Skip to content

Commit f838e20

Browse files
Merge pull request #16 from CodeSignal/codex/polish-documentation
docs: refactor docs and rebrand project to AgentFlow
2 parents 0cd2e18 + f3bda0f commit f838e20

19 files changed

Lines changed: 898 additions & 367 deletions

AGENTS.md

Lines changed: 59 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,82 @@
11
# Repository Guidelines
22

33
## Project Structure & Module Organization
4+
45
This repository is an npm workspace monorepo:
5-
- `apps/server`: Express API + Vite middleware integration (`src/index.ts`). Routes: `POST /api/run-stream` (SSE, primary), `POST /api/run` (batch JSON), `POST /api/resume` (approval resumption), `GET /api/config` (provider/model config), `GET /api/default-workflow` (optional startup workflow).
6-
- `apps/web`: Vite frontend for the workflow editor (`src/app/workflow-editor.ts`).
7-
- `packages/types`: Shared TypeScript contracts used by server, web, and engine.
8-
- `packages/workflow-engine`: Reusable workflow execution runtime.
9-
- `design-system/`: Git submodule with UI tokens/components consumed by the web app.
10-
- `data/runs/`: Runtime run snapshots (gitignored artifacts).
11-
- `.config/config.json`: Provider and model definitions served via `/api/config` (committed). `.config/default-workflow.json`: Optional startup workflow loaded by the editor on init (gitignored).
6+
7+
- `apps/server`: Express API + Vite middleware integration (`src/index.ts`).
8+
- `apps/web`: Vite frontend workflow editor (`src/app/workflow-editor.ts`).
9+
- `packages/types`: Shared TypeScript contracts.
10+
- `packages/workflow-engine`: Reusable workflow runtime.
11+
- `design-system/`: Git submodule with UI tokens/components.
12+
- `data/runs/`: Runtime run snapshots (gitignored).
13+
- `.config/config.json`: Provider/model definitions (committed).
14+
- `.config/default-workflow.json`: Optional startup workflow (gitignored).
15+
16+
Server routes:
17+
18+
- `POST /api/run-stream` (SSE run, primary)
19+
- `POST /api/run` (batch JSON run)
20+
- `POST /api/resume-stream` (SSE resume, primary)
21+
- `POST /api/resume` (batch JSON resume)
22+
- `GET /api/run/:runId` (active/persisted run fetch)
23+
- `GET /api/config` (provider/model config)
24+
- `GET /api/default-workflow` (optional startup workflow)
1225

1326
## Build, Test, and Development Commands
27+
1428
- `npm install`: Install all workspace dependencies.
1529
- `npm run dev`: Start integrated server + UI on `http://localhost:3000`.
1630
- `npm run dev:web`: Run frontend-only Vite dev server.
17-
- `npm run build`: Build shared packages, server, and web app.
18-
- `npm run lint`: Run ESLint for all TypeScript files.
19-
- `npm run typecheck`: Type-check server and web workspaces.
20-
- `npm test`: Run current repo test gate (`workflow-engine` + server typecheck scripts).
31+
- `npm run build`: Build server and web app.
32+
- `npm run build:packages`: Build shared packages.
33+
- `npm run lint`: Run ESLint.
34+
- `npm run typecheck`: Typecheck server and web workspaces.
35+
- `npm test`: Run repo test gate (`workflow-engine` + server typecheck scripts).
2136

2237
## Coding Style & Naming Conventions
23-
- Language: TypeScript across apps/packages, with `strict` mode enabled.
24-
- Use `import type` where applicable (`@typescript-eslint/consistent-type-imports` is enforced).
25-
- Keep unused parameters/locals prefixed with `_` to satisfy lint rules.
26-
- Match existing file naming patterns: kebab-case files (`openai-agents-llm.ts`), PascalCase classes, UPPER_SNAKE_CASE constants.
27-
- Follow existing indentation/style in each file; do not reformat unrelated code.
38+
39+
- Language: TypeScript with `strict` mode.
40+
- Use `import type` where applicable (`@typescript-eslint/consistent-type-imports`).
41+
- Prefix unused parameters/locals with `_`.
42+
- Naming patterns: kebab-case files, PascalCase classes, UPPER_SNAKE_CASE constants.
43+
- Avoid reformatting unrelated code.
2844

