* fix(cli): don't recover benign typos into destructive commands CLI did-you-mean ranked purely by Levenshtein, so `orca worktree move` sole-suggested `orca worktree remove` (distance 2) — an alias of the destructive `worktree rm`. Suggestions also flow into --json error.data.nextSteps, the agent recovery channel, so a blind retry could delete a clean worktree. Make destructiveness a declared property of the command instead of a verb heuristic: add `destructive?: true` to CommandSpec and mark the irreversible commands (worktree rm, environment rm, automations remove, project setup-delete, tab profile delete, cookie delete, storage local/session clear). The suggestion ranker excludes destructive candidates unless the input token is itself a near-miss (distance <=1) of a destructive verb, so `worktree remov` still recovers `rm`/`remove` while `worktree move` no longer does. The guard tracks the registry, so it also covers destructive verbs outside the delete family (e.g. kill). Fixes #6303 Co-authored-by: Orca <help@stably.ai> * fix(cli): use Array.at(-1) to satisfy oxlint prefer-at Co-authored-by: Orca <help@stably.ai> --------- Co-authored-by: Orca <help@stably.ai>
116 lines
4.5 KiB
TypeScript
116 lines
4.5 KiB
TypeScript
import type { CommandSpec } from '../args'
|
|
import { GLOBAL_FLAGS } from '../args'
|
|
|
|
const AUTOMATION_TARGET_FLAGS = [
|
|
'repo',
|
|
'workspace',
|
|
'project',
|
|
'host',
|
|
'project-host-setup',
|
|
'source-context',
|
|
'workspace-mode',
|
|
'base-branch'
|
|
]
|
|
const AUTOMATION_SCHEDULE_FLAGS = ['trigger', 'schedule', 'time', 'day', 'timezone']
|
|
const AUTOMATION_PRECHECK_FLAGS = ['precheck', 'precheck-timeout']
|
|
const AUTOMATION_STATE_FLAGS = [
|
|
'enabled',
|
|
'disabled',
|
|
'missed-run-grace-minutes',
|
|
'reuse-session',
|
|
'fresh-session'
|
|
]
|
|
|
|
export const AUTOMATION_COMMAND_SPECS: CommandSpec[] = [
|
|
{
|
|
path: ['automations', 'list'],
|
|
summary: 'List scheduled Orca automations',
|
|
usage: 'orca automations list [--json]',
|
|
allowedFlags: [...GLOBAL_FLAGS],
|
|
examples: ['orca automations list', 'orca automations list --json']
|
|
},
|
|
{
|
|
path: ['automations', 'show'],
|
|
summary: 'Show one Orca automation',
|
|
usage: 'orca automations show <id> [--json]',
|
|
allowedFlags: [...GLOBAL_FLAGS, 'id'],
|
|
positionalArgs: ['id'],
|
|
examples: ['orca automations show 2f9e...', 'orca automations show --id 2f9e... --json']
|
|
},
|
|
{
|
|
path: ['automations', 'create'],
|
|
summary: 'Create a scheduled Orca automation',
|
|
usage:
|
|
'orca automations create --name <name> --trigger <preset|cron|rrule> --prompt <text> --provider <agent> [--precheck <command>] [--repo <selector>|--workspace <selector>|--project <id> [--host <id>]|--project-host-setup <id>] [--json]',
|
|
allowedFlags: [
|
|
...GLOBAL_FLAGS,
|
|
'name',
|
|
'prompt',
|
|
'provider',
|
|
...AUTOMATION_PRECHECK_FLAGS,
|
|
...AUTOMATION_TARGET_FLAGS,
|
|
...AUTOMATION_SCHEDULE_FLAGS,
|
|
...AUTOMATION_STATE_FLAGS
|
|
],
|
|
notes: [
|
|
'Trigger accepts hourly, daily, weekdays, weekly, a 5-field cron expression, or an RRULE string.',
|
|
'When --repo is omitted, the CLI uses the enclosing Orca worktree when one can be resolved from cwd.',
|
|
'Use --project with --host, or --project-host-setup, to run on a specific project host setup.',
|
|
'Use --source-context with a JSON TaskSourceContext when task/provider data should come from a specific host/account; pass null on edit to clear it.',
|
|
'Use --workspace to run in an existing worktree; otherwise the automation creates a new worktree per run.',
|
|
'Use --precheck to run a bounded command before scheduled runs; exit code 0 continues, anything else records a skipped run.',
|
|
'Use --reuse-session only with existing-workspace automations to submit later runs to the previous live automation session when it is still available. Use --fresh-session to disable reuse.'
|
|
],
|
|
examples: [
|
|
'orca automations create --name "Daily review" --trigger daily --prompt "Review open changes" --provider codex',
|
|
'orca automations create --name "Weekday triage" --trigger "0 9 * * 1-5" --prompt "Triage issues" --provider claude --repo my-repo',
|
|
'orca automations create --name "PR review" --trigger hourly --precheck "gh pr list --json number -q .[0].number" --prompt "Review requested PRs" --provider codex'
|
|
]
|
|
},
|
|
{
|
|
path: ['automations', 'edit'],
|
|
summary: 'Edit an Orca automation',
|
|
usage: 'orca automations edit <id> [--name <name>] [--trigger <preset|cron|rrule>] [--json]',
|
|
allowedFlags: [
|
|
...GLOBAL_FLAGS,
|
|
'id',
|
|
'name',
|
|
'prompt',
|
|
'provider',
|
|
...AUTOMATION_PRECHECK_FLAGS,
|
|
...AUTOMATION_TARGET_FLAGS,
|
|
...AUTOMATION_SCHEDULE_FLAGS,
|
|
...AUTOMATION_STATE_FLAGS
|
|
],
|
|
positionalArgs: ['id'],
|
|
examples: [
|
|
'orca automations edit 2f9e... --disabled',
|
|
'orca automations edit --id 2f9e... --trigger "30 * * * *" --json'
|
|
]
|
|
},
|
|
{
|
|
path: ['automations', 'remove'],
|
|
destructive: true,
|
|
summary: 'Remove an Orca automation and its run history',
|
|
usage: 'orca automations remove <id> [--json]',
|
|
allowedFlags: [...GLOBAL_FLAGS, 'id'],
|
|
positionalArgs: ['id'],
|
|
examples: ['orca automations remove 2f9e...', 'orca automations remove --id 2f9e... --json']
|
|
},
|
|
{
|
|
path: ['automations', 'run'],
|
|
summary: 'Run an Orca automation now',
|
|
usage: 'orca automations run <id> [--json]',
|
|
allowedFlags: [...GLOBAL_FLAGS, 'id'],
|
|
positionalArgs: ['id'],
|
|
examples: ['orca automations run 2f9e...', 'orca automations run --id 2f9e... --json']
|
|
},
|
|
{
|
|
path: ['automations', 'runs'],
|
|
summary: 'List automation run history',
|
|
usage: 'orca automations runs [--id <automation-id>] [--json]',
|
|
allowedFlags: [...GLOBAL_FLAGS, 'id'],
|
|
examples: ['orca automations runs', 'orca automations runs --id 2f9e... --json']
|
|
}
|
|
]
|