akm-cli 0.7.4 → 0.8.0-rc1

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 (158) hide show
  1. package/{CHANGELOG.md → .github/CHANGELOG.md} +34 -1
  2. package/.github/LICENSE +374 -0
  3. package/dist/cli/parse-args.js +43 -0
  4. package/dist/cli.js +1007 -593
  5. package/dist/commands/agent-dispatch.js +102 -0
  6. package/dist/commands/agent-support.js +62 -0
  7. package/dist/commands/config-cli.js +68 -84
  8. package/dist/commands/consolidate.js +823 -0
  9. package/dist/commands/curate.js +1 -0
  10. package/dist/commands/distill-promotion-policy.js +658 -0
  11. package/dist/commands/distill.js +250 -48
  12. package/dist/commands/eval-cases.js +40 -0
  13. package/dist/commands/events.js +12 -24
  14. package/dist/commands/graph.js +222 -0
  15. package/dist/commands/health.js +376 -0
  16. package/dist/commands/help/help-accept.md +9 -0
  17. package/dist/commands/help/help-improve.md +53 -0
  18. package/dist/commands/help/help-proposals.md +15 -0
  19. package/dist/commands/help/help-propose.md +17 -0
  20. package/dist/commands/help/help-reject.md +8 -0
  21. package/dist/commands/history.js +3 -30
  22. package/dist/commands/improve.js +1170 -0
  23. package/dist/commands/info.js +2 -2
  24. package/dist/commands/init.js +2 -2
  25. package/dist/commands/install-audit.js +5 -1
  26. package/dist/commands/installed-stashes.js +118 -138
  27. package/dist/commands/knowledge.js +133 -0
  28. package/dist/commands/lint/agent-linter.js +46 -0
  29. package/dist/commands/lint/base-linter.js +251 -0
  30. package/dist/commands/lint/command-linter.js +46 -0
  31. package/dist/commands/lint/default-linter.js +13 -0
  32. package/dist/commands/lint/index.js +107 -0
  33. package/dist/commands/lint/knowledge-linter.js +13 -0
  34. package/dist/commands/lint/memory-linter.js +58 -0
  35. package/dist/commands/lint/registry.js +33 -0
  36. package/dist/commands/lint/skill-linter.js +42 -0
  37. package/dist/commands/lint/task-linter.js +47 -0
  38. package/dist/commands/lint/types.js +1 -0
  39. package/dist/commands/lint/workflow-linter.js +53 -0
  40. package/dist/commands/lint.js +1 -0
  41. package/dist/commands/migration-help.js +2 -2
  42. package/dist/commands/proposal.js +8 -7
  43. package/dist/commands/propose.js +113 -43
  44. package/dist/commands/reflect.js +175 -41
  45. package/dist/commands/registry-search.js +2 -2
  46. package/dist/commands/remember.js +55 -1
  47. package/dist/commands/schema-repair.js +130 -0
  48. package/dist/commands/search.js +21 -5
  49. package/dist/commands/show.js +131 -52
  50. package/dist/commands/source-add.js +10 -10
  51. package/dist/commands/source-manage.js +11 -19
  52. package/dist/commands/tasks.js +385 -0
  53. package/dist/commands/url-checker.js +39 -0
  54. package/dist/commands/vault.js +7 -33
  55. package/dist/core/action-contributors.js +25 -0
  56. package/dist/core/asset-registry.js +5 -17
  57. package/dist/core/asset-spec.js +11 -1
  58. package/dist/core/common.js +94 -0
  59. package/dist/core/concurrent.js +22 -0
  60. package/dist/core/config.js +229 -122
  61. package/dist/core/events.js +87 -123
  62. package/dist/core/frontmatter.js +3 -1
  63. package/dist/core/markdown.js +17 -0
  64. package/dist/core/memory-improve.js +678 -0
  65. package/dist/core/parse.js +155 -0
  66. package/dist/core/paths.js +101 -3
  67. package/dist/core/proposal-validators.js +61 -0
  68. package/dist/core/proposals.js +49 -38
  69. package/dist/core/state-db.js +775 -0
  70. package/dist/core/time.js +51 -0
  71. package/dist/core/warn.js +59 -1
  72. package/dist/indexer/db-search.js +86 -472
  73. package/dist/indexer/db.js +392 -6
  74. package/dist/indexer/ensure-index.js +133 -0
  75. package/dist/indexer/graph-boost.js +247 -94
  76. package/dist/indexer/graph-db.js +201 -0
  77. package/dist/indexer/graph-dedup.js +99 -0
  78. package/dist/indexer/graph-extraction.js +417 -74
  79. package/dist/indexer/index-context.js +10 -0
  80. package/dist/indexer/indexer.js +466 -298
  81. package/dist/indexer/llm-cache.js +47 -0
  82. package/dist/indexer/match-contributors.js +141 -0
  83. package/dist/indexer/matchers.js +24 -190
  84. package/dist/indexer/memory-inference.js +63 -29
  85. package/dist/indexer/metadata-contributors.js +26 -0
  86. package/dist/indexer/metadata.js +188 -175
  87. package/dist/indexer/path-resolver.js +89 -0
  88. package/dist/indexer/ranking-contributors.js +204 -0
  89. package/dist/indexer/ranking.js +74 -0
  90. package/dist/indexer/search-hit-enrichers.js +22 -0
  91. package/dist/indexer/search-source.js +24 -9
  92. package/dist/indexer/semantic-status.js +2 -16
  93. package/dist/indexer/walker.js +25 -0
  94. package/dist/integrations/agent/config.js +175 -3
  95. package/dist/integrations/agent/index.js +3 -1
  96. package/dist/integrations/agent/pipeline.js +39 -0
  97. package/dist/integrations/agent/profiles.js +67 -5
  98. package/dist/integrations/agent/prompts.js +114 -29
  99. package/dist/integrations/agent/runners.js +31 -0
  100. package/dist/integrations/agent/sdk-runner.js +120 -0
  101. package/dist/integrations/agent/spawn.js +136 -28
  102. package/dist/integrations/lockfile.js +10 -18
  103. package/dist/integrations/session-logs/index.js +65 -0
  104. package/dist/integrations/session-logs/providers/claude-code.js +56 -0
  105. package/dist/integrations/session-logs/providers/opencode.js +52 -0
  106. package/dist/integrations/session-logs/types.js +1 -0
  107. package/dist/llm/call-ai.js +74 -0
  108. package/dist/llm/client.js +63 -86
  109. package/dist/llm/feature-gate.js +27 -16
  110. package/dist/llm/graph-extract.js +297 -64
  111. package/dist/llm/memory-infer.js +52 -71
  112. package/dist/llm/metadata-enhance.js +39 -22
  113. package/dist/llm/prompts/graph-extract-user-prompt.md +12 -0
  114. package/dist/output/cli-hints-full.md +277 -0
  115. package/dist/output/cli-hints-short.md +65 -0
  116. package/dist/output/cli-hints.js +2 -309
  117. package/dist/output/renderers.js +196 -124
  118. package/dist/output/shapes.js +41 -3
  119. package/dist/output/text.js +257 -21
  120. package/dist/registry/providers/skills-sh.js +61 -49
  121. package/dist/registry/providers/static-index.js +44 -48
  122. package/dist/setup/setup.js +510 -11
  123. package/dist/sources/provider-factory.js +2 -1
  124. package/dist/sources/providers/git.js +44 -2
  125. package/dist/sources/website-ingest.js +4 -0
  126. package/dist/tasks/backends/cron.js +200 -0
  127. package/dist/tasks/backends/exec-utils.js +25 -0
  128. package/dist/tasks/backends/index.js +32 -0
  129. package/dist/tasks/backends/launchd-template.xml +19 -0
  130. package/dist/tasks/backends/launchd.js +184 -0
  131. package/dist/tasks/backends/schtasks-template.xml +29 -0
  132. package/dist/tasks/backends/schtasks.js +212 -0
  133. package/dist/tasks/parser.js +198 -0
  134. package/dist/tasks/resolveAkmBin.js +84 -0
  135. package/dist/tasks/runner.js +432 -0
  136. package/dist/tasks/schedule.js +208 -0
  137. package/dist/tasks/schema.js +13 -0
  138. package/dist/tasks/validator.js +59 -0
  139. package/dist/wiki/index-template.md +12 -0
  140. package/dist/wiki/ingest-workflow-template.md +54 -0
  141. package/dist/wiki/log-template.md +8 -0
  142. package/dist/wiki/schema-template.md +61 -0
  143. package/dist/wiki/wiki-templates.js +12 -0
  144. package/dist/wiki/wiki.js +10 -61
  145. package/dist/workflows/authoring.js +5 -25
  146. package/dist/workflows/db.js +9 -0
  147. package/dist/workflows/renderer.js +8 -3
  148. package/dist/workflows/runs.js +73 -88
  149. package/dist/workflows/scope-key.js +76 -0
  150. package/dist/workflows/validator.js +1 -1
  151. package/dist/workflows/workflow-template.md +24 -0
  152. package/docs/README.md +3 -0
  153. package/docs/migration/release-notes/0.7.0.md +1 -1
  154. package/docs/migration/release-notes/0.7.4.md +1 -1
  155. package/docs/migration/release-notes/0.7.5.md +20 -0
  156. package/docs/migration/release-notes/0.8.0.md +43 -0
  157. package/package.json +4 -3
  158. package/dist/templates/wiki-templates.js +0 -100
