@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,82 @@
1
+ # Build Spec — {Build Name}
2
+
3
+ **Build id:** `{build-id}` (slug; matches `projects/{build-id}/`)
4
+ **Operator:** {operator-name}
5
+ **PA instance:** {pa-name}
6
+ **Spec author:** {operator | PA-name-and-role} — {date}
7
+ **Status:** `{draft | ready-for-preflight | approved | building | done}`
8
+
9
+ > **How to use this template.** This is the single entry-point document for a product-engineer build. It may link to other docs (research, mockups, related projects) but this file is the canonical source of truth for what's being built. Either the operator writes this directly, or the PA produces it from a discussion with the operator. Either way, it lands here before the Product Engineer is invoked.
10
+ >
11
+ > Delete these blockquote instructions before saving.
12
+
13
+ ---
14
+
15
+ ## Summary
16
+
17
+ > One to two paragraphs. What is being built, for whom, why now. Written so someone with no prior context can decide in ninety seconds whether they care.
18
+
19
+ ## Functional requirements
20
+
21
+ > Numbered, testable, un-ambiguous. Each is a checkable claim — "the user can X," "the system Y's when Z." Not design decisions, not implementation hints — just what the thing does.
22
+
23
+ 1. ...
24
+ 2. ...
25
+ 3. ...
26
+
27
+ ## Non-functional requirements
28
+
29
+ > Performance, security, accessibility, durability, observability — whichever apply. Leave sections out that genuinely don't apply; don't fill with boilerplate.
30
+
31
+ - **Performance:** ...
32
+ - **Security:** ...
33
+ - **Accessibility:** ...
34
+ - **Observability:** ...
35
+ - **Reliability:** ...
36
+
37
+ ## Success criteria
38
+
39
+ > How we know it works. Restate the important functional + non-functional requirements as *measurable* checks. Each criterion is a test the Product Engineer's Stage 5 review walks through.
40
+
41
+ - [ ] ...
42
+ - [ ] ...
43
+ - [ ] ...
44
+
45
+ ## Out of scope
46
+
47
+ > Anything the operator has considered and deliberately left for later. Naming the exclusion here is how the Product Engineer avoids scope creep without a second approval round.
48
+
49
+ - ...
50
+ - ...
51
+
52
+ ## Constraints
53
+
54
+ > Hard limits the build must respect. Budget, deadline, infrastructure, approved third-party services, banned dependencies, data residency, etc.
55
+
56
+ - ...
57
+ - ...
58
+
59
+ ## Stack note (optional)
60
+
61
+ > If the operator has a strong preference away from the default stack (Node / Fastify / SvelteKit / SQLite-or-Postgres / node:test + Playwright / Docker / GitHub Actions), note it here with a one-line reason. Absent this section, the Product Engineer uses the default stack.
62
+
63
+ - ...
64
+
65
+ ## Deployment note
66
+
67
+ > Where the finished build goes beyond local Docker. This is *out of the Product Engineer's scope*, but flagging it here helps the PA plan the handoff. "Local only, for operator's personal use" is a valid answer.
68
+
69
+ - ...
70
+
71
+ ## Related documents
72
+
73
+ > Links to related projects, research notes, prior discussions, mockups. Each link has a one-line description so the reader knows whether to follow it.
74
+
75
+ - [...](path) — ...
76
+
77
+ ## Operator preferences relevant to this build
78
+
79
+ > The PA extracts and pastes the operator-profile/memory items that actually bear on this build. **Not** the full operator profile. Just what's relevant. This is where the Product Engineer learns "this operator prefers minimalistic UI" or "this operator's firm rule is never mock databases."
80
+
81
+ - ...
82
+ - ...
@@ -0,0 +1,158 @@
1
+ # Preflight Checklist — {Build Name}
2
+
3
+ **Build id:** `{build-id}`
4
+ **Build spec:** [`projects/{build-id}/build-spec.md`](./build-spec.md)
5
+ **Design doc:** [`projects/{build-id}/design-doc.md`](./design-doc.md)
6
+ **Product Engineer:** {agent-name-or-id}
7
+ **Issued:** {date}
8
+ **Status:** `{pending-approval | approved | changes-requested | rejected}`
9
+
10
+ > **Operator, this is the last point of contact until demo.** Review every section below. If every item accurately reflects what you want built, approve. If anything is wrong, reject or request changes. Once you approve, the Product Engineer proceeds to build, test, and demo without further interaction unless something locked here proves wrong in practice.
11
+ >
12
+ > The Product Engineer has done the thinking; your job here is to confirm (or course-correct).
13
+
14
+ ---
15
+
16
+ ## 1. What we're building
17
+
18
+ > One paragraph, in plain operator-facing language. Restated from the build-spec summary — not reinterpreted.
19
+
20
+ ...
21
+
22
+ ## 2. Stack decisions
23
+
24
+ > Default stack is Node.js + Fastify + SvelteKit + SQLite-then-Postgres + node:test + Playwright + Docker + GitHub Actions. Any deviation is listed below with a one-line reason.
25
+
26
+ **Using default:** _yes | no (see deviations)_
27
+
28
+ **Deviations:**
29
+
30
+ | Layer | Default | Chosen | Reason |
31
+ |---|---|---|---|
32
+ | ... | ... | ... | ... |
33
+
34
+ ## 3. Architecture sketch
35
+
36
+ > Services, data flow, integration points. ASCII diagram or bullet list — whichever reads clearer. Should fit on one screen.
37
+
38
+ ...
39
+
40
+ ## 4. Data model
41
+
42
+ > Entities, key fields, relationships. Just enough to show the shape.
43
+
44
+ ...
45
+
46
+ ## 5. API surface
47
+
48
+ > Endpoints the build will expose. Routes, methods, purpose. Not full OpenAPI — just the surface.
49
+
50
+ | Method | Path | Purpose |
51
+ |---|---|---|
52
+ | ... | ... | ... |
53
+
54
+ ## 6. UX sketch (if UI)
55
+
56
+ > Screens, main flows, styling approach. Can reference external mockups.
57
+ >
58
+ > **Minimum content (when there is a UI):** list each screen by name + one-line purpose; text-wireframe the main form/layout of each; show the flow arrows between screens; name the styling approach (e.g. "plain CSS, system font stack, one accent colour"). Don't go beyond text-wireframes unless the build-spec specifically asks for design mockups — full UI mocks are a different artefact and belong outside the preflight if used.
59
+ >
60
+ > **When there is no UI** (API-only, CLI, scheduled task): delete this whole section — don't leave it empty.
61
+
62
+ ...
63
+
64
+ ## 7. Test plan
65
+
66
+ - **Unit tests:** _what kinds of tests at what depth_
67
+ - **Integration tests:** _real DB — no mocks; what flows are covered_
68
+ - **E2E tests (Playwright, if UI):** _what user journeys_
69
+ - **Security scan:** _npm audit + any deeper scans_
70
+ - **CI coverage:** _what runs in GitHub Actions_
71
+
72
+ ## 8. Repository plan
73
+
74
+ - **Organisation / account:** `{org-or-account}` ← **operator confirms at invocation**
75
+ - **Repository name:** `{repo-name}`
76
+ - **Visibility:** `{private | public}` (default private)
77
+ - **Default branch:** `main`
78
+ - **Branching strategy:** `{feature-branch-PR | direct-to-main-for-scaffold}`
79
+
80
+ ## 9. Deployment plan (local scope only)
81
+
82
+ > **These three bullets are boilerplate you keep verbatim in most builds.** The "local Docker only" scope ceiling is a role-level rule (not a build choice), so the third bullet should appear unchanged in almost every preflight. Don't delete or soften it unless there's a genuinely new scope decision you're making.
83
+
84
+ - **Container:** Docker multi-stage, distroless runtime (distroless-nonroot when writing to a volume — see role spec Stage 3 Dockerfile snippet)
85
+ - **Local run command:** `docker compose up` or `docker run ...` (exact command in build summary at Stage 6)
86
+ - **Production deployment:** **OUT OF SCOPE** — handed back to PA for per-instance deployment routing
87
+
88
+ ## 10. Secrets plan
89
+
90
+ - **What the app needs:** _list of env vars_
91
+ - **Local sourcing:** `.env` (in `.gitignore` from commit one)
92
+ - **CI sourcing:** GitHub Actions repo secrets
93
+ - **Production sourcing:** operator's PA instance (out of scope here — flagged for PA)
94
+
95
+ ## 11. Success criteria
96
+
97
+ > Restated from the build-spec as measurable checks the Product Engineer will self-verify at Stage 5 Review before declaring done.
98
+
99
+ - [ ] ...
100
+ - [ ] ...
101
+ - [ ] ...
102
+
103
+ ## 12. Risks and trade-offs
104
+
105
+ > Anything the Product Engineer wants the operator to knowingly accept before building.
106
+
107
+ - **Risk:** ... → **Mitigation:** ...
108
+ - **Trade-off:** ...
109
+
110
+ ## 13. What we're explicitly NOT doing in this build
111
+
112
+ > Called out so the operator doesn't expect it at demo.
113
+
114
+ - ...
115
+ - ...
116
+
117
+ ---
118
+
119
+ ## Operator approval
120
+
121
+ > **Iteration protocol.** This section reflects the **current iteration only** — rewrite it in place each time the preflight cycles. The full audit trail (who decided what, when, with what words) is preserved in the Approval log table below. This keeps the top-of-section unambiguous while still guaranteeing a complete history.
122
+
123
+ **Operator:** _{operator-name}_
124
+
125
+ > **Stand-in approvers** are valid for pilot protocol or operator-absent cases. Use the form: `{operator-name} (via operator-stand-in: {pa-name}, {role} — {reason})`. The approval is still binding on the operator; the stand-in is acting under delegated authority.
126
+
127
+ - [ ] Stack decisions correct
128
+ - [ ] Architecture matches intent
129
+ - [ ] API surface correct
130
+ - [ ] Test plan sufficient
131
+ - [ ] Repository plan correct (org, name, visibility)
132
+ - [ ] Success criteria accurately reflect "done"
133
+ - [ ] Out-of-scope list is accurate
134
+ - [ ] Risks are acceptable
135
+
136
+ **Decision:** _approve | request-changes | reject_
137
+
138
+ **Approval phrase (verbatim from operator):** _"..."_
139
+
140
+ **Timestamp:** _{date}T{time}Z_
141
+
142
+ ---
143
+
144
+ ## Changes requested (if any)
145
+
146
+ > **On the first issue of the preflight, leave this section at `_(none yet)_`** — the Operator either approves outright, or populates this section with a numbered list and sets Decision to `request-changes`. The Product Engineer then updates the design-doc and this checklist per the list, resets Status to `pending-approval`, and re-presents. Cycle until aligned.
147
+
148
+ - _(none yet)_
149
+
150
+ ---
151
+
152
+ ## Approval log
153
+
154
+ > Every approval cycle (initial, re-approval after changes) gets a line here. This table is append-only and preserves the full history across iterations — whereas the Operator-approval block above is rewritten per iteration.
155
+
156
+ | Iteration | Date | Decision | Approval phrase |
157
+ |---|---|---|---|
158
+ | 1 | ... | ... | ... |
@@ -0,0 +1,130 @@
1
+ # Worker Brief — {task-name}
2
+
3
+ > **Specialised briefing contract for Product Engineer → Worker dispatches during a build.** Extends the 8-section briefing contract at [`core/knowledge/standards/briefing-contract.md`](../../../knowledge/standards/briefing-contract.md) with product-engineer-specific sections. Every field is mandatory — if you can't fill one, do not dispatch. Fall back to in-thread execution instead.
4
+
5
+ **Build id:** `{build-id}`
6
+ **Build repository:** `{owner}/{repo}`
7
+ **Branch:** `{branch-name}`
8
+ **Dispatched by:** {product-engineer-agent-id}
9
+ **Worker id (for spawn-log):** `{d-YYYY-MM-DD-NNN}`
10
+ **Isolation:** `{none | worktree}`
11
+ **Parallel or sequential:** `{single | part-of-task-group-{group-id}}`
12
+
13
+ ---
14
+
15
+ ## Goal
16
+
17
+ > One sentence. Outcome-shaped. What success looks like.
18
+
19
+ ...
20
+
21
+ ## Trace — why we're doing this
22
+
23
+ > **Mandatory. Three to six sentences.** Explain why this slice exists, what decisions have already been made, what alternatives have been ruled out. The worker reads this before doing anything else. If this field is shallow, the integration step will be painful.
24
+
25
+ > If part of a task group, this trace summarises the *worker-specific* reasoning; the broader trace lives in `projects/{build-id}/group-context/trace.md` and is read by every worker.
26
+
27
+ ...
28
+
29
+ ## Context
30
+
31
+ > The "what" — paths, files, decisions already made. Extracted and tailored for this worker, never the full operator profile or full build-spec.
32
+
33
+ **Build spec:** `projects/{build-id}/build-spec.md` — **read before starting**
34
+ **Design doc:** `projects/{build-id}/design-doc.md` — **read before starting**
35
+ **Preflight (approved):** `projects/{build-id}/preflight-checklist.md`
36
+ **Shared context store (if task group):** `projects/{build-id}/group-context/`
37
+
38
+ **Files the worker touches:**
39
+ - `...`
40
+ - `...`
41
+
42
+ **Files the worker may READ but NOT WRITE:**
43
+ - `...`
44
+
45
+ **Decisions already locked (do not re-open):**
46
+ - ...
47
+
48
+ ## Tools and sources
49
+
50
+ > Which tools to use, which to avoid, where to find information.
51
+
52
+ **Tools:** `{Read, Write, Edit, Bash, Playwright, etc. — be explicit}`
53
+
54
+ **Standards to read (not paraphrase):**
55
+ - `core/knowledge/standards/briefing-contract.md` — the brief contract this dispatch uses
56
+ - `core/knowledge/standards/tooling.md` — if the worker writes any internal tooling
57
+ - `core/roles/product-engineer/definition.md` — the role this dispatch operates under
58
+ - _Additional standards specific to this slice: ..._
59
+
60
+ **Operator memories relevant to this slice** (PA extracts from `operator/memory/`):
61
+ - ...
62
+ - ...
63
+
64
+ **Must NOT touch:**
65
+ - Any file outside the build's repository
66
+ - The PA instance's `operator/`, `agents/`, `work/`, `projects/` (except this build's own project folder where explicitly authorised)
67
+
68
+ ## Boundaries
69
+
70
+ **In scope for this worker:**
71
+ - ...
72
+
73
+ **Out of scope for this worker:**
74
+ - ...
75
+
76
+ **Decision authority:**
77
+ - **Decide alone:** implementation details inside the scoped files, naming, test layout
78
+ - **Decide and log:** any deviation from the design-doc for this slice
79
+ - **Must escalate to orchestrator (Product Engineer):** anything outside scope, anything affecting other workers, any spec change
80
+
81
+ ## Output format
82
+
83
+ > Exactly what the worker returns to the orchestrator.
84
+
85
+ **Files to create / modify:**
86
+ - `...`
87
+
88
+ **Tests to pass:**
89
+ - `...`
90
+
91
+ **Artefacts:**
92
+ - _A short return summary in the agent response_
93
+ - _A commit (or commits) on the named branch with conventional-commit messages_
94
+ - _If part of a task group, a decision log entry at `projects/{build-id}/group-context/decisions.md`_
95
+
96
+ **Length cap on return summary:** under 200 words unless something specific requires more.
97
+
98
+ ## Done when
99
+
100
+ > Concrete, self-checkable acceptance criteria. "Tests pass" alone is not enough — name the tests, the invocation, the expected output.
101
+
102
+ - [ ] Files listed above exist and implement the goal
103
+ - [ ] `npm test` (or equivalent) passes on the branch
104
+ - [ ] `npm run build` (if applicable) passes
105
+ - [ ] Linter / typechecker (`npm run check` or equivalent) passes
106
+ - [ ] Commit(s) pushed to `{branch-name}`
107
+ - [ ] Spawn-log entry for this worker recorded by orchestrator at dispatch time (orchestrator's responsibility, noted here for audit)
108
+ - [ ] Return summary submitted
109
+
110
+ ## Escalation rule
111
+
112
+ > Default: **if any field in this brief is unclear or you encounter a constraint not covered here, stop and report the question rather than guessing.**
113
+
114
+ **This dispatch's specific escalation rules:**
115
+ - If the build-spec, design-doc, or preflight conflict with this brief, stop — the orchestrator made a mistake. Report it.
116
+ - If the design-doc is missing information you need to implement the slice, stop. Do not guess the design.
117
+ - If an external resource (dependency, API, service) is unavailable, stop. Do not synthesise a workaround without telling the orchestrator.
118
+ - If your slice touches files another worker in this task group is writing, stop. Coordination flows through the orchestrator, not between workers.
119
+
120
+ **Do not communicate with other workers directly.** If coordination is needed, append to the shared context store at `projects/{build-id}/group-context/coordination.md` and return control to the orchestrator.
121
+
122
+ ---
123
+
124
+ ## Worktree notes (if isolation: worktree)
125
+
126
+ > When this brief sets `isolation: worktree`, the following MUST be honoured verbatim by the worker:
127
+
128
+ **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.
129
+
130
+ **Worktree absolute-path rule:** Every absolute path passed to Write, Edit, MultiEdit, or Bash (for writes) MUST begin with the worktree root. Writing to main-worktree absolute paths is forbidden.
@@ -0,0 +1,197 @@
1
+ # Workspace Server CLI (`ws.mjs`)
2
+
3
+ Manages the workspace dev server (`server.mjs`) as a background process. Cross-platform (macOS, Linux, Windows), zero npm dependencies.
4
+
5
+ For installing the server as an always-on supervised daemon (launchd / systemd), see [`DAEMON.md`](./DAEMON.md).
6
+
7
+ ## Usage
8
+
9
+ ```bash
10
+ node ws.mjs start [--port N] [--no-open] # Start server as background daemon
11
+ node ws.mjs stop # Stop the running server
12
+ node ws.mjs restart [--port N] [--no-open] # Stop then start
13
+ node ws.mjs status # Show server status (PID, port, uptime, health)
14
+ node ws.mjs open # Open browser to server URL
15
+ ```
16
+
17
+ ## Port resolution
18
+
19
+ The port is resolved in this order (last wins):
20
+
21
+ 1. Default: `4200`
22
+ 2. `operator/config/preferences.json` key `workspacePort`
23
+ 3. `--port` CLI flag
24
+
25
+ ## Files
26
+
27
+ | File | Purpose |
28
+ |---|---|
29
+ | `.ws.pid` | PID + port tracking (repo root). JSON: `{ "pid": N, "port": N }` |
30
+ | `.ws.log` | Server stdout/stderr (repo root). Overwritten on each `start`. |
31
+
32
+ Both files are gitignored artifacts. They live in the repo root for easy discovery.
33
+
34
+ ## Commands
35
+
36
+ ### `start`
37
+
38
+ 1. Checks if the server is already running (PID file + process check + port check). If so, prints the URL and exits.
39
+ 2. Recovers from bad states (see table below) or reports them with a one-line fix.
40
+ 3. Spawns `server.mjs` detached with `--no-timeout` (background servers should not auto-shutdown) and `--no-open` (the CLI handles browser opening).
41
+ 4. Writes `.ws.pid`.
42
+ 5. Waits up to 3 seconds for the port to become available, then prints the URL.
43
+ 6. Opens the browser unless `--no-open` is passed.
44
+
45
+ #### Bad-state matrix (on `start`)
46
+
47
+ | PID file | Port | Behaviour |
48
+ |---|---|---|
49
+ | exists, PID alive, port up | — | Already running — print URL, exit 0. |
50
+ | exists, PID alive, port down | — | Stale process. Kill it, clean up, then spawn. |
51
+ | exists, PID dead, port free | — | Clean up pidfile, spawn fresh. |
52
+ | exists, PID dead, port busy | — | Unverifiable port holder. Print diagnostic with the holder's PID/command and a recovery one-liner, exit 1. Never kills a process we cannot prove we started. |
53
+ | missing, port free | — | Spawn fresh. |
54
+ | missing, port busy | — | Print diagnostic with holder PID, exit 1. |
55
+
56
+ On platforms where `lsof` (macOS/Linux) or `netstat` (Windows) is unavailable the holder lookup is skipped and the diagnostic falls back to suggesting manual investigation.
57
+
58
+ ### `stop`
59
+
60
+ 1. Reads `.ws.pid`. If missing or process dead, prints "not running" and exits 0.
61
+ 2. Sends SIGTERM (or `taskkill` on Windows). Waits up to 5 seconds.
62
+ 3. If still alive, sends SIGKILL (or `taskkill /F`).
63
+ 4. Cleans up `.ws.pid`.
64
+
65
+ ### `restart`
66
+
67
+ When a supervisor (launchd / systemd) is installed, asks the supervisor to bounce the service:
68
+
69
+ - **launchd:** `launchctl kickstart -k gui/$UID/com.dave.workspace`
70
+ - **systemd:** `systemctl --user restart dave-workspace.service`
71
+
72
+ This is the **safe way to pick up an in-place version change** (e.g. after `pnpm update`). `stop` then `start` would race the supervisor's KeepAlive / Restart=always and fail with "Port already in use".
73
+
74
+ Without a supervisor, falls back to `stop` then `start`.
75
+
76
+ ### `status`
77
+
78
+ Prints supervisor-aware status:
79
+
80
+ - **Without supervisor** — running/stopped, PID, port, uptime (from PID file mtime), URL, HTTP health.
81
+ - **With supervisor** — supervisor kind (launchd / systemd), unit/plist path, supervisor state (`running` / `loaded` / `inactive`), supervised PID, port, port listener PID (via `lsof` / `ss` / `netstat`), URL, HTTP health.
82
+
83
+ The supervisor-aware path bypasses the pidfile entirely — a launchd / systemd-managed process is invisible to the legacy pidfile check.
84
+
85
+ ## Supervisor awareness
86
+
87
+ If a launchd plist at `~/Library/LaunchAgents/com.dave.workspace.plist` (macOS) or a systemd unit at `~/.config/systemd/user/dave-workspace.service` (Linux) is present, ws.mjs switches into supervisor-aware mode:
88
+
89
+ | Verb | Supervisor present | Behaviour |
90
+ |---|---|---|
91
+ | `start` | yes, running | "Already running (supervised by X, PID N)" — exit 0. Does NOT spawn a detached process. |
92
+ | `start` | yes, not running | Refuses to spawn; tells the operator how to bring the service up via the supervisor. |
93
+ | `stop` | yes | Refuses with a helpful message — `kill <pid>` triggers KeepAlive instant respawn. Exit 1. |
94
+ | `restart` | yes | Delegates to `launchctl kickstart -k` / `systemctl --user restart`. |
95
+ | `status` | yes | Reports supervisor state + port-listener PID, ignoring the pidfile. |
96
+ | `open` | yes | Resolves the port via prefs and opens the URL; no pidfile lookup. |
97
+
98
+ Detection is purely file-existence: a unit file alone activates the supervisor path. Whether the unit is loaded is reported as `state`. Cross-platform parity is guarded by tests — a launchd plist on Linux (or a systemd unit on macOS) is ignored.
99
+
100
+ **Test-only env var:** `WORKSPACE_SUPERVISOR_PLATFORM_OVERRIDE` forces `ws.mjs` to treat the host as the named platform (`darwin` / `linux` / `win32`) when probing for a supervisor. This is how the e2e suite exercises both supervisor branches from any host — launchd behaviour can be asserted on Linux CI and systemd behaviour on macOS dev boxes. Unset in production; honoured only by `detectSupervisor`'s existing dependency-injection contract.
101
+
102
+ ### `open`
103
+
104
+ Opens the server URL in the default browser. Errors if the server is not running.
105
+
106
+ ## Extension mechanism
107
+
108
+ Operator forks can layer pages and API routes over the core app without forking `server.mjs`.
109
+
110
+ ### Static page overlay
111
+
112
+ Place HTML files in `operator/extensions/workspace/`. The server checks that directory before `core/tools/workspace/app/`, so any same-named file there takes precedence. No config required — the directory's presence activates the overlay.
113
+
114
+ ```
115
+ operator/extensions/workspace/home.html → overrides core home.html
116
+ operator/extensions/workspace/mypage.html → served at /mypage.html
117
+ ```
118
+
119
+ ### Additional API routes
120
+
121
+ If `operator/extensions/workspace/api.mjs` exists, the server imports it at startup and calls its `register(addRoute)` export. Use `addRoute(method, pathname, handler)` to register routes. Routes registered here shadow same-method+pathname core routes (logged at startup).
122
+
123
+ ```js
124
+ // operator/extensions/workspace/api.mjs
125
+ export function register(addRoute) {
126
+ addRoute('GET', '/__api/my-data', (req, res, url, repoRoot) => {
127
+ res.writeHead(200, { 'Content-Type': 'application/json' });
128
+ res.end(JSON.stringify({ ok: true }));
129
+ });
130
+ }
131
+ ```
132
+
133
+ ### Nav registration
134
+
135
+ The main sidebar is driven by a declarative manifest rather than hard-coded markup. This lets extensions surface new pages in the nav without shadowing `index.html`.
136
+
137
+ **Core manifest:** `core/tools/workspace/app/nav.json` defines the built-in entries.
138
+
139
+ **Extension manifest (optional):** `operator/extensions/workspace/nav.json`. Same shape, merged after core. Missing file is not an error.
140
+
141
+ **Shape:**
142
+
143
+ ```json
144
+ [
145
+ {
146
+ "id": "mypage",
147
+ "label": "My Page",
148
+ "href": "/mypage.html",
149
+ "section": "Extensions"
150
+ }
151
+ ]
152
+ ```
153
+
154
+ | Field | Required | Purpose |
155
+ |---|---|---|
156
+ | `id` | yes | Drives the sidebar DOM id `nav-<id>` and the internal NAV_MAP key. Must be unique within the merged manifest — extension items with a core id replace the core entry in place (warning logged). |
157
+ | `label` | yes | Sidebar text and breadcrumb label. |
158
+ | `href` | yes | Navigation target. Extension pages typically use `/<name>.html`; core pages use `/core/tools/workspace/app/<name>.html`. |
159
+ | `section` | no | Section header. Defaults to `Navigation`. Any other string creates a new section appended after the core sections (in manifest order). |
160
+ | `aliases` | no | Additional paths that should highlight this nav item when loaded (e.g. `project-detail.html` highlights `Projects`). |
161
+
162
+ **Endpoint:** `GET /__api/nav` returns `{ "items": [...] }` — the merged manifest in final order. The shell fetches this on load and renders the sidebar dynamically. Read-through cached with mtime invalidation; no restart needed after editing a manifest. If the endpoint fails, the shell falls back to a minimal Home-only nav rather than rendering a white page.
163
+
164
+ **Missing pages:** if an `href` doesn't resolve to a real page (neither a core page nor an extension overlay), a warning is logged at startup but the item stays in the list — useful while building.
165
+
166
+ **Example:** copy `core/tools/workspace/nav.json.example` to `operator/extensions/workspace/nav.json` and adjust for your pages. A worked demo:
167
+
168
+ ```bash
169
+ # Create a new extension page
170
+ cat > operator/extensions/workspace/mypage.html <<'EOF'
171
+ <!DOCTYPE html><html><body><h1>My Page</h1></body></html>
172
+ EOF
173
+
174
+ # Register it in the nav
175
+ cat > operator/extensions/workspace/nav.json <<'EOF'
176
+ [{ "id": "mypage", "label": "My Page", "href": "/mypage.html", "section": "Extensions" }]
177
+ EOF
178
+
179
+ # Reload the browser — "My Page" appears in a new "Extensions" section.
180
+ ```
181
+
182
+ ### Live reload
183
+
184
+ Live reload was temporarily removed pending a workspace rebuild. Refresh the browser manually (Cmd+R / Ctrl+R) after editing core pages or extension overlays. See the PR "Remove live-reload SSE mechanism (temporary — pending workspace rebuild)" for context.
185
+
186
+ ## Tests
187
+
188
+ ```bash
189
+ node --test core/tools/workspace/test.mjs
190
+ ```
191
+
192
+ Pass the explicit test file. `node --test <dir>` does not work on Node 24 — the runner expects a CommonJS entry in the directory and will error out without one.
193
+
194
+ ## Requirements
195
+
196
+ - Node.js 24+
197
+ - No npm dependencies (node built-ins only)