@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,142 @@
1
+ // team-scope.mjs — shared project-visibility scoping for every read surface
2
+ // that enumerates projects/*/project.json (desk overview/today/projects,
3
+ // `pa project list`, `pa status`'s in-process `desk overview`).
4
+ //
5
+ // Why this exists: the operator repo's projects/ directory is materialised
6
+ // from multiple teams via a library-sync transport (see work item
7
+ // w-2026-07-14-008). Without scoping, one team's read surfaces show every
8
+ // other team's projects with no way to tell them apart at a glance.
9
+ //
10
+ // Scoping key: project.executor, falling back to project.assignee. This is
11
+ // deliberate — `owner` is a human name (e.g. "Barry") that can be shared
12
+ // across teams working for the same person under different agent
13
+ // identities, so it cannot discriminate. `executor`/`assignee` carry the
14
+ // *agent* identity that actually does the work, which is unique per team.
15
+ //
16
+ // Own-team is a SET, not a single name: in real estates `assignee` carries
17
+ // a mix of agent names ("dave") and role names ("system-architect") on
18
+ // projects that belong to the same team. Matching against paName alone
19
+ // would silently hide the role-assigned projects. The effective set is
20
+ // `preferences.json:teamIdentities` (string[]) when present, else
21
+ // `[paName]` — and paName is ALWAYS a member even if teamIdentities omits
22
+ // it (belt-and-braces: the local agent must never scope out its own
23
+ // directly-assigned projects through a config oversight).
24
+ //
25
+ // Fail-open: a project with neither `executor` nor `assignee` set is
26
+ // unclassifiable. It is always shown in the default scoped view — hiding
27
+ // unowned work silently is a worse failure than a little noise.
28
+ //
29
+ // Backward compatibility: scoping only activates when the operator repo
30
+ // opts in via `operator/config/preferences.json:scopeProjectsToTeam = true`.
31
+ // With no config and no flags, behaviour is unchanged from pre-scoping
32
+ // desk/pa (show everything). This is load-bearing — existing installs must
33
+ // not silently start hiding projects on a package bump.
34
+
35
+ import { readFile } from 'node:fs/promises';
36
+ import { join } from 'node:path';
37
+
38
+ /**
39
+ * Resolve the agent identity a project is scoped to, or null if the
40
+ * project carries no identity field at all (unclassifiable -> fail open).
41
+ */
42
+ export function resolveProjectIdentity(project) {
43
+ if (!project) return null;
44
+ return project.executor || project.assignee || null;
45
+ }
46
+
47
+ /**
48
+ * True if `project` belongs to the local team under the default scoped
49
+ * view. `selfIdentities` is the team-identity set (Set or array of
50
+ * strings — mixed agent names and role names; see header note).
51
+ * Unclassifiable projects (no executor/assignee) count as "own" for the
52
+ * purposes of the default view — see fail-open note above.
53
+ */
54
+ export function isOwnProject(project, selfIdentities) {
55
+ const identity = resolveProjectIdentity(project);
56
+ if (identity == null) return true;
57
+ const set = selfIdentities instanceof Set ? selfIdentities : new Set(selfIdentities || []);
58
+ return set.has(identity);
59
+ }
60
+
61
+ /**
62
+ * Filter a project list per the team-scoping rules.
63
+ *
64
+ * Precedence:
65
+ * 1. `team` explicit filter (--team <identity>) — strict: only projects
66
+ * whose resolved identity matches exactly. Unclassifiable projects are
67
+ * NOT included here; the fail-open guarantee applies to the default
68
+ * view, not to a narrow explicit query for one specific team.
69
+ * 2. `allTeams` (--all-teams) — bypass scoping entirely, return input
70
+ * unchanged.
71
+ * 3. `scopeEnabled` false (no config opt-in) — bypass scoping entirely,
72
+ * return input unchanged (backward compatibility).
73
+ * 4. Default scoped view — own projects + unclassifiable (fail open).
74
+ *
75
+ * @param {object[]} projects
76
+ * @param {object} opts
77
+ * @param {string[]|Set<string>} opts.selfIdentities - local team-identity
78
+ * set (effective set from readTeamScopeConfig: teamIdentities ∪ {paName})
79
+ * @param {boolean} opts.scopeEnabled - config opt-in state
80
+ * @param {boolean} [opts.allTeams] - explicit bypass
81
+ * @param {string|null} [opts.team] - explicit single-identity filter
82
+ */
83
+ export function filterProjectsByTeam(projects, opts = {}) {
84
+ const { selfIdentities = [], scopeEnabled = false, allTeams = false, team = null } = opts;
85
+
86
+ if (team) {
87
+ return projects.filter((p) => resolveProjectIdentity(p) === team);
88
+ }
89
+ if (allTeams) return projects;
90
+ if (!scopeEnabled) return projects;
91
+
92
+ const set = selfIdentities instanceof Set ? selfIdentities : new Set(selfIdentities);
93
+ return projects.filter((p) => isOwnProject(p, set));
94
+ }
95
+
96
+ /**
97
+ * Read the team-scoping config out of operator/config/preferences.json.
98
+ * Falls back to disabled scoping + no identity if the file is missing or
99
+ * malformed — same fail-open posture as the filter itself.
100
+ *
101
+ * `teamIdentities` in the returned object is the EFFECTIVE set, already
102
+ * resolved: `preferences.teamIdentities` (string[], non-string entries
103
+ * dropped) when present, else `[paName]` — with paName always unioned in
104
+ * even when the configured list omits it (documented belt-and-braces: the
105
+ * local agent can never scope out its own directly-assigned projects).
106
+ *
107
+ * @param {string} repoRoot
108
+ * @returns {Promise<{ paName: string, teamIdentities: string[], scopeEnabled: boolean }>}
109
+ */
110
+ export async function readTeamScopeConfig(repoRoot) {
111
+ let paName = 'pa';
112
+ let configured = null;
113
+ let scopeEnabled = false;
114
+ try {
115
+ const raw = await readFile(join(repoRoot, 'operator', 'config', 'preferences.json'), 'utf8');
116
+ const config = JSON.parse(raw);
117
+ paName = config.paName || config.agentName || 'pa';
118
+ scopeEnabled = config.scopeProjectsToTeam === true;
119
+ if (Array.isArray(config.teamIdentities)) {
120
+ configured = config.teamIdentities.filter((x) => typeof x === 'string' && x.length > 0);
121
+ }
122
+ } catch {
123
+ // Missing/malformed file -> defaults above (scoping disabled).
124
+ }
125
+ const teamIdentities = [...new Set([paName, ...(configured || [])])];
126
+ return { paName, teamIdentities, scopeEnabled };
127
+ }
128
+
129
+ /**
130
+ * Parse the two team-scope flags out of an argv-style array. Does not
131
+ * consume/mutate the input; callers that also parse other flags should
132
+ * run this in addition to their own parsing (or fold it in — see
133
+ * commands.mjs `parseFilters`).
134
+ */
135
+ export function parseTeamScopeFlags(args) {
136
+ const out = { allTeams: false, team: null };
137
+ for (let i = 0; i < args.length; i++) {
138
+ if (args[i] === '--all-teams') out.allTeams = true;
139
+ else if (args[i] === '--team') out.team = args[++i] ?? null;
140
+ }
141
+ return out;
142
+ }
@@ -0,0 +1,112 @@
1
+ // distill — CLI.
2
+ //
3
+ // Arg parsing (node:util.parseArgs, strict:true), verb routing,
4
+ // exit-code translation per §5–§6 of the tooling standard.
5
+
6
+ import { appendFile, mkdir } from 'node:fs/promises';
7
+ import { join } from 'node:path';
8
+ import { parseArgs } from 'node:util';
9
+
10
+ import { defaultRepoRoot } from './prereqs.mjs';
11
+ import { runDistill } from './run.mjs';
12
+ import { defaultRunner } from './runner.mjs';
13
+
14
+ const USAGE = `distill — librarian distillation sweep runner
15
+
16
+ Usage:
17
+ distill run Run a real distillation sweep
18
+ distill run --dry-run Print what would run, don't invoke claude
19
+ distill -h, --help Show this help
20
+
21
+ Exit codes:
22
+ 0 ok
23
+ 1 usage error
24
+ 2 prerequisite missing / operational failure
25
+ 3 claude / git transport failure
26
+
27
+ Source of truth for behaviour: @stravica-ai/engineering-pa-core/docs/tools/distill.md
28
+ `;
29
+
30
+ // Best-effort runs.jsonl write for the CLI-bootstrap failure path.
31
+ //
32
+ // runDistill() writes its own audit records on every documented exit
33
+ // branch via writeAudit() in run.mjs. This handler covers the residual
34
+ // gap: a *synchronous* throw before/around runDistill (a parseArgs
35
+ // strict-mode TypeError, an import surfaced as a runtime crash, a
36
+ // destructuring failure on a malformed argv, etc) — without it, the
37
+ // catch in main() would report to stderr and exit non-zero with no
38
+ // runs.jsonl entry, leaving a hole in the always-log invariant the
39
+ // freshness monitor depends on.
40
+ //
41
+ // Defensive on every step: best-effort path resolution, mkdir -p the
42
+ // logs dir, append. Any failure here is swallowed with a stderr note —
43
+ // losing the audit line is less bad than masking the real exit code.
44
+ async function writeBootstrapAudit({ err, exitCode, stderr }) {
45
+ try {
46
+ const repoRoot = await defaultRepoRoot();
47
+ if (!repoRoot) {
48
+ stderr.write(`[distill] warning: no repo root resolved; skipping bootstrap audit\n`);
49
+ return;
50
+ }
51
+ const logDir = join(repoRoot, '.cache/distill/logs');
52
+ const runsLog = join(logDir, 'runs.jsonl');
53
+ await mkdir(logDir, { recursive: true });
54
+ const record = {
55
+ ts: new Date().toISOString(),
56
+ status: 'fail-cli-bootstrap',
57
+ exitCode,
58
+ durationSec: 0,
59
+ stagingCount: null,
60
+ log: null,
61
+ reason: `cli bootstrap failure: ${err?.message || err}`,
62
+ };
63
+ await appendFile(runsLog, JSON.stringify(record) + '\n');
64
+ } catch (auditErr) {
65
+ stderr.write(`[distill] warning: failed to append bootstrap audit record: ${auditErr.message}\n`);
66
+ }
67
+ }
68
+
69
+ export async function main(
70
+ argv,
71
+ { stderr = process.stderr, exit = process.exit, audit = writeBootstrapAudit } = {},
72
+ ) {
73
+ try {
74
+ return await route(argv);
75
+ } catch (err) {
76
+ const code = err?.distillExitCode ?? 2;
77
+ stderr.write(`[distill] ${err.message || err}\n`);
78
+ await audit({ err, exitCode: code, stderr });
79
+ exit(code);
80
+ }
81
+ }
82
+
83
+ async function route(argv) {
84
+ if (argv.length === 0 || argv[0] === '-h' || argv[0] === '--help') {
85
+ process.stdout.write(USAGE);
86
+ process.exit(0);
87
+ }
88
+
89
+ const verb = argv[0];
90
+ const rest = argv.slice(1);
91
+
92
+ if (verb === 'run') {
93
+ const { values } = parseArgs({
94
+ args: rest,
95
+ options: {
96
+ 'dry-run': { type: 'boolean', default: false },
97
+ help: { type: 'boolean', short: 'h', default: false },
98
+ },
99
+ strict: true,
100
+ });
101
+ if (values.help) {
102
+ process.stdout.write(USAGE);
103
+ process.exit(0);
104
+ }
105
+ const code = await runDistill({ dryRun: values['dry-run'], runner: defaultRunner });
106
+ process.exit(code ?? 0);
107
+ }
108
+
109
+ process.stderr.write(`[distill] unknown command: ${verb}\n`);
110
+ process.stderr.write(USAGE);
111
+ process.exit(1);
112
+ }
@@ -0,0 +1,171 @@
1
+ // distill — prerequisite resolution.
2
+ //
3
+ // Locates the operator repo root, reads the PA name from preferences, validates
4
+ // the librarian role definition and the claude binary exist. Throws errors
5
+ // carrying `distillExitCode` so the CLI maps to the correct exit code (§6 of
6
+ // the tooling standard: 1 usage, 2 operational).
7
+ //
8
+ // In v2 the platform is installed as the `@stravica-ai/engineering-pa-core`
9
+ // package inside the operator repo. The librarian definition is bundled with
10
+ // the package (this same module's tree), and the log directory lives inside
11
+ // the operator repo at `.cache/distill/` (gitignored — §16 of the standard).
12
+ //
13
+ // Repo-root discovery (in order):
14
+ // 1. opts.repoRoot — explicit caller override (used by tests).
15
+ // 2. process.env.DAVE_REPO_ROOT / PA_REPO_ROOT — operator override.
16
+ // 3. `.git`-walk upwards from process.cwd().
17
+
18
+ import { access, readFile, mkdir, stat } from 'node:fs/promises';
19
+ import { constants as fsConstants } from 'node:fs';
20
+ import { dirname, join, resolve } from 'node:path';
21
+ import { fileURLToPath } from 'node:url';
22
+
23
+ const __dirname = dirname(fileURLToPath(import.meta.url));
24
+
25
+ // The package's bundled librarian definition. From this module
26
+ // (`packages/core/src/distill/prereqs.mjs`) the file lives at
27
+ // `../../roles/librarian/definition.md` — i.e. inside the same package tree.
28
+ export const BUNDLED_LIBRARIAN_DEF = resolve(__dirname, '..', '..', 'roles', 'librarian', 'definition.md');
29
+
30
+ async function pathKind(p) {
31
+ try {
32
+ const s = await stat(p);
33
+ if (s.isDirectory()) return 'dir';
34
+ if (s.isFile()) return 'file';
35
+ return 'other';
36
+ } catch {
37
+ return 'missing';
38
+ }
39
+ }
40
+
41
+ export async function findRepoRoot(start) {
42
+ let d = start;
43
+ while (d && d !== dirname(d)) {
44
+ const kind = await pathKind(join(d, '.git'));
45
+ if (kind === 'dir' || kind === 'file') return d;
46
+ d = dirname(d);
47
+ }
48
+ return null;
49
+ }
50
+
51
+ /**
52
+ * Best-effort repo-root discovery. Returns null if nothing is found; callers
53
+ * decide whether that is a usage error or an operational error.
54
+ */
55
+ export async function defaultRepoRoot() {
56
+ const envRoot = process.env.DAVE_REPO_ROOT || process.env.PA_REPO_ROOT;
57
+ if (envRoot) return resolve(envRoot);
58
+ return await findRepoRoot(process.cwd());
59
+ }
60
+
61
+ export async function exists(path) {
62
+ try {
63
+ await access(path, fsConstants.F_OK);
64
+ return true;
65
+ } catch {
66
+ return false;
67
+ }
68
+ }
69
+
70
+ function opError(msg) {
71
+ const err = new Error(msg);
72
+ err.distillExitCode = 2;
73
+ return err;
74
+ }
75
+
76
+ export async function resolvePrereqs({
77
+ repoRoot,
78
+ librarianDef,
79
+ which = defaultWhich,
80
+ } = {}) {
81
+ const root = repoRoot || (await defaultRepoRoot());
82
+ if (!root) {
83
+ throw opError('could not find repo root (no .git ancestor; set DAVE_REPO_ROOT or PA_REPO_ROOT)');
84
+ }
85
+ if (!(await exists(join(root, '.git')))) {
86
+ throw opError(`could not find repo root at ${root}`);
87
+ }
88
+
89
+ const prefsFile = join(root, 'operator/config/preferences.json');
90
+ if (!(await exists(prefsFile))) {
91
+ throw opError(`missing preferences at ${prefsFile}`);
92
+ }
93
+
94
+ let prefs;
95
+ try {
96
+ prefs = JSON.parse(await readFile(prefsFile, 'utf8'));
97
+ } catch (err) {
98
+ throw opError(`failed to parse preferences at ${prefsFile}: ${err.message}`);
99
+ }
100
+
101
+ const paName = prefs.paName;
102
+ if (!paName || typeof paName !== 'string') {
103
+ throw opError(`no paName configured in ${prefsFile}`);
104
+ }
105
+
106
+ // Librarian definition resolution (highest precedence first):
107
+ // 1. explicit opts.librarianDef (tests pass a fixture path here) —
108
+ // the caller controls the whole prompt; no supplement is applied;
109
+ // 2. full operator override at
110
+ // operator/extensions/roles/librarian/definition.md — the operator
111
+ // has taken ownership of the whole prompt; no supplement is applied
112
+ // even if overrides.md also exists (back-compat with pre-supplement
113
+ // operator repos is byte-for-byte);
114
+ // 3. bundled definition + operator supplement at
115
+ // operator/extensions/roles/librarian/overrides.md — run.mjs appends
116
+ // the supplement after the bundled definition with an explicit
117
+ // operator-wins precedence statement;
118
+ // 4. bundled definition alone (BUNDLED_LIBRARIAN_DEF).
119
+ //
120
+ // This module resolves *paths* only; reading and composing the content
121
+ // is run.mjs's job. `librarianSupplement` is null for outcomes 1, 2, 4.
122
+ let resolvedLibrarianDef;
123
+ let resolvedLibrarianSupplement = null;
124
+ if (librarianDef) {
125
+ resolvedLibrarianDef = librarianDef;
126
+ } else {
127
+ const operatorOverride = join(root, 'operator/extensions/roles/librarian/definition.md');
128
+ if (await exists(operatorOverride)) {
129
+ resolvedLibrarianDef = operatorOverride;
130
+ } else {
131
+ resolvedLibrarianDef = BUNDLED_LIBRARIAN_DEF;
132
+ const operatorSupplement = join(root, 'operator/extensions/roles/librarian/overrides.md');
133
+ if (await exists(operatorSupplement)) {
134
+ resolvedLibrarianSupplement = operatorSupplement;
135
+ }
136
+ }
137
+ }
138
+ if (!(await exists(resolvedLibrarianDef))) {
139
+ throw opError(`missing librarian definition at ${resolvedLibrarianDef}`);
140
+ }
141
+
142
+ // Log directory in the operator repo, gitignored per the tooling standard §16.
143
+ const logDir = join(root, '.cache/distill/logs');
144
+ await mkdir(logDir, { recursive: true });
145
+
146
+ if (!(await which('claude'))) {
147
+ throw opError('claude binary not on PATH');
148
+ }
149
+
150
+ return {
151
+ repoRoot: root,
152
+ paName,
153
+ librarianDef: resolvedLibrarianDef,
154
+ librarianSupplement: resolvedLibrarianSupplement,
155
+ logDir,
156
+ runsLog: join(logDir, 'runs.jsonl'),
157
+ };
158
+ }
159
+
160
+ async function defaultWhich(binary) {
161
+ const PATH = process.env.PATH || '';
162
+ const sep = process.platform === 'win32' ? ';' : ':';
163
+ const exts = process.platform === 'win32' ? (process.env.PATHEXT || '.EXE;.CMD;.BAT').split(';') : [''];
164
+ for (const dir of PATH.split(sep)) {
165
+ if (!dir) continue;
166
+ for (const ext of exts) {
167
+ if (await exists(join(dir, binary + ext))) return true;
168
+ }
169
+ }
170
+ return false;
171
+ }
@@ -0,0 +1,74 @@
1
+ // distill — prompt assembly. Pure string building; no I/O.
2
+ //
3
+ // The DISTILL_PROMPT instructs the librarian session to rebuild retrieval
4
+ // indexes after promoting observations. In v2 the retrieval tools ship inside
5
+ // the `@stravica-ai/engineering-pa-core` package, not at `core/knowledge/retrieval/`
6
+ // in the operator repo. Concrete absolute paths are computed at runtime so
7
+ // Claude invokes the correct binaries from inside its session.
8
+
9
+ import { dirname, resolve } from 'node:path';
10
+ import { fileURLToPath } from 'node:url';
11
+
12
+ const __dirname = dirname(fileURLToPath(import.meta.url));
13
+
14
+ // Absolute paths to the bundled retrieval tools. From this module
15
+ // (`packages/core/src/distill/prompt.mjs`) the retrieval tools live at
16
+ // `../knowledge/retrieval/`.
17
+ export const RETRIEVAL_INDEX_BUILDER = resolve(__dirname, '..', 'knowledge', 'retrieval', 'index-builder.mjs');
18
+ export const RETRIEVAL_BACKLINK_INDEXER = resolve(__dirname, '..', 'knowledge', 'retrieval', 'backlink-indexer.mjs');
19
+ export const RETRIEVAL_GRAPH_BUILDER = resolve(__dirname, '..', 'knowledge', 'retrieval', 'graph-builder.mjs');
20
+
21
+ /**
22
+ * Build the distillation prompt text. Absolute paths are interpolated for the
23
+ * retrieval-tool invocations so Claude doesn't have to guess at install
24
+ * locations.
25
+ */
26
+ export function buildDistillPrompt({
27
+ indexBuilder = RETRIEVAL_INDEX_BUILDER,
28
+ backlinkIndexer = RETRIEVAL_BACKLINK_INDEXER,
29
+ graphBuilder = RETRIEVAL_GRAPH_BUILDER,
30
+ } = {}) {
31
+ return `You are operating as the Librarian. Run a full distillation sweep now.
32
+
33
+ ## Instructions
34
+
35
+ 1. **Scan all staging areas.** Process every markdown file in agents/*/staging/ (skip _archived/).
36
+
37
+ 2. **Extract durable knowledge.** For each observation:
38
+ - If it reveals something about the operator: update operator/profile/operator.json
39
+ - If it belongs in a knowledge domain: file it into operator/knowledge/ under the appropriate domain
40
+ - If it captures a reusable pattern or decision: ensure it is recorded
41
+
42
+ 3. **Synthesise the operator profile narrative.** After updating operator/profile/operator.json, regenerate operator/profile/profile.md as a human-readable markdown narrative derived from the JSON plus the body of accumulated observations. This is the file the workspace and PA read first; it must always exist and reflect current state. Replace it in full each run — it is a derived artefact, not an append log.
43
+
44
+ 4. **Rebuild indexes.** After all content changes, run these in order:
45
+ - node ${indexBuilder}
46
+ - node ${backlinkIndexer}
47
+ - node ${graphBuilder}
48
+
49
+ 5. **Library hygiene check.** Per your role definition — verify JSON camelCase, cross-reference integrity, index completeness, and lastUpdated freshness. Fix violations in place.
50
+
51
+ 6. **Archive processed observations.** Move each processed staging file to agents/{agent}/staging/_archived/ (create the directory if needed).
52
+
53
+ 7. **Report.** Summarise what was processed, what was promoted, what was archived, and any hygiene findings.`;
54
+ }
55
+
56
+ /**
57
+ * Back-compat constant: the prompt assembled with default (bundled) paths.
58
+ * Existing consumers that import DISTILL_PROMPT keep working; new callers
59
+ * should use buildDistillPrompt() with explicit overrides where needed.
60
+ */
61
+ export const DISTILL_PROMPT = buildDistillPrompt();
62
+
63
+ export function claudeArgs({ sessionName, librarianDef, prompt = DISTILL_PROMPT }) {
64
+ // Positional prompt last. No shell interpolation — this array is
65
+ // handed directly to child_process.spawn.
66
+ return [
67
+ '--print',
68
+ '--permission-mode', 'bypassPermissions',
69
+ '--no-session-persistence',
70
+ '--name', sessionName,
71
+ '--append-system-prompt', librarianDef,
72
+ prompt,
73
+ ];
74
+ }