@hung319/opencode-hive 1.3.1 → 1.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -13,8 +13,223 @@ var __export = (target, all) => {
13
13
  set: __exportSetter.bind(all, name)
14
14
  });
15
15
  };
16
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
16
17
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
17
18
 
19
+ // src/utils/context-compression.ts
20
+ var exports_context_compression = {};
21
+ __export(exports_context_compression, {
22
+ needsCompression: () => needsCompression,
23
+ getContextUsage: () => getContextUsage,
24
+ estimateTokens: () => estimateTokens,
25
+ createCompactionHook: () => createCompactionHook,
26
+ compressContext: () => compressContext,
27
+ buildCompressionHint: () => buildCompressionHint
28
+ });
29
+ function estimateTokens(messages) {
30
+ let total = 0;
31
+ for (const msg of messages) {
32
+ if (typeof msg.content === "string") {
33
+ total += msg.content.length / 4;
34
+ } else if (Array.isArray(msg.content)) {
35
+ for (const part of msg.content) {
36
+ if (typeof part === "string") {
37
+ total += part.length / 4;
38
+ } else if (part && typeof part === "object") {
39
+ const p = part;
40
+ if (p.type === "text") {
41
+ total += (p.text?.length ?? 0) / 4;
42
+ } else if (p.type === "tool_result") {
43
+ total += (p.content?.length ?? 0) / 6;
44
+ }
45
+ }
46
+ }
47
+ }
48
+ }
49
+ return Math.ceil(total);
50
+ }
51
+ function getContextUsage(messages, contextLimit) {
52
+ const tokens = estimateTokens(messages);
53
+ return tokens / contextLimit;
54
+ }
55
+ function needsCompression(messages, contextLimit, config2 = DEFAULT_CONFIG) {
56
+ if (!config2.enabled)
57
+ return false;
58
+ return getContextUsage(messages, contextLimit) >= config2.threshold;
59
+ }
60
+ function deduplicateToolCalls(messages) {
61
+ const seen = new Map;
62
+ const result = [];
63
+ for (let i = messages.length - 1;i >= 0; i--) {
64
+ const msg = messages[i];
65
+ if (msg.role !== "assistant" || !msg.tool_calls?.length) {
66
+ result.unshift(msg);
67
+ continue;
68
+ }
69
+ for (const toolCall of msg.tool_calls) {
70
+ const key = `${toolCall.name}:${JSON.stringify(toolCall.arguments || {}).slice(0, 100)}`;
71
+ if (!seen.has(key)) {
72
+ seen.set(key, i);
73
+ }
74
+ }
75
+ }
76
+ const keptIndices = new Set(seen.values());
77
+ return messages.filter((_, idx) => keptIndices.has(idx));
78
+ }
79
+ function removeSupersededWrites(messages) {
80
+ const latestWrite = new Map;
81
+ const result = [];
82
+ for (let i = messages.length - 1;i >= 0; i--) {
83
+ const msg = messages[i];
84
+ if (msg.role !== "assistant" || !msg.tool_calls?.length)
85
+ continue;
86
+ for (const toolCall of msg.tool_calls) {
87
+ if (toolCall.name === "filesystem_write_file" || toolCall.name === "write") {
88
+ const args2 = toolCall.arguments;
89
+ if (args2?.path) {
90
+ latestWrite.set(args2.path, i);
91
+ }
92
+ }
93
+ }
94
+ }
95
+ for (let i = 0;i < messages.length; i++) {
96
+ const msg = messages[i];
97
+ if (msg.role !== "assistant" || !msg.tool_calls?.length) {
98
+ result.push(msg);
99
+ continue;
100
+ }
101
+ const filteredCalls = msg.tool_calls.filter((tc) => {
102
+ if (tc.name === "filesystem_write_file" || tc.name === "write") {
103
+ const args2 = tc.arguments;
104
+ if (args2?.path) {
105
+ return latestWrite.get(args2.path) === i;
106
+ }
107
+ }
108
+ return true;
109
+ });
110
+ if (filteredCalls.length > 0) {
111
+ result.push({ ...msg, tool_calls: filteredCalls });
112
+ }
113
+ }
114
+ return result;
115
+ }
116
+ function purgeErrors(messages) {
117
+ return messages.filter((msg) => {
118
+ if (msg.role !== "tool")
119
+ return true;
120
+ const content = typeof msg.content === "string" ? msg.content : "";
121
+ if (content.includes("Error:") || content.includes("error:") || content.includes("Failed:") || content.includes("failed:")) {
122
+ return false;
123
+ }
124
+ if (!content.trim() || content === "undefined" || content === "null") {
125
+ return false;
126
+ }
127
+ return true;
128
+ });
129
+ }
130
+ function truncateLongOutputs(messages, maxLength = 2000) {
131
+ return messages.map((msg) => {
132
+ if (msg.role !== "tool")
133
+ return msg;
134
+ const content = typeof msg.content === "string" ? msg.content : "";
135
+ if (content.length > maxLength) {
136
+ const kept = content.slice(0, maxLength / 2) + `
137
+
138
+ [... ` + (content.length - maxLength) + ` bytes truncated ...]
139
+
140
+ ` + content.slice(-maxLength / 2);
141
+ return { ...msg, content: kept };
142
+ }
143
+ return msg;
144
+ });
145
+ }
146
+ function trimOldToolCalls(messages, maxToolCalls) {
147
+ let toolCallCount = 0;
148
+ return messages.filter((msg) => {
149
+ if (msg.role !== "assistant" || !msg.tool_calls?.length) {
150
+ return true;
151
+ }
152
+ const msgToolCount = msg.tool_calls.length;
153
+ if (toolCallCount + msgToolCount <= maxToolCalls) {
154
+ toolCallCount += msgToolCount;
155
+ return true;
156
+ }
157
+ const remaining = maxToolCalls - toolCallCount;
158
+ if (remaining > 0) {
159
+ toolCallCount = maxToolCalls;
160
+ return {
161
+ ...msg,
162
+ tool_calls: msg.tool_calls.slice(-remaining)
163
+ };
164
+ }
165
+ return false;
166
+ });
167
+ }
168
+ function compressContext(messages, config2 = DEFAULT_CONFIG, contextLimit = 200000) {
169
+ const cfg = { ...DEFAULT_CONFIG, ...config2 };
170
+ const startTokens = estimateTokens(messages);
171
+ let compressed = [...messages];
172
+ compressed = purgeErrors(compressed);
173
+ compressed = deduplicateToolCalls(compressed);
174
+ compressed = removeSupersededWrites(compressed);
175
+ compressed = truncateLongOutputs(compressed, 3000);
176
+ compressed = trimOldToolCalls(compressed, cfg.maxToolCalls);
177
+ const endTokens = estimateTokens(compressed);
178
+ return {
179
+ compressed,
180
+ stats: {
181
+ originalTokens: startTokens,
182
+ compressedTokens: endTokens,
183
+ reductionRatio: startTokens > 0 ? (startTokens - endTokens) / startTokens : 0,
184
+ originalMessages: messages.length,
185
+ compressedMessages: compressed.length
186
+ }
187
+ };
188
+ }
189
+ function buildCompressionHint() {
190
+ return `
191
+ ## Context Compression Active
192
+
193
+ The conversation has been compressed to fit within the context window.
194
+ - Previous tool calls may have been deduplicated or truncated
195
+ - Only the most recent and relevant information is retained
196
+ - Focus on continuing from the current state rather than redoing completed work
197
+
198
+ If you need context from earlier in the conversation, you can:
199
+ - Ask the user to provide relevant context
200
+ - Use hive_context_write to check for saved context
201
+ - Use hive_plan_read to review the current plan
202
+ `;
203
+ }
204
+ function createCompactionHook(config2 = DEFAULT_CONFIG) {
205
+ const cfg = { ...DEFAULT_CONFIG, ...config2 };
206
+ return function compactionHook(input, output) {
207
+ const messages = input.messages || [];
208
+ const contextLimit = input.contextLimit || 200000;
209
+ if (!needsCompression(messages, contextLimit, cfg)) {
210
+ return;
211
+ }
212
+ const { compressed, stats } = compressContext(messages, cfg, contextLimit);
213
+ output.context.push(buildCompressionHint());
214
+ console.log(`[hive:compaction] Compressed context: ${stats.originalTokens} → ${stats.compressedTokens} tokens (${Math.round(stats.reductionRatio * 100)}% reduction)`);
215
+ };
216
+ }
217
+ var DEFAULT_CONFIG;
218
+ var init_context_compression = __esm(() => {
219
+ DEFAULT_CONFIG = {
220
+ threshold: 0.5,
221
+ enabled: true,
222
+ protectedTools: [
223
+ "hive_feature_create",
224
+ "hive_plan_write",
225
+ "hive_worktree_commit",
226
+ "hive_merge"
227
+ ],
228
+ protectUserMessages: true,
229
+ maxToolCalls: 50
230
+ };
231
+ });
232
+
18
233
  // src/index.ts
19
234
  import * as path8 from "path";
20
235
  import * as os from "os";
@@ -1150,8 +1365,8 @@ function getLengthableOrigin(input) {
1150
1365
  return "string";
1151
1366
  return "unknown";
1152
1367
  }
