@kontourai/flow-agents 1.0.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/.github/workflows/ci.yml +110 -0
  2. package/.github/workflows/runtime-compat.yml +5 -2
  3. package/CHANGELOG.md +42 -0
  4. package/README.md +26 -5
  5. package/build/src/cli/console-learning-projection.js +19 -2
  6. package/build/src/cli/effective-backlog-settings.js +18 -2
  7. package/build/src/cli/fixture-retirement-audit.js +19 -2
  8. package/build/src/cli/init.js +19 -2
  9. package/build/src/cli/{flow-kit.js → kit.js} +122 -108
  10. package/build/src/cli/promote-workflow-artifact.js +19 -2
  11. package/build/src/cli/publish-change-helper.js +19 -2
  12. package/build/src/cli/pull-work-provider.js +19 -2
  13. package/build/src/cli/runtime-adapter.js +20 -2
  14. package/build/src/cli/usage-feedback.js +19 -2
  15. package/build/src/cli/utterance-check.js +19 -2
  16. package/build/src/cli/validate-hook-influence.js +19 -2
  17. package/build/src/cli/validate-source-tree.js +4 -4
  18. package/build/src/cli/veritas-governance.js +19 -2
  19. package/build/src/cli/workflow-artifact-cleanup-audit.js +19 -2
  20. package/build/src/cli.js +3 -3
  21. package/build/src/flow-kit/validate.js +58 -62
  22. package/build/src/runtime-adapters.js +55 -24
  23. package/build/src/tools/build-universal-bundles.js +83 -19
  24. package/build/src/tools/generate-context-map.js +68 -9
  25. package/build/src/tools/validate-package.js +19 -2
  26. package/build/src/tools/validate-source-tree.js +51 -3
  27. package/context/scripts/telemetry/console-presets.sh +1 -1
  28. package/docs/adr/0007-flow-skill-kit-tool-boundary.md +169 -0
  29. package/docs/adr/0007-skill-audit.md +112 -0
  30. package/docs/adr/0008-kit-operation-boundary.md +88 -0
  31. package/docs/context-map.md +18 -22
  32. package/docs/flow-kit-repository-contract.md +5 -5
  33. package/docs/getting-started.md +177 -0
  34. package/docs/index.md +19 -8
  35. package/docs/kit-authoring-guide.md +46 -10
  36. package/docs/knowledge-kit.md +2 -2
  37. package/docs/spec/runtime-hook-surface.md +1 -1
  38. package/docs/vision.md +1 -1
  39. package/docs/workflow-usage-guide.md +1 -1
  40. package/evals/ci/run-baseline.sh +55 -8
  41. package/evals/fixtures/builder-kit-workflow-state/happy-path.json +2 -2
  42. package/evals/fixtures/builder-kit-workflow-state/mid-work-resume.json +2 -2
  43. package/evals/fixtures/console-learning-projection/artifacts/console-learning-correction/learning.json +1 -1
  44. package/evals/fixtures/pull-work-provider/github-issues.json +5 -5
  45. package/evals/integration/test_activate_npx_context.sh +2 -2
  46. package/evals/integration/test_bundle_install.sh +17 -12
  47. package/evals/integration/test_console_learning_projection.sh +1 -1
  48. package/evals/integration/test_flow_kit_install_git.sh +7 -7
  49. package/evals/integration/test_flow_kit_repository.sh +4 -4
  50. package/evals/integration/test_kit_conformance_levels.sh +1 -1
  51. package/evals/integration/test_local_flow_kit_install.sh +7 -7
  52. package/evals/integration/test_publish_change_helper.sh +1 -1
  53. package/evals/integration/test_pull_work_provider.sh +1 -1
  54. package/evals/integration/test_runtime_adapter_activation.sh +140 -19
  55. package/evals/lib/node.sh +2 -2
  56. package/evals/run.sh +2 -0
  57. package/evals/static/test_console_presets.sh +49 -0
  58. package/evals/static/test_workflow_skills.sh +15 -15
  59. package/integrations/strands/flow_agents_strands/steering.py +1 -1
  60. package/integrations/strands-ts/src/hooks.ts +1 -1
  61. package/kits/builder/kit.json +17 -0
  62. package/{skills → kits/builder/skills}/builder-shape/SKILL.md +4 -4
  63. package/{skills → kits/builder/skills}/idea-to-backlog/SKILL.md +1 -1
  64. package/kits/knowledge/kit.json +16 -9
  65. package/package.json +8 -5
  66. package/packaging/packs.json +1 -21
  67. package/scripts/README.md +1 -1
  68. package/scripts/kit.js +2 -0
  69. package/scripts/telemetry/console-presets.sh +1 -1
  70. package/skills/README.md +23 -0
  71. package/src/cli/console-learning-projection.ts +7 -1
  72. package/src/cli/effective-backlog-settings.ts +6 -1
  73. package/src/cli/fixture-retirement-audit.ts +7 -1
  74. package/src/cli/init.ts +7 -1
  75. package/src/cli/{flow-kit.ts → kit.ts} +124 -109
  76. package/src/cli/promote-workflow-artifact.ts +7 -1
  77. package/src/cli/publish-change-helper.ts +7 -1
  78. package/src/cli/pull-work-provider.ts +7 -1
  79. package/src/cli/runtime-adapter.ts +8 -1
  80. package/src/cli/usage-feedback.ts +7 -1
  81. package/src/cli/utterance-check.ts +7 -1
  82. package/src/cli/validate-hook-influence.ts +7 -1
  83. package/src/cli/validate-source-tree.ts +4 -4
  84. package/src/cli/veritas-governance.ts +7 -1
  85. package/src/cli/workflow-artifact-cleanup-audit.ts +7 -1
  86. package/src/cli.ts +3 -3
  87. package/src/flow-kit/validate.ts +63 -57
  88. package/src/runtime-adapters.ts +54 -26
  89. package/src/tools/build-universal-bundles.ts +67 -14
  90. package/src/tools/generate-context-map.ts +43 -7
  91. package/src/tools/validate-package.ts +7 -1
  92. package/src/tools/validate-source-tree.ts +34 -2
  93. package/scripts/flow-kit.js +0 -2
  94. package/skills/context-budget/SKILL.md +0 -40
  95. package/skills/explore/SKILL.md +0 -137
  96. package/skills/feedback-loop/SKILL.md +0 -87
  97. package/skills/frontend-design/SKILL.md +0 -80
  98. /package/{skills → kits/builder/skills}/deliver/SKILL.md +0 -0
  99. /package/{skills → kits/builder/skills}/design-probe/SKILL.md +0 -0
  100. /package/{skills → kits/builder/skills}/evidence-gate/SKILL.md +0 -0
  101. /package/{skills → kits/builder/skills}/execute-plan/SKILL.md +0 -0
  102. /package/{skills → kits/builder/skills}/fix-bug/SKILL.md +0 -0
  103. /package/{skills → kits/builder/skills}/learning-review/SKILL.md +0 -0
  104. /package/{skills → kits/builder/skills}/pickup-probe/SKILL.md +0 -0
  105. /package/{skills → kits/builder/skills}/plan-work/SKILL.md +0 -0
  106. /package/{skills → kits/builder/skills}/pull-work/SKILL.md +0 -0
  107. /package/{skills → kits/builder/skills}/release-readiness/SKILL.md +0 -0
  108. /package/{skills → kits/builder/skills}/review-work/SKILL.md +0 -0
  109. /package/{skills → kits/builder/skills}/tdd-workflow/SKILL.md +0 -0
  110. /package/{skills → kits/builder/skills}/verify-work/SKILL.md +0 -0
  111. /package/{skills → kits/knowledge/skills}/knowledge-capture/SKILL.md +0 -0
