akm-cli 0.9.0-rc.4 → 0.9.0-rc.6
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 +122 -26
- package/README.md +7 -7
- package/SECURITY.md +11 -10
- package/dist/akm +2 -2
- package/dist/akm-migrate-storage +2 -2
- package/dist/assets/hints/cli-hints-full.md +60 -73
- package/dist/assets/hints/cli-hints-short.md +8 -12
- package/dist/assets/improve-strategies/default.json +5 -7
- package/dist/assets/improve-strategies/frequent.json +2 -2
- package/dist/assets/improve-strategies/proactive-maintenance.json +2 -2
- package/dist/assets/improve-strategies/quick.json +1 -1
- package/dist/assets/improve-strategies/reflect-distill.json +3 -3
- package/dist/assets/improve-strategies/thorough.json +1 -1
- package/dist/assets/prompts/consolidate-system.md +5 -5
- package/dist/assets/prompts/extract-session.md +2 -6
- package/dist/assets/prompts/reflect-llm-framed-contract.md +11 -0
- package/dist/assets/prompts/reflect-llm-schema-contract.md +3 -0
- package/dist/assets/prompts/reflect-output-repair.md +3 -0
- package/dist/assets/stash-skeleton/README.md +10 -11
- package/dist/assets/stash-skeleton/facts/conventions/assets/agent.md +1 -1
- package/dist/assets/stash-skeleton/facts/conventions/assets/fact.md +1 -1
- package/dist/assets/stash-skeleton/facts/conventions/assets/knowledge.md +1 -1
- package/dist/assets/stash-skeleton/facts/conventions/assets/lesson.md +2 -2
- package/dist/assets/stash-skeleton/facts/conventions/assets/memory.md +2 -2
- package/dist/assets/stash-skeleton/facts/conventions/assets/script.md +1 -1
- package/dist/assets/stash-skeleton/facts/conventions/assets/skill.md +2 -2
- package/dist/assets/stash-skeleton/facts/conventions/assets/workflow.md +1 -1
- package/dist/assets/stash-skeleton/facts/conventions/backlinks.md +18 -18
- package/dist/assets/stash-skeleton/facts/conventions/domains.md +8 -9
- package/dist/assets/stash-skeleton/facts/conventions/organization.md +13 -15
- package/dist/assets/tasks/core/extract.yml +2 -2
- package/dist/assets/tasks/core/improve.yml +1 -1
- package/dist/assets/templates/html/health.html +2 -3
- package/dist/cli/config-migrate.js +1328 -101
- package/dist/cli/invocation.js +255 -0
- package/dist/cli/parse-args.js +20 -83
- package/dist/cli/shared.js +15 -37
- package/dist/cli.js +18 -49
- package/dist/commands/agent/agent-dispatch.js +2 -2
- package/dist/commands/agent/contribute-cli.js +5 -4
- package/dist/commands/bundle/bundle-cli.js +68 -0
- package/dist/commands/bundle/bundle.js +219 -0
- package/dist/commands/completions.js +2 -2
- package/dist/commands/config-cli.js +6 -3
- package/dist/commands/env/env-binding.js +13 -9
- package/dist/commands/env/env-cli.js +49 -48
- package/dist/commands/env/secret-cli.js +24 -10
- package/dist/commands/events.js +2 -2
- package/dist/commands/feedback-cli.js +59 -33
- package/dist/commands/graph/graph.js +6 -4
- package/dist/commands/health/advisories.js +4 -4
- package/dist/commands/health/html-report.js +190 -593
- package/dist/commands/health/improve-metrics.js +240 -188
- package/dist/commands/health/metrics.js +9 -17
- package/dist/commands/health/report-view-model.js +509 -0
- package/dist/commands/health/surfaces.js +6 -3
- package/dist/commands/health/types-checks.js +4 -0
- package/dist/commands/health/types-improve.js +22 -0
- package/dist/commands/health/types-metrics.js +4 -0
- package/dist/commands/health/types-result.js +7 -0
- package/dist/commands/health/types-runs.js +4 -0
- package/dist/commands/health/types-session-log.js +4 -0
- package/dist/commands/health/types-windows.js +4 -0
- package/dist/commands/health/types.js +26 -21
- package/dist/commands/health/windows.js +1 -2
- package/dist/commands/health.js +219 -161
- package/dist/commands/improve/collapse-detector.js +25 -14
- package/dist/commands/improve/consolidate/chunking.js +7 -5
- package/dist/commands/improve/consolidate.js +640 -740
- package/dist/commands/improve/content-hash.js +39 -0
- package/dist/commands/improve/distill/content-repair.js +4 -10
- package/dist/commands/improve/distill/promote-memory.js +79 -49
- package/dist/commands/improve/distill/quality-gate.js +113 -35
- package/dist/commands/improve/distill-promotion-policy.js +24 -885
- package/dist/commands/improve/distill.js +565 -337
- package/dist/commands/improve/eligibility.js +75 -36
- package/dist/commands/improve/extract-cli.js +6 -6
- package/dist/commands/improve/extract-prompt.js +5 -34
- package/dist/commands/improve/extract.js +526 -357
- package/dist/commands/improve/feedback-valence.js +2 -12
- package/dist/commands/improve/improve-cli.js +11 -20
- package/dist/commands/improve/improve-result-file.js +7 -6
- package/dist/commands/improve/improve-run-types.js +4 -0
- package/dist/commands/improve/improve-strategies.js +3 -9
- package/dist/commands/improve/improve.js +822 -727
- package/dist/commands/improve/locks.js +27 -95
- package/dist/commands/improve/loop-stages.js +941 -963
- package/dist/commands/improve/memory/derived-ref.js +122 -0
- package/dist/commands/improve/memory/memory-contradiction-detect.js +35 -38
- package/dist/commands/improve/memory/memory-improve.js +24 -37
- package/dist/commands/improve/outcome-loop.js +13 -33
- package/dist/commands/improve/preparation.js +889 -691
- package/dist/commands/improve/proactive-maintenance.js +37 -9
- package/dist/commands/improve/proposal-envelope.js +31 -0
- package/dist/commands/improve/reflect.js +974 -588
- package/dist/commands/improve/run-context.js +119 -0
- package/dist/commands/improve/salience.js +8 -4
- package/dist/commands/improve/session-asset.js +7 -3
- package/dist/commands/improve/shared.js +14 -40
- package/dist/commands/improve/source-identity.js +39 -26
- package/dist/commands/improve/triage.js +20 -17
- package/dist/commands/lint/base-linter.js +288 -295
- package/dist/commands/lint/index.js +132 -19
- package/dist/commands/mv-cli.js +257 -234
- package/dist/commands/observability-cli.js +2 -1
- package/dist/commands/proposal/diff-format.js +50 -0
- package/dist/commands/proposal/drain-policies.js +0 -6
- package/dist/commands/proposal/drain.js +17 -16
- package/dist/commands/proposal/proposal-cli.js +40 -77
- package/dist/commands/proposal/proposal-types.js +56 -0
- package/dist/commands/proposal/proposal.js +39 -1
- package/dist/commands/proposal/propose.js +41 -19
- package/dist/commands/proposal/repository.js +566 -486
- package/dist/commands/proposal/validators/proposal-quality-validators.js +22 -6
- package/dist/commands/proposal/validators/proposal-validators.js +6 -5
- package/dist/commands/proposal/validators/proposals.js +5 -4
- package/dist/commands/read/curate.js +50 -28
- package/dist/commands/read/knowledge.js +25 -16
- package/dist/commands/read/remember-cli.js +12 -4
- package/dist/commands/read/search-cli.js +33 -33
- package/dist/commands/read/search.js +68 -55
- package/dist/commands/read/show.js +54 -135
- package/dist/commands/remember.js +7 -5
- package/dist/commands/sources/add-cli.js +10 -24
- package/dist/commands/sources/bundle-config-ops.js +58 -0
- package/dist/commands/sources/history.js +13 -8
- package/dist/commands/sources/info.js +10 -11
- package/dist/commands/sources/init.js +12 -21
- package/dist/commands/sources/installed-stashes.js +151 -138
- package/dist/commands/sources/schema-repair.js +5 -3
- package/dist/commands/sources/self-update.js +9 -7
- package/dist/commands/sources/source-add.js +116 -154
- package/dist/commands/sources/source-clone.js +33 -14
- package/dist/commands/sources/source-manage.js +43 -32
- package/dist/commands/sources/sources-cli.js +12 -7
- package/dist/commands/sources/stash-cli.js +12 -5
- package/dist/commands/sources/stash-skeleton.js +1 -1
- package/dist/commands/tasks/default-tasks.js +13 -13
- package/dist/commands/tasks/tasks-cli.js +3 -3
- package/dist/commands/tasks/tasks.js +71 -31
- package/dist/commands/workflow-cli.js +22 -26
- package/dist/core/action-contributors.js +1 -1
- package/dist/core/activation-policy.js +49 -0
- package/dist/core/adapter/adapters/agent-skills-adapter.js +181 -0
- package/dist/core/adapter/adapters/akm-adapter.js +509 -0
- package/dist/core/adapter/adapters/akm-lint.js +381 -0
- package/dist/core/adapter/adapters/akm-metadata.js +416 -0
- package/dist/core/adapter/adapters/akm-task-adapter.js +150 -0
- package/dist/core/adapter/adapters/akm-workflow-adapter.js +196 -0
- package/dist/core/adapter/adapters/claude-adapter.js +61 -0
- package/dist/core/adapter/adapters/dotenv-adapter.js +187 -0
- package/dist/core/adapter/adapters/generic-files-adapter.js +117 -0
- package/dist/core/adapter/adapters/index.js +80 -0
- package/dist/core/adapter/adapters/llm-wiki-adapter.js +413 -0
- package/dist/core/adapter/adapters/okf-adapter.js +223 -0
- package/dist/core/adapter/adapters/opencode-adapter.js +68 -0
- package/dist/core/adapter/adapters/shared.js +286 -0
- package/dist/core/adapter/adapters/tool-dir-shared.js +212 -0
- package/dist/core/adapter/adapters/website-snapshot-adapter.js +154 -0
- package/dist/core/adapter/bundle-adapter.js +4 -0
- package/dist/core/adapter/recognize-match.js +42 -0
- package/dist/core/adapter/registry.js +56 -0
- package/dist/core/adapter/types.js +4 -0
- package/dist/core/asset/asset-placement.js +229 -0
- package/dist/core/asset/asset-ref.js +107 -78
- package/dist/core/asset/asset-serialize.js +20 -0
- package/dist/core/asset/frontmatter.js +1 -1
- package/dist/core/asset/resolve-ref.js +223 -0
- package/dist/core/asset/stash-meta.js +1 -1
- package/dist/core/common.js +141 -49
- package/dist/core/config/config-io.js +0 -108
- package/dist/core/config/config-schema.js +94 -1039
- package/dist/core/config/config-sources.js +115 -36
- package/dist/core/config/config-types.js +16 -11
- package/dist/core/config/config-walker.js +4 -2
- package/dist/core/config/config.js +21 -26
- package/dist/core/config/engine-semantics.js +0 -4
- package/dist/core/config/schema/embedding.js +38 -0
- package/dist/core/config/schema/engines.js +116 -0
- package/dist/core/config/schema/feedback.js +31 -0
- package/dist/core/config/schema/improve-processes.js +395 -0
- package/dist/core/config/schema/improve.js +76 -0
- package/dist/core/config/schema/index-config.js +183 -0
- package/dist/core/config/schema/output.js +15 -0
- package/dist/core/config/schema/primitives.js +94 -0
- package/dist/core/config/schema/search.js +30 -0
- package/dist/core/config/schema/setup.js +27 -0
- package/dist/core/config/schema/sources-bundles.js +164 -0
- package/dist/core/config/schema/workflow.js +29 -0
- package/dist/core/env-secret-ref.js +113 -8
- package/dist/core/errors.js +1 -1
- package/dist/core/events-types.js +4 -0
- package/dist/core/extra-params.js +1 -0
- package/dist/core/file-change.js +16 -0
- package/dist/core/fs-txn.js +316 -0
- package/dist/core/git-message.js +59 -0
- package/dist/core/improve-result.js +9 -1
- package/dist/core/logs-db.js +1 -1
- package/dist/core/maintenance-barrier.js +16 -0
- package/dist/core/migration-backup.js +332 -160
- package/dist/core/paths.js +3 -6
- package/dist/core/platform.js +10 -0
- package/dist/core/recognition-util.js +130 -0
- package/dist/core/redaction.js +2 -2
- package/dist/core/standards/resolve-standards-context.js +47 -64
- package/dist/core/standards/resolve-type-conventions.js +3 -3
- package/dist/core/state/migrations.js +201 -8
- package/dist/core/state-db.js +38 -2
- package/dist/core/subprocess.js +303 -0
- package/dist/core/time.js +20 -0
- package/dist/core/type-presentation.js +130 -0
- package/dist/core/write-source.js +39 -67
- package/dist/indexer/bundle-identity-guard.js +91 -0
- package/dist/indexer/db/graph-db.js +1 -1
- package/dist/indexer/db/llm-cache.js +1 -1
- package/dist/indexer/ensure-index.js +29 -9
- package/dist/indexer/graph/graph-boost.js +28 -24
- package/dist/indexer/graph/graph-extraction.js +5 -6
- package/dist/indexer/graph/graph-types.js +4 -0
- package/dist/indexer/index-written-assets.js +44 -17
- package/dist/indexer/indexer.js +289 -153
- package/dist/indexer/init.js +18 -25
- package/dist/indexer/installations.js +224 -0
- package/dist/indexer/passes/dir-staleness.js +2 -1
- package/dist/indexer/passes/memory-inference.js +8 -4
- package/dist/indexer/passes/metadata.js +96 -243
- package/dist/indexer/scan/doc-to-entry.js +123 -0
- package/dist/indexer/scan/drain-dir.js +144 -0
- package/dist/indexer/search/db-search.js +171 -99
- package/dist/indexer/search/fts-query.js +1 -1
- package/dist/indexer/search/ranking-contributors.js +57 -7
- package/dist/indexer/search/ranking-types.js +4 -0
- package/dist/indexer/search/ranking.js +31 -6
- package/dist/indexer/search/search-attribution.js +67 -0
- package/dist/indexer/search/search-hit-enrichers.js +30 -40
- package/dist/indexer/search/search-source.js +109 -52
- package/dist/indexer/search/semantic-status.js +4 -1
- package/dist/indexer/usage/unmigrated-vaults-guard.js +2 -1
- package/dist/indexer/usage/usage-events.js +72 -9
- package/dist/indexer/walk/file-context.js +1 -44
- package/dist/indexer/walk/matchers.js +16 -32
- package/dist/indexer/walk/path-resolver.js +6 -5
- package/dist/indexer/walk/walker.js +4 -2
- package/dist/integrations/agent/engine-resolution.js +22 -0
- package/dist/integrations/agent/model-aliases.js +1 -1
- package/dist/integrations/agent/prompts.js +35 -11
- package/dist/integrations/agent/spawn.js +41 -270
- package/dist/integrations/harnesses/aider/agent-builder.js +2 -2
- package/dist/integrations/harnesses/aider/index.js +2 -11
- package/dist/integrations/harnesses/amazonq/agent-builder.js +1 -9
- package/dist/integrations/harnesses/amazonq/index.js +3 -16
- package/dist/integrations/harnesses/claude/config-import.js +1 -3
- package/dist/integrations/harnesses/claude/index.js +1 -12
- package/dist/integrations/harnesses/claude/session-log.js +27 -65
- package/dist/integrations/harnesses/codex/agent-builder.js +1 -2
- package/dist/integrations/harnesses/codex/index.js +2 -12
- package/dist/integrations/harnesses/copilot/agent-builder.js +2 -3
- package/dist/integrations/harnesses/copilot/index.js +1 -12
- package/dist/integrations/harnesses/gemini/agent-builder.js +1 -3
- package/dist/integrations/harnesses/gemini/index.js +1 -12
- package/dist/integrations/harnesses/ids.js +24 -0
- package/dist/integrations/harnesses/index.js +27 -2
- package/dist/integrations/harnesses/opencode/config-import.js +1 -3
- package/dist/integrations/harnesses/opencode/index.js +1 -12
- package/dist/integrations/harnesses/opencode/session-log.js +67 -110
- package/dist/integrations/harnesses/opencode-sdk/harness.js +2 -11
- package/dist/integrations/harnesses/openhands/agent-builder.js +3 -3
- package/dist/integrations/harnesses/openhands/index.js +2 -11
- package/dist/integrations/harnesses/pi/agent-builder.js +3 -11
- package/dist/integrations/harnesses/pi/index.js +3 -15
- package/dist/integrations/harnesses/shared.js +17 -0
- package/dist/integrations/harnesses/types.js +37 -2
- package/dist/integrations/lockfile.js +36 -0
- package/dist/integrations/session-logs/index.js +21 -12
- package/dist/integrations/session-logs/provider-base.js +113 -0
- package/dist/llm/client.js +7 -5
- package/dist/llm/embedders/deterministic.js +2 -2
- package/dist/llm/embedders/remote.js +8 -4
- package/dist/llm/graph-extract.js +7 -2
- package/dist/llm/metadata-enhance.js +43 -26
- package/dist/llm/structured-call.js +15 -7
- package/dist/migrate/legacy/config-source-migration.js +223 -0
- package/dist/migrate/legacy/content-migration.js +305 -0
- package/dist/migrate/legacy/legacy-layout.js +779 -0
- package/dist/migrate/legacy/legacy-paths.js +25 -0
- package/dist/migrate/legacy/legacy-stash-json.js +72 -0
- package/dist/migrate/legacy/proposal-fs-import.js +168 -0
- package/dist/migrate/legacy/task-target-ref-migration.js +272 -0
- package/dist/migrate/legacy/three-db-cutover.js +840 -0
- package/dist/migrate/legacy/workflow-migrations-bodies.js +52 -0
- package/dist/migrate/legacy/workflow-migrations-frozen.js +21 -0
- package/dist/migrate/legacy-ref-grammar.js +209 -0
- package/dist/output/command-registry.js +27 -0
- package/dist/output/html-render.js +11 -16
- package/dist/output/renderers.js +32 -276
- package/dist/output/shapes/passthrough.js +3 -9
- package/dist/output/shapes/registry.js +12 -6
- package/dist/output/text/command-format.js +547 -0
- package/dist/output/text/helpers.js +15 -1377
- package/dist/output/text/proposal-format.js +230 -0
- package/dist/output/text/registry.js +12 -6
- package/dist/output/text/show-directives.js +107 -0
- package/dist/output/text/show-format.js +103 -0
- package/dist/output/text/workflow-format.js +345 -0
- package/dist/output/text.js +1 -3
- package/dist/registry/build-index.js +13 -17
- package/dist/registry/providers/static-index.js +2 -2
- package/dist/registry/resolve.js +4 -90
- package/dist/registry/semver.js +93 -0
- package/dist/runtime.js +90 -0
- package/dist/schemas/akm-config.json +2956 -14890
- package/dist/schemas/akm-task.json +2 -2
- package/dist/schemas/akm-workflow.json +2 -2
- package/dist/scripts/migrate-storage.js +2312 -19642
- package/dist/setup/detect.js +5 -7
- package/dist/setup/engine-config.js +2 -1
- package/dist/setup/registry-stash-loader.js +1 -1
- package/dist/setup/semantic-assets.js +12 -9
- package/dist/setup/setup.js +109 -39
- package/dist/setup/steps/connection-shared.js +120 -0
- package/dist/setup/steps/connection.js +50 -274
- package/dist/setup/steps/platforms.js +1 -0
- package/dist/setup/steps/sources.js +13 -6
- package/dist/setup/steps/stashdir.js +5 -2
- package/dist/sources/freshness.js +39 -0
- package/dist/sources/providers/git-provider.js +29 -33
- package/dist/sources/providers/git-stash.js +10 -5
- package/dist/sources/providers/provider-utils.js +40 -18
- package/dist/sources/providers/website.js +1 -1
- package/dist/sources/resolve.js +5 -5
- package/dist/sources/snapshot-fetchers/types.js +4 -0
- package/dist/sources/{website-ingest.js → snapshot-fetchers/website-ingest.js} +105 -39
- package/dist/storage/database.js +47 -3
- package/dist/storage/engines/sqlite-migrations.js +34 -16
- package/dist/storage/locations.js +1 -2
- package/dist/storage/repositories/improve-runs-repository.js +0 -20
- package/dist/storage/repositories/index-connection.js +80 -0
- package/dist/storage/repositories/index-db.js +4 -3
- package/dist/storage/repositories/index-entries-repository.js +952 -0
- package/dist/{indexer/db/entry-mapper.js → storage/repositories/index-entry-mapper.js} +15 -2
- package/dist/storage/repositories/index-entry-types.js +4 -0
- package/dist/storage/repositories/index-fts-repository.js +164 -0
- package/dist/storage/repositories/index-llm-cache-repository.js +109 -0
- package/dist/storage/repositories/index-meta-repository.js +50 -0
- package/dist/{indexer/db/schema.js → storage/repositories/index-schema.js} +241 -100
- package/dist/storage/repositories/index-sql.js +12 -0
- package/dist/storage/repositories/index-utility-repository.js +369 -0
- package/dist/storage/repositories/index-vec-repository.js +245 -0
- package/dist/storage/repositories/proposals-repository.js +41 -50
- package/dist/storage/repositories/registry-cache.js +1 -1
- package/dist/storage/repositories/workflow-runs-repository.js +17 -11
- package/dist/tasks/backends/cron.js +5 -5
- package/dist/tasks/backends/exec-utils.js +21 -0
- package/dist/tasks/backends/index.js +6 -9
- package/dist/tasks/backends/launchd.js +16 -17
- package/dist/tasks/backends/schtasks.js +33 -41
- package/dist/tasks/backends/types.js +4 -0
- package/dist/tasks/parser.js +25 -5
- package/dist/tasks/runner.js +33 -39
- package/dist/tasks/validator.js +5 -6
- package/dist/workflows/authoring/authoring.js +8 -11
- package/dist/workflows/exec/brief.js +10 -7
- package/dist/workflows/exec/report.js +261 -156
- package/dist/workflows/exec/run-workflow.js +2 -1
- package/dist/workflows/exec/step-work.js +3 -9
- package/dist/workflows/program/parser.js +4 -60
- package/dist/workflows/renderer.js +11 -60
- package/dist/workflows/runtime/checkin.js +1 -1
- package/dist/workflows/runtime/plan-classifier.js +7 -4
- package/dist/workflows/runtime/runs.js +11 -10
- package/dist/workflows/runtime/unit-checkin.js +1 -1
- package/dist/workflows/runtime/unit-phases.js +20 -0
- package/dist/workflows/runtime/workflow-asset-loader.js +27 -16
- package/dist/workflows/validate-summary.js +2 -2
- package/dist/workflows/validator.js +18 -2
- package/docs/migration/release-notes/0.9.0.md +45 -3
- package/docs/migration/v0.8-to-v0.9.md +466 -262
- package/docs/{data-and-telemetry.md → reference/data-and-telemetry.md} +61 -17
- package/package.json +10 -9
- package/schemas/akm-config.json +2956 -14890
- package/schemas/akm-task.json +2 -2
- package/schemas/akm-workflow.json +2 -2
- package/dist/assets/help/help-accept.md +0 -12
- package/dist/assets/help/help-improve.md +0 -84
- package/dist/assets/help/help-proposals.md +0 -17
- package/dist/assets/help/help-propose.md +0 -17
- package/dist/assets/help/help-reject.md +0 -11
- package/dist/assets/improve-strategies/recombine-only.json +0 -23
- package/dist/assets/improve-strategies/synthesize.json +0 -17
- package/dist/assets/prompts/procedural-system.md +0 -44
- package/dist/assets/prompts/recombine-system.md +0 -40
- package/dist/assets/prompts/staleness-detect-system.md +0 -6
- package/dist/assets/templates/html/default.html +0 -78
- package/dist/assets/templates/html/vendor/echarts.min.js +0 -45
- package/dist/assets/wiki/index-template.md +0 -12
- package/dist/assets/wiki/ingest-workflow-template.md +0 -83
- package/dist/assets/wiki/log-template.md +0 -8
- package/dist/assets/wiki/schema-template.md +0 -61
- package/dist/commands/improve/calibration.js +0 -161
- package/dist/commands/improve/dedup.js +0 -482
- package/dist/commands/improve/hot-probation.js +0 -45
- package/dist/commands/improve/improve-auto-accept.js +0 -262
- package/dist/commands/improve/procedural.js +0 -403
- package/dist/commands/improve/recombine.js +0 -843
- package/dist/commands/improve/schema-similarity-gate.js +0 -168
- package/dist/commands/lint/agent-linter.js +0 -44
- package/dist/commands/lint/command-linter.js +0 -44
- package/dist/commands/lint/default-linter.js +0 -16
- package/dist/commands/lint/fact-linter.js +0 -39
- package/dist/commands/lint/knowledge-linter.js +0 -16
- package/dist/commands/lint/memory-linter.js +0 -61
- package/dist/commands/lint/registry.js +0 -41
- package/dist/commands/lint/skill-linter.js +0 -45
- package/dist/commands/lint/task-linter.js +0 -50
- package/dist/commands/lint/workflow-linter.js +0 -81
- package/dist/commands/proposal/legacy-import.js +0 -115
- package/dist/commands/wiki-cli.js +0 -291
- package/dist/core/asset/asset-registry.js +0 -76
- package/dist/core/asset/asset-spec.js +0 -316
- package/dist/core/eval/rank-metrics.js +0 -113
- package/dist/core/ripgrep/install.js +0 -163
- package/dist/core/ripgrep/resolve.js +0 -81
- package/dist/indexer/db/db.js +0 -1585
- package/dist/indexer/manifest.js +0 -170
- package/dist/indexer/passes/metadata-contributors.js +0 -31
- package/dist/integrations/harnesses/opencode-sdk/index.js +0 -25
- package/dist/output/text/wiki.js +0 -16
- package/dist/scripts/migrations/import-fs-improve-runs-to-db.js +0 -18228
- package/dist/scripts/migrations/v16-to-v17.js +0 -141
- package/dist/storage/repositories/consolidation-repository.js +0 -38
- package/dist/storage/repositories/recombine-repository.js +0 -213
- package/dist/wiki/wiki-templates.js +0 -15
- package/dist/wiki/wiki.js +0 -1013
- package/dist/workflows/db.js +0 -413
- package/docs/README.md +0 -103
- package/docs/migration/release-notes/0.9.0-beta.60.md +0 -19
- /package/dist/sources/{wiki-fetchers → snapshot-fetchers}/registry.js +0 -0
- /package/dist/sources/{wiki-fetchers → snapshot-fetchers}/youtube.js +0 -0
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
4
|
+
/**
|
|
5
|
+
* Single-parse argv normalization (plan §10.7, chunk-9 WI-9.9).
|
|
6
|
+
*
|
|
7
|
+
* Before this module, ~46 `process.argv` read sites were scattered across
|
|
8
|
+
* `src/**` (32 outside `src/cli.ts`), each re-scanning the raw argv array for
|
|
9
|
+
* repeated flags (`parseAllFlagValues`), `--`-passthrough tails (`env run`,
|
|
10
|
+
* `secret run`), or first-occurrence flag values (`parseFlagValue`) — plus a
|
|
11
|
+
* startup MUTATION of the global `process.argv` at `cli.ts:644`. This module
|
|
12
|
+
* normalizes argv into one typed {@link ParsedInvocation} object, minted ONCE
|
|
13
|
+
* by `src/cli.ts` right after its `normalizeShowArgv` rewrite, so every
|
|
14
|
+
* downstream reader shares one parse instead of re-scanning the raw array.
|
|
15
|
+
*
|
|
16
|
+
* Deliberately import-free: this module must never join an import cycle
|
|
17
|
+
* (cycle ratchet, plan §10.7 / chunk-9 D.3), so it depends on nothing but
|
|
18
|
+
* global `process` — no `output/context`, no `core/errors`. The flag-parsing
|
|
19
|
+
* primitives below are intentionally small, self-contained re-implementations
|
|
20
|
+
* of the same algorithms `output/context.ts`'s `parseFlagValue`/
|
|
21
|
+
* `hasBooleanFlag` and (the now-retired) `cli/shared.ts` `parseAllFlagValues`
|
|
22
|
+
* used, kept byte-identical so every converted call site is behavior-
|
|
23
|
+
* preserving.
|
|
24
|
+
*
|
|
25
|
+
* Singleton + fallback semantics (the design decision this module encodes):
|
|
26
|
+
* - `setParsedInvocation(argv)` is called exactly once, by `src/cli.ts`,
|
|
27
|
+
* immediately after `process.argv = normalizeShowArgv(process.argv)`. It
|
|
28
|
+
* snapshots that argv into an immutable {@link ParsedInvocation} that
|
|
29
|
+
* every subsequent `getParsedInvocation()` call returns unchanged for the
|
|
30
|
+
* rest of the process lifetime — "normalize argv exactly once at entry".
|
|
31
|
+
* - `getParsedInvocation()` is the ONLY way leaf command modules read
|
|
32
|
+
* invocation state. When the singleton was never set — the common case
|
|
33
|
+
* for unit tests that call command logic directly, and for
|
|
34
|
+
* `tests/_helpers/cli.ts`'s in-process CLI harness, which drives citty's
|
|
35
|
+
* `runCommand` WITHOUT running `src/cli.ts`'s `import.meta.main` startup
|
|
36
|
+
* block (see that file's docstring) — it falls back to parsing the
|
|
37
|
+
* CURRENT `process.argv` fresh, on every call, uncached. That harness
|
|
38
|
+
* mutates `process.argv` itself per invocation and restores it in
|
|
39
|
+
* `finally`, and many suites issue several back-to-back in-process runs
|
|
40
|
+
* per test; caching the fallback parse would leak one run's flags into
|
|
41
|
+
* the next. So "lazily parses process.argv once" means "once PER CALL",
|
|
42
|
+
* not "once for the life of the process" — the fallback is intentionally
|
|
43
|
+
* request-scoped, mirroring how every pre-WI-9.9 leaf site read
|
|
44
|
+
* `process.argv` fresh at call time. Production code never touches the
|
|
45
|
+
* fallback path: the real entry point sets the singleton before any
|
|
46
|
+
* command handler can run.
|
|
47
|
+
* - `_resetParsedInvocationForTests()` clears an explicitly-set singleton
|
|
48
|
+
* (symmetry with `resetOutputMode`/`resetConfigCache` in
|
|
49
|
+
* `tests/_helpers/cli.ts`); no suite currently needs it because the
|
|
50
|
+
* startup block that calls `setParsedInvocation` never runs under
|
|
51
|
+
* `bun test`, but it exists so a test that DOES call
|
|
52
|
+
* `setParsedInvocation` directly can clean up after itself.
|
|
53
|
+
*
|
|
54
|
+
* Also folds three argv re-scanners that pre-dated this module (plan §10.7):
|
|
55
|
+
* - `parseAllFlagValues` (moved from `cli/shared.ts`) — repeated-flag
|
|
56
|
+
* collection (`--tag foo --tag bar`), re-exported from `cli/shared.ts` so
|
|
57
|
+
* every existing importer (feedback-cli, observability-cli, remember-cli,
|
|
58
|
+
* search-cli, stash-cli, cli.ts) is unaffected.
|
|
59
|
+
* - `findCittyTopLevelCommand`/`findCittyTopLevelCommandIndex` (moved from
|
|
60
|
+
* `cli/parse-args.ts`, which had zero internal imports for this cluster) —
|
|
61
|
+
* re-exported from `cli/parse-args.ts` for `tests/tasks-embedded.test.ts`
|
|
62
|
+
* and `commands/read/show.ts`.
|
|
63
|
+
* - `resolveHelpMigrateVersionArg` (moved from `cli.ts`, where it was
|
|
64
|
+
* private) — the `akm help migrate <version>` positional/flag
|
|
65
|
+
* disambiguation guard.
|
|
66
|
+
*/
|
|
67
|
+
// ── Repeated-flag / `--`-passthrough primitives (byte-identical to the
|
|
68
|
+
// pre-WI-9.9 per-site implementations they replace) ─────────────────────────
|
|
69
|
+
function getFlagValueFrom(argv, flag) {
|
|
70
|
+
for (let i = 0; i < argv.length; i++) {
|
|
71
|
+
const arg = argv[i];
|
|
72
|
+
if (arg === flag)
|
|
73
|
+
return argv[i + 1];
|
|
74
|
+
if (arg.startsWith(`${flag}=`))
|
|
75
|
+
return arg.slice(flag.length + 1);
|
|
76
|
+
}
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
function hasFlagIn(argv, flag) {
|
|
80
|
+
return argv.some((arg) => arg === flag || arg === `${flag}=true`);
|
|
81
|
+
}
|
|
82
|
+
function getAllFlagValuesFrom(argv, flag) {
|
|
83
|
+
const values = [];
|
|
84
|
+
for (let i = 0; i < argv.length; i++) {
|
|
85
|
+
const arg = argv[i];
|
|
86
|
+
if (arg === flag && i + 1 < argv.length) {
|
|
87
|
+
values.push(argv[i + 1]);
|
|
88
|
+
// BUG-M4: skip the value index so `--tag --tag` (literal `--tag` value)
|
|
89
|
+
// does not double-count the second `--tag` as a separate flag occurrence.
|
|
90
|
+
i++;
|
|
91
|
+
}
|
|
92
|
+
else if (arg.startsWith(`${flag}=`)) {
|
|
93
|
+
values.push(arg.slice(flag.length + 1));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return values;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Tokens after a literal `--` marker in argv, or `[]` when there is no `--`
|
|
100
|
+
* OR nothing follows it. Callers that previously threw a "Missing command"
|
|
101
|
+
* UsageError on `dashIndex < 0 || dashIndex === argv.length - 1` now check
|
|
102
|
+
* `passthroughArgs().length === 0` — the two conditions are equivalent.
|
|
103
|
+
*/
|
|
104
|
+
function passthroughArgsFrom(argv) {
|
|
105
|
+
const dashIndex = argv.indexOf("--");
|
|
106
|
+
if (dashIndex < 0 || dashIndex === argv.length - 1)
|
|
107
|
+
return [];
|
|
108
|
+
return argv.slice(dashIndex + 1);
|
|
109
|
+
}
|
|
110
|
+
function createParsedInvocation(argv) {
|
|
111
|
+
const snapshot = Object.freeze([...argv]);
|
|
112
|
+
const userArgs = Object.freeze(snapshot.slice(2));
|
|
113
|
+
return {
|
|
114
|
+
argv: snapshot,
|
|
115
|
+
userArgs,
|
|
116
|
+
getFlagValue: (flag) => getFlagValueFrom(snapshot, flag),
|
|
117
|
+
hasFlag: (flag) => hasFlagIn(snapshot, flag),
|
|
118
|
+
getAllFlagValues: (flag) => getAllFlagValuesFrom(snapshot, flag),
|
|
119
|
+
passthroughArgs: () => passthroughArgsFrom(snapshot),
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
let _invocation;
|
|
123
|
+
/**
|
|
124
|
+
* Mint the process-wide {@link ParsedInvocation} singleton. Called exactly
|
|
125
|
+
* once, by `src/cli.ts`, right after `normalizeShowArgv` — "normalize argv
|
|
126
|
+
* exactly once at entry" (plan §10.7).
|
|
127
|
+
*/
|
|
128
|
+
export function setParsedInvocation(argv) {
|
|
129
|
+
_invocation = createParsedInvocation(argv);
|
|
130
|
+
return _invocation;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Read the process-wide {@link ParsedInvocation}. Returns the singleton set
|
|
134
|
+
* by `setParsedInvocation` when one exists; otherwise falls back to parsing
|
|
135
|
+
* the CURRENT `process.argv` fresh (uncached — see the module docstring for
|
|
136
|
+
* why caching the fallback would be wrong). The fallback is what every
|
|
137
|
+
* leaf-command unit test and `tests/_helpers/cli.ts`'s in-process harness
|
|
138
|
+
* exercise; production CLI runs always hit the singleton.
|
|
139
|
+
*/
|
|
140
|
+
export function getParsedInvocation() {
|
|
141
|
+
if (_invocation)
|
|
142
|
+
return _invocation;
|
|
143
|
+
return createParsedInvocation(process.argv);
|
|
144
|
+
}
|
|
145
|
+
/** Test-only: clear an explicitly-set singleton. Symmetry with resetOutputMode/resetConfigCache. */
|
|
146
|
+
export function _resetParsedInvocationForTests() {
|
|
147
|
+
_invocation = undefined;
|
|
148
|
+
}
|
|
149
|
+
// ── Folded re-scanner #1: parseAllFlagValues (moved from cli/shared.ts) ─────
|
|
150
|
+
/**
|
|
151
|
+
* Collect all occurrences of a repeatable flag from the current invocation's
|
|
152
|
+
* argv. Citty's StringArgDef only exposes the last value when a flag is
|
|
153
|
+
* repeated, so for repeatable CLI args (like `--tag foo --tag bar`) callers
|
|
154
|
+
* read argv directly via this helper. Supports both `--flag value` and
|
|
155
|
+
* `--flag=value` forms.
|
|
156
|
+
*/
|
|
157
|
+
export function parseAllFlagValues(flag) {
|
|
158
|
+
return getParsedInvocation().getAllFlagValues(flag);
|
|
159
|
+
}
|
|
160
|
+
function cittyComparableName(name) {
|
|
161
|
+
return name.replace(/[-_]+([a-zA-Z0-9])/g, (_match, char) => char.toUpperCase());
|
|
162
|
+
}
|
|
163
|
+
function toAliasArray(alias) {
|
|
164
|
+
if (Array.isArray(alias))
|
|
165
|
+
return alias;
|
|
166
|
+
return typeof alias === "string" ? [alias] : [];
|
|
167
|
+
}
|
|
168
|
+
function isCittyValueFlag(flag, argsDef) {
|
|
169
|
+
const name = flag.replace(/^-{1,2}/, "");
|
|
170
|
+
const normalized = cittyComparableName(name);
|
|
171
|
+
for (const [key, def] of Object.entries(argsDef)) {
|
|
172
|
+
if (def.type !== "string" && def.type !== "enum")
|
|
173
|
+
continue;
|
|
174
|
+
if (normalized === cittyComparableName(key))
|
|
175
|
+
return true;
|
|
176
|
+
if (toAliasArray(def.alias).includes(name))
|
|
177
|
+
return true;
|
|
178
|
+
}
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Match citty's top-level subcommand scan (`findSubCommandIndex`).
|
|
183
|
+
*
|
|
184
|
+
* Citty does not assume `rawArgs[0]` is the command: global string flags may
|
|
185
|
+
* appear first and consume the following token. The CLI startup guard uses this
|
|
186
|
+
* to classify the requested command before any command handler can run.
|
|
187
|
+
*/
|
|
188
|
+
export function findCittyTopLevelCommandIndex(rawArgs, argsDef) {
|
|
189
|
+
for (let i = 0; i < rawArgs.length; i += 1) {
|
|
190
|
+
const arg = rawArgs[i];
|
|
191
|
+
if (arg === "--")
|
|
192
|
+
return -1;
|
|
193
|
+
if (arg.startsWith("-")) {
|
|
194
|
+
if (!arg.includes("=") && isCittyValueFlag(arg, argsDef))
|
|
195
|
+
i += 1;
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
return i;
|
|
199
|
+
}
|
|
200
|
+
return -1;
|
|
201
|
+
}
|
|
202
|
+
export function findCittyTopLevelCommand(rawArgs, argsDef) {
|
|
203
|
+
const index = findCittyTopLevelCommandIndex(rawArgs, argsDef);
|
|
204
|
+
return index >= 0 ? rawArgs[index] : undefined;
|
|
205
|
+
}
|
|
206
|
+
// ── Folded re-scanner #3: resolveHelpMigrateVersionArg (moved from cli.ts,
|
|
207
|
+
// where it was a private, unexported function) ──────────────────────────────
|
|
208
|
+
/**
|
|
209
|
+
* Guard against citty consuming a global flag value as the `help migrate`
|
|
210
|
+
* version positional (mirrors `resolveRememberContentArg` /
|
|
211
|
+
* `wasFormatValueConsumedAsName` in the read/sources leaf modules).
|
|
212
|
+
*
|
|
213
|
+
* When the user runs `akm help migrate --format json` without a version
|
|
214
|
+
* argument, citty may assign `"json"` to the `version` positional. This
|
|
215
|
+
* detects that case and returns `undefined` so the caller surfaces the
|
|
216
|
+
* "missing version" UsageError instead of treating a flag value as a version.
|
|
217
|
+
*/
|
|
218
|
+
export function resolveHelpMigrateVersionArg(version) {
|
|
219
|
+
if (version === undefined)
|
|
220
|
+
return undefined;
|
|
221
|
+
const invocation = getParsedInvocation();
|
|
222
|
+
const parsedFormat = invocation.getFlagValue("--format");
|
|
223
|
+
if (parsedFormat !== undefined &&
|
|
224
|
+
version === parsedFormat &&
|
|
225
|
+
wasHelpMigrateFlagValueConsumedAsVersion(version, parsedFormat, "--format")) {
|
|
226
|
+
return undefined;
|
|
227
|
+
}
|
|
228
|
+
const parsedDetail = invocation.getFlagValue("--detail");
|
|
229
|
+
if (parsedDetail !== undefined &&
|
|
230
|
+
version === parsedDetail &&
|
|
231
|
+
wasHelpMigrateFlagValueConsumedAsVersion(version, parsedDetail, "--detail")) {
|
|
232
|
+
return undefined;
|
|
233
|
+
}
|
|
234
|
+
return version;
|
|
235
|
+
}
|
|
236
|
+
function wasHelpMigrateFlagValueConsumedAsVersion(version, flagValue, flagName) {
|
|
237
|
+
const argv = getParsedInvocation().userArgs;
|
|
238
|
+
const helpIndex = argv.indexOf("help");
|
|
239
|
+
const tokens = helpIndex >= 0 ? argv.slice(helpIndex + 1) : argv;
|
|
240
|
+
const migrateIndex = tokens.indexOf("migrate");
|
|
241
|
+
const relevant = migrateIndex >= 0 ? tokens.slice(migrateIndex + 1) : tokens;
|
|
242
|
+
let flagIndex = -1;
|
|
243
|
+
for (let i = 0; i < relevant.length; i += 1) {
|
|
244
|
+
const token = relevant[i];
|
|
245
|
+
if (token === flagName || token === `${flagName}=${flagValue}`) {
|
|
246
|
+
flagIndex = i;
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
if (flagIndex === -1)
|
|
251
|
+
return false;
|
|
252
|
+
if (relevant.slice(0, flagIndex).includes(version))
|
|
253
|
+
return false;
|
|
254
|
+
return relevant[flagIndex] === flagName ? relevant[flagIndex + 1] === version : true;
|
|
255
|
+
}
|
package/dist/cli/parse-args.js
CHANGED
|
@@ -8,52 +8,12 @@
|
|
|
8
8
|
* main CLI file focused on command definitions and routing.
|
|
9
9
|
*/
|
|
10
10
|
import { UsageError } from "../core/errors.js";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return typeof alias === "string" ? [alias] : [];
|
|
18
|
-
}
|
|
19
|
-
function isCittyValueFlag(flag, argsDef) {
|
|
20
|
-
const name = flag.replace(/^-{1,2}/, "");
|
|
21
|
-
const normalized = cittyComparableName(name);
|
|
22
|
-
for (const [key, def] of Object.entries(argsDef)) {
|
|
23
|
-
if (def.type !== "string" && def.type !== "enum")
|
|
24
|
-
continue;
|
|
25
|
-
if (normalized === cittyComparableName(key))
|
|
26
|
-
return true;
|
|
27
|
-
if (toAliasArray(def.alias).includes(name))
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Match citty's top-level subcommand scan (`findSubCommandIndex`).
|
|
34
|
-
*
|
|
35
|
-
* Citty does not assume `rawArgs[0]` is the command: global string flags may
|
|
36
|
-
* appear first and consume the following token. The CLI startup guard uses this
|
|
37
|
-
* to classify the requested command before any command handler can run.
|
|
38
|
-
*/
|
|
39
|
-
export function findCittyTopLevelCommandIndex(rawArgs, argsDef) {
|
|
40
|
-
for (let i = 0; i < rawArgs.length; i += 1) {
|
|
41
|
-
const arg = rawArgs[i];
|
|
42
|
-
if (arg === "--")
|
|
43
|
-
return -1;
|
|
44
|
-
if (arg.startsWith("-")) {
|
|
45
|
-
if (!arg.includes("=") && isCittyValueFlag(arg, argsDef))
|
|
46
|
-
i += 1;
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
return i;
|
|
50
|
-
}
|
|
51
|
-
return -1;
|
|
52
|
-
}
|
|
53
|
-
export function findCittyTopLevelCommand(rawArgs, argsDef) {
|
|
54
|
-
const index = findCittyTopLevelCommandIndex(rawArgs, argsDef);
|
|
55
|
-
return index >= 0 ? rawArgs[index] : undefined;
|
|
56
|
-
}
|
|
11
|
+
import { warn } from "../core/warn.js";
|
|
12
|
+
// findCittyTopLevelCommand(Index) + CittyArg(s)DefinitionForScan moved to
|
|
13
|
+
// ./invocation (chunk-9 WI-9.9 argv-normalization fold — that cluster had no
|
|
14
|
+
// internal imports, so it relocated cleanly); re-exported here so existing
|
|
15
|
+
// importers (tests/tasks-embedded.test.ts, commands/read/show.ts) are unaffected.
|
|
16
|
+
export { findCittyTopLevelCommand, findCittyTopLevelCommandIndex, } from "./invocation.js";
|
|
57
17
|
/**
|
|
58
18
|
* Return true when `args._[0]` is a member of `validSet`.
|
|
59
19
|
*
|
|
@@ -113,49 +73,26 @@ export function parseNonNegativeIntFlag(raw, flagName) {
|
|
|
113
73
|
}
|
|
114
74
|
return parseInt(trimmed, 10);
|
|
115
75
|
}
|
|
116
|
-
// ── Auto-accept flag parsing
|
|
76
|
+
// ── Auto-accept flag parsing (deprecated) ───────────────────────────────────
|
|
117
77
|
/**
|
|
118
|
-
*
|
|
78
|
+
* DEPRECATED (0.9.0): `akm improve --auto-accept` is accepted but ignored.
|
|
119
79
|
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
* - anything else → throws `UsageError("INVALID_FLAG_VALUE")`
|
|
80
|
+
* The confidence gate the flag configured was deleted in 0.9.0 — proposals
|
|
81
|
+
* now queue for review (`akm proposal` / the drain engine) instead of being
|
|
82
|
+
* auto-promoted by threshold. The flag warns-and-ignores for one minor
|
|
83
|
+
* because installed crontabs embed the old command line; a hard parse error
|
|
84
|
+
* would make scheduled background runs fail invisibly after upgrade. Hard
|
|
85
|
+
* removal in 0.10.
|
|
127
86
|
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
* deliberate flip from the earlier 0.8.0-RC behaviour, which defaulted to ON
|
|
132
|
-
* at threshold 90 and surprised users who didn't expect Phase B operations to
|
|
133
|
-
* apply without confirmation.
|
|
134
|
-
*
|
|
135
|
-
* Until proposals expose per-operation confidence scores, any non-`undefined`
|
|
136
|
-
* threshold causes the consolidate path to auto-accept the whole batch
|
|
137
|
-
* (legacy "safe" behaviour). The threshold value is preserved for the eventual
|
|
138
|
-
* per-operation comparison; see the TODO in `consolidate.ts`.
|
|
87
|
+
* - `undefined` (flag absent) → silent no-op.
|
|
88
|
+
* - Any present value (bare flag, `safe`, `false`, a number, garbage) →
|
|
89
|
+
* one deprecation warning on stderr; never throws.
|
|
139
90
|
*/
|
|
140
91
|
export function parseAutoAcceptFlag(raw) {
|
|
141
92
|
if (raw === undefined)
|
|
142
|
-
return
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
return undefined;
|
|
146
|
-
const lower = trimmed.toLowerCase();
|
|
147
|
-
if (lower === "false")
|
|
148
|
-
return undefined;
|
|
149
|
-
if (lower === "safe")
|
|
150
|
-
return 90;
|
|
151
|
-
if (!/^\d+$/.test(trimmed)) {
|
|
152
|
-
throw new UsageError(`Invalid --auto-accept value: "${raw}". Must be an integer 0-100, 'safe', or 'false'.`, "INVALID_FLAG_VALUE");
|
|
153
|
-
}
|
|
154
|
-
const parsed = parseInt(trimmed, 10);
|
|
155
|
-
if (parsed < 0 || parsed > 100) {
|
|
156
|
-
throw new UsageError(`Invalid --auto-accept value: "${raw}". Must be an integer 0-100, 'safe', or 'false'.`, "INVALID_FLAG_VALUE");
|
|
157
|
-
}
|
|
158
|
-
return parsed;
|
|
93
|
+
return;
|
|
94
|
+
warn("[improve] --auto-accept is deprecated and ignored (the 0.9.0 confidence gate was removed; " +
|
|
95
|
+
"proposals queue for review via `akm proposal` or the drain engine). The flag will be removed in 0.10.");
|
|
159
96
|
}
|
|
160
97
|
// ── String flag parsing ──────────────────────────────────────────────────────
|
|
161
98
|
/**
|
package/dist/cli/shared.js
CHANGED
|
@@ -10,12 +10,14 @@
|
|
|
10
10
|
import { defineCommand } from "citty";
|
|
11
11
|
import { stringify as yamlStringify } from "yaml";
|
|
12
12
|
import { assertNever } from "../core/assert.js";
|
|
13
|
-
import { AkmError } from "../core/errors.js";
|
|
13
|
+
import { AkmError, UsageError } from "../core/errors.js";
|
|
14
14
|
import { getOutputMode } from "../output/context.js";
|
|
15
|
-
import {
|
|
15
|
+
import { deliverRendered } from "../output/html-render.js";
|
|
16
16
|
import { shapeForCommand } from "../output/shapes.js";
|
|
17
17
|
import { formatPlain, outputJsonl } from "../output/text.js";
|
|
18
|
+
import { parseAllFlagValues } from "./invocation.js";
|
|
18
19
|
import { hasSubcommand } from "./parse-args.js";
|
|
20
|
+
export { parseAllFlagValues };
|
|
19
21
|
// ── Exit codes ───────────────────────────────────────────────────────────────
|
|
20
22
|
/**
|
|
21
23
|
* Canonical process exit-code table for the akm CLI. Single source of truth —
|
|
@@ -171,40 +173,16 @@ export function output(command, result) {
|
|
|
171
173
|
// pipelines never get an empty stdout.
|
|
172
174
|
deliverRendered(JSON.stringify(shaped, null, 2), mode.outputPath);
|
|
173
175
|
return;
|
|
174
|
-
case "html":
|
|
175
|
-
//
|
|
176
|
-
//
|
|
177
|
-
//
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
});
|
|
183
|
-
deliverRendered(html, mode.outputPath);
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Collect all occurrences of a repeatable flag from process.argv.
|
|
190
|
-
* Citty's StringArgDef only exposes the last value when a flag is repeated,
|
|
191
|
-
* so for repeatable CLI args (like `--tag foo --tag bar`) we read argv directly.
|
|
192
|
-
* Supports both `--flag value` and `--flag=value` forms.
|
|
193
|
-
*/
|
|
194
|
-
export function parseAllFlagValues(flag) {
|
|
195
|
-
const values = [];
|
|
196
|
-
for (let i = 0; i < process.argv.length; i++) {
|
|
197
|
-
const arg = process.argv[i];
|
|
198
|
-
if (arg === flag && i + 1 < process.argv.length) {
|
|
199
|
-
values.push(process.argv[i + 1]);
|
|
200
|
-
// BUG-M4: skip the value index so `--tag --tag` (literal `--tag`
|
|
201
|
-
// value) does not double-count the second `--tag` as a separate
|
|
202
|
-
// flag occurrence.
|
|
203
|
-
i++;
|
|
204
|
-
}
|
|
205
|
-
else if (arg.startsWith(`${flag}=`)) {
|
|
206
|
-
values.push(arg.slice(flag.length + 1));
|
|
207
|
-
}
|
|
176
|
+
case "html":
|
|
177
|
+
// `akm health` intercepts `mode.format === "html"` before reaching
|
|
178
|
+
// output() (cli.ts, same as the `md` intercept) and renders its own
|
|
179
|
+
// bespoke template. Every other command has no HTML surface — the
|
|
180
|
+
// generic JSON-in-<pre> fallback template was removed (chunk-9 WI-9.4c
|
|
181
|
+
// / Decision 4); `html` stays a valid --format value (OUTPUT_FORMATS),
|
|
182
|
+
// it just only resolves for health.
|
|
183
|
+
throw new UsageError("html output is only available for `akm health`", "INVALID_FLAG_VALUE");
|
|
208
184
|
}
|
|
209
|
-
return values;
|
|
210
185
|
}
|
|
186
|
+
// parseAllFlagValues moved to ./invocation (chunk-9 WI-9.9 argv-normalization
|
|
187
|
+
// fold); re-exported above so every existing importer of this module is
|
|
188
|
+
// unaffected.
|
package/dist/cli.js
CHANGED
|
@@ -2,24 +2,22 @@
|
|
|
2
2
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
3
3
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
4
|
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
5
|
-
// Runtime guard: the akm-cli npm package bootstraps with Node.js >=
|
|
5
|
+
// Runtime guard: the akm-cli npm package bootstraps with Node.js >= 22
|
|
6
6
|
// (#465, #560), then its launcher prefers a working Bun >= 1.0 when available.
|
|
7
7
|
// The runtime boundary (src/runtime.ts, src/storage/database.ts) supports both.
|
|
8
8
|
// Under Node the CLI must be launched via the
|
|
9
9
|
// `dist/cli-node.mjs` wrapper, which registers the text-import loader hook
|
|
10
10
|
// before this module graph loads; running `node dist/cli.js` directly still
|
|
11
11
|
// works for code paths that touch no embedded text asset, but the wrapper is
|
|
12
|
-
// the supported entry. The hard floor is Node 20
|
|
12
|
+
// the supported entry. The hard floor is Node 22 (Node 20 support dropped 2026-07; `@clack/core` imports
|
|
13
13
|
// `node:util`'s `styleText` (added in Node 20.12) — Node 18 (EOL) throws at import.
|
|
14
14
|
{
|
|
15
15
|
const isBun = typeof globalThis.Bun !== "undefined";
|
|
16
16
|
if (!isBun) {
|
|
17
|
-
const [major = 0
|
|
18
|
-
|
|
19
|
-
.map((part) => Number.parseInt(part, 10) || 0);
|
|
20
|
-
const nodeOk = major > 20 || (major === 20 && (minor > 12 || (minor === 12 && patch >= 0)));
|
|
17
|
+
const [major = 0] = (process.versions.node ?? "0").split(".").map((part) => Number.parseInt(part, 10) || 0);
|
|
18
|
+
const nodeOk = major >= 22;
|
|
21
19
|
if (!nodeOk) {
|
|
22
|
-
console.error("\n ERROR: the akm-cli npm package requires Node.js >=
|
|
20
|
+
console.error("\n ERROR: the akm-cli npm package requires Node.js >= 22.\n" +
|
|
23
21
|
` Detected Node.js ${process.versions.node ?? "unknown"}.\n` +
|
|
24
22
|
" Bun >= 1.0 is optional for execution; it does not replace the Node.js bootstrap.\n" +
|
|
25
23
|
" Upgrade Node.js (https://nodejs.org), or install the runtime-free standalone binary:\n" +
|
|
@@ -60,10 +58,11 @@ process.on("uncaughtException", (err) => {
|
|
|
60
58
|
import fs from "node:fs";
|
|
61
59
|
import path from "node:path";
|
|
62
60
|
import { defineCommand, runMain } from "citty";
|
|
63
|
-
import { findCittyTopLevelCommand, findCittyTopLevelCommandIndex } from "./cli/
|
|
64
|
-
import { EXIT_CODES, emitJsonError, output,
|
|
61
|
+
import { findCittyTopLevelCommand, findCittyTopLevelCommandIndex, parseAllFlagValues, resolveHelpMigrateVersionArg, setParsedInvocation, } from "./cli/invocation.js";
|
|
62
|
+
import { EXIT_CODES, emitJsonError, output, runWithJsonErrors } from "./cli/shared.js";
|
|
65
63
|
import { agentCommand, lintCommand, proposeCommand } from "./commands/agent/contribute-cli.js";
|
|
66
64
|
import { backupCommand } from "./commands/backup-cli.js";
|
|
65
|
+
import { bundleCommand } from "./commands/bundle/bundle-cli.js";
|
|
67
66
|
import { generateBashCompletions, installBashCompletions } from "./commands/completions.js";
|
|
68
67
|
import { configCommand } from "./commands/config-cli.js";
|
|
69
68
|
import { envCommand } from "./commands/env/env-cli.js";
|
|
@@ -88,7 +87,6 @@ import { renderMigrationHelp } from "./commands/sources/migration-help.js";
|
|
|
88
87
|
import { cloneCommand, historyCommand, listCommand, removeCommand, syncCommand, updateCommand, upgradeCommand, } from "./commands/sources/sources-cli.js";
|
|
89
88
|
import { importKnowledgeCommand, indexCommand, infoCommand, initCommand } from "./commands/sources/stash-cli.js";
|
|
90
89
|
import { tasksCommand } from "./commands/tasks/tasks-cli.js";
|
|
91
|
-
import { wikiCommand } from "./commands/wiki-cli.js";
|
|
92
90
|
import { workflowCommand } from "./commands/workflow-cli.js";
|
|
93
91
|
import { bestEffort } from "./core/best-effort.js";
|
|
94
92
|
import { DEFAULT_CONFIG, loadConfig } from "./core/config/config.js";
|
|
@@ -98,7 +96,7 @@ import { getCacheDir, getConfigPath, getDbPath } from "./core/paths.js";
|
|
|
98
96
|
import { plainize } from "./core/tty.js";
|
|
99
97
|
import { info, isQuiet, setQuiet, setVerbose, warn } from "./core/warn.js";
|
|
100
98
|
import { disposeDispatchResources } from "./integrations/agent/runner-dispatch.js";
|
|
101
|
-
import { getHyphenatedBoolean, getOutputMode, initOutputMode
|
|
99
|
+
import { getHyphenatedBoolean, getOutputMode, initOutputMode } from "./output/context.js";
|
|
102
100
|
import { deliverRendered, renderHtml, resolveTemplatePath } from "./output/html-render.js";
|
|
103
101
|
import { pkgVersion } from "./version.js";
|
|
104
102
|
function applyEarlyStderrFlags(argv) {
|
|
@@ -109,43 +107,9 @@ function applyEarlyStderrFlags(argv) {
|
|
|
109
107
|
setVerbose(true);
|
|
110
108
|
}
|
|
111
109
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
const parsedFormat = parseFlagValue(process.argv, "--format");
|
|
116
|
-
if (parsedFormat !== undefined &&
|
|
117
|
-
version === parsedFormat &&
|
|
118
|
-
wasHelpMigrateFlagValueConsumedAsVersion(version, parsedFormat, "--format")) {
|
|
119
|
-
return undefined;
|
|
120
|
-
}
|
|
121
|
-
const parsedDetail = parseFlagValue(process.argv, "--detail");
|
|
122
|
-
if (parsedDetail !== undefined &&
|
|
123
|
-
version === parsedDetail &&
|
|
124
|
-
wasHelpMigrateFlagValueConsumedAsVersion(version, parsedDetail, "--detail")) {
|
|
125
|
-
return undefined;
|
|
126
|
-
}
|
|
127
|
-
return version;
|
|
128
|
-
}
|
|
129
|
-
function wasHelpMigrateFlagValueConsumedAsVersion(version, flagValue, flagName) {
|
|
130
|
-
const argv = process.argv.slice(2);
|
|
131
|
-
const helpIndex = argv.indexOf("help");
|
|
132
|
-
const tokens = helpIndex >= 0 ? argv.slice(helpIndex + 1) : argv;
|
|
133
|
-
const migrateIndex = tokens.indexOf("migrate");
|
|
134
|
-
const relevant = migrateIndex >= 0 ? tokens.slice(migrateIndex + 1) : tokens;
|
|
135
|
-
let flagIndex = -1;
|
|
136
|
-
for (let i = 0; i < relevant.length; i += 1) {
|
|
137
|
-
const token = relevant[i];
|
|
138
|
-
if (token === flagName || token === `${flagName}=${flagValue}`) {
|
|
139
|
-
flagIndex = i;
|
|
140
|
-
break;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
if (flagIndex === -1)
|
|
144
|
-
return false;
|
|
145
|
-
if (relevant.slice(0, flagIndex).includes(version))
|
|
146
|
-
return false;
|
|
147
|
-
return relevant[flagIndex] === flagName ? relevant[flagIndex + 1] === version : true;
|
|
148
|
-
}
|
|
110
|
+
// resolveHelpMigrateVersionArg moved to ./cli/invocation (chunk-9 WI-9.9
|
|
111
|
+
// argv-normalization fold — it re-scanned process.argv, same as
|
|
112
|
+
// findCittyTopLevelCommand and parseAllFlagValues below).
|
|
149
113
|
/**
|
|
150
114
|
* Stderr-only human-friendly hint after a non-interactive `setup` invocation.
|
|
151
115
|
* Default --format is `json`, so a CI or piped consumer sees only the JSON on
|
|
@@ -504,6 +468,7 @@ export const main = defineCommand({
|
|
|
504
468
|
health: healthCommand,
|
|
505
469
|
info: infoCommand,
|
|
506
470
|
graph: graphCommand,
|
|
471
|
+
bundle: bundleCommand,
|
|
507
472
|
add: addCommand,
|
|
508
473
|
list: listCommand,
|
|
509
474
|
remove: removeCommand,
|
|
@@ -537,7 +502,6 @@ export const main = defineCommand({
|
|
|
537
502
|
completions: completionsCommand,
|
|
538
503
|
env: envCommand,
|
|
539
504
|
secret: secretCommand,
|
|
540
|
-
wiki: wikiCommand,
|
|
541
505
|
tasks: tasksCommand,
|
|
542
506
|
},
|
|
543
507
|
});
|
|
@@ -590,6 +554,11 @@ if (import.meta.main || process.env.AKM_NODE_ENTRY === "1") {
|
|
|
590
554
|
// citty reads process.argv directly and does not accept a custom argv array,
|
|
591
555
|
// so we must replace process.argv with the normalized version before runMain.
|
|
592
556
|
process.argv = normalizeShowArgv(process.argv);
|
|
557
|
+
// Mint the ParsedInvocation singleton from the (normalized) argv — the ONE
|
|
558
|
+
// place argv is parsed for the whole process (plan §10.7 / chunk-9 WI-9.9).
|
|
559
|
+
// Every out-of-cli.ts command module reads argv state through
|
|
560
|
+
// `getParsedInvocation()` from here on instead of re-scanning process.argv.
|
|
561
|
+
setParsedInvocation(process.argv);
|
|
593
562
|
// Resolve output mode once at startup from the (normalized) argv and persisted
|
|
594
563
|
// config. All subsequent output() calls read from this in-memory singleton.
|
|
595
564
|
// `initOutputMode` can throw a UsageError when --format/--detail values are
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* filled from the extra positional args in order.
|
|
15
15
|
*/
|
|
16
16
|
import fs from "node:fs";
|
|
17
|
-
import {
|
|
17
|
+
import { parseRefInput } from "../../core/asset/resolve-ref.js";
|
|
18
18
|
import { NotFoundError, UsageError } from "../../core/errors.js";
|
|
19
19
|
import { resolveEngine } from "../../integrations/agent/engine-resolution.js";
|
|
20
20
|
import { executeRunner } from "../../integrations/agent/runner-dispatch.js";
|
|
@@ -39,7 +39,7 @@ function fillPlaceholders(template, args) {
|
|
|
39
39
|
async function resolveAssetBody(ref) {
|
|
40
40
|
let parsed;
|
|
41
41
|
try {
|
|
42
|
-
parsed =
|
|
42
|
+
parsed = parseRefInput(ref);
|
|
43
43
|
}
|
|
44
44
|
catch (err) {
|
|
45
45
|
throw new UsageError(`Invalid asset ref "${ref}": ${err instanceof Error ? err.message : String(err)}`, "INVALID_FLAG_VALUE");
|
|
@@ -28,6 +28,7 @@ import { EXIT_CODES, output, runWithJsonErrors } from "../../cli/shared.js";
|
|
|
28
28
|
import { assertFlatAssetName, combineCreatePath, normalizeCreateSubPath } from "../../core/asset/asset-create.js";
|
|
29
29
|
import { loadConfig } from "../../core/config/config.js";
|
|
30
30
|
import { UsageError } from "../../core/errors.js";
|
|
31
|
+
import { resolveUsageEventSource } from "../../indexer/usage/usage-events.js";
|
|
31
32
|
import { akmLint } from "../lint/index.js";
|
|
32
33
|
import { akmPropose } from "../proposal/propose.js";
|
|
33
34
|
import { akmAgentDispatch } from "./agent-dispatch.js";
|
|
@@ -40,13 +41,13 @@ export const agentCommand = defineCommand({
|
|
|
40
41
|
args: {
|
|
41
42
|
"agent-ref": {
|
|
42
43
|
type: "positional",
|
|
43
|
-
description: "Optional agent asset ref (e.g.
|
|
44
|
+
description: "Optional agent asset ref (e.g. agents/code-reviewer). Loads system prompt, model, and tool policy from the stash asset.",
|
|
44
45
|
required: false,
|
|
45
46
|
},
|
|
46
47
|
prompt: { type: "string", description: "Task prompt to pass to the agent" },
|
|
47
48
|
engine: { type: "string", description: "Agent engine to use (default: defaults.engine)" },
|
|
48
|
-
command: { type: "string", description: "Load prompt from a command
|
|
49
|
-
workflow: { type: "string", description: "Load prompt from a workflow
|
|
49
|
+
command: { type: "string", description: "Load prompt from a command asset" },
|
|
50
|
+
workflow: { type: "string", description: "Load prompt from a workflow asset" },
|
|
50
51
|
model: {
|
|
51
52
|
type: "string",
|
|
52
53
|
description: "Model override — accepts aliases (opus, sonnet, haiku) or exact platform model IDs. Overrides the model specified in the agent asset.",
|
|
@@ -69,7 +70,7 @@ export const agentCommand = defineCommand({
|
|
|
69
70
|
let assetTools;
|
|
70
71
|
if (agentRef) {
|
|
71
72
|
const { akmShowUnified } = await import("../read/show.js");
|
|
72
|
-
const asset = await akmShowUnified({ ref: agentRef, detail: "full" });
|
|
73
|
+
const asset = await akmShowUnified({ ref: agentRef, detail: "full", eventSource: resolveUsageEventSource() });
|
|
73
74
|
systemPrompt = typeof asset.content === "string" ? asset.content : undefined;
|
|
74
75
|
assetModel = typeof asset.modelHint === "string" ? asset.modelHint : undefined;
|
|
75
76
|
assetTools = asset.toolPolicy;
|