This document maps the main parts of the gajae-code repository. The root README stays intentionally small; this file is the architecture-oriented companion.
Gajae-Code (gjc) is centered on packages/coding-agent/. The public workflow surface is intentionally fixed at four source-bundled skills and four public role subagents. Runtime state, specs, plans, goals, team state, and local overrides live under .gjc/.
Default workflow skills are embedded from:
packages/coding-agent/src/defaults/gjc/skills/<name>/SKILL.md
Public role subagent prompts are embedded from:
packages/coding-agent/src/prompts/agents/<role>.md
The runtime can still discover project/user overrides, but the bundled defaults are loaded from source so a missing project .gjc directory does not remove the default workflow surface.
Main gjc CLI and product runtime.
packages/coding-agent/package.jsonexposes thegjcbinary atsrc/cli.tsand the SDK/barrel entrypoint atsrc/index.ts.packages/coding-agent/src/cli.tsis the executable bootstrap. It registers CLI commands such assetup,deep-interview,ralplan,ultragoal,team, and the default launch path.packages/coding-agent/src/main.tsadapts CLI options into session creation and dispatches interactive, print, and ACP modes; external machine clients use the SDK WebSocket interface.packages/coding-agent/src/sdk/session.tsassembles settings, model registry, auth, workspace/context discovery, skills, rules, tools, system prompt, and the underlying@gajae-code/agent-coreagent.packages/coding-agent/src/tools/index.tsis the built-in tool registry for file/code/runtime tools such as read, bash, edit, AST tools, eval, find/search, LSP, browser, task/subagent, recipe, IRC, todo, web search, and write. Memory backends are private integrations, not public coding-harness tools.packages/coding-agent/src/defaults/gjc-defaults.tsembeds and installs the default workflow skills.packages/coding-agent/src/task/agents.tsembeds bundled task-agent prompts. The public contract isexecutor,architect,planner, andcritic; other bundled prompts are internal/runtime utilities.packages/coding-agent/src/coordinator/contract.tsdefines the transport-neutral third-party coordinator contract used bygjc mcp-serve coordinator,gjc coordinator, andgjc setup hermes.packages/coding-agent/src/coordinator-mcp/server.tsimplements the outward MCP adapter for bot/coordinator integrations, including session start/register, turn state, question answering, status reports, and artifact reads.docs/external-control-readiness.mdclassifies the public external-control surfaces: SDK WebSocket for live session control, Coordinator MCP for multi-session control planes, and ACP for editor/ACP clients.docs/bot-integration.mdis the end-to-end guide for external controller authors.
Provider/model boundary for LLM access.
packages/ai/src/index.tsexports model registry/resolution, provider implementations, auth broker/gateway/storage, streaming, usage, retry/overflow utilities, OAuth, discovery, and validation helpers.packages/ai/src/types.tsdefines provider, model, context, message, tool, usage, reasoning, and stream-event contracts.packages/ai/src/stream.tsdispatches model-driven streams to the right provider/API implementation and normalizes streaming events.packages/ai/src/model-manager.tsmerges static, cached, dynamic, and remote model sources.packages/ai/README.mddocuments tool calling, partial streaming tool calls, thinking/reasoning, provider configuration, context handoff, and OAuth flows.
Stateful agent runtime built on @gajae-code/ai.
packages/agent/src/index.tsexports theAgent, loop APIs, append-only context, compaction, telemetry, proxy utilities, thinking helpers, and shared types.packages/agent/src/agent-loop.tsowns the turn loop: transform context, call the model stream, execute tool calls, append tool results, and emit lifecycle events.packages/agent/src/agent.tswraps the loop with mutable state, subscriptions, prompt/continue/abort APIs, queues, provider session state, telemetry, and state mutation helpers.packages/agent/src/types.tsdefinesAgentMessage,AgentTool, loop config, event, and runtime state contracts.
Terminal UI framework used by the CLI.
packages/tui/src/index.tsexports components, keybindings, autocomplete, terminal abstractions, image support, TUI core, and utilities.packages/tui/src/tui.tsmanages component rendering, focus, overlays, terminal dimensions, diff state, and synchronized output.packages/tui/src/terminal.tsabstracts terminal lifecycle, dimensions, cursor controls, title/progress, Kitty protocol state, and appearance notifications.packages/tui/README.mddocuments the component model and built-in components such as text, input, editor, markdown, loaders, select/settings lists, spacer, image, box, and container.
Native helper layer exposed through N-API.
packages/natives/package.jsonexportsnative/index.jsand generated TypeScript definitions.packages/natives/native/loader-state.jsresolves platform/CPU-specific native binaries and validates package/native version alignment.crates/pi-natives/src/lib.rsis the N-API root for appearance, AST search/editing, clipboard, filesystem scan/cache, grep/glob, syntax highlighting, HTML-to-Markdown, keyboard parsing, process/PTY/shell support, SIXEL, code summarization, text measurement/wrapping/truncation, workspace scanning, power assertions, and isolation helpers.crates/pi-shell/src/lib.rsexposes brush-based shell execution primitives used by the native shell adapter.crates/pi-shell/src/shell.rsimplements persistent and one-shot shell execution, streaming, environment handling, cancellation, and output minimizer telemetry.crates/pi-shell/src/fixup.rsperforms conservative AST-based bash command fixups.crates/pi-natives/src/pty.rsimplements interactive PTY sessions.
Shared TypeScript utilities.
packages/utils/src/index.tsexports abortable/async helpers, color/env/dir utilities, fetch retry, formatting, frontmatter, glob helpers, JSON helpers, logging, MIME detection, prompt rendering, process-tree helpers, sanitization, streams, temp files, tab spacing, type guards, and executable lookup.packages/utils/src/ptree.tsandpackages/utils/src/procmgr.tswrap native process helpers for ergonomic TypeScript use.
Local observability dashboard for session and model usage.
packages/stats/src/index.tsexposes thegjc-statsCLI entrypoint and exports aggregation/server APIs.packages/stats/src/aggregator.tsparses session-derived request metrics and writes aggregated data through SQLite.packages/stats/src/server.tsserves local dashboard API routes and static SPA assets.packages/stats/src/types.tsandpackages/stats/src/shared-types.tsdefine dashboard and aggregate metric shapes.
Private benchmark package for TypeScript edit tasks.
packages/typescript-edit-benchmark/package.jsonexposestypescript-edit-benchmarkand depends on the coding-agent, agent-core, ai, tui, utils, diff, prettier, and Babel tooling.packages/typescript-edit-benchmark/src/index.tsis the benchmark CLI: it resolves fixtures, loads tasks, runs edit attempts, records progress, and writes reports/conversation dumps underruns/.
External machine clients use the SDK WebSocket interface documented in docs/sdk.md. Coordinator MCP supplies multi-session orchestration, while ACP remains the stdio editor protocol. The former Python RPC client and bot integration paths were removed with the RPC ingress mode.
A normal CLI session starts in packages/coding-agent/src/cli.ts, routes through command handling, then reaches packages/coding-agent/src/main.ts. main.ts converts CLI/runtime settings into CreateAgentSessionOptions and calls createAgentSession() in packages/coding-agent/src/sdk/session.ts.
The SDK builds the session context, loads the default skills, creates built-in tools, resolves model/auth state through @gajae-code/ai, constructs the system prompt, and instantiates @gajae-code/agent-core. The agent loop streams model events, executes tools, records tool results, and hands state back to the selected interactive TUI, print, or ACP mode while exposing external control through the SDK WebSocket interface.
Package-local checks are defined in each package.json. For workflow-definition or default-surface changes, the focused gates are:
bun scripts/check-visible-definitions.ts
bun scripts/verify-g002-gates.ts
bun scripts/rebrand-inventory.ts --strict
bun test packages/coding-agent/test/default-gjc-definitions.test.tsFor broader TypeScript verification, use the root script:
bun run check:tsDo not use tsc or npx tsc directly in this repository.