agentikit 0.0.7 → 0.0.8
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/README.md +113 -77
- package/dist/index.d.ts +13 -3
- package/dist/index.js +7 -2
- package/dist/src/asset-spec.d.ts +14 -0
- package/dist/src/asset-spec.js +46 -0
- package/dist/src/cli.js +154 -52
- package/dist/src/common.d.ts +8 -0
- package/dist/src/common.js +46 -0
- package/dist/src/config.d.ts +31 -0
- package/dist/src/config.js +74 -0
- package/dist/src/embedder.d.ts +10 -0
- package/dist/src/embedder.js +87 -0
- package/dist/src/frontmatter.d.ts +30 -0
- package/dist/src/frontmatter.js +86 -0
- package/dist/src/indexer.d.ts +20 -2
- package/dist/src/indexer.js +212 -80
- package/dist/src/init.d.ts +19 -0
- package/dist/src/init.js +87 -0
- package/dist/src/llm.d.ts +15 -0
- package/dist/src/llm.js +91 -0
- package/dist/src/markdown.d.ts +18 -0
- package/dist/src/markdown.js +77 -0
- package/dist/src/metadata.d.ts +10 -2
- package/dist/src/metadata.js +146 -30
- package/dist/src/ripgrep-install.d.ts +12 -0
- package/dist/src/ripgrep-install.js +169 -0
- package/dist/src/ripgrep-resolve.d.ts +13 -0
- package/dist/src/ripgrep-resolve.js +68 -0
- package/dist/src/ripgrep.d.ts +3 -36
- package/dist/src/ripgrep.js +2 -262
- package/dist/src/similarity.d.ts +1 -2
- package/dist/src/similarity.js +11 -0
- package/dist/src/stash-ref.d.ts +7 -0
- package/dist/src/stash-ref.js +33 -0
- package/dist/src/stash-resolve.d.ts +2 -0
- package/dist/src/stash-resolve.js +45 -0
- package/dist/src/stash-search.d.ts +6 -0
- package/dist/src/stash-search.js +269 -0
- package/dist/src/stash-show.d.ts +5 -0
- package/dist/src/stash-show.js +107 -0
- package/dist/src/stash-types.d.ts +53 -0
- package/dist/src/stash-types.js +1 -0
- package/dist/src/stash.d.ts +8 -63
- package/dist/src/stash.js +4 -633
- package/dist/src/tool-runner.d.ts +35 -0
- package/dist/src/tool-runner.js +100 -0
- package/dist/src/walker.d.ts +19 -0
- package/dist/src/walker.js +47 -0
- package/package.json +8 -14
- package/src/asset-spec.ts +69 -0
- package/src/cli.ts +164 -48
- package/src/common.ts +58 -0
- package/src/config.ts +124 -0
- package/src/embedder.ts +117 -0
- package/src/frontmatter.ts +95 -0
- package/src/indexer.ts +244 -84
- package/src/init.ts +106 -0
- package/src/llm.ts +124 -0
- package/src/markdown.ts +106 -0
- package/src/metadata.ts +157 -29
- package/src/ripgrep-install.ts +200 -0
- package/src/ripgrep-resolve.ts +72 -0
- package/src/ripgrep.ts +3 -315
- package/src/similarity.ts +13 -1
- package/src/stash-ref.ts +41 -0
- package/src/stash-resolve.ts +47 -0
- package/src/stash-search.ts +343 -0
- package/src/stash-show.ts +104 -0
- package/src/stash-types.ts +46 -0
- package/src/stash.ts +16 -760
- package/src/tool-runner.ts +129 -0
- package/src/walker.ts +53 -0
- package/.claude-plugin/plugin.json +0 -21
- package/commands/open.md +0 -11
- package/commands/run.md +0 -11
- package/commands/search.md +0 -11
- package/dist/src/plugin.d.ts +0 -2
- package/dist/src/plugin.js +0 -55
- package/skills/stash/SKILL.md +0 -73
- package/src/plugin.ts +0 -56
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { parseFrontmatter, toStringOrUndefined } from "./frontmatter";
|
|
4
|
+
import { resolveStashDir } from "./common";
|
|
5
|
+
import { parseOpenRef } from "./stash-ref";
|
|
6
|
+
import { resolveAssetPath } from "./stash-resolve";
|
|
7
|
+
import { parseMarkdownToc, extractSection, extractLineRange, extractFrontmatterOnly, formatToc } from "./markdown";
|
|
8
|
+
import { buildToolInfo } from "./tool-runner";
|
|
9
|
+
import { loadConfig } from "./config";
|
|
10
|
+
export function agentikitShow(input) {
|
|
11
|
+
const parsed = parseOpenRef(input.ref);
|
|
12
|
+
const stashDir = resolveStashDir();
|
|
13
|
+
const config = loadConfig(stashDir);
|
|
14
|
+
const allStashDirs = [
|
|
15
|
+
stashDir,
|
|
16
|
+
...config.additionalStashDirs.filter((d) => {
|
|
17
|
+
try {
|
|
18
|
+
return fs.statSync(d).isDirectory();
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
}),
|
|
24
|
+
];
|
|
25
|
+
let assetPath;
|
|
26
|
+
let lastError;
|
|
27
|
+
for (const dir of allStashDirs) {
|
|
28
|
+
try {
|
|
29
|
+
assetPath = resolveAssetPath(dir, parsed.type, parsed.name);
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
catch (err) {
|
|
33
|
+
lastError = err instanceof Error ? err : new Error(String(err));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (!assetPath) {
|
|
37
|
+
throw lastError ?? new Error(`Stash asset not found for ref: ${parsed.type}:${parsed.name}`);
|
|
38
|
+
}
|
|
39
|
+
const content = fs.readFileSync(assetPath, "utf8");
|
|
40
|
+
switch (parsed.type) {
|
|
41
|
+
case "skill":
|
|
42
|
+
return {
|
|
43
|
+
type: "skill",
|
|
44
|
+
name: parsed.name,
|
|
45
|
+
path: assetPath,
|
|
46
|
+
content,
|
|
47
|
+
};
|
|
48
|
+
case "command": {
|
|
49
|
+
const parsedMd = parseFrontmatter(content);
|
|
50
|
+
return {
|
|
51
|
+
type: "command",
|
|
52
|
+
name: parsed.name,
|
|
53
|
+
path: assetPath,
|
|
54
|
+
description: toStringOrUndefined(parsedMd.data.description),
|
|
55
|
+
template: parsedMd.content,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
case "agent": {
|
|
59
|
+
const parsedMd = parseFrontmatter(content);
|
|
60
|
+
return {
|
|
61
|
+
type: "agent",
|
|
62
|
+
name: parsed.name,
|
|
63
|
+
path: assetPath,
|
|
64
|
+
description: toStringOrUndefined(parsedMd.data.description),
|
|
65
|
+
prompt: parsedMd.content,
|
|
66
|
+
toolPolicy: parsedMd.data.tools,
|
|
67
|
+
modelHint: parsedMd.data.model,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
case "tool": {
|
|
71
|
+
const assetStashDir = allStashDirs.find((d) => path.resolve(assetPath).startsWith(path.resolve(d) + path.sep)) ?? stashDir;
|
|
72
|
+
const toolInfo = buildToolInfo(assetStashDir, assetPath);
|
|
73
|
+
return {
|
|
74
|
+
type: "tool",
|
|
75
|
+
name: parsed.name,
|
|
76
|
+
path: assetPath,
|
|
77
|
+
runCmd: toolInfo.runCmd,
|
|
78
|
+
kind: toolInfo.kind,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
case "knowledge": {
|
|
82
|
+
const v = input.view ?? { mode: "full" };
|
|
83
|
+
switch (v.mode) {
|
|
84
|
+
case "toc": {
|
|
85
|
+
const toc = parseMarkdownToc(content);
|
|
86
|
+
return { type: "knowledge", name: parsed.name, path: assetPath, content: formatToc(toc) };
|
|
87
|
+
}
|
|
88
|
+
case "frontmatter": {
|
|
89
|
+
const fm = extractFrontmatterOnly(content);
|
|
90
|
+
return { type: "knowledge", name: parsed.name, path: assetPath, content: fm ?? "(no frontmatter)" };
|
|
91
|
+
}
|
|
92
|
+
case "section": {
|
|
93
|
+
const section = extractSection(content, v.heading);
|
|
94
|
+
if (!section)
|
|
95
|
+
throw new Error(`Section "${v.heading}" not found in ${parsed.name}`);
|
|
96
|
+
return { type: "knowledge", name: parsed.name, path: assetPath, content: section.content };
|
|
97
|
+
}
|
|
98
|
+
case "lines": {
|
|
99
|
+
return { type: "knowledge", name: parsed.name, path: assetPath, content: extractLineRange(content, v.start, v.end) };
|
|
100
|
+
}
|
|
101
|
+
default: {
|
|
102
|
+
return { type: "knowledge", name: parsed.name, path: assetPath, content };
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { AgentikitAssetType } from "./common";
|
|
2
|
+
import type { ToolKind } from "./tool-runner";
|
|
3
|
+
export type AgentikitSearchType = AgentikitAssetType | "any";
|
|
4
|
+
export interface SearchHit {
|
|
5
|
+
type: AgentikitAssetType;
|
|
6
|
+
name: string;
|
|
7
|
+
path: string;
|
|
8
|
+
openRef: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
tags?: string[];
|
|
11
|
+
score?: number;
|
|
12
|
+
whyMatched?: string[];
|
|
13
|
+
runCmd?: string;
|
|
14
|
+
kind?: ToolKind;
|
|
15
|
+
}
|
|
16
|
+
export interface SearchResponse {
|
|
17
|
+
stashDir: string;
|
|
18
|
+
hits: SearchHit[];
|
|
19
|
+
tip?: string;
|
|
20
|
+
/** Timing counters in milliseconds */
|
|
21
|
+
timing?: {
|
|
22
|
+
totalMs: number;
|
|
23
|
+
rankMs?: number;
|
|
24
|
+
embedMs?: number;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export interface ShowResponse {
|
|
28
|
+
type: AgentikitAssetType;
|
|
29
|
+
name: string;
|
|
30
|
+
path: string;
|
|
31
|
+
content?: string;
|
|
32
|
+
template?: string;
|
|
33
|
+
prompt?: string;
|
|
34
|
+
description?: string;
|
|
35
|
+
toolPolicy?: unknown;
|
|
36
|
+
modelHint?: unknown;
|
|
37
|
+
runCmd?: string;
|
|
38
|
+
kind?: ToolKind;
|
|
39
|
+
}
|
|
40
|
+
export type KnowledgeView = {
|
|
41
|
+
mode: "full";
|
|
42
|
+
} | {
|
|
43
|
+
mode: "toc";
|
|
44
|
+
} | {
|
|
45
|
+
mode: "frontmatter";
|
|
46
|
+
} | {
|
|
47
|
+
mode: "section";
|
|
48
|
+
heading: string;
|
|
49
|
+
} | {
|
|
50
|
+
mode: "lines";
|
|
51
|
+
start: number;
|
|
52
|
+
end: number;
|
|
53
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/src/stash.d.ts
CHANGED
|
@@ -1,63 +1,8 @@
|
|
|
1
|
-
export type AgentikitAssetType
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
description?: string;
|
|
10
|
-
tags?: string[];
|
|
11
|
-
score?: number;
|
|
12
|
-
runCmd?: string;
|
|
13
|
-
kind?: "bash" | "bun" | "powershell" | "cmd";
|
|
14
|
-
}
|
|
15
|
-
export interface SearchResponse {
|
|
16
|
-
stashDir: string;
|
|
17
|
-
hits: SearchHit[];
|
|
18
|
-
tip?: string;
|
|
19
|
-
}
|
|
20
|
-
export interface OpenResponse {
|
|
21
|
-
type: AgentikitAssetType;
|
|
22
|
-
name: string;
|
|
23
|
-
path: string;
|
|
24
|
-
content?: string;
|
|
25
|
-
template?: string;
|
|
26
|
-
prompt?: string;
|
|
27
|
-
description?: string;
|
|
28
|
-
toolPolicy?: unknown;
|
|
29
|
-
modelHint?: unknown;
|
|
30
|
-
runCmd?: string;
|
|
31
|
-
kind?: "bash" | "bun" | "powershell" | "cmd";
|
|
32
|
-
}
|
|
33
|
-
export interface RunResponse {
|
|
34
|
-
type: "tool";
|
|
35
|
-
name: string;
|
|
36
|
-
path: string;
|
|
37
|
-
output: string;
|
|
38
|
-
exitCode: number;
|
|
39
|
-
}
|
|
40
|
-
export declare function resolveStashDir(): string;
|
|
41
|
-
export declare function agentikitSearch(input: {
|
|
42
|
-
query: string;
|
|
43
|
-
type?: AgentikitSearchType;
|
|
44
|
-
limit?: number;
|
|
45
|
-
}): SearchResponse;
|
|
46
|
-
export declare function agentikitOpen(input: {
|
|
47
|
-
ref: string;
|
|
48
|
-
}): OpenResponse;
|
|
49
|
-
export declare function agentikitRun(input: {
|
|
50
|
-
ref: string;
|
|
51
|
-
}): RunResponse;
|
|
52
|
-
export interface InitResponse {
|
|
53
|
-
stashDir: string;
|
|
54
|
-
created: boolean;
|
|
55
|
-
envSet: boolean;
|
|
56
|
-
profileUpdated?: string;
|
|
57
|
-
ripgrep?: {
|
|
58
|
-
rgPath: string;
|
|
59
|
-
installed: boolean;
|
|
60
|
-
version: string;
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
export declare function agentikitInit(): InitResponse;
|
|
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 { agentikitSearch } from "./stash-search";
|
|
7
|
+
export { agentikitShow } from "./stash-show";
|
|
8
|
+
export type { AgentikitSearchType, SearchHit, SearchResponse, ShowResponse, KnowledgeView, } from "./stash-types";
|