@hung319/opencode-hive 1.4.2 → 1.4.4
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 +181 -1
- package/dist/ast-grep-napi.linux-x64-gnu-qdwfscvp.node +0 -0
- package/dist/ast-grep-napi.linux-x64-musl-qnd01z8b.node +0 -0
- package/dist/index.js +2160 -219
- package/dist/mcp/pare-search.d.ts +13 -0
- package/dist/services/vector-memory.d.ts +85 -0
- package/dist/tools/agent-booster.d.ts +48 -0
- package/dist/tools/ast-grep-native.d.ts +18 -0
- package/dist/tools/hive-doctor.d.ts +6 -0
- package/dist/tools/vector-memory.d.ts +10 -0
- package/package.json +6 -2
package/dist/index.js
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
2
4
|
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
function __accessProp(key) {
|
|
8
|
+
return this[key];
|
|
9
|
+
}
|
|
10
|
+
var __toESMCache_node;
|
|
11
|
+
var __toESMCache_esm;
|
|
12
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
13
|
+
var canCache = mod != null && typeof mod === "object";
|
|
14
|
+
if (canCache) {
|
|
15
|
+
var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
|
|
16
|
+
var cached = cache.get(mod);
|
|
17
|
+
if (cached)
|
|
18
|
+
return cached;
|
|
19
|
+
}
|
|
20
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
21
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
22
|
+
for (let key of __getOwnPropNames(mod))
|
|
23
|
+
if (!__hasOwnProp.call(to, key))
|
|
24
|
+
__defProp(to, key, {
|
|
25
|
+
get: __accessProp.bind(mod, key),
|
|
26
|
+
enumerable: true
|
|
27
|
+
});
|
|
28
|
+
if (canCache)
|
|
29
|
+
cache.set(mod, to);
|
|
30
|
+
return to;
|
|
31
|
+
};
|
|
32
|
+
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
3
33
|
var __returnValue = (v) => v;
|
|
4
34
|
function __exportSetter(name, newValue) {
|
|
5
35
|
this[name] = __returnValue.bind(null, newValue);
|
|
@@ -16,6 +46,599 @@ var __export = (target, all) => {
|
|
|
16
46
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
17
47
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
18
48
|
|
|
49
|
+
// ../../node_modules/.bun/@sparkleideas+agent-booster@0.2.34/node_modules/@sparkleideas/agent-booster/dist/index.js
|
|
50
|
+
var require_dist = __commonJS((exports) => {
|
|
51
|
+
var __dirname = "/home/runner/work/agent-hive/agent-hive/node_modules/.bun/@sparkleideas+agent-booster@0.2.34/node_modules/@sparkleideas/agent-booster/dist";
|
|
52
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
53
|
+
if (k2 === undefined)
|
|
54
|
+
k2 = k;
|
|
55
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
56
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
57
|
+
desc = { enumerable: true, get: function() {
|
|
58
|
+
return m[k];
|
|
59
|
+
} };
|
|
60
|
+
}
|
|
61
|
+
Object.defineProperty(o, k2, desc);
|
|
62
|
+
} : function(o, m, k, k2) {
|
|
63
|
+
if (k2 === undefined)
|
|
64
|
+
k2 = k;
|
|
65
|
+
o[k2] = m[k];
|
|
66
|
+
});
|
|
67
|
+
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
|
|
68
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
69
|
+
} : function(o, v) {
|
|
70
|
+
o["default"] = v;
|
|
71
|
+
});
|
|
72
|
+
var __importStar = exports && exports.__importStar || function() {
|
|
73
|
+
var ownKeys = function(o) {
|
|
74
|
+
ownKeys = Object.getOwnPropertyNames || function(o2) {
|
|
75
|
+
var ar = [];
|
|
76
|
+
for (var k in o2)
|
|
77
|
+
if (Object.prototype.hasOwnProperty.call(o2, k))
|
|
78
|
+
ar[ar.length] = k;
|
|
79
|
+
return ar;
|
|
80
|
+
};
|
|
81
|
+
return ownKeys(o);
|
|
82
|
+
};
|
|
83
|
+
return function(mod) {
|
|
84
|
+
if (mod && mod.__esModule)
|
|
85
|
+
return mod;
|
|
86
|
+
var result = {};
|
|
87
|
+
if (mod != null) {
|
|
88
|
+
for (var k = ownKeys(mod), i = 0;i < k.length; i++)
|
|
89
|
+
if (k[i] !== "default")
|
|
90
|
+
__createBinding(result, mod, k[i]);
|
|
91
|
+
}
|
|
92
|
+
__setModuleDefault(result, mod);
|
|
93
|
+
return result;
|
|
94
|
+
};
|
|
95
|
+
}();
|
|
96
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
97
|
+
exports.AgentBooster = undefined;
|
|
98
|
+
exports.apply = apply;
|
|
99
|
+
var path3 = __importStar(__require("path"));
|
|
100
|
+
var wasmPath = path3.join(__dirname, "../wasm/agent_booster_wasm.js");
|
|
101
|
+
var AgentBoosterWasm;
|
|
102
|
+
try {
|
|
103
|
+
AgentBoosterWasm = __require(wasmPath);
|
|
104
|
+
} catch (e) {
|
|
105
|
+
throw new Error(`Failed to load WASM module from ${wasmPath}: ${e}`);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
class AgentBooster {
|
|
109
|
+
constructor(config2 = {}) {
|
|
110
|
+
this.config = {
|
|
111
|
+
confidenceThreshold: config2.confidenceThreshold || 0.5,
|
|
112
|
+
maxChunks: config2.maxChunks || 100
|
|
113
|
+
};
|
|
114
|
+
this.wasmInstance = new AgentBoosterWasm.AgentBoosterWasm;
|
|
115
|
+
}
|
|
116
|
+
async apply(request) {
|
|
117
|
+
const startTime = Date.now();
|
|
118
|
+
try {
|
|
119
|
+
if (!request.edit || request.edit.trim().length === 0) {
|
|
120
|
+
throw new Error("Edit instruction cannot be empty. Provide specific code snippet or transformation.");
|
|
121
|
+
}
|
|
122
|
+
const vaguePhrases = [
|
|
123
|
+
"make it better",
|
|
124
|
+
"improve",
|
|
125
|
+
"optimize",
|
|
126
|
+
"fix",
|
|
127
|
+
"refactor",
|
|
128
|
+
"add feature",
|
|
129
|
+
"implement",
|
|
130
|
+
"create",
|
|
131
|
+
"design",
|
|
132
|
+
"build",
|
|
133
|
+
"handle",
|
|
134
|
+
"manage",
|
|
135
|
+
"process",
|
|
136
|
+
"support"
|
|
137
|
+
];
|
|
138
|
+
const isVague = vaguePhrases.some((phrase) => request.edit.toLowerCase().includes(phrase) && !request.edit.includes("{") && !request.edit.includes("function") && !request.edit.includes("const") && !request.edit.includes("class"));
|
|
139
|
+
if (isVague) {
|
|
140
|
+
throw new Error(`Vague instruction detected: "${request.edit}". Agent Booster requires specific code snippets, not high-level instructions. Use an LLM for vague tasks.`);
|
|
141
|
+
}
|
|
142
|
+
const result = this.wasmInstance.apply_edit(request.code, request.edit, request.language || "javascript", this.config.confidenceThreshold);
|
|
143
|
+
const latency = Date.now() - startTime;
|
|
144
|
+
if (process.env.DEBUG_AGENT_BOOSTER) {
|
|
145
|
+
console.log("WASM result:", {
|
|
146
|
+
type: typeof result,
|
|
147
|
+
confidence: result.confidence,
|
|
148
|
+
strategy: result.strategy,
|
|
149
|
+
merged_code_length: result.merged_code?.length
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
const confidence = this.getConfidence(result);
|
|
153
|
+
const strategy = this.getStrategy(result);
|
|
154
|
+
const mergedCode = this.getMergedCode(result);
|
|
155
|
+
const inputTokens = Math.ceil(request.code.length / 4);
|
|
156
|
+
const outputTokens = Math.ceil(mergedCode.length / 4);
|
|
157
|
+
return {
|
|
158
|
+
output: mergedCode,
|
|
159
|
+
success: confidence > this.config.confidenceThreshold,
|
|
160
|
+
latency,
|
|
161
|
+
tokens: {
|
|
162
|
+
input: inputTokens,
|
|
163
|
+
output: outputTokens
|
|
164
|
+
},
|
|
165
|
+
confidence,
|
|
166
|
+
strategy: this.strategyToString(strategy)
|
|
167
|
+
};
|
|
168
|
+
} catch (error45) {
|
|
169
|
+
const latency = Date.now() - startTime;
|
|
170
|
+
if (process.env.DEBUG_AGENT_BOOSTER) {
|
|
171
|
+
console.error("Error in apply():", error45.message || error45);
|
|
172
|
+
}
|
|
173
|
+
return {
|
|
174
|
+
output: request.code,
|
|
175
|
+
success: false,
|
|
176
|
+
latency,
|
|
177
|
+
tokens: { input: 0, output: 0 },
|
|
178
|
+
confidence: 0,
|
|
179
|
+
strategy: "failed"
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
async batchApply(requests) {
|
|
184
|
+
return Promise.all(requests.map((req) => this.apply(req)));
|
|
185
|
+
}
|
|
186
|
+
getConfidence(result) {
|
|
187
|
+
if (typeof result === "object" && result !== null) {
|
|
188
|
+
if (typeof result.confidence === "number")
|
|
189
|
+
return result.confidence;
|
|
190
|
+
if (typeof result.get_confidence === "function")
|
|
191
|
+
return result.get_confidence();
|
|
192
|
+
}
|
|
193
|
+
return 0.5;
|
|
194
|
+
}
|
|
195
|
+
getStrategy(result) {
|
|
196
|
+
if (typeof result === "object" && result !== null) {
|
|
197
|
+
if (typeof result.strategy === "number")
|
|
198
|
+
return result.strategy;
|
|
199
|
+
if (typeof result.strategy === "string")
|
|
200
|
+
return result.strategy;
|
|
201
|
+
if (typeof result.get_strategy === "function")
|
|
202
|
+
return result.get_strategy();
|
|
203
|
+
}
|
|
204
|
+
return 2;
|
|
205
|
+
}
|
|
206
|
+
getMergedCode(result) {
|
|
207
|
+
if (typeof result === "object" && result !== null) {
|
|
208
|
+
if (typeof result.merged_code === "string")
|
|
209
|
+
return result.merged_code;
|
|
210
|
+
if (typeof result.get_merged_code === "function")
|
|
211
|
+
return result.get_merged_code();
|
|
212
|
+
if (typeof result.code === "string")
|
|
213
|
+
return result.code;
|
|
214
|
+
}
|
|
215
|
+
return "";
|
|
216
|
+
}
|
|
217
|
+
strategyToString(strategy) {
|
|
218
|
+
if (typeof strategy === "string")
|
|
219
|
+
return strategy;
|
|
220
|
+
const strategies = {
|
|
221
|
+
0: "exact_replace",
|
|
222
|
+
1: "fuzzy_replace",
|
|
223
|
+
2: "insert_after",
|
|
224
|
+
3: "insert_before",
|
|
225
|
+
4: "append"
|
|
226
|
+
};
|
|
227
|
+
return strategies[strategy] || "unknown";
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
exports.AgentBooster = AgentBooster;
|
|
231
|
+
async function apply(request) {
|
|
232
|
+
const booster = new AgentBooster;
|
|
233
|
+
return booster.apply(request);
|
|
234
|
+
}
|
|
235
|
+
exports.default = AgentBooster;
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
// ../../node_modules/.bun/@ast-grep+napi-linux-x64-musl@0.41.1/node_modules/@ast-grep/napi-linux-x64-musl/ast-grep-napi.linux-x64-musl.node
|
|
239
|
+
var require_ast_grep_napi_linux_x64_musl = __commonJS((exports, module) => {
|
|
240
|
+
module.exports = __require("./ast-grep-napi.linux-x64-musl-qnd01z8b.node");
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
// ../../node_modules/.bun/@ast-grep+napi-linux-x64-gnu@0.41.1/node_modules/@ast-grep/napi-linux-x64-gnu/ast-grep-napi.linux-x64-gnu.node
|
|
244
|
+
var require_ast_grep_napi_linux_x64_gnu = __commonJS((exports, module) => {
|
|
245
|
+
module.exports = __require("./ast-grep-napi.linux-x64-gnu-qdwfscvp.node");
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
// ../../node_modules/.bun/@ast-grep+napi@0.41.1/node_modules/@ast-grep/napi/index.js
|
|
249
|
+
var require_napi = __commonJS((exports, module) => {
|
|
250
|
+
var __filename = "/home/runner/work/agent-hive/agent-hive/node_modules/.bun/@ast-grep+napi@0.41.1/node_modules/@ast-grep/napi/index.js";
|
|
251
|
+
var { createRequire: createRequire2 } = __require("node:module");
|
|
252
|
+
__require = createRequire2(__filename);
|
|
253
|
+
var { readFileSync: readFileSync5 } = __require("node:fs");
|
|
254
|
+
var nativeBinding = null;
|
|
255
|
+
var loadErrors = [];
|
|
256
|
+
var isMusl = () => {
|
|
257
|
+
let musl = false;
|
|
258
|
+
if (process.platform === "linux") {
|
|
259
|
+
musl = isMuslFromFilesystem();
|
|
260
|
+
if (musl === null) {
|
|
261
|
+
musl = isMuslFromReport();
|
|
262
|
+
}
|
|
263
|
+
if (musl === null) {
|
|
264
|
+
musl = isMuslFromChildProcess();
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return musl;
|
|
268
|
+
};
|
|
269
|
+
var isFileMusl = (f) => f.includes("libc.musl-") || f.includes("ld-musl-");
|
|
270
|
+
var isMuslFromFilesystem = () => {
|
|
271
|
+
try {
|
|
272
|
+
return readFileSync5("/usr/bin/ldd", "utf-8").includes("musl");
|
|
273
|
+
} catch {
|
|
274
|
+
return null;
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
var isMuslFromReport = () => {
|
|
278
|
+
let report = null;
|
|
279
|
+
if (typeof process.report?.getReport === "function") {
|
|
280
|
+
process.report.excludeNetwork = true;
|
|
281
|
+
report = process.report.getReport();
|
|
282
|
+
}
|
|
283
|
+
if (!report) {
|
|
284
|
+
return null;
|
|
285
|
+
}
|
|
286
|
+
if (report.header && report.header.glibcVersionRuntime) {
|
|
287
|
+
return false;
|
|
288
|
+
}
|
|
289
|
+
if (Array.isArray(report.sharedObjects)) {
|
|
290
|
+
if (report.sharedObjects.some(isFileMusl)) {
|
|
291
|
+
return true;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return false;
|
|
295
|
+
};
|
|
296
|
+
var isMuslFromChildProcess = () => {
|
|
297
|
+
try {
|
|
298
|
+
return __require("child_process").execSync("ldd --version", { encoding: "utf8" }).includes("musl");
|
|
299
|
+
} catch (e) {
|
|
300
|
+
return false;
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
function requireNative() {
|
|
304
|
+
if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
|
|
305
|
+
try {
|
|
306
|
+
nativeBinding = __require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
|
|
307
|
+
} catch (err) {
|
|
308
|
+
loadErrors.push(err);
|
|
309
|
+
}
|
|
310
|
+
} else if (process.platform === "android") {
|
|
311
|
+
if (process.arch === "arm64") {
|
|
312
|
+
try {
|
|
313
|
+
return (()=>{throw new Error("Cannot require module "+"./ast-grep-napi.android-arm64.node");})();
|
|
314
|
+
} catch (e) {
|
|
315
|
+
loadErrors.push(e);
|
|
316
|
+
}
|
|
317
|
+
try {
|
|
318
|
+
return (()=>{throw new Error("Cannot require module "+"@ast-grep/napi-android-arm64");})();
|
|
319
|
+
} catch (e) {
|
|
320
|
+
loadErrors.push(e);
|
|
321
|
+
}
|
|
322
|
+
} else if (process.arch === "arm") {
|
|
323
|
+
try {
|
|
324
|
+
return (()=>{throw new Error("Cannot require module "+"./ast-grep-napi.android-arm-eabi.node");})();
|
|
325
|
+
} catch (e) {
|
|
326
|
+
loadErrors.push(e);
|
|
327
|
+
}
|
|
328
|
+
try {
|
|
329
|
+
return (()=>{throw new Error("Cannot require module "+"@ast-grep/napi-android-arm-eabi");})();
|
|
330
|
+
} catch (e) {
|
|
331
|
+
loadErrors.push(e);
|
|
332
|
+
}
|
|
333
|
+
} else {
|
|
334
|
+
loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`));
|
|
335
|
+
}
|
|
336
|
+
} else if (process.platform === "win32") {
|
|
337
|
+
if (process.arch === "x64") {
|
|
338
|
+
try {
|
|
339
|
+
return (()=>{throw new Error("Cannot require module "+"./ast-grep-napi.win32-x64-msvc.node");})();
|
|
340
|
+
} catch (e) {
|
|
341
|
+
loadErrors.push(e);
|
|
342
|
+
}
|
|
343
|
+
try {
|
|
344
|
+
return (()=>{throw new Error("Cannot require module "+"@ast-grep/napi-win32-x64-msvc");})();
|
|
345
|
+
} catch (e) {
|
|
346
|
+
loadErrors.push(e);
|
|
347
|
+
}
|
|
348
|
+
} else if (process.arch === "ia32") {
|
|
349
|
+
try {
|
|
350
|
+
return (()=>{throw new Error("Cannot require module "+"./ast-grep-napi.win32-ia32-msvc.node");})();
|
|
351
|
+
} catch (e) {
|
|
352
|
+
loadErrors.push(e);
|
|
353
|
+
}
|
|
354
|
+
try {
|
|
355
|
+
return (()=>{throw new Error("Cannot require module "+"@ast-grep/napi-win32-ia32-msvc");})();
|
|
356
|
+
} catch (e) {
|
|
357
|
+
loadErrors.push(e);
|
|
358
|
+
}
|
|
359
|
+
} else if (process.arch === "arm64") {
|
|
360
|
+
try {
|
|
361
|
+
return (()=>{throw new Error("Cannot require module "+"./ast-grep-napi.win32-arm64-msvc.node");})();
|
|
362
|
+
} catch (e) {
|
|
363
|
+
loadErrors.push(e);
|
|
364
|
+
}
|
|
365
|
+
try {
|
|
366
|
+
return (()=>{throw new Error("Cannot require module "+"@ast-grep/napi-win32-arm64-msvc");})();
|
|
367
|
+
} catch (e) {
|
|
368
|
+
loadErrors.push(e);
|
|
369
|
+
}
|
|
370
|
+
} else {
|
|
371
|
+
loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`));
|
|
372
|
+
}
|
|
373
|
+
} else if (process.platform === "darwin") {
|
|
374
|
+
try {
|
|
375
|
+
return (()=>{throw new Error("Cannot require module "+"./ast-grep-napi.darwin-universal.node");})();
|
|
376
|
+
} catch (e) {
|
|
377
|
+
loadErrors.push(e);
|
|
378
|
+
}
|
|
379
|
+
try {
|
|
380
|
+
return (()=>{throw new Error("Cannot require module "+"@ast-grep/napi-darwin-universal");})();
|
|
381
|
+
} catch (e) {
|
|
382
|
+
loadErrors.push(e);
|
|
383
|
+
}
|
|
384
|
+
if (process.arch === "x64") {
|
|
385
|
+
try {
|
|
386
|
+
return (()=>{throw new Error("Cannot require module "+"./ast-grep-napi.darwin-x64.node");})();
|
|
387
|
+
} catch (e) {
|
|
388
|
+
loadErrors.push(e);
|
|
389
|
+
}
|
|
390
|
+
try {
|
|
391
|
+
return (()=>{throw new Error("Cannot require module "+"@ast-grep/napi-darwin-x64");})();
|
|
392
|
+
} catch (e) {
|
|
393
|
+
loadErrors.push(e);
|
|
394
|
+
}
|
|
395
|
+
} else if (process.arch === "arm64") {
|
|
396
|
+
try {
|
|
397
|
+
return (()=>{throw new Error("Cannot require module "+"./ast-grep-napi.darwin-arm64.node");})();
|
|
398
|
+
} catch (e) {
|
|
399
|
+
loadErrors.push(e);
|
|
400
|
+
}
|
|
401
|
+
try {
|
|
402
|
+
return (()=>{throw new Error("Cannot require module "+"@ast-grep/napi-darwin-arm64");})();
|
|
403
|
+
} catch (e) {
|
|
404
|
+
loadErrors.push(e);
|
|
405
|
+
}
|
|
406
|
+
} else {
|
|
407
|
+
loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`));
|
|
408
|
+
}
|
|
409
|
+
} else if (process.platform === "freebsd") {
|
|
410
|
+
if (process.arch === "x64") {
|
|
411
|
+
try {
|
|
412
|
+
return (()=>{throw new Error("Cannot require module "+"./ast-grep-napi.freebsd-x64.node");})();
|
|
413
|
+
} catch (e) {
|
|
414
|
+
loadErrors.push(e);
|
|
415
|
+
}
|
|
416
|
+
try {
|
|
417
|
+
return (()=>{throw new Error("Cannot require module "+"@ast-grep/napi-freebsd-x64");})();
|
|
418
|
+
} catch (e) {
|
|
419
|
+
loadErrors.push(e);
|
|
420
|
+
}
|
|
421
|
+
} else if (process.arch === "arm64") {
|
|
422
|
+
try {
|
|
423
|
+
return (()=>{throw new Error("Cannot require module "+"./ast-grep-napi.freebsd-arm64.node");})();
|
|
424
|
+
} catch (e) {
|
|
425
|
+
loadErrors.push(e);
|
|
426
|
+
}
|
|
427
|
+
try {
|
|
428
|
+
return (()=>{throw new Error("Cannot require module "+"@ast-grep/napi-freebsd-arm64");})();
|
|
429
|
+
} catch (e) {
|
|
430
|
+
loadErrors.push(e);
|
|
431
|
+
}
|
|
432
|
+
} else {
|
|
433
|
+
loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`));
|
|
434
|
+
}
|
|
435
|
+
} else if (process.platform === "linux") {
|
|
436
|
+
if (process.arch === "x64") {
|
|
437
|
+
if (isMusl()) {
|
|
438
|
+
try {
|
|
439
|
+
return (()=>{throw new Error("Cannot require module "+"./ast-grep-napi.linux-x64-musl.node");})();
|
|
440
|
+
} catch (e) {
|
|
441
|
+
loadErrors.push(e);
|
|
442
|
+
}
|
|
443
|
+
try {
|
|
444
|
+
return require_ast_grep_napi_linux_x64_musl();
|
|
445
|
+
} catch (e) {
|
|
446
|
+
loadErrors.push(e);
|
|
447
|
+
}
|
|
448
|
+
} else {
|
|
449
|
+
try {
|
|
450
|
+
return (()=>{throw new Error("Cannot require module "+"./ast-grep-napi.linux-x64-gnu.node");})();
|
|
451
|
+
} catch (e) {
|
|
452
|
+
loadErrors.push(e);
|
|
453
|
+
}
|
|
454
|
+
try {
|
|
455
|
+
return require_ast_grep_napi_linux_x64_gnu();
|
|
456
|
+
} catch (e) {
|
|
457
|
+
loadErrors.push(e);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
} else if (process.arch === "arm64") {
|
|
461
|
+
if (isMusl()) {
|
|
462
|
+
try {
|
|
463
|
+
return (()=>{throw new Error("Cannot require module "+"./ast-grep-napi.linux-arm64-musl.node");})();
|
|
464
|
+
} catch (e) {
|
|
465
|
+
loadErrors.push(e);
|
|
466
|
+
}
|
|
467
|
+
try {
|
|
468
|
+
return (()=>{throw new Error("Cannot require module "+"@ast-grep/napi-linux-arm64-musl");})();
|
|
469
|
+
} catch (e) {
|
|
470
|
+
loadErrors.push(e);
|
|
471
|
+
}
|
|
472
|
+
} else {
|
|
473
|
+
try {
|
|
474
|
+
return (()=>{throw new Error("Cannot require module "+"./ast-grep-napi.linux-arm64-gnu.node");})();
|
|
475
|
+
} catch (e) {
|
|
476
|
+
loadErrors.push(e);
|
|
477
|
+
}
|
|
478
|
+
try {
|
|
479
|
+
return (()=>{throw new Error("Cannot require module "+"@ast-grep/napi-linux-arm64-gnu");})();
|
|
480
|
+
} catch (e) {
|
|
481
|
+
loadErrors.push(e);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
} else if (process.arch === "arm") {
|
|
485
|
+
if (isMusl()) {
|
|
486
|
+
try {
|
|
487
|
+
return (()=>{throw new Error("Cannot require module "+"./ast-grep-napi.linux-arm-musleabihf.node");})();
|
|
488
|
+
} catch (e) {
|
|
489
|
+
loadErrors.push(e);
|
|
490
|
+
}
|
|
491
|
+
try {
|
|
492
|
+
return (()=>{throw new Error("Cannot require module "+"@ast-grep/napi-linux-arm-musleabihf");})();
|
|
493
|
+
} catch (e) {
|
|
494
|
+
loadErrors.push(e);
|
|
495
|
+
}
|
|
496
|
+
} else {
|
|
497
|
+
try {
|
|
498
|
+
return (()=>{throw new Error("Cannot require module "+"./ast-grep-napi.linux-arm-gnueabihf.node");})();
|
|
499
|
+
} catch (e) {
|
|
500
|
+
loadErrors.push(e);
|
|
501
|
+
}
|
|
502
|
+
try {
|
|
503
|
+
return (()=>{throw new Error("Cannot require module "+"@ast-grep/napi-linux-arm-gnueabihf");})();
|
|
504
|
+
} catch (e) {
|
|
505
|
+
loadErrors.push(e);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
} else if (process.arch === "riscv64") {
|
|
509
|
+
if (isMusl()) {
|
|
510
|
+
try {
|
|
511
|
+
return (()=>{throw new Error("Cannot require module "+"./ast-grep-napi.linux-riscv64-musl.node");})();
|
|
512
|
+
} catch (e) {
|
|
513
|
+
loadErrors.push(e);
|
|
514
|
+
}
|
|
515
|
+
try {
|
|
516
|
+
return (()=>{throw new Error("Cannot require module "+"@ast-grep/napi-linux-riscv64-musl");})();
|
|
517
|
+
} catch (e) {
|
|
518
|
+
loadErrors.push(e);
|
|
519
|
+
}
|
|
520
|
+
} else {
|
|
521
|
+
try {
|
|
522
|
+
return (()=>{throw new Error("Cannot require module "+"./ast-grep-napi.linux-riscv64-gnu.node");})();
|
|
523
|
+
} catch (e) {
|
|
524
|
+
loadErrors.push(e);
|
|
525
|
+
}
|
|
526
|
+
try {
|
|
527
|
+
return (()=>{throw new Error("Cannot require module "+"@ast-grep/napi-linux-riscv64-gnu");})();
|
|
528
|
+
} catch (e) {
|
|
529
|
+
loadErrors.push(e);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
} else if (process.arch === "ppc64") {
|
|
533
|
+
try {
|
|
534
|
+
return (()=>{throw new Error("Cannot require module "+"./ast-grep-napi.linux-ppc64-gnu.node");})();
|
|
535
|
+
} catch (e) {
|
|
536
|
+
loadErrors.push(e);
|
|
537
|
+
}
|
|
538
|
+
try {
|
|
539
|
+
return (()=>{throw new Error("Cannot require module "+"@ast-grep/napi-linux-ppc64-gnu");})();
|
|
540
|
+
} catch (e) {
|
|
541
|
+
loadErrors.push(e);
|
|
542
|
+
}
|
|
543
|
+
} else if (process.arch === "s390x") {
|
|
544
|
+
try {
|
|
545
|
+
return (()=>{throw new Error("Cannot require module "+"./ast-grep-napi.linux-s390x-gnu.node");})();
|
|
546
|
+
} catch (e) {
|
|
547
|
+
loadErrors.push(e);
|
|
548
|
+
}
|
|
549
|
+
try {
|
|
550
|
+
return (()=>{throw new Error("Cannot require module "+"@ast-grep/napi-linux-s390x-gnu");})();
|
|
551
|
+
} catch (e) {
|
|
552
|
+
loadErrors.push(e);
|
|
553
|
+
}
|
|
554
|
+
} else {
|
|
555
|
+
loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`));
|
|
556
|
+
}
|
|
557
|
+
} else if (process.platform === "openharmony") {
|
|
558
|
+
if (process.arch === "arm64") {
|
|
559
|
+
try {
|
|
560
|
+
return (()=>{throw new Error("Cannot require module "+"./ast-grep-napi.linux-arm64-ohos.node");})();
|
|
561
|
+
} catch (e) {
|
|
562
|
+
loadErrors.push(e);
|
|
563
|
+
}
|
|
564
|
+
try {
|
|
565
|
+
return (()=>{throw new Error("Cannot require module "+"@ast-grep/napi-linux-arm64-ohos");})();
|
|
566
|
+
} catch (e) {
|
|
567
|
+
loadErrors.push(e);
|
|
568
|
+
}
|
|
569
|
+
} else if (process.arch === "x64") {
|
|
570
|
+
try {
|
|
571
|
+
return (()=>{throw new Error("Cannot require module "+"./ast-grep-napi.linux-x64-ohos.node");})();
|
|
572
|
+
} catch (e) {
|
|
573
|
+
loadErrors.push(e);
|
|
574
|
+
}
|
|
575
|
+
try {
|
|
576
|
+
return (()=>{throw new Error("Cannot require module "+"@ast-grep/napi-linux-x64-ohos");})();
|
|
577
|
+
} catch (e) {
|
|
578
|
+
loadErrors.push(e);
|
|
579
|
+
}
|
|
580
|
+
} else if (process.arch === "arm") {
|
|
581
|
+
try {
|
|
582
|
+
return (()=>{throw new Error("Cannot require module "+"./ast-grep-napi.linux-arm-ohos.node");})();
|
|
583
|
+
} catch (e) {
|
|
584
|
+
loadErrors.push(e);
|
|
585
|
+
}
|
|
586
|
+
try {
|
|
587
|
+
return (()=>{throw new Error("Cannot require module "+"@ast-grep/napi-linux-arm-ohos");})();
|
|
588
|
+
} catch (e) {
|
|
589
|
+
loadErrors.push(e);
|
|
590
|
+
}
|
|
591
|
+
} else {
|
|
592
|
+
loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`));
|
|
593
|
+
}
|
|
594
|
+
} else {
|
|
595
|
+
loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`));
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
nativeBinding = requireNative();
|
|
599
|
+
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
600
|
+
try {
|
|
601
|
+
nativeBinding = (()=>{throw new Error("Cannot require module "+"./ast-grep-napi.wasi.cjs");})();
|
|
602
|
+
} catch (err) {
|
|
603
|
+
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
604
|
+
loadErrors.push(err);
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
if (!nativeBinding) {
|
|
608
|
+
try {
|
|
609
|
+
nativeBinding = (()=>{throw new Error("Cannot require module "+"@ast-grep/napi-wasm32-wasi");})();
|
|
610
|
+
} catch (err) {
|
|
611
|
+
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
612
|
+
loadErrors.push(err);
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
if (!nativeBinding) {
|
|
618
|
+
if (loadErrors.length > 0) {
|
|
619
|
+
throw new Error(`Cannot find native binding. ` + `npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` + "Please try `npm i` again after removing both package-lock.json and node_modules directory.", { cause: loadErrors });
|
|
620
|
+
}
|
|
621
|
+
throw new Error(`Failed to load native binding`);
|
|
622
|
+
}
|
|
623
|
+
module.exports = nativeBinding;
|
|
624
|
+
module.exports.SgNode = nativeBinding.SgNode;
|
|
625
|
+
module.exports.SgRoot = nativeBinding.SgRoot;
|
|
626
|
+
module.exports.findInFiles = nativeBinding.findInFiles;
|
|
627
|
+
module.exports.kind = nativeBinding.kind;
|
|
628
|
+
module.exports.Lang = nativeBinding.Lang;
|
|
629
|
+
module.exports.parse = nativeBinding.parse;
|
|
630
|
+
module.exports.parseAsync = nativeBinding.parseAsync;
|
|
631
|
+
module.exports.parseFiles = nativeBinding.parseFiles;
|
|
632
|
+
module.exports.pattern = nativeBinding.pattern;
|
|
633
|
+
module.exports.registerDynamicLanguage = nativeBinding.registerDynamicLanguage;
|
|
634
|
+
module.exports.css = nativeBinding.css;
|
|
635
|
+
module.exports.html = nativeBinding.html;
|
|
636
|
+
module.exports.js = nativeBinding.js;
|
|
637
|
+
module.exports.jsx = nativeBinding.jsx;
|
|
638
|
+
module.exports.ts = nativeBinding.ts;
|
|
639
|
+
module.exports.tsx = nativeBinding.tsx;
|
|
640
|
+
});
|
|
641
|
+
|
|
19
642
|
// src/utils/context-compression.ts
|
|
20
643
|
var exports_context_compression = {};
|
|
21
644
|
__export(exports_context_compression, {
|
|
@@ -231,8 +854,8 @@ var init_context_compression = __esm(() => {
|
|
|
231
854
|
});
|
|
232
855
|
|
|
233
856
|
// src/index.ts
|
|
234
|
-
import * as
|
|
235
|
-
import * as
|
|
857
|
+
import * as path11 from "path";
|
|
858
|
+
import * as os4 from "os";
|
|
236
859
|
|
|
237
860
|
// ../../node_modules/.bun/zod@4.1.8/node_modules/zod/v4/classic/external.js
|
|
238
861
|
var exports_external = {};
|
|
@@ -16528,7 +17151,1292 @@ var hiveMemoryForgetTool = tool({
|
|
|
16528
17151
|
}
|
|
16529
17152
|
});
|
|
16530
17153
|
|
|
16531
|
-
// src/
|
|
17154
|
+
// src/tools/agent-booster.ts
|
|
17155
|
+
import * as fs3 from "fs";
|
|
17156
|
+
import * as path3 from "path";
|
|
17157
|
+
var boosterInstance = null;
|
|
17158
|
+
var boosterInitPromise = null;
|
|
17159
|
+
async function initBooster() {
|
|
17160
|
+
if (boosterInstance !== null) {
|
|
17161
|
+
return;
|
|
17162
|
+
}
|
|
17163
|
+
if (boosterInitPromise !== null) {
|
|
17164
|
+
await boosterInitPromise;
|
|
17165
|
+
return;
|
|
17166
|
+
}
|
|
17167
|
+
boosterInitPromise = (async () => {
|
|
17168
|
+
try {
|
|
17169
|
+
const booster = require_dist();
|
|
17170
|
+
if (booster && typeof booster.init === "function") {
|
|
17171
|
+
await booster.init();
|
|
17172
|
+
boosterInstance = booster;
|
|
17173
|
+
} else if (booster && typeof booster.default === "function") {
|
|
17174
|
+
boosterInstance = booster.default;
|
|
17175
|
+
} else {
|
|
17176
|
+
boosterInstance = booster || {};
|
|
17177
|
+
}
|
|
17178
|
+
console.log("[agent-booster] Initialized successfully");
|
|
17179
|
+
} catch (error45) {
|
|
17180
|
+
console.warn("[agent-booster] Failed to initialize:", error45 instanceof Error ? error45.message : error45);
|
|
17181
|
+
boosterInstance = null;
|
|
17182
|
+
}
|
|
17183
|
+
})();
|
|
17184
|
+
await boosterInitPromise;
|
|
17185
|
+
}
|
|
17186
|
+
async function applyWithBooster(edit) {
|
|
17187
|
+
await initBooster();
|
|
17188
|
+
if (!boosterInstance) {
|
|
17189
|
+
return {
|
|
17190
|
+
success: false,
|
|
17191
|
+
path: edit.path,
|
|
17192
|
+
error: "Agent booster not available",
|
|
17193
|
+
fallback: true
|
|
17194
|
+
};
|
|
17195
|
+
}
|
|
17196
|
+
try {
|
|
17197
|
+
if (!fs3.existsSync(edit.path)) {
|
|
17198
|
+
return {
|
|
17199
|
+
success: false,
|
|
17200
|
+
path: edit.path,
|
|
17201
|
+
error: `File not found: ${edit.path}`
|
|
17202
|
+
};
|
|
17203
|
+
}
|
|
17204
|
+
const currentContent = fs3.readFileSync(edit.path, "utf-8");
|
|
17205
|
+
if (typeof boosterInstance.fastApply === "function") {
|
|
17206
|
+
const result = await boosterInstance.fastApply({
|
|
17207
|
+
path: edit.path,
|
|
17208
|
+
old: edit.oldContent,
|
|
17209
|
+
new: edit.newContent
|
|
17210
|
+
});
|
|
17211
|
+
return {
|
|
17212
|
+
success: result.success ?? true,
|
|
17213
|
+
path: edit.path,
|
|
17214
|
+
applied: result.applied ?? "Applied via agent-booster"
|
|
17215
|
+
};
|
|
17216
|
+
}
|
|
17217
|
+
if (currentContent.includes(edit.oldContent)) {
|
|
17218
|
+
const newContent = currentContent.replace(edit.oldContent, edit.newContent);
|
|
17219
|
+
fs3.writeFileSync(edit.path, newContent, "utf-8");
|
|
17220
|
+
return {
|
|
17221
|
+
success: true,
|
|
17222
|
+
path: edit.path,
|
|
17223
|
+
applied: "Applied via fallback (string replace)"
|
|
17224
|
+
};
|
|
17225
|
+
}
|
|
17226
|
+
return {
|
|
17227
|
+
success: false,
|
|
17228
|
+
path: edit.path,
|
|
17229
|
+
error: "oldContent not found in file"
|
|
17230
|
+
};
|
|
17231
|
+
} catch (error45) {
|
|
17232
|
+
return {
|
|
17233
|
+
success: false,
|
|
17234
|
+
path: edit.path,
|
|
17235
|
+
error: error45 instanceof Error ? error45.message : String(error45),
|
|
17236
|
+
fallback: true
|
|
17237
|
+
};
|
|
17238
|
+
}
|
|
17239
|
+
}
|
|
17240
|
+
async function applyCodeEdit(edit) {
|
|
17241
|
+
const boosterResult = await applyWithBooster(edit);
|
|
17242
|
+
if (boosterResult.success) {
|
|
17243
|
+
return boosterResult;
|
|
17244
|
+
}
|
|
17245
|
+
try {
|
|
17246
|
+
if (!fs3.existsSync(edit.path)) {
|
|
17247
|
+
return {
|
|
17248
|
+
success: false,
|
|
17249
|
+
path: edit.path,
|
|
17250
|
+
error: `File not found: ${edit.path}`
|
|
17251
|
+
};
|
|
17252
|
+
}
|
|
17253
|
+
const currentContent = fs3.readFileSync(edit.path, "utf-8");
|
|
17254
|
+
if (!currentContent.includes(edit.oldContent)) {
|
|
17255
|
+
return {
|
|
17256
|
+
success: false,
|
|
17257
|
+
path: edit.path,
|
|
17258
|
+
error: "oldContent not found in file"
|
|
17259
|
+
};
|
|
17260
|
+
}
|
|
17261
|
+
const newContent = currentContent.replace(edit.oldContent, edit.newContent);
|
|
17262
|
+
fs3.writeFileSync(edit.path, newContent, "utf-8");
|
|
17263
|
+
return {
|
|
17264
|
+
success: true,
|
|
17265
|
+
path: edit.path,
|
|
17266
|
+
applied: "Applied via native fallback"
|
|
17267
|
+
};
|
|
17268
|
+
} catch (error45) {
|
|
17269
|
+
return {
|
|
17270
|
+
success: false,
|
|
17271
|
+
path: edit.path,
|
|
17272
|
+
error: error45 instanceof Error ? error45.message : String(error45)
|
|
17273
|
+
};
|
|
17274
|
+
}
|
|
17275
|
+
}
|
|
17276
|
+
async function isBoosterAvailable() {
|
|
17277
|
+
await initBooster();
|
|
17278
|
+
return boosterInstance !== null;
|
|
17279
|
+
}
|
|
17280
|
+
async function getBoosterStatus() {
|
|
17281
|
+
const available = await isBoosterAvailable();
|
|
17282
|
+
if (!available) {
|
|
17283
|
+
return { available: false };
|
|
17284
|
+
}
|
|
17285
|
+
try {
|
|
17286
|
+
const booster = await Promise.resolve().then(() => __toESM(require_dist(), 1));
|
|
17287
|
+
return {
|
|
17288
|
+
available: true,
|
|
17289
|
+
version: booster.version || "unknown"
|
|
17290
|
+
};
|
|
17291
|
+
} catch {
|
|
17292
|
+
return { available: true };
|
|
17293
|
+
}
|
|
17294
|
+
}
|
|
17295
|
+
var hiveCodeEditTool = tool({
|
|
17296
|
+
description: `Ultra-fast code editing using agent-booster (52x faster than Morph, FREE).
|
|
17297
|
+
|
|
17298
|
+
**Features:**
|
|
17299
|
+
- 52x faster than Morph LLM
|
|
17300
|
+
- No API key required
|
|
17301
|
+
- Rust+WASM powered
|
|
17302
|
+
- Graceful fallback to native edit
|
|
17303
|
+
|
|
17304
|
+
**Usage:**
|
|
17305
|
+
- oldContent: Exact text to replace (must match file content)
|
|
17306
|
+
- newContent: Replacement text
|
|
17307
|
+
- Automatically falls back to native edit if agent-booster unavailable`,
|
|
17308
|
+
args: {
|
|
17309
|
+
path: tool.schema.string().describe("Absolute or relative path to the file to edit"),
|
|
17310
|
+
oldContent: tool.schema.string().describe("Exact text to find and replace"),
|
|
17311
|
+
newContent: tool.schema.string().describe("Replacement text")
|
|
17312
|
+
},
|
|
17313
|
+
async execute({ path: filePath, oldContent, newContent }) {
|
|
17314
|
+
const resolvedPath = path3.isAbsolute(filePath) ? filePath : path3.join(process.cwd(), filePath);
|
|
17315
|
+
const result = await applyCodeEdit({
|
|
17316
|
+
path: resolvedPath,
|
|
17317
|
+
oldContent,
|
|
17318
|
+
newContent
|
|
17319
|
+
});
|
|
17320
|
+
if (!result.success) {
|
|
17321
|
+
return JSON.stringify({
|
|
17322
|
+
success: false,
|
|
17323
|
+
error: result.error,
|
|
17324
|
+
hint: "Ensure oldContent matches exactly. Check for whitespace differences."
|
|
17325
|
+
}, null, 2);
|
|
17326
|
+
}
|
|
17327
|
+
return JSON.stringify({
|
|
17328
|
+
success: true,
|
|
17329
|
+
path: result.path,
|
|
17330
|
+
applied: result.applied,
|
|
17331
|
+
message: `Edit applied successfully`
|
|
17332
|
+
}, null, 2);
|
|
17333
|
+
}
|
|
17334
|
+
});
|
|
17335
|
+
var hiveLazyEditTool = tool({
|
|
17336
|
+
description: `Fast code editing with lazy markers using agent-booster.
|
|
17337
|
+
|
|
17338
|
+
**Lazy Markers:**
|
|
17339
|
+
Use \`// ... existing code ...\` to indicate unchanged sections.
|
|
17340
|
+
Agent-booster intelligently merges your partial code into the full file.
|
|
17341
|
+
|
|
17342
|
+
**Example:**
|
|
17343
|
+
\`\`\`
|
|
17344
|
+
// ... existing code ...
|
|
17345
|
+
const newFunction = () => { ... };
|
|
17346
|
+
// ... existing code ...
|
|
17347
|
+
\`\`\`
|
|
17348
|
+
|
|
17349
|
+
**Note:** Requires @sparkleideas/agent-booster to be installed and enabled.`,
|
|
17350
|
+
args: {
|
|
17351
|
+
path: tool.schema.string().describe("File path"),
|
|
17352
|
+
snippet: tool.schema.string().describe("Code snippet with // ... existing code ... markers")
|
|
17353
|
+
},
|
|
17354
|
+
async execute({ path: filePath, snippet }) {
|
|
17355
|
+
const resolvedPath = path3.isAbsolute(filePath) ? filePath : path3.join(process.cwd(), filePath);
|
|
17356
|
+
const available = await isBoosterAvailable();
|
|
17357
|
+
if (!available) {
|
|
17358
|
+
return JSON.stringify({
|
|
17359
|
+
success: false,
|
|
17360
|
+
error: "agent-booster not available",
|
|
17361
|
+
hint: "Install @sparkleideas/agent-booster or use hive_code_edit for native editing"
|
|
17362
|
+
}, null, 2);
|
|
17363
|
+
}
|
|
17364
|
+
try {
|
|
17365
|
+
if (typeof boosterInstance.lazyApply === "function") {
|
|
17366
|
+
const result = await boosterInstance.lazyApply({
|
|
17367
|
+
path: resolvedPath,
|
|
17368
|
+
snippet
|
|
17369
|
+
});
|
|
17370
|
+
return JSON.stringify({
|
|
17371
|
+
success: result.success ?? true,
|
|
17372
|
+
path: resolvedPath,
|
|
17373
|
+
message: result.message || "Lazy edit applied"
|
|
17374
|
+
}, null, 2);
|
|
17375
|
+
}
|
|
17376
|
+
return JSON.stringify({
|
|
17377
|
+
success: false,
|
|
17378
|
+
error: "Lazy apply not supported",
|
|
17379
|
+
hint: "Update @sparkleideas/agent-booster for lazy edit support"
|
|
17380
|
+
}, null, 2);
|
|
17381
|
+
} catch (error45) {
|
|
17382
|
+
return JSON.stringify({
|
|
17383
|
+
success: false,
|
|
17384
|
+
error: error45 instanceof Error ? error45.message : String(error45)
|
|
17385
|
+
}, null, 2);
|
|
17386
|
+
}
|
|
17387
|
+
}
|
|
17388
|
+
});
|
|
17389
|
+
var hiveBoosterStatusTool = tool({
|
|
17390
|
+
description: `Check agent-booster availability and status.
|
|
17391
|
+
|
|
17392
|
+
**Returns:**
|
|
17393
|
+
- available: Whether agent-booster is installed and working
|
|
17394
|
+
- version: Agent-booster version (if available)
|
|
17395
|
+
- speed: Performance comparison vs native editing`,
|
|
17396
|
+
args: {},
|
|
17397
|
+
async execute() {
|
|
17398
|
+
const status = await getBoosterStatus();
|
|
17399
|
+
return JSON.stringify({
|
|
17400
|
+
...status,
|
|
17401
|
+
performance: {
|
|
17402
|
+
agentBooster: "52x faster than Morph",
|
|
17403
|
+
native: "baseline",
|
|
17404
|
+
savings: "60-90% tokens on large files"
|
|
17405
|
+
},
|
|
17406
|
+
installation: status.available ? "Ready" : "Run: npm install @sparkleideas/agent-booster"
|
|
17407
|
+
}, null, 2);
|
|
17408
|
+
}
|
|
17409
|
+
});
|
|
17410
|
+
|
|
17411
|
+
// src/services/vector-memory.ts
|
|
17412
|
+
import * as fs4 from "fs";
|
|
17413
|
+
import * as path4 from "path";
|
|
17414
|
+
import * as os2 from "os";
|
|
17415
|
+
var memoryInstance = null;
|
|
17416
|
+
var memoryInitPromise = null;
|
|
17417
|
+
async function initMemory(options) {
|
|
17418
|
+
if (memoryInstance !== null) {
|
|
17419
|
+
return;
|
|
17420
|
+
}
|
|
17421
|
+
if (memoryInitPromise !== null) {
|
|
17422
|
+
await memoryInitPromise;
|
|
17423
|
+
return;
|
|
17424
|
+
}
|
|
17425
|
+
memoryInitPromise = (async () => {
|
|
17426
|
+
try {
|
|
17427
|
+
const memory = (()=>{throw new Error("Cannot require module "+"@sparkleideas/memory");})();
|
|
17428
|
+
const indexPath = options?.indexPath || path4.join(os2.homedir(), ".config", "opencode", "hive", "vector-index");
|
|
17429
|
+
const dimensions = options?.dimensions || 384;
|
|
17430
|
+
fs4.mkdirSync(indexPath, { recursive: true });
|
|
17431
|
+
if (typeof memory.init === "function") {
|
|
17432
|
+
await memory.init({
|
|
17433
|
+
indexPath,
|
|
17434
|
+
dimensions
|
|
17435
|
+
});
|
|
17436
|
+
} else if (memory.default && typeof memory.default.init === "function") {
|
|
17437
|
+
memoryInstance = memory.default;
|
|
17438
|
+
await memoryInstance.init({
|
|
17439
|
+
indexPath,
|
|
17440
|
+
dimensions
|
|
17441
|
+
});
|
|
17442
|
+
} else {
|
|
17443
|
+
memoryInstance = memory;
|
|
17444
|
+
}
|
|
17445
|
+
console.log("[vector-memory] Initialized successfully");
|
|
17446
|
+
} catch (error45) {
|
|
17447
|
+
console.warn("[vector-memory] Failed to initialize:", error45 instanceof Error ? error45.message : error45);
|
|
17448
|
+
memoryInstance = null;
|
|
17449
|
+
}
|
|
17450
|
+
})();
|
|
17451
|
+
await memoryInitPromise;
|
|
17452
|
+
}
|
|
17453
|
+
async function addMemory(content, metadata = {}) {
|
|
17454
|
+
await initMemory();
|
|
17455
|
+
if (memoryInstance) {
|
|
17456
|
+
try {
|
|
17457
|
+
const id2 = await memoryInstance.add({
|
|
17458
|
+
content,
|
|
17459
|
+
metadata
|
|
17460
|
+
});
|
|
17461
|
+
return { id: id2, success: true };
|
|
17462
|
+
} catch (error45) {
|
|
17463
|
+
console.warn("[vector-memory] Failed to add with vector:", error45 instanceof Error ? error45.message : error45);
|
|
17464
|
+
}
|
|
17465
|
+
}
|
|
17466
|
+
return addMemoryFallback(content, metadata);
|
|
17467
|
+
}
|
|
17468
|
+
async function searchMemories(query, options = {}) {
|
|
17469
|
+
const { limit = 10, type, scope, minScore = 0 } = options;
|
|
17470
|
+
await initMemory();
|
|
17471
|
+
if (memoryInstance && typeof memoryInstance.search === "function") {
|
|
17472
|
+
try {
|
|
17473
|
+
const searchResults = await memoryInstance.search(query, {
|
|
17474
|
+
limit,
|
|
17475
|
+
filter: { type, scope },
|
|
17476
|
+
minScore
|
|
17477
|
+
});
|
|
17478
|
+
return {
|
|
17479
|
+
results: searchResults.map((r) => ({
|
|
17480
|
+
id: r.id,
|
|
17481
|
+
content: r.content,
|
|
17482
|
+
score: r.score || r.similarity || 0,
|
|
17483
|
+
metadata: r.metadata || {}
|
|
17484
|
+
}))
|
|
17485
|
+
};
|
|
17486
|
+
} catch (error45) {
|
|
17487
|
+
console.warn("[vector-memory] Failed to search with vector:", error45 instanceof Error ? error45.message : error45);
|
|
17488
|
+
}
|
|
17489
|
+
}
|
|
17490
|
+
return searchMemoriesFallback(query, { limit, type, scope });
|
|
17491
|
+
}
|
|
17492
|
+
async function getMemory(id2) {
|
|
17493
|
+
await initMemory();
|
|
17494
|
+
if (memoryInstance && typeof memoryInstance.get === "function") {
|
|
17495
|
+
try {
|
|
17496
|
+
const entry = await memoryInstance.get(id2);
|
|
17497
|
+
return entry;
|
|
17498
|
+
} catch {}
|
|
17499
|
+
}
|
|
17500
|
+
return getMemoryFallback(id2);
|
|
17501
|
+
}
|
|
17502
|
+
async function deleteMemory(id2) {
|
|
17503
|
+
await initMemory();
|
|
17504
|
+
if (memoryInstance && typeof memoryInstance.delete === "function") {
|
|
17505
|
+
try {
|
|
17506
|
+
await memoryInstance.delete(id2);
|
|
17507
|
+
return true;
|
|
17508
|
+
} catch {}
|
|
17509
|
+
}
|
|
17510
|
+
return deleteMemoryFallback(id2);
|
|
17511
|
+
}
|
|
17512
|
+
async function getMemoryStatus() {
|
|
17513
|
+
await initMemory();
|
|
17514
|
+
if (memoryInstance) {
|
|
17515
|
+
try {
|
|
17516
|
+
const stats = await memoryInstance.stats?.() || {};
|
|
17517
|
+
return {
|
|
17518
|
+
available: true,
|
|
17519
|
+
type: "vector",
|
|
17520
|
+
stats
|
|
17521
|
+
};
|
|
17522
|
+
} catch {}
|
|
17523
|
+
}
|
|
17524
|
+
const fallbackStats = getFallbackStats();
|
|
17525
|
+
return {
|
|
17526
|
+
available: false,
|
|
17527
|
+
type: "fallback",
|
|
17528
|
+
stats: fallbackStats
|
|
17529
|
+
};
|
|
17530
|
+
}
|
|
17531
|
+
function getFallbackDir() {
|
|
17532
|
+
return path4.join(os2.homedir(), ".config", "opencode", "hive", "vector-memory", "fallback");
|
|
17533
|
+
}
|
|
17534
|
+
function ensureFallbackDir() {
|
|
17535
|
+
const dir = getFallbackDir();
|
|
17536
|
+
if (!fs4.existsSync(dir)) {
|
|
17537
|
+
fs4.mkdirSync(dir, { recursive: true });
|
|
17538
|
+
}
|
|
17539
|
+
}
|
|
17540
|
+
function generateId() {
|
|
17541
|
+
return `mem_${Date.now()}_${Math.random().toString(36).slice(2, 9)}`;
|
|
17542
|
+
}
|
|
17543
|
+
async function addMemoryFallback(content, metadata) {
|
|
17544
|
+
ensureFallbackDir();
|
|
17545
|
+
const id2 = generateId();
|
|
17546
|
+
const entry = {
|
|
17547
|
+
id: id2,
|
|
17548
|
+
content,
|
|
17549
|
+
metadata,
|
|
17550
|
+
createdAt: new Date().toISOString(),
|
|
17551
|
+
updatedAt: new Date().toISOString()
|
|
17552
|
+
};
|
|
17553
|
+
const filePath = path4.join(getFallbackDir(), `${id2}.json`);
|
|
17554
|
+
fs4.writeFileSync(filePath, JSON.stringify(entry, null, 2), "utf-8");
|
|
17555
|
+
return { id: id2, success: true, fallback: true };
|
|
17556
|
+
}
|
|
17557
|
+
async function searchMemoriesFallback(query, options) {
|
|
17558
|
+
ensureFallbackDir();
|
|
17559
|
+
const { limit = 10, type, scope } = options;
|
|
17560
|
+
const queryLower = query.toLowerCase();
|
|
17561
|
+
const results = [];
|
|
17562
|
+
const files = fs4.readdirSync(getFallbackDir()).filter((f) => f.endsWith(".json"));
|
|
17563
|
+
for (const file2 of files) {
|
|
17564
|
+
try {
|
|
17565
|
+
const content = fs4.readFileSync(path4.join(getFallbackDir(), file2), "utf-8");
|
|
17566
|
+
const entry = JSON.parse(content);
|
|
17567
|
+
if (type && entry.metadata.type !== type)
|
|
17568
|
+
continue;
|
|
17569
|
+
if (scope && entry.metadata.scope !== scope)
|
|
17570
|
+
continue;
|
|
17571
|
+
const contentLower = entry.content.toLowerCase();
|
|
17572
|
+
let score = 0;
|
|
17573
|
+
if (contentLower.includes(queryLower)) {
|
|
17574
|
+
score = queryLower.length / contentLower.length;
|
|
17575
|
+
}
|
|
17576
|
+
if (entry.metadata.tags) {
|
|
17577
|
+
for (const tag of entry.metadata.tags) {
|
|
17578
|
+
if (tag.toLowerCase().includes(queryLower)) {
|
|
17579
|
+
score = Math.max(score, 0.8);
|
|
17580
|
+
}
|
|
17581
|
+
}
|
|
17582
|
+
}
|
|
17583
|
+
if (score > 0) {
|
|
17584
|
+
results.push({
|
|
17585
|
+
id: entry.id,
|
|
17586
|
+
content: entry.content,
|
|
17587
|
+
score,
|
|
17588
|
+
metadata: entry.metadata
|
|
17589
|
+
});
|
|
17590
|
+
}
|
|
17591
|
+
} catch {}
|
|
17592
|
+
}
|
|
17593
|
+
results.sort((a, b) => b.score - a.score);
|
|
17594
|
+
return {
|
|
17595
|
+
results: results.slice(0, limit),
|
|
17596
|
+
fallback: true
|
|
17597
|
+
};
|
|
17598
|
+
}
|
|
17599
|
+
async function getMemoryFallback(id2) {
|
|
17600
|
+
const filePath = path4.join(getFallbackDir(), `${id2}.json`);
|
|
17601
|
+
if (!fs4.existsSync(filePath)) {
|
|
17602
|
+
return null;
|
|
17603
|
+
}
|
|
17604
|
+
try {
|
|
17605
|
+
const content = fs4.readFileSync(filePath, "utf-8");
|
|
17606
|
+
return JSON.parse(content);
|
|
17607
|
+
} catch {
|
|
17608
|
+
return null;
|
|
17609
|
+
}
|
|
17610
|
+
}
|
|
17611
|
+
async function deleteMemoryFallback(id2) {
|
|
17612
|
+
const filePath = path4.join(getFallbackDir(), `${id2}.json`);
|
|
17613
|
+
if (!fs4.existsSync(filePath)) {
|
|
17614
|
+
return false;
|
|
17615
|
+
}
|
|
17616
|
+
try {
|
|
17617
|
+
fs4.unlinkSync(filePath);
|
|
17618
|
+
return true;
|
|
17619
|
+
} catch {
|
|
17620
|
+
return false;
|
|
17621
|
+
}
|
|
17622
|
+
}
|
|
17623
|
+
function getFallbackStats() {
|
|
17624
|
+
ensureFallbackDir();
|
|
17625
|
+
const stats = { total: 0, byType: {} };
|
|
17626
|
+
const files = fs4.readdirSync(getFallbackDir()).filter((f) => f.endsWith(".json"));
|
|
17627
|
+
for (const file2 of files) {
|
|
17628
|
+
try {
|
|
17629
|
+
const content = fs4.readFileSync(path4.join(getFallbackDir(), file2), "utf-8");
|
|
17630
|
+
const entry = JSON.parse(content);
|
|
17631
|
+
stats.total++;
|
|
17632
|
+
const type = entry.metadata.type || "unknown";
|
|
17633
|
+
stats.byType[type] = (stats.byType[type] || 0) + 1;
|
|
17634
|
+
} catch {}
|
|
17635
|
+
}
|
|
17636
|
+
return stats;
|
|
17637
|
+
}
|
|
17638
|
+
var VectorMemoryService = {
|
|
17639
|
+
init: initMemory,
|
|
17640
|
+
add: addMemory,
|
|
17641
|
+
search: searchMemories,
|
|
17642
|
+
get: getMemory,
|
|
17643
|
+
delete: deleteMemory,
|
|
17644
|
+
status: getMemoryStatus
|
|
17645
|
+
};
|
|
17646
|
+
|
|
17647
|
+
// src/tools/vector-memory.ts
|
|
17648
|
+
var hiveVectorSearchTool = tool({
|
|
17649
|
+
description: `Semantic memory search using vector embeddings.
|
|
17650
|
+
|
|
17651
|
+
**Features:**
|
|
17652
|
+
- HNSW indexing for fast similarity search
|
|
17653
|
+
- Semantic matching (finds conceptually similar content)
|
|
17654
|
+
- Filter by type and scope
|
|
17655
|
+
- Fallback to text search if vector unavailable
|
|
17656
|
+
|
|
17657
|
+
**Types:**
|
|
17658
|
+
- decision: Architectural decisions, design choices
|
|
17659
|
+
- learning: Insights, discoveries, patterns found
|
|
17660
|
+
- preference: User preferences, coding style
|
|
17661
|
+
- blocker: Known blockers, workarounds
|
|
17662
|
+
- context: Important context about the project
|
|
17663
|
+
- pattern: Code patterns, recurring solutions`,
|
|
17664
|
+
args: {
|
|
17665
|
+
query: tool.schema.string().describe("Search query (semantic or keyword)"),
|
|
17666
|
+
type: tool.schema.enum(["decision", "learning", "preference", "blocker", "context", "pattern"]).optional().describe("Filter by memory type"),
|
|
17667
|
+
scope: tool.schema.string().optional().describe("Filter by scope (e.g., auth, api, ui)"),
|
|
17668
|
+
limit: tool.schema.number().optional().describe("Maximum results (default: 10)")
|
|
17669
|
+
},
|
|
17670
|
+
async execute({ query, type, scope, limit = 10 }) {
|
|
17671
|
+
const result = await VectorMemoryService.search(query, {
|
|
17672
|
+
limit,
|
|
17673
|
+
type,
|
|
17674
|
+
scope
|
|
17675
|
+
});
|
|
17676
|
+
if (result.results.length === 0) {
|
|
17677
|
+
return JSON.stringify({
|
|
17678
|
+
message: "No matching memories found",
|
|
17679
|
+
query,
|
|
17680
|
+
fallback: result.fallback || false,
|
|
17681
|
+
tips: [
|
|
17682
|
+
"Try different keywords",
|
|
17683
|
+
"Use broader search terms",
|
|
17684
|
+
"Create memories with hive_memory_set first"
|
|
17685
|
+
]
|
|
17686
|
+
}, null, 2);
|
|
17687
|
+
}
|
|
17688
|
+
return JSON.stringify({
|
|
17689
|
+
total: result.results.length,
|
|
17690
|
+
query,
|
|
17691
|
+
fallback: result.fallback || false,
|
|
17692
|
+
results: result.results.map((r) => ({
|
|
17693
|
+
id: r.id,
|
|
17694
|
+
content: r.content,
|
|
17695
|
+
score: Math.round(r.score * 100) / 100,
|
|
17696
|
+
type: r.metadata.type,
|
|
17697
|
+
scope: r.metadata.scope,
|
|
17698
|
+
tags: r.metadata.tags
|
|
17699
|
+
}))
|
|
17700
|
+
}, null, 2);
|
|
17701
|
+
}
|
|
17702
|
+
});
|
|
17703
|
+
var hiveVectorAddTool = tool({
|
|
17704
|
+
description: `Add a memory with semantic indexing for future search.
|
|
17705
|
+
|
|
17706
|
+
**Metadata:**
|
|
17707
|
+
- type: Categorize the memory
|
|
17708
|
+
- scope: Project area or component
|
|
17709
|
+
- tags: Additional categorization
|
|
17710
|
+
|
|
17711
|
+
**Example:**
|
|
17712
|
+
\`\`\`
|
|
17713
|
+
Content: "Use async/await instead of .then() chains"
|
|
17714
|
+
Type: learning
|
|
17715
|
+
Scope: async-patterns
|
|
17716
|
+
Tags: javascript, promises, best-practice
|
|
17717
|
+
\`\`\``,
|
|
17718
|
+
args: {
|
|
17719
|
+
content: tool.schema.string().describe("Memory content to store"),
|
|
17720
|
+
type: tool.schema.enum(["decision", "learning", "preference", "blocker", "context", "pattern"]).optional().describe("Memory type"),
|
|
17721
|
+
scope: tool.schema.string().optional().describe("Scope (e.g., auth, api, ui)"),
|
|
17722
|
+
tags: tool.schema.array(tool.schema.string()).optional().describe("Tags for categorization")
|
|
17723
|
+
},
|
|
17724
|
+
async execute({ content, type, scope, tags }) {
|
|
17725
|
+
const metadata = {};
|
|
17726
|
+
if (type)
|
|
17727
|
+
metadata.type = type;
|
|
17728
|
+
if (scope)
|
|
17729
|
+
metadata.scope = scope;
|
|
17730
|
+
if (tags)
|
|
17731
|
+
metadata.tags = tags;
|
|
17732
|
+
const result = await VectorMemoryService.add(content, metadata);
|
|
17733
|
+
return JSON.stringify({
|
|
17734
|
+
success: result.success,
|
|
17735
|
+
id: result.id,
|
|
17736
|
+
fallback: result.fallback || false,
|
|
17737
|
+
message: `Memory stored${result.fallback ? " (text search mode)" : " (vector indexed)"}`
|
|
17738
|
+
}, null, 2);
|
|
17739
|
+
}
|
|
17740
|
+
});
|
|
17741
|
+
var hiveVectorStatusTool = tool({
|
|
17742
|
+
description: `Check vector memory status and statistics.
|
|
17743
|
+
|
|
17744
|
+
**Returns:**
|
|
17745
|
+
- available: Whether @sparkleideas/memory is working
|
|
17746
|
+
- type: vector or fallback
|
|
17747
|
+
- stats: Memory counts by type`,
|
|
17748
|
+
args: {},
|
|
17749
|
+
async execute() {
|
|
17750
|
+
const status = await VectorMemoryService.status();
|
|
17751
|
+
return JSON.stringify({
|
|
17752
|
+
status: status.available ? "ready" : "fallback",
|
|
17753
|
+
type: status.type,
|
|
17754
|
+
backend: status.available ? "@sparkleideas/memory (HNSW + Vector)" : "Simple text search",
|
|
17755
|
+
stats: status.stats,
|
|
17756
|
+
tips: status.available ? [] : [
|
|
17757
|
+
"Install @sparkleideas/memory for vector search",
|
|
17758
|
+
"npm install @sparkleideas/memory"
|
|
17759
|
+
]
|
|
17760
|
+
}, null, 2);
|
|
17761
|
+
}
|
|
17762
|
+
});
|
|
17763
|
+
|
|
17764
|
+
// src/tools/ast-grep-native.ts
|
|
17765
|
+
import * as fs5 from "fs";
|
|
17766
|
+
var astGrepModule = null;
|
|
17767
|
+
var astGrepInitPromise = null;
|
|
17768
|
+
async function initAstGrep() {
|
|
17769
|
+
if (astGrepModule !== null) {
|
|
17770
|
+
return;
|
|
17771
|
+
}
|
|
17772
|
+
if (astGrepInitPromise !== null) {
|
|
17773
|
+
await astGrepInitPromise;
|
|
17774
|
+
return;
|
|
17775
|
+
}
|
|
17776
|
+
astGrepInitPromise = (async () => {
|
|
17777
|
+
try {
|
|
17778
|
+
astGrepModule = await Promise.resolve().then(() => __toESM(require_napi(), 1));
|
|
17779
|
+
console.log("[ast-grep] Native NAPI initialized successfully");
|
|
17780
|
+
} catch (error45) {
|
|
17781
|
+
console.warn("[ast-grep] Failed to load @ast-grep/napi:", error45 instanceof Error ? error45.message : error45);
|
|
17782
|
+
astGrepModule = null;
|
|
17783
|
+
}
|
|
17784
|
+
})();
|
|
17785
|
+
await astGrepInitPromise;
|
|
17786
|
+
}
|
|
17787
|
+
var astGrepDumpSyntaxTreeTool = tool({
|
|
17788
|
+
description: `Dump code's syntax structure or dump a query's pattern structure.
|
|
17789
|
+
|
|
17790
|
+
This is useful to discover correct syntax kind and syntax tree structure. Call it when debugging a rule.
|
|
17791
|
+
|
|
17792
|
+
**Parameters:**
|
|
17793
|
+
- code: The code you need
|
|
17794
|
+
- language: Programming language (typescript, javascript, python, rust, go, java, etc.)
|
|
17795
|
+
- format: Output format - 'cst' (concrete syntax tree) or 'pattern' (to inspect rule patterns)
|
|
17796
|
+
|
|
17797
|
+
**Use when:**
|
|
17798
|
+
- Debugging AST patterns
|
|
17799
|
+
- Finding correct syntax kind names
|
|
17800
|
+
- Understanding code structure`,
|
|
17801
|
+
args: {
|
|
17802
|
+
code: tool.schema.string().describe("The code to analyze"),
|
|
17803
|
+
language: tool.schema.string().describe("Programming language (typescript, javascript, python, rust, go, java, etc.)"),
|
|
17804
|
+
format: tool.schema.enum(["cst", "pattern"]).default("cst").describe("Output format")
|
|
17805
|
+
},
|
|
17806
|
+
async execute({ code, language, format }) {
|
|
17807
|
+
await initAstGrep();
|
|
17808
|
+
if (!astGrepModule) {
|
|
17809
|
+
return JSON.stringify({
|
|
17810
|
+
success: false,
|
|
17811
|
+
error: "@ast-grep/napi not available",
|
|
17812
|
+
hint: "Install @ast-grep/napi or use MCP-based ast_grep"
|
|
17813
|
+
}, null, 2);
|
|
17814
|
+
}
|
|
17815
|
+
try {
|
|
17816
|
+
const langMap = {
|
|
17817
|
+
typescript: "TypeScript",
|
|
17818
|
+
javascript: "JavaScript",
|
|
17819
|
+
tsx: "Tsx",
|
|
17820
|
+
jsx: "Jsx",
|
|
17821
|
+
python: "Python",
|
|
17822
|
+
rust: "Rust",
|
|
17823
|
+
go: "Go",
|
|
17824
|
+
java: "Java",
|
|
17825
|
+
c: "C",
|
|
17826
|
+
cpp: "Cpp",
|
|
17827
|
+
csharp: "CSharp"
|
|
17828
|
+
};
|
|
17829
|
+
const lang = langMap[language.toLowerCase()] || language;
|
|
17830
|
+
const Lang = astGrepModule.Lang;
|
|
17831
|
+
if (!Lang || !Lang[lang]) {
|
|
17832
|
+
return JSON.stringify({
|
|
17833
|
+
success: false,
|
|
17834
|
+
error: `Unsupported language: ${language}`,
|
|
17835
|
+
availableLanguages: Object.keys(langMap)
|
|
17836
|
+
}, null, 2);
|
|
17837
|
+
}
|
|
17838
|
+
if (format === "pattern") {
|
|
17839
|
+
return JSON.stringify({
|
|
17840
|
+
success: true,
|
|
17841
|
+
format: "pattern",
|
|
17842
|
+
language,
|
|
17843
|
+
example: {
|
|
17844
|
+
match: "AwaitExpression",
|
|
17845
|
+
kind: "Use kind to match AST node types",
|
|
17846
|
+
pattern: "Use pattern for code templates"
|
|
17847
|
+
}
|
|
17848
|
+
}, null, 2);
|
|
17849
|
+
}
|
|
17850
|
+
const parse5 = astGrepModule.parse;
|
|
17851
|
+
const ast = parse5(Lang[lang], code);
|
|
17852
|
+
const root = ast.root();
|
|
17853
|
+
const dump = (node, depth = 0) => {
|
|
17854
|
+
if (!node)
|
|
17855
|
+
return null;
|
|
17856
|
+
return {
|
|
17857
|
+
kind: node.kind(),
|
|
17858
|
+
text: node.text(),
|
|
17859
|
+
children: node.children().map((child) => dump(child, depth + 1))
|
|
17860
|
+
};
|
|
17861
|
+
};
|
|
17862
|
+
return JSON.stringify({
|
|
17863
|
+
success: true,
|
|
17864
|
+
format: "cst",
|
|
17865
|
+
language,
|
|
17866
|
+
tree: dump(root)
|
|
17867
|
+
}, null, 2);
|
|
17868
|
+
} catch (error45) {
|
|
17869
|
+
return JSON.stringify({
|
|
17870
|
+
success: false,
|
|
17871
|
+
error: error45 instanceof Error ? error45.message : String(error45)
|
|
17872
|
+
}, null, 2);
|
|
17873
|
+
}
|
|
17874
|
+
}
|
|
17875
|
+
});
|
|
17876
|
+
var astGrepTestMatchCodeRuleTool = tool({
|
|
17877
|
+
description: `Test a code against an ast-grep YAML rule.
|
|
17878
|
+
|
|
17879
|
+
This is useful to test a rule before using it in a project.
|
|
17880
|
+
|
|
17881
|
+
**Parameters:**
|
|
17882
|
+
- code: The code to test against the rule
|
|
17883
|
+
- yaml: The ast-grep YAML rule to test
|
|
17884
|
+
|
|
17885
|
+
**Returns:**
|
|
17886
|
+
- Whether the rule matched
|
|
17887
|
+
- Matched nodes with locations`,
|
|
17888
|
+
args: {
|
|
17889
|
+
code: tool.schema.string().describe("The code to test against the rule"),
|
|
17890
|
+
yaml: tool.schema.string().describe("The ast-grep YAML rule to search")
|
|
17891
|
+
},
|
|
17892
|
+
async execute({ code, yaml }) {
|
|
17893
|
+
await initAstGrep();
|
|
17894
|
+
if (!astGrepModule) {
|
|
17895
|
+
return JSON.stringify({
|
|
17896
|
+
success: false,
|
|
17897
|
+
error: "@ast-grep/napi not available",
|
|
17898
|
+
hint: "Install @ast-grep/napi or use MCP-based ast_grep"
|
|
17899
|
+
}, null, 2);
|
|
17900
|
+
}
|
|
17901
|
+
try {
|
|
17902
|
+
const parse5 = astGrepModule.parse;
|
|
17903
|
+
const Lang = astGrepModule.Lang;
|
|
17904
|
+
const ast = parse5(Lang.TypeScript, code);
|
|
17905
|
+
const root = ast.root();
|
|
17906
|
+
return JSON.stringify({
|
|
17907
|
+
success: true,
|
|
17908
|
+
matched: false,
|
|
17909
|
+
note: "YAML rule testing requires @ast-grep/cli. Use ast_grep_find_code for pattern-based search.",
|
|
17910
|
+
example: {
|
|
17911
|
+
pattern: "console.log($ARG)",
|
|
17912
|
+
description: "Match console.log with any argument"
|
|
17913
|
+
}
|
|
17914
|
+
}, null, 2);
|
|
17915
|
+
} catch (error45) {
|
|
17916
|
+
return JSON.stringify({
|
|
17917
|
+
success: false,
|
|
17918
|
+
error: error45 instanceof Error ? error45.message : String(error45)
|
|
17919
|
+
}, null, 2);
|
|
17920
|
+
}
|
|
17921
|
+
}
|
|
17922
|
+
});
|
|
17923
|
+
var astGrepFindCodeTool = tool({
|
|
17924
|
+
description: `Find code in a project folder that matches the given ast-grep pattern.
|
|
17925
|
+
|
|
17926
|
+
Pattern is good for simple and single-AST node result. For more complex usage, use ast_grep_scan_code.
|
|
17927
|
+
|
|
17928
|
+
**Parameters:**
|
|
17929
|
+
- project_folder: The absolute path to the project folder
|
|
17930
|
+
- pattern: The ast-grep pattern to search for (e.g., 'console.log($ARG)', '$VAR = $VALUE')
|
|
17931
|
+
- language: Optional - programming language filter
|
|
17932
|
+
|
|
17933
|
+
**Pattern Examples:**
|
|
17934
|
+
- 'console.log($ARG)' - Match console.log with any argument
|
|
17935
|
+
- '$VAR = $VALUE' - Match any assignment
|
|
17936
|
+
- 'function $NAME($PARAMS) { $BODY }' - Match function declarations`,
|
|
17937
|
+
args: {
|
|
17938
|
+
project_folder: tool.schema.string().describe("The absolute path to the project folder"),
|
|
17939
|
+
pattern: tool.schema.string().describe("The ast-grep pattern to search for"),
|
|
17940
|
+
language: tool.schema.string().optional().describe("Programming language filter (typescript, javascript, python, etc.)")
|
|
17941
|
+
},
|
|
17942
|
+
async execute({ project_folder, pattern, language }) {
|
|
17943
|
+
await initAstGrep();
|
|
17944
|
+
if (!astGrepModule) {
|
|
17945
|
+
return JSON.stringify({
|
|
17946
|
+
success: false,
|
|
17947
|
+
error: "@ast-grep/napi not available",
|
|
17948
|
+
hint: "Install @ast-grep/napi or use MCP-based ast_grep"
|
|
17949
|
+
}, null, 2);
|
|
17950
|
+
}
|
|
17951
|
+
try {
|
|
17952
|
+
if (!fs5.existsSync(project_folder)) {
|
|
17953
|
+
return JSON.stringify({
|
|
17954
|
+
success: false,
|
|
17955
|
+
error: `Path not found: ${project_folder}`
|
|
17956
|
+
}, null, 2);
|
|
17957
|
+
}
|
|
17958
|
+
const langMap = {
|
|
17959
|
+
typescript: "TypeScript",
|
|
17960
|
+
javascript: "JavaScript",
|
|
17961
|
+
tsx: "Tsx",
|
|
17962
|
+
jsx: "Jsx",
|
|
17963
|
+
python: "Python",
|
|
17964
|
+
rust: "Rust",
|
|
17965
|
+
go: "Go",
|
|
17966
|
+
java: "Java"
|
|
17967
|
+
};
|
|
17968
|
+
const lang = language ? langMap[language.toLowerCase()] || language : "TypeScript";
|
|
17969
|
+
const Lang = astGrepModule.Lang;
|
|
17970
|
+
if (!Lang[lang]) {
|
|
17971
|
+
return JSON.stringify({
|
|
17972
|
+
success: false,
|
|
17973
|
+
error: `Unsupported language: ${language}`
|
|
17974
|
+
}, null, 2);
|
|
17975
|
+
}
|
|
17976
|
+
const findInFiles = astGrepModule.findInFiles;
|
|
17977
|
+
const results = [];
|
|
17978
|
+
await findInFiles(Lang[lang], {
|
|
17979
|
+
paths: [project_folder],
|
|
17980
|
+
matcher: { rule: { pattern } }
|
|
17981
|
+
}, (err, node) => {
|
|
17982
|
+
if (err) {
|
|
17983
|
+
console.warn("[ast-grep] Search error:", err);
|
|
17984
|
+
return;
|
|
17985
|
+
}
|
|
17986
|
+
if (node) {
|
|
17987
|
+
const text = node.text();
|
|
17988
|
+
const range = node.range();
|
|
17989
|
+
results.push({
|
|
17990
|
+
file: node.filename() || "unknown",
|
|
17991
|
+
line: range ? range.start.index : 0,
|
|
17992
|
+
column: range ? range.start.column : 0,
|
|
17993
|
+
matched: text.slice(0, 100)
|
|
17994
|
+
});
|
|
17995
|
+
}
|
|
17996
|
+
});
|
|
17997
|
+
return JSON.stringify({
|
|
17998
|
+
success: true,
|
|
17999
|
+
count: results.length,
|
|
18000
|
+
matches: results.slice(0, 50)
|
|
18001
|
+
}, null, 2);
|
|
18002
|
+
} catch (error45) {
|
|
18003
|
+
return JSON.stringify({
|
|
18004
|
+
success: false,
|
|
18005
|
+
error: error45 instanceof Error ? error45.message : String(error45)
|
|
18006
|
+
}, null, 2);
|
|
18007
|
+
}
|
|
18008
|
+
}
|
|
18009
|
+
});
|
|
18010
|
+
var astGrepScanCodeTool = tool({
|
|
18011
|
+
description: `Analyze TypeScript/JS code for common bugs, performance issues and best practices.
|
|
18012
|
+
|
|
18013
|
+
Uses AST-based analysis for precise detection without false positives. Essential for maintaining code quality and preventing runtime errors.
|
|
18014
|
+
|
|
18015
|
+
**Detects:**
|
|
18016
|
+
- Type safety violations
|
|
18017
|
+
- Loose object types
|
|
18018
|
+
- Incorrect async patterns
|
|
18019
|
+
- Import style issues
|
|
18020
|
+
- Common bugs
|
|
18021
|
+
|
|
18022
|
+
**Parameters:**
|
|
18023
|
+
- project_folder: Optional - path to scan (defaults to current directory)`,
|
|
18024
|
+
args: {
|
|
18025
|
+
project_folder: tool.schema.string().optional().describe("Path to scan (defaults to current directory)")
|
|
18026
|
+
},
|
|
18027
|
+
async execute({ project_folder }) {
|
|
18028
|
+
await initAstGrep();
|
|
18029
|
+
if (!astGrepModule) {
|
|
18030
|
+
return JSON.stringify({
|
|
18031
|
+
success: false,
|
|
18032
|
+
error: "@ast-grep/napi not available",
|
|
18033
|
+
hint: "Install @ast-grep/napi or use MCP-based ast_grep"
|
|
18034
|
+
}, null, 2);
|
|
18035
|
+
}
|
|
18036
|
+
try {
|
|
18037
|
+
const scanPath = project_folder || process.cwd();
|
|
18038
|
+
if (!fs5.existsSync(scanPath)) {
|
|
18039
|
+
return JSON.stringify({
|
|
18040
|
+
success: false,
|
|
18041
|
+
error: `Path not found: ${scanPath}`
|
|
18042
|
+
}, null, 2);
|
|
18043
|
+
}
|
|
18044
|
+
const bugPatterns = [
|
|
18045
|
+
{ pattern: "await Promise.all($ARR)", severity: "warning", message: "Check if Promise.all is used correctly with async operations" },
|
|
18046
|
+
{ pattern: "JSON.parse($STR)", severity: "info", message: "Consider adding try-catch for JSON.parse" },
|
|
18047
|
+
{ pattern: "$VAR == $VAL", severity: "warning", message: "Use === instead of == for strict equality" }
|
|
18048
|
+
];
|
|
18049
|
+
const issues = [];
|
|
18050
|
+
const Lang = astGrepModule.Lang;
|
|
18051
|
+
const findInFiles = astGrepModule.findInFiles;
|
|
18052
|
+
for (const bug of bugPatterns) {
|
|
18053
|
+
await findInFiles(Lang.TypeScript, {
|
|
18054
|
+
paths: [scanPath],
|
|
18055
|
+
matcher: { rule: { pattern: bug.pattern } }
|
|
18056
|
+
}, (err, node) => {
|
|
18057
|
+
if (err || !node)
|
|
18058
|
+
return;
|
|
18059
|
+
issues.push({
|
|
18060
|
+
file: node.filename() || "unknown",
|
|
18061
|
+
line: node.range()?.start.index || 0,
|
|
18062
|
+
severity: bug.severity,
|
|
18063
|
+
message: bug.message,
|
|
18064
|
+
pattern: bug.pattern
|
|
18065
|
+
});
|
|
18066
|
+
});
|
|
18067
|
+
}
|
|
18068
|
+
return JSON.stringify({
|
|
18069
|
+
success: true,
|
|
18070
|
+
scanned: scanPath,
|
|
18071
|
+
issuesFound: issues.length,
|
|
18072
|
+
issues: issues.slice(0, 20),
|
|
18073
|
+
summary: issues.length === 0 ? "No common issues detected" : `Found ${issues.length} potential issues`
|
|
18074
|
+
}, null, 2);
|
|
18075
|
+
} catch (error45) {
|
|
18076
|
+
return JSON.stringify({
|
|
18077
|
+
success: false,
|
|
18078
|
+
error: error45 instanceof Error ? error45.message : String(error45)
|
|
18079
|
+
}, null, 2);
|
|
18080
|
+
}
|
|
18081
|
+
}
|
|
18082
|
+
});
|
|
18083
|
+
var astGrepRewriteCodeTool = tool({
|
|
18084
|
+
description: `Transform and refactor code using AST-based find-and-replace patterns.
|
|
18085
|
+
|
|
18086
|
+
Use metavariables ($VAR, $$$VARS) in both pattern and replacement.
|
|
18087
|
+
|
|
18088
|
+
**Example:** Find 'console.log($ARG)' and replace with 'logger.info($ARG)'
|
|
18089
|
+
|
|
18090
|
+
**Parameters:**
|
|
18091
|
+
- project_folder: Path to the project folder
|
|
18092
|
+
- pattern: AST pattern to find
|
|
18093
|
+
- replacement: Replacement pattern
|
|
18094
|
+
- language: Programming language (defaults to TypeScript)`,
|
|
18095
|
+
args: {
|
|
18096
|
+
project_folder: tool.schema.string().describe("Path to the project folder"),
|
|
18097
|
+
pattern: tool.schema.string().describe("AST pattern to find"),
|
|
18098
|
+
replacement: tool.schema.string().describe("Replacement pattern"),
|
|
18099
|
+
language: tool.schema.string().optional().default("TypeScript").describe("Programming language")
|
|
18100
|
+
},
|
|
18101
|
+
async execute({ project_folder, pattern, replacement, language }) {
|
|
18102
|
+
await initAstGrep();
|
|
18103
|
+
if (!astGrepModule) {
|
|
18104
|
+
return JSON.stringify({
|
|
18105
|
+
success: false,
|
|
18106
|
+
error: "@ast-grep/napi not available",
|
|
18107
|
+
hint: "Install @ast-grep/napi or use MCP-based ast_grep"
|
|
18108
|
+
}, null, 2);
|
|
18109
|
+
}
|
|
18110
|
+
try {
|
|
18111
|
+
if (!fs5.existsSync(project_folder)) {
|
|
18112
|
+
return JSON.stringify({
|
|
18113
|
+
success: false,
|
|
18114
|
+
error: `Path not found: ${project_folder}`
|
|
18115
|
+
}, null, 2);
|
|
18116
|
+
}
|
|
18117
|
+
const Lang = astGrepModule.Lang;
|
|
18118
|
+
if (!Lang[language]) {
|
|
18119
|
+
return JSON.stringify({
|
|
18120
|
+
success: false,
|
|
18121
|
+
error: `Unsupported language: ${language}`
|
|
18122
|
+
}, null, 2);
|
|
18123
|
+
}
|
|
18124
|
+
return JSON.stringify({
|
|
18125
|
+
success: true,
|
|
18126
|
+
operation: "info",
|
|
18127
|
+
message: "Full rewrite requires @ast-grep/cli with config file",
|
|
18128
|
+
suggestion: "Use ast_grep_find_code to find matches, then hive_code_edit for individual replacements",
|
|
18129
|
+
parameters: {
|
|
18130
|
+
projectFolder: project_folder,
|
|
18131
|
+
pattern,
|
|
18132
|
+
replacement,
|
|
18133
|
+
language
|
|
18134
|
+
}
|
|
18135
|
+
}, null, 2);
|
|
18136
|
+
} catch (error45) {
|
|
18137
|
+
return JSON.stringify({
|
|
18138
|
+
success: false,
|
|
18139
|
+
error: error45 instanceof Error ? error45.message : String(error45)
|
|
18140
|
+
}, null, 2);
|
|
18141
|
+
}
|
|
18142
|
+
}
|
|
18143
|
+
});
|
|
18144
|
+
var astGrepAnalyzeImportsTool = tool({
|
|
18145
|
+
description: `Analyze import statements and dependencies in your codebase.
|
|
18146
|
+
|
|
18147
|
+
Choose "usage" to see which imports are actually used (great for refactoring), or "discovery" to explore all imports and identifiers in the code (great for understanding structure).
|
|
18148
|
+
|
|
18149
|
+
**Parameters:**
|
|
18150
|
+
- mode: "usage" (default) shows where imports are used, "discovery" shows all imports
|
|
18151
|
+
- path: Specific directory or file to analyze (defaults to current directory)`,
|
|
18152
|
+
args: {
|
|
18153
|
+
mode: tool.schema.enum(["usage", "discovery"]).default("usage").describe("Analysis mode"),
|
|
18154
|
+
path: tool.schema.string().optional().describe("Directory or file to analyze")
|
|
18155
|
+
},
|
|
18156
|
+
async execute({ mode, path: path5 }) {
|
|
18157
|
+
await initAstGrep();
|
|
18158
|
+
if (!astGrepModule) {
|
|
18159
|
+
return JSON.stringify({
|
|
18160
|
+
success: false,
|
|
18161
|
+
error: "@ast-grep/napi not available"
|
|
18162
|
+
}, null, 2);
|
|
18163
|
+
}
|
|
18164
|
+
try {
|
|
18165
|
+
const analyzePath = path5 || process.cwd();
|
|
18166
|
+
if (!fs5.existsSync(analyzePath)) {
|
|
18167
|
+
return JSON.stringify({
|
|
18168
|
+
success: false,
|
|
18169
|
+
error: `Path not found: ${analyzePath}`
|
|
18170
|
+
}, null, 2);
|
|
18171
|
+
}
|
|
18172
|
+
const Lang = astGrepModule.Lang;
|
|
18173
|
+
const findInFiles = astGrepModule.findInFiles;
|
|
18174
|
+
const imports = {};
|
|
18175
|
+
await findInFiles(Lang.TypeScript, {
|
|
18176
|
+
paths: [analyzePath],
|
|
18177
|
+
matcher: { rule: { kind: "import_statement" } }
|
|
18178
|
+
}, (err, node) => {
|
|
18179
|
+
if (err || !node)
|
|
18180
|
+
return;
|
|
18181
|
+
const text = node.text();
|
|
18182
|
+
const match = text.match(/from ['"]([^'"]+)['"]/);
|
|
18183
|
+
if (match) {
|
|
18184
|
+
const module = match[1];
|
|
18185
|
+
const file2 = node.filename() || "unknown";
|
|
18186
|
+
if (!imports[module]) {
|
|
18187
|
+
imports[module] = [];
|
|
18188
|
+
}
|
|
18189
|
+
if (!imports[module].includes(file2)) {
|
|
18190
|
+
imports[module].push(file2);
|
|
18191
|
+
}
|
|
18192
|
+
}
|
|
18193
|
+
});
|
|
18194
|
+
if (mode === "usage") {
|
|
18195
|
+
return JSON.stringify({
|
|
18196
|
+
success: true,
|
|
18197
|
+
mode: "usage",
|
|
18198
|
+
imports: Object.entries(imports).map(([module, files]) => ({
|
|
18199
|
+
module,
|
|
18200
|
+
importCount: 1,
|
|
18201
|
+
filesCount: files.length
|
|
18202
|
+
})),
|
|
18203
|
+
note: "Full usage analysis requires @ast-grep/cli"
|
|
18204
|
+
}, null, 2);
|
|
18205
|
+
}
|
|
18206
|
+
return JSON.stringify({
|
|
18207
|
+
success: true,
|
|
18208
|
+
mode: "discovery",
|
|
18209
|
+
totalModules: Object.keys(imports).length,
|
|
18210
|
+
imports: Object.entries(imports).map(([module, files]) => ({
|
|
18211
|
+
module,
|
|
18212
|
+
importCount: files.length,
|
|
18213
|
+
files: files.slice(0, 5)
|
|
18214
|
+
}))
|
|
18215
|
+
}, null, 2);
|
|
18216
|
+
} catch (error45) {
|
|
18217
|
+
return JSON.stringify({
|
|
18218
|
+
success: false,
|
|
18219
|
+
error: error45 instanceof Error ? error45.message : String(error45)
|
|
18220
|
+
}, null, 2);
|
|
18221
|
+
}
|
|
18222
|
+
}
|
|
18223
|
+
});
|
|
18224
|
+
|
|
18225
|
+
// src/tools/hive-doctor.ts
|
|
18226
|
+
import * as fs6 from "fs";
|
|
18227
|
+
import * as path5 from "path";
|
|
18228
|
+
async function checkPackage(packageName) {
|
|
18229
|
+
try {
|
|
18230
|
+
const packageJsonPath = __require.resolve(`${packageName}/package.json`, {
|
|
18231
|
+
paths: [
|
|
18232
|
+
process.cwd(),
|
|
18233
|
+
path5.join(process.cwd(), "node_modules"),
|
|
18234
|
+
path5.join(process.cwd(), "packages/opencode-hive/node_modules")
|
|
18235
|
+
]
|
|
18236
|
+
});
|
|
18237
|
+
if (fs6.existsSync(packageJsonPath)) {
|
|
18238
|
+
const pkg = JSON.parse(fs6.readFileSync(packageJsonPath, "utf-8"));
|
|
18239
|
+
return { installed: true, version: pkg.version };
|
|
18240
|
+
}
|
|
18241
|
+
} catch {}
|
|
18242
|
+
return { installed: false };
|
|
18243
|
+
}
|
|
18244
|
+
function checkOptimizations() {
|
|
18245
|
+
const checks3 = [];
|
|
18246
|
+
const configPaths = [
|
|
18247
|
+
path5.join(process.env.HOME || "", ".config/opencode/agent_hive.json"),
|
|
18248
|
+
path5.join(process.env.HOME || "", ".config/opencode/agent_hive.jsonc")
|
|
18249
|
+
];
|
|
18250
|
+
let config2 = null;
|
|
18251
|
+
for (const configPath of configPaths) {
|
|
18252
|
+
if (fs6.existsSync(configPath)) {
|
|
18253
|
+
try {
|
|
18254
|
+
const content = fs6.readFileSync(configPath, "utf-8");
|
|
18255
|
+
config2 = JSON.parse(content.replace(/\\/g, ""));
|
|
18256
|
+
break;
|
|
18257
|
+
} catch {}
|
|
18258
|
+
}
|
|
18259
|
+
}
|
|
18260
|
+
const snipConfig = config2?.snip;
|
|
18261
|
+
checks3.push({
|
|
18262
|
+
name: "snip",
|
|
18263
|
+
enabled: snipConfig?.enabled === true,
|
|
18264
|
+
recommendation: !snipConfig?.enabled ? "Enable snip in config for 60-90% token reduction on shell output" : undefined
|
|
18265
|
+
});
|
|
18266
|
+
const vectorConfig = config2?.vectorMemory;
|
|
18267
|
+
checks3.push({
|
|
18268
|
+
name: "vectorMemory",
|
|
18269
|
+
enabled: vectorConfig?.enabled === true,
|
|
18270
|
+
recommendation: !vectorConfig?.enabled ? "Enable vector memory for semantic search across memories" : undefined
|
|
18271
|
+
});
|
|
18272
|
+
const boosterConfig = config2?.agentBooster;
|
|
18273
|
+
checks3.push({
|
|
18274
|
+
name: "agentBooster",
|
|
18275
|
+
enabled: boosterConfig?.enabled !== false,
|
|
18276
|
+
recommendation: boosterConfig?.enabled === false ? "Enable agent booster for 52x faster code editing" : undefined
|
|
18277
|
+
});
|
|
18278
|
+
const sandboxConfig = config2?.sandbox;
|
|
18279
|
+
checks3.push({
|
|
18280
|
+
name: "sandbox",
|
|
18281
|
+
enabled: sandboxConfig !== "none",
|
|
18282
|
+
recommendation: sandboxConfig === "none" ? "Enable Docker sandbox for isolated test environments" : undefined
|
|
18283
|
+
});
|
|
18284
|
+
const disabledMcps = config2?.disableMcps || [];
|
|
18285
|
+
const hasAstGrep = !disabledMcps.includes("ast_grep");
|
|
18286
|
+
checks3.push({
|
|
18287
|
+
name: "nativeAstGrep",
|
|
18288
|
+
enabled: hasAstGrep,
|
|
18289
|
+
recommendation: !hasAstGrep ? "Enable native ast-grep for fast AST analysis" : undefined
|
|
18290
|
+
});
|
|
18291
|
+
const hasPareSearch = !disabledMcps.includes("pare_search");
|
|
18292
|
+
checks3.push({
|
|
18293
|
+
name: "pareSearch",
|
|
18294
|
+
enabled: hasPareSearch,
|
|
18295
|
+
recommendation: !hasPareSearch ? "Enable pare_search for structured ripgrep output (65-95% token reduction)" : undefined
|
|
18296
|
+
});
|
|
18297
|
+
return checks3;
|
|
18298
|
+
}
|
|
18299
|
+
function generateRecommendations(dependencies, optimizations) {
|
|
18300
|
+
const recommendations = [];
|
|
18301
|
+
const missingRequired = dependencies.filter((d) => d.required && !d.installed);
|
|
18302
|
+
if (missingRequired.length > 0) {
|
|
18303
|
+
recommendations.push(`Missing required packages: ${missingRequired.map((d) => d.name).join(", ")}`);
|
|
18304
|
+
}
|
|
18305
|
+
const disabledOptimizations = optimizations.filter((o) => !o.enabled && o.recommendation);
|
|
18306
|
+
for (const opt of disabledOptimizations) {
|
|
18307
|
+
if (opt.recommendation) {
|
|
18308
|
+
recommendations.push(opt.recommendation);
|
|
18309
|
+
}
|
|
18310
|
+
}
|
|
18311
|
+
if (recommendations.length === 0) {
|
|
18312
|
+
recommendations.push("System is optimized! No immediate actions needed.");
|
|
18313
|
+
}
|
|
18314
|
+
return recommendations;
|
|
18315
|
+
}
|
|
18316
|
+
function generateQuickFixes(dependencies, optimizations) {
|
|
18317
|
+
const fixes = [];
|
|
18318
|
+
const missingPackages = dependencies.filter((d) => !d.installed && !d.required);
|
|
18319
|
+
for (const pkg of missingPackages) {
|
|
18320
|
+
fixes.push({
|
|
18321
|
+
command: `npm install ${pkg.package}`,
|
|
18322
|
+
description: `Install ${pkg.name}`
|
|
18323
|
+
});
|
|
18324
|
+
}
|
|
18325
|
+
if (optimizations.find((o) => o.name === "snip" && !o.enabled)) {
|
|
18326
|
+
fixes.push({
|
|
18327
|
+
command: 'Add to ~/.config/opencode/agent_hive.json: { "snip": { "enabled": true } }',
|
|
18328
|
+
description: "Enable snip for token reduction"
|
|
18329
|
+
});
|
|
18330
|
+
}
|
|
18331
|
+
if (optimizations.find((o) => o.name === "vectorMemory" && !o.enabled)) {
|
|
18332
|
+
fixes.push({
|
|
18333
|
+
command: 'Add to ~/.config/opencode/agent_hive.json: { "vectorMemory": { "enabled": true } }',
|
|
18334
|
+
description: "Enable vector memory for semantic search"
|
|
18335
|
+
});
|
|
18336
|
+
}
|
|
18337
|
+
return fixes;
|
|
18338
|
+
}
|
|
18339
|
+
function calculateStatus(dependencies, optimizations) {
|
|
18340
|
+
const missingRequired = dependencies.filter((d) => d.required && !d.installed);
|
|
18341
|
+
if (missingRequired.length > 0) {
|
|
18342
|
+
return "issues";
|
|
18343
|
+
}
|
|
18344
|
+
const disabledCount = optimizations.filter((o) => !o.enabled).length;
|
|
18345
|
+
if (disabledCount > 2) {
|
|
18346
|
+
return "warning";
|
|
18347
|
+
}
|
|
18348
|
+
return "healthy";
|
|
18349
|
+
}
|
|
18350
|
+
var hiveDoctorTool = tool({
|
|
18351
|
+
description: `Hive Doctor - System health check and optimization advisor.
|
|
18352
|
+
|
|
18353
|
+
**What it checks:**
|
|
18354
|
+
1. Dependencies - Optional packages installed and working
|
|
18355
|
+
2. Optimizations - Features enabled in config
|
|
18356
|
+
3. Recommendations - Suggestions for improvements
|
|
18357
|
+
|
|
18358
|
+
**Use when:**
|
|
18359
|
+
- Setting up Hive for the first time
|
|
18360
|
+
- Troubleshooting issues
|
|
18361
|
+
- Optimizing performance
|
|
18362
|
+
- Checking if new features are available
|
|
18363
|
+
|
|
18364
|
+
**Example output:**
|
|
18365
|
+
- healthy: All checks pass
|
|
18366
|
+
- warning: Some optimizations disabled
|
|
18367
|
+
- issues: Missing required packages`,
|
|
18368
|
+
args: {},
|
|
18369
|
+
async execute() {
|
|
18370
|
+
const dependencyChecks = [
|
|
18371
|
+
{ name: "agent-booster", package: "@sparkleideas/agent-booster", required: false },
|
|
18372
|
+
{ name: "vector-memory", package: "@sparkleideas/memory", required: false },
|
|
18373
|
+
{ name: "ast-grep NAPI", package: "@ast-grep/napi", required: false },
|
|
18374
|
+
{ name: "pare-search", package: "@paretools/search", required: false },
|
|
18375
|
+
{ name: "context7", package: "@upstash/context7-mcp", required: false },
|
|
18376
|
+
{ name: "Exa search", package: "exa-mcp-server", required: false }
|
|
18377
|
+
];
|
|
18378
|
+
for (const dep of dependencyChecks) {
|
|
18379
|
+
const result2 = await checkPackage(dep.package);
|
|
18380
|
+
dep.installed = result2.installed;
|
|
18381
|
+
dep.version = result2.version;
|
|
18382
|
+
}
|
|
18383
|
+
const optimizationChecks = checkOptimizations();
|
|
18384
|
+
const recommendations = generateRecommendations(dependencyChecks, optimizationChecks);
|
|
18385
|
+
const quickFixes = generateQuickFixes(dependencyChecks, optimizationChecks);
|
|
18386
|
+
const status = calculateStatus(dependencyChecks, optimizationChecks);
|
|
18387
|
+
const result = {
|
|
18388
|
+
status,
|
|
18389
|
+
timestamp: new Date().toISOString(),
|
|
18390
|
+
checks: {
|
|
18391
|
+
dependencies: {
|
|
18392
|
+
total: dependencyChecks.length,
|
|
18393
|
+
installed: dependencyChecks.filter((d) => d.installed).length,
|
|
18394
|
+
packages: dependencyChecks
|
|
18395
|
+
},
|
|
18396
|
+
optimizations: {
|
|
18397
|
+
total: optimizationChecks.length,
|
|
18398
|
+
enabled: optimizationChecks.filter((o) => o.enabled).length,
|
|
18399
|
+
features: optimizationChecks
|
|
18400
|
+
}
|
|
18401
|
+
},
|
|
18402
|
+
recommendations,
|
|
18403
|
+
quickFixes
|
|
18404
|
+
};
|
|
18405
|
+
return JSON.stringify(result, null, 2);
|
|
18406
|
+
}
|
|
18407
|
+
});
|
|
18408
|
+
var hiveDoctorQuickTool = tool({
|
|
18409
|
+
description: `Quick health check - shows status summary only.
|
|
18410
|
+
|
|
18411
|
+
**Returns:**
|
|
18412
|
+
- healthy: All systems go
|
|
18413
|
+
- warning: Some optimizations disabled
|
|
18414
|
+
- issues: Action required`,
|
|
18415
|
+
args: {},
|
|
18416
|
+
async execute() {
|
|
18417
|
+
const keyPackages = [
|
|
18418
|
+
"@ast-grep/napi",
|
|
18419
|
+
"@sparkleideas/agent-booster",
|
|
18420
|
+
"@paretools/search"
|
|
18421
|
+
];
|
|
18422
|
+
const results = {};
|
|
18423
|
+
let healthy = true;
|
|
18424
|
+
for (const pkg of keyPackages) {
|
|
18425
|
+
const result = await checkPackage(pkg);
|
|
18426
|
+
results[pkg] = result.installed;
|
|
18427
|
+
if (!result.installed) {
|
|
18428
|
+
healthy = false;
|
|
18429
|
+
}
|
|
18430
|
+
}
|
|
18431
|
+
return JSON.stringify({
|
|
18432
|
+
status: healthy ? "healthy" : "warning",
|
|
18433
|
+
packages: results,
|
|
18434
|
+
runFullCheck: "Use hive_doctor for detailed analysis"
|
|
18435
|
+
}, null, 2);
|
|
18436
|
+
}
|
|
18437
|
+
});
|
|
18438
|
+
|
|
18439
|
+
// src/agents/hive.ts
|
|
16532
18440
|
var QUEEN_BEE_PROMPT = `# Zetta (Hybrid)
|
|
16533
18441
|
|
|
16534
18442
|
Hybrid agent: plans AND orchestrates. Phase-aware, skills on-demand.
|
|
@@ -17861,12 +19769,19 @@ var astGrepMcp = {
|
|
|
17861
19769
|
command: ["npx", "-y", "@notprolands/ast-grep-mcp"]
|
|
17862
19770
|
};
|
|
17863
19771
|
|
|
19772
|
+
// src/mcp/pare-search.ts
|
|
19773
|
+
var pareSearchMcp = {
|
|
19774
|
+
type: "local",
|
|
19775
|
+
command: ["npx", "-y", "@paretools/search"]
|
|
19776
|
+
};
|
|
19777
|
+
|
|
17864
19778
|
// src/mcp/index.ts
|
|
17865
19779
|
var allBuiltinMcps = {
|
|
17866
19780
|
websearch: websearchMcp,
|
|
17867
19781
|
context7: context7Mcp,
|
|
17868
19782
|
grep_app: grepAppMcp,
|
|
17869
|
-
ast_grep: astGrepMcp
|
|
19783
|
+
ast_grep: astGrepMcp,
|
|
19784
|
+
pare_search: pareSearchMcp
|
|
17870
19785
|
};
|
|
17871
19786
|
var createBuiltinMcps = (disabledMcps = []) => {
|
|
17872
19787
|
const disabled = new Set(disabledMcps);
|
|
@@ -17875,61 +19790,63 @@ var createBuiltinMcps = (disabledMcps = []) => {
|
|
|
17875
19790
|
|
|
17876
19791
|
// ../hive-core/dist/index.js
|
|
17877
19792
|
import { createRequire as createRequire2 } from "node:module";
|
|
17878
|
-
import * as
|
|
17879
|
-
import * as
|
|
19793
|
+
import * as path6 from "path";
|
|
19794
|
+
import * as os3 from "os";
|
|
17880
19795
|
import * as path22 from "path";
|
|
19796
|
+
import * as fs7 from "fs";
|
|
19797
|
+
import * as path32 from "path";
|
|
17881
19798
|
import * as fs22 from "fs";
|
|
17882
19799
|
import * as fs32 from "fs";
|
|
17883
|
-
import * as
|
|
17884
|
-
import * as
|
|
17885
|
-
import * as
|
|
17886
|
-
import * as
|
|
19800
|
+
import * as fs42 from "fs";
|
|
19801
|
+
import * as fs52 from "fs";
|
|
19802
|
+
import * as fs72 from "fs/promises";
|
|
19803
|
+
import * as path42 from "path";
|
|
17887
19804
|
import { Buffer as Buffer2 } from "node:buffer";
|
|
17888
19805
|
import { spawn } from "child_process";
|
|
17889
19806
|
import { normalize } from "node:path";
|
|
17890
19807
|
import { EventEmitter } from "node:events";
|
|
17891
19808
|
import * as fs8 from "fs";
|
|
17892
|
-
import * as
|
|
19809
|
+
import * as path52 from "path";
|
|
17893
19810
|
import * as fs10 from "fs";
|
|
17894
|
-
import * as path6 from "path";
|
|
17895
|
-
import * as fs11 from "fs";
|
|
17896
19811
|
import * as path7 from "path";
|
|
17897
|
-
import
|
|
17898
|
-
import
|
|
19812
|
+
import * as fs11 from "fs";
|
|
19813
|
+
import * as path8 from "path";
|
|
19814
|
+
import { existsSync as existsSync52 } from "fs";
|
|
19815
|
+
import { join as join92, sep } from "path";
|
|
17899
19816
|
import { execSync } from "child_process";
|
|
17900
|
-
var
|
|
17901
|
-
var
|
|
19817
|
+
var __create2 = Object.create;
|
|
19818
|
+
var __getProtoOf2 = Object.getPrototypeOf;
|
|
17902
19819
|
var __defProp2 = Object.defineProperty;
|
|
17903
|
-
var
|
|
17904
|
-
var
|
|
17905
|
-
function
|
|
19820
|
+
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
19821
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
19822
|
+
function __accessProp2(key) {
|
|
17906
19823
|
return this[key];
|
|
17907
19824
|
}
|
|
17908
|
-
var
|
|
17909
|
-
var
|
|
17910
|
-
var
|
|
19825
|
+
var __toESMCache_node2;
|
|
19826
|
+
var __toESMCache_esm2;
|
|
19827
|
+
var __toESM2 = (mod, isNodeMode, target) => {
|
|
17911
19828
|
var canCache = mod != null && typeof mod === "object";
|
|
17912
19829
|
if (canCache) {
|
|
17913
|
-
var cache = isNodeMode ?
|
|
19830
|
+
var cache = isNodeMode ? __toESMCache_node2 ??= new WeakMap : __toESMCache_esm2 ??= new WeakMap;
|
|
17914
19831
|
var cached2 = cache.get(mod);
|
|
17915
19832
|
if (cached2)
|
|
17916
19833
|
return cached2;
|
|
17917
19834
|
}
|
|
17918
|
-
target = mod != null ?
|
|
19835
|
+
target = mod != null ? __create2(__getProtoOf2(mod)) : {};
|
|
17919
19836
|
const to = isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target;
|
|
17920
|
-
for (let key of
|
|
17921
|
-
if (!
|
|
19837
|
+
for (let key of __getOwnPropNames2(mod))
|
|
19838
|
+
if (!__hasOwnProp2.call(to, key))
|
|
17922
19839
|
__defProp2(to, key, {
|
|
17923
|
-
get:
|
|
19840
|
+
get: __accessProp2.bind(mod, key),
|
|
17924
19841
|
enumerable: true
|
|
17925
19842
|
});
|
|
17926
19843
|
if (canCache)
|
|
17927
19844
|
cache.set(mod, to);
|
|
17928
19845
|
return to;
|
|
17929
19846
|
};
|
|
17930
|
-
var
|
|
19847
|
+
var __commonJS2 = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
17931
19848
|
var __require2 = /* @__PURE__ */ createRequire2(import.meta.url);
|
|
17932
|
-
var require_ms =
|
|
19849
|
+
var require_ms = __commonJS2((exports, module) => {
|
|
17933
19850
|
var s = 1000;
|
|
17934
19851
|
var m = s * 60;
|
|
17935
19852
|
var h = m * 60;
|
|
@@ -18037,7 +19954,7 @@ var require_ms = __commonJS((exports, module) => {
|
|
|
18037
19954
|
return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
|
|
18038
19955
|
}
|
|
18039
19956
|
});
|
|
18040
|
-
var require_common =
|
|
19957
|
+
var require_common = __commonJS2((exports, module) => {
|
|
18041
19958
|
function setup(env) {
|
|
18042
19959
|
createDebug.debug = createDebug;
|
|
18043
19960
|
createDebug.default = createDebug;
|
|
@@ -18210,7 +20127,7 @@ var require_common = __commonJS((exports, module) => {
|
|
|
18210
20127
|
}
|
|
18211
20128
|
module.exports = setup;
|
|
18212
20129
|
});
|
|
18213
|
-
var require_browser =
|
|
20130
|
+
var require_browser = __commonJS2((exports, module) => {
|
|
18214
20131
|
exports.formatArgs = formatArgs;
|
|
18215
20132
|
exports.save = save;
|
|
18216
20133
|
exports.load = load;
|
|
@@ -18368,7 +20285,7 @@ var require_browser = __commonJS((exports, module) => {
|
|
|
18368
20285
|
}
|
|
18369
20286
|
};
|
|
18370
20287
|
});
|
|
18371
|
-
var require_node =
|
|
20288
|
+
var require_node = __commonJS2((exports, module) => {
|
|
18372
20289
|
var tty = __require2("tty");
|
|
18373
20290
|
var util = __require2("util");
|
|
18374
20291
|
exports.init = init;
|
|
@@ -18539,14 +20456,14 @@ var require_node = __commonJS((exports, module) => {
|
|
|
18539
20456
|
return util.inspect(v, this.inspectOpts);
|
|
18540
20457
|
};
|
|
18541
20458
|
});
|
|
18542
|
-
var require_src =
|
|
20459
|
+
var require_src = __commonJS2((exports, module) => {
|
|
18543
20460
|
if (typeof process === "undefined" || process.type === "renderer" || false || process.__nwjs) {
|
|
18544
20461
|
module.exports = require_browser();
|
|
18545
20462
|
} else {
|
|
18546
20463
|
module.exports = require_node();
|
|
18547
20464
|
}
|
|
18548
20465
|
});
|
|
18549
|
-
var require_src2 =
|
|
20466
|
+
var require_src2 = __commonJS2((exports) => {
|
|
18550
20467
|
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
18551
20468
|
return mod && mod.__esModule ? mod : { default: mod };
|
|
18552
20469
|
};
|
|
@@ -18554,10 +20471,10 @@ var require_src2 = __commonJS((exports) => {
|
|
|
18554
20471
|
var fs_1 = __require2("fs");
|
|
18555
20472
|
var debug_1 = __importDefault(require_src());
|
|
18556
20473
|
var log = debug_1.default("@kwsites/file-exists");
|
|
18557
|
-
function check2(
|
|
18558
|
-
log(`checking %s`,
|
|
20474
|
+
function check2(path43, isFile, isDirectory) {
|
|
20475
|
+
log(`checking %s`, path43);
|
|
18559
20476
|
try {
|
|
18560
|
-
const stat2 = fs_1.statSync(
|
|
20477
|
+
const stat2 = fs_1.statSync(path43);
|
|
18561
20478
|
if (stat2.isFile() && isFile) {
|
|
18562
20479
|
log(`[OK] path represents a file`);
|
|
18563
20480
|
return true;
|
|
@@ -18577,15 +20494,15 @@ var require_src2 = __commonJS((exports) => {
|
|
|
18577
20494
|
throw e;
|
|
18578
20495
|
}
|
|
18579
20496
|
}
|
|
18580
|
-
function exists(
|
|
18581
|
-
return check2(
|
|
20497
|
+
function exists(path43, type = exports.READABLE) {
|
|
20498
|
+
return check2(path43, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
|
|
18582
20499
|
}
|
|
18583
20500
|
exports.exists = exists;
|
|
18584
20501
|
exports.FILE = 1;
|
|
18585
20502
|
exports.FOLDER = 2;
|
|
18586
20503
|
exports.READABLE = exports.FILE + exports.FOLDER;
|
|
18587
20504
|
});
|
|
18588
|
-
var
|
|
20505
|
+
var require_dist2 = __commonJS2((exports) => {
|
|
18589
20506
|
function __export2(m) {
|
|
18590
20507
|
for (var p in m)
|
|
18591
20508
|
if (!exports.hasOwnProperty(p))
|
|
@@ -18594,7 +20511,7 @@ var require_dist = __commonJS((exports) => {
|
|
|
18594
20511
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18595
20512
|
__export2(require_src2());
|
|
18596
20513
|
});
|
|
18597
|
-
var
|
|
20514
|
+
var require_dist22 = __commonJS2((exports) => {
|
|
18598
20515
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18599
20516
|
exports.createDeferred = exports.deferred = undefined;
|
|
18600
20517
|
function deferred() {
|
|
@@ -18740,6 +20657,16 @@ var DEFAULT_HIVE_CONFIG = {
|
|
|
18740
20657
|
smartTitle: {
|
|
18741
20658
|
enabled: false,
|
|
18742
20659
|
updateThreshold: 1
|
|
20660
|
+
},
|
|
20661
|
+
agentBooster: {
|
|
20662
|
+
enabled: false,
|
|
20663
|
+
serverUrl: "http://localhost:3001",
|
|
20664
|
+
serverPort: 3001
|
|
20665
|
+
},
|
|
20666
|
+
vectorMemory: {
|
|
20667
|
+
enabled: false,
|
|
20668
|
+
indexPath: path6.join(os3.homedir(), ".config", "opencode", "hive", "vector-index"),
|
|
20669
|
+
dimensions: 384
|
|
18743
20670
|
}
|
|
18744
20671
|
};
|
|
18745
20672
|
var HIVE_DIR = ".hive";
|
|
@@ -18756,78 +20683,78 @@ function normalizePath(filePath) {
|
|
|
18756
20683
|
return filePath.replace(/\\/g, "/");
|
|
18757
20684
|
}
|
|
18758
20685
|
function getHivePath(projectRoot) {
|
|
18759
|
-
return
|
|
20686
|
+
return path22.join(projectRoot, HIVE_DIR);
|
|
18760
20687
|
}
|
|
18761
20688
|
function getFeaturesPath(projectRoot) {
|
|
18762
|
-
return
|
|
20689
|
+
return path22.join(getHivePath(projectRoot), FEATURES_DIR);
|
|
18763
20690
|
}
|
|
18764
20691
|
function getFeaturePath(projectRoot, featureName) {
|
|
18765
|
-
return
|
|
20692
|
+
return path22.join(getFeaturesPath(projectRoot), featureName);
|
|
18766
20693
|
}
|
|
18767
20694
|
function getPlanPath(projectRoot, featureName) {
|
|
18768
|
-
return
|
|
20695
|
+
return path22.join(getFeaturePath(projectRoot, featureName), PLAN_FILE);
|
|
18769
20696
|
}
|
|
18770
20697
|
function getCommentsPath(projectRoot, featureName) {
|
|
18771
|
-
return
|
|
20698
|
+
return path22.join(getFeaturePath(projectRoot, featureName), COMMENTS_FILE);
|
|
18772
20699
|
}
|
|
18773
20700
|
function getFeatureJsonPath(projectRoot, featureName) {
|
|
18774
|
-
return
|
|
20701
|
+
return path22.join(getFeaturePath(projectRoot, featureName), FEATURE_FILE);
|
|
18775
20702
|
}
|
|
18776
20703
|
function getContextPath(projectRoot, featureName) {
|
|
18777
|
-
return
|
|
20704
|
+
return path22.join(getFeaturePath(projectRoot, featureName), CONTEXT_DIR);
|
|
18778
20705
|
}
|
|
18779
20706
|
function getTasksPath(projectRoot, featureName) {
|
|
18780
|
-
return
|
|
20707
|
+
return path22.join(getFeaturePath(projectRoot, featureName), TASKS_DIR);
|
|
18781
20708
|
}
|
|
18782
20709
|
function getTaskPath(projectRoot, featureName, taskFolder) {
|
|
18783
|
-
return
|
|
20710
|
+
return path22.join(getTasksPath(projectRoot, featureName), taskFolder);
|
|
18784
20711
|
}
|
|
18785
20712
|
function getTaskStatusPath(projectRoot, featureName, taskFolder) {
|
|
18786
|
-
return
|
|
20713
|
+
return path22.join(getTaskPath(projectRoot, featureName, taskFolder), STATUS_FILE);
|
|
18787
20714
|
}
|
|
18788
20715
|
function getTaskReportPath(projectRoot, featureName, taskFolder) {
|
|
18789
|
-
return
|
|
20716
|
+
return path22.join(getTaskPath(projectRoot, featureName, taskFolder), REPORT_FILE);
|
|
18790
20717
|
}
|
|
18791
20718
|
function getTaskSpecPath(projectRoot, featureName, taskFolder) {
|
|
18792
|
-
return
|
|
20719
|
+
return path22.join(getTaskPath(projectRoot, featureName, taskFolder), "spec.md");
|
|
18793
20720
|
}
|
|
18794
20721
|
function getApprovedPath(projectRoot, featureName) {
|
|
18795
|
-
return
|
|
20722
|
+
return path22.join(getFeaturePath(projectRoot, featureName), APPROVED_FILE);
|
|
18796
20723
|
}
|
|
18797
20724
|
var SUBTASKS_DIR = "subtasks";
|
|
18798
20725
|
var SPEC_FILE = "spec.md";
|
|
18799
20726
|
function getSubtasksPath(projectRoot, featureName, taskFolder) {
|
|
18800
|
-
return
|
|
20727
|
+
return path22.join(getTaskPath(projectRoot, featureName, taskFolder), SUBTASKS_DIR);
|
|
18801
20728
|
}
|
|
18802
20729
|
function getSubtaskPath(projectRoot, featureName, taskFolder, subtaskFolder) {
|
|
18803
|
-
return
|
|
20730
|
+
return path22.join(getSubtasksPath(projectRoot, featureName, taskFolder), subtaskFolder);
|
|
18804
20731
|
}
|
|
18805
20732
|
function getSubtaskStatusPath(projectRoot, featureName, taskFolder, subtaskFolder) {
|
|
18806
|
-
return
|
|
20733
|
+
return path22.join(getSubtaskPath(projectRoot, featureName, taskFolder, subtaskFolder), STATUS_FILE);
|
|
18807
20734
|
}
|
|
18808
20735
|
function getSubtaskSpecPath(projectRoot, featureName, taskFolder, subtaskFolder) {
|
|
18809
|
-
return
|
|
20736
|
+
return path22.join(getSubtaskPath(projectRoot, featureName, taskFolder, subtaskFolder), SPEC_FILE);
|
|
18810
20737
|
}
|
|
18811
20738
|
function getSubtaskReportPath(projectRoot, featureName, taskFolder, subtaskFolder) {
|
|
18812
|
-
return
|
|
20739
|
+
return path22.join(getSubtaskPath(projectRoot, featureName, taskFolder, subtaskFolder), REPORT_FILE);
|
|
18813
20740
|
}
|
|
18814
20741
|
function ensureDir(dirPath) {
|
|
18815
|
-
if (!
|
|
18816
|
-
|
|
20742
|
+
if (!fs7.existsSync(dirPath)) {
|
|
20743
|
+
fs7.mkdirSync(dirPath, { recursive: true });
|
|
18817
20744
|
}
|
|
18818
20745
|
}
|
|
18819
20746
|
function fileExists(filePath) {
|
|
18820
|
-
return
|
|
20747
|
+
return fs7.existsSync(filePath);
|
|
18821
20748
|
}
|
|
18822
20749
|
function readJson(filePath) {
|
|
18823
|
-
if (!
|
|
20750
|
+
if (!fs7.existsSync(filePath))
|
|
18824
20751
|
return null;
|
|
18825
|
-
const content =
|
|
20752
|
+
const content = fs7.readFileSync(filePath, "utf-8");
|
|
18826
20753
|
return JSON.parse(content);
|
|
18827
20754
|
}
|
|
18828
20755
|
function writeJson(filePath, data) {
|
|
18829
|
-
ensureDir(
|
|
18830
|
-
|
|
20756
|
+
ensureDir(path22.dirname(filePath));
|
|
20757
|
+
fs7.writeFileSync(filePath, JSON.stringify(data, null, 2));
|
|
18831
20758
|
}
|
|
18832
20759
|
var DEFAULT_LOCK_OPTIONS = {
|
|
18833
20760
|
timeout: 5000,
|
|
@@ -18839,7 +20766,7 @@ function getLockPath(filePath) {
|
|
|
18839
20766
|
}
|
|
18840
20767
|
function isLockStale(lockPath, staleTTL) {
|
|
18841
20768
|
try {
|
|
18842
|
-
const stat2 =
|
|
20769
|
+
const stat2 = fs7.statSync(lockPath);
|
|
18843
20770
|
const age = Date.now() - stat2.mtimeMs;
|
|
18844
20771
|
return age > staleTTL;
|
|
18845
20772
|
} catch {
|
|
@@ -18849,7 +20776,7 @@ function isLockStale(lockPath, staleTTL) {
|
|
|
18849
20776
|
function acquireLockSync(filePath, options = {}) {
|
|
18850
20777
|
const opts = { ...DEFAULT_LOCK_OPTIONS, ...options };
|
|
18851
20778
|
const lockPath = getLockPath(filePath);
|
|
18852
|
-
const lockDir =
|
|
20779
|
+
const lockDir = path22.dirname(lockPath);
|
|
18853
20780
|
const startTime = Date.now();
|
|
18854
20781
|
const lockContent = JSON.stringify({
|
|
18855
20782
|
pid: process.pid,
|
|
@@ -18859,12 +20786,12 @@ function acquireLockSync(filePath, options = {}) {
|
|
|
18859
20786
|
ensureDir(lockDir);
|
|
18860
20787
|
while (true) {
|
|
18861
20788
|
try {
|
|
18862
|
-
const fd =
|
|
18863
|
-
|
|
18864
|
-
|
|
20789
|
+
const fd = fs7.openSync(lockPath, fs7.constants.O_CREAT | fs7.constants.O_EXCL | fs7.constants.O_WRONLY);
|
|
20790
|
+
fs7.writeSync(fd, lockContent);
|
|
20791
|
+
fs7.closeSync(fd);
|
|
18865
20792
|
return () => {
|
|
18866
20793
|
try {
|
|
18867
|
-
|
|
20794
|
+
fs7.unlinkSync(lockPath);
|
|
18868
20795
|
} catch {}
|
|
18869
20796
|
};
|
|
18870
20797
|
} catch (err) {
|
|
@@ -18874,7 +20801,7 @@ function acquireLockSync(filePath, options = {}) {
|
|
|
18874
20801
|
} else if (error45.code === "EEXIST") {
|
|
18875
20802
|
if (isLockStale(lockPath, opts.staleLockTTL)) {
|
|
18876
20803
|
try {
|
|
18877
|
-
|
|
20804
|
+
fs7.unlinkSync(lockPath);
|
|
18878
20805
|
continue;
|
|
18879
20806
|
} catch {}
|
|
18880
20807
|
}
|
|
@@ -18890,14 +20817,14 @@ function acquireLockSync(filePath, options = {}) {
|
|
|
18890
20817
|
}
|
|
18891
20818
|
}
|
|
18892
20819
|
function writeAtomic(filePath, content) {
|
|
18893
|
-
ensureDir(
|
|
20820
|
+
ensureDir(path22.dirname(filePath));
|
|
18894
20821
|
const tempPath = `${filePath}.tmp.${process.pid}.${Date.now()}`;
|
|
18895
20822
|
try {
|
|
18896
|
-
|
|
18897
|
-
|
|
20823
|
+
fs7.writeFileSync(tempPath, content);
|
|
20824
|
+
fs7.renameSync(tempPath, filePath);
|
|
18898
20825
|
} catch (error45) {
|
|
18899
20826
|
try {
|
|
18900
|
-
|
|
20827
|
+
fs7.unlinkSync(tempPath);
|
|
18901
20828
|
} catch {}
|
|
18902
20829
|
throw error45;
|
|
18903
20830
|
}
|
|
@@ -18932,13 +20859,13 @@ function patchJsonLockedSync(filePath, patch, options = {}) {
|
|
|
18932
20859
|
}
|
|
18933
20860
|
}
|
|
18934
20861
|
function readText(filePath) {
|
|
18935
|
-
if (!
|
|
20862
|
+
if (!fs7.existsSync(filePath))
|
|
18936
20863
|
return null;
|
|
18937
|
-
return
|
|
20864
|
+
return fs7.readFileSync(filePath, "utf-8");
|
|
18938
20865
|
}
|
|
18939
20866
|
function writeText(filePath, content) {
|
|
18940
|
-
ensureDir(
|
|
18941
|
-
|
|
20867
|
+
ensureDir(path22.dirname(filePath));
|
|
20868
|
+
fs7.writeFileSync(filePath, content);
|
|
18942
20869
|
}
|
|
18943
20870
|
function detectContext(cwd) {
|
|
18944
20871
|
const result = {
|
|
@@ -18958,7 +20885,7 @@ function detectContext(cwd) {
|
|
|
18958
20885
|
result.projectRoot = worktreeMatch[1];
|
|
18959
20886
|
return result;
|
|
18960
20887
|
}
|
|
18961
|
-
const gitPath =
|
|
20888
|
+
const gitPath = path32.join(cwd, ".git");
|
|
18962
20889
|
if (fs22.existsSync(gitPath)) {
|
|
18963
20890
|
const stat2 = fs22.statSync(gitPath);
|
|
18964
20891
|
if (stat2.isFile()) {
|
|
@@ -19134,7 +21061,7 @@ class PlanService {
|
|
|
19134
21061
|
}
|
|
19135
21062
|
const approvedPath = getApprovedPath(this.projectRoot, featureName);
|
|
19136
21063
|
const timestamp = new Date().toISOString();
|
|
19137
|
-
|
|
21064
|
+
fs42.writeFileSync(approvedPath, `Approved at ${timestamp}
|
|
19138
21065
|
`);
|
|
19139
21066
|
const featurePath = getFeatureJsonPath(this.projectRoot, featureName);
|
|
19140
21067
|
const feature = readJson(featurePath);
|
|
@@ -19150,7 +21077,7 @@ class PlanService {
|
|
|
19150
21077
|
revokeApproval(featureName) {
|
|
19151
21078
|
const approvedPath = getApprovedPath(this.projectRoot, featureName);
|
|
19152
21079
|
if (fileExists(approvedPath)) {
|
|
19153
|
-
|
|
21080
|
+
fs42.unlinkSync(approvedPath);
|
|
19154
21081
|
}
|
|
19155
21082
|
const featurePath = getFeatureJsonPath(this.projectRoot, featureName);
|
|
19156
21083
|
const feature = readJson(featurePath);
|
|
@@ -19396,20 +21323,20 @@ ${f.content}`).join(`
|
|
|
19396
21323
|
return [task.order - 1];
|
|
19397
21324
|
};
|
|
19398
21325
|
const visited = new Map;
|
|
19399
|
-
const
|
|
21326
|
+
const path43 = [];
|
|
19400
21327
|
const dfs = (taskOrder) => {
|
|
19401
21328
|
const state = visited.get(taskOrder);
|
|
19402
21329
|
if (state === 2) {
|
|
19403
21330
|
return;
|
|
19404
21331
|
}
|
|
19405
21332
|
if (state === 1) {
|
|
19406
|
-
const cycleStart =
|
|
19407
|
-
const cyclePath = [...
|
|
21333
|
+
const cycleStart = path43.indexOf(taskOrder);
|
|
21334
|
+
const cyclePath = [...path43.slice(cycleStart), taskOrder];
|
|
19408
21335
|
const cycleDesc = cyclePath.join(" -> ");
|
|
19409
21336
|
throw new Error(`Invalid dependency graph in plan.md: Cycle detected in task dependencies: ${cycleDesc}. ` + `Tasks cannot have circular dependencies. Please fix the "Depends on:" lines in plan.md.`);
|
|
19410
21337
|
}
|
|
19411
21338
|
visited.set(taskOrder, 1);
|
|
19412
|
-
|
|
21339
|
+
path43.push(taskOrder);
|
|
19413
21340
|
const task = taskByOrder.get(taskOrder);
|
|
19414
21341
|
if (task) {
|
|
19415
21342
|
const deps = getDependencies(task);
|
|
@@ -19417,7 +21344,7 @@ ${f.content}`).join(`
|
|
|
19417
21344
|
dfs(depOrder);
|
|
19418
21345
|
}
|
|
19419
21346
|
}
|
|
19420
|
-
|
|
21347
|
+
path43.pop();
|
|
19421
21348
|
visited.set(taskOrder, 2);
|
|
19422
21349
|
};
|
|
19423
21350
|
for (const task of tasks) {
|
|
@@ -19503,12 +21430,12 @@ ${f.content}`).join(`
|
|
|
19503
21430
|
const tasksPath = getTasksPath(this.projectRoot, featureName);
|
|
19504
21431
|
if (!fileExists(tasksPath))
|
|
19505
21432
|
return [];
|
|
19506
|
-
return
|
|
21433
|
+
return fs52.readdirSync(tasksPath, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name).sort();
|
|
19507
21434
|
}
|
|
19508
21435
|
deleteTask(featureName, taskFolder) {
|
|
19509
21436
|
const taskPath = getTaskPath(this.projectRoot, featureName, taskFolder);
|
|
19510
21437
|
if (fileExists(taskPath)) {
|
|
19511
|
-
|
|
21438
|
+
fs52.rmSync(taskPath, { recursive: true });
|
|
19512
21439
|
}
|
|
19513
21440
|
}
|
|
19514
21441
|
getNextOrder(existingFolders) {
|
|
@@ -19660,7 +21587,7 @@ _Add detailed instructions here_
|
|
|
19660
21587
|
}
|
|
19661
21588
|
const subtaskPath = getSubtaskPath(this.projectRoot, featureName, taskFolder, subtaskFolder);
|
|
19662
21589
|
if (fileExists(subtaskPath)) {
|
|
19663
|
-
|
|
21590
|
+
fs52.rmSync(subtaskPath, { recursive: true });
|
|
19664
21591
|
}
|
|
19665
21592
|
}
|
|
19666
21593
|
getSubtask(featureName, taskFolder, subtaskId) {
|
|
@@ -19720,7 +21647,7 @@ _Add detailed instructions here_
|
|
|
19720
21647
|
const subtasksPath = getSubtasksPath(this.projectRoot, featureName, taskFolder);
|
|
19721
21648
|
if (!fileExists(subtasksPath))
|
|
19722
21649
|
return [];
|
|
19723
|
-
return
|
|
21650
|
+
return fs52.readdirSync(subtasksPath, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name).sort();
|
|
19724
21651
|
}
|
|
19725
21652
|
findSubtaskFolder(featureName, taskFolder, subtaskId) {
|
|
19726
21653
|
const folders = this.listSubtaskFolders(featureName, taskFolder);
|
|
@@ -19731,19 +21658,19 @@ _Add detailed instructions here_
|
|
|
19731
21658
|
return name.toLowerCase().replace(/\s+/g, "-").replace(/[^a-z0-9-]/g, "");
|
|
19732
21659
|
}
|
|
19733
21660
|
}
|
|
19734
|
-
var import_file_exists =
|
|
19735
|
-
var import_debug =
|
|
19736
|
-
var import_promise_deferred =
|
|
19737
|
-
var import_promise_deferred2 =
|
|
21661
|
+
var import_file_exists = __toESM2(require_dist2(), 1);
|
|
21662
|
+
var import_debug = __toESM2(require_src(), 1);
|
|
21663
|
+
var import_promise_deferred = __toESM2(require_dist22(), 1);
|
|
21664
|
+
var import_promise_deferred2 = __toESM2(require_dist22(), 1);
|
|
19738
21665
|
var __defProp22 = Object.defineProperty;
|
|
19739
21666
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
19740
|
-
var
|
|
19741
|
-
var
|
|
21667
|
+
var __getOwnPropNames22 = Object.getOwnPropertyNames;
|
|
21668
|
+
var __hasOwnProp22 = Object.prototype.hasOwnProperty;
|
|
19742
21669
|
var __esm2 = (fn, res) => function __init() {
|
|
19743
|
-
return fn && (res = (0, fn[
|
|
21670
|
+
return fn && (res = (0, fn[__getOwnPropNames22(fn)[0]])(fn = 0)), res;
|
|
19744
21671
|
};
|
|
19745
|
-
var
|
|
19746
|
-
return mod || (0, cb[
|
|
21672
|
+
var __commonJS22 = (cb, mod) => function __require22() {
|
|
21673
|
+
return mod || (0, cb[__getOwnPropNames22(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
19747
21674
|
};
|
|
19748
21675
|
var __export2 = (target, all) => {
|
|
19749
21676
|
for (var name in all)
|
|
@@ -19751,8 +21678,8 @@ var __export2 = (target, all) => {
|
|
|
19751
21678
|
};
|
|
19752
21679
|
var __copyProps = (to, from, except, desc) => {
|
|
19753
21680
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
19754
|
-
for (let key of
|
|
19755
|
-
if (!
|
|
21681
|
+
for (let key of __getOwnPropNames22(from))
|
|
21682
|
+
if (!__hasOwnProp22.call(to, key) && key !== except)
|
|
19756
21683
|
__defProp22(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19757
21684
|
}
|
|
19758
21685
|
return to;
|
|
@@ -19763,8 +21690,8 @@ function pathspec(...paths) {
|
|
|
19763
21690
|
cache.set(key, paths);
|
|
19764
21691
|
return key;
|
|
19765
21692
|
}
|
|
19766
|
-
function isPathSpec(
|
|
19767
|
-
return
|
|
21693
|
+
function isPathSpec(path43) {
|
|
21694
|
+
return path43 instanceof String && cache.has(path43);
|
|
19768
21695
|
}
|
|
19769
21696
|
function toPaths(pathSpec) {
|
|
19770
21697
|
return cache.get(pathSpec) || [];
|
|
@@ -19850,8 +21777,8 @@ function toLinesWithContent(input = "", trimmed2 = true, separator = `
|
|
|
19850
21777
|
function forEachLineWithContent(input, callback) {
|
|
19851
21778
|
return toLinesWithContent(input, true).map((line) => callback(line));
|
|
19852
21779
|
}
|
|
19853
|
-
function folderExists(
|
|
19854
|
-
return import_file_exists.exists(
|
|
21780
|
+
function folderExists(path43) {
|
|
21781
|
+
return import_file_exists.exists(path43, import_file_exists.FOLDER);
|
|
19855
21782
|
}
|
|
19856
21783
|
function append(target, item) {
|
|
19857
21784
|
if (Array.isArray(target)) {
|
|
@@ -20242,8 +22169,8 @@ function checkIsRepoRootTask() {
|
|
|
20242
22169
|
commands,
|
|
20243
22170
|
format: "utf-8",
|
|
20244
22171
|
onError,
|
|
20245
|
-
parser(
|
|
20246
|
-
return /^\.(git)?$/.test(
|
|
22172
|
+
parser(path43) {
|
|
22173
|
+
return /^\.(git)?$/.test(path43.trim());
|
|
20247
22174
|
}
|
|
20248
22175
|
};
|
|
20249
22176
|
}
|
|
@@ -20654,11 +22581,11 @@ function parseGrep(grep) {
|
|
|
20654
22581
|
const paths = /* @__PURE__ */ new Set;
|
|
20655
22582
|
const results = {};
|
|
20656
22583
|
forEachLineWithContent(grep, (input) => {
|
|
20657
|
-
const [
|
|
20658
|
-
paths.add(
|
|
20659
|
-
(results[
|
|
22584
|
+
const [path43, line, preview] = input.split(NULL);
|
|
22585
|
+
paths.add(path43);
|
|
22586
|
+
(results[path43] = results[path43] || []).push({
|
|
20660
22587
|
line: asNumber(line),
|
|
20661
|
-
path:
|
|
22588
|
+
path: path43,
|
|
20662
22589
|
preview
|
|
20663
22590
|
});
|
|
20664
22591
|
});
|
|
@@ -21324,14 +23251,14 @@ var init_hash_object = __esm2({
|
|
|
21324
23251
|
init_task();
|
|
21325
23252
|
}
|
|
21326
23253
|
});
|
|
21327
|
-
function parseInit(bare,
|
|
23254
|
+
function parseInit(bare, path43, text) {
|
|
21328
23255
|
const response = String(text).trim();
|
|
21329
23256
|
let result;
|
|
21330
23257
|
if (result = initResponseRegex.exec(response)) {
|
|
21331
|
-
return new InitSummary(bare,
|
|
23258
|
+
return new InitSummary(bare, path43, false, result[1]);
|
|
21332
23259
|
}
|
|
21333
23260
|
if (result = reInitResponseRegex.exec(response)) {
|
|
21334
|
-
return new InitSummary(bare,
|
|
23261
|
+
return new InitSummary(bare, path43, true, result[1]);
|
|
21335
23262
|
}
|
|
21336
23263
|
let gitDir = "";
|
|
21337
23264
|
const tokens = response.split(" ");
|
|
@@ -21342,7 +23269,7 @@ function parseInit(bare, path33, text) {
|
|
|
21342
23269
|
break;
|
|
21343
23270
|
}
|
|
21344
23271
|
}
|
|
21345
|
-
return new InitSummary(bare,
|
|
23272
|
+
return new InitSummary(bare, path43, /^re/i.test(response), gitDir);
|
|
21346
23273
|
}
|
|
21347
23274
|
var InitSummary;
|
|
21348
23275
|
var initResponseRegex;
|
|
@@ -21350,9 +23277,9 @@ var reInitResponseRegex;
|
|
|
21350
23277
|
var init_InitSummary = __esm2({
|
|
21351
23278
|
"src/lib/responses/InitSummary.ts"() {
|
|
21352
23279
|
InitSummary = class {
|
|
21353
|
-
constructor(bare,
|
|
23280
|
+
constructor(bare, path43, existing, gitDir) {
|
|
21354
23281
|
this.bare = bare;
|
|
21355
|
-
this.path =
|
|
23282
|
+
this.path = path43;
|
|
21356
23283
|
this.existing = existing;
|
|
21357
23284
|
this.gitDir = gitDir;
|
|
21358
23285
|
}
|
|
@@ -21364,7 +23291,7 @@ var init_InitSummary = __esm2({
|
|
|
21364
23291
|
function hasBareCommand(command) {
|
|
21365
23292
|
return command.includes(bareCommand);
|
|
21366
23293
|
}
|
|
21367
|
-
function initTask(bare = false,
|
|
23294
|
+
function initTask(bare = false, path43, customArgs) {
|
|
21368
23295
|
const commands = ["init", ...customArgs];
|
|
21369
23296
|
if (bare && !hasBareCommand(commands)) {
|
|
21370
23297
|
commands.splice(1, 0, bareCommand);
|
|
@@ -21373,7 +23300,7 @@ function initTask(bare = false, path33, customArgs) {
|
|
|
21373
23300
|
commands,
|
|
21374
23301
|
format: "utf-8",
|
|
21375
23302
|
parser(text) {
|
|
21376
|
-
return parseInit(commands.includes("--bare"),
|
|
23303
|
+
return parseInit(commands.includes("--bare"), path43, text);
|
|
21377
23304
|
}
|
|
21378
23305
|
};
|
|
21379
23306
|
}
|
|
@@ -22088,12 +24015,12 @@ var init_FileStatusSummary = __esm2({
|
|
|
22088
24015
|
"src/lib/responses/FileStatusSummary.ts"() {
|
|
22089
24016
|
fromPathRegex = /^(.+)\0(.+)$/;
|
|
22090
24017
|
FileStatusSummary = class {
|
|
22091
|
-
constructor(
|
|
22092
|
-
this.path =
|
|
24018
|
+
constructor(path43, index, working_dir) {
|
|
24019
|
+
this.path = path43;
|
|
22093
24020
|
this.index = index;
|
|
22094
24021
|
this.working_dir = working_dir;
|
|
22095
24022
|
if (index === "R" || working_dir === "R") {
|
|
22096
|
-
const detail = fromPathRegex.exec(
|
|
24023
|
+
const detail = fromPathRegex.exec(path43) || [null, path43, path43];
|
|
22097
24024
|
this.from = detail[2] || "";
|
|
22098
24025
|
this.path = detail[1] || "";
|
|
22099
24026
|
}
|
|
@@ -22124,14 +24051,14 @@ function splitLine(result, lineStr) {
|
|
|
22124
24051
|
default:
|
|
22125
24052
|
return;
|
|
22126
24053
|
}
|
|
22127
|
-
function data(index, workingDir,
|
|
24054
|
+
function data(index, workingDir, path43) {
|
|
22128
24055
|
const raw = `${index}${workingDir}`;
|
|
22129
24056
|
const handler = parsers6.get(raw);
|
|
22130
24057
|
if (handler) {
|
|
22131
|
-
handler(result,
|
|
24058
|
+
handler(result, path43);
|
|
22132
24059
|
}
|
|
22133
24060
|
if (raw !== "##" && raw !== "!!") {
|
|
22134
|
-
result.files.push(new FileStatusSummary(
|
|
24061
|
+
result.files.push(new FileStatusSummary(path43, index, workingDir));
|
|
22135
24062
|
}
|
|
22136
24063
|
}
|
|
22137
24064
|
}
|
|
@@ -22415,8 +24342,8 @@ var init_simple_git_api = __esm2({
|
|
|
22415
24342
|
}
|
|
22416
24343
|
return this._runTask(configurationErrorTask("Git.cwd: workingDirectory must be supplied as a string"), next);
|
|
22417
24344
|
}
|
|
22418
|
-
hashObject(
|
|
22419
|
-
return this._runTask(hashObjectTask(
|
|
24345
|
+
hashObject(path43, write) {
|
|
24346
|
+
return this._runTask(hashObjectTask(path43, write === true), trailingFunctionArgument(arguments));
|
|
22420
24347
|
}
|
|
22421
24348
|
init(bare) {
|
|
22422
24349
|
return this._runTask(initTask(bare === true, this._executor.cwd, getTrailingOptions(arguments)), trailingFunctionArgument(arguments));
|
|
@@ -22709,8 +24636,8 @@ var init_branch = __esm2({
|
|
|
22709
24636
|
}
|
|
22710
24637
|
});
|
|
22711
24638
|
function toPath(input) {
|
|
22712
|
-
const
|
|
22713
|
-
return
|
|
24639
|
+
const path43 = input.trim().replace(/^["']|["']$/g, "");
|
|
24640
|
+
return path43 && normalize(path43);
|
|
22714
24641
|
}
|
|
22715
24642
|
var parseCheckIgnore;
|
|
22716
24643
|
var init_CheckIgnore = __esm2({
|
|
@@ -22975,8 +24902,8 @@ __export2(sub_module_exports, {
|
|
|
22975
24902
|
subModuleTask: () => subModuleTask,
|
|
22976
24903
|
updateSubModuleTask: () => updateSubModuleTask
|
|
22977
24904
|
});
|
|
22978
|
-
function addSubModuleTask(repo,
|
|
22979
|
-
return subModuleTask(["add", repo,
|
|
24905
|
+
function addSubModuleTask(repo, path43) {
|
|
24906
|
+
return subModuleTask(["add", repo, path43]);
|
|
22980
24907
|
}
|
|
22981
24908
|
function initSubModuleTask(customArgs) {
|
|
22982
24909
|
return subModuleTask(["init", ...customArgs]);
|
|
@@ -23089,7 +25016,7 @@ var init_tag = __esm2({
|
|
|
23089
25016
|
init_TagList();
|
|
23090
25017
|
}
|
|
23091
25018
|
});
|
|
23092
|
-
var require_git =
|
|
25019
|
+
var require_git = __commonJS22({
|
|
23093
25020
|
"src/git.js"(exports, module) {
|
|
23094
25021
|
var { GitExecutor: GitExecutor2 } = (init_git_executor(), __toCommonJS(git_executor_exports));
|
|
23095
25022
|
var { SimpleGitApi: SimpleGitApi2 } = (init_simple_git_api(), __toCommonJS(simple_git_api_exports));
|
|
@@ -23230,8 +25157,8 @@ var require_git = __commonJS2({
|
|
|
23230
25157
|
}
|
|
23231
25158
|
return this._runTask(straightThroughStringTask2(command, this._trimmed), next);
|
|
23232
25159
|
};
|
|
23233
|
-
Git2.prototype.submoduleAdd = function(repo,
|
|
23234
|
-
return this._runTask(addSubModuleTask2(repo,
|
|
25160
|
+
Git2.prototype.submoduleAdd = function(repo, path43, then) {
|
|
25161
|
+
return this._runTask(addSubModuleTask2(repo, path43), trailingFunctionArgument2(arguments));
|
|
23235
25162
|
};
|
|
23236
25163
|
Git2.prototype.submoduleUpdate = function(args2, then) {
|
|
23237
25164
|
return this._runTask(updateSubModuleTask2(getTrailingOptions2(arguments, true)), trailingFunctionArgument2(arguments));
|
|
@@ -23764,19 +25691,19 @@ class WorktreeService {
|
|
|
23764
25691
|
return esm_default(cwd || this.config.baseDir);
|
|
23765
25692
|
}
|
|
23766
25693
|
getWorktreesDir() {
|
|
23767
|
-
return
|
|
25694
|
+
return path42.join(this.config.hiveDir, ".worktrees");
|
|
23768
25695
|
}
|
|
23769
25696
|
getWorktreePath(feature, step) {
|
|
23770
|
-
return
|
|
25697
|
+
return path42.join(this.getWorktreesDir(), feature, step);
|
|
23771
25698
|
}
|
|
23772
25699
|
async getStepStatusPath(feature, step) {
|
|
23773
|
-
const featurePath =
|
|
23774
|
-
const tasksPath =
|
|
25700
|
+
const featurePath = path42.join(this.config.hiveDir, "features", feature);
|
|
25701
|
+
const tasksPath = path42.join(featurePath, "tasks", step, "status.json");
|
|
23775
25702
|
try {
|
|
23776
|
-
await
|
|
25703
|
+
await fs72.access(tasksPath);
|
|
23777
25704
|
return tasksPath;
|
|
23778
25705
|
} catch {}
|
|
23779
|
-
return
|
|
25706
|
+
return path42.join(featurePath, "execution", step, "status.json");
|
|
23780
25707
|
}
|
|
23781
25708
|
getBranchName(feature, step) {
|
|
23782
25709
|
return `hive/${feature}/${step}`;
|
|
@@ -23785,7 +25712,7 @@ class WorktreeService {
|
|
|
23785
25712
|
const worktreePath = this.getWorktreePath(feature, step);
|
|
23786
25713
|
const branchName = this.getBranchName(feature, step);
|
|
23787
25714
|
const git = this.getGit();
|
|
23788
|
-
await
|
|
25715
|
+
await fs72.mkdir(path42.dirname(worktreePath), { recursive: true });
|
|
23789
25716
|
const base = baseBranch || (await git.revparse(["HEAD"])).trim();
|
|
23790
25717
|
const existing = await this.get(feature, step);
|
|
23791
25718
|
if (existing) {
|
|
@@ -23814,7 +25741,7 @@ class WorktreeService {
|
|
|
23814
25741
|
const worktreePath = this.getWorktreePath(feature, step);
|
|
23815
25742
|
const branchName = this.getBranchName(feature, step);
|
|
23816
25743
|
try {
|
|
23817
|
-
await
|
|
25744
|
+
await fs72.access(worktreePath);
|
|
23818
25745
|
const worktreeGit = this.getGit(worktreePath);
|
|
23819
25746
|
const commit = (await worktreeGit.revparse(["HEAD"])).trim();
|
|
23820
25747
|
return {
|
|
@@ -23834,7 +25761,7 @@ class WorktreeService {
|
|
|
23834
25761
|
let base = baseCommit;
|
|
23835
25762
|
if (!base) {
|
|
23836
25763
|
try {
|
|
23837
|
-
const status = JSON.parse(await
|
|
25764
|
+
const status = JSON.parse(await fs72.readFile(statusPath, "utf-8"));
|
|
23838
25765
|
base = status.baseCommit;
|
|
23839
25766
|
} catch {}
|
|
23840
25767
|
}
|
|
@@ -23880,11 +25807,11 @@ class WorktreeService {
|
|
|
23880
25807
|
}
|
|
23881
25808
|
async exportPatch(feature, step, baseBranch) {
|
|
23882
25809
|
const worktreePath = this.getWorktreePath(feature, step);
|
|
23883
|
-
const patchPath =
|
|
25810
|
+
const patchPath = path42.join(worktreePath, "..", `${step}.patch`);
|
|
23884
25811
|
const base = baseBranch || "HEAD~1";
|
|
23885
25812
|
const worktreeGit = this.getGit(worktreePath);
|
|
23886
25813
|
const diff = await worktreeGit.diff([`${base}...HEAD`]);
|
|
23887
|
-
await
|
|
25814
|
+
await fs72.writeFile(patchPath, diff);
|
|
23888
25815
|
return patchPath;
|
|
23889
25816
|
}
|
|
23890
25817
|
async applyDiff(feature, step, baseBranch) {
|
|
@@ -23892,15 +25819,15 @@ class WorktreeService {
|
|
|
23892
25819
|
if (!hasDiff) {
|
|
23893
25820
|
return { success: true, filesAffected: [] };
|
|
23894
25821
|
}
|
|
23895
|
-
const patchPath =
|
|
25822
|
+
const patchPath = path42.join(this.config.hiveDir, ".worktrees", feature, `${step}.patch`);
|
|
23896
25823
|
try {
|
|
23897
|
-
await
|
|
25824
|
+
await fs72.writeFile(patchPath, diffContent);
|
|
23898
25825
|
const git = this.getGit();
|
|
23899
25826
|
await git.applyPatch(patchPath);
|
|
23900
|
-
await
|
|
25827
|
+
await fs72.unlink(patchPath).catch(() => {});
|
|
23901
25828
|
return { success: true, filesAffected: filesChanged };
|
|
23902
25829
|
} catch (error45) {
|
|
23903
|
-
await
|
|
25830
|
+
await fs72.unlink(patchPath).catch(() => {});
|
|
23904
25831
|
const err = error45;
|
|
23905
25832
|
return {
|
|
23906
25833
|
success: false,
|
|
@@ -23914,15 +25841,15 @@ class WorktreeService {
|
|
|
23914
25841
|
if (!hasDiff) {
|
|
23915
25842
|
return { success: true, filesAffected: [] };
|
|
23916
25843
|
}
|
|
23917
|
-
const patchPath =
|
|
25844
|
+
const patchPath = path42.join(this.config.hiveDir, ".worktrees", feature, `${step}.patch`);
|
|
23918
25845
|
try {
|
|
23919
|
-
await
|
|
25846
|
+
await fs72.writeFile(patchPath, diffContent);
|
|
23920
25847
|
const git = this.getGit();
|
|
23921
25848
|
await git.applyPatch(patchPath, ["-R"]);
|
|
23922
|
-
await
|
|
25849
|
+
await fs72.unlink(patchPath).catch(() => {});
|
|
23923
25850
|
return { success: true, filesAffected: filesChanged };
|
|
23924
25851
|
} catch (error45) {
|
|
23925
|
-
await
|
|
25852
|
+
await fs72.unlink(patchPath).catch(() => {});
|
|
23926
25853
|
const err = error45;
|
|
23927
25854
|
return {
|
|
23928
25855
|
success: false,
|
|
@@ -23941,7 +25868,7 @@ class WorktreeService {
|
|
|
23941
25868
|
return [...new Set(files)];
|
|
23942
25869
|
}
|
|
23943
25870
|
async revertFromSavedDiff(diffPath) {
|
|
23944
|
-
const diffContent = await
|
|
25871
|
+
const diffContent = await fs72.readFile(diffPath, "utf-8");
|
|
23945
25872
|
if (!diffContent.trim()) {
|
|
23946
25873
|
return { success: true, filesAffected: [] };
|
|
23947
25874
|
}
|
|
@@ -23966,7 +25893,7 @@ class WorktreeService {
|
|
|
23966
25893
|
try {
|
|
23967
25894
|
await git.raw(["worktree", "remove", worktreePath, "--force"]);
|
|
23968
25895
|
} catch {
|
|
23969
|
-
await
|
|
25896
|
+
await fs72.rm(worktreePath, { recursive: true, force: true });
|
|
23970
25897
|
}
|
|
23971
25898
|
try {
|
|
23972
25899
|
await git.raw(["worktree", "prune"]);
|
|
@@ -23981,13 +25908,13 @@ class WorktreeService {
|
|
|
23981
25908
|
const worktreesDir = this.getWorktreesDir();
|
|
23982
25909
|
const results = [];
|
|
23983
25910
|
try {
|
|
23984
|
-
const features = feature ? [feature] : await
|
|
25911
|
+
const features = feature ? [feature] : await fs72.readdir(worktreesDir);
|
|
23985
25912
|
for (const feat of features) {
|
|
23986
|
-
const featurePath =
|
|
23987
|
-
const stat2 = await
|
|
25913
|
+
const featurePath = path42.join(worktreesDir, feat);
|
|
25914
|
+
const stat2 = await fs72.stat(featurePath).catch(() => null);
|
|
23988
25915
|
if (!stat2?.isDirectory())
|
|
23989
25916
|
continue;
|
|
23990
|
-
const steps = await
|
|
25917
|
+
const steps = await fs72.readdir(featurePath).catch(() => []);
|
|
23991
25918
|
for (const step of steps) {
|
|
23992
25919
|
const info = await this.get(feat, step);
|
|
23993
25920
|
if (info) {
|
|
@@ -24005,16 +25932,16 @@ class WorktreeService {
|
|
|
24005
25932
|
await git.raw(["worktree", "prune"]);
|
|
24006
25933
|
} catch {}
|
|
24007
25934
|
const worktreesDir = this.getWorktreesDir();
|
|
24008
|
-
const features = feature ? [feature] : await
|
|
25935
|
+
const features = feature ? [feature] : await fs72.readdir(worktreesDir).catch(() => []);
|
|
24009
25936
|
for (const feat of features) {
|
|
24010
|
-
const featurePath =
|
|
24011
|
-
const stat2 = await
|
|
25937
|
+
const featurePath = path42.join(worktreesDir, feat);
|
|
25938
|
+
const stat2 = await fs72.stat(featurePath).catch(() => null);
|
|
24012
25939
|
if (!stat2?.isDirectory())
|
|
24013
25940
|
continue;
|
|
24014
|
-
const steps = await
|
|
25941
|
+
const steps = await fs72.readdir(featurePath).catch(() => []);
|
|
24015
25942
|
for (const step of steps) {
|
|
24016
|
-
const worktreePath =
|
|
24017
|
-
const stepStat = await
|
|
25943
|
+
const worktreePath = path42.join(featurePath, step);
|
|
25944
|
+
const stepStat = await fs72.stat(worktreePath).catch(() => null);
|
|
24018
25945
|
if (!stepStat?.isDirectory())
|
|
24019
25946
|
continue;
|
|
24020
25947
|
try {
|
|
@@ -24033,15 +25960,15 @@ class WorktreeService {
|
|
|
24033
25960
|
if (!hasDiff) {
|
|
24034
25961
|
return [];
|
|
24035
25962
|
}
|
|
24036
|
-
const patchPath =
|
|
25963
|
+
const patchPath = path42.join(this.config.hiveDir, ".worktrees", feature, `${step}-check.patch`);
|
|
24037
25964
|
try {
|
|
24038
|
-
await
|
|
25965
|
+
await fs72.writeFile(patchPath, diffContent);
|
|
24039
25966
|
const git = this.getGit();
|
|
24040
25967
|
await git.applyPatch(patchPath, ["--check"]);
|
|
24041
|
-
await
|
|
25968
|
+
await fs72.unlink(patchPath).catch(() => {});
|
|
24042
25969
|
return [];
|
|
24043
25970
|
} catch (error45) {
|
|
24044
|
-
await
|
|
25971
|
+
await fs72.unlink(patchPath).catch(() => {});
|
|
24045
25972
|
const err = error45;
|
|
24046
25973
|
const stderr = err.message || "";
|
|
24047
25974
|
const conflicts2 = stderr.split(`
|
|
@@ -24054,7 +25981,7 @@ class WorktreeService {
|
|
|
24054
25981
|
}
|
|
24055
25982
|
async checkConflictsFromSavedDiff(diffPath, reverse = false) {
|
|
24056
25983
|
try {
|
|
24057
|
-
await
|
|
25984
|
+
await fs72.access(diffPath);
|
|
24058
25985
|
} catch {
|
|
24059
25986
|
return [];
|
|
24060
25987
|
}
|
|
@@ -24077,7 +26004,7 @@ class WorktreeService {
|
|
|
24077
26004
|
async commitChanges(feature, step, message) {
|
|
24078
26005
|
const worktreePath = this.getWorktreePath(feature, step);
|
|
24079
26006
|
try {
|
|
24080
|
-
await
|
|
26007
|
+
await fs72.access(worktreePath);
|
|
24081
26008
|
} catch {
|
|
24082
26009
|
return { committed: false, sha: "", message: "Worktree not found" };
|
|
24083
26010
|
}
|
|
@@ -24204,7 +26131,7 @@ class ContextService {
|
|
|
24204
26131
|
write(featureName, fileName, content) {
|
|
24205
26132
|
const contextPath = getContextPath(this.projectRoot, featureName);
|
|
24206
26133
|
ensureDir(contextPath);
|
|
24207
|
-
const filePath =
|
|
26134
|
+
const filePath = path52.join(contextPath, this.normalizeFileName(fileName));
|
|
24208
26135
|
writeText(filePath, content);
|
|
24209
26136
|
const totalChars = this.list(featureName).reduce((sum, c) => sum + c.content.length, 0);
|
|
24210
26137
|
if (totalChars > 20000) {
|
|
@@ -24216,7 +26143,7 @@ class ContextService {
|
|
|
24216
26143
|
}
|
|
24217
26144
|
read(featureName, fileName) {
|
|
24218
26145
|
const contextPath = getContextPath(this.projectRoot, featureName);
|
|
24219
|
-
const filePath =
|
|
26146
|
+
const filePath = path52.join(contextPath, this.normalizeFileName(fileName));
|
|
24220
26147
|
return readText(filePath);
|
|
24221
26148
|
}
|
|
24222
26149
|
list(featureName) {
|
|
@@ -24225,7 +26152,7 @@ class ContextService {
|
|
|
24225
26152
|
return [];
|
|
24226
26153
|
const files = fs8.readdirSync(contextPath, { withFileTypes: true }).filter((f) => f.isFile() && f.name.endsWith(".md")).map((f) => f.name);
|
|
24227
26154
|
return files.map((name) => {
|
|
24228
|
-
const filePath =
|
|
26155
|
+
const filePath = path52.join(contextPath, name);
|
|
24229
26156
|
const stat2 = fs8.statSync(filePath);
|
|
24230
26157
|
const content = readText(filePath) || "";
|
|
24231
26158
|
return {
|
|
@@ -24237,7 +26164,7 @@ class ContextService {
|
|
|
24237
26164
|
}
|
|
24238
26165
|
delete(featureName, fileName) {
|
|
24239
26166
|
const contextPath = getContextPath(this.projectRoot, featureName);
|
|
24240
|
-
const filePath =
|
|
26167
|
+
const filePath = path52.join(contextPath, this.normalizeFileName(fileName));
|
|
24241
26168
|
if (fileExists(filePath)) {
|
|
24242
26169
|
fs8.unlinkSync(filePath);
|
|
24243
26170
|
return true;
|
|
@@ -24262,14 +26189,14 @@ ${f.content}`);
|
|
|
24262
26189
|
if (contexts.length === 0)
|
|
24263
26190
|
return { archived: [], archivePath: "" };
|
|
24264
26191
|
const contextPath = getContextPath(this.projectRoot, featureName);
|
|
24265
|
-
const archiveDir =
|
|
26192
|
+
const archiveDir = path52.join(contextPath, "..", "archive");
|
|
24266
26193
|
ensureDir(archiveDir);
|
|
24267
26194
|
const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
|
|
24268
26195
|
const archived = [];
|
|
24269
26196
|
for (const ctx of contexts) {
|
|
24270
26197
|
const archiveName = `${timestamp}_${ctx.name}.md`;
|
|
24271
|
-
const src =
|
|
24272
|
-
const dest =
|
|
26198
|
+
const src = path52.join(contextPath, `${ctx.name}.md`);
|
|
26199
|
+
const dest = path52.join(archiveDir, archiveName);
|
|
24273
26200
|
fs8.copyFileSync(src, dest);
|
|
24274
26201
|
fs8.unlinkSync(src);
|
|
24275
26202
|
archived.push(ctx.name);
|
|
@@ -24299,8 +26226,8 @@ class ConfigService {
|
|
|
24299
26226
|
cachedCustomAgentConfigs = null;
|
|
24300
26227
|
constructor() {
|
|
24301
26228
|
const homeDir = process.env.HOME || process.env.USERPROFILE || "";
|
|
24302
|
-
const configDir =
|
|
24303
|
-
this.configPath =
|
|
26229
|
+
const configDir = path7.join(homeDir, ".config", "opencode");
|
|
26230
|
+
this.configPath = path7.join(configDir, "agent_hive.json");
|
|
24304
26231
|
}
|
|
24305
26232
|
getPath() {
|
|
24306
26233
|
return this.configPath;
|
|
@@ -24363,7 +26290,7 @@ class ConfigService {
|
|
|
24363
26290
|
...updates.customAgents
|
|
24364
26291
|
} : current.customAgents
|
|
24365
26292
|
};
|
|
24366
|
-
const configDir =
|
|
26293
|
+
const configDir = path7.dirname(this.configPath);
|
|
24367
26294
|
if (!fs10.existsSync(configDir)) {
|
|
24368
26295
|
fs10.mkdirSync(configDir, { recursive: true });
|
|
24369
26296
|
}
|
|
@@ -24518,7 +26445,7 @@ class AgentsMdService {
|
|
|
24518
26445
|
this.contextService = contextService;
|
|
24519
26446
|
}
|
|
24520
26447
|
async init() {
|
|
24521
|
-
const agentsMdPath =
|
|
26448
|
+
const agentsMdPath = path8.join(this.rootDir, "AGENTS.md");
|
|
24522
26449
|
const existed = fileExists(agentsMdPath);
|
|
24523
26450
|
if (existed) {
|
|
24524
26451
|
const existing = readText(agentsMdPath);
|
|
@@ -24529,14 +26456,14 @@ class AgentsMdService {
|
|
|
24529
26456
|
}
|
|
24530
26457
|
async sync(featureName) {
|
|
24531
26458
|
const contexts = this.contextService.list(featureName);
|
|
24532
|
-
const agentsMdPath =
|
|
26459
|
+
const agentsMdPath = path8.join(this.rootDir, "AGENTS.md");
|
|
24533
26460
|
const current = await fs11.promises.readFile(agentsMdPath, "utf-8").catch(() => "");
|
|
24534
26461
|
const findings = this.extractFindings(contexts);
|
|
24535
26462
|
const proposals = this.generateProposals(findings, current);
|
|
24536
26463
|
return { proposals, diff: this.formatDiff(current, proposals) };
|
|
24537
26464
|
}
|
|
24538
26465
|
apply(content) {
|
|
24539
|
-
const agentsMdPath =
|
|
26466
|
+
const agentsMdPath = path8.join(this.rootDir, "AGENTS.md");
|
|
24540
26467
|
const isNew = !fileExists(agentsMdPath);
|
|
24541
26468
|
writeText(agentsMdPath, content);
|
|
24542
26469
|
return { path: agentsMdPath, chars: content.length, isNew };
|
|
@@ -24596,7 +26523,7 @@ class AgentsMdService {
|
|
|
24596
26523
|
return this.generateTemplate(detections);
|
|
24597
26524
|
}
|
|
24598
26525
|
async detectProjectInfo() {
|
|
24599
|
-
const packageJsonPath =
|
|
26526
|
+
const packageJsonPath = path8.join(this.rootDir, "package.json");
|
|
24600
26527
|
let packageJson = null;
|
|
24601
26528
|
if (fileExists(packageJsonPath)) {
|
|
24602
26529
|
try {
|
|
@@ -24616,26 +26543,26 @@ class AgentsMdService {
|
|
|
24616
26543
|
return info;
|
|
24617
26544
|
}
|
|
24618
26545
|
detectPackageManager() {
|
|
24619
|
-
if (fileExists(
|
|
26546
|
+
if (fileExists(path8.join(this.rootDir, "bun.lockb")))
|
|
24620
26547
|
return "bun";
|
|
24621
|
-
if (fileExists(
|
|
26548
|
+
if (fileExists(path8.join(this.rootDir, "pnpm-lock.yaml")))
|
|
24622
26549
|
return "pnpm";
|
|
24623
|
-
if (fileExists(
|
|
26550
|
+
if (fileExists(path8.join(this.rootDir, "yarn.lock")))
|
|
24624
26551
|
return "yarn";
|
|
24625
|
-
if (fileExists(
|
|
26552
|
+
if (fileExists(path8.join(this.rootDir, "package-lock.json")))
|
|
24626
26553
|
return "npm";
|
|
24627
26554
|
return "npm";
|
|
24628
26555
|
}
|
|
24629
26556
|
detectLanguage() {
|
|
24630
|
-
if (fileExists(
|
|
26557
|
+
if (fileExists(path8.join(this.rootDir, "tsconfig.json")))
|
|
24631
26558
|
return "TypeScript";
|
|
24632
|
-
if (fileExists(
|
|
26559
|
+
if (fileExists(path8.join(this.rootDir, "package.json")))
|
|
24633
26560
|
return "JavaScript";
|
|
24634
|
-
if (fileExists(
|
|
26561
|
+
if (fileExists(path8.join(this.rootDir, "requirements.txt")))
|
|
24635
26562
|
return "Python";
|
|
24636
|
-
if (fileExists(
|
|
26563
|
+
if (fileExists(path8.join(this.rootDir, "go.mod")))
|
|
24637
26564
|
return "Go";
|
|
24638
|
-
if (fileExists(
|
|
26565
|
+
if (fileExists(path8.join(this.rootDir, "Cargo.toml")))
|
|
24639
26566
|
return "Rust";
|
|
24640
26567
|
return "Unknown";
|
|
24641
26568
|
}
|
|
@@ -24716,19 +26643,19 @@ class AgentsMdService {
|
|
|
24716
26643
|
|
|
24717
26644
|
class DockerSandboxService {
|
|
24718
26645
|
static detectImage(worktreePath) {
|
|
24719
|
-
if (
|
|
26646
|
+
if (existsSync52(join92(worktreePath, "Dockerfile"))) {
|
|
24720
26647
|
return null;
|
|
24721
26648
|
}
|
|
24722
|
-
if (
|
|
26649
|
+
if (existsSync52(join92(worktreePath, "package.json"))) {
|
|
24723
26650
|
return "node:22-slim";
|
|
24724
26651
|
}
|
|
24725
|
-
if (
|
|
26652
|
+
if (existsSync52(join92(worktreePath, "requirements.txt")) || existsSync52(join92(worktreePath, "pyproject.toml"))) {
|
|
24726
26653
|
return "python:3.12-slim";
|
|
24727
26654
|
}
|
|
24728
|
-
if (
|
|
26655
|
+
if (existsSync52(join92(worktreePath, "go.mod"))) {
|
|
24729
26656
|
return "golang:1.22-slim";
|
|
24730
26657
|
}
|
|
24731
|
-
if (
|
|
26658
|
+
if (existsSync52(join92(worktreePath, "Cargo.toml"))) {
|
|
24732
26659
|
return "rust:1.77-slim";
|
|
24733
26660
|
}
|
|
24734
26661
|
return "ubuntu:24.04";
|
|
@@ -25289,15 +27216,15 @@ function applyContextBudget(files, config2 = {}) {
|
|
|
25289
27216
|
}
|
|
25290
27217
|
|
|
25291
27218
|
// src/utils/prompt-file.ts
|
|
25292
|
-
import * as
|
|
25293
|
-
import * as
|
|
27219
|
+
import * as fs9 from "fs";
|
|
27220
|
+
import * as path9 from "path";
|
|
25294
27221
|
function writeWorkerPromptFile(feature, task, prompt, hiveDir) {
|
|
25295
|
-
const promptDir =
|
|
25296
|
-
const promptPath =
|
|
25297
|
-
if (!
|
|
25298
|
-
|
|
27222
|
+
const promptDir = path9.join(hiveDir, "features", feature, "tasks", task);
|
|
27223
|
+
const promptPath = path9.join(promptDir, "worker-prompt.md");
|
|
27224
|
+
if (!fs9.existsSync(promptDir)) {
|
|
27225
|
+
fs9.mkdirSync(promptDir, { recursive: true });
|
|
25299
27226
|
}
|
|
25300
|
-
|
|
27227
|
+
fs9.writeFileSync(promptPath, prompt, "utf-8");
|
|
25301
27228
|
return promptPath;
|
|
25302
27229
|
}
|
|
25303
27230
|
|
|
@@ -25375,7 +27302,7 @@ async function buildAutoLoadedSkillsContent(agentName, configService, projectRoo
|
|
|
25375
27302
|
if (autoLoadSkills.length === 0) {
|
|
25376
27303
|
return "";
|
|
25377
27304
|
}
|
|
25378
|
-
const homeDir = process.env.HOME ||
|
|
27305
|
+
const homeDir = process.env.HOME || os4.homedir();
|
|
25379
27306
|
const skillTemplates = [];
|
|
25380
27307
|
for (const skillId of autoLoadSkills) {
|
|
25381
27308
|
const builtinSkill = BUILTIN_SKILLS.find((entry) => entry.name === skillId);
|
|
@@ -25461,7 +27388,7 @@ var plugin = async (ctx) => {
|
|
|
25461
27388
|
const effectiveAutoLoadSkills = configService.getAgentConfig("zetta").autoLoadSkills ?? [];
|
|
25462
27389
|
const worktreeService = new WorktreeService({
|
|
25463
27390
|
baseDir: directory,
|
|
25464
|
-
hiveDir:
|
|
27391
|
+
hiveDir: path11.join(directory, ".hive")
|
|
25465
27392
|
});
|
|
25466
27393
|
const isOmoSlimEnabled = () => {
|
|
25467
27394
|
return configService.isOmoSlimEnabled();
|
|
@@ -25487,10 +27414,10 @@ var plugin = async (ctx) => {
|
|
|
25487
27414
|
}
|
|
25488
27415
|
};
|
|
25489
27416
|
const checkBlocked = (feature) => {
|
|
25490
|
-
const
|
|
25491
|
-
const blockedPath =
|
|
25492
|
-
if (
|
|
25493
|
-
const reason =
|
|
27417
|
+
const fs12 = __require("fs");
|
|
27418
|
+
const blockedPath = path11.join(directory, ".hive", "features", feature, "BLOCKED");
|
|
27419
|
+
if (fs12.existsSync(blockedPath)) {
|
|
27420
|
+
const reason = fs12.readFileSync(blockedPath, "utf-8").trim();
|
|
25494
27421
|
return `⛔ BLOCKED by Beekeeper
|
|
25495
27422
|
|
|
25496
27423
|
${reason || "(No reason provided)"}
|
|
@@ -25642,9 +27569,9 @@ To unblock: Remove .hive/features/${feature}/BLOCKED`;
|
|
|
25642
27569
|
spec: specContent,
|
|
25643
27570
|
workerPrompt
|
|
25644
27571
|
});
|
|
25645
|
-
const hiveDir =
|
|
27572
|
+
const hiveDir = path11.join(directory, ".hive");
|
|
25646
27573
|
const workerPromptPath = writeWorkerPromptFile(feature, task, workerPrompt, hiveDir);
|
|
25647
|
-
const relativePromptPath = normalizePath(
|
|
27574
|
+
const relativePromptPath = normalizePath(path11.relative(directory, workerPromptPath));
|
|
25648
27575
|
const PREVIEW_MAX_LENGTH = 200;
|
|
25649
27576
|
const workerPromptPreview = workerPrompt.length > PREVIEW_MAX_LENGTH ? workerPrompt.slice(0, PREVIEW_MAX_LENGTH) + "..." : workerPrompt;
|
|
25650
27577
|
const taskToolPrompt = `Follow instructions in @${relativePromptPath}`;
|
|
@@ -26052,7 +27979,7 @@ ${snapshot}
|
|
|
26052
27979
|
if (sandboxConfig.mode !== "none") {
|
|
26053
27980
|
const workdir = output.args?.workdir;
|
|
26054
27981
|
if (workdir) {
|
|
26055
|
-
const hiveWorktreeBase =
|
|
27982
|
+
const hiveWorktreeBase = path11.join(directory, ".hive", ".worktrees");
|
|
26056
27983
|
if (workdir.startsWith(hiveWorktreeBase)) {
|
|
26057
27984
|
const wrapped = DockerSandboxService.wrapCommand(workdir, finalCommand, sandboxConfig);
|
|
26058
27985
|
output.args.command = wrapped;
|
|
@@ -26113,6 +28040,20 @@ ${snapshot}
|
|
|
26113
28040
|
hive_memory_forget: hiveMemoryForgetTool,
|
|
26114
28041
|
hive_journal_write: hiveJournalWriteTool,
|
|
26115
28042
|
hive_journal_search: hiveJournalSearchTool,
|
|
28043
|
+
hive_code_edit: hiveCodeEditTool,
|
|
28044
|
+
hive_lazy_edit: hiveLazyEditTool,
|
|
28045
|
+
hive_booster_status: hiveBoosterStatusTool,
|
|
28046
|
+
hive_vector_search: hiveVectorSearchTool,
|
|
28047
|
+
hive_vector_add: hiveVectorAddTool,
|
|
28048
|
+
hive_vector_status: hiveVectorStatusTool,
|
|
28049
|
+
ast_grep_dump_syntax_tree: astGrepDumpSyntaxTreeTool,
|
|
28050
|
+
ast_grep_test_match_code_rule: astGrepTestMatchCodeRuleTool,
|
|
28051
|
+
ast_grep_find_code: astGrepFindCodeTool,
|
|
28052
|
+
ast_grep_scan_code: astGrepScanCodeTool,
|
|
28053
|
+
ast_grep_rewrite_code: astGrepRewriteCodeTool,
|
|
28054
|
+
ast_grep_analyze_imports: astGrepAnalyzeImportsTool,
|
|
28055
|
+
hive_doctor: hiveDoctorTool,
|
|
28056
|
+
hive_doctor_quick: hiveDoctorQuickTool,
|
|
26116
28057
|
hive_skill: createHiveSkillTool(filteredSkills),
|
|
26117
28058
|
hive_feature_create: tool({
|
|
26118
28059
|
description: "Create a new feature and set it as active",
|