@interf/compiler 0.33.0 → 0.50.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 (234) hide show
  1. package/README.md +122 -226
  2. package/dist/cli/commands/agents.js +1 -32
  3. package/dist/cli/commands/benchmark.d.ts +2 -3
  4. package/dist/cli/commands/benchmark.js +1 -31
  5. package/dist/cli/commands/build-plan.js +26 -50
  6. package/dist/cli/commands/build.d.ts +2 -3
  7. package/dist/cli/commands/build.js +1 -31
  8. package/dist/cli/commands/graphs.js +177 -32
  9. package/dist/cli/commands/mcp.d.ts +1 -0
  10. package/dist/cli/commands/mcp.js +223 -126
  11. package/dist/cli/commands/project.js +10 -36
  12. package/dist/cli/commands/reset.d.ts +2 -3
  13. package/dist/cli/commands/reset.js +1 -22
  14. package/dist/cli/commands/runs.js +86 -33
  15. package/dist/cli/commands/status.js +3 -24
  16. package/dist/cli/commands/traces.js +1 -29
  17. package/dist/cli/commands/wizard.js +17 -29
  18. package/dist/cli/lib/http-client.d.ts +39 -0
  19. package/dist/cli/lib/http-client.js +73 -0
  20. package/dist/packages/build-plans/authoring/brief.d.ts +25 -4
  21. package/dist/packages/build-plans/authoring/build-plan-authoring.d.ts +42 -1
  22. package/dist/packages/build-plans/authoring/build-plan-authoring.js +470 -63
  23. package/dist/packages/build-plans/authoring/build-plan-edit-session.d.ts +9 -0
  24. package/dist/packages/build-plans/authoring/build-plan-edit-session.js +27 -10
  25. package/dist/packages/build-plans/authoring/build-plan-improvement.js +62 -8
  26. package/dist/packages/build-plans/authoring/lib/build-plan-edit-utils.d.ts +1 -0
  27. package/dist/packages/build-plans/package/build-plan-definitions.d.ts +0 -1
  28. package/dist/packages/build-plans/package/build-plan-definitions.js +5 -3
  29. package/dist/packages/build-plans/package/build-plan-stage-runner.d.ts +1 -0
  30. package/dist/packages/build-plans/package/build-plan-stage-runner.js +2 -1
  31. package/dist/packages/build-plans/package/builtin-build-plan.d.ts +2 -2
  32. package/dist/packages/build-plans/package/builtin-build-plan.js +3 -3
  33. package/dist/packages/build-plans/package/context-interface.d.ts +3 -0
  34. package/dist/packages/build-plans/package/context-interface.js +5 -5
  35. package/dist/packages/build-plans/package/interf-build-plan-package.js +22 -22
  36. package/dist/packages/build-plans/package/local-build-plans.d.ts +10 -5
  37. package/dist/packages/build-plans/package/local-build-plans.js +57 -32
  38. package/dist/packages/contracts/index.d.ts +4 -3
  39. package/dist/packages/contracts/index.js +2 -1
  40. package/dist/packages/contracts/lib/context-graph-layer.d.ts +161 -0
  41. package/dist/packages/contracts/lib/context-graph-layer.js +216 -0
  42. package/dist/packages/contracts/lib/project-paths.d.ts +7 -0
  43. package/dist/packages/contracts/lib/project-paths.js +9 -0
  44. package/dist/packages/contracts/lib/project-schema.d.ts +264 -1
  45. package/dist/packages/contracts/lib/project-schema.js +38 -13
  46. package/dist/packages/contracts/lib/schema.d.ts +556 -23
  47. package/dist/packages/contracts/lib/schema.js +279 -18
  48. package/dist/packages/contracts/utils/filesystem.d.ts +1 -0
  49. package/dist/packages/contracts/utils/filesystem.js +29 -1
  50. package/dist/packages/projects/lib/schema.d.ts +6 -8
  51. package/dist/packages/projects/lib/schema.js +3 -1
  52. package/dist/packages/projects/source-config.d.ts +0 -5
  53. package/dist/packages/projects/source-config.js +9 -22
  54. package/dist/packages/runtime/actions/fields.d.ts +4 -0
  55. package/dist/packages/runtime/actions/form-builders.js +79 -31
  56. package/dist/packages/runtime/actions/form-validators.js +9 -3
  57. package/dist/packages/runtime/actions/helpers.js +3 -3
  58. package/dist/packages/runtime/actions/registry.d.ts +1 -1
  59. package/dist/packages/runtime/actions/registry.js +1 -1
  60. package/dist/packages/runtime/actions/requests.d.ts +1 -1
  61. package/dist/packages/runtime/actions/requests.js +12 -6
  62. package/dist/packages/runtime/actions/schemas.d.ts +7 -0
  63. package/dist/packages/runtime/actions/schemas.js +1 -0
  64. package/dist/packages/runtime/agent-handoff.js +8 -7
  65. package/dist/packages/runtime/agents/lib/execution-profile.d.ts +14 -0
  66. package/dist/packages/runtime/agents/lib/execution-profile.js +23 -0
  67. package/dist/packages/runtime/agents/lib/execution.js +14 -8
  68. package/dist/packages/runtime/agents/lib/executors.d.ts +1 -0
  69. package/dist/packages/runtime/agents/lib/executors.js +11 -2
  70. package/dist/packages/runtime/agents/lib/logs.d.ts +10 -0
  71. package/dist/packages/runtime/agents/lib/logs.js +32 -8
  72. package/dist/packages/runtime/agents/lib/preflight.js +4 -1
  73. package/dist/packages/runtime/agents/lib/render.d.ts +18 -0
  74. package/dist/packages/runtime/agents/lib/render.js +44 -18
  75. package/dist/packages/runtime/agents/lib/shell-templates.js +105 -63
  76. package/dist/packages/runtime/agents/lib/shells.d.ts +29 -0
  77. package/dist/packages/runtime/agents/lib/shells.js +158 -32
  78. package/dist/packages/runtime/agents/lib/source-context-scan.d.ts +10 -0
  79. package/dist/packages/runtime/agents/lib/source-context-scan.js +388 -0
  80. package/dist/packages/runtime/agents/lib/status.js +1 -14
  81. package/dist/packages/runtime/agents/lib/string-utils.d.ts +16 -0
  82. package/dist/packages/runtime/agents/lib/string-utils.js +36 -0
  83. package/dist/packages/runtime/agents/lib/types.d.ts +1 -0
  84. package/dist/packages/runtime/agents/providers/codex.js +2 -0
  85. package/dist/packages/runtime/agents/role-executors.js +2 -1
  86. package/dist/packages/runtime/auth/session-store.js +11 -3
  87. package/dist/packages/runtime/benchmark-question-draft.d.ts +3 -0
  88. package/dist/packages/runtime/benchmark-question-draft.js +57 -28
  89. package/dist/packages/runtime/build/artifact-status.d.ts +1 -1
  90. package/dist/packages/runtime/build/artifact-status.js +1 -1
  91. package/dist/packages/runtime/build/build-evidence.d.ts +2 -1
  92. package/dist/packages/runtime/build/build-evidence.js +11 -5
  93. package/dist/packages/runtime/build/build-pipeline.js +89 -5
  94. package/dist/packages/runtime/build/build-stage-plan.js +3 -1
  95. package/dist/packages/runtime/build/build-stage-runner.js +169 -32
  96. package/dist/packages/runtime/build/build-target.d.ts +3 -0
  97. package/dist/packages/runtime/build/build-target.js +25 -1
  98. package/dist/packages/runtime/build/check-evaluator.d.ts +1 -1
  99. package/dist/packages/runtime/build/check-evaluator.js +655 -4
  100. package/dist/packages/runtime/build/context-graph-paths.d.ts +13 -0
  101. package/dist/packages/runtime/build/context-graph-paths.js +27 -0
  102. package/dist/packages/runtime/build/index.d.ts +2 -2
  103. package/dist/packages/runtime/build/index.js +2 -2
  104. package/dist/packages/runtime/build/inspect-map.d.ts +10 -0
  105. package/dist/packages/runtime/build/inspect-map.js +270 -0
  106. package/dist/packages/runtime/build/lib/schema.d.ts +246 -53
  107. package/dist/packages/runtime/build/lib/schema.js +173 -15
  108. package/dist/packages/runtime/build/native-entrypoint.d.ts +2 -0
  109. package/dist/packages/runtime/build/native-entrypoint.js +286 -0
  110. package/dist/packages/runtime/build/runtime-contracts.js +9 -3
  111. package/dist/packages/runtime/build/runtime-log-paths.d.ts +3 -0
  112. package/dist/packages/runtime/build/runtime-log-paths.js +16 -0
  113. package/dist/packages/runtime/build/runtime-prompt.js +6 -4
  114. package/dist/packages/runtime/build/runtime-runs.js +63 -10
  115. package/dist/packages/runtime/build/runtime-types.d.ts +4 -1
  116. package/dist/packages/runtime/build/runtime.d.ts +3 -1
  117. package/dist/packages/runtime/build/runtime.js +3 -1
  118. package/dist/packages/runtime/build/source-files.js +11 -2
  119. package/dist/packages/runtime/build/source-inventory.d.ts +1 -0
  120. package/dist/packages/runtime/build/source-inventory.js +246 -7
  121. package/dist/packages/runtime/build/source-manifest.d.ts +11 -0
  122. package/dist/packages/runtime/build/source-manifest.js +30 -2
  123. package/dist/packages/runtime/build/stage-evidence.js +80 -11
  124. package/dist/packages/runtime/build/stage-manifest.d.ts +45 -0
  125. package/dist/packages/runtime/build/stage-manifest.js +1125 -0
  126. package/dist/packages/runtime/build/stage-reuse.js +12 -0
  127. package/dist/packages/runtime/build/stage-session.d.ts +81 -0
  128. package/dist/packages/runtime/build/stage-session.js +308 -0
  129. package/dist/packages/runtime/build/state-io.js +10 -11
  130. package/dist/packages/runtime/build/state-view.js +1 -1
  131. package/dist/packages/runtime/build/state.d.ts +1 -1
  132. package/dist/packages/runtime/build/state.js +1 -1
  133. package/dist/packages/runtime/build/summary-coverage-index.d.ts +21 -0
  134. package/dist/packages/runtime/build/summary-coverage-index.js +189 -0
  135. package/dist/packages/runtime/build/traces.js +3 -3
  136. package/dist/packages/runtime/build/validate-context-graph.d.ts +1 -1
  137. package/dist/packages/runtime/build/validate-context-graph.js +5 -5
  138. package/dist/packages/runtime/build/validate.d.ts +1 -1
  139. package/dist/packages/runtime/build/validate.js +1 -1
  140. package/dist/packages/runtime/client.d.ts +3 -3
  141. package/dist/packages/runtime/client.js +8 -13
  142. package/dist/packages/runtime/context-checks.js +13 -0
  143. package/dist/packages/runtime/context-graph-scaffold.js +2 -1
  144. package/dist/packages/runtime/context-graph-semantic-graph.d.ts +9 -0
  145. package/dist/packages/runtime/context-graph-semantic-graph.js +416 -0
  146. package/dist/packages/runtime/execution/lib/schema.d.ts +34 -31
  147. package/dist/packages/runtime/index.d.ts +2 -2
  148. package/dist/packages/runtime/index.js +1 -1
  149. package/dist/packages/runtime/native-run-handlers.d.ts +38 -0
  150. package/dist/packages/runtime/native-run-handlers.js +52 -33
  151. package/dist/packages/runtime/plan-artifact-contract.js +1 -1
  152. package/dist/packages/runtime/project-source-state.d.ts +4 -4
  153. package/dist/packages/runtime/project-source-state.js +5 -2
  154. package/dist/packages/runtime/project-store.d.ts +5 -0
  155. package/dist/packages/runtime/project-store.js +30 -3
  156. package/dist/packages/runtime/requested-artifacts.js +1 -1
  157. package/dist/packages/runtime/run-observability.js +9 -4
  158. package/dist/packages/runtime/runtime-action-proposals.js +3 -3
  159. package/dist/packages/runtime/runtime-build-plans.js +47 -3
  160. package/dist/packages/runtime/runtime-build-runs.js +9 -16
  161. package/dist/packages/runtime/runtime-caches.d.ts +26 -0
  162. package/dist/packages/runtime/runtime-caches.js +47 -0
  163. package/dist/packages/runtime/runtime-jobs.js +6 -6
  164. package/dist/packages/runtime/runtime-project-mutations.js +1 -0
  165. package/dist/packages/runtime/runtime-project-reads.d.ts +4 -1
  166. package/dist/packages/runtime/runtime-project-reads.js +229 -36
  167. package/dist/packages/runtime/runtime-proposal-helpers.js +6 -6
  168. package/dist/packages/runtime/runtime-resource-builders.d.ts +4 -2
  169. package/dist/packages/runtime/runtime-resource-builders.js +16 -14
  170. package/dist/packages/runtime/runtime-status.d.ts +14 -0
  171. package/dist/packages/runtime/runtime-status.js +15 -0
  172. package/dist/packages/runtime/runtime-verify-runs.js +6 -5
  173. package/dist/packages/runtime/runtime.d.ts +439 -22
  174. package/dist/packages/runtime/runtime.js +16 -2
  175. package/dist/packages/runtime/schemas/actions.d.ts +24 -0
  176. package/dist/packages/runtime/schemas/agents.d.ts +28 -0
  177. package/dist/packages/runtime/schemas/agents.js +33 -0
  178. package/dist/packages/runtime/schemas/build-plans.d.ts +181 -8
  179. package/dist/packages/runtime/schemas/build-plans.js +36 -2
  180. package/dist/packages/runtime/schemas/context-graphs.d.ts +1522 -0
  181. package/dist/packages/runtime/schemas/context-graphs.js +110 -0
  182. package/dist/packages/runtime/schemas/files.d.ts +7 -347
  183. package/dist/packages/runtime/schemas/files.js +1 -24
  184. package/dist/packages/runtime/schemas/index.d.ts +1 -0
  185. package/dist/packages/runtime/schemas/index.js +1 -0
  186. package/dist/packages/runtime/schemas/jobs.js +4 -0
  187. package/dist/packages/runtime/schemas/projects.d.ts +48 -21
  188. package/dist/packages/runtime/schemas/projects.js +34 -10
  189. package/dist/packages/runtime/schemas/runs.d.ts +1009 -240
  190. package/dist/packages/runtime/schemas/runs.js +17 -0
  191. package/dist/packages/runtime/service/openapi.js +1 -0
  192. package/dist/packages/runtime/service/operations.d.ts +1666 -145
  193. package/dist/packages/runtime/service/operations.js +147 -17
  194. package/dist/packages/runtime/service/routes.d.ts +11 -3
  195. package/dist/packages/runtime/service/routes.js +11 -3
  196. package/dist/packages/runtime/service/server-app-boot.js +2 -2
  197. package/dist/packages/runtime/service/server-helpers.d.ts +11 -0
  198. package/dist/packages/runtime/service/server-helpers.js +19 -0
  199. package/dist/packages/runtime/service/server-routes-action-proposals.js +4 -2
  200. package/dist/packages/runtime/service/server-routes-agents.js +19 -85
  201. package/dist/packages/runtime/service/server-routes-build-plans.js +14 -11
  202. package/dist/packages/runtime/service/server-routes-project-context.js +102 -7
  203. package/dist/packages/runtime/service/server-routes-project-jobs.js +19 -12
  204. package/dist/packages/runtime/service/server-routes-project-runs.js +5 -2
  205. package/dist/packages/runtime/service/server-routes-projects.js +6 -2
  206. package/dist/packages/runtime/service/server-routes-runs.js +11 -4
  207. package/dist/packages/runtime/verify/lib/schema.js +12 -0
  208. package/dist/packages/runtime/verify/test-file-guard.d.ts +2 -0
  209. package/dist/packages/runtime/verify/test-file-guard.js +29 -0
  210. package/dist/packages/runtime/verify/verify-execution.d.ts +7 -0
  211. package/dist/packages/runtime/verify/verify-execution.js +109 -35
  212. package/dist/packages/runtime/verify/verify-paths.d.ts +1 -0
  213. package/dist/packages/runtime/verify/verify-paths.js +4 -0
  214. package/dist/packages/runtime/verify/verify-specs.js +49 -39
  215. package/dist/packages/runtime/wire-schemas.d.ts +1 -1
  216. package/dist/packages/runtime/wire-schemas.js +1 -1
  217. package/package.json +2 -8
  218. package/public-repo/CONTRIBUTING.md +10 -3
  219. package/public-repo/README.md +122 -226
  220. package/public-repo/build-plans/interf-default/README.md +15 -12
  221. package/public-repo/build-plans/interf-default/build/stages/entrypoint/SKILL.md +74 -0
  222. package/public-repo/build-plans/interf-default/build/stages/knowledge/SKILL.md +95 -0
  223. package/public-repo/build-plans/interf-default/build/stages/summarize/SKILL.md +38 -5
  224. package/public-repo/build-plans/interf-default/build-plan.json +27 -23
  225. package/public-repo/build-plans/interf-default/build-plan.schema.json +24 -20
  226. package/public-repo/build-plans/interf-default/use/query/SKILL.md +8 -7
  227. package/public-repo/openapi/local-service.openapi.json +11637 -4213
  228. package/public-repo/skills/interf/SKILL.md +174 -134
  229. package/dist/packages/runtime/build/runtime-paths.d.ts +0 -8
  230. package/dist/packages/runtime/build/runtime-paths.js +0 -26
  231. package/dist/packages/runtime/build/state-paths.d.ts +0 -7
  232. package/dist/packages/runtime/build/state-paths.js +0 -22
  233. package/public-repo/build-plans/interf-default/build/stages/shape/SKILL.md +0 -34
  234. package/public-repo/build-plans/interf-default/build/stages/structure/SKILL.md +0 -28