1153
- function issue(...args) {
1154
- const [iss, input, inst] = args;
1368
+ function issue(...args2) {
1369
+ const [iss, input, inst] = args2;
1155
1370
  if (typeof iss === "string") {
1156
1371
  return {
1157
1372
  message: iss,
@@ -1538,20 +1753,20 @@ var domain = /^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
1538
1753
  var e164 = /^\+(?:[0-9]){6,14}[0-9]$/;
1539
1754
  var dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
1540
1755
  var date = /* @__PURE__ */ new RegExp(`^${dateSource}$`);
1541
- function timeSource(args) {
1756
+ function timeSource(args2) {
1542
1757
  const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
1543
- const regex = typeof args.precision === "number" ? args.precision === -1 ? `${hhmm}` : args.precision === 0 ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}` : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
1758
+ const regex = typeof args2.precision === "number" ? args2.precision === -1 ? `${hhmm}` : args2.precision === 0 ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args2.precision}}` : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
1544
1759
  return regex;
1545
1760
  }
1546
- function time(args) {
1547
- return new RegExp(`^${timeSource(args)}$`);
1761
+ function time(args2) {
1762
+ return new RegExp(`^${timeSource(args2)}$`);
1548
1763
  }
1549
- function datetime(args) {
1550
- const time2 = timeSource({ precision: args.precision });
1764
+ function datetime(args2) {
1765
+ const time2 = timeSource({ precision: args2.precision });
1551
1766
  const opts = ["Z"];
1552
- if (args.local)
1767
+ if (args2.local)
1553
1768
  opts.push("");
1554
- if (args.offset)
1769
+ if (args2.offset)
1555
1770
  opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
1556
1771
  const timeRegex = `${time2}(?:${opts.join("|")})`;
1557
1772
  return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
@@ -2134,11 +2349,11 @@ var $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (ins
2134
2349
 
2135
2350
  // ../../node_modules/.bun/zod@4.1.8/node_modules/zod/v4/core/doc.js
2136
2351
  class Doc {
2137
- constructor(args = []) {
2352
+ constructor(args2 = []) {
2138
2353
  this.content = [];
2139
2354
  this.indent = 0;
2140
2355
  if (this)
2141
- this.args = args;
2356
+ this.args = args2;
2142
2357
  }
2143
2358
  indented(fn) {
2144
2359
  this.indent += 1;
@@ -2162,10 +2377,10 @@ class Doc {
2162
2377
  }
2163
2378
  compile() {
2164
2379
  const F = Function;
2165
- const args = this?.args;
2380
+ const args2 = this?.args;
2166
2381
  const content = this?.content ?? [``];
2167
2382
  const lines = [...content.map((x) => ` ${x}`)];
2168
- return new F(...args, lines.join(`
2383
+ return new F(...args2, lines.join(`
2169
2384
  `));
2170
2385
  }
2171
2386
  }
@@ -2948,24 +3163,24 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
2948
3163
  }
2949
3164
  doc.write(`const newResult = {};`);
2950
3165
  for (const key of normalized.keys) {
2951
- const id = ids[key];
3166
+ const id2 = ids[key];
2952
3167
  const k = esc(key);
2953
- doc.write(`const ${id} = ${parseStr(key)};`);
3168
+ doc.write(`const ${id2} = ${parseStr(key)};`);
2954
3169
  doc.write(`
2955
- if (${id}.issues.length) {
2956
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
3170
+ if (${id2}.issues.length) {
3171
+ payload.issues = payload.issues.concat(${id2}.issues.map(iss => ({
2957
3172
  ...iss,
2958
3173
  path: iss.path ? [${k}, ...iss.path] : [${k}]
2959
3174
  })));
2960
3175
  }
2961
3176
 
2962
3177
 
2963
- if (${id}.value === undefined) {
3178
+ if (${id2}.value === undefined) {
2964
3179
  if (${k} in input) {
2965
3180
  newResult[${k}] = undefined;
2966
3181
  }
2967
3182
  } else {
2968
- newResult[${k}] = ${id}.value;
3183
+ newResult[${k}] = ${id2}.value;
2969
3184
  }
2970
3185
 
2971
3186
  `);
@@ -3883,8 +4098,8 @@ var $ZodFunction = /* @__PURE__ */ $constructor("$ZodFunction", (inst, def) => {
3883
4098
  if (typeof func !== "function") {
3884
4099
  throw new Error("implement() must be called with a function");
3885
4100
  }
3886
- return function(...args) {
3887
- const parsedArgs = inst._def.input ? parse(inst._def.input, args) : args;
4101
+ return function(...args2) {
4102
+ const parsedArgs = inst._def.input ? parse(inst._def.input, args2) : args2;
3888
4103
  const result = Reflect.apply(func, this, parsedArgs);
3889
4104
  if (inst._def.output) {
3890
4105
  return parse(inst._def.output, result);
@@ -3896,8 +4111,8 @@ var $ZodFunction = /* @__PURE__ */ $constructor("$ZodFunction", (inst, def) => {
3896
4111
  if (typeof func !== "function") {
3897
4112
  throw new Error("implementAsync() must be called with a function");
3898
4113
  }
3899
- return async function(...args) {
3900
- const parsedArgs = inst._def.input ? await parseAsync(inst._def.input, args) : args;
4114
+ return async function(...args2) {
4115
+ const parsedArgs = inst._def.input ? await parseAsync(inst._def.input, args2) : args2;
3901
4116
  const result = await Reflect.apply(func, this, parsedArgs);
3902
4117
  if (inst._def.output) {
3903
4118
  return await parseAsync(inst._def.output, result);
@@ -3923,22 +4138,22 @@ var $ZodFunction = /* @__PURE__ */ $constructor("$ZodFunction", (inst, def) => {
3923
4138
  }
3924
4139
  return payload;
3925
4140
  };
3926
- inst.input = (...args) => {
4141
+ inst.input = (...args2) => {
3927
4142
  const F = inst.constructor;
3928
- if (Array.isArray(args[0])) {
4143
+ if (Array.isArray(args2[0])) {
3929
4144
  return new F({
3930
4145
  type: "function",
3931
4146
  input: new $ZodTuple({
3932
4147
  type: "tuple",
3933
- items: args[0],
3934
- rest: args[1]
4148
+ items: args2[0],
4149
+ rest: args2[1]
3935
4150
  }),
3936
4151
  output: inst._def.output
3937
4152
  });
3938
4153
  }
3939
4154
  return new F({
3940
4155
  type: "function",
3941
- input: args[0],
4156
+ input: args2[0],
3942
4157
  output: inst._def.output
3943
4158
  });
3944
4159
  };
@@ -10945,13 +11160,13 @@ class JSONSchemaGenerator {
10945
11160
  const defsSegment = this.target === "draft-2020-12" ? "$defs" : "definitions";
10946
11161
  if (params.external) {
10947
11162
  const externalId = params.external.registry.get(entry[0])?.id;
10948
- const uriGenerator = params.external.uri ?? ((id2) => id2);
11163
+ const uriGenerator = params.external.uri ?? ((id3) => id3);
10949
11164
  if (externalId) {
10950
11165
  return { ref: uriGenerator(externalId) };
10951
11166
  }
10952
- const id = entry[1].defId ?? entry[1].schema.id ?? `schema${this.counter++}`;
10953
- entry[1].defId = id;
10954
- return { defId: id, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}` };
11167
+ const id2 = entry[1].defId ?? entry[1].schema.id ?? `schema${this.counter++}`;
11168
+ entry[1].defId = id2;
11169
+ return { defId: id2, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id2}` };
10955
11170
  }
10956
11171
  if (entry[1] === root) {
10957
11172
  return { ref: "#" };
@@ -10997,8 +11212,8 @@ class JSONSchemaGenerator {
10997
11212
  continue;
10998
11213
  }
10999
11214
  }
11000
- const id = this.metadataRegistry.get(entry[0])?.id;
11001
- if (id) {
11215
+ const id2 = this.metadataRegistry.get(entry[0])?.id;
11216
+ if (id2) {
11002
11217
  extractToDef(entry);
11003
11218
  continue;
11004
11219
  }
@@ -11054,10 +11269,10 @@ class JSONSchemaGenerator {
11054
11269
  console.warn(`Invalid target: ${this.target}`);
11055
11270
  }
11056
11271
  if (params.external?.uri) {
11057
- const id = params.external.registry.get(schema)?.id;
11058
- if (!id)
11272
+ const id2 = params.external.registry.get(schema)?.id;
11273
+ if (!id2)
11059
11274
  throw new Error("Schema is missing an `id` property");
11060
- result.$id = params.external.uri(id);
11275
+ result.$id = params.external.uri(id2);
11061
11276
  }
11062
11277
  Object.assign(result, root.def);
11063
11278
  const defs = params.external?.defs ?? {};
@@ -11369,12 +11584,12 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
11369
11584
  },
11370
11585
  configurable: true
11371
11586
  });
11372
- inst.meta = (...args) => {
11373
- if (args.length === 0) {
11587
+ inst.meta = (...args2) => {
11588
+ if (args2.length === 0) {
11374
11589
  return globalRegistry.get(inst);
11375
11590
  }
11376
11591
  const cl = inst.clone();
11377
- globalRegistry.add(cl, args[0]);
11592
+ globalRegistry.add(cl, args2[0]);
11378
11593
  return cl;
11379
11594
  };
11380
11595
  inst.isOptional = () => inst.safeParse(undefined).success;
@@ -11388,18 +11603,18 @@ var _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
11388
11603
  inst.format = bag.format ?? null;
11389
11604
  inst.minLength = bag.minimum ?? null;
11390
11605
  inst.maxLength = bag.maximum ?? null;
11391
- inst.regex = (...args) => inst.check(_regex(...args));
11392
- inst.includes = (...args) => inst.check(_includes(...args));
11393
- inst.startsWith = (...args) => inst.check(_startsWith(...args));
11394
- inst.endsWith = (...args) => inst.check(_endsWith(...args));
11395
- inst.min = (...args) => inst.check(_minLength(...args));
11396
- inst.max = (...args) => inst.check(_maxLength(...args));
11397
- inst.length = (...args) => inst.check(_length(...args));
11398
- inst.nonempty = (...args) => inst.check(_minLength(1, ...args));
11606
+ inst.regex = (...args2) => inst.check(_regex(...args2));
11607
+ inst.includes = (...args2) => inst.check(_includes(...args2));
11608
+ inst.startsWith = (...args2) => inst.check(_startsWith(...args2));
11609
+ inst.endsWith = (...args2) => inst.check(_endsWith(...args2));
11610
+ inst.min = (...args2) => inst.check(_minLength(...args2));
11611
+ inst.max = (...args2) => inst.check(_maxLength(...args2));
11612
+ inst.length = (...args2) => inst.check(_length(...args2));
11613
+ inst.nonempty = (...args2) => inst.check(_minLength(1, ...args2));
11399
11614
  inst.lowercase = (params) => inst.check(_lowercase(params));
11400
11615
  inst.uppercase = (params) => inst.check(_uppercase(params));
11401
11616
  inst.trim = () => inst.check(_trim());
11402
- inst.normalize = (...args) => inst.check(_normalize(...args));
11617
+ inst.normalize = (...args2) => inst.check(_normalize(...args2));
11403
11618
  inst.toLowerCase = () => inst.check(_toLowerCase());
11404
11619
  inst.toUpperCase = () => inst.check(_toUpperCase());
11405
11620
  });
@@ -11796,8 +12011,8 @@ var ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
11796
12011
  inst.merge = (other) => exports_util.merge(inst, other);
11797
12012
  inst.pick = (mask) => exports_util.pick(inst, mask);
11798
12013
  inst.omit = (mask) => exports_util.omit(inst, mask);
11799
- inst.partial = (...args) => exports_util.partial(ZodOptional, inst, args[0]);
11800
- inst.required = (...args) => exports_util.required(ZodNonOptional, inst, args[0]);
12014
+ inst.partial = (...args2) => exports_util.partial(ZodOptional, inst, args2[0]);
12015
+ inst.required = (...args2) => exports_util.required(ZodNonOptional, inst, args2[0]);
11801
12016
  });
11802
12017
  function object(shape, params) {
11803
12018
  const def = {
@@ -11927,10 +12142,10 @@ function map(keyType, valueType, params) {
11927
12142
  var ZodSet = /* @__PURE__ */ $constructor("ZodSet", (inst, def) => {
11928
12143
  $ZodSet.init(inst, def);
11929
12144
  ZodType.init(inst, def);
11930
- inst.min = (...args) => inst.check(_minSize(...args));
12145
+ inst.min = (...args2) => inst.check(_minSize(...args2));
11931
12146
  inst.nonempty = (params) => inst.check(_minSize(1, params));
11932
- inst.max = (...args) => inst.check(_maxSize(...args));
11933
- inst.size = (...args) => inst.check(_size(...args));
12147
+ inst.max = (...args2) => inst.check(_maxSize(...args2));
12148
+ inst.size = (...args2) => inst.check(_size(...args2));
11934
12149
  });
11935
12150
  function set(valueType, params) {
11936
12151
  return new ZodSet({
@@ -12269,11 +12484,11 @@ function _instanceof(cls, params = {
12269
12484
  inst._zod.bag.Class = cls;
12270
12485
  return inst;
12271
12486
  }
12272
- var stringbool = (...args) => _stringbool({
12487
+ var stringbool = (...args2) => _stringbool({
12273
12488
  Codec: ZodCodec,
12274
12489
  Boolean: ZodBoolean,
12275
12490
  String: ZodString
12276
- }, ...args);
12491
+ }, ...args2);
12277
12492
  function json(params) {
12278
12493
  const jsonSchema = lazy(() => {
12279
12494
  return union([string2(params), number2(), boolean2(), _null3(), array(jsonSchema), record(string2(), jsonSchema)]);
@@ -12340,7 +12555,7 @@ function tool(input) {
12340
12555
  }
12341
12556
  tool.schema = exports_external;
12342
12557
  // src/skills/registry.generated.ts
12343
- var BUILTIN_SKILL_NAMES = ["agents-md-mastery", "brainstorming", "code-reviewer", "dispatching-parallel-agents", "docker-mastery", "executing-plans", "parallel-exploration", "systematic-debugging", "test-driven-development", "verification-before-completion", "writing-plans"];
12558
+ var BUILTIN_SKILL_NAMES = ["agents-md-mastery", "ask-questions-if-underspecified", "brainstorming", "code-reviewer", "dispatching-parallel-agents", "docker-mastery", "executing-plans", "parallel-exploration", "systematic-debugging", "test-driven-development", "verification-before-completion", "writing-plans"];
12344
12559
  var BUILTIN_SKILLS = [
12345
12560
  {
12346
12561
  name: "agents-md-mastery",
@@ -12592,6 +12807,58 @@ AGENTS.md is **behavioral memory**, not documentation:
12592
12807
  - Test: Would agent make a mistake without this entry?
12593
12808
 
12594
12809
  **Quality > quantity. Every line counts.**`
12810
+ },
12811
+ {
12812
+ name: "ask-questions-if-underspecified",
12813
+ description: "Clarify requirements before implementing. Use when serious doubts arise.",
12814
+ template: `# Ask Questions If Underspecified
12815
+
12816
+ ## Goal
12817
+
12818
+ Ask the minimum set of clarifying questions needed to avoid wrong work; do not start implementing until the must-have questions are answered (or the user explicitly approves proceeding with stated assumptions).
12819
+
12820
+ ## Workflow
12821
+
12822
+ ### 1) Decide whether the request is underspecified
12823
+
12824
+ Treat a request as underspecified if after exploring how to perform the work, some or all of the following are not clear:
12825
+ - Define the objective (what should change vs stay the same)
12826
+ - Define "done" (acceptance criteria, examples, edge cases)
12827
+ - Define scope (which files/components/users are in/out)
12828
+ - Define constraints (compatibility, performance, style, deps, time)
12829
+ - Identify environment (language/runtime versions, OS, build/test runner)
12830
+ - Clarify safety/reversibility (data migration, rollout/rollback, risk)
12831
+
12832
+ If multiple plausible interpretations exist, assume it is underspecified.
12833
+
12834
+ ### 2) Ask must-have questions first (keep it small)
12835
+
12836
+ Ask 1-5 questions in the first pass. Prefer questions that eliminate whole branches of work.
12837
+
12838
+ Use the \`question\` tool to present structured choices:
12839
+ - Offer multiple-choice options with clear labels
12840
+ - Mark recommended defaults with "(Recommended)" in the label
12841
+ - Use \`multiple: true\` when the user can select several options
12842
+ - The user can always select "Other" for custom input
12843
+
12844
+ ### 3) Pause before acting
12845
+
12846
+ Until must-have answers arrive:
12847
+ - Do not run commands, edit files, or produce a detailed plan that depends on unknowns
12848
+ - Do perform a clearly labeled, low-risk discovery step only if it does not commit you to a direction (e.g., inspect repo structure, read relevant config files)
12849
+
12850
+ If the user explicitly asks you to proceed without answers:
12851
+ - State your assumptions as a short numbered list
12852
+ - Ask for confirmation; proceed only after they confirm or correct them
12853
+
12854
+ ### 4) Confirm interpretation, then proceed
12855
+
12856
+ Once you have answers, restate the requirements in 1-3 sentences (including key constraints and what success looks like), then start work.
12857
+
12858
+ ## Anti-patterns
12859
+
12860
+ - Don't ask questions you can answer with a quick, low-risk discovery read (e.g., configs, existing patterns, docs).
12861
+ - Don't ask open-ended questions if a tight multiple-choice or yes/no would eliminate ambiguity faster.`
12595
12862
  },
12596
12863
  {
12597
12864
  name: "brainstorming",
@@ -14804,8 +15071,527 @@ async function loadFileSkill(skillId, projectRoot, homeDir) {
14804
15071
  };
14805
15072
  }
14806
15073
 
15074
+ // src/tools/gitingest.ts
15075
+ async function fetchGitingest(args2) {
15076
+ const response = await fetch("https://gitingest.com/api/ingest", {
15077
+ method: "POST",
15078
+ headers: { "Content-Type": "application/json" },
15079
+ body: JSON.stringify({
15080
+ input_text: args2.url,
15081
+ max_file_size: args2.maxFileSize ?? 50000,
15082
+ pattern: args2.pattern ?? "",
15083
+ pattern_type: args2.patternType ?? "exclude"
15084
+ })
15085
+ });
15086
+ if (!response.ok) {
15087
+ throw new Error(`gitingest API error: ${response.status} ${response.statusText}`);
15088
+ }
15089
+ const data = await response.json();
15090
+ return `${data.summary}
15091
+
15092
+ ${data.tree}
15093
+
15094
+ ${data.content}`;
15095
+ }
15096
+ var gitingestTool = tool({
15097
+ description: "Fetch a GitHub repository's full content via gitingest.com. Returns summary, directory tree, and file contents optimized for LLM analysis. Use when you need to understand an external repository's structure or code.",
15098
+ args: {
15099
+ url: tool.schema.string().describe("GitHub repository URL (e.g., https://github.com/owner/repo)"),
15100
+ maxFileSize: tool.schema.number().optional().describe("Maximum file size in bytes to include (default: 50000)"),
15101
+ pattern: tool.schema.string().optional().describe("Glob pattern to filter files (e.g., '*.py' or 'src/*')"),
15102
+ patternType: tool.schema.enum(["include", "exclude"]).optional().describe("Whether pattern includes or excludes matching files (default: exclude)")
15103
+ },
15104
+ async execute(args2, _context) {
15105
+ return fetchGitingest(args2);
15106
+ }
15107
+ });
15108
+
15109
+ // src/tools/look-at.ts
15110
+ import { readFileSync, statSync } from "node:fs";
15111
+ import { basename, extname } from "node:path";
15112
+ var BYTES_PER_KB = 1024;
15113
+ var LARGE_FILE_THRESHOLD_KB = 100;
15114
+ var LARGE_FILE_THRESHOLD = LARGE_FILE_THRESHOLD_KB * BYTES_PER_KB;
15115
+ var MAX_LINES_WITHOUT_EXTRACT = 200;
15116
+ var MAX_SIGNATURE_LENGTH = 80;
15117
+ var MAX_JSON_KEYS_SHOWN = 50;
15118
+ var MAX_PREVIEW_LINES = 10;
15119
+ var TAIL_PREVIEW_LINES = -5;
15120
+ var STRUCTURE_HEADING = `## Structure
15121
+ `;
15122
+ var EXTRACTABLE_EXTENSIONS = [
15123
+ ".ts",
15124
+ ".tsx",
15125
+ ".js",
15126
+ ".jsx",
15127
+ ".py",
15128
+ ".go",
15129
+ ".rs",
15130
+ ".java",
15131
+ ".md",
15132
+ ".json",
15133
+ ".yaml",
15134
+ ".yml"
15135
+ ];
15136
+ function extractStructure(content, ext) {
15137
+ const lines = content.split(`
15138
+ `);
15139
+ switch (ext) {
15140
+ case ".ts":
15141
+ case ".tsx":
15142
+ case ".js":
15143
+ case ".jsx":
15144
+ return extractTypeScriptStructure(lines);
15145
+ case ".py":
15146
+ return extractPythonStructure(lines);
15147
+ case ".go":
15148
+ return extractGoStructure(lines);
15149
+ case ".md":
15150
+ return extractMarkdownStructure(lines);
15151
+ case ".json":
15152
+ return extractJsonStructure(content);
15153
+ case ".yaml":
15154
+ case ".yml":
15155
+ return extractYamlStructure(lines);
15156
+ default:
15157
+ return extractGenericStructure(lines);
15158
+ }
15159
+ }
15160
+ function extractTypeScriptStructure(lines) {
15161
+ const output = [STRUCTURE_HEADING];
15162
+ for (let i = 0;i < lines.length; i++) {
15163
+ const line = lines[i];
15164
+ const trimmed = line.trim();
15165
+ if (trimmed.startsWith("export ") || trimmed.startsWith("class ") || trimmed.startsWith("interface ") || trimmed.startsWith("type ") || trimmed.startsWith("function ") || trimmed.startsWith("const ") || trimmed.startsWith("async function ")) {
15166
+ const signature = trimmed.length > MAX_SIGNATURE_LENGTH ? `${trimmed.slice(0, MAX_SIGNATURE_LENGTH)}...` : trimmed;
15167
+ output.push(`Line ${i + 1}: ${signature}`);
15168
+ }
15169
+ }
15170
+ return output.join(`
15171
+ `);
15172
+ }
15173
+ function extractPythonStructure(lines) {
15174
+ const output = [STRUCTURE_HEADING];
15175
+ for (let i = 0;i < lines.length; i++) {
15176
+ const line = lines[i];
15177
+ const trimmed = line.trim();
15178
+ if (trimmed.startsWith("class ") || trimmed.startsWith("def ") || trimmed.startsWith("async def ") || trimmed.startsWith("@")) {
15179
+ const signature = trimmed.length > MAX_SIGNATURE_LENGTH ? `${trimmed.slice(0, MAX_SIGNATURE_LENGTH)}...` : trimmed;
15180
+ output.push(`Line ${i + 1}: ${signature}`);
15181
+ }
15182
+ }
15183
+ return output.join(`
15184
+ `);
15185
+ }
15186
+ function extractGoStructure(lines) {
15187
+ const output = [STRUCTURE_HEADING];
15188
+ for (let i = 0;i < lines.length; i++) {
15189
+ const line = lines[i];
15190
+ const trimmed = line.trim();
15191
+ if (trimmed.startsWith("type ") || trimmed.startsWith("func ") || trimmed.startsWith("package ")) {
15192
+ const signature = trimmed.length > MAX_SIGNATURE_LENGTH ? `${trimmed.slice(0, MAX_SIGNATURE_LENGTH)}...` : trimmed;
15193
+ output.push(`Line ${i + 1}: ${signature}`);
15194
+ }
15195
+ }
15196
+ return output.join(`
15197
+ `);
15198
+ }
15199
+ function extractMarkdownStructure(lines) {
15200
+ const output = [`## Outline
15201
+ `];
15202
+ for (let i = 0;i < lines.length; i++) {
15203
+ const line = lines[i];
15204
+ if (line.startsWith("#")) {
15205
+ output.push(`Line ${i + 1}: ${line}`);
15206
+ }
15207
+ }
15208
+ return output.join(`
15209
+ `);
15210
+ }
15211
+ function extractJsonStructure(content) {
15212
+ try {
15213
+ const obj = JSON.parse(content);
15214
+ if (typeof obj !== "object" || obj === null || Array.isArray(obj)) {
15215
+ return "## JSON (non-object top-level value)";
15216
+ }
15217
+ const keys = Object.keys(obj);
15218
+ return `## Top-level keys (${keys.length})
15219
+
15220
+ ${keys.slice(0, MAX_JSON_KEYS_SHOWN).join(", ")}${keys.length > MAX_JSON_KEYS_SHOWN ? "..." : ""}`;
15221
+ } catch {
15222
+ return "## Invalid JSON";
15223
+ }
15224
+ }
15225
+ function extractYamlStructure(lines) {
15226
+ const output = [`## Top-level keys
15227
+ `];
15228
+ for (let i = 0;i < lines.length; i++) {
15229
+ const line = lines[i];
15230
+ if (line.match(/^[a-zA-Z_][a-zA-Z0-9_]*:/)) {
15231
+ output.push(`Line ${i + 1}: ${line}`);
15232
+ }
15233
+ }
15234
+ return output.join(`
15235
+ `);
15236
+ }
15237
+ function extractGenericStructure(lines) {
15238
+ const total = lines.length;
15239
+ const preview = lines.slice(0, MAX_PREVIEW_LINES).join(`
15240
+ `);
15241
+ const tail = lines.slice(TAIL_PREVIEW_LINES).join(`
15242
+ `);
15243
+ return `## File Preview (${total} lines)
15244
+
15245
+ ### First ${MAX_PREVIEW_LINES} lines:
15246
+ ${preview}
15247
+
15248
+ ### Last ${-TAIL_PREVIEW_LINES} lines:
15249
+ ${tail}`;
15250
+ }
15251
+ var lookAtTool = tool({
15252
+ description: `Extract key information from a file to save context tokens.
15253
+ For large files, returns structure/outline instead of full content.
15254
+ Use when you need to understand a file without loading all content.
15255
+ Ideal for: large files, getting file structure, quick overview.`,
15256
+ args: {
15257
+ filePath: tool.schema.string().describe("Path to the file"),
15258
+ extract: tool.schema.string().optional().describe("What to extract: 'structure', 'imports', 'exports', 'all' (default: auto)")
15259
+ },
15260
+ execute: async (args2) => {
15261
+ try {
15262
+ const stats = statSync(args2.filePath);
15263
+ const ext = extname(args2.filePath).toLowerCase();
15264
+ const name = basename(args2.filePath);
15265
+ const content = readFileSync(args2.filePath, "utf-8");
15266
+ const lines = content.split(`
15267
+ `);
15268
+ if (stats.size < LARGE_FILE_THRESHOLD && lines.length <= MAX_LINES_WITHOUT_EXTRACT) {
15269
+ return `## ${name} (${lines.length} lines)
15270
+
15271
+ ${content}`;
15272
+ }
15273
+ let output = `## ${name}
15274
+ `;
15275
+ output += `**Size**: ${Math.round(stats.size / BYTES_PER_KB)}KB | **Lines**: ${lines.length}
15276
+
15277
+ `;
15278
+ if (EXTRACTABLE_EXTENSIONS.includes(ext)) {
15279
+ output += extractStructure(content, ext);
15280
+ } else {
15281
+ output += extractGenericStructure(lines);
15282
+ }
15283
+ output += `
15284
+
15285
+ ---
15286
+ *Use Read tool with line offset/limit for specific sections*`;
15287
+ return output;
15288
+ } catch (e) {
15289
+ return `Error: ${e instanceof Error ? e.message : String(e)}`;
15290
+ }
15291
+ }
15292
+ });
15293
+
15294
+ // src/tools/artifact-search.ts
15295
+ async function searchArtifacts(args2) {
15296
+ try {
15297
+ const { spawn } = await import("child_process");
15298
+ return new Promise((resolve, reject) => {
15299
+ const limit = args2.limit ?? 10;
15300
+ const typeFilter = args2.type ?? "all";
15301
+ const proc = spawn("artifact-index", ["search", "--query", args2.query, "--limit", String(limit), "--type", typeFilter], {
15302
+ stdio: ["pipe", "pipe", "pipe"]
15303
+ });
15304
+ let stdout = "";
15305
+ let stderr = "";
15306
+ proc.stdout?.on("data", (data) => {
15307
+ stdout += data.toString();
15308
+ });
15309
+ proc.stderr?.on("data", (data) => {
15310
+ stderr += data.toString();
15311
+ });
15312
+ proc.on("close", (code) => {
15313
+ if (code === 0) {
15314
+ resolve(stdout || "No artifacts found matching your query.");
15315
+ } else {
15316
+ reject(new Error(`artifact-index exited with code ${code}: ${stderr}`));
15317
+ }
15318
+ });
15319
+ proc.on("error", (err) => {
15320
+ reject(err);
15321
+ });
15322
+ setTimeout(() => {
15323
+ proc.kill();
15324
+ reject(new Error("artifact-index search timed out"));
15325
+ }, 30000);
15326
+ });
15327
+ } catch (error45) {
15328
+ if (error45 instanceof Error && error45.message.includes("not found")) {
15329
+ return `artifact_search requires artifact-index to be installed:
15330
+
15331
+ 1. Install artifact-index CLI:
15332
+ npm install -g artifact-index
15333
+
15334
+ 2. Initialize the database:
15335
+ artifact-index init
15336
+
15337
+ 3. Index your artifacts:
15338
+ artifact-index add /path/to/your/code
15339
+
15340
+ 4. Then search using this tool with your query.
15341
+
15342
+ Note: This tool requires the artifact-index npm package to be installed globally.`;
15343
+ }
15344
+ throw error45;
15345
+ }
15346
+ }
15347
+ var artifactSearchTool = tool({
15348
+ description: "Search through indexed artifacts (code snippets, documents) stored in SQLite. Requires artifact-index npm package to be installed. Use for finding previously indexed code or documentation.",
15349
+ args: {
15350
+ query: tool.schema.string().describe("Search query for artifacts"),
15351
+ limit: tool.schema.number().optional().describe("Maximum number of results to return (default: 10)"),
15352
+ type: tool.schema.enum(["code", "doc", "all"]).optional().describe("Filter by type: code, doc, or all (default: all)")
15353
+ },
15354
+ async execute(args2, _context) {
15355
+ return searchArtifacts(args2);
15356
+ }
15357
+ });
15358
+
15359
+ // src/tools/btca-ask.ts
15360
+ async function btcaAsk(args2) {
15361
+ try {
15362
+ const { spawn } = await import("child_process");
15363
+ return new Promise((resolve, reject) => {
15364
+ const cmdArgs = [args2.command];
15365
+ if (args2.device && ["connect", "disconnect"].includes(args2.command)) {
15366
+ cmdArgs.push(args2.device);
15367
+ }
15368
+ if (args2.value && args2.command === "volume") {
15369
+ cmdArgs.push(args2.value);
15370
+ }
15371
+ const proc = spawn("btca", cmdArgs, {
15372
+ stdio: ["pipe", "pipe", "pipe"]
15373
+ });
15374
+ let stdout = "";
15375
+ let stderr = "";
15376
+ proc.stdout?.on("data", (data) => {
15377
+ stdout += data.toString();
15378
+ });
15379
+ proc.stderr?.on("data", (data) => {
15380
+ stderr += data.toString();
15381
+ });
15382
+ proc.on("close", (code) => {
15383
+ if (code === 0) {
15384
+ resolve(stdout || `Command ${args2.command} executed successfully.`);
15385
+ } else {
15386
+ reject(new Error(`btca exited with code ${code}: ${stderr}`));
15387
+ }
15388
+ });
15389
+ proc.on("error", (err) => {
15390
+ reject(err);
15391
+ });
15392
+ setTimeout(() => {
15393
+ proc.kill();
15394
+ reject(new Error("btca command timed out"));
15395
+ }, 1e4);
15396
+ });
15397
+ } catch (error45) {
15398
+ if (error45 instanceof Error && error45.message.includes("not found")) {
15399
+ return `btca_ask requires btca CLI to be installed:
15400
+
15401
+ 1. Install btca CLI:
15402
+ npm install -g btca-cli
15403
+
15404
+ 2. Make sure Bluetooth is enabled on your system
15405
+
15406
+ 3. Pair your Bluetooth audio device:
15407
+ btca pair
15408
+
15409
+ 4. List available devices:
15410
+ btca list
15411
+
15412
+ 5. Connect to a device:
15413
+ btca connect <device-name>
15414
+
15415
+ 6. Then use this tool to control playback.
15416
+
15417
+ Note: This tool requires the btca-cli npm package and Bluetooth hardware.`;
15418
+ }
15419
+ throw error45;
15420
+ }
15421
+ }
15422
+ var btcaAskTool = tool({
15423
+ description: "Control Bluetooth Classic Audio devices. Requires btca-cli npm package. Use for playing/pausing music, controlling volume, and managing Bluetooth audio connections.",
15424
+ args: {
15425
+ command: tool.schema.enum(["status", "play", "pause", "next", "prev", "volume", "list", "connect", "disconnect"]).describe("Command to execute"),
15426
+ device: tool.schema.string().optional().describe("Device name (required for connect/disconnect commands)"),
15427
+ value: tool.schema.string().optional().describe("Value (e.g., volume level 0-100 for volume command)")
15428
+ },
15429
+ async execute(args2, _context) {
15430
+ return btcaAsk(args2);
15431
+ }
15432
+ });
15433
+
15434
+ // src/tools/pty.ts
15435
+ var ptySessions = new Map;
15436
+ async function startPty(args) {
15437
+ try {
15438
+ const bunPty = await eval('import("bun-pty")');
15439
+ const open = bunPty.open;
15440
+ const pty = open({
15441
+ command: args.command,
15442
+ cwd: args.cwd,
15443
+ env: args.env
15444
+ });
15445
+ const id = `pty-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
15446
+ ptySessions.set(id, {
15447
+ proc: pty,
15448
+ command: args.command,
15449
+ startedAt: new Date
15450
+ });
15451
+ pty.on("data", (data) => {
15452
+ console.log(`[${id}] ${data}`);
15453
+ });
15454
+ return `Started PTY session: ${id}
15455
+ Command: ${args.command}
15456
+ Working Directory: ${args.cwd ?? process.cwd()}
15457
+
15458
+ Use pty_read with id "${id}" to read output, pty_send to send input, and pty_kill to terminate.`;
15459
+ } catch (error45) {
15460
+ if (error45 instanceof Error && (error45.message.includes("not found") || error45.message.includes("MODULE_NOT_FOUND") || error45.message.includes("Cannot find module"))) {
15461
+ return `pty_start requires bun-pty to be installed:
15462
+
15463
+ Option 1 - Use opencode-pty plugin (recommended):
15464
+ Add "opencode-pty" to your plugins in opencode.json
15465
+
15466
+ Option 2 - Install bun-pty directly:
15467
+ npm install -g bun-pty
15468
+
15469
+ The PTY tools provide interactive terminal sessions for:
15470
+ - Running dev servers in background
15471
+ - Interactive programs (REPLs)
15472
+ - Long-running processes
15473
+ - Watch modes
15474
+
15475
+ Note: bun-pty may require native compilation which can fail on some systems.
15476
+ The opencode-pty plugin handles this more gracefully.`;
15477
+ }
15478
+ throw error45;
15479
+ }
15480
+ }
15481
+ async function sendToPty(args2) {
15482
+ const session = ptySessions.get(args2.id);
15483
+ if (!session) {
15484
+ return `No PTY session found with id: ${args2.id}. Use pty_list to see active sessions.`;
15485
+ }
15486
+ if (!session.proc) {
15487
+ return `PTY session ${args2.id} is not running.`;
15488
+ }
15489
+ try {
15490
+ session.proc.write(args2.input);
15491
+ return `Sent to ${args2.id}: ${args2.input}`;
15492
+ } catch (error45) {
15493
+ return `Failed to send input: ${error45 instanceof Error ? error45.message : String(error45)}`;
15494
+ }
15495
+ }
15496
+ async function readPty(args2) {
15497
+ const session = ptySessions.get(args2.id);
15498
+ if (!session) {
15499
+ return `No PTY session found with id: ${args2.id}. Use pty_list to see active sessions.`;
15500
+ }
15501
+ return `PTY Session: ${args2.id}
15502
+ Command: ${session.command}
15503
+ Started: ${session.startedAt.toISOString()}
15504
+ Status: ${session.proc ? "running" : "stopped"}
15505
+
15506
+ Note: Full output streaming requires bun-pty native module.`;
15507
+ }
15508
+ async function killPty(args2) {
15509
+ const session = ptySessions.get(args2.id);
15510
+ if (!session) {
15511
+ return `No PTY session found with id: ${args2.id}. Use pty_list to see active sessions.`;
15512
+ }
15513
+ try {
15514
+ if (session.proc) {
15515
+ session.proc.kill();
15516
+ }
15517
+ ptySessions.delete(args2.id);
15518
+ return `Killed PTY session: ${args2.id}`;
15519
+ } catch (error45) {
15520
+ ptySessions.delete(args2.id);
15521
+ return `Error killing PTY ${args2.id}: ${error45 instanceof Error ? error45.message : String(error45)}`;
15522
+ }
15523
+ }
15524
+ async function listPty(_args) {
15525
+ if (ptySessions.size === 0) {
15526
+ return "No active PTY sessions.";
15527
+ }
15528
+ let output = `Active PTY Sessions:
15529
+
15530
+ `;
15531
+ for (const [id2, session] of ptySessions) {
15532
+ output += `ID: ${id2}
15533
+ `;
15534
+ output += `Command: ${session.command}
15535
+ `;
15536
+ output += `Started: ${session.startedAt.toISOString()}
15537
+ `;
15538
+ output += `Status: ${session.proc ? "running" : "stopped"}
15539
+ `;
15540
+ output += `---
15541
+ `;
15542
+ }
15543
+ return output;
15544
+ }
15545
+ var ptyStartTool = tool({
15546
+ description: "Start a new PTY (pseudo-terminal) session for running interactive processes in background. Requires bun-pty or opencode-pty plugin.",
15547
+ args: {
15548
+ command: tool.schema.string().describe("Command to execute in the PTY"),
15549
+ cwd: tool.schema.string().optional().describe("Working directory for the command"),
15550
+ env: tool.schema.object({}).optional().describe("Environment variables for the command")
15551
+ },
15552
+ async execute(args2, _context) {
15553
+ return startPty(args2);
15554
+ }
15555
+ });
15556
+ var ptySendTool = tool({
15557
+ description: "Send input to a running PTY session.",
15558
+ args: {
15559
+ id: tool.schema.string().describe("PTY session ID"),
15560
+ input: tool.schema.string().describe("Input to send to the PTY")
15561
+ },
15562
+ async execute(args2, _context) {
15563
+ return sendToPty(args2);
15564
+ }
15565
+ });
15566
+ var ptyReadTool = tool({
15567
+ description: "Read output from a PTY session.",
15568
+ args: {
15569
+ id: tool.schema.string().describe("PTY session ID"),
15570
+ clear: tool.schema.boolean().optional().describe("Clear the output buffer after reading")
15571
+ },
15572
+ async execute(args2, _context) {
15573
+ return readPty(args2);
15574
+ }
15575
+ });
15576
+ var ptyKillTool = tool({
15577
+ description: "Kill/terminate a PTY session.",
15578
+ args: {
15579
+ id: tool.schema.string().describe("PTY session ID to kill")
15580
+ },
15581
+ async execute(args2, _context) {
15582
+ return killPty(args2);
15583
+ }
15584
+ });
15585
+ var ptyListTool = tool({
15586
+ description: "List all active PTY sessions.",
15587
+ args: {},
15588
+ async execute(_args, _context) {
15589
+ return listPty({});
15590
+ }
15591
+ });
15592
+
14807
15593
  // src/agents/hive.ts
14808
- var QUEEN_BEE_PROMPT = `# Hive (Hybrid)
15594
+ var QUEEN_BEE_PROMPT = `# Zetta (Hybrid)
14809
15595
 
14810
15596
  Hybrid agent: plans AND orchestrates. Phase-aware, skills on-demand.
14811
15597
 
@@ -15687,17 +16473,20 @@ function buildCustomSubagents({
15687
16473
  }
15688
16474
 
15689
16475
  // src/mcp/websearch.ts
16476
+ var exaApiKey = process.env.EXA_API_KEY || process.env.OPENCODE_EXA_API_KEY;
15690
16477
  var websearchMcp = {
15691
16478
  type: "remote",
15692
16479
  url: "https://mcp.exa.ai/mcp?tools=web_search_exa",
15693
- headers: process.env.EXA_API_KEY ? { "x-api-key": process.env.EXA_API_KEY } : undefined,
16480
+ headers: exaApiKey ? { "x-api-key": exaApiKey } : undefined,
15694
16481
  oauth: false
15695
16482
  };
15696
16483
 
15697
16484
  // src/mcp/context7.ts
16485
+ var context7ApiKey = process.env.CONTEXT7_API_KEY || process.env.OPENCODE_CONTEXT7_API_KEY;
15698
16486
  var context7Mcp = {
15699
16487
  type: "remote",
15700
16488
  url: "https://mcp.context7.com/mcp",
16489
+ headers: context7ApiKey ? { Authorization: `Bearer ${context7ApiKey}` } : undefined,
15701
16490
  oauth: false
15702
16491
  };
15703
16492
 
@@ -15709,9 +16498,10 @@ var grepAppMcp = {
15709
16498
  };
15710
16499
 
15711
16500
  // src/mcp/ast-grep.ts
15712
- var astGrepMcp = {
15713
- type: "local",
15714
- command: ["npx", "-y", "@notprolands/ast-grep-mcp"]
16501
+ var astGrepRemoteMcp = {
16502
+ type: "remote",
16503
+ url: "https://mcp.ast-grep.dev/mcp",
16504
+ oauth: false
15715
16505
  };
15716
16506
 
15717
16507
  // src/mcp/index.ts
@@ -15719,7 +16509,7 @@ var allBuiltinMcps = {
15719
16509
  websearch: websearchMcp,
15720
16510
  context7: context7Mcp,
15721
16511
  grep_app: grepAppMcp,
15722
- ast_grep: astGrepMcp
16512
+ ast_grep: astGrepRemoteMcp
15723
16513
  };
15724
16514
  var createBuiltinMcps = (disabledMcps = []) => {
15725
16515
  const disabled = new Set(disabledMcps);
@@ -15920,7 +16710,7 @@ var require_common = __commonJS((exports, module) => {
15920
16710
  let enableOverride = null;
15921
16711
  let namespacesCache;
15922
16712
  let enabledCache;
15923
- function debug(...args) {
16713
+ function debug(...args2) {
15924
16714
  if (!debug.enabled) {
15925
16715
  return;
15926
16716
  }
@@ -15931,28 +16721,28 @@ var require_common = __commonJS((exports, module) => {
15931
16721
  self.prev = prevTime;
15932
16722
  self.curr = curr;
15933
16723
  prevTime = curr;
15934
- args[0] = createDebug.coerce(args[0]);
15935
- if (typeof args[0] !== "string") {
15936
- args.unshift("%O");
16724
+ args2[0] = createDebug.coerce(args2[0]);
16725
+ if (typeof args2[0] !== "string") {
16726
+ args2.unshift("%O");
15937
16727
  }
15938
16728
  let index = 0;
15939
- args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
16729
+ args2[0] = args2[0].replace(/%([a-zA-Z%])/g, (match, format) => {
15940
16730
  if (match === "%%") {
15941
16731
  return "%";
15942
16732
  }
15943
16733
  index++;
15944
16734
  const formatter = createDebug.formatters[format];
15945
16735
  if (typeof formatter === "function") {
15946
- const val = args[index];
16736
+ const val = args2[index];
15947
16737
  match = formatter.call(self, val);
15948
- args.splice(index, 1);
16738
+ args2.splice(index, 1);
15949
16739
  index--;
15950
16740
  }
15951
16741
  return match;
15952
16742
  });
15953
- createDebug.formatArgs.call(self, args);
16743
+ createDebug.formatArgs.call(self, args2);
15954
16744
  const logFn = self.log || createDebug.log;
15955
- logFn.apply(self, args);
16745
+ logFn.apply(self, args2);
15956
16746
  }
15957
16747
  debug.namespace = namespace;
15958
16748
  debug.useColors = createDebug.useColors();
@@ -16166,16 +16956,16 @@ var require_browser = __commonJS((exports, module) => {
16166
16956
  let m;
16167
16957
  return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || typeof navigator !== "undefined" && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31 || typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
16168
16958
  }
16169
- function formatArgs(args) {
16170
- args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff);
16959
+ function formatArgs(args2) {
16960
+ args2[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args2[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff);
16171
16961
  if (!this.useColors) {
16172
16962
  return;
16173
16963
  }
16174
16964
  const c = "color: " + this.color;
16175
- args.splice(1, 0, c, "color: inherit");
16965
+ args2.splice(1, 0, c, "color: inherit");
16176
16966
  let index = 0;
16177
16967
  let lastC = 0;
16178
- args[0].replace(/%[a-zA-Z%]/g, (match) => {
16968
+ args2[0].replace(/%[a-zA-Z%]/g, (match) => {
16179
16969
  if (match === "%%") {
16180
16970
  return;
16181
16971
  }
@@ -16184,7 +16974,7 @@ var require_browser = __commonJS((exports, module) => {
16184
16974
  lastC = index;
16185
16975
  }
16186
16976
  });
16187
- args.splice(lastC, 0, c);
16977
+ args2.splice(lastC, 0, c);
16188
16978
  }
16189
16979
  exports.log = console.debug || console.log || (() => {});
16190
16980
  function save(namespaces) {
@@ -16339,18 +17129,18 @@ var require_node = __commonJS((exports, module) => {
16339
17129
  function useColors() {
16340
17130
  return "colors" in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) : tty.isatty(process.stderr.fd);
16341
17131
  }
16342
- function formatArgs(args) {
17132
+ function formatArgs(args2) {
16343
17133
  const { namespace: name, useColors: useColors2 } = this;
16344
17134
  if (useColors2) {
16345
17135
  const c = this.color;
16346
17136
  const colorCode = "\x1B[3" + (c < 8 ? c : "8;5;" + c);
16347
17137
  const prefix = ` ${colorCode};1m${name} \x1B[0m`;
16348
- args[0] = prefix + args[0].split(`
17138
+ args2[0] = prefix + args2[0].split(`
16349
17139
  `).join(`
16350
17140
  ` + prefix);
16351
- args.push(colorCode + "m+" + module.exports.humanize(this.diff) + "\x1B[0m");
17141
+ args2.push(colorCode + "m+" + module.exports.humanize(this.diff) + "\x1B[0m");
16352
17142
  } else {
16353
- args[0] = getDate() + name + " " + args[0];
17143
+ args2[0] = getDate() + name + " " + args2[0];
16354
17144
  }
16355
17145
  }
16356
17146
  function getDate() {
@@ -16359,8 +17149,8 @@ var require_node = __commonJS((exports, module) => {
16359
17149
  }
16360
17150
  return new Date().toISOString() + " ";
16361
17151
  }
16362
- function log(...args) {
16363
- return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + `
17152
+ function log(...args2) {
17153
+ return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args2) + `
16364
17154
  `);
16365
17155
  }
16366
17156
  function save(namespaces) {
@@ -16485,7 +17275,7 @@ var require_dist2 = __commonJS((exports) => {
16485
17275
  exports.default = deferred;
16486
17276
  });
16487
17277
  var BUILT_IN_AGENT_NAMES = [
16488
- "hive",
17278
+ "zetta",
16489
17279
  "architect-planner",
16490
17280
  "swarm-orchestrator",
16491
17281
  "scout-researcher",
@@ -16507,7 +17297,7 @@ var CUSTOM_AGENT_RESERVED_NAMES = [
16507
17297
  "code"
16508
17298
  ];
16509
17299
  var DEFAULT_AGENT_MODELS = {
16510
- hive: "github-copilot/claude-opus-4.5",
17300
+ zetta: "github-copilot/claude-opus-4.5",
16511
17301
  "architect-planner": "github-copilot/gpt-5.2-codex",
16512
17302
  "swarm-orchestrator": "github-copilot/claude-opus-4.5",
16513
17303
  "scout-researcher": "zai-coding-plan/glm-4.7",
@@ -16537,27 +17327,22 @@ var DEFAULT_HIVE_CONFIG = {
16537
17327
  }
16538
17328
  },
16539
17329
  agents: {
16540
- hive: {
16541
- model: DEFAULT_AGENT_MODELS["hive"],
17330
+ zetta: {
17331
+ model: DEFAULT_AGENT_MODELS["zetta"],
16542
17332
  temperature: 0.5,
16543
- skills: [
16544
- "brainstorming",
16545
- "writing-plans",
16546
- "dispatching-parallel-agents",
16547
- "executing-plans"
16548
- ],
17333
+ skills: [],
16549
17334
  autoLoadSkills: ["parallel-exploration"]
16550
17335
  },
16551
17336
  "architect-planner": {
16552
17337
  model: DEFAULT_AGENT_MODELS["architect-planner"],
16553
17338
  temperature: 0.7,
16554
- skills: ["brainstorming", "writing-plans"],
17339
+ skills: [],
16555
17340
  autoLoadSkills: ["parallel-exploration"]
16556
17341
  },
16557
17342
  "swarm-orchestrator": {
16558
17343
  model: DEFAULT_AGENT_MODELS["swarm-orchestrator"],
16559
17344
  temperature: 0.5,
16560
- skills: ["dispatching-parallel-agents", "executing-plans"],
17345
+ skills: [],
16561
17346
  autoLoadSkills: []
16562
17347
  },
16563
17348
  "scout-researcher": {
@@ -16574,7 +17359,7 @@ var DEFAULT_HIVE_CONFIG = {
16574
17359
  "hygienic-reviewer": {
16575
17360
  model: DEFAULT_AGENT_MODELS["hygienic-reviewer"],
16576
17361
  temperature: 0.3,
16577
- skills: ["systematic-debugging", "code-reviewer"],
17362
+ skills: [],
16578
17363
  autoLoadSkills: []
16579
17364
  }
16580
17365
  }
@@ -17576,7 +18361,7 @@ var __defProp22 = Object.defineProperty;
17576
18361
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
17577
18362
  var __getOwnPropNames2 = Object.getOwnPropertyNames;
17578
18363
  var __hasOwnProp2 = Object.prototype.hasOwnProperty;
17579
- var __esm = (fn, res) => function __init() {
18364
+ var __esm2 = (fn, res) => function __init() {
17580
18365
  return fn && (res = (0, fn[__getOwnPropNames2(fn)[0]])(fn = 0)), res;
17581
18366
  };
17582
18367
  var __commonJS2 = (cb, mod) => function __require22() {
@@ -17607,13 +18392,13 @@ function toPaths(pathSpec) {
17607
18392
  return cache.get(pathSpec) || [];
17608
18393
  }
17609
18394
  var cache;
17610
- var init_pathspec = __esm({
18395
+ var init_pathspec = __esm2({
17611
18396
  "src/lib/args/pathspec.ts"() {
17612
18397
  cache = /* @__PURE__ */ new WeakMap;
17613
18398
  }
17614
18399
  });
17615
18400
  var GitError;
17616
- var init_git_error = __esm({
18401
+ var init_git_error = __esm2({
17617
18402
  "src/lib/errors/git-error.ts"() {
17618
18403
  GitError = class extends Error {
17619
18404
  constructor(task, message) {
@@ -17625,7 +18410,7 @@ var init_git_error = __esm({
17625
18410
  }
17626
18411
  });
17627
18412
  var GitResponseError;
17628
- var init_git_response_error = __esm({
18413
+ var init_git_response_error = __esm2({
17629
18414
  "src/lib/errors/git-response-error.ts"() {
17630
18415
  init_git_error();
17631
18416
  GitResponseError = class extends GitError {
@@ -17637,7 +18422,7 @@ var init_git_response_error = __esm({
17637
18422
  }
17638
18423
  });
17639
18424
  var TaskConfigurationError;
17640
- var init_task_configuration_error = __esm({
18425
+ var init_task_configuration_error = __esm2({
17641
18426
  "src/lib/errors/task-configuration-error.ts"() {
17642
18427
  init_git_error();
17643
18428
  TaskConfigurationError = class extends GitError {
@@ -17768,7 +18553,7 @@ function orVoid(input) {
17768
18553
  var NULL;
17769
18554
  var NOOP;
17770
18555
  var objectToString;
17771
- var init_util = __esm({
18556
+ var init_util = __esm2({
17772
18557
  "src/lib/utils/util.ts"() {
17773
18558
  init_argument_filters();
17774
18559
  NULL = "\x00";
@@ -17797,7 +18582,7 @@ var filterNumber;
17797
18582
  var filterString;
17798
18583
  var filterStringOrStringArray;
17799
18584
  var filterHasLength;
17800
- var init_argument_filters = __esm({
18585
+ var init_argument_filters = __esm2({
17801
18586
  "src/lib/utils/argument-filters.ts"() {
17802
18587
  init_pathspec();
17803
18588
  init_util();
@@ -17822,7 +18607,7 @@ var init_argument_filters = __esm({
17822
18607
  }
17823
18608
  });
17824
18609
  var ExitCodes;
17825
- var init_exit_codes = __esm({
18610
+ var init_exit_codes = __esm2({
17826
18611
  "src/lib/utils/exit-codes.ts"() {
17827
18612
  ExitCodes = /* @__PURE__ */ ((ExitCodes2) => {
17828
18613
  ExitCodes2[ExitCodes2["SUCCESS"] = 0] = "SUCCESS";
@@ -17834,7 +18619,7 @@ var init_exit_codes = __esm({
17834
18619
  }
17835
18620
  });
17836
18621
  var GitOutputStreams;
17837
- var init_git_output_streams = __esm({
18622
+ var init_git_output_streams = __esm2({
17838
18623
  "src/lib/utils/git-output-streams.ts"() {
17839
18624
  GitOutputStreams = class _GitOutputStreams {
17840
18625
  constructor(stdOut, stdErr) {
@@ -17852,7 +18637,7 @@ function useMatchesDefault() {
17852
18637
  }
17853
18638
  var LineParser;
17854
18639
  var RemoteLineParser;
17855
- var init_line_parser = __esm({
18640
+ var init_line_parser = __esm2({
17856
18641
  "src/lib/utils/line-parser.ts"() {
17857
18642
  LineParser = class {
17858
18643
  constructor(regExp, useMatches) {
@@ -17907,7 +18692,7 @@ function createInstanceConfig(...options) {
17907
18692
  return config2;
17908
18693
  }
17909
18694
  var defaultOptions;
17910
- var init_simple_git_options = __esm({
18695
+ var init_simple_git_options = __esm2({
17911
18696
  "src/lib/utils/simple-git-options.ts"() {
17912
18697
  defaultOptions = {
17913
18698
  binary: "git",
@@ -17939,32 +18724,32 @@ function appendTaskOptions(options, commands = []) {
17939
18724
  return commands2;
17940
18725
  }, commands);
17941
18726
  }
17942
- function getTrailingOptions(args, initialPrimitive = 0, objectOnly = false) {
18727
+ function getTrailingOptions(args2, initialPrimitive = 0, objectOnly = false) {
17943
18728
  const command = [];
17944
- for (let i = 0, max = initialPrimitive < 0 ? args.length : initialPrimitive;i < max; i++) {
17945
- if ("string|number".includes(typeof args[i])) {
17946
- command.push(String(args[i]));
18729
+ for (let i = 0, max = initialPrimitive < 0 ? args2.length : initialPrimitive;i < max; i++) {
18730
+ if ("string|number".includes(typeof args2[i])) {
18731
+ command.push(String(args2[i]));
17947
18732
  }
17948
18733
  }
17949
- appendTaskOptions(trailingOptionsArgument(args), command);
18734
+ appendTaskOptions(trailingOptionsArgument(args2), command);
17950
18735
  if (!objectOnly) {
17951
- command.push(...trailingArrayArgument(args));
18736
+ command.push(...trailingArrayArgument(args2));
17952
18737
  }
17953
18738
  return command;
17954
18739
  }
17955
- function trailingArrayArgument(args) {
17956
- const hasTrailingCallback = typeof last(args) === "function";
17957
- return asStringArray(filterType(last(args, hasTrailingCallback ? 1 : 0), filterArray, []));
18740
+ function trailingArrayArgument(args2) {
18741
+ const hasTrailingCallback = typeof last(args2) === "function";
18742
+ return asStringArray(filterType(last(args2, hasTrailingCallback ? 1 : 0), filterArray, []));
17958
18743
  }
17959
- function trailingOptionsArgument(args) {
17960
- const hasTrailingCallback = filterFunction(last(args));
17961
- return filterType(last(args, hasTrailingCallback ? 1 : 0), filterPlainObject);
18744
+ function trailingOptionsArgument(args2) {
18745
+ const hasTrailingCallback = filterFunction(last(args2));
18746
+ return filterType(last(args2, hasTrailingCallback ? 1 : 0), filterPlainObject);
17962
18747
  }
17963
- function trailingFunctionArgument(args, includeNoop = true) {
17964
- const callback = asFunction(last(args));
18748
+ function trailingFunctionArgument(args2, includeNoop = true) {
18749
+ const callback = asFunction(last(args2));
17965
18750
  return includeNoop || isUserFunction(callback) ? callback : undefined;
17966
18751
  }
17967
- var init_task_options = __esm({
18752
+ var init_task_options = __esm2({
17968
18753
  "src/lib/utils/task-options.ts"() {
17969
18754
  init_argument_filters();
17970
18755
  init_util();
@@ -17988,7 +18773,7 @@ function parseStringResponse(result, parsers12, texts, trim = true) {
17988
18773
  });
17989
18774
  return result;
17990
18775
  }
17991
- var init_task_parser = __esm({
18776
+ var init_task_parser = __esm2({
17992
18777
  "src/lib/utils/task-parser.ts"() {
17993
18778
  init_util();
17994
18779
  }
@@ -18039,7 +18824,7 @@ __export2(utils_exports, {
18039
18824
  trailingFunctionArgument: () => trailingFunctionArgument,
18040
18825
  trailingOptionsArgument: () => trailingOptionsArgument
18041
18826
  });
18042
- var init_utils = __esm({
18827
+ var init_utils = __esm2({
18043
18828
  "src/lib/utils/index.ts"() {
18044
18829
  init_argument_filters();
18045
18830
  init_exit_codes();
@@ -18099,7 +18884,7 @@ function isNotRepoMessage(error45) {
18099
18884
  var CheckRepoActions;
18100
18885
  var onError;
18101
18886
  var parser;
18102
- var init_check_is_repo = __esm({
18887
+ var init_check_is_repo = __esm2({
18103
18888
  "src/lib/tasks/check-is-repo.ts"() {
18104
18889
  init_utils();
18105
18890
  CheckRepoActions = /* @__PURE__ */ ((CheckRepoActions2) => {
@@ -18133,7 +18918,7 @@ var CleanResponse;
18133
18918
  var removalRegexp;
18134
18919
  var dryRunRemovalRegexp;
18135
18920
  var isFolderRegexp;
18136
- var init_CleanSummary = __esm({
18921
+ var init_CleanSummary = __esm2({
18137
18922
  "src/lib/responses/CleanSummary.ts"() {
18138
18923
  init_utils();
18139
18924
  CleanResponse = class {
@@ -18200,7 +18985,7 @@ function isEmptyTask(task) {
18200
18985
  return task.format === "empty" || !task.commands.length;
18201
18986
  }
18202
18987
  var EMPTY_COMMANDS;
18203
- var init_task = __esm({
18988
+ var init_task = __esm2({
18204
18989
  "src/lib/tasks/task.ts"() {
18205
18990
  init_task_configuration_error();
18206
18991
  EMPTY_COMMANDS = [];
@@ -18278,7 +19063,7 @@ var CONFIG_ERROR_MODE_REQUIRED;
18278
19063
  var CONFIG_ERROR_UNKNOWN_OPTION;
18279
19064
  var CleanOptions;
18280
19065
  var CleanOptionValues;
18281
- var init_clean = __esm({
19066
+ var init_clean = __esm2({
18282
19067
  "src/lib/tasks/clean.ts"() {
18283
19068
  init_CleanSummary();
18284
19069
  init_utils();
@@ -18351,7 +19136,7 @@ function* configParser(text, requestedKey = null) {
18351
19136
  }
18352
19137
  }
18353
19138
  var ConfigList;
18354
- var init_ConfigList = __esm({
19139
+ var init_ConfigList = __esm2({
18355
19140
  "src/lib/responses/ConfigList.ts"() {
18356
19141
  init_utils();
18357
19142
  ConfigList = class {
@@ -18449,7 +19234,7 @@ function config_default() {
18449
19234
  };
18450
19235
  }
18451
19236
  var GitConfigScope;
18452
- var init_config = __esm({
19237
+ var init_config = __esm2({
18453
19238
  "src/lib/tasks/config.ts"() {
18454
19239
  init_ConfigList();
18455
19240
  init_utils();
@@ -18467,7 +19252,7 @@ function isDiffNameStatus(input) {
18467
19252
  }
18468
19253
  var DiffNameStatus;
18469
19254
  var diffNameStatus;
18470
- var init_diff_name_status = __esm({
19255
+ var init_diff_name_status = __esm2({
18471
19256
  "src/lib/tasks/diff-name-status.ts"() {
18472
19257
  DiffNameStatus = /* @__PURE__ */ ((DiffNameStatus2) => {
18473
19258
  DiffNameStatus2["ADDED"] = "A";
@@ -18532,7 +19317,7 @@ var disallowedOptions;
18532
19317
  var Query;
18533
19318
  var _a;
18534
19319
  var GrepQuery;
18535
- var init_grep = __esm({
19320
+ var init_grep = __esm2({
18536
19321
  "src/lib/tasks/grep.ts"() {
18537
19322
  init_utils();
18538
19323
  init_task();
@@ -18588,7 +19373,7 @@ function isValidResetMode(mode) {
18588
19373
  }
18589
19374
  var ResetMode;
18590
19375
  var validResetModes;
18591
- var init_reset = __esm({
19376
+ var init_reset = __esm2({
18592
19377
  "src/lib/tasks/reset.ts"() {
18593
19378
  init_utils();
18594
19379
  init_task();
@@ -18608,15 +19393,15 @@ function createLog() {
18608
19393
  }
18609
19394
  function prefixedLogger(to, prefix, forward) {
18610
19395
  if (!prefix || !String(prefix).replace(/\s*/, "")) {
18611
- return !forward ? to : (message, ...args) => {
18612
- to(message, ...args);
18613
- forward(message, ...args);
19396
+ return !forward ? to : (message, ...args2) => {
19397
+ to(message, ...args2);
19398
+ forward(message, ...args2);
18614
19399
  };
18615
19400
  }
18616
- return (message, ...args) => {
18617
- to(`%s ${message}`, prefix, ...args);
19401
+ return (message, ...args2) => {
19402
+ to(`%s ${message}`, prefix, ...args2);
18618
19403
  if (forward) {
18619
- forward(message, ...args);
19404
+ forward(message, ...args2);
18620
19405
  }
18621
19406
  };
18622
19407
  }
@@ -18651,7 +19436,7 @@ function createLogger(label, verbose, initialStep, infoDebugger = createLog()) {
18651
19436
  });
18652
19437
  }
18653
19438
  }
18654
- var init_git_logger = __esm({
19439
+ var init_git_logger = __esm2({
18655
19440
  "src/lib/git-logger.ts"() {
18656
19441
  init_utils();
18657
19442
  import_debug.default.formatters.L = (value) => String(filterHasLength(value) ? value.length : "-");
@@ -18664,7 +19449,7 @@ var init_git_logger = __esm({
18664
19449
  }
18665
19450
  });
18666
19451
  var TasksPendingQueue;
18667
- var init_tasks_pending_queue = __esm({
19452
+ var init_tasks_pending_queue = __esm2({
18668
19453
  "src/lib/runners/tasks-pending-queue.ts"() {
18669
19454
  init_git_error();
18670
19455
  init_git_logger();
@@ -18748,7 +19533,7 @@ function onDataReceived(target, name, logger, output) {
18748
19533
  };
18749
19534
  }
18750
19535
  var GitExecutorChain;
18751
- var init_git_executor_chain = __esm({
19536
+ var init_git_executor_chain = __esm2({
18752
19537
  "src/lib/runners/git-executor-chain.ts"() {
18753
19538
  init_git_error();
18754
19539
  init_task();
@@ -18802,9 +19587,9 @@ var init_git_executor_chain = __esm({
18802
19587
  }
18803
19588
  async attemptRemoteTask(task, logger) {
18804
19589
  const binary = this._plugins.exec("spawn.binary", "", pluginContext(task, task.commands));
18805
- const args = this._plugins.exec("spawn.args", [...task.commands], pluginContext(task, task.commands));
18806
- const raw = await this.gitResponse(task, binary, args, this.outputHandler, logger.step("SPAWN"));
18807
- const outputStreams = await this.handleTaskData(task, args, raw, logger.step("HANDLE"));
19590
+ const args2 = this._plugins.exec("spawn.args", [...task.commands], pluginContext(task, task.commands));
19591
+ const raw = await this.gitResponse(task, binary, args2, this.outputHandler, logger.step("SPAWN"));
19592
+ const outputStreams = await this.handleTaskData(task, args2, raw, logger.step("HANDLE"));
18808
19593
  logger(`passing response to task's parser as a %s`, task.format);
18809
19594
  if (isBufferTask(task)) {
18810
19595
  return callTaskParser(task.parser, outputStreams);
@@ -18815,12 +19600,12 @@ var init_git_executor_chain = __esm({
18815
19600
  logger(`empty task bypassing child process to call to task's parser`);
18816
19601
  return task.parser(this);
18817
19602
  }
18818
- handleTaskData(task, args, result, logger) {
19603
+ handleTaskData(task, args2, result, logger) {
18819
19604
  const { exitCode, rejection, stdOut, stdErr } = result;
18820
19605
  return new Promise((done, fail) => {
18821
19606
  logger(`Preparing to handle process response exitCode=%d stdOut=`, exitCode);
18822
19607
  const { error: error45 } = this._plugins.exec("task.error", { error: rejection }, {
18823
- ...pluginContext(task, args),
19608
+ ...pluginContext(task, args2),
18824
19609
  ...result
18825
19610
  });
18826
19611
  if (error45 && task.onError) {
@@ -18839,7 +19624,7 @@ var init_git_executor_chain = __esm({
18839
19624
  done(new GitOutputStreams(Buffer.concat(stdOut), Buffer.concat(stdErr)));
18840
19625
  });
18841
19626
  }
18842
- async gitResponse(task, command, args, outputHandler, logger) {
19627
+ async gitResponse(task, command, args2, outputHandler, logger) {
18843
19628
  const outputLogger = logger.sibling("output");
18844
19629
  const spawnOptions = this._plugins.exec("spawn.options", {
18845
19630
  cwd: this.cwd,
@@ -18849,9 +19634,9 @@ var init_git_executor_chain = __esm({
18849
19634
  return new Promise((done) => {
18850
19635
  const stdOut = [];
18851
19636
  const stdErr = [];
18852
- logger.info(`%s %o`, command, args);
19637
+ logger.info(`%s %o`, command, args2);
18853
19638
  logger("%O", spawnOptions);
18854
- let rejection = this._beforeSpawn(task, args);
19639
+ let rejection = this._beforeSpawn(task, args2);
18855
19640
  if (rejection) {
18856
19641
  return done({
18857
19642
  stdOut,
@@ -18861,21 +19646,21 @@ var init_git_executor_chain = __esm({
18861
19646
  });
18862
19647
  }
18863
19648
  this._plugins.exec("spawn.before", undefined, {
18864
- ...pluginContext(task, args),
19649
+ ...pluginContext(task, args2),
18865
19650
  kill(reason) {
18866
19651
  rejection = reason || rejection;
18867
19652
  }
18868
19653
  });
18869
- const spawned = spawn(command, args, spawnOptions);
19654
+ const spawned = spawn(command, args2, spawnOptions);
18870
19655
  spawned.stdout.on("data", onDataReceived(stdOut, "stdOut", logger, outputLogger.step("stdOut")));
18871
19656
  spawned.stderr.on("data", onDataReceived(stdErr, "stdErr", logger, outputLogger.step("stdErr")));
18872
19657
  spawned.on("error", onErrorReceived(stdErr, logger));
18873
19658
  if (outputHandler) {
18874
19659
  logger(`Passing child process stdOut/stdErr to custom outputHandler`);
18875
- outputHandler(command, spawned.stdout, spawned.stderr, [...args]);
19660
+ outputHandler(command, spawned.stdout, spawned.stderr, [...args2]);
18876
19661
  }
18877
19662
  this._plugins.exec("spawn.after", undefined, {
18878
- ...pluginContext(task, args),
19663
+ ...pluginContext(task, args2),
18879
19664
  spawned,
18880
19665
  close(exitCode, reason) {
18881
19666
  done({
@@ -18895,10 +19680,10 @@ var init_git_executor_chain = __esm({
18895
19680
  });
18896
19681
  });
18897
19682
  }
18898
- _beforeSpawn(task, args) {
19683
+ _beforeSpawn(task, args2) {
18899
19684
  let rejection;
18900
19685
  this._plugins.exec("spawn.before", undefined, {
18901
- ...pluginContext(task, args),
19686
+ ...pluginContext(task, args2),
18902
19687
  kill(reason) {
18903
19688
  rejection = reason || rejection;
18904
19689
  }
@@ -18913,7 +19698,7 @@ __export2(git_executor_exports, {
18913
19698
  GitExecutor: () => GitExecutor
18914
19699
  });
18915
19700
  var GitExecutor;
18916
- var init_git_executor = __esm({
19701
+ var init_git_executor = __esm2({
18917
19702
  "src/lib/runners/git-executor.ts"() {
18918
19703
  init_git_executor_chain();
18919
19704
  GitExecutor = class {
@@ -18964,7 +19749,7 @@ function addDeprecationNoticeToError(err) {
18964
19749
  return all;
18965
19750
  }
18966
19751
  }
18967
- var init_task_callback = __esm({
19752
+ var init_task_callback = __esm2({
18968
19753
  "src/lib/task-callback.ts"() {
18969
19754
  init_git_response_error();
18970
19755
  init_utils();
@@ -18978,14 +19763,14 @@ function changeWorkingDirectoryTask(directory, root) {
18978
19763
  return (root || instance).cwd = directory;
18979
19764
  });
18980
19765
  }
18981
- var init_change_working_directory = __esm({
19766
+ var init_change_working_directory = __esm2({
18982
19767
  "src/lib/tasks/change-working-directory.ts"() {
18983
19768
  init_utils();
18984
19769
  init_task();
18985
19770
  }
18986
19771
  });
18987
- function checkoutTask(args) {
18988
- const commands = ["checkout", ...args];
19772
+ function checkoutTask(args2) {
19773
+ const commands = ["checkout", ...args2];
18989
19774
  if (commands[1] === "-b" && commands.includes("-B")) {
18990
19775
  commands[1] = remove(commands, "-B");
18991
19776
  }
@@ -19004,7 +19789,7 @@ function checkout_default() {
19004
19789
  }
19005
19790
  };
19006
19791
  }
19007
- var init_checkout = __esm({
19792
+ var init_checkout = __esm2({
19008
19793
  "src/lib/tasks/checkout.ts"() {
19009
19794
  init_utils();
19010
19795
  init_task();
@@ -19036,7 +19821,7 @@ function count_objects_default() {
19036
19821
  };
19037
19822
  }
19038
19823
  var parser2;
19039
- var init_count_objects = __esm({
19824
+ var init_count_objects = __esm2({
19040
19825
  "src/lib/tasks/count-objects.ts"() {
19041
19826
  init_utils();
19042
19827
  parser2 = new LineParser(/([a-z-]+): (\d+)$/, (result, [key, value]) => {
@@ -19062,7 +19847,7 @@ function parseCommitResult(stdOut) {
19062
19847
  return parseStringResponse(result, parsers, stdOut);
19063
19848
  }
19064
19849
  var parsers;
19065
- var init_parse_commit = __esm({
19850
+ var init_parse_commit = __esm2({
19066
19851
  "src/lib/parsers/parse-commit.ts"() {
19067
19852
  init_utils();
19068
19853
  parsers = [
@@ -19129,7 +19914,7 @@ function commit_default() {
19129
19914
  return !filterStringOrStringArray(message) && configurationErrorTask(`git.commit: requires the commit message to be supplied as a string/string[]`);
19130
19915
  }
19131
19916
  }
19132
- var init_commit = __esm({
19917
+ var init_commit = __esm2({
19133
19918
  "src/lib/tasks/commit.ts"() {
19134
19919
  init_parse_commit();
19135
19920
  init_utils();
@@ -19143,7 +19928,7 @@ function first_commit_default() {
19143
19928
  }
19144
19929
  };
19145
19930
  }
19146
- var init_first_commit = __esm({
19931
+ var init_first_commit = __esm2({
19147
19932
  "src/lib/tasks/first-commit.ts"() {
19148
19933
  init_utils();
19149
19934
  init_task();
@@ -19156,7 +19941,7 @@ function hashObjectTask(filePath, write) {
19156
19941
  }
19157
19942
  return straightThroughStringTask(commands, true);
19158
19943
  }
19159
- var init_hash_object = __esm({
19944
+ var init_hash_object = __esm2({
19160
19945
  "src/lib/tasks/hash-object.ts"() {
19161
19946
  init_task();
19162
19947
  }
@@ -19184,7 +19969,7 @@ function parseInit(bare, path32, text) {
19184
19969
  var InitSummary;
19185
19970
  var initResponseRegex;
19186
19971
  var reInitResponseRegex;
19187
- var init_InitSummary = __esm({
19972
+ var init_InitSummary = __esm2({
19188
19973
  "src/lib/responses/InitSummary.ts"() {
19189
19974
  InitSummary = class {
19190
19975
  constructor(bare, path32, existing, gitDir) {
@@ -19215,7 +20000,7 @@ function initTask(bare = false, path32, customArgs) {
19215
20000
  };
19216
20001
  }
19217
20002
  var bareCommand;
19218
- var init_init = __esm({
20003
+ var init_init = __esm2({
19219
20004
  "src/lib/tasks/init.ts"() {
19220
20005
  init_InitSummary();
19221
20006
  bareCommand = "--bare";
@@ -19234,13 +20019,13 @@ function isLogFormat(customArg) {
19234
20019
  return logFormatRegex.test(customArg);
19235
20020
  }
19236
20021
  var logFormatRegex;
19237
- var init_log_format = __esm({
20022
+ var init_log_format = __esm2({
19238
20023
  "src/lib/args/log-format.ts"() {
19239
20024
  logFormatRegex = /^--(stat|numstat|name-only|name-status)(=|$)/;
19240
20025
  }
19241
20026
  });
19242
20027
  var DiffSummary;
19243
- var init_DiffSummary = __esm({
20028
+ var init_DiffSummary = __esm2({
19244
20029
  "src/lib/responses/DiffSummary.ts"() {
19245
20030
  DiffSummary = class {
19246
20031
  constructor() {
@@ -19261,7 +20046,7 @@ var numStatParser;
19261
20046
  var nameOnlyParser;
19262
20047
  var nameStatusParser;
19263
20048
  var diffSummaryParsers;
19264
- var init_parse_diff_summary = __esm({
20049
+ var init_parse_diff_summary = __esm2({
19265
20050
  "src/lib/parsers/parse-diff-summary.ts"() {
19266
20051
  init_log_format();
19267
20052
  init_DiffSummary();
@@ -19382,7 +20167,7 @@ var START_BOUNDARY;
19382
20167
  var COMMIT_BOUNDARY;
19383
20168
  var SPLITTER;
19384
20169
  var defaultFieldNames;
19385
- var init_parse_list_log_summary = __esm({
20170
+ var init_parse_list_log_summary = __esm2({
19386
20171
  "src/lib/parsers/parse-list-log-summary.ts"() {
19387
20172
  init_utils();
19388
20173
  init_parse_diff_summary();
@@ -19421,7 +20206,7 @@ function validateLogFormatConfig(customArgs) {
19421
20206
  return configurationErrorTask(`Summary flag ${flags} parsing is not compatible with null termination option '-z'`);
19422
20207
  }
19423
20208
  }
19424
- var init_diff = __esm({
20209
+ var init_diff = __esm2({
19425
20210
  "src/lib/tasks/diff.ts"() {
19426
20211
  init_log_format();
19427
20212
  init_parse_diff_summary();
@@ -19505,7 +20290,7 @@ function log_default() {
19505
20290
  }
19506
20291
  }
19507
20292
  var excludeOptions;
19508
- var init_log = __esm({
20293
+ var init_log = __esm2({
19509
20294
  "src/lib/tasks/log.ts"() {
19510
20295
  init_log_format();
19511
20296
  init_pathspec();
@@ -19533,7 +20318,7 @@ var init_log = __esm({
19533
20318
  });
19534
20319
  var MergeSummaryConflict;
19535
20320
  var MergeSummaryDetail;
19536
- var init_MergeSummary = __esm({
20321
+ var init_MergeSummary = __esm2({
19537
20322
  "src/lib/responses/MergeSummary.ts"() {
19538
20323
  MergeSummaryConflict = class {
19539
20324
  constructor(reason, file2 = null, meta) {
@@ -19568,7 +20353,7 @@ var init_MergeSummary = __esm({
19568
20353
  });
19569
20354
  var PullSummary;
19570
20355
  var PullFailedSummary;
19571
- var init_PullSummary = __esm({
20356
+ var init_PullSummary = __esm2({
19572
20357
  "src/lib/responses/PullSummary.ts"() {
19573
20358
  PullSummary = class {
19574
20359
  constructor() {
@@ -19625,7 +20410,7 @@ function asObjectCount(source) {
19625
20410
  };
19626
20411
  }
19627
20412
  var remoteMessagesObjectParsers;
19628
- var init_parse_remote_objects = __esm({
20413
+ var init_parse_remote_objects = __esm2({
19629
20414
  "src/lib/parsers/parse-remote-objects.ts"() {
19630
20415
  init_utils();
19631
20416
  remoteMessagesObjectParsers = [
@@ -19653,7 +20438,7 @@ function parseRemoteMessages(_stdOut, stdErr) {
19653
20438
  }
19654
20439
  var parsers2;
19655
20440
  var RemoteMessageSummary;
19656
- var init_parse_remote_messages = __esm({
20441
+ var init_parse_remote_messages = __esm2({
19657
20442
  "src/lib/parsers/parse-remote-messages.ts"() {
19658
20443
  init_utils();
19659
20444
  init_parse_remote_objects();
@@ -19692,7 +20477,7 @@ var parsers3;
19692
20477
  var errorParsers;
19693
20478
  var parsePullDetail;
19694
20479
  var parsePullResult;
19695
- var init_parse_pull = __esm({
20480
+ var init_parse_pull = __esm2({
19696
20481
  "src/lib/parsers/parse-pull.ts"() {
19697
20482
  init_PullSummary();
19698
20483
  init_utils();
@@ -19745,7 +20530,7 @@ var init_parse_pull = __esm({
19745
20530
  var parsers4;
19746
20531
  var parseMergeResult;
19747
20532
  var parseMergeDetail;
19748
- var init_parse_merge = __esm({
20533
+ var init_parse_merge = __esm2({
19749
20534
  "src/lib/parsers/parse-merge.ts"() {
19750
20535
  init_MergeSummary();
19751
20536
  init_utils();
@@ -19791,7 +20576,7 @@ function mergeTask(customArgs) {
19791
20576
  }
19792
20577
  };
19793
20578
  }
19794
- var init_merge = __esm({
20579
+ var init_merge = __esm2({
19795
20580
  "src/lib/tasks/merge.ts"() {
19796
20581
  init_git_response_error();
19797
20582
  init_parse_merge();
@@ -19815,7 +20600,7 @@ function pushResultPushedItem(local, remote, status) {
19815
20600
  var parsers5;
19816
20601
  var parsePushResult;
19817
20602
  var parsePushDetail;
19818
- var init_parse_push = __esm({
20603
+ var init_parse_push = __esm2({
19819
20604
  "src/lib/parsers/parse-push.ts"() {
19820
20605
  init_utils();
19821
20606
  init_parse_remote_messages();
@@ -19892,7 +20677,7 @@ function pushTask(ref = {}, customArgs) {
19892
20677
  parser: parsePushResult
19893
20678
  };
19894
20679
  }
19895
- var init_push = __esm({
20680
+ var init_push = __esm2({
19896
20681
  "src/lib/tasks/push.ts"() {
19897
20682
  init_parse_push();
19898
20683
  init_utils();
@@ -19913,7 +20698,7 @@ function show_default() {
19913
20698
  }
19914
20699
  };
19915
20700
  }
19916
- var init_show = __esm({
20701
+ var init_show = __esm2({
19917
20702
  "src/lib/tasks/show.ts"() {
19918
20703
  init_utils();
19919
20704
  init_task();
@@ -19921,7 +20706,7 @@ var init_show = __esm({
19921
20706
  });
19922
20707
  var fromPathRegex;
19923
20708
  var FileStatusSummary;
19924
- var init_FileStatusSummary = __esm({
20709
+ var init_FileStatusSummary = __esm2({
19925
20710
  "src/lib/responses/FileStatusSummary.ts"() {
19926
20711
  fromPathRegex = /^(.+)\0(.+)$/;
19927
20712
  FileStatusSummary = class {
@@ -19975,7 +20760,7 @@ function splitLine(result, lineStr) {
19975
20760
  var StatusSummary;
19976
20761
  var parsers6;
19977
20762
  var parseStatusSummary;
19978
- var init_StatusSummary = __esm({
20763
+ var init_StatusSummary = __esm2({
19979
20764
  "src/lib/responses/StatusSummary.ts"() {
19980
20765
  init_utils();
19981
20766
  init_FileStatusSummary();
@@ -20099,7 +20884,7 @@ function statusTask(customArgs) {
20099
20884
  };
20100
20885
  }
20101
20886
  var ignoredOptions;
20102
- var init_status = __esm({
20887
+ var init_status = __esm2({
20103
20888
  "src/lib/tasks/status.ts"() {
20104
20889
  init_StatusSummary();
20105
20890
  ignoredOptions = ["--null", "-z"];
@@ -20148,7 +20933,7 @@ function versionParser(stdOut) {
20148
20933
  }
20149
20934
  var NOT_INSTALLED;
20150
20935
  var parsers7;
20151
- var init_version = __esm({
20936
+ var init_version = __esm2({
20152
20937
  "src/lib/tasks/version.ts"() {
20153
20938
  init_utils();
20154
20939
  NOT_INSTALLED = "installed=false";
@@ -20162,11 +20947,11 @@ var init_version = __esm({
20162
20947
  ];
20163
20948
  }
20164
20949
  });
20165
- function createCloneTask(api2, task, repoPath, ...args) {
20950
+ function createCloneTask(api2, task, repoPath, ...args2) {
20166
20951
  if (!filterString(repoPath)) {
20167
20952
  return configurationErrorTask(`git.${api2}() requires a string 'repoPath'`);
20168
20953
  }
20169
- return task(repoPath, filterType(args[0], filterString), getTrailingOptions(arguments));
20954
+ return task(repoPath, filterType(args2[0], filterString), getTrailingOptions(arguments));
20170
20955
  }
20171
20956
  function clone_default() {
20172
20957
  return {
@@ -20180,7 +20965,7 @@ function clone_default() {
20180
20965
  }
20181
20966
  var cloneTask;
20182
20967
  var cloneMirrorTask;
20183
- var init_clone = __esm({
20968
+ var init_clone = __esm2({
20184
20969
  "src/lib/tasks/clone.ts"() {
20185
20970
  init_task();
20186
20971
  init_utils();
@@ -20202,7 +20987,7 @@ __export2(simple_git_api_exports, {
20202
20987
  SimpleGitApi: () => SimpleGitApi
20203
20988
  });
20204
20989
  var SimpleGitApi;
20205
- var init_simple_git_api = __esm({
20990
+ var init_simple_git_api = __esm2({
20206
20991
  "src/lib/simple-git-api.ts"() {
20207
20992
  init_task_callback();
20208
20993
  init_change_working_directory();
@@ -20294,19 +21079,19 @@ __export2(scheduler_exports, {
20294
21079
  });
20295
21080
  var createScheduledTask;
20296
21081
  var Scheduler;
20297
- var init_scheduler = __esm({
21082
+ var init_scheduler = __esm2({
20298
21083
  "src/lib/runners/scheduler.ts"() {
20299
21084
  init_utils();
20300
21085
  init_git_logger();
20301
21086
  createScheduledTask = /* @__PURE__ */ (() => {
20302
- let id = 0;
21087
+ let id2 = 0;
20303
21088
  return () => {
20304
- id++;
21089
+ id2++;
20305
21090
  const { promise: promise2, done } = import_promise_deferred.createDeferred();
20306
21091
  return {
20307
21092
  promise: promise2,
20308
21093
  done,
20309
- id
21094
+ id: id2
20310
21095
  };
20311
21096
  };
20312
21097
  })();
@@ -20332,8 +21117,8 @@ var init_scheduler = __esm({
20332
21117
  });
20333
21118
  }
20334
21119
  next() {
20335
- const { promise: promise2, id } = append(this.pending, createScheduledTask());
20336
- this.logger(`Scheduling id=%s`, id);
21120
+ const { promise: promise2, id: id2 } = append(this.pending, createScheduledTask());
21121
+ this.logger(`Scheduling id=%s`, id2);
20337
21122
  this.schedule();
20338
21123
  return promise2;
20339
21124
  }
@@ -20347,7 +21132,7 @@ __export2(apply_patch_exports, {
20347
21132
  function applyPatchTask(patches, customArgs) {
20348
21133
  return straightThroughStringTask(["apply", ...customArgs, ...patches]);
20349
21134
  }
20350
- var init_apply_patch = __esm({
21135
+ var init_apply_patch = __esm2({
20351
21136
  "src/lib/tasks/apply-patch.ts"() {
20352
21137
  init_task();
20353
21138
  }
@@ -20367,7 +21152,7 @@ function branchDeletionFailure(branch) {
20367
21152
  };
20368
21153
  }
20369
21154
  var BranchDeletionBatch;
20370
- var init_BranchDeleteSummary = __esm({
21155
+ var init_BranchDeleteSummary = __esm2({
20371
21156
  "src/lib/responses/BranchDeleteSummary.ts"() {
20372
21157
  BranchDeletionBatch = class {
20373
21158
  constructor() {
@@ -20388,7 +21173,7 @@ var deleteSuccessRegex;
20388
21173
  var deleteErrorRegex;
20389
21174
  var parsers8;
20390
21175
  var parseBranchDeletions;
20391
- var init_parse_branch_delete = __esm({
21176
+ var init_parse_branch_delete = __esm2({
20392
21177
  "src/lib/parsers/parse-branch-delete.ts"() {
20393
21178
  init_BranchDeleteSummary();
20394
21179
  init_utils();
@@ -20413,7 +21198,7 @@ var init_parse_branch_delete = __esm({
20413
21198
  }
20414
21199
  });
20415
21200
  var BranchSummaryResult;
20416
- var init_BranchSummary = __esm({
21201
+ var init_BranchSummary = __esm2({
20417
21202
  "src/lib/responses/BranchSummary.ts"() {
20418
21203
  BranchSummaryResult = class {
20419
21204
  constructor() {
@@ -20447,7 +21232,7 @@ function parseBranchSummary(stdOut, currentOnly = false) {
20447
21232
  }
20448
21233
  var parsers9;
20449
21234
  var currentBranchParser;
20450
- var init_parse_branch = __esm({
21235
+ var init_parse_branch = __esm2({
20451
21236
  "src/lib/parsers/parse-branch.ts"() {
20452
21237
  init_BranchSummary();
20453
21238
  init_utils();
@@ -20537,7 +21322,7 @@ function deleteBranchTask(branch, forceDelete = false) {
20537
21322
  };
20538
21323
  return task;
20539
21324
  }
20540
- var init_branch = __esm({
21325
+ var init_branch = __esm2({
20541
21326
  "src/lib/tasks/branch.ts"() {
20542
21327
  init_git_response_error();
20543
21328
  init_parse_branch_delete();
@@ -20550,7 +21335,7 @@ function toPath(input) {
20550
21335
  return path32 && normalize(path32);
20551
21336
  }
20552
21337
  var parseCheckIgnore;
20553
- var init_CheckIgnore = __esm({
21338
+ var init_CheckIgnore = __esm2({
20554
21339
  "src/lib/responses/CheckIgnore.ts"() {
20555
21340
  parseCheckIgnore = (text) => {
20556
21341
  return text.split(/\n/g).map(toPath).filter(Boolean);
@@ -20568,7 +21353,7 @@ function checkIgnoreTask(paths) {
20568
21353
  parser: parseCheckIgnore
20569
21354
  };
20570
21355
  }
20571
- var init_check_ignore = __esm({
21356
+ var init_check_ignore = __esm2({
20572
21357
  "src/lib/tasks/check-ignore.ts"() {
20573
21358
  init_CheckIgnore();
20574
21359
  }
@@ -20585,7 +21370,7 @@ function parseFetchResult(stdOut, stdErr) {
20585
21370
  return parseStringResponse(result, parsers10, [stdOut, stdErr]);
20586
21371
  }
20587
21372
  var parsers10;
20588
- var init_parse_fetch = __esm({
21373
+ var init_parse_fetch = __esm2({
20589
21374
  "src/lib/parsers/parse-fetch.ts"() {
20590
21375
  init_utils();
20591
21376
  parsers10 = [
@@ -20642,7 +21427,7 @@ function fetchTask(remote, branch, customArgs) {
20642
21427
  parser: parseFetchResult
20643
21428
  };
20644
21429
  }
20645
- var init_fetch = __esm({
21430
+ var init_fetch = __esm2({
20646
21431
  "src/lib/tasks/fetch.ts"() {
20647
21432
  init_parse_fetch();
20648
21433
  init_task();
@@ -20652,7 +21437,7 @@ function parseMoveResult(stdOut) {
20652
21437
  return parseStringResponse({ moves: [] }, parsers11, stdOut);
20653
21438
  }
20654
21439
  var parsers11;
20655
- var init_parse_move = __esm({
21440
+ var init_parse_move = __esm2({
20656
21441
  "src/lib/parsers/parse-move.ts"() {
20657
21442
  init_utils();
20658
21443
  parsers11 = [
@@ -20673,7 +21458,7 @@ function moveTask(from, to) {
20673
21458
  parser: parseMoveResult
20674
21459
  };
20675
21460
  }
20676
- var init_move = __esm({
21461
+ var init_move = __esm2({
20677
21462
  "src/lib/tasks/move.ts"() {
20678
21463
  init_parse_move();
20679
21464
  init_utils();
@@ -20703,7 +21488,7 @@ function pullTask(remote, branch, customArgs) {
20703
21488
  }
20704
21489
  };
20705
21490
  }
20706
- var init_pull = __esm({
21491
+ var init_pull = __esm2({
20707
21492
  "src/lib/tasks/pull.ts"() {
20708
21493
  init_git_response_error();
20709
21494
  init_parse_pull();
@@ -20733,7 +21518,7 @@ function parseGetRemotesVerbose(text) {
20733
21518
  function forEach(text, handler) {
20734
21519
  forEachLineWithContent(text, (line) => handler(line.split(/\s+/)));
20735
21520
  }
20736
- var init_GetRemoteSummary = __esm({
21521
+ var init_GetRemoteSummary = __esm2({
20737
21522
  "src/lib/responses/GetRemoteSummary.ts"() {
20738
21523
  init_utils();
20739
21524
  }
@@ -20777,7 +21562,7 @@ function remoteTask(customArgs) {
20777
21562
  function removeRemoteTask(remoteName) {
20778
21563
  return straightThroughStringTask(["remote", "remove", remoteName]);
20779
21564
  }
20780
- var init_remote = __esm({
21565
+ var init_remote = __esm2({
20781
21566
  "src/lib/tasks/remote.ts"() {
20782
21567
  init_GetRemoteSummary();
20783
21568
  init_task();
@@ -20797,7 +21582,7 @@ function stashListTask(opt = {}, customArgs) {
20797
21582
  parser: parser4
20798
21583
  };
20799
21584
  }
20800
- var init_stash_list = __esm({
21585
+ var init_stash_list = __esm2({
20801
21586
  "src/lib/tasks/stash-list.ts"() {
20802
21587
  init_log_format();
20803
21588
  init_parse_list_log_summary();
@@ -20828,7 +21613,7 @@ function subModuleTask(customArgs) {
20828
21613
  function updateSubModuleTask(customArgs) {
20829
21614
  return subModuleTask(["update", ...customArgs]);
20830
21615
  }
20831
- var init_sub_module = __esm({
21616
+ var init_sub_module = __esm2({
20832
21617
  "src/lib/tasks/sub-module.ts"() {
20833
21618
  init_task();
20834
21619
  }
@@ -20855,7 +21640,7 @@ function toNumber(input) {
20855
21640
  }
20856
21641
  var TagList;
20857
21642
  var parseTagList;
20858
- var init_TagList = __esm({
21643
+ var init_TagList = __esm2({
20859
21644
  "src/lib/responses/TagList.ts"() {
20860
21645
  TagList = class {
20861
21646
  constructor(all, latest) {
@@ -20921,7 +21706,7 @@ function addAnnotatedTagTask(name, tagMessage) {
20921
21706
  }
20922
21707
  };
20923
21708
  }
20924
- var init_tag = __esm({
21709
+ var init_tag = __esm2({
20925
21710
  "src/lib/tasks/tag.ts"() {
20926
21711
  init_TagList();
20927
21712
  }
@@ -21070,10 +21855,10 @@ var require_git = __commonJS2({
21070
21855
  Git2.prototype.submoduleAdd = function(repo, path32, then) {
21071
21856
  return this._runTask(addSubModuleTask2(repo, path32), trailingFunctionArgument2(arguments));
21072
21857
  };
21073
- Git2.prototype.submoduleUpdate = function(args, then) {
21858
+ Git2.prototype.submoduleUpdate = function(args2, then) {
21074
21859
  return this._runTask(updateSubModuleTask2(getTrailingOptions2(arguments, true)), trailingFunctionArgument2(arguments));
21075
21860
  };
21076
- Git2.prototype.submoduleInit = function(args, then) {
21861
+ Git2.prototype.submoduleInit = function(args2, then) {
21077
21862
  return this._runTask(initSubModuleTask2(getTrailingOptions2(arguments, true)), trailingFunctionArgument2(arguments));
21078
21863
  };
21079
21864
  Git2.prototype.subModule = function(options, then) {
@@ -21120,10 +21905,10 @@ var require_git = __commonJS2({
21120
21905
  Git2.prototype.binaryCatFile = function() {
21121
21906
  return this._catFile("buffer", arguments);
21122
21907
  };
21123
- Git2.prototype._catFile = function(format, args) {
21124
- var handler = trailingFunctionArgument2(args);
21908
+ Git2.prototype._catFile = function(format, args2) {
21909
+ var handler = trailingFunctionArgument2(args2);
21125
21910
  var command = ["cat-file"];
21126
- var options = args[0];
21911
+ var options = args2[0];
21127
21912
  if (typeof options === "string") {
21128
21913
  return this._runTask(configurationErrorTask2("Git.catFile: options must be supplied as an array of strings"), handler);
21129
21914
  }
@@ -21270,13 +22055,13 @@ function blockUnsafeOperationsPlugin({
21270
22055
  } = {}) {
21271
22056
  return {
21272
22057
  type: "spawn.args",
21273
- action(args, context) {
21274
- args.forEach((current, index) => {
21275
- const next = index < args.length ? args[index + 1] : "";
22058
+ action(args2, context) {
22059
+ args2.forEach((current, index) => {
22060
+ const next = index < args2.length ? args2[index + 1] : "";
21276
22061
  allowUnsafePack || preventUploadPack(current, context.method);
21277
22062
  preventUnsafeConfig.forEach((helper) => helper(options, current, next));
21278
22063
  });
21279
- return args;
22064
+ return args2;
21280
22065
  }
21281
22066
  };
21282
22067
  }
@@ -21484,11 +22269,11 @@ function progressMonitorPlugin(progress) {
21484
22269
  };
21485
22270
  const onArgs = {
21486
22271
  type: "spawn.args",
21487
- action(args, context) {
22272
+ action(args2, context) {
21488
22273
  if (!progressMethods.includes(context.method)) {
21489
- return args;
22274
+ return args2;
21490
22275
  }
21491
- return including(args, progressCommand);
22276
+ return including(args2, progressCommand);
21492
22277
  }
21493
22278
  };
21494
22279
  return [onArgs, onProgress];
@@ -21547,8 +22332,8 @@ function suffixPathsPlugin() {
21547
22332
  action(data) {
21548
22333
  const prefix = [];
21549
22334
  let suffix;
21550
- function append2(args) {
21551
- (suffix = suffix || []).push(...args);
22335
+ function append2(args2) {
22336
+ (suffix = suffix || []).push(...args2);
21552
22337
  }
21553
22338
  for (let i = 0;i < data.length; i++) {
21554
22339
  const param = data[i];
@@ -22219,11 +23004,12 @@ class ConfigService {
22219
23004
  return this.get();
22220
23005
  }
22221
23006
  getAgentConfig(agent) {
23007
+ const resolvedAgent = agent === "hive" ? "zetta" : agent;
22222
23008
  const config2 = this.get();
22223
- if (this.isBuiltInAgent(agent)) {
22224
- const agentConfig = config2.agents?.[agent] ?? {};
22225
- const defaultAutoLoadSkills = DEFAULT_HIVE_CONFIG.agents?.[agent]?.autoLoadSkills ?? [];
22226
- const effectiveAutoLoadSkills = this.resolveAutoLoadSkills(defaultAutoLoadSkills, agentConfig.autoLoadSkills ?? [], this.isPlannerAgent(agent));
23009
+ if (this.isBuiltInAgent(resolvedAgent)) {
23010
+ const agentConfig = config2.agents?.[resolvedAgent] ?? {};
23011
+ const defaultAutoLoadSkills = DEFAULT_HIVE_CONFIG.agents?.[resolvedAgent]?.autoLoadSkills ?? [];
23012
+ const effectiveAutoLoadSkills = this.resolveAutoLoadSkills(defaultAutoLoadSkills, agentConfig.autoLoadSkills ?? [], this.isPlannerAgent(resolvedAgent));
22227
23013
  return {
22228
23014
  ...agentConfig,
22229
23015
  autoLoadSkills: effectiveAutoLoadSkills
@@ -22297,7 +23083,7 @@ class ConfigService {
22297
23083
  return CUSTOM_AGENT_BASES.includes(baseAgent);
22298
23084
  }
22299
23085
  isPlannerAgent(agent) {
22300
- return agent === "hive" || agent === "architect-planner";
23086
+ return agent === "zetta" || agent === "architect-planner";
22301
23087
  }
22302
23088
  isObjectRecord(value) {
22303
23089
  return value !== null && typeof value === "object" && !Array.isArray(value);
@@ -23282,7 +24068,7 @@ var plugin = async (ctx) => {
23282
24068
  const disabledSkills = configService.getDisabledSkills();
23283
24069
  const builtinMcps = createBuiltinMcps(disabledMcps);
23284
24070
  const filteredSkills = getFilteredSkills(disabledSkills);
23285
- const effectiveAutoLoadSkills = configService.getAgentConfig("hive").autoLoadSkills ?? [];
24071
+ const effectiveAutoLoadSkills = configService.getAgentConfig("zetta").autoLoadSkills ?? [];
23286
24072
  const worktreeService = new WorktreeService({
23287
24073
  baseDir: directory,
23288
24074
  hiveDir: path8.join(directory, ".hive")
@@ -23773,8 +24559,31 @@ Use the \`@path\` attachment syntax in the prompt to reference the file. Do not
23773
24559
  }
23774
24560
  }
23775
24561
  },
23776
- "experimental.session.compacting": async (_input, output) => {
23777
- output.context.push(buildCompactionPrompt());
24562
+ "experimental.session.compacting": async (input, output) => {
24563
+ const contextLimit = input.contextLimit || 200000;
24564
+ const messages = input.messages || [];
24565
+ if (messages.length > 0) {
24566
+ const { estimateTokens: estimateTokens2, needsCompression: needsCompression2, compressContext: compressContext2, buildCompressionHint: buildCompressionHint2 } = await Promise.resolve().then(() => (init_context_compression(), exports_context_compression));
24567
+ if (needsCompression2(messages, contextLimit, { threshold: 0.5, enabled: true })) {
24568
+ const { compressed, stats } = compressContext2(messages, {
24569
+ threshold: 0.5,
24570
+ enabled: true,
24571
+ maxToolCalls: 50,
24572
+ protectedTools: [
24573
+ "hive_feature_create",
24574
+ "hive_plan_write",
24575
+ "hive_worktree_commit",
24576
+ "hive_merge"
24577
+ ]
24578
+ }, contextLimit);
24579
+ console.log(`[hive:compaction] Context at ${Math.round(stats.reductionRatio * 100)}% - compressed ${stats.originalMessages} → ${stats.compressedMessages} messages`);
24580
+ output.context.push(buildCompressionHint2());
24581
+ } else {
24582
+ output.context.push(buildCompactionPrompt());
24583
+ }
24584
+ } else {
24585
+ output.context.push(buildCompactionPrompt());
24586
+ }
23778
24587
  },
23779
24588
  "chat.message": createVariantHook(configService),
23780
24589
  "tool.execute.before": async (input, output) => {
@@ -23807,6 +24616,15 @@ Use the \`@path\` attachment syntax in the prompt to reference the file. Do not
23807
24616
  },
23808
24617
  mcp: builtinMcps,
23809
24618
  tool: {
24619
+ gitingest: gitingestTool,
24620
+ look_at: lookAtTool,
24621
+ artifact_search: artifactSearchTool,
24622
+ btca_ask: btcaAskTool,
24623
+ pty_start: ptyStartTool,
24624
+ pty_send: ptySendTool,
24625
+ pty_read: ptyReadTool,
24626
+ pty_kill: ptyKillTool,
24627
+ pty_list: ptyListTool,
23810
24628
  hive_skill: createHiveSkillTool(filteredSkills),
23811
24629
  hive_feature_create: tool({
23812
24630
  description: "Create a new feature and set it as active",
@@ -24418,8 +25236,8 @@ ${result.diff}
24418
25236
  command: {
24419
25237
  hive: {
24420
25238
  description: "Create a new feature: /hive <feature-name>",
24421
- async run(args) {
24422
- const name = args.trim();
25239
+ async run(args2) {
25240
+ const name = args2.trim();
24423
25241
  if (!name)
24424
25242
  return "Usage: /hive <feature-name>";
24425
25243
  return `Create feature "${name}" using hive_feature_create tool.`;
@@ -24464,14 +25282,14 @@ ${result.diff}
24464
25282
  ## Configured Custom Subagents
24465
25283
  ${Object.entries(customAgentConfigs).sort(([left], [right]) => left.localeCompare(right)).map(([name, config2]) => `- \`${name}\` — derived from \`${config2.baseAgent}\`; ${config2.description}`).join(`
24466
25284
  `)}`;
24467
- const hiveUserConfig = configService.getAgentConfig("hive");
24468
- const hiveAutoLoadedSkills = await buildAutoLoadedSkillsContent("hive", configService, directory);
24469
- const hiveConfig = {
24470
- model: hiveUserConfig.model,
24471
- variant: hiveUserConfig.variant,
24472
- temperature: hiveUserConfig.temperature ?? 0.5,
24473
- description: "Hive (Hybrid) - Plans + orchestrates. Detects phase, loads skills on-demand.",
24474
- prompt: QUEEN_BEE_PROMPT + hiveAutoLoadedSkills + (agentMode === "unified" ? customSubagentAppendix : ""),
25285
+ const zettaUserConfig = configService.getAgentConfig("zetta");
25286
+ const zettaAutoLoadedSkills = await buildAutoLoadedSkillsContent("zetta", configService, directory);
25287
+ const zettaConfig = {
25288
+ model: zettaUserConfig.model,
25289
+ variant: zettaUserConfig.variant,
25290
+ temperature: zettaUserConfig.temperature ?? 0.5,
25291
+ description: "Zetta (Hybrid) - Plans + orchestrates. Detects phase, loads skills on-demand.",
25292
+ prompt: QUEEN_BEE_PROMPT + zettaAutoLoadedSkills + (agentMode === "unified" ? customSubagentAppendix : ""),
24475
25293
  permission: {
24476
25294
  question: "allow",
24477
25295
  skill: "allow",
@@ -24582,7 +25400,7 @@ ${Object.entries(customAgentConfigs).sort(([left], [right]) => left.localeCompar
24582
25400
  }
24583
25401
  };
24584
25402
  const builtInAgentConfigs = {
24585
- hive: hiveConfig,
25403
+ zetta: zettaConfig,
24586
25404
  "architect-planner": architectConfig,
24587
25405
  "swarm-orchestrator": swarmConfig,
24588
25406
  "scout-researcher": scoutConfig,
@@ -24607,7 +25425,7 @@ ${Object.entries(customAgentConfigs).sort(([left], [right]) => left.localeCompar
24607
25425
  });
24608
25426
  const allAgents = {};
24609
25427
  if (agentMode === "unified") {
24610
- allAgents["hive"] = builtInAgentConfigs["hive"];
25428
+ allAgents["zetta"] = builtInAgentConfigs["zetta"];
24611
25429
  allAgents["scout-researcher"] = builtInAgentConfigs["scout-researcher"];
24612
25430
  allAgents["forager-worker"] = builtInAgentConfigs["forager-worker"];
24613
25431
  allAgents["hygienic-reviewer"] = builtInAgentConfigs["hygienic-reviewer"];
@@ -24636,14 +25454,31 @@ ${Object.entries(customAgentConfigs).sort(([left], [right]) => left.localeCompar
24636
25454
  delete configAgent["scout-researcher"];
24637
25455
  delete configAgent["forager-worker"];
24638
25456
  delete configAgent["hygienic-reviewer"];
25457
+ if (configAgent.build) {
25458
+ configAgent.build.mode = "subagent";
25459
+ }
25460
+ if (configAgent.plan) {
25461
+ configAgent.plan.mode = "subagent";
25462
+ }
25463
+ if (configAgent.triage) {
25464
+ configAgent.triage.mode = "subagent";
25465
+ }
25466
+ if (configAgent.docs) {
25467
+ configAgent.docs.mode = "subagent";
25468
+ }
24639
25469
  Object.assign(configAgent, allAgents);
24640
25470
  }
24641
- opencodeConfig.default_agent = agentMode === "unified" ? "hive" : "architect-planner";
25471
+ opencodeConfig.default_agent = agentMode === "unified" ? "zetta" : "architect-planner";
24642
25472
  const configMcp = opencodeConfig.mcp;
25473
+ const mcpToAdd = builtinMcps;
24643
25474
  if (!configMcp) {
24644
- opencodeConfig.mcp = builtinMcps;
25475
+ opencodeConfig.mcp = mcpToAdd;
24645
25476
  } else {
24646
- Object.assign(configMcp, builtinMcps);
25477
+ for (const [name, config2] of Object.entries(mcpToAdd)) {
25478
+ if (!(name in configMcp)) {
25479
+ configMcp[name] = config2;
25480
+ }
25481
+ }
24647
25482
  }
24648
25483
  }
24649
25484
  };