Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 22 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
name: CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
- run: bun install
- run: bun test
- run: bun run build

docker:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- name: Build Docker image
run: docker build -t agentswarm/agentswarm:latest .
name: CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
- run: bun install
- run: bun lint
- run: bun format --check
Comment on lines +10 to +11

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Confirm workflow commands and available package scripts
rg -n "bun lint|bun format --check" .github/workflows/ci.yml
jq -r '.scripts // {}' package.json

Repository: raynr7/agentswarp

Length of output: 262


Add missing lint and format scripts to package.json before the CI workflow will pass.

The workflow at lines 10-11 invokes bun lint and bun format --check, but neither script is defined in package.json. This will cause CI to fail immediately. Either add these scripts to package.json or remove the corresponding workflow steps.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/ci.yml around lines 10 - 11, CI invokes "bun lint" and
"bun format --check" but package.json lacks "lint" and "format" scripts; add
"lint" and "format" script entries to package.json (e.g., map "lint" to your
linter command and "format" to your formatter/check command) so "bun lint" and
"bun format --check" succeed, or alternatively remove the "run: bun lint" and
"run: bun format --check" steps from the workflow if you don't want those checks
enforced; update the package.json scripts section and ensure the commands
referenced by "lint" and "format" match your tooling.

- run: bun test
- run: bun run build

docker:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- name: Build Docker image
run: docker build -t agentswarm/agentswarm:latest .
36 changes: 36 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,37 @@
# Dependencies
node_modules/

# Build output
dist/
.next/
.svelte-kit/
build/

# Environment — never commit secrets
.env
.env.local
.env.*.local

Comment on lines +11 to +14

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Broaden env-file ignores to avoid accidental secret commits.

Line 11–Line 14 only cover local variants; files like .env.production are still committable. Prefer a broad ignore with explicit allowlist for examples.

🔧 Suggested update
-# Environment — never commit secrets
-.env
-.env.local
-.env.*.local
+# Environment — never commit secrets
+.env*
+!.env.example
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.gitignore around lines 11 - 14, Update the .gitignore to broadly ignore
environment files by adding a general pattern that covers all env variants
(e.g., .env*) while explicitly allow-listing example/sample files (e.g.,
.env.example, .env.sample) so that secrets like .env.production cannot be
committed but documentation/example env files remain tracked.

# Database files
*.db
*.db-shm
*.db-wal
data/

# Logs
*.log
npm-debug.log*
bun-debug.log*

# OS
.DS_Store
Thumbs.db

# Editor
.vscode/
.idea/
*.swp
*.swo

# Vercel
.vercel
165 changes: 165 additions & 0 deletions AGENTS-IMPROVEMENT-SPEC.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
# AGENTS.md Improvement Spec

This document records the audit findings and the concrete changes made or required to bring agent guidance up to a useful standard.

---

## Audit Summary

### What exists

| Artifact | Location | Quality |
|----------|----------|---------|
| `AGENTS.md` | — | **Missing** (created in this session) |
| Agent skill files (`.ona/skills/`, `.cursor/rules/`) | — | **Missing** |
| `CONTRIBUTING.md` | `/CONTRIBUTING.md` | Good baseline; lacks agent-specific detail |
| `README.md` | `/README.md` | Good user-facing overview; not agent-oriented |
| `swarm-core.md` | `/swarm-core.md` | Phase 2 code reference dump; not structured guidance |
| `docs/` | `/docs/` | Two useful docs (`how-it-works.md`, `tools.md`); no index |
| `.devcontainer/devcontainer.json` | `/.devcontainer/` | Uses heavy universal image; no Bun feature pinned |
| `.gitignore` | `/.gitignore` | Only contains `.vercel` — critically incomplete |
| CI (`ci.yml`) | `.github/workflows/` | Functional but no lint step |
| PR template | `.github/PULL_REQUEST_TEMPLATE.md` | Good |

---

## What Is Good

- **CONTRIBUTING.md** covers setup, code style, PR process, and community links clearly.
- **PR template** is well-structured with a type-of-change checklist and a 512 MB RAM reminder.
- **Issue templates** (bug + feature) are thorough and include environment fields.
- **docs/how-it-works.md** explains the ReAct loop with a clear ASCII diagram.
- **docs/tools.md** lists all 14 tools with required env vars — useful for agents adding integrations.
- **CI** runs install + test + build on every push/PR, and builds Docker on `main`.
- **`.env.example`** documents all env vars with comments.

