akm-cli 0.9.29 → 0.9.31

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.
Files changed (162) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +10 -10
  3. package/ROADMAP.md +112 -0
  4. package/dist/commands/improve/improve-cli.js +33 -12
  5. package/dist/commands/sources/plugin-upgrade.js +46 -23
  6. package/dist/core/file-lock.js +10 -1
  7. package/dist/llm/client.js +33 -3
  8. package/dist/scripts/akm-migrate-node.js +5 -1
  9. package/dist/scripts/akm-migrate.js +5 -1
  10. package/docs/README.md +42 -41
  11. package/docs/agents/README.md +15 -0
  12. package/docs/agents/agent-install.md +14 -0
  13. package/docs/architecture/README.md +67 -0
  14. package/docs/architecture/adapters.md +272 -0
  15. package/docs/architecture/akm-architecture-decision-history.md +2055 -0
  16. package/docs/architecture/akm-core-principles.md +126 -0
  17. package/docs/architecture/architecture.md +579 -0
  18. package/docs/architecture/comparisons/claude-code-vs-akm-workflows-full.md +550 -0
  19. package/docs/architecture/decisions/0001-no-interpolation-attached-structured-context.md +72 -0
  20. package/docs/architecture/decisions/0002-unit-reuse-and-input-hash-scope.md +142 -0
  21. package/docs/architecture/decisions/0003-child-env-allowlist-and-provenance.md +189 -0
  22. package/docs/architecture/decisions/0004-task-input-contract-and-flag-coercion.md +97 -0
  23. package/docs/architecture/decisions/0005-task-result-vocabulary-and-legacy-read-mapping.md +108 -0
  24. package/docs/architecture/decisions/0006-task-source-version-routing.md +124 -0
  25. package/docs/architecture/decisions/0007-workflow-composition-bounds.md +83 -0
  26. package/docs/architecture/decisions/0008-task-binding-normalization.md +88 -0
  27. package/docs/architecture/decisions/0009-child-run-publication-column-parity.md +80 -0
  28. package/docs/architecture/decisions/0010-driver-protocol-cut.md +36 -0
  29. package/docs/architecture/decisions/0011-engine-run-loop-invariants.md +125 -0
  30. package/docs/architecture/decisions/README.md +62 -0
  31. package/docs/architecture/improvement.md +440 -0
  32. package/docs/architecture/internals/classification.md +154 -0
  33. package/docs/architecture/internals/fresh-host-rebuild-runbook.md +40 -0
  34. package/docs/architecture/internals/functional-contract-patterns.md +340 -0
  35. package/docs/architecture/internals/health-advisories.md +110 -0
  36. package/docs/architecture/internals/improve-workflow.md +713 -0
  37. package/docs/architecture/internals/indexing.md +498 -0
  38. package/docs/architecture/internals/registry-network-boundary.md +57 -0
  39. package/docs/architecture/internals/search.md +249 -0
  40. package/docs/architecture/internals/storage-locations.md +943 -0
  41. package/docs/architecture/persisted-data-compat.md +59 -0
  42. package/docs/architecture/reviews/env-secret-access.md +319 -0
  43. package/docs/architecture/runtime-boundary-design.md +153 -0
  44. package/docs/architecture/specs/0.9.0-close-out-plan.md +361 -0
  45. package/docs/architecture/specs/0.9.0-decisions.md +528 -0
  46. package/docs/architecture/specs/0.9.0-docs-code-drift-register.md +745 -0
  47. package/docs/architecture/specs/0.9.0-open-items-register.md +135 -0
  48. package/docs/architecture/specs/0.9.0-public-api-issue-backlog.md +740 -0
  49. package/docs/architecture/specs/0.9.0-release-surface-review.md +636 -0
  50. package/docs/architecture/specs/agent-command-engine-model-design.md +513 -0
  51. package/docs/architecture/specs/akm-0.9.0-bundle-adapter-spec.md +501 -0
  52. package/docs/architecture/specs/akm-0.9.0-ref-grammar-decision.md +291 -0
  53. package/docs/architecture/specs/akm-format-neutral-bundle-workspace-spec.md +2059 -0
  54. package/docs/architecture/specs/di-seams-plan.md +539 -0
  55. package/docs/architecture/specs/driver-protocol-keep-or-cut.md +275 -0
  56. package/docs/architecture/specs/fact-asset-type.md +142 -0
  57. package/docs/architecture/specs/improve-collapse-churn-detector-design.md +634 -0
  58. package/docs/architecture/specs/okf-support.md +148 -0
  59. package/docs/architecture/specs/ref.md +329 -0
  60. package/docs/architecture/specs/reviews/task-workflow-unification/README.md +72 -0
  61. package/docs/architecture/specs/reviews/task-workflow-unification/findings-consolidated.md +152 -0
  62. package/docs/architecture/specs/reviews/task-workflow-unification/library-eval-alternatives.md +352 -0
  63. package/docs/architecture/specs/reviews/task-workflow-unification/library-eval-bunqueue.md +300 -0
  64. package/docs/architecture/specs/reviews/task-workflow-unification/library-eval-openworkflow.md +402 -0
  65. package/docs/architecture/specs/reviews/task-workflow-unification/opus-review-1.md +758 -0
  66. package/docs/architecture/specs/reviews/task-workflow-unification/opus-review-2.md +645 -0
  67. package/docs/architecture/specs/reviews/task-workflow-unification/opus-review-3.md +602 -0
  68. package/docs/architecture/specs/reviews/task-workflow-unification/panel-r1-adversarial.md +27 -0
  69. package/docs/architecture/specs/reviews/task-workflow-unification/panel-r1-architecture.md +27 -0
  70. package/docs/architecture/specs/reviews/task-workflow-unification/panel-r1-coverage.md +74 -0
  71. package/docs/architecture/specs/reviews/task-workflow-unification/panel-r1-security.md +15 -0
  72. package/docs/architecture/specs/reviews/task-workflow-unification/panel-r2-adversarial.md +132 -0
  73. package/docs/architecture/specs/reviews/task-workflow-unification/panel-r2-verification.md +147 -0
  74. package/docs/architecture/specs/stash-conventions-code-spec.md +275 -0
  75. package/docs/architecture/specs/stash-organization-conventions.md +377 -0
  76. package/docs/architecture/specs/task-workflow-format-unification.md +721 -0
  77. package/docs/architecture/specs/workflow-engine-buy-vs-build.md +231 -0
  78. package/docs/architecture/specs/workflow-format-unification.md +437 -0
  79. package/docs/architecture/testing/manual-testing-checklist.md +3420 -0
  80. package/docs/architecture/testing/okf-v0.2-conformance-runbook.md +924 -0
  81. package/docs/architecture/testing/task-workflow-manual-tests.md +1817 -0
  82. package/docs/architecture/testing/testing-workflow.md +446 -0
  83. package/docs/architecture/workflow-engine.md +274 -0
  84. package/docs/guides/README.md +33 -0
  85. package/docs/guides/author-bundles.md +310 -0
  86. package/docs/guides/author-workflows.md +520 -0
  87. package/docs/guides/bundles.md +321 -0
  88. package/docs/guides/capture-knowledge.md +136 -0
  89. package/docs/guides/claude-code-vs-akm-workflows.md +30 -0
  90. package/docs/guides/concepts.md +93 -0
  91. package/docs/guides/discover-and-load.md +158 -0
  92. package/docs/guides/getting-started.md +240 -0
  93. package/docs/guides/improve-the-library.md +246 -0
  94. package/docs/guides/knowledge-management.md +18 -0
  95. package/docs/guides/recipes/headless-install.md +97 -0
  96. package/docs/guides/recipes/website-source.md +28 -0
  97. package/docs/guides/run-workflows.md +279 -0
  98. package/docs/guides/scheduling.md +123 -0
  99. package/docs/guides/use-with-any-agent.md +129 -0
  100. package/docs/guides/wikis.md +81 -0
  101. package/docs/maintainers/README.md +19 -0
  102. package/docs/maintainers/curate-workmap.md +336 -0
  103. package/docs/maintainers/eval.md +3 -0
  104. package/docs/maintainers/local-development.md +108 -0
  105. package/docs/maintainers/release-checklist.md +103 -0
  106. package/docs/migration/README.md +2 -2
  107. package/docs/migration/release-notes/0.0.13.md +1 -1
  108. package/docs/migration/release-notes/0.1.0.md +1 -1
  109. package/docs/migration/release-notes/0.2.0.md +1 -1
  110. package/docs/migration/release-notes/0.3.0.md +1 -1
  111. package/docs/migration/release-notes/0.5.0.md +1 -1
  112. package/docs/migration/release-notes/0.6.0.md +1 -1
  113. package/docs/migration/release-notes/0.7.0.md +1 -1
  114. package/docs/migration/release-notes/0.7.3.md +2 -2
  115. package/docs/migration/release-notes/0.7.4.md +1 -1
  116. package/docs/migration/release-notes/0.7.5.md +1 -1
  117. package/docs/migration/release-notes/0.8.0.md +1 -1
  118. package/docs/migration/release-notes/0.9.0.md +1 -1
  119. package/docs/migration/release-notes/0.9.14.md +1 -1
  120. package/docs/migration/release-notes/0.9.15.md +1 -1
  121. package/docs/migration/release-notes/0.9.16.md +1 -1
  122. package/docs/migration/release-notes/0.9.17.md +1 -1
  123. package/docs/migration/release-notes/0.9.19.md +1 -1
  124. package/docs/migration/release-notes/0.9.2.md +1 -1
  125. package/docs/migration/release-notes/README.md +27 -31
  126. package/docs/migration/v0.5-to-v0.6.md +759 -0
  127. package/docs/migration/v0.8-to-v0.9.md +1 -1
  128. package/docs/plans/0.9.2-agent-command-workflow-plan.md +423 -0
  129. package/docs/posts/README.md +30 -0
  130. package/docs/posts/akm-command-tour.md +495 -0
  131. package/docs/posts/akm-logo-sized.webp +0 -0
  132. package/docs/posts/belief-aware-memory-12.md +139 -0
  133. package/docs/posts/config-v2-lessons-16.md +191 -0
  134. package/docs/posts/improve-loop-autonomous-10.md +225 -0
  135. package/docs/posts/improve-pipeline-debugging-0803.md +179 -0
  136. package/docs/posts/intro-part-01.md +76 -0
  137. package/docs/posts/intro-part-02.md +221 -0
  138. package/docs/posts/intro-part-03.md +190 -0
  139. package/docs/posts/intro-part-04.md +221 -0
  140. package/docs/posts/llm-mode-reflect-13.md +166 -0
  141. package/docs/posts/openpalm-built-on-akm.md +86 -0
  142. package/docs/posts/progressive-disclosure-06.md +129 -0
  143. package/docs/posts/proposal-safety-net-15.md +112 -0
  144. package/docs/posts/release-0.5.0.md +247 -0
  145. package/docs/posts/release-0.6.0.md +117 -0
  146. package/docs/posts/release-0.7.0.md +159 -0
  147. package/docs/posts/release-0.8.0.md +332 -0
  148. package/docs/posts/scattered-skills-05.md +100 -0
  149. package/docs/posts/task-assets-persistent-workflows-11.md +222 -0
  150. package/docs/posts/team-skills-07.md +198 -0
  151. package/docs/posts/wiki-agent-knowledge-08.md +223 -0
  152. package/docs/posts/workflows-vaults-09.md +321 -0
  153. package/docs/product-surface.md +54 -0
  154. package/docs/reference/README.md +1 -2
  155. package/docs/reference/asset-types.md +168 -0
  156. package/docs/reference/cli.md +5 -6
  157. package/docs/reference/env-and-secrets.md +126 -0
  158. package/docs/reference/memory.md +124 -0
  159. package/docs/reference/refs.md +156 -0
  160. package/docs/reference/registry.md +489 -0
  161. package/docs/reference/website-sources.md +141 -0
  162. package/package.json +12 -15
