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
@@ -18,34 +18,14 @@
18
18
  import { toErrorMessage } from "../core/common";
19
19
  import { warn } from "../core/warn";
20
20
  import { chatCompletion, parseEmbeddedJsonResponse } from "./client";
21
+ import { tryLlmFeature } from "./feature-gate";
21
22
  /** Hard cap on body chars sent to the model — pragmatic and matches `runLlmEnrich`. */
22
23
  const MAX_BODY_CHARS = 4000;
23
- /** Hard timeout for the LLM call. The index run must not hang on a misbehaving endpoint. */
24
- const LLM_TIMEOUT_MS = 30_000;
25
24
  const SYSTEM_PROMPT = "You compress a developer memory into one high-signal derived memory for later retrieval. " +
26
25
  "Return only valid JSON. No prose outside the JSON object. No markdown fences.";
27
- const USER_PROMPT_PREFIX = `Compress the memory below into one concise, information-dense derived memory.
28
-
29
- Rules:
30
- - Output ONLY a JSON object with exactly these keys: {"title": string, "description": string, "tags": string[], "searchHints": string[], "content": string}.
31
- - ` +
32
- '"title"' +
33
- ` is a short, descriptive title for the derived memory.
34
- - ` +
35
- '"description"' +
36
- ` is one sentence explaining why this derived memory matters.
37
- - ` +
38
- '"tags"' +
39
- ` contains 3-8 specific keywords.
40
- - ` +
41
- '"searchHints"' +
42
- ` contains 3-6 natural-language retrieval phrases.
43
- - ` +
44
- '"content"' +
45
- ` must be compact markdown that preserves the reusable insight, root cause, fix, constraints, and applicability conditions when present.
46
- - Prefer 2-4 short sections with informative headings over long prose.
47
- - Omit timestamps, verification-only metrics, pleasantries, and session-specific chatter unless they are essential to applying the insight later.
48
- - Preserve technical specifics (names, versions, identifiers, selectors, file paths, config keys) verbatim.
26
+ const USER_PROMPT_PREFIX = `Compress the memory below into one derived memory. Output ONLY JSON:
27
+ {"title":"string","description":"string","tags":["string"],"searchHints":["string"],"content":"string"}
28
+ Rules: be specific, no vague generalizations, preserve key facts (names/versions/paths/config keys verbatim), merge related points, max 3 sentences body, 3-8 tags, 3-6 searchHints.
49
29
 
50
30
  Memory:
51
31
  `;
@@ -53,62 +33,63 @@ Memory:
53
33
  * Compress a single memory body into one derived memory via the configured LLM.
54
34
  *
55
35
  * Returns `undefined` on any failure (timeout, invalid JSON, empty response).
56
- * Errors
57
- * are logged via `warn()` but never thrown — a failed split for one memory
36
+ * Errors are logged via `warn()` but never thrown — a failed split for one memory
58
37
  * must not abort the rest of the index pass.
38
+ *
39
+ * Routes through `tryLlmFeature("memory_inference", ...)` so the feature gate
40
+ * and onFallback hook are honoured uniformly (Fix C5).
59
41
  */
60
- export async function compressMemoryToDerivedMemory(llmConfig, body, signal) {
42
+ export async function compressMemoryToDerivedMemory(llmConfig, body, signal, akmConfig, onFallback) {
61
43
  const trimmedBody = body.trim();
62
44
  if (!trimmedBody)
63
45
  return undefined;
64
46
  const userPrompt = `${USER_PROMPT_PREFIX}${trimmedBody.slice(0, MAX_BODY_CHARS)}`;
65
- let timeoutHandle;
66
- try {
67
- const raw = await Promise.race([
68
- chatCompletion(llmConfig, [
47
+ return tryLlmFeature("memory_inference", akmConfig, async () => {
48
+ try {
49
+ const raw = await chatCompletion(llmConfig, [
69
50
  { role: "system", content: SYSTEM_PROMPT },
70
51
  { role: "user", content: userPrompt },
71
- ], { maxTokens: 768, temperature: 0.1, signal }),
72
- new Promise((_, reject) => {
73
- timeoutHandle = setTimeout(() => reject(new Error("memory inference timed out")), LLM_TIMEOUT_MS);
74
- }),
75
- ]);
76
- if (!raw)
77
- return undefined;
78
- const parsed = parseEmbeddedJsonResponse(raw);
79
- if (!parsed) {
80
- warn("memory inference: invalid JSON response from LLM; skipping memory.");
81
- return undefined;
52
+ ], {
53
+ temperature: 0.1,
54
+ timeoutMs: llmConfig.timeoutMs,
55
+ signal,
56
+ });
57
+ if (!raw)
58
+ return undefined;
59
+ const parsed = parseEmbeddedJsonResponse(raw);
60
+ if (!parsed) {
61
+ warn("memory inference: invalid JSON response from LLM; skipping memory.");
62
+ return undefined;
63
+ }
64
+ const title = typeof parsed.title === "string" ? parsed.title.trim() : "";
65
+ const description = typeof parsed.description === "string" ? parsed.description.trim() : "";
66
+ const content = typeof parsed.content === "string" ? parsed.content.trim() : "";
67
+ const tags = Array.isArray(parsed.tags)
68
+ ? parsed.tags
69
+ .filter((t) => typeof t === "string")
70
+ .map((t) => t.trim())
71
+ .filter(Boolean)
72
+ .slice(0, 8)
73
+ : [];
74
+ const searchHints = Array.isArray(parsed.searchHints)
75
+ ? parsed.searchHints
76
+ .filter((h) => typeof h === "string")
77
+ .map((h) => h.trim())
78
+ .filter(Boolean)
79
+ .slice(0, 6)
80
+ : [];
81
+ if (!title || !description || !content || tags.length === 0 || searchHints.length === 0) {
82
+ warn("memory inference: incomplete derived memory payload from LLM; skipping memory.");
83
+ return undefined;
84
+ }
85
+ return { title, description, tags, searchHints, content };
82
86
  }
83
- const title = typeof parsed.title === "string" ? parsed.title.trim() : "";
84
- const description = typeof parsed.description === "string" ? parsed.description.trim() : "";
85
- const content = typeof parsed.content === "string" ? parsed.content.trim() : "";
86
- const tags = Array.isArray(parsed.tags)
87
- ? parsed.tags
88
- .filter((t) => typeof t === "string")
89
- .map((t) => t.trim())
90
- .filter(Boolean)
91
- .slice(0, 8)
92
- : [];
93
- const searchHints = Array.isArray(parsed.searchHints)
94
- ? parsed.searchHints
95
- .filter((h) => typeof h === "string")
96
- .map((h) => h.trim())
97
- .filter(Boolean)
98
- .slice(0, 6)
99
- : [];
100
- if (!title || !description || !content || tags.length === 0 || searchHints.length === 0) {
101
- warn("memory inference: incomplete derived memory payload from LLM; skipping memory.");
87
+ catch (err) {
88
+ warn(`memory inference failed: ${toErrorMessage(err)}`);
102
89
  return undefined;
103
90
  }
104
- return { title, description, tags, searchHints, content };
105
- }
106
- catch (err) {
107
- warn(`memory inference failed: ${toErrorMessage(err)}`);
108
- return undefined;
109
- }
110
- finally {
111
- if (timeoutHandle !== undefined)
112
- clearTimeout(timeoutHandle);
113
- }
91
+ }, undefined, {
92
+ timeoutMs: llmConfig.timeoutMs,
93
+ onFallback,
94
+ });
114
95
  }
@@ -6,20 +6,27 @@
6
6
  * transport client in `client.ts`.
7
7
  */
8
8
  import { chatCompletion, parseJsonResponse } from "./client";
9
+ import { tryLlmFeature } from "./feature-gate";
9
10
  const SYSTEM_PROMPT = `You are a metadata generator for a developer asset registry. Given a script/skill/command/agent entry, generate improved metadata. Respond with ONLY valid JSON, no markdown fencing.`;
10
11
  /**
11
12
  * Use an LLM to enhance a stash entry's metadata: improve description,
12
13
  * generate searchHints, and suggest tags.
14
+ *
15
+ * When `akmConfig` is provided, routes through
16
+ * `tryLlmFeature("metadata_enhance", ...)` so the feature gate is honoured and
17
+ * errors are swallowed to `{}`. When `akmConfig` is `undefined` the gate is
18
+ * bypassed entirely — the LLM call runs unconditionally and errors propagate to
19
+ * the caller (pre-gate behaviour, used by direct callers such as tests).
13
20
  */
14
- export async function enhanceMetadata(config, entry, fileContent, signal) {
21
+ export async function enhanceMetadata(config, entry, fileContent, signal, akmConfig) {
15
22
  const contextParts = [`Name: ${entry.name}`, `Type: ${entry.type}`];
16
23
  if (entry.description)
17
24
  contextParts.push(`Current description: ${entry.description}`);
18
25
  if (entry.tags?.length)
19
26
  contextParts.push(`Current tags: ${entry.tags.join(", ")}`);
20
27
  if (fileContent) {
21
- // Limit content to first 2000 chars to stay within token limits
22
- const truncated = fileContent.length > 2000 ? `${fileContent.slice(0, 2000)}\n... (truncated)` : fileContent;
28
+ // Limit content to first 4000 chars to stay within token limits (matches other modules)
29
+ const truncated = fileContent.length > 4000 ? `${fileContent.slice(0, 4000)}\n... (truncated)` : fileContent;
23
30
  contextParts.push(`File content:\n${truncated}`);
24
31
  }
25
32
  const userPrompt = `${contextParts.join("\n")}