2945
## Testing Guidelines
30-
- Current CI checks in `.github/workflows/pr.yml`: `lint`, `build:packages`, `typecheck`, and `build`.
46+
47+
- CI checks in `.github/workflows/pr.yml`: `lint`, `build:packages`, `typecheck`, `build`.
3148
- Web workspace uses Vitest (`npm --workspace apps/web run test`).
32-
- When adding tests, prefer `*.test.ts` near the feature being tested.
33-
- No coverage threshold is currently enforced; focus on targeted tests for changed behavior.
49+
- Prefer targeted `*.test.ts` files near changed behavior.
3450

3551
## Commit & Pull Request Guidelines
36-
- Prefer short, imperative commit subjects. Existing history favors Conventional Commit prefixes like `feat(web): ...` and `fix: ...`.
52+
53+
- Prefer short, imperative commit subjects.
54+
- Conventional prefixes are common (`feat(web):`, `fix:`, `chore:`).
3755
- Keep commits scoped to one logical change.
38-
- PRs should include: purpose, risk/impact, linked issue (if any), and validation steps run locally.
39-
- For UI changes in `apps/web`, include screenshots or short recordings.
56+
- PRs should include purpose, risk/impact, and validation steps.
57+
- For UI changes in `apps/web`, include screenshots or recordings.
4058

4159
## Security & Configuration Tips
42-
- Set `OPENAI_API_KEY` in your shell before running agent workflows.
43-
- Never commit secrets, `.env` files, or generated run data from `data/runs/`.
60+
61+
- Set `OPENAI_API_KEY` before running agent workflows.
62+
- Never commit secrets, `.env` files, or generated data from `data/runs/`.
4463

4564
## Design System Policy
46-
- Treat `design-system/` (git submodule) as the source of truth for UI primitives.
47-
- Prefer existing tokens/components from the submodule before building custom UI in `apps/web`.
48-
- If a needed component does not exist in `design-system/`, pause and consult the user before adding a new component or introducing a non-design-system alternative.
49-
- In a brand new git worktree, initialize submodules before development (`git submodule update --init --recursive`), or the design-system assets will be missing.
65+
66+
- Treat `design-system/` as source of truth for UI primitives.
67+
- Prefer submodule tokens/components over custom alternatives.
68+
- If a needed component is missing in `design-system/`, consult user before adding alternatives.
69+
- In fresh worktrees, run `git submodule update --init --recursive`.
5070

5171
## Subagent Graph Rules
52-
- Subagent links are tool-delegation edges and do not represent execution flow edges.
53-
- Subagent hierarchies must remain acyclic (for example, `A -> B -> A` is invalid).
54-
- Subagent targets are tool-only nodes and cannot participate in regular execution edges.
72+
73+
- Links between agents and subagents are tool-delegation edges, not execution edges.
74+
- Hierarchies of subagents must remain acyclic.
75+
- Targets of subagent links are tool-only and cannot participate in regular execution edges.
76+
77+
## Additional Documentation
78+
79+
- `docs/README.md`
80+
- `docs/api.md`
81+
- `docs/workflow-semantics.md`
82+
- `apps/web/docs/run-readiness.md`

CLAUDE.md

Lines changed: 71 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,113 +1,106 @@
11
# CLAUDE.md
22

3-
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
3+
This file provides guidance to Claude Code when working in this repository.
44

55
## Project Overview
66

7-
Visual workflow builder for agentic LLM pipelines. Users drag-and-drop nodes (Start, Agent, If/Else, Approval) onto a canvas, connect them, configure LLM prompts and branching logic, then execute workflows server-side against OpenAI. Run results are persisted as JSON audit trails.
7+
AgentFlow is a visual workflow editor and runtime for LLM pipelines.
88

