apcore-cli 0.4.0 → 0.6.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/CHANGELOG.md +39 -0
- package/README.md +20 -1
- package/dist/bin/apcore-cli.js +1043 -12
- package/dist/bin/apcore-cli.js.map +1 -1
- package/dist/index.d.ts +155 -22
- package/dist/index.js +2234 -1041
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -17,6 +17,43 @@ interface Registry {
|
|
|
17
17
|
/** Placeholder for apcore-js Executor. */
|
|
18
18
|
interface Executor {
|
|
19
19
|
execute(moduleId: string, input: Record<string, unknown>): Promise<unknown>;
|
|
20
|
+
/** Validate inputs without executing. Returns a PreflightResult. */
|
|
21
|
+
validate?(moduleId: string, input: Record<string, unknown>): Promise<PreflightResult>;
|
|
22
|
+
/** Execute with pipeline trace. Returns [result, PipelineTrace]. */
|
|
23
|
+
callWithTrace?(moduleId: string, input: Record<string, unknown>, options?: {
|
|
24
|
+
strategy?: string;
|
|
25
|
+
}): Promise<[unknown, PipelineTrace]>;
|
|
26
|
+
/** Stream execution — async iterator of chunks. */
|
|
27
|
+
stream?(moduleId: string, input: Record<string, unknown>): AsyncIterable<unknown>;
|
|
28
|
+
/** Call a module (synchronous-style, used by system commands). */
|
|
29
|
+
call?(moduleId: string, input: Record<string, unknown>): Promise<unknown>;
|
|
30
|
+
}
|
|
31
|
+
/** Result of a preflight validation check. */
|
|
32
|
+
interface PreflightCheck {
|
|
33
|
+
check: string;
|
|
34
|
+
passed: boolean;
|
|
35
|
+
error?: unknown;
|
|
36
|
+
warnings?: string[];
|
|
37
|
+
}
|
|
38
|
+
/** Result of executor.validate(). */
|
|
39
|
+
interface PreflightResult {
|
|
40
|
+
valid: boolean;
|
|
41
|
+
requires_approval: boolean;
|
|
42
|
+
checks: PreflightCheck[];
|
|
43
|
+
}
|
|
44
|
+
/** A single step in a pipeline trace. */
|
|
45
|
+
interface PipelineTraceStep {
|
|
46
|
+
name: string;
|
|
47
|
+
duration_ms: number;
|
|
48
|
+
skipped: boolean;
|
|
49
|
+
skip_reason?: string;
|
|
50
|
+
}
|
|
51
|
+
/** Pipeline execution trace returned by callWithTrace(). */
|
|
52
|
+
interface PipelineTrace {
|
|
53
|
+
strategy_name: string;
|
|
54
|
+
total_duration_ms: number;
|
|
55
|
+
success: boolean;
|
|
56
|
+
steps: PipelineTraceStep[];
|
|
20
57
|
}
|
|
21
58
|
/** Placeholder for apcore-js ModuleDescriptor. */
|
|
22
59
|
interface ModuleDescriptor {
|
|
@@ -89,8 +126,13 @@ declare class GroupedModuleGroup extends LazyModuleGroup {
|
|
|
89
126
|
private groupMapBuilt;
|
|
90
127
|
/**
|
|
91
128
|
* Determine (groupName | null, commandName) for a module from its display overlay.
|
|
129
|
+
*
|
|
130
|
+
* @param groupDepth Number of dotted segments to consume as the group prefix.
|
|
131
|
+
* Defaults to 1 (e.g., "math.add" → group="math", cmd="add").
|
|
132
|
+
* Set to 2 for multi-level grouping (e.g., "math.trig.sin" →
|
|
133
|
+
* group="math.trig", cmd="sin").
|
|
92
134
|
*/
|
|
93
|
-
static resolveGroup(moduleId: string, descriptor: ModuleDescriptor): [string | null, string];
|
|
135
|
+
static resolveGroup(moduleId: string, descriptor: ModuleDescriptor, groupDepth?: number): [string | null, string];
|
|
94
136
|
/**
|
|
95
137
|
* Build the group map from registry modules.
|
|
96
138
|
*/
|
|
@@ -115,6 +157,9 @@ declare class GroupedModuleGroup extends LazyModuleGroup {
|
|
|
115
157
|
* CLI entry point — createCli / main equivalents.
|
|
116
158
|
*
|
|
117
159
|
* Protocol spec: CLI bootstrapping & command registration
|
|
160
|
+
* Implements: F1 (dry-run), F3 (enhanced errors), F4 (trace),
|
|
161
|
+
* F5 (approval handler), F6 (stream), F8 (strategy), F9 (output formats),
|
|
162
|
+
* F11 (extra commands)
|
|
118
163
|
*/
|
|
119
164
|
|
|
120
165
|
/** Whether --verbose was passed (controls help detail level). */
|
|
@@ -151,13 +196,34 @@ interface OptionConfig {
|
|
|
151
196
|
/** Parser function for Commander (e.g. parseInt, parseFloat). */
|
|
152
197
|
parseArg?: (value: string) => unknown;
|
|
153
198
|
}
|
|
199
|
+
/**
|
|
200
|
+
* Emit structured JSON error to stderr for AI agents.
|
|
201
|
+
*/
|
|
202
|
+
declare function emitErrorJson(e: unknown, exitCode: number): void;
|
|
203
|
+
/**
|
|
204
|
+
* Emit human-readable error to stderr with guidance fields.
|
|
205
|
+
*/
|
|
206
|
+
declare function emitErrorTty(e: unknown, exitCode: number): void;
|
|
207
|
+
/** Options for createCli. */
|
|
208
|
+
interface CreateCliOptions {
|
|
209
|
+
extensionsDir?: string;
|
|
210
|
+
progName?: string;
|
|
211
|
+
verbose?: boolean;
|
|
212
|
+
/** Pre-populated Registry instance. Skips filesystem discovery when provided. */
|
|
213
|
+
registry?: Registry;
|
|
214
|
+
/** Pre-built Executor instance. Used alongside registry. */
|
|
215
|
+
executor?: Executor;
|
|
216
|
+
/** Extra commands to register after built-in commands (FE-11 F11). */
|
|
217
|
+
extraCommands?: Command[];
|
|
218
|
+
}
|
|
154
219
|
/**
|
|
155
220
|
* Build and return the top-level Commander program.
|
|
156
221
|
*
|
|
157
|
-
* @param
|
|
222
|
+
* @param extensionsDirOrOpts Path to extensions directory, or a CreateCliOptions object.
|
|
158
223
|
* @param progName Program name shown in help (default: apcore-cli)
|
|
224
|
+
* @param verbose Show verbose help output
|
|
159
225
|
*/
|
|
160
|
-
declare function createCli(
|
|
226
|
+
declare function createCli(extensionsDirOrOpts?: string | CreateCliOptions, progName?: string, verbose?: boolean): Command;
|
|
161
227
|
/**
|
|
162
228
|
* Optionally apply apcore-toolkit features (DisplayResolver, RegistryWriter).
|
|
163
229
|
*
|
|
@@ -171,6 +237,9 @@ declare function applyToolkitIntegration(commandsDir?: string, bindingPath?: str
|
|
|
171
237
|
declare function main(progName?: string): void;
|
|
172
238
|
/**
|
|
173
239
|
* Build a Commander Command for a single apcore module.
|
|
240
|
+
*
|
|
241
|
+
* Includes all 11 FE-11 options: --dry-run, --trace, --stream, --strategy,
|
|
242
|
+
* --approval-timeout, --approval-token, --fields, and enhanced --format choices.
|
|
174
243
|
*/
|
|
175
244
|
declare function buildModuleCommand(moduleDef: ModuleDescriptor, executor: Executor, helpTextMaxLength?: number, cmdName?: string, verbose?: boolean): Command;
|
|
176
245
|
/**
|
|
@@ -188,6 +257,35 @@ declare function collectInput(stdinFlag?: string, cliKwargs?: Record<string, unk
|
|
|
188
257
|
*/
|
|
189
258
|
declare function reconvertEnumValues(kwargs: Record<string, unknown>, options: OptionConfig[]): Record<string, unknown>;
|
|
190
259
|
|
|
260
|
+
/**
|
|
261
|
+
* Interactive approval prompts with timeout.
|
|
262
|
+
*
|
|
263
|
+
* Protocol spec: Approval workflow
|
|
264
|
+
*/
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* CLI ApprovalHandler that prompts in TTY, auto-denies in non-TTY.
|
|
268
|
+
*
|
|
269
|
+
* Implements the apcore ApprovalHandler protocol:
|
|
270
|
+
* - `requestApproval(request) -> ApprovalResult`
|
|
271
|
+
* - `checkApproval(approvalId) -> ApprovalResult`
|
|
272
|
+
*
|
|
273
|
+
* Pass to Executor via `executor.setApprovalHandler(handler)`.
|
|
274
|
+
*/
|
|
275
|
+
declare class CliApprovalHandler {
|
|
276
|
+
autoApprove: boolean;
|
|
277
|
+
timeout: number;
|
|
278
|
+
constructor(autoApprove?: boolean, timeout?: number);
|
|
279
|
+
requestApproval(request: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
280
|
+
checkApproval(_approvalId: string): Promise<Record<string, unknown>>;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Check if module requires approval and handle accordingly.
|
|
284
|
+
* Returns normally if approved (or approval not required).
|
|
285
|
+
* Calls process.exit(46) if denied/timed out/non-TTY.
|
|
286
|
+
*/
|
|
287
|
+
declare function checkApproval(moduleDef: ModuleDescriptor, autoApprove: boolean, timeout?: number): Promise<void>;
|
|
288
|
+
|
|
191
289
|
/**
|
|
192
290
|
* Display overlay helpers — shared resolution logic for CLI surfaces.
|
|
193
291
|
*/
|
|
@@ -219,6 +317,11 @@ declare function registerInitCommand(cli: Command): void;
|
|
|
219
317
|
*/
|
|
220
318
|
/** Default configuration values. */
|
|
221
319
|
declare const DEFAULTS: Record<string, unknown>;
|
|
320
|
+
/**
|
|
321
|
+
* Register the apcore-cli Config Bus namespace (apcore >= 0.15.0).
|
|
322
|
+
* Safe to call even when apcore-js is unavailable or < 0.15.0.
|
|
323
|
+
*/
|
|
324
|
+
declare function registerConfigNamespace(): void;
|
|
222
325
|
/**
|
|
223
326
|
* Resolves configuration from four tiers (highest to lowest priority):
|
|
224
327
|
* 1. CLI flags
|
|
@@ -251,7 +354,7 @@ declare class ConfigResolver {
|
|
|
251
354
|
}
|
|
252
355
|
|
|
253
356
|
/**
|
|
254
|
-
* Discovery commands — list
|
|
357
|
+
* Discovery commands — list, describe, validate (FE-04, FE-11).
|
|
255
358
|
*
|
|
256
359
|
* Protocol spec: Module discovery & introspection
|
|
257
360
|
*/
|
|
@@ -260,11 +363,15 @@ declare class ConfigResolver {
|
|
|
260
363
|
* Register list and describe commands on the CLI group.
|
|
261
364
|
*/
|
|
262
365
|
declare function registerDiscoveryCommands(cli: Command, registry: Registry): void;
|
|
366
|
+
/**
|
|
367
|
+
* Register the standalone validate command.
|
|
368
|
+
*/
|
|
369
|
+
declare function registerValidateCommand(cli: Command, registry: Registry, executor: Executor): void;
|
|
263
370
|
|
|
264
371
|
/**
|
|
265
|
-
* TTY-adaptive output formatting (table/json).
|
|
372
|
+
* TTY-adaptive output formatting (table/json/csv/yaml/jsonl).
|
|
266
373
|
*
|
|
267
|
-
* Protocol spec: Output formatting
|
|
374
|
+
* Protocol spec: Output formatting (FE-09 enhanced)
|
|
268
375
|
*/
|
|
269
376
|
|
|
270
377
|
/**
|
|
@@ -278,15 +385,26 @@ declare function truncate(text: string, maxLength?: number): string;
|
|
|
278
385
|
/**
|
|
279
386
|
* Format and print a list of modules.
|
|
280
387
|
*/
|
|
281
|
-
declare function formatModuleList(modules: ModuleDescriptor[], format: string, filterTags?: string[]): void;
|
|
388
|
+
declare function formatModuleList(modules: ModuleDescriptor[], format: string, filterTags?: string[], showDeps?: boolean): void;
|
|
282
389
|
/**
|
|
283
390
|
* Format and print full module metadata.
|
|
284
391
|
*/
|
|
285
392
|
declare function formatModuleDetail(moduleDef: ModuleDescriptor, format: string): void;
|
|
286
393
|
/**
|
|
287
394
|
* Format and print module execution result.
|
|
395
|
+
*
|
|
396
|
+
* Supports formats: json, table, csv, yaml, jsonl.
|
|
397
|
+
* The `fields` option allows dot-path field selection on dict results.
|
|
398
|
+
*/
|
|
399
|
+
declare function formatExecResult(result: unknown, format?: string, fields?: string): void;
|
|
400
|
+
/**
|
|
401
|
+
* Format and print a PreflightResult to stdout.
|
|
402
|
+
*/
|
|
403
|
+
declare function formatPreflightResult(result: PreflightResult, format?: string): void;
|
|
404
|
+
/**
|
|
405
|
+
* Return the exit code for the first failed check in a PreflightResult.
|
|
288
406
|
*/
|
|
289
|
-
declare function
|
|
407
|
+
declare function firstFailedExitCode(result: PreflightResult): number;
|
|
290
408
|
|
|
291
409
|
/**
|
|
292
410
|
* JSON Schema $ref resolver.
|
|
@@ -322,19 +440,6 @@ declare function extractHelp(propSchema: Record<string, unknown>, maxLength?: nu
|
|
|
322
440
|
*/
|
|
323
441
|
declare function schemaToCliOptions(schema: Record<string, unknown>, maxHelpLength?: number): OptionConfig[];
|
|
324
442
|
|
|
325
|
-
/**
|
|
326
|
-
* Interactive approval prompts with timeout.
|
|
327
|
-
*
|
|
328
|
-
* Protocol spec: Approval workflow
|
|
329
|
-
*/
|
|
330
|
-
|
|
331
|
-
/**
|
|
332
|
-
* Check if module requires approval and handle accordingly.
|
|
333
|
-
* Returns normally if approved (or approval not required).
|
|
334
|
-
* Calls process.exit(46) if denied/timed out/non-TTY.
|
|
335
|
-
*/
|
|
336
|
-
declare function checkApproval(moduleDef: ModuleDescriptor, autoApprove: boolean): Promise<void>;
|
|
337
|
-
|
|
338
443
|
/**
|
|
339
444
|
* Shell completion + man page generation.
|
|
340
445
|
*
|
|
@@ -360,6 +465,27 @@ declare function configureManHelp(program: Command, progName: string, version: s
|
|
|
360
465
|
*/
|
|
361
466
|
declare function registerShellCommands(cli: Command, progName?: string): void;
|
|
362
467
|
|
|
468
|
+
/**
|
|
469
|
+
* System management commands — health, usage, enable, disable, reload, config (FE-11 F2).
|
|
470
|
+
*
|
|
471
|
+
* Each delegates to system.* modules via executor.
|
|
472
|
+
* No-op if system modules are unavailable (graceful probe).
|
|
473
|
+
*/
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* Register system management commands. No-op if system modules are not available.
|
|
477
|
+
*/
|
|
478
|
+
declare function registerSystemCommands(cli: Command, executor: Executor): Promise<void>;
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* Pipeline strategy commands — describe-pipeline (FE-11 F8).
|
|
482
|
+
*/
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* Register the describe-pipeline command.
|
|
486
|
+
*/
|
|
487
|
+
declare function registerPipelineCommand(cli: Command, executor: Executor): void;
|
|
488
|
+
|
|
363
489
|
/**
|
|
364
490
|
* Error classes and exit code mapping for apcore-cli.
|
|
365
491
|
*
|
|
@@ -408,6 +534,13 @@ declare const EXIT_CODES: {
|
|
|
408
534
|
readonly CONFIG_INVALID: 47;
|
|
409
535
|
readonly SCHEMA_CIRCULAR_REF: 48;
|
|
410
536
|
readonly ACL_DENIED: 77;
|
|
537
|
+
readonly CONFIG_NAMESPACE_RESERVED: 78;
|
|
538
|
+
readonly CONFIG_NAMESPACE_DUPLICATE: 78;
|
|
539
|
+
readonly CONFIG_ENV_PREFIX_CONFLICT: 78;
|
|
540
|
+
readonly CONFIG_ENV_MAP_CONFLICT: 78;
|
|
541
|
+
readonly CONFIG_MOUNT_ERROR: 66;
|
|
542
|
+
readonly CONFIG_BIND_ERROR: 65;
|
|
543
|
+
readonly ERROR_FORMATTER_DUPLICATE: 70;
|
|
411
544
|
readonly KEYBOARD_INTERRUPT: 130;
|
|
412
545
|
};
|
|
413
546
|
type ExitCode = (typeof EXIT_CODES)[keyof typeof EXIT_CODES];
|
|
@@ -532,4 +665,4 @@ declare class Sandbox {
|
|
|
532
665
|
private sandboxedExecute;
|
|
533
666
|
}
|
|
534
667
|
|
|
535
|
-
export { ApprovalDeniedError, ApprovalTimeoutError, AuditLogger, AuthProvider, AuthenticationError, BUILTIN_COMMANDS, ConfigDecryptionError, ConfigEncryptor, ConfigResolver, DEFAULTS, EXIT_CODES, type Executor, type ExitCode, GroupedModuleGroup, LazyGroup, LazyModuleGroup, type ModuleDescriptor, ModuleExecutionError, ModuleNotFoundError, type OptionConfig, type Registry, Sandbox, SchemaValidationError, applyToolkitIntegration, buildModuleCommand, buildProgramManPage, checkApproval, collectInput, configureManHelp, createCli, debug, docsUrl, error, exitCodeForError, extractHelp, formatExecResult, formatModuleDetail, formatModuleList, getAuditLogger, getCliDisplayFields, getDisplay, getLogLevel, info, main, mapType, reconvertEnumValues, registerDiscoveryCommands, registerInitCommand, registerShellCommands, resolveFormat, resolveRefs, schemaToCliOptions, setAuditLogger, setDocsUrl, setLogLevel, setVerboseHelp, truncate, validateModuleId, verboseHelp, warn };
|
|
668
|
+
export { ApprovalDeniedError, ApprovalTimeoutError, AuditLogger, AuthProvider, AuthenticationError, BUILTIN_COMMANDS, CliApprovalHandler, ConfigDecryptionError, ConfigEncryptor, ConfigResolver, type CreateCliOptions, DEFAULTS, EXIT_CODES, type Executor, type ExitCode, GroupedModuleGroup, LazyGroup, LazyModuleGroup, type ModuleDescriptor, ModuleExecutionError, ModuleNotFoundError, type OptionConfig, type PipelineTrace, type PipelineTraceStep, type PreflightCheck, type PreflightResult, type Registry, Sandbox, SchemaValidationError, applyToolkitIntegration, buildModuleCommand, buildProgramManPage, checkApproval, collectInput, configureManHelp, createCli, debug, docsUrl, emitErrorJson, emitErrorTty, error, exitCodeForError, extractHelp, firstFailedExitCode, formatExecResult, formatModuleDetail, formatModuleList, formatPreflightResult, getAuditLogger, getCliDisplayFields, getDisplay, getLogLevel, info, main, mapType, reconvertEnumValues, registerConfigNamespace, registerDiscoveryCommands, registerInitCommand, registerPipelineCommand, registerShellCommands, registerSystemCommands, registerValidateCommand, resolveFormat, resolveRefs, schemaToCliOptions, setAuditLogger, setDocsUrl, setLogLevel, setVerboseHelp, truncate, validateModuleId, verboseHelp, warn };
|