akm-cli 0.5.0 → 0.6.0-rc2

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 (118) hide show
  1. package/CHANGELOG.md +53 -5
  2. package/README.md +9 -9
  3. package/dist/cli.js +379 -1448
  4. package/dist/{completions.js → commands/completions.js} +1 -1
  5. package/dist/{config-cli.js → commands/config-cli.js} +109 -11
  6. package/dist/commands/curate.js +263 -0
  7. package/dist/{info.js → commands/info.js} +17 -11
  8. package/dist/{init.js → commands/init.js} +4 -4
  9. package/dist/{install-audit.js → commands/install-audit.js} +14 -2
  10. package/dist/{installed-kits.js → commands/installed-stashes.js} +122 -50
  11. package/dist/commands/migration-help.js +141 -0
  12. package/dist/{registry-search.js → commands/registry-search.js} +68 -9
  13. package/dist/commands/remember.js +178 -0
  14. package/dist/{stash-search.js → commands/search.js} +28 -69
  15. package/dist/{self-update.js → commands/self-update.js} +3 -3
  16. package/dist/{stash-show.js → commands/show.js} +106 -81
  17. package/dist/{stash-add.js → commands/source-add.js} +133 -67
  18. package/dist/{stash-clone.js → commands/source-clone.js} +15 -13
  19. package/dist/{stash-source-manage.js → commands/source-manage.js} +24 -24
  20. package/dist/{vault.js → commands/vault.js} +43 -0
  21. package/dist/{stash-ref.js → core/asset-ref.js} +4 -4
  22. package/dist/{asset-registry.js → core/asset-registry.js} +30 -6
  23. package/dist/{asset-spec.js → core/asset-spec.js} +13 -6
  24. package/dist/{common.js → core/common.js} +147 -50
  25. package/dist/{config.js → core/config.js} +288 -29
  26. package/dist/core/errors.js +90 -0
  27. package/dist/{frontmatter.js → core/frontmatter.js} +64 -8
  28. package/dist/{paths.js → core/paths.js} +4 -4
  29. package/dist/core/write-source.js +280 -0
  30. package/dist/{local-search.js → indexer/db-search.js} +49 -32
  31. package/dist/{db.js → indexer/db.js} +210 -81
  32. package/dist/{file-context.js → indexer/file-context.js} +3 -3
  33. package/dist/{indexer.js → indexer/indexer.js} +153 -30
  34. package/dist/{manifest.js → indexer/manifest.js} +10 -10
  35. package/dist/{matchers.js → indexer/matchers.js} +4 -7
  36. package/dist/{metadata.js → indexer/metadata.js} +9 -5
  37. package/dist/{search-source.js → indexer/search-source.js} +97 -55
  38. package/dist/{semantic-status.js → indexer/semantic-status.js} +2 -2
  39. package/dist/{walker.js → indexer/walker.js} +1 -1
  40. package/dist/{lockfile.js → integrations/lockfile.js} +29 -2
  41. package/dist/{llm.js → llm/client.js} +12 -48
  42. package/dist/llm/embedder.js +127 -0
  43. package/dist/llm/embedders/cache.js +47 -0
  44. package/dist/llm/embedders/local.js +152 -0
  45. package/dist/llm/embedders/remote.js +121 -0
  46. package/dist/llm/embedders/types.js +39 -0
  47. package/dist/llm/metadata-enhance.js +53 -0
  48. package/dist/output/cli-hints.js +301 -0
  49. package/dist/output/context.js +95 -0
  50. package/dist/{renderers.js → output/renderers.js} +57 -61
  51. package/dist/output/shapes.js +212 -0
  52. package/dist/output/text.js +520 -0
  53. package/dist/{registry-build-index.js → registry/build-index.js} +48 -32
  54. package/dist/{create-provider-registry.js → registry/create-provider-registry.js} +6 -2
  55. package/dist/registry/factory.js +33 -0
  56. package/dist/{origin-resolve.js → registry/origin-resolve.js} +1 -1
  57. package/dist/registry/providers/index.js +11 -0
  58. package/dist/{providers → registry/providers}/skills-sh.js +60 -4
  59. package/dist/{providers → registry/providers}/static-index.js +126 -56
  60. package/dist/registry/providers/types.js +25 -0
  61. package/dist/{registry-resolve.js → registry/resolve.js} +10 -6
  62. package/dist/{detect.js → setup/detect.js} +0 -27
  63. package/dist/{ripgrep-install.js → setup/ripgrep-install.js} +1 -1
  64. package/dist/{ripgrep-resolve.js → setup/ripgrep-resolve.js} +2 -2
  65. package/dist/{setup.js → setup/setup.js} +162 -129
  66. package/dist/setup/steps.js +45 -0
  67. package/dist/{kit-include.js → sources/include.js} +1 -1
  68. package/dist/sources/provider-factory.js +36 -0
  69. package/dist/sources/provider.js +21 -0
  70. package/dist/sources/providers/filesystem.js +35 -0
  71. package/dist/{stash-providers → sources/providers}/git.js +218 -28
  72. package/dist/{stash-providers → sources/providers}/index.js +4 -4
  73. package/dist/sources/providers/install-types.js +14 -0
  74. package/dist/sources/providers/npm.js +160 -0
  75. package/dist/sources/providers/provider-utils.js +173 -0
  76. package/dist/sources/providers/sync-from-ref.js +45 -0
  77. package/dist/sources/providers/tar-utils.js +154 -0
  78. package/dist/{stash-providers → sources/providers}/website.js +60 -20
  79. package/dist/{stash-resolve.js → sources/resolve.js} +13 -12
  80. package/dist/{wiki.js → wiki/wiki.js} +18 -17
  81. package/dist/{workflow-authoring.js → workflows/authoring.js} +48 -17
  82. package/dist/{workflow-cli.js → workflows/cli.js} +2 -1
  83. package/dist/{workflow-db.js → workflows/db.js} +1 -1
  84. package/dist/workflows/document-cache.js +20 -0
  85. package/dist/workflows/parser.js +379 -0
  86. package/dist/workflows/renderer.js +78 -0
  87. package/dist/{workflow-runs.js → workflows/runs.js} +84 -30
  88. package/dist/workflows/schema.js +11 -0
  89. package/dist/workflows/validator.js +48 -0
  90. package/docs/README.md +30 -0
  91. package/docs/migration/release-notes/0.0.13.md +4 -0
  92. package/docs/migration/release-notes/0.1.0.md +6 -0
  93. package/docs/migration/release-notes/0.2.0.md +6 -0
  94. package/docs/migration/release-notes/0.3.0.md +5 -0
  95. package/docs/migration/release-notes/0.5.0.md +6 -0
  96. package/docs/migration/release-notes/0.6.0.md +75 -0
  97. package/docs/migration/release-notes/README.md +21 -0
  98. package/package.json +3 -2
  99. package/dist/embedder.js +0 -351
  100. package/dist/errors.js +0 -34
  101. package/dist/migration-help.js +0 -110
  102. package/dist/registry-factory.js +0 -19
  103. package/dist/registry-install.js +0 -532
  104. package/dist/ripgrep.js +0 -2
  105. package/dist/stash-provider-factory.js +0 -35
  106. package/dist/stash-provider.js +0 -1
  107. package/dist/stash-providers/filesystem.js +0 -41
  108. package/dist/stash-providers/openviking.js +0 -348
  109. package/dist/stash-providers/provider-utils.js +0 -11
  110. package/dist/stash-types.js +0 -1
  111. package/dist/workflow-markdown.js +0 -251
  112. /package/dist/{markdown.js → core/markdown.js} +0 -0
  113. /package/dist/{warn.js → core/warn.js} +0 -0
  114. /package/dist/{search-fields.js → indexer/search-fields.js} +0 -0
  115. /package/dist/{usage-events.js → indexer/usage-events.js} +0 -0
  116. /package/dist/{github.js → integrations/github.js} +0 -0
  117. /package/dist/{registry-provider.js → registry/types.js} +0 -0
  118. /package/dist/{registry-types.js → sources/types.js} +0 -0
