@kontourai/flow-agents 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (418) hide show
  1. package/.githooks/pre-push +11 -0
  2. package/.github/workflows/ci.yml +210 -0
  3. package/.github/workflows/docs-pages.yml +52 -0
  4. package/.github/workflows/publish-npm.yml +104 -0
  5. package/AGENTS.md +26 -0
  6. package/CHANGELOG.md +66 -0
  7. package/CODE_OF_CONDUCT.md +25 -0
  8. package/CONTEXT.md +300 -0
  9. package/CONTRIBUTING.md +44 -0
  10. package/LICENSE +201 -0
  11. package/README.md +129 -0
  12. package/SECURITY.md +33 -0
  13. package/agent-cards/dev.json +19 -0
  14. package/agents/dev.json +127 -0
  15. package/agents/tool-code-reviewer.json +61 -0
  16. package/agents/tool-dependencies-updater.json +118 -0
  17. package/agents/tool-explore-config.json +92 -0
  18. package/agents/tool-explore-deps.json +92 -0
  19. package/agents/tool-explore-entry.json +92 -0
  20. package/agents/tool-explore-patterns.json +92 -0
  21. package/agents/tool-explore-structure.json +92 -0
  22. package/agents/tool-explore-tests.json +92 -0
  23. package/agents/tool-planner.json +57 -0
  24. package/agents/tool-playwright.json +145 -0
  25. package/agents/tool-security-reviewer.json +56 -0
  26. package/agents/tool-verifier.json +61 -0
  27. package/agents/tool-worker.json +58 -0
  28. package/build/src/cli/console-learning-projection.js +123 -0
  29. package/build/src/cli/docs-preview.js +39 -0
  30. package/build/src/cli/effective-backlog-settings.js +102 -0
  31. package/build/src/cli/export-bookmarks.js +38 -0
  32. package/build/src/cli/fixture-retirement-audit.js +140 -0
  33. package/build/src/cli/flow-kit.js +138 -0
  34. package/build/src/cli/import-bookmarks.js +50 -0
  35. package/build/src/cli/init.js +239 -0
  36. package/build/src/cli/instinct-cli.js +93 -0
  37. package/build/src/cli/promote-workflow-artifact.js +63 -0
  38. package/build/src/cli/publish-change-helper.js +154 -0
  39. package/build/src/cli/pull-work-provider.js +469 -0
  40. package/build/src/cli/runtime-adapter.js +23 -0
  41. package/build/src/cli/telemetry-doctor.js +221 -0
  42. package/build/src/cli/usage-feedback.js +443 -0
  43. package/build/src/cli/validate-hook-influence.js +152 -0
  44. package/build/src/cli/validate-source-tree.js +31 -0
  45. package/build/src/cli/validate-workflow-artifacts.js +486 -0
  46. package/build/src/cli/veritas-governance.js +262 -0
  47. package/build/src/cli/workflow-artifact-cleanup-audit.js +272 -0
  48. package/build/src/cli/workflow-sidecar.js +816 -0
  49. package/build/src/cli.js +89 -0
  50. package/build/src/flow-kit/validate.js +75 -0
  51. package/build/src/lib/args.js +45 -0
  52. package/build/src/lib/fs.js +62 -0
  53. package/build/src/lib/workflow-learning-projection.js +334 -0
  54. package/build/src/runtime-adapters.js +146 -0
  55. package/build/src/tools/build-universal-bundles.js +397 -0
  56. package/build/src/tools/common.js +56 -0
  57. package/build/src/tools/filter-installed-packs.js +132 -0
  58. package/build/src/tools/generate-context-map.js +198 -0
  59. package/build/src/tools/validate-package.js +64 -0
  60. package/build/src/tools/validate-source-tree.js +622 -0
  61. package/console.telemetry.json +176 -0
  62. package/context/base-rules.md +17 -0
  63. package/context/code-review-standards.md +62 -0
  64. package/context/coding-standards.md +42 -0
  65. package/context/common/orchestrators.md +12 -0
  66. package/context/common/subagents.md +28 -0
  67. package/context/contracts/artifact-contract.md +182 -0
  68. package/context/contracts/builder-kit-workflow-state-contract.md +319 -0
  69. package/context/contracts/delivery-contract.md +69 -0
  70. package/context/contracts/execution-contract.md +53 -0
  71. package/context/contracts/governance-adapter-contract.md +67 -0
  72. package/context/contracts/planning-contract.md +85 -0
  73. package/context/contracts/review-contract.md +104 -0
  74. package/context/contracts/sandbox-policy.md +52 -0
  75. package/context/contracts/verification-contract.md +134 -0
  76. package/context/contracts/work-item-contract.md +215 -0
  77. package/context/deferred/demo-mode.md +33 -0
  78. package/context/deferred/languages/go.md +31 -0
  79. package/context/deferred/languages/python.md +31 -0
  80. package/context/deferred/languages/typescript.md +34 -0
  81. package/context/deferred/parallelization.md +35 -0
  82. package/context/deferred/worktree-isolation.md +24 -0
  83. package/context/development-workflow.md +50 -0
  84. package/context/scripts/context-budget/budget-scan.sh +166 -0
  85. package/context/scripts/detect-tools.sh +3 -0
  86. package/context/scripts/discover-agents.sh +28 -0
  87. package/context/scripts/git-status.sh +49 -0
  88. package/context/scripts/hooks/config-protection.js +79 -0
  89. package/context/scripts/hooks/desktop-notify.sh +39 -0
  90. package/context/scripts/hooks/governance-audit.sh +135 -0
  91. package/context/scripts/hooks/lib/audit-transport.sh +40 -0
  92. package/context/scripts/hooks/lib/hook-flags.js +49 -0
  93. package/context/scripts/hooks/lib/patterns.sh +57 -0
  94. package/context/scripts/hooks/lib/resolve-formatter.js +80 -0
  95. package/context/scripts/hooks/post-edit-accumulator.js +66 -0
  96. package/context/scripts/hooks/pre-commit-quality.js +194 -0
  97. package/context/scripts/hooks/quality-gate.js +93 -0
  98. package/context/scripts/hooks/report-only-guard.js +21 -0
  99. package/context/scripts/hooks/run-hook.js +136 -0
  100. package/context/scripts/hooks/stop-format-typecheck.js +141 -0
  101. package/context/scripts/hooks/stop-goal-fit.js +337 -0
  102. package/context/scripts/hooks/workflow-steering.js +250 -0
  103. package/context/scripts/telemetry/console-presets.sh +14 -0
  104. package/context/scripts/telemetry/install-console-config.sh +214 -0
  105. package/context/scripts/telemetry/lib/config.sh +85 -0
  106. package/context/scripts/telemetry/lib/enrich.sh +115 -0
  107. package/context/scripts/telemetry/lib/redact.sh +22 -0
  108. package/context/scripts/telemetry/lib/session.sh +63 -0
  109. package/context/scripts/telemetry/lib/transport.sh +183 -0
  110. package/context/scripts/telemetry/lib/usage.sh +29 -0
  111. package/context/scripts/telemetry/sync-agents.sh +173 -0
  112. package/context/scripts/telemetry/telemetry.conf +23 -0
  113. package/context/scripts/telemetry/telemetry.sh +387 -0
  114. package/context/scripts/validate-package.sh +89 -0
  115. package/context/settings/backlog-provider-settings.json +54 -0
  116. package/context/templates/core/identity.md +26 -0
  117. package/context/templates/core/user.md +15 -0
  118. package/docs/_config.yml +15 -0
  119. package/docs/_layouts/default.html +87 -0
  120. package/docs/adr/0001-flow-agents-consumes-flow.md +77 -0
  121. package/docs/adr/0002-flow-kits-as-extension-unit.md +13 -0
  122. package/docs/adr/0003-flow-agents-coordinates-kits-and-adapters.md +13 -0
  123. package/docs/adr/0004-gates-expect-surface-claims.md +15 -0
  124. package/docs/adr/0005-kubernetes-inspired-resource-contracts.md +48 -0
  125. package/docs/adr/0006-typescript-first-source-policy.md +98 -0
  126. package/docs/agent-system-guidebook.md +391 -0
  127. package/docs/agent-usage-feedback-loop.md +351 -0
  128. package/docs/assets/favicon.svg +13 -0
  129. package/docs/assets/og-image.png +0 -0
  130. package/docs/assets/site.css +774 -0
  131. package/docs/assets/site.js +139 -0
  132. package/docs/configurable-workflow-routing.md +174 -0
  133. package/docs/context-map.md +145 -0
  134. package/docs/developer-architecture.md +145 -0
  135. package/docs/developer-hook-setup.md +61 -0
  136. package/docs/fixture-ownership.md +44 -0
  137. package/docs/flow-kit-repository-contract.md +180 -0
  138. package/docs/index.md +129 -0
  139. package/docs/kontour-resource-contract.md +358 -0
  140. package/docs/migrations.md +64 -0
  141. package/docs/north-star.md +322 -0
  142. package/docs/operating-layers.md +110 -0
  143. package/docs/repository-structure.md +132 -0
  144. package/docs/sandbox-policy.md +56 -0
  145. package/docs/skills-map.md +203 -0
  146. package/docs/standards-register.md +96 -0
  147. package/docs/veritas-integration.md +165 -0
  148. package/docs/work-item-adapters.md +72 -0
  149. package/docs/workflow-artifact-lifecycle.md +141 -0
  150. package/docs/workflow-eval-strategy.md +295 -0
  151. package/docs/workflow-shared-contracts.md +51 -0
  152. package/docs/workflow-usage-guide.md +443 -0
  153. package/evals/ARCHITECTURE.md +143 -0
  154. package/evals/CONVENTIONS.md +58 -0
  155. package/evals/README.md +128 -0
  156. package/evals/acceptance/run.sh +29 -0
  157. package/evals/acceptance/test_claude_harness.sh +242 -0
  158. package/evals/acceptance/test_codex_harness.sh +108 -0
  159. package/evals/acceptance/test_kiro_harness.sh +128 -0
  160. package/evals/cases/dev/404.html +97 -0
  161. package/evals/cases/dev/code-review.yaml +44 -0
  162. package/evals/cases/dev/dashboard.html +300 -0
  163. package/evals/cases/dev/deliver.yaml +66 -0
  164. package/evals/cases/dev/dependency-update.yaml +16 -0
  165. package/evals/cases/dev/explore.yaml +20 -0
  166. package/evals/cases/dev/index.html +370 -0
  167. package/evals/cases/dev/package-lock.json +28 -0
  168. package/evals/cases/dev/package.json +16 -0
  169. package/evals/cases/dev/plan-work.yaml +20 -0
  170. package/evals/cases/dev/promptfooconfig.yaml +666 -0
  171. package/evals/cases/dev/search-first.yaml +20 -0
  172. package/evals/cases/dev/tdd-workflow.yaml +48 -0
  173. package/evals/cases/dev/verify-work.yaml +44 -0
  174. package/evals/cases/dev/workflow.yaml +34 -0
  175. package/evals/ci/run-baseline.sh +283 -0
  176. package/evals/fixtures/backlog-provider-settings/global-default.json +44 -0
  177. package/evals/fixtures/backlog-provider-settings/project-override.json +53 -0
  178. package/evals/fixtures/builder-kit-workflow-state/baseline-freshness-resolution-hint.json +139 -0
  179. package/evals/fixtures/builder-kit-workflow-state/direct-primitive-stop.json +59 -0
  180. package/evals/fixtures/builder-kit-workflow-state/empty-board-route-shape.json +55 -0
  181. package/evals/fixtures/builder-kit-workflow-state/happy-path.json +71 -0
  182. package/evals/fixtures/builder-kit-workflow-state/mid-work-resume.json +80 -0
  183. package/evals/fixtures/builder-kit-workflow-state/missing-prestep-recovery.json +65 -0
  184. package/evals/fixtures/builder-kit-workflow-state/product-build-chaining.json +60 -0
  185. package/evals/fixtures/builder-kit-workflow-state/stale-continuation-requires-new-probe.json +57 -0
  186. package/evals/fixtures/console-learning-projection/artifacts/console-learning-correction/learning.json +50 -0
  187. package/evals/fixtures/console-learning-projection/artifacts/console-learning-open-route/learning.json +41 -0
  188. package/evals/fixtures/flow-kit-repository/invalid-absolute-path/kit.json +8 -0
  189. package/evals/fixtures/flow-kit-repository/invalid-asset-section/flows/review.flow.json +6 -0
  190. package/evals/fixtures/flow-kit-repository/invalid-asset-section/kit.json +11 -0
  191. package/evals/fixtures/flow-kit-repository/invalid-duplicate-flow/flows/review.flow.json +6 -0
  192. package/evals/fixtures/flow-kit-repository/invalid-duplicate-flow/kit.json +9 -0
  193. package/evals/fixtures/flow-kit-repository/invalid-id/flows/review.flow.json +6 -0
  194. package/evals/fixtures/flow-kit-repository/invalid-id/kit.json +8 -0
  195. package/evals/fixtures/flow-kit-repository/invalid-malformed-json/kit.json +8 -0
  196. package/evals/fixtures/flow-kit-repository/invalid-missing-flow/kit.json +8 -0
  197. package/evals/fixtures/flow-kit-repository/invalid-missing-id/flows/review.flow.json +6 -0
  198. package/evals/fixtures/flow-kit-repository/invalid-missing-id/kit.json +7 -0
  199. package/evals/fixtures/flow-kit-repository/invalid-missing-schema-version/flows/review.flow.json +6 -0
  200. package/evals/fixtures/flow-kit-repository/invalid-missing-schema-version/kit.json +7 -0
  201. package/evals/fixtures/flow-kit-repository/invalid-name/flows/review.flow.json +6 -0
  202. package/evals/fixtures/flow-kit-repository/invalid-name/kit.json +8 -0
  203. package/evals/fixtures/flow-kit-repository/invalid-schema-version/flows/review.flow.json +6 -0
  204. package/evals/fixtures/flow-kit-repository/invalid-schema-version/kit.json +8 -0
  205. package/evals/fixtures/flow-kit-repository/invalid-traversal/kit.json +8 -0
  206. package/evals/fixtures/flow-kit-repository/mixed-runtime-kit/adapters/example.json +3 -0
  207. package/evals/fixtures/flow-kit-repository/mixed-runtime-kit/assets/example.txt +1 -0
  208. package/evals/fixtures/flow-kit-repository/mixed-runtime-kit/docs/README.md +3 -0
  209. package/evals/fixtures/flow-kit-repository/mixed-runtime-kit/flows/runtime.flow.json +26 -0
  210. package/evals/fixtures/flow-kit-repository/mixed-runtime-kit/kit-evals/example.json +3 -0
  211. package/evals/fixtures/flow-kit-repository/mixed-runtime-kit/kit-skills/mixed/SKILL.md +3 -0
  212. package/evals/fixtures/flow-kit-repository/mixed-runtime-kit/kit.json +44 -0
  213. package/evals/fixtures/flow-kit-repository/valid-local-kit/docs/README.md +3 -0
  214. package/evals/fixtures/flow-kit-repository/valid-local-kit/flows/review.flow.json +26 -0
  215. package/evals/fixtures/flow-kit-repository/valid-local-kit/kit.json +20 -0
  216. package/evals/fixtures/hook-influence/cases.json +336 -0
  217. package/evals/fixtures/pull-work-provider/github-issues.json +170 -0
  218. package/evals/fixtures/pull-work-wip-shepherding/global-wip-informs.json +43 -0
  219. package/evals/fixtures/pull-work-wip-shepherding/personal-wip-blocks.json +42 -0
  220. package/evals/fixtures/surface-trust/accepted-claim-trust-report.json +31 -0
  221. package/evals/fixtures/surface-trust/artifact-absent.json +19 -0
  222. package/evals/fixtures/surface-trust/integrity-mismatch-trust-report.json +32 -0
  223. package/evals/fixtures/surface-trust/missing-authority-trust-report.json +27 -0
  224. package/evals/fixtures/surface-trust/provider-absent.json +19 -0
  225. package/evals/fixtures/surface-trust/rejected-claim-trust-report.json +30 -0
  226. package/evals/fixtures/surface-trust/stale-claim-trust-snapshot.json +31 -0
  227. package/evals/fixtures/usage-feedback/sample-full.jsonl +11 -0
  228. package/evals/fixtures/usage-feedback/sample-outcomes.jsonl +1 -0
  229. package/evals/fixtures/veritas-governance-adapter/fake-veritas-pass.sh +18 -0
  230. package/evals/fixtures/veritas-governance-adapter/fake-veritas-secret-fail.sh +10 -0
  231. package/evals/fixtures/veritas-governance-adapter/fake-veritas-unconfigured.sh +4 -0
  232. package/evals/integration/test_bundle_install.sh +541 -0
  233. package/evals/integration/test_console_learning_projection.sh +192 -0
  234. package/evals/integration/test_context_map.sh +65 -0
  235. package/evals/integration/test_effective_backlog_settings.sh +58 -0
  236. package/evals/integration/test_fixture_retirement_audit.sh +58 -0
  237. package/evals/integration/test_flow_agents_statusline.sh +93 -0
  238. package/evals/integration/test_flow_kit_repository.sh +90 -0
  239. package/evals/integration/test_goal_fit_hook.sh +482 -0
  240. package/evals/integration/test_hook_category_behaviors.sh +190 -0
  241. package/evals/integration/test_hook_influence_cases.sh +69 -0
  242. package/evals/integration/test_local_flow_kit_install.sh +145 -0
  243. package/evals/integration/test_publish_change_helper.sh +176 -0
  244. package/evals/integration/test_pull_work_provider.sh +140 -0
  245. package/evals/integration/test_runtime_adapter_activation.sh +106 -0
  246. package/evals/integration/test_telemetry.sh +485 -0
  247. package/evals/integration/test_telemetry_doctor.sh +193 -0
  248. package/evals/integration/test_usage_feedback_dashboard.sh +169 -0
  249. package/evals/integration/test_usage_feedback_global.sh +117 -0
  250. package/evals/integration/test_usage_feedback_import.sh +227 -0
  251. package/evals/integration/test_usage_feedback_outcomes.sh +165 -0
  252. package/evals/integration/test_usage_feedback_report.sh +263 -0
  253. package/evals/integration/test_veritas_governance_adapter.sh +235 -0
  254. package/evals/integration/test_workflow_artifact_cleanup_audit.sh +287 -0
  255. package/evals/integration/test_workflow_artifacts.sh +1247 -0
  256. package/evals/integration/test_workflow_sidecar_writer.sh +2112 -0
  257. package/evals/integration/test_workflow_steering_hook.sh +337 -0
  258. package/evals/lib/assertions/delegated-to.js +40 -0
  259. package/evals/lib/assertions/max-tool-calls.js +15 -0
  260. package/evals/lib/assertions/no-write-tools.js +27 -0
  261. package/evals/lib/assertions/pass-at-k.js +39 -0
  262. package/evals/lib/assertions/telemetry-utils.js +105 -0
  263. package/evals/lib/assertions/tool-called.js +39 -0
  264. package/evals/lib/assertions/verify-after-fix.js +61 -0
  265. package/evals/lib/claude-judge.sh +40 -0
  266. package/evals/lib/claude-provider.sh +74 -0
  267. package/evals/lib/codex-judge.sh +39 -0
  268. package/evals/lib/codex-provider.sh +81 -0
  269. package/evals/lib/eval-dev.sh +5 -0
  270. package/evals/lib/eval-judge.sh +22 -0
  271. package/evals/lib/eval-provider.sh +26 -0
  272. package/evals/lib/eval-report.sh +73 -0
  273. package/evals/lib/kiro-dev.sh +4 -0
  274. package/evals/lib/kiro-judge.sh +17 -0
  275. package/evals/lib/kiro-provider.sh +62 -0
  276. package/evals/lib/node.sh +111 -0
  277. package/evals/promptfooconfig.yaml +70 -0
  278. package/evals/run.sh +309 -0
  279. package/evals/static/test_evidence_refs.sh +141 -0
  280. package/evals/static/test_package.sh +407 -0
  281. package/evals/static/test_repo_hooks.sh +68 -0
  282. package/evals/static/test_universal_bundles.sh +274 -0
  283. package/evals/static/test_workflow_skills.sh +1207 -0
  284. package/install.sh +64 -0
  285. package/integrations/veritas/flow-agents.adapter.json +138 -0
  286. package/integrations/veritas/flow-agents.authority-settings.json +26 -0
  287. package/integrations/veritas/flow-agents.repo-standards.json +82 -0
  288. package/kits/builder/flows/build.flow.json +218 -0
  289. package/kits/builder/flows/shape.flow.json +127 -0
  290. package/kits/builder/kit.json +19 -0
  291. package/kits/catalog.json +11 -0
  292. package/package.json +130 -0
  293. package/packaging/README.md +60 -0
  294. package/packaging/manifest.json +173 -0
  295. package/packaging/packs.json +69 -0
  296. package/powers/dependency-checker/POWER.md +20 -0
  297. package/powers/dependency-checker/mcp.json +20 -0
  298. package/powers/playwright/POWER.md +25 -0
  299. package/powers/playwright/mcp.json +12 -0
  300. package/prompts/code-audit.md +123 -0
  301. package/prompts/kcommit.md +88 -0
  302. package/schemas/backlog-provider-settings.schema.json +138 -0
  303. package/schemas/workflow-acceptance.schema.json +216 -0
  304. package/schemas/workflow-critique.schema.json +113 -0
  305. package/schemas/workflow-evidence.schema.json +357 -0
  306. package/schemas/workflow-handoff.schema.json +52 -0
  307. package/schemas/workflow-learning.schema.json +223 -0
  308. package/schemas/workflow-release.schema.json +172 -0
  309. package/schemas/workflow-state.schema.json +80 -0
  310. package/scripts/README.md +111 -0
  311. package/scripts/build-universal-bundles.js +3 -0
  312. package/scripts/check-content-boundary.cjs +99 -0
  313. package/scripts/context-budget/budget-scan.sh +166 -0
  314. package/scripts/detect-tools.sh +3 -0
  315. package/scripts/discover-agents.sh +28 -0
  316. package/scripts/effective-backlog-settings.js +2 -0
  317. package/scripts/filter-installed-packs.js +2 -0
  318. package/scripts/flow-kit.js +2 -0
  319. package/scripts/generate-context-map.js +2 -0
  320. package/scripts/git-status.sh +49 -0
  321. package/scripts/hooks/claude-hook-adapter.js +174 -0
  322. package/scripts/hooks/claude-telemetry-hook.js +115 -0
  323. package/scripts/hooks/codex-hook-adapter.js +176 -0
  324. package/scripts/hooks/codex-telemetry-hook.js +95 -0
  325. package/scripts/hooks/config-protection.js +79 -0
  326. package/scripts/hooks/desktop-notify.sh +39 -0
  327. package/scripts/hooks/governance-audit.sh +135 -0
  328. package/scripts/hooks/lib/audit-transport.sh +40 -0
  329. package/scripts/hooks/lib/hook-flags.js +49 -0
  330. package/scripts/hooks/lib/patterns.sh +57 -0
  331. package/scripts/hooks/lib/resolve-formatter.js +80 -0
  332. package/scripts/hooks/post-edit-accumulator.js +66 -0
  333. package/scripts/hooks/pre-commit-quality.js +194 -0
  334. package/scripts/hooks/quality-gate.js +93 -0
  335. package/scripts/hooks/report-only-guard.js +21 -0
  336. package/scripts/hooks/run-hook.js +136 -0
  337. package/scripts/hooks/stop-format-typecheck.js +141 -0
  338. package/scripts/hooks/stop-goal-fit.js +337 -0
  339. package/scripts/hooks/workflow-steering.js +250 -0
  340. package/scripts/install-codex-home.sh +106 -0
  341. package/scripts/package.json +3 -0
  342. package/scripts/promote-workflow-artifact.js +2 -0
  343. package/scripts/publish-change-helper.js +2 -0
  344. package/scripts/pull-work-provider.js +2 -0
  345. package/scripts/setup-repo-hooks.sh +8 -0
  346. package/scripts/statusline/flow-agents-statusline.js +157 -0
  347. package/scripts/telemetry/console-presets.sh +14 -0
  348. package/scripts/telemetry/install-console-config.sh +214 -0
  349. package/scripts/telemetry/lib/config.sh +85 -0
  350. package/scripts/telemetry/lib/enrich.sh +115 -0
  351. package/scripts/telemetry/lib/redact.sh +22 -0
  352. package/scripts/telemetry/lib/session.sh +63 -0
  353. package/scripts/telemetry/lib/transport.sh +183 -0
  354. package/scripts/telemetry/lib/usage.sh +29 -0
  355. package/scripts/telemetry/sync-agents.sh +173 -0
  356. package/scripts/telemetry/telemetry.conf +23 -0
  357. package/scripts/telemetry/telemetry.sh +387 -0
  358. package/scripts/usage-feedback.js +2 -0
  359. package/scripts/validate-hook-influence-cases.js +2 -0
  360. package/scripts/validate-package.sh +89 -0
  361. package/scripts/validate-source-tree.js +9 -0
  362. package/skills/agentic-engineering/SKILL.md +62 -0
  363. package/skills/browser-test/SKILL.md +51 -0
  364. package/skills/builder-shape/SKILL.md +76 -0
  365. package/skills/context-budget/SKILL.md +40 -0
  366. package/skills/deliver/SKILL.md +241 -0
  367. package/skills/dependency-update/SKILL.md +68 -0
  368. package/skills/design-probe/SKILL.md +107 -0
  369. package/skills/eval-rebuild/SKILL.md +39 -0
  370. package/skills/evidence-gate/SKILL.md +186 -0
  371. package/skills/execute-plan/SKILL.md +110 -0
  372. package/skills/explore/SKILL.md +137 -0
  373. package/skills/feedback-loop/SKILL.md +87 -0
  374. package/skills/fix-bug/SKILL.md +133 -0
  375. package/skills/frontend-design/SKILL.md +80 -0
  376. package/skills/github-cli/SKILL.md +63 -0
  377. package/skills/idea-to-backlog/SKILL.md +267 -0
  378. package/skills/knowledge-capture/SKILL.md +55 -0
  379. package/skills/learning-review/SKILL.md +115 -0
  380. package/skills/pickup-probe/SKILL.md +114 -0
  381. package/skills/plan-work/SKILL.md +176 -0
  382. package/skills/pull-work/SKILL.md +309 -0
  383. package/skills/release-readiness/SKILL.md +121 -0
  384. package/skills/review-work/SKILL.md +161 -0
  385. package/skills/search-first/SKILL.md +66 -0
  386. package/skills/tdd-workflow/SKILL.md +140 -0
  387. package/skills/verify-work/SKILL.md +109 -0
  388. package/src/cli/console-learning-projection.ts +140 -0
  389. package/src/cli/effective-backlog-settings.ts +99 -0
  390. package/src/cli/fixture-retirement-audit.ts +154 -0
  391. package/src/cli/flow-kit.ts +139 -0
  392. package/src/cli/init.ts +248 -0
  393. package/src/cli/promote-workflow-artifact.ts +64 -0
  394. package/src/cli/publish-change-helper.ts +143 -0
  395. package/src/cli/pull-work-provider.ts +481 -0
  396. package/src/cli/runtime-adapter.ts +24 -0
  397. package/src/cli/telemetry-doctor.ts +243 -0
  398. package/src/cli/usage-feedback.ts +418 -0
  399. package/src/cli/validate-hook-influence.ts +119 -0
  400. package/src/cli/validate-source-tree.ts +30 -0
  401. package/src/cli/validate-workflow-artifacts.ts +411 -0
  402. package/src/cli/veritas-governance.ts +322 -0
  403. package/src/cli/workflow-artifact-cleanup-audit.ts +281 -0
  404. package/src/cli/workflow-sidecar.ts +676 -0
  405. package/src/cli.ts +95 -0
  406. package/src/flow-kit/validate.ts +74 -0
  407. package/src/lib/args.ts +43 -0
  408. package/src/lib/fs.ts +62 -0
  409. package/src/lib/workflow-learning-projection.ts +491 -0
  410. package/src/runtime-adapters.ts +154 -0
  411. package/src/tools/build-universal-bundles.ts +366 -0
  412. package/src/tools/common.ts +61 -0
  413. package/src/tools/filter-installed-packs.ts +129 -0
  414. package/src/tools/generate-context-map.ts +199 -0
  415. package/src/tools/validate-package.ts +57 -0
  416. package/src/tools/validate-source-tree.ts +488 -0
  417. package/tsconfig.json +19 -0
  418. package/veritas.claims.json +6 -0
