Development

How to build, test, and contribute to AgentGem.

Prerequisites

Build, run, test

pnpm install
pnpm build      # tsc -b, then copies the UI into dist/
pnpm start      # node dist/index.js  (UI /, Explorer /explorer, MCP /mcp)
pnpm dev        # build + start in one step
pnpm test       # tsc -b && vitest run
pnpm clean      # rm -rf dist *.tsbuildinfo

Why the build is compiled, not transpiled

AgentBack defines REST endpoints and MCP tools with decorators (@api, @get, @post, @mcpServer, @tool). The framework reads decorator metadata at runtime, so tsconfig.json sets experimentalDecorators: true and emitDecoratorMetadata: true (with useDefineForClassFields: false for legacy-decorator compatibility). You must compile with tsc -b — a transpile-only path that drops decorator metadata will fail at runtime. The build is incremental (.tsbuildinfo).

Tests run against dist/

vitest.config.ts includes dist/**/__tests__/**/*.test.js — tests run against the compiled output, not the .ts source. Consequences:

The suite covers the core thoroughly: the pipeline (introspect, redact, buildGem, archive, archiveFs, archiveTar), targets, the registry (publish/resolve/merge/install), deploy and deploy records, testbed flavors, run, credentials, the MCP proxy, and TOML.

Code organization conventions

Concurrent sessions

Use a dedicated git worktree per session so branches and build artifacts (dist/, tsconfig.tsbuildinfo) don't collide (see CLAUDE.md):

git worktree add ../agentgem-<task> -b <task>
# … work …
git worktree remove ../agentgem-<task>

Diagrams

The docs diagrams live in docs/diagrams/ in three formats per diagram:

If you edit a diagram, update the .svg and re-render the .png.