Summary
This explains where src/lib/*.ts files should live.
The goal is to make future work more reviewable and consistent.
Proposed first step
Create a PR that documents the target src/lib layout and migration rules.
Suggested files:
src/lib/README.md
src/lib/core/README.md
src/lib/onboard/README.md
src/lib/inference/README.md
src/lib/sandbox/README.md
Update existing orientation READMEs as needed:
src/lib/actions/README.md
src/lib/domain/README.md
src/lib/adapters/README.md
src/commands/internal/README.md
Target rules to document
src/lib/commands/** = oclif command adapters / parser glue
src/lib/actions/** = workflow orchestration
src/lib/domain/** = pure decisions / policy / classification
src/lib/adapters/** = process, fs, Docker, OpenShell, network boundaries
src/lib/state/** = persisted local state
src/lib/cli/** = CLI framework/routing/help infrastructure
src/lib/core/** = tiny cross-cutting primitives
For large legacy areas that are not ready to split cleanly yet, document transitional feature folders:
src/lib/onboard/**
src/lib/inference/**
src/lib/sandbox/**
src/lib/policy/**
src/lib/shields/**
src/lib/credentials/**
src/lib/agent/**
src/lib/diagnostics/**
src/lib/dashboard/**
src/lib/deploy/**
src/lib/tunnel/**
Initial moves
Core / CLI primitives
branding.ts -> cli/branding.ts or core/branding.ts
command-registry.ts -> cli/command-registry.ts
terminal-style.ts -> cli/terminal-style.ts
duration-flags.ts -> cli/duration-flags.ts
version.ts -> core/version.ts
ports.ts -> core/ports.ts
json-types.ts -> core/json-types.ts
errno.ts -> core/errno.ts
wait.ts -> core/wait.ts
url-utils.ts -> core/url-utils.ts
shell-quote.ts -> core/shell-quote.ts
Host/process boundary
runner.ts -> adapters/process/runner.ts eventually
subprocess-env.ts -> adapters/process/env.ts
platform.ts -> adapters/host/platform.ts
http-probe.ts -> adapters/http/probe.ts
High-import files like runner.ts should either move later or keep temporary re-export shims.
Credentials / security
credentials.ts -> credentials/store.ts
credential-filter.ts -> security/credential-filter.ts
credential-hash.ts -> security/credential-hash.ts
redact.ts -> security/redact.ts
secret-patterns.ts -> security/secret-patterns.ts
Onboarding
onboard.ts -> onboard/flow.ts eventually
onboard-command.ts -> onboard/legacy-command.ts or commands/onboard/**
onboard-types.ts -> onboard/types.ts
onboard-session.ts -> state/onboard-session.ts
onboard-providers.ts -> onboard/providers.ts
onboard-inference-probes.ts -> inference/onboard-probes.ts
onboard-ollama-proxy.ts -> inference/ollama/proxy.ts
onboard-vllm.ts -> inference/vllm.ts
onboard-windows-ollama.ts -> inference/ollama/windows.ts
preflight.ts -> onboard/preflight.ts
usage-notice.ts -> onboard/usage-notice.ts
onboard.ts is very large and should not be moved casually unless we keep a compatibility re-export path.
Inference / models / local runtimes
inference-config.ts -> inference/config.ts
inference-health.ts -> inference/health.ts
local-inference.ts -> inference/local.ts
provider-models.ts -> inference/provider-models.ts
model-prompts.ts -> inference/model-prompts.ts
nim.ts -> inference/nim.ts
ollama-model-size.ts -> inference/ollama/model-size.ts
web-search.ts -> inference/web-search.ts
Sandbox support
sandbox-config.ts -> sandbox/config.ts
sandbox-build-context.ts -> sandbox/build-context.ts
sandbox-create-stream.ts -> sandbox/create-stream.ts
sandbox-version.ts -> sandbox/version.ts
sandbox-channels.ts -> sandbox/channels.ts or messaging/channels.ts
validation.ts -> domain/sandbox/validation.ts
validation-recovery.ts -> domain/sandbox/recovery-validation.ts
name-validation.ts -> domain/sandbox/name-validation.ts
Policy, shields, messaging
policies.ts -> policy/presets.ts or actions/policy/presets.ts
tiers.ts -> domain/policy/tiers.ts
private-networks.ts -> domain/network/private-networks.ts
shields.ts -> shields/index.ts
shields-timer.ts -> shields/timer.ts
shields-audit.ts -> shields/audit.ts
messaging-conflict.ts -> messaging/conflict.ts
chat-filter.ts -> messaging/chat-filter.ts
Agent-specific code
agent-defs.ts -> agent/defs.ts
agent-onboard.ts -> agent/onboard.ts
agent-runtime.ts -> agent/runtime.ts
Diagnostics / dashboard / runtime recovery
debug.ts -> diagnostics/debug.ts
debug-command.ts -> diagnostics/debug-command.ts
dashboard-contract.ts -> dashboard/contract.ts
dashboard-health.ts -> dashboard/health.ts
dashboard-recover.ts -> dashboard/recover.ts
runtime-recovery.ts -> runtime/recovery.ts
registry-recovery-action.ts -> actions/registry/recover.ts or actions/gateway/registry-recovery.ts
gateway-runtime-action.ts -> actions/gateway/runtime.ts
Deploy / services
deploy.ts -> actions/deploy/index.ts eventually
build-context.ts -> deploy/build-context.ts or sandbox/build-context-errors.ts
cluster-image-patch.ts -> deploy/cluster-image-patch.ts
services.ts -> tunnel/services.ts
services-command.ts -> tunnel/command.ts
Non-goals for the first PR
- Do not move every remaining file.
- Do not split
onboard.ts.
- Do not move
runner.ts without a compatibility strategy.
- Do not change public CLI behavior.
- Do not mix this with installer/runtime behavior work.
Acceptance criteria
- The target layout and placement rules are documented under
src/lib/**.
- The docs identify safe follow-up clusters and high-risk files that need shims or separate PRs.
- No behavior changes.
npx prek run --all-files passes.
Summary
This explains where
src/lib/*.tsfiles should live.The goal is to make future work more reviewable and consistent.
Proposed first step
Create a PR that documents the target
src/liblayout and migration rules.Suggested files:
Update existing orientation READMEs as needed:
Target rules to document
For large legacy areas that are not ready to split cleanly yet, document transitional feature folders:
Initial moves
Core / CLI primitives
Host/process boundary
High-import files like
runner.tsshould either move later or keep temporary re-export shims.Credentials / security
Onboarding
onboard.tsis very large and should not be moved casually unless we keep a compatibility re-export path.Inference / models / local runtimes
Sandbox support
Policy, shields, messaging
Agent-specific code
Diagnostics / dashboard / runtime recovery
Deploy / services
Non-goals for the first PR
onboard.ts.runner.tswithout a compatibility strategy.Acceptance criteria
src/lib/**.npx prek run --all-filespasses.