agentikit 0.0.13 → 0.0.15

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 (156) hide show
  1. package/LICENSE +385 -0
  2. package/README.md +187 -110
  3. package/dist/{src/asset-spec.js → asset-spec.js} +11 -2
  4. package/dist/{src/asset-type-handler.js → asset-type-handler.js} +4 -3
  5. package/dist/cli.js +709 -0
  6. package/dist/common.js +192 -0
  7. package/dist/{src/config-cli.js → config-cli.js} +36 -30
  8. package/dist/{src/config.js → config.js} +95 -25
  9. package/dist/{src/db.js → db.js} +123 -51
  10. package/dist/{src/embedder.js → embedder.js} +57 -2
  11. package/dist/errors.js +28 -0
  12. package/dist/file-context.js +188 -0
  13. package/dist/{src/frontmatter.js → frontmatter.js} +1 -1
  14. package/dist/{src/github.js → github.js} +1 -3
  15. package/dist/handlers/agent-handler.js +19 -0
  16. package/dist/handlers/command-handler.js +20 -0
  17. package/dist/handlers/handler-bridge.js +51 -0
  18. package/dist/handlers/index.js +19 -0
  19. package/dist/handlers/knowledge-handler.js +32 -0
  20. package/dist/handlers/script-handler.js +42 -0
  21. package/dist/{src/handlers → handlers}/skill-handler.js +5 -6
  22. package/dist/{src/handlers → handlers}/tool-handler.js +8 -24
  23. package/dist/{src/indexer.js → indexer.js} +50 -26
  24. package/dist/init.js +43 -0
  25. package/dist/{src/llm.js → llm.js} +6 -11
  26. package/dist/lockfile.js +60 -0
  27. package/dist/matchers.js +163 -0
  28. package/dist/{src/metadata.js → metadata.js} +36 -16
  29. package/dist/{src/origin-resolve.js → origin-resolve.js} +10 -9
  30. package/dist/paths.js +83 -0
  31. package/dist/{src/registry-install.js → registry-install.js} +151 -19
  32. package/dist/{src/registry-resolve.js → registry-resolve.js} +190 -26
  33. package/dist/{src/registry-search.js → registry-search.js} +13 -21
  34. package/dist/renderers.js +286 -0
  35. package/dist/{src/ripgrep-install.js → ripgrep-install.js} +8 -27
  36. package/dist/{src/ripgrep-resolve.js → ripgrep-resolve.js} +21 -11
  37. package/dist/ripgrep.js +2 -0
  38. package/dist/self-update.js +226 -0
  39. package/dist/{src/stash-add.js → stash-add.js} +14 -4
  40. package/dist/stash-clone.js +115 -0
  41. package/dist/{src/stash-ref.js → stash-ref.js} +10 -9
  42. package/dist/{src/stash-registry.js → stash-registry.js} +21 -46
  43. package/dist/{src/stash-resolve.js → stash-resolve.js} +10 -9
  44. package/dist/{src/stash-search.js → stash-search.js} +89 -74
  45. package/dist/stash-show.js +74 -0
  46. package/dist/stash-source.js +127 -0
  47. package/dist/submit.js +557 -0
  48. package/dist/{src/tool-runner.js → tool-runner.js} +1 -5
  49. package/dist/{src/walker.js → walker.js} +38 -0
  50. package/dist/warn.js +20 -0
  51. package/package.json +13 -18
  52. package/dist/index.d.ts +0 -28
  53. package/dist/index.js +0 -15
  54. package/dist/src/asset-spec.d.ts +0 -16
  55. package/dist/src/asset-type-handler.d.ts +0 -27
  56. package/dist/src/cli.d.ts +0 -2
  57. package/dist/src/cli.js +0 -399
  58. package/dist/src/common.d.ts +0 -13
  59. package/dist/src/common.js +0 -60
  60. package/dist/src/config-cli.d.ts +0 -9
  61. package/dist/src/config.d.ts +0 -50
  62. package/dist/src/db.d.ts +0 -46
  63. package/dist/src/embedder.d.ts +0 -10
  64. package/dist/src/frontmatter.d.ts +0 -30
  65. package/dist/src/github.d.ts +0 -4
  66. package/dist/src/handlers/agent-handler.d.ts +0 -2
  67. package/dist/src/handlers/agent-handler.js +0 -26
  68. package/dist/src/handlers/command-handler.d.ts +0 -2
  69. package/dist/src/handlers/command-handler.js +0 -23
  70. package/dist/src/handlers/index.d.ts +0 -6
  71. package/dist/src/handlers/index.js +0 -23
  72. package/dist/src/handlers/knowledge-handler.d.ts +0 -2
  73. package/dist/src/handlers/knowledge-handler.js +0 -56
  74. package/dist/src/handlers/markdown-helpers.d.ts +0 -7
  75. package/dist/src/handlers/script-handler.d.ts +0 -2
  76. package/dist/src/handlers/script-handler.js +0 -78
  77. package/dist/src/handlers/skill-handler.d.ts +0 -2
  78. package/dist/src/handlers/tool-handler.d.ts +0 -2
  79. package/dist/src/indexer.d.ts +0 -22
  80. package/dist/src/init.d.ts +0 -19
  81. package/dist/src/init.js +0 -99
  82. package/dist/src/llm.d.ts +0 -15
  83. package/dist/src/markdown.d.ts +0 -18
  84. package/dist/src/metadata.d.ts +0 -41
  85. package/dist/src/origin-resolve.d.ts +0 -19
  86. package/dist/src/registry-install.d.ts +0 -11
  87. package/dist/src/registry-resolve.d.ts +0 -3
  88. package/dist/src/registry-search.d.ts +0 -27
  89. package/dist/src/registry-types.d.ts +0 -62
  90. package/dist/src/ripgrep-install.d.ts +0 -12
  91. package/dist/src/ripgrep-resolve.d.ts +0 -13
  92. package/dist/src/ripgrep.d.ts +0 -3
  93. package/dist/src/ripgrep.js +0 -2
  94. package/dist/src/stash-add.d.ts +0 -4
  95. package/dist/src/stash-clone.d.ts +0 -22
  96. package/dist/src/stash-clone.js +0 -83
  97. package/dist/src/stash-ref.d.ts +0 -31
  98. package/dist/src/stash-registry.d.ts +0 -18
  99. package/dist/src/stash-resolve.d.ts +0 -2
  100. package/dist/src/stash-search.d.ts +0 -8
  101. package/dist/src/stash-show.d.ts +0 -5
  102. package/dist/src/stash-show.js +0 -46
  103. package/dist/src/stash-source.d.ts +0 -24
  104. package/dist/src/stash-source.js +0 -81
  105. package/dist/src/stash-types.d.ts +0 -227
  106. package/dist/src/stash.d.ts +0 -16
  107. package/dist/src/stash.js +0 -9
  108. package/dist/src/tool-runner.d.ts +0 -35
  109. package/dist/src/walker.d.ts +0 -19
  110. package/src/asset-spec.ts +0 -85
  111. package/src/asset-type-handler.ts +0 -77
  112. package/src/cli.ts +0 -427
  113. package/src/common.ts +0 -76
  114. package/src/config-cli.ts +0 -499
  115. package/src/config.ts +0 -305
  116. package/src/db.ts +0 -411
  117. package/src/embedder.ts +0 -128
  118. package/src/frontmatter.ts +0 -95
  119. package/src/github.ts +0 -21
  120. package/src/handlers/agent-handler.ts +0 -32
  121. package/src/handlers/command-handler.ts +0 -29
  122. package/src/handlers/index.ts +0 -25
  123. package/src/handlers/knowledge-handler.ts +0 -62
  124. package/src/handlers/markdown-helpers.ts +0 -19
  125. package/src/handlers/script-handler.ts +0 -92
  126. package/src/handlers/skill-handler.ts +0 -37
  127. package/src/handlers/tool-handler.ts +0 -71
  128. package/src/indexer.ts +0 -392
  129. package/src/init.ts +0 -114
  130. package/src/llm.ts +0 -125
  131. package/src/markdown.ts +0 -106
  132. package/src/metadata.ts +0 -333
  133. package/src/origin-resolve.ts +0 -67
  134. package/src/registry-install.ts +0 -361
  135. package/src/registry-resolve.ts +0 -341
  136. package/src/registry-search.ts +0 -335
  137. package/src/registry-types.ts +0 -72
  138. package/src/ripgrep-install.ts +0 -200
  139. package/src/ripgrep-resolve.ts +0 -72
  140. package/src/ripgrep.ts +0 -3
  141. package/src/stash-add.ts +0 -63
  142. package/src/stash-clone.ts +0 -127
  143. package/src/stash-ref.ts +0 -99
  144. package/src/stash-registry.ts +0 -259
  145. package/src/stash-resolve.ts +0 -50
  146. package/src/stash-search.ts +0 -613
  147. package/src/stash-show.ts +0 -55
  148. package/src/stash-source.ts +0 -103
  149. package/src/stash-types.ts +0 -231
  150. package/src/stash.ts +0 -39
  151. package/src/tool-runner.ts +0 -142
  152. package/src/walker.ts +0 -53
  153. /package/dist/{src/handlers → handlers}/markdown-helpers.js +0 -0
  154. /package/dist/{src/markdown.js → markdown.js} +0 -0
  155. /package/dist/{src/registry-types.js → registry-types.js} +0 -0
  156. /package/dist/{src/stash-types.js → stash-types.js} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentikit",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "type": "module",
