akm-cli 0.9.30 → 0.10.26101001-alpha
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.
- package/CHANGELOG.md +282 -0
- package/README.md +10 -10
- package/ROADMAP.md +112 -0
- package/STABILITY.md +79 -53
- package/dist/api-node.mjs +20 -0
- package/dist/api.d.ts +23 -0
- package/dist/api.js +45 -0
- package/dist/assets/hints/cli-hints-full.md +13 -27
- package/dist/assets/hints/cli-hints-short.md +1 -1
- package/dist/assets/improve-strategies/default.json +3 -3
- package/dist/assets/prompts/consolidate-pair.md +9 -7
- package/dist/cli/shared.js +31 -48
- package/dist/cli/unknown-flags.js +6 -43
- package/dist/cli.js +8 -34
- package/dist/commands/agent/contribute-cli.js +1 -1
- package/dist/commands/completions.js +1 -2
- package/dist/commands/config-cli.js +5 -28
- package/dist/commands/env/env-cli.js +5 -5
- package/dist/commands/env/secret-cli.js +2 -2
- package/dist/commands/health/checks.js +41 -16
- package/dist/commands/health/plugin-staleness.js +52 -22
- package/dist/commands/improve/autonomy-gate.js +5 -3
- package/dist/commands/improve/consolidate/pair-pass.js +7 -1
- package/dist/commands/improve/consolidate.js +6 -35
- package/dist/commands/improve/distill/lesson-update.js +91 -0
- package/dist/commands/improve/distill-guards.js +1 -43
- package/dist/commands/improve/distill.js +140 -20
- package/dist/commands/improve/extract-cli.js +1 -1
- package/dist/commands/improve/improve-cli.js +120 -114
- package/dist/commands/improve/improve-strategies.js +8 -12
- package/dist/commands/improve/loop-stages.js +0 -1
- package/dist/commands/improve/planner.js +0 -1
- package/dist/commands/improve/preparation.js +40 -99
- package/dist/commands/improve/proactive-maintenance.js +2 -2
- package/dist/commands/improve/reflect-noise.js +3 -55
- package/dist/commands/improve/reflect.js +3 -8
- package/dist/commands/improve/retrieval-scope.js +2 -2
- package/dist/commands/improve/salience.js +2 -9
- package/dist/commands/improve/stage.js +14 -9
- package/dist/commands/lint/index.js +5 -20
- package/dist/commands/observability-cli.js +3 -9
- package/dist/commands/proposal/drain.js +39 -6
- package/dist/commands/proposal/proposal-cli.js +10 -30
- package/dist/commands/proposal/repository.js +3 -3
- package/dist/commands/read/knowledge.js +3 -3
- package/dist/commands/read/remember-cli.js +0 -13
- package/dist/commands/read/search-cli.js +29 -97
- package/dist/commands/read/search.js +0 -11
- package/dist/commands/read/show.js +0 -19
- package/dist/commands/sources/plugin-upgrade.js +164 -101
- package/dist/commands/sources/sources-cli.js +1 -15
- package/dist/commands/sources/stash-cli.js +4 -12
- package/dist/commands/tasks/tasks-cli.js +4 -115
- package/dist/commands/workflow/plan.js +11 -33
- package/dist/commands/workflow-cli.js +2 -7
- package/dist/core/adapter/adapter-ids.js +1 -2
- package/dist/core/adapter/adapters/agent-skills-adapter.js +0 -4
- package/dist/core/adapter/adapters/akm-adapter.js +9 -48
- package/dist/core/adapter/adapters/akm-lint.js +10 -26
- package/dist/core/adapter/adapters/akm-metadata.js +2 -72
- package/dist/core/adapter/adapters/akm-task-adapter.js +0 -5
- package/dist/core/adapter/adapters/akm-workflow-adapter.js +9 -28
- package/dist/core/adapter/adapters/dotenv-adapter.js +1 -20
- package/dist/core/adapter/adapters/generic-files-adapter.js +0 -10
- package/dist/core/adapter/adapters/llm-wiki-adapter.js +0 -4
- package/dist/core/adapter/adapters/tool-dir-shared.js +0 -24
- package/dist/core/adapter/adapters/website-snapshot-adapter.js +4 -4
- package/dist/core/adapter/recognize-match.js +3 -4
- package/dist/core/common.js +18 -2
- package/dist/core/config/config-schema.js +12 -15
- package/dist/core/config/config-types.js +6 -15
- package/dist/core/config/config-walker.js +6 -23
- package/dist/core/config/config.js +17 -80
- package/dist/core/config/engine-semantics.js +7 -3
- package/dist/core/config/schema/engines.js +7 -7
- package/dist/core/config/schema/improve-processes.js +8 -61
- package/dist/core/config/schema/improve.js +2 -21
- package/dist/core/config/schema/index-config.js +6 -39
- package/dist/core/env-secret-ref.js +2 -45
- package/dist/core/errors.js +1 -2
- package/dist/core/extra-params.js +2 -86
- package/dist/core/file-lock.js +10 -1
- package/dist/core/improve-result.js +11 -1
- package/dist/core/mutation-target.js +2 -2
- package/dist/core/recognition-util.js +4 -5
- package/dist/core/warn.js +21 -4
- package/dist/core/write-source.js +3 -3
- package/dist/execution/target-ref.js +1 -2
- package/dist/indexer/search/db-search.js +4 -19
- package/dist/indexer/search/fts-query.js +0 -19
- package/dist/integrations/agent/engine-resolution.js +5 -2
- package/dist/integrations/agent/index.js +1 -1
- package/dist/integrations/agent/profiles.js +41 -98
- package/dist/integrations/agent/request-lowering.js +3 -3
- package/dist/integrations/harnesses/aider/index.js +5 -0
- package/dist/integrations/harnesses/amazonq/index.js +1 -0
- package/dist/integrations/harnesses/claude/config-import.js +2 -3
- package/dist/integrations/harnesses/claude/index.js +5 -0
- package/dist/integrations/harnesses/codex/index.js +1 -0
- package/dist/integrations/harnesses/copilot/index.js +1 -0
- package/dist/integrations/harnesses/gemini/index.js +1 -0
- package/dist/integrations/harnesses/index.js +18 -39
- package/dist/integrations/harnesses/opencode/agent-builder.js +60 -35
- package/dist/integrations/harnesses/opencode/config-import.js +121 -52
- package/dist/integrations/harnesses/opencode/index.js +22 -0
- package/dist/integrations/harnesses/opencode/plugin-layout.js +68 -0
- package/dist/integrations/harnesses/opencode/session-log-types.js +12 -0
- package/dist/integrations/harnesses/opencode/session-log-v1.js +72 -0
- package/dist/integrations/harnesses/opencode/session-log-v2.js +140 -0
- package/dist/integrations/harnesses/opencode/session-log.js +104 -115
- package/dist/integrations/harnesses/opencode/version.js +98 -0
- package/dist/integrations/harnesses/opencode-sdk/{harness.js → index.js} +5 -17
- package/dist/integrations/harnesses/opencode-sdk/sdk-runner.js +105 -206
- package/dist/integrations/harnesses/opencode-sdk/v1-adapter.js +199 -0
- package/dist/integrations/harnesses/opencode-sdk/v2-adapter.js +228 -0
- package/dist/integrations/harnesses/opencode-sdk/wire.js +66 -0
- package/dist/integrations/harnesses/openhands/index.js +1 -0
- package/dist/integrations/harnesses/pi/index.js +1 -0
- package/dist/integrations/harnesses/shared.js +2 -0
- package/dist/integrations/harnesses/types.js +2 -0
- package/dist/llm/client.js +74 -14
- package/dist/output/cli-hints.js +1 -1
- package/dist/output/context.js +10 -19
- package/dist/output/format-exempt.js +5 -8
- package/dist/output/shapes/helpers.js +1 -22
- package/dist/output/shapes/passthrough.js +0 -1
- package/dist/output/shapes.js +3 -31
- package/dist/output/stdout.js +5 -1
- package/dist/output/text/command-format.js +6 -1
- package/dist/output/text/workflow-format.js +4 -22
- package/dist/scripts/akm-migrate-node.js +15746 -16706
- package/dist/scripts/akm-migrate.js +16319 -17275
- package/dist/setup/detect.js +10 -4
- package/dist/setup/harness-config-import.js +5 -14
- package/dist/setup/setup.js +1 -1
- package/dist/setup/steps/tasks.js +12 -13
- package/dist/storage/repositories/task-history-repository.js +0 -5
- package/dist/storage/repositories/workflow-runs-repository.js +5 -15
- package/dist/tasks/embedded.js +2 -1
- package/dist/tasks/run/task-history.js +0 -2
- package/dist/tasks/schedule-gates.js +39 -0
- package/dist/tasks/scheduler-binding.js +0 -16
- package/dist/tasks/scheduler-sync.js +3 -97
- package/dist/tasks/source/bounded-document.js +1 -1
- package/dist/tasks/source/task-source-v4.js +2 -12
- package/dist/tasks/task-run-reserved-flags.js +2 -31
- package/dist/workflows/authoring/authoring.js +6 -6
- package/dist/workflows/compile.js +8 -65
- package/dist/workflows/exec/child-workflow.js +22 -3
- package/dist/workflows/exec/native-executor.js +12 -147
- package/dist/workflows/exec/run-workflow.js +31 -103
- package/dist/workflows/exec/step-work.js +9 -178
- package/dist/workflows/exec/unit-dispatch.js +0 -10
- package/dist/workflows/freeze/environment.js +3 -44
- package/dist/workflows/freeze/freeze.js +8 -41
- package/dist/workflows/freeze/targets/child-workflow.js +27 -63
- package/dist/workflows/freeze/targets/command.js +2 -16
- package/dist/workflows/freeze/targets/shell.js +0 -2
- package/dist/workflows/freeze/task-bindings.js +2 -28
- package/dist/workflows/ir/params.js +12 -2
- package/dist/workflows/parser.js +82 -232
- package/dist/workflows/plan.js +1 -1
- package/dist/workflows/renderer.js +10 -19
- package/dist/workflows/runtime/run-plan.js +11 -53
- package/dist/workflows/runtime/runs.js +4 -27
- package/dist/workflows/source-files.js +12 -16
- package/dist/workflows/source-semantics.js +1 -93
- package/docs/README.md +43 -42
- package/docs/agents/README.md +15 -0
- package/docs/agents/agent-install.md +14 -0
- package/docs/architecture/README.md +67 -0
- package/docs/architecture/adapters.md +258 -0
- package/docs/architecture/akm-architecture-decision-history.md +2055 -0
- package/docs/architecture/akm-core-principles.md +126 -0
- package/docs/architecture/architecture.md +578 -0
- package/docs/architecture/comparisons/claude-code-vs-akm-workflows-full.md +550 -0
- package/docs/architecture/decisions/0001-no-interpolation-attached-structured-context.md +72 -0
- package/docs/architecture/decisions/0002-unit-reuse-and-input-hash-scope.md +142 -0
- package/docs/architecture/decisions/0003-child-env-allowlist-and-provenance.md +189 -0
- package/docs/architecture/decisions/0004-task-input-contract-and-flag-coercion.md +97 -0
- package/docs/architecture/decisions/0005-task-result-vocabulary-and-legacy-read-mapping.md +108 -0
- package/docs/architecture/decisions/0006-task-source-version-routing.md +124 -0
- package/docs/architecture/decisions/0007-workflow-composition-bounds.md +83 -0
- package/docs/architecture/decisions/0008-task-binding-normalization.md +88 -0
- package/docs/architecture/decisions/0009-child-run-publication-column-parity.md +80 -0
- package/docs/architecture/decisions/0010-driver-protocol-cut.md +36 -0
- package/docs/architecture/decisions/0011-engine-run-loop-invariants.md +125 -0
- package/docs/architecture/decisions/README.md +62 -0
- package/docs/architecture/improvement.md +471 -0
- package/docs/architecture/internals/classification.md +154 -0
- package/docs/architecture/internals/fresh-host-rebuild-runbook.md +40 -0
- package/docs/architecture/internals/functional-contract-patterns.md +340 -0
- package/docs/architecture/internals/health-advisories.md +110 -0
- package/docs/architecture/internals/improve-workflow.md +720 -0
- package/docs/architecture/internals/indexing.md +498 -0
- package/docs/architecture/internals/registry-network-boundary.md +57 -0
- package/docs/architecture/internals/search.md +248 -0
- package/docs/architecture/internals/storage-locations.md +943 -0
- package/docs/architecture/persisted-data-compat.md +68 -0
- package/docs/architecture/reviews/env-secret-access.md +319 -0
- package/docs/architecture/runtime-boundary-design.md +153 -0
- package/docs/architecture/specs/0.9.0-close-out-plan.md +361 -0
- package/docs/architecture/specs/0.9.0-decisions.md +532 -0
- package/docs/architecture/specs/0.9.0-docs-code-drift-register.md +745 -0
- package/docs/architecture/specs/0.9.0-open-items-register.md +135 -0
- package/docs/architecture/specs/0.9.0-public-api-issue-backlog.md +740 -0
- package/docs/architecture/specs/0.9.0-release-surface-review.md +636 -0
- package/docs/architecture/specs/agent-command-engine-model-design.md +513 -0
- package/docs/architecture/specs/akm-0.9.0-bundle-adapter-spec.md +501 -0
- package/docs/architecture/specs/akm-0.9.0-ref-grammar-decision.md +291 -0
- package/docs/architecture/specs/akm-format-neutral-bundle-workspace-spec.md +2059 -0
- package/docs/architecture/specs/di-seams-plan.md +539 -0
- package/docs/architecture/specs/driver-protocol-keep-or-cut.md +275 -0
- package/docs/architecture/specs/fact-asset-type.md +142 -0
- package/docs/architecture/specs/improve-collapse-churn-detector-design.md +634 -0
- package/docs/architecture/specs/okf-support.md +148 -0
- package/docs/architecture/specs/ref.md +329 -0
- package/docs/architecture/specs/reviews/task-workflow-unification/README.md +72 -0
- package/docs/architecture/specs/reviews/task-workflow-unification/findings-consolidated.md +152 -0
- package/docs/architecture/specs/reviews/task-workflow-unification/library-eval-alternatives.md +352 -0
- package/docs/architecture/specs/reviews/task-workflow-unification/library-eval-bunqueue.md +300 -0
- package/docs/architecture/specs/reviews/task-workflow-unification/library-eval-openworkflow.md +402 -0
- package/docs/architecture/specs/reviews/task-workflow-unification/opus-review-1.md +758 -0
- package/docs/architecture/specs/reviews/task-workflow-unification/opus-review-2.md +645 -0
- package/docs/architecture/specs/reviews/task-workflow-unification/opus-review-3.md +602 -0
- package/docs/architecture/specs/reviews/task-workflow-unification/panel-r1-adversarial.md +27 -0
- package/docs/architecture/specs/reviews/task-workflow-unification/panel-r1-architecture.md +27 -0
- package/docs/architecture/specs/reviews/task-workflow-unification/panel-r1-coverage.md +74 -0
- package/docs/architecture/specs/reviews/task-workflow-unification/panel-r1-security.md +15 -0
- package/docs/architecture/specs/reviews/task-workflow-unification/panel-r2-adversarial.md +132 -0
- package/docs/architecture/specs/reviews/task-workflow-unification/panel-r2-verification.md +147 -0
- package/docs/architecture/specs/stash-conventions-code-spec.md +275 -0
- package/docs/architecture/specs/stash-organization-conventions.md +377 -0
- package/docs/architecture/specs/task-workflow-format-unification.md +721 -0
- package/docs/architecture/specs/workflow-engine-buy-vs-build.md +231 -0
- package/docs/architecture/specs/workflow-format-unification.md +432 -0
- package/docs/architecture/testing/manual-testing-checklist.md +3411 -0
- package/docs/architecture/testing/okf-v0.2-conformance-runbook.md +924 -0
- package/docs/architecture/testing/task-workflow-manual-tests.md +1720 -0
- package/docs/architecture/testing/testing-workflow.md +446 -0
- package/docs/architecture/workflow-engine.md +223 -0
- package/docs/guides/README.md +33 -0
- package/docs/guides/author-bundles.md +310 -0
- package/docs/guides/author-workflows.md +490 -0
- package/docs/guides/bundles.md +321 -0
- package/docs/guides/capture-knowledge.md +136 -0
- package/docs/guides/claude-code-vs-akm-workflows.md +29 -0
- package/docs/guides/concepts.md +93 -0
- package/docs/guides/discover-and-load.md +158 -0
- package/docs/guides/getting-started.md +240 -0
- package/docs/guides/improve-the-library.md +246 -0
- package/docs/guides/knowledge-management.md +18 -0
- package/docs/guides/recipes/headless-install.md +97 -0
- package/docs/guides/recipes/website-source.md +28 -0
- package/docs/guides/run-workflows.md +279 -0
- package/docs/guides/scheduling.md +123 -0
- package/docs/guides/use-with-any-agent.md +174 -0
- package/docs/guides/wikis.md +81 -0
- package/docs/integration/bundling-akm.md +7 -6
- package/docs/maintainers/README.md +19 -0
- package/docs/maintainers/curate-workmap.md +335 -0
- package/docs/maintainers/eval.md +3 -0
- package/docs/maintainers/local-development.md +108 -0
- package/docs/maintainers/release-checklist.md +132 -0
- package/docs/migration/README.md +2 -2
- package/docs/migration/release-notes/0.0.13.md +1 -1
- package/docs/migration/release-notes/0.1.0.md +1 -1
- package/docs/migration/release-notes/0.2.0.md +1 -1
- package/docs/migration/release-notes/0.3.0.md +1 -1
- package/docs/migration/release-notes/0.5.0.md +1 -1
- package/docs/migration/release-notes/0.6.0.md +1 -1
- package/docs/migration/release-notes/0.7.0.md +1 -1
- package/docs/migration/release-notes/0.7.3.md +2 -2
- package/docs/migration/release-notes/0.7.4.md +1 -1
- package/docs/migration/release-notes/0.7.5.md +1 -1
- package/docs/migration/release-notes/0.8.0.md +1 -1
- package/docs/migration/release-notes/0.9.0.md +1 -1
- package/docs/migration/release-notes/0.9.14.md +1 -1
- package/docs/migration/release-notes/0.9.15.md +1 -1
- package/docs/migration/release-notes/0.9.16.md +1 -1
- package/docs/migration/release-notes/0.9.17.md +1 -1
- package/docs/migration/release-notes/0.9.19.md +1 -1
- package/docs/migration/release-notes/0.9.2.md +1 -1
- package/docs/migration/release-notes/README.md +27 -31
- package/docs/migration/v0.5-to-v0.6.md +759 -0
- package/docs/migration/v0.8-to-v0.9.md +1 -1
- package/docs/plans/0.9.2-agent-command-workflow-plan.md +423 -0
- package/docs/posts/README.md +30 -0
- package/docs/posts/akm-command-tour.md +495 -0
- package/docs/posts/akm-logo-sized.webp +0 -0
- package/docs/posts/belief-aware-memory-12.md +139 -0
- package/docs/posts/config-v2-lessons-16.md +191 -0
- package/docs/posts/improve-loop-autonomous-10.md +225 -0
- package/docs/posts/improve-pipeline-debugging-0803.md +179 -0
- package/docs/posts/intro-part-01.md +76 -0
- package/docs/posts/intro-part-02.md +221 -0
- package/docs/posts/intro-part-03.md +190 -0
- package/docs/posts/intro-part-04.md +221 -0
- package/docs/posts/llm-mode-reflect-13.md +166 -0
- package/docs/posts/openpalm-built-on-akm.md +86 -0
- package/docs/posts/progressive-disclosure-06.md +129 -0
- package/docs/posts/proposal-safety-net-15.md +112 -0
- package/docs/posts/release-0.5.0.md +247 -0
- package/docs/posts/release-0.6.0.md +117 -0
- package/docs/posts/release-0.7.0.md +159 -0
- package/docs/posts/release-0.8.0.md +332 -0
- package/docs/posts/scattered-skills-05.md +100 -0
- package/docs/posts/task-assets-persistent-workflows-11.md +222 -0
- package/docs/posts/team-skills-07.md +198 -0
- package/docs/posts/wiki-agent-knowledge-08.md +223 -0
- package/docs/posts/workflows-vaults-09.md +321 -0
- package/docs/product-surface.md +54 -0
- package/docs/reference/README.md +2 -2
- package/docs/reference/api.md +65 -0
- package/docs/reference/asset-types.md +166 -0
- package/docs/reference/bundle-types.md +2 -4
- package/docs/reference/cli.md +129 -175
- package/docs/reference/configuration.md +84 -19
- package/docs/reference/data-and-telemetry.md +1 -1
- package/docs/reference/env-and-secrets.md +126 -0
- package/docs/reference/memory.md +124 -0
- package/docs/reference/refs.md +156 -0
- package/docs/reference/registry.md +489 -0
- package/docs/reference/supported-formats.md +3 -4
- package/docs/reference/tasks.md +12 -19
- package/docs/reference/website-sources.md +141 -0
- package/docs/reference/workflow-schema.md +89 -317
- package/docs/reference/workflows.md +20 -48
- package/package.json +23 -16
- package/schemas/akm-config.json +2 -243
- package/schemas/akm-task.json +2 -3
- package/schemas/akm-workflow.json +47 -84
- package/dist/assets/improve-strategies/catchup.json +0 -41
- package/dist/assets/improve-strategies/proactive-maintenance.json +0 -24
- package/dist/assets/improve-strategies/quick.json +0 -17
- package/dist/assets/improve-strategies/reflect-distill.json +0 -29
- package/dist/assets/improve-strategies/thorough.json +0 -49
- package/dist/assets/tasks/improve/akm-improve-catchup.yml +0 -6
- package/dist/assets/tasks/improve/akm-improve-frequent.yml +0 -4
- package/dist/assets/tasks/improve/akm-improve-nightly.yml +0 -4
- package/dist/cli/retired-commands.js +0 -118
- package/dist/commands/tasks/validate.js +0 -176
- package/dist/core/config/legacy-source-shape-shim.js +0 -117
- package/dist/integrations/harnesses/ids.js +0 -28
- package/dist/tasks/source/task-source-v3-frozen.js +0 -424
- package/dist/tasks/source/task-to-v4.js +0 -863
- package/dist/workflows/exec/worktree.js +0 -372
- package/dist/workflows/freeze/child-output-references.js +0 -83
- package/dist/workflows/freeze/identity.js +0 -22
- package/dist/workflows/freeze/targets/script.js +0 -50
- package/dist/workflows/freeze/targets/task.js +0 -124
- package/dist/workflows/github-yaml.js +0 -506
- package/dist/workflows/runtime/run-outputs.js +0 -80
package/dist/cli/shared.js
CHANGED
|
@@ -156,19 +156,8 @@ export const GLOBAL_OUTPUT_ARGS = {
|
|
|
156
156
|
format: { type: "string", description: "Output format: json|jsonl|yaml|text|md|html (global flag)" },
|
|
157
157
|
detail: {
|
|
158
158
|
type: "string",
|
|
159
|
-
description: "Detail level
|
|
160
|
-
|
|
161
|
-
// R-050(c): single-sourced with the root command's own `--shape` help
|
|
162
|
-
// (`main.args.shape` in src/cli.ts, which spreads this object) so the
|
|
163
|
-
// caveat is visible from every leaf's own `--help`, not only the top-level
|
|
164
|
-
// one. `summary` outside `show` falls back to `agent` with a warning
|
|
165
|
-
// (shapeForCommand in src/output/shapes.ts) — `--shape` is a global flag,
|
|
166
|
-
// so a script that passes it to a mixed batch of commands still works.
|
|
167
|
-
shape: {
|
|
168
|
-
type: "string",
|
|
169
|
-
description: "Output projection: human|agent|summary (global flag). 'agent' trims to agent-essential fields; " +
|
|
170
|
-
"'summary' only has a dedicated projection on 'akm show' — elsewhere it falls back to 'agent' with a " +
|
|
171
|
-
"warning. Default: human.",
|
|
159
|
+
description: "Detail level: brief|normal|full (verbosity), or agent (trims search, curate and show to agent-essential " +
|
|
160
|
+
"fields; other commands ignore it) (global flag).",
|
|
172
161
|
},
|
|
173
162
|
output: {
|
|
174
163
|
type: "string",
|
|
@@ -294,51 +283,45 @@ export function outputWithExitCode(command, result, exitCode) {
|
|
|
294
283
|
}
|
|
295
284
|
export function output(command, result) {
|
|
296
285
|
const mode = getOutputMode();
|
|
297
|
-
const
|
|
298
|
-
if (
|
|
299
|
-
outputJsonl(command,
|
|
286
|
+
const { format } = mode;
|
|
287
|
+
if (format === "jsonl") {
|
|
288
|
+
outputJsonl(command, shapeForCommand(command, result, mode.detail, mode.shape));
|
|
300
289
|
return;
|
|
301
290
|
}
|
|
291
|
+
deliverRendered(renderOutput(command, result, { ...mode, format }), mode.outputPath);
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Shape and render a command result into the document `output()` delivers.
|
|
295
|
+
* Pure: reads no process-level output mode and writes nothing, so in-process
|
|
296
|
+
* callers (`src/api.ts`) get text byte-identical to the CLI's stdout from an
|
|
297
|
+
* explicit `mode`.
|
|
298
|
+
*/
|
|
299
|
+
export function renderOutput(command, result, mode) {
|
|
300
|
+
const shaped = shapeForCommand(command, result, mode.detail, mode.shape);
|
|
302
301
|
switch (mode.format) {
|
|
303
302
|
case "json":
|
|
304
|
-
|
|
305
|
-
return;
|
|
303
|
+
return JSON.stringify(shaped, null, 2);
|
|
306
304
|
case "yaml":
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
case "text": {
|
|
305
|
+
return yamlStringify(shaped);
|
|
306
|
+
case "text":
|
|
310
307
|
// D7 — registry first, generic rendering of the shaped envelope second.
|
|
311
|
-
//
|
|
312
|
-
// registered text formatter used to fall through to
|
|
308
|
+
// A command with no registered text formatter used to fall through to
|
|
313
309
|
// `JSON.stringify(shaped, null, 2)`, i.e. silently hand back JSON while
|
|
314
|
-
// claiming `--format text`
|
|
315
|
-
//
|
|
316
|
-
//
|
|
317
|
-
//
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
//
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
}
|
|
325
|
-
case "md": {
|
|
326
|
-
// D7 — registry first, generic rendering of the shaped envelope second.
|
|
327
|
-
// No command emits JSON under `--format md` any more: silently handing
|
|
328
|
-
// back the wrong format was the worst of the three behaviours this
|
|
329
|
-
// replaced.
|
|
330
|
-
const rendered = getMdRendererHandler(command)?.(shaped, mode.detail);
|
|
331
|
-
deliverRendered(rendered ?? renderGenericMarkdown(command, shaped), mode.outputPath);
|
|
332
|
-
return;
|
|
333
|
-
}
|
|
334
|
-
case "html": {
|
|
310
|
+
// claiming `--format text`. `renderGenericText` renders flat
|
|
311
|
+
// `key=value` text matching the house style of registered formatters
|
|
312
|
+
// like `config list`; it is a DISTINCT function from
|
|
313
|
+
// `renderGenericMarkdown` (see src/output/generic-render.ts).
|
|
314
|
+
return formatPlain(command, shaped, mode.detail) ?? renderGenericText(command, shaped);
|
|
315
|
+
case "md":
|
|
316
|
+
// D7 — registry first, generic rendering second; no command emits JSON
|
|
317
|
+
// under `--format md`.
|
|
318
|
+
return getMdRendererHandler(command)?.(shaped, mode.detail) ?? renderGenericMarkdown(command, shaped);
|
|
319
|
+
case "html":
|
|
335
320
|
// `akm health` and `akm metrics` are the only commands with a bespoke
|
|
336
321
|
// HTML report, so they are called directly rather than through a
|
|
337
322
|
// registry with two possible registrants (see `output/render-registry.ts`).
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
return;
|
|
341
|
-
}
|
|
323
|
+
return ((command === "health" ? renderHealthHtml(shaped) : command === "metrics" ? renderMetricsHtml(shaped) : null) ??
|
|
324
|
+
renderGenericHtml(command, shaped));
|
|
342
325
|
}
|
|
343
326
|
}
|
|
344
327
|
// parseAllFlagValues moved to ./invocation (chunk-9 WI-9.9 argv-normalization
|
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
import { UsageError } from "../core/errors.js";
|
|
29
29
|
import { warn } from "../core/warn.js";
|
|
30
30
|
import { cittyComparableName, findCittyTopLevelCommandIndex, toAliasArray, } from "./invocation.js";
|
|
31
|
-
import { retiredFlagHint } from "./retired-commands.js";
|
|
32
31
|
/**
|
|
33
32
|
* Commands that must never refuse on an unrecognized flag — `akm info` warns
|
|
34
33
|
* and continues instead of exiting 2, the same tolerance a bare `akm help
|
|
@@ -39,36 +38,6 @@ import { retiredFlagHint } from "./retired-commands.js";
|
|
|
39
38
|
const UNKNOWN_FLAG_TOLERANT_COMMANDS = new Set(["info"]);
|
|
40
39
|
/** Flags citty implements itself, which no command declares. */
|
|
41
40
|
const IMPLICIT_FLAGS = ["help", "h", "version", "v"];
|
|
42
|
-
/**
|
|
43
|
-
* Retired flags whose commands still diagnose them THEMSELVES, with a message
|
|
44
|
-
* that names the replacement ("`--scope` was removed, use `--filter`",
|
|
45
|
-
* "`--source` was renamed to `--generator`"). A generic "unknown flag" would
|
|
46
|
-
* preempt the better diagnosis, so these are passed through — but ONLY on the
|
|
47
|
-
* command path that owns the diagnostic, keyed by the resolved path. On every
|
|
48
|
-
* other command the same spelling is a genuine typo and still fails fast
|
|
49
|
-
* A retired flag is rejected everywhere else, where silently dropping it could
|
|
50
|
-
* run a real mutation.
|
|
51
|
-
*
|
|
52
|
-
* Shrink-only: when a command drops its bespoke diagnostic, drop the entry and
|
|
53
|
-
* the generic error takes over.
|
|
54
|
-
*/
|
|
55
|
-
const SELF_DIAGNOSED_FLAGS = new Map(Object.entries({
|
|
56
|
-
show: ["akmView", "scope"], // removed view grammar; --scope points at --filter
|
|
57
|
-
index: ["enrich", "re-enrich"], // removed index-time enrichment flags
|
|
58
|
-
"proposal accept": ["source"], // renamed to --generator
|
|
59
|
-
"proposal reject": ["source"], // renamed to --generator
|
|
60
|
-
"proposal drain": ["profile"], // retired, points at --strategy
|
|
61
|
-
search: ["source"], // renamed to --from
|
|
62
|
-
curate: ["source"], // renamed to --from
|
|
63
|
-
"task list": ["source"], // renamed to --from (alias of `search --type task`, #951)
|
|
64
|
-
remember: ["target"], // renamed to --bundle
|
|
65
|
-
clone: ["target"], // renamed to --bundle
|
|
66
|
-
improve: ["auto-accept", "target"], // retired in 0.9.0 / renamed to --bundle
|
|
67
|
-
"task add": ["target"], // renamed to --bundle
|
|
68
|
-
"task run": ["target"], // renamed to --bundle
|
|
69
|
-
"task history": ["target"], // renamed to --bundle
|
|
70
|
-
"task sync": ["target"], // renamed to --bundle
|
|
71
|
-
}).map(([path, flags]) => [path, new Set(flags.map(cittyComparableName))]));
|
|
72
41
|
/**
|
|
73
42
|
* Union the arg definitions declared along the resolved command path. The
|
|
74
43
|
* subcommand walk delegates to {@link findCittyTopLevelCommandIndex} — the
|
|
@@ -111,6 +80,12 @@ function collectKnownArgs(root, rawArgs) {
|
|
|
111
80
|
break;
|
|
112
81
|
const idx = findCittyTopLevelCommandIndex(args, (cmd.args ?? {}));
|
|
113
82
|
const token = idx >= 0 ? args[idx] : undefined;
|
|
83
|
+
// A command that takes a positional AND has subcommands (`improve [scope]`
|
|
84
|
+
// beside `improve report`) is itself the target when the token is absent
|
|
85
|
+
// or names none of them.
|
|
86
|
+
const takesPositional = Object.values(cmd.args ?? {}).some((def) => def.type === "positional");
|
|
87
|
+
if (takesPositional && (token === undefined || !subCommands[token]))
|
|
88
|
+
break;
|
|
114
89
|
// A group with no subcommand token: citty reports "no command specified".
|
|
115
90
|
if (token === undefined)
|
|
116
91
|
return { names, valueFlags, booleanFlags, displayNames, path, resolved: false };
|
|
@@ -166,15 +141,6 @@ export function closestMatch(attempted, candidates, threshold) {
|
|
|
166
141
|
* @param attempted The spelling to edit-distance against `--long` candidates.
|
|
167
142
|
*/
|
|
168
143
|
function throwUnknownFlag(shown, attempted, known) {
|
|
169
|
-
// Flags the 0.9 overhaul removed outright get their retirement note, not a
|
|
170
|
-
// did-you-mean — same reasoning as `retiredCommandHint` in src/cli.ts:
|
|
171
|
-
// edit distance can point at an unrelated survivor rather than the real
|
|
172
|
-
// replacement procedure (e.g. `index --background` is closer to no other
|
|
173
|
-
// `index` flag than it is to any useful suggestion).
|
|
174
|
-
const retired = retiredFlagHint(known.path, attempted);
|
|
175
|
-
if (retired) {
|
|
176
|
-
throw new UsageError(`Unknown flag "${shown}".`, "UNKNOWN_FLAG", retired);
|
|
177
|
-
}
|
|
178
144
|
const threshold = Math.max(2, Math.ceil(attempted.length / 3));
|
|
179
145
|
const suggestion = closestMatch(attempted, known.displayNames, threshold);
|
|
180
146
|
throw new UsageError(`Unknown flag "${shown}".`, "UNKNOWN_FLAG", suggestion
|
|
@@ -207,7 +173,6 @@ export function assertKnownFlags(root, rawArgs) {
|
|
|
207
173
|
// scanner, so it needs the identical exemption).
|
|
208
174
|
const dynamicNamedFlagCommands = new Set(["workflow run", "task run", "task explain"]);
|
|
209
175
|
const dynamicWorkflowParams = dynamicNamedFlagCommands.has(known.path.join(" "));
|
|
210
|
-
const selfDiagnosed = SELF_DIAGNOSED_FLAGS.get(known.path.join(" "));
|
|
211
176
|
const tolerant = UNKNOWN_FLAG_TOLERANT_COMMANDS.has(known.path.join(" "));
|
|
212
177
|
for (let i = 0; i < ownArgs.length; i += 1) {
|
|
213
178
|
const token = ownArgs[i];
|
|
@@ -250,8 +215,6 @@ export function assertKnownFlags(root, rawArgs) {
|
|
|
250
215
|
? rawName.slice(3)
|
|
251
216
|
: undefined;
|
|
252
217
|
const candidates = [cittyComparableName(rawName), ...(negated ? [cittyComparableName(negated)] : [])];
|
|
253
|
-
if (selfDiagnosed !== undefined && candidates.some((name) => selfDiagnosed.has(name)))
|
|
254
|
-
continue;
|
|
255
218
|
if (!candidates.some((name) => known.names.has(name))) {
|
|
256
219
|
// `workflow run` owns one deliberately dynamic namespace: long options
|
|
257
220
|
// become exact-name workflow parameters and are checked against the
|
package/dist/cli.js
CHANGED
|
@@ -58,7 +58,6 @@ process.on("uncaughtException", (err) => {
|
|
|
58
58
|
import fs from "node:fs";
|
|
59
59
|
import { defineCommand, parseArgs, renderUsage, runCommand, showUsage } from "citty";
|
|
60
60
|
import { findCittyTopLevelCommandIndex, getParsedInvocation, parseAllFlagValues, resolveHelpMigrateVersionArg, setParsedInvocation, } from "./cli/invocation.js";
|
|
61
|
-
import { retiredCommandHint } from "./cli/retired-commands.js";
|
|
62
61
|
import { defineGroupCommand, EXIT_CODES, emitJsonError, GLOBAL_OUTPUT_ARGS, output, runWithJsonErrors, } from "./cli/shared.js";
|
|
63
62
|
import { assertKnownFlags, closestMatch } from "./cli/unknown-flags.js";
|
|
64
63
|
import { agentCommand, lintCommand } from "./commands/agent/contribute-cli.js";
|
|
@@ -137,7 +136,7 @@ function printSetupTtyHint(result) {
|
|
|
137
136
|
if (!result?.bundleDir)
|
|
138
137
|
return;
|
|
139
138
|
console.error(plainize(`\n✓ Bundle created at ${result.bundleDir}\n` +
|
|
140
|
-
' Next: `akm bundle add <source>`, `akm index`, `akm search "<query>"`, `akm
|
|
139
|
+
' Next: `akm bundle add <source>`, `akm index`, `akm search "<query>"`, `akm hints`'));
|
|
141
140
|
}
|
|
142
141
|
/**
|
|
143
142
|
* Module Naming:
|
|
@@ -264,7 +263,7 @@ const healthCommand = defineCommand({
|
|
|
264
263
|
args: {
|
|
265
264
|
// R-051: `health` is a raw `defineCommand` (not `defineJsonCommand`), so
|
|
266
265
|
// it does not get `GLOBAL_OUTPUT_ARGS` for free. `--format`/`--detail`/
|
|
267
|
-
// `--
|
|
266
|
+
// `--output` already parsed correctly here (this command has
|
|
268
267
|
// no positional for a stray value to fall into), so this is purely a
|
|
269
268
|
// `--help` visibility / consistency fix, not a behavior change.
|
|
270
269
|
...GLOBAL_OUTPUT_ARGS,
|
|
@@ -383,9 +382,6 @@ const healthCommand = defineCommand({
|
|
|
383
382
|
}
|
|
384
383
|
},
|
|
385
384
|
});
|
|
386
|
-
function loadAgentHints(full) {
|
|
387
|
-
return full ? EMBEDDED_HINTS_FULL : EMBEDDED_HINTS;
|
|
388
|
-
}
|
|
389
385
|
const hintsCommand = defineCommand({
|
|
390
386
|
meta: {
|
|
391
387
|
name: "hints",
|
|
@@ -401,7 +397,7 @@ const hintsCommand = defineCommand({
|
|
|
401
397
|
run({ args }) {
|
|
402
398
|
return runWithJsonErrors(() => {
|
|
403
399
|
const detail = parseDetailLevel(args.detail) ?? "normal";
|
|
404
|
-
process.stdout.write(
|
|
400
|
+
process.stdout.write(detail === "brief" ? EMBEDDED_HINTS : EMBEDDED_HINTS_FULL);
|
|
405
401
|
});
|
|
406
402
|
},
|
|
407
403
|
});
|
|
@@ -504,24 +500,6 @@ const helpCommand = defineGroupCommand({
|
|
|
504
500
|
},
|
|
505
501
|
subCommands: {
|
|
506
502
|
...commandHelpTopics,
|
|
507
|
-
agents: defineCommand({
|
|
508
|
-
meta: {
|
|
509
|
-
name: "agents",
|
|
510
|
-
description: "Print agent instructions on how to use akm — the short guide by default; pass --full for the complete guide",
|
|
511
|
-
},
|
|
512
|
-
args: {
|
|
513
|
-
full: {
|
|
514
|
-
type: "boolean",
|
|
515
|
-
default: false,
|
|
516
|
-
description: "Print the complete guide instead of the short one.",
|
|
517
|
-
},
|
|
518
|
-
},
|
|
519
|
-
run({ args }) {
|
|
520
|
-
return runWithJsonErrors(() => {
|
|
521
|
-
process.stdout.write(loadAgentHints(args.full === true));
|
|
522
|
-
});
|
|
523
|
-
},
|
|
524
|
-
}),
|
|
525
503
|
migrate: defineCommand({
|
|
526
504
|
meta: {
|
|
527
505
|
name: "migrate",
|
|
@@ -855,7 +833,7 @@ function renderCommandSections() {
|
|
|
855
833
|
* USAGE line + global OPTIONS, then cuts the string before citty's own
|
|
856
834
|
* "COMMANDS" heading (present because `main` has `subCommands`) and appends
|
|
857
835
|
* the grouped sections plus a one-line bundle/ref-grammar tagline and the
|
|
858
|
-
* `akm
|
|
836
|
+
* `akm hints` pointer.
|
|
859
837
|
*/
|
|
860
838
|
async function renderSectionedRootHelp() {
|
|
861
839
|
const base = await renderUsage(main, undefined);
|
|
@@ -872,7 +850,7 @@ async function renderSectionedRootHelp() {
|
|
|
872
850
|
"`akm search` output rather than synthesizing them.",
|
|
873
851
|
"",
|
|
874
852
|
"Run `akm help <command>` or `akm <command> --help` for details on any command.",
|
|
875
|
-
"Agents: run `akm hints` for the complete guide or `akm
|
|
853
|
+
"Agents: run `akm hints` for the complete guide, or `akm hints --detail brief` for the short one.",
|
|
876
854
|
].join("\n");
|
|
877
855
|
return [head, "", renderCommandSections(), "", epilogue].join("\n");
|
|
878
856
|
}
|
|
@@ -910,7 +888,7 @@ function findUnknownCommandAttempt(rawArgs) {
|
|
|
910
888
|
}
|
|
911
889
|
/** Closest command within a length-scaled distance threshold (shared DP in cli/unknown-flags.ts). */
|
|
912
890
|
function closestCommandMatch(attempted, candidates) {
|
|
913
|
-
return closestMatch(attempted, candidates, Math.
|
|
891
|
+
return closestMatch(attempted, candidates, Math.floor(attempted.length / 3));
|
|
914
892
|
}
|
|
915
893
|
const CLI_HELP_POINTER = "Run `akm --help` for usage.";
|
|
916
894
|
/**
|
|
@@ -944,12 +922,8 @@ function cittyCliErrorUsageCode(error) {
|
|
|
944
922
|
function toUsageErrorFromCliError(error, rawArgs) {
|
|
945
923
|
const code = cittyCliErrorUsageCode(error);
|
|
946
924
|
const attempt = code === "UNKNOWN_COMMAND" ? findUnknownCommandAttempt(rawArgs) : undefined;
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
// (`init`→`info`, `update`→`upgrade`), and agents follow suggestions.
|
|
950
|
-
const retired = attempt ? retiredCommandHint(attempt.parentPath, attempt.attempted) : undefined;
|
|
951
|
-
const suggestion = retired === undefined && attempt ? closestCommandMatch(attempt.attempted, attempt.candidates) : undefined;
|
|
952
|
-
const hint = retired ?? (suggestion ? `Did you mean \`${suggestion}\`? ${CLI_HELP_POINTER}` : CLI_HELP_POINTER);
|
|
925
|
+
const suggestion = attempt ? closestCommandMatch(attempt.attempted, attempt.candidates) : undefined;
|
|
926
|
+
const hint = suggestion ? `Did you mean \`${suggestion}\`? ${CLI_HELP_POINTER}` : CLI_HELP_POINTER;
|
|
953
927
|
// citty colorizes error.message with ANSI escapes even when stdout/stderr
|
|
954
928
|
// is not a TTY. Strip them so the JSON envelope's `error` field is plain
|
|
955
929
|
// text instead of embedding raw escape sequences.
|
|
@@ -112,7 +112,7 @@ export const lintCommand = defineCommand({
|
|
|
112
112
|
args: {
|
|
113
113
|
// R-051: `lint` is a raw `defineCommand` (not `defineJsonCommand`), so it
|
|
114
114
|
// does not get `GLOBAL_OUTPUT_ARGS` for free. `--format`/`--detail`/
|
|
115
|
-
// `--
|
|
115
|
+
// `--output` already parsed correctly here (this command has no
|
|
116
116
|
// positional for a stray value to fall into), so this is purely a
|
|
117
117
|
// `--help` visibility / consistency fix, not a behavior change.
|
|
118
118
|
...GLOBAL_OUTPUT_ARGS,
|
|
@@ -7,8 +7,7 @@ import path from "node:path";
|
|
|
7
7
|
import { placementTypes } from "../core/asset/asset-placement.js";
|
|
8
8
|
const FLAG_VALUES = {
|
|
9
9
|
"--format": [{ values: ["json", "jsonl", "yaml", "text", "md", "html"] }],
|
|
10
|
-
"--detail": [{ values: ["brief", "normal", "full"] }],
|
|
11
|
-
"--shape": [{ values: ["human", "agent", "summary"] }],
|
|
10
|
+
"--detail": [{ values: ["brief", "normal", "full", "agent"] }],
|
|
12
11
|
"--type": [{ values: () => [...placementTypes(), "any"] }],
|
|
13
12
|
"--shell": [{ values: ["bash"] }],
|
|
14
13
|
"--from": [{ paths: ["akm search", "akm curate"], values: ["local", "registry", "all"] }],
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import { isDeepStrictEqual } from "node:util";
|
|
16
16
|
import { defineGroupCommand, defineJsonCommand, output } from "../cli/shared.js";
|
|
17
|
-
import { isRecord
|
|
17
|
+
import { isRecord } from "../core/common.js";
|
|
18
18
|
import { DEFAULT_CONFIG, getConfigValueSource, loadConfig, mutateConfig, parseAndValidateConfigText, resolveConfigRefSource, } from "../core/config/config.js";
|
|
19
19
|
import { configGet, configSet, configUnset, unknownKeyHint } from "../core/config/config-walker.js";
|
|
20
20
|
import { UsageError } from "../core/errors.js";
|
|
21
|
-
import {
|
|
21
|
+
import { getConfigPath } from "../core/paths.js";
|
|
22
22
|
import { formatRegistryUrl } from "../core/registry-url.js";
|
|
23
23
|
// ── Public API ──────────────────────────────────────────────────────────────
|
|
24
24
|
export function getConfigValue(config, key) {
|
|
@@ -118,32 +118,9 @@ export const configCommand = defineGroupCommand({
|
|
|
118
118
|
meta: { name: "config", description: "Show and manage configuration" },
|
|
119
119
|
subCommands: {
|
|
120
120
|
path: defineJsonCommand({
|
|
121
|
-
meta: { name: "path", description: "
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
},
|
|
125
|
-
run({ args }) {
|
|
126
|
-
const configPath = getConfigPath();
|
|
127
|
-
if (args.all) {
|
|
128
|
-
let stashDir;
|
|
129
|
-
try {
|
|
130
|
-
stashDir = resolveStashDir();
|
|
131
|
-
}
|
|
132
|
-
catch {
|
|
133
|
-
stashDir = `${getDefaultStashDir()} (not initialized)`;
|
|
134
|
-
}
|
|
135
|
-
const cacheDir = getCacheDir();
|
|
136
|
-
const result = {
|
|
137
|
-
config: configPath,
|
|
138
|
-
bundle: stashDir,
|
|
139
|
-
cache: cacheDir,
|
|
140
|
-
index: getDbPath(),
|
|
141
|
-
};
|
|
142
|
-
output("config", result);
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
console.log(configPath);
|
|
146
|
-
}
|
|
121
|
+
meta: { name: "path", description: "Print the path to the config file" },
|
|
122
|
+
run() {
|
|
123
|
+
console.log(getConfigPath());
|
|
147
124
|
},
|
|
148
125
|
}),
|
|
149
126
|
list: defineJsonCommand({
|
|
@@ -56,7 +56,7 @@ const envCreateCommand = defineJsonCommand({
|
|
|
56
56
|
description: "Exclude this env file from env list output and the search index",
|
|
57
57
|
default: false,
|
|
58
58
|
},
|
|
59
|
-
|
|
59
|
+
bundle: {
|
|
60
60
|
type: "string",
|
|
61
61
|
description: "Override the write destination. Accepts a source name from your config; falls back to defaultWriteTarget then the working bundle.",
|
|
62
62
|
},
|
|
@@ -64,8 +64,8 @@ const envCreateCommand = defineJsonCommand({
|
|
|
64
64
|
async run({ args }) {
|
|
65
65
|
const { createEnv, writeEnv } = await import("./env.js");
|
|
66
66
|
// `create` always targets env/, never the frozen vaults/ copy. `--path` is
|
|
67
|
-
// the subdirectory; `--
|
|
68
|
-
const { name, absPath, target, ref } = resolveEnvWriteTarget(args.name, args.
|
|
67
|
+
// the subdirectory; `--bundle` selects the writable destination source.
|
|
68
|
+
const { name, absPath, target, ref } = resolveEnvWriteTarget(args.name, args.bundle, {
|
|
69
69
|
subPath: getStringArg(args, "path"),
|
|
70
70
|
});
|
|
71
71
|
const fromFile = args["from-file"];
|
|
@@ -304,13 +304,13 @@ const envRemoveCommand = defineJsonCommand({
|
|
|
304
304
|
args: {
|
|
305
305
|
ref: { type: "positional", description: "Env ref", required: true },
|
|
306
306
|
yes: { type: "boolean", alias: "y", description: "Skip confirmation prompt", default: false },
|
|
307
|
-
|
|
307
|
+
bundle: {
|
|
308
308
|
type: "string",
|
|
309
309
|
description: "Override the write destination. Accepts a source name from your config; falls back to defaultWriteTarget then the working bundle.",
|
|
310
310
|
},
|
|
311
311
|
},
|
|
312
312
|
async run({ args }) {
|
|
313
|
-
const { name, absPath, target, ref } = resolveEnvWriteTarget(args.ref, args.
|
|
313
|
+
const { name, absPath, target, ref } = resolveEnvWriteTarget(args.ref, args.bundle);
|
|
314
314
|
const { confirmDestructive } = await import("../../cli/confirm.js");
|
|
315
315
|
const confirmed = await confirmDestructive(`Remove env "${args.ref}"? This cannot be undone.`, {
|
|
316
316
|
yes: args.yes === true,
|
|
@@ -108,14 +108,14 @@ const secretSetCommand = defineJsonCommand({
|
|
|
108
108
|
},
|
|
109
109
|
"from-file": { type: "string", description: "Read the value from this file (stored byte-exact)" },
|
|
110
110
|
"from-env": { type: "string", description: "Read the value from the named environment variable" },
|
|
111
|
-
|
|
111
|
+
bundle: {
|
|
112
112
|
type: "string",
|
|
113
113
|
description: "Override the write destination. Accepts a source name from your config; falls back to defaultWriteTarget then the working bundle.",
|
|
114
114
|
},
|
|
115
115
|
},
|
|
116
116
|
async run({ args }) {
|
|
117
117
|
const { setSecret } = await import("./secret.js");
|
|
118
|
-
const { name, absPath, target, ref } = resolveSecretWriteTarget(args.ref, args.
|
|
118
|
+
const { name, absPath, target, ref } = resolveSecretWriteTarget(args.ref, args.bundle, {
|
|
119
119
|
subPath: getStringArg(args, "path"),
|
|
120
120
|
});
|
|
121
121
|
const fromEnv = args["from-env"];
|
|
@@ -11,6 +11,8 @@ import { withEngineFallback } from "../../integrations/agent/engine-fallback.js"
|
|
|
11
11
|
import { isLlmCredentialAvailable, resolveEngine, } from "../../integrations/agent/engine-resolution.js";
|
|
12
12
|
import { executionEngineDefinitionsFromConfig } from "../../integrations/agent/execution.js";
|
|
13
13
|
import { loadModelMap, mergeModelMapLayers, parseModelMapLayer, readInstalledModelMapText, resolveModelMapAlias, userModelMapPath, } from "../../integrations/agent/model-map.js";
|
|
14
|
+
import { detectOpencodeMajor, resolveOpencodeBin, } from "../../integrations/harnesses/opencode/version.js";
|
|
15
|
+
import { OPENCODE_CLIENT_PACKAGE } from "../../integrations/harnesses/opencode-sdk/wire.js";
|
|
14
16
|
import { probeEndpointOnce } from "../../llm/client.js";
|
|
15
17
|
import { STATE_DB_FREELIST_WARN_RATIO, } from "../../storage/state-db-integrity.js";
|
|
16
18
|
import { listKeys } from "../env/env.js";
|
|
@@ -116,20 +118,15 @@ async function runConfiguredEngineProbe(checkName, engineName, config, deps, rea
|
|
|
116
118
|
const env = deps.env ?? process.env;
|
|
117
119
|
const configuredEngine = config.engines?.[engineName];
|
|
118
120
|
if (configuredEngine?.kind === "agent" && configuredEngine.platform === "opencode-sdk") {
|
|
119
|
-
|
|
121
|
+
const binary = resolveOpencodeBin(configuredEngine.bin);
|
|
122
|
+
let detected;
|
|
120
123
|
try {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
const binary = configuredEngine.bin ?? "opencode";
|
|
129
|
-
let binaryAvailable;
|
|
130
|
-
try {
|
|
131
|
-
const version = (deps.spawnSync ?? spawnSync)(binary, ["--version"], { encoding: "utf8", timeout: 5_000 });
|
|
132
|
-
binaryAvailable = (version.status ?? 1) === 0;
|
|
124
|
+
detected = detectOpencodeMajor(binary, {
|
|
125
|
+
probe: (bin) => {
|
|
126
|
+
const run = (deps.spawnSync ?? spawnSync)(bin, ["--version"], { encoding: "utf8", timeout: 5_000 });
|
|
127
|
+
return (run.status ?? 1) === 0 ? String(run.stdout ?? "").trim() : undefined;
|
|
128
|
+
},
|
|
129
|
+
});
|
|
133
130
|
}
|
|
134
131
|
catch {
|
|
135
132
|
return {
|
|
@@ -141,6 +138,18 @@ async function runConfiguredEngineProbe(checkName, engineName, config, deps, rea
|
|
|
141
138
|
evidence: { engine: engineName, runtimeKind: "sdk", binaryAvailable: false },
|
|
142
139
|
};
|
|
143
140
|
}
|
|
141
|
+
const binaryAvailable = detected.runnable;
|
|
142
|
+
// The client package of the OpenCode major the binary reports; never the other major's.
|
|
143
|
+
const clientPackage = OPENCODE_CLIENT_PACKAGE[detected.major];
|
|
144
|
+
let packageAvailable = false;
|
|
145
|
+
try {
|
|
146
|
+
const resolvePackage = deps.resolvePackage ?? ((name) => import.meta.resolve(name));
|
|
147
|
+
resolvePackage(clientPackage);
|
|
148
|
+
packageAvailable = true;
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
packageAvailable = false;
|
|
152
|
+
}
|
|
144
153
|
const fallbackEngine = configuredEngine.llmEngine;
|
|
145
154
|
let fallback;
|
|
146
155
|
let fallbackCredential;
|
|
@@ -183,7 +192,7 @@ async function runConfiguredEngineProbe(checkName, engineName, config, deps, rea
|
|
|
183
192
|
? findSuppliedByEnvAsset(fallbackCredential, deps)
|
|
184
193
|
: null;
|
|
185
194
|
const missing = [
|
|
186
|
-
!packageAvailable ?
|
|
195
|
+
!packageAvailable ? `${clientPackage} package` : undefined,
|
|
187
196
|
!binaryAvailable ? `${binary} binary` : undefined,
|
|
188
197
|
fallbackEngine && !fallback ? "configured fallback LLM connection" : undefined,
|
|
189
198
|
!fallbackCredentialAvailable
|
|
@@ -198,7 +207,9 @@ async function runConfiguredEngineProbe(checkName, engineName, config, deps, rea
|
|
|
198
207
|
runtimeKind: "sdk",
|
|
199
208
|
binary,
|
|
200
209
|
binaryAvailable,
|
|
201
|
-
package:
|
|
210
|
+
package: clientPackage,
|
|
211
|
+
detectedVersion: detected.version || null,
|
|
212
|
+
detectedMajor: detected.major,
|
|
202
213
|
packageAvailable,
|
|
203
214
|
model: effectiveModel ?? null,
|
|
204
215
|
configuredModel: configuredModel ?? null,
|
|
@@ -533,7 +544,21 @@ export function probeActiveImproveStrategy(deps = {}) {
|
|
|
533
544
|
const requiredModelProcessNames = modelProcessNames.filter((name) => plan.processes[name].enabled || plan.engineUnavailable.some((item) => item.process === name));
|
|
534
545
|
const availableModelProcessNames = modelProcessNames.filter((name) => plan.processes[name].enabled);
|
|
535
546
|
const allRequiredUnavailable = requiredModelProcessNames.length > 0 && availableModelProcessNames.length === 0;
|
|
536
|
-
|
|
547
|
+
// No engine configured at all (no unavailable item carries a resolved engine)
|
|
548
|
+
// is "not set up yet", not a broken credential: it keeps the unknown/warn
|
|
549
|
+
// result it had when the plan threw for it. Engine-free deterministic triage
|
|
550
|
+
// (#1143) now lets such a plan resolve, so this has to be explicit.
|
|
551
|
+
const noEngineConfigured = plan.engineUnavailable.length > 0 && plan.engineUnavailable.every((i) => !i.engine);
|
|
552
|
+
const explicitlyConfigured = config.defaults?.improveStrategy !== undefined || Object.keys(config.improve?.strategies ?? {}).length > 0;
|
|
553
|
+
const status = unavailableProcesses.length === 0
|
|
554
|
+
? "pass"
|
|
555
|
+
: allRequiredUnavailable
|
|
556
|
+
? noEngineConfigured
|
|
557
|
+
? explicitlyConfigured
|
|
558
|
+
? "warn"
|
|
559
|
+
: "unknown"
|
|
560
|
+
: "fail"
|
|
561
|
+
: "warn";
|
|
537
562
|
return {
|
|
538
563
|
check: {
|
|
539
564
|
name: "active-improve-strategy",
|