Read the Codant source
Follow codant hunt from the CLI through task execution, validation, and result retrieval. Then trace how the terminal and VS Code read task state and changes from the same daemon.
Paths start at the product repository root and describe the current development tree. Search for the named class, function, or method in your checkout. To check an installed build, run codant --version and consult the corresponding source revision. Integrations can use the daemon/initialize response to discover the capabilities of the current connection. Product repository · Initialization response
Find the right package
| What you are looking for | Where to start |
|---|---|
| Task cards, pheromones, claims, and completion rules | PheromoneBus in packages/core/src/bus/bus.ts and schedule in packages/core/src/ant/scheduler.ts. |
| Daemon connections, RPC, and task execution | Method dispatch in packages/api/src/connection.ts and ScoutTaskExecutor.submitHunt in packages/api/src/scout-task-executor.ts. |
| CLI commands and terminal UI | CLI commands enter through packages/cli/src/index.ts. The terminal root in packages/cli/src/tui/root.tsx wires up scheduler commands. |
| TypeScript integration clients | packages/sdk/src/index.ts and packages/ui/src/index.ts export clients from @codant/api. Follow each client's protocol imports for its request and response types. SDK integration guide |
| VS Code extension and panel | packages/vscode/src/extension.ts registers the panel. In the same directory, bridge-client.ts manages the bridge connection and panel-inspect-controller.ts handles swarm state and workspace diffs. |
Trace a codant hunt run
- Enter the local daemon from the CLI. The
huntbranch ofpackages/cli/src/index.tsparses the arguments and checks daemon availability before callingrunRealHunt. FollowrunHuntinpackages/api/src/hunt.tsto see the client open the local runtime endpoint, negotiate capabilities withdaemon/initialize, subscribe to bus events, and sendtask/submit. The client usestaskIdandrootTaskIdfrom the submission receipt to associate events with the run. Event reference - Accept the submission and create the card. In
packages/api/src/hunt-submit-rpc.ts,TaskSubmissionRequests.handlechecks the connection and submission parameters and callsScoutTaskExecutor.submitHuntin the adjacentscout-task-executor.ts. The executor validates the project directory, establishes the task plan and execution conditions, submits the root task through the pheromone bus, and starts the hunt. The response contains the task and root task IDs. - Execute the task and validate the candidate. The root dispatch in
packages/api/src/scout-root-dispatch.tsconnects execution to delivery. After the worker runs,ScoutExecution.runinscout-execution.tsprepares a candidate and checks it against the frozen task plan. For read-only answers, it checks for workspace changes. Tasks that can write go through the applicable delivery checks. Before recording completion,stageCompletioninpackages/core/src/bus/lease-commands.tschecks that acceptance belongs to the latest claim generation and checks dependencies, active leases, and unresolved alarms. - Confirm the result from task records. The terminal learns the final state through task events. For
--answer,readHuntAnswerinpackages/api/src/hunt-answer.tschecks the accepted delivery against the task IDs, claim generation, and artifact digests before printing the answer. If the task completed and the answer cannot be confirmed,runRealHuntinpackages/api/src/chat.tsprints the history command for the original task. Hunt guide
The detailed design describes how investigation, execution, and acceptance fit together and how subtasks hand results back to the parent.
Trace a read from either interface
- Terminal. Start with the
/antsbranch inpackages/cli/src/tui/scheduler-commands.ts. The swarm view reads the current working set fromSwarmHub.snapshot()inpackages/api/src/swarm-hub.ts. The history browser inpackages/cli/src/tui/task-history-browser.tsorganizes parent and child cards, and the task detail view can open related file changes. For scripts,packages/cli/src/task.tsmapscodant task showtotask/inspectandcodant task evidencetotask/evidence. Task query reference - VS Code. The extension connects to the daemon through the IDE bridge in
packages/vscode/src/bridge-client.ts. In the same directory,panel-inspect-controller.tsreadsswarm/snapshotand uses its sequence to requestswarm/subscribe, refreshing the panel as state changes. Workspace diffs have a separate query throughWorkspaceDiffClient. When building an integration, choose the interface for the current working set, durable history, or workspace changes. VS Code guide
Verify a change
| Area you are changing | Tests to start with |
|---|---|
| Hunt submission, cancellation, or reconnects | packages/api/test/hunt-client.test.ts checks how the actual task title and working directory are submitted. The adjacent hunt-recovery.test.ts covers resuming the event cursor and avoiding a duplicate cancellation after disconnecting. |
| Subtask scheduling or completion conditions | packages/api/test/parallel-hunt.test.ts covers worktree isolation, overlapping file scopes, and cascading cancellation. packages/core/test/task-recovery.test.ts covers task recovery on restart. |
| Task views in the terminal or VS Code | packages/api/test/swarm-hub-working-set.test.ts checks which tasks enter the current working set. packages/cli/test/tui/swarm-matrix-detail.test.tsx checks that opening details and file changes preserves the original history query. packages/vscode/test/panel-snapshot-publisher.test.ts covers snapshot delivery and page changes. |
When extending a client, follow the existing request and response validation. For a new RPC method, check the schema registration in packages/api/src/feature-protocol-registry.ts and the capability response and request dispatch in the adjacent connection.ts. Verify how the client behaves when the daemon lacks the capability. Build from source
