Skip to content

Commit cd229fc

Browse files
committed
feat(cli): unify roboppi CLI and add e2e tests
1 parent 97151b2 commit cd229fc

65 files changed

Lines changed: 6286 additions & 1048 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/ci.yml‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
checks:
9+
runs-on: ubuntu-latest
10+
timeout-minutes: 30
11+
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
16+
- name: Setup Bun
17+
uses: oven-sh/setup-bun@v2
18+
with:
19+
bun-version: "1.3.8"
20+
21+
- name: Install dependencies
22+
run: bun install --frozen-lockfile
23+
24+
- name: Run CI checks
25+
run: make test-all

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ dist
33
*.tsbuildinfo
44
.DS_Store
55
/agentcore
6+
/roboppi
67

78
# Local AgentCore workflow state
89
.agentcore-loop/

‎AGENTS.md‎

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
# AGENTS.md
2+
3+
This repository ("Roboppi" / package name: `agentcore`) is a Bun + TypeScript (ESM)
4+
codebase that implements an execution-control runtime for agentic workers.
5+
6+
## Build / Lint / Test
7+
8+
Prefer `make` targets (CI uses them), but `bun` equivalents work.
9+
10+
### Install
11+
12+
```bash
13+
bun install
14+
bun install --frozen-lockfile # CI
15+
```
16+
17+
CI currently uses Bun 1.3.8 (see `.github/workflows/ci.yml`).
18+
19+
### Typecheck (acts as "lint")
20+
21+
There is no ESLint/Prettier/Biome config today; use TypeScript strict checks + tests.
22+
23+
```bash
24+
make typecheck
25+
# or
26+
bun run typecheck
27+
```
28+
29+
### Tests
30+
31+
```bash
32+
make test # bun test
33+
make test-unit # bun test test/unit
34+
make test-integration # bun test test/integration
35+
make test-at # bun test tests/at
36+
make test-branch # bash tests/branch/run-branch-verification.sh
37+
make test-all # CI: typecheck + test + test-branch
38+
```
39+
40+
Acceptance test helper runner:
41+
42+
```bash
43+
bash scripts/run-at.sh # typecheck + tests/at
44+
bash scripts/run-at.sh --full # + bun test
45+
```
46+
47+
### Run A Single Test
48+
49+
```bash
50+
bun test test/unit/ipc/protocol.test.ts
51+
bun test test/unit/ipc/protocol.test.ts -t "routes submit_job" # regex on test name
52+
bun test -t "routes submit_job" # match across all tests
53+
bun test --only # only test.only/describe.only
54+
bun test --timeout 20000 test/integration # per-test timeout (ms)
55+
bun test --watch test/unit # watch mode
56+
```
57+
58+
### Build
59+
60+
Builds a native executable `./agentcore` (gitignored).
61+
62+
```bash
63+
make build # or: bun run build
64+
make install # /usr/local/bin/agentcore
65+
make uninstall
66+
```
67+
68+
### Dev / Run
69+
70+
```bash
71+
make dev # bun run src/cli.ts
72+
bun run dev # bun run src/index.ts
73+
bun run dev:scheduler # bun run src/scheduler/index.ts
74+
```
75+
76+
## Project Layout (high-level)
77+
78+
- Runtime entrypoints: `src/cli.ts` (bin), `src/index.ts` (Core process)
79+
- Core safety mechanisms: `src/core/**`
80+
- IPC JSONL protocol/transport: `src/ipc/**`
81+
- Daemon entrypoints: `src/daemon/**`
82+
- Worker adapters + process mgmt: `src/worker/**`
83+
- Workflow runner/executor: `src/workflow/**`
84+
- Scheduler layer: `src/scheduler/**`
85+
- Design notes: `docs/**`
86+
- Unit/integration tests: `test/**`
87+
- Acceptance + branch-safety tests: `tests/**`
88+
89+
## Code Style Guidelines
90+
91+
### TypeScript / Module System
92+
93+
- ESM everywhere (`package.json` has `"type": "module"`).
94+
- Relative imports for local modules MUST include the `.js` extension.
95+
- Example: `import { AgentCore } from "./core/agentcore.js";`
96+
- Use `node:` specifiers for built-in modules.
97+
- Example: `import { readFile } from "node:fs/promises";`
98+
- Use `import type { ... }` for type-only imports.
99+
- Avoid the `@/*` path alias unless you confirm runtime resolution; prefer relative imports.
100+
101+
### Formatting
102+
103+
- 2-space indentation, semicolons, trailing commas in multiline constructs.
104+
- Keep changes minimal: no repo-wide reformatting sweeps (no formatter is enforced).
105+
106+
### Imports
107+
108+
- No enforced ordering; keep import groups consistent within the file you touch.
109+
- Keep `import ...` statements at the top of the file.
110+
- Prefer `../types/index.js` barrel exports for shared types/enums.
111+
- Avoid default exports for local modules; use named exports (existing pattern).
112+
113+
### Types
114+
115+
- `tsconfig.json` is strict (`noUncheckedIndexedAccess`, `noUnusedLocals/Parameters`, etc.).
116+
- Avoid `any` in `src/**`.
117+
- Use `unknown` in `catch` and narrow via `instanceof Error`, `typeof`, etc.
118+
- Add explicit return types for exported functions and public class methods.
119+
- Prefer small discriminated unions / string enums for protocol/state machines.
120+
121+
### Naming
122+
123+
- Files: `kebab-case.ts` (e.g., `json-lines-transport.ts`).
124+
- Classes/types/interfaces/enums: `PascalCase`.
125+
- Functions/locals: `camelCase`.
126+
- Constants: `SCREAMING_SNAKE_CASE`.
127+
- IDs are UUID strings: use `generateId()` / `crypto.randomUUID()`.
128+
129+
### Error Handling
130+
131+
- Throw `Error` (or subclasses), never strings.
132+
- Set `err.name` on custom error classes; attach `cause` when useful.
133+
- When surfacing errors across boundaries (IPC/worker/workflow), include context: `requestId`, `jobId`, `permitId`, `stepId`.
134+
- Use `ErrorClass` for retryability when returning `WorkerResult`-style failures.
135+
136+
### Cancellation / Timeouts / Cleanup
137+
138+
- If a function can block (IO, process spawn, long loop), accept an `AbortSignal`
139+
and stop promptly when aborted.
140+
- Always clear timers and remove event listeners in `finally` blocks.
141+
- When spawning subprocesses, prefer `ProcessManager` (abort, timeout, best-effort process-group termination).
142+
143+
### IPC Safety
144+
145+
- IPC is JSON Lines over stdout. In server/Core mode, NEVER write non-JSON to stdout (use stderr/loggers).
146+
- Validate message shape before acting (see `src/ipc/protocol.ts`).
147+
148+
### Tests
149+
150+
- Use `bun:test` (`describe`, `test`/`it`, `expect`).
151+
- Keep tests deterministic; avoid network and real worker CLIs in unit tests.
152+
- Use temp dirs for filesystem work; clean up after.
153+
154+
## Cursor / Copilot Rules
155+
156+
- No `.cursor/rules/`, `.cursorrules`, or `.github/copilot-instructions.md` found in this repo.

