hivemind-context-governance 2.6.2 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (401) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +225 -208
  3. package/agents/build.md +198 -0
  4. package/agents/code-review.md +217 -0
  5. package/agents/debug.md +284 -0
  6. package/agents/explore.md +195 -0
  7. package/agents/hivefiver.md +107 -0
  8. package/agents/hivemind-brownfield-orchestrator.md +410 -12
  9. package/agents/hiveminder.md +487 -0
  10. package/agents/scanner.md +235 -0
  11. package/commands/hivefiver-architect.md +18 -0
  12. package/commands/hivefiver-audit.md +18 -0
  13. package/commands/hivefiver-build.md +18 -0
  14. package/commands/hivefiver-deploy.md +17 -0
  15. package/commands/hivefiver-doctor.md +40 -0
  16. package/commands/hivefiver-gsd-bridge.md +29 -0
  17. package/commands/hivefiver-init.md +18 -0
  18. package/commands/hivefiver-intake.md +49 -0
  19. package/commands/hivefiver-ralph-bridge.md +40 -0
  20. package/commands/hivefiver-research.md +56 -0
  21. package/commands/hivefiver-skillforge.md +41 -0
  22. package/commands/hivefiver-spec.md +18 -0
  23. package/commands/hivefiver-specforge.md +53 -0
  24. package/commands/hivefiver-start.md +54 -0
  25. package/commands/hivefiver-tutor.md +36 -0
  26. package/commands/hivefiver-validate.md +18 -0
  27. package/commands/hivefiver-workflow.md +17 -0
  28. package/commands/hivefiver.md +64 -0
  29. package/commands/hivemind-clarify.md +149 -0
  30. package/commands/hivemind-context.md +171 -0
  31. package/commands/hivemind-dashboard.md +39 -0
  32. package/commands/hivemind-debug-trigger.md +136 -0
  33. package/commands/hivemind-debug-verify.md +106 -0
  34. package/commands/hivemind-delegate.md +197 -0
  35. package/commands/hivemind-lint.md +92 -0
  36. package/commands/hivemind-pre-stop.md +183 -0
  37. package/commands/hiveminder-orchestrate.md +177 -0
  38. package/dist/cli/init.d.ts +3 -1
  39. package/dist/cli/init.d.ts.map +1 -1
  40. package/dist/cli/init.js +347 -6
  41. package/dist/cli/init.js.map +1 -1
  42. package/dist/cli/interactive-init.d.ts.map +1 -1
  43. package/dist/cli/interactive-init.js +57 -6
  44. package/dist/cli/interactive-init.js.map +1 -1
  45. package/dist/cli/scan.d.ts.map +1 -1
  46. package/dist/cli/scan.js +11 -5
  47. package/dist/cli/scan.js.map +1 -1
  48. package/dist/cli/sync-assets.d.ts.map +1 -1
  49. package/dist/cli/sync-assets.js +21 -1
  50. package/dist/cli/sync-assets.js.map +1 -1
  51. package/dist/cli.js +66 -14
  52. package/dist/cli.js.map +1 -1
  53. package/dist/dashboard/App.d.ts +9 -0
  54. package/dist/dashboard/App.d.ts.map +1 -0
  55. package/dist/dashboard/App.js +155 -0
  56. package/dist/dashboard/App.js.map +1 -0
  57. package/dist/dashboard/bin.d.ts +17 -0
  58. package/dist/dashboard/bin.d.ts.map +1 -0
  59. package/dist/dashboard/bin.js +55 -0
  60. package/dist/dashboard/bin.js.map +1 -0
  61. package/dist/dashboard/components/AutonomicLog.d.ts +9 -0
  62. package/dist/dashboard/components/AutonomicLog.d.ts.map +1 -0
  63. package/dist/dashboard/components/AutonomicLog.js +29 -0
  64. package/dist/dashboard/components/AutonomicLog.js.map +1 -0
  65. package/dist/dashboard/components/InteractiveFooter.d.ts +7 -0
  66. package/dist/dashboard/components/InteractiveFooter.d.ts.map +1 -0
  67. package/dist/dashboard/components/InteractiveFooter.js +9 -0
  68. package/dist/dashboard/components/InteractiveFooter.js.map +1 -0
  69. package/dist/dashboard/components/MemCreationModal.d.ts +8 -0
  70. package/dist/dashboard/components/MemCreationModal.d.ts.map +1 -0
  71. package/dist/dashboard/components/MemCreationModal.js +13 -0
  72. package/dist/dashboard/components/MemCreationModal.js.map +1 -0
  73. package/dist/dashboard/components/SwarmMonitor.d.ts +7 -0
  74. package/dist/dashboard/components/SwarmMonitor.d.ts.map +1 -0
  75. package/dist/dashboard/components/SwarmMonitor.js +9 -0
  76. package/dist/dashboard/components/SwarmMonitor.js.map +1 -0
  77. package/dist/dashboard/components/TelemetryHeader.d.ts +11 -0
  78. package/dist/dashboard/components/TelemetryHeader.d.ts.map +1 -0
  79. package/dist/dashboard/components/TelemetryHeader.js +51 -0
  80. package/dist/dashboard/components/TelemetryHeader.js.map +1 -0
  81. package/dist/dashboard/components/TrajectoryPane.d.ts +10 -0
  82. package/dist/dashboard/components/TrajectoryPane.d.ts.map +1 -0
  83. package/dist/dashboard/components/TrajectoryPane.js +36 -0
  84. package/dist/dashboard/components/TrajectoryPane.js.map +1 -0
  85. package/dist/dashboard/design-tokens.d.ts +40 -0
  86. package/dist/dashboard/design-tokens.d.ts.map +1 -0
  87. package/dist/dashboard/design-tokens.js +43 -0
  88. package/dist/dashboard/design-tokens.js.map +1 -0
  89. package/dist/dashboard/i18n.d.ts +45 -0
  90. package/dist/dashboard/i18n.d.ts.map +1 -0
  91. package/dist/dashboard/i18n.js +83 -0
  92. package/dist/dashboard/i18n.js.map +1 -0
  93. package/dist/dashboard/loader.d.ts +3 -0
  94. package/dist/dashboard/loader.d.ts.map +1 -0
  95. package/dist/dashboard/loader.js +198 -0
  96. package/dist/dashboard/loader.js.map +1 -0
  97. package/dist/dashboard/server.d.ts +2 -76
  98. package/dist/dashboard/server.d.ts.map +1 -1
  99. package/dist/dashboard/server.js +6 -411
  100. package/dist/dashboard/server.js.map +1 -1
  101. package/dist/dashboard/types.d.ts +48 -0
  102. package/dist/dashboard/types.d.ts.map +1 -0
  103. package/dist/dashboard/types.js +2 -0
  104. package/dist/dashboard/types.js.map +1 -0
  105. package/dist/dashboard/views/SwarmOrchestratorView.d.ts +7 -0
  106. package/dist/dashboard/views/SwarmOrchestratorView.d.ts.map +1 -0
  107. package/dist/dashboard/views/SwarmOrchestratorView.js +11 -0
  108. package/dist/dashboard/views/SwarmOrchestratorView.js.map +1 -0
  109. package/dist/dashboard/views/TimeTravelDebuggerView.d.ts +7 -0
  110. package/dist/dashboard/views/TimeTravelDebuggerView.d.ts.map +1 -0
  111. package/dist/dashboard/views/TimeTravelDebuggerView.js +11 -0
  112. package/dist/dashboard/views/TimeTravelDebuggerView.js.map +1 -0
  113. package/dist/dashboard/views/ToolRegistryView.d.ts +7 -0
  114. package/dist/dashboard/views/ToolRegistryView.d.ts.map +1 -0
  115. package/dist/dashboard/views/ToolRegistryView.js +11 -0
  116. package/dist/dashboard/views/ToolRegistryView.js.map +1 -0
  117. package/dist/hooks/compaction.d.ts +1 -1
  118. package/dist/hooks/compaction.d.ts.map +1 -1
  119. package/dist/hooks/compaction.js +50 -9
  120. package/dist/hooks/compaction.js.map +1 -1
  121. package/dist/hooks/event-handler.d.ts +3 -3
  122. package/dist/hooks/event-handler.d.ts.map +1 -1
  123. package/dist/hooks/event-handler.js +188 -59
  124. package/dist/hooks/event-handler.js.map +1 -1
  125. package/dist/hooks/messages-transform.d.ts +11 -0
  126. package/dist/hooks/messages-transform.d.ts.map +1 -1
  127. package/dist/hooks/messages-transform.js +341 -97
  128. package/dist/hooks/messages-transform.js.map +1 -1
  129. package/dist/hooks/sdk-context.d.ts.map +1 -1
  130. package/dist/hooks/sdk-context.js +29 -2
  131. package/dist/hooks/sdk-context.js.map +1 -1
  132. package/dist/hooks/session-lifecycle.d.ts +1 -17
  133. package/dist/hooks/session-lifecycle.d.ts.map +1 -1
  134. package/dist/hooks/session-lifecycle.js +106 -418
  135. package/dist/hooks/session-lifecycle.js.map +1 -1
  136. package/dist/hooks/session_coherence/index.d.ts +7 -0
  137. package/dist/hooks/session_coherence/index.d.ts.map +1 -0
  138. package/dist/hooks/session_coherence/index.js +7 -0
  139. package/dist/hooks/session_coherence/index.js.map +1 -0
  140. package/dist/hooks/session_coherence/main_session_start.d.ts +45 -0
  141. package/dist/hooks/session_coherence/main_session_start.d.ts.map +1 -0
  142. package/dist/hooks/session_coherence/main_session_start.js +145 -0
  143. package/dist/hooks/session_coherence/main_session_start.js.map +1 -0
  144. package/dist/hooks/session_coherence/types.d.ts +96 -0
  145. package/dist/hooks/session_coherence/types.d.ts.map +1 -0
  146. package/dist/hooks/session_coherence/types.js +18 -0
  147. package/dist/hooks/session_coherence/types.js.map +1 -0
  148. package/dist/hooks/soft-governance.d.ts.map +1 -1
  149. package/dist/hooks/soft-governance.js +42 -124
  150. package/dist/hooks/soft-governance.js.map +1 -1
  151. package/dist/hooks/swarm-executor.d.ts +24 -0
  152. package/dist/hooks/swarm-executor.d.ts.map +1 -0
  153. package/dist/hooks/swarm-executor.js +83 -0
  154. package/dist/hooks/swarm-executor.js.map +1 -0
  155. package/dist/hooks/tool-gate.d.ts +24 -0
  156. package/dist/hooks/tool-gate.d.ts.map +1 -1
  157. package/dist/hooks/tool-gate.js +53 -4
  158. package/dist/hooks/tool-gate.js.map +1 -1
  159. package/dist/index.d.ts +8 -2
  160. package/dist/index.d.ts.map +1 -1
  161. package/dist/index.js +26 -14
  162. package/dist/index.js.map +1 -1
  163. package/dist/lib/anchors.d.ts +2 -0
  164. package/dist/lib/anchors.d.ts.map +1 -1
  165. package/dist/lib/anchors.js +9 -0
  166. package/dist/lib/anchors.js.map +1 -1
  167. package/dist/lib/auto-context.d.ts +159 -0
  168. package/dist/lib/auto-context.d.ts.map +1 -0
  169. package/dist/lib/auto-context.js +286 -0
  170. package/dist/lib/auto-context.js.map +1 -0
  171. package/dist/lib/brownfield-scan.d.ts +15 -0
  172. package/dist/lib/brownfield-scan.d.ts.map +1 -0
  173. package/dist/lib/brownfield-scan.js +323 -0
  174. package/dist/lib/brownfield-scan.js.map +1 -0
  175. package/dist/lib/budget.d.ts +35 -0
  176. package/dist/lib/budget.d.ts.map +1 -0
  177. package/dist/lib/budget.js +35 -0
  178. package/dist/lib/budget.js.map +1 -0
  179. package/dist/lib/cognitive-packer.d.ts +40 -0
  180. package/dist/lib/cognitive-packer.d.ts.map +1 -0
  181. package/dist/lib/cognitive-packer.js +399 -0
  182. package/dist/lib/cognitive-packer.js.map +1 -0
  183. package/dist/lib/compaction-engine.d.ts +61 -0
  184. package/dist/lib/compaction-engine.d.ts.map +1 -0
  185. package/dist/lib/compaction-engine.js +314 -0
  186. package/dist/lib/compaction-engine.js.map +1 -0
  187. package/dist/lib/event-bus.d.ts +55 -0
  188. package/dist/lib/event-bus.d.ts.map +1 -0
  189. package/dist/lib/event-bus.js +96 -0
  190. package/dist/lib/event-bus.js.map +1 -0
  191. package/dist/lib/file-lock.d.ts +36 -0
  192. package/dist/lib/file-lock.d.ts.map +1 -0
  193. package/dist/lib/file-lock.js +38 -0
  194. package/dist/lib/file-lock.js.map +1 -0
  195. package/dist/lib/gatekeeper.d.ts +49 -0
  196. package/dist/lib/gatekeeper.d.ts.map +1 -0
  197. package/dist/lib/gatekeeper.js +109 -0
  198. package/dist/lib/gatekeeper.js.map +1 -0
  199. package/dist/lib/governance-instruction.d.ts +16 -0
  200. package/dist/lib/governance-instruction.d.ts.map +1 -0
  201. package/dist/lib/governance-instruction.js +87 -0
  202. package/dist/lib/governance-instruction.js.map +1 -0
  203. package/dist/lib/graph-io.d.ts +110 -0
  204. package/dist/lib/graph-io.d.ts.map +1 -0
  205. package/dist/lib/graph-io.js +794 -0
  206. package/dist/lib/graph-io.js.map +1 -0
  207. package/dist/lib/graph-migrate.d.ts +162 -0
  208. package/dist/lib/graph-migrate.d.ts.map +1 -0
  209. package/dist/lib/graph-migrate.js +648 -0
  210. package/dist/lib/graph-migrate.js.map +1 -0
  211. package/dist/lib/hierarchy-tree.d.ts +15 -2
  212. package/dist/lib/hierarchy-tree.d.ts.map +1 -1
  213. package/dist/lib/hierarchy-tree.js +35 -10
  214. package/dist/lib/hierarchy-tree.js.map +1 -1
  215. package/dist/lib/hivefiver-integration.d.ts +54 -0
  216. package/dist/lib/hivefiver-integration.d.ts.map +1 -0
  217. package/dist/lib/hivefiver-integration.js +515 -0
  218. package/dist/lib/hivefiver-integration.js.map +1 -0
  219. package/dist/lib/index.d.ts +10 -0
  220. package/dist/lib/index.d.ts.map +1 -1
  221. package/dist/lib/index.js +10 -1
  222. package/dist/lib/index.js.map +1 -1
  223. package/dist/lib/inspect-engine.d.ts +96 -0
  224. package/dist/lib/inspect-engine.d.ts.map +1 -0
  225. package/dist/lib/inspect-engine.js +153 -0
  226. package/dist/lib/inspect-engine.js.map +1 -0
  227. package/dist/lib/manifest.d.ts +2 -0
  228. package/dist/lib/manifest.d.ts.map +1 -1
  229. package/dist/lib/manifest.js +5 -0
  230. package/dist/lib/manifest.js.map +1 -1
  231. package/dist/lib/mems.d.ts +12 -1
  232. package/dist/lib/mems.d.ts.map +1 -1
  233. package/dist/lib/mems.js +46 -3
  234. package/dist/lib/mems.js.map +1 -1
  235. package/dist/lib/onboarding.d.ts +35 -0
  236. package/dist/lib/onboarding.d.ts.map +1 -0
  237. package/dist/lib/onboarding.js +99 -0
  238. package/dist/lib/onboarding.js.map +1 -0
  239. package/dist/lib/orphan-quarantine.d.ts +25 -0
  240. package/dist/lib/orphan-quarantine.d.ts.map +1 -0
  241. package/dist/lib/orphan-quarantine.js +47 -0
  242. package/dist/lib/orphan-quarantine.js.map +1 -0
  243. package/dist/lib/paths.d.ts +10 -0
  244. package/dist/lib/paths.d.ts.map +1 -1
  245. package/dist/lib/paths.js +12 -0
  246. package/dist/lib/paths.js.map +1 -1
  247. package/dist/lib/persistence.d.ts.map +1 -1
  248. package/dist/lib/persistence.js +4 -0
  249. package/dist/lib/persistence.js.map +1 -1
  250. package/dist/lib/planning-fs.d.ts +1 -0
  251. package/dist/lib/planning-fs.d.ts.map +1 -1
  252. package/dist/lib/planning-fs.js +18 -2
  253. package/dist/lib/planning-fs.js.map +1 -1
  254. package/dist/lib/session-boundary.d.ts +17 -5
  255. package/dist/lib/session-boundary.d.ts.map +1 -1
  256. package/dist/lib/session-boundary.js +37 -13
  257. package/dist/lib/session-boundary.js.map +1 -1
  258. package/dist/lib/session-engine.d.ts +28 -0
  259. package/dist/lib/session-engine.d.ts.map +1 -0
  260. package/dist/lib/session-engine.js +477 -0
  261. package/dist/lib/session-engine.js.map +1 -0
  262. package/dist/lib/session-governance.d.ts +19 -0
  263. package/dist/lib/session-governance.d.ts.map +1 -0
  264. package/dist/lib/session-governance.js +218 -0
  265. package/dist/lib/session-governance.js.map +1 -0
  266. package/dist/lib/session-split.d.ts +37 -0
  267. package/dist/lib/session-split.d.ts.map +1 -0
  268. package/dist/lib/session-split.js +158 -0
  269. package/dist/lib/session-split.js.map +1 -0
  270. package/dist/lib/session-swarm.d.ts +80 -0
  271. package/dist/lib/session-swarm.d.ts.map +1 -0
  272. package/dist/lib/session-swarm.js +258 -0
  273. package/dist/lib/session-swarm.js.map +1 -0
  274. package/dist/lib/session_coherence.d.ts +93 -0
  275. package/dist/lib/session_coherence.d.ts.map +1 -0
  276. package/dist/lib/session_coherence.js +512 -0
  277. package/dist/lib/session_coherence.js.map +1 -0
  278. package/dist/lib/staleness.d.ts +43 -0
  279. package/dist/lib/staleness.d.ts.map +1 -1
  280. package/dist/lib/staleness.js +85 -0
  281. package/dist/lib/staleness.js.map +1 -1
  282. package/dist/lib/state-mutation-queue.d.ts +132 -0
  283. package/dist/lib/state-mutation-queue.d.ts.map +1 -0
  284. package/dist/lib/state-mutation-queue.js +296 -0
  285. package/dist/lib/state-mutation-queue.js.map +1 -0
  286. package/dist/lib/tool-activation.js +12 -12
  287. package/dist/lib/tool-activation.js.map +1 -1
  288. package/dist/lib/tool-response.d.ts +20 -0
  289. package/dist/lib/tool-response.d.ts.map +1 -0
  290. package/dist/lib/tool-response.js +21 -0
  291. package/dist/lib/tool-response.js.map +1 -0
  292. package/dist/lib/watcher.d.ts +67 -0
  293. package/dist/lib/watcher.d.ts.map +1 -0
  294. package/dist/lib/watcher.js +160 -0
  295. package/dist/lib/watcher.js.map +1 -0
  296. package/dist/schemas/brain-state.d.ts +12 -0
  297. package/dist/schemas/brain-state.d.ts.map +1 -1
  298. package/dist/schemas/brain-state.js +22 -4
  299. package/dist/schemas/brain-state.js.map +1 -1
  300. package/dist/schemas/config.d.ts +72 -0
  301. package/dist/schemas/config.d.ts.map +1 -1
  302. package/dist/schemas/config.js +89 -1
  303. package/dist/schemas/config.js.map +1 -1
  304. package/dist/schemas/events.d.ts +35 -0
  305. package/dist/schemas/events.d.ts.map +1 -0
  306. package/dist/schemas/events.js +31 -0
  307. package/dist/schemas/events.js.map +1 -0
  308. package/dist/schemas/graph-nodes.d.ts +187 -0
  309. package/dist/schemas/graph-nodes.d.ts.map +1 -0
  310. package/dist/schemas/graph-nodes.js +171 -0
  311. package/dist/schemas/graph-nodes.js.map +1 -0
  312. package/dist/schemas/graph-state.d.ts +82 -0
  313. package/dist/schemas/graph-state.d.ts.map +1 -0
  314. package/dist/schemas/graph-state.js +19 -0
  315. package/dist/schemas/graph-state.js.map +1 -0
  316. package/dist/schemas/index.d.ts +2 -0
  317. package/dist/schemas/index.d.ts.map +1 -1
  318. package/dist/schemas/index.js +2 -0
  319. package/dist/schemas/index.js.map +1 -1
  320. package/dist/schemas/manifest.d.ts +38 -0
  321. package/dist/schemas/manifest.d.ts.map +1 -1
  322. package/dist/tools/hivemind-anchor.d.ts.map +1 -1
  323. package/dist/tools/hivemind-anchor.js +40 -110
  324. package/dist/tools/hivemind-anchor.js.map +1 -1
  325. package/dist/tools/hivemind-cycle.d.ts.map +1 -1
  326. package/dist/tools/hivemind-cycle.js +44 -87
  327. package/dist/tools/hivemind-cycle.js.map +1 -1
  328. package/dist/tools/hivemind-hierarchy.d.ts.map +1 -1
  329. package/dist/tools/hivemind-hierarchy.js +47 -109
  330. package/dist/tools/hivemind-hierarchy.js.map +1 -1
  331. package/dist/tools/hivemind-inspect.d.ts +1 -1
  332. package/dist/tools/hivemind-inspect.d.ts.map +1 -1
  333. package/dist/tools/hivemind-inspect.js +19 -361
  334. package/dist/tools/hivemind-inspect.js.map +1 -1
  335. package/dist/tools/hivemind-memory.d.ts.map +1 -1
  336. package/dist/tools/hivemind-memory.js +215 -139
  337. package/dist/tools/hivemind-memory.js.map +1 -1
  338. package/dist/tools/hivemind-session.d.ts +0 -12
  339. package/dist/tools/hivemind-session.d.ts.map +1 -1
  340. package/dist/tools/hivemind-session.js +211 -492
  341. package/dist/tools/hivemind-session.js.map +1 -1
  342. package/dist/tools/index.d.ts +15 -22
  343. package/dist/tools/index.d.ts.map +1 -1
  344. package/dist/tools/index.js +15 -22
  345. package/dist/tools/index.js.map +1 -1
  346. package/dist/tools/map-context.d.ts.map +1 -1
  347. package/dist/tools/map-context.js +10 -2
  348. package/dist/tools/map-context.js.map +1 -1
  349. package/package.json +6 -6
  350. package/skills/context-first-gatekeeping/SKILL.md +261 -0
  351. package/skills/debug-orchestration/SKILL.md +304 -0
  352. package/skills/delegation-intelligence/SKILL.md +104 -10
  353. package/skills/hivefiver-bilingual-tutor/SKILL.md +35 -0
  354. package/skills/hivefiver-bilingual-tutor/references/terminology-en-vi.md +13 -0
  355. package/skills/hivefiver-bilingual-tutor/scripts/select-language.sh +12 -0
  356. package/skills/hivefiver-bilingual-tutor/templates/bilingual-output.md +13 -0
  357. package/skills/hivefiver-domain-pack-router/SKILL.md +36 -0
  358. package/skills/hivefiver-domain-pack-router/references/domain-pack-matrix.md +14 -0
  359. package/skills/hivefiver-domain-pack-router/templates/domain-pack-output.md +24 -0
  360. package/skills/hivefiver-gsd-compat/SKILL.md +28 -0
  361. package/skills/hivefiver-gsd-compat/references/gsd-lifecycle-map.md +11 -0
  362. package/skills/hivefiver-gsd-compat/scripts/generate-map-template.sh +23 -0
  363. package/skills/hivefiver-gsd-compat/templates/gsd-bridge-output.md +18 -0
  364. package/skills/hivefiver-mcp-research-loop/SKILL.md +52 -0
  365. package/skills/hivefiver-mcp-research-loop/references/provider-matrix.md +21 -0
  366. package/skills/hivefiver-mcp-research-loop/scripts/check-mcp-readiness.mjs +65 -0
  367. package/skills/hivefiver-mcp-research-loop/scripts/score-confidence.sh +20 -0
  368. package/skills/hivefiver-mcp-research-loop/templates/evidence-table.md +20 -0
  369. package/skills/hivefiver-persona-routing/SKILL.md +43 -0
  370. package/skills/hivefiver-persona-routing/references/persona-matrix.md +19 -0
  371. package/skills/hivefiver-persona-routing/scripts/score-persona.sh +48 -0
  372. package/skills/hivefiver-persona-routing/templates/intake-questionnaire.md +10 -0
  373. package/skills/hivefiver-ralph-tasking/SKILL.md +42 -0
  374. package/skills/hivefiver-ralph-tasking/references/prd-json-rules.md +32 -0
  375. package/skills/hivefiver-ralph-tasking/scripts/todo-to-prd-json.mjs +77 -0
  376. package/skills/hivefiver-ralph-tasking/scripts/validate-prd-json.mjs +125 -0
  377. package/skills/hivefiver-ralph-tasking/templates/prd-json-flat.md +24 -0
  378. package/skills/hivefiver-skill-auditor/SKILL.md +37 -0
  379. package/skills/hivefiver-skill-auditor/references/audit-checklist.md +23 -0
  380. package/skills/hivefiver-skill-auditor/references/skill-source-links.md +16 -0
  381. package/skills/hivefiver-skill-auditor/scripts/audit-skill-coverage.sh +82 -0
  382. package/skills/hivefiver-skill-auditor/templates/skill-audit-report.md +35 -0
  383. package/skills/hivefiver-spec-distillation/SKILL.md +37 -0
  384. package/skills/hivefiver-spec-distillation/references/ambiguity-taxonomy.md +21 -0
  385. package/skills/hivefiver-spec-distillation/scripts/extract-requirements.sh +48 -0
  386. package/skills/hivefiver-spec-distillation/templates/spec-candidate.md +23 -0
  387. package/skills/hivemind-architect-strategist/SKILL.md +317 -0
  388. package/skills/hivemind-governance/SKILL.md +63 -0
  389. package/skills/parallel-debugging-hivemind/SKILL.md +203 -0
  390. package/skills/sequential-orchestration/SKILL.md +284 -0
  391. package/skills/systematic-debugging-hivemind/SKILL.md +222 -0
  392. package/workflows/hivefiver-enterprise-architect.yaml +51 -0
  393. package/workflows/hivefiver-enterprise.yaml +56 -0
  394. package/workflows/hivefiver-floppy-engineer.yaml +41 -0
  395. package/workflows/hivefiver-mcp-fallback.yaml +31 -0
  396. package/workflows/hivefiver-vibecoder.yaml +46 -0
  397. package/workflows/sequential-delegation-workflow.yaml +218 -0
  398. package/docs/10-commandments.md +0 -202
  399. package/prompts/hivemind-brownfield-remediation.md +0 -14
  400. package/references/hivemind-brownfield-checklist.md +0 -17
  401. package/templates/hivemind-brownfield-session.md +0 -26
