@hung319/opencode-hive 1.4.1 → 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/README.md +99 -0
- package/dist/hooks/smart-title.d.ts +18 -0
- package/dist/index.js +1379 -196
- package/dist/services/vector-memory.d.ts +85 -0
- package/dist/tools/agent-booster.d.ts +48 -0
- package/dist/tools/memory.d.ts +12 -0
- package/dist/tools/vector-memory.d.ts +10 -0
- package/package.json +4 -2
package/dist/index.js
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
2
4
|
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
function __accessProp(key) {
|
|
8
|
+
return this[key];
|
|
9
|
+
}
|
|
10
|
+
var __toESMCache_node;
|
|
11
|
+
var __toESMCache_esm;
|
|
12
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
13
|
+
var canCache = mod != null && typeof mod === "object";
|
|
14
|
+
if (canCache) {
|
|
15
|
+
var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
|
|
16
|
+
var cached = cache.get(mod);
|
|
17
|
+
if (cached)
|
|
18
|
+
return cached;
|
|
19
|
+
}
|
|
20
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
21
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
22
|
+
for (let key of __getOwnPropNames(mod))
|
|
23
|
+
if (!__hasOwnProp.call(to, key))
|
|
24
|
+
__defProp(to, key, {
|
|
25
|
+
get: __accessProp.bind(mod, key),
|
|
26
|
+
enumerable: true
|
|
27
|
+
});
|
|
28
|
+
if (canCache)
|
|
29
|
+
cache.set(mod, to);
|
|
30
|
+
return to;
|
|
31
|
+
};
|
|
32
|
+
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
3
33
|
var __returnValue = (v) => v;
|
|
4
34
|
function __exportSetter(name, newValue) {
|
|
5
35
|
this[name] = __returnValue.bind(null, newValue);
|
|
@@ -16,6 +46,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
|
|
235
|
-
import * as
|
|
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 = {};
|
|
@@ -16266,6 +16485,877 @@ async function buildMemoryInjection(projectRoot) {
|
|
|
16266
16485
|
return sections.join(`
|
|
16267
16486
|
`);
|
|
16268
16487
|
}
|
|
16488
|
+
function getTypedMemoryDir() {
|
|
16489
|
+
return path2.join(os.homedir(), ".config", "opencode", "hive", "typed-memory");
|
|
16490
|
+
}
|
|
16491
|
+
function getDeletionsFile() {
|
|
16492
|
+
return path2.join(getTypedMemoryDir(), "deletions.logfmt");
|
|
16493
|
+
}
|
|
16494
|
+
function parseTypedMemoryLine(line) {
|
|
16495
|
+
const tsMatch = line.match(/ts=([^\s]+)/);
|
|
16496
|
+
const typeMatch = line.match(/type=([^\s]+)/);
|
|
16497
|
+
const scopeMatch = line.match(/scope=([^\s]+)/);
|
|
16498
|
+
const contentMatch = line.match(/content="([^"]*(?:\\"[^"]*)*)"/);
|
|
16499
|
+
const issueMatch = line.match(/issue=([^\s]+)/);
|
|
16500
|
+
const tagsMatch = line.match(/tags=([^\s]+)/);
|
|
16501
|
+
if (!tsMatch?.[1] || !typeMatch?.[1] || !scopeMatch?.[1])
|
|
16502
|
+
return null;
|
|
16503
|
+
return {
|
|
16504
|
+
ts: tsMatch[1],
|
|
16505
|
+
type: typeMatch[1],
|
|
16506
|
+
scope: scopeMatch[1],
|
|
16507
|
+
content: contentMatch?.[1]?.replace(/\\"/g, '"') || "",
|
|
16508
|
+
issue: issueMatch?.[1],
|
|
16509
|
+
tags: tagsMatch?.[1]?.split(",")
|
|
16510
|
+
};
|
|
16511
|
+
}
|
|
16512
|
+
function formatTypedMemory(m) {
|
|
16513
|
+
const date5 = m.ts.split("T")[0];
|
|
16514
|
+
const tags = m.tags?.length ? ` [${m.tags.join(", ")}]` : "";
|
|
16515
|
+
const issue2 = m.issue ? ` (${m.issue})` : "";
|
|
16516
|
+
return `[${date5}] ${m.type}/${m.scope}: ${m.content}${issue2}${tags}`;
|
|
16517
|
+
}
|
|
16518
|
+
function scoreTypedMemoryMatch(memory, words) {
|
|
16519
|
+
const searchable = `${memory.type} ${memory.scope} ${memory.content} ${memory.tags?.join(" ") || ""}`.toLowerCase();
|
|
16520
|
+
let score = 0;
|
|
16521
|
+
for (const word of words) {
|
|
16522
|
+
if (searchable.includes(word))
|
|
16523
|
+
score++;
|
|
16524
|
+
if (memory.scope.toLowerCase() === word)
|
|
16525
|
+
score += 2;
|
|
16526
|
+
if (memory.type.toLowerCase() === word)
|
|
16527
|
+
score += 2;
|
|
16528
|
+
}
|
|
16529
|
+
return score;
|
|
16530
|
+
}
|
|
16531
|
+
async function ensureTypedMemoryDir() {
|
|
16532
|
+
const dir = getTypedMemoryDir();
|
|
16533
|
+
if (!fs2.existsSync(dir)) {
|
|
16534
|
+
fs2.mkdirSync(dir, { recursive: true });
|
|
16535
|
+
}
|
|
16536
|
+
}
|
|
16537
|
+
async function getAllTypedMemories() {
|
|
16538
|
+
const dir = getTypedMemoryDir();
|
|
16539
|
+
if (!fs2.existsSync(dir))
|
|
16540
|
+
return [];
|
|
16541
|
+
const files = fs2.readdirSync(dir).filter((f) => f.endsWith(".logfmt"));
|
|
16542
|
+
if (!files.length)
|
|
16543
|
+
return [];
|
|
16544
|
+
const lines = [];
|
|
16545
|
+
for (const filename of files) {
|
|
16546
|
+
if (filename === "deletions.logfmt")
|
|
16547
|
+
continue;
|
|
16548
|
+
const filepath = path2.join(dir, filename);
|
|
16549
|
+
const text = fs2.readFileSync(filepath, "utf-8");
|
|
16550
|
+
lines.push(...text.trim().split(`
|
|
16551
|
+
`).filter(Boolean));
|
|
16552
|
+
}
|
|
16553
|
+
return lines.map(parseTypedMemoryLine).filter((m) => m !== null);
|
|
16554
|
+
}
|
|
16555
|
+
async function findTypedMemories(scope, type, query) {
|
|
16556
|
+
const dir = getTypedMemoryDir();
|
|
16557
|
+
if (!fs2.existsSync(dir))
|
|
16558
|
+
return [];
|
|
16559
|
+
const files = fs2.readdirSync(dir).filter((f) => f.endsWith(".logfmt"));
|
|
16560
|
+
const matches = [];
|
|
16561
|
+
for (const filename of files) {
|
|
16562
|
+
if (filename === "deletions.logfmt")
|
|
16563
|
+
continue;
|
|
16564
|
+
const filepath = path2.join(dir, filename);
|
|
16565
|
+
const text = fs2.readFileSync(filepath, "utf-8");
|
|
16566
|
+
const lines = text.split(`
|
|
16567
|
+
`);
|
|
16568
|
+
lines.forEach((line, lineIndex) => {
|
|
16569
|
+
const memory = parseTypedMemoryLine(line);
|
|
16570
|
+
if (!memory)
|
|
16571
|
+
return;
|
|
16572
|
+
if (scope && memory.scope !== scope)
|
|
16573
|
+
return;
|
|
16574
|
+
if (type && memory.type !== type)
|
|
16575
|
+
return;
|
|
16576
|
+
if (query) {
|
|
16577
|
+
const words = query.toLowerCase().split(/\s+/).filter(Boolean);
|
|
16578
|
+
if (scoreTypedMemoryMatch(memory, words) === 0)
|
|
16579
|
+
return;
|
|
16580
|
+
}
|
|
16581
|
+
matches.push({ filepath, lineIndex });
|
|
16582
|
+
});
|
|
16583
|
+
}
|
|
16584
|
+
return matches;
|
|
16585
|
+
}
|
|
16586
|
+
async function logTypedMemoryDeletion(memory, reason) {
|
|
16587
|
+
await ensureTypedMemoryDir();
|
|
16588
|
+
const ts = new Date().toISOString();
|
|
16589
|
+
const content = memory.content.replace(/"/g, "\\\"");
|
|
16590
|
+
const escapedReason = reason.replace(/"/g, "\\\"");
|
|
16591
|
+
const issue2 = memory.issue ? ` issue=${memory.issue}` : "";
|
|
16592
|
+
const tags = memory.tags?.length ? ` tags=${memory.tags.join(",")}` : "";
|
|
16593
|
+
const line = `ts=${ts} action=deleted original_ts=${memory.ts} type=${memory.type} scope=${memory.scope} content="${content}" reason="${escapedReason}"${issue2}${tags}
|
|
16594
|
+
`;
|
|
16595
|
+
const file2 = getDeletionsFile();
|
|
16596
|
+
const existing = fs2.existsSync(file2) ? fs2.readFileSync(file2, "utf-8") : "";
|
|
16597
|
+
fs2.writeFileSync(file2, existing + line);
|
|
16598
|
+
}
|
|
16599
|
+
var hiveMemoryRecallTool = tool({
|
|
16600
|
+
description: "Search typed memories by scope, type, or query. Retrieve learnings, decisions, preferences, and patterns.",
|
|
16601
|
+
args: {
|
|
16602
|
+
scope: tool.schema.string().optional().describe("Filter by scope (e.g., project, user, auth, api)"),
|
|
16603
|
+
type: tool.schema.enum(["decision", "learning", "preference", "blocker", "context", "pattern"]).optional().describe("Filter by memory type"),
|
|
16604
|
+
query: tool.schema.string().optional().describe("Search terms (matches type, scope, content)"),
|
|
16605
|
+
limit: tool.schema.number().optional().describe("Maximum results (default: 20)")
|
|
16606
|
+
},
|
|
16607
|
+
async execute({ scope, type, query, limit = 20 }) {
|
|
16608
|
+
await ensureTypedMemoryDir();
|
|
16609
|
+
const allMemories = await getAllTypedMemories();
|
|
16610
|
+
if (!allMemories.length) {
|
|
16611
|
+
return JSON.stringify({
|
|
16612
|
+
message: "No typed memories found. Use hive_memory_set to create one.",
|
|
16613
|
+
total: 0,
|
|
16614
|
+
results: []
|
|
16615
|
+
}, null, 2);
|
|
16616
|
+
}
|
|
16617
|
+
let results = allMemories;
|
|
16618
|
+
if (scope) {
|
|
16619
|
+
results = results.filter((m) => m.scope === scope || m.scope.includes(scope));
|
|
16620
|
+
}
|
|
16621
|
+
if (type) {
|
|
16622
|
+
results = results.filter((m) => m.type === type);
|
|
16623
|
+
}
|
|
16624
|
+
if (query) {
|
|
16625
|
+
const words = query.toLowerCase().split(/\s+/).filter(Boolean);
|
|
16626
|
+
const scored = results.map((m) => ({ memory: m, score: scoreTypedMemoryMatch(m, words) })).filter((x) => x.score > 0).sort((a, b) => b.score - a.score);
|
|
16627
|
+
results = scored.map((x) => x.memory);
|
|
16628
|
+
}
|
|
16629
|
+
const totalCount = allMemories.length;
|
|
16630
|
+
const filteredCount = results.length;
|
|
16631
|
+
const limited = results.slice(0, limit);
|
|
16632
|
+
if (!limited.length) {
|
|
16633
|
+
return JSON.stringify({
|
|
16634
|
+
message: "No matching memories found.",
|
|
16635
|
+
total: totalCount,
|
|
16636
|
+
results: []
|
|
16637
|
+
}, null, 2);
|
|
16638
|
+
}
|
|
16639
|
+
return JSON.stringify({
|
|
16640
|
+
total: totalCount,
|
|
16641
|
+
filtered: filteredCount,
|
|
16642
|
+
returned: limited.length,
|
|
16643
|
+
results: limited.map((m) => ({
|
|
16644
|
+
type: m.type,
|
|
16645
|
+
scope: m.scope,
|
|
16646
|
+
content: m.content,
|
|
16647
|
+
created: m.ts,
|
|
16648
|
+
issue: m.issue,
|
|
16649
|
+
tags: m.tags,
|
|
16650
|
+
formatted: formatTypedMemory(m)
|
|
16651
|
+
}))
|
|
16652
|
+
}, null, 2);
|
|
16653
|
+
}
|
|
16654
|
+
});
|
|
16655
|
+
var hiveMemoryUpdateTool = tool({
|
|
16656
|
+
description: "Update a typed memory entry. Finds by scope and type, updates content.",
|
|
16657
|
+
args: {
|
|
16658
|
+
scope: tool.schema.string().describe("Scope of memory to update"),
|
|
16659
|
+
type: tool.schema.enum(["decision", "learning", "preference", "blocker", "context", "pattern"]).describe("Type of memory"),
|
|
16660
|
+
content: tool.schema.string().describe("New content"),
|
|
16661
|
+
query: tool.schema.string().optional().describe("If multiple matches, filter by query")
|
|
16662
|
+
},
|
|
16663
|
+
async execute({ scope, type, content, query }) {
|
|
16664
|
+
const matches = await findTypedMemories(scope, type);
|
|
16665
|
+
if (matches.length === 0) {
|
|
16666
|
+
return JSON.stringify({
|
|
16667
|
+
success: false,
|
|
16668
|
+
error: `No memories found for ${type} in ${scope}`
|
|
16669
|
+
}, null, 2);
|
|
16670
|
+
}
|
|
16671
|
+
let target = matches[0];
|
|
16672
|
+
if (matches.length > 1 && query) {
|
|
16673
|
+
const words = query.toLowerCase().split(/\s+/).filter(Boolean);
|
|
16674
|
+
const scored = matches.map((m) => {
|
|
16675
|
+
const memory = parseTypedMemoryLine(fs2.readFileSync(m.filepath, "utf-8").split(`
|
|
16676
|
+
`)[m.lineIndex]);
|
|
16677
|
+
return { match: m, score: memory ? scoreTypedMemoryMatch(memory, words) : 0 };
|
|
16678
|
+
}).filter((x) => x.score > 0).sort((a, b) => b.score - a.score);
|
|
16679
|
+
if (scored.length === 0) {
|
|
16680
|
+
return JSON.stringify({
|
|
16681
|
+
success: false,
|
|
16682
|
+
error: `Found ${matches.length} memories for ${type}/${scope}, but none matched query "${query}"`
|
|
16683
|
+
}, null, 2);
|
|
16684
|
+
}
|
|
16685
|
+
target = scored[0].match;
|
|
16686
|
+
}
|
|
16687
|
+
const oldLine = fs2.readFileSync(target.filepath, "utf-8").split(`
|
|
16688
|
+
`)[target.lineIndex];
|
|
16689
|
+
const oldMemory = parseTypedMemoryLine(oldLine);
|
|
16690
|
+
if (oldMemory) {
|
|
16691
|
+
await logTypedMemoryDeletion(oldMemory, `Updated to: ${content}`);
|
|
16692
|
+
}
|
|
16693
|
+
const ts = new Date().toISOString();
|
|
16694
|
+
const lines = fs2.readFileSync(target.filepath, "utf-8").split(`
|
|
16695
|
+
`);
|
|
16696
|
+
lines[target.lineIndex] = `ts=${ts} type=${type} scope=${scope} content="${content.replace(/"/g, "\\\"")}"`;
|
|
16697
|
+
fs2.writeFileSync(target.filepath, lines.join(`
|
|
16698
|
+
`));
|
|
16699
|
+
return JSON.stringify({
|
|
16700
|
+
success: true,
|
|
16701
|
+
scope,
|
|
16702
|
+
type,
|
|
16703
|
+
content,
|
|
16704
|
+
message: `Updated ${type} in ${scope}`
|
|
16705
|
+
}, null, 2);
|
|
16706
|
+
}
|
|
16707
|
+
});
|
|
16708
|
+
var hiveMemoryForgetTool = tool({
|
|
16709
|
+
description: "Delete a typed memory. Logs deletion for audit purposes.",
|
|
16710
|
+
args: {
|
|
16711
|
+
scope: tool.schema.string().describe("Scope of memory to delete"),
|
|
16712
|
+
type: tool.schema.enum(["decision", "learning", "preference", "blocker", "context", "pattern"]).describe("Type of memory"),
|
|
16713
|
+
reason: tool.schema.string().describe("Why this memory is being deleted")
|
|
16714
|
+
},
|
|
16715
|
+
async execute({ scope, type, reason }) {
|
|
16716
|
+
const matches = await findTypedMemories(scope, type);
|
|
16717
|
+
if (matches.length === 0) {
|
|
16718
|
+
return JSON.stringify({
|
|
16719
|
+
success: false,
|
|
16720
|
+
error: `No memories found for ${type} in ${scope}`
|
|
16721
|
+
}, null, 2);
|
|
16722
|
+
}
|
|
16723
|
+
let deleted = 0;
|
|
16724
|
+
const deletedMemories = [];
|
|
16725
|
+
for (const match of matches) {
|
|
16726
|
+
const text = fs2.readFileSync(match.filepath, "utf-8");
|
|
16727
|
+
const lines = text.split(`
|
|
16728
|
+
`);
|
|
16729
|
+
const memory = parseTypedMemoryLine(lines[match.lineIndex]);
|
|
16730
|
+
if (memory) {
|
|
16731
|
+
await logTypedMemoryDeletion(memory, reason);
|
|
16732
|
+
deletedMemories.push(memory);
|
|
16733
|
+
deleted++;
|
|
16734
|
+
}
|
|
16735
|
+
lines.splice(match.lineIndex, 1);
|
|
16736
|
+
fs2.writeFileSync(match.filepath, lines.join(`
|
|
16737
|
+
`));
|
|
16738
|
+
}
|
|
16739
|
+
return JSON.stringify({
|
|
16740
|
+
success: true,
|
|
16741
|
+
deleted,
|
|
16742
|
+
scope,
|
|
16743
|
+
type,
|
|
16744
|
+
reason,
|
|
16745
|
+
message: `Deleted ${deleted} ${type} memory(ies) from ${scope}. Deletion logged.`
|
|
16746
|
+
}, null, 2);
|
|
16747
|
+
}
|
|
16748
|
+
});
|
|
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
|
+
});
|
|
16269
17359
|
|
|
16270
17360
|
// src/agents/hive.ts
|
|
16271
17361
|
var QUEEN_BEE_PROMPT = `# Zetta (Hybrid)
|
|
@@ -17614,61 +18704,63 @@ var createBuiltinMcps = (disabledMcps = []) => {
|
|
|
17614
18704
|
|
|
17615
18705
|
// ../hive-core/dist/index.js
|
|
17616
18706
|
import { createRequire as createRequire2 } from "node:module";
|
|
17617
|
-
import * as
|
|
17618
|
-
import * as
|
|
18707
|
+
import * as path5 from "path";
|
|
18708
|
+
import * as os3 from "os";
|
|
17619
18709
|
import * as path22 from "path";
|
|
18710
|
+
import * as fs5 from "fs";
|
|
18711
|
+
import * as path32 from "path";
|
|
17620
18712
|
import * as fs22 from "fs";
|
|
17621
18713
|
import * as fs32 from "fs";
|
|
17622
|
-
import * as
|
|
17623
|
-
import * as
|
|
18714
|
+
import * as fs42 from "fs";
|
|
18715
|
+
import * as fs52 from "fs";
|
|
17624
18716
|
import * as fs7 from "fs/promises";
|
|
17625
|
-
import * as
|
|
18717
|
+
import * as path42 from "path";
|
|
17626
18718
|
import { Buffer as Buffer2 } from "node:buffer";
|
|
17627
18719
|
import { spawn } from "child_process";
|
|
17628
18720
|
import { normalize } from "node:path";
|
|
17629
18721
|
import { EventEmitter } from "node:events";
|
|
17630
18722
|
import * as fs8 from "fs";
|
|
17631
|
-
import * as
|
|
18723
|
+
import * as path52 from "path";
|
|
17632
18724
|
import * as fs10 from "fs";
|
|
17633
|
-
import * as path6 from "path";
|
|
17634
|
-
import * as fs11 from "fs";
|
|
17635
18725
|
import * as path7 from "path";
|
|
17636
|
-
import
|
|
17637
|
-
import
|
|
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";
|
|
17638
18730
|
import { execSync } from "child_process";
|
|
17639
|
-
var
|
|
17640
|
-
var
|
|
18731
|
+
var __create2 = Object.create;
|
|
18732
|
+
var __getProtoOf2 = Object.getPrototypeOf;
|
|
17641
18733
|
var __defProp2 = Object.defineProperty;
|
|
17642
|
-
var
|
|
17643
|
-
var
|
|
17644
|
-
function
|
|
18734
|
+
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
18735
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
18736
|
+
function __accessProp2(key) {
|
|
17645
18737
|
return this[key];
|
|
17646
18738
|
}
|
|
17647
|
-
var
|
|
17648
|
-
var
|
|
17649
|
-
var
|
|
18739
|
+
var __toESMCache_node2;
|
|
18740
|
+
var __toESMCache_esm2;
|
|
18741
|
+
var __toESM2 = (mod, isNodeMode, target) => {
|
|
17650
18742
|
var canCache = mod != null && typeof mod === "object";
|
|
17651
18743
|
if (canCache) {
|
|
17652
|
-
var cache = isNodeMode ?
|
|
18744
|
+
var cache = isNodeMode ? __toESMCache_node2 ??= new WeakMap : __toESMCache_esm2 ??= new WeakMap;
|
|
17653
18745
|
var cached2 = cache.get(mod);
|
|
17654
18746
|
if (cached2)
|
|
17655
18747
|
return cached2;
|
|
17656
18748
|
}
|
|
17657
|
-
target = mod != null ?
|
|
18749
|
+
target = mod != null ? __create2(__getProtoOf2(mod)) : {};
|
|
17658
18750
|
const to = isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target;
|
|
17659
|
-
for (let key of
|
|
17660
|
-
if (!
|
|
18751
|
+
for (let key of __getOwnPropNames2(mod))
|
|
18752
|
+
if (!__hasOwnProp2.call(to, key))
|
|
17661
18753
|
__defProp2(to, key, {
|
|
17662
|
-
get:
|
|
18754
|
+
get: __accessProp2.bind(mod, key),
|
|
17663
18755
|
enumerable: true
|
|
17664
18756
|
});
|
|
17665
18757
|
if (canCache)
|
|
17666
18758
|
cache.set(mod, to);
|
|
17667
18759
|
return to;
|
|
17668
18760
|
};
|
|
17669
|
-
var
|
|
18761
|
+
var __commonJS2 = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
17670
18762
|
var __require2 = /* @__PURE__ */ createRequire2(import.meta.url);
|
|
17671
|
-
var require_ms =
|
|
18763
|
+
var require_ms = __commonJS2((exports, module) => {
|
|
17672
18764
|
var s = 1000;
|
|
17673
18765
|
var m = s * 60;
|
|
17674
18766
|
var h = m * 60;
|
|
@@ -17776,7 +18868,7 @@ var require_ms = __commonJS((exports, module) => {
|
|
|
17776
18868
|
return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
|
|
17777
18869
|
}
|
|
17778
18870
|
});
|
|
17779
|
-
var require_common =
|
|
18871
|
+
var require_common = __commonJS2((exports, module) => {
|
|
17780
18872
|
function setup(env) {
|
|
17781
18873
|
createDebug.debug = createDebug;
|
|
17782
18874
|
createDebug.default = createDebug;
|
|
@@ -17949,7 +19041,7 @@ var require_common = __commonJS((exports, module) => {
|
|
|
17949
19041
|
}
|
|
17950
19042
|
module.exports = setup;
|
|
17951
19043
|
});
|
|
17952
|
-
var require_browser =
|
|
19044
|
+
var require_browser = __commonJS2((exports, module) => {
|
|
17953
19045
|
exports.formatArgs = formatArgs;
|
|
17954
19046
|
exports.save = save;
|
|
17955
19047
|
exports.load = load;
|
|
@@ -18107,7 +19199,7 @@ var require_browser = __commonJS((exports, module) => {
|
|
|
18107
19199
|
}
|
|
18108
19200
|
};
|
|
18109
19201
|
});
|
|
18110
|
-
var require_node =
|
|
19202
|
+
var require_node = __commonJS2((exports, module) => {
|
|
18111
19203
|
var tty = __require2("tty");
|
|
18112
19204
|
var util = __require2("util");
|
|
18113
19205
|
exports.init = init;
|
|
@@ -18278,14 +19370,14 @@ var require_node = __commonJS((exports, module) => {
|
|
|
18278
19370
|
return util.inspect(v, this.inspectOpts);
|
|
18279
19371
|
};
|
|
18280
19372
|
});
|
|
18281
|
-
var require_src =
|
|
19373
|
+
var require_src = __commonJS2((exports, module) => {
|
|
18282
19374
|
if (typeof process === "undefined" || process.type === "renderer" || false || process.__nwjs) {
|
|
18283
19375
|
module.exports = require_browser();
|
|
18284
19376
|
} else {
|
|
18285
19377
|
module.exports = require_node();
|
|
18286
19378
|
}
|
|
18287
19379
|
});
|
|
18288
|
-
var require_src2 =
|
|
19380
|
+
var require_src2 = __commonJS2((exports) => {
|
|
18289
19381
|
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
18290
19382
|
return mod && mod.__esModule ? mod : { default: mod };
|
|
18291
19383
|
};
|
|
@@ -18293,10 +19385,10 @@ var require_src2 = __commonJS((exports) => {
|
|
|
18293
19385
|
var fs_1 = __require2("fs");
|
|
18294
19386
|
var debug_1 = __importDefault(require_src());
|
|
18295
19387
|
var log = debug_1.default("@kwsites/file-exists");
|
|
18296
|
-
function check2(
|
|
18297
|
-
log(`checking %s`,
|
|
19388
|
+
function check2(path43, isFile, isDirectory) {
|
|
19389
|
+
log(`checking %s`, path43);
|
|
18298
19390
|
try {
|
|
18299
|
-
const stat2 = fs_1.statSync(
|
|
19391
|
+
const stat2 = fs_1.statSync(path43);
|
|
18300
19392
|
if (stat2.isFile() && isFile) {
|
|
18301
19393
|
log(`[OK] path represents a file`);
|
|
18302
19394
|
return true;
|
|
@@ -18316,15 +19408,15 @@ var require_src2 = __commonJS((exports) => {
|
|
|
18316
19408
|
throw e;
|
|
18317
19409
|
}
|
|
18318
19410
|
}
|
|
18319
|
-
function exists(
|
|
18320
|
-
return check2(
|
|
19411
|
+
function exists(path43, type = exports.READABLE) {
|
|
19412
|
+
return check2(path43, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
|
|
18321
19413
|
}
|
|
18322
19414
|
exports.exists = exists;
|
|
18323
19415
|
exports.FILE = 1;
|
|
18324
19416
|
exports.FOLDER = 2;
|
|
18325
19417
|
exports.READABLE = exports.FILE + exports.FOLDER;
|
|
18326
19418
|
});
|
|
18327
|
-
var
|
|
19419
|
+
var require_dist2 = __commonJS2((exports) => {
|
|
18328
19420
|
function __export2(m) {
|
|
18329
19421
|
for (var p in m)
|
|
18330
19422
|
if (!exports.hasOwnProperty(p))
|
|
@@ -18333,7 +19425,7 @@ var require_dist = __commonJS((exports) => {
|
|
|
18333
19425
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18334
19426
|
__export2(require_src2());
|
|
18335
19427
|
});
|
|
18336
|
-
var
|
|
19428
|
+
var require_dist22 = __commonJS2((exports) => {
|
|
18337
19429
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18338
19430
|
exports.createDeferred = exports.deferred = undefined;
|
|
18339
19431
|
function deferred() {
|
|
@@ -18471,6 +19563,24 @@ var DEFAULT_HIVE_CONFIG = {
|
|
|
18471
19563
|
includeActiveFeature: true,
|
|
18472
19564
|
includePendingTasks: true,
|
|
18473
19565
|
includeModifiedFiles: false
|
|
19566
|
+
},
|
|
19567
|
+
snip: {
|
|
19568
|
+
enabled: false,
|
|
19569
|
+
command: "snip"
|
|
19570
|
+
},
|
|
19571
|
+
smartTitle: {
|
|
19572
|
+
enabled: false,
|
|
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
|
|
18474
19584
|
}
|
|
18475
19585
|
};
|
|
18476
19586
|
var HIVE_DIR = ".hive";
|
|
@@ -18487,78 +19597,78 @@ function normalizePath(filePath) {
|
|
|
18487
19597
|
return filePath.replace(/\\/g, "/");
|
|
18488
19598
|
}
|
|
18489
19599
|
function getHivePath(projectRoot) {
|
|
18490
|
-
return
|
|
19600
|
+
return path22.join(projectRoot, HIVE_DIR);
|
|
18491
19601
|
}
|
|
18492
19602
|
function getFeaturesPath(projectRoot) {
|
|
18493
|
-
return
|
|
19603
|
+
return path22.join(getHivePath(projectRoot), FEATURES_DIR);
|
|
18494
19604
|
}
|
|
18495
19605
|
function getFeaturePath(projectRoot, featureName) {
|
|
18496
|
-
return
|
|
19606
|
+
return path22.join(getFeaturesPath(projectRoot), featureName);
|
|
18497
19607
|
}
|
|
18498
19608
|
function getPlanPath(projectRoot, featureName) {
|
|
18499
|
-
return
|
|
19609
|
+
return path22.join(getFeaturePath(projectRoot, featureName), PLAN_FILE);
|
|
18500
19610
|
}
|
|
18501
19611
|
function getCommentsPath(projectRoot, featureName) {
|
|
18502
|
-
return
|
|
19612
|
+
return path22.join(getFeaturePath(projectRoot, featureName), COMMENTS_FILE);
|
|
18503
19613
|
}
|
|
18504
19614
|
function getFeatureJsonPath(projectRoot, featureName) {
|
|
18505
|
-
return
|
|
19615
|
+
return path22.join(getFeaturePath(projectRoot, featureName), FEATURE_FILE);
|
|
18506
19616
|
}
|
|
18507
19617
|
function getContextPath(projectRoot, featureName) {
|
|
18508
|
-
return
|
|
19618
|
+
return path22.join(getFeaturePath(projectRoot, featureName), CONTEXT_DIR);
|
|
18509
19619
|
}
|
|
18510
19620
|
function getTasksPath(projectRoot, featureName) {
|
|
18511
|
-
return
|
|
19621
|
+
return path22.join(getFeaturePath(projectRoot, featureName), TASKS_DIR);
|
|
18512
19622
|
}
|
|
18513
19623
|
function getTaskPath(projectRoot, featureName, taskFolder) {
|
|
18514
|
-
return
|
|
19624
|
+
return path22.join(getTasksPath(projectRoot, featureName), taskFolder);
|
|
18515
19625
|
}
|
|
18516
19626
|
function getTaskStatusPath(projectRoot, featureName, taskFolder) {
|
|
18517
|
-
return
|
|
19627
|
+
return path22.join(getTaskPath(projectRoot, featureName, taskFolder), STATUS_FILE);
|
|
18518
19628
|
}
|
|
18519
19629
|
function getTaskReportPath(projectRoot, featureName, taskFolder) {
|
|
18520
|
-
return
|
|
19630
|
+
return path22.join(getTaskPath(projectRoot, featureName, taskFolder), REPORT_FILE);
|
|
18521
19631
|
}
|
|
18522
19632
|
function getTaskSpecPath(projectRoot, featureName, taskFolder) {
|
|
18523
|
-
return
|
|
19633
|
+
return path22.join(getTaskPath(projectRoot, featureName, taskFolder), "spec.md");
|
|
18524
19634
|
}
|
|
18525
19635
|
function getApprovedPath(projectRoot, featureName) {
|
|
18526
|
-
return
|
|
19636
|
+
return path22.join(getFeaturePath(projectRoot, featureName), APPROVED_FILE);
|
|
18527
19637
|
}
|
|
18528
19638
|
var SUBTASKS_DIR = "subtasks";
|
|
18529
19639
|
var SPEC_FILE = "spec.md";
|
|
18530
19640
|
function getSubtasksPath(projectRoot, featureName, taskFolder) {
|
|
18531
|
-
return
|
|
19641
|
+
return path22.join(getTaskPath(projectRoot, featureName, taskFolder), SUBTASKS_DIR);
|
|
18532
19642
|
}
|
|
18533
19643
|
function getSubtaskPath(projectRoot, featureName, taskFolder, subtaskFolder) {
|
|
18534
|
-
return
|
|
19644
|
+
return path22.join(getSubtasksPath(projectRoot, featureName, taskFolder), subtaskFolder);
|
|
18535
19645
|
}
|
|
18536
19646
|
function getSubtaskStatusPath(projectRoot, featureName, taskFolder, subtaskFolder) {
|
|
18537
|
-
return
|
|
19647
|
+
return path22.join(getSubtaskPath(projectRoot, featureName, taskFolder, subtaskFolder), STATUS_FILE);
|
|
18538
19648
|
}
|
|
18539
19649
|
function getSubtaskSpecPath(projectRoot, featureName, taskFolder, subtaskFolder) {
|
|
18540
|
-
return
|
|
19650
|
+
return path22.join(getSubtaskPath(projectRoot, featureName, taskFolder, subtaskFolder), SPEC_FILE);
|
|
18541
19651
|
}
|
|
18542
19652
|
function getSubtaskReportPath(projectRoot, featureName, taskFolder, subtaskFolder) {
|
|
18543
|
-
return
|
|
19653
|
+
return path22.join(getSubtaskPath(projectRoot, featureName, taskFolder, subtaskFolder), REPORT_FILE);
|
|
18544
19654
|
}
|
|
18545
19655
|
function ensureDir(dirPath) {
|
|
18546
|
-
if (!
|
|
18547
|
-
|
|
19656
|
+
if (!fs5.existsSync(dirPath)) {
|
|
19657
|
+
fs5.mkdirSync(dirPath, { recursive: true });
|
|
18548
19658
|
}
|
|
18549
19659
|
}
|
|
18550
19660
|
function fileExists(filePath) {
|
|
18551
|
-
return
|
|
19661
|
+
return fs5.existsSync(filePath);
|
|
18552
19662
|
}
|
|
18553
19663
|
function readJson(filePath) {
|
|
18554
|
-
if (!
|
|
19664
|
+
if (!fs5.existsSync(filePath))
|
|
18555
19665
|
return null;
|
|
18556
|
-
const content =
|
|
19666
|
+
const content = fs5.readFileSync(filePath, "utf-8");
|
|
18557
19667
|
return JSON.parse(content);
|
|
18558
19668
|
}
|
|
18559
19669
|
function writeJson(filePath, data) {
|
|
18560
|
-
ensureDir(
|
|
18561
|
-
|
|
19670
|
+
ensureDir(path22.dirname(filePath));
|
|
19671
|
+
fs5.writeFileSync(filePath, JSON.stringify(data, null, 2));
|
|
18562
19672
|
}
|
|
18563
19673
|
var DEFAULT_LOCK_OPTIONS = {
|
|
18564
19674
|
timeout: 5000,
|
|
@@ -18570,7 +19680,7 @@ function getLockPath(filePath) {
|
|
|
18570
19680
|
}
|
|
18571
19681
|
function isLockStale(lockPath, staleTTL) {
|
|
18572
19682
|
try {
|
|
18573
|
-
const stat2 =
|
|
19683
|
+
const stat2 = fs5.statSync(lockPath);
|
|
18574
19684
|
const age = Date.now() - stat2.mtimeMs;
|
|
18575
19685
|
return age > staleTTL;
|
|
18576
19686
|
} catch {
|
|
@@ -18580,7 +19690,7 @@ function isLockStale(lockPath, staleTTL) {
|
|
|
18580
19690
|
function acquireLockSync(filePath, options = {}) {
|
|
18581
19691
|
const opts = { ...DEFAULT_LOCK_OPTIONS, ...options };
|
|
18582
19692
|
const lockPath = getLockPath(filePath);
|
|
18583
|
-
const lockDir =
|
|
19693
|
+
const lockDir = path22.dirname(lockPath);
|
|
18584
19694
|
const startTime = Date.now();
|
|
18585
19695
|
const lockContent = JSON.stringify({
|
|
18586
19696
|
pid: process.pid,
|
|
@@ -18590,12 +19700,12 @@ function acquireLockSync(filePath, options = {}) {
|
|
|
18590
19700
|
ensureDir(lockDir);
|
|
18591
19701
|
while (true) {
|
|
18592
19702
|
try {
|
|
18593
|
-
const fd =
|
|
18594
|
-
|
|
18595
|
-
|
|
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);
|
|
18596
19706
|
return () => {
|
|
18597
19707
|
try {
|
|
18598
|
-
|
|
19708
|
+
fs5.unlinkSync(lockPath);
|
|
18599
19709
|
} catch {}
|
|
18600
19710
|
};
|
|
18601
19711
|
} catch (err) {
|
|
@@ -18605,7 +19715,7 @@ function acquireLockSync(filePath, options = {}) {
|
|
|
18605
19715
|
} else if (error45.code === "EEXIST") {
|
|
18606
19716
|
if (isLockStale(lockPath, opts.staleLockTTL)) {
|
|
18607
19717
|
try {
|
|
18608
|
-
|
|
19718
|
+
fs5.unlinkSync(lockPath);
|
|
18609
19719
|
continue;
|
|
18610
19720
|
} catch {}
|
|
18611
19721
|
}
|
|
@@ -18621,14 +19731,14 @@ function acquireLockSync(filePath, options = {}) {
|
|
|
18621
19731
|
}
|
|
18622
19732
|
}
|
|
18623
19733
|
function writeAtomic(filePath, content) {
|
|
18624
|
-
ensureDir(
|
|
19734
|
+
ensureDir(path22.dirname(filePath));
|
|
18625
19735
|
const tempPath = `${filePath}.tmp.${process.pid}.${Date.now()}`;
|
|
18626
19736
|
try {
|
|
18627
|
-
|
|
18628
|
-
|
|
19737
|
+
fs5.writeFileSync(tempPath, content);
|
|
19738
|
+
fs5.renameSync(tempPath, filePath);
|
|
18629
19739
|
} catch (error45) {
|
|
18630
19740
|
try {
|
|
18631
|
-
|
|
19741
|
+
fs5.unlinkSync(tempPath);
|
|
18632
19742
|
} catch {}
|
|
18633
19743
|
throw error45;
|
|
18634
19744
|
}
|
|
@@ -18663,13 +19773,13 @@ function patchJsonLockedSync(filePath, patch, options = {}) {
|
|
|
18663
19773
|
}
|
|
18664
19774
|
}
|
|
18665
19775
|
function readText(filePath) {
|
|
18666
|
-
if (!
|
|
19776
|
+
if (!fs5.existsSync(filePath))
|
|
18667
19777
|
return null;
|
|
18668
|
-
return
|
|
19778
|
+
return fs5.readFileSync(filePath, "utf-8");
|
|
18669
19779
|
}
|
|
18670
19780
|
function writeText(filePath, content) {
|
|
18671
|
-
ensureDir(
|
|
18672
|
-
|
|
19781
|
+
ensureDir(path22.dirname(filePath));
|
|
19782
|
+
fs5.writeFileSync(filePath, content);
|
|
18673
19783
|
}
|
|
18674
19784
|
function detectContext(cwd) {
|
|
18675
19785
|
const result = {
|
|
@@ -18689,7 +19799,7 @@ function detectContext(cwd) {
|
|
|
18689
19799
|
result.projectRoot = worktreeMatch[1];
|
|
18690
19800
|
return result;
|
|
18691
19801
|
}
|
|
18692
|
-
const gitPath =
|
|
19802
|
+
const gitPath = path32.join(cwd, ".git");
|
|
18693
19803
|
if (fs22.existsSync(gitPath)) {
|
|
18694
19804
|
const stat2 = fs22.statSync(gitPath);
|
|
18695
19805
|
if (stat2.isFile()) {
|
|
@@ -18865,7 +19975,7 @@ class PlanService {
|
|
|
18865
19975
|
}
|
|
18866
19976
|
const approvedPath = getApprovedPath(this.projectRoot, featureName);
|
|
18867
19977
|
const timestamp = new Date().toISOString();
|
|
18868
|
-
|
|
19978
|
+
fs42.writeFileSync(approvedPath, `Approved at ${timestamp}
|
|
18869
19979
|
`);
|
|
18870
19980
|
const featurePath = getFeatureJsonPath(this.projectRoot, featureName);
|
|
18871
19981
|
const feature = readJson(featurePath);
|
|
@@ -18881,7 +19991,7 @@ class PlanService {
|
|
|
18881
19991
|
revokeApproval(featureName) {
|
|
18882
19992
|
const approvedPath = getApprovedPath(this.projectRoot, featureName);
|
|
18883
19993
|
if (fileExists(approvedPath)) {
|
|
18884
|
-
|
|
19994
|
+
fs42.unlinkSync(approvedPath);
|
|
18885
19995
|
}
|
|
18886
19996
|
const featurePath = getFeatureJsonPath(this.projectRoot, featureName);
|
|
18887
19997
|
const feature = readJson(featurePath);
|
|
@@ -19127,20 +20237,20 @@ ${f.content}`).join(`
|
|
|
19127
20237
|
return [task.order - 1];
|
|
19128
20238
|
};
|
|
19129
20239
|
const visited = new Map;
|
|
19130
|
-
const
|
|
20240
|
+
const path43 = [];
|
|
19131
20241
|
const dfs = (taskOrder) => {
|
|
19132
20242
|
const state = visited.get(taskOrder);
|
|
19133
20243
|
if (state === 2) {
|
|
19134
20244
|
return;
|
|
19135
20245
|
}
|
|
19136
20246
|
if (state === 1) {
|
|
19137
|
-
const cycleStart =
|
|
19138
|
-
const cyclePath = [...
|
|
20247
|
+
const cycleStart = path43.indexOf(taskOrder);
|
|
20248
|
+
const cyclePath = [...path43.slice(cycleStart), taskOrder];
|
|
19139
20249
|
const cycleDesc = cyclePath.join(" -> ");
|
|
19140
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.`);
|
|
19141
20251
|
}
|
|
19142
20252
|
visited.set(taskOrder, 1);
|
|
19143
|
-
|
|
20253
|
+
path43.push(taskOrder);
|
|
19144
20254
|
const task = taskByOrder.get(taskOrder);
|
|
19145
20255
|
if (task) {
|
|
19146
20256
|
const deps = getDependencies(task);
|
|
@@ -19148,7 +20258,7 @@ ${f.content}`).join(`
|
|
|
19148
20258
|
dfs(depOrder);
|
|
19149
20259
|
}
|
|
19150
20260
|
}
|
|
19151
|
-
|
|
20261
|
+
path43.pop();
|
|
19152
20262
|
visited.set(taskOrder, 2);
|
|
19153
20263
|
};
|
|
19154
20264
|
for (const task of tasks) {
|
|
@@ -19234,12 +20344,12 @@ ${f.content}`).join(`
|
|
|
19234
20344
|
const tasksPath = getTasksPath(this.projectRoot, featureName);
|
|
19235
20345
|
if (!fileExists(tasksPath))
|
|
19236
20346
|
return [];
|
|
19237
|
-
return
|
|
20347
|
+
return fs52.readdirSync(tasksPath, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name).sort();
|
|
19238
20348
|
}
|
|
19239
20349
|
deleteTask(featureName, taskFolder) {
|
|
19240
20350
|
const taskPath = getTaskPath(this.projectRoot, featureName, taskFolder);
|
|
19241
20351
|
if (fileExists(taskPath)) {
|
|
19242
|
-
|
|
20352
|
+
fs52.rmSync(taskPath, { recursive: true });
|
|
19243
20353
|
}
|
|
19244
20354
|
}
|
|
19245
20355
|
getNextOrder(existingFolders) {
|
|
@@ -19391,7 +20501,7 @@ _Add detailed instructions here_
|
|
|
19391
20501
|
}
|
|
19392
20502
|
const subtaskPath = getSubtaskPath(this.projectRoot, featureName, taskFolder, subtaskFolder);
|
|
19393
20503
|
if (fileExists(subtaskPath)) {
|
|
19394
|
-
|
|
20504
|
+
fs52.rmSync(subtaskPath, { recursive: true });
|
|
19395
20505
|
}
|
|
19396
20506
|
}
|
|
19397
20507
|
getSubtask(featureName, taskFolder, subtaskId) {
|
|
@@ -19451,7 +20561,7 @@ _Add detailed instructions here_
|
|
|
19451
20561
|
const subtasksPath = getSubtasksPath(this.projectRoot, featureName, taskFolder);
|
|
19452
20562
|
if (!fileExists(subtasksPath))
|
|
19453
20563
|
return [];
|
|
19454
|
-
return
|
|
20564
|
+
return fs52.readdirSync(subtasksPath, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name).sort();
|
|
19455
20565
|
}
|
|
19456
20566
|
findSubtaskFolder(featureName, taskFolder, subtaskId) {
|
|
19457
20567
|
const folders = this.listSubtaskFolders(featureName, taskFolder);
|
|
@@ -19462,19 +20572,19 @@ _Add detailed instructions here_
|
|
|
19462
20572
|
return name.toLowerCase().replace(/\s+/g, "-").replace(/[^a-z0-9-]/g, "");
|
|
19463
20573
|
}
|
|
19464
20574
|
}
|
|
19465
|
-
var import_file_exists =
|
|
19466
|
-
var import_debug =
|
|
19467
|
-
var import_promise_deferred =
|
|
19468
|
-
var import_promise_deferred2 =
|
|
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);
|
|
19469
20579
|
var __defProp22 = Object.defineProperty;
|
|
19470
20580
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
19471
|
-
var
|
|
19472
|
-
var
|
|
20581
|
+
var __getOwnPropNames22 = Object.getOwnPropertyNames;
|
|
20582
|
+
var __hasOwnProp22 = Object.prototype.hasOwnProperty;
|
|
19473
20583
|
var __esm2 = (fn, res) => function __init() {
|
|
19474
|
-
return fn && (res = (0, fn[
|
|
20584
|
+
return fn && (res = (0, fn[__getOwnPropNames22(fn)[0]])(fn = 0)), res;
|
|
19475
20585
|
};
|
|
19476
|
-
var
|
|
19477
|
-
return mod || (0, cb[
|
|
20586
|
+
var __commonJS22 = (cb, mod) => function __require22() {
|
|
20587
|
+
return mod || (0, cb[__getOwnPropNames22(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
19478
20588
|
};
|
|
19479
20589
|
var __export2 = (target, all) => {
|
|
19480
20590
|
for (var name in all)
|
|
@@ -19482,8 +20592,8 @@ var __export2 = (target, all) => {
|
|
|
19482
20592
|
};
|
|
19483
20593
|
var __copyProps = (to, from, except, desc) => {
|
|
19484
20594
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
19485
|
-
for (let key of
|
|
19486
|
-
if (!
|
|
20595
|
+
for (let key of __getOwnPropNames22(from))
|
|
20596
|
+
if (!__hasOwnProp22.call(to, key) && key !== except)
|
|
19487
20597
|
__defProp22(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19488
20598
|
}
|
|
19489
20599
|
return to;
|
|
@@ -19494,8 +20604,8 @@ function pathspec(...paths) {
|
|
|
19494
20604
|
cache.set(key, paths);
|
|
19495
20605
|
return key;
|
|
19496
20606
|
}
|
|
19497
|
-
function isPathSpec(
|
|
19498
|
-
return
|
|
20607
|
+
function isPathSpec(path43) {
|
|
20608
|
+
return path43 instanceof String && cache.has(path43);
|
|
19499
20609
|
}
|
|
19500
20610
|
function toPaths(pathSpec) {
|
|
19501
20611
|
return cache.get(pathSpec) || [];
|
|
@@ -19581,8 +20691,8 @@ function toLinesWithContent(input = "", trimmed2 = true, separator = `
|
|
|
19581
20691
|
function forEachLineWithContent(input, callback) {
|
|
19582
20692
|
return toLinesWithContent(input, true).map((line) => callback(line));
|
|
19583
20693
|
}
|
|
19584
|
-
function folderExists(
|
|
19585
|
-
return import_file_exists.exists(
|
|
20694
|
+
function folderExists(path43) {
|
|
20695
|
+
return import_file_exists.exists(path43, import_file_exists.FOLDER);
|
|
19586
20696
|
}
|
|
19587
20697
|
function append(target, item) {
|
|
19588
20698
|
if (Array.isArray(target)) {
|
|
@@ -19973,8 +21083,8 @@ function checkIsRepoRootTask() {
|
|
|
19973
21083
|
commands,
|
|
19974
21084
|
format: "utf-8",
|
|
19975
21085
|
onError,
|
|
19976
|
-
parser(
|
|
19977
|
-
return /^\.(git)?$/.test(
|
|
21086
|
+
parser(path43) {
|
|
21087
|
+
return /^\.(git)?$/.test(path43.trim());
|
|
19978
21088
|
}
|
|
19979
21089
|
};
|
|
19980
21090
|
}
|
|
@@ -20385,11 +21495,11 @@ function parseGrep(grep) {
|
|
|
20385
21495
|
const paths = /* @__PURE__ */ new Set;
|
|
20386
21496
|
const results = {};
|
|
20387
21497
|
forEachLineWithContent(grep, (input) => {
|
|
20388
|
-
const [
|
|
20389
|
-
paths.add(
|
|
20390
|
-
(results[
|
|
21498
|
+
const [path43, line, preview] = input.split(NULL);
|
|
21499
|
+
paths.add(path43);
|
|
21500
|
+
(results[path43] = results[path43] || []).push({
|
|
20391
21501
|
line: asNumber(line),
|
|
20392
|
-
path:
|
|
21502
|
+
path: path43,
|
|
20393
21503
|
preview
|
|
20394
21504
|
});
|
|
20395
21505
|
});
|
|
@@ -21055,14 +22165,14 @@ var init_hash_object = __esm2({
|
|
|
21055
22165
|
init_task();
|
|
21056
22166
|
}
|
|
21057
22167
|
});
|
|
21058
|
-
function parseInit(bare,
|
|
22168
|
+
function parseInit(bare, path43, text) {
|
|
21059
22169
|
const response = String(text).trim();
|
|
21060
22170
|
let result;
|
|
21061
22171
|
if (result = initResponseRegex.exec(response)) {
|
|
21062
|
-
return new InitSummary(bare,
|
|
22172
|
+
return new InitSummary(bare, path43, false, result[1]);
|
|
21063
22173
|
}
|
|
21064
22174
|
if (result = reInitResponseRegex.exec(response)) {
|
|
21065
|
-
return new InitSummary(bare,
|
|
22175
|
+
return new InitSummary(bare, path43, true, result[1]);
|
|
21066
22176
|
}
|
|
21067
22177
|
let gitDir = "";
|
|
21068
22178
|
const tokens = response.split(" ");
|
|
@@ -21073,7 +22183,7 @@ function parseInit(bare, path33, text) {
|
|
|
21073
22183
|
break;
|
|
21074
22184
|
}
|
|
21075
22185
|
}
|
|
21076
|
-
return new InitSummary(bare,
|
|
22186
|
+
return new InitSummary(bare, path43, /^re/i.test(response), gitDir);
|
|
21077
22187
|
}
|
|
21078
22188
|
var InitSummary;
|
|
21079
22189
|
var initResponseRegex;
|
|
@@ -21081,9 +22191,9 @@ var reInitResponseRegex;
|
|
|
21081
22191
|
var init_InitSummary = __esm2({
|
|
21082
22192
|
"src/lib/responses/InitSummary.ts"() {
|
|
21083
22193
|
InitSummary = class {
|
|
21084
|
-
constructor(bare,
|
|
22194
|
+
constructor(bare, path43, existing, gitDir) {
|
|
21085
22195
|
this.bare = bare;
|
|
21086
|
-
this.path =
|
|
22196
|
+
this.path = path43;
|
|
21087
22197
|
this.existing = existing;
|
|
21088
22198
|
this.gitDir = gitDir;
|
|
21089
22199
|
}
|
|
@@ -21095,7 +22205,7 @@ var init_InitSummary = __esm2({
|
|
|
21095
22205
|
function hasBareCommand(command) {
|
|
21096
22206
|
return command.includes(bareCommand);
|
|
21097
22207
|
}
|
|
21098
|
-
function initTask(bare = false,
|
|
22208
|
+
function initTask(bare = false, path43, customArgs) {
|
|
21099
22209
|
const commands = ["init", ...customArgs];
|
|
21100
22210
|
if (bare && !hasBareCommand(commands)) {
|
|
21101
22211
|
commands.splice(1, 0, bareCommand);
|
|
@@ -21104,7 +22214,7 @@ function initTask(bare = false, path33, customArgs) {
|
|
|
21104
22214
|
commands,
|
|
21105
22215
|
format: "utf-8",
|
|
21106
22216
|
parser(text) {
|
|
21107
|
-
return parseInit(commands.includes("--bare"),
|
|
22217
|
+
return parseInit(commands.includes("--bare"), path43, text);
|
|
21108
22218
|
}
|
|
21109
22219
|
};
|
|
21110
22220
|
}
|
|
@@ -21819,12 +22929,12 @@ var init_FileStatusSummary = __esm2({
|
|
|
21819
22929
|
"src/lib/responses/FileStatusSummary.ts"() {
|
|
21820
22930
|
fromPathRegex = /^(.+)\0(.+)$/;
|
|
21821
22931
|
FileStatusSummary = class {
|
|
21822
|
-
constructor(
|
|
21823
|
-
this.path =
|
|
22932
|
+
constructor(path43, index, working_dir) {
|
|
22933
|
+
this.path = path43;
|
|
21824
22934
|
this.index = index;
|
|
21825
22935
|
this.working_dir = working_dir;
|
|
21826
22936
|
if (index === "R" || working_dir === "R") {
|
|
21827
|
-
const detail = fromPathRegex.exec(
|
|
22937
|
+
const detail = fromPathRegex.exec(path43) || [null, path43, path43];
|
|
21828
22938
|
this.from = detail[2] || "";
|
|
21829
22939
|
this.path = detail[1] || "";
|
|
21830
22940
|
}
|
|
@@ -21855,14 +22965,14 @@ function splitLine(result, lineStr) {
|
|
|
21855
22965
|
default:
|
|
21856
22966
|
return;
|
|
21857
22967
|
}
|
|
21858
|
-
function data(index, workingDir,
|
|
22968
|
+
function data(index, workingDir, path43) {
|
|
21859
22969
|
const raw = `${index}${workingDir}`;
|
|
21860
22970
|
const handler = parsers6.get(raw);
|
|
21861
22971
|
if (handler) {
|
|
21862
|
-
handler(result,
|
|
22972
|
+
handler(result, path43);
|
|
21863
22973
|
}
|
|
21864
22974
|
if (raw !== "##" && raw !== "!!") {
|
|
21865
|
-
result.files.push(new FileStatusSummary(
|
|
22975
|
+
result.files.push(new FileStatusSummary(path43, index, workingDir));
|
|
21866
22976
|
}
|
|
21867
22977
|
}
|
|
21868
22978
|
}
|
|
@@ -22146,8 +23256,8 @@ var init_simple_git_api = __esm2({
|
|
|
22146
23256
|
}
|
|
22147
23257
|
return this._runTask(configurationErrorTask("Git.cwd: workingDirectory must be supplied as a string"), next);
|
|
22148
23258
|
}
|
|
22149
|
-
hashObject(
|
|
22150
|
-
return this._runTask(hashObjectTask(
|
|
23259
|
+
hashObject(path43, write) {
|
|
23260
|
+
return this._runTask(hashObjectTask(path43, write === true), trailingFunctionArgument(arguments));
|
|
22151
23261
|
}
|
|
22152
23262
|
init(bare) {
|
|
22153
23263
|
return this._runTask(initTask(bare === true, this._executor.cwd, getTrailingOptions(arguments)), trailingFunctionArgument(arguments));
|
|
@@ -22440,8 +23550,8 @@ var init_branch = __esm2({
|
|
|
22440
23550
|
}
|
|
22441
23551
|
});
|
|
22442
23552
|
function toPath(input) {
|
|
22443
|
-
const
|
|
22444
|
-
return
|
|
23553
|
+
const path43 = input.trim().replace(/^["']|["']$/g, "");
|
|
23554
|
+
return path43 && normalize(path43);
|
|
22445
23555
|
}
|
|
22446
23556
|
var parseCheckIgnore;
|
|
22447
23557
|
var init_CheckIgnore = __esm2({
|
|
@@ -22706,8 +23816,8 @@ __export2(sub_module_exports, {
|
|
|
22706
23816
|
subModuleTask: () => subModuleTask,
|
|
22707
23817
|
updateSubModuleTask: () => updateSubModuleTask
|
|
22708
23818
|
});
|
|
22709
|
-
function addSubModuleTask(repo,
|
|
22710
|
-
return subModuleTask(["add", repo,
|
|
23819
|
+
function addSubModuleTask(repo, path43) {
|
|
23820
|
+
return subModuleTask(["add", repo, path43]);
|
|
22711
23821
|
}
|
|
22712
23822
|
function initSubModuleTask(customArgs) {
|
|
22713
23823
|
return subModuleTask(["init", ...customArgs]);
|
|
@@ -22820,7 +23930,7 @@ var init_tag = __esm2({
|
|
|
22820
23930
|
init_TagList();
|
|
22821
23931
|
}
|
|
22822
23932
|
});
|
|
22823
|
-
var require_git =
|
|
23933
|
+
var require_git = __commonJS22({
|
|
22824
23934
|
"src/git.js"(exports, module) {
|
|
22825
23935
|
var { GitExecutor: GitExecutor2 } = (init_git_executor(), __toCommonJS(git_executor_exports));
|
|
22826
23936
|
var { SimpleGitApi: SimpleGitApi2 } = (init_simple_git_api(), __toCommonJS(simple_git_api_exports));
|
|
@@ -22961,8 +24071,8 @@ var require_git = __commonJS2({
|
|
|
22961
24071
|
}
|
|
22962
24072
|
return this._runTask(straightThroughStringTask2(command, this._trimmed), next);
|
|
22963
24073
|
};
|
|
22964
|
-
Git2.prototype.submoduleAdd = function(repo,
|
|
22965
|
-
return this._runTask(addSubModuleTask2(repo,
|
|
24074
|
+
Git2.prototype.submoduleAdd = function(repo, path43, then) {
|
|
24075
|
+
return this._runTask(addSubModuleTask2(repo, path43), trailingFunctionArgument2(arguments));
|
|
22966
24076
|
};
|
|
22967
24077
|
Git2.prototype.submoduleUpdate = function(args2, then) {
|
|
22968
24078
|
return this._runTask(updateSubModuleTask2(getTrailingOptions2(arguments, true)), trailingFunctionArgument2(arguments));
|
|
@@ -23495,19 +24605,19 @@ class WorktreeService {
|
|
|
23495
24605
|
return esm_default(cwd || this.config.baseDir);
|
|
23496
24606
|
}
|
|
23497
24607
|
getWorktreesDir() {
|
|
23498
|
-
return
|
|
24608
|
+
return path42.join(this.config.hiveDir, ".worktrees");
|
|
23499
24609
|
}
|
|
23500
24610
|
getWorktreePath(feature, step) {
|
|
23501
|
-
return
|
|
24611
|
+
return path42.join(this.getWorktreesDir(), feature, step);
|
|
23502
24612
|
}
|
|
23503
24613
|
async getStepStatusPath(feature, step) {
|
|
23504
|
-
const featurePath =
|
|
23505
|
-
const tasksPath =
|
|
24614
|
+
const featurePath = path42.join(this.config.hiveDir, "features", feature);
|
|
24615
|
+
const tasksPath = path42.join(featurePath, "tasks", step, "status.json");
|
|
23506
24616
|
try {
|
|
23507
24617
|
await fs7.access(tasksPath);
|
|
23508
24618
|
return tasksPath;
|
|
23509
24619
|
} catch {}
|
|
23510
|
-
return
|
|
24620
|
+
return path42.join(featurePath, "execution", step, "status.json");
|
|
23511
24621
|
}
|
|
23512
24622
|
getBranchName(feature, step) {
|
|
23513
24623
|
return `hive/${feature}/${step}`;
|
|
@@ -23516,7 +24626,7 @@ class WorktreeService {
|
|
|
23516
24626
|
const worktreePath = this.getWorktreePath(feature, step);
|
|
23517
24627
|
const branchName = this.getBranchName(feature, step);
|
|
23518
24628
|
const git = this.getGit();
|
|
23519
|
-
await fs7.mkdir(
|
|
24629
|
+
await fs7.mkdir(path42.dirname(worktreePath), { recursive: true });
|
|
23520
24630
|
const base = baseBranch || (await git.revparse(["HEAD"])).trim();
|
|
23521
24631
|
const existing = await this.get(feature, step);
|
|
23522
24632
|
if (existing) {
|
|
@@ -23611,7 +24721,7 @@ class WorktreeService {
|
|
|
23611
24721
|
}
|
|
23612
24722
|
async exportPatch(feature, step, baseBranch) {
|
|
23613
24723
|
const worktreePath = this.getWorktreePath(feature, step);
|
|
23614
|
-
const patchPath =
|
|
24724
|
+
const patchPath = path42.join(worktreePath, "..", `${step}.patch`);
|
|
23615
24725
|
const base = baseBranch || "HEAD~1";
|
|
23616
24726
|
const worktreeGit = this.getGit(worktreePath);
|
|
23617
24727
|
const diff = await worktreeGit.diff([`${base}...HEAD`]);
|
|
@@ -23623,7 +24733,7 @@ class WorktreeService {
|
|
|
23623
24733
|
if (!hasDiff) {
|
|
23624
24734
|
return { success: true, filesAffected: [] };
|
|
23625
24735
|
}
|
|
23626
|
-
const patchPath =
|
|
24736
|
+
const patchPath = path42.join(this.config.hiveDir, ".worktrees", feature, `${step}.patch`);
|
|
23627
24737
|
try {
|
|
23628
24738
|
await fs7.writeFile(patchPath, diffContent);
|
|
23629
24739
|
const git = this.getGit();
|
|
@@ -23645,7 +24755,7 @@ class WorktreeService {
|
|
|
23645
24755
|
if (!hasDiff) {
|
|
23646
24756
|
return { success: true, filesAffected: [] };
|
|
23647
24757
|
}
|
|
23648
|
-
const patchPath =
|
|
24758
|
+
const patchPath = path42.join(this.config.hiveDir, ".worktrees", feature, `${step}.patch`);
|
|
23649
24759
|
try {
|
|
23650
24760
|
await fs7.writeFile(patchPath, diffContent);
|
|
23651
24761
|
const git = this.getGit();
|
|
@@ -23714,7 +24824,7 @@ class WorktreeService {
|
|
|
23714
24824
|
try {
|
|
23715
24825
|
const features = feature ? [feature] : await fs7.readdir(worktreesDir);
|
|
23716
24826
|
for (const feat of features) {
|
|
23717
|
-
const featurePath =
|
|
24827
|
+
const featurePath = path42.join(worktreesDir, feat);
|
|
23718
24828
|
const stat2 = await fs7.stat(featurePath).catch(() => null);
|
|
23719
24829
|
if (!stat2?.isDirectory())
|
|
23720
24830
|
continue;
|
|
@@ -23738,13 +24848,13 @@ class WorktreeService {
|
|
|
23738
24848
|
const worktreesDir = this.getWorktreesDir();
|
|
23739
24849
|
const features = feature ? [feature] : await fs7.readdir(worktreesDir).catch(() => []);
|
|
23740
24850
|
for (const feat of features) {
|
|
23741
|
-
const featurePath =
|
|
24851
|
+
const featurePath = path42.join(worktreesDir, feat);
|
|
23742
24852
|
const stat2 = await fs7.stat(featurePath).catch(() => null);
|
|
23743
24853
|
if (!stat2?.isDirectory())
|
|
23744
24854
|
continue;
|
|
23745
24855
|
const steps = await fs7.readdir(featurePath).catch(() => []);
|
|
23746
24856
|
for (const step of steps) {
|
|
23747
|
-
const worktreePath =
|
|
24857
|
+
const worktreePath = path42.join(featurePath, step);
|
|
23748
24858
|
const stepStat = await fs7.stat(worktreePath).catch(() => null);
|
|
23749
24859
|
if (!stepStat?.isDirectory())
|
|
23750
24860
|
continue;
|
|
@@ -23764,7 +24874,7 @@ class WorktreeService {
|
|
|
23764
24874
|
if (!hasDiff) {
|
|
23765
24875
|
return [];
|
|
23766
24876
|
}
|
|
23767
|
-
const patchPath =
|
|
24877
|
+
const patchPath = path42.join(this.config.hiveDir, ".worktrees", feature, `${step}-check.patch`);
|
|
23768
24878
|
try {
|
|
23769
24879
|
await fs7.writeFile(patchPath, diffContent);
|
|
23770
24880
|
const git = this.getGit();
|
|
@@ -23935,7 +25045,7 @@ class ContextService {
|
|
|
23935
25045
|
write(featureName, fileName, content) {
|
|
23936
25046
|
const contextPath = getContextPath(this.projectRoot, featureName);
|
|
23937
25047
|
ensureDir(contextPath);
|
|
23938
|
-
const filePath =
|
|
25048
|
+
const filePath = path52.join(contextPath, this.normalizeFileName(fileName));
|
|
23939
25049
|
writeText(filePath, content);
|
|
23940
25050
|
const totalChars = this.list(featureName).reduce((sum, c) => sum + c.content.length, 0);
|
|
23941
25051
|
if (totalChars > 20000) {
|
|
@@ -23947,7 +25057,7 @@ class ContextService {
|
|
|
23947
25057
|
}
|
|
23948
25058
|
read(featureName, fileName) {
|
|
23949
25059
|
const contextPath = getContextPath(this.projectRoot, featureName);
|
|
23950
|
-
const filePath =
|
|
25060
|
+
const filePath = path52.join(contextPath, this.normalizeFileName(fileName));
|
|
23951
25061
|
return readText(filePath);
|
|
23952
25062
|
}
|
|
23953
25063
|
list(featureName) {
|
|
@@ -23956,7 +25066,7 @@ class ContextService {
|
|
|
23956
25066
|
return [];
|
|
23957
25067
|
const files = fs8.readdirSync(contextPath, { withFileTypes: true }).filter((f) => f.isFile() && f.name.endsWith(".md")).map((f) => f.name);
|
|
23958
25068
|
return files.map((name) => {
|
|
23959
|
-
const filePath =
|
|
25069
|
+
const filePath = path52.join(contextPath, name);
|
|
23960
25070
|
const stat2 = fs8.statSync(filePath);
|
|
23961
25071
|
const content = readText(filePath) || "";
|
|
23962
25072
|
return {
|
|
@@ -23968,7 +25078,7 @@ class ContextService {
|
|
|
23968
25078
|
}
|
|
23969
25079
|
delete(featureName, fileName) {
|
|
23970
25080
|
const contextPath = getContextPath(this.projectRoot, featureName);
|
|
23971
|
-
const filePath =
|
|
25081
|
+
const filePath = path52.join(contextPath, this.normalizeFileName(fileName));
|
|
23972
25082
|
if (fileExists(filePath)) {
|
|
23973
25083
|
fs8.unlinkSync(filePath);
|
|
23974
25084
|
return true;
|
|
@@ -23993,14 +25103,14 @@ ${f.content}`);
|
|
|
23993
25103
|
if (contexts.length === 0)
|
|
23994
25104
|
return { archived: [], archivePath: "" };
|
|
23995
25105
|
const contextPath = getContextPath(this.projectRoot, featureName);
|
|
23996
|
-
const archiveDir =
|
|
25106
|
+
const archiveDir = path52.join(contextPath, "..", "archive");
|
|
23997
25107
|
ensureDir(archiveDir);
|
|
23998
25108
|
const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
|
|
23999
25109
|
const archived = [];
|
|
24000
25110
|
for (const ctx of contexts) {
|
|
24001
25111
|
const archiveName = `${timestamp}_${ctx.name}.md`;
|
|
24002
|
-
const src =
|
|
24003
|
-
const dest =
|
|
25112
|
+
const src = path52.join(contextPath, `${ctx.name}.md`);
|
|
25113
|
+
const dest = path52.join(archiveDir, archiveName);
|
|
24004
25114
|
fs8.copyFileSync(src, dest);
|
|
24005
25115
|
fs8.unlinkSync(src);
|
|
24006
25116
|
archived.push(ctx.name);
|
|
@@ -24030,8 +25140,8 @@ class ConfigService {
|
|
|
24030
25140
|
cachedCustomAgentConfigs = null;
|
|
24031
25141
|
constructor() {
|
|
24032
25142
|
const homeDir = process.env.HOME || process.env.USERPROFILE || "";
|
|
24033
|
-
const configDir =
|
|
24034
|
-
this.configPath =
|
|
25143
|
+
const configDir = path7.join(homeDir, ".config", "opencode");
|
|
25144
|
+
this.configPath = path7.join(configDir, "agent_hive.json");
|
|
24035
25145
|
}
|
|
24036
25146
|
getPath() {
|
|
24037
25147
|
return this.configPath;
|
|
@@ -24094,7 +25204,7 @@ class ConfigService {
|
|
|
24094
25204
|
...updates.customAgents
|
|
24095
25205
|
} : current.customAgents
|
|
24096
25206
|
};
|
|
24097
|
-
const configDir =
|
|
25207
|
+
const configDir = path7.dirname(this.configPath);
|
|
24098
25208
|
if (!fs10.existsSync(configDir)) {
|
|
24099
25209
|
fs10.mkdirSync(configDir, { recursive: true });
|
|
24100
25210
|
}
|
|
@@ -24249,7 +25359,7 @@ class AgentsMdService {
|
|
|
24249
25359
|
this.contextService = contextService;
|
|
24250
25360
|
}
|
|
24251
25361
|
async init() {
|
|
24252
|
-
const agentsMdPath =
|
|
25362
|
+
const agentsMdPath = path8.join(this.rootDir, "AGENTS.md");
|
|
24253
25363
|
const existed = fileExists(agentsMdPath);
|
|
24254
25364
|
if (existed) {
|
|
24255
25365
|
const existing = readText(agentsMdPath);
|
|
@@ -24260,14 +25370,14 @@ class AgentsMdService {
|
|
|
24260
25370
|
}
|
|
24261
25371
|
async sync(featureName) {
|
|
24262
25372
|
const contexts = this.contextService.list(featureName);
|
|
24263
|
-
const agentsMdPath =
|
|
25373
|
+
const agentsMdPath = path8.join(this.rootDir, "AGENTS.md");
|
|
24264
25374
|
const current = await fs11.promises.readFile(agentsMdPath, "utf-8").catch(() => "");
|
|
24265
25375
|
const findings = this.extractFindings(contexts);
|
|
24266
25376
|
const proposals = this.generateProposals(findings, current);
|
|
24267
25377
|
return { proposals, diff: this.formatDiff(current, proposals) };
|
|
24268
25378
|
}
|
|
24269
25379
|
apply(content) {
|
|
24270
|
-
const agentsMdPath =
|
|
25380
|
+
const agentsMdPath = path8.join(this.rootDir, "AGENTS.md");
|
|
24271
25381
|
const isNew = !fileExists(agentsMdPath);
|
|
24272
25382
|
writeText(agentsMdPath, content);
|
|
24273
25383
|
return { path: agentsMdPath, chars: content.length, isNew };
|
|
@@ -24327,7 +25437,7 @@ class AgentsMdService {
|
|
|
24327
25437
|
return this.generateTemplate(detections);
|
|
24328
25438
|
}
|
|
24329
25439
|
async detectProjectInfo() {
|
|
24330
|
-
const packageJsonPath =
|
|
25440
|
+
const packageJsonPath = path8.join(this.rootDir, "package.json");
|
|
24331
25441
|
let packageJson = null;
|
|
24332
25442
|
if (fileExists(packageJsonPath)) {
|
|
24333
25443
|
try {
|
|
@@ -24347,26 +25457,26 @@ class AgentsMdService {
|
|
|
24347
25457
|
return info;
|
|
24348
25458
|
}
|
|
24349
25459
|
detectPackageManager() {
|
|
24350
|
-
if (fileExists(
|
|
25460
|
+
if (fileExists(path8.join(this.rootDir, "bun.lockb")))
|
|
24351
25461
|
return "bun";
|
|
24352
|
-
if (fileExists(
|
|
25462
|
+
if (fileExists(path8.join(this.rootDir, "pnpm-lock.yaml")))
|
|
24353
25463
|
return "pnpm";
|
|
24354
|
-
if (fileExists(
|
|
25464
|
+
if (fileExists(path8.join(this.rootDir, "yarn.lock")))
|
|
24355
25465
|
return "yarn";
|
|
24356
|
-
if (fileExists(
|
|
25466
|
+
if (fileExists(path8.join(this.rootDir, "package-lock.json")))
|
|
24357
25467
|
return "npm";
|
|
24358
25468
|
return "npm";
|
|
24359
25469
|
}
|
|
24360
25470
|
detectLanguage() {
|
|
24361
|
-
if (fileExists(
|
|
25471
|
+
if (fileExists(path8.join(this.rootDir, "tsconfig.json")))
|
|
24362
25472
|
return "TypeScript";
|
|
24363
|
-
if (fileExists(
|
|
25473
|
+
if (fileExists(path8.join(this.rootDir, "package.json")))
|
|
24364
25474
|
return "JavaScript";
|
|
24365
|
-
if (fileExists(
|
|
25475
|
+
if (fileExists(path8.join(this.rootDir, "requirements.txt")))
|
|
24366
25476
|
return "Python";
|
|
24367
|
-
if (fileExists(
|
|
25477
|
+
if (fileExists(path8.join(this.rootDir, "go.mod")))
|
|
24368
25478
|
return "Go";
|
|
24369
|
-
if (fileExists(
|
|
25479
|
+
if (fileExists(path8.join(this.rootDir, "Cargo.toml")))
|
|
24370
25480
|
return "Rust";
|
|
24371
25481
|
return "Unknown";
|
|
24372
25482
|
}
|
|
@@ -24447,19 +25557,19 @@ class AgentsMdService {
|
|
|
24447
25557
|
|
|
24448
25558
|
class DockerSandboxService {
|
|
24449
25559
|
static detectImage(worktreePath) {
|
|
24450
|
-
if (
|
|
25560
|
+
if (existsSync52(join92(worktreePath, "Dockerfile"))) {
|
|
24451
25561
|
return null;
|
|
24452
25562
|
}
|
|
24453
|
-
if (
|
|
25563
|
+
if (existsSync52(join92(worktreePath, "package.json"))) {
|
|
24454
25564
|
return "node:22-slim";
|
|
24455
25565
|
}
|
|
24456
|
-
if (
|
|
25566
|
+
if (existsSync52(join92(worktreePath, "requirements.txt")) || existsSync52(join92(worktreePath, "pyproject.toml"))) {
|
|
24457
25567
|
return "python:3.12-slim";
|
|
24458
25568
|
}
|
|
24459
|
-
if (
|
|
25569
|
+
if (existsSync52(join92(worktreePath, "go.mod"))) {
|
|
24460
25570
|
return "golang:1.22-slim";
|
|
24461
25571
|
}
|
|
24462
|
-
if (
|
|
25572
|
+
if (existsSync52(join92(worktreePath, "Cargo.toml"))) {
|
|
24463
25573
|
return "rust:1.77-slim";
|
|
24464
25574
|
}
|
|
24465
25575
|
return "ubuntu:24.04";
|
|
@@ -25021,10 +26131,10 @@ function applyContextBudget(files, config2 = {}) {
|
|
|
25021
26131
|
|
|
25022
26132
|
// src/utils/prompt-file.ts
|
|
25023
26133
|
import * as fs6 from "fs";
|
|
25024
|
-
import * as
|
|
26134
|
+
import * as path6 from "path";
|
|
25025
26135
|
function writeWorkerPromptFile(feature, task, prompt, hiveDir) {
|
|
25026
|
-
const promptDir =
|
|
25027
|
-
const promptPath =
|
|
26136
|
+
const promptDir = path6.join(hiveDir, "features", feature, "tasks", task);
|
|
26137
|
+
const promptPath = path6.join(promptDir, "worker-prompt.md");
|
|
25028
26138
|
if (!fs6.existsSync(promptDir)) {
|
|
25029
26139
|
fs6.mkdirSync(promptDir, { recursive: true });
|
|
25030
26140
|
}
|
|
@@ -25106,7 +26216,7 @@ async function buildAutoLoadedSkillsContent(agentName, configService, projectRoo
|
|
|
25106
26216
|
if (autoLoadSkills.length === 0) {
|
|
25107
26217
|
return "";
|
|
25108
26218
|
}
|
|
25109
|
-
const homeDir = process.env.HOME ||
|
|
26219
|
+
const homeDir = process.env.HOME || os4.homedir();
|
|
25110
26220
|
const skillTemplates = [];
|
|
25111
26221
|
for (const skillId of autoLoadSkills) {
|
|
25112
26222
|
const builtinSkill = BUILTIN_SKILLS.find((entry) => entry.name === skillId);
|
|
@@ -25165,6 +26275,18 @@ No Hive skills available.` : base + formatSkillsXml(filteredSkills);
|
|
|
25165
26275
|
}
|
|
25166
26276
|
});
|
|
25167
26277
|
}
|
|
26278
|
+
var ENV_VAR_RE = /^([A-Za-z_][A-Za-z0-9_]*=[^\s]* +)*/;
|
|
26279
|
+
function prefixWithSnip(command, snipCommand = "snip") {
|
|
26280
|
+
if (command.startsWith(`${snipCommand} `)) {
|
|
26281
|
+
return command;
|
|
26282
|
+
}
|
|
26283
|
+
const splitMatch = command.match(/^(.*?)( &&| [|]| ;|;)(.*)$/);
|
|
26284
|
+
const firstPart = splitMatch ? splitMatch[1] : command;
|
|
26285
|
+
const rest = splitMatch ? splitMatch[2] + splitMatch[3] : "";
|
|
26286
|
+
const envPrefix = (firstPart.match(ENV_VAR_RE) ?? [""])[0];
|
|
26287
|
+
const bareCmd = firstPart.slice(envPrefix.length).trim();
|
|
26288
|
+
return `${envPrefix}${snipCommand} ${bareCmd}${rest}`;
|
|
26289
|
+
}
|
|
25168
26290
|
var plugin = async (ctx) => {
|
|
25169
26291
|
const { directory, client } = ctx;
|
|
25170
26292
|
const featureService = new FeatureService(directory);
|
|
@@ -25180,7 +26302,7 @@ var plugin = async (ctx) => {
|
|
|
25180
26302
|
const effectiveAutoLoadSkills = configService.getAgentConfig("zetta").autoLoadSkills ?? [];
|
|
25181
26303
|
const worktreeService = new WorktreeService({
|
|
25182
26304
|
baseDir: directory,
|
|
25183
|
-
hiveDir:
|
|
26305
|
+
hiveDir: path9.join(directory, ".hive")
|
|
25184
26306
|
});
|
|
25185
26307
|
const isOmoSlimEnabled = () => {
|
|
25186
26308
|
return configService.isOmoSlimEnabled();
|
|
@@ -25207,7 +26329,7 @@ var plugin = async (ctx) => {
|
|
|
25207
26329
|
};
|
|
25208
26330
|
const checkBlocked = (feature) => {
|
|
25209
26331
|
const fs9 = __require("fs");
|
|
25210
|
-
const blockedPath =
|
|
26332
|
+
const blockedPath = path9.join(directory, ".hive", "features", feature, "BLOCKED");
|
|
25211
26333
|
if (fs9.existsSync(blockedPath)) {
|
|
25212
26334
|
const reason = fs9.readFileSync(blockedPath, "utf-8").trim();
|
|
25213
26335
|
return `⛔ BLOCKED by Beekeeper
|
|
@@ -25361,9 +26483,9 @@ To unblock: Remove .hive/features/${feature}/BLOCKED`;
|
|
|
25361
26483
|
spec: specContent,
|
|
25362
26484
|
workerPrompt
|
|
25363
26485
|
});
|
|
25364
|
-
const hiveDir =
|
|
26486
|
+
const hiveDir = path9.join(directory, ".hive");
|
|
25365
26487
|
const workerPromptPath = writeWorkerPromptFile(feature, task, workerPrompt, hiveDir);
|
|
25366
|
-
const relativePromptPath = normalizePath(
|
|
26488
|
+
const relativePromptPath = normalizePath(path9.relative(directory, workerPromptPath));
|
|
25367
26489
|
const PREVIEW_MAX_LENGTH = 200;
|
|
25368
26490
|
const workerPromptPreview = workerPrompt.length > PREVIEW_MAX_LENGTH ? workerPrompt.slice(0, PREVIEW_MAX_LENGTH) + "..." : workerPrompt;
|
|
25369
26491
|
const taskToolPrompt = `Follow instructions in @${relativePromptPath}`;
|
|
@@ -25753,9 +26875,6 @@ ${snapshot}
|
|
|
25753
26875
|
}
|
|
25754
26876
|
if (input.tool !== "bash")
|
|
25755
26877
|
return;
|
|
25756
|
-
const sandboxConfig = configService.getSandboxConfig();
|
|
25757
|
-
if (sandboxConfig.mode === "none")
|
|
25758
|
-
return;
|
|
25759
26878
|
const command = output.args?.command?.trim();
|
|
25760
26879
|
if (!command)
|
|
25761
26880
|
return;
|
|
@@ -25765,15 +26884,27 @@ ${snapshot}
|
|
|
25765
26884
|
output.args.command = strippedCommand;
|
|
25766
26885
|
return;
|
|
25767
26886
|
}
|
|
25768
|
-
const
|
|
25769
|
-
|
|
25770
|
-
|
|
25771
|
-
|
|
25772
|
-
|
|
25773
|
-
|
|
25774
|
-
|
|
25775
|
-
|
|
25776
|
-
|
|
26887
|
+
const snipConfig = configService.get().snip;
|
|
26888
|
+
let finalCommand = command;
|
|
26889
|
+
if (snipConfig?.enabled) {
|
|
26890
|
+
finalCommand = prefixWithSnip(command, snipConfig.command ?? "snip");
|
|
26891
|
+
}
|
|
26892
|
+
const sandboxConfig = configService.getSandboxConfig();
|
|
26893
|
+
if (sandboxConfig.mode !== "none") {
|
|
26894
|
+
const workdir = output.args?.workdir;
|
|
26895
|
+
if (workdir) {
|
|
26896
|
+
const hiveWorktreeBase = path9.join(directory, ".hive", ".worktrees");
|
|
26897
|
+
if (workdir.startsWith(hiveWorktreeBase)) {
|
|
26898
|
+
const wrapped = DockerSandboxService.wrapCommand(workdir, finalCommand, sandboxConfig);
|
|
26899
|
+
output.args.command = wrapped;
|
|
26900
|
+
output.args.workdir = undefined;
|
|
26901
|
+
return;
|
|
26902
|
+
}
|
|
26903
|
+
}
|
|
26904
|
+
}
|
|
26905
|
+
if (snipConfig?.enabled && finalCommand !== command) {
|
|
26906
|
+
output.args.command = finalCommand;
|
|
26907
|
+
}
|
|
25777
26908
|
},
|
|
25778
26909
|
"tool.execute.after": async (input, output) => {
|
|
25779
26910
|
const truncationConfig = configService.get().tokenTruncation;
|
|
@@ -25818,8 +26949,17 @@ ${snapshot}
|
|
|
25818
26949
|
hive_memory_list: hiveMemoryListTool,
|
|
25819
26950
|
hive_memory_set: hiveMemorySetTool,
|
|
25820
26951
|
hive_memory_replace: hiveMemoryReplaceTool,
|
|
26952
|
+
hive_memory_recall: hiveMemoryRecallTool,
|
|
26953
|
+
hive_memory_update: hiveMemoryUpdateTool,
|
|
26954
|
+
hive_memory_forget: hiveMemoryForgetTool,
|
|
25821
26955
|
hive_journal_write: hiveJournalWriteTool,
|
|
25822
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,
|
|
25823
26963
|
hive_skill: createHiveSkillTool(filteredSkills),
|
|
25824
26964
|
hive_feature_create: tool({
|
|
25825
26965
|
description: "Create a new feature and set it as active",
|
|
@@ -26787,9 +27927,52 @@ ${Object.entries(customAgentConfigs).sort(([left], [right]) => left.localeCompar
|
|
|
26787
27927
|
}
|
|
26788
27928
|
}
|
|
26789
27929
|
}
|
|
27930
|
+
},
|
|
27931
|
+
event: async (input) => {
|
|
27932
|
+
const smartTitleConfig = configService.get().smartTitle;
|
|
27933
|
+
if (!smartTitleConfig?.enabled)
|
|
27934
|
+
return;
|
|
27935
|
+
const { event } = input;
|
|
27936
|
+
if (event.type === "message.created" || event.type === "message-part.created") {
|
|
27937
|
+
const sessionID = event.properties?.sessionID;
|
|
27938
|
+
const role = event.properties?.role;
|
|
27939
|
+
const content = event.properties?.content;
|
|
27940
|
+
if (sessionID && role === "user" && content && !sessionFirstMessage.has(sessionID)) {
|
|
27941
|
+
sessionFirstMessage.set(sessionID, content);
|
|
27942
|
+
}
|
|
27943
|
+
}
|
|
27944
|
+
if (event.type === "session.idle") {
|
|
27945
|
+
const sessionID = event.properties?.sessionID;
|
|
27946
|
+
if (!sessionID)
|
|
27947
|
+
return;
|
|
27948
|
+
if (sessionID.includes("-worker-") || sessionID.includes("-sub-"))
|
|
27949
|
+
return;
|
|
27950
|
+
const currentCount = (sessionIdleCount.get(sessionID) || 0) + 1;
|
|
27951
|
+
sessionIdleCount.set(sessionID, currentCount);
|
|
27952
|
+
if (currentCount % (smartTitleConfig.updateThreshold ?? 1) !== 0)
|
|
27953
|
+
return;
|
|
27954
|
+
const firstMessage = sessionFirstMessage.get(sessionID);
|
|
27955
|
+
if (firstMessage) {
|
|
27956
|
+
const title = generateSmartTitle(firstMessage);
|
|
27957
|
+
console.log(`[hive:smart-title] Title for ${sessionID}: "${title}"`);
|
|
27958
|
+
}
|
|
27959
|
+
}
|
|
26790
27960
|
}
|
|
26791
27961
|
};
|
|
26792
27962
|
};
|
|
27963
|
+
var sessionIdleCount = new Map;
|
|
27964
|
+
var sessionFirstMessage = new Map;
|
|
27965
|
+
function generateSmartTitle(message) {
|
|
27966
|
+
if (!message)
|
|
27967
|
+
return "Untitled session";
|
|
27968
|
+
let cleaned = message.trim();
|
|
27969
|
+
cleaned = cleaned.replace(/^(user[:\s]*|human[:\s]*|hi[,!\s]*|hello[,!\s]*|hey[,!\s]*)/i, "");
|
|
27970
|
+
if (cleaned.length > 50) {
|
|
27971
|
+
cleaned = cleaned.slice(0, 47) + "...";
|
|
27972
|
+
}
|
|
27973
|
+
cleaned = cleaned.charAt(0).toUpperCase() + cleaned.slice(1);
|
|
27974
|
+
return cleaned || "Untitled session";
|
|
27975
|
+
}
|
|
26793
27976
|
var src_default = plugin;
|
|
26794
27977
|
export {
|
|
26795
27978
|
src_default as default
|