@hung319/opencode-hive 1.4.3 → 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/dist/index.js CHANGED
@@ -235,6 +235,410 @@ var require_dist = __commonJS((exports) => {
235
235
  exports.default = AgentBooster;
236
236
  });
237
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
+
238
642
  // src/utils/context-compression.ts
239
643
  var exports_context_compression = {};
240
644
  __export(exports_context_compression, {
@@ -450,7 +854,7 @@ var init_context_compression = __esm(() => {
450
854
  });
451
855
 
452
856
  // src/index.ts
453
- import * as path9 from "path";
857
+ import * as path11 from "path";
454
858
  import * as os4 from "os";
455
859
 
456
860
  // ../../node_modules/.bun/zod@4.1.8/node_modules/zod/v4/classic/external.js
@@ -17357,6 +17761,681 @@ var hiveVectorStatusTool = tool({
17357
17761
  }
17358
17762
  });
17359
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
+
17360
18439
  // src/agents/hive.ts
17361
18440
  var QUEEN_BEE_PROMPT = `# Zetta (Hybrid)
17362
18441
 
@@ -18690,12 +19769,19 @@ var astGrepMcp = {
18690
19769
  command: ["npx", "-y", "@notprolands/ast-grep-mcp"]
18691
19770
  };
18692
19771
 
19772
+ // src/mcp/pare-search.ts
19773
+ var pareSearchMcp = {
19774
+ type: "local",
19775
+ command: ["npx", "-y", "@paretools/search"]
19776
+ };
19777
+
18693
19778
  // src/mcp/index.ts
18694
19779
  var allBuiltinMcps = {
18695
19780
  websearch: websearchMcp,
18696
19781
  context7: context7Mcp,
18697
19782
  grep_app: grepAppMcp,
18698
- ast_grep: astGrepMcp
19783
+ ast_grep: astGrepMcp,
19784
+ pare_search: pareSearchMcp
18699
19785
  };
18700
19786
  var createBuiltinMcps = (disabledMcps = []) => {
18701
19787
  const disabled = new Set(disabledMcps);
@@ -18704,16 +19790,16 @@ var createBuiltinMcps = (disabledMcps = []) => {
18704
19790
 
18705
19791
  // ../hive-core/dist/index.js
18706
19792
  import { createRequire as createRequire2 } from "node:module";
18707
- import * as path5 from "path";
19793
+ import * as path6 from "path";
18708
19794
  import * as os3 from "os";
18709
19795
  import * as path22 from "path";
18710
- import * as fs5 from "fs";
19796
+ import * as fs7 from "fs";
18711
19797
  import * as path32 from "path";
18712
19798
  import * as fs22 from "fs";
18713
19799
  import * as fs32 from "fs";
18714
19800
  import * as fs42 from "fs";
18715
19801
  import * as fs52 from "fs";
18716
- import * as fs7 from "fs/promises";
19802
+ import * as fs72 from "fs/promises";
18717
19803
  import * as path42 from "path";
18718
19804
  import { Buffer as Buffer2 } from "node:buffer";
18719
19805
  import { spawn } from "child_process";
@@ -19579,7 +20665,7 @@ var DEFAULT_HIVE_CONFIG = {
19579
20665
  },
19580
20666
  vectorMemory: {
19581
20667
  enabled: false,
19582
- indexPath: path5.join(os3.homedir(), ".config", "opencode", "hive", "vector-index"),
20668
+ indexPath: path6.join(os3.homedir(), ".config", "opencode", "hive", "vector-index"),
19583
20669
  dimensions: 384
19584
20670
  }
19585
20671
  };
@@ -19653,22 +20739,22 @@ function getSubtaskReportPath(projectRoot, featureName, taskFolder, subtaskFolde
19653
20739
  return path22.join(getSubtaskPath(projectRoot, featureName, taskFolder, subtaskFolder), REPORT_FILE);
19654
20740
  }
19655
20741
  function ensureDir(dirPath) {
19656
- if (!fs5.existsSync(dirPath)) {
19657
- fs5.mkdirSync(dirPath, { recursive: true });
20742
+ if (!fs7.existsSync(dirPath)) {
20743
+ fs7.mkdirSync(dirPath, { recursive: true });
19658
20744
  }
19659
20745
  }
19660
20746
  function fileExists(filePath) {
19661
- return fs5.existsSync(filePath);
20747
+ return fs7.existsSync(filePath);
19662
20748
  }
19663
20749
  function readJson(filePath) {
19664
- if (!fs5.existsSync(filePath))
20750
+ if (!fs7.existsSync(filePath))
19665
20751
  return null;
19666
- const content = fs5.readFileSync(filePath, "utf-8");
20752
+ const content = fs7.readFileSync(filePath, "utf-8");
19667
20753
  return JSON.parse(content);
19668
20754
  }
19669
20755
  function writeJson(filePath, data) {
19670
20756
  ensureDir(path22.dirname(filePath));
19671
- fs5.writeFileSync(filePath, JSON.stringify(data, null, 2));
20757
+ fs7.writeFileSync(filePath, JSON.stringify(data, null, 2));
19672
20758
  }
19673
20759
  var DEFAULT_LOCK_OPTIONS = {
19674
20760
  timeout: 5000,
@@ -19680,7 +20766,7 @@ function getLockPath(filePath) {
19680
20766
  }
19681
20767
  function isLockStale(lockPath, staleTTL) {
19682
20768
  try {
19683
- const stat2 = fs5.statSync(lockPath);
20769
+ const stat2 = fs7.statSync(lockPath);
19684
20770
  const age = Date.now() - stat2.mtimeMs;
19685
20771
  return age > staleTTL;
19686
20772
  } catch {
@@ -19700,12 +20786,12 @@ function acquireLockSync(filePath, options = {}) {
19700
20786
  ensureDir(lockDir);
19701
20787
  while (true) {
19702
20788
  try {
19703
- const fd = fs5.openSync(lockPath, fs5.constants.O_CREAT | fs5.constants.O_EXCL | fs5.constants.O_WRONLY);
19704
- fs5.writeSync(fd, lockContent);
19705
- fs5.closeSync(fd);
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);
19706
20792
  return () => {
19707
20793
  try {
19708
- fs5.unlinkSync(lockPath);
20794
+ fs7.unlinkSync(lockPath);
19709
20795
  } catch {}
19710
20796
  };
19711
20797
  } catch (err) {
@@ -19715,7 +20801,7 @@ function acquireLockSync(filePath, options = {}) {
19715
20801
  } else if (error45.code === "EEXIST") {
19716
20802
  if (isLockStale(lockPath, opts.staleLockTTL)) {
19717
20803
  try {
19718
- fs5.unlinkSync(lockPath);
20804
+ fs7.unlinkSync(lockPath);
19719
20805
  continue;
19720
20806
  } catch {}
19721
20807
  }
@@ -19734,11 +20820,11 @@ function writeAtomic(filePath, content) {
19734
20820
  ensureDir(path22.dirname(filePath));
19735
20821
  const tempPath = `${filePath}.tmp.${process.pid}.${Date.now()}`;
19736
20822
  try {
19737
- fs5.writeFileSync(tempPath, content);
19738
- fs5.renameSync(tempPath, filePath);
20823
+ fs7.writeFileSync(tempPath, content);
20824
+ fs7.renameSync(tempPath, filePath);
19739
20825
  } catch (error45) {
19740
20826
  try {
19741
- fs5.unlinkSync(tempPath);
20827
+ fs7.unlinkSync(tempPath);
19742
20828
  } catch {}
19743
20829
  throw error45;
19744
20830
  }
@@ -19773,13 +20859,13 @@ function patchJsonLockedSync(filePath, patch, options = {}) {
19773
20859
  }
19774
20860
  }
19775
20861
  function readText(filePath) {
19776
- if (!fs5.existsSync(filePath))
20862
+ if (!fs7.existsSync(filePath))
19777
20863
  return null;
19778
- return fs5.readFileSync(filePath, "utf-8");
20864
+ return fs7.readFileSync(filePath, "utf-8");
19779
20865
  }
19780
20866
  function writeText(filePath, content) {
19781
20867
  ensureDir(path22.dirname(filePath));
19782
- fs5.writeFileSync(filePath, content);
20868
+ fs7.writeFileSync(filePath, content);
19783
20869
  }
19784
20870
  function detectContext(cwd) {
19785
20871
  const result = {
@@ -24614,7 +25700,7 @@ class WorktreeService {
24614
25700
  const featurePath = path42.join(this.config.hiveDir, "features", feature);
24615
25701
  const tasksPath = path42.join(featurePath, "tasks", step, "status.json");
24616
25702
  try {
24617
- await fs7.access(tasksPath);
25703
+ await fs72.access(tasksPath);
24618
25704
  return tasksPath;
24619
25705
  } catch {}
24620
25706
  return path42.join(featurePath, "execution", step, "status.json");
@@ -24626,7 +25712,7 @@ class WorktreeService {
24626
25712
  const worktreePath = this.getWorktreePath(feature, step);
24627
25713
  const branchName = this.getBranchName(feature, step);
24628
25714
  const git = this.getGit();
24629
- await fs7.mkdir(path42.dirname(worktreePath), { recursive: true });
25715
+ await fs72.mkdir(path42.dirname(worktreePath), { recursive: true });
24630
25716
  const base = baseBranch || (await git.revparse(["HEAD"])).trim();
24631
25717
  const existing = await this.get(feature, step);
24632
25718
  if (existing) {
@@ -24655,7 +25741,7 @@ class WorktreeService {
24655
25741
  const worktreePath = this.getWorktreePath(feature, step);
24656
25742
  const branchName = this.getBranchName(feature, step);
24657
25743
  try {
24658
- await fs7.access(worktreePath);
25744
+ await fs72.access(worktreePath);
24659
25745
  const worktreeGit = this.getGit(worktreePath);
24660
25746
  const commit = (await worktreeGit.revparse(["HEAD"])).trim();
24661
25747
  return {
@@ -24675,7 +25761,7 @@ class WorktreeService {
24675
25761
  let base = baseCommit;
24676
25762
  if (!base) {
24677
25763
  try {
24678
- const status = JSON.parse(await fs7.readFile(statusPath, "utf-8"));
25764
+ const status = JSON.parse(await fs72.readFile(statusPath, "utf-8"));
24679
25765
  base = status.baseCommit;
24680
25766
  } catch {}
24681
25767
  }
@@ -24725,7 +25811,7 @@ class WorktreeService {
24725
25811
  const base = baseBranch || "HEAD~1";
24726
25812
  const worktreeGit = this.getGit(worktreePath);
24727
25813
  const diff = await worktreeGit.diff([`${base}...HEAD`]);
24728
- await fs7.writeFile(patchPath, diff);
25814
+ await fs72.writeFile(patchPath, diff);
24729
25815
  return patchPath;
24730
25816
  }
24731
25817
  async applyDiff(feature, step, baseBranch) {
@@ -24735,13 +25821,13 @@ class WorktreeService {
24735
25821
  }
24736
25822
  const patchPath = path42.join(this.config.hiveDir, ".worktrees", feature, `${step}.patch`);
24737
25823
  try {
24738
- await fs7.writeFile(patchPath, diffContent);
25824
+ await fs72.writeFile(patchPath, diffContent);
24739
25825
  const git = this.getGit();
24740
25826
  await git.applyPatch(patchPath);
24741
- await fs7.unlink(patchPath).catch(() => {});
25827
+ await fs72.unlink(patchPath).catch(() => {});
24742
25828
  return { success: true, filesAffected: filesChanged };
24743
25829
  } catch (error45) {
24744
- await fs7.unlink(patchPath).catch(() => {});
25830
+ await fs72.unlink(patchPath).catch(() => {});
24745
25831
  const err = error45;
24746
25832
  return {
24747
25833
  success: false,
@@ -24757,13 +25843,13 @@ class WorktreeService {
24757
25843
  }
24758
25844
  const patchPath = path42.join(this.config.hiveDir, ".worktrees", feature, `${step}.patch`);
24759
25845
  try {
24760
- await fs7.writeFile(patchPath, diffContent);
25846
+ await fs72.writeFile(patchPath, diffContent);
24761
25847
  const git = this.getGit();
24762
25848
  await git.applyPatch(patchPath, ["-R"]);
24763
- await fs7.unlink(patchPath).catch(() => {});
25849
+ await fs72.unlink(patchPath).catch(() => {});
24764
25850
  return { success: true, filesAffected: filesChanged };
24765
25851
  } catch (error45) {
24766
- await fs7.unlink(patchPath).catch(() => {});
25852
+ await fs72.unlink(patchPath).catch(() => {});
24767
25853
  const err = error45;
24768
25854
  return {
24769
25855
  success: false,
@@ -24782,7 +25868,7 @@ class WorktreeService {
24782
25868
  return [...new Set(files)];
24783
25869
  }
24784
25870
  async revertFromSavedDiff(diffPath) {
24785
- const diffContent = await fs7.readFile(diffPath, "utf-8");
25871
+ const diffContent = await fs72.readFile(diffPath, "utf-8");
24786
25872
  if (!diffContent.trim()) {
24787
25873
  return { success: true, filesAffected: [] };
24788
25874
  }
@@ -24807,7 +25893,7 @@ class WorktreeService {
24807
25893
  try {
24808
25894
  await git.raw(["worktree", "remove", worktreePath, "--force"]);
24809
25895
  } catch {
24810
- await fs7.rm(worktreePath, { recursive: true, force: true });
25896
+ await fs72.rm(worktreePath, { recursive: true, force: true });
24811
25897
  }
24812
25898
  try {
24813
25899
  await git.raw(["worktree", "prune"]);
@@ -24822,13 +25908,13 @@ class WorktreeService {
24822
25908
  const worktreesDir = this.getWorktreesDir();
24823
25909
  const results = [];
24824
25910
  try {
24825
- const features = feature ? [feature] : await fs7.readdir(worktreesDir);
25911
+ const features = feature ? [feature] : await fs72.readdir(worktreesDir);
24826
25912
  for (const feat of features) {
24827
25913
  const featurePath = path42.join(worktreesDir, feat);
24828
- const stat2 = await fs7.stat(featurePath).catch(() => null);
25914
+ const stat2 = await fs72.stat(featurePath).catch(() => null);
24829
25915
  if (!stat2?.isDirectory())
24830
25916
  continue;
24831
- const steps = await fs7.readdir(featurePath).catch(() => []);
25917
+ const steps = await fs72.readdir(featurePath).catch(() => []);
24832
25918
  for (const step of steps) {
24833
25919
  const info = await this.get(feat, step);
24834
25920
  if (info) {
@@ -24846,16 +25932,16 @@ class WorktreeService {
24846
25932
  await git.raw(["worktree", "prune"]);
24847
25933
  } catch {}
24848
25934
  const worktreesDir = this.getWorktreesDir();
24849
- const features = feature ? [feature] : await fs7.readdir(worktreesDir).catch(() => []);
25935
+ const features = feature ? [feature] : await fs72.readdir(worktreesDir).catch(() => []);
24850
25936
  for (const feat of features) {
24851
25937
  const featurePath = path42.join(worktreesDir, feat);
24852
- const stat2 = await fs7.stat(featurePath).catch(() => null);
25938
+ const stat2 = await fs72.stat(featurePath).catch(() => null);
24853
25939
  if (!stat2?.isDirectory())
24854
25940
  continue;
24855
- const steps = await fs7.readdir(featurePath).catch(() => []);
25941
+ const steps = await fs72.readdir(featurePath).catch(() => []);
24856
25942
  for (const step of steps) {
24857
25943
  const worktreePath = path42.join(featurePath, step);
24858
- const stepStat = await fs7.stat(worktreePath).catch(() => null);
25944
+ const stepStat = await fs72.stat(worktreePath).catch(() => null);
24859
25945
  if (!stepStat?.isDirectory())
24860
25946
  continue;
24861
25947
  try {
@@ -24876,13 +25962,13 @@ class WorktreeService {
24876
25962
  }
24877
25963
  const patchPath = path42.join(this.config.hiveDir, ".worktrees", feature, `${step}-check.patch`);
24878
25964
  try {
24879
- await fs7.writeFile(patchPath, diffContent);
25965
+ await fs72.writeFile(patchPath, diffContent);
24880
25966
  const git = this.getGit();
24881
25967
  await git.applyPatch(patchPath, ["--check"]);
24882
- await fs7.unlink(patchPath).catch(() => {});
25968
+ await fs72.unlink(patchPath).catch(() => {});
24883
25969
  return [];
24884
25970
  } catch (error45) {
24885
- await fs7.unlink(patchPath).catch(() => {});
25971
+ await fs72.unlink(patchPath).catch(() => {});
24886
25972
  const err = error45;
24887
25973
  const stderr = err.message || "";
24888
25974
  const conflicts2 = stderr.split(`
@@ -24895,7 +25981,7 @@ class WorktreeService {
24895
25981
  }
24896
25982
  async checkConflictsFromSavedDiff(diffPath, reverse = false) {
24897
25983
  try {
24898
- await fs7.access(diffPath);
25984
+ await fs72.access(diffPath);
24899
25985
  } catch {
24900
25986
  return [];
24901
25987
  }
@@ -24918,7 +26004,7 @@ class WorktreeService {
24918
26004
  async commitChanges(feature, step, message) {
24919
26005
  const worktreePath = this.getWorktreePath(feature, step);
24920
26006
  try {
24921
- await fs7.access(worktreePath);
26007
+ await fs72.access(worktreePath);
24922
26008
  } catch {
24923
26009
  return { committed: false, sha: "", message: "Worktree not found" };
24924
26010
  }
@@ -26130,15 +27216,15 @@ function applyContextBudget(files, config2 = {}) {
26130
27216
  }
26131
27217
 
26132
27218
  // src/utils/prompt-file.ts
26133
- import * as fs6 from "fs";
26134
- import * as path6 from "path";
27219
+ import * as fs9 from "fs";
27220
+ import * as path9 from "path";
26135
27221
  function writeWorkerPromptFile(feature, task, prompt, hiveDir) {
26136
- const promptDir = path6.join(hiveDir, "features", feature, "tasks", task);
26137
- const promptPath = path6.join(promptDir, "worker-prompt.md");
26138
- if (!fs6.existsSync(promptDir)) {
26139
- fs6.mkdirSync(promptDir, { recursive: true });
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 });
26140
27226
  }
26141
- fs6.writeFileSync(promptPath, prompt, "utf-8");
27227
+ fs9.writeFileSync(promptPath, prompt, "utf-8");
26142
27228
  return promptPath;
26143
27229
  }
26144
27230
 
@@ -26302,7 +27388,7 @@ var plugin = async (ctx) => {
26302
27388
  const effectiveAutoLoadSkills = configService.getAgentConfig("zetta").autoLoadSkills ?? [];
26303
27389
  const worktreeService = new WorktreeService({
26304
27390
  baseDir: directory,
26305
- hiveDir: path9.join(directory, ".hive")
27391
+ hiveDir: path11.join(directory, ".hive")
26306
27392
  });
26307
27393
  const isOmoSlimEnabled = () => {
26308
27394
  return configService.isOmoSlimEnabled();
@@ -26328,10 +27414,10 @@ var plugin = async (ctx) => {
26328
27414
  }
26329
27415
  };
26330
27416
  const checkBlocked = (feature) => {
26331
- const fs9 = __require("fs");
26332
- const blockedPath = path9.join(directory, ".hive", "features", feature, "BLOCKED");
26333
- if (fs9.existsSync(blockedPath)) {
26334
- const reason = fs9.readFileSync(blockedPath, "utf-8").trim();
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();
26335
27421
  return `⛔ BLOCKED by Beekeeper
26336
27422
 
26337
27423
  ${reason || "(No reason provided)"}
@@ -26483,9 +27569,9 @@ To unblock: Remove .hive/features/${feature}/BLOCKED`;
26483
27569
  spec: specContent,
26484
27570
  workerPrompt
26485
27571
  });
26486
- const hiveDir = path9.join(directory, ".hive");
27572
+ const hiveDir = path11.join(directory, ".hive");
26487
27573
  const workerPromptPath = writeWorkerPromptFile(feature, task, workerPrompt, hiveDir);
26488
- const relativePromptPath = normalizePath(path9.relative(directory, workerPromptPath));
27574
+ const relativePromptPath = normalizePath(path11.relative(directory, workerPromptPath));
26489
27575
  const PREVIEW_MAX_LENGTH = 200;
26490
27576
  const workerPromptPreview = workerPrompt.length > PREVIEW_MAX_LENGTH ? workerPrompt.slice(0, PREVIEW_MAX_LENGTH) + "..." : workerPrompt;
26491
27577
  const taskToolPrompt = `Follow instructions in @${relativePromptPath}`;
@@ -26893,7 +27979,7 @@ ${snapshot}
26893
27979
  if (sandboxConfig.mode !== "none") {
26894
27980
  const workdir = output.args?.workdir;
26895
27981
  if (workdir) {
26896
- const hiveWorktreeBase = path9.join(directory, ".hive", ".worktrees");
27982
+ const hiveWorktreeBase = path11.join(directory, ".hive", ".worktrees");
26897
27983
  if (workdir.startsWith(hiveWorktreeBase)) {
26898
27984
  const wrapped = DockerSandboxService.wrapCommand(workdir, finalCommand, sandboxConfig);
26899
27985
  output.args.command = wrapped;
@@ -26960,6 +28046,14 @@ ${snapshot}
26960
28046
  hive_vector_search: hiveVectorSearchTool,
26961
28047
  hive_vector_add: hiveVectorAddTool,
26962
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,
26963
28057
  hive_skill: createHiveSkillTool(filteredSkills),
26964
28058
  hive_feature_create: tool({
26965
28059
  description: "Create a new feature and set it as active",