@fro.bot/systematic 3.36.0 → 3.38.0

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.
@@ -25,7 +25,7 @@ function parseFrontmatter(content) {
25
25
  // src/lib/config.ts
26
26
  import fs5 from "fs";
27
27
  import os3 from "os";
28
- import path4 from "path";
28
+ import path5 from "path";
29
29
 
30
30
  // node_modules/.bun/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/scanner.js
31
31
  function createScanner(text, ignoreTrivia = false) {
@@ -7425,6 +7425,13 @@ var OPENCODE_AGENT_COLOR_TOKENS = [
7425
7425
  "info"
7426
7426
  ];
7427
7427
 
7428
+ // src/lib/opencode-config-dir.ts
7429
+ import path from "path";
7430
+ function opencodeUserConfigDir(homeDir, env = process.env) {
7431
+ const xdg = env.XDG_CONFIG_HOME;
7432
+ return path.join(xdg && path.isAbsolute(xdg) ? xdg : path.join(homeDir, ".config"), "opencode");
7433
+ }
7434
+
7428
7435
  // src/lib/search-bounded-read.ts
7429
7436
  import fs from "fs";
7430
7437
  var READ_CHUNK_BYTES = 64 * 1024;
@@ -7467,7 +7474,7 @@ function readBytesBounded(filePath, maxBytes) {
7467
7474
  // src/lib/search-project-identity.ts
7468
7475
  import fs2 from "fs";
7469
7476
  import os from "os";
7470
- import path from "path";
7477
+ import path2 from "path";
7471
7478
  var MAX_IDENTITY_FILE_BYTES = 1024 * 1024;
7472
7479
  function realpath(target) {
7473
7480
  return fs2.realpathSync.native(target);
@@ -7475,7 +7482,7 @@ function realpath(target) {
7475
7482
  function readSmallFile(file) {
7476
7483
  const read = readBytesBounded(file, MAX_IDENTITY_FILE_BYTES);
7477
7484
  if (read.kind !== "bytes") {
7478
- throw new Error(`${path.basename(file)} cannot be read as an identity file`);
7485
+ throw new Error(`${path2.basename(file)} cannot be read as an identity file`);
7479
7486
  }
7480
7487
  return read.bytes.toString("utf8");
7481
7488
  }
@@ -7484,7 +7491,7 @@ function firstLine(text) {
7484
7491
  `, 1)[0] ?? "").replace(/\r$/, "").trim();
7485
7492
  }
7486
7493
  function resolveFrom(base, value) {
7487
- return path.isAbsolute(value) ? value : path.resolve(base, value);
7494
+ return path2.isAbsolute(value) ? value : path2.resolve(base, value);
7488
7495
  }
7489
7496
  function setsCoreWorktree(config) {
7490
7497
  let inCore = false;
@@ -7507,10 +7514,10 @@ function setsCoreWorktree(config) {
7507
7514
  return false;
7508
7515
  }
7509
7516
  function isSubmoduleGitdir(gitdir) {
7510
- return gitdir.split(path.sep).includes("modules");
7517
+ return gitdir.split(path2.sep).includes("modules");
7511
7518
  }
7512
7519
  function resolveLinkedWorktree(gitFile, gitdir) {
7513
- const commonFile = path.join(gitdir, "commondir");
7520
+ const commonFile = path2.join(gitdir, "commondir");
7514
7521
  if (!fs2.existsSync(commonFile)) {
7515
7522
  return { reason: "missing-commondir" };
7516
7523
  }
@@ -7519,27 +7526,27 @@ function resolveLinkedWorktree(gitFile, gitdir) {
7519
7526
  return { reason: "corrupt-git-file" };
7520
7527
  }
7521
7528
  const common = realpath(resolveFrom(gitdir, commonRaw));
7522
- if (gitdir !== path.join(common, "worktrees", path.basename(gitdir))) {
7529
+ if (gitdir !== path2.join(common, "worktrees", path2.basename(gitdir))) {
7523
7530
  return { reason: "inconsistent" };
7524
7531
  }
7525
- const backRaw = firstLine(readSmallFile(path.join(gitdir, "gitdir")));
7532
+ const backRaw = firstLine(readSmallFile(path2.join(gitdir, "gitdir")));
7526
7533
  if (backRaw === "") {
7527
7534
  return { reason: "corrupt-git-file" };
7528
7535
  }
7529
7536
  if (realpath(resolveFrom(gitdir, backRaw)) !== realpath(gitFile)) {
7530
7537
  return { reason: "inconsistent" };
7531
7538
  }
7532
- if (path.basename(common) !== ".git") {
7539
+ if (path2.basename(common) !== ".git") {
7533
7540
  return { reason: "unsupported-layout" };
7534
7541
  }
7535
- if (setsCoreWorktree(readSmallFile(path.join(common, "config")))) {
7542
+ if (setsCoreWorktree(readSmallFile(path2.join(common, "config")))) {
7536
7543
  return { reason: "core-worktree" };
7537
7544
  }
7538
- return { root: path.dirname(common) };
7545
+ return { root: path2.dirname(common) };
7539
7546
  }
7540
7547
  function deriveMainRoot(checkoutRoot) {
7541
7548
  const root = realpath(checkoutRoot);
7542
- const gitPath = path.join(root, ".git");
7549
+ const gitPath = path2.join(root, ".git");
7543
7550
  let stat;
7544
7551
  try {
7545
7552
  stat = fs2.lstatSync(gitPath);
@@ -7564,7 +7571,7 @@ function deriveMainRoot(checkoutRoot) {
7564
7571
  if (!fs2.statSync(gitdir).isDirectory()) {
7565
7572
  return { reason: "corrupt-git-file" };
7566
7573
  }
7567
- if (path.basename(path.dirname(gitdir)) === "worktrees") {
7574
+ if (path2.basename(path2.dirname(gitdir)) === "worktrees") {
7568
7575
  return resolveLinkedWorktree(gitPath, gitdir);
7569
7576
  }
7570
7577
  if (isSubmoduleGitdir(gitdir)) {
@@ -7584,8 +7591,8 @@ function expandHome(entry, homeDir) {
7584
7591
  if (entry === "~") {
7585
7592
  return homeDir;
7586
7593
  }
7587
- if (entry.startsWith("~/") || entry.startsWith(`~${path.sep}`)) {
7588
- return path.join(homeDir, entry.slice(2));
7594
+ if (entry.startsWith("~/") || entry.startsWith(`~${path2.sep}`)) {
7595
+ return path2.join(homeDir, entry.slice(2));
7589
7596
  }
7590
7597
  return entry;
7591
7598
  }
@@ -7605,7 +7612,7 @@ function isAllowedProject(identity, allowList, options = {}) {
7605
7612
  continue;
7606
7613
  }
7607
7614
  const expanded = expandHome(entry, homeDir);
7608
- if (expanded === undefined || !path.isAbsolute(expanded)) {
7615
+ if (expanded === undefined || !path2.isAbsolute(expanded)) {
7609
7616
  continue;
7610
7617
  }
7611
7618
  try {
@@ -7623,6 +7630,44 @@ var MAX_ALLOW_PROJECT_LENGTH = 4096;
7623
7630
  var MAX_CONNECT_CONFIG_BYTES = 1024 * 1024;
7624
7631
  var MAX_CONNECT_GROUPS = 32;
7625
7632
  var CONNECT_GROUP_NAME_PATTERN = /^[a-z0-9][a-z0-9-]{0,63}$/;
7633
+ var MAX_CONNECT_PINS = 64;
7634
+ var MAX_PIN_FILE_LENGTH = 256;
7635
+ var MAX_PIN_KEY_LENGTH = 256;
7636
+ var PIN_FILE_PATTERN = /^(?!\/)(?!(?:.*\/)?\.\.(?:\/|$))[A-Za-z0-9._/-]+$/;
7637
+ var OWNER = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/;
7638
+ var REPO = /^[A-Za-z0-9._-]{1,100}$/;
7639
+ function isGithubOwnerRepo(value) {
7640
+ const parts = value.split("/");
7641
+ const [owner, name] = parts;
7642
+ return parts.length === 2 && owner !== undefined && name !== undefined && OWNER.test(owner) && REPO.test(name) && name !== "." && name !== "..";
7643
+ }
7644
+ function hasControlCharacter(value) {
7645
+ for (const char of value) {
7646
+ const code = char.codePointAt(0) ?? 0;
7647
+ if (code < 32 || code >= 127 && code <= 159)
7648
+ return true;
7649
+ }
7650
+ return false;
7651
+ }
7652
+ function isPinKey(value) {
7653
+ return value.length > 0 && value.length <= MAX_PIN_KEY_LENGTH && !hasControlCharacter(value) && value.split(".").every((segment) => segment.length > 0);
7654
+ }
7655
+ function unionPins(lists) {
7656
+ const seen = new Map;
7657
+ for (const list of lists) {
7658
+ for (const pin of list ?? []) {
7659
+ const identity = JSON.stringify([
7660
+ pin.project,
7661
+ pin.upstream,
7662
+ pin.file,
7663
+ pin.key
7664
+ ]);
7665
+ if (!seen.has(identity))
7666
+ seen.set(identity, pin);
7667
+ }
7668
+ }
7669
+ return [...seen.values()];
7670
+ }
7626
7671
 
7627
7672
  // src/lib/removed-names.ts
7628
7673
  var REMOVED_BUNDLED_SKILL_NAMES = [
@@ -7685,7 +7730,7 @@ var REMOVED_CONFIG_KEYS = [
7685
7730
  // src/lib/search-user-config.ts
7686
7731
  import fs3 from "fs";
7687
7732
  import os2 from "os";
7688
- import path2 from "path";
7733
+ import path3 from "path";
7689
7734
 
7690
7735
  // src/lib/search-exclude.ts
7691
7736
  var MAX_EXCLUDE_PATTERNS = 64;
@@ -7986,10 +8031,10 @@ function isTildePath(value) {
7986
8031
  return value === "~" || value.startsWith("~/") || value.startsWith("~\\");
7987
8032
  }
7988
8033
  function isUserPathForm(value) {
7989
- return typeof value === "string" && value.length > 0 && !hasControlChar(value) && (isTildePath(value) || path2.isAbsolute(value));
8034
+ return typeof value === "string" && value.length > 0 && !hasControlChar(value) && (isTildePath(value) || path3.isAbsolute(value));
7990
8035
  }
7991
8036
  function isAbsoluteAnywhere(value) {
7992
- return path2.isAbsolute(value) || path2.posix.isAbsolute(value) || path2.win32.isAbsolute(value);
8037
+ return path3.isAbsolute(value) || path3.posix.isAbsolute(value) || path3.win32.isAbsolute(value);
7993
8038
  }
7994
8039
  function isProjectRoot(root, format) {
7995
8040
  if (root.length === 0 || hasControlChar(root))
@@ -8288,19 +8333,19 @@ function configEntryExists(target) {
8288
8333
  }
8289
8334
  }
8290
8335
  function selectConfigFile(dir, basename) {
8291
- const jsoncPath = path2.join(dir, `${basename}.jsonc`);
8336
+ const jsoncPath = path3.join(dir, `${basename}.jsonc`);
8292
8337
  if (configEntryExists(jsoncPath))
8293
8338
  return jsoncPath;
8294
- return path2.join(dir, `${basename}.json`);
8339
+ return path3.join(dir, `${basename}.json`);
8295
8340
  }
8296
8341
  function resolveUserLevelConfigDirs(options) {
8297
8342
  const homeDir = options?.homeDir ?? os2.homedir();
8298
- const userConfigDir = options?.userConfigDir ?? path2.join(homeDir, ".config/opencode");
8343
+ const userConfigDir = options?.userConfigDir ?? opencodeUserConfigDir(homeDir);
8299
8344
  const rawCustom = options !== undefined && Object.hasOwn(options, "customConfigDir") ? options.customConfigDir?.trim() : process.env.OPENCODE_CONFIG_DIR?.trim();
8300
8345
  return { homeDir, userConfigDir, customConfigDir: rawCustom || undefined };
8301
8346
  }
8302
8347
  function realpathOrResolved(dir) {
8303
- const resolved = path2.resolve(dir);
8348
+ const resolved = path3.resolve(dir);
8304
8349
  try {
8305
8350
  return fs3.realpathSync(resolved);
8306
8351
  } catch {
@@ -8325,11 +8370,11 @@ function selectUserLevelConfigFiles(dirs) {
8325
8370
  layer: "custom.local",
8326
8371
  path: selectConfigFile(custom, "systematic.local")
8327
8372
  });
8328
- const aliased = path2.resolve(custom) === path2.resolve(dirs.userConfigDir) || realpathOrResolved(custom) === realpathOrResolved(dirs.userConfigDir);
8373
+ const aliased = path3.resolve(custom) === path3.resolve(dirs.userConfigDir) || realpathOrResolved(custom) === realpathOrResolved(dirs.userConfigDir);
8329
8374
  return { files, aliased };
8330
8375
  }
8331
8376
  function selectProjectConfigFile(repoRoot) {
8332
- const opencodeFile = selectConfigFile(path2.join(repoRoot, ".opencode"), "systematic");
8377
+ const opencodeFile = selectConfigFile(path3.join(repoRoot, ".opencode"), "systematic");
8333
8378
  const rootFile = selectConfigFile(repoRoot, ".systematic");
8334
8379
  if (!configEntryExists(rootFile))
8335
8380
  return { path: opencodeFile };
@@ -8340,7 +8385,7 @@ function findStartDirProjectConfig(startDir, repoRoot, selectedProjectConfig) {
8340
8385
  return;
8341
8386
  if (realpathOrResolved(startDir) === repoRoot.root)
8342
8387
  return;
8343
- const candidate = selectConfigFile(path2.join(startDir, ".opencode"), "systematic");
8388
+ const candidate = selectConfigFile(path3.join(startDir, ".opencode"), "systematic");
8344
8389
  if (!configEntryExists(candidate))
8345
8390
  return;
8346
8391
  return realpathOrResolved(candidate) === realpathOrResolved(selectedProjectConfig) ? undefined : candidate;
@@ -8766,6 +8811,37 @@ var ConnectSettingsSchema = trustProtected(object({
8766
8811
  }
8767
8812
  ],
8768
8813
  maxProperties: MAX_CONNECT_GROUPS
8814
+ }),
8815
+ pins: array(object({
8816
+ project: string().min(1).max(MAX_ALLOW_PROJECT_LENGTH).meta({
8817
+ description: `The project that pins the upstream, written as an \`allow_projects\` entry: an absolute or \`~\`-prefixed path. It must match, exactly as written or by its resolved root, an allow-list entry that the run has selected; any other pin is dropped without a read. A pin never adds a project to the allow list.`,
8818
+ examples: ["~/src/github.com/me/app"]
8819
+ }),
8820
+ upstream: string().refine(isGithubOwnerRepo).meta({
8821
+ description: "The GitHub `owner/repo` of the upstream that the project pins. It matches an allowed checkout whose git `origin` is this repository, ignoring case.",
8822
+ examples: ["anomalyco/opencode"]
8823
+ }),
8824
+ file: string().min(1).max(MAX_PIN_FILE_LENGTH).regex(PIN_FILE_PATTERN).meta({
8825
+ description: `The JSON or JSONC file in the project's working tree that holds the pin, as a repo-relative path. Letters, digits, \`.\`, \`_\`, \`-\` and \`/\` only, at most ${MAX_PIN_FILE_LENGTH} characters, with no leading slash and no \`..\` segment (\`${PIN_FILE_PATTERN.source}\`).`,
8826
+ examples: ["package.json"]
8827
+ }),
8828
+ key: string().refine(isPinKey).meta({
8829
+ description: `A dotted path to a string value in the file, such as \`dependencies.opencode\`. One or more non-empty segments joined by single dots, at most ${MAX_PIN_KEY_LENGTH} characters, with no control character. An array index is not supported.`,
8830
+ maxLength: MAX_PIN_KEY_LENGTH,
8831
+ examples: ["dependencies.opencode"]
8832
+ })
8833
+ }).strict()).max(MAX_CONNECT_PINS).optional().meta({
8834
+ description: `Dependency pins that \`ce:connect\` shows the researcher, so a claim that is true at one version of an upstream and false at another can be checked. Each entry says that \`project\` pins \`upstream\` at the value found under \`key\` in \`file\`. At \`begin\` the helper reads that value from the project's working tree and finds every selected allowed checkout whose git \`origin\` is the upstream. It reads each one's version from the git tag at its HEAD, or reports it as unknown, and gives the researcher one fixed line per pair. A pin never widens the allow list or the selection, and is dropped silently when its project is not selected or no selected checkout matches. At most ${MAX_CONNECT_PINS} pins per file. The lists in user, user.local, custom and custom.local config are merged as a union, with an identical pin kept once; entries that name different files for the same project, upstream and key are dropped at run time with a note. The helper states the versions and the researcher judges them: a pin is a hint, not evidence.`,
8835
+ examples: [
8836
+ [
8837
+ {
8838
+ project: "~/src/github.com/me/app",
8839
+ upstream: "anomalyco/opencode",
8840
+ file: "package.json",
8841
+ key: "dependencies.opencode"
8842
+ }
8843
+ ]
8844
+ ]
8769
8845
  })
8770
8846
  }).strict().meta({
8771
8847
  description: "Cross-project connections. User-owned only: valid in user config or OPENCODE_CONFIG_DIR config, and a project config setting it has the whole block ignored with a warning, because a repository cannot grant itself access to other projects. A block with an unknown key or a bad value is unreadable and counts as an empty allow list and no groups.",
@@ -9233,7 +9309,7 @@ function collectWrittenLegacyPiSubagentsThinkingWarnings(piSubagentsOverlays) {
9233
9309
 
9234
9310
  // src/lib/search-corpus.ts
9235
9311
  import fs4 from "fs";
9236
- import path3 from "path";
9312
+ import path4 from "path";
9237
9313
  var MAX_FILE_BYTES = 256 * 1024;
9238
9314
  var MAX_FILES = 2000;
9239
9315
  var MAX_DEPTH = 6;
@@ -9366,18 +9442,18 @@ function listDirectoryBounded(target, limit) {
9366
9442
  }
9367
9443
  }
9368
9444
  function walkToGitRoot(startDir) {
9369
- const resolved = path3.resolve(startDir);
9445
+ const resolved = path4.resolve(startDir);
9370
9446
  const start = safeRealpath(resolved) ?? resolved;
9371
9447
  let current = start;
9372
9448
  while (true) {
9373
9449
  try {
9374
- if (fs4.lstatSync(path3.join(current, ".git"), { throwIfNoEntry: false })) {
9450
+ if (fs4.lstatSync(path4.join(current, ".git"), { throwIfNoEntry: false })) {
9375
9451
  return { gitRoot: current, start };
9376
9452
  }
9377
9453
  } catch {
9378
9454
  return { gitRoot: null, start };
9379
9455
  }
9380
- const parent = path3.dirname(current);
9456
+ const parent = path4.dirname(current);
9381
9457
  if (parent === current)
9382
9458
  return { gitRoot: null, start };
9383
9459
  current = parent;
@@ -9392,16 +9468,16 @@ function lookupSearchRoot(startDir) {
9392
9468
  return gitRoot === null ? { root: startDir, foundGit: false } : { root: gitRoot, foundGit: true };
9393
9469
  }
9394
9470
  function isInside(root, candidate) {
9395
- const relative = path3.relative(root, candidate);
9396
- return relative !== "" && relative !== ".." && !relative.startsWith(`..${path3.sep}`) && !path3.isAbsolute(relative);
9471
+ const relative = path4.relative(root, candidate);
9472
+ return relative !== "" && relative !== ".." && !relative.startsWith(`..${path4.sep}`) && !path4.isAbsolute(relative);
9397
9473
  }
9398
9474
  function symlinkedComponent(container, target) {
9399
9475
  if (!isInside(container, target))
9400
9476
  return;
9401
- const segments = path3.relative(container, target).split(path3.sep);
9477
+ const segments = path4.relative(container, target).split(path4.sep);
9402
9478
  let current = container;
9403
9479
  for (const [index, segment] of segments.entries()) {
9404
- current = path3.join(current, segment);
9480
+ current = path4.join(current, segment);
9405
9481
  const stat = safeLstat(current);
9406
9482
  if (stat === null)
9407
9483
  return;
@@ -9477,7 +9553,7 @@ function discoverFiles(spec, label, directory, prefix, depth, found, warnings) {
9477
9553
  return;
9478
9554
  if (found.isExcluded?.(`${prefix}${name}`) === true)
9479
9555
  continue;
9480
- const absolute = path3.join(directory, name);
9556
+ const absolute = path4.join(directory, name);
9481
9557
  const stat = safeLstat(absolute);
9482
9558
  const entryKind = classifyEntry(spec, name, stat);
9483
9559
  if (entryKind === "directory" && depth + 1 <= MAX_DEPTH) {
@@ -9698,7 +9774,7 @@ function loadSourceFiles(discover, read) {
9698
9774
  function loadCorpus(root, kind = "solution") {
9699
9775
  const spec = KIND_TABLE[kind];
9700
9776
  const loaded = loadSourceFiles({
9701
- directory: path3.join(root, ...spec.dir.split("/")),
9777
+ directory: path4.join(root, ...spec.dir.split("/")),
9702
9778
  containedIn: root,
9703
9779
  walk: spec,
9704
9780
  label: spec.dir
@@ -10120,7 +10196,7 @@ function resolveConfigSourcePath(filePath) {
10120
10196
  try {
10121
10197
  return fs5.realpathSync(filePath);
10122
10198
  } catch {
10123
- return path4.resolve(filePath);
10199
+ return path5.resolve(filePath);
10124
10200
  }
10125
10201
  }
10126
10202
  function emitTopLevelProtectedFieldWarning(projectSource, fieldPath, messageTemplate, sink) {
@@ -10546,10 +10622,12 @@ function mergeConnect(sources) {
10546
10622
  groups[name] = [...members];
10547
10623
  }
10548
10624
  }
10625
+ const pins = unionPins(blocks.map((block) => block.pins));
10549
10626
  return {
10550
10627
  connect: {
10551
10628
  allow_projects: blocks.reduce((merged, block) => mergeArraysUnique(merged, block.allow_projects), []),
10552
- ...hasGroups && { groups }
10629
+ ...hasGroups && { groups },
10630
+ ...pins.length > 0 && { pins }
10553
10631
  }
10554
10632
  };
10555
10633
  }
@@ -11132,7 +11210,7 @@ function throwInvalidOverlay(sourcePath, keyPath) {
11132
11210
  }
11133
11211
  function getConfigPaths(projectDir, options) {
11134
11212
  const dirs = resolveUserLevelConfigDirs(options);
11135
- const { homeDir, customConfigDir } = dirs;
11213
+ const { customConfigDir } = dirs;
11136
11214
  const selection = selectUserLevelConfigFiles(dirs);
11137
11215
  const fileFor = (layer) => selection.files.find((file) => file.layer === layer)?.path;
11138
11216
  const userFile = (layer) => {
@@ -11145,7 +11223,7 @@ function getConfigPaths(projectDir, options) {
11145
11223
  const repoRoot = options?.includeProject ?? true ? lookupSearchRoot(projectDir) : undefined;
11146
11224
  const projectRoot = repoRoot?.root ?? projectDir;
11147
11225
  const project = repoRoot ? selectProjectConfigFile(projectRoot) : {
11148
- path: selectConfigFile(path4.join(projectDir, ".opencode"), "systematic")
11226
+ path: selectConfigFile(path5.join(projectDir, ".opencode"), "systematic")
11149
11227
  };
11150
11228
  const startDirProjectConfig = repoRoot ? findStartDirProjectConfig(projectDir, repoRoot, project.path) : undefined;
11151
11229
  const ignoredProjectConfig = "ignoredPath" in project ? project.ignoredPath : undefined;
@@ -11156,22 +11234,22 @@ function getConfigPaths(projectDir, options) {
11156
11234
  userLocalConfig: userFile("user.local"),
11157
11235
  projectConfig: project.path,
11158
11236
  projectRoot,
11159
- userDir: path4.join(homeDir, ".config/opencode/systematic"),
11160
- projectDir: path4.join(projectRoot, ".opencode/systematic"),
11237
+ userDir: path5.join(dirs.userConfigDir, "systematic"),
11238
+ projectDir: path5.join(projectRoot, ".opencode/systematic"),
11161
11239
  customAliasesUser: selection.aliased,
11162
11240
  ...ignoredProjectConfig !== undefined && { ignoredProjectConfig },
11163
11241
  ...startDirProjectConfig !== undefined && { startDirProjectConfig },
11164
11242
  ...customConfigDir && customConfig !== undefined && customLocalConfig !== undefined && {
11165
11243
  customConfig,
11166
11244
  customLocalConfig,
11167
- customDir: path4.join(customConfigDir, "systematic")
11245
+ customDir: path5.join(customConfigDir, "systematic")
11168
11246
  }
11169
11247
  };
11170
11248
  }
11171
11249
 
11172
11250
  // src/lib/walk-dir.ts
11173
11251
  import fs6 from "fs";
11174
- import path5 from "path";
11252
+ import path6 from "path";
11175
11253
  function isDiscoverableMarkdown(fileName) {
11176
11254
  return fileName.endsWith(".md") && fileName.toLowerCase() !== "readme.md";
11177
11255
  }
@@ -11185,7 +11263,7 @@ function walkDir(rootDir, options = {}) {
11185
11263
  return;
11186
11264
  const entries = fs6.readdirSync(currentDir, { withFileTypes: true });
11187
11265
  for (const entry of entries) {
11188
- const fullPath = path5.join(currentDir, entry.name);
11266
+ const fullPath = path6.join(currentDir, entry.name);
11189
11267
  const walkEntry = {
11190
11268
  path: fullPath,
11191
11269
  name: entry.name,
@@ -11281,11 +11359,11 @@ function extractCommandFrontmatter(content) {
11281
11359
 
11282
11360
  // src/lib/discovered-skills.ts
11283
11361
  import fs8 from "fs";
11284
- import path7 from "path";
11362
+ import path8 from "path";
11285
11363
 
11286
11364
  // src/lib/skills.ts
11287
11365
  import fs7 from "fs";
11288
- import path6 from "path";
11366
+ import path7 from "path";
11289
11367
  function parseMetadata(data) {
11290
11368
  const metadataRaw = data.metadata;
11291
11369
  if (!isRecord(metadataRaw)) {
@@ -11335,7 +11413,7 @@ function findSkillsInDir(dir, maxDepth = 3) {
11335
11413
  filter: (e) => e.isDirectory
11336
11414
  });
11337
11415
  for (const entry of entries) {
11338
- const skillFile = path6.join(entry.path, "SKILL.md");
11416
+ const skillFile = path7.join(entry.path, "SKILL.md");
11339
11417
  if (fs7.existsSync(skillFile)) {
11340
11418
  const frontmatter = extractFrontmatter(skillFile);
11341
11419
  skills.push({
@@ -11365,16 +11443,16 @@ function isValidSkillName(name) {
11365
11443
  return name.length >= 1 && name.length <= 64 && SKILL_NAME_REGEX.test(name);
11366
11444
  }
11367
11445
  function findGitWorktreeRoot(startDir) {
11368
- let current = path7.resolve(startDir);
11446
+ let current = path8.resolve(startDir);
11369
11447
  while (true) {
11370
11448
  try {
11371
- if (fs8.existsSync(path7.join(current, ".git"))) {
11449
+ if (fs8.existsSync(path8.join(current, ".git"))) {
11372
11450
  return current;
11373
11451
  }
11374
11452
  } catch {
11375
11453
  return null;
11376
11454
  }
11377
- const parent = path7.dirname(current);
11455
+ const parent = path8.dirname(current);
11378
11456
  if (parent === current)
11379
11457
  return null;
11380
11458
  current = parent;
@@ -11382,11 +11460,11 @@ function findGitWorktreeRoot(startDir) {
11382
11460
  }
11383
11461
  function upWalk(targets, start, stop) {
11384
11462
  const results = [];
11385
- let current = path7.resolve(start);
11386
- const resolvedStop = stop === undefined ? undefined : path7.resolve(stop);
11463
+ let current = path8.resolve(start);
11464
+ const resolvedStop = stop === undefined ? undefined : path8.resolve(stop);
11387
11465
  while (true) {
11388
11466
  for (const target of targets) {
11389
- const candidate = path7.join(current, target);
11467
+ const candidate = path8.join(current, target);
11390
11468
  try {
11391
11469
  if (fs8.existsSync(candidate)) {
11392
11470
  results.push(candidate);
@@ -11395,7 +11473,7 @@ function upWalk(targets, start, stop) {
11395
11473
  }
11396
11474
  if (resolvedStop !== undefined && current === resolvedStop)
11397
11475
  break;
11398
- const parent = path7.dirname(current);
11476
+ const parent = path8.dirname(current);
11399
11477
  if (parent === current)
11400
11478
  break;
11401
11479
  current = parent;
@@ -11417,7 +11495,7 @@ function buildOpencodeConfigDirs(startDir, homeDir, gitRoot, globalConfigDir, op
11417
11495
  function globSkillFiles(rootDir, subdirNames) {
11418
11496
  const results = [];
11419
11497
  for (const subdirName of subdirNames) {
11420
- const scanRoot = path7.join(rootDir, subdirName);
11498
+ const scanRoot = path8.join(rootDir, subdirName);
11421
11499
  try {
11422
11500
  if (!fs8.existsSync(scanRoot))
11423
11501
  continue;
@@ -11461,7 +11539,7 @@ function toDiscoveredSkill(skillPath, rootId, onIssue) {
11461
11539
  }
11462
11540
  function discoverSkills(options) {
11463
11541
  const { startDir, homeDir, configDir, onIssue, opencodeConfigDirOverride } = options;
11464
- const globalConfigDir = configDir ?? path7.join(homeDir, ".config/opencode");
11542
+ const globalConfigDir = configDir ?? opencodeUserConfigDir(homeDir);
11465
11543
  const gitRoot = findGitWorktreeRoot(startDir);
11466
11544
  const byName = new Map;
11467
11545
  function upsertAll(skillPaths, rootId) {
@@ -11475,8 +11553,8 @@ function discoverSkills(options) {
11475
11553
  upsertAll(globSkillFiles(homeDir, [".agents/skills"]), "global-agents");
11476
11554
  const externalLevels = upWalk([".claude", ".agents"], startDir, gitRoot ?? startDir);
11477
11555
  for (const levelDir of externalLevels) {
11478
- const isClaudeDir = path7.basename(levelDir) === ".claude";
11479
- const parentDir = path7.dirname(levelDir);
11556
+ const isClaudeDir = path8.basename(levelDir) === ".claude";
11557
+ const parentDir = path8.dirname(levelDir);
11480
11558
  const subdirGlob = isClaudeDir ? ".claude/skills" : ".agents/skills";
11481
11559
  const rootId = isClaudeDir ? "project-claude" : "project-agents";
11482
11560
  upsertAll(globSkillFiles(parentDir, [subdirGlob]), rootId);
@@ -11491,14 +11569,14 @@ function discoverSkills(options) {
11491
11569
 
11492
11570
  // src/lib/search-core.ts
11493
11571
  import fs10 from "fs";
11494
- import path11 from "path";
11572
+ import path12 from "path";
11495
11573
 
11496
11574
  // src/lib/search-external.ts
11497
- import path9 from "path";
11575
+ import path10 from "path";
11498
11576
 
11499
11577
  // src/lib/search-external-deciduous.ts
11500
11578
  import fs9 from "fs";
11501
- import path8 from "path";
11579
+ import path9 from "path";
11502
11580
  var RECORD_NODE_TYPES = new Set([
11503
11581
  "decision",
11504
11582
  "option",
@@ -11544,7 +11622,7 @@ function classifyJsonEntry(directory, folder, name, skips, isExcluded) {
11544
11622
  return;
11545
11623
  if (isExcluded(`${folder}/${name}`))
11546
11624
  return;
11547
- const absolute = path8.join(directory, name);
11625
+ const absolute = path9.join(directory, name);
11548
11626
  const entry = safeLstat(absolute);
11549
11627
  if (entry === null)
11550
11628
  return;
@@ -11575,7 +11653,7 @@ function statFolder(directory) {
11575
11653
  function scanFolder(rootReal, folder, limit, skips, budget, isExcluded) {
11576
11654
  if (isExcluded(folder))
11577
11655
  return folderScan("excluded");
11578
- const directory = path8.join(rootReal, folder);
11656
+ const directory = path9.join(rootReal, folder);
11579
11657
  const probed = statFolder(directory);
11580
11658
  if (probed.kind === "absent")
11581
11659
  return folderScan("absent");
@@ -12170,7 +12248,7 @@ function loadSource(source, context) {
12170
12248
  return LOADERS[source.format](source, context);
12171
12249
  }
12172
12250
  function loadExternalSources(input) {
12173
- const checkoutRoot = path9.resolve(input.checkoutRoot);
12251
+ const checkoutRoot = path10.resolve(input.checkoutRoot);
12174
12252
  let remainingBytes = input.budgetBytes ?? EXTERNAL_TOTAL_BUDGET_BYTES;
12175
12253
  const loads = [];
12176
12254
  for (const source of input.sources) {
@@ -12187,14 +12265,14 @@ function loadExternalSources(input) {
12187
12265
 
12188
12266
  // src/lib/search-external-sources.ts
12189
12267
  import os4 from "os";
12190
- import path10 from "path";
12268
+ import path11 from "path";
12191
12269
  var MAX_ACTIVE_SOURCES = 8;
12192
12270
  var MAX_LISTED_DROPPED = 8;
12193
12271
  function expandHome2(root, homeDir) {
12194
12272
  if (root === "~")
12195
12273
  return homeDir;
12196
12274
  if (root.startsWith("~/") || root.startsWith("~\\")) {
12197
- return path10.join(homeDir, root.slice(2));
12275
+ return path11.join(homeDir, root.slice(2));
12198
12276
  }
12199
12277
  return root;
12200
12278
  }
@@ -12223,7 +12301,7 @@ function projectSourceOf(entry, checkoutRoot) {
12223
12301
  return {
12224
12302
  name: entry.name,
12225
12303
  format: entry.format,
12226
- roots: entry.roots.map((root) => path10.resolve(checkoutRoot, root)),
12304
+ roots: entry.roots.map((root) => path11.resolve(checkoutRoot, root)),
12227
12305
  origin: "project",
12228
12306
  exclude: entry.exclude ?? []
12229
12307
  };
@@ -12282,7 +12360,7 @@ function resolveExternalSources(input) {
12282
12360
  function inspectBuiltInKinds(checkoutRoot) {
12283
12361
  return Object.keys(KIND_TABLE).filter(isDocumentKind).map((kind) => {
12284
12362
  const spec = KIND_TABLE[kind];
12285
- const directory = path10.join(checkoutRoot, ...spec.dir.split("/"));
12363
+ const directory = path11.join(checkoutRoot, ...spec.dir.split("/"));
12286
12364
  const discovery = discoverSourceFiles({
12287
12365
  directory,
12288
12366
  containedIn: checkoutRoot,
@@ -12318,7 +12396,7 @@ function inspectSearch(input) {
12318
12396
  }));
12319
12397
  const ordered = [...userDeclared, ...projectAllowed ? projectDeclared : []];
12320
12398
  const rejected = projectAllowed ? [] : projectDeclared;
12321
- const loaderRoot = path10.resolve(checkoutRoot);
12399
+ const loaderRoot = path11.resolve(checkoutRoot);
12322
12400
  const outcomes = [...user.entries, ...project.entries];
12323
12401
  const warningsOfKept = new Map;
12324
12402
  for (const outcome of outcomes) {
@@ -13313,7 +13391,7 @@ async function runSearch(request, options) {
13313
13391
  function hasCheckout(startDir) {
13314
13392
  try {
13315
13393
  const root = resolveSearchRoot(startDir);
13316
- return fs10.lstatSync(path11.join(root, ".git"), { throwIfNoEntry: false }) !== undefined;
13394
+ return fs10.lstatSync(path12.join(root, ".git"), { throwIfNoEntry: false }) !== undefined;
13317
13395
  } catch {
13318
13396
  return false;
13319
13397
  }
@@ -13429,4 +13507,4 @@ async function runExternalSearch(checked, options) {
13429
13507
  };
13430
13508
  }
13431
13509
 
13432
- export { parseFrontmatter, parse, parseTree, modify, applyEdits, CONFIG_PROTECTED_FIELD_PATHS, _isoDateTime, _isoDate, _isoTime, _isoDuration, string, ZodISODateTime, ZodISODate, ZodISOTime, ZodISODuration, number, boolean, array, object, union, discriminatedUnion, _enum, literal, displaySafe, configEntryExists, MAX_PROJECT_CONFIG_BYTES, readTextBounded, loadUserLevelSearchSettings, AgentOverlaySchema, CategoryOverlaySchema, isRecord, isPermissionSetting, isAgentMode, extractString, toSourcedPiSubagentsOverlays, resolveRouting, loadConfig, loadConfigWithSources, isAgentDisabled, collectRoutingTargets, getConfigPaths, isDiscoverableMarkdown, findAgentsInDir, extractAgentFrontmatter, findCommandsInDir, extractCommandFrontmatter, findSkillsInDir, discoverSkills, inspectSearch, SEARCH_TOOL_NAME, SEARCH_ARGS, MIN_LIMIT, MAX_LIMIT, KIND_SELECTOR_EXTERNAL, SEARCH_TOOL_DESCRIPTION, SEARCH_ARG_DESCRIPTIONS, SEARCH_NOTICES, SEARCH_CONFIG_UNREADABLE_NOTE, runSearch };
13510
+ export { parseFrontmatter, parse, parseTree, modify, applyEdits, CONFIG_PROTECTED_FIELD_PATHS, _isoDateTime, _isoDate, _isoTime, _isoDuration, string, ZodISODateTime, ZodISODate, ZodISOTime, ZodISODuration, number, boolean, array, object, union, discriminatedUnion, _enum, literal, opencodeUserConfigDir, displaySafe, configEntryExists, MAX_PROJECT_CONFIG_BYTES, readTextBounded, loadUserLevelSearchSettings, AgentOverlaySchema, CategoryOverlaySchema, isRecord, isPermissionSetting, isAgentMode, extractString, toSourcedPiSubagentsOverlays, resolveRouting, loadConfig, loadConfigWithSources, isAgentDisabled, collectRoutingTargets, getConfigPaths, isDiscoverableMarkdown, findAgentsInDir, extractAgentFrontmatter, findCommandsInDir, extractCommandFrontmatter, findSkillsInDir, discoverSkills, inspectSearch, SEARCH_TOOL_NAME, SEARCH_ARGS, MIN_LIMIT, MAX_LIMIT, KIND_SELECTOR_EXTERNAL, SEARCH_TOOL_DESCRIPTION, SEARCH_ARG_DESCRIPTIONS, SEARCH_NOTICES, SEARCH_CONFIG_UNREADABLE_NOTE, runSearch };