akm-cli 0.9.0-rc.2 → 0.9.0-rc.3

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 (88) hide show
  1. package/CHANGELOG.md +34 -8
  2. package/dist/assets/improve-strategies/catchup.json +3 -1
  3. package/dist/assets/improve-strategies/consolidate.json +3 -1
  4. package/dist/assets/improve-strategies/frequent.json +3 -1
  5. package/dist/assets/improve-strategies/graph-refresh.json +3 -1
  6. package/dist/assets/improve-strategies/memory-focus.json +4 -1
  7. package/dist/assets/improve-strategies/proactive-maintenance.json +1 -0
  8. package/dist/assets/improve-strategies/quick.json +3 -1
  9. package/dist/assets/improve-strategies/recombine-only.json +2 -0
  10. package/dist/assets/improve-strategies/reflect-distill.json +1 -0
  11. package/dist/assets/improve-strategies/synthesize.json +2 -0
  12. package/dist/assets/tasks/core/backup.yml +2 -2
  13. package/dist/cli/config-migrate.js +554 -26
  14. package/dist/cli.js +3 -1
  15. package/dist/commands/backup-cli.js +6 -4
  16. package/dist/commands/config-cli.js +10 -3
  17. package/dist/commands/feedback-cli.js +24 -7
  18. package/dist/commands/health/checks.js +94 -15
  19. package/dist/commands/health/surfaces.js +2 -1
  20. package/dist/commands/improve/anti-collapse.js +3 -3
  21. package/dist/commands/improve/collapse-detector.js +5 -5
  22. package/dist/commands/improve/consolidate.js +123 -66
  23. package/dist/commands/improve/distill/promote-memory.js +8 -6
  24. package/dist/commands/improve/distill/quality-gate.js +1 -1
  25. package/dist/commands/improve/distill-guards.js +1 -1
  26. package/dist/commands/improve/distill-promotion-policy.js +32 -26
  27. package/dist/commands/improve/distill.js +52 -36
  28. package/dist/commands/improve/eligibility.js +9 -8
  29. package/dist/commands/improve/extract-prompt.js +2 -2
  30. package/dist/commands/improve/extract.js +43 -11
  31. package/dist/commands/improve/improve-auto-accept.js +14 -28
  32. package/dist/commands/improve/improve-cli.js +4 -2
  33. package/dist/commands/improve/improve-strategies.js +2 -1
  34. package/dist/commands/improve/improve.js +49 -8
  35. package/dist/commands/improve/loop-stages.js +11 -6
  36. package/dist/commands/improve/preparation.js +51 -17
  37. package/dist/commands/improve/procedural.js +10 -6
  38. package/dist/commands/improve/recombine.js +31 -7
  39. package/dist/commands/improve/reflect.js +24 -14
  40. package/dist/commands/improve/salience.js +5 -1
  41. package/dist/commands/improve/source-identity.js +43 -0
  42. package/dist/commands/migrate-cli.js +36 -0
  43. package/dist/commands/mv-cli.js +647 -258
  44. package/dist/commands/proposal/drain.js +16 -4
  45. package/dist/commands/proposal/proposal-cli.js +3 -2
  46. package/dist/commands/proposal/proposal.js +16 -55
  47. package/dist/commands/proposal/repository.js +664 -58
  48. package/dist/commands/read/curate.js +4 -2
  49. package/dist/commands/read/knowledge.js +4 -1
  50. package/dist/commands/read/search.js +6 -2
  51. package/dist/commands/read/show.js +8 -7
  52. package/dist/commands/sources/self-update.js +156 -112
  53. package/dist/commands/sources/sources-cli.js +7 -2
  54. package/dist/core/common.js +36 -3
  55. package/dist/core/config/config-io.js +2 -2
  56. package/dist/core/config/config-schema.js +15 -3
  57. package/dist/core/config/config.js +14 -13
  58. package/dist/core/file-lock.js +2 -2
  59. package/dist/core/migration-backup.js +816 -171
  60. package/dist/core/migration-operation.js +44 -0
  61. package/dist/core/state/migrations.js +4 -7
  62. package/dist/core/state-db.js +22 -7
  63. package/dist/core/write-source.js +86 -18
  64. package/dist/indexer/db/db.js +109 -53
  65. package/dist/indexer/index-writer-lock.js +38 -37
  66. package/dist/indexer/index-written-assets.js +73 -56
  67. package/dist/indexer/indexer.js +5 -1
  68. package/dist/indexer/search/search-source.js +2 -2
  69. package/dist/indexer/usage/usage-events.js +8 -2
  70. package/dist/integrations/agent/engine-resolution.js +14 -7
  71. package/dist/scripts/migrate-storage.js +867 -990
  72. package/dist/scripts/migrations/import-fs-improve-runs-to-db.js +405 -566
  73. package/dist/setup/detected-engines.js +7 -13
  74. package/dist/setup/engine-config.js +14 -4
  75. package/dist/setup/setup.js +1 -1
  76. package/dist/setup/steps/connection.js +1 -1
  77. package/dist/setup/steps/tasks.js +1 -1
  78. package/dist/sources/providers/git-stash.js +58 -21
  79. package/dist/sources/providers/git.js +1 -1
  80. package/dist/storage/engines/sqlite-migrations.js +138 -3
  81. package/dist/storage/repositories/events-repository.js +24 -0
  82. package/dist/storage/repositories/proposals-repository.js +14 -0
  83. package/dist/tasks/embedded.js +2 -0
  84. package/dist/workflows/db.js +24 -13
  85. package/dist/workflows/validator.js +24 -2
  86. package/docs/migration/release-notes/0.9.0.md +24 -7
  87. package/docs/migration/v0.8-to-v0.9.md +124 -19
  88. package/package.json +1 -1
