mirror of
https://github.com/stablyai/orca.git
synced 2026-10-31 00:57:45 +00:00
* Add CLI commands to manage and find workspace references * Fix reference review findings: source-context twins, legacy link collapse, closed chats, old-host errors - Keep same-URL links with different source contexts separate; CLI add/remove no longer drops a twin - Restore merging a bare legacy link into its single matching URL link (no duplicate PR rows, no resurrection on older-client removal) - Carry absorbed data through collapse chains; resolve repoId conflicts deterministically - Identity: ignore www., case-insensitive GitHub/GitLab/Gitea paths (stored URL keeps case), no Jira match on git hosts; find accepts self-hosted issue URLs - reference find: skip closed native chats, require a session id for linked, include an explicitly named archived workspace, warm-cache fallback for --worktree - Selector parity: collapse same-host duplicate paths, issue: ignores unlinked rows - CLI: clear update-host error for hosts without reference.*, local flag checks before host probe, help text fixes * Fix CI: add reference rm alias for verb policy; expect linkedItems in worktree ps summary * Simplify reference CLI: share identifier/legacy-match helpers, drop redundant dedupe
52 lines
2.3 KiB
TypeScript
52 lines
2.3 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { normalizeCommandPositionals, parseArgs, specPaths, validateCommandAndFlags } from './args'
|
|
import { buildAgentContext } from './agent-context'
|
|
import { getRepeatedStringFlag } from './flags'
|
|
import { COMMAND_SPECS } from './specs'
|
|
|
|
function parse(argv: string[]) {
|
|
return normalizeCommandPositionals(
|
|
COMMAND_SPECS,
|
|
parseArgs(argv, COMMAND_SPECS.flatMap(specPaths), COMMAND_SPECS)
|
|
)
|
|
}
|
|
|
|
describe('reference command arguments', () => {
|
|
it('collects variadic URLs around flags without losing or reordering values', () => {
|
|
const parsed = parse(['reference', 'add', 'one', '--worktree', 'name:api', 'two', 'three'])
|
|
validateCommandAndFlags(COMMAND_SPECS, parsed)
|
|
expect(parsed.commandPath).toEqual(['reference', 'add'])
|
|
expect(getRepeatedStringFlag(parsed.flags, 'url')).toEqual(['one', 'two', 'three'])
|
|
})
|
|
|
|
it('accepts repeated remove keys with positional URLs', () => {
|
|
const parsed = parse(['reference', 'remove', 'url', '--key', 'first', '--key', 'second'])
|
|
validateCommandAndFlags(COMMAND_SPECS, parsed)
|
|
expect(getRepeatedStringFlag(parsed.flags, 'url')).toEqual(['url'])
|
|
expect(getRepeatedStringFlag(parsed.flags, 'key')).toEqual(['first', 'second'])
|
|
})
|
|
|
|
it('rejects positional and named forms of the same argument', () => {
|
|
const parsed = parse(['reference', 'add', 'one', 'two', '--url', 'three'])
|
|
expect(() => validateCommandAndFlags(COMMAND_SPECS, parsed)).toThrow('not both')
|
|
})
|
|
|
|
it('does not accept extra arguments on commands without variadic positionals', () => {
|
|
const parsed = parse(['reference', 'find', 'STA-1', 'STA-2'])
|
|
expect(() => validateCommandAndFlags(COMMAND_SPECS, parsed)).toThrow('Unknown command')
|
|
})
|
|
|
|
it('exposes repeatability to agents and excludes browser targeting', () => {
|
|
const schema = buildAgentContext(COMMAND_SPECS)
|
|
const add = schema.commands.find((command) => command.command === 'reference add')
|
|
expect(add).toMatchObject({
|
|
positionalArgs: ['url'],
|
|
variadicPositional: true,
|
|
repeatableFlags: ['url']
|
|
})
|
|
expect(add?.flags).not.toContain('page')
|
|
const create = schema.commands.find((command) => command.command === 'worktree create')
|
|
expect(create?.repeatableFlags).toEqual(['reference'])
|
|
})
|
|
})
|