@kyo-so/cli 0.5.0 → 0.6.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/CHANGELOG.md +29 -0
- package/README.ja.md +42 -23
- package/README.md +42 -23
- package/README.zh-CN.md +42 -23
- package/dist/bin/kyoso.js +1565 -204
- package/dist/cli/doctor.d.ts +1 -0
- package/dist/config/loadConfig.d.ts +8 -0
- package/dist/config/projectScope.d.ts +15 -0
- package/dist/config/schema.d.ts +3 -0
- package/dist/config/tomlConfigLoader.d.ts +1 -0
- package/dist/core/constants.d.ts +1 -1
- package/dist/index.js +1449 -121
- package/examples/claude-only.toml +2 -0
- package/examples/codex-only.toml +2 -0
- package/examples/kyoso.toml +11 -0
- package/package.json +2 -1
- package/examples/claude-only.config.ts +0 -9
- package/examples/codex-only.config.ts +0 -9
- package/examples/kyoso.config.ts +0 -22
package/dist/index.js
CHANGED
|
@@ -8124,7 +8124,7 @@ ${lanes.join(`
|
|
|
8124
8124
|
writeOutputIsTTY() {
|
|
8125
8125
|
return process.stdout.isTTY;
|
|
8126
8126
|
},
|
|
8127
|
-
readFile,
|
|
8127
|
+
readFile: readFile2,
|
|
8128
8128
|
writeFile: writeFile2,
|
|
8129
8129
|
watchFile: watchFile2,
|
|
8130
8130
|
watchDirectory,
|
|
@@ -8317,7 +8317,7 @@ ${lanes.join(`
|
|
|
8317
8317
|
function fsWatchWorker(fileOrDirectory, recursive, callback) {
|
|
8318
8318
|
return _fs.watch(fileOrDirectory, fsSupportsRecursiveFsWatch ? { persistent: true, recursive: !!recursive } : { persistent: true }, callback);
|
|
8319
8319
|
}
|
|
8320
|
-
function
|
|
8320
|
+
function readFile2(fileName, _encoding) {
|
|
8321
8321
|
let buffer;
|
|
8322
8322
|
try {
|
|
8323
8323
|
buffer = _fs.readFileSync(fileName);
|
|
@@ -39384,7 +39384,7 @@ ${lanes.join(`
|
|
|
39384
39384
|
const possibleOption = getSpellingSuggestion(unknownOption, diagnostics.optionDeclarations, getOptionName);
|
|
39385
39385
|
return possibleOption ? createDiagnosticForNodeInSourceFileOrCompilerDiagnostic(sourceFile, node, diagnostics.unknownDidYouMeanDiagnostic, unknownOptionErrorText || unknownOption, possibleOption.name) : createDiagnosticForNodeInSourceFileOrCompilerDiagnostic(sourceFile, node, diagnostics.unknownOptionDiagnostic, unknownOptionErrorText || unknownOption);
|
|
39386
39386
|
}
|
|
39387
|
-
function parseCommandLineWorker(diagnostics, commandLine,
|
|
39387
|
+
function parseCommandLineWorker(diagnostics, commandLine, readFile2) {
|
|
39388
39388
|
const options = {};
|
|
39389
39389
|
let watchOptions;
|
|
39390
39390
|
const fileNames = [];
|
|
@@ -39422,7 +39422,7 @@ ${lanes.join(`
|
|
|
39422
39422
|
}
|
|
39423
39423
|
}
|
|
39424
39424
|
function parseResponseFile(fileName) {
|
|
39425
|
-
const text = tryReadFile(fileName,
|
|
39425
|
+
const text = tryReadFile(fileName, readFile2 || ((fileName2) => sys.readFile(fileName2)));
|
|
39426
39426
|
if (!isString(text)) {
|
|
39427
39427
|
errors3.push(text);
|
|
39428
39428
|
return;
|
|
@@ -39525,8 +39525,8 @@ ${lanes.join(`
|
|
|
39525
39525
|
unknownDidYouMeanDiagnostic: Diagnostics.Unknown_compiler_option_0_Did_you_mean_1,
|
|
39526
39526
|
optionTypeMismatchDiagnostic: Diagnostics.Compiler_option_0_expects_an_argument
|
|
39527
39527
|
};
|
|
39528
|
-
function parseCommandLine(commandLine,
|
|
39529
|
-
return parseCommandLineWorker(compilerOptionsDidYouMeanDiagnostics, commandLine,
|
|
39528
|
+
function parseCommandLine(commandLine, readFile2) {
|
|
39529
|
+
return parseCommandLineWorker(compilerOptionsDidYouMeanDiagnostics, commandLine, readFile2);
|
|
39530
39530
|
}
|
|
39531
39531
|
function getOptionFromName(optionName, allowShort) {
|
|
39532
39532
|
return getOptionDeclarationFromName(getOptionsNameMap, optionName, allowShort);
|
|
@@ -39594,8 +39594,8 @@ ${lanes.join(`
|
|
|
39594
39594
|
result.originalFileName = result.fileName;
|
|
39595
39595
|
return parseJsonSourceFileConfigFileContent(result, host, getNormalizedAbsolutePath(getDirectoryPath(configFileName), cwd), optionsToExtend, getNormalizedAbsolutePath(configFileName, cwd), undefined, extraFileExtensions, extendedConfigCache, watchOptionsToExtend);
|
|
39596
39596
|
}
|
|
39597
|
-
function readConfigFile(fileName,
|
|
39598
|
-
const textOrDiagnostic = tryReadFile(fileName,
|
|
39597
|
+
function readConfigFile(fileName, readFile2) {
|
|
39598
|
+
const textOrDiagnostic = tryReadFile(fileName, readFile2);
|
|
39599
39599
|
return isString(textOrDiagnostic) ? parseConfigFileTextToJson(fileName, textOrDiagnostic) : { config: {}, error: textOrDiagnostic };
|
|
39600
39600
|
}
|
|
39601
39601
|
function parseConfigFileTextToJson(fileName, jsonText) {
|
|
@@ -39605,14 +39605,14 @@ ${lanes.join(`
|
|
|
39605
39605
|
error: jsonSourceFile.parseDiagnostics.length ? jsonSourceFile.parseDiagnostics[0] : undefined
|
|
39606
39606
|
};
|
|
39607
39607
|
}
|
|
39608
|
-
function readJsonConfigFile(fileName,
|
|
39609
|
-
const textOrDiagnostic = tryReadFile(fileName,
|
|
39608
|
+
function readJsonConfigFile(fileName, readFile2) {
|
|
39609
|
+
const textOrDiagnostic = tryReadFile(fileName, readFile2);
|
|
39610
39610
|
return isString(textOrDiagnostic) ? parseJsonText(fileName, textOrDiagnostic) : { fileName, parseDiagnostics: [textOrDiagnostic] };
|
|
39611
39611
|
}
|
|
39612
|
-
function tryReadFile(fileName,
|
|
39612
|
+
function tryReadFile(fileName, readFile2) {
|
|
39613
39613
|
let text;
|
|
39614
39614
|
try {
|
|
39615
|
-
text =
|
|
39615
|
+
text = readFile2(fileName);
|
|
39616
39616
|
} catch (e) {
|
|
39617
39617
|
return createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message);
|
|
39618
39618
|
}
|
|
@@ -107509,12 +107509,12 @@ ${lanes.join(`
|
|
|
107509
107509
|
function createCompilerHost(options, setParentNodes) {
|
|
107510
107510
|
return createCompilerHostWorker(options, setParentNodes);
|
|
107511
107511
|
}
|
|
107512
|
-
function createGetSourceFile(
|
|
107512
|
+
function createGetSourceFile(readFile2, setParentNodes) {
|
|
107513
107513
|
return (fileName, languageVersionOrOptions, onError) => {
|
|
107514
107514
|
let text;
|
|
107515
107515
|
try {
|
|
107516
107516
|
mark("beforeIORead");
|
|
107517
|
-
text =
|
|
107517
|
+
text = readFile2(fileName);
|
|
107518
107518
|
mark("afterIORead");
|
|
107519
107519
|
measure("I/O Read", "beforeIORead", "afterIORead");
|
|
107520
107520
|
} catch (e) {
|
|
@@ -108305,7 +108305,7 @@ ${lanes.join(`
|
|
|
108305
108305
|
getRedirectFromOutput,
|
|
108306
108306
|
forEachResolvedProjectReference: forEachResolvedProjectReference2
|
|
108307
108307
|
});
|
|
108308
|
-
const
|
|
108308
|
+
const readFile2 = host.readFile.bind(host);
|
|
108309
108309
|
(_e = tracing) == null || _e.push(tracing.Phase.Program, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram });
|
|
108310
108310
|
const shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options);
|
|
108311
108311
|
(_f = tracing) == null || _f.pop();
|
|
@@ -108482,7 +108482,7 @@ ${lanes.join(`
|
|
|
108482
108482
|
shouldTransformImportCall,
|
|
108483
108483
|
emitBuildInfo,
|
|
108484
108484
|
fileExists,
|
|
108485
|
-
readFile,
|
|
108485
|
+
readFile: readFile2,
|
|
108486
108486
|
directoryExists,
|
|
108487
108487
|
getSymlinkCache,
|
|
108488
108488
|
realpath: (_o = host.realpath) == null ? undefined : _o.bind(host),
|
|
@@ -121384,7 +121384,7 @@ ${lanes.join(`
|
|
|
121384
121384
|
if (importingFile !== usableByFileName)
|
|
121385
121385
|
return;
|
|
121386
121386
|
return forEachEntry(exportInfo, (info, key2) => {
|
|
121387
|
-
const { symbolName: symbolName2, ambientModuleName } =
|
|
121387
|
+
const { symbolName: symbolName2, ambientModuleName } = parseKey2(key2);
|
|
121388
121388
|
const name = preferCapitalized && info[0].capitalizedSymbolName || symbolName2;
|
|
121389
121389
|
if (matches(name, info[0].targetFlags)) {
|
|
121390
121390
|
const rehydrated = info.map(rehydrateCachedInfo);
|
|
@@ -121448,7 +121448,7 @@ ${lanes.join(`
|
|
|
121448
121448
|
const moduleKey = ambientModuleName || "";
|
|
121449
121449
|
return `${importedName.length} ${getSymbolId(skipAlias(symbol2, checker))} ${importedName} ${moduleKey}`;
|
|
121450
121450
|
}
|
|
121451
|
-
function
|
|
121451
|
+
function parseKey2(key2) {
|
|
121452
121452
|
const firstSpace = key2.indexOf(" ");
|
|
121453
121453
|
const secondSpace = key2.indexOf(" ", firstSpace + 1);
|
|
121454
121454
|
const symbolNameLength = parseInt(key2.substring(0, firstSpace), 10);
|
|
@@ -150512,14 +150512,14 @@ ${newComment.split(`
|
|
|
150512
150512
|
});
|
|
150513
150513
|
function mapCode(sourceFile, contents, focusLocations, host, formatContext, preferences) {
|
|
150514
150514
|
return ts_textChanges_exports.ChangeTracker.with({ host, formatContext, preferences }, (changeTracker) => {
|
|
150515
|
-
const parsed = contents.map((c) =>
|
|
150515
|
+
const parsed = contents.map((c) => parse6(sourceFile, c));
|
|
150516
150516
|
const flattenedLocations = focusLocations && flatten(focusLocations);
|
|
150517
150517
|
for (const nodes of parsed) {
|
|
150518
150518
|
placeNodeGroup(sourceFile, changeTracker, nodes, flattenedLocations);
|
|
150519
150519
|
}
|
|
150520
150520
|
});
|
|
150521
150521
|
}
|
|
150522
|
-
function
|
|
150522
|
+
function parse6(sourceFile, content) {
|
|
150523
150523
|
const nodeKinds = [
|
|
150524
150524
|
{
|
|
150525
150525
|
parse: () => createSourceFile("__mapcode_content_nodes.ts", content, sourceFile.languageVersion, true, sourceFile.scriptKind),
|
|
@@ -183863,6 +183863,79 @@ var kyosoConfigSchema = exports_external.object({
|
|
|
183863
183863
|
includeFileContents: exports_external.boolean()
|
|
183864
183864
|
})
|
|
183865
183865
|
});
|
|
183866
|
+
function agentConfigLeafPaths(agent) {
|
|
183867
|
+
return [
|
|
183868
|
+
`agents.${agent}.enabled`,
|
|
183869
|
+
`agents.${agent}.type`,
|
|
183870
|
+
`agents.${agent}.command`,
|
|
183871
|
+
`agents.${agent}.args`,
|
|
183872
|
+
`agents.${agent}.model`,
|
|
183873
|
+
`agents.${agent}.role`,
|
|
183874
|
+
`agents.${agent}.timeoutMs`,
|
|
183875
|
+
`agents.${agent}.env`,
|
|
183876
|
+
`agents.${agent}.auth.mode`,
|
|
183877
|
+
`agents.${agent}.auth.preferExistingLogin`,
|
|
183878
|
+
`agents.${agent}.auth.preferApiKey`,
|
|
183879
|
+
`agents.${agent}.auth.recommendedEnv`,
|
|
183880
|
+
`agents.${agent}.auth.envWhitelist`
|
|
183881
|
+
];
|
|
183882
|
+
}
|
|
183883
|
+
var kyosoConfigKnownLeafPaths = [
|
|
183884
|
+
"entrypoints.mcp",
|
|
183885
|
+
"entrypoints.cli",
|
|
183886
|
+
"firstClassClient",
|
|
183887
|
+
"tools.planReview",
|
|
183888
|
+
"tools.securityReview",
|
|
183889
|
+
"tools.diffReview",
|
|
183890
|
+
...agentConfigLeafPaths("codex"),
|
|
183891
|
+
...agentConfigLeafPaths("claude"),
|
|
183892
|
+
"workspace.mode",
|
|
183893
|
+
"workspace.root",
|
|
183894
|
+
"workspace.readOnly",
|
|
183895
|
+
"workspace.maxContextBytes",
|
|
183896
|
+
"workspace.maxDiffBytes",
|
|
183897
|
+
"workspace.deny",
|
|
183898
|
+
"secrets.mode",
|
|
183899
|
+
"secrets.blockOnDetectedSecret",
|
|
183900
|
+
"secrets.allowOverride",
|
|
183901
|
+
"network.defaultMode",
|
|
183902
|
+
"network.allowUnrestricted",
|
|
183903
|
+
"network.warnOnUnrestricted",
|
|
183904
|
+
"network.mediatedWeb.enabled",
|
|
183905
|
+
"securityReview.cisaSecureByDesign.enabled",
|
|
183906
|
+
"securityReview.cisaSecureByDesign.gate",
|
|
183907
|
+
"securityReview.cisaSecureByDesign.dimensions.customerSecurityOutcomes",
|
|
183908
|
+
"securityReview.cisaSecureByDesign.dimensions.secureByDefault",
|
|
183909
|
+
"securityReview.cisaSecureByDesign.dimensions.transparencyAndAccountability",
|
|
183910
|
+
"securityReview.cisaSecureByDesign.dimensions.governance",
|
|
183911
|
+
"judge.mode",
|
|
183912
|
+
"judge.provider",
|
|
183913
|
+
"judge.timeoutMs",
|
|
183914
|
+
"verification.enabled",
|
|
183915
|
+
"verification.maxFindings",
|
|
183916
|
+
"verification.timeoutMs",
|
|
183917
|
+
"verification.allowDemotion",
|
|
183918
|
+
"audit.enabled",
|
|
183919
|
+
"audit.format",
|
|
183920
|
+
"audit.directory",
|
|
183921
|
+
"audit.includeRawAgentOutput",
|
|
183922
|
+
"audit.includeFileContents"
|
|
183923
|
+
];
|
|
183924
|
+
var kyosoConfigRecordPrefixes = [
|
|
183925
|
+
"agents.codex.env",
|
|
183926
|
+
"agents.claude.env"
|
|
183927
|
+
];
|
|
183928
|
+
var kyosoConfigSecuritySensitivePrefixes = [
|
|
183929
|
+
"agents.codex",
|
|
183930
|
+
"agents.claude",
|
|
183931
|
+
"audit",
|
|
183932
|
+
"judge",
|
|
183933
|
+
"network",
|
|
183934
|
+
"secrets",
|
|
183935
|
+
"securityReview",
|
|
183936
|
+
"verification",
|
|
183937
|
+
"workspace"
|
|
183938
|
+
];
|
|
183866
183939
|
|
|
183867
183940
|
// src/config/defaultConfig.ts
|
|
183868
183941
|
var defaultConfig = {
|
|
@@ -183904,7 +183977,7 @@ var defaultConfig = {
|
|
|
183904
183977
|
command: "npx",
|
|
183905
183978
|
args: ["-y", "@agentclientprotocol/claude-agent-acp@0.57.0"],
|
|
183906
183979
|
role: "architecture_security_reviewer",
|
|
183907
|
-
timeoutMs:
|
|
183980
|
+
timeoutMs: 300000,
|
|
183908
183981
|
env: {
|
|
183909
183982
|
KYOSO_CHILD_AGENT: "1"
|
|
183910
183983
|
},
|
|
@@ -183993,11 +184066,1157 @@ var defaultConfig = {
|
|
|
183993
184066
|
};
|
|
183994
184067
|
|
|
183995
184068
|
// src/config/loadConfig.ts
|
|
183996
|
-
import { access, readFile as
|
|
184069
|
+
import { access, readFile as readFile3 } from "node:fs/promises";
|
|
184070
|
+
import { homedir as homedir2 } from "node:os";
|
|
183997
184071
|
import { stderr, stdin } from "node:process";
|
|
183998
|
-
import { resolve as resolve2 } from "node:path";
|
|
184072
|
+
import { extname as extname2, join as join2, resolve as resolve2 } from "node:path";
|
|
183999
184073
|
import { createInterface } from "node:readline/promises";
|
|
184000
184074
|
|
|
184075
|
+
// src/config/projectScope.ts
|
|
184076
|
+
var PROJECT_GLOBAL_ONLY_MESSAGE = "Move global-only settings to the user global config:";
|
|
184077
|
+
function mergeProjectTomlConfig(baseConfig, projectConfig, options) {
|
|
184078
|
+
const violations = collectProjectScopeViolations(projectConfig);
|
|
184079
|
+
if (violations.length > 0) {
|
|
184080
|
+
throw new Error(formatProjectScopeError(violations, options));
|
|
184081
|
+
}
|
|
184082
|
+
const projectDeny = readPath(projectConfig, ["workspace", "deny"]);
|
|
184083
|
+
const mergeableProjectConfig = omitPath(projectConfig, ["workspace", "deny"]);
|
|
184084
|
+
const merged = deepMerge(baseConfig, mergeableProjectConfig);
|
|
184085
|
+
if (projectDeny !== undefined) {
|
|
184086
|
+
writePath(merged, ["workspace", "deny"], Array.isArray(projectDeny) && allStrings(projectDeny) ? unionStrings(readStringArray(baseConfig, ["workspace", "deny"]), [
|
|
184087
|
+
...projectDeny
|
|
184088
|
+
]) : projectDeny);
|
|
184089
|
+
}
|
|
184090
|
+
return merged;
|
|
184091
|
+
}
|
|
184092
|
+
function collectProjectScopeViolations(config2) {
|
|
184093
|
+
const leaves = flattenLeaves(config2);
|
|
184094
|
+
const violations = [];
|
|
184095
|
+
for (const leaf of leaves) {
|
|
184096
|
+
const path = leaf.path.join(".");
|
|
184097
|
+
if (!isAllowedProjectPath(leaf.path)) {
|
|
184098
|
+
violations.push({ path });
|
|
184099
|
+
continue;
|
|
184100
|
+
}
|
|
184101
|
+
const reason = tightenOnlyReason(leaf.path, leaf.value);
|
|
184102
|
+
if (reason)
|
|
184103
|
+
violations.push({ path, reason });
|
|
184104
|
+
}
|
|
184105
|
+
return violations.sort((left, right) => left.path.localeCompare(right.path));
|
|
184106
|
+
}
|
|
184107
|
+
function isAllowedProjectPath(path) {
|
|
184108
|
+
const [top, second, third, fourth] = path;
|
|
184109
|
+
if (top === "tools" && path.length === 2 && ["planReview", "securityReview", "diffReview"].includes(second ?? "")) {
|
|
184110
|
+
return true;
|
|
184111
|
+
}
|
|
184112
|
+
if (top === "agents" && path.length === 3 && ["codex", "claude"].includes(second ?? "") && ["enabled", "model", "role", "timeoutMs"].includes(third ?? "")) {
|
|
184113
|
+
return true;
|
|
184114
|
+
}
|
|
184115
|
+
if (top === "verification" && path.length === 2 && ["enabled", "maxFindings", "timeoutMs"].includes(second ?? "")) {
|
|
184116
|
+
return true;
|
|
184117
|
+
}
|
|
184118
|
+
if (top === "workspace" && path.length === 2 && ["maxContextBytes", "maxDiffBytes", "deny"].includes(second ?? "")) {
|
|
184119
|
+
return true;
|
|
184120
|
+
}
|
|
184121
|
+
if (top === "network" && second === "defaultMode" && path.length === 2) {
|
|
184122
|
+
return true;
|
|
184123
|
+
}
|
|
184124
|
+
if (top === "secrets" && path.length === 2 && ["blockOnDetectedSecret", "allowOverride"].includes(second ?? "")) {
|
|
184125
|
+
return true;
|
|
184126
|
+
}
|
|
184127
|
+
if (top === "judge" && path.length === 2 && ["mode", "provider", "timeoutMs"].includes(second ?? "")) {
|
|
184128
|
+
return true;
|
|
184129
|
+
}
|
|
184130
|
+
if (top === "securityReview" && second === "cisaSecureByDesign" && path.length >= 3) {
|
|
184131
|
+
if (third === "dimensions") {
|
|
184132
|
+
return path.length === 4 && [
|
|
184133
|
+
"customerSecurityOutcomes",
|
|
184134
|
+
"secureByDefault",
|
|
184135
|
+
"transparencyAndAccountability",
|
|
184136
|
+
"governance"
|
|
184137
|
+
].includes(fourth ?? "");
|
|
184138
|
+
}
|
|
184139
|
+
return path.length === 3 && ["enabled", "gate"].includes(third ?? "");
|
|
184140
|
+
}
|
|
184141
|
+
return false;
|
|
184142
|
+
}
|
|
184143
|
+
function tightenOnlyReason(path, value) {
|
|
184144
|
+
const dotted = path.join(".");
|
|
184145
|
+
if (dotted === "network.defaultMode" && value !== "model_only") {
|
|
184146
|
+
return 'must be "model_only" in project TOML';
|
|
184147
|
+
}
|
|
184148
|
+
if (dotted === "secrets.blockOnDetectedSecret" && value !== true) {
|
|
184149
|
+
return "must be true in project TOML";
|
|
184150
|
+
}
|
|
184151
|
+
if (dotted === "secrets.allowOverride" && value !== false) {
|
|
184152
|
+
return "must be false in project TOML";
|
|
184153
|
+
}
|
|
184154
|
+
if (path[0] === "securityReview" && path[1] === "cisaSecureByDesign" && value !== true) {
|
|
184155
|
+
return "must be true in project TOML";
|
|
184156
|
+
}
|
|
184157
|
+
return;
|
|
184158
|
+
}
|
|
184159
|
+
function formatProjectScopeError(violations, options) {
|
|
184160
|
+
const entries = violations.map((violation) => violation.reason ? `${violation.path} (${violation.reason})` : violation.path);
|
|
184161
|
+
return [
|
|
184162
|
+
`Project TOML config ${options.projectPath} contains settings that are not allowed in project scope: ${entries.join(", ")}`,
|
|
184163
|
+
`${PROJECT_GLOBAL_ONLY_MESSAGE} ${options.globalConfigPath}. If a key is misspelled, fix the name instead.`
|
|
184164
|
+
].join(`
|
|
184165
|
+
`);
|
|
184166
|
+
}
|
|
184167
|
+
function flattenLeaves(value, path = []) {
|
|
184168
|
+
if (!isRecord(value))
|
|
184169
|
+
return path.length > 0 ? [{ path, value }] : [];
|
|
184170
|
+
const entries = Object.entries(value);
|
|
184171
|
+
if (entries.length === 0)
|
|
184172
|
+
return path.length > 0 ? [{ path, value }] : [];
|
|
184173
|
+
return entries.flatMap(([key, child]) => flattenLeaves(child, [...path, key]));
|
|
184174
|
+
}
|
|
184175
|
+
function omitPath(value, path) {
|
|
184176
|
+
if (!isRecord(value) || path.length === 0)
|
|
184177
|
+
return value;
|
|
184178
|
+
const [head, ...tail] = path;
|
|
184179
|
+
if (head === undefined)
|
|
184180
|
+
return value;
|
|
184181
|
+
const result = { ...value };
|
|
184182
|
+
if (tail.length === 0) {
|
|
184183
|
+
delete result[head];
|
|
184184
|
+
} else {
|
|
184185
|
+
const child = omitPath(result[head], tail);
|
|
184186
|
+
if (isRecord(child) && Object.keys(child).length === 0) {
|
|
184187
|
+
delete result[head];
|
|
184188
|
+
} else {
|
|
184189
|
+
result[head] = child;
|
|
184190
|
+
}
|
|
184191
|
+
}
|
|
184192
|
+
return result;
|
|
184193
|
+
}
|
|
184194
|
+
function readPath(value, path) {
|
|
184195
|
+
let current = value;
|
|
184196
|
+
for (const key of path) {
|
|
184197
|
+
if (!isRecord(current))
|
|
184198
|
+
return;
|
|
184199
|
+
current = current[key];
|
|
184200
|
+
}
|
|
184201
|
+
return current;
|
|
184202
|
+
}
|
|
184203
|
+
function writePath(target, path, value) {
|
|
184204
|
+
if (!isRecord(target))
|
|
184205
|
+
return;
|
|
184206
|
+
let current = target;
|
|
184207
|
+
for (const key of path.slice(0, -1)) {
|
|
184208
|
+
const child = current[key];
|
|
184209
|
+
if (!isRecord(child)) {
|
|
184210
|
+
current[key] = {};
|
|
184211
|
+
}
|
|
184212
|
+
current = current[key];
|
|
184213
|
+
}
|
|
184214
|
+
const leaf = path.at(-1);
|
|
184215
|
+
if (leaf)
|
|
184216
|
+
current[leaf] = value;
|
|
184217
|
+
}
|
|
184218
|
+
function readStringArray(value, path) {
|
|
184219
|
+
const found = readPath(value, path);
|
|
184220
|
+
return Array.isArray(found) && allStrings(found) ? [...found] : [];
|
|
184221
|
+
}
|
|
184222
|
+
function unionStrings(base, override) {
|
|
184223
|
+
return [...new Set([...base, ...override])];
|
|
184224
|
+
}
|
|
184225
|
+
function allStrings(values) {
|
|
184226
|
+
return values.every((value) => typeof value === "string");
|
|
184227
|
+
}
|
|
184228
|
+
function deepMerge(base, override) {
|
|
184229
|
+
if (!isRecord(base) || !isRecord(override))
|
|
184230
|
+
return override ?? base;
|
|
184231
|
+
const result = { ...base };
|
|
184232
|
+
for (const [key, value] of Object.entries(override)) {
|
|
184233
|
+
result[key] = deepMerge(result[key], value);
|
|
184234
|
+
}
|
|
184235
|
+
return result;
|
|
184236
|
+
}
|
|
184237
|
+
function isRecord(value) {
|
|
184238
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
184239
|
+
}
|
|
184240
|
+
|
|
184241
|
+
// src/security/redact.ts
|
|
184242
|
+
var REDACTION = "[KYOSO_REDACTED]";
|
|
184243
|
+
|
|
184244
|
+
// src/core/constants.ts
|
|
184245
|
+
var DEFAULT_AGENT_TIMEOUT_MS = 120000;
|
|
184246
|
+
var RAW_OUTPUT_MAX_CHARS = 16384;
|
|
184247
|
+
var KYOSO_CHILD_AGENT = "KYOSO_CHILD_AGENT";
|
|
184248
|
+
|
|
184249
|
+
// src/security/sanitizeText.ts
|
|
184250
|
+
var SENSITIVE_TEXT_PATTERNS = [
|
|
184251
|
+
/\bsk-(?:proj-)?[A-Za-z0-9_-]{8,}\b/g,
|
|
184252
|
+
/\bsk-ant-[A-Za-z0-9_-]{8,}\b/g,
|
|
184253
|
+
/\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9_]{8,}\b/g,
|
|
184254
|
+
/\bAKIA[0-9A-Z]{8,}\b/g,
|
|
184255
|
+
/\bxox[baprs]-[A-Za-z0-9-]{8,}\b/g,
|
|
184256
|
+
/\bsk_(?:live|test)_[A-Za-z0-9]{8,}\b/g,
|
|
184257
|
+
/\b(?:api[_-]?key|secret|token|password)\b\s*[:=]\s*["']?[A-Za-z0-9_./+=-]{8,}["']?/gi
|
|
184258
|
+
];
|
|
184259
|
+
function sanitizeText(value) {
|
|
184260
|
+
return SENSITIVE_TEXT_PATTERNS.reduce((text, pattern) => text.replace(pattern, REDACTION), value);
|
|
184261
|
+
}
|
|
184262
|
+
function sanitizeTextForDisplay(value, maxChars = 240) {
|
|
184263
|
+
const compact = sanitizeText(value).replace(/\s+/g, " ").trim();
|
|
184264
|
+
if (compact.length <= maxChars)
|
|
184265
|
+
return compact;
|
|
184266
|
+
return `${compact.slice(0, Math.max(0, maxChars - 3))}...`;
|
|
184267
|
+
}
|
|
184268
|
+
function sanitizeTextForRawOutput(value, maxChars = RAW_OUTPUT_MAX_CHARS) {
|
|
184269
|
+
const sanitized = sanitizeText(value);
|
|
184270
|
+
const limit = Math.max(0, maxChars);
|
|
184271
|
+
if (sanitized.length <= limit)
|
|
184272
|
+
return sanitized;
|
|
184273
|
+
return `${sanitized.slice(0, limit)}
|
|
184274
|
+
[KYOSO_TRUNCATED: ${sanitized.length - limit} chars omitted]`;
|
|
184275
|
+
}
|
|
184276
|
+
|
|
184277
|
+
// src/config/tomlConfigLoader.ts
|
|
184278
|
+
import { readFile } from "node:fs/promises";
|
|
184279
|
+
|
|
184280
|
+
// node_modules/smol-toml/dist/date.js
|
|
184281
|
+
/*!
|
|
184282
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
184283
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
184284
|
+
*
|
|
184285
|
+
* Redistribution and use in source and binary forms, with or without
|
|
184286
|
+
* modification, are permitted provided that the following conditions are met:
|
|
184287
|
+
*
|
|
184288
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
184289
|
+
* list of conditions and the following disclaimer.
|
|
184290
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
184291
|
+
* this list of conditions and the following disclaimer in the
|
|
184292
|
+
* documentation and/or other materials provided with the distribution.
|
|
184293
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
184294
|
+
* may be used to endorse or promote products derived from this software without
|
|
184295
|
+
* specific prior written permission.
|
|
184296
|
+
*
|
|
184297
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
184298
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
184299
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
184300
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
184301
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
184302
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
184303
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
184304
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
184305
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
184306
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
184307
|
+
*/
|
|
184308
|
+
var DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;
|
|
184309
|
+
|
|
184310
|
+
class TomlDate extends Date {
|
|
184311
|
+
#hasDate = false;
|
|
184312
|
+
#hasTime = false;
|
|
184313
|
+
#offset = null;
|
|
184314
|
+
constructor(date5) {
|
|
184315
|
+
let hasDate = true;
|
|
184316
|
+
let hasTime = true;
|
|
184317
|
+
let offset = "Z";
|
|
184318
|
+
if (typeof date5 === "string") {
|
|
184319
|
+
let match = date5.match(DATE_TIME_RE);
|
|
184320
|
+
if (match) {
|
|
184321
|
+
if (!match[1]) {
|
|
184322
|
+
hasDate = false;
|
|
184323
|
+
date5 = `0000-01-01T${date5}`;
|
|
184324
|
+
}
|
|
184325
|
+
hasTime = !!match[2];
|
|
184326
|
+
hasTime && date5[10] === " " && (date5 = date5.replace(" ", "T"));
|
|
184327
|
+
if (match[2] && +match[2] > 23) {
|
|
184328
|
+
date5 = "";
|
|
184329
|
+
} else {
|
|
184330
|
+
offset = match[3] || null;
|
|
184331
|
+
date5 = date5.toUpperCase();
|
|
184332
|
+
if (!offset && hasTime)
|
|
184333
|
+
date5 += "Z";
|
|
184334
|
+
}
|
|
184335
|
+
} else {
|
|
184336
|
+
date5 = "";
|
|
184337
|
+
}
|
|
184338
|
+
}
|
|
184339
|
+
super(date5);
|
|
184340
|
+
if (!isNaN(this.getTime())) {
|
|
184341
|
+
this.#hasDate = hasDate;
|
|
184342
|
+
this.#hasTime = hasTime;
|
|
184343
|
+
this.#offset = offset;
|
|
184344
|
+
}
|
|
184345
|
+
}
|
|
184346
|
+
isDateTime() {
|
|
184347
|
+
return this.#hasDate && this.#hasTime;
|
|
184348
|
+
}
|
|
184349
|
+
isLocal() {
|
|
184350
|
+
return !this.#hasDate || !this.#hasTime || !this.#offset;
|
|
184351
|
+
}
|
|
184352
|
+
isDate() {
|
|
184353
|
+
return this.#hasDate && !this.#hasTime;
|
|
184354
|
+
}
|
|
184355
|
+
isTime() {
|
|
184356
|
+
return this.#hasTime && !this.#hasDate;
|
|
184357
|
+
}
|
|
184358
|
+
isValid() {
|
|
184359
|
+
return this.#hasDate || this.#hasTime;
|
|
184360
|
+
}
|
|
184361
|
+
toISOString() {
|
|
184362
|
+
let iso = super.toISOString();
|
|
184363
|
+
if (this.isDate())
|
|
184364
|
+
return iso.slice(0, 10);
|
|
184365
|
+
if (this.isTime())
|
|
184366
|
+
return iso.slice(11, 23);
|
|
184367
|
+
if (this.#offset === null)
|
|
184368
|
+
return iso.slice(0, -1);
|
|
184369
|
+
if (this.#offset === "Z")
|
|
184370
|
+
return iso;
|
|
184371
|
+
let offset = +this.#offset.slice(1, 3) * 60 + +this.#offset.slice(4, 6);
|
|
184372
|
+
offset = this.#offset[0] === "-" ? offset : -offset;
|
|
184373
|
+
let offsetDate = new Date(this.getTime() - offset * 60000);
|
|
184374
|
+
return offsetDate.toISOString().slice(0, -1) + this.#offset;
|
|
184375
|
+
}
|
|
184376
|
+
static wrapAsOffsetDateTime(jsDate, offset = "Z") {
|
|
184377
|
+
let date5 = new TomlDate(jsDate);
|
|
184378
|
+
date5.#offset = offset;
|
|
184379
|
+
return date5;
|
|
184380
|
+
}
|
|
184381
|
+
static wrapAsLocalDateTime(jsDate) {
|
|
184382
|
+
let date5 = new TomlDate(jsDate);
|
|
184383
|
+
date5.#offset = null;
|
|
184384
|
+
return date5;
|
|
184385
|
+
}
|
|
184386
|
+
static wrapAsLocalDate(jsDate) {
|
|
184387
|
+
let date5 = new TomlDate(jsDate);
|
|
184388
|
+
date5.#hasTime = false;
|
|
184389
|
+
date5.#offset = null;
|
|
184390
|
+
return date5;
|
|
184391
|
+
}
|
|
184392
|
+
static wrapAsLocalTime(jsDate) {
|
|
184393
|
+
let date5 = new TomlDate(jsDate);
|
|
184394
|
+
date5.#hasDate = false;
|
|
184395
|
+
date5.#offset = null;
|
|
184396
|
+
return date5;
|
|
184397
|
+
}
|
|
184398
|
+
}
|
|
184399
|
+
|
|
184400
|
+
// node_modules/smol-toml/dist/error.js
|
|
184401
|
+
/*!
|
|
184402
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
184403
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
184404
|
+
*
|
|
184405
|
+
* Redistribution and use in source and binary forms, with or without
|
|
184406
|
+
* modification, are permitted provided that the following conditions are met:
|
|
184407
|
+
*
|
|
184408
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
184409
|
+
* list of conditions and the following disclaimer.
|
|
184410
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
184411
|
+
* this list of conditions and the following disclaimer in the
|
|
184412
|
+
* documentation and/or other materials provided with the distribution.
|
|
184413
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
184414
|
+
* may be used to endorse or promote products derived from this software without
|
|
184415
|
+
* specific prior written permission.
|
|
184416
|
+
*
|
|
184417
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
184418
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
184419
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
184420
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
184421
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
184422
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
184423
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
184424
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
184425
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
184426
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
184427
|
+
*/
|
|
184428
|
+
function getLineColFromPtr(string4, ptr) {
|
|
184429
|
+
let lines = string4.slice(0, ptr).split(/\r\n|\n|\r/g);
|
|
184430
|
+
return [lines.length, lines.pop().length + 1];
|
|
184431
|
+
}
|
|
184432
|
+
function makeCodeBlock(string4, line, column) {
|
|
184433
|
+
let lines = string4.split(/\r\n|\n|\r/g);
|
|
184434
|
+
let codeblock = "";
|
|
184435
|
+
let numberLen = (Math.log10(line + 1) | 0) + 1;
|
|
184436
|
+
for (let i = line - 1;i <= line + 1; i++) {
|
|
184437
|
+
let l = lines[i - 1];
|
|
184438
|
+
if (!l)
|
|
184439
|
+
continue;
|
|
184440
|
+
codeblock += i.toString().padEnd(numberLen, " ");
|
|
184441
|
+
codeblock += ": ";
|
|
184442
|
+
codeblock += l;
|
|
184443
|
+
codeblock += `
|
|
184444
|
+
`;
|
|
184445
|
+
if (i === line) {
|
|
184446
|
+
codeblock += " ".repeat(numberLen + column + 2);
|
|
184447
|
+
codeblock += `^
|
|
184448
|
+
`;
|
|
184449
|
+
}
|
|
184450
|
+
}
|
|
184451
|
+
return codeblock;
|
|
184452
|
+
}
|
|
184453
|
+
|
|
184454
|
+
class TomlError extends Error {
|
|
184455
|
+
line;
|
|
184456
|
+
column;
|
|
184457
|
+
codeblock;
|
|
184458
|
+
constructor(message, options) {
|
|
184459
|
+
const [line, column] = getLineColFromPtr(options.toml, options.ptr);
|
|
184460
|
+
const codeblock = makeCodeBlock(options.toml, line, column);
|
|
184461
|
+
super(`Invalid TOML document: ${message}
|
|
184462
|
+
|
|
184463
|
+
${codeblock}`, options);
|
|
184464
|
+
this.line = line;
|
|
184465
|
+
this.column = column;
|
|
184466
|
+
this.codeblock = codeblock;
|
|
184467
|
+
}
|
|
184468
|
+
}
|
|
184469
|
+
|
|
184470
|
+
// node_modules/smol-toml/dist/primitive.js
|
|
184471
|
+
/*!
|
|
184472
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
184473
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
184474
|
+
*
|
|
184475
|
+
* Redistribution and use in source and binary forms, with or without
|
|
184476
|
+
* modification, are permitted provided that the following conditions are met:
|
|
184477
|
+
*
|
|
184478
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
184479
|
+
* list of conditions and the following disclaimer.
|
|
184480
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
184481
|
+
* this list of conditions and the following disclaimer in the
|
|
184482
|
+
* documentation and/or other materials provided with the distribution.
|
|
184483
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
184484
|
+
* may be used to endorse or promote products derived from this software without
|
|
184485
|
+
* specific prior written permission.
|
|
184486
|
+
*
|
|
184487
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
184488
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
184489
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
184490
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
184491
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
184492
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
184493
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
184494
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
184495
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
184496
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
184497
|
+
*/
|
|
184498
|
+
var INT_REGEX = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/;
|
|
184499
|
+
var FLOAT_REGEX = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/;
|
|
184500
|
+
var LEADING_ZERO = /^[+-]?0[0-9_]/;
|
|
184501
|
+
function parseString(str, ptr) {
|
|
184502
|
+
let c = str[ptr++];
|
|
184503
|
+
let first = c;
|
|
184504
|
+
let isLiteral = c === "'";
|
|
184505
|
+
let isMultiline = c === str[ptr] && c === str[ptr + 1];
|
|
184506
|
+
if (isMultiline) {
|
|
184507
|
+
if (str[ptr += 2] === `
|
|
184508
|
+
`)
|
|
184509
|
+
ptr++;
|
|
184510
|
+
else if (str[ptr] === "\r" && str[ptr + 1] === `
|
|
184511
|
+
`)
|
|
184512
|
+
ptr += 2;
|
|
184513
|
+
}
|
|
184514
|
+
let parsed = "";
|
|
184515
|
+
let sliceStart = ptr;
|
|
184516
|
+
let state = 0;
|
|
184517
|
+
for (let i = ptr;i < str.length; i++) {
|
|
184518
|
+
c = str[i];
|
|
184519
|
+
if (isMultiline && (c === `
|
|
184520
|
+
` || c === "\r" && str[i + 1] === `
|
|
184521
|
+
`)) {
|
|
184522
|
+
state = state && 3;
|
|
184523
|
+
} else if (c < " " && c !== "\t" || c === "") {
|
|
184524
|
+
throw new TomlError("control characters are not allowed in strings", {
|
|
184525
|
+
toml: str,
|
|
184526
|
+
ptr: i
|
|
184527
|
+
});
|
|
184528
|
+
} else if ((!state || state === 3) && c === first && (!isMultiline || str[i + 1] === first && str[i + 2] === first)) {
|
|
184529
|
+
if (isMultiline) {
|
|
184530
|
+
if (str[i + 3] === first)
|
|
184531
|
+
i++;
|
|
184532
|
+
if (str[i + 3] === first)
|
|
184533
|
+
i++;
|
|
184534
|
+
}
|
|
184535
|
+
return [
|
|
184536
|
+
state ? parsed : parsed + str.slice(sliceStart, i),
|
|
184537
|
+
i + (isMultiline ? 3 : 1)
|
|
184538
|
+
];
|
|
184539
|
+
} else if (!state) {
|
|
184540
|
+
if (!isLiteral && c === "\\") {
|
|
184541
|
+
parsed += str.slice(sliceStart, sliceStart = i);
|
|
184542
|
+
state = 1;
|
|
184543
|
+
}
|
|
184544
|
+
} else if (state === 1) {
|
|
184545
|
+
if (c === "x" || c === "u" || c === "U") {
|
|
184546
|
+
let value = 0;
|
|
184547
|
+
let len = c === "x" ? 2 : c === "u" ? 4 : 8;
|
|
184548
|
+
for (let j = 0;j < len; j++, i++) {
|
|
184549
|
+
let hex3 = str.charCodeAt(i + 1);
|
|
184550
|
+
let digit = hex3 >= 48 && hex3 <= 57 ? hex3 - 48 : hex3 >= 65 && hex3 <= 70 ? hex3 - 65 + 10 : hex3 >= 97 && hex3 <= 102 ? hex3 - 97 + 10 : -1;
|
|
184551
|
+
if (digit < 0)
|
|
184552
|
+
throw new TomlError("invalid non-hex character in unicode escape", { toml: str, ptr: i + 1 });
|
|
184553
|
+
value = value << 4 | digit;
|
|
184554
|
+
}
|
|
184555
|
+
if (value < 0 || value > 1114111 || value >= 55296 && value <= 57343) {
|
|
184556
|
+
throw new TomlError("invalid unicode escape", { toml: str, ptr: i });
|
|
184557
|
+
}
|
|
184558
|
+
parsed += String.fromCodePoint(value);
|
|
184559
|
+
sliceStart = i + 1;
|
|
184560
|
+
state = 0;
|
|
184561
|
+
} else if (c === " " || c === "\t") {
|
|
184562
|
+
state = 2;
|
|
184563
|
+
} else {
|
|
184564
|
+
if (c === "b")
|
|
184565
|
+
parsed += "\b";
|
|
184566
|
+
else if (c === "t")
|
|
184567
|
+
parsed += "\t";
|
|
184568
|
+
else if (c === "n")
|
|
184569
|
+
parsed += `
|
|
184570
|
+
`;
|
|
184571
|
+
else if (c === "f")
|
|
184572
|
+
parsed += "\f";
|
|
184573
|
+
else if (c === "r")
|
|
184574
|
+
parsed += "\r";
|
|
184575
|
+
else if (c === "e")
|
|
184576
|
+
parsed += "\x1B";
|
|
184577
|
+
else if (c === '"')
|
|
184578
|
+
parsed += '"';
|
|
184579
|
+
else if (c === "\\")
|
|
184580
|
+
parsed += "\\";
|
|
184581
|
+
else
|
|
184582
|
+
throw new TomlError("unrecognized escape sequence", { toml: str, ptr: i });
|
|
184583
|
+
sliceStart = i + 1;
|
|
184584
|
+
state = 0;
|
|
184585
|
+
}
|
|
184586
|
+
} else if (c !== " " && c !== "\t") {
|
|
184587
|
+
if (state === 2) {
|
|
184588
|
+
throw new TomlError("invalid escape: only line-ending whitespace may be escaped", {
|
|
184589
|
+
toml: str,
|
|
184590
|
+
ptr: sliceStart
|
|
184591
|
+
});
|
|
184592
|
+
}
|
|
184593
|
+
state = !isLiteral && c === "\\" ? 1 : 0;
|
|
184594
|
+
sliceStart = i;
|
|
184595
|
+
}
|
|
184596
|
+
}
|
|
184597
|
+
throw new TomlError("unfinished string", { toml: str, ptr });
|
|
184598
|
+
}
|
|
184599
|
+
function parseValue(value, toml, ptr, integersAsBigInt) {
|
|
184600
|
+
if (value === "true")
|
|
184601
|
+
return true;
|
|
184602
|
+
if (value === "false")
|
|
184603
|
+
return false;
|
|
184604
|
+
if (value === "-inf")
|
|
184605
|
+
return -Infinity;
|
|
184606
|
+
if (value === "inf" || value === "+inf")
|
|
184607
|
+
return Infinity;
|
|
184608
|
+
if (value === "nan" || value === "+nan" || value === "-nan")
|
|
184609
|
+
return NaN;
|
|
184610
|
+
if (value === "-0")
|
|
184611
|
+
return integersAsBigInt ? 0n : 0;
|
|
184612
|
+
let isInt = INT_REGEX.test(value);
|
|
184613
|
+
if (isInt || FLOAT_REGEX.test(value)) {
|
|
184614
|
+
if (LEADING_ZERO.test(value)) {
|
|
184615
|
+
throw new TomlError("leading zeroes are not allowed", {
|
|
184616
|
+
toml,
|
|
184617
|
+
ptr
|
|
184618
|
+
});
|
|
184619
|
+
}
|
|
184620
|
+
value = value.replace(/_/g, "");
|
|
184621
|
+
let numeric = +value;
|
|
184622
|
+
if (isNaN(numeric)) {
|
|
184623
|
+
throw new TomlError("invalid number", {
|
|
184624
|
+
toml,
|
|
184625
|
+
ptr
|
|
184626
|
+
});
|
|
184627
|
+
}
|
|
184628
|
+
if (isInt) {
|
|
184629
|
+
if ((isInt = !Number.isSafeInteger(numeric)) && !integersAsBigInt) {
|
|
184630
|
+
throw new TomlError("integer value cannot be represented losslessly", {
|
|
184631
|
+
toml,
|
|
184632
|
+
ptr
|
|
184633
|
+
});
|
|
184634
|
+
}
|
|
184635
|
+
if (isInt || integersAsBigInt === true)
|
|
184636
|
+
numeric = BigInt(value);
|
|
184637
|
+
}
|
|
184638
|
+
return numeric;
|
|
184639
|
+
}
|
|
184640
|
+
const date5 = new TomlDate(value);
|
|
184641
|
+
if (!date5.isValid()) {
|
|
184642
|
+
throw new TomlError("invalid value", {
|
|
184643
|
+
toml,
|
|
184644
|
+
ptr
|
|
184645
|
+
});
|
|
184646
|
+
}
|
|
184647
|
+
return date5;
|
|
184648
|
+
}
|
|
184649
|
+
|
|
184650
|
+
// node_modules/smol-toml/dist/util.js
|
|
184651
|
+
/*!
|
|
184652
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
184653
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
184654
|
+
*
|
|
184655
|
+
* Redistribution and use in source and binary forms, with or without
|
|
184656
|
+
* modification, are permitted provided that the following conditions are met:
|
|
184657
|
+
*
|
|
184658
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
184659
|
+
* list of conditions and the following disclaimer.
|
|
184660
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
184661
|
+
* this list of conditions and the following disclaimer in the
|
|
184662
|
+
* documentation and/or other materials provided with the distribution.
|
|
184663
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
184664
|
+
* may be used to endorse or promote products derived from this software without
|
|
184665
|
+
* specific prior written permission.
|
|
184666
|
+
*
|
|
184667
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
184668
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
184669
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
184670
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
184671
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
184672
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
184673
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
184674
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
184675
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
184676
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
184677
|
+
*/
|
|
184678
|
+
function indexOfNewline(str, start = 0, end = str.length) {
|
|
184679
|
+
let idx = str.indexOf(`
|
|
184680
|
+
`, start);
|
|
184681
|
+
if (str[idx - 1] === "\r")
|
|
184682
|
+
idx--;
|
|
184683
|
+
return idx <= end ? idx : -1;
|
|
184684
|
+
}
|
|
184685
|
+
function skipComment(str, ptr) {
|
|
184686
|
+
for (let i = ptr;i < str.length; i++) {
|
|
184687
|
+
let c = str[i];
|
|
184688
|
+
if (c === `
|
|
184689
|
+
`)
|
|
184690
|
+
return i;
|
|
184691
|
+
if (c === "\r" && str[i + 1] === `
|
|
184692
|
+
`)
|
|
184693
|
+
return i + 1;
|
|
184694
|
+
if (c < " " && c !== "\t" || c === "") {
|
|
184695
|
+
throw new TomlError("control characters are not allowed in comments", {
|
|
184696
|
+
toml: str,
|
|
184697
|
+
ptr
|
|
184698
|
+
});
|
|
184699
|
+
}
|
|
184700
|
+
}
|
|
184701
|
+
return str.length;
|
|
184702
|
+
}
|
|
184703
|
+
function skipVoid(str, ptr, banNewLines, banComments) {
|
|
184704
|
+
let c;
|
|
184705
|
+
while (true) {
|
|
184706
|
+
while ((c = str[ptr]) === " " || c === "\t" || !banNewLines && (c === `
|
|
184707
|
+
` || c === "\r" && str[ptr + 1] === `
|
|
184708
|
+
`))
|
|
184709
|
+
ptr++;
|
|
184710
|
+
if (banComments || c !== "#")
|
|
184711
|
+
break;
|
|
184712
|
+
ptr = skipComment(str, ptr);
|
|
184713
|
+
}
|
|
184714
|
+
return ptr;
|
|
184715
|
+
}
|
|
184716
|
+
function skipUntil(str, ptr, sep, end, banNewLines = false) {
|
|
184717
|
+
if (!end) {
|
|
184718
|
+
ptr = indexOfNewline(str, ptr);
|
|
184719
|
+
return ptr < 0 ? str.length : ptr;
|
|
184720
|
+
}
|
|
184721
|
+
for (let i = ptr;i < str.length; i++) {
|
|
184722
|
+
let c = str[i];
|
|
184723
|
+
if (c === "#") {
|
|
184724
|
+
i = indexOfNewline(str, i);
|
|
184725
|
+
} else if (c === sep) {
|
|
184726
|
+
return i + 1;
|
|
184727
|
+
} else if (c === end || banNewLines && (c === `
|
|
184728
|
+
` || c === "\r" && str[i + 1] === `
|
|
184729
|
+
`)) {
|
|
184730
|
+
return i;
|
|
184731
|
+
}
|
|
184732
|
+
}
|
|
184733
|
+
throw new TomlError("cannot find end of structure", {
|
|
184734
|
+
toml: str,
|
|
184735
|
+
ptr
|
|
184736
|
+
});
|
|
184737
|
+
}
|
|
184738
|
+
|
|
184739
|
+
// node_modules/smol-toml/dist/extract.js
|
|
184740
|
+
/*!
|
|
184741
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
184742
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
184743
|
+
*
|
|
184744
|
+
* Redistribution and use in source and binary forms, with or without
|
|
184745
|
+
* modification, are permitted provided that the following conditions are met:
|
|
184746
|
+
*
|
|
184747
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
184748
|
+
* list of conditions and the following disclaimer.
|
|
184749
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
184750
|
+
* this list of conditions and the following disclaimer in the
|
|
184751
|
+
* documentation and/or other materials provided with the distribution.
|
|
184752
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
184753
|
+
* may be used to endorse or promote products derived from this software without
|
|
184754
|
+
* specific prior written permission.
|
|
184755
|
+
*
|
|
184756
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
184757
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
184758
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
184759
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
184760
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
184761
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
184762
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
184763
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
184764
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
184765
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
184766
|
+
*/
|
|
184767
|
+
function sliceAndTrimEndOf(str, startPtr, endPtr) {
|
|
184768
|
+
let value = str.slice(startPtr, endPtr);
|
|
184769
|
+
let commentIdx = value.indexOf("#");
|
|
184770
|
+
if (commentIdx > -1) {
|
|
184771
|
+
skipComment(str, commentIdx);
|
|
184772
|
+
value = value.slice(0, commentIdx);
|
|
184773
|
+
}
|
|
184774
|
+
return [value.trimEnd(), commentIdx];
|
|
184775
|
+
}
|
|
184776
|
+
function extractValue(str, ptr, end, depth, integersAsBigInt) {
|
|
184777
|
+
if (depth === 0) {
|
|
184778
|
+
throw new TomlError("document contains excessively nested structures. aborting.", {
|
|
184779
|
+
toml: str,
|
|
184780
|
+
ptr
|
|
184781
|
+
});
|
|
184782
|
+
}
|
|
184783
|
+
let c = str[ptr];
|
|
184784
|
+
if (c === "[" || c === "{") {
|
|
184785
|
+
let [value, endPtr2] = c === "[" ? parseArray(str, ptr, depth, integersAsBigInt) : parseInlineTable(str, ptr, depth, integersAsBigInt);
|
|
184786
|
+
if (end) {
|
|
184787
|
+
endPtr2 = skipVoid(str, endPtr2);
|
|
184788
|
+
if (str[endPtr2] === ",")
|
|
184789
|
+
endPtr2++;
|
|
184790
|
+
else if (str[endPtr2] !== end) {
|
|
184791
|
+
throw new TomlError("expected comma or end of structure", {
|
|
184792
|
+
toml: str,
|
|
184793
|
+
ptr: endPtr2
|
|
184794
|
+
});
|
|
184795
|
+
}
|
|
184796
|
+
}
|
|
184797
|
+
return [value, endPtr2];
|
|
184798
|
+
}
|
|
184799
|
+
if (c === '"' || c === "'") {
|
|
184800
|
+
let [parsed, endPtr2] = parseString(str, ptr);
|
|
184801
|
+
if (end) {
|
|
184802
|
+
endPtr2 = skipVoid(str, endPtr2);
|
|
184803
|
+
if (str[endPtr2] && str[endPtr2] !== "," && str[endPtr2] !== end && str[endPtr2] !== `
|
|
184804
|
+
` && str[endPtr2] !== "\r") {
|
|
184805
|
+
throw new TomlError("unexpected character encountered", {
|
|
184806
|
+
toml: str,
|
|
184807
|
+
ptr: endPtr2
|
|
184808
|
+
});
|
|
184809
|
+
}
|
|
184810
|
+
if (str[endPtr2] === ",")
|
|
184811
|
+
endPtr2++;
|
|
184812
|
+
}
|
|
184813
|
+
return [parsed, endPtr2];
|
|
184814
|
+
}
|
|
184815
|
+
let endPtr = skipUntil(str, ptr, ",", end);
|
|
184816
|
+
let slice = sliceAndTrimEndOf(str, ptr, endPtr - (str[endPtr - 1] === "," ? 1 : 0));
|
|
184817
|
+
if (!slice[0]) {
|
|
184818
|
+
throw new TomlError("incomplete key-value declaration: no value specified", {
|
|
184819
|
+
toml: str,
|
|
184820
|
+
ptr
|
|
184821
|
+
});
|
|
184822
|
+
}
|
|
184823
|
+
if (end && slice[1] > -1) {
|
|
184824
|
+
endPtr = skipVoid(str, ptr + slice[1]);
|
|
184825
|
+
if (str[endPtr] === ",")
|
|
184826
|
+
endPtr++;
|
|
184827
|
+
}
|
|
184828
|
+
return [
|
|
184829
|
+
parseValue(slice[0], str, ptr, integersAsBigInt),
|
|
184830
|
+
endPtr
|
|
184831
|
+
];
|
|
184832
|
+
}
|
|
184833
|
+
|
|
184834
|
+
// node_modules/smol-toml/dist/struct.js
|
|
184835
|
+
/*!
|
|
184836
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
184837
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
184838
|
+
*
|
|
184839
|
+
* Redistribution and use in source and binary forms, with or without
|
|
184840
|
+
* modification, are permitted provided that the following conditions are met:
|
|
184841
|
+
*
|
|
184842
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
184843
|
+
* list of conditions and the following disclaimer.
|
|
184844
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
184845
|
+
* this list of conditions and the following disclaimer in the
|
|
184846
|
+
* documentation and/or other materials provided with the distribution.
|
|
184847
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
184848
|
+
* may be used to endorse or promote products derived from this software without
|
|
184849
|
+
* specific prior written permission.
|
|
184850
|
+
*
|
|
184851
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
184852
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
184853
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
184854
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
184855
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
184856
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
184857
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
184858
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
184859
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
184860
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
184861
|
+
*/
|
|
184862
|
+
var KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
|
|
184863
|
+
function parseKey(str, ptr, end = "=") {
|
|
184864
|
+
let dot = ptr - 1;
|
|
184865
|
+
let parsed = [];
|
|
184866
|
+
let endPtr = str.indexOf(end, ptr);
|
|
184867
|
+
if (endPtr < 0) {
|
|
184868
|
+
throw new TomlError("incomplete key-value: cannot find end of key", {
|
|
184869
|
+
toml: str,
|
|
184870
|
+
ptr
|
|
184871
|
+
});
|
|
184872
|
+
}
|
|
184873
|
+
do {
|
|
184874
|
+
let c = str[ptr = ++dot];
|
|
184875
|
+
if (c !== " " && c !== "\t") {
|
|
184876
|
+
if (c === '"' || c === "'") {
|
|
184877
|
+
if (c === str[ptr + 1] && c === str[ptr + 2]) {
|
|
184878
|
+
throw new TomlError("multiline strings are not allowed in keys", {
|
|
184879
|
+
toml: str,
|
|
184880
|
+
ptr
|
|
184881
|
+
});
|
|
184882
|
+
}
|
|
184883
|
+
let [part, eos] = parseString(str, ptr);
|
|
184884
|
+
dot = str.indexOf(".", eos);
|
|
184885
|
+
let strEnd = str.slice(eos, dot < 0 || dot > endPtr ? endPtr : dot);
|
|
184886
|
+
let newLine = indexOfNewline(strEnd);
|
|
184887
|
+
if (newLine > -1) {
|
|
184888
|
+
throw new TomlError("newlines are not allowed in keys", {
|
|
184889
|
+
toml: str,
|
|
184890
|
+
ptr: ptr + dot + newLine
|
|
184891
|
+
});
|
|
184892
|
+
}
|
|
184893
|
+
if (strEnd.trimStart()) {
|
|
184894
|
+
throw new TomlError("found extra tokens after the string part", {
|
|
184895
|
+
toml: str,
|
|
184896
|
+
ptr: eos
|
|
184897
|
+
});
|
|
184898
|
+
}
|
|
184899
|
+
if (endPtr < eos) {
|
|
184900
|
+
endPtr = str.indexOf(end, eos);
|
|
184901
|
+
if (endPtr < 0) {
|
|
184902
|
+
throw new TomlError("incomplete key-value: cannot find end of key", {
|
|
184903
|
+
toml: str,
|
|
184904
|
+
ptr
|
|
184905
|
+
});
|
|
184906
|
+
}
|
|
184907
|
+
}
|
|
184908
|
+
parsed.push(part);
|
|
184909
|
+
} else {
|
|
184910
|
+
dot = str.indexOf(".", ptr);
|
|
184911
|
+
let part = str.slice(ptr, dot < 0 || dot > endPtr ? endPtr : dot);
|
|
184912
|
+
if (!KEY_PART_RE.test(part)) {
|
|
184913
|
+
throw new TomlError("only letter, numbers, dashes and underscores are allowed in keys", {
|
|
184914
|
+
toml: str,
|
|
184915
|
+
ptr
|
|
184916
|
+
});
|
|
184917
|
+
}
|
|
184918
|
+
parsed.push(part.trimEnd());
|
|
184919
|
+
}
|
|
184920
|
+
}
|
|
184921
|
+
} while (dot + 1 && dot < endPtr);
|
|
184922
|
+
return [parsed, skipVoid(str, endPtr + 1, true, true)];
|
|
184923
|
+
}
|
|
184924
|
+
function parseInlineTable(str, ptr, depth, integersAsBigInt) {
|
|
184925
|
+
let res = {};
|
|
184926
|
+
let seen = new Set;
|
|
184927
|
+
let c;
|
|
184928
|
+
ptr++;
|
|
184929
|
+
while ((c = str[ptr++]) !== "}" && c) {
|
|
184930
|
+
if (c === ",") {
|
|
184931
|
+
throw new TomlError("expected value, found comma", {
|
|
184932
|
+
toml: str,
|
|
184933
|
+
ptr: ptr - 1
|
|
184934
|
+
});
|
|
184935
|
+
} else if (c === "#")
|
|
184936
|
+
ptr = skipComment(str, ptr);
|
|
184937
|
+
else if (c !== " " && c !== "\t" && c !== `
|
|
184938
|
+
` && c !== "\r") {
|
|
184939
|
+
let k;
|
|
184940
|
+
let t = res;
|
|
184941
|
+
let hasOwn = false;
|
|
184942
|
+
let [key, keyEndPtr] = parseKey(str, ptr - 1);
|
|
184943
|
+
for (let i = 0;i < key.length; i++) {
|
|
184944
|
+
if (i)
|
|
184945
|
+
t = hasOwn ? t[k] : t[k] = {};
|
|
184946
|
+
k = key[i];
|
|
184947
|
+
if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== "object" || seen.has(t[k]))) {
|
|
184948
|
+
throw new TomlError("trying to redefine an already defined value", {
|
|
184949
|
+
toml: str,
|
|
184950
|
+
ptr
|
|
184951
|
+
});
|
|
184952
|
+
}
|
|
184953
|
+
if (!hasOwn && k === "__proto__") {
|
|
184954
|
+
Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
|
|
184955
|
+
}
|
|
184956
|
+
}
|
|
184957
|
+
if (hasOwn) {
|
|
184958
|
+
throw new TomlError("trying to redefine an already defined value", {
|
|
184959
|
+
toml: str,
|
|
184960
|
+
ptr
|
|
184961
|
+
});
|
|
184962
|
+
}
|
|
184963
|
+
let [value, valueEndPtr] = extractValue(str, keyEndPtr, "}", depth - 1, integersAsBigInt);
|
|
184964
|
+
seen.add(value);
|
|
184965
|
+
t[k] = value;
|
|
184966
|
+
ptr = valueEndPtr;
|
|
184967
|
+
}
|
|
184968
|
+
}
|
|
184969
|
+
if (!c) {
|
|
184970
|
+
throw new TomlError("unfinished table encountered", {
|
|
184971
|
+
toml: str,
|
|
184972
|
+
ptr
|
|
184973
|
+
});
|
|
184974
|
+
}
|
|
184975
|
+
return [res, ptr];
|
|
184976
|
+
}
|
|
184977
|
+
function parseArray(str, ptr, depth, integersAsBigInt) {
|
|
184978
|
+
let res = [];
|
|
184979
|
+
let c;
|
|
184980
|
+
ptr++;
|
|
184981
|
+
while ((c = str[ptr++]) !== "]" && c) {
|
|
184982
|
+
if (c === ",") {
|
|
184983
|
+
throw new TomlError("expected value, found comma", {
|
|
184984
|
+
toml: str,
|
|
184985
|
+
ptr: ptr - 1
|
|
184986
|
+
});
|
|
184987
|
+
} else if (c === "#")
|
|
184988
|
+
ptr = skipComment(str, ptr);
|
|
184989
|
+
else if (c !== " " && c !== "\t" && c !== `
|
|
184990
|
+
` && c !== "\r") {
|
|
184991
|
+
let e = extractValue(str, ptr - 1, "]", depth - 1, integersAsBigInt);
|
|
184992
|
+
res.push(e[0]);
|
|
184993
|
+
ptr = e[1];
|
|
184994
|
+
}
|
|
184995
|
+
}
|
|
184996
|
+
if (!c) {
|
|
184997
|
+
throw new TomlError("unfinished array encountered", {
|
|
184998
|
+
toml: str,
|
|
184999
|
+
ptr
|
|
185000
|
+
});
|
|
185001
|
+
}
|
|
185002
|
+
return [res, ptr];
|
|
185003
|
+
}
|
|
185004
|
+
|
|
185005
|
+
// node_modules/smol-toml/dist/parse.js
|
|
185006
|
+
/*!
|
|
185007
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
185008
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
185009
|
+
*
|
|
185010
|
+
* Redistribution and use in source and binary forms, with or without
|
|
185011
|
+
* modification, are permitted provided that the following conditions are met:
|
|
185012
|
+
*
|
|
185013
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
185014
|
+
* list of conditions and the following disclaimer.
|
|
185015
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
185016
|
+
* this list of conditions and the following disclaimer in the
|
|
185017
|
+
* documentation and/or other materials provided with the distribution.
|
|
185018
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
185019
|
+
* may be used to endorse or promote products derived from this software without
|
|
185020
|
+
* specific prior written permission.
|
|
185021
|
+
*
|
|
185022
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
185023
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
185024
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
185025
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
185026
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
185027
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
185028
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
185029
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
185030
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
185031
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
185032
|
+
*/
|
|
185033
|
+
function peekTable(key, table, meta3, type) {
|
|
185034
|
+
let t = table;
|
|
185035
|
+
let m = meta3;
|
|
185036
|
+
let k;
|
|
185037
|
+
let hasOwn = false;
|
|
185038
|
+
let state;
|
|
185039
|
+
for (let i = 0;i < key.length; i++) {
|
|
185040
|
+
if (i) {
|
|
185041
|
+
t = hasOwn ? t[k] : t[k] = {};
|
|
185042
|
+
m = (state = m[k]).c;
|
|
185043
|
+
if (type === 0 && (state.t === 1 || state.t === 2)) {
|
|
185044
|
+
return null;
|
|
185045
|
+
}
|
|
185046
|
+
if (state.t === 2) {
|
|
185047
|
+
let l = t.length - 1;
|
|
185048
|
+
t = t[l];
|
|
185049
|
+
m = m[l].c;
|
|
185050
|
+
}
|
|
185051
|
+
}
|
|
185052
|
+
k = key[i];
|
|
185053
|
+
if ((hasOwn = Object.hasOwn(t, k)) && m[k]?.t === 0 && m[k]?.d) {
|
|
185054
|
+
return null;
|
|
185055
|
+
}
|
|
185056
|
+
if (!hasOwn) {
|
|
185057
|
+
if (k === "__proto__") {
|
|
185058
|
+
Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
|
|
185059
|
+
Object.defineProperty(m, k, { enumerable: true, configurable: true, writable: true });
|
|
185060
|
+
}
|
|
185061
|
+
m[k] = {
|
|
185062
|
+
t: i < key.length - 1 && type === 2 ? 3 : type,
|
|
185063
|
+
d: false,
|
|
185064
|
+
i: 0,
|
|
185065
|
+
c: {}
|
|
185066
|
+
};
|
|
185067
|
+
}
|
|
185068
|
+
}
|
|
185069
|
+
state = m[k];
|
|
185070
|
+
if (state.t !== type && !(type === 1 && state.t === 3)) {
|
|
185071
|
+
return null;
|
|
185072
|
+
}
|
|
185073
|
+
if (type === 2) {
|
|
185074
|
+
if (!state.d) {
|
|
185075
|
+
state.d = true;
|
|
185076
|
+
t[k] = [];
|
|
185077
|
+
}
|
|
185078
|
+
t[k].push(t = {});
|
|
185079
|
+
state.c[state.i++] = state = { t: 1, d: false, i: 0, c: {} };
|
|
185080
|
+
}
|
|
185081
|
+
if (state.d) {
|
|
185082
|
+
return null;
|
|
185083
|
+
}
|
|
185084
|
+
state.d = true;
|
|
185085
|
+
if (type === 1) {
|
|
185086
|
+
t = hasOwn ? t[k] : t[k] = {};
|
|
185087
|
+
} else if (type === 0 && hasOwn) {
|
|
185088
|
+
return null;
|
|
185089
|
+
}
|
|
185090
|
+
return [k, t, state.c];
|
|
185091
|
+
}
|
|
185092
|
+
function parse5(toml, { maxDepth = 1000, integersAsBigInt } = {}) {
|
|
185093
|
+
let res = {};
|
|
185094
|
+
let meta3 = {};
|
|
185095
|
+
let tbl = res;
|
|
185096
|
+
let m = meta3;
|
|
185097
|
+
for (let ptr = skipVoid(toml, 0);ptr < toml.length; ) {
|
|
185098
|
+
if (toml[ptr] === "[") {
|
|
185099
|
+
let isTableArray = toml[++ptr] === "[";
|
|
185100
|
+
let k = parseKey(toml, ptr += +isTableArray, "]");
|
|
185101
|
+
if (isTableArray) {
|
|
185102
|
+
if (toml[k[1] - 1] !== "]") {
|
|
185103
|
+
throw new TomlError("expected end of table declaration", {
|
|
185104
|
+
toml,
|
|
185105
|
+
ptr: k[1] - 1
|
|
185106
|
+
});
|
|
185107
|
+
}
|
|
185108
|
+
k[1]++;
|
|
185109
|
+
}
|
|
185110
|
+
let p = peekTable(k[0], res, meta3, isTableArray ? 2 : 1);
|
|
185111
|
+
if (!p) {
|
|
185112
|
+
throw new TomlError("trying to redefine an already defined table or value", {
|
|
185113
|
+
toml,
|
|
185114
|
+
ptr
|
|
185115
|
+
});
|
|
185116
|
+
}
|
|
185117
|
+
m = p[2];
|
|
185118
|
+
tbl = p[1];
|
|
185119
|
+
ptr = k[1];
|
|
185120
|
+
} else {
|
|
185121
|
+
let k = parseKey(toml, ptr);
|
|
185122
|
+
let p = peekTable(k[0], tbl, m, 0);
|
|
185123
|
+
if (!p) {
|
|
185124
|
+
throw new TomlError("trying to redefine an already defined table or value", {
|
|
185125
|
+
toml,
|
|
185126
|
+
ptr
|
|
185127
|
+
});
|
|
185128
|
+
}
|
|
185129
|
+
let v = extractValue(toml, k[1], undefined, maxDepth, integersAsBigInt);
|
|
185130
|
+
p[1][p[0]] = v[0];
|
|
185131
|
+
ptr = v[1];
|
|
185132
|
+
}
|
|
185133
|
+
ptr = skipVoid(toml, ptr, true);
|
|
185134
|
+
if (toml[ptr] && toml[ptr] !== `
|
|
185135
|
+
` && toml[ptr] !== "\r") {
|
|
185136
|
+
throw new TomlError("each key-value declaration must be followed by an end-of-line", {
|
|
185137
|
+
toml,
|
|
185138
|
+
ptr
|
|
185139
|
+
});
|
|
185140
|
+
}
|
|
185141
|
+
ptr = skipVoid(toml, ptr);
|
|
185142
|
+
}
|
|
185143
|
+
return res;
|
|
185144
|
+
}
|
|
185145
|
+
|
|
185146
|
+
// node_modules/smol-toml/dist/stringify.js
|
|
185147
|
+
/*!
|
|
185148
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
185149
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
185150
|
+
*
|
|
185151
|
+
* Redistribution and use in source and binary forms, with or without
|
|
185152
|
+
* modification, are permitted provided that the following conditions are met:
|
|
185153
|
+
*
|
|
185154
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
185155
|
+
* list of conditions and the following disclaimer.
|
|
185156
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
185157
|
+
* this list of conditions and the following disclaimer in the
|
|
185158
|
+
* documentation and/or other materials provided with the distribution.
|
|
185159
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
185160
|
+
* may be used to endorse or promote products derived from this software without
|
|
185161
|
+
* specific prior written permission.
|
|
185162
|
+
*
|
|
185163
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
185164
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
185165
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
185166
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
185167
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
185168
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
185169
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
185170
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
185171
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
185172
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
185173
|
+
*/
|
|
185174
|
+
|
|
185175
|
+
// node_modules/smol-toml/dist/index.js
|
|
185176
|
+
/*!
|
|
185177
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
185178
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
185179
|
+
*
|
|
185180
|
+
* Redistribution and use in source and binary forms, with or without
|
|
185181
|
+
* modification, are permitted provided that the following conditions are met:
|
|
185182
|
+
*
|
|
185183
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
185184
|
+
* list of conditions and the following disclaimer.
|
|
185185
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
185186
|
+
* this list of conditions and the following disclaimer in the
|
|
185187
|
+
* documentation and/or other materials provided with the distribution.
|
|
185188
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
185189
|
+
* may be used to endorse or promote products derived from this software without
|
|
185190
|
+
* specific prior written permission.
|
|
185191
|
+
*
|
|
185192
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
185193
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
185194
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
185195
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
185196
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
185197
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
185198
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
185199
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
185200
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
185201
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
185202
|
+
*/
|
|
185203
|
+
|
|
185204
|
+
// src/config/tomlConfigLoader.ts
|
|
185205
|
+
async function loadTomlConfigFile(configPath) {
|
|
185206
|
+
const source = await readFile(configPath, "utf8");
|
|
185207
|
+
try {
|
|
185208
|
+
return parse5(source);
|
|
185209
|
+
} catch (error51) {
|
|
185210
|
+
throw new Error(formatTomlError(configPath, error51));
|
|
185211
|
+
}
|
|
185212
|
+
}
|
|
185213
|
+
function formatTomlError(configPath, error51) {
|
|
185214
|
+
if (error51 instanceof TomlError) {
|
|
185215
|
+
return `TOML config parse failed for ${configPath} at ${error51.line}:${error51.column}: ${error51.message}`;
|
|
185216
|
+
}
|
|
185217
|
+
return `TOML config parse failed for ${configPath}: ${error51 instanceof Error ? error51.message : String(error51)}`;
|
|
185218
|
+
}
|
|
185219
|
+
|
|
184001
185220
|
// src/config/tsConfigLoader.ts
|
|
184002
185221
|
var import_typescript = __toESM(require_typescript(), 1);
|
|
184003
185222
|
import { createRequire as createRequire2 } from "node:module";
|
|
@@ -184034,14 +185253,14 @@ ${transpiled}
|
|
|
184034
185253
|
|
|
184035
185254
|
// src/config/trustedConfig.ts
|
|
184036
185255
|
import { createHash } from "node:crypto";
|
|
184037
|
-
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
185256
|
+
import { mkdir, readFile as readFile2, writeFile } from "node:fs/promises";
|
|
184038
185257
|
import { homedir } from "node:os";
|
|
184039
185258
|
import { dirname as dirname2, join, resolve } from "node:path";
|
|
184040
185259
|
function hashConfigSource(source) {
|
|
184041
185260
|
return createHash("sha256").update(source).digest("hex");
|
|
184042
185261
|
}
|
|
184043
185262
|
function defaultTrustedConfigStorePath(env = process.env) {
|
|
184044
|
-
return env.KYOSO_TRUST_STORE_PATH ? resolve(env.KYOSO_TRUST_STORE_PATH) : join(homedir(), ".kyoso", "trusted-configs.json");
|
|
185263
|
+
return env.KYOSO_TRUST_STORE_PATH ? resolve(env.KYOSO_TRUST_STORE_PATH) : join(env.HOME ? resolve(env.HOME) : homedir(), ".kyoso", "trusted-configs.json");
|
|
184045
185264
|
}
|
|
184046
185265
|
async function isTrustedConfig(storePath, configPath, configHash) {
|
|
184047
185266
|
const store = await readTrustedConfigStore(storePath);
|
|
@@ -184060,7 +185279,7 @@ async function trustConfig(storePath, configPath, configHash) {
|
|
|
184060
185279
|
async function readTrustedConfigStore(storePath) {
|
|
184061
185280
|
let parsed;
|
|
184062
185281
|
try {
|
|
184063
|
-
parsed = JSON.parse(await
|
|
185282
|
+
parsed = JSON.parse(await readFile2(storePath, "utf8"));
|
|
184064
185283
|
} catch (error51) {
|
|
184065
185284
|
if (isMissingPathError(error51))
|
|
184066
185285
|
return {};
|
|
@@ -184068,7 +185287,7 @@ async function readTrustedConfigStore(storePath) {
|
|
|
184068
185287
|
return {};
|
|
184069
185288
|
throw error51;
|
|
184070
185289
|
}
|
|
184071
|
-
if (!
|
|
185290
|
+
if (!isRecord2(parsed))
|
|
184072
185291
|
return {};
|
|
184073
185292
|
const store = {};
|
|
184074
185293
|
for (const [configPath, configHash] of Object.entries(parsed)) {
|
|
@@ -184077,7 +185296,7 @@ async function readTrustedConfigStore(storePath) {
|
|
|
184077
185296
|
}
|
|
184078
185297
|
return store;
|
|
184079
185298
|
}
|
|
184080
|
-
function
|
|
185299
|
+
function isRecord2(value) {
|
|
184081
185300
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
184082
185301
|
}
|
|
184083
185302
|
function isMissingPathError(error51) {
|
|
@@ -184085,44 +185304,178 @@ function isMissingPathError(error51) {
|
|
|
184085
185304
|
}
|
|
184086
185305
|
|
|
184087
185306
|
// src/config/loadConfig.ts
|
|
185307
|
+
var KNOWN_GLOBAL_CONFIG_LEAF_PATHS = new Set(kyosoConfigKnownLeafPaths);
|
|
185308
|
+
var GLOBAL_CONFIG_RECORD_PREFIXES = kyosoConfigRecordPrefixes.map((path) => path.split("."));
|
|
185309
|
+
var SECURITY_SENSITIVE_GLOBAL_PREFIXES = kyosoConfigSecuritySensitivePrefixes.map((path) => path.split("."));
|
|
184088
185310
|
async function loadConfig(options = {}) {
|
|
184089
185311
|
const cwd = options.cwd ?? process.cwd();
|
|
185312
|
+
const env = options.env ?? process.env;
|
|
185313
|
+
const globalConfigPath = resolveGlobalTomlConfigPath(env);
|
|
184090
185314
|
const warnings = [];
|
|
184091
|
-
|
|
185315
|
+
const sources = [];
|
|
185316
|
+
let mergedConfig = defaultConfig;
|
|
184092
185317
|
let configPath;
|
|
184093
185318
|
let configHash;
|
|
184094
185319
|
let configTrustStatus = options.ignoreConfig ? "ignored" : "not_found";
|
|
184095
185320
|
if (!options.ignoreConfig) {
|
|
184096
|
-
|
|
184097
|
-
|
|
184098
|
-
|
|
184099
|
-
const
|
|
184100
|
-
|
|
184101
|
-
|
|
184102
|
-
|
|
184103
|
-
|
|
184104
|
-
|
|
184105
|
-
|
|
184106
|
-
|
|
185321
|
+
if (await exists(globalConfigPath)) {
|
|
185322
|
+
const globalConfig2 = await loadTomlConfigFile(globalConfigPath);
|
|
185323
|
+
const globalConfigWarnings = collectGlobalConfigWarnings(globalConfigPath, globalConfig2);
|
|
185324
|
+
const securitySensitiveWarnings = globalConfigWarnings.filter((warning) => warning.startsWith("security-sensitive unknown settings "));
|
|
185325
|
+
if (securitySensitiveWarnings.length > 0 && !options.allowUnknownConfig) {
|
|
185326
|
+
throw new Error(`Security-sensitive unknown config settings rejected. Fix the key name or pass --allow-unknown-config to continue with warnings: ${securitySensitiveWarnings.join("; ")}`);
|
|
185327
|
+
}
|
|
185328
|
+
warnings.push(...globalConfigWarnings);
|
|
185329
|
+
mergedConfig = deepMerge2(mergedConfig, globalConfig2);
|
|
185330
|
+
sources.push({ path: globalConfigPath, layer: "global_toml" });
|
|
185331
|
+
}
|
|
185332
|
+
if (options.configPath) {
|
|
185333
|
+
const explicitConfigPath = resolve2(cwd, options.configPath);
|
|
185334
|
+
if (!await exists(explicitConfigPath)) {
|
|
185335
|
+
throw new Error(`Config file not found: ${explicitConfigPath} (from --config)`);
|
|
185336
|
+
}
|
|
185337
|
+
const loaded = await loadProjectConfig({
|
|
185338
|
+
configPath: explicitConfigPath,
|
|
185339
|
+
baseConfig: mergedConfig,
|
|
185340
|
+
globalConfigPath,
|
|
184107
185341
|
options
|
|
184108
185342
|
});
|
|
184109
|
-
|
|
184110
|
-
|
|
184111
|
-
|
|
184112
|
-
|
|
184113
|
-
|
|
184114
|
-
|
|
184115
|
-
|
|
184116
|
-
|
|
185343
|
+
mergedConfig = loaded.mergedConfig;
|
|
185344
|
+
configPath = loaded.configPath;
|
|
185345
|
+
configHash = loaded.configHash;
|
|
185346
|
+
configTrustStatus = loaded.configTrustStatus;
|
|
185347
|
+
sources.push(loaded.source);
|
|
185348
|
+
warnings.push(...loaded.warnings);
|
|
185349
|
+
} else {
|
|
185350
|
+
const projectTomlPath = resolve2(cwd, "kyoso.toml");
|
|
185351
|
+
const projectTsPath = resolve2(cwd, "kyoso.config.ts");
|
|
185352
|
+
const hasProjectToml = await exists(projectTomlPath);
|
|
185353
|
+
const hasProjectTs = await exists(projectTsPath);
|
|
185354
|
+
if (hasProjectToml) {
|
|
185355
|
+
mergedConfig = mergeProjectTomlConfig(mergedConfig, await loadTomlConfigFile(projectTomlPath), { projectPath: projectTomlPath, globalConfigPath });
|
|
185356
|
+
configPath = projectTomlPath;
|
|
185357
|
+
sources.push({ path: projectTomlPath, layer: "project_toml" });
|
|
185358
|
+
if (hasProjectTs) {
|
|
185359
|
+
warnings.push(`kyoso.config.ts was ignored because kyoso.toml takes precedence: ${projectTsPath}`);
|
|
185360
|
+
}
|
|
185361
|
+
} else if (hasProjectTs) {
|
|
185362
|
+
const loaded = await loadProjectTsConfig({
|
|
185363
|
+
configPath: projectTsPath,
|
|
185364
|
+
baseConfig: mergedConfig,
|
|
185365
|
+
options
|
|
185366
|
+
});
|
|
185367
|
+
mergedConfig = loaded.mergedConfig;
|
|
185368
|
+
configPath = loaded.configPath;
|
|
185369
|
+
configHash = loaded.configHash;
|
|
185370
|
+
configTrustStatus = loaded.configTrustStatus;
|
|
185371
|
+
sources.push(loaded.source);
|
|
185372
|
+
warnings.push(...loaded.warnings);
|
|
184117
185373
|
}
|
|
184118
185374
|
}
|
|
184119
185375
|
}
|
|
184120
|
-
const parsed = kyosoConfigSchema.parse(
|
|
185376
|
+
const parsed = kyosoConfigSchema.parse(mergedConfig);
|
|
184121
185377
|
return {
|
|
184122
185378
|
config: parsed,
|
|
184123
185379
|
configPath,
|
|
184124
185380
|
configHash,
|
|
184125
185381
|
configTrustStatus,
|
|
185382
|
+
sources,
|
|
185383
|
+
warnings
|
|
185384
|
+
};
|
|
185385
|
+
}
|
|
185386
|
+
function resolveGlobalTomlConfigPath(env = process.env) {
|
|
185387
|
+
const configHome = env.XDG_CONFIG_HOME ? resolve2(env.XDG_CONFIG_HOME) : join2(env.HOME ? resolve2(env.HOME) : homedir2(), ".config");
|
|
185388
|
+
return join2(configHome, "kyoso", "config.toml");
|
|
185389
|
+
}
|
|
185390
|
+
function collectGlobalConfigWarnings(configPath, config2) {
|
|
185391
|
+
const unknownSettings = flattenLeaves(config2).map((leaf) => leaf.path).filter((path) => !isKnownGlobalConfigPath(path)).map((path) => ({
|
|
185392
|
+
path: sanitizeWarningText(path.join(".")),
|
|
185393
|
+
securitySensitive: isSecuritySensitiveGlobalPath(path)
|
|
185394
|
+
})).sort((left, right) => left.path.localeCompare(right.path));
|
|
185395
|
+
const warnings = [];
|
|
185396
|
+
const securitySensitivePaths = unknownSettings.filter((setting) => setting.securitySensitive).map((setting) => setting.path);
|
|
185397
|
+
const generalPaths = unknownSettings.filter((setting) => !setting.securitySensitive).map((setting) => setting.path);
|
|
185398
|
+
const sanitizedConfigPath = sanitizeWarningText(configPath);
|
|
185399
|
+
if (securitySensitivePaths.length > 0) {
|
|
185400
|
+
warnings.push(`security-sensitive unknown settings in ${sanitizedConfigPath} were ignored: ${formatUnknownPaths(securitySensitivePaths)}`);
|
|
185401
|
+
}
|
|
185402
|
+
if (generalPaths.length > 0) {
|
|
185403
|
+
warnings.push(`unknown settings in ${sanitizedConfigPath} were ignored: ${formatUnknownPaths(generalPaths)}`);
|
|
185404
|
+
}
|
|
185405
|
+
return warnings;
|
|
185406
|
+
}
|
|
185407
|
+
function sanitizeWarningText(value) {
|
|
185408
|
+
const withoutControlChars = value.replace(/\u001b\[[0-?]*[ -/]*[@-~]/g, "").replace(/[\u0000-\u001f\u007f-\u009f]/g, "");
|
|
185409
|
+
return sanitizeText(withoutControlChars);
|
|
185410
|
+
}
|
|
185411
|
+
function formatUnknownPaths(paths) {
|
|
185412
|
+
return paths.map((path) => JSON.stringify(path)).join("; ");
|
|
185413
|
+
}
|
|
185414
|
+
function isSecuritySensitiveGlobalPath(path) {
|
|
185415
|
+
return SECURITY_SENSITIVE_GLOBAL_PREFIXES.some((prefix) => pathStartsWith(path, prefix));
|
|
185416
|
+
}
|
|
185417
|
+
function isKnownGlobalConfigPath(path) {
|
|
185418
|
+
if (KNOWN_GLOBAL_CONFIG_LEAF_PATHS.has(path.join(".")))
|
|
185419
|
+
return true;
|
|
185420
|
+
return GLOBAL_CONFIG_RECORD_PREFIXES.some((prefix) => pathStartsWith(path, prefix));
|
|
185421
|
+
}
|
|
185422
|
+
function pathStartsWith(path, prefix) {
|
|
185423
|
+
return path.length >= prefix.length && prefix.every((part, index) => path[index] === part);
|
|
185424
|
+
}
|
|
185425
|
+
async function loadProjectConfig(input) {
|
|
185426
|
+
const extension = extname2(input.configPath);
|
|
185427
|
+
if (extension === ".toml") {
|
|
185428
|
+
return {
|
|
185429
|
+
mergedConfig: mergeProjectTomlConfig(input.baseConfig, await loadTomlConfigFile(input.configPath), {
|
|
185430
|
+
projectPath: input.configPath,
|
|
185431
|
+
globalConfigPath: input.globalConfigPath
|
|
185432
|
+
}),
|
|
185433
|
+
configPath: input.configPath,
|
|
185434
|
+
configTrustStatus: "not_found",
|
|
185435
|
+
source: { path: input.configPath, layer: "project_toml" },
|
|
185436
|
+
warnings: []
|
|
185437
|
+
};
|
|
185438
|
+
}
|
|
185439
|
+
if (extension === ".ts") {
|
|
185440
|
+
return await loadProjectTsConfig(input);
|
|
185441
|
+
}
|
|
185442
|
+
throw new Error(`Unsupported config file extension for ${input.configPath}. Expected .toml or .ts.`);
|
|
185443
|
+
}
|
|
185444
|
+
async function loadProjectTsConfig(input) {
|
|
185445
|
+
const warnings = [
|
|
185446
|
+
'kyoso.config.ts is deprecated; migrate to kyoso.toml (see README "Configuration")'
|
|
185447
|
+
];
|
|
185448
|
+
const source = await readFile3(input.configPath, "utf8");
|
|
185449
|
+
const configHash = hashConfigSource(source);
|
|
185450
|
+
const trustStorePath = input.options.trustStorePath ?? defaultTrustedConfigStorePath(input.options.env);
|
|
185451
|
+
const trusted = await isTrustedConfig(trustStorePath, input.configPath, configHash);
|
|
185452
|
+
const trustDecision = await resolveTrustDecision({
|
|
185453
|
+
configPath: input.configPath,
|
|
185454
|
+
configHash,
|
|
185455
|
+
trusted,
|
|
185456
|
+
options: input.options
|
|
185457
|
+
});
|
|
185458
|
+
if (trustDecision.execute) {
|
|
185459
|
+
const userConfig = await loadUserConfig(input.configPath, source);
|
|
185460
|
+
if (trustDecision.shouldPersist) {
|
|
185461
|
+
await trustConfig(trustStorePath, input.configPath, configHash);
|
|
185462
|
+
}
|
|
185463
|
+
return {
|
|
185464
|
+
mergedConfig: deepMerge2(input.baseConfig, userConfig),
|
|
185465
|
+
configPath: input.configPath,
|
|
185466
|
+
configHash,
|
|
185467
|
+
configTrustStatus: trustDecision.status,
|
|
185468
|
+
source: { path: input.configPath, layer: "project_ts" },
|
|
185469
|
+
warnings
|
|
185470
|
+
};
|
|
185471
|
+
}
|
|
185472
|
+
warnings.push(`untrusted config was not executed: ${input.configPath}; run \`kyoso doctor --trust-config\` or pass \`--trust-config\` once to trust it`);
|
|
185473
|
+
return {
|
|
185474
|
+
mergedConfig: input.baseConfig,
|
|
185475
|
+
configPath: input.configPath,
|
|
185476
|
+
configHash,
|
|
185477
|
+
configTrustStatus: trustDecision.status,
|
|
185478
|
+
source: { path: input.configPath, layer: "project_ts" },
|
|
184126
185479
|
warnings
|
|
184127
185480
|
};
|
|
184128
185481
|
}
|
|
@@ -184172,16 +185525,16 @@ async function promptForConfigTrust(configPath, configHash) {
|
|
|
184172
185525
|
rl.close();
|
|
184173
185526
|
}
|
|
184174
185527
|
}
|
|
184175
|
-
function
|
|
184176
|
-
if (!
|
|
185528
|
+
function deepMerge2(base, override) {
|
|
185529
|
+
if (!isRecord3(base) || !isRecord3(override))
|
|
184177
185530
|
return override ?? base;
|
|
184178
185531
|
const result = { ...base };
|
|
184179
185532
|
for (const [key, value] of Object.entries(override)) {
|
|
184180
|
-
result[key] =
|
|
185533
|
+
result[key] = deepMerge2(result[key], value);
|
|
184181
185534
|
}
|
|
184182
185535
|
return result;
|
|
184183
185536
|
}
|
|
184184
|
-
function
|
|
185537
|
+
function isRecord3(value) {
|
|
184185
185538
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
184186
185539
|
}
|
|
184187
185540
|
async function exists(path) {
|
|
@@ -184195,7 +185548,7 @@ async function exists(path) {
|
|
|
184195
185548
|
|
|
184196
185549
|
// src/acp/AcpAgentProcess.ts
|
|
184197
185550
|
import { spawn } from "node:child_process";
|
|
184198
|
-
import { readFile as
|
|
185551
|
+
import { readFile as readFile4, realpath } from "node:fs/promises";
|
|
184199
185552
|
import { isAbsolute, relative, resolve as resolve3 } from "node:path";
|
|
184200
185553
|
import { Readable, Writable } from "node:stream";
|
|
184201
185554
|
|
|
@@ -186069,14 +187422,14 @@ function ndJsonStream(output, input) {
|
|
|
186069
187422
|
}
|
|
186070
187423
|
// node_modules/@agentclientprotocol/sdk/dist/jsonrpc.js
|
|
186071
187424
|
var CANCEL_REQUEST_METHOD = "$/cancel_request";
|
|
186072
|
-
function
|
|
187425
|
+
function isRecord4(value) {
|
|
186073
187426
|
return typeof value === "object" && value !== null;
|
|
186074
187427
|
}
|
|
186075
187428
|
function isJsonRpcId(value) {
|
|
186076
187429
|
return value === null || typeof value === "string" || typeof value === "number" && Number.isFinite(value);
|
|
186077
187430
|
}
|
|
186078
187431
|
function cancelRequestId(params) {
|
|
186079
|
-
if (!
|
|
187432
|
+
if (!isRecord4(params) || !isJsonRpcId(params["requestId"])) {
|
|
186080
187433
|
return;
|
|
186081
187434
|
}
|
|
186082
187435
|
return params["requestId"];
|
|
@@ -186578,25 +187931,25 @@ class ConnectionBuilder {
|
|
|
186578
187931
|
describe: () => this.connectionName ?? "onReceiveMessage"
|
|
186579
187932
|
});
|
|
186580
187933
|
}
|
|
186581
|
-
onReceiveRequest(method,
|
|
187934
|
+
onReceiveRequest(method, parse6, handler) {
|
|
186582
187935
|
return this.withHandler({
|
|
186583
187936
|
handleMessage: async (message, cx) => {
|
|
186584
187937
|
if (message.kind !== "request" || message.method !== method) {
|
|
186585
187938
|
return Handled.no(message);
|
|
186586
187939
|
}
|
|
186587
|
-
const request =
|
|
187940
|
+
const request = parse6(message.params);
|
|
186588
187941
|
return await handler(request, message.responder, cx) ?? Handled.yes();
|
|
186589
187942
|
},
|
|
186590
187943
|
describe: () => `${this.connectionName ?? "request"}:${method}`
|
|
186591
187944
|
});
|
|
186592
187945
|
}
|
|
186593
|
-
onReceiveNotification(method,
|
|
187946
|
+
onReceiveNotification(method, parse6, handler) {
|
|
186594
187947
|
return this.withHandler({
|
|
186595
187948
|
handleMessage: async (message, cx) => {
|
|
186596
187949
|
if (message.kind !== "notification" || message.method !== method) {
|
|
186597
187950
|
return Handled.no(message);
|
|
186598
187951
|
}
|
|
186599
|
-
const notification =
|
|
187952
|
+
const notification = parse6(message.params);
|
|
186600
187953
|
return await handler(notification, cx) ?? Handled.yes();
|
|
186601
187954
|
},
|
|
186602
187955
|
describe: () => `${this.connectionName ?? "notification"}:${method}`
|
|
@@ -187470,42 +188823,6 @@ var legacyClientNotificationMethods = new Set([
|
|
|
187470
188823
|
CLIENT_METHODS.elicitation_complete
|
|
187471
188824
|
]);
|
|
187472
188825
|
|
|
187473
|
-
// src/security/redact.ts
|
|
187474
|
-
var REDACTION = "[KYOSO_REDACTED]";
|
|
187475
|
-
|
|
187476
|
-
// src/core/constants.ts
|
|
187477
|
-
var DEFAULT_AGENT_TIMEOUT_MS = 120000;
|
|
187478
|
-
var RAW_OUTPUT_MAX_CHARS = 16384;
|
|
187479
|
-
var KYOSO_CHILD_AGENT = "KYOSO_CHILD_AGENT";
|
|
187480
|
-
|
|
187481
|
-
// src/security/sanitizeText.ts
|
|
187482
|
-
var SENSITIVE_TEXT_PATTERNS = [
|
|
187483
|
-
/\bsk-(?:proj-)?[A-Za-z0-9_-]{8,}\b/g,
|
|
187484
|
-
/\bsk-ant-[A-Za-z0-9_-]{8,}\b/g,
|
|
187485
|
-
/\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9_]{8,}\b/g,
|
|
187486
|
-
/\bAKIA[0-9A-Z]{8,}\b/g,
|
|
187487
|
-
/\bxox[baprs]-[A-Za-z0-9-]{8,}\b/g,
|
|
187488
|
-
/\bsk_(?:live|test)_[A-Za-z0-9]{8,}\b/g,
|
|
187489
|
-
/\b(?:api[_-]?key|secret|token|password)\b\s*[:=]\s*["']?[A-Za-z0-9_./+=-]{8,}["']?/gi
|
|
187490
|
-
];
|
|
187491
|
-
function sanitizeText(value) {
|
|
187492
|
-
return SENSITIVE_TEXT_PATTERNS.reduce((text, pattern) => text.replace(pattern, REDACTION), value);
|
|
187493
|
-
}
|
|
187494
|
-
function sanitizeTextForDisplay(value, maxChars = 240) {
|
|
187495
|
-
const compact = sanitizeText(value).replace(/\s+/g, " ").trim();
|
|
187496
|
-
if (compact.length <= maxChars)
|
|
187497
|
-
return compact;
|
|
187498
|
-
return `${compact.slice(0, Math.max(0, maxChars - 3))}...`;
|
|
187499
|
-
}
|
|
187500
|
-
function sanitizeTextForRawOutput(value, maxChars = RAW_OUTPUT_MAX_CHARS) {
|
|
187501
|
-
const sanitized = sanitizeText(value);
|
|
187502
|
-
const limit = Math.max(0, maxChars);
|
|
187503
|
-
if (sanitized.length <= limit)
|
|
187504
|
-
return sanitized;
|
|
187505
|
-
return `${sanitized.slice(0, limit)}
|
|
187506
|
-
[KYOSO_TRUNCATED: ${sanitized.length - limit} chars omitted]`;
|
|
187507
|
-
}
|
|
187508
|
-
|
|
187509
188826
|
// src/utils/env.ts
|
|
187510
188827
|
var MINIMAL_ENV_KEYS = [
|
|
187511
188828
|
"PATH",
|
|
@@ -187685,7 +189002,7 @@ function isSeverity(value) {
|
|
|
187685
189002
|
return typeof value === "string" && severities.includes(value);
|
|
187686
189003
|
}
|
|
187687
189004
|
function normalizeCisaSecureByDesign(value) {
|
|
187688
|
-
if (!
|
|
189005
|
+
if (!isRecord5(value))
|
|
187689
189006
|
return;
|
|
187690
189007
|
const normalized = {};
|
|
187691
189008
|
const customerSecurityOutcomes = normalizeGateStatus(value.customerSecurityOutcomes);
|
|
@@ -187726,7 +189043,7 @@ function normalizeFindingFiles(value) {
|
|
|
187726
189043
|
if (!Array.isArray(value))
|
|
187727
189044
|
return;
|
|
187728
189045
|
const files = value.flatMap((item) => {
|
|
187729
|
-
if (!
|
|
189046
|
+
if (!isRecord5(item) || typeof item.path !== "string" || item.path.trim().length === 0) {
|
|
187730
189047
|
return [];
|
|
187731
189048
|
}
|
|
187732
189049
|
const file2 = {
|
|
@@ -187745,7 +189062,7 @@ function normalizeFindingFiles(value) {
|
|
|
187745
189062
|
function normalizeLineNumber(value) {
|
|
187746
189063
|
return typeof value === "number" && Number.isSafeInteger(value) && value > 0 ? value : undefined;
|
|
187747
189064
|
}
|
|
187748
|
-
function
|
|
189065
|
+
function isRecord5(value) {
|
|
187749
189066
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
187750
189067
|
}
|
|
187751
189068
|
|
|
@@ -187933,7 +189250,7 @@ async function readWorkspaceFile(workspaceDir, requestedPath, line, limit) {
|
|
|
187933
189250
|
const readablePath = await resolveReadableFile(workspaceRoot, absolute);
|
|
187934
189251
|
if (!readablePath)
|
|
187935
189252
|
continue;
|
|
187936
|
-
content = await
|
|
189253
|
+
content = await readFile4(readablePath, "utf8").catch(() => {
|
|
187937
189254
|
return;
|
|
187938
189255
|
});
|
|
187939
189256
|
if (content !== undefined)
|
|
@@ -188686,7 +190003,7 @@ function normalizeTitle(value) {
|
|
|
188686
190003
|
|
|
188687
190004
|
// src/audit/trace.ts
|
|
188688
190005
|
import { mkdir as mkdir2, appendFile } from "node:fs/promises";
|
|
188689
|
-
import { dirname as dirname3, isAbsolute as isAbsolute2, join as
|
|
190006
|
+
import { dirname as dirname3, isAbsolute as isAbsolute2, join as join3 } from "node:path";
|
|
188690
190007
|
|
|
188691
190008
|
// src/context/pathPolicy.ts
|
|
188692
190009
|
import { normalize, sep } from "node:path";
|
|
@@ -188780,7 +190097,7 @@ function createTraceWriter(options) {
|
|
|
188780
190097
|
}
|
|
188781
190098
|
const date5 = new Date().toISOString().slice(0, 10);
|
|
188782
190099
|
const directory = validateAuditDirectory(options.directory, warnings);
|
|
188783
|
-
const tracePath =
|
|
190100
|
+
const tracePath = join3(options.cwd, directory, date5, `${options.traceId}.jsonl`);
|
|
188784
190101
|
return {
|
|
188785
190102
|
tracePath,
|
|
188786
190103
|
warnings,
|
|
@@ -188961,6 +190278,10 @@ function renderMarkdownResult(tool, result, options = {}) {
|
|
|
188961
190278
|
lines.push(...result.testsToAdd.length > 0 ? result.testsToAdd.map((test) => `- ${test}`) : ["- None."]);
|
|
188962
190279
|
lines.push("", "## Residual Risks", "");
|
|
188963
190280
|
lines.push(...result.residualRisks.length > 0 ? result.residualRisks.map((risk) => `- ${risk}`) : ["- None."]);
|
|
190281
|
+
if (result.audit.warnings && result.audit.warnings.length > 0) {
|
|
190282
|
+
lines.push("", "## Warnings", "");
|
|
190283
|
+
lines.push(...result.audit.warnings.map((warning) => `- ${escapeMarkdownText(warning)}`));
|
|
190284
|
+
}
|
|
188964
190285
|
if (result.crossModelAnalysis) {
|
|
188965
190286
|
lines.push("", "## Cross-Model Analysis", "");
|
|
188966
190287
|
if (result.reviewMode === "single_agent") {
|
|
@@ -189025,6 +190346,9 @@ function formatVerification(finding) {
|
|
|
189025
190346
|
function formatList(items) {
|
|
189026
190347
|
return items.length > 0 ? items.map((item) => `- ${item}`) : ["- None."];
|
|
189027
190348
|
}
|
|
190349
|
+
function escapeMarkdownText(value) {
|
|
190350
|
+
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replace(/[\r\n]+/g, " ").replace(/([\\`*_{}\[\]()#+!|])/g, "\\$1");
|
|
190351
|
+
}
|
|
189028
190352
|
|
|
189029
190353
|
// src/judge/prompt.ts
|
|
189030
190354
|
var ANALYSIS_MAX_ITEMS = 5;
|
|
@@ -189074,7 +190398,7 @@ function parseJudgeOutput(text, fallbackSummaryText) {
|
|
|
189074
190398
|
const parsed = JSON.parse(json2);
|
|
189075
190399
|
const summaryText = typeof parsed.summaryText === "string" && parsed.summaryText.trim().length > 0 ? sanitizeText(parsed.summaryText) : fallbackSummaryText;
|
|
189076
190400
|
const disagreementComments = Array.isArray(parsed.disagreementComments) ? parsed.disagreementComments.flatMap((item) => {
|
|
189077
|
-
if (!
|
|
190401
|
+
if (!isRecord6(item) || typeof item.topic !== "string" || typeof item.judgeComment !== "string") {
|
|
189078
190402
|
return [];
|
|
189079
190403
|
}
|
|
189080
190404
|
return [
|
|
@@ -189090,7 +190414,7 @@ function parseJudgeOutput(text, fallbackSummaryText) {
|
|
|
189090
190414
|
return { summaryText, disagreementComments, analysis };
|
|
189091
190415
|
}
|
|
189092
190416
|
function parseAnalysis(value) {
|
|
189093
|
-
if (!
|
|
190417
|
+
if (!isRecord6(value))
|
|
189094
190418
|
return;
|
|
189095
190419
|
if (!Array.isArray(value.blindSpots) || !Array.isArray(value.contradictions) || !Array.isArray(value.partialCoverage)) {
|
|
189096
190420
|
return;
|
|
@@ -189098,7 +190422,7 @@ function parseAnalysis(value) {
|
|
|
189098
190422
|
return {
|
|
189099
190423
|
blindSpots: value.blindSpots.slice(0, ANALYSIS_MAX_ITEMS).flatMap((item) => typeof item === "string" ? [sanitizeAnalysisText(item)] : []),
|
|
189100
190424
|
contradictions: value.contradictions.slice(0, ANALYSIS_MAX_ITEMS).flatMap((item) => {
|
|
189101
|
-
if (!
|
|
190425
|
+
if (!isRecord6(item) || typeof item.topic !== "string" || typeof item.detail !== "string") {
|
|
189102
190426
|
return [];
|
|
189103
190427
|
}
|
|
189104
190428
|
return [
|
|
@@ -189109,7 +190433,7 @@ function parseAnalysis(value) {
|
|
|
189109
190433
|
];
|
|
189110
190434
|
}),
|
|
189111
190435
|
partialCoverage: value.partialCoverage.slice(0, ANALYSIS_MAX_ITEMS).flatMap((item) => {
|
|
189112
|
-
if (!
|
|
190436
|
+
if (!isRecord6(item) || typeof item.note !== "string")
|
|
189113
190437
|
return [];
|
|
189114
190438
|
const findingId = typeof item.findingId === "string" ? sanitizeAnalysisText(item.findingId) : undefined;
|
|
189115
190439
|
return [
|
|
@@ -189156,7 +190480,7 @@ function extractFirstJsonObject2(text) {
|
|
|
189156
190480
|
}
|
|
189157
190481
|
return;
|
|
189158
190482
|
}
|
|
189159
|
-
function
|
|
190483
|
+
function isRecord6(value) {
|
|
189160
190484
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
189161
190485
|
}
|
|
189162
190486
|
|
|
@@ -189492,12 +190816,12 @@ function decide(input) {
|
|
|
189492
190816
|
|
|
189493
190817
|
// src/workspace/createSnapshot.ts
|
|
189494
190818
|
import { chmod, mkdir as mkdir3, mkdtemp, writeFile as writeFile2 } from "node:fs/promises";
|
|
189495
|
-
import { dirname as dirname4, join as
|
|
190819
|
+
import { dirname as dirname4, join as join4 } from "node:path";
|
|
189496
190820
|
import { tmpdir } from "node:os";
|
|
189497
190821
|
async function createSnapshot(traceId, tool, request, options = {}) {
|
|
189498
|
-
const root = await mkdtemp(
|
|
189499
|
-
const repoDir =
|
|
189500
|
-
const contextDir =
|
|
190822
|
+
const root = await mkdtemp(join4(tmpdir(), `kyoso-${traceId}-`));
|
|
190823
|
+
const repoDir = join4(root, "repo");
|
|
190824
|
+
const contextDir = join4(root, "context");
|
|
189501
190825
|
await mkdir3(repoDir, { recursive: true });
|
|
189502
190826
|
await mkdir3(contextDir, { recursive: true });
|
|
189503
190827
|
let fileCount = 0;
|
|
@@ -189507,7 +190831,7 @@ async function createSnapshot(traceId, tool, request, options = {}) {
|
|
|
189507
190831
|
continue;
|
|
189508
190832
|
if (!isAllowedPath(relative2, options.allowPatterns ?? []))
|
|
189509
190833
|
continue;
|
|
189510
|
-
const dest =
|
|
190834
|
+
const dest = join4(repoDir, relative2);
|
|
189511
190835
|
await mkdir3(dirname4(dest), { recursive: true });
|
|
189512
190836
|
await writeFile2(dest, file2.content, "utf8");
|
|
189513
190837
|
await chmod(dest, 292).catch(() => {
|
|
@@ -189515,16 +190839,16 @@ async function createSnapshot(traceId, tool, request, options = {}) {
|
|
|
189515
190839
|
});
|
|
189516
190840
|
fileCount += 1;
|
|
189517
190841
|
}
|
|
189518
|
-
await writeFile2(
|
|
189519
|
-
await writeFile2(
|
|
189520
|
-
await writeFile2(
|
|
189521
|
-
await writeFile2(
|
|
190842
|
+
await writeFile2(join4(contextDir, "request.json"), JSON.stringify(stripContents(request), null, 2), "utf8");
|
|
190843
|
+
await writeFile2(join4(contextDir, "selected_files_manifest.json"), JSON.stringify(buildSelectedFilesManifest(request), null, 2), "utf8");
|
|
190844
|
+
await writeFile2(join4(contextDir, "instructions.codex.md"), buildAgentPrompt(tool, request, "codex", options.agentRoles?.codex ?? "implementation_reviewer"), "utf8");
|
|
190845
|
+
await writeFile2(join4(contextDir, "instructions.claude.md"), buildAgentPrompt(tool, request, "claude", options.agentRoles?.claude ?? "architecture_security_reviewer"), "utf8");
|
|
189522
190846
|
if (request.repoSummary)
|
|
189523
|
-
await writeFile2(
|
|
190847
|
+
await writeFile2(join4(contextDir, "repo_summary.md"), request.repoSummary, "utf8");
|
|
189524
190848
|
if (request.currentPlan)
|
|
189525
|
-
await writeFile2(
|
|
190849
|
+
await writeFile2(join4(contextDir, "current_plan.md"), request.currentPlan, "utf8");
|
|
189526
190850
|
if (request.diff?.unifiedDiff)
|
|
189527
|
-
await writeFile2(
|
|
190851
|
+
await writeFile2(join4(contextDir, "diff.patch"), request.diff.unifiedDiff, "utf8");
|
|
189528
190852
|
return { root, repoDir, contextDir, fileCount };
|
|
189529
190853
|
}
|
|
189530
190854
|
function stripContents(request) {
|
|
@@ -189614,7 +190938,7 @@ function parseVerificationVerdicts(rawText) {
|
|
|
189614
190938
|
if (!Array.isArray(parsed.verdicts))
|
|
189615
190939
|
return;
|
|
189616
190940
|
return parsed.verdicts.flatMap((item) => {
|
|
189617
|
-
if (!
|
|
190941
|
+
if (!isRecord7(item))
|
|
189618
190942
|
return [];
|
|
189619
190943
|
if (typeof item.findingId !== "string")
|
|
189620
190944
|
return [];
|
|
@@ -189692,7 +191016,7 @@ function verificationNote(reasoning) {
|
|
|
189692
191016
|
function isVerdict(value) {
|
|
189693
191017
|
return value === "confirmed" || value === "refuted" || value === "uncertain";
|
|
189694
191018
|
}
|
|
189695
|
-
function
|
|
191019
|
+
function isRecord7(value) {
|
|
189696
191020
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
189697
191021
|
}
|
|
189698
191022
|
|
|
@@ -189745,14 +191069,17 @@ async function runReview(tool, request, options = {}) {
|
|
|
189745
191069
|
config: options.config,
|
|
189746
191070
|
configHash: options.configHash,
|
|
189747
191071
|
configTrustStatus: "trusted",
|
|
191072
|
+
sources: [],
|
|
189748
191073
|
warnings: []
|
|
189749
191074
|
} : await loadConfig({
|
|
189750
191075
|
cwd,
|
|
189751
191076
|
configPath: options.configPath,
|
|
189752
191077
|
ignoreConfig: options.ignoreConfig,
|
|
189753
191078
|
trustConfig: options.trustConfig,
|
|
191079
|
+
allowUnknownConfig: options.allowUnknownConfig,
|
|
189754
191080
|
promptForTrust: options.promptForTrust,
|
|
189755
191081
|
trustStorePath: options.trustStorePath,
|
|
191082
|
+
env: options.env,
|
|
189756
191083
|
trustPrompt: options.trustPrompt
|
|
189757
191084
|
});
|
|
189758
191085
|
const trace = createTraceWriter({
|
|
@@ -189775,6 +191102,7 @@ async function runReview(tool, request, options = {}) {
|
|
|
189775
191102
|
traceId,
|
|
189776
191103
|
configHash: loaded.configHash,
|
|
189777
191104
|
configPath: loaded.configPath,
|
|
191105
|
+
configSources: loaded.sources,
|
|
189778
191106
|
configTrustStatus: loaded.configTrustStatus,
|
|
189779
191107
|
timestamp: new Date().toISOString()
|
|
189780
191108
|
});
|