@hung319/opencode-hive 1.4.2 → 1.4.3

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
@@ -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,195 @@ 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
+
19
238
  // src/utils/context-compression.ts
20
239
  var exports_context_compression = {};
21
240
  __export(exports_context_compression, {
@@ -231,8 +450,8 @@ var init_context_compression = __esm(() => {
231
450
  });
232
451
 
233
452
  // src/index.ts
234
- import * as path8 from "path";
235
- import * as os2 from "os";
453
+ import * as path9 from "path";
454
+ import * as os4 from "os";
236
455
 
237
456
  // ../../node_modules/.bun/zod@4.1.8/node_modules/zod/v4/classic/external.js
238
457
  var exports_external = {};
@@ -16528,6 +16747,616 @@ var hiveMemoryForgetTool = tool({
16528
16747
  }
16529
16748
  });
16530
16749
 
16750
+ // src/tools/agent-booster.ts
16751
+ import * as fs3 from "fs";
16752
+ import * as path3 from "path";
16753
+ var boosterInstance = null;
16754
+ var boosterInitPromise = null;
16755
+ async function initBooster() {
16756
+ if (boosterInstance !== null) {
16757
+ return;
16758
+ }
16759
+ if (boosterInitPromise !== null) {
16760
+ await boosterInitPromise;
16761
+ return;
16762
+ }
16763
+ boosterInitPromise = (async () => {
16764
+ try {
16765
+ const booster = require_dist();
16766
+ if (booster && typeof booster.init === "function") {
16767
+ await booster.init();
16768
+ boosterInstance = booster;
16769
+ } else if (booster && typeof booster.default === "function") {
16770
+ boosterInstance = booster.default;
16771
+ } else {
16772
+ boosterInstance = booster || {};
16773
+ }
16774
+ console.log("[agent-booster] Initialized successfully");
16775
+ } catch (error45) {
16776
+ console.warn("[agent-booster] Failed to initialize:", error45 instanceof Error ? error45.message : error45);
16777
+ boosterInstance = null;
16778
+ }
16779
+ })();
16780
+ await boosterInitPromise;
16781
+ }
16782
+ async function applyWithBooster(edit) {
16783
+ await initBooster();
16784
+ if (!boosterInstance) {
16785
+ return {
16786
+ success: false,
16787
+ path: edit.path,
16788
+ error: "Agent booster not available",
16789
+ fallback: true
16790
+ };
16791
+ }
16792
+ try {
16793
+ if (!fs3.existsSync(edit.path)) {
16794
+ return {
16795
+ success: false,
16796
+ path: edit.path,
16797
+ error: `File not found: ${edit.path}`
16798
+ };
16799
+ }
16800
+ const currentContent = fs3.readFileSync(edit.path, "utf-8");
16801
+ if (typeof boosterInstance.fastApply === "function") {
16802
+ const result = await boosterInstance.fastApply({
16803
+ path: edit.path,
16804
+ old: edit.oldContent,
16805
+ new: edit.newContent
16806
+ });
16807
+ return {
16808
+ success: result.success ?? true,
16809
+ path: edit.path,
16810
+ applied: result.applied ?? "Applied via agent-booster"
16811
+ };
16812
+ }
16813
+ if (currentContent.includes(edit.oldContent)) {
16814
+ const newContent = currentContent.replace(edit.oldContent, edit.newContent);
16815
+ fs3.writeFileSync(edit.path, newContent, "utf-8");
16816
+ return {
16817
+ success: true,
16818
+ path: edit.path,
16819
+ applied: "Applied via fallback (string replace)"
16820
+ };
16821
+ }
16822
+ return {
16823
+ success: false,
16824
+ path: edit.path,
16825
+ error: "oldContent not found in file"
16826
+ };
16827
+ } catch (error45) {
16828
+ return {
16829
+ success: false,
16830
+ path: edit.path,
16831
+ error: error45 instanceof Error ? error45.message : String(error45),
16832
+ fallback: true
16833
+ };
16834
+ }
16835
+ }
16836
+ async function applyCodeEdit(edit) {
16837
+ const boosterResult = await applyWithBooster(edit);
16838
+ if (boosterResult.success) {
16839
+ return boosterResult;
16840
+ }
16841
+ try {
16842
+ if (!fs3.existsSync(edit.path)) {
16843
+ return {
16844
+ success: false,
16845
+ path: edit.path,
16846
+ error: `File not found: ${edit.path}`
16847
+ };
16848
+ }
16849
+ const currentContent = fs3.readFileSync(edit.path, "utf-8");
16850
+ if (!currentContent.includes(edit.oldContent)) {
16851
+ return {
16852
+ success: false,
16853
+ path: edit.path,
16854
+ error: "oldContent not found in file"
16855
+ };
16856
+ }
16857
+ const newContent = currentContent.replace(edit.oldContent, edit.newContent);
16858
+ fs3.writeFileSync(edit.path, newContent, "utf-8");
16859
+ return {
16860
+ success: true,
16861
+ path: edit.path,
16862
+ applied: "Applied via native fallback"
16863
+ };
16864
+ } catch (error45) {
16865
+ return {
16866
+ success: false,
16867
+ path: edit.path,
16868
+ error: error45 instanceof Error ? error45.message : String(error45)
16869
+ };
16870
+ }
16871
+ }
16872
+ async function isBoosterAvailable() {
16873
+ await initBooster();
16874
+ return boosterInstance !== null;
16875
+ }
16876
+ async function getBoosterStatus() {
16877
+ const available = await isBoosterAvailable();
16878
+ if (!available) {
16879
+ return { available: false };
16880
+ }
16881
+ try {
16882
+ const booster = await Promise.resolve().then(() => __toESM(require_dist(), 1));
16883
+ return {
16884
+ available: true,
16885
+ version: booster.version || "unknown"
16886
+ };
16887
+ } catch {
16888
+ return { available: true };
16889
+ }
16890
+ }
16891
+ var hiveCodeEditTool = tool({
16892
+ description: `Ultra-fast code editing using agent-booster (52x faster than Morph, FREE).
16893
+
16894
+ **Features:**
16895
+ - 52x faster than Morph LLM
16896
+ - No API key required
16897
+ - Rust+WASM powered
16898
+ - Graceful fallback to native edit
16899
+
16900
+ **Usage:**
16901
+ - oldContent: Exact text to replace (must match file content)
16902
+ - newContent: Replacement text
16903
+ - Automatically falls back to native edit if agent-booster unavailable`,
16904
+ args: {
16905
+ path: tool.schema.string().describe("Absolute or relative path to the file to edit"),
16906
+ oldContent: tool.schema.string().describe("Exact text to find and replace"),
16907
+ newContent: tool.schema.string().describe("Replacement text")
16908
+ },
16909
+ async execute({ path: filePath, oldContent, newContent }) {
16910
+ const resolvedPath = path3.isAbsolute(filePath) ? filePath : path3.join(process.cwd(), filePath);
16911
+ const result = await applyCodeEdit({
16912
+ path: resolvedPath,
16913
+ oldContent,
16914
+ newContent
16915
+ });
16916
+ if (!result.success) {
16917
+ return JSON.stringify({
16918
+ success: false,
16919
+ error: result.error,
16920
+ hint: "Ensure oldContent matches exactly. Check for whitespace differences."
16921
+ }, null, 2);
16922
+ }
16923
+ return JSON.stringify({
16924
+ success: true,
16925
+ path: result.path,
16926
+ applied: result.applied,
16927
+ message: `Edit applied successfully`
16928
+ }, null, 2);
16929
+ }
16930
+ });
16931
+ var hiveLazyEditTool = tool({
16932
+ description: `Fast code editing with lazy markers using agent-booster.
16933
+
16934
+ **Lazy Markers:**
16935
+ Use \`// ... existing code ...\` to indicate unchanged sections.
16936
+ Agent-booster intelligently merges your partial code into the full file.
16937
+
16938
+ **Example:**
16939
+ \`\`\`
16940
+ // ... existing code ...
16941
+ const newFunction = () => { ... };
16942
+ // ... existing code ...
16943
+ \`\`\`
16944
+
16945
+ **Note:** Requires @sparkleideas/agent-booster to be installed and enabled.`,
16946
+ args: {
16947
+ path: tool.schema.string().describe("File path"),
16948
+ snippet: tool.schema.string().describe("Code snippet with // ... existing code ... markers")
16949
+ },
16950
+ async execute({ path: filePath, snippet }) {
16951
+ const resolvedPath = path3.isAbsolute(filePath) ? filePath : path3.join(process.cwd(), filePath);
16952
+ const available = await isBoosterAvailable();
16953
+ if (!available) {
16954
+ return JSON.stringify({
16955
+ success: false,
16956
+ error: "agent-booster not available",
16957
+ hint: "Install @sparkleideas/agent-booster or use hive_code_edit for native editing"
16958
+ }, null, 2);
16959
+ }
16960
+ try {
16961
+ if (typeof boosterInstance.lazyApply === "function") {
16962
+ const result = await boosterInstance.lazyApply({
16963
+ path: resolvedPath,
16964
+ snippet
16965
+ });
16966
+ return JSON.stringify({
16967
+ success: result.success ?? true,
16968
+ path: resolvedPath,
16969
+ message: result.message || "Lazy edit applied"
16970
+ }, null, 2);
16971
+ }
16972
+ return JSON.stringify({
16973
+ success: false,
16974
+ error: "Lazy apply not supported",
16975
+ hint: "Update @sparkleideas/agent-booster for lazy edit support"
16976
+ }, null, 2);
16977
+ } catch (error45) {
16978
+ return JSON.stringify({
16979
+ success: false,
16980
+ error: error45 instanceof Error ? error45.message : String(error45)
16981
+ }, null, 2);
16982
+ }
16983
+ }
16984
+ });
16985
+ var hiveBoosterStatusTool = tool({
16986
+ description: `Check agent-booster availability and status.
16987
+
16988
+ **Returns:**
16989
+ - available: Whether agent-booster is installed and working
16990
+ - version: Agent-booster version (if available)
16991
+ - speed: Performance comparison vs native editing`,
16992
+ args: {},
16993
+ async execute() {
16994
+ const status = await getBoosterStatus();
16995
+ return JSON.stringify({
16996
+ ...status,
16997
+ performance: {
16998
+ agentBooster: "52x faster than Morph",
16999
+ native: "baseline",
17000
+ savings: "60-90% tokens on large files"
17001
+ },
17002
+ installation: status.available ? "Ready" : "Run: npm install @sparkleideas/agent-booster"
17003
+ }, null, 2);
17004
+ }
17005
+ });
17006
+
17007
+ // src/services/vector-memory.ts
17008
+ import * as fs4 from "fs";
17009
+ import * as path4 from "path";
17010
+ import * as os2 from "os";
17011
+ var memoryInstance = null;
17012
+ var memoryInitPromise = null;
17013
+ async function initMemory(options) {
17014
+ if (memoryInstance !== null) {
17015
+ return;
17016
+ }
17017
+ if (memoryInitPromise !== null) {
17018
+ await memoryInitPromise;
17019
+ return;
17020
+ }
17021
+ memoryInitPromise = (async () => {
17022
+ try {
17023
+ const memory = (()=>{throw new Error("Cannot require module "+"@sparkleideas/memory");})();
17024
+ const indexPath = options?.indexPath || path4.join(os2.homedir(), ".config", "opencode", "hive", "vector-index");
17025
+ const dimensions = options?.dimensions || 384;
17026
+ fs4.mkdirSync(indexPath, { recursive: true });
17027
+ if (typeof memory.init === "function") {
17028
+ await memory.init({
17029
+ indexPath,
17030
+ dimensions
17031
+ });
17032
+ } else if (memory.default && typeof memory.default.init === "function") {
17033
+ memoryInstance = memory.default;
17034
+ await memoryInstance.init({
17035
+ indexPath,
17036
+ dimensions
17037
+ });
17038
+ } else {
17039
+ memoryInstance = memory;
17040
+ }
17041
+ console.log("[vector-memory] Initialized successfully");
17042
+ } catch (error45) {
17043
+ console.warn("[vector-memory] Failed to initialize:", error45 instanceof Error ? error45.message : error45);
17044
+ memoryInstance = null;
17045
+ }
17046
+ })();
17047
+ await memoryInitPromise;
17048
+ }
17049
+ async function addMemory(content, metadata = {}) {
17050
+ await initMemory();
17051
+ if (memoryInstance) {
17052
+ try {
17053
+ const id2 = await memoryInstance.add({
17054
+ content,
17055
+ metadata
17056
+ });
17057
+ return { id: id2, success: true };
17058
+ } catch (error45) {
17059
+ console.warn("[vector-memory] Failed to add with vector:", error45 instanceof Error ? error45.message : error45);
17060
+ }
17061
+ }
17062
+ return addMemoryFallback(content, metadata);
17063
+ }
17064
+ async function searchMemories(query, options = {}) {
17065
+ const { limit = 10, type, scope, minScore = 0 } = options;
17066
+ await initMemory();
17067
+ if (memoryInstance && typeof memoryInstance.search === "function") {
17068
+ try {
17069
+ const searchResults = await memoryInstance.search(query, {
17070
+ limit,
17071
+ filter: { type, scope },
17072
+ minScore
17073
+ });
17074
+ return {
17075
+ results: searchResults.map((r) => ({
17076
+ id: r.id,
17077
+ content: r.content,
17078
+ score: r.score || r.similarity || 0,
17079
+ metadata: r.metadata || {}
17080
+ }))
17081
+ };
17082
+ } catch (error45) {
17083
+ console.warn("[vector-memory] Failed to search with vector:", error45 instanceof Error ? error45.message : error45);
17084
+ }
17085
+ }
17086
+ return searchMemoriesFallback(query, { limit, type, scope });
17087
+ }
17088
+ async function getMemory(id2) {
17089
+ await initMemory();
17090
+ if (memoryInstance && typeof memoryInstance.get === "function") {
17091
+ try {
17092
+ const entry = await memoryInstance.get(id2);
17093
+ return entry;
17094
+ } catch {}
17095
+ }
17096
+ return getMemoryFallback(id2);
17097
+ }
17098
+ async function deleteMemory(id2) {
17099
+ await initMemory();
17100
+ if (memoryInstance && typeof memoryInstance.delete === "function") {
17101
+ try {
17102
+ await memoryInstance.delete(id2);
17103
+ return true;
17104
+ } catch {}
17105
+ }
17106
+ return deleteMemoryFallback(id2);
17107
+ }
17108
+ async function getMemoryStatus() {
17109
+ await initMemory();
17110
+ if (memoryInstance) {
17111
+ try {
17112
+ const stats = await memoryInstance.stats?.() || {};
17113
+ return {
17114
+ available: true,
17115
+ type: "vector",
17116
+ stats
17117
+ };
17118
+ } catch {}
17119
+ }
17120
+ const fallbackStats = getFallbackStats();
17121
+ return {
17122
+ available: false,
17123
+ type: "fallback",
17124
+ stats: fallbackStats
17125
+ };
17126
+ }
17127
+ function getFallbackDir() {
17128
+ return path4.join(os2.homedir(), ".config", "opencode", "hive", "vector-memory", "fallback");
17129
+ }
17130
+ function ensureFallbackDir() {
17131
+ const dir = getFallbackDir();
17132
+ if (!fs4.existsSync(dir)) {
17133
+ fs4.mkdirSync(dir, { recursive: true });
17134
+ }
17135
+ }
17136
+ function generateId() {
17137
+ return `mem_${Date.now()}_${Math.random().toString(36).slice(2, 9)}`;
17138
+ }
17139
+ async function addMemoryFallback(content, metadata) {
17140
+ ensureFallbackDir();
17141
+ const id2 = generateId();
17142
+ const entry = {
17143
+ id: id2,
17144
+ content,
17145
+ metadata,
17146
+ createdAt: new Date().toISOString(),
17147
+ updatedAt: new Date().toISOString()
17148
+ };
17149
+ const filePath = path4.join(getFallbackDir(), `${id2}.json`);
17150
+ fs4.writeFileSync(filePath, JSON.stringify(entry, null, 2), "utf-8");
17151
+ return { id: id2, success: true, fallback: true };
17152
+ }
17153
+ async function searchMemoriesFallback(query, options) {
17154
+ ensureFallbackDir();
17155
+ const { limit = 10, type, scope } = options;
17156
+ const queryLower = query.toLowerCase();
17157
+ const results = [];
17158
+ const files = fs4.readdirSync(getFallbackDir()).filter((f) => f.endsWith(".json"));
17159
+ for (const file2 of files) {
17160
+ try {
17161
+ const content = fs4.readFileSync(path4.join(getFallbackDir(), file2), "utf-8");
17162
+ const entry = JSON.parse(content);
17163
+ if (type && entry.metadata.type !== type)
17164
+ continue;
17165
+ if (scope && entry.metadata.scope !== scope)
17166
+ continue;
17167
+ const contentLower = entry.content.toLowerCase();
17168
+ let score = 0;
17169
+ if (contentLower.includes(queryLower)) {
17170
+ score = queryLower.length / contentLower.length;
17171
+ }
17172
+ if (entry.metadata.tags) {
17173
+ for (const tag of entry.metadata.tags) {
17174
+ if (tag.toLowerCase().includes(queryLower)) {
17175
+ score = Math.max(score, 0.8);
17176
+ }
17177
+ }
17178
+ }
17179
+ if (score > 0) {
17180
+ results.push({
17181
+ id: entry.id,
17182
+ content: entry.content,
17183
+ score,
17184
+ metadata: entry.metadata
17185
+ });
17186
+ }
17187
+ } catch {}
17188
+ }
17189
+ results.sort((a, b) => b.score - a.score);
17190
+ return {
17191
+ results: results.slice(0, limit),
17192
+ fallback: true
17193
+ };
17194
+ }
17195
+ async function getMemoryFallback(id2) {
17196
+ const filePath = path4.join(getFallbackDir(), `${id2}.json`);
17197
+ if (!fs4.existsSync(filePath)) {
17198
+ return null;
17199
+ }
17200
+ try {
17201
+ const content = fs4.readFileSync(filePath, "utf-8");
17202
+ return JSON.parse(content);
17203
+ } catch {
17204
+ return null;
17205
+ }
17206
+ }
17207
+ async function deleteMemoryFallback(id2) {
17208
+ const filePath = path4.join(getFallbackDir(), `${id2}.json`);
17209
+ if (!fs4.existsSync(filePath)) {
17210
+ return false;
17211
+ }
17212
+ try {
17213
+ fs4.unlinkSync(filePath);
17214
+ return true;
17215
+ } catch {
17216
+ return false;
17217
+ }
17218
+ }
17219
+ function getFallbackStats() {
17220
+ ensureFallbackDir();
17221
+ const stats = { total: 0, byType: {} };
17222
+ const files = fs4.readdirSync(getFallbackDir()).filter((f) => f.endsWith(".json"));
17223
+ for (const file2 of files) {
17224
+ try {
17225
+ const content = fs4.readFileSync(path4.join(getFallbackDir(), file2), "utf-8");
17226
+ const entry = JSON.parse(content);
17227
+ stats.total++;
17228
+ const type = entry.metadata.type || "unknown";
17229
+ stats.byType[type] = (stats.byType[type] || 0) + 1;
17230
+ } catch {}
17231
+ }
17232
+ return stats;
17233
+ }
17234
+ var VectorMemoryService = {
17235
+ init: initMemory,
17236
+ add: addMemory,
17237
+ search: searchMemories,
17238
+ get: getMemory,
17239
+ delete: deleteMemory,
17240
+ status: getMemoryStatus
17241
+ };
17242
+
17243
+ // src/tools/vector-memory.ts
17244
+ var hiveVectorSearchTool = tool({
17245
+ description: `Semantic memory search using vector embeddings.
17246
+
17247
+ **Features:**
17248
+ - HNSW indexing for fast similarity search
17249
+ - Semantic matching (finds conceptually similar content)
17250
+ - Filter by type and scope
17251
+ - Fallback to text search if vector unavailable
17252
+
17253
+ **Types:**
17254
+ - decision: Architectural decisions, design choices
17255
+ - learning: Insights, discoveries, patterns found
17256
+ - preference: User preferences, coding style
17257
+ - blocker: Known blockers, workarounds
17258
+ - context: Important context about the project
17259
+ - pattern: Code patterns, recurring solutions`,
17260
+ args: {
17261
+ query: tool.schema.string().describe("Search query (semantic or keyword)"),
17262
+ type: tool.schema.enum(["decision", "learning", "preference", "blocker", "context", "pattern"]).optional().describe("Filter by memory type"),
17263
+ scope: tool.schema.string().optional().describe("Filter by scope (e.g., auth, api, ui)"),
17264
+ limit: tool.schema.number().optional().describe("Maximum results (default: 10)")
17265
+ },
17266
+ async execute({ query, type, scope, limit = 10 }) {
17267
+ const result = await VectorMemoryService.search(query, {
17268
+ limit,
17269
+ type,
17270
+ scope
17271
+ });
17272
+ if (result.results.length === 0) {
17273
+ return JSON.stringify({
17274
+ message: "No matching memories found",
17275
+ query,
17276
+ fallback: result.fallback || false,
17277
+ tips: [
17278
+ "Try different keywords",
17279
+ "Use broader search terms",
17280
+ "Create memories with hive_memory_set first"
17281
+ ]
17282
+ }, null, 2);
17283
+ }
17284
+ return JSON.stringify({
17285
+ total: result.results.length,
17286
+ query,
17287
+ fallback: result.fallback || false,
17288
+ results: result.results.map((r) => ({
17289
+ id: r.id,
17290
+ content: r.content,
17291
+ score: Math.round(r.score * 100) / 100,
17292
+ type: r.metadata.type,
17293
+ scope: r.metadata.scope,
17294
+ tags: r.metadata.tags
17295
+ }))
17296
+ }, null, 2);
17297
+ }
17298
+ });
17299
+ var hiveVectorAddTool = tool({
17300
+ description: `Add a memory with semantic indexing for future search.
17301
+
17302
+ **Metadata:**
17303
+ - type: Categorize the memory
17304
+ - scope: Project area or component
17305
+ - tags: Additional categorization
17306
+
17307
+ **Example:**
17308
+ \`\`\`
17309
+ Content: "Use async/await instead of .then() chains"
17310
+ Type: learning
17311
+ Scope: async-patterns
17312
+ Tags: javascript, promises, best-practice
17313
+ \`\`\``,
17314
+ args: {
17315
+ content: tool.schema.string().describe("Memory content to store"),
17316
+ type: tool.schema.enum(["decision", "learning", "preference", "blocker", "context", "pattern"]).optional().describe("Memory type"),
17317
+ scope: tool.schema.string().optional().describe("Scope (e.g., auth, api, ui)"),
17318
+ tags: tool.schema.array(tool.schema.string()).optional().describe("Tags for categorization")
17319
+ },
17320
+ async execute({ content, type, scope, tags }) {
17321
+ const metadata = {};
17322
+ if (type)
17323
+ metadata.type = type;
17324
+ if (scope)
17325
+ metadata.scope = scope;
17326
+ if (tags)
17327
+ metadata.tags = tags;
17328
+ const result = await VectorMemoryService.add(content, metadata);
17329
+ return JSON.stringify({
17330
+ success: result.success,
17331
+ id: result.id,
17332
+ fallback: result.fallback || false,
17333
+ message: `Memory stored${result.fallback ? " (text search mode)" : " (vector indexed)"}`
17334
+ }, null, 2);
17335
+ }
17336
+ });
17337
+ var hiveVectorStatusTool = tool({
17338
+ description: `Check vector memory status and statistics.
17339
+
17340
+ **Returns:**
17341
+ - available: Whether @sparkleideas/memory is working
17342
+ - type: vector or fallback
17343
+ - stats: Memory counts by type`,
17344
+ args: {},
17345
+ async execute() {
17346
+ const status = await VectorMemoryService.status();
17347
+ return JSON.stringify({
17348
+ status: status.available ? "ready" : "fallback",
17349
+ type: status.type,
17350
+ backend: status.available ? "@sparkleideas/memory (HNSW + Vector)" : "Simple text search",
17351
+ stats: status.stats,
17352
+ tips: status.available ? [] : [
17353
+ "Install @sparkleideas/memory for vector search",
17354
+ "npm install @sparkleideas/memory"
17355
+ ]
17356
+ }, null, 2);
17357
+ }
17358
+ });
17359
+
16531
17360
  // src/agents/hive.ts
16532
17361
  var QUEEN_BEE_PROMPT = `# Zetta (Hybrid)
16533
17362
 
@@ -17875,61 +18704,63 @@ var createBuiltinMcps = (disabledMcps = []) => {
17875
18704
 
17876
18705
  // ../hive-core/dist/index.js
17877
18706
  import { createRequire as createRequire2 } from "node:module";
17878
- import * as path3 from "path";
17879
- import * as fs3 from "fs";
18707
+ import * as path5 from "path";
18708
+ import * as os3 from "os";
17880
18709
  import * as path22 from "path";
18710
+ import * as fs5 from "fs";
18711
+ import * as path32 from "path";
17881
18712
  import * as fs22 from "fs";
17882
18713
  import * as fs32 from "fs";
17883
- import * as fs4 from "fs";
17884
- import * as fs5 from "fs";
18714
+ import * as fs42 from "fs";
18715
+ import * as fs52 from "fs";
17885
18716
  import * as fs7 from "fs/promises";
17886
- import * as path32 from "path";
18717
+ import * as path42 from "path";
17887
18718
  import { Buffer as Buffer2 } from "node:buffer";
17888
18719
  import { spawn } from "child_process";
17889
18720
  import { normalize } from "node:path";
17890
18721
  import { EventEmitter } from "node:events";
17891
18722
  import * as fs8 from "fs";
17892
- import * as path4 from "path";
18723
+ import * as path52 from "path";
17893
18724
  import * as fs10 from "fs";
17894
- import * as path6 from "path";
17895
- import * as fs11 from "fs";
17896
18725
  import * as path7 from "path";
17897
- import { existsSync as existsSync5 } from "fs";
17898
- import { join as join82, sep } from "path";
18726
+ import * as fs11 from "fs";
18727
+ import * as path8 from "path";
18728
+ import { existsSync as existsSync52 } from "fs";
18729
+ import { join as join92, sep } from "path";
17899
18730
  import { execSync } from "child_process";
17900
- var __create = Object.create;
17901
- var __getProtoOf = Object.getPrototypeOf;
18731
+ var __create2 = Object.create;
18732
+ var __getProtoOf2 = Object.getPrototypeOf;
17902
18733
  var __defProp2 = Object.defineProperty;
17903
- var __getOwnPropNames = Object.getOwnPropertyNames;
17904
- var __hasOwnProp = Object.prototype.hasOwnProperty;
17905
- function __accessProp(key) {
18734
+ var __getOwnPropNames2 = Object.getOwnPropertyNames;
18735
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
18736
+ function __accessProp2(key) {
17906
18737
  return this[key];
17907
18738
  }
17908
- var __toESMCache_node;
17909
- var __toESMCache_esm;
17910
- var __toESM = (mod, isNodeMode, target) => {
18739
+ var __toESMCache_node2;
18740
+ var __toESMCache_esm2;
18741
+ var __toESM2 = (mod, isNodeMode, target) => {
17911
18742
  var canCache = mod != null && typeof mod === "object";
17912
18743
  if (canCache) {
17913
- var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
18744
+ var cache = isNodeMode ? __toESMCache_node2 ??= new WeakMap : __toESMCache_esm2 ??= new WeakMap;
17914
18745
  var cached2 = cache.get(mod);
17915
18746
  if (cached2)
17916
18747
  return cached2;
17917
18748
  }
17918
- target = mod != null ? __create(__getProtoOf(mod)) : {};
18749
+ target = mod != null ? __create2(__getProtoOf2(mod)) : {};
17919
18750
  const to = isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target;
17920
- for (let key of __getOwnPropNames(mod))
17921
- if (!__hasOwnProp.call(to, key))
18751
+ for (let key of __getOwnPropNames2(mod))
18752
+ if (!__hasOwnProp2.call(to, key))
17922
18753
  __defProp2(to, key, {
17923
- get: __accessProp.bind(mod, key),
18754
+ get: __accessProp2.bind(mod, key),
17924
18755
  enumerable: true
17925
18756
  });
17926
18757
  if (canCache)
17927
18758
  cache.set(mod, to);
17928
18759
  return to;
17929
18760
  };
17930
- var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
18761
+ var __commonJS2 = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
17931
18762
  var __require2 = /* @__PURE__ */ createRequire2(import.meta.url);
17932
- var require_ms = __commonJS((exports, module) => {
18763
+ var require_ms = __commonJS2((exports, module) => {
17933
18764
  var s = 1000;
17934
18765
  var m = s * 60;
17935
18766
  var h = m * 60;
@@ -18037,7 +18868,7 @@ var require_ms = __commonJS((exports, module) => {
18037
18868
  return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
18038
18869
  }
18039
18870
  });
18040
- var require_common = __commonJS((exports, module) => {
18871
+ var require_common = __commonJS2((exports, module) => {
18041
18872
  function setup(env) {
18042
18873
  createDebug.debug = createDebug;
18043
18874
  createDebug.default = createDebug;
@@ -18210,7 +19041,7 @@ var require_common = __commonJS((exports, module) => {
18210
19041
  }
18211
19042
  module.exports = setup;
18212
19043
  });
18213
- var require_browser = __commonJS((exports, module) => {
19044
+ var require_browser = __commonJS2((exports, module) => {
18214
19045
  exports.formatArgs = formatArgs;
18215
19046
  exports.save = save;
18216
19047
  exports.load = load;
@@ -18368,7 +19199,7 @@ var require_browser = __commonJS((exports, module) => {
18368
19199
  }
18369
19200
  };
18370
19201
  });
18371
- var require_node = __commonJS((exports, module) => {
19202
+ var require_node = __commonJS2((exports, module) => {
18372
19203
  var tty = __require2("tty");
18373
19204
  var util = __require2("util");
18374
19205
  exports.init = init;
@@ -18539,14 +19370,14 @@ var require_node = __commonJS((exports, module) => {
18539
19370
  return util.inspect(v, this.inspectOpts);
18540
19371
  };
18541
19372
  });
18542
- var require_src = __commonJS((exports, module) => {
19373
+ var require_src = __commonJS2((exports, module) => {
18543
19374
  if (typeof process === "undefined" || process.type === "renderer" || false || process.__nwjs) {
18544
19375
  module.exports = require_browser();
18545
19376
  } else {
18546
19377
  module.exports = require_node();
18547
19378
  }
18548
19379
  });
18549
- var require_src2 = __commonJS((exports) => {
19380
+ var require_src2 = __commonJS2((exports) => {
18550
19381
  var __importDefault = exports && exports.__importDefault || function(mod) {
18551
19382
  return mod && mod.__esModule ? mod : { default: mod };
18552
19383
  };
@@ -18554,10 +19385,10 @@ var require_src2 = __commonJS((exports) => {
18554
19385
  var fs_1 = __require2("fs");
18555
19386
  var debug_1 = __importDefault(require_src());
18556
19387
  var log = debug_1.default("@kwsites/file-exists");
18557
- function check2(path33, isFile, isDirectory) {
18558
- log(`checking %s`, path33);
19388
+ function check2(path43, isFile, isDirectory) {
19389
+ log(`checking %s`, path43);
18559
19390
  try {
18560
- const stat2 = fs_1.statSync(path33);
19391
+ const stat2 = fs_1.statSync(path43);
18561
19392
  if (stat2.isFile() && isFile) {
18562
19393
  log(`[OK] path represents a file`);
18563
19394
  return true;
@@ -18577,15 +19408,15 @@ var require_src2 = __commonJS((exports) => {
18577
19408
  throw e;
18578
19409
  }
18579
19410
  }
18580
- function exists(path33, type = exports.READABLE) {
18581
- return check2(path33, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
19411
+ function exists(path43, type = exports.READABLE) {
19412
+ return check2(path43, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
18582
19413
  }
18583
19414
  exports.exists = exists;
18584
19415
  exports.FILE = 1;
18585
19416
  exports.FOLDER = 2;
18586
19417
  exports.READABLE = exports.FILE + exports.FOLDER;
18587
19418
  });
18588
- var require_dist = __commonJS((exports) => {
19419
+ var require_dist2 = __commonJS2((exports) => {
18589
19420
  function __export2(m) {
18590
19421
  for (var p in m)
18591
19422
  if (!exports.hasOwnProperty(p))
@@ -18594,7 +19425,7 @@ var require_dist = __commonJS((exports) => {
18594
19425
  Object.defineProperty(exports, "__esModule", { value: true });
18595
19426
  __export2(require_src2());
18596
19427
  });
18597
- var require_dist2 = __commonJS((exports) => {
19428
+ var require_dist22 = __commonJS2((exports) => {
18598
19429
  Object.defineProperty(exports, "__esModule", { value: true });
18599
19430
  exports.createDeferred = exports.deferred = undefined;
18600
19431
  function deferred() {
@@ -18740,6 +19571,16 @@ var DEFAULT_HIVE_CONFIG = {
18740
19571
  smartTitle: {
18741
19572
  enabled: false,
18742
19573
  updateThreshold: 1
19574
+ },
19575
+ agentBooster: {
19576
+ enabled: false,
19577
+ serverUrl: "http://localhost:3001",
19578
+ serverPort: 3001
19579
+ },
19580
+ vectorMemory: {
19581
+ enabled: false,
19582
+ indexPath: path5.join(os3.homedir(), ".config", "opencode", "hive", "vector-index"),
19583
+ dimensions: 384
18743
19584
  }
18744
19585
  };
18745
19586
  var HIVE_DIR = ".hive";
@@ -18756,78 +19597,78 @@ function normalizePath(filePath) {
18756
19597
  return filePath.replace(/\\/g, "/");
18757
19598
  }
18758
19599
  function getHivePath(projectRoot) {
18759
- return path3.join(projectRoot, HIVE_DIR);
19600
+ return path22.join(projectRoot, HIVE_DIR);
18760
19601
  }
18761
19602
  function getFeaturesPath(projectRoot) {
18762
- return path3.join(getHivePath(projectRoot), FEATURES_DIR);
19603
+ return path22.join(getHivePath(projectRoot), FEATURES_DIR);
18763
19604
  }
18764
19605
  function getFeaturePath(projectRoot, featureName) {
18765
- return path3.join(getFeaturesPath(projectRoot), featureName);
19606
+ return path22.join(getFeaturesPath(projectRoot), featureName);
18766
19607
  }
18767
19608
  function getPlanPath(projectRoot, featureName) {
18768
- return path3.join(getFeaturePath(projectRoot, featureName), PLAN_FILE);
19609
+ return path22.join(getFeaturePath(projectRoot, featureName), PLAN_FILE);
18769
19610
  }
18770
19611
  function getCommentsPath(projectRoot, featureName) {
18771
- return path3.join(getFeaturePath(projectRoot, featureName), COMMENTS_FILE);
19612
+ return path22.join(getFeaturePath(projectRoot, featureName), COMMENTS_FILE);
18772
19613
  }
18773
19614
  function getFeatureJsonPath(projectRoot, featureName) {
18774
- return path3.join(getFeaturePath(projectRoot, featureName), FEATURE_FILE);
19615
+ return path22.join(getFeaturePath(projectRoot, featureName), FEATURE_FILE);
18775
19616
  }
18776
19617
  function getContextPath(projectRoot, featureName) {
18777
- return path3.join(getFeaturePath(projectRoot, featureName), CONTEXT_DIR);
19618
+ return path22.join(getFeaturePath(projectRoot, featureName), CONTEXT_DIR);
18778
19619
  }
18779
19620
  function getTasksPath(projectRoot, featureName) {
18780
- return path3.join(getFeaturePath(projectRoot, featureName), TASKS_DIR);
19621
+ return path22.join(getFeaturePath(projectRoot, featureName), TASKS_DIR);
18781
19622
  }
18782
19623
  function getTaskPath(projectRoot, featureName, taskFolder) {
18783
- return path3.join(getTasksPath(projectRoot, featureName), taskFolder);
19624
+ return path22.join(getTasksPath(projectRoot, featureName), taskFolder);
18784
19625
  }
18785
19626
  function getTaskStatusPath(projectRoot, featureName, taskFolder) {
18786
- return path3.join(getTaskPath(projectRoot, featureName, taskFolder), STATUS_FILE);
19627
+ return path22.join(getTaskPath(projectRoot, featureName, taskFolder), STATUS_FILE);
18787
19628
  }
18788
19629
  function getTaskReportPath(projectRoot, featureName, taskFolder) {
18789
- return path3.join(getTaskPath(projectRoot, featureName, taskFolder), REPORT_FILE);
19630
+ return path22.join(getTaskPath(projectRoot, featureName, taskFolder), REPORT_FILE);
18790
19631
  }
18791
19632
  function getTaskSpecPath(projectRoot, featureName, taskFolder) {
18792
- return path3.join(getTaskPath(projectRoot, featureName, taskFolder), "spec.md");
19633
+ return path22.join(getTaskPath(projectRoot, featureName, taskFolder), "spec.md");
18793
19634
  }
18794
19635
  function getApprovedPath(projectRoot, featureName) {
18795
- return path3.join(getFeaturePath(projectRoot, featureName), APPROVED_FILE);
19636
+ return path22.join(getFeaturePath(projectRoot, featureName), APPROVED_FILE);
18796
19637
  }
18797
19638
  var SUBTASKS_DIR = "subtasks";
18798
19639
  var SPEC_FILE = "spec.md";
18799
19640
  function getSubtasksPath(projectRoot, featureName, taskFolder) {
18800
- return path3.join(getTaskPath(projectRoot, featureName, taskFolder), SUBTASKS_DIR);
19641
+ return path22.join(getTaskPath(projectRoot, featureName, taskFolder), SUBTASKS_DIR);
18801
19642
  }
18802
19643
  function getSubtaskPath(projectRoot, featureName, taskFolder, subtaskFolder) {
18803
- return path3.join(getSubtasksPath(projectRoot, featureName, taskFolder), subtaskFolder);
19644
+ return path22.join(getSubtasksPath(projectRoot, featureName, taskFolder), subtaskFolder);
18804
19645
  }
18805
19646
  function getSubtaskStatusPath(projectRoot, featureName, taskFolder, subtaskFolder) {
18806
- return path3.join(getSubtaskPath(projectRoot, featureName, taskFolder, subtaskFolder), STATUS_FILE);
19647
+ return path22.join(getSubtaskPath(projectRoot, featureName, taskFolder, subtaskFolder), STATUS_FILE);
18807
19648
  }
18808
19649
  function getSubtaskSpecPath(projectRoot, featureName, taskFolder, subtaskFolder) {
18809
- return path3.join(getSubtaskPath(projectRoot, featureName, taskFolder, subtaskFolder), SPEC_FILE);
19650
+ return path22.join(getSubtaskPath(projectRoot, featureName, taskFolder, subtaskFolder), SPEC_FILE);
18810
19651
  }
18811
19652
  function getSubtaskReportPath(projectRoot, featureName, taskFolder, subtaskFolder) {
18812
- return path3.join(getSubtaskPath(projectRoot, featureName, taskFolder, subtaskFolder), REPORT_FILE);
19653
+ return path22.join(getSubtaskPath(projectRoot, featureName, taskFolder, subtaskFolder), REPORT_FILE);
18813
19654
  }
18814
19655
  function ensureDir(dirPath) {
18815
- if (!fs3.existsSync(dirPath)) {
18816
- fs3.mkdirSync(dirPath, { recursive: true });
19656
+ if (!fs5.existsSync(dirPath)) {
19657
+ fs5.mkdirSync(dirPath, { recursive: true });
18817
19658
  }
18818
19659
  }
18819
19660
  function fileExists(filePath) {
18820
- return fs3.existsSync(filePath);
19661
+ return fs5.existsSync(filePath);
18821
19662
  }
18822
19663
  function readJson(filePath) {
18823
- if (!fs3.existsSync(filePath))
19664
+ if (!fs5.existsSync(filePath))
18824
19665
  return null;
18825
- const content = fs3.readFileSync(filePath, "utf-8");
19666
+ const content = fs5.readFileSync(filePath, "utf-8");
18826
19667
  return JSON.parse(content);
18827
19668
  }
18828
19669
  function writeJson(filePath, data) {
18829
- ensureDir(path3.dirname(filePath));
18830
- fs3.writeFileSync(filePath, JSON.stringify(data, null, 2));
19670
+ ensureDir(path22.dirname(filePath));
19671
+ fs5.writeFileSync(filePath, JSON.stringify(data, null, 2));
18831
19672
  }
18832
19673
  var DEFAULT_LOCK_OPTIONS = {
18833
19674
  timeout: 5000,
@@ -18839,7 +19680,7 @@ function getLockPath(filePath) {
18839
19680
  }
18840
19681
  function isLockStale(lockPath, staleTTL) {
18841
19682
  try {
18842
- const stat2 = fs3.statSync(lockPath);
19683
+ const stat2 = fs5.statSync(lockPath);
18843
19684
  const age = Date.now() - stat2.mtimeMs;
18844
19685
  return age > staleTTL;
18845
19686
  } catch {
@@ -18849,7 +19690,7 @@ function isLockStale(lockPath, staleTTL) {
18849
19690
  function acquireLockSync(filePath, options = {}) {
18850
19691
  const opts = { ...DEFAULT_LOCK_OPTIONS, ...options };
18851
19692
  const lockPath = getLockPath(filePath);
18852
- const lockDir = path3.dirname(lockPath);
19693
+ const lockDir = path22.dirname(lockPath);
18853
19694
  const startTime = Date.now();
18854
19695
  const lockContent = JSON.stringify({
18855
19696
  pid: process.pid,
@@ -18859,12 +19700,12 @@ function acquireLockSync(filePath, options = {}) {
18859
19700
  ensureDir(lockDir);
18860
19701
  while (true) {
18861
19702
  try {
18862
- const fd = fs3.openSync(lockPath, fs3.constants.O_CREAT | fs3.constants.O_EXCL | fs3.constants.O_WRONLY);
18863
- fs3.writeSync(fd, lockContent);
18864
- fs3.closeSync(fd);
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);
18865
19706
  return () => {
18866
19707
  try {
18867
- fs3.unlinkSync(lockPath);
19708
+ fs5.unlinkSync(lockPath);
18868
19709
  } catch {}
18869
19710
  };
18870
19711
  } catch (err) {
@@ -18874,7 +19715,7 @@ function acquireLockSync(filePath, options = {}) {
18874
19715
  } else if (error45.code === "EEXIST") {
18875
19716
  if (isLockStale(lockPath, opts.staleLockTTL)) {
18876
19717
  try {
18877
- fs3.unlinkSync(lockPath);
19718
+ fs5.unlinkSync(lockPath);
18878
19719
  continue;
18879
19720
  } catch {}
18880
19721
  }
@@ -18890,14 +19731,14 @@ function acquireLockSync(filePath, options = {}) {
18890
19731
  }
18891
19732
  }
18892
19733
  function writeAtomic(filePath, content) {
18893
- ensureDir(path3.dirname(filePath));
19734
+ ensureDir(path22.dirname(filePath));
18894
19735
  const tempPath = `${filePath}.tmp.${process.pid}.${Date.now()}`;
18895
19736
  try {
18896
- fs3.writeFileSync(tempPath, content);
18897
- fs3.renameSync(tempPath, filePath);
19737
+ fs5.writeFileSync(tempPath, content);
19738
+ fs5.renameSync(tempPath, filePath);
18898
19739
  } catch (error45) {
18899
19740
  try {
18900
- fs3.unlinkSync(tempPath);
19741
+ fs5.unlinkSync(tempPath);
18901
19742
  } catch {}
18902
19743
  throw error45;
18903
19744
  }
@@ -18932,13 +19773,13 @@ function patchJsonLockedSync(filePath, patch, options = {}) {
18932
19773
  }
18933
19774
  }
18934
19775
  function readText(filePath) {
18935
- if (!fs3.existsSync(filePath))
19776
+ if (!fs5.existsSync(filePath))
18936
19777
  return null;
18937
- return fs3.readFileSync(filePath, "utf-8");
19778
+ return fs5.readFileSync(filePath, "utf-8");
18938
19779
  }
18939
19780
  function writeText(filePath, content) {
18940
- ensureDir(path3.dirname(filePath));
18941
- fs3.writeFileSync(filePath, content);
19781
+ ensureDir(path22.dirname(filePath));
19782
+ fs5.writeFileSync(filePath, content);
18942
19783
  }
18943
19784
  function detectContext(cwd) {
18944
19785
  const result = {
@@ -18958,7 +19799,7 @@ function detectContext(cwd) {
18958
19799
  result.projectRoot = worktreeMatch[1];
18959
19800
  return result;
18960
19801
  }
18961
- const gitPath = path22.join(cwd, ".git");
19802
+ const gitPath = path32.join(cwd, ".git");
18962
19803
  if (fs22.existsSync(gitPath)) {
18963
19804
  const stat2 = fs22.statSync(gitPath);
18964
19805
  if (stat2.isFile()) {
@@ -19134,7 +19975,7 @@ class PlanService {
19134
19975
  }
19135
19976
  const approvedPath = getApprovedPath(this.projectRoot, featureName);
19136
19977
  const timestamp = new Date().toISOString();
19137
- fs4.writeFileSync(approvedPath, `Approved at ${timestamp}
19978
+ fs42.writeFileSync(approvedPath, `Approved at ${timestamp}
19138
19979
  `);
19139
19980
  const featurePath = getFeatureJsonPath(this.projectRoot, featureName);
19140
19981
  const feature = readJson(featurePath);
@@ -19150,7 +19991,7 @@ class PlanService {
19150
19991
  revokeApproval(featureName) {
19151
19992
  const approvedPath = getApprovedPath(this.projectRoot, featureName);
19152
19993
  if (fileExists(approvedPath)) {
19153
- fs4.unlinkSync(approvedPath);
19994
+ fs42.unlinkSync(approvedPath);
19154
19995
  }
19155
19996
  const featurePath = getFeatureJsonPath(this.projectRoot, featureName);
19156
19997
  const feature = readJson(featurePath);
@@ -19396,20 +20237,20 @@ ${f.content}`).join(`
19396
20237
  return [task.order - 1];
19397
20238
  };
19398
20239
  const visited = new Map;
19399
- const path33 = [];
20240
+ const path43 = [];
19400
20241
  const dfs = (taskOrder) => {
19401
20242
  const state = visited.get(taskOrder);
19402
20243
  if (state === 2) {
19403
20244
  return;
19404
20245
  }
19405
20246
  if (state === 1) {
19406
- const cycleStart = path33.indexOf(taskOrder);
19407
- const cyclePath = [...path33.slice(cycleStart), taskOrder];
20247
+ const cycleStart = path43.indexOf(taskOrder);
20248
+ const cyclePath = [...path43.slice(cycleStart), taskOrder];
19408
20249
  const cycleDesc = cyclePath.join(" -> ");
19409
20250
  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
20251
  }
19411
20252
  visited.set(taskOrder, 1);
19412
- path33.push(taskOrder);
20253
+ path43.push(taskOrder);
19413
20254
  const task = taskByOrder.get(taskOrder);
19414
20255
  if (task) {
19415
20256
  const deps = getDependencies(task);
@@ -19417,7 +20258,7 @@ ${f.content}`).join(`
19417
20258
  dfs(depOrder);
19418
20259
  }
19419
20260
  }
19420
- path33.pop();
20261
+ path43.pop();
19421
20262
  visited.set(taskOrder, 2);
19422
20263
  };
19423
20264
  for (const task of tasks) {
@@ -19503,12 +20344,12 @@ ${f.content}`).join(`
19503
20344
  const tasksPath = getTasksPath(this.projectRoot, featureName);
19504
20345
  if (!fileExists(tasksPath))
19505
20346
  return [];
19506
- return fs5.readdirSync(tasksPath, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name).sort();
20347
+ return fs52.readdirSync(tasksPath, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name).sort();
19507
20348
  }
19508
20349
  deleteTask(featureName, taskFolder) {
19509
20350
  const taskPath = getTaskPath(this.projectRoot, featureName, taskFolder);
19510
20351
  if (fileExists(taskPath)) {
19511
- fs5.rmSync(taskPath, { recursive: true });
20352
+ fs52.rmSync(taskPath, { recursive: true });
19512
20353
  }
19513
20354
  }
19514
20355
  getNextOrder(existingFolders) {
@@ -19660,7 +20501,7 @@ _Add detailed instructions here_
19660
20501
  }
19661
20502
  const subtaskPath = getSubtaskPath(this.projectRoot, featureName, taskFolder, subtaskFolder);
19662
20503
  if (fileExists(subtaskPath)) {
19663
- fs5.rmSync(subtaskPath, { recursive: true });
20504
+ fs52.rmSync(subtaskPath, { recursive: true });
19664
20505
  }
19665
20506
  }
