@claude-flow/cli 3.32.26 → 3.32.30

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 (403) hide show
  1. package/.claude/helpers/.helpers-version +1 -1
  2. package/.claude/helpers/helpers.manifest.json +2 -2
  3. package/catalog-manifest.json +4 -4
  4. package/dist/src/commands/index.d.ts +1 -0
  5. package/dist/src/commands/index.js +5 -3
  6. package/dist/src/commands/memory.js +49 -5
  7. package/dist/src/commands/metaharness.js +25 -5
  8. package/dist/src/commands/policy.d.ts +4 -0
  9. package/dist/src/commands/policy.js +107 -0
  10. package/dist/src/index.js +18 -0
  11. package/dist/src/init/claudemd-generator.js +53 -2
  12. package/dist/src/mcp-client.js +25 -1
  13. package/dist/src/mcp-tools/capability-brain.d.ts +134 -0
  14. package/dist/src/mcp-tools/capability-brain.js +697 -0
  15. package/dist/src/mcp-tools/guidance-tools.d.ts +2 -0
  16. package/dist/src/mcp-tools/guidance-tools.js +369 -37
  17. package/dist/src/mcp-tools/index.d.ts +4 -1
  18. package/dist/src/mcp-tools/index.js +3 -1
  19. package/dist/src/mcp-tools/memory-tools.js +26 -0
  20. package/dist/src/mcp-tools/metaharness-tools.js +27 -1
  21. package/dist/src/mcp-tools/policy-tools.d.ts +3 -0
  22. package/dist/src/mcp-tools/policy-tools.js +121 -0
  23. package/dist/src/memory/memory-bridge.d.ts +11 -0
  24. package/dist/src/memory/memory-bridge.js +100 -21
  25. package/dist/src/memory/memory-initializer.d.ts +22 -1
  26. package/dist/src/memory/memory-initializer.js +184 -39
  27. package/dist/src/services/bounded-worker-pool.d.ts +28 -0
  28. package/dist/src/services/bounded-worker-pool.js +90 -0
  29. package/dist/src/services/harness-flywheel-runtime.d.ts +2 -0
  30. package/dist/src/services/harness-flywheel-runtime.js +18 -0
  31. package/dist/src/services/harness-flywheel.d.ts +4 -1
  32. package/dist/src/services/harness-flywheel.js +27 -6
  33. package/dist/src/services/policy-runtime.d.ts +38 -0
  34. package/dist/src/services/policy-runtime.js +340 -0
  35. package/node_modules/@claude-flow/codex/.agents/skills/memory-management/SKILL.md +45 -0
  36. package/node_modules/@claude-flow/codex/.agents/skills/security-audit/SKILL.md +46 -0
  37. package/node_modules/@claude-flow/codex/.agents/skills/sparc-methodology/SKILL.md +46 -0
  38. package/node_modules/@claude-flow/codex/.agents/skills/swarm-orchestration/SKILL.md +53 -0
  39. package/node_modules/@claude-flow/codex/README.md +1044 -0
  40. package/node_modules/@claude-flow/codex/dist/cli.d.ts +9 -0
  41. package/node_modules/@claude-flow/codex/dist/cli.d.ts.map +1 -0
  42. package/node_modules/@claude-flow/codex/dist/cli.js +686 -0
  43. package/node_modules/@claude-flow/codex/dist/cli.js.map +1 -0
  44. package/node_modules/@claude-flow/codex/dist/dual-mode/cli.d.ts +17 -0
  45. package/node_modules/@claude-flow/codex/dist/dual-mode/cli.d.ts.map +1 -0
  46. package/node_modules/@claude-flow/codex/dist/dual-mode/cli.js +278 -0
  47. package/node_modules/@claude-flow/codex/dist/dual-mode/cli.js.map +1 -0
  48. package/node_modules/@claude-flow/codex/dist/dual-mode/index.d.ts +8 -0
  49. package/node_modules/@claude-flow/codex/dist/dual-mode/index.d.ts.map +1 -0
  50. package/node_modules/@claude-flow/codex/dist/dual-mode/index.js +7 -0
  51. package/node_modules/@claude-flow/codex/dist/dual-mode/index.js.map +1 -0
  52. package/node_modules/@claude-flow/codex/dist/dual-mode/orchestrator.d.ts +143 -0
  53. package/node_modules/@claude-flow/codex/dist/dual-mode/orchestrator.d.ts.map +1 -0
  54. package/node_modules/@claude-flow/codex/dist/dual-mode/orchestrator.js +621 -0
  55. package/node_modules/@claude-flow/codex/dist/dual-mode/orchestrator.js.map +1 -0
  56. package/node_modules/@claude-flow/codex/dist/generators/agents-md.d.ts +12 -0
  57. package/node_modules/@claude-flow/codex/dist/generators/agents-md.d.ts.map +1 -0
  58. package/node_modules/@claude-flow/codex/dist/generators/agents-md.js +730 -0
  59. package/node_modules/@claude-flow/codex/dist/generators/agents-md.js.map +1 -0
  60. package/node_modules/@claude-flow/codex/dist/generators/config-toml.d.ts +74 -0
  61. package/node_modules/@claude-flow/codex/dist/generators/config-toml.d.ts.map +1 -0
  62. package/node_modules/@claude-flow/codex/dist/generators/config-toml.js +922 -0
  63. package/node_modules/@claude-flow/codex/dist/generators/config-toml.js.map +1 -0
  64. package/node_modules/@claude-flow/codex/dist/generators/index.d.ts +9 -0
  65. package/node_modules/@claude-flow/codex/dist/generators/index.d.ts.map +1 -0
  66. package/node_modules/@claude-flow/codex/dist/generators/index.js +9 -0
  67. package/node_modules/@claude-flow/codex/dist/generators/index.js.map +1 -0
  68. package/node_modules/@claude-flow/codex/dist/generators/skill-md.d.ts +20 -0
  69. package/node_modules/@claude-flow/codex/dist/generators/skill-md.d.ts.map +1 -0
  70. package/node_modules/@claude-flow/codex/dist/generators/skill-md.js +951 -0
  71. package/node_modules/@claude-flow/codex/dist/generators/skill-md.js.map +1 -0
  72. package/node_modules/@claude-flow/codex/dist/harness/build-evidence.d.ts +46 -0
  73. package/node_modules/@claude-flow/codex/dist/harness/build-evidence.d.ts.map +1 -0
  74. package/node_modules/@claude-flow/codex/dist/harness/build-evidence.js +126 -0
  75. package/node_modules/@claude-flow/codex/dist/harness/build-evidence.js.map +1 -0
  76. package/node_modules/@claude-flow/codex/dist/harness/contract.d.ts +153 -0
  77. package/node_modules/@claude-flow/codex/dist/harness/contract.d.ts.map +1 -0
  78. package/node_modules/@claude-flow/codex/dist/harness/contract.js +44 -0
  79. package/node_modules/@claude-flow/codex/dist/harness/contract.js.map +1 -0
  80. package/node_modules/@claude-flow/codex/dist/harness/in-memory-fenced-lease-reference.d.ts +33 -0
  81. package/node_modules/@claude-flow/codex/dist/harness/in-memory-fenced-lease-reference.d.ts.map +1 -0
  82. package/node_modules/@claude-flow/codex/dist/harness/in-memory-fenced-lease-reference.js +175 -0
  83. package/node_modules/@claude-flow/codex/dist/harness/in-memory-fenced-lease-reference.js.map +1 -0
  84. package/node_modules/@claude-flow/codex/dist/harness/in-memory-inbox-reference.d.ts +42 -0
  85. package/node_modules/@claude-flow/codex/dist/harness/in-memory-inbox-reference.d.ts.map +1 -0
  86. package/node_modules/@claude-flow/codex/dist/harness/in-memory-inbox-reference.js +140 -0
  87. package/node_modules/@claude-flow/codex/dist/harness/in-memory-inbox-reference.js.map +1 -0
  88. package/node_modules/@claude-flow/codex/dist/harness/in-memory-run-receipt-reference.d.ts +19 -0
  89. package/node_modules/@claude-flow/codex/dist/harness/in-memory-run-receipt-reference.d.ts.map +1 -0
  90. package/node_modules/@claude-flow/codex/dist/harness/in-memory-run-receipt-reference.js +79 -0
  91. package/node_modules/@claude-flow/codex/dist/harness/in-memory-run-receipt-reference.js.map +1 -0
  92. package/node_modules/@claude-flow/codex/dist/harness/index.d.ts +9 -0
  93. package/node_modules/@claude-flow/codex/dist/harness/index.d.ts.map +1 -0
  94. package/node_modules/@claude-flow/codex/dist/harness/index.js +9 -0
  95. package/node_modules/@claude-flow/codex/dist/harness/index.js.map +1 -0
  96. package/node_modules/@claude-flow/codex/dist/harness/portable-case-fold.d.ts +8 -0
  97. package/node_modules/@claude-flow/codex/dist/harness/portable-case-fold.d.ts.map +1 -0
  98. package/node_modules/@claude-flow/codex/dist/harness/portable-case-fold.js +10 -0
  99. package/node_modules/@claude-flow/codex/dist/harness/portable-case-fold.js.map +1 -0
  100. package/node_modules/@claude-flow/codex/dist/harness/repository-state.d.ts +68 -0
  101. package/node_modules/@claude-flow/codex/dist/harness/repository-state.d.ts.map +1 -0
  102. package/node_modules/@claude-flow/codex/dist/harness/repository-state.js +403 -0
  103. package/node_modules/@claude-flow/codex/dist/harness/repository-state.js.map +1 -0
  104. package/node_modules/@claude-flow/codex/dist/harness/unsigned-integer.d.ts +3 -0
  105. package/node_modules/@claude-flow/codex/dist/harness/unsigned-integer.d.ts.map +1 -0
  106. package/node_modules/@claude-flow/codex/dist/harness/unsigned-integer.js +14 -0
  107. package/node_modules/@claude-flow/codex/dist/harness/unsigned-integer.js.map +1 -0
  108. package/node_modules/@claude-flow/codex/dist/index.d.ts +53 -0
  109. package/node_modules/@claude-flow/codex/dist/index.d.ts.map +1 -0
  110. package/node_modules/@claude-flow/codex/dist/index.js +54 -0
  111. package/node_modules/@claude-flow/codex/dist/index.js.map +1 -0
  112. package/node_modules/@claude-flow/codex/dist/initializer.d.ts +98 -0
  113. package/node_modules/@claude-flow/codex/dist/initializer.d.ts.map +1 -0
  114. package/node_modules/@claude-flow/codex/dist/initializer.js +795 -0
  115. package/node_modules/@claude-flow/codex/dist/initializer.js.map +1 -0
  116. package/node_modules/@claude-flow/codex/dist/loop/cli.d.ts +3 -0
  117. package/node_modules/@claude-flow/codex/dist/loop/cli.d.ts.map +1 -0
  118. package/node_modules/@claude-flow/codex/dist/loop/cli.js +123 -0
  119. package/node_modules/@claude-flow/codex/dist/loop/cli.js.map +1 -0
  120. package/node_modules/@claude-flow/codex/dist/loop/index.d.ts +58 -0
  121. package/node_modules/@claude-flow/codex/dist/loop/index.d.ts.map +1 -0
  122. package/node_modules/@claude-flow/codex/dist/loop/index.js +230 -0
  123. package/node_modules/@claude-flow/codex/dist/loop/index.js.map +1 -0
  124. package/node_modules/@claude-flow/codex/dist/mcp-config.d.ts +28 -0
  125. package/node_modules/@claude-flow/codex/dist/mcp-config.d.ts.map +1 -0
  126. package/node_modules/@claude-flow/codex/dist/mcp-config.js +121 -0
  127. package/node_modules/@claude-flow/codex/dist/mcp-config.js.map +1 -0
  128. package/node_modules/@claude-flow/codex/dist/migrations/index.d.ts +114 -0
  129. package/node_modules/@claude-flow/codex/dist/migrations/index.d.ts.map +1 -0
  130. package/node_modules/@claude-flow/codex/dist/migrations/index.js +880 -0
  131. package/node_modules/@claude-flow/codex/dist/migrations/index.js.map +1 -0
  132. package/node_modules/@claude-flow/codex/dist/templates/index.d.ts +92 -0
  133. package/node_modules/@claude-flow/codex/dist/templates/index.d.ts.map +1 -0
  134. package/node_modules/@claude-flow/codex/dist/templates/index.js +284 -0
  135. package/node_modules/@claude-flow/codex/dist/templates/index.js.map +1 -0
  136. package/node_modules/@claude-flow/codex/dist/types.d.ts +240 -0
  137. package/node_modules/@claude-flow/codex/dist/types.d.ts.map +1 -0
  138. package/node_modules/@claude-flow/codex/dist/types.js +8 -0
  139. package/node_modules/@claude-flow/codex/dist/types.js.map +1 -0
  140. package/node_modules/@claude-flow/codex/dist/validators/index.d.ts +42 -0
  141. package/node_modules/@claude-flow/codex/dist/validators/index.d.ts.map +1 -0
  142. package/node_modules/@claude-flow/codex/dist/validators/index.js +929 -0
  143. package/node_modules/@claude-flow/codex/dist/validators/index.js.map +1 -0
  144. package/node_modules/@claude-flow/codex/dist/worktrees/coordinator.d.ts +37 -0
  145. package/node_modules/@claude-flow/codex/dist/worktrees/coordinator.d.ts.map +1 -0
  146. package/node_modules/@claude-flow/codex/dist/worktrees/coordinator.js +137 -0
  147. package/node_modules/@claude-flow/codex/dist/worktrees/coordinator.js.map +1 -0
  148. package/node_modules/@claude-flow/codex/dist/worktrees/index.d.ts +2 -0
  149. package/node_modules/@claude-flow/codex/dist/worktrees/index.d.ts.map +1 -0
  150. package/node_modules/@claude-flow/codex/dist/worktrees/index.js +2 -0
  151. package/node_modules/@claude-flow/codex/dist/worktrees/index.js.map +1 -0
  152. package/node_modules/@claude-flow/codex/package.json +122 -0
  153. package/node_modules/@claude-flow/plugin-agent-federation/README.md +49 -0
  154. package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/agent-card.d.ts +130 -0
  155. package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/agent-card.d.ts.map +1 -0
  156. package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/agent-card.js +239 -0
  157. package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/agent-card.js.map +1 -0
  158. package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/consume.d.ts +34 -0
  159. package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/consume.d.ts.map +1 -0
  160. package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/consume.js +69 -0
  161. package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/consume.js.map +1 -0
  162. package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/well-known.d.ts +46 -0
  163. package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/well-known.d.ts.map +1 -0
  164. package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/well-known.js +84 -0
  165. package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/well-known.js.map +1 -0
  166. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/claim-checker.d.ts +27 -0
  167. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/claim-checker.d.ts.map +1 -0
  168. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/claim-checker.js +46 -0
  169. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/claim-checker.js.map +1 -0
  170. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-breaker-service.d.ts +192 -0
  171. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-breaker-service.d.ts.map +1 -0
  172. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-breaker-service.js +253 -0
  173. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-breaker-service.js.map +1 -0
  174. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-coordinator.d.ts +211 -0
  175. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-coordinator.d.ts.map +1 -0
  176. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-coordinator.js +501 -0
  177. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-coordinator.js.map +1 -0
  178. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/inbound-dispatcher.d.ts +114 -0
  179. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/inbound-dispatcher.d.ts.map +1 -0
  180. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/inbound-dispatcher.js +356 -0
  181. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/inbound-dispatcher.js.map +1 -0
  182. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/policy-engine.d.ts +41 -0
  183. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/policy-engine.d.ts.map +1 -0
  184. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/policy-engine.js +184 -0
  185. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/policy-engine.js.map +1 -0
  186. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/spend-reporter.d.ts +150 -0
  187. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/spend-reporter.d.ts.map +1 -0
  188. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/spend-reporter.js +128 -0
  189. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/spend-reporter.js.map +1 -0
  190. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/trust-evaluator.d.ts +74 -0
  191. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/trust-evaluator.d.ts.map +1 -0
  192. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/trust-evaluator.js +179 -0
  193. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/trust-evaluator.js.map +1 -0
  194. package/node_modules/@claude-flow/plugin-agent-federation/dist/bin.d.ts +13 -0
  195. package/node_modules/@claude-flow/plugin-agent-federation/dist/bin.d.ts.map +1 -0
  196. package/node_modules/@claude-flow/plugin-agent-federation/dist/bin.js +189 -0
  197. package/node_modules/@claude-flow/plugin-agent-federation/dist/bin.js.map +1 -0
  198. package/node_modules/@claude-flow/plugin-agent-federation/dist/cli-commands.d.ts +7 -0
  199. package/node_modules/@claude-flow/plugin-agent-federation/dist/cli-commands.d.ts.map +1 -0
  200. package/node_modules/@claude-flow/plugin-agent-federation/dist/cli-commands.js +317 -0
  201. package/node_modules/@claude-flow/plugin-agent-federation/dist/cli-commands.js.map +1 -0
  202. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-envelope.d.ts +45 -0
  203. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-envelope.d.ts.map +1 -0
  204. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-envelope.js +71 -0
  205. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-envelope.js.map +1 -0
  206. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-node.d.ts +104 -0
  207. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-node.d.ts.map +1 -0
  208. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-node.js +152 -0
  209. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-node.js.map +1 -0
  210. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-session.d.ts +55 -0
  211. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-session.d.ts.map +1 -0
  212. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-session.js +105 -0
  213. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-session.js.map +1 -0
  214. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/trust-level.d.ts +17 -0
  215. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/trust-level.d.ts.map +1 -0
  216. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/trust-level.js +35 -0
  217. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/trust-level.js.map +1 -0
  218. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/audit-service.d.ts +69 -0
  219. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/audit-service.d.ts.map +1 -0
  220. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/audit-service.js +149 -0
  221. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/audit-service.js.map +1 -0
  222. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/discovery-service.d.ts +68 -0
  223. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/discovery-service.d.ts.map +1 -0
  224. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/discovery-service.js +161 -0
  225. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/discovery-service.js.map +1 -0
  226. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/handshake-service.d.ts +58 -0
  227. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/handshake-service.d.ts.map +1 -0
  228. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/handshake-service.js +122 -0
  229. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/handshake-service.js.map +1 -0
  230. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/pii-pipeline-service.d.ts +65 -0
  231. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/pii-pipeline-service.d.ts.map +1 -0
  232. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/pii-pipeline-service.js +208 -0
  233. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/pii-pipeline-service.js.map +1 -0
  234. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/routing-service.d.ts +51 -0
  235. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/routing-service.d.ts.map +1 -0
  236. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/routing-service.js +147 -0
  237. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/routing-service.js.map +1 -0
  238. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-firewall-service.d.ts +71 -0
  239. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-firewall-service.d.ts.map +1 -0
  240. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-firewall-service.js +194 -0
  241. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-firewall-service.js.map +1 -0
  242. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-mesh-service.d.ts +156 -0
  243. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-mesh-service.d.ts.map +1 -0
  244. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-mesh-service.js +292 -0
  245. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-mesh-service.js.map +1 -0
  246. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-witness-service.d.ts +98 -0
  247. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-witness-service.d.ts.map +1 -0
  248. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-witness-service.js +122 -0
  249. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-witness-service.js.map +1 -0
  250. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-budget.d.ts +89 -0
  251. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-budget.d.ts.map +1 -0
  252. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-budget.js +165 -0
  253. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-budget.js.map +1 -0
  254. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-node-state.d.ts +92 -0
  255. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-node-state.d.ts.map +1 -0
  256. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-node-state.js +100 -0
  257. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-node-state.js.map +1 -0
  258. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/wg-config.d.ts +70 -0
  259. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/wg-config.d.ts.map +1 -0
  260. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/wg-config.js +104 -0
  261. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/wg-config.js.map +1 -0
  262. package/node_modules/@claude-flow/plugin-agent-federation/dist/index.d.ts +23 -0
  263. package/node_modules/@claude-flow/plugin-agent-federation/dist/index.d.ts.map +1 -0
  264. package/node_modules/@claude-flow/plugin-agent-federation/dist/index.js +24 -0
  265. package/node_modules/@claude-flow/plugin-agent-federation/dist/index.js.map +1 -0
  266. package/node_modules/@claude-flow/plugin-agent-federation/dist/mcp-tools.d.ts +10 -0
  267. package/node_modules/@claude-flow/plugin-agent-federation/dist/mcp-tools.d.ts.map +1 -0
  268. package/node_modules/@claude-flow/plugin-agent-federation/dist/mcp-tools.js +439 -0
  269. package/node_modules/@claude-flow/plugin-agent-federation/dist/mcp-tools.js.map +1 -0
  270. package/node_modules/@claude-flow/plugin-agent-federation/dist/plugin.d.ts +19 -0
  271. package/node_modules/@claude-flow/plugin-agent-federation/dist/plugin.d.ts.map +1 -0
  272. package/node_modules/@claude-flow/plugin-agent-federation/dist/plugin.js +515 -0
  273. package/node_modules/@claude-flow/plugin-agent-federation/dist/plugin.js.map +1 -0
  274. package/node_modules/@claude-flow/plugin-agent-federation/dist/transport/midstream-aware-loader.d.ts +72 -0
  275. package/node_modules/@claude-flow/plugin-agent-federation/dist/transport/midstream-aware-loader.d.ts.map +1 -0
  276. package/node_modules/@claude-flow/plugin-agent-federation/dist/transport/midstream-aware-loader.js +269 -0
  277. package/node_modules/@claude-flow/plugin-agent-federation/dist/transport/midstream-aware-loader.js.map +1 -0
  278. package/node_modules/@claude-flow/plugin-agent-federation/dist/version.d.ts +3 -0
  279. package/node_modules/@claude-flow/plugin-agent-federation/dist/version.d.ts.map +1 -0
  280. package/node_modules/@claude-flow/plugin-agent-federation/dist/version.js +3 -0
  281. package/node_modules/@claude-flow/plugin-agent-federation/dist/version.js.map +1 -0
  282. package/node_modules/@claude-flow/plugin-agent-federation/package.json +64 -0
  283. package/node_modules/@claude-flow/security/README.md +292 -0
  284. package/node_modules/@claude-flow/security/dist/CVE-REMEDIATION.d.ts +97 -0
  285. package/node_modules/@claude-flow/security/dist/CVE-REMEDIATION.d.ts.map +1 -0
  286. package/node_modules/@claude-flow/security/dist/CVE-REMEDIATION.js +537 -0
  287. package/node_modules/@claude-flow/security/dist/CVE-REMEDIATION.js.map +1 -0
  288. package/node_modules/@claude-flow/security/dist/application/index.d.ts +7 -0
  289. package/node_modules/@claude-flow/security/dist/application/index.d.ts.map +1 -0
  290. package/node_modules/@claude-flow/security/dist/application/index.js +7 -0
  291. package/node_modules/@claude-flow/security/dist/application/index.js.map +1 -0
  292. package/node_modules/@claude-flow/security/dist/application/services/security-application-service.d.ts +71 -0
  293. package/node_modules/@claude-flow/security/dist/application/services/security-application-service.d.ts.map +1 -0
  294. package/node_modules/@claude-flow/security/dist/application/services/security-application-service.js +153 -0
  295. package/node_modules/@claude-flow/security/dist/application/services/security-application-service.js.map +1 -0
  296. package/node_modules/@claude-flow/security/dist/authorization/propagator.d.ts +148 -0
  297. package/node_modules/@claude-flow/security/dist/authorization/propagator.d.ts.map +1 -0
  298. package/node_modules/@claude-flow/security/dist/authorization/propagator.js +182 -0
  299. package/node_modules/@claude-flow/security/dist/authorization/propagator.js.map +1 -0
  300. package/node_modules/@claude-flow/security/dist/credential-generator.d.ts +176 -0
  301. package/node_modules/@claude-flow/security/dist/credential-generator.d.ts.map +1 -0
  302. package/node_modules/@claude-flow/security/dist/credential-generator.js +272 -0
  303. package/node_modules/@claude-flow/security/dist/credential-generator.js.map +1 -0
  304. package/node_modules/@claude-flow/security/dist/domain/entities/security-context.d.ts +68 -0
  305. package/node_modules/@claude-flow/security/dist/domain/entities/security-context.d.ts.map +1 -0
  306. package/node_modules/@claude-flow/security/dist/domain/entities/security-context.js +132 -0
  307. package/node_modules/@claude-flow/security/dist/domain/entities/security-context.js.map +1 -0
  308. package/node_modules/@claude-flow/security/dist/domain/index.d.ts +8 -0
  309. package/node_modules/@claude-flow/security/dist/domain/index.d.ts.map +1 -0
  310. package/node_modules/@claude-flow/security/dist/domain/index.js +8 -0
  311. package/node_modules/@claude-flow/security/dist/domain/index.js.map +1 -0
  312. package/node_modules/@claude-flow/security/dist/domain/services/security-domain-service.d.ts +71 -0
  313. package/node_modules/@claude-flow/security/dist/domain/services/security-domain-service.d.ts.map +1 -0
  314. package/node_modules/@claude-flow/security/dist/domain/services/security-domain-service.js +237 -0
  315. package/node_modules/@claude-flow/security/dist/domain/services/security-domain-service.js.map +1 -0
  316. package/node_modules/@claude-flow/security/dist/index.d.ts +129 -0
  317. package/node_modules/@claude-flow/security/dist/index.d.ts.map +1 -0
  318. package/node_modules/@claude-flow/security/dist/index.js +176 -0
  319. package/node_modules/@claude-flow/security/dist/index.js.map +1 -0
  320. package/node_modules/@claude-flow/security/dist/input-validator.d.ts +306 -0
  321. package/node_modules/@claude-flow/security/dist/input-validator.d.ts.map +1 -0
  322. package/node_modules/@claude-flow/security/dist/input-validator.js +393 -0
  323. package/node_modules/@claude-flow/security/dist/input-validator.js.map +1 -0
  324. package/node_modules/@claude-flow/security/dist/keychain-adapter.d.ts +48 -0
  325. package/node_modules/@claude-flow/security/dist/keychain-adapter.d.ts.map +1 -0
  326. package/node_modules/@claude-flow/security/dist/keychain-adapter.js +0 -0
  327. package/node_modules/@claude-flow/security/dist/keychain-adapter.js.map +1 -0
  328. package/node_modules/@claude-flow/security/dist/mcp-composition-inspector.d.ts +133 -0
  329. package/node_modules/@claude-flow/security/dist/mcp-composition-inspector.d.ts.map +1 -0
  330. package/node_modules/@claude-flow/security/dist/mcp-composition-inspector.js +254 -0
  331. package/node_modules/@claude-flow/security/dist/mcp-composition-inspector.js.map +1 -0
  332. package/node_modules/@claude-flow/security/dist/oauth/browser.d.ts +31 -0
  333. package/node_modules/@claude-flow/security/dist/oauth/browser.d.ts.map +1 -0
  334. package/node_modules/@claude-flow/security/dist/oauth/browser.js +55 -0
  335. package/node_modules/@claude-flow/security/dist/oauth/browser.js.map +1 -0
  336. package/node_modules/@claude-flow/security/dist/oauth/callback-server.d.ts +37 -0
  337. package/node_modules/@claude-flow/security/dist/oauth/callback-server.d.ts.map +1 -0
  338. package/node_modules/@claude-flow/security/dist/oauth/callback-server.js +86 -0
  339. package/node_modules/@claude-flow/security/dist/oauth/callback-server.js.map +1 -0
  340. package/node_modules/@claude-flow/security/dist/oauth/client.d.ts +57 -0
  341. package/node_modules/@claude-flow/security/dist/oauth/client.d.ts.map +1 -0
  342. package/node_modules/@claude-flow/security/dist/oauth/client.js +120 -0
  343. package/node_modules/@claude-flow/security/dist/oauth/client.js.map +1 -0
  344. package/node_modules/@claude-flow/security/dist/oauth/pkce.d.ts +25 -0
  345. package/node_modules/@claude-flow/security/dist/oauth/pkce.d.ts.map +1 -0
  346. package/node_modules/@claude-flow/security/dist/oauth/pkce.js +36 -0
  347. package/node_modules/@claude-flow/security/dist/oauth/pkce.js.map +1 -0
  348. package/node_modules/@claude-flow/security/dist/password-hasher.d.ts +128 -0
  349. package/node_modules/@claude-flow/security/dist/password-hasher.d.ts.map +1 -0
  350. package/node_modules/@claude-flow/security/dist/password-hasher.js +190 -0
  351. package/node_modules/@claude-flow/security/dist/password-hasher.js.map +1 -0
  352. package/node_modules/@claude-flow/security/dist/path-validator.d.ts +148 -0
  353. package/node_modules/@claude-flow/security/dist/path-validator.d.ts.map +1 -0
  354. package/node_modules/@claude-flow/security/dist/path-validator.js +421 -0
  355. package/node_modules/@claude-flow/security/dist/path-validator.js.map +1 -0
  356. package/node_modules/@claude-flow/security/dist/plugins/integrity-verifier.d.ts +125 -0
  357. package/node_modules/@claude-flow/security/dist/plugins/integrity-verifier.d.ts.map +1 -0
  358. package/node_modules/@claude-flow/security/dist/plugins/integrity-verifier.js +186 -0
  359. package/node_modules/@claude-flow/security/dist/plugins/integrity-verifier.js.map +1 -0
  360. package/node_modules/@claude-flow/security/dist/policy/canonical.d.ts +5 -0
  361. package/node_modules/@claude-flow/security/dist/policy/canonical.d.ts.map +1 -0
  362. package/node_modules/@claude-flow/security/dist/policy/canonical.js +30 -0
  363. package/node_modules/@claude-flow/security/dist/policy/canonical.js.map +1 -0
  364. package/node_modules/@claude-flow/security/dist/policy/engine.d.ts +34 -0
  365. package/node_modules/@claude-flow/security/dist/policy/engine.d.ts.map +1 -0
  366. package/node_modules/@claude-flow/security/dist/policy/engine.js +285 -0
  367. package/node_modules/@claude-flow/security/dist/policy/engine.js.map +1 -0
  368. package/node_modules/@claude-flow/security/dist/policy/envelope.d.ts +9 -0
  369. package/node_modules/@claude-flow/security/dist/policy/envelope.d.ts.map +1 -0
  370. package/node_modules/@claude-flow/security/dist/policy/envelope.js +90 -0
  371. package/node_modules/@claude-flow/security/dist/policy/envelope.js.map +1 -0
  372. package/node_modules/@claude-flow/security/dist/policy/evaluator.d.ts +4 -0
  373. package/node_modules/@claude-flow/security/dist/policy/evaluator.d.ts.map +1 -0
  374. package/node_modules/@claude-flow/security/dist/policy/evaluator.js +119 -0
  375. package/node_modules/@claude-flow/security/dist/policy/evaluator.js.map +1 -0
  376. package/node_modules/@claude-flow/security/dist/policy/index.d.ts +7 -0
  377. package/node_modules/@claude-flow/security/dist/policy/index.d.ts.map +1 -0
  378. package/node_modules/@claude-flow/security/dist/policy/index.js +7 -0
  379. package/node_modules/@claude-flow/security/dist/policy/index.js.map +1 -0
  380. package/node_modules/@claude-flow/security/dist/policy/product-plane.d.ts +238 -0
  381. package/node_modules/@claude-flow/security/dist/policy/product-plane.d.ts.map +1 -0
  382. package/node_modules/@claude-flow/security/dist/policy/product-plane.js +1022 -0
  383. package/node_modules/@claude-flow/security/dist/policy/product-plane.js.map +1 -0
  384. package/node_modules/@claude-flow/security/dist/policy/types.d.ts +169 -0
  385. package/node_modules/@claude-flow/security/dist/policy/types.d.ts.map +1 -0
  386. package/node_modules/@claude-flow/security/dist/policy/types.js +2 -0
  387. package/node_modules/@claude-flow/security/dist/policy/types.js.map +1 -0
  388. package/node_modules/@claude-flow/security/dist/safe-executor.d.ts +180 -0
  389. package/node_modules/@claude-flow/security/dist/safe-executor.d.ts.map +1 -0
  390. package/node_modules/@claude-flow/security/dist/safe-executor.js +390 -0
  391. package/node_modules/@claude-flow/security/dist/safe-executor.js.map +1 -0
  392. package/node_modules/@claude-flow/security/dist/token-generator.d.ts +224 -0
  393. package/node_modules/@claude-flow/security/dist/token-generator.d.ts.map +1 -0
  394. package/node_modules/@claude-flow/security/dist/token-generator.js +351 -0
  395. package/node_modules/@claude-flow/security/dist/token-generator.js.map +1 -0
  396. package/node_modules/@claude-flow/security/dist/tool-output-guardrail.d.ts +126 -0
  397. package/node_modules/@claude-flow/security/dist/tool-output-guardrail.d.ts.map +1 -0
  398. package/node_modules/@claude-flow/security/dist/tool-output-guardrail.js +257 -0
  399. package/node_modules/@claude-flow/security/dist/tool-output-guardrail.js.map +1 -0
  400. package/node_modules/@claude-flow/security/package.json +44 -0
  401. package/package.json +44 -12
  402. package/plugins/ruflo-metaharness/scripts/smoke.sh +22 -14
  403. package/plugins/ruflo-metaharness/scripts/test-mcp-tools.mjs +3 -1
