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.
- package/LICENSE +385 -0
- package/README.md +187 -110
- package/dist/{src/asset-spec.js → asset-spec.js} +11 -2
- package/dist/{src/asset-type-handler.js → asset-type-handler.js} +4 -3
- package/dist/cli.js +709 -0
- package/dist/common.js +192 -0
- package/dist/{src/config-cli.js → config-cli.js} +36 -30
- package/dist/{src/config.js → config.js} +95 -25
- package/dist/{src/db.js → db.js} +123 -51
- package/dist/{src/embedder.js → embedder.js} +57 -2
- package/dist/errors.js +28 -0
- package/dist/file-context.js +188 -0
- package/dist/{src/frontmatter.js → frontmatter.js} +1 -1
- package/dist/{src/github.js → github.js} +1 -3
- package/dist/handlers/agent-handler.js +19 -0
- package/dist/handlers/command-handler.js +20 -0
- package/dist/handlers/handler-bridge.js +51 -0
- package/dist/handlers/index.js +19 -0
- package/dist/handlers/knowledge-handler.js +32 -0
- package/dist/handlers/script-handler.js +42 -0
- package/dist/{src/handlers → handlers}/skill-handler.js +5 -6
- package/dist/{src/handlers → handlers}/tool-handler.js +8 -24
- package/dist/{src/indexer.js → indexer.js} +50 -26
- package/dist/init.js +43 -0
- package/dist/{src/llm.js → llm.js} +6 -11
- package/dist/lockfile.js +60 -0
- package/dist/matchers.js +163 -0
- package/dist/{src/metadata.js → metadata.js} +36 -16
- package/dist/{src/origin-resolve.js → origin-resolve.js} +10 -9
- package/dist/paths.js +83 -0
- package/dist/{src/registry-install.js → registry-install.js} +151 -19
- package/dist/{src/registry-resolve.js → registry-resolve.js} +190 -26
- package/dist/{src/registry-search.js → registry-search.js} +13 -21
- package/dist/renderers.js +286 -0
- package/dist/{src/ripgrep-install.js → ripgrep-install.js} +8 -27
- package/dist/{src/ripgrep-resolve.js → ripgrep-resolve.js} +21 -11
- package/dist/ripgrep.js +2 -0
- package/dist/self-update.js +226 -0
- package/dist/{src/stash-add.js → stash-add.js} +14 -4
- package/dist/stash-clone.js +115 -0
- package/dist/{src/stash-ref.js → stash-ref.js} +10 -9
- package/dist/{src/stash-registry.js → stash-registry.js} +21 -46
- package/dist/{src/stash-resolve.js → stash-resolve.js} +10 -9
- package/dist/{src/stash-search.js → stash-search.js} +89 -74
- package/dist/stash-show.js +74 -0
- package/dist/stash-source.js +127 -0
- package/dist/submit.js +557 -0
- package/dist/{src/tool-runner.js → tool-runner.js} +1 -5
- package/dist/{src/walker.js → walker.js} +38 -0
- package/dist/warn.js +20 -0
- package/package.json +13 -18
- package/dist/index.d.ts +0 -28
- package/dist/index.js +0 -15
- package/dist/src/asset-spec.d.ts +0 -16
- package/dist/src/asset-type-handler.d.ts +0 -27
- package/dist/src/cli.d.ts +0 -2
- package/dist/src/cli.js +0 -399
- package/dist/src/common.d.ts +0 -13
- package/dist/src/common.js +0 -60
- package/dist/src/config-cli.d.ts +0 -9
- package/dist/src/config.d.ts +0 -50
- package/dist/src/db.d.ts +0 -46
- package/dist/src/embedder.d.ts +0 -10
- package/dist/src/frontmatter.d.ts +0 -30
- package/dist/src/github.d.ts +0 -4
- package/dist/src/handlers/agent-handler.d.ts +0 -2
- package/dist/src/handlers/agent-handler.js +0 -26
- package/dist/src/handlers/command-handler.d.ts +0 -2
- package/dist/src/handlers/command-handler.js +0 -23
- package/dist/src/handlers/index.d.ts +0 -6
- package/dist/src/handlers/index.js +0 -23
- package/dist/src/handlers/knowledge-handler.d.ts +0 -2
- package/dist/src/handlers/knowledge-handler.js +0 -56
- package/dist/src/handlers/markdown-helpers.d.ts +0 -7
- package/dist/src/handlers/script-handler.d.ts +0 -2
- package/dist/src/handlers/script-handler.js +0 -78
- package/dist/src/handlers/skill-handler.d.ts +0 -2
- package/dist/src/handlers/tool-handler.d.ts +0 -2
- package/dist/src/indexer.d.ts +0 -22
- package/dist/src/init.d.ts +0 -19
- package/dist/src/init.js +0 -99
- package/dist/src/llm.d.ts +0 -15
- package/dist/src/markdown.d.ts +0 -18
- package/dist/src/metadata.d.ts +0 -41
- package/dist/src/origin-resolve.d.ts +0 -19
- package/dist/src/registry-install.d.ts +0 -11
- package/dist/src/registry-resolve.d.ts +0 -3
- package/dist/src/registry-search.d.ts +0 -27
- package/dist/src/registry-types.d.ts +0 -62
- package/dist/src/ripgrep-install.d.ts +0 -12
- package/dist/src/ripgrep-resolve.d.ts +0 -13
- package/dist/src/ripgrep.d.ts +0 -3
- package/dist/src/ripgrep.js +0 -2
- package/dist/src/stash-add.d.ts +0 -4
- package/dist/src/stash-clone.d.ts +0 -22
- package/dist/src/stash-clone.js +0 -83
- package/dist/src/stash-ref.d.ts +0 -31
- package/dist/src/stash-registry.d.ts +0 -18
- package/dist/src/stash-resolve.d.ts +0 -2
- package/dist/src/stash-search.d.ts +0 -8
- package/dist/src/stash-show.d.ts +0 -5
- package/dist/src/stash-show.js +0 -46
- package/dist/src/stash-source.d.ts +0 -24
- package/dist/src/stash-source.js +0 -81
- package/dist/src/stash-types.d.ts +0 -227
- package/dist/src/stash.d.ts +0 -16
- package/dist/src/stash.js +0 -9
- package/dist/src/tool-runner.d.ts +0 -35
- package/dist/src/walker.d.ts +0 -19
- package/src/asset-spec.ts +0 -85
- package/src/asset-type-handler.ts +0 -77
- package/src/cli.ts +0 -427
- package/src/common.ts +0 -76
- package/src/config-cli.ts +0 -499
- package/src/config.ts +0 -305
- package/src/db.ts +0 -411
- package/src/embedder.ts +0 -128
- package/src/frontmatter.ts +0 -95
- package/src/github.ts +0 -21
- package/src/handlers/agent-handler.ts +0 -32
- package/src/handlers/command-handler.ts +0 -29
- package/src/handlers/index.ts +0 -25
- package/src/handlers/knowledge-handler.ts +0 -62
- package/src/handlers/markdown-helpers.ts +0 -19
- package/src/handlers/script-handler.ts +0 -92
- package/src/handlers/skill-handler.ts +0 -37
- package/src/handlers/tool-handler.ts +0 -71
- package/src/indexer.ts +0 -392
- package/src/init.ts +0 -114
- package/src/llm.ts +0 -125
- package/src/markdown.ts +0 -106
- package/src/metadata.ts +0 -333
- package/src/origin-resolve.ts +0 -67
- package/src/registry-install.ts +0 -361
- package/src/registry-resolve.ts +0 -341
- package/src/registry-search.ts +0 -335
- package/src/registry-types.ts +0 -72
- package/src/ripgrep-install.ts +0 -200
- package/src/ripgrep-resolve.ts +0 -72
- package/src/ripgrep.ts +0 -3
- package/src/stash-add.ts +0 -63
- package/src/stash-clone.ts +0 -127
- package/src/stash-ref.ts +0 -99
- package/src/stash-registry.ts +0 -259
- package/src/stash-resolve.ts +0 -50
- package/src/stash-search.ts +0 -613
- package/src/stash-show.ts +0 -55
- package/src/stash-source.ts +0 -103
- package/src/stash-types.ts +0 -231
- package/src/stash.ts +0 -39
- package/src/tool-runner.ts +0 -142
- package/src/walker.ts +0 -53
- /package/dist/{src/handlers → handlers}/markdown-helpers.js +0 -0
- /package/dist/{src/markdown.js → markdown.js} +0 -0
- /package/dist/{src/registry-types.js → registry-types.js} +0 -0
- /package/dist/{src/stash-types.js → stash-types.js} +0 -0
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { parseFrontmatter, toStringOrUndefined } from "../frontmatter"
|
|
2
|
-
import { isMarkdownFile, markdownCanonicalName, markdownAssetPath } from "./markdown-helpers"
|
|
3
|
-
import type { AssetTypeHandler, ShowInput } from "../asset-type-handler"
|
|
4
|
-
import type { ShowResponse } from "../stash-types"
|
|
5
|
-
|
|
6
|
-
export const commandHandler: AssetTypeHandler = {
|
|
7
|
-
typeName: "command",
|
|
8
|
-
stashDir: "commands",
|
|
9
|
-
|
|
10
|
-
isRelevantFile: isMarkdownFile,
|
|
11
|
-
toCanonicalName: markdownCanonicalName,
|
|
12
|
-
toAssetPath: markdownAssetPath,
|
|
13
|
-
|
|
14
|
-
buildShowResponse(input: ShowInput): ShowResponse {
|
|
15
|
-
const parsedMd = parseFrontmatter(input.content)
|
|
16
|
-
return {
|
|
17
|
-
type: "command",
|
|
18
|
-
name: input.name,
|
|
19
|
-
path: input.path,
|
|
20
|
-
description: toStringOrUndefined(parsedMd.data.description),
|
|
21
|
-
template: parsedMd.content,
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
|
|
25
|
-
defaultUsageGuide: [
|
|
26
|
-
"Read the .md file, fill placeholders, and run it in the current repo context.",
|
|
27
|
-
"Use `akm show <openRef>` to retrieve the command template body.",
|
|
28
|
-
],
|
|
29
|
-
}
|
package/src/handlers/index.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { registerAssetType } from "../asset-type-handler"
|
|
2
|
-
import { toolHandler } from "./tool-handler"
|
|
3
|
-
import { skillHandler } from "./skill-handler"
|
|
4
|
-
import { commandHandler } from "./command-handler"
|
|
5
|
-
import { agentHandler } from "./agent-handler"
|
|
6
|
-
import { knowledgeHandler } from "./knowledge-handler"
|
|
7
|
-
import { scriptHandler } from "./script-handler"
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Register all built-in asset type handlers.
|
|
11
|
-
* This must be called (imported) before any handler lookups.
|
|
12
|
-
*/
|
|
13
|
-
registerAssetType(toolHandler)
|
|
14
|
-
registerAssetType(skillHandler)
|
|
15
|
-
registerAssetType(commandHandler)
|
|
16
|
-
registerAssetType(agentHandler)
|
|
17
|
-
registerAssetType(knowledgeHandler)
|
|
18
|
-
registerAssetType(scriptHandler)
|
|
19
|
-
|
|
20
|
-
export { toolHandler } from "./tool-handler"
|
|
21
|
-
export { skillHandler } from "./skill-handler"
|
|
22
|
-
export { commandHandler } from "./command-handler"
|
|
23
|
-
export { agentHandler } from "./agent-handler"
|
|
24
|
-
export { knowledgeHandler } from "./knowledge-handler"
|
|
25
|
-
export { scriptHandler } from "./script-handler"
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs"
|
|
2
|
-
import { parseMarkdownToc, extractSection, extractLineRange, extractFrontmatterOnly, formatToc } from "../markdown"
|
|
3
|
-
import { isMarkdownFile, markdownCanonicalName, markdownAssetPath } from "./markdown-helpers"
|
|
4
|
-
import type { AssetTypeHandler, ShowInput } from "../asset-type-handler"
|
|
5
|
-
import type { ShowResponse } from "../stash-types"
|
|
6
|
-
import type { StashEntry } from "../metadata"
|
|
7
|
-
|
|
8
|
-
export const knowledgeHandler: AssetTypeHandler = {
|
|
9
|
-
typeName: "knowledge",
|
|
10
|
-
stashDir: "knowledge",
|
|
11
|
-
|
|
12
|
-
isRelevantFile: isMarkdownFile,
|
|
13
|
-
toCanonicalName: markdownCanonicalName,
|
|
14
|
-
toAssetPath: markdownAssetPath,
|
|
15
|
-
|
|
16
|
-
buildShowResponse(input: ShowInput): ShowResponse {
|
|
17
|
-
const v = input.view ?? { mode: "full" }
|
|
18
|
-
switch (v.mode) {
|
|
19
|
-
case "toc": {
|
|
20
|
-
const toc = parseMarkdownToc(input.content)
|
|
21
|
-
return { type: "knowledge", name: input.name, path: input.path, content: formatToc(toc) }
|
|
22
|
-
}
|
|
23
|
-
case "frontmatter": {
|
|
24
|
-
const fm = extractFrontmatterOnly(input.content)
|
|
25
|
-
return { type: "knowledge", name: input.name, path: input.path, content: fm ?? "(no frontmatter)" }
|
|
26
|
-
}
|
|
27
|
-
case "section": {
|
|
28
|
-
const section = extractSection(input.content, v.heading)
|
|
29
|
-
if (!section) {
|
|
30
|
-
return {
|
|
31
|
-
type: "knowledge",
|
|
32
|
-
name: input.name,
|
|
33
|
-
path: input.path,
|
|
34
|
-
content: `Section "${v.heading}" not found in ${input.name}. Try --view toc to discover available headings.`,
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return { type: "knowledge", name: input.name, path: input.path, content: section.content }
|
|
38
|
-
}
|
|
39
|
-
case "lines": {
|
|
40
|
-
return { type: "knowledge", name: input.name, path: input.path, content: extractLineRange(input.content, v.start, v.end) }
|
|
41
|
-
}
|
|
42
|
-
default: {
|
|
43
|
-
return { type: "knowledge", name: input.name, path: input.path, content: input.content }
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
defaultUsageGuide: [
|
|
49
|
-
"Use `akm show <openRef>` to read the document; start with `--view toc` for large files.",
|
|
50
|
-
"Use `--view section` or `--view lines` to load only the part you need.",
|
|
51
|
-
],
|
|
52
|
-
|
|
53
|
-
extractTypeMetadata(entry: StashEntry, file: string): void {
|
|
54
|
-
try {
|
|
55
|
-
const mdContent = fs.readFileSync(file, "utf8")
|
|
56
|
-
const toc = parseMarkdownToc(mdContent)
|
|
57
|
-
if (toc.headings.length > 0) entry.toc = toc.headings
|
|
58
|
-
} catch {
|
|
59
|
-
// Non-fatal: skip TOC if file can't be read
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import path from "node:path"
|
|
2
|
-
import { toPosix } from "../common"
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Shared file-system helpers for markdown-based asset types
|
|
6
|
-
* (command, agent, knowledge).
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
export function isMarkdownFile(fileName: string): boolean {
|
|
10
|
-
return path.extname(fileName).toLowerCase() === ".md"
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function markdownCanonicalName(typeRoot: string, filePath: string): string | undefined {
|
|
14
|
-
return toPosix(path.relative(typeRoot, filePath))
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function markdownAssetPath(typeRoot: string, name: string): string {
|
|
18
|
-
return path.join(typeRoot, name)
|
|
19
|
-
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import path from "node:path"
|
|
2
|
-
import { SCRIPT_EXTENSIONS, SCRIPT_EXTENSIONS_BROAD } from "../asset-spec"
|
|
3
|
-
import { hasErrnoCode, toPosix } from "../common"
|
|
4
|
-
import { buildToolInfo } from "../tool-runner"
|
|
5
|
-
import { extractDescriptionFromComments } from "../metadata"
|
|
6
|
-
import type { AssetTypeHandler, ShowInput } from "../asset-type-handler"
|
|
7
|
-
import type { ShowResponse, LocalSearchHit } from "../stash-types"
|
|
8
|
-
import type { StashEntry } from "../metadata"
|
|
9
|
-
|
|
10
|
-
/** Extensions that buildToolInfo can handle (tool-runner supported) */
|
|
11
|
-
const RUNNABLE_EXTENSIONS = SCRIPT_EXTENSIONS
|
|
12
|
-
|
|
13
|
-
export const scriptHandler: AssetTypeHandler = {
|
|
14
|
-
typeName: "script",
|
|
15
|
-
stashDir: "scripts",
|
|
16
|
-
|
|
17
|
-
isRelevantFile(fileName: string): boolean {
|
|
18
|
-
return SCRIPT_EXTENSIONS_BROAD.has(path.extname(fileName).toLowerCase())
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
-
toCanonicalName(typeRoot: string, filePath: string): string | undefined {
|
|
22
|
-
return toPosix(path.relative(typeRoot, filePath))
|
|
23
|
-
},
|
|
24
|
-
|
|
25
|
-
toAssetPath(typeRoot: string, name: string): string {
|
|
26
|
-
return path.join(typeRoot, name)
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
buildShowResponse(input: ShowInput): ShowResponse {
|
|
30
|
-
const ext = path.extname(input.path).toLowerCase()
|
|
31
|
-
|
|
32
|
-
// For extensions supported by tool-runner, show runCmd
|
|
33
|
-
if (RUNNABLE_EXTENSIONS.has(ext)) {
|
|
34
|
-
const stashDirs = input.stashDirs ?? []
|
|
35
|
-
const assetStashDir = stashDirs.find((d) =>
|
|
36
|
-
path.resolve(input.path).startsWith(path.resolve(d) + path.sep),
|
|
37
|
-
) ?? stashDirs[0]
|
|
38
|
-
|
|
39
|
-
if (assetStashDir) {
|
|
40
|
-
try {
|
|
41
|
-
const toolInfo = buildToolInfo(assetStashDir, input.path)
|
|
42
|
-
return {
|
|
43
|
-
type: "script",
|
|
44
|
-
name: input.name,
|
|
45
|
-
path: input.path,
|
|
46
|
-
runCmd: toolInfo.runCmd,
|
|
47
|
-
kind: toolInfo.kind,
|
|
48
|
-
}
|
|
49
|
-
} catch {
|
|
50
|
-
// Fall through to content display
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// For other extensions or when buildToolInfo fails, show file content
|
|
56
|
-
return {
|
|
57
|
-
type: "script",
|
|
58
|
-
name: input.name,
|
|
59
|
-
path: input.path,
|
|
60
|
-
content: input.content,
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
enrichSearchHit(hit: LocalSearchHit, stashDir: string): void {
|
|
65
|
-
const ext = path.extname(hit.path).toLowerCase()
|
|
66
|
-
if (!RUNNABLE_EXTENSIONS.has(ext)) return
|
|
67
|
-
|
|
68
|
-
try {
|
|
69
|
-
const toolInfo = buildToolInfo(stashDir, hit.path)
|
|
70
|
-
hit.runCmd = toolInfo.runCmd
|
|
71
|
-
hit.kind = toolInfo.kind
|
|
72
|
-
} catch (error: unknown) {
|
|
73
|
-
if (!hasErrnoCode(error, "ENOENT")) throw error
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
defaultUsageGuide: [
|
|
78
|
-
"Use the hit's runCmd for execution when available, or run the script directly with the appropriate interpreter.",
|
|
79
|
-
"Use `akm show <openRef>` to inspect the script before running it.",
|
|
80
|
-
],
|
|
81
|
-
|
|
82
|
-
extractTypeMetadata(entry: StashEntry, file: string, ext: string): void {
|
|
83
|
-
if (ext !== ".md") {
|
|
84
|
-
const commentDesc = extractDescriptionFromComments(file)
|
|
85
|
-
if (commentDesc && !entry.description) {
|
|
86
|
-
entry.description = commentDesc
|
|
87
|
-
entry.source = "comments"
|
|
88
|
-
entry.confidence = 0.7
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import path from "node:path"
|
|
2
|
-
import { toPosix } from "../common"
|
|
3
|
-
import type { AssetTypeHandler, ShowInput } from "../asset-type-handler"
|
|
4
|
-
import type { ShowResponse } from "../stash-types"
|
|
5
|
-
|
|
6
|
-
export const skillHandler: AssetTypeHandler = {
|
|
7
|
-
typeName: "skill",
|
|
8
|
-
stashDir: "skills",
|
|
9
|
-
|
|
10
|
-
isRelevantFile(fileName: string): boolean {
|
|
11
|
-
return fileName === "SKILL.md"
|
|
12
|
-
},
|
|
13
|
-
|
|
14
|
-
toCanonicalName(typeRoot: string, filePath: string): string | undefined {
|
|
15
|
-
const relDir = toPosix(path.dirname(path.relative(typeRoot, filePath)))
|
|
16
|
-
if (!relDir || relDir === ".") return undefined
|
|
17
|
-
return relDir
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
toAssetPath(typeRoot: string, name: string): string {
|
|
21
|
-
return path.join(typeRoot, name, "SKILL.md")
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
buildShowResponse(input: ShowInput): ShowResponse {
|
|
25
|
-
return {
|
|
26
|
-
type: "skill",
|
|
27
|
-
name: input.name,
|
|
28
|
-
path: input.path,
|
|
29
|
-
content: input.content,
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
defaultUsageGuide: [
|
|
34
|
-
"Read and apply the skill instructions as written, then adapt examples to your current repo state and task.",
|
|
35
|
-
"Use `akm show <openRef>` to read the full SKILL.md for required steps and constraints.",
|
|
36
|
-
],
|
|
37
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import path from "node:path"
|
|
2
|
-
import { SCRIPT_EXTENSIONS } from "../asset-spec"
|
|
3
|
-
import { hasErrnoCode, toPosix } from "../common"
|
|
4
|
-
import { buildToolInfo } from "../tool-runner"
|
|
5
|
-
import { extractDescriptionFromComments } from "../metadata"
|
|
6
|
-
import type { AssetTypeHandler, ShowInput } from "../asset-type-handler"
|
|
7
|
-
import type { ShowResponse, LocalSearchHit } from "../stash-types"
|
|
8
|
-
import type { StashEntry } from "../metadata"
|
|
9
|
-
|
|
10
|
-
export const toolHandler: AssetTypeHandler = {
|
|
11
|
-
typeName: "tool",
|
|
12
|
-
stashDir: "tools",
|
|
13
|
-
|
|
14
|
-
isRelevantFile(fileName: string): boolean {
|
|
15
|
-
return SCRIPT_EXTENSIONS.has(path.extname(fileName).toLowerCase())
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
-
toCanonicalName(typeRoot: string, filePath: string): string | undefined {
|
|
19
|
-
return toPosix(path.relative(typeRoot, filePath))
|
|
20
|
-
},
|
|
21
|
-
|
|
22
|
-
toAssetPath(typeRoot: string, name: string): string {
|
|
23
|
-
return path.join(typeRoot, name)
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
buildShowResponse(input: ShowInput): ShowResponse {
|
|
27
|
-
const stashDirs = input.stashDirs ?? []
|
|
28
|
-
const assetStashDir = stashDirs.find((d) =>
|
|
29
|
-
path.resolve(input.path).startsWith(path.resolve(d) + path.sep),
|
|
30
|
-
) ?? stashDirs[0]
|
|
31
|
-
|
|
32
|
-
if (!assetStashDir) {
|
|
33
|
-
return { type: "tool", name: input.name, path: input.path, content: input.content }
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const toolInfo = buildToolInfo(assetStashDir, input.path)
|
|
37
|
-
return {
|
|
38
|
-
type: "tool",
|
|
39
|
-
name: input.name,
|
|
40
|
-
path: input.path,
|
|
41
|
-
runCmd: toolInfo.runCmd,
|
|
42
|
-
kind: toolInfo.kind,
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
|
|
46
|
-
enrichSearchHit(hit: LocalSearchHit, stashDir: string): void {
|
|
47
|
-
try {
|
|
48
|
-
const toolInfo = buildToolInfo(stashDir, hit.path)
|
|
49
|
-
hit.runCmd = toolInfo.runCmd
|
|
50
|
-
hit.kind = toolInfo.kind
|
|
51
|
-
} catch (error: unknown) {
|
|
52
|
-
if (!hasErrnoCode(error, "ENOENT")) throw error
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
defaultUsageGuide: [
|
|
57
|
-
"Use the hit's runCmd for execution so runtime and working directory stay correct.",
|
|
58
|
-
"Use `akm show <openRef>` to inspect the tool before running it.",
|
|
59
|
-
],
|
|
60
|
-
|
|
61
|
-
extractTypeMetadata(entry: StashEntry, file: string, ext: string): void {
|
|
62
|
-
if (SCRIPT_EXTENSIONS.has(ext) && ext !== ".md") {
|
|
63
|
-
const commentDesc = extractDescriptionFromComments(file)
|
|
64
|
-
if (commentDesc && !entry.description) {
|
|
65
|
-
entry.description = commentDesc
|
|
66
|
-
entry.source = "comments"
|
|
67
|
-
entry.confidence = 0.7
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
}
|