apcore-cli 0.8.1 → 0.9.1

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 CHANGED
@@ -5,6 +5,76 @@ All notable changes to apcore-cli (TypeScript SDK) will be documented in this fi
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.9.1] - 2026-05-13
9
+
10
+ ### Fixed
11
+
12
+ - **Pre-execute schema validation missing in `buildModuleCommand`** — before calling `executor.execute()`, the CLI now validates the merged input against the module's JSON Schema (required fields + scalar types). Previously, a missing required field (e.g. `--url` not supplied) propagated as `undefined` into the executor and produced an opaque `TypeError`. Now exits 45 with a human-readable message (`Validation failed: 'url' is required`) matching Python's `jsonschema.validate` and Rust's `validate_against_schema` pre-execute behaviour. Validation is skipped in `--dry-run` mode (executor preflight handles that path). `src/main.ts:177-208` (`validateInputSchema`), call site `src/main.ts:1127-1133`.
13
+ - **`SchemaValidationError` emitted `"code":"UNKNOWN"` in JSON error output** — `emitErrorJson` reads `err.code` to populate the `"code"` field; `SchemaValidationError` had no `.code` property, so exit-45 validation errors always emitted `"code":"UNKNOWN"`. Added `readonly code = "SCHEMA_VALIDATION_ERROR"` to the class. `src/errors.ts:52`.
14
+
15
+ ### Changed
16
+
17
+ - **Step comment numbering in `buildModuleCommand` action handler corrected** — inserting the schema-validation step left two "3." labels in the try block. Renumbered: 3 = schema validation, 4 = check approval, 5 = execute, 6 = format, 7 = audit. `src/main.ts`.
18
+
19
+ ### Tests
20
+
21
+ - Renamed test 4 in the pre-execute schema-validation suite from `"exits 45 with type error message when field has wrong type"` (which actually tested the required-field path) to `"exits 45 when required field is missing (integer schema)"`.
22
+ - Added test 5: `"exits 45 with type-mismatch message when integer field receives string via --input"` — supplies `{"count":"not-a-number"}` via `--input <file>` to exercise the scalar type-check branch (`validateInputSchema` lines 198-206) that had zero coverage.
23
+
24
+ ---
25
+
26
+ ## [0.9.0] - 2026-05-13
27
+
28
+ ### Fixed (2026-05-13 — cross-SDK audit D10/D11/D1)
29
+
30
+ - **`ConfigEncryptor` LOGNAME key-derivation chain** (D10-001) — PBKDF2 username fallback was `USER → USERNAME → "unknown"` (3-tier); now `USER → LOGNAME → USERNAME → "unknown"` (4-tier) matching the spec and Rust. `src/security/config-encryptor.ts:183, 219`.
31
+ - **Sandbox stdin write lacks `'error'` listener** (D11-008) — `child.stdin.on('error', () => {})` added before `write()` so an EPIPE event from a child that exits early no longer surfaces as an uncaught exception. `src/security/sandbox.ts:153`.
32
+ - **`buildSandboxEnv` drops explicitly-empty env values** (D11-009) — `if (process.env[key])` changed to `if (process.env[key] !== undefined)` so `PATH=""` is forwarded uniformly with Python and Rust. `src/security/sandbox.ts:264`.
33
+ - **`exec --trace` flag ignored when used without `--strategy`** (D11-011) — condition `if (opts.strategy && executor.callWithTrace)` changed to `if ((opts.trace || opts.strategy) && executor.callWithTrace)`. `--trace` alone now routes through `callWithTrace` matching Python. `src/discovery.ts:345`.
34
+ - **CLI brand string in auth error messages** (D11-006) — remediation strings now say `apcli config set auth.api_key` (canonical FE-13 name). `src/security/auth.ts:46`.
35
+ - **`requestApproval` missing `requires_approval=false` short-circuit** (D11-014) — returns `approved/not_required` when the request explicitly carries `requires_approval: false`, matching Rust. `src/approval.ts:63`.
36
+ - **`AuthProvider` missing `config.encryptor` peer-attribute fallback** (D11-005) — `getEncryptor()` now walks explicit constructor arg → `config.encryptor` peer attribute → fresh instance, matching Python's three-tier chain. `src/security/auth.ts:22`.
37
+ - **`APCLI_SUBCOMMAND_NAMES` and `DEFAULT_BUILTIN_GROUP_NAME` not re-exported** (D1 re-audit) — both constants added to `src/index.ts:27` export block. Python and Rust already re-exported both.
38
+ - **Standalone bin entrypoint used deprecated `verbose:` field internally** (D9 re-audit) — `src/main.ts:848` `createCli` call now passes canonical `allOptions: verboseHelp`.
39
+ - **Stale `cli.ts` placeholder-type TODO** (D9-W2) — TODO comment updated to document the actual `apcore-js` Registry/ModuleDescriptor shape gap (method names diverge: `listModules`/`getModule` vs `list`/`getDefinition`/`moduleId`), replacing the generic "until available" wording.
40
+
41
+ ### Added
42
+
43
+ - **`CreateCliOptions.allOptions` field** (D1-W5) — canonical successor to the deprecated `verbose` field. Embedders should migrate `createCli({ verbose: true })` → `createCli({ allOptions: true })`. `verbose` remains for backward compat through v0.9 and will be removed in v0.10. `src/main.ts:251`.
44
+ - **`setLogLevel` / `getLogLevel` documented as intentionally TS-only** (D1-W4) — `src/index.ts:96-102` now carries a cross-SDK parity note explaining that Python and Rust delegate to their native logging channels.
45
+ - **`getAuditLogger` documented as intentionally TS-only** (D1 re-audit) — `src/index.ts:106` now carries a note. Only the setter (`setAuditLogger`) is the canonical cross-SDK API.
46
+
47
+ ### Fixed
48
+
49
+ - **CSV `--format csv` heterogeneous-keys data loss** — `formatExecResult` previously derived CSV headers from `Object.keys(rows[0])` only, silently dropping fields that first appeared in later rows. Surfaced via aisee-cli's `summarizeAction()` which emits optional `description` / `solution` fields. The header is now the **union of keys across all rows** in insertion-order. `src/output.ts:340-357`.
50
+ - **CSV line terminator** — now `\r\n` per RFC 4180 (was `\n`). Existing Excel + downstream-parser compatibility improves significantly.
51
+ - **CSV nested-value serialization** — now goes through the toolkit's canonical JSON encoder (compact, insertion-order, unicode-preserved). Behavior was already correct via `JSON.stringify`, but the contract is now enforced at the toolkit layer.
52
+
53
+ ### Changed
54
+
55
+ - **User-visible help/man/completion/error text no longer leaks the `apcore` / `apcore-js` framework name** to end users of downstream CLIs built on apcore-cli. Affected strings: footer hint (`Use --verbose to show all options (including built-in apcore options)` → `… (including built-in options)`, `src/main.ts:947`), `init` group description (`Scaffold new apcore modules` → `Scaffold new modules`, `src/init-cmd.ts:82`), top-level CLI description (`… execute apcore modules from the command line` → `… execute modules from the command line`, `src/main.ts:835`), standalone unwired-registry error message (`Error: no apcore-js registry wired.` → `Error: no module registry wired.`, `src/main.ts:619`), and man-page `ENVIRONMENT` text (`Path to the apcore extensions directory.` → `Path to the extensions directory.`, `src/shell.ts:302`). README's `--verbose` row updated to match. Two `tests/main.test.ts` assertions (`:891`, `:916`) updated to the new error string. Logger names, source comments, type comments, and environment-variable identifiers (`APCORE_*`) are unchanged — only descriptive copy that appears in `--help`, shell completion, `man` output, or user-facing error messages. Cross-SDK parity with Python 0.8.1 and Rust 0.8.1.
56
+
57
+ ### Changed (breaking CLI surface)
58
+
59
+ - **Global `--verbose` flag renamed to `--all-options`** — The help-display flag is now `--all-options`; use `apcore-cli module --help --all-options` to reveal hidden built-in options. `verbose` is removed from the reserved schema property names set — module schemas may now freely define `verbose: boolean` for runtime output control. Tracked in [apcore-cli#21](https://github.com/aiperceivable/apcore-cli/issues/21).
60
+
61
+ ### Changed (breaking peer-dep semantics)
62
+
63
+ - **`apcore-toolkit` promoted from optional to REQUIRED peer dependency** (`>=0.7.0`). All `--format` operations now go through the toolkit's reference implementation for csv/jsonl/markdown/skill (was only markdown/skill). Consumers that did not install the optional peer must add it. `package.json` peer-dependency-meta `optional: true` removed.
64
+
65
+ ### Removed
66
+
67
+ - `csvCellString` and `escapeCsvField` private helpers — replaced by `apcore_toolkit.formatCsv()` and the toolkit's RFC 4180 internals.
68
+
69
+ ### Why
70
+
71
+ Per-SDK CSV reimplementations had accumulated divergence: Python emitted Python repr `{'k': 'v'}`, TS dropped heterogeneous keys, Rust used `\n` not CRLF. The spec MUST language couldn't enforce conformance on downstream consumers (e.g. aisee-cli) that reimplemented. See ADR-09 in `apcore-cli/docs/tech-design.md` for the byte-equivalent vs SDK-native tier split.
72
+
73
+ ### Migration
74
+
75
+ Downstream consumers using only `json` / `table` formats are unaffected at runtime but need `apcore-toolkit@^0.7` installed alongside `apcore-cli@^0.9` (previously optional). aisee-cli and similar adapters get the CSV bug fix automatically on upgrade.
76
+
77
+
8
78
  ## [0.8.1] - 2026-05-09
9
79
 
10
80
  ### Fixed
package/README.md CHANGED
@@ -8,7 +8,7 @@ Terminal adapter for apcore. Execute AI-Perceivable modules from the command lin
8
8
 
9
9
  [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
10
10
  [![Node](https://img.shields.io/badge/node-18%2B-blue.svg)](https://nodejs.org)
11
- [![Tests](https://img.shields.io/badge/tests-275%2B%20passed-brightgreen.svg)]()
11
+ [![Tests](https://img.shields.io/badge/tests-passing-brightgreen.svg)]()
12
12
 
13
13
  | | |
14
14
  |---|---|
@@ -46,16 +46,15 @@ Terminal adapter for apcore. Execute AI-Perceivable modules from the command lin
46
46
  ## Installation
47
47
 
48
48
  ```bash
49
- pnpm add apcore-cli apcore-js
49
+ pnpm add apcore-cli apcore-js apcore-toolkit
50
50
  ```
51
51
 
52
- Requires Node.js 18+ and `apcore-js >= 0.21.0`.
52
+ Requires Node.js 18+, `apcore-js >= 0.21.0`, and `apcore-toolkit >= 0.7.0` (required peer dep as of v0.9.0).
53
53
 
54
- **Optional:** install `apcore-toolkit` (>=0.6.0) to enable display overlay and registry writer integration via `applyToolkitIntegration`, `DisplayResolver`, and `RegistryWriter`.
54
+ **v0.9.0 breaking change:** `apcore-toolkit` is now a **required** peer dependency (previously optional). All `--format` operations route through the toolkit's byte-equivalent reference implementations for csv / jsonl / markdown / skill. See [tech-design ADR-09](https://github.com/aiperceivable/apcore-cli/blob/main/docs/tech-design.md) for the rationale and migration notes.
55
55
 
56
56
  ```bash
57
- pnpm add apcore-cli apcore-js
58
- pnpm add -D apcore-toolkit # optional, for display overlay / registry writer
57
+ pnpm add apcore-cli apcore-js apcore-toolkit
59
58
  ```
60
59
 
61
60
  ## Quick Start
@@ -151,7 +150,7 @@ your-project/
151
150
  No changes to your project. Just install and run:
152
151
 
153
152
  ```bash
154
- pnpm add apcore-cli apcore-js
153
+ pnpm add apcore-cli apcore-js apcore-toolkit
155
154
  apcore-cli --extensions-dir ./extensions list
156
155
  apcore-cli --extensions-dir ./extensions math.add --a 5 --b 10
157
156
  ```
@@ -185,7 +184,7 @@ apcore-cli [OPTIONS] COMMAND [ARGS]
185
184
  | `--log-level` | `WARNING` | Logging: `DEBUG`, `INFO`, `WARNING`, `ERROR` |
186
185
  | `--version` | | Show version and exit |
187
186
  | `--help` | | Show help and exit |
188
- | `--verbose` | | Show all options in help (including built-in apcore options) |
187
+ | `--all-options` | | Show all options in help (including built-in options) |
189
188
  | `--man` | | Output man page in roff format (use with `--help`) |
190
189
 
191
190
  ### Built-in Commands (the `apcli` group)
@@ -235,12 +234,17 @@ The canonical 13 `apcli` subcommands:
235
234
  | `apcli init module <id>` | Scaffold a new module (TS/JS/YAML binding) into the extensions or commands directory (see `registerInitCommand` in `src/init-cmd.ts`) |
236
235
  | `apcli validate` | Validate modules and configuration against JSON Schema (see `registerValidateCommand` in `src/discovery.ts`) |
237
236
 
238
- **Shell integration**
237
+ **Shell integration** (under `apcli` group)
239
238
 
240
239
  | Command | Description |
241
240
  |---------|-------------|
242
241
  | `apcli completion <shell>` | Generate shell completion script for bash / zsh / fish (see `registerCompletionCommand` in `src/shell.ts`) |
243
- | `man [command]` (root) | Generate a man page in roff format for a single command or the whole program (see `configureManHelp` in `src/shell.ts`). Stays at the root (meta-command). |
242
+
243
+ **Root meta-commands** (NOT under `apcli` — invoked directly on the host CLI)
244
+
245
+ | Command | Description |
246
+ |---------|-------------|
247
+ | `<cli> --help --man [command]` | Generate a man page in roff format for a single command or the whole program (see `configureManHelp` in `src/shell.ts`). This is a root-level option, not an `apcli` subcommand. |
244
248
 
245
249
  #### Standalone vs. embedded surfaces
246
250
 
@@ -251,14 +255,14 @@ The canonical 13 `apcli` subcommands:
251
255
 
252
256
  ### Module Execution Options
253
257
 
254
- When executing a module (e.g. `apcore-cli math.add`), these built-in options are available (hidden by default; use `--verbose` to show in `--help`):
258
+ When executing a module (e.g. `apcore-cli math.add`), these built-in options are available (hidden by default; use `--all-options` to show in `--help`):
255
259
 
256
260
  | Option | Description |
257
261
  |--------|-------------|
258
262
  | `--input -` | Read JSON input from STDIN |
259
263
  | `--yes` / `-y` | Bypass approval prompts |
260
264
  | `--large-input` | Allow STDIN input larger than 10MB |
261
- | `--format <fmt>` | Output format: `json`, `table`, `csv`, `yaml`, or `jsonl` |
265
+ | `--format <fmt>` | Output format: `json`, `table`, `csv`, `yaml`, `jsonl`, `markdown`, `skill`. **v0.9.0:** `csv` / `jsonl` are byte-identical across SDKs via `apcore-toolkit.formatCsv` / `formatJsonl`. Fixes the prior heterogeneous-keys data-loss bug (header was derived from first row only). |
262
266
  | `--sandbox` | Run module in a subprocess sandbox (re-exec with stripped env; 64MiB stdout/stderr cap; 300s default timeout). Hidden by default — set `APCORE_CLI_SANDBOX=1` to enable globally. |
263
267
  | `--dry-run` | Run preflight checks (schema, ACL, approval) without executing (FE-11) |
264
268
  | `--trace` | Emit execution pipeline trace (strategy, hooks, middleware timings) |