@@ -196,6 +196,55 @@ jobs:
196
196
  continue-on-error: true
197
197
  run: bash evals/ci/run-baseline.sh --check bundle-install-integration
198
198
 
199
+ - name: Bundle lifecycle integration
200
+ continue-on-error: true
201
+ run: bash evals/ci/run-baseline.sh --check bundle-lifecycle-integration
202
+
203
+ - name: Activate npx context integration
204
+ continue-on-error: true
205
+ run: bash evals/ci/run-baseline.sh --check activate-npx-context-integration
206
+
207
+ - name: Kit conformance levels integration
208
+ continue-on-error: true
209
+ run: bash evals/ci/run-baseline.sh --check kit-conformance-levels-integration
210
+
211
+ - name: Local Flow Kit install integration
212
+ continue-on-error: true
213
+ run: bash evals/ci/run-baseline.sh --check local-flow-kit-install-integration
214
+
215
+ - name: Flow Kit install-git integration
216
+ continue-on-error: true
217
+ run: bash evals/ci/run-baseline.sh --check flow-kit-install-git-integration
218
+
219
+
220
+ - name: Context map integration
221
+ continue-on-error: true
222
+ run: bash evals/ci/run-baseline.sh --check context-map-integration
223
+
224
+ - name: Effective backlog settings integration
225
+ continue-on-error: true
226
+ run: bash evals/ci/run-baseline.sh --check effective-backlog-settings-integration
227
+
228
+ - name: Flow agents statusline integration
229
+ continue-on-error: true
230
+ run: bash evals/ci/run-baseline.sh --check flow-agents-statusline-integration
231
+
232
+ - name: Telemetry contract integration
233
+ continue-on-error: true
234
+ run: bash evals/ci/run-baseline.sh --check telemetry-contract-integration
235
+
236
+ - name: Telemetry doctor integration
237
+ continue-on-error: true
238
+ run: bash evals/ci/run-baseline.sh --check telemetry-doctor-integration
239
+
240
+ - name: Utterance check integration
241
+ continue-on-error: true
242
+ run: bash evals/ci/run-baseline.sh --check utterance-check-integration
243
+
244
+ - name: Pull work provider integration
245
+ continue-on-error: true
246
+ run: bash evals/ci/run-baseline.sh --check pull-work-provider-integration
247
+
199
248
  - name: Finalize CI evidence
200
249
  if: always()
201
250
  run: bash evals/ci/run-baseline.sh --finalize
@@ -208,3 +257,64 @@ jobs:
208
257
  path: evals/results/ci-baseline/runtime-and-kit/
209
258
  if-no-files-found: warn
210
259
  retention-days: 14