@@ -1,8 +1,9 @@
1
1
  Migration notes for akm v0.9.0
2
2
 
3
- This is the final 0.9.0 cut. If you were already running a 0.9.0 beta, the
4
- main upgrade work is to align scripts, prompts, and stash layout with the
5
- released command surface.
3
+ These notes apply to the 0.9.0 release candidates and final release. If you
4
+ were already running a 0.9.0 beta, align scripts, prompts, and stash layout
5
+ with the current command surface and verify every durable artifact before
6
+ normal use.
6
7
 
7
8
  Key operator-facing changes:
8
9
 
@@ -17,6 +18,9 @@ Key operator-facing changes:
17
18
  - Proposal workflow is fully consolidated around `akm improve`, `akm propose`,
18
19
  and `akm proposal ...`. Update any old `akm reflect`, `akm distill`,
19
20
  `akm accept`, `akm reject`, or `akm proposals` usage.
21
+ - Config, `state.db`, and `workflow.db` are now classified independently by the
22
+ explicit `akm migrate` coordinator. Normal commands refuse old, future, or
23
+ divergent durable schemas instead of attempting migration as a side effect.
20
24
 
21
25
  Primary public command family for 0.9.0:
22
26
 
@@ -28,11 +32,24 @@ Primary public command family for 0.9.0:
28
32
  - `akm proposal accept <id>`
29
33
  - `akm proposal reject <id> --reason "..."`
30
34
 
31
- Recommended post-upgrade checks:
32
-
33
- - Run `akm help migrate 0.9.0` on every machine where the CLI is installed.
35
+ Required upgrade checks:
36
+
37
+ - Before crossing from 0.8 to 0.9, create an independent filesystem backup and
38
+ prepare a valid 0.9 config. The installed 0.8 binary does not know the 0.9
39
+ migration protocol: install or stage the 0.9 binary, then run
40
+ `akm migrate apply --config <prepared-0.9-config>` before any normal command.
41
+ - On an existing 0.9 installation, run `akm migrate status`. If it reports
42
+ `ready`, run `akm migrate apply`; an already-current active config is used as
43
+ the target.
44
+ - Do not continue when status reports `blocked`. Preserve the reported backup
45
+ run and resolve the named artifact or active-operation error first.
46
+ - Restore is explicit and destructive: `akm backup restore --for 0.9.0 --run
47
+ <backup-run-id> --confirm`. It creates and verifies a rescue backup before
48
+ replacing current artifacts.
49
+ - Run `akm help migrate 0.9.0` for the storage and command-surface checklist.
34
50
  - Run `akm-migrate-storage --yes` once if the stash ever used `vaults/`.
35
- - Rebuild the index with `akm index`.
51
+ - Rebuild derived search data with `akm index` only after migration status is
52
+ `current`; indexing does not migrate config or durable schemas.
36
53
  - Review agent instructions and docs for old `vault`, `reflect`, and `distill`
37
54
  examples.
38
55
 
@@ -8,18 +8,100 @@ installation, then migrate the affected assets deliberately.
8
8
 
9
9
  ## Engine And Task Assets
10
10
 
