@chankov/agent-fleet 0.0.2 → 0.0.4

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 (362) hide show
  1. package/.claude/commands/doctor-agent-fleet.md +1 -1
  2. package/.claude/commands/setup-agent-fleet.md +5 -5
  3. package/.opencode/commands/af-doctor-agent-fleet.md +2 -0
  4. package/.opencode/commands/af-setup-agent-fleet.md +1 -1
  5. package/.pi/agents/peers.yaml +4 -0
  6. package/.pi/agents/teams.yaml +2 -2
  7. package/.pi/harnesses/agent-hub/README.md +254 -18
  8. package/.pi/harnesses/agent-hub/access-approval.ts +135 -0
  9. package/.pi/harnesses/agent-hub/delegate.ts +32 -9
  10. package/.pi/harnesses/agent-hub/drift-watchdog.js +165 -0
  11. package/.pi/harnesses/agent-hub/footer.ts +29 -0
  12. package/.pi/harnesses/agent-hub/helpers.ts +49 -0
  13. package/.pi/harnesses/agent-hub/index.ts +1269 -322
  14. package/.pi/harnesses/agent-hub/monitor-control.ts +9 -0
  15. package/.pi/harnesses/agent-hub/monitor-lifecycle.ts +13 -0
  16. package/.pi/harnesses/agent-hub/monitor-publisher.ts +59 -0
  17. package/.pi/harnesses/agent-hub/monitor-recovery.ts +3 -0
  18. package/.pi/harnesses/agent-hub/monitor-runtime.ts +3 -0
  19. package/.pi/harnesses/agent-hub/monitor-session-bridge.ts +11 -0
  20. package/.pi/harnesses/agent-hub/package.json +5 -4
  21. package/.pi/harnesses/agent-hub/research-retention.js +34 -0
  22. package/.pi/harnesses/agent-hub/research-watchdog.ts +40 -0
  23. package/.pi/harnesses/agent-hub/run-budget.js +155 -0
  24. package/.pi/harnesses/agent-hub/safety-routing.ts +22 -0
  25. package/.pi/harnesses/agent-hub/spawn.ts +161 -94
  26. package/.pi/harnesses/agent-hub/version.ts +18 -0
  27. package/.pi/harnesses/ask-user-remote/README.md +2 -0
  28. package/.pi/harnesses/coms/README.md +21 -0
  29. package/.pi/harnesses/coms/index.ts +2 -0
  30. package/.pi/harnesses/coms/package.json +5 -4
  31. package/.pi/harnesses/coms/version.ts +18 -0
  32. package/.pi/harnesses/damage-control-continue/README.md +32 -31
  33. package/.pi/harnesses/damage-control-continue/index.ts +23 -9
  34. package/.pi/harnesses/damage-control-continue/package.json +5 -4
  35. package/.pi/harnesses/damage-control-continue/version.ts +18 -0
  36. package/.pi/harnesses/{damage-control/shared.ts → lib/damage-control-shared.ts} +20 -6
  37. package/.pi/prompts/doctor-agent-fleet.md +1 -1
  38. package/.pi/prompts/setup-agent-fleet.md +5 -5
  39. package/.versions/0.0.4/.claude/commands/build.md +44 -0
  40. package/.versions/0.0.4/.claude/commands/code-simplify.md +22 -0
  41. package/.versions/0.0.4/.claude/commands/design-agent.md +14 -0
  42. package/.versions/0.0.4/.claude/commands/doctor-agent-fleet.md +17 -0
  43. package/.versions/0.0.4/.claude/commands/orchestrate.md +112 -0
  44. package/.versions/0.0.4/.claude/commands/plan.md +16 -0
  45. package/.versions/0.0.4/.claude/commands/prime.md +22 -0
  46. package/.versions/0.0.4/.claude/commands/review.md +16 -0
  47. package/.versions/0.0.4/.claude/commands/setup-agent-fleet.md +25 -0
  48. package/.versions/0.0.4/.claude/commands/ship.md +72 -0
  49. package/.versions/0.0.4/.claude/commands/spec.md +15 -0
  50. package/.versions/0.0.4/.claude/commands/test.md +19 -0
  51. package/.versions/0.0.4/.claude/commands/webperf.md +32 -0
  52. package/.versions/0.0.4/.claude/orchestrate-teams.yaml +24 -0
  53. package/.versions/0.0.4/.opencode/commands/af-build.md +17 -0
  54. package/.versions/0.0.4/.opencode/commands/af-code-simplify.md +16 -0
  55. package/.versions/0.0.4/.opencode/commands/af-compound.md +16 -0
  56. package/.versions/0.0.4/.opencode/commands/af-design-agent.md +15 -0
  57. package/.versions/0.0.4/.opencode/commands/af-doctor-agent-fleet.md +17 -0
  58. package/.versions/0.0.4/.opencode/commands/af-orchestrate.md +112 -0
  59. package/.versions/0.0.4/.opencode/commands/af-plan.md +16 -0
  60. package/.versions/0.0.4/.opencode/commands/af-prime.md +22 -0
  61. package/.versions/0.0.4/.opencode/commands/af-review.md +15 -0
  62. package/.versions/0.0.4/.opencode/commands/af-setup-agent-fleet.md +15 -0
  63. package/.versions/0.0.4/.opencode/commands/af-ship.md +16 -0
  64. package/.versions/0.0.4/.opencode/commands/af-spec.md +16 -0
  65. package/.versions/0.0.4/.opencode/commands/af-test.md +21 -0
  66. package/.versions/0.0.4/.opencode/commands/af-webperf.md +32 -0
  67. package/.versions/0.0.4/.opencode/orchestrate-teams.yaml +24 -0
  68. package/.versions/0.0.4/.pi/agents/dispatch-policy.yaml +32 -0
  69. package/.versions/0.0.4/.pi/agents/model-profiles.yaml +20 -0
  70. package/.versions/0.0.4/.pi/agents/peers.yaml +146 -0
  71. package/.versions/0.0.4/.pi/agents/teams.yaml +39 -0
  72. package/.versions/0.0.4/.pi/damage-control-rules.yaml +297 -0
  73. package/.versions/0.0.4/.pi/extensions/agent-fleet-update-check/README.md +58 -0
  74. package/.versions/0.0.4/.pi/extensions/agent-fleet-update-check/index.ts +161 -0
  75. package/{.pi/harnesses/damage-control → .versions/0.0.4/.pi/extensions/agent-fleet-update-check}/package.json +1 -1
  76. package/.versions/0.0.4/.pi/extensions/btw/README.md +118 -0
  77. package/.versions/0.0.4/.pi/extensions/btw/index.ts +917 -0
  78. package/.versions/0.0.4/.pi/extensions/btw/package.json +6 -0
  79. package/.versions/0.0.4/.pi/extensions/btw/state.js +179 -0
  80. package/.versions/0.0.4/.pi/extensions/chrome-devtools-mcp/README.md +58 -0
  81. package/.versions/0.0.4/.pi/extensions/chrome-devtools-mcp/index.ts +92 -0
  82. package/.versions/0.0.4/.pi/extensions/chrome-devtools-mcp/package.json +6 -0
  83. package/.versions/0.0.4/.pi/extensions/compact-and-continue/README.md +42 -0
  84. package/.versions/0.0.4/.pi/extensions/compact-and-continue/index.ts +120 -0
  85. package/.versions/0.0.4/.pi/extensions/compact-and-continue/package.json +6 -0
  86. package/.versions/0.0.4/.pi/extensions/mcp-bridge/README.md +46 -0
  87. package/.versions/0.0.4/.pi/extensions/mcp-bridge/index.ts +206 -0
  88. package/.versions/0.0.4/.pi/extensions/mcp-bridge/package.json +6 -0
  89. package/.versions/0.0.4/.pi/extensions/package-lock.json +1143 -0
  90. package/.versions/0.0.4/.pi/extensions/package.json +9 -0
  91. package/.versions/0.0.4/.pi/extensions/pi-voice-stt/README.md +201 -0
  92. package/.versions/0.0.4/.pi/extensions/pi-voice-stt/config.ts +198 -0
  93. package/.versions/0.0.4/.pi/extensions/pi-voice-stt/examples/stt.json +35 -0
  94. package/.versions/0.0.4/.pi/extensions/pi-voice-stt/index.ts +248 -0
  95. package/.versions/0.0.4/.pi/extensions/pi-voice-stt/package.json +6 -0
  96. package/.versions/0.0.4/.pi/extensions/pi-voice-stt/providers.ts +214 -0
  97. package/.versions/0.0.4/.pi/extensions/pi-voice-stt/recorder.ts +158 -0
  98. package/.versions/0.0.4/.pi/harnesses/agent-hub/README.md +798 -0
  99. package/.versions/0.0.4/.pi/harnesses/agent-hub/access-approval.ts +135 -0
  100. package/.versions/0.0.4/.pi/harnesses/agent-hub/artifacts.js +92 -0
  101. package/.versions/0.0.4/.pi/harnesses/agent-hub/backend-policy.js +153 -0
  102. package/.versions/0.0.4/.pi/harnesses/agent-hub/delegate.ts +386 -0
  103. package/.versions/0.0.4/.pi/harnesses/agent-hub/drift-watchdog.js +165 -0
  104. package/.versions/0.0.4/.pi/harnesses/agent-hub/evidence-rules.js +96 -0
  105. package/.versions/0.0.4/.pi/harnesses/agent-hub/footer.ts +29 -0
  106. package/.versions/0.0.4/.pi/harnesses/agent-hub/helpers.ts +214 -0
  107. package/.versions/0.0.4/.pi/harnesses/agent-hub/index.ts +8045 -0
  108. package/.versions/0.0.4/.pi/harnesses/agent-hub/monitor-control.ts +9 -0
  109. package/.versions/0.0.4/.pi/harnesses/agent-hub/monitor-lifecycle.ts +13 -0
  110. package/.versions/0.0.4/.pi/harnesses/agent-hub/monitor-publisher.ts +59 -0
  111. package/.versions/0.0.4/.pi/harnesses/agent-hub/monitor-recovery.ts +3 -0
  112. package/.versions/0.0.4/.pi/harnesses/agent-hub/monitor-runtime.ts +3 -0
  113. package/.versions/0.0.4/.pi/harnesses/agent-hub/monitor-session-bridge.ts +11 -0
  114. package/.versions/0.0.4/.pi/harnesses/agent-hub/package.json +7 -0
  115. package/.versions/0.0.4/.pi/harnesses/agent-hub/research-retention.js +34 -0
  116. package/.versions/0.0.4/.pi/harnesses/agent-hub/research-watchdog.ts +40 -0
  117. package/.versions/0.0.4/.pi/harnesses/agent-hub/return-contract.js +215 -0
  118. package/.versions/0.0.4/.pi/harnesses/agent-hub/run-budget.js +155 -0
  119. package/.versions/0.0.4/.pi/harnesses/agent-hub/safety-routing.ts +22 -0
  120. package/.versions/0.0.4/.pi/harnesses/agent-hub/scope-gate.js +103 -0
  121. package/.versions/0.0.4/.pi/harnesses/agent-hub/spawn.ts +246 -0
  122. package/.versions/0.0.4/.pi/harnesses/agent-hub/version.ts +18 -0
  123. package/.versions/0.0.4/.pi/harnesses/ask-user-remote/README.md +18 -0
  124. package/.versions/0.0.4/.pi/harnesses/ask-user-remote/index.ts +293 -0
  125. package/.versions/0.0.4/.pi/harnesses/ask-user-remote/race-core.js +106 -0
  126. package/.versions/0.0.4/.pi/harnesses/coms/README.md +92 -0
  127. package/.versions/0.0.4/.pi/harnesses/coms/index.ts +1745 -0
  128. package/.versions/0.0.4/.pi/harnesses/coms/package.json +7 -0
  129. package/.versions/0.0.4/.pi/harnesses/coms/version.ts +18 -0
  130. package/.versions/0.0.4/.pi/harnesses/damage-control-continue/README.md +117 -0
  131. package/.versions/0.0.4/.pi/harnesses/damage-control-continue/index.ts +536 -0
  132. package/.versions/0.0.4/.pi/harnesses/damage-control-continue/package.json +7 -0
  133. package/.versions/0.0.4/.pi/harnesses/damage-control-continue/version.ts +18 -0
  134. package/.versions/0.0.4/.pi/harnesses/lib/damage-control-shared.ts +197 -0
  135. package/.versions/0.0.4/.pi/harnesses/lib/herdr-client.ts +458 -0
  136. package/.versions/0.0.4/.pi/harnesses/lib/herdr-presence.ts +288 -0
  137. package/.versions/0.0.4/.pi/harnesses/package-lock.json +35 -0
  138. package/.versions/0.0.4/.pi/harnesses/package.json +9 -0
  139. package/.versions/0.0.4/.pi/prompts/build.md +24 -0
  140. package/.versions/0.0.4/.pi/prompts/code-simplify.md +22 -0
  141. package/.versions/0.0.4/.pi/prompts/doctor-agent-fleet.md +15 -0
  142. package/.versions/0.0.4/.pi/prompts/plan.md +16 -0
  143. package/.versions/0.0.4/.pi/prompts/review.md +16 -0
  144. package/.versions/0.0.4/.pi/prompts/setup-agent-fleet.md +27 -0
  145. package/.versions/0.0.4/.pi/prompts/ship.md +17 -0
  146. package/.versions/0.0.4/.pi/prompts/spec.md +15 -0
  147. package/.versions/0.0.4/.pi/prompts/test.md +19 -0
  148. package/.versions/0.0.4/.pi/skills/bowser/SKILL.md +145 -0
  149. package/.versions/0.0.4/.version +1 -0
  150. package/.versions/0.0.4/agents/architect.md +23 -0
  151. package/.versions/0.0.4/agents/bowser.md +26 -0
  152. package/.versions/0.0.4/agents/builder.md +53 -0
  153. package/.versions/0.0.4/agents/code-reviewer.md +205 -0
  154. package/.versions/0.0.4/agents/deep-researcher.md +31 -0
  155. package/.versions/0.0.4/agents/documenter.md +18 -0
  156. package/.versions/0.0.4/agents/orchestrator.md +54 -0
  157. package/.versions/0.0.4/agents/plan-reviewer.md +60 -0
  158. package/.versions/0.0.4/agents/planner.md +69 -0
  159. package/.versions/0.0.4/agents/releaser.md +24 -0
  160. package/.versions/0.0.4/agents/researcher.md +28 -0
  161. package/.versions/0.0.4/agents/security-auditor.md +166 -0
  162. package/.versions/0.0.4/agents/test-engineer.md +151 -0
  163. package/.versions/0.0.4/agents/web-debugger.md +42 -0
  164. package/.versions/0.0.4/agents/web-performance-auditor.md +192 -0
  165. package/.versions/0.0.4/codex/CONDUCTOR.md +148 -0
  166. package/.versions/0.0.4/docs/ARCHITECTURE.md +210 -0
  167. package/.versions/0.0.4/docs/agent-fleet-setup.md +366 -0
  168. package/.versions/0.0.4/docs/claude-code-coms-bridge.md +103 -0
  169. package/.versions/0.0.4/docs/codex-remote-conductor.md +170 -0
  170. package/.versions/0.0.4/docs/coms-hermes-bridge.md +121 -0
  171. package/.versions/0.0.4/docs/getting-started.md +183 -0
  172. package/.versions/0.0.4/docs/npm-install.md +337 -0
  173. package/.versions/0.0.4/docs/opencode-setup.md +248 -0
  174. package/.versions/0.0.4/docs/pi-extensions.md +288 -0
  175. package/.versions/0.0.4/docs/pi-setup.md +463 -0
  176. package/.versions/0.0.4/docs/skill-anatomy.md +150 -0
  177. package/.versions/0.0.4/hermes/README.md +228 -0
  178. package/.versions/0.0.4/hermes/desktop-plugins/agent-fleet-monitor/plugin.js +19 -0
  179. package/.versions/0.0.4/hermes/desktop-plugins/agent-fleet-monitor/state.js +10 -0
  180. package/.versions/0.0.4/hermes/plugins/agent-fleet-monitor/dashboard/adapter-cap.test.py +15 -0
  181. package/.versions/0.0.4/hermes/plugins/agent-fleet-monitor/dashboard/adapter-discovery.test.py +19 -0
  182. package/.versions/0.0.4/hermes/plugins/agent-fleet-monitor/dashboard/adapter-envelope.test.py +13 -0
  183. package/.versions/0.0.4/hermes/plugins/agent-fleet-monitor/dashboard/adapter-forged-owner.test.py +11 -0
  184. package/.versions/0.0.4/hermes/plugins/agent-fleet-monitor/dashboard/adapter-lease-list.test.py +9 -0
  185. package/.versions/0.0.4/hermes/plugins/agent-fleet-monitor/dashboard/adapter-multihub.test.py +17 -0
  186. package/.versions/0.0.4/hermes/plugins/agent-fleet-monitor/dashboard/adapter-output.test.py +34 -0
  187. package/.versions/0.0.4/hermes/plugins/agent-fleet-monitor/dashboard/adapter.py +151 -0
  188. package/.versions/0.0.4/hermes/plugins/agent-fleet-monitor/dashboard/adapter.test.py +39 -0
  189. package/.versions/0.0.4/hermes/plugins/agent-fleet-monitor/dashboard/manifest.json +11 -0
  190. package/.versions/0.0.4/hermes/plugins/agent-fleet-monitor/dashboard/plugin-api-validation.test.py +12 -0
  191. package/.versions/0.0.4/hermes/plugins/agent-fleet-monitor/dashboard/plugin_api.py +50 -0
  192. package/.versions/0.0.4/hermes/plugins/agent-fleet-monitor/dashboard/review-live-wiring.red.test.py +22 -0
  193. package/.versions/0.0.4/hermes/skills/hub-conductor/SKILL.md +84 -0
  194. package/.versions/0.0.4/hermes/skills/hub-liaison/SKILL.md +84 -0
  195. package/.versions/0.0.4/hooks/SIMPLIFY-IGNORE.md +90 -0
  196. package/.versions/0.0.4/hooks/coms-stop-hook.mjs +73 -0
  197. package/.versions/0.0.4/hooks/hooks.json +14 -0
  198. package/.versions/0.0.4/hooks/session-start.sh +74 -0
  199. package/.versions/0.0.4/hooks/simplify-ignore.sh +302 -0
  200. package/.versions/0.0.4/justfile +256 -0
  201. package/.versions/0.0.4/references/accessibility-checklist.md +160 -0
  202. package/.versions/0.0.4/references/definition-of-done.md +67 -0
  203. package/.versions/0.0.4/references/fleet-coordination-patterns.md +151 -0
  204. package/.versions/0.0.4/references/observability-checklist.md +91 -0
  205. package/.versions/0.0.4/references/orchestration-patterns.md +370 -0
  206. package/.versions/0.0.4/references/performance-checklist.md +153 -0
  207. package/.versions/0.0.4/references/prompting-patterns.md +380 -0
  208. package/.versions/0.0.4/references/security-checklist.md +179 -0
  209. package/.versions/0.0.4/references/testing-patterns.md +236 -0
  210. package/.versions/0.0.4/scripts/codex-conductor.ts +41 -0
  211. package/.versions/0.0.4/scripts/codex-remote-control.ts +167 -0
  212. package/.versions/0.0.4/scripts/coms-claude-bridge.ts +286 -0
  213. package/.versions/0.0.4/scripts/coms-cli.ts +484 -0
  214. package/.versions/0.0.4/scripts/coms-hermes-bridge.ts +403 -0
  215. package/.versions/0.0.4/scripts/hermes-monitor-capability-runner.ts +25 -0
  216. package/.versions/0.0.4/scripts/hermes-monitor-scenario.ts +7 -0
  217. package/.versions/0.0.4/scripts/lib/claude-bridge-core.ts +100 -0
  218. package/.versions/0.0.4/scripts/lib/codex-conductor.ts +88 -0
  219. package/.versions/0.0.4/scripts/lib/codex-remote-control.ts +480 -0
  220. package/.versions/0.0.4/scripts/lib/coms-envelope.ts +539 -0
  221. package/.versions/0.0.4/scripts/lib/fake-herdr-server.ts +88 -0
  222. package/.versions/0.0.4/scripts/lib/herdr-layout.ts +263 -0
  223. package/.versions/0.0.4/scripts/lib/hermes-bridge-core.ts +238 -0
  224. package/.versions/0.0.4/scripts/lib/hermes-monitor-herdr.ts +28 -0
  225. package/.versions/0.0.4/scripts/lib/hermes-monitor-model.ts +9 -0
  226. package/.versions/0.0.4/scripts/lib/hermes-monitor-registry.ts +6 -0
  227. package/.versions/0.0.4/scripts/lib/hermes-monitor-socket.ts +118 -0
  228. package/.versions/0.0.4/scripts/lib/hermes-monitor-store.ts +31 -0
  229. package/.versions/0.0.4/scripts/lib/persona-banner.ts +62 -0
  230. package/.versions/0.0.4/scripts/lib/spawn-stagger.ts +101 -0
  231. package/.versions/0.0.4/scripts/lib/team-project.ts +184 -0
  232. package/.versions/0.0.4/scripts/lib/team-snapshot.ts +147 -0
  233. package/.versions/0.0.4/scripts/peer-banner.ts +40 -0
  234. package/.versions/0.0.4/scripts/team-snapshot.ts +238 -0
  235. package/.versions/0.0.4/scripts/team-up.ts +333 -0
  236. package/.versions/0.0.4/skills/_internal/grilling.md +11 -0
  237. package/.versions/0.0.4/skills/browser-testing-with-devtools/SKILL.md +352 -0
  238. package/.versions/0.0.4/skills/code-review-and-quality/SKILL.md +381 -0
  239. package/.versions/0.0.4/skills/compound-learning/SKILL.md +137 -0
  240. package/.versions/0.0.4/skills/context-engineering/SKILL.md +291 -0
  241. package/.versions/0.0.4/skills/deprecation-and-migration/SKILL.md +206 -0
  242. package/.versions/0.0.4/skills/designing-agents/SKILL.md +394 -0
  243. package/.versions/0.0.4/skills/designing-agents/pi-harness-authoring.md +222 -0
  244. package/.versions/0.0.4/skills/frontend-ui-engineering/SKILL.md +328 -0
  245. package/.versions/0.0.4/skills/git-workflow-and-versioning/SKILL.md +316 -0
  246. package/.versions/0.0.4/skills/guided-workspace-setup/SKILL.md +535 -0
  247. package/.versions/0.0.4/skills/guided-workspace-setup/companion-manifest.json +33 -0
  248. package/.versions/0.0.4/skills/idea-refine/SKILL.md +182 -0
  249. package/.versions/0.0.4/skills/idea-refine/examples.md +238 -0
  250. package/.versions/0.0.4/skills/idea-refine/frameworks.md +99 -0
  251. package/.versions/0.0.4/skills/idea-refine/refinement-criteria.md +113 -0
  252. package/.versions/0.0.4/skills/idea-refine/scripts/idea-refine.sh +15 -0
  253. package/.versions/0.0.4/skills/incremental-implementation/SKILL.md +287 -0
  254. package/.versions/0.0.4/skills/interview-me/SKILL.md +226 -0
  255. package/.versions/0.0.4/skills/orchestration-verification/SKILL.md +181 -0
  256. package/.versions/0.0.4/skills/peer-coms/SKILL.md +90 -0
  257. package/.versions/0.0.4/skills/performance-optimization/SKILL.md +350 -0
  258. package/.versions/0.0.4/skills/planning-and-task-breakdown/SKILL.md +236 -0
  259. package/.versions/0.0.4/skills/security-and-hardening/SKILL.md +461 -0
  260. package/.versions/0.0.4/skills/spec-driven-development/SKILL.md +245 -0
  261. package/.versions/0.0.4/skills/using-agent-skills/SKILL.md +199 -0
  262. package/.versions/0.0.4/systemd/user/agent-fleet-codex-remote-control.service.in +23 -0
  263. package/.versions/0.0.4/vendor/agent-skills-upstream/LICENSE +21 -0
  264. package/.versions/0.0.4/vendor/agent-skills-upstream/README.md +11 -0
  265. package/.versions/0.0.4/vendor/agent-skills-upstream/skills/api-and-interface-design/SKILL.md +294 -0
  266. package/.versions/0.0.4/vendor/agent-skills-upstream/skills/browser-testing-with-devtools/SKILL.md +317 -0
  267. package/.versions/0.0.4/vendor/agent-skills-upstream/skills/ci-cd-and-automation/SKILL.md +390 -0
  268. package/.versions/0.0.4/vendor/agent-skills-upstream/skills/code-review-and-quality/SKILL.md +396 -0
  269. package/.versions/0.0.4/vendor/agent-skills-upstream/skills/code-simplification/SKILL.md +331 -0
  270. package/.versions/0.0.4/vendor/agent-skills-upstream/skills/context-engineering/SKILL.md +289 -0
  271. package/.versions/0.0.4/vendor/agent-skills-upstream/skills/debugging-and-error-recovery/SKILL.md +300 -0
  272. package/.versions/0.0.4/vendor/agent-skills-upstream/skills/deprecation-and-migration/SKILL.md +247 -0
  273. package/.versions/0.0.4/vendor/agent-skills-upstream/skills/documentation-and-adrs/SKILL.md +278 -0
  274. package/.versions/0.0.4/vendor/agent-skills-upstream/skills/doubt-driven-development/SKILL.md +243 -0
  275. package/.versions/0.0.4/vendor/agent-skills-upstream/skills/frontend-ui-engineering/SKILL.md +328 -0
  276. package/.versions/0.0.4/vendor/agent-skills-upstream/skills/git-workflow-and-versioning/SKILL.md +355 -0
  277. package/.versions/0.0.4/vendor/agent-skills-upstream/skills/idea-refine/SKILL.md +178 -0
  278. package/.versions/0.0.4/vendor/agent-skills-upstream/skills/idea-refine/examples.md +238 -0
  279. package/.versions/0.0.4/vendor/agent-skills-upstream/skills/idea-refine/frameworks.md +99 -0
  280. package/.versions/0.0.4/vendor/agent-skills-upstream/skills/idea-refine/refinement-criteria.md +113 -0
  281. package/.versions/0.0.4/vendor/agent-skills-upstream/skills/idea-refine/scripts/idea-refine.sh +15 -0
  282. package/.versions/0.0.4/vendor/agent-skills-upstream/skills/incremental-implementation/SKILL.md +249 -0
  283. package/.versions/0.0.4/vendor/agent-skills-upstream/skills/interview-me/SKILL.md +225 -0
  284. package/.versions/0.0.4/vendor/agent-skills-upstream/skills/observability-and-instrumentation/SKILL.md +203 -0
  285. package/.versions/0.0.4/vendor/agent-skills-upstream/skills/performance-optimization/SKILL.md +350 -0
  286. package/.versions/0.0.4/vendor/agent-skills-upstream/skills/planning-and-task-breakdown/SKILL.md +234 -0
  287. package/.versions/0.0.4/vendor/agent-skills-upstream/skills/security-and-hardening/SKILL.md +467 -0
  288. package/.versions/0.0.4/vendor/agent-skills-upstream/skills/shipping-and-launch/SKILL.md +310 -0
  289. package/.versions/0.0.4/vendor/agent-skills-upstream/skills/source-driven-development/SKILL.md +194 -0
  290. package/.versions/0.0.4/vendor/agent-skills-upstream/skills/spec-driven-development/SKILL.md +206 -0
  291. package/.versions/0.0.4/vendor/agent-skills-upstream/skills/test-driven-development/SKILL.md +383 -0
  292. package/.versions/0.0.4/vendor/agent-skills-upstream/skills/using-agent-skills/SKILL.md +191 -0
  293. package/CHANGELOG.md +53 -0
  294. package/README.md +103 -541
  295. package/agents/architect.md +1 -1
  296. package/agents/builder.md +1 -1
  297. package/agents/code-reviewer.md +1 -1
  298. package/agents/deep-researcher.md +3 -3
  299. package/agents/orchestrator.md +20 -11
  300. package/agents/plan-reviewer.md +3 -3
  301. package/agents/planner.md +1 -1
  302. package/agents/security-auditor.md +1 -1
  303. package/agents/test-engineer.md +11 -4
  304. package/bin/lib/validate-overrides.js +19 -0
  305. package/bin/snapshot-version.js +17 -1
  306. package/bin/sync-harness-versions.js +94 -0
  307. package/codex/CONDUCTOR.md +148 -0
  308. package/docs/ARCHITECTURE.md +210 -0
  309. package/docs/agent-fleet-setup.md +11 -0
  310. package/docs/claude-code-coms-bridge.md +10 -0
  311. package/docs/codex-remote-conductor.md +170 -0
  312. package/docs/coms-hermes-bridge.md +121 -0
  313. package/docs/getting-started.md +14 -0
  314. package/docs/npm-install.md +2 -0
  315. package/docs/pi-extensions.md +49 -14
  316. package/docs/pi-setup.md +12 -4
  317. package/hermes/README.md +228 -0
  318. package/hermes/desktop-plugins/agent-fleet-monitor/plugin.js +19 -0
  319. package/hermes/desktop-plugins/agent-fleet-monitor/state.js +10 -0
  320. package/hermes/plugins/agent-fleet-monitor/dashboard/adapter-cap.test.py +15 -0
  321. package/hermes/plugins/agent-fleet-monitor/dashboard/adapter-discovery.test.py +19 -0
  322. package/hermes/plugins/agent-fleet-monitor/dashboard/adapter-envelope.test.py +13 -0
  323. package/hermes/plugins/agent-fleet-monitor/dashboard/adapter-forged-owner.test.py +11 -0
  324. package/hermes/plugins/agent-fleet-monitor/dashboard/adapter-lease-list.test.py +9 -0
  325. package/hermes/plugins/agent-fleet-monitor/dashboard/adapter-multihub.test.py +17 -0
  326. package/hermes/plugins/agent-fleet-monitor/dashboard/adapter-output.test.py +34 -0
  327. package/hermes/plugins/agent-fleet-monitor/dashboard/adapter.py +151 -0
  328. package/hermes/plugins/agent-fleet-monitor/dashboard/adapter.test.py +39 -0
  329. package/hermes/plugins/agent-fleet-monitor/dashboard/dist/index.js +10 -0
  330. package/hermes/plugins/agent-fleet-monitor/dashboard/manifest.json +11 -0
  331. package/hermes/plugins/agent-fleet-monitor/dashboard/plugin-api-validation.test.py +12 -0
  332. package/hermes/plugins/agent-fleet-monitor/dashboard/plugin_api.py +50 -0
  333. package/hermes/plugins/agent-fleet-monitor/dashboard/review-live-wiring.red.test.py +22 -0
  334. package/hermes/skills/hub-conductor/SKILL.md +84 -0
  335. package/hermes/skills/hub-liaison/SKILL.md +84 -0
  336. package/justfile +106 -23
  337. package/package.json +17 -5
  338. package/scripts/codex-conductor.ts +41 -0
  339. package/scripts/codex-remote-control.ts +167 -0
  340. package/scripts/coms-cli.ts +311 -199
  341. package/scripts/coms-hermes-bridge.ts +2 -2
  342. package/scripts/lib/codex-conductor.ts +88 -0
  343. package/scripts/lib/codex-remote-control.ts +480 -0
  344. package/scripts/lib/coms-envelope.ts +51 -6
  345. package/scripts/lib/fake-herdr-server.ts +88 -0
  346. package/scripts/lib/herdr-layout.ts +18 -3
  347. package/scripts/lib/hermes-bridge-core.ts +4 -4
  348. package/scripts/lib/hermes-monitor-herdr.ts +28 -0
  349. package/scripts/lib/hermes-monitor-model.ts +9 -0
  350. package/scripts/lib/hermes-monitor-registry.ts +6 -0
  351. package/scripts/lib/hermes-monitor-socket.ts +118 -0
  352. package/scripts/lib/hermes-monitor-store.ts +31 -0
  353. package/scripts/lib/team-project.ts +85 -1
  354. package/scripts/team-up.ts +77 -18
  355. package/skills/designing-agents/SKILL.md +2 -2
  356. package/skills/designing-agents/pi-harness-authoring.md +26 -13
  357. package/skills/guided-workspace-setup/SKILL.md +131 -102
  358. package/skills/guided-workspace-setup/companion-manifest.json +33 -0
  359. package/skills/peer-coms/SKILL.md +9 -0
  360. package/systemd/user/agent-fleet-codex-remote-control.service.in +23 -0
  361. package/.pi/harnesses/damage-control/README.md +0 -65
  362. package/.pi/harnesses/damage-control/index.ts +0 -250