9-
## Monorepo Layout
9+
Users compose workflows with `Start`, `Agent`, `Condition`, and `Approval` nodes, then execute server-side with persisted run records.
10+
In the UI, `Condition` maps to runtime node type `"if"` in workflow JSON and persisted run records.
1011

11-
npm workspace monorepo:
12+
## Monorepo Layout
1213

1314
| Package | Purpose |
14-
|---------|---------|
15-
| `packages/types` | Shared TypeScript contracts (`WorkflowNode`, `WorkflowGraph`, `WorkflowRunResult`, etc.) |
16-
| `packages/workflow-engine` | Pure runtime executor (`WorkflowEngine` class, `WorkflowLLM` interface) — no OpenAI dependency |
17-
| `apps/server` | Express API + Vite dev middleware. Routes: `POST /api/run`, `POST /api/run-stream`, `POST /api/resume`, `GET /api/config`, `GET /api/default-workflow` |
18-
| `apps/web` | Vite SPA — `WorkflowEditor` class handles canvas, node palette, and run console |
19-
| `design-system/` | Git submodule (CodeSignal DS) — CSS tokens and components consumed by web app |
15+
| --- | --- |
16+
| `packages/types` | Shared TypeScript contracts (`WorkflowGraph`, `WorkflowRunResult`, etc.) |
17+
| `packages/workflow-engine` | Runtime executor (`WorkflowEngine`, `WorkflowLLM`) |
18+
| `apps/server` | Express API + Vite middleware/static hosting |
19+
| `apps/web` | Vite SPA editor (`WorkflowEditor`) |
20+
| `design-system/` | Git submodule for UI foundations/components |
21+
22+
## API Surface
23+
24+
- `POST /api/run-stream`
25+
- `POST /api/run`
26+
- `POST /api/resume-stream`
27+
- `POST /api/resume`
28+
- `GET /api/run/:runId`
29+
- `GET /api/config`
30+
- `GET /api/default-workflow`
2031

2132
## Common Commands
2233

2334
```bash
24-
npm install # Install all workspace deps
25-
npm run dev # Start integrated server+UI on http://localhost:3000
26-
npm run build # Build packages → server → web (production)
27-
npm run lint # ESLint across all TypeScript
28-
npm run typecheck # tsc --noEmit for server and web
29-
npm test # Run workflow-engine + server tests
30-
31-
# Workspace-specific
32-
npm --workspace apps/web run test # Vitest for web
33-
npm --workspace packages/workflow-engine run test # Engine tests
34-
npm run build:packages # Build only shared packages (types + engine)
35+
npm install
36+
npm run dev
37+
npm run build
38+
npm run build:packages
39+
npm run lint
40+
npm run typecheck
41+
npm test
42+
43+
npm --workspace apps/web run test
3544
```
3645

37-
## Architecture
38-
39-
**Request flow (streaming):** Browser (`api.ts` `runWorkflowStream`) → `POST /api/run-stream``WorkflowEngine.run()` with `onLog` callback → each `WorkflowLogEntry` is streamed to the client as an SSE event → final result persisted to `data/runs/run_<id>.json``done` event sent to close stream. This is the primary run path — the UI renders agent responses progressively as they arrive.
40-
41-
**Request flow (batch):** `POST /api/run` runs the same engine synchronously and returns the full `WorkflowRunResult` as JSON. Still available but not used by the default UI.
42-
43-
**Approval/pause flow:** When engine hits an Approval node, it sets `waitingForInput=true` and the engine instance is stored in an in-memory `Map` (`store/active-workflows.ts`). Client calls `POST /api/resume` with user input to continue.
46+
## Architecture Notes
4447

