specrails-core 5.3.0 → 5.5.0

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 (156) hide show
  1. package/README.md +2 -0
  2. package/dist/agent-runtime/capabilities.d.ts +28 -0
  3. package/dist/agent-runtime/capabilities.js +81 -0
  4. package/dist/agent-runtime/capabilities.js.map +1 -0
  5. package/dist/agent-runtime/cli-executor.d.ts +9 -0
  6. package/dist/agent-runtime/cli-executor.js +109 -34
  7. package/dist/agent-runtime/cli-executor.js.map +1 -1
  8. package/dist/agent-runtime/cli-process.d.ts +1 -0
  9. package/dist/agent-runtime/cli-process.js +13 -2
  10. package/dist/agent-runtime/cli-process.js.map +1 -1
  11. package/dist/agent-runtime/cli.d.ts +1 -0
  12. package/dist/agent-runtime/cli.js +60 -11
  13. package/dist/agent-runtime/cli.js.map +1 -1
  14. package/dist/agent-runtime/codex-schema.d.ts +4 -0
  15. package/dist/agent-runtime/codex-schema.js +31 -0
  16. package/dist/agent-runtime/codex-schema.js.map +1 -0
  17. package/dist/agent-runtime/compact/architect.d.ts +349 -0
  18. package/dist/agent-runtime/compact/architect.js +371 -0
  19. package/dist/agent-runtime/compact/architect.js.map +1 -0
  20. package/dist/agent-runtime/compact/chat-client.d.ts +83 -0
  21. package/dist/agent-runtime/compact/chat-client.js +307 -0
  22. package/dist/agent-runtime/compact/chat-client.js.map +1 -0
  23. package/dist/agent-runtime/compact/developer.d.ts +160 -0
  24. package/dist/agent-runtime/compact/developer.js +823 -0
  25. package/dist/agent-runtime/compact/developer.js.map +1 -0
  26. package/dist/agent-runtime/compact/environment.d.ts +62 -0
  27. package/dist/agent-runtime/compact/environment.js +213 -0
  28. package/dist/agent-runtime/compact/environment.js.map +1 -0
  29. package/dist/agent-runtime/compact/exit-code-honesty.d.ts +8 -0
  30. package/dist/agent-runtime/compact/exit-code-honesty.js +28 -0
  31. package/dist/agent-runtime/compact/exit-code-honesty.js.map +1 -0
  32. package/dist/agent-runtime/compact/guarded-loop.d.ts +73 -0
  33. package/dist/agent-runtime/compact/guarded-loop.js +320 -0
  34. package/dist/agent-runtime/compact/guarded-loop.js.map +1 -0
  35. package/dist/agent-runtime/compact/prompt-inputs.d.ts +42 -0
  36. package/dist/agent-runtime/compact/prompt-inputs.js +59 -0
  37. package/dist/agent-runtime/compact/prompt-inputs.js.map +1 -0
  38. package/dist/agent-runtime/compact/reviewer.d.ts +24 -0
  39. package/dist/agent-runtime/compact/reviewer.js +178 -0
  40. package/dist/agent-runtime/compact/reviewer.js.map +1 -0
  41. package/dist/agent-runtime/compact/step.d.ts +70 -0
  42. package/dist/agent-runtime/compact/step.js +136 -0
  43. package/dist/agent-runtime/compact/step.js.map +1 -0
  44. package/dist/agent-runtime/compact/test-reachability.d.ts +30 -0
  45. package/dist/agent-runtime/compact/test-reachability.js +147 -0
  46. package/dist/agent-runtime/compact/test-reachability.js.map +1 -0
  47. package/dist/agent-runtime/config.d.ts +4 -0
  48. package/dist/agent-runtime/config.js +146 -15
  49. package/dist/agent-runtime/config.js.map +1 -1
  50. package/dist/agent-runtime/core-host.d.ts +12 -4
  51. package/dist/agent-runtime/core-host.js +61 -21
  52. package/dist/agent-runtime/core-host.js.map +1 -1
  53. package/dist/agent-runtime/efficiency-summary.d.ts +67 -0
  54. package/dist/agent-runtime/efficiency-summary.js +52 -0
  55. package/dist/agent-runtime/efficiency-summary.js.map +1 -0
  56. package/dist/agent-runtime/efficiency-types.d.ts +60 -0
  57. package/dist/agent-runtime/efficiency-types.js +8 -0
  58. package/dist/agent-runtime/efficiency-types.js.map +1 -0
  59. package/dist/agent-runtime/efficiency.d.ts +5 -0
  60. package/dist/agent-runtime/efficiency.js +35 -0
  61. package/dist/agent-runtime/efficiency.js.map +1 -0
  62. package/dist/agent-runtime/evaluation-corpus.d.ts +13 -0
  63. package/dist/agent-runtime/evaluation-corpus.js +8 -0
  64. package/dist/agent-runtime/evaluation-corpus.js.map +1 -0
  65. package/dist/agent-runtime/evaluation.d.ts +43 -0
  66. package/dist/agent-runtime/evaluation.js +171 -0
  67. package/dist/agent-runtime/evaluation.js.map +1 -0
  68. package/dist/agent-runtime/executor-types.d.ts +71 -4
  69. package/dist/agent-runtime/executor-types.js +7 -2
  70. package/dist/agent-runtime/executor-types.js.map +1 -1
  71. package/dist/agent-runtime/executors.d.ts +1 -0
  72. package/dist/agent-runtime/executors.js +4 -0
  73. package/dist/agent-runtime/executors.js.map +1 -1
  74. package/dist/agent-runtime/graph/artifacts.d.ts +8 -22
  75. package/dist/agent-runtime/graph/artifacts.js +99 -73
  76. package/dist/agent-runtime/graph/artifacts.js.map +1 -1
  77. package/dist/agent-runtime/graph/nodes.d.ts +7 -2
  78. package/dist/agent-runtime/graph/nodes.js +207 -53
  79. package/dist/agent-runtime/graph/nodes.js.map +1 -1
  80. package/dist/agent-runtime/graph/roles.d.ts +11 -3
  81. package/dist/agent-runtime/graph/roles.js +109 -37
  82. package/dist/agent-runtime/graph/roles.js.map +1 -1
  83. package/dist/agent-runtime/graph/state.d.ts +10 -1
  84. package/dist/agent-runtime/graph/state.js +2 -1
  85. package/dist/agent-runtime/graph/state.js.map +1 -1
  86. package/dist/agent-runtime/guardrails.d.ts +15 -0
  87. package/dist/agent-runtime/guardrails.js +76 -0
  88. package/dist/agent-runtime/guardrails.js.map +1 -0
  89. package/dist/agent-runtime/index.d.ts +7 -1
  90. package/dist/agent-runtime/index.js +7 -1
  91. package/dist/agent-runtime/index.js.map +1 -1
  92. package/dist/agent-runtime/kimi-acp.d.ts +4 -0
  93. package/dist/agent-runtime/kimi-acp.js +20 -9
  94. package/dist/agent-runtime/kimi-acp.js.map +1 -1
  95. package/dist/agent-runtime/openai-executor.d.ts +33 -1
  96. package/dist/agent-runtime/openai-executor.js +76 -113
  97. package/dist/agent-runtime/openai-executor.js.map +1 -1
  98. package/dist/agent-runtime/openspec-tool-server.d.ts +1 -0
  99. package/dist/agent-runtime/openspec-tool-server.js +37 -0
  100. package/dist/agent-runtime/openspec-tool-server.js.map +1 -0
  101. package/dist/agent-runtime/openspec.d.ts +198 -0
  102. package/dist/agent-runtime/openspec.js +329 -0
  103. package/dist/agent-runtime/openspec.js.map +1 -0
  104. package/dist/agent-runtime/prompts.d.ts +24 -1
  105. package/dist/agent-runtime/prompts.js +112 -43
  106. package/dist/agent-runtime/prompts.js.map +1 -1
  107. package/dist/agent-runtime/provider-diagnostic.d.ts +2 -0
  108. package/dist/agent-runtime/provider-diagnostic.js +25 -0
  109. package/dist/agent-runtime/provider-diagnostic.js.map +1 -0
  110. package/dist/agent-runtime/repository-context.d.ts +25 -0
  111. package/dist/agent-runtime/repository-context.js +127 -0
  112. package/dist/agent-runtime/repository-context.js.map +1 -0
  113. package/dist/agent-runtime/review-context.d.ts +14 -0
  114. package/dist/agent-runtime/review-context.js +41 -0
  115. package/dist/agent-runtime/review-context.js.map +1 -0
  116. package/dist/agent-runtime/role-routing.d.ts +10 -0
  117. package/dist/agent-runtime/role-routing.js +30 -0
  118. package/dist/agent-runtime/role-routing.js.map +1 -0
  119. package/dist/agent-runtime/role-state.d.ts +19 -0
  120. package/dist/agent-runtime/role-state.js +24 -0
  121. package/dist/agent-runtime/role-state.js.map +1 -0
  122. package/dist/agent-runtime/runtime-identity.d.ts +11 -0
  123. package/dist/agent-runtime/runtime-identity.js +33 -0
  124. package/dist/agent-runtime/runtime-identity.js.map +1 -0
  125. package/dist/agent-runtime/tool-event.d.ts +3 -0
  126. package/dist/agent-runtime/tool-event.js +24 -0
  127. package/dist/agent-runtime/tool-event.js.map +1 -0
  128. package/dist/agent-runtime/verification-plan.d.ts +55 -0
  129. package/dist/agent-runtime/verification-plan.js +206 -0
  130. package/dist/agent-runtime/verification-plan.js.map +1 -0
  131. package/dist/agent-runtime/workflow-types.d.ts +19 -1
  132. package/dist/agent-runtime/workflow.js +29 -2
  133. package/dist/agent-runtime/workflow.js.map +1 -1
  134. package/dist/agent-runtime/workspace-tools.d.ts +4 -0
  135. package/dist/agent-runtime/workspace-tools.js +182 -20
  136. package/dist/agent-runtime/workspace-tools.js.map +1 -1
  137. package/dist/installer/phases/scaffold.js +39 -109
  138. package/dist/installer/phases/scaffold.js.map +1 -1
  139. package/dist/installer/runtime/pipeline-state.d.ts +143 -1
  140. package/dist/installer/runtime/pipeline-state.js +510 -30
  141. package/dist/installer/runtime/pipeline-state.js.map +1 -1
  142. package/docs/agent-runtime-efficiency.md +65 -0
  143. package/docs/agent-runtime.md +86 -15
  144. package/integration-contract.json +2 -1
  145. package/package.json +5 -2
  146. package/schemas/agent-runtime.schema.json +34 -4
  147. package/schemas/fixtures/runtime-efficiency-summary.v1.json +790 -0
  148. package/templates/codex-skills/batch-implement/SKILL.md +33 -58
  149. package/templates/codex-skills/implement/SKILL.md +21 -124
  150. package/templates/codex-skills/retry/SKILL.md +8 -34
  151. package/templates/commands/specrails/batch-implement.md +21 -16
  152. package/templates/commands/specrails/implement.md +17 -276
  153. package/templates/commands/specrails/retry.md +6 -34
  154. package/templates/gemini-commands/batch-implement.toml +34 -28
  155. package/templates/gemini-commands/implement.toml +34 -55
  156. package/templates/gemini-commands/retry.toml +10 -16
