Package Map

July 22, 2026 · View on GitHub

This map describes current package ownership and the layer each package belongs to. It should match the code under cmd/ and internal/. Layer names are defined in dependency-rules.md — update both files together when the assignment changes.

Entrypoints

PathLayerResponsibility
cmd/sancmdMain CLI binary. Parses flags, initializes runtime, wires subcommands.

Application Shell

PathLayerResponsibility
internal/appappBubble Tea root model, service composition, event routing, session restore, app lifecycle.
internal/app/convappConversation rendering state and agent outbox observation.
internal/app/inputappText input, selectors, approvals, user-input flow.
internal/app/triggerappSystem triggers such as cron and async hook polling.
internal/brokerfeatureRoutes messages between agents: addresses keyed by agent id, for main↔subagent messages and completions.
internal/app/kitappTUI support helpers shared by app subpackages.

Core Contracts

PathLayerResponsibility
internal/corecoreShared contracts for messages, tools, agents, sections, and system prompts.

Feature Packages

Agent, persistence, and orchestration:

PathLayerResponsibility
internal/agentfeatureAgent construction, permission adapter, and session-facing setup.
internal/llmfeatureLLM service, provider registry, provider setup, cost tracking, logging.
internal/toolfeatureBuilt-in tool schemas, registry, adapters, permission checks, execution.
internal/sessionfeatureSession metadata, transcript persistence, resume, projection, message conversion.
internal/session/transcriptfeatureTranscript records, filesystem store, projection, renderable views.
internal/taskfeatureBackground task management, bash and agent task execution, output storage.
internal/todofeatureAgent to-do list state and background tracker service (lifted from task/tracker).
internal/subagentfeatureSubagent registry, loading, matching, execution, storage, progress tools.
internal/cronfeatureCron definitions, storage, service, loop.
internal/selflearnfeatureBackground self-learning reviewer, durable memory store, and restricted skill-update surface.

Extension surfaces:

PathLayerResponsibility
internal/commandfeatureSlash command registry, built-ins, Markdown command loading.
internal/skillfeatureSkill registry, loading, lazy loading metadata.
internal/pluginfeaturePlugin compatibility, loading, installation, marketplace, integration.
internal/mcpfeatureMCP config, client, registry, caller, hook integration.
internal/mcp/transportfeatureMCP transport implementations.
internal/hookfeatureHook registry, matcher, engine, executors, store.

Configuration and supporting capabilities:

PathLayerResponsibility
internal/settingfeatureSettings loading, merge, permissions, operation mode, workdir, env.
internal/personafeaturePersona registry (system-prompt parts, skills, settings overlay), template, paths.
internal/searchfeatureSearch provider implementations and factory.
internal/inspectorfeatureTranscript inspector server, replay, stream, embedded UI.
internal/reminderfeatureRuntime reminder queue and provider integration.
internal/reviewerfeatureAuto-review LLM judge for gray-zone permissions and bash prompts.
internal/imagefeatureImage handling + core.Image adapter; provisional — see note in dependency-rules.md.

Infrastructure Helpers

PathLayerResponsibility
internal/loginfrastructureLogging, request/response logs, development log paths.
internal/secretinfrastructureSecret storage helpers.
internal/filecacheinfrastructureFile restore/cache helpers.
internal/markdowninfrastructureMarkdown frontmatter parsing.
internal/procinfrastructureCross-platform process-group / signal helpers (Unix/Windows variants).
internal/confdirinfrastructureShared .san configuration directory naming helper.
internal/atomicfileinfrastructureTemp-file-then-rename file replacement, so a reader never sees a half-written file.

Ownership Rule

New behavior should live in the package that owns the capability. Add a new top-level internal/ package only when the behavior has a distinct lifecycle, state model, or dependency boundary that does not fit an existing package. When adding a package, assign it a layer in this map and confirm the imports match dependency-rules.md.