@stravica-ai/digital-operator-pa 0.1.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 (372) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +170 -0
  3. package/bin/desk +9 -0
  4. package/bin/distill +2 -0
  5. package/bin/estate-sync +2 -0
  6. package/bin/launch +2 -0
  7. package/bin/memory-sync +2 -0
  8. package/bin/migrate-inspect +2 -0
  9. package/bin/pa +2 -0
  10. package/bin/pa-coordinator-hook +2 -0
  11. package/bin/pa-init +2 -0
  12. package/bin/research +2 -0
  13. package/bin/scheduler +2 -0
  14. package/bin/secrets +2 -0
  15. package/bin/slice +2 -0
  16. package/bin/smoke +9 -0
  17. package/bin/sync +2 -0
  18. package/dist/engineering-pa-cli/README.md +205 -0
  19. package/dist/engineering-pa-cli/bin/estate-sync +2 -0
  20. package/dist/engineering-pa-cli/bin/launch +2 -0
  21. package/dist/engineering-pa-cli/bin/pa +2 -0
  22. package/dist/engineering-pa-cli/bin/pa-coordinator-hook +12 -0
  23. package/dist/engineering-pa-cli/bin/research +2 -0
  24. package/dist/engineering-pa-cli/bin/scheduler +2 -0
  25. package/dist/engineering-pa-cli/bin/secrets +2 -0
  26. package/dist/engineering-pa-cli/bin/smoke +9 -0
  27. package/dist/engineering-pa-cli/bin/sync +2 -0
  28. package/dist/engineering-pa-cli/config/coordinator-allowlist.json +118 -0
  29. package/dist/engineering-pa-cli/docs/coordinator-hook.md +211 -0
  30. package/dist/engineering-pa-cli/docs/estate-sync.md +412 -0
  31. package/dist/engineering-pa-cli/docs/gsc.md +175 -0
  32. package/dist/engineering-pa-cli/docs/lint-linkedin.md +139 -0
  33. package/dist/engineering-pa-cli/docs/secrets.md +221 -0
  34. package/dist/engineering-pa-cli/docs/smoke.md +113 -0
  35. package/dist/engineering-pa-cli/docs/staging-alias.md +114 -0
  36. package/dist/engineering-pa-cli/index.mjs +17 -0
  37. package/dist/engineering-pa-cli/package.json +37 -0
  38. package/dist/engineering-pa-cli/src/autonomy/cli.mjs +329 -0
  39. package/dist/engineering-pa-cli/src/autonomy/envelope.mjs +301 -0
  40. package/dist/engineering-pa-cli/src/coordinator-hook/cli.mjs +140 -0
  41. package/dist/engineering-pa-cli/src/coordinator-hook/config.mjs +134 -0
  42. package/dist/engineering-pa-cli/src/coordinator-hook/message.mjs +47 -0
  43. package/dist/engineering-pa-cli/src/coordinator-hook/policy.mjs +211 -0
  44. package/dist/engineering-pa-cli/src/coordinator-hook/repo-root.mjs +44 -0
  45. package/dist/engineering-pa-cli/src/coordinator-hook/self.mjs +30 -0
  46. package/dist/engineering-pa-cli/src/environment/cli.mjs +287 -0
  47. package/dist/engineering-pa-cli/src/environment/probes.mjs +302 -0
  48. package/dist/engineering-pa-cli/src/gsc/auth.mjs +148 -0
  49. package/dist/engineering-pa-cli/src/gsc/cli.mjs +93 -0
  50. package/dist/engineering-pa-cli/src/gsc/cloudflare.mjs +318 -0
  51. package/dist/engineering-pa-cli/src/gsc/commands/add-property.mjs +70 -0
  52. package/dist/engineering-pa-cli/src/gsc/commands/list-properties.mjs +33 -0
  53. package/dist/engineering-pa-cli/src/gsc/commands/pull-analytics.mjs +130 -0
  54. package/dist/engineering-pa-cli/src/gsc/commands/submit-sitemap.mjs +41 -0
  55. package/dist/engineering-pa-cli/src/gsc/commands/verify-via-cf-dns.mjs +189 -0
  56. package/dist/engineering-pa-cli/src/knowledge/call-log.mjs +59 -0
  57. package/dist/engineering-pa-cli/src/knowledge/cli.mjs +242 -0
  58. package/dist/engineering-pa-cli/src/knowledge/eval.mjs +446 -0
  59. package/dist/engineering-pa-cli/src/knowledge/formatters.mjs +331 -0
  60. package/dist/engineering-pa-cli/src/knowledge/graph.mjs +710 -0
  61. package/dist/engineering-pa-cli/src/launch/README.md +214 -0
  62. package/dist/engineering-pa-cli/src/launch/cli.mjs +51 -0
  63. package/dist/engineering-pa-cli/src/launch/commands/launch.mjs +106 -0
  64. package/dist/engineering-pa-cli/src/launch/identity.mjs +43 -0
  65. package/dist/engineering-pa-cli/src/launch/planner.mjs +44 -0
  66. package/dist/engineering-pa-cli/src/launch/repo-root.mjs +53 -0
  67. package/dist/engineering-pa-cli/src/launch/runner.mjs +147 -0
  68. package/dist/engineering-pa-cli/src/launch/task-loader.mjs +85 -0
  69. package/dist/engineering-pa-cli/src/lint/cli.mjs +61 -0
  70. package/dist/engineering-pa-cli/src/lint/commands/linkedin.mjs +133 -0
  71. package/dist/engineering-pa-cli/src/lint/detectors.mjs +90 -0
  72. package/dist/engineering-pa-cli/src/lint/linter.mjs +69 -0
  73. package/dist/engineering-pa-cli/src/lint/reporter.mjs +32 -0
  74. package/dist/engineering-pa-cli/src/lint/rules.mjs +132 -0
  75. package/dist/engineering-pa-cli/src/pa/cli.mjs +369 -0
  76. package/dist/engineering-pa-cli/src/pa/doc-groups.mjs +164 -0
  77. package/dist/engineering-pa-cli/src/pa/io.mjs +80 -0
  78. package/dist/engineering-pa-cli/src/pa/project-cli.mjs +385 -0
  79. package/dist/engineering-pa-cli/src/pa/projects.mjs +352 -0
  80. package/dist/engineering-pa-cli/src/pa/repo-root.mjs +64 -0
  81. package/dist/engineering-pa-cli/src/pa/session.mjs +254 -0
  82. package/dist/engineering-pa-cli/src/pa/work-cli.mjs +164 -0
  83. package/dist/engineering-pa-cli/src/pa/work.mjs +196 -0
  84. package/dist/engineering-pa-cli/src/pa/workstreams.mjs +201 -0
  85. package/dist/engineering-pa-cli/src/research/README.md +360 -0
  86. package/dist/engineering-pa-cli/src/research/briefs/extractor.md +103 -0
  87. package/dist/engineering-pa-cli/src/research/briefs/searcher.md +113 -0
  88. package/dist/engineering-pa-cli/src/research/briefs/synthesizer.md +124 -0
  89. package/dist/engineering-pa-cli/src/research/briefs/verifier.md +86 -0
  90. package/dist/engineering-pa-cli/src/research/cli.mjs +141 -0
  91. package/dist/engineering-pa-cli/src/research/commands/gates.mjs +176 -0
  92. package/dist/engineering-pa-cli/src/research/commands/list.mjs +56 -0
  93. package/dist/engineering-pa-cli/src/research/commands/mark.mjs +97 -0
  94. package/dist/engineering-pa-cli/src/research/commands/paths.mjs +69 -0
  95. package/dist/engineering-pa-cli/src/research/commands/prune.mjs +86 -0
  96. package/dist/engineering-pa-cli/src/research/commands/run.mjs +94 -0
  97. package/dist/engineering-pa-cli/src/research/commands/show.mjs +43 -0
  98. package/dist/engineering-pa-cli/src/research/docs/operator-present-flow.md +120 -0
  99. package/dist/engineering-pa-cli/src/research/format.mjs +59 -0
  100. package/dist/engineering-pa-cli/src/research/promote.mjs +260 -0
  101. package/dist/engineering-pa-cli/src/research/schema/finding.schema.json +55 -0
  102. package/dist/engineering-pa-cli/src/research/schema/gates.schema.json +34 -0
  103. package/dist/engineering-pa-cli/src/research/schema/manifest.schema.json +59 -0
  104. package/dist/engineering-pa-cli/src/research/schema/plan.schema.json +41 -0
  105. package/dist/engineering-pa-cli/src/research/schema/sources.schema.json +31 -0
  106. package/dist/engineering-pa-cli/src/research/store/findings.mjs +61 -0
  107. package/dist/engineering-pa-cli/src/research/store/gates.mjs +73 -0
  108. package/dist/engineering-pa-cli/src/research/store/index.mjs +312 -0
  109. package/dist/engineering-pa-cli/src/research/store/manifest.mjs +56 -0
  110. package/dist/engineering-pa-cli/src/research/store/plan.mjs +59 -0
  111. package/dist/engineering-pa-cli/src/research/store/sources.mjs +44 -0
  112. package/dist/engineering-pa-cli/src/research/store/validate.mjs +92 -0
  113. package/dist/engineering-pa-cli/src/research/workflows/research-normal.js +573 -0
  114. package/dist/engineering-pa-cli/src/scheduler/cli.mjs +197 -0
  115. package/dist/engineering-pa-cli/src/secrets/cli.mjs +254 -0
  116. package/dist/engineering-pa-cli/src/secrets/commands/backup-template.mjs +67 -0
  117. package/dist/engineering-pa-cli/src/secrets/commands/backup.mjs +85 -0
  118. package/dist/engineering-pa-cli/src/secrets/commands/delete.mjs +58 -0
  119. package/dist/engineering-pa-cli/src/secrets/commands/find.mjs +36 -0
  120. package/dist/engineering-pa-cli/src/secrets/commands/get.mjs +49 -0
  121. package/dist/engineering-pa-cli/src/secrets/commands/init.mjs +69 -0
  122. package/dist/engineering-pa-cli/src/secrets/commands/list.mjs +37 -0
  123. package/dist/engineering-pa-cli/src/secrets/commands/rotate.mjs +46 -0
  124. package/dist/engineering-pa-cli/src/secrets/commands/set.mjs +123 -0
  125. package/dist/engineering-pa-cli/src/secrets/commands/status.mjs +146 -0
  126. package/dist/engineering-pa-cli/src/secrets/commands/vaults.mjs +57 -0
  127. package/dist/engineering-pa-cli/src/secrets/commands/verify.mjs +143 -0
  128. package/dist/engineering-pa-cli/src/secrets/vault.mjs +766 -0
  129. package/dist/engineering-pa-cli/src/smoke/checks.mjs +199 -0
  130. package/dist/engineering-pa-cli/src/smoke/cli.mjs +108 -0
  131. package/dist/engineering-pa-cli/src/smoke/commands/run.mjs +237 -0
  132. package/dist/engineering-pa-cli/src/smoke/runner.mjs +191 -0
  133. package/dist/engineering-pa-cli/src/staging-alias/cli.mjs +91 -0
  134. package/dist/engineering-pa-cli/src/staging-alias/cloudflare.mjs +380 -0
  135. package/dist/engineering-pa-cli/src/staging-alias/commands/list.mjs +36 -0
  136. package/dist/engineering-pa-cli/src/staging-alias/commands/set.mjs +188 -0
  137. package/dist/engineering-pa-cli/src/staging-alias/commands/status.mjs +113 -0
  138. package/dist/engineering-pa-cli/src/staging-alias/commands/unset.mjs +95 -0
  139. package/dist/engineering-pa-cli/src/staging-alias/sites.mjs +105 -0
  140. package/dist/engineering-pa-cli/src/sync/cli.mjs +151 -0
  141. package/dist/engineering-pa-cli/src/sync/git.mjs +149 -0
  142. package/dist/engineering-pa-cli/src/sync/lock.mjs +30 -0
  143. package/dist/engineering-pa-cli/src/sync/regenerated-artifacts.mjs +114 -0
  144. package/dist/engineering-pa-cli/src/sync/registry-scope.mjs +260 -0
  145. package/dist/engineering-pa-cli/src/sync/run.mjs +531 -0
  146. package/dist/engineering-pa-cli/src/sync/runner.mjs +62 -0
  147. package/dist/engineering-pa-cli/src/sync/runs-digest.mjs +138 -0
  148. package/dist/engineering-pa-core/README.md +60 -0
  149. package/dist/engineering-pa-core/bin/desk +9 -0
  150. package/dist/engineering-pa-core/bin/distill +2 -0
  151. package/dist/engineering-pa-core/bin/memory-sync +2 -0
  152. package/dist/engineering-pa-core/bin/slice +2 -0
  153. package/dist/engineering-pa-core/docs/autonomy-envelope-tracker.md +111 -0
  154. package/dist/engineering-pa-core/docs/blueprints/README.md +45 -0
  155. package/dist/engineering-pa-core/docs/blueprints/docker-services/blueprint.md +168 -0
  156. package/dist/engineering-pa-core/docs/blueprints/git-identity/blueprint.md +116 -0
  157. package/dist/engineering-pa-core/docs/blueprints/ideas/custom-workspace-views.md +9 -0
  158. package/dist/engineering-pa-core/docs/blueprints/ideas/knowledge-domain-patterns.md +15 -0
  159. package/dist/engineering-pa-core/docs/blueprints/ideas/office-integration.md +11 -0
  160. package/dist/engineering-pa-core/docs/blueprints/ideas/team-scaling.md +9 -0
  161. package/dist/engineering-pa-core/docs/blueprints/ideas/work-personal-separation.md +9 -0
  162. package/dist/engineering-pa-core/docs/blueprints/scheduled-distillation/blueprint.md +129 -0
  163. package/dist/engineering-pa-core/docs/blueprints/tool-integration/blueprint.md +110 -0
  164. package/dist/engineering-pa-core/docs/commands/init.md +159 -0
  165. package/dist/engineering-pa-core/docs/commands/schedule.md +98 -0
  166. package/dist/engineering-pa-core/docs/commands/upgrade.md +67 -0
  167. package/dist/engineering-pa-core/docs/entity-location-map.md +93 -0
  168. package/dist/engineering-pa-core/docs/knowledge-scaffold.md +121 -0
  169. package/dist/engineering-pa-core/docs/lock.md +155 -0
  170. package/dist/engineering-pa-core/docs/memory-sync.md +28 -0
  171. package/dist/engineering-pa-core/docs/pa-operating-model.md +457 -0
  172. package/dist/engineering-pa-core/docs/scheduling.md +35 -0
  173. package/dist/engineering-pa-core/docs/standards/README.md +24 -0
  174. package/dist/engineering-pa-core/docs/standards/briefing-contract.md +161 -0
  175. package/dist/engineering-pa-core/docs/standards/tooling.md +240 -0
  176. package/dist/engineering-pa-core/docs/tools/distill.md +230 -0
  177. package/dist/engineering-pa-core/docs/tools/memory-sync.md +98 -0
  178. package/dist/engineering-pa-core/docs/tools/scheduler.md +243 -0
  179. package/dist/engineering-pa-core/docs/tools/slice.md +150 -0
  180. package/dist/engineering-pa-core/docs/upstream-issue-filing.md +88 -0
  181. package/dist/engineering-pa-core/docs/working-directory.md +29 -0
  182. package/dist/engineering-pa-core/docs/workspace-operations.md +46 -0
  183. package/dist/engineering-pa-core/index.mjs +21 -0
  184. package/dist/engineering-pa-core/knowledge/README.md +53 -0
  185. package/dist/engineering-pa-core/knowledge/canonical/.gitkeep +0 -0
  186. package/dist/engineering-pa-core/knowledge/content-voice/README.md +64 -0
  187. package/dist/engineering-pa-core/knowledge/content-voice/banned-ai-tells-baseline.md +133 -0
  188. package/dist/engineering-pa-core/knowledge/content-voice/banned-ai-tells-shape.md +58 -0
  189. package/dist/engineering-pa-core/knowledge/content-voice/banned-ai-tells-taxonomy.md +33 -0
  190. package/dist/engineering-pa-core/knowledge/content-voice/content-pipeline-routing.md +58 -0
  191. package/dist/engineering-pa-core/knowledge/content-voice/new-tell-capture-procedure.md +40 -0
  192. package/dist/engineering-pa-core/knowledge/content-voice/voice-guide-shape.md +43 -0
  193. package/dist/engineering-pa-core/knowledge/delegation-dispatch/README.md +34 -0
  194. package/dist/engineering-pa-core/knowledge/delegation-dispatch/briefing-contract.md +77 -0
  195. package/dist/engineering-pa-core/knowledge/delegation-dispatch/delegation-modes.md +84 -0
  196. package/dist/engineering-pa-core/knowledge/delegation-dispatch/dispatch-envelope.md +238 -0
  197. package/dist/engineering-pa-core/knowledge/delegation-dispatch/task-groups-and-orchestrators.md +62 -0
  198. package/dist/engineering-pa-core/knowledge/delegation-dispatch/team-improvement-loop.md +48 -0
  199. package/dist/engineering-pa-core/knowledge/delegation-dispatch/tool-development-policy.md +48 -0
  200. package/dist/engineering-pa-core/knowledge/engineering-discipline/README.md +33 -0
  201. package/dist/engineering-pa-core/knowledge/engineering-discipline/blast-radius-and-safety.md +50 -0
  202. package/dist/engineering-pa-core/knowledge/engineering-discipline/investigate-root-causes.md +48 -0
  203. package/dist/engineering-pa-core/knowledge/engineering-discipline/role-ladder.md +57 -0
  204. package/dist/engineering-pa-core/knowledge/engineering-discipline/verify-runtime-behaviour.md +53 -0
  205. package/dist/engineering-pa-core/knowledge/engineering-discipline/worktree-isolation.md +50 -0
  206. package/dist/engineering-pa-core/knowledge/knowledge-memory/README.md +33 -0
  207. package/dist/engineering-pa-core/knowledge/knowledge-memory/claude-md-hygiene.md +47 -0
  208. package/dist/engineering-pa-core/knowledge/knowledge-memory/journal-and-self-improvement.md +53 -0
  209. package/dist/engineering-pa-core/knowledge/knowledge-memory/knowledge-retrieval-discipline.md +62 -0
  210. package/dist/engineering-pa-core/knowledge/knowledge-memory/librarian-synthesis-mandate.md +56 -0
  211. package/dist/engineering-pa-core/knowledge/knowledge-memory/staging-and-observations.md +58 -0
  212. package/dist/engineering-pa-core/knowledge/operator-interface/README.md +32 -0
  213. package/dist/engineering-pa-core/knowledge/operator-interface/communication-style.md +33 -0
  214. package/dist/engineering-pa-core/knowledge/operator-interface/escalation-and-correction.md +45 -0
  215. package/dist/engineering-pa-core/knowledge/operator-interface/push-back-discipline.md +42 -0
  216. package/dist/engineering-pa-core/knowledge/operator-interface/session-boot-and-end.md +56 -0
  217. package/dist/engineering-pa-core/knowledge/platform-tooling/README.md +37 -0
  218. package/dist/engineering-pa-core/knowledge/platform-tooling/desk-cli-reference.md +52 -0
  219. package/dist/engineering-pa-core/knowledge/platform-tooling/environment-awareness.md +91 -0
  220. package/dist/engineering-pa-core/knowledge/platform-tooling/mcp-servers-catalogue.md +52 -0
  221. package/dist/engineering-pa-core/knowledge/platform-tooling/pa-cli-reference.md +55 -0
  222. package/dist/engineering-pa-core/knowledge/platform-tooling/scheduling-and-launchd.md +56 -0
  223. package/dist/engineering-pa-core/knowledge/platform-tooling/tool-discovery-discipline.md +49 -0
  224. package/dist/engineering-pa-core/knowledge/platform-tooling/working-directory-vs-project-root.md +43 -0
  225. package/dist/engineering-pa-core/knowledge/platform-tooling/workspace-server.md +51 -0
  226. package/dist/engineering-pa-core/knowledge/raw/.gitkeep +0 -0
  227. package/dist/engineering-pa-core/knowledge/scaffold/domains.json +5 -0
  228. package/dist/engineering-pa-core/knowledge/schema/.gitkeep +0 -0
  229. package/dist/engineering-pa-core/knowledge/work-management/README.md +33 -0
  230. package/dist/engineering-pa-core/knowledge/work-management/desk-cli.md +84 -0
  231. package/dist/engineering-pa-core/knowledge/work-management/progress-md.md +48 -0
  232. package/dist/engineering-pa-core/knowledge/work-management/projects.md +64 -0
  233. package/dist/engineering-pa-core/knowledge/work-management/spawn-log.md +48 -0
  234. package/dist/engineering-pa-core/knowledge/work-management/work-items.md +67 -0
  235. package/dist/engineering-pa-core/package.json +26 -0
  236. package/dist/engineering-pa-core/roles/agent-ops/definition.md +79 -0
  237. package/dist/engineering-pa-core/roles/dispatch-briefer/definition.md +195 -0
  238. package/dist/engineering-pa-core/roles/librarian/definition.md +176 -0
  239. package/dist/engineering-pa-core/roles/pa/definition.md +93 -0
  240. package/dist/engineering-pa-core/roles/system-admin/definition.md +106 -0
  241. package/dist/engineering-pa-core/roles/tool-developer/definition.md +116 -0
  242. package/dist/engineering-pa-core/roles/writer/definition.md +130 -0
  243. package/dist/engineering-pa-core/schema/autonomy-envelope.schema.json +61 -0
  244. package/dist/engineering-pa-core/schema/project.json +114 -0
  245. package/dist/engineering-pa-core/schema/schedule.json +63 -0
  246. package/dist/engineering-pa-core/schema/work-item.json +92 -0
  247. package/dist/engineering-pa-core/src/config/pa-package-name.mjs +30 -0
  248. package/dist/engineering-pa-core/src/desk/cli.mjs +95 -0
  249. package/dist/engineering-pa-core/src/desk/commands.mjs +398 -0
  250. package/dist/engineering-pa-core/src/desk/format.mjs +84 -0
  251. package/dist/engineering-pa-core/src/desk/repo.mjs +172 -0
  252. package/dist/engineering-pa-core/src/desk/team-scope.mjs +142 -0
  253. package/dist/engineering-pa-core/src/distill/cli.mjs +112 -0
  254. package/dist/engineering-pa-core/src/distill/prereqs.mjs +171 -0
  255. package/dist/engineering-pa-core/src/distill/prompt.mjs +74 -0
  256. package/dist/engineering-pa-core/src/distill/run.mjs +230 -0
  257. package/dist/engineering-pa-core/src/distill/runner.mjs +86 -0
  258. package/dist/engineering-pa-core/src/distill/staging.mjs +59 -0
  259. package/dist/engineering-pa-core/src/knowledge/retrieval/backlink-indexer.mjs +154 -0
  260. package/dist/engineering-pa-core/src/knowledge/retrieval/graph-builder.mjs +186 -0
  261. package/dist/engineering-pa-core/src/knowledge/retrieval/index-builder.mjs +225 -0
  262. package/dist/engineering-pa-core/src/knowledge/retrieval/query.mjs +263 -0
  263. package/dist/engineering-pa-core/src/lock/lock.mjs +202 -0
  264. package/dist/engineering-pa-core/src/memory-sync/cli-support.mjs +12 -0
  265. package/dist/engineering-pa-core/src/memory-sync/cli.mjs +56 -0
  266. package/dist/engineering-pa-core/src/memory-sync/commands/pull.mjs +44 -0
  267. package/dist/engineering-pa-core/src/memory-sync/commands/push.mjs +46 -0
  268. package/dist/engineering-pa-core/src/memory-sync/mirror.mjs +114 -0
  269. package/dist/engineering-pa-core/src/memory-sync/repo.mjs +65 -0
  270. package/dist/engineering-pa-core/src/scheduler/detect.mjs +111 -0
  271. package/dist/engineering-pa-core/src/scheduler/host.mjs +38 -0
  272. package/dist/engineering-pa-core/src/scheduler/index.mjs +13 -0
  273. package/dist/engineering-pa-core/src/scheduler/install.mjs +854 -0
  274. package/dist/engineering-pa-core/src/scheduler/list.mjs +168 -0
  275. package/dist/engineering-pa-core/src/scheduler/remove.mjs +176 -0
  276. package/dist/engineering-pa-core/src/scheduler/verify.mjs +435 -0
  277. package/dist/engineering-pa-core/src/session-boot/autonomy-injection.mjs +84 -0
  278. package/dist/engineering-pa-core/src/slice/cli.mjs +139 -0
  279. package/dist/engineering-pa-core/src/slice/inputs.mjs +174 -0
  280. package/dist/engineering-pa-core/src/slice/prompt.mjs +94 -0
  281. package/dist/engineering-pa-core/src/slice/prompts/dave-boot.md +91 -0
  282. package/dist/engineering-pa-core/src/slice/run.mjs +334 -0
  283. package/dist/engineering-pa-core-extensions-atlassian/README.md +31 -0
  284. package/dist/engineering-pa-core-extensions-atlassian/index.mjs +9 -0
  285. package/dist/engineering-pa-core-extensions-atlassian/package.json +19 -0
  286. package/dist/engineering-pa-core-extensions-n8n/README.md +29 -0
  287. package/dist/engineering-pa-core-extensions-n8n/index.mjs +8 -0
  288. package/dist/engineering-pa-core-extensions-n8n/package.json +19 -0
  289. package/dist/engineering-pa-librarian/README.md +38 -0
  290. package/dist/engineering-pa-librarian/index.mjs +12 -0
  291. package/dist/engineering-pa-librarian/package.json +19 -0
  292. package/dist/engineering-pa-migrate-inspect/README.md +131 -0
  293. package/dist/engineering-pa-migrate-inspect/bin/migrate-inspect +2 -0
  294. package/dist/engineering-pa-migrate-inspect/package.json +21 -0
  295. package/dist/engineering-pa-migrate-inspect/src/age-key-migrate.mjs +83 -0
  296. package/dist/engineering-pa-migrate-inspect/src/cli.mjs +97 -0
  297. package/dist/engineering-pa-migrate-inspect/src/inspector.mjs +237 -0
  298. package/dist/engineering-pa-migrate-inspect/src/platforms/linux.mjs +87 -0
  299. package/dist/engineering-pa-migrate-inspect/src/platforms/macos.mjs +105 -0
  300. package/dist/engineering-pa-migrate-inspect/src/runner.mjs +87 -0
  301. package/dist/engineering-pa-runbook/README.md +103 -0
  302. package/dist/engineering-pa-runbook/package.json +18 -0
  303. package/dist/engineering-pa-runbook/reference/dex-template.runbook.json +66 -0
  304. package/dist/engineering-pa-runbook/reference/hq-dave.runbook.json +69 -0
  305. package/dist/engineering-pa-runbook/reference/smarthome01.runbook.json +92 -0
  306. package/dist/engineering-pa-runbook/schema/inspection.schema.json +113 -0
  307. package/dist/engineering-pa-runbook/schema/runbook.schema.json +67 -0
  308. package/dist/engineering-pa-runbook/src/validator.mjs +167 -0
  309. package/dist/engineering-pa-scaffold/README.md +164 -0
  310. package/dist/engineering-pa-scaffold/bin/pa-init +2 -0
  311. package/dist/engineering-pa-scaffold/index.mjs +42 -0
  312. package/dist/engineering-pa-scaffold/package.json +22 -0
  313. package/dist/engineering-pa-scaffold/src/cli.mjs +115 -0
  314. package/dist/engineering-pa-scaffold/src/commands/init.mjs +169 -0
  315. package/dist/engineering-pa-scaffold/src/generator.mjs +354 -0
  316. package/dist/engineering-pa-scaffold/src/prompts.mjs +125 -0
  317. package/dist/engineering-pa-scaffold/src/runner.mjs +142 -0
  318. package/dist/engineering-pa-scaffold/templates/CLAUDE.md.template +196 -0
  319. package/dist/engineering-pa-scaffold/templates/operator-README.md.template +44 -0
  320. package/dist/engineering-pa-types-engineering/README.md +35 -0
  321. package/dist/engineering-pa-types-engineering/docs/commands/product-build.md +120 -0
  322. package/dist/engineering-pa-types-engineering/index.mjs +9 -0
  323. package/dist/engineering-pa-types-engineering/package.json +19 -0
  324. package/dist/engineering-pa-types-engineering/roles/product-engineer/definition.md +650 -0
  325. package/dist/engineering-pa-types-engineering/roles/product-engineer/templates/build-spec.md +82 -0
  326. package/dist/engineering-pa-types-engineering/roles/product-engineer/templates/preflight-checklist.md +158 -0
  327. package/dist/engineering-pa-types-engineering/roles/product-engineer/templates/worker-brief.md +130 -0
  328. package/dist/engineering-pa-workspace/README.md +197 -0
  329. package/dist/engineering-pa-workspace/app/assets/md.js +187 -0
  330. package/dist/engineering-pa-workspace/app/assets/modal.js +120 -0
  331. package/dist/engineering-pa-workspace/app/assets/theme.css +132 -0
  332. package/dist/engineering-pa-workspace/app/assets/theme.js +159 -0
  333. package/dist/engineering-pa-workspace/app/banner.js +320 -0
  334. package/dist/engineering-pa-workspace/app/delegations.html +345 -0
  335. package/dist/engineering-pa-workspace/app/home.html +1060 -0
  336. package/dist/engineering-pa-workspace/app/index.html +361 -0
  337. package/dist/engineering-pa-workspace/app/knowledge-map.html +163 -0
  338. package/dist/engineering-pa-workspace/app/knowledge.html +304 -0
  339. package/dist/engineering-pa-workspace/app/nav.json +75 -0
  340. package/dist/engineering-pa-workspace/app/notes.html +199 -0
  341. package/dist/engineering-pa-workspace/app/onboarding.html +592 -0
  342. package/dist/engineering-pa-workspace/app/profile.html +243 -0
  343. package/dist/engineering-pa-workspace/app/project-detail.html +432 -0
  344. package/dist/engineering-pa-workspace/app/projects.html +297 -0
  345. package/dist/engineering-pa-workspace/app/repos.html +598 -0
  346. package/dist/engineering-pa-workspace/app/schedules.html +486 -0
  347. package/dist/engineering-pa-workspace/app/secrets.html +164 -0
  348. package/dist/engineering-pa-workspace/app/staging.html +319 -0
  349. package/dist/engineering-pa-workspace/app/tasks.html +465 -0
  350. package/dist/engineering-pa-workspace/app/vendor/chart.umd.min.js +21 -0
  351. package/dist/engineering-pa-workspace/app/viewer.html +116 -0
  352. package/dist/engineering-pa-workspace/docs/DAEMON.md +104 -0
  353. package/dist/engineering-pa-workspace/docs/page-blueprint.md +286 -0
  354. package/dist/engineering-pa-workspace/docs/status-mon.md +168 -0
  355. package/dist/engineering-pa-workspace/index.mjs +12 -0
  356. package/dist/engineering-pa-workspace/nav.json.example +8 -0
  357. package/dist/engineering-pa-workspace/package.json +27 -0
  358. package/dist/engineering-pa-workspace/src/api.mjs +2086 -0
  359. package/dist/engineering-pa-workspace/src/install-daemon.mjs +573 -0
  360. package/dist/engineering-pa-workspace/src/nav.mjs +190 -0
  361. package/dist/engineering-pa-workspace/src/secrets-api.mjs +175 -0
  362. package/dist/engineering-pa-workspace/src/server.mjs +516 -0
  363. package/dist/engineering-pa-workspace/src/status-mon/poll.mjs +220 -0
  364. package/dist/engineering-pa-workspace/src/status-mon/poller.mjs +113 -0
  365. package/dist/engineering-pa-workspace/src/status-mon/run.mjs +133 -0
  366. package/dist/engineering-pa-workspace/src/supervisor.mjs +264 -0
  367. package/dist/engineering-pa-workspace/src/ws.mjs +633 -0
  368. package/index.mjs +60 -0
  369. package/package.json +58 -0
  370. package/templates/banned-ai-tells.md +102 -0
  371. package/templates/purpose.md +105 -0
  372. package/templates/voice-guide.md +98 -0
