agentikit 0.0.13 → 0.0.14

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 (145) hide show
  1. package/LICENSE +385 -0
  2. package/README.md +180 -110
  3. package/dist/cli.js +671 -0
  4. package/dist/common.js +192 -0
  5. package/dist/{src/config-cli.js → config-cli.js} +14 -6
  6. package/dist/{src/config.js → config.js} +92 -24
  7. package/dist/{src/db.js → db.js} +109 -35
  8. package/dist/{src/embedder.js → embedder.js} +57 -2
  9. package/dist/file-context.js +158 -0
  10. package/dist/{src/handlers → handlers}/command-handler.js +2 -0
  11. package/dist/{src/handlers → handlers}/index.js +0 -6
  12. package/dist/{src/indexer.js → indexer.js} +34 -10
  13. package/dist/init.js +43 -0
  14. package/dist/lockfile.js +55 -0
  15. package/dist/matchers.js +157 -0
  16. package/dist/{src/metadata.js → metadata.js} +12 -1
  17. package/dist/{src/origin-resolve.js → origin-resolve.js} +10 -9
  18. package/dist/paths.js +82 -0
  19. package/dist/{src/registry-install.js → registry-install.js} +145 -17
  20. package/dist/{src/registry-resolve.js → registry-resolve.js} +178 -18
  21. package/dist/{src/registry-search.js → registry-search.js} +8 -16
  22. package/dist/renderers.js +276 -0
  23. package/dist/{src/ripgrep-install.js → ripgrep-install.js} +5 -5
  24. package/dist/{src/ripgrep-resolve.js → ripgrep-resolve.js} +21 -11
  25. package/dist/self-update.js +220 -0
  26. package/dist/{src/stash-add.js → stash-add.js} +11 -2
  27. package/dist/stash-clone.js +115 -0
  28. package/dist/{src/stash-registry.js → stash-registry.js} +15 -41
  29. package/dist/{src/stash-search.js → stash-search.js} +67 -55
  30. package/dist/{src/stash-show.js → stash-show.js} +30 -3
  31. package/dist/{src/stash-source.js → stash-source.js} +56 -9
  32. package/dist/submit.js +552 -0
  33. package/dist/{src/walker.js → walker.js} +38 -0
  34. package/package.json +7 -16
  35. package/dist/index.d.ts +0 -28
  36. package/dist/index.js +0 -15
  37. package/dist/src/asset-spec.d.ts +0 -16
  38. package/dist/src/asset-type-handler.d.ts +0 -27
  39. package/dist/src/cli.d.ts +0 -2
  40. package/dist/src/cli.js +0 -399
  41. package/dist/src/common.d.ts +0 -13
  42. package/dist/src/common.js +0 -60
  43. package/dist/src/config-cli.d.ts +0 -9
  44. package/dist/src/config.d.ts +0 -50
  45. package/dist/src/db.d.ts +0 -46
  46. package/dist/src/embedder.d.ts +0 -10
  47. package/dist/src/frontmatter.d.ts +0 -30
  48. package/dist/src/github.d.ts +0 -4
  49. package/dist/src/handlers/agent-handler.d.ts +0 -2
  50. package/dist/src/handlers/command-handler.d.ts +0 -2
  51. package/dist/src/handlers/index.d.ts +0 -6
  52. package/dist/src/handlers/knowledge-handler.d.ts +0 -2
  53. package/dist/src/handlers/markdown-helpers.d.ts +0 -7
  54. package/dist/src/handlers/script-handler.d.ts +0 -2
  55. package/dist/src/handlers/skill-handler.d.ts +0 -2
  56. package/dist/src/handlers/tool-handler.d.ts +0 -2
  57. package/dist/src/indexer.d.ts +0 -22
  58. package/dist/src/init.d.ts +0 -19
  59. package/dist/src/init.js +0 -99
  60. package/dist/src/llm.d.ts +0 -15
  61. package/dist/src/markdown.d.ts +0 -18
  62. package/dist/src/metadata.d.ts +0 -41
  63. package/dist/src/origin-resolve.d.ts +0 -19
  64. package/dist/src/registry-install.d.ts +0 -11
  65. package/dist/src/registry-resolve.d.ts +0 -3
  66. package/dist/src/registry-search.d.ts +0 -27
  67. package/dist/src/registry-types.d.ts +0 -62
  68. package/dist/src/ripgrep-install.d.ts +0 -12
  69. package/dist/src/ripgrep-resolve.d.ts +0 -13
  70. package/dist/src/ripgrep.d.ts +0 -3
  71. package/dist/src/stash-add.d.ts +0 -4
  72. package/dist/src/stash-clone.d.ts +0 -22
  73. package/dist/src/stash-clone.js +0 -83
  74. package/dist/src/stash-ref.d.ts +0 -31
  75. package/dist/src/stash-registry.d.ts +0 -18
  76. package/dist/src/stash-resolve.d.ts +0 -2
  77. package/dist/src/stash-search.d.ts +0 -8
  78. package/dist/src/stash-show.d.ts +0 -5
  79. package/dist/src/stash-source.d.ts +0 -24
  80. package/dist/src/stash-types.d.ts +0 -227
  81. package/dist/src/stash.d.ts +0 -16
  82. package/dist/src/stash.js +0 -9
  83. package/dist/src/tool-runner.d.ts +0 -35
  84. package/dist/src/walker.d.ts +0 -19
  85. package/src/asset-spec.ts +0 -85
  86. package/src/asset-type-handler.ts +0 -77
  87. package/src/cli.ts +0 -427
  88. package/src/common.ts +0 -76
  89. package/src/config-cli.ts +0 -499
  90. package/src/config.ts +0 -305
  91. package/src/db.ts +0 -411
  92. package/src/embedder.ts +0 -128
  93. package/src/frontmatter.ts +0 -95
  94. package/src/github.ts +0 -21
  95. package/src/handlers/agent-handler.ts +0 -32
  96. package/src/handlers/command-handler.ts +0 -29
  97. package/src/handlers/index.ts +0 -25
  98. package/src/handlers/knowledge-handler.ts +0 -62
  99. package/src/handlers/markdown-helpers.ts +0 -19
  100. package/src/handlers/script-handler.ts +0 -92
  101. package/src/handlers/skill-handler.ts +0 -37
  102. package/src/handlers/tool-handler.ts +0 -71
  103. package/src/indexer.ts +0 -392
  104. package/src/init.ts +0 -114
  105. package/src/llm.ts +0 -125
  106. package/src/markdown.ts +0 -106
  107. package/src/metadata.ts +0 -333
  108. package/src/origin-resolve.ts +0 -67
  109. package/src/registry-install.ts +0 -361
  110. package/src/registry-resolve.ts +0 -341
  111. package/src/registry-search.ts +0 -335
  112. package/src/registry-types.ts +0 -72
  113. package/src/ripgrep-install.ts +0 -200
  114. package/src/ripgrep-resolve.ts +0 -72
  115. package/src/ripgrep.ts +0 -3
  116. package/src/stash-add.ts +0 -63
  117. package/src/stash-clone.ts +0 -127
  118. package/src/stash-ref.ts +0 -99
  119. package/src/stash-registry.ts +0 -259
  120. package/src/stash-resolve.ts +0 -50
  121. package/src/stash-search.ts +0 -613
  122. package/src/stash-show.ts +0 -55
  123. package/src/stash-source.ts +0 -103
  124. package/src/stash-types.ts +0 -231
  125. package/src/stash.ts +0 -39
  126. package/src/tool-runner.ts +0 -142
  127. package/src/walker.ts +0 -53
  128. /package/dist/{src/asset-spec.js → asset-spec.js} +0 -0
  129. /package/dist/{src/asset-type-handler.js → asset-type-handler.js} +0 -0
  130. /package/dist/{src/frontmatter.js → frontmatter.js} +0 -0
  131. /package/dist/{src/github.js → github.js} +0 -0
  132. /package/dist/{src/handlers → handlers}/agent-handler.js +0 -0
  133. /package/dist/{src/handlers → handlers}/knowledge-handler.js +0 -0
  134. /package/dist/{src/handlers → handlers}/markdown-helpers.js +0 -0
  135. /package/dist/{src/handlers → handlers}/script-handler.js +0 -0
  136. /package/dist/{src/handlers → handlers}/skill-handler.js +0 -0
  137. /package/dist/{src/handlers → handlers}/tool-handler.js +0 -0
  138. /package/dist/{src/llm.js → llm.js} +0 -0
  139. /package/dist/{src/markdown.js → markdown.js} +0 -0
  140. /package/dist/{src/registry-types.js → registry-types.js} +0 -0
  141. /package/dist/{src/ripgrep.js → ripgrep.js} +0 -0
  142. /package/dist/{src/stash-ref.js → stash-ref.js} +0 -0
  143. /package/dist/{src/stash-resolve.js → stash-resolve.js} +0 -0
  144. /package/dist/{src/stash-types.js → stash-types.js} +0 -0
  145. /package/dist/{src/tool-runner.js → tool-runner.js} +0 -0