@@ -0,0 +1,212 @@
1
+ /**
2
+ * Pure shaping functions that select and trim fields from command result
3
+ * objects according to the active detail level / agent mode.
4
+ *
5
+ * Every function in this module is side-effect free and operates on plain
6
+ * `Record<string, unknown>` shapes, which makes them trivial to unit test.
7
+ */
8
+ const NORMAL_DESCRIPTION_LIMIT = 250;
9
+ export function shapeForCommand(command, result, detail, forAgent = false) {
10
+ switch (command) {
11
+ case "search":
12
+ return shapeSearchOutput(result, detail, forAgent);
13
+ case "registry-search":
14
+ return shapeRegistrySearchOutput(result, detail);
15
+ case "show":
16
+ return shapeShowOutput(result, detail, forAgent);
17
+ default:
18
+ return result;
19
+ }
20
+ }
21
+ export function shapeSearchOutput(result, detail, forAgent = false) {
22
+ const hits = Array.isArray(result.hits) ? result.hits : [];
23
+ const registryHits = Array.isArray(result.registryHits) ? result.registryHits : [];
24
+ const shapedHits = forAgent
25
+ ? hits.map((hit) => shapeSearchHitForAgent(hit))
26
+ : hits.map((hit) => shapeSearchHit(hit, detail));
27
+ const shapedRegistryHits = forAgent
28
+ ? registryHits.map((hit) => shapeSearchHitForAgent(hit))
29
+ : registryHits.map((hit) => shapeSearchHit(hit, detail));
30
+ if (forAgent) {
31
+ return {
32
+ hits: shapedHits,
33
+ ...(shapedRegistryHits.length > 0 ? { registryHits: shapedRegistryHits } : {}),
34
+ ...(result.tip ? { tip: result.tip } : {}),
35
+ };
36
+ }
37
+ if (detail === "full") {
38
+ return {
39
+ schemaVersion: result.schemaVersion,
40
+ stashDir: result.stashDir,
41
+ source: result.source,
42
+ hits: shapedHits,
43
+ ...(shapedRegistryHits.length > 0 ? { registryHits: shapedRegistryHits } : {}),
44
+ ...(result.semanticSearch ? { semanticSearch: result.semanticSearch } : {}),
45
+ ...(result.tip ? { tip: result.tip } : {}),
46
+ ...(result.warnings ? { warnings: result.warnings } : {}),
47
+ ...(result.timing ? { timing: result.timing } : {}),
48
+ };
49
+ }
50
+ return {
51
+ hits: shapedHits,
52
+ ...(shapedRegistryHits.length > 0 ? { registryHits: shapedRegistryHits } : {}),
53
+ ...(Array.isArray(result.warnings) && result.warnings.length > 0 ? { warnings: result.warnings } : {}),
54
+ ...(result.tip ? { tip: result.tip } : {}),
55
+ };
56
+ }
57
+ export function shapeRegistrySearchOutput(result, detail) {
58
+ const hits = Array.isArray(result.hits) ? result.hits : [];
59
+ const assetHits = Array.isArray(result.assetHits) ? result.assetHits : [];
60
+ // Shape stash hits as registry type
61
+ const shapedKitHits = hits.map((hit) => shapeSearchHit({ ...hit, type: "registry" }, detail));
62
+ // Shape asset hits by detail level
63
+ const shapedAssetHits = assetHits.map((hit) => shapeAssetHit(hit, detail));
64
+ const shaped = {
65
+ hits: shapedKitHits,
66
+ ...(shapedAssetHits.length > 0 ? { assetHits: shapedAssetHits } : {}),
67
+ ...(Array.isArray(result.warnings) && result.warnings.length > 0 ? { warnings: result.warnings } : {}),
68
+ };
69
+ if (detail === "full") {
70
+ shaped.query = result.query;
71
+ }
72
+ return shaped;
73
+ }
74
+ export function shapeAssetHit(hit, detail) {
75
+ if (detail === "brief")
76
+ return pickFields(hit, ["assetName", "assetType", "action", "estimatedTokens"]);
77
+ if (detail === "normal") {
78
+ return capDescription(pickFields(hit, ["assetName", "assetType", "description", "stash", "action", "estimatedTokens"]), NORMAL_DESCRIPTION_LIMIT);
79
+ }
80
+ return hit;
81
+ }
82
+ export function shapeSearchHit(hit, detail) {
83
+ if (hit.type === "registry") {
84
+ if (detail === "brief") {
85
+ // RegistrySearchHit uses `title` (not `name`); always project installRef
86
+ // and score so callers can use the result without --detail full (QA #28).
87
+ const out = pickFields(hit, ["title", "name", "installRef", "score"]);
88
+ // Normalise: if only title exists, expose it as `name` for consistency
89
+ if (out.title && !out.name)
90
+ out.name = out.title;
91
+ return out;
92
+ }
93
+ if (detail === "normal") {
94
+ const out = capDescription(pickFields(hit, ["title", "name", "description", "action", "installRef", "score", "curated"]), NORMAL_DESCRIPTION_LIMIT);
95
+ if (out.title && !out.name)
96
+ out.name = out.title;
97
+ return out;
98
+ }
99
+ return hit;
100
+ }
101
+ // Stash hit (local or remote)
102
+ if (detail === "brief")
103
+ return pickFields(hit, ["type", "name", "action", "estimatedTokens"]);
104
+ if (detail === "normal") {
105
+ return capDescription(pickFields(hit, ["type", "name", "description", "action", "score", "estimatedTokens"]), NORMAL_DESCRIPTION_LIMIT);
106
+ }
107
+ return hit;
108
+ }
109
+ /** Agent-optimized search hit: only fields an LLM agent needs to decide and act */
110
+ export function shapeSearchHitForAgent(hit) {
111
+ const picked = pickFields(hit, ["name", "ref", "type", "description", "action", "score", "estimatedTokens"]);
112
+ return capDescription(picked, NORMAL_DESCRIPTION_LIMIT);
113
+ }
114
+ export function capDescription(hit, limit) {
115
+ if (typeof hit.description !== "string")
116
+ return hit;
117
+ return { ...hit, description: truncateDescription(hit.description, limit) };
118
+ }
119
+ export function truncateDescription(description, limit) {
120
+ const normalized = description.replace(/\s+/g, " ").trim();
121
+ if (normalized.length <= limit)
122
+ return normalized;
123
+ const truncated = normalized.slice(0, limit - 1);
124
+ const lastSpace = truncated.lastIndexOf(" ");
125
+ const safe = lastSpace >= Math.floor(limit * 0.6) ? truncated.slice(0, lastSpace) : truncated;
126
+ return `${safe.trimEnd()}...`;
127
+ }
128
+ export function shapeShowOutput(result, detail, forAgent = false) {
129
+ if (forAgent) {
130
+ return pickFields(result, [
131
+ "type",
132
+ "name",
133
+ "description",
134
+ "action",
135
+ "content",
136
+ "template",
137
+ "prompt",
138
+ "run",
139
+ "setup",
140
+ "cwd",
141
+ "toolPolicy",
142
+ "modelHint",
143
+ "agent",
144
+ "parameters",
145
+ "workflowTitle",
146
+ "workflowParameters",
147
+ "steps",
148
+ "keys",
149
+ "comments",
150
+ ]);
151
+ }
152
+ if (detail === "summary") {
153
+ return pickFields(result, [
154
+ "type",
155
+ "name",
156
+ "description",
157
+ "tags",
158
+ "parameters",
159
+ "workflowTitle",
160
+ "action",
161
+ "run",
162
+ "origin",
163
+ "keys",
164
+ "comments",
165
+ ]);
166
+ }
167
+ const base = pickFields(result, [
168
+ "type",
169
+ "name",
170
+ "origin",
171
+ "action",
172
+ "description",
173
+ "tags",
174
+ "content",
175
+ "template",
176
+ "prompt",
177
+ "toolPolicy",
178
+ "modelHint",
179
+ "agent",
180
+ "parameters",
181
+ "workflowTitle",
182
+ "workflowParameters",
183
+ "steps",
184
+ "run",
185
+ "setup",
186
+ "cwd",
187
+ "keys",
188
+ "comments",
189
+ // path and editable are always projected so JSON consumers can locate and
190
+ // edit the asset without needing --detail full (QA #7).
191
+ "path",
192
+ "editable",
193
+ ]);
194
+ if (detail !== "full") {
195
+ return base;
196
+ }
197
+ return {
198
+ schemaVersion: 1,
199
+ ...base,
200
+ ...pickFields(result, ["editHint"]),
201
+ };
202
+ }
203
+ export function pickFields(source, fields) {
204
+ const result = {};
205
+ for (const field of fields) {
206
+ if (source[field] !== undefined) {
207
+ result[field] = source[field];
208
+ }
209
+ }
210
+ return result;
211
+ }
212
+ export { NORMAL_DESCRIPTION_LIMIT };