11
- Before editing a 0.8 configuration, create a recovery bundle:
11
+ The 0.8 binary does not contain `akm migrate` or the
12
+ `upgrade --migration-config` contract. Do not attempt to invoke either command
13
+ with 0.8, and do not use 0.8 self-update to cross this boundary.
14
+
15
+ Use this package-manager/manual boundary procedure instead:
16
+
17
+ 1. Stop AKM writers, schedulers, and workflow drivers.
18
+ 2. Prepare the complete 0.9 config in a separate file. Do not replace the live
19
+ 0.8 config; AKM cannot infer names when old LLM and agent profiles collide.
20
+ 3. Take an independent filesystem backup of the live 0.8 `config.json`,
21
+ `state.db`, and `workflow.db` (including any SQLite `-wal`/`-shm` files).
22
+ Store it outside AKM's data directory and verify it before continuing.
23
+ 4. Install 0.9 with the package manager, or download, checksum, and stage the
24
+ 0.9 standalone binary. A package-manager install replaces the managed 0.8
25
+ package; a standalone operator should retain the old executable. Keep the
26
+ independent data backup in either case.
27
+ 5. Invoke the newly installed or staged 0.9 binary, whose migration startup
28
+ bypass can read the old installation without loading its config normally:
29
+
30
+ Package-manager installation examples for step 4:
12
31
 
13
32
  ```sh
14
- akm backup create --for 0.9.0
33
+ npm install -g akm-cli@0.9.0
34
+ # or: bun install -g akm-cli@0.9.0
35
+ # or: pnpm add -g akm-cli@0.9.0
15
36
  ```
16
37
 
17
- The immutable bundle is stored under `$CACHE/migration-backups/0.9.0`
18
- (`$XDG_CACHE_HOME/akm` by default on Linux). It records both present and absent files for
19
- `config.json`, `state.db`, and `workflow.db`, verifies every captured file by
20
- SHA-256, and is created automatically before AKM first opens either canonical
21
- durable database for the 0.9 engine migrations. Do not move individual files
22
- into or out of the bundle; verification fails closed on any mismatch.
38
+ ```sh
39
+ # Package-manager install: this `akm` is now the 0.9 binary.
40
+ akm migrate status --config ./prepared-0.9.json
41
+ akm migrate apply --config ./prepared-0.9.json --dry-run
42
+ akm migrate apply --config ./prepared-0.9.json
43
+
44
+ # Or invoke a checksummed staged standalone binary explicitly.
45
+ ./akm-0.9 migrate status --config ./prepared-0.9.json
46
+ ./akm-0.9 migrate apply --config ./prepared-0.9.json
47
+ ```
48
+
49
+ Status and dry-run perform the same read-only eligibility checks and report the
50
+ source config plus target config explicitly. Apply validates the target in
51
+ memory, creates a verified recovery run, applies pending `state.db` and
52
+ `workflow.db` migrations one transaction at a time, and atomically installs the
53
+ prepared config last. If any later artifact fails, apply restores config and
54
+ both databases from the verified run before returning. Each artifact is
55
+ classified independently, so a current config with pre-cutover databases can be
56
+ recovered safely.
57
+
58
+ Apply records durable `prepared`, `state-applied`, `workflow-applied`,
59
+ `config-applied`, `rollback-prepared`, and `committed` phases. Every phase stores
60
+ streaming size/SHA fingerprints for config, both databases, and SQLite sidecars;
61
+ a resume or rollback first requires the exact live generation. After a process
62
+ crash, ordinary config and canonical database access fail closed; `akm migrate
63
+ status` reports the pending phase and `akm migrate apply` resumes idempotently
64
+ from the retained target and verified backup. Apply also refuses before backup
65
+ while managed database handles, maintenance activities, AKM mutation locks, or
66
+ workflow claims are live.
67
+
68
+ Canonical state/workflow opens check for pending recovery both before and after
69
+ registering their maintenance activity. Config writers perform the second check
70
+ while holding the same config lock used by migration, closing the check/start
71
+ race without recreating files or accepting a write.
72
+
73
+ Each database mutation also writes an operation-specific generation marker in
74
+ the migration transaction. If the process dies after the durable mutation but
75
+ before advancing the apply journal, recovery accepts only that authenticated
76
+ one-artifact adjacent generation while every unaffected fingerprint remains
77
+ exact. Config adjacency is authenticated against the exact serialized target.
78
+ If rollback restore commits before the apply journal is removed, the next apply
79
+ authenticates the live files against the backup generation and removes only the
80
+ stale apply journal.
81
+
82
+ Once already running a contract-capable 0.9 release, future self-upgrades may
83
+ pass a prepared target through the coordinated upgrade path:
84
+
85
+ ```sh
86
+ akm upgrade --migration-config ./prepared-0.9.json
87
+ ```
88
+
89
+ This command is not the 0.8-to-0.9 procedure. The already-installed 0.8 binary
90
+ cannot contain or enforce safeguards added in 0.9, so operators must follow the
91
+ manual boundary above rather than relying on 0.8 self-update. For 0.9+ upgrades,
92
+ the current binary preflights only its current artifact state; it does not parse
93
+ a prepared config for the future release. After installation, only the new
94
+ binary receives `--config` during apply. If the active config is already current,
95
+ no migration-config flag is needed.
96
+
97
+ Recovery runs are stored under
98
+ `$DATA/backups/migrations/<installation-id>/<run-id>/`. They record present and
99
+ absent `config.json`, `state.db`, and `workflow.db` artifacts, ordered migration
100
+ ledgers, sizes, and streaming SHA-256 hashes. SQLite snapshots must also pass
101
+ `PRAGMA quick_check` and ledger-prefix validation before the manifest is
102
+ published. `akm backup create --for 0.9.0` creates an additional unique run when
103
+ an operator wants a manual snapshot. Routine config writes, telemetry, and
104
+ already-current database opens do not depend on any historical run.
23
105
 