package/CHANGELOG.md CHANGED
@@ -6,6 +6,47 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.9.31] - 2026-10-09
10
+
11
+ A patch release: concurrent config writes no longer lose a change, OpenAI's reasoning models work as `llm`
12
+ engines, `akm improve --require-engines` probes send API keys, and the npm package's docs links resolve.
13
+
14
+ ### Fixed
15
+
16
+ - **`akm improve --require-engines` sends each engine's API key with its probe.** The probe used the engine's
17
+ connection as resolved, where the key is still a symbolic reference that a dispatch reads only when it sends a
18
+ request, so every keyed endpoint (OpenAI, a gateway that enforces auth) answered 401 and the run stopped with
19
+ "engine completion path is not reachable". The probe now builds the connection as a dispatch does; a required key
20
+ that is missing is reported as that engine's failure.
21
+ - **OpenAI's reasoning models (gpt-5.x) work as `llm` engines.** They answer 400 to any `temperature` but the
22
+ default and to `max_tokens`, so every akm model call failed on them. Like the existing fallback for the
23
+ thinking-control fields, a 400 that names `temperature` is retried once without it, and one that asks for
24
+ `max_completion_tokens` is retried with the cap under that name; the connection keeps the working shape for
25
+ the rest of the process.
26
+ - **Every relative link in the npm package's docs resolves again.** #1118 made `docs/README.md`,
27
+ `docs/migration/README.md` and `docs/reference/cli.md` link by relative path to guides and pages the package did
28
+ not ship. npm always ships a folder's `README.md`, so those links were dead for npm users. The package now ships
29
+ the user-facing `docs/` folders (`agents`, `architecture`, `guides`, `integration`, `maintainers`, `migration`,
30
+ `posts`, `reference`), `docs/product-surface.md`, the one plan they link to, and `ROADMAP.md`. `docs/plans` stays
31
+ out. The link check skips link syntax inside code, which is an example, not a link.
32
+ - **Concurrent `akm config set` runs no longer lose each other's changes.** A lock file was created empty and its
33
+ owner's PID written a moment later; a process that looked in that gap read no PID, took the live lock for an
34
+ abandoned one and removed it, so two writers ran at once and one change was lost. A lock now appears with its
35
+ owner's PID already in it. Every akm lock file (config, index writer, scheduler, `akm.lock`, run, extract, secret)
36
+ is created this way.
37
+
38
+ ## [0.9.30] - 2026-10-09
39
+
40
+ A patch release: `akm upgrade` acts only on the `akm-opencode` spec OpenCode's config names.
41
+
42
+ ### Fixed
43
+
44
+ - **`akm upgrade` leaves alone an OpenCode whose config pins another `akm-opencode` spec (#1117).** A config naming
45
+ an exact version (seen: `akm-opencode@0.8.0`) loads that version's cache, but the plugin step refreshed `@latest`:
46
+ the cache went to the trash, OpenCode did not re-create it, and the run exited 1. The step now acts only on the
47
+ spec the config names: bare or `@latest` on a plain run, `@next` under `--next`; any other spec is skipped with a
48
+ note, no cache is touched and the CLI is not held to a pin OpenCode does not load. This generalizes #1115.
49
+
9
50
  ## [0.9.29] - 2026-10-09
10
51
 
11
52
  A patch release on the 0.9.28 line: `akm upgrade` is Stable, and a plain upgrade no longer breaks OpenCode's
package/README.md CHANGED
@@ -55,7 +55,7 @@ akm show scripts/deploy.sh # View details and run command
55
55
  - **One library for every agent** -- Use the same capability library from Claude Code, OpenCode, Cursor, Aider, Windsurf, or any assistant that can run shell commands.
56
56
  - **Load only what the task needs** -- Search or curate a shortlist, then load full content by ref. No giant startup prompt is required.
57
57
  - **Package complete capabilities** -- Install and share bundles containing skills, scripts, workflows, agents, instructions, memories, and knowledge -- not just prompt snippets.
58
- - **Improve through evidence, with review** -- Feedback influences retrieval and produces diffable proposals. Changes remain reviewable and target only writable bundles.
58
+ - **Improve through evidence, with review** -- Feedback re-ranks assets right away. A negative report can carry an exact text fix, and `akm improve` repairs metadata; every edit lands as a diffable proposal you accept, reject or revert, and only writable bundles are changed.
59
59
  - **Turn knowledge into repeatable work** -- Run persisted workflows with dispatch, gates, retries, budgets, and resume instead of reconstructing a process from prose every session.
60
60
 
61
61
  akm retrieves every supported capability type. It directly orchestrates
@@ -80,16 +80,16 @@ Or generate it directly: `akm help agents >> AGENTS.md`
80
80
 
81
81
  ## Documentation
82
82
 
83
- Full docs, CLI reference, and guides are available on [GitHub](https://github.com/itlackey/akm):
83
+ Full docs, CLI reference, and guides are at **[akm.fwdslsh.dev](https://akm.fwdslsh.dev/)**:
84
84
 
85
- - [Getting Started](https://github.com/itlackey/akm/blob/main/docs/guides/getting-started.md)
86
- - [Supported Formats](https://github.com/itlackey/akm/blob/main/docs/reference/supported-formats.md)
87
- - [CLI Reference](https://github.com/itlackey/akm/blob/main/docs/reference/cli.md)
88
- - [Task v3 Reference](https://github.com/itlackey/akm/blob/main/docs/reference/tasks.md)
89
- - [0.9.2 Migration Guide](https://github.com/itlackey/akm/blob/main/docs/migration/v0.9.1-to-v0.9.2.md)
90
- - [Configuration](https://github.com/itlackey/akm/blob/main/docs/reference/configuration.md)
91
- - [Bundle Authoring Guide](https://github.com/itlackey/akm/blob/main/docs/guides/author-bundles.md)
92
- - [Registry](https://github.com/itlackey/akm/blob/main/docs/reference/registry.md)
85
+ - [Getting Started](https://akm.fwdslsh.dev/docs/guides/getting-started/)
86
+ - [Supported Formats](https://akm.fwdslsh.dev/docs/reference/supported-formats/)
87
+ - [CLI Reference](https://akm.fwdslsh.dev/docs/reference/cli/)
88
+ - [Task v3 Reference](https://akm.fwdslsh.dev/docs/reference/tasks/)
89
+ - [0.9.2 Migration Guide](https://akm.fwdslsh.dev/docs/migration/v0.9.1-to-v0.9.2/)
90
+ - [Configuration](https://akm.fwdslsh.dev/docs/reference/configuration/)
91
+ - [Bundle Authoring Guide](https://akm.fwdslsh.dev/docs/guides/author-bundles/)
92
+ - [Registry](https://akm.fwdslsh.dev/docs/reference/registry/)
93
93
 
94
94
  ## License
95
95
 
package/ROADMAP.md ADDED
@@ -0,0 +1,112 @@
1
+ # Roadmap
2
+
3
+ This page outlines the high-level focus for the next two releases.
4
+
5
+ It is intentionally directional rather than exhaustive. Detailed command,
6
+ schema, and migration behavior still lives in the release notes, the
7
+ migration guides, and [STABILITY.md](STABILITY.md), which classifies
8
+ today's public contract by surface. The internal design specs behind the
9
+ 0.9.0 architecture consolidation live under
10
+ [`docs/architecture/specs/`](docs/architecture/specs/).
11
+
12
+ ## 0.8 Foundation
13
+
14
+ Release `0.8.0` already established much of the product shape that `0.9` and
15
+ `1.0` build on.
16
+
17
+ - The CLI and config surface were substantially redesigned.
18
+ - `akm improve` became the main self-improvement and maintenance entry point.
19
+ - Task assets, proposal workflows, health reporting, and agent command-building
20
+ all landed as first-class capabilities.
21
+ - Storage, indexing, graph extraction, and migration paths were tightened to
22
+ support the v1 contract freeze.
23
+
24
+ That means the next two releases are less about inventing a new direction and
25
+ more about hardening, simplifying, and freezing what `0.8.0` put in place.
26
+
27
+ ## 0.9
28
+
29
+ Release `0.9` is the architecture-consolidation release ahead of the `1.0`
30
+ contract freeze. It replaces the flat asset-type registry with a
31
+ **bundle / adapter** model and settles the durable contracts `1.0` will freeze.
32
+
33
+ - **One canonical ref grammar.** Refs are `[bundle//]conceptId` — a
34
+ subdir-qualified concept id such as `skills/code-review` or `memories/vpn-note`
35
+ — replacing the pre-`0.9` `type:name` spelling. Durable state stores the
36
+ fully-qualified form; the short bundle-omitted form is input sugar. This is a
37
+ deliberate, one-time break, taken pre-`1.0` while it is still cheap.
38
+ - **Format-neutral bundles.** Installed sources are bundles, each recognized by
39
+ a built-in adapter (Agent Skills, Claude/OpenCode commands and agents,
40
+ knowledge, YAML workflows, tasks, env/secret files, scripts, OKF and LLM-wiki
41
+ knowledge bases) instead of a closed asset-type list.
42
+ - **Storage consolidation.** The durable databases collapse from four to three
43
+ (`state.db` / `index.db` / a separate `logs.db`); config migrates from the
44
+ flat `stashDir` / `sources` / `installed` keys to `bundles` / `defaultBundle`.
45
+ The one-time cutover is journaled and crash-resumable via `akm migrate apply`,
46
+ with a verified backup taken first.
47
+ - **Debt paydown.** The improve / proposal / workflow internals are decomposed
48
+ onto one file-change transaction model and an ambient run context, the
49
+ deprecated `0.8` CLI aliases are removed, and the `vault` asset type is
50
+ retired in favor of `env` / `secret`.
51
+
52
+ In short: `0.9` reduces ambiguity, pays down pre-`1.0` debt, and arrives at a
53
+ small, durable core ready for the `1.0` freeze.
54
+
55
+ ### The 0.9.x series
56
+
57
+ `0.9.x` is a series of refactoring and clean-up releases. The intent is to
58
+ have **all technical debt paid off and all planned breaking changes handled
59
+ before the 0.10.x series begins**. To get there quickly, 0.9.x patch releases
60
+ may include breaking changes (see [STABILITY.md](STABILITY.md)); every
61
+ break ships with a CHANGELOG migration note.
62
+
63
+ Alongside the bug fixes and compatibility improvements, `0.9.x` also focuses
64
+ on **tuning the improve processes** — reflect, distill, consolidate, memory
65
+ inference, graph extraction, and proactive maintenance — and **settling the
66
+ final design of those features** so the `0.10.0` release starts from a
67
+ finished improve surface rather than one still being reshaped.
68
+
69
+ ## 0.10
70
+
71
+ The `0.10.x` series is focused on **bug fixes and tuning** on top of the
72
+ debt-free 0.9 core — no new architecture. With the clean-up done, 0.10.x
73
+ attempts to return to the normal semver discipline: breaking changes only in
74
+ major and minor releases, never in patches.
75
+
76
+ ## 0.X
77
+
78
+ There may be other minor releases between 0.10.x and 1.0.0. The goal is to minimize the number of minor releases after 0.10.x, and they will only be used for addressing breaking changes that are justifiable before the 1.0.0 release.
79
+
80
+ ## 1.0
81
+
82
+ Release `1.0` is focused on freezing the public contract and shipping the first
83
+ stable ecosystem layer around that core.
84
+
85
+ - Freeze the supported source model, the `[bundle//]conceptId` ref format,
86
+ search behavior, and write-target rules — the surfaces
87
+ [STABILITY.md](STABILITY.md)'s own 1.0 contract-freeze section
88
+ already names — and settle the surfaces it currently classifies as
89
+ Evolving or Experimental.
90
+ - Carry the `0.8` agent and improvement workflow forward as a stable,
91
+ documented product surface rather than a collection of pre-release features.
92
+ - Ship an official akm SDK for building integrations against the stable v1
93
+ contract instead of reverse-engineering CLI behavior.
94
+ - Ship in-process akm plugins for Claude Code and OpenCode, built on that SDK,
95
+ so those tools can integrate more deeply without changing the CLI-first core
96
+ model that akm itself relies on.
97
+ - Keep the CLI as the canonical foundation so the SDK and plugin story extends
98
+ the existing system rather than forking it into separate integration models.
99
+
100
+ In short: `1.0` is where akm stops being only a strong CLI and becomes a stable
101
+ platform for both direct use and deeper tool integration.
102
+
103
+ ## Scope Notes
104
+
105
+ - The CLI remains the foundation in both releases.
106
+ - `0.9` prioritizes hardening over expansion.
107
+ - `1.0` adds the SDK and in-process plugin story on top of a frozen core, not
108
+ instead of it.
109
+ - The roadmap assumes the `0.8.0` redesign is the baseline; later releases are
110
+ about stabilizing and extending that baseline, not replacing it.
111
+ - Specific features may move between releases as implementation and testing
112
+ shake out, but the themes above are the intended direction.
@@ -16,7 +16,8 @@ import { clearLogFile, setLogFile, warn } from "../../core/warn.js";
16
16
  import { resolveWriteTarget } from "../../core/write-source.js";
17
17
  import { DEFAULT_LLM_TIMEOUT_MS } from "../../integrations/agent/config.js";
18
18
  import { defaultWhich } from "../../integrations/agent/detect.js";
19
- import { collectEngineCredentialValues } from "../../integrations/agent/engine-resolution.js";
19
+ import { collectEngineCredentialValues, materializeLlmConnection, } from "../../integrations/agent/engine-resolution.js";
20
+ import { llmUseFromRunner, sdkFallbackUseFromRunner } from "../../integrations/agent/runner.js";
20
21
  import { probeLlmReachable } from "../../llm/client.js";
21
22
  import { getOutputMode } from "../../output/context.js";
22
23
  import { deliverRendered } from "../../output/html-render.js";
@@ -81,18 +82,36 @@ function collectRequiredEngineTargets(plan) {
81
82
  const runners = Object.entries(plan.processes)
82
83
  .flatMap(([processName, process]) => (process.runner ? [[processName, process.runner]] : []))
83
84
  .concat(plan.triageJudgment ? [["triage.judgment", plan.triageJudgment]] : []);
84
- return runners.map(([processName, runner]) => ({
85
- process: processName,
86
- engine: runner.engine,
87
- ...(runner.kind === "llm" ? { connection: probeConnection(runner) } : { bin: runner.profile.bin }),
88
- ...(runner.kind === "sdk" && runner.fallbackConnection
89
- ? { connection: probeConnection({ connection: runner.fallbackConnection, timeoutMs: runner.fallbackTimeoutMs }) }
90
- : {}),
91
- }));
85
+ return runners.map(([processName, runner]) => {
86
+ // The runner's own timeout, else the connection's (sdkFallbackUseFromRunner already does this).
87
+ const use = runner.kind === "llm"
88
+ ? {
89
+ ...llmUseFromRunner(runner),
90
+ timeoutMs: runner.timeoutMs !== undefined ? runner.timeoutMs : (runner.connection.timeoutMs ?? null),
91
+ }
92
+ : runner.kind === "sdk"
93
+ ? sdkFallbackUseFromRunner(runner)
94
+ : undefined;
95
+ return {
96
+ process: processName,
97
+ engine: runner.engine,
98
+ ...(runner.kind === "llm" ? {} : { bin: runner.profile.bin }),
99
+ ...(use ? probeConnection(use) : {}),
100
+ };
101
+ });
92
102
  }
93
- /** The resolved engine keeps its request timeout beside the connection (the runtime merges it in); the probe needs it on the connection. */
94
- function probeConnection(runner) {
95
- return runner.timeoutMs !== undefined ? { ...runner.connection, timeoutMs: runner.timeoutMs } : runner.connection;
103
+ /**
104
+ * The connection the probe sends, built as a dispatch builds it: the runner
105
+ * keeps its credential symbolic, so the key is read and injected here, or the
106
+ * probe would go out without one.
107
+ */
108
+ function probeConnection(use) {
109
+ try {
110
+ return { connection: materializeLlmConnection(use) };
111
+ }
112
+ catch (err) {
113
+ return { connection: use.connection, error: err instanceof Error ? err.message : String(err) };
114
+ }
96
115
  }
97
116
  /**
98
117
  * The bound on `--require-engines`' probe: the connection's own request
@@ -133,6 +152,8 @@ export async function assertRequiredEnginesReachable(plan, probeReachable = (con
133
152
  }
134
153
  if (!target.connection)
135
154
  return { ...target, reach: { reachable: true }, latencyMs: 0 };
155
+ if (target.error)
156
+ return { ...target, reach: { reachable: false, error: target.error }, latencyMs: 0 };
136
157
  return { ...target, ...(await probeConnectionOnce(target.connection)) };
137
158
  }));
138
159
  const unreachable = probed.filter((item) => !item.reach.reachable);
@@ -141,13 +141,13 @@ function homeDir() {
141
141
  return process.env.HOME?.trim() || process.env.USERPROFILE?.trim() || os.homedir();
142
142
  }
143
143
  /**
144
- * Whether the user's global OpenCode config asks for `akm-opencode@next`.
145
- * A bare `akm-opencode` resolves to `@latest` when OpenCode prefetches it, so
146
- * only a config that names the tag can follow prereleases. The config is only
147
- * read, never written; project configs are not looked at (akm does not know
148
- * which project OpenCode runs in).
144
+ * The `akm-opencode` spec the user's global OpenCode config names (bare,
145
+ * `@latest`, `@next`, an exact version, ...), or undefined when none does.
146
+ * OpenCode caches each spec in its own folder, so this says which cache it
147
+ * loads. The config is only read, never written; project configs are not
148
+ * looked at (akm does not know which project OpenCode runs in).
149
149
  */
150
- export function openCodeConfigRequestsNext() {
150
+ export function openCodeConfigSpec() {
151
151
  const configHome = process.env.XDG_CONFIG_HOME?.trim() || path.join(homeDir(), ".config");
152
152
  const files = [
153
153
  process.env.OPENCODE_CONFIG?.trim(),
@@ -162,14 +162,18 @@ export function openCodeConfigRequestsNext() {
162
162
  if (!Array.isArray(config.plugin))
163
163
  continue;
164
164
  // An entry is a spec string or a `[spec, options]` pair.
165
- if (config.plugin.some((entry) => (Array.isArray(entry) ? entry[0] : entry) === OPENCODE_NEXT_SPEC))
166
- return true;
165
+ for (const entry of config.plugin) {
166
+ const spec = Array.isArray(entry) ? entry[0] : entry;
167
+ if (typeof spec === "string" && (spec === OPENCODE_PACKAGE || spec.startsWith(`${OPENCODE_PACKAGE}@`))) {
168
+ return spec;
169
+ }
170
+ }
167
171
  }
168
172
  catch {
169
- // Missing or unparseable: this file does not request it.
173
+ // Missing or unparseable: this file names no spec.
170
174
  }
171
175
  }
172
- return false;
176
+ return undefined;
173
177
  }
174
178
  /**
175
179
  * The cached `akm-opencode` OpenCode installed on first use, or undefined when
@@ -294,12 +298,17 @@ function openCodeRunning() {
294
298
  }
295
299
  const NOT_FOLLOWING_NEXT = `--next: OpenCode resolves a bare "${OPENCODE_PACKAGE}" to @latest, so it is not updated to a prerelease; ` +
296
300
  `set "plugin": ["${OPENCODE_NEXT_SPEC}"] in your OpenCode config to follow prereleases`;
297
- const FOLLOWING_NEXT = `OpenCode loads "${OPENCODE_NEXT_SPEC}" (your OpenCode config), so a plain upgrade leaves it alone; ` +
298
- `run \`akm upgrade --next\` to update it, or set "plugin": ["${OPENCODE_PACKAGE}"] to follow stable releases`;
299
- function upgradeOpenCode(dryRun, cache, latest, tag, notFollowingNext, followingNext) {
300
- // Refreshing @latest would trash a cache OpenCode never re-creates (#1115).
301
- if (followingNext)
302
- return skipped("opencode", FOLLOWING_NEXT);
301
+ /** Why a run leaves alone an OpenCode whose config names a spec this run does not refresh (#1115, #1117). */
302
+ function otherSpecNote(spec) {
303
+ const loads = `OpenCode loads "${spec}" (your OpenCode config), so this upgrade leaves it alone`;
304
+ return spec === OPENCODE_NEXT_SPEC
305
+ ? `${loads}; run \`akm upgrade --next\` to update it, or set "plugin": ["${OPENCODE_PACKAGE}"] to follow stable releases`
306
+ : `${loads}; set "plugin": ["${OPENCODE_PACKAGE}"] to have \`akm upgrade\` keep it current`;
307
+ }
308
+ function upgradeOpenCode(dryRun, cache, latest, tag, notFollowingNext, otherSpec) {
309
+ // Refreshing a cache OpenCode does not load would trash one it never re-creates (#1115, #1117).
310
+ if (otherSpec)
311
+ return skipped("opencode", otherSpecNote(otherSpec));
303
312
  if (!cache || !latest)
304
313
  return skipped("opencode", `no cached ${OPENCODE_PACKAGE}@${tag} plugin`);
305
314
  if ("error" in latest)
@@ -356,13 +365,13 @@ function withNextNote(entry) {
356
365
  return { ...entry, message: entry.message ? `${entry.message}; ${NO_PRERELEASE_CHANNEL}` : NO_PRERELEASE_CHANNEL };
357
366
  }
358
367
  export function upgradePlugins(opts) {
359
- const { cache, latest, tag, notFollowingNext, followingNext } = opts.openCode;
368
+ const { cache, latest, tag, notFollowingNext, otherSpec } = opts.openCode;
360
369
  const claude = upgradeClaudeCode(opts.dryRun);
361
370
  const codex = upgradeCodex(opts.dryRun);
362
371
  return [
363
372
  opts.next ? withNextNote(claude) : claude,
364
373
  opts.next ? withNextNote(codex) : codex,
365
- upgradeOpenCode(opts.dryRun, cache, latest, tag, notFollowingNext, followingNext),
374
+ upgradeOpenCode(opts.dryRun, cache, latest, tag, notFollowingNext, otherSpec),
366
375
  ];
367
376
  }
368
377
  /**
@@ -419,16 +428,30 @@ export function applyLockstep(check, latest, tag = "latest") {
419
428
  /**
420
429
  * Which OpenCode plugin build the CLI is held to, and which cache refreshes.
421
430
  * Under `--next` that is `akm-opencode@next`, but only when the user's OpenCode
422
- * config names that tag: otherwise OpenCode keeps resolving `@latest`, so the
423
- * lockstep stays against the `@latest` pin and the entry is reported as skipped.
431
+ * config names that tag: a bare one keeps resolving `@latest`, so the lockstep
432
+ * stays against the `@latest` pin and the entry is reported as skipped. A config
433
+ * naming any other spec (an exact version, or `@next` on a plain run) is left
434
+ * alone, with no lockstep.
424
435
  */
425
436
  function resolveOpenCodeTarget(next) {
426
- const requestsNext = openCodeConfigRequestsNext();
427
- const followNext = next && requestsNext;
437
+ // No config entry behaves like a bare one: OpenCode would resolve @latest.
438
+ const spec = openCodeConfigSpec() ?? OPENCODE_PACKAGE;
439
+ const followsLatest = spec === OPENCODE_PACKAGE || spec === `${OPENCODE_PACKAGE}@latest`;
440
+ const followNext = next && spec === OPENCODE_NEXT_SPEC;
441
+ // Any other spec loads a cache this run does not refresh, and pins no akm-cli it should be held to.
442
+ if (!followsLatest && !followNext) {
443
+ return {
444
+ cache: undefined,
445
+ latest: undefined,
446
+ tag: next ? "next" : "latest",
447
+ notFollowingNext: false,
448
+ otherSpec: spec,
449
+ };
450
+ }
428
451
  const tag = followNext ? "next" : "latest";
429
452
  const cache = detectOpenCodeCache(tag);
430
453
  const latest = cache ? (followNext ? lookupOpenCodeNext() : lookupOpenCodeLatest()) : undefined;
431
- return { cache, latest, tag, notFollowingNext: next && !followNext, followingNext: !next && requestsNext };
454
+ return { cache, latest, tag, notFollowingNext: next && !followNext };
432
455
  }
433
456
  /** `akm upgrade`: the CLI step (held to the OpenCode plugin's akm), then the plugins. */
434
457
  export async function runUpgrade(args, currentVersion, deps) {
@@ -51,14 +51,23 @@ function releaseLockRaw(lockPath) {
51
51
  }
52
52
  /** Create the lock file atomically; `undefined` when another holder already has it. */
53
53
  export function tryAcquireLockSync(lockPath, payload) {
54
+ // Write the payload under a private name, then hard-link it into place: the
55
+ // link is the exclusive step and the lock never exists without its payload.
56
+ // A `wx` write creates the file empty and fills it in afterwards; a contender
57
+ // probing in that gap reads no pid, calls the live lock stale and reclaims it.
58
+ const tmpPath = `${lockPath}.tmp-${process.pid}-${randomUUID()}`;
59
+ fs.writeFileSync(tmpPath, payload, { flag: "wx" });
54
60
  try {
55
- fs.writeFileSync(lockPath, payload, { flag: "wx" });
61
+ fs.linkSync(tmpPath, lockPath);
56
62
  }
57
63
  catch (err) {
58
64
  if (err.code === "EEXIST")
59
65
  return undefined;
60
66
  throw err;
61
67
  }
68
+ finally {
69
+ releaseLockRaw(tmpPath);
70
+ }
62
71
  let snapshot;
63
72
  try {
64
73
  snapshot = readLockSnapshot(lockPath);
@@ -227,6 +227,12 @@ const jsonSchemaUnsupportedConnections = new Set();
227
227
  * `enable_thinking`): a strict hosted API answers 400 `Unknown parameter`.
228
228
  */
229
229
  const thinkingControlRejectedConnections = new Set();
230
+ /**
231
+ * And for OpenAI's reasoning models: they answer 400 to any `temperature` but
232
+ * the default, and to `max_tokens`, naming `max_completion_tokens` instead.
233
+ */
234
+ const temperatureRejectedConnections = new Set();
235
+ const maxCompletionTokensConnections = new Set();
230
236
  function connectionKey(config) {
231
237
  return `${config.endpoint}|${config.model}`;
232
238
  }
@@ -234,6 +240,8 @@ function connectionKey(config) {
234
240
  export function _resetEndpointSupportTrackersForTests() {
235
241
  jsonSchemaUnsupportedConnections.clear();
236
242
  thinkingControlRejectedConnections.clear();
243
+ temperatureRejectedConnections.clear();
244
+ maxCompletionTokensConnections.clear();
237
245
  }
238
246
  /**
239
247
  * Whether this connection has already been proven, this process, not to
@@ -263,6 +271,10 @@ function isRejectedRequest(err) {
263
271
  }
264
272
  /** A strict API names the field it does not know: `Unknown parameter: 'chat_template_kwargs'.` */
265
273
  const THINKING_FIELD_NAMED = /chat_template_kwargs|enable_thinking/;
274
+ /** `Unsupported value: 'temperature' does not support 0 with this model. Only the default (1) value is supported.` */
275
+ const TEMPERATURE_NAMED = /'temperature'/;
276
+ /** `Unsupported parameter: 'max_tokens' is not supported with this model. Use 'max_completion_tokens' instead.` */
277
+ const MAX_TOKENS_REPLACED = /max_completion_tokens/;
266
278
  /**
267
279
  * A single chat-completion attempt: one HTTP request/response cycle, with an
268
280
  * inline fallback-once when a schema was requested and the provider 4xx's
@@ -275,7 +287,10 @@ const THINKING_FIELD_NAMED = /chat_template_kwargs|enable_thinking/;
275
287
  *
276
288
  * The thinking-control fields get the same treatment (#1045): a 4xx that
277
289
  * names `chat_template_kwargs` or `enable_thinking` is answered by one retry
278
- * without them, which may in turn fall back without the schema.
290
+ * without them, which may in turn fall back without the schema. A 4xx that
291
+ * names `temperature`, or asks for `max_completion_tokens`, is answered the
292
+ * same way: the connection stops sending `temperature`, or sends the token cap
293
+ * as `max_completion_tokens`, for the rest of the process.
279
294
  */
280
295
  async function chatCompletionAttempt(config, messages, options, timeoutMs, includeThinking = (options?.enableThinking ?? config.enableThinking) !== undefined &&
281
296
  !isThinkingControlKnownRejected(config)) {
@@ -286,6 +301,17 @@ async function chatCompletionAttempt(config, messages, options, timeoutMs, inclu
286
301
  catch (err) {
287
302
  if (!isRejectedRequest(err))
288
303
  throw err;
304
+ const key = connectionKey(config);
305
+ if (TEMPERATURE_NAMED.test(err.message) && !temperatureRejectedConnections.has(key)) {
306
+ warnVerbose(`[akm] LLM rejected temperature (${err.statusCode}); retrying once without it: ${err.message}`);
307
+ temperatureRejectedConnections.add(key);
308
+ return chatCompletionAttempt(config, messages, options, timeoutMs, includeThinking);
309
+ }
310
+ if (MAX_TOKENS_REPLACED.test(err.message) && !maxCompletionTokensConnections.has(key)) {
311
+ warnVerbose(`[akm] LLM rejected max_tokens (${err.statusCode}); retrying once with max_completion_tokens: ${err.message}`);
312
+ maxCompletionTokensConnections.add(key);
313
+ return chatCompletionAttempt(config, messages, options, timeoutMs, includeThinking);
314
+ }
289
315
  if (includeThinking && THINKING_FIELD_NAMED.test(err.message)) {
290
316
  warnVerbose(`[akm] LLM rejected chat_template_kwargs/enable_thinking (${err.statusCode}); retrying once without them: ${err.message}`);
291
317
  const fallback = await chatCompletionAttempt(config, messages, options, timeoutMs, false);
@@ -344,11 +370,15 @@ async function chatCompletionAttemptOnce(config, messages, options, timeoutMs, i
344
370
  ? {}
345
371
  : { chat_template_kwargs: { enable_thinking: resolvedEnableThinking }, enable_thinking: resolvedEnableThinking };
346
372
  const reasoningEffortParams = config.reasoningEffort === undefined ? {} : { reasoning_effort: config.reasoningEffort };
373
+ const key = connectionKey(config);
374
+ const maxTokensField = maxCompletionTokensConnections.has(key) ? "max_completion_tokens" : "max_tokens";
347
375
  const requestBody = JSON.stringify({
348
376
  model: config.model,
349
377
  messages,
350
- temperature: options?.temperature ?? config.temperature ?? 0.3,
351
- ...(resolvedMaxTokens !== undefined ? { max_tokens: resolvedMaxTokens } : {}),
378
+ ...(temperatureRejectedConnections.has(key)
379
+ ? {}
380
+ : { temperature: options?.temperature ?? config.temperature ?? 0.3 }),
381
+ ...(resolvedMaxTokens !== undefined ? { [maxTokensField]: resolvedMaxTokens } : {}),
352
382
  ...config.extraParams,
353
383
  ...responseFormat,
354
384
  ...thinkingParams,
@@ -36842,12 +36842,16 @@ function releaseLockRaw(lockPath) {
36842
36842
  } catch {}
36843
36843
  }
36844
36844
  function tryAcquireLockSync(lockPath, payload) {
36845
+ const tmpPath = `${lockPath}.tmp-${process.pid}-${randomUUID()}`;
36846
+ fs7.writeFileSync(tmpPath, payload, { flag: "wx" });
36845
36847
  try {
36846
- fs7.writeFileSync(lockPath, payload, { flag: "wx" });
36848
+ fs7.linkSync(tmpPath, lockPath);
36847
36849
  } catch (err) {
36848
36850
  if (err.code === "EEXIST")
36849
36851
  return;
36850
36852
  throw err;
36853
+ } finally {
36854
+ releaseLockRaw(tmpPath);
36851
36855
  }
36852
36856
  let snapshot;
36853
36857
  try {
@@ -36170,12 +36170,16 @@ function releaseLockRaw(lockPath) {
36170
36170
  } catch {}
36171
36171
  }
36172
36172
  function tryAcquireLockSync(lockPath, payload) {
36173
+ const tmpPath = `${lockPath}.tmp-${process.pid}-${randomUUID()}`;
36174
+ fs7.writeFileSync(tmpPath, payload, { flag: "wx" });
36173
36175
  try {
36174
- fs7.writeFileSync(lockPath, payload, { flag: "wx" });
36176
+ fs7.linkSync(tmpPath, lockPath);
36175
36177
  } catch (err) {
36176
36178
  if (err.code === "EEXIST")
36177
36179
  return;
36178
36180
  throw err;
36181
+ } finally {
36182
+ releaseLockRaw(tmpPath);
36179
36183
  }
36180
36184
  let snapshot;
36181
36185
  try {