eminiar 0.13.3 → 0.13.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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "eminiar",
3
3
  "displayName": "Eminiar",
4
- "version": "0.13.3",
4
+ "version": "0.13.4",
5
5
  "description": "Local-first context, memory and knowledge graph for Claude Code: sandboxed execution, FTS5 + vector search, session continuity, code graph.",
6
6
  "author": {
7
7
  "name": "Ryan Dick"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "eminiar",
3
3
  "displayName": "Eminiar",
4
- "version": "0.13.3",
4
+ "version": "0.13.4",
5
5
  "description": "Local-first context, memory and knowledge graph for coding agents: sandboxed execution, FTS5 + vector search, session continuity, code graph.",
6
6
  "author": {
7
7
  "name": "Ryan Dick"
package/dist/cli.js CHANGED
@@ -20796,6 +20796,18 @@ function adjudicatorDefaults() {
20796
20796
  privacy: { maxChars: 2e3, storeHead: true, captureExchanges: false }
20797
20797
  };
20798
20798
  }
20799
+ function graphGlobProblem(g) {
20800
+ if (g.length > 200) return "longer than 200 characters";
20801
+ if ((g.match(/\{/g)?.length ?? 0) > 4) return "more than 4 braces";
20802
+ if ((g.match(/\(/g)?.length ?? 0) > 2) return "more than 2 extglob groups";
20803
+ let total = 0;
20804
+ for (const seg of g.split(/[\\/]/)) {
20805
+ const groups = seg.match(/\*+|\?/g)?.length ?? 0;
20806
+ if (groups > 3) return "more than 3 wildcards in one path segment";
20807
+ total += groups;
20808
+ }
20809
+ return total > 8 ? "more than 8 wildcards" : void 0;
20810
+ }
20799
20811
  function ownJson(v) {
20800
20812
  if (Array.isArray(v)) return v.map(ownJson);
20801
20813
  if (typeof v !== "object" || v === null) return v;
@@ -21052,7 +21064,7 @@ function parseConfig(merged) {
21052
21064
  if (!base.success) return base;
21053
21065
  return { success: true, data: { ...base.data, adjudicator: adjudicatorDefaults() } };
21054
21066
  }
21055
- var RoutingMode, PROJECT_RELATIVE_PATH_RE, SECRET_FIELD, buildAdjudicatorObject, buildAdjudicatorSchema, adjudicatorSchema, AdjudicatorConfigSchema, BaseConfigSchema, ConfigSchema, UNSAFE_KEYS, PROJECT_ADJUDICATOR_KEYS, CASE_INSENSITIVE_FS, MAX_GIT_DEPTH, MAX_WORKTREES, PROJECT_PATH_KEYS;
21067
+ var RoutingMode, PROJECT_RELATIVE_PATH_RE, SECRET_FIELD, buildAdjudicatorObject, buildAdjudicatorSchema, adjudicatorSchema, AdjudicatorConfigSchema, GraphGlob, BaseConfigSchema, ConfigSchema, UNSAFE_KEYS, PROJECT_ADJUDICATOR_KEYS, CASE_INSENSITIVE_FS, MAX_GIT_DEPTH, MAX_WORKTREES, PROJECT_PATH_KEYS;
21056
21068
  var init_config = __esm({
21057
21069
  "src/config.ts"() {
21058
21070
  "use strict";
@@ -21190,6 +21202,14 @@ var init_config = __esm({
21190
21202
  AdjudicatorConfigSchema = external_exports.lazy(
21191
21203
  () => adjudicatorSchema ??= buildAdjudicatorSchema()
21192
21204
  );
21205
+ GraphGlob = external_exports.string().superRefine((g, ctx) => {
21206
+ const why = graphGlobProblem(g);
21207
+ if (why)
21208
+ ctx.addIssue({
21209
+ code: "custom",
21210
+ message: `graph glob ${JSON.stringify(g.slice(0, 40))} is ${why}`
21211
+ });
21212
+ });
21193
21213
  BaseConfigSchema = external_exports.object({
21194
21214
  routing: external_exports.object({
21195
21215
  /** auto = annotate while context-mode is installed, enforce once it is gone. */
@@ -21216,18 +21236,21 @@ var init_config = __esm({
21216
21236
  dims: external_exports.number().int().positive().default(384)
21217
21237
  }).prefault({}),
21218
21238
  graph: external_exports.object({
21219
- include: external_exports.array(external_exports.string()).default([
21239
+ include: external_exports.array(GraphGlob).default([
21220
21240
  "**/*.ts",
21221
21241
  "**/*.tsx",
21222
21242
  "**/*.js",
21223
21243
  "**/*.jsx",
21224
21244
  "**/*.mjs",
21225
21245
  "**/*.cjs",
21246
+ "**/*.mts",
21247
+ "**/*.cts",
21226
21248
  "**/*.py",
21249
+ "**/*.pyi",
21227
21250
  "**/*.go",
21228
21251
  "**/*.php"
21229
21252
  ]),
21230
- exclude: external_exports.array(external_exports.string()).default([
21253
+ exclude: external_exports.array(GraphGlob).default([
21231
21254
  "**/node_modules/**",
21232
21255
  "**/dist/**",
21233
21256
  "**/build/**",
@@ -34858,7 +34881,7 @@ var require_micromatch = __commonJS({
34858
34881
  const index = v.indexOf("{");
34859
34882
  return index > -1 && v.indexOf("}", index) > -1;
34860
34883
  };
34861
- var micromatch = (list2, patterns, options) => {
34884
+ var micromatch2 = (list2, patterns, options) => {
34862
34885
  patterns = [].concat(patterns);
34863
34886
  list2 = [].concat(list2);
34864
34887
  let omit2 = /* @__PURE__ */ new Set();
@@ -34899,11 +34922,11 @@ var require_micromatch = __commonJS({
34899
34922
  }
34900
34923
  return matches2;
34901
34924
  };
34902
- micromatch.match = micromatch;
34903
- micromatch.matcher = (pattern2, options) => picomatch(pattern2, options);
34904
- micromatch.isMatch = (str3, patterns, options) => picomatch(patterns, options)(str3);
34905
- micromatch.any = micromatch.isMatch;
34906
- micromatch.not = (list2, patterns, options = {}) => {
34925
+ micromatch2.match = micromatch2;
34926
+ micromatch2.matcher = (pattern2, options) => picomatch(pattern2, options);
34927
+ micromatch2.isMatch = (str3, patterns, options) => picomatch(patterns, options)(str3);
34928
+ micromatch2.any = micromatch2.isMatch;
34929
+ micromatch2.not = (list2, patterns, options = {}) => {
34907
34930
  patterns = [].concat(patterns).map(String);
34908
34931
  let result = /* @__PURE__ */ new Set();
34909
34932
  let items2 = [];
@@ -34911,7 +34934,7 @@ var require_micromatch = __commonJS({
34911
34934
  if (options.onResult) options.onResult(state);
34912
34935
  items2.push(state.output);
34913
34936
  };
34914
- let matches2 = new Set(micromatch(list2, patterns, { ...options, onResult }));
34937
+ let matches2 = new Set(micromatch2(list2, patterns, { ...options, onResult }));
34915
34938
  for (let item of items2) {
34916
34939
  if (!matches2.has(item)) {
34917
34940
  result.add(item);
@@ -34919,12 +34942,12 @@ var require_micromatch = __commonJS({
34919
34942
  }
34920
34943
  return [...result];
34921
34944
  };
34922
- micromatch.contains = (str3, pattern2, options) => {
34945
+ micromatch2.contains = (str3, pattern2, options) => {
34923
34946
  if (typeof str3 !== "string") {
34924
34947
  throw new TypeError(`Expected a string: "${util.inspect(str3)}"`);
34925
34948
  }
34926
34949
  if (Array.isArray(pattern2)) {
34927
- return pattern2.some((p2) => micromatch.contains(str3, p2, options));
34950
+ return pattern2.some((p2) => micromatch2.contains(str3, p2, options));
34928
34951
  }
34929
34952
  if (typeof pattern2 === "string") {
34930
34953
  if (isEmptyString(str3) || isEmptyString(pattern2)) {
@@ -34934,18 +34957,18 @@ var require_micromatch = __commonJS({
34934
34957
  return true;
34935
34958
  }
34936
34959
  }
34937
- return micromatch.isMatch(str3, pattern2, { ...options, contains: true });
34960
+ return micromatch2.isMatch(str3, pattern2, { ...options, contains: true });
34938
34961
  };
34939
- micromatch.matchKeys = (obj, patterns, options) => {
34962
+ micromatch2.matchKeys = (obj, patterns, options) => {
34940
34963
  if (!utils.isObject(obj)) {
34941
34964
  throw new TypeError("Expected the first argument to be an object");
34942
34965
  }
34943
- let keys = micromatch(Object.keys(obj), patterns, options);
34966
+ let keys = micromatch2(Object.keys(obj), patterns, options);
34944
34967
  let res = {};
34945
34968
  for (let key of keys) res[key] = obj[key];
34946
34969
  return res;
34947
34970
  };
34948
- micromatch.some = (list2, patterns, options) => {
34971
+ micromatch2.some = (list2, patterns, options) => {
34949
34972
  let items2 = [].concat(list2);
34950
34973
  for (let pattern2 of [].concat(patterns)) {
34951
34974
  let isMatch = picomatch(String(pattern2), options);
@@ -34955,7 +34978,7 @@ var require_micromatch = __commonJS({
34955
34978
  }
34956
34979
  return false;
34957
34980
  };
34958
- micromatch.every = (list2, patterns, options) => {
34981
+ micromatch2.every = (list2, patterns, options) => {
34959
34982
  let items2 = [].concat(list2);
34960
34983
  for (let pattern2 of [].concat(patterns)) {
34961
34984
  let isMatch = picomatch(String(pattern2), options);
@@ -34965,13 +34988,13 @@ var require_micromatch = __commonJS({
34965
34988
  }
34966
34989
  return true;
34967
34990
  };
34968
- micromatch.all = (str3, patterns, options) => {
34991
+ micromatch2.all = (str3, patterns, options) => {
34969
34992
  if (typeof str3 !== "string") {
34970
34993
  throw new TypeError(`Expected a string: "${util.inspect(str3)}"`);
34971
34994
  }
34972
34995
  return [].concat(patterns).every((p2) => picomatch(p2, options)(str3));
34973
34996
  };
34974
- micromatch.capture = (glob2, input2, options) => {
34997
+ micromatch2.capture = (glob2, input2, options) => {
34975
34998
  let posix3 = utils.isWindows(options);
34976
34999
  let regex = picomatch.makeRe(String(glob2), { ...options, capture: true });
34977
35000
  let match = regex.exec(posix3 ? utils.toPosixSlashes(input2) : input2);
@@ -34979,9 +35002,9 @@ var require_micromatch = __commonJS({
34979
35002
  return match.slice(1).map((v) => v === void 0 ? "" : v);
34980
35003
  }
34981
35004
  };
34982
- micromatch.makeRe = (...args) => picomatch.makeRe(...args);
34983
- micromatch.scan = (...args) => picomatch.scan(...args);
34984
- micromatch.parse = (patterns, options) => {
35005
+ micromatch2.makeRe = (...args) => picomatch.makeRe(...args);
35006
+ micromatch2.scan = (...args) => picomatch.scan(...args);
35007
+ micromatch2.parse = (patterns, options) => {
34985
35008
  let res = [];
34986
35009
  for (let pattern2 of [].concat(patterns || [])) {
34987
35010
  for (let str3 of braces(String(pattern2), options)) {
@@ -34990,19 +35013,19 @@ var require_micromatch = __commonJS({
34990
35013
  }
34991
35014
  return res;
34992
35015
  };
34993
- micromatch.braces = (pattern2, options) => {
35016
+ micromatch2.braces = (pattern2, options) => {
34994
35017
  if (typeof pattern2 !== "string") throw new TypeError("Expected a string");
34995
35018
  if (options && options.nobrace === true || !hasBraces(pattern2)) {
34996
35019
  return [pattern2];
34997
35020
  }
34998
35021
  return braces(pattern2, options);
34999
35022
  };
35000
- micromatch.braceExpand = (pattern2, options) => {
35023
+ micromatch2.braceExpand = (pattern2, options) => {
35001
35024
  if (typeof pattern2 !== "string") throw new TypeError("Expected a string");
35002
- return micromatch.braces(pattern2, { ...options, expand: true });
35025
+ return micromatch2.braces(pattern2, { ...options, expand: true });
35003
35026
  };
35004
- micromatch.hasBraces = hasBraces;
35005
- module.exports = micromatch;
35027
+ micromatch2.hasBraces = hasBraces;
35028
+ module.exports = micromatch2;
35006
35029
  }
35007
35030
  });
35008
35031
 
@@ -35015,7 +35038,7 @@ var require_pattern = __commonJS({
35015
35038
  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;
35016
35039
  var path3 = __require("path");
35017
35040
  var globParent = require_glob_parent();
35018
- var micromatch = require_micromatch();
35041
+ var micromatch2 = require_micromatch();
35019
35042
  var GLOBSTAR = "**";
35020
35043
  var ESCAPE_SYMBOL = "\\";
35021
35044
  var COMMON_GLOB_SYMBOLS_RE = /[*?]|^!/;
@@ -35108,8 +35131,8 @@ var require_pattern = __commonJS({
35108
35131
  }
35109
35132
  exports.endsWithSlashGlobStar = endsWithSlashGlobStar;
35110
35133
  function isAffectDepthOfReadingPattern(pattern2) {
35111
- const basename10 = path3.basename(pattern2);
35112
- return endsWithSlashGlobStar(pattern2) || isStaticPattern(basename10);
35134
+ const basename11 = path3.basename(pattern2);
35135
+ return endsWithSlashGlobStar(pattern2) || isStaticPattern(basename11);
35113
35136
  }
35114
35137
  exports.isAffectDepthOfReadingPattern = isAffectDepthOfReadingPattern;
35115
35138
  function expandPatternsWithBraceExpansion(patterns) {
@@ -35119,13 +35142,13 @@ var require_pattern = __commonJS({
35119
35142
  }
35120
35143
  exports.expandPatternsWithBraceExpansion = expandPatternsWithBraceExpansion;
35121
35144
  function expandBraceExpansion(pattern2) {
35122
- const patterns = micromatch.braces(pattern2, { expand: true, nodupes: true, keepEscaping: true });
35145
+ const patterns = micromatch2.braces(pattern2, { expand: true, nodupes: true, keepEscaping: true });
35123
35146
  patterns.sort((a, b) => a.length - b.length);
35124
35147
  return patterns.filter((pattern3) => pattern3 !== "");
35125
35148
  }
35126
35149
  exports.expandBraceExpansion = expandBraceExpansion;
35127
35150
  function getPatternParts(pattern2, options) {
35128
- let { parts } = micromatch.scan(pattern2, Object.assign(Object.assign({}, options), { parts: true }));
35151
+ let { parts } = micromatch2.scan(pattern2, Object.assign(Object.assign({}, options), { parts: true }));
35129
35152
  if (parts.length === 0) {
35130
35153
  parts = [pattern2];
35131
35154
  }
@@ -35137,7 +35160,7 @@ var require_pattern = __commonJS({
35137
35160
  }
35138
35161
  exports.getPatternParts = getPatternParts;
35139
35162
  function makeRe(pattern2, options) {
35140
- return micromatch.makeRe(pattern2, options);
35163
+ return micromatch2.makeRe(pattern2, options);
35141
35164
  }
35142
35165
  exports.makeRe = makeRe;
35143
35166
  function convertPatternsToRe(patterns, options) {
@@ -35156,7 +35179,7 @@ var require_pattern = __commonJS({
35156
35179
  const absolute = [];
35157
35180
  const relative18 = [];
35158
35181
  for (const pattern2 of patterns) {
35159
- if (isAbsolute8(pattern2)) {
35182
+ if (isAbsolute9(pattern2)) {
35160
35183
  absolute.push(pattern2);
35161
35184
  } else {
35162
35185
  relative18.push(pattern2);
@@ -35165,10 +35188,10 @@ var require_pattern = __commonJS({
35165
35188
  return [absolute, relative18];
35166
35189
  }
35167
35190
  exports.partitionAbsoluteAndRelative = partitionAbsoluteAndRelative;
35168
- function isAbsolute8(pattern2) {
35191
+ function isAbsolute9(pattern2) {
35169
35192
  return path3.isAbsolute(pattern2);
35170
35193
  }
35171
- exports.isAbsolute = isAbsolute8;
35194
+ exports.isAbsolute = isAbsolute9;
35172
35195
  }
35173
35196
  });
35174
35197
 
@@ -53676,16 +53699,42 @@ var init_link = __esm({
53676
53699
 
53677
53700
  // src/graph/reindex.ts
53678
53701
  import { readFileSync as readFileSync25, statSync as statSync16 } from "fs";
53679
- import { join as join33 } from "path";
53702
+ import { basename as basename7, isAbsolute as isAbsolute7, join as join33 } from "path";
53680
53703
  function listCodeFiles(ctx) {
53681
53704
  return import_fast_glob3.default.sync(ctx.config.graph.include, {
53705
+ ...CODE_GLOB,
53682
53706
  cwd: ctx.root,
53683
- ignore: ctx.config.graph.exclude,
53684
- onlyFiles: true,
53685
- dot: false,
53686
- followSymbolicLinks: false
53707
+ ignore: ctx.config.graph.exclude
53687
53708
  });
53688
53709
  }
53710
+ function codeFileFilter(graph) {
53711
+ const cached6 = FILTERS.get(graph);
53712
+ if (cached6) return cached6;
53713
+ const f = compileCodeFilter(graph);
53714
+ FILTERS.set(graph, f);
53715
+ return f;
53716
+ }
53717
+ function compileCodeFilter(graph) {
53718
+ const tasks = import_fast_glob3.default.generateTasks(graph.include, { ignore: graph.exclude });
53719
+ const re = (patterns, opts) => patterns.map((p2) => import_micromatch.default.makeRe(p2, opts));
53720
+ const any2 = (res, s) => res.some((r) => r.test(s));
53721
+ const positive = re(
53722
+ tasks.flatMap((t) => t.positive),
53723
+ MATCH
53724
+ );
53725
+ const ignore = tasks[0]?.negative ?? [];
53726
+ const ignored = re(ignore, { ...MATCH, dot: true });
53727
+ const pruned = re(
53728
+ ignore.filter((p2) => p2.endsWith("/**") || !import_fast_glob3.default.isDynamicPattern(basename7(p2))),
53729
+ MATCH
53730
+ );
53731
+ return (rel) => {
53732
+ if (isAbsolute7(rel) || rel.startsWith("../") || !any2(positive, rel) || any2(ignored, rel))
53733
+ return false;
53734
+ const dirs = rel.split("/").slice(0, -1);
53735
+ return !dirs.some((_, i) => any2(pruned, dirs.slice(0, i + 1).join("/")));
53736
+ };
53737
+ }
53689
53738
  async function indexOne(ctx, db, rel, force) {
53690
53739
  const abs = join33(ctx.root, rel);
53691
53740
  const st = statSync16(abs);
@@ -53886,7 +53935,7 @@ function statSafe(p2) {
53886
53935
  }
53887
53936
  async function drainReindexQueue(ctx, db) {
53888
53937
  if (draining) return 0;
53889
- const paths2 = db.reindexQueueDrain();
53938
+ const paths2 = db.reindexQueueDrain().filter(codeFileFilter(ctx.config.graph));
53890
53939
  if (!paths2.length) return 0;
53891
53940
  draining = true;
53892
53941
  try {
@@ -53936,12 +53985,13 @@ function indexFreshness(ctx, db) {
53936
53985
  lastRun: db.indexRunsRecent(1)[0]?.finished_at ?? null
53937
53986
  };
53938
53987
  }
53939
- var import_fast_glob3, MAX_CODE_BYTES, CODE_INDEX_VERSION, draining;
53988
+ var import_fast_glob3, import_micromatch, MAX_CODE_BYTES, CODE_INDEX_VERSION, CODE_GLOB, MATCH, FILTERS, draining;
53940
53989
  var init_reindex = __esm({
53941
53990
  "src/graph/reindex.ts"() {
53942
53991
  "use strict";
53943
53992
  init_esm_shims();
53944
53993
  import_fast_glob3 = __toESM(require_out4(), 1);
53994
+ import_micromatch = __toESM(require_micromatch(), 1);
53945
53995
  init_chunker();
53946
53996
  init_symbols();
53947
53997
  init_backend();
@@ -53951,6 +54001,9 @@ var init_reindex = __esm({
53951
54001
  init_metrics();
53952
54002
  MAX_CODE_BYTES = 15e5;
53953
54003
  CODE_INDEX_VERSION = "3";
54004
+ CODE_GLOB = { onlyFiles: true, dot: false, followSymbolicLinks: false };
54005
+ MATCH = { dot: false, posix: true, strictSlashes: false };
54006
+ FILTERS = /* @__PURE__ */ new WeakMap();
53954
54007
  draining = false;
53955
54008
  }
53956
54009
  });
@@ -54898,7 +54951,7 @@ var init_em_index_status = __esm({
54898
54951
 
54899
54952
  // src/docs/discover.ts
54900
54953
  import { existsSync as existsSync30, readFileSync as readFileSync27, statSync as statSync17 } from "fs";
54901
- import { basename as basename7, join as join35, relative as relative15 } from "path";
54954
+ import { basename as basename8, join as join35, relative as relative15 } from "path";
54902
54955
  function readText(file3) {
54903
54956
  try {
54904
54957
  return readFileSync27(file3, "utf8");
@@ -55094,7 +55147,7 @@ function apiSignals(dir, project) {
55094
55147
  const text3 = readText(file3);
55095
55148
  if (!text3 || text3.includes("\0")) continue;
55096
55149
  const rel = relative15(dir, file3).split("\\").join("/");
55097
- const isEnv = basename7(file3).startsWith(".env");
55150
+ const isEnv = basename8(file3).startsWith(".env");
55098
55151
  const lines = text3.split("\n");
55099
55152
  const found = [];
55100
55153
  for (let i = 0; i < lines.length; i++) {
@@ -55182,7 +55235,7 @@ function fileSignals(dir, project) {
55182
55235
  }
55183
55236
  function localCandidates(root, dir, project, isRegistered) {
55184
55237
  const out = [];
55185
- const prefix = project ? `${slugify2(basename7(dir))}-` : "";
55238
+ const prefix = project ? `${slugify2(basename8(dir))}-` : "";
55186
55239
  const rel = (abs) => relative15(root, abs).split("\\").join("/");
55187
55240
  const push = (c) => {
55188
55241
  if (!c.files) return;
@@ -55206,7 +55259,7 @@ function localCandidates(root, dir, project, isRegistered) {
55206
55259
  push({
55207
55260
  name: `${prefix}readme`,
55208
55261
  path: rel(dir) || ".",
55209
- glob: guides.map((g) => basename7(g)),
55262
+ glob: guides.map((g) => basename8(g)),
55210
55263
  recursive: false,
55211
55264
  files: guides.length,
55212
55265
  bytes: sizeOf(guides),
@@ -55307,7 +55360,7 @@ function localCandidates(root, dir, project, isRegistered) {
55307
55360
  push({
55308
55361
  name: `${prefix}env-example`,
55309
55362
  path: rel(dir) || ".",
55310
- glob: env.map((f) => basename7(f)),
55363
+ glob: env.map((f) => basename8(f)),
55311
55364
  recursive: false,
55312
55365
  files: env.length,
55313
55366
  bytes: sizeOf(env),
@@ -63041,10 +63094,10 @@ import {
63041
63094
  statSync as statSync19,
63042
63095
  writeSync
63043
63096
  } from "fs";
63044
- import { basename as basename8, dirname as dirname16, isAbsolute as isAbsolute7, relative as relative17, resolve as resolve16, sep as sep6 } from "path";
63097
+ import { basename as basename9, dirname as dirname16, isAbsolute as isAbsolute8, relative as relative17, resolve as resolve16, sep as sep6 } from "path";
63045
63098
  function within2(child, parent) {
63046
63099
  const rel = relative17(parent, child);
63047
- return rel === "" || rel !== ".." && !rel.startsWith(`..${sep6}`) && !isAbsolute7(rel);
63100
+ return rel === "" || rel !== ".." && !rel.startsWith(`..${sep6}`) && !isAbsolute8(rel);
63048
63101
  }
63049
63102
  function locationProblem2(file3, root) {
63050
63103
  if (file3 === root || !within2(file3, root)) return "it is outside the project";
@@ -63119,7 +63172,7 @@ function saveSwarmFile(root, text3, baseHash) {
63119
63172
  const mode = current ? statSync19(file3).mode & 511 : 420;
63120
63173
  const tmp = resolve16(
63121
63174
  dirname16(file3),
63122
- `.${basename8(file3)}.${process.pid}.${randomBytes4(4).toString("hex")}.tmp`
63175
+ `.${basename9(file3)}.${process.pid}.${randomBytes4(4).toString("hex")}.tmp`
63123
63176
  );
63124
63177
  try {
63125
63178
  const fd = openSync3(tmp, "wx", mode);
@@ -64647,7 +64700,7 @@ var init_identity = __esm({
64647
64700
  // src/swarm/hooks.ts
64648
64701
  import { execFileSync } from "child_process";
64649
64702
  import { readFileSync as readFileSync35, realpathSync as realpathSync13, statSync as statSync21 } from "fs";
64650
- import { basename as basename9, dirname as dirname17, join as join42, resolve as resolve18 } from "path";
64703
+ import { basename as basename10, dirname as dirname17, join as join42, resolve as resolve18 } from "path";
64651
64704
  function coordinationRoot(root) {
64652
64705
  try {
64653
64706
  const dotGit = join42(root, ".git");
@@ -64661,7 +64714,7 @@ function coordinationRoot(root) {
64661
64714
  } catch {
64662
64715
  return root;
64663
64716
  }
64664
- if (basename9(common) === ".git") return realpathSync13(dirname17(common));
64717
+ if (basename10(common) === ".git") return realpathSync13(dirname17(common));
64665
64718
  const out = execFileSync("git", ["worktree", "list", "--porcelain"], {
64666
64719
  cwd: root,
64667
64720
  encoding: "utf8",
@@ -65149,7 +65202,9 @@ function renderStatusline(raw) {
65149
65202
  }
65150
65203
  let line;
65151
65204
  try {
65152
- const ctx = getContext(input2.cwd ?? input2.workspace?.current_dir);
65205
+ const ctx = getContext(
65206
+ input2.workspace?.project_dir ?? input2.cwd ?? input2.workspace?.current_dir
65207
+ );
65153
65208
  const db = getStorage(ctx, { vectors: false });
65154
65209
  const session = summarize(db.statsBySession(input2.session_id ?? ""));
65155
65210
  const life = summarize(globalDb().lifetime());
@@ -4,12 +4,12 @@ import {
4
4
  parseJob,
5
5
  runAsyncJob,
6
6
  spawnAsyncJob
7
- } from "./hook-chunk-MVSMFCKL.js";
8
- import "./hook-chunk-ETYHCPPH.js";
7
+ } from "./hook-chunk-77LASZ3C.js";
8
+ import "./hook-chunk-G7UP4ZVA.js";
9
9
  export {
10
10
  ASYNC_JOB_MAX_MS,
11
11
  parseJob,
12
12
  runAsyncJob,
13
13
  spawnAsyncJob
14
14
  };
15
- //# sourceMappingURL=hook-async-3TLK23ZY.js.map
15
+ //# sourceMappingURL=hook-async-7GK6H3OO.js.map
@@ -7,14 +7,15 @@ import {
7
7
  __toESM,
8
8
  ensureDirs,
9
9
  external_exports,
10
- findProjectRoot,
11
10
  getContext,
12
11
  getStorage,
13
12
  init_esm_shims,
14
13
  paths,
15
14
  resolveProjectRoot,
15
+ sessionContext,
16
+ sessionRoot,
16
17
  tierOf
17
- } from "./hook-chunk-ETYHCPPH.js";
18
+ } from "./hook-chunk-G7UP4ZVA.js";
18
19
 
19
20
  // node_modules/fast-glob/out/utils/array.js
20
21
  var require_array = __commonJS({
@@ -9142,16 +9143,6 @@ function configFor(local, main, agentType) {
9142
9143
  }
9143
9144
  return void 0;
9144
9145
  }
9145
- function sessionRoot() {
9146
- const root = findProjectRoot(
9147
- process.env.CLAUDE_PROJECT_DIR || process.env.EMINIAR_PROJECT_ROOT || process.cwd()
9148
- );
9149
- try {
9150
- return realpathSync5(root);
9151
- } catch {
9152
- return root;
9153
- }
9154
- }
9155
9146
  function orderedRoots(hookRoot) {
9156
9147
  const out = [];
9157
9148
  try {
@@ -9162,13 +9153,8 @@ function orderedRoots(hookRoot) {
9162
9153
  return out;
9163
9154
  }
9164
9155
  function swarmRoots(input) {
9165
- let hook;
9166
- try {
9167
- hook = resolveProjectRoot(input.cwd || void 0);
9168
- } catch {
9169
- }
9170
9156
  const out = [];
9171
- for (const r of orderedRoots(hook)) {
9157
+ for (const r of orderedRoots(hookRootOf(input))) {
9172
9158
  for (const d of [r, coordinationRoot(r)]) if (!out.includes(d)) out.push(d);
9173
9159
  }
9174
9160
  return out;
@@ -9184,9 +9170,16 @@ function enforcementRoots() {
9184
9170
  return [];
9185
9171
  }
9186
9172
  }
9187
- function swarmRootCandidates(ctx) {
9173
+ function hookRootOf(input) {
9174
+ try {
9175
+ return resolveProjectRoot(input.cwd || void 0);
9176
+ } catch {
9177
+ return void 0;
9178
+ }
9179
+ }
9180
+ function swarmRootCandidates(ctx, input) {
9188
9181
  const out = [];
9189
- for (const r of orderedRoots(ctx.root)) {
9182
+ for (const r of orderedRoots(hookRootOf(input))) {
9190
9183
  if (r === ctx.root) {
9191
9184
  out.push(ctx);
9192
9185
  continue;
@@ -9198,8 +9191,8 @@ function swarmRootCandidates(ctx) {
9198
9191
  }
9199
9192
  return out;
9200
9193
  }
9201
- function swarmScope(hookCtx, agentType) {
9202
- for (const ctx of swarmRootCandidates(hookCtx)) {
9194
+ function swarmScope(hookCtx, input, agentType) {
9195
+ for (const ctx of swarmRootCandidates(hookCtx, input)) {
9203
9196
  const main = coordinationRoot(ctx.root);
9204
9197
  const config = configFor(ctx.root, main, agentType);
9205
9198
  if (!config) continue;
@@ -9219,7 +9212,7 @@ function swarmPreAgent(ctx, input) {
9219
9212
  if (!isSwarmAgentType(agentType)) return void 0;
9220
9213
  let scope;
9221
9214
  try {
9222
- scope = swarmScope(ctx, agentType);
9215
+ scope = swarmScope(ctx, input, agentType);
9223
9216
  } catch (err) {
9224
9217
  return fail("preAgent", err);
9225
9218
  }
@@ -9427,7 +9420,7 @@ function isBusy(err) {
9427
9420
  function swarmTouch(ctx, input) {
9428
9421
  if (!input.agent_id || !isSwarmAgentType(input.agent_type)) return;
9429
9422
  try {
9430
- const s = swarmScope(ctx, input.agent_type);
9423
+ const s = swarmScope(ctx, input, input.agent_type);
9431
9424
  if (s) touchWorker(s.db, input.agent_id);
9432
9425
  } catch (err) {
9433
9426
  fail("touch", err);
@@ -9474,7 +9467,7 @@ function swarmAgentReturned(ctx, input) {
9474
9467
  const agentType = spawnType(input);
9475
9468
  if (!isSwarmAgentType(agentType) || !input.tool_use_id) return;
9476
9469
  try {
9477
- const s = swarmScope(ctx, agentType);
9470
+ const s = swarmScope(ctx, input, agentType);
9478
9471
  if (s) releaseSpawn(s.db, input.tool_use_id);
9479
9472
  } catch (err) {
9480
9473
  fail("agentReturned", err);
@@ -9483,7 +9476,7 @@ function swarmAgentReturned(ctx, input) {
9483
9476
  function swarmSessionEnd(ctx, input) {
9484
9477
  if (!input.session_id) return;
9485
9478
  try {
9486
- const s = swarmScope(ctx);
9479
+ const s = swarmScope(ctx, input);
9487
9480
  if (s) closeSessionWorkers(s.db, input.session_id);
9488
9481
  } catch (err) {
9489
9482
  fail("sessionEnd", err);
@@ -9497,7 +9490,7 @@ async function swarmSubagentStart(ctx, input) {
9497
9490
  if (!isSwarmAgentType(agentType) || !input.agent_id) return void 0;
9498
9491
  let s;
9499
9492
  try {
9500
- s = swarmScope(ctx, agentType);
9493
+ s = swarmScope(ctx, input, agentType);
9501
9494
  } catch (err) {
9502
9495
  return fail("subagentStart", err);
9503
9496
  }
@@ -9555,7 +9548,7 @@ function fallbackBrief(role, swarm, runId) {
9555
9548
  var subagentStart = async (input) => {
9556
9549
  if (!isSwarmAgentType(input.agent_type) || !input.agent_id) return void 0;
9557
9550
  try {
9558
- return await swarmSubagentStart(getContext(input.cwd), input);
9551
+ return await swarmSubagentStart(sessionContext(input.cwd), input);
9559
9552
  } catch (err) {
9560
9553
  return fail("subagentStart", err);
9561
9554
  }
@@ -9564,7 +9557,7 @@ function swarmActivity(ctx, input, failed) {
9564
9557
  const agentType = input.agent_type;
9565
9558
  if (!isSwarmAgentType(agentType) || !input.agent_id || !input.tool_name) return;
9566
9559
  try {
9567
- const s = swarmScope(ctx, agentType);
9560
+ const s = swarmScope(ctx, input, agentType);
9568
9561
  if (!s) return;
9569
9562
  recordActivity(s.db, s.config, s.root, {
9570
9563
  agentId: input.agent_id,
@@ -9583,7 +9576,7 @@ function swarmSubagentStop(ctx, input) {
9583
9576
  const agentType = input.agent_type;
9584
9577
  if (!isSwarmAgentType(agentType) || !input.agent_id) return;
9585
9578
  try {
9586
- const s = swarmScope(ctx, agentType);
9579
+ const s = swarmScope(ctx, input, agentType);
9587
9580
  if (!s) return;
9588
9581
  closeWorker(s.db, s.config, {
9589
9582
  agentId: input.agent_id,
@@ -9905,4 +9898,4 @@ queue-microtask/index.js:
9905
9898
  run-parallel/index.js:
9906
9899
  (*! run-parallel. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
9907
9900
  */
9908
- //# sourceMappingURL=hook-chunk-ZLRLOPLR.js.map
9901
+ //# sourceMappingURL=hook-chunk-6EFFDI3S.js.map
@@ -13,7 +13,7 @@ import {
13
13
  init_esm_shims,
14
14
  loadConfig,
15
15
  paths
16
- } from "./hook-chunk-ETYHCPPH.js";
16
+ } from "./hook-chunk-G7UP4ZVA.js";
17
17
 
18
18
  // src/adjudicator/async.ts
19
19
  init_esm_shims();
@@ -3777,4 +3777,4 @@ export {
3777
3777
  parseJob,
3778
3778
  runAsyncJob
3779
3779
  };
3780
- //# sourceMappingURL=hook-chunk-MVSMFCKL.js.map
3780
+ //# sourceMappingURL=hook-chunk-77LASZ3C.js.map