@@ -1,24 +0,0 @@
1
- export type StashSourceKind = "working" | "mounted" | "installed";
2
- export interface StashSource {
3
- kind: StashSourceKind;
4
- path: string;
5
- /** For installed sources, the registry entry id */
6
- registryId?: string;
7
- /** Whether this source is writable (only working stash) */
8
- writable: boolean;
9
- }
10
- /**
11
- * Build the ordered list of stash sources:
12
- * 1. Working stash (writable)
13
- * 2. Mounted stash dirs (read-only, user-configured)
14
- * 3. Installed stash dirs (read-only, derived from registry.installed)
15
- */
16
- export declare function resolveStashSources(overrideStashDir?: string): StashSource[];
17
- /**
18
- * Convenience: returns just the directory paths, preserving priority order.
19
- */
20
- export declare function resolveAllStashDirs(overrideStashDir?: string): string[];
21
- /**
22
- * Find which source a file path belongs to.
23
- */
24
- export declare function findSourceForPath(filePath: string, sources: StashSource[]): StashSource | undefined;
@@ -1,227 +0,0 @@
1
- import type { AgentikitAssetType } from "./common";
2
- import type { RegistrySource } from "./registry-types";
3
- import type { ToolKind } from "./tool-runner";
4
- export type AgentikitSearchType = AgentikitAssetType | "any";
5
- export type SearchUsageMode = "none" | "both" | "item" | "guide";
6
- export type SearchSource = "local" | "registry" | "both";
7
- export interface LocalSearchHit {
8
- hitSource: "local";
9
- type: AgentikitAssetType;
10
- name: string;
11
- path: string;
12
- openRef: string;
13
- /** For installed sources, the registry id */
14
- registryId?: string;
15
- /** Whether this asset is editable (only true for working stash) */
16
- editable?: boolean;
17
- description?: string;
18
- tags?: string[];
19
- score?: number;
20
- whyMatched?: string[];
21
- runCmd?: string;
22
- kind?: ToolKind;
23
- usage?: string[];
24
- }
25
- export interface RegistrySearchResultHit {
26
- hitSource: "registry";
27
- type: "registry";
28
- name: string;
29
- path?: string;
30
- openRef?: string;
31
- id: string;
32
- registrySource: RegistrySource;
33
- ref: string;
34
- description?: string;
35
- tags?: string[];
36
- homepage?: string;
37
- score?: number;
38
- whyMatched?: string[];
39
- runCmd?: string;
40
- kind?: ToolKind;
41
- usage?: string[];
42
- metadata?: Record<string, string>;
43
- installRef: string;
44
- installCmd: string;
45
- /** Whether this entry was manually reviewed and approved */
46
- curated?: boolean;
47
- }
48
- export type SearchHit = LocalSearchHit | RegistrySearchResultHit;
49
- export interface SearchResponse {
50
- stashDir: string;
51
- source: SearchSource;
52
- hits: SearchHit[];
53
- usageGuide?: Partial<Record<AgentikitAssetType, string[]>>;
54
- tip?: string;
55
- warnings?: string[];
56
- /** Timing counters in milliseconds */
57
- timing?: {
58
- totalMs: number;
59
- rankMs?: number;
60
- embedMs?: number;
61
- };
62
- }
63
- export interface AddResponse {
64
- stashDir: string;
65
- ref: string;
66
- installed: {
67
- id: string;
68
- source: RegistrySource;
69
- ref: string;
70
- artifactUrl: string;
71
- resolvedVersion?: string;
72
- resolvedRevision?: string;
73
- stashRoot: string;
74
- cacheDir: string;
75
- extractedDir: string;
76
- installedAt: string;
77
- };
78
- config: {
79
- mountedStashDirs: string[];
80
- installedRegistryCount: number;
81
- };
82
- index: {
83
- mode: "full" | "incremental";
84
- totalEntries: number;
85
- directoriesScanned: number;
86
- directoriesSkipped: number;
87
- };
88
- }
89
- export interface RegistryInstallStatus {
90
- id: string;
91
- source: RegistrySource;
92
- ref: string;
93
- artifactUrl: string;
94
- resolvedVersion?: string;
95
- resolvedRevision?: string;
96
- stashRoot: string;
97
- cacheDir: string;
98
- extractedDir: string;
99
- installedAt: string;
100
- }
101
- export interface RegistryListEntry {
102
- id: string;
103
- source: RegistrySource;
104
- ref: string;
105
- artifactUrl: string;
106
- resolvedVersion?: string;
107
- resolvedRevision?: string;
108
- stashRoot: string;
109
- cacheDir: string;
110
- installedAt: string;
111
- status: {
112
- cacheDirExists: boolean;
113
- stashRootExists: boolean;
114
- };
115
- }
116
- export interface ListResponse {
117
- stashDir: string;
118
- installed: RegistryListEntry[];
119
- totalInstalled: number;
120
- }
121
- export interface RemoveResponse {
122
- stashDir: string;
123
- target: string;
124
- removed: {
125
- id: string;
126
- source: RegistrySource;
127
- ref: string;
128
- cacheDir: string;
129
- stashRoot: string;
130
- };
131
- config: {
132
- mountedStashDirs: string[];
133
- installedRegistryCount: number;
134
- };
135
- index: {
136
- mode: "full" | "incremental";
137
- totalEntries: number;
138
- directoriesScanned: number;
139
- directoriesSkipped: number;
140
- };
141
- }
142
- export interface ReinstallResultItem {
143
- id: string;
144
- source: RegistrySource;
145
- ref: string;
146
- previousCacheDir: string;
147
- installed: RegistryInstallStatus;
148
- }
149
- export interface ReinstallResponse {
150
- stashDir: string;
151
- target?: string;
152
- all: boolean;
153
- processed: ReinstallResultItem[];
154
- config: {
155
- mountedStashDirs: string[];
156
- installedRegistryCount: number;
157
- };
158
- index: {
159
- mode: "full" | "incremental";
160
- totalEntries: number;
161
- directoriesScanned: number;
162
- directoriesSkipped: number;
163
- };
164
- }
165
- export interface UpdateResultItem {
166
- id: string;
167
- source: RegistrySource;
168
- ref: string;
169
- previous: {
170
- resolvedVersion?: string;
171
- resolvedRevision?: string;
172
- cacheDir: string;
173
- };
174
- installed: RegistryInstallStatus;
175
- changed: {
176
- version: boolean;
177
- revision: boolean;
178
- any: boolean;
179
- };
180
- }
181
- export interface UpdateResponse {
182
- stashDir: string;
183
- target?: string;
184
- all: boolean;
185
- processed: UpdateResultItem[];
186
- config: {
187
- mountedStashDirs: string[];
188
- installedRegistryCount: number;
189
- };
190
- index: {
191
- mode: "full" | "incremental";
192
- totalEntries: number;
193
- directoriesScanned: number;
194
- directoriesSkipped: number;
195
- };
196
- }
197
- export interface ShowResponse {
198
- type: AgentikitAssetType;
199
- name: string;
200
- path: string;
201
- content?: string;
202
- template?: string;
203
- prompt?: string;
204
- description?: string;
205
- toolPolicy?: unknown;
206
- modelHint?: unknown;
207
- runCmd?: string;
208
- kind?: ToolKind;
209
- /** For installed sources, the registry id */
210
- registryId?: string;
211
- /** Whether this asset is editable (only true for working stash) */
212
- editable?: boolean;
213
- }
214
- export type KnowledgeView = {
215
- mode: "full";
216
- } | {
217
- mode: "toc";
218
- } | {
219
- mode: "frontmatter";
220
- } | {
221
- mode: "section";
222
- heading: string;
223
- } | {
224
- mode: "lines";
225
- start: number;
226
- end: number;
227
- };
@@ -1,16 +0,0 @@
1
- export type { AgentikitAssetType } from "./common";
2
- export { resolveStashDir } from "./common";
3
- export { agentikitInit } from "./init";
4
- export type { InitResponse } from "./init";
5
- export type { ToolKind } from "./tool-runner";
6
- export type { AssetTypeHandler, ShowInput } from "./asset-type-handler";
7
- export { registerAssetType, getHandler, getAllHandlers, getRegisteredTypeNames } from "./asset-type-handler";
8
- export { agentikitSearch } from "./stash-search";
9
- export { agentikitShow } from "./stash-show";
10
- export { agentikitAdd } from "./stash-add";
11
- export { agentikitClone } from "./stash-clone";
12
- export { agentikitList, agentikitRemove, agentikitReinstall, agentikitUpdate } from "./stash-registry";
13
- export { resolveStashSources, resolveAllStashDirs, findSourceForPath } from "./stash-source";
14
- export type { StashSource, StashSourceKind } from "./stash-source";
15
- export type { AddResponse, AgentikitSearchType, LocalSearchHit, RegistrySearchResultHit, SearchSource, SearchUsageMode, SearchHit, SearchResponse, ShowResponse, KnowledgeView, ListResponse, RemoveResponse, ReinstallResponse, UpdateResponse, RegistryListEntry, RegistryInstallStatus, ReinstallResultItem, UpdateResultItem, } from "./stash-types";
16
- export type { CloneOptions, CloneResponse } from "./stash-clone";
package/dist/src/stash.js DELETED
@@ -1,9 +0,0 @@
1
- export { resolveStashDir } from "./common";
2
- export { agentikitInit } from "./init";
3
- export { registerAssetType, getHandler, getAllHandlers, getRegisteredTypeNames } from "./asset-type-handler";
4
- export { agentikitSearch } from "./stash-search";
5
- export { agentikitShow } from "./stash-show";
6
- export { agentikitAdd } from "./stash-add";
7
- export { agentikitClone } from "./stash-clone";
8
- export { agentikitList, agentikitRemove, agentikitReinstall, agentikitUpdate } from "./stash-registry";
9
- export { resolveStashSources, resolveAllStashDirs, findSourceForPath } from "./stash-source";
@@ -1,35 +0,0 @@
1
- /**
2
- * Tool execution utilities.
3
- *
4
- * Handles building run commands and executing tool scripts for all supported
5
- * kinds (bash, bun, powershell, cmd).
6
- */
7
- /** The supported tool execution kinds. */
8
- export type ToolKind = "bash" | "bun" | "powershell" | "cmd";
9
- export interface ToolExecution {
10
- command: string;
11
- args: string[];
12
- cwd?: string;
13
- }
14
- export interface ToolInfo {
15
- runCmd: string;
16
- kind: ToolKind;
17
- install?: ToolExecution;
18
- execute: ToolExecution;
19
- }
20
- /**
21
- * Build execution metadata for a tool file based on its extension.
22
- *
23
- * For `.ts` / `.js` files, looks up the nearest `package.json` so that
24
- * `bun install` can be run in the correct working directory when the
25
- * `AKM_BUN_INSTALL` env flag is set.
26
- */
27
- export declare function buildToolInfo(stashDir: string, filePath: string): ToolInfo;
28
- /**
29
- * Shell-quote a path for inclusion in a human-readable `runCmd` string.
30
- */
31
- export declare function shellQuote(input: string): string;
32
- /**
33
- * Walk up from `startDir` toward `toolsRoot` looking for the nearest `package.json`.
34
- */
35
- export declare function findNearestPackageDir(startDir: string, toolsRoot: string): string | undefined;
@@ -1,19 +0,0 @@
1
- /**
2
- * Shared filesystem walker for agentikit stash directories.
3
- *
4
- * Provides a single implementation used by both the search fallback
5
- * (stash.ts) and the indexer (indexer.ts) to walk type-specific asset
6
- * directories and group files by parent directory.
7
- */
8
- import { type AgentikitAssetType } from "./common";
9
- export interface DirectoryGroup {
10
- dirPath: string;
11
- files: string[];
12
- }
13
- /**
14
- * Walk a type root directory and return files grouped by their parent directory.
15
- *
16
- * Only files relevant to the given `assetType` are included (e.g. `.md` for
17
- * commands, script extensions for tools, `SKILL.md` for skills).
18
- */
19
- export declare function walkStash(typeRoot: string, assetType: AgentikitAssetType): DirectoryGroup[];
package/src/asset-spec.ts DELETED
@@ -1,85 +0,0 @@
1
- import path from "node:path"
2
- import type { AgentikitAssetType } from "./common"
3
- import { toPosix } from "./common"
4
- import { tryGetHandler } from "./asset-type-handler"
5
-
6
- export const SCRIPT_EXTENSIONS = new Set([".sh", ".ts", ".js", ".ps1", ".cmd", ".bat"])
7
-
8
- export interface AssetSpec {
9
- stashDir: string
10
- isRelevantFile: (fileName: string) => boolean
11
- toCanonicalName: (typeRoot: string, filePath: string) => string | undefined
12
- toAssetPath: (typeRoot: string, name: string) => string
13
- }
14
-
15
- const markdownSpec: Omit<AssetSpec, "stashDir"> = {
16
- isRelevantFile: (fileName) => path.extname(fileName).toLowerCase() === ".md",
17
- toCanonicalName: (typeRoot, filePath) => toPosix(path.relative(typeRoot, filePath)),
18
- toAssetPath: (typeRoot, name) => path.join(typeRoot, name),
19
- }
20
-
21
- /** Extended set of script extensions for the script asset type */
22
- export const SCRIPT_EXTENSIONS_BROAD = new Set([
23
- ...SCRIPT_EXTENSIONS,
24
- ".py", ".rb", ".go", ".pl", ".php", ".lua", ".r", ".swift", ".kt", ".kts",
25
- ])
26
-
27
- export const ASSET_SPECS: Record<AgentikitAssetType, AssetSpec> = {
28
- tool: {
29
- stashDir: "tools",
30
- isRelevantFile: (fileName) => SCRIPT_EXTENSIONS.has(path.extname(fileName).toLowerCase()),
31
- toCanonicalName: (typeRoot, filePath) => toPosix(path.relative(typeRoot, filePath)),
32
- toAssetPath: (typeRoot, name) => path.join(typeRoot, name),
33
- },
34
- skill: {
35
- stashDir: "skills",
36
- isRelevantFile: (fileName) => fileName === "SKILL.md",
37
- toCanonicalName: (typeRoot, filePath) => {
38
- const relDir = toPosix(path.dirname(path.relative(typeRoot, filePath)))
39
- if (!relDir || relDir === ".") return undefined
40
- return relDir
41
- },
42
- toAssetPath: (typeRoot, name) => path.join(typeRoot, name, "SKILL.md"),
43
- },
44
- command: { stashDir: "commands", ...markdownSpec },
45
- agent: { stashDir: "agents", ...markdownSpec },
46
- knowledge: { stashDir: "knowledge", ...markdownSpec },
47
- script: {
48
- stashDir: "scripts",
49
- isRelevantFile: (fileName) => SCRIPT_EXTENSIONS_BROAD.has(path.extname(fileName).toLowerCase()),
50
- toCanonicalName: (typeRoot, filePath) => toPosix(path.relative(typeRoot, filePath)),
51
- toAssetPath: (typeRoot, name) => path.join(typeRoot, name),
52
- },
53
- }
54
-
55
- export const ASSET_TYPES = Object.keys(ASSET_SPECS) as AgentikitAssetType[]
56
-
57
- export const TYPE_DIRS: Record<AgentikitAssetType, string> = ASSET_TYPES.reduce(
58
- (acc, type) => {
59
- acc[type] = ASSET_SPECS[type].stashDir
60
- return acc
61
- },
62
- {} as Record<AgentikitAssetType, string>,
63
- )
64
-
65
- export function isRelevantAssetFile(assetType: AgentikitAssetType, fileName: string): boolean {
66
- const handler = tryGetHandler(assetType)
67
- if (handler) return handler.isRelevantFile(fileName)
68
- return ASSET_SPECS[assetType].isRelevantFile(fileName)
69
- }
70
-
71
- export function deriveCanonicalAssetName(
72
- assetType: AgentikitAssetType,
73
- typeRoot: string,
74
- filePath: string,
75
- ): string | undefined {
76
- const handler = tryGetHandler(assetType)
77
- if (handler) return handler.toCanonicalName(typeRoot, filePath)
78
- return ASSET_SPECS[assetType].toCanonicalName(typeRoot, filePath)
79
- }
80
-
81
- export function resolveAssetPathFromName(assetType: AgentikitAssetType, typeRoot: string, name: string): string {
82
- const handler = tryGetHandler(assetType)
83
- if (handler) return handler.toAssetPath(typeRoot, name)
84
- return ASSET_SPECS[assetType].toAssetPath(typeRoot, name)
85
- }
@@ -1,77 +0,0 @@
1
- import type { StashEntry } from "./metadata"
2
- import type { LocalSearchHit, ShowResponse, KnowledgeView } from "./stash-types"
3
-
4
- // ── Interface ────────────────────────────────────────────────────────────────
5
-
6
- export interface ShowInput {
7
- name: string
8
- path: string
9
- content: string
10
- view?: KnowledgeView
11
- stashDirs?: string[]
12
- }
13
-
14
- export interface AssetTypeHandler {
15
- /** The type name, e.g. "tool", "script" */
16
- readonly typeName: string
17
- /** Directory inside the stash root, e.g. "tools", "scripts" */
18
- readonly stashDir: string
19
-
20
- // -- File system spec --
21
- isRelevantFile(fileName: string): boolean
22
- toCanonicalName(typeRoot: string, filePath: string): string | undefined
23
- toAssetPath(typeRoot: string, name: string): string
24
-
25
- // -- Show behavior --
26
- buildShowResponse(input: ShowInput): ShowResponse
27
-
28
- // -- Search enrichment --
29
- enrichSearchHit?(hit: LocalSearchHit, stashDir: string): void
30
-
31
- // -- Usage guide --
32
- readonly defaultUsageGuide: string[]
33
-
34
- // -- Metadata generation hooks --
35
- extractTypeMetadata?(entry: StashEntry, file: string, ext: string): void
36
- }
37
-
38
- // ── Registry ─────────────────────────────────────────────────────────────────
39
-
40
- const handlers = new Map<string, AssetTypeHandler>()
41
-
42
- let handlersInitialized = false
43
-
44
- function ensureHandlersRegistered(): void {
45
- if (handlersInitialized) return
46
- handlersInitialized = true
47
- // Import handler registrations
48
- require("./handlers/index")
49
- }
50
-
51
- export function registerAssetType(handler: AssetTypeHandler): void {
52
- handlers.set(handler.typeName, handler)
53
- }
54
-
55
- export function getHandler(type: string): AssetTypeHandler {
56
- ensureHandlersRegistered()
57
- const handler = handlers.get(type)
58
- if (!handler) {
59
- throw new Error(`Unknown asset type: "${type}"`)
60
- }
61
- return handler
62
- }
63
-
64
- export function tryGetHandler(type: string): AssetTypeHandler | undefined {
65
- ensureHandlersRegistered()
66
- return handlers.get(type)
67
- }
68
-
69
- export function getAllHandlers(): AssetTypeHandler[] {
70
- ensureHandlersRegistered()
71
- return Array.from(handlers.values())
72
- }
73
-
74
- export function getRegisteredTypeNames(): string[] {
75
- ensureHandlersRegistered()
76
- return Array.from(handlers.keys())
77
- }