@bouncesecurity/aghast 0.4.4-alpha.1 → 0.5.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/config/prompts/general-vuln-discovery.md +7 -3
- package/dist/build-config.d.ts +15 -0
- package/dist/build-config.d.ts.map +1 -0
- package/dist/build-config.js +568 -0
- package/dist/build-config.js.map +1 -0
- package/dist/check-library.d.ts.map +1 -1
- package/dist/check-library.js +4 -1
- package/dist/check-library.js.map +1 -1
- package/dist/check-types.d.ts +1 -1
- package/dist/check-types.d.ts.map +1 -1
- package/dist/claude-code-provider.d.ts +6 -4
- package/dist/claude-code-provider.d.ts.map +1 -1
- package/dist/claude-code-provider.js +86 -51
- package/dist/claude-code-provider.js.map +1 -1
- package/dist/cli.js +8 -2
- package/dist/cli.js.map +1 -1
- package/dist/colors.js +4 -4
- package/dist/colors.js.map +1 -1
- package/dist/defaults.d.ts +21 -0
- package/dist/defaults.d.ts.map +1 -0
- package/dist/defaults.js +21 -0
- package/dist/defaults.js.map +1 -0
- package/dist/discoveries/openant-discovery.d.ts.map +1 -1
- package/dist/discoveries/openant-discovery.js +3 -2
- package/dist/discoveries/openant-discovery.js.map +1 -1
- package/dist/discoveries/sarif-discovery.d.ts.map +1 -1
- package/dist/discoveries/sarif-discovery.js +2 -1
- package/dist/discoveries/sarif-discovery.js.map +1 -1
- package/dist/discoveries/semgrep-discovery.d.ts.map +1 -1
- package/dist/discoveries/semgrep-discovery.js +11 -2
- package/dist/discoveries/semgrep-discovery.js.map +1 -1
- package/dist/discovery.d.ts +8 -2
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +8 -0
- package/dist/discovery.js.map +1 -1
- package/dist/error-codes.d.ts +2 -1
- package/dist/error-codes.d.ts.map +1 -1
- package/dist/error-codes.js +8 -3
- package/dist/error-codes.js.map +1 -1
- package/dist/formatters/types.d.ts +1 -1
- package/dist/formatters/types.js +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +92 -79
- package/dist/index.js.map +1 -1
- package/dist/logging.d.ts.map +1 -1
- package/dist/logging.js +36 -9
- package/dist/logging.js.map +1 -1
- package/dist/{mock-ai-provider.d.ts → mock-agent-provider.d.ts} +5 -5
- package/dist/mock-agent-provider.d.ts.map +1 -0
- package/dist/{mock-ai-provider.js → mock-agent-provider.js} +3 -3
- package/dist/mock-agent-provider.js.map +1 -0
- package/dist/new-check.js +2 -2
- package/dist/new-check.js.map +1 -1
- package/dist/openant-runner.d.ts +5 -2
- package/dist/openant-runner.d.ts.map +1 -1
- package/dist/openant-runner.js +12 -9
- package/dist/openant-runner.js.map +1 -1
- package/dist/opencode-provider.d.ts +65 -0
- package/dist/opencode-provider.d.ts.map +1 -0
- package/dist/opencode-provider.js +541 -0
- package/dist/opencode-provider.js.map +1 -0
- package/dist/prompt-template.d.ts.map +1 -1
- package/dist/prompt-template.js +2 -1
- package/dist/prompt-template.js.map +1 -1
- package/dist/provider-registry.d.ts +6 -6
- package/dist/provider-registry.d.ts.map +1 -1
- package/dist/provider-registry.js +6 -4
- package/dist/provider-registry.js.map +1 -1
- package/dist/provider-utils.d.ts +52 -0
- package/dist/provider-utils.d.ts.map +1 -0
- package/dist/provider-utils.js +40 -0
- package/dist/provider-utils.js.map +1 -0
- package/dist/response-parser.d.ts +8 -6
- package/dist/response-parser.d.ts.map +1 -1
- package/dist/response-parser.js +8 -6
- package/dist/response-parser.js.map +1 -1
- package/dist/runtime-config.d.ts +4 -4
- package/dist/runtime-config.d.ts.map +1 -1
- package/dist/runtime-config.js +15 -8
- package/dist/runtime-config.js.map +1 -1
- package/dist/scan-runner.d.ts +4 -4
- package/dist/scan-runner.d.ts.map +1 -1
- package/dist/scan-runner.js +99 -42
- package/dist/scan-runner.js.map +1 -1
- package/dist/types.d.ts +34 -7
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +3 -3
- package/dist/types.js.map +1 -1
- package/package.json +5 -3
- package/dist/mock-ai-provider.d.ts.map +0 -1
- package/dist/mock-ai-provider.js.map +0 -1
|
@@ -18,13 +18,14 @@ For each code unit, ask yourself:
|
|
|
18
18
|
- What can an attacker control? (request body, URL params, headers, query strings)
|
|
19
19
|
- Where does that input end up? (database queries, HTTP requests, file operations, authorization decisions)
|
|
20
20
|
- What guarantees does the code assume but not enforce? (atomicity, ownership, trust boundaries, data types)
|
|
21
|
-
- Are multi-step operations safe if executed concurrently by multiple users?
|
|
21
|
+
- Are multi-step operations safe if executed concurrently by multiple users? (check-then-act on shared state — stock, balances, quotas, uniqueness — without `FOR UPDATE`, transactions, or atomic conditional updates is a TOCTOU race)
|
|
22
|
+
- Are security-sensitive values (password reset tokens, session IDs, API keys, CSRF tokens, invitation codes, one-time codes) generated with cryptographically secure randomness? `Math.random()`, `Date.now()`, timestamps, or PIDs are predictable and unsafe for anything that gates authentication or authorization.
|
|
22
23
|
|
|
23
24
|
BEFORE REPORTING — VALIDATE EACH FINDING:
|
|
24
25
|
|
|
25
26
|
Before including any issue in your response, you MUST be able to answer YES to all of these:
|
|
26
|
-
1. Can I construct a specific HTTP request (or sequence of requests) that triggers this vulnerability?
|
|
27
|
-
2. After the exploit, what specific harm has occurred? Name ONE of: unauthorized data accessed, unauthorized action performed, authentication/authorization bypassed, server made to contact an attacker-controlled or internal endpoint, arbitrary code/query executed.
|
|
27
|
+
1. Can I construct a specific HTTP request (or sequence of requests) that triggers this vulnerability? For race conditions, two or more concurrent requests count as a valid "sequence" — you do not need a single-request exploit.
|
|
28
|
+
2. After the exploit, what specific harm has occurred? Name ONE of: unauthorized data accessed, unauthorized action performed, authentication/authorization bypassed (including via predictable security tokens that gate auth, e.g. reset tokens generated from `Math.random()`), server made to contact an attacker-controlled or internal endpoint, arbitrary code/query executed, or financial/inventory state corrupted in a way an attacker can exploit for value (e.g. overselling limited stock, double-spending balance, bypassing quota). Pure data-quality bugs (wrong types, missing length checks) with no security or value consequence are NOT findings.
|
|
28
29
|
3. Does the exploit work against THIS codebase as written — including all middleware, route registrations, and existing validation? Do not ignore protections that exist outside the function body (e.g., middleware applied at route registration time).
|
|
29
30
|
|
|
30
31
|
If you cannot answer YES to all three, do not report the issue.
|
|
@@ -37,6 +38,9 @@ Only report vulnerabilities that meet ALL of these criteria:
|
|
|
37
38
|
- The vulnerability exists in the code AS WRITTEN — do not speculate about missing features, future code, or how the code might be used differently
|
|
38
39
|
- The impact is demonstrated end-to-end in THIS codebase — not dependent on hypothetical downstream consumers of stored data
|
|
39
40
|
|
|
41
|
+
EXCEPTION — predictable security tokens:
|
|
42
|
+
The "end-to-end demonstration" and "no hypothetical downstream consumer" rules above DO NOT apply when code generates a value with a predictable source (`Math.random()`, `Date.now()`, timestamps, counters, non-CSPRNG hashes) AND the value's name or surrounding context indicates it functions as a credential or capability (reset/recovery tokens, session IDs, API keys, OTPs, magic links, CSRF tokens, invitation codes, etc.). Naming and intent are sufficient evidence — you do not need to find the consumer in this codebase. Report at the generation site; treat the harm as "authentication/authorization bypassed via predictable token". This exception applies only to values whose purpose is to authenticate a user, authorise an action, or establish a recoverable session — NOT to identifiers used purely for logging, tracing, or UI rendering, even if their names contain "token", "id", or "key".
|
|
43
|
+
|
|
40
44
|
Do NOT report:
|
|
41
45
|
- Missing input validation that has no security impact (e.g., missing length checks, type checks, or negative number checks unless they lead to a specific exploit like bypassing authorization)
|
|
42
46
|
- Information disclosure via error messages (e.g., leaking product names or stock counts in error responses) unless it exposes credentials or secrets
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI utility for building / editing a runtime-config.json file.
|
|
3
|
+
*
|
|
4
|
+
* Interactive by default; flag-only mode skips prompts. If a config file
|
|
5
|
+
* already exists, its values are loaded and used as defaults — only the
|
|
6
|
+
* fields you change (or pass as flags) are updated.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* aghast build-config --config-dir <path> # interactive, file at <path>/runtime-config.json
|
|
10
|
+
* aghast build-config --runtime-config <file> # interactive, write to explicit file
|
|
11
|
+
* aghast build-config --config-dir <path> --provider claude-code --model sonnet # non-interactive
|
|
12
|
+
* aghast build-config --config-dir <path> --non-interactive # accept all current/defaults
|
|
13
|
+
*/
|
|
14
|
+
export declare function runBuildConfig(args: string[]): Promise<void>;
|
|
15
|
+
//# sourceMappingURL=build-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-config.d.ts","sourceRoot":"","sources":["../src/build-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AA4XH,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAkOlE"}
|
|
@@ -0,0 +1,568 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI utility for building / editing a runtime-config.json file.
|
|
3
|
+
*
|
|
4
|
+
* Interactive by default; flag-only mode skips prompts. If a config file
|
|
5
|
+
* already exists, its values are loaded and used as defaults — only the
|
|
6
|
+
* fields you change (or pass as flags) are updated.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* aghast build-config --config-dir <path> # interactive, file at <path>/runtime-config.json
|
|
10
|
+
* aghast build-config --runtime-config <file> # interactive, write to explicit file
|
|
11
|
+
* aghast build-config --config-dir <path> --provider claude-code --model sonnet # non-interactive
|
|
12
|
+
* aghast build-config --config-dir <path> --non-interactive # accept all current/defaults
|
|
13
|
+
*/
|
|
14
|
+
import { writeFile, mkdir, access } from 'node:fs/promises';
|
|
15
|
+
import { resolve, dirname } from 'node:path';
|
|
16
|
+
import { createInterface } from 'node:readline/promises';
|
|
17
|
+
import { stdin, stdout } from 'node:process';
|
|
18
|
+
import { createRequire } from 'node:module';
|
|
19
|
+
import { ERROR_CODES, formatError, formatFatalError } from './error-codes.js';
|
|
20
|
+
import { loadRuntimeConfig } from './runtime-config.js';
|
|
21
|
+
import { createProviderByName, getProviderNames, DEFAULT_PROVIDER_NAME } from './provider-registry.js';
|
|
22
|
+
import { getAvailableFormats } from './formatters/index.js';
|
|
23
|
+
import { getAvailableLogTypes, isValidLogLevel, getLogLevel, setLogLevel } from './logging.js';
|
|
24
|
+
import { DEFAULT_MODEL } from './types.js';
|
|
25
|
+
import { DEFAULT_OUTPUT_FORMAT, DEFAULT_LOG_LEVEL, DEFAULT_LOG_TYPE, DEFAULT_GENERIC_PROMPT, DEFAULT_FAIL_ON_CHECK_FAILURE, } from './defaults.js';
|
|
26
|
+
/** Defaults shown in interactive prompts so users know what they'd get by leaving a field unset.
|
|
27
|
+
* Sourced from the same constants the scanner uses at runtime — no duplication. */
|
|
28
|
+
const SCAN_DEFAULTS = {
|
|
29
|
+
provider: DEFAULT_PROVIDER_NAME,
|
|
30
|
+
model: DEFAULT_MODEL,
|
|
31
|
+
outputFormat: DEFAULT_OUTPUT_FORMAT,
|
|
32
|
+
outputDirectory: '<repo-path>', // No constant — derived at runtime from the scanned repo path
|
|
33
|
+
logLevel: DEFAULT_LOG_LEVEL,
|
|
34
|
+
logType: DEFAULT_LOG_TYPE,
|
|
35
|
+
genericPrompt: DEFAULT_GENERIC_PROMPT,
|
|
36
|
+
failOnCheckFailure: DEFAULT_FAIL_ON_CHECK_FAILURE,
|
|
37
|
+
};
|
|
38
|
+
const VALID_LOG_LEVELS = ['error', 'warn', 'info', 'debug', 'trace'];
|
|
39
|
+
const VALID_BOOLS = ['true', 'false'];
|
|
40
|
+
const FLAG_MAP = {
|
|
41
|
+
'--config-dir': 'configDir',
|
|
42
|
+
'--runtime-config': 'runtimeConfig',
|
|
43
|
+
'--provider': 'provider',
|
|
44
|
+
'--model': 'model',
|
|
45
|
+
'--output-format': 'outputFormat',
|
|
46
|
+
'--output-directory': 'outputDirectory',
|
|
47
|
+
'--log-level': 'logLevel',
|
|
48
|
+
'--log-file': 'logFile',
|
|
49
|
+
'--log-type': 'logType',
|
|
50
|
+
'--generic-prompt': 'genericPrompt',
|
|
51
|
+
'--fail-on-check-failure': 'failOnCheckFailure',
|
|
52
|
+
};
|
|
53
|
+
const KNOWN_FLAGS = new Set([...Object.keys(FLAG_MAP), '--non-interactive', '--clear', '--help', '-h']);
|
|
54
|
+
function parseFlags(args) {
|
|
55
|
+
const flags = {};
|
|
56
|
+
const clear = [];
|
|
57
|
+
for (let i = 0; i < args.length; i++) {
|
|
58
|
+
const arg = args[i];
|
|
59
|
+
if (arg === '--non-interactive') {
|
|
60
|
+
flags.nonInteractive = true;
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (arg === '--clear') {
|
|
64
|
+
const value = args[i + 1];
|
|
65
|
+
if (value === undefined || value.startsWith('--')) {
|
|
66
|
+
console.error(formatError(ERROR_CODES.E1001, '--clear requires a field name'));
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
69
|
+
clear.push(value);
|
|
70
|
+
i++;
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
const key = FLAG_MAP[arg];
|
|
74
|
+
if (key) {
|
|
75
|
+
const value = args[i + 1];
|
|
76
|
+
if (value === undefined || value.startsWith('--')) {
|
|
77
|
+
console.error(formatError(ERROR_CODES.E1001, `${arg} requires a value`));
|
|
78
|
+
process.exit(1);
|
|
79
|
+
}
|
|
80
|
+
flags[key] = value;
|
|
81
|
+
i++;
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
if (arg.startsWith('--') || arg.startsWith('-')) {
|
|
85
|
+
// Unknown option — fail fast instead of silently ignoring (catches typos like `--outpt-format`).
|
|
86
|
+
const known = [...KNOWN_FLAGS].sort().join(', ');
|
|
87
|
+
console.error(formatError(ERROR_CODES.E1001, `Unknown option "${arg}". Known: ${known}`));
|
|
88
|
+
process.exit(1);
|
|
89
|
+
}
|
|
90
|
+
// Bare positional args are not used by build-config.
|
|
91
|
+
console.error(formatError(ERROR_CODES.E1001, `Unexpected positional argument "${arg}"`));
|
|
92
|
+
process.exit(1);
|
|
93
|
+
}
|
|
94
|
+
if (clear.length > 0) {
|
|
95
|
+
flags.clear = clear;
|
|
96
|
+
}
|
|
97
|
+
return flags;
|
|
98
|
+
}
|
|
99
|
+
const HELP = `Usage: aghast build-config [options]
|
|
100
|
+
|
|
101
|
+
Build or edit a runtime-config.json file. Interactive by default; pass --non-interactive
|
|
102
|
+
or any value flags to skip prompts. If the target file already exists, its values are
|
|
103
|
+
loaded as defaults — only fields you change are updated.
|
|
104
|
+
|
|
105
|
+
Target file:
|
|
106
|
+
--config-dir <path> Write to <path>/runtime-config.json (created if missing)
|
|
107
|
+
--runtime-config <path> Write to an explicit file path
|
|
108
|
+
(one of these is required; --runtime-config wins if both
|
|
109
|
+
are given)
|
|
110
|
+
|
|
111
|
+
Field flags (any value provided here skips its prompt; closed lists are validated):
|
|
112
|
+
--provider <name> Agent provider name (e.g. claude-code)
|
|
113
|
+
--model <id> Model ID. Must be one returned by the provider's
|
|
114
|
+
listModels() (skip flag and use interactive mode to
|
|
115
|
+
browse the live list).
|
|
116
|
+
--output-format <fmt> Output format: json | sarif
|
|
117
|
+
--output-directory <path> Default output directory for results
|
|
118
|
+
--log-level <level> Console log level: error | warn | info | debug | trace
|
|
119
|
+
--log-file <path> Log file path (omit to disable)
|
|
120
|
+
--log-type <type> Log file handler type (default: file)
|
|
121
|
+
--generic-prompt <file> Generic prompt template filename
|
|
122
|
+
--fail-on-check-failure <b> true | false
|
|
123
|
+
|
|
124
|
+
Mode flags:
|
|
125
|
+
--non-interactive Don't prompt — use existing values / defaults / flags only
|
|
126
|
+
--clear <field> Remove a field from the config. May be repeated.
|
|
127
|
+
Fields: provider, model, outputFormat, outputDirectory,
|
|
128
|
+
logLevel, logFile, logType, genericPrompt,
|
|
129
|
+
failOnCheckFailure
|
|
130
|
+
-h, --help Show this help message
|
|
131
|
+
|
|
132
|
+
Examples:
|
|
133
|
+
aghast build-config --config-dir ./my-checks
|
|
134
|
+
aghast build-config --config-dir ./my-checks --provider claude-code --model sonnet --non-interactive
|
|
135
|
+
aghast build-config --runtime-config ./prod.json --output-format sarif --fail-on-check-failure true
|
|
136
|
+
aghast build-config --config-dir ./my-checks --clear logFile --clear genericPrompt`;
|
|
137
|
+
const CLEARABLE_FIELDS = new Set([
|
|
138
|
+
'provider',
|
|
139
|
+
'model',
|
|
140
|
+
'outputFormat',
|
|
141
|
+
'outputDirectory',
|
|
142
|
+
'logLevel',
|
|
143
|
+
'logFile',
|
|
144
|
+
'logType',
|
|
145
|
+
'genericPrompt',
|
|
146
|
+
'failOnCheckFailure',
|
|
147
|
+
]);
|
|
148
|
+
async function fileExists(path) {
|
|
149
|
+
try {
|
|
150
|
+
await access(path);
|
|
151
|
+
return true;
|
|
152
|
+
}
|
|
153
|
+
catch {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function configToFlatDefaults(config) {
|
|
158
|
+
return {
|
|
159
|
+
provider: config.agentProvider?.name,
|
|
160
|
+
model: config.agentProvider?.model,
|
|
161
|
+
outputFormat: config.reporting?.outputFormat,
|
|
162
|
+
outputDirectory: config.reporting?.outputDirectory,
|
|
163
|
+
logLevel: config.logging?.level,
|
|
164
|
+
logFile: config.logging?.logFile,
|
|
165
|
+
logType: config.logging?.logType,
|
|
166
|
+
genericPrompt: config.genericPrompt,
|
|
167
|
+
failOnCheckFailure: config.failOnCheckFailure,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
function buildConfig(values) {
|
|
171
|
+
const config = {};
|
|
172
|
+
if (values.provider !== undefined || values.model !== undefined) {
|
|
173
|
+
config.agentProvider = {};
|
|
174
|
+
if (values.provider !== undefined)
|
|
175
|
+
config.agentProvider.name = values.provider;
|
|
176
|
+
if (values.model !== undefined)
|
|
177
|
+
config.agentProvider.model = values.model;
|
|
178
|
+
}
|
|
179
|
+
if (values.outputFormat !== undefined || values.outputDirectory !== undefined) {
|
|
180
|
+
config.reporting = {};
|
|
181
|
+
if (values.outputFormat !== undefined)
|
|
182
|
+
config.reporting.outputFormat = values.outputFormat;
|
|
183
|
+
if (values.outputDirectory !== undefined)
|
|
184
|
+
config.reporting.outputDirectory = values.outputDirectory;
|
|
185
|
+
}
|
|
186
|
+
if (values.logLevel !== undefined || values.logFile !== undefined || values.logType !== undefined) {
|
|
187
|
+
config.logging = {};
|
|
188
|
+
if (values.logLevel !== undefined)
|
|
189
|
+
config.logging.level = values.logLevel;
|
|
190
|
+
if (values.logFile !== undefined)
|
|
191
|
+
config.logging.logFile = values.logFile;
|
|
192
|
+
if (values.logType !== undefined)
|
|
193
|
+
config.logging.logType = values.logType;
|
|
194
|
+
}
|
|
195
|
+
if (values.genericPrompt !== undefined)
|
|
196
|
+
config.genericPrompt = values.genericPrompt;
|
|
197
|
+
if (values.failOnCheckFailure !== undefined)
|
|
198
|
+
config.failOnCheckFailure = values.failOnCheckFailure;
|
|
199
|
+
return config;
|
|
200
|
+
}
|
|
201
|
+
async function getProviderModels(providerName) {
|
|
202
|
+
const provider = createProviderByName(providerName);
|
|
203
|
+
// Silence provider progress logs ("Starting OpenCode server...", etc.) during the
|
|
204
|
+
// throwaway init/teardown used to fetch the model list. The user is in an interactive
|
|
205
|
+
// picker and doesn't need to see transient server lifecycle noise. Errors still surface
|
|
206
|
+
// via thrown exceptions, which the caller catches and reports.
|
|
207
|
+
const savedLevel = getLogLevel();
|
|
208
|
+
setLogLevel('silent');
|
|
209
|
+
try {
|
|
210
|
+
// Honor the AgentProvider contract — initialize() before any other method call.
|
|
211
|
+
// We intentionally pass an empty config so the provider falls back to env vars (e.g.
|
|
212
|
+
// ANTHROPIC_API_KEY). For providers like Claude Code that require either a key or
|
|
213
|
+
// AGHAST_LOCAL_CLAUDE=true, initialization may throw — let it propagate so callers
|
|
214
|
+
// can catch and degrade (e.g. fall back to free-text model entry).
|
|
215
|
+
await provider.initialize({});
|
|
216
|
+
if (!provider.listModels) {
|
|
217
|
+
return [];
|
|
218
|
+
}
|
|
219
|
+
return await provider.listModels();
|
|
220
|
+
}
|
|
221
|
+
finally {
|
|
222
|
+
// Providers that start subprocesses/servers (e.g. OpenCode) must be cleaned up,
|
|
223
|
+
// or the process leaks resources until Node exits. cleanup() is documented to be
|
|
224
|
+
// safe on partially-initialized providers. No-op for providers without cleanup.
|
|
225
|
+
await provider.cleanup?.();
|
|
226
|
+
setLogLevel(savedLevel);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
/** Memoising fetcher — call once per (providerName, run) and re-use the result.
|
|
230
|
+
*
|
|
231
|
+
* Note: this caches the Promise itself, including rejections. That's intentional —
|
|
232
|
+
* if the SDK call fails (e.g. no API key, no local Claude session), we want subsequent
|
|
233
|
+
* lookups within the same run to hit the cached failure rather than retrying and
|
|
234
|
+
* spamming the user with the same warning twice (once interactively, once during
|
|
235
|
+
* validation). Both call sites already handle the rejection by warning + degrading. */
|
|
236
|
+
function makeModelFetcher() {
|
|
237
|
+
const cache = new Map();
|
|
238
|
+
return (name) => {
|
|
239
|
+
if (!cache.has(name)) {
|
|
240
|
+
cache.set(name, getProviderModels(name));
|
|
241
|
+
}
|
|
242
|
+
return cache.get(name);
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
function formatModelChoice(m) {
|
|
246
|
+
const parts = [m.id];
|
|
247
|
+
if (m.label && m.label !== m.id)
|
|
248
|
+
parts.push(`— ${m.label}`);
|
|
249
|
+
if (m.description)
|
|
250
|
+
parts.push(`· ${m.description}`);
|
|
251
|
+
return parts.join(' ');
|
|
252
|
+
}
|
|
253
|
+
function createPromptHelpers() {
|
|
254
|
+
const rl = createInterface({ input: stdin, output: stdout });
|
|
255
|
+
function emptyHint(builtInDefault) {
|
|
256
|
+
if (builtInDefault !== undefined && builtInDefault !== '') {
|
|
257
|
+
return ` (Enter to leave unset — default: ${builtInDefault})`;
|
|
258
|
+
}
|
|
259
|
+
return ' (Enter to leave unset)';
|
|
260
|
+
}
|
|
261
|
+
function setHint() {
|
|
262
|
+
return ' (Enter to keep, "-" to clear)';
|
|
263
|
+
}
|
|
264
|
+
async function ask(label, current, builtInDefault) {
|
|
265
|
+
if (current === undefined || current === '') {
|
|
266
|
+
const answer = (await rl.question(`${label}${emptyHint(builtInDefault)}: `)).trim();
|
|
267
|
+
if (answer === '' || answer === '-')
|
|
268
|
+
return undefined;
|
|
269
|
+
return answer;
|
|
270
|
+
}
|
|
271
|
+
const annotations = [`current: ${current}`];
|
|
272
|
+
if (builtInDefault !== undefined && builtInDefault !== '' && builtInDefault !== current) {
|
|
273
|
+
annotations.push(`default if cleared: ${builtInDefault}`);
|
|
274
|
+
}
|
|
275
|
+
const answer = (await rl.question(`${label} [${annotations.join(', ')}]${setHint()}: `)).trim();
|
|
276
|
+
if (answer === '')
|
|
277
|
+
return current;
|
|
278
|
+
if (answer === '-')
|
|
279
|
+
return undefined;
|
|
280
|
+
return answer;
|
|
281
|
+
}
|
|
282
|
+
async function askChoice(label, choices, current, builtInDefault) {
|
|
283
|
+
if (choices.length === 0) {
|
|
284
|
+
return ask(label, current, builtInDefault);
|
|
285
|
+
}
|
|
286
|
+
const hasCurrent = current !== undefined && choices.includes(current);
|
|
287
|
+
const numbered = choices
|
|
288
|
+
.map((c, i) => {
|
|
289
|
+
const annotations = [];
|
|
290
|
+
if (hasCurrent && c === current)
|
|
291
|
+
annotations.push('current');
|
|
292
|
+
if (builtInDefault !== undefined && c === builtInDefault)
|
|
293
|
+
annotations.push('default');
|
|
294
|
+
return ` ${i + 1}) ${c}${annotations.length > 0 ? ` (${annotations.join(', ')})` : ''}`;
|
|
295
|
+
})
|
|
296
|
+
.join('\n');
|
|
297
|
+
// For numbered choices, the "(default)" annotation in the list above is enough —
|
|
298
|
+
// don't duplicate it in the hint (Enter doesn't pick the default anyway).
|
|
299
|
+
const hint = hasCurrent ? setHint() : ' (Enter to leave unset)';
|
|
300
|
+
for (let attempt = 0; attempt < 3; attempt++) {
|
|
301
|
+
const answer = (await rl.question(`${label}:\n${numbered}\nChoice${hint}: `)).trim();
|
|
302
|
+
if (answer === '')
|
|
303
|
+
return hasCurrent ? current : undefined;
|
|
304
|
+
if (answer === '-')
|
|
305
|
+
return undefined;
|
|
306
|
+
const byNumber = parseInt(answer, 10);
|
|
307
|
+
if (!isNaN(byNumber) && byNumber >= 1 && byNumber <= choices.length) {
|
|
308
|
+
return choices[byNumber - 1];
|
|
309
|
+
}
|
|
310
|
+
if (choices.includes(answer))
|
|
311
|
+
return answer;
|
|
312
|
+
console.error(`Invalid choice "${answer}". Enter a number 1-${choices.length} or the value.`);
|
|
313
|
+
}
|
|
314
|
+
throw new Error(`No valid choice for "${label}" after 3 attempts`);
|
|
315
|
+
}
|
|
316
|
+
async function askBool(label, current, builtInDefault) {
|
|
317
|
+
const choice = await askChoice(label, VALID_BOOLS, current === undefined ? undefined : String(current), builtInDefault === undefined ? undefined : String(builtInDefault));
|
|
318
|
+
if (choice === undefined)
|
|
319
|
+
return undefined;
|
|
320
|
+
return choice === 'true';
|
|
321
|
+
}
|
|
322
|
+
return { ask, askChoice, askBool, close: () => rl.close() };
|
|
323
|
+
}
|
|
324
|
+
function validateAgainst(label, value, allowed) {
|
|
325
|
+
if (value === undefined)
|
|
326
|
+
return;
|
|
327
|
+
if (!allowed.includes(value)) {
|
|
328
|
+
throw new Error(`Invalid ${label} "${value}". Must be one of: ${allowed.join(', ')}`);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
export async function runBuildConfig(args) {
|
|
332
|
+
if (args.includes('--help') || args.includes('-h')) {
|
|
333
|
+
console.log(HELP);
|
|
334
|
+
process.exit(0);
|
|
335
|
+
}
|
|
336
|
+
const flags = parseFlags(args);
|
|
337
|
+
// Validate --clear field names early
|
|
338
|
+
if (flags.clear) {
|
|
339
|
+
for (const field of flags.clear) {
|
|
340
|
+
if (!CLEARABLE_FIELDS.has(field)) {
|
|
341
|
+
console.error(formatError(ERROR_CODES.E1001, `Unknown --clear field "${field}". Valid fields: ${[...CLEARABLE_FIELDS].join(', ')}`));
|
|
342
|
+
process.exit(1);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
// Resolve target file path
|
|
347
|
+
let targetPath;
|
|
348
|
+
if (flags.runtimeConfig) {
|
|
349
|
+
targetPath = resolve(flags.runtimeConfig);
|
|
350
|
+
}
|
|
351
|
+
else if (flags.configDir) {
|
|
352
|
+
targetPath = resolve(flags.configDir, 'runtime-config.json');
|
|
353
|
+
}
|
|
354
|
+
else if (process.env.AGHAST_CONFIG_DIR) {
|
|
355
|
+
targetPath = resolve(process.env.AGHAST_CONFIG_DIR, 'runtime-config.json');
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
console.error(formatError(ERROR_CODES.E2001, 'One of --config-dir or --runtime-config is required (or set AGHAST_CONFIG_DIR).'));
|
|
359
|
+
process.exit(1);
|
|
360
|
+
}
|
|
361
|
+
// Load existing config (or empty)
|
|
362
|
+
const exists = await fileExists(targetPath);
|
|
363
|
+
let existing = {};
|
|
364
|
+
if (exists) {
|
|
365
|
+
try {
|
|
366
|
+
existing = await loadRuntimeConfig(undefined, targetPath);
|
|
367
|
+
console.log(`Loaded existing config from ${targetPath}`);
|
|
368
|
+
}
|
|
369
|
+
catch (err) {
|
|
370
|
+
console.error(formatError(ERROR_CODES.E2005, err instanceof Error ? err.message : String(err)));
|
|
371
|
+
process.exit(1);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
else {
|
|
375
|
+
console.log(`No existing config at ${targetPath} — creating new one.`);
|
|
376
|
+
}
|
|
377
|
+
const defaults = configToFlatDefaults(existing);
|
|
378
|
+
// Validate provider flag if given (so we can fetch model list)
|
|
379
|
+
if (flags.provider !== undefined) {
|
|
380
|
+
const known = getProviderNames();
|
|
381
|
+
if (!known.includes(flags.provider)) {
|
|
382
|
+
console.error(formatError(ERROR_CODES.E3002, `Unknown provider "${flags.provider}". Known: ${known.join(', ')}`));
|
|
383
|
+
process.exit(1);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
const interactive = !flags.nonInteractive
|
|
387
|
+
&& (process.stdin.isTTY ?? false);
|
|
388
|
+
// Reject conflicting --clear <field> + --<field> <value>: ambiguous intent.
|
|
389
|
+
// `field` here is already validated against CLEARABLE_FIELDS (which never contains
|
|
390
|
+
// 'clear' or 'nonInteractive'), so `flags[field]` only resolves to value-bearing flags.
|
|
391
|
+
if (flags.clear) {
|
|
392
|
+
const conflicts = [];
|
|
393
|
+
for (const field of flags.clear) {
|
|
394
|
+
if (flags[field] !== undefined) {
|
|
395
|
+
conflicts.push(field);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
if (conflicts.length > 0) {
|
|
399
|
+
const list = conflicts.map((f) => `--clear ${f} and --${f.replace(/([A-Z])/g, '-$1').toLowerCase()}`).join(', ');
|
|
400
|
+
console.error(formatError(ERROR_CODES.E1001, `Conflicting flags: ${list}. Use one or the other for each field.`));
|
|
401
|
+
process.exit(1);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
const result = { ...defaults };
|
|
405
|
+
// Apply --clear first
|
|
406
|
+
if (flags.clear) {
|
|
407
|
+
for (const field of flags.clear) {
|
|
408
|
+
result[field] = undefined;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
// Apply explicit flag values
|
|
412
|
+
if (flags.provider !== undefined)
|
|
413
|
+
result.provider = flags.provider;
|
|
414
|
+
if (flags.outputFormat !== undefined)
|
|
415
|
+
result.outputFormat = flags.outputFormat;
|
|
416
|
+
if (flags.outputDirectory !== undefined)
|
|
417
|
+
result.outputDirectory = flags.outputDirectory;
|
|
418
|
+
if (flags.logLevel !== undefined)
|
|
419
|
+
result.logLevel = flags.logLevel;
|
|
420
|
+
if (flags.logFile !== undefined)
|
|
421
|
+
result.logFile = flags.logFile;
|
|
422
|
+
if (flags.logType !== undefined)
|
|
423
|
+
result.logType = flags.logType;
|
|
424
|
+
if (flags.genericPrompt !== undefined)
|
|
425
|
+
result.genericPrompt = flags.genericPrompt;
|
|
426
|
+
if (flags.failOnCheckFailure !== undefined) {
|
|
427
|
+
if (!VALID_BOOLS.includes(flags.failOnCheckFailure)) {
|
|
428
|
+
console.error(formatError(ERROR_CODES.E1001, `Invalid --fail-on-check-failure "${flags.failOnCheckFailure}". Must be true or false.`));
|
|
429
|
+
process.exit(1);
|
|
430
|
+
}
|
|
431
|
+
result.failOnCheckFailure = flags.failOnCheckFailure === 'true';
|
|
432
|
+
}
|
|
433
|
+
// Model is applied last, after we have a resolved provider, so we can validate against listModels
|
|
434
|
+
const pendingModelFlag = flags.model;
|
|
435
|
+
// Cache provider→models lookups so we never call the SDK twice in one run.
|
|
436
|
+
const fetchModels = makeModelFetcher();
|
|
437
|
+
// Interactive prompts (only for fields not set by flags)
|
|
438
|
+
if (interactive) {
|
|
439
|
+
const helpers = createPromptHelpers();
|
|
440
|
+
try {
|
|
441
|
+
const providers = getProviderNames();
|
|
442
|
+
if (flags.provider === undefined) {
|
|
443
|
+
result.provider = await helpers.askChoice('Agent provider', providers, result.provider, SCAN_DEFAULTS.provider);
|
|
444
|
+
}
|
|
445
|
+
// Resolve provider for model listing — fall back to default only for the SDK call,
|
|
446
|
+
// not as a faked "current" value in the prompt above.
|
|
447
|
+
const providerForModels = result.provider ?? DEFAULT_PROVIDER_NAME;
|
|
448
|
+
let availableModels = [];
|
|
449
|
+
if (providers.includes(providerForModels)) {
|
|
450
|
+
try {
|
|
451
|
+
availableModels = await fetchModels(providerForModels);
|
|
452
|
+
}
|
|
453
|
+
catch (err) {
|
|
454
|
+
console.error(`Warning: could not fetch model list from "${providerForModels}": ${err instanceof Error ? err.message : String(err)}`);
|
|
455
|
+
console.error('Falling back to free-text model entry.');
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
if (pendingModelFlag === undefined) {
|
|
459
|
+
if (availableModels.length === 0) {
|
|
460
|
+
result.model = await helpers.ask('AI model', result.model, SCAN_DEFAULTS.model);
|
|
461
|
+
}
|
|
462
|
+
else {
|
|
463
|
+
const labels = availableModels.map(formatModelChoice);
|
|
464
|
+
// Match by id (not string-prefix on labels) — labels may include description text
|
|
465
|
+
// that could collide with another model's id.
|
|
466
|
+
const currentIdx = result.model
|
|
467
|
+
? availableModels.findIndex((m) => m.id === result.model)
|
|
468
|
+
: -1;
|
|
469
|
+
const defaultIdx = availableModels.findIndex((m) => m.id === SCAN_DEFAULTS.model);
|
|
470
|
+
const currentLabel = currentIdx >= 0 ? labels[currentIdx] : undefined;
|
|
471
|
+
const defaultLabel = defaultIdx >= 0 ? labels[defaultIdx] : undefined;
|
|
472
|
+
const chosen = await helpers.askChoice('AI model (from provider SDK)', labels, currentLabel, defaultLabel);
|
|
473
|
+
if (chosen === undefined) {
|
|
474
|
+
result.model = undefined;
|
|
475
|
+
}
|
|
476
|
+
else {
|
|
477
|
+
const idx = labels.indexOf(chosen);
|
|
478
|
+
result.model = idx >= 0 ? availableModels[idx].id : chosen;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
if (flags.outputFormat === undefined) {
|
|
483
|
+
result.outputFormat = await helpers.askChoice('Output format', getAvailableFormats(), result.outputFormat, SCAN_DEFAULTS.outputFormat);
|
|
484
|
+
}
|
|
485
|
+
if (flags.outputDirectory === undefined) {
|
|
486
|
+
result.outputDirectory = await helpers.ask('Output directory', result.outputDirectory, SCAN_DEFAULTS.outputDirectory);
|
|
487
|
+
}
|
|
488
|
+
if (flags.logLevel === undefined) {
|
|
489
|
+
result.logLevel = await helpers.askChoice('Log level', VALID_LOG_LEVELS, result.logLevel, SCAN_DEFAULTS.logLevel);
|
|
490
|
+
}
|
|
491
|
+
if (flags.logFile === undefined) {
|
|
492
|
+
result.logFile = await helpers.ask('Log file path', result.logFile);
|
|
493
|
+
}
|
|
494
|
+
if (flags.logType === undefined) {
|
|
495
|
+
const logTypes = getAvailableLogTypes();
|
|
496
|
+
result.logType = await helpers.askChoice('Log type', logTypes, result.logType, SCAN_DEFAULTS.logType);
|
|
497
|
+
}
|
|
498
|
+
if (flags.genericPrompt === undefined) {
|
|
499
|
+
result.genericPrompt = await helpers.ask('Generic prompt template filename', result.genericPrompt, SCAN_DEFAULTS.genericPrompt);
|
|
500
|
+
}
|
|
501
|
+
if (flags.failOnCheckFailure === undefined) {
|
|
502
|
+
result.failOnCheckFailure = await helpers.askBool('Fail on check failure', result.failOnCheckFailure, SCAN_DEFAULTS.failOnCheckFailure);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
catch (err) {
|
|
506
|
+
// Includes "No valid choice for X after N attempts" — surface as a usage error.
|
|
507
|
+
// process.exit terminates synchronously without running pending finally blocks,
|
|
508
|
+
// so the readline handle is left for the OS to reclaim on this path. That's fine —
|
|
509
|
+
// the process is dying anyway. The finally below only runs on the happy path.
|
|
510
|
+
console.error(formatError(ERROR_CODES.E1003, err instanceof Error ? err.message : String(err)));
|
|
511
|
+
process.exit(1);
|
|
512
|
+
}
|
|
513
|
+
finally {
|
|
514
|
+
helpers.close();
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
// Apply pending model flag now (after interactive may have changed provider)
|
|
518
|
+
if (pendingModelFlag !== undefined) {
|
|
519
|
+
result.model = pendingModelFlag;
|
|
520
|
+
}
|
|
521
|
+
// Validate selections against closed lists
|
|
522
|
+
try {
|
|
523
|
+
if (result.provider !== undefined) {
|
|
524
|
+
validateAgainst('provider', result.provider, getProviderNames());
|
|
525
|
+
}
|
|
526
|
+
if (result.model !== undefined) {
|
|
527
|
+
const providerForValidation = result.provider ?? DEFAULT_PROVIDER_NAME;
|
|
528
|
+
if (getProviderNames().includes(providerForValidation)) {
|
|
529
|
+
try {
|
|
530
|
+
const allowed = await fetchModels(providerForValidation);
|
|
531
|
+
if (allowed.length > 0) {
|
|
532
|
+
const allowedIds = allowed.map((m) => m.id);
|
|
533
|
+
validateAgainst(`model for provider "${providerForValidation}"`, result.model, allowedIds);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
catch (err) {
|
|
537
|
+
console.error(`Warning: skipped model validation — could not fetch model list: ${err instanceof Error ? err.message : String(err)}`);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
validateAgainst('output format', result.outputFormat, getAvailableFormats());
|
|
542
|
+
if (result.logLevel !== undefined && !isValidLogLevel(result.logLevel)) {
|
|
543
|
+
throw new Error(`Invalid log level "${result.logLevel}". Must be one of: ${VALID_LOG_LEVELS.join(', ')}`);
|
|
544
|
+
}
|
|
545
|
+
validateAgainst('log type', result.logType, getAvailableLogTypes());
|
|
546
|
+
}
|
|
547
|
+
catch (err) {
|
|
548
|
+
console.error(formatError(ERROR_CODES.E2005, err instanceof Error ? err.message : String(err)));
|
|
549
|
+
process.exit(1);
|
|
550
|
+
}
|
|
551
|
+
const finalConfig = buildConfig(result);
|
|
552
|
+
// Bootstrap parent directory if needed
|
|
553
|
+
await mkdir(dirname(targetPath), { recursive: true });
|
|
554
|
+
await writeFile(targetPath, JSON.stringify(finalConfig, null, 2) + '\n', 'utf-8');
|
|
555
|
+
console.log(`\nWrote runtime config to ${targetPath}`);
|
|
556
|
+
}
|
|
557
|
+
// Auto-run when executed directly, but not when imported by cli.ts.
|
|
558
|
+
if (!process.env._AGHAST_CLI) {
|
|
559
|
+
await import('dotenv/config');
|
|
560
|
+
runBuildConfig(process.argv.slice(2)).catch((err) => {
|
|
561
|
+
const require = createRequire(import.meta.url);
|
|
562
|
+
const pkg = require('../package.json');
|
|
563
|
+
console.error('');
|
|
564
|
+
console.error(formatFatalError(err instanceof Error ? err.message : String(err), pkg.version));
|
|
565
|
+
process.exit(1);
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
//# sourceMappingURL=build-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-config.js","sourceRoot":"","sources":["../src/build-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,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