create-harness-vibe-coding 0.8.13 → 0.8.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/CHANGELOG.md +174 -0
  2. package/README-CN.md +110 -107
  3. package/README.md +93 -44
  4. package/package.json +2 -1
  5. package/src/generator.js +609 -489
  6. package/src/index.js +5 -5
  7. package/templates/common/.claude/agents/architect-manager.md +1 -0
  8. package/templates/common/.claude/agents/architect.md +2 -1
  9. package/templates/common/.claude/agents/codebase-explorer.md +1 -0
  10. package/templates/common/.claude/agents/context-master.md +2 -1
  11. package/templates/common/.claude/agents/debugger.md +1 -0
  12. package/templates/common/.claude/agents/docs-researcher.md +2 -1
  13. package/templates/common/.claude/agents/explore-manager.md +1 -0
  14. package/templates/common/.claude/agents/implement-manager.md +1 -0
  15. package/templates/common/.claude/agents/implementer.md +1 -0
  16. package/templates/common/.claude/agents/memory-master.md +2 -1
  17. package/templates/common/.claude/agents/planner.md +3 -2
  18. package/templates/common/.claude/agents/reflector.md +1 -0
  19. package/templates/common/.claude/agents/researcher.md +1 -0
  20. package/templates/common/.claude/agents/review-manager.md +1 -0
  21. package/templates/common/.claude/agents/reviewer.md +2 -1
  22. package/templates/common/.claude/agents/task-scribe.md +1 -0
  23. package/templates/common/.claude/agents/tdd-guide.md +5 -4
  24. package/templates/common/.claude/agents/test-writer.md +6 -5
  25. package/templates/common/.claude/agents/verifier.md +1 -0
  26. package/templates/common/.claude/commands/wf-auto-spark.md +16 -0
  27. package/templates/common/.claude/commands/wf-auto.md +16 -0
  28. package/templates/{optional/skills/browser-e2e/.opencode → common/.claude}/commands/wf-browser.md +3 -2
  29. package/templates/common/.claude/commands/wf-help.md +9 -5
  30. package/templates/common/.claude/commands/wf-learn.md +16 -0
  31. package/templates/common/.claude/commands/wf-max.md +20 -0
  32. package/templates/common/.claude/commands/wf-readme.md +16 -0
  33. package/templates/common/.claude/commands/wf-remove.md +16 -0
  34. package/templates/common/.claude/commands/wf-review.md +16 -0
  35. package/templates/common/.claude/commands/wf-update.md +68 -10
  36. package/templates/common/.claude/commands/wf.md +16 -0
  37. package/templates/common/.claude/rules/ecc/common.md +6 -5
  38. package/templates/common/.claude/skills/subagent-orchestrator/SKILL.md +12 -6
  39. package/templates/common/.claude/skills/tdd/SKILL.md +5 -5
  40. package/templates/common/.claude/skills/wf/SKILL.md +13 -5
  41. package/templates/common/.claude/skills/wf-agents-docs/SKILL.md +119 -0
  42. package/templates/common/.claude/skills/wf-auto/SKILL.md +27 -7
  43. package/templates/common/.claude/skills/wf-auto-spark/SKILL.md +12 -5
  44. package/templates/common/.claude/skills/wf-browser/SKILL.md +176 -0
  45. package/templates/common/.claude/skills/wf-help/SKILL.md +30 -0
  46. package/templates/common/.claude/skills/wf-learn/SKILL.md +6 -0
  47. package/templates/common/.claude/skills/wf-max/SKILL.md +43 -14
  48. package/templates/common/.claude/skills/wf-readme/SKILL.md +8 -2
  49. package/templates/common/.claude/skills/wf-remove/SKILL.md +6 -0
  50. package/templates/common/.claude/skills/wf-review/SKILL.md +10 -3
  51. package/templates/common/.claude/skills/wf-update/SKILL.md +41 -4
  52. package/templates/common/.codex/config.toml +3 -5
  53. package/templates/common/.harness-version +326 -131
  54. package/templates/common/.opencode/agents/architect-manager.md +8 -1
  55. package/templates/common/.opencode/agents/architect.md +2 -1
  56. package/templates/common/.opencode/agents/codebase-explorer.md +1 -0
  57. package/templates/common/.opencode/agents/context-master.md +2 -1
  58. package/templates/common/.opencode/agents/debugger.md +1 -0
  59. package/templates/common/.opencode/agents/docs-researcher.md +2 -1
  60. package/templates/common/.opencode/agents/explore-manager.md +11 -1
  61. package/templates/common/.opencode/agents/implement-manager.md +6 -3
  62. package/templates/common/.opencode/agents/implementer.md +1 -0
  63. package/templates/common/.opencode/agents/memory-master.md +2 -1
  64. package/templates/common/.opencode/agents/planner.md +3 -2
  65. package/templates/common/.opencode/agents/reflector.md +1 -0
  66. package/templates/common/.opencode/agents/researcher.md +1 -0
  67. package/templates/common/.opencode/agents/review-manager.md +6 -2
  68. package/templates/common/.opencode/agents/reviewer.md +2 -1
  69. package/templates/common/.opencode/agents/task-scribe.md +1 -0
  70. package/templates/common/.opencode/agents/tdd-guide.md +5 -4
  71. package/templates/common/.opencode/agents/test-writer.md +6 -5
  72. package/templates/common/.opencode/agents/verifier.md +1 -0
  73. package/templates/common/.opencode/commands/wf-auto-spark.md +3 -2
  74. package/templates/common/.opencode/commands/wf-auto.md +3 -2
  75. package/templates/common/.opencode/commands/wf-browser.md +16 -0
  76. package/templates/common/.opencode/commands/wf-help.md +9 -5
  77. package/templates/common/.opencode/commands/wf-learn.md +3 -2
  78. package/templates/common/.opencode/commands/wf-max.md +12 -6
  79. package/templates/common/.opencode/commands/wf-readme.md +3 -2
  80. package/templates/common/.opencode/commands/wf-remove.md +3 -2
  81. package/templates/common/.opencode/commands/wf-review.md +3 -2
  82. package/templates/common/.opencode/commands/wf-update.md +68 -10
  83. package/templates/common/.opencode/commands/wf.md +3 -2
  84. package/templates/common/CLAUDE.md +15 -13
  85. package/templates/common/Harness/MEMORY.md +24 -21
  86. package/templates/common/Harness/README.md +50 -47
  87. package/templates/common/Harness/ownership.manifest.json +878 -0
  88. package/templates/common/Harness/{architecture.md → project/architecture.md} +1 -1
  89. package/templates/common/Harness/research/README.md +3 -3
  90. package/templates/common/Harness/scripts/archive-tasks.mjs +12 -220
  91. package/templates/common/Harness/scripts/context-budget.mjs +95 -0
  92. package/templates/common/Harness/scripts/l2-cache-telemetry.mjs +703 -0
  93. package/templates/common/Harness/scripts/scan-clean.mjs +16 -12
  94. package/templates/common/Harness/scripts/task-state.mjs +889 -0
  95. package/templates/common/Harness/scripts/validate-harness.mjs +553 -191
  96. package/templates/common/Harness/scripts/wf-remove.mjs +61 -35
  97. package/templates/common/Harness/scripts/wf-update-check.mjs +358 -45
  98. package/templates/common/Harness/settings.json +43 -0
  99. package/templates/common/Harness/{ECC-GUIDE.md → specs/guides/ECC-GUIDE.md} +4 -4
  100. package/templates/common/Harness/{SETUP.md → specs/guides/SETUP.md} +34 -37
  101. package/templates/common/Harness/{extension.md → specs/guides/extension.md} +3 -3
  102. package/templates/common/Harness/{lifecycle.md → specs/guides/lifecycle.md} +2 -2
  103. package/templates/common/Harness/specs/protocols/TASK_ARCHIVE.md +76 -0
  104. package/templates/common/Harness/{agent-workflow.md → specs/runtime/agent-workflow.md} +6 -6
  105. package/templates/common/Harness/{context-loading.md → specs/runtime/context-loading.md} +85 -21
  106. package/templates/common/Harness/{dispatch.md → specs/runtime/dispatch.md} +4 -3
  107. package/templates/common/Harness/{subagents.md → specs/runtime/subagents.md} +19 -10
  108. package/templates/common/Harness/{WF-AUTO-SPARK.md → specs/workflows/WF-AUTO-SPARK.md} +2 -2
  109. package/templates/common/Harness/{WF-AUTO.md → specs/workflows/WF-AUTO.md} +12 -7
  110. package/templates/common/Harness/{WF-KERNEL.md → specs/workflows/WF-KERNEL.md} +11 -1
  111. package/templates/common/Harness/{WF-MAX.md → specs/workflows/WF-MAX.md} +40 -7
  112. package/templates/common/Harness/specs/workflows/WF-STATE.md +141 -0
  113. package/templates/common/Harness/{WF.md → specs/workflows/WF.md} +12 -1
  114. package/templates/common/README.md +8 -6
  115. package/templates/common/memory/startup-hints.md +19 -17
  116. package/templates/common/opencode.json +1 -0
  117. package/templates/optional/catalog.json +2 -9
  118. package/templates/optional/skills/github-pr-review/.claude/skills/github-pr-review/SKILL.md +1 -1
  119. package/templates/optional/skills/python-backend/.claude/skills/python-backend/SKILL.md +1 -1
  120. package/templates/optional/skills/ts-react-frontend/.claude/skills/ts-react-frontend/SKILL.md +1 -1
  121. package/templates/optional/skills/ui-ux-review/.claude/skills/ui-ux-review/SKILL.md +1 -1
  122. package/templates/common/Harness/TASK_ARCHIVE.md +0 -56
  123. package/templates/common/Harness/WF-STATE.md +0 -83
  124. package/templates/optional/skills/browser-e2e/.claude/skills/browser-e2e/SKILL.md +0 -42
  125. package/templates/optional/skills/browser-e2e/.claude/skills/wf-browser/SKILL.md +0 -194
  126. package/templates/optional/skills/browser-e2e/Harness/workflows/browser-e2e.md +0 -119
  127. /package/templates/common/Harness/{ACCEPTANCE_PROTOCOL.md → specs/protocols/ACCEPTANCE_PROTOCOL.md} +0 -0
  128. /package/templates/common/Harness/{AGENT_ISOLATION.md → specs/protocols/AGENT_ISOLATION.md} +0 -0
  129. /package/templates/common/Harness/{DEBUG_PROTOCOL.md → specs/protocols/DEBUG_PROTOCOL.md} +0 -0
  130. /package/templates/common/Harness/{HARNESS_BRIDGE.md → specs/protocols/HARNESS_BRIDGE.md} +0 -0
  131. /package/templates/common/Harness/{MEMORY_PROTOCOL.md → specs/protocols/MEMORY_PROTOCOL.md} +0 -0
  132. /package/templates/common/Harness/{TDD-GUIDE.md → specs/protocols/TDD-GUIDE.md} +0 -0
  133. /package/templates/common/Harness/{WF-AUTO-ANGLES.md → specs/workflows/WF-AUTO-ANGLES.md} +0 -0
