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.
- package/{CHANGELOG.md → .github/CHANGELOG.md} +34 -1
- package/.github/LICENSE +374 -0
- package/dist/cli/parse-args.js +43 -0
- package/dist/cli.js +1007 -593
- package/dist/commands/agent-dispatch.js +102 -0
- package/dist/commands/agent-support.js +62 -0
- package/dist/commands/config-cli.js +68 -84
- package/dist/commands/consolidate.js +823 -0
- package/dist/commands/curate.js +1 -0
- package/dist/commands/distill-promotion-policy.js +658 -0
- package/dist/commands/distill.js +250 -48
- package/dist/commands/eval-cases.js +40 -0
- package/dist/commands/events.js +12 -24
- package/dist/commands/graph.js +222 -0
- package/dist/commands/health.js +376 -0
- package/dist/commands/help/help-accept.md +9 -0
- package/dist/commands/help/help-improve.md +53 -0
- package/dist/commands/help/help-proposals.md +15 -0
- package/dist/commands/help/help-propose.md +17 -0
- package/dist/commands/help/help-reject.md +8 -0
- package/dist/commands/history.js +3 -30
- package/dist/commands/improve.js +1170 -0
- package/dist/commands/info.js +2 -2
- package/dist/commands/init.js +2 -2
- package/dist/commands/install-audit.js +5 -1
- package/dist/commands/installed-stashes.js +118 -138
- package/dist/commands/knowledge.js +133 -0
- package/dist/commands/lint/agent-linter.js +46 -0
- package/dist/commands/lint/base-linter.js +251 -0
- package/dist/commands/lint/command-linter.js +46 -0
- package/dist/commands/lint/default-linter.js +13 -0
- package/dist/commands/lint/index.js +107 -0
- package/dist/commands/lint/knowledge-linter.js +13 -0
- package/dist/commands/lint/memory-linter.js +58 -0
- package/dist/commands/lint/registry.js +33 -0
- package/dist/commands/lint/skill-linter.js +42 -0
- package/dist/commands/lint/task-linter.js +47 -0
- package/dist/commands/lint/types.js +1 -0
- package/dist/commands/lint/workflow-linter.js +53 -0
- package/dist/commands/lint.js +1 -0
- package/dist/commands/migration-help.js +2 -2
- package/dist/commands/proposal.js +8 -7
- package/dist/commands/propose.js +113 -43
- package/dist/commands/reflect.js +175 -41
- package/dist/commands/registry-search.js +2 -2
- package/dist/commands/remember.js +55 -1
- package/dist/commands/schema-repair.js +130 -0
- package/dist/commands/search.js +21 -5
- package/dist/commands/show.js +131 -52
- package/dist/commands/source-add.js +10 -10
- package/dist/commands/source-manage.js +11 -19
- package/dist/commands/tasks.js +385 -0
- package/dist/commands/url-checker.js +39 -0
- package/dist/commands/vault.js +7 -33
- package/dist/core/action-contributors.js +25 -0
- package/dist/core/asset-registry.js +5 -17
- package/dist/core/asset-spec.js +11 -1
- package/dist/core/common.js +94 -0
- package/dist/core/concurrent.js +22 -0
- package/dist/core/config.js +229 -122
- package/dist/core/events.js +87 -123
- package/dist/core/frontmatter.js +3 -1
- package/dist/core/markdown.js +17 -0
- package/dist/core/memory-improve.js +678 -0
- package/dist/core/parse.js +155 -0
- package/dist/core/paths.js +101 -3
- package/dist/core/proposal-validators.js +61 -0
- package/dist/core/proposals.js +49 -38
- package/dist/core/state-db.js +775 -0
- package/dist/core/time.js +51 -0
- package/dist/core/warn.js +59 -1
- package/dist/indexer/db-search.js +86 -472
- package/dist/indexer/db.js +392 -6
- package/dist/indexer/ensure-index.js +133 -0
- package/dist/indexer/graph-boost.js +247 -94
- package/dist/indexer/graph-db.js +201 -0
- package/dist/indexer/graph-dedup.js +99 -0
- package/dist/indexer/graph-extraction.js +417 -74
- package/dist/indexer/index-context.js +10 -0
- package/dist/indexer/indexer.js +466 -298
- package/dist/indexer/llm-cache.js +47 -0
- package/dist/indexer/match-contributors.js +141 -0
- package/dist/indexer/matchers.js +24 -190
- package/dist/indexer/memory-inference.js +63 -29
- package/dist/indexer/metadata-contributors.js +26 -0
- package/dist/indexer/metadata.js +188 -175
- package/dist/indexer/path-resolver.js +89 -0
- package/dist/indexer/ranking-contributors.js +204 -0
- package/dist/indexer/ranking.js +74 -0
- package/dist/indexer/search-hit-enrichers.js +22 -0
- package/dist/indexer/search-source.js +24 -9
- package/dist/indexer/semantic-status.js +2 -16
- package/dist/indexer/walker.js +25 -0
- package/dist/integrations/agent/config.js +175 -3
- package/dist/integrations/agent/index.js +3 -1
- package/dist/integrations/agent/pipeline.js +39 -0
- package/dist/integrations/agent/profiles.js +67 -5
- package/dist/integrations/agent/prompts.js +114 -29
- package/dist/integrations/agent/runners.js +31 -0
- package/dist/integrations/agent/sdk-runner.js +120 -0
- package/dist/integrations/agent/spawn.js +136 -28
- package/dist/integrations/lockfile.js +10 -18
- package/dist/integrations/session-logs/index.js +65 -0
- package/dist/integrations/session-logs/providers/claude-code.js +56 -0
- package/dist/integrations/session-logs/providers/opencode.js +52 -0
- package/dist/integrations/session-logs/types.js +1 -0
- package/dist/llm/call-ai.js +74 -0
- package/dist/llm/client.js +63 -86
- package/dist/llm/feature-gate.js +27 -16
- package/dist/llm/graph-extract.js +297 -64
- package/dist/llm/memory-infer.js +52 -71
- package/dist/llm/metadata-enhance.js +39 -22
- package/dist/llm/prompts/graph-extract-user-prompt.md +12 -0
- package/dist/output/cli-hints-full.md +277 -0
- package/dist/output/cli-hints-short.md +65 -0
- package/dist/output/cli-hints.js +2 -309
- package/dist/output/renderers.js +196 -124
- package/dist/output/shapes.js +41 -3
- package/dist/output/text.js +257 -21
- package/dist/registry/providers/skills-sh.js +61 -49
- package/dist/registry/providers/static-index.js +44 -48
- package/dist/setup/setup.js +510 -11
- package/dist/sources/provider-factory.js +2 -1
- package/dist/sources/providers/git.js +44 -2
- package/dist/sources/website-ingest.js +4 -0
- package/dist/tasks/backends/cron.js +200 -0
- package/dist/tasks/backends/exec-utils.js +25 -0
- package/dist/tasks/backends/index.js +32 -0
- package/dist/tasks/backends/launchd-template.xml +19 -0
- package/dist/tasks/backends/launchd.js +184 -0
- package/dist/tasks/backends/schtasks-template.xml +29 -0
- package/dist/tasks/backends/schtasks.js +212 -0
- package/dist/tasks/parser.js +198 -0
- package/dist/tasks/resolveAkmBin.js +84 -0
- package/dist/tasks/runner.js +432 -0
- package/dist/tasks/schedule.js +208 -0
- package/dist/tasks/schema.js +13 -0
- package/dist/tasks/validator.js +59 -0
- package/dist/wiki/index-template.md +12 -0
- package/dist/wiki/ingest-workflow-template.md +54 -0
- package/dist/wiki/log-template.md +8 -0
- package/dist/wiki/schema-template.md +61 -0
- package/dist/wiki/wiki-templates.js +12 -0
- package/dist/wiki/wiki.js +10 -61
- package/dist/workflows/authoring.js +5 -25
- package/dist/workflows/db.js +9 -0
- package/dist/workflows/renderer.js +8 -3
- package/dist/workflows/runs.js +73 -88
- package/dist/workflows/scope-key.js +76 -0
- package/dist/workflows/validator.js +1 -1
- package/dist/workflows/workflow-template.md +24 -0
- package/docs/README.md +3 -0
- package/docs/migration/release-notes/0.7.0.md +1 -1
- package/docs/migration/release-notes/0.7.4.md +1 -1
- package/docs/migration/release-notes/0.7.5.md +20 -0
- package/docs/migration/release-notes/0.8.0.md +43 -0
- package/package.json +4 -3
- package/dist/templates/wiki-templates.js +0 -100
package/dist/core/common.js
CHANGED
|
@@ -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
|
+
}
|