‎Makefile‎

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,62 @@
1-
.PHONY: all build test test-unit test-integration test-at test-all typecheck clean help
21

3-
BIN := agentcore
2+
.PHONY: all build test tests test-unit test-integration test-at test-branch test-all typecheck clean install uninstall dev help
3+
4+
BIN := roboppi
5+
LEGACY_BIN := agentcore
6+
7+
# Legacy build artifacts (no longer built by default)
8+
EXTRA_BINS := roboppi-core roboppi-workflow roboppi-daemon
9+
410
SRC := src/cli.ts
511

12+
# Allow passing Bun runtime flags (e.g. BUN_FLAGS=--smol)
13+
BUN ?= bun
14+
BUN_FLAGS ?=
15+
16+
# Extra flags passed to `bun build` (e.g. BUN_BUILD_FLAGS=--compile-exec-argv=--smol)
17+
BUN_BUILD_FLAGS ?=
18+
619
all: build ## Build the binary (default)
720

8-
build: ## Build single binary
9-
bun build --compile $(SRC) --outfile $(BIN)
21+
build: ## Build a single binary (roboppi)
22+
$(BUN) $(BUN_FLAGS) build $(BUN_BUILD_FLAGS) --compile $(SRC) --outfile $(BIN)
23+
@ln -sf $(BIN) $(LEGACY_BIN) 2>/dev/null || cp $(BIN) $(LEGACY_BIN)
1024

1125
test: ## Run all tests
12-
bun test
26+
$(BUN) $(BUN_FLAGS) test
27+
28+
tests: test ## Alias for `make test`
1329

1430
test-unit: ## Run unit tests only
15-
bun test test/unit
31+
$(BUN) $(BUN_FLAGS) test test/unit
1632

1733
test-integration: ## Run integration tests only
18-
bun test test/integration
34+
$(BUN) $(BUN_FLAGS) test test/integration
1935

2036
test-at: ## Run acceptance tests only
21-
bun test tests/at
37+
$(BUN) $(BUN_FLAGS) test tests/at
38+
39+
test-branch: ## Run branch safety verification tests
40+
bash tests/branch/run-branch-verification.sh
2241

23-
test-all: typecheck test ## Run type check + all tests
42+
test-all: typecheck test test-branch ## Run type check + all tests
2443
@echo "All checks passed"
2544

2645
typecheck: ## Run TypeScript type checker
27-
bun x tsc --noEmit
46+
$(BUN) $(BUN_FLAGS) x tsc --noEmit
2847

2948
clean: ## Remove build artifacts
30-
rm -f $(BIN)
49+
rm -f $(BIN) $(LEGACY_BIN) $(EXTRA_BINS)
3150

3251
install: build ## Install binary to /usr/local/bin
3352
install -m 755 $(BIN) /usr/local/bin/$(BIN)
53+
@ln -sf /usr/local/bin/$(BIN) /usr/local/bin/$(LEGACY_BIN) 2>/dev/null || cp /usr/local/bin/$(BIN) /usr/local/bin/$(LEGACY_BIN)
3454

3555
uninstall: ## Remove binary from /usr/local/bin
36-
rm -f /usr/local/bin/$(BIN)
56+
rm -f /usr/local/bin/$(BIN) /usr/local/bin/$(LEGACY_BIN) $(addprefix /usr/local/bin/,$(EXTRA_BINS))
3757

3858
dev: ## Run in dev mode (no build)
39-
bun run $(SRC)
59+
$(BUN) $(BUN_FLAGS) run $(SRC)
4060

4161
help: ## Show this help
4262
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-18s\033[0m %s\n", $$1, $$2}'

0 commit comments

Comments
 (0)