@@ -67,7 +67,7 @@ State in this repo should be explicit, serializable, and owned by one layer.
67
67
 
68
68
  - **Location**: `src/prompts.js`
69
69
  - **Responsibility**: Ask basic interactive npx questions: project name and target directory.
70
- - **Does NOT handle**: Agent-link install intake. That matrix is read by coding agents from `README.md` and `Harness/SETUP.md`.
70
+ - **Does NOT handle**: Agent-link install intake. That matrix is read by coding agents from `README.md` and `Harness/specs/guides/SETUP.md`.
71
71
 
72
72
  ### 4.3 Generator Core
73
73
 
@@ -21,7 +21,7 @@ Built-in agents:
21
21
  - `.claude/agents/researcher.md`: product, market, open-source, dependency, pricing, policy, and ecosystem research.
22
22
  - `.claude/agents/docs-researcher.md`: official docs, API, SDK, config, limits, errors, and examples verification.
23
23
 
24
- For multi-agent research plus build work, create the dispatch table in `Harness/tasks/<task-id>/PLAN.md` and follow `Harness/dispatch.md`.
24
+ For multi-agent research plus build work, create the dispatch table in `Harness/tasks/<task-id>/PLAN.md` and follow `Harness/specs/runtime/dispatch.md`.
25
25
 
