Files
archived-orca/src/shared/cli-argument-boundary.ts
T
Neil 0df9ea1fbf feat(cloud): org environment builds — desktop: Settings → Cloud environment, live logs, CLI, low-disk banner (#47)
* fix(sandbox-control): read the orgRole claim that Orca Cloud auth mints (#29)

Auth mints the live org role as orgRole on sandbox tokens (same claim as billing
tokens, stablyai/orca-cloud#695); the verifier read org_role, so admins would
never have been recognized.

* wip(cloud): environment builds control plane

* wip(cloud): environment build boot path, staleness, routes

* wip(cloud): env build tests, anonymous staleness fallback

* wip(cloud): migration 0008 (claimed), quieter recovered clone errors

* fix(cloud): env build review: interrupted-snapshot recovery, bounded log reads, secret redaction, activation guard, hook/prelude fixes

* fix(cloud): wait briefly for the build exit code after its log ends; print the base image and package manager

* wip(desktop): org environments client, IPC, CLI, settings UI, orcad disk usage + low-disk banner

* perf(cloud): smoke-boot each environment build before activating it; skip the redundant prelude fetch

* fix(cloud): a GitHub token error fails the build as github_unavailable instead of cloning anonymously

* perf(cloud): warm pool VMs per hot environment build, so a create from an org environment skips the provider boot

* wip(desktop): cloud environment UI round-3 fixes

* fix(cloud): pool-per-build review: smoke race safety, provider hiccups skip smoke, usage-based hot builds with caps, bounded boots, index

* fix(desktop): Configure with an agent hands the prompt over at launch (trust dialog swallowed the pasted Enter); CLI builds table widths

* polish(desktop): W10 P2s — InlineError action slot, shared focus-ring, copy

* feat(cloud): build event stream heartbeat every 20 s

* fix(desktop): FE review — stable virtualizer, shadow-buffer replays, heartbeat-aware build watch, CLI follower restarts, repo import path checks, poll races
2026-11-09 08:03:35 -08:00

131 lines
2.7 KiB
TypeScript

export const CLI_GLOBAL_VALUE_FLAGS: readonly string[] = ['pairing-code', 'environment']
export const CLI_GLOBAL_FLAGS: readonly string[] = ['help', 'json', ...CLI_GLOBAL_VALUE_FLAGS]
export const CLI_BOOLEAN_FLAGS = new Set([
'accept-changed-state',
'agent-wait',
'all',
'allow-failed-archive-hook',
'allow-public',
'annotate',
'attachments',
'check',
'children',
'comments',
'compact',
'connect',
'current',
'current-json',
'current-sqlite',
'debug',
'delete-branch',
'delta',
'dry-run',
'enter',
'focus',
'grant-desktop-control',
'force',
'fresh',
'full',
'full-tree',
'help',
'if-changed',
'inject',
'include-archived',
'include-remote',
'include-visual-layouts',
'index-status',
'interactive',
'interrupt',
'keep-open',
'json',
'latest-json',
'local',
'messages',
'me',
'mobile',
'mobile-pairing',
'no-pairing',
'screen',
'parent-current',
'print',
'provision',
'ready',
'recipe-json',
'refuse-public',
'reclaim-stale-lock',
'references',
'refresh',
'relations',
'relay',
'removed',
'reinstall',
'restore-window',
'return-preamble',
'rotate',
'run-hooks',
'run-setup',
'show-profile',
'staged',
'supervise',
'tab',
'takeover-legacy',
'tasks',
'text-stdin',
'unread',
'urls',
'value-stdin',
'wait',
'yes'
])
function commandPathStartsAt(
argv: readonly string[],
tokenIndex: number,
path: readonly string[]
): boolean {
let cursor = tokenIndex
for (const part of path) {
while (argv[cursor]?.startsWith('--')) {
const assignment = argv[cursor].slice(2)
const flag = assignment.split('=', 1)[0]
cursor += assignment.includes('=') || CLI_BOOLEAN_FLAGS.has(flag) ? 1 : 2
}
if (argv[cursor] !== part) {
return false
}
cursor += 1
}
return true
}
export function findCliCommandIndex(
argv: readonly string[],
commandPaths: readonly (readonly string[])[],
knownValueFlags: readonly string[] = []
): number {
const startsCommandAt = (index: number): boolean =>
commandPaths.some((path) => commandPathStartsAt(argv, index, path))
for (let index = 0; index < argv.length;) {
const token = argv[index]
if (!token.startsWith('--')) {
return startsCommandAt(index) ? index : -1
}
const assignment = token.slice(2)
const flag = assignment.split('=', 1)[0]
const next = argv[index + 1]
const takesNext =
!assignment.includes('=') &&
!CLI_BOOLEAN_FLAGS.has(flag) &&
next !== undefined &&
!next.startsWith('--') &&
(knownValueFlags.includes(flag) ||
!(startsCommandAt(index + 1) && !startsCommandAt(index + 2)))
index += takesNext ? 2 : 1
}
return -1
}