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,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
- }
@@ -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
- }