@chankov/agent-fleet 0.0.1

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 (419) hide show
  1. package/.claude/commands/build.md +44 -0
  2. package/.claude/commands/code-simplify.md +22 -0
  3. package/.claude/commands/design-agent.md +14 -0
  4. package/.claude/commands/doctor-agent-fleet.md +17 -0
  5. package/.claude/commands/orchestrate.md +112 -0
  6. package/.claude/commands/plan.md +16 -0
  7. package/.claude/commands/prime.md +22 -0
  8. package/.claude/commands/review.md +16 -0
  9. package/.claude/commands/setup-agent-fleet.md +25 -0
  10. package/.claude/commands/ship.md +72 -0
  11. package/.claude/commands/spec.md +15 -0
  12. package/.claude/commands/test.md +19 -0
  13. package/.claude/commands/webperf.md +32 -0
  14. package/.claude/orchestrate-teams.yaml +24 -0
  15. package/.opencode/commands/af-build.md +17 -0
  16. package/.opencode/commands/af-code-simplify.md +16 -0
  17. package/.opencode/commands/af-compound.md +16 -0
  18. package/.opencode/commands/af-design-agent.md +15 -0
  19. package/.opencode/commands/af-doctor-agent-fleet.md +15 -0
  20. package/.opencode/commands/af-orchestrate.md +112 -0
  21. package/.opencode/commands/af-plan.md +16 -0
  22. package/.opencode/commands/af-prime.md +22 -0
  23. package/.opencode/commands/af-review.md +15 -0
  24. package/.opencode/commands/af-setup-agent-fleet.md +15 -0
  25. package/.opencode/commands/af-ship.md +16 -0
  26. package/.opencode/commands/af-spec.md +16 -0
  27. package/.opencode/commands/af-test.md +21 -0
  28. package/.opencode/commands/af-webperf.md +32 -0
  29. package/.opencode/orchestrate-teams.yaml +24 -0
  30. package/.pi/agents/dispatch-policy.yaml +32 -0
  31. package/.pi/agents/model-profiles.yaml +20 -0
  32. package/.pi/agents/peers.yaml +142 -0
  33. package/.pi/agents/teams.yaml +39 -0
  34. package/.pi/damage-control-rules.yaml +297 -0
  35. package/.pi/extensions/agent-fleet-update-check/README.md +58 -0
  36. package/.pi/extensions/agent-fleet-update-check/index.ts +161 -0
  37. package/.pi/extensions/agent-fleet-update-check/package.json +6 -0
  38. package/.pi/extensions/btw/README.md +118 -0
  39. package/.pi/extensions/btw/index.ts +917 -0
  40. package/.pi/extensions/btw/package.json +6 -0
  41. package/.pi/extensions/btw/state.js +179 -0
  42. package/.pi/extensions/chrome-devtools-mcp/README.md +58 -0
  43. package/.pi/extensions/chrome-devtools-mcp/index.ts +92 -0
  44. package/.pi/extensions/chrome-devtools-mcp/package.json +6 -0
  45. package/.pi/extensions/compact-and-continue/README.md +42 -0
  46. package/.pi/extensions/compact-and-continue/index.ts +120 -0
  47. package/.pi/extensions/compact-and-continue/package.json +6 -0
  48. package/.pi/extensions/mcp-bridge/README.md +46 -0
  49. package/.pi/extensions/mcp-bridge/index.ts +206 -0
  50. package/.pi/extensions/mcp-bridge/package.json +6 -0
  51. package/.pi/extensions/package-lock.json +1143 -0
  52. package/.pi/extensions/package.json +9 -0
  53. package/.pi/extensions/pi-voice-stt/README.md +201 -0
  54. package/.pi/extensions/pi-voice-stt/config.ts +198 -0
  55. package/.pi/extensions/pi-voice-stt/examples/stt.json +35 -0
  56. package/.pi/extensions/pi-voice-stt/index.ts +248 -0
  57. package/.pi/extensions/pi-voice-stt/package.json +6 -0
  58. package/.pi/extensions/pi-voice-stt/providers.ts +214 -0
  59. package/.pi/extensions/pi-voice-stt/recorder.ts +158 -0
  60. package/.pi/harnesses/agent-hub/README.md +562 -0
  61. package/.pi/harnesses/agent-hub/artifacts.js +92 -0
  62. package/.pi/harnesses/agent-hub/backend-policy.js +153 -0
  63. package/.pi/harnesses/agent-hub/delegate.ts +363 -0
  64. package/.pi/harnesses/agent-hub/evidence-rules.js +96 -0
  65. package/.pi/harnesses/agent-hub/helpers.ts +165 -0
  66. package/.pi/harnesses/agent-hub/index.ts +7098 -0
  67. package/.pi/harnesses/agent-hub/package.json +6 -0
  68. package/.pi/harnesses/agent-hub/return-contract.js +215 -0
  69. package/.pi/harnesses/agent-hub/scope-gate.js +103 -0
  70. package/.pi/harnesses/agent-hub/spawn.ts +179 -0
  71. package/.pi/harnesses/ask-user-remote/README.md +10 -0
  72. package/.pi/harnesses/ask-user-remote/index.ts +253 -0
  73. package/.pi/harnesses/ask-user-remote/race-core.js +106 -0
  74. package/.pi/harnesses/coms/README.md +71 -0
  75. package/.pi/harnesses/coms/index.ts +1743 -0
  76. package/.pi/harnesses/coms/package.json +6 -0
  77. package/.pi/harnesses/damage-control/README.md +65 -0
  78. package/.pi/harnesses/damage-control/index.ts +250 -0
  79. package/.pi/harnesses/damage-control/package.json +6 -0
  80. package/.pi/harnesses/damage-control/shared.ts +183 -0
  81. package/.pi/harnesses/damage-control-continue/README.md +116 -0
  82. package/.pi/harnesses/damage-control-continue/index.ts +522 -0
  83. package/.pi/harnesses/damage-control-continue/package.json +6 -0
  84. package/.pi/harnesses/lib/herdr-client.ts +458 -0
  85. package/.pi/harnesses/lib/herdr-presence.ts +288 -0
  86. package/.pi/harnesses/package-lock.json +35 -0
  87. package/.pi/harnesses/package.json +9 -0
  88. package/.pi/prompts/build.md +24 -0
  89. package/.pi/prompts/code-simplify.md +22 -0
  90. package/.pi/prompts/doctor-agent-fleet.md +15 -0
  91. package/.pi/prompts/plan.md +16 -0
  92. package/.pi/prompts/review.md +16 -0
  93. package/.pi/prompts/setup-agent-fleet.md +27 -0
  94. package/.pi/prompts/ship.md +17 -0
  95. package/.pi/prompts/spec.md +15 -0
  96. package/.pi/prompts/test.md +19 -0
  97. package/.pi/skills/bowser/SKILL.md +145 -0
  98. package/.versions/0.0.1/.claude/commands/build.md +44 -0
  99. package/.versions/0.0.1/.claude/commands/code-simplify.md +22 -0
  100. package/.versions/0.0.1/.claude/commands/design-agent.md +14 -0
  101. package/.versions/0.0.1/.claude/commands/doctor-agent-fleet.md +17 -0
  102. package/.versions/0.0.1/.claude/commands/orchestrate.md +112 -0
  103. package/.versions/0.0.1/.claude/commands/plan.md +16 -0
  104. package/.versions/0.0.1/.claude/commands/prime.md +22 -0
  105. package/.versions/0.0.1/.claude/commands/review.md +16 -0
  106. package/.versions/0.0.1/.claude/commands/setup-agent-fleet.md +25 -0
  107. package/.versions/0.0.1/.claude/commands/ship.md +72 -0
  108. package/.versions/0.0.1/.claude/commands/spec.md +15 -0
  109. package/.versions/0.0.1/.claude/commands/test.md +19 -0
  110. package/.versions/0.0.1/.claude/commands/webperf.md +32 -0
  111. package/.versions/0.0.1/.claude/orchestrate-teams.yaml +24 -0
  112. package/.versions/0.0.1/.opencode/commands/af-build.md +17 -0
  113. package/.versions/0.0.1/.opencode/commands/af-code-simplify.md +16 -0
  114. package/.versions/0.0.1/.opencode/commands/af-compound.md +16 -0
  115. package/.versions/0.0.1/.opencode/commands/af-design-agent.md +15 -0
  116. package/.versions/0.0.1/.opencode/commands/af-doctor-agent-fleet.md +15 -0
  117. package/.versions/0.0.1/.opencode/commands/af-orchestrate.md +112 -0
  118. package/.versions/0.0.1/.opencode/commands/af-plan.md +16 -0
  119. package/.versions/0.0.1/.opencode/commands/af-prime.md +22 -0
  120. package/.versions/0.0.1/.opencode/commands/af-review.md +15 -0
  121. package/.versions/0.0.1/.opencode/commands/af-setup-agent-fleet.md +15 -0
  122. package/.versions/0.0.1/.opencode/commands/af-ship.md +16 -0
  123. package/.versions/0.0.1/.opencode/commands/af-spec.md +16 -0
  124. package/.versions/0.0.1/.opencode/commands/af-test.md +21 -0
  125. package/.versions/0.0.1/.opencode/commands/af-webperf.md +32 -0
  126. package/.versions/0.0.1/.opencode/orchestrate-teams.yaml +24 -0
  127. package/.versions/0.0.1/.pi/agents/dispatch-policy.yaml +32 -0
  128. package/.versions/0.0.1/.pi/agents/model-profiles.yaml +20 -0
  129. package/.versions/0.0.1/.pi/agents/peers.yaml +142 -0
  130. package/.versions/0.0.1/.pi/agents/teams.yaml +39 -0
  131. package/.versions/0.0.1/.pi/damage-control-rules.yaml +297 -0
  132. package/.versions/0.0.1/.pi/extensions/agent-fleet-update-check/README.md +58 -0
  133. package/.versions/0.0.1/.pi/extensions/agent-fleet-update-check/index.ts +161 -0
  134. package/.versions/0.0.1/.pi/extensions/agent-fleet-update-check/package.json +6 -0
  135. package/.versions/0.0.1/.pi/extensions/btw/README.md +118 -0
  136. package/.versions/0.0.1/.pi/extensions/btw/index.ts +917 -0
  137. package/.versions/0.0.1/.pi/extensions/btw/package.json +6 -0
  138. package/.versions/0.0.1/.pi/extensions/btw/state.js +179 -0
  139. package/.versions/0.0.1/.pi/extensions/chrome-devtools-mcp/README.md +58 -0
  140. package/.versions/0.0.1/.pi/extensions/chrome-devtools-mcp/index.ts +92 -0
  141. package/.versions/0.0.1/.pi/extensions/chrome-devtools-mcp/package.json +6 -0
  142. package/.versions/0.0.1/.pi/extensions/compact-and-continue/README.md +42 -0
  143. package/.versions/0.0.1/.pi/extensions/compact-and-continue/index.ts +120 -0
  144. package/.versions/0.0.1/.pi/extensions/compact-and-continue/package.json +6 -0
  145. package/.versions/0.0.1/.pi/extensions/mcp-bridge/README.md +46 -0
  146. package/.versions/0.0.1/.pi/extensions/mcp-bridge/index.ts +206 -0
  147. package/.versions/0.0.1/.pi/extensions/mcp-bridge/package.json +6 -0
  148. package/.versions/0.0.1/.pi/extensions/package-lock.json +1143 -0
  149. package/.versions/0.0.1/.pi/extensions/package.json +9 -0
  150. package/.versions/0.0.1/.pi/extensions/pi-voice-stt/README.md +201 -0
  151. package/.versions/0.0.1/.pi/extensions/pi-voice-stt/config.ts +198 -0
  152. package/.versions/0.0.1/.pi/extensions/pi-voice-stt/examples/stt.json +35 -0
  153. package/.versions/0.0.1/.pi/extensions/pi-voice-stt/index.ts +248 -0
  154. package/.versions/0.0.1/.pi/extensions/pi-voice-stt/package.json +6 -0
  155. package/.versions/0.0.1/.pi/extensions/pi-voice-stt/providers.ts +214 -0
  156. package/.versions/0.0.1/.pi/extensions/pi-voice-stt/recorder.ts +158 -0
  157. package/.versions/0.0.1/.pi/harnesses/agent-hub/README.md +562 -0
  158. package/.versions/0.0.1/.pi/harnesses/agent-hub/artifacts.js +92 -0
  159. package/.versions/0.0.1/.pi/harnesses/agent-hub/backend-policy.js +153 -0
  160. package/.versions/0.0.1/.pi/harnesses/agent-hub/delegate.ts +363 -0
  161. package/.versions/0.0.1/.pi/harnesses/agent-hub/evidence-rules.js +96 -0
  162. package/.versions/0.0.1/.pi/harnesses/agent-hub/helpers.ts +165 -0
  163. package/.versions/0.0.1/.pi/harnesses/agent-hub/index.ts +7098 -0
  164. package/.versions/0.0.1/.pi/harnesses/agent-hub/package.json +6 -0
  165. package/.versions/0.0.1/.pi/harnesses/agent-hub/return-contract.js +215 -0
  166. package/.versions/0.0.1/.pi/harnesses/agent-hub/scope-gate.js +103 -0
  167. package/.versions/0.0.1/.pi/harnesses/agent-hub/spawn.ts +179 -0
  168. package/.versions/0.0.1/.pi/harnesses/ask-user-remote/README.md +10 -0
  169. package/.versions/0.0.1/.pi/harnesses/ask-user-remote/index.ts +253 -0
  170. package/.versions/0.0.1/.pi/harnesses/ask-user-remote/race-core.js +106 -0
  171. package/.versions/0.0.1/.pi/harnesses/coms/README.md +71 -0
  172. package/.versions/0.0.1/.pi/harnesses/coms/index.ts +1743 -0
  173. package/.versions/0.0.1/.pi/harnesses/coms/package.json +6 -0
  174. package/.versions/0.0.1/.pi/harnesses/damage-control/README.md +65 -0
  175. package/.versions/0.0.1/.pi/harnesses/damage-control/index.ts +250 -0
  176. package/.versions/0.0.1/.pi/harnesses/damage-control/package.json +6 -0
  177. package/.versions/0.0.1/.pi/harnesses/damage-control/shared.ts +183 -0
  178. package/.versions/0.0.1/.pi/harnesses/damage-control-continue/README.md +116 -0
  179. package/.versions/0.0.1/.pi/harnesses/damage-control-continue/index.ts +522 -0
  180. package/.versions/0.0.1/.pi/harnesses/damage-control-continue/package.json +6 -0
  181. package/.versions/0.0.1/.pi/harnesses/lib/herdr-client.ts +458 -0
  182. package/.versions/0.0.1/.pi/harnesses/lib/herdr-presence.ts +288 -0
  183. package/.versions/0.0.1/.pi/harnesses/package-lock.json +35 -0
  184. package/.versions/0.0.1/.pi/harnesses/package.json +9 -0
  185. package/.versions/0.0.1/.pi/prompts/build.md +24 -0
  186. package/.versions/0.0.1/.pi/prompts/code-simplify.md +22 -0
  187. package/.versions/0.0.1/.pi/prompts/doctor-agent-fleet.md +15 -0
  188. package/.versions/0.0.1/.pi/prompts/plan.md +16 -0
  189. package/.versions/0.0.1/.pi/prompts/review.md +16 -0
  190. package/.versions/0.0.1/.pi/prompts/setup-agent-fleet.md +27 -0
  191. package/.versions/0.0.1/.pi/prompts/ship.md +17 -0
  192. package/.versions/0.0.1/.pi/prompts/spec.md +15 -0
  193. package/.versions/0.0.1/.pi/prompts/test.md +19 -0
  194. package/.versions/0.0.1/.pi/skills/bowser/SKILL.md +145 -0
  195. package/.versions/0.0.1/.version +1 -0
  196. package/.versions/0.0.1/agents/architect.md +21 -0
  197. package/.versions/0.0.1/agents/bowser.md +25 -0
  198. package/.versions/0.0.1/agents/builder.md +52 -0
  199. package/.versions/0.0.1/agents/code-reviewer.md +205 -0
  200. package/.versions/0.0.1/agents/deep-researcher.md +31 -0
  201. package/.versions/0.0.1/agents/documenter.md +16 -0
  202. package/.versions/0.0.1/agents/orchestrator.md +43 -0
  203. package/.versions/0.0.1/agents/plan-reviewer.md +60 -0
  204. package/.versions/0.0.1/agents/planner.md +69 -0
  205. package/.versions/0.0.1/agents/releaser.md +22 -0
  206. package/.versions/0.0.1/agents/researcher.md +28 -0
  207. package/.versions/0.0.1/agents/security-auditor.md +166 -0
  208. package/.versions/0.0.1/agents/test-engineer.md +144 -0
  209. package/.versions/0.0.1/agents/web-debugger.md +42 -0
  210. package/.versions/0.0.1/agents/web-performance-auditor.md +192 -0
  211. package/.versions/0.0.1/hooks/SIMPLIFY-IGNORE.md +90 -0
  212. package/.versions/0.0.1/hooks/coms-stop-hook.mjs +73 -0
  213. package/.versions/0.0.1/hooks/hooks.json +14 -0
  214. package/.versions/0.0.1/hooks/session-start.sh +74 -0
  215. package/.versions/0.0.1/hooks/simplify-ignore.sh +302 -0
  216. package/.versions/0.0.1/justfile +143 -0
  217. package/.versions/0.0.1/references/accessibility-checklist.md +160 -0
  218. package/.versions/0.0.1/references/definition-of-done.md +67 -0
  219. package/.versions/0.0.1/references/fleet-coordination-patterns.md +151 -0
  220. package/.versions/0.0.1/references/observability-checklist.md +91 -0
  221. package/.versions/0.0.1/references/orchestration-patterns.md +370 -0
  222. package/.versions/0.0.1/references/performance-checklist.md +153 -0
  223. package/.versions/0.0.1/references/prompting-patterns.md +380 -0
  224. package/.versions/0.0.1/references/security-checklist.md +179 -0
  225. package/.versions/0.0.1/references/testing-patterns.md +236 -0
  226. package/.versions/0.0.1/scripts/coms-claude-bridge.ts +286 -0
  227. package/.versions/0.0.1/scripts/coms-cli.ts +372 -0
  228. package/.versions/0.0.1/scripts/coms-hermes-bridge.ts +399 -0
  229. package/.versions/0.0.1/scripts/lib/claude-bridge-core.ts +100 -0
  230. package/.versions/0.0.1/scripts/lib/coms-envelope.ts +494 -0
  231. package/.versions/0.0.1/scripts/lib/herdr-layout.ts +235 -0
  232. package/.versions/0.0.1/scripts/lib/hermes-bridge-core.ts +238 -0
  233. package/.versions/0.0.1/scripts/lib/persona-banner.ts +62 -0
  234. package/.versions/0.0.1/scripts/lib/team-project.ts +75 -0
  235. package/.versions/0.0.1/scripts/lib/team-snapshot.ts +146 -0
  236. package/.versions/0.0.1/scripts/peer-banner.ts +40 -0
  237. package/.versions/0.0.1/scripts/team-snapshot.ts +221 -0
  238. package/.versions/0.0.1/scripts/team-up.ts +245 -0
  239. package/.versions/0.0.1/skills/_internal/grilling.md +11 -0
  240. package/.versions/0.0.1/skills/browser-testing-with-devtools/SKILL.md +352 -0
  241. package/.versions/0.0.1/skills/code-review-and-quality/SKILL.md +381 -0
  242. package/.versions/0.0.1/skills/compound-learning/SKILL.md +137 -0
  243. package/.versions/0.0.1/skills/context-engineering/SKILL.md +291 -0
  244. package/.versions/0.0.1/skills/deprecation-and-migration/SKILL.md +206 -0
  245. package/.versions/0.0.1/skills/designing-agents/SKILL.md +394 -0
  246. package/.versions/0.0.1/skills/designing-agents/pi-harness-authoring.md +209 -0
  247. package/.versions/0.0.1/skills/frontend-ui-engineering/SKILL.md +328 -0
  248. package/.versions/0.0.1/skills/git-workflow-and-versioning/SKILL.md +316 -0
  249. package/.versions/0.0.1/skills/guided-workspace-setup/SKILL.md +506 -0
  250. package/.versions/0.0.1/skills/idea-refine/SKILL.md +182 -0
  251. package/.versions/0.0.1/skills/idea-refine/examples.md +238 -0
  252. package/.versions/0.0.1/skills/idea-refine/frameworks.md +99 -0
  253. package/.versions/0.0.1/skills/idea-refine/refinement-criteria.md +113 -0
  254. package/.versions/0.0.1/skills/idea-refine/scripts/idea-refine.sh +15 -0
  255. package/.versions/0.0.1/skills/incremental-implementation/SKILL.md +287 -0
  256. package/.versions/0.0.1/skills/interview-me/SKILL.md +226 -0
  257. package/.versions/0.0.1/skills/orchestration-verification/SKILL.md +181 -0
  258. package/.versions/0.0.1/skills/peer-coms/SKILL.md +81 -0
  259. package/.versions/0.0.1/skills/performance-optimization/SKILL.md +350 -0
  260. package/.versions/0.0.1/skills/planning-and-task-breakdown/SKILL.md +236 -0
  261. package/.versions/0.0.1/skills/security-and-hardening/SKILL.md +461 -0
  262. package/.versions/0.0.1/skills/spec-driven-development/SKILL.md +245 -0
  263. package/.versions/0.0.1/skills/using-agent-skills/SKILL.md +199 -0
  264. package/.versions/0.0.1/vendor/agent-skills-upstream/LICENSE +21 -0
  265. package/.versions/0.0.1/vendor/agent-skills-upstream/README.md +11 -0
  266. package/.versions/0.0.1/vendor/agent-skills-upstream/skills/api-and-interface-design/SKILL.md +294 -0
  267. package/.versions/0.0.1/vendor/agent-skills-upstream/skills/browser-testing-with-devtools/SKILL.md +317 -0
  268. package/.versions/0.0.1/vendor/agent-skills-upstream/skills/ci-cd-and-automation/SKILL.md +390 -0
  269. package/.versions/0.0.1/vendor/agent-skills-upstream/skills/code-review-and-quality/SKILL.md +396 -0
  270. package/.versions/0.0.1/vendor/agent-skills-upstream/skills/code-simplification/SKILL.md +331 -0
  271. package/.versions/0.0.1/vendor/agent-skills-upstream/skills/context-engineering/SKILL.md +289 -0
  272. package/.versions/0.0.1/vendor/agent-skills-upstream/skills/debugging-and-error-recovery/SKILL.md +300 -0
  273. package/.versions/0.0.1/vendor/agent-skills-upstream/skills/deprecation-and-migration/SKILL.md +247 -0
  274. package/.versions/0.0.1/vendor/agent-skills-upstream/skills/documentation-and-adrs/SKILL.md +278 -0
  275. package/.versions/0.0.1/vendor/agent-skills-upstream/skills/doubt-driven-development/SKILL.md +243 -0
  276. package/.versions/0.0.1/vendor/agent-skills-upstream/skills/frontend-ui-engineering/SKILL.md +328 -0
  277. package/.versions/0.0.1/vendor/agent-skills-upstream/skills/git-workflow-and-versioning/SKILL.md +355 -0
  278. package/.versions/0.0.1/vendor/agent-skills-upstream/skills/idea-refine/SKILL.md +178 -0
  279. package/.versions/0.0.1/vendor/agent-skills-upstream/skills/idea-refine/examples.md +238 -0
  280. package/.versions/0.0.1/vendor/agent-skills-upstream/skills/idea-refine/frameworks.md +99 -0
  281. package/.versions/0.0.1/vendor/agent-skills-upstream/skills/idea-refine/refinement-criteria.md +113 -0
  282. package/.versions/0.0.1/vendor/agent-skills-upstream/skills/idea-refine/scripts/idea-refine.sh +15 -0
  283. package/.versions/0.0.1/vendor/agent-skills-upstream/skills/incremental-implementation/SKILL.md +249 -0
  284. package/.versions/0.0.1/vendor/agent-skills-upstream/skills/interview-me/SKILL.md +225 -0
  285. package/.versions/0.0.1/vendor/agent-skills-upstream/skills/observability-and-instrumentation/SKILL.md +203 -0
  286. package/.versions/0.0.1/vendor/agent-skills-upstream/skills/performance-optimization/SKILL.md +350 -0
  287. package/.versions/0.0.1/vendor/agent-skills-upstream/skills/planning-and-task-breakdown/SKILL.md +234 -0
  288. package/.versions/0.0.1/vendor/agent-skills-upstream/skills/security-and-hardening/SKILL.md +467 -0
  289. package/.versions/0.0.1/vendor/agent-skills-upstream/skills/shipping-and-launch/SKILL.md +310 -0
  290. package/.versions/0.0.1/vendor/agent-skills-upstream/skills/source-driven-development/SKILL.md +194 -0
  291. package/.versions/0.0.1/vendor/agent-skills-upstream/skills/spec-driven-development/SKILL.md +206 -0
  292. package/.versions/0.0.1/vendor/agent-skills-upstream/skills/test-driven-development/SKILL.md +383 -0
  293. package/.versions/0.0.1/vendor/agent-skills-upstream/skills/using-agent-skills/SKILL.md +191 -0
  294. package/CHANGELOG.md +65 -0
  295. package/LICENSE +21 -0
  296. package/README.md +458 -0
  297. package/agents/architect.md +21 -0
  298. package/agents/bowser.md +25 -0
  299. package/agents/builder.md +52 -0
  300. package/agents/code-reviewer.md +205 -0
  301. package/agents/deep-researcher.md +31 -0
  302. package/agents/documenter.md +16 -0
  303. package/agents/orchestrator.md +43 -0
  304. package/agents/plan-reviewer.md +60 -0
  305. package/agents/planner.md +69 -0
  306. package/agents/releaser.md +22 -0
  307. package/agents/researcher.md +28 -0
  308. package/agents/security-auditor.md +166 -0
  309. package/agents/test-engineer.md +144 -0
  310. package/agents/web-debugger.md +42 -0
  311. package/agents/web-performance-auditor.md +192 -0
  312. package/bin/cli.js +633 -0
  313. package/bin/force-patch-changesets.js +44 -0
  314. package/bin/lib/bootstrap.js +323 -0
  315. package/bin/lib/detect-agent.js +49 -0
  316. package/bin/lib/doctor.js +302 -0
  317. package/bin/lib/transform-persona.js +180 -0
  318. package/bin/lib/update-notifier.js +195 -0
  319. package/bin/lib/validate-overrides.js +229 -0
  320. package/bin/snapshot-version.js +91 -0
  321. package/docs/agent-fleet-setup.md +355 -0
  322. package/docs/claude-code-coms-bridge.md +93 -0
  323. package/docs/getting-started.md +169 -0
  324. package/docs/npm-install.md +335 -0
  325. package/docs/opencode-setup.md +248 -0
  326. package/docs/pi-extensions.md +237 -0
  327. package/docs/pi-setup.md +455 -0
  328. package/docs/skill-anatomy.md +150 -0
  329. package/hooks/SIMPLIFY-IGNORE.md +90 -0
  330. package/hooks/coms-stop-hook.mjs +73 -0
  331. package/hooks/hooks.json +14 -0
  332. package/hooks/session-start.sh +74 -0
  333. package/hooks/simplify-ignore.sh +302 -0
  334. package/justfile +143 -0
  335. package/node_modules/pi-ask-user/LICENSE +21 -0
  336. package/node_modules/pi-ask-user/README.md +156 -0
  337. package/node_modules/pi-ask-user/index.ts +1795 -0
  338. package/node_modules/pi-ask-user/package.json +51 -0
  339. package/node_modules/pi-ask-user/single-select-layout.ts +203 -0
  340. package/node_modules/pi-ask-user/skills/ask-user/SKILL.md +162 -0
  341. package/node_modules/pi-ask-user/skills/ask-user/references/ask-user-skill-extension-spec.md +96 -0
  342. package/package.json +121 -0
  343. package/references/accessibility-checklist.md +160 -0
  344. package/references/definition-of-done.md +67 -0
  345. package/references/fleet-coordination-patterns.md +151 -0
  346. package/references/observability-checklist.md +91 -0
  347. package/references/orchestration-patterns.md +370 -0
  348. package/references/performance-checklist.md +153 -0
  349. package/references/prompting-patterns.md +380 -0
  350. package/references/security-checklist.md +179 -0
  351. package/references/testing-patterns.md +236 -0
  352. package/scripts/coms-claude-bridge.ts +286 -0
  353. package/scripts/coms-cli.ts +372 -0
  354. package/scripts/coms-hermes-bridge.ts +399 -0
  355. package/scripts/lib/claude-bridge-core.ts +100 -0
  356. package/scripts/lib/coms-envelope.ts +494 -0
  357. package/scripts/lib/herdr-layout.ts +235 -0
  358. package/scripts/lib/hermes-bridge-core.ts +238 -0
  359. package/scripts/lib/persona-banner.ts +62 -0
  360. package/scripts/lib/team-project.ts +75 -0
  361. package/scripts/lib/team-snapshot.ts +146 -0
  362. package/scripts/peer-banner.ts +40 -0
  363. package/scripts/team-snapshot.ts +221 -0
  364. package/scripts/team-up.ts +245 -0
  365. package/skills/_internal/grilling.md +11 -0
  366. package/skills/browser-testing-with-devtools/SKILL.md +352 -0
  367. package/skills/code-review-and-quality/SKILL.md +381 -0
  368. package/skills/compound-learning/SKILL.md +137 -0
  369. package/skills/context-engineering/SKILL.md +291 -0
  370. package/skills/deprecation-and-migration/SKILL.md +206 -0
  371. package/skills/designing-agents/SKILL.md +394 -0
  372. package/skills/designing-agents/pi-harness-authoring.md +209 -0
  373. package/skills/frontend-ui-engineering/SKILL.md +328 -0
  374. package/skills/git-workflow-and-versioning/SKILL.md +316 -0
  375. package/skills/guided-workspace-setup/SKILL.md +506 -0
  376. package/skills/idea-refine/SKILL.md +182 -0
  377. package/skills/idea-refine/examples.md +238 -0
  378. package/skills/idea-refine/frameworks.md +99 -0
  379. package/skills/idea-refine/refinement-criteria.md +113 -0
  380. package/skills/idea-refine/scripts/idea-refine.sh +15 -0
  381. package/skills/incremental-implementation/SKILL.md +287 -0
  382. package/skills/interview-me/SKILL.md +226 -0
  383. package/skills/orchestration-verification/SKILL.md +181 -0
  384. package/skills/peer-coms/SKILL.md +81 -0
  385. package/skills/performance-optimization/SKILL.md +350 -0
  386. package/skills/planning-and-task-breakdown/SKILL.md +236 -0
  387. package/skills/security-and-hardening/SKILL.md +461 -0
  388. package/skills/spec-driven-development/SKILL.md +245 -0
  389. package/skills/using-agent-skills/SKILL.md +199 -0
  390. package/vendor/agent-skills-upstream/LICENSE +21 -0
  391. package/vendor/agent-skills-upstream/README.md +11 -0
  392. package/vendor/agent-skills-upstream/skills/api-and-interface-design/SKILL.md +294 -0
  393. package/vendor/agent-skills-upstream/skills/browser-testing-with-devtools/SKILL.md +317 -0
  394. package/vendor/agent-skills-upstream/skills/ci-cd-and-automation/SKILL.md +390 -0
  395. package/vendor/agent-skills-upstream/skills/code-review-and-quality/SKILL.md +396 -0
  396. package/vendor/agent-skills-upstream/skills/code-simplification/SKILL.md +331 -0
  397. package/vendor/agent-skills-upstream/skills/context-engineering/SKILL.md +289 -0
  398. package/vendor/agent-skills-upstream/skills/debugging-and-error-recovery/SKILL.md +300 -0
  399. package/vendor/agent-skills-upstream/skills/deprecation-and-migration/SKILL.md +247 -0
  400. package/vendor/agent-skills-upstream/skills/documentation-and-adrs/SKILL.md +278 -0
  401. package/vendor/agent-skills-upstream/skills/doubt-driven-development/SKILL.md +243 -0
  402. package/vendor/agent-skills-upstream/skills/frontend-ui-engineering/SKILL.md +328 -0
  403. package/vendor/agent-skills-upstream/skills/git-workflow-and-versioning/SKILL.md +355 -0
  404. package/vendor/agent-skills-upstream/skills/idea-refine/SKILL.md +178 -0
  405. package/vendor/agent-skills-upstream/skills/idea-refine/examples.md +238 -0
  406. package/vendor/agent-skills-upstream/skills/idea-refine/frameworks.md +99 -0
  407. package/vendor/agent-skills-upstream/skills/idea-refine/refinement-criteria.md +113 -0
  408. package/vendor/agent-skills-upstream/skills/idea-refine/scripts/idea-refine.sh +15 -0
  409. package/vendor/agent-skills-upstream/skills/incremental-implementation/SKILL.md +249 -0
  410. package/vendor/agent-skills-upstream/skills/interview-me/SKILL.md +225 -0
  411. package/vendor/agent-skills-upstream/skills/observability-and-instrumentation/SKILL.md +203 -0
  412. package/vendor/agent-skills-upstream/skills/performance-optimization/SKILL.md +350 -0
  413. package/vendor/agent-skills-upstream/skills/planning-and-task-breakdown/SKILL.md +234 -0
  414. package/vendor/agent-skills-upstream/skills/security-and-hardening/SKILL.md +467 -0
  415. package/vendor/agent-skills-upstream/skills/shipping-and-launch/SKILL.md +310 -0
  416. package/vendor/agent-skills-upstream/skills/source-driven-development/SKILL.md +194 -0
  417. package/vendor/agent-skills-upstream/skills/spec-driven-development/SKILL.md +206 -0
  418. package/vendor/agent-skills-upstream/skills/test-driven-development/SKILL.md +383 -0
  419. package/vendor/agent-skills-upstream/skills/using-agent-skills/SKILL.md +191 -0