19666
20507
  getSubtask(featureName, taskFolder, subtaskId) {
@@ -19720,7 +20561,7 @@ _Add detailed instructions here_
19720
20561
  const subtasksPath = getSubtasksPath(this.projectRoot, featureName, taskFolder);
19721
20562
  if (!fileExists(subtasksPath))
19722
20563
  return [];
19723
- return fs5.readdirSync(subtasksPath, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name).sort();
20564
+ return fs52.readdirSync(subtasksPath, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name).sort();
19724
20565
  }
19725
20566
  findSubtaskFolder(featureName, taskFolder, subtaskId) {
19726
20567
  const folders = this.listSubtaskFolders(featureName, taskFolder);
@@ -19731,19 +20572,19 @@ _Add detailed instructions here_
19731
20572
  return name.toLowerCase().replace(/\s+/g, "-").replace(/[^a-z0-9-]/g, "");
19732
20573
  }
19733
20574
  }
19734
- var import_file_exists = __toESM(require_dist(), 1);
19735
- var import_debug = __toESM(require_src(), 1);
19736
- var import_promise_deferred = __toESM(require_dist2(), 1);
19737
- var import_promise_deferred2 = __toESM(require_dist2(), 1);
20575
+ var import_file_exists = __toESM2(require_dist2(), 1);
20576
+ var import_debug = __toESM2(require_src(), 1);
20577
+ var import_promise_deferred = __toESM2(require_dist22(), 1);
20578
+ var import_promise_deferred2 = __toESM2(require_dist22(), 1);
19738
20579
  var __defProp22 = Object.defineProperty;