@@ -10,6 +10,7 @@ export interface AgentExecutionProfile {
10
10
  export interface AgentExecuteOptions {
11
11
  eventLogPath?: string | null;
12
12
  statusLogPath?: string | null;
13
+ reasoningLogPath?: string | null;
13
14
  completionCheck?: (() => boolean) | null;
14
15
  onStatus?: (line: string) => void;
15
16
  }
@@ -1,4 +1,5 @@
1
1
  import { resolveAgent } from "./detection.js";
2
+ import { resolveEffectiveAgentExecutionProfile } from "./execution-profile.js";
2
3
  import { spawnAgent } from "./execution.js";
3
4
  import { ensureAgentAutomatedRunReady } from "./preflight.js";
4
5
  export function buildRuntimeExecutorInfo(executor) {
@@ -14,17 +15,25 @@ export function buildRuntimeExecutorInfo(executor) {
14
15
  };
15
16
  }
16
17
  export function createLocalAgentExecutor(agent, executionProfile = {}) {
18
+ // Resolve the EFFECTIVE profile (per-run override ∨ saved agent prefs) ONCE,
19
+ // here, at construction. The executor then carries this single resolved value
20
+ // as `executionProfile`, so the model `buildRuntimeExecutorInfo` records and
21
+ // the model `buildAgentArgs` runs are sourced from the same object and can
22
+ // never disagree (F1). `spawnAgent` no longer re-merges prefs — it consumes
23
+ // this resolved profile as-is.
24
+ const effectiveProfile = resolveEffectiveAgentExecutionProfile(agent, executionProfile);
17
25
  return {
18
26
  kind: "local-agent",
19
27
  name: agent.name,
20
28
  displayName: agent.displayName,
21
29
  command: agent.command,
22
- executionProfile,
30
+ executionProfile: effectiveProfile,
23
31
  execute(rootPath, prompt, options) {
24
32
  return spawnAgent(agent, rootPath, prompt, {
25
33
  eventLogPath: options?.eventLogPath,
26
34
  statusLogPath: options?.statusLogPath,
27
- executionProfile,
35
+ reasoningLogPath: options?.reasoningLogPath,
36
+ executionProfile: effectiveProfile,
28
37
  completionCheck: options?.completionCheck,
29
38
  onStatus: options?.onStatus,
30
39
  });
@@ -1,2 +1,12 @@
1
1
  export declare function appendAgentEventLog(eventLogPath: string | null | undefined, event: Record<string, unknown>): void;
2
2
  export declare function appendAgentStatusLog(statusLogPath: string | null | undefined, text: string): void;
3
+ /**
4
+ * Append one reasoning/thinking span to the best-effort reasoning transcript
5
+ * (one JSON object per line). Reasoning capture must never block or fail a run,
6
+ * so any write error is swallowed — a missing reasoning line is acceptable, a
7
+ * crashed Build is not.
8
+ */
9
+ export declare function appendAgentReasoningLog(reasoningLogPath: string | null | undefined, span: {
10
+ kind: string;
11
+ text: string;
12
+ }): void;
@@ -1,17 +1,41 @@
1
1
  import { appendFileSync, mkdirSync } from "node:fs";
2
2
  import { dirname } from "node:path";
3
- export function appendAgentEventLog(eventLogPath, event) {
4
- if (!eventLogPath)
3
+ /**
4
+ * Append one line to a run log file, creating its directory on demand.
5
+ *
6
+ * Run log writes are observability, never run control: a mid-run disk hiccup
7
+ * (mkdir/append failure) must record a recoverable session, not throw an
8
+ * unhandled rejection that crashes the Build and dangles the session's
9
+ * `logs.event_stream_path`/`logs.status_path`. The single explicit policy for
10
+ * every agent run log is therefore best-effort — a missing log line is
11
+ * acceptable, a crashed run is not. A null/empty path is a no-op.
12
+ */
13
+ function ensureLogFile(path, content) {
14
+ if (!path)
5
15
  return;
6
- mkdirSync(dirname(eventLogPath), { recursive: true });
7
- appendFileSync(eventLogPath, `${JSON.stringify({
16
+ try {
17
+ mkdirSync(dirname(path), { recursive: true });
18
+ appendFileSync(path, content);
19
+ }
20
+ catch {
21
+ // Best-effort only: log writes must never block or fail a run.
22
+ }
23
+ }
24
+ export function appendAgentEventLog(eventLogPath, event) {
25
+ ensureLogFile(eventLogPath, `${JSON.stringify({
8
26
  timestamp: new Date().toISOString(),
9
27
  ...event,
10
28
  })}\n`);
11
29
  }
12
30
  export function appendAgentStatusLog(statusLogPath, text) {
13
- if (!statusLogPath)
14
- return;
15
- mkdirSync(dirname(statusLogPath), { recursive: true });
16
- appendFileSync(statusLogPath, `${new Date().toISOString()} ${text}\n`);
31
+ ensureLogFile(statusLogPath, `${new Date().toISOString()} ${text}\n`);
32
+ }
33
+ /**
34
+ * Append one reasoning/thinking span to the best-effort reasoning transcript
35
+ * (one JSON object per line). Reasoning capture must never block or fail a run,
36
+ * so any write error is swallowed — a missing reasoning line is acceptable, a
37
+ * crashed Build is not.
38
+ */
39
+ export function appendAgentReasoningLog(reasoningLogPath, span) {
40
+ ensureLogFile(reasoningLogPath, `${JSON.stringify({ timestamp: new Date().toISOString(), ...span })}\n`);
17
41
  }
@@ -77,7 +77,10 @@ export function ensureAgentAutomatedRunReady(agent, options = {}) {
77
77
  const details = result ? [result.error, result.stderr].filter(Boolean).join(" ") : "";
78
78
  return {
79
79
  ok: false,
80
- error: `${agent.displayName} failed Interf executor preflight. Run \`interf doctor --live\` for details.${details ? ` ${details}` : ""}`,
80
+ error: `${agent.displayName} failed Interf executor preflight. ` +
81
+ `Run \`interf doctor --live\` for details, or switch active agent with \`interf agents use <name>\` ` +
82
+ `(e.g. \`interf agents use claude-code\`).` +
83
+ (details ? ` ${details}` : ""),
81
84
  };
82
85
  }
83
86
  function sanitizeAgentStderr(agent, stderr) {
@@ -5,4 +5,22 @@ export interface VisibleTextState {
5
5
  }
6
6
  export declare function emitVisibleAgentText(text: string, statusLogPath: string | null | undefined, lastVisibleText?: VisibleTextState, onStatus?: (line: string) => void): boolean;
7
7
  export declare function displayAgentEvent(event: Record<string, unknown>, statusLogPath: string | null | undefined, lastVisibleText: VisibleTextState, onStatus?: (line: string) => void): boolean;
8
+ /**
9
+ * One reasoning/thinking span lifted from an agent event, for the best-effort
10
+ * reasoning transcript. `kind` records where it came from so the transcript
11
+ * stays inspectable across executors.
12
+ */
13
+ export interface AgentReasoningSpan {
14
+ kind: "thinking" | "reasoning";
15
+ text: string;
16
+ }
17
+ /**
18
+ * Extract any reasoning/thinking spans from a single parsed agent event. The
19
+ * event stream is already parsed for display; this lifts the reasoning the
20
+ * display path discards (it never renders thinking) so it can be teed to a
21
+ * runtime file. Covers Claude Code `assistant` messages carrying `thinking`
22
+ * content blocks and Codex `item.*` reasoning items. Returns `[]` for events
23
+ * with no reasoning — callers must treat reasoning capture as best-effort.
24
+ */
25
+ export declare function extractAgentReasoning(event: Record<string, unknown>): AgentReasoningSpan[];
8
26
  export declare function summarizeAgentToolActivity(event: Record<string, unknown>): string | null;
@@ -2,6 +2,7 @@ import { basename } from "node:path";
2
2
  import chalk from "chalk";
3
3
  import { SHOW_AGENT_TOOL_EVENTS, VISIBLE_STATUS_PREFIXES, } from "./constants.js";
4
4
  import { appendAgentStatusLog } from "./logs.js";
5
+ import { extractInputPath, pickString } from "./string-utils.js";
5
6
  export function emitVisibleAgentText(text, statusLogPath, lastVisibleText, onStatus) {
6
7
  if (lastVisibleText?.terminated) {
7
8
  return false;
@@ -37,7 +38,7 @@ export function displayAgentEvent(event, statusLogPath, lastVisibleText, onStatu
37
38
  const input = event.input;
38
39
  let detail = "";
39
40
  if (input) {
40
- const path = (input.file_path ?? input.path ?? input.pattern ?? input.command ?? "");
41
+ const path = extractInputPath(input);
41
42
  if (path)
42
43
  detail = chalk.dim(` ${path.slice(0, 80)}`);
43
44
  }
@@ -58,7 +59,7 @@ export function displayAgentEvent(event, statusLogPath, lastVisibleText, onStatu
58
59
  const input = block.input;
59
60
  let detail = "";
60
61
  if (input) {
61
- const path = (input.file_path ?? input.path ?? input.pattern ?? input.command ?? "");
62
+ const path = extractInputPath(input);
62
63
  if (path)
63
64
  detail = chalk.dim(` ${path.slice(0, 80)}`);
64
65
  }
@@ -95,6 +96,45 @@ export function displayAgentEvent(event, statusLogPath, lastVisibleText, onStatu
95
96
  }
96
97
  return displayed;
97
98
  }
99
+ /**
100
+ * Extract any reasoning/thinking spans from a single parsed agent event. The
101
+ * event stream is already parsed for display; this lifts the reasoning the
102
+ * display path discards (it never renders thinking) so it can be teed to a
103
+ * runtime file. Covers Claude Code `assistant` messages carrying `thinking`
104
+ * content blocks and Codex `item.*` reasoning items. Returns `[]` for events
105
+ * with no reasoning — callers must treat reasoning capture as best-effort.
106
+ */
107
+ export function extractAgentReasoning(event) {
108
+ const type = event.type;
109
+ const spans = [];
110
+ if (type === "assistant") {
111
+ const message = event.message;
112
+ const content = message?.content;
113
+ if (Array.isArray(content)) {
114
+ for (const block of content) {
115
+ if (block.type === "thinking" || block.type === "redacted_thinking") {
116
+ const text = pickString(block.thinking) ?? pickString(block.text);
117
+ if (text)
118
+ spans.push({ kind: "thinking", text });
119
+ }
120
+ }
121
+ }
122
+ }
123
+ if (type === "item.started" || type === "item.completed") {
124
+ const item = event.item;
125
+ if (item?.type === "reasoning") {
126
+ const text = pickString(item.text) ?? pickString(item.summary) ?? pickString(item.content);
127
+ if (text)
128
+ spans.push({ kind: "reasoning", text });
129
+ }
130
+ }
131
+ if (type === "reasoning") {
132
+ const text = pickString(event.text) ?? pickString(event.summary) ?? pickString(event.content);
133
+ if (text)
134
+ spans.push({ kind: "reasoning", text });
135
+ }
136
+ return spans;
137
+ }
98
138
  export function summarizeAgentToolActivity(event) {
99
139
  const type = event.type;
100
140
  if (type === "assistant") {
@@ -116,20 +156,6 @@ export function summarizeAgentToolActivity(event) {
116
156
  }
117
157
  return null;
118
158
  }
119
- function pickString(value) {
120
- if (typeof value === "string")
121
- return value;
122
- if (!Array.isArray(value))
123
- return null;
124
- for (const entry of value) {
125
- if (typeof entry === "string")
126
- return entry;
127
- if (entry && typeof entry === "object" && "text" in entry && typeof entry.text === "string") {
128
- return entry.text;
129
- }
130
- }
131
- return null;
132
- }
133
159
  function displayItemEvent(type, item, statusLogPath, lastVisibleText, onStatus) {
134
160
  const itemType = item.type;
135
161
  if (itemType === "agent_message") {
@@ -159,7 +185,7 @@ function displayItemEvent(type, item, statusLogPath, lastVisibleText, onStatus)
159
185
  return false;
160
186
  }
161
187
  function describeInput(input) {
162
- const path = (input.file_path ?? input.path ?? input.pattern ?? input.command ?? "");
188
+ const path = extractInputPath(input);
163
189
  return path ? chalk.dim(` ${path.slice(0, 80)}`) : "";
164
190
  }
165
191
  function summarizeToolUse(name, input) {
@@ -185,7 +211,7 @@ function summarizeToolUse(name, input) {
185
211
  function summarizeToolTarget(input) {
186
212
  if (!input)
187
213
  return null;
188
- const raw = (input.file_path ?? input.path ?? input.pattern ?? input.command ?? input.notebook_path);
214
+ const raw = extractInputPath(input);
189
215
  if (!raw || raw.length === 0)
190
216
  return null;
191
217
  if (raw.includes("\n")) {
@@ -26,19 +26,21 @@ export function renderContextGraphAgents(contextGraphPath, name, buildPlanId, op
26
26
  `# ${name}`,
27
27
  "",
28
28
  "This is a Context Graph built by Interf.",
29
- "This folder gives agents a prepared knowledge map over the Source: summaries, claims, requested Artifacts, traces, routes, and links back to sources.",
29
+ "This folder gives agents a prepared knowledge map over the Source: source-backed summaries, knowledge notes, entrypoints, traces, routes, and links back to sources.",
30
30
  "It normally contains source references rather than raw source copies. The original Source remains the source of truth.",
31
31
  "Use this graph before any source drilldown so you know what exists, what matters, and where evidence lives.",
32
32
  "",
33
33
  "## How to use this Context Graph",
34
34
  "",
35
- "1. Use the local native `interf-query` skill that Interf generated for this Context Graph.",
36
- "2. Let the Build Plan docs and declared Artifacts guide retrieval instead of assuming a fixed note layout.",
37
- "3. Use `.interf/runtime/source-manifest.json` to follow graph-provided source references for exact quotes, table values, chart reads, and provenance-sensitive claims.",
35
+ "1. Start with `home.md`. It is the primary agent entrypoint for this Context Graph.",
36
+ "2. Use the local native `interf-query` skill that Interf generated for this Context Graph.",
37
+ "3. Follow links from `home.md` into `knowledge/`, `summaries/`, `artifacts/`, traces, or Build Plan details.",
38
+ "4. Use `.interf/runtime/graph-manifest.json` for coverage metrics, stage summaries, entrypoints, and readiness.",
39
+ "5. Use `.interf/runtime/source-manifest.json` to follow graph-provided source references for exact quotes, table values, chart reads, and provenance-sensitive claims.",
38
40
  "",
39
41
  "## How this Context Graph works",
40
42
  "",
41
- "- The Build Plan defines the requested Artifact contract this Context Graph implements on disk.",
43
+ "- The Build Plan defines the requested output contract this Context Graph implements on disk.",
42
44
  "- `.interf/interf.json` records the selected Source binding and Project metadata.",
43
45
  `- Build Plan seed: \`${buildPlanOriginSelected}\`.`,
44
46
  ...(buildPlanLocalDraft
@@ -46,14 +48,15 @@ export function renderContextGraphAgents(contextGraphPath, name, buildPlanId, op
46
48
  : []),
47
49
  `- Selected Build Plan id: \`${buildPlanId}\`.`,
48
50
  "- `.interf/build-plan/` is the local editable Build Plan package for this Context Graph.",
49
- `- \`.interf/build-plan/${BUILD_PLAN_SCHEMA_FILE}\` is the deterministic requested Artifact contract for this Context Graph.`,
51
+ `- \`.interf/build-plan/${BUILD_PLAN_SCHEMA_FILE}\` is the deterministic requested output contract for this Context Graph.`,
50
52
  "- `.interf/build-plan/improve/` is the editable source for Build Plan improvement loops.",
51
53
  "- `.interf/build-plan/use/query/` is the editable source for the generated native query shell.",
52
54
  "- `.interf/build-plan/build/stages/` defines stage-specific docs that Interf projects into native execution shells for automated runs.",
53
55
  "- Native local query skills are generated under local agent skill directories such as `.claude/skills/` and `.codex/skills/`.",
54
56
  "- `.interf/runtime/source-manifest.json` is the authoritative Source inventory recorded for this Context Graph.",
55
- "- `.interf/runtime/source-state.json` is a compatibility projection of the Source Manifest.",
56
- `- Requested Artifact contracts are declared in \`.interf/build-plan/${BUILD_PLAN_SCHEMA_FILE}\`.`,
57
+ "- `.interf/runtime/graph-manifest.json` is the authoritative Context Graph manifest recorded for this build.",
58
+ "- `.interf/runtime/source-state.json` is a derived projection of the Source Manifest.",
59
+ `- Requested output contracts are declared in \`.interf/build-plan/${BUILD_PLAN_SCHEMA_FILE}\`.`,
57
60
  ...artifactLines,
58
61
  "- `.interf/runtime/` holds runtime artifacts written by Interf.",
59
62
  "- `.interf/tests/` mirrors the latest saved benchmark/evaluation run and keeps detailed target runs plus preserved sandboxes.",
@@ -61,10 +64,10 @@ export function renderContextGraphAgents(contextGraphPath, name, buildPlanId, op
61
64
  "",
62
65
  "## Manual query rules",
63
66
  "",
64
- "- Prefer the Build Plan-declared Context Graph outputs before source drilldown.",
67
+ "- Start from `home.md` before other Context Graph outputs or source drilldown.",
65
68
  "- Use the generated native `interf-query` skill for manual querying. The editable source lives at `.interf/build-plan/use/query/SKILL.md`.",
66
69
  "- Treat `.interf/` as Build Plan/runtime metadata, not answer evidence, unless explicitly asked to inspect Build Plan or benchmark history.",
67
- "- Do not bypass the graph with ad hoc source browsing. Drill into Source only through graph-provided source references, traces, requested Artifacts, or recorded Source state.",
70
+ "- Do not bypass the graph with ad hoc source browsing. Drill into Source only through graph-provided source references, traces, graph entrypoints, or recorded Source state.",
68
71
  "- Use `.interf/runtime/source-manifest.json` to find source references for quotes, verification, ambiguity, or evidence the Context Graph does not expose well.",
69
72
  "- If exact chart, table, or image-derived evidence matters, inspect the cited source reference and say whether the answer was text-derived, table-derived, or chart-derived.",
70
73
  "- If the graph points to the right evidence but misses required range, axis, period, unit, series, or provenance semantics, treat the graph as not ready and improve the Build Plan instead of presenting a blurry artifact as ready.",
@@ -93,20 +96,23 @@ export function renderContextGraphQuerySkill() {
93
96
  "",
94
97
  "Default loop:",
95
98
  "1. Read `.interf/build-plan/README.md` and this file first.",
96
- `2. Use the requested Artifact contract declared in \`.interf/build-plan/${BUILD_PLAN_SCHEMA_FILE}\` plus \`home.md\` to understand the prepared map.`,
97
- "3. Use Context Graph notes and requested Artifacts to locate the relevant evidence before any source drilldown.",
98
- "4. Use `.interf/runtime/source-manifest.json` to follow graph-provided source references for direct quotes, exact values, visual/table verification, and provenance-sensitive claims.",
99
+ "2. Read `home.md` first; it is the primary agent entrypoint.",
100
+ `3. Use the requested output contract declared in \`.interf/build-plan/${BUILD_PLAN_SCHEMA_FILE}\` and \`.interf/runtime/graph-manifest.json\` when you need to understand coverage, readiness, or prepared outputs.`,
101
+ "4. Follow at least one linked `knowledge/` or `summaries/` note when the answer depends on a claim, entity, timeline, comparison, or source-backed fact.",
102
+ "5. Use `.interf/runtime/source-manifest.json` and note source refs to follow graph-provided source references for direct quotes, exact values, visual/table verification, and provenance-sensitive claims.",
99
103
  "",
100
104
  "Answering rule:",
101
105
  "- do not modify source files while answering",
102
- "- treat the Build Plan as the Context Graph contract and use its Artifacts as the working retrieval surface",
106
+ "- treat the Build Plan as the Context Graph contract and use its graph resources as the working retrieval surface",
107
+ "- start from `home.md`; treat entrypoints and generated graph files as routing and source-evidence maps, not as a replacement dataset",
103
108
  "- use the Context Graph as a knowledge map over the Source, not as a raw-source replacement",
104
- "- do not bypass the graph with ad hoc source browsing; source drilldown must follow graph-provided source references, traces, requested Artifacts, or the recorded Source Manifest",
109
+ "- do not bypass the graph with ad hoc source browsing; source drilldown must follow graph-provided source references, traces, graph entrypoints, or the recorded Source Manifest",
110
+ "- record the entrypoint and linked `knowledge/` or `summaries/` notes you used when a trace log is requested",
105
111
  "- say explicitly when an answer depends on approximation, bounded inference, or a source re-check",
106
112
  "- when exact wording, table values, chart positions, visual ranges, or provenance matter, follow the cited source reference before making a strong claim",
107
113
  "- use source references to confirm source page, metric family, visual series, axis/range, period, unit, provenance, or exact wording",
108
114
  "- do not invent navigation or note structure beyond what this Build Plan declares",
109
- "- when the Context Graph is insufficient but points to the right source evidence, improve or rebuild if the missing semantics are part of the requested Artifact contract; do not present a blurry artifact as ready",
115
+ "- when the Context Graph is insufficient but points to the right source evidence, improve or rebuild if the missing semantics are part of the requested output contract; do not present a weak graph output as ready",
110
116
  "",
111
117
  "You can edit this file to bias manual question-answering behavior for this Context Graph.",
112
118
  "",
@@ -129,7 +135,7 @@ export function renderSourceFilesTestAgents() {
129
135
  "## Rules",
130
136
  "",
131
137
  "- Answer only from source files listed in `runtime/source-manifest.json`.",
132
- "- There is no Context Graph here, so do not assume any Context Graph Artifacts exist.",
138
+ "- There is no Context Graph here, so do not assume any generated graph outputs exist.",
133
139
  "- Do not treat hidden runtime files or benchmark artifacts as evidence.",
134
140
  ...chartNotes,
135
141
  "- Write the requested answer and trace files, then stop.",
@@ -169,27 +175,34 @@ export function renderStageExecutionAgents(contextGraphName, buildPlanId, stage)
169
175
  return [
170
176
  `# ${contextGraphName} — ${stage.label} Execution Shell`,
171
177
  "",
172
- "This is an ephemeral stage-execution shell generated by Interf.",
173
- "It is for automated pipeline execution only, not for manual querying.",
178
+ "This is a replayable stage-execution shell generated by Interf.",
179
+ "It contains the stage prompt, logs, local agent instructions, skill, contract, inputs, output mounts, and validator for this stage.",
174
180
  "",
175
181
  "## Start Here",
176
182
  "",
177
183
  "1. Read `runtime/stage-contract.json` now.",
178
- "2. Read `runtime/source-manifest.json`, `runtime/source-state.json`, and `runtime/stage-inputs.json` now.",
179
- "3. Read `runtime/paths.json` now.",
180
- "4. Use the local native `interf-stage` skill now.",
181
- `5. Execute only the current stage: \`${stage.id}\` (${stage.label}).`,
184
+ "2. Read `runtime/project.json` now.",
185
+ "3. Read `runtime/source-manifest.json`, `runtime/stage-inputs.json`, and `runtime/expected-inputs.json` now.",
186
+ "4. Read `runtime/paths.json` now.",
187
+ "5. Use the local native `interf-stage` skill now.",
188
+ `6. Execute only the current stage: \`${stage.id}\` (${stage.label}).`,
189
+ "7. Write `runtime/reviewed-inputs.json` before DONE.",
182
190
  "",
183
191
  "## Shell ABI",
184
192
  "",
185
193
  "- `inputs/<artifact-id>/` = read mounts for the current stage.",
186
194
  "- `outputs/<artifact-id>/` = write mounts for the current stage.",
187
- "- For file Artifacts, `runtime/paths.json` points to the exact file path inside those mount roots.",
195
+ "- For file outputs, `runtime/paths.json` points to the exact file path inside those mount roots.",
196
+ "- `runtime/project.json` = Project id and task intent for this stage.",
188
197
  "- `runtime/source-manifest.json` = authoritative Source inventory for this run.",
189
- "- `runtime/source-state.json` = compatibility projection of manifest source references.",
198
+ "- `runtime/source-state.json` = derived projection of manifest source references.",
190
199
  "- `runtime/stage-inputs.json` = exact manifest source references assigned to this stage.",
200
+ "- `runtime/expected-inputs.json` = required inputs this stage must review, use, or mark missing/blocked/not relevant.",
201
+ "- `runtime/reviewed-inputs.json` = coverage decisions this stage writes before DONE.",
191
202
  "- `runtime/check-stage.mjs` = shell-local deterministic verifier for the current stage outputs.",
192
- "- declared Artifact paths are also projected at the shell root so Build Plan-relative contract paths stay valid.",
203
+ "- `runtime/workspace.json` = shell map for retrospective inspection and replay.",
204
+ "- `logs/` = prompt, event stream, and status log for this agent session.",
205
+ "- declared output paths are also projected at the shell root so Build Plan-relative contract paths stay valid.",
193
206
  "- `runtime/` = stage contract and machine-readable path map for this shell.",
194
207
  "- `build-plan/` = Build Plan metadata, `build-plan.schema.json`, and docs for the current stage only.",
195
208
  "",
@@ -197,12 +210,14 @@ export function renderStageExecutionAgents(contextGraphName, buildPlanId, stage)
197
210
  "",
198
211
  `- Build Plan: \`${buildPlanId}\`.`,
199
212
  `- Contract type: \`${stage.contractType}\`.`,
200
- "- This shell has its own AGENTS/CLAUDE/native skills. It does not inherit the context-graph query shell.",
213
+ "- This shell has its own AGENTS/CLAUDE/native skills. It is the runnable workspace for this stage.",
201
214
  "- The context-graph root itself is not linked into this shell.",
202
215
  "- Do not switch into query mode or act like a user-facing assistant.",
216
+ "- Use `runtime/project.json` and `runtime/stage-contract.json.project.intent` as the task focus whenever this stage writes task-aware summaries, knowledge, entrypoints, or requested outputs.",
217
+ "- Use `runtime/expected-inputs.json` as the coverage contract. Every required expected input must be reviewed or marked missing, blocked, or not relevant with a reason.",
203
218
  "- Do not modify files under `inputs/` unless the same Artifact is also mounted under `outputs/`.",
204
219
  "",
205
- "## Current Stage Artifacts",
220
+ "## Current Stage Outputs",
206
221
  "",
207
222
  `- reads: ${stage.reads.join(", ")}`,
208
223
  `- writes: ${stage.writes.join(", ")}`,
@@ -212,9 +227,32 @@ export function renderStageExecutionAgents(contextGraphName, buildPlanId, stage)
212
227
  "- complete the current stage",
213
228
  "- honor the deterministic contract",
214
229
  "- write outputs through the declared Artifact mounts",
230
+ "- write `runtime/reviewed-inputs.json` with one decision per required expected input",
215
231
  "- run `node runtime/check-stage.mjs` and fix failures until it prints `VALID:`",
216
232
  "- stop when the stage is complete",
217
233
  "",
234
+ "## Reviewed Inputs File",
235
+ "",
236
+ "Write this JSON shape at `runtime/reviewed-inputs.json`:",
237
+ "",
238
+ "```json",
239
+ "{",
240
+ " \"kind\": \"interf-stage-reviewed-inputs\",",
241
+ " \"version\": 1,",
242
+ " \"generated_at\": \"2026-01-01T00:00:00.000Z\",",
243
+ ` \"stage_id\": \"${stage.id}\",`,
244
+ " \"reviewed\": [",
245
+ " {",
246
+ " \"resource_id\": \"copy-one-id-from-runtime-expected-inputs\",",
247
+ " \"decision\": \"used\",",
248
+ " \"source_refs\": [\"source-or-note-ref\"]",
249
+ " }",
250
+ " ]",
251
+ "}",
252
+ "```",
253
+ "",
254
+ "Allowed decisions: `used`, `reviewed`, `missing`, `blocked`, `not-relevant`. Missing, blocked, and not-relevant decisions require a concrete `reason`.",
255
+ "",
218
256
  ].join("\n");
219
257
  }
220
258
  export function renderStageExecutionSkill(stage, stageBuildPlanDoc) {
@@ -230,8 +268,11 @@ export function renderStageExecutionSkill(stage, stageBuildPlanDoc) {
230
268
  "",
231
269
  "This local native skill exists for automated Interf stage execution.",
232
270
  "Read `runtime/stage-contract.json` first.",
233
- "Then read `runtime/source-manifest.json`, `runtime/source-state.json`, `runtime/stage-inputs.json`, and `runtime/paths.json`.",
234
- "Use the assigned source references and the mounted `inputs/` and `outputs/` Artifacts for this stage.",
271
+ "Then read `runtime/project.json`, `runtime/source-manifest.json`, `runtime/stage-inputs.json`, `runtime/expected-inputs.json`, and `runtime/paths.json`.",
272
+ "Use the assigned source references and the mounted `inputs/` and `outputs/` requested outputs for this stage.",
273
+ "Use Project intent and the expected input coverage file when this stage writes task-aware summaries, knowledge, entrypoints, or requested outputs.",
274
+ "Write `runtime/reviewed-inputs.json` with kind `interf-stage-reviewed-inputs`, this stage id, and one decision per required expected input before DONE.",
275
+ "Allowed decisions are `used`, `reviewed`, `missing`, `blocked`, and `not-relevant`; missing, blocked, and not-relevant decisions require a concrete `reason`.",
235
276
  "Before emitting DONE, run `node runtime/check-stage.mjs` from the shell root and fix outputs until it prints `VALID:`.",
236
277
  "Do not switch into manual query mode.",
237
278
  "",
@@ -286,7 +327,7 @@ export function renderBuildPlanAuthoringAgents(options) {
286
327
  `# ${options.label} — Build Plan Authoring Shell`,
287
328
  "",
288
329
  "This is an automated Build Plan authoring shell generated by Interf.",
289
- "It exists to create one standalone Build Plan package from the source data, requested Artifacts, Context Checks, and evidence requirements in this task.",
330
+ "It exists to create one standalone Build Plan package from the Source, Project intent, requested outputs, coverage metrics, and evidence requirements in this task.",
290
331
  "",
291
332
  "## Start Here",
292
333
  "",
@@ -305,31 +346,31 @@ export function renderBuildPlanAuthoringAgents(options) {
305
346
  "- Edit only files under `build-plan/`.",
306
347
  "- Do not edit source artifacts.",
307
348
  "- Keep the Build Plan package valid for the current build API and `build-plan.schema.json`.",
308
- "- Use kebab-case ids everywhere: stage ids, skill_dir values, Artifact ids, reads/writes values, and package ids. Never use underscores.",
309
- "- Treat `checks` from `runtime/authoring-context.json` as user-facing Context Checks: plain-English checks the requested Artifacts must satisfy.",
310
- "- Create Context Checks first, then requested Artifacts that back those checks, then deterministic Artifact diagnostics (`checks[]`) under each Artifact.",
311
- "- Preserve the file-based Context Graph architecture: `summaries/` for source coverage, `knowledge/` for task-aware navigation/drilldown, and `artifacts/` for task-specific agent handoffs.",
312
- "- Artifact handoffs under `artifacts/` are the default downstream agent handoff surface. They must route to original Source refs for exact claims; generated summaries and knowledge notes are not the source of truth.",
313
- "- Treat `home.md` as a graph index only, not as the answer surface.",
314
- "- For tasks that depend on charts, tables, images, or other visual evidence, requested Artifacts must capture target period, unit, series/legend, axis or table interpretation, exact printed values when available, bounded ranges when not, evidence tier, and source page.",
315
- "- Do not let structural diagnostics such as file existence, frontmatter keys, or phrase presence stand in for evidence fidelity. Stage docs and Artifact descriptions must require the semantic fields the agent task needs.",
349
+ "- Use kebab-case ids everywhere: stage ids, skill_dir values, requested output ids, reads/writes values, and package ids. Never use underscores.",
350
+ "- Start from the saved Project intent. Build Plans operationalize that intent into summaries, task-aware knowledge, home.md, task entrypoint notes, StageManifest coverage, and GraphManifest metrics.",
351
+ "- Treat `checks` from `runtime/authoring-context.json` as optional context, not the primary product surface.",
352
+ "- Design coverage metrics first: expected Source units, reviewed inputs, produced outputs, entrypoints, and missing/blocked/not-relevant coverage decisions.",
353
+ "- Preserve the file-based Context Graph architecture: `summaries/` for source coverage, `knowledge/` for task-aware navigation/drilldown, and `artifacts/` for focused task entrypoint notes.",
354
+ "- `home.md` is the primary downstream agent entrypoint. Notes under `artifacts/` supplement it and route to original Source refs for exact claims.",
355
+ "- For tasks that depend on charts, tables, images, or other visual evidence, requested outputs must capture target period, unit, series/legend, axis or table interpretation, exact printed values when available, bounded ranges when not, evidence tier, and source page.",
356
+ "- Do not let structural diagnostics such as file existence, frontmatter keys, or phrase presence stand in for evidence fidelity. Stage docs and output descriptions must require the semantic fields the agent task needs.",
316
357
  "- If visual evidence has no printed data labels, require a bounded read at source granularity and unresolved-semantics handling instead of pseudo-exact precision.",
317
- "- Preserve `backed_by_artifact_ids` and make them match requested Artifact ids.",
318
- "- When `artifact_requirements[]` is non-empty, copy every requirement's `id`, `shape`, and `checks[]` exactly into the requested Artifact contract; do not rename or move required Artifacts.",
319
- "- Put deterministic validation on Artifact `checks[]`; do not add stage `acceptance` blocks.",
358
+ "- Preserve `backed_by_artifact_ids` and make them match requested output ids.",
359
+ "- When `artifact_requirements[]` is non-empty, treat it as the legacy storage field for required requested outputs; copy every requirement's `id`, `shape`, and `checks[]` exactly into the requested output contract; do not rename or move required outputs.",
360
+ "- Put minimal deterministic validation on requested output `checks[]`; StageManifest and GraphManifest coverage are the primary proof surface.",
320
361
  "- Use `runtime/authoring-context.json.check_param_contracts` as the exact parameter contract for each check kind.",
321
- "- Give every Artifact diagnostic a human-readable `description`; the UI shows that assertion first and uses evaluator details as drilldown.",
362
+ "- Give every deterministic check a human-readable `description`; the UI uses evaluator details only as drilldown.",
322
363
  "- Prefer direct file-reading and search tools over shell commands for routine file inspection.",
323
364
  "- Do not use shell helpers like `cat`, `sed`, `ls`, or `find` when a native read/search tool can inspect the same files.",
324
365
  "",
325
366
  "## Goal",
326
367
  "",
327
- "- produce one standalone Build Plan package tuned to the source data, requested Artifacts, and checks in this task",
368
+ "- produce one standalone Build Plan package tuned to the Source, Project intent, requested outputs, and coverage metrics in this task",
328
369
  "- replace the neutral scaffold topology with the stage flow this agent task needs",
329
- "- define Context Checks, requested Artifacts, and Artifact diagnostics so Interf can show which checks passed, which Artifacts back them, and what evidence or traces support them",
330
- "- satisfy every `artifact_requirements[]` entry from `runtime/authoring-context.json` when entries are present",
331
- "- otherwise draft requested Artifact contracts from every `requested_artifacts[]` entry; do not ignore or truncate them",
332
- "- preserve deterministic stage and requested Artifact contracts",
370
+ "- define requested outputs and stage docs so Interf can record StageManifests, GraphManifest primary metrics, evidence, and traces",
371
+ "- satisfy every `artifact_requirements[]` entry from `runtime/authoring-context.json` when entries are present; this is the legacy storage field for required requested outputs",
372
+ "- otherwise treat `requested_artifacts[]` as the legacy storage field for requested outputs/entrypoints and draft requested output contracts from every entry; do not ignore or truncate them",
373
+ "- preserve deterministic stage and requested output contracts",
333
374
  "- stop once the Build Plan edits are complete",
334
375
  "",
335
376
  ].join("\n");
@@ -350,25 +391,26 @@ export function renderBuildPlanAuthoringSkill() {
350
391
  "Rules:",
351
392
  "- edit only `build-plan/`",
352
393
  `- keep \`build-plan.json\`, \`${BUILD_PLAN_SCHEMA_FILE}\`, and any changed stage docs aligned`,
353
- "- treat `checks` from `runtime/authoring-context.json` as user-facing Context Checks, not deterministic operators",
354
- "- create Context Checks first, then requested Artifacts that back them, then deterministic Artifact diagnostics (`checks[]`) under those Artifacts",
355
- "- preserve the file-based Context Graph architecture: `summaries/` for source coverage, `knowledge/` for task-aware navigation/drilldown, and `artifacts/` for task-specific agent handoffs",
356
- "- make `artifacts/` the downstream agent handoff layer; route to original Source refs for exact claims and do not present generated notes as the source of truth",
357
- "- treat `home.md` as a graph index only, not as the answer surface",
394
+ "- treat `checks` from `runtime/authoring-context.json` as optional context, not the primary product surface",
395
+ "- design coverage metrics first: expected inputs, reviewed inputs, produced outputs, entrypoints, and missing coverage decisions",
396
+ "- preserve the file-based Context Graph architecture: `summaries/` for source coverage, `knowledge/` for task-aware navigation/drilldown, and `artifacts/` for focused task entrypoint notes",
397
+ "- make `home.md` the primary downstream agent entrypoint; route to original Source refs for exact claims and do not present generated notes as the source of truth",
358
398
  "- for charts, tables, images, and other visual evidence, require target period, unit, series/legend, axis or table interpretation, exact printed values when available, bounded ranges when not, evidence tier, and source page",
359
399
  "- structural diagnostics are not evidence fidelity; do not treat file existence, frontmatter keys, or phrase presence as proof that a visual/table value was correctly extracted",
360
400
  "- if visual evidence has no printed data labels, preserve a bounded read at source granularity and unresolved-semantics handling instead of pseudo-exact precision",
361
- "- preserve `backed_by_artifact_ids` and make them match requested Artifact ids",
362
- "- when `artifact_requirements[]` is non-empty, copy every requirement's `id`, `shape`, and `checks[]` exactly into the requested Artifact contract; do not rename or move required Artifacts",
363
- "- put deterministic validation on Artifact `checks[]`; do not add stage `acceptance` blocks",
401
+ "- preserve `backed_by_artifact_ids` in the root Build Plan `brief` and make them match requested output ids",
402
+ "- keep `purpose` limited to its documented fields; never add `purpose.brief` or other ad-hoc nested promise fields",
403
+ "- when `artifact_requirements[]` is non-empty, treat it as the legacy storage field for required requested outputs; copy every requirement's `id`, `shape`, and `checks[]` exactly into the requested output contract; do not rename or move required outputs",
404
+ "- keep deterministic validation on requested output `checks[]` minimal; StageManifest and GraphManifest coverage are the primary proof surface",
405
+ "- do not edit the root `brief`; the service restores it from Project intent, requested outputs, diagnostic checks, and Source context after every edit attempt",
364
406
  "- use only CheckKind values listed in `runtime/authoring-context.json`; do not invent aliases",
365
407
  "- use `runtime/authoring-context.json.check_param_contracts` as the exact parameter contract for each check kind",
366
- "- give every Artifact diagnostic a human-readable `description`; the UI shows that assertion first and uses evaluator details as drilldown",
367
- "- keep Artifact diagnostics aligned with produced outputs; use stage docs to describe the output contract without requiring exact source-specific phrases in the stage docs",
368
- "- satisfy every `artifact_requirements[]` entry from `runtime/authoring-context.json` when entries are present",
369
- "- otherwise draft requested Artifact contracts from every `requested_artifacts[]` entry; do not ignore or truncate them",
408
+ "- give every deterministic check a human-readable `description`; the UI uses evaluator details only as drilldown",
409
+ "- keep deterministic checks aligned with produced outputs; use stage docs and StageManifest coverage to describe the output contract without requiring exact source-specific phrases in the stage docs",
410
+ "- satisfy every `artifact_requirements[]` entry from `runtime/authoring-context.json` when entries are present; this is the legacy storage field for required requested outputs",
411
+ "- otherwise treat `requested_artifacts[]` as the legacy storage field for requested outputs/entrypoints and draft requested output contracts from every entry; do not ignore or truncate them",
370
412
  "- design the stage flow from the source data, agent task, and evidence brief",
371
- "- use kebab-case ids everywhere: stage ids, skill_dir values, Artifact ids, reads/writes values, and package ids; never use underscores",
413
+ "- use kebab-case ids everywhere: stage ids, skill_dir values, requested output ids, reads/writes values, and package ids; never use underscores",
372
414
  "- replace the placeholder `prepare` stage unless that exact stage is truly the final Build Plan",
373
415
  "- keep the package standalone; do not introduce runtime inheritance or hidden source-package assumptions",
374
416
  "- do not introduce wikilinks unless the Build Plan also creates the target note by exact basename or explicit relative path",
@@ -401,9 +443,9 @@ export function renderBuildPlanImprovementAgents(contextGraphName, buildPlanId,
401
443
  `- Improvement loop: ${loopIndex}.`,
402
444
  "- Edit only files under `build-plan/`.",
403
445
  "- Do not edit checks, benchmark specs, source files, or generated context outputs.",
404
- "- Review context-graph outputs under `artifacts/context-graph-view/` and benchmark/runtime evidence under `artifacts/`.",
446
+ "- Review `home.md`, `knowledge/`, `summaries/`, `.interf/runtime/graph-manifest.json`, stage manifests, and benchmark/runtime evidence under `artifacts/`.",
405
447
  "- Keep the Build Plan package valid for the current build API and `build-plan.schema.json`.",
406
- "- Put deterministic validation on Artifact `checks[]`; do not add stage `acceptance` blocks.",
448
+ "- Keep deterministic validation on Artifact `checks[]` minimal and aligned with produced outputs; use stage docs and manifests for coverage proof.",
407
449
  "",
408
450
  "## Goal",
409
451
  "",