@outfitter/cli 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -361,6 +361,31 @@ if (flags.reset) {
361
361
  }
362
362
  ```
363
363
 
364
+ ## Conventions
365
+
366
+ Composable flag presets provide typed, reusable CLI flag definitions. See the [full conventions guide](../../docs/CLI-CONVENTIONS.md) for the complete catalog.
367
+
368
+ ```typescript
369
+ import { composePresets, verbosePreset, cwdPreset, forcePreset } from "@outfitter/cli/flags";
370
+ import { outputModePreset } from "@outfitter/cli/query";
371
+
372
+ const preset = composePresets(verbosePreset(), cwdPreset(), forcePreset());
373
+
374
+ command("deploy")
375
+ .preset(preset)
376
+ .action(async ({ flags }) => {
377
+ const { verbose, cwd, force } = preset.resolve(flags);
378
+ // All typed, all composable
379
+ });
380
+ ```
381
+
382
+ **Available presets:** `verbosePreset`, `cwdPreset`, `dryRunPreset`, `forcePreset`, `interactionPreset`, `strictPreset`, `colorPreset`, `projectionPreset`, `paginationPreset`, `timeWindowPreset`, `executionPreset`, `outputModePreset`, `jqPreset`
383
+
384
+ **Additional modules:**
385
+ - `@outfitter/cli/verbs` — Standard verb families (`create`, `modify`, `remove`, `list`, `show`)
386
+ - `@outfitter/cli/query` — Output mode and jq expression presets
387
+ - `@outfitter/cli/completion` — Shell completion script generation
388
+
364
389
  ## Configuration
365
390
 
366
391
  ### Environment Variables
package/dist/actions.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { SchemaCommandOptions } from "./shared/@outfitter/cli-n1k0d23k";
1
2
  import { ActionRegistry, ActionSurface, AnyActionSpec, HandlerContext } from "@outfitter/contracts";
2
3
  import { Command } from "commander";
3
4
  interface BuildCliCommandsOptions {
@@ -7,6 +8,7 @@ interface BuildCliCommandsOptions {
7
8
  flags: Record<string, unknown>;
8
9
  }) => HandlerContext;
9
10
  readonly includeSurfaces?: readonly ActionSurface[];
11
+ readonly schema?: boolean | SchemaCommandOptions;
10
12
  }
11
13
  type ActionSource = ActionRegistry | readonly AnyActionSpec[];
12
14
  declare function buildCliCommands(source: ActionSource, options?: BuildCliCommandsOptions): Command[];
package/dist/actions.js CHANGED
@@ -1,4 +1,8 @@
1
1
  // @bun
2
+ import {
3
+ createSchemaCommand
4
+ } from "./shared/@outfitter/cli-g0sn0r0b.js";
5
+
2
6
  // packages/cli/src/actions.ts
3
7
  import {
4
8
  createContext as createHandlerContext,
@@ -163,6 +167,13 @@ function buildCliCommands(source, options = {}) {
163
167
  }
164
168
  commands.push(groupCommand);
165
169
  }
170
+ if (options.schema !== false) {
171
+ const hasSchemaCommand = commands.some((cmd) => cmd.name() === "schema");
172
+ if (!hasSchemaCommand) {
173
+ const schemaOptions = typeof options.schema === "object" ? options.schema : undefined;
174
+ commands.push(createSchemaCommand(source, schemaOptions));
175
+ }
176
+ }
166
177
  return commands;
167
178
  }
168
179
  function isActionRegistry(source) {
package/dist/cli.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CLI, CLIConfig } from "./shared/@outfitter/cli-02kyvj7h";
1
+ import { CLI, CLIConfig } from "./shared/@outfitter/cli-md9347gn";
2
2
  /**
3
3
  * Create a new CLI instance with the given configuration.
4
4
  *
package/dist/command.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CLI, CLIConfig, CommandAction, CommandBuilder, CommandConfig, CommandFlags } from "./shared/@outfitter/cli-02kyvj7h";
1
+ import { CLI, CLIConfig, CommandAction, CommandBuilder, CommandConfig, CommandFlags, FlagPreset } from "./shared/@outfitter/cli-md9347gn";
2
2
  /**
3
3
  * Create a CLI instance with a portable return type from this module.
4
4
  */
@@ -40,4 +40,4 @@ declare function createCLI(config: CLIConfig): CLI;
40
40
  * ```