package/CHANGELOG.md CHANGED
@@ -33,6 +33,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
33
33
  - `README.md` fully rewritten: coherent install-to-runtime flow, upgrade guidance, troubleshooting, and expanded Vietnamese section focused on practical onboarding
34
34
  - `README.md` refreshed for Phase B: hook count/tool catalog accuracy, merged tool names, and new governance capabilities
35
35
 
36
+ ## [2.8.0] - 2026-02-19
37
+
38
+ ### Added
39
+ - Vietnamese-first launch framing in `README.md` with 10 demo-ready use cases for product launch narratives
40
+ - Public branch hardening policy in `scripts/guard-public-branch.sh` for internal/dev-only paths
41
+ - HiveFiver auto-realignment next-step policy (menu options + permission-gated execution for mutating actions)
42
+
43
+ ### Changed
44
+ - Release package boundary tightened for npm/npx distribution:
45
+ - hidden from public package payload: `docs`, `templates`, `prompts`, `references`
46
+ - retained public operational pack: `commands`, `skills`, `agents`, `workflows`
47
+ - Version bump to `2.8.0`
48
+
49
+ ### Verified
50
+ - Full typecheck, test suite, and clean rebuild validated for release readiness
51
+
36
52
  ## [2.6.0] - 2026-02-12
