DreamLake

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 fileDecisionWhy
src/cli/client.tsRestored unchangedOriginal HTTP encoding, error class, attribution and streaming stay in place; API uses its own thin transport.
src/cli/compat/http.tsRestored unchangedRestore original data-plane HTTP wrappers and their existing retry behavior.
src/cli/compat/presignedTransfer.tsRestored unchangedAPI re-exports existing upload executor; no relocation or duplicate executor.
src/cli/notes/character-plan.tsRestored unchangedAPI re-exports existing pure alignment planner.
src/cli/notes/document.tsRestored unchangedOriginal Memo source/read/conditional patch and span compiler remain unchanged; API adapter validates expected text before calling it.
src/cli/notes/editing.tsRestored unchangedAPI re-exports existing pure Unicode editing helpers.
src/cli/notes/html.tsRestored unchangedAPI re-exports existing HTML parser/selectors.
src/cli/notes/html-read.tsRestored unchangedAPI re-exports existing snapshot validation/annotation.
src/cli/notes/toc.tsRestored unchangedAPI re-exports existing outline implementation.
src/cli/notes/events.tsSmall addition retainedKeep original SSE parser and CLI default request. Add optional request function for explicit API transport.
src/cli/jobs/api.tsSmall addition retainedKeep original operations/connect. Add explicit-credential create factory and injected fetch; API re-exports it.
src/cli/infra/api.tsSmall addition retainedKeep original validation/operations/connect. Add explicit-credential create factory and injected fetch; API re-exports it.
src/cli/layout/transport.tsRestored unchangedAPI re-exports original explicit-loopback transport.
src/cli/library/add.tsRestored unchangedAPI re-exports already exported merge planner; CLI add remains unchanged.
src/cli/library/rm.tsRestored unchangedAPI re-exports already exported removal planner; CLI rm remains unchanged.
src/cli/library/manifest.tsRestored unchangedAPI re-exports existing manifest types, validation and diff.
src/cli/project/grants.tsRestored unchangedRestore original CLI attachment/grant flow. API independently uses the same authorized service contract.
src/cli/runnable/run.tsSmall addition retainedKeep original planner, submit and receipt validation. Add optional request function to receipt reader; API submission is an explicit-transport adapter.
src/cli/runnable/worker.tsRestored unchangedKeep original worker string and its imports; delete duplicate API worker module.
src/cli/index.tsSmall addition retainedRestore 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.