thehood 0.1.0-preview.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 (274) hide show
  1. package/CODE_OF_CONDUCT.md +21 -0
  2. package/CONTRIBUTING.md +58 -0
  3. package/LICENSE +21 -0
  4. package/PRIVACY.md +49 -0
  5. package/README.md +264 -0
  6. package/SECURITY.md +31 -0
  7. package/dist/bridges/chatgptWebBridge.d.ts +2 -0
  8. package/dist/bridges/chatgptWebBridge.js +981 -0
  9. package/dist/bridges/chatgptWebBridge.js.map +1 -0
  10. package/dist/cli/args.d.ts +9 -0
  11. package/dist/cli/args.js +82 -0
  12. package/dist/cli/args.js.map +1 -0
  13. package/dist/cli/format.d.ts +56 -0
  14. package/dist/cli/format.js +752 -0
  15. package/dist/cli/format.js.map +1 -0
  16. package/dist/cli/main.d.ts +2 -0
  17. package/dist/cli/main.js +996 -0
  18. package/dist/cli/main.js.map +1 -0
  19. package/dist/cli/mcpConfig.d.ts +36 -0
  20. package/dist/cli/mcpConfig.js +98 -0
  21. package/dist/cli/mcpConfig.js.map +1 -0
  22. package/dist/index.d.ts +37 -0
  23. package/dist/index.js +38 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/mcp/protocol.d.ts +44 -0
  26. package/dist/mcp/protocol.js +33 -0
  27. package/dist/mcp/protocol.js.map +1 -0
  28. package/dist/mcp/server.d.ts +1 -0
  29. package/dist/mcp/server.js +106 -0
  30. package/dist/mcp/server.js.map +1 -0
  31. package/dist/mcp/tools.d.ts +10 -0
  32. package/dist/mcp/tools.js +2200 -0
  33. package/dist/mcp/tools.js.map +1 -0
  34. package/dist/mcp/validation.d.ts +8 -0
  35. package/dist/mcp/validation.js +67 -0
  36. package/dist/mcp/validation.js.map +1 -0
  37. package/dist/providers/chatgptWeb.d.ts +2 -0
  38. package/dist/providers/chatgptWeb.js +26 -0
  39. package/dist/providers/chatgptWeb.js.map +1 -0
  40. package/dist/providers/claudeCode.d.ts +4 -0
  41. package/dist/providers/claudeCode.js +32 -0
  42. package/dist/providers/claudeCode.js.map +1 -0
  43. package/dist/providers/codexCli.d.ts +6 -0
  44. package/dist/providers/codexCli.js +25 -0
  45. package/dist/providers/codexCli.js.map +1 -0
  46. package/dist/providers/codexCliModels.d.ts +23 -0
  47. package/dist/providers/codexCliModels.js +147 -0
  48. package/dist/providers/codexCliModels.js.map +1 -0
  49. package/dist/providers/localCommand.d.ts +26 -0
  50. package/dist/providers/localCommand.js +614 -0
  51. package/dist/providers/localCommand.js.map +1 -0
  52. package/dist/providers/markdownPayload.d.ts +7 -0
  53. package/dist/providers/markdownPayload.js +29 -0
  54. package/dist/providers/markdownPayload.js.map +1 -0
  55. package/dist/providers/responseSchema.d.ts +3 -0
  56. package/dist/providers/responseSchema.js +187 -0
  57. package/dist/providers/responseSchema.js.map +1 -0
  58. package/dist/providers/router.d.ts +3 -0
  59. package/dist/providers/router.js +21 -0
  60. package/dist/providers/router.js.map +1 -0
  61. package/dist/providers/stub.d.ts +2 -0
  62. package/dist/providers/stub.js +177 -0
  63. package/dist/providers/stub.js.map +1 -0
  64. package/dist/providers/types.d.ts +37 -0
  65. package/dist/providers/types.js +2 -0
  66. package/dist/providers/types.js.map +1 -0
  67. package/dist/runtime/agentBoard.d.ts +79 -0
  68. package/dist/runtime/agentBoard.js +166 -0
  69. package/dist/runtime/agentBoard.js.map +1 -0
  70. package/dist/runtime/agentBoardArtifact.d.ts +9 -0
  71. package/dist/runtime/agentBoardArtifact.js +171 -0
  72. package/dist/runtime/agentBoardArtifact.js.map +1 -0
  73. package/dist/runtime/agentRunner.d.ts +17 -0
  74. package/dist/runtime/agentRunner.js +92 -0
  75. package/dist/runtime/agentRunner.js.map +1 -0
  76. package/dist/runtime/approvalInbox.d.ts +54 -0
  77. package/dist/runtime/approvalInbox.js +143 -0
  78. package/dist/runtime/approvalInbox.js.map +1 -0
  79. package/dist/runtime/approvalPolicy.d.ts +11 -0
  80. package/dist/runtime/approvalPolicy.js +58 -0
  81. package/dist/runtime/approvalPolicy.js.map +1 -0
  82. package/dist/runtime/artifacts.d.ts +23 -0
  83. package/dist/runtime/artifacts.js +48 -0
  84. package/dist/runtime/artifacts.js.map +1 -0
  85. package/dist/runtime/browserManager.d.ts +37 -0
  86. package/dist/runtime/browserManager.js +356 -0
  87. package/dist/runtime/browserManager.js.map +1 -0
  88. package/dist/runtime/canonicalMemory.d.ts +23 -0
  89. package/dist/runtime/canonicalMemory.js +134 -0
  90. package/dist/runtime/canonicalMemory.js.map +1 -0
  91. package/dist/runtime/chatGptPageReadiness.d.ts +16 -0
  92. package/dist/runtime/chatGptPageReadiness.js +74 -0
  93. package/dist/runtime/chatGptPageReadiness.js.map +1 -0
  94. package/dist/runtime/commandRunner.d.ts +18 -0
  95. package/dist/runtime/commandRunner.js +115 -0
  96. package/dist/runtime/commandRunner.js.map +1 -0
  97. package/dist/runtime/commandSafety.d.ts +7 -0
  98. package/dist/runtime/commandSafety.js +61 -0
  99. package/dist/runtime/commandSafety.js.map +1 -0
  100. package/dist/runtime/config.d.ts +10 -0
  101. package/dist/runtime/config.js +107 -0
  102. package/dist/runtime/config.js.map +1 -0
  103. package/dist/runtime/crewLanes.d.ts +2 -0
  104. package/dist/runtime/crewLanes.js +123 -0
  105. package/dist/runtime/crewLanes.js.map +1 -0
  106. package/dist/runtime/criticPolicy.d.ts +17 -0
  107. package/dist/runtime/criticPolicy.js +50 -0
  108. package/dist/runtime/criticPolicy.js.map +1 -0
  109. package/dist/runtime/defaults.d.ts +5 -0
  110. package/dist/runtime/defaults.js +100 -0
  111. package/dist/runtime/defaults.js.map +1 -0
  112. package/dist/runtime/directives.d.ts +3 -0
  113. package/dist/runtime/directives.js +218 -0
  114. package/dist/runtime/directives.js.map +1 -0
  115. package/dist/runtime/doctor.d.ts +36 -0
  116. package/dist/runtime/doctor.js +185 -0
  117. package/dist/runtime/doctor.js.map +1 -0
  118. package/dist/runtime/errors.d.ts +20 -0
  119. package/dist/runtime/errors.js +41 -0
  120. package/dist/runtime/errors.js.map +1 -0
  121. package/dist/runtime/externalTransfer.d.ts +20 -0
  122. package/dist/runtime/externalTransfer.js +156 -0
  123. package/dist/runtime/externalTransfer.js.map +1 -0
  124. package/dist/runtime/fanout.d.ts +64 -0
  125. package/dist/runtime/fanout.js +263 -0
  126. package/dist/runtime/fanout.js.map +1 -0
  127. package/dist/runtime/gitEvidence.d.ts +10 -0
  128. package/dist/runtime/gitEvidence.js +80 -0
  129. package/dist/runtime/gitEvidence.js.map +1 -0
  130. package/dist/runtime/handoffs.d.ts +32 -0
  131. package/dist/runtime/handoffs.js +100 -0
  132. package/dist/runtime/handoffs.js.map +1 -0
  133. package/dist/runtime/ids.d.ts +2 -0
  134. package/dist/runtime/ids.js +4 -0
  135. package/dist/runtime/ids.js.map +1 -0
  136. package/dist/runtime/localStateIgnore.d.ts +9 -0
  137. package/dist/runtime/localStateIgnore.js +98 -0
  138. package/dist/runtime/localStateIgnore.js.map +1 -0
  139. package/dist/runtime/loop.d.ts +14 -0
  140. package/dist/runtime/loop.js +1863 -0
  141. package/dist/runtime/loop.js.map +1 -0
  142. package/dist/runtime/loopRecommendation.d.ts +109 -0
  143. package/dist/runtime/loopRecommendation.js +566 -0
  144. package/dist/runtime/loopRecommendation.js.map +1 -0
  145. package/dist/runtime/loopResponsibilities.d.ts +2 -0
  146. package/dist/runtime/loopResponsibilities.js +395 -0
  147. package/dist/runtime/loopResponsibilities.js.map +1 -0
  148. package/dist/runtime/loopRunner.d.ts +28 -0
  149. package/dist/runtime/loopRunner.js +81 -0
  150. package/dist/runtime/loopRunner.js.map +1 -0
  151. package/dist/runtime/operatorNextActions.d.ts +2 -0
  152. package/dist/runtime/operatorNextActions.js +344 -0
  153. package/dist/runtime/operatorNextActions.js.map +1 -0
  154. package/dist/runtime/paths.d.ts +9 -0
  155. package/dist/runtime/paths.js +14 -0
  156. package/dist/runtime/paths.js.map +1 -0
  157. package/dist/runtime/permissions.d.ts +9 -0
  158. package/dist/runtime/permissions.js +73 -0
  159. package/dist/runtime/permissions.js.map +1 -0
  160. package/dist/runtime/progressPacket.d.ts +12 -0
  161. package/dist/runtime/progressPacket.js +512 -0
  162. package/dist/runtime/progressPacket.js.map +1 -0
  163. package/dist/runtime/protectedPaths.d.ts +6 -0
  164. package/dist/runtime/protectedPaths.js +48 -0
  165. package/dist/runtime/protectedPaths.js.map +1 -0
  166. package/dist/runtime/providers.d.ts +13 -0
  167. package/dist/runtime/providers.js +60 -0
  168. package/dist/runtime/providers.js.map +1 -0
  169. package/dist/runtime/reconciliation.d.ts +17 -0
  170. package/dist/runtime/reconciliation.js +283 -0
  171. package/dist/runtime/reconciliation.js.map +1 -0
  172. package/dist/runtime/redaction.d.ts +1 -0
  173. package/dist/runtime/redaction.js +5 -0
  174. package/dist/runtime/redaction.js.map +1 -0
  175. package/dist/runtime/remoteRepoContext.d.ts +77 -0
  176. package/dist/runtime/remoteRepoContext.js +316 -0
  177. package/dist/runtime/remoteRepoContext.js.map +1 -0
  178. package/dist/runtime/repoContext.d.ts +50 -0
  179. package/dist/runtime/repoContext.js +399 -0
  180. package/dist/runtime/repoContext.js.map +1 -0
  181. package/dist/runtime/repoGateway.d.ts +64 -0
  182. package/dist/runtime/repoGateway.js +308 -0
  183. package/dist/runtime/repoGateway.js.map +1 -0
  184. package/dist/runtime/responseContracts.d.ts +3 -0
  185. package/dist/runtime/responseContracts.js +86 -0
  186. package/dist/runtime/responseContracts.js.map +1 -0
  187. package/dist/runtime/reviewLanes.d.ts +2 -0
  188. package/dist/runtime/reviewLanes.js +343 -0
  189. package/dist/runtime/reviewLanes.js.map +1 -0
  190. package/dist/runtime/reviewRouting.d.ts +51 -0
  191. package/dist/runtime/reviewRouting.js +152 -0
  192. package/dist/runtime/reviewRouting.js.map +1 -0
  193. package/dist/runtime/revisionPacket.d.ts +38 -0
  194. package/dist/runtime/revisionPacket.js +144 -0
  195. package/dist/runtime/revisionPacket.js.map +1 -0
  196. package/dist/runtime/revisionTrail.d.ts +2 -0
  197. package/dist/runtime/revisionTrail.js +162 -0
  198. package/dist/runtime/revisionTrail.js.map +1 -0
  199. package/dist/runtime/role-assignment.d.ts +4 -0
  200. package/dist/runtime/role-assignment.js +21 -0
  201. package/dist/runtime/role-assignment.js.map +1 -0
  202. package/dist/runtime/roleRoster.d.ts +28 -0
  203. package/dist/runtime/roleRoster.js +96 -0
  204. package/dist/runtime/roleRoster.js.map +1 -0
  205. package/dist/runtime/runInsights.d.ts +121 -0
  206. package/dist/runtime/runInsights.js +305 -0
  207. package/dist/runtime/runInsights.js.map +1 -0
  208. package/dist/runtime/runMonitor.d.ts +33 -0
  209. package/dist/runtime/runMonitor.js +143 -0
  210. package/dist/runtime/runMonitor.js.map +1 -0
  211. package/dist/runtime/runtime.d.ts +15 -0
  212. package/dist/runtime/runtime.js +199 -0
  213. package/dist/runtime/runtime.js.map +1 -0
  214. package/dist/runtime/runtimeInfo.d.ts +9 -0
  215. package/dist/runtime/runtimeInfo.js +76 -0
  216. package/dist/runtime/runtimeInfo.js.map +1 -0
  217. package/dist/runtime/store.d.ts +4 -0
  218. package/dist/runtime/store.js +48 -0
  219. package/dist/runtime/store.js.map +1 -0
  220. package/dist/runtime/summons.d.ts +25 -0
  221. package/dist/runtime/summons.js +403 -0
  222. package/dist/runtime/summons.js.map +1 -0
  223. package/dist/runtime/teamPresets.d.ts +14 -0
  224. package/dist/runtime/teamPresets.js +153 -0
  225. package/dist/runtime/teamPresets.js.map +1 -0
  226. package/dist/runtime/types.d.ts +505 -0
  227. package/dist/runtime/types.js +28 -0
  228. package/dist/runtime/types.js.map +1 -0
  229. package/dist/runtime/validationCommands.d.ts +18 -0
  230. package/dist/runtime/validationCommands.js +106 -0
  231. package/dist/runtime/validationCommands.js.map +1 -0
  232. package/dist/tui/dashboard.d.ts +41 -0
  233. package/dist/tui/dashboard.js +1115 -0
  234. package/dist/tui/dashboard.js.map +1 -0
  235. package/docs/ARCHITECTURE.md +277 -0
  236. package/docs/CLI_SPEC.md +396 -0
  237. package/docs/CODEX_SETUP.md +288 -0
  238. package/docs/COMPLETION_CONTRACT.md +52 -0
  239. package/docs/CONTRIBUTOR_GUIDE.md +70 -0
  240. package/docs/DEMO.md +62 -0
  241. package/docs/GLOSSARY.md +46 -0
  242. package/docs/GOAL_LOOP_SCHEDULE.md +50 -0
  243. package/docs/KNOWN_LIMITATIONS.md +29 -0
  244. package/docs/LICENSING.md +21 -0
  245. package/docs/LOOP_RECIPES.md +290 -0
  246. package/docs/LOOP_SELECTION_UX.md +118 -0
  247. package/docs/MCP_SPEC.md +689 -0
  248. package/docs/MEMORY_AND_RECONCILIATION.md +222 -0
  249. package/docs/NPM_PUBLISHING.md +51 -0
  250. package/docs/OPEN_DECISIONS.md +81 -0
  251. package/docs/PROMPT_SCHEMAS.md +411 -0
  252. package/docs/PROVIDER_ADAPTERS.md +323 -0
  253. package/docs/PROVIDER_MATRIX.md +21 -0
  254. package/docs/PUBLIC_REPO_READINESS.md +49 -0
  255. package/docs/RESEARCH_NOTES.md +92 -0
  256. package/docs/ROADMAP.md +94 -0
  257. package/docs/ROLE_CONTRACTS.md +252 -0
  258. package/docs/RUNTIME_LOOP.md +240 -0
  259. package/docs/SECURITY_AND_PRIVACY.md +161 -0
  260. package/docs/TESTING_AND_VERIFICATION.md +180 -0
  261. package/docs/TRUST_MODEL.md +65 -0
  262. package/docs/decisions/0001-runtime-first-cli-and-mcp.md +23 -0
  263. package/docs/decisions/0002-provider-neutral-role-mapping.md +43 -0
  264. package/docs/decisions/0003-separate-implementation-and-verification.md +27 -0
  265. package/docs/product/README.md +14 -0
  266. package/docs/product/model-selection.md +88 -0
  267. package/docs/product/positioning.md +37 -0
  268. package/docs/product/pro-usage-modes.md +70 -0
  269. package/docs/product/roadmap.md +57 -0
  270. package/docs/product/role-policy.md +89 -0
  271. package/docs/product/runtime-invariants.md +44 -0
  272. package/docs/release/v0.1.0-preview.0.md +48 -0
  273. package/examples/stub-demo/README.md +25 -0
  274. package/package.json +55 -0