---

## What Is Missing

### 1. `AGENTS.md` — created in this session
No file existed to orient AI coding agents. Created at `/AGENTS.md` covering:
- Repo structure map
- Tech stack table
- Dev commands
- Code conventions
- Architecture constraints (memory budget, step limit, sandbox)
- Step-by-step guide for adding a new tool
- PR checklist
- CI expectations
- File ownership table

### 2. `.gitignore` is nearly empty
Only `.vercel` is listed. The repo uses Bun, Node, TypeScript, and Docker. Without proper ignore rules, `node_modules/`, `dist/`, `.env`, `*.db`, and build artifacts will be committed accidentally.

**Required additions:**
```
# Dependencies
node_modules/

# Build output
dist/
.next/
.svelte-kit/

# Environment
.env
.env.local
.env.*.local

# Database files
*.db
*.db-shm
*.db-wal
data/

# Logs
*.log
npm-debug.log*
bun-debug.log*

# OS
.DS_Store
Thumbs.db

# Editor
.vscode/
.idea/
*.swp
*.swo
```

### 3. No lint step in CI
`ci.yml` runs `bun test` and `bun build` but not `bun lint`. Code style violations pass CI undetected.

**Required change** — add to the `test` job in `.github/workflows/ci.yml`:
```yaml
- run: bun lint
- run: bun format --check
```

### 4. Dev container uses a 10 GB universal image with no Bun feature
`devcontainer.json` uses `mcr.microsoft.com/devcontainers/universal:4.0.1-noble`. This is slow to pull and does not pin Bun. A Bun-specific or Node image with the Bun devcontainer feature is faster and more reproducible.

**Recommended change:**
```json
{
"name": "AgentSwarp",
"image": "mcr.microsoft.com/devcontainers/javascript-node:22",
"features": {
"ghcr.io/devcontainers/features/bun:1": { "version": "1" }
},
"postCreateCommand": "bun install",
"forwardPorts": [3000, 3001]
}
```

### 5. `swarm-core.md` is a raw code dump, not structured guidance
The file contains 26 source files pasted inline. It is not useful as documentation and will confuse agents that read it as authoritative. It should either be deleted or replaced with a structured Phase 2 migration guide.

### 6. No `docs/` index
`docs/` has two good files but no index or README. Agents and contributors cannot discover what is documented.

**Required:** add `docs/README.md` listing available docs and their purpose.

### 7. `src/main.ts` diverges from the documented architecture
README and `AGENTS.md` describe `apps/server/` as the API layer, but `src/main.ts` contains live route handlers and direct SQLite calls. This creates two competing entry points. The minimal `src/main.ts` should either be removed or reduced to a thin bootstrap that delegates to `apps/server/`.

---

## What Is Wrong

### Critical: `.gitignore` is dangerously incomplete
`node_modules/`, `.env`, `*.db`, and `dist/` are not ignored. Any `git add .` will stage secrets and large dependency trees. This must be fixed before any new contributor runs `bun install`.

### Inconsistency: `package.json` version vs roadmap
`package.json` declares `"version": "2.0.0"` but the README roadmap shows v0.2 as "In progress" and v1.0 as "Planned". The version field should match the public release state.

### Inconsistency: `DATABASE_URL` vs hardcoded path
`.env.example` sets `DATABASE_URL=./data/agentswarm.db` but `src/main.ts` opens `new Database("agentswarp.db")` ignoring the env var. The env var is documented but not respected.

---

## Improvement Priority

| Priority | Item | Effort |
|----------|------|--------|
| P0 | Fix `.gitignore` | 5 min |
| P0 | Respect `DATABASE_URL` in `src/main.ts` | 10 min |
| P1 | Add lint + format-check to CI | 5 min |
| P1 | Replace `swarm-core.md` with a structured migration guide or delete it | 30 min |
| P2 | Switch devcontainer to a lighter image with pinned Bun | 15 min |
| P2 | Add `docs/README.md` index | 10 min |
| P3 | Reconcile `src/main.ts` with `apps/server/` architecture | 1–2 h |
| P3 | Align `package.json` version with public roadmap | 5 min |