45-
**Agent backend:** Server agent execution is implemented through OpenAI Agents SDK (`apps/server/src/services/openai-agents-llm.ts`). Agent runs are capped with `maxTurns: 20` to bound loop iterations.
48+
## Execution path
4649

47-
**Subagent hierarchy:** Agent nodes may expose other agent nodes as tools through subagent links. These links are not execution-flow edges. The subagent graph must be acyclic, and subagent targets are tool-only (no regular execution edges).
50+
Primary path is streaming:
4851

49-
**Build dependency chain:** `packages/types``packages/workflow-engine``apps/server` / `apps/web`. Always run `build:packages` before typechecking or building apps.
52+
`apps/web` -> `POST /api/run-stream` -> `WorkflowEngine.run()` -> SSE log events -> persisted run record -> final `done` event.
5053

51-
## Design System (Git Submodule)
54+
Resume follows equivalent streaming path through `POST /api/resume-stream`.
5255

53-
`design-system/` is a CodeSignal design system git submodule. It is the **source of truth** for all UI primitives — always prefer existing DS tokens and components over custom CSS or new UI elements. If a needed component doesn't exist in the DS, consult the user before adding alternatives.
56+
## Persistence
5457

55-
### Token layers
58+
Each run/resume operation persists `data/runs/run_<runId>.json` with:
5659

57-
Tokens live in three foundation files linked as static CSS in `apps/web/index.html`:
60+
- workflow graph
61+
- logs
62+
- status
63+
- state snapshot
64+
- `currentNodeId`
65+
- `waitingForInput`
5866

59-
- **Colors** (`colors/colors.css`): Two-tier system — base scales (`--Colors-Base-Primary-700`) and semantic names (`--Colors-Backgrounds-Main-Default`, `--Colors-Text-Body-Strong`, `--Colors-Stroke-Default`, etc.). Dark mode is automatic via `@media (prefers-color-scheme: dark)`.
60-
- **Spacing** (`spacing/spacing.css`): Spacing scale `--UI-Spacing-spacing-{none|min|xxs|xs|s|mxs|ms|m|ml|mxl|l|xl|xxl|xxxl|4xl|max}`, border radii `--UI-Radius-radius-{size}`, and input heights `--UI-Input-{min|xs|sm|md|lg}`.
61-
- **Typography** (`typography/typography.css`): Font families (`--body-family`, `--heading-family`, `--code-family`), size variables (`--Fonts-Body-Default-md`), and utility classes (`.body-small`, `.heading-xxxsmall`, `.label-small`, `.code`).
67+
## Paused-run restoration
6268

63-
### Component CSS + JS
69+
On server startup, paused runs are rehydrated into in-memory active workflow map when restore fields are present.
6470

65-
Component CSS is loaded statically in `index.html` (button, boxes, dropdown, icons, input, modal, split-panel, tags). Interactive components with JS (Dropdown, Modal, SplitPanel) are **lazy-loaded at runtime** via dynamic `import()` from the submodule path:
71+
## Subagent hierarchy
6672

67-
```typescript
68-
// Pattern used in workflow-editor.ts
69-
const mod = await import(`${origin}/design-system/components/dropdown/dropdown.js`);
70-
const DropdownCtor = mod.default;
71-
const dropdown = new DropdownCtor(container, { items, selectedValue, onSelect });
72-
```
73-
74-
Components currently used in the web app:
75-
- **SplitPanel** — main layout (canvas left, run console right). Constructor: `new SplitPanel(el, { initialSplit, minLeft, minRight })`.
76-
- **Dropdown** — model and reasoning-effort selectors. Constructor: `new Dropdown(el, { items, selectedValue, placeholder, width, onSelect })`.
77-
- **Modal** — help dialog, confirmation prompts. Constructor: `new Modal({ size, title, content, footerButtons })`. Also `Modal.createHelpModal()` factory.
78-
- **Button** — pure CSS (`.button .button-primary`, `.button-secondary`, `.button-danger`, sizes via `.button-small`/`.button-xsmall`).
79-
- **Input** — pure CSS (`.input` for text/number, `.input-checkbox` / `.input-radio` with wrapper structure).
80-
81-
### Styling rules for the web app
73+
Subagent links are tool-delegation edges (`sourceHandle: "subagent"`), not execution edges. Hierarchy must be acyclic and subagent targets are tool-only nodes.
8274