@@ -35,7 +35,7 @@ import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
35
35
  import { Type } from "@sinclair/typebox";
36
36
  import { appendFileSync, mkdirSync, writeFileSync } from "fs";
37
37
  import type { ChildProcess } from "child_process";
38
- import { spawnPiAgent } from "./spawn.ts";
38
+ import { spawnPiAgent, killPiTree } from "./spawn.ts";
39
39
  import {
40
40
  delegateBudgetRefusal,
41
41
  DELEGATE_TREE_SPAWN_BUDGET,
@@ -68,6 +68,10 @@ export interface DelegateConfig {
68
68
  eventDir: string;
69
69
  damageControl?: string;
70
70
  delegateExt: string;
71
+ /** Parent-side per-tool deadline inherited by every terminal child. */
72
+ reconSearchTimeoutMs?: number | null;
73
+ /** Whole-run deadline per delegate child (hub mode budget); null/absent = off. */
74
+ turnDeadlineMs?: number | null;
71
75
  cwd: string;
72
76
  }
73
77
 
@@ -139,9 +143,7 @@ export default function (pi: ExtensionAPI) {
139
143
  // signals the specialist's negative PID), but if only this process is
140
144
  // terminated, forward the signal to any live children.
141
145
  process.on("SIGTERM", () => {
142
- for (const child of liveChildren) {
143
- try { child.kill("SIGTERM"); } catch {}
144
- }
146
+ for (const child of liveChildren) killPiTree(child, "SIGTERM");
145
147
  });
146
148
 
147
149
  const emit = (event: Record<string, unknown>) => {
@@ -303,6 +305,16 @@ export default function (pi: ExtensionAPI) {
303
305
  extensions: childExtensions,
304
306
  env: childConfig ? { AGENT_HUB_DELEGATE_CONFIG: JSON.stringify(childConfig) } : undefined,
305
307
  cwd: config.cwd,
308
+ // Each nested child owns its group. The SIGTERM trap above forwards
309
+ // parent cancellation so detached children cannot become orphans.
310
+ detached: true,
311
+ signal: _signal,
312
+ // `null` is the explicit `off` override; preserve it rather than
313
+ // silently restoring the default for terminal children.
314
+ toolWatchdog: { timeoutMs: config.reconSearchTimeoutMs === undefined ? 120_000 : config.reconSearchTimeoutMs },
315
+ // Whole-run bound from the hub's mode budget: a hung delegate (the
316
+ // 92-minute conventions scout) must not hold its parent hostage.
317
+ turnDeadlineMs: config.turnDeadlineMs === undefined ? null : config.turnDeadlineMs,
306
318
  }, {
307
319
  onProcess: (p) => { childProc = p; liveChildren.add(p); },
308
320
  onTextDelta: (delta) => queueDelta("text", delta),
@@ -325,8 +337,8 @@ export default function (pi: ExtensionAPI) {
325
337
 
326
338
  flushTimeline();
327
339
  const elapsed = Date.now() - startTime;
328
- const code = res.spawnError ? 1 : (res.exitCode ?? 1);
329
- emit({ t: "exit", id: childId, code, elapsed, ts: Date.now() });
340
+ const code = res.spawnError ? 1 : (res.termination ? (res.termination.reason === "cancelled" ? 130 : res.termination.reason === "drift_stop" ? 125 : 124) : (res.exitCode ?? 1));
341
+ emit({ t: "exit", id: childId, code, elapsed, termination: res.termination, ts: Date.now() });
330
342
 
331
343
  if (res.spawnError) {
332
344
  const spawnFailure = `Delegate ${childId} failed to spawn: ${res.spawnError}`;
@@ -338,7 +350,18 @@ export default function (pi: ExtensionAPI) {
338
350
  }
339
351
 
340
352
  let output = res.output;
341
- if (code !== 0) {
353
+ if (res.termination) {
354
+ const reason = res.termination.reason;
355
+ const tool = res.termination.tool;
356
+ const explanation = reason === "tool_timeout"
357
+ ? `exceeded its per-tool watchdog on ${tool?.toolName || "tool"} (${tool?.toolCallId || "unknown"})`
358
+ : reason === "turn_timeout"
359
+ ? "exceeded the per-run deadline (mode budget / agent-turn-timeout-s)"
360
+ : reason === "drift_stop"
361
+ ? "was stopped by the drift watchdog"
362
+ : "was cancelled by its caller";
363
+ output = `${reason}: delegate ${childId} ${explanation}; terminationConfirmed=${res.termination.confirmed}.`;
364
+ } else if (code !== 0) {
342
365
  const errTail = res.stderr.trim().slice(-1000);
343
366
  output = output
344
367
  ? `${output}\n\n[stderr]\n${errTail}`
@@ -354,9 +377,9 @@ export default function (pi: ExtensionAPI) {
354
377
 
355
378
  return {
356
379
  content: [{ type: "text" as const, text:
357
- `[delegate ${childId} · ${roleDef.model} · ${effectiveTools}] ${code === 0 ? "done" : "error"} ` +
380
+ `[delegate ${childId} · ${roleDef.model} · ${effectiveTools}] ${res.termination ? res.termination.reason : code === 0 ? "done" : "error"} ` +
358
381
  `in ${Math.round(elapsed / 1000)}s${noteBlock}\n\n${digest.text}` }],
359
- details: { id: childId, role: roleKey, model: roleDef.model, status: code === 0 ? "done" : "error", elapsed, resultPath: childResultFile, digestFound: digest.hasDigest },
382
+ details: { id: childId, role: roleKey, model: roleDef.model, status: res.termination ? res.termination.reason : code === 0 ? "done" : "error", elapsed, resultPath: childResultFile, digestFound: digest.hasDigest, termination: res.termination },
360
383
  };
361
384
  },
362
385
  });
@@ -0,0 +1,165 @@
1
+ // Drift watchdog — the pure policy core behind in-flight specialist
2
+ // observation. Layer 1 is deterministic rules over the child's tool event
3
+ // stream (zero tokens); a firing rule is an ESCALATION SIGNAL, not a verdict —
4
+ // the harness then asks a cheap LLM judge (layer 2) whether the run is still
5
+ // on task, and only a DRIFTING/STUCK verdict terminates it (`drift_stop`).
6
+ // Everything here is data + pure functions so the policy is unit-testable
7
+ // away from the harness.
8
+
9
+ import { checkScope } from "./scope-gate.js";
10
+
11
+ export const WATCHDOG_SETTINGS = ["on", "off", "auto"];
12
+ export const DEFAULT_WATCHDOG_SETTING = "auto";
13
+
14
+ /** "On", " AUTO " → canonical setting, or null when unrecognized. */
15
+ export function normalizeWatchdogSetting(value) {
16
+ const v = String(value ?? "").trim().toLowerCase();
17
+ return WATCHDOG_SETTINGS.includes(v) ? v : null;
18
+ }
19
+
20
+ /**
21
+ * Is the watchdog armed for one dispatch? Precedence: the dispatch_agent
22
+ * `watchdog` param (boolean) > the per-agent /watchdog override ("on"/"off")
23
+ * > the hub-wide setting ("on"/"auto" arm, "off" disarms).
24
+ */
25
+ export function resolveWatchdogActive(dispatchParam, agentOverride, hubSetting) {
26
+ if (dispatchParam === true) return true;
27
+ if (dispatchParam === false) return false;
28
+ if (agentOverride === "on") return true;
29
+ if (agentOverride === "off") return false;
30
+ return normalizeWatchdogSetting(hubSetting) !== "off";
31
+ }
32
+
33
+ // Conservative thresholds: a false positive kills a productive run, so every
34
+ // rule needs sustained evidence before it fires.
35
+ export const DRIFT_DEFAULTS = {
36
+ writeTools: ["write", "edit"],
37
+ maxRepeats: 4,
38
+ maxConsecutiveFailures: 5,
39
+ maxToolCalls: 200,
40
+ trailLimit: 60,
41
+ };
42
+
43
+ const pathFromArgs = (argStr) => {
44
+ try {
45
+ const args = JSON.parse(argStr || "{}");
46
+ for (const key of ["path", "file_path", "filePath", "file", "filename"]) {
47
+ if (typeof args[key] === "string" && args[key].trim()) return args[key].trim();
48
+ }
49
+ } catch {}
50
+ return null;
51
+ };
52
+
53
+ /**
54
+ * Per-run monitor fed from the tool event stream. `onToolStart(tool, argStr)`
55
+ * and `onToolEnd(tool, isError)` return `null` while the run looks healthy, or
56
+ * `{ rule, detail }` when a rule crosses its threshold:
57
+ * scope — a write-capable tool touched a path outside the declared scope
58
+ * loop — the exact same (tool, args) call repeated maxRepeats times
59
+ * failures — maxConsecutiveFailures failed tool calls in a row
60
+ * toolcap — maxToolCalls total tool calls in one run
61
+ * Each rule instance fires once (at the crossing), so the caller escalates —
62
+ * it never gets spammed. `trail(n)` returns the recent tool trail for the judge.
63
+ */
64
+ export function createDriftMonitor(cfg = {}) {
65
+ const scopeGlobs = (cfg.scopeGlobs || []).filter(Boolean);
66
+ const writeTools = new Set(cfg.writeTools || DRIFT_DEFAULTS.writeTools);
67
+ const maxRepeats = cfg.maxRepeats ?? DRIFT_DEFAULTS.maxRepeats;
68
+ const maxConsecutiveFailures = cfg.maxConsecutiveFailures ?? DRIFT_DEFAULTS.maxConsecutiveFailures;
69
+ const maxToolCalls = cfg.maxToolCalls ?? DRIFT_DEFAULTS.maxToolCalls;
70
+ const trailLimit = cfg.trailLimit ?? DRIFT_DEFAULTS.trailLimit;
71
+
72
+ const callCounts = new Map();
73
+ const trailLines = [];
74
+ let totalCalls = 0;
75
+ let consecutiveFailures = 0;
76
+
77
+ const pushTrail = (line) => {
78
+ trailLines.push(line);
79
+ if (trailLines.length > trailLimit) trailLines.shift();
80
+ };
81
+
82
+ return {
83
+ onToolStart(toolName, argStr) {
84
+ totalCalls++;
85
+ pushTrail(`${toolName} ${String(argStr || "").slice(0, 120)}`.trim());
86
+
87
+ if (scopeGlobs.length > 0 && writeTools.has(toolName)) {
88
+ const path = pathFromArgs(argStr);
89
+ if (path && checkScope([path], scopeGlobs).outOfScope.length > 0) {
90
+ return { rule: "scope", detail: `${toolName} touched ${path} — outside the declared scope (${scopeGlobs.join(", ")})` };
91
+ }
92
+ }
93
+
94
+ const fingerprint = `${toolName}::${argStr || ""}`;
95
+ const count = (callCounts.get(fingerprint) || 0) + 1;
96
+ callCounts.set(fingerprint, count);
97
+ if (count === maxRepeats) {
98
+ return { rule: "loop", detail: `${toolName} called ${count}× with identical arguments — likely stuck in a loop` };
99
+ }
100
+
101
+ if (totalCalls === maxToolCalls) {
102
+ return { rule: "toolcap", detail: `${totalCalls} tool calls in one run — far beyond a focused task` };
103
+ }
104
+ return null;
105
+ },
106
+
107
+ onToolEnd(_toolName, isError) {
108
+ if (isError === true) {
109
+ consecutiveFailures++;
110
+ pushTrail(" ↳ FAILED");
111
+ if (consecutiveFailures % maxConsecutiveFailures === 0) {
112
+ return { rule: "failures", detail: `${consecutiveFailures} consecutive failed tool calls — no forward progress` };
113
+ }
114
+ } else if (isError === false) {
115
+ consecutiveFailures = 0;
116
+ }
117
+ // isError undefined: the stream carries no error flag — rule stays inert.
118
+ return null;
119
+ },
120
+
121
+ trail(n = 40) {
122
+ return trailLines.slice(-n);
123
+ },
124
+ };
125
+ }
126
+
127
+ /**
128
+ * The one-shot judge prompt: original task + declared scope + recent trail +
129
+ * the rule that fired. The judge answers with a single machine-parseable line.
130
+ */
131
+ export function buildJudgePrompt({ agent, task, scopeGlobs = [], trail = [], violation }) {
132
+ const scopeBlock = scopeGlobs.length > 0
133
+ ? `\n## Declared file scope\n${scopeGlobs.map(s => `- ${s}`).join("\n")}\n`
134
+ : "";
135
+ return `You are a drift watchdog judging whether a running coding agent is still on task.
136
+ Do not solve the task. Judge only whether the agent's recent actions serve it.
137
+
138
+ ## Agent
139
+ ${agent}
140
+
141
+ ## Original task (verbatim)
142
+ ${task}
143
+ ${scopeBlock}
144
+ ## Escalation signal
145
+ Rule "${violation?.rule || "unknown"}" fired: ${violation?.detail || "(no detail)"}
146
+
147
+ ## Recent tool trail (oldest first)
148
+ ${trail.length > 0 ? trail.join("\n") : "(no tool calls recorded)"}
149
+
150
+ ## Your answer
151
+ Reply with EXACTLY one line, nothing else:
152
+ VERDICT: ON_TRACK — <why the actions still serve the task>
153
+ VERDICT: DRIFTING — <what the agent is doing instead of the task>
154
+ VERDICT: STUCK — <the loop or dead end it cannot escape>
155
+ Prefer ON_TRACK unless the trail clearly contradicts the task: false alarms kill
156
+ productive work.`;
157
+ }
158
+
159
+ /** Parse the judge's reply. Returns { verdict, reason } or null when unparseable. */
160
+ export function parseJudgeVerdict(text) {
161
+ const matches = [...String(text ?? "").matchAll(/VERDICT:\s*(ON_TRACK|DRIFTING|STUCK)\s*(?:[—:-]\s*(.*))?/gi)];
162
+ if (matches.length === 0) return null;
163
+ const last = matches[matches.length - 1];
164
+ return { verdict: last[1].toLowerCase(), reason: (last[2] || "").trim() };
165
+ }
@@ -0,0 +1,29 @@
1
+ type FooterTheme = {
2
+ fg(color: string, text: string): string;
3
+ };
4
+
5
+ export function composeHubFooterLeft(
6
+ version: string | null,
7
+ model: string,
8
+ thinkingSuffix: string,
9
+ team: string,
10
+ ): string {
11
+ return [version ? `v${version}` : "", `${model}${thinkingSuffix}`, team]
12
+ .filter(Boolean)
13
+ .join(" · ");
14
+ }
15
+
16
+ export function renderHubFooterLeft(
17
+ theme: FooterTheme,
18
+ version: string | null,
19
+ model: string,
20
+ thinkingSuffix: string,
21
+ team: string,
22
+ ): string {
23
+ const metadata = [version ? `v${version}` : "", `${model}${thinkingSuffix}`]
24
+ .filter(Boolean)
25
+ .join(" · ");
26
+ const dimMetadata = theme.fg("dim", ` ${metadata}`);
27
+ const separator = metadata && team ? theme.fg("muted", " · ") : "";
28
+ return dimMetadata + separator + (team ? theme.fg("accent", team) : "");
29
+ }
@@ -25,6 +25,55 @@ export function parseTeamsYaml(raw: string): Record<string, string[]> {
25
25
  return teams;
26
26
  }
27
27
 
28
+ // Normalize a dispatcher-supplied agent name to the persona-slug key space:
29
+ // display names ("Test Engineer"), underscores, and stray whitespace all resolve
30
+ // to the same key the hub stores states under ("test-engineer").
31
+ export function normalizeAgentInput(value: string): string {
32
+ return String(value ?? "").trim().toLowerCase().replace(/[\s_]+/g, "-");
33
+ }
34
+
35
+ // Duplicate-dispatch guard: one fingerprint per (agent, task) where the task
36
+ // text is normalized hard (case, whitespace, punctuation) so trivial rewording
37
+ // still collides. Genuinely different tasks differ in their words, not their
38
+ // commas.
39
+ export function taskFingerprint(agent: string, task: string): string {
40
+ const normalizedTask = String(task ?? "")
41
+ .toLowerCase()
42
+ .replace(/[^\p{L}\p{N}]+/gu, " ")
43
+ .trim()
44
+ .replace(/\s+/g, " ");
45
+ return `${normalizeAgentInput(agent)}::${normalizedTask}`;
46
+ }
47
+
48
+ // Replace one team's block in teams.yaml text (or append it) without touching
49
+ // comments or other teams — a full re-serialize would destroy the file's
50
+ // header comments. The block is `name:` plus its ` - member` lines.
51
+ export function upsertTeamInYaml(raw: string, name: string, members: string[]): string {
52
+ const block = `${name}:\n${members.map(m => ` - ${m}`).join("\n")}\n`;
53
+ const lines = String(raw ?? "").split("\n");
54
+ let start = -1;
55
+ let end = -1;
56
+ for (let i = 0; i < lines.length; i++) {
57
+ const teamMatch = lines[i].match(/^(\S[^:]*):\s*$/);
58
+ if (start === -1) {
59
+ if (teamMatch && teamMatch[1].trim() === name) start = i;
60
+ continue;
61
+ }
62
+ // Inside the target block: it ends at the next top-level key or a
63
+ // top-level comment (comments are never deleted, only members are).
64
+ if (teamMatch || /^#/.test(lines[i])) { end = i; break; }
65
+ }
66
+ if (start === -1) {
67
+ const body = String(raw ?? "");
68
+ const sep = body.length === 0 || body.endsWith("\n\n") ? "" : body.endsWith("\n") ? "\n" : "\n\n";
69
+ return body + sep + block;
70
+ }
71
+ if (end === -1) end = lines.length;
72
+ // Keep blank/comment lines that trail the block attached to the NEXT section.
73
+ while (end - 1 > start && lines[end - 1].trim() === "") end--;
74
+ return [...lines.slice(0, start), ...block.split("\n").slice(0, -1), ...lines.slice(end)].join("\n");
75
+ }
76
+
28
77
  export function safeAgentKey(value: string): string {
29
78
  if (typeof value !== "string") {
30
79
  throw new Error("Agent key must be a string");