Group CLI modules into parse, run, output, and help

Move parser, tokenize, and area-aliases under cli/parse; runner and read-only under cli/run; printer under cli/output; help plus the docs/naming contract tests under cli/help. types.ts and helpers.ts stay at the cli root. Update imports, the app-root depth calculation, test fixtures, and the CLI doc generator path. No behavior change.
This commit is contained in:
gitea committed 2026-11-19 16:38:14 +08:00
1 parent 37b54065d9
commit ca9d87e13f
80 files changed
+196 -195

No files matched your search

+4 -4
View File
@@ -13,7 +13,7 @@ When developing or refactoring CLI commands under `src/cli/`:
- **Machine Channel (`stdout`)**: - **Machine Channel (`stdout`)**:
- Data commands **MUST** output pure, parseable JSON on `stdout`. - Data commands **MUST** output pure, parseable JSON on `stdout`.
- **NEVER** output human text, logs, spinners, progress banners, or update notices to `stdout`. The Agent Harness parses `stdout` directly into typed payloads. - **NEVER** output human text, logs, spinners, progress banners, or update notices to `stdout`. The Agent Harness parses `stdout` directly into typed payloads.
- **Documented exceptions**: `seal-use --help` / `seal-use help <area>` (`src/cli/printer.ts`), `seal-use doctor guide` (`src/cli/commands/doctor.ts`), and `seal-use skill dump` (`src/cli/commands/skill.ts`) intentionally output Markdown documents on `stdout` because their output *is* the requested document payload (e.g. `seal-use skill dump > SKILL.md`). Never add new stdout-prose commands outside this list. - **Documented exceptions**: `seal-use --help` / `seal-use help <area>` (`src/cli/output/printer.ts`), `seal-use doctor guide` (`src/cli/commands/doctor.ts`), and `seal-use skill dump` (`src/cli/commands/skill.ts`) intentionally output Markdown documents on `stdout` because their output *is* the requested document payload (e.g. `seal-use skill dump > SKILL.md`). Never add new stdout-prose commands outside this list.
- **Diagnostics & Guidance Channel (`stderr`)**: - **Diagnostics & Guidance Channel (`stderr`)**:
- Use `stderr` for runtime logs, network probing status, self-healing notifications, and human tips. - Use `stderr` for runtime logs, network probing status, self-healing notifications, and human tips.
- Explicit **Next-Step Command Suggestions** MUST follow the format: - Explicit **Next-Step Command Suggestions** MUST follow the format:
@@ -27,7 +27,7 @@ When developing or refactoring CLI commands under `src/cli/`:
- **Sub-70ms Local Execution**: - **Sub-70ms Local Execution**:
- Read-only discovery commands (e.g. `seal-use version`, `seal-use doctor paths`, `seal-use corps list`) MUST return in under 70ms wall clock (Bun interpreter startup is ~7ms on its own, so this leaves ~60ms for the module graph). - Read-only discovery commands (e.g. `seal-use version`, `seal-use doctor paths`, `seal-use corps list`) MUST return in under 70ms wall clock (Bun interpreter startup is ~7ms on its own, so this leaves ~60ms for the module graph).
- Achieved by keeping `src/cli/runner.ts` free of static command-module imports: dispatch branches load their handler with `await import("./commands/<area>.js")` on demand, so `seal-use version` never loads the Excel/zip tool chain. - Achieved by keeping `src/cli/run/runner.ts` free of static command-module imports: dispatch branches load their handler with `await import("./commands/<area>.js")` on demand, so `seal-use version` never loads the Excel/zip tool chain.
- Never trigger synchronous external HTTP requests during routine discovery or inspection invocations. Measured on the maintainer's machine (2026-09): version 45ms, help 41ms, corps list 41ms, bare `bun -e` 7ms. - Never trigger synchronous external HTTP requests during routine discovery or inspection invocations. Measured on the maintainer's machine (2026-09): version 45ms, help 41ms, corps list 41ms, bare `bun -e` 7ms.
- **Stale-While-Revalidate (SWR) Pattern**: - **Stale-While-Revalidate (SWR) Pattern**:
1. Synchronously read local cache from `~/.config/seal-use/*.json` (<0.2ms). 1. Synchronously read local cache from `~/.config/seal-use/*.json` (<0.2ms).
@@ -74,13 +74,13 @@ When developing or refactoring CLI commands under `src/cli/`:
| `13` | **Config / Input Validation** | Well-formed command with an unusable value: missing `--corp` in stateless mode, unparseable enterprise JSON, missing required parameter (Chinese-language usage wording), Zod/schema validation failure | | `13` | **Config / Input Validation** | Well-formed command with an unusable value: missing `--corp` in stateless mode, unparseable enterprise JSON, missing required parameter (Chinese-language usage wording), Zod/schema validation failure |
| `14` | **Safety Guard Block** | Target environment forbids the action: replay into a production tenant, regression matrix outside a test tenant. Requires a different target or an explicit override flag | | `14` | **Safety Guard Block** | Target environment forbids the action: replay into a production tenant, regression matrix outside a test tenant. Requires a different target or an explicit override flag |
**Rule**: Never call `process.exit()` deep in domain functions. Throw structured errors (`usageError` → 2, `validationError` → 13, `safetyBlocked` → 14, `confirmationRequired` → 10) and let `src/cli/runner.ts` handle error classification, stream routing, and exit code assignment. Domain failures and quality gates stay at `1`. **Rule**: Never call `process.exit()` deep in domain functions. Throw structured errors (`usageError` → 2, `validationError` → 13, `safetyBlocked` → 14, `confirmationRequired` → 10) and let `src/cli/run/runner.ts` handle error classification, stream routing, and exit code assignment. Domain failures and quality gates stay at `1`.
--- ---
## 5. Argument Parsing Conventions ## 5. Argument Parsing Conventions
- Use helpers from `src/cli/parser.ts`: - Use helpers from `src/cli/parse/parser.ts`:
- `booleanOption(args.options.flag)` - `booleanOption(args.options.flag)`
- `stringOption(args.options.param)` - `stringOption(args.options.param)`
- `numberOption(args.options.limit)` - `numberOption(args.options.limit)`
+2 -2
View File
@@ -38,7 +38,7 @@ Prefer small domain functions over broad utility modules.
## CLI & Agent Harness Protocol Guidelines ## CLI & Agent Harness Protocol Guidelines
- **Machine Channel (`stdout`)**: Data commands MUST output clean, parseable JSON on `stdout`. Never dump human prose, raw logs, or progress banners into `stdout`. The Agent Harness parses `stdout` directly into typed payloads. - **Machine Channel (`stdout`)**: Data commands MUST output clean, parseable JSON on `stdout`. Never dump human prose, raw logs, or progress banners into `stdout`. The Agent Harness parses `stdout` directly into typed payloads.
- **Documented exception — document-output commands**: `seal-use --help` / `seal-use help <area>` (`src/cli/printer.ts`), `seal-use doctor guide` (`src/cli/commands/doctor.ts`), and `seal-use skill dump` (`src/cli/commands/skill.ts`) intentionally write Markdown to `stdout`, because their output *is* the payload the caller redirects or reads (e.g. `seal-use doctor guide > guide.md`, `seal-use skill dump > SKILL.md`). Never add a new prose-on-stdout command outside this list: return structured JSON and put the readable rendering on `stderr` instead. `src/probe.ts` is a local developer probe script rather than a `bin` entry point, so its `[probe] …` lines are outside this contract. - **Documented exception — document-output commands**: `seal-use --help` / `seal-use help <area>` (`src/cli/output/printer.ts`), `seal-use doctor guide` (`src/cli/commands/doctor.ts`), and `seal-use skill dump` (`src/cli/commands/skill.ts`) intentionally write Markdown to `stdout`, because their output *is* the payload the caller redirects or reads (e.g. `seal-use doctor guide > guide.md`, `seal-use skill dump > SKILL.md`). Never add a new prose-on-stdout command outside this list: return structured JSON and put the readable rendering on `stderr` instead. `src/probe.ts` is a local developer probe script rather than a `bin` entry point, so its `[probe] …` lines are outside this contract.
- **Guidance & Diagnostic Channel (`stderr`)**: Use `stderr` for runtime logs, network probing status, self-healing notifications, and explicit **Next-Step Command Suggestions** (e.g. `👉 Next action: seal-use deploy hosecloud sync <signKey>`). - **Guidance & Diagnostic Channel (`stderr`)**: Use `stderr` for runtime logs, network probing status, self-healing notifications, and explicit **Next-Step Command Suggestions** (e.g. `👉 Next action: seal-use deploy hosecloud sync <signKey>`).
- **Performance Contract & SWR Architecture**: Read-only discovery and version commands (`seal-use version`, `seal-use doctor`, `seal-use corps list`) MUST execute in under 70ms wall clock (Bun startup alone is ~7ms; runner dispatch uses lazy `await import()` per command area, so the version path never loads the Excel/zip tool chain). Never block on external network I/O during routine invocations. Use the Stale-While-Revalidate (SWR) pattern: read local cache from `~/.config/seal-use/*.json` synchronously (<0.2ms), and refresh stale/missing data via detached, unref'd child processes (`triggerBackgroundUpdateCheck`, `unref()`). - **Performance Contract & SWR Architecture**: Read-only discovery and version commands (`seal-use version`, `seal-use doctor`, `seal-use corps list`) MUST execute in under 70ms wall clock (Bun startup alone is ~7ms; runner dispatch uses lazy `await import()` per command area, so the version path never loads the Excel/zip tool chain). Never block on external network I/O during routine invocations. Use the Stale-While-Revalidate (SWR) pattern: read local cache from `~/.config/seal-use/*.json` synchronously (<0.2ms), and refresh stale/missing data via detached, unref'd child processes (`triggerBackgroundUpdateCheck`, `unref()`).
- **Safety Guardrail & Mutation Preview (`--dry-run`)**: All potentially destructive or state-mutating commands (e.g. `rules push/clear`, `corps sync-test`, `preference update`, `webhook create/update`) MUST support `--dry-run` returning structured JSON previews with `preview: true` and a clean diff, without executing mutations. Live execution requires explicit `--yes` or `--confirm`. - **Safety Guardrail & Mutation Preview (`--dry-run`)**: All potentially destructive or state-mutating commands (e.g. `rules push/clear`, `corps sync-test`, `preference update`, `webhook create/update`) MUST support `--dry-run` returning structured JSON previews with `preview: true` and a clean diff, without executing mutations. Live execution requires explicit `--yes` or `--confirm`.
@@ -51,7 +51,7 @@ Prefer small domain functions over broad utility modules.
- `12`: Output protection — response exceeds the size limit; use `--summary`/`--fields`/`--count`/`--output-file` (or `--full` when the full payload is genuinely required). - `12`: Output protection — response exceeds the size limit; use `--summary`/`--fields`/`--count`/`--output-file` (or `--full` when the full payload is genuinely required).
- `13`: Local configuration or input-data validation failure — well-formed command, but the value or config file is unusable (missing `--corp`, unparseable enterprise JSON, missing required parameter named in a Chinese-language error). - `13`: Local configuration or input-data validation failure — well-formed command, but the value or config file is unusable (missing `--corp`, unparseable enterprise JSON, missing required parameter named in a Chinese-language error).
- `14`: Safety guard block — the target environment forbids the action (replay into production, regression outside a test tenant); requires a different target or an explicit override. - `14`: Safety guard block — the target environment forbids the action (replay into production, regression outside a test tenant); requires a different target or an explicit override.
- Never call `process.exit()` deep in domain functions; throw structured errors and let `src/cli/runner.ts` handle stream routing and exit code assignment. - Never call `process.exit()` deep in domain functions; throw structured errors and let `src/cli/run/runner.ts` handle stream routing and exit code assignment.
## Testing Guidelines ## Testing Guidelines
+1 -1
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env bun #!/usr/bin/env bun
import { readFileSync, writeFileSync } from "node:fs"; import { readFileSync, writeFileSync } from "node:fs";
import { resolve } from "node:path"; import { resolve } from "node:path";
import { HELP_REGISTRY } from "../src/cli/help.ts"; import { HELP_REGISTRY } from "../src/cli/help/help.ts";
export const cliDocPath = resolve(import.meta.dirname, "../skills/seal-use/references/cli.md"); export const cliDocPath = resolve(import.meta.dirname, "../skills/seal-use/references/cli.md");
const begin = "<!-- BEGIN GENERATED CLI COMMANDS -->"; const begin = "<!-- BEGIN GENERATED CLI COMMANDS -->";
+3 -2
View File
@@ -52,12 +52,13 @@ describe("generated documentation contracts", () => {
const core = join(dir, "src/core") const core = join(dir, "src/core")
const coreSkill = join(core, "skill") const coreSkill = join(core, "skill")
const cli = join(dir, "src/cli") const cli = join(dir, "src/cli")
const cliHelp = join(cli, "help")
const skill = join(dir, "skills/seal-use") const skill = join(dir, "skills/seal-use")
for (const path of [scripts, core, coreSkill, cli, join(skill, "references")]) mkdirSync(path, { recursive: true }) for (const path of [scripts, core, coreSkill, cli, cliHelp, join(skill, "references")]) mkdirSync(path, { recursive: true })
for (const name of ["generate-embedded-skill.mjs", "check-embedded-skill.mjs", "generate-cli-md.mjs", "check-cli-md.mjs"]) { for (const name of ["generate-embedded-skill.mjs", "check-embedded-skill.mjs", "generate-cli-md.mjs", "check-cli-md.mjs"]) {
copyFileSync(join(import.meta.dir, name), join(scripts, name)) copyFileSync(join(import.meta.dir, name), join(scripts, name))
} }
writeFileSync(join(cli, "help.ts"), 'export const HELP_REGISTRY = [{ commands: [{ usage: ["seal-use fixture list"] }] }];') writeFileSync(join(cliHelp, "help.ts"), 'export const HELP_REGISTRY = [{ commands: [{ usage: ["seal-use fixture list"] }] }];')
writeFileSync(join(skill, "SKILL.md"), "fixture skill") writeFileSync(join(skill, "SKILL.md"), "fixture skill")
const embeddedPath = join(coreSkill, "embedded-skill.generated.ts") const embeddedPath = join(coreSkill, "embedded-skill.generated.ts")
const markdownPath = join(skill, "references/cli.md") const markdownPath = join(skill, "references/cli.md")
+1 -1
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env bun #!/usr/bin/env bun
import { fileURLToPath } from "node:url"; import { fileURLToPath } from "node:url";
import { runCli } from "./cli/runner.js"; import { runCli } from "./cli/run/runner.js";
import { isCompiledBinary, performRuntimeSelfHealing, resolveAppRoot, resolveDefaultLauncher } from "./core/util/runtime.js"; import { isCompiledBinary, performRuntimeSelfHealing, resolveAppRoot, resolveDefaultLauncher } from "./core/util/runtime.js";
process.stdout.on("error", (err: any) => { process.stdout.on("error", (err: any) => {
+2 -2
View File
@@ -3,8 +3,8 @@ import type { CorpConfig } from "../../core/config/types.js";
import type { createSealClient } from "../../core/http/factory.js"; import type { createSealClient } from "../../core/http/factory.js";
import { exportInsightReportToExcel } from "../../domains/seal/insight/export.js"; import { exportInsightReportToExcel } from "../../domains/seal/insight/export.js";
import { runCapability } from "../helpers.js"; import { runCapability } from "../helpers.js";
import { booleanOption, dryRunOption, numberOption, stringOption } from "../parser.js"; import { booleanOption, dryRunOption, numberOption, stringOption } from "../parse/parser.js";
import { outputOptions, printJson } from "../printer.js"; import { outputOptions, printJson } from "../output/printer.js";
import type { ParsedArgs } from "../types.js"; import type { ParsedArgs } from "../types.js";
export async function handleAnalyticsCommand( export async function handleAnalyticsCommand(
@@ -4,9 +4,9 @@ import { tmpdir } from "node:os"
import { fileURLToPath } from "node:url" import { fileURLToPath } from "node:url"
import { join } from "node:path" import { join } from "node:path"
import ExcelJS from "exceljs" import ExcelJS from "exceljs"
import { parseArgs } from "../parser.js" import { parseArgs } from "../parse/parser.js"
import { runCli } from "../runner.js" import { runCli } from "../run/runner.js"
import { isReadOnlyCliCommand } from "../read-only.js" import { isReadOnlyCliCommand } from "../run/read-only.js"
import { getExportTask, startExportTask, waitForExportTask, writeExportTask } from "../../domains/seal/approval-runs/export-task.js" import { getExportTask, startExportTask, waitForExportTask, writeExportTask } from "../../domains/seal/approval-runs/export-task.js"
import { resolveExportOptions } from "./approval-runs-export.js" import { resolveExportOptions } from "./approval-runs-export.js"
import type { CorpConfig } from "../../core/config/types.js" import type { CorpConfig } from "../../core/config/types.js"
+2 -2
View File
@@ -12,8 +12,8 @@ import {
type ExportTaskOptions type ExportTaskOptions
} from "../../domains/seal/approval-runs/export-task.js" } from "../../domains/seal/approval-runs/export-task.js"
import { selectCorp } from "../helpers.js" import { selectCorp } from "../helpers.js"
import { booleanOption, dryRunOption, numberOption, stringOption } from "../parser.js" import { booleanOption, dryRunOption, numberOption, stringOption } from "../parse/parser.js"
import { formatConsoleOutput, printJson, redactSensitiveText } from "../printer.js" import { formatConsoleOutput, printJson, redactSensitiveText } from "../output/printer.js"
import type { CliRuntime, ParsedArgs } from "../types.js" import type { CliRuntime, ParsedArgs } from "../types.js"
import { approvalRunsExportOptions } from "./approval-runs.js" import { approvalRunsExportOptions } from "./approval-runs.js"
import type { CorpConfig } from "../../core/config/types.js" import type { CorpConfig } from "../../core/config/types.js"
+1 -1
View File
@@ -2,7 +2,7 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test"
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs" import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"
import { tmpdir } from "node:os" import { tmpdir } from "node:os"
import { join } from "node:path" import { join } from "node:path"
import { runCli } from "../runner.js" import { runCli } from "../run/runner.js"
const envKeys = ["SEAL_USE_ENTERPRISES_DIR", "SEAL_USE_CONFIG_FILE", "SEAL_USE_TOKEN_STORE", "SEAL_USE_USAGE_FILE", "SEAL_DISABLE_BG_UPDATE"] as const const envKeys = ["SEAL_USE_ENTERPRISES_DIR", "SEAL_USE_CONFIG_FILE", "SEAL_USE_TOKEN_STORE", "SEAL_USE_USAGE_FILE", "SEAL_DISABLE_BG_UPDATE"] as const
const oldEnv = Object.fromEntries(envKeys.map(key => [key, process.env[key]])) const oldEnv = Object.fromEntries(envKeys.map(key => [key, process.env[key]]))
+2 -2
View File
@@ -8,8 +8,8 @@ import {
extractApprovalRunAttachments extractApprovalRunAttachments
} from "../../domains/seal/approval-runs/attachments.js"; } from "../../domains/seal/approval-runs/attachments.js";
import { runCapability, runCapabilityResult } from "../helpers.js"; import { runCapability, runCapabilityResult } from "../helpers.js";
import { booleanOption, numberOption, stringOption } from "../parser.js"; import { booleanOption, numberOption, stringOption } from "../parse/parser.js";
import { outputOptions, printJson } from "../printer.js"; import { outputOptions, printJson } from "../output/printer.js";
import type { ParsedArgs } from "../types.js"; import type { ParsedArgs } from "../types.js";
import { handleWebhookCommand } from "./webhook.js"; import { handleWebhookCommand } from "./webhook.js";
+1 -1
View File
@@ -2,7 +2,7 @@ import { afterEach, describe, expect, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs"; import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os"; import { tmpdir } from "node:os";
import { join } from "node:path"; import { join } from "node:path";
import { runCli } from "../runner.js"; import { runCli } from "../run/runner.js";
const ORIGINAL_ENV = { const ORIGINAL_ENV = {
enterprises: process.env.SEAL_USE_ENTERPRISES_DIR, enterprises: process.env.SEAL_USE_ENTERPRISES_DIR,
+2 -2
View File
@@ -19,8 +19,8 @@ import {
parseDelegationExpireHours, parseDelegationExpireHours,
parseHoseExpireSeconds, parseHoseExpireSeconds,
stringOption stringOption
} from "../parser.js"; } from "../parse/parser.js";
import { outputOptions, printJson, redactSensitiveText } from "../printer.js"; import { outputOptions, printJson, redactSensitiveText } from "../output/printer.js";
import type { ParsedArgs } from "../types.js"; import type { ParsedArgs } from "../types.js";
import { runCapability, runCapabilityResult } from "../helpers.js"; import { runCapability, runCapabilityResult } from "../helpers.js";
import { extractKeysFromLinkAction, showCorpKeysAction } from "./corps.js"; import { extractKeysFromLinkAction, showCorpKeysAction } from "./corps.js";
+1 -1
View File
@@ -2,7 +2,7 @@ import { usageError } from "../../core/errors.js";
import type { CorpConfig } from "../../core/config/types.js"; import type { CorpConfig } from "../../core/config/types.js";
import type { createSealClient } from "../../core/http/factory.js"; import type { createSealClient } from "../../core/http/factory.js";
import { runCapability } from "../helpers.js"; import { runCapability } from "../helpers.js";
import { outputOptions } from "../printer.js"; import { outputOptions } from "../output/printer.js";
import type { ParsedArgs } from "../types.js"; import type { ParsedArgs } from "../types.js";
export async function handleBillingCommand( export async function handleBillingCommand(
+2 -2
View File
@@ -8,8 +8,8 @@ import {
} from "../../core/config/loader.js"; } from "../../core/config/loader.js";
import { resolveCorpConfig } from "../../core/config/manager.js"; import { resolveCorpConfig } from "../../core/config/manager.js";
import { globalConfigSummary } from "../helpers.js"; import { globalConfigSummary } from "../helpers.js";
import { parseStateMode, stringOption } from "../parser.js"; import { parseStateMode, stringOption } from "../parse/parser.js";
import { printJson } from "../printer.js"; import { printJson } from "../output/printer.js";
import type { ParsedArgs } from "../types.js"; import type { ParsedArgs } from "../types.js";
export function handleConfigCommand(action: string | undefined, maybeName: string | undefined, args: ParsedArgs) { export function handleConfigCommand(action: string | undefined, maybeName: string | undefined, args: ParsedArgs) {
+1 -1
View File
@@ -2,7 +2,7 @@ import { usageError } from "../../core/errors.js";
import type { CorpConfig } from "../../core/config/types.js"; import type { CorpConfig } from "../../core/config/types.js";
import type { createSealClient } from "../../core/http/factory.js"; import type { createSealClient } from "../../core/http/factory.js";
import { runCapability } from "../helpers.js"; import { runCapability } from "../helpers.js";
import { outputOptions } from "../printer.js"; import { outputOptions } from "../output/printer.js";
import type { ParsedArgs } from "../types.js"; import type { ParsedArgs } from "../types.js";
export async function handleContactsCommand( export async function handleContactsCommand(
+2 -2
View File
@@ -1,8 +1,8 @@
import type { CorpConfig } from "../../core/config/types.js"; import type { CorpConfig } from "../../core/config/types.js";
import type { createSealClient } from "../../core/http/factory.js"; import type { createSealClient } from "../../core/http/factory.js";
import { runCapability } from "../helpers.js"; import { runCapability } from "../helpers.js";
import { numberOption, ruleVersionContextOptions, stringOption } from "../parser.js"; import { numberOption, ruleVersionContextOptions, stringOption } from "../parse/parser.js";
import { outputOptions } from "../printer.js"; import { outputOptions } from "../output/printer.js";
import type { ParsedArgs } from "../types.js"; import type { ParsedArgs } from "../types.js";
export async function handleContextCommand( export async function handleContextCommand(
+1 -1
View File
@@ -3,7 +3,7 @@ import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "nod
import { tmpdir } from "node:os"; import { tmpdir } from "node:os";
import { join } from "node:path"; import { join } from "node:path";
import type { CorpConfig } from "../../core/config/types.js"; import type { CorpConfig } from "../../core/config/types.js";
import { runCli } from "../runner.js"; import { runCli } from "../run/runner.js";
const ORIGINAL_ENV = { const ORIGINAL_ENV = {
enterprises: process.env.SEAL_USE_ENTERPRISES_DIR, enterprises: process.env.SEAL_USE_ENTERPRISES_DIR,
+2 -2
View File
@@ -2,7 +2,7 @@ import { afterEach, describe, expect, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"; import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os"; import { tmpdir } from "node:os";
import { join } from "node:path"; import { join } from "node:path";
import { runCli } from "../runner.js"; import { runCli } from "../run/runner.js";
const ORIGINAL_ENV = { const ORIGINAL_ENV = {
enterprises: process.env.SEAL_USE_ENTERPRISES_DIR, enterprises: process.env.SEAL_USE_ENTERPRISES_DIR,
@@ -1140,7 +1140,7 @@ describe("Hose OpenAPI key extraction from assistance link", () => {
}); });
test("RULE_SUMMARY_FIELDS excludes raw internal UUID and prioritizes business fields", async () => { test("RULE_SUMMARY_FIELDS excludes raw internal UUID and prioritizes business fields", async () => {
const { RULE_SUMMARY_FIELDS } = await import("../printer.js"); const { RULE_SUMMARY_FIELDS } = await import("../output/printer.js");
expect(RULE_SUMMARY_FIELDS).not.toContain("id"); expect(RULE_SUMMARY_FIELDS).not.toContain("id");
expect(RULE_SUMMARY_FIELDS).toContain("code"); expect(RULE_SUMMARY_FIELDS).toContain("code");
expect(RULE_SUMMARY_FIELDS).toContain("status"); expect(RULE_SUMMARY_FIELDS).toContain("status");
+2 -2
View File
@@ -1,7 +1,7 @@
import { updateCorpConfig } from "../../../core/config/loader.js"; import { updateCorpConfig } from "../../../core/config/loader.js";
import { confirmationRequired, usageError } from "../../../core/errors.js"; import { confirmationRequired, usageError } from "../../../core/errors.js";
import { booleanOption, dryRunOption, stringOption } from "../../parser.js"; import { booleanOption, dryRunOption, stringOption } from "../../parse/parser.js";
import { printJson } from "../../printer.js"; import { printJson } from "../../output/printer.js";
import type { ParsedArgs } from "../../types.js"; import type { ParsedArgs } from "../../types.js";
/** /**
+2 -2
View File
@@ -1,8 +1,8 @@
import { updateCorpConfig } from "../../../core/config/loader.js"; import { updateCorpConfig } from "../../../core/config/loader.js";
import { selectCorp } from "../../helpers.js"; import { selectCorp } from "../../helpers.js";
import { confirmationRequired, usageError } from "../../../core/errors.js"; import { confirmationRequired, usageError } from "../../../core/errors.js";
import { booleanOption, stringOption } from "../../parser.js"; import { booleanOption, stringOption } from "../../parse/parser.js";
import { printJson } from "../../printer.js"; import { printJson } from "../../output/printer.js";
import type { ParsedArgs } from "../../types.js"; import type { ParsedArgs } from "../../types.js";
export async function handleCorpBindings( export async function handleCorpBindings(
+2 -2
View File
@@ -23,8 +23,8 @@ import {
optionalString, optionalString,
requiredString, requiredString,
stringOption stringOption
} from "../../parser.js"; } from "../../parse/parser.js";
import { printJson } from "../../printer.js"; import { printJson } from "../../output/printer.js";
import type { ParsedArgs } from "../../types.js"; import type { ParsedArgs } from "../../types.js";
import { maskCellphone } from "./shared.js"; import { maskCellphone } from "./shared.js";
+2 -2
View File
@@ -11,8 +11,8 @@ import {
} from "../../../core/stats/usage-tracker.js"; } from "../../../core/stats/usage-tracker.js";
import type { CorpEnvironment } from "../../../core/config/types.js"; import type { CorpEnvironment } from "../../../core/config/types.js";
import { confirmationRequired, usageError } from "../../../core/errors.js"; import { confirmationRequired, usageError } from "../../../core/errors.js";
import { booleanOption, dryRunOption, numberOption, stringOption } from "../../parser.js"; import { booleanOption, dryRunOption, numberOption, stringOption } from "../../parse/parser.js";
import { printJson } from "../../printer.js"; import { printJson } from "../../output/printer.js";
import type { ParsedArgs } from "../../types.js"; import type { ParsedArgs } from "../../types.js";
export async function handleCorpOverview( export async function handleCorpOverview(
+2 -2
View File
@@ -4,8 +4,8 @@ import { syncTestEnterprise } from "../../../domains/seal/testing/sync.js";
import { executeApprovalRunsReplay, type ReplayRecordsQuery } from "../../../domains/seal/replay/webhook.js"; import { executeApprovalRunsReplay, type ReplayRecordsQuery } from "../../../domains/seal/replay/webhook.js";
import { selectCorp } from "../../helpers.js"; import { selectCorp } from "../../helpers.js";
import { CliError, confirmationRequired, usageError } from "../../../core/errors.js"; import { CliError, confirmationRequired, usageError } from "../../../core/errors.js";
import { booleanOption, numberOption, stringOption } from "../../parser.js"; import { booleanOption, numberOption, stringOption } from "../../parse/parser.js";
import { outputOptions, printJson } from "../../printer.js"; import { outputOptions, printJson } from "../../output/printer.js";
import type { ParsedArgs } from "../../types.js"; import type { ParsedArgs } from "../../types.js";
export { buildTestHosecloudOutboundName } from "../../../domains/seal/testing/sync.js"; export { buildTestHosecloudOutboundName } from "../../../domains/seal/testing/sync.js";
+1 -1
View File
@@ -2,7 +2,7 @@ import { afterEach, describe, expect, test } from "bun:test";
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"; import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os"; import { tmpdir } from "node:os";
import { join } from "node:path"; import { join } from "node:path";
import { runCli } from "../../runner.js"; import { runCli } from "../../run/runner.js";
import { selectCorp } from "../../helpers.js"; import { selectCorp } from "../../helpers.js";
import { getEnterprisesDirCandidates, loadCorpConfigs, loadGlobalConfig } from "../../../core/config/loader.js"; import { getEnterprisesDirCandidates, loadCorpConfigs, loadGlobalConfig } from "../../../core/config/loader.js";
import { resolveCorpConfig } from "../../../core/config/manager.js"; import { resolveCorpConfig } from "../../../core/config/manager.js";
+1 -1
View File
@@ -1,7 +1,7 @@
import { afterEach, describe, expect, test } from "bun:test"; import { afterEach, describe, expect, test } from "bun:test";
import type { KyInstance } from "ky"; import type { KyInstance } from "ky";
import { CorpConfigSchema } from "../../core/config/types.js"; import { CorpConfigSchema } from "../../core/config/types.js";
import { parseArgs } from "../parser.js"; import { parseArgs } from "../parse/parser.js";
import { runCapabilityResult } from "../helpers.js"; import { runCapabilityResult } from "../helpers.js";
import { handleDeployCommand } from "./deploy.js"; import { handleDeployCommand } from "./deploy.js";
+2 -2
View File
@@ -2,8 +2,8 @@ import { readFileSync } from "node:fs";
import type { CorpConfig } from "../../core/config/types.js"; import type { CorpConfig } from "../../core/config/types.js";
import type { createSealClient } from "../../core/http/factory.js"; import type { createSealClient } from "../../core/http/factory.js";
import { runCapability } from "../helpers.js"; import { runCapability } from "../helpers.js";
import { booleanOption, jsonObject, numberOption, stringOption } from "../parser.js"; import { booleanOption, jsonObject, numberOption, stringOption } from "../parse/parser.js";
import { outputOptions } from "../printer.js"; import { outputOptions } from "../output/printer.js";
import type { ParsedArgs } from "../types.js"; import type { ParsedArgs } from "../types.js";
import * as api from "../../domains/seal/api.js"; import * as api from "../../domains/seal/api.js";
import { listHoseIntegrations } from "../../domains/seal/outbound/push.js"; import { listHoseIntegrations } from "../../domains/seal/outbound/push.js";
+1 -1
View File
@@ -1,5 +1,5 @@
import { describe, expect, test } from "bun:test"; import { describe, expect, test } from "bun:test";
import { runCli } from "../runner.js"; import { runCli } from "../run/runner.js";
describe("seal-use doctor CLI", () => { describe("seal-use doctor CLI", () => {
test("runs full system diagnosis and outputs JSON to stdout and dashboard to stderr", async () => { test("runs full system diagnosis and outputs JSON to stdout and dashboard to stderr", async () => {
+4 -4
View File
@@ -1,7 +1,7 @@
import { diagnoseSystem, formatDoctorDashboard } from "../../core/doctor/diagnose.js"; import { diagnoseSystem, formatDoctorDashboard } from "../../core/doctor/diagnose.js";
import { getEmbeddedGuideMarkdown } from "../../core/doctor/knowledge.js"; import { getEmbeddedGuideMarkdown } from "../../core/doctor/knowledge.js";
import { booleanOption } from "../parser.js"; import { booleanOption } from "../parse/parser.js";
import { printJson } from "../printer.js"; import { printJson } from "../output/printer.js";
import type { ParsedArgs } from "../types.js"; import type { ParsedArgs } from "../types.js";
export async function handleDoctorCommand( export async function handleDoctorCommand(
@@ -28,7 +28,7 @@ export async function handleDoctorCommand(
// 2.5. Output auth session diagnostics (seal-use doctor auth) // 2.5. Output auth session diagnostics (seal-use doctor auth)
if (subAction === "auth") { if (subAction === "auth") {
const { selectCorp } = await import("../helpers.js"); const { selectCorp } = await import("../helpers.js");
const { stringOption } = await import("../parser.js"); const { stringOption } = await import("../parse/parser.js");
const { handleAuthCommand } = await import("./auth.js"); const { handleAuthCommand } = await import("./auth.js");
const corpSelector = const corpSelector =
stringOption(args.options.corp) ?? stringOption(args.options.corp) ??
@@ -43,7 +43,7 @@ export async function handleDoctorCommand(
if (subAction === "tenant" || subAction === "corp" || subAction === "enterprise") { if (subAction === "tenant" || subAction === "corp" || subAction === "enterprise") {
const { selectCorp } = await import("../helpers.js"); const { selectCorp } = await import("../helpers.js");
const { createSealClient } = await import("../../core/http/factory.js"); const { createSealClient } = await import("../../core/http/factory.js");
const { stringOption } = await import("../parser.js"); const { stringOption } = await import("../parse/parser.js");
const { diagnoseTenantContract, formatTenantDoctorDashboard } = await import("../../domains/seal/doctor/tenant-diagnose.js"); const { diagnoseTenantContract, formatTenantDoctorDashboard } = await import("../../domains/seal/doctor/tenant-diagnose.js");
const corpSelector = const corpSelector =
+1 -1
View File
@@ -2,7 +2,7 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test"
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs" import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"
import { tmpdir } from "node:os" import { tmpdir } from "node:os"
import { join } from "node:path" import { join } from "node:path"
import { runCli } from "../runner.js" import { runCli } from "../run/runner.js"
const envKeys = ["SEAL_USE_ENTERPRISES_DIR", "SEAL_USE_CONFIG_FILE", "SEAL_USE_TOKEN_STORE", "SEAL_USE_USAGE_FILE"] as const const envKeys = ["SEAL_USE_ENTERPRISES_DIR", "SEAL_USE_CONFIG_FILE", "SEAL_USE_TOKEN_STORE", "SEAL_USE_USAGE_FILE"] as const
const oldEnv = Object.fromEntries(envKeys.map(key => [key, process.env[key]])) const oldEnv = Object.fromEntries(envKeys.map(key => [key, process.env[key]]))
+2 -2
View File
@@ -12,8 +12,8 @@ import {
numberOption, numberOption,
splitOption, splitOption,
stringOption stringOption
} from "../parser.js"; } from "../parse/parser.js";
import { outputOptions, printJson } from "../printer.js"; import { outputOptions, printJson } from "../output/printer.js";
import type { ParsedArgs } from "../types.js"; import type { ParsedArgs } from "../types.js";
function contentFilePath(args: ParsedArgs): string | undefined { function contentFilePath(args: ParsedArgs): string | undefined {
+1 -1
View File
@@ -2,7 +2,7 @@ import { afterEach, describe, expect, test } from "bun:test";
import { mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"; import { mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os"; import { tmpdir } from "node:os";
import { join } from "node:path"; import { join } from "node:path";
import { runCli } from "../runner.js"; import { runCli } from "../run/runner.js";
/** /**
* Mutation-preview (`--dry-run`) gates for commands that previously mutated * Mutation-preview (`--dry-run`) gates for commands that previously mutated
+1 -1
View File
@@ -2,7 +2,7 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test"
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs" import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"
import { tmpdir } from "node:os" import { tmpdir } from "node:os"
import { join } from "node:path" import { join } from "node:path"
import { runCli } from "../runner.js" import { runCli } from "../run/runner.js"
const envKeys = ["SEAL_USE_CONFIG_FILE", "SEAL_USE_ENTERPRISES_DIR", "SEAL_USE_TOKEN_STORE", "SEAL_USE_USAGE_FILE"] as const const envKeys = ["SEAL_USE_CONFIG_FILE", "SEAL_USE_ENTERPRISES_DIR", "SEAL_USE_TOKEN_STORE", "SEAL_USE_USAGE_FILE"] as const
const oldEnv = Object.fromEntries(envKeys.map(key => [key, process.env[key]])) const oldEnv = Object.fromEntries(envKeys.map(key => [key, process.env[key]]))
+2 -2
View File
@@ -3,8 +3,8 @@ import type { createSealClient } from "../../core/http/factory.js"
import { usageError } from "../../core/errors.js" import { usageError } from "../../core/errors.js"
import { ExpenseLookupError } from "../../domains/seal/expenses/lookup.js" import { ExpenseLookupError } from "../../domains/seal/expenses/lookup.js"
import { runCapabilityResult } from "../helpers.js" import { runCapabilityResult } from "../helpers.js"
import { numberOption, stringOption } from "../parser.js" import { numberOption, stringOption } from "../parse/parser.js"
import { outputOptions, printJson } from "../printer.js" import { outputOptions, printJson } from "../output/printer.js"
import type { ParsedArgs } from "../types.js" import type { ParsedArgs } from "../types.js"
export async function handleExpensesCommand(action: string | undefined, client: Awaited<ReturnType<typeof createSealClient>>, corp: CorpConfig, args: ParsedArgs) { export async function handleExpensesCommand(action: string | undefined, client: Awaited<ReturnType<typeof createSealClient>>, corp: CorpConfig, args: ParsedArgs) {
+1 -1
View File
@@ -5,7 +5,7 @@ import { join } from "node:path";
import type { KyInstance } from "ky"; import type { KyInstance } from "ky";
import { CorpConfigSchema } from "../../core/config/types.js"; import { CorpConfigSchema } from "../../core/config/types.js";
import { classifyCliError } from "../../core/errors.js"; import { classifyCliError } from "../../core/errors.js";
import { parseArgs } from "../parser.js"; import { parseArgs } from "../parse/parser.js";
import { handleHoseEbotCommand } from "./hose-ebot.js"; import { handleHoseEbotCommand } from "./hose-ebot.js";
const ORIGINAL_ENV = { const ORIGINAL_ENV = {
+2 -2
View File
@@ -2,8 +2,8 @@ import type { CorpConfig } from "../../core/config/types.js";
import type { createSealClient } from "../../core/http/factory.js"; import type { createSealClient } from "../../core/http/factory.js";
import { CliError } from "../../core/errors.js"; import { CliError } from "../../core/errors.js";
import { runCapability } from "../helpers.js"; import { runCapability } from "../helpers.js";
import { booleanOption, numberOption, stringOption } from "../parser.js"; import { booleanOption, numberOption, stringOption } from "../parse/parser.js";
import { outputOptions } from "../printer.js"; import { outputOptions } from "../output/printer.js";
import type { ParsedArgs } from "../types.js"; import type { ParsedArgs } from "../types.js";
const USAGE = const USAGE =
+2 -2
View File
@@ -2,8 +2,8 @@ import type { CorpConfig } from "../../core/config/types.js";
import type { createSealClient } from "../../core/http/factory.js"; import type { createSealClient } from "../../core/http/factory.js";
import { traceInvoice } from "../../domains/seal/approval-runs/invoices.js"; import { traceInvoice } from "../../domains/seal/approval-runs/invoices.js";
import { runCapability } from "../helpers.js"; import { runCapability } from "../helpers.js";
import { booleanOption, numberOption, stringOption } from "../parser.js"; import { booleanOption, numberOption, stringOption } from "../parse/parser.js";
import { outputOptions, printJson } from "../printer.js"; import { outputOptions, printJson } from "../output/printer.js";
import type { ParsedArgs } from "../types.js"; import type { ParsedArgs } from "../types.js";
export async function handleInvoicesCommand( export async function handleInvoicesCommand(
+2 -2
View File
@@ -1,7 +1,7 @@
import { validationError, usageError } from "../../core/errors.js"; import { validationError, usageError } from "../../core/errors.js";
import { booleanOption, numberOption, splitOption, stringOption } from "../parser.js"; import { booleanOption, numberOption, splitOption, stringOption } from "../parse/parser.js";
import { runLangfuseCapability } from "../helpers.js"; import { runLangfuseCapability } from "../helpers.js";
import { outputOptions } from "../printer.js"; import { outputOptions } from "../output/printer.js";
import type { ParsedArgs } from "../types.js"; import type { ParsedArgs } from "../types.js";
/** /**
+1 -1
View File
@@ -2,7 +2,7 @@ import { usageError } from "../../core/errors.js";
import type { CorpConfig } from "../../core/config/types.js"; import type { CorpConfig } from "../../core/config/types.js";
import type { createSealClient } from "../../core/http/factory.js"; import type { createSealClient } from "../../core/http/factory.js";
import { runCapability } from "../helpers.js"; import { runCapability } from "../helpers.js";
import { outputOptions } from "../printer.js"; import { outputOptions } from "../output/printer.js";
import type { ParsedArgs } from "../types.js"; import type { ParsedArgs } from "../types.js";
export async function handleLlmCommand( export async function handleLlmCommand(
+1 -1
View File
@@ -1,4 +1,4 @@
import { printJson } from "../printer.js"; import { printJson } from "../output/printer.js";
export async function handleMcpCommand(action: string | undefined) { export async function handleMcpCommand(action: string | undefined) {
if (action === "config" || action === "json") { if (action === "config" || action === "json") {
+1 -1
View File
@@ -2,7 +2,7 @@ import { usageError } from "../../core/errors.js";
import type { CorpConfig } from "../../core/config/types.js"; import type { CorpConfig } from "../../core/config/types.js";
import type { createSealClient } from "../../core/http/factory.js"; import type { createSealClient } from "../../core/http/factory.js";
import { runCapability } from "../helpers.js"; import { runCapability } from "../helpers.js";
import { outputOptions } from "../printer.js"; import { outputOptions } from "../output/printer.js";
import type { ParsedArgs } from "../types.js"; import type { ParsedArgs } from "../types.js";
export async function handlePermissionsCommand( export async function handlePermissionsCommand(
+2 -2
View File
@@ -3,8 +3,8 @@ import { readFileSync } from "node:fs";
import type { CorpConfig } from "../../core/config/types.js"; import type { CorpConfig } from "../../core/config/types.js";
import type { createSealClient } from "../../core/http/factory.js"; import type { createSealClient } from "../../core/http/factory.js";
import { runCapability } from "../helpers.js"; import { runCapability } from "../helpers.js";
import { booleanOption, jsonObject, stringOption } from "../parser.js"; import { booleanOption, jsonObject, stringOption } from "../parse/parser.js";
import { outputOptions } from "../printer.js"; import { outputOptions } from "../output/printer.js";
import type { ParsedArgs } from "../types.js"; import type { ParsedArgs } from "../types.js";
export async function handlePreferenceCommand( export async function handlePreferenceCommand(
+2 -2
View File
@@ -1,6 +1,6 @@
import { runProbe } from "../../probe.js"; import { runProbe } from "../../probe.js";
import { stringOption } from "../parser.js"; import { stringOption } from "../parse/parser.js";
import { printJson } from "../printer.js"; import { printJson } from "../output/printer.js";
import type { ParsedArgs } from "../types.js"; import type { ParsedArgs } from "../types.js";
export async function handleProbeCommand(action: string | undefined, maybeName: string | undefined, args: ParsedArgs) { export async function handleProbeCommand(action: string | undefined, maybeName: string | undefined, args: ParsedArgs) {
+1 -1
View File
@@ -2,7 +2,7 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test";
import { mkdtempSync, rmSync } from "node:fs"; import { mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os"; import { tmpdir } from "node:os";
import { join } from "node:path"; import { join } from "node:path";
import { runCli } from "../runner.js"; import { runCli } from "../run/runner.js";
import { saveCorpConfig } from "../../core/config/repository.js"; import { saveCorpConfig } from "../../core/config/repository.js";
import { import {
closeReviewsDb, closeReviewsDb,
+2 -2
View File
@@ -3,8 +3,8 @@ import { resolve } from "node:path";
import type { CorpConfig } from "../../core/config/types.js"; import type { CorpConfig } from "../../core/config/types.js";
import type { createSealClient } from "../../core/http/factory.js"; import type { createSealClient } from "../../core/http/factory.js";
import { runCapabilityResult } from "../helpers.js"; import { runCapabilityResult } from "../helpers.js";
import { booleanOption, numberOption, stringOption } from "../parser.js"; import { booleanOption, numberOption, stringOption } from "../parse/parser.js";
import { outputOptions, printJson } from "../printer.js"; import { outputOptions, printJson } from "../output/printer.js";
import { CliError, usageError } from "../../core/errors.js"; import { CliError, usageError } from "../../core/errors.js";
import { isCorpDisabledError } from "../../core/config/active.js"; import { isCorpDisabledError } from "../../core/config/active.js";
import { import {
+2 -2
View File
@@ -20,13 +20,13 @@ import {
ruleVersionSearchOptions, ruleVersionSearchOptions,
splitOption, splitOption,
stringOption stringOption
} from "../parser.js"; } from "../parse/parser.js";
import { import {
outputOptions, outputOptions,
printJson, printJson,
protectLargeRuleListOutput, protectLargeRuleListOutput,
RULE_SUMMARY_FIELDS RULE_SUMMARY_FIELDS
} from "../printer.js"; } from "../output/printer.js";
import type { ParsedArgs } from "../types.js"; import type { ParsedArgs } from "../types.js";
function readDescriptionInput(args: ParsedArgs, payload: Record<string, unknown>): string | undefined { function readDescriptionInput(args: ParsedArgs, payload: Record<string, unknown>): string | undefined {
+1 -1
View File
@@ -2,7 +2,7 @@ import { afterEach, describe, expect, test } from "bun:test";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs"; import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os"; import { tmpdir } from "node:os";
import { join } from "node:path"; import { join } from "node:path";
import { runCli } from "../runner.js"; import { runCli } from "../run/runner.js";
const ORIGINAL_ENV = { const ORIGINAL_ENV = {
enterprises: process.env.SEAL_USE_ENTERPRISES_DIR, enterprises: process.env.SEAL_USE_ENTERPRISES_DIR,
+2 -2
View File
@@ -10,8 +10,8 @@ import {
numberOption, numberOption,
splitOption, splitOption,
stringOption stringOption
} from "../parser.js"; } from "../parse/parser.js";
import { outputOptions, printJson } from "../printer.js"; import { outputOptions, printJson } from "../output/printer.js";
import type { ParsedArgs } from "../types.js"; import type { ParsedArgs } from "../types.js";
export async function handleSimulationCommand( export async function handleSimulationCommand(
+2 -2
View File
@@ -11,8 +11,8 @@ import {
getSkillContent, getSkillContent,
installSkillFiles installSkillFiles
} from "../../core/skill/embedded-skill.js"; } from "../../core/skill/embedded-skill.js";
import { booleanOption, stringOption } from "../parser.js"; import { booleanOption, stringOption } from "../parse/parser.js";
import { printJson } from "../printer.js"; import { printJson } from "../output/printer.js";
import type { ParsedArgs } from "../types.js"; import type { ParsedArgs } from "../types.js";
import { getSkillVersionStatus } from "../../core/skill/skill-version.js"; import { getSkillVersionStatus } from "../../core/skill/skill-version.js";
import { VERSION } from "../../version.js"; import { VERSION } from "../../version.js";
+1 -1
View File
@@ -1,7 +1,7 @@
import { usageError } from "../../core/errors.js"; import { usageError } from "../../core/errors.js";
import type { CorpConfig } from "../../core/config/types.js"; import type { CorpConfig } from "../../core/config/types.js";
import { resolveLiveSealEnterpriseConfig } from "../../domains/seal/enterprise/source.js"; import { resolveLiveSealEnterpriseConfig } from "../../domains/seal/enterprise/source.js";
import { printJson } from "../printer.js"; import { printJson } from "../output/printer.js";
export async function handleSourceCommand(action: string | undefined, corp: CorpConfig) { export async function handleSourceCommand(action: string | undefined, corp: CorpConfig) {
if (action === "config") { if (action === "config") {
+1 -1
View File
@@ -3,7 +3,7 @@ import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os"; import { tmpdir } from "node:os";
import { join } from "node:path"; import { join } from "node:path";
import type { CorpConfig } from "../../core/config/types.js"; import type { CorpConfig } from "../../core/config/types.js";
import { runCli } from "../runner.js"; import { runCli } from "../run/runner.js";
const ORIGINAL_ENV = { const ORIGINAL_ENV = {
enterprises: process.env.SEAL_USE_ENTERPRISES_DIR, enterprises: process.env.SEAL_USE_ENTERPRISES_DIR,
+2 -2
View File
@@ -1,7 +1,7 @@
import { CliError } from "../../core/errors.js"; import { CliError } from "../../core/errors.js";
import { selectCorp } from "../helpers.js"; import { selectCorp } from "../helpers.js";
import { booleanOption, numberOption, stringOption } from "../parser.js"; import { booleanOption, numberOption, stringOption } from "../parse/parser.js";
import { printJson } from "../printer.js"; import { printJson } from "../output/printer.js";
import type { ParsedArgs } from "../types.js"; import type { ParsedArgs } from "../types.js";
import { createSealClient } from "../../core/http/factory.js"; import { createSealClient } from "../../core/http/factory.js";
import { import {
+1 -1
View File
@@ -7,7 +7,7 @@ import { normalizeBeijingIso } from "../../core/config/timestamps.js";
import { readInstalledSkillVersion } from "../../core/skill/embedded-skill.js"; import { readInstalledSkillVersion } from "../../core/skill/embedded-skill.js";
import { saveUpdateCache } from "../../core/update/update-cache.js"; import { saveUpdateCache } from "../../core/update/update-cache.js";
import { VERSION, IS_RELEASE } from "../../version.js"; import { VERSION, IS_RELEASE } from "../../version.js";
import { printJson } from "../printer.js"; import { printJson } from "../output/printer.js";
import { validationError } from "../../core/errors.js"; import { validationError } from "../../core/errors.js";
import type { CliRuntime } from "../types.js"; import type { CliRuntime } from "../types.js";
+1 -1
View File
@@ -2,7 +2,7 @@ import { afterEach, describe, expect, test } from "bun:test";
import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from "node:fs"; import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os"; import { tmpdir } from "node:os";
import { join } from "node:path"; import { join } from "node:path";
import { runCli } from "../runner.js"; import { runCli } from "../run/runner.js";
const ORIGINAL_ENV = { const ORIGINAL_ENV = {
enterprises: process.env.SEAL_USE_ENTERPRISES_DIR, enterprises: process.env.SEAL_USE_ENTERPRISES_DIR,
+2 -2
View File
@@ -2,8 +2,8 @@ import type { CorpConfig } from "../../core/config/types.js";
import type { createSealClient } from "../../core/http/factory.js"; import type { createSealClient } from "../../core/http/factory.js";
import { confirmationRequired, usageError } from "../../core/errors.js"; import { confirmationRequired, usageError } from "../../core/errors.js";
import { runCapability } from "../helpers.js"; import { runCapability } from "../helpers.js";
import { booleanOption, dryRunOption, parseDelegationExpireHours, stringOption } from "../parser.js"; import { booleanOption, dryRunOption, parseDelegationExpireHours, stringOption } from "../parse/parser.js";
import { outputOptions } from "../printer.js"; import { outputOptions } from "../output/printer.js";
import type { ParsedArgs } from "../types.js"; import type { ParsedArgs } from "../types.js";
export async function handleUsersCommand( export async function handleUsersCommand(
+1 -1
View File
@@ -2,7 +2,7 @@ import { afterEach, describe, expect, test } from "bun:test";
import { mkdtempSync, rmSync, writeFileSync } from "node:fs"; import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os"; import { tmpdir } from "node:os";
import { join } from "node:path"; import { join } from "node:path";
import { runCli } from "../runner.js"; import { runCli } from "../run/runner.js";
const ORIGINAL_ENV = { const ORIGINAL_ENV = {
enterprises: process.env.SEAL_USE_ENTERPRISES_DIR, enterprises: process.env.SEAL_USE_ENTERPRISES_DIR,
@@ -2,7 +2,7 @@ import { afterEach, describe, expect, test } from "bun:test";
import { mkdtempSync, rmSync, writeFileSync, existsSync } from "node:fs"; import { mkdtempSync, rmSync, writeFileSync, existsSync } from "node:fs";
import { tmpdir } from "node:os"; import { tmpdir } from "node:os";
import { join } from "node:path"; import { join } from "node:path";
import { runCli } from "../runner.js"; import { runCli } from "../run/runner.js";
import { exportApprovalRunsToResourcePack } from "../../domains/seal/material-pack/export.js"; import { exportApprovalRunsToResourcePack } from "../../domains/seal/material-pack/export.js";
import { previewResourcePack } from "../../domains/seal/material-pack/service.js"; import { previewResourcePack } from "../../domains/seal/material-pack/service.js";
+2 -2
View File
@@ -28,8 +28,8 @@ import {
stringOption, stringOption,
webhookRateOption, webhookRateOption,
webhookShowSecretOption webhookShowSecretOption
} from "../parser.js"; } from "../parse/parser.js";
import { outputOptions, printJson } from "../printer.js"; import { outputOptions, printJson } from "../output/printer.js";
import type { ParsedArgs } from "../types.js"; import type { ParsedArgs } from "../types.js";
import type { MaterialPackFilePolicyPatch } from "../../domains/seal/material-pack/policy.js"; import type { MaterialPackFilePolicyPatch } from "../../domains/seal/material-pack/policy.js";
import { CliError, confirmationRequired, usageError, validationError } from "../../core/errors.js"; import { CliError, confirmationRequired, usageError, validationError } from "../../core/errors.js";
@@ -1,8 +1,8 @@
import { describe, expect, test } from "bun:test"; import { describe, expect, test } from "bun:test";
import { readFileSync, readdirSync } from "node:fs"; import { readFileSync, readdirSync } from "node:fs";
import { join } from "node:path"; import { join } from "node:path";
import { parseArgs } from "./parser.js"; import { parseArgs } from "../parse/parser.js";
import { KNOWN_AREAS, UPDATE_ALIASES } from "./runner.js"; import { KNOWN_AREAS, UPDATE_ALIASES } from "../run/runner.js";
/** /**
* Documentation cross-check: every command a maintained doc shows a reader must * Documentation cross-check: every command a maintained doc shows a reader must
@@ -21,7 +21,7 @@ import { KNOWN_AREAS, UPDATE_ALIASES } from "./runner.js";
* like "the seal-use wrapped API" is not a command and is not matched. * like "the seal-use wrapped API" is not a command and is not matched.
*/ */
const REPO_ROOT = join(import.meta.dir, "..", ".."); const REPO_ROOT = join(import.meta.dir, "..", "..", "..");
const DOC_FILES = [ const DOC_FILES = [
"README.md", "README.md",
@@ -1,6 +1,6 @@
import { describe, expect, test } from "bun:test"; import { describe, expect, test } from "bun:test";
import { extractHelpRequest, HELP_REGISTRY, renderHelp } from "./help.js"; import { extractHelpRequest, HELP_REGISTRY, renderHelp } from "./help.js";
import { KNOWN_AREAS, runCli } from "./runner.js"; import { KNOWN_AREAS, runCli } from "../run/runner.js";
describe("extractHelpRequest", () => { describe("extractHelpRequest", () => {
test("detects global help from empty command or help option", () => { test("detects global help from empty command or help option", () => {
+3 -3
View File
@@ -1,6 +1,6 @@
import { normalizeCliArea } from "./area-aliases.js"; import { normalizeCliArea } from "../parse/area-aliases.js";
import type { ParsedArgs } from "./types.js"; import type { ParsedArgs } from "../types.js";
import { usageError } from "../core/errors.js"; import { usageError } from "../../core/errors.js";
export interface CommandOptionHelp { export interface CommandOptionHelp {
flag: string; flag: string;
@@ -2,7 +2,7 @@ import { describe, expect, test } from "bun:test";
import { readFileSync } from "node:fs"; import { readFileSync } from "node:fs";
import { fileURLToPath } from "node:url"; import { fileURLToPath } from "node:url";
import { HELP_REGISTRY } from "./help.js"; import { HELP_REGISTRY } from "./help.js";
import { parseArgs } from "./parser.js"; import { parseArgs } from "../parse/parser.js";
/** /**
* Naming charter guard (.agents/rules/cli-protocol.md "Naming Charter"). * Naming charter guard (.agents/rules/cli-protocol.md "Naming Charter").
@@ -110,20 +110,20 @@ describe("naming charter: canonical accept-sets are wired in commands", () => {
const read = (path: string) => readFileSync(fileURLToPath(new URL(path, import.meta.url)), "utf8"); const read = (path: string) => readFileSync(fileURLToPath(new URL(path, import.meta.url)), "utf8");
test("webhook resource-pack export reads --out and --downloads (no silent ignore)", () => { test("webhook resource-pack export reads --out and --downloads (no silent ignore)", () => {
const source = read("./commands/webhook.ts"); const source = read("../commands/webhook.ts");
expect(source).toContain("stringOption(args.options.out) ??"); expect(source).toContain("stringOption(args.options.out) ??");
expect(source).toContain("booleanOption(args.options.downloads) ??"); expect(source).toContain("booleanOption(args.options.downloads) ??");
expect(source).toContain("booleanOption(args.options.download) ??"); expect(source).toContain("booleanOption(args.options.download) ??");
}); });
test("webhook secret reveal accepts --reveal alongside legacy --show-secret", () => { test("webhook secret reveal accepts --reveal alongside legacy --show-secret", () => {
const source = read("./parser.ts"); const source = read("../parse/parser.ts");
expect(source).toContain("booleanOption(options.reveal)"); expect(source).toContain("booleanOption(options.reveal)");
expect(source).toContain('booleanOption(options["show-secret"])'); expect(source).toContain('booleanOption(options["show-secret"])');
}); });
test("approval-runs reads canonical --start-date/--end-date everywhere", () => { test("approval-runs reads canonical --start-date/--end-date everywhere", () => {
const source = read("./commands/approval-runs.ts"); const source = read("../commands/approval-runs.ts");
const startDateReads = source.match(/args\.options\["start-date"\]/g)?.length ?? 0; const startDateReads = source.match(/args\.options\["start-date"\]/g)?.length ?? 0;
const endDateReads = source.match(/args\.options\["end-date"\]/g)?.length ?? 0; const endDateReads = source.match(/args\.options\["end-date"\]/g)?.length ?? 0;
expect(startDateReads).toBeGreaterThanOrEqual(3); expect(startDateReads).toBeGreaterThanOrEqual(3);
+1 -1
View File
@@ -7,7 +7,7 @@ import { createLangfuseService, findLangfuseCapability } from "../domains/langfu
import type { LangfuseService } from "../domains/langfuse/service.js"; import type { LangfuseService } from "../domains/langfuse/service.js";
import { validationError } from "../core/errors.js"; import { validationError } from "../core/errors.js";
import type { CorpConfig, GlobalConfig } from "../core/config/types.js"; import type { CorpConfig, GlobalConfig } from "../core/config/types.js";
import { printJson } from "./printer.js"; import { printJson } from "./output/printer.js";
import type { OutputOptions } from "./types.js"; import type { OutputOptions } from "./types.js";
export function selectCorp(corpId?: string, options: { allowDisabled?: boolean } = {}): CorpConfig { export function selectCorp(corpId?: string, options: { allowDisabled?: boolean } = {}): CorpConfig {
@@ -1,8 +1,8 @@
import { writeFileSync } from "node:fs"; import { writeFileSync } from "node:fs";
import { booleanOption, stringOption } from "./parser.js"; import { booleanOption, stringOption } from "../parse/parser.js";
import { PayloadTooLargeError } from "../core/errors.js"; import { PayloadTooLargeError } from "../../core/errors.js";
import { redactSensitiveText } from "../core/util/redact.js"; import { redactSensitiveText } from "../../core/util/redact.js";
import type { OutputOptions } from "./types.js"; import type { OutputOptions } from "../types.js";
export { redactSensitiveText }; export { redactSensitiveText };
@@ -68,7 +68,7 @@ export function outputOptions(options: Record<string, string | boolean>): Output
}; };
} }
import { renderHelp } from "./help.js"; import { renderHelp } from "../help/help.js";
export function printHelp(target: string[] = []) { export function printHelp(target: string[] = []) {
console.log(renderHelp(target)); console.log(renderHelp(target));
@@ -1,6 +1,6 @@
import { describe, expect, test } from "bun:test"; import { describe, expect, test } from "bun:test";
import { AREA_ALIASES, UPDATE_ALIASES, normalizeCliArea } from "./area-aliases.js"; import { AREA_ALIASES, UPDATE_ALIASES, normalizeCliArea } from "./area-aliases.js";
import { KNOWN_AREAS } from "./runner.js"; import { KNOWN_AREAS } from "../run/runner.js";
/** /**
* Drift guard for the shared alias table. * Drift guard for the shared alias table.
File renamed without changes.
@@ -1,5 +1,5 @@
import { describe, expect, test } from "bun:test"; import { describe, expect, test } from "bun:test";
import { HELP_REGISTRY } from "./help.js"; import { HELP_REGISTRY } from "../help/help.js";
import { import {
booleanOption, booleanOption,
BOOLEAN_FLAGS, BOOLEAN_FLAGS,
@@ -1,8 +1,8 @@
import type { WebhookMode } from "../domains/seal/types.js"; import type { WebhookMode } from "../../domains/seal/types.js";
import type { MaterialPackFilePolicyPatch } from "../domains/seal/material-pack/policy.js"; import type { MaterialPackFilePolicyPatch } from "../../domains/seal/material-pack/policy.js";
import type { ParsedArgs } from "./types.js"; import type { ParsedArgs } from "../types.js";
import { type DurationToken, EXPIRE_UNITS, expireSeconds, tokenizeDuration } from "../core/util/duration.js"; import { type DurationToken, EXPIRE_UNITS, expireSeconds, tokenizeDuration } from "../../core/util/duration.js";
import { usageError, validationError } from "../core/errors.js"; import { usageError, validationError } from "../../core/errors.js";
/** /**
* Flag metadata for argv parsing, derived from how the code reads each flag: * Flag metadata for argv parsing, derived from how the code reads each flag:
@@ -3,7 +3,7 @@
* reach the CLI intact. Lives in its own module because both the MCP server and the HTTP routes * reach the CLI intact. Lives in its own module because both the MCP server and the HTTP routes
* need it; importing it from the server entry would make the CLI graph circular. * need it; importing it from the server entry would make the CLI graph circular.
*/ */
import { usageError } from "../core/errors.js"; import { usageError } from "../../core/errors.js";
export function tokenizeCommand(command: string): string[] { export function tokenizeCommand(command: string): string[] {
const tokens: string[] = []; const tokens: string[] = [];
let token = ""; let token = "";
@@ -1,9 +1,9 @@
import { describe, expect, test } from "bun:test"; import { describe, expect, test } from "bun:test";
import { readFileSync, readdirSync } from "node:fs"; import { readFileSync, readdirSync } from "node:fs";
import { join } from "node:path"; import { join } from "node:path";
import { HELP_REGISTRY } from "./help.js"; import { HELP_REGISTRY } from "../help/help.js";
import { KNOWN_AREAS } from "./runner.js"; import { KNOWN_AREAS } from "./runner.js";
import { SEAL_MUTATING_CAPABILITIES, SEAL_READ_ONLY_CAPABILITIES, sealCapabilities } from "../domains/seal/capabilities.js"; import { SEAL_MUTATING_CAPABILITIES, SEAL_READ_ONLY_CAPABILITIES, sealCapabilities } from "../../domains/seal/capabilities.js";
import { isReadOnlyCliCommand, listReadOnlyCommands } from "./read-only.js"; import { isReadOnlyCliCommand, listReadOnlyCommands } from "./read-only.js";
describe("CLI read-only classification", () => { describe("CLI read-only classification", () => {
@@ -177,14 +177,14 @@ describe("CLI allow-list agrees with the tool registry", () => {
]); ]);
test("every CLI verb dispatching to a read-only tool is itself read-only, and mutating tools are not read-only", () => { test("every CLI verb dispatching to a read-only tool is itself read-only, and mutating tools are not read-only", () => {
const files = readdirSync(join(import.meta.dir, "commands")).filter( const files = readdirSync(join(import.meta.dir, "../commands")).filter(
(f) => f.endsWith(".ts") && !f.endsWith(".test.ts") (f) => f.endsWith(".ts") && !f.endsWith(".test.ts")
); );
const pairs: Array<{ area: string; action: string; tool: string }> = []; const pairs: Array<{ area: string; action: string; tool: string }> = [];
for (const file of files) { for (const file of files) {
const area = file.replace(/\.ts$/, ""); const area = file.replace(/\.ts$/, "");
const source = readFileSync(join(import.meta.dir, "commands", file), "utf8"); const source = readFileSync(join(import.meta.dir, "../commands", file), "utf8");
const pattern = const pattern =
/if\s*\(\s*action === "([a-z0-9-]+)"(?:(?!\bif\s*\(\s*action\b)[\s\S]){0,600}?runCapability(?:Result)?\(\s*"(seal[A-Z][A-Za-z0-9]*)"/g; /if\s*\(\s*action === "([a-z0-9-]+)"(?:(?!\bif\s*\(\s*action\b)[\s\S]){0,600}?runCapability(?:Result)?\(\s*"(seal[A-Z][A-Za-z0-9]*)"/g;
let match; let match;
@@ -1,5 +1,5 @@
import { normalizeCliArea } from "./area-aliases.js"; import { normalizeCliArea } from "../parse/area-aliases.js";
import { parseArgs } from "./parser.js"; import { parseArgs } from "../parse/parser.js";
/** /**
* Read-only classification for CLI commands, used to decide whether a command may be executed * Read-only classification for CLI commands, used to decide whether a command may be executed
@@ -3,8 +3,8 @@ import { tmpdir } from "node:os";
import { join } from "node:path"; import { join } from "node:path";
import { afterEach, beforeEach, describe, expect, test } from "bun:test"; import { afterEach, beforeEach, describe, expect, test } from "bun:test";
import { runCli } from "./runner.js"; import { runCli } from "./runner.js";
import { saveUpdateCache, UPDATE_CACHE_FILE_ENV } from "../core/update/update-cache.js"; import { saveUpdateCache, UPDATE_CACHE_FILE_ENV } from "../../core/update/update-cache.js";
import { GLOBAL_SKILL_DIR_ENV } from "../core/skill/skill-version.js"; import { GLOBAL_SKILL_DIR_ENV } from "../../core/skill/skill-version.js";
describe("CLI runner", () => { describe("CLI runner", () => {
let tempSkillDir: string; let tempSkillDir: string;
+58 -58
View File
@@ -2,34 +2,34 @@
import { dirname, join } from "node:path"; import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url"; import { fileURLToPath } from "node:url";
import type { CorpConfig } from "../core/config/types.js"; import type { CorpConfig } from "../../core/config/types.js";
import { VERSION_INFO } from "../version.js"; import { VERSION_INFO } from "../../version.js";
import { isUpdateCacheExpired, loadUpdateCache, triggerBackgroundUpdateCheck } from "../core/update/update-cache.js"; import { isUpdateCacheExpired, loadUpdateCache, triggerBackgroundUpdateCheck } from "../../core/update/update-cache.js";
import { classifyCliError, usageError, validationError } from "../core/errors.js"; import { classifyCliError, usageError, validationError } from "../../core/errors.js";
import { isCorpDisabledError } from "../core/config/active.js"; import { isCorpDisabledError } from "../../core/config/active.js";
import { import {
booleanOption, booleanOption,
materialPackFilePolicyOptions, materialPackFilePolicyOptions,
numberOption, numberOption,
parseArgs, parseArgs,
stringOption stringOption
} from "./parser.js"; } from "../parse/parser.js";
import { extractHelpRequest } from "./help.js"; import { extractHelpRequest } from "../help/help.js";
import { isNewerVersion } from "../core/util/semver.js"; import { isNewerVersion } from "../../core/util/semver.js";
import { getSkillVersionStatus } from "../core/skill/skill-version.js"; import { getSkillVersionStatus } from "../../core/skill/skill-version.js";
import { import {
formatConsoleOutput, formatConsoleOutput,
joinOutput, joinOutput,
printHelp, printHelp,
printJson, printJson,
redactSensitiveText redactSensitiveText
} from "./printer.js"; } from "../output/printer.js";
import type { KyInstance } from "ky"; import type { KyInstance } from "ky";
import type { ParsedArgs, CliResult, CliRunOptions, CliRuntime } from "./types.js"; import type { ParsedArgs, CliResult, CliRunOptions, CliRuntime } from "../types.js";
const DEFAULT_APP_ROOT = dirname(dirname(dirname(fileURLToPath(import.meta.url)))); const DEFAULT_APP_ROOT = dirname(dirname(dirname(dirname(fileURLToPath(import.meta.url)))));
export { UPDATE_ALIASES } from "./area-aliases.js"; export { UPDATE_ALIASES } from "../parse/area-aliases.js";
import { AREA_ALIASES, normalizeCliArea, UPDATE_ALIASES } from "./area-aliases.js"; import { AREA_ALIASES, normalizeCliArea, UPDATE_ALIASES } from "../parse/area-aliases.js";
type LocalCommand = (args: ParsedArgs, runtime: CliRuntime) => Promise<void>; type LocalCommand = (args: ParsedArgs, runtime: CliRuntime) => Promise<void>;
type CorpCommand = (args: ParsedArgs, corp: CorpConfig) => Promise<void>; type CorpCommand = (args: ParsedArgs, corp: CorpConfig) => Promise<void>;
@@ -38,56 +38,56 @@ type ClientCommand = (args: ParsedArgs, corp: CorpConfig, client: KyInstance) =>
// Handler tables also define the known command surface. Imports stay lazy so // Handler tables also define the known command surface. Imports stay lazy so
// local discovery never loads the tenant, Excel, or zip implementation graphs. // local discovery never loads the tenant, Excel, or zip implementation graphs.
const LOCAL_COMMANDS: Record<string, LocalCommand> = { const LOCAL_COMMANDS: Record<string, LocalCommand> = {
"mcp-config": async () => (await import("./commands/mcp.js")).printMcpConfig(), "mcp-config": async () => (await import("../commands/mcp.js")).printMcpConfig(),
skill: async (args) => (await import("./commands/skill.js")).handleSkillCommand(args.command[1], args.command[2], args), skill: async (args) => (await import("../commands/skill.js")).handleSkillCommand(args.command[1], args.command[2], args),
mcp: async (args) => (await import("./commands/mcp.js")).handleMcpCommand(args.command[1]), mcp: async (args) => (await import("../commands/mcp.js")).handleMcpCommand(args.command[1]),
probe: async (args) => (await import("./commands/probe.js")).handleProbeCommand(args.command[1], args.command[2], args), probe: async (args) => (await import("../commands/probe.js")).handleProbeCommand(args.command[1], args.command[2], args),
doctor: async (args) => (await import("./commands/doctor.js")).handleDoctorCommand(args.command[1], args.command[2], args), doctor: async (args) => (await import("../commands/doctor.js")).handleDoctorCommand(args.command[1], args.command[2], args),
langfuse: async (args) => (await import("./commands/langfuse.js")).handleLangfuseCommand(args.command[1], args.command[2], args), langfuse: async (args) => (await import("../commands/langfuse.js")).handleLangfuseCommand(args.command[1], args.command[2], args),
test: async (args) => (await import("./commands/test.js")).handleTestCommand(args.command[1], args.command[2], args), test: async (args) => (await import("../commands/test.js")).handleTestCommand(args.command[1], args.command[2], args),
config: async (args) => (await import("./commands/config.js")).handleConfigCommand(args.command[1], args.command[2], args), config: async (args) => (await import("../commands/config.js")).handleConfigCommand(args.command[1], args.command[2], args),
update: dispatchUpdate, update: dispatchUpdate,
changelog: dispatchUpdate, changelog: dispatchUpdate,
corps: async (args) => { corps: async (args) => {
const action = args.command[1]; const action = args.command[1];
// Local discovery must not initialize onboarding, sync or the capability registry. // Local discovery must not initialize onboarding, sync or the capability registry.
if (!action || ["list", "search", "find"].includes(action)) { if (!action || ["list", "search", "find"].includes(action)) {
await (await import("./commands/corps/overview.js")).handleCorpOverview(action, args.command[2], args); await (await import("../commands/corps/overview.js")).handleCorpOverview(action, args.command[2], args);
return; return;
} }
if (action === "regression" || action === "test-regression") { if (action === "regression" || action === "test-regression") {
await (await import("./commands/test.js")).handleTestCommand("regression", args.command[2], args); await (await import("../commands/test.js")).handleTestCommand("regression", args.command[2], args);
return; return;
} }
await (await import("./commands/corps.js")).handleCorpsCommand(action, args.command[2], args); await (await import("../commands/corps.js")).handleCorpsCommand(action, args.command[2], args);
} }
}; };
const CORP_COMMANDS: Record<string, CorpCommand> = { const CORP_COMMANDS: Record<string, CorpCommand> = {
source: async (args, corp) => (await import("./commands/source.js")).handleSourceCommand(args.command[1], corp), source: async (args, corp) => (await import("../commands/source.js")).handleSourceCommand(args.command[1], corp),
auth: async (args, corp) => (await import("./commands/auth.js")).handleAuthCommand(args.command[1], corp, args) auth: async (args, corp) => (await import("../commands/auth.js")).handleAuthCommand(args.command[1], corp, args)
}; };
const CLIENT_COMMANDS: Record<string, ClientCommand> = { const CLIENT_COMMANDS: Record<string, ClientCommand> = {
"users": async (args, corp, client) => (await import("./commands/users.js")).handleUsersCommand(args.command[1], args.command[2], client, corp, args), "users": async (args, corp, client) => (await import("../commands/users.js")).handleUsersCommand(args.command[1], args.command[2], client, corp, args),
"contacts": async (args, corp, client) => (await import("./commands/contacts.js")).handleContactsCommand(args.command[1], args.command[2], client, corp, args), "contacts": async (args, corp, client) => (await import("../commands/contacts.js")).handleContactsCommand(args.command[1], args.command[2], client, corp, args),
"data": async (args, corp, client) => (await import("./commands/data.js")).handleDataCommand(args.command[1], client, corp, args), "data": async (args, corp, client) => (await import("../commands/data.js")).handleDataCommand(args.command[1], client, corp, args),
"invoices": async (args, corp, client) => (await import("./commands/invoices.js")).handleInvoicesCommand(args.command[1], args.command[2], client, corp, args), "invoices": async (args, corp, client) => (await import("../commands/invoices.js")).handleInvoicesCommand(args.command[1], args.command[2], client, corp, args),
"expenses": async (args, corp, client) => (await import("./commands/expenses.js")).handleExpensesCommand(args.command[1], client, corp, args), "expenses": async (args, corp, client) => (await import("../commands/expenses.js")).handleExpensesCommand(args.command[1], client, corp, args),
"llm": async (args, corp, client) => (await import("./commands/llm.js")).handleLlmCommand(args.command[1], client, corp, args), "llm": async (args, corp, client) => (await import("../commands/llm.js")).handleLlmCommand(args.command[1], client, corp, args),
"permissions": async (args, corp, client) => (await import("./commands/permissions.js")).handlePermissionsCommand(args.command[1], client, corp, args), "permissions": async (args, corp, client) => (await import("../commands/permissions.js")).handlePermissionsCommand(args.command[1], client, corp, args),
"billing": async (args, corp, client) => (await import("./commands/billing.js")).handleBillingCommand(args.command[1], client, corp, args), "billing": async (args, corp, client) => (await import("../commands/billing.js")).handleBillingCommand(args.command[1], client, corp, args),
"webhook": async (args, corp, client) => (await import("./commands/webhook.js")).handleWebhookCommand(args.command[1], args.command[2], client, corp, args), "webhook": async (args, corp, client) => (await import("../commands/webhook.js")).handleWebhookCommand(args.command[1], args.command[2], client, corp, args),
"context": async (args, corp, client) => (await import("./commands/context.js")).handleContextCommand(client, corp, args), "context": async (args, corp, client) => (await import("../commands/context.js")).handleContextCommand(client, corp, args),
"documents": async (args, corp, client) => (await import("./commands/documents.js")).handleDocumentsCommand(args.command[1], args.command[2], client, corp, args), "documents": async (args, corp, client) => (await import("../commands/documents.js")).handleDocumentsCommand(args.command[1], args.command[2], client, corp, args),
"rules": async (args, corp, client) => (await import("./commands/rules.js")).handleRulesCommand(args.command[1], args.command[2], client, corp, args), "rules": async (args, corp, client) => (await import("../commands/rules.js")).handleRulesCommand(args.command[1], args.command[2], client, corp, args),
"approval-runs": async (args, corp, client) => (await import("./commands/approval-runs.js")).handleApprovalRunsCommand(args.command[1], args.command[2], client, corp, args), "approval-runs": async (args, corp, client) => (await import("../commands/approval-runs.js")).handleApprovalRunsCommand(args.command[1], args.command[2], client, corp, args),
"analytics": async (args, corp, client) => (await import("./commands/analytics.js")).handleAnalyticsCommand(args.command[1], args.command[2], client, corp, args), "analytics": async (args, corp, client) => (await import("../commands/analytics.js")).handleAnalyticsCommand(args.command[1], args.command[2], client, corp, args),
"report": async (args, corp, client) => (await import("./commands/report.js")).handleReportCommand(args.command[1], client, corp, args), "report": async (args, corp, client) => (await import("../commands/report.js")).handleReportCommand(args.command[1], client, corp, args),
"simulation": async (args, corp, client) => (await import("./commands/simulation.js")).handleSimulationCommand(args.command[1], args.command[2], client, corp, args), "simulation": async (args, corp, client) => (await import("../commands/simulation.js")).handleSimulationCommand(args.command[1], args.command[2], client, corp, args),
"deploy": async (args, corp, client) => (await import("./commands/deploy.js")).handleDeployCommand(args.command[1], args.command[2], args.command[3], client, corp, args), "deploy": async (args, corp, client) => (await import("../commands/deploy.js")).handleDeployCommand(args.command[1], args.command[2], args.command[3], client, corp, args),
"hose-ebot": async (args, corp, client) => (await import("./commands/hose-ebot.js")).handleHoseEbotCommand(args.command[1], args.command[2], client, corp, args), "hose-ebot": async (args, corp, client) => (await import("../commands/hose-ebot.js")).handleHoseEbotCommand(args.command[1], args.command[2], client, corp, args),
"preference": async (args, corp, client) => (await import("./commands/preference.js")).handlePreferenceCommand(args.command[1], args.command[2], args.command[3], args.command[4], client, corp, args), "preference": async (args, corp, client) => (await import("../commands/preference.js")).handlePreferenceCommand(args.command[1], args.command[2], args.command[3], args.command[4], client, corp, args),
}; };
export const KNOWN_AREAS = new Set([ export const KNOWN_AREAS = new Set([
@@ -97,7 +97,7 @@ export const KNOWN_AREAS = new Set([
...Object.keys(AREA_ALIASES) ...Object.keys(AREA_ALIASES)
]); ]);
export type { CliResult, CliRunOptions } from "./types.js"; export type { CliResult, CliRunOptions } from "../types.js";
const STANDING_COMMANDS = new Set(["server", "mcp"]); const STANDING_COMMANDS = new Set(["server", "mcp"]);
@@ -210,7 +210,7 @@ async function dispatchUpdate(args: ParsedArgs, runtime: CliRuntime): Promise<vo
stringOption(args.options.tag) ?? stringOption(args.options.tag) ??
(!isChangelog && !isCheck && !isBgSave && !isSystem && !isUser && action && !action.startsWith("-") ? action : undefined); (!isChangelog && !isCheck && !isBgSave && !isSystem && !isUser && action && !action.startsWith("-") ? action : undefined);
await (await import("./commands/update.js")).handleUpdateCommand(runtime, { await (await import("../commands/update.js")).handleUpdateCommand(runtime, {
checkOnly: isCheck || isBgSave, checkOnly: isCheck || isBgSave,
changelogOnly: isChangelog, changelogOnly: isChangelog,
limit: numberOption(args.options.limit), limit: numberOption(args.options.limit),
@@ -284,7 +284,7 @@ async function dispatch(argv: string[], runtime: CliRuntime) {
) { ) {
const filePath = args.command[3] ?? stringOption(args.options.file) ?? stringOption(args.options.input); const filePath = args.command[3] ?? stringOption(args.options.file) ?? stringOption(args.options.input);
if (!filePath) throw usageError("Usage: seal-use webhook resource-pack preview <资源包.zip>"); if (!filePath) throw usageError("Usage: seal-use webhook resource-pack preview <资源包.zip>");
await (await import("./commands/webhook.js")).handleWebhookResourcePackPreview(filePath, materialPackFilePolicyOptions(args.options)); await (await import("../commands/webhook.js")).handleWebhookResourcePackPreview(filePath, materialPackFilePolicyOptions(args.options));
return; return;
} }
@@ -298,7 +298,7 @@ async function dispatch(argv: string[], runtime: CliRuntime) {
action === "review" || action === "review" ||
Boolean(args.options.ledger)) Boolean(args.options.ledger))
) { ) {
await (await import("./commands/report.js")).handleLocalReportCommand(action, args); await (await import("../commands/report.js")).handleLocalReportCommand(action, args);
return; return;
} }
@@ -313,7 +313,7 @@ async function dispatch(argv: string[], runtime: CliRuntime) {
if (area === "rules" && action === "lint" && ("file" in args.options || "f" in args.options)) { if (area === "rules" && action === "lint" && ("file" in args.options || "f" in args.options)) {
let corp: CorpConfig; let corp: CorpConfig;
try { try {
corp = (await import("./helpers.js")).selectCorp(stringOption(args.options.corp)); corp = (await import("../helpers.js")).selectCorp(stringOption(args.options.corp));
} catch (error) { } catch (error) {
// Local lint tolerates a missing enterprise config, but a disabled tenant // Local lint tolerates a missing enterprise config, but a disabled tenant
// is an explicit block: never degrade into the synthetic workspace corp. // is an explicit block: never degrade into the synthetic workspace corp.
@@ -324,7 +324,7 @@ async function dispatch(argv: string[], runtime: CliRuntime) {
source: { type: "native" } source: { type: "native" }
} as any; } as any;
} }
await (await import("./commands/rules.js")).handleRulesCommand(action, maybeName, null, corp, args); await (await import("../commands/rules.js")).handleRulesCommand(action, maybeName, null, corp, args);
return; return;
} }
@@ -332,7 +332,7 @@ async function dispatch(argv: string[], runtime: CliRuntime) {
area === "auth" && area === "auth" &&
(action === "extract-keys" || action === "extract-key" || action === "extract-hose-keys" || action === "hose-extract-keys") (action === "extract-keys" || action === "extract-key" || action === "extract-hose-keys" || action === "hose-extract-keys")
) { ) {
await (await import("./commands/auth.js")).handleAuthExtractKeysCommand(maybeName, args); await (await import("../commands/auth.js")).handleAuthExtractKeysCommand(maybeName, args);
return; return;
} }
@@ -341,23 +341,23 @@ async function dispatch(argv: string[], runtime: CliRuntime) {
(action === "link" || action === "seal-link") && (action === "link" || action === "seal-link") &&
("from-link" in args.options || maybeName === "from-link") ("from-link" in args.options || maybeName === "from-link")
) { ) {
await (await import("./commands/auth.js")).handleAuthCommand(action, null, args); await (await import("../commands/auth.js")).handleAuthCommand(action, null, args);
return; return;
} }
// Local task observation and previews must not authenticate or contact a tenant. // Local task observation and previews must not authenticate or contact a tenant.
if (area === "approval-runs" && (action === "export" || action === "export-worker")) { if (area === "approval-runs" && (action === "export" || action === "export-worker")) {
await (await import("./commands/approval-runs-export.js")).handleApprovalRunsExportCommand(args, runtime); await (await import("../commands/approval-runs-export.js")).handleApprovalRunsExportCommand(args, runtime);
return; return;
} }
const corp = (await import("./helpers.js")).selectCorp(stringOption(args.options.corp)); const corp = (await import("../helpers.js")).selectCorp(stringOption(args.options.corp));
const maybePromptDivergences = async () => { const maybePromptDivergences = async () => {
if (area === "report" && action === "review") return; if (area === "report" && action === "review") return;
try { try {
const { countUnreviewedDivergences, shouldPromptDivergence } = await import( const { countUnreviewedDivergences, shouldPromptDivergence } = await import(
"../domains/seal/reports/pipeline/review-store.js" "../../domains/seal/reports/pipeline/review-store.js"
); );
const count = countUnreviewedDivergences(corp.id, 30); const count = countUnreviewedDivergences(corp.id, 30);
if (count > 0 && shouldPromptDivergence(corp.id)) { if (count > 0 && shouldPromptDivergence(corp.id)) {
@@ -379,7 +379,7 @@ async function dispatch(argv: string[], runtime: CliRuntime) {
const clientCommand = CLIENT_COMMANDS[area]; const clientCommand = CLIENT_COMMANDS[area];
if (clientCommand) { if (clientCommand) {
const client = await (await import("../core/http/factory.js")).createSealClient(corp); const client = await (await import("../../core/http/factory.js")).createSealClient(corp);
await clientCommand(args, corp, client); await clientCommand(args, corp, client);
await maybePromptDivergences(); await maybePromptDivergences();
return; return;
+1 -1
View File
@@ -2,7 +2,7 @@
* Redacts credential-bearing patterns from free text before it reaches an * Redacts credential-bearing patterns from free text before it reaches an
* output channel. * output channel.
* *
* Applied to: error messages surfaced by the CLI runner (`src/cli/runner.ts`) and * Applied to: error messages surfaced by the CLI runner (`src/cli/run/runner.ts`) and
* HTTP error responses (`src/http/routes.ts`). * HTTP error responses (`src/http/routes.ts`).
* *
* NOT applied to successful stdout payloads: those are redacted where they are * NOT applied to successful stdout payloads: those are redacted where they are
@@ -3,7 +3,7 @@ import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync
import { tmpdir } from "node:os"; import { tmpdir } from "node:os";
import { join } from "node:path"; import { join } from "node:path";
import { PNG } from "pngjs"; import { PNG } from "pngjs";
import { runCli } from "../../../../cli/runner.js"; import { runCli } from "../../../../cli/run/runner.js";
import { buildMonthlyReport } from "../pipeline/index.js"; import { buildMonthlyReport } from "../pipeline/index.js";
import { renderReportFile, saveReportMarkdown, validateReportFile } from "./files.js"; import { renderReportFile, saveReportMarkdown, validateReportFile } from "./files.js";
import { BUILTIN_MONTHLY_TEMPLATE, BUILTIN_TEMPLATE_PATH } from "../templates/resources.js"; import { BUILTIN_MONTHLY_TEMPLATE, BUILTIN_TEMPLATE_PATH } from "../templates/resources.js";
+1 -1
View File
@@ -6,7 +6,7 @@ import type { KyInstance } from "ky";
import type { CorpConfig } from "../../../core/config/types.js"; import type { CorpConfig } from "../../../core/config/types.js";
import { classifyCliError } from "../../../core/errors.js"; import { classifyCliError } from "../../../core/errors.js";
import { handleRulesCommand } from "../../../cli/commands/rules.js"; import { handleRulesCommand } from "../../../cli/commands/rules.js";
import { parseArgs } from "../../../cli/parser.js"; import { parseArgs } from "../../../cli/parse/parser.js";
import type { ApprovalRule } from "../types.js"; import type { ApprovalRule } from "../types.js";
import { import {
executeRulePush, executeRulePush,
+1 -1
View File
@@ -10,7 +10,7 @@ import { recodeApprovalRules } from "../api.js"
import type { ApprovalRulesData } from "../types.js" import type { ApprovalRulesData } from "../types.js"
import { runCapabilityResult } from "../../../cli/helpers.js" import { runCapabilityResult } from "../../../cli/helpers.js"
import { handleRulesCommand } from "../../../cli/commands/rules.js" import { handleRulesCommand } from "../../../cli/commands/rules.js"
import { parseArgs } from "../../../cli/parser.js" import { parseArgs } from "../../../cli/parse/parser.js"
const originalStore = process.env.SEAL_USE_RECODE_STORE const originalStore = process.env.SEAL_USE_RECODE_STORE
const dirs: string[] = [] const dirs: string[] = []
+1 -1
View File
@@ -2,7 +2,7 @@ import { afterEach, describe, expect, test } from "bun:test";
import { mkdtempSync, rmSync, writeFileSync } from "node:fs"; import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os"; import { tmpdir } from "node:os";
import { join } from "node:path"; import { join } from "node:path";
import { runCli } from "./cli/runner.js"; import { runCli } from "./cli/run/runner.js";
const ENV_KEYS = ["SEAL_USE_ENTERPRISES_DIR", "SEAL_USE_CONFIG_FILE", "SEAL_USE_TOKEN_STORE", "SEAL_DISABLE_BG_UPDATE"] as const; const ENV_KEYS = ["SEAL_USE_ENTERPRISES_DIR", "SEAL_USE_CONFIG_FILE", "SEAL_USE_TOKEN_STORE", "SEAL_DISABLE_BG_UPDATE"] as const;
const ORIGINAL_ENV: Record<string, string | undefined> = Object.fromEntries(ENV_KEYS.map((key) => [key, process.env[key]])); const ORIGINAL_ENV: Record<string, string | undefined> = Object.fromEntries(ENV_KEYS.map((key) => [key, process.env[key]]));
+1 -1
View File
@@ -4,7 +4,7 @@ import { createSealClient } from "./core/http/factory.js";
import type { SealEnterpriseConfig } from "./core/auth/types.js"; import type { SealEnterpriseConfig } from "./core/auth/types.js";
import { resolveLiveSealEnterpriseConfig } from "./domains/seal/enterprise/source.js"; import { resolveLiveSealEnterpriseConfig } from "./domains/seal/enterprise/source.js";
import { getApprovalContext } from "./domains/seal/api.js"; import { getApprovalContext } from "./domains/seal/api.js";
import { printJson } from "./cli/printer.js"; import { printJson } from "./cli/output/printer.js";
/** One probe run's payload — the entire stdout of `seal-use probe`. */ /** One probe run's payload — the entire stdout of `seal-use probe`. */
export type ProbeResult = { export type ProbeResult = {
+3 -3
View File
@@ -3,9 +3,9 @@ import { fileURLToPath } from "node:url";
import { McpServer, type CallToolResult } from "@modelcontextprotocol/server"; import { McpServer, type CallToolResult } from "@modelcontextprotocol/server";
import { serveStdio, type StdioServerHandle } from "@modelcontextprotocol/server/stdio"; import { serveStdio, type StdioServerHandle } from "@modelcontextprotocol/server/stdio";
import { z } from "zod"; import { z } from "zod";
import { runCli } from "./cli/runner.js"; import { runCli } from "./cli/run/runner.js";
import { isReadOnlyCliCommand } from "./cli/read-only.js"; import { isReadOnlyCliCommand } from "./cli/run/read-only.js";
import { normalizeCliArgs, tokenizeCommand } from "./cli/tokenize.js"; import { normalizeCliArgs, tokenizeCommand } from "./cli/parse/tokenize.js";
import { classifyCliError } from "./core/errors.js"; import { classifyCliError } from "./core/errors.js";
import { VERSION } from "./version.js"; import { VERSION } from "./version.js";
import { isCompiledBinary, resolveAppRoot, resolveDefaultLauncher } from "./core/util/runtime.js"; import { isCompiledBinary, resolveAppRoot, resolveDefaultLauncher } from "./core/util/runtime.js";
+1 -1
View File
@@ -22,7 +22,7 @@ import { join, relative } from "node:path";
const SRC_DIR = join(import.meta.dir); const SRC_DIR = join(import.meta.dir);
const STDOUT_WRITERS = new Set([ const STDOUT_WRITERS = new Set([
"cli/printer.ts", "cli/output/printer.ts",
"cli/commands/doctor.ts", "cli/commands/doctor.ts",
"cli/commands/skill.ts", "cli/commands/skill.ts",
"cli.ts", "cli.ts",