akm-cli 0.9.14 → 0.9.15-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/CHANGELOG.md +559 -0
  2. package/STABILITY.md +6 -3
  3. package/dist/akm +54 -1
  4. package/dist/akm-migrate +34 -1
  5. package/dist/assets/prompts/reflect-feedback-framing.md +1 -0
  6. package/dist/assets/prompts/reflect-llm-framed-contract.md +2 -0
  7. package/dist/assets/prompts/reflect-llm-schema-contract.md +2 -0
  8. package/dist/assets/tasks/core/improve.yml +1 -1
  9. package/dist/assets/tasks/core/index-refresh.yml +1 -1
  10. package/dist/assets/tasks/improve/akm-graph-refresh-weekly.yml +1 -1
  11. package/dist/assets/tasks/improve/akm-improve-catchup.yml +1 -1
  12. package/dist/assets/tasks/improve/akm-improve-consolidate.yml +1 -1
  13. package/dist/assets/tasks/improve/akm-improve-frequent.yml +1 -1
  14. package/dist/assets/tasks/improve/akm-improve-nightly.yml +1 -1
  15. package/dist/cli/retired-commands.js +0 -1
  16. package/dist/cli/shared.js +9 -0
  17. package/dist/cli/unknown-flags.js +1 -0
  18. package/dist/cli.js +40 -3
  19. package/dist/commands/config-cli.js +85 -3
  20. package/dist/commands/env/env-cli.js +1 -42
  21. package/dist/commands/env/env.js +1 -1
  22. package/dist/commands/env/secret-cli.js +1 -2
  23. package/dist/commands/health/checks.js +357 -63
  24. package/dist/commands/health/engine-usage.js +45 -0
  25. package/dist/commands/health/improve-metrics.js +18 -0
  26. package/dist/commands/health/llm-usage.js +41 -1
  27. package/dist/commands/health/plugin-staleness.js +7 -3
  28. package/dist/commands/health/version-drift.js +93 -0
  29. package/dist/commands/health/windows.js +3 -1
  30. package/dist/commands/health.js +44 -9
  31. package/dist/commands/improve/consolidate/chunking.js +4 -2
  32. package/dist/commands/improve/improve-cli.js +99 -5
  33. package/dist/commands/improve/improve-report.js +154 -0
  34. package/dist/commands/improve/improve-result-file.js +45 -33
  35. package/dist/commands/improve/improve-strategies.js +133 -3
  36. package/dist/commands/improve/improve-usage-report.js +182 -0
  37. package/dist/commands/improve/improve.js +40 -3
  38. package/dist/commands/improve/locks.js +28 -78
  39. package/dist/commands/improve/planner.js +1 -0
  40. package/dist/commands/improve/preparation.js +9 -1
  41. package/dist/commands/improve/reflect.js +44 -4
  42. package/dist/commands/models-cli.js +50 -1
  43. package/dist/commands/proposal/repository.js +8 -3
  44. package/dist/commands/proposal/validators/proposal-quality-validators.js +41 -6
  45. package/dist/commands/proposal/validators/proposal-validators.js +24 -0
  46. package/dist/commands/read/search-cli.js +38 -2
  47. package/dist/commands/read/show.js +103 -4
  48. package/dist/commands/sources/info.js +5 -1
  49. package/dist/commands/sources/installed-stashes.js +58 -16
  50. package/dist/commands/sources/self-update.js +2 -2
  51. package/dist/commands/sources/stash-cli.js +48 -0
  52. package/dist/commands/tasks/tasks-cli.js +49 -2
  53. package/dist/commands/workflow-cli.js +86 -12
  54. package/dist/core/asset/markdown-fragments.js +35 -0
  55. package/dist/core/config/config-schema.js +14 -0
  56. package/dist/core/config/config.js +302 -24
  57. package/dist/core/config/schema/embedding.js +41 -0
  58. package/dist/core/env-secret-ref.js +58 -5
  59. package/dist/core/errors.js +30 -0
  60. package/dist/core/file-lock.js +49 -15
  61. package/dist/core/improve-result.js +51 -0
  62. package/dist/core/loopback.js +17 -0
  63. package/dist/core/parent-watchdog.js +64 -0
  64. package/dist/core/paths.js +11 -0
  65. package/dist/core/run-lock.js +107 -0
  66. package/dist/core/sensitive-marker-path.js +19 -0
  67. package/dist/core/state-db.js +74 -14
  68. package/dist/indexer/index-rebuild-lock.js +73 -0
  69. package/dist/indexer/index-writer-lock.js +40 -1
  70. package/dist/indexer/index-written-assets.js +29 -1
  71. package/dist/indexer/indexer.js +93 -29
  72. package/dist/indexer/materialize-embeddings.js +564 -48
  73. package/dist/indexer/search/db-search.js +49 -2
  74. package/dist/indexer/search/search-source.js +23 -1
  75. package/dist/integrations/agent/engine-resolution.js +96 -6
  76. package/dist/integrations/agent/execution-definitions.js +6 -15
  77. package/dist/integrations/agent/execution-lowering.js +6 -1
  78. package/dist/integrations/agent/execution-preparation.js +1 -1
  79. package/dist/integrations/agent/model-map.js +123 -20
  80. package/dist/integrations/agent/prompts.js +40 -8
  81. package/dist/integrations/agent/runner-dispatch.js +9 -3
  82. package/dist/integrations/agent/runner.js +2 -0
  83. package/dist/llm/client.js +8 -3
  84. package/dist/llm/embedder.js +20 -8
  85. package/dist/llm/embedders/local.js +10 -2
  86. package/dist/llm/embedders/remote.js +497 -32
  87. package/dist/output/shapes/helpers.js +38 -2
  88. package/dist/output/shapes/models-list.js +16 -0
  89. package/dist/output/shapes/passthrough.js +2 -0
  90. package/dist/output/shapes.js +4 -0
  91. package/dist/output/text/command-format.js +29 -0
  92. package/dist/output/text/helpers.js +1 -1
  93. package/dist/output/text/improve-report.js +27 -0
  94. package/dist/{commands/env/marker-path.js → output/text/models.js} +4 -3
  95. package/dist/output/text/show-format.js +4 -0
  96. package/dist/output/text.js +4 -0
  97. package/dist/scripts/akm-migrate-node.js +25146 -21759
  98. package/dist/scripts/akm-migrate.js +24271 -20885
  99. package/dist/storage/repositories/embedding-salvage-repository.js +184 -0
  100. package/dist/storage/repositories/improve-runs-repository.js +34 -0
  101. package/dist/storage/repositories/index-fts-repository.js +49 -6
  102. package/dist/storage/repositories/index-schema.js +16 -0
  103. package/dist/storage/repositories/index-vec-repository.js +30 -0
  104. package/dist/storage/repositories/workflow-runs-repository.js +55 -18
  105. package/dist/tasks/backends/cron.js +14 -7
  106. package/dist/tasks/run/run-native-task.js +23 -1
  107. package/dist/tasks/run/run-workflow-task.js +16 -0
  108. package/dist/workflows/exec/child-workflow.js +2 -2
  109. package/dist/workflows/exec/dispatch-redaction.js +21 -9
  110. package/dist/workflows/exec/run-workflow.js +6 -5
  111. package/dist/workflows/runtime/runs.js +33 -5
  112. package/docs/migration/release-notes/0.9.15.md +133 -0
  113. package/docs/migration/release-notes/README.md +5 -0
  114. package/docs/reference/cli.md +271 -30
  115. package/docs/reference/configuration.md +234 -21
  116. package/docs/reference/data-and-telemetry.md +8 -0
  117. package/docs/reference/tasks.md +16 -1
  118. package/docs/reference/workflow-schema.md +5 -1
  119. package/package.json +1 -1
  120. package/schemas/akm-config.json +47 -0