260
+
261
+ usage-feedback:
262
+ name: Usage Feedback
263
+ runs-on: ubuntu-latest
264
+ timeout-minutes: 15
265
+ env:
266
+ FLOW_AGENTS_CI_LANE: usage-feedback
267
+ FLOW_AGENTS_CI_RESULTS_DIR: evals/results/ci-baseline/usage-feedback
268
+
269
+ steps:
270
+ - name: Checkout
271
+ uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
272
+
273
+ - name: Set up Node.js
274
+ uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
275
+ with:
276
+ node-version: "22"
277
+
278
+ - name: Install Node dependencies
279
+ run: npm ci
280
+
281
+ - name: Install shell tools
282
+ run: |
283
+ sudo apt-get update
284
+ sudo apt-get install -y jq ripgrep
285
+
286
+ - name: Initialize CI evidence
287
+ run: bash evals/ci/run-baseline.sh --init
288
+
289
+ - name: Usage feedback import integration
290
+ continue-on-error: true
291
+ run: bash evals/ci/run-baseline.sh --check usage-feedback-import-integration
292
+
293
+ - name: Usage feedback outcomes integration
294
+ continue-on-error: true
295
+ run: bash evals/ci/run-baseline.sh --check usage-feedback-outcomes-integration
296
+
297
+ - name: Usage feedback report integration
298
+ continue-on-error: true
299
+ run: bash evals/ci/run-baseline.sh --check usage-feedback-report-integration
300
+
301
+ - name: Usage feedback dashboard integration
302
+ continue-on-error: true
303
+ run: bash evals/ci/run-baseline.sh --check usage-feedback-dashboard-integration
304
+
305
+ - name: Usage feedback global integration
306
+ continue-on-error: true
307
+ run: bash evals/ci/run-baseline.sh --check usage-feedback-global-integration
308
+
309
+ - name: Finalize CI evidence
310
+ if: always()
311
+ run: bash evals/ci/run-baseline.sh --finalize
312
+
313
+ - name: Upload CI evidence artifacts
314
+ if: always()
315
+ uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
316
+ with:
317
+ name: flow-agents-ci-usage-feedback
318
+ path: evals/results/ci-baseline/usage-feedback/
319
+ if-no-files-found: warn
320
+ retention-days: 14
@@ -40,7 +40,7 @@ jobs:
40
40
  uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
41
41
 
42
42
  - name: Set up Node.js
43
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
43
+ uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
44
44
  with:
45
45
  node-version: 24
46
46
 
@@ -49,6 +49,9 @@ jobs:
49
49
  ${{ matrix.install }}
50
50
  ${{ matrix.version }}
51
51
 
52
+ - name: Install dependencies
53
+ run: npm ci
54
+
52
55
  - name: Build bundles
53
56
  run: npm run build:bundles
54
57
 
@@ -67,7 +70,7 @@ jobs:
67
70
  uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
68
71
 
69
72
  - name: Set up Node.js
70
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
73
+ uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
71
74
  with:
72
75
  node-version: 24
