@jmylchreest/aide-plugin 0.0.16
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/bin/aide-wrapper.sh +123 -0
- package/dist/core/aide-client.d.ts +48 -0
- package/dist/core/aide-client.d.ts.map +1 -0
- package/dist/core/aide-client.js +166 -0
- package/dist/core/aide-client.js.map +1 -0
- package/dist/core/cleanup.d.ts +15 -0
- package/dist/core/cleanup.d.ts.map +1 -0
- package/dist/core/cleanup.js +48 -0
- package/dist/core/cleanup.js.map +1 -0
- package/dist/core/index.d.ts +17 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +17 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/mcp-sync.d.ts +99 -0
- package/dist/core/mcp-sync.d.ts.map +1 -0
- package/dist/core/mcp-sync.js +525 -0
- package/dist/core/mcp-sync.js.map +1 -0
- package/dist/core/persistence-logic.d.ts +24 -0
- package/dist/core/persistence-logic.d.ts.map +1 -0
- package/dist/core/persistence-logic.js +61 -0
- package/dist/core/persistence-logic.js.map +1 -0
- package/dist/core/pre-compact-logic.d.ts +11 -0
- package/dist/core/pre-compact-logic.d.ts.map +1 -0
- package/dist/core/pre-compact-logic.js +29 -0
- package/dist/core/pre-compact-logic.js.map +1 -0
- package/dist/core/session-init.d.ts +54 -0
- package/dist/core/session-init.d.ts.map +1 -0
- package/dist/core/session-init.js +349 -0
- package/dist/core/session-init.js.map +1 -0
- package/dist/core/session-summary-logic.d.ts +29 -0
- package/dist/core/session-summary-logic.d.ts.map +1 -0
- package/dist/core/session-summary-logic.js +167 -0
- package/dist/core/session-summary-logic.js.map +1 -0
- package/dist/core/skill-matcher.d.ts +46 -0
- package/dist/core/skill-matcher.d.ts.map +1 -0
- package/dist/core/skill-matcher.js +242 -0
- package/dist/core/skill-matcher.js.map +1 -0
- package/dist/core/tool-tracking.d.ts +20 -0
- package/dist/core/tool-tracking.d.ts.map +1 -0
- package/dist/core/tool-tracking.js +81 -0
- package/dist/core/tool-tracking.js.map +1 -0
- package/dist/core/types.d.ts +109 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +31 -0
- package/dist/core/types.js.map +1 -0
- package/dist/lib/aide-downloader.d.ts +90 -0
- package/dist/lib/aide-downloader.js +471 -0
- package/dist/lib/aide-downloader.js.map +1 -0
- package/dist/lib/hook-utils.d.ts +45 -0
- package/dist/lib/hook-utils.js +163 -0
- package/dist/lib/hook-utils.js.map +1 -0
- package/dist/opencode/hooks.d.ts +25 -0
- package/dist/opencode/hooks.d.ts.map +1 -0
- package/dist/opencode/hooks.js +268 -0
- package/dist/opencode/hooks.js.map +1 -0
- package/dist/opencode/index.d.ts +30 -0
- package/dist/opencode/index.d.ts.map +1 -0
- package/dist/opencode/index.js +32 -0
- package/dist/opencode/index.js.map +1 -0
- package/dist/opencode/types.d.ts +129 -0
- package/dist/opencode/types.d.ts.map +1 -0
- package/dist/opencode/types.js +12 -0
- package/dist/opencode/types.js.map +1 -0
- package/package.json +55 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skill discovery and matching — platform-agnostic.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from src/hooks/skill-injector.ts.
|
|
5
|
+
* Finds skill files, parses frontmatter, and fuzzy-matches triggers.
|
|
6
|
+
*/
|
|
7
|
+
import type { Skill } from "./types.js";
|
|
8
|
+
/**
|
|
9
|
+
* Calculate Levenshtein distance between two strings
|
|
10
|
+
*/
|
|
11
|
+
export declare function levenshtein(a: string, b: string): number;
|
|
12
|
+
/**
|
|
13
|
+
* Check if a trigger fuzzy-matches any word sequence in the prompt
|
|
14
|
+
*/
|
|
15
|
+
export declare function fuzzyMatchTrigger(promptLower: string, trigger: string, maxDistance?: number): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Parse YAML frontmatter from skill file
|
|
18
|
+
*/
|
|
19
|
+
export declare function parseSkillFrontmatter(content: string): {
|
|
20
|
+
meta: Record<string, unknown>;
|
|
21
|
+
body: string;
|
|
22
|
+
} | null;
|
|
23
|
+
/**
|
|
24
|
+
* Recursively find all skill files in a directory
|
|
25
|
+
*/
|
|
26
|
+
export declare function findSkillFiles(dir: string, files?: string[]): string[];
|
|
27
|
+
/**
|
|
28
|
+
* Load and parse a skill file
|
|
29
|
+
*/
|
|
30
|
+
export declare function loadSkill(path: string): Skill | null;
|
|
31
|
+
/**
|
|
32
|
+
* Discover all skills from configured locations
|
|
33
|
+
*
|
|
34
|
+
* @param cwd - Project working directory
|
|
35
|
+
* @param pluginRoot - Optional plugin root for finding bundled skills
|
|
36
|
+
*/
|
|
37
|
+
export declare function discoverSkills(cwd: string, pluginRoot?: string): Skill[];
|
|
38
|
+
/**
|
|
39
|
+
* Find skills matching the prompt (supports typos via Levenshtein distance)
|
|
40
|
+
*/
|
|
41
|
+
export declare function matchSkills(prompt: string, skills: Skill[], maxResults?: number): Skill[];
|
|
42
|
+
/**
|
|
43
|
+
* Format skills for injection into context
|
|
44
|
+
*/
|
|
45
|
+
export declare function formatSkillsContext(skills: Skill[]): string;
|
|
46
|
+
//# sourceMappingURL=skill-matcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill-matcher.d.ts","sourceRoot":"","sources":["../../src/core/skill-matcher.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,KAAK,EAAoB,MAAM,YAAY,CAAC;AAY1D;;GAEG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CA4BxD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,EACf,WAAW,GAAE,MAAU,GACtB,OAAO,CAyBT;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,GACd;IAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CA6BxD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,GAAE,MAAM,EAAO,GAAG,MAAM,EAAE,CAkB1E;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,CAsBpD;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,KAAK,EAAE,CAwCxE;AAED;;GAEG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,KAAK,EAAE,EACf,UAAU,SAAI,GACb,KAAK,EAAE,CA0BT;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAiB3D"}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skill discovery and matching — platform-agnostic.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from src/hooks/skill-injector.ts.
|
|
5
|
+
* Finds skill files, parses frontmatter, and fuzzy-matches triggers.
|
|
6
|
+
*/
|
|
7
|
+
import { existsSync, readFileSync, readdirSync } from "fs";
|
|
8
|
+
import { join, basename, extname } from "path";
|
|
9
|
+
import { homedir } from "os";
|
|
10
|
+
// Skill search locations relative to cwd
|
|
11
|
+
const SKILL_LOCATIONS = [
|
|
12
|
+
".aide/skills",
|
|
13
|
+
"skills",
|
|
14
|
+
];
|
|
15
|
+
const GLOBAL_SKILL_LOCATIONS = [
|
|
16
|
+
join(homedir(), ".aide", "skills"),
|
|
17
|
+
];
|
|
18
|
+
/**
|
|
19
|
+
* Calculate Levenshtein distance between two strings
|
|
20
|
+
*/
|
|
21
|
+
export function levenshtein(a, b) {
|
|
22
|
+
const matrix = [];
|
|
23
|
+
if (a.length === 0)
|
|
24
|
+
return b.length;
|
|
25
|
+
if (b.length === 0)
|
|
26
|
+
return a.length;
|
|
27
|
+
for (let i = 0; i <= b.length; i++) {
|
|
28
|
+
matrix[i] = [i];
|
|
29
|
+
}
|
|
30
|
+
for (let j = 0; j <= a.length; j++) {
|
|
31
|
+
matrix[0][j] = j;
|
|
32
|
+
}
|
|
33
|
+
for (let i = 1; i <= b.length; i++) {
|
|
34
|
+
for (let j = 1; j <= a.length; j++) {
|
|
35
|
+
if (b.charAt(i - 1) === a.charAt(j - 1)) {
|
|
36
|
+
matrix[i][j] = matrix[i - 1][j - 1];
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
matrix[i][j] = Math.min(matrix[i - 1][j - 1] + 1, matrix[i][j - 1] + 1, matrix[i - 1][j] + 1);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return matrix[b.length][a.length];
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Check if a trigger fuzzy-matches any word sequence in the prompt
|
|
47
|
+
*/
|
|
48
|
+
export function fuzzyMatchTrigger(promptLower, trigger, maxDistance = 2) {
|
|
49
|
+
const triggerWords = trigger.split(/\s+/);
|
|
50
|
+
const promptWords = promptLower.split(/\s+/);
|
|
51
|
+
if (triggerWords.length === 1) {
|
|
52
|
+
for (const word of promptWords) {
|
|
53
|
+
const dist = levenshtein(word, trigger);
|
|
54
|
+
const allowedDist = Math.min(maxDistance, Math.floor(trigger.length / 3));
|
|
55
|
+
if (dist <= Math.max(1, allowedDist)) {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
for (let i = 0; i <= promptWords.length - triggerWords.length; i++) {
|
|
62
|
+
const window = promptWords.slice(i, i + triggerWords.length).join(" ");
|
|
63
|
+
const dist = levenshtein(window, trigger);
|
|
64
|
+
const allowedDist = Math.min(maxDistance, Math.ceil(trigger.length / 5));
|
|
65
|
+
if (dist <= Math.max(1, allowedDist)) {
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Parse YAML frontmatter from skill file
|
|
73
|
+
*/
|
|
74
|
+
export function parseSkillFrontmatter(content) {
|
|
75
|
+
const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/);
|
|
76
|
+
if (!match)
|
|
77
|
+
return null;
|
|
78
|
+
const yamlContent = match[1];
|
|
79
|
+
const body = match[2].trim();
|
|
80
|
+
const meta = {};
|
|
81
|
+
const nameMatch = yamlContent.match(/^name:\s*["']?([^"'\n]+)["']?\s*$/m);
|
|
82
|
+
if (nameMatch)
|
|
83
|
+
meta.name = nameMatch[1].trim();
|
|
84
|
+
const descMatch = yamlContent.match(/^description:\s*["']?([^"'\n]+)["']?\s*$/m);
|
|
85
|
+
if (descMatch)
|
|
86
|
+
meta.description = descMatch[1].trim();
|
|
87
|
+
const triggers = [];
|
|
88
|
+
const triggerMatch = yamlContent.match(/triggers:\s*\n((?:\s+-\s*.+\n?)*)/);
|
|
89
|
+
if (triggerMatch) {
|
|
90
|
+
const lines = triggerMatch[1].split("\n");
|
|
91
|
+
for (const line of lines) {
|
|
92
|
+
const itemMatch = line.match(/^\s+-\s*["']?([^"'\n]+)["']?\s*$/);
|
|
93
|
+
if (itemMatch)
|
|
94
|
+
triggers.push(itemMatch[1].trim().toLowerCase());
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
meta.triggers = triggers;
|
|
98
|
+
return { meta, body };
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Recursively find all skill files in a directory
|
|
102
|
+
*/
|
|
103
|
+
export function findSkillFiles(dir, files = []) {
|
|
104
|
+
if (!existsSync(dir))
|
|
105
|
+
return files;
|
|
106
|
+
try {
|
|
107
|
+
const entries = readdirSync(dir, { withFileTypes: true });
|
|
108
|
+
for (const entry of entries) {
|
|
109
|
+
const fullPath = join(dir, entry.name);
|
|
110
|
+
if (entry.isDirectory()) {
|
|
111
|
+
findSkillFiles(fullPath, files);
|
|
112
|
+
}
|
|
113
|
+
else if (entry.isFile() && extname(entry.name) === ".md") {
|
|
114
|
+
files.push(fullPath);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
// Ignore errors
|
|
120
|
+
}
|
|
121
|
+
return files;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Load and parse a skill file
|
|
125
|
+
*/
|
|
126
|
+
export function loadSkill(path) {
|
|
127
|
+
try {
|
|
128
|
+
const content = readFileSync(path, "utf-8");
|
|
129
|
+
const parsed = parseSkillFrontmatter(content);
|
|
130
|
+
if (!parsed)
|
|
131
|
+
return null;
|
|
132
|
+
const { meta, body } = parsed;
|
|
133
|
+
const triggers = meta.triggers || [];
|
|
134
|
+
if (triggers.length === 0)
|
|
135
|
+
return null;
|
|
136
|
+
return {
|
|
137
|
+
name: meta.name || basename(path, ".md"),
|
|
138
|
+
path,
|
|
139
|
+
triggers,
|
|
140
|
+
description: meta.description,
|
|
141
|
+
content: body,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Discover all skills from configured locations
|
|
150
|
+
*
|
|
151
|
+
* @param cwd - Project working directory
|
|
152
|
+
* @param pluginRoot - Optional plugin root for finding bundled skills
|
|
153
|
+
*/
|
|
154
|
+
export function discoverSkills(cwd, pluginRoot) {
|
|
155
|
+
const skills = [];
|
|
156
|
+
const seenPaths = new Set();
|
|
157
|
+
// Project-local skills (higher priority)
|
|
158
|
+
for (const location of SKILL_LOCATIONS) {
|
|
159
|
+
const dir = join(cwd, location);
|
|
160
|
+
const files = findSkillFiles(dir);
|
|
161
|
+
for (const file of files) {
|
|
162
|
+
if (seenPaths.has(file))
|
|
163
|
+
continue;
|
|
164
|
+
seenPaths.add(file);
|
|
165
|
+
const skill = loadSkill(file);
|
|
166
|
+
if (skill)
|
|
167
|
+
skills.push(skill);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
// Plugin-bundled skills (if pluginRoot provided)
|
|
171
|
+
if (pluginRoot) {
|
|
172
|
+
const pluginSkillDir = join(pluginRoot, "skills");
|
|
173
|
+
const files = findSkillFiles(pluginSkillDir);
|
|
174
|
+
for (const file of files) {
|
|
175
|
+
if (seenPaths.has(file))
|
|
176
|
+
continue;
|
|
177
|
+
seenPaths.add(file);
|
|
178
|
+
const skill = loadSkill(file);
|
|
179
|
+
if (skill)
|
|
180
|
+
skills.push(skill);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
// Global skills (lower priority)
|
|
184
|
+
for (const dir of GLOBAL_SKILL_LOCATIONS) {
|
|
185
|
+
const files = findSkillFiles(dir);
|
|
186
|
+
for (const file of files) {
|
|
187
|
+
if (seenPaths.has(file))
|
|
188
|
+
continue;
|
|
189
|
+
seenPaths.add(file);
|
|
190
|
+
const skill = loadSkill(file);
|
|
191
|
+
if (skill)
|
|
192
|
+
skills.push(skill);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return skills;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Find skills matching the prompt (supports typos via Levenshtein distance)
|
|
199
|
+
*/
|
|
200
|
+
export function matchSkills(prompt, skills, maxResults = 3) {
|
|
201
|
+
const promptLower = prompt.toLowerCase();
|
|
202
|
+
const matches = [];
|
|
203
|
+
for (const skill of skills) {
|
|
204
|
+
let score = 0;
|
|
205
|
+
for (const trigger of skill.triggers) {
|
|
206
|
+
const triggerLower = trigger.toLowerCase();
|
|
207
|
+
if (promptLower.includes(triggerLower)) {
|
|
208
|
+
score += trigger.length * 2;
|
|
209
|
+
}
|
|
210
|
+
else if (fuzzyMatchTrigger(promptLower, triggerLower)) {
|
|
211
|
+
score += trigger.length;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
if (score > 0) {
|
|
215
|
+
matches.push({ skill, score });
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return matches
|
|
219
|
+
.sort((a, b) => b.score - a.score)
|
|
220
|
+
.slice(0, maxResults)
|
|
221
|
+
.map((m) => m.skill);
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Format skills for injection into context
|
|
225
|
+
*/
|
|
226
|
+
export function formatSkillsContext(skills) {
|
|
227
|
+
const lines = ["<aide-skills>", "", "## Matching Skills", ""];
|
|
228
|
+
for (const skill of skills) {
|
|
229
|
+
lines.push(`### ${skill.name}`);
|
|
230
|
+
if (skill.description) {
|
|
231
|
+
lines.push(`*${skill.description}*`);
|
|
232
|
+
}
|
|
233
|
+
lines.push("");
|
|
234
|
+
lines.push(skill.content);
|
|
235
|
+
lines.push("");
|
|
236
|
+
lines.push("---");
|
|
237
|
+
lines.push("");
|
|
238
|
+
}
|
|
239
|
+
lines.push("</aide-skills>");
|
|
240
|
+
return lines.join("\n");
|
|
241
|
+
}
|
|
242
|
+
//# sourceMappingURL=skill-matcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill-matcher.js","sourceRoot":"","sources":["../../src/core/skill-matcher.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAG7B,yCAAyC;AACzC,MAAM,eAAe,GAAG;IACtB,cAAc;IACd,QAAQ;CACT,CAAC;AAEF,MAAM,sBAAsB,GAAG;IAC7B,IAAI,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,QAAQ,CAAC;CACnC,CAAC;AAEF;;GAEG;AACH,MA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AAI,CAAC,EAAE,CAAC,CAAC;QACf,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAClB,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAC7B,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool tracking and HUD updating — platform-agnostic.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from src/hooks/tool-tracker.ts and src/hooks/hud-updater.ts.
|
|
5
|
+
* Tracks tool usage per-agent and updates session statistics.
|
|
6
|
+
*/
|
|
7
|
+
import type { ToolUseInfo } from "./types.js";
|
|
8
|
+
/**
|
|
9
|
+
* Format tool description for HUD display
|
|
10
|
+
*/
|
|
11
|
+
export declare function formatToolDescription(toolName: string, toolInput?: ToolUseInfo["toolInput"]): string;
|
|
12
|
+
/**
|
|
13
|
+
* Track a tool use event (PreToolUse)
|
|
14
|
+
*/
|
|
15
|
+
export declare function trackToolUse(binary: string, cwd: string, info: ToolUseInfo): void;
|
|
16
|
+
/**
|
|
17
|
+
* Update session state after tool completion (PostToolUse)
|
|
18
|
+
*/
|
|
19
|
+
export declare function updateToolStats(binary: string, cwd: string, toolName: string, agentId?: string): void;
|
|
20
|
+
//# sourceMappingURL=tool-tracking.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-tracking.d.ts","sourceRoot":"","sources":["../../src/core/tool-tracking.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,EAChB,SAAS,CAAC,EAAE,WAAW,CAAC,WAAW,CAAC,GACnC,MAAM,CAgDR;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,WAAW,GAChB,IAAI,CAON;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,MAAM,GACf,IAAI,CAqBN"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool tracking and HUD updating — platform-agnostic.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from src/hooks/tool-tracker.ts and src/hooks/hud-updater.ts.
|
|
5
|
+
* Tracks tool usage per-agent and updates session statistics.
|
|
6
|
+
*/
|
|
7
|
+
import { setState, getState } from "./aide-client.js";
|
|
8
|
+
/**
|
|
9
|
+
* Format tool description for HUD display
|
|
10
|
+
*/
|
|
11
|
+
export function formatToolDescription(toolName, toolInput) {
|
|
12
|
+
if (!toolInput)
|
|
13
|
+
return toolName;
|
|
14
|
+
switch (toolName) {
|
|
15
|
+
case "Bash":
|
|
16
|
+
if (toolInput.command) {
|
|
17
|
+
const cmd = toolInput.command.length > 40
|
|
18
|
+
? toolInput.command.slice(0, 37) + "..."
|
|
19
|
+
: toolInput.command;
|
|
20
|
+
return `Bash(${cmd})`;
|
|
21
|
+
}
|
|
22
|
+
return toolName;
|
|
23
|
+
case "Read":
|
|
24
|
+
if (toolInput.file_path) {
|
|
25
|
+
const filename = toolInput.file_path.split("/").pop() || toolInput.file_path;
|
|
26
|
+
return `Read(${filename})`;
|
|
27
|
+
}
|
|
28
|
+
return toolName;
|
|
29
|
+
case "Edit":
|
|
30
|
+
case "Write":
|
|
31
|
+
if (toolInput.file_path) {
|
|
32
|
+
const filename = toolInput.file_path.split("/").pop() || toolInput.file_path;
|
|
33
|
+
return `${toolName}(${filename})`;
|
|
34
|
+
}
|
|
35
|
+
return toolName;
|
|
36
|
+
case "Task":
|
|
37
|
+
if (toolInput.description) {
|
|
38
|
+
const desc = toolInput.description.length > 30
|
|
39
|
+
? toolInput.description.slice(0, 27) + "..."
|
|
40
|
+
: toolInput.description;
|
|
41
|
+
return `Task(${desc})`;
|
|
42
|
+
}
|
|
43
|
+
return toolName;
|
|
44
|
+
case "Grep":
|
|
45
|
+
case "Glob":
|
|
46
|
+
return toolName;
|
|
47
|
+
default:
|
|
48
|
+
return toolName;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Track a tool use event (PreToolUse)
|
|
53
|
+
*/
|
|
54
|
+
export function trackToolUse(binary, cwd, info) {
|
|
55
|
+
const { toolName, agentId, toolInput } = info;
|
|
56
|
+
if (agentId && toolName) {
|
|
57
|
+
const toolDesc = formatToolDescription(toolName, toolInput);
|
|
58
|
+
setState(binary, cwd, "currentTool", toolDesc, agentId);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Update session state after tool completion (PostToolUse)
|
|
63
|
+
*/
|
|
64
|
+
export function updateToolStats(binary, cwd, toolName, agentId) {
|
|
65
|
+
// Initialize startedAt if not set
|
|
66
|
+
const existingStartedAt = getState(binary, cwd, "startedAt");
|
|
67
|
+
if (!existingStartedAt) {
|
|
68
|
+
setState(binary, cwd, "startedAt", new Date().toISOString());
|
|
69
|
+
}
|
|
70
|
+
// Track tool calls
|
|
71
|
+
const currentToolCalls = parseInt(getState(binary, cwd, "toolCalls") || "0", 10);
|
|
72
|
+
setState(binary, cwd, "toolCalls", String(currentToolCalls + 1));
|
|
73
|
+
setState(binary, cwd, "lastToolUse", new Date().toISOString());
|
|
74
|
+
setState(binary, cwd, "lastTool", toolName);
|
|
75
|
+
// Clear currentTool since PostToolUse means the tool completed
|
|
76
|
+
if (agentId) {
|
|
77
|
+
setState(binary, cwd, "currentTool", "", agentId);
|
|
78
|
+
setState(binary, cwd, "lastTool", toolName, agentId);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
//# sour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AQ,CAC/B,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE,WAAW,CAAC,IAAI,GAAG,EACzC,EAAE,CACH,CAAC;IACF,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,CAAC,gBAAgB,GAAG,CAAC,CAAC,CAAC,CAAC;IACjE,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE,aAAa,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;IAC/D,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;IAE5C,+DAA+D;IAC/D,IAAI,OAAO,EAAE,CAAC;QACZ,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE,aAAa,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;QAClD,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types used by both Claude Code hooks and OpenCode plugin.
|
|
3
|
+
*
|
|
4
|
+
* Platform-agnostic interfaces for aide's core functionality.
|
|
5
|
+
*/
|
|
6
|
+
export interface AideConfig {
|
|
7
|
+
tiers: Record<string, string>;
|
|
8
|
+
aliases: Record<string, string>;
|
|
9
|
+
hud: {
|
|
10
|
+
enabled: boolean;
|
|
11
|
+
elements: string[];
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export declare const DEFAULT_CONFIG: AideConfig;
|
|
15
|
+
export interface SessionState {
|
|
16
|
+
sessionId: string;
|
|
17
|
+
startedAt: string;
|
|
18
|
+
cwd: string;
|
|
19
|
+
activeMode: string | null;
|
|
20
|
+
agentCount: number;
|
|
21
|
+
}
|
|
22
|
+
export interface SessionInitResult {
|
|
23
|
+
state_keys_deleted: number;
|
|
24
|
+
stale_agents_cleaned: number;
|
|
25
|
+
global_memories: Array<{
|
|
26
|
+
id: string;
|
|
27
|
+
content: string;
|
|
28
|
+
category: string;
|
|
29
|
+
tags: string[];
|
|
30
|
+
}>;
|
|
31
|
+
project_memories: Array<{
|
|
32
|
+
id: string;
|
|
33
|
+
content: string;
|
|
34
|
+
category: string;
|
|
35
|
+
tags: string[];
|
|
36
|
+
}>;
|
|
37
|
+
decisions: Array<{
|
|
38
|
+
topic: string;
|
|
39
|
+
value: string;
|
|
40
|
+
rationale?: string;
|
|
41
|
+
}>;
|
|
42
|
+
recent_sessions: Array<{
|
|
43
|
+
session_id: string;
|
|
44
|
+
last_at: string;
|
|
45
|
+
memories: Array<{
|
|
46
|
+
content: string;
|
|
47
|
+
category: string;
|
|
48
|
+
}>;
|
|
49
|
+
}>;
|
|
50
|
+
}
|
|
51
|
+
export interface MemoryInjection {
|
|
52
|
+
static: {
|
|
53
|
+
global: string[];
|
|
54
|
+
project: string[];
|
|
55
|
+
decisions: string[];
|
|
56
|
+
};
|
|
57
|
+
dynamic: {
|
|
58
|
+
sessions: string[];
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
export interface StartupNotices {
|
|
62
|
+
error?: string | null;
|
|
63
|
+
warning?: string | null;
|
|
64
|
+
info?: string[];
|
|
65
|
+
}
|
|
66
|
+
export interface Skill {
|
|
67
|
+
name: string;
|
|
68
|
+
path: string;
|
|
69
|
+
triggers: string[];
|
|
70
|
+
description?: string;
|
|
71
|
+
content: string;
|
|
72
|
+
}
|
|
73
|
+
export interface SkillMatchResult {
|
|
74
|
+
skill: Skill;
|
|
75
|
+
score: number;
|
|
76
|
+
}
|
|
77
|
+
export interface ToolUseInfo {
|
|
78
|
+
toolName: string;
|
|
79
|
+
agentId?: string;
|
|
80
|
+
toolInput?: {
|
|
81
|
+
command?: string;
|
|
82
|
+
description?: string;
|
|
83
|
+
prompt?: string;
|
|
84
|
+
file_path?: string;
|
|
85
|
+
model?: string;
|
|
86
|
+
subagent_type?: string;
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
export declare const PERSISTENCE_MODES: readonly ["ralph", "autopilot"];
|
|
90
|
+
export type PersistenceMode = (typeof PERSISTENCE_MODES)[number];
|
|
91
|
+
export declare const MAX_PERSISTENCE_ITERATIONS = 20;
|
|
92
|
+
/**
|
|
93
|
+
* Identifies which host platform aide is running in.
|
|
94
|
+
* Used for platform-specific behavior like binary discovery or context injection.
|
|
95
|
+
*/
|
|
96
|
+
export type AidePlatform = "claude-code" | "opencode" | "unknown";
|
|
97
|
+
/**
|
|
98
|
+
* Options for finding the aide binary.
|
|
99
|
+
* Platforms provide different hints for where to find the binary.
|
|
100
|
+
*/
|
|
101
|
+
export interface FindBinaryOptions {
|
|
102
|
+
/** Current working directory */
|
|
103
|
+
cwd?: string;
|
|
104
|
+
/** Plugin root directory (AIDE_PLUGIN_ROOT or CLAUDE_PLUGIN_ROOT) */
|
|
105
|
+
pluginRoot?: string;
|
|
106
|
+
/** Additional paths to search before PATH fallback */
|
|
107
|
+
additionalPaths?: string[];
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,GAAG,EAAE;QACH,OAAO,EAAE,OAAO,CAAC;QACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;KACpB,CAAC;CACH;AAED,eAAO,MAAM,cAAc,EAAE,UAmB5B,CAAC;AAMF,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,GAAG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faces for aide's core functionality.
|
|
5
|
+
*/
|
|
6
|
+
export const DEFAULT_CONFIG = {
|
|
7
|
+
tiers: {
|
|
8
|
+
fast: "Cheapest/fastest model",
|
|
9
|
+
balanced: "Good cost/capability balance",
|
|
10
|
+
smart: "Most capable model",
|
|
11
|
+
},
|
|
12
|
+
aliases: {
|
|
13
|
+
opus: "smart",
|
|
14
|
+
sonnet: "balanced",
|
|
15
|
+
haiku: "fast",
|
|
16
|
+
cheap: "fast",
|
|
17
|
+
quick: "fast",
|
|
18
|
+
thorough: "smart",
|
|
19
|
+
best: "smart",
|
|
20
|
+
},
|
|
21
|
+
hud: {
|
|
22
|
+
enabled: true,
|
|
23
|
+
elements: ["mode", "model", "agents"],
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
// =============================================================================
|
|
27
|
+
// Persistence
|
|
28
|
+
// =============================================================================
|
|
29
|
+
export const PERSISTENCE_MODES = ["ralph", "autopilot"];
|
|
30
|
+
export const MAX_PERSISTENCE_ITERATIONS = 20;
|
|
31
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAeH,MAAM,CAAC,MAAM,cAAc,GAAe;IACxC,KAAK,EAAE;QACL,IAAI,EAAE,wBAAwB;QAC9B,QAAQ,EAAE,8BAA8B;QACxC,KAAK,EAAE,oBAAoB;KAC5B;IACD,OAAO,EAAE;QACP,IAAI,EAAE,OAAO;QACb,MAAM,EAAE,UAAU;QAClB,KAAK,EAAE,MAAM;QACb,KAAK,EAAE,MAAM;QACb,KAAK,EAAE,MAAM;QACb,QAAQ,EAAE,OAAO;QACjB,IAAI,EAAE,OAAO;KACd;IACD,GAAG,EAAE;QACH,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC;KACtC;CACF,CAAC;AAgGF,gFAAgF;AAChF,cAAc;AACd,gFAAgF;AAEhF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,OAAO,EAAE,WAAW,CAAU,CAAC;AAEjE,MAAM,CAAC,MAAM,0BAA0B,GAAG,EAAE,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* AIDE Binary Downloader
|
|
4
|
+
*
|
|
5
|
+
* Downloads the aide binary from GitHub releases.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* node dist/lib/aide-downloader.js --plugin # Install to plugin's bin/ (postinstall)
|
|
9
|
+
* node dist/lib/aide-downloader.js --cwd /path # Install to project's .aide/bin/
|
|
10
|
+
*
|
|
11
|
+
* The binary is downloaded from the release matching the plugin version.
|
|
12
|
+
*/
|
|
13
|
+
import { findAideBinary } from "./hook-utils.js";
|
|
14
|
+
export { findAideBinary };
|
|
15
|
+
export interface DownloadResult {
|
|
16
|
+
success: boolean;
|
|
17
|
+
path: string | null;
|
|
18
|
+
message: string;
|
|
19
|
+
cached: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface EnsureResult {
|
|
22
|
+
binary: string | null;
|
|
23
|
+
error: string | null;
|
|
24
|
+
warning: string | null;
|
|
25
|
+
downloaded: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Get the plugin version from package.json
|
|
29
|
+
*/
|
|
30
|
+
export declare function getPluginVersion(): string | null;
|
|
31
|
+
/**
|
|
32
|
+
* Get the version of an installed aide binary
|
|
33
|
+
* Returns full semver including prerelease (e.g., "0.0.5-dev.21+abc1234")
|
|
34
|
+
*/
|
|
35
|
+
export declare function getBinaryVersion(binaryPath: string): string | null;
|
|
36
|
+
/**
|
|
37
|
+
* Check if a version string is a dev/prerelease build
|
|
38
|
+
*/
|
|
39
|
+
export declare function isDevBuild(version: string): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Extract the base semver (major.minor.patch) from a full version string
|
|
42
|
+
* e.g., "0.0.5-dev.21+abc1234" → "0.0.5"
|
|
43
|
+
*/
|
|
44
|
+
export declare function getBaseVersion(version: string): string;
|
|
45
|
+
/**
|
|
46
|
+
* Check the latest release version from GitHub API
|
|
47
|
+
* Returns null if check fails (network error, rate limit, etc.)
|
|
48
|
+
*/
|
|
49
|
+
export declare function getLatestGitHubVersion(): Promise<string | null>;
|
|
50
|
+
/**
|
|
51
|
+
* Compare semantic versions
|
|
52
|
+
* Returns: -1 if a < b, 0 if a == b, 1 if a > b
|
|
53
|
+
*/
|
|
54
|
+
export declare function compareVersions(a: string, b: string): number;
|
|
55
|
+
/**
|
|
56
|
+
* Get the download URL for the current platform
|
|
57
|
+
*/
|
|
58
|
+
export declare function getDownloadUrl(): string;
|
|
59
|
+
/**
|
|
60
|
+
* Get the plugin root directory (where package.json lives)
|
|
61
|
+
*/
|
|
62
|
+
export declare function getPluginRoot(): string | null;
|
|
63
|
+
/**
|
|
64
|
+
* Download aide binary
|
|
65
|
+
*
|
|
66
|
+
* @param destDir - Directory to install the binary (e.g., plugin's bin/ or project's .aide/bin/)
|
|
67
|
+
* @param options - Download options
|
|
68
|
+
*/
|
|
69
|
+
export declare function downloadAideBinary(destDir: string, options?: {
|
|
70
|
+
force?: boolean;
|
|
71
|
+
quiet?: boolean;
|
|
72
|
+
useStderr?: boolean;
|
|
73
|
+
}): Promise<DownloadResult>;
|
|
74
|
+
/**
|
|
75
|
+
* Ensure aide binary is present with version checking and auto-download
|
|
76
|
+
*
|
|
77
|
+
* This function:
|
|
78
|
+
* 1. Checks if binary exists
|
|
79
|
+
* 2. Verifies binary version matches plugin version
|
|
80
|
+
* 3. Auto-downloads if missing or version mismatch
|
|
81
|
+
* 4. Checks GitHub for newer releases (non-blocking)
|
|
82
|
+
* 5. Returns warnings for plugin updates
|
|
83
|
+
*/
|
|
84
|
+
export declare function ensureAideBinary(cwd?: string): Promise<EnsureResult>;
|
|
85
|
+
/**
|
|
86
|
+
* Synchronous version for simple existence check (no download, no version check)
|
|
87
|
+
* Use ensureAideBinary() for full functionality
|
|
88
|
+
*/
|
|
89
|
+
export declare function findAideBinarySync(cwd?: string): string | null;
|
|
90
|
+
//# sourceMappingURL=aide-downloader.d.ts.map
|