<!-- source: https://cli.dreamlake.ai/dev/api-change-audit @ 0.134.0 99837ab -->

# Minimal CLI changes for the TypeScript API

Unreleased source under review. Capability coverage does not require moving the
existing CLI implementation. The review compares the pre-PR source with the
current diff, follows imports and checks both source and actual npm-pack output.
Existing HTTP, Memo editing/HTML, upload, library, layout and project operations
stay at their original locations. Public API modules re-export existing helpers
or adapt explicitly supplied transport/credentials; they do not execute CLI startup.

15 existing CLI files are restored byte-for-byte to the pre-PR source. The remaining 5 files have the small additions explained below. Churn in these 20 existing source files drops from 3471 to 53 added/deleted lines. This excludes new session features and tests.

| Existing file | Decision | Why |
| --- | --- | --- |
| `src/cli/client.ts` | Restored unchanged | Original HTTP encoding, error class, attribution and streaming stay in place; API uses its own thin transport. |
| `src/cli/compat/http.ts` | Restored unchanged | Restore original data-plane HTTP wrappers and their existing retry behavior. |
| `src/cli/compat/presignedTransfer.ts` | Restored unchanged | API re-exports existing upload executor; no relocation or duplicate executor. |
| `src/cli/notes/character-plan.ts` | Restored unchanged | API re-exports existing pure alignment planner. |
| `src/cli/notes/document.ts` | Restored unchanged | Original Memo source/read/conditional patch and span compiler remain unchanged; API adapter validates expected text before calling it. |
| `src/cli/notes/editing.ts` | Restored unchanged | API re-exports existing pure Unicode editing helpers. |
| `src/cli/notes/html.ts` | Restored unchanged | API re-exports existing HTML parser/selectors. |
| `src/cli/notes/html-read.ts` | Restored unchanged | API re-exports existing snapshot validation/annotation. |
| `src/cli/notes/toc.ts` | Restored unchanged | API re-exports existing outline implementation. |
| `src/cli/notes/events.ts` | Small addition retained | Keep original SSE parser and CLI default request. Add optional request function for explicit API transport. |
| `src/cli/jobs/api.ts` | Small addition retained | Keep original operations/connect. Add explicit-credential create factory and injected fetch; API re-exports it. |
| `src/cli/infra/api.ts` | Small addition retained | Keep original validation/operations/connect. Add explicit-credential create factory and injected fetch; API re-exports it. |
| `src/cli/layout/transport.ts` | Restored unchanged | API re-exports original explicit-loopback transport. |
| `src/cli/library/add.ts` | Restored unchanged | API re-exports already exported merge planner; CLI add remains unchanged. |
| `src/cli/library/rm.ts` | Restored unchanged | API re-exports already exported removal planner; CLI rm remains unchanged. |
| `src/cli/library/manifest.ts` | Restored unchanged | API re-exports existing manifest types, validation and diff. |
| `src/cli/project/grants.ts` | Restored unchanged | Restore original CLI attachment/grant flow. API independently uses the same authorized service contract. |
| `src/cli/runnable/run.ts` | Small addition retained | Keep original planner, submit and receipt validation. Add optional request function to receipt reader; API submission is an explicit-transport adapter. |
| `src/cli/runnable/worker.ts` | Restored unchanged | Keep original worker string and its imports; delete duplicate API worker module. |
| `src/cli/index.ts` | Small addition retained | Restore original command registration/startup. Only a private read-only inventory branch is added, skipping migration/updates/telemetry/command execution. Delete program.ts extraction. |

`src/cli/program.ts`, the duplicate API worker and `tsconfig.api.json` are
removed. The npm generator uses the existing TypeScript configuration and keeps
compiled paths/dependencies from the same CLI package. It does not create or
maintain a second SDK package. The private command-tree audit preserves the
472-command coverage check without extracting the CLI entrypoint.

The new session-control runner, its isolation/fencing/recovery fixes, the API
export and declaration emission remain necessary feature additions. Existing
command behavior, authentication selection and output remain CLI-owned.

Boundary regressions check that importing source or the extracted npm tarball
cannot read saved credentials, start a process or use ambient network fetch.
Jobs/Infra and Memo API calls use supplied credentials/fetch. A consumer compiles
against the extracted package's actual exports and declarations. Original CLI
regressions continue to exercise their original modules.