26
26
  Research Agent input:
27
27
 
@@ -107,11 +107,11 @@ Use these patterns when turning research into PRD or feature docs:
107
107
  - Research process, queries, and limitations: this file or `Harness/tasks/<task-id>/PLAN.md`.
108
108
  - Final research decisions: [research-results.md](research-results.md).
109
109
  - Product scope: [PRD.md](PRD.md).
110
- - Architecture consequences: `Harness/architecture.md`.
110
+ - Architecture consequences: `Harness/project/architecture.md`.
111
111
 
112
112
  ## Architecture Decision References
113
113
 
114
- When filling `Harness/architecture.md` and `Harness/research/research-results.md`, use these high-trust sources as starting points. Search within them; do not read them whole.
114
+ When filling `Harness/project/architecture.md` and `Harness/research/research-results.md`, use these high-trust sources as starting points. Search within them; do not read them whole.
115
115
 
116
116
  ### System Design & Architecture Patterns
117
117
 
@@ -1,26 +1,21 @@
1
1
  #!/usr/bin/env node
2
- import fs from 'node:fs';
2
+ import { spawnSync } from 'node:child_process';
3
3
  import path from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
4
5
 
5
- const root = process.cwd();
6
- const tasksDir = path.join(root, 'Harness', 'tasks');
7
- const archiveDir = path.join(tasksDir, '_archive');
8
-
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = path.dirname(__filename);
8
+ const taskState = path.join(__dirname, 'task-state.mjs');
9
9
  const args = process.argv.slice(2);
