akm-cli 0.9.31 → 0.10.26101002-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 +265 -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/eligibility.js +14 -1
- package/dist/commands/improve/extract-cli.js +1 -1
- package/dist/commands/improve/improve-cli.js +87 -102
- package/dist/commands/improve/improve-strategies.js +8 -12
- package/dist/commands/improve/improve.js +2 -2
- 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 +11 -31
- 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/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 +41 -11
- 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 +13049 -14013
- package/dist/scripts/akm-migrate.js +16316 -17276
- 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 +1 -1
- package/docs/agents/README.md +3 -3
- package/docs/agents/agent-install.md +1 -1
- package/docs/architecture/adapters.md +17 -31
- package/docs/architecture/architecture.md +4 -5
- package/docs/architecture/improvement.md +52 -21
- package/docs/architecture/internals/improve-workflow.md +15 -8
- package/docs/architecture/internals/indexing.md +1 -1
- package/docs/architecture/internals/search.md +1 -2
- package/docs/architecture/internals/storage-locations.md +5 -5
- package/docs/architecture/persisted-data-compat.md +13 -4
- package/docs/architecture/specs/0.9.0-decisions.md +6 -2
- package/docs/architecture/specs/improve-collapse-churn-detector-design.md +2 -2
- package/docs/architecture/specs/workflow-format-unification.md +1 -6
- package/docs/architecture/testing/manual-testing-checklist.md +20 -29
- package/docs/architecture/testing/task-workflow-manual-tests.md +106 -203
- package/docs/architecture/testing/testing-workflow.md +1 -1
- package/docs/architecture/workflow-engine.md +5 -56
- package/docs/guides/author-workflows.md +39 -69
- package/docs/guides/capture-knowledge.md +1 -1
- package/docs/guides/claude-code-vs-akm-workflows.md +1 -2
- package/docs/guides/discover-and-load.md +4 -4
- package/docs/guides/getting-started.md +1 -1
- package/docs/guides/improve-the-library.md +7 -7
- package/docs/guides/recipes/headless-install.md +2 -2
- package/docs/guides/run-workflows.md +1 -1
- package/docs/guides/use-with-any-agent.md +49 -4
- package/docs/integration/bundling-akm.md +7 -6
- package/docs/maintainers/curate-workmap.md +1 -2
- package/docs/maintainers/release-checklist.md +30 -1
- package/docs/posts/akm-command-tour.md +3 -3
- package/docs/product-surface.md +1 -1
- package/docs/reference/README.md +1 -0
- package/docs/reference/api.md +65 -0
- package/docs/reference/asset-types.md +3 -5
- package/docs/reference/bundle-types.md +2 -4
- package/docs/reference/cli.md +129 -171
- package/docs/reference/configuration.md +84 -19
- package/docs/reference/data-and-telemetry.md +1 -1
- package/docs/reference/env-and-secrets.md +2 -2
- package/docs/reference/supported-formats.md +3 -4
- package/docs/reference/tasks.md +12 -19
- package/docs/reference/website-sources.md +1 -1
- package/docs/reference/workflow-schema.md +89 -317
- package/docs/reference/workflows.md +20 -48
- package/package.json +12 -2
- 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/output/context.js
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* Process-level output mode singleton.
|
|
6
6
|
*
|
|
7
|
-
* Output mode (format + detail
|
|
7
|
+
* Output mode (format + detail, and the agent projection `--detail agent`
|
|
8
|
+
* selects) is parsed once at startup from
|
|
8
9
|
* `process.argv` and the persisted user config. All subsequent `output()`
|
|
9
10
|
* calls read from this in-memory singleton instead of re-scanning argv and
|
|
10
11
|
* re-loading config on every call.
|
|
@@ -15,8 +16,7 @@
|
|
|
15
16
|
*/
|
|
16
17
|
import { UsageError } from "../core/errors.js";
|
|
17
18
|
const OUTPUT_FORMATS = ["json", "yaml", "text", "jsonl", "md", "html"];
|
|
18
|
-
const
|
|
19
|
-
const SHAPE_MODES = ["human", "agent", "summary"];
|
|
19
|
+
const DETAIL_VALUES = ["brief", "normal", "full", "agent"];
|
|
20
20
|
function parseOutputFormat(value) {
|
|
21
21
|
if (!value)
|
|
22
22
|
return undefined;
|
|
@@ -27,16 +27,9 @@ function parseOutputFormat(value) {
|
|
|
27
27
|
export function parseDetailLevel(value) {
|
|
28
28
|
if (!value)
|
|
29
29
|
return undefined;
|
|
30
|
-
if (
|
|
30
|
+
if (DETAIL_VALUES.includes(value))
|
|
31
31
|
return value;
|
|
32
|
-
throw new UsageError(`Invalid value for --detail: ${value}. Expected one of: ${
|
|
33
|
-
}
|
|
34
|
-
function parseShapeMode(value) {
|
|
35
|
-
if (!value)
|
|
36
|
-
return undefined;
|
|
37
|
-
if (SHAPE_MODES.includes(value))
|
|
38
|
-
return value;
|
|
39
|
-
throw new UsageError(`Invalid value for --shape: ${value}. Expected one of: ${SHAPE_MODES.join("|")}`, "INVALID_SHAPE_VALUE");
|
|
32
|
+
throw new UsageError(`Invalid value for --detail: ${value}. Expected one of: ${DETAIL_VALUES.join("|")}`, "INVALID_DETAIL_VALUE");
|
|
40
33
|
}
|
|
41
34
|
export function parseFlagValue(argv, flag) {
|
|
42
35
|
for (let i = 0; i < argv.length; i++) {
|
|
@@ -88,13 +81,11 @@ export function getHyphenatedBoolean(args, key) {
|
|
|
88
81
|
*/
|
|
89
82
|
export function resolveOutputMode(argv, defaults = {}) {
|
|
90
83
|
const format = parseOutputFormat(parseFlagValue(argv, "--format")) ?? defaults?.format ?? "json";
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const detail = parseDetailLevel(rawDetail) ?? defaults?.detail ?? "brief";
|
|
97
|
-
const shape = parseShapeMode(rawShape) ?? "human";
|
|
84
|
+
// `--detail agent` selects the agent projection; the verbosity then stays at
|
|
85
|
+
// the configured default (the projection ignores it).
|
|
86
|
+
const parsedDetail = parseDetailLevel(parseFlagValue(argv, "--detail"));
|
|
87
|
+
const shape = parsedDetail === "agent" ? "agent" : "human";
|
|
88
|
+
const detail = (parsedDetail === "agent" ? undefined : parsedDetail) ?? defaults?.detail ?? "brief";
|
|
98
89
|
const outputPath = parseFlagValue(argv, "--output");
|
|
99
90
|
return { format, detail, shape, ...(outputPath ? { outputPath } : {}) };
|
|
100
91
|
}
|
|
@@ -35,12 +35,11 @@ const EXEMPT_COMMANDS = new Set([
|
|
|
35
35
|
// progress-event lines the child prints during a real `apply` still print
|
|
36
36
|
// verbatim ahead of the formatted result — those are operational logging,
|
|
37
37
|
// not part of the result envelope, the same way a progress spinner would be.
|
|
38
|
-
// Document payload group: bare `help` prints the sectioned overview
|
|
39
|
-
// `help migrate <version>` prints release notes
|
|
40
|
-
//
|
|
41
|
-
// the three render a result envelope.
|
|
38
|
+
// Document payload group: bare `help` prints the sectioned overview and
|
|
39
|
+
// `help migrate <version>` prints release notes — neither renders a result
|
|
40
|
+
// envelope.
|
|
42
41
|
"help",
|
|
43
|
-
// Embedded agent guide document.
|
|
42
|
+
// Embedded agent guide document (`src/output/cli-hints.ts`).
|
|
44
43
|
"hints",
|
|
45
44
|
]);
|
|
46
45
|
/**
|
|
@@ -57,9 +56,7 @@ const EXEMPT_SUBCOMMANDS = new Set([
|
|
|
57
56
|
// envelope. Wrapping it broke every existing substitution silently: the
|
|
58
57
|
// CLI's default format is `json`, so an un-flagged `akm env path <ref>`
|
|
59
58
|
// (exactly how the substitution is always written) started emitting
|
|
60
|
-
// `{"path":"..."}` instead of the raw path.
|
|
61
|
-
// command has no `--all`-style multi-field variant, so the whole surface
|
|
62
|
-
// can be exempt without wrongly warning on a real envelope case.
|
|
59
|
+
// `{"path":"..."}` instead of the raw path.
|
|
63
60
|
"env path",
|
|
64
61
|
]);
|
|
65
62
|
/**
|
|
@@ -310,7 +310,7 @@ export function shapeSearchHit(hit, detail) {
|
|
|
310
310
|
}
|
|
311
311
|
// Stash hit (local or remote)
|
|
312
312
|
// `ref` is included at `brief` so agents can run `akm show <ref>` without
|
|
313
|
-
// needing --detail full or --
|
|
313
|
+
// needing --detail full or --detail agent (REC-03).
|
|
314
314
|
if (detail === "brief") {
|
|
315
315
|
return pickFields(hit, ["type", "name", "ref", "action", "estimatedTokens", "keys"]);
|
|
316
316
|
}
|
|
@@ -393,27 +393,6 @@ export function shapeShowOutput(result, detail, shape = "human") {
|
|
|
393
393
|
delete shaped.editHint;
|
|
394
394
|
return shaped;
|
|
395
395
|
}
|
|
396
|
-
if (shape === "summary") {
|
|
397
|
-
return pickFields(result, [
|
|
398
|
-
"type",
|
|
399
|
-
"name",
|
|
400
|
-
// ref is present on every show shape (human/summary/agent) — it is the
|
|
401
|
-
// canonical identity of the asset, not an agent-only convenience field
|
|
402
|
-
// (R-020).
|
|
403
|
-
"ref",
|
|
404
|
-
"description",
|
|
405
|
-
"tags",
|
|
406
|
-
"parameters",
|
|
407
|
-
"workflowTitle",
|
|
408
|
-
"action",
|
|
409
|
-
"run",
|
|
410
|
-
"origin",
|
|
411
|
-
"keys",
|
|
412
|
-
"links",
|
|
413
|
-
...FRAGMENT_PROVENANCE_FIELDS,
|
|
414
|
-
...FRAGMENT_CONTEXT_FIELDS,
|
|
415
|
-
]);
|
|
416
|
-
}
|
|
417
396
|
const base = pickFields(result, [
|
|
418
397
|
"type",
|
|
419
398
|
"name",
|
package/dist/output/shapes.js
CHANGED
|
@@ -1,23 +1,6 @@
|
|
|
1
1
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
2
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
3
|
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
4
|
-
/**
|
|
5
|
-
* Pure shaping functions that select and trim fields from command result
|
|
6
|
-
* objects according to the active detail level / agent mode.
|
|
7
|
-
*
|
|
8
|
-
* Every function in this module is side-effect free and operates on plain
|
|
9
|
-
* `Record<string, unknown>` shapes, which makes them trivial to unit test.
|
|
10
|
-
*
|
|
11
|
-
* Output shapes are assembled EXPLICITLY here: each per-command module under
|
|
12
|
-
* `src/output/shapes/` EXPORTS a pure `OutputShapeEntry[]` (no top-level
|
|
13
|
-
* side effect), and this barrel imports those exports and registers them in a
|
|
14
|
-
* single deterministic, order-independent pass (`BUILT_IN_OUTPUT_SHAPES`).
|
|
15
|
-
* Dropping a module from the assembly array is a COMPILE error, not a silent
|
|
16
|
-
* runtime gap. The central `shapeForCommand` dispatcher looks up the registry
|
|
17
|
-
* and throws for unknown commands (v1 spec §9 — exhaustive registry, no silent
|
|
18
|
-
* fallback).
|
|
19
|
-
*/
|
|
20
|
-
import { warnOnce } from "../core/warn.js";
|
|
21
4
|
import { curateShapes } from "./shapes/curate.js";
|
|
22
5
|
import { envListShapes } from "./shapes/env-list.js";
|
|
23
6
|
import { eventsShapes } from "./shapes/events.js";
|
|
@@ -64,12 +47,6 @@ const BUILT_IN_OUTPUT_SHAPES = [
|
|
|
64
47
|
...passthroughShapes,
|
|
65
48
|
];
|
|
66
49
|
registerOutputShapes(BUILT_IN_OUTPUT_SHAPES);
|
|
67
|
-
/**
|
|
68
|
-
* Commands whose shape handler implements the `summary` projection. For every
|
|
69
|
-
* other command, `--shape summary` is a usage error (v1 §5 — honest rejection
|
|
70
|
-
* for a soon-frozen contract, not a silent fallback to `human`).
|
|
71
|
-
*/
|
|
72
|
-
const SHAPE_SUMMARY_COMMANDS = new Set(["show"]);
|
|
73
50
|
// ── `results` collection alias ──────────────────────────────────────────────
|
|
74
51
|
//
|
|
75
52
|
// Every list-returning command names its collection differently (`hits`,
|
|
@@ -80,8 +57,8 @@ const SHAPE_SUMMARY_COMMANDS = new Set(["show"]);
|
|
|
80
57
|
//
|
|
81
58
|
// This maps each list-returning command to the field already holding its
|
|
82
59
|
// collection, and `withResultsAlias` below adds a `results` key pointing at
|
|
83
|
-
// that SAME array (not a copy) to the shaped output — in every
|
|
84
|
-
// `--detail` combination, `
|
|
60
|
+
// that SAME array (not a copy) to the shaped output — in every
|
|
61
|
+
// `--detail` combination, `agent` included, so `--detail agent` needs no
|
|
85
62
|
// separate handling to "guarantee" it. A new list-returning command MUST add
|
|
86
63
|
// an entry here; there is no way to detect a missed one automatically, so the
|
|
87
64
|
// survey deliberately lives in this one place rather than scattered per
|
|
@@ -118,14 +95,9 @@ function withResultsAlias(command, shaped) {
|
|
|
118
95
|
return { ...obj, results: collection };
|
|
119
96
|
}
|
|
120
97
|
export function shapeForCommand(command, result, detail, shape = "human") {
|
|
121
|
-
let effectiveShape = shape;
|
|
122
|
-
if (shape === "summary" && !SHAPE_SUMMARY_COMMANDS.has(command)) {
|
|
123
|
-
warnOnce(`shape-summary-unsupported:${command}`, `[output] '--shape summary' is not supported for 'akm ${command}' (only 'akm show' has a summary projection); falling back to 'agent'.`);
|
|
124
|
-
effectiveShape = "agent";
|
|
125
|
-
}
|
|
126
98
|
const handler = getOutputShapeHandler(command);
|
|
127
99
|
if (handler) {
|
|
128
|
-
return withResultsAlias(command, handler(result, detail,
|
|
100
|
+
return withResultsAlias(command, handler(result, detail, shape));
|
|
129
101
|
}
|
|
130
102
|
// v1 spec §9 (output-shape registry exhaustive): no silent JSON.stringify
|
|
131
103
|
// fallback. A missing case here is a registration bug — fail loudly so
|
package/dist/output/stdout.js
CHANGED
|
@@ -20,5 +20,9 @@
|
|
|
20
20
|
* `tests/integration/output-baseline.test.ts` pins the bytes either way.
|
|
21
21
|
*/
|
|
22
22
|
export function writeStdout(document) {
|
|
23
|
-
process.stdout.write(
|
|
23
|
+
process.stdout.write(stdoutText(document));
|
|
24
|
+
}
|
|
25
|
+
/** The exact bytes {@link writeStdout} writes for `document`; in-process callers return this instead of writing. */
|
|
26
|
+
export function stdoutText(document) {
|
|
27
|
+
return `${document}\n`;
|
|
24
28
|
}
|
|
@@ -662,7 +662,12 @@ export function formatUpdatePlain(r) {
|
|
|
662
662
|
}
|
|
663
663
|
return lines.length > 0 ? lines.join("\n") : `update: nothing to update`;
|
|
664
664
|
}
|
|
665
|
-
const HARNESS_LABELS = {
|
|
665
|
+
const HARNESS_LABELS = {
|
|
666
|
+
"claude-code": "Claude Code",
|
|
667
|
+
codex: "Codex",
|
|
668
|
+
opencode: "OpenCode",
|
|
669
|
+
"opencode-v2": "OpenCode 2",
|
|
670
|
+
};
|
|
666
671
|
/** The plugin lines worth printing: nothing for a plugin that is current or has no plugin to update. */
|
|
667
672
|
function formatUpgradePluginLines(r) {
|
|
668
673
|
const lines = [];
|
|
@@ -235,8 +235,7 @@ function formatInputBindingsList(bindings) {
|
|
|
235
235
|
* expansion's own steps, recursively, indented one level per composition
|
|
236
236
|
* boundary. A child step also carries the child's `planHash` on the step
|
|
237
237
|
* line itself, and (when present) a `with:` line for the step's own
|
|
238
|
-
* `inputBindings[]`
|
|
239
|
-
* names — §4.6's worked example.
|
|
238
|
+
* `inputBindings[]` — §4.6's worked example.
|
|
240
239
|
*/
|
|
241
240
|
function renderPlanStepLines(step, ordinal, lines, prefix = " ") {
|
|
242
241
|
const stepId = typeof step.stepId === "string" ? step.stepId : "unknown";
|
|
@@ -244,11 +243,9 @@ function renderPlanStepLines(step, ordinal, lines, prefix = " ") {
|
|
|
244
243
|
const expansion = typeof step.expansion === "object" && step.expansion !== null ? step.expansion : {};
|
|
245
244
|
const via = typeof expansion.via === "string" ? expansion.via : "direct";
|
|
246
245
|
const childPlanHash = typeof expansion.childPlanHash === "string" ? expansion.childPlanHash : undefined;
|
|
247
|
-
const viaText = via === "
|
|
248
|
-
?
|
|
249
|
-
:
|
|
250
|
-
? `-> ${String(expansion.childRef ?? "")}${childPlanHash ? ` (plan ${childPlanHash})` : ""}`
|
|
251
|
-
: "direct";
|
|
246
|
+
const viaText = via === "child"
|
|
247
|
+
? `-> ${String(expansion.childRef ?? "")}${childPlanHash ? ` (plan ${childPlanHash})` : ""}`
|
|
248
|
+
: "direct";
|
|
252
249
|
lines.push(`${prefix}${ordinal}. ${stepId} ${targetKind} ${viaText}`.replace(/ +/g, " ").trimEnd());
|
|
253
250
|
const detailPrefix = `${prefix} `;
|
|
254
251
|
const inputBindings = Array.isArray(step.inputBindings) ? step.inputBindings : [];
|
|
@@ -256,10 +253,6 @@ function renderPlanStepLines(step, ordinal, lines, prefix = " ") {
|
|
|
256
253
|
lines.push(`${detailPrefix}with: ${formatInputBindingsList(inputBindings)}`);
|
|
257
254
|
}
|
|
258
255
|
if (via === "child") {
|
|
259
|
-
const childOutputs = Array.isArray(expansion.childOutputs) ? expansion.childOutputs : [];
|
|
260
|
-
if (childOutputs.length > 0) {
|
|
261
|
-
lines.push(`${detailPrefix}exports: ${childOutputs.map(String).join(", ")}`);
|
|
262
|
-
}
|
|
263
256
|
const childSteps = Array.isArray(expansion.steps) ? expansion.steps : [];
|
|
264
257
|
for (const [index, childStep] of childSteps.entries()) {
|
|
265
258
|
renderPlanStepLines(childStep, index + 1, lines, `${prefix} ${ordinal}.`);
|
|
@@ -304,17 +297,6 @@ export function formatWorkflowPlanPlain(result) {
|
|
|
304
297
|
const params = Array.isArray(result.params) ? result.params : undefined;
|
|
305
298
|
if (params && params.length > 0)
|
|
306
299
|
lines.push(`params: ${params.join(", ")}`);
|
|
307
|
-
const outputs = typeof result.outputs === "object" && result.outputs !== null
|
|
308
|
-
? result.outputs
|
|
309
|
-
: undefined;
|
|
310
|
-
if (outputs) {
|
|
311
|
-
for (const [name, declaration] of Object.entries(outputs)) {
|
|
312
|
-
const from = typeof declaration === "object" && declaration !== null
|
|
313
|
-
? String(declaration.from ?? "")
|
|
314
|
-
: "";
|
|
315
|
-
lines.push(`outputs: ${name} <- ${from}`);
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
300
|
const steps = Array.isArray(result.steps) ? result.steps : [];
|
|
319
301
|
lines.push("steps:");
|
|
320
302
|
for (const [index, step] of steps.entries()) {
|