akm-cli 0.10.261016-beta → 0.10.261017-beta

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 (104) hide show
  1. package/CHANGELOG.md +100 -0
  2. package/README.md +8 -10
  3. package/SECURITY.md +7 -99
  4. package/STABILITY.md +57 -98
  5. package/dist/assets/stash-skeleton/facts/conventions/backlinks.md +2 -2
  6. package/dist/assets/stash-skeleton/facts/conventions/organization.md +11 -17
  7. package/dist/cli.js +32 -41
  8. package/dist/commands/feedback-cli.js +5 -4
  9. package/dist/commands/health.js +15 -16
  10. package/dist/commands/proposal/proposal-cli.js +1 -1
  11. package/dist/commands/read/registry-search.js +4 -1
  12. package/dist/commands/read/search.js +6 -6
  13. package/dist/commands/sources/self-update.js +9 -5
  14. package/dist/commands/tasks/tasks.js +12 -13
  15. package/dist/core/adapter/adapters/agent-skills-adapter.js +7 -7
  16. package/dist/core/adapter/adapters/akm-task-adapter.js +1 -1
  17. package/dist/core/adapter/adapters/akm-workflow-adapter.js +1 -1
  18. package/dist/core/adapter/adapters/claude-adapter.js +1 -1
  19. package/dist/core/adapter/adapters/dotenv-adapter.js +1 -1
  20. package/dist/core/adapter/adapters/generic-files-adapter.js +1 -1
  21. package/dist/core/adapter/adapters/llm-wiki-adapter.js +1 -1
  22. package/dist/core/adapter/adapters/opencode-adapter.js +1 -1
  23. package/dist/core/adapter/adapters/website-snapshot-adapter.js +1 -1
  24. package/dist/core/bundle-rename.js +17 -7
  25. package/dist/indexer/bundle-identity-guard.js +6 -6
  26. package/dist/indexer/index-written-assets.js +3 -3
  27. package/dist/indexer/indexer.js +12 -8
  28. package/dist/indexer/materialize-embeddings.js +12 -2
  29. package/dist/indexer/passes/metadata.js +103 -46
  30. package/dist/indexer/search/ranking.js +7 -3
  31. package/dist/indexer/search/search-fields.js +1 -1
  32. package/dist/indexer/usage/usage-events.js +30 -8
  33. package/dist/indexer/walk/walker.js +1 -1
  34. package/dist/output/shapes/helpers.js +3 -3
  35. package/dist/output/text/command-format.js +5 -6
  36. package/dist/scripts/akm-migrate-node.js +31 -3
  37. package/dist/scripts/akm-migrate.js +31 -3
  38. package/dist/sources/providers/git-provider.js +2 -4
  39. package/dist/sources/providers/provider-utils.js +8 -13
  40. package/dist/sources/snapshot-fetchers/website-ingest.js +6 -7
  41. package/dist/storage/repositories/events-repository.js +15 -0
  42. package/dist/storage/repositories/improve-ledger-repository.js +13 -0
  43. package/dist/storage/repositories/index-entries-repository.js +43 -5
  44. package/dist/storage/repositories/outcome-repository.js +12 -0
  45. package/dist/storage/repositories/proposals-repository.js +5 -5
  46. package/dist/storage/repositories/salience-repository.js +13 -0
  47. package/dist/storage/repositories/task-history-repository.js +8 -7
  48. package/dist/storage/repositories/workflow-runs-repository.js +10 -8
  49. package/docs/README.md +24 -60
  50. package/docs/agents/README.md +3 -8
  51. package/docs/architecture/README.md +18 -20
  52. package/docs/architecture/adapters.md +40 -43
  53. package/docs/architecture/architecture.md +171 -151
  54. package/docs/architecture/improvement.md +95 -91
  55. package/docs/architecture/internals/classification.md +101 -119
  56. package/docs/architecture/internals/fresh-host-rebuild-runbook.md +33 -35
  57. package/docs/architecture/internals/health-advisories.md +59 -46
  58. package/docs/architecture/internals/improve-workflow.md +166 -693
  59. package/docs/architecture/internals/indexing.md +65 -465
  60. package/docs/architecture/internals/storage-locations.md +301 -848
  61. package/docs/architecture/persisted-data-compat.md +6 -6
  62. package/docs/architecture/specs/okf-support.md +67 -95
  63. package/docs/architecture/specs/ref.md +67 -125
  64. package/docs/architecture/testing/testing-workflow.md +107 -167
  65. package/docs/architecture/workflow-engine.md +34 -33
  66. package/docs/guides/README.md +5 -5
  67. package/docs/guides/author-bundles.md +72 -98
  68. package/docs/guides/author-workflows.md +11 -18
  69. package/docs/guides/bundles.md +91 -123
  70. package/docs/guides/capture-knowledge.md +10 -9
  71. package/docs/guides/concepts.md +45 -30
  72. package/docs/guides/discover-and-load.md +39 -32
  73. package/docs/guides/getting-started.md +24 -24
  74. package/docs/guides/improve-the-library.md +98 -80
  75. package/docs/guides/recipes/headless-install.md +4 -4
  76. package/docs/guides/recipes/website-source.md +9 -5
  77. package/docs/guides/run-workflows.md +10 -11
  78. package/docs/guides/scheduling.md +11 -17
  79. package/docs/guides/use-with-any-agent.md +15 -14
  80. package/docs/guides/wikis.md +6 -9
  81. package/docs/integration/bundling-akm.md +21 -26
  82. package/docs/maintainers/README.md +2 -2
  83. package/docs/maintainers/local-development.md +3 -16
  84. package/docs/migration/README.md +2 -1
  85. package/docs/migration/release-notes/0.10.0.md +167 -22
  86. package/docs/migration/release-notes/README.md +2 -2
  87. package/docs/migration/v0.9-to-v0.10.md +47 -7
  88. package/docs/product-surface.md +10 -8
  89. package/docs/reference/README.md +26 -15
  90. package/docs/reference/asset-types.md +11 -12
  91. package/docs/reference/bundle-types.md +6 -5
  92. package/docs/reference/cli.md +52 -28
  93. package/docs/reference/configuration.md +46 -60
  94. package/docs/reference/data-and-telemetry.md +204 -421
  95. package/docs/reference/env-and-secrets.md +80 -83
  96. package/docs/reference/memory.md +1 -1
  97. package/docs/reference/refs.md +23 -36
  98. package/docs/reference/registry.md +138 -348
  99. package/docs/reference/supported-formats.md +8 -8
  100. package/docs/reference/tasks.md +13 -19
  101. package/docs/reference/website-sources.md +23 -15
  102. package/docs/reference/workflow-schema.md +28 -47
  103. package/docs/reference/workflows.md +33 -37
  104. package/package.json +1 -1