---

## Changes Made in This Session

| File | Action |
|------|--------|
| `AGENTS.md` | Created |
| `AGENTS-IMPROVEMENT-SPEC.md` | Created (this file) |

All remaining items above are **not yet implemented** and require explicit follow-up.
Comment on lines +160 to +165

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Session change log is now stale against this PR.

Line 165 says remaining items are not implemented, but this PR already implements multiple P0/P1 items. Please update this table/conclusion so the spec reflects current repo state.

📝 Suggested adjustment
 | File | Action |
 |------|--------|
 | `AGENTS.md` | Created |
 | `AGENTS-IMPROVEMENT-SPEC.md` | Created (this file) |
+| `.gitignore` | Expanded with dependency/build/env/db/log/editor ignores |
+| `src/main.ts` | `DATABASE_URL` respected for SQLite path |
+| `.github/workflows/ci.yml` | Added lint + format-check steps |
+| `docs/phase-2-migration.md` | Added to replace raw `swarm-core.md` dump |
 
-All remaining items above are **not yet implemented** and require explicit follow-up.
+Remaining **P2/P3** items above require explicit follow-up.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@AGENTS-IMPROVEMENT-SPEC.md` around lines 160 - 165, The conclusion row in
AGENTS-IMPROVEMENT-SPEC.md that states "All remaining items above are **not yet
implemented**" is stale; update the table and concluding text to reflect the
current state by marking implemented P0/P1 items now present in the repo (as
reflected in AGENTS.md and other changes) and remove or rephrase the blanket
"not yet implemented" line. Locate the table and concluding paragraph in
AGENTS-IMPROVEMENT-SPEC.md, update the "Action" column entries for the specific
files/items that are implemented (including AGENTS.md), and change the final
summary sentence to accurately indicate which items remain outstanding versus
completed.

140 changes: 140 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
# AGENTS.md — AgentSwarp

Guidance for AI coding agents working in this repository.

---

## Repository Overview

AgentSwarp is a self-hosted, no-code AI agent platform built with Bun, Hono, SvelteKit, and SQLite. It is designed to run on low RAM (512 MB minimum).

```
agentswarp/
├── src/main.ts Entry point (Hono server, SQLite setup)
├── apps/
│ ├── web/ SvelteKit frontend (port 3000)
│ └── server/ Bun + Hono API server (port 3001)
├── packages/
│ ├── core/ Agent runner, LLM abstraction, memory, scheduler
│ └── tools/ Built-in tool implementations (14 tools)
├── docs/ Architecture and tool reference docs
├── public/ Static assets served by Hono
├── .devcontainer/ Dev container config
└── .github/ CI, PR template, issue templates
```
Comment on lines +11 to +24

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Add a language hint to the fenced block.

The repo tree block should declare a language (or text) to satisfy markdown linting.

🔧 Suggested update
-```
+```text
 agentswarp/
 ├── src/main.ts              Entry point (Hono server, SQLite setup)
 ...
 └── .github/                 CI, PR template, issue templates
</details>

<details>
<summary>🤖 Prompt for AI Agents</summary>

Verify each finding against the current code and only fix it if needed.

In @AGENTS.md around lines 11 - 24, Update the fenced repo-tree block in
AGENTS.md to include a language hint (e.g., use text) so the markdown linter recognizes it; locate the fenced block that starts with the agentswarp/ tree and change the opening fence to include the language token (for example replace
with ```text) while leaving the tree content unchanged.


</details>

<!-- fingerprinting:phantom:poseidon:hawk -->

<!-- This is an auto-generated comment by CodeRabbit -->


---

## Tech Stack

| Layer | Technology |
|------------|-------------------------------------|
| Runtime | Bun 1.0+ |
| Backend | Hono (HTTP + WebSocket) |
| Frontend | SvelteKit |
| Database | SQLite via `better-sqlite3` |
| Language | TypeScript (strict, no `any`) |
| Container | Docker / Docker Compose |

---

## Development Commands

```bash
bun install # Install dependencies
bun dev # Start dev server with file watching (port 3000)
bun start # Start production server
bun build # Build to ./dist
bun test # Run tests
bun lint # ESLint
bun format # Prettier
```

