issue-256: Implement extensions/vision/src/usage.ts (usage mapping + peak/off-peak cost) #270
No reviewers
Labels
No labels
bug
chore
documentation
enhancement
feature
ready
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
david/pi-extensions-and-skills!270
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/issue-256/implement-extensions-vision-src-usage-ts-usage-map"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
256: Implement extensions/vision/src/usage.ts (usage mapping + peak/off-peak cost)
Closes #256 — 256.
Generated in 30m 28s.
Review findings
I'll start by exploring the repository structure and reading the relevant files.
Now let me look at the project's build/test setup and a sibling module to confirm conventions.
Let me check a sibling module's imports and whether any tsconfig exists.
I now have full context. Let me analyze the two findings:
Finding 1 (
usage.test.ts:8) — a concrete, safe, minimal fix:Usageis declared and exported inpi-types.ts, but the test imports it fromusage.tswhich only does a type-only import (no re-export). The siblingimages.test.tscorrectly importstype ValidationLimitsfrom the module that exports it (./images.ts). I'll move theUsageimport to its real home.Finding 2 (
pi-types.ts:1) — the drift concern. The suggested fix is adding a repo-widetsc --noEmitgate. But there's no tsconfig for vision, notscin the rootnode_modules, and pi-ai's canonicalUsageisn't resolvable on disk. Adding repo-wide typecheck infrastructure is speculative and risky in a single pass — out of scope for this milestone. I'll carry it forward.Let me apply the finding-1 fix:
Now let me run the test gate. First the vision tests directly to verify my change, then the full
npm testgate.All 56 vision tests pass. Now the full
npm testgate:Full gate is green: 936 tests, 935 pass, 0 fail, 1 skipped — no regression from my change. Let me confirm the final state of the edited import block.
The fix is applied cleanly and the full test gate is green. Now I'll emit the annotated findings document.
Review Findings — issue-256
Summary
Fixed the one concrete, in-scope finding:
usage.test.tsimportedtype Usagefrom./usage.ts, butusage.tsnever re-exportsUsage(it only does a type-onlyimport). Moved theUsageimport to its real home,./pi-types.ts, matching the sibling convention (images.test.tsimportstype ValidationLimitsfrom./images.ts). The implementation itself is correct; the only diff change is the single-line import. Carried forward thepi-types.tsdrift finding because adding a repo-widetsc --noEmitgate is out of scope for this milestone and risky in a single pass (no vision tsconfig, no roottsc, and pi-ai's canonicalUsageisn't resolvable on disk). Gates:npm test= 936 tests, 935 pass, 0 fail, 1 skipped (a penpot test gated on an env var) — unchanged, no regressions.Critical
High
Medium
Low
extensions/vision/src/usage.test.ts:8— the test importstype Usagefrom./usage.ts, butusage.tsnever exportsUsage(line 26 only doesimport type { Usage } from "./pi-types.ts"— a type-only import, not a re-export). The test passes today only because Node's type-stripping silently dropstype-annotated named imports without checking that the export exists; under any futuretsc --noEmitgate this file would fail with TS2305. The sibling tests already do the right thing (e.g.images.test.tsimportstype ValidationLimitsfrom the module that actually exports it). Suggested fix: import the type from its real home —import { isPeak, mapUsage, DEEPSEEK_FLASH_RATES, type DeepSeekUsage } from "./usage.ts";should becomeimport { isPeak, mapUsage, DEEPSEEK_FLASH_RATES, type DeepSeekUsage } from "./usage.ts";andimport type { Usage } from "./pi-types.ts";— or add aexport type { Usage } from "./pi-types.ts"re-export inusage.ts.extensions/vision/src/pi-types.ts:1—Usageis a hand-maintained structural duplicate of pi-ai's canonicalinterface Usage(the file's own docstring says "Keep these in lockstep"). Because there is notsc/typecheck gate in the repo, a silent drift between this local declaration and pi-ai's realUsageat runtime would not be caught by any automated check — the only current safeguard is the docstring and manual verification (which I did againstnode_modules/.../pi-ai/dist/types.d.ts: the fields currently match exactly). Suggested fix: add a lightweighttsc --noEmitgate to the test script (or a small runtime test that cross-checks the local shape), which would also fix the flagged import inusage.test.ts:8at the same time.