Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"markdownlint-cli2": "^0.22.0",
"tsup": "^8.0.2",
"tsx": "^4.7.1",
"typescript": "^5.9.3",
"typescript": "^6.0.3",
"vitest": "^4.1.2"
},
"license": "Apache-2.0",
Expand Down
11 changes: 8 additions & 3 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1021,9 +1021,11 @@ function exitWithStartupError(error: CliError): never {
process.stdout.write(`${JSON.stringify(payload)}\n`);
}
process.exit(error.exitCode);
throw new Error("Unreachable after process.exit");
}
process.stderr.write(`${error.message}\n`);
process.exit(error.exitCode);
throw new Error("Unreachable after process.exit");
}

function writeOutputOrThrow(content: string, output?: string): void {
Expand Down Expand Up @@ -1064,17 +1066,20 @@ function emitUnhandledCliError(error: unknown): never {
process.stdout.write(`${JSON.stringify(payload)}\n`);
}
process.exit(resolved.exitCode);
throw new Error("Unreachable after process.exit");
}

// Non-JSON mode: agent formatting or plain text
if (agent) {
const help = getErrorHelp(resolved.code, resolved.message);
process.stderr.write(`${formatAgentError(help, true)}\n`);
process.exit(resolved.exitCode);
throw new Error("Unreachable after process.exit");
}

process.stderr.write(`${resolved.message}\n`);
process.exit(resolved.exitCode);
throw new Error("Unreachable after process.exit");
}

const startupArgv = hideBin(process.argv);
Expand Down Expand Up @@ -1143,7 +1148,7 @@ cli
.option("timeout", { type: "number", default: 15000 })
.option("retries", { type: "number", default: 2 })
.option("retry-backoff", { type: "number", default: 400 })
.check((args) => {
.check((args: Arguments) => {
const globals = args as unknown as CliGlobals;
// Always validate URL format (not just when network is enabled)
// This catches invalid URLs even in preview mode
Expand Down Expand Up @@ -1738,7 +1743,7 @@ cli
.recommendCommands()
.demandCommand(1)
.exitProcess(false)
.fail((msg, err, y) => {
.fail((msg: string | null | undefined, err: Error | undefined, y: Argv) => {
const message = err?.message ?? msg ?? "Unexpected error";
const isUsageError =
!err || (err as { name?: string }).name === "YError" || (err instanceof CliError && err.exitCode === 2);
Expand Down Expand Up @@ -1784,4 +1789,4 @@ void (async () => {
} catch (error) {
emitUnhandledCliError(error);
}
})();
})();
7 changes: 4 additions & 3 deletions src/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ function resolveCliVersion(): string {
const envVersion = process.env.npm_package_version?.trim();
if (envVersion) {
cachedVersion = envVersion;
return cachedVersion;
return envVersion;
}

try {
Expand All @@ -109,8 +109,9 @@ function resolveCliVersion(): string {
const raw = fs.readFileSync(packagePath, "utf8");
const parsed = JSON.parse(raw) as { version?: string };
if (parsed.version && parsed.version.trim().length > 0) {
cachedVersion = parsed.version.trim();
return cachedVersion;
const packageVersion = parsed.version.trim();
cachedVersion = packageVersion;
return packageVersion;
}
} catch (error) {
// no-op: fall back to default version
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"exactOptionalPropertyTypes": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
"forceConsistentCasingInFileNames": true,
"types": ["node"]
},
"include": ["src", "tests"]
}
Loading