@@ -0,0 +1,752 @@
1
+ import { formatRoleAssignment } from "../runtime/role-assignment.js";
2
+ import { agentMarkdownField } from "../providers/markdownPayload.js";
3
+ import { recentRunHandoffSummaries } from "../runtime/handoffs.js";
4
+ export const printJson = (value) => {
5
+ process.stdout.write(`${JSON.stringify(value, null, 2)}\n`);
6
+ };
7
+ const quoteArg = (value) => /^[A-Za-z0-9_./:@=-]+$/.test(value) ? value : `'${value.replace(/'/g, "'\\''")}'`;
8
+ export const formatRoles = (roles) => Object.entries(roles)
9
+ .sort(([left], [right]) => left.localeCompare(right))
10
+ .map(([role, assignment]) => `${role}: ${formatRoleAssignment(assignment)}`)
11
+ .join("\n");
12
+ const rosterSourceLabel = (source) => {
13
+ if (source === "product_default") {
14
+ return "product default";
15
+ }
16
+ if (source === "repo_config") {
17
+ return "repo config";
18
+ }
19
+ return "not assigned";
20
+ };
21
+ const rosterStateLabel = (item) => item.issues.length > 0 ? `${item.state} (${item.issues.join(", ")})` : item.state;
22
+ const permissionWord = (value) => value ? "yes" : "no";
23
+ const formatRosterPermissions = (item) => [
24
+ `read:${permissionWord(item.permissions.read)}`,
25
+ `edit:${permissionWord(item.permissions.edit)}`,
26
+ `shell:${permissionWord(item.permissions.shell)}`,
27
+ `network:${permissionWord(item.permissions.network)}`
28
+ ].join(" ");
29
+ export const formatRoleRoster = (roster, repoPath) => [
30
+ "Agent Roster",
31
+ ...roster.flatMap((item) => [
32
+ ` ${item.laneLabel}`,
33
+ ` role ${item.role}`,
34
+ ` owner ${item.assignmentLabel} (${rosterSourceLabel(item.assignmentSource)})`,
35
+ ...(item.defaultAssignmentLabel && item.assignmentSource !== "product_default"
36
+ ? [` default ${item.defaultAssignmentLabel}`]
37
+ : []),
38
+ ` state ${rosterStateLabel(item)}`,
39
+ ` authority ${item.authority}`,
40
+ ` tools ${formatRosterPermissions(item)}`,
41
+ ` purpose ${item.responsibility}`,
42
+ ` configure thehood roles set ${item.role} <provider:model> --repo ${quoteArg(repoPath)}`
43
+ ])
44
+ ].join("\n");
45
+ const cardStatusLabel = (status) => status.replace(/_/g, " ");
46
+ export const formatAgentBoard = (board) => [
47
+ "Agent Board",
48
+ ` scope ${board.scope}${board.runId ? ` ${board.runId}` : ""}`,
49
+ ` repo ${board.repoPath}`,
50
+ ...(board.runState ? [` run ${board.runState}${board.runMode ? ` (${board.runMode})` : ""}`] : []),
51
+ ` summary ${board.summary.ready}/${board.summary.total} ready active:${board.summary.active} blocked:${board.summary.blocked} unassigned:${board.summary.unassigned}`,
52
+ "",
53
+ ...board.cards.flatMap((card) => [
54
+ ` ${card.laneLabel}`,
55
+ ` owner ${card.assignmentLabel} (${rosterSourceLabel(card.assignmentSource)})`,
56
+ ` status ${cardStatusLabel(card.status)}`,
57
+ ` readiness ${cardStatusLabel(card.readiness)}`,
58
+ ` authority ${card.authority}`,
59
+ ...(card.run
60
+ ? [
61
+ ` lane ${card.run.currentLane ?? card.role}`,
62
+ ` laneState ${cardStatusLabel(card.run.laneStatus ?? "unknown")}${card.run.blocking ? " blocking" : ""}`,
63
+ ...(card.run.laneSummary ? [` summary ${card.run.laneSummary}`] : []),
64
+ ...(card.run.artifactRefs.length > 0 ? [` artifacts ${card.run.artifactRefs.join(", ")}`] : []),
65
+ ...(card.run.eventRefs.length > 0 ? [` events ${card.run.eventRefs.join(", ")}`] : [])
66
+ ]
67
+ : []),
68
+ ` tools read:${permissionWord(card.permissions.read)} edit:${permissionWord(card.permissions.edit)} shell:${permissionWord(card.permissions.shell)} network:${permissionWord(card.permissions.network)}`,
69
+ ...(card.issues.length > 0 ? [` issues ${card.issues.join(", ")}`] : [])
70
+ ]),
71
+ ...(board.actions.length > 0
72
+ ? [
73
+ "",
74
+ "next actions:",
75
+ ...board.actions.map((action) => ` ${action.action} ${action.blocking ? "blocking" : "ready"} owner=${action.ownerLabel} ${action.tool ?? action.commandHint ?? action.description}`.trimEnd())
76
+ ]
77
+ : []),
78
+ "",
79
+ ...board.notes.map((note) => ` note ${note}`)
80
+ ].join("\n");
81
+ const formatRecipeScore = (score) => `${score.recipe.id} (${score.recipe.status}, score:${score.score}) ${score.recipe.title}`;
82
+ export const formatLoopRecommendation = (recommendation) => [
83
+ "Loop Recommendation",
84
+ ` repo ${recommendation.repoPath}`,
85
+ ` confidence ${recommendation.confidence}`,
86
+ ` recipe ${formatRecipeScore(recommendation.recommended)}`,
87
+ ` why ${recommendation.reason}`,
88
+ "",
89
+ "recommended stack:",
90
+ ...recommendation.stack.map((item) => ` ${item.order}. ${item.recipe.id} (${item.recipe.status}) ${item.required ? "primary" : "companion"}`),
91
+ "",
92
+ "contract draft:",
93
+ ` goal ${recommendation.contract.goal}`,
94
+ ` evidence ${recommendation.contract.requiredEvidence.join("; ")}`,
95
+ ` validation ${recommendation.contract.validationCommands.join("; ")}`,
96
+ ` stop ${recommendation.contract.stopConditions.join("; ")}`,
97
+ ` budget ${recommendation.contract.iterationBudget}`,
98
+ "",
99
+ "alternatives:",
100
+ ...recommendation.alternatives.map((score) => ` ${formatRecipeScore(score)}`),
101
+ "",
102
+ "run action:",
103
+ ` tool ${recommendation.runAction.tool}`,
104
+ ` note ${recommendation.runAction.description}`,
105
+ "",
106
+ "card actions:",
107
+ ...recommendation.actions.map((action) => ` ${action.label} ${action.style}${action.tool ? ` tool=${action.tool}` : ""}${action.commandHint ? ` hint=${action.commandHint}` : ""}`),
108
+ "",
109
+ ...recommendation.notes.map((note) => ` note ${note}`)
110
+ ].join("\n");
111
+ export const formatProviders = (providers) => providers
112
+ .map((provider) => {
113
+ const state = provider.enabled ? "enabled" : "disabled";
114
+ const discovery = provider.modelDiscovery
115
+ ? ` discovery=${provider.modelDiscovery.status}:${provider.modelDiscovery.models.length}`
116
+ : "";
117
+ return `${provider.id} (${state}, ${provider.defaultAccessMode}, models=${provider.modelPolicy}${discovery}): ${provider.models.join(", ")} [${provider.accessModes.join(", ")}]`;
118
+ })
119
+ .join("\n");
120
+ export const formatDoctorReport = (report) => [
121
+ `runtime: ${report.runtime.name} ${report.runtime.version}`,
122
+ `capabilities: ${report.runtime.capabilities.join(", ")}`,
123
+ "",
124
+ "providers:",
125
+ ...report.providers.map((provider) => {
126
+ const state = provider.issues.length > 0 ? provider.issues.join(", ") : "ready";
127
+ const command = provider.command ? ` command=${provider.command}` : "";
128
+ const discovery = provider.modelDiscovery
129
+ ? ` modelDiscovery=${provider.modelDiscovery.status}:${provider.modelDiscovery.models.length}`
130
+ : "";
131
+ return ` ${provider.id}: ${state} modes=${provider.accessModes.join(", ")} default=${provider.defaultAccessMode} models=${provider.modelPolicy}${command}${discovery}`;
132
+ }),
133
+ "",
134
+ "roles:",
135
+ ...report.roles.map((role) => {
136
+ const state = role.issues.length > 0 ? role.issues.join(", ") : "ready";
137
+ const resolved = role.resolvedModel ? ` resolved=${role.resolvedModel}` : "";
138
+ return ` ${role.role}: ${formatRoleAssignment(role.assignment)} ${state} model=${role.modelStatus}${resolved}`;
139
+ })
140
+ ].join("\n");
141
+ export const formatConfig = (config) => [
142
+ "defaults:",
143
+ ` maxIterations: ${config.defaults.maxIterations}`,
144
+ ` fanoutMaxItems: ${config.defaults.fanoutMaxItems}`,
145
+ ` editRequiresApproval: ${config.defaults.editRequiresApproval}`,
146
+ ` networkRequiresApproval: ${config.defaults.networkRequiresApproval}`,
147
+ "",
148
+ "approval policy:",
149
+ ` mode: ${config.approvalPolicy.mode}`,
150
+ ` externalTransfers: ${config.approvalPolicy.externalTransfers.mode}`,
151
+ ` maxAutoApproveBytes: ${config.approvalPolicy.externalTransfers.maxAutoApproveBytes}`,
152
+ "",
153
+ "roles:",
154
+ formatRoles(config.roles)
155
+ .split("\n")
156
+ .map((line) => ` ${line}`)
157
+ .join("\n")
158
+ ].join("\n");
159
+ const formatStringList = (label, values) => Array.isArray(values) && values.every((value) => typeof value === "string")
160
+ ? [
161
+ `${label}:`,
162
+ ...values.map((value) => ` - ${value}`)
163
+ ]
164
+ : [];
165
+ const formatDecisionLines = (decision) => [
166
+ ...(typeof decision.action === "string" ? [`action: ${decision.action}`] : []),
167
+ ...(typeof decision.reason === "string" ? [`reason: ${decision.reason}`] : []),
168
+ ...(typeof decision.milestone === "string" ? [`milestone: ${decision.milestone}`] : []),
169
+ ...formatStringList("buildNext", decision.buildNext),
170
+ ...formatStringList("acceptanceCriteria", decision.acceptanceCriteria),
171
+ ...formatStringList("validationHints", decision.validationHints),
172
+ ...(decision.suggestedDelegation && typeof decision.suggestedDelegation === "object" && !Array.isArray(decision.suggestedDelegation)
173
+ ? [
174
+ "suggestedDelegation:",
175
+ ...Object.entries(decision.suggestedDelegation)
176
+ .filter(([, value]) => typeof value === "string" || typeof value === "boolean")
177
+ .map(([key, value]) => ` ${key}: ${String(value)}`)
178
+ ]
179
+ : [])
180
+ ];
181
+ const markdownPreviewLineLimit = 24;
182
+ const formatAgentMarkdownLines = (run, response) => {
183
+ const markdown = response.markdown;
184
+ if (!markdown) {
185
+ return [];
186
+ }
187
+ const previewLines = markdown.preview.trimEnd().split("\n").slice(0, markdownPreviewLineLimit);
188
+ const lineTruncated = markdown.preview.trimEnd().split("\n").length > markdownPreviewLineLimit;
189
+ const truncated = markdown.truncated || lineTruncated;
190
+ return [
191
+ "markdown preview:",
192
+ ...previewLines.map((line) => ` ${line}`),
193
+ ...(truncated ? [` ... truncated (${markdown.charLength} chars)`] : []),
194
+ `inspect: thehood artifact ${run.runId} ${quoteArg(response.artifact.ref)} --repo ${quoteArg(run.repoPath)}`
195
+ ];
196
+ };
197
+ const formatPrimaryOutputLines = (insights) => {
198
+ const response = insights.latestAgentResponse;
199
+ if (!response) {
200
+ return [];
201
+ }
202
+ const primary = response.primaryOutput;
203
+ if (!primary) {
204
+ return [];
205
+ }
206
+ if (response.primaryOutputKey === "decision") {
207
+ return formatDecisionLines(primary);
208
+ }
209
+ return Object.entries(primary)
210
+ .filter(([key, value]) => key !== agentMarkdownField &&
211
+ (typeof value === "string" || typeof value === "number" || typeof value === "boolean"))
212
+ .map(([key, value]) => `${key}: ${String(value)}`);
213
+ };
214
+ const formatMemoryRefLines = (insights) => {
215
+ const refs = [
216
+ ["progress", insights.latestProgressPacket],
217
+ ["reconciliation", insights.latestReconciliation],
218
+ ["repoContext", insights.latestRepoContext],
219
+ ["remoteRepoContext", insights.latestRemoteRepoContext],
220
+ ["providerExecution", insights.latestProviderExecution?.artifact],
221
+ ["revisionPacket", insights.latestRevisionPacket?.artifact],
222
+ ["reviewRouting", insights.latestReviewRouting?.artifact],
223
+ ["fanout", insights.latestFanout?.artifact],
224
+ ["transferManifest", insights.latestTransferManifest]
225
+ ];
226
+ return refs.flatMap(([label, artifact]) => artifact ? [` ${label}: ${artifact.ref}`] : []);
227
+ };
228
+ const formatProviderExecutionLines = (insights) => {
229
+ const executions = insights.recentProviderExecutions.slice(-5);
230
+ if (executions.length === 0) {
231
+ return [];
232
+ }
233
+ return [
234
+ "local agent executions:",
235
+ ...executions.map((execution) => {
236
+ const assignment = [execution.provider, execution.model].filter(Boolean).join(":");
237
+ const owner = [execution.role ?? "role", assignment].filter(Boolean).join(" ");
238
+ const exit = execution.exitCode === undefined ? "exit=unknown" : `exit=${execution.exitCode}`;
239
+ const parsed = execution.responseParsed === undefined ? "" : ` parsed=${execution.responseParsed}`;
240
+ const mode = [
241
+ execution.commandMode,
242
+ execution.workspaceMode,
243
+ execution.sandbox ? `sandbox=${execution.sandbox}` : undefined,
244
+ execution.permissionMode ? `permission=${execution.permissionMode}` : undefined
245
+ ].filter(Boolean).join(" ");
246
+ const logs = [
247
+ execution.stdoutRef ? `stdout=${execution.stdoutRef}` : undefined,
248
+ execution.stderrRef ? `stderr=${execution.stderrRef}` : undefined
249
+ ].filter(Boolean).join(" ");
250
+ return ` ${owner} ${exit}${parsed} ${mode} artifact=${execution.artifact.ref} ${logs}`.trimEnd();
251
+ })
252
+ ];
253
+ };
254
+ const formatCriticTriggerLines = (insights) => {
255
+ const trigger = insights.latestCriticTrigger;
256
+ if (!trigger) {
257
+ return [];
258
+ }
259
+ return [
260
+ "critic trigger:",
261
+ ...(trigger.reasonCode ? [` reasonCode: ${trigger.reasonCode}`] : []),
262
+ ...(trigger.reason ? [` reason: ${trigger.reason}`] : []),
263
+ ...(trigger.sourceRoles.length > 0 ? [` sourceRoles: ${trigger.sourceRoles.join(", ")}`] : []),
264
+ ` artifact: ${trigger.artifact.ref}`,
265
+ ...(trigger.criticResponseRef ? [` criticResponse: ${trigger.criticResponseRef}`] : [])
266
+ ];
267
+ };
268
+ const formatRevisionPacketLines = (insights) => {
269
+ const packet = insights.latestRevisionPacket;
270
+ if (!packet) {
271
+ return [];
272
+ }
273
+ return [
274
+ "revision packet:",
275
+ ...(packet.sourceRole ? [` sourceRole: ${packet.sourceRole}`] : []),
276
+ ...(packet.reasonCode ? [` reasonCode: ${packet.reasonCode}`] : []),
277
+ ...(packet.reason ? [` reason: ${packet.reason}`] : []),
278
+ ...(packet.repairObjective ? [` repairObjective: ${packet.repairObjective}`] : []),
279
+ ` artifact: ${packet.artifact.ref}`,
280
+ ...(packet.sourceResponseRef ? [` sourceResponse: ${packet.sourceResponseRef}`] : []),
281
+ ...(packet.criticTriggerRef ? [` criticTrigger: ${packet.criticTriggerRef}`] : [])
282
+ ];
283
+ };
284
+ const formatRevisionTrailLines = (insights) => insights.revisionTrail.items.slice(-5).flatMap((item) => [
285
+ ` ${item.reasonCode ?? "revision"} ${item.status}${item.active ? " active" : ""} source=${item.sourceRole ?? "unknown"}`,
286
+ ...(item.repairObjective ? [` repairObjective: ${item.repairObjective}`] : []),
287
+ ` packet: ${item.packetArtifactRef}`,
288
+ ...(item.repairResponseRef ? [` repairResponse: ${item.repairResponseRef}`] : []),
289
+ ...(item.validationArtifactRefs.length > 0 ? [` validation: ${item.validationArtifactRefs.join(", ")}`] : []),
290
+ ...(item.reviewResponseRefs.length > 0 ? [` review: ${item.reviewResponseRefs.join(", ")}`] : [])
291
+ ]);
292
+ const formatFanoutLines = (insights) => {
293
+ const fanout = insights.latestFanout;
294
+ if (!fanout) {
295
+ return [];
296
+ }
297
+ return [
298
+ "agent fan-out:",
299
+ ...(fanout.status ? [` status: ${fanout.status}`] : []),
300
+ ...(fanout.executedItems !== undefined && fanout.requestedItems !== undefined
301
+ ? [` items: ${fanout.executedItems}/${fanout.requestedItems}`]
302
+ : []),
303
+ ` artifact: ${fanout.artifact.ref}`,
304
+ ` gates: ${fanout.canSatisfyRequiredGates ? "can satisfy required gates" : "advisory only"}`,
305
+ ...fanout.items.slice(0, 6).map((item) => ` - #${item.index + 1} ${item.role ?? "role"} ${item.status ?? "unknown"} ${item.responseArtifactRef ?? ""}`.trimEnd())
306
+ ];
307
+ };
308
+ const formatReviewRoutingLines = (insights) => {
309
+ const routing = insights.latestReviewRouting;
310
+ if (!routing) {
311
+ return [];
312
+ }
313
+ const required = routing.required ?? {};
314
+ return [
315
+ "review routing:",
316
+ ...(routing.riskTier ? [` risk: ${routing.riskTier}`] : []),
317
+ ...(routing.action ? [` action: ${routing.action}`] : []),
318
+ ` required: validation=${String(required.validation ?? true)} qa=${String(required.qa ?? false)} verifier=${String(required.verifier ?? false)} critic=${String(required.critic ?? false)}`,
319
+ ...routing.reasons.slice(0, 4).map((reason) => ` - ${reason}`),
320
+ ` artifact: ${routing.artifact.ref}`
321
+ ];
322
+ };
323
+ const formatLaneState = (state) => state.replace(/_/g, " ");
324
+ const formatLoopResponsibilityStatus = (status) => status.replace(/_/g, " ");
325
+ const formatReviewLaneOwner = (owner) => owner.assignment ? `${owner.label} (${owner.assignment})` : owner.label;
326
+ const formatReviewLaneLines = (insights) => insights.reviewLanes.flatMap((lane) => {
327
+ const satisfaction = lane.required
328
+ ? lane.satisfiesRequired ? "satisfies" : "missing"
329
+ : "advisory";
330
+ const owner = formatReviewLaneOwner(lane.owner);
331
+ const source = lane.canSatisfyRequired ? lane.sourceKind : `${lane.sourceKind}/read-only`;
332
+ return [
333
+ ` ${lane.kind.padEnd(8)} ${formatLaneState(lane.state).padEnd(14)} ${lane.required ? "required" : "optional"} ${satisfaction} owner=${owner} source=${source}`,
334
+ ` ${lane.summary}`,
335
+ ...(lane.artifactRefs[0] ? [` artifact: ${lane.artifactRefs[0]}`] : []),
336
+ ...(lane.sidecarEvidence.length > 0
337
+ ? [` sidecar: ${lane.sidecarEvidence.length} read-only summon evidence item(s); cannot satisfy required gates`]
338
+ : [])
339
+ ];
340
+ });
341
+ const formatOperatorOwner = (owner) => owner.role ? `${owner.label} (${owner.role})` : owner.label;
342
+ const formatLoopResponsibilityOwner = (owner) => owner.assignment ? `${owner.label} (${owner.assignment})` : owner.label;
343
+ const formatLoopResponsibilityLines = (insights) => insights.loopResponsibilities.responsibilities.slice(0, 10).flatMap((item) => {
344
+ const status = formatLoopResponsibilityStatus(item.status);
345
+ const gate = item.canSatisfyGate ? "gate" : item.sidecarOnly ? "sidecar" : "view";
346
+ return [
347
+ ` ${item.kind.padEnd(17)} ${status.padEnd(12)} ${item.required ? "required" : "optional"} ${gate} owner=${formatLoopResponsibilityOwner(item.owner)}`,
348
+ ` ${item.reason}`,
349
+ ...(item.artifactRefs[0] ? [` artifact: ${item.artifactRefs[0]}`] : []),
350
+ ...(item.eventRefs[0] ? [` event: ${item.eventRefs[0]}`] : [])
351
+ ];
352
+ });
353
+ const formatCrewLaneOwner = (owner) => owner.assignment ? `${owner.label} (${owner.assignment})` : owner.label;
354
+ const formatCrewLaneLines = (insights) => insights.crewLanes.lanes.slice(0, 10).flatMap((lane) => {
355
+ const status = formatLoopResponsibilityStatus(lane.status);
356
+ const gate = lane.canSatisfyGate ? "gate" : lane.sidecarOnly ? "sidecar" : "view";
357
+ const required = lane.required ? (lane.satisfiesRequired ? "satisfies" : "missing") : "advisory";
358
+ return [
359
+ ` ${lane.kind.padEnd(17)} ${status.padEnd(12)} ${lane.authority.padEnd(9)} ${required} ${gate} owner=${formatCrewLaneOwner(lane.owner)}`,
360
+ ` ${lane.summary}`,
361
+ ...(lane.artifactRefs[0] ? [` artifact: ${lane.artifactRefs[0]}`] : []),
362
+ ...(lane.eventRefs[0] ? [` event: ${lane.eventRefs[0]}`] : [])
363
+ ];
364
+ });
365
+ const formatOperatorNextActionLines = (insights) => insights.operatorNextActions.slice(0, 6).flatMap((nextAction) => [
366
+ ` ${nextAction.action.padEnd(24)} ${nextAction.blocking ? "blocking" : "ready"} owner=${formatOperatorOwner(nextAction.owner)}`,
367
+ ` ${nextAction.description}`,
368
+ ...(nextAction.commandHint ? [` command: ${nextAction.commandHint}`] : []),
369
+ ...(nextAction.tool ? [` mcp: ${nextAction.tool}`] : []),
370
+ ...(nextAction.artifactRefs[0] ? [` artifact: ${nextAction.artifactRefs[0]}`] : [])
371
+ ]);
372
+ const handoffEndpoint = (label, assignment, fallback) => {
373
+ const endpoint = label ?? fallback;
374
+ return assignment ? `${endpoint} (${assignment})` : endpoint;
375
+ };
376
+ const handoffToLabel = (handoff) => {
377
+ if (handoff.toLabel) {
378
+ return handoffEndpoint(handoff.toLabel, handoff.toAssignment, "Runtime");
379
+ }
380
+ if (handoff.kind === "approval_gate" || handoff.kind === "approval_auto_approved") {
381
+ return "Approval Gate";
382
+ }
383
+ if (handoff.kind === "completion") {
384
+ return "Completed";
385
+ }
386
+ return "Runtime";
387
+ };
388
+ const formatHandoffSummary = (handoff) => {
389
+ const from = handoffEndpoint(handoff.fromLabel, handoff.fromAssignment, "Runtime");
390
+ const to = handoffToLabel(handoff);
391
+ const gate = handoff.gate ? ` gate=${handoff.gate}` : "";
392
+ return `${handoff.createdAt} ${handoff.kind}${gate} ${from} -> ${to} ${handoff.reason}`;
393
+ };
394
+ const formatRunInsights = (run, insights) => {
395
+ if (!insights) {
396
+ return [];
397
+ }
398
+ const response = insights.latestAgentResponse;
399
+ const finalReport = insights.finalReport;
400
+ const autopilotApprovals = insights.recentAutopilotApprovals.slice(0, 5);
401
+ const handoffTimeline = insights.handoffTimeline.slice(-5);
402
+ const memoryRefs = formatMemoryRefLines(insights);
403
+ const providerExecutions = formatProviderExecutionLines(insights);
404
+ const criticTrigger = formatCriticTriggerLines(insights);
405
+ const revisionPacket = formatRevisionPacketLines(insights);
406
+ const revisionTrail = formatRevisionTrailLines(insights);
407
+ const reviewRouting = formatReviewRoutingLines(insights);
408
+ const fanout = formatFanoutLines(insights);
409
+ const crewLanes = formatCrewLaneLines(insights);
410
+ const reviewLanes = formatReviewLaneLines(insights);
411
+ const loopResponsibilities = formatLoopResponsibilityLines(insights);
412
+ const operatorNextActions = formatOperatorNextActionLines(insights);
413
+ return [
414
+ ...(response
415
+ ? [
416
+ "",
417
+ "latest agent response:",
418
+ ` status: ${response.status}`,
419
+ ` summary: ${response.summary}`,
420
+ ` artifact: ${response.artifact.ref}`,
421
+ ...formatPrimaryOutputLines(insights).map((line) => ` ${line}`),
422
+ ...formatAgentMarkdownLines(run, response).map((line) => ` ${line}`)
423
+ ]
424
+ : []),
425
+ ...(finalReport
426
+ ? [
427
+ "",
428
+ "final report:",
429
+ ` summary: ${finalReport.artifact.summary}`,
430
+ ` artifact: ${finalReport.artifact.ref}`,
431
+ ...(finalReport.stopReason ? [` stopReason: ${finalReport.stopReason}`] : []),
432
+ ` inspect: thehood artifact ${run.runId} ${quoteArg(finalReport.artifact.ref)} --repo ${quoteArg(run.repoPath)}`
433
+ ]
434
+ : []),
435
+ ...(memoryRefs.length > 0
436
+ ? [
437
+ "",
438
+ "canonical memory refs:",
439
+ ...memoryRefs
440
+ ]
441
+ : []),
442
+ ...(providerExecutions.length > 0
443
+ ? [
444
+ "",
445
+ ...providerExecutions
446
+ ]
447
+ : []),
448
+ ...(criticTrigger.length > 0
449
+ ? [
450
+ "",
451
+ ...criticTrigger
452
+ ]
453
+ : []),
454
+ ...(revisionPacket.length > 0
455
+ ? [
456
+ "",
457
+ ...revisionPacket
458
+ ]
459
+ : []),
460
+ ...(revisionTrail.length > 0
461
+ ? [
462
+ "",
463
+ "revision trail:",
464
+ ...revisionTrail
465
+ ]
466
+ : []),
467
+ ...(reviewRouting.length > 0
468
+ ? [
469
+ "",
470
+ ...reviewRouting
471
+ ]
472
+ : []),
473
+ ...(fanout.length > 0
474
+ ? [
475
+ "",
476
+ ...fanout
477
+ ]
478
+ : []),
479
+ ...(crewLanes.length > 0
480
+ ? [
481
+ "",
482
+ "crew lanes:",
483
+ ...crewLanes
484
+ ]
485
+ : []),
486
+ ...(reviewLanes.length > 0
487
+ ? [
488
+ "",
489
+ "review lanes:",
490
+ ...reviewLanes
491
+ ]
492
+ : []),
493
+ ...(loopResponsibilities.length > 0
494
+ ? [
495
+ "",
496
+ "loop responsibilities:",
497
+ ...loopResponsibilities
498
+ ]
499
+ : []),
500
+ ...(operatorNextActions.length > 0
501
+ ? [
502
+ "",
503
+ "operator next actions:",
504
+ ...operatorNextActions
505
+ ]
506
+ : []),
507
+ ...(insights.latestHandoff
508
+ ? [
509
+ "",
510
+ "latest handoff:",
511
+ ` ${formatHandoffSummary(insights.latestHandoff)}`
512
+ ]
513
+ : []),
514
+ ...(handoffTimeline.length > 0
515
+ ? [
516
+ "",
517
+ "handoff timeline:",
518
+ ...handoffTimeline.map((handoff) => ` ${formatHandoffSummary(handoff)}`)
519
+ ]
520
+ : []),
521
+ ...(autopilotApprovals.length > 0
522
+ ? [
523
+ "",
524
+ "recent autopilot approvals:",
525
+ ...autopilotApprovals.flatMap((approval) => [
526
+ ` ${approval.createdAt} ${approval.gate ?? "autopilot"} ${approval.policyReason ?? approval.message}`,
527
+ ...(approval.artifact ? [` artifact: ${approval.artifact.ref}`] : []),
528
+ ...(approval.sourceArtifact ? [` source: ${approval.sourceArtifact.ref}`] : [])
529
+ ])
530
+ ]
531
+ : []),
532
+ ...(insights.issues.length > 0
533
+ ? [
534
+ "",
535
+ "insight issues:",
536
+ ...insights.issues.map((issue) => ` - ${issue}`)
537
+ ]
538
+ : [])
539
+ ];
540
+ };
541
+ export const formatRunSummary = (run, insights) => {
542
+ const approval = run.approvalRequired
543
+ ? `\napproval: required (${run.approvalReason ?? "no reason recorded"})`
544
+ : "\napproval: not required";
545
+ return [
546
+ `run: ${run.runId}`,
547
+ `state: ${run.state}`,
548
+ `mode: ${run.mode}`,
549
+ `repo: ${run.repoPath}`,
550
+ `goal: ${run.userGoal}`,
551
+ approval,
552
+ "",
553
+ "roles:",
554
+ formatRoles(run.roleMapping)
555
+ .split("\n")
556
+ .map((line) => ` ${line}`)
557
+ .join("\n"),
558
+ ...formatRunInsights(run, insights)
559
+ ].join("\n");
560
+ };
561
+ export const formatRunList = (runs) => {
562
+ if (runs.length === 0) {
563
+ return "No runs found.";
564
+ }
565
+ return runs
566
+ .map((run) => `${run.runId} ${run.state} ${run.mode} ${run.userGoal}`)
567
+ .join("\n");
568
+ };
569
+ export const formatRunEvents = (run) => [
570
+ ...run.events.map((event) => `${event.createdAt} ${event.type} ${event.message}`),
571
+ ...((run.handoffs ?? []).length > 0
572
+ ? [
573
+ "",
574
+ "handoffs:",
575
+ ...recentRunHandoffSummaries(run, 10).map((handoff) => formatHandoffSummary(handoff))
576
+ ]
577
+ : [])
578
+ ].join("\n");
579
+ export const formatCommandResult = (result) => [
580
+ `command: ${[result.event.command, ...result.event.args].join(" ")}`,
581
+ `exitCode: ${result.event.exitCode}`,
582
+ `cwd: ${result.event.cwd}`,
583
+ `safety: ${result.event.safetyCategory}`,
584
+ `stdout: ${result.event.stdoutRef ?? "none"}`,
585
+ `stderr: ${result.event.stderrRef ?? "none"}`
586
+ ].join("\n");
587
+ export const formatGitEvidence = (result) => [
588
+ `changedPaths: ${result.changedPaths.length}`,
589
+ `protectedChanges: ${result.protectedChanges.length}`,
590
+ ...result.changedPaths.map((changedPath) => ` ${changedPath}`),
591
+ ...(result.protectedChanges.length > 0
592
+ ? [
593
+ "",
594
+ "protected:",
595
+ ...result.protectedChanges.map((match) => ` ${match.path} (${match.pattern})`)
596
+ ]
597
+ : [])
598
+ ].join("\n");
599
+ export const formatAdvanceRunResult = (result) => [
600
+ formatRunSummary(result.run),
601
+ "",
602
+ `advanced: ${result.advanced}`,
603
+ `stopReason: ${result.stopReason}`,
604
+ `providerResponses: ${result.providerResponses.length}`
605
+ ].join("\n");
606
+ export const formatRunLoopResult = (result) => [
607
+ formatRunSummary(result.run),
608
+ "",
609
+ `advanced: ${result.advanced}`,
610
+ `stopKind: ${result.stopKind}`,
611
+ `stopReason: ${result.stopReason}`,
612
+ `cycles: ${result.cycles.length}/${result.maxCycles}`,
613
+ `maxStepsPerCycle: ${result.maxStepsPerCycle}`,
614
+ `providerResponses: ${result.providerResponses.length}`,
615
+ "",
616
+ "cycle log:",
617
+ ...result.cycles.map((cycle) => ` #${cycle.cycle} state=${cycle.state} advanced=${cycle.advanced} responses=${cycle.providerResponseCount} stop=${cycle.stopReason}`)
618
+ ].join("\n");
619
+ export const formatReconcileRunResult = (result) => [
620
+ formatRunSummary(result.run),
621
+ "",
622
+ `reconcileRole: ${result.role}`,
623
+ `advanced: ${result.advanced}`,
624
+ `stopReason: ${result.stopReason}`,
625
+ ...(result.progressArtifact
626
+ ? [
627
+ `progress: ${result.progressArtifact.summary}`,
628
+ `progressArtifact: ${result.progressArtifact.ref}`
629
+ ]
630
+ : []),
631
+ ...(result.reconciliationArtifact
632
+ ? [
633
+ `reconciliation: ${result.reconciliationArtifact.summary}`,
634
+ `reconciliationArtifact: ${result.reconciliationArtifact.ref}`,
635
+ `inspect: thehood artifact ${result.run.runId} ${quoteArg(result.reconciliationArtifact.ref)} --repo ${quoteArg(result.run.repoPath)}`
636
+ ]
637
+ : []),
638
+ `providerResponses: ${result.providerResponses.length}`
639
+ ].join("\n");
640
+ export const formatSummonAgentResult = (result) => [
641
+ formatRunSummary(result.run),
642
+ "",
643
+ `summonRole: ${result.role}`,
644
+ `summonKind: ${result.summonKind}`,
645
+ `agent: ${formatRoleAssignment(result.assignment)}`,
646
+ `advanced: ${result.advanced}`,
647
+ `stopReason: ${result.stopReason}`,
648
+ ...(result.directiveArtifact ? [`directiveArtifact: ${result.directiveArtifact.ref}`] : []),
649
+ ...(result.responseArtifact ? [`responseArtifact: ${result.responseArtifact.ref}`] : []),
650
+ `providerResponses: ${result.providerResponses.length}`
651
+ ].join("\n");
652
+ export const formatFanoutAgentsResult = (result) => [
653
+ formatRunSummary(result.run),
654
+ "",
655
+ `fanoutStatus: ${result.status}`,
656
+ `items: ${result.bounds.executedItems}/${result.bounds.requestedItems}`,
657
+ `maxItems: ${result.bounds.maxItems}`,
658
+ `artifact: ${result.artifact.ref}`,
659
+ ...result.items.map((item) => ` #${item.index + 1} ${item.role}/${item.summonKind} ${item.status}: ${item.stopReason}`)
660
+ ].join("\n");
661
+ export const formatExternalTransferPreview = (preview) => [
662
+ `manifest: ${preview.manifestArtifact.ref}`,
663
+ `destination: ${formatRoleAssignment(preview.manifest.destination)}`,
664
+ `purpose: ${preview.manifest.purpose}`,
665
+ `risk: ${preview.manifest.risk.class}`,
666
+ `totalBytes: ${preview.manifest.totalBytes}`,
667
+ `approval: ${preview.manifest.approvalHint}`,
668
+ "",
669
+ "artifacts:",
670
+ ...preview.manifest.artifacts.map((artifact) => ` ${artifact.kind}: ${artifact.summary} (${artifact.byteLength} bytes, sha256 ${artifact.sha256.slice(0, 12)})`),
671
+ "",
672
+ "risk reasons:",
673
+ ...preview.manifest.risk.reasons.map((reason) => ` - ${reason}`),
674
+ "",
675
+ "preview:",
676
+ preview.manifest.preview.content,
677
+ ...(preview.manifest.preview.truncated ? ["", "preview truncated"] : [])
678
+ ].join("\n");
679
+ export const formatMcpConfigReport = (report) => [
680
+ "installed package:",
681
+ report.installedToml,
682
+ "",
683
+ "local build:",
684
+ report.localToml
685
+ ].join("\n");
686
+ export const formatCliSetupReport = (report) => [
687
+ "TheHood CLI Setup",
688
+ "",
689
+ "run this local build:",
690
+ ` ${report.localBuildCommand}`,
691
+ "",
692
+ "temporary shell alias:",
693
+ ` ${report.oneSessionAlias}`,
694
+ "",
695
+ "optional install/link commands:",
696
+ ` ${report.npmLinkCommand}`,
697
+ ` ${report.npmInstallCommand}`,
698
+ "",
699
+ "MCP config:",
700
+ ` local: ${report.localMcpConfigCommand}`,
701
+ ` installed: ${report.installedMcpConfigCommand}`,
702
+ "",
703
+ "TUI:",
704
+ ` local: ${report.localUiCommand}`,
705
+ ` installed: ${report.installedUiCommand}`,
706
+ "",
707
+ "notes:",
708
+ ...report.notes.map((note) => ` - ${note}`)
709
+ ].join("\n");
710
+ export const formatMcpTunnelConfigReport = (report) => [
711
+ "installed package tunnel:",
712
+ report.installed.initCommand,
713
+ "",
714
+ report.installed.doctorCommand,
715
+ report.installed.runCommand,
716
+ "",
717
+ "local build tunnel:",
718
+ report.local.initCommand,
719
+ "",
720
+ report.local.doctorCommand,
721
+ report.local.runCommand,
722
+ "",
723
+ "ChatGPT connector:",
724
+ ...report.chatGptSteps.map((step) => ` - ${step}`),
725
+ "",
726
+ "notes:",
727
+ ...report.notes.map((note) => ` - ${note}`)
728
+ ].join("\n");
729
+ export const formatBrowserStatus = (status) => [
730
+ `provider: ${status.provider}`,
731
+ `readyForBridge: ${status.readyForBridge}`,
732
+ `cdp: ${status.cdpReachable ? "reachable" : "unreachable"} (${status.cdpUrl})`,
733
+ `chatgptTab: ${status.chatGptTabFound ? "found" : "not found"}`,
734
+ `chatgptPage: ${status.chatGptPageInspected ? "inspected" : "not inspected"}`,
735
+ `chatgptAuth: ${status.chatGptAuthenticated ? "authenticated" : "not ready"}`,
736
+ `composer: ${status.chatGptComposerReady ? "ready" : "not ready"}`,
737
+ `profile: ${status.profilePath}`,
738
+ ...(status.chromePath ? [`chrome: ${status.chromePath}`] : []),
739
+ ...(status.pid ? [`pid: ${status.pid}`] : []),
740
+ `targets: ${status.targetCount}`,
741
+ `issues: ${status.issues.length > 0 ? status.issues.join(", ") : "none"}`
742
+ ].join("\n");
743
+ export const formatBrowserStartResult = (result) => [
744
+ `launched: ${result.launched}`,
745
+ formatBrowserStatus(result.status)
746
+ ].join("\n");
747
+ export const formatBrowserStopResult = (result) => [
748
+ `stopped: ${result.stopped}`,
749
+ ...(result.reason ? [`reason: ${result.reason}`] : []),
750
+ formatBrowserStatus(result.status)
751
+ ].join("\n");
752
+ //# sourceMappingURL=format.js.map