burhan-mop 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (382) hide show
  1. package/.agents/AGENTS.md +54 -0
  2. package/.agents/skills/auto-deploy/SKILL.md +48 -0
  3. package/.agents/skills/autosycn/SKILL.md +75 -0
  4. package/.agents/skills/mop-help/SKILL.md +35 -0
  5. package/.agents/skills/ruflo-core/SKILL.md +35 -0
  6. package/.claude/agents/analysis/analyze-code-quality.md +179 -0
  7. package/.claude/agents/analysis/code-analyzer.md +210 -0
  8. package/.claude/agents/analysis/code-review/analyze-code-quality.md +179 -0
  9. package/.claude/agents/architecture/arch-system-design.md +157 -0
  10. package/.claude/agents/architecture/system-design/arch-system-design.md +155 -0
  11. package/.claude/agents/browser/browser-agent.yaml +182 -0
  12. package/.claude/agents/consensus/byzantine-coordinator.md +63 -0
  13. package/.claude/agents/consensus/crdt-synchronizer.md +997 -0
  14. package/.claude/agents/consensus/gossip-coordinator.md +63 -0
  15. package/.claude/agents/consensus/performance-benchmarker.md +851 -0
  16. package/.claude/agents/consensus/quorum-manager.md +823 -0
  17. package/.claude/agents/consensus/raft-manager.md +63 -0
  18. package/.claude/agents/consensus/security-manager.md +622 -0
  19. package/.claude/agents/core/planner.md +375 -0
  20. package/.claude/agents/custom/test-long-runner.md +44 -0
  21. package/.claude/agents/data/data-ml-model.md +445 -0
  22. package/.claude/agents/data/ml/data-ml-model.md +193 -0
  23. package/.claude/agents/development/backend/dev-backend-api.md +142 -0
  24. package/.claude/agents/development/dev-backend-api.md +345 -0
  25. package/.claude/agents/devops/ci-cd/ops-cicd-github.md +164 -0
  26. package/.claude/agents/devops/ops-cicd-github.md +165 -0
  27. package/.claude/agents/documentation/api-docs/docs-api-openapi.md +174 -0
  28. package/.claude/agents/documentation/docs-api-openapi.md +355 -0
  29. package/.claude/agents/flow-nexus/app-store.md +88 -0
  30. package/.claude/agents/flow-nexus/authentication.md +69 -0
  31. package/.claude/agents/flow-nexus/challenges.md +81 -0
  32. package/.claude/agents/flow-nexus/neural-network.md +88 -0
  33. package/.claude/agents/flow-nexus/payments.md +83 -0
  34. package/.claude/agents/flow-nexus/sandbox.md +76 -0
  35. package/.claude/agents/flow-nexus/swarm.md +76 -0
  36. package/.claude/agents/flow-nexus/user-tools.md +96 -0
  37. package/.claude/agents/flow-nexus/workflow.md +84 -0
  38. package/.claude/agents/github/code-review-swarm.md +377 -0
  39. package/.claude/agents/github/github-modes.md +173 -0
  40. package/.claude/agents/github/issue-tracker.md +576 -0
  41. package/.claude/agents/github/multi-repo-swarm.md +553 -0
  42. package/.claude/agents/github/pr-manager.md +438 -0
  43. package/.claude/agents/github/project-board-sync.md +509 -0
  44. package/.claude/agents/github/release-manager.md +605 -0
  45. package/.claude/agents/github/release-swarm.md +583 -0
  46. package/.claude/agents/github/repo-architect.md +398 -0
  47. package/.claude/agents/github/swarm-issue.md +573 -0
  48. package/.claude/agents/github/swarm-pr.md +428 -0
  49. package/.claude/agents/github/sync-coordinator.md +452 -0
  50. package/.claude/agents/github/workflow-automation.md +903 -0
  51. package/.claude/agents/goal/agent.md +816 -0
  52. package/.claude/agents/optimization/benchmark-suite.md +665 -0
  53. package/.claude/agents/optimization/load-balancer.md +431 -0
  54. package/.claude/agents/optimization/performance-monitor.md +672 -0
  55. package/.claude/agents/optimization/resource-allocator.md +674 -0
  56. package/.claude/agents/optimization/topology-optimizer.md +808 -0
  57. package/.claude/agents/payments/agentic-payments.md +126 -0
  58. package/.claude/agents/sona/sona-learning-optimizer.md +74 -0
  59. package/.claude/agents/sparc/architecture.md +699 -0
  60. package/.claude/agents/sparc/pseudocode.md +520 -0
  61. package/.claude/agents/sparc/refinement.md +802 -0
  62. package/.claude/agents/sparc/specification.md +478 -0
  63. package/.claude/agents/specialized/mobile/spec-mobile-react-native.md +225 -0
  64. package/.claude/agents/specialized/spec-mobile-react-native.md +227 -0
  65. package/.claude/agents/sublinear/consensus-coordinator.md +338 -0
  66. package/.claude/agents/sublinear/matrix-optimizer.md +185 -0
  67. package/.claude/agents/sublinear/pagerank-analyzer.md +299 -0
  68. package/.claude/agents/sublinear/performance-optimizer.md +368 -0
  69. package/.claude/agents/sublinear/trading-predictor.md +246 -0
  70. package/.claude/agents/swarm/adaptive-coordinator.md +1127 -0
  71. package/.claude/agents/swarm/hierarchical-coordinator.md +710 -0
  72. package/.claude/agents/swarm/mesh-coordinator.md +963 -0
  73. package/.claude/agents/templates/automation-smart-agent.md +205 -0
  74. package/.claude/agents/templates/base-template-generator.md +289 -0
  75. package/.claude/agents/templates/coordinator-swarm-init.md +90 -0
  76. package/.claude/agents/templates/github-pr-manager.md +177 -0
  77. package/.claude/agents/templates/implementer-sparc-coder.md +259 -0
  78. package/.claude/agents/templates/memory-coordinator.md +187 -0
  79. package/.claude/agents/templates/orchestrator-task.md +139 -0
  80. package/.claude/agents/templates/performance-analyzer.md +199 -0
  81. package/.claude/agents/templates/sparc-coordinator.md +514 -0
  82. package/.claude/agents/testing/production-validator.md +395 -0
  83. package/.claude/agents/testing/tdd-london-swarm.md +244 -0
  84. package/.claude/agents/v3/aidefence-guardian.md +282 -0
  85. package/.claude/agents/v3/claims-authorizer.md +208 -0
  86. package/.claude/agents/v3/collective-intelligence-coordinator.md +993 -0
  87. package/.claude/agents/v3/ddd-domain-expert.md +220 -0
  88. package/.claude/agents/v3/injection-analyst.md +236 -0
  89. package/.claude/agents/v3/performance-engineer.md +1233 -0
  90. package/.claude/agents/v3/pii-detector.md +151 -0
  91. package/.claude/agents/v3/reasoningbank-learner.md +213 -0
  92. package/.claude/agents/v3/security-architect-aidefence.md +410 -0
  93. package/.claude/agents/v3/security-architect.md +867 -0
  94. package/.claude/agents/v3/swarm-memory-manager.md +157 -0
  95. package/.claude/agents/v3/v3-integration-architect.md +205 -0
  96. package/.claude/commands/agents/README.md +50 -0
  97. package/.claude/commands/agents/agent-capabilities.md +140 -0
  98. package/.claude/commands/agents/agent-coordination.md +28 -0
  99. package/.claude/commands/agents/agent-spawning.md +28 -0
  100. package/.claude/commands/agents/agent-types.md +216 -0
  101. package/.claude/commands/agents/health.md +139 -0
  102. package/.claude/commands/agents/list.md +100 -0
  103. package/.claude/commands/agents/logs.md +130 -0
  104. package/.claude/commands/agents/metrics.md +122 -0
  105. package/.claude/commands/agents/pool.md +127 -0
  106. package/.claude/commands/agents/spawn.md +140 -0
  107. package/.claude/commands/agents/status.md +115 -0
  108. package/.claude/commands/agents/stop.md +102 -0
  109. package/.claude/commands/analysis/COMMAND_COMPLIANCE_REPORT.md +54 -0
  110. package/.claude/commands/analysis/README.md +9 -0
  111. package/.claude/commands/analysis/bottleneck-detect.md +162 -0
  112. package/.claude/commands/analysis/performance-bottlenecks.md +59 -0
  113. package/.claude/commands/analysis/performance-report.md +25 -0
  114. package/.claude/commands/analysis/token-efficiency.md +45 -0
  115. package/.claude/commands/analysis/token-usage.md +25 -0
  116. package/.claude/commands/automation/README.md +9 -0
  117. package/.claude/commands/automation/auto-agent.md +122 -0
  118. package/.claude/commands/automation/self-healing.md +106 -0
  119. package/.claude/commands/automation/session-memory.md +90 -0
  120. package/.claude/commands/automation/smart-agents.md +73 -0
  121. package/.claude/commands/automation/smart-spawn.md +25 -0
  122. package/.claude/commands/automation/workflow-select.md +25 -0
  123. package/.claude/commands/claude-flow-help.md +103 -0
  124. package/.claude/commands/claude-flow-memory.md +107 -0
  125. package/.claude/commands/claude-flow-swarm.md +205 -0
  126. package/.claude/commands/coordination/README.md +9 -0
  127. package/.claude/commands/coordination/agent-spawn.md +25 -0
  128. package/.claude/commands/coordination/init.md +44 -0
  129. package/.claude/commands/coordination/orchestrate.md +43 -0
  130. package/.claude/commands/coordination/spawn.md +45 -0
  131. package/.claude/commands/coordination/swarm-init.md +85 -0
  132. package/.claude/commands/coordination/task-orchestrate.md +25 -0
  133. package/.claude/commands/github/README.md +11 -0
  134. package/.claude/commands/github/code-review-swarm.md +514 -0
  135. package/.claude/commands/github/code-review.md +25 -0
  136. package/.claude/commands/github/github-modes.md +147 -0
  137. package/.claude/commands/github/github-swarm.md +121 -0
  138. package/.claude/commands/github/issue-tracker.md +292 -0
  139. package/.claude/commands/github/issue-triage.md +25 -0
  140. package/.claude/commands/github/multi-repo-swarm.md +519 -0
  141. package/.claude/commands/github/pr-enhance.md +26 -0
  142. package/.claude/commands/github/pr-manager.md +170 -0
  143. package/.claude/commands/github/project-board-sync.md +471 -0
  144. package/.claude/commands/github/release-manager.md +340 -0
  145. package/.claude/commands/github/release-swarm.md +544 -0
  146. package/.claude/commands/github/repo-analyze.md +25 -0
  147. package/.claude/commands/github/repo-architect.md +367 -0
  148. package/.claude/commands/github/swarm-issue.md +485 -0
  149. package/.claude/commands/github/swarm-pr.md +288 -0
  150. package/.claude/commands/github/sync-coordinator.md +303 -0
  151. package/.claude/commands/github/workflow-automation.md +442 -0
  152. package/.claude/commands/hive-mind/README.md +17 -0
  153. package/.claude/commands/hive-mind/hive-mind-consensus.md +8 -0
  154. package/.claude/commands/hive-mind/hive-mind-init.md +18 -0
  155. package/.claude/commands/hive-mind/hive-mind-memory.md +8 -0
  156. package/.claude/commands/hive-mind/hive-mind-metrics.md +8 -0
  157. package/.claude/commands/hive-mind/hive-mind-resume.md +8 -0
  158. package/.claude/commands/hive-mind/hive-mind-sessions.md +8 -0
  159. package/.claude/commands/hive-mind/hive-mind-spawn.md +21 -0
  160. package/.claude/commands/hive-mind/hive-mind-status.md +8 -0
  161. package/.claude/commands/hive-mind/hive-mind-stop.md +8 -0
  162. package/.claude/commands/hive-mind/hive-mind-wizard.md +8 -0
  163. package/.claude/commands/hive-mind/hive-mind.md +27 -0
  164. package/.claude/commands/hooks/README.md +11 -0
  165. package/.claude/commands/hooks/overview.md +58 -0
  166. package/.claude/commands/hooks/post-edit.md +117 -0
  167. package/.claude/commands/hooks/post-task.md +112 -0
  168. package/.claude/commands/hooks/pre-edit.md +113 -0
  169. package/.claude/commands/hooks/pre-task.md +111 -0
  170. package/.claude/commands/hooks/session-end.md +118 -0
  171. package/.claude/commands/hooks/setup.md +103 -0
  172. package/.claude/commands/memory/README.md +9 -0
  173. package/.claude/commands/memory/memory-persist.md +25 -0
  174. package/.claude/commands/memory/memory-search.md +25 -0
  175. package/.claude/commands/memory/memory-usage.md +25 -0
  176. package/.claude/commands/memory/neural.md +47 -0
  177. package/.claude/commands/monitoring/README.md +9 -0
  178. package/.claude/commands/monitoring/agent-metrics.md +25 -0
  179. package/.claude/commands/monitoring/agents.md +44 -0
  180. package/.claude/commands/monitoring/real-time-view.md +25 -0
  181. package/.claude/commands/monitoring/status.md +46 -0
  182. package/.claude/commands/monitoring/swarm-monitor.md +25 -0
  183. package/.claude/commands/optimization/README.md +9 -0
  184. package/.claude/commands/optimization/auto-topology.md +62 -0
  185. package/.claude/commands/optimization/cache-manage.md +25 -0
  186. package/.claude/commands/optimization/parallel-execute.md +25 -0
  187. package/.claude/commands/optimization/parallel-execution.md +50 -0
  188. package/.claude/commands/optimization/topology-optimize.md +25 -0
  189. package/.claude/commands/pair/README.md +261 -0
  190. package/.claude/commands/pair/commands.md +546 -0
  191. package/.claude/commands/pair/config.md +510 -0
  192. package/.claude/commands/pair/examples.md +512 -0
  193. package/.claude/commands/pair/modes.md +348 -0
  194. package/.claude/commands/pair/session.md +407 -0
  195. package/.claude/commands/pair/start.md +209 -0
  196. package/.claude/commands/sparc/analyzer.md +52 -0
  197. package/.claude/commands/sparc/architect.md +53 -0
  198. package/.claude/commands/sparc/ask.md +97 -0
  199. package/.claude/commands/sparc/batch-executor.md +54 -0
  200. package/.claude/commands/sparc/code.md +89 -0
  201. package/.claude/commands/sparc/coder.md +54 -0
  202. package/.claude/commands/sparc/debug.md +83 -0
  203. package/.claude/commands/sparc/debugger.md +54 -0
  204. package/.claude/commands/sparc/designer.md +53 -0
  205. package/.claude/commands/sparc/devops.md +109 -0
  206. package/.claude/commands/sparc/docs-writer.md +80 -0
  207. package/.claude/commands/sparc/documenter.md +54 -0
  208. package/.claude/commands/sparc/innovator.md +54 -0
  209. package/.claude/commands/sparc/integration.md +83 -0
  210. package/.claude/commands/sparc/mcp.md +117 -0
  211. package/.claude/commands/sparc/memory-manager.md +54 -0
  212. package/.claude/commands/sparc/optimizer.md +54 -0
  213. package/.claude/commands/sparc/orchestrator.md +132 -0
  214. package/.claude/commands/sparc/post-deployment-monitoring-mode.md +83 -0
  215. package/.claude/commands/sparc/refinement-optimization-mode.md +83 -0
  216. package/.claude/commands/sparc/researcher.md +54 -0
  217. package/.claude/commands/sparc/reviewer.md +54 -0
  218. package/.claude/commands/sparc/security-review.md +80 -0
  219. package/.claude/commands/sparc/sparc-modes.md +174 -0
  220. package/.claude/commands/sparc/sparc.md +111 -0
  221. package/.claude/commands/sparc/spec-pseudocode.md +80 -0
  222. package/.claude/commands/sparc/supabase-admin.md +348 -0
  223. package/.claude/commands/sparc/swarm-coordinator.md +54 -0
  224. package/.claude/commands/sparc/tdd.md +54 -0
  225. package/.claude/commands/sparc/tester.md +54 -0
  226. package/.claude/commands/sparc/tutorial.md +79 -0
  227. package/.claude/commands/sparc/workflow-manager.md +54 -0
  228. package/.claude/commands/stream-chain/pipeline.md +121 -0
  229. package/.claude/commands/stream-chain/run.md +70 -0
  230. package/.claude/commands/swarm/README.md +15 -0
  231. package/.claude/commands/swarm/analysis.md +95 -0
  232. package/.claude/commands/swarm/development.md +96 -0
  233. package/.claude/commands/swarm/examples.md +168 -0
  234. package/.claude/commands/swarm/maintenance.md +102 -0
  235. package/.claude/commands/swarm/optimization.md +117 -0
  236. package/.claude/commands/swarm/research.md +136 -0
  237. package/.claude/commands/swarm/swarm-analysis.md +8 -0
  238. package/.claude/commands/swarm/swarm-background.md +8 -0
  239. package/.claude/commands/swarm/swarm-init.md +19 -0
  240. package/.claude/commands/swarm/swarm-modes.md +8 -0
  241. package/.claude/commands/swarm/swarm-monitor.md +8 -0
  242. package/.claude/commands/swarm/swarm-spawn.md +19 -0
  243. package/.claude/commands/swarm/swarm-status.md +8 -0
  244. package/.claude/commands/swarm/swarm-strategies.md +8 -0
  245. package/.claude/commands/swarm/swarm.md +87 -0
  246. package/.claude/commands/swarm/testing.md +131 -0
  247. package/.claude/commands/training/README.md +9 -0
  248. package/.claude/commands/training/model-update.md +25 -0
  249. package/.claude/commands/training/neural-patterns.md +108 -0
  250. package/.claude/commands/training/neural-train.md +75 -0
  251. package/.claude/commands/training/pattern-learn.md +25 -0
  252. package/.claude/commands/training/specialization.md +63 -0
  253. package/.claude/commands/truth/start.md +143 -0
  254. package/.claude/commands/verify/check.md +50 -0
  255. package/.claude/commands/verify/start.md +128 -0
  256. package/.claude/commands/workflows/README.md +9 -0
  257. package/.claude/commands/workflows/development.md +78 -0
  258. package/.claude/commands/workflows/research.md +63 -0
  259. package/.claude/commands/workflows/workflow-create.md +25 -0
  260. package/.claude/commands/workflows/workflow-execute.md +25 -0
  261. package/.claude/commands/workflows/workflow-export.md +25 -0
  262. package/.claude/helpers/README.md +97 -0
  263. package/.claude/helpers/adr-compliance.sh +186 -0
  264. package/.claude/helpers/auto-commit.sh +178 -0
  265. package/.claude/helpers/auto-memory-hook.mjs +368 -0
  266. package/.claude/helpers/checkpoint-manager.sh +251 -0
  267. package/.claude/helpers/daemon-manager.sh +252 -0
  268. package/.claude/helpers/ddd-tracker.sh +144 -0
  269. package/.claude/helpers/github-safe.js +156 -0
  270. package/.claude/helpers/github-setup.sh +45 -0
  271. package/.claude/helpers/guidance-hook.sh +13 -0
  272. package/.claude/helpers/guidance-hooks.sh +102 -0
  273. package/.claude/helpers/health-monitor.sh +108 -0
  274. package/.claude/helpers/hook-handler.cjs +286 -0
  275. package/.claude/helpers/intelligence.cjs +1031 -0
  276. package/.claude/helpers/learning-hooks.sh +329 -0
  277. package/.claude/helpers/learning-optimizer.sh +127 -0
  278. package/.claude/helpers/learning-service.mjs +1144 -0
  279. package/.claude/helpers/memory.js +83 -0
  280. package/.claude/helpers/metrics-db.mjs +488 -0
  281. package/.claude/helpers/pattern-consolidator.sh +86 -0
  282. package/.claude/helpers/perf-worker.sh +160 -0
  283. package/.claude/helpers/post-commit +16 -0
  284. package/.claude/helpers/pre-commit +26 -0
  285. package/.claude/helpers/quick-start.sh +19 -0
  286. package/.claude/helpers/router.js +105 -0
  287. package/.claude/helpers/ruflo-hook.cjs +59 -0
  288. package/.claude/helpers/security-scanner.sh +127 -0
  289. package/.claude/helpers/session.js +157 -0
  290. package/.claude/helpers/setup-mcp.sh +18 -0
  291. package/.claude/helpers/standard-checkpoint-hooks.sh +189 -0
  292. package/.claude/helpers/statusline-hook.sh +21 -0
  293. package/.claude/helpers/statusline.cjs +693 -0
  294. package/.claude/helpers/statusline.js +352 -0
  295. package/.claude/helpers/swarm-comms.sh +353 -0
  296. package/.claude/helpers/swarm-hooks.sh +761 -0
  297. package/.claude/helpers/swarm-monitor.sh +211 -0
  298. package/.claude/helpers/sync-v3-metrics.sh +245 -0
  299. package/.claude/helpers/update-v3-progress.sh +166 -0
  300. package/.claude/helpers/v3-quick-status.sh +58 -0
  301. package/.claude/helpers/v3.sh +111 -0
  302. package/.claude/helpers/validate-v3-config.sh +216 -0
  303. package/.claude/helpers/worker-manager.sh +170 -0
  304. package/.claude/settings.json +285 -0
  305. package/.claude/skills/agentdb-advanced/SKILL.md +550 -0
  306. package/.claude/skills/agentdb-learning/SKILL.md +545 -0
  307. package/.claude/skills/agentdb-memory-patterns/SKILL.md +339 -0
  308. package/.claude/skills/agentdb-optimization/SKILL.md +509 -0
  309. package/.claude/skills/agentdb-vector-search/SKILL.md +339 -0
  310. package/.claude/skills/auto-deploy/SKILL.md +31 -0
  311. package/.claude/skills/autosycn/SKILL.md +30 -0
  312. package/.claude/skills/browser/SKILL.md +204 -0
  313. package/.claude/skills/dual-mode/README.md +71 -0
  314. package/.claude/skills/dual-mode/dual-collect.md +103 -0
  315. package/.claude/skills/dual-mode/dual-coordinate.md +85 -0
  316. package/.claude/skills/dual-mode/dual-spawn.md +81 -0
  317. package/.claude/skills/flow-nexus-neural/SKILL.md +727 -0
  318. package/.claude/skills/flow-nexus-platform/SKILL.md +1154 -0
  319. package/.claude/skills/flow-nexus-swarm/SKILL.md +604 -0
  320. package/.claude/skills/github-code-review/SKILL.md +1125 -0
  321. package/.claude/skills/github-multi-repo/SKILL.md +862 -0
  322. package/.claude/skills/github-project-management/SKILL.md +1262 -0
  323. package/.claude/skills/github-release-management/SKILL.md +1064 -0
  324. package/.claude/skills/github-workflow-automation/SKILL.md +1047 -0
  325. package/.claude/skills/hooks-automation/SKILL.md +1201 -0
  326. package/.claude/skills/mop-help/SKILL.md +35 -0
  327. package/.claude/skills/pair-programming/SKILL.md +1202 -0
  328. package/.claude/skills/reasoningbank-agentdb/SKILL.md +446 -0
  329. package/.claude/skills/reasoningbank-intelligence/SKILL.md +201 -0
  330. package/.claude/skills/skill-builder/SKILL.md +910 -0
  331. package/.claude/skills/sparc-methodology/SKILL.md +1106 -0
  332. package/.claude/skills/stream-chain/SKILL.md +560 -0
  333. package/.claude/skills/swarm-advanced/SKILL.md +970 -0
  334. package/.claude/skills/swarm-orchestration/SKILL.md +179 -0
  335. package/.claude/skills/v3-cli-modernization/SKILL.md +872 -0
  336. package/.claude/skills/v3-core-implementation/SKILL.md +797 -0
  337. package/.claude/skills/v3-ddd-architecture/SKILL.md +442 -0
  338. package/.claude/skills/v3-integration-deep/SKILL.md +241 -0
  339. package/.claude/skills/v3-mcp-optimization/SKILL.md +777 -0
  340. package/.claude/skills/v3-memory-unification/SKILL.md +174 -0
  341. package/.claude/skills/v3-performance-optimization/SKILL.md +390 -0
  342. package/.claude/skills/v3-security-overhaul/SKILL.md +82 -0
  343. package/.claude/skills/v3-swarm-coordination/SKILL.md +340 -0
  344. package/.claude/skills/verification-quality/SKILL.md +691 -0
  345. package/.claude-flow/CAPABILITIES.md +403 -0
  346. package/.claude-flow/config.yaml +43 -0
  347. package/.claude-flow/metrics/learning.json +17 -0
  348. package/.claude-flow/metrics/swarm-activity.json +18 -0
  349. package/.claude-flow/metrics/v3-progress.json +26 -0
  350. package/.claude-flow/security/audit-status.json +8 -0
  351. package/.codex/config.toml +39 -0
  352. package/.gemini/settings.json +49 -0
  353. package/.mcp.json +55 -0
  354. package/.memoryofplanet/PROTOCOL.md +436 -0
  355. package/.memoryofplanet/STATE.json +561 -0
  356. package/.memoryofplanet/config/defaults.json +46 -0
  357. package/.memoryofplanet/config/team.json +7 -0
  358. package/.memoryofplanet/scripts/burhan-mop.mjs +124 -0
  359. package/.memoryofplanet/scripts/mop-auto-deploy.mjs +153 -0
  360. package/.memoryofplanet/scripts/mop-autosycn.mjs +617 -0
  361. package/.memoryofplanet/scripts/mop-core.mjs +774 -0
  362. package/.memoryofplanet/scripts/mop-workflow.mjs +348 -0
  363. package/.memoryofplanet/templates/artifacts/adversarial-review.md +33 -0
  364. package/.memoryofplanet/templates/artifacts/architecture.md +28 -0
  365. package/.memoryofplanet/templates/artifacts/decision-log.md +21 -0
  366. package/.memoryofplanet/templates/artifacts/handoff.md +21 -0
  367. package/.memoryofplanet/templates/artifacts/implementation-notes.md +21 -0
  368. package/.memoryofplanet/templates/artifacts/prd.md +29 -0
  369. package/.memoryofplanet/templates/artifacts/product-brief.md +30 -0
  370. package/.memoryofplanet/templates/artifacts/readiness-report.md +25 -0
  371. package/.memoryofplanet/templates/artifacts/release-notes.md +21 -0
  372. package/.memoryofplanet/templates/artifacts/review.md +21 -0
  373. package/.memoryofplanet/templates/artifacts/story.md +25 -0
  374. package/.memoryofplanet/templates/artifacts/ux-spec.md +32 -0
  375. package/AGENTS.md +126 -0
  376. package/CLAUDE.md +235 -0
  377. package/GEMINI.md +19 -0
  378. package/README.md +1096 -0
  379. package/bin/burhan-mop.mjs +2 -0
  380. package/bin/mop-core.mjs +2 -0
  381. package/bin/mop-workflow.mjs +2 -0
  382. package/package.json +66 -0