@@ -0,0 +1,371 @@
1
+ import { languageProfile } from './developer.js';
2
+ import { existsSync, readdirSync, statSync } from 'node:fs';
3
+ import path from 'node:path';
4
+ import { bounded } from './prompt-inputs.js';
5
+ import { finalJson, openspecCall, strings, structuredStep, text, toolStep, PLANNING_CONTROLS, on } from './step.js';
6
+ const MAX_CAPABILITIES = 6;
7
+ const MAX_TASKS = 9;
8
+ const MIN_TASKS = 4;
9
+ /** A task that names a path under openspec/ would make the developer mutate frozen artifacts. */
10
+ const GENERIC_IDENTIFIERS = new Set(['number', 'string', 'boolean', 'null', 'undefined', 'void', 'object', 'array', 'true', 'false', 'seed', 'state', 'error', 'command', 'optional']);
11
+ /** The load-bearing tokens of a criterion: identifiers (`createGame`, `applyInput`, `tick`), numbers and hyphenated terms — never prose words. */
12
+ export function criterionTokens(text) {
13
+ const out = new Set();
14
+ // Identifiers inside backticks (`tick(state)` → tick, state; `createGame(seed?: number): GameState` → creategame, gamestate…).
15
+ for (const match of text.matchAll(/`([^`]+)`/g))
16
+ for (const id of match[1].match(/[A-Za-z_][A-Za-z0-9_]{2,}/g) ?? [])
17
+ if (!GENERIC_IDENTIFIERS.has(id.toLowerCase()))
18
+ out.add(id.toLowerCase());
19
+ // camelCase / snake_case identifiers, calls, numbers and hyphenated terms in prose.
20
+ for (const match of text.replace(/`[^`]+`/g, ' ').matchAll(/\b[a-z]+(?:[A-Z][a-z0-9]*)+\b|\b[a-z]+_[a-z0-9_]+\b|\b[A-Za-z_][A-Za-z0-9_]*(?=\()|(?<![\w-])[a-z0-9]+-[a-z]+(?![\w-])|\b\d+(?:x\d+)?\b/g))
21
+ out.add(match[0].toLowerCase());
22
+ return [...out].filter(token => token.length > 1);
23
+ }
24
+ /** A task that names at least one source/test file (not a document) — the plan must implement, not describe. */
25
+ const CODE_FILE = /\.(?:[cm]?[jt]sx?|py|go|rs|java|kt|swift|cs|rb|php|c|cc|cpp|h|hpp|vue|svelte|html|css|scss|sql|sh)\b/i;
26
+ const STOP_WORDS = new Set(['that', 'with', 'from', 'this', 'when', 'then', 'into', 'each', 'must', 'shall', 'should', 'system', 'returns', 'return', 'state', 'after', 'before', 'their', 'which', 'every', 'only', 'also', 'than', 'have', 'been', 'game']);
27
+ const OPENSPEC_TARGET = /(?:^|[\s`'"(/\\])openspec[\/\\]/i;
28
+ const SLUG = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
29
+ const NON_SOURCE = new Set(['openspec', 'README.md', 'README', 'LICENSE', 'LICENSE.md', '.gitignore', '.gitattributes', '.editorconfig', 'CLAUDE.md', 'AGENTS.md', 'GEMINI.md', '.DS_Store']);
30
+ const HIDDEN = /^\./;
31
+ const stringList = { type: 'array', items: { type: 'string' } };
32
+ export const INVENTORY_SCHEMA = { type: 'object', additionalProperties: false, required: ['greenfield', 'languages', 'frameworks', 'keyFiles', 'tests', 'notes'], properties: { greenfield: { type: 'boolean' }, languages: stringList, frameworks: stringList, keyFiles: stringList, tests: stringList, notes: { type: 'string' } } };
33
+ export const PROPOSAL_SCHEMA = { type: 'object', additionalProperties: false, required: ['why', 'whatChanges', 'capabilities', 'impact'], properties: { why: { type: 'string' }, whatChanges: stringList, capabilities: { type: 'object', additionalProperties: false, required: ['new', 'modified'], properties: { new: stringList, modified: stringList } }, impact: stringList } };
34
+ export const DESIGN_SCHEMA = { type: 'object', additionalProperties: false, required: ['context', 'goals', 'nonGoals', 'decisions', 'risks'], properties: { context: { type: 'string' }, goals: stringList, nonGoals: stringList, decisions: { type: 'array', items: { type: 'object', additionalProperties: false, required: ['title', 'choice', 'why'], properties: { title: { type: 'string' }, choice: { type: 'string' }, why: { type: 'string' } } } }, risks: { type: 'array', items: { type: 'object', additionalProperties: false, required: ['risk', 'mitigation'], properties: { risk: { type: 'string' }, mitigation: { type: 'string' } } } } } };
35
+ export const SPEC_SCHEMA = { type: 'object', additionalProperties: false, required: ['name', 'requirements'], properties: { name: { type: 'string' }, requirements: { type: 'array', items: { type: 'object', additionalProperties: false, required: ['name', 'text', 'scenarios'], properties: { name: { type: 'string' }, text: { type: 'string' }, scenarios: { type: 'array', items: { type: 'object', additionalProperties: false, required: ['name', 'when', 'then'], properties: { name: { type: 'string' }, when: { type: 'string' }, then: { type: 'string' } } } } } } } } };
36
+ /** Names the repository's primary language for the plan, so task file names use its extension (a greenfield repository has none yet). */
37
+ function languageLine(roots) {
38
+ const profile = languageProfile(roots);
39
+ return profile ? `\nPrimary language of the repository: ${profile.primary}${profile.others.length ? ` (also present: ${profile.others.join(', ')})` : ''} — name new source files with its extension.` : '';
40
+ }
41
+ export const TASKS_SCHEMA = { type: 'object', additionalProperties: false, required: ['groups'], properties: { groups: { type: 'array', items: { type: 'object', additionalProperties: false, required: ['title', 'tasks'], properties: { title: { type: 'string' }, tasks: stringList } } }, verification: { type: 'array', items: { type: 'object', additionalProperties: false, required: ['repositoryId', 'command', 'args'], properties: { repositoryId: { type: 'string' }, command: { type: 'string' }, args: stringList } } }, blockingQuestion: { type: 'string' } } };
42
+ /** True when no repository holds anything but OpenSpec artifacts and repository boilerplate. */
43
+ export function hostGreenfield(roots) {
44
+ return roots.every(root => {
45
+ if (!existsSync(root))
46
+ return true;
47
+ return readdirSync(root).every(name => NON_SOURCE.has(name) || HIDDEN.test(name));
48
+ });
49
+ }
50
+ function slug(value) { return value.trim().toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 60); }
51
+ function bullets(items, fallback) { return items.length ? items.map(item => `- ${item}`).join('\n') : `- ${fallback}`; }
52
+ /** Rendered with the exact headings `openspec instructions proposal` returns. */
53
+ export function renderProposal(proposal, capabilityNames) {
54
+ return ['## Why', '', proposal.why, '', '## What Changes', '', bullets(proposal.whatChanges, 'See the requirements in the specs of this change.'), '', '## Capabilities', '', '### New Capabilities',
55
+ ...(capabilityNames.new.length ? capabilityNames.new.map(name => `- \`${name}\`: ${name.replace(/-/g, ' ')}`) : ['- (none)']), '', '### Modified Capabilities',
56
+ ...(capabilityNames.modified.length ? capabilityNames.modified.map(name => `- \`${name}\`: requirements extended by this change`) : ['- (none)']), '', '## Impact', '', bullets(proposal.impact, 'Limited to the repositories in scope.'), ''].join('\n');
57
+ }
58
+ export function renderDesign(design, greenfield) {
59
+ return ['## Context', '', ...(greenfield ? ['The repository has no application code; the spec means building it from scratch.', ''] : []), design.context, '', '## Goals / Non-Goals', '', '**Goals:**', bullets(design.goals, 'Deliver the requested work.'), '', '**Non-Goals:**', bullets(design.nonGoals, 'Anything outside the frozen scope.'), '', '## Decisions', '',
60
+ ...(design.decisions.length ? design.decisions.map(item => `- **${item.title}**: ${item.choice} — ${item.why}`) : ['- Follow the existing conventions of the repository.']), '', '## Risks / Trade-offs', '', ...(design.risks.length ? design.risks.map(item => `- [${item.risk}] → ${item.mitigation}`) : ['- [Scope creep] → implement only the listed tasks.']), '', '## Local reference patterns', '', greenfield ? 'No existing implementation to reference: the repository is empty.' : 'See the key files listed in the inventory of this change; no equivalent implementation was verified beyond them.', ''].join('\n');
61
+ }
62
+ /** Every requirement carries SHALL/MUST and at least one scenario, which `validate --strict` requires. */
63
+ const BINARY_ASSET_EXT = /\.(?:wav|mp3|ogg|flac|m4a|aac|png|jpe?g|gif|webp|svg|ico|woff2?|ttf|otf|mp4|webm)$/i;
64
+ /** True when any media/font file exists under the roots (bounded walk, dot/dependency dirs skipped). */
65
+ export function hasBinaryAssets(roots, limit = 4000) {
66
+ let seen = 0;
67
+ const walk = (dir, depth) => {
68
+ if (depth > 6 || seen > limit)
69
+ return false;
70
+ let entries = [];
71
+ try {
72
+ entries = readdirSync(dir);
73
+ }
74
+ catch {
75
+ return false;
76
+ }
77
+ for (const entry of entries) {
78
+ if (entry === 'node_modules' || entry === 'openspec' || entry.startsWith('.'))
79
+ continue;
80
+ seen++;
81
+ const full = path.join(dir, entry);
82
+ let isDir = false;
83
+ try {
84
+ isDir = statSync(full).isDirectory();
85
+ }
86
+ catch {
87
+ continue;
88
+ }
89
+ if (isDir ? walk(full, depth + 1) : BINARY_ASSET_EXT.test(entry))
90
+ return true;
91
+ }
92
+ return false;
93
+ };
94
+ return roots.some(root => walk(root, 0));
95
+ }
96
+ const STOP = new Set(['the', 'a', 'an', 'and', 'or', 'of', 'to', 'in', 'on', 'for', 'with', 'when', 'is', 'are', 'be', 'by', 'at', 'as', 'that', 'this', 'it', 'its', 'shall', 'must', 'system', 'should', 'will', 'from', 'into', 'than', 'then']);
97
+ function requirementTokens(text) {
98
+ return new Set(text.toLowerCase().replace(/[^a-z0-9]+/g, ' ').split(' ').filter(word => word.length > 2 && !STOP.has(word)));
99
+ }
100
+ function jaccard(a, b) {
101
+ if (!a.size || !b.size)
102
+ return 0;
103
+ let shared = 0;
104
+ for (const token of a)
105
+ if (b.has(token))
106
+ shared++;
107
+ return shared / (a.size + b.size - shared);
108
+ }
109
+ /**
110
+ * One requirement lives in exactly one capability. A small model given
111
+ * "write the requirements of capability X" restates the WHOLE ticket under
112
+ * every capability (observed: 20 requirements for 8 obligations across
113
+ * sound-effects / audio-controls / gameplay-events, three near-identical
114
+ * lists). Later capabilities lose the requirements an earlier one already
115
+ * holds (same normalized name, or ≥ 0.6 token overlap of the SHALL text);
116
+ * a capability left empty is dropped. Returns the kept specs and the drops.
117
+ */
118
+ export function dedupeSpecRequirements(specs) {
119
+ const kept = [];
120
+ const dropped = [];
121
+ const out = [];
122
+ for (const spec of specs) {
123
+ const requirements = spec.requirements.filter(requirement => {
124
+ const name = requirement.name.toLowerCase().replace(/[^a-z0-9]+/g, ' ').trim();
125
+ const tokens = requirementTokens(requirement.text);
126
+ const twin = kept.find(item => item.name === name || jaccard(item.tokens, tokens) >= 0.6);
127
+ if (twin) {
128
+ dropped.push({ capability: spec.name, requirement: requirement.name, keptIn: twin.capability });
129
+ return false;
130
+ }
131
+ kept.push({ capability: spec.name, name, tokens });
132
+ return true;
133
+ });
134
+ if (requirements.length)
135
+ out.push({ name: spec.name, requirements });
136
+ }
137
+ return { specs: out, dropped };
138
+ }
139
+ /**
140
+ * Every acceptance criterion of the ticket must reach a spec, or the plan
141
+ * (which is validated against the specs) can legitimately skip it (observed:
142
+ * the ticket listed soft-drop among the SFX actions; no spec mentioned it,
143
+ * no task implemented it). Criteria with no identifier/number token in any
144
+ * requirement text are appended verbatim to the best-matching capability,
145
+ * as the requester's own words.
146
+ */
147
+ export function coverCriteria(specs, criteria) {
148
+ if (!specs.length)
149
+ return { specs, added: [] };
150
+ const haystack = specs.flatMap(spec => spec.requirements.map(item => `${item.name} ${item.text} ${item.scenarios.map(row => `${row.when} ${row.then}`).join(' ')}`)).join(' ').toLowerCase();
151
+ const added = [];
152
+ for (const criterion of criteria) {
153
+ const tokens = criterionTokens(criterion);
154
+ const words = [...requirementTokens(criterion)];
155
+ const covered = tokens.length ? tokens.some(token => haystack.includes(token)) : words.length === 0 || words.filter(word => haystack.includes(word)).length >= Math.ceil(words.length / 2);
156
+ if (covered)
157
+ continue;
158
+ const wordSet = requirementTokens(criterion);
159
+ const target = specs.map(spec => ({ spec, score: jaccard(wordSet, requirementTokens(spec.requirements.map(item => item.text).join(' '))) })).sort((a, b) => b.score - a.score)[0].spec;
160
+ target.requirements.push({ name: criterion.slice(0, 80).replace(/[.:]+$/, ''), text: /(?:SHALL|MUST)/.test(criterion) ? criterion : `The system SHALL satisfy the requester's criterion: ${criterion}`, scenarios: [{ name: 'Requester criterion', when: 'the behaviour this criterion describes is exercised', then: criterion }] });
161
+ added.push(criterion);
162
+ }
163
+ return { specs, added };
164
+ }
165
+ export function renderSpec(spec) {
166
+ const lines = ['## ADDED Requirements', ''];
167
+ for (const requirement of spec.requirements) {
168
+ const body = /\b(?:SHALL|MUST)\b/.test(requirement.text) ? requirement.text : `The system SHALL satisfy the following: ${requirement.text}`;
169
+ lines.push(`### Requirement: ${requirement.name}`, body, '');
170
+ for (const scenario of requirement.scenarios.length ? requirement.scenarios : [{ name: 'Requested behavior', when: 'the feature is used as specified', then: requirement.text }])
171
+ lines.push(`#### Scenario: ${scenario.name}`, `- **WHEN** ${scenario.when}`, `- **THEN** ${scenario.then}`, '');
172
+ }
173
+ return lines.join('\n');
174
+ }
175
+ export function renderTasks(groups) {
176
+ const lines = [];
177
+ groups.forEach((group, index) => {
178
+ lines.push(`## ${index + 1}. ${group.title}`, '');
179
+ group.tasks.forEach((task, taskIndex) => lines.push(`- [ ] ${index + 1}.${taskIndex + 1} ${task}`));
180
+ lines.push('');
181
+ });
182
+ return lines.join('\n');
183
+ }
184
+ function normalizeSpec(raw, name) {
185
+ const requirements = (Array.isArray(raw.requirements) ? raw.requirements : []).flatMap(item => {
186
+ const entry = item && typeof item === 'object' && !Array.isArray(item) ? item : undefined;
187
+ if (!entry || !text(entry.name) || !text(entry.text))
188
+ return [];
189
+ const scenarios = (Array.isArray(entry.scenarios) ? entry.scenarios : []).flatMap(scenario => {
190
+ const row = scenario && typeof scenario === 'object' && !Array.isArray(scenario) ? scenario : undefined;
191
+ return row && text(row.when) && text(row.then) ? [{ name: text(row.name, 'Requested behavior'), when: text(row.when), then: text(row.then) }] : [];
192
+ }).slice(0, 8);
193
+ return [{ name: text(entry.name).slice(0, 120), text: text(entry.text).slice(0, 2000), scenarios }];
194
+ }).slice(0, 12);
195
+ return { name, requirements };
196
+ }
197
+ /**
198
+ * Rejects plans a small model tends to produce: tasks that "implement" by
199
+ * writing next to the frozen OpenSpec plan (verify then fails with
200
+ * "Architecture artifacts changed after design approval") and plans made only
201
+ * of documents/specs. Returned text is fed back to the model for ONE retry.
202
+ */
203
+ export function validateTaskPlan(value, repositories, requirements = []) {
204
+ const normalized = normalizeTasks(value, repositories);
205
+ if (!normalized.groups.length)
206
+ return 'at least one group with one task is required';
207
+ const all = normalized.groups.flatMap(group => group.tasks);
208
+ // A "task" must be a sentence of work, not a file name: small models answer
209
+ // "package.json" / "src/index.js" when they resume a plan into a scaffold.
210
+ const stubs = all.filter(task => task.trim().length < 25 || !/\s/.test(task.trim()));
211
+ if (stubs.length)
212
+ return `these tasks are file names or stubs, not units of work: ${stubs.map(task => JSON.stringify(task)).join(', ')}. Each task must say WHAT behaviour it implements, in WHICH files, with WHICH tests.`;
213
+ // Enough work to carry the requirements: a real spec never fits one group.
214
+ if (requirements.length >= 3 && (all.length < 4 || normalized.groups.length < 2))
215
+ return `the plan has ${all.length} task(s) in ${normalized.groups.length} group(s) for ${requirements.length} requirements; break the work into at least 4 tasks across at least 2 groups (scaffold → domain model → game logic → integration/API → tests).`;
216
+ // Every requirement must be traceable to a task (by name words), or the
217
+ // developer will legitimately ship a stub and the reviewer will reject it.
218
+ const haystack = all.join(' ').toLowerCase();
219
+ // Identifiers and numbers are the load-bearing tokens of a criterion
220
+ // (`createGame`, `applyInput`, `7-bag`, `800`, `hold-piece-canvas`): a miss
221
+ // on them is reliable, so ONE such requirement is enough to reject the plan
222
+ // (observed: a `ui-rendering` spec with zero tasks shipped without the UI,
223
+ // accepted under the old one-third tolerance). Prose-only matches stay
224
+ // fuzzy — synonyms are common — and keep that tolerance.
225
+ const identifiersOf = (text) => [...new Set((text.match(/[A-Za-z_][A-Za-z0-9_]*(?:[A-Z][a-z0-9]+|_[a-z0-9]+)|\b\d+(?:x\d+)?\b|[a-z]+-[a-z]+/g) ?? []).map(token => token.toLowerCase()))];
226
+ const uncoveredStrict = requirements.filter(text => { const identifiers = identifiersOf(text); return identifiers.length > 0 && !identifiers.some(token => haystack.includes(token)); });
227
+ const uncoveredFuzzy = requirements.filter(text => {
228
+ if (identifiersOf(text).length)
229
+ return false;
230
+ const words = text.toLowerCase().split(/[^a-z0-9]+/).filter(word => word.length > 3 && !STOP_WORDS.has(word));
231
+ return words.length > 0 && !words.some(word => haystack.includes(word));
232
+ });
233
+ const uncovered = [...uncoveredStrict, ...uncoveredFuzzy];
234
+ if (requirements.length >= 3 && (uncoveredStrict.length || uncoveredFuzzy.length > Math.floor(requirements.length / 3)))
235
+ return `these requirements are not covered by any task: ${uncovered.map(name => JSON.stringify(name)).join(', ')}. Add tasks (with files and tests) that implement each of them.`;
236
+ const planning = all.filter(task => OPENSPEC_TARGET.test(task));
237
+ if (planning.length)
238
+ return `these tasks target the frozen OpenSpec planning directory instead of application code: ${planning.map(task => JSON.stringify(task.slice(0, 120))).join('; ')}. Name real source/test files (e.g. src/, tests/) for every task.`;
239
+ const codeLike = all.filter(task => CODE_FILE.test(task));
240
+ if (!codeLike.length)
241
+ return 'no task names an application source or test file; the plan must implement the behaviour in code (for example src/**/*.ts, tests/**), not describe it in documents';
242
+ // One task carrying most of the spec ("implement createGame, tick, applyInput,
243
+ // getState, gravity, locking, scoring, game over…") is what a small model
244
+ // stubs out and never finishes inside one tool budget. Split it.
245
+ if (requirements.length >= 3) {
246
+ const overloaded = all.filter(task => !/\b(?:test|spec)s?\b/i.test(task.split(/\s+in\s+/)[0] ?? '') && requirements.filter(text => criterionTokens(text).some(token => new RegExp(`\\b${token}\\b`, 'i').test(task))).length > 2);
247
+ if (overloaded.length)
248
+ return `these tasks each cover more than two requirements at once and will be stubbed rather than finished: ${overloaded.map(task => JSON.stringify(task.slice(0, 100))).join('; ')}. Split them so each task implements one or two requirements with its tests.`;
249
+ }
250
+ return undefined;
251
+ }
252
+ /** Test seam for the task normaliser. */
253
+ export function normalizeTasksForTest(raw, repositories = []) { return normalizeTasks(raw, repositories); }
254
+ function normalizeTasks(raw, repositories, strictQuestion = true) {
255
+ const groups = (Array.isArray(raw.groups) ? raw.groups : []).flatMap(item => {
256
+ const entry = item && typeof item === 'object' && !Array.isArray(item) ? item : undefined;
257
+ const tasks = strings(entry?.tasks, MAX_TASKS, 400).map(task => task.replace(/^\s*(?:task with concrete files|<[^>]*>)\s*:?\s*/i, '').trim()).filter(Boolean);
258
+ return entry && tasks.length ? [{ title: text(entry.title, 'Implementation').slice(0, 120), tasks }] : [];
259
+ });
260
+ let remaining = MAX_TASKS;
261
+ const capped = groups.map(group => { const tasks = group.tasks.slice(0, Math.max(0, remaining)); remaining -= tasks.length; return { ...group, tasks }; }).filter(group => group.tasks.length);
262
+ const verification = (Array.isArray(raw.verification) ? raw.verification : []).flatMap(item => {
263
+ const entry = item && typeof item === 'object' && !Array.isArray(item) ? item : undefined;
264
+ return entry && typeof entry.repositoryId === 'string' && repositories.includes(entry.repositoryId) && text(entry.command) && !/[\s]/.test(text(entry.command)) ? [{ repositoryId: entry.repositoryId, command: text(entry.command), args: strings(entry.args, 20, 200) }] : [];
265
+ }).slice(0, 10);
266
+ // A real question ends in "?" and is not the prompt's own instruction echoed
267
+ // back — models without reasoning copy example text verbatim.
268
+ const question = text(raw.blockingQuestion).slice(0, 4000);
269
+ const genuine = question.length > 0 && (!strictQuestion || (/\?\s*$/.test(question) && !/omit unless|only the requester can choose|leave .*empty/i.test(question)));
270
+ return { groups: capped, verification, ...(genuine ? { blockingQuestion: question } : {}) };
271
+ }
272
+ /**
273
+ * The compact architect: a bounded inventory, four tool-less structured steps
274
+ * and host-rendered OpenSpec artifacts written through the official workflow, so
275
+ * the graph's participation and completeness checks pass unchanged.
276
+ */
277
+ export async function runCompactArchitect(env) {
278
+ const { inputs } = env;
279
+ const roots = env.toolset.roots;
280
+ await openspecCall(env, { action: 'load_skill' });
281
+ // 1. Inventory: what exists, so every later step reasons from facts.
282
+ const greenfieldByHost = hostGreenfield(roots);
283
+ const inventoryLoop = await toolStep(env, {
284
+ system: 'Inventory the repository for a planning step. Start with list_files on ".", open the manifest and entry files you find, and locate existing tests. Do not read more than you need. Finish with one JSON object: {"greenfield":boolean,"languages":[],"frameworks":[],"keyFiles":[],"tests":[],"notes":"one paragraph"}. greenfield is true only when there is no application source code at all.',
285
+ user: `Repositories:\n${inputs.repositories.map(repo => `- ${repo.id}: ${repo.path}`).join('\n') || roots.map(root => `- ${root}`).join('\n')}\n${greenfieldByHost ? 'The host found no application source files in any repository (only OpenSpec artifacts and repository boilerplate).\n' : ''}${inputs.repositoryMap ? bounded(inputs.repositoryMap, 2500) + '\n' : ''}Requested work (for orientation only):\n${bounded(inputs.scope, 2500)}`,
286
+ tools: ['list_files', 'read_file', 'search_text'], maxToolCalls: 12,
287
+ });
288
+ const inventoryRaw = await finalJson(env, 'inventory', inventoryLoop.messages, inventoryLoop.text, INVENTORY_SCHEMA, value => typeof value.greenfield === 'boolean' ? undefined : '"greenfield" must be a boolean');
289
+ const inventory = { greenfield: greenfieldByHost || inventoryRaw.greenfield === true, languages: strings(inventoryRaw.languages, 10, 60), frameworks: strings(inventoryRaw.frameworks, 10, 60), keyFiles: strings(inventoryRaw.keyFiles, 20, 300), tests: strings(inventoryRaw.tests, 20, 300), notes: text(inventoryRaw.notes).slice(0, 1500) };
290
+ // No engineer or shell will ever add media files: a plan that "loads
291
+ // assets" sends the developer chasing .wav/.mp3 it cannot produce
292
+ // (observed: a 4-byte RIFF stub and an unrunnable generator script).
293
+ const assetsNote = hasBinaryAssets(roots) ? '' : 'The repository contains NO binary assets (audio, images, fonts) and none will be added by anyone: the implementer has no shell and cannot download or generate media. Design every audiovisual effect to be produced at runtime by code (Web Audio API oscillators, canvas drawing, CSS) and never condition behaviour on loading asset files.\n';
294
+ const facts = `Repository inventory (facts):\n${JSON.stringify(inventory)}\n${assetsNote}${inventory.greenfield ? 'The repository has no application code; the spec means building it from scratch. This is expected, not an open question.\n' : ''}`;
295
+ const scope = `Requested work (frozen scope):\n${bounded(inputs.scope, 6000)}\n${inputs.answers ? `Answers from the requester (authoritative):\n${inputs.answers}\n` : ''}`;
296
+ // 2. Proposal.
297
+ const proposalRaw = await structuredStep(env, 'proposal', 'Write the OpenSpec proposal for the requested work. JSON: {"why":"1-2 sentences","whatChanges":["specific change"],"capabilities":{"new":["kebab-case-name"],"modified":["existing-kebab-case-name"]},"impact":["affected code or system"]}. Capabilities are the spec files this change creates; one to three short kebab-case names.', scope + facts, PROPOSAL_SCHEMA, value => text(value.why) ? undefined : '"why" must be a non-empty string');
298
+ const changeName = env.openspec.context.change;
299
+ const capabilityNames = {
300
+ new: [...new Set(strings(proposalRaw.capabilities?.new, MAX_CAPABILITIES, 80).map(slug).filter(name => SLUG.test(name)))],
301
+ modified: [...new Set(strings(proposalRaw.capabilities?.modified, MAX_CAPABILITIES, 80).map(slug).filter(name => SLUG.test(name)))],
302
+ };
303
+ capabilityNames.modified = capabilityNames.modified.filter(name => !capabilityNames.new.includes(name));
304
+ if (!capabilityNames.new.length && !capabilityNames.modified.length)
305
+ capabilityNames.new = [changeName];
306
+ const proposal = { why: text(proposalRaw.why), whatChanges: strings(proposalRaw.whatChanges, 20, 400), capabilities: capabilityNames, impact: strings(proposalRaw.impact, 20, 400) };
307
+ // 3. Design.
308
+ const designRaw = await structuredStep(env, 'design', 'Write the OpenSpec design for the proposal. JSON: {"context":"current state and constraints","goals":[],"nonGoals":[],"decisions":[{"title":"","choice":"","why":""}],"risks":[{"risk":"","mitigation":""}]}. Name the concrete files or modules to create or change; keep decisions to the ones that matter.', scope + facts + `Proposal:\n${JSON.stringify(proposal)}\n`, DESIGN_SCHEMA, value => text(value.context) ? undefined : '"context" must be a non-empty string');
309
+ const design = { context: text(designRaw.context), goals: strings(designRaw.goals, 12, 400), nonGoals: strings(designRaw.nonGoals, 12, 400),
310
+ decisions: (Array.isArray(designRaw.decisions) ? designRaw.decisions : []).flatMap(item => { const entry = item && typeof item === 'object' && !Array.isArray(item) ? item : undefined; return entry && text(entry.title) && text(entry.choice) ? [{ title: text(entry.title).slice(0, 120), choice: text(entry.choice).slice(0, 600), why: text(entry.why, 'fits the requested scope').slice(0, 600) }] : []; }).slice(0, 10),
311
+ risks: (Array.isArray(designRaw.risks) ? designRaw.risks : []).flatMap(item => { const entry = item && typeof item === 'object' && !Array.isArray(item) ? item : undefined; return entry && text(entry.risk) ? [{ risk: text(entry.risk).slice(0, 300), mitigation: text(entry.mitigation, 'covered by the verification commands').slice(0, 400) }] : []; }).slice(0, 10) };
312
+ // 4. Specs, one call per capability.
313
+ const specs = [];
314
+ for (const name of [...capabilityNames.new, ...capabilityNames.modified]) {
315
+ // The requester's frozen acceptance criteria are the source of truth: each
316
+ // one becomes a requirement, so a terse model cannot shrink a rich spec
317
+ // into "two to five" generic requirements that the plan then "covers".
318
+ const frozen = inputs.criteria.map(item => item.requirement);
319
+ const perCapability = Math.max(2, Math.ceil(frozen.length / Math.max(1, capabilityNames.new.length + capabilityNames.modified.length)));
320
+ const already = specs.flatMap(spec => spec.requirements.map(item => `${item.name} (${spec.name})`));
321
+ const raw = await structuredStep(env, 'specs', `Write the requirements of the capability "${name}" as an OpenSpec delta spec.${already.length ? ` Requirements ALREADY written under other capabilities — do NOT restate them here, only what is specific to "${name}": ${already.slice(0, 30).join('; ')}.` : ''} JSON: {"name":"${name}","requirements":[{"name":"short requirement name","text":"The system SHALL …","scenarios":[{"name":"scenario name","when":"condition","then":"observable outcome"}]}]}. Use SHALL or MUST in every requirement text; every requirement needs at least one testable scenario. ${frozen.length ? `Turn EACH of the requester's acceptance criteria that belongs to this capability into its own requirement (${perCapability} or more here; every criterion must end up in exactly one capability) — keep their exact obligations (names, API signatures, numbers), never merge or paraphrase them away.` : 'Two to five requirements.'}`, scope + `${frozen.length ? `Requester's acceptance criteria (authoritative):\n${frozen.map((item, n) => `${n + 1}. ${item}`).join('\n')}\n` : ''}Proposal:\n${JSON.stringify(proposal)}\nDesign decisions:\n${JSON.stringify(design.decisions)}\n`, SPEC_SCHEMA, value => normalizeSpec(value, name).requirements.length ? undefined : 'at least one requirement with name and text is required', { ...PLANNING_CONTROLS, reasoningEffort: 'medium' });
322
+ specs.push(normalizeSpec(raw, name));
323
+ }
324
+ {
325
+ const deduped = dedupeSpecRequirements(specs);
326
+ if (deduped.dropped.length)
327
+ env.onEvent?.({ kind: 'text', text: `Compact architect: dropped ${deduped.dropped.length} requirement${deduped.dropped.length === 1 ? '' : 's'} restated across capabilities (${deduped.dropped.slice(0, 4).map(item => `"${item.requirement}" in ${item.capability} ≈ ${item.keptIn}`).join('; ')}${deduped.dropped.length > 4 ? '; …' : ''}).` });
328
+ const covered = coverCriteria(deduped.specs, inputs.criteria.map(item => item.requirement));
329
+ if (covered.added.length)
330
+ env.onEvent?.({ kind: 'text', text: `Compact architect: ${covered.added.length} acceptance criteri${covered.added.length === 1 ? 'on was' : 'a were'} missing from every spec and ${covered.added.length === 1 ? 'was' : 'were'} appended verbatim (${covered.added.map(item => `"${item.slice(0, 60)}"`).join('; ')}).` });
331
+ specs.splice(0, specs.length, ...covered.specs);
332
+ for (const key of ['new', 'modified'])
333
+ capabilityNames[key] = capabilityNames[key].filter(name => specs.some(spec => spec.name === name));
334
+ }
335
+ // 5. Tasks and proposed verification.
336
+ // The five-group skeleton exists for a GREENFIELD repository. Handed to a
337
+ // small model for a repository that already has its manifest, runner and
338
+ // modules, it produced a literal "Scaffold" group with duplicate smoke-test
339
+ // tasks and placeholder files (`src/index.ts`, `src/feature.ts` in a
340
+ // vanilla-JS game — observed twice with the same 32k coder). Brownfield
341
+ // plans are grouped by the requirements and extend the existing modules.
342
+ const skeleton = inventory.greenfield
343
+ ? `following this skeleton — 1. Scaffold (manifest with a \"test\" script, runner config, smoke test) · 2. Domain model (types, data tables) · 3. Core logic (the behaviours the requirements describe) · 4. Integration / public API · 5. Remaining tests — 1 to 3 tasks per group, dropping a group only when the repository already has it.`
344
+ : `grouped by the requirements they implement (for example one group per capability, or logic · integration · remaining tests). The repository ALREADY EXISTS: do not add a \"Scaffold\" group, a smoke test, a manifest or runner task, and never a placeholder or stub file — every task extends the existing modules the inventory lists (${inventory.keyFiles.slice(0, 6).join(', ') || 'see the inventory'}) in the repository's language, or adds a real test to the existing test files. Two tasks must never describe the same work.`;
345
+ const tasksRaw = await structuredStep(env, 'tasks', `Break the implementation into ${MIN_TASKS} to ${MAX_TASKS} ordered tasks in 2 to 5 groups ${skeleton} EVERY group's tasks include the tests for the behaviours they implement (tests are written alongside the code, never deferred); group 5 exists ONLY for requirements that no earlier task tests yet, and is omitted when every requirement is already covered. Each task is ONE sentence of work that names the behaviour it implements, the files it creates or changes and the tests it adds (never a bare file name); never add tasks like \"run the tests\", \"verify\", \"commit\" or \"open a PR\". Every requirement listed below MUST be covered by at least one task. Tasks create or change APPLICATION source and test files (for example src/, lib/, tests/) that make the requested behaviour actually run; writing documents, specs, JSON/YAML descriptions or plans is NOT an implementation task, and the OpenSpec artifacts under openspec/ are frozen planning documents that MUST NOT appear as task targets. JSON: {"groups":[{"title":"<area name>","tasks":["<one sentence: what behaviour, in which files, with which tests>"]}],"verification":[{"repositoryId":"<id>","command":"npm","args":["test"]}],"blockingQuestion":""}. Leave "blockingQuestion" EMPTY unless several plausible designs exist and only the requester can choose; if you ask, write the actual question ending in "?". "verification" lists one existing (or task-added) automated command per repository that has no host-configured check; omit it when none applies.`, scope + facts + `Proposal:\n${JSON.stringify(proposal)}\nDesign:\n${JSON.stringify(design)}\nRequirements (each MUST map to a task):\n${specs.flatMap(spec => spec.requirements.map(item => `- [${spec.name}] ${item.name}: ${item.text.slice(0, 160)}`)).join('\n')}${inputs.criteria.length ? `\nRequester's acceptance criteria (authoritative — every one needs a task that implements and tests it):\n${inputs.criteria.map((item, n) => `${n + 1}. ${item.requirement.slice(0, 200)}`).join('\n')}` : ''}\n${inputs.configuredVerification ? inputs.configuredVerification + '\n' : ''}Repository ids: ${inputs.repositories.map(repo => repo.id).join(', ') || '(single repository)'}${on(env, 'plan-language-hint') ? languageLine(env.toolset.roots) : ''}`, TASKS_SCHEMA, value => on(env, 'plan-validation') ? validateTaskPlan(value, inputs.repositories.map(repo => repo.id), inputs.criteria.length ? inputs.criteria.map(item => item.requirement) : specs.flatMap(spec => spec.requirements.map(item => item.name))) : undefined);
346
+ const tasks = normalizeTasks(tasksRaw, inputs.repositories.map(repo => repo.id), on(env, 'genuine-blocking-question'));
347
+ // 6. The host writes the artifacts through the official workflow, in dependency order.
348
+ await openspecCall(env, { action: 'new' });
349
+ const status = await openspecCall(env, { action: 'status' });
350
+ const existingSpecs = new Set(Object.values(status.artifactPaths.specs?.existingOutputPaths ?? []).map(file => path.basename(path.dirname(file))));
351
+ await openspecCall(env, { action: 'instructions', artifact: 'proposal' });
352
+ await openspecCall(env, { action: 'write_artifact', path: 'proposal.md', content: renderProposal(proposal, capabilityNames) });
353
+ await openspecCall(env, { action: 'instructions', artifact: 'design' });
354
+ await openspecCall(env, { action: 'write_artifact', path: 'design.md', content: renderDesign(design, inventory.greenfield) });
355
+ await openspecCall(env, { action: 'instructions', artifact: 'specs' });
356
+ for (const spec of specs)
357
+ await openspecCall(env, { action: 'write_artifact', path: `specs/${spec.name}/spec.md`, content: renderSpec(spec) });
358
+ for (const stale of existingSpecs)
359
+ if (!specs.some(spec => spec.name === stale))
360
+ env.onEvent?.({ kind: 'text', text: `Existing spec ${stale} of a previous pass was left in place.` });
361
+ await openspecCall(env, { action: 'instructions', artifact: 'tasks' });
362
+ await openspecCall(env, { action: 'write_artifact', path: 'tasks.md', content: renderTasks(tasks.groups) });
363
+ await openspecCall(env, { action: 'validate' });
364
+ const confidence = tasks.blockingQuestion ? 'low' : inventory.greenfield ? 'high' : 'medium';
365
+ const structured = { confidence, planningDepth: 'full', planningReason: inventory.greenfield ? 'Greenfield repository: the spec is built from scratch.' : 'Compact planning from a bounded inventory.', referencePatterns: inventory.keyFiles.slice(0, 20), riskFlags: design.risks.map(item => item.risk).slice(0, 20),
366
+ ...(tasks.blockingQuestion ? { question: tasks.blockingQuestion } : {}), ...(tasks.verification.length ? { verification: tasks.verification } : {}) };
367
+ const result = JSON.stringify(structured);
368
+ env.onEvent?.({ kind: 'text', text: `Compact architect: ${specs.length} spec${specs.length === 1 ? '' : 's'}, ${tasks.groups.reduce((total, group) => total + group.tasks.length, 0)} tasks, ${inventoryLoop.toolCalls} inventory tool calls.` });
369
+ return { text: result, usage: env.client.usage, structured };
370
+ }
371
+ //# sourceMappingURL=architect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"architect.js","sourceRoot":"","sources":["../../../src/agent-runtime/compact/architect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAC3D,OAAO,IAAI,MAAM,WAAW,CAAA;AAG5B,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC5C,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,QAAQ,EAAoB,iBAAiB,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;AAErI,MAAM,gBAAgB,GAAG,CAAC,CAAA;AAC1B,MAAM,SAAS,GAAG,CAAC,CAAA;AACnB,MAAM,SAAS,GAAG,CAAC,CAAA;AACnB,iGAAiG;AACjG,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EA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M,CAAC,KAAK,EAAE,UAAU,EAAE,CAAA;AAC9D,CAAC"}
@@ -0,0 +1,83 @@
1
+ import { type AgentEvent, type AgentUsage } from '../executor-types.js';
2
+ export type ChatMessage = Record<string, unknown>;
3
+ /**
4
+ * Node creates its global undici dispatcher LAZILY, on the first fetch — so
5
+ * a fresh runtime process had no symbol to read, `patientDispatcher` stayed
6
+ * null and every request ran with undici's default 300 s body timeout
7
+ * (observed: `UND_ERR_BODY_TIMEOUT` killing a run whose Mac-mini model spent
8
+ * >5 min on one prefill/generation with no bytes on the wire). Force the
9
+ * lazy init with one refused loopback connect, then read the constructor.
10
+ */
11
+ export declare function ensurePatientDispatcher(): Promise<void>;
12
+ export declare function patientFetchInit(): Pick<RequestInit, 'dispatcher'>;
13
+ export interface ChatCompletion {
14
+ message: Record<string, unknown>;
15
+ finishReason: unknown;
16
+ }
17
+ export interface ChatClientOptions {
18
+ endpoint: URL;
19
+ headers: Record<string, string>;
20
+ fetch: typeof globalThis.fetch;
21
+ signal: AbortSignal;
22
+ model: string;
23
+ maxTokens?: number;
24
+ maxCostUsd?: number;
25
+ onEvent?: (event: AgentEvent) => void;
26
+ /** Default `reasoning_effort` for every call (the role's configured effort). */
27
+ reasoningEffort?: string;
28
+ /** The endpoint declared support for `reasoning_effort`; otherwise it is never sent. */
29
+ effortSupported?: boolean;
30
+ /** `off` (the default for local engines) sends `chat_template_kwargs: { enable_thinking: false }` — the Qwen/llama.cpp/vLLM switch; `reasoning_effort`, when declared, still travels (models that steer thinking by effort keep working). `on` leaves the server default. Dropped for the session when the endpoint rejects the field. */
31
+ thinking?: 'on' | 'off';
32
+ }
33
+ export declare function record(value: unknown): Record<string, unknown> | undefined;
34
+ /**
35
+ * One non-streaming `chat/completions` round trip with the executor's usage
36
+ * accounting: every response adds to the running totals, emits a usage event and
37
+ * is checked against the token/cost budget before the caller sees the message.
38
+ */
39
+ export declare class ChatClient {
40
+ private readonly options;
41
+ usage: AgentUsage;
42
+ responses: number;
43
+ /** Endpoints without `response_format` support are remembered after the first rejection. */
44
+ structuredOutput: 'unknown' | 'supported' | 'unsupported';
45
+ /** Effort is sent while the endpoint accepts it; a per-model rejection turns it off for the session. */
46
+ effortEnabled: boolean;
47
+ private thinkingOff;
48
+ constructor(options: ChatClientOptions);
49
+ /** The effort every call carries unless a per-call control overrides it (undefined when the endpoint declared no support). */
50
+ get defaultEffort(): string | undefined;
51
+ get budgetUsage(): AgentUsage;
52
+ /** Per-call generation controls. `reasoningEffort` is sent only when the
53
+ * endpoint declared support; `temperature`/`max_tokens` are universal. */
54
+ complete(body: {
55
+ messages: ChatMessage[];
56
+ tools?: unknown[];
57
+ tool_choice?: string;
58
+ response_format?: Record<string, unknown>;
59
+ }, controls?: {
60
+ temperature?: number;
61
+ maxOutputTokens?: number;
62
+ reasoningEffort?: string;
63
+ }): Promise<ChatCompletion>;
64
+ /**
65
+ * A tool-less call whose reply must be one JSON object. Uses `response_format`
66
+ * json_schema when the endpoint accepts it; an endpoint that rejects the field
67
+ * (HTTP 4xx on the first structured call) falls back to instructions only.
68
+ */
69
+ completeStructured(messages: ChatMessage[], name: string, schema: Record<string, unknown>, controls?: {
70
+ temperature?: number;
71
+ maxOutputTokens?: number;
72
+ reasoningEffort?: string;
73
+ }): Promise<ChatCompletion>;
74
+ }
75
+ /**
76
+ * Reads a chat completion whether the server streamed it (SSE — the request
77
+ * asks for it, so a model that reasons for minutes before its first token
78
+ * never trips the client's headers timeout) or answered with one JSON body
79
+ * (servers and fixtures that ignore `stream`). The result has the classic
80
+ * non-streaming shape: `{ choices: [{ message, finish_reason }], usage }`.
81
+ */
82
+ export declare function readCompletionResponse(response: Response): Promise<unknown>;
83
+ export declare function readBoundedResponse(response: Response): Promise<unknown>;