@@ -440,23 +440,25 @@ export class WorkflowRunsRepository {
440
440
  * finishes or abandons them — the rename lists them rather than touching them).
441
441
  */
442
442
  export function countWorkflowRunRefsForRename(db, oldBundleId) {
443
- const like = `${escapeLikePattern(oldBundleId)}//%`;
444
- const refs = db.prepare(`SELECT COUNT(*) AS n FROM workflow_runs WHERE workflow_ref LIKE ? ESCAPE '\\'`).get(like).n;
443
+ const prefix = `${oldBundleId}//`;
444
+ const refs = db
445
+ .prepare(`SELECT COUNT(*) AS n FROM workflow_runs WHERE substr(workflow_ref, 1, length(?)) = ?`)
446
+ .get(prefix, prefix).n;
445
447
  const active = db
446
- .prepare(`SELECT id, workflow_ref AS workflowRef, status FROM workflow_runs WHERE workflow_ref LIKE ? ESCAPE '\\' AND status IN ('active', 'blocked') ORDER BY updated_at DESC, created_at DESC`)
447
- .all(like);
448
+ .prepare(`SELECT id, workflow_ref AS workflowRef, status FROM workflow_runs WHERE substr(workflow_ref, 1, length(?)) = ? AND status IN ('active', 'blocked') ORDER BY updated_at DESC, created_at DESC`)
449
+ .all(prefix, prefix);
448
450
  return { refs, active };
449
451
  }
450
452
  /**
451
453
  * Rewrite every `workflow_runs.workflow_ref` naming `oldBundleId` to
452
454
  * `newBundleId` (`akm bundle rename`). A legacy unqualified ref is not matched
453
- * by the `LIKE` prefix and is left alone. Returns the number of rows rewritten.
455
+ * by the `<old>//` prefix and is left alone. Returns the number of rows rewritten.
454
456
  */
455
457
  export function renameWorkflowRunRefs(db, oldBundleId, newBundleId) {
456
- const prefix = `${escapeLikePattern(oldBundleId)}//`;
458
+ const prefix = `${oldBundleId}//`;
457
459
  return Number(db
458
- .prepare(`UPDATE workflow_runs SET workflow_ref = ? || substr(workflow_ref, length(?) + 1) WHERE workflow_ref LIKE ? ESCAPE '\\'`)
459
- .run(newBundleId, oldBundleId, `${prefix}%`).changes);
460
+ .prepare(`UPDATE workflow_runs SET workflow_ref = ? || substr(workflow_ref, length(?) + 1) WHERE substr(workflow_ref, 1, length(?)) = ?`)
461
+ .run(newBundleId, oldBundleId, prefix, prefix).changes);
460
462
  }