83-
`apps/web/src/workflow-editor.css` consumes DS tokens throughout. When writing new CSS:
84-
- Use semantic color tokens (`--Colors-Backgrounds-Main-Top`, `--Colors-Stroke-Default`) rather than base scales or raw hex values.
85-
- Use spacing tokens (`--UI-Spacing-spacing-s`) instead of hardcoded pixel values.
86-
- Use radius tokens (`--UI-Radius-radius-xs`) for border-radius.
87-
- Use typography variables/classes (`--body-family`, `.body-small`) for font styling.
75+
## Design System
8876

89-
## Coding Conventions
77+
`design-system/` is a git submodule and source of truth for UI primitives.
9078

91-
- TypeScript strict mode everywhere. Use `import type` (enforced by `@typescript-eslint/consistent-type-imports`).
92-
- File naming: kebab-case. Classes: PascalCase. Constants: UPPER_SNAKE_CASE.
93-
- Prefix unused parameters with `_`.
94-
- Tests: `*.test.ts` co-located near the feature. Vitest for web, CI runs lint → build:packages → typecheck → build.
95-
- Commits: short imperative subjects, Conventional Commit prefixes (`feat(web):`, `fix:`, `chore:`).
79+
- CSS tokens/components are linked in `apps/web/index.html`.
80+
- Interactive DS components are dynamically imported in `workflow-editor.ts`.
81+
- `apps/web/public/design-system` is a symlink to root submodule.
9682

97-
## Local Configuration (`.config/`)
83+
Initialize submodule in fresh worktrees:
9884

99-
The `.config/` directory holds developer-local files that are partially gitignored:
85+
```bash
86+
git submodule update --init --recursive
87+
```
10088

101-
- **`config.json`** *(committed)* — provider and model definitions. The server serves this via `GET /api/config`; the web app loads it on startup to populate the model and reasoning-effort dropdowns. Structure: `{ providers: [{ id, name, enabled, models: [{ id, name, reasoningEfforts[] }] }] }`.
102-
- **`default-workflow.json`** *(gitignored)* — optional startup workflow. If present, the editor loads it instead of the blank Start node. Same `{ nodes, connections }` shape as a run record's `workflow` field.
89+
## Configuration
10390

104-
Agent node `userPrompt` fields support `{{PREVIOUS_OUTPUT}}` as a template token, which is substituted with the previous node's output before the LLM is called.
91+
- `OPENAI_API_KEY`: required for agent-node execution.
92+
- `PORT`: server port (default `3000`).
93+
- `PROJECT_ROOT`: optional root override.
94+
- `.config/config.json`: provider/model config served by API.
95+
- `.config/default-workflow.json`: optional startup workflow (gitignored).
10596

106-
## Environment
97+
## References
10798

108-
- Requires Node.js 20+.
109-
- `OPENAI_API_KEY` must be exported in your shell for Agent node execution.
110-
- `data/runs/` is gitignored — created automatically at runtime.
111-
- `.config/default-workflow.json` is gitignored — create it locally to preload a workflow on startup.
112-
- Clone with `--recurse-submodules` to pull the design-system submodule.
113-
- In a brand new git worktree, run `git submodule update --init --recursive` before development so the design-system submodule is available.
99+
- `docs/README.md`
100+
- `docs/architecture.md`
101+
- `docs/api.md`
102+
- `docs/workflow-semantics.md`
103+
- `docs/run-persistence.md`
104+
- `docs/configuration.md`
105+
- `docs/troubleshooting.md`
106+
- `apps/web/docs/run-readiness.md`

0 commit comments

Comments
 (0)