eminiar 0.13.3 → 0.13.5
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/.claude-plugin/plugin.json +1 -1
- package/.cursor-plugin/plugin.json +1 -1
- package/dist/cli.js +528 -306
- package/dist/{hook-async-3TLK23ZY.js → hook-async-7GK6H3OO.js} +3 -3
- package/dist/{hook-chunk-MVSMFCKL.js → hook-chunk-77LASZ3C.js} +2 -2
- package/dist/{hook-chunk-ETYHCPPH.js → hook-chunk-G7UP4ZVA.js} +36 -4
- package/dist/{hook-chunk-ZLRLOPLR.js → hook-chunk-RE4WT5D3.js} +202 -66
- package/dist/{hook-hooks-5U2AI6W7.js → hook-hooks-5H6LFYD5.js} +4 -4
- package/dist/hook.js +29 -26
- package/dist/server.js +474 -278
- package/eminiar.config.schema.json +3 -0
- package/package.json +3 -1
package/dist/server.js
CHANGED
|
@@ -7256,8 +7256,8 @@ var require_dist = __commonJS({
|
|
|
7256
7256
|
return ajv;
|
|
7257
7257
|
}
|
|
7258
7258
|
const [formats, exportName] = opts.mode === "fast" ? [formats_1.fastFormats, fastName] : [formats_1.fullFormats, fullName];
|
|
7259
|
-
const
|
|
7260
|
-
addFormats(ajv,
|
|
7259
|
+
const list3 = opts.formats || formats_1.formatNames;
|
|
7260
|
+
addFormats(ajv, list3, formats, exportName);
|
|
7261
7261
|
if (opts.keywords)
|
|
7262
7262
|
(0, limit_1.default)(ajv);
|
|
7263
7263
|
return ajv;
|
|
@@ -7269,11 +7269,11 @@ var require_dist = __commonJS({
|
|
|
7269
7269
|
throw new Error(`Unknown format "${name}"`);
|
|
7270
7270
|
return f;
|
|
7271
7271
|
};
|
|
7272
|
-
function addFormats(ajv,
|
|
7272
|
+
function addFormats(ajv, list3, fs, exportName) {
|
|
7273
7273
|
var _a3;
|
|
7274
7274
|
var _b;
|
|
7275
7275
|
(_a3 = (_b = ajv.opts.code).formats) !== null && _a3 !== void 0 ? _a3 : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
|
|
7276
|
-
for (const f of
|
|
7276
|
+
for (const f of list3)
|
|
7277
7277
|
ajv.addFormat(f, fs[f]);
|
|
7278
7278
|
}
|
|
7279
7279
|
module.exports = exports = formatsPlugin;
|
|
@@ -10441,9 +10441,9 @@ var require_micromatch = __commonJS({
|
|
|
10441
10441
|
const index = v.indexOf("{");
|
|
10442
10442
|
return index > -1 && v.indexOf("}", index) > -1;
|
|
10443
10443
|
};
|
|
10444
|
-
var
|
|
10444
|
+
var micromatch2 = (list3, patterns, options) => {
|
|
10445
10445
|
patterns = [].concat(patterns);
|
|
10446
|
-
|
|
10446
|
+
list3 = [].concat(list3);
|
|
10447
10447
|
let omit2 = /* @__PURE__ */ new Set();
|
|
10448
10448
|
let keep = /* @__PURE__ */ new Set();
|
|
10449
10449
|
let items = /* @__PURE__ */ new Set();
|
|
@@ -10458,7 +10458,7 @@ var require_micromatch = __commonJS({
|
|
|
10458
10458
|
let isMatch = picomatch(String(patterns[i]), { ...options, onResult }, true);
|
|
10459
10459
|
let negated = isMatch.state.negated || isMatch.state.negatedExtglob;
|
|
10460
10460
|
if (negated) negatives++;
|
|
10461
|
-
for (let item of
|
|
10461
|
+
for (let item of list3) {
|
|
10462
10462
|
let matched = isMatch(item, true);
|
|
10463
10463
|
let match = negated ? !matched.isMatch : matched.isMatch;
|
|
10464
10464
|
if (!match) continue;
|
|
@@ -10482,11 +10482,11 @@ var require_micromatch = __commonJS({
|
|
|
10482
10482
|
}
|
|
10483
10483
|
return matches2;
|
|
10484
10484
|
};
|
|
10485
|
-
|
|
10486
|
-
|
|
10487
|
-
|
|
10488
|
-
|
|
10489
|
-
|
|
10485
|
+
micromatch2.match = micromatch2;
|
|
10486
|
+
micromatch2.matcher = (pattern2, options) => picomatch(pattern2, options);
|
|
10487
|
+
micromatch2.isMatch = (str4, patterns, options) => picomatch(patterns, options)(str4);
|
|
10488
|
+
micromatch2.any = micromatch2.isMatch;
|
|
10489
|
+
micromatch2.not = (list3, patterns, options = {}) => {
|
|
10490
10490
|
patterns = [].concat(patterns).map(String);
|
|
10491
10491
|
let result = /* @__PURE__ */ new Set();
|
|
10492
10492
|
let items = [];
|
|
@@ -10494,7 +10494,7 @@ var require_micromatch = __commonJS({
|
|
|
10494
10494
|
if (options.onResult) options.onResult(state);
|
|
10495
10495
|
items.push(state.output);
|
|
10496
10496
|
};
|
|
10497
|
-
let matches2 = new Set(
|
|
10497
|
+
let matches2 = new Set(micromatch2(list3, patterns, { ...options, onResult }));
|
|
10498
10498
|
for (let item of items) {
|
|
10499
10499
|
if (!matches2.has(item)) {
|
|
10500
10500
|
result.add(item);
|
|
@@ -10502,12 +10502,12 @@ var require_micromatch = __commonJS({
|
|
|
10502
10502
|
}
|
|
10503
10503
|
return [...result];
|
|
10504
10504
|
};
|
|
10505
|
-
|
|
10505
|
+
micromatch2.contains = (str4, pattern2, options) => {
|
|
10506
10506
|
if (typeof str4 !== "string") {
|
|
10507
10507
|
throw new TypeError(`Expected a string: "${util2.inspect(str4)}"`);
|
|
10508
10508
|
}
|
|
10509
10509
|
if (Array.isArray(pattern2)) {
|
|
10510
|
-
return pattern2.some((p2) =>
|
|
10510
|
+
return pattern2.some((p2) => micromatch2.contains(str4, p2, options));
|
|
10511
10511
|
}
|
|
10512
10512
|
if (typeof pattern2 === "string") {
|
|
10513
10513
|
if (isEmptyString(str4) || isEmptyString(pattern2)) {
|
|
@@ -10517,19 +10517,19 @@ var require_micromatch = __commonJS({
|
|
|
10517
10517
|
return true;
|
|
10518
10518
|
}
|
|
10519
10519
|
}
|
|
10520
|
-
return
|
|
10520
|
+
return micromatch2.isMatch(str4, pattern2, { ...options, contains: true });
|
|
10521
10521
|
};
|
|
10522
|
-
|
|
10522
|
+
micromatch2.matchKeys = (obj, patterns, options) => {
|
|
10523
10523
|
if (!utils.isObject(obj)) {
|
|
10524
10524
|
throw new TypeError("Expected the first argument to be an object");
|
|
10525
10525
|
}
|
|
10526
|
-
let keys =
|
|
10526
|
+
let keys = micromatch2(Object.keys(obj), patterns, options);
|
|
10527
10527
|
let res = {};
|
|
10528
10528
|
for (let key of keys) res[key] = obj[key];
|
|
10529
10529
|
return res;
|
|
10530
10530
|
};
|
|
10531
|
-
|
|
10532
|
-
let items = [].concat(
|
|
10531
|
+
micromatch2.some = (list3, patterns, options) => {
|
|
10532
|
+
let items = [].concat(list3);
|
|
10533
10533
|
for (let pattern2 of [].concat(patterns)) {
|
|
10534
10534
|
let isMatch = picomatch(String(pattern2), options);
|
|
10535
10535
|
if (items.some((item) => isMatch(item))) {
|
|
@@ -10538,8 +10538,8 @@ var require_micromatch = __commonJS({
|
|
|
10538
10538
|
}
|
|
10539
10539
|
return false;
|
|
10540
10540
|
};
|
|
10541
|
-
|
|
10542
|
-
let items = [].concat(
|
|
10541
|
+
micromatch2.every = (list3, patterns, options) => {
|
|
10542
|
+
let items = [].concat(list3);
|
|
10543
10543
|
for (let pattern2 of [].concat(patterns)) {
|
|
10544
10544
|
let isMatch = picomatch(String(pattern2), options);
|
|
10545
10545
|
if (!items.every((item) => isMatch(item))) {
|
|
@@ -10548,13 +10548,13 @@ var require_micromatch = __commonJS({
|
|
|
10548
10548
|
}
|
|
10549
10549
|
return true;
|
|
10550
10550
|
};
|
|
10551
|
-
|
|
10551
|
+
micromatch2.all = (str4, patterns, options) => {
|
|
10552
10552
|
if (typeof str4 !== "string") {
|
|
10553
10553
|
throw new TypeError(`Expected a string: "${util2.inspect(str4)}"`);
|
|
10554
10554
|
}
|
|
10555
10555
|
return [].concat(patterns).every((p2) => picomatch(p2, options)(str4));
|
|
10556
10556
|
};
|
|
10557
|
-
|
|
10557
|
+
micromatch2.capture = (glob2, input2, options) => {
|
|
10558
10558
|
let posix3 = utils.isWindows(options);
|
|
10559
10559
|
let regex = picomatch.makeRe(String(glob2), { ...options, capture: true });
|
|
10560
10560
|
let match = regex.exec(posix3 ? utils.toPosixSlashes(input2) : input2);
|
|
@@ -10562,9 +10562,9 @@ var require_micromatch = __commonJS({
|
|
|
10562
10562
|
return match.slice(1).map((v) => v === void 0 ? "" : v);
|
|
10563
10563
|
}
|
|
10564
10564
|
};
|
|
10565
|
-
|
|
10566
|
-
|
|
10567
|
-
|
|
10565
|
+
micromatch2.makeRe = (...args) => picomatch.makeRe(...args);
|
|
10566
|
+
micromatch2.scan = (...args) => picomatch.scan(...args);
|
|
10567
|
+
micromatch2.parse = (patterns, options) => {
|
|
10568
10568
|
let res = [];
|
|
10569
10569
|
for (let pattern2 of [].concat(patterns || [])) {
|
|
10570
10570
|
for (let str4 of braces(String(pattern2), options)) {
|
|
@@ -10573,19 +10573,19 @@ var require_micromatch = __commonJS({
|
|
|
10573
10573
|
}
|
|
10574
10574
|
return res;
|
|
10575
10575
|
};
|
|
10576
|
-
|
|
10576
|
+
micromatch2.braces = (pattern2, options) => {
|
|
10577
10577
|
if (typeof pattern2 !== "string") throw new TypeError("Expected a string");
|
|
10578
10578
|
if (options && options.nobrace === true || !hasBraces(pattern2)) {
|
|
10579
10579
|
return [pattern2];
|
|
10580
10580
|
}
|
|
10581
10581
|
return braces(pattern2, options);
|
|
10582
10582
|
};
|
|
10583
|
-
|
|
10583
|
+
micromatch2.braceExpand = (pattern2, options) => {
|
|
10584
10584
|
if (typeof pattern2 !== "string") throw new TypeError("Expected a string");
|
|
10585
|
-
return
|
|
10585
|
+
return micromatch2.braces(pattern2, { ...options, expand: true });
|
|
10586
10586
|
};
|
|
10587
|
-
|
|
10588
|
-
module.exports =
|
|
10587
|
+
micromatch2.hasBraces = hasBraces;
|
|
10588
|
+
module.exports = micromatch2;
|
|
10589
10589
|
}
|
|
10590
10590
|
});
|
|
10591
10591
|
|
|
@@ -10598,7 +10598,7 @@ var require_pattern2 = __commonJS({
|
|
|
10598
10598
|
exports.isAbsolute = exports.partitionAbsoluteAndRelative = exports.removeDuplicateSlashes = exports.matchAny = exports.convertPatternsToRe = exports.makeRe = exports.getPatternParts = exports.expandBraceExpansion = exports.expandPatternsWithBraceExpansion = exports.isAffectDepthOfReadingPattern = exports.endsWithSlashGlobStar = exports.hasGlobStar = exports.getBaseDirectory = exports.isPatternRelatedToParentDirectory = exports.getPatternsOutsideCurrentDirectory = exports.getPatternsInsideCurrentDirectory = exports.getPositivePatterns = exports.getNegativePatterns = exports.isPositivePattern = exports.isNegativePattern = exports.convertToNegativePattern = exports.convertToPositivePattern = exports.isDynamicPattern = exports.isStaticPattern = void 0;
|
|
10599
10599
|
var path3 = __require("path");
|
|
10600
10600
|
var globParent = require_glob_parent();
|
|
10601
|
-
var
|
|
10601
|
+
var micromatch2 = require_micromatch();
|
|
10602
10602
|
var GLOBSTAR = "**";
|
|
10603
10603
|
var ESCAPE_SYMBOL = "\\";
|
|
10604
10604
|
var COMMON_GLOB_SYMBOLS_RE = /[*?]|^!/;
|
|
@@ -10691,8 +10691,8 @@ var require_pattern2 = __commonJS({
|
|
|
10691
10691
|
}
|
|
10692
10692
|
exports.endsWithSlashGlobStar = endsWithSlashGlobStar;
|
|
10693
10693
|
function isAffectDepthOfReadingPattern(pattern2) {
|
|
10694
|
-
const
|
|
10695
|
-
return endsWithSlashGlobStar(pattern2) || isStaticPattern(
|
|
10694
|
+
const basename10 = path3.basename(pattern2);
|
|
10695
|
+
return endsWithSlashGlobStar(pattern2) || isStaticPattern(basename10);
|
|
10696
10696
|
}
|
|
10697
10697
|
exports.isAffectDepthOfReadingPattern = isAffectDepthOfReadingPattern;
|
|
10698
10698
|
function expandPatternsWithBraceExpansion(patterns) {
|
|
@@ -10702,13 +10702,13 @@ var require_pattern2 = __commonJS({
|
|
|
10702
10702
|
}
|
|
10703
10703
|
exports.expandPatternsWithBraceExpansion = expandPatternsWithBraceExpansion;
|
|
10704
10704
|
function expandBraceExpansion(pattern2) {
|
|
10705
|
-
const patterns =
|
|
10705
|
+
const patterns = micromatch2.braces(pattern2, { expand: true, nodupes: true, keepEscaping: true });
|
|
10706
10706
|
patterns.sort((a, b) => a.length - b.length);
|
|
10707
10707
|
return patterns.filter((pattern3) => pattern3 !== "");
|
|
10708
10708
|
}
|
|
10709
10709
|
exports.expandBraceExpansion = expandBraceExpansion;
|
|
10710
10710
|
function getPatternParts(pattern2, options) {
|
|
10711
|
-
let { parts } =
|
|
10711
|
+
let { parts } = micromatch2.scan(pattern2, Object.assign(Object.assign({}, options), { parts: true }));
|
|
10712
10712
|
if (parts.length === 0) {
|
|
10713
10713
|
parts = [pattern2];
|
|
10714
10714
|
}
|
|
@@ -10720,7 +10720,7 @@ var require_pattern2 = __commonJS({
|
|
|
10720
10720
|
}
|
|
10721
10721
|
exports.getPatternParts = getPatternParts;
|
|
10722
10722
|
function makeRe(pattern2, options) {
|
|
10723
|
-
return
|
|
10723
|
+
return micromatch2.makeRe(pattern2, options);
|
|
10724
10724
|
}
|
|
10725
10725
|
exports.makeRe = makeRe;
|
|
10726
10726
|
function convertPatternsToRe(patterns, options) {
|
|
@@ -10739,7 +10739,7 @@ var require_pattern2 = __commonJS({
|
|
|
10739
10739
|
const absolute = [];
|
|
10740
10740
|
const relative16 = [];
|
|
10741
10741
|
for (const pattern2 of patterns) {
|
|
10742
|
-
if (
|
|
10742
|
+
if (isAbsolute8(pattern2)) {
|
|
10743
10743
|
absolute.push(pattern2);
|
|
10744
10744
|
} else {
|
|
10745
10745
|
relative16.push(pattern2);
|
|
@@ -10748,10 +10748,10 @@ var require_pattern2 = __commonJS({
|
|
|
10748
10748
|
return [absolute, relative16];
|
|
10749
10749
|
}
|
|
10750
10750
|
exports.partitionAbsoluteAndRelative = partitionAbsoluteAndRelative;
|
|
10751
|
-
function
|
|
10751
|
+
function isAbsolute8(pattern2) {
|
|
10752
10752
|
return path3.isAbsolute(pattern2);
|
|
10753
10753
|
}
|
|
10754
|
-
exports.isAbsolute =
|
|
10754
|
+
exports.isAbsolute = isAbsolute8;
|
|
10755
10755
|
}
|
|
10756
10756
|
});
|
|
10757
10757
|
|
|
@@ -15445,15 +15445,15 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
15445
15445
|
});
|
|
15446
15446
|
}
|
|
15447
15447
|
if (this._def.catchall instanceof ZodNever) {
|
|
15448
|
-
const
|
|
15449
|
-
if (
|
|
15448
|
+
const unknownKeys2 = this._def.unknownKeys;
|
|
15449
|
+
if (unknownKeys2 === "passthrough") {
|
|
15450
15450
|
for (const key of extraKeys) {
|
|
15451
15451
|
pairs.push({
|
|
15452
15452
|
key: { status: "valid", value: key },
|
|
15453
15453
|
value: { status: "valid", value: ctx.data[key] }
|
|
15454
15454
|
});
|
|
15455
15455
|
}
|
|
15456
|
-
} else if (
|
|
15456
|
+
} else if (unknownKeys2 === "strict") {
|
|
15457
15457
|
if (extraKeys.length > 0) {
|
|
15458
15458
|
addIssueToContext(ctx, {
|
|
15459
15459
|
code: ZodIssueCode.unrecognized_keys,
|
|
@@ -15461,7 +15461,7 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
15461
15461
|
});
|
|
15462
15462
|
status.dirty();
|
|
15463
15463
|
}
|
|
15464
|
-
} else if (
|
|
15464
|
+
} else if (unknownKeys2 === "strip") {
|
|
15465
15465
|
} else {
|
|
15466
15466
|
throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
|
|
15467
15467
|
}
|
|
@@ -33067,8 +33067,8 @@ var contributors = {
|
|
|
33067
33067
|
function aggregateChecks(schema2) {
|
|
33068
33068
|
const agg = {};
|
|
33069
33069
|
const def = schema2._zod.def;
|
|
33070
|
-
const
|
|
33071
|
-
for (const ch of
|
|
33070
|
+
const list3 = schema2._zod.traits.has("$ZodCheck") ? [schema2, ...def.checks ?? []] : def.checks ?? [];
|
|
33071
|
+
for (const ch of list3)
|
|
33072
33072
|
contributors[ch._zod.def.check]?.(agg, ch._zod.def);
|
|
33073
33073
|
const bag = schema2._zod.bag;
|
|
33074
33074
|
if (bag.minimum !== void 0)
|
|
@@ -42987,6 +42987,26 @@ function adjudicatorDefaults() {
|
|
|
42987
42987
|
privacy: { maxChars: 2e3, storeHead: true, captureExchanges: false }
|
|
42988
42988
|
};
|
|
42989
42989
|
}
|
|
42990
|
+
function graphGlobProblem(g) {
|
|
42991
|
+
if (g.length > 200) return "longer than 200 characters";
|
|
42992
|
+
if ((g.match(/\{/g)?.length ?? 0) > 4) return "more than 4 braces";
|
|
42993
|
+
if ((g.match(/\(/g)?.length ?? 0) > 2) return "more than 2 extglob groups";
|
|
42994
|
+
let total = 0;
|
|
42995
|
+
for (const seg of g.split(/[\\/]/)) {
|
|
42996
|
+
const groups = seg.match(/\*+|\?/g)?.length ?? 0;
|
|
42997
|
+
if (groups > 3) return "more than 3 wildcards in one path segment";
|
|
42998
|
+
total += groups;
|
|
42999
|
+
}
|
|
43000
|
+
return total > 8 ? "more than 8 wildcards" : void 0;
|
|
43001
|
+
}
|
|
43002
|
+
var GraphGlob = external_exports.string().superRefine((g, ctx) => {
|
|
43003
|
+
const why = graphGlobProblem(g);
|
|
43004
|
+
if (why)
|
|
43005
|
+
ctx.addIssue({
|
|
43006
|
+
code: "custom",
|
|
43007
|
+
message: `graph glob ${JSON.stringify(g.slice(0, 40))} is ${why}`
|
|
43008
|
+
});
|
|
43009
|
+
});
|
|
42990
43010
|
var BaseConfigSchema = external_exports.object({
|
|
42991
43011
|
routing: external_exports.object({
|
|
42992
43012
|
/** auto = annotate while context-mode is installed, enforce once it is gone. */
|
|
@@ -43013,18 +43033,21 @@ var BaseConfigSchema = external_exports.object({
|
|
|
43013
43033
|
dims: external_exports.number().int().positive().default(384)
|
|
43014
43034
|
}).prefault({}),
|
|
43015
43035
|
graph: external_exports.object({
|
|
43016
|
-
include: external_exports.array(
|
|
43036
|
+
include: external_exports.array(GraphGlob).default([
|
|
43017
43037
|
"**/*.ts",
|
|
43018
43038
|
"**/*.tsx",
|
|
43019
43039
|
"**/*.js",
|
|
43020
43040
|
"**/*.jsx",
|
|
43021
43041
|
"**/*.mjs",
|
|
43022
43042
|
"**/*.cjs",
|
|
43043
|
+
"**/*.mts",
|
|
43044
|
+
"**/*.cts",
|
|
43023
43045
|
"**/*.py",
|
|
43046
|
+
"**/*.pyi",
|
|
43024
43047
|
"**/*.go",
|
|
43025
43048
|
"**/*.php"
|
|
43026
43049
|
]),
|
|
43027
|
-
exclude: external_exports.array(
|
|
43050
|
+
exclude: external_exports.array(GraphGlob).default([
|
|
43028
43051
|
"**/node_modules/**",
|
|
43029
43052
|
"**/dist/**",
|
|
43030
43053
|
"**/build/**",
|
|
@@ -43659,8 +43682,9 @@ function embeddingStatus(ctx, db) {
|
|
|
43659
43682
|
// src/graph/reindex.ts
|
|
43660
43683
|
init_esm_shims();
|
|
43661
43684
|
var import_fast_glob2 = __toESM(require_out4(), 1);
|
|
43685
|
+
var import_micromatch = __toESM(require_micromatch(), 1);
|
|
43662
43686
|
import { readFileSync as readFileSync7, statSync as statSync7 } from "fs";
|
|
43663
|
-
import { join as join11 } from "path";
|
|
43687
|
+
import { basename as basename3, isAbsolute as isAbsolute3, join as join11 } from "path";
|
|
43664
43688
|
|
|
43665
43689
|
// src/chunker/index.ts
|
|
43666
43690
|
init_esm_shims();
|
|
@@ -44198,8 +44222,8 @@ function parseRouteAnnotations(doc) {
|
|
|
44198
44222
|
const body = m[1] ?? "";
|
|
44199
44223
|
const path3 = /^\s*"([^"]*)"/.exec(body)?.[1] ?? /\bpath\s*=\s*"([^"]*)"/.exec(body)?.[1];
|
|
44200
44224
|
if (path3 === void 0) continue;
|
|
44201
|
-
const
|
|
44202
|
-
const methods = [...
|
|
44225
|
+
const list3 = /\bmethods\s*=\s*(\{[^}]*\}|"[^"]*")/.exec(body)?.[1] ?? "";
|
|
44226
|
+
const methods = [...list3.matchAll(/"([^"]+)"/g)].map((x) => httpMethod(x[1])).filter((x) => !!x);
|
|
44203
44227
|
for (const method of methods.length ? methods : ["ALL"]) out.push({ method, path: path3 });
|
|
44204
44228
|
}
|
|
44205
44229
|
return out;
|
|
@@ -45013,16 +45037,16 @@ function phpString(n) {
|
|
|
45013
45037
|
return literalText(n)?.replace(/\\(\\|')/g, "$1");
|
|
45014
45038
|
}
|
|
45015
45039
|
function argsOf(call) {
|
|
45016
|
-
const
|
|
45017
|
-
return (
|
|
45040
|
+
const list3 = call.childForFieldName("arguments") ?? call.childForFieldName("parameters");
|
|
45041
|
+
return (list3?.namedChildren ?? []).filter((a) => a?.type === "argument").map((a) => a.namedChildren[a.namedChildren.length - 1]).filter((a) => !!a);
|
|
45018
45042
|
}
|
|
45019
45043
|
function positionalArgs(call) {
|
|
45020
|
-
const
|
|
45021
|
-
return (
|
|
45044
|
+
const list3 = call.childForFieldName("arguments") ?? call.childForFieldName("parameters");
|
|
45045
|
+
return (list3?.namedChildren ?? []).filter((a) => a?.type === "argument" && !a.childForFieldName("name")).map((a) => a.namedChildren[0]).filter((a) => !!a);
|
|
45022
45046
|
}
|
|
45023
45047
|
function namedArg(call, name) {
|
|
45024
|
-
const
|
|
45025
|
-
for (const a of
|
|
45048
|
+
const list3 = call.childForFieldName("arguments") ?? call.childForFieldName("parameters");
|
|
45049
|
+
for (const a of list3?.namedChildren ?? []) {
|
|
45026
45050
|
if (a?.type === "argument" && a.childForFieldName("name")?.text === name)
|
|
45027
45051
|
return a.namedChildren[a.namedChildren.length - 1] ?? void 0;
|
|
45028
45052
|
}
|
|
@@ -48113,9 +48137,9 @@ function computeMetrics(db) {
|
|
|
48113
48137
|
for (const s of symbols) {
|
|
48114
48138
|
const f = s.path ? `file:${s.path}` : void 0;
|
|
48115
48139
|
if (!f) continue;
|
|
48116
|
-
const
|
|
48117
|
-
|
|
48118
|
-
symbolsByFile.set(f,
|
|
48140
|
+
const list3 = symbolsByFile.get(f) ?? [];
|
|
48141
|
+
list3.push(s);
|
|
48142
|
+
symbolsByFile.set(f, list3);
|
|
48119
48143
|
}
|
|
48120
48144
|
for (const f of files) {
|
|
48121
48145
|
const m = meta3(f);
|
|
@@ -48168,9 +48192,9 @@ function computeMetrics(db) {
|
|
|
48168
48192
|
const members2 = /* @__PURE__ */ new Map();
|
|
48169
48193
|
for (const r of fileRows) {
|
|
48170
48194
|
if (r.cluster === null) continue;
|
|
48171
|
-
const
|
|
48172
|
-
|
|
48173
|
-
members2.set(r.cluster,
|
|
48195
|
+
const list3 = members2.get(r.cluster) ?? [];
|
|
48196
|
+
list3.push(r);
|
|
48197
|
+
members2.set(r.cluster, list3);
|
|
48174
48198
|
}
|
|
48175
48199
|
const links = /* @__PURE__ */ new Map();
|
|
48176
48200
|
for (const e of importEdges) {
|
|
@@ -48227,15 +48251,44 @@ function readCycles(db) {
|
|
|
48227
48251
|
// src/graph/reindex.ts
|
|
48228
48252
|
var MAX_CODE_BYTES = 15e5;
|
|
48229
48253
|
var CODE_INDEX_VERSION = "3";
|
|
48254
|
+
var CODE_GLOB = { onlyFiles: true, dot: false, followSymbolicLinks: false };
|
|
48255
|
+
var MATCH = { dot: false, posix: true, strictSlashes: false };
|
|
48230
48256
|
function listCodeFiles(ctx) {
|
|
48231
48257
|
return import_fast_glob2.default.sync(ctx.config.graph.include, {
|
|
48258
|
+
...CODE_GLOB,
|
|
48232
48259
|
cwd: ctx.root,
|
|
48233
|
-
ignore: ctx.config.graph.exclude
|
|
48234
|
-
onlyFiles: true,
|
|
48235
|
-
dot: false,
|
|
48236
|
-
followSymbolicLinks: false
|
|
48260
|
+
ignore: ctx.config.graph.exclude
|
|
48237
48261
|
});
|
|
48238
48262
|
}
|
|
48263
|
+
function codeFileFilter(graph) {
|
|
48264
|
+
const cached7 = FILTERS.get(graph);
|
|
48265
|
+
if (cached7) return cached7;
|
|
48266
|
+
const f = compileCodeFilter(graph);
|
|
48267
|
+
FILTERS.set(graph, f);
|
|
48268
|
+
return f;
|
|
48269
|
+
}
|
|
48270
|
+
var FILTERS = /* @__PURE__ */ new WeakMap();
|
|
48271
|
+
function compileCodeFilter(graph) {
|
|
48272
|
+
const tasks = import_fast_glob2.default.generateTasks(graph.include, { ignore: graph.exclude });
|
|
48273
|
+
const re = (patterns, opts) => patterns.map((p2) => import_micromatch.default.makeRe(p2, opts));
|
|
48274
|
+
const any2 = (res, s) => res.some((r) => r.test(s));
|
|
48275
|
+
const positive = re(
|
|
48276
|
+
tasks.flatMap((t) => t.positive),
|
|
48277
|
+
MATCH
|
|
48278
|
+
);
|
|
48279
|
+
const ignore = tasks[0]?.negative ?? [];
|
|
48280
|
+
const ignored = re(ignore, { ...MATCH, dot: true });
|
|
48281
|
+
const pruned = re(
|
|
48282
|
+
ignore.filter((p2) => p2.endsWith("/**") || !import_fast_glob2.default.isDynamicPattern(basename3(p2))),
|
|
48283
|
+
MATCH
|
|
48284
|
+
);
|
|
48285
|
+
return (rel) => {
|
|
48286
|
+
if (isAbsolute3(rel) || rel.startsWith("../") || !any2(positive, rel) || any2(ignored, rel))
|
|
48287
|
+
return false;
|
|
48288
|
+
const dirs = rel.split("/").slice(0, -1);
|
|
48289
|
+
return !dirs.some((_, i) => any2(pruned, dirs.slice(0, i + 1).join("/")));
|
|
48290
|
+
};
|
|
48291
|
+
}
|
|
48239
48292
|
async function indexOne(ctx, db, rel, force) {
|
|
48240
48293
|
const abs = join11(ctx.root, rel);
|
|
48241
48294
|
const st = statSync7(abs);
|
|
@@ -48437,7 +48490,7 @@ function statSafe(p2) {
|
|
|
48437
48490
|
var draining = false;
|
|
48438
48491
|
async function drainReindexQueue(ctx, db) {
|
|
48439
48492
|
if (draining) return 0;
|
|
48440
|
-
const paths2 = db.reindexQueueDrain();
|
|
48493
|
+
const paths2 = db.reindexQueueDrain().filter(codeFileFilter(ctx.config.graph));
|
|
48441
48494
|
if (!paths2.length) return 0;
|
|
48442
48495
|
draining = true;
|
|
48443
48496
|
try {
|
|
@@ -53872,7 +53925,7 @@ init_esm_shims();
|
|
|
53872
53925
|
init_esm_shims();
|
|
53873
53926
|
import { createHash as createHash4 } from "crypto";
|
|
53874
53927
|
import { realpathSync as realpathSync6 } from "fs";
|
|
53875
|
-
import { isAbsolute as
|
|
53928
|
+
import { isAbsolute as isAbsolute4, relative as relative9 } from "path";
|
|
53876
53929
|
|
|
53877
53930
|
// src/capture/categories.ts
|
|
53878
53931
|
init_esm_shims();
|
|
@@ -55769,11 +55822,11 @@ function createOpenAIProvider(r, cfg, deps = {}) {
|
|
|
55769
55822
|
};
|
|
55770
55823
|
}
|
|
55771
55824
|
function mapAnswers(reqs, items, raw, cat, askTool) {
|
|
55772
|
-
const
|
|
55773
|
-
if (!
|
|
55825
|
+
const list3 = raw && typeof raw === "object" && Array.isArray(raw.items) ? raw.items : void 0;
|
|
55826
|
+
if (!list3) throw new ProviderError("invalid", "the answer has no items array");
|
|
55774
55827
|
const Item = itemSchema(cat, askTool);
|
|
55775
55828
|
const byId = /* @__PURE__ */ new Map();
|
|
55776
|
-
for (const x of
|
|
55829
|
+
for (const x of list3) {
|
|
55777
55830
|
const p2 = Item.safeParse(x);
|
|
55778
55831
|
if (p2.success && !byId.has(p2.data.id)) byId.set(p2.data.id, p2.data);
|
|
55779
55832
|
}
|
|
@@ -57122,8 +57175,8 @@ function pricedSavings(stats, calls, overrides, opts = {}) {
|
|
|
57122
57175
|
};
|
|
57123
57176
|
const bySession2 = /* @__PURE__ */ new Map();
|
|
57124
57177
|
for (const c of calls) {
|
|
57125
|
-
const
|
|
57126
|
-
if (
|
|
57178
|
+
const list3 = bySession2.get(c.session_id);
|
|
57179
|
+
if (list3) list3.push(c);
|
|
57127
57180
|
else bySession2.set(c.session_id, [c]);
|
|
57128
57181
|
}
|
|
57129
57182
|
const sessionModel = /* @__PURE__ */ new Map();
|
|
@@ -57295,29 +57348,29 @@ function promptWindows(prompts, calls) {
|
|
|
57295
57348
|
const bySession2 = /* @__PURE__ */ new Map();
|
|
57296
57349
|
for (const p2 of prompts) {
|
|
57297
57350
|
if (!p2.sessionId) continue;
|
|
57298
|
-
const
|
|
57299
|
-
if (
|
|
57351
|
+
const list3 = bySession2.get(p2.sessionId);
|
|
57352
|
+
if (list3) list3.push(p2);
|
|
57300
57353
|
else bySession2.set(p2.sessionId, [p2]);
|
|
57301
57354
|
}
|
|
57302
|
-
for (const
|
|
57355
|
+
for (const list3 of bySession2.values()) list3.sort((a, b) => a.ts - b.ts || a.id - b.id);
|
|
57303
57356
|
const out = /* @__PURE__ */ new Map();
|
|
57304
57357
|
for (const p2 of prompts) out.set(p2.id, []);
|
|
57305
57358
|
for (const c of calls) {
|
|
57306
57359
|
if (c.sidechain) continue;
|
|
57307
|
-
const
|
|
57308
|
-
if (!
|
|
57360
|
+
const list3 = bySession2.get(c.session_id);
|
|
57361
|
+
if (!list3) continue;
|
|
57309
57362
|
let lo = 0;
|
|
57310
|
-
let hi =
|
|
57363
|
+
let hi = list3.length - 1;
|
|
57311
57364
|
let at = -1;
|
|
57312
57365
|
while (lo <= hi) {
|
|
57313
57366
|
const mid = lo + hi >> 1;
|
|
57314
|
-
if (
|
|
57367
|
+
if (list3[mid].ts <= c.ts) {
|
|
57315
57368
|
at = mid;
|
|
57316
57369
|
lo = mid + 1;
|
|
57317
57370
|
} else hi = mid - 1;
|
|
57318
57371
|
}
|
|
57319
57372
|
if (at < 0) continue;
|
|
57320
|
-
out.get(
|
|
57373
|
+
out.get(list3[at].id)?.push(c);
|
|
57321
57374
|
}
|
|
57322
57375
|
return out;
|
|
57323
57376
|
}
|
|
@@ -57666,8 +57719,8 @@ var Reconciler = class {
|
|
|
57666
57719
|
const m = /* @__PURE__ */ new Map();
|
|
57667
57720
|
for (const p2 of allRows(this.db, { surface: "prompt", since })) {
|
|
57668
57721
|
if (!p2.sessionId) continue;
|
|
57669
|
-
const
|
|
57670
|
-
if (
|
|
57722
|
+
const list3 = m.get(p2.sessionId);
|
|
57723
|
+
if (list3) list3.push(p2);
|
|
57671
57724
|
else m.set(p2.sessionId, [p2]);
|
|
57672
57725
|
}
|
|
57673
57726
|
this.promptsBySession = m;
|
|
@@ -57693,8 +57746,8 @@ var Reconciler = class {
|
|
|
57693
57746
|
const bySession2 = /* @__PURE__ */ new Map();
|
|
57694
57747
|
for (const r of targets) {
|
|
57695
57748
|
if (r.agentId || !r.sessionId) continue;
|
|
57696
|
-
const
|
|
57697
|
-
if (
|
|
57749
|
+
const list3 = bySession2.get(r.sessionId);
|
|
57750
|
+
if (list3) list3.push(r);
|
|
57698
57751
|
else bySession2.set(r.sessionId, [r]);
|
|
57699
57752
|
}
|
|
57700
57753
|
if (!bySession2.size) return;
|
|
@@ -57712,8 +57765,8 @@ var Reconciler = class {
|
|
|
57712
57765
|
const callsBy = /* @__PURE__ */ new Map();
|
|
57713
57766
|
for (const c of this.calls(sessionId)) {
|
|
57714
57767
|
if (!c.sidechain || !c.agent_id || this.taken.has(c.agent_id)) continue;
|
|
57715
|
-
const
|
|
57716
|
-
if (
|
|
57768
|
+
const list3 = callsBy.get(c.agent_id);
|
|
57769
|
+
if (list3) list3.push(c);
|
|
57717
57770
|
else callsBy.set(c.agent_id, [c]);
|
|
57718
57771
|
}
|
|
57719
57772
|
const agents = [...callsBy].map(([id, cs]) => ({
|
|
@@ -58611,7 +58664,7 @@ init_esm_shims();
|
|
|
58611
58664
|
init_esm_shims();
|
|
58612
58665
|
import { existsSync as existsSync10, readdirSync as readdirSync8, readFileSync as readFileSync12, statSync as statSync10 } from "fs";
|
|
58613
58666
|
import { homedir as homedir2 } from "os";
|
|
58614
|
-
import { basename as
|
|
58667
|
+
import { basename as basename4, dirname as dirname11, isAbsolute as isAbsolute5, join as join16, relative as relative11, resolve as resolve8 } from "path";
|
|
58615
58668
|
|
|
58616
58669
|
// src/swarm/agents.ts
|
|
58617
58670
|
init_esm_shims();
|
|
@@ -58827,6 +58880,70 @@ function existingGenerated(dir) {
|
|
|
58827
58880
|
}
|
|
58828
58881
|
return out;
|
|
58829
58882
|
}
|
|
58883
|
+
function ignoredWhere(ignored, config2, agentType) {
|
|
58884
|
+
const hit = config2.swarms.flatMap(
|
|
58885
|
+
(swarm) => swarm.roles.filter((r) => r.agentType === agentType).map((r) => ({ swarm, role: r }))
|
|
58886
|
+
)[0];
|
|
58887
|
+
if (!hit) return [];
|
|
58888
|
+
const out = [];
|
|
58889
|
+
for (const i of ignored) {
|
|
58890
|
+
const seg = i.path === "" ? [] : i.path.split(".");
|
|
58891
|
+
const name = /"(.+?)"/.exec(i.message)?.[1] ?? "?";
|
|
58892
|
+
const mine = seg[0] !== "swarms" || seg.length < 2 || seg[1] === hit.swarm.name && (seg.length < 4 || seg[2] !== "agents" || seg[3] === hit.role.role);
|
|
58893
|
+
if (mine) out.push(name);
|
|
58894
|
+
}
|
|
58895
|
+
return out;
|
|
58896
|
+
}
|
|
58897
|
+
var list2 = (v) => typeof v === "string" ? v.split(",").map((x) => x.trim()).filter(Boolean) : [];
|
|
58898
|
+
function frontmatterOf(raw) {
|
|
58899
|
+
const content = raw.replace(/\r\n/g, "\n");
|
|
58900
|
+
const end = content.indexOf("\n---\n", 3);
|
|
58901
|
+
if (!content.startsWith("---\n") || end === -1) return void 0;
|
|
58902
|
+
try {
|
|
58903
|
+
const v = yaml().parse(content.slice(4, end));
|
|
58904
|
+
return v && typeof v === "object" ? v : void 0;
|
|
58905
|
+
} catch {
|
|
58906
|
+
return void 0;
|
|
58907
|
+
}
|
|
58908
|
+
}
|
|
58909
|
+
var NEUTRAL_KEYS = /* @__PURE__ */ new Set(["name", "description", "skills", "color", "model", "effort"]);
|
|
58910
|
+
function tightens(oldRaw, newRaw) {
|
|
58911
|
+
const o = frontmatterOf(oldRaw);
|
|
58912
|
+
const n = frontmatterOf(newRaw);
|
|
58913
|
+
if (!o || !n) return false;
|
|
58914
|
+
let tighter = false;
|
|
58915
|
+
for (const k of Object.keys(o)) {
|
|
58916
|
+
if (NEUTRAL_KEYS.has(k)) continue;
|
|
58917
|
+
if (!(k in n)) return false;
|
|
58918
|
+
const a = o[k];
|
|
58919
|
+
const b = n[k];
|
|
58920
|
+
if (JSON.stringify(a) === JSON.stringify(b)) continue;
|
|
58921
|
+
if (k === "tools") {
|
|
58922
|
+
const ob = new Set(list2(a));
|
|
58923
|
+
const nb = list2(b);
|
|
58924
|
+
if (!nb.every((t) => ob.has(t))) return false;
|
|
58925
|
+
tighter = true;
|
|
58926
|
+
} else if (k === "disallowedTools") {
|
|
58927
|
+
const nb = new Set(list2(b));
|
|
58928
|
+
if (!list2(a).every((t) => nb.has(t))) return false;
|
|
58929
|
+
tighter = true;
|
|
58930
|
+
} else if (k === "hooks") {
|
|
58931
|
+
const oh = a ?? {};
|
|
58932
|
+
const nh = b ?? {};
|
|
58933
|
+
for (const [ev3, entries] of Object.entries(oh)) {
|
|
58934
|
+
const have = new Set((nh[ev3] ?? []).map((e) => JSON.stringify(e)));
|
|
58935
|
+
if (!Array.isArray(entries) || !entries.every((e) => have.has(JSON.stringify(e))))
|
|
58936
|
+
return false;
|
|
58937
|
+
}
|
|
58938
|
+
tighter = true;
|
|
58939
|
+
} else if (k === "maxTurns") {
|
|
58940
|
+
if (typeof a !== "number" || typeof b !== "number" || b > a) return false;
|
|
58941
|
+
tighter = true;
|
|
58942
|
+
} else return false;
|
|
58943
|
+
}
|
|
58944
|
+
for (const k of Object.keys(n)) if (!(k in o) && !NEUTRAL_KEYS.has(k)) tighter = true;
|
|
58945
|
+
return tighter;
|
|
58946
|
+
}
|
|
58830
58947
|
function planAgentSync(root, config2, opts = {}) {
|
|
58831
58948
|
const dir = agentsDir(root);
|
|
58832
58949
|
const wantedRoles = config2?.enabled ? config2.swarms.flatMap((swarm) => swarm.roles.map((role) => ({ swarm, role }))) : [];
|
|
@@ -58894,6 +59011,24 @@ function planAgentSync(root, config2, opts = {}) {
|
|
|
58894
59011
|
reason: config2?.enabled ? "no longer in the swarm file" : "swarms are disabled"
|
|
58895
59012
|
}
|
|
58896
59013
|
);
|
|
59014
|
+
const ignored = config2?.ignoredKeys ?? [];
|
|
59015
|
+
if (ignored.length && !opts.force) {
|
|
59016
|
+
const holds = (agentType) => ignoredWhere(ignored, config2, agentType);
|
|
59017
|
+
return actions.map((a) => {
|
|
59018
|
+
if (a.action !== "update") return a;
|
|
59019
|
+
const where = holds(a.agentType);
|
|
59020
|
+
if (!where.length) return a;
|
|
59021
|
+
const old = generated.get(a.agentType);
|
|
59022
|
+
if (old && tightens(old.content, a.content ?? "")) return a;
|
|
59023
|
+
return {
|
|
59024
|
+
agentType: a.agentType,
|
|
59025
|
+
path: a.path,
|
|
59026
|
+
action: "conflict",
|
|
59027
|
+
held: true,
|
|
59028
|
+
reason: `kept: ${config2.rel} has keys this eminiar version does not know (${where.slice(0, 3).join(", ")}${where.length > 3 ? ", ..." : ""}), and a newer one may have generated this file with them; update eminiar, or sync with --force`
|
|
59029
|
+
};
|
|
59030
|
+
});
|
|
59031
|
+
}
|
|
58897
59032
|
return actions;
|
|
58898
59033
|
}
|
|
58899
59034
|
function syncAgents(root, config2, opts = {}) {
|
|
@@ -59038,7 +59173,7 @@ function byName(dir, type) {
|
|
|
59038
59173
|
}
|
|
59039
59174
|
function shown(file3, home) {
|
|
59040
59175
|
const rel = relative11(home, file3);
|
|
59041
|
-
return rel && !rel.startsWith("..") && !
|
|
59176
|
+
return rel && !rel.startsWith("..") && !isAbsolute5(rel) ? join16("~", rel) : file3;
|
|
59042
59177
|
}
|
|
59043
59178
|
function decide(defs, source, home) {
|
|
59044
59179
|
const pins = new Set(defs.map((d) => isPinned(d.model) ? d.model.trim() : ""));
|
|
@@ -59076,7 +59211,7 @@ function projectDirs(root, cwd) {
|
|
|
59076
59211
|
const top2 = resolve8(root);
|
|
59077
59212
|
const inside = (d2) => {
|
|
59078
59213
|
const rel = relative11(top2, d2);
|
|
59079
|
-
return rel === "" || !rel.startsWith("..") && !
|
|
59214
|
+
return rel === "" || !rel.startsWith("..") && !isAbsolute5(rel);
|
|
59080
59215
|
};
|
|
59081
59216
|
let d = cwd && inside(resolve8(cwd)) ? resolve8(cwd) : top2;
|
|
59082
59217
|
const dirs = [];
|
|
@@ -59119,9 +59254,9 @@ function pluginDirs(plugin, env, home) {
|
|
|
59119
59254
|
const sep6 = process.platform === "win32" ? ";" : ":";
|
|
59120
59255
|
for (const raw of (env.CLAUDE_CODE_PLUGIN_DIRS ?? "").split(sep6)) {
|
|
59121
59256
|
const p2 = raw.trim().replace(/^~(?=$|[/\\])/, home);
|
|
59122
|
-
if (!p2 || !
|
|
59257
|
+
if (!p2 || !isAbsolute5(p2)) continue;
|
|
59123
59258
|
const name = manifest(p2)?.name;
|
|
59124
|
-
if ((typeof name === "string" ? name :
|
|
59259
|
+
if ((typeof name === "string" ? name : basename4(p2)) === plugin) out.add(p2);
|
|
59125
59260
|
}
|
|
59126
59261
|
return [...out];
|
|
59127
59262
|
}
|
|
@@ -59135,8 +59270,8 @@ function manifest(dir) {
|
|
|
59135
59270
|
}
|
|
59136
59271
|
function agentPaths(dir) {
|
|
59137
59272
|
const a = manifest(dir)?.agents;
|
|
59138
|
-
const
|
|
59139
|
-
return (
|
|
59273
|
+
const list3 = typeof a === "string" ? [a] : Array.isArray(a) ? a.filter((x) => typeof x === "string") : [];
|
|
59274
|
+
return (list3.length ? list3 : ["./agents"]).map((p2) => resolve8(dir, p2));
|
|
59140
59275
|
}
|
|
59141
59276
|
function pluginDefs(segments, env, home) {
|
|
59142
59277
|
const [plugin, ...rest] = segments;
|
|
@@ -59145,7 +59280,7 @@ function pluginDefs(segments, env, home) {
|
|
|
59145
59280
|
const installs = pluginDirs(plugin, env, home);
|
|
59146
59281
|
if (!installs.length) return `plugin ${plugin} is not installed where eminiar can see it`;
|
|
59147
59282
|
const defs = [];
|
|
59148
|
-
const matches2 = (d, file3) => !!d && (d.name === agent ||
|
|
59283
|
+
const matches2 = (d, file3) => !!d && (d.name === agent || basename4(file3, ".md") === agent);
|
|
59149
59284
|
for (const install of installs) {
|
|
59150
59285
|
for (const p2 of agentPaths(install)) {
|
|
59151
59286
|
let isDir = false;
|
|
@@ -59515,7 +59650,7 @@ init_esm_shims();
|
|
|
59515
59650
|
init_esm_shims();
|
|
59516
59651
|
import { randomBytes as randomBytes3 } from "crypto";
|
|
59517
59652
|
import { existsSync as existsSync12, statSync as statSync11 } from "fs";
|
|
59518
|
-
import { isAbsolute as
|
|
59653
|
+
import { isAbsolute as isAbsolute6, join as join18, relative as relative12 } from "path";
|
|
59519
59654
|
|
|
59520
59655
|
// src/swarm/config.ts
|
|
59521
59656
|
init_esm_shims();
|
|
@@ -59524,6 +59659,52 @@ import { existsSync as existsSync11, readFileSync as readFileSync13 } from "fs";
|
|
|
59524
59659
|
import { createRequire as createRequire2 } from "module";
|
|
59525
59660
|
import { join as join17 } from "path";
|
|
59526
59661
|
|
|
59662
|
+
// src/search/typo.ts
|
|
59663
|
+
init_esm_shims();
|
|
59664
|
+
function editDistance(a, b, max = 3) {
|
|
59665
|
+
if (Math.abs(a.length - b.length) > max) return max + 1;
|
|
59666
|
+
const prev2 = [];
|
|
59667
|
+
let prev = Array.from({ length: b.length + 1 }, (_, j) => j);
|
|
59668
|
+
let cur = new Array(b.length + 1).fill(0);
|
|
59669
|
+
for (let i = 1; i <= a.length; i++) {
|
|
59670
|
+
cur[0] = i;
|
|
59671
|
+
let rowMin = cur[0];
|
|
59672
|
+
for (let j = 1; j <= b.length; j++) {
|
|
59673
|
+
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
59674
|
+
let v = Math.min(prev[j] + 1, cur[j - 1] + 1, prev[j - 1] + cost);
|
|
59675
|
+
if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {
|
|
59676
|
+
v = Math.min(v, prev2[j - 2] + 1);
|
|
59677
|
+
}
|
|
59678
|
+
cur[j] = v;
|
|
59679
|
+
if (v < rowMin) rowMin = v;
|
|
59680
|
+
}
|
|
59681
|
+
if (rowMin > max) return max + 1;
|
|
59682
|
+
prev2.splice(0, prev2.length, ...prev);
|
|
59683
|
+
[prev, cur] = [cur, prev];
|
|
59684
|
+
}
|
|
59685
|
+
return prev[b.length];
|
|
59686
|
+
}
|
|
59687
|
+
function correctTerms(db, terms) {
|
|
59688
|
+
const corrections = [];
|
|
59689
|
+
const out = terms.map((term) => {
|
|
59690
|
+
if (term.length < 4 || /[^a-z0-9]/.test(term) || db.termExists(term)) return term;
|
|
59691
|
+
const max = term.length >= 7 ? 2 : 1;
|
|
59692
|
+
const candidates2 = db.vocabCandidates(term[0], 3e3);
|
|
59693
|
+
let best;
|
|
59694
|
+
for (const c of candidates2) {
|
|
59695
|
+
if (c.term.length < 3) continue;
|
|
59696
|
+
const d = editDistance(term, c.term, max);
|
|
59697
|
+
if (d > max) continue;
|
|
59698
|
+
if (!best || d < best.d || d === best.d && c.df > best.df)
|
|
59699
|
+
best = { term: c.term, d, df: c.df };
|
|
59700
|
+
}
|
|
59701
|
+
if (!best) return term;
|
|
59702
|
+
corrections.push({ from: term, to: best.term });
|
|
59703
|
+
return `${best.term}*`;
|
|
59704
|
+
});
|
|
59705
|
+
return { terms: out, corrections };
|
|
59706
|
+
}
|
|
59707
|
+
|
|
59527
59708
|
// src/swarm/glob.ts
|
|
59528
59709
|
init_esm_shims();
|
|
59529
59710
|
var MAX_EXPANSIONS = 64;
|
|
@@ -59703,15 +59884,6 @@ var NAME_MSG = "use 1-32 characters: lowercase letters and digits in words joine
|
|
|
59703
59884
|
var noFence = (s) => !s.includes("---");
|
|
59704
59885
|
var FENCE_MSG = 'must not contain "---" (Claude Code would end the agent frontmatter there)';
|
|
59705
59886
|
var MODEL_RE = /^(?:inherit|opusplan|(?:sonnet|opus|haiku|fable)(?:\[1m\])?|(?:[a-z0-9-]+\.)*claude-[a-z0-9.:@-]+(?:\[1m\])?)$/;
|
|
59706
|
-
var TOP_KEYS = /* @__PURE__ */ new Set([
|
|
59707
|
-
"version",
|
|
59708
|
-
"enabled",
|
|
59709
|
-
"sync",
|
|
59710
|
-
"enforce",
|
|
59711
|
-
"allowed_agents",
|
|
59712
|
-
"defaults",
|
|
59713
|
-
"swarms"
|
|
59714
|
-
]);
|
|
59715
59887
|
var DEFAULT_CONTEXT = {
|
|
59716
59888
|
memories: 4,
|
|
59717
59889
|
docs: 2,
|
|
@@ -59740,7 +59912,7 @@ var SkillName = external_exports.string().regex(
|
|
|
59740
59912
|
).refine(noFence, FENCE_MSG);
|
|
59741
59913
|
var Model = external_exports.string().max(100).regex(MODEL_RE, "a model alias (inherit, sonnet, opus, haiku, fable) or a Claude model id").refine(noFence, FENCE_MSG);
|
|
59742
59914
|
var rank = (t) => TIERS.indexOf(t);
|
|
59743
|
-
var RawModelRange = external_exports.
|
|
59915
|
+
var RawModelRange = external_exports.object({ floor: external_exports.enum(TIERS).optional(), ceiling: external_exports.enum(TIERS).optional() }).refine(
|
|
59744
59916
|
(r) => !r.floor || !r.ceiling || rank(r.floor) <= rank(r.ceiling),
|
|
59745
59917
|
`floor must not be above ceiling (${TIERS.join(" < ")})`
|
|
59746
59918
|
);
|
|
@@ -59764,7 +59936,7 @@ var AgentName = external_exports.string().trim().regex(
|
|
|
59764
59936
|
(n) => !n.startsWith("swarm-"),
|
|
59765
59937
|
"swarm workers need no entry: they are allowed during a run of their swarm"
|
|
59766
59938
|
);
|
|
59767
|
-
var RawContext = external_exports.
|
|
59939
|
+
var RawContext = external_exports.object({
|
|
59768
59940
|
memories: external_exports.number().int().min(0).max(10).optional(),
|
|
59769
59941
|
docs: external_exports.number().int().min(0).max(10).optional(),
|
|
59770
59942
|
history: external_exports.boolean().optional(),
|
|
@@ -59773,12 +59945,12 @@ var RawContext = external_exports.strictObject({
|
|
|
59773
59945
|
// SubagentStart context over 10,000 characters is moved to a file Claude may never read.
|
|
59774
59946
|
max_chars: external_exports.number().int().min(500).max(9e3).optional()
|
|
59775
59947
|
});
|
|
59776
|
-
var RawHookCommand = external_exports.
|
|
59948
|
+
var RawHookCommand = external_exports.object({
|
|
59777
59949
|
type: external_exports.literal("command"),
|
|
59778
59950
|
command: external_exports.string().trim().min(1).max(2e3).refine(noFence, FENCE_MSG),
|
|
59779
59951
|
timeout: external_exports.number().int().positive().max(600).optional()
|
|
59780
59952
|
});
|
|
59781
|
-
var RawHookMatcher = external_exports.
|
|
59953
|
+
var RawHookMatcher = external_exports.object({
|
|
59782
59954
|
matcher: external_exports.string().max(200).refine(noFence, FENCE_MSG).refine((m) => {
|
|
59783
59955
|
try {
|
|
59784
59956
|
new RegExp(m);
|
|
@@ -59789,12 +59961,12 @@ var RawHookMatcher = external_exports.strictObject({
|
|
|
59789
59961
|
}, "not a valid regular expression (Claude Code matches tool names with it)").optional(),
|
|
59790
59962
|
hooks: external_exports.array(RawHookCommand).min(1).max(10)
|
|
59791
59963
|
});
|
|
59792
|
-
var RawHooks = external_exports.
|
|
59964
|
+
var RawHooks = external_exports.object({
|
|
59793
59965
|
PreToolUse: external_exports.array(RawHookMatcher).max(10).optional(),
|
|
59794
59966
|
PostToolUse: external_exports.array(RawHookMatcher).max(10).optional(),
|
|
59795
59967
|
Stop: external_exports.array(RawHookMatcher).max(10).optional()
|
|
59796
59968
|
});
|
|
59797
|
-
var RawAgent = external_exports.
|
|
59969
|
+
var RawAgent = external_exports.object({
|
|
59798
59970
|
description: external_exports.string().trim().min(1).max(500).refine(noFence, FENCE_MSG),
|
|
59799
59971
|
prompt: external_exports.string().max(2e4).optional(),
|
|
59800
59972
|
model: Model.optional(),
|
|
@@ -59812,7 +59984,7 @@ var RawAgent = external_exports.strictObject({
|
|
|
59812
59984
|
color: external_exports.enum(AGENT_COLORS).optional(),
|
|
59813
59985
|
context: RawContext.optional()
|
|
59814
59986
|
});
|
|
59815
|
-
var RawSwarm = external_exports.
|
|
59987
|
+
var RawSwarm = external_exports.object({
|
|
59816
59988
|
description: external_exports.string().trim().min(1).max(500),
|
|
59817
59989
|
topology: external_exports.enum(TOPOLOGIES).optional(),
|
|
59818
59990
|
max_agents: external_exports.number().int().min(1).max(16).optional(),
|
|
@@ -59828,7 +60000,7 @@ var RawFile = external_exports.looseObject({
|
|
|
59828
60000
|
sync: external_exports.enum(["auto", "manual"]).optional(),
|
|
59829
60001
|
enforce: external_exports.boolean().optional(),
|
|
59830
60002
|
allowed_agents: external_exports.array(AgentName).max(50).optional(),
|
|
59831
|
-
defaults: external_exports.
|
|
60003
|
+
defaults: external_exports.object({
|
|
59832
60004
|
model: Model.optional(),
|
|
59833
60005
|
model_range: RawModelRange.optional(),
|
|
59834
60006
|
skills: external_exports.array(SkillName).max(20).optional(),
|
|
@@ -59853,6 +60025,53 @@ function mergeContext(...layers) {
|
|
|
59853
60025
|
return out;
|
|
59854
60026
|
}
|
|
59855
60027
|
var uniq = (xs) => [...new Set(xs)];
|
|
60028
|
+
function unknownKeys(v, s = RawFile, at = []) {
|
|
60029
|
+
if (s instanceof external_exports.ZodOptional) s = s.unwrap();
|
|
60030
|
+
if (Array.isArray(v))
|
|
60031
|
+
return s instanceof external_exports.ZodArray ? v.flatMap((x, i) => unknownKeys(x, s.element, [...at, String(i)])) : [];
|
|
60032
|
+
if (!v || typeof v !== "object") return [];
|
|
60033
|
+
const entries = Object.entries(v);
|
|
60034
|
+
if (s instanceof external_exports.ZodRecord)
|
|
60035
|
+
return entries.flatMap(([k, x]) => unknownKeys(x, s.valueType, [...at, k]));
|
|
60036
|
+
if (!(s instanceof external_exports.ZodObject)) return [];
|
|
60037
|
+
const known = Object.keys(s.shape);
|
|
60038
|
+
return entries.flatMap(
|
|
60039
|
+
([k, x]) => Object.hasOwn(s.shape, k) ? unknownKeys(x, s.shape[k], [...at, k]) : at.length === 0 && (k.startsWith("x-") || k === "<<") ? [] : [{ at, key: k, known }]
|
|
60040
|
+
);
|
|
60041
|
+
}
|
|
60042
|
+
function schemaKeys(s = RawFile, out = /* @__PURE__ */ new Set()) {
|
|
60043
|
+
if (s instanceof external_exports.ZodOptional) s = s.unwrap();
|
|
60044
|
+
if (s instanceof external_exports.ZodArray) schemaKeys(s.element, out);
|
|
60045
|
+
else if (s instanceof external_exports.ZodRecord) schemaKeys(s.valueType, out);
|
|
60046
|
+
else if (s instanceof external_exports.ZodObject) {
|
|
60047
|
+
for (const [k, v] of Object.entries(s.shape))
|
|
60048
|
+
if (!out.has(k)) {
|
|
60049
|
+
out.add(k);
|
|
60050
|
+
schemaKeys(v, out);
|
|
60051
|
+
}
|
|
60052
|
+
}
|
|
60053
|
+
return out;
|
|
60054
|
+
}
|
|
60055
|
+
var RESTRICTION_KEY = /tool|scope|hook|allow|deny|permission|model|effort|count/i;
|
|
60056
|
+
function restrictionLike(key, known) {
|
|
60057
|
+
let best;
|
|
60058
|
+
for (const k of known) {
|
|
60059
|
+
if (!RESTRICTION_KEY.test(k)) continue;
|
|
60060
|
+
const d = editDistance(key.toLowerCase(), k.toLowerCase(), 2);
|
|
60061
|
+
if (d <= 2 && key.length >= 3 && (!best || d < best.d)) best = { k, d };
|
|
60062
|
+
}
|
|
60063
|
+
if (best) return best.k;
|
|
60064
|
+
return RESTRICTION_KEY.test(key) ? "" : void 0;
|
|
60065
|
+
}
|
|
60066
|
+
function typoOf(key, known) {
|
|
60067
|
+
const max = key.length >= 7 ? 2 : 1;
|
|
60068
|
+
let best;
|
|
60069
|
+
for (const k of known) {
|
|
60070
|
+
const d = editDistance(key.toLowerCase(), k.toLowerCase(), max);
|
|
60071
|
+
if (d <= max && (!best || d < best.d)) best = { k, d };
|
|
60072
|
+
}
|
|
60073
|
+
return best?.k;
|
|
60074
|
+
}
|
|
59856
60075
|
function roleRange(defaults, a, at, issue2) {
|
|
59857
60076
|
const spec = a.model_range ?? defaults?.model_range;
|
|
59858
60077
|
if (!spec || !spec.floor && !spec.ceiling) return void 0;
|
|
@@ -59988,6 +60207,27 @@ function parseSwarmYaml(text2, file3, rel) {
|
|
|
59988
60207
|
for (const role of Object.keys(agents))
|
|
59989
60208
|
checkName(["swarms", name, "agents", role], role, "agent");
|
|
59990
60209
|
}
|
|
60210
|
+
const ignoredKeys = [];
|
|
60211
|
+
const allKeys = schemaKeys();
|
|
60212
|
+
for (const u of unknownKeys(js)) {
|
|
60213
|
+
const near = typoOf(u.key, u.known);
|
|
60214
|
+
const found = { path: u.at.join("."), line: lineOf([...u.at, u.key]) };
|
|
60215
|
+
if (allKeys.has(u.key))
|
|
60216
|
+
issues.push({ ...found, message: `unknown key "${u.key}": not allowed here` });
|
|
60217
|
+
else if (near)
|
|
60218
|
+
issues.push({ ...found, message: `unknown key "${u.key}" (did you mean "${near}"?)` });
|
|
60219
|
+
else if (u.at.length === 4 && u.at[0] === "swarms" && u.at[2] === "agents" && restrictionLike(u.key, u.known) !== void 0) {
|
|
60220
|
+
const like = restrictionLike(u.key, u.known);
|
|
60221
|
+
issues.push({
|
|
60222
|
+
...found,
|
|
60223
|
+
message: `unknown key "${u.key}" looks like a restriction${like ? ` (did you mean "${like}"?)` : ""}: ignoring it would silently drop a limit`
|
|
60224
|
+
});
|
|
60225
|
+
} else
|
|
60226
|
+
ignoredKeys.push({
|
|
60227
|
+
...found,
|
|
60228
|
+
message: `unknown key "${u.key}" ignored: not a setting in this eminiar version`
|
|
60229
|
+
});
|
|
60230
|
+
}
|
|
59991
60231
|
const parsed = RawFile.safeParse(js);
|
|
59992
60232
|
if (!parsed.success) {
|
|
59993
60233
|
return {
|
|
@@ -60005,15 +60245,9 @@ function parseSwarmYaml(text2, file3, rel) {
|
|
|
60005
60245
|
]
|
|
60006
60246
|
};
|
|
60007
60247
|
}
|
|
60008
|
-
for (const k of Object.keys(js))
|
|
60009
|
-
if (!TOP_KEYS.has(k) && !k.startsWith("x-") && k !== "<<")
|
|
60010
|
-
issue2(
|
|
60011
|
-
[k],
|
|
60012
|
-
`unknown key "${k}" (top-level keys: ${[...TOP_KEYS].join(", ")}; x-* keys may hold YAML anchors)`
|
|
60013
|
-
);
|
|
60014
60248
|
const config2 = resolve9(parsed.data, file3, rel, issue2);
|
|
60015
60249
|
if (issues.length) return { state: "invalid", file: file3, rel, enforce, issues };
|
|
60016
|
-
return { state: "ok", config: config2 };
|
|
60250
|
+
return { state: "ok", config: { ...config2, ignoredKeys } };
|
|
60017
60251
|
}
|
|
60018
60252
|
function resolve9(raw, file3, rel, issue2) {
|
|
60019
60253
|
const swarms = [];
|
|
@@ -60239,7 +60473,7 @@ function requireActive(db, run) {
|
|
|
60239
60473
|
}
|
|
60240
60474
|
function relPath(root, p2) {
|
|
60241
60475
|
let s = p2.trim().replace(/\\/g, "/");
|
|
60242
|
-
if (!
|
|
60476
|
+
if (!isAbsolute6(s)) {
|
|
60243
60477
|
while (s.startsWith("./")) s = s.slice(2);
|
|
60244
60478
|
return s;
|
|
60245
60479
|
}
|
|
@@ -60743,6 +60977,7 @@ function formatSwarmList(config2, plan, active, opts = {}) {
|
|
|
60743
60977
|
const lines = [
|
|
60744
60978
|
`eminiar swarms \xB7 ${config2.rel} \xB7 sync ${config2.sync}${enforceNote(config2)} \xB7 agent files: ${fileSummary || "none"}`
|
|
60745
60979
|
];
|
|
60980
|
+
if (config2.ignoredKeys.length) lines.push(formatIssues(config2.rel, config2.ignoredKeys));
|
|
60746
60981
|
if (opts.swarm && !swarms.length)
|
|
60747
60982
|
lines.push(
|
|
60748
60983
|
`No swarm "${opts.swarm}"; ${config2.rel} defines: ${config2.swarms.map((s) => s.name).join(", ")}`
|
|
@@ -60808,6 +61043,11 @@ function formatSync(result, opts = {}) {
|
|
|
60808
61043
|
` ${SYNC_VERB[a.action].mark} ${word(a.action)} ${a.path}${a.reason ? `: ${a.reason}` : ""}`
|
|
60809
61044
|
);
|
|
60810
61045
|
}
|
|
61046
|
+
const held = result.actions.filter((a) => a.held).length;
|
|
61047
|
+
if (held)
|
|
61048
|
+
lines.push(
|
|
61049
|
+
`${held} update(s) held: the swarm file has keys this eminiar version does not know, so those agent files were not rewritten (an update that only tightens a file still applies). Update eminiar, or run \`eminiar swarm sync --force\`.`
|
|
61050
|
+
);
|
|
60811
61051
|
if (!opts.dryRun && result.actions.some((a) => a.action === "create"))
|
|
60812
61052
|
lines.push(
|
|
60813
61053
|
"Claude Code reads agent files when a session starts: if a new worker type is not available yet, open /agents or restart the session."
|
|
@@ -61255,8 +61495,8 @@ function groupBy(calls, keyFn) {
|
|
|
61255
61495
|
if (!isRealCall(c)) continue;
|
|
61256
61496
|
const k = keyFn(c);
|
|
61257
61497
|
if (k == null) continue;
|
|
61258
|
-
const
|
|
61259
|
-
if (
|
|
61498
|
+
const list3 = buckets.get(k);
|
|
61499
|
+
if (list3) list3.push(c);
|
|
61260
61500
|
else buckets.set(k, [c]);
|
|
61261
61501
|
}
|
|
61262
61502
|
return [...buckets.entries()].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([key, rows]) => ({ key, totals: totals(rows) }));
|
|
@@ -61403,7 +61643,7 @@ function topToolConsumers(toolUses, limit = 10) {
|
|
|
61403
61643
|
init_esm_shims();
|
|
61404
61644
|
import { createHash as createHash10 } from "crypto";
|
|
61405
61645
|
import { closeSync as closeSync2, existsSync as existsSync13, openSync as openSync2, readdirSync as readdirSync9, readSync as readSync2, statSync as statSync13 } from "fs";
|
|
61406
|
-
import { basename as
|
|
61646
|
+
import { basename as basename5, dirname as dirname12, join as join20, resolve as resolve10, sep as sep4 } from "path";
|
|
61407
61647
|
|
|
61408
61648
|
// src/usage/transcript.ts
|
|
61409
61649
|
init_esm_shims();
|
|
@@ -61710,8 +61950,8 @@ function byteAt(path3, pos) {
|
|
|
61710
61950
|
}
|
|
61711
61951
|
function sessionIdFromName(path3) {
|
|
61712
61952
|
const dir = dirname12(path3);
|
|
61713
|
-
if (
|
|
61714
|
-
const name =
|
|
61953
|
+
if (basename5(dir) === "subagents") return basename5(dirname12(dir));
|
|
61954
|
+
const name = basename5(path3, ".jsonl");
|
|
61715
61955
|
return name.startsWith("agent-") ? void 0 : name;
|
|
61716
61956
|
}
|
|
61717
61957
|
function contextEventExists(db, e) {
|
|
@@ -61842,7 +62082,7 @@ function sidechainFilesFor(db, dir, sessionId) {
|
|
|
61842
62082
|
const inside = (p2) => insideDir(p2, dir) && p2.endsWith(".jsonl");
|
|
61843
62083
|
const out = listJsonl(join20(dir, sessionId, "subagents")).filter(inside);
|
|
61844
62084
|
for (const path3 of listJsonl(dir)) {
|
|
61845
|
-
if (!inside(path3) || !
|
|
62085
|
+
if (!inside(path3) || !basename5(path3).startsWith("agent-")) continue;
|
|
61846
62086
|
const known = db.transcriptFileGet(path3)?.session_id;
|
|
61847
62087
|
let owner = known ?? void 0;
|
|
61848
62088
|
if (!owner) {
|
|
@@ -61953,18 +62193,18 @@ function threads(calls) {
|
|
|
61953
62193
|
const out = /* @__PURE__ */ new Map();
|
|
61954
62194
|
for (const c of calls) {
|
|
61955
62195
|
const key = `${c.session_id}\0${c.sidechain ? c.agent_id ?? "sidechain" : ""}`;
|
|
61956
|
-
const
|
|
61957
|
-
if (
|
|
62196
|
+
const list3 = out.get(key);
|
|
62197
|
+
if (list3) list3.push(c);
|
|
61958
62198
|
else out.set(key, [c]);
|
|
61959
62199
|
}
|
|
61960
|
-
for (const
|
|
62200
|
+
for (const list3 of out.values()) list3.sort((a, b) => a.ts - b.ts);
|
|
61961
62201
|
return out;
|
|
61962
62202
|
}
|
|
61963
62203
|
function groupBySession(rows) {
|
|
61964
62204
|
const out = /* @__PURE__ */ new Map();
|
|
61965
62205
|
for (const r of rows) {
|
|
61966
|
-
const
|
|
61967
|
-
if (
|
|
62206
|
+
const list3 = out.get(r.session_id);
|
|
62207
|
+
if (list3) list3.push(r);
|
|
61968
62208
|
else out.set(r.session_id, [r]);
|
|
61969
62209
|
}
|
|
61970
62210
|
return out;
|
|
@@ -61996,9 +62236,9 @@ function withScope(base, sessionIds) {
|
|
|
61996
62236
|
}
|
|
61997
62237
|
var SEVERITY_RANK = { high: 0, warn: 1, info: 2 };
|
|
61998
62238
|
function hasCompactionBetween(ctx, sessionId, from, to) {
|
|
61999
|
-
const
|
|
62000
|
-
if (!
|
|
62001
|
-
return
|
|
62239
|
+
const list3 = ctx.compactionsBySession.get(sessionId);
|
|
62240
|
+
if (!list3) return false;
|
|
62241
|
+
return list3.some((t) => t > from && t <= to);
|
|
62002
62242
|
}
|
|
62003
62243
|
function detectCacheThrash(ctx) {
|
|
62004
62244
|
let runs = 0;
|
|
@@ -62006,7 +62246,7 @@ function detectCacheThrash(ctx) {
|
|
|
62006
62246
|
let rewritten = 0;
|
|
62007
62247
|
let savings = 0;
|
|
62008
62248
|
const sessions = /* @__PURE__ */ new Set();
|
|
62009
|
-
for (const
|
|
62249
|
+
for (const list3 of ctx.threads.values()) {
|
|
62010
62250
|
let run = [];
|
|
62011
62251
|
const flush = () => {
|
|
62012
62252
|
if (run.length >= THRASH_RUN) {
|
|
@@ -62022,12 +62262,12 @@ function detectCacheThrash(ctx) {
|
|
|
62022
62262
|
}
|
|
62023
62263
|
run = [];
|
|
62024
62264
|
};
|
|
62025
|
-
for (let i = 1; i <
|
|
62026
|
-
const c =
|
|
62027
|
-
const prev =
|
|
62265
|
+
for (let i = 1; i < list3.length; i++) {
|
|
62266
|
+
const c = list3[i];
|
|
62267
|
+
const prev = list3[i - 1];
|
|
62028
62268
|
const ctxTokens = contextOf(c);
|
|
62029
62269
|
const heavy = ctxTokens > 0 && writesOf(c) / ctxTokens >= THRASH_WRITE_SHARE;
|
|
62030
|
-
const broken = hasCompactionBetween(ctx, c.session_id, prev.ts, c.ts) || c.ts - prev.ts > ttlFor(
|
|
62270
|
+
const broken = hasCompactionBetween(ctx, c.session_id, prev.ts, c.ts) || c.ts - prev.ts > ttlFor(list3);
|
|
62031
62271
|
if (!heavy || broken) {
|
|
62032
62272
|
flush();
|
|
62033
62273
|
continue;
|
|
@@ -62050,10 +62290,10 @@ function detectCacheThrash(ctx) {
|
|
|
62050
62290
|
sessions
|
|
62051
62291
|
);
|
|
62052
62292
|
}
|
|
62053
|
-
function ttlFor(
|
|
62293
|
+
function ttlFor(list3) {
|
|
62054
62294
|
let w5 = 0;
|
|
62055
62295
|
let w1 = 0;
|
|
62056
|
-
for (const c of
|
|
62296
|
+
for (const c of list3) {
|
|
62057
62297
|
w5 += num4(c.cache_create_5m);
|
|
62058
62298
|
w1 += num4(c.cache_create_1h);
|
|
62059
62299
|
}
|
|
@@ -62065,11 +62305,11 @@ function detectCacheCold(ctx) {
|
|
|
62065
62305
|
let savings = 0;
|
|
62066
62306
|
let longestGap = 0;
|
|
62067
62307
|
const sessions = /* @__PURE__ */ new Set();
|
|
62068
|
-
for (const
|
|
62069
|
-
const ttl = ttlFor(
|
|
62070
|
-
for (let i = 1; i <
|
|
62071
|
-
const c =
|
|
62072
|
-
const prev =
|
|
62308
|
+
for (const list3 of ctx.threads.values()) {
|
|
62309
|
+
const ttl = ttlFor(list3);
|
|
62310
|
+
for (let i = 1; i < list3.length; i++) {
|
|
62311
|
+
const c = list3[i];
|
|
62312
|
+
const prev = list3[i - 1];
|
|
62073
62313
|
const gap = c.ts - prev.ts;
|
|
62074
62314
|
if (gap <= ttl) continue;
|
|
62075
62315
|
if (hasCompactionBetween(ctx, c.session_id, prev.ts, c.ts)) continue;
|
|
@@ -62345,15 +62585,15 @@ function detectErrorLoop(ctx) {
|
|
|
62345
62585
|
const byThread = /* @__PURE__ */ new Map();
|
|
62346
62586
|
for (const u of ctx.toolUses) {
|
|
62347
62587
|
const key = `${u.session_id}\0${u.agent_id ?? ""}`;
|
|
62348
|
-
const
|
|
62349
|
-
if (
|
|
62588
|
+
const list3 = byThread.get(key);
|
|
62589
|
+
if (list3) list3.push(u);
|
|
62350
62590
|
else byThread.set(key, [u]);
|
|
62351
62591
|
}
|
|
62352
|
-
for (const
|
|
62353
|
-
|
|
62592
|
+
for (const list3 of byThread.values()) {
|
|
62593
|
+
list3.sort((a, b) => a.ts - b.ts);
|
|
62354
62594
|
let run = 0;
|
|
62355
62595
|
let tool = "";
|
|
62356
|
-
for (const u of
|
|
62596
|
+
for (const u of list3) {
|
|
62357
62597
|
if (u.is_error && u.tool === tool) run += 1;
|
|
62358
62598
|
else {
|
|
62359
62599
|
run = u.is_error ? 1 : 0;
|
|
@@ -62591,11 +62831,11 @@ function detectInsights(input2) {
|
|
|
62591
62831
|
const calls = input2.calls.filter(isRealCall);
|
|
62592
62832
|
const compactionsBySession = /* @__PURE__ */ new Map();
|
|
62593
62833
|
for (const e of input2.contextEvents) {
|
|
62594
|
-
const
|
|
62595
|
-
if (
|
|
62834
|
+
const list3 = compactionsBySession.get(e.session_id);
|
|
62835
|
+
if (list3) list3.push(e.ts);
|
|
62596
62836
|
else compactionsBySession.set(e.session_id, [e.ts]);
|
|
62597
62837
|
}
|
|
62598
|
-
for (const
|
|
62838
|
+
for (const list3 of compactionsBySession.values()) list3.sort((a, b) => a - b);
|
|
62599
62839
|
const callTs = /* @__PURE__ */ new Map();
|
|
62600
62840
|
for (const [sid, rows] of groupBySession(calls))
|
|
62601
62841
|
callTs.set(
|
|
@@ -62782,8 +63022,8 @@ function periods(calls, keyFn) {
|
|
|
62782
63022
|
const buckets = /* @__PURE__ */ new Map();
|
|
62783
63023
|
for (const c of calls) {
|
|
62784
63024
|
const k = keyFn(c.ts);
|
|
62785
|
-
const
|
|
62786
|
-
if (
|
|
63025
|
+
const list3 = buckets.get(k);
|
|
63026
|
+
if (list3) list3.push(c);
|
|
62787
63027
|
else buckets.set(k, [c]);
|
|
62788
63028
|
}
|
|
62789
63029
|
return [...buckets.entries()].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([key, rows]) => ({ key, totals: totals(rows), models: modelSlices(rows) }));
|
|
@@ -62814,8 +63054,8 @@ function insightsFor(ctx, data) {
|
|
|
62814
63054
|
return { insights: r.insights, scores: r.scores };
|
|
62815
63055
|
}
|
|
62816
63056
|
var SEVERITY_RANK2 = { high: 0, warn: 1, info: 2 };
|
|
62817
|
-
function sortInsights(
|
|
62818
|
-
return
|
|
63057
|
+
function sortInsights(list3) {
|
|
63058
|
+
return list3.slice().sort(
|
|
62819
63059
|
(a, b) => SEVERITY_RANK2[a.severity] - SEVERITY_RANK2[b.severity] || (b.estimatedSavingsUsd ?? 0) - (a.estimatedSavingsUsd ?? 0)
|
|
62820
63060
|
);
|
|
62821
63061
|
}
|
|
@@ -63550,10 +63790,10 @@ function impact(db, ref, opts = {}) {
|
|
|
63550
63790
|
add3(e.dst, e.weight, 1, `co-changed ${meta4.count ?? "?"}\xD7 (${Math.round(e.weight * 100)}%)`);
|
|
63551
63791
|
}
|
|
63552
63792
|
}
|
|
63553
|
-
const
|
|
63554
|
-
const nodes = new Map(db.graphGetNodes(
|
|
63555
|
-
for (const h of
|
|
63556
|
-
return { root, hits:
|
|
63793
|
+
const list3 = [...hits.values()].sort((a, b) => b.score - a.score);
|
|
63794
|
+
const nodes = new Map(db.graphGetNodes(list3.map((h) => h.id)).map((n) => [n.id, n]));
|
|
63795
|
+
for (const h of list3) h.node = nodes.get(h.id);
|
|
63796
|
+
return { root, hits: list3 };
|
|
63557
63797
|
}
|
|
63558
63798
|
function dependencies(db, ref, depth = 1) {
|
|
63559
63799
|
const root = resolveNode(db, ref);
|
|
@@ -63580,10 +63820,10 @@ function dependencies(db, ref, depth = 1) {
|
|
|
63580
63820
|
frontier = next;
|
|
63581
63821
|
if (!frontier.length) break;
|
|
63582
63822
|
}
|
|
63583
|
-
const
|
|
63584
|
-
const nodes = new Map(db.graphGetNodes(
|
|
63585
|
-
for (const h of
|
|
63586
|
-
return { root, hits:
|
|
63823
|
+
const list3 = [...hits.values()].sort((a, b) => b.score - a.score);
|
|
63824
|
+
const nodes = new Map(db.graphGetNodes(list3.map((h) => h.id)).map((n) => [n.id, n]));
|
|
63825
|
+
for (const h of list3) h.node = nodes.get(h.id);
|
|
63826
|
+
return { root, hits: list3 };
|
|
63587
63827
|
}
|
|
63588
63828
|
function neighbors(db, ref, depth = 1, kinds) {
|
|
63589
63829
|
const root = resolveNode(db, ref);
|
|
@@ -64394,10 +64634,10 @@ function loadPermissionRules(root, extraDeny = []) {
|
|
|
64394
64634
|
const hit = cache5.get(key);
|
|
64395
64635
|
if (hit?.stamps.every((s, i) => s === stamps[i])) return hit.rules;
|
|
64396
64636
|
const out = { allow: [], deny: [], ask: [], root };
|
|
64397
|
-
const push = (
|
|
64637
|
+
const push = (list3, raws) => {
|
|
64398
64638
|
for (const raw of raws ?? []) {
|
|
64399
64639
|
const r = parseRule(raw);
|
|
64400
|
-
if (r)
|
|
64640
|
+
if (r) list3.push(r);
|
|
64401
64641
|
}
|
|
64402
64642
|
};
|
|
64403
64643
|
for (const f of files) {
|
|
@@ -64444,7 +64684,7 @@ function checkReadPath(rules, abs) {
|
|
|
64444
64684
|
// src/sandbox/file.ts
|
|
64445
64685
|
init_esm_shims();
|
|
64446
64686
|
import { existsSync as existsSync16, realpathSync as realpathSync9 } from "fs";
|
|
64447
|
-
import { isAbsolute as
|
|
64687
|
+
import { isAbsolute as isAbsolute7, relative as relative13, resolve as resolve11 } from "path";
|
|
64448
64688
|
function confinePath(root, target2, given) {
|
|
64449
64689
|
const abs = resolve11(root, target2);
|
|
64450
64690
|
const rules = given.root ? given : { ...given, root };
|
|
@@ -64457,7 +64697,7 @@ function confinePath(root, target2, given) {
|
|
|
64457
64697
|
}
|
|
64458
64698
|
refuse(checkReadPath(rules, abs), target2);
|
|
64459
64699
|
const rel = relative13(root, real);
|
|
64460
|
-
const inside = rel !== "" && !rel.startsWith("..") && !
|
|
64700
|
+
const inside = rel !== "" && !rel.startsWith("..") && !isAbsolute7(rel);
|
|
64461
64701
|
if (inside) return real;
|
|
64462
64702
|
if (readMatcher(rules.allow, rules.root).test(real)) return real;
|
|
64463
64703
|
throw new Error(
|
|
@@ -65488,19 +65728,19 @@ function mergedCatalog(extra) {
|
|
|
65488
65728
|
function catalogLookup(kind, key, catalog = CATALOG) {
|
|
65489
65729
|
const k = key.trim();
|
|
65490
65730
|
for (const e of catalog) {
|
|
65491
|
-
const
|
|
65492
|
-
if (!
|
|
65731
|
+
const list3 = kind === "api" ? e.hosts : e[kind];
|
|
65732
|
+
if (!list3) continue;
|
|
65493
65733
|
if (kind === "env") {
|
|
65494
|
-
if (
|
|
65734
|
+
if (list3.some((p2) => envMatches(p2, k))) return e;
|
|
65495
65735
|
} else if (kind === "api") {
|
|
65496
65736
|
const host = k.toLowerCase();
|
|
65497
|
-
if (
|
|
65737
|
+
if (list3.some((h) => host === h || host.endsWith(`.${h}`))) return e;
|
|
65498
65738
|
} else if (kind === "image") {
|
|
65499
65739
|
const bare = k.split(":")[0].replace(/^docker\.io\/(library\/)?/, "");
|
|
65500
|
-
if (
|
|
65740
|
+
if (list3.some((p2) => matches(p2, bare))) return e;
|
|
65501
65741
|
} else if (kind === "go") {
|
|
65502
|
-
if (
|
|
65503
|
-
} else if (
|
|
65742
|
+
if (list3.some((p2) => k === p2 || k.startsWith(p2))) return e;
|
|
65743
|
+
} else if (list3.some((p2) => matches(p2, k))) return e;
|
|
65504
65744
|
}
|
|
65505
65745
|
return void 0;
|
|
65506
65746
|
}
|
|
@@ -65882,9 +66122,9 @@ function schemaSummary(doc, schema2, depth = 0) {
|
|
|
65882
66122
|
if (Array.isArray(s.enum))
|
|
65883
66123
|
return `enum(${s.enum.slice(0, 8).map(String).join(", ")}${s.enum.length > 8 ? ", \u2026" : ""})`;
|
|
65884
66124
|
for (const k of ["oneOf", "anyOf", "allOf"]) {
|
|
65885
|
-
const
|
|
65886
|
-
if (Array.isArray(
|
|
65887
|
-
return `${k}<${
|
|
66125
|
+
const list3 = s[k];
|
|
66126
|
+
if (Array.isArray(list3))
|
|
66127
|
+
return `${k}<${list3.slice(0, 4).map((x) => schemaSummary(doc, x, depth + 1)).join(" | ")}>`;
|
|
65888
66128
|
}
|
|
65889
66129
|
if (type === "array" || s.items) return `${schemaSummary(doc, s.items, depth + 1) || "any"}[]`;
|
|
65890
66130
|
if (type === "object" || isObj2(s.properties)) {
|
|
@@ -66047,9 +66287,9 @@ function postmanBody(body) {
|
|
|
66047
66287
|
const lang = isObj2(body.options) && isObj2(body.options.raw) ? String(body.options.raw.language ?? "json") : "json";
|
|
66048
66288
|
return raw.length > 2e3 ? [`Body (${lang}): ${raw.slice(0, 2e3)}\u2026`] : ["Body:", "", `\`\`\`${lang}`, raw, "```"];
|
|
66049
66289
|
}
|
|
66050
|
-
const
|
|
66051
|
-
if (Array.isArray(
|
|
66052
|
-
const keys =
|
|
66290
|
+
const list3 = body[mode];
|
|
66291
|
+
if (Array.isArray(list3)) {
|
|
66292
|
+
const keys = list3.filter(isObj2).map(
|
|
66053
66293
|
(e) => `${String(e.key)}${e.type && e.type !== "text" ? ` (${String(e.type)})` : ""}${e.description ? ` \u2014 ${clip4(e.description, 100)}` : ""}`
|
|
66054
66294
|
);
|
|
66055
66295
|
return keys.length ? [`Body (${mode}): ${keys.join(", ")}`] : [];
|
|
@@ -67414,52 +67654,6 @@ function snippet(body, terms, opts = {}) {
|
|
|
67414
67654
|
}).join("\n\u22EF\n");
|
|
67415
67655
|
}
|
|
67416
67656
|
|
|
67417
|
-
// src/search/typo.ts
|
|
67418
|
-
init_esm_shims();
|
|
67419
|
-
function editDistance(a, b, max = 3) {
|
|
67420
|
-
if (Math.abs(a.length - b.length) > max) return max + 1;
|
|
67421
|
-
const prev2 = [];
|
|
67422
|
-
let prev = Array.from({ length: b.length + 1 }, (_, j) => j);
|
|
67423
|
-
let cur = new Array(b.length + 1).fill(0);
|
|
67424
|
-
for (let i = 1; i <= a.length; i++) {
|
|
67425
|
-
cur[0] = i;
|
|
67426
|
-
let rowMin = cur[0];
|
|
67427
|
-
for (let j = 1; j <= b.length; j++) {
|
|
67428
|
-
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
67429
|
-
let v = Math.min(prev[j] + 1, cur[j - 1] + 1, prev[j - 1] + cost);
|
|
67430
|
-
if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {
|
|
67431
|
-
v = Math.min(v, prev2[j - 2] + 1);
|
|
67432
|
-
}
|
|
67433
|
-
cur[j] = v;
|
|
67434
|
-
if (v < rowMin) rowMin = v;
|
|
67435
|
-
}
|
|
67436
|
-
if (rowMin > max) return max + 1;
|
|
67437
|
-
prev2.splice(0, prev2.length, ...prev);
|
|
67438
|
-
[prev, cur] = [cur, prev];
|
|
67439
|
-
}
|
|
67440
|
-
return prev[b.length];
|
|
67441
|
-
}
|
|
67442
|
-
function correctTerms(db, terms) {
|
|
67443
|
-
const corrections = [];
|
|
67444
|
-
const out = terms.map((term) => {
|
|
67445
|
-
if (term.length < 4 || /[^a-z0-9]/.test(term) || db.termExists(term)) return term;
|
|
67446
|
-
const max = term.length >= 7 ? 2 : 1;
|
|
67447
|
-
const candidates2 = db.vocabCandidates(term[0], 3e3);
|
|
67448
|
-
let best;
|
|
67449
|
-
for (const c of candidates2) {
|
|
67450
|
-
if (c.term.length < 3) continue;
|
|
67451
|
-
const d = editDistance(term, c.term, max);
|
|
67452
|
-
if (d > max) continue;
|
|
67453
|
-
if (!best || d < best.d || d === best.d && c.df > best.df)
|
|
67454
|
-
best = { term: c.term, d, df: c.df };
|
|
67455
|
-
}
|
|
67456
|
-
if (!best) return term;
|
|
67457
|
-
corrections.push({ from: term, to: best.term });
|
|
67458
|
-
return `${best.term}*`;
|
|
67459
|
-
});
|
|
67460
|
-
return { terms: out, corrections };
|
|
67461
|
-
}
|
|
67462
|
-
|
|
67463
67657
|
// src/search/pipeline.ts
|
|
67464
67658
|
var WEIGHTS = { porter: 1, trigram: 0.7, vector: 1 };
|
|
67465
67659
|
function lexical(db, terms, phrases, filters, n) {
|
|
@@ -67736,7 +67930,7 @@ init_esm_shims();
|
|
|
67736
67930
|
init_esm_shims();
|
|
67737
67931
|
var import_fast_glob4 = __toESM(require_out4(), 1);
|
|
67738
67932
|
import { existsSync as existsSync19, readFileSync as readFileSync17, statSync as statSync16 } from "fs";
|
|
67739
|
-
import { basename as
|
|
67933
|
+
import { basename as basename6, join as join25, relative as relative15 } from "path";
|
|
67740
67934
|
var IGNORE = [
|
|
67741
67935
|
"**/node_modules/**",
|
|
67742
67936
|
"**/.git/**",
|
|
@@ -68054,9 +68248,9 @@ function envSignals(dir, project, catalog) {
|
|
|
68054
68248
|
}
|
|
68055
68249
|
const token = name.split("_")[0];
|
|
68056
68250
|
if (token.length < 3 || GENERIC_ENV.has(token)) continue;
|
|
68057
|
-
const
|
|
68058
|
-
if (!
|
|
68059
|
-
unknownPrefixes.set(token,
|
|
68251
|
+
const list3 = unknownPrefixes.get(token) ?? [];
|
|
68252
|
+
if (!list3.includes(name)) list3.push(name);
|
|
68253
|
+
unknownPrefixes.set(token, list3);
|
|
68060
68254
|
}
|
|
68061
68255
|
}
|
|
68062
68256
|
return { signals, unknownPrefixes };
|
|
@@ -68217,7 +68411,7 @@ function apiSignals(dir, project) {
|
|
|
68217
68411
|
const text2 = readText(file3);
|
|
68218
68412
|
if (!text2 || text2.includes("\0")) continue;
|
|
68219
68413
|
const rel = relative15(dir, file3).split("\\").join("/");
|
|
68220
|
-
const isEnv =
|
|
68414
|
+
const isEnv = basename6(file3).startsWith(".env");
|
|
68221
68415
|
const lines = text2.split("\n");
|
|
68222
68416
|
const found = [];
|
|
68223
68417
|
for (let i = 0; i < lines.length; i++) {
|
|
@@ -68305,7 +68499,7 @@ function fileSignals(dir, project) {
|
|
|
68305
68499
|
}
|
|
68306
68500
|
function localCandidates(root, dir, project, isRegistered) {
|
|
68307
68501
|
const out = [];
|
|
68308
|
-
const prefix = project ? `${slugify2(
|
|
68502
|
+
const prefix = project ? `${slugify2(basename6(dir))}-` : "";
|
|
68309
68503
|
const rel = (abs) => relative15(root, abs).split("\\").join("/");
|
|
68310
68504
|
const push = (c) => {
|
|
68311
68505
|
if (!c.files) return;
|
|
@@ -68329,7 +68523,7 @@ function localCandidates(root, dir, project, isRegistered) {
|
|
|
68329
68523
|
push({
|
|
68330
68524
|
name: `${prefix}readme`,
|
|
68331
68525
|
path: rel(dir) || ".",
|
|
68332
|
-
glob: guides.map((g) =>
|
|
68526
|
+
glob: guides.map((g) => basename6(g)),
|
|
68333
68527
|
recursive: false,
|
|
68334
68528
|
files: guides.length,
|
|
68335
68529
|
bytes: sizeOf2(guides),
|
|
@@ -68430,7 +68624,7 @@ function localCandidates(root, dir, project, isRegistered) {
|
|
|
68430
68624
|
push({
|
|
68431
68625
|
name: `${prefix}env-example`,
|
|
68432
68626
|
path: rel(dir) || ".",
|
|
68433
|
-
glob: env.map((f) =>
|
|
68627
|
+
glob: env.map((f) => basename6(f)),
|
|
68434
68628
|
recursive: false,
|
|
68435
68629
|
files: env.length,
|
|
68436
68630
|
bytes: sizeOf2(env),
|
|
@@ -68508,15 +68702,15 @@ function discoverDocs(ctx, opts = {}) {
|
|
|
68508
68702
|
);
|
|
68509
68703
|
for (const hit of api.hits.values()) {
|
|
68510
68704
|
if (inSubproject(hit.samples)) continue;
|
|
68511
|
-
const
|
|
68512
|
-
|
|
68513
|
-
apiHits.set(hit.host,
|
|
68705
|
+
const list3 = apiHits.get(hit.host) ?? [];
|
|
68706
|
+
list3.push(hit);
|
|
68707
|
+
apiHits.set(hit.host, list3);
|
|
68514
68708
|
}
|
|
68515
68709
|
for (const link of api.docLinks.values()) {
|
|
68516
68710
|
if (inSubproject(link.samples)) continue;
|
|
68517
|
-
const
|
|
68518
|
-
|
|
68519
|
-
docLinks.set(link.host,
|
|
68711
|
+
const list3 = docLinks.get(link.host) ?? [];
|
|
68712
|
+
list3.push(link);
|
|
68713
|
+
docLinks.set(link.host, list3);
|
|
68520
68714
|
}
|
|
68521
68715
|
const env = envSignals(dir, project, catalog);
|
|
68522
68716
|
signals.push(...env.signals);
|
|
@@ -68606,12 +68800,12 @@ function discoverDocs(ctx, opts = {}) {
|
|
|
68606
68800
|
evidence: `${info.vars.slice(0, 4).join(", ")}${info.vars.length > 4 ? ", \u2026" : ""}`
|
|
68607
68801
|
});
|
|
68608
68802
|
}
|
|
68609
|
-
for (const [host,
|
|
68610
|
-
const calls =
|
|
68803
|
+
for (const [host, list3] of apiHits) {
|
|
68804
|
+
const calls = list3.reduce((n, h) => n + h.calls, 0);
|
|
68611
68805
|
if (!calls) continue;
|
|
68612
68806
|
const entry = catalogLookup("api", host, catalog);
|
|
68613
|
-
const specUrls = [...new Set(
|
|
68614
|
-
for (const h of
|
|
68807
|
+
const specUrls = [...new Set(list3.flatMap((h) => h.specUrls))];
|
|
68808
|
+
for (const h of list3) {
|
|
68615
68809
|
if (!h.calls) continue;
|
|
68616
68810
|
const evidence = `api:${host} (${h.samples.slice(0, 2).join(", ")})${specUrls.length ? ` \xB7 spec ${specUrls[0]}` : ""}`;
|
|
68617
68811
|
if (entry) {
|
|
@@ -68644,10 +68838,10 @@ function discoverDocs(ctx, opts = {}) {
|
|
|
68644
68838
|
}
|
|
68645
68839
|
}
|
|
68646
68840
|
}
|
|
68647
|
-
for (const [host,
|
|
68648
|
-
const urls = [...new Set(
|
|
68841
|
+
for (const [host, list3] of docLinks) {
|
|
68842
|
+
const urls = [...new Set(list3.flatMap((l) => l.urls))].slice(0, 3);
|
|
68649
68843
|
const entry = catalogLookup("api", host, catalog);
|
|
68650
|
-
for (const l of
|
|
68844
|
+
for (const l of list3) {
|
|
68651
68845
|
const evidence = `link:${host} (${l.samples.slice(0, 2).join(", ")})`;
|
|
68652
68846
|
if (entry) {
|
|
68653
68847
|
add3({
|
|
@@ -68822,7 +69016,7 @@ function rootOf(host) {
|
|
|
68822
69016
|
function docGuesses(host) {
|
|
68823
69017
|
const h = host.toLowerCase();
|
|
68824
69018
|
const root = rootOf(h);
|
|
68825
|
-
const
|
|
69019
|
+
const list3 = [
|
|
68826
69020
|
`https://docs.${root}/`,
|
|
68827
69021
|
`https://developer.${root}/`,
|
|
68828
69022
|
`https://developers.${root}/`,
|
|
@@ -68840,7 +69034,7 @@ function docGuesses(host) {
|
|
|
68840
69034
|
`https://${h}/openapi.json`,
|
|
68841
69035
|
`https://${h}/swagger.json`
|
|
68842
69036
|
];
|
|
68843
|
-
return [...new Set(
|
|
69037
|
+
return [...new Set(list3)];
|
|
68844
69038
|
}
|
|
68845
69039
|
async function probe2(url2, opts) {
|
|
68846
69040
|
const f = opts.fetchImpl ?? fetch;
|
|
@@ -69235,16 +69429,16 @@ function formatDiscovery(d, max = 40) {
|
|
|
69235
69429
|
]
|
|
69236
69430
|
];
|
|
69237
69431
|
for (const [conf, title, note, wants] of groups) {
|
|
69238
|
-
const
|
|
69239
|
-
if (!
|
|
69240
|
-
lines.push("", `${title} (${
|
|
69241
|
-
for (const p2 of
|
|
69432
|
+
const list3 = d.providers.filter(wants);
|
|
69433
|
+
if (!list3.length) continue;
|
|
69434
|
+
lines.push("", `${title} (${list3.length}; ${note}):`);
|
|
69435
|
+
for (const p2 of list3.slice(0, max)) {
|
|
69242
69436
|
const used = p2.usedBy.length > 1 ? ` \xB7 used by ${p2.usedBy.length} projects` : p2.usedBy[0] && p2.usedBy[0] !== "." ? ` \xB7 ${p2.usedBy[0]}` : "";
|
|
69243
69437
|
const where = p2.urls[0] ? ` \xB7 ${p2.urls[0]}` : "";
|
|
69244
69438
|
const ev3 = conf === "probe" || conf === "unknown" ? ` \xB7 ${p2.evidence[0]}` : "";
|
|
69245
69439
|
lines.push(`- ${p2.name} \u2190 ${p2.provider}${used}${where}${ev3}${reg(p2.registered)}`);
|
|
69246
69440
|
}
|
|
69247
|
-
if (
|
|
69441
|
+
if (list3.length > max) lines.push(` \u2026 ${list3.length - max} more`);
|
|
69248
69442
|
}
|
|
69249
69443
|
const rec = d.local.filter((c) => !c.registered).length + d.providers.filter(
|
|
69250
69444
|
(p2) => !p2.registered && (p2.confidence === "probe" || p2.confidence === "catalog" && (p2.tier ?? "library") === "service")
|
|
@@ -69483,14 +69677,14 @@ import {
|
|
|
69483
69677
|
} from "fs";
|
|
69484
69678
|
import { connect } from "net";
|
|
69485
69679
|
import { homedir as homedir3 } from "os";
|
|
69486
|
-
import { basename as
|
|
69680
|
+
import { basename as basename8, dirname as dirname14, join as join26 } from "path";
|
|
69487
69681
|
import { parseArgs } from "util";
|
|
69488
69682
|
|
|
69489
69683
|
// src/adjudicator/eval.ts
|
|
69490
69684
|
init_esm_shims();
|
|
69491
69685
|
import { createHash as createHash11 } from "crypto";
|
|
69492
69686
|
import { readFile } from "fs/promises";
|
|
69493
|
-
import { basename as
|
|
69687
|
+
import { basename as basename7, extname as extname3, resolve as resolvePath } from "path";
|
|
69494
69688
|
import { pathToFileURL } from "url";
|
|
69495
69689
|
|
|
69496
69690
|
// src/adjudicator/data/evalset.ts
|
|
@@ -70250,21 +70444,21 @@ function detectChanges(db, root, opts = {}) {
|
|
|
70250
70444
|
}
|
|
70251
70445
|
const byFile = /* @__PURE__ */ new Map();
|
|
70252
70446
|
for (const h of hunks) {
|
|
70253
|
-
const
|
|
70254
|
-
|
|
70255
|
-
byFile.set(h.path,
|
|
70447
|
+
const list3 = byFile.get(h.path) ?? [];
|
|
70448
|
+
list3.push(h);
|
|
70449
|
+
byFile.set(h.path, list3);
|
|
70256
70450
|
}
|
|
70257
70451
|
const symbols = /* @__PURE__ */ new Map();
|
|
70258
70452
|
const files = [];
|
|
70259
70453
|
const unindexed = [];
|
|
70260
|
-
for (const [path3,
|
|
70454
|
+
for (const [path3, list3] of byFile) {
|
|
70261
70455
|
const indexed = !!db.graphGetNode(fileId(path3));
|
|
70262
|
-
files.push({ path: path3, hunks:
|
|
70456
|
+
files.push({ path: path3, hunks: list3.length, indexed });
|
|
70263
70457
|
if (!indexed) {
|
|
70264
70458
|
unindexed.push(path3);
|
|
70265
70459
|
continue;
|
|
70266
70460
|
}
|
|
70267
|
-
for (const [id, s] of symbolsAt(db, path3,
|
|
70461
|
+
for (const [id, s] of symbolsAt(db, path3, list3)) symbols.set(id, s);
|
|
70268
70462
|
}
|
|
70269
70463
|
const ids = [...symbols.keys()];
|
|
70270
70464
|
const metrics = new Map(db.metricsGet(ids).map((m) => [m.node_id, m]));
|
|
@@ -72259,7 +72453,7 @@ ${swarm.instructions}`] : []
|
|
|
72259
72453
|
init_esm_shims();
|
|
72260
72454
|
import { execFileSync } from "child_process";
|
|
72261
72455
|
import { readFileSync as readFileSync25, realpathSync as realpathSync11, statSync as statSync18 } from "fs";
|
|
72262
|
-
import { basename as
|
|
72456
|
+
import { basename as basename9, dirname as dirname16, join as join33, resolve as resolve14 } from "path";
|
|
72263
72457
|
|
|
72264
72458
|
// src/hooks/log.ts
|
|
72265
72459
|
init_esm_shims();
|
|
@@ -72335,7 +72529,7 @@ function coordinationRoot(root) {
|
|
|
72335
72529
|
} catch {
|
|
72336
72530
|
return root;
|
|
72337
72531
|
}
|
|
72338
|
-
if (
|
|
72532
|
+
if (basename9(common) === ".git") return realpathSync11(dirname16(common));
|
|
72339
72533
|
const out = execFileSync("git", ["worktree", "list", "--porcelain"], {
|
|
72340
72534
|
cwd: root,
|
|
72341
72535
|
encoding: "utf8",
|
|
@@ -72391,7 +72585,9 @@ var schema = {
|
|
|
72391
72585
|
remember: external_exports.boolean().optional().describe("finish: keep the outcome as an eminiar memory"),
|
|
72392
72586
|
agent: external_exports.string().optional().describe("release: worker agent id (a prefix is enough)"),
|
|
72393
72587
|
role: external_exports.string().optional().describe("release: every running worker of this role"),
|
|
72394
|
-
force: external_exports.boolean().optional().describe(
|
|
72588
|
+
force: external_exports.boolean().optional().describe(
|
|
72589
|
+
"sync: also overwrite generated agent files that were edited by hand, and write them while the swarm file has keys this eminiar does not know"
|
|
72590
|
+
),
|
|
72395
72591
|
caller_kind: external_exports.string().optional().describe(HOOK_FIELD),
|
|
72396
72592
|
caller_agent_id: external_exports.string().optional().describe(HOOK_FIELD),
|
|
72397
72593
|
caller_agent_type: external_exports.string().optional().describe(HOOK_FIELD),
|
|
@@ -72580,9 +72776,9 @@ async function dispatch(args, callerCtx) {
|
|
|
72580
72776
|
case "list": {
|
|
72581
72777
|
const plan = planAgentSync(ctx.root, config2);
|
|
72582
72778
|
const active = listItems(db, db.swarm.runs({ status: "active", limit: 10 }));
|
|
72583
|
-
const
|
|
72779
|
+
const list3 = formatSwarmList(config2, plan, active, { swarm: args.swarm, sessionId });
|
|
72584
72780
|
return who.unverified !== void 0 ? `${unstampedNote(who.unverified)}
|
|
72585
|
-
${
|
|
72781
|
+
${list3}` : list3;
|
|
72586
72782
|
}
|
|
72587
72783
|
case "start": {
|
|
72588
72784
|
if (!args.swarm)
|
|
@@ -72639,7 +72835,7 @@ ${list2}` : list2;
|
|
|
72639
72835
|
if (ctx.config.adjudicator?.enabled && ctx.config.adjudicator.surfaces.plan) {
|
|
72640
72836
|
const unavailable = "Adjudicator advice unavailable for this plan (the tasks are planned).";
|
|
72641
72837
|
try {
|
|
72642
|
-
const
|
|
72838
|
+
const list3 = await adjudicatePlan(ctx, db, run, swarm, rows, {
|
|
72643
72839
|
sessionId,
|
|
72644
72840
|
log: (line) => process.stderr.write(`eminiar: ${line}
|
|
72645
72841
|
`),
|
|
@@ -72647,8 +72843,8 @@ ${list2}` : list2;
|
|
|
72647
72843
|
adviceNote = unavailable;
|
|
72648
72844
|
}
|
|
72649
72845
|
});
|
|
72650
|
-
advice = planAdviceBlock(
|
|
72651
|
-
adviceHint = planNextHint(
|
|
72846
|
+
advice = planAdviceBlock(list3);
|
|
72847
|
+
adviceHint = planNextHint(list3);
|
|
72652
72848
|
} catch (err) {
|
|
72653
72849
|
process.stderr.write(
|
|
72654
72850
|
`eminiar: adjudicator plan advice skipped: ${err?.message ?? String(err)}
|
|
@@ -72973,8 +73169,8 @@ for (const tool of listed) {
|
|
|
72973
73169
|
tool.name,
|
|
72974
73170
|
{
|
|
72975
73171
|
description: tool.description,
|
|
72976
|
-
// Every tool accepts an optional project_root
|
|
72977
|
-
//
|
|
73172
|
+
// Every tool accepts an optional project_root, for a caller whose project is not the
|
|
73173
|
+
// server's own (the em_swarm stamp hook names the session's); without it, the server's.
|
|
72978
73174
|
inputSchema: { ...tool.schema, project_root: external_exports.string().optional() }
|
|
72979
73175
|
},
|
|
72980
73176
|
async (args) => {
|