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,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,2 +0,0 @@
1
- import type { AssetTypeHandler } from "../asset-type-handler";
2
- export declare const commandHandler: AssetTypeHandler;
@@ -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,2 +0,0 @@
1
- import type { AssetTypeHandler } from "../asset-type-handler";
2
- export declare const knowledgeHandler: AssetTypeHandler;
@@ -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,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>;
@@ -1,27 +0,0 @@
1
- import type { RegistrySearchResponse } from "./registry-types";
2
- export interface RegistryIndex {
3
- version: number;
4
- updatedAt: string;
5
- kits: RegistryKitEntry[];
6
- }
7
- export interface RegistryKitEntry {
8
- id: string;
9
- name: string;
10
- description?: string;
11
- ref: string;
12
- source: "npm" | "github" | "git";
13
- homepage?: string;
14
- tags?: string[];
15
- assetTypes?: string[];
16
- author?: string;
17
- license?: string;
18
- latestVersion?: string;
19
- /** Whether this entry was manually reviewed and approved */
20
- curated?: boolean;
21
- }
22
- export interface RegistrySearchOptions {
23
- limit?: number;
24
- /** Override registry URL(s). Accepts a single URL or an array. */
25
- registryUrls?: string | string[];
26
- }
27
- export declare function searchRegistry(query: string, options?: RegistrySearchOptions): Promise<RegistrySearchResponse>;
@@ -1,62 +0,0 @@
1
- export type RegistrySource = "npm" | "github" | "git";
2
- export interface RegistryRefBase {
3
- source: RegistrySource;
4
- ref: string;
5
- id: string;
6
- }
7
- export interface ParsedNpmRef extends RegistryRefBase {
8
- source: "npm";
9
- packageName: string;
10
- requestedVersionOrTag?: string;
11
- }
12
- export interface ParsedGithubRef extends RegistryRefBase {
13
- source: "github";
14
- owner: string;
15
- repo: string;
16
- requestedRef?: string;
17
- }
18
- export interface ParsedGitRef extends RegistryRefBase {
19
- source: "git";
20
- repoRoot: string;
21
- sourcePath: string;
22
- }
23
- export type ParsedRegistryRef = ParsedNpmRef | ParsedGithubRef | ParsedGitRef;
24
- export interface ResolvedRegistryArtifact {
25
- id: string;
26
- source: RegistrySource;
27
- ref: string;
28
- artifactUrl: string;
29
- resolvedVersion?: string;
30
- resolvedRevision?: string;
31
- }
32
- export interface RegistryInstalledEntry {
33
- id: string;
34
- source: RegistrySource;
35
- ref: string;
36
- resolvedVersion?: string;
37
- resolvedRevision?: string;
38
- artifactUrl: string;
39
- stashRoot: string;
40
- cacheDir: string;
41
- installedAt: string;
42
- }
43
- export interface RegistryInstallResult extends RegistryInstalledEntry {
44
- extractedDir: string;
45
- }
46
- export interface RegistrySearchHit {
47
- source: RegistrySource;
48
- id: string;
49
- title: string;
50
- description?: string;
51
- ref: string;
52
- homepage?: string;
53
- score?: number;
54
- metadata?: Record<string, string>;
55
- /** Whether this entry was manually reviewed and approved */
56
- curated?: boolean;
57
- }
58
- export interface RegistrySearchResponse {
59
- query: string;
60
- hits: RegistrySearchHit[];
61
- warnings: string[];
62
- }
@@ -1,12 +0,0 @@
1
- export interface EnsureRgResult {
2
- rgPath: string;
3
- installed: boolean;
4
- version: string;
5
- }
6
- /**
7
- * Ensure ripgrep is available. If not found on PATH or in stash/bin,
8
- * download and install it to stash/bin.
9
- *
10
- * Returns the path to the ripgrep binary and whether it was newly installed.
11
- */
12
- export declare function ensureRg(stashDir: string): EnsureRgResult;
@@ -1,13 +0,0 @@
1
- export declare const RG_BINARY: string;
2
- /**
3
- * Resolve the path to a usable ripgrep binary.
4
- * Checks in order:
5
- * 1. stashDir/bin/rg
6
- * 2. system PATH (rg)
7
- * Returns null if ripgrep is not available.
8
- */
9
- export declare function resolveRg(stashDir?: string): string | null;
10
- /**
11
- * Check if ripgrep is available (either in stash/bin or system PATH).
12
- */
13
- export declare function isRgAvailable(stashDir?: string): boolean;
@@ -1,3 +0,0 @@
1
- export { resolveRg, isRgAvailable } from "./ripgrep-resolve";
2
- export { ensureRg } from "./ripgrep-install";
3
- export type { EnsureRgResult } from "./ripgrep-install";
@@ -1,4 +0,0 @@
1
- import type { AddResponse } from "./stash-types";
2
- export declare function agentikitAdd(input: {
3
- ref: string;
4
- }): Promise<AddResponse>;
@@ -1,22 +0,0 @@
1
- import { type StashSourceKind } from "./stash-source";
2
- export interface CloneOptions {
3
- /** Source ref (e.g., npm:@scope/pkg//tool:deploy.sh) */
4
- sourceRef: string;
5
- /** Optional new name for the cloned asset */
6
- newName?: string;
7
- /** If true, overwrite existing asset in working stash */
8
- force?: boolean;
9
- }
10
- export interface CloneResponse {
11
- source: {
12
- path: string;
13
- sourceKind: StashSourceKind;
14
- registryId?: string;
15
- };
16
- destination: {
17
- path: string;
18
- ref: string;
19
- };
20
- overwritten: boolean;
21
- }
22
- export declare function agentikitClone(options: CloneOptions): Promise<CloneResponse>;
@@ -1,83 +0,0 @@
1
- import fs from "node:fs";
2
- import path from "node:path";
3
- import { TYPE_DIRS } from "./asset-spec";
4
- import { parseAssetRef, makeAssetRef } from "./stash-ref";
5
- import { resolveSourcesForOrigin } from "./origin-resolve";
6
- import { resolveAssetPath } from "./stash-resolve";
7
- import { resolveStashSources, findSourceForPath } from "./stash-source";
8
- export async function agentikitClone(options) {
9
- const parsed = parseAssetRef(options.sourceRef);
10
- const allSources = resolveStashSources();
11
- const workingSource = allSources.find((s) => s.kind === "working");
12
- if (!workingSource) {
13
- throw new Error("No working stash configured. Run `akm init` first.");
14
- }
15
- const searchSources = resolveSourcesForOrigin(parsed.origin, allSources);
16
- let sourcePath;
17
- let lastError;
18
- for (const source of searchSources) {
19
- try {
20
- sourcePath = resolveAssetPath(source.path, parsed.type, parsed.name);
21
- break;
22
- }
23
- catch (err) {
24
- lastError = err instanceof Error ? err : new Error(String(err));
25
- }
26
- }
27
- if (!sourcePath) {
28
- throw lastError ?? new Error(`Source asset not found for ref: ${options.sourceRef}`);
29
- }
30
- const sourceSource = findSourceForPath(sourcePath, allSources);
31
- const sourceKind = sourceSource?.kind ?? "working";
32
- const destName = options.newName ?? parsed.name;
33
- const typeDir = TYPE_DIRS[parsed.type];
34
- const workingDir = workingSource.path;
35
- // Guard against self-clone
36
- if (parsed.type === "skill") {
37
- const sourceSkillDir = path.resolve(path.dirname(sourcePath));
38
- const destSkillDir = path.resolve(path.join(workingDir, typeDir, destName));
39
- if (sourceSkillDir === destSkillDir) {
40
- throw new Error(`Source and destination are the same path. Use --name to provide a new name for the clone.`);
41
- }
42
- }
43
- else {
44
- const resolvedSource = path.resolve(sourcePath);
45
- const resolvedDest = path.resolve(path.join(workingDir, typeDir, destName));
46
- if (resolvedSource === resolvedDest) {
47
- throw new Error(`Source and destination are the same path. Use --name to provide a new name for the clone.`);
48
- }
49
- }
50
- let destPath;
51
- if (parsed.type === "skill") {
52
- const sourceSkillDir = path.dirname(sourcePath);
53
- const destSkillDir = path.join(workingDir, typeDir, destName);
54
- const overwritten = fs.existsSync(destSkillDir);
55
- if (overwritten && !options.force) {
56
- throw new Error(`Asset already exists in working stash: ${destSkillDir}. Use --force to overwrite.`);
57
- }
58
- if (overwritten) {
59
- fs.rmSync(destSkillDir, { recursive: true, force: true });
60
- }
61
- fs.cpSync(sourceSkillDir, destSkillDir, { recursive: true });
62
- destPath = path.join(destSkillDir, "SKILL.md");
63
- const ref = makeAssetRef(parsed.type, destName, "local");
64
- return {
65
- source: { path: sourcePath, sourceKind, registryId: sourceSource?.registryId },
66
- destination: { path: destPath, ref },
67
- overwritten,
68
- };
69
- }
70
- destPath = path.join(workingDir, typeDir, destName);
71
- const overwritten = fs.existsSync(destPath);
72
- if (overwritten && !options.force) {
73
- throw new Error(`Asset already exists in working stash: ${destPath}. Use --force to overwrite.`);
74
- }
75
- fs.mkdirSync(path.dirname(destPath), { recursive: true });
76
- fs.copyFileSync(sourcePath, destPath);
77
- const ref = makeAssetRef(parsed.type, destName, "local");
78
- return {
79
- source: { path: sourcePath, sourceKind, registryId: sourceSource?.registryId },
80
- destination: { path: destPath, ref },
81
- overwritten,
82
- };
83
- }
@@ -1,31 +0,0 @@
1
- import { type AgentikitAssetType } from "./common";
2
- export interface AssetRef {
3
- type: AgentikitAssetType;
4
- name: string;
5
- /**
6
- * Where to find this asset.
7
- * - undefined: search all sources (working → mounted → installed)
8
- * - "local": working stash only
9
- * - registry ref: e.g. "npm:@scope/pkg", "owner/repo", "github:owner/repo#v1"
10
- * - filesystem path: e.g. "/mnt/shared-stash"
11
- */
12
- origin?: string;
13
- }
14
- /**
15
- * Build a ref string from components.
16
- *
17
- * Examples:
18
- * makeAssetRef("tool", "deploy.sh")
19
- * → "tool:deploy.sh"
20
- * makeAssetRef("tool", "deploy.sh", "npm:@scope/pkg")
21
- * → "npm:@scope/pkg//tool:deploy.sh"
22
- * makeAssetRef("skill", "code-review", "local")
23
- * → "local//skill:code-review"
24
- * makeAssetRef("tool", "db/migrate/run.sh", "owner/repo")
25
- * → "owner/repo//tool:db/migrate/run.sh"
26
- */
27
- export declare function makeAssetRef(type: AgentikitAssetType, name: string, origin?: string): string;
28
- /**
29
- * Parse a ref string in the format `[origin//]type:name`.
30
- */
31
- export declare function parseAssetRef(ref: string): AssetRef;
@@ -1,18 +0,0 @@
1
- import type { ListResponse, RemoveResponse, ReinstallResponse, UpdateResponse } from "./stash-types";
2
- export declare function agentikitList(input?: {
3
- stashDir?: string;
4
- }): Promise<ListResponse>;
5
- export declare function agentikitRemove(input: {
6
- target: string;
7
- stashDir?: string;
8
- }): Promise<RemoveResponse>;
9
- export declare function agentikitReinstall(input?: {
10
- target?: string;
11
- all?: boolean;
12
- stashDir?: string;
13
- }): Promise<ReinstallResponse>;
14
- export declare function agentikitUpdate(input?: {
15
- target?: string;
16
- all?: boolean;
17
- stashDir?: string;
18
- }): Promise<UpdateResponse>;
@@ -1,2 +0,0 @@
1
- import { type AgentikitAssetType } from "./common";
2
- export declare function resolveAssetPath(stashDir: string, type: AgentikitAssetType, name: string): string;
@@ -1,8 +0,0 @@
1
- import type { AgentikitSearchType, SearchResponse, SearchSource, SearchUsageMode } from "./stash-types";
2
- export declare function agentikitSearch(input: {
3
- query: string;
4
- type?: AgentikitSearchType;
5
- limit?: number;
6
- usage?: SearchUsageMode;
7
- source?: SearchSource;
8
- }): Promise<SearchResponse>;
@@ -1,5 +0,0 @@
1
- import type { KnowledgeView, ShowResponse } from "./stash-types";
2
- export declare function agentikitShow(input: {
3
- ref: string;
4
- view?: KnowledgeView;
5
- }): Promise<ShowResponse>;