---

## Code Conventions

- **TypeScript everywhere** — no `any` unless unavoidable; document why if used.
- **Prettier + ESLint** — run `bun format` and `bun lint` before committing.
- **Small, named functions** — prefer composition over inheritance.
- **Comments explain why**, not what.
- **No placeholders or TODOs** in committed code — implement fully or open an issue.
- SQLite access goes through `packages/core/` — do not add raw DB calls in route handlers.
- New tools belong in `packages/tools/src/` and must be registered in `packages/core/src/tool-registry.ts`.
- New API routes belong in `apps/server/` (not `src/main.ts`, which is the minimal entry point).

---

## Architecture Constraints

- **Memory budget**: keep the runtime footprint under 512 MB. Avoid loading large assets or models into process memory.
- **Step limit**: agent runs are capped at 15 steps to prevent infinite loops. Do not raise this without a corresponding safety review.
- **Code execution sandbox**: `execute_code` tool runs in a sandboxed context — do not widen its permissions.
- **WAL mode**: SQLite is opened with `journal_mode = WAL`. Maintain this for concurrent read performance.

---

## Environment Variables

Copy `.env.example` to `.env` before running locally. Key variables:

| Variable | Purpose |
|-----------------------|----------------------------------------------|
| `PORT` | Server port (default `3000`) |
| `SECRET_KEY` | Session/auth secret — change before deploy |
| `DATABASE_URL` | SQLite file path |
| `DEFAULT_LLM_PROVIDER`| `ollama` (default), `openai`, `groq`, etc. |
| `DEFAULT_MODEL` | Model name for the default provider |
| `OLLAMA_BASE_URL` | Ollama endpoint (default `localhost:11434`) |

Never commit `.env` or any file containing real secrets.

---

## Adding a New Tool

1. Create `packages/tools/src/<tool-name>.ts` implementing the `Tool` interface from `packages/core/src/types.ts`.
2. Export it from `packages/tools/src/index.ts`.
3. Register it in `packages/core/src/tool-registry.ts`.
4. Add the required env vars to `.env.example` with empty values.
5. Document the tool in `docs/tools.md`.
6. Add a test in `packages/tools/src/__tests__/`.

---

## Pull Request Checklist

Before opening a PR, verify:

- [ ] `bun test` passes
- [ ] `bun lint` passes with no errors
- [ ] `bun format` applied
- [ ] No `any` types introduced without justification
- [ ] `.env.example` updated if new env vars were added
- [ ] `docs/` updated if behaviour or architecture changed
- [ ] Tested under constrained memory if the change touches the agent runner or tools

---

## CI

GitHub Actions runs on every push and PR:

- `bun install && bun test && bun run build` — must pass on all PRs.
- Docker image build runs on `main` only.
Comment on lines +123 to +124

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

CI section is outdated vs current workflow checks.

Line 123 currently documents install/test/build only, but CI now also runs lint and format-check gates.

📝 Suggested update
-- `bun install && bun test && bun run build` — must pass on all PRs.
+- `bun install && bun lint && bun format --check && bun test && bun run build` — must pass on all PRs.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@AGENTS.md` around lines 123 - 124, Update the CI notes in AGENTS.md to
reflect the current PR gates: change the first bullet that says "`bun install &&
bun test && bun run build` — must pass on all PRs." to include lint and
format-check (e.g. "`bun install && bun test && bun run build && bun run lint &&
bun run format:check` — must pass on all PRs.") and ensure the second bullet
about Docker image builds still notes "Docker image build runs on `main` only."
Make the text concise and accurate so the documented commands match the actual
CI workflow.


Do not merge if CI is red.

---

## File Ownership

| Area | Primary location |
|-----------------------------|-----------------------------------------|
| Agent execution logic | `packages/core/src/agent-runner.ts` |
| LLM provider abstraction | `packages/core/src/llm-client.ts` |
| Memory (KV + vector) | `packages/core/src/memory.ts`, `vector-store.ts` |
| Tool implementations | `packages/tools/src/` |
| Frontend UI | `apps/web/src/` |
| API routes | `apps/server/` |
| Static entry point | `src/main.ts` |
Loading
Loading