@@ -0,0 +1,161 @@
1
+ ---
2
+ type: standard
3
+ status: active
4
+ scope: core
5
+ appliesTo:
6
+ - All dispatches between an orchestrator and a worker
7
+ ---
8
+
9
+ # Briefing Contract Standard
10
+
11
+ The structured prompt an orchestrator hands to a worker. Every dispatch — whether a single subagent invocation, a task-group worker, or any future mechanism — uses this contract. The structure is mechanical because every missing field is a question the worker has to ask, and every question costs a round trip we cannot afford to a worker running detached.
12
+
13
+ The big rule, drawn from Cognition's published failure analysis, is the **trace field**: every brief must include the reasoning that led to the task, not just the task description. Without it, workers re-derive context from scratch and make locally consistent but globally incompatible choices.
14
+
15
+ ---
16
+
17
+ ## The contract
18
+
19
+ Every brief MUST include all of these fields, in this order. Section headings are mechanical — copy them verbatim.
20
+
21
+ ```markdown
22
+ # <Task name>
23
+
24
+ ## Goal
25
+ <one sentence — what success looks like>
26
+
27
+ ## Trace — why we're doing this
28
+ <one paragraph — the reasoning that led to this task. Decisions already
29
+ made, alternatives ruled out, the broader context the worker needs to
30
+ make consistent choices. Do not skip this section. Cognition's Flappy
31
+ Bird failure happens when workers are briefed without context: they
32
+ embed conflicting assumptions and the integration step is forced to
33
+ reconcile two miscommunications.>
34
+
35
+ ## Context
36
+ <paths, files, decisions already made, constraints, relevant operator
37
+ preferences. Extracted from the operator profile for this task — do not
38
+ send the full profile. Reference standards and existing patterns by
39
+ path so the worker reads the canonical source rather than a paraphrase.>
40
+
41
+ ## Tools and sources
42
+ <which tools the worker should use, which to avoid, where to find
43
+ authoritative information. If the worker should consult specific
44
+ existing files, list them. If the worker should NOT touch certain
45
+ files or systems, say so explicitly.>
46
+
47
+ ## Boundaries
48
+ <what is in scope, what is out of scope. The boundary between "decide
49
+ yourself" and "escalate to me" should be explicit. Reference the
50
+ worker's autonomy envelope if relevant.>
51
+
52
+ ## Output format
53
+ <exactly what the worker returns. File paths, document structure,
54
+ length cap, format. Vague output specs produce vague outputs.>
55
+
56
+ ## Done when
57
+ <concrete acceptance criteria the worker can self-check. "Tests pass"
58
+ is not enough — say which tests, how to run them, what counts as pass.>
59
+
60
+ ## Escalation rule
61
+ <when the worker should stop and escalate rather than guess. Default:
62
+ "if any of the above fields is unclear or you encounter a constraint
63
+ not covered here, stop and report the question rather than guessing."
64
+ Customise per task.>
65
+ ```
66
+
67
+ If your brief is missing any of these fields, **do not dispatch**. Write the missing field or fall back to in-thread execution.
68
+
69
+ ---
70
+
71
+ ## Field-by-field rationale
72
+
73
+ ### Goal
74
+
75
+ One sentence, outcome-shaped. Not "implement function X" — "the system can do Y when Z". The goal is what the worker checks against when it thinks it might be done.
76
+
77
+ ### Trace — the load-bearing field
78
+
79
+ This is the field most often missed and most often the cause of bad outcomes. The trace tells the worker *why* this task exists, what alternatives were considered, what decisions were already made and why. Without it, the worker re-derives context from scratch, and its derivation may not match the orchestrator's.
80
+
81
+ Cognition's Flappy Bird example: one subagent built Mario-style art, another built incompatible bird sprite, the integrator had to reconcile two miscommunications. The cause was not poor briefing — it was *briefing without trace*. Each subagent made consistent local choices that were globally incompatible.
82
+
83
+ The trace prevents this by sharing the orchestrator's reasoning. It does not need to be long. Three to six sentences is usually enough. What matters is that the worker reads it before acting.
84
+
85
+ For task groups of 2+ workers, the trace lives in the shared context store and every worker reads it at the start of every action. The brief still includes a per-worker trace summarising the *worker-specific* reasoning, but the broader trace is in the context store.
86
+
87
+ ### Context
88
+
89
+ The "what" — paths, files, constraints, operator preferences. Distinct from the trace (which is the "why"). Extracted and tailored — never the full operator profile. The worker should not need to read the operator profile to do its job; the orchestrator has already extracted what's relevant.
90
+
91
+ Reference existing standards by path. Do not paraphrase a standard in a brief; the worker should read the canonical source so the standard's evolution propagates.
92
+
93
+ ### Tools and sources
94
+
95
+ Explicit. Workers default to "use whatever tool seems right" which is sometimes wrong. If the task requires WebFetch, say so. If the task forbids modifying files outside a specific path, say so. If the worker should consult a specific reference document before starting, list it.
96
+
97
+ ### Boundaries
98
+
99
+ Where decision authority sits. The default is "decide-alone within the goal, escalate everything else". A more constrained envelope might be "decide-alone within these specific files, decide-and-log everything else, escalate anything affecting external systems". A more permissive envelope might be "you have full latitude on architecture and implementation; report decisions in your final output".
100
+
101
+ The autonomy envelope of the worker's role is the default. The brief can tighten it for this task but should not loosen it without explicit reason.
102
+
103
+ ### Output format
104
+
105
+ Exactly what the worker returns. File paths, length cap, structure. Vague output specs produce vague outputs and force the orchestrator to re-derive structure when integrating.
106
+
107
+ For detached dispatches: the worker writes a report file at a known path. The orchestrator reads the report, not the worker's full context.
108
+
109
+ ### Done when
110
+
111
+ Concrete acceptance criteria. The worker checks against these before declaring done. "Tests pass" alone is not enough — which tests, how to run them, what counts as pass. Vague done criteria produce work that "looks done" but isn't.
112
+
113
+ ### Escalation rule
114
+
115
+ The default escalation rule is the standard one: *if any field is unclear or you encounter a constraint not covered here, stop and report the question rather than guessing*. The brief can customise this — for example, "if you discover the existing implementation is broken in a way that affects your task, fix it and report; do not escalate for a same-file fix".
116
+
117
+ The escalation rule is also where the brief makes peer coordination explicit when the worker is part of a task group: "do not communicate with other workers in this group directly; coordinate via the shared context store at <path>".
118
+
119
+ ---
120
+
121
+ ## Brief size signals
122
+
123
+ A brief shorter than ~50 lines for a detached dispatch is **usually** under-specified. The fields above can all be terse, but the trace and the done criteria in particular are rarely complete in fewer than ten lines combined. If your brief is short, check whether you're missing the trace — that's the most common cause.
124
+
125
+ A brief longer than ~300 lines is **usually** over-specified. If you're prescribing every step, you're not delegating, you're remote-controlling. Step back and ask whether the worker has enough autonomy to actually be useful.
126
+
127
+ ---
128
+
129
+ ## Bolt-on: worktree-isolated dispatches
130
+
131
+ Any dispatch with `isolation: "worktree"` must include the following in its **Boundaries** section, verbatim or equivalent:
132
+
133
+ > **Phase 0 — cwd verification:** Before ANY file-write or git op, run `pwd` and verify the output is inside `.claude/worktrees/agent-<id>/`. If not, `cd` to the worktree root before proceeding.
134
+ >
135
+ > **Worktree absolute-path rule:** Every absolute path passed to Write, Edit, MultiEdit, or Bash (for writes) MUST begin with the worktree root — typically `<project-root>/.claude/worktrees/agent-<id>/...`. Paths beginning with the main worktree root (no worktree segment) are the MAIN worktree and writing to them is forbidden for source changes. Absolute paths are still fine for READING context files from main — the rule applies to writes only.
136
+
137
+ **Why both rules:** Phase 0 catches shell-cwd drift. The absolute-path rule catches Write/Edit tool calls that use absolute paths (the default behaviour in some agent runtimes), which bypass `cwd` entirely. Phase 0 alone is necessary but not sufficient; field experience has shown dozens of file changes landing in main via absolute paths despite a passing `pwd` check.
138
+
139
+ **Recovery playbook** (when a worker writes to the wrong worktree):
140
+ 1. `cp <file-in-main> <worktree>` for every intended edit
141
+ 2. `git -C <main> checkout -- <file>` on files the worker themselves modified (surgical — never `git checkout .`)
142
+ 3. `rm <main>/<file>` for untracked files the worker created
143
+
144
+ ---
145
+
146
+ ## Bolt-on: specification quality checklist
147
+
148
+ When a brief's **Context** or **Goal** includes consuming a structured payload (API response, config file, event schema) to gate decisions or rendering, the brief must address:
149
+
150
+ 1. **Effective-value rule.** If the payload contains multiple fields describing the same phenomenon (e.g. `overall.indicator` vs per-incident `impact`), the brief MUST define how to reconcile disagreement. Do not pick one field arbitrarily.
151
+
152
+ 2. **Shell-path test coverage.** If the output is UI rendered inside an iframed shell (a workspace shell or any future wrapper), the **Done when** must include at least one e2e test that navigates through the shell, not just direct-to-page loads.
153
+
154
+ Both rules derive from incidents where individually-passing specs missed real user-path failures.
155
+
156
+ ---
157
+
158
+ ## See also
159
+
160
+ - [`tooling.md`](./tooling.md) — the tooling standard that briefs reference for any worker that writes internal tooling.
161
+ - Operator extensions: an operator's `operator/knowledge/engineering/standards/briefing-contract.md` (when present) MAY add operator-specific bolt-ons but MUST NOT relax this contract.
@@ -0,0 +1,240 @@
1
+ ---
2
+ type: standard
3
+ status: active
4
+ scope: core
5
+ appliesTo:
6
+ - core/tools/**
7
+ - operator/extensions/tools/**
8
+ ---
9
+
10
+ # Tooling Standard
11
+
12
+ Canonical contract for shared and library tools on the platform. This document is authoritative for every tool that ships in `core/tools/`, and the default contract for tools under `operator/extensions/tools/`. Operators MAY extend this standard with additional, more-restrictive rules in their own `operator/knowledge/engineering/standards/tooling.md`; they MUST NOT relax it.
13
+
14
+ A tool that does not satisfy every section below is non-compliant. Compliance is enforced by code review, by the tooling lint described in [§17](#17-lint-enforcement), and by the readers of every README who treat it as the spec.
15
+
16
+ See also: [`naming.md`](./naming.md) (when present in your tree), the per-tool README under `core/tools/<alias>/README.md`, and the broader principles document at `operator/knowledge/principles.md` if your operator layer ships one.
17
+
18
+ ---
19
+
20
+ ## 1. Identity & naming
21
+
22
+ - Reverse-domain identity in `package.json` under `"name"`: `<org>.<scope>.<component>`, e.g. `ai.example.platform.svc`.
23
+ - `<scope>` is the functional domain (`platform`, `ops`, `knowledge`, …).
24
+ - `<component>` is a short identifier matching the CLI alias.
25
+ - Short CLI alias — single lowercase word, verb-ish or noun-ish. The alias is the directory name under `core/tools/` (or `operator/extensions/tools/`) and the name of the shim in `bin/`.
26
+ - Location: `core/tools/<alias>/`. The bin shim is `core/tools/<alias>/bin/<alias>`.
27
+ - Reference implementations shipped in core: `core/tools/secrets/`, `core/tools/memory-sync/`, `core/tools/smoke/`, `core/tools/distill/`.
28
+
29
+ ## 2. Language and cross-platform posture
30
+
31
+ - **Tools are written in Node.js. Full stop.** Shell scripts (`.sh`, `.ps1`, `.bat`, `.zsh`, `.fish`) are not acceptable tool implementations. The platform ships to macOS, Linux, and Windows — a Unix-shell tool silently breaks on Windows; a PowerShell tool silently breaks on Unix; a platform that depends on maintaining two parallel shell implementations is a platform with twice the surface area and half the confidence.
32
+ - **The only acceptable shell files in the repo are thin launchers at repo root** (`dave.sh` + `dave.ps1`) which exist because *something* has to pre-date Node being available. Any logic inside those launchers that grows beyond "parse flags, find node, hand off" belongs in a Node.js tool they invoke.
33
+ - Tools shell out to external **binaries** (git, docker, ssh, sops, age, node itself) as needed — those are cross-platform programs with native installers, not scripts. `node:child_process.spawn` does this fine without a shell in the middle.
34
+ - Rationale: every `.sh`-only tool ever shipped on this platform created a Windows gap that wasn't noticed until an operator hit it. The cost of writing one tool in Node is always less than the cost of discovering the gap in production.
35
+
36
+ ## 3. Dependencies
37
+
38
+ - **Zero runtime npm dependencies in the tool itself.** Tools use only the Node standard library.
39
+ - Allowed stdlib surface: `node:util` (especially `parseArgs`), `node:child_process`, `node:fs/promises`, `node:path`, `node:os`, `node:test`, `node:assert/strict`.
40
+ - No schema libraries, no CLI frameworks, no test frameworks, no lodash.
41
+ - Rationale:
42
+ - **Auditability** — the entire tool is readable without third-party spelunking.
43
+ - **Supply-chain hygiene** — no transitive footguns, no lockfile churn.
44
+ - **Reproducibility** — a cloned repo runs immediately; no `npm install` step to fail.
45
+ - **Longevity** — the Node stdlib outlives every fashion in userland.
46
+ - Runtime infrastructure that a tool *manages* (e.g. pm2 for native service supervision, docker for container orchestration) is a separate concern — those are external programs the tool shells out to, not dependencies of the tool.
47
+
48
+ ## 4. Project structure
49
+
50
+ Canonical layout:
51
+
52
+ ```
53
+ core/tools/<alias>/
54
+ bin/<alias> # node shebang shim — one line
55
+ package.json # name, version, type: module, no dependencies
56
+ README.md # the spec (see §9)
57
+ src/
58
+ cli.mjs # arg parsing, verb routing, exit-code translation
59
+ {domain}.mjs # domain loaders (e.g. discover.mjs, manifest.mjs)
60
+ runner.mjs # SOLE chokepoint for external effects (see §7)
61
+ commands/
62
+ {verb}.mjs # thin glue per command
63
+ renderers/
64
+ {runtime}.mjs # pure functions per target runtime
65
+ test/
66
+ fixtures/ # sample inputs, fake trees
67
+ *.test.mjs # node:test, one per module under test
68
+ ```
69
+
70
+ Per-directory rationale:
71
+
72
+ - **`bin/<alias>`** — a single-line node shebang shim importing `src/cli.mjs`. The entry point is unambiguously the CLI module; the shim carries no logic.
73
+ - **`src/cli.mjs`** — the only module that knows about `process.exit` codes. Commands return numbers or throw; `cli.mjs` translates to exit codes.
74
+ - **`src/{domain}.mjs`** — pure loaders, validators, and domain helpers. No spawning, no SSH.
75
+ - **`src/runner.mjs`** — the chokepoint (§7). Nothing else spawns processes.
76
+ - **`src/commands/`** — glue. Each command file is thin: discover → render → run → format.
77
+ - **`src/renderers/`** — pure functions per runtime. No I/O. Easy to test, easy to swap.
78
+ - **`test/`** — `node:test` files alongside `fixtures/`. No separate test config.
79
+
80
+ Smaller tools may compress this layout — a single `src/cli.mjs` is fine when there is no chokepoint to isolate. Larger tools must observe the boundaries above.
81
+
82
+ ## 5. CLI conventions
83
+
84
+ - **Verb-noun pattern**: `<alias> list`, `<alias> status <target>`, `<alias> health <target>`. Verb first, target after.
85
+ - **`--help` / `-h`** prints usage and exits `0`.
86
+ - Arg parsing uses `node:util.parseArgs` with `strict: true`. No ad-hoc string splitting.
87
+ - Subcommand routing is an explicit `switch` in `cli.mjs`. No dynamic dispatch, no plugin mechanism.
88
+ - Unknown verbs exit `1` with usage printed to stderr.
89
+ - Flags use long form primarily (`--device foo`). Short flags only for `--help` / `-h`.
90
+
91
+ ## 6. Exit code contract
92
+
93
+ Every tool uses the same four exit codes:
94
+
95
+ | Code | Meaning |
96
+ |---|---|
97
+ | `0` | OK |
98
+ | `1` | Usage error (bad arguments, unknown target, ambiguous selector) |
99
+ | `2` | Logical / operational failure (the thing you asked about is broken, unhealthy, missing) |
100
+ | `3` | Transport / IO failure (ssh, spawn, network, disk) |
101
+
102
+ Rationale: automation can distinguish *"you invoked me wrong"* from *"the world is broken"* from *"I couldn't even reach the world"*. Translation is centralised in `cli.mjs` — domain code throws errors carrying an exit-code property (e.g. `err.exitCode`), and the CLI wrapper maps them to `process.exit`.
103
+
104
+ ## 7. Module boundaries and the chokepoint pattern
105
+
106
+ **Every external-effect API has exactly one place where it can happen.**
107
+
108
+ This is a general principle, not a tool-specific detail. When an operation has safety properties that must always hold — rate limits, destructive guards, dry-run support, retry logic, auditing — those properties are enforced in a single chokepoint module. Scattered call sites mean scattered violations.
109
+
110
+ - A canonical example: an SSH-driven tool exposes a `runner.mjs` that is the only module that spawns processes or opens SSH. It deliberately does **not** expose a "run a command N times remotely" API. Tools that need more remote work must build a bigger script and dispatch it once.
111
+ - Renderer-per-runtime separation: `renderers/{runtime}.mjs` produces the script or config for a given substrate. Renderers are pure — no I/O. Commands drive the actual execution via the runner.
112
+ - Domain concerns (`discover.mjs`, `manifest.mjs`) are separate from execution concerns (`runner.mjs`) are separate from presentation concerns (`renderers/`, `cli.mjs`).
113
+
114
+ When designing a new tool, ask: *what operation, if it ever happens in the wrong place or the wrong way, causes the most damage?* That operation gets a chokepoint.
115
+
116
+ ## 8. Testing
117
+
118
+ - Test runner: `node:test`. Assertions: `node:assert/strict`. Nothing else.
119
+ - Layout: `test/*.test.mjs` plus `test/fixtures/` for sample inputs.
120
+ - Run: `node --test core/tools/<alias>/test/*.test.mjs`.
121
+ - **Dependency injection over mocking libraries.** Modules that touch the outside world expose a seam for tests — e.g. `runner.mjs` accepts (or can be monkey-patched to use) a fake spawner. No `sinon`, no `jest.mock`.
122
+ - Coverage expectations:
123
+ - Every module has a test file.
124
+ - Commands are tested via fake renderers.
125
+ - Renderers are pure — tested directly as input-to-output functions.
126
+ - The runner is exercised against a real local command *and* against a fake spawner to verify framing and error paths.
127
+ - Real network / SSH never appears in the test suite.
128
+
129
+ ## 9. README as contract
130
+
131
+ The README is the specification. It is not marketing, not a tutorial, not a changelog. Read-and-extend: a new contributor should be able to read only the README and understand the tool completely. Required sections:
132
+
133
+ - **Identity** — reverse-domain name, one-line purpose.
134
+ - **Status** — what's implemented vs deferred.
135
+ - **Install / invoke** — how to run it.
136
+ - **Commands** — every verb, synopsis, flags.
137
+ - **Exit codes** — the contract from §6.
138
+ - **Operational discipline rules** — non-negotiable constraints baked into the architecture (see §10).
139
+ - **Project layout** — the directory tree with one-line rationale per entry.
140
+ - **Tests** — how to run them.
141
+ - **The tooling standard** — back-reference to this document, naming the sections that govern the tool.
142
+
143
+ Tone: dense, declarative, no fluff. This is a contract.
144
+
145
+ ## 10. Operational discipline rules
146
+
147
+ Some tools have non-negotiable safety rules baked into their architecture. These rules are documented in the README, enforced in the chokepoint module, and have no escape hatch API.
148
+
149
+ **Example — SSH discipline.** A target host enforces, say, a 6-connection / 60-second SSH rate limit. Exceeding it locks the agent out and trips a firewall dead-man switch. Therefore every command of an SSH-driven tool performs at most one SSH call per cluster. For a `health` verb, all healthchecks are concatenated into a single bash script and dispatched once via `ssh <host> bash -s`. The runner deliberately has no "run remote command N times" API — there is no remote-loop footgun because there is no remote-loop API.
150
+
151
+ When a tool has a similar constraint (rate limits, destructive operations, audit requirements), it follows the same pattern: one chokepoint, no loop API, rule written into the README.
152
+
153
+ ## 11. JSON conventions
154
+
155
+ All JSON produced or consumed by tools uses **camelCase** property names. **No exceptions.** This matches the rule the Librarian enforces across the knowledge system. Values that are identifiers (service IDs, role IDs, map keys) keep their natural form; only the property *names* are governed.
156
+
157
+ Snake_case and kebab-case property names are violations and must be corrected in place; consumers are updated in the same change.
158
+
159
+ ## 12. Reference implementations
160
+
161
+ Concrete tools shipped in core that exemplify this standard:
162
+
163
+ - [`core/tools/secrets/`](../../tools/secrets/) — vault CLI; clean chokepoint, hand-rolled validation, exit-code discipline.
164
+ - [`core/tools/memory-sync/`](../../tools/memory-sync/) — bidirectional cache mirror; demonstrates the `2`-overload for "asked-thing-not-where-it-should-be" semantics.
165
+ - [`core/tools/smoke/`](../../tools/smoke/) — health-check orchestrator; pure renderer + chokepoint runner pattern.
166
+ - [`core/tools/distill/`](../../tools/distill/) — scheduled tool with the audit-record contract from §15.
167
+
168
+ Read these before designing a new tool.
169
+
170
+ ## 13. Versioning
171
+
172
+ Tools are versioned via the `version` field in their `package.json`. Release notes live in the README under a `## Changelog` heading, or in a dedicated `CHANGELOG.md` once the history grows large enough to warrant it. SemVer applies: the CLI surface and exit-code contract are the public API.
173
+
174
+ ## 14. Installing on PATH
175
+
176
+ Tools live under `core/tools/<name>/` and are invoked through their `bin/<name>` shim. To make them callable as a bare command from any directory, the convention is:
177
+
178
+ - A single directory `core/tools/bin/` at the repo root contains **symlinks** to each tool's `bin/<name>` shim.
179
+ - The PATH addition is **one entry**, set by the operator (e.g. in `~/.zshrc` or via the launcher script). Adding a new tool means dropping one symlink — no PATH change.
180
+ - The shim is `#!/usr/bin/env node` with one line: `import('../src/cli.mjs').then(m => m.main(process.argv.slice(2)))`. Node resolves the symlink to its target before resolving the relative `import`, so the symlink Just Works without any `--preserve-symlinks` ceremony.
181
+
182
+ To install on a new machine:
183
+
184
+ ```bash
185
+ ln -sf ../<tool>/bin/<tool> core/tools/bin/<tool>
186
+ ```
187
+
188
+ That's the entire install procedure. Operators who automate this can add the PATH entry to whatever shell-rc loader they ship.
189
+
190
+ ## 15. Scheduled-tool audit-record contract
191
+
192
+ Any scheduled tool that writes a `runs.jsonl` MUST append one record on every non-dry-run exit path — success, legitimate no-op, AND failure. Downstream freshness monitors (e.g. `tasks status` overlays) read `runs.jsonl`'s last line; if any exit path skips the append, the monitor sees stale data and either alarms falsely or stays silent on real outages.
193
+
194
+ **Required fields:**
195
+
196
+ | Field | Values | Notes |
197
+ |---|---|---|
198
+ | `status` | `ok`, `noop-*`, `fail-*` | Closed vocabulary. Prefix match for monitors: `noop-*` = fresh, `fail-*` = failing |
199
+ | `ts` | RFC-3339 (`YYYY-MM-DDTHH:MM:SSZ`) | Must `new Date(ts)` without NaN. Filename-safe ts with dashes belongs only in filenames and commit-message slugs |
200
+
201
+ **Rules:**
202
+
203
+ 1. Append on every non-dry-run exit path — success, no-op, AND failure.
204
+ 2. Skip the append on dry-run (no side effects).
205
+ 3. Tests must cover every exit path's audit record, not just the happy path.
206
+ 4. Backwards compat: consumers that fall back to `exitCode` when `status` is absent handle historical records.
207
+
208
+ ## 16. Operational artefacts must be gitignored
209
+
210
+ Per-host operational files — audit logs (`runs.jsonl`), last-run timestamps, host-local caches, PID files — **must be in `.gitignore`**. They must never be git-tracked.
211
+
212
+ **Why:** Any tool that combines (a) writes to a tracked file on every invocation (audit log, counter, timestamp) with (b) a precondition that fails on working-tree modifications will deadlock itself within one cycle. The first run dirties the tree; the next run sees the dirty tree and refuses to start; the refusal writes another audit line; the tree gets dirtier.
213
+
214
+ This is not a hypothetical. Multiple scheduled tools across the platform have hit exactly this deadlock — `runs.jsonl` was tracked, the runner had a clean-tree precondition, and the schedule wedged for days.
215
+
216
+ **Rule:** cross-host visibility of operational state is a legitimate need, but git-tracking the file is the wrong solution. Use a workspace endpoint, a sync job, or shared storage instead. The file stays local and gitignored; the visibility layer reads it on demand.
217
+
218
+ ## 17. Lint enforcement
219
+
220
+ A `core/*` document, role definition, or tool source file must not refer to paths under `operator/`, `agents/`, `work/`, `projects/`, `.vault/`, or `schedules/`. Those directories are operator-owned; nothing in core is allowed to depend on them. Cross-layer references invert the layering and silently break for forks that have not populated their operator layer in the same shape as the originating fork.
221
+
222
+ The `core/tools/lint-core-isolation/` tool enforces this rule. It scans `core/**/*.{md,mjs,js,ts,json}` and exits `2` with a list of violations on any cross-layer reference. CI runs the lint on every push and pull request.
223
+
224
+ Allowed exceptions are limited and explicitly enumerated in the lint tool's README:
225
+
226
+ - Comments or strings naming `operator/` purely as a *destination convention* (e.g. server code that locates the operator's knowledge tree at runtime). These are functional references, not documentation pointers, and they live in the lint's allowlist with a one-line justification.
227
+ - Test fixtures that simulate the operator layer for the purpose of testing core code. These live under `core/tools/<tool>/test/fixtures/operator/` and the lint allowlist names that prefix.
228
+
229
+ If you need a new exception, change the lint allowlist and explain in the same change why the reference cannot be eliminated. "It would be inconvenient to remove" is not a justification.
230
+
231
+ ---
232
+
233
+ ## Operator extensions
234
+
235
+ Operators may layer additional rules on top of this standard at `operator/knowledge/engineering/standards/tooling.md`. The operator-side document SHOULD:
236
+
237
+ - Cite this document as the base.
238
+ - State only the operator-specific *additions* (e.g. operator-private CLI conventions, operator-private chokepoints, naming for operator-private runtime targets). It MUST NOT contradict any rule in this document.
239
+
240
+ Tools under `operator/extensions/tools/` follow this standard as the floor; the operator's extensions raise it where needed.
@@ -0,0 +1,230 @@
1
+ # distill
2
+
3
+ `@stravica-ai/engineering-pa-core` › `distill` — the librarian distillation
4
+ sweep runner.
5
+
6
+ Launches a non-interactive Claude Code session as the Librarian, hands it
7
+ the repo-wide distillation prompt, and writes its outputs into the working
8
+ tree. **It does not commit, pull, fetch, or push.** Git is owned by the
9
+ per-host `sync` CLI (`packages/cli/src/sync/`); distill is a pure file
10
+ writer.
11
+
12
+ Designed for cron: quiet on success, loud on failure, exit-code accurate
13
+ so cron mail / monitoring can catch breakage.
14
+
15
+ ## Status
16
+
17
+ Implemented: `run`, `run --dry-run`, `--help`.
18
+
19
+ ## Install / invoke
20
+
21
+ Via the core package's bin shim — from an operator repo:
22
+
23
+ ```
24
+ pnpm exec distill run
25
+ pnpm exec distill run --dry-run
26
+ pnpm exec distill --help
27
+ ```
28
+
29
+ (or directly in this repo: `node packages/core/bin/distill run`.)
30
+
31
+ Scheduled by the operator repo's `schedules/distillation-sweep.json`
32
+ (cadence is operator-configured). The scheduler invokes it from the
33
+ operator repo root via cron. The companion sync schedule (e.g.
34
+ `schedules/dave-sync.json`, every 30 minutes on the same host) picks up
35
+ any file changes distill produced.
36
+
37
+ ## Commands
38
+
39
+ ### `distill run`
40
+
41
+ 1. Resolve prereqs — repo root (walks up to `.git`), `paName` from
42
+ `operator/config/preferences.json`, librarian definition per the
43
+ resolution order below, `claude` on `$PATH`, log dir
44
+ `<repoRoot>/.cache/distill/logs/` (created if missing; gitignored per
45
+ tooling standard §16).
46
+ 2. Count markdown observations under `agents/*/staging/` (depth ≤ 2,
47
+ excluding `_archived/`). If zero, append a `noop-empty-staging`
48
+ audit record and exit 0.
49
+ 3. Invoke `claude` with the librarian definition as an appended system
50
+ prompt and the distillation instructions as the positional prompt.
51
+ Output is written to `<repoRoot>/.cache/distill/logs/<ts>.log`.
52
+ 4. Append a one-line JSON audit record to
53
+ `<repoRoot>/.cache/distill/logs/runs.jsonl` (schema below).
54
+ 5. Exit 0 (ok) or 3 (claude transport failure).
55
+
56
+ ### Librarian definition resolution
57
+
58
+ The system prompt appended to the sweep session is resolved in this
59
+ order (highest precedence first):
60
+
61
+ 1. **Explicit `librarianDef` option** (tests pass fixture paths here).
62
+ The caller controls the whole prompt; no supplement is applied.
63
+ 2. **Full operator override** at
64
+ `operator/extensions/roles/librarian/definition.md` (under the
65
+ discovered repo root). The operator has taken ownership of the whole
66
+ prompt: the file is used byte-for-byte and **no supplement is
67
+ appended, even if `overrides.md` also exists**. This preserves exact
68
+ back-compat with pre-supplement operator repos.
69
+ 3. **Bundled definition + operator supplement.** When there is no full
70
+ override but `operator/extensions/roles/librarian/overrides.md`
71
+ exists, the composed prompt is the bundled definition followed by the
72
+ supplement, joined by an explicit precedence statement: wherever the
73
+ supplement conflicts with the bundled text, **the supplement wins**;
74
+ where it is silent, the bundled definition applies unchanged. This is
75
+ the recommended way to customise routing (e.g. a repo-specific
76
+ operational-rules destination) without forking — and silently
77
+ diverging from — the whole bundled definition.
78
+ 4. **Bundled definition alone**
79
+ (`engineering-pa-core/roles/librarian/definition.md` inside the
80
+ package tree).
81
+
82
+ A supplement file that exists but is empty or whitespace-only is treated
83
+ as absent (outcome 4): appending an empty supplement under an
84
+ operator-wins banner would claim a customisation that does not exist.
85
+ The dry-run plan reports which outcome applied — the resolved definition
86
+ path and byte size, the supplement path and byte size (or `none`, or
87
+ `empty — ignored`), and the composed total.
88
+
89
+ **Git changes the librarian produces are committed by sync, not here.**
90
+ Distill stops at the audit-record write; the sync CLI's next tick on
91
+ the same host picks up the staging-area changes, the deletions from
92
+ `agents/*/staging/`, the additions/updates under `operator/knowledge/`
93
+ and `operator/profile/`, etc.
94
+
95
+ ### Why the change (2026-05-11)
96
+
97
+ Previously distill did `git status / fetch / pull --rebase` as a pre-flight
98
+ and `git add / commit / push` as a post-flight. This raced with the other
99
+ cron writers on the same host (`wsd-ingest` every 15m, `upstream-triage`
100
+ every 30m), each doing the same thing on their own clocks. A ~2-second
101
+ window between `isTreeClean` and `pull --rebase` was enough to surface
102
+ `fail-rebase` audit records — including the 2026-05-11 03:00 BST alert.
103
+ The fix is structural: cron tools stop touching git; a single per-host
104
+ writer (the `sync` CLI, `packages/cli/src/sync/`) handles all of it.
105
+
106
+ ### `runs.jsonl` audit-record schema
107
+
108
+ One JSON object per line, camelCase keys (§11 of the tooling standard):
109
+
110
+ | Field | Type | Description |
111
+ |---|---|---|
112
+ | `ts` | string | RFC-3339 / ISO-8601 UTC timestamp (e.g. `2026-04-16T02:00:06Z`). Round-trips cleanly through `new Date()`. |
113
+ | `status` | string | Semantic status, closed vocabulary (see below). |
114
+ | `exitCode` | number | Process exit code (0 / 2 / 3). Consumers that only need pass/fail can ignore `status`. |
115
+ | `durationSec` | number | Seconds elapsed. Typically 0 for pre-claude early exits. |
116
+ | `stagingCount` | number | Result of `countStagedObservations`. 0 on `noop-empty-staging`. |
117
+ | `log` | string \| null | Basename of the per-run log file, or `null` when no log file was created (pre-claude early exits). |
118
+ | `reason` | string | Human-readable one-liner. Present on every non-`ok` record; omitted on `ok`. |
119
+
120
+ Status vocabulary (closed set):
121
+
122
+ | Status | exitCode | When |
123
+ |---|---|---|
124
+ | `ok` | 0 | Claude ran successfully (changes, if any, will be committed by sync). |
125
+ | `noop-empty-staging` | 0 | No observations in `agents/*/staging/` — healthy no-op. |
126
+ | `fail-claude` | 3 | Claude exited non-zero. |
127
+ | `fail-cli-bootstrap` | 1 / 2 | parseArgs / startup failure before runDistill was reached. |
128
+
129
+ Statuses that USED to exist but no longer can (the git pre/post-flight was removed):
130
+ `fail-dirty-tree`, `fail-rebase`, `fail-git`. Historical records carrying
131
+ those statuses remain valid and consumers should still recognise them.
132
+ Git is now owned end-to-end by the per-host `sync` CLI
133
+ (`packages/cli/src/sync/`).
134
+
135
+ Consumer contract: monitors should treat `status == 'ok'` and any
136
+ `noop-*` as healthy; any `fail-*` as failing. For backwards compatibility
137
+ with historical entries (pre-2026-04-22) that lack the `status` field,
138
+ derive from `exitCode`: 0 ⇒ healthy, non-zero ⇒ failing.
139
+
140
+ ### `distill run --dry-run`
141
+
142
+ Same as step 1–2, then print what *would* be invoked (including the
143
+ explicit "git: none — sync (core/tools/sync) picks up changes" line) and
144
+ exit 0. Never spawns `claude`, never writes `runs.jsonl`.
145
+
146
+ ## Exit codes
147
+
148
+ | Code | Meaning |
149
+ |---|---|
150
+ | `0` | OK — nothing to distill, or sweep completed. |
151
+ | `1` | Usage error (unknown verb, bad flag). |
152
+ | `2` | Prerequisite missing (no preferences, no paName, no librarian definition, no `claude` on PATH). |
153
+ | `3` | Transport / IO failure (claude exited non-zero). |
154
+
155
+ ## Operational discipline rules
156
+
157
+ 1. **One claude invocation per run.** The runner has no "invoke claude
158
+ multiple times" API. Bigger sweeps go in the prompt; they do not
159
+ become more spawns.
160
+ 2. **No shell interpolation.** Every `spawn()` call passes arguments as
161
+ an array with `shell:false`. User-supplied data (observation filenames,
162
+ paths with spaces) flows through untouched — a malicious name cannot
163
+ become a shell command.
164
+ 3. **Chokepoint for every external effect.** `src/runner.mjs` is the only
165
+ module that spawns processes or reads wall-clock time. Tests replace
166
+ it with a scripted fake to exercise every flow without touching the
167
+ filesystem, the network, or claude.
168
+ 4. **No git, ever.** Distill must not spawn `git` of any kind — that
169
+ discipline is the structural fix for the racy pre/post-flight pattern.
170
+ The regression test `regression: distill spawns NO git commands at any
171
+ point` exists specifically to enforce this; if a future maintainer
172
+ re-introduces a git call, that test will fail.
173
+
174
+ ## Project layout
175
+
176
+ ```
177
+ packages/core/
178
+ bin/distill Node shebang shim. One line.
179
+ docs/tools/distill.md This file. The contract.
180
+ src/distill/
181
+ cli.mjs Arg parsing (node:util.parseArgs), verb routing,
182
+ exit-code translation.
183
+ run.mjs Orchestrator. One function per step of the sweep.
184
+ prereqs.mjs Repo root, paName, librarian def, claude-on-PATH.
185
+ staging.mjs Counts agents/*/staging/*.md (depth ≤ 2, no _archived).
186
+ prompt.mjs DISTILL_PROMPT + claudeArgs(). Pure strings.
187
+ runner.mjs Chokepoint — the only module that spawns processes
188
+ and reads the clock. Takes a spawner factory so the
189
+ tests can inject a fake.
190
+ test/distill/
191
+ fixtures/ Synthetic repo trees (clean, empty, missing-pieces).
192
+ *.test.mjs node:test.
193
+ ```
194
+
195
+ (`src/git.mjs` and `test/git.test.mjs` were removed in the 2026-05-11
196
+ sync refactor — they tested porcelain-Z parsing that is no longer
197
+ needed.)
198
+
199
+ ## Tests
200
+
201
+ ```
202
+ node --test packages/core/test/distill/*.test.mjs
203
+ ```
204
+
205
+ Tests use dependency injection over mocking libraries. Real git, real
206
+ claude, and real filesystem mutations (outside of a temp dir) never
207
+ appear in the suite.
208
+
209
+ Coverage:
210
+
211
+ - `staging.test.mjs` — staging counter with and without `_archived/`.
212
+ - `prereqs.test.mjs` — every error path on the prerequisite ladder, plus
213
+ the four-step librarian-definition resolution order (explicit opt >
214
+ full override > bundled + supplement > bundled alone).
215
+ - `run.test.mjs` — empty staging (audits `noop-empty-staging`),
216
+ dry-run, happy path, claude failure (audits `fail-claude`), two
217
+ regression guards that fail if a future change re-introduces any
218
+ `git` invocation, and the librarian-definition composition contract:
219
+ full-override back-compat (byte-for-byte, supplement ignored),
220
+ bundled + supplement composition with the operator-wins precedence
221
+ statement, whitespace-only supplements treated as absent, and dry-run
222
+ reporting of source paths + byte sizes under each resolution outcome.
223
+ - `cli.test.mjs` — `--help`, `-h`, no-args, unknown verb, unknown flag.
224
+
225
+ ## The tooling standard
226
+
227
+ This tool follows [the tooling standard](../standards/tooling.md)
228
+ (§1 identity, §2 Node-only, §3 zero deps, §4 structure, §5 CLI,
229
+ §6 exit codes, §7 chokepoint, §8 testing, §11 camelCase JSON, §15 audit-record,
230
+ §16 gitignored operational artefacts).