@@ -0,0 +1,774 @@
1
+ #!/usr/bin/env node
2
+ import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
3
+ import { dirname, join, resolve } from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+ import { randomBytes, scryptSync, timingSafeEqual } from 'node:crypto';
6
+
7
+ const here = dirname(fileURLToPath(import.meta.url));
8
+ const coreDir = resolve(here, '..');
9
+ const rootDir = resolve(coreDir, '..');
10
+ const statePath = join(coreDir, 'STATE.json');
11
+
12
+ function now() {
13
+ return new Date().toISOString();
14
+ }
15
+
16
+ function readState() {
17
+ return JSON.parse(readFileSync(statePath, 'utf8'));
18
+ }
19
+
20
+ function writeState(state) {
21
+ mkdirSync(coreDir, { recursive: true });
22
+ const tmp = `${statePath}.tmp`;
23
+ writeFileSync(tmp, `${JSON.stringify(state, null, 2)}\n`, 'utf8');
24
+ renameSync(tmp, statePath);
25
+ }
26
+
27
+ function parseArgs(argv) {
28
+ const out = { _: [] };
29
+ for (let i = 0; i < argv.length; i += 1) {
30
+ const item = argv[i];
31
+ if (!item.startsWith('--')) {
32
+ out._.push(item);
33
+ continue;
34
+ }
35
+ const key = item.slice(2);
36
+ const next = argv[i + 1];
37
+ if (!next || next.startsWith('--')) {
38
+ out[key] = true;
39
+ } else {
40
+ out[key] = next;
41
+ i += 1;
42
+ }
43
+ }
44
+ return out;
45
+ }
46
+
47
+ function requireArg(args, key) {
48
+ const value = args[key];
49
+ if (!value || value === true) {
50
+ throw new Error(`Missing --${key}`);
51
+ }
52
+ return String(value);
53
+ }
54
+
55
+ function slug(value) {
56
+ return String(value)
57
+ .trim()
58
+ .toLowerCase()
59
+ .replace(/[^a-z0-9]+/g, '-')
60
+ .replace(/^-+|-+$/g, '');
61
+ }
62
+
63
+ function hashPassword(password, salt = randomBytes(16).toString('hex')) {
64
+ const passwordHash = scryptSync(password, salt, 64).toString('hex');
65
+ return { passwordHash, passwordSalt: salt };
66
+ }
67
+
68
+ function verifyPassword(password, salt, expectedHex) {
69
+ const actual = scryptSync(password, salt, 64);
70
+ const expected = Buffer.from(expectedHex, 'hex');
71
+ return expected.length === actual.length && timingSafeEqual(actual, expected);
72
+ }
73
+
74
+ function activeAgentFor(state, actor) {
75
+ const activeId = state.activeAgents?.[actor];
76
+ if (!activeId) return null;
77
+ const agent = (state.agentRoster || []).find((item) => item.id === activeId || item.name === activeId);
78
+ if (!agent || !(agent.owners || []).includes(actor)) return null;
79
+ return agent;
80
+ }
81
+
82
+ function agentLedgerFields(agent) {
83
+ return agent ? {
84
+ agent: agent.name,
85
+ agentRole: agent.role,
86
+ agentId: agent.id
87
+ } : {};
88
+ }
89
+
90
+ function requireActiveAgent(state, actor, role = 'core', title = 'Core Agent') {
91
+ const agent = activeAgentFor(state, actor);
92
+ if (agent) return agent;
93
+ throw new Error([
94
+ `Agent diperlukan sebelum sambung kerja untuk ${actor}.`,
95
+ `Task ini perlukan ${title}. Agent ini belum ada nama lagi atau belum dipilih.`,
96
+ `Jalankan: node .memoryofplanet/scripts/mop-core.mjs agent activate --actor ${actor} --role ${role} --title "${title}" --name "<agent-name>"`
97
+ ].join(' '));
98
+ }
99
+
100
+ function appendLedger(state, actor, kind, summary, agent = activeAgentFor(state, actor)) {
101
+ state.ledger ||= [];
102
+ state.ledger.push({ at: now(), actor, ...agentLedgerFields(agent), kind, summary });
103
+ }
104
+
105
+ const routeRules = [
106
+ {
107
+ role: 'memory',
108
+ support: ['researcher'],
109
+ keywords: ['memory', 'memori', 'ingat', 'recall', 'search', 'cari semula', 'journal', 'ledger', 'history', 'sejarah']
110
+ },
111
+ {
112
+ role: 'github',
113
+ support: ['reviewer'],
114
+ keywords: ['github', 'git', 'branch', 'merge', 'megre', 'commit', 'push', 'pull', 'pr', 'repo', 'repository', 'autosycn', 'autosync']
115
+ },
116
+ {
117
+ role: 'deploy',
118
+ support: ['devops', 'github'],
119
+ keywords: ['deploy', 'deployment', 'vercel', 'docker', 'github pages', 'github actions', 'hosting', 'release']
120
+ },
121
+ {
122
+ role: 'security',
123
+ support: ['architect', 'reviewer'],
124
+ keywords: ['security', 'secure', 'auth', 'login', 'password', 'token', 'secret', 'permission', 'role', 'akses', 'encrypt', 'api key']
125
+ },
126
+ {
127
+ role: 'performance',
128
+ support: ['architect', 'coder'],
129
+ keywords: ['performance', 'slow', 'lambat', 'speed', 'optimize', 'latency', 'memory leak', 'bundle', 'cache']
130
+ },
131
+ {
132
+ role: 'database',
133
+ support: ['backend', 'architect'],
134
+ keywords: ['database', 'db', 'schema', 'migration', 'sql', 'postgres', 'mysql', 'sqlite', 'prisma', 'query']
135
+ },
136
+ {
137
+ role: 'backend',
138
+ support: ['database', 'security', 'tester'],
139
+ keywords: ['backend', 'api', 'server', 'endpoint', 'route', 'auth api', 'middleware', 'webhook', 'integration']
140
+ },
141
+ {
142
+ role: 'frontend',
143
+ support: ['design', 'ux', 'tester'],
144
+ keywords: ['frontend', 'ui', 'react', 'next', 'vue', 'css', 'tailwind', 'component', 'page', 'browser', 'dashboard']
145
+ },
146
+ {
147
+ role: 'mobile',
148
+ support: ['ux', 'backend'],
149
+ keywords: ['mobile', 'android', 'ios', 'react native', 'flutter', 'pwa']
150
+ },
151
+ {
152
+ role: 'design',
153
+ support: ['ux', 'frontend'],
154
+ keywords: ['design', 'ui/ux', 'layout', 'figma', 'wireframe', 'visual', 'color', 'theme', 'responsive']
155
+ },
156
+ {
157
+ role: 'ux',
158
+ support: ['planner', 'design'],
159
+ keywords: ['ux', 'user flow', 'persona', 'journey', 'usability', 'pengguna', 'flow']
160
+ },
161
+ {
162
+ role: 'tester',
163
+ support: ['reviewer'],
164
+ keywords: ['test', 'testing', 'bug', 'error', 'fix', 'regression', 'playwright', 'vitest', 'jest', 'qa']
165
+ },
166
+ {
167
+ role: 'reviewer',
168
+ support: ['security', 'tester'],
169
+ keywords: ['review', 'semak', 'audit', 'check', 'validate', 'risk', 'risiko', 'quality']
170
+ },
171
+ {
172
+ role: 'docs',
173
+ support: ['prompt'],
174
+ keywords: ['docs', 'documentation', 'readme', 'guide', 'manual', 'changelog', 'spec', 'tulis']
175
+ },
176
+ {
177
+ role: 'prompt',
178
+ support: ['architect', 'docs'],
179
+ keywords: ['prompt', 'prompts', 'copy to prompts', 'ai prompt', 'system prompt', 'agent prompt', 'chatgpt', 'claude', 'gemini']
180
+ },
181
+ {
182
+ role: 'architect',
183
+ support: ['planner', 'researcher', 'coder', 'reviewer'],
184
+ keywords: ['system', 'architecture', 'architect', 'platform', 'workflow', 'engine', 'core', 'framework', 'template', 'buat sebuah system', 'bina system']
185
+ },
186
+ {
187
+ role: 'planner',
188
+ support: ['architect', 'researcher'],
189
+ keywords: ['plan', 'roadmap', 'scope', 'idea', 'konsep', 'feature', 'requirement', 'mvp', 'project']
190
+ },
191
+ {
192
+ role: 'coder',
193
+ support: ['tester', 'reviewer'],
194
+ keywords: ['code', 'coding', 'implement', 'buat file', 'ubah file', 'fix code', 'script', 'function']
195
+ },
196
+ {
197
+ role: 'researcher',
198
+ support: ['planner'],
199
+ keywords: ['research', 'kaji', 'compare', 'pilih', 'cari info', 'best practice']
200
+ }
201
+ ];
202
+
203
+ function catalogForRole(state, role) {
204
+ return (state.agentCatalog || []).find((item) => item.role === role) || {
205
+ role,
206
+ title: role.split('-').map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(' ')
207
+ };
208
+ }
209
+
210
+ function ownedAgentForRole(state, actor, role) {
211
+ return (state.agentRoster || []).find((agent) => agent.role === role && (agent.owners || []).includes(actor)) || null;
212
+ }
213
+
214
+ function routeScore(task, rule) {
215
+ return rule.keywords.reduce((score, keyword) => task.includes(keyword) ? score + Math.max(1, keyword.split(/\s+/).length) : score, 0);
216
+ }
217
+
218
+ function uniqueValues(values) {
219
+ return [...new Set(values.filter(Boolean))];
220
+ }
221
+
222
+ function maybeLimit(values, limit) {
223
+ if (limit === null || limit === undefined || limit === '' || limit === 'unlimited') return values;
224
+ const numeric = Number(limit);
225
+ if (!Number.isFinite(numeric) || numeric < 1) return values;
226
+ return values.slice(0, numeric);
227
+ }
228
+
229
+ function shouldActivatePartyMode(state, task, primaryRole, supportRoles, newSystemIntent) {
230
+ if (state.partyMode?.enabled === false || state.partyMode?.autoActivateWhenNeeded === false) return false;
231
+ const multiDomainIntent = [
232
+ ['ui', 'backend'],
233
+ ['frontend', 'backend'],
234
+ ['design', 'api'],
235
+ ['database', 'api'],
236
+ ['deploy', 'github'],
237
+ ['security', 'auth'],
238
+ ['prompt', 'system']
239
+ ].some(([first, second]) => task.includes(first) && task.includes(second));
240
+ const connectiveIntent = /\b(connect|connected|integrate|integration|bersambung|sambung|hubung|flow|workflow)\b/.test(task);
241
+ const broadBuild = newSystemIntent && supportRoles.length >= 2;
242
+ const specialistStack = supportRoles.length >= 3 && ['architect', 'planner', 'core'].includes(primaryRole);
243
+ return multiDomainIntent || connectiveIntent || broadBuild || specialistStack;
244
+ }
245
+
246
+ function partyFormat(state) {
247
+ const format = state.partyMode?.format || {};
248
+ return {
249
+ banner: format.banner || state.partyMode?.banner || 'PARTY MODE',
250
+ agentToAgent: format.agentToAgent || 'agent: <from-name> (<from-role>) to agent: <to-name> (<to-role>)',
251
+ agentToUser: format.agentToUser || 'agent: <from-name> (<from-role>) to <user>',
252
+ explanation: format.explanation || 'agent: <from-name> (<from-role>)',
253
+ messageIndent: format.messageIndent || ' ',
254
+ blankLineBeforeMessage: format.blankLineBeforeMessage !== false
255
+ };
256
+ }
257
+
258
+ function partyParticipantsFor(state, primaryRole, supportRoles, scored, partyActive) {
259
+ if (!partyActive) return [];
260
+ const preferredMinimum = Number(state.partyMode?.preferredMinimumParticipants || 4);
261
+ const minimum = Number(state.partyMode?.minimumParticipants || 3);
262
+ const floor = Number.isFinite(preferredMinimum) ? Math.max(minimum, preferredMinimum) : minimum;
263
+ const fallbackRoles = ['planner', 'researcher', 'reviewer', 'coder', 'architect', 'prompt', 'tester'];
264
+ const participants = uniqueValues([
265
+ primaryRole,
266
+ ...supportRoles,
267
+ ...scored.map((rule) => rule.role),
268
+ ...fallbackRoles
269
+ ]);
270
+ const catalogRoles = new Set((state.agentCatalog || []).map((item) => item.role));
271
+ const filtered = participants.filter((role) => catalogRoles.has(role));
272
+ const enough = filtered.length >= floor ? filtered : participants;
273
+ return maybeLimit(enough, state.partyMode?.participantLimit);
274
+ }
275
+
276
+ function inferAgentRoute(state, taskText) {
277
+ const task = taskText.toLowerCase();
278
+ const words = task.split(/\s+/).filter(Boolean);
279
+ const scored = routeRules
280
+ .map((rule) => ({ ...rule, score: routeScore(task, rule) }))
281
+ .filter((rule) => rule.score > 0)
282
+ .sort((a, b) => b.score - a.score);
283
+
284
+ const newSystemIntent = /\b(system|sistem|app|tool|platform|website|dashboard|engine|core)\b/.test(task)
285
+ || /buat sebuah|bina sebuah|create a|build a/.test(task);
286
+ const implementationIntent = /\b(code|coding|implement|fix|ubah file|buat file)\b/.test(task);
287
+ const top = scored[0];
288
+ let primaryRole = top?.role || state.agentPolicy?.defaultRole || 'core';
289
+
290
+ if (newSystemIntent && !implementationIntent && state.agentRouter?.preferHighReasoningForNewSystems !== false) {
291
+ primaryRole = state.agentRouter?.defaultHighReasoningRole || 'architect';
292
+ }
293
+
294
+ const primary = catalogForRole(state, primaryRole);
295
+ const baseSupport = newSystemIntent
296
+ ? ['planner', 'researcher', 'prompt', 'coder', 'reviewer']
297
+ : (top?.support || []);
298
+ const supportRoles = maybeLimit(uniqueValues([
299
+ ...baseSupport,
300
+ ...scored.slice(1).map((rule) => rule.role)
301
+ ])
302
+ .filter((role) => role !== primaryRole), state.agentRouter?.supportAgentLimit);
303
+ const partyActive = shouldActivatePartyMode(state, task, primaryRole, supportRoles, newSystemIntent);
304
+ const partyParticipants = partyParticipantsFor(state, primaryRole, supportRoles, scored, partyActive);
305
+
306
+ const ambiguousNewSystem = newSystemIntent && words.length < 18;
307
+ const noClearMatch = scored.length === 0 && words.length > 3;
308
+ const needsClarification = state.agentRouter?.clarifyBeforeActionWhenAmbiguous !== false
309
+ && (ambiguousNewSystem || noClearMatch || /\b(maybe|mungkin|lebih kurang|macam)\b/.test(task));
310
+
311
+ const questions = needsClarification ? [
312
+ 'Apa tujuan utama system ini dan masalah apa yang dia selesaikan?',
313
+ 'Siapa pengguna utama system ini?',
314
+ 'Output wajib apa yang awak nak lihat dulu: plan, UI, repo/file, atau prompt template?'
315
+ ] : [];
316
+
317
+ return {
318
+ task: taskText,
319
+ primaryRole,
320
+ primaryTitle: primary.title,
321
+ supportRoles,
322
+ partyMode: {
323
+ active: partyActive,
324
+ banner: partyActive && state.partyMode?.bannerRequired !== false ? (state.partyMode?.banner || 'PARTY MODE') : '',
325
+ participants: partyActive ? partyParticipants : [],
326
+ minimumParticipants: state.partyMode?.minimumParticipants || 3,
327
+ preferredMinimumParticipants: state.partyMode?.preferredMinimumParticipants || 4,
328
+ visibleToUser: state.partyMode?.showAgentDialogueToUser !== false,
329
+ format: partyFormat(state),
330
+ reason: partyActive
331
+ ? 'Task needs several specialist agents to reason together before the primary agent answers the user.'
332
+ : 'Single-agent route is enough for this task.'
333
+ },
334
+ confidence: top ? Math.min(0.95, 0.45 + (top.score * 0.08)) : 0.35,
335
+ needsClarification,
336
+ questions,
337
+ reason: newSystemIntent
338
+ ? `New or broad system task routed to ${primary.title} for high-reasoning planning before implementation.`
339
+ : top
340
+ ? `Matched keywords for ${primary.title}: ${top.keywords.filter((keyword) => task.includes(keyword)).join(', ')}.`
341
+ : `No strong specialist match; using ${primary.title}.`
342
+ };
343
+ }
344
+
345
+ function setup(args) {
346
+ const state = readState();
347
+ if (state.initialized) {
348
+ throw new Error('MemoryOfPlanet already initialized.');
349
+ }
350
+
351
+ const folderDefault = rootDir.split(/[\\/]/).filter(Boolean).pop() || 'MemoryOfPlanet';
352
+ const projectName = String(args['project-name'] || folderDefault);
353
+ const displayName = requireArg(args, 'name');
354
+ const codename = slug(requireArg(args, 'codename'));
355
+ const password = requireArg(args, 'password');
356
+ const mode = requireArg(args, 'mode').toLowerCase();
357
+ const conversationLanguage = String(args['conversation-language'] || 'Melayu');
358
+ const codingLanguage = String(args['coding-language'] || 'English');
359
+ const githubUrl = String(args['github-url'] || '');
360
+ const gitName = String(args['git-name'] || displayName);
361
+ const gitEmail = String(args['git-email'] || '');
362
+ const githubUsername = String(args['github-username'] || '');
363
+ const joinMode = String(args['join-mode'] || 'owner-approved');
364
+
365
+ if (codename.length < 2) throw new Error('Codename too short.');
366
+ if (password.length < 8) throw new Error('Password must be at least 8 characters.');
367
+ if (!['solo', 'team'].includes(mode)) throw new Error('Mode must be solo or team.');
368
+ if (mode === 'team' && !githubUrl) throw new Error('Team mode requires --github-url.');
369
+ if (state.autosync?.requireUserGitEmail !== false && !gitEmail) {
370
+ throw new Error('Git email is required so commits are attributed to the real user, not the AI tool.');
371
+ }
372
+ if (!['open', 'owner-approved', 'invite'].includes(joinMode)) {
373
+ throw new Error('Join mode must be open, owner-approved, or invite.');
374
+ }
375
+
376
+ const { passwordHash, passwordSalt } = hashPassword(password);
377
+ state.initialized = true;
378
+ state.projectName = projectName;
379
+ state.projectNameDefault = folderDefault;
380
+ state.ownerCodename = codename;
381
+ state.activeMember = codename;
382
+ state.activeAgents ||= {};
383
+ state.agentPolicy ||= {
384
+ requiredAfterAuth: true,
385
+ requireForEveryConversation: true,
386
+ defaultRole: 'core',
387
+ defaultTitle: 'Core Agent',
388
+ gateOrder: 'AUTH_GATE_THEN_AGENT_ROUTER_THEN_AGENT_GATE_THEN_ACTION'
389
+ };
390
+ state.mode = mode;
391
+ state.joinMode = mode === 'team' ? joinMode : 'owner-approved';
392
+ state.githubUrl = githubUrl;
393
+ state.members = {
394
+ [codename]: {
395
+ codename,
396
+ displayName,
397
+ role: 'owner',
398
+ passwordHash,
399
+ passwordSalt,
400
+ languagePreferences: {
401
+ conversation: conversationLanguage,
402
+ coding: codingLanguage
403
+ },
404
+ gitIdentity: {
405
+ name: gitName,
406
+ email: gitEmail,
407
+ githubUsername
408
+ },
409
+ joinedAt: now()
410
+ }
411
+ };
412
+ appendLedger(state, codename, 'setup', `Initialized ${projectName} in ${mode} mode.`);
413
+ writeState(state);
414
+ console.log(`MemoryOfPlanet initialized. Owner ${displayName} (${codename}) is active.`);
415
+ }
416
+
417
+ function login(args) {
418
+ const state = readState();
419
+ const codename = slug(requireArg(args, 'codename'));
420
+ const password = requireArg(args, 'password');
421
+ const member = state.members?.[codename];
422
+ if (!member || !verifyPassword(password, member.passwordSalt, member.passwordHash)) {
423
+ console.log('Credentials tidak sah.');
424
+ process.exitCode = 1;
425
+ return;
426
+ }
427
+ state.activeMember = codename;
428
+ appendLedger(state, codename, 'login', 'Member authenticated.');
429
+ writeState(state);
430
+ console.log(`Active member: ${codename}`);
431
+ if (!activeAgentFor(state, codename) && state.agentPolicy?.requiredAfterAuth !== false) {
432
+ console.log(`Agent diperlukan. Jalankan: node .memoryofplanet/scripts/mop-core.mjs agent activate --actor ${codename} --role ${state.agentPolicy?.defaultRole || 'core'} --title "${state.agentPolicy?.defaultTitle || 'Core Agent'}" --name "<agent-name>"`);
433
+ }
434
+ }
435
+
436
+ function agentActivate(args) {
437
+ const state = readState();
438
+ if (!state.initialized) throw new Error('MemoryOfPlanet is not initialized.');
439
+ const actor = slug(requireArg(args, 'actor'));
440
+ if (!state.members?.[actor]) throw new Error('Unknown actor.');
441
+
442
+ const role = slug(requireArg(args, 'role'));
443
+ const title = String(args.title || role);
444
+ const name = requireArg(args, 'name').trim();
445
+ const key = name.toLowerCase();
446
+ state.agentRoster ||= [];
447
+ state.activeAgents ||= {};
448
+
449
+ let agent = state.agentRoster.find((item) => item.name.toLowerCase() === key);
450
+ if (agent) {
451
+ agent.owners ||= [];
452
+ if (!agent.owners.includes(actor)) agent.owners.push(actor);
453
+ appendLedger(state, actor, 'agent-share', `${actor} joined agent ${agent.name}.`);
454
+ } else {
455
+ agent = {
456
+ id: `agent-${slug(name)}`,
457
+ role,
458
+ title,
459
+ name,
460
+ owners: [actor],
461
+ createdBy: actor,
462
+ createdAt: now()
463
+ };
464
+ state.agentRoster.push(agent);
465
+ appendLedger(state, actor, 'agent-activate', `Named ${title} as ${name}.`);
466
+ }
467
+ state.activeAgents[actor] = agent.id;
468
+ appendLedger(state, actor, 'agent-use', `Set active agent to ${agent.name}.`, agent);
469
+ writeState(state);
470
+ console.log(`Agent active: ${agent.name} (${agent.role}) owners=${agent.owners.join(',')}`);
471
+ }
472
+
473
+ function agentUse(args) {
474
+ const state = readState();
475
+ if (!state.initialized) throw new Error('MemoryOfPlanet is not initialized.');
476
+ const actor = slug(requireArg(args, 'actor'));
477
+ if (!state.members?.[actor]) throw new Error('Unknown actor.');
478
+ const name = requireArg(args, 'name').trim();
479
+ const agent = (state.agentRoster || []).find((item) => item.name.toLowerCase() === name.toLowerCase());
480
+ if (!agent) throw new Error(`Unknown agent: ${name}`);
481
+ if (!(agent.owners || []).includes(actor)) throw new Error(`${actor} does not own agent ${agent.name}.`);
482
+ state.activeAgents ||= {};
483
+ state.activeAgents[actor] = agent.id;
484
+ appendLedger(state, actor, 'agent-use', `Set active agent to ${agent.name}.`, agent);
485
+ writeState(state);
486
+ console.log(`Active agent for ${actor}: ${agent.name} (${agent.role})`);
487
+ }
488
+
489
+ function agentCurrent(args) {
490
+ const state = readState();
491
+ const actor = slug(requireArg(args, 'actor'));
492
+ const agent = activeAgentFor(state, actor);
493
+ if (!agent) {
494
+ console.log(`No active agent for ${actor}.`);
495
+ process.exitCode = 2;
496
+ return;
497
+ }
498
+ console.log(JSON.stringify({
499
+ actor,
500
+ agent: agent.name,
501
+ role: agent.role,
502
+ title: agent.title,
503
+ id: agent.id
504
+ }, null, 2));
505
+ }
506
+
507
+ function agentRequire(args) {
508
+ const state = readState();
509
+ const actor = slug(requireArg(args, 'actor'));
510
+ const role = slug(String(args.role || state.agentPolicy?.defaultRole || 'core'));
511
+ const title = String(args.title || state.agentPolicy?.defaultTitle || 'Core Agent');
512
+ const agent = requireActiveAgent(state, actor, role, title);
513
+ console.log(JSON.stringify({
514
+ actor,
515
+ agent: agent.name,
516
+ role: agent.role,
517
+ title: agent.title,
518
+ id: agent.id
519
+ }, null, 2));
520
+ }
521
+
522
+ function agentRoute(args) {
523
+ const state = readState();
524
+ if (!state.initialized) throw new Error('MemoryOfPlanet is not initialized.');
525
+ if (state.agentRouter?.enabled === false) throw new Error('Agent Router is disabled.');
526
+ const actor = slug(requireArg(args, 'actor'));
527
+ if (!state.members?.[actor]) throw new Error('Unknown actor.');
528
+ const task = String(args.task || args._?.join(' ') || '').trim();
529
+ if (!task) throw new Error('Missing --task');
530
+
531
+ const route = inferAgentRoute(state, task);
532
+ const agent = ownedAgentForRole(state, actor, route.primaryRole);
533
+ const partyAgents = route.partyMode.active ? route.partyMode.participants.map((role) => {
534
+ const catalog = catalogForRole(state, role);
535
+ const owned = ownedAgentForRole(state, actor, role);
536
+ return {
537
+ role,
538
+ title: catalog.title,
539
+ name: owned?.name || null,
540
+ id: owned?.id || null,
541
+ missing: !owned
542
+ };
543
+ }) : [];
544
+ const missingPartyAgents = partyAgents.filter((item) => item.missing);
545
+ const response = {
546
+ ok: Boolean(agent),
547
+ actor,
548
+ route,
549
+ partyAgents,
550
+ activeAgent: null,
551
+ nextAction: null
552
+ };
553
+
554
+ if (agent) {
555
+ state.activeAgents ||= {};
556
+ state.activeAgents[actor] = agent.id;
557
+ appendLedger(state, actor, 'agent-route', `Routed task to ${agent.name}: ${route.reason}`, agent);
558
+ writeState(state);
559
+ response.activeAgent = {
560
+ id: agent.id,
561
+ name: agent.name,
562
+ role: agent.role,
563
+ title: agent.title
564
+ };
565
+ if (route.partyMode.active && missingPartyAgents.length) {
566
+ response.ok = false;
567
+ response.nextAction = 'name-required-party-agents';
568
+ response.message = 'Party mode diperlukan, tetapi ada agent terlibat yang belum dinamakan.';
569
+ response.missingAgentCommands = missingPartyAgents.map((item) => (
570
+ `node .memoryofplanet/scripts/mop-core.mjs agent activate --actor ${actor} --role ${item.role} --title "${item.title}" --name "<agent-name>"`
571
+ ));
572
+ } else {
573
+ response.nextAction = route.needsClarification ? 'ask-clarifying-questions' : 'proceed-with-agent';
574
+ }
575
+ } else {
576
+ response.nextAction = 'name-required-agent';
577
+ response.message = `Task ini perlukan ${route.primaryTitle}. Agent ini belum ada nama lagi atau belum dipilih.`;
578
+ response.ask = `Beri nama untuk ${route.primaryTitle} kamu:`;
579
+ response.command = `node .memoryofplanet/scripts/mop-core.mjs agent activate --actor ${actor} --role ${route.primaryRole} --title "${route.primaryTitle}" --name "<agent-name>"`;
580
+ if (route.needsClarification) response.afterNaming = route.questions;
581
+ }
582
+
583
+ console.log(JSON.stringify(response, null, 2));
584
+ }
585
+
586
+ function agentList() {
587
+ const state = readState();
588
+ console.log(JSON.stringify({
589
+ activeAgents: state.activeAgents || {},
590
+ agents: state.agentRoster || []
591
+ }, null, 2));
592
+ }
593
+
594
+ function memberGitIdentity(args) {
595
+ const state = readState();
596
+ if (!state.initialized) throw new Error('MemoryOfPlanet is not initialized.');
597
+ const actor = slug(requireArg(args, 'actor'));
598
+ const member = state.members?.[actor];
599
+ if (!member) throw new Error('Unknown actor.');
600
+ const agent = requireActiveAgent(state, actor);
601
+ const name = String(args.name || member.displayName || actor);
602
+ const email = requireArg(args, 'email');
603
+ const githubUsername = String(args['github-username'] || member.gitIdentity?.githubUsername || '');
604
+ member.gitIdentity = { name, email, githubUsername };
605
+ appendLedger(state, actor, 'git-identity', `Updated git identity for ${actor}.`, agent);
606
+ writeState(state);
607
+ console.log(`Git identity set for ${actor}: ${name} <${email}>${githubUsername ? ` github=${githubUsername}` : ''}`);
608
+ }
609
+
610
+ function validate() {
611
+ const state = readState();
612
+ const errors = [];
613
+ if (typeof state.initialized !== 'boolean') errors.push('initialized must be boolean');
614
+ if (!state.projectName) errors.push('projectName is required');
615
+ if (!Array.isArray(state.agentRoster)) errors.push('agentRoster must be array');
616
+ if (!Array.isArray(state.agentCatalog)) errors.push('agentCatalog must be array');
617
+ if (state.activeAgents && typeof state.activeAgents !== 'object') errors.push('activeAgents must be object');
618
+ if (state.agentPolicy && typeof state.agentPolicy !== 'object') errors.push('agentPolicy must be object');
619
+ if (state.agentRouter && typeof state.agentRouter !== 'object') errors.push('agentRouter must be object');
620
+ if (state.partyMode && typeof state.partyMode !== 'object') errors.push('partyMode must be object');
621
+ if (state.projectRootPolicy && typeof state.projectRootPolicy !== 'object') errors.push('projectRootPolicy must be object');
622
+ if (state.projectRootPolicy?.rules && !Array.isArray(state.projectRootPolicy.rules)) {
623
+ errors.push('projectRootPolicy.rules must be array');
624
+ }
625
+ if (!Array.isArray(state.ledger)) errors.push('ledger must be array');
626
+ const catalogRoles = new Set();
627
+ for (const item of state.agentCatalog || []) {
628
+ if (!item.role) errors.push('agentCatalog entry missing role');
629
+ if (!item.title) errors.push(`agentCatalog ${item.role || '<unknown>'} missing title`);
630
+ if (item.role && catalogRoles.has(item.role)) errors.push(`duplicate agentCatalog role: ${item.role}`);
631
+ if (item.role) catalogRoles.add(item.role);
632
+ }
633
+ const routerRole = state.agentRouter?.defaultHighReasoningRole;
634
+ if (routerRole && !catalogRoles.has(routerRole)) {
635
+ errors.push(`agentRouter.defaultHighReasoningRole missing from agentCatalog: ${routerRole}`);
636
+ }
637
+ const defaultRole = state.agentPolicy?.defaultRole;
638
+ if (defaultRole && !catalogRoles.has(defaultRole)) {
639
+ errors.push(`agentPolicy.defaultRole missing from agentCatalog: ${defaultRole}`);
640
+ }
641
+ for (const phase of state.workflow?.phases || []) {
642
+ if (!phase.id) errors.push('workflow phase missing id');
643
+ if (phase.primaryRole && !catalogRoles.has(phase.primaryRole)) {
644
+ errors.push(`workflow phase ${phase.id} primaryRole missing from agentCatalog: ${phase.primaryRole}`);
645
+ }
646
+ for (const role of phase.partyRoles || []) {
647
+ if (!catalogRoles.has(role)) errors.push(`workflow phase ${phase.id} partyRole missing from agentCatalog: ${role}`);
648
+ }
649
+ if (phase.artifact && !(state.artifacts?.types || []).includes(phase.artifact)) {
650
+ errors.push(`workflow phase ${phase.id} artifact missing from artifact types: ${phase.artifact}`);
651
+ }
652
+ }
653
+ for (const type of state.artifacts?.types || []) {
654
+ const templatePath = join(rootDir, state.artifacts?.templateDirectory || '.memoryofplanet/templates/artifacts', `${type}.md`);
655
+ if (!existsSync(templatePath)) errors.push(`artifact template missing: ${templatePath}`);
656
+ const folder = state.artifacts?.folderByType?.[type];
657
+ if (state.artifacts?.folderByType && (!folder || typeof folder !== 'string')) {
658
+ errors.push(`artifact folder missing for type: ${type}`);
659
+ }
660
+ }
661
+ if (state.installer?.entrypoint && !existsSync(join(rootDir, state.installer.entrypoint))) {
662
+ errors.push(`installer entrypoint missing: ${state.installer.entrypoint}`);
663
+ }
664
+ if (state.initialized) {
665
+ if (!state.ownerCodename) errors.push('ownerCodename is required after setup');
666
+ if (!state.members?.[state.ownerCodename]) errors.push('owner member missing');
667
+ if (!['solo', 'team'].includes(state.mode)) errors.push('mode must be solo or team');
668
+ if (state.mode === 'team' && !state.githubUrl) errors.push('team mode requires githubUrl');
669
+ if (state.autosync?.requireUserGitEmail !== false) {
670
+ for (const [codename, member] of Object.entries(state.members || {})) {
671
+ if (!member.gitIdentity?.email && !member.github?.noreplyEmail) {
672
+ errors.push(`member ${codename} is missing git identity email`);
673
+ }
674
+ }
675
+ }
676
+ for (const [codename, agentId] of Object.entries(state.activeAgents || {})) {
677
+ const agent = (state.agentRoster || []).find((item) => item.id === agentId || item.name === agentId);
678
+ if (!agent) errors.push(`active agent for ${codename} is missing from agentRoster`);
679
+ if (agent && !(agent.owners || []).includes(codename)) errors.push(`active agent ${agent.name} does not include owner ${codename}`);
680
+ }
681
+ }
682
+ if (errors.length) {
683
+ console.error(errors.join('\n'));
684
+ process.exitCode = 1;
685
+ return;
686
+ }
687
+ console.log('MemoryOfPlanet state OK.');
688
+ }
689
+
690
+ function status() {
691
+ const state = readState();
692
+ console.log(JSON.stringify({
693
+ initialized: state.initialized,
694
+ projectName: state.projectName,
695
+ activeMember: state.activeMember,
696
+ activeAgents: Object.fromEntries(Object.entries(state.activeAgents || {}).map(([codename, agentId]) => {
697
+ const agent = (state.agentRoster || []).find((item) => item.id === agentId || item.name === agentId);
698
+ return [codename, agent ? { name: agent.name, role: agent.role, id: agent.id } : { id: agentId, missing: true }];
699
+ })),
700
+ agentPolicy: state.agentPolicy || {},
701
+ agentRouter: state.agentRouter || {},
702
+ partyMode: state.partyMode || {},
703
+ workflow: {
704
+ enabled: state.workflow?.enabled !== false,
705
+ currentPhase: state.workflow?.currentPhase || null,
706
+ phases: state.workflow?.phaseOrder || []
707
+ },
708
+ artifacts: state.artifacts || {},
709
+ projectRootPolicy: state.projectRootPolicy || {},
710
+ readinessGate: state.readinessGate || {},
711
+ adversarialReview: state.adversarialReview || {},
712
+ installer: state.installer || {},
713
+ mode: state.mode,
714
+ githubUrl: state.githubUrl,
715
+ members: Object.keys(state.members || {}),
716
+ agents: (state.agentRoster || []).map((agent) => ({
717
+ name: agent.name,
718
+ role: agent.role,
719
+ owners: agent.owners
720
+ })),
721
+ autosync: {
722
+ enabled: state.autosync?.enabled !== false,
723
+ requireUserGitEmail: state.autosync?.requireUserGitEmail !== false
724
+ },
725
+ gitIdentities: Object.fromEntries(Object.entries(state.members || {}).map(([codename, member]) => [
726
+ codename,
727
+ {
728
+ name: member.gitIdentity?.name || member.displayName || codename,
729
+ email: member.gitIdentity?.email || member.github?.noreplyEmail || '',
730
+ githubUsername: member.gitIdentity?.githubUsername || member.github?.username || ''
731
+ }
732
+ ]))
733
+ }, null, 2));
734
+ }
735
+
736
+ function main() {
737
+ if (!existsSync(statePath)) {
738
+ throw new Error(`Missing state file: ${statePath}`);
739
+ }
740
+ const [command, subcommand, ...rest] = process.argv.slice(2);
741
+ const args = parseArgs(rest);
742
+
743
+ if (command === 'setup') return setup(parseArgs([subcommand, ...rest].filter(Boolean)));
744
+ if (command === 'login') return login(parseArgs([subcommand, ...rest].filter(Boolean)));
745
+ if (command === 'validate') return validate();
746
+ if (command === 'status') return status();
747
+ if (command === 'member' && subcommand === 'git-identity') return memberGitIdentity(args);
748
+ if (command === 'agent' && subcommand === 'activate') return agentActivate(args);
749
+ if (command === 'agent' && subcommand === 'use') return agentUse(args);
750
+ if (command === 'agent' && subcommand === 'current') return agentCurrent(args);
751
+ if (command === 'agent' && subcommand === 'require') return agentRequire(args);
752
+ if (command === 'agent' && subcommand === 'route') return agentRoute(args);
753
+ if (command === 'agent' && subcommand === 'list') return agentList();
754
+
755
+ console.log(`Usage:
756
+ node .memoryofplanet/scripts/mop-core.mjs status
757
+ node .memoryofplanet/scripts/mop-core.mjs validate
758
+ node .memoryofplanet/scripts/mop-core.mjs setup --project-name NAME --name DISPLAY --codename CODE --password PASS --mode solo|team --conversation-language LANG --coding-language LANG --git-email EMAIL [--git-name NAME] [--github-username USER] [--github-url URL]
759
+ node .memoryofplanet/scripts/mop-core.mjs login --codename CODE --password PASS
760
+ node .memoryofplanet/scripts/mop-core.mjs member git-identity --actor CODE --name NAME --email EMAIL [--github-username USER]
761
+ node .memoryofplanet/scripts/mop-core.mjs agent activate --actor CODE --role ROLE --title TITLE --name NAME
762
+ node .memoryofplanet/scripts/mop-core.mjs agent use --actor CODE --name NAME
763
+ node .memoryofplanet/scripts/mop-core.mjs agent current --actor CODE
764
+ node .memoryofplanet/scripts/mop-core.mjs agent require --actor CODE [--role ROLE] [--title TITLE]
765
+ node .memoryofplanet/scripts/mop-core.mjs agent route --actor CODE --task "task text"
766
+ node .memoryofplanet/scripts/mop-core.mjs agent list`);
767
+ }
768
+
769
+ try {
770
+ main();
771
+ } catch (error) {
772
+ console.error(error.message);
773
+ process.exitCode = 1;
774
+ }