Todd of AIDLC — Code Map (exports by file)
One-line purpose for every public export. Use with ai-reference.md for why .
CLI entry (commander). Registers commands: chat, run, check getGoat, init, setup, aidlc, --ipc daemon mode.
Shared IPC and domain types (mirror extension). Key: AgentId, CopilotMode, ChatSendPayload, IpcAction.
Export
Purpose
AgentConnectorConfig
All agent connection settings (tokens, endpoints, Kiro CLI path).
KiroConnectorConfig
Kiro-specific: cliPath, trustTools, aidlcAutoInstall, mode cli|rest.
LoadedToddSpectConfig
Config + defaultAgent.
loadToddSpectConfig()
Merge YAML + env + TODDSPECT_SETTINGS_JSON; Copilot token includes getGhCliToken().
loadAgentConfig()
Returns only connectors slice (used by IPC router).
Export
Purpose
toddspectLog()
Print to stderr if TODDSPECT_IPC=1, else stdout.
toddspectWarn()
Same for warnings.
Export
Purpose
startIpcServer()
Main daemon loop: read stdin NDJSON, dispatch, write stdout frames.
Internal handlers: handleChatSend (context + spec injection), handleContextBuild, handleSpecParse, handleAidlcInstall, handleSetupBootstrap.
Export
Purpose
AUTO_ROUTING_RULES
Keyword/signal table for Auto provider selection (documented in file).
scoreAutoAgents()
Score each AgentId from prompt + mode + context.
resolveAutoAgent()
Pick ready agent; fallback chain if winner unavailable.
resolveAgentSelection()
Map auto → concrete AgentId.
Export
Purpose
AgentRequest
Route payload: messages, agent, mode, config, callbacks.
AgentRouter
Class with route() → per-agent private methods.
Method
Purpose
route()
Readiness check then switch on agent.
routeCopilot()
Token resolve + ask (SSE) or agent (tool loop).
routeCopilotAgent()
OpenAI tools loop, max 10 iterations.
routeDevin()
POST session to Devin API.
routeCursor()
Agent/Spec+Agent: Cursor SDK local or Copilot fallback; else Cloud API. Ask: Cloud.
routeClaude()
Spawn Claude Code CLI, parse NDJSON stdout.
routeKiro()
ensure Kiro CLI + AI-DLC, runKiroCli().
buildOpenAiMessages()
Map chat history; inject agent system prompt by mode.
streamSseRequest()
SSE parser for OpenAI-style streaming.
httpPostJson()
Non-streaming POST for tool-call turns.
Module-level: buildCopilotTools(), executeCopilotTool() — agent file tools.
Export
Purpose
AgentReadiness
{ agent, label, ready, hint }.
checkAgentReadiness()
Per-agent token/CLI checks.
checkAllAgents()
All five agents for check getGoat.
connectors/cursorLocal.ts
Export
Purpose
routeCursorLocal()
@cursor/sdk local runtime — edits TODDSPECT_WORKSPACE, emits onToolEvent.
cancelCursorLocalSession()
Cancel active SDK run on Stop.
clearCursorLocalSession()
Dispose SDK agent for session.
CursorLocalUnavailableError
SDK load failure — router may fall back to Copilot.
connectors/cursorCloud.ts
Export
Purpose
routeCursorCloud()
Cursor Cloud Agents API v1 — remote runs.
buildCursorPrompt()
Shared prompt for Cloud + SDK local (context + history).
cancelCursorCloudSession()
Cancel cloud run on Stop.
probeCursorApi()
GET /v1/me connection test.
connectors/copilotAuth.ts
Export
Purpose
COPILOT_INTEGRATION_ID
Header value for Copilot API.
getCopilotApiToken()
Exchange GitHub token via internal endpoint; cache ~15 min.
buildCopilotAuthHeaders()
Bearer + integration id.
validateCopilotToken()
Reject empty / ghp_ classic PATs.
Export
Purpose
getGhCliToken()
gh auth token; skip ghp_.
isGhCliAvailable()
gh auth status exit 0.
Export
Purpose
runKiroCli()
Exec kiro-cli chat --no-interactive with streaming stdout/stderr.
probeKiroCli()
Check binary exists/runs.
Export
Purpose
ensureKiroCli()
Download/install Kiro CLI for OS/arch; cache path in ~/.toddspect/tools.
resolveKiroCliPathSync()
Sync path: env > cache marker > bundled > kiro-cli.
Export
Purpose
getKiroToolsRoot()
~/.toddspect/tools/kiro-cli.
readCachedKiroCliPath() / writeCachedKiroCliPath()
Marker file for installed binary.
resolveBundledKiroCliPath()
Path inside extension/npm package if present.
Version, steering rule names, release zip URL for AI-DLC rules.
Export
Purpose
getAidlcPaths()
Workspace paths: .kiro/steering, aidlc-docs/.
Export
Purpose
getAidlcStatus()
Whether steering rules are installed + version.
Export
Purpose
installAidlcRules()
Copy vendor or download zip into .kiro/steering.
ensureAidlcInstalled()
Install if missing when autoInstall enabled.
resolveBundledAidlcVendorDir()
Bundled rules in extension/cli/vendor.
Export
Purpose
isAidlcActivationPrompt()
Detect "Using AI-DLC" prefix.
buildKiroPrompt()
Flatten messages + optional AI-DLC prefix for kiro-cli.
parsers/specParser.ts
Export
Purpose
parseSpecFile()
Parse one YAML spec with Zod validation.
parseSpecDirectory()
Parse all specs in folder.
specToYaml() / specToMarkdown()
Serialize spec for export/display.
parsers/markdownParser.ts
Export
Purpose
parseMarkdownFile()
Section-based markdown parse (legacy/spec docs).
scanMarkdownDirectory()
Find markdown files under tree.
Export
Purpose
getGoatCommand()
Print agent readiness + AI-DLC status; exit code 0 if any agent ready.
Export
Purpose
setupCommand()
init workspace + Kiro CLI + AI-DLC (flags: --skip-kiro, -q).
Export
Purpose
initCommand()
Create .toddspect/ scaffold (config, specs dir).
Export
Purpose
aidlcInstallCommand()
CLI wrapper for install.
aidlcStatusCommand()
CLI wrapper for status.
Export
Purpose
agentRunCommand()
One-shot agent prompt from CLI (todd run).
Export
Purpose
contextBuildCommand()
Build context items + token estimates from paths.
Export
Purpose
specParseCommand()
CLI spec parse to JSON.
Export
Purpose
McpConnection
MCP client (stdio/HTTP) for tool calls from CLI context.
Extension — packages/extension/src/
Export
Purpose
activate()
Start CliService daemon, bootstrap setup subprocess, register commands/webviews.
deactivate()
Subscriptions dispose CLI/MCP.
Commands include: toddspect.check.getGoat, toddspect.copilotLogin, toddspect.setup, toddspect.aidlcInstall, context commands.
Canonical types for extension + webview: AGENT_DESCRIPTORS, CopilotMode, IPC payloads, webview command unions.
Export
Purpose
buildToddSpectProcessEnv()
Build env for CLI child: secrets, live gh auth token first, TODDSPECT_SETTINGS_JSON, KIRO_CLI_PATH.
Export
Purpose
CliService
Spawn node cli/dist/index.js --ipc, NDJSON framing, restart with backoff, runCommand() for one-shot CLI.
onCliMessage()
EventEmitter per action for streaming push frames.
Export
Purpose
AgentService.chat()
Register chunk listeners, send chat:send with mode + specPaths, invoke callbacks.
cancelSession()
Drop active session id.
providers/ChatViewProvider.ts
Export
Purpose
ChatViewProvider
Webview view for chat; history, agent, mode; sendChatMessage(); resolveSpecPaths() for spec+agent.
providers/ContextProvider.ts
Export
Purpose
ContextProvider
Track context URIs; expose absolute paths to AgentService.
panels/ConfigurationPanel.ts
Export
Purpose
ConfigurationPanel
Webview for tokens, test connection, save secrets.
Export
Purpose
initSddWorkspace()
Bootstrap .toddspect/sdd/ (spec-kit layout).
getSddWorkflowStatus()
Step states (locked/ready/done) per feature.
createSddFeature()
New specs/001-slug/ with spec + clarifications templates.
writeSddArtifact()
Scaffold constitution, spec, plan, tasks, checklist.
buildSddStepPrompt()
/speckit.* prompts for chat.
collectSddContextPaths()
Paths to attach when running a step.
panels/SpecManagerPanel.ts
Export
Purpose
SpecManagerProvider
SDD webview: spec-kit workflow + Todd of AIDLC specs editor; IPC sdd:workflow:*.
Export
Purpose
McpClientManager
Extension-side MCP servers from workspace config.
Export
Purpose
buildCopilotAuthHeaders()
Duplicate of CLI headers for connection test in UI.
validateCopilotToken()
Duplicate validation for config panel.
Browser bundle: chat UI, mode bar (Ask/Agent/Spec+Agent), agent dropdown, context chips, markdown render, slash commands.
Browser bundle: configuration wizard UI.
Browser bundle: spec editor/list UI.
Path
Purpose
scripts/bundle-cli.mjs
Copy CLI dist + AI-DLC vendor into packages/extension/cli/.
scripts/smoke-ipc.mjs
IPC ping smoke test.
Path
Purpose
.toddspect/config.yaml
Default agent, connector endpoints (no secrets).
.toddspect/specs/*.yaml
SDD spec definitions for Spec+Agent mode.