@@ -2,6 +2,21 @@
2
2
  // License, v. 2.0. If a copy of the MPL was not distributed with this
3
3
  // file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
4
  export const NORMAL_DESCRIPTION_LIMIT = 250;
5
+ const FRAGMENT_PROVENANCE_FIELDS = [
6
+ "selectedRef",
7
+ "parentRef",
8
+ "fragmentOrdinal",
9
+ "fragmentCount",
10
+ "startLine",
11
+ "endLine",
12
+ "previousRef",
13
+ "nextRef",
14
+ "fragmentChars",
15
+ "fragmentEstimatedTokens",
16
+ "parentChars",
17
+ "parentEstimatedTokens",
18
+ ];
19
+ const FRAGMENT_CONTEXT_FIELDS = ["contextMode", "contextMaxChars", "contextTruncated"];
5
20
  export function shapeProposalProducerOutput(result, detail) {
6
21
  if (result.ok === false) {
7
22
  const base = {
@@ -268,8 +283,21 @@ export function shapeSearchHit(hit, detail) {
268
283
  // Stash hit (local or remote)
269
284
  // `ref` is included at `brief` so agents can run `akm show <ref>` without
270
285
  // needing --detail full or --shape agent (REC-03).
271
- if (detail === "brief")
272
- return pickFields(hit, ["type", "name", "ref", "action", "estimatedTokens", "keys"]);
286
+ if (detail === "brief") {
287
+ return pickFields(hit, [
288
+ "type",
289
+ "name",
290
+ "ref",
291
+ "action",
292
+ "estimatedTokens",
293
+ "keys",
294
+ "selectedRef",
295
+ "parentRef",
296
+ "fragmentOrdinal",
297
+ "fragmentCount",
298
+ "parentEstimatedTokens",
299
+ ]);
300
+ }
273
301
  if (detail === "normal") {
274
302
  // `warnings` is projected at `normal` so non-fatal hit-level issues are
275
303
  // visible without forcing callers up to `--detail full`. Optional
@@ -288,6 +316,7 @@ export function shapeSearchHit(hit, detail) {
288
316
  "warnings",
289
317
  "quality",
290
318
  "matchStage",
319
+ ...FRAGMENT_PROVENANCE_FIELDS,
291
320
  ]), NORMAL_DESCRIPTION_LIMIT);
292
321
  if (Array.isArray(hit.keys) && hit.keys.length > 0)
293
322
  shaped.keys = hit.keys;
@@ -314,6 +343,7 @@ export function shapeSearchHitForAgent(hit) {
314
343
  // hit (a strict-AND match is stronger signal than an OR-fallback
315
344
  // recovery match) without going to `--detail full`.
316
345
  "matchStage",
346
+ ...FRAGMENT_PROVENANCE_FIELDS,
317
347
  ]);
318
348
  if (picked.editable !== false)
319
349
  delete picked.editHint;
@@ -360,6 +390,8 @@ export function shapeShowOutput(result, detail, shape = "human") {
360
390
  "steps",
361
391
  "keys",
362
392
  "related",
393
+ ...FRAGMENT_PROVENANCE_FIELDS,
394
+ ...FRAGMENT_CONTEXT_FIELDS,
363
395
  ]);
364
396
  if (shaped.editable !== false)
365
397
  delete shaped.editHint;
@@ -382,6 +414,8 @@ export function shapeShowOutput(result, detail, shape = "human") {
382
414
  "origin",
383
415
  "keys",
384
416
  "related",
417
+ ...FRAGMENT_PROVENANCE_FIELDS,
418
+ ...FRAGMENT_CONTEXT_FIELDS,
385
419
  ]);