5
5
  "description": "CLI tool to search, open, and run extension assets from an agentikit stash directory.",
6
6
  "keywords": [
@@ -21,40 +21,35 @@
21
21
  "bugs": {
22
22
  "url": "https://github.com/itlackey/agentikit/issues"
23
23
  },
24
- "license": "CC-BY-4.0",
24
+ "license": "MPL-2.0",
25
25
  "files": [
26
26
  "dist",
27
- "src",
28
- "README.md"
27
+ "README.md",
28
+ "LICENSE"
29
29
  ],
30
30
  "bin": {
31
- "akm": "dist/src/cli.js"
32
- },
33
- "main": "./dist/index.js",
34
- "types": "./dist/index.d.ts",
35
- "exports": {
36
- ".": {
37
- "types": "./dist/index.d.ts",
38
- "default": "./dist/index.js"
39
- }
31
+ "akm": "dist/cli.js"
40
32
  },
41
33
  "scripts": {
42
- "build": "bun run tsc --project ./tsconfig.json --emitDeclarationOnly false --declaration false --outDir dist",
43
- "build:types": "bun run tsc --project ./tsconfig.json",
34
+ "build": "rm -rf dist && bun run tsc --project ./tsconfig.json --outDir dist",
44
35
  "test": "bun test",
45
- "prepublishOnly": "bun run build && bun run build:types"
36
+ "lint": "biome check src/ tests/",
37
+ "lint:fix": "biome check --write src/ tests/",
38
+ "format": "biome format --write src/ tests/",
39
+ "prepublishOnly": "bun run build"
46
40
  },
47
41
  "publishConfig": {
48
42
  "access": "public"
49
43
  },
50
44
  "devDependencies": {
51
- "@types/node": "^24.0.0",
45
+ "@biomejs/biome": "^2.4.6",
46
+ "@types/node": "^22.0.0",
52
47
  "bun-types": "^1.3.10",
53
48
  "typescript": "^5.9.3"
54
49
  },
55
50
  "optionalDependencies": {
56
51
  "@xenova/transformers": "^2.17.0",
57
- "sqlite-vec": "^0.1.7-alpha.2"
52
+ "sqlite-vec": "0.1.7-alpha.2"
58
53
  },
59
54
  "engines": {
60
55
  "bun": ">=1.0.0"
package/dist/index.d.ts DELETED
@@ -1,28 +0,0 @@
1
- export { agentikitAdd, agentikitClone, agentikitList, agentikitRemove, agentikitReinstall, agentikitSearch, agentikitShow, agentikitUpdate, resolveStashSources, resolveAllStashDirs, findSourceForPath, } from "./src/stash";
2
- export { agentikitInit } from "./src/init";
3
- export type { InitResponse } from "./src/init";
4
- export type { AgentikitAssetType, AgentikitSearchType, AddResponse, LocalSearchHit, RegistrySearchResultHit, SearchSource, SearchHit, SearchResponse, ShowResponse, KnowledgeView, ListResponse, RemoveResponse, ReinstallResponse, UpdateResponse, RegistryListEntry, RegistryInstallStatus, ReinstallResultItem, UpdateResultItem, StashSource, StashSourceKind, CloneOptions, CloneResponse, } from "./src/stash";
5
- export type { ToolKind } from "./src/tool-runner";
6
- export { agentikitIndex } from "./src/indexer";
7
- export type { IndexResponse } from "./src/indexer";
8
- export type { StashEntry, StashFile, StashIntent } from "./src/metadata";
9
- export { resolveRg, isRgAvailable, ensureRg } from "./src/ripgrep";
10
- export type { EnsureRgResult } from "./src/ripgrep";
11
- export { parseMarkdownToc, extractSection, extractLineRange, extractFrontmatterOnly, formatToc } from "./src/markdown";
12
- export type { TocHeading, KnowledgeToc } from "./src/markdown";
13
- export { parseFrontmatter } from "./src/frontmatter";
14
- export { loadConfig, saveConfig, updateConfig } from "./src/config";
15
- export type { AgentikitConfig, EmbeddingConnectionConfig, LlmConnectionConfig, RegistryConfig } from "./src/config";
16
- export { parseRegistryRef, resolveRegistryArtifact } from "./src/registry-resolve";
17
- export { searchRegistry } from "./src/registry-search";
18
- export { installRegistryRef, upsertInstalledRegistryEntry, removeInstalledRegistryEntry, getRegistryCacheRootDir, detectStashRoot, } from "./src/registry-install";
19
- export type { RegistrySource, ParsedRegistryRef, ParsedNpmRef, ParsedGithubRef, ResolvedRegistryArtifact, RegistryInstalledEntry, RegistryInstallResult, RegistrySearchHit, RegistrySearchResponse, } from "./src/registry-types";
20
- export { enhanceMetadata, isLlmAvailable } from "./src/llm";
21
- export { embed, cosineSimilarity, isEmbeddingAvailable } from "./src/embedder";
22
- export type { EmbeddingVector } from "./src/embedder";
23
- export type { SearchUsageMode } from "./src/stash-types";
24
- export type { AssetTypeHandler, ShowInput } from "./src/asset-type-handler";
25
- export { registerAssetType, getHandler, tryGetHandler, getAllHandlers, getRegisteredTypeNames } from "./src/asset-type-handler";
26
- export { parseAssetRef, makeAssetRef } from "./src/stash-ref";
27
- export type { AssetRef } from "./src/stash-ref";
28
- export { resolveSourcesForOrigin, isRemoteOrigin } from "./src/origin-resolve";
package/dist/index.js DELETED
@@ -1,15 +0,0 @@
1
- export { agentikitAdd, agentikitClone, agentikitList, agentikitRemove, agentikitReinstall, agentikitSearch, agentikitShow, agentikitUpdate, resolveStashSources, resolveAllStashDirs, findSourceForPath, } from "./src/stash";
2
- export { agentikitInit } from "./src/init";
3
- export { agentikitIndex } from "./src/indexer";
4
- export { resolveRg, isRgAvailable, ensureRg } from "./src/ripgrep";
5
- export { parseMarkdownToc, extractSection, extractLineRange, extractFrontmatterOnly, formatToc } from "./src/markdown";
6
- export { parseFrontmatter } from "./src/frontmatter";
7
- export { loadConfig, saveConfig, updateConfig } from "./src/config";
8
- export { parseRegistryRef, resolveRegistryArtifact } from "./src/registry-resolve";
9
- export { searchRegistry } from "./src/registry-search";
10
- export { installRegistryRef, upsertInstalledRegistryEntry, removeInstalledRegistryEntry, getRegistryCacheRootDir, detectStashRoot, } from "./src/registry-install";
11
- export { enhanceMetadata, isLlmAvailable } from "./src/llm";
12
- export { embed, cosineSimilarity, isEmbeddingAvailable } from "./src/embedder";
13
- export { registerAssetType, getHandler, tryGetHandler, getAllHandlers, getRegisteredTypeNames } from "./src/asset-type-handler";
14
- export { parseAssetRef, makeAssetRef } from "./src/stash-ref";
15
- export { resolveSourcesForOrigin, isRemoteOrigin } from "./src/origin-resolve";
@@ -1,16 +0,0 @@
1
- import type { AgentikitAssetType } from "./common";
2
- export declare const SCRIPT_EXTENSIONS: Set<string>;
3
- export interface AssetSpec {
4
- stashDir: string;
5
- isRelevantFile: (fileName: string) => boolean;
6
- toCanonicalName: (typeRoot: string, filePath: string) => string | undefined;
7
- toAssetPath: (typeRoot: string, name: string) => string;
8
- }
9
- /** Extended set of script extensions for the script asset type */
10
- export declare const SCRIPT_EXTENSIONS_BROAD: Set<string>;
11
- export declare const ASSET_SPECS: Record<AgentikitAssetType, AssetSpec>;
12
- export declare const ASSET_TYPES: AgentikitAssetType[];
13
- export declare const TYPE_DIRS: Record<AgentikitAssetType, string>;
14
- export declare function isRelevantAssetFile(assetType: AgentikitAssetType, fileName: string): boolean;
15
- export declare function deriveCanonicalAssetName(assetType: AgentikitAssetType, typeRoot: string, filePath: string): string | undefined;
16
- export declare function resolveAssetPathFromName(assetType: AgentikitAssetType, typeRoot: string, name: string): string;
@@ -1,27 +0,0 @@
1
- import type { StashEntry } from "./metadata";
2
- import type { LocalSearchHit, ShowResponse, KnowledgeView } from "./stash-types";
3
- export interface ShowInput {
4
- name: string;
5
- path: string;
6
- content: string;
7
- view?: KnowledgeView;
8
- stashDirs?: string[];
9
- }
10
- export interface AssetTypeHandler {
11
- /** The type name, e.g. "tool", "script" */
12
- readonly typeName: string;
13
- /** Directory inside the stash root, e.g. "tools", "scripts" */
14
- readonly stashDir: string;
15
- isRelevantFile(fileName: string): boolean;
16
- toCanonicalName(typeRoot: string, filePath: string): string | undefined;
17
- toAssetPath(typeRoot: string, name: string): string;
18
- buildShowResponse(input: ShowInput): ShowResponse;
19
- enrichSearchHit?(hit: LocalSearchHit, stashDir: string): void;
20
- readonly defaultUsageGuide: string[];
21
- extractTypeMetadata?(entry: StashEntry, file: string, ext: string): void;
22
- }
23
- export declare function registerAssetType(handler: AssetTypeHandler): void;
24
- export declare function getHandler(type: string): AssetTypeHandler;
25
- export declare function tryGetHandler(type: string): AssetTypeHandler | undefined;
26
- export declare function getAllHandlers(): AssetTypeHandler[];
27
- export declare function getRegisteredTypeNames(): string[];
package/dist/src/cli.d.ts DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
package/dist/src/cli.js DELETED
@@ -1,399 +0,0 @@
1
- #!/usr/bin/env node
2
- import { defineCommand, runMain } from "citty";
3
- import { agentikitAdd, agentikitList, agentikitReinstall, agentikitRemove, agentikitSearch, agentikitShow, agentikitUpdate, } from "./stash";
4
- import { agentikitInit } from "./init";
5
- import { agentikitIndex } from "./indexer";
6
- import { agentikitClone } from "./stash-clone";
7
- import { resolveStashSources } from "./stash-source";
8
- import { loadConfig, saveConfig } from "./config";
9
- import { getConfigValue, listConfig, listProviders, parseConfigValue, setConfigValue, unsetConfigValue, useProvider, } from "./config-cli";
10
- const initCommand = defineCommand({
11
- meta: { name: "init", description: "Initialize Agent-i-Kit's working stash directory and set AKM_STASH_DIR" },
12
- async run() {
13
- await runWithJsonErrors(async () => {
14
- const result = await agentikitInit();
15
- console.log(JSON.stringify(result, null, 2));
16
- });
17
- },
18
- });
19
- const indexCommand = defineCommand({
20
- meta: { name: "index", description: "Build search index (incremental by default; --full forces full reindex)" },
21
- args: {
22
- full: { type: "boolean", description: "Force full reindex", default: false },
23
- },
24
- async run({ args }) {
25
- await runWithJsonErrors(async () => {
26
- const result = await agentikitIndex({ full: args.full });
27
- console.log(JSON.stringify(result, null, 2));
28
- });
29
- },
30
- });
31
- const searchCommand = defineCommand({
32
- meta: { name: "search", description: "Search the stash" },
33
- args: {
34
- query: { type: "positional", description: "Search query", required: false, default: "" },
35
- type: { type: "string", description: "Asset type filter (tool|skill|command|agent|knowledge|script|any)" },
36
- limit: { type: "string", description: "Maximum number of results" },
37
- usage: { type: "string", description: "Usage metadata mode (none|both|item|guide)", default: "both" },
38
- source: { type: "string", description: "Search source (local|registry|both)", default: "local" },
39
- },
40
- async run({ args }) {
41
- await runWithJsonErrors(async () => {
42
- const type = args.type;
43
- const limit = args.limit ? parseInt(args.limit, 10) : undefined;
44
- const usage = parseSearchUsageMode(args.usage);
45
- const source = parseSearchSource(args.source);
46
- console.log(JSON.stringify(await agentikitSearch({ query: args.query, type, limit, usage, source }), null, 2));
47
- });
48
- },
49
- });
50
- const addCommand = defineCommand({
51
- meta: { name: "add", description: "Install a registry package or local git directory into the stash" },
52
- args: {
53
- ref: {
54
- type: "positional",
55
- description: "Registry ref (npm package, owner/repo, github URL, or local git directory)",
56
- required: true,
57
- },
58
- },
59
- async run({ args }) {
60
- await runWithJsonErrors(async () => {
61
- console.log(JSON.stringify(await agentikitAdd({ ref: args.ref }), null, 2));
62
- });
63
- },
64
- });
65
- const listCommand = defineCommand({
66
- meta: { name: "list", description: "List installed registry packages from config" },
67
- async run() {
68
- await runWithJsonErrors(async () => {
69
- console.log(JSON.stringify(await agentikitList(), null, 2));
70
- });
71
- },
72
- });
73
- const removeCommand = defineCommand({
74
- meta: { name: "remove", description: "Remove an installed registry package by id or ref" },
75
- args: {
76
- target: { type: "positional", description: "Installed target (id or ref)", required: true },
77
- },
78
- async run({ args }) {
79
- await runWithJsonErrors(async () => {
80
- console.log(JSON.stringify(await agentikitRemove({ target: args.target }), null, 2));
81
- });
82
- },
83
- });
84
- const updateCommand = defineCommand({
85
- meta: { name: "update", description: "Update one or all installed registry packages" },
86
- args: {
87
- target: { type: "positional", description: "Installed target (id or ref)", required: false },
88
- all: { type: "boolean", description: "Update all installed entries", default: false },
89
- },
90
- async run({ args }) {
91
- await runWithJsonErrors(async () => {
92
- console.log(JSON.stringify(await agentikitUpdate({ target: args.target, all: args.all }), null, 2));
93
- });
94
- },
95
- });
96
- const reinstallCommand = defineCommand({
97
- meta: { name: "reinstall", description: "Reinstall one or all installed registry packages" },
98
- args: {
99
- target: { type: "positional", description: "Installed target (id or ref)", required: false },
100
- all: { type: "boolean", description: "Reinstall all installed entries", default: false },
101
- },
102
- async run({ args }) {
103
- await runWithJsonErrors(async () => {
104
- console.log(JSON.stringify(await agentikitReinstall({ target: args.target, all: args.all }), null, 2));
105
- });
106
- },
107
- });
108
- const showCommand = defineCommand({
109
- meta: { name: "show", description: "Show a stash asset by ref (e.g. agent:bunjs-typescript-coder.md)" },
110
- args: {
111
- ref: { type: "positional", description: "Asset ref (type:name)", required: true },
112
- view: { type: "string", description: "Knowledge view mode (full|toc|frontmatter|section|lines)" },
113
- heading: { type: "string", description: "Section heading (for --view section)" },
114
- start: { type: "string", description: "Start line (for --view lines)" },
115
- end: { type: "string", description: "End line (for --view lines)" },
116
- },
117
- async run({ args }) {
118
- await runWithJsonErrors(async () => {
119
- let view;
120
- if (args.view) {
121
- switch (args.view) {
122
- case "section":
123
- view = { mode: "section", heading: args.heading ?? "" };
124
- break;
125
- case "lines":
126
- view = {
127
- mode: "lines",
128
- start: Number(args.start ?? "1"),
129
- end: args.end ? parseInt(args.end, 10) : Number.MAX_SAFE_INTEGER,
130
- };
131
- break;
132
- case "toc":
133
- case "frontmatter":
134
- case "full":
135
- view = { mode: args.view };
136
- break;
137
- default:
138
- throw new Error(`Unknown view mode: ${args.view}. Expected one of: full|toc|frontmatter|section|lines`);
139
- }
140
- }
141
- console.log(JSON.stringify(await agentikitShow({ ref: args.ref, view }), null, 2));
142
- });
143
- },
144
- });
145
- const configCommand = defineCommand({
146
- meta: { name: "config", description: "Show configuration, get/set keys, and manage embedding/LLM providers" },
147
- args: {
148
- list: { type: "boolean", description: "List current configuration with effective defaults", default: false },
149
- get: { type: "string", description: "Get a configuration value by key" },
150
- unset: { type: "string", description: "Unset an optional configuration key or whole embedding/llm section" },
151
- set: { type: "string", description: "Back-compat alias for updating a key (key=value format)" },
152
- },
153
- subCommands: {
154
- list: defineCommand({
155
- meta: { name: "list", description: "List current configuration with effective embedding/LLM settings" },
156
- run() {
157
- return runWithJsonErrors(() => {
158
- console.log(JSON.stringify(listConfig(loadConfig()), null, 2));
159
- });
160
- },
161
- }),
162
- get: defineCommand({
163
- meta: { name: "get", description: "Get a configuration value by key" },
164
- args: {
165
- key: { type: "positional", required: true, description: "Config key (for example: embedding.provider)" },
166
- },
167
- run({ args }) {
168
- return runWithJsonErrors(() => {
169
- console.log(JSON.stringify(getConfigValue(loadConfig(), args.key), null, 2));
170
- });
171
- },
172
- }),
173
- set: defineCommand({
174
- meta: { name: "set", description: "Set a configuration value by key" },
175
- args: {
176
- key: { type: "positional", required: true, description: "Config key (for example: llm.temperature)" },
177
- value: { type: "positional", required: true, description: "Config value" },
178
- },
179
- run({ args }) {
180
- return runWithJsonErrors(() => {
181
- const updated = setConfigValue(loadConfig(), args.key, args.value);
182
- saveConfig(updated);
183
- console.log(JSON.stringify(listConfig(updated), null, 2));
184
- });
185
- },
186
- }),
187
- unset: defineCommand({
188
- meta: { name: "unset", description: "Unset an optional configuration key or whole embedding/llm section" },
189
- args: {
190
- key: { type: "positional", required: true, description: "Config key to unset" },
191
- },
192
- run({ args }) {
193
- return runWithJsonErrors(() => {
194
- const updated = unsetConfigValue(loadConfig(), args.key);
195
- saveConfig(updated);
196
- console.log(JSON.stringify(listConfig(updated), null, 2));
197
- });
198
- },
199
- }),
200
- providers: defineCommand({
201
- meta: { name: "providers", description: "List available embedding or LLM providers" },
202
- args: {
203
- scope: { type: "positional", required: true, description: "Provider scope: embedding or llm" },
204
- },
205
- run({ args }) {
206
- return runWithJsonErrors(() => {
207
- const scope = parseProviderScope(args.scope);
208
- console.log(JSON.stringify(listProviders(scope, loadConfig()), null, 2));
209
- });
210
- },
211
- }),
212
- use: defineCommand({
213
- meta: { name: "use", description: "Switch the default embedding or LLM provider" },
214
- args: {
215
- scope: { type: "positional", required: true, description: "Provider scope: embedding or llm" },
216
- provider: { type: "positional", required: true, description: "Provider name" },
217
- },
218
- run({ args }) {
219
- return runWithJsonErrors(() => {
220
- const scope = parseProviderScope(args.scope);
221
- const updated = useProvider(loadConfig(), scope, args.provider);
222
- saveConfig(updated);
223
- console.log(JSON.stringify(listConfig(updated), null, 2));
224
- });
225
- },
226
- }),
227
- },
228
- run({ args }) {
229
- return runWithJsonErrors(() => {
230
- if (hasConfigSubcommand(args))
231
- return;
232
- if (args.list) {
233
- console.log(JSON.stringify(listConfig(loadConfig()), null, 2));
234
- return;
235
- }
236
- if (args.get) {
237
- console.log(JSON.stringify(getConfigValue(loadConfig(), args.get), null, 2));
238
- return;
239
- }
240
- if (args.unset) {
241
- const updated = unsetConfigValue(loadConfig(), args.unset);
242
- saveConfig(updated);
243
- console.log(JSON.stringify(listConfig(updated), null, 2));
244
- return;
245
- }
246
- if (args.set) {
247
- const eqIndex = args.set.indexOf("=");
248
- if (eqIndex === -1) {
249
- throw new Error("--set expects key=value format");
250
- }
251
- const key = args.set.slice(0, eqIndex);
252
- const value = args.set.slice(eqIndex + 1);
253
- const partial = parseConfigValue(key, value);
254
- const config = { ...loadConfig(), ...partial };
255
- saveConfig(config);
256
- console.log(JSON.stringify(listConfig(config), null, 2));
257
- }
258
- else {
259
- console.log(JSON.stringify(listConfig(loadConfig()), null, 2));
260
- }
261
- });
262
- },
263
- });
264
- const cloneCommand = defineCommand({
265
- meta: { name: "clone", description: "Clone an asset from any stash source into the working stash" },
266
- args: {
267
- ref: { type: "positional", description: "Asset ref (e.g. @installed:pkg/tool:script.sh)", required: true },
268
- name: { type: "string", description: "New name for the cloned asset" },
269
- force: { type: "boolean", description: "Overwrite if asset already exists in working stash", default: false },
270
- },
271
- async run({ args }) {
272
- await runWithJsonErrors(async () => {
273
- const result = await agentikitClone({
274
- sourceRef: args.ref,
275
- newName: args.name,
276
- force: args.force,
277
- });
278
- console.log(JSON.stringify(result, null, 2));
279
- });
280
- },
281
- });
282
- const sourcesCommand = defineCommand({
283
- meta: { name: "sources", description: "List all stash sources with their kind, path, and status" },
284
- run() {
285
- return runWithJsonErrors(() => {
286
- const sources = resolveStashSources();
287
- console.log(JSON.stringify({ sources }, null, 2));
288
- });
289
- },
290
- });
291
- const main = defineCommand({
292
- meta: {
293
- name: "akm",
294
- description: "CLI tool to search, open, and manage assets from Agent-i-Kit stash.",
295
- },
296
- subCommands: {
297
- init: initCommand,
298
- index: indexCommand,
299
- add: addCommand,
300
- list: listCommand,
301
- remove: removeCommand,
302
- update: updateCommand,
303
- reinstall: reinstallCommand,
304
- search: searchCommand,
305
- show: showCommand,
306
- clone: cloneCommand,
307
- sources: sourcesCommand,
308
- config: configCommand,
309
- },
310
- });
311
- const SEARCH_USAGE_MODES = ["none", "both", "item", "guide"];
312
- const SEARCH_SOURCES = ["local", "registry", "both"];
313
- const CONFIG_SUBCOMMAND_SET = new Set(["list", "get", "set", "unset", "providers", "use"]);
314
- // Note: citty reads process.argv directly, so we must normalize it in-place.
315
- // This is done once at startup before runMain.
316
- normalizeConfigArgv(process.argv);
317
- runMain(main);
318
- function parseSearchUsageMode(value) {
319
- if (SEARCH_USAGE_MODES.includes(value))
320
- return value;
321
- throw new Error(`Invalid value for --usage: ${value}. Expected one of: ${SEARCH_USAGE_MODES.join("|")}`);
322
- }
323
- function parseSearchSource(value) {
324
- if (SEARCH_SOURCES.includes(value))
325
- return value;
326
- throw new Error(`Invalid value for --source: ${value}. Expected one of: ${SEARCH_SOURCES.join("|")}`);
327
- }
328
- async function runWithJsonErrors(fn) {
329
- try {
330
- await fn();
331
- }
332
- catch (error) {
333
- const message = error instanceof Error ? error.message : String(error);
334
- const hint = buildHint(message);
335
- console.error(JSON.stringify({ ok: false, error: message, hint }, null, 2));
336
- process.exit(1);
337
- }
338
- }
339
- function buildHint(message) {
340
- if (message.includes("AKM_STASH_DIR"))
341
- return "Run `akm init` or set AKM_STASH_DIR to a valid directory.";
342
- if (message.includes("Either <target> or --all is required"))
343
- return "Use `akm update --all` or pass a target like `akm update npm:@scope/pkg`.";
344
- if (message.includes("Specify either <target> or --all"))
345
- return "Use only one: a positional target or `--all`.";
346
- if (message.includes("No installed registry entry matched target"))
347
- return "Run `akm list` to view installed ids/refs, then retry with one of those values.";
348
- if (message.includes("Invalid value for --source"))
349
- return "Pick one of: local, registry, both.";
350
- if (message.includes("Invalid value for --usage"))
351
- return "Pick one of: none, both, item, guide.";
352
- if (message.includes("expected JSON object with endpoint and model")) {
353
- return "Quote JSON values in your shell, for example: akm config set embedding '{\"endpoint\":\"http://localhost:11434/v1/embeddings\",\"model\":\"nomic-embed-text\"}'.";
354
- }
355
- return undefined;
356
- }
357
- function parseProviderScope(value) {
358
- if (value === "embedding" || value === "llm")
359
- return value;
360
- throw new Error(`Invalid provider scope: ${value}. Expected one of: embedding|llm`);
361
- }
362
- function hasConfigSubcommand(args) {
363
- const command = Array.isArray(args._) ? args._[0] : undefined;
364
- return typeof command === "string" && CONFIG_SUBCOMMAND_SET.has(command);
365
- }
366
- /**
367
- * Mutate argv before citty parses it so git-style config forms like
368
- * `akm config llm.maxTokens 512` and `akm config --get llm.maxTokens`
369
- * are normalized into the existing config subcommands.
370
- */
371
- function normalizeConfigArgv(argv) {
372
- const [, , command, argAfterCommand, argAfterKey, ...rest] = argv;
373
- if (command !== "config")
374
- return;
375
- if (!argAfterCommand)
376
- return;
377
- if (argAfterCommand === "--list") {
378
- argv.splice(3, argv.length - 3, "list");
379
- return;
380
- }
381
- if (argAfterCommand === "--get" && argAfterKey) {
382
- argv.splice(3, argv.length - 3, "get", argAfterKey, ...rest);
383
- return;
384
- }
385
- if (argAfterCommand === "--unset" && argAfterKey) {
386
- argv.splice(3, argv.length - 3, "unset", argAfterKey, ...rest);
387
- return;
388
- }
389
- if (argAfterCommand.startsWith("-"))
390
- return;
391
- if (CONFIG_SUBCOMMAND_SET.has(argAfterCommand))
392
- return;
393
- // A single arg after `config` behaves like `git config <key>` and reads the value.
394
- if (argAfterKey === undefined) {
395
- argv.splice(3, argv.length - 3, "get", argAfterCommand);
396
- return;
397
- }
398
- argv.splice(3, argv.length - 3, "set", argAfterCommand, argAfterKey, ...rest);
399
- }
@@ -1,13 +0,0 @@
1
- export type AgentikitAssetType = "tool" | "skill" | "command" | "agent" | "knowledge" | "script";
2
- export declare const IS_WINDOWS: boolean;
3
- export { SCRIPT_EXTENSIONS, TYPE_DIRS } from "./asset-spec";
4
- export declare function isAssetType(type: string): type is AgentikitAssetType;
5
- export declare function resolveStashDir(): string;
6
- export declare function toPosix(input: string): string;
7
- export declare function hasErrnoCode(error: unknown, code: string): boolean;
8
- export declare function isWithin(candidate: string, root: string): boolean;
9
- /**
10
- * Fetch with an AbortController timeout.
11
- * Defaults to 30 seconds if no timeout is specified.
12
- */
13
- export declare function fetchWithTimeout(url: string, opts?: RequestInit, timeoutMs?: number): Promise<Response>;
@@ -1,60 +0,0 @@
1
- import fs from "node:fs";
2
- import path from "node:path";
3
- import { TYPE_DIRS } from "./asset-spec";
4
- // ── Constants ───────────────────────────────────────────────────────────────
5
- export const IS_WINDOWS = process.platform === "win32";
6
- export { SCRIPT_EXTENSIONS, TYPE_DIRS } from "./asset-spec";
7
- // ── Validators ──────────────────────────────────────────────────────────────
8
- export function isAssetType(type) {
9
- return type in TYPE_DIRS;
10
- }
11
- // ── Utilities ───────────────────────────────────────────────────────────────
12
- export function resolveStashDir() {
13
- const raw = process.env.AKM_STASH_DIR?.trim();
14
- if (!raw) {
15
- throw new Error("AKM_STASH_DIR is not set. Set it to your Agentikit stash path.");
16
- }
17
- const stashDir = path.resolve(raw);
18
- let stat;
19
- try {
20
- stat = fs.statSync(stashDir);
21
- }
22
- catch {
23
- throw new Error(`Unable to read AKM_STASH_DIR at "${stashDir}".`);
24
- }
25
- if (!stat.isDirectory()) {
26
- throw new Error(`AKM_STASH_DIR must point to a directory: "${stashDir}".`);
27
- }
28
- return stashDir;
29
- }
30
- export function toPosix(input) {
31
- return input.replace(/\\/g, "/");
32
- }
33
- export function hasErrnoCode(error, code) {
34
- if (typeof error !== "object" || error === null || !("code" in error))
35
- return false;
36
- return error.code === code;
37
- }
38
- export function isWithin(candidate, root) {
39
- const normalizedRoot = normalizeFsPathForComparison(path.resolve(root));
40
- const normalizedCandidate = normalizeFsPathForComparison(path.resolve(candidate));
41
- const rel = path.relative(normalizedRoot, normalizedCandidate);
42
- return rel === "" || (!rel.startsWith("..") && !path.isAbsolute(rel));
43
- }
44
- function normalizeFsPathForComparison(value) {
45
- return process.platform === "win32" ? value.toLowerCase() : value;
46
- }
47
- /**
48
- * Fetch with an AbortController timeout.
49
- * Defaults to 30 seconds if no timeout is specified.
50
- */
51
- export async function fetchWithTimeout(url, opts, timeoutMs = 30_000) {
52
- const controller = new AbortController();
53
- const timer = setTimeout(() => controller.abort(), timeoutMs);
54
- try {
55
- return await fetch(url, { ...opts, signal: controller.signal });
56
- }
57
- finally {
58
- clearTimeout(timer);
59
- }
60
- }
@@ -1,9 +0,0 @@
1
- import { type AgentikitConfig } from "./config";
2
- export type ConfigProviderScope = "embedding" | "llm";
3
- export declare function parseConfigValue(key: string, value: string): Partial<AgentikitConfig>;
4
- export declare function getConfigValue(config: AgentikitConfig, key: string): unknown;
5
- export declare function setConfigValue(config: AgentikitConfig, key: string, rawValue: string): AgentikitConfig;
6
- export declare function unsetConfigValue(config: AgentikitConfig, key: string): AgentikitConfig;
7
- export declare function listConfig(config: AgentikitConfig): Record<string, unknown>;
8
- export declare function listProviders(scope: ConfigProviderScope, config: AgentikitConfig): Array<Record<string, unknown>>;
9
- export declare function useProvider(config: AgentikitConfig, scope: ConfigProviderScope, providerName: string): AgentikitConfig;