73
76
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,47 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.2.0](https://github.com/kontourai/flow-agents/compare/v1.1.0...v1.2.0) (2026-06-15)
4
+
5
+
6
+ ### Features
7
+
8
+ * **#62:** move Builder Kit skills into kits/builder, add Knowledge Kit skill, remove orphans ([3822e07](https://github.com/kontourai/flow-agents/commit/3822e075e9cd488f46124179ebf9a8459825b9c6))
9
+ * **#62:** move Builder Kit skills into kits/builder, Knowledge Kit skill, remove orphans ([31f63ca](https://github.com/kontourai/flow-agents/commit/31f63ca18019d51438accd3b5f1e03cb5f2873f2))
10
+ * delegate container validation to @kontourai/flow; rename flow-kit → flow-agents kit ([d39e909](https://github.com/kontourai/flow-agents/commit/d39e9090dad220a8159d2148d5a1effb2460ac9f))
11
+ * delegate container validation to @kontourai/flow; rename flow-kit → flow-agents kit (ADR 0008) ([4343e84](https://github.com/kontourai/flow-agents/commit/4343e845a992858c9441258bedbbf3c7302a8532))
12
+
13
+
14
+ ### Fixes
15
+
16
+ * **ci:** install repo deps before building bundles in runtime-compat canary ([#76](https://github.com/kontourai/flow-agents/issues/76)) ([f8947aa](https://github.com/kontourai/flow-agents/commit/f8947aab5723ba9325372ea4054458ce21875bee))
17
+ * lazy-load @kontourai/flow in validate.ts so list/status/activate work without it ([99beebb](https://github.com/kontourai/flow-agents/commit/99beebb58f02dba374b35ae5e3df229cb39ea8d0))
18
+
19
+
20
+ ### Documentation
21
+
22
+ * add ADR 0007 flow/skill/kit/tool boundary + skill audit ([20b5c7b](https://github.com/kontourai/flow-agents/commit/20b5c7b272e7ad7985640e70b6be71733cec9995))
23
+ * add Builder Kit quick-start guide and update index/README Quick Start ([2e89bf0](https://github.com/kontourai/flow-agents/commit/2e89bf08968a6f45a26ceddcddf5a66bf77d3f44))
24
+ * ADR 0007 flow/skill/kit/tool boundary + skill audit ([a1dde52](https://github.com/kontourai/flow-agents/commit/a1dde52eb3b051a0eab5712395f0266c7428ae0f))
25
+ * Builder Kit quick-start guide (zero to gated build flow) ([83237f7](https://github.com/kontourai/flow-agents/commit/83237f77812917d49c86547db87986d6dbfdbfd9))
26
+ * fold orphan rulings into ADR 0007, add ADR 0008 kit-operation boundary ([d547edc](https://github.com/kontourai/flow-agents/commit/d547edc954ea9d9a12039003d41401802f994097))
27
+ * mark ADRs 0007 + 0008 Accepted (decisions reached in 2026-06-15 design conversation) ([3eb7636](https://github.com/kontourai/flow-agents/commit/3eb7636c1c4f866fd119195936ec856425573dda))
28
+
29
+ ## [1.1.0](https://github.com/kontourai/flow-agents/compare/v1.0.1...v1.1.0) (2026-06-15)
30
+
31
+
32
+ ### Features
33
+
34
+ * activate skills and docs in kit runtime adapters (fix [#58](https://github.com/kontourai/flow-agents/issues/58)) ([dc726fd](https://github.com/kontourai/flow-agents/commit/dc726fd1d56e79b5bda577985aa87befe3a1eb9d))
35
+ * activate skills and docs in kit runtime adapters (fix [#58](https://github.com/kontourai/flow-agents/issues/58)) ([dc774e0](https://github.com/kontourai/flow-agents/commit/dc774e001b54f7a09f6ab81a6aafcf2ad8552b6d))
36
+
37
+
38
+ ### Fixes
39
+
40
+ * apply realpathSync entry-guard to 7 remaining CLI/tool files ([c1b3272](https://github.com/kontourai/flow-agents/commit/c1b3272c623055662a63c5d11c6dbef5aabe1cf0))
41
+ * apply realpathSync entry-guard to all 16 affected CLI/tool files (closes [#71](https://github.com/kontourai/flow-agents/issues/71)) ([8a676b0](https://github.com/kontourai/flow-agents/commit/8a676b0c9c91464d64755719ff778a13e298beb9))
42
+ * apply realpathSync entry-guard to remaining 10 CLI/tool files ([159bb78](https://github.com/kontourai/flow-agents/commit/159bb785b6b28f99b0a3a5c95e0d4428512f4314))
43
+ * use hosted console io preset ([5b4bb7b](https://github.com/kontourai/flow-agents/commit/5b4bb7bc86d154bcf4d529a62e398a2196b702cc))
44
+
3
45
  ## [1.0.1](https://github.com/kontourai/flow-agents/compare/v1.0.0...v1.0.1) (2026-06-12)
4
46
 
5
47
 
package/README.md CHANGED
@@ -99,21 +99,42 @@ bash install.sh /path/to/workspace --telemetry-sink local-kontour-console
99
99
 
100
100
  ## Use it
101
101
 
102
- After installing, ask the agent for the workflow you want — in plain language:
102
+ After installing, ask the agent for the workflow you want — in plain language.
103
+
104
+ ### Builder Kit quick start
105
+
106
+ The Builder Kit installs automatically and gives your agent two gated flows: `builder.shape` turns a raw idea into slices and executable work items; `builder.build` takes a selected work item through design probe, planning, execution, verification, PR readiness, merge readiness, and learning.
107
+
108
+ Shape an idea:
109
+
110
+ ```text
111
+ Use Builder Kit shape. I want to add a progress indicator to the CLI output
112
+ so users can see what step the installer is on. Shape this into an executable
113
+ work item and stop at the backlog gate.
114
+ ```
115
+
116
+ Build it:
103
117
 
104
118
  ```text
105
- Use Builder Kit shape for this feature idea and create executable GitHub issues.
119
+ Use deliver for the issue you just filed. Pull it, probe the design, plan it,
120
+ implement it, verify it, and stop if any evidence is missing.
106
121
  ```
107
122
 
123
+ Each step has an evidence gate. The agent either presents the expected evidence and advances, or blocks and explains what is missing — it does not produce a confident summary and proceed on partial work. Session state is written to `.flow-agents/<slug>/` and survives context loss or compaction.
124
+
125
+ For a full walkthrough — what each gate checks, what you observe, and how to invoke individual skills — read the [Builder Kit Quick Start](docs/getting-started.md).
126
+
127
+ For bugs:
128
+
108
129
  ```text
109
- Use deliver for this issue. Plan it, execute it, verify it, and stop if evidence is missing.
130
+ Use fix-bug. Reproduce the problem, diagnose root cause, implement the fix, and verify the regression path.
110
131
  ```
111
132
 
112
133
  The [Workflow Usage Guide](docs/workflow-usage-guide.md) has example prompts and expected behavior for every stage — `pull-work`, `plan-work`, `execute-plan`, `review-work`, `verify-work`, `fix-bug`, `release-readiness`, and more. The [Agent System Guidebook](docs/agent-system-guidebook.md) is the plain-language map of how the pieces fit.
113
134
 
114
135
  ## Flow Kits
115
136
 
116
- A Flow Kit bundles a workflow AND its opinionated output shape into a single validated unit: a `kit.json` manifest (schema version 1.0), one or more Flow Definitions, and optional skills, docs, adapters, evals, and assets. Authoring a kit means deciding not just _what_ an agent does but _how the result is rendered_ — the same pipeline produces different representations depending on which store adapter is active. Kits are the extension model for Flow Agents: validated by the `flow-kit` CLI, installed through a single command, and activatable into any workspace that runs Flow Agents.
137
+ A Flow Kit bundles a workflow AND its opinionated output shape into a single validated unit: a `kit.json` manifest (schema version 1.0), one or more Flow Definitions, and optional skills, docs, adapters, evals, and assets. Authoring a kit means deciding not just _what_ an agent does but _how the result is rendered_ — the same pipeline produces different representations depending on which store adapter is active. Kits are the extension model for Flow Agents: validated and installed through the `flow-agents kit` CLI, and activatable into any workspace that runs Flow Agents.
117
138
 
118
139
  **Builder Kit** — ships with `builder.shape` (shape a problem into slices and fileable work items) and `builder.build` (pull ready work through design probing, planning, execution, verification, PR readiness, merge readiness, and learning). Installed automatically by `npx @kontourai/flow-agents init`.
119
140
 
@@ -126,7 +147,7 @@ The Knowledge Kit is also LIVE-proven: the default adapter passes the parameteri
126
147
  Install a local kit:
127
148
 
128
149
  ```bash
129
- npx @kontourai/flow-agents flow-kit install-local path/to/my-kit --dest /path/to/workspace
150
+ npx @kontourai/flow-agents kit install path/to/my-kit --dest /path/to/workspace
130
151
  ```
131
152
 
132
153
  - [Kit Authoring Guide](docs/kit-authoring-guide.md) — build your own kit from scratch: directory layout, `kit.json`, a flow file, validation, install, and activation.
@@ -1,4 +1,5 @@
1
1
  import * as fs from "node:fs";
2
+ import { fileURLToPath } from "node:url";
2
3
  import * as path from "node:path";
3
4
  import { flagBool, flagString, parseArgs } from "../lib/args.js";
4
5
  import { buildWorkflowLearningProjection, readWorkflowLearningSources } from "../lib/workflow-learning-projection.js";
@@ -119,5 +120,21 @@ export function main(argv = process.argv.slice(2)) {
119
120
  return 1;
120
121
  }
121
122
  }
122
- if (import.meta.url === `file://${process.argv[1]}`)
123
- process.exit(main());
123
+ // Use process.exitCode (not process.exit) to allow stdout to be flushed before exit.
124
+ // Resolve real paths to handle symlinks (e.g. /tmp -> /private/tmp on macOS) so the
125
+ // entry-point guard fires correctly when the module is loaded directly as a script.
126
+ const _selfRealPath = (() => { try {
127
+ return fs.realpathSync(fileURLToPath(import.meta.url));
128
+ }
129
+ catch {
130
+ return fileURLToPath(import.meta.url);
131
+ } })();
132
+ const _argv1RealPath = (() => { try {
133
+ return fs.realpathSync(process.argv[1]);
134
+ }
135
+ catch {
136
+ return process.argv[1];
137
+ } })();
138
+ if (_selfRealPath === _argv1RealPath) {
139
+ process.exitCode = main();
140
+ }
@@ -98,5 +98,21 @@ export function main(argv = process.argv.slice(2)) {
98
98
  return 1;
99
99
  }
100
100
  }
101
- if (import.meta.url === `file://${process.argv[1]}`)
102
- process.exit(main());
101
+ // Use process.exitCode (not process.exit) to allow stdout to be flushed before exit.
102
+ // Resolve real paths to handle symlinks (e.g. /tmp -> /private/tmp on macOS) so the
103
+ // entry-point guard fires correctly when the module is loaded directly as a script.
104
+ const _selfRealPath = (() => { try {
105
+ return fs.realpathSync(fileURLToPath(import.meta.url));
106
+ }
107
+ catch {
108
+ return fileURLToPath(import.meta.url);
109
+ } })();
110
+ const _argv1RealPath = (() => { try {
111
+ return fs.realpathSync(process.argv[1]);
112
+ }
113
+ catch {
114
+ return process.argv[1];
115
+ } })();
116
+ if (_selfRealPath === _argv1RealPath) {
117
+ process.exitCode = main();
118
+ }
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import * as fs from "node:fs";
3
+ import { fileURLToPath } from "node:url";
3
4
  import * as path from "node:path";
4
5
  const root = path.resolve(".");
5
6
  const fixtureRoot = "evals/fixtures";
@@ -136,5 +137,21 @@ export function main(argv = process.argv.slice(2)) {
136
137
  return 1;
137
138
  }
138
139
  }
139
- if (import.meta.url === `file://${process.argv[1]}`)
140
- process.exit(main());
140
+ // Use process.exitCode (not process.exit) to allow stdout to be flushed before exit.
141
+ // Resolve real paths to handle symlinks (e.g. /tmp -> /private/tmp on macOS) so the
142
+ // entry-point guard fires correctly when the module is loaded directly as a script.
143
+ const _selfRealPath = (() => { try {
144
+ return fs.realpathSync(fileURLToPath(import.meta.url));
145
+ }
146
+ catch {
147
+ return fileURLToPath(import.meta.url);
148
+ } })();
149
+ const _argv1RealPath = (() => { try {
150
+ return fs.realpathSync(process.argv[1]);
151
+ }
152
+ catch {
153
+ return process.argv[1];
154
+ } })();
155
+ if (_selfRealPath === _argv1RealPath) {
156
+ process.exitCode = main();
157
+ }
@@ -1,5 +1,6 @@
1
1
  import { spawnSync } from "node:child_process";
2
2
  import * as fs from "node:fs";
3
+ import { fileURLToPath } from "node:url";
3
4
  import * as os from "node:os";
4
5
  import * as path from "node:path";
5
6
  import { createInterface } from "node:readline/promises";
@@ -445,5 +446,21 @@ export async function mainDogfood(argv = process.argv.slice(2)) {
445
446
  return 2;
446
447
  }
447
448
  }
448
- if (import.meta.url === `file://${process.argv[1]}`)
449
- process.exit(await main());
449
+ // Use process.exitCode (not process.exit) to allow stdout to be flushed before exit.
450
+ // Resolve real paths to handle symlinks (e.g. /tmp -> /private/tmp on macOS) so the
451
+ // entry-point guard fires correctly when the module is loaded directly as a script.
452
+ const _selfRealPath = (() => { try {
453
+ return fs.realpathSync(fileURLToPath(import.meta.url));
454
+ }
455
+ catch {
456
+ return fileURLToPath(import.meta.url);
457
+ } })();
458
+ const _argv1RealPath = (() => { try {
459
+ return fs.realpathSync(process.argv[1]);
460
+ }
461
+ catch {
462
+ return process.argv[1];
463
+ } })();
464
+ if (_selfRealPath === _argv1RealPath) {
465
+ process.exitCode = await main();
466
+ }
@@ -30,7 +30,7 @@ function contentHash(root) {
30
30
  }
31
31
  return `sha256:${hash.digest("hex")}`;
32
32
  }
33
- /** Content hash that excludes .git and other VCS/cache directories (for install-git clones). */
33
+ /** Content hash that excludes .git and other VCS/cache directories (for install git clones). */
34
34
  function kitContentHash(root) {
35
35
  const EXCLUDE_DIRS = new Set([".git", "__pycache__", ".pytest_cache"]);
36
36
  const hash = crypto.createHash("sha256");
@@ -46,13 +46,37 @@ function kitContentHash(root) {
46
46
  }
47
47
  return `sha256:${hash.digest("hex")}`;
48
48
  }
49
- function installLocal(argv) {
49
+ /**
50
+ * install <source> [--dest <path>] [--force] [--update] [--ref <branch|tag|sha>]
51
+ *
52
+ * Installs a Flow Kit from a local path or a git URL.
53
+ *
54
+ * - Local path: validates then copies the kit into the destination registry.
55
+ * - Git URL (http://, https://, git+, ssh://, file://): shallow-clones the repository,
56
+ * validates the kit container with @kontourai/flow, then delegates to the install path.
57
+ * Supports an optional #ref fragment in the URL or a separate --ref flag.
58
+ */
59
+ async function install(argv) {
60
+ const args = parseArgs(argv);
61
+ const source = args.positionals[0] ?? "";
62
+ if (!source) {
63
+ console.error("install: missing <source> argument");
64
+ console.error("usage: flow-agents kit install <path-or-git-url> [--dest <path>] [--ref <ref>] [--force] [--update]");
65
+ return 2;
66
+ }
67
+ // Detect git URL: starts with http(s)://, git+, ssh://, file://, or ends with .git
68
+ const isGitUrl = /^(https?:\/\/|git\+|ssh:\/\/|file:\/\/)/.test(source) || source.endsWith(".git");
69
+ if (isGitUrl) {
70
+ return await installGitSource(source, argv);
71
+ }
72
+ return await installLocalSource(path.resolve(source), argv);
73
+ }
74
+ async function installLocalSource(source, argv) {
50
75
  const args = parseArgs(argv);
51
- const source = path.resolve(args.positionals[0] ?? "");
52
76
  const dest = path.resolve(flagString(args.flags, "dest", ".") ?? ".");
53
77
  let manifest;
54
78
  try {
55
- manifest = assertKitRepository(source);
79
+ manifest = await assertKitRepository(source);
56
80
  }
57
81
  catch (error) {
58
82
  console.log("Flow Kit repository validation failed:");
@@ -91,6 +115,86 @@ function installLocal(argv) {
91
115
  console.log(`${existing ? "updated" : "installed"} local kit '${kitId}' at ${target}`);
92
116
  return 0;
93
117
  }
118
+ async function installGitSource(rawUrl, argv) {
119
+ const args = parseArgs(argv);
120
+ // Parse ref: #fragment in URL takes precedence over --ref flag.
121
+ let repoUrl = rawUrl;
122
+ let ref = null;
123
+ const hashIdx = rawUrl.indexOf("#");
124
+ if (hashIdx !== -1) {
125
+ repoUrl = rawUrl.slice(0, hashIdx);
126
+ ref = rawUrl.slice(hashIdx + 1) || null;
127
+ }
128
+ if (!ref)
129
+ ref = flagString(args.flags, "ref") ?? null;
130
+ const dest = path.resolve(flagString(args.flags, "dest", ".") ?? ".");
131
+ const force = flagBool(args.flags, "force") ?? false;
132
+ const update = flagBool(args.flags, "update") ?? false;
133
+ // Shallow-clone into a temporary directory.
134
+ const tmpBase = fs.mkdtempSync(path.join(os.tmpdir(), "flow-kit-git-"));
135
+ try {
136
+ const cloneArgs = ["clone", "--depth", "1"];
137
+ if (ref)
138
+ cloneArgs.push("--branch", ref);
139
+ cloneArgs.push("--", repoUrl, tmpBase);
140
+ try {
141
+ child_process.execFileSync("git", cloneArgs, { stdio: ["ignore", "pipe", "pipe"] });
142
+ }
143
+ catch (err) {
144
+ const msg = err instanceof Error && err.stderr
145
+ ? err.stderr.toString().trim()
146
+ : String(err);
147
+ console.error(`install: git clone failed: ${msg}`);
148
+ return 1;
149
+ }
150
+ // Validate the cloned kit using the same logic as install local.
151
+ let manifest;
152
+ try {
153
+ manifest = await assertKitRepository(tmpBase);
154
+ }
155
+ catch (error) {
156
+ console.log("Flow Kit repository validation failed:");
157
+ for (const diagnostic of (error.diagnostics ?? [error.message])) {
158
+ console.log(` - ${diagnostic}`);
159
+ }
160
+ return 1;
161
+ }
162
+ // Delegate to the shared install logic (copy + registry update).
163
+ const kitId = String(manifest.id);
164
+ const hash = kitContentHash(tmpBase);
165
+ const registry = loadRegistry(dest);
166
+ const existing = registry.kits.find((entry) => entry.id === kitId);
167
+ const target = installedPath(dest, kitId);
168
+ assertPathContained(dest, target);
169
+ const sourceText = repoUrl + (ref ? `#${ref}` : "");
170
+ if (existing && existing.source !== sourceText && !update) {
171
+ console.log(`conflict: kit '${kitId}' is already installed from ${existing.source}; rerun with --update to replace it`);
172
+ return 2;
173
+ }
174
+ if (existing && existing.source === sourceText && existing.hash === hash && fs.existsSync(target) && !force) {
175
+ console.log(`kit '${kitId}' is already installed from ${sourceText}`);
176
+ return 0;
177
+ }
178
+ copyDir(tmpBase, target);
179
+ const entry = {
180
+ id: kitId,
181
+ source: sourceText,
182
+ hash,
183
+ installed_at: existing && existing.source === sourceText && !update ? existing.installed_at : isoNow(),
184
+ installed_path: target,
185
+ state: "installed",
186
+ };
187
+ if (typeof manifest.version === "string" && manifest.version)
188
+ entry.version = manifest.version;
189
+ registry.kits = existing ? registry.kits.map((item) => item.id === kitId ? entry : item) : [...registry.kits, entry];
190
+ writeJson(registryPath(dest), registry);
191
+ console.log(`${existing ? "updated" : "installed"} git kit '${kitId}' from ${sourceText} at ${target}`);
192
+ return 0;
193
+ }
194
+ finally {
195
+ fs.rmSync(tmpBase, { recursive: true, force: true });
196
+ }
197
+ }
94
198
  function list(argv) {
95
199
  const args = parseArgs(argv);
96
200
  const dest = path.resolve(flagString(args.flags, "dest", ".") ?? ".");
@@ -147,7 +251,8 @@ function activate(argv) {
147
251
  * inspect <kit-dir> [--json]
148
252
  *
149
253
  * Derives conformance level (K0/K1/K2) and consumer targets from a kit's
150
- * observable asset classes. Exits 1 if the kit fails core container validation.
254
+ * observable asset classes. Delegates core container validation to @kontourai/flow.
255
+ * Exits 1 if the kit fails core container validation.
151
256
  * Outputs stable JSON suitable for use by catalog tooling and CI.
152
257
  *
153
258
  * K-levels (issue #52):
@@ -160,7 +265,7 @@ function activate(argv) {
160
265
  * flow-agents present at K1+ (Flow Agents extension activated)
161
266
  * <namespace> unknown top-level keys list verbatim as third-party consumer targets
162
267
  */
163
- function inspect(argv) {
268
+ async function inspect(argv) {
164
269
  const args = parseArgs(argv);
165
270
  const kitDir = path.resolve(args.positionals[0] ?? ".");
166
271
  const manifestPath = path.join(kitDir, "kit.json");
@@ -176,111 +281,20 @@ function inspect(argv) {
176
281
  console.error(`inspect: invalid JSON in ${manifestPath}: ${err.message}`);
177
282
  return 1;
178
283
  }
179
- const result = deriveKitTargets(manifest);
284
+ // Pass the real kitDir so @kontourai/flow can validate flow file existence for K0.
285
+ const result = await deriveKitTargets(manifest, kitDir);
180
286
  console.log(JSON.stringify(result, null, 2));
181
287
  return result.conformance.k0 ? 0 : 1;
182
288
  }
183
- /**
184
- * install-git <repo-url>[#ref] [--ref <branch|tag|sha>] [--dest <path>] [--force] [--update]
185
- *
186
- * Shallow-clones a remote git repository to a temporary directory, validates the kit
187
- * container with the same logic used by install-local, then delegates to the existing
188
- * install path. Supports an optional #ref fragment in the URL or a separate --ref flag.
189
- *
190
- * Implements kontourai/flow-agents#56 (git-ref install surface).
191
- */
192
- function installGit(argv) {
193
- const args = parseArgs(argv);
194
- const rawUrl = args.positionals[0] ?? "";
195
- if (!rawUrl) {
196
- console.error("install-git: missing <repo-url> argument");
197
- console.error("usage: flow-kit install-git <repo-url>[#ref] [--ref <branch|tag|sha>] [--dest <path>]");
198
- return 2;
199
- }
200
- // Parse ref: #fragment in URL takes precedence over --ref flag.
201
- let repoUrl = rawUrl;
202
- let ref = null;
203
- const hashIdx = rawUrl.indexOf("#");
204
- if (hashIdx !== -1) {
205
- repoUrl = rawUrl.slice(0, hashIdx);
206
- ref = rawUrl.slice(hashIdx + 1) || null;
207
- }
208
- if (!ref)
209
- ref = flagString(args.flags, "ref") ?? null;
210
- const dest = path.resolve(flagString(args.flags, "dest", ".") ?? ".");
211
- const force = flagBool(args.flags, "force") ?? false;
212
- const update = flagBool(args.flags, "update") ?? false;
213
- // Shallow-clone into a temporary directory.
214
- const tmpBase = fs.mkdtempSync(path.join(os.tmpdir(), "flow-kit-git-"));
215
- try {
216
- const cloneArgs = ["clone", "--depth", "1"];
217
- if (ref)
218
- cloneArgs.push("--branch", ref);
219
- cloneArgs.push("--", repoUrl, tmpBase);
220
- try {
221
- child_process.execFileSync("git", cloneArgs, { stdio: ["ignore", "pipe", "pipe"] });
222
- }
223
- catch (err) {
224
- const msg = err instanceof Error && err.stderr
225
- ? err.stderr.toString().trim()
226
- : String(err);
227
- console.error(`install-git: git clone failed: ${msg}`);
228
- return 1;
229
- }
230
- // Validate the cloned kit using the same logic as install-local.
231
- let manifest;
232
- try {
233
- manifest = assertKitRepository(tmpBase);
234
- }
235
- catch (error) {
236
- console.log("Flow Kit repository validation failed:");
237
- for (const diagnostic of (error.diagnostics ?? [error.message])) {
238
- console.log(` - ${diagnostic}`);
239
- }
240
- return 1;
241
- }
242
- // Delegate to the shared install logic (copy + registry update).
243
- const kitId = String(manifest.id);
244
- const hash = kitContentHash(tmpBase);
245
- const registry = loadRegistry(dest);
246
- const existing = registry.kits.find((entry) => entry.id === kitId);
247
- const target = installedPath(dest, kitId);
248
- assertPathContained(dest, target);
249
- const sourceText = repoUrl + (ref ? `#${ref}` : "");
250
- if (existing && existing.source !== sourceText && !update) {
251
- console.log(`conflict: kit '${kitId}' is already installed from ${existing.source}; rerun with --update to replace it`);
252
- return 2;
253
- }
254
- if (existing && existing.source === sourceText && existing.hash === hash && fs.existsSync(target) && !force) {
255
- console.log(`kit '${kitId}' is already installed from ${sourceText}`);
256
- return 0;
257
- }
258
- copyDir(tmpBase, target);
259
- const entry = {
260
- id: kitId,
261
- source: sourceText,
262
- hash,
263
- installed_at: existing && existing.source === sourceText && !update ? existing.installed_at : isoNow(),
264
- installed_path: target,
265
- state: "installed",
266
- };
267
- if (typeof manifest.version === "string" && manifest.version)
268
- entry.version = manifest.version;
269
- registry.kits = existing ? registry.kits.map((item) => item.id === kitId ? entry : item) : [...registry.kits, entry];
270
- writeJson(registryPath(dest), registry);
271
- console.log(`${existing ? "updated" : "installed"} git kit '${kitId}' from ${sourceText} at ${target}`);
272
- return 0;
273
- }
274
- finally {
275
- fs.rmSync(tmpBase, { recursive: true, force: true });
276
- }
277
- }
278
- export function main(argv = process.argv.slice(2)) {
289
+ export async function main(argv = process.argv.slice(2)) {
279
290
  const [command, ...rest] = argv;
291
+ if (command === "install")
292
+ return await install(rest);
293
+ // Legacy sub-subcommands forwarded for backward compatibility within the kit subcommand.
280
294
  if (command === "install-local")
281
- return installLocal(rest);
295
+ return await installLocalSource(path.resolve(rest[0] ?? ""), rest);
282
296
  if (command === "install-git")
283
- return installGit(rest);
297
+ return await installGitSource(rest[0] ?? "", rest);
284
298
  if (command === "list")
285
299
  return list(rest);
286
300
  if (command === "status")
@@ -288,8 +302,8 @@ export function main(argv = process.argv.slice(2)) {
288
302
  if (command === "activate")
289
303
  return activate(rest);
290
304
  if (command === "inspect")
291
- return inspect(rest);
292
- console.error("usage: flow-kit <install-local|install-git|list|status|activate|inspect> ...");
305
+ return await inspect(rest);
306
+ console.error("usage: flow-agents kit <install|activate|inspect|list|status> ...");
293
307
  return 2;
294
308
  }
295
309
  // Use process.exitCode (not process.exit) to allow stdout to be flushed before exit.
@@ -308,5 +322,5 @@ catch {
308
322
  return process.argv[1];
309
323
  } })();
310
324
  if (_selfRealPath === _argv1RealPath) {
311
- process.exitCode = main();
325
+ main().then((code) => { process.exitCode = code; }).catch((err) => { console.error(err); process.exitCode = 1; });
312
326
  }