386
420
  }
387
421
  const base = pickFields(result, [
@@ -409,6 +443,8 @@ export function shapeShowOutput(result, detail, shape = "human") {
409
443
  "activeRun",
410
444
  "keys",
411
445
  "related",
446
+ ...FRAGMENT_PROVENANCE_FIELDS,
447
+ ...FRAGMENT_CONTEXT_FIELDS,
412
448
  // ref, path, and editable are always projected — at every --detail level,
413
449
  // not just --detail full — so JSON consumers can locate and edit the
414
450
  // asset without needing --detail full (QA #7 / D-14).
@@ -0,0 +1,16 @@
1
+ // This Source Code Form is subject to the terms of the Mozilla Public
2
+ // License, v. 2.0. If a copy of the MPL was not distributed with this
3
+ // file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
+ export const modelsListShapes = [
5
+ {
6
+ command: "models-list",
7
+ handler: (result) => {
8
+ const r = result;
9
+ return {
10
+ ...r,
11
+ shape: r.shape ?? "models-list",
12
+ schemaVersion: r.schemaVersion ?? 1,
13
+ };
14
+ },
15
+ },
16
+ ];
@@ -43,6 +43,7 @@ const PASSTHROUGH_COMMANDS = [
43
43
  "clone",
44
44
  "command-dry-run",
45
45
  "config",
46
+ "config-diff",
46
47
  "env-create",
47
48
  "env-export",
48
49
  "env-remove",
@@ -50,6 +51,7 @@ const PASSTHROUGH_COMMANDS = [
50
51
  "extract",
51
52
  "health",
52
53
  "improve",
54
+ "improve-report",
53
55
  "import",
54
56
  "index",
55
57
  "info",
@@ -22,6 +22,7 @@ import { curateShapes } from "./shapes/curate.js";
22
22
  import { envListShapes } from "./shapes/env-list.js";
23
23
  import { eventsShapes } from "./shapes/events.js";
24
24
  import { migrateShapes } from "./shapes/migrate.js";
25
+ import { modelsListShapes } from "./shapes/models-list.js";
25
26
  import { passthroughShapes } from "./shapes/passthrough.js";
26
27
  import { proposalAcceptShapes } from "./shapes/proposal/accept.js";
27
28
  import { proposalDiffShapes } from "./shapes/proposal/diff.js";
@@ -55,6 +56,7 @@ const BUILT_IN_OUTPUT_SHAPES = [
55
56
  ...envListShapes,
56
57
  ...secretListShapes,
57
58
  ...migrateShapes,
59
+ ...modelsListShapes,
58
60
  // Passthrough commands are registered last so an explicit dedicated handler
59
61
  // above always wins over the identity-stamp fallback for the same name.
60
62
  ...passthroughShapes,
@@ -94,6 +96,8 @@ const LIST_RESULT_COLLECTION_KEYS = {
94
96
  "workflow-list": "runs",
95
97
  "task-history": "rows",
96
98
  "log-list": "events", // `akm log list`
99
+ "config-diff": "rows", // `akm config diff`
100
+ "models-list": "rows", // `akm models list`
97
101
  };
98
102
  function withResultsAlias(command, shaped) {
99
103
  const key = LIST_RESULT_COLLECTION_KEYS[command];
@@ -478,6 +478,35 @@ export function formatListPlain(r) {
478
478
  lines.push("To search: akm search '<query>' | To view an asset: akm show <ref>");
479
479
  return lines.join("\n");
480
480
  }
481
+ /** Render `akm models list`'s `{ rows }` as a column-aligned table (#946). */
482
+ export function formatModelsListPlain(r) {
483
+ const rows = Array.isArray(r.rows) ? r.rows : [];
484
+ if (rows.length === 0)
485
+ return "No model aliases configured.";
486
+ const headers = ["ALIAS", "COLUMN", "MODEL", "SOURCE", "VIA", "ENGINE"];
487
+ const cells = rows.map((row) => [
488
+ String(row.alias ?? "?"),
489
+ String(row.column ?? "?"),
490
+ String(row.model ?? "?"),
491
+ String(row.source ?? "?"),
492
+ String(row.via ?? "?"),
493
+ row.engine !== undefined ? String(row.engine) : "-",
494
+ ]);
495
+ const widths = headers.map((header, i) => {
496
+ let width = header.length;
497
+ for (const cols of cells) {
498
+ const cell = cols[i];
499
+ if (cell !== undefined && cell.length > width)
500
+ width = cell.length;
501
+ }
502
+ return width;
503
+ });
504
+ const renderRow = (cols) => cols
505
+ .map((cell, i) => cell.padEnd(widths[i] ?? cell.length))
506
+ .join(" ")
507
+ .trimEnd();
508
+ return [renderRow(headers), ...cells.map(renderRow)].join("\n");
509
+ }
481
510
  /** Render a single `SourceEntry` — `akm bundle show <name>`'s detail view of one `list` row. */
482
511
  export function formatBundleShowPlain(r) {
483
512
  const name = typeof r.name === "string" ? r.name : "unknown";
@@ -15,7 +15,7 @@
15
15
  *
16
16
  * No registry imports — no circular dependencies.
17
17
  */
18
- export { formatAddPlain, formatBundleShowPlain, formatClonePlain, formatConfigPlain, formatCuratePlain, formatEnvCreatePlain, formatEnvExportPlain, formatEnvListPlain, formatEnvRemovePlain, formatEventLine, formatEventsPlain, formatFeedbackPlain, formatImportPlain, formatIndexPlain, formatInfoPlain, formatInitPlain, formatListPlain, formatRegistryAddPlain, formatRegistryListPlain, formatRegistryRemovePlain, formatRegistrySearchPlain, formatRememberPlain, formatRemovePlain, formatSearchPlain, formatSyncPlain, formatUpdatePlain, formatUpgradePlain, } from "./command-format.js";
18
+ export { formatAddPlain, formatBundleShowPlain, formatClonePlain, formatConfigPlain, formatCuratePlain, formatEnvCreatePlain, formatEnvExportPlain, formatEnvListPlain, formatEnvRemovePlain, formatEventLine, formatEventsPlain, formatFeedbackPlain, formatImportPlain, formatIndexPlain, formatInfoPlain, formatInitPlain, formatListPlain, formatModelsListPlain, formatRegistryAddPlain, formatRegistryListPlain, formatRegistryRemovePlain, formatRegistrySearchPlain, formatRememberPlain, formatRemovePlain, formatSearchPlain, formatSyncPlain, formatUpdatePlain, formatUpgradePlain, } from "./command-format.js";
19
19
  export { formatHealthPlain } from "./health-format.js";
20
20
  export { formatLintPlain } from "./lint-format.js";
21
21
  export { formatGateDecisionSummary, formatProposalAcceptPlain, formatProposalDiffPlain, formatProposalDrainPlain, formatProposalListPlain, formatProposalProducerPlain, formatProposalRejectPlain, formatProposalShowPlain, } from "./proposal-format.js";
@@ -0,0 +1,27 @@
1
+ // This Source Code Form is subject to the terms of the Mozilla Public
2
+ // License, v. 2.0. If a copy of the MPL was not distributed with this
3
+ // file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
+ /**
5
+ * #944 — `akm improve report --format text`. Renders the SAME fixed-width
6
+ * table `formatUsageReportTable` produces for the end-of-run stderr summary
7
+ * (`improve-cli.ts`), prefixed with which run(s) it covers.
8
+ */
9
+ import { formatUsageReportTable } from "../../commands/improve/improve-usage-report.js";
10
+ function formatImproveReportPlain(result) {
11
+ const usageReport = result.usageReport;
12
+ if (!usageReport)
13
+ return null;
14
+ const lines = [];
15
+ if (result.mode === "since") {
16
+ const runIds = Array.isArray(result.runIds) ? result.runIds : [];
17
+ lines.push(`[improve] report since ${String(result.since ?? "?")} (${runIds.length} run${runIds.length === 1 ? "" : "s"})`);
18
+ }
19
+ else {
20
+ lines.push(`[improve] report for run ${String(result.runId ?? "?")}${result.strategy ? ` (strategy: ${result.strategy})` : ""}`);
21
+ }
22
+ lines.push(formatUsageReportTable(usageReport, result.notes));
23
+ return lines.join("\n");
24
+ }
25
+ export const improveReportFormatters = [
26
+ { command: "improve-report", handler: (r) => formatImproveReportPlain(r) },
27
+ ];
@@ -1,6 +1,7 @@
1
1
  // This Source Code Form is subject to the terms of the Mozilla Public
2
2
  // License, v. 2.0. If a copy of the MPL was not distributed with this
3
3
  // file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
- export function sensitiveMarkerPath(assetPath, type) {
5
- return type === "env" ? assetPath.replace(/\.env$/, ".sensitive") : `${assetPath}.sensitive`;
6
- }
4
+ import { formatModelsListPlain } from "./helpers.js";
5
+ export const modelsFormatters = [
6
+ { command: "models-list", handler: (r) => formatModelsListPlain(r) },
7
+ ];
@@ -14,6 +14,10 @@ export function formatShowPlain(r, detail) {
14
14
  lines.push(`# origin: ${String(r.origin)}`);
15
15
  if (r.action)
16
16
  lines.push(`# ${String(r.action)}`);
17
+ if (Array.isArray(r.keys)) {
18
+ const keys = r.keys.map(String);
19
+ lines.push(keys.length > 0 ? `keys: ${keys.join(", ")}` : "(no keys)");
20
+ }
17
21
  if (r.description)
18
22
  lines.push(`description: ${String(r.description)}`);
19
23
  if (r.workflowTitle)
@@ -12,11 +12,13 @@ import { eventsFormatters } from "./text/events.js";
12
12
  import { feedbackFormatters } from "./text/feedback.js";
13
13
  import { healthFormatters } from "./text/health.js";
14
14
  import { importFormatters } from "./text/import.js";
15
+ import { improveReportFormatters } from "./text/improve-report.js";
15
16
  import { indexFormatters } from "./text/index.js";
16
17
  import { infoFormatters } from "./text/info.js";
17
18
  import { lintFormatters } from "./text/lint.js";
18
19
  import { listFormatters } from "./text/list.js";
19
20
  import { migrateFormatters } from "./text/migrate.js";
21
+ import { modelsFormatters } from "./text/models.js";
20
22
  import { proposalProducerFormatters } from "./text/proposal/producer.js";
21
23
  import { proposalFormatters } from "./text/proposal/proposal.js";
22
24
  import { getTextFormatterHandler, registerTextFormatters } from "./text/registry.js";
@@ -54,6 +56,7 @@ const BUILT_IN_TEXT_FORMATTERS = [
54
56
  ...proposalProducerFormatters,
55
57
  ...infoFormatters,
56
58
  ...healthFormatters,
59
+ ...improveReportFormatters,
57
60
  ...lintFormatters,
58
61
  ...configFormatters,
59
62
  ...feedbackFormatters,
@@ -63,6 +66,7 @@ const BUILT_IN_TEXT_FORMATTERS = [
63
66
  ...registryCommandFormatters,
64
67
  ...envFormatters,
65
68
  ...migrateFormatters,
69
+ ...modelsFormatters,
66
70
  ];
67
71
  registerTextFormatters(BUILT_IN_TEXT_FORMATTERS);
68
72
  // ── JSONL output (unchanged — not part of the formatPlain dispatch) ───────────