@fro.bot/systematic 3.31.6 → 3.32.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.
@@ -1400,6 +1400,7 @@ var BUNDLED_AGENT_NAMES = [
1400
1400
  "cli-readiness-reviewer",
1401
1401
  "code-simplicity-reviewer",
1402
1402
  "coherence-reviewer",
1403
+ "connections-researcher",
1403
1404
  "correctness-reviewer",
1404
1405
  "data-migrations-reviewer",
1405
1406
  "deployment-verification-agent",
@@ -1438,6 +1439,7 @@ var BUNDLED_AGENT_QUALIFIED_IDS = [
1438
1439
  "document-review/scope-guardian-reviewer",
1439
1440
  "document-review/security-lens-reviewer",
1440
1441
  "research/best-practices-researcher",
1442
+ "research/connections-researcher",
1441
1443
  "research/framework-docs-researcher",
1442
1444
  "research/git-history-analyzer",
1443
1445
  "research/issue-intelligence-analyst",
@@ -1474,6 +1476,7 @@ var BUNDLED_SKILL_NAMES = [
1474
1476
  "ce:brainstorm",
1475
1477
  "ce:compound",
1476
1478
  "ce:compound-refresh",
1479
+ "ce:connect",
1477
1480
  "ce:ideate",
1478
1481
  "ce:plan",
1479
1482
  "ce:review",
@@ -1509,6 +1512,7 @@ var CONFIG_PROTECTED_FIELD_PATHS = [
1509
1512
  "allow_project_profiles",
1510
1513
  "search.enabled",
1511
1514
  "search.allow_project_sources",
1515
+ "connect",
1512
1516
  "agents.*.model",
1513
1517
  "agents.*.permission",
1514
1518
  "agents.*.skills",
@@ -7421,6 +7425,203 @@ var OPENCODE_AGENT_COLOR_TOKENS = [
7421
7425
  "info"
7422
7426
  ];
7423
7427
 
7428
+ // src/lib/search-bounded-read.ts
7429
+ import fs from "fs";
7430
+ var READ_CHUNK_BYTES = 64 * 1024;
7431
+ function errorCode(error) {
7432
+ return typeof error === "object" && error !== null && "code" in error ? error.code : undefined;
7433
+ }
7434
+ function readBytesBounded(filePath, maxBytes) {
7435
+ let fd;
7436
+ try {
7437
+ fd = fs.openSync(filePath, fs.constants.O_RDONLY | (fs.constants.O_NONBLOCK ?? 0));
7438
+ } catch (error) {
7439
+ return errorCode(error) === "ENOENT" ? { kind: "absent" } : { kind: "failed" };
7440
+ }
7441
+ try {
7442
+ if (!fs.fstatSync(fd).isFile())
7443
+ return { kind: "not-regular" };
7444
+ const limit = maxBytes + 1;
7445
+ const chunks = [];
7446
+ let total = 0;
7447
+ while (total < limit) {
7448
+ const chunk = Buffer.allocUnsafe(Math.min(READ_CHUNK_BYTES, limit - total));
7449
+ const count = fs.readSync(fd, chunk, 0, chunk.length, null);
7450
+ if (count === 0)
7451
+ break;
7452
+ chunks.push(chunk.subarray(0, count));
7453
+ total += count;
7454
+ }
7455
+ if (total >= limit)
7456
+ return { kind: "too-large", bytesRead: total };
7457
+ return { kind: "bytes", bytes: Buffer.concat(chunks) };
7458
+ } catch {
7459
+ return { kind: "failed" };
7460
+ } finally {
7461
+ try {
7462
+ fs.closeSync(fd);
7463
+ } catch {}
7464
+ }
7465
+ }
7466
+
7467
+ // src/lib/search-project-identity.ts
7468
+ import fs2 from "fs";
7469
+ import os from "os";
7470
+ import path from "path";
7471
+ var MAX_IDENTITY_FILE_BYTES = 1024 * 1024;
7472
+ function realpath(target) {
7473
+ return fs2.realpathSync.native(target);
7474
+ }
7475
+ function readSmallFile(file) {
7476
+ const read = readBytesBounded(file, MAX_IDENTITY_FILE_BYTES);
7477
+ if (read.kind !== "bytes") {
7478
+ throw new Error(`${path.basename(file)} cannot be read as an identity file`);
7479
+ }
7480
+ return read.bytes.toString("utf8");
7481
+ }
7482
+ function firstLine(text) {
7483
+ return (text.split(`
7484
+ `, 1)[0] ?? "").replace(/\r$/, "").trim();
7485
+ }
7486
+ function resolveFrom(base, value) {
7487
+ return path.isAbsolute(value) ? value : path.resolve(base, value);
7488
+ }
7489
+ function setsCoreWorktree(config) {
7490
+ let inCore = false;
7491
+ for (const raw of config.split(`
7492
+ `)) {
7493
+ let line = raw.trim();
7494
+ if (line.startsWith("[")) {
7495
+ const end = line.indexOf("]");
7496
+ if (end === -1) {
7497
+ inCore = false;
7498
+ continue;
7499
+ }
7500
+ inCore = line.slice(1, end).trim().toLowerCase() === "core";
7501
+ line = line.slice(end + 1).trim();
7502
+ }
7503
+ if (inCore && /^worktree\s*(=|$)/i.test(line)) {
7504
+ return true;
7505
+ }
7506
+ }
7507
+ return false;
7508
+ }
7509
+ function isSubmoduleGitdir(gitdir) {
7510
+ return gitdir.split(path.sep).includes("modules");
7511
+ }
7512
+ function resolveLinkedWorktree(gitFile, gitdir) {
7513
+ const commonFile = path.join(gitdir, "commondir");
7514
+ if (!fs2.existsSync(commonFile)) {
7515
+ return { reason: "missing-commondir" };
7516
+ }
7517
+ const commonRaw = firstLine(readSmallFile(commonFile));
7518
+ if (commonRaw === "") {
7519
+ return { reason: "corrupt-git-file" };
7520
+ }
7521
+ const common = realpath(resolveFrom(gitdir, commonRaw));
7522
+ if (gitdir !== path.join(common, "worktrees", path.basename(gitdir))) {
7523
+ return { reason: "inconsistent" };
7524
+ }
7525
+ const backRaw = firstLine(readSmallFile(path.join(gitdir, "gitdir")));
7526
+ if (backRaw === "") {
7527
+ return { reason: "corrupt-git-file" };
7528
+ }
7529
+ if (realpath(resolveFrom(gitdir, backRaw)) !== realpath(gitFile)) {
7530
+ return { reason: "inconsistent" };
7531
+ }
7532
+ if (path.basename(common) !== ".git") {
7533
+ return { reason: "unsupported-layout" };
7534
+ }
7535
+ if (setsCoreWorktree(readSmallFile(path.join(common, "config")))) {
7536
+ return { reason: "core-worktree" };
7537
+ }
7538
+ return { root: path.dirname(common) };
7539
+ }
7540
+ function deriveMainRoot(checkoutRoot) {
7541
+ const root = realpath(checkoutRoot);
7542
+ const gitPath = path.join(root, ".git");
7543
+ let stat;
7544
+ try {
7545
+ stat = fs2.lstatSync(gitPath);
7546
+ } catch {
7547
+ return { reason: "not-a-checkout" };
7548
+ }
7549
+ if (stat.isSymbolicLink()) {
7550
+ return { reason: "symlinked-git" };
7551
+ }
7552
+ if (stat.isDirectory()) {
7553
+ return { root };
7554
+ }
7555
+ if (!stat.isFile()) {
7556
+ return { reason: "corrupt-git-file" };
7557
+ }
7558
+ const match = /^gitdir:[ \t]*(.+)$/.exec(firstLine(readSmallFile(gitPath)));
7559
+ const claimed = match?.[1]?.trim();
7560
+ if (claimed === undefined || claimed === "") {
7561
+ return { reason: "corrupt-git-file" };
7562
+ }
7563
+ const gitdir = realpath(resolveFrom(root, claimed));
7564
+ if (!fs2.statSync(gitdir).isDirectory()) {
7565
+ return { reason: "corrupt-git-file" };
7566
+ }
7567
+ if (path.basename(path.dirname(gitdir)) === "worktrees") {
7568
+ return resolveLinkedWorktree(gitPath, gitdir);
7569
+ }
7570
+ if (isSubmoduleGitdir(gitdir)) {
7571
+ return { root };
7572
+ }
7573
+ return { reason: "unsupported-layout" };
7574
+ }
7575
+ function resolveProjectIdentity(checkoutRoot) {
7576
+ try {
7577
+ const derived = deriveMainRoot(checkoutRoot);
7578
+ return "root" in derived ? { status: "resolved", mainRoot: derived.root } : { status: "unresolved", reason: derived.reason };
7579
+ } catch {
7580
+ return { status: "unresolved", reason: "unreadable" };
7581
+ }
7582
+ }
7583
+ function expandHome(entry, homeDir) {
7584
+ if (entry === "~") {
7585
+ return homeDir;
7586
+ }
7587
+ if (entry.startsWith("~/") || entry.startsWith(`~${path.sep}`)) {
7588
+ return path.join(homeDir, entry.slice(2));
7589
+ }
7590
+ return entry;
7591
+ }
7592
+ function isAllowedProject(identity, allowList, options = {}) {
7593
+ if (identity.status !== "resolved") {
7594
+ return false;
7595
+ }
7596
+ let mainRoot;
7597
+ try {
7598
+ mainRoot = realpath(identity.mainRoot);
7599
+ } catch {
7600
+ return false;
7601
+ }
7602
+ const homeDir = options.homeDir ?? os.homedir();
7603
+ for (const entry of allowList) {
7604
+ if (typeof entry !== "string" || entry === "") {
7605
+ continue;
7606
+ }
7607
+ const expanded = expandHome(entry, homeDir);
7608
+ if (expanded === undefined || !path.isAbsolute(expanded)) {
7609
+ continue;
7610
+ }
7611
+ try {
7612
+ if (realpath(expanded) === mainRoot) {
7613
+ return true;
7614
+ }
7615
+ } catch {}
7616
+ }
7617
+ return false;
7618
+ }
7619
+
7620
+ // src/lib/connect-config.ts
7621
+ var MAX_ALLOW_PROJECTS = 64;
7622
+ var MAX_ALLOW_PROJECT_LENGTH = 4096;
7623
+ var MAX_CONNECT_CONFIG_BYTES = 1024 * 1024;
7624
+
7424
7625
  // src/lib/removed-names.ts
7425
7626
  var REMOVED_BUNDLED_SKILL_NAMES = [
7426
7627
  "andrew-kane-gem-writer",
@@ -7480,48 +7681,9 @@ var REMOVED_CONFIG_KEYS = [
7480
7681
  ];
7481
7682
 
7482
7683
  // src/lib/search-user-config.ts
7483
- import fs2 from "fs";
7484
- import os from "os";
7485
- import path from "path";
7486
-
7487
- // src/lib/search-bounded-read.ts
7488
- import fs from "fs";
7489
- var READ_CHUNK_BYTES = 64 * 1024;
7490
- function errorCode(error) {
7491
- return typeof error === "object" && error !== null && "code" in error ? error.code : undefined;
7492
- }
7493
- function readBytesBounded(filePath, maxBytes) {
7494
- let fd;
7495
- try {
7496
- fd = fs.openSync(filePath, fs.constants.O_RDONLY | (fs.constants.O_NONBLOCK ?? 0));
7497
- } catch (error) {
7498
- return errorCode(error) === "ENOENT" ? { kind: "absent" } : { kind: "failed" };
7499
- }
7500
- try {
7501
- if (!fs.fstatSync(fd).isFile())
7502
- return { kind: "not-regular" };
7503
- const limit = maxBytes + 1;
7504
- const chunks = [];
7505
- let total = 0;
7506
- while (total < limit) {
7507
- const chunk = Buffer.allocUnsafe(Math.min(READ_CHUNK_BYTES, limit - total));
7508
- const count = fs.readSync(fd, chunk, 0, chunk.length, null);
7509
- if (count === 0)
7510
- break;
7511
- chunks.push(chunk.subarray(0, count));
7512
- total += count;
7513
- }
7514
- if (total >= limit)
7515
- return { kind: "too-large", bytesRead: total };
7516
- return { kind: "bytes", bytes: Buffer.concat(chunks) };
7517
- } catch {
7518
- return { kind: "failed" };
7519
- } finally {
7520
- try {
7521
- fs.closeSync(fd);
7522
- } catch {}
7523
- }
7524
- }
7684
+ import fs3 from "fs";
7685
+ import os2 from "os";
7686
+ import path2 from "path";
7525
7687
 
7526
7688
  // src/lib/search-exclude.ts
7527
7689
  var MAX_EXCLUDE_PATTERNS = 64;
@@ -7822,10 +7984,10 @@ function isTildePath(value) {
7822
7984
  return value === "~" || value.startsWith("~/") || value.startsWith("~\\");
7823
7985
  }
7824
7986
  function isUserPathForm(value) {
7825
- return typeof value === "string" && value.length > 0 && !hasControlChar(value) && (isTildePath(value) || path.isAbsolute(value));
7987
+ return typeof value === "string" && value.length > 0 && !hasControlChar(value) && (isTildePath(value) || path2.isAbsolute(value));
7826
7988
  }
7827
7989
  function isAbsoluteAnywhere(value) {
7828
- return path.isAbsolute(value) || path.posix.isAbsolute(value) || path.win32.isAbsolute(value);
7990
+ return path2.isAbsolute(value) || path2.posix.isAbsolute(value) || path2.win32.isAbsolute(value);
7829
7991
  }
7830
7992
  function isProjectRoot(root, format) {
7831
7993
  if (root.length === 0 || hasControlChar(root))
@@ -8116,7 +8278,7 @@ function absorb(acc, settings, layer) {
8116
8278
  }
8117
8279
  function configEntryExists(target) {
8118
8280
  try {
8119
- fs2.lstatSync(target);
8281
+ fs3.lstatSync(target);
8120
8282
  return true;
8121
8283
  } catch (error) {
8122
8284
  const code = errorCode2(error);
@@ -8124,21 +8286,21 @@ function configEntryExists(target) {
8124
8286
  }
8125
8287
  }
8126
8288
  function selectConfigFile(dir, basename) {
8127
- const jsoncPath = path.join(dir, `${basename}.jsonc`);
8289
+ const jsoncPath = path2.join(dir, `${basename}.jsonc`);
8128
8290
  if (configEntryExists(jsoncPath))
8129
8291
  return jsoncPath;
8130
- return path.join(dir, `${basename}.json`);
8292
+ return path2.join(dir, `${basename}.json`);
8131
8293
  }
8132
8294
  function resolveUserLevelConfigDirs(options) {
8133
- const homeDir = options?.homeDir ?? os.homedir();
8134
- const userConfigDir = options?.userConfigDir ?? path.join(homeDir, ".config/opencode");
8295
+ const homeDir = options?.homeDir ?? os2.homedir();
8296
+ const userConfigDir = options?.userConfigDir ?? path2.join(homeDir, ".config/opencode");
8135
8297
  const rawCustom = options !== undefined && Object.hasOwn(options, "customConfigDir") ? options.customConfigDir?.trim() : process.env.OPENCODE_CONFIG_DIR?.trim();
8136
8298
  return { homeDir, userConfigDir, customConfigDir: rawCustom || undefined };
8137
8299
  }
8138
8300
  function realpathOrResolved(dir) {
8139
- const resolved = path.resolve(dir);
8301
+ const resolved = path2.resolve(dir);
8140
8302
  try {
8141
- return fs2.realpathSync(resolved);
8303
+ return fs3.realpathSync(resolved);
8142
8304
  } catch {
8143
8305
  return resolved;
8144
8306
  }
@@ -8161,11 +8323,11 @@ function selectUserLevelConfigFiles(dirs) {
8161
8323
  layer: "custom.local",
8162
8324
  path: selectConfigFile(custom, "systematic.local")
8163
8325
  });
8164
- const aliased = path.resolve(custom) === path.resolve(dirs.userConfigDir) || realpathOrResolved(custom) === realpathOrResolved(dirs.userConfigDir);
8326
+ const aliased = path2.resolve(custom) === path2.resolve(dirs.userConfigDir) || realpathOrResolved(custom) === realpathOrResolved(dirs.userConfigDir);
8165
8327
  return { files, aliased };
8166
8328
  }
8167
8329
  function selectProjectConfigFile(repoRoot) {
8168
- const opencodeFile = selectConfigFile(path.join(repoRoot, ".opencode"), "systematic");
8330
+ const opencodeFile = selectConfigFile(path2.join(repoRoot, ".opencode"), "systematic");
8169
8331
  const rootFile = selectConfigFile(repoRoot, ".systematic");
8170
8332
  if (!configEntryExists(rootFile))
8171
8333
  return { path: opencodeFile };
@@ -8176,7 +8338,7 @@ function findStartDirProjectConfig(startDir, repoRoot, selectedProjectConfig) {
8176
8338
  return;
8177
8339
  if (realpathOrResolved(startDir) === repoRoot.root)
8178
8340
  return;
8179
- const candidate = selectConfigFile(path.join(startDir, ".opencode"), "systematic");
8341
+ const candidate = selectConfigFile(path2.join(startDir, ".opencode"), "systematic");
8180
8342
  if (!configEntryExists(candidate))
8181
8343
  return;
8182
8344
  return realpathOrResolved(candidate) === realpathOrResolved(selectedProjectConfig) ? undefined : candidate;
@@ -8586,6 +8748,18 @@ var BootstrapSchema = object({
8586
8748
  description: "Bootstrap prompt configuration",
8587
8749
  examples: [{ enabled: true }, { enabled: false }]
8588
8750
  });
8751
+ var ConnectSettingsSchema = trustProtected(object({
8752
+ allow_projects: array(string().min(1).max(MAX_ALLOW_PROJECT_LENGTH)).max(MAX_ALLOW_PROJECTS).optional().meta({
8753
+ description: `Main repository roots that \`ce:connect\` may read for contradictions and transferable lessons. Each entry is an absolute or \`~\`-prefixed path to the root of a repository checkout, not a subdirectory and not a linked worktree. At most ${MAX_ALLOW_PROJECTS} entries; an entry that matches no repository is reported by the run and does not widen the list. The lists in user, user.local, custom and custom.local config are merged as a union. Omitted or empty, it allows no project.`,
8754
+ examples: [["~/src/github.com/me/app", "/srv/checkouts/shared-lib"]]
8755
+ })
8756
+ }).strict().meta({
8757
+ 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.",
8758
+ examples: [
8759
+ { allow_projects: ["~/src/github.com/me/app"] },
8760
+ { allow_projects: [] }
8761
+ ]
8762
+ }));
8589
8763
  function createSystematicConfigSchema(opts) {
8590
8764
  const {
8591
8765
  agentNames,
@@ -8635,6 +8809,7 @@ function createSystematicConfigSchema(opts) {
8635
8809
  examples: [true, false]
8636
8810
  })).default(false),
8637
8811
  search: SearchSettingsSchema.optional(),
8812
+ connect: ConnectSettingsSchema.optional(),
8638
8813
  disabled_skills: array(_enum([...skillNames, ...removedSkillNames])).default([]).meta({
8639
8814
  description: "Array of bundled skill names to disable globally. Unknown skill names are rejected at parse time.",
8640
8815
  examples: [["ce:plan", "ce:review"]]
@@ -8725,7 +8900,7 @@ function extractBashPermission(data) {
8725
8900
  }
8726
8901
  return null;
8727
8902
  }
8728
- function buildPermissionObject(edit, bash, webfetch, doom_loop, external_directory, task, skill) {
8903
+ function buildPermissionObject(edit, bash, webfetch, websearch, doom_loop, external_directory, task, skill) {
8729
8904
  const permission = {};
8730
8905
  if (edit)
8731
8906
  permission.edit = edit;
@@ -8733,6 +8908,8 @@ function buildPermissionObject(edit, bash, webfetch, doom_loop, external_directo
8733
8908
  permission.bash = bash;
8734
8909
  if (webfetch)
8735
8910
  permission.webfetch = webfetch;
8911
+ if (websearch)
8912
+ permission.websearch = websearch;
8736
8913
  if (doom_loop)
8737
8914
  permission.doom_loop = doom_loop;
8738
8915
  if (external_directory)
@@ -8755,6 +8932,9 @@ function normalizePermission(value) {
8755
8932
  const webfetch = extractSimplePermission(value, "webfetch");
8756
8933
  if (webfetch === null)
8757
8934
  return;
8935
+ const websearch = extractSimplePermission(value, "websearch");
8936
+ if (websearch === null)
8937
+ return;
8758
8938
  const doom_loop = extractSimplePermission(value, "doom_loop");
8759
8939
  if (doom_loop === null)
8760
8940
  return;
@@ -8767,7 +8947,7 @@ function normalizePermission(value) {
8767
8947
  const skill = extractSimplePermission(value, "skill");
8768
8948
  if (skill === null)
8769
8949
  return;
8770
- return buildPermissionObject(edit, bash, webfetch, doom_loop, external_directory, task, skill);
8950
+ return buildPermissionObject(edit, bash, webfetch, websearch, doom_loop, external_directory, task, skill);
8771
8951
  }
8772
8952
  function extractString(data, key, fallback = "") {
8773
8953
  const value = data[key];
@@ -9031,8 +9211,8 @@ function collectWrittenLegacyPiSubagentsThinkingWarnings(piSubagentsOverlays) {
9031
9211
  }
9032
9212
 
9033
9213
  // src/lib/search-corpus.ts
9034
- import fs3 from "fs";
9035
- import path2 from "path";
9214
+ import fs4 from "fs";
9215
+ import path3 from "path";
9036
9216
  var MAX_FILE_BYTES = 256 * 1024;
9037
9217
  var MAX_FILES = 2000;
9038
9218
  var MAX_DEPTH = 6;
@@ -9083,14 +9263,14 @@ function compareCodeUnits(a, b) {
9083
9263
  }
9084
9264
  function safeLstat(target) {
9085
9265
  try {
9086
- return fs3.lstatSync(target, { throwIfNoEntry: false }) ?? null;
9266
+ return fs4.lstatSync(target, { throwIfNoEntry: false }) ?? null;
9087
9267
  } catch {
9088
9268
  return null;
9089
9269
  }
9090
9270
  }
9091
9271
  function safeRealpath(target) {
9092
9272
  try {
9093
- return fs3.realpathSync(target);
9273
+ return fs4.realpathSync(target);
9094
9274
  } catch {
9095
9275
  return null;
9096
9276
  }
@@ -9101,14 +9281,14 @@ function isAbsence(error) {
9101
9281
  }
9102
9282
  function probeRealpath(target) {
9103
9283
  try {
9104
- return { kind: "ok", value: fs3.realpathSync(target) };
9284
+ return { kind: "ok", value: fs4.realpathSync(target) };
9105
9285
  } catch (error) {
9106
9286
  return { kind: isAbsence(error) ? "absent" : "failed" };
9107
9287
  }
9108
9288
  }
9109
9289
  function probeLstat(target) {
9110
9290
  try {
9111
- const stat = fs3.lstatSync(target, { throwIfNoEntry: false });
9291
+ const stat = fs4.lstatSync(target, { throwIfNoEntry: false });
9112
9292
  return stat === undefined ? { kind: "absent" } : { kind: "ok", value: stat };
9113
9293
  } catch (error) {
9114
9294
  return { kind: isAbsence(error) ? "absent" : "failed" };
@@ -9116,7 +9296,7 @@ function probeLstat(target) {
9116
9296
  }
9117
9297
  function safeReaddir(target) {
9118
9298
  try {
9119
- return fs3.readdirSync(target);
9299
+ return fs4.readdirSync(target);
9120
9300
  } catch {
9121
9301
  return null;
9122
9302
  }
@@ -9142,7 +9322,7 @@ function listDirectoryWithin(target, budget) {
9142
9322
  function listDirectoryBounded(target, limit) {
9143
9323
  let directory;
9144
9324
  try {
9145
- directory = fs3.opendirSync(target);
9325
+ directory = fs4.opendirSync(target);
9146
9326
  } catch {
9147
9327
  return null;
9148
9328
  }
@@ -9165,18 +9345,18 @@ function listDirectoryBounded(target, limit) {
9165
9345
  }
9166
9346
  }
9167
9347
  function walkToGitRoot(startDir) {
9168
- const resolved = path2.resolve(startDir);
9348
+ const resolved = path3.resolve(startDir);
9169
9349
  const start = safeRealpath(resolved) ?? resolved;
9170
9350
  let current = start;
9171
9351
  while (true) {
9172
9352
  try {
9173
- if (fs3.lstatSync(path2.join(current, ".git"), { throwIfNoEntry: false })) {
9353
+ if (fs4.lstatSync(path3.join(current, ".git"), { throwIfNoEntry: false })) {
9174
9354
  return { gitRoot: current, start };
9175
9355
  }
9176
9356
  } catch {
9177
9357
  return { gitRoot: null, start };
9178
9358
  }
9179
- const parent = path2.dirname(current);
9359
+ const parent = path3.dirname(current);
9180
9360
  if (parent === current)
9181
9361
  return { gitRoot: null, start };
9182
9362
  current = parent;
@@ -9191,16 +9371,16 @@ function lookupSearchRoot(startDir) {
9191
9371
  return gitRoot === null ? { root: startDir, foundGit: false } : { root: gitRoot, foundGit: true };
9192
9372
  }
9193
9373
  function isInside(root, candidate) {
9194
- const relative = path2.relative(root, candidate);
9195
- return relative !== "" && relative !== ".." && !relative.startsWith(`..${path2.sep}`) && !path2.isAbsolute(relative);
9374
+ const relative = path3.relative(root, candidate);
9375
+ return relative !== "" && relative !== ".." && !relative.startsWith(`..${path3.sep}`) && !path3.isAbsolute(relative);
9196
9376
  }
9197
9377
  function symlinkedComponent(container, target) {
9198
9378
  if (!isInside(container, target))
9199
9379
  return;
9200
- const segments = path2.relative(container, target).split(path2.sep);
9380
+ const segments = path3.relative(container, target).split(path3.sep);
9201
9381
  let current = container;
9202
9382
  for (const [index, segment] of segments.entries()) {
9203
- current = path2.join(current, segment);
9383
+ current = path3.join(current, segment);
9204
9384
  const stat = safeLstat(current);
9205
9385
  if (stat === null)
9206
9386
  return;
@@ -9276,7 +9456,7 @@ function discoverFiles(spec, label, directory, prefix, depth, found, warnings) {
9276
9456
  return;
9277
9457
  if (found.isExcluded?.(`${prefix}${name}`) === true)
9278
9458
  continue;
9279
- const absolute = path2.join(directory, name);
9459
+ const absolute = path3.join(directory, name);
9280
9460
  const stat = safeLstat(absolute);
9281
9461
  const entryKind = classifyEntry(spec, name, stat);
9282
9462
  if (entryKind === "directory" && depth + 1 <= MAX_DEPTH) {
@@ -9497,7 +9677,7 @@ function loadSourceFiles(discover, read) {
9497
9677
  function loadCorpus(root, kind = "solution") {
9498
9678
  const spec = KIND_TABLE[kind];
9499
9679
  const loaded = loadSourceFiles({
9500
- directory: path2.join(root, ...spec.dir.split("/")),
9680
+ directory: path3.join(root, ...spec.dir.split("/")),
9501
9681
  containedIn: root,
9502
9682
  walk: spec,
9503
9683
  label: spec.dir
@@ -9520,159 +9700,6 @@ function loadCorpus(root, kind = "solution") {
9520
9700
  };
9521
9701
  }
9522
9702
 
9523
- // src/lib/search-project-identity.ts
9524
- import fs4 from "fs";
9525
- import os2 from "os";
9526
- import path3 from "path";
9527
- var MAX_IDENTITY_FILE_BYTES = 1024 * 1024;
9528
- function realpath(target) {
9529
- return fs4.realpathSync.native(target);
9530
- }
9531
- function readSmallFile(file) {
9532
- const read = readBytesBounded(file, MAX_IDENTITY_FILE_BYTES);
9533
- if (read.kind !== "bytes") {
9534
- throw new Error(`${path3.basename(file)} cannot be read as an identity file`);
9535
- }
9536
- return read.bytes.toString("utf8");
9537
- }
9538
- function firstLine(text) {
9539
- return (text.split(`
9540
- `, 1)[0] ?? "").replace(/\r$/, "").trim();
9541
- }
9542
- function resolveFrom(base, value) {
9543
- return path3.isAbsolute(value) ? value : path3.resolve(base, value);
9544
- }
9545
- function setsCoreWorktree(config) {
9546
- let inCore = false;
9547
- for (const raw of config.split(`
9548
- `)) {
9549
- let line = raw.trim();
9550
- if (line.startsWith("[")) {
9551
- const end = line.indexOf("]");
9552
- if (end === -1) {
9553
- inCore = false;
9554
- continue;
9555
- }
9556
- inCore = line.slice(1, end).trim().toLowerCase() === "core";
9557
- line = line.slice(end + 1).trim();
9558
- }
9559
- if (inCore && /^worktree\s*(=|$)/i.test(line)) {
9560
- return true;
9561
- }
9562
- }
9563
- return false;
9564
- }
9565
- function isSubmoduleGitdir(gitdir) {
9566
- return gitdir.split(path3.sep).includes("modules");
9567
- }
9568
- function resolveLinkedWorktree(gitFile, gitdir) {
9569
- const commonFile = path3.join(gitdir, "commondir");
9570
- if (!fs4.existsSync(commonFile)) {
9571
- return { reason: "missing-commondir" };
9572
- }
9573
- const commonRaw = firstLine(readSmallFile(commonFile));
9574
- if (commonRaw === "") {
9575
- return { reason: "corrupt-git-file" };
9576
- }
9577
- const common = realpath(resolveFrom(gitdir, commonRaw));
9578
- if (gitdir !== path3.join(common, "worktrees", path3.basename(gitdir))) {
9579
- return { reason: "inconsistent" };
9580
- }
9581
- const backRaw = firstLine(readSmallFile(path3.join(gitdir, "gitdir")));
9582
- if (backRaw === "") {
9583
- return { reason: "corrupt-git-file" };
9584
- }
9585
- if (realpath(resolveFrom(gitdir, backRaw)) !== realpath(gitFile)) {
9586
- return { reason: "inconsistent" };
9587
- }
9588
- if (path3.basename(common) !== ".git") {
9589
- return { reason: "unsupported-layout" };
9590
- }
9591
- if (setsCoreWorktree(readSmallFile(path3.join(common, "config")))) {
9592
- return { reason: "core-worktree" };
9593
- }
9594
- return { root: path3.dirname(common) };
9595
- }
9596
- function deriveMainRoot(checkoutRoot) {
9597
- const root = realpath(checkoutRoot);
9598
- const gitPath = path3.join(root, ".git");
9599
- let stat;
9600
- try {
9601
- stat = fs4.lstatSync(gitPath);
9602
- } catch {
9603
- return { reason: "not-a-checkout" };
9604
- }
9605
- if (stat.isSymbolicLink()) {
9606
- return { reason: "symlinked-git" };
9607
- }
9608
- if (stat.isDirectory()) {
9609
- return { root };
9610
- }
9611
- if (!stat.isFile()) {
9612
- return { reason: "corrupt-git-file" };
9613
- }
9614
- const match = /^gitdir:[ \t]*(.+)$/.exec(firstLine(readSmallFile(gitPath)));
9615
- const claimed = match?.[1]?.trim();
9616
- if (claimed === undefined || claimed === "") {
9617
- return { reason: "corrupt-git-file" };
9618
- }
9619
- const gitdir = realpath(resolveFrom(root, claimed));
9620
- if (!fs4.statSync(gitdir).isDirectory()) {
9621
- return { reason: "corrupt-git-file" };
9622
- }
9623
- if (path3.basename(path3.dirname(gitdir)) === "worktrees") {
9624
- return resolveLinkedWorktree(gitPath, gitdir);
9625
- }
9626
- if (isSubmoduleGitdir(gitdir)) {
9627
- return { root };
9628
- }
9629
- return { reason: "unsupported-layout" };
9630
- }
9631
- function resolveProjectIdentity(checkoutRoot) {
9632
- try {
9633
- const derived = deriveMainRoot(checkoutRoot);
9634
- return "root" in derived ? { status: "resolved", mainRoot: derived.root } : { status: "unresolved", reason: derived.reason };
9635
- } catch {
9636
- return { status: "unresolved", reason: "unreadable" };
9637
- }
9638
- }
9639
- function expandHome(entry, homeDir) {
9640
- if (entry === "~") {
9641
- return homeDir;
9642
- }
9643
- if (entry.startsWith("~/") || entry.startsWith(`~${path3.sep}`)) {
9644
- return path3.join(homeDir, entry.slice(2));
9645
- }
9646
- return entry;
9647
- }
9648
- function isAllowedProject(identity, allowList, options = {}) {
9649
- if (identity.status !== "resolved") {
9650
- return false;
9651
- }
9652
- let mainRoot;
9653
- try {
9654
- mainRoot = realpath(identity.mainRoot);
9655
- } catch {
9656
- return false;
9657
- }
9658
- const homeDir = options.homeDir ?? os2.homedir();
9659
- for (const entry of allowList) {
9660
- if (typeof entry !== "string" || entry === "") {
9661
- continue;
9662
- }
9663
- const expanded = expandHome(entry, homeDir);
9664
- if (expanded === undefined || !path3.isAbsolute(expanded)) {
9665
- continue;
9666
- }
9667
- try {
9668
- if (realpath(expanded) === mainRoot) {
9669
- return true;
9670
- }
9671
- } catch {}
9672
- }
9673
- return false;
9674
- }
9675
-
9676
9703
  // src/lib/config.ts
9677
9704
  var CONFIG_AUTHORITY_FIELD_PATHS = [
9678
9705
  "bootstrap.enabled",
@@ -9717,7 +9744,10 @@ var PROTECTED_OVERLAY_FIELD_PATHS = {
9717
9744
  pi: "categories.*.pi"
9718
9745
  }
9719
9746
  };
9720
- var PROJECT_ALWAYS_PROTECTED_FIELDS = new Set(["allow_project_profiles"]);
9747
+ var PROJECT_ALWAYS_PROTECTED_FIELDS = new Set([
9748
+ "allow_project_profiles",
9749
+ "connect"
9750
+ ]);
9721
9751
  var PROJECT_PROTECTED_SEARCH_FIELDS = [
9722
9752
  ["enabled", "search.enabled"],
9723
9753
  ["allow_project_sources", "search.allow_project_sources"]
@@ -10102,6 +10132,13 @@ function collectProjectProtectedFields(rawConfig, trust, allowProjectProfiles) {
10102
10132
  sourceKind: "project"
10103
10133
  }
10104
10134
  ] : [],
10135
+ ...Object.hasOwn(rawConfig, "connect") ? [
10136
+ {
10137
+ fieldPath: "connect",
10138
+ outcome: "blocked",
10139
+ sourceKind: "project"
10140
+ }
10141
+ ] : [],
10105
10142
  ...collectSearchProtectedFields(rawConfig.search),
10106
10143
  ...collectOverlayProtectedFields(rawConfig.agents, "agents"),
10107
10144
  ...collectOverlayProtectedFields(rawConfig.categories, "categories")
@@ -10474,6 +10511,16 @@ function buildProfileEntry(profileSelection) {
10474
10511
  function unionDisabledList(sources, key) {
10475
10512
  return sources.reduce((merged, source) => mergeArraysUnique(merged, source.config[key]), mergeArraysUnique(DEFAULT_CONFIG[key], undefined));
10476
10513
  }
10514
+ function mergeConnect(sources) {
10515
+ const blocks = sources.flatMap((source) => source.config.connect === undefined ? [] : [source.config.connect]);
10516
+ if (blocks.length === 0)
10517
+ return {};
10518
+ return {
10519
+ connect: {
10520
+ allow_projects: blocks.reduce((merged, block) => mergeArraysUnique(merged, block.allow_projects), [])
10521
+ }
10522
+ };
10523
+ }
10477
10524
  function mergeBootstrap(sources) {
10478
10525
  const merged = { ...DEFAULT_CONFIG.bootstrap };
10479
10526
  for (const source of sources)
@@ -10565,6 +10612,7 @@ function loadConfigLayers(projectDir, options, attempt) {
10565
10612
  attempt.projectContributed = projectSource !== null;
10566
10613
  emitTopLevelProtectedFieldWarning(projectSource, "profiles", `\`profiles\` in project config (%PATH%) is only valid in user config or OPENCODE_CONFIG_DIR config and has been ignored. Its bundles are not selectable even if this project also sets \`profile\`.`, boundedProjectStrip.sink);
10567
10614
  emitTopLevelProtectedFieldWarning(projectSource, "allow_project_profiles", `\`allow_project_profiles\` in project config (%PATH%) is only valid in user config or OPENCODE_CONFIG_DIR config and has been ignored.`, boundedProjectStrip.sink);
10615
+ emitTopLevelProtectedFieldWarning(projectSource, "connect", `\`connect\` in project config (%PATH%) is only valid in user config or OPENCODE_CONFIG_DIR config and has been ignored.`, boundedProjectStrip.sink);
10568
10616
  emitProjectSearchProtectedWarnings(projectSource, boundedProjectStrip.sink);
10569
10617
  const suppressedStripCount = boundedProjectStrip.suppressedCount();
10570
10618
  if (suppressedStripCount > 0) {
@@ -10634,7 +10682,8 @@ function loadConfigLayers(projectDir, options, attempt) {
10634
10682
  skills_as_commands: lastDefined(sources, "skills_as_commands") ?? DEFAULT_CONFIG.skills_as_commands,
10635
10683
  allow_project_profiles: allowProjectProfiles,
10636
10684
  ...mergedSearch.settings && { search: mergedSearch.settings },
10637
- ...mergedSearch.unreadable && { searchUnreadable: true }
10685
+ ...mergedSearch.unreadable && { searchUnreadable: true },
10686
+ ...mergeConnect(sources)
10638
10687
  };
10639
10688
  const droppedSkills = computeDroppedNames(result.disabled_skills, CURRENT_SKILL_NAMES_SET);
10640
10689
  warnDroppedNames(droppedSkills, "disabled_skills", warned, undefined, warningSink);