@@ -30,24 +37,34 @@ Generate improved metadata for this ${entry.type}. Return JSON with these fields
30
37
  - "tags": an array of 3-8 relevant keyword tags
31
38
 
32
39
  Return ONLY the JSON object, no explanation.`;
33
- const raw = await chatCompletion(config, [
34
- { role: "system", content: SYSTEM_PROMPT },
35
- { role: "user", content: userPrompt },
36
- ], { signal });
37
- const parsed = parseJsonResponse(raw);
38
- if (!parsed)
39
- return {};
40
- const result = {};
41
- if (typeof parsed.description === "string" && parsed.description) {
42
- result.description = parsed.description;
43
- }
44
- if (Array.isArray(parsed.searchHints)) {
45
- result.searchHints = parsed.searchHints
46
- .filter((s) => typeof s === "string" && s.trim().length > 0)
47
- .slice(0, 8);
48
- }
49
- if (Array.isArray(parsed.tags)) {
50
- result.tags = parsed.tags.filter((s) => typeof s === "string" && s.trim().length > 0).slice(0, 10);
40
+ const runLlm = async () => {
41
+ const raw = await chatCompletion(config, [
42
+ { role: "system", content: SYSTEM_PROMPT },
43
+ { role: "user", content: userPrompt },
44
+ ], { signal });
45
+ const parsed = parseJsonResponse(raw);
46
+ if (!parsed)
47
+ return {};
48
+ const result = {};
49
+ if (typeof parsed.description === "string" && parsed.description) {
50
+ result.description = parsed.description;
51
+ }
52
+ if (Array.isArray(parsed.searchHints)) {
53
+ result.searchHints = parsed.searchHints
54
+ .filter((s) => typeof s === "string" && s.trim().length > 0)
55
+ .slice(0, 8);
56
+ }
57
+ if (Array.isArray(parsed.tags)) {
58
+ result.tags = parsed.tags.filter((s) => typeof s === "string" && s.trim().length > 0).slice(0, 10);
59
+ }
60
+ return result;
61
+ };
62
+ // When no akmConfig is provided, bypass the feature gate entirely: run the
63
+ // LLM call directly and let errors propagate to the caller (pre-gate
64
+ // behaviour). When akmConfig is present, honour the feature flag and swallow
65
+ // errors to {} via tryLlmFeature.
66
+ if (akmConfig === undefined) {
67
+ return runLlm();
51
68
  }
52
- return result;
69
+ return tryLlmFeature("metadata_enhance", akmConfig, runLlm, {}, { timeoutMs: config.timeoutMs });
53
70
  }
@@ -0,0 +1,12 @@
1
+ Extract entities and relations from the asset body below.
2
+
3
+ Rules:
4
+ - Output ONLY a JSON object: {"entities": ["Entity One", ...], "relations": [{"from": "A", "to": "B", "type": "uses"}, ...]}.
5
+ - Entities are short, canonical noun phrases (project names, services, tools, people, file/dir names, technical concepts).
6
+ - Relations connect two entities that both appear in the entities array.
7
+ - "type" is a short verb phrase (e.g. "uses", "depends on", "owns", "documents"). Optional; omit when unsure.
8
+ - Drop pleasantries, meta-commentary, and timestamps.
9
+ - Limit to at most {{MAX_ENTITIES}} entities and {{MAX_RELATIONS}} relations per asset.
10
+ - Return {"entities": [], "relations": []} if the body has no extractable graph content.
11
+
12
+ Asset body:
@@ -0,0 +1,277 @@
1
+ # akm CLI — Full Reference
2
+
3
+ You have access to a searchable library of scripts, skills, commands, agents, knowledge documents, workflows, wikis, and memories via `akm`. Search your sources first before writing something from scratch.
4
+
5
+ ## Search
6
+
7
+ ```sh
8
+ akm search "<query>" # Search all sources
9
+ akm curate "<task>" # Curate the best matches for a task
10
+ akm search "<query>" --type workflow # Filter by asset type
11
+ akm search "<query>" --source both # Also search registries
12
+ akm search "<query>" --source registry # Search registries only
13
+ akm search "<query>" --limit 10 # Limit results
14
+ akm search "<query>" --detail full # Include scores, paths, timing
15
+ ```
16
+
17
+ | Flag | Values | Default |
18
+ | --- | --- | --- |
19
+ | `--type` | `skill`, `command`, `agent`, `knowledge`, `workflow`, `script`, `memory`, `vault`, `wiki`, `any` | `any` |
20
+ | `--source` | `stash`, `registry`, `both` | `stash` |
21
+ | `--limit` | number | `20` |
22
+ | `--format` | `json`, `jsonl`, `text`, `yaml` | `json` |
23
+ | `--detail` | `brief`, `normal`, `full`, `summary`, `agent` | `brief` |
24
+ | `--for-agent` | boolean (deprecated — use `--detail agent`) | `false` |
25
+
26
+ ## Curate
27
+
28
+ Combine search + follow-up hints into a dense summary for a task or prompt.
29
+
30
+ ```sh
31
+ akm curate "plan a release" # Pick top matches across asset types
32
+ akm curate "deploy a Bun app" --limit 3 # Keep the summary shorter
33
+ akm curate "review architecture" --type workflow # Restrict to one asset type
34
+ ```
35
+
36
+ ## Show
37
+
38
+ Display an asset by ref. Knowledge assets support view modes as positional arguments.
39
+
40
+ ```sh
41
+ akm show script:deploy.sh # Show script (returns run command)
42
+ akm show skill:code-review # Show skill (returns full content)
43
+ akm show command:release # Show command (returns template)
44
+ akm show agent:architect # Show agent (returns system prompt)
45
+ akm show workflow:ship-release # Show parsed workflow steps
46
+ akm show knowledge:guide toc # Table of contents
47
+ akm show knowledge:guide section "Auth" # Specific section
48
+ akm show knowledge:guide lines 10 30 # Line range
49
+ akm show knowledge:my-doc # Show content (local or remote)
50
+ ```
51
+
52
+ | Type | Key fields returned |
53
+ | --- | --- |
54
+ | script | `run`, `setup`, `cwd` |
55
+ | skill | `content` (full SKILL.md) |
56
+ | command | `template`, `description`, `parameters` |
57
+ | agent | `prompt`, `description`, `modelHint`, `toolPolicy` |
58
+ | knowledge | `content` (with view modes: `full`, `toc`, `frontmatter`, `section`, `lines`) |
59
+ | workflow | `workflowTitle`, `workflowParameters`, `steps` |
60
+ | memory | `content` (recalled context) |
61
+ | vault | `keys`, `comments` |
62
+ | wiki | `content` (same view modes as knowledge). For any wiki task, run `akm wiki list` then `akm wiki ingest <name>` for the workflow. |
63
+
64
+ ## Capture Knowledge While You Work
65
+
66
+ ```sh
67
+ akm remember "Deployment needs VPN access" # Record a memory in your stash
68
+ akm remember --name release-retro < notes.md # Save multiline memory from stdin
69
+ akm remember "note" --target my-other-stash # Route write to a named writable stash source
70
+ akm import ./docs/auth-flow.md # Import a file as knowledge
71
+ akm import - --name scratch-notes < notes.md # Import stdin as a knowledge doc
72
+ akm import https://example.com/docs/auth # Fetch one URL and import it as knowledge
73
+ akm import ./doc.md --target my-other-stash # Route import to a named writable stash source
74
+ akm workflow create ship-release # Create a workflow asset in the stash
75
+ akm workflow validate workflows/foo.md # Validate a workflow file or ref; lists every error
76
+ akm workflow next workflow:ship-release # Start or resume the next workflow step
77
+ akm feedback skill:code-review --positive # Record that an asset helped
78
+ akm feedback agent:reviewer --negative # Record that an asset missed the mark
79
+ akm feedback memory:deployment-notes --positive # Works for memories too
80
+ akm feedback vault:prod --positive # Records vault feedback without surfacing values
81
+ ```
82
+
83
+ Use `akm feedback` whenever an asset materially helps or fails so future search
84
+ ranking can learn from actual usage.
85
+
86
+ ## Wikis
87
+
88
+ Multi-wiki knowledge bases (Karpathy-style). A stash-owned wiki lives at
89
+ `<stashDir>/wikis/<name>/`; external directories or repos can also be registered
90
+ as first-class wikis. akm owns lifecycle + raw-slug + lint + index regeneration
91
+ for stash-owned wikis; page edits use your native Read/Write/Edit tools.
92
+
93
+ ```sh
94
+ akm wiki list # List wikis (name, pages, raws, last-modified)
95
+ akm wiki create research # Scaffold a new wiki
96
+ akm wiki register ics-docs ~/code/ics-documentation # Register an external wiki
97
+ akm wiki show research # Path, description, counts, last 3 log entries
98
+ akm wiki pages research # Page refs + descriptions (excludes schema/index/log; includes raw/)
99
+ akm wiki search research "attention" # Scoped search (equivalent to --type wiki --wiki research)
100
+ akm wiki stash research ./paper.md # Copy source into raw/<slug>.md (never overwrites)
101
+ akm wiki stash research https://example.com/paper # Fetch one URL into raw/<slug>.md
102
+ akm wiki stash research ./paper.md --target my-stash # Route write to a named writable stash source
103
+ echo "..." | akm wiki stash research - # stdin form
104
+ akm wiki lint research # Structural checks: orphans, broken xrefs, uncited raws, stale index
105
+ akm wiki ingest research # Print the ingest workflow for this wiki (no action)
106
+ akm wiki remove research --force # Delete pages/schema/index/log; preserves raw/
107
+ akm wiki remove research --force --with-sources # Full nuke, including raw/
108
+ ```
109
+
110
+ **For any wiki task, start with `akm wiki list`, then `akm wiki ingest <name>`
111
+ to get the step-by-step workflow.** Wiki pages are also addressable as
112
+ `wiki:<name>/<page-path>` and show up in stash-wide `akm search` as
113
+ `type: wiki`. Files under `raw/` and the wiki root infrastructure files
114
+ `schema.md`, `index.md`, and `log.md` are not indexed and do not appear in
115
+ search results. No `--llm` anywhere — akm never reasons about page content.
116
+
117
+ ## Vaults
118
+
119
+ Encrypted-at-rest key/value stores for secrets. Each vault is a `.env`-format
120
+ file at `<stashDir>/vaults/<name>.env`.
121
+
122
+ ```sh
123
+ akm vault create prod # Create a new vault
124
+ akm vault set prod DB_URL postgres://... # Set a key (or KEY=VALUE combined form)
125
+ akm vault set prod DB_URL=postgres://... # Combined KEY=VALUE form also works
126
+ akm vault unset prod DB_URL # Remove a key
127
+ akm vault list # List all vaults across all stashes with key names
128
+ akm vault path vault:prod # Print the vault file path for shell loading
129
+ akm vault run vault:prod -- env # Run one command with all vault vars injected
130
+ akm vault run vault:prod/DB_URL -- printenv DB_URL # Inject one key for one command
131
+ ```
132
+
133
+ ## Workflows
134
+
135
+ Step-based workflows stored as `<stashDir>/workflows/<name>.md`.
136
+
137
+ Ref-based workflow commands are scoped to the current project/worktree/directory,
138
+ so one active run does not block unrelated directories from starting the same
139
+ workflow. Direct run-id commands still target the exact run.
140
+
141
+ ```sh
142
+ akm workflow template # Print a starter workflow template
143
+ akm workflow create ship-release # Scaffold a new workflow asset
144
+ akm workflow start workflow:ship-release # Start a new run in the current scope
145
+ akm workflow next workflow:ship-release # Advance to the next step (or auto-start) in the current scope
146
+ akm workflow complete <run-id> # Mark a step complete and advance
147
+ akm workflow status <run-id> # Show the exact run by id
148
+ akm workflow resume <run-id> # Resume a blocked or failed run
149
+ akm workflow list # List workflow runs in the current scope
150
+ ```
151
+
152
+ ## Clone
153
+
154
+ Copy an asset to the working stash or a custom destination for editing.
155
+
156
+ ```sh
157
+ akm clone <ref> # Clone to working stash
158
+ akm clone <ref> --name new-name # Rename on clone
159
+ akm clone <ref> --dest ./project/.claude # Clone to custom location
160
+ akm clone <ref> --force # Overwrite existing
161
+ akm clone "npm:@scope/pkg//script:deploy.sh" # Clone from remote package
162
+ ```
163
+
164
+ When `--dest` is provided, `akm init` is not required first.
165
+
166
+ ## Save
167
+
168
+ Commit local changes in a git-backed stash. Behaviour adapts automatically:
169
+
170
+ - **Not a git repo** — no-op (silent skip)
171
+ - **Git repo, no remote** — stage and commit only (the default stash always falls here)
172
+ - **Git repo, has remote, not writable** — stage and commit only
173
+ - **Git repo, has remote, `writable: true`** — stage, commit, and push
174
+
175
+ ```sh
176
+ akm save # Save primary stash (timestamp message)
177
+ akm save -m "Add deploy skill" # Save with explicit message
178
+ akm save my-skills # Save a named writable git stash
179
+ akm save my-skills -m "Update patterns" # Save named stash with message
180
+ ```
181
+
182
+ The `--writable` flag on `akm add` opts a remote git stash into push-on-save:
183
+
184
+ ```sh
185
+ akm add git@github.com:org/skills.git --provider git --name my-skills --writable
186
+ ```
187
+
188
+ ## Add & Manage Sources
189
+
190
+ ```sh
191
+ akm add <ref> # Add a source
192
+ akm add @scope/stash # From npm (managed)
193
+ akm add owner/repo # From GitHub (managed)
194
+ akm add ./path/to/local/stash # Local directory
195
+ akm add git@github.com:org/repo.git --provider git --name my-skills --writable
196
+ akm enable skills.sh # Enable the skills.sh registry
197
+ akm disable skills.sh # Disable the skills.sh registry
198
+ akm list # List all sources
199
+ akm list --kind managed # List managed sources only
200
+ akm remove <target> # Remove by id, ref, path, or name
201
+ akm update --all # Update all managed sources
202
+ akm update <target> --force # Force re-download
203
+ ```
204
+
205
+ ## Registries
206
+
207
+ ```sh
208
+ akm registry list # List configured registries
209
+ akm registry add <url> # Add a registry
210
+ akm registry add <url> --name my-team # Add with label
211
+ akm registry add <url> --provider skills-sh # Specify provider type
212
+ akm registry remove <url-or-name> # Remove a registry
213
+ akm registry search "<query>" # Search all registries
214
+ akm registry search "<query>" --assets # Include asset-level results
215
+ akm registry build-index # Build the default cache-backed index.json
216
+ akm registry build-index --out dist/index.json # Build to a custom path
217
+ ```
218
+
219
+ ## Configuration
220
+
221
+ ```sh
222
+ akm config list # Show current config
223
+ akm config get <key> # Read a value
224
+ akm config set <key> <value> # Set a value
225
+ akm config unset <key> # Remove a key
226
+ akm config path --all # Show all config paths
227
+ ```
228
+
229
+ ## Other Commands
230
+
231
+ ```sh
232
+ akm init # Initialize working stash
233
+ akm index # Rebuild search index (metadata enrichment when configured)
234
+ akm index --full # Full reindex (metadata enrichment when configured)
235
+ akm list # List all sources
236
+ akm upgrade # Upgrade akm using its install method
237
+ akm upgrade --check # Check for updates
238
+ akm help migrate 0.6.0 # Print migration notes for a release (or: latest)
239
+ akm hints # Print this reference
240
+ akm completions # Print bash completion script
241
+ akm completions --install # Install completions
242
+ ```
243
+
244
+ ## Proposals & Improvement (0.8.0+)
245
+
246
+ ```sh
247
+ akm improve <ref> # Propose improvement for an asset
248
+ akm proposals # List pending proposals
249
+ akm show proposal <id> # Render the proposal body
250
+ akm diff <ref-or-id> # Diff by ref, UUID, or 8-char prefix (proposal positional optional)
251
+ akm diff skill:akm-dream # Diff by asset ref
252
+ akm accept 7c115132 # Accept by UUID prefix
253
+ akm accept <id> --target team-stash # Accept to a named writable stash source
254
+ akm reject skill:my-skill --reason "not ready" # Reject by asset ref
255
+ akm reject <id> --reason "..." # Archive with a reason
256
+ ```
257
+
258
+ Per-task `timeoutMs`: task markdown frontmatter may set `timeoutMs: null` to
259
+ disable the agent kill timer for long-running local-model tasks, or a number
260
+ (milliseconds) to override `config.agent.timeoutMs` for that task only.
261
+
262
+ ## Output Control
263
+
264
+ All commands accept `--format` and `--detail` flags:
265
+
266
+ - `--format json` (default) — structured JSON
267
+ - `--format jsonl` — one JSON object per line (streaming-friendly)
268
+ - `--format text` — human-readable plain text
269
+ - `--format yaml` — YAML output
270
+ - `--detail brief` (default) — compact output
271
+ - `--detail normal` — adds tags, refs, origins
272
+ - `--detail full` — includes scores, paths, timing, debug info
273
+ - `--detail summary` — metadata only (no content/template/prompt), under 200 tokens
274
+ - `--detail agent` — agent-optimized output: strips non-actionable fields
275
+ - `--for-agent` — deprecated alias for `--detail agent`
276
+
277
+ Run `akm -h` or `akm <command> -h` for per-command help.
@@ -0,0 +1,65 @@
1
+ # akm CLI
2
+
3
+ You have access to a searchable library of scripts, skills, commands, agents, knowledge documents, workflows, wikis, and memories via `akm`. Search your sources first before writing something from scratch.
4
+
5
+ ## Agent Task Loop
6
+
7
+ For any task, follow this loop:
8
+ 1. `akm curate "<task>"` — find the best matching asset
9
+ 2. `akm show <ref>` — read the schema (field names and structure)
10
+ 3. Edit the workspace file using schema field names + task-specific values from your README
11
+ 4. `akm feedback <ref> --positive` — record success
12
+
13
+ For workflow tasks:
14
+ 1. `akm workflow next workflow:<name>` — get current step instructions
15
+ 2. Do the step work in your workspace
16
+ 3. `akm workflow complete <run-id> --step <step-id>` — mark done, get next step
17
+
18
+ Workflow runs are scoped to your current project/worktree/directory. Ref-based
19
+ commands like `workflow next workflow:<name>`, `workflow status workflow:<name>`,
20
+ and `workflow list` operate within the current scope only.
21
+
22
+ ## Quick Reference
23
+
24
+ ```sh
25
+ akm search "<query>" # Search all sources
26
+ akm curate "<task>" # Curate the best matches for a task
27
+ akm search "<query>" --type workflow # Filter to workflow assets
28
+ akm search "<query>" --source both # Also search registries
29
+ akm show <ref> # View asset details
30
+ akm workflow next <ref> # Start or resume a workflow
31
+ akm remember "Deployment needs VPN access" # Record a memory in your stash
32
+ akm remember "note" --target my-stash # Route write to a named writable stash source
33
+ akm import ./notes/release-checklist.md # Import a knowledge doc into your stash
34
+ akm import ./doc.md --target my-stash # Route import to a named writable stash source
35
+ akm wiki list # List available wikis
36
+ akm wiki ingest <name> # Print the ingest workflow for a wiki
37
+ akm wiki stash <name> ./paper.md --target my-stash # Route wiki stash write to a named source
38
+ akm diff skill:akm-dream # Diff proposal by ref, UUID, or 8-char prefix
39
+ akm accept 7c115132 # Accept by UUID prefix (proposal positional optional)
40
+ akm reject skill:my-skill --reason "..." # Reject by ref (proposal positional optional)
41
+ akm feedback <ref> --positive|--negative # Record whether an asset helped
42
+ akm add <ref> # Add a source (npm, GitHub, git, local dir)
43
+ akm clone <ref> # Copy an asset to the working stash (optional --dest arg to clone to specific location)
44
+ akm save # Commit (and push if writable remote) changes in the primary stash
45
+ akm registry search "<query>" # Search all registries
46
+ ```
47
+
48
+ ## Primary Asset Types
49
+
50
+ | Type | What `akm show` returns |
51
+ | --- | --- |
52
+ | script | A `run` command you can execute directly |
53
+ | skill | Instructions to follow (read the full content) |
54
+ | command | A prompt template with placeholders to fill in |
55
+ | agent | A system prompt with model and tool hints |
56
+ | knowledge | A reference doc (use `toc` or `section "..."` to navigate) |
57
+ | workflow | Parsed steps plus workflow-specific execution commands |
58
+ | memory | Recalled context (read the content for background information) |
59
+ | vault | Key names only; use `akm vault path` or `akm vault run` to use values safely |
60
+ | wiki | A page in a multi-wiki knowledge base. For any wiki task, start with `akm wiki list`, then `akm wiki ingest <name>` for the workflow. Run `akm wiki -h` for the full surface. |
61
+
62
+ When an asset meaningfully helps or fails, record that with `akm feedback` so
63
+ future search ranking can learn from real usage.
64
+
65
+ Run `akm -h` for the full command reference.