@kyo-so/cli 0.5.0 → 0.7.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.
package/dist/bin/kyoso.js CHANGED
@@ -8125,7 +8125,7 @@ ${lanes.join(`
8125
8125
  writeOutputIsTTY() {
8126
8126
  return process.stdout.isTTY;
8127
8127
  },
8128
- readFile: readFile2,
8128
+ readFile: readFile3,
8129
8129
  writeFile: writeFile22,
8130
8130
  watchFile: watchFile2,
8131
8131
  watchDirectory,
@@ -8318,7 +8318,7 @@ ${lanes.join(`
8318
8318
  function fsWatchWorker(fileOrDirectory, recursive, callback) {
8319
8319
  return _fs.watch(fileOrDirectory, fsSupportsRecursiveFsWatch ? { persistent: true, recursive: !!recursive } : { persistent: true }, callback);
8320
8320
  }
8321
- function readFile2(fileName, _encoding) {
8321
+ function readFile3(fileName, _encoding) {
8322
8322
  let buffer;
8323
8323
  try {
8324
8324
  buffer = _fs.readFileSync(fileName);
@@ -39385,7 +39385,7 @@ ${lanes.join(`
39385
39385
  const possibleOption = getSpellingSuggestion(unknownOption, diagnostics.optionDeclarations, getOptionName);
39386
39386
  return possibleOption ? createDiagnosticForNodeInSourceFileOrCompilerDiagnostic(sourceFile, node, diagnostics.unknownDidYouMeanDiagnostic, unknownOptionErrorText || unknownOption, possibleOption.name) : createDiagnosticForNodeInSourceFileOrCompilerDiagnostic(sourceFile, node, diagnostics.unknownOptionDiagnostic, unknownOptionErrorText || unknownOption);
39387
39387
  }
39388
- function parseCommandLineWorker(diagnostics, commandLine, readFile2) {
39388
+ function parseCommandLineWorker(diagnostics, commandLine, readFile3) {
39389
39389
  const options = {};
39390
39390
  let watchOptions;
39391
39391
  const fileNames = [];
@@ -39423,7 +39423,7 @@ ${lanes.join(`
39423
39423
  }
39424
39424
  }
39425
39425
  function parseResponseFile(fileName) {
39426
- const text = tryReadFile(fileName, readFile2 || ((fileName2) => sys.readFile(fileName2)));
39426
+ const text = tryReadFile(fileName, readFile3 || ((fileName2) => sys.readFile(fileName2)));
39427
39427
  if (!isString(text)) {
39428
39428
  errors3.push(text);
39429
39429
  return;
@@ -39526,8 +39526,8 @@ ${lanes.join(`
39526
39526
  unknownDidYouMeanDiagnostic: Diagnostics.Unknown_compiler_option_0_Did_you_mean_1,
39527
39527
  optionTypeMismatchDiagnostic: Diagnostics.Compiler_option_0_expects_an_argument
39528
39528
  };
39529
- function parseCommandLine(commandLine, readFile2) {
39530
- return parseCommandLineWorker(compilerOptionsDidYouMeanDiagnostics, commandLine, readFile2);
39529
+ function parseCommandLine(commandLine, readFile3) {
39530
+ return parseCommandLineWorker(compilerOptionsDidYouMeanDiagnostics, commandLine, readFile3);
39531
39531
  }
39532
39532
  function getOptionFromName(optionName, allowShort) {
39533
39533
  return getOptionDeclarationFromName(getOptionsNameMap, optionName, allowShort);
@@ -39595,8 +39595,8 @@ ${lanes.join(`
39595
39595
  result.originalFileName = result.fileName;
39596
39596
  return parseJsonSourceFileConfigFileContent(result, host, getNormalizedAbsolutePath(getDirectoryPath(configFileName), cwd), optionsToExtend, getNormalizedAbsolutePath(configFileName, cwd), undefined, extraFileExtensions, extendedConfigCache, watchOptionsToExtend);
39597
39597
  }
39598
- function readConfigFile(fileName, readFile2) {
39599
- const textOrDiagnostic = tryReadFile(fileName, readFile2);
39598
+ function readConfigFile(fileName, readFile3) {
39599
+ const textOrDiagnostic = tryReadFile(fileName, readFile3);
39600
39600
  return isString(textOrDiagnostic) ? parseConfigFileTextToJson(fileName, textOrDiagnostic) : { config: {}, error: textOrDiagnostic };
39601
39601
  }
39602
39602
  function parseConfigFileTextToJson(fileName, jsonText) {
@@ -39606,14 +39606,14 @@ ${lanes.join(`
39606
39606
  error: jsonSourceFile.parseDiagnostics.length ? jsonSourceFile.parseDiagnostics[0] : undefined
39607
39607
  };
39608
39608
  }
39609
- function readJsonConfigFile(fileName, readFile2) {
39610
- const textOrDiagnostic = tryReadFile(fileName, readFile2);
39609
+ function readJsonConfigFile(fileName, readFile3) {
39610
+ const textOrDiagnostic = tryReadFile(fileName, readFile3);
39611
39611
  return isString(textOrDiagnostic) ? parseJsonText(fileName, textOrDiagnostic) : { fileName, parseDiagnostics: [textOrDiagnostic] };
39612
39612
  }
39613
- function tryReadFile(fileName, readFile2) {
39613
+ function tryReadFile(fileName, readFile3) {
39614
39614
  let text;
39615
39615
  try {
39616
- text = readFile2(fileName);
39616
+ text = readFile3(fileName);
39617
39617
  } catch (e) {
39618
39618
  return createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message);
39619
39619
  }
@@ -107510,12 +107510,12 @@ ${lanes.join(`
107510
107510
  function createCompilerHost(options, setParentNodes) {
107511
107511
  return createCompilerHostWorker(options, setParentNodes);
107512
107512
  }
107513
- function createGetSourceFile(readFile2, setParentNodes) {
107513
+ function createGetSourceFile(readFile3, setParentNodes) {
107514
107514
  return (fileName, languageVersionOrOptions, onError) => {
107515
107515
  let text;
107516
107516
  try {
107517
107517
  mark("beforeIORead");
107518
- text = readFile2(fileName);
107518
+ text = readFile3(fileName);
107519
107519
  mark("afterIORead");
107520
107520
  measure("I/O Read", "beforeIORead", "afterIORead");
107521
107521
  } catch (e) {
@@ -108306,7 +108306,7 @@ ${lanes.join(`
108306
108306
  getRedirectFromOutput,
108307
108307
  forEachResolvedProjectReference: forEachResolvedProjectReference2
108308
108308
  });
108309
- const readFile2 = host.readFile.bind(host);
108309
+ const readFile3 = host.readFile.bind(host);
108310
108310
  (_e = tracing) == null || _e.push(tracing.Phase.Program, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram });
108311
108311
  const shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options);
108312
108312
  (_f = tracing) == null || _f.pop();
@@ -108483,7 +108483,7 @@ ${lanes.join(`
108483
108483
  shouldTransformImportCall,
108484
108484
  emitBuildInfo,
108485
108485
  fileExists,
108486
- readFile: readFile2,
108486
+ readFile: readFile3,
108487
108487
  directoryExists,
108488
108488
  getSymlinkCache,
108489
108489
  realpath: (_o = host.realpath) == null ? undefined : _o.bind(host),
@@ -121385,7 +121385,7 @@ ${lanes.join(`
121385
121385
  if (importingFile !== usableByFileName)
121386
121386
  return;
121387
121387
  return forEachEntry(exportInfo, (info, key2) => {
121388
- const { symbolName: symbolName2, ambientModuleName } = parseKey(key2);
121388
+ const { symbolName: symbolName2, ambientModuleName } = parseKey2(key2);
121389
121389
  const name = preferCapitalized && info[0].capitalizedSymbolName || symbolName2;
121390
121390
  if (matches(name, info[0].targetFlags)) {
121391
121391
  const rehydrated = info.map(rehydrateCachedInfo);
@@ -121449,7 +121449,7 @@ ${lanes.join(`
121449
121449
  const moduleKey = ambientModuleName || "";
121450
121450
  return `${importedName.length} ${getSymbolId(skipAlias(symbol2, checker))} ${importedName} ${moduleKey}`;
121451
121451
  }
121452
- function parseKey(key2) {
121452
+ function parseKey2(key2) {
121453
121453
  const firstSpace = key2.indexOf(" ");
121454
121454
  const secondSpace = key2.indexOf(" ", firstSpace + 1);
121455
121455
  const symbolNameLength = parseInt(key2.substring(0, firstSpace), 10);
@@ -150513,14 +150513,14 @@ ${newComment.split(`
150513
150513
  });
150514
150514
  function mapCode(sourceFile, contents, focusLocations, host, formatContext, preferences) {
150515
150515
  return ts_textChanges_exports.ChangeTracker.with({ host, formatContext, preferences }, (changeTracker) => {
150516
- const parsed = contents.map((c) => parse5(sourceFile, c));
150516
+ const parsed = contents.map((c) => parse6(sourceFile, c));
150517
150517
  const flattenedLocations = focusLocations && flatten(focusLocations);
150518
150518
  for (const nodes of parsed) {
150519
150519
  placeNodeGroup(sourceFile, changeTracker, nodes, flattenedLocations);
150520
150520
  }
150521
150521
  });
150522
150522
  }
150523
- function parse5(sourceFile, content) {
150523
+ function parse6(sourceFile, content) {
150524
150524
  const nodeKinds = [
150525
150525
  {
150526
150526
  parse: () => createSourceFile("__mapcode_content_nodes.ts", content, sourceFile.languageVersion, true, sourceFile.scriptKind),
@@ -169600,12 +169600,13 @@ function languageFromPath(path) {
169600
169600
 
169601
169601
  // src/cli/doctor.ts
169602
169602
  import { accessSync } from "node:fs";
169603
- import { delimiter as delimiter2 } from "node:path";
169603
+ import { delimiter as delimiter2, resolve as resolve4 } from "node:path";
169604
169604
 
169605
169605
  // src/config/loadConfig.ts
169606
- import { access as access2, readFile as readFile3 } from "node:fs/promises";
169606
+ import { access as access2, readFile as readFile4 } from "node:fs/promises";
169607
+ import { homedir as homedir2 } from "node:os";
169607
169608
  import { stderr, stdin } from "node:process";
169608
- import { resolve as resolve2 } from "node:path";
169609
+ import { extname as extname3, join as join2, resolve as resolve2 } from "node:path";
169609
169610
  import { createInterface as createInterface2 } from "node:readline/promises";
169610
169611
 
169611
169612
  // src/config/defaultConfig.ts
@@ -169648,7 +169649,7 @@ var defaultConfig = {
169648
169649
  command: "npx",
169649
169650
  args: ["-y", "@agentclientprotocol/claude-agent-acp@0.57.0"],
169650
169651
  role: "architecture_security_reviewer",
169651
- timeoutMs: 240000,
169652
+ timeoutMs: 300000,
169652
169653
  env: {
169653
169654
  KYOSO_CHILD_AGENT: "1"
169654
169655
  },
@@ -169736,6 +169737,172 @@ var defaultConfig = {
169736
169737
  }
169737
169738
  };
169738
169739
 
169740
+ // src/config/projectScope.ts
169741
+ var PROJECT_GLOBAL_ONLY_MESSAGE = "Move global-only settings to the user global config:";
169742
+ function mergeProjectTomlConfig(baseConfig, projectConfig, options) {
169743
+ const violations = collectProjectScopeViolations(projectConfig);
169744
+ if (violations.length > 0) {
169745
+ throw new Error(formatProjectScopeError(violations, options));
169746
+ }
169747
+ const projectDeny = readPath(projectConfig, ["workspace", "deny"]);
169748
+ const mergeableProjectConfig = omitPath(projectConfig, ["workspace", "deny"]);
169749
+ const merged = deepMerge(baseConfig, mergeableProjectConfig);
169750
+ if (projectDeny !== undefined) {
169751
+ writePath(merged, ["workspace", "deny"], Array.isArray(projectDeny) && allStrings(projectDeny) ? unionStrings(readStringArray(baseConfig, ["workspace", "deny"]), [
169752
+ ...projectDeny
169753
+ ]) : projectDeny);
169754
+ }
169755
+ return merged;
169756
+ }
169757
+ function collectProjectScopeViolations(config) {
169758
+ const leaves = flattenLeaves(config);
169759
+ const violations = [];
169760
+ for (const leaf of leaves) {
169761
+ const path = leaf.path.join(".");
169762
+ if (!isAllowedProjectPath(leaf.path)) {
169763
+ violations.push({ path });
169764
+ continue;
169765
+ }
169766
+ const reason = tightenOnlyReason(leaf.path, leaf.value);
169767
+ if (reason)
169768
+ violations.push({ path, reason });
169769
+ }
169770
+ return violations.sort((left, right) => left.path.localeCompare(right.path));
169771
+ }
169772
+ function isAllowedProjectPath(path) {
169773
+ const [top, second, third, fourth] = path;
169774
+ if (top === "tools" && path.length === 2 && ["planReview", "securityReview", "diffReview"].includes(second ?? "")) {
169775
+ return true;
169776
+ }
169777
+ if (top === "agents" && path.length === 3 && ["codex", "claude"].includes(second ?? "") && ["enabled", "model", "effort", "role", "timeoutMs"].includes(third ?? "")) {
169778
+ return true;
169779
+ }
169780
+ if (top === "verification" && path.length === 2 && ["enabled", "maxFindings", "timeoutMs"].includes(second ?? "")) {
169781
+ return true;
169782
+ }
169783
+ if (top === "workspace" && path.length === 2 && ["maxContextBytes", "maxDiffBytes", "deny"].includes(second ?? "")) {
169784
+ return true;
169785
+ }
169786
+ if (top === "network" && second === "defaultMode" && path.length === 2) {
169787
+ return true;
169788
+ }
169789
+ if (top === "secrets" && path.length === 2 && ["blockOnDetectedSecret", "allowOverride"].includes(second ?? "")) {
169790
+ return true;
169791
+ }
169792
+ if (top === "judge" && path.length === 2 && ["mode", "provider", "timeoutMs"].includes(second ?? "")) {
169793
+ return true;
169794
+ }
169795
+ if (top === "securityReview" && second === "cisaSecureByDesign" && path.length >= 3) {
169796
+ if (third === "dimensions") {
169797
+ return path.length === 4 && [
169798
+ "customerSecurityOutcomes",
169799
+ "secureByDefault",
169800
+ "transparencyAndAccountability",
169801
+ "governance"
169802
+ ].includes(fourth ?? "");
169803
+ }
169804
+ return path.length === 3 && ["enabled", "gate"].includes(third ?? "");
169805
+ }
169806
+ return false;
169807
+ }
169808
+ function tightenOnlyReason(path, value) {
169809
+ const dotted = path.join(".");
169810
+ if (dotted === "network.defaultMode" && value !== "model_only") {
169811
+ return 'must be "model_only" in project TOML';
169812
+ }
169813
+ if (dotted === "secrets.blockOnDetectedSecret" && value !== true) {
169814
+ return "must be true in project TOML";
169815
+ }
169816
+ if (dotted === "secrets.allowOverride" && value !== false) {
169817
+ return "must be false in project TOML";
169818
+ }
169819
+ if (path[0] === "securityReview" && path[1] === "cisaSecureByDesign" && value !== true) {
169820
+ return "must be true in project TOML";
169821
+ }
169822
+ return;
169823
+ }
169824
+ function formatProjectScopeError(violations, options) {
169825
+ const entries = violations.map((violation) => violation.reason ? `${violation.path} (${violation.reason})` : violation.path);
169826
+ return [
169827
+ `Project TOML config ${options.projectPath} contains settings that are not allowed in project scope: ${entries.join(", ")}`,
169828
+ `${PROJECT_GLOBAL_ONLY_MESSAGE} ${options.globalConfigPath}. If a key is misspelled, fix the name instead.`
169829
+ ].join(`
169830
+ `);
169831
+ }
169832
+ function flattenLeaves(value, path = []) {
169833
+ if (!isRecord(value))
169834
+ return path.length > 0 ? [{ path, value }] : [];
169835
+ const entries = Object.entries(value);
169836
+ if (entries.length === 0)
169837
+ return path.length > 0 ? [{ path, value }] : [];
169838
+ return entries.flatMap(([key, child]) => flattenLeaves(child, [...path, key]));
169839
+ }
169840
+ function omitPath(value, path) {
169841
+ if (!isRecord(value) || path.length === 0)
169842
+ return value;
169843
+ const [head, ...tail] = path;
169844
+ if (head === undefined)
169845
+ return value;
169846
+ const result = { ...value };
169847
+ if (tail.length === 0) {
169848
+ delete result[head];
169849
+ } else {
169850
+ const child = omitPath(result[head], tail);
169851
+ if (isRecord(child) && Object.keys(child).length === 0) {
169852
+ delete result[head];
169853
+ } else {
169854
+ result[head] = child;
169855
+ }
169856
+ }
169857
+ return result;
169858
+ }
169859
+ function readPath(value, path) {
169860
+ let current = value;
169861
+ for (const key of path) {
169862
+ if (!isRecord(current))
169863
+ return;
169864
+ current = current[key];
169865
+ }
169866
+ return current;
169867
+ }
169868
+ function writePath(target, path, value) {
169869
+ if (!isRecord(target))
169870
+ return;
169871
+ let current = target;
169872
+ for (const key of path.slice(0, -1)) {
169873
+ const child = current[key];
169874
+ if (!isRecord(child)) {
169875
+ current[key] = {};
169876
+ }
169877
+ current = current[key];
169878
+ }
169879
+ const leaf = path.at(-1);
169880
+ if (leaf)
169881
+ current[leaf] = value;
169882
+ }
169883
+ function readStringArray(value, path) {
169884
+ const found = readPath(value, path);
169885
+ return Array.isArray(found) && allStrings(found) ? [...found] : [];
169886
+ }
169887
+ function unionStrings(base, override) {
169888
+ return [...new Set([...base, ...override])];
169889
+ }
169890
+ function allStrings(values) {
169891
+ return values.every((value) => typeof value === "string");
169892
+ }
169893
+ function deepMerge(base, override) {
169894
+ if (!isRecord(base) || !isRecord(override))
169895
+ return override ?? base;
169896
+ const result = { ...base };
169897
+ for (const [key, value] of Object.entries(override)) {
169898
+ result[key] = deepMerge(result[key], value);
169899
+ }
169900
+ return result;
169901
+ }
169902
+ function isRecord(value) {
169903
+ return typeof value === "object" && value !== null && !Array.isArray(value);
169904
+ }
169905
+
169739
169906
  // node_modules/zod/v4/classic/external.js
169740
169907
  var exports_external = {};
169741
169908
  __export(exports_external, {
@@ -184019,6 +184186,7 @@ var agentSchema = exports_external.object({
184019
184186
  command: exports_external.string(),
184020
184187
  args: exports_external.array(exports_external.string()).default([]),
184021
184188
  model: exports_external.string().optional(),
184189
+ effort: exports_external.string().optional(),
184022
184190
  role: exports_external.enum([
184023
184191
  "implementation_reviewer",
184024
184192
  "architecture_security_reviewer",
@@ -184099,6 +184267,1060 @@ var kyosoConfigSchema = exports_external.object({
184099
184267
  includeFileContents: exports_external.boolean()
184100
184268
  })
184101
184269
  });
184270
+ function agentConfigLeafPaths(agent) {
184271
+ return [
184272
+ `agents.${agent}.enabled`,
184273
+ `agents.${agent}.type`,
184274
+ `agents.${agent}.command`,
184275
+ `agents.${agent}.args`,
184276
+ `agents.${agent}.model`,
184277
+ `agents.${agent}.effort`,
184278
+ `agents.${agent}.role`,
184279
+ `agents.${agent}.timeoutMs`,
184280
+ `agents.${agent}.env`,
184281
+ `agents.${agent}.auth.mode`,
184282
+ `agents.${agent}.auth.preferExistingLogin`,
184283
+ `agents.${agent}.auth.preferApiKey`,
184284
+ `agents.${agent}.auth.recommendedEnv`,
184285
+ `agents.${agent}.auth.envWhitelist`
184286
+ ];
184287
+ }
184288
+ var kyosoConfigKnownLeafPaths = [
184289
+ "entrypoints.mcp",
184290
+ "entrypoints.cli",
184291
+ "firstClassClient",
184292
+ "tools.planReview",
184293
+ "tools.securityReview",
184294
+ "tools.diffReview",
184295
+ ...agentConfigLeafPaths("codex"),
184296
+ ...agentConfigLeafPaths("claude"),
184297
+ "workspace.mode",
184298
+ "workspace.root",
184299
+ "workspace.readOnly",
184300
+ "workspace.maxContextBytes",
184301
+ "workspace.maxDiffBytes",
184302
+ "workspace.deny",
184303
+ "secrets.mode",
184304
+ "secrets.blockOnDetectedSecret",
184305
+ "secrets.allowOverride",
184306
+ "network.defaultMode",
184307
+ "network.allowUnrestricted",
184308
+ "network.warnOnUnrestricted",
184309
+ "network.mediatedWeb.enabled",
184310
+ "securityReview.cisaSecureByDesign.enabled",
184311
+ "securityReview.cisaSecureByDesign.gate",
184312
+ "securityReview.cisaSecureByDesign.dimensions.customerSecurityOutcomes",
184313
+ "securityReview.cisaSecureByDesign.dimensions.secureByDefault",
184314
+ "securityReview.cisaSecureByDesign.dimensions.transparencyAndAccountability",
184315
+ "securityReview.cisaSecureByDesign.dimensions.governance",
184316
+ "judge.mode",
184317
+ "judge.provider",
184318
+ "judge.timeoutMs",
184319
+ "verification.enabled",
184320
+ "verification.maxFindings",
184321
+ "verification.timeoutMs",
184322
+ "verification.allowDemotion",
184323
+ "audit.enabled",
184324
+ "audit.format",
184325
+ "audit.directory",
184326
+ "audit.includeRawAgentOutput",
184327
+ "audit.includeFileContents"
184328
+ ];
184329
+ var kyosoConfigRecordPrefixes = [
184330
+ "agents.codex.env",
184331
+ "agents.claude.env"
184332
+ ];
184333
+ var kyosoConfigSecuritySensitivePrefixes = [
184334
+ "agents.codex",
184335
+ "agents.claude",
184336
+ "audit",
184337
+ "judge",
184338
+ "network",
184339
+ "secrets",
184340
+ "securityReview",
184341
+ "verification",
184342
+ "workspace"
184343
+ ];
184344
+
184345
+ // src/security/redact.ts
184346
+ var REDACTION = "[KYOSO_REDACTED]";
184347
+
184348
+ // src/core/constants.ts
184349
+ var DEFAULT_AGENT_TIMEOUT_MS = 120000;
184350
+ var RAW_OUTPUT_MAX_CHARS = 16384;
184351
+ var KYOSO_CHILD_AGENT = "KYOSO_CHILD_AGENT";
184352
+ var KYOSO_VERSION = "0.7.0";
184353
+
184354
+ // src/security/sanitizeText.ts
184355
+ var SENSITIVE_TEXT_PATTERNS = [
184356
+ /\bsk-(?:proj-)?[A-Za-z0-9_-]{8,}\b/g,
184357
+ /\bsk-ant-[A-Za-z0-9_-]{8,}\b/g,
184358
+ /\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9_]{8,}\b/g,
184359
+ /\bAKIA[0-9A-Z]{8,}\b/g,
184360
+ /\bxox[baprs]-[A-Za-z0-9-]{8,}\b/g,
184361
+ /\bsk_(?:live|test)_[A-Za-z0-9]{8,}\b/g,
184362
+ /\b(?:api[_-]?key|secret|token|password)\b\s*[:=]\s*["']?[A-Za-z0-9_./+=-]{8,}["']?/gi
184363
+ ];
184364
+ function sanitizeText(value) {
184365
+ return SENSITIVE_TEXT_PATTERNS.reduce((text, pattern) => text.replace(pattern, REDACTION), value);
184366
+ }
184367
+ function sanitizeTextForDisplay(value, maxChars = 240) {
184368
+ const compact = sanitizeText(value).replace(/\s+/g, " ").trim();
184369
+ if (compact.length <= maxChars)
184370
+ return compact;
184371
+ return `${compact.slice(0, Math.max(0, maxChars - 3))}...`;
184372
+ }
184373
+ function sanitizeTextForRawOutput(value, maxChars = RAW_OUTPUT_MAX_CHARS) {
184374
+ const sanitized = sanitizeText(value);
184375
+ const limit = Math.max(0, maxChars);
184376
+ if (sanitized.length <= limit)
184377
+ return sanitized;
184378
+ return `${sanitized.slice(0, limit)}
184379
+ [KYOSO_TRUNCATED: ${sanitized.length - limit} chars omitted]`;
184380
+ }
184381
+
184382
+ // src/config/tomlConfigLoader.ts
184383
+ import { readFile as readFile2 } from "node:fs/promises";
184384
+
184385
+ // node_modules/smol-toml/dist/date.js
184386
+ /*!
184387
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
184388
+ * SPDX-License-Identifier: BSD-3-Clause
184389
+ *
184390
+ * Redistribution and use in source and binary forms, with or without
184391
+ * modification, are permitted provided that the following conditions are met:
184392
+ *
184393
+ * 1. Redistributions of source code must retain the above copyright notice, this
184394
+ * list of conditions and the following disclaimer.
184395
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
184396
+ * this list of conditions and the following disclaimer in the
184397
+ * documentation and/or other materials provided with the distribution.
184398
+ * 3. Neither the name of the copyright holder nor the names of its contributors
184399
+ * may be used to endorse or promote products derived from this software without
184400
+ * specific prior written permission.
184401
+ *
184402
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
184403
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
184404
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
184405
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
184406
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
184407
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
184408
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
184409
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
184410
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
184411
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
184412
+ */
184413
+ var DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;
184414
+
184415
+ class TomlDate extends Date {
184416
+ #hasDate = false;
184417
+ #hasTime = false;
184418
+ #offset = null;
184419
+ constructor(date5) {
184420
+ let hasDate = true;
184421
+ let hasTime = true;
184422
+ let offset = "Z";
184423
+ if (typeof date5 === "string") {
184424
+ let match = date5.match(DATE_TIME_RE);
184425
+ if (match) {
184426
+ if (!match[1]) {
184427
+ hasDate = false;
184428
+ date5 = `0000-01-01T${date5}`;
184429
+ }
184430
+ hasTime = !!match[2];
184431
+ hasTime && date5[10] === " " && (date5 = date5.replace(" ", "T"));
184432
+ if (match[2] && +match[2] > 23) {
184433
+ date5 = "";
184434
+ } else {
184435
+ offset = match[3] || null;
184436
+ date5 = date5.toUpperCase();
184437
+ if (!offset && hasTime)
184438
+ date5 += "Z";
184439
+ }
184440
+ } else {
184441
+ date5 = "";
184442
+ }
184443
+ }
184444
+ super(date5);
184445
+ if (!isNaN(this.getTime())) {
184446
+ this.#hasDate = hasDate;
184447
+ this.#hasTime = hasTime;
184448
+ this.#offset = offset;
184449
+ }
184450
+ }
184451
+ isDateTime() {
184452
+ return this.#hasDate && this.#hasTime;
184453
+ }
184454
+ isLocal() {
184455
+ return !this.#hasDate || !this.#hasTime || !this.#offset;
184456
+ }
184457
+ isDate() {
184458
+ return this.#hasDate && !this.#hasTime;
184459
+ }
184460
+ isTime() {
184461
+ return this.#hasTime && !this.#hasDate;
184462
+ }
184463
+ isValid() {
184464
+ return this.#hasDate || this.#hasTime;
184465
+ }
184466
+ toISOString() {
184467
+ let iso = super.toISOString();
184468
+ if (this.isDate())
184469
+ return iso.slice(0, 10);
184470
+ if (this.isTime())
184471
+ return iso.slice(11, 23);
184472
+ if (this.#offset === null)
184473
+ return iso.slice(0, -1);
184474
+ if (this.#offset === "Z")
184475
+ return iso;
184476
+ let offset = +this.#offset.slice(1, 3) * 60 + +this.#offset.slice(4, 6);
184477
+ offset = this.#offset[0] === "-" ? offset : -offset;
184478
+ let offsetDate = new Date(this.getTime() - offset * 60000);
184479
+ return offsetDate.toISOString().slice(0, -1) + this.#offset;
184480
+ }
184481
+ static wrapAsOffsetDateTime(jsDate, offset = "Z") {
184482
+ let date5 = new TomlDate(jsDate);
184483
+ date5.#offset = offset;
184484
+ return date5;
184485
+ }
184486
+ static wrapAsLocalDateTime(jsDate) {
184487
+ let date5 = new TomlDate(jsDate);
184488
+ date5.#offset = null;
184489
+ return date5;
184490
+ }
184491
+ static wrapAsLocalDate(jsDate) {
184492
+ let date5 = new TomlDate(jsDate);
184493
+ date5.#hasTime = false;
184494
+ date5.#offset = null;
184495
+ return date5;
184496
+ }
184497
+ static wrapAsLocalTime(jsDate) {
184498
+ let date5 = new TomlDate(jsDate);
184499
+ date5.#hasDate = false;
184500
+ date5.#offset = null;
184501
+ return date5;
184502
+ }
184503
+ }
184504
+
184505
+ // node_modules/smol-toml/dist/error.js
184506
+ /*!
184507
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
184508
+ * SPDX-License-Identifier: BSD-3-Clause
184509
+ *
184510
+ * Redistribution and use in source and binary forms, with or without
184511
+ * modification, are permitted provided that the following conditions are met:
184512
+ *
184513
+ * 1. Redistributions of source code must retain the above copyright notice, this
184514
+ * list of conditions and the following disclaimer.
184515
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
184516
+ * this list of conditions and the following disclaimer in the
184517
+ * documentation and/or other materials provided with the distribution.
184518
+ * 3. Neither the name of the copyright holder nor the names of its contributors
184519
+ * may be used to endorse or promote products derived from this software without
184520
+ * specific prior written permission.
184521
+ *
184522
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
184523
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
184524
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
184525
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
184526
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
184527
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
184528
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
184529
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
184530
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
184531
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
184532
+ */
184533
+ function getLineColFromPtr(string4, ptr) {
184534
+ let lines = string4.slice(0, ptr).split(/\r\n|\n|\r/g);
184535
+ return [lines.length, lines.pop().length + 1];
184536
+ }
184537
+ function makeCodeBlock(string4, line, column) {
184538
+ let lines = string4.split(/\r\n|\n|\r/g);
184539
+ let codeblock = "";
184540
+ let numberLen = (Math.log10(line + 1) | 0) + 1;
184541
+ for (let i = line - 1;i <= line + 1; i++) {
184542
+ let l = lines[i - 1];
184543
+ if (!l)
184544
+ continue;
184545
+ codeblock += i.toString().padEnd(numberLen, " ");
184546
+ codeblock += ": ";
184547
+ codeblock += l;
184548
+ codeblock += `
184549
+ `;
184550
+ if (i === line) {
184551
+ codeblock += " ".repeat(numberLen + column + 2);
184552
+ codeblock += `^
184553
+ `;
184554
+ }
184555
+ }
184556
+ return codeblock;
184557
+ }
184558
+
184559
+ class TomlError extends Error {
184560
+ line;
184561
+ column;
184562
+ codeblock;
184563
+ constructor(message, options) {
184564
+ const [line, column] = getLineColFromPtr(options.toml, options.ptr);
184565
+ const codeblock = makeCodeBlock(options.toml, line, column);
184566
+ super(`Invalid TOML document: ${message}
184567
+
184568
+ ${codeblock}`, options);
184569
+ this.line = line;
184570
+ this.column = column;
184571
+ this.codeblock = codeblock;
184572
+ }
184573
+ }
184574
+
184575
+ // node_modules/smol-toml/dist/primitive.js
184576
+ /*!
184577
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
184578
+ * SPDX-License-Identifier: BSD-3-Clause
184579
+ *
184580
+ * Redistribution and use in source and binary forms, with or without
184581
+ * modification, are permitted provided that the following conditions are met:
184582
+ *
184583
+ * 1. Redistributions of source code must retain the above copyright notice, this
184584
+ * list of conditions and the following disclaimer.
184585
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
184586
+ * this list of conditions and the following disclaimer in the
184587
+ * documentation and/or other materials provided with the distribution.
184588
+ * 3. Neither the name of the copyright holder nor the names of its contributors
184589
+ * may be used to endorse or promote products derived from this software without
184590
+ * specific prior written permission.
184591
+ *
184592
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
184593
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
184594
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
184595
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
184596
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
184597
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
184598
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
184599
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
184600
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
184601
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
184602
+ */
184603
+ var INT_REGEX = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/;
184604
+ var FLOAT_REGEX = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/;
184605
+ var LEADING_ZERO = /^[+-]?0[0-9_]/;
184606
+ function parseString(str, ptr) {
184607
+ let c = str[ptr++];
184608
+ let first = c;
184609
+ let isLiteral = c === "'";
184610
+ let isMultiline = c === str[ptr] && c === str[ptr + 1];
184611
+ if (isMultiline) {
184612
+ if (str[ptr += 2] === `
184613
+ `)
184614
+ ptr++;
184615
+ else if (str[ptr] === "\r" && str[ptr + 1] === `
184616
+ `)
184617
+ ptr += 2;
184618
+ }
184619
+ let parsed = "";
184620
+ let sliceStart = ptr;
184621
+ let state = 0;
184622
+ for (let i = ptr;i < str.length; i++) {
184623
+ c = str[i];
184624
+ if (isMultiline && (c === `
184625
+ ` || c === "\r" && str[i + 1] === `
184626
+ `)) {
184627
+ state = state && 3;
184628
+ } else if (c < " " && c !== "\t" || c === "") {
184629
+ throw new TomlError("control characters are not allowed in strings", {
184630
+ toml: str,
184631
+ ptr: i
184632
+ });
184633
+ } else if ((!state || state === 3) && c === first && (!isMultiline || str[i + 1] === first && str[i + 2] === first)) {
184634
+ if (isMultiline) {
184635
+ if (str[i + 3] === first)
184636
+ i++;
184637
+ if (str[i + 3] === first)
184638
+ i++;
184639
+ }
184640
+ return [
184641
+ state ? parsed : parsed + str.slice(sliceStart, i),
184642
+ i + (isMultiline ? 3 : 1)
184643
+ ];
184644
+ } else if (!state) {
184645
+ if (!isLiteral && c === "\\") {
184646
+ parsed += str.slice(sliceStart, sliceStart = i);
184647
+ state = 1;
184648
+ }
184649
+ } else if (state === 1) {
184650
+ if (c === "x" || c === "u" || c === "U") {
184651
+ let value = 0;
184652
+ let len = c === "x" ? 2 : c === "u" ? 4 : 8;
184653
+ for (let j = 0;j < len; j++, i++) {
184654
+ let hex3 = str.charCodeAt(i + 1);
184655
+ let digit = hex3 >= 48 && hex3 <= 57 ? hex3 - 48 : hex3 >= 65 && hex3 <= 70 ? hex3 - 65 + 10 : hex3 >= 97 && hex3 <= 102 ? hex3 - 97 + 10 : -1;
184656
+ if (digit < 0)
184657
+ throw new TomlError("invalid non-hex character in unicode escape", { toml: str, ptr: i + 1 });
184658
+ value = value << 4 | digit;
184659
+ }
184660
+ if (value < 0 || value > 1114111 || value >= 55296 && value <= 57343) {
184661
+ throw new TomlError("invalid unicode escape", { toml: str, ptr: i });
184662
+ }
184663
+ parsed += String.fromCodePoint(value);
184664
+ sliceStart = i + 1;
184665
+ state = 0;
184666
+ } else if (c === " " || c === "\t") {
184667
+ state = 2;
184668
+ } else {
184669
+ if (c === "b")
184670
+ parsed += "\b";
184671
+ else if (c === "t")
184672
+ parsed += "\t";
184673
+ else if (c === "n")
184674
+ parsed += `
184675
+ `;
184676
+ else if (c === "f")
184677
+ parsed += "\f";
184678
+ else if (c === "r")
184679
+ parsed += "\r";
184680
+ else if (c === "e")
184681
+ parsed += "\x1B";
184682
+ else if (c === '"')
184683
+ parsed += '"';
184684
+ else if (c === "\\")
184685
+ parsed += "\\";
184686
+ else
184687
+ throw new TomlError("unrecognized escape sequence", { toml: str, ptr: i });
184688
+ sliceStart = i + 1;
184689
+ state = 0;
184690
+ }
184691
+ } else if (c !== " " && c !== "\t") {
184692
+ if (state === 2) {
184693
+ throw new TomlError("invalid escape: only line-ending whitespace may be escaped", {
184694
+ toml: str,
184695
+ ptr: sliceStart
184696
+ });
184697
+ }
184698
+ state = !isLiteral && c === "\\" ? 1 : 0;
184699
+ sliceStart = i;
184700
+ }
184701
+ }
184702
+ throw new TomlError("unfinished string", { toml: str, ptr });
184703
+ }
184704
+ function parseValue(value, toml, ptr, integersAsBigInt) {
184705
+ if (value === "true")
184706
+ return true;
184707
+ if (value === "false")
184708
+ return false;
184709
+ if (value === "-inf")
184710
+ return -Infinity;
184711
+ if (value === "inf" || value === "+inf")
184712
+ return Infinity;
184713
+ if (value === "nan" || value === "+nan" || value === "-nan")
184714
+ return NaN;
184715
+ if (value === "-0")
184716
+ return integersAsBigInt ? 0n : 0;
184717
+ let isInt = INT_REGEX.test(value);
184718
+ if (isInt || FLOAT_REGEX.test(value)) {
184719
+ if (LEADING_ZERO.test(value)) {
184720
+ throw new TomlError("leading zeroes are not allowed", {
184721
+ toml,
184722
+ ptr
184723
+ });
184724
+ }
184725
+ value = value.replace(/_/g, "");
184726
+ let numeric = +value;
184727
+ if (isNaN(numeric)) {
184728
+ throw new TomlError("invalid number", {
184729
+ toml,
184730
+ ptr
184731
+ });
184732
+ }
184733
+ if (isInt) {
184734
+ if ((isInt = !Number.isSafeInteger(numeric)) && !integersAsBigInt) {
184735
+ throw new TomlError("integer value cannot be represented losslessly", {
184736
+ toml,
184737
+ ptr
184738
+ });
184739
+ }
184740
+ if (isInt || integersAsBigInt === true)
184741
+ numeric = BigInt(value);
184742
+ }
184743
+ return numeric;
184744
+ }
184745
+ const date5 = new TomlDate(value);
184746
+ if (!date5.isValid()) {
184747
+ throw new TomlError("invalid value", {
184748
+ toml,
184749
+ ptr
184750
+ });
184751
+ }
184752
+ return date5;
184753
+ }
184754
+
184755
+ // node_modules/smol-toml/dist/util.js
184756
+ /*!
184757
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
184758
+ * SPDX-License-Identifier: BSD-3-Clause
184759
+ *
184760
+ * Redistribution and use in source and binary forms, with or without
184761
+ * modification, are permitted provided that the following conditions are met:
184762
+ *
184763
+ * 1. Redistributions of source code must retain the above copyright notice, this
184764
+ * list of conditions and the following disclaimer.
184765
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
184766
+ * this list of conditions and the following disclaimer in the
184767
+ * documentation and/or other materials provided with the distribution.
184768
+ * 3. Neither the name of the copyright holder nor the names of its contributors
184769
+ * may be used to endorse or promote products derived from this software without
184770
+ * specific prior written permission.
184771
+ *
184772
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
184773
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
184774
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
184775
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
184776
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
184777
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
184778
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
184779
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
184780
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
184781
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
184782
+ */
184783
+ function indexOfNewline(str, start = 0, end = str.length) {
184784
+ let idx = str.indexOf(`
184785
+ `, start);
184786
+ if (str[idx - 1] === "\r")
184787
+ idx--;
184788
+ return idx <= end ? idx : -1;
184789
+ }
184790
+ function skipComment(str, ptr) {
184791
+ for (let i = ptr;i < str.length; i++) {
184792
+ let c = str[i];
184793
+ if (c === `
184794
+ `)
184795
+ return i;
184796
+ if (c === "\r" && str[i + 1] === `
184797
+ `)
184798
+ return i + 1;
184799
+ if (c < " " && c !== "\t" || c === "") {
184800
+ throw new TomlError("control characters are not allowed in comments", {
184801
+ toml: str,
184802
+ ptr
184803
+ });
184804
+ }
184805
+ }
184806
+ return str.length;
184807
+ }
184808
+ function skipVoid(str, ptr, banNewLines, banComments) {
184809
+ let c;
184810
+ while (true) {
184811
+ while ((c = str[ptr]) === " " || c === "\t" || !banNewLines && (c === `
184812
+ ` || c === "\r" && str[ptr + 1] === `
184813
+ `))
184814
+ ptr++;
184815
+ if (banComments || c !== "#")
184816
+ break;
184817
+ ptr = skipComment(str, ptr);
184818
+ }
184819
+ return ptr;
184820
+ }
184821
+ function skipUntil(str, ptr, sep, end, banNewLines = false) {
184822
+ if (!end) {
184823
+ ptr = indexOfNewline(str, ptr);
184824
+ return ptr < 0 ? str.length : ptr;
184825
+ }
184826
+ for (let i = ptr;i < str.length; i++) {
184827
+ let c = str[i];
184828
+ if (c === "#") {
184829
+ i = indexOfNewline(str, i);
184830
+ } else if (c === sep) {
184831
+ return i + 1;
184832
+ } else if (c === end || banNewLines && (c === `
184833
+ ` || c === "\r" && str[i + 1] === `
184834
+ `)) {
184835
+ return i;
184836
+ }
184837
+ }
184838
+ throw new TomlError("cannot find end of structure", {
184839
+ toml: str,
184840
+ ptr
184841
+ });
184842
+ }
184843
+
184844
+ // node_modules/smol-toml/dist/extract.js
184845
+ /*!
184846
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
184847
+ * SPDX-License-Identifier: BSD-3-Clause
184848
+ *
184849
+ * Redistribution and use in source and binary forms, with or without
184850
+ * modification, are permitted provided that the following conditions are met:
184851
+ *
184852
+ * 1. Redistributions of source code must retain the above copyright notice, this
184853
+ * list of conditions and the following disclaimer.
184854
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
184855
+ * this list of conditions and the following disclaimer in the
184856
+ * documentation and/or other materials provided with the distribution.
184857
+ * 3. Neither the name of the copyright holder nor the names of its contributors
184858
+ * may be used to endorse or promote products derived from this software without
184859
+ * specific prior written permission.
184860
+ *
184861
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
184862
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
184863
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
184864
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
184865
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
184866
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
184867
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
184868
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
184869
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
184870
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
184871
+ */
184872
+ function sliceAndTrimEndOf(str, startPtr, endPtr) {
184873
+ let value = str.slice(startPtr, endPtr);
184874
+ let commentIdx = value.indexOf("#");
184875
+ if (commentIdx > -1) {
184876
+ skipComment(str, commentIdx);
184877
+ value = value.slice(0, commentIdx);
184878
+ }
184879
+ return [value.trimEnd(), commentIdx];
184880
+ }
184881
+ function extractValue(str, ptr, end, depth, integersAsBigInt) {
184882
+ if (depth === 0) {
184883
+ throw new TomlError("document contains excessively nested structures. aborting.", {
184884
+ toml: str,
184885
+ ptr
184886
+ });
184887
+ }
184888
+ let c = str[ptr];
184889
+ if (c === "[" || c === "{") {
184890
+ let [value, endPtr2] = c === "[" ? parseArray(str, ptr, depth, integersAsBigInt) : parseInlineTable(str, ptr, depth, integersAsBigInt);
184891
+ if (end) {
184892
+ endPtr2 = skipVoid(str, endPtr2);
184893
+ if (str[endPtr2] === ",")
184894
+ endPtr2++;
184895
+ else if (str[endPtr2] !== end) {
184896
+ throw new TomlError("expected comma or end of structure", {
184897
+ toml: str,
184898
+ ptr: endPtr2
184899
+ });
184900
+ }
184901
+ }
184902
+ return [value, endPtr2];
184903
+ }
184904
+ if (c === '"' || c === "'") {
184905
+ let [parsed, endPtr2] = parseString(str, ptr);
184906
+ if (end) {
184907
+ endPtr2 = skipVoid(str, endPtr2);
184908
+ if (str[endPtr2] && str[endPtr2] !== "," && str[endPtr2] !== end && str[endPtr2] !== `
184909
+ ` && str[endPtr2] !== "\r") {
184910
+ throw new TomlError("unexpected character encountered", {
184911
+ toml: str,
184912
+ ptr: endPtr2
184913
+ });
184914
+ }
184915
+ if (str[endPtr2] === ",")
184916
+ endPtr2++;
184917
+ }
184918
+ return [parsed, endPtr2];
184919
+ }
184920
+ let endPtr = skipUntil(str, ptr, ",", end);
184921
+ let slice = sliceAndTrimEndOf(str, ptr, endPtr - (str[endPtr - 1] === "," ? 1 : 0));
184922
+ if (!slice[0]) {
184923
+ throw new TomlError("incomplete key-value declaration: no value specified", {
184924
+ toml: str,
184925
+ ptr
184926
+ });
184927
+ }
184928
+ if (end && slice[1] > -1) {
184929
+ endPtr = skipVoid(str, ptr + slice[1]);
184930
+ if (str[endPtr] === ",")
184931
+ endPtr++;
184932
+ }
184933
+ return [
184934
+ parseValue(slice[0], str, ptr, integersAsBigInt),
184935
+ endPtr
184936
+ ];
184937
+ }
184938
+
184939
+ // node_modules/smol-toml/dist/struct.js
184940
+ /*!
184941
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
184942
+ * SPDX-License-Identifier: BSD-3-Clause
184943
+ *
184944
+ * Redistribution and use in source and binary forms, with or without
184945
+ * modification, are permitted provided that the following conditions are met:
184946
+ *
184947
+ * 1. Redistributions of source code must retain the above copyright notice, this
184948
+ * list of conditions and the following disclaimer.
184949
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
184950
+ * this list of conditions and the following disclaimer in the
184951
+ * documentation and/or other materials provided with the distribution.
184952
+ * 3. Neither the name of the copyright holder nor the names of its contributors
184953
+ * may be used to endorse or promote products derived from this software without
184954
+ * specific prior written permission.
184955
+ *
184956
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
184957
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
184958
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
184959
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
184960
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
184961
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
184962
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
184963
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
184964
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
184965
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
184966
+ */
184967
+ var KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
184968
+ function parseKey(str, ptr, end = "=") {
184969
+ let dot = ptr - 1;
184970
+ let parsed = [];
184971
+ let endPtr = str.indexOf(end, ptr);
184972
+ if (endPtr < 0) {
184973
+ throw new TomlError("incomplete key-value: cannot find end of key", {
184974
+ toml: str,
184975
+ ptr
184976
+ });
184977
+ }
184978
+ do {
184979
+ let c = str[ptr = ++dot];
184980
+ if (c !== " " && c !== "\t") {
184981
+ if (c === '"' || c === "'") {
184982
+ if (c === str[ptr + 1] && c === str[ptr + 2]) {
184983
+ throw new TomlError("multiline strings are not allowed in keys", {
184984
+ toml: str,
184985
+ ptr
184986
+ });
184987
+ }
184988
+ let [part, eos] = parseString(str, ptr);
184989
+ dot = str.indexOf(".", eos);
184990
+ let strEnd = str.slice(eos, dot < 0 || dot > endPtr ? endPtr : dot);
184991
+ let newLine = indexOfNewline(strEnd);
184992
+ if (newLine > -1) {
184993
+ throw new TomlError("newlines are not allowed in keys", {
184994
+ toml: str,
184995
+ ptr: ptr + dot + newLine
184996
+ });
184997
+ }
184998
+ if (strEnd.trimStart()) {
184999
+ throw new TomlError("found extra tokens after the string part", {
185000
+ toml: str,
185001
+ ptr: eos
185002
+ });
185003
+ }
185004
+ if (endPtr < eos) {
185005
+ endPtr = str.indexOf(end, eos);
185006
+ if (endPtr < 0) {
185007
+ throw new TomlError("incomplete key-value: cannot find end of key", {
185008
+ toml: str,
185009
+ ptr
185010
+ });
185011
+ }
185012
+ }
185013
+ parsed.push(part);
185014
+ } else {
185015
+ dot = str.indexOf(".", ptr);
185016
+ let part = str.slice(ptr, dot < 0 || dot > endPtr ? endPtr : dot);
185017
+ if (!KEY_PART_RE.test(part)) {
185018
+ throw new TomlError("only letter, numbers, dashes and underscores are allowed in keys", {
185019
+ toml: str,
185020
+ ptr
185021
+ });
185022
+ }
185023
+ parsed.push(part.trimEnd());
185024
+ }
185025
+ }
185026
+ } while (dot + 1 && dot < endPtr);
185027
+ return [parsed, skipVoid(str, endPtr + 1, true, true)];
185028
+ }
185029
+ function parseInlineTable(str, ptr, depth, integersAsBigInt) {
185030
+ let res = {};
185031
+ let seen = new Set;
185032
+ let c;
185033
+ ptr++;
185034
+ while ((c = str[ptr++]) !== "}" && c) {
185035
+ if (c === ",") {
185036
+ throw new TomlError("expected value, found comma", {
185037
+ toml: str,
185038
+ ptr: ptr - 1
185039
+ });
185040
+ } else if (c === "#")
185041
+ ptr = skipComment(str, ptr);
185042
+ else if (c !== " " && c !== "\t" && c !== `
185043
+ ` && c !== "\r") {
185044
+ let k;
185045
+ let t = res;
185046
+ let hasOwn = false;
185047
+ let [key, keyEndPtr] = parseKey(str, ptr - 1);
185048
+ for (let i = 0;i < key.length; i++) {
185049
+ if (i)
185050
+ t = hasOwn ? t[k] : t[k] = {};
185051
+ k = key[i];
185052
+ if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== "object" || seen.has(t[k]))) {
185053
+ throw new TomlError("trying to redefine an already defined value", {
185054
+ toml: str,
185055
+ ptr
185056
+ });
185057
+ }
185058
+ if (!hasOwn && k === "__proto__") {
185059
+ Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
185060
+ }
185061
+ }
185062
+ if (hasOwn) {
185063
+ throw new TomlError("trying to redefine an already defined value", {
185064
+ toml: str,
185065
+ ptr
185066
+ });
185067
+ }
185068
+ let [value, valueEndPtr] = extractValue(str, keyEndPtr, "}", depth - 1, integersAsBigInt);
185069
+ seen.add(value);
185070
+ t[k] = value;
185071
+ ptr = valueEndPtr;
185072
+ }
185073
+ }
185074
+ if (!c) {
185075
+ throw new TomlError("unfinished table encountered", {
185076
+ toml: str,
185077
+ ptr
185078
+ });
185079
+ }
185080
+ return [res, ptr];
185081
+ }
185082
+ function parseArray(str, ptr, depth, integersAsBigInt) {
185083
+ let res = [];
185084
+ let c;
185085
+ ptr++;
185086
+ while ((c = str[ptr++]) !== "]" && c) {
185087
+ if (c === ",") {
185088
+ throw new TomlError("expected value, found comma", {
185089
+ toml: str,
185090
+ ptr: ptr - 1
185091
+ });
185092
+ } else if (c === "#")
185093
+ ptr = skipComment(str, ptr);
185094
+ else if (c !== " " && c !== "\t" && c !== `
185095
+ ` && c !== "\r") {
185096
+ let e = extractValue(str, ptr - 1, "]", depth - 1, integersAsBigInt);
185097
+ res.push(e[0]);
185098
+ ptr = e[1];
185099
+ }
185100
+ }
185101
+ if (!c) {
185102
+ throw new TomlError("unfinished array encountered", {
185103
+ toml: str,
185104
+ ptr
185105
+ });
185106
+ }
185107
+ return [res, ptr];
185108
+ }
185109
+
185110
+ // node_modules/smol-toml/dist/parse.js
185111
+ /*!
185112
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
185113
+ * SPDX-License-Identifier: BSD-3-Clause
185114
+ *
185115
+ * Redistribution and use in source and binary forms, with or without
185116
+ * modification, are permitted provided that the following conditions are met:
185117
+ *
185118
+ * 1. Redistributions of source code must retain the above copyright notice, this
185119
+ * list of conditions and the following disclaimer.
185120
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
185121
+ * this list of conditions and the following disclaimer in the
185122
+ * documentation and/or other materials provided with the distribution.
185123
+ * 3. Neither the name of the copyright holder nor the names of its contributors
185124
+ * may be used to endorse or promote products derived from this software without
185125
+ * specific prior written permission.
185126
+ *
185127
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
185128
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
185129
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
185130
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
185131
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
185132
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
185133
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
185134
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
185135
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
185136
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
185137
+ */
185138
+ function peekTable(key, table, meta3, type) {
185139
+ let t = table;
185140
+ let m = meta3;
185141
+ let k;
185142
+ let hasOwn = false;
185143
+ let state;
185144
+ for (let i = 0;i < key.length; i++) {
185145
+ if (i) {
185146
+ t = hasOwn ? t[k] : t[k] = {};
185147
+ m = (state = m[k]).c;
185148
+ if (type === 0 && (state.t === 1 || state.t === 2)) {
185149
+ return null;
185150
+ }
185151
+ if (state.t === 2) {
185152
+ let l = t.length - 1;
185153
+ t = t[l];
185154
+ m = m[l].c;
185155
+ }
185156
+ }
185157
+ k = key[i];
185158
+ if ((hasOwn = Object.hasOwn(t, k)) && m[k]?.t === 0 && m[k]?.d) {
185159
+ return null;
185160
+ }
185161
+ if (!hasOwn) {
185162
+ if (k === "__proto__") {
185163
+ Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
185164
+ Object.defineProperty(m, k, { enumerable: true, configurable: true, writable: true });
185165
+ }
185166
+ m[k] = {
185167
+ t: i < key.length - 1 && type === 2 ? 3 : type,
185168
+ d: false,
185169
+ i: 0,
185170
+ c: {}
185171
+ };
185172
+ }
185173
+ }
185174
+ state = m[k];
185175
+ if (state.t !== type && !(type === 1 && state.t === 3)) {
185176
+ return null;
185177
+ }
185178
+ if (type === 2) {
185179
+ if (!state.d) {
185180
+ state.d = true;
185181
+ t[k] = [];
185182
+ }
185183
+ t[k].push(t = {});
185184
+ state.c[state.i++] = state = { t: 1, d: false, i: 0, c: {} };
185185
+ }
185186
+ if (state.d) {
185187
+ return null;
185188
+ }
185189
+ state.d = true;
185190
+ if (type === 1) {
185191
+ t = hasOwn ? t[k] : t[k] = {};
185192
+ } else if (type === 0 && hasOwn) {
185193
+ return null;
185194
+ }
185195
+ return [k, t, state.c];
185196
+ }
185197
+ function parse5(toml, { maxDepth = 1000, integersAsBigInt } = {}) {
185198
+ let res = {};
185199
+ let meta3 = {};
185200
+ let tbl = res;
185201
+ let m = meta3;
185202
+ for (let ptr = skipVoid(toml, 0);ptr < toml.length; ) {
185203
+ if (toml[ptr] === "[") {
185204
+ let isTableArray = toml[++ptr] === "[";
185205
+ let k = parseKey(toml, ptr += +isTableArray, "]");
185206
+ if (isTableArray) {
185207
+ if (toml[k[1] - 1] !== "]") {
185208
+ throw new TomlError("expected end of table declaration", {
185209
+ toml,
185210
+ ptr: k[1] - 1
185211
+ });
185212
+ }
185213
+ k[1]++;
185214
+ }
185215
+ let p = peekTable(k[0], res, meta3, isTableArray ? 2 : 1);
185216
+ if (!p) {
185217
+ throw new TomlError("trying to redefine an already defined table or value", {
185218
+ toml,
185219
+ ptr
185220
+ });
185221
+ }
185222
+ m = p[2];
185223
+ tbl = p[1];
185224
+ ptr = k[1];
185225
+ } else {
185226
+ let k = parseKey(toml, ptr);
185227
+ let p = peekTable(k[0], tbl, m, 0);
185228
+ if (!p) {
185229
+ throw new TomlError("trying to redefine an already defined table or value", {
185230
+ toml,
185231
+ ptr
185232
+ });
185233
+ }
185234
+ let v = extractValue(toml, k[1], undefined, maxDepth, integersAsBigInt);
185235
+ p[1][p[0]] = v[0];
185236
+ ptr = v[1];
185237
+ }
185238
+ ptr = skipVoid(toml, ptr, true);
185239
+ if (toml[ptr] && toml[ptr] !== `
185240
+ ` && toml[ptr] !== "\r") {
185241
+ throw new TomlError("each key-value declaration must be followed by an end-of-line", {
185242
+ toml,
185243
+ ptr
185244
+ });
185245
+ }
185246
+ ptr = skipVoid(toml, ptr);
185247
+ }
185248
+ return res;
185249
+ }
185250
+
185251
+ // node_modules/smol-toml/dist/stringify.js
185252
+ /*!
185253
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
185254
+ * SPDX-License-Identifier: BSD-3-Clause
185255
+ *
185256
+ * Redistribution and use in source and binary forms, with or without
185257
+ * modification, are permitted provided that the following conditions are met:
185258
+ *
185259
+ * 1. Redistributions of source code must retain the above copyright notice, this
185260
+ * list of conditions and the following disclaimer.
185261
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
185262
+ * this list of conditions and the following disclaimer in the
185263
+ * documentation and/or other materials provided with the distribution.
185264
+ * 3. Neither the name of the copyright holder nor the names of its contributors
185265
+ * may be used to endorse or promote products derived from this software without
185266
+ * specific prior written permission.
185267
+ *
185268
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
185269
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
185270
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
185271
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
185272
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
185273
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
185274
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
185275
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
185276
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
185277
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
185278
+ */
185279
+
185280
+ // node_modules/smol-toml/dist/index.js
185281
+ /*!
185282
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
185283
+ * SPDX-License-Identifier: BSD-3-Clause
185284
+ *
185285
+ * Redistribution and use in source and binary forms, with or without
185286
+ * modification, are permitted provided that the following conditions are met:
185287
+ *
185288
+ * 1. Redistributions of source code must retain the above copyright notice, this
185289
+ * list of conditions and the following disclaimer.
185290
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
185291
+ * this list of conditions and the following disclaimer in the
185292
+ * documentation and/or other materials provided with the distribution.
185293
+ * 3. Neither the name of the copyright holder nor the names of its contributors
185294
+ * may be used to endorse or promote products derived from this software without
185295
+ * specific prior written permission.
185296
+ *
185297
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
185298
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
185299
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
185300
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
185301
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
185302
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
185303
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
185304
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
185305
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
185306
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
185307
+ */
185308
+
185309
+ // src/config/tomlConfigLoader.ts
185310
+ async function loadTomlConfigFile(configPath) {
185311
+ const source = await readFile2(configPath, "utf8");
185312
+ try {
185313
+ return parse5(source);
185314
+ } catch (error51) {
185315
+ throw new Error(formatTomlError(configPath, error51));
185316
+ }
185317
+ }
185318
+ function formatTomlError(configPath, error51) {
185319
+ if (error51 instanceof TomlError) {
185320
+ return `TOML config parse failed for ${configPath} at ${error51.line}:${error51.column}: ${error51.message}`;
185321
+ }
185322
+ return `TOML config parse failed for ${configPath}: ${error51 instanceof Error ? error51.message : String(error51)}`;
185323
+ }
184102
185324
 
184103
185325
  // src/config/tsConfigLoader.ts
184104
185326
  var import_typescript = __toESM(require_typescript(), 1);
@@ -184143,14 +185365,14 @@ ${transpiled}
184143
185365
 
184144
185366
  // src/config/trustedConfig.ts
184145
185367
  import { createHash } from "node:crypto";
184146
- import { mkdir as mkdir2, readFile as readFile2, writeFile as writeFile2 } from "node:fs/promises";
185368
+ import { mkdir as mkdir2, readFile as readFile3, writeFile as writeFile2 } from "node:fs/promises";
184147
185369
  import { homedir } from "node:os";
184148
185370
  import { dirname as dirname3, join, resolve } from "node:path";
184149
185371
  function hashConfigSource(source) {
184150
185372
  return createHash("sha256").update(source).digest("hex");
184151
185373
  }
184152
185374
  function defaultTrustedConfigStorePath(env = process.env) {
184153
- return env.KYOSO_TRUST_STORE_PATH ? resolve(env.KYOSO_TRUST_STORE_PATH) : join(homedir(), ".kyoso", "trusted-configs.json");
185375
+ return env.KYOSO_TRUST_STORE_PATH ? resolve(env.KYOSO_TRUST_STORE_PATH) : join(env.HOME ? resolve(env.HOME) : homedir(), ".kyoso", "trusted-configs.json");
184154
185376
  }
184155
185377
  async function isTrustedConfig(storePath, configPath, configHash) {
184156
185378
  const store = await readTrustedConfigStore(storePath);
@@ -184169,7 +185391,7 @@ async function trustConfig(storePath, configPath, configHash) {
184169
185391
  async function readTrustedConfigStore(storePath) {
184170
185392
  let parsed;
184171
185393
  try {
184172
- parsed = JSON.parse(await readFile2(storePath, "utf8"));
185394
+ parsed = JSON.parse(await readFile3(storePath, "utf8"));
184173
185395
  } catch (error51) {
184174
185396
  if (isMissingPathError(error51))
184175
185397
  return {};
@@ -184177,7 +185399,7 @@ async function readTrustedConfigStore(storePath) {
184177
185399
  return {};
184178
185400
  throw error51;
184179
185401
  }
184180
- if (!isRecord(parsed))
185402
+ if (!isRecord2(parsed))
184181
185403
  return {};
184182
185404
  const store = {};
184183
185405
  for (const [configPath, configHash] of Object.entries(parsed)) {
@@ -184186,7 +185408,7 @@ async function readTrustedConfigStore(storePath) {
184186
185408
  }
184187
185409
  return store;
184188
185410
  }
184189
- function isRecord(value) {
185411
+ function isRecord2(value) {
184190
185412
  return typeof value === "object" && value !== null && !Array.isArray(value);
184191
185413
  }
184192
185414
  function isMissingPathError(error51) {
@@ -184194,44 +185416,178 @@ function isMissingPathError(error51) {
184194
185416
  }
184195
185417
 
184196
185418
  // src/config/loadConfig.ts
185419
+ var KNOWN_GLOBAL_CONFIG_LEAF_PATHS = new Set(kyosoConfigKnownLeafPaths);
185420
+ var GLOBAL_CONFIG_RECORD_PREFIXES = kyosoConfigRecordPrefixes.map((path) => path.split("."));
185421
+ var SECURITY_SENSITIVE_GLOBAL_PREFIXES = kyosoConfigSecuritySensitivePrefixes.map((path) => path.split("."));
184197
185422
  async function loadConfig(options = {}) {
184198
185423
  const cwd = options.cwd ?? process.cwd();
185424
+ const env = options.env ?? process.env;
185425
+ const globalConfigPath = resolveGlobalTomlConfigPath(env);
184199
185426
  const warnings = [];
184200
- let userConfig = {};
185427
+ const sources = [];
185428
+ let mergedConfig = defaultConfig;
184201
185429
  let configPath;
184202
185430
  let configHash;
184203
185431
  let configTrustStatus = options.ignoreConfig ? "ignored" : "not_found";
184204
185432
  if (!options.ignoreConfig) {
184205
- const candidate = resolve2(cwd, options.configPath ?? "kyoso.config.ts");
184206
- if (await exists2(candidate)) {
184207
- configPath = candidate;
184208
- const source = await readFile3(candidate, "utf8");
184209
- configHash = hashConfigSource(source);
184210
- const trustStorePath = options.trustStorePath ?? defaultTrustedConfigStorePath();
184211
- const trusted = await isTrustedConfig(trustStorePath, candidate, configHash);
184212
- const trustDecision = await resolveTrustDecision({
184213
- configPath: candidate,
184214
- configHash,
184215
- trusted,
185433
+ if (await exists2(globalConfigPath)) {
185434
+ const globalConfig2 = await loadTomlConfigFile(globalConfigPath);
185435
+ const globalConfigWarnings = collectGlobalConfigWarnings(globalConfigPath, globalConfig2);
185436
+ const securitySensitiveWarnings = globalConfigWarnings.filter((warning) => warning.startsWith("security-sensitive unknown settings "));
185437
+ if (securitySensitiveWarnings.length > 0 && !options.allowUnknownConfig) {
185438
+ throw new Error(`Security-sensitive unknown config settings rejected. Fix the key name or pass --allow-unknown-config to continue with warnings: ${securitySensitiveWarnings.join("; ")}`);
185439
+ }
185440
+ warnings.push(...globalConfigWarnings);
185441
+ mergedConfig = deepMerge2(mergedConfig, globalConfig2);
185442
+ sources.push({ path: globalConfigPath, layer: "global_toml" });
185443
+ }
185444
+ if (options.configPath) {
185445
+ const explicitConfigPath = resolve2(cwd, options.configPath);
185446
+ if (!await exists2(explicitConfigPath)) {
185447
+ throw new Error(`Config file not found: ${explicitConfigPath} (from --config)`);
185448
+ }
185449
+ const loaded = await loadProjectConfig({
185450
+ configPath: explicitConfigPath,
185451
+ baseConfig: mergedConfig,
185452
+ globalConfigPath,
184216
185453
  options
184217
185454
  });
184218
- configTrustStatus = trustDecision.status;
184219
- if (trustDecision.execute) {
184220
- userConfig = await loadUserConfig(candidate, source);
184221
- if (trustDecision.shouldPersist) {
184222
- await trustConfig(trustStorePath, candidate, configHash);
184223
- }
184224
- } else {
184225
- warnings.push(`untrusted config was not executed: ${candidate}; run \`kyoso doctor --trust-config\` or pass \`--trust-config\` once to trust it`);
185455
+ mergedConfig = loaded.mergedConfig;
185456
+ configPath = loaded.configPath;
185457
+ configHash = loaded.configHash;
185458
+ configTrustStatus = loaded.configTrustStatus;
185459
+ sources.push(loaded.source);
185460
+ warnings.push(...loaded.warnings);
185461
+ } else {
185462
+ const projectTomlPath = resolve2(cwd, "kyoso.toml");
185463
+ const projectTsPath = resolve2(cwd, "kyoso.config.ts");
185464
+ const hasProjectToml = await exists2(projectTomlPath);
185465
+ const hasProjectTs = await exists2(projectTsPath);
185466
+ if (hasProjectToml) {
185467
+ mergedConfig = mergeProjectTomlConfig(mergedConfig, await loadTomlConfigFile(projectTomlPath), { projectPath: projectTomlPath, globalConfigPath });
185468
+ configPath = projectTomlPath;
185469
+ sources.push({ path: projectTomlPath, layer: "project_toml" });
185470
+ if (hasProjectTs) {
185471
+ warnings.push(`kyoso.config.ts was ignored because kyoso.toml takes precedence: ${projectTsPath}`);
185472
+ }
185473
+ } else if (hasProjectTs) {
185474
+ const loaded = await loadProjectTsConfig({
185475
+ configPath: projectTsPath,
185476
+ baseConfig: mergedConfig,
185477
+ options
185478
+ });
185479
+ mergedConfig = loaded.mergedConfig;
185480
+ configPath = loaded.configPath;
185481
+ configHash = loaded.configHash;
185482
+ configTrustStatus = loaded.configTrustStatus;
185483
+ sources.push(loaded.source);
185484
+ warnings.push(...loaded.warnings);
184226
185485
  }
184227
185486
  }
184228
185487
  }
184229
- const parsed = kyosoConfigSchema.parse(deepMerge(defaultConfig, userConfig));
185488
+ const parsed = kyosoConfigSchema.parse(mergedConfig);
184230
185489
  return {
184231
185490
  config: parsed,
184232
185491
  configPath,
184233
185492
  configHash,
184234
185493
  configTrustStatus,
185494
+ sources,
185495
+ warnings
185496
+ };
185497
+ }
185498
+ function resolveGlobalTomlConfigPath(env = process.env) {
185499
+ const configHome = env.XDG_CONFIG_HOME ? resolve2(env.XDG_CONFIG_HOME) : join2(env.HOME ? resolve2(env.HOME) : homedir2(), ".config");
185500
+ return join2(configHome, "kyoso", "config.toml");
185501
+ }
185502
+ function collectGlobalConfigWarnings(configPath, config2) {
185503
+ const unknownSettings = flattenLeaves(config2).map((leaf) => leaf.path).filter((path) => !isKnownGlobalConfigPath(path)).map((path) => ({
185504
+ path: sanitizeWarningText(path.join(".")),
185505
+ securitySensitive: isSecuritySensitiveGlobalPath(path)
185506
+ })).sort((left, right) => left.path.localeCompare(right.path));
185507
+ const warnings = [];
185508
+ const securitySensitivePaths = unknownSettings.filter((setting) => setting.securitySensitive).map((setting) => setting.path);
185509
+ const generalPaths = unknownSettings.filter((setting) => !setting.securitySensitive).map((setting) => setting.path);
185510
+ const sanitizedConfigPath = sanitizeWarningText(configPath);
185511
+ if (securitySensitivePaths.length > 0) {
185512
+ warnings.push(`security-sensitive unknown settings in ${sanitizedConfigPath} were ignored: ${formatUnknownPaths(securitySensitivePaths)}`);
185513
+ }
185514
+ if (generalPaths.length > 0) {
185515
+ warnings.push(`unknown settings in ${sanitizedConfigPath} were ignored: ${formatUnknownPaths(generalPaths)}`);
185516
+ }
185517
+ return warnings;
185518
+ }
185519
+ function sanitizeWarningText(value) {
185520
+ const withoutControlChars = value.replace(/\u001b\[[0-?]*[ -/]*[@-~]/g, "").replace(/[\u0000-\u001f\u007f-\u009f]/g, "");
185521
+ return sanitizeText(withoutControlChars);
185522
+ }
185523
+ function formatUnknownPaths(paths) {
185524
+ return paths.map((path) => JSON.stringify(path)).join("; ");
185525
+ }
185526
+ function isSecuritySensitiveGlobalPath(path) {
185527
+ return SECURITY_SENSITIVE_GLOBAL_PREFIXES.some((prefix) => pathStartsWith(path, prefix));
185528
+ }
185529
+ function isKnownGlobalConfigPath(path) {
185530
+ if (KNOWN_GLOBAL_CONFIG_LEAF_PATHS.has(path.join(".")))
185531
+ return true;
185532
+ return GLOBAL_CONFIG_RECORD_PREFIXES.some((prefix) => pathStartsWith(path, prefix));
185533
+ }
185534
+ function pathStartsWith(path, prefix) {
185535
+ return path.length >= prefix.length && prefix.every((part, index) => path[index] === part);
185536
+ }
185537
+ async function loadProjectConfig(input2) {
185538
+ const extension = extname3(input2.configPath);
185539
+ if (extension === ".toml") {
185540
+ return {
185541
+ mergedConfig: mergeProjectTomlConfig(input2.baseConfig, await loadTomlConfigFile(input2.configPath), {
185542
+ projectPath: input2.configPath,
185543
+ globalConfigPath: input2.globalConfigPath
185544
+ }),
185545
+ configPath: input2.configPath,
185546
+ configTrustStatus: "not_found",
185547
+ source: { path: input2.configPath, layer: "project_toml" },
185548
+ warnings: []
185549
+ };
185550
+ }
185551
+ if (extension === ".ts") {
185552
+ return await loadProjectTsConfig(input2);
185553
+ }
185554
+ throw new Error(`Unsupported config file extension for ${input2.configPath}. Expected .toml or .ts.`);
185555
+ }
185556
+ async function loadProjectTsConfig(input2) {
185557
+ const warnings = [
185558
+ 'kyoso.config.ts is deprecated; migrate to kyoso.toml (see README "Configuration")'
185559
+ ];
185560
+ const source = await readFile4(input2.configPath, "utf8");
185561
+ const configHash = hashConfigSource(source);
185562
+ const trustStorePath = input2.options.trustStorePath ?? defaultTrustedConfigStorePath(input2.options.env);
185563
+ const trusted = await isTrustedConfig(trustStorePath, input2.configPath, configHash);
185564
+ const trustDecision = await resolveTrustDecision({
185565
+ configPath: input2.configPath,
185566
+ configHash,
185567
+ trusted,
185568
+ options: input2.options
185569
+ });
185570
+ if (trustDecision.execute) {
185571
+ const userConfig = await loadUserConfig(input2.configPath, source);
185572
+ if (trustDecision.shouldPersist) {
185573
+ await trustConfig(trustStorePath, input2.configPath, configHash);
185574
+ }
185575
+ return {
185576
+ mergedConfig: deepMerge2(input2.baseConfig, userConfig),
185577
+ configPath: input2.configPath,
185578
+ configHash,
185579
+ configTrustStatus: trustDecision.status,
185580
+ source: { path: input2.configPath, layer: "project_ts" },
185581
+ warnings
185582
+ };
185583
+ }
185584
+ warnings.push(`untrusted config was not executed: ${input2.configPath}; run \`kyoso doctor --trust-config\` or pass \`--trust-config\` once to trust it`);
185585
+ return {
185586
+ mergedConfig: input2.baseConfig,
185587
+ configPath: input2.configPath,
185588
+ configHash,
185589
+ configTrustStatus: trustDecision.status,
185590
+ source: { path: input2.configPath, layer: "project_ts" },
184235
185591
  warnings
184236
185592
  };
184237
185593
  }
@@ -184281,16 +185637,16 @@ async function promptForConfigTrust(configPath, configHash) {
184281
185637
  rl.close();
184282
185638
  }
184283
185639
  }
184284
- function deepMerge(base, override) {
184285
- if (!isRecord2(base) || !isRecord2(override))
185640
+ function deepMerge2(base, override) {
185641
+ if (!isRecord3(base) || !isRecord3(override))
184286
185642
  return override ?? base;
184287
185643
  const result = { ...base };
184288
185644
  for (const [key, value] of Object.entries(override)) {
184289
- result[key] = deepMerge(result[key], value);
185645
+ result[key] = deepMerge2(result[key], value);
184290
185646
  }
184291
185647
  return result;
184292
185648
  }
184293
- function isRecord2(value) {
185649
+ function isRecord3(value) {
184294
185650
  return typeof value === "object" && value !== null && !Array.isArray(value);
184295
185651
  }
184296
185652
  async function exists2(path) {
@@ -184302,43 +185658,6 @@ async function exists2(path) {
184302
185658
  }
184303
185659
  }
184304
185660
 
184305
- // src/security/redact.ts
184306
- var REDACTION = "[KYOSO_REDACTED]";
184307
-
184308
- // src/core/constants.ts
184309
- var DEFAULT_AGENT_TIMEOUT_MS = 120000;
184310
- var RAW_OUTPUT_MAX_CHARS = 16384;
184311
- var KYOSO_CHILD_AGENT = "KYOSO_CHILD_AGENT";
184312
- var KYOSO_VERSION = "0.5.0";
184313
-
184314
- // src/security/sanitizeText.ts
184315
- var SENSITIVE_TEXT_PATTERNS = [
184316
- /\bsk-(?:proj-)?[A-Za-z0-9_-]{8,}\b/g,
184317
- /\bsk-ant-[A-Za-z0-9_-]{8,}\b/g,
184318
- /\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9_]{8,}\b/g,
184319
- /\bAKIA[0-9A-Z]{8,}\b/g,
184320
- /\bxox[baprs]-[A-Za-z0-9-]{8,}\b/g,
184321
- /\bsk_(?:live|test)_[A-Za-z0-9]{8,}\b/g,
184322
- /\b(?:api[_-]?key|secret|token|password)\b\s*[:=]\s*["']?[A-Za-z0-9_./+=-]{8,}["']?/gi
184323
- ];
184324
- function sanitizeText(value) {
184325
- return SENSITIVE_TEXT_PATTERNS.reduce((text, pattern) => text.replace(pattern, REDACTION), value);
184326
- }
184327
- function sanitizeTextForDisplay(value, maxChars = 240) {
184328
- const compact = sanitizeText(value).replace(/\s+/g, " ").trim();
184329
- if (compact.length <= maxChars)
184330
- return compact;
184331
- return `${compact.slice(0, Math.max(0, maxChars - 3))}...`;
184332
- }
184333
- function sanitizeTextForRawOutput(value, maxChars = RAW_OUTPUT_MAX_CHARS) {
184334
- const sanitized = sanitizeText(value);
184335
- const limit = Math.max(0, maxChars);
184336
- if (sanitized.length <= limit)
184337
- return sanitized;
184338
- return `${sanitized.slice(0, limit)}
184339
- [KYOSO_TRUNCATED: ${sanitized.length - limit} chars omitted]`;
184340
- }
184341
-
184342
185661
  // src/judge/prompt.ts
184343
185662
  var ANALYSIS_MAX_ITEMS = 5;
184344
185663
  var ANALYSIS_MAX_CHARS = 500;
@@ -184387,7 +185706,7 @@ function parseJudgeOutput(text, fallbackSummaryText) {
184387
185706
  const parsed = JSON.parse(json2);
184388
185707
  const summaryText = typeof parsed.summaryText === "string" && parsed.summaryText.trim().length > 0 ? sanitizeText(parsed.summaryText) : fallbackSummaryText;
184389
185708
  const disagreementComments = Array.isArray(parsed.disagreementComments) ? parsed.disagreementComments.flatMap((item) => {
184390
- if (!isRecord3(item) || typeof item.topic !== "string" || typeof item.judgeComment !== "string") {
185709
+ if (!isRecord4(item) || typeof item.topic !== "string" || typeof item.judgeComment !== "string") {
184391
185710
  return [];
184392
185711
  }
184393
185712
  return [
@@ -184403,7 +185722,7 @@ function parseJudgeOutput(text, fallbackSummaryText) {
184403
185722
  return { summaryText, disagreementComments, analysis };
184404
185723
  }
184405
185724
  function parseAnalysis(value) {
184406
- if (!isRecord3(value))
185725
+ if (!isRecord4(value))
184407
185726
  return;
184408
185727
  if (!Array.isArray(value.blindSpots) || !Array.isArray(value.contradictions) || !Array.isArray(value.partialCoverage)) {
184409
185728
  return;
@@ -184411,7 +185730,7 @@ function parseAnalysis(value) {
184411
185730
  return {
184412
185731
  blindSpots: value.blindSpots.slice(0, ANALYSIS_MAX_ITEMS).flatMap((item) => typeof item === "string" ? [sanitizeAnalysisText(item)] : []),
184413
185732
  contradictions: value.contradictions.slice(0, ANALYSIS_MAX_ITEMS).flatMap((item) => {
184414
- if (!isRecord3(item) || typeof item.topic !== "string" || typeof item.detail !== "string") {
185733
+ if (!isRecord4(item) || typeof item.topic !== "string" || typeof item.detail !== "string") {
184415
185734
  return [];
184416
185735
  }
184417
185736
  return [
@@ -184422,7 +185741,7 @@ function parseAnalysis(value) {
184422
185741
  ];
184423
185742
  }),
184424
185743
  partialCoverage: value.partialCoverage.slice(0, ANALYSIS_MAX_ITEMS).flatMap((item) => {
184425
- if (!isRecord3(item) || typeof item.note !== "string")
185744
+ if (!isRecord4(item) || typeof item.note !== "string")
184426
185745
  return [];
184427
185746
  const findingId = typeof item.findingId === "string" ? sanitizeAnalysisText(item.findingId) : undefined;
184428
185747
  return [
@@ -184469,7 +185788,7 @@ function extractFirstJsonObject(text) {
184469
185788
  }
184470
185789
  return;
184471
185790
  }
184472
- function isRecord3(value) {
185791
+ function isRecord4(value) {
184473
185792
  return typeof value === "object" && value !== null && !Array.isArray(value);
184474
185793
  }
184475
185794
 
@@ -184616,9 +185935,9 @@ function hasEnv(env, key) {
184616
185935
  // src/cli/setup.ts
184617
185936
  import { spawnSync } from "node:child_process";
184618
185937
  import { existsSync, readFileSync } from "node:fs";
184619
- import { cp, mkdir as mkdir3, readFile as readFile4, writeFile as writeFile3 } from "node:fs/promises";
184620
- import { homedir as homedir2 } from "node:os";
184621
- import { delimiter, dirname as dirname4, join as join2 } from "node:path";
185938
+ import { cp, mkdir as mkdir3, readFile as readFile5, writeFile as writeFile3 } from "node:fs/promises";
185939
+ import { homedir as homedir3 } from "node:os";
185940
+ import { delimiter, dirname as dirname4, join as join3 } from "node:path";
184622
185941
  import { fileURLToPath } from "node:url";
184623
185942
  async function runSetup(options) {
184624
185943
  const client = parseClient(options.client);
@@ -184626,7 +185945,7 @@ async function runSetup(options) {
184626
185945
  const command = options.command ? parseCommandSpec(options.command) : commandForRunner(runner);
184627
185946
  const context = {
184628
185947
  cwd: options.cwd,
184629
- home: options.env?.HOME ?? homedir2(),
185948
+ home: options.env?.HOME ?? homedir3(),
184630
185949
  env: options.env ?? process.env,
184631
185950
  write: options.write,
184632
185951
  scope: options.global ? "global" : "project",
@@ -184672,21 +185991,21 @@ function buildClaudeMcpEntry(command) {
184672
185991
  function skillDestination(client, scope, cwd, home) {
184673
185992
  if (client === "codex") {
184674
185993
  const root2 = scope === "global" ? home : cwd;
184675
- return join2(root2, ".agents", "skills", "kyoso-review");
185994
+ return join3(root2, ".agents", "skills", "kyoso-review");
184676
185995
  }
184677
185996
  const root = scope === "global" ? home : cwd;
184678
- return join2(root, ".claude", "skills", "kyoso-review");
185997
+ return join3(root, ".claude", "skills", "kyoso-review");
184679
185998
  }
184680
185999
  function detectSetup(options) {
184681
- const home = options.home ?? homedir2();
186000
+ const home = options.home ?? homedir3();
184682
186001
  return {
184683
186002
  codex: {
184684
- mcp: hasCodexMcp(join2(home, ".codex", "config.toml")),
184685
- skill: existsSync(join2(options.cwd, ".agents", "skills", "kyoso-review", "SKILL.md")) || existsSync(join2(home, ".agents", "skills", "kyoso-review", "SKILL.md"))
186003
+ mcp: hasCodexMcp(join3(home, ".codex", "config.toml")),
186004
+ skill: existsSync(join3(options.cwd, ".agents", "skills", "kyoso-review", "SKILL.md")) || existsSync(join3(home, ".agents", "skills", "kyoso-review", "SKILL.md"))
184686
186005
  },
184687
186006
  "claude-code": {
184688
- mcp: hasClaudeMcp(join2(options.cwd, ".mcp.json")) || hasClaudeMcp(join2(home, ".claude.json")),
184689
- skill: existsSync(join2(options.cwd, ".claude", "skills", "kyoso-review", "SKILL.md")) || existsSync(join2(home, ".claude", "skills", "kyoso-review", "SKILL.md"))
186007
+ mcp: hasClaudeMcp(join3(options.cwd, ".mcp.json")) || hasClaudeMcp(join3(home, ".claude.json")),
186008
+ skill: existsSync(join3(options.cwd, ".claude", "skills", "kyoso-review", "SKILL.md")) || existsSync(join3(home, ".claude", "skills", "kyoso-review", "SKILL.md"))
184690
186009
  }
184691
186010
  };
184692
186011
  }
@@ -184715,7 +186034,7 @@ async function setupClaudeCode(context) {
184715
186034
  ];
184716
186035
  }
184717
186036
  async function ensureCodexMcp(context) {
184718
- const configPath = join2(context.home, ".codex", "config.toml");
186037
+ const configPath = join3(context.home, ".codex", "config.toml");
184719
186038
  const snippet = buildCodexMcpToml(context.mcpCommand);
184720
186039
  const current = await readOptionalFile(configPath);
184721
186040
  if (hasCodexMcpContent(current)) {
@@ -184747,10 +186066,10 @@ async function ensureClaudeMcp(context) {
184747
186066
  if (context.scope === "global") {
184748
186067
  return ensureClaudeGlobalMcp(context);
184749
186068
  }
184750
- const configPath = join2(context.cwd, ".mcp.json");
186069
+ const configPath = join3(context.cwd, ".mcp.json");
184751
186070
  const current = await readJsonObject(configPath);
184752
186071
  const mcpServers = recordValue(current.mcpServers);
184753
- if (isRecord4(mcpServers.kyoso)) {
186072
+ if (isRecord5(mcpServers.kyoso)) {
184754
186073
  return {
184755
186074
  title: "Claude Code MCP",
184756
186075
  status: "skipped",
@@ -184784,7 +186103,7 @@ async function ensureClaudeMcp(context) {
184784
186103
  };
184785
186104
  }
184786
186105
  function ensureClaudeGlobalMcp(context) {
184787
- const configPath = join2(context.home, ".claude.json");
186106
+ const configPath = join3(context.home, ".claude.json");
184788
186107
  if (hasClaudeMcp(configPath)) {
184789
186108
  return {
184790
186109
  title: "Claude Code MCP",
@@ -184816,7 +186135,7 @@ function ensureClaudeGlobalMcp(context) {
184816
186135
  };
184817
186136
  }
184818
186137
  async function ensureSkill(options) {
184819
- const destinationSkill = join2(options.destinationDir, "SKILL.md");
186138
+ const destinationSkill = join3(options.destinationDir, "SKILL.md");
184820
186139
  if (existsSync(destinationSkill)) {
184821
186140
  return {
184822
186141
  title: options.title,
@@ -184937,8 +186256,8 @@ function resolveBundledSkillDir() {
184937
186256
  const start = dirname4(fileURLToPath(import.meta.url));
184938
186257
  let current = start;
184939
186258
  for (let depth = 0;depth < 5; depth += 1) {
184940
- const candidate = join2(current, ".agents", "skills", "kyoso-review");
184941
- if (existsSync(join2(candidate, "SKILL.md")))
186259
+ const candidate = join3(current, ".agents", "skills", "kyoso-review");
186260
+ if (existsSync(join3(candidate, "SKILL.md")))
184942
186261
  return candidate;
184943
186262
  current = dirname4(current);
184944
186263
  }
@@ -184946,7 +186265,7 @@ function resolveBundledSkillDir() {
184946
186265
  }
184947
186266
  async function readOptionalFile(path) {
184948
186267
  try {
184949
- return await readFile4(path, "utf8");
186268
+ return await readFile5(path, "utf8");
184950
186269
  } catch (error51) {
184951
186270
  if (isMissingPathError2(error51))
184952
186271
  return "";
@@ -184958,7 +186277,7 @@ async function readJsonObject(path) {
184958
186277
  if (content.trim().length === 0)
184959
186278
  return {};
184960
186279
  const parsed = JSON.parse(content);
184961
- if (!isRecord4(parsed))
186280
+ if (!isRecord5(parsed))
184962
186281
  throw new Error(`${path} must contain a JSON object`);
184963
186282
  return parsed;
184964
186283
  }
@@ -184979,9 +186298,9 @@ function hasClaudeMcp(path) {
184979
186298
  }
184980
186299
  }
184981
186300
  function jsonHasKyosoMcp(value) {
184982
- if (!isRecord4(value))
186301
+ if (!isRecord5(value))
184983
186302
  return false;
184984
- if (isRecord4(value.mcpServers) && isRecord4(value.mcpServers.kyoso)) {
186303
+ if (isRecord5(value.mcpServers) && isRecord5(value.mcpServers.kyoso)) {
184985
186304
  return true;
184986
186305
  }
184987
186306
  return Object.values(value).some((child) => jsonHasKyosoMcp(child));
@@ -184992,7 +186311,7 @@ function readTextSync(path) {
184992
186311
  function recordValue(value) {
184993
186312
  return typeof value === "object" && value !== null && !Array.isArray(value) ? value : {};
184994
186313
  }
184995
- function isRecord4(value) {
186314
+ function isRecord5(value) {
184996
186315
  return typeof value === "object" && value !== null && !Array.isArray(value);
184997
186316
  }
184998
186317
  function diffForAppend(path, snippet) {
@@ -185069,7 +186388,7 @@ function shellQuote(value) {
185069
186388
  }
185070
186389
  function commandExists(command, env) {
185071
186390
  const paths = env.PATH?.split(delimiter) ?? [];
185072
- return paths.some((path) => existsSync(join2(path, command)));
186391
+ return paths.some((path) => existsSync(join3(path, command)));
185073
186392
  }
185074
186393
  function isMissingPathError2(error51) {
185075
186394
  return typeof error51 === "object" && error51 !== null && "code" in error51 && error51.code === "ENOENT";
@@ -185079,11 +186398,16 @@ function isMissingPathError2(error51) {
185079
186398
  async function runDoctor(options) {
185080
186399
  const env = options.env ?? process.env;
185081
186400
  const loaded = await loadConfig(options);
186401
+ const globalConfigPath = resolveGlobalTomlConfigPath(env);
186402
+ const projectTomlPath = resolve4(options.cwd, "kyoso.toml");
186403
+ const projectTsPath = resolve4(options.cwd, "kyoso.config.ts");
185082
186404
  const lines = ["Kyoso doctor", "", "Runtime"];
185083
186405
  lines.push(` Bun: ${commandExists2("bun", env) ? "ok" : "warning not found"}`);
185084
186406
  lines.push(` Node/npm: ${commandExists2("npm", env) ? "ok" : "warning npm not found"}`);
185085
186407
  lines.push("", "Config");
185086
- lines.push(` kyoso.config.ts: ${loaded.configPath ? `found ${loaded.configPath}` : "not found; using defaults"}`);
186408
+ lines.push(` global config.toml: ${formatLayer(loaded, "global_toml", globalConfigPath)}`);
186409
+ lines.push(` kyoso.toml: ${formatLayer(loaded, "project_toml", projectTomlPath)}`);
186410
+ lines.push(` kyoso.config.ts: ${formatProjectTsLayer(loaded, projectTsPath)}`);
185087
186411
  lines.push(` trusted config: ${formatTrustStatus(loaded.configTrustStatus)}`);
185088
186412
  if (loaded.configHash)
185089
186413
  lines.push(` config hash: ${loaded.configHash}`);
@@ -185119,7 +186443,7 @@ async function runDoctor(options) {
185119
186443
  lines.push(` ${agent === "codex" ? "Codex" : "Claude"}: ${exists3 ? "ok" : "warning command not found"}`);
185120
186444
  lines.push(` command: ${[config2.command, ...config2.args].join(" ")}`);
185121
186445
  if (!exists3 && config2.command === "npx" && commandExists2("bunx", env)) {
185122
- lines.push(' hint: replace command "npx" with "bunx" in kyoso.config.ts');
186446
+ lines.push(' hint: set agents.<name>.command = "bunx" in config.toml');
185123
186447
  }
185124
186448
  if (agent === "claude") {
185125
186449
  const hasApiKey = hasEnv2(env, "ANTHROPIC_API_KEY");
@@ -185157,6 +186481,19 @@ async function runDoctor(options) {
185157
186481
  return lines.join(`
185158
186482
  `);
185159
186483
  }
186484
+ function formatLayer(loaded, layer, defaultPath) {
186485
+ const source = loaded.sources.find((candidate) => candidate.layer === layer);
186486
+ return source ? `found ${source.path}` : `not found ${defaultPath}`;
186487
+ }
186488
+ function formatProjectTsLayer(loaded, defaultPath) {
186489
+ const source = loaded.sources.find((candidate) => candidate.layer === "project_ts");
186490
+ if (source)
186491
+ return `found ${source.path} (deprecated)`;
186492
+ if (loaded.warnings.some((warning) => warning.includes("was ignored"))) {
186493
+ return `ignored ${defaultPath} (kyoso.toml takes precedence)`;
186494
+ }
186495
+ return `not found ${defaultPath}`;
186496
+ }
185160
186497
  function formatTrustStatus(status) {
185161
186498
  if (status === "trusted_by_flag")
185162
186499
  return "trusted by --trust-config";
@@ -185190,26 +186527,31 @@ function commandExists2(command, env) {
185190
186527
  }
185191
186528
 
185192
186529
  // src/cli/init.ts
185193
- import { readFile as readFile5, writeFile as writeFile4 } from "node:fs/promises";
185194
- import { join as join3 } from "node:path";
186530
+ import { access as access3, readFile as readFile6, writeFile as writeFile4 } from "node:fs/promises";
186531
+ import { join as join4 } from "node:path";
185195
186532
  async function runInit(options) {
185196
- const configPath = join3(options.cwd, "kyoso.config.ts");
185197
- const skillPath = join3(options.cwd, ".agents/skills/kyoso-review/SKILL.md");
185198
- const gitignorePath = join3(options.cwd, ".gitignore");
186533
+ const configPath = join4(options.cwd, "kyoso.toml");
186534
+ const tsConfigPath = join4(options.cwd, "kyoso.config.ts");
186535
+ const skillPath = join4(options.cwd, ".agents/skills/kyoso-review/SKILL.md");
186536
+ const gitignorePath = join4(options.cwd, ".gitignore");
185199
186537
  const configResult = await writeFileWithOverwritePrompt(configPath, CONFIG_TEMPLATE, options.force);
185200
186538
  const skillResult = await writeFileWithOverwritePrompt(skillPath, SKILL_TEMPLATE, options.force);
185201
186539
  const gitignoreResult = await ensureGitignoreEntry(gitignorePath, ".kyoso/");
185202
- return [
185203
- `kyoso.config.ts: ${configResult}`,
186540
+ const lines = [
186541
+ `kyoso.toml: ${configResult}`,
185204
186542
  `.agents/skills/kyoso-review/SKILL.md: ${skillResult}`,
185205
186543
  `.gitignore .kyoso/: ${gitignoreResult}`
185206
- ].join(`
186544
+ ];
186545
+ if (await exists3(tsConfigPath)) {
186546
+ lines.push("kyoso.config.ts: found deprecated config; kyoso.toml takes precedence");
186547
+ }
186548
+ return lines.join(`
185207
186549
  `);
185208
186550
  }
185209
186551
  async function ensureGitignoreEntry(path, entry) {
185210
186552
  let content = "";
185211
186553
  try {
185212
- content = await readFile5(path, "utf8");
186554
+ content = await readFile6(path, "utf8");
185213
186555
  } catch (error51) {
185214
186556
  if (!isMissingPathError3(error51))
185215
186557
  throw error51;
@@ -185230,13 +186572,19 @@ async function ensureGitignoreEntry(path, entry) {
185230
186572
  function isMissingPathError3(error51) {
185231
186573
  return typeof error51 === "object" && error51 !== null && "code" in error51 && error51.code === "ENOENT";
185232
186574
  }
185233
- var CONFIG_TEMPLATE = `import { defineConfig } from "@kyo-so/cli";
186575
+ async function exists3(path) {
186576
+ try {
186577
+ await access3(path);
186578
+ return true;
186579
+ } catch {
186580
+ return false;
186581
+ }
186582
+ }
186583
+ var CONFIG_TEMPLATE = `# Kyoso project config.
186584
+ # Project TOML is declarative and does not require trust approval.
185234
186585
 
185235
- export default defineConfig({
185236
- network: {
185237
- defaultMode: "model_only",
185238
- },
185239
- });
186586
+ [network]
186587
+ defaultMode = "model_only"
185240
186588
  `;
185241
186589
  var SKILL_TEMPLATE = `---
185242
186590
  name: kyoso-review
@@ -185424,10 +186772,10 @@ var require_code$1 = /* @__PURE__ */ __commonJSMin((exports) => {
185424
186772
  function interpolate(x) {
185425
186773
  return typeof x == "number" || typeof x == "boolean" || x === null ? x : safeStringify(Array.isArray(x) ? x.join(",") : x);
185426
186774
  }
185427
- function stringify(x) {
186775
+ function stringify2(x) {
185428
186776
  return new _Code(safeStringify(x));
185429
186777
  }
185430
- exports.stringify = stringify;
186778
+ exports.stringify = stringify2;
185431
186779
  function safeStringify(x) {
185432
186780
  return JSON.stringify(x).replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
185433
186781
  }
@@ -188133,7 +189481,7 @@ var require_compile = /* @__PURE__ */ __commonJSMin((exports) => {
188133
189481
  const schOrFunc = root.refs[ref];
188134
189482
  if (schOrFunc)
188135
189483
  return schOrFunc;
188136
- let _sch = resolve4.call(this, root, ref);
189484
+ let _sch = resolve5.call(this, root, ref);
188137
189485
  if (_sch === undefined) {
188138
189486
  const schema = (_a3 = root.localRefs) === null || _a3 === undefined ? undefined : _a3[ref];
188139
189487
  const { schemaId } = this.opts;
@@ -188164,7 +189512,7 @@ var require_compile = /* @__PURE__ */ __commonJSMin((exports) => {
188164
189512
  function sameSchemaEnv(s1, s2) {
188165
189513
  return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
188166
189514
  }
188167
- function resolve4(root, ref) {
189515
+ function resolve5(root, ref) {
188168
189516
  let sch;
188169
189517
  while (typeof (sch = this.refs[ref]) == "string")
188170
189518
  ref = sch;
@@ -188665,22 +190013,22 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin((exports, module) => {
188665
190013
  const { SCHEMES, getSchemeHandler } = require_schemes();
188666
190014
  function normalize(uri, options) {
188667
190015
  if (typeof uri === "string")
188668
- uri = serialize(parse5(uri, options), options);
190016
+ uri = serialize(parse6(uri, options), options);
188669
190017
  else if (typeof uri === "object")
188670
- uri = parse5(serialize(uri, options), options);
190018
+ uri = parse6(serialize(uri, options), options);
188671
190019
  return uri;
188672
190020
  }
188673
- function resolve4(baseURI, relativeURI, options) {
190021
+ function resolve5(baseURI, relativeURI, options) {
188674
190022
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
188675
- const resolved = resolveComponent(parse5(baseURI, schemelessOptions), parse5(relativeURI, schemelessOptions), schemelessOptions, true);
190023
+ const resolved = resolveComponent(parse6(baseURI, schemelessOptions), parse6(relativeURI, schemelessOptions), schemelessOptions, true);
188676
190024
  schemelessOptions.skipEscape = true;
188677
190025
  return serialize(resolved, schemelessOptions);
188678
190026
  }
188679
190027
  function resolveComponent(base, relative, options, skipNormalization) {
188680
190028
  const target = {};
188681
190029
  if (!skipNormalization) {
188682
- base = parse5(serialize(base, options), options);
188683
- relative = parse5(serialize(relative, options), options);
190030
+ base = parse6(serialize(base, options), options);
190031
+ relative = parse6(serialize(relative, options), options);
188684
190032
  }
188685
190033
  options = options || {};
188686
190034
  if (!options.tolerant && relative.scheme) {
@@ -188730,7 +190078,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin((exports, module) => {
188730
190078
  function equal(uriA, uriB, options) {
188731
190079
  if (typeof uriA === "string") {
188732
190080
  uriA = unescape(uriA);
188733
- uriA = serialize(normalizeComponentEncoding(parse5(uriA, options), true), {
190081
+ uriA = serialize(normalizeComponentEncoding(parse6(uriA, options), true), {
188734
190082
  ...options,
188735
190083
  skipEscape: true
188736
190084
  });
@@ -188741,7 +190089,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin((exports, module) => {
188741
190089
  });
188742
190090
  if (typeof uriB === "string") {
188743
190091
  uriB = unescape(uriB);
188744
- uriB = serialize(normalizeComponentEncoding(parse5(uriB, options), true), {
190092
+ uriB = serialize(normalizeComponentEncoding(parse6(uriB, options), true), {
188745
190093
  ...options,
188746
190094
  skipEscape: true
188747
190095
  });
@@ -188806,7 +190154,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin((exports, module) => {
188806
190154
  return uriTokens.join("");
188807
190155
  }
188808
190156
  const URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
188809
- function parse5(uri, opts) {
190157
+ function parse6(uri, opts) {
188810
190158
  const options = Object.assign({}, opts);
188811
190159
  const parsed = {
188812
190160
  scheme: undefined,
@@ -188881,11 +190229,11 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin((exports, module) => {
188881
190229
  const fastUri = {
188882
190230
  SCHEMES,
188883
190231
  normalize,
188884
- resolve: resolve4,
190232
+ resolve: resolve5,
188885
190233
  resolveComponent,
188886
190234
  equal,
188887
190235
  serialize,
188888
- parse: parse5
190236
+ parse: parse6
188889
190237
  };
188890
190238
  module.exports = fastUri;
188891
190239
  module.exports.default = fastUri;
@@ -196023,14 +197371,14 @@ function inputRequiredRoundsExceededMessage(method, maxRounds) {
196023
197371
  return `Multi-round-trip request '${method}' still required input after ${maxRounds} rounds (inputRequired.maxRounds)`;
196024
197372
  }
196025
197373
  function sleep(ms, signal) {
196026
- return new Promise((resolve4, reject) => {
197374
+ return new Promise((resolve5, reject) => {
196027
197375
  if (signal?.aborted) {
196028
197376
  reject(signal.reason instanceof SdkError ? signal.reason : new SdkError(SdkErrorCode.RequestTimeout, String(signal.reason)));
196029
197377
  return;
196030
197378
  }
196031
197379
  const timer = setTimeout(() => {
196032
197380
  signal?.removeEventListener("abort", onAbort);
196033
- resolve4();
197381
+ resolve5();
196034
197382
  }, ms);
196035
197383
  const onAbort = () => {
196036
197384
  clearTimeout(timer);
@@ -196792,7 +198140,7 @@ var Protocol = class {
196792
198140
  const flowStartedAt = Date.now();
196793
198141
  let onAbort;
196794
198142
  let cleanupMessageId;
196795
- return new Promise((resolve4, reject) => {
198143
+ return new Promise((resolve5, reject) => {
196796
198144
  const earlyReject = (error51) => {
196797
198145
  reject(error51);
196798
198146
  };
@@ -196868,7 +198216,7 @@ var Protocol = class {
196868
198216
  return reject(decoded.error);
196869
198217
  if (decoded.kind === "input_required") {
196870
198218
  if (options?.allowInputRequired === true)
196871
- return resolve4(manualInputRequiredValue(decoded));
198219
+ return resolve5(manualInputRequiredValue(decoded));
196872
198220
  const flow = {
196873
198221
  codec: codec2,
196874
198222
  request,
@@ -196880,12 +198228,12 @@ var Protocol = class {
196880
198228
  params
196881
198229
  }, resultSchema, legOptions)
196882
198230
  };
196883
- return resolve4(this._resolveNonCompleteResult(decoded, flow));
198231
+ return resolve5(this._resolveNonCompleteResult(decoded, flow));
196884
198232
  }
196885
198233
  const result = decoded.result;
196886
198234
  validateStandardSchema(resultSchema, result).then((parseResult) => {
196887
198235
  if (parseResult.success)
196888
- resolve4(parseResult.data);
198236
+ resolve5(parseResult.data);
196889
198237
  else
196890
198238
  reject(new SdkError(SdkErrorCode.InvalidResult, `Invalid result for ${request.method}: ${parseResult.error}`));
196891
198239
  }, reject);
@@ -198429,7 +199777,7 @@ var StdioServerTransport = class {
198429
199777
  send(message) {
198430
199778
  if (this._closed)
198431
199779
  return Promise.reject(/* @__PURE__ */ new Error("StdioServerTransport is closed"));
198432
- return new Promise((resolve4, reject) => {
199780
+ return new Promise((resolve5, reject) => {
198433
199781
  const json2 = serializeMessage(message);
198434
199782
  let settled = false;
198435
199783
  const onError = (error51) => {
@@ -198446,7 +199794,7 @@ var StdioServerTransport = class {
198446
199794
  settled = true;
198447
199795
  this._stdout.off("error", onError);
198448
199796
  this._stdout.off("drain", onDrain);
198449
- resolve4();
199797
+ resolve5();
198450
199798
  };
198451
199799
  this._stdout.once("error", onError);
198452
199800
  if (this._stdout.write(json2)) {
@@ -198454,7 +199802,7 @@ var StdioServerTransport = class {
198454
199802
  return;
198455
199803
  settled = true;
198456
199804
  this._stdout.off("error", onError);
198457
- resolve4();
199805
+ resolve5();
198458
199806
  } else if (!settled)
198459
199807
  this._stdout.once("drain", onDrain);
198460
199808
  });
@@ -198462,12 +199810,12 @@ var StdioServerTransport = class {
198462
199810
  };
198463
199811
 
198464
199812
  // src/core/runReview.ts
198465
- import { resolve as resolve5 } from "node:path";
199813
+ import { resolve as resolve6 } from "node:path";
198466
199814
 
198467
199815
  // src/acp/AcpAgentProcess.ts
198468
199816
  import { spawn } from "node:child_process";
198469
- import { readFile as readFile6, realpath } from "node:fs/promises";
198470
- import { isAbsolute, relative, resolve as resolve4 } from "node:path";
199817
+ import { readFile as readFile7, realpath } from "node:fs/promises";
199818
+ import { isAbsolute, relative, resolve as resolve5 } from "node:path";
198471
199819
  import { Readable, Writable } from "node:stream";
198472
199820
 
198473
199821
  // node_modules/@agentclientprotocol/sdk/dist/schema/index.js
@@ -200341,14 +201689,14 @@ function ndJsonStream(output2, input2) {
200341
201689
  }
200342
201690
  // node_modules/@agentclientprotocol/sdk/dist/jsonrpc.js
200343
201691
  var CANCEL_REQUEST_METHOD = "$/cancel_request";
200344
- function isRecord5(value) {
201692
+ function isRecord6(value) {
200345
201693
  return typeof value === "object" && value !== null;
200346
201694
  }
200347
201695
  function isJsonRpcId(value) {
200348
201696
  return value === null || typeof value === "string" || typeof value === "number" && Number.isFinite(value);
200349
201697
  }
200350
201698
  function cancelRequestId(params) {
200351
- if (!isRecord5(params) || !isJsonRpcId(params["requestId"])) {
201699
+ if (!isRecord6(params) || !isJsonRpcId(params["requestId"])) {
200352
201700
  return;
200353
201701
  }
200354
201702
  return params["requestId"];
@@ -200572,12 +201920,12 @@ class Connection {
200572
201920
  }
200573
201921
  const id = this.nextRequestId++;
200574
201922
  let cancel = () => {};
200575
- const responsePromise = new Promise((resolve4, reject) => {
201923
+ const responsePromise = new Promise((resolve5, reject) => {
200576
201924
  const pendingResponse = {
200577
201925
  resolve: (response) => {
200578
201926
  try {
200579
201927
  const value = mapResponse ? mapResponse(response) : response;
200580
- resolve4(value);
201928
+ resolve5(value);
200581
201929
  } catch (error51) {
200582
201930
  reject(error51);
200583
201931
  }
@@ -200642,8 +201990,8 @@ class Connection {
200642
201990
  initialize(stream, handlers) {
200643
201991
  this.stream = stream;
200644
201992
  this.staticHandlers = handlers;
200645
- this.closedPromise = new Promise((resolve4) => {
200646
- this.abortController.signal.addEventListener("abort", () => resolve4());
201993
+ this.closedPromise = new Promise((resolve5) => {
201994
+ this.abortController.signal.addEventListener("abort", () => resolve5());
200647
201995
  });
200648
201996
  this.receive();
200649
201997
  }
@@ -200850,25 +202198,25 @@ class ConnectionBuilder {
200850
202198
  describe: () => this.connectionName ?? "onReceiveMessage"
200851
202199
  });
200852
202200
  }
200853
- onReceiveRequest(method, parse5, handler) {
202201
+ onReceiveRequest(method, parse6, handler) {
200854
202202
  return this.withHandler({
200855
202203
  handleMessage: async (message, cx) => {
200856
202204
  if (message.kind !== "request" || message.method !== method) {
200857
202205
  return Handled.no(message);
200858
202206
  }
200859
- const request = parse5(message.params);
202207
+ const request = parse6(message.params);
200860
202208
  return await handler(request, message.responder, cx) ?? Handled.yes();
200861
202209
  },
200862
202210
  describe: () => `${this.connectionName ?? "request"}:${method}`
200863
202211
  });
200864
202212
  }
200865
- onReceiveNotification(method, parse5, handler) {
202213
+ onReceiveNotification(method, parse6, handler) {
200866
202214
  return this.withHandler({
200867
202215
  handleMessage: async (message, cx) => {
200868
202216
  if (message.kind !== "notification" || message.method !== method) {
200869
202217
  return Handled.no(message);
200870
202218
  }
200871
- const notification = parse5(message.params);
202219
+ const notification = parse6(message.params);
200872
202220
  return await handler(notification, cx) ?? Handled.yes();
200873
202221
  },
200874
202222
  describe: () => `${this.connectionName ?? "notification"}:${method}`
@@ -201218,8 +202566,8 @@ class AsyncQueue {
201218
202566
  if (this.failed) {
201219
202567
  return Promise.reject(this.failure);
201220
202568
  }
201221
- return new Promise((resolve4, reject) => {
201222
- this.waiters.push({ resolve: resolve4, reject });
202569
+ return new Promise((resolve5, reject) => {
202570
+ this.waiters.push({ resolve: resolve5, reject });
201223
202571
  });
201224
202572
  }
201225
202573
  }
@@ -201921,7 +203269,7 @@ function isSeverity(value) {
201921
203269
  return typeof value === "string" && severities.includes(value);
201922
203270
  }
201923
203271
  function normalizeCisaSecureByDesign(value) {
201924
- if (!isRecord6(value))
203272
+ if (!isRecord7(value))
201925
203273
  return;
201926
203274
  const normalized = {};
201927
203275
  const customerSecurityOutcomes = normalizeGateStatus(value.customerSecurityOutcomes);
@@ -201962,7 +203310,7 @@ function normalizeFindingFiles(value) {
201962
203310
  if (!Array.isArray(value))
201963
203311
  return;
201964
203312
  const files = value.flatMap((item) => {
201965
- if (!isRecord6(item) || typeof item.path !== "string" || item.path.trim().length === 0) {
203313
+ if (!isRecord7(item) || typeof item.path !== "string" || item.path.trim().length === 0) {
201966
203314
  return [];
201967
203315
  }
201968
203316
  const file2 = {
@@ -201981,7 +203329,7 @@ function normalizeFindingFiles(value) {
201981
203329
  function normalizeLineNumber(value) {
201982
203330
  return typeof value === "number" && Number.isSafeInteger(value) && value > 0 ? value : undefined;
201983
203331
  }
201984
- function isRecord6(value) {
203332
+ function isRecord7(value) {
201985
203333
  return typeof value === "object" && value !== null && !Array.isArray(value);
201986
203334
  }
201987
203335
 
@@ -202060,7 +203408,7 @@ async function runSubprocessAgent(agent, agentConfig, input2) {
202060
203408
  error: failure
202061
203409
  });
202062
203410
  });
202063
- runAcpClientWorkflow(child, input2, abortController.signal).then((rawText) => {
203411
+ runAcpClientWorkflow(child, input2, abortController.signal, resolveEffortConfigOption(agent, agentConfig.effort)).then(({ rawText, warnings }) => {
202064
203412
  stdout = rawText;
202065
203413
  resolveOnce({
202066
203414
  agent,
@@ -202069,7 +203417,8 @@ async function runSubprocessAgent(agent, agentConfig, input2) {
202069
203417
  rawText,
202070
203418
  normalized: normalizeAgentOutput(agent, input2.role, rawText),
202071
203419
  startedAt,
202072
- completedAt: new Date().toISOString()
203420
+ completedAt: new Date().toISOString(),
203421
+ ...warnings.length > 0 ? { warnings } : {}
202073
203422
  });
202074
203423
  }).catch((error51) => {
202075
203424
  if (abortController.signal.aborted)
@@ -202104,7 +203453,7 @@ async function runSubprocessAgent(agent, agentConfig, input2) {
202104
203453
  });
202105
203454
  });
202106
203455
  }
202107
- async function runAcpClientWorkflow(child, input2, signal) {
203456
+ async function runAcpClientWorkflow(child, input2, signal, configOption) {
202108
203457
  if (!child.stdin || !child.stdout) {
202109
203458
  throw new Error("Agent process did not expose stdio streams.");
202110
203459
  }
@@ -202152,15 +203501,36 @@ async function runAcpClientWorkflow(child, input2, signal) {
202152
203501
  kyosoReadOnly: true
202153
203502
  }
202154
203503
  }).withSession(async (session) => {
203504
+ const warnings = [];
203505
+ if (configOption) {
203506
+ await ctx.request(methods.agent.session.setConfigOption, { sessionId: session.sessionId, ...configOption }, { cancellationSignal: signal }).catch((error51) => {
203507
+ if (signal.aborted)
203508
+ return;
203509
+ const sanitizedValue = sanitizeTextForDisplay(configOption.value);
203510
+ const detail = sanitizeTextForDisplay(formatAgentErrorDetail(error51));
203511
+ const warning = `rejected effort config option (configId=${configOption.configId}, value=${sanitizedValue}); continuing without it: ${detail}`;
203512
+ warnings.push(warning);
203513
+ console.error(`kyoso: ${warning}`);
203514
+ });
203515
+ }
202155
203516
  const promptResponse = session.prompt(input2.prompt, {
202156
203517
  cancellationSignal: signal
202157
203518
  });
202158
203519
  const text = await session.readText();
202159
203520
  await promptResponse;
202160
- return text;
203521
+ return { rawText: text, warnings };
202161
203522
  });
202162
203523
  });
202163
203524
  }
203525
+ function resolveEffortConfigOption(agent, effort) {
203526
+ if (!effort)
203527
+ return;
203528
+ if (agent === "codex")
203529
+ return { configId: "reasoning_effort", value: effort };
203530
+ if (agent === "claude")
203531
+ return { configId: "effort", value: effort };
203532
+ return;
203533
+ }
202164
203534
  async function readWorkspaceFile(workspaceDir, requestedPath, line, limit) {
202165
203535
  const workspaceRoot = await realpath(workspaceDir);
202166
203536
  const candidates = resolveReadablePaths(workspaceRoot, requestedPath);
@@ -202169,7 +203539,7 @@ async function readWorkspaceFile(workspaceDir, requestedPath, line, limit) {
202169
203539
  const readablePath = await resolveReadableFile(workspaceRoot, absolute);
202170
203540
  if (!readablePath)
202171
203541
  continue;
202172
- content = await readFile6(readablePath, "utf8").catch(() => {
203542
+ content = await readFile7(readablePath, "utf8").catch(() => {
202173
203543
  return;
202174
203544
  });
202175
203545
  if (content !== undefined)
@@ -202196,13 +203566,13 @@ async function resolveReadableFile(workspaceRoot, absolute) {
202196
203566
  return realPath;
202197
203567
  }
202198
203568
  function resolveReadablePaths(workspaceRoot, requestedPath) {
202199
- const primary = resolve4(workspaceRoot, requestedPath);
203569
+ const primary = resolve5(workspaceRoot, requestedPath);
202200
203570
  assertWithinWorkspace(workspaceRoot, primary);
202201
203571
  const relativePath = relative(workspaceRoot, primary).replaceAll("\\", "/");
202202
203572
  if (relativePath.startsWith("context/") || relativePath.startsWith("repo/")) {
202203
203573
  return [primary];
202204
203574
  }
202205
- const repoPath = resolve4(workspaceRoot, "repo", relativePath);
203575
+ const repoPath = resolve5(workspaceRoot, "repo", relativePath);
202206
203576
  assertWithinWorkspace(workspaceRoot, repoPath);
202207
203577
  return isAbsolute(requestedPath) ? [primary, repoPath] : [repoPath, primary];
202208
203578
  }
@@ -202922,7 +204292,7 @@ function normalizeTitle(value) {
202922
204292
 
202923
204293
  // src/audit/trace.ts
202924
204294
  import { mkdir as mkdir4, appendFile } from "node:fs/promises";
202925
- import { dirname as dirname5, isAbsolute as isAbsolute2, join as join4 } from "node:path";
204295
+ import { dirname as dirname5, isAbsolute as isAbsolute2, join as join5 } from "node:path";
202926
204296
 
202927
204297
  // src/context/pathPolicy.ts
202928
204298
  import { normalize, sep } from "node:path";
@@ -203016,7 +204386,7 @@ function createTraceWriter(options) {
203016
204386
  }
203017
204387
  const date5 = new Date().toISOString().slice(0, 10);
203018
204388
  const directory = validateAuditDirectory(options.directory, warnings);
203019
- const tracePath = join4(options.cwd, directory, date5, `${options.traceId}.jsonl`);
204389
+ const tracePath = join5(options.cwd, directory, date5, `${options.traceId}.jsonl`);
203020
204390
  return {
203021
204391
  tracePath,
203022
204392
  warnings,
@@ -203197,6 +204567,10 @@ function renderMarkdownResult(tool, result, options = {}) {
203197
204567
  lines.push(...result.testsToAdd.length > 0 ? result.testsToAdd.map((test) => `- ${test}`) : ["- None."]);
203198
204568
  lines.push("", "## Residual Risks", "");
203199
204569
  lines.push(...result.residualRisks.length > 0 ? result.residualRisks.map((risk) => `- ${risk}`) : ["- None."]);
204570
+ if (result.audit.warnings && result.audit.warnings.length > 0) {
204571
+ lines.push("", "## Warnings", "");
204572
+ lines.push(...result.audit.warnings.map((warning) => `- ${escapeMarkdownText(warning)}`));
204573
+ }
203200
204574
  if (result.crossModelAnalysis) {
203201
204575
  lines.push("", "## Cross-Model Analysis", "");
203202
204576
  if (result.reviewMode === "single_agent") {
@@ -203261,6 +204635,9 @@ function formatVerification(finding) {
203261
204635
  function formatList(items) {
203262
204636
  return items.length > 0 ? items.map((item) => `- ${item}`) : ["- None."];
203263
204637
  }
204638
+ function escapeMarkdownText(value) {
204639
+ return value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replace(/[\r\n]+/g, " ").replace(/([\\`*_{}\[\]()#+!|])/g, "\\$1");
204640
+ }
203264
204641
 
203265
204642
  // src/security/recursionGuard.ts
203266
204643
  function assertNotChildAgent(env = process.env) {
@@ -203454,12 +204831,12 @@ function decide(input2) {
203454
204831
 
203455
204832
  // src/workspace/createSnapshot.ts
203456
204833
  import { chmod, mkdir as mkdir5, mkdtemp, writeFile as writeFile5 } from "node:fs/promises";
203457
- import { dirname as dirname6, join as join5 } from "node:path";
204834
+ import { dirname as dirname6, join as join6 } from "node:path";
203458
204835
  import { tmpdir } from "node:os";
203459
204836
  async function createSnapshot(traceId, tool, request, options = {}) {
203460
- const root = await mkdtemp(join5(tmpdir(), `kyoso-${traceId}-`));
203461
- const repoDir = join5(root, "repo");
203462
- const contextDir = join5(root, "context");
204837
+ const root = await mkdtemp(join6(tmpdir(), `kyoso-${traceId}-`));
204838
+ const repoDir = join6(root, "repo");
204839
+ const contextDir = join6(root, "context");
203463
204840
  await mkdir5(repoDir, { recursive: true });
203464
204841
  await mkdir5(contextDir, { recursive: true });
203465
204842
  let fileCount = 0;
@@ -203469,7 +204846,7 @@ async function createSnapshot(traceId, tool, request, options = {}) {
203469
204846
  continue;
203470
204847
  if (!isAllowedPath(relative2, options.allowPatterns ?? []))
203471
204848
  continue;
203472
- const dest = join5(repoDir, relative2);
204849
+ const dest = join6(repoDir, relative2);
203473
204850
  await mkdir5(dirname6(dest), { recursive: true });
203474
204851
  await writeFile5(dest, file2.content, "utf8");
203475
204852
  await chmod(dest, 292).catch(() => {
@@ -203477,16 +204854,16 @@ async function createSnapshot(traceId, tool, request, options = {}) {
203477
204854
  });
203478
204855
  fileCount += 1;
203479
204856
  }
203480
- await writeFile5(join5(contextDir, "request.json"), JSON.stringify(stripContents(request), null, 2), "utf8");
203481
- await writeFile5(join5(contextDir, "selected_files_manifest.json"), JSON.stringify(buildSelectedFilesManifest(request), null, 2), "utf8");
203482
- await writeFile5(join5(contextDir, "instructions.codex.md"), buildAgentPrompt(tool, request, "codex", options.agentRoles?.codex ?? "implementation_reviewer"), "utf8");
203483
- await writeFile5(join5(contextDir, "instructions.claude.md"), buildAgentPrompt(tool, request, "claude", options.agentRoles?.claude ?? "architecture_security_reviewer"), "utf8");
204857
+ await writeFile5(join6(contextDir, "request.json"), JSON.stringify(stripContents(request), null, 2), "utf8");
204858
+ await writeFile5(join6(contextDir, "selected_files_manifest.json"), JSON.stringify(buildSelectedFilesManifest(request), null, 2), "utf8");
204859
+ await writeFile5(join6(contextDir, "instructions.codex.md"), buildAgentPrompt(tool, request, "codex", options.agentRoles?.codex ?? "implementation_reviewer"), "utf8");
204860
+ await writeFile5(join6(contextDir, "instructions.claude.md"), buildAgentPrompt(tool, request, "claude", options.agentRoles?.claude ?? "architecture_security_reviewer"), "utf8");
203484
204861
  if (request.repoSummary)
203485
- await writeFile5(join5(contextDir, "repo_summary.md"), request.repoSummary, "utf8");
204862
+ await writeFile5(join6(contextDir, "repo_summary.md"), request.repoSummary, "utf8");
203486
204863
  if (request.currentPlan)
203487
- await writeFile5(join5(contextDir, "current_plan.md"), request.currentPlan, "utf8");
204864
+ await writeFile5(join6(contextDir, "current_plan.md"), request.currentPlan, "utf8");
203488
204865
  if (request.diff?.unifiedDiff)
203489
- await writeFile5(join5(contextDir, "diff.patch"), request.diff.unifiedDiff, "utf8");
204866
+ await writeFile5(join6(contextDir, "diff.patch"), request.diff.unifiedDiff, "utf8");
203490
204867
  return { root, repoDir, contextDir, fileCount };
203491
204868
  }
203492
204869
  function stripContents(request) {
@@ -203576,7 +204953,7 @@ function parseVerificationVerdicts(rawText) {
203576
204953
  if (!Array.isArray(parsed.verdicts))
203577
204954
  return;
203578
204955
  return parsed.verdicts.flatMap((item) => {
203579
- if (!isRecord7(item))
204956
+ if (!isRecord8(item))
203580
204957
  return [];
203581
204958
  if (typeof item.findingId !== "string")
203582
204959
  return [];
@@ -203654,7 +205031,7 @@ function verificationNote(reasoning) {
203654
205031
  function isVerdict(value) {
203655
205032
  return value === "confirmed" || value === "refuted" || value === "uncertain";
203656
205033
  }
203657
- function isRecord7(value) {
205034
+ function isRecord8(value) {
203658
205035
  return typeof value === "object" && value !== null && !Array.isArray(value);
203659
205036
  }
203660
205037
 
@@ -203707,14 +205084,17 @@ async function runReview(tool, request, options = {}) {
203707
205084
  config: options.config,
203708
205085
  configHash: options.configHash,
203709
205086
  configTrustStatus: "trusted",
205087
+ sources: [],
203710
205088
  warnings: []
203711
205089
  } : await loadConfig({
203712
205090
  cwd,
203713
205091
  configPath: options.configPath,
203714
205092
  ignoreConfig: options.ignoreConfig,
203715
205093
  trustConfig: options.trustConfig,
205094
+ allowUnknownConfig: options.allowUnknownConfig,
203716
205095
  promptForTrust: options.promptForTrust,
203717
205096
  trustStorePath: options.trustStorePath,
205097
+ env: options.env,
203718
205098
  trustPrompt: options.trustPrompt
203719
205099
  });
203720
205100
  const trace = createTraceWriter({
@@ -203737,6 +205117,7 @@ async function runReview(tool, request, options = {}) {
203737
205117
  traceId,
203738
205118
  configHash: loaded.configHash,
203739
205119
  configPath: loaded.configPath,
205120
+ configSources: loaded.sources,
203740
205121
  configTrustStatus: loaded.configTrustStatus,
203741
205122
  timestamp: new Date().toISOString()
203742
205123
  });
@@ -203803,6 +205184,7 @@ async function runReview(tool, request, options = {}) {
203803
205184
  manager,
203804
205185
  trace
203805
205186
  });
205187
+ warnings.push(...agentResults.flatMap((result2) => (result2.warnings ?? []).map((warning) => `Agent ${result2.agent} ${warning}`)));
203806
205188
  const normalizedAgentResults = agentResults.map(normalizeAgentRunResult);
203807
205189
  const agentsUsed = normalizedAgentResults.map((result2) => result2.agent);
203808
205190
  const reviewMode = agentsUsed.length === 1 ? "single_agent" : "multi_agent";
@@ -204285,7 +205667,7 @@ function mergeDenyPatterns(configDeny, requestDeny) {
204285
205667
  function assertTrustedWorkspaceRoot(requestRoot, configRoot, cwd) {
204286
205668
  if (!requestRoot)
204287
205669
  return;
204288
- if (resolve5(cwd, requestRoot) !== resolve5(cwd, configRoot)) {
205670
+ if (resolve6(cwd, requestRoot) !== resolve6(cwd, configRoot)) {
204289
205671
  throw new KyosoRequestError("workspace.root is not trusted by config", "UNTRUSTED_WORKSPACE_ROOT");
204290
205672
  }
204291
205673
  }
@@ -204368,6 +205750,7 @@ async function main() {
204368
205750
  const configPath = stringFlag(parsed.flags, "config");
204369
205751
  const ignoreConfig = booleanFlag(parsed.flags, "ignore-config");
204370
205752
  const trustConfig2 = booleanFlag(parsed.flags, "trust-config");
205753
+ const allowUnknownConfig = booleanFlag(parsed.flags, "allow-unknown-config");
204371
205754
  if (parsed.command === "mcp") {
204372
205755
  const network = networkFlag(parsed.flags);
204373
205756
  await startMcpServer({
@@ -204375,6 +205758,7 @@ async function main() {
204375
205758
  configPath,
204376
205759
  ignoreConfig,
204377
205760
  trustConfig: trustConfig2,
205761
+ allowUnknownConfig,
204378
205762
  mcpNetworkMode: network
204379
205763
  });
204380
205764
  return;
@@ -204385,6 +205769,7 @@ async function main() {
204385
205769
  configPath,
204386
205770
  ignoreConfig,
204387
205771
  trustConfig: trustConfig2,
205772
+ allowUnknownConfig,
204388
205773
  promptForTrust: canPromptForConfigTrust()
204389
205774
  }));
204390
205775
  return;
@@ -204412,6 +205797,7 @@ async function main() {
204412
205797
  configPath,
204413
205798
  ignoreConfig,
204414
205799
  trustConfig: trustConfig2,
205800
+ allowUnknownConfig,
204415
205801
  promptForTrust: canPromptForConfigTrust()
204416
205802
  });
204417
205803
  console.log(booleanFlag(parsed.flags, "json") ? JSON.stringify(result, null, 2) : result.summaryMarkdown);
@@ -204494,12 +205880,12 @@ function canPromptForConfigTrust() {
204494
205880
  var HELP = `Kyoso
204495
205881
 
204496
205882
  Usage:
204497
- kyoso mcp [--config kyoso.config.ts] [--ignore-config] [--trust-config] [--network model_only|unrestricted]
205883
+ kyoso mcp [--config kyoso.toml|kyoso.config.ts] [--ignore-config] [--trust-config] [--allow-unknown-config] [--network model_only|unrestricted]
204498
205884
  kyoso setup [codex|claude-code] [--write] [--runner npx|bunx] [--command <command>] [--global]
204499
- kyoso plan --goal <text> [--plan <path-or-text>] [--file <path>] [--json] [--trust-config]
204500
- kyoso security --goal <text> [--diff <path>] [--file <path>] [--allow-secret-redaction] [--trust-config]
204501
- kyoso diff --base main --head HEAD [--json] [--trust-config]
204502
- kyoso doctor [--trust-config]
205885
+ kyoso plan --goal <text> [--plan <path-or-text>] [--file <path>] [--json] [--trust-config] [--allow-unknown-config]
205886
+ kyoso security --goal <text> [--diff <path>] [--file <path>] [--allow-secret-redaction] [--trust-config] [--allow-unknown-config]
205887
+ kyoso diff --base main --head HEAD [--json] [--trust-config] [--allow-unknown-config]
205888
+ kyoso doctor [--trust-config] [--allow-unknown-config]
204503
205889
  kyoso init [--force]
204504
205890
  `;
204505
205891
  main().catch((error51) => {