41
41
  */
42
42
  declare function command(name: string): CommandBuilder;
43
- export { createCLI, command, CommandFlags, CommandConfig, CommandBuilder, CommandAction, CLIConfig, CLI };
43
+ export { createCLI, command, FlagPreset, CommandFlags, CommandConfig, CommandBuilder, CommandAction, CLIConfig, CLI };
package/dist/command.js CHANGED
@@ -47,6 +47,16 @@ class CommandBuilderImpl {
47
47
  this.command.alias(alias);
48
48
  return this;
49
49
  }
50
+ preset(preset) {
51
+ for (const opt of preset.options) {
52
+ if (opt.required) {
53
+ this.command.requiredOption(opt.flags, opt.description, opt.defaultValue);
54
+ } else {
55
+ this.command.option(opt.flags, opt.description, opt.defaultValue);
56
+ }
57
+ }
58
+ return this;
59
+ }
50
60
  action(handler) {
51
61
  this.command.action(async (...args) => {
52
62
  const command = args.at(-1);
@@ -0,0 +1,36 @@
1
+ import { Command } from "commander";
2
+ /**
3
+ * Configuration for the completion command.
4
+ */
5
+ interface CompletionConfig {
6
+ /** Supported shells (default: bash, zsh, fish) */
7
+ readonly shells?: readonly ("bash" | "zsh" | "fish")[];
8
+ /** Program name for completion scripts (inferred from CLI name if not provided) */
9
+ readonly programName?: string;
10
+ }
11
+ /**
12
+ * Generate a completion script for the given shell.
13
+ *
14
+ * @param shell - Target shell
15
+ * @param programName - CLI program name
16
+ * @returns The completion script string, or undefined for unsupported shells
17
+ */
18
+ declare function generateCompletion(shell: string, programName: string): string | undefined;
19
+ /**
20
+ * Create a `completion <shell>` command that outputs install-ready
21
+ * completion scripts.
22
+ *
23
+ * @param config - Optional configuration
24
+ * @returns A Commander command instance
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * import { createCLI } from "@outfitter/cli";
29
+ * import { createCompletionCommand } from "@outfitter/cli/completion";
30
+ *
31
+ * const cli = createCLI({ name: "mycli", version: "1.0.0" });
32
+ * cli.register(createCompletionCommand({ programName: "mycli" }));
33
+ * ```
34
+ */
35
+ declare function createCompletionCommand(config?: CompletionConfig): Command;
36
+ export { generateCompletion, createCompletionCommand, CompletionConfig };
@@ -0,0 +1,91 @@
1
+ // @bun
2
+ // packages/cli/src/completion.ts
3
+ import { Command } from "commander";
4
+ var SHELL_SAFE_PROGRAM_NAME = /^[A-Za-z0-9._-]+$/;
5
+ function assertSafeProgramName(programName) {
6
+ if (SHELL_SAFE_PROGRAM_NAME.test(programName))
7
+ return;
8
+ throw new Error(`Invalid program name for shell completion: "${programName}".` + " Must match /^[A-Za-z0-9._-]+$/.");
9
+ }
10
+ function toShellIdentifier(programName) {
11
+ assertSafeProgramName(programName);
12
+ return programName.replaceAll(/[^A-Za-z0-9_]/g, "_");
13
+ }
14
+ function generateBashCompletion(programName) {
15
+ assertSafeProgramName(programName);
16
+ const shellIdentifier = toShellIdentifier(programName);
17
+ return `# bash completion for ${programName}
18
+ # Add to ~/.bashrc or ~/.bash_profile:
19
+ # eval "$(${programName} completion bash)"
20
+
21
+ _${shellIdentifier}_completions() {
22
+ local cur
23
+ cur="\${COMP_WORDS[COMP_CWORD]}"
24
+
25
+ COMPREPLY=( $(compgen -W "$(${programName} --help 2>/dev/null | grep -oE '^ [a-z][-a-z]*' | tr -d ' ')" -- "\${cur}") )
26
+ }
27
+
28
+ complete -F _${shellIdentifier}_completions ${programName}
29
+ `;
30
+ }
31
+ function generateZshCompletion(programName) {
32
+ assertSafeProgramName(programName);
33
+ const shellIdentifier = toShellIdentifier(programName);
34
+ return `#compdef ${programName}
35
+ # zsh completion for ${programName}
36
+ # Add to ~/.zshrc:
37
+ # eval "$(${programName} completion zsh)"
38
+
39
+ _${shellIdentifier}() {
40
+ local -a commands
41
+ commands=($(${programName} --help 2>/dev/null | grep -oE '^ [a-z][-a-z]*' | tr -d ' '))
42
+
43
+ _arguments \\
44
+ '1:command:compadd -a commands' \\
45
+ '*::arg:->args'
46
+ }
47
+
48
+ compdef _${shellIdentifier} ${programName}
49
+ `;
50
+ }
51
+ function generateFishCompletion(programName) {
52
+ assertSafeProgramName(programName);
53
+ return `# fish completion for ${programName}
54
+ # Add to ~/.config/fish/completions/${programName}.fish:
55
+ # ${programName} completion fish > ~/.config/fish/completions/${programName}.fish
56
+
57
+ complete -c ${programName} -f
58
+ complete -c ${programName} -n "__fish_use_subcommand" -a "(${programName} --help 2>/dev/null | string match -r '^ [a-z][-a-z]*' | string trim)"
59
+ `;
60
+ }
61
+ var GENERATORS = {
62
+ bash: generateBashCompletion,
63
+ zsh: generateZshCompletion,
64
+ fish: generateFishCompletion
65
+ };
66
+ function generateCompletion(shell, programName) {
67
+ const generator = Object.hasOwn(GENERATORS, shell) ? GENERATORS[shell] : undefined;
68
+ return generator?.(programName);
69
+ }
70
+ function createCompletionCommand(config) {
71
+ const shells = config?.shells ?? ["bash", "zsh", "fish"];
72
+ const shellSet = new Set(shells);
73
+ const cmd = new Command("completion").description(`Generate shell completion script (${shells.join(", ")})`).argument("<shell>", `Shell type (${shells.join(", ")})`).action((shell) => {
74
+ if (!shellSet.has(shell)) {
75
+ cmd.error(`error: unsupported shell '${shell}'. Supported: ${shells.join(", ")}`);
76
+ return;
77
+ }
78
+ const generator = GENERATORS[shell];
79
+ if (generator) {
80
+ const programName = config?.programName ?? cmd.parent?.name() ?? "program";
81
+ assertSafeProgramName(programName);
82
+ const script = generator(programName);
83
+ process.stdout.write(script);
84
+ }
85
+ });
86
+ return cmd;
87
+ }
88
+ export {
89
+ generateCompletion,
90
+ createCompletionCommand
91
+ };
@@ -0,0 +1,167 @@
1
+ import { ColorFlags, ColorMode, ComposedPreset, ExecutionFlags, ExecutionPresetConfig, FlagPreset, FlagPresetConfig, InteractionFlags, PaginationFlags, PaginationPresetConfig, ProjectionFlags, StrictFlags, TimeWindowFlags, TimeWindowPresetConfig } from "./shared/@outfitter/cli-md9347gn";
2
+ /**
3
+ * Create a typed flag preset.
4
+ *
5
+ * @param config - Preset configuration with id, options, and resolver
6
+ * @returns A flag preset that can be applied to commands or composed
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * const myPreset = createPreset({
11
+ * id: "output-format",
12
+ * options: [{ flags: "--format <type>", description: "Output format" }],
13
+ * resolve: (flags) => ({
14
+ * format: String(flags["format"] ?? "text"),
15
+ * }),
16
+ * });
17
+ * ```
18
+ */
19
+ declare function createPreset<TResolved extends Record<string, unknown>>(config: FlagPresetConfig<TResolved>): FlagPreset<TResolved>;
20
+ type ResolvedType<T> = T extends FlagPreset<infer R> ? R : never;
21
+ type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
22
+ /**
23
+ * Resolves the merged type from a tuple of presets.
24
+ * Falls back to Record<string, unknown> when the tuple is empty
25
+ * (since UnionToIntersection<never> produces unknown).
26
+ */
27
+ type MergedPresetResult<TPresets extends readonly FlagPreset<Record<string, unknown>>[]> = UnionToIntersection<ResolvedType<TPresets[number]>> extends Record<string, unknown> ? UnionToIntersection<ResolvedType<TPresets[number]>> : Record<string, unknown>;
28
+ /**
29
+ * Compose multiple presets into one, deduplicating by id (first wins).
30
+ *
31
+ * @param presets - Presets to compose together
32
+ * @returns A single preset merging all options and resolvers
33
+ *
34
+ * @example
35
+ * ```typescript
36
+ * const composed = composePresets(
37
+ * verbosePreset(),
38
+ * cwdPreset(),
39
+ * forcePreset(),
40
+ * );
41
+ * // composed.resolve({ verbose: true, cwd: "/tmp", force: false })
42
+ * // => { verbose: true, cwd: "/tmp", force: false }
43
+ * ```
44
+ */
45
+ declare function composePresets<TPresets extends readonly FlagPreset<Record<string, unknown>>[]>(...presets: TPresets): ComposedPreset<MergedPresetResult<TPresets>>;
46
+ /**
47
+ * Verbose output flag preset.
48
+ *
49
+ * Adds: `-v, --verbose`
50
+ * Resolves: `{ verbose: boolean }`
51
+ */
52
+ declare function verbosePreset(): FlagPreset<{
53
+ verbose: boolean;
54
+ }>;
55
+ /**
56
+ * Working directory flag preset.
57
+ *
58
+ * Adds: `--cwd <path>`
59
+ * Resolves: `{ cwd: string }` (defaults to `process.cwd()`)
60
+ */
61
+ declare function cwdPreset(): FlagPreset<{
62
+ cwd: string;
63
+ }>;
64
+ /**
65
+ * Dry-run flag preset.
66
+ *
67
+ * Adds: `--dry-run`
68
+ * Resolves: `{ dryRun: boolean }`
69
+ */
70
+ declare function dryRunPreset(): FlagPreset<{
71
+ dryRun: boolean;
72
+ }>;
73
+ /**
74
+ * Force flag preset.
75
+ *
76
+ * Adds: `-f, --force`
77
+ * Resolves: `{ force: boolean }`
78
+ */
79
+ declare function forcePreset(): FlagPreset<{
80
+ force: boolean;
81
+ }>;
82
+ /**
83
+ * Interaction mode flag preset.
84
+ *
85
+ * Adds: `--non-interactive`, `--no-input`, `-y, --yes`
86
+ * Resolves: `{ interactive: boolean, yes: boolean }`
87
+ *
88
+ * `interactive` defaults to `true` and is set to `false` when
89
+ * `--non-interactive` or `--no-input` is passed. The two flags
90
+ * are synonyms for user convenience.
91
+ */
92
+ declare function interactionPreset(): FlagPreset<InteractionFlags>;
93
+ /**
94
+ * Strict mode flag preset.
95
+ *
96
+ * Adds: `--strict`
97
+ * Resolves: `{ strict: boolean }`
98
+ */
99
+ declare function strictPreset(): FlagPreset<StrictFlags>;
100
+ /**
101
+ * Color mode flag preset.
102
+ *
103
+ * Adds: `--color [mode]`, `--no-color`
104
+ * Resolves: `{ color: "auto" | "always" | "never" }`
105
+ *
106
+ * Commander's `--no-color` negation sets `flags["color"]` to `false`,
107
+ * which resolves to `"never"`. Invalid values default to `"auto"`.
108
+ *
109
+ * This preset resolves the user's *intent*. Consumers should compose
110
+ * with terminal detection (`supportsColor()`, `resolveColorEnv()`)
111
+ * to determine actual color output behavior.
112
+ */
113
+ declare function colorPreset(): FlagPreset<ColorFlags>;
114
+ /**
115
+ * Projection flag preset.
116
+ *
117
+ * Adds: `--fields <fields>`, `--exclude-fields <fields>`, `--count`
118
+ * Resolves: `{ fields: string[] | undefined, excludeFields: string[] | undefined, count: boolean }`
119
+ *
120
+ * Fields are parsed as comma-separated strings with whitespace trimming.
121
+ * `undefined` when not provided (not empty array) to distinguish
122
+ * "not specified" from "empty".
123
+ *
124
+ * Conflict between `--fields` and `--exclude-fields` is a handler
125
+ * concern (documented, not enforced).
126
+ */
127
+ declare function projectionPreset(): FlagPreset<ProjectionFlags>;
128
+ /**
129
+ * Time-window flag preset.
130
+ *
131
+ * Adds: `--since <date>`, `--until <date>`
132
+ * Resolves: `{ since: Date | undefined, until: Date | undefined }`
133
+ *
134
+ * Accepts ISO 8601 dates (`2024-01-15`) or relative durations
135
+ * (`7d`, `24h`, `30m`, `2w`). Durations are past-relative
136
+ * (subtracted from now).
137
+ *
138
+ * Returns `undefined` for unparseable values (does not throw).
139
+ * When `config.maxRange` is set and both bounds are provided,
140
+ * ranges above the limit are treated as invalid.
141
+ */
142
+ declare function timeWindowPreset(config?: TimeWindowPresetConfig): FlagPreset<TimeWindowFlags>;
143
+ /**
144
+ * Execution flag preset.
145
+ *
146
+ * Adds: `--timeout <ms>`, `--retries <n>`, `--offline`
147
+ * Resolves: `{ timeout: number | undefined, retries: number, offline: boolean }`
148
+ *
149
+ * Timeout is parsed as a positive integer in milliseconds.
150
+ * Retries are parsed as a non-negative integer, clamped to maxRetries.
151
+ */
152
+ declare function executionPreset(config?: ExecutionPresetConfig): FlagPreset<ExecutionFlags>;
153
+ /**
154
+ * Pagination flag preset.
155
+ *
156
+ * Adds: `-l, --limit <n>`, `--next`, `--reset`
157
+ * Resolves: `{ limit: number, next: boolean, reset: boolean }`
158
+ *
159
+ * Limit is parsed as an integer, clamped to maxLimit, and defaults
160
+ * to defaultLimit on invalid input. Mutual exclusivity of --next
161
+ * and --reset is a handler concern (not enforced here).
162
+ *
163
+ * Integrates with loadCursor/saveCursor/clearCursor from
164
+ * `@outfitter/cli/pagination`.
165
+ */
166
+ declare function paginationPreset(config?: PaginationPresetConfig): FlagPreset<PaginationFlags>;
167
+ export { verbosePreset, timeWindowPreset, strictPreset, projectionPreset, paginationPreset, interactionPreset, forcePreset, executionPreset, dryRunPreset, cwdPreset, createPreset, composePresets, colorPreset, TimeWindowPresetConfig, TimeWindowFlags, StrictFlags, ProjectionFlags, PaginationPresetConfig, PaginationFlags, InteractionFlags, FlagPresetConfig, FlagPreset, ExecutionPresetConfig, ExecutionFlags, ComposedPreset, ColorMode, ColorFlags };
package/dist/flags.js ADDED
@@ -0,0 +1,31 @@
1
+ // @bun
2
+ import {
3
+ colorPreset,
4
+ composePresets,
5
+ createPreset,
6
+ cwdPreset,
7
+ dryRunPreset,
8
+ executionPreset,
9
+ forcePreset,
10
+ interactionPreset,
11
+ paginationPreset,
12
+ projectionPreset,
13
+ strictPreset,
14
+ timeWindowPreset,
15
+ verbosePreset
16
+ } from "./shared/@outfitter/cli-b2zk8fb3.js";
17
+ export {
18
+ verbosePreset,
19
+ timeWindowPreset,
20
+ strictPreset,
21
+ projectionPreset,
22
+ paginationPreset,
23
+ interactionPreset,
24
+ forcePreset,
25
+ executionPreset,
26
+ dryRunPreset,
27
+ cwdPreset,
28
+ createPreset,
29
+ composePresets,
30
+ colorPreset
31
+ };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./shared/@outfitter/cli-qz47jk6d";
2
2
  import { ANSI, Theme, Tokens, createTheme } from "./shared/@outfitter/cli-xppg982q";
3
- import { output } from "./shared/@outfitter/cli-f79bwzsp";
4
- import { OutputMode } from "./shared/@outfitter/cli-02kyvj7h";
5
- export { output, createTheme, Tokens, Theme, OutputMode, ANSI };
3
+ import { exitWithError, output } from "./shared/@outfitter/cli-k0yvzn6d";
4
+ import { OutputMode } from "./shared/@outfitter/cli-md9347gn";
5
+ export { output, exitWithError, createTheme, Tokens, Theme, OutputMode, ANSI };
package/dist/index.js CHANGED
@@ -6,10 +6,12 @@ import {
6
6
  } from "./shared/@outfitter/cli-rk9zagkm.js";
7
7
  import"./shared/@outfitter/cli-jbj78ac5.js";
8
8
  import {
9
+ exitWithError,
9
10
  output
10
11
  } from "./shared/@outfitter/cli-7wp5nj0s.js";
11
12
  export {
12
13
  output,
14
+ exitWithError,
13
15
  createTheme,
14
16
  ANSI
15
17
  };
package/dist/input.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CollectIdsOptions, ExpandFileOptions, FilterExpression, KeyValuePair, NormalizeIdOptions, ParseGlobOptions, Range, SortCriteria } from "./shared/@outfitter/cli-02kyvj7h";
1
+ import { CollectIdsOptions, ExpandFileOptions, FilterExpression, KeyValuePair, NormalizeIdOptions, ParseGlobOptions, Range, SortCriteria } from "./shared/@outfitter/cli-md9347gn";
2
2
  import { ValidationError } from "@outfitter/contracts";
3
3
  import { Result } from "better-result";
4
4
  /**
package/dist/output.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { exitWithError, output, resolveVerbose } from "./shared/@outfitter/cli-f79bwzsp";
2
- import "./shared/@outfitter/cli-02kyvj7h";
1
+ import { exitWithError, output, resolveVerbose } from "./shared/@outfitter/cli-k0yvzn6d";
2
+ import "./shared/@outfitter/cli-md9347gn";
3
3
  export { resolveVerbose, output, exitWithError };
@@ -1,4 +1,4 @@
1
- import { CursorOptions, PaginationState } from "./shared/@outfitter/cli-02kyvj7h";
1
+ import { CursorOptions, PaginationState } from "./shared/@outfitter/cli-md9347gn";
2
2
  /**
3
3
  * Load persisted pagination state for a command.
4
4
  *
@@ -0,0 +1,50 @@
1
+ import { FlagPreset, OutputMode } from "./shared/@outfitter/cli-md9347gn";
2
+ /**
3
+ * Configuration for the output mode preset.
4
+ */
5
+ interface OutputModePresetConfig {
6
+ /** Allowed output modes (default: ["human", "json"]) */
7
+ readonly modes?: readonly OutputMode[];
8
+ /** Default mode when not specified (default: "human") */
9
+ readonly defaultMode?: OutputMode;
10
+ /** Whether to include "jsonl" in allowed modes (default: false) */
11
+ readonly includeJsonl?: boolean;
12
+ }
13
+ /**
14
+ * Resolved output mode from CLI input.
15
+ */
16
+ type OutputModeFlags = {
17
+ /** The resolved output mode */
18
+ readonly outputMode: OutputMode;
19
+ };
20
+ /**
21
+ * Output mode flag preset.
22
+ *
23
+ * Adds: `-o, --output <mode>`
24
+ * Resolves: `{ outputMode: string }`
25
+ *
26
+ * Replaces ad-hoc `--json`/`--jsonl` handling with a single
27
+ * `--output` flag that accepts a mode name. Invalid modes
28
+ * fall back to the configured default.
29
+ *
30
+ * @param config - Optional configuration for allowed modes and default
31
+ */
32
+ declare function outputModePreset(config?: OutputModePresetConfig): FlagPreset<OutputModeFlags>;
33
+ /**
34
+ * Resolved jq expression from CLI input.
35
+ */
36
+ type JqFlags = {
37
+ /** The jq expression, or undefined if not provided */
38
+ readonly jq: string | undefined;
39
+ };
40
+ /**
41
+ * JQ expression flag preset.
42
+ *
43
+ * Adds: `--jq <expr>`
44
+ * Resolves: `{ jq: string | undefined }`
45
+ *
46
+ * The resolver returns the expression string or `undefined`.
47
+ * Actual jq execution is a consumer concern.
48
+ */
49
+ declare function jqPreset(): FlagPreset<JqFlags>;
50
+ export { outputModePreset, jqPreset, OutputModePresetConfig, OutputModeFlags, JqFlags };
package/dist/query.js ADDED
@@ -0,0 +1,51 @@
1
+ // @bun
2
+ import {
3
+ createPreset
4
+ } from "./shared/@outfitter/cli-b2zk8fb3.js";
5
+
6
+ // packages/cli/src/query.ts
7
+ function outputModePreset(config) {
8
+ const defaultMode = config?.defaultMode ?? "human";
9
+ const baseModes = config?.modes ?? ["human", "json"];
10
+ const modes = new Set(config?.includeJsonl ? [...baseModes, "jsonl"] : baseModes);
11
+ modes.add(defaultMode);
12
+ return createPreset({
13
+ id: "outputMode",
14
+ options: [
15
+ {
16
+ flags: "-o, --output <mode>",
17
+ description: `Output mode (${[...modes].join(", ")})`,
18
+ defaultValue: defaultMode
19
+ }
20
+ ],
21
+ resolve: (flags) => {
22
+ const raw = flags["output"];
23
+ if (typeof raw === "string" && modes.has(raw)) {
24
+ return { outputMode: raw };
25
+ }
26
+ return { outputMode: defaultMode };
27
+ }
28
+ });
29
+ }
30
+ function jqPreset() {
31
+ return createPreset({
32
+ id: "jq",
33
+ options: [
34
+ {
35
+ flags: "--jq <expr>",
36
+ description: "Filter JSON output with a jq expression"
37
+ }
38
+ ],
39
+ resolve: (flags) => {
40
+ const raw = flags["jq"];
41
+ if (typeof raw === "string" && raw.length > 0) {
42
+ return { jq: raw };
43
+ }
44
+ return { jq: undefined };
45
+ }
46
+ });
47
+ }
48
+ export {
49
+ outputModePreset,
50
+ jqPreset
51
+ };
@@ -0,0 +1,2 @@
1
+ import { ActionManifest, ActionManifestEntry, ActionSource, GenerateManifestOptions, SchemaCommandOptions, SurfaceCommandOptions, createSchemaCommand, formatManifestHuman, generateManifest } from "./shared/@outfitter/cli-n1k0d23k";
2
+ export { generateManifest, formatManifestHuman, createSchemaCommand, SurfaceCommandOptions, SchemaCommandOptions, GenerateManifestOptions, ActionSource, ActionManifestEntry, ActionManifest };
package/dist/schema.js ADDED
@@ -0,0 +1,11 @@
1
+ // @bun
2
+ import {
3
+ createSchemaCommand,
4
+ formatManifestHuman,
5
+ generateManifest
6
+ } from "./shared/@outfitter/cli-g0sn0r0b.js";
7
+ export {
8
+ generateManifest,
9
+ formatManifestHuman,
10
+ createSchemaCommand
11
+ };