mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-05-11 05:00:07 +00:00
Restructure the repo as a Bun workspace monorepo: - Move cli/ → packages/cli/ - Create packages/shared/ (@openrouter/spawn-shared) with type-guards and parse utilities - Add root package.json with workspace configuration - Update all CLI imports to use @openrouter/spawn-shared - Deduplicate toRecord/toObjectArray helpers from 4 cloud modules - Update SPA (slack-bot) to use shared package instead of local toObj() - Update 48 agent shell scripts for new packages/cli/ path - Update install.sh, install.ps1, e2e, and test scripts - Update all GitHub workflows, .gitignore, pre-commit hooks - Update CLAUDE.md, README.md, and skill prompt references - Pin all dependency versions (no ^ ranges) - Bump CLI version 0.9.1 → 0.10.0 All 1908 tests pass. Lint clean. All 8 cloud bundles build. Co-authored-by: Claude <claude@anthropic.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
54 lines
1.2 KiB
TypeScript
54 lines
1.2 KiB
TypeScript
/** CLI flag definitions and utilities — single source of truth for flag validation */
|
|
|
|
export const KNOWN_FLAGS = new Set([
|
|
"--help",
|
|
"-h",
|
|
"--version",
|
|
"-v",
|
|
"-V",
|
|
"--prompt",
|
|
"-p",
|
|
"--prompt-file",
|
|
"-f",
|
|
"--dry-run",
|
|
"-n",
|
|
"--debug",
|
|
"--headless",
|
|
"--output",
|
|
"--name",
|
|
"--default",
|
|
"-a",
|
|
"-c",
|
|
"--agent",
|
|
"--cloud",
|
|
"--clear",
|
|
"--custom",
|
|
"--reauth",
|
|
]);
|
|
|
|
/** Return the first unknown flag in args, or null if all are known/positional */
|
|
export function findUnknownFlag(args: string[]): string | null {
|
|
for (const arg of args) {
|
|
if (
|
|
(arg.startsWith("--") || (arg.startsWith("-") && arg.length > 1 && !/^-\d/.test(arg))) &&
|
|
!KNOWN_FLAGS.has(arg)
|
|
) {
|
|
return arg;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
/** Expand --flag=value into --flag value so all flag parsing works uniformly */
|
|
export function expandEqualsFlags(args: string[]): string[] {
|
|
const result: string[] = [];
|
|
for (const arg of args) {
|
|
if (arg.startsWith("--") && arg.includes("=")) {
|
|
const eqIdx = arg.indexOf("=");
|
|
result.push(arg.slice(0, eqIdx), arg.slice(eqIdx + 1));
|
|
} else {
|
|
result.push(arg);
|
|
}
|
|
}
|
|
return result;
|
|
}
|