@@ -0,0 +1,138 @@
1
+ import * as crypto from "node:crypto";
2
+ import * as fs from "node:fs";
3
+ import * as path from "node:path";
4
+ import { parseArgs, flagBool, flagString } from "../lib/args.js";
5
+ import { assertPathContained, copyDir, isoNow, readJson, walkFiles, writeJson } from "../lib/fs.js";
6
+ import { assertKitRepository } from "../flow-kit/validate.js";
7
+ import { activateCodexLocal } from "../runtime-adapters.js";
8
+ const REGISTRY_REL = path.join("kits", "local", "installed-kits.json");
9
+ const REPOSITORIES_REL = path.join("kits", "local", "repositories");
10
+ function registryPath(dest) { return path.join(dest, REGISTRY_REL); }
11
+ function installedPath(dest, kitId) { return path.join(dest, REPOSITORIES_REL, kitId); }
12
+ function loadRegistry(dest) {
13
+ const file = registryPath(dest);
14
+ if (!fs.existsSync(file))
15
+ return { schema_version: "1.0", kits: [] };
16
+ const data = readJson(file);
17
+ return { schema_version: data.schema_version ?? "1.0", kits: Array.isArray(data.kits) ? data.kits.filter((item) => typeof item === "object" && item !== null) : [] };
18
+ }
19
+ function contentHash(root) {
20
+ const hash = crypto.createHash("sha256");
21
+ for (const file of walkFiles(root)) {
22
+ const rel = path.relative(root, file).split(path.sep).join("/");
23
+ hash.update(rel);
24
+ hash.update("\0");
25
+ hash.update(fs.readFileSync(file));
26
+ hash.update("\0");
27
+ }
28
+ return `sha256:${hash.digest("hex")}`;
29
+ }
30
+ function installLocal(argv) {
31
+ const args = parseArgs(argv);
32
+ const source = path.resolve(args.positionals[0] ?? "");
33
+ const dest = path.resolve(flagString(args.flags, "dest", ".") ?? ".");
34
+ let manifest;
35
+ try {
36
+ manifest = assertKitRepository(source);
37
+ }
38
+ catch (error) {
39
+ console.log("warning: Flow validation surface unavailable; local kit check uses the minimal Flow Definition fallback");
40
+ console.log("Flow Kit repository validation failed:");
41
+ for (const diagnostic of (error.diagnostics ?? [error.message]))
42
+ console.log(` - ${diagnostic}`);
43
+ return 1;
44
+ }
45
+ console.log("warning: Flow validation surface unavailable; local kit check uses the minimal Flow Definition fallback");
46
+ const kitId = String(manifest.id);
47
+ const hash = contentHash(source);
48
+ const registry = loadRegistry(dest);
49
+ const existing = registry.kits.find((entry) => entry.id === kitId);
50
+ const target = installedPath(dest, kitId);
51
+ assertPathContained(dest, target);
52
+ const sourceText = source;
53
+ if (existing && existing.source !== sourceText && !flagBool(args.flags, "update")) {
54
+ console.log(`conflict: kit '${kitId}' is already installed from ${existing.source}; rerun with --update to replace it`);
55
+ return 2;
56
+ }
57
+ if (existing && existing.source === sourceText && existing.hash === hash && fs.existsSync(target) && !flagBool(args.flags, "force")) {
58
+ console.log(`kit '${kitId}' is already installed from ${sourceText}`);
59
+ return 0;
60
+ }
61
+ copyDir(source, target);
62
+ const entry = {
63
+ id: kitId,
64
+ source: sourceText,
65
+ hash,
66
+ installed_at: existing && existing.source === sourceText && !flagBool(args.flags, "update") ? existing.installed_at : isoNow(),
67
+ installed_path: target,
68
+ state: "installed",
69
+ };
70
+ if (typeof manifest.version === "string" && manifest.version)
71
+ entry.version = manifest.version;
72
+ registry.kits = existing ? registry.kits.map((item) => item.id === kitId ? entry : item) : [...registry.kits, entry];
73
+ writeJson(registryPath(dest), registry);
74
+ console.log(`${existing ? "updated" : "installed"} local kit '${kitId}' at ${target}`);
75
+ return 0;
76
+ }
77
+ function list(argv) {
78
+ const args = parseArgs(argv);
79
+ const dest = path.resolve(flagString(args.flags, "dest", ".") ?? ".");
80
+ const entries = loadRegistry(dest).kits;
81
+ if (!entries.length) {
82
+ console.log("No local Flow Kits installed.");
83
+ return 0;
84
+ }
85
+ for (const entry of entries.sort((a, b) => String(a.id ?? "").localeCompare(String(b.id ?? "")))) {
86
+ console.log(`${entry.id} | source=${entry.source} | hash=${entry.hash} | installed_at=${entry.installed_at} | path=${entry.installed_path} | state=${entry.state ?? "unknown"}`);
87
+ }
88
+ return 0;
89
+ }
90
+ function status(argv) {
91
+ const args = parseArgs(argv);
92
+ const dest = path.resolve(flagString(args.flags, "dest", ".") ?? ".");
93
+ let entries = loadRegistry(dest).kits;
94
+ const kitId = args.positionals[0];
95
+ if (kitId) {
96
+ entries = entries.filter((entry) => entry.id === kitId);
97
+ if (!entries.length) {
98
+ console.log(`local Flow Kit '${kitId}' is not installed`);
99
+ return 1;
100
+ }
101
+ }
102
+ if (!entries.length) {
103
+ console.log("No local Flow Kits installed.");
104
+ return 0;
105
+ }
106
+ for (const entry of entries.sort((a, b) => String(a.id ?? "").localeCompare(String(b.id ?? "")))) {
107
+ console.log(JSON.stringify({ ...entry, state: fs.existsSync(String(entry.installed_path ?? "")) ? "installed" : "missing" }, null, 2));
108
+ }
109
+ return 0;
110
+ }
111
+ function activate(argv) {
112
+ const args = parseArgs(argv);
113
+ const dest = path.resolve(flagString(args.flags, "dest", ".") ?? ".");
114
+ const sourceRoot = path.resolve(flagString(args.flags, "source-root", path.resolve(path.dirname(process.argv[1]), "..")) ?? ".");
115
+ const adapter = flagString(args.flags, "adapter");
116
+ if (adapter && adapter !== "codex-local") {
117
+ console.log(JSON.stringify({ selected_adapter: null, available_adapters: ["codex-local"], supported_asset_classes: [], generated_runtime_files: [], skipped_assets: [], warnings: [], errors: [`unknown runtime adapter '${adapter}'; available adapters: codex-local`] }, null, 2));
118
+ return 2;
119
+ }
120
+ const result = activateCodexLocal(sourceRoot, dest);
121
+ console.log(JSON.stringify(result, null, 2));
122
+ return Array.isArray(result.errors) && result.errors.length ? 1 : 0;
123
+ }
124
+ export function main(argv = process.argv.slice(2)) {
125
+ const [command, ...rest] = argv;
126
+ if (command === "install-local")
127
+ return installLocal(rest);
128
+ if (command === "list")
129
+ return list(rest);
130
+ if (command === "status")
131
+ return status(rest);
132
+ if (command === "activate")
133
+ return activate(rest);
134
+ console.error("usage: flow-kit <install-local|list|status|activate> ...");
135
+ return 2;
136
+ }
137
+ if (import.meta.url === `file://${process.argv[1]}`)
138
+ process.exit(main());
@@ -0,0 +1,50 @@
1
+ import * as fs from "node:fs";
2
+ const SKIP = [/mail\.google\.com/i, /outlook\.(office|live)\.com/i, /calendar\.google\.com/i, /linkedin\.com\/in\//i, /slack\.com\/archives/i, /zoom\.us\/j\//i, /teams\.microsoft\.com/i];
3
+ const TAGS = [[/github\.com|gitlab\.com|codecommit|code\.amazon/i, "repo"], [/docs\.|documentation|\/docs\/|readme|userguide|developer-guide/i, "docs"], [/wiki\.|\/wiki\/|confluence|runbook/i, "wiki"], [/dashboard|console\.|portal|admin\.|grafana|cloudwatch/i, "tool"], [/learn\.|training\.|course|certification|workshop|tutorial/i, "training"], [/template|boilerplate|starter|scaffold/i, "template"], [/spec\.|standard|architecture|rfc|design-doc/i, "reference"]];
4
+ function inferTag(url) {
5
+ return TAGS.find(([pattern]) => pattern.test(url))?.[1] ?? "external";
6
+ }
7
+ function existingUrls(file) {
8
+ if (!fs.existsSync(file))
9
+ return new Set();
10
+ return new Set(Array.from(fs.readFileSync(file, "utf8").matchAll(/-->\s*(https?:\/\/\S+)|—\s+(https?:\/\/\S+)/g), (match) => match[1] ?? match[2]));
11
+ }
12
+ export function main(argv = process.argv.slice(2)) {
13
+ if (argv.length < 2) {
14
+ console.log("Usage: import-bookmarks <bookmarks.html> <bookmarks.md>");
15
+ return 1;
16
+ }
17
+ const [htmlPath, mdPath] = argv;
18
+ if (!fs.existsSync(htmlPath)) {
19
+ console.log(`Error: ${htmlPath} not found`);
20
+ return 1;
21
+ }
22
+ const html = fs.readFileSync(htmlPath, "utf8");
23
+ const bookmarks = Array.from(html.matchAll(/<A\b[^>]*HREF=["']([^"']+)["'][^>]*>(.*?)<\/A>/gi), (match) => ({ url: match[1], title: match[2].replace(/<[^>]+>/g, "").trim() }));
24
+ console.log(`Found ${bookmarks.length} bookmarks in HTML`);
25
+ const seen = existingUrls(mdPath);
26
+ console.log(`Found ${seen.size} existing entries in bookmarks.md`);
27
+ const today = new Date().toISOString().slice(0, 10);
28
+ const entries = [];
29
+ let skipped = 0;
30
+ let preserved = 0;
31
+ for (const bookmark of bookmarks) {
32
+ if (!/^https?:\/\//.test(bookmark.url) || SKIP.some((pattern) => pattern.test(bookmark.url))) {
33
+ skipped += 1;
34
+ continue;
35
+ }
36
+ if (seen.has(bookmark.url)) {
37
+ preserved += 1;
38
+ continue;
39
+ }
40
+ entries.push(`- **${today}** [${inferTag(bookmark.url)}]: ${bookmark.title} — ${bookmark.url} — (imported from browser)`);
41
+ }
42
+ if (entries.length)
43
+ fs.appendFileSync(mdPath, `${fs.existsSync(mdPath) ? "\n" : ""}${entries.join("\n")}\n`, "utf8");
44
+ console.log(`Added ${entries.length} new bookmarks`);
45
+ console.log(`Preserved ${preserved} existing bookmarks`);
46
+ console.log(`Skipped ${skipped} routine/non-http bookmarks`);
47
+ return 0;
48
+ }
49
+ if (import.meta.url === `file://${process.argv[1]}`)
50
+ process.exit(main());
@@ -0,0 +1,239 @@
1
+ import { spawnSync } from "node:child_process";
2
+ import * as fs from "node:fs";
3
+ import * as os from "node:os";
4
+ import * as path from "node:path";
5
+ import { createInterface } from "node:readline/promises";
6
+ import { stdin as input, stdout as output } from "node:process";
7
+ import { parseArgs, flagBool, flagList, flagString } from "../lib/args.js";
8
+ import { activateCodexLocal } from "../runtime-adapters.js";
9
+ import { main as buildBundles } from "../tools/build-universal-bundles.js";
10
+ import { root } from "../tools/common.js";
11
+ const runtimeBundles = {
12
+ base: "base",
13
+ codex: "codex",
14
+ "claude-code": "claude-code",
15
+ kiro: "kiro",
16
+ };
17
+ function usage() {
18
+ console.error(`usage: flow-agents init [options]
19
+
20
+ Options:
21
+ --runtime base|codex|claude-code|kiro
22
+ --dest PATH
23
+ --telemetry-sink local-files|local-kontour-console|kontour-hosted-console|user-hosted-console
24
+ --console-url URL
25
+ --console-endpoint URL
26
+ --console-token-file PATH
27
+ --console-tenant ID
28
+ --packs LIST
29
+ --activate-kits
30
+ --yes, --headless
31
+ `);
32
+ }
33
+ function normalizeRuntime(value) {
34
+ if (!value)
35
+ return undefined;
36
+ if (value === "claude")
37
+ return "claude-code";
38
+ if (value === "base" || value === "codex" || value === "claude-code" || value === "kiro")
39
+ return value;
40
+ throw new Error(`unknown runtime '${value}'; expected base, codex, claude-code, or kiro`);
41
+ }
42
+ function normalizeTelemetrySink(value) {
43
+ if (value === "local-files" || value === "local-kontour-console" || value === "kontour-hosted-console" || value === "user-hosted-console" || value === "kontour-cloud" || value === "hosted-kontour-console")
44
+ return value;
45
+ throw new Error(`unknown telemetry sink '${value}'`);
46
+ }
47
+ function telemetrySinksFromValues(values) {
48
+ const sinks = values.flatMap((value) => value.split(",")).map((value) => value.trim()).filter(Boolean).map(normalizeTelemetrySink);
49
+ return sinks.length ? Array.from(new Set(sinks)) : ["local-files"];
50
+ }
51
+ function telemetrySinksFromFlags(flags) {
52
+ return telemetrySinksFromValues(flagList(flags, "telemetry-sink").concat(flagList(flags, "telemetry-sinks")));
53
+ }
54
+ function needsConsoleCredentials(sinks) {
55
+ return sinks.some((sink) => sink !== "local-files");
56
+ }
57
+ async function questionHidden(prompt) {
58
+ if (!process.stdin.isTTY)
59
+ return "";
60
+ return await new Promise((resolve) => {
61
+ const stdin = process.stdin;
62
+ const stdout = process.stdout;
63
+ const wasRaw = stdin.isRaw;
64
+ stdout.write(prompt);
65
+ stdin.setRawMode(true);
66
+ stdin.resume();
67
+ let value = "";
68
+ const onData = (buffer) => {
69
+ const text = buffer.toString("utf8");
70
+ if (text === "\u0003") {
71
+ stdout.write("\n");
72
+ process.exit(130);
73
+ }
74
+ if (text === "\r" || text === "\n") {
75
+ stdout.write("\n");
76
+ stdin.setRawMode(wasRaw);
77
+ stdin.off("data", onData);
78
+ resolve(value);
79
+ return;
80
+ }
81
+ if (text === "\u007f") {
82
+ value = value.slice(0, -1);
83
+ return;
84
+ }
85
+ value += text;
86
+ };
87
+ stdin.on("data", onData);
88
+ });
89
+ }
90
+ function defaultDest(runtime) {
91
+ if (runtime === "kiro")
92
+ return path.join(os.homedir(), ".flow-agents");
93
+ return process.cwd();
94
+ }
95
+ function parseYesNo(value, fallback) {
96
+ const normalized = value.trim().toLowerCase();
97
+ if (!normalized)
98
+ return fallback;
99
+ if (["y", "yes", "true", "1"].includes(normalized))
100
+ return true;
101
+ if (["n", "no", "false", "0"].includes(normalized))
102
+ return false;
103
+ return fallback;
104
+ }
105
+ async function interactiveOptions(argv) {
106
+ const args = parseArgs(argv);
107
+ const rl = createInterface({ input, output });
108
+ try {
109
+ const runtimeDefault = normalizeRuntime(flagString(args.flags, "runtime")) ?? "base";
110
+ const runtimeAnswer = flagString(args.flags, "runtime") ?? await rl.question(`Runtime [${runtimeDefault}]: `);
111
+ const runtime = normalizeRuntime(runtimeAnswer.trim() || runtimeDefault) ?? runtimeDefault;
112
+ const destDefault = flagString(args.flags, "dest", defaultDest(runtime)) ?? defaultDest(runtime);
113
+ const destAnswer = flagString(args.flags, "dest") ?? await rl.question(`Install destination [${destDefault}]: `);
114
+ const sinkDefault = telemetrySinksFromFlags(args.flags);
115
+ const sinkAnswer = flagList(args.flags, "telemetry-sink").length || flagList(args.flags, "telemetry-sinks").length
116
+ ? sinkDefault.join(",")
117
+ : await rl.question(`Telemetry sinks [${sinkDefault.join(",")}]: `);
118
+ const telemetrySinks = telemetrySinksFromValues([sinkAnswer || sinkDefault.join(",")]);
119
+ const needsUserHostedUrl = telemetrySinks.includes("user-hosted-console") || telemetrySinks.includes("hosted-kontour-console");
120
+ const consoleUrl = flagString(args.flags, "console-url") ?? (needsUserHostedUrl ? await rl.question("User-hosted Console URL: ") : undefined);
121
+ const consoleEndpoint = flagString(args.flags, "console-endpoint") ?? flagString(args.flags, "console-endpoint-url");
122
+ const consoleTokenFile = flagString(args.flags, "console-token-file");
123
+ const consoleTokenValue = consoleTokenFile ? undefined : (needsConsoleCredentials(telemetrySinks) ? await questionHidden("Console telemetry token (blank to skip): ") : undefined);
124
+ const consoleTenant = flagString(args.flags, "console-tenant") ?? flagString(args.flags, "console-tenant-id") ?? (needsConsoleCredentials(telemetrySinks) ? await rl.question("Console tenant ID (blank to skip): ") : undefined);
125
+ const activateDefault = false;
126
+ const activateAnswer = flagBool(args.flags, "activate-kits")
127
+ ? "yes"
128
+ : runtime === "codex"
129
+ ? await rl.question(`Activate local Builder Kit runtime assets [${activateDefault ? "Y/n" : "y/N"}]: `)
130
+ : "no";
131
+ return {
132
+ runtime,
133
+ dest: path.resolve(destAnswer.trim() || destDefault),
134
+ consoleUrl: consoleUrl?.trim() || undefined,
135
+ consoleEndpoint: consoleEndpoint?.trim() || undefined,
136
+ consoleTokenFile: consoleTokenFile?.trim() || undefined,
137
+ consoleTokenValue: consoleTokenValue?.trim() || undefined,
138
+ consoleTenant: consoleTenant?.trim() || undefined,
139
+ telemetrySinks,
140
+ packs: flagString(args.flags, "packs"),
141
+ activateKits: runtime === "codex" && parseYesNo(activateAnswer, activateDefault),
142
+ };
143
+ }
144
+ finally {
145
+ rl.close();
146
+ }
147
+ }
148
+ function headlessOptions(argv) {
149
+ const args = parseArgs(argv);
150
+ const runtime = normalizeRuntime(flagString(args.flags, "runtime")) ?? "base";
151
+ return {
152
+ runtime,
153
+ dest: path.resolve(flagString(args.flags, "dest", defaultDest(runtime)) ?? defaultDest(runtime)),
154
+ consoleUrl: flagString(args.flags, "console-url"),
155
+ consoleEndpoint: flagString(args.flags, "console-endpoint") ?? flagString(args.flags, "console-endpoint-url"),
156
+ consoleTokenFile: flagString(args.flags, "console-token-file"),
157
+ consoleTenant: flagString(args.flags, "console-tenant") ?? flagString(args.flags, "console-tenant-id"),
158
+ telemetrySinks: telemetrySinksFromFlags(args.flags),
159
+ packs: flagString(args.flags, "packs"),
160
+ activateKits: runtime === "codex" && flagBool(args.flags, "activate-kits"),
161
+ };
162
+ }
163
+ function ensureBundle(runtime) {
164
+ const bundle = path.join(root, "dist", runtimeBundles[runtime]);
165
+ if (!fs.existsSync(path.join(bundle, "install.sh"))) {
166
+ const rc = buildBundles();
167
+ if (rc !== 0)
168
+ throw new Error(`bundle build failed with exit code ${rc}`);
169
+ }
170
+ if (!fs.existsSync(path.join(bundle, "install.sh")))
171
+ throw new Error(`bundle installer missing: ${bundle}`);
172
+ return bundle;
173
+ }
174
+ function installBundle(bundle, options) {
175
+ const args = ["install.sh", options.dest];
176
+ for (const sink of options.telemetrySinks)
177
+ args.push("--telemetry-sink", sink);
178
+ if (options.consoleUrl)
179
+ args.push("--console-url", options.consoleUrl);
180
+ if (options.consoleEndpoint)
181
+ args.push("--console-endpoint", options.consoleEndpoint);
182
+ let tempTokenFile;
183
+ const consoleTokenFile = options.consoleTokenFile ?? (() => {
184
+ if (!options.consoleTokenValue)
185
+ return undefined;
186
+ const file = path.join(fs.mkdtempSync(path.join(os.tmpdir(), "flow-agents-token-")), "console-token");
187
+ fs.writeFileSync(file, options.consoleTokenValue, { encoding: "utf8", mode: 0o600 });
188
+ tempTokenFile = file;
189
+ return file;
190
+ })();
191
+ if (consoleTokenFile)
192
+ args.push("--console-token-file", consoleTokenFile);
193
+ if (options.consoleTenant)
194
+ args.push("--console-tenant", options.consoleTenant);
195
+ const env = { ...process.env };
196
+ if (options.packs)
197
+ env.FLOW_AGENTS_PACKS = options.packs;
198
+ const result = spawnSync("bash", args, { cwd: bundle, env, encoding: "utf8", stdio: "inherit" });
199
+ if (tempTokenFile)
200
+ fs.rmSync(path.dirname(tempTokenFile), { recursive: true, force: true });
201
+ if (result.error) {
202
+ console.error(`flow-agents init: unable to run bundle installer: ${result.error.message}`);
203
+ return 1;
204
+ }
205
+ return result.status ?? 1;
206
+ }
207
+ function activateKits(options) {
208
+ if (!options.activateKits)
209
+ return 0;
210
+ const result = activateCodexLocal(options.dest, options.dest);
211
+ if (Array.isArray(result.errors) && result.errors.length > 0) {
212
+ console.error(JSON.stringify(result, null, 2));
213
+ return 1;
214
+ }
215
+ const generated = Array.isArray(result.generated_runtime_files) ? result.generated_runtime_files : [];
216
+ console.log(`Activated ${generated.length} Codex local runtime asset(s)`);
217
+ return 0;
218
+ }
219
+ export async function main(argv = process.argv.slice(2)) {
220
+ if (argv.includes("--help") || argv.includes("-h")) {
221
+ usage();
222
+ return 0;
223
+ }
224
+ const headless = argv.includes("--yes") || argv.includes("--headless") || !process.stdin.isTTY;
225
+ try {
226
+ const options = headless ? headlessOptions(argv) : await interactiveOptions(argv);
227
+ const bundle = ensureBundle(options.runtime);
228
+ const installed = installBundle(bundle, options);
229
+ if (installed !== 0)
230
+ return installed;
231
+ return activateKits(options);
232
+ }
233
+ catch (error) {
234
+ console.error(`flow-agents init: ${error.message}`);
235
+ return 2;
236
+ }
237
+ }
238
+ if (import.meta.url === `file://${process.argv[1]}`)
239
+ process.exit(await main());
@@ -0,0 +1,93 @@
1
+ import * as fs from "node:fs";
2
+ import * as os from "node:os";
3
+ import * as path from "node:path";
4
+ const SOUL_PATH = process.env.SOUL_PATH ?? path.join(os.homedir(), ".soul");
5
+ const INSTINCTS_DIR = path.join(SOUL_PATH, "knowledge", "instincts");
6
+ function parse(file) {
7
+ const text = fs.readFileSync(file, "utf8");
8
+ if (!text.startsWith("---"))
9
+ return null;
10
+ const [, fm, body] = text.split("---", 3);
11
+ const meta = {};
12
+ for (const line of fm.trim().split(/\r?\n/)) {
13
+ const idx = line.indexOf(":");
14
+ if (idx === -1)
15
+ continue;
16
+ const key = line.slice(0, idx).trim();
17
+ const raw = line.slice(idx + 1).trim().replace(/^["']|["']$/g, "");
18
+ meta[key] = key === "confidence" ? Number(raw) : key === "observation_count" ? Number.parseInt(raw, 10) : raw;
19
+ }
20
+ meta._body = body.trim();
21
+ meta._path = file;
22
+ return meta;
23
+ }
24
+ function files() {
25
+ const roots = [path.join(INSTINCTS_DIR, "global"), path.join(INSTINCTS_DIR, "projects")];
26
+ const out = [];
27
+ for (const root of roots) {
28
+ if (!fs.existsSync(root))
29
+ continue;
30
+ const stack = [root];
31
+ while (stack.length) {
32
+ const dir = stack.pop();
33
+ for (const name of fs.readdirSync(dir)) {
34
+ const file = path.join(dir, name);
35
+ if (fs.statSync(file).isDirectory())
36
+ stack.push(file);
37
+ else if (file.endsWith(".md"))
38
+ out.push(file);
39
+ }
40
+ }
41
+ }
42
+ return out;
43
+ }
44
+ function write(inst, file) {
45
+ const body = String(inst._body ?? "");
46
+ const lines = ["---"];
47
+ for (const [key, value] of Object.entries(inst))
48
+ if (!key.startsWith("_"))
49
+ lines.push(`${key}: ${typeof value === "number" ? value : String(value)}`);
50
+ lines.push("---", "", body);
51
+ fs.mkdirSync(path.dirname(file), { recursive: true });
52
+ fs.writeFileSync(file, `${lines.join("\n").trimEnd()}\n`, "utf8");
53
+ }
54
+ export function main(argv = process.argv.slice(2)) {
55
+ const [command, ...rest] = argv;
56
+ const instincts = files().map(parse).filter((item) => Boolean(item));
57
+ if (command === "status") {
58
+ const global = instincts.filter((item) => item.scope === "global").length;
59
+ console.log(`Total instincts: ${instincts.length}`);
60
+ console.log(` Global: ${global}, Project: ${instincts.length - global}`);
61
+ return 0;
62
+ }
63
+ if (command === "list") {
64
+ for (const inst of instincts)
65
+ console.log(` [${Number(inst.confidence ?? 0).toFixed(2)}] ${inst.id ?? "?"} - ${inst.trigger ?? "?"} (${inst.scope ?? "?"})`);
66
+ return 0;
67
+ }
68
+ if (command === "show") {
69
+ const found = instincts.find((item) => item.id === rest[0]);
70
+ if (!found) {
71
+ console.error(`Instinct '${rest[0]}' not found.`);
72
+ return 1;
73
+ }
74
+ console.log(fs.readFileSync(String(found._path), "utf8"));
75
+ return 0;
76
+ }
77
+ if (command === "create") {
78
+ const id = rest[rest.indexOf("--id") + 1];
79
+ const trigger = rest[rest.indexOf("--trigger") + 1];
80
+ const domain = rest[rest.indexOf("--domain") + 1];
81
+ const scope = rest.includes("--scope") ? rest[rest.indexOf("--scope") + 1] : "project";
82
+ if (!id || !trigger || !domain)
83
+ return 2;
84
+ const file = scope === "global" ? path.join(INSTINCTS_DIR, "global", `${id}.md`) : path.join(INSTINCTS_DIR, "projects", rest[rest.indexOf("--project-id") + 1] ?? "default", "instincts", `${id}.md`);
85
+ write({ id, trigger, confidence: 0.3, domain, source: "session-observation", scope, created: new Date().toISOString().slice(0, 10), last_observed: new Date().toISOString().slice(0, 10), observation_count: 1, _body: `# ${id}\n\n## Action\nTBD` }, file);
86
+ console.log(`Created ${file}`);
87
+ return 0;
88
+ }
89
+ console.error("usage: instinct-cli <status|list|show|create>");
90
+ return 2;
91
+ }
92
+ if (import.meta.url === `file://${process.argv[1]}`)
93
+ process.exit(main());
@@ -0,0 +1,63 @@
1
+ import * as fs from "node:fs";
2
+ import * as path from "node:path";
3
+ import { parseArgs, flagString } from "../lib/args.js";
4
+ import { isoNow, relPath } from "../lib/fs.js";
5
+ function slugify(value) {
6
+ return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "") || "delivery";
7
+ }
8
+ function repoRootFor(file) {
9
+ let current = path.dirname(path.resolve(file));
10
+ for (let i = 0; i < 40; i += 1) {
11
+ if (fs.existsSync(path.join(current, ".git")) || fs.existsSync(path.join(current, "AGENTS.md")))
12
+ return current;
13
+ const parent = path.dirname(current);
14
+ if (parent === current)
15
+ break;
16
+ current = parent;
17
+ }
18
+ return process.cwd();
19
+ }
20
+ function firstHeading(text) {
21
+ return text.split(/\r?\n/).find((line) => line.startsWith("# "))?.slice(2).trim() || "Delivery";
22
+ }
23
+ function field(text, name) {
24
+ return text.match(new RegExp(`^${name}:\\s*(.+)$`, "m"))?.[1].trim() ?? "";
25
+ }
26
+ function section(text, heading) {
27
+ const match = new RegExp(`^##\\s+${heading}\\s*$`, "m").exec(text);
28
+ if (!match)
29
+ return "";
30
+ const start = match.index + match[0].length;
31
+ const rest = text.slice(start);
32
+ const next = /^##\s+/m.exec(rest);
33
+ return rest.slice(0, next ? next.index : undefined).trim();
34
+ }
35
+ export function main(argv = process.argv.slice(2)) {
36
+ const args = parseArgs(argv);
37
+ const artifact = path.resolve(args.positionals[0] ?? "");
38
+ if (!artifact || !fs.existsSync(artifact))
39
+ throw new Error(`artifact not found: ${artifact}`);
40
+ const root = repoRootFor(artifact);
41
+ const text = fs.readFileSync(artifact, "utf8");
42
+ const title = flagString(args.flags, "title") ?? firstHeading(text);
43
+ const docsDir = path.resolve(root, flagString(args.flags, "docs-dir", "docs/delivery") ?? "docs/delivery");
44
+ const date = isoNow().slice(0, 10);
45
+ const archiveBase = flagString(args.flags, "archive-dir") ? path.resolve(root, flagString(args.flags, "archive-dir") ?? "") : path.join(path.dirname(artifact), "archive");
46
+ const archive = path.join(archiveBase, date, path.basename(artifact));
47
+ const doc = path.join(docsDir, `${slugify(title)}.md`);
48
+ fs.mkdirSync(path.dirname(archive), { recursive: true });
49
+ fs.mkdirSync(path.dirname(doc), { recursive: true });
50
+ fs.copyFileSync(artifact, archive);
51
+ const pieces = ["---", `title: "${title}"`, `created: ${isoNow()}`, `source_artifact: ${relPath(root, artifact)}`, `archived_artifact: ${relPath(root, archive)}`, `delivery_status: ${field(text, "status") || "unknown"}`, "---", "", `# ${title}`, "", "This document was promoted from a delivery artifact after final acceptance.", "", "## Source", "", `- Working artifact: \`${relPath(root, artifact)}\``, `- Archived artifact: \`${relPath(root, archive)}\``, `- Status at promotion: \`${field(text, "status") || "unknown"}\``, ""];
52
+ for (const heading of ["Definition Of Done", "Plan", "Verification Report", "Goal Fit Gate", "Final Acceptance", "History"]) {
53
+ const body = section(text, heading);
54
+ if (body)
55
+ pieces.push(`## ${heading}`, "", body, "");
56
+ }
57
+ fs.writeFileSync(doc, `${pieces.join("\n").trimEnd()}\n`, "utf8");
58
+ console.log(`promoted_doc=${doc}`);
59
+ console.log(`archived_artifact=${archive}`);
60
+ return 0;
61
+ }
62
+ if (import.meta.url === `file://${process.argv[1]}`)
63
+ process.exit(main());