19739
20580
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
19740
- var __getOwnPropNames2 = Object.getOwnPropertyNames;
19741
- var __hasOwnProp2 = Object.prototype.hasOwnProperty;
20581
+ var __getOwnPropNames22 = Object.getOwnPropertyNames;
20582
+ var __hasOwnProp22 = Object.prototype.hasOwnProperty;
19742
20583
  var __esm2 = (fn, res) => function __init() {
19743
- return fn && (res = (0, fn[__getOwnPropNames2(fn)[0]])(fn = 0)), res;
20584
+ return fn && (res = (0, fn[__getOwnPropNames22(fn)[0]])(fn = 0)), res;
19744
20585
  };
19745
- var __commonJS2 = (cb, mod) => function __require22() {
19746
- return mod || (0, cb[__getOwnPropNames2(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
20586
+ var __commonJS22 = (cb, mod) => function __require22() {
20587
+ return mod || (0, cb[__getOwnPropNames22(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
19747
20588
  };
19748
20589
  var __export2 = (target, all) => {
19749
20590
  for (var name in all)
@@ -19751,8 +20592,8 @@ var __export2 = (target, all) => {
19751
20592
  };
19752
20593
  var __copyProps = (to, from, except, desc) => {
19753
20594
  if (from && typeof from === "object" || typeof from === "function") {
19754
- for (let key of __getOwnPropNames2(from))
19755
- if (!__hasOwnProp2.call(to, key) && key !== except)
20595
+ for (let key of __getOwnPropNames22(from))
20596
+ if (!__hasOwnProp22.call(to, key) && key !== except)
19756
20597
  __defProp22(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19757
20598
  }
19758
20599
  return to;
@@ -19763,8 +20604,8 @@ function pathspec(...paths) {
19763
20604
  cache.set(key, paths);
19764
20605
  return key;
19765
20606
  }
19766
- function isPathSpec(path33) {
19767
- return path33 instanceof String && cache.has(path33);
20607
+ function isPathSpec(path43) {
20608
+ return path43 instanceof String && cache.has(path43);
19768
20609
  }
19769
20610
  function toPaths(pathSpec) {
19770
20611
  return cache.get(pathSpec) || [];
@@ -19850,8 +20691,8 @@ function toLinesWithContent(input = "", trimmed2 = true, separator = `
19850
20691
  function forEachLineWithContent(input, callback) {
19851
20692
  return toLinesWithContent(input, true).map((line) => callback(line));
19852
20693
  }
19853
- function folderExists(path33) {
19854
- return import_file_exists.exists(path33, import_file_exists.FOLDER);
20694
+ function folderExists(path43) {
20695
+ return import_file_exists.exists(path43, import_file_exists.FOLDER);
19855
20696
  }
19856
20697
  function append(target, item) {
19857
20698
  if (Array.isArray(target)) {
@@ -20242,8 +21083,8 @@ function checkIsRepoRootTask() {
20242
21083
  commands,
20243
21084
  format: "utf-8",
20244
21085
  onError,
20245
- parser(path33) {
20246
- return /^\.(git)?$/.test(path33.trim());
21086
+ parser(path43) {
21087
+ return /^\.(git)?$/.test(path43.trim());
20247
21088
  }
20248
21089
  };
20249
21090
  }
@@ -20654,11 +21495,11 @@ function parseGrep(grep) {
20654
21495
  const paths = /* @__PURE__ */ new Set;
20655
21496
  const results = {};
20656
21497
  forEachLineWithContent(grep, (input) => {
20657
- const [path33, line, preview] = input.split(NULL);
20658
- paths.add(path33);
20659
- (results[path33] = results[path33] || []).push({
21498
+ const [path43, line, preview] = input.split(NULL);
21499
+ paths.add(path43);
21500
+ (results[path43] = results[path43] || []).push({
20660
21501
  line: asNumber(line),
20661
- path: path33,
21502
+ path: path43,
20662
21503
  preview
20663
21504
  });
20664
21505
  });
@@ -21324,14 +22165,14 @@ var init_hash_object = __esm2({
21324
22165
  init_task();
21325
22166
  }
21326
22167
  });
21327
- function parseInit(bare, path33, text) {
22168
+ function parseInit(bare, path43, text) {
21328
22169
  const response = String(text).trim();
21329
22170
  let result;
21330
22171
  if (result = initResponseRegex.exec(response)) {
21331
- return new InitSummary(bare, path33, false, result[1]);
22172
+ return new InitSummary(bare, path43, false, result[1]);
21332
22173
  }
21333
22174
  if (result = reInitResponseRegex.exec(response)) {
21334
- return new InitSummary(bare, path33, true, result[1]);
22175
+ return new InitSummary(bare, path43, true, result[1]);
21335
22176
  }
21336
22177
  let gitDir = "";
21337
22178
  const tokens = response.split(" ");
@@ -21342,7 +22183,7 @@ function parseInit(bare, path33, text) {
21342
22183
  break;
21343
22184
  }
21344
22185
  }
21345
- return new InitSummary(bare, path33, /^re/i.test(response), gitDir);
22186
+ return new InitSummary(bare, path43, /^re/i.test(response), gitDir);
21346
22187
  }
21347
22188
  var InitSummary;
21348
22189
  var initResponseRegex;
@@ -21350,9 +22191,9 @@ var reInitResponseRegex;
21350
22191
  var init_InitSummary = __esm2({
21351
22192
  "src/lib/responses/InitSummary.ts"() {
21352
22193
  InitSummary = class {
21353
- constructor(bare, path33, existing, gitDir) {
22194
+ constructor(bare, path43, existing, gitDir) {
21354
22195
  this.bare = bare;
21355
- this.path = path33;
22196
+ this.path = path43;
21356
22197
  this.existing = existing;
21357
22198
  this.gitDir = gitDir;
21358
22199
  }
@@ -21364,7 +22205,7 @@ var init_InitSummary = __esm2({
21364
22205
  function hasBareCommand(command) {
21365
22206
  return command.includes(bareCommand);
21366
22207
  }
21367
- function initTask(bare = false, path33, customArgs) {
22208
+ function initTask(bare = false, path43, customArgs) {
21368
22209
  const commands = ["init", ...customArgs];
21369
22210
  if (bare && !hasBareCommand(commands)) {
21370
22211
  commands.splice(1, 0, bareCommand);
@@ -21373,7 +22214,7 @@ function initTask(bare = false, path33, customArgs) {
21373
22214
  commands,
21374
22215
  format: "utf-8",
21375
22216
  parser(text) {
21376
- return parseInit(commands.includes("--bare"), path33, text);
22217
+ return parseInit(commands.includes("--bare"), path43, text);
21377
22218
  }
21378
22219
  };
21379
22220
  }
@@ -22088,12 +22929,12 @@ var init_FileStatusSummary = __esm2({
22088
22929
  "src/lib/responses/FileStatusSummary.ts"() {
22089
22930
  fromPathRegex = /^(.+)\0(.+)$/;
22090
22931
  FileStatusSummary = class {
22091
- constructor(path33, index, working_dir) {
22092
- this.path = path33;
22932
+ constructor(path43, index, working_dir) {
22933
+ this.path = path43;
22093
22934
  this.index = index;
22094
22935
  this.working_dir = working_dir;
22095
22936
  if (index === "R" || working_dir === "R") {
22096
- const detail = fromPathRegex.exec(path33) || [null, path33, path33];
22937
+ const detail = fromPathRegex.exec(path43) || [null, path43, path43];
22097
22938
  this.from = detail[2] || "";
22098
22939
  this.path = detail[1] || "";
22099
22940
  }
@@ -22124,14 +22965,14 @@ function splitLine(result, lineStr) {
22124
22965
  default:
22125
22966
  return;
22126
22967
  }
22127
- function data(index, workingDir, path33) {
22968
+ function data(index, workingDir, path43) {
22128
22969
  const raw = `${index}${workingDir}`;
22129
22970
  const handler = parsers6.get(raw);
22130
22971
  if (handler) {
22131
- handler(result, path33);
22972
+ handler(result, path43);
22132
22973
  }
22133
22974
  if (raw !== "##" && raw !== "!!") {
22134
- result.files.push(new FileStatusSummary(path33, index, workingDir));
22975
+ result.files.push(new FileStatusSummary(path43, index, workingDir));
22135
22976
  }
22136
22977
  }
22137
22978
  }
@@ -22415,8 +23256,8 @@ var init_simple_git_api = __esm2({
22415
23256
  }
22416
23257
  return this._runTask(configurationErrorTask("Git.cwd: workingDirectory must be supplied as a string"), next);
22417
23258
  }
22418
- hashObject(path33, write) {
22419
- return this._runTask(hashObjectTask(path33, write === true), trailingFunctionArgument(arguments));
23259
+ hashObject(path43, write) {
23260
+ return this._runTask(hashObjectTask(path43, write === true), trailingFunctionArgument(arguments));
22420
23261
  }
22421
23262
  init(bare) {
22422
23263
  return this._runTask(initTask(bare === true, this._executor.cwd, getTrailingOptions(arguments)), trailingFunctionArgument(arguments));
@@ -22709,8 +23550,8 @@ var init_branch = __esm2({
22709
23550
  }
22710
23551
  });
22711
23552
  function toPath(input) {
22712
- const path33 = input.trim().replace(/^["']|["']$/g, "");
22713
- return path33 && normalize(path33);
23553
+ const path43 = input.trim().replace(/^["']|["']$/g, "");
23554
+ return path43 && normalize(path43);
22714
23555
  }
22715
23556
  var parseCheckIgnore;
22716
23557
  var init_CheckIgnore = __esm2({
@@ -22975,8 +23816,8 @@ __export2(sub_module_exports, {
22975
23816
  subModuleTask: () => subModuleTask,
22976
23817
  updateSubModuleTask: () => updateSubModuleTask
22977
23818
  });
22978
- function addSubModuleTask(repo, path33) {
22979
- return subModuleTask(["add", repo, path33]);
23819
+ function addSubModuleTask(repo, path43) {
23820
+ return subModuleTask(["add", repo, path43]);
22980
23821
  }
22981
23822
  function initSubModuleTask(customArgs) {
22982
23823
  return subModuleTask(["init", ...customArgs]);
@@ -23089,7 +23930,7 @@ var init_tag = __esm2({
23089
23930
  init_TagList();
23090
23931
  }
23091
23932
  });
23092
- var require_git = __commonJS2({
23933
+ var require_git = __commonJS22({
23093
23934
  "src/git.js"(exports, module) {
23094
23935
  var { GitExecutor: GitExecutor2 } = (init_git_executor(), __toCommonJS(git_executor_exports));
23095
23936
  var { SimpleGitApi: SimpleGitApi2 } = (init_simple_git_api(), __toCommonJS(simple_git_api_exports));
@@ -23230,8 +24071,8 @@ var require_git = __commonJS2({
23230
24071
  }
23231
24072
  return this._runTask(straightThroughStringTask2(command, this._trimmed), next);
23232
24073
  };
23233
- Git2.prototype.submoduleAdd = function(repo, path33, then) {
23234
- return this._runTask(addSubModuleTask2(repo, path33), trailingFunctionArgument2(arguments));
24074
+ Git2.prototype.submoduleAdd = function(repo, path43, then) {
24075
+ return this._runTask(addSubModuleTask2(repo, path43), trailingFunctionArgument2(arguments));
23235
24076
  };
23236
24077
  Git2.prototype.submoduleUpdate = function(args2, then) {
23237
24078
  return this._runTask(updateSubModuleTask2(getTrailingOptions2(arguments, true)), trailingFunctionArgument2(arguments));
@@ -23764,19 +24605,19 @@ class WorktreeService {
23764
24605
  return esm_default(cwd || this.config.baseDir);
23765
24606
  }
23766
24607
  getWorktreesDir() {
23767
- return path32.join(this.config.hiveDir, ".worktrees");
24608
+ return path42.join(this.config.hiveDir, ".worktrees");
23768
24609
  }
23769
24610
  getWorktreePath(feature, step) {
23770
- return path32.join(this.getWorktreesDir(), feature, step);
24611
+ return path42.join(this.getWorktreesDir(), feature, step);
23771
24612
  }
23772
24613
  async getStepStatusPath(feature, step) {
23773
- const featurePath = path32.join(this.config.hiveDir, "features", feature);
23774
- const tasksPath = path32.join(featurePath, "tasks", step, "status.json");
24614
+ const featurePath = path42.join(this.config.hiveDir, "features", feature);
24615
+ const tasksPath = path42.join(featurePath, "tasks", step, "status.json");
23775
24616
  try {
23776
24617
  await fs7.access(tasksPath);
23777
24618
  return tasksPath;
23778
24619
  } catch {}
23779
- return path32.join(featurePath, "execution", step, "status.json");
24620
+ return path42.join(featurePath, "execution", step, "status.json");
23780
24621
  }
23781
24622
  getBranchName(feature, step) {
23782
24623
  return `hive/${feature}/${step}`;
@@ -23785,7 +24626,7 @@ class WorktreeService {
23785
24626
  const worktreePath = this.getWorktreePath(feature, step);
23786
24627
  const branchName = this.getBranchName(feature, step);
23787
24628
  const git = this.getGit();
23788
- await fs7.mkdir(path32.dirname(worktreePath), { recursive: true });
24629
+ await fs7.mkdir(path42.dirname(worktreePath), { recursive: true });
23789
24630
  const base = baseBranch || (await git.revparse(["HEAD"])).trim();
23790
24631
  const existing = await this.get(feature, step);
23791
24632
  if (existing) {
@@ -23880,7 +24721,7 @@ class WorktreeService {
23880
24721
  }
23881
24722
  async exportPatch(feature, step, baseBranch) {
23882
24723
  const worktreePath = this.getWorktreePath(feature, step);
23883
- const patchPath = path32.join(worktreePath, "..", `${step}.patch`);
24724
+ const patchPath = path42.join(worktreePath, "..", `${step}.patch`);
23884
24725
  const base = baseBranch || "HEAD~1";
23885
24726
  const worktreeGit = this.getGit(worktreePath);
23886
24727
  const diff = await worktreeGit.diff([`${base}...HEAD`]);
@@ -23892,7 +24733,7 @@ class WorktreeService {
23892
24733
  if (!hasDiff) {
23893
24734
  return { success: true, filesAffected: [] };
23894
24735
  }
23895
- const patchPath = path32.join(this.config.hiveDir, ".worktrees", feature, `${step}.patch`);
24736
+ const patchPath = path42.join(this.config.hiveDir, ".worktrees", feature, `${step}.patch`);
23896
24737
  try {
23897
24738
  await fs7.writeFile(patchPath, diffContent);
23898
24739
  const git = this.getGit();
@@ -23914,7 +24755,7 @@ class WorktreeService {
23914
24755
  if (!hasDiff) {
23915
24756
  return { success: true, filesAffected: [] };
23916
24757
  }
23917
- const patchPath = path32.join(this.config.hiveDir, ".worktrees", feature, `${step}.patch`);
24758
+ const patchPath = path42.join(this.config.hiveDir, ".worktrees", feature, `${step}.patch`);
23918
24759
  try {
23919
24760
  await fs7.writeFile(patchPath, diffContent);
23920
24761
  const git = this.getGit();
@@ -23983,7 +24824,7 @@ class WorktreeService {
23983
24824
  try {
23984
24825
  const features = feature ? [feature] : await fs7.readdir(worktreesDir);
23985
24826
  for (const feat of features) {
23986
- const featurePath = path32.join(worktreesDir, feat);
24827
+ const featurePath = path42.join(worktreesDir, feat);
23987
24828
  const stat2 = await fs7.stat(featurePath).catch(() => null);
23988
24829
  if (!stat2?.isDirectory())
23989
24830
  continue;
@@ -24007,13 +24848,13 @@ class WorktreeService {
24007
24848
  const worktreesDir = this.getWorktreesDir();
24008
24849
  const features = feature ? [feature] : await fs7.readdir(worktreesDir).catch(() => []);
24009
24850
  for (const feat of features) {
24010
- const featurePath = path32.join(worktreesDir, feat);
24851
+ const featurePath = path42.join(worktreesDir, feat);
24011
24852
  const stat2 = await fs7.stat(featurePath).catch(() => null);
24012
24853
  if (!stat2?.isDirectory())
24013
24854
  continue;
24014
24855
  const steps = await fs7.readdir(featurePath).catch(() => []);
24015
24856
  for (const step of steps) {
24016
- const worktreePath = path32.join(featurePath, step);
24857
+ const worktreePath = path42.join(featurePath, step);
24017
24858
  const stepStat = await fs7.stat(worktreePath).catch(() => null);
24018
24859
  if (!stepStat?.isDirectory())
24019
24860
  continue;
@@ -24033,7 +24874,7 @@ class WorktreeService {
24033
24874
  if (!hasDiff) {
24034
24875
  return [];
24035
24876
  }
24036
- const patchPath = path32.join(this.config.hiveDir, ".worktrees", feature, `${step}-check.patch`);
24877
+ const patchPath = path42.join(this.config.hiveDir, ".worktrees", feature, `${step}-check.patch`);
24037
24878
  try {
24038
24879
  await fs7.writeFile(patchPath, diffContent);
24039
24880
  const git = this.getGit();
@@ -24204,7 +25045,7 @@ class ContextService {
24204
25045
  write(featureName, fileName, content) {
24205
25046
  const contextPath = getContextPath(this.projectRoot, featureName);
24206
25047
  ensureDir(contextPath);
24207
- const filePath = path4.join(contextPath, this.normalizeFileName(fileName));
25048
+ const filePath = path52.join(contextPath, this.normalizeFileName(fileName));
24208
25049
  writeText(filePath, content);
24209
25050
  const totalChars = this.list(featureName).reduce((sum, c) => sum + c.content.length, 0);
24210
25051
  if (totalChars > 20000) {
@@ -24216,7 +25057,7 @@ class ContextService {
24216
25057
  }
24217
25058
  read(featureName, fileName) {
24218
25059
  const contextPath = getContextPath(this.projectRoot, featureName);
24219
- const filePath = path4.join(contextPath, this.normalizeFileName(fileName));
25060
+ const filePath = path52.join(contextPath, this.normalizeFileName(fileName));
24220
25061
  return readText(filePath);
24221
25062
  }
24222
25063
  list(featureName) {
@@ -24225,7 +25066,7 @@ class ContextService {
24225
25066
  return [];
24226
25067
  const files = fs8.readdirSync(contextPath, { withFileTypes: true }).filter((f) => f.isFile() && f.name.endsWith(".md")).map((f) => f.name);
24227
25068
  return files.map((name) => {
24228
- const filePath = path4.join(contextPath, name);
25069
+ const filePath = path52.join(contextPath, name);
24229
25070
  const stat2 = fs8.statSync(filePath);
24230
25071
  const content = readText(filePath) || "";
24231
25072
  return {
@@ -24237,7 +25078,7 @@ class ContextService {
24237
25078
  }
24238
25079
  delete(featureName, fileName) {
24239
25080
  const contextPath = getContextPath(this.projectRoot, featureName);
24240
- const filePath = path4.join(contextPath, this.normalizeFileName(fileName));
25081
+ const filePath = path52.join(contextPath, this.normalizeFileName(fileName));
24241
25082
  if (fileExists(filePath)) {
24242
25083
  fs8.unlinkSync(filePath);
24243
25084
  return true;
@@ -24262,14 +25103,14 @@ ${f.content}`);
24262
25103
  if (contexts.length === 0)
24263
25104
  return { archived: [], archivePath: "" };
24264
25105
  const contextPath = getContextPath(this.projectRoot, featureName);
24265
- const archiveDir = path4.join(contextPath, "..", "archive");
25106
+ const archiveDir = path52.join(contextPath, "..", "archive");
24266
25107
  ensureDir(archiveDir);
24267
25108
  const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
24268
25109
  const archived = [];
24269
25110
  for (const ctx of contexts) {
24270
25111
  const archiveName = `${timestamp}_${ctx.name}.md`;
24271
- const src = path4.join(contextPath, `${ctx.name}.md`);
24272
- const dest = path4.join(archiveDir, archiveName);
25112
+ const src = path52.join(contextPath, `${ctx.name}.md`);
25113
+ const dest = path52.join(archiveDir, archiveName);
24273
25114
  fs8.copyFileSync(src, dest);
24274
25115
  fs8.unlinkSync(src);
24275
25116
  archived.push(ctx.name);
@@ -24299,8 +25140,8 @@ class ConfigService {
24299
25140
  cachedCustomAgentConfigs = null;
24300
25141
  constructor() {
24301
25142
  const homeDir = process.env.HOME || process.env.USERPROFILE || "";
24302
- const configDir = path6.join(homeDir, ".config", "opencode");
24303
- this.configPath = path6.join(configDir, "agent_hive.json");
25143
+ const configDir = path7.join(homeDir, ".config", "opencode");
25144
+ this.configPath = path7.join(configDir, "agent_hive.json");
24304
25145
  }
24305
25146
  getPath() {
24306
25147
  return this.configPath;
@@ -24363,7 +25204,7 @@ class ConfigService {
24363
25204
  ...updates.customAgents
24364
25205
  } : current.customAgents
24365
25206
  };
24366
- const configDir = path6.dirname(this.configPath);
25207
+ const configDir = path7.dirname(this.configPath);
24367
25208
  if (!fs10.existsSync(configDir)) {
24368
25209
  fs10.mkdirSync(configDir, { recursive: true });
24369
25210
  }
@@ -24518,7 +25359,7 @@ class AgentsMdService {
24518
25359
  this.contextService = contextService;
24519
25360
  }
24520
25361
  async init() {
24521
- const agentsMdPath = path7.join(this.rootDir, "AGENTS.md");
25362
+ const agentsMdPath = path8.join(this.rootDir, "AGENTS.md");
24522
25363
  const existed = fileExists(agentsMdPath);
24523
25364
  if (existed) {
24524
25365
  const existing = readText(agentsMdPath);
@@ -24529,14 +25370,14 @@ class AgentsMdService {
24529
25370
  }
24530
25371
  async sync(featureName) {
24531
25372
  const contexts = this.contextService.list(featureName);
24532
- const agentsMdPath = path7.join(this.rootDir, "AGENTS.md");
25373
+ const agentsMdPath = path8.join(this.rootDir, "AGENTS.md");
24533
25374
  const current = await fs11.promises.readFile(agentsMdPath, "utf-8").catch(() => "");
24534
25375
  const findings = this.extractFindings(contexts);
24535
25376
  const proposals = this.generateProposals(findings, current);
24536
25377
  return { proposals, diff: this.formatDiff(current, proposals) };
24537
25378
  }
24538
25379
  apply(content) {
24539
- const agentsMdPath = path7.join(this.rootDir, "AGENTS.md");
25380
+ const agentsMdPath = path8.join(this.rootDir, "AGENTS.md");
24540
25381
  const isNew = !fileExists(agentsMdPath);
24541
25382
  writeText(agentsMdPath, content);
24542
25383
  return { path: agentsMdPath, chars: content.length, isNew };
@@ -24596,7 +25437,7 @@ class AgentsMdService {
24596
25437
  return this.generateTemplate(detections);
24597
25438
  }
24598
25439
  async detectProjectInfo() {
24599
- const packageJsonPath = path7.join(this.rootDir, "package.json");
25440
+ const packageJsonPath = path8.join(this.rootDir, "package.json");
24600
25441
  let packageJson = null;
24601
25442
  if (fileExists(packageJsonPath)) {
24602
25443
  try {
@@ -24616,26 +25457,26 @@ class AgentsMdService {
24616
25457
  return info;
24617
25458
  }
24618
25459
  detectPackageManager() {
24619
- if (fileExists(path7.join(this.rootDir, "bun.lockb")))
25460
+ if (fileExists(path8.join(this.rootDir, "bun.lockb")))
24620
25461
  return "bun";
24621
- if (fileExists(path7.join(this.rootDir, "pnpm-lock.yaml")))
25462
+ if (fileExists(path8.join(this.rootDir, "pnpm-lock.yaml")))
24622
25463
  return "pnpm";
24623
- if (fileExists(path7.join(this.rootDir, "yarn.lock")))
25464
+ if (fileExists(path8.join(this.rootDir, "yarn.lock")))
24624
25465
  return "yarn";
24625
- if (fileExists(path7.join(this.rootDir, "package-lock.json")))
25466
+ if (fileExists(path8.join(this.rootDir, "package-lock.json")))
24626
25467
  return "npm";
24627
25468
  return "npm";
24628
25469
  }
24629
25470
  detectLanguage() {
24630
- if (fileExists(path7.join(this.rootDir, "tsconfig.json")))
25471
+ if (fileExists(path8.join(this.rootDir, "tsconfig.json")))
24631
25472
  return "TypeScript";
24632
- if (fileExists(path7.join(this.rootDir, "package.json")))
25473
+ if (fileExists(path8.join(this.rootDir, "package.json")))
24633
25474
  return "JavaScript";
24634
- if (fileExists(path7.join(this.rootDir, "requirements.txt")))
25475
+ if (fileExists(path8.join(this.rootDir, "requirements.txt")))
24635
25476
  return "Python";
24636
- if (fileExists(path7.join(this.rootDir, "go.mod")))
25477
+ if (fileExists(path8.join(this.rootDir, "go.mod")))
24637
25478
  return "Go";
24638
- if (fileExists(path7.join(this.rootDir, "Cargo.toml")))
25479
+ if (fileExists(path8.join(this.rootDir, "Cargo.toml")))
24639
25480
  return "Rust";
24640
25481
  return "Unknown";
24641
25482
  }
@@ -24716,19 +25557,19 @@ class AgentsMdService {
24716
25557
 
24717
25558
  class DockerSandboxService {
24718
25559
  static detectImage(worktreePath) {
24719
- if (existsSync5(join82(worktreePath, "Dockerfile"))) {
25560
+ if (existsSync52(join92(worktreePath, "Dockerfile"))) {
24720
25561
  return null;
24721
25562
  }
24722
- if (existsSync5(join82(worktreePath, "package.json"))) {
25563
+ if (existsSync52(join92(worktreePath, "package.json"))) {
24723
25564
  return "node:22-slim";
24724
25565
  }
24725
- if (existsSync5(join82(worktreePath, "requirements.txt")) || existsSync5(join82(worktreePath, "pyproject.toml"))) {
25566
+ if (existsSync52(join92(worktreePath, "requirements.txt")) || existsSync52(join92(worktreePath, "pyproject.toml"))) {
24726
25567
  return "python:3.12-slim";
24727
25568
  }
24728
- if (existsSync5(join82(worktreePath, "go.mod"))) {
25569
+ if (existsSync52(join92(worktreePath, "go.mod"))) {
24729
25570
  return "golang:1.22-slim";
24730
25571
  }
24731
- if (existsSync5(join82(worktreePath, "Cargo.toml"))) {
25572
+ if (existsSync52(join92(worktreePath, "Cargo.toml"))) {
24732
25573
  return "rust:1.77-slim";
24733
25574
  }
24734
25575
  return "ubuntu:24.04";
@@ -25290,10 +26131,10 @@ function applyContextBudget(files, config2 = {}) {
25290
26131
 
25291
26132
  // src/utils/prompt-file.ts
25292
26133
  import * as fs6 from "fs";
25293
- import * as path5 from "path";
26134
+ import * as path6 from "path";
25294
26135
  function writeWorkerPromptFile(feature, task, prompt, hiveDir) {
25295
- const promptDir = path5.join(hiveDir, "features", feature, "tasks", task);
25296
- const promptPath = path5.join(promptDir, "worker-prompt.md");
26136
+ const promptDir = path6.join(hiveDir, "features", feature, "tasks", task);
26137
+ const promptPath = path6.join(promptDir, "worker-prompt.md");
25297
26138
  if (!fs6.existsSync(promptDir)) {
25298
26139
  fs6.mkdirSync(promptDir, { recursive: true });
25299
26140
  }
@@ -25375,7 +26216,7 @@ async function buildAutoLoadedSkillsContent(agentName, configService, projectRoo
25375
26216
  if (autoLoadSkills.length === 0) {
25376
26217
  return "";
25377
26218
  }
25378
- const homeDir = process.env.HOME || os2.homedir();
26219
+ const homeDir = process.env.HOME || os4.homedir();
25379
26220
  const skillTemplates = [];
25380
26221
  for (const skillId of autoLoadSkills) {
25381
26222
  const builtinSkill = BUILTIN_SKILLS.find((entry) => entry.name === skillId);
@@ -25461,7 +26302,7 @@ var plugin = async (ctx) => {
25461
26302
  const effectiveAutoLoadSkills = configService.getAgentConfig("zetta").autoLoadSkills ?? [];
25462
26303
  const worktreeService = new WorktreeService({
25463
26304
  baseDir: directory,
25464
- hiveDir: path8.join(directory, ".hive")
26305
+ hiveDir: path9.join(directory, ".hive")
25465
26306
  });
25466
26307
  const isOmoSlimEnabled = () => {
25467
26308
  return configService.isOmoSlimEnabled();
@@ -25488,7 +26329,7 @@ var plugin = async (ctx) => {
25488
26329
  };
25489
26330
  const checkBlocked = (feature) => {
25490
26331
  const fs9 = __require("fs");
25491
- const blockedPath = path8.join(directory, ".hive", "features", feature, "BLOCKED");
26332
+ const blockedPath = path9.join(directory, ".hive", "features", feature, "BLOCKED");
25492
26333
  if (fs9.existsSync(blockedPath)) {
25493
26334
  const reason = fs9.readFileSync(blockedPath, "utf-8").trim();
25494
26335
  return `⛔ BLOCKED by Beekeeper
@@ -25642,9 +26483,9 @@ To unblock: Remove .hive/features/${feature}/BLOCKED`;
25642
26483
  spec: specContent,
25643
26484
  workerPrompt
25644
26485
  });
25645
- const hiveDir = path8.join(directory, ".hive");
26486
+ const hiveDir = path9.join(directory, ".hive");
25646
26487
  const workerPromptPath = writeWorkerPromptFile(feature, task, workerPrompt, hiveDir);
25647
- const relativePromptPath = normalizePath(path8.relative(directory, workerPromptPath));
26488
+ const relativePromptPath = normalizePath(path9.relative(directory, workerPromptPath));
25648
26489
  const PREVIEW_MAX_LENGTH = 200;
25649
26490
  const workerPromptPreview = workerPrompt.length > PREVIEW_MAX_LENGTH ? workerPrompt.slice(0, PREVIEW_MAX_LENGTH) + "..." : workerPrompt;
25650
26491
  const taskToolPrompt = `Follow instructions in @${relativePromptPath}`;
@@ -26052,7 +26893,7 @@ ${snapshot}
26052
26893
  if (sandboxConfig.mode !== "none") {
26053
26894
  const workdir = output.args?.workdir;
26054
26895
  if (workdir) {
26055
- const hiveWorktreeBase = path8.join(directory, ".hive", ".worktrees");
26896
+ const hiveWorktreeBase = path9.join(directory, ".hive", ".worktrees");
26056
26897
  if (workdir.startsWith(hiveWorktreeBase)) {
26057
26898
  const wrapped = DockerSandboxService.wrapCommand(workdir, finalCommand, sandboxConfig);
26058
26899
  output.args.command = wrapped;
@@ -26113,6 +26954,12 @@ ${snapshot}
26113
26954
  hive_memory_forget: hiveMemoryForgetTool,
26114
26955
  hive_journal_write: hiveJournalWriteTool,
26115
26956
  hive_journal_search: hiveJournalSearchTool,
26957
+ hive_code_edit: hiveCodeEditTool,
26958
+ hive_lazy_edit: hiveLazyEditTool,
26959
+ hive_booster_status: hiveBoosterStatusTool,
26960
+ hive_vector_search: hiveVectorSearchTool,
26961
+ hive_vector_add: hiveVectorAddTool,
26962
+ hive_vector_status: hiveVectorStatusTool,
26116
26963
  hive_skill: createHiveSkillTool(filteredSkills),
26117
26964
  hive_feature_create: tool({
26118
26965
  description: "Create a new feature and set it as active",