apcore-cli 0.7.0 → 0.8.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 +123 -0
- package/README.md +37 -27
- package/dist/bin/apcore-cli.js +462 -178
- package/dist/bin/apcore-cli.js.map +1 -1
- package/dist/index.d.ts +128 -22
- package/dist/index.js +432 -152
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
package/dist/index.d.ts
CHANGED
|
@@ -37,6 +37,18 @@ declare class ExposureFilter {
|
|
|
37
37
|
* named static factories, and a small set of predicate methods.
|
|
38
38
|
* See the feature spec §4.2–4.7 for authoritative semantics.
|
|
39
39
|
*/
|
|
40
|
+
/**
|
|
41
|
+
* Thrown for invalid built-in apcli group configuration (e.g. invalid
|
|
42
|
+
* `builtinGroupName` regex match). Cross-SDK parity with Rust's
|
|
43
|
+
* `ApcliGroupError` (D1-info-1, 2026-05-08).
|
|
44
|
+
*
|
|
45
|
+
* Extends `Error` so existing `catch (e)` blocks continue to work via
|
|
46
|
+
* `instanceof Error`; callers that want to distinguish apcli config
|
|
47
|
+
* errors from generic errors can switch on `instanceof ApcliGroupError`.
|
|
48
|
+
*/
|
|
49
|
+
declare class ApcliGroupError extends Error {
|
|
50
|
+
constructor(message: string);
|
|
51
|
+
}
|
|
40
52
|
/**
|
|
41
53
|
* Resolved visibility mode.
|
|
42
54
|
*
|
|
@@ -57,7 +69,12 @@ type ApcliConfig = boolean | {
|
|
|
57
69
|
exclude?: string[];
|
|
58
70
|
disableEnv?: boolean;
|
|
59
71
|
};
|
|
60
|
-
/**
|
|
72
|
+
/**
|
|
73
|
+
* Set of group names reserved by apcore-cli when no rename is configured.
|
|
74
|
+
* Default mirrors {@link DEFAULT_BUILTIN_GROUP_NAME}; when `builtinGroupName`
|
|
75
|
+
* is overridden the live reserved set is `new Set([apcliGroup.name])` and
|
|
76
|
+
* is applied per-instance during the cli.ts collision check.
|
|
77
|
+
*/
|
|
61
78
|
declare const RESERVED_GROUP_NAMES: ReadonlySet<string>;
|
|
62
79
|
/**
|
|
63
80
|
* Visibility configuration for the built-in `apcli` command group.
|
|
@@ -73,7 +90,15 @@ declare class ApcliGroup {
|
|
|
73
90
|
private readonly _disableEnv;
|
|
74
91
|
private readonly _registryInjected;
|
|
75
92
|
private readonly _fromCliConfig;
|
|
93
|
+
private readonly _name;
|
|
76
94
|
private constructor();
|
|
95
|
+
/**
|
|
96
|
+
* Resolved name for the built-in command group (default `"apcli"`).
|
|
97
|
+
* Overridable via createCli's `builtinGroupName` option for downstream
|
|
98
|
+
* branded CLIs that want a custom namespace. Cross-SDK parity with
|
|
99
|
+
* Python `ApcliGroup.name` (2026-05-08).
|
|
100
|
+
*/
|
|
101
|
+
get name(): string;
|
|
77
102
|
/**
|
|
78
103
|
* Tier 1 constructor — config came from `createCli({ apcli })`.
|
|
79
104
|
*
|
|
@@ -81,6 +106,7 @@ declare class ApcliGroup {
|
|
|
81
106
|
*/
|
|
82
107
|
static fromCliConfig(config: ApcliConfig | undefined, opts: {
|
|
83
108
|
registryInjected: boolean;
|
|
109
|
+
name?: string;
|
|
84
110
|
}): ApcliGroup;
|
|
85
111
|
/**
|
|
86
112
|
* Tier 3 constructor — config came from `apcore.yaml`.
|
|
@@ -89,6 +115,7 @@ declare class ApcliGroup {
|
|
|
89
115
|
*/
|
|
90
116
|
static fromYaml(config: unknown, opts: {
|
|
91
117
|
registryInjected: boolean;
|
|
118
|
+
name?: string;
|
|
92
119
|
}): ApcliGroup;
|
|
93
120
|
/**
|
|
94
121
|
* Non-panicking Tier 3 factory (A-001 parity with Rust's `try_from_yaml`).
|
|
@@ -97,6 +124,7 @@ declare class ApcliGroup {
|
|
|
97
124
|
*/
|
|
98
125
|
static tryFromYaml(config: unknown, opts: {
|
|
99
126
|
registryInjected: boolean;
|
|
127
|
+
name?: string;
|
|
100
128
|
}): [ApcliGroup, null] | [null, string];
|
|
101
129
|
private static _build;
|
|
102
130
|
/**
|
|
@@ -336,6 +364,17 @@ declare class GroupedModuleGroup extends LazyModuleGroup {
|
|
|
336
364
|
isGroupMapBuilt(): boolean;
|
|
337
365
|
}
|
|
338
366
|
|
|
367
|
+
/**
|
|
368
|
+
* Validate that a module ID conforms to the expected format.
|
|
369
|
+
*
|
|
370
|
+
* Pattern: `[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)*` — max 192 chars.
|
|
371
|
+
*
|
|
372
|
+
* On invalid input, writes a human-readable error to stderr and calls
|
|
373
|
+
* `process.exit(EXIT_CODES.INVALID_CLI_INPUT)`. Cross-SDK parity with Python
|
|
374
|
+
* `apcore_cli.validate.validate_module_id` and Rust `validate_module_id`.
|
|
375
|
+
*/
|
|
376
|
+
declare function validateModuleId(moduleId: string): void;
|
|
377
|
+
|
|
339
378
|
/** Set the verbose help flag. When false, built-in options are hidden from help. */
|
|
340
379
|
declare function setVerboseHelp(verbose: boolean): void;
|
|
341
380
|
/**
|
|
@@ -366,14 +405,6 @@ interface OptionConfig {
|
|
|
366
405
|
/** Parser function for Commander (e.g. parseInt, parseFloat). */
|
|
367
406
|
parseArg?: (value: string) => unknown;
|
|
368
407
|
}
|
|
369
|
-
/**
|
|
370
|
-
* Emit structured JSON error to stderr for AI agents.
|
|
371
|
-
*/
|
|
372
|
-
declare function emitErrorJson(e: unknown, exitCode: number): void;
|
|
373
|
-
/**
|
|
374
|
-
* Emit human-readable error to stderr with guidance fields.
|
|
375
|
-
*/
|
|
376
|
-
declare function emitErrorTty(e: unknown, exitCode: number): void;
|
|
377
408
|
/**
|
|
378
409
|
* APCore unified client facade (apcore-js >= 0.18.0).
|
|
379
410
|
* Exposes registry and executor as top-level properties.
|
|
@@ -405,6 +436,17 @@ interface CreateCliOptions {
|
|
|
405
436
|
commandsDir?: string;
|
|
406
437
|
/** Path to binding.yaml for display overlay (apcore-toolkit DisplayResolver). */
|
|
407
438
|
bindingPath?: string;
|
|
439
|
+
/**
|
|
440
|
+
* Optional allowlist of module-path prefixes forwarded to
|
|
441
|
+
* apcore-toolkit's `RegistryWriter.write` when registering convention-scanned
|
|
442
|
+
* or binding-loaded modules. When set, the writer rejects any `target:`
|
|
443
|
+
* path outside the listed prefixes — mitigates arbitrary-code-execution via
|
|
444
|
+
* forged binding YAML (e.g. `target: "os:system"`).
|
|
445
|
+
*
|
|
446
|
+
* Mirrors the Python SDK's `allowed_prefixes` kwarg
|
|
447
|
+
* (apcore-cli-python/src/apcore_cli/factory.py).
|
|
448
|
+
*/
|
|
449
|
+
allowedPrefixes?: string[];
|
|
408
450
|
/**
|
|
409
451
|
* Built-in apcli group configuration (FE-13).
|
|
410
452
|
*
|
|
@@ -417,6 +459,34 @@ interface CreateCliOptions {
|
|
|
417
459
|
* back to auto-detect: standalone → visible, embedded → hidden.
|
|
418
460
|
*/
|
|
419
461
|
apcli?: ApcliConfig | ApcliGroup;
|
|
462
|
+
/**
|
|
463
|
+
* Override the name of the built-in command group (default `"apcli"`).
|
|
464
|
+
* Downstream branded CLIs that want their built-ins under a custom
|
|
465
|
+
* namespace (e.g. `mycorp-cli admin health`) pass a different value
|
|
466
|
+
* here. Must match `/^[a-z][a-z0-9_-]*$/` — non-empty, lowercase,
|
|
467
|
+
* alphanumeric + `_` / `-`. Invalid values cause exit code 2.
|
|
468
|
+
*
|
|
469
|
+
* Note: env var `APCORE_CLI_APCLI` and config keys `apcli.*` remain
|
|
470
|
+
* stable regardless of this rename — they are apcore-cli-internal
|
|
471
|
+
* toggles, not user-facing. Mirrors Python
|
|
472
|
+
* `create_cli(builtin_group_name=)`. Cross-SDK parity: 2026-05-08.
|
|
473
|
+
*/
|
|
474
|
+
builtinGroupName?: string;
|
|
475
|
+
/**
|
|
476
|
+
* Host application version printed by `-V, --version`.
|
|
477
|
+
*
|
|
478
|
+
* When omitted, the `--version` flag is NOT registered — embedded CLIs
|
|
479
|
+
* that do not opt in will not surface the SDK's own version. The
|
|
480
|
+
* standalone `apcore-cli` binary entry point passes its package version
|
|
481
|
+
* explicitly (see `main()`).
|
|
482
|
+
*/
|
|
483
|
+
version?: string;
|
|
484
|
+
/**
|
|
485
|
+
* Top-level CLI description shown at the head of `--help`. Defaults to
|
|
486
|
+
* `${progName} CLI` when omitted, so embedded CLIs do not leak the
|
|
487
|
+
* "apcore" framework name into their own help output.
|
|
488
|
+
*/
|
|
489
|
+
description?: string;
|
|
420
490
|
}
|
|
421
491
|
/**
|
|
422
492
|
* Build and return the top-level Commander program.
|
|
@@ -426,7 +496,16 @@ interface CreateCliOptions {
|
|
|
426
496
|
* @param verbose Show verbose help output
|
|
427
497
|
*/
|
|
428
498
|
declare function createCli(extensionsDirOrOpts?: string | CreateCliOptions, progName?: string, verbose?: boolean): Command;
|
|
429
|
-
|
|
499
|
+
/** Options bag for {@link applyToolkitIntegration}. */
|
|
500
|
+
interface ApplyToolkitIntegrationOptions {
|
|
501
|
+
/**
|
|
502
|
+
* Allowlist of module-path prefixes forwarded to apcore-toolkit's
|
|
503
|
+
* `RegistryWriter.write` when registering scanned/loaded modules. Mirrors
|
|
504
|
+
* the Python factory's `allowed_prefixes` kwarg.
|
|
505
|
+
*/
|
|
506
|
+
allowedPrefixes?: string[];
|
|
507
|
+
}
|
|
508
|
+
declare function applyToolkitIntegration(commandsDir?: string, bindingPath?: string, options?: ApplyToolkitIntegrationOptions): Promise<void>;
|
|
430
509
|
/**
|
|
431
510
|
* Parse argv and run the CLI. Handles top-level error catching and exit codes.
|
|
432
511
|
*/
|
|
@@ -438,15 +517,7 @@ declare function main(progName?: string): void;
|
|
|
438
517
|
* --approval-timeout, --approval-token, --fields, and enhanced --format choices.
|
|
439
518
|
*/
|
|
440
519
|
declare function buildModuleCommand(moduleDef: ModuleDescriptor, executor: Executor, helpTextMaxLength?: number, cmdName?: string, verbose?: boolean): Command;
|
|
441
|
-
|
|
442
|
-
* Validate that a module ID conforms to the expected format.
|
|
443
|
-
* Pattern: [a-z][a-z0-9_]*(.[a-z][a-z0-9_])* — max 192 chars.
|
|
444
|
-
*
|
|
445
|
-
* Length limit tracks PROTOCOL_SPEC §2.7 EBNF constraint #1 — bumped from
|
|
446
|
-
* 128 to 192 in spec 1.6.0-draft to accommodate Java/.NET deep-namespace
|
|
447
|
-
* FQN-derived IDs. Filesystem-safe (192 + ".binding.yaml".length = 205 < 255).
|
|
448
|
-
*/
|
|
449
|
-
declare function validateModuleId(moduleId: string): void;
|
|
520
|
+
|
|
450
521
|
/**
|
|
451
522
|
* Collect module input from stdin and/or CLI keyword arguments.
|
|
452
523
|
*/
|
|
@@ -594,11 +665,25 @@ declare function registerExecCommand(apcliGroup: Command, registry: Registry, ex
|
|
|
594
665
|
declare function registerValidateCommand(cli: Command, registry: Registry, executor: Executor): void;
|
|
595
666
|
|
|
596
667
|
/**
|
|
597
|
-
* TTY-adaptive output formatting (table/json/csv/yaml/jsonl).
|
|
668
|
+
* TTY-adaptive output formatting (table/json/csv/yaml/jsonl/markdown/skill).
|
|
598
669
|
*
|
|
599
|
-
* Protocol spec: Output formatting (FE-09 enhanced)
|
|
670
|
+
* Protocol spec: Output formatting (FE-08 / FE-09 enhanced)
|
|
600
671
|
*/
|
|
601
672
|
|
|
673
|
+
/**
|
|
674
|
+
* Resolve output format with TTY-adaptive default.
|
|
675
|
+
*/
|
|
676
|
+
declare function resolveFormat(explicitFormat?: string): string;
|
|
677
|
+
/**
|
|
678
|
+
* Format and print a list of modules.
|
|
679
|
+
*/
|
|
680
|
+
declare function formatModuleList(modules: ModuleDescriptor[], format: string, filterTags?: string[], showDeps?: boolean, exposureFilter?: {
|
|
681
|
+
isExposed(moduleId: string): boolean;
|
|
682
|
+
}): Promise<void>;
|
|
683
|
+
/**
|
|
684
|
+
* Format and print full module metadata.
|
|
685
|
+
*/
|
|
686
|
+
declare function formatModuleDetail(moduleDef: ModuleDescriptor, format: string): Promise<void>;
|
|
602
687
|
/**
|
|
603
688
|
* Format and print module execution result.
|
|
604
689
|
*
|
|
@@ -911,9 +996,30 @@ declare class AuthProvider {
|
|
|
911
996
|
* `--internal-sandbox-runner <module_id>`.
|
|
912
997
|
*/
|
|
913
998
|
declare class Sandbox {
|
|
999
|
+
/** Default post-capture stdout+stderr byte budget for sandboxed children. */
|
|
1000
|
+
static readonly DEFAULT_MAX_OUTPUT_BYTES: number;
|
|
914
1001
|
private readonly enabled;
|
|
915
1002
|
private readonly timeoutSeconds;
|
|
1003
|
+
private extensionsRoot;
|
|
1004
|
+
private maxOutputBytes;
|
|
916
1005
|
constructor(enabled?: boolean, timeoutSeconds?: number);
|
|
1006
|
+
/**
|
|
1007
|
+
* Set the extensions root that is forwarded to the sandboxed runner via
|
|
1008
|
+
* `APCORE_EXTENSIONS_ROOT`. The path is resolved to absolute when injected
|
|
1009
|
+
* so the child (whose cwd is the fresh sandbox tempdir) can locate modules.
|
|
1010
|
+
*
|
|
1011
|
+
* Builder-style — returns `this` so call sites can chain. Mirrors Python's
|
|
1012
|
+
* `Sandbox.with_extensions_root` (D1-004 cross-SDK parity).
|
|
1013
|
+
*/
|
|
1014
|
+
withExtensionsRoot(extensionsRoot: string | null): this;
|
|
1015
|
+
/**
|
|
1016
|
+
* Cap the post-capture stdout+stderr byte budget for the sandboxed
|
|
1017
|
+
* subprocess. Default: 64 MiB (`Sandbox.DEFAULT_MAX_OUTPUT_BYTES`).
|
|
1018
|
+
*
|
|
1019
|
+
* Builder-style — returns `this`. Mirrors Python's
|
|
1020
|
+
* `Sandbox.with_max_output_bytes` (D1-004 cross-SDK parity).
|
|
1021
|
+
*/
|
|
1022
|
+
withMaxOutputBytes(maxOutputBytes: number): this;
|
|
917
1023
|
/**
|
|
918
1024
|
* Execute a module, optionally inside a sandboxed subprocess.
|
|
919
1025
|
*/
|
|
@@ -921,4 +1027,4 @@ declare class Sandbox {
|
|
|
921
1027
|
private _sandboxedExecute;
|
|
922
1028
|
}
|
|
923
1029
|
|
|
924
|
-
export { type APCore, type ApcliConfig, ApcliGroup, type ApcliMode, ApprovalDeniedError, ApprovalTimeoutError, AuditLogger, AuthProvider, AuthenticationError, CliApprovalHandler, ConfigDecryptionError, ConfigEncryptor, ConfigResolver, type CreateCliOptions, DEFAULTS, EXIT_CODES, type Executor, type ExitCode, ExposureFilter, GroupedModuleGroup, LazyGroup, LazyModuleGroup, type ModuleDescriptor, ModuleExecutionError, ModuleNotFoundError, type OptionConfig, type PipelineTrace, type PipelineTraceStep, type PreflightCheck, type PreflightResult, RESERVED_GROUP_NAMES, type Registry, Sandbox, SchemaValidationError, type StrategyInfo, type StrategyStep, applyToolkitIntegration, buildModuleCommand, checkApproval, collectInput, configureManHelp, createCli,
|
|
1030
|
+
export { type APCore, type ApcliConfig, ApcliGroup, ApcliGroupError, type ApcliMode, type ApplyToolkitIntegrationOptions, ApprovalDeniedError, ApprovalTimeoutError, AuditLogger, AuthProvider, AuthenticationError, CliApprovalHandler, ConfigDecryptionError, ConfigEncryptor, ConfigResolver, type CreateCliOptions, DEFAULTS, EXIT_CODES, type Executor, type ExitCode, ExposureFilter, GroupedModuleGroup, LazyGroup, LazyModuleGroup, type ModuleDescriptor, ModuleExecutionError, ModuleNotFoundError, type OptionConfig, type PipelineTrace, type PipelineTraceStep, type PreflightCheck, type PreflightResult, RESERVED_GROUP_NAMES, type Registry, Sandbox, SchemaValidationError, type StrategyInfo, type StrategyStep, applyToolkitIntegration, buildModuleCommand, checkApproval, collectInput, configureManHelp, createCli, exitCodeForError, formatExecResult, formatModuleDetail, formatModuleList, getAuditLogger, getLogLevel, main, reconvertEnumValues, registerCompletionCommand, registerConfigCommand, registerConfigNamespace, registerDescribeCommand, registerDisableCommand, registerEnableCommand, registerExecCommand, registerHealthCommand, registerInitCommand, registerListCommand, registerPipelineCommand, registerReloadCommand, registerUsageCommand, registerValidateCommand, resolveFormat, resolveRefs, schemaToCliOptions, setAuditLogger, setDocsUrl, setLogLevel, setVerboseHelp, validateModuleId };
|