apcore-cli 0.5.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 +821 -6
- package/dist/bin/apcore-cli.js.map +1 -1
- package/dist/index.d.ts +144 -22
- package/dist/index.js +1408 -313
- 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
|
*/
|
|
@@ -256,7 +354,7 @@ declare class ConfigResolver {
|
|
|
256
354
|
}
|
|
257
355
|
|
|
258
356
|
/**
|
|
259
|
-
* Discovery commands — list
|
|
357
|
+
* Discovery commands — list, describe, validate (FE-04, FE-11).
|
|
260
358
|
*
|
|
261
359
|
* Protocol spec: Module discovery & introspection
|
|
262
360
|
*/
|
|
@@ -265,11 +363,15 @@ declare class ConfigResolver {
|
|
|
265
363
|
* Register list and describe commands on the CLI group.
|
|
266
364
|
*/
|
|
267
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;
|
|
268
370
|
|
|
269
371
|
/**
|
|
270
|
-
* TTY-adaptive output formatting (table/json).
|
|
372
|
+
* TTY-adaptive output formatting (table/json/csv/yaml/jsonl).
|
|
271
373
|
*
|
|
272
|
-
* Protocol spec: Output formatting
|
|
374
|
+
* Protocol spec: Output formatting (FE-09 enhanced)
|
|
273
375
|
*/
|
|
274
376
|
|
|
275
377
|
/**
|
|
@@ -283,15 +385,26 @@ declare function truncate(text: string, maxLength?: number): string;
|
|
|
283
385
|
/**
|
|
284
386
|
* Format and print a list of modules.
|
|
285
387
|
*/
|
|
286
|
-
declare function formatModuleList(modules: ModuleDescriptor[], format: string, filterTags?: string[]): void;
|
|
388
|
+
declare function formatModuleList(modules: ModuleDescriptor[], format: string, filterTags?: string[], showDeps?: boolean): void;
|
|
287
389
|
/**
|
|
288
390
|
* Format and print full module metadata.
|
|
289
391
|
*/
|
|
290
392
|
declare function formatModuleDetail(moduleDef: ModuleDescriptor, format: string): void;
|
|
291
393
|
/**
|
|
292
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.
|
|
293
398
|
*/
|
|
294
|
-
declare function formatExecResult(result: unknown, format?: string): void;
|
|
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.
|
|
406
|
+
*/
|
|
407
|
+
declare function firstFailedExitCode(result: PreflightResult): number;
|
|
295
408
|
|
|
296
409
|
/**
|
|
297
410
|
* JSON Schema $ref resolver.
|
|
@@ -327,19 +440,6 @@ declare function extractHelp(propSchema: Record<string, unknown>, maxLength?: nu
|
|
|
327
440
|
*/
|
|
328
441
|
declare function schemaToCliOptions(schema: Record<string, unknown>, maxHelpLength?: number): OptionConfig[];
|
|
329
442
|
|
|
330
|
-
/**
|
|
331
|
-
* Interactive approval prompts with timeout.
|
|
332
|
-
*
|
|
333
|
-
* Protocol spec: Approval workflow
|
|
334
|
-
*/
|
|
335
|
-
|
|
336
|
-
/**
|
|
337
|
-
* Check if module requires approval and handle accordingly.
|
|
338
|
-
* Returns normally if approved (or approval not required).
|
|
339
|
-
* Calls process.exit(46) if denied/timed out/non-TTY.
|
|
340
|
-
*/
|
|
341
|
-
declare function checkApproval(moduleDef: ModuleDescriptor, autoApprove: boolean): Promise<void>;
|
|
342
|
-
|
|
343
443
|
/**
|
|
344
444
|
* Shell completion + man page generation.
|
|
345
445
|
*
|
|
@@ -365,6 +465,27 @@ declare function configureManHelp(program: Command, progName: string, version: s
|
|
|
365
465
|
*/
|
|
366
466
|
declare function registerShellCommands(cli: Command, progName?: string): void;
|
|
367
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
|
+
|
|
368
489
|
/**
|
|
369
490
|
* Error classes and exit code mapping for apcore-cli.
|
|
370
491
|
*
|
|
@@ -416,6 +537,7 @@ declare const EXIT_CODES: {
|
|
|
416
537
|
readonly CONFIG_NAMESPACE_RESERVED: 78;
|
|
417
538
|
readonly CONFIG_NAMESPACE_DUPLICATE: 78;
|
|
418
539
|
readonly CONFIG_ENV_PREFIX_CONFLICT: 78;
|
|
540
|
+
readonly CONFIG_ENV_MAP_CONFLICT: 78;
|
|
419
541
|
readonly CONFIG_MOUNT_ERROR: 66;
|
|
420
542
|
readonly CONFIG_BIND_ERROR: 65;
|
|
421
543
|
readonly ERROR_FORMATTER_DUPLICATE: 70;
|
|
@@ -543,4 +665,4 @@ declare class Sandbox {
|
|
|
543
665
|
private sandboxedExecute;
|
|
544
666
|
}
|
|
545
667
|
|
|
546
|
-
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, registerConfigNamespace, 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 };
|