10
- const flags = {
11
- dryRun: !args.includes('--apply'),
12
- apply: args.includes('--apply'),
13
- json: args.includes('--json'),
14
- keep: parseInt(args.includes('--keep') ? args[args.indexOf('--keep') + 1] : '5', 10),
15
- task: args.includes('--task') ? args[args.indexOf('--task') + 1] : null,
16
- };
17
10
 
18
11
  if (args.includes('--help') || args.includes('-h')) {
19
12
  console.log(`Usage: node Harness/scripts/archive-tasks.mjs [options]
20
13
 
14
+ Compatibility entry for: node Harness/scripts/task-state.mjs archive [options]
15
+
21
16
  Options:
22
17
  --dry-run Show what would be archived without moving files (default)
23
- --apply Execute the archive moves
18
+ --apply Execute archive moves
24
19
  --keep <n> Keep at most <n> non-archived tasks (default: 5)
25
20
  --task <id> Archive only the specified task
26
21
  --json Output results as JSON
@@ -28,212 +23,9 @@ Options:
28
23
  process.exit(0);
29
24
  }
30
25
 
31
- const RESERVED = new Set(['_template', '_archive', 'auto']);
32
- const NEVER_ARCHIVE_STATUSES = new Set([
33
- 'active', 'blocked', 'in_progress', 'running', 'pending', 'needs-user-decision',
34
- ]);
35
- const SAFE_ARCHIVE_STATUSES = new Set([
36
- 'complete', 'verified', 'archived', 'abandoned', 'obsolete', 'done', 'closed', 'closeout',
37
- ]);
38
-
39
- function readStateJson(taskDir) {
40
- const statePath = path.join(tasksDir, taskDir, 'STATE.json');
41
- if (!fs.existsSync(statePath)) return null;
42
- try {
43
- return JSON.parse(fs.readFileSync(statePath, 'utf8'));
44
- } catch {
45
- return null;
46
- }
47
- }
48
-
49
- function readProgressPhase(taskDir) {
50
- const progressPath = path.join(tasksDir, taskDir, 'PROGRESS.md');
51
- if (!fs.existsSync(progressPath)) return null;
52
- const text = fs.readFileSync(progressPath, 'utf8');
53
- // Match "- Phase: X", "Phase: X", or "Current: X" (task capsules use all three).
54
- const match = text.match(/^(?:-\s*)?(?:Phase|Current(?: phase)?):\s*([A-Za-z_-]+)/mi);
55
- return match ? match[1].trim().toLowerCase() : null;
56
- }
57
-
58
- function canArchive(taskDir) {
59
- if (RESERVED.has(taskDir)) return { ok: false, reason: 'reserved directory' };
60
- if (taskDir.startsWith('_')) return { ok: false, reason: 'system directory' };
61
-
62
- const state = readStateJson(taskDir);
63
- const status = state?.status?.toLowerCase() || '';
64
- const phase = state?.phase?.toLowerCase() || '';
65
-
66
- if (NEVER_ARCHIVE_STATUSES.has(status)) {
67
- return { ok: false, reason: `status "${status}" is never auto-archived` };
68
- }
69
- if (NEVER_ARCHIVE_STATUSES.has(phase)) {
70
- return { ok: false, reason: `phase "${phase}" is never auto-archived` };
71
- }
72
-
73
- if (SAFE_ARCHIVE_STATUSES.has(status) || SAFE_ARCHIVE_STATUSES.has(phase)) {
74
- return { ok: true, reason: `status/phase allows archive` };
75
- }
76
-
77
- // Fallback: check PROGRESS.md phase
78
- const progressPhase = readProgressPhase(taskDir);
79
- if (progressPhase && SAFE_ARCHIVE_STATUSES.has(progressPhase)) {
80
- return { ok: true, reason: `PROGRESS.md phase "${progressPhase}" allows archive` };
81
- }
82
- if (progressPhase && NEVER_ARCHIVE_STATUSES.has(progressPhase)) {
83
- return { ok: false, reason: `PROGRESS.md phase "${progressPhase}" is never auto-archived` };
84
- }
85
-
86
- return { ok: false, reason: 'status indeterminate — requires manual review' };
87
- }
88
-
89
- function scandir(dir) {
90
- if (!fs.existsSync(dir)) return [];
91
- return fs.readdirSync(dir, { withFileTypes: true })
92
- .filter(e => e.isDirectory())
93
- .map(e => e.name);
94
- }
95
-
96
- function safeResolve(...segments) {
97
- const resolved = path.resolve(root, ...segments);
98
- const normalized = resolved.replace(/\\/g, '/');
99
- const tasksPrefix = tasksDir.replace(/\\/g, '/');
100
- if (!normalized.startsWith(tasksPrefix + '/') && normalized !== tasksPrefix) {
101
- throw new Error(`Path "${resolved}" is outside Harness/tasks/ — aborting`);
102
- }
103
- return resolved;
104
- }
105
-
106
- function mkdirIfMissing(dir) {
107
- if (!fs.existsSync(dir)) {
108
- if (flags.apply) {
109
- fs.mkdirSync(dir, { recursive: true });
110
- }
111
- return true;
112
- }
113
- return false;
114
- }
115
-
116
- function resultsToJson(results) {
117
- return JSON.stringify(results, null, 2);
118
- }
119
-
120
- // Main
121
- const taskDirs = scandir(tasksDir).filter(d => !RESERVED.has(d));
122
- const candidates = flags.task
123
- ? taskDirs.filter(d => d === flags.task)
124
- : taskDirs;
125
-
126
- if (flags.task && candidates.length === 0) {
127
- const msg = `Task "${flags.task}" not found in Harness/tasks/`;
128
- if (flags.json) console.log(resultsToJson({ error: msg }));
129
- else console.error(msg);
130
- process.exit(1);
131
- }
132
-
133
- const results = [];
134
- const skipped = [];
135
-
136
- // Read active task from PROGRESS.md
137
- const progressPath = path.join(root, 'Harness', 'PROGRESS.md');
138
- let activeTask = null;
139
- if (fs.existsSync(progressPath)) {
140
- const text = fs.readFileSync(progressPath, 'utf8');
141
- const match = text.match(/## Active Task\s*\n+\s*-\s*(.+)/);
142
- if (match) activeTask = match[1].trim();
143
- }
144
-
145
- const archiveable = [];
146
- for (const dir of candidates) {
147
- if (dir === activeTask) {
148
- skipped.push({ dir, reason: 'active task' });
149
- continue;
150
- }
151
- const result = canArchive(dir);
152
- if (result.ok) {
153
- archiveable.push(dir);
154
- } else {
155
- skipped.push({ dir, reason: result.reason });
156
- }
157
- }
158
-
159
- // Sort by modified time (oldest first) to archive oldest first
160
- archiveable.sort((a, b) => {
161
- const statA = fs.statSync(path.join(tasksDir, a));
162
- const statB = fs.statSync(path.join(tasksDir, b));
163
- return statA.mtimeMs - statB.mtimeMs;
26
+ const result = spawnSync(process.execPath, [taskState, 'archive', ...args], {
27
+ cwd: process.cwd(),
28
+ stdio: 'inherit',
164
29
  });
165
30
 
166
- // Determine how many to archive: keep `flags.keep` non-archived
167
- const currentNonArchived = taskDirs.length;
168
- const toArchiveCount = flags.task
169
- ? archiveable.length
170
- : Math.max(0, currentNonArchived - flags.keep);
171
-
172
- const toArchive = archiveable.slice(0, toArchiveCount);
173
-
174
- for (const dir of toArchive) {
175
- const stat = fs.statSync(path.join(tasksDir, dir));
176
- const year = new Date(stat.mtimeMs).getFullYear().toString();
177
- const src = safeResolve('Harness', 'tasks', dir);
178
- const destDir = safeResolve('Harness', 'tasks', '_archive', year);
179
- const dest = path.join(destDir, dir);
180
-
181
- if (flags.apply) {
182
- mkdirIfMissing(destDir);
183
- fs.renameSync(src, dest);
184
-
185
- // Update STATE.json status to archived
186
- const statePath = path.join(dest, 'STATE.json');
187
- if (fs.existsSync(statePath)) {
188
- try {
189
- const state = JSON.parse(fs.readFileSync(statePath, 'utf8'));
190
- state.status = 'archived';
191
- state.phase = 'archived';
192
- state.updatedAt = new Date().toISOString();
193
- fs.writeFileSync(statePath, JSON.stringify(state, null, 2) + '\n');
194
- } catch {
195
- // If STATE.json is broken, leave it alone
196
- }
197
- }
198
-
199
- results.push({ dir, year, action: 'archived', status: 'moved' });
200
- } else {
201
- results.push({ dir, year, action: 'would-archive', status: 'dry-run' });
202
- }
203
- }
204
-
205
- for (const s of skipped) {
206
- results.push({ dir: s.dir, year: null, action: 'skipped', status: s.reason });
207
- }
208
-
209
- // Update INDEX.md
210
- const indexPath = path.join(archiveDir, 'INDEX.md');
211
- const indexEntries = results
212
- .filter(r => r.action === 'archived')
213
- .map(r => `| ${r.dir} | ${r.year} | ${new Date().toISOString().split('T')[0]} |`);
214
-
215
- if (indexEntries.length > 0 && flags.apply) {
216
- mkdirIfMissing(archiveDir);
217
- const existingIndex = fs.existsSync(indexPath)
218
- ? fs.readFileSync(indexPath, 'utf8')
219
- : '| Task | Year | Archived |\n|------|------|----------|\n';
220
- const newEntries = indexEntries.join('\n') + '\n';
221
- fs.writeFileSync(indexPath, existingIndex + newEntries);
222
- }
223
-
224
- if (flags.json) {
225
- console.log(resultsToJson({
226
- scanned: candidates.length,
227
- archiveable: archiveable.length,
228
- toArchive: toArchive.length,
229
- skipped: skipped.length,
230
- dryRun: flags.dryRun,
231
- results,
232
- }));
233
- } else {
234
- if (flags.dryRun) console.log('[DRY RUN] No files moved. Use --apply to execute.');
235
- console.log(`Scanned: ${candidates.length}, Archiveable: ${archiveable.length}, To archive: ${toArchive.length}, Skipped: ${skipped.length}`);
236
- for (const r of results) {
237
- console.log(` ${r.action}: ${r.dir} (${r.status})${r.year ? ' → _archive/' + r.year : ''}`);
238
- }
239
- }
31
+ process.exit(result.status ?? 1);
@@ -0,0 +1,95 @@
1
+ #!/usr/bin/env node
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+
5
+ const args = new Set(process.argv.slice(2));
6
+ const rootArgIndex = process.argv.indexOf('--root');
7
+ const root = rootArgIndex !== -1 && process.argv[rootArgIndex + 1]
8
+ ? path.resolve(process.argv[rootArgIndex + 1])
9
+ : process.cwd();
10
+ const json = args.has('--json');
11
+
12
+ const routes = [
13
+ {
14
+ id: 'thin-startup',
15
+ maxBytes: 12500,
16
+ paths: [
17
+ 'CLAUDE.md',
18
+ 'Harness/memory/startup-hints.md',
19
+ ],
20
+ },
21
+ {
22
+ id: 'wf-router-prefix',
23
+ maxBytes: 42000,
24
+ paths: [
25
+ 'CLAUDE.md',
26
+ 'Harness/MEMORY.md',
27
+ 'Harness/README.md',
28
+ ],
29
+ },
30
+ {
31
+ id: 'wf-light-prefix',
32
+ maxBytes: 58000,
33
+ paths: [
34
+ 'CLAUDE.md',
35
+ 'Harness/MEMORY.md',
36
+ 'Harness/README.md',
37
+ 'Harness/specs/workflows/WF.md',
38
+ 'Harness/specs/workflows/WF-KERNEL.md',
39
+ ],
40
+ },
41
+ {
42
+ id: 'cache-diagnostics-route',
43
+ maxBytes: 36000,
44
+ paths: [
45
+ 'Harness/specs/runtime/context-loading.md',
46
+ 'Harness/specs/workflows/WF-KERNEL.md',
47
+ 'Harness/specs/runtime/dispatch.md',
48
+ '.claude/skills/wf-agents-docs/SKILL.md',
49
+ ],
50
+ },
51
+ ];
52
+
53
+ function readBytes(rel) {
54
+ const abs = path.join(root, ...rel.split('/'));
55
+ if (!fs.existsSync(abs)) return { missing: true, bytes: 0 };
56
+ return { missing: false, bytes: Buffer.byteLength(fs.readFileSync(abs)) };
57
+ }
58
+
59
+ function routeResult(route) {
60
+ const files = route.paths.map(rel => ({ path: rel, ...readBytes(rel) }));
61
+ const totalBytes = files.reduce((sum, file) => sum + file.bytes, 0);
62
+ const missing = files.filter(file => file.missing).map(file => file.path);
63
+ return {
64
+ id: route.id,
65
+ maxBytes: route.maxBytes,
66
+ totalBytes,
67
+ approxTokens: Math.ceil(totalBytes / 4),
68
+ status: missing.length > 0 || totalBytes > route.maxBytes ? 'FAIL' : 'PASS',
69
+ missing,
70
+ files,
71
+ };
72
+ }
73
+
74
+ const results = routes.map(routeResult);
75
+ const ok = results.every(result => result.status === 'PASS');
76
+
77
+ if (json) {
78
+ console.log(JSON.stringify({
79
+ ok,
80
+ root,
81
+ note: 'Budgets are route-profile regression guards, not runtime exclusion rules. approxTokens is bytes/4, not provider token accounting.',
82
+ results,
83
+ }, null, 2));
84
+ } else {
85
+ console.log('Context budgets are route-profile regression guards, not runtime exclusion rules.');
86
+ for (const result of results) {
87
+ console.log(`${result.status} ${result.id}: ${result.totalBytes}/${result.maxBytes} bytes (~${result.approxTokens} tokens)`);
88
+ for (const file of result.files) {
89
+ const state = file.missing ? 'MISSING' : `${file.bytes} bytes`;
90
+ console.log(` - ${file.path}: ${state}`);
91
+ }
92
+ }
93
+ }
94
+
95
+ process.exit(ok ? 0 : 1);