@@ -8,6 +8,20 @@ export const IS_WINDOWS = process.platform === "win32";
8
8
  export function isHttpUrl(value) {
9
9
  return !!value && /^https?:\/\//.test(value);
10
10
  }
11
+ /**
12
+ * Returns `true` when `value` looks like a remote URL that a VCS or HTTP
13
+ * fetch can access. Covers http/https, git@, ssh://, and git:// schemes.
14
+ * Consolidates the repeated inline URL-detection pattern in source-manage.ts.
15
+ */
16
+ export function isRemoteUrl(value) {
17
+ if (!value)
18
+ return false;
19
+ return (value.startsWith("http://") ||
20
+ value.startsWith("https://") ||
21
+ value.startsWith("git@") ||
22
+ value.startsWith("ssh://") ||
23
+ value.startsWith("git://"));
24
+ }
11
25
  export function filterNonEmptyStrings(value) {
12
26
  if (!Array.isArray(value))
13
27
  return undefined;
@@ -18,6 +32,18 @@ export function isAssetType(type) {
18
32
  return Object.hasOwn(TYPE_DIRS, type);
19
33
  }
20
34
  // ── Utilities ───────────────────────────────────────────────────────────────
35
+ /**
36
+ * Write content to a file atomically via a temp file + rename.
37
+ * Prevents partial-write corruption on crash.
38
+ * An optional `mode` (e.g. 0o600) is applied with `chmod` after the rename.
39
+ */
40
+ export function writeFileAtomic(target, content, mode) {
41
+ const tmp = `${target}.tmp.${process.pid}.${Math.random().toString(36).slice(2)}`;
42
+ fs.writeFileSync(tmp, content, "utf8");
43
+ fs.renameSync(tmp, target);
44
+ if (mode !== undefined)
45
+ fs.chmodSync(target, mode);
46
+ }
21
47
  /**
22
48
  * Resolve the stash directory using a three-level fallback chain:
23
49
  * 1. AKM_STASH_DIR environment variable (override for CI/scripts)
@@ -329,3 +355,71 @@ function parseRetryAfter(response) {
329
355
  export function toErrorMessage(error) {
330
356
  return error instanceof Error ? error.message : String(error);
331
357
  }
358
+ // ── Date / timestamp utilities ───────────────────────────────────────────────
359
+ /**
360
+ * Return today's date in ISO-8601 format (`YYYY-MM-DD`).
361
+ * Consolidates the `new Date().toISOString().slice(0, 10)` pattern that
362
+ * appears at multiple call sites.
363
+ */
364
+ export function todayIso() {
365
+ return new Date().toISOString().slice(0, 10);
366
+ }
367
+ /**
368
+ * Return a filesystem-safe timestamp string derived from the current instant.
369
+ * Colons and dots are replaced with hyphens so the result is safe as a
370
+ * filename component on all platforms (e.g. `2024-01-15T10-30-00-000Z`).
371
+ */
372
+ export function timestampForFilename() {
373
+ return new Date().toISOString().replace(/[:.]/g, "-");
374
+ }
375
+ // ── String coercion ──────────────────────────────────────────────────────────
376
+ /**
377
+ * Return the trimmed string value if non-empty, otherwise `undefined`.
378
+ * Consolidates `toStringOrUndefined` (frontmatter.ts), `asNonEmptyString`
379
+ * (config.ts), and `firstString` (memory-improve.ts) — all had the same
380
+ * "return a string or undefined" contract with minor semantic differences.
381
+ */
382
+ export function asNonEmptyString(value) {
383
+ if (typeof value !== "string")
384
+ return undefined;
385
+ const trimmed = value.trim();
386
+ return trimmed.length > 0 ? trimmed : undefined;
387
+ }
388
+ // ── Generic data utilities ───────────────────────────────────────────────────
389
+ /**
390
+ * Return the trimmed string if non-empty, otherwise `undefined`.
391
+ * Equivalent to `firstString` previously defined in `memory-improve.ts`.
392
+ */
393
+ export function firstString(value) {
394
+ return typeof value === "string" && value.trim().length > 0 ? value.trim() : undefined;
395
+ }
396
+ /**
397
+ * Coerce an unknown value to a filtered, trimmed string array.
398
+ * Non-strings and empty/whitespace-only entries are dropped.
399
+ */
400
+ export function stringArray(value) {
401
+ if (!Array.isArray(value))
402
+ return [];
403
+ const out = [];
404
+ for (const item of value) {
405
+ if (typeof item === "string" && item.trim().length > 0)
406
+ out.push(item.trim());
407
+ }
408
+ return out;
409
+ }
410
+ /**
411
+ * Group an array of values by a string key derived from each element.
412
+ * Returns a `Map` so insertion order within each group is preserved.
413
+ */
414
+ export function groupBy(values, keyFn) {
415
+ const groups = new Map();
416
+ for (const value of values) {
417
+ const key = keyFn(value);
418
+ const existing = groups.get(key);
419
+ if (existing)
420
+ existing.push(value);
421
+ else
422
+ groups.set(key, [value]);
423
+ }
424
+ return groups;
425
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Maps over items concurrently with a pool size limit.
3
+ * Uses Promise.allSettled semantics — one failure does not cancel others.
4
+ */
5
+ export async function concurrentMap(items, fn, concurrency = 1) {
6
+ const results = new Array(items.length).fill(undefined);
7
+ let nextIndex = 0;
8
+ async function worker() {
9
+ while (nextIndex < items.length) {
10
+ const i = nextIndex++;
11
+ try {
12
+ results[i] = await fn(items[i], i);
13
+ }
14
+ catch {
15
+ // individual failure: leave undefined, caller checks
16
+ }
17
+ }
18
+ }
19
+ const workers = Array.from({ length: Math.min(concurrency, items.length) }, worker);
20
+ await Promise.all(workers);
21
+ return results;
22
+ }