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
@@ -1,50 +0,0 @@
1
- import type { RegistryInstalledEntry } from "./registry-types";
2
- export interface EmbeddingConnectionConfig {
3
- /** Provider name for display/CLI switching (e.g. "openai", "ollama") */
4
- provider?: string;
5
- /** OpenAI-compatible embeddings endpoint (e.g. "http://localhost:11434/v1/embeddings") */
6
- endpoint: string;
7
- /** Model name to use for embeddings (e.g. "nomic-embed-text") */
8
- model: string;
9
- /** Optional output dimension for providers that support it */
10
- dimension?: number;
11
- /** Optional API key for authenticated endpoints */
12
- apiKey?: string;
13
- }
14
- export interface LlmConnectionConfig {
15
- /** Provider name for display/CLI switching (e.g. "openai", "ollama") */
16
- provider?: string;
17
- /** OpenAI-compatible chat completions endpoint (e.g. "http://localhost:11434/v1/chat/completions") */
18
- endpoint: string;
19
- /** Model name to use (e.g. "llama3.2") */
20
- model: string;
21
- /** Optional sampling temperature */
22
- temperature?: number;
23
- /** Optional response token limit */
24
- maxTokens?: number;
25
- /** Optional API key for authenticated endpoints */
26
- apiKey?: string;
27
- }
28
- export interface AgentikitConfig {
29
- /** Whether semantic search is enabled. Default: true */
30
- semanticSearch: boolean;
31
- /** User-mounted read-only stash directories */
32
- mountedStashDirs: string[];
33
- /** OpenAI-compatible embedding endpoint config. If not set, uses local @xenova/transformers */
34
- embedding?: EmbeddingConnectionConfig;
35
- /** OpenAI-compatible LLM endpoint config for metadata generation. If not set, uses heuristic generation */
36
- llm?: LlmConnectionConfig;
37
- /** Installed registry sources and local cache metadata */
38
- registry?: RegistryConfig;
39
- /** Registry index URLs for kit discovery. Default: official agentikit-registry on GitHub */
40
- registryUrls?: string[];
41
- }
42
- export interface RegistryConfig {
43
- installed: RegistryInstalledEntry[];
44
- }
45
- export declare const DEFAULT_CONFIG: AgentikitConfig;
46
- export declare function getConfigDir(env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform): string;
47
- export declare function getConfigPath(): string;
48
- export declare function loadConfig(): AgentikitConfig;
49
- export declare function saveConfig(config: AgentikitConfig): void;
50
- export declare function updateConfig(partial: Partial<AgentikitConfig>): AgentikitConfig;
package/dist/src/db.d.ts DELETED
@@ -1,46 +0,0 @@
1
- import { Database } from "bun:sqlite";
2
- import type { StashEntry } from "./metadata";
3
- import type { EmbeddingVector } from "./embedder";
4
- export interface DbIndexedEntry {
5
- id: number;
6
- entryKey: string;
7
- dirPath: string;
8
- filePath: string;
9
- stashDir: string;
10
- entry: StashEntry;
11
- searchText: string;
12
- }
13
- export interface DbSearchResult {
14
- id: number;
15
- filePath: string;
16
- entry: StashEntry;
17
- searchText: string;
18
- bm25Score: number;
19
- }
20
- export interface DbVecResult {
21
- id: number;
22
- distance: number;
23
- }
24
- export declare const DB_VERSION = 5;
25
- export declare const EMBEDDING_DIM = 384;
26
- export declare function getDbPath(): string;
27
- export declare function openDatabase(dbPath?: string, options?: {
28
- embeddingDim?: number;
29
- }): Database;
30
- export declare function closeDatabase(db: Database): void;
31
- export declare function isVecAvailable(): boolean;
32
- export declare function getMeta(db: Database, key: string): string | undefined;
33
- export declare function setMeta(db: Database, key: string, value: string): void;
34
- export declare function upsertEntry(db: Database, entryKey: string, dirPath: string, filePath: string, stashDir: string, entry: StashEntry, searchText: string): number;
35
- export declare function deleteEntriesByDir(db: Database, dirPath: string): void;
36
- export declare function rebuildFts(db: Database): void;
37
- export declare function upsertEmbedding(db: Database, entryId: number, embedding: EmbeddingVector): void;
38
- export declare function searchVec(db: Database, queryEmbedding: EmbeddingVector, k: number): DbVecResult[];
39
- export declare function searchFts(db: Database, query: string, limit: number, entryType?: string): DbSearchResult[];
40
- export declare function getAllEntries(db: Database, entryType?: string): DbIndexedEntry[];
41
- export declare function getEntryCount(db: Database): number;
42
- export declare function getEntryById(db: Database, id: number): {
43
- filePath: string;
44
- entry: StashEntry;
45
- } | undefined;
46
- export declare function getEntriesByDir(db: Database, dirPath: string): DbIndexedEntry[];
@@ -1,10 +0,0 @@
1
- import type { EmbeddingConnectionConfig } from "./config";
2
- export type EmbeddingVector = number[];
3
- /**
4
- * Generate an embedding for the given text.
5
- * If embeddingConfig is provided, uses the configured OpenAI-compatible endpoint.
6
- * Otherwise falls back to local @xenova/transformers.
7
- */
8
- export declare function embed(text: string, embeddingConfig?: EmbeddingConnectionConfig): Promise<EmbeddingVector>;
9
- export declare function cosineSimilarity(a: EmbeddingVector, b: EmbeddingVector): number;
10
- export declare function isEmbeddingAvailable(embeddingConfig?: EmbeddingConnectionConfig): Promise<boolean>;
@@ -1,30 +0,0 @@
1
- /**
2
- * Shared frontmatter parsing utilities.
3
- *
4
- * Provides a single, canonical YAML-subset frontmatter parser used by both
5
- * the stash open logic and the metadata generator.
6
- */
7
- /**
8
- * Parse YAML-subset frontmatter from a Markdown (or similar) string.
9
- *
10
- * Returns the parsed key-value data and the remaining body content.
11
- */
12
- export declare function parseFrontmatter(raw: string): {
13
- data: Record<string, unknown>;
14
- content: string;
15
- frontmatter: string | null;
16
- bodyStartLine: number;
17
- };
18
- export declare function parseFrontmatterBlock(raw: string): {
19
- frontmatter: string;
20
- content: string;
21
- bodyStartLine: number;
22
- } | null;
23
- /**
24
- * Parse a simple YAML scalar value (string, boolean, or number).
25
- */
26
- export declare function parseYamlScalar(value: string): unknown;
27
- /**
28
- * Coerce an unknown value to a trimmed string, or return undefined if empty/non-string.
29
- */
30
- export declare function toStringOrUndefined(value: unknown): string | undefined;
@@ -1,4 +0,0 @@
1
- export declare const GITHUB_API_BASE = "https://api.github.com";
2
- export declare function githubHeaders(): HeadersInit;
3
- export declare function asRecord(value: unknown): Record<string, unknown>;
4
- export declare function asString(value: unknown): string | undefined;
@@ -1,2 +0,0 @@
1
- import type { AssetTypeHandler } from "../asset-type-handler";
2
- export declare const agentHandler: AssetTypeHandler;
@@ -1,26 +0,0 @@
1
- import { parseFrontmatter, toStringOrUndefined } from "../frontmatter";
2
- import { isMarkdownFile, markdownCanonicalName, markdownAssetPath } from "./markdown-helpers";
3
- export const agentHandler = {
4
- typeName: "agent",
5
- stashDir: "agents",
6
- isRelevantFile: isMarkdownFile,
7
- toCanonicalName: markdownCanonicalName,
8
- toAssetPath: markdownAssetPath,
9
- buildShowResponse(input) {
10
- const parsedMd = parseFrontmatter(input.content);
11
- return {
12
- type: "agent",
13
- name: input.name,
14
- path: input.path,
15
- description: toStringOrUndefined(parsedMd.data.description),
16
- prompt: "Dispatching prompt must include the agent's full prompt content verbatim; summaries are non-compliant. \n\n"
17
- + parsedMd.content,
18
- toolPolicy: parsedMd.data.tools,
19
- modelHint: parsedMd.data.model,
20
- };
21
- },
22
- defaultUsageGuide: [
23
- "Read the .md file and dispatch an agent using the content of the file. Use modelHint/toolPolicy when present to run the agent with compatible settings.",
24
- "Use with `akm show <openRef>` to get the full prompt payload.",
25
- ],
26
- };
@@ -1,2 +0,0 @@
1
- import type { AssetTypeHandler } from "../asset-type-handler";
2
- export declare const commandHandler: AssetTypeHandler;
@@ -1,23 +0,0 @@
1
- import { parseFrontmatter, toStringOrUndefined } from "../frontmatter";
2
- import { isMarkdownFile, markdownCanonicalName, markdownAssetPath } from "./markdown-helpers";
3
- export const commandHandler = {
4
- typeName: "command",
5
- stashDir: "commands",
6
- isRelevantFile: isMarkdownFile,
7
- toCanonicalName: markdownCanonicalName,
8
- toAssetPath: markdownAssetPath,
9
- buildShowResponse(input) {
10
- const parsedMd = parseFrontmatter(input.content);
11
- return {
12
- type: "command",
13
- name: input.name,
14
- path: input.path,
15
- description: toStringOrUndefined(parsedMd.data.description),
16
- template: parsedMd.content,
17
- };
18
- },
19
- defaultUsageGuide: [
20
- "Read the .md file, fill placeholders, and run it in the current repo context.",
21
- "Use `akm show <openRef>` to retrieve the command template body.",
22
- ],
23
- };
@@ -1,6 +0,0 @@
1
- export { toolHandler } from "./tool-handler";
2
- export { skillHandler } from "./skill-handler";
3
- export { commandHandler } from "./command-handler";
4
- export { agentHandler } from "./agent-handler";
5
- export { knowledgeHandler } from "./knowledge-handler";
6
- export { scriptHandler } from "./script-handler";
@@ -1,23 +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
- * Register all built-in asset type handlers.
10
- * This must be called (imported) before any handler lookups.
11
- */
12
- registerAssetType(toolHandler);
13
- registerAssetType(skillHandler);
14
- registerAssetType(commandHandler);
15
- registerAssetType(agentHandler);
16
- registerAssetType(knowledgeHandler);
17
- registerAssetType(scriptHandler);
18
- export { toolHandler } from "./tool-handler";
19
- export { skillHandler } from "./skill-handler";
20
- export { commandHandler } from "./command-handler";
21
- export { agentHandler } from "./agent-handler";
22
- export { knowledgeHandler } from "./knowledge-handler";
23
- export { scriptHandler } from "./script-handler";
@@ -1,2 +0,0 @@
1
- import type { AssetTypeHandler } from "../asset-type-handler";
2
- export declare const knowledgeHandler: AssetTypeHandler;
@@ -1,56 +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
- export const knowledgeHandler = {
5
- typeName: "knowledge",
6
- stashDir: "knowledge",
7
- isRelevantFile: isMarkdownFile,
8
- toCanonicalName: markdownCanonicalName,
9
- toAssetPath: markdownAssetPath,
10
- buildShowResponse(input) {
11
- const v = input.view ?? { mode: "full" };
12
- switch (v.mode) {
13
- case "toc": {
14
- const toc = parseMarkdownToc(input.content);
15
- return { type: "knowledge", name: input.name, path: input.path, content: formatToc(toc) };
16
- }
17
- case "frontmatter": {
18
- const fm = extractFrontmatterOnly(input.content);
19
- return { type: "knowledge", name: input.name, path: input.path, content: fm ?? "(no frontmatter)" };
20
- }
21
- case "section": {
22
- const section = extractSection(input.content, v.heading);
23
- if (!section) {
24
- return {
25
- type: "knowledge",
26
- name: input.name,
27
- path: input.path,
28
- content: `Section "${v.heading}" not found in ${input.name}. Try --view toc to discover available headings.`,
29
- };
30
- }
31
- return { type: "knowledge", name: input.name, path: input.path, content: section.content };
32
- }
33
- case "lines": {
34
- return { type: "knowledge", name: input.name, path: input.path, content: extractLineRange(input.content, v.start, v.end) };
35
- }
36
- default: {
37
- return { type: "knowledge", name: input.name, path: input.path, content: input.content };
38
- }
39
- }
40
- },
41
- defaultUsageGuide: [
42
- "Use `akm show <openRef>` to read the document; start with `--view toc` for large files.",
43
- "Use `--view section` or `--view lines` to load only the part you need.",
44
- ],
45
- extractTypeMetadata(entry, file) {
46
- try {
47
- const mdContent = fs.readFileSync(file, "utf8");
48
- const toc = parseMarkdownToc(mdContent);
49
- if (toc.headings.length > 0)
50
- entry.toc = toc.headings;
51
- }
52
- catch {
53
- // Non-fatal: skip TOC if file can't be read
54
- }
55
- },
56
- };
@@ -1,7 +0,0 @@
1
- /**
2
- * Shared file-system helpers for markdown-based asset types
3
- * (command, agent, knowledge).
4
- */
5
- export declare function isMarkdownFile(fileName: string): boolean;
6
- export declare function markdownCanonicalName(typeRoot: string, filePath: string): string | undefined;
7
- export declare function markdownAssetPath(typeRoot: string, name: string): string;
@@ -1,2 +0,0 @@
1
- import type { AssetTypeHandler } from "../asset-type-handler";
2
- export declare const scriptHandler: AssetTypeHandler;
@@ -1,78 +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
- /** Extensions that buildToolInfo can handle (tool-runner supported) */
7
- const RUNNABLE_EXTENSIONS = SCRIPT_EXTENSIONS;
8
- export const scriptHandler = {
9
- typeName: "script",
10
- stashDir: "scripts",
11
- isRelevantFile(fileName) {
12
- return SCRIPT_EXTENSIONS_BROAD.has(path.extname(fileName).toLowerCase());
13
- },
14
- toCanonicalName(typeRoot, filePath) {
15
- return toPosix(path.relative(typeRoot, filePath));
16
- },
17
- toAssetPath(typeRoot, name) {
18
- return path.join(typeRoot, name);
19
- },
20
- buildShowResponse(input) {
21
- const ext = path.extname(input.path).toLowerCase();
22
- // For extensions supported by tool-runner, show runCmd
23
- if (RUNNABLE_EXTENSIONS.has(ext)) {
24
- const stashDirs = input.stashDirs ?? [];
25
- const assetStashDir = stashDirs.find((d) => path.resolve(input.path).startsWith(path.resolve(d) + path.sep)) ?? stashDirs[0];
26
- if (assetStashDir) {
27
- try {
28
- const toolInfo = buildToolInfo(assetStashDir, input.path);
29
- return {
30
- type: "script",
31
- name: input.name,
32
- path: input.path,
33
- runCmd: toolInfo.runCmd,
34
- kind: toolInfo.kind,
35
- };
36
- }
37
- catch {
38
- // Fall through to content display
39
- }
40
- }
41
- }
42
- // For other extensions or when buildToolInfo fails, show file content
43
- return {
44
- type: "script",
45
- name: input.name,
46
- path: input.path,
47
- content: input.content,
48
- };
49
- },
50
- enrichSearchHit(hit, stashDir) {
51
- const ext = path.extname(hit.path).toLowerCase();
52
- if (!RUNNABLE_EXTENSIONS.has(ext))
53
- return;
54
- try {
55
- const toolInfo = buildToolInfo(stashDir, hit.path);
56
- hit.runCmd = toolInfo.runCmd;
57
- hit.kind = toolInfo.kind;
58
- }
59
- catch (error) {
60
- if (!hasErrnoCode(error, "ENOENT"))
61
- throw error;
62
- }
63
- },
64
- defaultUsageGuide: [
65
- "Use the hit's runCmd for execution when available, or run the script directly with the appropriate interpreter.",
66
- "Use `akm show <openRef>` to inspect the script before running it.",
67
- ],
68
- extractTypeMetadata(entry, file, ext) {
69
- if (ext !== ".md") {
70
- const commentDesc = extractDescriptionFromComments(file);
71
- if (commentDesc && !entry.description) {
72
- entry.description = commentDesc;
73
- entry.source = "comments";
74
- entry.confidence = 0.7;
75
- }
76
- }
77
- },
78
- };
@@ -1,2 +0,0 @@
1
- import type { AssetTypeHandler } from "../asset-type-handler";
2
- export declare const skillHandler: AssetTypeHandler;
@@ -1,2 +0,0 @@
1
- import type { AssetTypeHandler } from "../asset-type-handler";
2
- export declare const toolHandler: AssetTypeHandler;
@@ -1,22 +0,0 @@
1
- import { type StashEntry } from "./metadata";
2
- export interface IndexResponse {
3
- stashDir: string;
4
- totalEntries: number;
5
- generatedMetadata: number;
6
- indexPath: string;
7
- mode: "full" | "incremental";
8
- directoriesScanned: number;
9
- directoriesSkipped: number;
10
- /** Timing counters in milliseconds */
11
- timing?: {
12
- totalMs: number;
13
- walkMs: number;
14
- embedMs: number;
15
- ftsMs: number;
16
- };
17
- }
18
- export declare function agentikitIndex(options?: {
19
- stashDir?: string;
20
- full?: boolean;
21
- }): Promise<IndexResponse>;
22
- export declare function buildSearchText(entry: StashEntry): string;
@@ -1,19 +0,0 @@
1
- /**
2
- * Agentikit initialization logic.
3
- *
4
- * Creates the working stash directory structure, sets the AKM_STASH_DIR
5
- * environment variable, and ensures ripgrep is available.
6
- */
7
- export interface InitResponse {
8
- stashDir: string;
9
- created: boolean;
10
- envSet: boolean;
11
- profileUpdated?: string;
12
- configPath: string;
13
- ripgrep?: {
14
- rgPath: string;
15
- installed: boolean;
16
- version: string;
17
- };
18
- }
19
- export declare function agentikitInit(): Promise<InitResponse>;
package/dist/src/init.js DELETED
@@ -1,99 +0,0 @@
1
- /**
2
- * Agentikit initialization logic.
3
- *
4
- * Creates the working stash directory structure, sets the AKM_STASH_DIR
5
- * environment variable, and ensures ripgrep is available.
6
- */
7
- import { spawnSync } from "node:child_process";
8
- import fs from "node:fs";
9
- import path from "node:path";
10
- import { IS_WINDOWS, TYPE_DIRS } from "./common";
11
- import { ensureRg } from "./ripgrep-install";
12
- import { getConfigPath, saveConfig, DEFAULT_CONFIG } from "./config";
13
- export async function agentikitInit() {
14
- let stashDir;
15
- if (IS_WINDOWS) {
16
- const userProfile = process.env.USERPROFILE?.trim();
17
- if (!userProfile) {
18
- throw new Error("Unable to determine Documents folder. Ensure USERPROFILE is set.");
19
- }
20
- const docs = path.join(userProfile, "Documents");
21
- stashDir = path.join(docs, "agentikit");
22
- }
23
- else {
24
- const home = process.env.HOME?.trim();
25
- if (!home) {
26
- throw new Error("Unable to determine home directory. Set HOME.");
27
- }
28
- stashDir = path.join(home, "agentikit");
29
- }
30
- let created = false;
31
- if (!fs.existsSync(stashDir)) {
32
- fs.mkdirSync(stashDir, { recursive: true });
33
- created = true;
34
- }
35
- for (const sub of Object.values(TYPE_DIRS)) {
36
- const subDir = path.join(stashDir, sub);
37
- if (!fs.existsSync(subDir)) {
38
- fs.mkdirSync(subDir, { recursive: true });
39
- }
40
- }
41
- let envSet = false;
42
- let profileUpdated;
43
- if (IS_WINDOWS) {
44
- const result = spawnSync("setx", ["AKM_STASH_DIR", stashDir], {
45
- encoding: "utf8",
46
- timeout: 10_000,
47
- });
48
- envSet = result.status === 0;
49
- }
50
- else {
51
- const shell = process.env.SHELL || "";
52
- const homeDir = process.env.HOME; // already validated non-empty above
53
- let profile;
54
- if (shell.endsWith("/zsh")) {
55
- profile = path.join(homeDir, ".zshrc");
56
- }
57
- else if (shell.endsWith("/bash")) {
58
- profile = path.join(homeDir, ".bashrc");
59
- }
60
- else {
61
- profile = path.join(homeDir, ".profile");
62
- }
63
- const exportLine = `export AKM_STASH_DIR="${stashDir}"`;
64
- const existing = fs.existsSync(profile) ? fs.readFileSync(profile, "utf8") : "";
65
- if (!existing.includes("AKM_STASH_DIR")) {
66
- const updated = existing + `\n# Agentikit working stash directory\n${exportLine}\n`;
67
- const tmpPath = profile + `.tmp.${process.pid}`;
68
- try {
69
- fs.writeFileSync(tmpPath, updated, "utf8");
70
- fs.renameSync(tmpPath, profile);
71
- }
72
- catch (err) {
73
- try {
74
- fs.unlinkSync(tmpPath);
75
- }
76
- catch { /* ignore */ }
77
- throw err;
78
- }
79
- envSet = true;
80
- profileUpdated = profile;
81
- }
82
- }
83
- // Create default config.json if it doesn't exist
84
- const configPath = getConfigPath();
85
- if (!fs.existsSync(configPath)) {
86
- saveConfig(DEFAULT_CONFIG);
87
- }
88
- process.env.AKM_STASH_DIR = stashDir;
89
- // Ensure ripgrep is available (install to stash/bin if needed)
90
- let ripgrep;
91
- try {
92
- const rgResult = ensureRg(stashDir);
93
- ripgrep = rgResult;
94
- }
95
- catch {
96
- // Non-fatal: ripgrep is optional, search works without it
97
- }
98
- return { stashDir, created, envSet, profileUpdated, configPath, ripgrep };
99
- }
package/dist/src/llm.d.ts DELETED
@@ -1,15 +0,0 @@
1
- import type { LlmConnectionConfig } from "./config";
2
- import type { StashEntry } from "./metadata";
3
- /**
4
- * Use an LLM to enhance a stash entry's metadata: improve description,
5
- * generate intents, and suggest tags.
6
- */
7
- export declare function enhanceMetadata(config: LlmConnectionConfig, entry: StashEntry, fileContent?: string): Promise<{
8
- description?: string;
9
- intents?: string[];
10
- tags?: string[];
11
- }>;
12
- /**
13
- * Check if the LLM endpoint is reachable.
14
- */
15
- export declare function isLlmAvailable(config: LlmConnectionConfig): Promise<boolean>;
@@ -1,18 +0,0 @@
1
- export interface TocHeading {
2
- level: number;
3
- text: string;
4
- line: number;
5
- }
6
- export interface KnowledgeToc {
7
- headings: TocHeading[];
8
- totalLines: number;
9
- }
10
- export declare function parseMarkdownToc(content: string): KnowledgeToc;
11
- export declare function extractSection(content: string, heading: string): {
12
- content: string;
13
- startLine: number;
14
- endLine: number;
15
- } | null;
16
- export declare function extractLineRange(content: string, start: number, end: number): string;
17
- export declare function extractFrontmatterOnly(content: string): string | null;
18
- export declare function formatToc(toc: KnowledgeToc): string;
@@ -1,41 +0,0 @@
1
- import { type AgentikitAssetType } from "./common";
2
- import { type TocHeading } from "./markdown";
3
- export interface StashIntent {
4
- when?: string;
5
- input?: string;
6
- output?: string;
7
- }
8
- export interface StashEntry {
9
- name: string;
10
- type: AgentikitAssetType;
11
- description?: string;
12
- tags?: string[];
13
- examples?: string[];
14
- intents?: string[];
15
- intent?: StashIntent;
16
- entry?: string;
17
- generated?: boolean;
18
- quality?: "generated" | "curated";
19
- confidence?: number;
20
- source?: "package" | "frontmatter" | "comments" | "filename" | "manual" | "llm";
21
- aliases?: string[];
22
- toc?: TocHeading[];
23
- usage?: string[];
24
- }
25
- export interface StashFile {
26
- entries: StashEntry[];
27
- }
28
- export declare function stashFilePath(dirPath: string): string;
29
- export declare function loadStashFile(dirPath: string): StashFile | null;
30
- export declare function writeStashFile(dirPath: string, stash: StashFile): void;
31
- export declare function validateStashEntry(entry: unknown): StashEntry | null;
32
- export declare function generateMetadata(dirPath: string, assetType: AgentikitAssetType, files: string[], typeRoot?: string): StashFile;
33
- export declare function extractDescriptionFromComments(filePath: string): string | null;
34
- export declare function extractFrontmatterDescription(filePath: string): string | null;
35
- export declare function extractPackageMetadata(dirPath: string): {
36
- name?: string;
37
- description?: string;
38
- keywords?: string[];
39
- } | null;
40
- export declare function fileNameToDescription(fileName: string): string;
41
- export declare function extractTagsFromPath(filePath: string, rootDir: string): string[];
@@ -1,19 +0,0 @@
1
- import type { StashSource } from "./stash-source";
2
- /**
3
- * Given an origin string (from an AssetRef) and the full list of stash
4
- * sources, return the subset of sources to search.
5
- *
6
- * Resolution order:
7
- * 1. undefined → all sources (working → mounted → installed)
8
- * 2. "local" → working stash only
9
- * 3. exact match → installed source whose registryId matches verbatim
10
- * 4. parsed match → parse origin as a registry ref, match by parsed ID
11
- * 5. path match → mounted source whose path matches
12
- * 6. empty → indicates a remote/uninstalled origin (caller decides)
13
- */
14
- export declare function resolveSourcesForOrigin(origin: string | undefined, allSources: StashSource[]): StashSource[];
15
- /**
16
- * Check whether an origin refers to something that could be fetched remotely
17
- * (i.e. it looks like a registry ref but isn't installed locally).
18
- */
19
- export declare function isRemoteOrigin(origin: string, allSources: StashSource[]): boolean;
@@ -1,11 +0,0 @@
1
- import { type AgentikitConfig } from "./config";
2
- import type { RegistryInstallResult, RegistryInstalledEntry } from "./registry-types";
3
- export interface InstallRegistryRefOptions {
4
- cacheRootDir?: string;
5
- now?: Date;
6
- }
7
- export declare function installRegistryRef(ref: string, options?: InstallRegistryRefOptions): Promise<RegistryInstallResult>;
8
- export declare function upsertInstalledRegistryEntry(entry: RegistryInstalledEntry): AgentikitConfig;
9
- export declare function removeInstalledRegistryEntry(id: string): AgentikitConfig;
10
- export declare function getRegistryCacheRootDir(): string;
11
- export declare function detectStashRoot(extractedDir: string): string;
@@ -1,3 +0,0 @@
1
- import type { ParsedRegistryRef, ResolvedRegistryArtifact } from "./registry-types";
2
- export declare function parseRegistryRef(rawRef: string): ParsedRegistryRef;
3
- export declare function resolveRegistryArtifact(parsed: ParsedRegistryRef): Promise<ResolvedRegistryArtifact>;