From 2774aba182bf0abb8c0edbaaf66d5dcad45a0bc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Sun, 13 Sep 2026 17:37:05 +0200 Subject: [PATCH] refactor(command-registry): move CLI flag grammar, text and command aliases down MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the vocabulary that both the CLI and commands read but no command's runtime depends on into the package below both: flag types, registry, groups and the four flag-definitions files, command-text, and cli-command-aliases. These are pure moves; only their import specifiers change. No compat re-export at the old paths — every consumer switches to the owning subpath. The per-command defaults stay where they are for now (the daemon's edge into the facet resolver is the harder cut and belongs with the daemon-closure work). Part of #2545 / #2543. --- docs/agents/cli-flags.md | 3 ++- packages/command-registry/package.json | 20 +++++++++++++++++++ .../src/__tests__}/flag-registry.test.ts | 2 +- .../src}/cli-command-aliases.ts | 0 .../command-registry/src}/command-text.ts | 0 .../src}/flag-definitions-action.ts | 0 .../src}/flag-definitions-connection.ts | 0 .../src}/flag-definitions-target.ts | 0 .../src}/flag-definitions-workflow.ts | 0 .../command-registry/src}/flag-groups.ts | 0 .../command-registry/src}/flag-registry.ts | 0 .../command-registry/src}/flag-types.ts | 0 scripts/integration-progress-model.ts | 2 +- src/__tests__/command-doc-coverage.test.ts | 2 +- src/cli-schema/cli-config.ts | 2 +- .../cli-help-alias-fast-path.test.ts | 2 +- src/cli-schema/cli-help.ts | 4 ++-- src/cli-schema/command-overrides.ts | 2 +- src/cli-schema/command-schema.ts | 6 +++--- src/cli-schema/types.ts | 4 ++-- src/cli-schema/usage.test.ts | 2 +- src/cli.ts | 2 +- src/cli/entry.test.ts | 2 +- .../__tests__/maestro-support-matrix.test.ts | 2 +- src/cli/parser/args.ts | 2 +- .../command-surface-metadata.test.ts | 2 +- src/commands/capture/diff.ts | 2 +- src/commands/capture/snapshot.ts | 2 +- src/commands/capture/wait.ts | 2 +- .../flag-declaration-admission.test.ts | 10 +++++----- src/commands/command-explain.ts | 5 ++++- src/commands/command-flags.ts | 2 +- .../command-input-option-field.test.ts | 9 ++++++--- src/commands/command-input.ts | 4 ++-- src/commands/family/types.ts | 5 ++++- src/commands/interaction/index.ts | 5 ++++- src/commands/management/app.ts | 2 +- src/commands/metro/index.ts | 5 ++++- .../post-action-observation-grammar.ts | 4 ++-- src/commands/replay/index.ts | 2 +- src/mcp/command-tools.ts | 2 +- src/mcp/tool-input-config.ts | 2 +- test/integration/smoke-cli.test.ts | 2 +- 43 files changed, 81 insertions(+), 45 deletions(-) rename {src/commands/cli-grammar => packages/command-registry/src/__tests__}/flag-registry.test.ts (94%) rename {src/commands => packages/command-registry/src}/cli-command-aliases.ts (100%) rename {src/commands => packages/command-registry/src}/command-text.ts (100%) rename {src/commands/cli-grammar => packages/command-registry/src}/flag-definitions-action.ts (100%) rename {src/commands/cli-grammar => packages/command-registry/src}/flag-definitions-connection.ts (100%) rename {src/commands/cli-grammar => packages/command-registry/src}/flag-definitions-target.ts (100%) rename {src/commands/cli-grammar => packages/command-registry/src}/flag-definitions-workflow.ts (100%) rename {src/commands/cli-grammar => packages/command-registry/src}/flag-groups.ts (100%) rename {src/commands/cli-grammar => packages/command-registry/src}/flag-registry.ts (100%) rename {src/commands/cli-grammar => packages/command-registry/src}/flag-types.ts (100%) diff --git a/docs/agents/cli-flags.md b/docs/agents/cli-flags.md index 0ad8553c10..eb1a0c62f6 100644 --- a/docs/agents/cli-flags.md +++ b/docs/agents/cli-flags.md @@ -3,7 +3,8 @@ Thread a flag only through the layers that consume it: 1. `packages/contracts/src/cli-flags.ts`: add to `CliFlags`; add the definition to the matching - `src/commands/cli-grammar/flag-definitions-*.ts` owner and the relevant group in `flag-groups.ts` + `packages/command-registry/src/flag-definitions-*.ts` owner and the relevant group in + `packages/command-registry/src/flag-groups.ts` (for example `SNAPSHOT_FLAGS`). Then update the command family metadata/schema that exposes the flag; find the owner with `rg -n "|supportedFlags|allowedFlags" src/commands src/cli-schema src/cli/parser`. For diff --git a/packages/command-registry/package.json b/packages/command-registry/package.json index cc6e4723d9..c959f6a287 100644 --- a/packages/command-registry/package.json +++ b/packages/command-registry/package.json @@ -70,6 +70,26 @@ "./batch-policy": { "types": "./src/batch-policy.ts", "default": "./src/batch-policy.ts" + }, + "./flag-types": { + "types": "./src/flag-types.ts", + "default": "./src/flag-types.ts" + }, + "./flag-registry": { + "types": "./src/flag-registry.ts", + "default": "./src/flag-registry.ts" + }, + "./flag-groups": { + "types": "./src/flag-groups.ts", + "default": "./src/flag-groups.ts" + }, + "./command-text": { + "types": "./src/command-text.ts", + "default": "./src/command-text.ts" + }, + "./cli-command-aliases": { + "types": "./src/cli-command-aliases.ts", + "default": "./src/cli-command-aliases.ts" } } } diff --git a/src/commands/cli-grammar/flag-registry.test.ts b/packages/command-registry/src/__tests__/flag-registry.test.ts similarity index 94% rename from src/commands/cli-grammar/flag-registry.test.ts rename to packages/command-registry/src/__tests__/flag-registry.test.ts index 7e25223b96..ca74e3d129 100644 --- a/src/commands/cli-grammar/flag-registry.test.ts +++ b/packages/command-registry/src/__tests__/flag-registry.test.ts @@ -1,6 +1,6 @@ import { test } from 'vitest'; import assert from 'node:assert/strict'; -import { getFlagDefinition } from './flag-registry.ts'; +import { getFlagDefinition } from '../flag-registry.ts'; import { PLATFORM_SELECTORS } from '@agent-device/kernel/device'; test('--platform enumValues are derived from the canonical PLATFORM_SELECTORS tuple', () => { diff --git a/src/commands/cli-command-aliases.ts b/packages/command-registry/src/cli-command-aliases.ts similarity index 100% rename from src/commands/cli-command-aliases.ts rename to packages/command-registry/src/cli-command-aliases.ts diff --git a/src/commands/command-text.ts b/packages/command-registry/src/command-text.ts similarity index 100% rename from src/commands/command-text.ts rename to packages/command-registry/src/command-text.ts diff --git a/src/commands/cli-grammar/flag-definitions-action.ts b/packages/command-registry/src/flag-definitions-action.ts similarity index 100% rename from src/commands/cli-grammar/flag-definitions-action.ts rename to packages/command-registry/src/flag-definitions-action.ts diff --git a/src/commands/cli-grammar/flag-definitions-connection.ts b/packages/command-registry/src/flag-definitions-connection.ts similarity index 100% rename from src/commands/cli-grammar/flag-definitions-connection.ts rename to packages/command-registry/src/flag-definitions-connection.ts diff --git a/src/commands/cli-grammar/flag-definitions-target.ts b/packages/command-registry/src/flag-definitions-target.ts similarity index 100% rename from src/commands/cli-grammar/flag-definitions-target.ts rename to packages/command-registry/src/flag-definitions-target.ts diff --git a/src/commands/cli-grammar/flag-definitions-workflow.ts b/packages/command-registry/src/flag-definitions-workflow.ts similarity index 100% rename from src/commands/cli-grammar/flag-definitions-workflow.ts rename to packages/command-registry/src/flag-definitions-workflow.ts diff --git a/src/commands/cli-grammar/flag-groups.ts b/packages/command-registry/src/flag-groups.ts similarity index 100% rename from src/commands/cli-grammar/flag-groups.ts rename to packages/command-registry/src/flag-groups.ts diff --git a/src/commands/cli-grammar/flag-registry.ts b/packages/command-registry/src/flag-registry.ts similarity index 100% rename from src/commands/cli-grammar/flag-registry.ts rename to packages/command-registry/src/flag-registry.ts diff --git a/src/commands/cli-grammar/flag-types.ts b/packages/command-registry/src/flag-types.ts similarity index 100% rename from src/commands/cli-grammar/flag-types.ts rename to packages/command-registry/src/flag-types.ts diff --git a/scripts/integration-progress-model.ts b/scripts/integration-progress-model.ts index 7c1d3f858b..a65593d3ff 100644 --- a/scripts/integration-progress-model.ts +++ b/scripts/integration-progress-model.ts @@ -2,7 +2,7 @@ import fs from 'node:fs'; import path from 'node:path'; import { PUBLIC_COMMANDS } from '@agent-device/command-registry/catalog'; import { listCommandMetadata } from '../src/commands/command-metadata.ts'; -import { getFlagDefinitions } from '../src/commands/cli-grammar/flag-registry.ts'; +import { getFlagDefinitions } from '@agent-device/command-registry/flag-registry'; import { walkFiles } from './lib/walk-files.ts'; const EMPTY_COVERAGE_METRIC = { pct: 0 }; diff --git a/src/__tests__/command-doc-coverage.test.ts b/src/__tests__/command-doc-coverage.test.ts index b54c36a659..6ad7824c54 100644 --- a/src/__tests__/command-doc-coverage.test.ts +++ b/src/__tests__/command-doc-coverage.test.ts @@ -2,7 +2,7 @@ import fs from 'node:fs'; import assert from 'node:assert/strict'; import { describe, test } from 'vitest'; import { PUBLIC_COMMANDS, isKnownCliCommandName } from '@agent-device/command-registry/catalog'; -import { cliCommandAlias } from '../commands/cli-command-aliases.ts'; +import { cliCommandAlias } from '@agent-device/command-registry/cli-command-aliases'; import { getCliCommandSchema } from '../cli-schema/command-schema.ts'; import { buildCommandUsage } from '../cli-schema/usage.ts'; diff --git a/src/cli-schema/cli-config.ts b/src/cli-schema/cli-config.ts index 351e97d4f5..7049e81036 100644 --- a/src/cli-schema/cli-config.ts +++ b/src/cli-schema/cli-config.ts @@ -3,7 +3,7 @@ import fs from 'node:fs'; import path from 'node:path'; import { AppError } from '@agent-device/kernel/errors'; import { mergeDefinedFlags } from './merge-flags.ts'; -import { type FlagKey } from '../commands/cli-grammar/flag-types.ts'; +import { type FlagKey } from '@agent-device/command-registry/flag-types'; import { projectConfigFlagKeys } from './command-schema.ts'; import { expandUserHomePath, resolveUserPath } from '@agent-device/host-kit/file'; import { diff --git a/src/cli-schema/cli-help-alias-fast-path.test.ts b/src/cli-schema/cli-help-alias-fast-path.test.ts index 50e489c857..3669adeb8c 100644 --- a/src/cli-schema/cli-help-alias-fast-path.test.ts +++ b/src/cli-schema/cli-help-alias-fast-path.test.ts @@ -1,7 +1,7 @@ import { test } from 'vitest'; import assert from 'node:assert/strict'; import { buildCommandUsageText, resolveHelpTargetUsageText } from './cli-help.ts'; -import { cliAliasesForCommand } from '../commands/cli-command-aliases.ts'; +import { cliAliasesForCommand } from '@agent-device/command-registry/cli-command-aliases'; import { listCliCommandNames } from '@agent-device/command-registry/catalog'; const ALIASES = listCliCommandNames().flatMap((command) => diff --git a/src/cli-schema/cli-help.ts b/src/cli-schema/cli-help.ts index f7b8dbc1cf..a95861879e 100644 --- a/src/cli-schema/cli-help.ts +++ b/src/cli-schema/cli-help.ts @@ -4,8 +4,8 @@ import { MAESTRO_COMPATIBILITY_ADR_URL, MAESTRO_COMPATIBILITY_ISSUE_URL, } from '@agent-device/maestro'; -import { normalizeCliCommandAlias } from '../commands/cli-command-aliases.ts'; -import { helpBody } from '../commands/command-text.ts'; +import { normalizeCliCommandAlias } from '@agent-device/command-registry/cli-command-aliases'; +import { helpBody } from '@agent-device/command-registry/command-text'; import { DEVICE_SELECTION_FLAG_KEYS, getCliCommandSchema, diff --git a/src/cli-schema/command-overrides.ts b/src/cli-schema/command-overrides.ts index 430c83225b..a6db46f202 100644 --- a/src/cli-schema/command-overrides.ts +++ b/src/cli-schema/command-overrides.ts @@ -5,7 +5,7 @@ import type { CommandSchema } from './types.ts'; import { COMMON_COMMAND_SUPPORTED_FLAG_KEYS, METRO_PREPARE_FLAGS, -} from '../commands/cli-grammar/flag-groups.ts'; +} from '@agent-device/command-registry/flag-groups'; type SchemaOnlyCliCommandName = Exclude; diff --git a/src/cli-schema/command-schema.ts b/src/cli-schema/command-schema.ts index 157463358c..125a16eb42 100644 --- a/src/cli-schema/command-schema.ts +++ b/src/cli-schema/command-schema.ts @@ -7,13 +7,13 @@ import { getFlagDefinitions, projectConfigFlagKeys, recordedFlagKeys, -} from '../commands/cli-grammar/flag-registry.ts'; +} from '@agent-device/command-registry/flag-registry'; import { COMMON_COMMAND_SUPPORTED_FLAG_KEYS, DEVICE_SELECTION_FLAG_KEYS, GLOBAL_FLAG_KEYS, -} from '../commands/cli-grammar/flag-groups.ts'; -import { type FlagDefinition, type FlagKey } from '../commands/cli-grammar/flag-types.ts'; +} from '@agent-device/command-registry/flag-groups'; +import { type FlagDefinition, type FlagKey } from '@agent-device/command-registry/flag-types'; import { AppError } from '@agent-device/kernel/errors'; export type { FlagDefinition, FlagKey }; diff --git a/src/cli-schema/types.ts b/src/cli-schema/types.ts index 4b6bd39239..51b477532c 100644 --- a/src/cli-schema/types.ts +++ b/src/cli-schema/types.ts @@ -1,6 +1,6 @@ -import type { FlagKey } from '../commands/cli-grammar/flag-types.ts'; +import type { FlagKey } from '@agent-device/command-registry/flag-types'; import type { CliFlags } from '@agent-device/contracts/command'; -import type { CommandText } from '../commands/command-text.ts'; +import type { CommandText } from '@agent-device/command-registry/command-text'; /** * Command grammar plus its resolved text. Prose lives entirely in `text`; everything else here diff --git a/src/cli-schema/usage.test.ts b/src/cli-schema/usage.test.ts index 9a4def337f..e0420cfebd 100644 --- a/src/cli-schema/usage.test.ts +++ b/src/cli-schema/usage.test.ts @@ -1,7 +1,7 @@ import assert from 'node:assert/strict'; import { test } from 'vitest'; import { listCliCommandNames } from '@agent-device/command-registry/catalog'; -import type { CommandText } from '../commands/command-text.ts'; +import type { CommandText } from '@agent-device/command-registry/command-text'; import { getCliCommandSchema, getFlagDefinitions, diff --git a/src/cli.ts b/src/cli.ts index 941ac5cc3b..33880dc744 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -47,7 +47,7 @@ import { type RemoteConnectionRequestMetadata, } from './remote/remote-connection-state.ts'; import { resolveRemoteAuthForCli } from './cli/auth-session.ts'; -import type { FlagKey } from './commands/cli-grammar/flag-types.ts'; +import type { FlagKey } from '@agent-device/command-registry/flag-types'; import type { CliFlags } from '@agent-device/contracts/command'; import type { SessionRuntimeHints } from '@agent-device/kernel/contracts'; import { INTERNAL_COMMANDS, isKnownCliCommandName } from '@agent-device/command-registry/catalog'; diff --git a/src/cli/entry.test.ts b/src/cli/entry.test.ts index 085478702f..13a3836919 100644 --- a/src/cli/entry.test.ts +++ b/src/cli/entry.test.ts @@ -2,7 +2,7 @@ import assert from 'node:assert/strict'; import { test } from 'vitest'; import * as cliHelp from '../cli-schema/cli-help.ts'; import { listCliCommandNames } from '@agent-device/command-registry/catalog'; -import { cliAliasesForCommand } from '../commands/cli-command-aliases.ts'; +import { cliAliasesForCommand } from '@agent-device/command-registry/cli-command-aliases'; import { runEntry, type EntryModules } from './entry.ts'; const ALIASES = listCliCommandNames().flatMap((command) => diff --git a/src/cli/parser/__tests__/maestro-support-matrix.test.ts b/src/cli/parser/__tests__/maestro-support-matrix.test.ts index 8f99969d5a..f3ea7789b6 100644 --- a/src/cli/parser/__tests__/maestro-support-matrix.test.ts +++ b/src/cli/parser/__tests__/maestro-support-matrix.test.ts @@ -1,7 +1,7 @@ import fs from 'node:fs'; import { expect, test } from 'vitest'; import { usageForCommand } from '../args.ts'; -import { getFlagDefinitions } from '../../../commands/cli-grammar/flag-registry.ts'; +import { getFlagDefinitions } from '@agent-device/command-registry/flag-registry'; import { MAESTRO_COMPATIBILITY_ADR_URL, MAESTRO_COMPATIBILITY_ISSUE_URL, diff --git a/src/cli/parser/args.ts b/src/cli/parser/args.ts index 9d97103ec4..b2d75d81f6 100644 --- a/src/cli/parser/args.ts +++ b/src/cli/parser/args.ts @@ -16,7 +16,7 @@ import { cliCommandAlias, normalizeCliCommandAlias, retiredCliCommandMessage, -} from '../../commands/cli-command-aliases.ts'; +} from '@agent-device/command-registry/cli-command-aliases'; import { formatUnknownFlagMessage, suggestCommandFor } from './command-suggestions.ts'; type ParsedArgs = { diff --git a/src/commands/__tests__/command-surface-metadata.test.ts b/src/commands/__tests__/command-surface-metadata.test.ts index d45514e947..d067291531 100644 --- a/src/commands/__tests__/command-surface-metadata.test.ts +++ b/src/commands/__tests__/command-surface-metadata.test.ts @@ -20,7 +20,7 @@ import { listCommandFamilyMetadata, } from '../family/registry.ts'; import { listExecutableCommandNames } from '../command-surface.ts'; -import { helpBody, mcpBody } from '../command-text.ts'; +import { helpBody, mcpBody } from '@agent-device/command-registry/command-text'; import { explainCommand } from '../command-explain.ts'; import { getDaemonRouteOwnerFiles } from '../../daemon/route-owner-files.ts'; diff --git a/src/commands/capture/diff.ts b/src/commands/capture/diff.ts index 007614206f..4e50a78596 100644 --- a/src/commands/capture/diff.ts +++ b/src/commands/capture/diff.ts @@ -1,5 +1,5 @@ import { PUBLIC_COMMANDS } from '@agent-device/command-registry/catalog'; -import { SNAPSHOT_FLAGS } from '../cli-grammar/flag-groups.ts'; +import { SNAPSHOT_FLAGS } from '@agent-device/command-registry/flag-groups'; import { AppError } from '@agent-device/kernel/errors'; import { booleanField, diff --git a/src/commands/capture/snapshot.ts b/src/commands/capture/snapshot.ts index ada54d8937..093a9c2056 100644 --- a/src/commands/capture/snapshot.ts +++ b/src/commands/capture/snapshot.ts @@ -4,7 +4,7 @@ import { SNAPSHOT_COMMAND_OPTION_KEYS, snapshotOptionsFromFlags, } from '@agent-device/kernel/snapshot'; -import { SNAPSHOT_FLAGS } from '../cli-grammar/flag-groups.ts'; +import { SNAPSHOT_FLAGS } from '@agent-device/command-registry/flag-groups'; import { booleanField, integerField, optionField, stringField } from '../command-input.ts'; import { commonInputFromFlags, diff --git a/src/commands/capture/wait.ts b/src/commands/capture/wait.ts index 1e2676b5e8..867f40e4e1 100644 --- a/src/commands/capture/wait.ts +++ b/src/commands/capture/wait.ts @@ -3,7 +3,7 @@ import { PUBLIC_COMMANDS } from '@agent-device/command-registry/catalog'; import type { WaitCommandOptions } from '@agent-device/contracts/client'; import { parseWaitPositionals } from '@agent-device/command-registry/wait-positionals'; import type { WaitParsed } from '@agent-device/command-registry/wait-positionals'; -import { SELECTOR_SNAPSHOT_FLAGS } from '../cli-grammar/flag-groups.ts'; +import { SELECTOR_SNAPSHOT_FLAGS } from '@agent-device/command-registry/flag-groups'; import { AppError } from '@agent-device/kernel/errors'; import { isValidSelectorExpression } from '@agent-device/selectors'; import { booleanField, enumField, integerField, stringField } from '../command-input.ts'; diff --git a/src/commands/cli-grammar/flag-declaration-admission.test.ts b/src/commands/cli-grammar/flag-declaration-admission.test.ts index 81ad5f3431..5891055a51 100644 --- a/src/commands/cli-grammar/flag-declaration-admission.test.ts +++ b/src/commands/cli-grammar/flag-declaration-admission.test.ts @@ -3,8 +3,8 @@ import fs from 'node:fs'; import path from 'node:path'; import { test, vi } from 'vitest'; import type { CliFlags } from '@agent-device/contracts/command'; -import { getFlagDefinitionsForKey } from './flag-registry.ts'; -import type { FlagDefinition } from './flag-types.ts'; +import { getFlagDefinitionsForKey } from '@agent-device/command-registry/flag-registry'; +import type { FlagDefinition } from '@agent-device/command-registry/flag-types'; import { resolveConfigBackedFlagDefaults } from '../../cli-schema/cli-config.ts'; import { recordActionEntry } from '../../daemon/session-action-recorder.ts'; import { makeIosSession } from '../../__tests__/test-utils/session-factories.ts'; @@ -59,7 +59,7 @@ test('project-config admission follows the declaration: an undeclared key is ref // Planted: flip the declaration before `cli-config` builds, and the identical file is // admitted. A hand-maintained allowlist in `cli-config.ts` could not follow this. vi.resetModules(); - const registry = await import('./flag-registry.ts'); + const registry = await import('@agent-device/command-registry/flag-registry'); const planted = getInRegistry(registry, 'daemonBaseUrl'); Object.assign(planted, { projectConfig: true }); const { resolveConfigBackedFlagDefaults: derivePlanted } = @@ -95,7 +95,7 @@ test('recorder sanitization follows the declaration: an undeclared key is droppe // Planted: flip the declaration before the recorder builds, and the production // `sanitizeFlags` now copies the same value. vi.resetModules(); - const registry = await import('./flag-registry.ts'); + const registry = await import('@agent-device/command-registry/flag-registry'); const planted = getInRegistry(registry, 'overlayRefs'); Object.assign(planted, { recorded: true }); const { recordActionEntry: recordPlanted } = @@ -130,7 +130,7 @@ test('a CLI-only key cannot opt into recording', () => { }); function getInRegistry( - registry: typeof import('./flag-registry.ts'), + registry: typeof import('@agent-device/command-registry/flag-registry'), key: 'daemonBaseUrl' | 'overlayRefs', ): FlagDefinition { const declaration = registry.getFlagDefinitionsForKey(key)[0]; diff --git a/src/commands/command-explain.ts b/src/commands/command-explain.ts index df63c68f72..5070d0c4ad 100644 --- a/src/commands/command-explain.ts +++ b/src/commands/command-explain.ts @@ -1,5 +1,8 @@ import { listCliCommandNames } from '@agent-device/command-registry/catalog'; -import { cliAliasesForCommand, normalizeCliCommandAlias } from './cli-command-aliases.ts'; +import { + cliAliasesForCommand, + normalizeCliCommandAlias, +} from '@agent-device/command-registry/cli-command-aliases'; import { buildCommandUsage } from '../cli-schema/usage.ts'; import type { DaemonCommandRoute } from '../daemon/daemon-command-registry.ts'; import { commandDescriptors, type Command } from '@agent-device/command-registry/registry'; diff --git a/src/commands/command-flags.ts b/src/commands/command-flags.ts index f2c8dc5d91..fec8636037 100644 --- a/src/commands/command-flags.ts +++ b/src/commands/command-flags.ts @@ -9,7 +9,7 @@ import { SNAPSHOT_COMMAND_OPTION_KEYS, snapshotFlagsFromOptions, } from '@agent-device/kernel/snapshot'; -import { getFlagDefinitions } from './cli-grammar/flag-registry.ts'; +import { getFlagDefinitions } from '@agent-device/command-registry/flag-registry'; import type { InternalRequestOptions } from '@agent-device/contracts/client'; import type { CommandMetadata } from './command-contract.ts'; diff --git a/src/commands/command-input-option-field.test.ts b/src/commands/command-input-option-field.test.ts index fae8e1a072..a8236035c8 100644 --- a/src/commands/command-input-option-field.test.ts +++ b/src/commands/command-input-option-field.test.ts @@ -1,8 +1,11 @@ import assert from 'node:assert/strict'; import { readFileSync } from 'node:fs'; import { test, vi } from 'vitest'; -import { getFlagDefinitions, getFlagDefinitionsForKey } from './cli-grammar/flag-registry.ts'; -import type { FlagDefinition, FlagKey } from './cli-grammar/flag-types.ts'; +import { + getFlagDefinitions, + getFlagDefinitionsForKey, +} from '@agent-device/command-registry/flag-registry'; +import type { FlagDefinition, FlagKey } from '@agent-device/command-registry/flag-types'; import { listCommandMetadata } from './command-metadata.ts'; import type { JsonSchema } from './command-contract.ts'; import { optionField } from './command-input.ts'; @@ -57,7 +60,7 @@ async function buildWithPlantedOption( vi.resetModules(); // Plant first: nothing in this module graph has built a command yet. - const registry = await import('./cli-grammar/flag-registry.ts'); + const registry = await import('@agent-device/command-registry/flag-registry'); const declaration = registry .getFlagDefinitionsForKey(key) .find((candidate) => candidate.inputDescription !== undefined); diff --git a/src/commands/command-input.ts b/src/commands/command-input.ts index b69329c6f3..cc542be6a4 100644 --- a/src/commands/command-input.ts +++ b/src/commands/command-input.ts @@ -9,8 +9,8 @@ import { readOptionalNumber as optionalNumberValue, type CliFlags, } from '@agent-device/contracts/command'; -import { getFlagDefinitionsForKey } from './cli-grammar/flag-registry.ts'; -import type { FlagDefinition, FlagKey } from './cli-grammar/flag-types.ts'; +import { getFlagDefinitionsForKey } from '@agent-device/command-registry/flag-registry'; +import type { FlagDefinition, FlagKey } from '@agent-device/command-registry/flag-types'; import { AppError } from '@agent-device/kernel/errors'; import type { RepeatedInput } from '@agent-device/contracts/interaction'; import type { JsonSchema } from './command-contract.ts'; diff --git a/src/commands/family/types.ts b/src/commands/family/types.ts index 3650199c08..4ca984a75c 100644 --- a/src/commands/family/types.ts +++ b/src/commands/family/types.ts @@ -3,7 +3,10 @@ import type { CommandSchema, CommandSchemaOverride } from '../../cli-schema/type import type { AnyDaemonWriter, CliReader } from '../cli-grammar/types.ts'; import type { CommandMetadata, JsonSchema } from '../command-contract.ts'; import type { CliOutputFormatter } from '../output-common.ts'; -import { resolveFacetText, type FacetCommandText } from '../command-text.ts'; +import { + resolveFacetText, + type FacetCommandText, +} from '@agent-device/command-registry/command-text'; export type AnyCommandMetadata = CommandMetadata; diff --git a/src/commands/interaction/index.ts b/src/commands/interaction/index.ts index ec3f622ed6..7dd5671f72 100644 --- a/src/commands/interaction/index.ts +++ b/src/commands/interaction/index.ts @@ -20,7 +20,10 @@ import type { TypeTextOptions, } from '@agent-device/contracts/client'; import type { CommandSchemaOverride } from '../../cli-schema/types.ts'; -import { REPEATED_TOUCH_FLAGS, SELECTOR_SNAPSHOT_FLAGS } from '../cli-grammar/flag-groups.ts'; +import { + REPEATED_TOUCH_FLAGS, + SELECTOR_SNAPSHOT_FLAGS, +} from '@agent-device/command-registry/flag-groups'; import { postActionObservationCliFlags } from '../post-action-observation-grammar.ts'; import { toClientElementTarget, diff --git a/src/commands/management/app.ts b/src/commands/management/app.ts index 590dabf443..5de1d1fc83 100644 --- a/src/commands/management/app.ts +++ b/src/commands/management/app.ts @@ -17,7 +17,7 @@ import { } from '../command-input.ts'; import { commonInputFromFlags, direct, optionalString } from '../cli-grammar/common.ts'; import type { CliReader, CommandInput, DaemonWriter } from '../cli-grammar/types.ts'; -import { METRO_RELOAD_FLAGS } from '../cli-grammar/flag-groups.ts'; +import { METRO_RELOAD_FLAGS } from '@agent-device/command-registry/flag-groups'; import { defineCommandFacet } from '../family/types.ts'; import { defineFieldCommandMetadata } from '../field-command-contract.ts'; import { withCommandRuntimeHints } from '../runtime-hints.ts'; diff --git a/src/commands/metro/index.ts b/src/commands/metro/index.ts index 1175ad9a78..620d282ce2 100644 --- a/src/commands/metro/index.ts +++ b/src/commands/metro/index.ts @@ -19,7 +19,10 @@ import { import { defineCommandFacet, defineCommandFamilyFromFacets } from '../family/types.ts'; import { defineFieldCommandMetadata } from '../field-command-contract.ts'; import type { CliReader } from '../cli-grammar/types.ts'; -import { METRO_PREPARE_FLAGS, METRO_RELOAD_FLAGS } from '../cli-grammar/flag-groups.ts'; +import { + METRO_PREPARE_FLAGS, + METRO_RELOAD_FLAGS, +} from '@agent-device/command-registry/flag-groups'; import { metroCliOutputFormatters } from './output.ts'; import { readMetroPrepareKind } from './prepare-kind.ts'; diff --git a/src/commands/post-action-observation-grammar.ts b/src/commands/post-action-observation-grammar.ts index 63cfbf4899..45b6eb0612 100644 --- a/src/commands/post-action-observation-grammar.ts +++ b/src/commands/post-action-observation-grammar.ts @@ -5,8 +5,8 @@ import { commandSupportsVerifyEvidence, } from '@agent-device/command-registry/registry'; import { settleInputFromFlags } from './cli-grammar/common.ts'; -import { SETTLE_FLAGS } from './cli-grammar/flag-groups.ts'; -import type { FlagKey } from './cli-grammar/flag-types.ts'; +import { SETTLE_FLAGS } from '@agent-device/command-registry/flag-groups'; +import type { FlagKey } from '@agent-device/command-registry/flag-types'; import { booleanField, integerField } from './command-input.ts'; /** diff --git a/src/commands/replay/index.ts b/src/commands/replay/index.ts index cb85cc0e35..1f1d9b2728 100644 --- a/src/commands/replay/index.ts +++ b/src/commands/replay/index.ts @@ -18,7 +18,7 @@ import { requiredString, } from '../cli-grammar/common.ts'; import type { AsyncDaemonWriter, CliReader, CommandInput } from '../cli-grammar/types.ts'; -import { METRO_RELOAD_FLAGS, REPLAY_FLAGS } from '../cli-grammar/flag-groups.ts'; +import { METRO_RELOAD_FLAGS, REPLAY_FLAGS } from '@agent-device/command-registry/flag-groups'; import { withCommandRuntimeHints } from '../runtime-hints.ts'; import { collectReplayShellEnv, diff --git a/src/mcp/command-tools.ts b/src/mcp/command-tools.ts index fc364d7f1f..07fa5a5f37 100644 --- a/src/mcp/command-tools.ts +++ b/src/mcp/command-tools.ts @@ -11,7 +11,7 @@ import { listMcpCommandMetadata, type CommandName, } from '../commands/command-metadata.ts'; -import { mcpBody } from '../commands/command-text.ts'; +import { mcpBody } from '@agent-device/command-registry/command-text'; import { resolveStructuredBatchCommandName } from '@agent-device/command-registry/batch-policy'; import { resolveCommandRecordsSessionAction, diff --git a/src/mcp/tool-input-config.ts b/src/mcp/tool-input-config.ts index 2ad0ea22fe..c26f027e2a 100644 --- a/src/mcp/tool-input-config.ts +++ b/src/mcp/tool-input-config.ts @@ -1,5 +1,5 @@ import { isFlagSupportedForCommand } from '../cli-schema/option-schema.ts'; -import type { FlagKey } from '../commands/cli-grammar/flag-types.ts'; +import type { FlagKey } from '@agent-device/command-registry/flag-types'; import type { CliFlags } from '@agent-device/contracts/command'; import type { JsonSchema } from '../commands/command-contract.ts'; import type { CommandName } from '../commands/command-metadata.ts'; diff --git a/test/integration/smoke-cli.test.ts b/test/integration/smoke-cli.test.ts index aaa287ad22..7d7444154a 100644 --- a/test/integration/smoke-cli.test.ts +++ b/test/integration/smoke-cli.test.ts @@ -1,7 +1,7 @@ import test from 'node:test'; import assert from 'node:assert/strict'; import { runCmdSync } from '@agent-device/host-kit/command'; -import { cliAliasesForCommand } from '../../src/commands/cli-command-aliases.ts'; +import { cliAliasesForCommand } from '@agent-device/command-registry/cli-command-aliases'; import { listCliCommandNames } from '@agent-device/command-registry/catalog'; function runCli(args: string[]): { status: number; stdout: string; stderr: string } {