Development Guide
Development Guide
Section titled “Development Guide”Agents and quick verify: Agent harness · Do / don’t / pitfalls: Agent golden rules · Root index: AGENTS.md
Prerequisites
Section titled “Prerequisites”Installation
Section titled “Installation”cd agent-detectivepnpm installConfiguration
Section titled “Configuration”See configuration-hub.md for load order and top-level keys, then configuration.md for default.json / local.json merge rules, supported environment variables, and generated plugin option schemas.
Edit config/default.json
Section titled “Edit config/default.json”{ "port": 3001, "agent": "opencode", "plugins": [ { "package": "@agent-detective/local-repos-plugin", "options": { "repos": [ { "name": "my-project", "path": "/path/to/your/project", "description": "Your project description" } ], "techStackDetection": { "enabled": true }, "validation": { "failOnMissing": false } } }, { "package": "@agent-detective/jira-adapter", "options": { "enabled": true, "mockMode": true } } ]}Running
Section titled “Running”pnpm run devUses tsx watch — auto-restarts on changes.
pnpm startRequires pnpm run build:app first.
End-to-end Jira webhook testing (tunnel, labels, smoke script): e2e/jira-manual-e2e.md.
Monorepo layout (pnpm + Turborepo)
Section titled “Monorepo layout (pnpm + Turborepo)”- Root
package.jsonis the main Fastify app (src/,test/). It is not a separate package underpackages/, but it depends on workspace packages viaworkspace:*. - Workspace packages live under
packages/*and an optional app package underapps/*(the documentation site is inapps/docs). All are listed inpnpm-workspace.yaml. Shared dependency versions use thecatalog:protocol defined in that file. - Dependency upgrades: Bump shared tools and runtime libraries in the
catalog:section ofpnpm-workspace.yaml, thenpnpm install, so every package that references"catalog:"for that name updates together. Dependencies that are not in the catalog (for example Astro or Tailwind underapps/, orpinounderpackages/observability) are upgraded in that package’s ownpackage.json. After any bump, runpnpm run build,pnpm test, andpnpm run lint. Usepnpm outdated -rto see newer versions across the workspace. pnpm run buildruns Turborepo (turbo run build) and builds every workspace package’sdist/. It does not bundle the root server by itself.pnpm run build:appruns tsup on the root entrypoint and writesdist/index.jsforpnpm start(runpnpm run buildfirst so workspace packages are built).pnpm run typecheckrunsturbo run typecheckfor packages andtsc --noEmitat the repo root forsrc/+test/.pnpm testrunsturbo run test(package tests, e.g.@agent-detective/jira-adapter, with^builddeps) then root tests with tsx ontest/**/*.test.ts.- npm publish is automated by release-please on merge of the Release PR (see publishing.md); do not publish manually from a dirty tree unless debugging.
- Turborepo cache: stored under
.turbo/at the repo root. To discard local task cache:rm -rf .turbo(orpnpm exec turbo daemon cleanif you use the daemon).pnpm run cleanruns each package’scleanscript (typicallyrm -rf dist) viaturbo run clean.
Workspace and tooling (detail)
Section titled “Workspace and tooling (detail)”pnpm-workspace.yaml lists only packages/* (the root app is not a subfolder package; it is the repo root with its own package.json).
turbo.json defines build, typecheck, lint, test, and clean with dependsOn: ["^build"] where needed so dependency packages build first.
tsup is used in packages for fast ESM + dts output; the root app uses tsup for build:app to emit dist/index.js.
| Command | Description |
|---|---|
pnpm run build | Build all workspace packages (Turbo, cached) |
pnpm run typecheck | turbo run typecheck + root tsc --noEmit |
pnpm run test | Package tests + root test/**/*.test.ts |
pnpm run clean | Each package’s clean (e.g. rm -rf dist) |
| Release PR merge | release-please tags and publishes agent-detective + @agent-detective/* (see publishing.md) |
Build order (conceptual): types and process-utils have no workspace deps; core and observability depend on types; plugins depend on types/core/process-utils as declared in their package.json. Turbo resolves the graph via ^build.
New package: create packages/<name>/ with package.json, tsup.config.ts, tsconfig.json extending the repo base, and list workspace deps as workspace:*. See a sibling package (e.g. packages/jira-adapter) as a template.
VS Code: point TypeScript at the workspace SDK:
{ "typescript.tsdk": "node_modules/typescript/lib", "typescript.enablePromptUseWorkspaceTsdk": true}Building
Section titled “Building”# Build all workspace packages (Turborepo, cached)pnpm run build
# Bundle the root server to dist/ (production entrypoint)pnpm run build:app
# TypeScript type checking (packages via Turbo + root tsc)pnpm run typecheck
# ESLint (all packages that define a lint script)pnpm run lint
# Remove dist/ in packages (turbo run clean)pnpm run cleanTesting
Section titled “Testing”# Run all testspnpm test
# Watch modepnpm run test:watchProject Structure
Section titled “Project Structure”Directorysrc/ Main application (TypeScript)
Directorycore/
- types.ts Re-exports from @agent-detective/types
- agent-runner.ts Executes prompts against AI agents
- queue.ts Task queuing (prevents parallel execution)
- process.ts Shell command execution
- plugin-system.ts Plugin loader & registry
- schema-validator.ts Plugin schema validation
Directoryagents/ AI agent integrations
- index.ts Agent registry
- opencode.ts
- claude.ts
- cursor.ts
- utils.ts
- server.ts Fastify server (+ Core API endpoints)
- index.ts Bootstrap
Directorypackages/ Workspace packages
Directorytypes/ @agent-detective/types
- …
Directorysdk/ @agent-detective/sdk
- …
Directoryobservability/ @agent-detective/observability
- …
Directoryprocess-utils/ @agent-detective/process-utils
- …
Directorylocal-repos-plugin/ @agent-detective/local-repos-plugin
- …
Directoryjira-adapter/ @agent-detective/jira-adapter
- …
Directorytest/ Main app tests
Directorycore/
- …
Directoryconfig/
- default.json Server configuration
Directorydocs/ Documentation
- …
Running Plugin Tests
Section titled “Running Plugin Tests”cd packages/jira-adapterpnpm testTesting Jira Adapter (mock vs real)
Section titled “Testing Jira Adapter (mock vs real)”When mockMode: false, set Jira credentials via config or JIRA_* env (see configuration.md).
Smoke tests: Agent harness — plugin / integration smoke (pnpm run jira:webhook-smoke, pnpm run ci:webhook-smoke). npm operators: agent-detective smoke — get started.
Debugging
Section titled “Debugging”Enable debug logging
Section titled “Enable debug logging”Set log level via observability in config or OBSERVABILITY_LOG_LEVEL / LOG_LEVEL (see observability.md).
Common Issues
Section titled “Common Issues”Creating a New Plugin
Section titled “Creating a New Plugin”For a complete plugin development guide, see plugins.md.
Plugin authors import everything from @agent-detective/sdk (types and runtime helpers). @agent-detective/types is host-internal:
import type { Plugin, PluginContext } from '@agent-detective/sdk';