@@ -0,0 +1,235 @@
1
+ // scripts/lib/herdr-layout.ts
2
+ //
3
+ // Pure logic for the herdr fleet recipes: peers.yaml parsing, peer→command
4
+ // construction, and peers.yaml team → herdr declarative layout tree (BSP
5
+ // splits, one pane per peer). No pi imports, no sockets, no process.exit —
6
+ // everything throws plain Errors so callers decide how to die. Testable
7
+ // under node --test; the wiring (requireHerdr, workspace.create,
8
+ // layout.apply) lives in scripts/team-up.ts.
9
+
10
+ import { resolve as resolvePath } from "node:path";
11
+
12
+ import type { LayoutNode } from "../../.pi/harnesses/lib/herdr-client.ts";
13
+ import { DEFAULT_PROJECT, validateProject } from "./team-project.ts";
14
+
15
+ export type { LayoutNode };
16
+
17
+ // Safe charset for any value spliced into a command line or layout — the
18
+ // peers.yaml file is user-edited, so every manifest value is validated.
19
+ export const SAFE = /^[A-Za-z0-9._/,-]+$/;
20
+
21
+ export interface Peer {
22
+ name?: string;
23
+ persona?: string;
24
+ model?: string;
25
+ // Optional comma-separated extension names under .pi/extensions/ to load into
26
+ // this peer (routes it through `just _peer-plus` instead of `just _peer`).
27
+ extensions?: string;
28
+ // Optional repo-relative KEY=VALUE file injected as the pane's env at spawn
29
+ // (herdr injects it before the command runs — no shell `source`).
30
+ env_file?: string;
31
+ // Optional runner. Default (absent) is a pi peer via `_peer`/`_peer-plus`;
32
+ // "claude-code" spawns an interactive Claude Code plus its coms bridge in
33
+ // the pane via `_claude-peer` (model → `claude --model`).
34
+ runner?: string;
35
+ }
36
+
37
+ function stripQuotes(v: string): string {
38
+ if ((v.startsWith('"') && v.endsWith('"')) || (v.startsWith("'") && v.endsWith("'"))) {
39
+ return v.slice(1, -1);
40
+ }
41
+ return v;
42
+ }
43
+
44
+ // Minimal parser for the specific peers.yaml shape (team → list of {name,persona,model}).
45
+ // Not a general YAML parser; tolerant of comments and blank lines only.
46
+ export function parsePeersYaml(raw: string): Record<string, Peer[]> {
47
+ const teams: Record<string, Peer[]> = {};
48
+ let currentTeam: string | null = null;
49
+ let currentPeer: Peer | null = null;
50
+
51
+ for (const rawLine of raw.split("\n")) {
52
+ const line = rawLine.replace(/\s+$/, "");
53
+ if (line.trim() === "" || /^\s*#/.test(line)) continue;
54
+ const indent = line.length - line.trimStart().length;
55
+ const content = line.trim();
56
+
57
+ if (indent === 0) {
58
+ const m = content.match(/^([A-Za-z0-9_-]+):\s*$/);
59
+ if (m) {
60
+ currentTeam = m[1];
61
+ teams[currentTeam] = [];
62
+ currentPeer = null;
63
+ }
64
+ continue;
65
+ }
66
+ if (!currentTeam) continue;
67
+
68
+ const itemM = content.match(/^-\s*([A-Za-z0-9_]+):\s*(.+)$/);
69
+ if (itemM) {
70
+ currentPeer = {};
71
+ teams[currentTeam].push(currentPeer);
72
+ (currentPeer as Record<string, string>)[itemM[1]] = stripQuotes(itemM[2]);
73
+ continue;
74
+ }
75
+ const fieldM = content.match(/^([A-Za-z0-9_]+):\s*(.+)$/);
76
+ if (fieldM && currentPeer) {
77
+ (currentPeer as Record<string, string>)[fieldM[1]] = stripQuotes(fieldM[2]);
78
+ }
79
+ }
80
+ return teams;
81
+ }
82
+
83
+ // Validate a peer's fields and build its launch argv. `just` recipe params are
84
+ // POSITIONAL (persona name model session) — bare positional args, never
85
+ // key=value. A peer with `extensions:` routes through `_peer-plus
86
+ // <extensions> <persona> <name> [<model>] [<session>]`; otherwise plain
87
+ // `_peer <persona> <name> [<model>] [<session>]`. `resumeRef` (a pi session
88
+ // path for `pi --session`) fills the trailing session positional — when the
89
+ // peer has no model, an empty-string placeholder keeps the positions aligned.
90
+ export function peerCommand(p: Peer, team: string, resumeRef?: string, project = DEFAULT_PROJECT): string[] {
91
+ validateProject(project);
92
+ if (p.runner !== undefined && p.runner !== "claude-code") {
93
+ throw new Error(`Unknown runner "${p.runner}" for peer "${p.name}" in team "${team}" (supported: claude-code).`);
94
+ }
95
+ if (!p.persona && p.runner !== "claude-code") {
96
+ throw new Error(`Peer "${p.name ?? "(unnamed)"}" in team "${team}" is missing a persona.`);
97
+ }
98
+ if (!p.name) {
99
+ throw new Error(`Peer with persona "${p.persona}" in team "${team}" is missing a name.`);
100
+ }
101
+ for (const [k, v] of Object.entries(p)) {
102
+ // Only string fields can reach a command line; extra non-string fields
103
+ // (e.g. a snapshot's `resume` object) are never spliced into argv.
104
+ if (typeof v === "string" && !SAFE.test(v)) {
105
+ throw new Error(`Unsafe value for ${k} in team "${team}": ${JSON.stringify(v)} (allowed: ${SAFE})`);
106
+ }
107
+ }
108
+ if (resumeRef !== undefined && !SAFE.test(resumeRef)) {
109
+ throw new Error(`Unsafe resume ref for ${p.name}: ${JSON.stringify(resumeRef)} (allowed: ${SAFE})`);
110
+ }
111
+ if (p.runner === "claude-code" && p.extensions) {
112
+ throw new Error(`Peer "${p.name}": extensions: are pi-only and cannot combine with runner: claude-code.`);
113
+ }
114
+ const parts =
115
+ p.runner === "claude-code"
116
+ ? ["just", "_claude-peer", p.name]
117
+ : p.extensions
118
+ ? ["just", "_peer-plus", p.extensions, p.persona, p.name]
119
+ : ["just", "_peer", p.persona, p.name];
120
+ if (p.model) parts.push(p.model);
121
+ if (resumeRef !== undefined) {
122
+ if (!p.model) parts.push(""); // keep the model positional aligned
123
+ parts.push(resumeRef);
124
+ }
125
+ if (project !== DEFAULT_PROJECT) {
126
+ if (!p.model && resumeRef === undefined) parts.push("");
127
+ if (resumeRef === undefined) parts.push("");
128
+ parts.push(project);
129
+ }
130
+ return parts;
131
+ }
132
+
133
+ // Parse a KEY=VALUE env file (B3): no shell evaluation, no expansion.
134
+ // Blank lines and #-comments are skipped; values may be single- or
135
+ // double-quoted (quotes stripped, contents taken literally).
136
+ export function parseEnvFile(raw: string, sourceName = "env file"): Record<string, string> {
137
+ const env: Record<string, string> = {};
138
+ const lines = raw.split("\n");
139
+ for (let i = 0; i < lines.length; i++) {
140
+ const line = lines[i].trim();
141
+ if (line === "" || line.startsWith("#")) continue;
142
+ const m = line.match(/^(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)=(.*)$/);
143
+ if (!m) {
144
+ throw new Error(`${sourceName}:${i + 1}: not a KEY=VALUE line: ${JSON.stringify(line)}`);
145
+ }
146
+ env[m[1]] = stripQuotes(m[2].trim());
147
+ }
148
+ return env;
149
+ }
150
+
151
+ // Resolve a peer's env_file to an absolute path inside the repo. The SAFE
152
+ // charset (enforced on every peer field) already excludes shell metacharacters;
153
+ // this adds the traversal guard: repo-relative, no escaping the repo root.
154
+ export function resolveEnvFilePath(envFile: string, repoRoot: string): string {
155
+ if (!SAFE.test(envFile)) {
156
+ throw new Error(`Unsafe env_file path: ${JSON.stringify(envFile)} (allowed: ${SAFE})`);
157
+ }
158
+ if (envFile.startsWith("/")) {
159
+ throw new Error(`env_file must be repo-relative, got absolute path: ${envFile}`);
160
+ }
161
+ const abs = resolvePath(repoRoot, envFile);
162
+ if (abs !== repoRoot && !abs.startsWith(repoRoot + "/")) {
163
+ throw new Error(`env_file escapes the repo root: ${envFile}`);
164
+ }
165
+ return abs;
166
+ }
167
+
168
+ export interface TeamLayoutOptions {
169
+ team: string;
170
+ peers: Peer[];
171
+ repoRoot: string;
172
+ // B3 hook: resolve a peer's extra env (e.g. from its env_file). Returning
173
+ // undefined means no extra env for that peer.
174
+ envForPeer?: (peer: Peer) => Record<string, string> | undefined;
175
+ // B5 hook: resume ref (pi session path) for a peer being restored from a
176
+ // team snapshot. Returning undefined starts the peer fresh.
177
+ resumeForPeer?: (peer: Peer) => string | undefined;
178
+ // B2 hook: when set, the hub occupies a larger root pane (ratio of the
179
+ // horizontal split) and the team tiles in the remaining space.
180
+ // Coms project scope shared by all panes in this layout. The default keeps
181
+ // existing argv shapes; non-default projects are appended to hidden recipe
182
+ // positional args after model/session.
183
+ project?: string;
184
+ hub?: { command: string[]; label: string; ratio?: number };
185
+ }
186
+
187
+ function paneNode(
188
+ peer: Peer,
189
+ team: string,
190
+ repoRoot: string,
191
+ envForPeer?: TeamLayoutOptions["envForPeer"],
192
+ resumeForPeer?: TeamLayoutOptions["resumeForPeer"],
193
+ project = DEFAULT_PROJECT,
194
+ ): LayoutNode {
195
+ validateProject(project);
196
+ const env = envForPeer?.(peer);
197
+ return {
198
+ type: "pane",
199
+ command: peerCommand(peer, team, resumeForPeer?.(peer), project),
200
+ cwd: repoRoot,
201
+ label: peer.name as string,
202
+ ...(env && Object.keys(env).length > 0 ? { env } : {}),
203
+ };
204
+ }
205
+
206
+ // Balanced BSP over a list of panes: split the list in half, alternating
207
+ // split direction by depth — the herdr equivalent of tmux's tiled layout.
208
+ function bsp(nodes: LayoutNode[], depth: number): LayoutNode {
209
+ if (nodes.length === 1) return nodes[0];
210
+ const mid = Math.ceil(nodes.length / 2);
211
+ return {
212
+ type: "split",
213
+ direction: depth % 2 === 0 ? "right" : "down",
214
+ ratio: mid / nodes.length,
215
+ first: bsp(nodes.slice(0, mid), depth + 1),
216
+ second: bsp(nodes.slice(mid), depth + 1),
217
+ };
218
+ }
219
+
220
+ // peers.yaml team → herdr layout tree for layout.apply.
221
+ export function buildTeamLayout(opts: TeamLayoutOptions): LayoutNode {
222
+ const { team, peers, repoRoot, envForPeer, resumeForPeer, hub, project = DEFAULT_PROJECT } = opts;
223
+ validateProject(project);
224
+ if (peers.length === 0) throw new Error(`Team "${team}" has no peers.`);
225
+ const panes = peers.map((p) => paneNode(p, team, repoRoot, envForPeer, resumeForPeer, project));
226
+ const grid = bsp(panes, hub ? 1 : 0);
227
+ if (!hub) return grid;
228
+ return {
229
+ type: "split",
230
+ direction: "right",
231
+ ratio: hub.ratio ?? 0.4,
232
+ first: { type: "pane", command: hub.command, cwd: repoRoot, label: hub.label },
233
+ second: grid,
234
+ };
235
+ }
@@ -0,0 +1,238 @@
1
+ // scripts/lib/hermes-bridge-core.ts
2
+ //
3
+ // Pure logic for the Hermes ⇄ coms bridge: qid correlation, Telegram
4
+ // formatting, answer-file validation, answer mapping, timeout outcomes,
5
+ // state transitions, and ndjson log records. No sockets, no fs, no Hermes CLI.
6
+
7
+ import * as os from "node:os";
8
+ import * as path from "node:path";
9
+
10
+ export const QID_RE = /^[0-9A-HJKMNP-TV-Z]{26}$/;
11
+ export const TELEGRAM_TEXT_LIMIT = 4096;
12
+ export const DEFAULT_REMOTE_TIMEOUT_MS = 1_800_000;
13
+ export const HUB_Q_PREFIX = "HUB-Q";
14
+ export const ANSWER_FILE_SUFFIX = ".answer.json";
15
+
16
+ export const BRIDGE_EVENT_NAMES = [
17
+ "question_received",
18
+ "delivered",
19
+ "delivery_error",
20
+ "answered",
21
+ "cancelled",
22
+ "timeout",
23
+ "late_answer",
24
+ ] as const;
25
+
26
+ export type BridgeEventName = (typeof BRIDGE_EVENT_NAMES)[number];
27
+ export type QuestionState = "pending" | "delivered" | "answered" | "cancelled" | "timeout";
28
+
29
+ export interface QuestionOption {
30
+ title: string;
31
+ description?: string;
32
+ }
33
+
34
+ export interface HermesBridgeQuestion {
35
+ qid: string;
36
+ question: string;
37
+ context?: string;
38
+ options?: QuestionOption[];
39
+ }
40
+
41
+ export interface HermesAnswerFile {
42
+ qid: string;
43
+ answer: string;
44
+ answered_by: string;
45
+ at: string;
46
+ }
47
+
48
+ export type AskResponse =
49
+ | { kind: "selection"; selections: string[]; comment?: string }
50
+ | { kind: "freeform"; text: string };
51
+
52
+ export type AnswerRejectReason =
53
+ | "invalid_path"
54
+ | "invalid_qid"
55
+ | "foreign_qid"
56
+ | "invalid_json"
57
+ | "invalid_schema"
58
+ | "qid_mismatch";
59
+
60
+ export type AnswerFileValidation =
61
+ | { ok: true; qid: string; answer: HermesAnswerFile }
62
+ | { ok: false; reason: AnswerRejectReason; qid?: string; detail?: string };
63
+
64
+ export type StateTransition =
65
+ | { ok: true; state: QuestionState | null }
66
+ | { ok: false; reason: "unsupported_transition"; state: QuestionState | null; event: BridgeEventName };
67
+
68
+ export interface LogRecord {
69
+ at: string;
70
+ qid: string;
71
+ event: BridgeEventName;
72
+ detail?: unknown;
73
+ }
74
+
75
+ export function hermesBridgeDir(home = os.homedir()): string {
76
+ return path.join(home, ".pi", "coms", "hermes-bridge");
77
+ }
78
+
79
+ export function questionsDir(home = os.homedir()): string {
80
+ return path.join(hermesBridgeDir(home), "questions");
81
+ }
82
+
83
+ export function logPath(home = os.homedir()): string {
84
+ return path.join(hermesBridgeDir(home), "log.ndjson");
85
+ }
86
+
87
+ export function answerFilePath(qid: string, dir = questionsDir()): string {
88
+ return path.join(dir, `${qid}${ANSWER_FILE_SUFFIX}`);
89
+ }
90
+
91
+ export function isValidQid(qid: unknown): qid is string {
92
+ return typeof qid === "string" && QID_RE.test(qid);
93
+ }
94
+
95
+ export function qidFromPromptEnvelope(env: { msg_id?: unknown }): string {
96
+ if (!isValidQid(env.msg_id)) throw new Error("prompt msg_id must be a 26-character Crockford ULID qid");
97
+ return env.msg_id;
98
+ }
99
+
100
+ function truncateUtf16(text: string, limit: number): string {
101
+ if (text.length <= limit) return text;
102
+ if (limit <= 0) return "";
103
+ if (limit === 1) return "…";
104
+ return `${text.slice(0, limit - 1)}…`;
105
+ }
106
+
107
+ function formatOptions(options: QuestionOption[]): string {
108
+ return options
109
+ .map((option, index) => {
110
+ const desc = option.description ? ` — ${option.description}` : "";
111
+ return `${index + 1}. ${option.title}${desc}`;
112
+ })
113
+ .join("\n");
114
+ }
115
+
116
+ export function formatTelegramQuestion(input: HermesBridgeQuestion, limit = TELEGRAM_TEXT_LIMIT): string {
117
+ if (!isValidQid(input.qid)) throw new Error("qid must be a 26-character Crockford ULID");
118
+ const options = input.options ?? [];
119
+ const header = `❓ [${HUB_Q_PREFIX}:${input.qid}] ${input.question}`;
120
+ const optionsBlock = options.length > 0 ? `\n\nОпции:\n${formatOptions(options)}` : "";
121
+ const instruction = `\n\n↩ Отговори с reply на това съобщение, или напиши: ${HUB_Q_PREFIX}:${input.qid}: <отговор>`;
122
+ const contextPrefix = input.context ? "\n\nКонтекст: " : "";
123
+ const fixedLength = header.length + contextPrefix.length + optionsBlock.length + instruction.length;
124
+ const contextBudget = Math.max(0, limit - fixedLength);
125
+ const context = input.context ? truncateUtf16(input.context, contextBudget) : "";
126
+ return truncateUtf16(`${header}${contextPrefix}${context}${optionsBlock}${instruction}`, limit);
127
+ }
128
+
129
+ export function mapAnswerToAskResponse(answer: string, options: QuestionOption[] = []): AskResponse {
130
+ const text = answer.trim();
131
+ if (options.length > 0) {
132
+ if (/^\d+$/.test(text)) {
133
+ const index = Number(text) - 1;
134
+ const option = options[index];
135
+ if (option) return { kind: "selection", selections: [option.title] };
136
+ }
137
+ const byTitle = options.find((option) => option.title.toLowerCase() === text.toLowerCase());
138
+ if (byTitle) return { kind: "selection", selections: [byTitle.title] };
139
+ }
140
+ return { kind: "freeform", text };
141
+ }
142
+
143
+ function qidFromAnswerPath(filePath: string): { ok: true; qid: string } | { ok: false; reason: AnswerRejectReason } {
144
+ const base = path.basename(filePath);
145
+ if (!base.endsWith(ANSWER_FILE_SUFFIX)) return { ok: false, reason: "invalid_path" };
146
+ const qid = base.slice(0, -ANSWER_FILE_SUFFIX.length);
147
+ if (!isValidQid(qid)) return { ok: false, reason: "invalid_qid" };
148
+ return { ok: true, qid };
149
+ }
150
+
151
+ function isIsoTimestamp(value: string): boolean {
152
+ return !Number.isNaN(Date.parse(value));
153
+ }
154
+
155
+ function schemaValid(value: unknown): value is HermesAnswerFile {
156
+ const rec = value as HermesAnswerFile;
157
+ return (
158
+ !!rec &&
159
+ typeof rec === "object" &&
160
+ isValidQid(rec.qid) &&
161
+ typeof rec.answer === "string" &&
162
+ typeof rec.answered_by === "string" &&
163
+ rec.answered_by.length > 0 &&
164
+ typeof rec.at === "string" &&
165
+ isIsoTimestamp(rec.at)
166
+ );
167
+ }
168
+
169
+ export function validateAnswerFile(
170
+ raw: string,
171
+ filePath: string,
172
+ livePendingQids: Iterable<string>,
173
+ ): AnswerFileValidation {
174
+ const pathQid = qidFromAnswerPath(filePath);
175
+ if (!pathQid.ok) return { ok: false, reason: pathQid.reason };
176
+ const pending = new Set(livePendingQids);
177
+ if (!pending.has(pathQid.qid)) return { ok: false, reason: "foreign_qid", qid: pathQid.qid };
178
+
179
+ let parsed: unknown;
180
+ try {
181
+ parsed = JSON.parse(raw);
182
+ } catch (err) {
183
+ return { ok: false, reason: "invalid_json", qid: pathQid.qid, detail: err instanceof Error ? err.message : String(err) };
184
+ }
185
+ if (!schemaValid(parsed)) return { ok: false, reason: "invalid_schema", qid: pathQid.qid };
186
+ if (parsed.qid !== pathQid.qid) return { ok: false, reason: "qid_mismatch", qid: pathQid.qid };
187
+ return { ok: true, qid: pathQid.qid, answer: parsed };
188
+ }
189
+
190
+ export function timeoutMsFromEnv(env: Pick<NodeJS.ProcessEnv, "PI_COMS_TIMEOUT_MS"> = process.env): number {
191
+ const raw = env.PI_COMS_TIMEOUT_MS;
192
+ if (!raw) return DEFAULT_REMOTE_TIMEOUT_MS;
193
+ const n = Number(raw);
194
+ return Number.isFinite(n) && n > 0 ? n : DEFAULT_REMOTE_TIMEOUT_MS;
195
+ }
196
+
197
+ export function timeoutErrorMessage(timeoutMs: number): string {
198
+ return `no remote answer within ${timeoutMs}ms`;
199
+ }
200
+
201
+ export function timeoutTelegramNote(qid: string, timeoutMs: number): string {
202
+ return `⌛ [${HUB_Q_PREFIX}:${qid}] Въпросът изтече след ${timeoutMs}ms.`;
203
+ }
204
+
205
+ export function timeoutOutcome(qid: string, timeoutMs = timeoutMsFromEnv()): {
206
+ response: null;
207
+ error: string;
208
+ telegramNote: string;
209
+ } {
210
+ return {
211
+ response: null,
212
+ error: timeoutErrorMessage(timeoutMs),
213
+ telegramNote: timeoutTelegramNote(qid, timeoutMs),
214
+ };
215
+ }
216
+
217
+ export function transitionState(state: QuestionState | null, event: BridgeEventName): StateTransition {
218
+ if (state === null && event === "question_received") return { ok: true, state: "pending" };
219
+ if (state === "pending" && event === "delivered") return { ok: true, state: "delivered" };
220
+ if (state === "pending" && event === "delivery_error") return { ok: true, state: null };
221
+ if ((state === "pending" || state === "delivered") && event === "cancelled") return { ok: true, state: "cancelled" };
222
+ if ((state === "pending" || state === "delivered") && event === "timeout") return { ok: true, state: "timeout" };
223
+ if (state === "delivered" && event === "answered") return { ok: true, state: "answered" };
224
+ if ((state === "answered" || state === "cancelled" || state === "timeout") && event === "late_answer") {
225
+ return { ok: true, state };
226
+ }
227
+ return { ok: false, reason: "unsupported_transition", state, event };
228
+ }
229
+
230
+ export function makeLogRecord(qid: string, event: BridgeEventName, detail?: unknown, at = new Date().toISOString()): LogRecord {
231
+ if (!isValidQid(qid)) throw new Error("qid must be a 26-character Crockford ULID");
232
+ if (!BRIDGE_EVENT_NAMES.includes(event)) throw new Error(`unsupported bridge event: ${event}`);
233
+ return detail === undefined ? { at, qid, event } : { at, qid, event, detail };
234
+ }
235
+
236
+ export function renderLogRecord(record: LogRecord): string {
237
+ return `${JSON.stringify(record)}\n`;
238
+ }
@@ -0,0 +1,62 @@
1
+ // scripts/lib/persona-banner.ts
2
+ //
3
+ // Pure logic for the per-pane identity banner (`just _peer`/`_peer-plus`
4
+ // print it before exec'ing pi): persona frontmatter → colored ANSI banner.
5
+ // Frontmatter parsing mirrors the coms harness convention (name /
6
+ // description / color, quoted values allowed). Backend-agnostic — works in
7
+ // any terminal, inside or outside herdr.
8
+
9
+ export interface PersonaMeta {
10
+ name?: string;
11
+ description?: string;
12
+ color?: string;
13
+ }
14
+
15
+ export function parsePersonaFrontmatter(raw: string): PersonaMeta {
16
+ const match = raw.match(/^---\n([\s\S]*?)\n---\n?/);
17
+ if (!match) return {};
18
+ const fm: Record<string, string> = {};
19
+ for (const line of match[1].split("\n")) {
20
+ const idx = line.indexOf(":");
21
+ if (idx > 0) {
22
+ const key = line.slice(0, idx).trim();
23
+ let val = line.slice(idx + 1).trim();
24
+ if ((val.startsWith('"') && val.endsWith('"')) || (val.startsWith("'") && val.endsWith("'"))) {
25
+ val = val.slice(1, -1);
26
+ }
27
+ fm[key] = val;
28
+ }
29
+ }
30
+ return { name: fm.name, description: fm.description, color: fm.color };
31
+ }
32
+
33
+ export function isValidHex(hex: string): boolean {
34
+ return /^#[0-9a-fA-F]{6}$/.test(hex);
35
+ }
36
+
37
+ function hexFg(hex: string, s: string): string {
38
+ const r = parseInt(hex.slice(1, 3), 16);
39
+ const g = parseInt(hex.slice(3, 5), 16);
40
+ const b = parseInt(hex.slice(5, 7), 16);
41
+ return `\x1b[38;2;${r};${g};${b}m${s}\x1b[0m`;
42
+ }
43
+
44
+ const DEFAULT_COLOR = "#36F9F6";
45
+
46
+ // Colored banner lines for a peer pane: name in the persona color, purpose
47
+ // dimmed below, framed by a rule in the same color. `width` caps the rule so
48
+ // narrow panes don't wrap.
49
+ export function renderBanner(
50
+ peerName: string,
51
+ meta: PersonaMeta,
52
+ width = 60,
53
+ ): string[] {
54
+ const color = meta.color && isValidHex(meta.color) ? meta.color : DEFAULT_COLOR;
55
+ const purpose = (meta.description ?? "").trim();
56
+ const rule = hexFg(color, "━".repeat(Math.max(8, Math.min(width, 100))));
57
+ const title = hexFg(color, `● ${peerName}`);
58
+ const lines = [rule, title];
59
+ if (purpose) lines.push(`\x1b[2m${purpose}\x1b[0m`);
60
+ lines.push(rule);
61
+ return lines;
62
+ }
@@ -0,0 +1,75 @@
1
+ // scripts/lib/team-project.ts
2
+ //
3
+ // Shared project scoping helpers for herdr team commands. The coms harness
4
+ // already isolates peers by --project; this file only keeps team workspace
5
+ // labels, snapshot files, and generated launch argv in sync with that scope.
6
+
7
+ import * as path from "node:path";
8
+
9
+ export const DEFAULT_PROJECT = "default";
10
+
11
+ // Conservative project names: no empty string, path separators, traversal,
12
+ // whitespace, shell metacharacters, or glob stars. Dots are allowed for names
13
+ // like "acme.prod", but ".." is not allowed anywhere.
14
+ export const PROJECT_SAFE = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
15
+ export const TEAM_SAFE = /^[A-Za-z0-9_-]+$/;
16
+
17
+ export function validateProject(project: string): string {
18
+ if (
19
+ project.length === 0 ||
20
+ project === "." ||
21
+ project.includes("..") ||
22
+ project.includes("/") ||
23
+ project.includes("\\") ||
24
+ !PROJECT_SAFE.test(project)
25
+ ) {
26
+ throw new Error(
27
+ `Invalid project name: ${JSON.stringify(project)} (use letters, numbers, dots, underscores, or hyphens; no '..')`,
28
+ );
29
+ }
30
+ return project;
31
+ }
32
+
33
+ export function validateTeamName(team: string): string {
34
+ if (!TEAM_SAFE.test(team)) throw new Error(`Invalid team name: ${JSON.stringify(team)}`);
35
+ return team;
36
+ }
37
+
38
+ export function parseProjectFlag(argv: string[]): string {
39
+ let project = DEFAULT_PROJECT;
40
+ let seen = false;
41
+ for (let i = 0; i < argv.length; i++) {
42
+ if (argv[i] !== "--project") continue;
43
+ if (seen) throw new Error("--project may only be provided once");
44
+ seen = true;
45
+ const value = argv[i + 1];
46
+ if (!value || value.startsWith("--")) throw new Error("--project requires a name");
47
+ project = value;
48
+ i++;
49
+ }
50
+ return validateProject(project);
51
+ }
52
+
53
+ export function teamWorkspaceLabel(kind: "peers" | "hub" | "conductor", team: string, project = DEFAULT_PROJECT): string {
54
+ validateTeamName(team);
55
+ validateProject(project);
56
+ const prefix = kind === "hub" ? "pi-hub" : kind === "conductor" ? "pi-conductor" : "pi-peers";
57
+ return project === DEFAULT_PROJECT ? `${prefix}-${team}` : `${prefix}-${team}--project.${project}`;
58
+ }
59
+
60
+ export function hubCommand(project = DEFAULT_PROJECT): string[] {
61
+ validateProject(project);
62
+ return project === DEFAULT_PROJECT ? ["just", "hub"] : ["just", "hub", "--project", project];
63
+ }
64
+
65
+ export function conductorCommand(): string[] {
66
+ return ["hermes", "-p", "dev"];
67
+ }
68
+
69
+ export function teamSnapshotPath(snapshotDir: string, team: string, project = DEFAULT_PROJECT): string {
70
+ validateTeamName(team);
71
+ validateProject(project);
72
+ return project === DEFAULT_PROJECT
73
+ ? path.join(snapshotDir, `${team}.json`)
74
+ : path.join(snapshotDir, "projects", project, `${team}.json`);
75
+ }