@arnilo/prism-hosts 0.0.0-stage → 0.13.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 (322) hide show
  1. package/CHANGELOG.md +394 -0
  2. package/LICENSE +21 -0
  3. package/README.md +34 -2
  4. package/acp/README.md +87 -0
  5. package/acp/src/capabilities.ts +184 -0
  6. package/acp/src/errors.ts +24 -0
  7. package/acp/src/host.ts +36 -0
  8. package/acp/src/index.ts +25 -0
  9. package/acp/src/limits.ts +49 -0
  10. package/acp/src/mapper.ts +419 -0
  11. package/acp/src/permission.ts +37 -0
  12. package/acp/src/projection.ts +39 -0
  13. package/acp/src/prompt.ts +170 -0
  14. package/acp/src/serve.ts +345 -0
  15. package/acp/src/session-map.ts +49 -0
  16. package/ag-ui/README.md +56 -0
  17. package/ag-ui/src/a2ui.ts +570 -0
  18. package/ag-ui/src/ag-ui-mapper.ts +507 -0
  19. package/ag-ui/src/encrypted-value.ts +40 -0
  20. package/ag-ui/src/errors.ts +29 -0
  21. package/ag-ui/src/handler.ts +642 -0
  22. package/ag-ui/src/index.ts +177 -0
  23. package/ag-ui/src/input.ts +190 -0
  24. package/ag-ui/src/limits.ts +279 -0
  25. package/ag-ui/src/mcp-apps.ts +256 -0
  26. package/ag-ui/src/mcp.ts +94 -0
  27. package/ag-ui/src/projection.ts +201 -0
  28. package/ag-ui/src/projectors.ts +272 -0
  29. package/ag-ui/src/renderer/bind.ts +152 -0
  30. package/ag-ui/src/renderer/core.ts +270 -0
  31. package/ag-ui/src/renderer/index.ts +165 -0
  32. package/ag-ui/src/replay.ts +189 -0
  33. package/ag-ui/src/types.ts +66 -0
  34. package/channels/README.md +139 -0
  35. package/channels/src/admission.ts +8 -0
  36. package/channels/src/approvals.ts +262 -0
  37. package/channels/src/checkpoint-contract.ts +97 -0
  38. package/channels/src/delivery.ts +116 -0
  39. package/channels/src/host-ui.ts +356 -0
  40. package/channels/src/identity.ts +46 -0
  41. package/channels/src/index.ts +82 -0
  42. package/channels/src/limits.ts +49 -0
  43. package/channels/src/memory-stores.ts +112 -0
  44. package/channels/src/pairing.ts +178 -0
  45. package/channels/src/runtime-admit.ts +389 -0
  46. package/channels/src/runtime-core.ts +621 -0
  47. package/channels/src/runtime-reconcile.ts +299 -0
  48. package/channels/src/runtime-turn.ts +664 -0
  49. package/channels/src/runtime-types.ts +95 -0
  50. package/channels/src/runtime.ts +86 -0
  51. package/channels/src/secret-ref.ts +42 -0
  52. package/channels/src/signal.ts +790 -0
  53. package/channels/src/state.ts +355 -0
  54. package/channels/src/telegram.ts +1317 -0
  55. package/channels/src/types.ts +442 -0
  56. package/devtools/README.md +92 -0
  57. package/devtools/bin/prism-devtools.ts +63 -0
  58. package/devtools/src/args.ts +71 -0
  59. package/devtools/src/bun.d.ts +27 -0
  60. package/devtools/src/compare.ts +190 -0
  61. package/devtools/src/errors.ts +15 -0
  62. package/devtools/src/index.ts +25 -0
  63. package/devtools/src/replay.ts +36 -0
  64. package/devtools/src/security.ts +80 -0
  65. package/devtools/src/serve.ts +259 -0
  66. package/devtools/src/ui/assets.ts +108 -0
  67. package/devtools/src/ui/inspector.ts +182 -0
  68. package/driver-process/README.md +197 -0
  69. package/driver-process/src/abort.ts +74 -0
  70. package/driver-process/src/adapter.ts +211 -0
  71. package/driver-process/src/driver.ts +303 -0
  72. package/driver-process/src/errors.ts +17 -0
  73. package/driver-process/src/extend.ts +72 -0
  74. package/driver-process/src/index.ts +5 -0
  75. package/driver-process/src/inspect.ts +33 -0
  76. package/driver-process/src/session.ts +72 -0
  77. package/driver-process/src/testing.ts +394 -0
  78. package/driver-process/src/transports/json-rpc.ts +147 -0
  79. package/driver-process/src/transports/jsonl-stream.ts +12 -0
  80. package/driver-process/src/transports/types.ts +11 -0
  81. package/driver-process/src/turn.ts +106 -0
  82. package/evals/README.md +843 -0
  83. package/evals/src/calibration.ts +179 -0
  84. package/evals/src/citation-integrity.ts +98 -0
  85. package/evals/src/citations.ts +45 -0
  86. package/evals/src/compare-experiments.ts +153 -0
  87. package/evals/src/comparison.ts +230 -0
  88. package/evals/src/curate.ts +257 -0
  89. package/evals/src/dataset.ts +81 -0
  90. package/evals/src/erp-invariants.ts +163 -0
  91. package/evals/src/errors.ts +23 -0
  92. package/evals/src/experiment.ts +537 -0
  93. package/evals/src/failure-injection.ts +77 -0
  94. package/evals/src/feedback.ts +53 -0
  95. package/evals/src/index.ts +198 -0
  96. package/evals/src/injection.ts +247 -0
  97. package/evals/src/judge-panel.ts +109 -0
  98. package/evals/src/judge.ts +89 -0
  99. package/evals/src/limits.ts +50 -0
  100. package/evals/src/report-record.ts +47 -0
  101. package/evals/src/rubric-judge.ts +334 -0
  102. package/evals/src/scenario-runner.ts +317 -0
  103. package/evals/src/scenarios.ts +81 -0
  104. package/evals/src/score.ts +328 -0
  105. package/evals/src/scorer.ts +21 -0
  106. package/evals/src/state-match.ts +130 -0
  107. package/evals/src/stats.ts +635 -0
  108. package/evals/src/threshold.ts +117 -0
  109. package/evals/src/timeline.ts +38 -0
  110. package/evals/src/toolless-session.ts +33 -0
  111. package/evals/src/trace.ts +80 -0
  112. package/evals/src/trajectory.ts +623 -0
  113. package/evals/src/types.ts +672 -0
  114. package/evals/src/user-simulator.ts +101 -0
  115. package/evals/src/util.ts +207 -0
  116. package/headless/README.md +172 -0
  117. package/headless/src/answers.ts +91 -0
  118. package/headless/src/authority.ts +32 -0
  119. package/headless/src/errors.ts +36 -0
  120. package/headless/src/index.ts +17 -0
  121. package/headless/src/limits.ts +11 -0
  122. package/headless/src/pending.ts +16 -0
  123. package/headless/src/policy.ts +36 -0
  124. package/headless/src/resume.ts +103 -0
  125. package/headless/src/route.ts +153 -0
  126. package/headless/src/scheduler/clock.ts +22 -0
  127. package/headless/src/scheduler/cron.ts +19 -0
  128. package/headless/src/scheduler/firing.ts +58 -0
  129. package/headless/src/scheduler/index.ts +399 -0
  130. package/headless/src/scheduler/lease.ts +38 -0
  131. package/headless/src/scheduler/missed.ts +12 -0
  132. package/headless/src/scheduler/state.ts +132 -0
  133. package/host-builder/README.md +251 -0
  134. package/host-builder/bin/prism-host-builder.ts +169 -0
  135. package/host-builder/data/api.json +6167 -0
  136. package/host-builder/data/errors.json +546 -0
  137. package/host-builder/data/examples/acp.ts +63 -0
  138. package/host-builder/data/examples/adapters/conformance.ts +34 -0
  139. package/host-builder/data/examples/adapters/fixtures/rpc-server.json +26 -0
  140. package/host-builder/data/examples/adapters/fixtures/stream-cli.json +27 -0
  141. package/host-builder/data/examples/adapters/fixtures/workspace-config.json +28 -0
  142. package/host-builder/data/examples/adapters/rpc-server.dialect.ts +218 -0
  143. package/host-builder/data/examples/adapters/rpc-server.ts +309 -0
  144. package/host-builder/data/examples/adapters/stream-cli.dialect.ts +165 -0
  145. package/host-builder/data/examples/adapters/stream-cli.ts +256 -0
  146. package/host-builder/data/examples/adapters/workspace-config.dialect.ts +172 -0
  147. package/host-builder/data/examples/adapters/workspace-config.ts +251 -0
  148. package/host-builder/data/examples/advisor.ts +94 -0
  149. package/host-builder/data/examples/ag-ui-a2ui.ts +80 -0
  150. package/host-builder/data/examples/ag-ui-mcp-apps.ts +44 -0
  151. package/host-builder/data/examples/ag-ui-server.ts +118 -0
  152. package/host-builder/data/examples/agent-durable-approval.ts +43 -0
  153. package/host-builder/data/examples/api-key-auth.ts +23 -0
  154. package/host-builder/data/examples/approval.ts +92 -0
  155. package/host-builder/data/examples/attention-compiler.ts +81 -0
  156. package/host-builder/data/examples/autonomous-coding-loop.ts +343 -0
  157. package/host-builder/data/examples/behavior-evaluation.ts +303 -0
  158. package/host-builder/data/examples/build-workflow.ts +334 -0
  159. package/host-builder/data/examples/cache-aware-prompt-assembly.ts +139 -0
  160. package/host-builder/data/examples/caveman-ponytail.ts +197 -0
  161. package/host-builder/data/examples/cli.ts +31 -0
  162. package/host-builder/data/examples/coding-approval.ts +115 -0
  163. package/host-builder/data/examples/coding-browser-evaluation.ts +208 -0
  164. package/host-builder/data/examples/coding-compaction.ts +30 -0
  165. package/host-builder/data/examples/coding-goal-verify.ts +121 -0
  166. package/host-builder/data/examples/coding-tools-capability-gaps.ts +75 -0
  167. package/host-builder/data/examples/compaction.ts +36 -0
  168. package/host-builder/data/examples/connected-slack-mcp.ts +67 -0
  169. package/host-builder/data/examples/context.ts +29 -0
  170. package/host-builder/data/examples/custom-adapter.ts +256 -0
  171. package/host-builder/data/examples/custom-builders.ts +66 -0
  172. package/host-builder/data/examples/custom-loop.ts +89 -0
  173. package/host-builder/data/examples/custom-provider.ts +70 -0
  174. package/host-builder/data/examples/custom-session-store.ts +72 -0
  175. package/host-builder/data/examples/custom-tools-skills-context.ts +97 -0
  176. package/host-builder/data/examples/decision-models.ts +98 -0
  177. package/host-builder/data/examples/define-package.ts +188 -0
  178. package/host-builder/data/examples/delegate.ts +200 -0
  179. package/host-builder/data/examples/discover-skills.ts +65 -0
  180. package/host-builder/data/examples/drive-rag-sync.ts +44 -0
  181. package/host-builder/data/examples/durable-approval.ts +139 -0
  182. package/host-builder/data/examples/durable-investigation.ts +93 -0
  183. package/host-builder/data/examples/durable-loops-and-approvals.ts +94 -0
  184. package/host-builder/data/examples/enterprise-identity.ts +21 -0
  185. package/host-builder/data/examples/enterprise-policy-audit.ts +50 -0
  186. package/host-builder/data/examples/enterprise-work-connectors.ts +103 -0
  187. package/host-builder/data/examples/eval-injection.ts +73 -0
  188. package/host-builder/data/examples/eval-judges.ts +145 -0
  189. package/host-builder/data/examples/evals.ts +86 -0
  190. package/host-builder/data/examples/evaluation-gate.ts +40 -0
  191. package/host-builder/data/examples/execution-timeline.ts +173 -0
  192. package/host-builder/data/examples/external-agent.ts +541 -0
  193. package/host-builder/data/examples/external-app-db-backed.ts +344 -0
  194. package/host-builder/data/examples/governance-deny.ts +122 -0
  195. package/host-builder/data/examples/guardrail-packs.ts +240 -0
  196. package/host-builder/data/examples/headless-host.ts +245 -0
  197. package/host-builder/data/examples/hooks-audit-command.mjs +31 -0
  198. package/host-builder/data/examples/hooks-json.ts +87 -0
  199. package/host-builder/data/examples/host-builder-agent.ts +150 -0
  200. package/host-builder/data/examples/host-hooks.ts +71 -0
  201. package/host-builder/data/examples/host-step-loop-timeline.ts +212 -0
  202. package/host-builder/data/examples/hosted-sandbox.ts +48 -0
  203. package/host-builder/data/examples/instruction-injection.ts +127 -0
  204. package/host-builder/data/examples/jsonl-stores-branching.ts +49 -0
  205. package/host-builder/data/examples/long-term-memory.ts +158 -0
  206. package/host-builder/data/examples/manifest.ts +112 -0
  207. package/host-builder/data/examples/mcp-server.ts +48 -0
  208. package/host-builder/data/examples/mcp-trust.ts +173 -0
  209. package/host-builder/data/examples/memory-and-wiki.ts +315 -0
  210. package/host-builder/data/examples/memory-lifecycle.ts +302 -0
  211. package/host-builder/data/examples/memory-system.ts +252 -0
  212. package/host-builder/data/examples/messaging-agent.ts +70 -0
  213. package/host-builder/data/examples/minimal-host-app.ts +41 -0
  214. package/host-builder/data/examples/model-router-aggregate-budgets.ts +364 -0
  215. package/host-builder/data/examples/model-router.ts +106 -0
  216. package/host-builder/data/examples/obscura.ts +48 -0
  217. package/host-builder/data/examples/observability.ts +116 -0
  218. package/host-builder/data/examples/open-connector-sidecar.ts +105 -0
  219. package/host-builder/data/examples/openai-compatible.ts +70 -0
  220. package/host-builder/data/examples/package-skills.ts +85 -0
  221. package/host-builder/data/examples/phase9-coding-intelligence.ts +221 -0
  222. package/host-builder/data/examples/provider-registration.ts +29 -0
  223. package/host-builder/data/examples/provider-resolver.ts +39 -0
  224. package/host-builder/data/examples/rag.ts +40 -0
  225. package/host-builder/data/examples/remote-agent-server.ts +45 -0
  226. package/host-builder/data/examples/remote-agent.ts +124 -0
  227. package/host-builder/data/examples/research-ledger.ts +79 -0
  228. package/host-builder/data/examples/revocation-propagation.ts +287 -0
  229. package/host-builder/data/examples/run-feedback.ts +93 -0
  230. package/host-builder/data/examples/scanned-document-rag.ts +48 -0
  231. package/host-builder/data/examples/sdk-basics.ts +21 -0
  232. package/host-builder/data/examples/secure-agent.ts +55 -0
  233. package/host-builder/data/examples/semantic-memory.ts +52 -0
  234. package/host-builder/data/examples/serve-tools.ts +495 -0
  235. package/host-builder/data/examples/session-memory.ts +317 -0
  236. package/host-builder/data/examples/session-search.ts +131 -0
  237. package/host-builder/data/examples/session.ts +52 -0
  238. package/host-builder/data/examples/side-call.ts +64 -0
  239. package/host-builder/data/examples/signal-agent.ts +9 -0
  240. package/host-builder/data/examples/skills-progressive-disclosure.ts +88 -0
  241. package/host-builder/data/examples/skills.ts +19 -0
  242. package/host-builder/data/examples/sqlite-resume.ts +147 -0
  243. package/host-builder/data/examples/system-project-prompts.ts +74 -0
  244. package/host-builder/data/examples/system-prompts.ts +19 -0
  245. package/host-builder/data/examples/telegram-agent.ts +30 -0
  246. package/host-builder/data/examples/tool-narrowing-planes.ts +99 -0
  247. package/host-builder/data/examples/tools.ts +29 -0
  248. package/host-builder/data/examples/validator.ts +67 -0
  249. package/host-builder/data/examples/web-no-key.ts +85 -0
  250. package/host-builder/data/examples/web-research.ts +35 -0
  251. package/host-builder/data/examples/workflow-event-sink.ts +114 -0
  252. package/host-builder/data/examples/workflow-loop.ts +93 -0
  253. package/host-builder/data/examples/workflow-multimodal-document.ts +94 -0
  254. package/host-builder/data/examples/workflow-parallel-research.ts +111 -0
  255. package/host-builder/data/examples/workflow-postgres-resume.ts +75 -0
  256. package/host-builder/data/examples/workflow-research-and-review.ts +98 -0
  257. package/host-builder/data/examples/workflow-sqlite-resume.ts +163 -0
  258. package/host-builder/data/examples.json +130 -0
  259. package/host-builder/skills/prism-host-builder/SKILL.md +85 -0
  260. package/host-builder/skills/prism-host-builder/references/choosing.md +101 -0
  261. package/host-builder/skills/prism-host-builder/references/layout.md +52 -0
  262. package/host-builder/skills/prism-host-builder/references/pitfalls.md +50 -0
  263. package/host-builder/skills/prism-host-builder/references/recipes.md +129 -0
  264. package/host-builder/skills/prism-host-builder/references/security.md +52 -0
  265. package/host-builder/skills/prism-host-builder/references/upgrading.md +67 -0
  266. package/host-builder/skills/prism-host-builder/references/verification.md +108 -0
  267. package/host-builder/src/check/child.ts +108 -0
  268. package/host-builder/src/check/conformance.ts +13 -0
  269. package/host-builder/src/check/inspect.ts +20 -0
  270. package/host-builder/src/check/manifest.ts +23 -0
  271. package/host-builder/src/check/runner.ts +181 -0
  272. package/host-builder/src/check/targets.ts +65 -0
  273. package/host-builder/src/errors.ts +35 -0
  274. package/host-builder/src/index.ts +25 -0
  275. package/host-builder/src/indexes.ts +145 -0
  276. package/host-builder/src/install/install.ts +400 -0
  277. package/host-builder/src/install/targets.ts +50 -0
  278. package/host-builder/src/lookup/api.ts +127 -0
  279. package/host-builder/src/lookup/bound.ts +38 -0
  280. package/host-builder/src/lookup/docs.ts +238 -0
  281. package/host-builder/src/lookup/errors.ts +92 -0
  282. package/host-builder/src/lookup/examples.ts +117 -0
  283. package/host-builder/src/lookup/text.ts +60 -0
  284. package/host-builder/src/server.ts +300 -0
  285. package/host-builder/src/version.ts +38 -0
  286. package/mcp-server/README.md +219 -0
  287. package/mcp-server/src/bounds.ts +23 -0
  288. package/mcp-server/src/host.ts +31 -0
  289. package/mcp-server/src/index.ts +27 -0
  290. package/mcp-server/src/serve-tools.ts +408 -0
  291. package/mcp-server/src/serve.ts +329 -0
  292. package/mcp-server/src/server.ts +331 -0
  293. package/mcp-server/src/session-map.ts +47 -0
  294. package/mcp-server/src/skill-resources.ts +85 -0
  295. package/mcp-server/src/types.ts +215 -0
  296. package/package.json +130 -4
  297. package/remote/README.md +244 -0
  298. package/remote/src/attribution.ts +22 -0
  299. package/remote/src/auth.ts +30 -0
  300. package/remote/src/bun-module.d.ts +34 -0
  301. package/remote/src/channel.ts +86 -0
  302. package/remote/src/connect.ts +212 -0
  303. package/remote/src/dispatcher.ts +282 -0
  304. package/remote/src/errors.ts +59 -0
  305. package/remote/src/host-ui.ts +152 -0
  306. package/remote/src/http-gate.ts +43 -0
  307. package/remote/src/index.ts +53 -0
  308. package/remote/src/jsonl.ts +69 -0
  309. package/remote/src/limits.ts +43 -0
  310. package/remote/src/mirror.ts +90 -0
  311. package/remote/src/pending.ts +22 -0
  312. package/remote/src/protocol.ts +107 -0
  313. package/remote/src/serve.ts +560 -0
  314. package/remote/src/session-proxy.ts +219 -0
  315. package/remote/src/sse.ts +38 -0
  316. package/remote/src/stdio-client.ts +41 -0
  317. package/remote/src/testing-fixtures/serve-stdio.ts +32 -0
  318. package/remote/src/testing.ts +230 -0
  319. package/remote/src/transport.ts +139 -0
  320. package/remote/src/transports/client.ts +126 -0
  321. package/remote/src/transports/network.ts +268 -0
  322. package/remote/src/wire.ts +244 -0