461
463
  /**
462
464
  * Run `fn` against a {@link WorkflowRunsRepository} bound to state.db
package/docs/README.md CHANGED
@@ -1,12 +1,8 @@
1
1
  # Documentation
2
2
 
3
3
  AKM is a portable capability library for AI agents: one library for every
4
- agent. This hub is organized by what you're trying to do, not by directory —
5
- start here, then follow links out to the guides, reference, and architecture
6
- pages as you need more depth. Each subdirectory also has its own README
7
- indexing everything inside it.
8
-
9
- Full per-directory indexes: [Guides](guides/README.md),
4
+ agent. This hub is organized by what you're trying to do. Each subdirectory
5
+ also has its own README indexing everything inside it: [Guides](guides/README.md),
10
6
  [Reference](reference/README.md), [Agents](agents/README.md),
11
7
  [Architecture](architecture/README.md), [Maintainers](maintainers/README.md),
12
8
  [Migration](migration/README.md), [Posts](posts/README.md).
@@ -14,80 +10,50 @@ Full per-directory indexes: [Guides](guides/README.md),
14
10
  ## Start
15
11
 
16
12
  - [Product Surface](product-surface.md) -- Every feature and its status
17
- - [Getting Started](guides/getting-started.md) -- Install akm, connect a source, and pull a curated shortlist in five to seven minutes
18
- - [Concepts](guides/concepts.md) -- Capabilities, bundles, adapters, asset types, and refs -- the mental model in one page
19
- - [Agent Install Guide](agents/agent-install.md) -- Step-by-step automated (non-interactive) install for agents
13
+ - [Getting Started](guides/getting-started.md) -- Install akm, connect a source, and pull a curated shortlist
14
+ - [Concepts](guides/concepts.md) -- Capabilities, bundles, adapters, and refs: the mental model in one page
15
+ - [Agent Install Guide](agents/agent-install.md) -- Automated, non-interactive install for agents
20
16
  - [Upgrade from 0.9 to 0.10](migration/v0.9-to-v0.10.md) -- The current upgrade path: the order to follow, every removed CLI spelling, config key and workflow feature with its replacement, and what a scheduled `akm improve` now does
21
- - `akm hints` (complete guide by default; `akm hints --detail brief` for the short one) -- The CLI reference agents load to use akm; always the embedded corpus at `src/assets/hints/cli-hints-{full,short}.md`
17
+ - `akm hints` -- The CLI guide agents load (complete by default; `akm hints --detail brief` for the short one)
22
18
 
23
19
  ## Use
24
20
 
25
- One library for every agent: connect what you already have, load only what
26
- the task needs, and capture what you learn along the way.
27
-
28
- - [Use AKM With Any Agent](guides/use-with-any-agent.md) -- Wire akm into Claude Code, OpenCode, Cursor, and other coding assistants with a three-line system prompt block
21
+ - [Use AKM With Any Agent](guides/use-with-any-agent.md) -- Wire akm into Claude Code, OpenCode, Cursor, and other coding assistants
29
22
  - [Discover and Load](guides/discover-and-load.md) -- Search, curate a shortlist, and load exactly the ref a task needs
30
23
  - [Bundles](guides/bundles.md) -- Connect local dirs, git repos, npm packages, and websites; browse the registry
31
24
  - [Capture Knowledge](guides/capture-knowledge.md) -- `akm remember`, `akm import`, and how captured material becomes available to every agent
32
25
  - [Wikis](guides/wikis.md) -- Multi-wiki knowledge bases (Karpathy-style)
33
- - [Environment & Secrets](reference/env-and-secrets.md) -- `akm env` and `akm secret`: exact operations, file modes, and the security guarantee
26
+ - [Environment & Secrets](reference/env-and-secrets.md) -- `akm env` and `akm secret`: operations and file modes
34
27
  - [Run Workflows](guides/run-workflows.md) -- Start or continue a run, check on it, resume it, or abandon it
35
- - [Scheduling](guides/scheduling.md) -- Run akm tasks through the OS scheduler (cron / launchd / schtasks) safely
36
- - [Improve the Library](guides/improve-the-library.md) -- Feedback, history, and proposals -- how evidence turns into reviewable changes
28
+ - [Scheduling](guides/scheduling.md) -- Run akm tasks through the OS scheduler (cron / launchd / schtasks)
29
+ - [Improve the Library](guides/improve-the-library.md) -- Feedback, history, and proposals: how evidence turns into reviewable changes
37
30
  - Recipes: [Turn a Website into a Searchable Bundle](guides/recipes/website-source.md), [Headless Install](guides/recipes/headless-install.md)
38
31
 
39
32
  ## Build and operate
40
33
 
41
- Package complete capabilities and turn knowledge into repeatable work.
42
-
43
- - [Bundle Author's Guide](guides/author-bundles.md) -- Build a bundle, make it discoverable, and share it so others can install it with `akm bundle add`
34
+ - [Bundle Author's Guide](guides/author-bundles.md) -- Build a bundle, make it discoverable, and share it
44
35
  - [Author's Guide: Writing Workflows](guides/author-workflows.md) -- Write and test a workflow definition, from a minimal example to gates and outputs
45
- - [Bundling akm](integration/bundling-akm.md) -- Ship akm inside your own product: the pin/migrate/health boot contract, plan JSON shapes, and exit codes for bundlers
46
-
47
- ### Maintainers
48
-
49
- Working on akm itself, not just using it.
50
-
51
- - [Maintainer Docs](maintainers/README.md) -- Start here: local development, the release checklist, and measuring improvement
52
- - [Local Development](maintainers/local-development.md) -- Dogfooding akm while editing its own source
36
+ - [Bundling akm](integration/bundling-akm.md) -- Ship akm inside your own product: the pin/migrate/health boot contract, plan JSON shapes, and exit codes
37
+ - [Maintainer Docs](maintainers/README.md) -- Local development and the release checklist
53
38
 
54
39
  ## Look up details
55
40
 
56
41
  - [CLI](reference/cli.md) -- All `akm` commands and flags
57
42
  - [Configuration](reference/configuration.md) -- Connections, harnesses, strategies, bundles, and settings
58
43
  - [Supported Formats](reference/supported-formats.md) -- Every bundle format akm recognizes, its detection marker, and current read/write support
59
- - [Tasks](reference/tasks.md) -- Task source v4 files, targets, triggers, and the explicit `akm migrate apply` conversion of v2 and v3 files
60
44
  - [Asset Types](reference/asset-types.md) -- The capability taxonomy, directory conventions, and per-type examples
61
45
  - [Refs](reference/refs.md) -- The ref grammar `akm search` emits and `akm show` consumes
62
46
  - [Memory](reference/memory.md) -- The `memory` asset type: capture, belief states, and derived memories
63
- - [Workflow Schema](reference/workflow-schema.md) -- Authoritative frontmatter/body syntax for a workflow asset
64
- - [Workflows (overview)](reference/workflows.md) -- Short map across the workflow schema, engine, and how-to guides
47
+ - [Tasks](reference/tasks.md) -- Task source v4 files, targets, triggers, scheduling, and the explicit `akm migrate apply` conversion of v2 and v3 files
48
+ - [Workflow Schema](reference/workflow-schema.md) -- Frontmatter and body syntax for a workflow asset
65
49
  - [Registry](reference/registry.md) -- Registries, search, hosting, and managing sources
66
- - [Website Sources](reference/website-sources.md) -- The pluggable fetcher API for URL-based knowledge reads
67
- - [Data & Telemetry](reference/data-and-telemetry.md) -- Exactly what akm reads and writes on your machine (no remote telemetry)
68
- - [Architecture Overview](architecture/architecture.md) -- How akm's bundles, cache, index, and registries fit together
69
- - [Core Principles](architecture/akm-core-principles.md) -- How the code, tests and docs in this repo are built: the engineering rules and what enforces each
70
- - [Adapters](architecture/adapters.md) -- How akm picks an adapter, indexes, validates, and writes into a bundle
71
- - [The Workflow Engine](architecture/workflow-engine.md) -- How a frozen plan is stored, dispatched, and resumed without replaying completed units
72
- - [The Improvement Loop](architecture/improvement.md) -- How a feedback signal becomes a ranking change, and how evidence becomes a proposal
73
- - [Specs](architecture/README.md#specs-specs) -- Normative specifications (ref grammar, OKF support)
74
- - [Internals](architecture/README.md#internals-internals) -- Current-truth subsystem references (storage, indexing, classification, improve, health)
75
- - [Testing](architecture/README.md#testing-testing) -- Testing workflow
76
- - [Migration](migration/README.md) -- The current 0.9 to 0.10 upgrade guide, then the historical guides and per-release notes of earlier releases
77
-
78
- ## Execution boundary
50
+ - [Website Sources](reference/website-sources.md) -- The fetcher API for crawling and importing URLs
51
+ - [Data & Telemetry](reference/data-and-telemetry.md) -- What akm reads and writes on your machine
52
+ - [Architecture](architecture/architecture.md) -- How akm fits together, and the invariants every command keeps; [Core Principles](architecture/akm-core-principles.md) -- How the code, tests and docs in this repo are built; [the architecture index](architecture/README.md) lists the subsystem references
79
53
 
80
- AKM retrieves every supported capability type. It directly orchestrates
81
- defined execution surfaces such as workflows, agent dispatch, tasks, and
82
- guarded subprocess injection. It does not blindly execute arbitrary indexed
83
- content merely because that content appears in search results. See
84
- [The Improvement Loop](architecture/improvement.md) for how that boundary
85
- applies to akm's own self-generated changes.
54
+ ## Migration
86
55
 
87
- ## Posts
88
-
89
- Source articles for the dev.to publishing pipeline (historical record). See
90
- [posts index](posts/README.md).
56
+ - [Migration](migration/README.md) -- The current 0.9 to 0.10 upgrade guide, then the historical guides and per-release notes of earlier releases
91
57
 
92
58
  ## Official Ecosystem Repositories
93
59
 
@@ -100,9 +66,7 @@ Source articles for the dev.to publishing pipeline (historical record). See
100
66
  ---
101
67
 
102
68
  New docs, in five lines: keep one current-truth doc per subsystem, don't fork a
103
- second one. Planning, review, and analysis material lives in the untracked
104
- `.plans/` directory, never under `docs/` -- promote conclusions into the
105
- current-truth doc or drop them. Normative specs live in
106
- `docs/architecture/specs/`. Cite code by symbol and memories by search-terms --
107
- not line numbers or exact refs, both rot. Nothing in `docs/` may reference
108
- `.plans/`.
69
+ second one. Plans, reviews, and analysis do not live under `docs/`; promote
70
+ conclusions into the current-truth doc or drop them. Normative specs live in
71
+ `docs/architecture/specs/`. Cite code by symbol, not line number; line numbers
72
+ rot. Check every command you document with `bun run lint:doc-examples`.
@@ -3,13 +3,8 @@
3
3
  Documentation for wiring AI agents into akm.
4
4
 
5
5
  Run `akm hints` for the complete CLI reference agents should load into a
6
- system prompt, or `akm hints --detail brief` for the compact guide.
7
- It always prints the embedded
8
- corpus at `src/assets/hints/cli-hints-full.md` / `cli-hints-short.md` --
9
- browse those files directly if you want to read the reference without running
10
- the CLI. There used to be a separate `docs/agents/AGENTS.md` /
11
- `AGENTS.full.md` pair here; it fed nothing at runtime after R-006 and kept
12
- re-diverging from the embedded copy with no test to catch it, so it was
13
- deleted and its still-true unique content was merged into the embedded files.
6
+ system prompt, or `akm hints --detail brief` for the compact guide. Both print
7
+ the guide embedded in the CLI (`src/assets/hints/cli-hints-full.md` and
8
+ `cli-hints-short.md`), so you can also read those files directly.
14
9
 
15
10
  - [Agent Install Guide](agent-install.md) -- Short redirect covering the install shape (binary, `akm setup --yes`, a source, an index, `akm hints`); for the exact no-prompts command sequence, see the [headless install recipe](../guides/recipes/headless-install.md)
@@ -1,32 +1,30 @@
1
1
  # Architecture Index
2
2
 
3
- How akm is built: system overview, normative specs, and subsystem internals.
3
+ How akm is built.
4
4
 
5
- - [Architecture](architecture.md) -- How akm's bundles, cache, index, and registries fit together
6
- - [Core Principles](akm-core-principles.md) -- How the code, tests and docs in this repo are built: the engineering rules and what enforces each
7
- - [Adapters](adapters.md) -- The `BundleAdapter` contract: what a bundle's files *are*, how they're indexed, linted, and written
8
- - [Architecture: The Workflow Engine](workflow-engine.md) -- How a workflow compiles to a frozen plan, persists run/unit state, dispatches work, and resumes without replaying completed steps
9
- - [Architecture: The Improvement Loop](improvement.md) -- Purpose and boundary of the improvement loop
10
-
11
- ## Specs (`specs/`)
5
+ ## Overview
12
6
 
13
- Normative specifications and binding conventions.
7
+ - [Architecture](architecture.md) -- How bundles, sources, refs, the index, search and show, writes, registries, and the execution boundary fit together
8
+ - [Core Principles](akm-core-principles.md) -- How the code, tests and docs in this repo are built: the engineering rules and what enforces each
9
+ - [Adapters](adapters.md) -- The `BundleAdapter` contract: how a bundle's files are recognized, indexed, linted, and written
10
+ - [The Workflow Engine](workflow-engine.md) -- How a workflow compiles to a frozen plan, persists run and unit state, dispatches work, and resumes without replaying completed steps
11
+ - [The Improvement Loop](improvement.md) -- How feedback changes ranking and the utility signal, how evidence becomes reviewable proposals, and which writes happen without review
12
+ - [Persisted-Data Compatibility](persisted-data-compat.md) -- What a reader owes data an earlier release wrote, per persisted format
14
13
 
15
- - [OKF format support](specs/okf-support.md) -- OKF is a first-class format supported through the built-in `okf` adapter
16
- - [Ref Format](specs/ref.md) -- Wire format for asset references
14
+ ## Specs
17
15
 
18
- ## Internals (`internals/`)
16
+ - [Ref Format](specs/ref.md) -- The `[bundle//]conceptId[#fragment]` ref grammar
17
+ - [OKF Format Support](specs/okf-support.md) -- What the built-in `okf` adapter reads, and how OKF relates to AKM Markdown
19
18
 
20
- Current-truth subsystem references.
19
+ ## Internals
21
20
 
22
- - [Storage Locations](internals/storage-locations.md) -- Authoritative inventory of every on-disk read/write path
21
+ - [Storage Locations](internals/storage-locations.md) -- Where akm reads and writes on disk
23
22
  - [Indexing](internals/indexing.md) -- How the search index is built
24
- - [Classification](internals/classification.md) -- Matcher and renderer behavior
25
- - [Improve Workflow](internals/improve-workflow.md) -- `akm improve` command surface and pipeline reference
26
- - [Health Advisories](internals/health-advisories.md) -- `akm health` advisory-to-action map for operators
23
+ - [Classification](internals/classification.md) -- How adapters recognize files and pick renderers
24
+ - [Improve Workflow](internals/improve-workflow.md) -- `akm improve` command surface and per-step pipeline reference
25
+ - [Health Advisories](internals/health-advisories.md) -- The `akm health` checks and what to do about each
27
26
  - [Fresh-Host Rebuild Runbook](internals/fresh-host-rebuild-runbook.md) -- Rebuild an akm install on a new machine
28
- - [Persisted-Data Compatibility Contract](persisted-data-compat.md) -- What a reader owes data an earlier release wrote, per persisted format
29
27
 
30
- ## Testing (`testing/`)
28
+ ## Testing
31
29
 
32
- - [Testing Workflow](testing/testing-workflow.md) -- End-to-end, Docker, deployment, and upgrade validation, plus the coverage gap guide
30
+ - [Testing Workflow](testing/testing-workflow.md) -- Test layers, isolation rules, Docker and upgrade validation
@@ -2,7 +2,7 @@
2
2
 
3
3
  A **`BundleAdapter`** (`src/core/adapter/bundle-adapter.ts`) is the code that
4
4
  decides what a bundle's files *are*, how they're indexed, how `akm lint`
5
- validates them, and where a new item would be placed. 0.9.0 ships 11
5
+ validates them, and where a new item would be placed. akm ships 11
6
6
  built-in adapters — one per format in
7
7
  [Supported Formats](../reference/supported-formats.md). This page is the
8
8
  write-path and internals reference; that page is the compatibility table.
@@ -11,8 +11,8 @@ For read-only native tool bundles, recognition is runtime translation, not
11
11
  conversion: the adapter projects native files into AKM's index/runtime shapes
12
12
  while the source file remains authoritative. AKM does not synchronize native
13
13
  formats, maintain translated canonical copies, or write agent/command assets
14
- back through the Claude/OpenCode adapters. Execution of agent and command
15
- assets is described in [Architecture: Connections and Harnesses](architecture.md#connections-and-harnesses).
14
+ back through the Claude/OpenCode adapters. Execution of agent and command assets
15
+ is described in [Architecture: Connections and Harnesses](architecture.md#connections-and-harnesses).
16
16
 
17
17
  > **Stability note.** The adapter set, bundle-recognition rules, and the
18
18
  > `bundles` config shape are still evolving — see [STABILITY.md](../../STABILITY.md).
@@ -31,9 +31,9 @@ install/index time:
31
31
  returns `true` claims the root.
32
32
  3. If no probe fires, the bundle falls back to the `akm` adapter.
33
33
 
34
- The order is pinned by `BUILTIN_ADAPTERS` (`src/core/adapter/adapters/index.ts`)
35
- and enforced by the conformance suite's ordered-owner matrix — it, not any
36
- prose spec listing, is authoritative:
34
+ The order is the array order of `BUILTIN_ADAPTERS`
35
+ (`src/core/adapter/adapters/index.ts`), pinned by
36
+ `tests/core/adapter/registry.test.ts`:
37
37
 
38
38
  ```text
39
39
  website-snapshot -- root manifest.json {url, fetchedAt}
@@ -42,7 +42,7 @@ claude -- root CLAUDE.md + commands/|agents/|skills/
42
42
  opencode -- opencode.json(c), or root AGENTS.md + a tool dir
43
43
  dotenv -- every top-level dir is env/ and/or secrets/
44
44
  akm-workflow -- a top-level .md with explicit type: workflow
45
- akm-task -- a top-level valid task source v4 .yml (schedule optional)
45
+ akm-task -- a top-level task source .yml (v4, or a v2/v3 file awaiting migration)
46
46
  llm-wiki -- root schema.md + pages/
47
47
  akm -- .stash marker, or 2+ native subdirs, or fallback
48
48
  okf -- root index.md, or any .md with frontmatter type
@@ -91,15 +91,19 @@ interface BundleAdapter {
91
91
  affectedItems?(c: BundleComponent, changedPaths: string[]): string[];
92
92
 
93
93
  // REQUIRED — native validation (change-transaction pre-commit + lint --fix).
94
- // Adapters MUST NOT write and MUST NOT read the live filesystem: ctx serves
94
+ // Adapters do not write and do not read the live filesystem: ctx serves
95
95
  // a run snapshot with pending changes overlaid, plus a read-only
96
96
  // resolveRef for link/xref existence.
97
97
  validate(c: BundleComponent, changes: FileChange[], ctx: ValidateContext): Promise<Diagnostic[]>;
98
98
 
99
+ // OPTIONAL — runtime translation for executable agent/command assets: returns
100
+ // the frontmatter-free command or persona source the execution boundary uses.
101
+ renderExecutionSource?(c: BundleComponent, file: FileContext): AdapterRenderedExecutionSource | null;
102
+
99
103
  // OPTIONAL — the CLOSED-FORM set of existing-file placements/read aliases
100
104
  // that could own `conceptId`, used for first-owner arbitration without
101
105
  // reading authored bytes or walking the bundle.
102
- readCandidates?(c: BundleComponent, conceptId: string): Array<{ path: string; conceptId: string }>;
106
+ readCandidates?(c: BundleComponent, conceptId: string): AdapterReadCandidate[]; // { path, conceptId }
103
107
 
104
108
  // OPTIONAL — discovery.
105
109
  directoryList?(c: BundleComponent): string[]; // owned dirs; feeds git exact-path staging
@@ -108,7 +112,7 @@ interface BundleAdapter {
108
112
  ```
109
113
 
110
114
  `recognize` and `validate` are required on every adapter; `index`,
111
- `affectedItems`, `readCandidates`, `directoryList`, and
115
+ `affectedItems`, `renderExecutionSource`, `readCandidates`, `directoryList`, and
112
116
  `looksLikeRoot` are optional capability methods. An adapter overriding `index()` must keep
113
117
  `recognize()` coherent with it (conformance: `index()` == fold of
114
118
  `recognize()` over the core walk) or declare component-level
@@ -121,7 +125,7 @@ physical-owner decision. Each candidate carries its canonical concept identity,
121
125
  so a byte-denying ownership probe never has to infer identity from the query.
122
126
  Path-derived recognition (`toCanonicalName`/`toAssetPath`, `src/core/asset/asset-placement.ts`)
123
127
  is a deterministic function of a file's path, so its inverse — every physical
124
- spelling that could own one conceptId — is computable in CLOSED FORM (#857):
128
+ spelling that could own one conceptId — is computable in closed form:
125
129
  the canonical placement under the type's own bundle subdir, the loose
126
130
  off-canonical placement (an authored path elsewhere in the bundle, keyed off
127
131
  its full path relative to the bundle root instead of the type subdir — this
@@ -135,8 +139,8 @@ adapter returning a candidate the file does not actually own is harmless —
135
139
  it is simply filtered out.
136
140
 
137
141
  The core walk — the live indexer's per-dir walk, drained by
138
- `drainDirDocuments` — is one implementation carrying the security policy
139
- (symlink-safety, skip-dirs, git-awareness); adapters never reimplement it.
142
+ `drainDirDocuments` — is one implementation (symlink handling, skipped
143
+ directories, git awareness); adapters do not reimplement it.
140
144
 
141
145
  Cross-component ref existence is a **core** base check, not an adapter
142
146
  concern.
@@ -157,9 +161,9 @@ writable bundles in another layout would need it back: see
157
161
 
158
162
  ## Write allowlists
159
163
 
160
- Which bundles AKM-native write commands are allowed to touch at all is decided by a
161
- small allowlist check, `assertAkmAssetWrite` (`src/core/write-source.ts`),
162
- run before any write command touches the filesystem. It compares the target
164
+ Which bundles AKM-native write commands may touch is decided by a small
165
+ allowlist check, `assertAkmAssetWrite` (`src/core/write-source.ts`), run before
166
+ any write command touches the filesystem. It compares the target
163
167
  bundle's detected (or configured) adapter id against an allowlist and throws
164
168
  a `UsageError` on a miss.
165
169
 
@@ -180,11 +184,9 @@ creating, editing, or deleting through AKM's own commands is restricted.
180
184
  "Read-only" in [Supported Formats](../reference/supported-formats.md) means
181
185
  this write-command restriction, not a filesystem permission.
182
186
 
183
- This allowlist boundary is also where AKM's [execution
184
- boundary](../guides/concepts.md) principle shows up on the write side: AKM
185
- retrieves and validates every supported format, but it only lets its own
186
- write commands mutate a narrow, explicitly-declared set of targets — it
187
- does not widen write access to a format just because it can read it.
187
+ AKM retrieves and validates every supported format, but its own write
188
+ commands mutate only the targets on the allowlist; being able to read a format
189
+ does not add it.
188
190
 
189
191
  ---
190
192
 
@@ -193,10 +195,15 @@ does not widen write access to a format just because it can read it.
193
195
  The native and standalone `akm-task` paths delegate to the authoritative task
194
196
  source parser, `parseTaskSource`, which accepts only `version: 4` (task
195
197
  source v4). A task source v4 document declares exactly one executable
196
- selector (`uses` or `run`), but its scheduling is OPTIONAL — a document with
198
+ selector (`uses` or `run`), but its scheduling is optional — a document with
197
199
  no `schedule:` is valid and runnable manually. A `version: 3` or `version: 2`
198
- document is no longer read by `src` at all: it fails closed with
199
- `TASK_SCHEMA_VERSION_UNSUPPORTED`, naming `akm migrate` as the path forward.
200
+ document is not read: it raises `TASK_SCHEMA_VERSION_UNSUPPORTED`, naming
201
+ `akm migrate apply`, which converts it. The `akm-task` probe still recognizes a
202
+ root of v2/v3 task files so the migrator can find them. Targets are
203
+ `akm/command` and canonical `commands/`, `workflows/`, and `scripts/` refs;
204
+ the github-action `uses:` variant, agent refs, and task refs are refused.
205
+ `.yaml` is a collection hint only: recognition gates on `.yml`, so a `.yaml`
206
+ near miss is diagnosed (`invalid-task-yaml`) but never indexed or scheduled.
200
207
  See [Tasks](../reference/tasks.md) for the public source contract and the
201
208
  migration path.
202
209
 
@@ -219,26 +226,16 @@ they actually work:
219
226
  - **`claude`/`opencode` share one codec** (`tool-dir-shared.ts`) and differ
220
227
  only in instruction filename and adapter/component ids. Both accept only
221
228
  the canonical plural tool directories.
222
- - **`dotenv` redaction is a hard, adapter-level contract.** No frontmatter
223
- `type:` override can bypass it: `env` entries surface only key names,
224
- `secret` entries surface only the file name, never content. A `.env`
225
- file placed under `secrets/` is a secret (name-only), not an env group —
226
- the directory gate wins over the `.env` suffix.
229
+ - **`dotenv` redaction is keyed on the adapter.** A frontmatter `type:` does
230
+ not change it: `env` entries surface only key names and `secret` entries
231
+ surface only the file name. A `.env` file placed under `secrets/` is a secret
232
+ (name-only), not an env group — the directory wins over the `.env` suffix.
227
233
  - **Task adapters share one task source parser.** A standalone `akm-task`
228
234
  bundle and task files owned by the native `akm` adapter both route through
229
- `parseTaskSource`, which accepts only `version: 4` (task source v4) — a
230
- `version: 3` or `version: 2` document fails closed with
231
- `TASK_SCHEMA_VERSION_UNSUPPORTED` and is never indexed, validated, or run.
232
- Task source v4 requires exactly one `uses` or `run` executable selector,
233
- but its `schedule:` is OPTIONAL. It recognizes `akm/command`, `commands/`,
234
- `workflows/`, and `scripts/` targets, refuses the github-action `uses:`
235
- variant entirely (removed in v4 — no equivalent spelling), and refuses
236
- agent/task refs and unsupported actions. `.yaml` is a collection hint only:
237
- recognition still gates on `.yml`, so the near miss is diagnosed but never
238
- indexed or scheduled. See the [Tasks reference](../reference/tasks.md).
239
- - **`llm-wiki`, `akm`, and `okf` all reserve `index.md`/`log.md`** as
240
- structural files — never indexed as concepts, never valid write targets —
241
- at any depth.
235
+ `parseTaskSource` (see [Task adapter](#task-adapter)).
236
+ - **`akm` and `okf` reserve `index.md`/`log.md`** as structural files — never
237
+ indexed as concepts, never valid write targets — at any depth. `llm-wiki`
238
+ reserves `schema.md`, `index.md` and `log.md` only at the wiki root.
242
239
  - **`okf`'s lenient wording is not a lenient gate.** `missing-type` and
243
240
  broken-link findings are labelled `info:`/`warning:` in the diagnostic
244
241
  text, but diagnostics carry no severity field: `akm lint` funnels every
@@ -254,5 +251,5 @@ they actually work:
254
251
 
255
252
  - [Supported Formats](../reference/supported-formats.md) — the compatibility table this page's internals back
256
253
  - [Asset Types](../reference/asset-types.md) — the `akm` adapter's 14 native asset types
257
- - [Concepts](../guides/concepts.md) — the retrieval loop and execution boundary these adapters serve
254
+ - [Concepts](../guides/concepts.md) — the retrieval loop these adapters serve
258
255
  - [Architecture](architecture.md) — sources, refs, the search pipeline, and the write-source chokepoint