akm-cli 0.9.0 → 0.9.1-beta.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 +724 -0
- package/README.md +28 -63
- package/STABILITY.md +4 -2
- package/dist/cli/parse-args.js +7 -1
- package/dist/commands/agent/contribute-cli.js +1 -1
- package/dist/commands/env/child-env.js +14 -0
- package/dist/commands/feedback-cli.js +7 -1
- package/dist/commands/health/llm-usage.js +2 -1
- package/dist/commands/health/surfaces.js +4 -77
- package/dist/commands/health.js +65 -11
- package/dist/commands/improve/distill/quality-gate.js +6 -1
- package/dist/commands/improve/eligibility.js +7 -1
- package/dist/commands/improve/eval-cases.js +2 -0
- package/dist/commands/improve/improve.js +126 -10
- package/dist/commands/improve/locks.js +7 -0
- package/dist/commands/improve/memory/memory-improve.js +9 -0
- package/dist/commands/improve/run-context.js +5 -0
- package/dist/commands/improve/session-asset.js +4 -0
- package/dist/commands/lint/base-linter.js +31 -7
- package/dist/commands/lint/index.js +205 -51
- package/dist/commands/lint/types.js +22 -1
- package/dist/commands/proposal/repository.js +17 -1
- package/dist/commands/sources/add-cli.js +8 -2
- package/dist/commands/sources/info.js +12 -2
- package/dist/commands/sources/installed-stashes.js +6 -1
- package/dist/commands/sources/migration-help.js +12 -3
- package/dist/commands/sources/self-update.js +9 -1
- package/dist/commands/tasks/tasks.js +8 -2
- package/dist/commands/workflow-cli.js +17 -11
- package/dist/core/abort-deadline.js +28 -0
- package/dist/core/adapter/adapters/agent-skills-adapter.js +83 -5
- package/dist/core/adapter/adapters/akm-adapter.js +13 -10
- package/dist/core/adapter/adapters/akm-lint.js +78 -22
- package/dist/core/adapter/adapters/akm-task-adapter.js +43 -20
- package/dist/core/adapter/adapters/dotenv-adapter.js +21 -0
- package/dist/core/adapter/adapters/tool-dir-shared.js +5 -3
- package/dist/core/asset/frontmatter.js +10 -1
- package/dist/core/common.js +147 -9
- package/dist/core/concurrent.js +32 -0
- package/dist/core/config/config-io.js +5 -45
- package/dist/core/config/schema/engines.js +14 -3
- package/dist/core/config/schema/workflow.js +11 -0
- package/dist/core/errors.js +25 -0
- package/dist/core/events.js +30 -24
- package/dist/core/extra-params.js +11 -0
- package/dist/core/file-lock.js +7 -1
- package/dist/core/fs-txn.js +15 -2
- package/dist/core/improve-result.js +5 -0
- package/dist/core/json-schema.js +344 -9
- package/dist/core/loopback.js +89 -0
- package/dist/core/migration-operation.js +17 -2
- package/dist/core/path-access.js +107 -0
- package/dist/core/paths.js +16 -2
- package/dist/core/redaction.js +86 -18
- package/dist/core/spawn-env.js +234 -0
- package/dist/core/state-db-scope.js +134 -0
- package/dist/core/state-db.js +1 -0
- package/dist/core/subprocess.js +181 -37
- package/dist/core/write-provenance.js +85 -0
- package/dist/core/write-source.js +33 -2
- package/dist/indexer/db/graph-db.js +17 -6
- package/dist/indexer/ensure-index.js +10 -3
- package/dist/indexer/index-written-assets.js +17 -2
- package/dist/indexer/indexer.js +86 -21
- package/dist/indexer/passes/memory-inference.js +4 -0
- package/dist/indexer/search/db-search.js +25 -17
- package/dist/indexer/walk/walker.js +6 -1
- package/dist/integrations/agent/detect.js +13 -1
- package/dist/integrations/agent/engine-resolution.js +24 -11
- package/dist/integrations/agent/model-aliases.js +1 -1
- package/dist/integrations/agent/profiles.js +9 -1
- package/dist/integrations/agent/spawn.js +15 -87
- package/dist/integrations/harnesses/opencode-sdk/sdk-runner.js +21 -0
- package/dist/integrations/lockfile.js +55 -2
- package/dist/llm/client.js +14 -19
- package/dist/llm/embedder.js +23 -3
- package/dist/llm/embedders/remote.js +27 -2
- package/dist/output/html-render.js +40 -1
- package/dist/output/text/lint-format.js +17 -4
- package/dist/runtime.js +23 -1
- package/dist/scripts/akm-migrate-node.js +1714 -836
- package/dist/scripts/akm-migrate.js +1682 -804
- package/dist/setup/setup.js +22 -7
- package/dist/sources/providers/git-install.js +25 -2
- package/dist/sources/providers/git-stash.js +19 -0
- package/dist/sources/providers/git.js +1 -1
- package/dist/sources/snapshot-fetchers/content-extract.js +63 -1
- package/dist/sources/snapshot-fetchers/website-ingest.js +126 -20
- package/dist/storage/database.js +71 -7
- package/dist/storage/engines/sqlite-migrations.js +61 -2
- package/dist/storage/managed-db.js +19 -0
- package/dist/storage/repositories/index-connection.js +39 -4
- package/dist/storage/repositories/index-entries-repository.js +6 -1
- package/dist/storage/repositories/index-meta-repository.js +11 -0
- package/dist/storage/repositories/index-schema.js +17 -2
- package/dist/storage/repositories/index-vec-repository.js +43 -5
- package/dist/storage/repositories/workflow-runs-repository.js +66 -13
- package/dist/storage/sqlite-pragmas.js +12 -1
- package/dist/tasks/log-redaction.js +156 -0
- package/dist/tasks/parser.js +82 -5
- package/dist/tasks/runner.js +222 -17
- package/dist/tasks/scheduler-invocation.js +19 -0
- package/dist/tasks/schema.js +86 -1
- package/dist/text-import-hook.mjs +1 -1
- package/dist/workflows/concurrency-policy.js +95 -1
- package/dist/workflows/exec/dispatch-redaction.js +114 -0
- package/dist/workflows/exec/exec-unit.js +542 -0
- package/dist/workflows/exec/frozen-judge.js +114 -42
- package/dist/workflows/exec/native-executor.js +465 -238
- package/dist/workflows/exec/param-secrets.js +4 -3
- package/dist/workflows/exec/run-workflow.js +424 -219
- package/dist/workflows/exec/step-work.js +506 -167
- package/dist/workflows/exec/unit-dispatch.js +31 -1
- package/dist/workflows/exec/unit-writer.js +53 -13
- package/dist/workflows/exec/worktree.js +454 -41
- package/dist/workflows/ir/compile.js +26 -2
- package/dist/workflows/ir/freeze.js +82 -15
- package/dist/workflows/ir/schema.js +105 -20
- package/dist/workflows/parser.js +242 -19
- package/dist/workflows/program/schema.js +24 -0
- package/dist/workflows/renderer.js +32 -4
- package/dist/workflows/resource-limits.js +182 -0
- package/dist/workflows/runtime/runs.js +146 -6
- package/dist/workflows/validate-summary.js +17 -2
- package/docs/README.md +74 -32
- package/docs/migration/release-notes/0.9.0.md +2 -1
- package/docs/migration/v0.7-to-v0.8.md +2 -1
- package/docs/migration/v0.8-to-v0.9.md +3 -1
- package/docs/reference/README.md +11 -4
- package/docs/reference/bundle-types.md +19 -0
- package/docs/reference/cli.md +105 -16
- package/docs/reference/configuration.md +15 -2
- package/docs/reference/data-and-telemetry.md +30 -10
- package/docs/reference/supported-formats.md +50 -0
- package/docs/reference/workflow-schema.md +1014 -0
- package/docs/reference/workflows.md +37 -633
- package/package.json +13 -6
- package/schemas/akm-config.json +18 -5
- package/schemas/akm-task.json +27 -5
- package/schemas/akm-workflow.json +92 -13
|
@@ -1,4 +1,34 @@
|
|
|
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
|
-
|
|
4
|
+
import { deepMergeConfig } from "../../core/config/deep-merge.js";
|
|
5
|
+
import { resolveCredentialFromEnv } from "../../integrations/agent/engine-resolution.js";
|
|
6
|
+
/**
|
|
7
|
+
* Materialize a frozen llm engine snapshot into a live connection: resolve the
|
|
8
|
+
* credential out of `process.env`, then apply the invocation's model/llm
|
|
9
|
+
* overrides. The ONE definition — the default dispatcher's llm runner and the
|
|
10
|
+
* frozen gate judge both dispatch through it, so credential resolution and
|
|
11
|
+
* connection-field mapping cannot drift between the two llm dispatch paths.
|
|
12
|
+
*
|
|
13
|
+
* The credential read itself is {@link resolveCredentialFromEnv}, shared with
|
|
14
|
+
* the live-config dispatch boundary (`materializeLlmConnection`): a frozen
|
|
15
|
+
* snapshot's `credential` and a resolved engine's `CredentialDescriptor` are the
|
|
16
|
+
* same descriptor, so lookup order and the "required … is not set" failure are
|
|
17
|
+
* one implementation, not two that happen to agree.
|
|
18
|
+
*/
|
|
19
|
+
export function materializeFrozenLlm(snapshot, invocation) {
|
|
20
|
+
const apiKey = resolveCredentialFromEnv(snapshot.credential);
|
|
21
|
+
const base = {
|
|
22
|
+
provider: snapshot.provider,
|
|
23
|
+
endpoint: snapshot.endpoint,
|
|
24
|
+
model: invocation?.model ?? snapshot.model,
|
|
25
|
+
...(snapshot.temperature !== undefined ? { temperature: snapshot.temperature } : {}),
|
|
26
|
+
...(snapshot.maxTokens !== undefined ? { maxTokens: snapshot.maxTokens } : {}),
|
|
27
|
+
...(snapshot.supportsJsonSchema !== undefined ? { supportsJsonSchema: snapshot.supportsJsonSchema } : {}),
|
|
28
|
+
...(snapshot.extraParams ? { extraParams: snapshot.extraParams } : {}),
|
|
29
|
+
...(snapshot.contextLength !== undefined ? { contextLength: snapshot.contextLength } : {}),
|
|
30
|
+
...(snapshot.enableThinking !== undefined ? { enableThinking: snapshot.enableThinking } : {}),
|
|
31
|
+
...(apiKey ? { apiKey } : {}),
|
|
32
|
+
};
|
|
33
|
+
return invocation?.llm ? deepMergeConfig(base, invocation.llm) : base;
|
|
34
|
+
}
|
|
@@ -5,19 +5,59 @@
|
|
|
5
5
|
* Serialized writer queue for `workflow_run_units` (orchestration plan,
|
|
6
6
|
* *Persistence changes*).
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
8
|
+
* ## What the chain actually protects
|
|
9
|
+
*
|
|
10
|
+
* SQLite allows exactly ONE writer per database FILE. Outside a
|
|
11
|
+
* `withWorkflowRunsConnection` scope, `withWorkflowRunsRepo` opens a fresh
|
|
12
|
+
* connection per call, so N units completing at once would be N separate
|
|
13
|
+
* connections racing for the same file's write lock, burning the 30 s
|
|
14
|
+
* `busy_timeout` on contention we created ourselves. Bun runs a single-threaded
|
|
15
|
+
* event loop, so an in-process promise chain is a sufficient (and free)
|
|
16
|
+
* admission control: every unit write executes strictly in enqueue order.
|
|
17
|
+
*
|
|
18
|
+
* That is the ONLY invariant the chain owns. In particular it does NOT own
|
|
19
|
+
* per-unit insert→finish ordering: `dispatchJournaledAttempt` awaits its insert
|
|
20
|
+
* before it dispatches and only finishes after the dispatch resolves, so a
|
|
21
|
+
* unit's own writes are ordered by program order, not by queue position. The
|
|
22
|
+
* queue could be reordered arbitrarily between units without breaking
|
|
23
|
+
* `finishUnitFromDispatch`'s row-conditional logic.
|
|
24
|
+
*
|
|
25
|
+
* ## Scope of the serialization (issue B)
|
|
26
|
+
*
|
|
27
|
+
* The chain is keyed by DATABASE PATH, not global, because the resource being
|
|
28
|
+
* protected is one SQLite file's write lock. Two runs against two different
|
|
29
|
+
* data dirs (`AKM_DATA_DIR` isolation, a test sandbox, a second stash) share no
|
|
30
|
+
* write lock and must not queue behind each other. Narrowing further — per run
|
|
31
|
+
* — would be unsound: two runs in the SAME state.db still contend for that one
|
|
32
|
+
* file's writer, which is precisely what the chain exists to avoid.
|
|
33
|
+
*
|
|
34
|
+
* Inside a `withWorkflowRunsConnection` scope the chain also becomes nearly
|
|
35
|
+
* free: every write goes through the same handle, so each queued task is a
|
|
36
|
+
* synchronous statement (or a synchronous `BEGIN IMMEDIATE … COMMIT`) that
|
|
37
|
+
* settles in microseconds rather than a per-call open/migrate-preflight/close.
|
|
38
|
+
* The queue depth stops gating unit completion in practice, without weakening
|
|
39
|
+
* anything.
|
|
40
|
+
*
|
|
41
|
+
* Reads and gate evaluation stay OFF this queue — only writes serialize.
|
|
42
|
+
*
|
|
43
|
+
* A failed write rejects its own caller but never wedges its chain.
|
|
44
|
+
*/
|
|
45
|
+
import { serializeByKey } from "../../core/concurrent.js";
|
|
46
|
+
import { getStateDbPath } from "../../core/state-db.js";
|
|
47
|
+
/**
|
|
48
|
+
* One promise chain per database path ({@link serializeByKey}). Entries are
|
|
49
|
+
* pruned when their chain drains, so a long-lived process that touches many
|
|
50
|
+
* data dirs (the test harness swaps `AKM_DATA_DIR` per test) does not
|
|
51
|
+
* accumulate one resolved promise per path forever.
|
|
52
|
+
*/
|
|
53
|
+
const chains = new Map();
|
|
54
|
+
/**
|
|
55
|
+
* Enqueue a `workflow_run_units` write behind every write already queued for
|
|
56
|
+
* the same state.db. The key is the current state.db path — the file whose one
|
|
57
|
+
* write lock this exists to protect — and is not a caller's choice: a caller
|
|
58
|
+
* writing somewhere else is not on this queue at all, and wants
|
|
59
|
+
* {@link serializeByKey} with its own chain map.
|
|
16
60
|
*/
|
|
17
|
-
let tail = Promise.resolve();
|
|
18
61
|
export function enqueueUnitWrite(fn) {
|
|
19
|
-
|
|
20
|
-
// Keep the chain alive regardless of individual outcomes.
|
|
21
|
-
tail = run.then(() => undefined, () => undefined);
|
|
22
|
-
return run;
|
|
62
|
+
return serializeByKey(chains, getStateDbPath(), fn);
|
|
23
63
|
}
|