Skip to content

Polish: npm run cost + unified stub gating#5

Merged
dadachi merged 1 commit intomainfrom
feat/day2-polish-and-cost
Apr 21, 2026
Merged

Polish: npm run cost + unified stub gating#5
dadachi merged 1 commit intomainfrom
feat/day2-polish-and-cost

Conversation

@dadachi
Copy link
Copy Markdown
Contributor

@dadachi dadachi commented Apr 21, 2026

Summary

Small quality-of-life pass building on the Day 2 merge.

  • npm run cost — new scripts/cost.sh parses tmp/trace/*.log for usage: N in / M out lines, aggregates per sub-agent, prints Opus 4.7 cost estimate. Useful while the Anthropic console lags 5–15 min.
  • src/stub.ts — single isStub(agent) helper. Honors NATEMPLATE_STUB_ALL=1 (everything stubbed) or NATEMPLATE_STUB_<AGENT>=1 (per-sub-agent override).
  • Test script now sets NATEMPLATE_STUB_ALL=1 so future sub-agents inherit stub behavior without updating package.json each time.
  • Planner refactor — replaces inline process.env[...] check with isStub("planner"). Matches the shape Day 3's rails worker will use.

Gitignored docs-private/PLAN.md also gets a "Status" summary + "Execution utilities" section in the working copy (not in this PR, since it's out-of-tree).

Test plan

  • npm run ci — 5/5 tests pass under NATEMPLATE_STUB_ALL=1
  • npm run dev -- "<spec>" — real planner runs correctly with NATEMPLATE_STUB_ALL unset
  • NATEMPLATE_STUB_ALL=1 npm run dev -- "<spec>" — planner takes stub path, trace log confirms
  • npm run cost — prints table with planner row summing prior test-run usages; returns 0 gracefully when no traces exist yet

- scripts/cost.sh aggregates `usage: N in / M out` lines across
  tmp/trace/*.log and prints per-agent token totals + Opus 4.7 cost
  estimate. Exposed via `npm run cost`.
- src/stub.ts provides isStub(agent): single entry point for the
  stub-mode check. Honors NATEMPLATE_STUB_ALL=1 (every sub-agent
  stubbed) or NATEMPLATE_STUB_<AGENT>=1 (per-sub-agent override).
- package.json test script now sets NATEMPLATE_STUB_ALL=1 so future
  sub-agents inherit the behavior without touching the script.
- Planner refactored to call isStub("planner") instead of reading
  the env var directly.

No behavior change for CI (still runs stubbed); docs-private/PLAN.md
gets a Status summary + Execution utilities section in a follow-up.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@dadachi dadachi merged commit 0907cad into main Apr 21, 2026
1 check passed
@dadachi dadachi deleted the feat/day2-polish-and-cost branch April 21, 2026 03:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant