Skip to content
Website ↗

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 forWhere to start
Task cards, pheromones, claims, and completion rulesPheromoneBus in packages/core/src/bus/bus.ts and schedule in packages/core/src/ant/scheduler.ts.
Daemon connections, RPC, and task executionMethod dispatch in packages/api/src/connection.ts and ScoutTaskExecutor.submitHunt in packages/api/src/scout-task-executor.ts.
CLI commands and terminal UICLI commands enter through packages/cli/src/index.ts. The terminal root in packages/cli/src/tui/root.tsx wires up scheduler commands.
TypeScript integration clientspackages/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 panelpackages/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 ​

  1. Enter the local daemon from the CLI. The hunt branch of packages/cli/src/index.ts parses the arguments and checks daemon availability before calling runRealHunt. Follow runHunt in packages/api/src/hunt.ts to see the client open the local runtime endpoint, negotiate capabilities with daemon/initialize, subscribe to bus events, and send task/submit. The client uses taskId and rootTaskId from the submission receipt to associate events with the run. Event reference
  2. Accept the submission and create the card. In packages/api/src/hunt-submit-rpc.ts, TaskSubmissionRequests.handle checks the connection and submission parameters and calls ScoutTaskExecutor.submitHunt in the adjacent scout-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.
  3. Execute the task and validate the candidate. The root dispatch in packages/api/src/scout-root-dispatch.ts connects execution to delivery. After the worker runs, ScoutExecution.run in scout-execution.ts prepares 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, stageCompletion in packages/core/src/bus/lease-commands.ts checks that acceptance belongs to the latest claim generation and checks dependencies, active leases, and unresolved alarms.
  4. Confirm the result from task records. The terminal learns the final state through task events. For --answer, readHuntAnswer in packages/api/src/hunt-answer.ts checks 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, runRealHunt in packages/api/src/chat.ts prints 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 /ants branch in packages/cli/src/tui/scheduler-commands.ts. The swarm view reads the current working set from SwarmHub.snapshot() in packages/api/src/swarm-hub.ts. The history browser in packages/cli/src/tui/task-history-browser.ts organizes parent and child cards, and the task detail view can open related file changes. For scripts, packages/cli/src/task.ts maps codant task show to task/inspect and codant task evidence to task/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.ts reads swarm/snapshot and uses its sequence to request swarm/subscribe, refreshing the panel as state changes. Workspace diffs have a separate query through WorkspaceDiffClient. 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 changingTests to start with
Hunt submission, cancellation, or reconnectspackages/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 conditionspackages/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 Codepackages/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