24
106
  Replace `profiles.llm.<name>` and `profiles.agent.<name>` with one
25
107
  `engines.<name>` map. Replace `defaults.llm`, `defaults.agent`, and
@@ -374,19 +456,42 @@ workflow lease exists. Then, while still running the 0.9 binary, restore the
374
456
  complete pre-cutover snapshot:
375
457
 
376
458
  ```sh
377
- akm backup restore --for 0.9.0 --confirm
459
+ akm backup restore --for 0.9.0 --run <run-id> --confirm
378
460
  ```
379
461
 
380
- Restore verifies the manifest, permissions, sizes, and checksums before
381
- replacing anything. It restores each original file and removes a canonical DB
382
- that the manifest recorded as originally absent, including its WAL/SHM
383
- sidecars. Restore also holds the global maintenance barrier from its last
384
- lock/lease check through replacement, so a new index writer, improve/extract
385
- lock, lockfile writer, or workflow engine lease cannot start in that window.
386
- The recovery bundle itself remains in `$CACHE` for repeatable recovery. If
387
- verification reports corruption, preserve the bundle and recover
388
- from an independent backup; do not delete the manifest or regenerate it from a
389
- post-cutover config.
462
+ Restore verifies the selected run before changing live files and then creates a
463
+ second verified rescue run of the current installation. It stages every
464
+ replacement beside its destination, writes a durable restore journal,
465
+ quarantines each database together with its WAL/SHM sidecars, and only then
466
+ publishes clean staged files. The journal records a durable committed phase
467
+ before cleanup: an earlier interruption rolls back, while an interruption after
468
+ commit finishes cleanup without mixing generations. While either recovery phase
469
+ is pending, ordinary config and canonical database access fail closed before
470
+ accepting writes or recreating absent files. The selected and rescue runs remain
471
+ under `$DATA`; if verification reports corruption, preserve them and recover
472
+ from an independent backup.
473
+
474
+ Recovery validates the complete restore journal before removing or renaming any
475
+ path: journal format and migration version, phase, exact artifact and SQLite
476
+ sidecar set, operation-bound stage/quarantine names, path uniqueness, source
477
+ backup, and the expected prepared/committed filesystem state. A malformed or
478
+ stale journal remains in place and recovery fails closed for operator diagnosis.
479
+ Committed recovery additionally authenticates each published artifact against
480
+ the selected backup's byte size and streaming SHA-256, then reruns config-state
481
+ validation or SQLite `quick_check` and ledger validation before deleting any
482
+ quarantine or journal.
483
+
484
+ Prepared rollback is itself crash-idempotent. The journal fingerprints the
485
+ original config/database/sidecar generation before quarantine. If recovery dies
486
+ after restoring a quarantine or deleting a stage but before journal deletion,
487
+ the next recovery authenticates the already-restored destination and continues
488
+ cleanup. A same-ledger but byte-different substitution fails closed.
489
+
490
+ Migration config files, manifests, and apply/restore journals are read through
491
+ bounded readers (1 MiB each). Oversized local control files fail closed rather
492
+ than being loaded wholesale. Apply also measures the complete serialized journal
493
+ before its first write; a near-limit config whose expanded target would exceed
494
+ the same cap is rejected before any apply journal or artifact mutation.
390
495
 
391
496
  Only after restore succeeds should you install the older AKM binary. A 0.8
392
497
  binary must not run against a 0.9 config or against `state.db` migration 017 /
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "akm-cli",
3
- "version": "0.9.0-rc.2",
3
+ "version": "0.9.0-rc.3",
4
4
  "type": "module",
5
5
  "description": "akm (Agent Knowledge Management) — A package manager for AI agent skills, commands, tools, and knowledge. Works with Claude Code, OpenCode, Cursor, and any AI coding assistant.",
6
6
  "keywords": [