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