@@ -0,0 +1,795 @@
1
+ /**
2
+ * @claude-flow/codex - CodexInitializer
3
+ *
4
+ * Main initialization class for setting up Codex projects
5
+ */
6
+ import fs from 'fs-extra';
7
+ import path from 'path';
8
+ import { fileURLToPath } from 'node:url';
9
+ import { generateAgentsMd } from './generators/agents-md.js';
10
+ import { generateSkillMd, generateBuiltInSkill } from './generators/skill-md.js';
11
+ import { generateConfigToml } from './generators/config-toml.js';
12
+ import { DEFAULT_SKILLS_BY_TEMPLATE, AGENTS_OVERRIDE_TEMPLATE, GITIGNORE_ENTRIES } from './templates/index.js';
13
+ import { getRufloMcpAddCommand } from './mcp-config.js';
14
+ /**
15
+ * Bundled skills source directory (relative to package)
16
+ */
17
+ const BUNDLED_SKILLS_DIR = '../.agents/skills';
18
+ export function resolveBundledSkillsPath(moduleUrl = import.meta.url) {
19
+ return path.resolve(path.dirname(fileURLToPath(moduleUrl)), BUNDLED_SKILLS_DIR);
20
+ }
21
+ /**
22
+ * Main initializer for Codex projects
23
+ */
24
+ export class CodexInitializer {
25
+ projectPath = '';
26
+ template = 'default';
27
+ skills = [];
28
+ force = false;
29
+ dual = false;
30
+ bundledSkillsPath = '';
31
+ /**
32
+ * Initialize a new Codex project
33
+ */
34
+ async initialize(options) {
35
+ this.projectPath = path.resolve(options.projectPath);
36
+ this.template = options.template ?? 'default';
37
+ this.skills = options.skills ?? DEFAULT_SKILLS_BY_TEMPLATE[this.template];
38
+ this.force = options.force ?? false;
39
+ this.dual = options.dual ?? false;
40
+ // Resolve bundled skills path (relative to this file's location)
41
+ this.bundledSkillsPath = resolveBundledSkillsPath();
42
+ const filesCreated = [];
43
+ const skillsGenerated = [];
44
+ const warnings = [];
45
+ const errors = [];
46
+ try {
47
+ // Validate project path
48
+ await this.validateProjectPath();
49
+ // Check if already initialized
50
+ const alreadyInitialized = await this.isAlreadyInitialized();
51
+ if (alreadyInitialized && !this.force) {
52
+ return {
53
+ success: false,
54
+ filesCreated,
55
+ skillsGenerated,
56
+ warnings: ['Project already initialized. Use --force to overwrite.'],
57
+ errors: ['Project already initialized'],
58
+ };
59
+ }
60
+ if (alreadyInitialized && this.force) {
61
+ warnings.push('Overwriting existing configuration files');
62
+ }
63
+ // Create directory structure
64
+ await this.createDirectoryStructure();
65
+ // Generate AGENTS.md
66
+ const agentsMd = await this.generateAgentsMd();
67
+ const agentsMdPath = path.join(this.projectPath, 'AGENTS.md');
68
+ if (await this.shouldWriteFile(agentsMdPath)) {
69
+ await fs.writeFile(agentsMdPath, agentsMd, 'utf-8');
70
+ filesCreated.push('AGENTS.md');
71
+ }
72
+ else {
73
+ warnings.push('AGENTS.md already exists - skipped');
74
+ }
75
+ // Generate config.toml
76
+ const configToml = await this.generateConfigToml();
77
+ const configTomlPath = path.join(this.projectPath, '.agents', 'config.toml');
78
+ if (await this.shouldWriteFile(configTomlPath)) {
79
+ await fs.writeFile(configTomlPath, configToml, 'utf-8');
80
+ filesCreated.push('.agents/config.toml');
81
+ }
82
+ else {
83
+ warnings.push('.agents/config.toml already exists - skipped');
84
+ }
85
+ // Copy bundled skills first (for full/enterprise templates or specific skills)
86
+ const bundledResult = await this.copyBundledSkills();
87
+ skillsGenerated.push(...bundledResult.copied);
88
+ warnings.push(...bundledResult.warnings);
89
+ // For skills not bundled, generate from templates
90
+ for (const skillName of this.skills) {
91
+ // Skip if already copied as bundled skill
92
+ if (bundledResult.copied.includes(skillName)) {
93
+ filesCreated.push(`.agents/skills/${skillName}/SKILL.md`);
94
+ continue;
95
+ }
96
+ try {
97
+ const skillResult = await this.generateSkill(skillName);
98
+ if (skillResult.created) {
99
+ skillsGenerated.push(skillName);
100
+ filesCreated.push(skillResult.path);
101
+ }
102
+ else if (skillResult.skipped) {
103
+ // Only warn if not already in bundled warnings
104
+ if (!bundledResult.warnings.some(w => w.includes(skillName))) {
105
+ warnings.push(`Skill ${skillName} already exists - skipped`);
106
+ }
107
+ }
108
+ }
109
+ catch (err) {
110
+ const errorMessage = err instanceof Error ? err.message : String(err);
111
+ warnings.push(`Failed to generate skill ${skillName}: ${errorMessage}`);
112
+ }
113
+ }
114
+ // Generate local overrides template
115
+ const overridePath = path.join(this.projectPath, '.codex', 'AGENTS.override.md');
116
+ if (await this.shouldWriteFile(overridePath)) {
117
+ await fs.writeFile(overridePath, AGENTS_OVERRIDE_TEMPLATE, 'utf-8');
118
+ filesCreated.push('.codex/AGENTS.override.md');
119
+ }
120
+ // Generate local config.toml
121
+ const localConfigPath = path.join(this.projectPath, '.codex', 'config.toml');
122
+ if (await this.shouldWriteFile(localConfigPath)) {
123
+ await fs.writeFile(localConfigPath, await this.generateLocalConfigToml(), 'utf-8');
124
+ filesCreated.push('.codex/config.toml');
125
+ }
126
+ // Update .gitignore
127
+ const gitignoreUpdated = await this.updateGitignore();
128
+ if (gitignoreUpdated) {
129
+ filesCreated.push('.gitignore (updated)');
130
+ }
131
+ // Register MCP server with Codex
132
+ const mcpResult = await this.registerMCPServer();
133
+ if (mcpResult.registered) {
134
+ filesCreated.push('MCP server (ruflo) registered');
135
+ }
136
+ if (mcpResult.warning) {
137
+ warnings.push(mcpResult.warning);
138
+ }
139
+ // #2801 — install the canonical ruflo-core@ruflo plugin so Codex
140
+ // gets Ruflo's lifecycle hooks (PreToolUse/PostToolUse/PreCompact/
141
+ // Stop). Before this, --codex/--dual set up skills + MCP but no
142
+ // lifecycle hooks. We install the UPSTREAM plugin (not a second
143
+ // project-local bundle) to avoid the #2640 double-firing class.
144
+ const pluginResult = await this.installRufloCorePlugin();
145
+ if (pluginResult.installed) {
146
+ filesCreated.push('Codex plugin (ruflo-core@ruflo) installed');
147
+ }
148
+ if (pluginResult.warning) {
149
+ warnings.push(pluginResult.warning);
150
+ }
151
+ if (pluginResult.activationMessage) {
152
+ // Surfaced as a warning so it prints prominently. Codex deliberately
153
+ // does NOT auto-trust new command hooks — the user must review them.
154
+ warnings.push(pluginResult.activationMessage);
155
+ }
156
+ // If dual mode, also generate Claude Code files
157
+ if (this.dual) {
158
+ const dualResult = await this.generateDualPlatformFiles();
159
+ filesCreated.push(...dualResult.files);
160
+ if (dualResult.warnings) {
161
+ warnings.push(...dualResult.warnings);
162
+ }
163
+ }
164
+ // Create a README for the .agents directory
165
+ const agentsReadmePath = path.join(this.projectPath, '.agents', 'README.md');
166
+ if (await this.shouldWriteFile(agentsReadmePath)) {
167
+ await fs.writeFile(agentsReadmePath, this.generateAgentsReadme(), 'utf-8');
168
+ filesCreated.push('.agents/README.md');
169
+ }
170
+ const result = {
171
+ success: true,
172
+ filesCreated,
173
+ skillsGenerated,
174
+ };
175
+ if (warnings.length > 0) {
176
+ result.warnings = warnings;
177
+ }
178
+ return result;
179
+ }
180
+ catch (error) {
181
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
182
+ errors.push(errorMessage);
183
+ const result = {
184
+ success: false,
185
+ filesCreated,
186
+ skillsGenerated,
187
+ errors,
188
+ };
189
+ if (warnings.length > 0) {
190
+ result.warnings = warnings;
191
+ }
192
+ return result;
193
+ }
194
+ }
195
+ /**
196
+ * Validate that the project path is valid and writable
197
+ */
198
+ async validateProjectPath() {
199
+ try {
200
+ await fs.ensureDir(this.projectPath);
201
+ // Check write permissions by attempting to create a temp file
202
+ const tempFile = path.join(this.projectPath, '.codex-init-test');
203
+ await fs.writeFile(tempFile, 'test', 'utf-8');
204
+ await fs.remove(tempFile);
205
+ }
206
+ catch (error) {
207
+ throw new Error(`Cannot write to project path: ${this.projectPath}`);
208
+ }
209
+ }
210
+ /**
211
+ * Check if project is already initialized
212
+ */
213
+ async isAlreadyInitialized() {
214
+ const agentsMdExists = await fs.pathExists(path.join(this.projectPath, 'AGENTS.md'));
215
+ const agentsConfigExists = await fs.pathExists(path.join(this.projectPath, '.agents', 'config.toml'));
216
+ return agentsMdExists || agentsConfigExists;
217
+ }
218
+ /**
219
+ * Check if we should write a file (force mode or doesn't exist)
220
+ */
221
+ async shouldWriteFile(filePath) {
222
+ if (this.force) {
223
+ return true;
224
+ }
225
+ return !(await fs.pathExists(filePath));
226
+ }
227
+ /**
228
+ * Create the directory structure
229
+ */
230
+ async createDirectoryStructure() {
231
+ const dirs = [
232
+ '.agents',
233
+ '.agents/skills',
234
+ '.codex',
235
+ '.claude-flow',
236
+ '.claude-flow/data',
237
+ '.claude-flow/logs',
238
+ ];
239
+ for (const dir of dirs) {
240
+ const fullPath = path.join(this.projectPath, dir);
241
+ await fs.ensureDir(fullPath);
242
+ }
243
+ }
244
+ /**
245
+ * Copy bundled skills from the package or source directory
246
+ * Returns the list of skills copied
247
+ */
248
+ async copyBundledSkills() {
249
+ const copied = [];
250
+ const warnings = [];
251
+ // Check if bundled skills directory exists
252
+ if (!await fs.pathExists(this.bundledSkillsPath)) {
253
+ warnings.push(`Bundled skills directory not found: ${this.bundledSkillsPath}`);
254
+ return { copied, warnings };
255
+ }
256
+ const destSkillsDir = path.join(this.projectPath, '.agents', 'skills');
257
+ // Get all skill directories
258
+ const skillDirs = await fs.readdir(this.bundledSkillsPath, { withFileTypes: true });
259
+ for (const dirent of skillDirs) {
260
+ if (!dirent.isDirectory())
261
+ continue;
262
+ const skillName = dirent.name;
263
+ const srcPath = path.join(this.bundledSkillsPath, skillName);
264
+ const destPath = path.join(destSkillsDir, skillName);
265
+ // Skip if skill should be filtered (based on template)
266
+ // For 'full' and 'enterprise' templates, include all skills
267
+ const includeAll = this.template === 'full' || this.template === 'enterprise';
268
+ if (!includeAll && !this.skills.includes(skillName)) {
269
+ continue;
270
+ }
271
+ try {
272
+ // Check if skill already exists and we're not forcing
273
+ if (!this.force && await fs.pathExists(destPath)) {
274
+ warnings.push(`Skill ${skillName} already exists - skipped`);
275
+ continue;
276
+ }
277
+ // Copy the entire skill directory
278
+ await fs.copy(srcPath, destPath, { overwrite: this.force });
279
+ copied.push(skillName);
280
+ }
281
+ catch (err) {
282
+ const errorMessage = err instanceof Error ? err.message : String(err);
283
+ warnings.push(`Failed to copy skill ${skillName}: ${errorMessage}`);
284
+ }
285
+ }
286
+ return { copied, warnings };
287
+ }
288
+ /**
289
+ * Check if a skill is bundled (exists in source directory)
290
+ */
291
+ async isBundledSkill(skillName) {
292
+ const skillPath = path.join(this.bundledSkillsPath, skillName);
293
+ return fs.pathExists(skillPath);
294
+ }
295
+ /**
296
+ * Register claude-flow as MCP server with Codex
297
+ */
298
+ async registerMCPServer() {
299
+ try {
300
+ const { execSync } = await import('child_process');
301
+ // Check if codex CLI is available
302
+ try {
303
+ execSync('which codex', { stdio: 'pipe' });
304
+ }
305
+ catch {
306
+ return {
307
+ registered: false,
308
+ warning: `Codex CLI not found. Run: ${getRufloMcpAddCommand()}`,
309
+ };
310
+ }
311
+ // Check if already registered. Prefer the structured `--json` output
312
+ // (each entry has a `name` field — confirmed current as of the 2026
313
+ // `codex mcp` CLI) over a plain substring match against the human
314
+ // -readable table, which false-positives on any server whose name or
315
+ // command merely contains "ruflo" and breaks silently if the table
316
+ // formatting changes.
317
+ try {
318
+ const listJson = execSync('codex mcp list --json 2>&1', { encoding: 'utf-8' });
319
+ const parsed = JSON.parse(listJson);
320
+ // Confirmed shape (2026 `codex mcp` CLI) is a bare array; tolerate a
321
+ // future `{ servers: [...] }` wrapper but otherwise treat an
322
+ // unrecognized shape as "unknown" rather than silently concluding
323
+ // not-registered — falls through to the safe text-based fallback.
324
+ const servers = Array.isArray(parsed) ? parsed : Array.isArray(parsed?.servers) ? parsed.servers : null;
325
+ if (!servers)
326
+ throw new Error('unrecognized `codex mcp list --json` shape');
327
+ if (servers.some((s) => s && typeof s === 'object' && s.name === 'ruflo')) {
328
+ return { registered: true }; // Already registered
329
+ }
330
+ }
331
+ catch {
332
+ // --json unsupported (older codex CLI) or unparsable — fall back to
333
+ // the plain-text listing so registration still no-ops idempotently.
334
+ try {
335
+ const list = execSync('codex mcp list 2>&1', { encoding: 'utf-8' });
336
+ if (list.includes('ruflo')) {
337
+ return { registered: true };
338
+ }
339
+ }
340
+ catch {
341
+ // Ignore list errors — fall through to (re-)register below.
342
+ }
343
+ }
344
+ // Register the MCP server.
345
+ //
346
+ // Use the shared platform-aware Ruflo MCP definition so generators,
347
+ // migrations, and live registration cannot drift.
348
+ try {
349
+ execSync(getRufloMcpAddCommand(), {
350
+ stdio: 'pipe',
351
+ timeout: 10000,
352
+ });
353
+ return { registered: true };
354
+ }
355
+ catch (err) {
356
+ const errorMessage = err instanceof Error ? err.message : String(err);
357
+ return {
358
+ registered: false,
359
+ warning: `Failed to register MCP server: ${errorMessage}. Run manually: ${getRufloMcpAddCommand()}`,
360
+ };
361
+ }
362
+ }
363
+ catch {
364
+ return {
365
+ registered: false,
366
+ warning: `Could not register MCP server. Run manually: ${getRufloMcpAddCommand()}`,
367
+ };
368
+ }
369
+ }
370
+ /**
371
+ * #2801 — Install the canonical `ruflo-core@ruflo` plugin so Codex
372
+ * discovers Ruflo's lifecycle hooks. Idempotent: adds the marketplace
373
+ * and installs the plugin at user scope, mirroring registerMCPServer's
374
+ * detect-then-add pattern. Codex does NOT auto-trust command hooks, so
375
+ * we always return an activation message instructing the user to review
376
+ * and trust them in a new session. Installation state is NOT reported as
377
+ * "hook-active" — only "installed, pending trust review".
378
+ */
379
+ async installRufloCorePlugin() {
380
+ const ACTIVATION = [
381
+ '',
382
+ 'ACTION REQUIRED (Ruflo lifecycle hooks): start a new Codex session, open /hooks,',
383
+ 'review the ruflo-core@ruflo hook definitions, and trust them. Use "trust all" only',
384
+ 'when every pending definition is from Ruflo; otherwise trust the Ruflo definitions',
385
+ 'individually. Hooks are installed but remain INACTIVE until you complete this review.',
386
+ ].join('\n');
387
+ const MANUAL = 'Install manually: codex plugin marketplace add ruvnet/ruflo --ref main && codex plugin add ruflo-core@ruflo';
388
+ try {
389
+ const { execSync } = await import('child_process');
390
+ // Codex CLI present?
391
+ try {
392
+ execSync('which codex', { stdio: 'pipe' });
393
+ }
394
+ catch {
395
+ return { installed: false, warning: `Codex CLI not found. ${MANUAL}` };
396
+ }
397
+ // Already installed? (structured --json first, plain-text fallback —
398
+ // same resilience approach as registerMCPServer).
399
+ try {
400
+ const listJson = execSync('codex plugin list --json 2>&1', { encoding: 'utf-8' });
401
+ const parsed = JSON.parse(listJson);
402
+ const plugins = Array.isArray(parsed) ? parsed : Array.isArray(parsed?.plugins) ? parsed.plugins : null;
403
+ if (plugins && plugins.some((p) => {
404
+ if (!p || typeof p !== 'object')
405
+ return false;
406
+ const name = String(p.name ?? '');
407
+ return name === 'ruflo-core' || name === 'ruflo-core@ruflo' || name.startsWith('ruflo-core@');
408
+ })) {
409
+ // Installed already — still surface the trust reminder (idempotent).
410
+ return { installed: true, activationMessage: ACTIVATION };
411
+ }
412
+ }
413
+ catch {
414
+ try {
415
+ const list = execSync('codex plugin list 2>&1', { encoding: 'utf-8' });
416
+ if (list.includes('ruflo-core')) {
417
+ return { installed: true, activationMessage: ACTIVATION };
418
+ }
419
+ }
420
+ catch {
421
+ // Ignore — fall through to install.
422
+ }
423
+ }
424
+ // Add the marketplace (idempotent — codex no-ops if already added; any
425
+ // error here is non-fatal, the plugin-add below reports the real failure).
426
+ try {
427
+ execSync('codex plugin marketplace add ruvnet/ruflo --ref main', { stdio: 'pipe', timeout: 20000 });
428
+ }
429
+ catch {
430
+ // Marketplace may already exist, or the CLI may not support this exact
431
+ // verb — let the plugin-add attempt surface the actionable error.
432
+ }
433
+ // Install the plugin at user scope.
434
+ try {
435
+ execSync('codex plugin add ruflo-core@ruflo', { stdio: 'pipe', timeout: 20000 });
436
+ return { installed: true, activationMessage: ACTIVATION };
437
+ }
438
+ catch (err) {
439
+ const msg = err instanceof Error ? err.message : String(err);
440
+ return { installed: false, warning: `Failed to install ruflo-core@ruflo plugin: ${msg}. ${MANUAL}` };
441
+ }
442
+ }
443
+ catch {
444
+ return { installed: false, warning: `Could not install Ruflo plugin. ${MANUAL}` };
445
+ }
446
+ }
447
+ /**
448
+ * Generate AGENTS.md content
449
+ */
450
+ async generateAgentsMd() {
451
+ const projectName = path.basename(this.projectPath);
452
+ return generateAgentsMd({
453
+ projectName,
454
+ template: this.template,
455
+ skills: this.skills,
456
+ });
457
+ }
458
+ /**
459
+ * Generate config.toml content
460
+ */
461
+ async generateConfigToml() {
462
+ return generateConfigToml({
463
+ skills: this.skills.map(skill => ({
464
+ path: `.agents/skills/${skill}`,
465
+ enabled: true,
466
+ })),
467
+ });
468
+ }
469
+ /**
470
+ * Generate local config.toml for .codex directory
471
+ */
472
+ async generateLocalConfigToml() {
473
+ return `# Local Codex Configuration
474
+ # This file overrides .agents/config.toml for local development
475
+ # DO NOT commit this file to version control
476
+
477
+ # Development profile - more permissive
478
+ approval_policy = "never"
479
+ sandbox_mode = "danger-full-access"
480
+ web_search = "live"
481
+
482
+ # Debug settings
483
+ # Uncomment to enable debug logging
484
+ # CODEX_LOG_LEVEL = "debug"
485
+
486
+ # Local MCP server overrides
487
+ # [mcp_servers.local]
488
+ # command = "node"
489
+ # args = ["./local-mcp-server.js"]
490
+ # enabled = true
491
+
492
+ # Environment-specific settings
493
+ # [env]
494
+ # ANTHROPIC_API_KEY = "your-local-key"
495
+ `;
496
+ }
497
+ /**
498
+ * Generate a skill
499
+ */
500
+ async generateSkill(skillName) {
501
+ const skillDir = path.join(this.projectPath, '.agents', 'skills', skillName);
502
+ const skillPath = path.join(skillDir, 'SKILL.md');
503
+ // Check if skill already exists
504
+ if (!this.force && await fs.pathExists(skillPath)) {
505
+ return { created: false, skipped: true, path: `.agents/skills/${skillName}/SKILL.md` };
506
+ }
507
+ await fs.ensureDir(skillDir);
508
+ // Check if it's a built-in skill
509
+ const builtInSkills = [
510
+ 'swarm-orchestration',
511
+ 'memory-management',
512
+ 'sparc-methodology',
513
+ 'security-audit',
514
+ 'performance-analysis',
515
+ 'github-automation',
516
+ ];
517
+ let skillMd;
518
+ if (builtInSkills.includes(skillName)) {
519
+ const result = await generateBuiltInSkill(skillName);
520
+ skillMd = result.skillMd;
521
+ // Also write any associated scripts or references
522
+ if (Object.keys(result.scripts).length > 0) {
523
+ const scriptsDir = path.join(skillDir, 'scripts');
524
+ await fs.ensureDir(scriptsDir);
525
+ for (const [scriptName, scriptContent] of Object.entries(result.scripts)) {
526
+ await fs.writeFile(path.join(scriptsDir, scriptName), scriptContent, 'utf-8');
527
+ }
528
+ }
529
+ if (Object.keys(result.references).length > 0) {
530
+ const refsDir = path.join(skillDir, 'docs');
531
+ await fs.ensureDir(refsDir);
532
+ for (const [refName, refContent] of Object.entries(result.references)) {
533
+ await fs.writeFile(path.join(refsDir, refName), refContent, 'utf-8');
534
+ }
535
+ }
536
+ }
537
+ else {
538
+ // Generate a custom skill template
539
+ skillMd = await generateSkillMd({
540
+ name: skillName,
541
+ description: `Custom skill: ${skillName}`,
542
+ triggers: ['Define when to trigger this skill'],
543
+ skipWhen: ['Define when to skip this skill'],
544
+ });
545
+ }
546
+ await fs.writeFile(skillPath, skillMd, 'utf-8');
547
+ return { created: true, skipped: false, path: `.agents/skills/${skillName}/SKILL.md` };
548
+ }
549
+ /**
550
+ * Update .gitignore with Codex entries
551
+ */
552
+ async updateGitignore() {
553
+ const gitignorePath = path.join(this.projectPath, '.gitignore');
554
+ let content = '';
555
+ if (await fs.pathExists(gitignorePath)) {
556
+ content = await fs.readFile(gitignorePath, 'utf-8');
557
+ }
558
+ // Check if Codex entries already exist
559
+ if (content.includes('.codex/')) {
560
+ return false; // Already has entries
561
+ }
562
+ // Add entries with proper spacing
563
+ const separator = content.length > 0 && !content.endsWith('\n') ? '\n\n' : '\n';
564
+ const newContent = content + separator + GITIGNORE_ENTRIES.join('\n') + '\n';
565
+ await fs.writeFile(gitignorePath, newContent, 'utf-8');
566
+ return true;
567
+ }
568
+ /**
569
+ * Generate README for .agents directory
570
+ */
571
+ generateAgentsReadme() {
572
+ return `# .agents Directory
573
+
574
+ This directory contains agent configuration and skills for OpenAI Codex CLI.
575
+
576
+ ## Structure
577
+
578
+ \`\`\`
579
+ .agents/
580
+ config.toml # Main configuration file
581
+ skills/ # Skill definitions
582
+ skill-name/
583
+ SKILL.md # Skill instructions
584
+ scripts/ # Optional scripts
585
+ docs/ # Optional documentation
586
+ README.md # This file
587
+ \`\`\`
588
+
589
+ ## Configuration
590
+
591
+ The \`config.toml\` file controls:
592
+ - Model selection
593
+ - Approval policies
594
+ - Sandbox modes
595
+ - MCP server connections
596
+ - Skills configuration
597
+
598
+ ## Skills
599
+
600
+ Skills are invoked using \`$skill-name\` syntax. Each skill has:
601
+ - YAML frontmatter with metadata
602
+ - Trigger and skip conditions
603
+ - Commands and examples
604
+
605
+ ## Documentation
606
+
607
+ - Main instructions: \`AGENTS.md\` (project root)
608
+ - Local overrides: \`.codex/AGENTS.override.md\` (gitignored)
609
+ - Ruflo: https://github.com/ruvnet/ruflo
610
+ `;
611
+ }
612
+ /**
613
+ * Generate dual-platform files (Claude Code + Codex)
614
+ */
615
+ async generateDualPlatformFiles() {
616
+ const files = [];
617
+ const warnings = [];
618
+ // Check if CLAUDE.md already exists
619
+ const claudeMdPath = path.join(this.projectPath, 'CLAUDE.md');
620
+ const claudeMdExists = await fs.pathExists(claudeMdPath);
621
+ if (claudeMdExists && !this.force) {
622
+ warnings.push('CLAUDE.md already exists - not overwriting. Use --force to replace.');
623
+ return { files, warnings };
624
+ }
625
+ const projectName = path.basename(this.projectPath);
626
+ // Generate a CLAUDE.md that references AGENTS.md
627
+ const claudeMd = `# ${projectName}
628
+
629
+ > This project supports both Claude Code and OpenAI Codex.
630
+
631
+ ## Platform Compatibility
632
+
633
+ | Platform | Config File | Skill Syntax |
634
+ |----------|-------------|--------------|
635
+ | Claude Code | CLAUDE.md | /skill-name |
636
+ | OpenAI Codex | AGENTS.md | $skill-name |
637
+
638
+ ## Instructions
639
+
640
+ **Primary instructions are in \`AGENTS.md\`** (Agentic AI Foundation standard).
641
+ Read and follow that file before starting work; it contains the live
642
+ \`guidance_brain\` routing workflow, concurrency ownership rules, and authority
643
+ boundaries.
644
+
645
+ This file provides compatibility for Claude Code users.
646
+
647
+ ## Quick Start
648
+
649
+ \`\`\`bash
650
+ # Install dependencies
651
+ npm install
652
+
653
+ # Build the project
654
+ npm run build
655
+
656
+ # Run tests
657
+ npm test
658
+ \`\`\`
659
+
660
+ ## Available Skills
661
+
662
+ Both platforms share the same skills in \`.agents/skills/\`:
663
+
664
+ ${this.skills.map(s => `- \`$${s}\` (Codex) / \`/${s}\` (Claude Code)`).join('\n')}
665
+
666
+ ## Configuration
667
+
668
+ ### Codex Configuration
669
+ - Main: \`.agents/config.toml\`
670
+ - Local: \`.codex/config.toml\` (gitignored)
671
+
672
+ ### Claude Code Configuration
673
+ - This file: \`CLAUDE.md\`
674
+ - Local: \`CLAUDE.local.md\` (gitignored)
675
+
676
+ ## MCP Integration
677
+
678
+ \`\`\`bash
679
+ # Start Ruflo's MCP server over stdio (dedicated entry point — the
680
+ # management \`ruflo mcp start\` CLI does NOT answer JSON-RPC on stdio).
681
+ npx -y ruflo@latest mcp start
682
+ \`\`\`
683
+
684
+ ## Swarm Orchestration
685
+
686
+ This project uses hierarchical swarm coordination:
687
+
688
+ | Setting | Value |
689
+ |---------|-------|
690
+ | Topology | hierarchical |
691
+ | Max Agents | 8 |
692
+ | Strategy | specialized |
693
+
694
+ ## Code Standards
695
+
696
+ - Files under 500 lines
697
+ - No hardcoded secrets
698
+ - Input validation at boundaries
699
+ - Typed interfaces for APIs
700
+
701
+ ## Security
702
+
703
+ - NEVER commit .env files or secrets
704
+ - Always validate user input
705
+ - Use parameterized queries for SQL
706
+
707
+ ## Full Documentation
708
+
709
+ For complete instructions, see \`AGENTS.md\`.
710
+
711
+ ---
712
+
713
+ *Generated by @claude-flow/codex - Dual platform mode*
714
+ `;
715
+ await fs.writeFile(claudeMdPath, claudeMd, 'utf-8');
716
+ files.push('CLAUDE.md');
717
+ // Generate CLAUDE.local.md template
718
+ const claudeLocalPath = path.join(this.projectPath, 'CLAUDE.local.md');
719
+ if (await this.shouldWriteFile(claudeLocalPath)) {
720
+ const claudeLocal = `# Local Development Configuration
721
+
722
+ ## Environment
723
+
724
+ \`\`\`bash
725
+ # Development settings
726
+ CLAUDE_FLOW_LOG_LEVEL=debug
727
+ \`\`\`
728
+
729
+ ## Personal Preferences
730
+
731
+ [Add your preferences here]
732
+
733
+ ## Debug Settings
734
+
735
+ Enable verbose logging for development.
736
+
737
+ ---
738
+
739
+ *This file is gitignored and contains local-only settings.*
740
+ `;
741
+ await fs.writeFile(claudeLocalPath, claudeLocal, 'utf-8');
742
+ files.push('CLAUDE.local.md');
743
+ }
744
+ // Update .gitignore for CLAUDE.local.md
745
+ const gitignorePath = path.join(this.projectPath, '.gitignore');
746
+ if (await fs.pathExists(gitignorePath)) {
747
+ let content = await fs.readFile(gitignorePath, 'utf-8');
748
+ if (!content.includes('CLAUDE.local.md')) {
749
+ content += '\n# Claude Code local config\nCLAUDE.local.md\n';
750
+ await fs.writeFile(gitignorePath, content, 'utf-8');
751
+ }
752
+ }
753
+ warnings.push('Generated dual-platform setup. AGENTS.md is the canonical source.');
754
+ return { files, warnings };
755
+ }
756
+ /**
757
+ * Get the list of files that would be created (dry-run)
758
+ */
759
+ async dryRun(options) {
760
+ const files = [
761
+ 'AGENTS.md',
762
+ '.agents/config.toml',
763
+ '.agents/README.md',
764
+ '.codex/AGENTS.override.md',
765
+ '.codex/config.toml',
766
+ '.gitignore (updated)',
767
+ ];
768
+ const skills = options.skills ?? DEFAULT_SKILLS_BY_TEMPLATE[options.template ?? 'default'];
769
+ for (const skill of skills) {
770
+ files.push(`.agents/skills/${skill}/SKILL.md`);
771
+ }
772
+ if (options.dual) {
773
+ files.push('CLAUDE.md');
774
+ files.push('CLAUDE.local.md');
775
+ }
776
+ return files;
777
+ }
778
+ }
779
+ /**
780
+ * Quick initialization function for programmatic use
781
+ */
782
+ export async function initializeCodexProject(projectPath, options) {
783
+ const initializer = new CodexInitializer();
784
+ const initOptions = {
785
+ projectPath,
786
+ template: options?.template ?? 'default',
787
+ force: options?.force ?? false,
788
+ dual: options?.dual ?? false,
789
+ };
790
+ if (options?.skills) {
791
+ initOptions.skills = options.skills;
792
+ }
793
+ return initializer.initialize(initOptions);
794
+ }
795
+ //# sourceMappingURL=initializer.js.map