Files
orca/src/cli/agent-context.ts
T
Jinwoo-H c46a06032e feat(cli): name the Orca that owns a workspace 'server'
orca server ... replaces orca environment ... and orca host name; --server and
--parent-server replace --environment and --parent-environment. Old spellings
stay accepted as input only: help, suggestions, errors and printed commands use
the new names, and giving both spellings different values is invalid_argument.
--host is still parsed but leaves help; orca host list/rm are hidden.

Listings name each row's owning server (server: / server=) from data already
returned, mapping a stored owner to a saved-server name only from this
computer's own store, and print server=unknown instead of guessing local. The
ports footer and search hits drop host=. CLI-built JSON uses server keys
(server, address.server, parent.server, unknown-server, servers, knownServers,
status target kind server). create/set print the same parent line as ps.
2026-11-09 02:12:19 -05:00

61 lines
1.9 KiB
TypeScript

import type { CommandSpec } from './args'
import { effectiveAllowedFlags } from './args'
import { INPUT_ONLY_FLAGS } from './command-spec'
const SCHEMA_VERSION = 1
export type AgentContextCommand = {
command: string
path: string[]
aliases: string[][]
argumentMode: 'parsed' | 'passthrough'
summary: string
usage: string
flags: string[]
positionalArgs: string[]
variadicPositional?: boolean
repeatableFlags?: string[]
examples: string[]
notes: string[]
}
export type AgentContextSchema = {
schemaVersion: number
commandCount: number
commands: AgentContextCommand[]
}
export function buildAgentContext(specs: CommandSpec[]): AgentContextSchema {
const commands = specs
// Hidden commands dispatch but stay off discovery surfaces.
.filter((spec) => spec.hidden !== true)
.map((spec) => ({
command: spec.path.join(' '),
path: spec.path,
aliases: spec.aliases ?? [],
argumentMode: spec.argumentMode ?? 'parsed',
summary: spec.summary,
usage: spec.usage,
// Include globals and conditional flags so discovery matches validation.
flags: effectiveAllowedFlags(spec).filter((flag) => !INPUT_ONLY_FLAGS.has(flag)),
positionalArgs: spec.positionalArgs ?? [],
...(spec.variadicPositional ? { variadicPositional: true } : {}),
...(spec.repeatableFlags ? { repeatableFlags: spec.repeatableFlags } : {}),
examples: spec.examples ?? [],
notes: spec.notes ?? []
}))
.sort((a, b) => a.command.localeCompare(b.command))
return {
schemaVersion: SCHEMA_VERSION,
commandCount: commands.length,
commands
}
}
export function formatAgentContextSummary(schema: AgentContextSchema): string {
return [
`${schema.commandCount} commands (schema v${schema.schemaVersion}).`,
'Run `orca agent-context --json` for the full machine-readable command schema.'
].join('\n')
}