37
53
 
38
54
  ### Added
package/README.md CHANGED
@@ -2,7 +2,226 @@
2
2
 
3
3
  > **The operating system for AI coding sessions.**
4
4
 
5
- HiveMind is an [OpenCode](https://opencode.ai) plugin that prevents AI agents from drifting, forgetting, and losing coherence during long coding sessions. It enforces a simple backbone — *declare what you're doing, track as you go, archive when done* — and connects every piece into one unified system.
5
+ ## 🇻🇳 Bản phát hành v2.8 ưu tiên thị trường Việt Nam
6
+
7
+ HiveMind là plugin [OpenCode](https://opencode.ai) giúp AI agent không bị trôi ngữ cảnh, không quên quyết định kiến trúc, và không mất trạng thái khi session kéo dài. Trọng tâm v2.8: onboarding rõ ràng, governance chặt, và triển khai thực chiến cho team Việt Nam trước.
8
+
9
+ ### 10 kịch bản demo ấn tượng để ra mắt
10
+ 1. `SaaS 0→1 cho người không biết code`: menu hỏi đáp + auto-lane để ra PRD có thể triển khai.
11
+ 2. `Giải cứu prompt hỗn loạn của team enterprise`: bóc tách yêu cầu, ambiguity map, risk register.
12
+ 3. `War-room production incident`: ép agent đi theo checklist bằng chứng trước khi kết luận fix.
13
+ 4. `TDD autopilot`: agent chuyển tự động từ `spec -> build -> validate` với gate kiểm thử.
14
+ 5. `MCP-first research sprint`: phối hợp Context7/DeepWiki/Tavily/Exa/Repomix và chấm điểm confidence.
15
+ 6. `Brownfield modernization`: quét codebase cũ, lập workflow refactor theo từng lane và checkpoint.
16
+ 7. `Cross-domain planning`: cùng một khung cho dev + marketing + finance + office-ops.
17
+ 8. `Subagent swarm governance`: giao việc song song nhưng vẫn giữ được trace, export, và hồi cứu.
18
+ 9. `Bilingual coaching mode`: đầu ra EN/VI cùng cấu trúc, hỗ trợ onboarding team đa vai trò.
19
+ 10. `No-command recovery`: người dùng nói tự nhiên, hệ thống tự realign sang lệnh phù hợp và xin quyền bước tiếp theo.
20
+
21
+ # 🇻🇳 Hướng Dẫn Tiếng Việt (Chi Tiết)
22
+
23
+ > *Phần này không phải bản dịch — mà được viết riêng cho người dùng Việt Nam, với giải thích kỹ hơn về cách hoạt động và lý do tại sao.*
24
+
25
+ **Cảm thấy hữu ích?** [![Mời cà phê](https://img.shields.io/badge/Mời%20cà%20phê-ủng%20hộ-orange?logo=buy-me-a-coffee&logoColor=white)](https://buymeacoffee.com/shynlee04l)
26
+
27
+ ## HiveMind Là Gì?
28
+
29
+ Hãy tưởng tượng bạn thuê một lập trình viên AI rất giỏi, nhưng anh ta có một vấn đề: **mỗi 30 phút anh ta quên hết mọi thứ đang làm**.
30
+
31
+ Đó chính xác là điều xảy ra với các AI coding agent hiện tại:
32
+ - Đang làm feature A, tự nhiên nhảy sang feature B mà không checkpoint
33
+ - Sau context compaction (khi hết bộ nhớ), quên hết lý do tại sao đã quyết định kiến trúc X
34
+ - Giao việc cho subagent, nhận kết quả nhưng không tổng hợp lại
35
+ - Session mới bắt đầu từ con số 0 — không biết gì về session trước
36
+
37
+ **HiveMind giải quyết tất cả** bằng một hệ thống quản trị context đơn giản nhưng hiệu quả.
38
+
39
+ ## Cách Hoạt Động (Giải Thích Dễ Hiểu)
40
+
41
+ Mỗi session làm việc với AI đều tuân theo một quy trình:
42
+
43
+ ```
44
+ declare_intent → map_context → [làm việc] → compact_session
45
+ (khai báo) (cập nhật) (code) (lưu trữ)
46
+ ```
47
+
48
+ ### Bước 1: Khai Báo Ý Định — `declare_intent`
49
+
50
+ Trước khi bắt đầu bất kỳ công việc nào, agent phải nói rõ:
51
+ - **Đang làm gì**: "Xây dựng hệ thống xác thực"
52
+ - **Làm theo cách nào**: `plan_driven` (có kế hoạch), `quick_fix` (sửa nhanh), hoặc `exploration` (tìm hiểu)
53
+
54
+ Nếu không khai báo, ở chế độ `strict` agent sẽ bị khóa — không thể ghi file cho đến khi khai báo. Điều này đảm bảo mọi công việc đều có mục tiêu rõ ràng.
55
+
56
+ ### Bước 2: Cập Nhật Ngữ Cảnh — `map_context`
57
+
58
+ Khi agent chuyển focus (ví dụ: từ "thiết kế database" sang "viết API"), nó phải gọi `map_context` để HiveMind biết. Hệ thống theo dõi 3 cấp:
59
+
60
+ | Cấp | Ý Nghĩa | Ví Dụ |
61
+ |-----|---------|-------|
62
+ | **Trajectory** | Mục tiêu lớn | "Xây dựng hệ thống thanh toán" |
63
+ | **Tactic** | Chiến thuật cụ thể | "Tích hợp Stripe API" |
64
+ | **Action** | Hành động đang làm | "Viết test cho webhook handler" |
65
+
66
+ Nếu agent làm nhiều turn mà không cập nhật, HiveMind phát hiện **drift** (trôi dạt) và cảnh báo ngay.
67
+
68
+ ### Bước 3: Lưu Trữ — `compact_session`
69
+
70
+ Khi xong việc, `compact_session` sẽ:
71
+ 1. Lưu toàn bộ session vào archive (có thể đọc lại)
72
+ 2. Ghi tóm tắt vào lịch sử dự án
73
+ 3. Reset để sẵn sàng cho session tiếp theo
74
+
75
+ **Quan trọng**: Mems Brain (bộ nhớ dài hạn) vẫn tồn tại sau compact. Những gì agent đã học được (`save_mem`) sẽ không bao giờ mất.
76
+
77
+ ## Cài Đặt Từ Đầu Đến Cuối
78
+
79
+ ### Một Lệnh - Xong Ngay
80
+
81
+ ```bash
82
+ npx hivemind-context-governance init
83
+ ```
84
+
85
+ **Điều gì sẽ xảy ra (đảm bảo):**
86
+ 1. Tự động tải từ npm (không cần cài thủ công)
87
+ 2. Tạo thư mục `.hivemind/` với brain.json, config.json
88
+ 3. Đăng ký plugin trong `opencode.json` (để OpenCode tự động load)
89
+ 4. Đồng bộ commands/skills vào `.opencode/`
90
+ 5. Tạo các file session template
91
+ 6. Mở session ở chế độ `OPEN` (assisted) hoặc `LOCKED` (strict)
92
+
93
+ **Hoạt động trên mọi máy, mọi project. Không ngoại lệ.**
94
+
95
+ ### Xác Nhận Cài Đặt (Tùy Chọn)
96
+
97
+ Wizard sẽ hướng dẫn bạn từng bước:
98
+
99
+ ```
100
+ ◆ Welcome to HiveMind Context Governance!
101
+
102
+ ◆ Select governance mode:
103
+ │ ○ strict — Session starts LOCKED. Must declare intent before writes.
104
+ │ ● assisted — Session starts OPEN. Guidance without blocking. (recommended)
105
+ │ ○ permissive — Always OPEN. Silent tracking only.
106
+
107
+ ◆ Select language:
108
+ │ ○ English
109
+ │ ● Tiếng Việt
110
+
111
+ ◆ Select automation level:
112
+ │ ○ manual — No automation, you control everything
113
+ │ ○ guided — Suggestions only
114
+ │ ● assisted — Balanced automation (recommended)
115
+ │ ○ full — Maximum automation
116
+ │ ○ coach — Maximum handholding, skeptical of everything
117
+
118
+ ◆ Configuration saved! .hivemind/ created.
119
+ ```
120
+
121
+ ### Cài Đặt Không Tương Tác
122
+
123
+ ```bash
124
+ npx hivemind-context-governance init --mode strict --lang vi --automation full
125
+ ```
126
+
127
+ Lệnh này làm **đúng như** wizard tương tác:
128
+ - Tạo cấu trúc `.hivemind/`
129
+ - Đăng ký plugin trong `opencode.json`
130
+ - Đồng bộ OpenCode assets
131
+ - Khởi tạo brain state với cài đặt đã chọn
132
+
133
+ ### Mở OpenCode
134
+
135
+ Xong. Plugin tự động hoạt động. AI agent sẽ nhận governance context được inject vào mỗi turn.
136
+
137
+ ### Xác Nhận Cài Đặt (Tùy Chọn)
138
+
139
+ ```bash
140
+ npx hivemind-context-governance status
141
+ ```
142
+
143
+ Hoặc kiểm tra thủ công `opencode.json` có chứa:
144
+ ```json
145
+ {
146
+ "plugin": ["hivemind-context-governance"]
147
+ }
148
+ ```
149
+
150
+ ### Sử Dụng Slash Command
151
+
152
+ Gõ `/hivemind-scan` trong OpenCode để quét dự án và tạo bản đồ cơ sở trước khi bắt đầu code.
153
+
154
+ Hoặc dùng CLI trực tiếp:
155
+
156
+ ```bash
157
+ npx hivemind-context-governance scan --action analyze --json
158
+ npx hivemind-context-governance scan --action recommend
159
+ npx hivemind-context-governance scan --action orchestrate --json
160
+ ```
161
+
162
+ ## Runbook Brownfield (Tiếng Việt)
163
+
164
+ Khi người dùng nói: *\"Hãy quét dự án và refactor\"*, chạy theo thứ tự:
165
+
166
+ 1. `scan_hierarchy({ action: "analyze", json: true })`
167
+ 2. `scan_hierarchy({ action: "recommend" })`
168
+ 3. `scan_hierarchy({ action: "orchestrate", json: true })`
169
+ 4. `declare_intent(...)` + `map_context(...)` để khóa focus trước khi sửa code
170
+
171
+ Mục tiêu:
172
+ - Phát hiện framework (`gsd/spec-kit/both/none`) và tín hiệu BMAD
173
+ - Cô lập artifact cũ/stale có nguy cơ nhiễm context
174
+ - Lưu baseline anchors + memory trước khi refactor diện rộng
175
+
176
+ ## 10 Công Cụ — Giải Thích Chi Tiết
177
+
178
+ ### Nhóm 1: Vòng Đời Session
179
+
180
+ | Công Cụ | Khi Nào Dùng | Tại Sao Quan Trọng |
181
+ |---------|-------------|---------------------|
182
+ | `declare_intent` | Bắt đầu làm việc | Không có ý định rõ ràng = không có cơ sở để đánh giá drift |
183
+ | `map_context` | Đổi hướng/focus | Mỗi lần đổi mà không cập nhật = context bị ô nhiễm |
184
+ | `compact_session` | Xong việc | Không compact = mất toàn bộ intelligence tích lũy |
185
+
186
+ ### Nhóm 2: Nhận Thức & Sửa Lỗi
187
+
188
+ | Công Cụ | Khi Nào Dùng | Tại Sao Quan Trọng |
189
+ |---------|-------------|---------------------|
190
+ | `scan_hierarchy` | Muốn xem nhanh trạng thái | Nắm bắt tình hình trong 1 giây |
191
+ | `think_back` | Cảm thấy lạc | Hồi phục context sâu sau compaction |
192
+ | `scan_hierarchy` (`include_drift`) | Trước khi kết luận xong | Kiểm tra độ lệch hướng theo trajectory/tactic/action |
193
+
194
+ ### Nhóm 3: Bộ Nhớ Dài Hạn
195
+
196
+ | Công Cụ | Khi Nào Dùng | Tại Sao Quan Trọng |
197
+ |---------|-------------|---------------------|
198
+ | `save_mem` | Học được bài học quan trọng | Quyết định, pattern, lỗi — tồn tại vĩnh viễn |
199
+ | `recall_mems` | Gặp vấn đề quen thuộc | Tìm giải pháp từ quá khứ |
200
+ | `save_anchor` | Sự thật bất biến | Port number, schema, API endpoint — không bao giờ quên |
201
+
202
+ ### Nhóm 4: Quản Lý Cây & Subagent
203
+
204
+ | Công Cụ | Khi Nào Dùng | Tại Sao Quan Trọng |
205
+ |---------|-------------|---------------------|
206
+ | `hierarchy_manage` | Cây nhiều nhánh hoặc cần nâng cấp | Gộp cả prune và migrate trong một công cụ |
207
+ | `export_cycle` | Subagent vừa trả kết quả | Không export = mất intelligence từ subagent |
208
+
209
+ ## Lần Đầu Mở OpenCode (Quan Trọng!)
210
+
211
+ Khi HiveMind được load nhưng chưa cấu hình:
212
+
213
+ 1. **Không tự động tạo session mặc định** — tránh tình trạng config không đúng ý người dùng
214
+ 2. **Quét project tự động** — phát hiện tên project, tech stack (20+ framework), cấu trúc thư mục, tài liệu
215
+ 3. **Hướng dẫn recon protocol** — agent được yêu cầu:
216
+ - Quét cấu trúc repo
217
+ - Đọc tài liệu cốt lõi (README, AGENTS.md, package.json)
218
+ - Phát hiện context bị "nhiễm" (plan cũ, artifact trùng lặp, framework xung đột)
219
+ - Xây dựng backbone dự án trước khi code
220
+
221
+ **Mục tiêu**: Tránh tình trạng "vừa vào đã sửa code" khi chưa hiểu project.
222
+ ### English Snapshot
223
+
224
+ HiveMind is an [OpenCode](https://opencode.ai) plugin that prevents AI agents from drifting, forgetting, and losing coherence during long coding sessions. It enforces one backbone: *declare what you're doing, track as you go, archive when done*.
6
225
 
7
226
  ```
8
227
  10 tools · 6 hooks · 5 skills · 3 slash commands · interactive CLI · Ink TUI dashboard · EN/VI
@@ -34,7 +253,7 @@ Without governance, long AI sessions decay:
34
253
  ### One Command - That's It
35
254
 
36
255
  ```bash
37
- npx hivemind-context-governance init --mode assisted
256
+ npx hivemind-context-governance init
38
257
  ```
39
258
 
40
259
  **What happens (guaranteed):**
@@ -327,14 +546,13 @@ npx hivemind-context-governance sync-assets --overwrite
327
546
 
328
547
  `init` also performs asset sync automatically. Re-running `init` on an existing project refreshes missing assets without resetting `.hivemind` state.
329
548
 
330
- Packaged optional ecosystem assets now include starter files for:
549
+ Public v2.8 package intentionally ships only the operational pack:
550
+ - `commands`
551
+ - `skills`
331
552
  - `agents`
332
553
  - `workflows`
333
- - `templates`
334
- - `prompts`
335
- - `references`
336
554
 
337
- These are synced into `.opencode/` (or global OpenCode config path) alongside commands and skills.
555
+ Internal playbooks (`docs`, `templates`, `tasks`, and local dot-folders) are kept out of public release flow.
338
556
 
339
557
  ### Existing User Upgrade (No Re-init Required)
340
558
 
@@ -511,207 +729,6 @@ MIT
511
729
 
512
730
  ---
513
731
 
514
- # 🇻🇳 Hướng Dẫn Tiếng Việt (Chi Tiết)
515
-
516
- > *Phần này không phải bản dịch — mà được viết riêng cho người dùng Việt Nam, với giải thích kỹ hơn về cách hoạt động và lý do tại sao.*
517
-
518
- **Cảm thấy hữu ích?** [![Mời cà phê](https://img.shields.io/badge/Mời%20cà%20phê-ủng%20hộ-orange?logo=buy-me-a-coffee&logoColor=white)](https://buymeacoffee.com/shynlee04l)
519
-
520
- ## HiveMind Là Gì?
521
-
522
- Hãy tưởng tượng bạn thuê một lập trình viên AI rất giỏi, nhưng anh ta có một vấn đề: **mỗi 30 phút anh ta quên hết mọi thứ đang làm**.
523
-
524
- Đó chính xác là điều xảy ra với các AI coding agent hiện tại:
525
- - Đang làm feature A, tự nhiên nhảy sang feature B mà không checkpoint
526
- - Sau context compaction (khi hết bộ nhớ), quên hết lý do tại sao đã quyết định kiến trúc X
527
- - Giao việc cho subagent, nhận kết quả nhưng không tổng hợp lại
528
- - Session mới bắt đầu từ con số 0 — không biết gì về session trước
529
-
530
- **HiveMind giải quyết tất cả** bằng một hệ thống quản trị context đơn giản nhưng hiệu quả.
531
-
532
- ## Cách Hoạt Động (Giải Thích Dễ Hiểu)
533
-
534
- Mỗi session làm việc với AI đều tuân theo một quy trình:
535
-
536
- ```
537
- declare_intent → map_context → [làm việc] → compact_session
538
- (khai báo) (cập nhật) (code) (lưu trữ)
539
- ```
540
-
541
- ### Bước 1: Khai Báo Ý Định — `declare_intent`
542
-
543
- Trước khi bắt đầu bất kỳ công việc nào, agent phải nói rõ:
544
- - **Đang làm gì**: "Xây dựng hệ thống xác thực"
545
- - **Làm theo cách nào**: `plan_driven` (có kế hoạch), `quick_fix` (sửa nhanh), hoặc `exploration` (tìm hiểu)
546
-
547
- Nếu không khai báo, ở chế độ `strict` agent sẽ bị khóa — không thể ghi file cho đến khi khai báo. Điều này đảm bảo mọi công việc đều có mục tiêu rõ ràng.
548
-
549
- ### Bước 2: Cập Nhật Ngữ Cảnh — `map_context`
550
-
551
- Khi agent chuyển focus (ví dụ: từ "thiết kế database" sang "viết API"), nó phải gọi `map_context` để HiveMind biết. Hệ thống theo dõi 3 cấp:
552
-
553
- | Cấp | Ý Nghĩa | Ví Dụ |
554
- |-----|---------|-------|
555
- | **Trajectory** | Mục tiêu lớn | "Xây dựng hệ thống thanh toán" |
556
- | **Tactic** | Chiến thuật cụ thể | "Tích hợp Stripe API" |
557
- | **Action** | Hành động đang làm | "Viết test cho webhook handler" |
558
-
559
- Nếu agent làm nhiều turn mà không cập nhật, HiveMind phát hiện **drift** (trôi dạt) và cảnh báo ngay.
560
-
561
- ### Bước 3: Lưu Trữ — `compact_session`
562
-
563
- Khi xong việc, `compact_session` sẽ:
564
- 1. Lưu toàn bộ session vào archive (có thể đọc lại)
565
- 2. Ghi tóm tắt vào lịch sử dự án
566
- 3. Reset để sẵn sàng cho session tiếp theo
567
-
568
- **Quan trọng**: Mems Brain (bộ nhớ dài hạn) vẫn tồn tại sau compact. Những gì agent đã học được (`save_mem`) sẽ không bao giờ mất.
569
-
570
- ## Cài Đặt Từ Đầu Đến Cuối
571
-
572
- ### Một Lệnh - Xong Ngay
573
-
574
- ```bash
575
- npx hivemind-context-governance init --mode assisted
576
- ```
577
-
578
- **Điều gì sẽ xảy ra (đảm bảo):**
579
- 1. Tự động tải từ npm (không cần cài thủ công)
580
- 2. Tạo thư mục `.hivemind/` với brain.json, config.json
581
- 3. Đăng ký plugin trong `opencode.json` (để OpenCode tự động load)
582
- 4. Đồng bộ commands/skills vào `.opencode/`
583
- 5. Tạo các file session template
584
- 6. Mở session ở chế độ `OPEN` (assisted) hoặc `LOCKED` (strict)
585
-
586
- **Hoạt động trên mọi máy, mọi project. Không ngoại lệ.**
587
-
588
- ### Xác Nhận Cài Đặt (Tùy Chọn)
589
-
590
- Wizard sẽ hướng dẫn bạn từng bước:
591
-
592
- ```
593
- ◆ Welcome to HiveMind Context Governance!
594
-
595
- ◆ Select governance mode:
596
- │ ○ strict — Session starts LOCKED. Must declare intent before writes.
597
- │ ● assisted — Session starts OPEN. Guidance without blocking. (recommended)
598
- │ ○ permissive — Always OPEN. Silent tracking only.
599
-
600
- ◆ Select language:
601
- │ ○ English
602
- │ ● Tiếng Việt
603
-
604
- ◆ Select automation level:
605
- │ ○ manual — No automation, you control everything
606
- │ ○ guided — Suggestions only
607
- │ ● assisted — Balanced automation (recommended)
608
- │ ○ full — Maximum automation
609
- │ ○ coach — Maximum handholding, skeptical of everything
610
-
611
- ◆ Configuration saved! .hivemind/ created.
612
- ```
613
-
614
- ### Cài Đặt Không Tương Tác
615
-
616
- ```bash
617
- npx hivemind-context-governance init --mode strict --lang vi --automation full
618
- ```
619
-
620
- Lệnh này làm **đúng như** wizard tương tác:
621
- - Tạo cấu trúc `.hivemind/`
622
- - Đăng ký plugin trong `opencode.json`
623
- - Đồng bộ OpenCode assets
624
- - Khởi tạo brain state với cài đặt đã chọn
625
-
626
- ### Mở OpenCode
627
-
628
- Xong. Plugin tự động hoạt động. AI agent sẽ nhận governance context được inject vào mỗi turn.
629
-
630
- ### Xác Nhận Cài Đặt (Tùy Chọn)
631
-
632
- ```bash
633
- npx hivemind-context-governance status
634
- ```
635
-
636
- Hoặc kiểm tra thủ công `opencode.json` có chứa:
637
- ```json
638
- {
639
- "plugin": ["hivemind-context-governance"]
640
- }
641
- ```
642
-
643
- ### Sử Dụng Slash Command
644
-
645
- Gõ `/hivemind-scan` trong OpenCode để quét dự án và tạo bản đồ cơ sở trước khi bắt đầu code.
646
-
647
- Hoặc dùng CLI trực tiếp:
648
-
649
- ```bash
650
- npx hivemind-context-governance scan --action analyze --json
651
- npx hivemind-context-governance scan --action recommend
652
- npx hivemind-context-governance scan --action orchestrate --json
653
- ```
654
-
655
- ## Runbook Brownfield (Tiếng Việt)
656
-
657
- Khi người dùng nói: *\"Hãy quét dự án và refactor\"*, chạy theo thứ tự:
658
-
659
- 1. `scan_hierarchy({ action: "analyze", json: true })`
660
- 2. `scan_hierarchy({ action: "recommend" })`
661
- 3. `scan_hierarchy({ action: "orchestrate", json: true })`
662
- 4. `declare_intent(...)` + `map_context(...)` để khóa focus trước khi sửa code
663
-
664
- Mục tiêu:
665
- - Phát hiện framework (`gsd/spec-kit/both/none`) và tín hiệu BMAD
666
- - Cô lập artifact cũ/stale có nguy cơ nhiễm context
667
- - Lưu baseline anchors + memory trước khi refactor diện rộng
668
-
669
- ## 10 Công Cụ — Giải Thích Chi Tiết
670
-
671
- ### Nhóm 1: Vòng Đời Session
672
-
673
- | Công Cụ | Khi Nào Dùng | Tại Sao Quan Trọng |
674
- |---------|-------------|---------------------|
675
- | `declare_intent` | Bắt đầu làm việc | Không có ý định rõ ràng = không có cơ sở để đánh giá drift |
676
- | `map_context` | Đổi hướng/focus | Mỗi lần đổi mà không cập nhật = context bị ô nhiễm |
677
- | `compact_session` | Xong việc | Không compact = mất toàn bộ intelligence tích lũy |
678
-
679
- ### Nhóm 2: Nhận Thức & Sửa Lỗi
680
-
681
- | Công Cụ | Khi Nào Dùng | Tại Sao Quan Trọng |
682
- |---------|-------------|---------------------|
683
- | `scan_hierarchy` | Muốn xem nhanh trạng thái | Nắm bắt tình hình trong 1 giây |
684
- | `think_back` | Cảm thấy lạc | Hồi phục context sâu sau compaction |
685
- | `scan_hierarchy` (`include_drift`) | Trước khi kết luận xong | Kiểm tra độ lệch hướng theo trajectory/tactic/action |
686
-
687
- ### Nhóm 3: Bộ Nhớ Dài Hạn
688
-
689
- | Công Cụ | Khi Nào Dùng | Tại Sao Quan Trọng |
690
- |---------|-------------|---------------------|
691
- | `save_mem` | Học được bài học quan trọng | Quyết định, pattern, lỗi — tồn tại vĩnh viễn |
692
- | `recall_mems` | Gặp vấn đề quen thuộc | Tìm giải pháp từ quá khứ |
693
- | `save_anchor` | Sự thật bất biến | Port number, schema, API endpoint — không bao giờ quên |
694
-
695
- ### Nhóm 4: Quản Lý Cây & Subagent
696
-
697
- | Công Cụ | Khi Nào Dùng | Tại Sao Quan Trọng |
698
- |---------|-------------|---------------------|
699
- | `hierarchy_manage` | Cây nhiều nhánh hoặc cần nâng cấp | Gộp cả prune và migrate trong một công cụ |
700
- | `export_cycle` | Subagent vừa trả kết quả | Không export = mất intelligence từ subagent |
701
-
702
- ## Lần Đầu Mở OpenCode (Quan Trọng!)
703
-
704
- Khi HiveMind được load nhưng chưa cấu hình:
705
-
706
- 1. **Không tự động tạo session mặc định** — tránh tình trạng config không đúng ý người dùng
707
- 2. **Quét project tự động** — phát hiện tên project, tech stack (20+ framework), cấu trúc thư mục, tài liệu
708
- 3. **Hướng dẫn recon protocol** — agent được yêu cầu:
709
- - Quét cấu trúc repo
710
- - Đọc tài liệu cốt lõi (README, AGENTS.md, package.json)
711
- - Phát hiện context bị "nhiễm" (plan cũ, artifact trùng lặp, framework xung đột)
712
- - Xây dựng backbone dự án trước khi code
713
-
714
- **Mục tiêu**: Tránh tình trạng "vừa vào đã sửa code" khi chưa hiểu project.
715
732
 
716
733
  ## Dashboard (TUI Trực Tiếp)
717
734
 
@@ -0,0 +1,198 @@
1
+ ---
2
+ name: build
3
+ description: "Full-stack implementation agent for HiveMind. Builds, tests, validates, and requests review before completion."
4
+ mode: all
5
+ ---
6
+
7
+ # Build Agent - HiveMind v3 Development Engine
8
+
9
+ ## Identity
10
+
11
+ You are the **build** agent - a full-stack development engine for HiveMind v3 refactoring. You are NOT a general-purpose assistant. You are a specialized developer that builds, tests, validates, and verifies code with surgical precision.
12
+
13
+ ## CRITICAL CONSTRAINTS
14
+
15
+ ### Delegation Restrictions
16
+ - **YOU CANNOT delegate to another "build" subagent** unless you are running in the MAIN SESSION (not a subagent yourself)
17
+ - If you are a subagent, you MUST request human or code-review agent validation BEFORE delegating further
18
+ - Use `scanner` or `explore` agents for investigation tasks, not additional `build` agents
19
+
20
+ ### Review Requirements
21
+ - **ALWAYS** request external code review before finalizing ANY work
22
+ - After self-validation, invoke the **code-review** agent to validate your changes
23
+ - Do NOT claim completion until code-review agent has approved the work
24
+ - If code-review agent rejects changes, fix issues and re-request review
25
+
26
+ ## Core Directives
27
+
28
+ 1. **Self-Validate Always** - Run tests, type-checks, and lints BEFORE claiming work complete
29
+ 2. **Self Code-Review** - Review your own changes against architectural standards
30
+ 3. **Request Code Review** - Always request external review before finalizing
31
+ 4. **Be Skeptical** - Question assumptions, verify before proceeding
32
+ 5. **Pull Latest Tech** - Use web search, Context7, Exa to get current best practices
33
+ 6. **Synthesize Patterns** - Find and apply patterns from codebase, not just external docs
34
+ 7. **Launch Sub-Agents** - Use `explore` and `scanner` for deep investigation
35
+
36
+ ## Permissions (ALL ENABLED)
37
+
38
+ ```json
39
+ {
40
+ "tools": {
41
+ "read": true,
42
+ "write": true,
43
+ "edit": true,
44
+ "glob": true,
45
+ "grep": true,
46
+ "bash": true,
47
+ "task": true,
48
+ "skill": true,
49
+ "webfetch": true,
50
+ "websearch": true,
51
+ "google_search": true,
52
+ "codesearch": true,
53
+ "context7_*": true
54
+ }
55
+ }
56
+ ```
57
+
58
+ ## Workflow
59
+
60
+ ### Phase 1: Context Acquisition
61
+
62
+ Before ANY task:
63
+ 1. Run `scan_hierarchy` to understand current trajectory/tactic/action
64
+ 2. Check anchors via `save_anchor` mode=list
65
+ 3. Recall relevant memories via `recall_mems`
66
+ 4. If unclear → launch `explore` agent to map the terrain
67
+
68
+ ### Phase 2: Skill Discovery
69
+
70
+ For ANY new domain/task:
71
+ 1. Use `find-skills` to discover relevant skills
72
+ 2. Install with `npx skills add <skill> -g -y`
73
+ 3. Load skill via `skill` tool
74
+ 4. Apply to current task
75
+
76
+ ### Phase 3: Implementation
77
+
78
+ Follow architectural taxonomy:
79
+ - **Schemas** (`src/schemas/`) - Zod validation, FK constraints
80
+ - **Libraries** (`src/lib/`) - Pure TS, no LLM prompts
81
+ - **Tools** (`src/tools/`) - ≤100 lines, Zod schema + lib call
82
+ - **Hooks** (`src/hooks/`) - Read-auto context injection
83
+
84
+ ### Phase 4: Self-Validation
85
+
86
+ Run these BEFORE claiming done:
87
+ ```bash
88
+ npx tsc --noEmit # Type check
89
+ npm test # Unit tests
90
+ ```
91
+
92
+ ### Phase 5: Self Code Review
93
+
94
+ Review your changes against:
95
+ - [ ] Architectural taxonomy respected
96
+ - [ ] No business logic in tools
97
+ - [ ] Zod schemas have FK validation
98
+ - [ ] Pure functions in lib/
99
+ - [ ] Tests added for new code
100
+
101
+ ### Phase 6: Request Review (MANDATORY)
102
+
103
+ **CRITICAL**: You MUST request external code review BEFORE considering work complete.
104
+
105
+ 1. Use `task` with `code-review` subagent to validate your changes
106
+ 2. Wait for review approval before claiming completion
107
+ 3. If rejected: fix issues, then re-request review
108
+ 4. Document review outcome in task summary
109
+
110
+ ## Self-Delegation Prevention
111
+
112
+ If you are a **subagent** (not main session):
113
+ - DO NOT spawn additional `build` subagents
114
+ - DO use `scanner` or `explore` for deep investigation
115
+ - DO request code-review agent for validation
116
+ - If delegation is truly needed, escalate to human
117
+
118
+ ## Key Skills to Load
119
+
120
+ | Task | Skill |
121
+ |------|-------|
122
+ | Zod/TypeScript | `~/.agents/skills/zod` |
123
+ | Code Review | `~/.agents/skills/code-review` |
124
+ | Architecture | `~/.agents/skills/code-architecture-review` |
125
+ | Verification | `~/.agents/skills/verification-before-completion` |
126
+ | Testing | `~/.agents/skills/test-driven-development` |
127
+ | TypeScript Types | `~/.agents/skills/typescript-advanced-types` |
128
+
129
+ ## Codebase Context (Memorize)
130
+
131
+ ### Architecture
132
+
133
+ ```
134
+ src/
135
+ ├── tools/ # Write-Only (≤100 lines)
136
+ ├── lib/ # Subconscious Engine (pure TS)
137
+ ├── hooks/ # Read-Auto (context injection)
138
+ └── schemas/ # DNA (Zod validation)
139
+ ```
140
+
141
+ ### Key Files
142
+
143
+ | File | Purpose |
144
+ |------|---------|
145
+ | `src/schemas/graph-nodes.ts` | Graph node schemas with FK |
146
+ | `src/lib/paths.ts` | Single path source of truth |
147
+ | `src/hooks/session-lifecycle.ts` | Context injection every turn |
148
+ | `src/lib/hierarchy-tree.ts` | Trajectory → Tactic → Action |
149
+
150
+ ### V3.0 Goals
151
+
152
+ 1. **Graph-RAG**: All entities UUID-keyed with FKs
153
+ 2. **CQRS**: Tools = Write, Hooks = Read
154
+ 3. **Cognitive Packer**: Deterministic XML context compiler
155
+ 4. **Actor Model**: Session swarms via SDK
156
+
157
+ ## Validation Commands
158
+
159
+ Always run before completing:
160
+
161
+ ```bash
162
+ # Type check
163
+ npx tsc --noEmit
164
+
165
+ # Tests
166
+ npm test
167
+
168
+ # Source audit (if available)
169
+ node bin/hivemind-tools.cjs source-audit
170
+
171
+ # Ecosystem check
172
+ node bin/hivemind-tools.cjs ecosystem-check
173
+ ```
174
+
175
+ ## Skepticism Checklist
176
+
177
+ Before proceeding, ask:
178
+ - [ ] Have I explored the codebase first?
179
+ - [ ] Do I understand the existing patterns?
180
+ - [ ] Are there similar implementations to reference?
181
+ - [ ] Is my approach architecturally sound?
182
+ - [ ] Have I checked for edge cases?
183
+ - [ ] Will this break existing functionality?
184
+
185
+ ## Tech Docs Pattern
186
+
187
+ When implementing new features:
188
+ 1. Search Context7/Exa for latest patterns
189
+ 2. Check if similar code exists in this repo
190
+ 3. Synthesize external best practices + internal conventions
191
+ 4. Document any new patterns in comments
192
+
193
+ ## Execution Posture
194
+
195
+ - NEVER execute without understanding
196
+ - NEVER claim complete without validation
197
+ - ALWAYS question, verify, double-check
198
+ - Document your reasoning in code comments