akm-cli 0.9.2-alpha.4 → 0.9.2
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 +493 -0
- package/STABILITY.md +23 -5
- package/dist/assets/hints/cli-hints-full.md +12 -7
- package/dist/assets/tasks/core/extract.yml +3 -5
- package/dist/assets/tasks/core/improve.yml +3 -5
- package/dist/assets/tasks/core/index-refresh.yml +3 -5
- package/dist/assets/tasks/core/sync.yml +3 -5
- package/dist/assets/tasks/core/version-check.yml +3 -5
- package/dist/assets/tasks/improve/akm-graph-refresh-weekly.yml +3 -5
- package/dist/assets/tasks/improve/akm-improve-catchup.yml +6 -6
- package/dist/assets/tasks/improve/akm-improve-consolidate.yml +3 -5
- package/dist/assets/tasks/improve/akm-improve-frequent.yml +3 -5
- package/dist/assets/tasks/improve/akm-improve-nightly.yml +3 -5
- package/dist/cli/unknown-flags.js +12 -1
- package/dist/cli.js +8 -1
- package/dist/commands/command/command-execution.js +23 -2
- package/dist/commands/health/improve-metrics.js +38 -0
- package/dist/commands/health/windows.js +8 -4
- package/dist/commands/health.js +8 -4
- package/dist/commands/lint/index.js +1 -1
- package/dist/commands/migrate-cli.js +130 -24
- package/dist/commands/proposal/validators/proposal-validators.js +7 -2
- package/dist/commands/tasks/explain.js +304 -0
- package/dist/commands/tasks/tasks-cli.js +185 -3
- package/dist/commands/tasks/tasks.js +265 -52
- package/dist/commands/workflow/plan.js +159 -0
- package/dist/commands/workflow-cli.js +94 -2
- package/dist/core/activation-policy.js +2 -12
- package/dist/core/adapter/adapters/akm-lint.js +7 -4
- package/dist/core/adapter/adapters/akm-metadata.js +26 -14
- package/dist/core/adapter/adapters/akm-task-adapter.js +13 -10
- package/dist/core/errors.js +45 -0
- package/dist/core/json-schema.js +15 -5
- package/dist/core/state/migrations.js +57 -0
- package/dist/core/state-db.js +16 -14
- package/dist/core/subprocess.js +47 -13
- package/dist/execution/guarded-source.js +44 -0
- package/dist/execution/input-contract.js +250 -0
- package/dist/execution/target-ref.js +63 -0
- package/dist/indexer/usage/usage-events.js +14 -3
- package/dist/integrations/agent/execution-lowering.js +12 -1
- package/dist/output/shapes/passthrough.js +2 -0
- package/dist/output/text/helpers.js +1 -1
- package/dist/output/text/migrate.js +12 -3
- package/dist/output/text/workflow-format.js +192 -10
- package/dist/output/text/workflow.js +2 -1
- package/dist/runtime.js +1 -0
- package/dist/scripts/akm-migrate-node.js +11838 -10118
- package/dist/scripts/akm-migrate.js +11828 -10117
- package/dist/setup/steps/tasks.js +34 -17
- package/dist/storage/repositories/task-history-repository.js +5 -1
- package/dist/storage/repositories/workflow-runs-repository.js +144 -6
- package/dist/tasks/backends/launchd.js +31 -84
- package/dist/tasks/embedded.js +13 -7
- package/dist/tasks/model/invocation.js +4 -0
- package/dist/tasks/prepare/prepare-script-target.js +9 -0
- package/dist/tasks/prepare/prepare-support.js +154 -0
- package/dist/tasks/prepare/prepare.js +117 -0
- package/dist/tasks/prepare/prepared-execution.js +4 -0
- package/dist/tasks/prepare/script-capture.js +80 -0
- package/dist/tasks/run/attempt-lifecycle.js +165 -0
- package/dist/tasks/run/load-task.js +117 -0
- package/dist/tasks/run/provenance.js +20 -0
- package/dist/tasks/run/run-command-task.js +92 -0
- package/dist/tasks/run/run-native-task.js +222 -0
- package/dist/tasks/run/run-task.js +99 -0
- package/dist/tasks/run/run-workflow-task.js +222 -0
- package/dist/tasks/run/task-history.js +134 -0
- package/dist/tasks/run/task-log.js +179 -0
- package/dist/tasks/run/task-result.js +19 -0
- package/dist/tasks/scheduler-binding.js +66 -2
- package/dist/tasks/scheduler-invocation.js +63 -3
- package/dist/tasks/scheduler-sync.js +77 -14
- package/dist/tasks/source/bounded-document.js +455 -0
- package/dist/tasks/source/parse-task-source.js +59 -0
- package/dist/tasks/source/project-v4.js +62 -0
- package/dist/tasks/source/task-input-diagnostics.js +36 -0
- package/dist/tasks/source/task-source-v4.js +626 -0
- package/dist/tasks/source-v3.js +10 -733
- package/dist/tasks/task-run-reserved-flags.js +79 -0
- package/dist/workflows/authoring/authoring.js +17 -8
- package/dist/workflows/exec/child-invocation.js +34 -0
- package/dist/workflows/exec/child-workflow.js +370 -0
- package/dist/workflows/exec/exec-unit.js +50 -170
- package/dist/workflows/exec/frozen-judge.js +19 -2
- package/dist/workflows/exec/native-executor.js +49 -27
- package/dist/workflows/exec/param-secrets.js +12 -0
- package/dist/workflows/exec/run-workflow.js +48 -59
- package/dist/workflows/exec/step-work.js +222 -80
- package/dist/workflows/exec/unit-dispatch.js +72 -0
- package/dist/workflows/freeze/child-output-references.js +94 -0
- package/dist/workflows/freeze/environment.js +174 -0
- package/dist/workflows/freeze/identity.js +22 -0
- package/dist/workflows/freeze/resolve-steps.js +78 -0
- package/dist/workflows/freeze/source-freeze.js +57 -0
- package/dist/workflows/freeze/step-values.js +68 -0
- package/dist/workflows/freeze/targets/child-workflow.js +206 -0
- package/dist/workflows/freeze/targets/command.js +81 -0
- package/dist/workflows/freeze/targets/script.js +57 -0
- package/dist/workflows/freeze/targets/shell.js +31 -0
- package/dist/workflows/freeze/targets/task.js +179 -0
- package/dist/workflows/freeze/task-bindings.js +180 -0
- package/dist/workflows/ir/compile.js +59 -11
- package/dist/workflows/ir/environment-v4.js +3 -3
- package/dist/workflows/ir/freeze-v4.js +41 -7
- package/dist/workflows/ir/params.js +58 -131
- package/dist/workflows/ir/plan-hash.js +3 -3
- package/dist/workflows/ir/schema-v4.js +246 -17
- package/dist/workflows/parser.js +74 -2
- package/dist/workflows/program/schema.js +5 -2
- package/dist/workflows/resource-limits.js +20 -0
- package/dist/workflows/runtime/plan-classifier.js +24 -7
- package/dist/workflows/runtime/run-outputs.js +103 -0
- package/dist/workflows/runtime/runs.js +114 -9
- package/dist/workflows/runtime/workflow-asset-loader.js +14 -6
- package/dist/workflows/source-files.js +5 -5
- package/dist/workflows/source-ir/compare.js +17 -0
- package/dist/workflows/source-ir/compile.js +7 -3
- package/dist/workflows/source-ir/github-yaml.js +64 -17
- package/dist/workflows/source-ir/schema.js +69 -21
- package/dist/workflows/source-ir/semantics.js +7 -25
- package/dist/workflows/source-ir/triggers.js +79 -0
- package/dist/workflows/source-ir/uses.js +33 -7
- package/docs/migration/README.md +1 -1
- package/docs/migration/release-notes/0.9.2.md +87 -11
- package/docs/migration/release-notes/README.md +3 -2
- package/docs/migration/v0.8-to-v0.9.md +13 -11
- package/docs/migration/v0.9.0-troubleshooting.md +20 -13
- package/docs/migration/v0.9.1-to-v0.9.2.md +598 -49
- package/docs/reference/README.md +1 -1
- package/docs/reference/cli.md +140 -46
- package/docs/reference/configuration.md +6 -5
- package/docs/reference/supported-formats.md +9 -5
- package/docs/reference/tasks.md +338 -75
- package/docs/reference/workflow-schema.md +290 -16
- package/docs/reference/workflows.md +57 -7
- package/package.json +1 -1
- package/schemas/akm-task.json +173 -118
- package/schemas/akm-workflow.json +28 -0
- package/dist/tasks/runner.js +0 -941
- package/dist/tasks/runtime-v3.js +0 -281
- package/dist/workflows/ir/source-freeze-v4.js +0 -506
- package/dist/workflows/source-ir/ordering.js +0 -38
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
* The task source version router (spec docs/plans/specs/p4-deletions-closeout.md
|
|
6
|
+
* §3.2.2).
|
|
7
|
+
*
|
|
8
|
+
* Runs the bounded YAML front end ONCE (`readBoundedTaskSourceYaml`), reads
|
|
9
|
+
* `root.version`, and either dispatches into `parseTaskSourceV4Document` or
|
|
10
|
+
* fails closed — no second parse, no re-serialization, no synthetic document
|
|
11
|
+
* (the P1b §4.3 invariant this phase carries forward).
|
|
12
|
+
*
|
|
13
|
+
* The terminal routing table:
|
|
14
|
+
*
|
|
15
|
+
* | root `version` | outcome |
|
|
16
|
+
* |------------------------|-----------------------------------------------------------------|
|
|
17
|
+
* | `4` | `parseTaskSourceV4Document` — the new grammar (row B-13) |
|
|
18
|
+
* | any other number | `TASK_SCHEMA_VERSION_UNSUPPORTED`, naming the migrator (B-14/B-15) |
|
|
19
|
+
* | absent / not a number | `parseTaskSourceV4Document` — its own `TASK_SOURCE_INVALID` "version is required and must be 4" / "must be exactly 4" wording (row B-16) |
|
|
20
|
+
*
|
|
21
|
+
* A missing or non-numeric `version:` is a MALFORMED v4 document, not a
|
|
22
|
+
* legacy one — it routes into the v4 parser so the field error names the
|
|
23
|
+
* one grammar `src` still accepts, rather than a generic "unsupported"
|
|
24
|
+
* message that would send the user to the migrator for a document that was
|
|
25
|
+
* never task v2 or v3 in the first place.
|
|
26
|
+
*
|
|
27
|
+
* task v2 and task v3 sources are no longer read by `src` at all — the only
|
|
28
|
+
* surviving reader is the frozen, vendored copy in
|
|
29
|
+
* `scripts/akm-migrate/migrate/task-source-v3-frozen.ts`, reachable only
|
|
30
|
+
* through `akm migrate apply` / `akm-migrate`. The front end's own
|
|
31
|
+
* pre-version failures (source not a string, source too large, YAML
|
|
32
|
+
* parse/warning/expansion) render with the label `task source` (row B-17,
|
|
33
|
+
* closing the "task v3 source" label wart P2a's §3.4 recorded).
|
|
34
|
+
*/
|
|
35
|
+
import { UsageError } from "../../core/errors.js";
|
|
36
|
+
import { readBoundedTaskSourceYaml } from "./bounded-document.js";
|
|
37
|
+
import { parseTaskSourceV4Document, TASK_SOURCE_V4_VERSION } from "./task-source-v4.js";
|
|
38
|
+
/** Read the root `version` field without over-accepting non-number values (e.g. the string `"4"`). */
|
|
39
|
+
export function peekTaskSourceVersion(root) {
|
|
40
|
+
if (root === null || typeof root !== "object" || Array.isArray(root))
|
|
41
|
+
return undefined;
|
|
42
|
+
const value = root.version;
|
|
43
|
+
return typeof value === "number" ? value : undefined;
|
|
44
|
+
}
|
|
45
|
+
const TASK_MIGRATE_HINT = "Run `akm migrate apply --dry-run` to preview the task-v3 to task-source-v4 conversion, then run `akm migrate apply`.";
|
|
46
|
+
/** Parse task source YAML, routing per the terminal table above. */
|
|
47
|
+
export function parseTaskSource(input) {
|
|
48
|
+
const { root, lineAt } = readBoundedTaskSourceYaml(input, { sourceLabel: "task source" });
|
|
49
|
+
const version = peekTaskSourceVersion(root);
|
|
50
|
+
if (version !== undefined && version !== TASK_SOURCE_V4_VERSION) {
|
|
51
|
+
throw new UsageError(`TASK_SCHEMA_VERSION_UNSUPPORTED: Task at ${input.filePath} uses task schema version ${version}, which this release does not accept.`, "TASK_SCHEMA_VERSION_UNSUPPORTED", TASK_MIGRATE_HINT);
|
|
52
|
+
}
|
|
53
|
+
const documentOptions = {
|
|
54
|
+
filePath: input.filePath,
|
|
55
|
+
...(input.workspaceRoot ? { workspaceRoot: input.workspaceRoot } : {}),
|
|
56
|
+
lineAt,
|
|
57
|
+
};
|
|
58
|
+
return Object.freeze({ version: 4, v4: parseTaskSourceV4Document(root, documentOptions) });
|
|
59
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
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
|
+
* Map every top-level task source v4 execution control and D2-N7 survivor
|
|
6
|
+
* into v3's `akm.*` shape, one field at a time (never a whole-object copy,
|
|
7
|
+
* so a field task source v4 does not represent — `inputs`, per-binding
|
|
8
|
+
* `enabled` — can never leak in by accident). Returns `undefined` when
|
|
9
|
+
* nothing maps, matching v3's own
|
|
10
|
+
* convention of omitting the `akm` key entirely rather than emitting an
|
|
11
|
+
* always-present empty object (`source-v3.ts:789`).
|
|
12
|
+
*/
|
|
13
|
+
function projectAkm(document) {
|
|
14
|
+
const out = {};
|
|
15
|
+
if (document.description !== undefined)
|
|
16
|
+
out.description = document.description;
|
|
17
|
+
if (document.when_to_use !== undefined)
|
|
18
|
+
out.when_to_use = document.when_to_use;
|
|
19
|
+
if (document.tags !== undefined)
|
|
20
|
+
out.tags = document.tags;
|
|
21
|
+
const execution = document.execution;
|
|
22
|
+
if (execution.agent !== undefined)
|
|
23
|
+
out.agent = execution.agent;
|
|
24
|
+
if (execution.engine !== undefined)
|
|
25
|
+
out.engine = execution.engine;
|
|
26
|
+
if (execution.model !== undefined)
|
|
27
|
+
out.model = execution.model;
|
|
28
|
+
if (execution.inference !== undefined)
|
|
29
|
+
out.inference = execution.inference;
|
|
30
|
+
if (execution.tools !== undefined)
|
|
31
|
+
out.tools = execution.tools;
|
|
32
|
+
if (execution.timeout !== undefined)
|
|
33
|
+
out.timeout = execution.timeout;
|
|
34
|
+
if (execution.redact !== undefined)
|
|
35
|
+
out.redact = execution.redact;
|
|
36
|
+
if (execution.maxSteps !== undefined)
|
|
37
|
+
out.maxSteps = execution.maxSteps;
|
|
38
|
+
if (execution.maxRetries !== undefined)
|
|
39
|
+
out.maxRetries = execution.maxRetries;
|
|
40
|
+
if (document.output !== undefined)
|
|
41
|
+
out.outputSchema = document.output;
|
|
42
|
+
return Object.keys(out).length > 0 ? Object.freeze(out) : undefined;
|
|
43
|
+
}
|
|
44
|
+
/** Project one parsed task source v4 document into the prepare seam's existing input shape (spec §3.5). */
|
|
45
|
+
export function projectTaskSourceV4(document) {
|
|
46
|
+
const akm = projectAkm(document);
|
|
47
|
+
const schedules = Object.freeze(document.schedule.map((entry) => Object.freeze({ cron: entry.cron, source: entry.source, ordinal: entry.ordinal })));
|
|
48
|
+
return Object.freeze({
|
|
49
|
+
// The literal `3` is the prepare seam's own discriminant
|
|
50
|
+
// (PreparableTaskDocument = TaskV3SourceDocument), not an assertion that
|
|
51
|
+
// the source this was projected from was task v3 — `TASK_V3_SCHEMA_VERSION`
|
|
52
|
+
// is gone (P4 deleted task v3 acceptance from src), and this projection
|
|
53
|
+
// only ever runs on a task source v4 document (P2a §3.5's recorded wart).
|
|
54
|
+
version: 3,
|
|
55
|
+
...(document.name !== undefined ? { name: document.name } : {}),
|
|
56
|
+
target: document.target,
|
|
57
|
+
...(document.env !== undefined ? { env: document.env } : {}),
|
|
58
|
+
...(akm !== undefined ? { akm } : {}),
|
|
59
|
+
triggers: Object.freeze({ manual: document.manualOnly, schedules }),
|
|
60
|
+
source: Object.freeze({ path: document.source.path }),
|
|
61
|
+
});
|
|
62
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
* `TASK_INPUT_DIAGNOSTICS` — the task-side message/code vocabulary for
|
|
6
|
+
* `materializeInputFlags` (spec docs/plans/specs/p2a-task-source-v4.md §1.5
|
|
7
|
+
* D3-N3, §4.2, §5.1).
|
|
8
|
+
*
|
|
9
|
+
* `materializeInputFlags` (`src/execution/input-contract.ts`) contains no
|
|
10
|
+
* literal user-facing string of its own — every message/code it raises comes
|
|
11
|
+
* from a caller-supplied `InputFlagDiagnostics`. `src/workflows/ir/params.ts`
|
|
12
|
+
* supplies `WORKFLOW_PARAMETER_DIAGNOSTICS` for workflow params; this module
|
|
13
|
+
* is that same seam's task-side sibling, consumed by `akm task run`'s Stage 2
|
|
14
|
+
* (`src/tasks/run/load-task.ts`). Mirrors `WORKFLOW_PARAMETER_DIAGNOSTICS`'s
|
|
15
|
+
* shape exactly (`unknownFlag`'s declared-name enumeration in the SEPARATE
|
|
16
|
+
* `hint`, not the message — `params.ts:65-72`) with task-flavored nouns and
|
|
17
|
+
* the codes §5.1 binds: `UNKNOWN_FLAG` for an undeclared name,
|
|
18
|
+
* `INPUT_BINDING_INVALID` for every value/contract failure.
|
|
19
|
+
*/
|
|
20
|
+
import { UsageError } from "../../core/errors.js";
|
|
21
|
+
function invalidTaskInput(name, detail) {
|
|
22
|
+
return new UsageError(`Task input "--${name}" ${detail}.`, "INPUT_BINDING_INVALID");
|
|
23
|
+
}
|
|
24
|
+
/** The task-input message/code vocabulary for `materializeInputFlags` (D3-N3). */
|
|
25
|
+
export const TASK_INPUT_DIAGNOSTICS = {
|
|
26
|
+
unknownFlag: (name, declared) => {
|
|
27
|
+
const available = declared.map((n) => `--${n}`).join(", ");
|
|
28
|
+
return new UsageError(`Unknown task input "--${name}". Input flags must exactly match a declared task input.`, "UNKNOWN_FLAG", available ? `Declared inputs: ${available}.` : "This task declares no inputs.");
|
|
29
|
+
},
|
|
30
|
+
invalidValue: (name, detail) => invalidTaskInput(name, detail),
|
|
31
|
+
contractViolation: (errors) => new UsageError(`Task input flags do not satisfy the task's declared input schemas:\n${errors
|
|
32
|
+
.map((error) => ` - ${error.replace(/^\$/, "inputs")}`)
|
|
33
|
+
.join("\n")}`, "INPUT_BINDING_INVALID"),
|
|
34
|
+
duplicateNonArray: (name) => invalidTaskInput(name, "was provided more than once but is not declared as an array"),
|
|
35
|
+
malformedJson: (name) => invalidTaskInput(name, "must contain valid JSON"),
|
|
36
|
+
};
|