@@ -0,0 +1,251 @@
1
+ # @arnilo/prism-hosts/host-builder
2
+
3
+ Version-exact reference data for coding agents that build or change a [Prism](../../../README.md) host. It ships
4
+ indexes generated from the `@arnilo/prism` version it is released with, so what an agent reads is what the
5
+ installed kernel and packages export, and never a remembered 0.12 contract.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ bun add -d @arnilo/prism-hosts
11
+ ```
12
+
13
+ It is a development dependency: it adds nothing to an agent at run time and registers no package, hook, slot,
14
+ tool or skill. Its peer is `@arnilo/prism` (`>=0.13.0 <1.0.0`).
15
+
16
+ ## What it ships
17
+
18
+ | File | Holds |
19
+ | --- | --- |
20
+ | `data/api.json` | Every public name of `@arnilo/prism`, its subpaths and every published package: kind, signature, one-line summary, the docs pages and READMEs that mention it, the examples that import it. |
21
+ | `data/errors.json` | Every `ERR_PRISM_*` code from the source scan and the short codes of the `*ErrorCode` unions: owning package, declaring file and line, error class, meaning from the doc comment, a sample message from the first throw site, and the docs that mention it. |
22
+ | `data/examples.json` | The CI-tested examples: path, title, imported packages, whether they need credentials. |
23
+ | `data/examples/**` | The example sources, verbatim. |
24
+
25
+ Each file records `prismVersion` and a `contentHash`. The files are generated, never edited by hand:
26
+
27
+ ```bash
28
+ bun scripts/host-builder-index.mjs # regenerate packages/hosts/host-builder/data
29
+ bun scripts/host-builder-index.mjs --check # fail if the committed data is stale
30
+ ```
31
+
32
+ The generator reuses the release gate's declaration model (`scripts/release-gates.mjs`) and reads only `src/`,
33
+ `packages/*/src`, `docs/`, the package READMEs and `examples/`. It leaves out `docs/history/**` and the
34
+ `migrate-to-0.5` … `0.11` pages, which describe retired contracts, and it fails when a copied example holds a
35
+ secret-shaped literal.
36
+
37
+ ## Use
38
+
39
+ ```ts
40
+ import { loadHostBuilderIndex, readExampleSource } from "@arnilo/prism-hosts/host-builder";
41
+
42
+ const api = await loadHostBuilderIndex("api");
43
+ const kernel = api.packages.find((pkg) => pkg.name === "@arnilo/prism");
44
+ const source = await readExampleSource("examples/define-package.ts");
45
+ ```
46
+
47
+ An index loads on the first call that needs it, not at import. `readExampleSource` serves only paths that
48
+ `examples.json` lists.
49
+
50
+ ```bash
51
+ prism-host-builder info # Prism version and the size of each index
52
+ prism-host-builder install --target claude --mcp # copy the skill and add the MCP server to a coding agent
53
+ prism-host-builder mcp # serve the lookup tools, docs resources and prompts over stdio
54
+ prism-host-builder --help # usage
55
+ ```
56
+
57
+ An unknown command exits 2.
58
+
59
+ ## The skill
60
+
61
+ `skills/prism-host-builder/` is an Agent Skills package skill for a coding agent that builds, changes, upgrades or
62
+ debugs a Prism host. `SKILL.md` (at most 8 KiB) holds the workflow (orient, choose, build, verify, report) and a map of
63
+ seven references: `choosing`, `layout`, `recipes`, `pitfalls`, `security`, `verification` and `upgrading`. It holds
64
+ judgment and pointers. Signatures, options and code live in the installed docs, the indexes above and the CI-tested
65
+ examples, and the skill links to them with project-relative paths (`node_modules/@arnilo/prism/docs/<page>.md`,
66
+ `node_modules/@arnilo/<package>/README.md`) so a copied skill reads version-exact pages. The MCP tools are an optional
67
+ accelerator; every procedure also works with a file read.
68
+
69
+ The package does not register the skill into an agent (it has no `setup`). The installer copies it into the project
70
+ (see "Installing into your coding agent").
71
+ A package-skill gate still checks it as one (`scripts/package-skills-conformance.mjs`), and
72
+ `src/__tests__/host-builder-kit.test.ts` (`host_builder_kit_matches_surface`, in `release:gate`) keeps it from drifting:
73
+
74
+ 1. every fenced `ts` block is typechecked with the `examples/tsconfig.json` settings. A block that cannot be gets
75
+ `<!-- no-check: <reason> -->` on the line before it;
76
+ 2. every `node_modules/@arnilo/<package>/<path>` is in that package's packed file list;
77
+ 3. every `examples/<file>` is in `data/examples.json`;
78
+ 4. every `ERR_PRISM_*` token, and every code in the `Code` column of a table, is in `data/errors.json` and has a meaning;
79
+ 5. no retired name (`scripts/retired-tool-names.json`, or the left column of a table in `docs/migrate-to-0.13.md`) appears
80
+ outside the left column of a table in `references/upgrading.md`;
81
+ 6. no secret-shaped literal appears.
82
+
83
+ Editing the skill, a docs page or an example changes the indexes: run `bun scripts/host-builder-index.mjs`.
84
+
85
+ ## Installing into your coding agent
86
+
87
+ ```bash
88
+ bunx --package @arnilo/prism-hosts prism-host-builder install --target claude --mcp
89
+ bunx --package @arnilo/prism-hosts prism-host-builder install --target codex --mcp --dry-run # prints the TOML snippet; writes nothing
90
+ ```
91
+
92
+ `install --target <name> [--mcp] [--root <dir>] [--force] [--dry-run]` works on the project in `--root` (default: the
93
+ current directory) and nothing else.
94
+
95
+ | Target | Skill copied to | `--mcp` |
96
+ | --- | --- | --- |
97
+ | `claude` | `.claude/skills/prism-host-builder` | Merged into `.mcp.json` under `mcpServers`. |
98
+ | `cursor` | `.agents/skills/prism-host-builder` (Cursor also reads `.claude/skills`) | Merged into `.cursor/mcp.json` under `mcpServers`. |
99
+ | `codex` | `.agents/skills/prism-host-builder` | Prints the `[mcp_servers.prism]` table for `.codex/config.toml` and writes nothing: the package takes no TOML dependency. Codex loads project configuration only for a trusted project. |
100
+ | `agents` | `.agents/skills/prism-host-builder` (Codex, Cursor and Prism's `contextFiles` read it) | None. |
101
+ | `prism` | `.agents/skills/prism-host-builder` | Always prints the `contextFiles` and `@arnilo/prism-extensions/mcp` packages a Prism builder agent lists. |
102
+
103
+ The server entry is `prism: { command: "bunx", args: ["--package", "@arnilo/prism-hosts", "prism-host-builder", "mcp"] }`: no env, no token. A JSON config
104
+ is parsed, given that one key and written back with its own indent, line ending and trailing newline; every other key
105
+ keeps its value and order. A file that is not plain JSON (invalid, empty, or with comments) or whose `mcpServers` is not
106
+ an object is refused with `ERR_PRISM_HOST_BUILDER_INSTALL_CONFIG` and left as it was. Add start flags such as
107
+ `--entry` by hand afterwards.
108
+
109
+ - **Stamp.** The copy carries `.prism-host-builder.json` (package, version, content hash, file list). Installing the
110
+ same version again is a no-op, even over a locally edited copy. A different version replaces the copy and removes
111
+ files the new skill dropped only while the files still match the stamp's hash; otherwise the install fails with
112
+ `ERR_PRISM_HOST_BUILDER_INSTALL_CONFLICT`. So does a directory with no stamp, and a `prism` server entry that
113
+ differs. `--force` overwrites; it never deletes files the stamp does not list.
114
+ - **All or nothing.** Every conflict is found before the first write, so a refused install changes nothing.
115
+ `--dry-run` runs the same checks and prints the result.
116
+ - **One copy.** A `.claude/skills` symlink to `.agents/skills` resolves to one directory, so both targets share a copy.
117
+ When the two are distinct directories, the second install warns that Cursor reads both and will list the skill twice.
118
+ - **Boundaries.** Every destination is resolved through symlinks and must stay inside `--root`
119
+ (`ERR_PRISM_HOST_BUILDER_INSTALL_ROOT`); user-global directories (`~/.claude`, `~/.codex`) are never written because
120
+ the kit is version-exact per project. The installer runs no package manager and no network.
121
+
122
+ ## MCP server
123
+
124
+ `prism-host-builder mcp [--root <dir>] [--allow-version-mismatch] [--entry <file>#<export>] [--package <file>#<export>]
125
+ [--trust-project] [--check-timeout <seconds>] [--pass-env <NAME>]` serves over stdio through `servePrismMcpStdio`
126
+ (`@arnilo/prism-hosts/mcp-server`). It is local: no listener, no network, no model, no embeddings, and it never writes. The
127
+ four lookup tools read only files. The three check tools (see "Checking your host") run the host's own code, and only
128
+ when the server was started with a target for them. `--root` is the host project (default: the current directory).
129
+
130
+ | Tool | Input | Returns |
131
+ | --- | --- | --- |
132
+ | `prism_api` | `symbol?`, `query?`, `package?` | Signature, package, import specifier, docs pages and examples for an exact export name, or a ranked lexical search over names, signatures and summaries. |
133
+ | `prism_errors` | `code` | Meaning, owning package, declaring `file:line`, class, sample message, docs, and the fix `references/pitfalls.md` lists. |
134
+ | `prism_examples` | `query?`, `package?`, `path?` | Ranked examples, or the verbatim source of one indexed example. |
135
+ | `prism_docs` | `query` | Heading-anchored excerpts from the docs installed in the project, with a `prism-docs://` URI. Every query word must appear in a section. |
136
+
137
+ - **Resources.** `prism-docs://<package>/<path>` for each page installed under `<root>/node_modules/@arnilo/`: every
138
+ package's `README.md` and the kernel's current `docs/*.md` (not `docs/history/**` or the retired migration pages). A
139
+ page whose real path leaves `node_modules`, or the package it belongs to, is neither searched nor read.
140
+ - **Prompts.** `build-host` (goal), `add-capability` (capability) and `upgrade-host`. Each points at the skill, the
141
+ matching reference and the tools.
142
+ - **Version rule.** Every tool call compares the `@arnilo/prism` installed under `--root` with the version the
143
+ indexes describe. A mismatch, or no install, is a tool error `ERR_PRISM_HOST_BUILDER_VERSION` naming both versions
144
+ and the fix (`bun add -d @arnilo/prism-hosts@<installed>`). `--allow-version-mismatch` turns it into a
145
+ `warning` field on every result.
146
+ - **Bounds.** Every result and resource read is at most 64 KiB; a cut is marked `[truncated: N bytes omitted]`. An
147
+ unknown symbol, code or path is `found: false` with the nearest matches, never an exception.
148
+ - **Examples.** `path` resolves only to a path `examples.json` lists; anything else is not found.
149
+
150
+ ```json
151
+ { "mcpServers": { "prism-host-builder": { "command": "bunx", "args": ["--package", "@arnilo/prism-hosts", "prism-host-builder", "mcp"] } } }
152
+ ```
153
+
154
+ The lookups are plain functions in `src/lookup/` and `src/server.ts` only registers them.
155
+
156
+ ## Checking your host
157
+
158
+ Three more tools check code the user owns. **They execute it**, so they are not read-only, and they run only for targets
159
+ the user named when the server started. A tool argument can pick among those targets and can never add one.
160
+
161
+ | Start flag | Tool | Does |
162
+ | --- | --- | --- |
163
+ | `--entry <file>#<export>` (repeatable) | `prism_inspect_host({ entry })` | Runs the exported async function, which returns an `Agent`; returns `agent.inspect()` (packages, tools, skills with `requiresTools`, hooks, slot owners, status notes) and calls `dispose()`. |
164
+ | none (`--trust-project` optional) | `prism_check_manifest()` | What `prism verify` does: re-hashes every install and re-checks config. Project-scope packages are imported only with `--trust-project`. |
165
+ | `--package <file>#<export>` (repeatable) | `prism_check_package({ package })` | `packageConformance` from the project's installed `@arnilo/prism/testing` on a package definition or factory; one result per check. |
166
+
167
+ ```bash
168
+ bunx --package @arnilo/prism-hosts prism-host-builder mcp --entry src/agent.ts#createInspectionAgent --package src/my-package.ts#default
169
+ ```
170
+
171
+ **The factory convention.** An inspection factory builds the agent on the mock provider and runs nothing:
172
+
173
+ ```ts
174
+ // src/agent.ts
175
+ import { createAgent } from "@arnilo/prism";
176
+ import { mockProvider } from "@arnilo/prism/testing";
177
+
178
+ export async function createInspectionAgent() {
179
+ return createAgent({ model: "mock/demo", packages: [mockProvider(), ...hostPackages()] });
180
+ }
181
+ ```
182
+
183
+ The child sets `PRISM_HOST_BUILDER_CHECK=1`, so a factory can also branch on it. A factory that runs a session, or makes
184
+ an outbound `fetch`, fails with `ERR_PRISM_HOST_BUILDER_CHECK_MODEL_CALL` (the request is refused and its URL is
185
+ reported without the query).
186
+
187
+ - **Where a path may point.** Every target is `realpath`ed at start and must sit inside `--root`; a path outside it, or
188
+ a symlink that leaves it, refuses the start with `ERR_PRISM_HOST_BUILDER_ENTRY` (exit 1).
189
+ - **One child per call, with limits.** Each check is one `bun` child process in its own process group, with the project
190
+ root as working directory. `--check-timeout <seconds>` (default 30, at most 120) kills the group on expiry and the
191
+ result says `timedOut: true`. The group is also killed after a normal exit, so nothing the host code started outlives
192
+ the call. The result and each output stream are capped at 1 MiB (`truncated: true`), and the MCP layer bounds the
193
+ text it returns at 64 KiB.
194
+ - **Environment allowlist.** The child sees `PATH`, `HOME`, `TMPDIR` and `PRISM_HOME` when set, the names given with
195
+ `--pass-env NAME` (repeatable), and `PRISM_HOST_BUILDER_CHECK=1`. Provider keys are absent unless named, so an
196
+ `env:` ref resolves to nothing and the check fails closed on a missing credential. The values of `--pass-env`
197
+ variables are masked in every returned string with `redactSecrets`. Secret config fields already show their ref in
198
+ `inspect()`.
199
+ - **What it cannot stop.** The allowlist, timeout and caps bound the child; they do not sandbox it. Host code that
200
+ spawns a process or opens a socket still can, until the check ends. Point `--entry` at a factory you have read.
201
+ - **Cost.** A check builds the host's agent once per call, at whatever cost its `setup` has (an MCP client connection, a
202
+ database open). Nothing is cached between calls.
203
+ - **Result shape.** `{ ok, result | error, timedOut, truncated }`. `ok: true` means the check ran: a package that fails
204
+ conformance is `ok: true` with `result.ok: false` and each failing check listed. `error` is `{ code?, message }`.
205
+ - **No targets.** Without `--entry` or `--package` the tools still list; they return a `guidance` field naming the flag.
206
+ An unknown `entry` returns the configured names. The server never guesses.
207
+
208
+ ## What it changes
209
+
210
+ **No measured claim yet.** This package publishes a claim only when `compareExperiments` shows a significant
211
+ improvement at alpha .05, with multiple-comparison correction, on a pre-registered evaluation
212
+ (`scripts/host-builder-evals/`, 7 build tasks x 3 arms x 3 trials, graded by hidden tests and checks the builder never
213
+ sees). None passed, so the skill and the MCP server are not claimed to improve anything.
214
+
215
+ What the evidence does show, with `gemma4:31b` as the builder, is a direction and not a result:
216
+
217
+ | Run | `none` | `skill` | `skill+mcp` | Verdict |
218
+ | --- | --- | --- | --- | --- |
219
+ | Acceptance tests pass, kit-v1, natural loading | 0.19 | 0.57 | 0.52 | no claims |
220
+ | Acceptance tests pass, kit-v1, skill preloaded | 0.43 | 0.52 | 0.43 | no claims |
221
+ | Acceptance tests pass, kit-v2, natural loading | 0.24 | 0.67 | 0.62 | no claims (skill over `none` +0.43, q 0.125) |
222
+ | Acceptance tests pass, kit-v2, skill preloaded | 0.29 | 0.57 | 0.67 | inconclusive (2 of 63 runs lost to network errors) |
223
+
224
+ - The `skill` arm scored higher than `none` in every complete run, but 21 records per arm cannot separate that from noise at the
225
+ pre-registered bar. The MCP server added nothing over the skill alone (skill+mcp over skill: no significant
226
+ difference in any run).
227
+ - The kit-v1 to kit-v2 change came from diagnosing the first run: interfaces had no member lists in `data/api.json`,
228
+ the skill never mentioned that tools with durable effects need a `principal`, and the upgrade page called the retired
229
+ `identity` field valid. After the fix, the 0.12 upgrade task went from 0 of 3 to 3 of 3 with the skill.
230
+ - `beam` wrote no files in most runs and `gpt-oss:120b` lost many runs to server errors, so neither gave a usable
231
+ comparison. Only `gemma4:31b` was run on kit-v2.
232
+
233
+ Evidence: [`docs/_evidence/host-builder/212/`](../../../docs/_evidence/host-builder/212/) holds the kit-v2 runs
234
+ (`ollama-gemma4.md`, `ollama-gemma4.preload.md`), the earlier kit-v1 runs (`kit-v1/`) and the inconclusive attempt
235
+ (`attempts/`). The criteria, claim rules and registered input hashes are `scripts/host-builder-evals/criteria.json` and
236
+ `criteria.lock.json`.
237
+
238
+ ## Cost
239
+
240
+ No model calls and no network from the lookup tools. Everything they return is read from files inside this package. A
241
+ check tool costs one child process per call (see "Checking your host").
242
+
243
+ ## Security
244
+
245
+ - The indexes and the skill come from this package's own `data/` and `skills/`. The lookup tools also read markdown pages under `<root>/node_modules/@arnilo/` (real paths only, see above) and each package's `package.json` version, and nothing else from the project. The server writes nothing.
246
+ - The check tools execute project code: only the targets named at server start, each `realpath`ed inside `--root`, in a child with an allowlisted environment, a time limit and output caps (see "Checking your host"). Targets never come from a tool argument or from model output.
247
+ - The generator copies example sources into `data/`. It scans them for key-shaped literals and for values found in
248
+ the environment or `scripts/live.env`, and a hit fails generation. No `_evidence` content enters `data/`.
249
+ - `readExampleSource` rejects absolute paths, `..` segments and any path the examples index does not list.
250
+
251
+ Protocol dependencies are optional peers of `@arnilo/prism-hosts`. Install `@modelcontextprotocol/server@^2.3.0` and `zod@^4.6.2` for the MCP command. Protocol entrypoints require these peers; see the [bundle dependency table](../README.md).
@@ -0,0 +1,169 @@
1
+ #!/usr/bin/env bun
2
+ /**
3
+ * `prism-host-builder`: reference indexes for building a Prism host. `info` prints what the installed indexes
4
+ * describe, `install` copies the skill into a coding agent's project, `mcp` serves the lookup tools. Any other
5
+ * command exits 2.
6
+ */
7
+ import { resolve } from "node:path";
8
+ import { resolveCheckTargets } from "../src/check/targets.js";
9
+ import { HostBuilderError, loadHostBuilderIndex } from "../src/index.js";
10
+ import { describeInstall, installHostBuilder } from "../src/install/install.js";
11
+ import { INSTALL_TARGET_NAMES, isInstallTargetName } from "../src/install/targets.js";
12
+
13
+ export const USAGE = `Usage: prism-host-builder <command>
14
+
15
+ Commands:
16
+ info Print the Prism version and the size of each shipped index.
17
+ install Copy the skill into a coding agent's project directory, and optionally add the MCP server.
18
+ mcp Serve the lookup tools, docs resources and prompts over stdio (read-only).
19
+ help Print this message.
20
+
21
+ Options:
22
+ -h, --help Print this message.
23
+
24
+ install options:
25
+ --target <name> claude, codex, cursor, agents or prism (required).
26
+ --mcp Also add the MCP server to the target's project config (JSON), or print the snippet (Codex TOML).
27
+ --root <dir> The host project (default: the current directory). Nothing outside it is written.
28
+ --force Overwrite a locally edited skill copy or a different "prism" server entry.
29
+ --dry-run Print what would change and write nothing.
30
+
31
+ mcp options:
32
+ --root <dir> The host project (default: the current directory).
33
+ --allow-version-mismatch Warn instead of failing when the installed @arnilo/prism is not the version the indexes describe.
34
+ --entry <file>#<export> An async function returning an Agent, for prism_inspect_host. Repeatable. Runs the host's code.
35
+ --package <file>#<export> A package factory or definition, for prism_check_package. Repeatable. Runs the package's code.
36
+ --trust-project Let prism_check_manifest import project-scope packages, as prism verify --trust-project does.
37
+ --check-timeout <seconds> Per-check time limit (default 30, at most 120).
38
+ --pass-env <NAME> Let the check child see this variable. Repeatable. Only PATH, HOME, TMPDIR and PRISM_HOME pass by default.
39
+ `;
40
+
41
+ function usageError(message: string): number {
42
+ console.error(`prism-host-builder: ${message}\n`);
43
+ console.error(USAGE);
44
+ return 2;
45
+ }
46
+
47
+ function install(args: readonly string[]): number {
48
+ let root = process.cwd();
49
+ let target: string | undefined;
50
+ let mcp = false;
51
+ let force = false;
52
+ let dryRun = false;
53
+ for (let index = 0; index < args.length; index++) {
54
+ const arg = args[index] as string;
55
+ if (arg === "--mcp") mcp = true;
56
+ else if (arg === "--force") force = true;
57
+ else if (arg === "--dry-run") dryRun = true;
58
+ else if (arg === "--target" || arg === "--root") {
59
+ const value = args[++index];
60
+ if (value === undefined || value.startsWith("--")) return usageError(`${arg} needs a value`);
61
+ if (arg === "--root") root = resolve(value);
62
+ else target = value;
63
+ } else return usageError(`unknown install option "${arg}"`);
64
+ }
65
+ if (target === undefined) return usageError(`install needs --target (${INSTALL_TARGET_NAMES.join(", ")})`);
66
+ if (!isInstallTargetName(target)) return usageError(`unknown install target "${target}" (${INSTALL_TARGET_NAMES.join(", ")})`);
67
+ try {
68
+ for (const line of describeInstall(installHostBuilder({ target, root, mcp, force, dryRun }))) console.log(line);
69
+ return 0;
70
+ } catch (error) {
71
+ if (!(error instanceof HostBuilderError)) throw error;
72
+ console.error(`prism-host-builder: ${error.code}: ${error.message}`);
73
+ return 1;
74
+ }
75
+ }
76
+
77
+ async function mcp(args: readonly string[]): Promise<number> {
78
+ let root = process.cwd();
79
+ let allowVersionMismatch = false;
80
+ let trustProject = false;
81
+ let checkTimeoutSeconds: number | undefined;
82
+ const entries: string[] = [];
83
+ const packages: string[] = [];
84
+ const passEnv: string[] = [];
85
+ for (let index = 0; index < args.length; index++) {
86
+ const arg = args[index] as string;
87
+ if (arg === "--allow-version-mismatch") allowVersionMismatch = true;
88
+ else if (arg === "--trust-project") trustProject = true;
89
+ else if (arg === "--root" || arg === "--entry" || arg === "--package" || arg === "--check-timeout" || arg === "--pass-env") {
90
+ const value = args[++index];
91
+ if (value === undefined || value.startsWith("--")) return usageError(`${arg} needs a value`);
92
+ if (arg === "--root") root = resolve(value);
93
+ else if (arg === "--entry") entries.push(value);
94
+ else if (arg === "--package") packages.push(value);
95
+ else if (arg === "--pass-env") {
96
+ if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(value)) return usageError(`--pass-env needs a variable name, got "${value}"`);
97
+ passEnv.push(value);
98
+ } else {
99
+ const seconds = Number(value);
100
+ if (!Number.isFinite(seconds) || seconds <= 0 || seconds > 120)
101
+ return usageError("--check-timeout needs a number of seconds from 1 to 120");
102
+ checkTimeoutSeconds = seconds;
103
+ }
104
+ } else return usageError(`unknown mcp option "${arg}"`);
105
+ }
106
+ // Refuse a bad check target now, not on the first tool call.
107
+ try {
108
+ resolveCheckTargets(root, entries, packages);
109
+ } catch (error) {
110
+ if (!(error instanceof HostBuilderError)) throw error;
111
+ console.error(`prism-host-builder: ${error.code}: ${error.message}`);
112
+ return 1;
113
+ }
114
+ // Loaded here so `info` and `--help` do not pay for the MCP SDK.
115
+ const [{ servePrismMcpStdio }, { createHostBuilderMcpServer }] = await Promise.all([
116
+ import("@arnilo/prism-hosts/mcp-server"),
117
+ import("../src/server.js"),
118
+ ]);
119
+ const handle = servePrismMcpStdio(() =>
120
+ createHostBuilderMcpServer({
121
+ root,
122
+ allowVersionMismatch,
123
+ entries,
124
+ packages,
125
+ trustProject,
126
+ passEnv,
127
+ ...(checkTimeoutSeconds === undefined ? {} : { checkTimeoutSeconds }),
128
+ }),
129
+ );
130
+ const stop = () => void handle.close().finally(() => process.exit(0));
131
+ process.once("SIGINT", stop);
132
+ process.once("SIGTERM", stop);
133
+ process.stdin.once("end", stop);
134
+ // The stdio transport keeps the process alive until the client closes the pipe.
135
+ return await new Promise<number>(() => {});
136
+ }
137
+
138
+ export async function main(argv: readonly string[]): Promise<number> {
139
+ const command = argv[0];
140
+ if (command === "--help" || command === "-h" || command === "help") {
141
+ console.log(USAGE);
142
+ return 0;
143
+ }
144
+ if (command === "info") {
145
+ try {
146
+ const [api, errors, examples] = await Promise.all([
147
+ loadHostBuilderIndex("api"),
148
+ loadHostBuilderIndex("errors"),
149
+ loadHostBuilderIndex("examples"),
150
+ ]);
151
+ const names = api.packages.reduce((total, pkg) => total + pkg.entries.reduce((sum, entry) => sum + entry.exports.length, 0), 0);
152
+ console.log(
153
+ `prism ${api.prismVersion}: ${api.packages.length} packages, ${names} exports, ${errors.codes.length} error codes, ${examples.examples.length} examples`,
154
+ );
155
+ return 0;
156
+ } catch (error) {
157
+ if (!(error instanceof HostBuilderError)) throw error;
158
+ console.error(`prism-host-builder: ${error.code}: ${error.message}`);
159
+ return 1;
160
+ }
161
+ }
162
+ if (command === "install") return install(argv.slice(1));
163
+ if (command === "mcp") return await mcp(argv.slice(1));
164
+ console.error(command === undefined ? "prism-host-builder: missing command\n" : `prism-host-builder: unknown command "${command}"\n`);
165
+ console.error(USAGE);
166
+ return 2;
167
+ }
168
+
169
+ if (import.meta.main) process.exitCode = await main(process.argv.slice(2));