chore: replace 607 em-dashes with double hyphens project-wide
Includes MCP crash-after-init test fix (crash moved from handle() to serve() entry point so transport sees immediate subprocess death).
This commit is contained in:
1 parent
16d6cd62b7
commit
f6d51416f0
112 files changed
+587
-582
No files matched your search
+4
-4
@@ -1,18 +1,18 @@
|
||||
# archied — design notes
|
||||
# archied -- design notes
|
||||
|
||||
Archie is a resident daemon that keeps personal projects moving: it polls GitHub for issues labelled
|
||||
`archie`, works each one in an isolated fresh-clone worktree through a routed **workflow**, and opens a
|
||||
pull request for human review. Sam reviews and merges; the machine grinds in between.
|
||||
|
||||
Guiding principle: **environmental constraints over prompt instructions.** Agents don't get asked nicely
|
||||
to write good code — the quality gate (vet/build/test/lint, configurable per repo and per workflow stage)
|
||||
to write good code -- the quality gate (vet/build/test/lint, configurable per repo and per workflow stage)
|
||||
refuses to let a run succeed until it passes. The gate mechanics live in `ai-sdk/agentloop`; this repo
|
||||
owns orchestration only.
|
||||
|
||||
## Workflows, not a pipeline
|
||||
|
||||
`internal/workflow` is the engine: a Workflow is an ordered list of stages over a shared TaskContext;
|
||||
stages are deterministic steps (worktree, gate, diff cap, PR, comments — the shared step library in
|
||||
stages are deterministic steps (worktree, gate, diff cap, PR, comments -- the shared step library in
|
||||
`steps.go`) or agent stages (`agentloop.Run` with a stage-specific mission/toolset/gate). Routing is
|
||||
label-driven (`bug` → tdd, `feature` → feasibility, default → implement), refinable by an LLM triage
|
||||
stage. Adding a workflow must never require touching the engine or reimplementing steps.
|
||||
@@ -31,7 +31,7 @@ Planned workflows:
|
||||
`queued → running(workflow:stage) → waiting_human | pr_open → merged | parked | rejected | closed_wont_do`
|
||||
|
||||
SQLite (`internal/store`), WAL, one row per issue with a transitions audit table. Crash recovery:
|
||||
`running` tasks re-queue on startup with attempt++. Parks are never silent — every park comments on the
|
||||
`running` tasks re-queue on startup with attempt++. Parks are never silent -- every park comments on the
|
||||
issue with the reason and gate output.
|
||||
|
||||
## Rejected alternative: building on tau's peer-agent runtime
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# archie-core Skills System — PRD
|
||||
# archie-core Skills System -- PRD
|
||||
|
||||
**Author:** Archie (Hermes agent)
|
||||
**Date:** 2026-07-18
|
||||
@@ -21,7 +21,7 @@ Every project can ship an `archie.yaml` that defines how archie-core should beha
|
||||
### 1.1 Discovery
|
||||
|
||||
```
|
||||
.archie.yaml (root of repo — highest precedence)
|
||||
.archie.yaml (root of repo -- highest precedence)
|
||||
archie.yaml (repo root)
|
||||
.archie/archie.yaml (subdirectory, one level deep)
|
||||
```
|
||||
@@ -54,7 +54,7 @@ connection:
|
||||
base: main
|
||||
draft: false
|
||||
|
||||
# Skills — playbooks archie-core loads to know how to work
|
||||
# Skills -- playbooks archie-core loads to know how to work
|
||||
skills:
|
||||
paths:
|
||||
- .archie/skills/ # project-local skills
|
||||
@@ -62,7 +62,7 @@ skills:
|
||||
remotes:
|
||||
- github.com/sam/archie-skills@v1 # shared skill library
|
||||
|
||||
# Sandbox — what's available in the container
|
||||
# Sandbox -- what's available in the container
|
||||
sandbox:
|
||||
image: ghcr.io/sam/archie-sandbox:latest
|
||||
tools:
|
||||
@@ -75,7 +75,7 @@ sandbox:
|
||||
env:
|
||||
GOFLAGS: "-mod=readonly"
|
||||
|
||||
# Gates — archie-core must pass these before committing
|
||||
# Gates -- archie-core must pass these before committing
|
||||
gates:
|
||||
test:
|
||||
run: go test -race -count=1 ./...
|
||||
@@ -89,7 +89,7 @@ gates:
|
||||
run: task deadcode
|
||||
optional: true
|
||||
|
||||
# Quality pipeline — which gates run when
|
||||
# Quality pipeline -- which gates run when
|
||||
quality:
|
||||
pre_commit: [test, lint, format]
|
||||
pre_push: [deadcode]
|
||||
@@ -171,9 +171,9 @@ All five steps must exit 0. If `task deadcode` fails on unrelated packages,
|
||||
scope it to only changed packages: `golangci-lint run --tests=false --enable-only=unused,staticcheck ./changed/pkg/...`
|
||||
|
||||
## Common failures
|
||||
- `golangci-lint`: unused function — remove it or add `//nolint:unused` comment
|
||||
- `go test -race`: data race — protect with mutex or channel
|
||||
- `task deadcode`: pre-existing dead code in unrelated package — scope to changed packages
|
||||
- `golangci-lint`: unused function -- remove it or add `//nolint:unused` comment
|
||||
- `go test -race`: data race -- protect with mutex or channel
|
||||
- `task deadcode`: pre-existing dead code in unrelated package -- scope to changed packages
|
||||
```
|
||||
|
||||
### 2.3 Skill metadata (arcie-specific)
|
||||
@@ -258,15 +258,15 @@ arcie-core can delegate implementation to different LLM engines. The workflow fi
|
||||
|
||||
```yaml
|
||||
engines:
|
||||
- type: claude # Claude Code CLI — full agent loop
|
||||
- type: claude # Claude Code CLI -- full agent loop
|
||||
model: sonnet
|
||||
budget_usd: 5.00
|
||||
- type: tau # Tau — Sam's native Go agent
|
||||
- type: tau # Tau -- Sam's native Go agent
|
||||
model: gpt-4o
|
||||
budget_usd: 2.00
|
||||
- type: codex # OpenAI Codex CLI
|
||||
model: gpt-5.1-codex-max
|
||||
- type: raw # Direct LLM — no agent loop, single prompt
|
||||
- type: raw # Direct LLM -- no agent loop, single prompt
|
||||
model: gpt-4o-mini
|
||||
```
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# archie-core Workflows & Skills — Product Requirements Document
|
||||
# archie-core Workflows & Skills -- Product Requirements Document
|
||||
|
||||
**Author:** Archie (Hermes agent)
|
||||
**Date:** 2026-07-18
|
||||
@@ -19,7 +19,7 @@ This PRD defines a workflow and skills system for archie-core. Workflow files de
|
||||
A project declares its workflow in `archie.yaml` at the project root. archie-core discovers it the same way Task (Taskfile) and devcontainers do:
|
||||
|
||||
```
|
||||
.archie.yaml (root of repo — highest precedence)
|
||||
.archie.yaml (root of repo -- highest precedence)
|
||||
archie.yaml (repo root)
|
||||
.archie/archie.yaml (subdirectory, one level deep)
|
||||
```
|
||||
@@ -29,7 +29,7 @@ If no file is found, archie-core uses built-in defaults (read, write, bash).
|
||||
### 1.2 Schema
|
||||
|
||||
```yaml
|
||||
# archie.yaml — complete schema
|
||||
# archie.yaml -- complete schema
|
||||
version: "1"
|
||||
|
||||
# Project identity
|
||||
@@ -74,7 +74,7 @@ sandbox:
|
||||
GOFLAGS: "-mod=readonly"
|
||||
CGO_ENABLED: "0"
|
||||
|
||||
# Gates — ordered checkpoints that must pass
|
||||
# Gates -- ordered checkpoints that must pass
|
||||
gates:
|
||||
test:
|
||||
run: go test -race -count=1 ./...
|
||||
@@ -95,7 +95,7 @@ gates:
|
||||
optional: true # non-blocking gate
|
||||
description: "Dead code check (advisory)"
|
||||
|
||||
# Quality pipeline — ordered sequence of gate groups
|
||||
# Quality pipeline -- ordered sequence of gate groups
|
||||
quality:
|
||||
pre_commit:
|
||||
- test
|
||||
|
||||
@@ -459,7 +459,7 @@
|
||||
<div>
|
||||
<p class="eyebrow"><span class="live-dot" aria-hidden="true"></span>Implemented topology · v2</p>
|
||||
<h1>archie-core</h1>
|
||||
<p class="subtitle">Single-daemon architecture: poll GitHub for labelled issues, route through label-driven workflows, run gated AI agent loops via ai-sdk, and deliver reviewed PRs — all in-process with SQLite crash recovery and an SSE observability dashboard.</p>
|
||||
<p class="subtitle">Single-daemon architecture: poll GitHub for labelled issues, route through label-driven workflows, run gated AI agent loops via ai-sdk, and deliver reviewed PRs -- all in-process with SQLite crash recovery and an SSE observability dashboard.</p>
|
||||
</div>
|
||||
<div class="legend" aria-label="Component legend">
|
||||
<span class="chip" style="--chip-color: var(--slate)">External</span>
|
||||
@@ -761,17 +761,17 @@
|
||||
<article class="insight" style="--accent: var(--green)">
|
||||
<p class="insight-kicker">01 · Task flow</p>
|
||||
<h2>Label-driven, in-process execution</h2>
|
||||
<p>archied polls GitHub for issues matching the configured trigger (assignee, label, or either). Each issue becomes a SQLite-tracked task, claimed one at a time, and routed to a workflow by issue labels — no LLM involved in routing. All stages run sequentially inside the daemon process.</p>
|
||||
<p>archied polls GitHub for issues matching the configured trigger (assignee, label, or either). Each issue becomes a SQLite-tracked task, claimed one at a time, and routed to a workflow by issue labels -- no LLM involved in routing. All stages run sequentially inside the daemon process.</p>
|
||||
</article>
|
||||
<article class="insight" style="--accent: var(--orange)">
|
||||
<p class="insight-kicker">02 · Failure boundaries</p>
|
||||
<h2>Environmental constraints, not prompt rules</h2>
|
||||
<p>The quality gate, test-file protection (TDD fix stage), and diff-size cap are code enforcement — not "please don't do that" in the system prompt. Crashed daemons re-queue stale running tasks on startup. Parks are never silent: every parked task posts a comment with the reason and gate output.</p>
|
||||
<p>The quality gate, test-file protection (TDD fix stage), and diff-size cap are code enforcement -- not "please don't do that" in the system prompt. Crashed daemons re-queue stale running tasks on startup. Parks are never silent: every parked task posts a comment with the reason and gate output.</p>
|
||||
</article>
|
||||
<article class="insight" style="--accent: var(--cyan)">
|
||||
<p class="insight-kicker">03 · Design decisions</p>
|
||||
<h2>Deterministic git, fresh worktrees</h2>
|
||||
<p>The model never runs git — worktree operations (clone, branch, commit, push, diff, cleanup) are deterministic steps, not agent tools. Every task gets a fresh clone under <code>~/.local/share/archie/work/</code>. Tokens are tracked per task and emitted in observability events, but not budgeted beyond the agent loop's own limits.</p>
|
||||
<p>The model never runs git -- worktree operations (clone, branch, commit, push, diff, cleanup) are deterministic steps, not agent tools. Every task gets a fresh clone under <code>~/.local/share/archie/work/</code>. Tokens are tracked per task and emitted in observability events, but not budgeted beyond the agent loop's own limits.</p>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
+20
-20
@@ -7,7 +7,7 @@ changing anything that contradicts a prior decision.
|
||||
|
||||
---
|
||||
|
||||
## 2026-07-23 — Forge-agnostic issue creation via CreateIssue
|
||||
## 2026-07-23 -- Forge-agnostic issue creation via CreateIssue
|
||||
|
||||
**Decision**: Add `CreateIssue(ctx, owner, repo, title, body, labels)
|
||||
(int, error)` to the `forge.Forge` interface. Every forge backend
|
||||
@@ -21,11 +21,11 @@ calls one method regardless of the underlying ticketing system.
|
||||
**Future**: A `beads` forge backend will implement `CreateIssue` by
|
||||
calling `bd create`. This makes beads the internal/default issue tracker
|
||||
while Gitea/GitHub are external forges. The agent doesn't know which
|
||||
it's talking to — the daemon resolves the forge from repo config.
|
||||
it's talking to -- the daemon resolves the forge from repo config.
|
||||
|
||||
---
|
||||
|
||||
## 2026-07-23 — Dolt and Beads for agent-native issue tracking
|
||||
## 2026-07-23 -- Dolt and Beads for agent-native issue tracking
|
||||
|
||||
**Decision**: Install dolt (version-controlled SQL) and beads (`bd`,
|
||||
a graph-based issue tracker for AI agents) as the foundation for
|
||||
@@ -35,9 +35,9 @@ multi-repo scaling and multi-agent coordination.
|
||||
class dependency tracking, JSON output for programmatic use, and hash-
|
||||
based IDs that prevent merge conflicts in multi-agent workflows. It's
|
||||
built on Dolt which gives cell-level merge, native branching, and
|
||||
remote sync — the same primitives git gives code but applied to issues.
|
||||
remote sync -- the same primitives git gives code but applied to issues.
|
||||
|
||||
**Context**: Gas Town (`~/gt/`) is cloned for reference — it implements
|
||||
**Context**: Gas Town (`~/gt/`) is cloned for reference -- it implements
|
||||
a multi-agent workspace on top of beads. The archie-core scaling
|
||||
strategy will follow a similar model: a coordinator daemon with per-repo
|
||||
agents, all sharing a beads-backed task graph.
|
||||
@@ -47,7 +47,7 @@ in archie-core (`.beads/`). Six issues seeded for the scaling roadmap.
|
||||
|
||||
---
|
||||
|
||||
## 2026-07-23 — Token budgets must be generous, not predictive
|
||||
## 2026-07-23 -- Token budgets must be generous, not predictive
|
||||
|
||||
**Decision**: Set `max_tokens` to 100,000,000 (100M). Do not attempt to
|
||||
predict what a task needs without data. Lower limits later based on
|
||||
@@ -61,7 +61,7 @@ lines) need proportionally more.
|
||||
|
||||
**Context**: The planner burned 357K tokens just to discover a fix
|
||||
already existed. The builder hit 1M at step 25 of 90. Neither task was
|
||||
unreasonable — they were just exploring a large codebase.
|
||||
unreasonable -- they were just exploring a large codebase.
|
||||
|
||||
**Future**: Track actual token consumption per workflow/stage/repo. Use
|
||||
that data to set informed limits. Build compaction or checkpointing so
|
||||
@@ -69,7 +69,7 @@ a killed agent can resume rather than restart.
|
||||
|
||||
---
|
||||
|
||||
## 2026-07-23 — baseline-fix: auto-repair pre-existing gate failures
|
||||
## 2026-07-23 -- baseline-fix: auto-repair pre-existing gate failures
|
||||
|
||||
**Decision**: When `StageBaselineGate` detects a red gate (gofumpt, go
|
||||
vet, etc. failing on clean main), launch the builder to fix the
|
||||
@@ -77,7 +77,7 @@ failures via TDD rather than parking. Only park if the builder cannot
|
||||
fix them.
|
||||
|
||||
**Reasoning**: A red baseline means the repo was broken before archie
|
||||
touched it. Parking creates an infinite loop — the next retry hits the
|
||||
touched it. Parking creates an infinite loop -- the next retry hits the
|
||||
same failure. The agent should fix pre-existing issues, not fail on them.
|
||||
|
||||
**Implementation**: `StageBaselineGate` now calls `tc.Agent.Run()` with
|
||||
@@ -86,7 +86,7 @@ this required wiring `tc.Agent` (the runner) through the stage context.
|
||||
|
||||
---
|
||||
|
||||
## 2026-07-23 — No hardcoded MaxSteps in workflow stages
|
||||
## 2026-07-23 -- No hardcoded MaxSteps in workflow stages
|
||||
|
||||
**Decision**: Remove all hardcoded `MaxSteps` values from workflow
|
||||
stages. Every stage inherits from `[budgets].max_steps` in the config.
|
||||
@@ -99,7 +99,7 @@ repos. The config should be the single source of truth.
|
||||
|
||||
---
|
||||
|
||||
## 2026-07-23 — No-op detection: close issues when build has 0 changes
|
||||
## 2026-07-23 -- No-op detection: close issues when build has 0 changes
|
||||
|
||||
**Decision**: When the builder completes with `StatusPassed` and 0 file
|
||||
changes, close the issue with a comment rather than parking on "worktree
|
||||
@@ -120,7 +120,7 @@ sets `Outcome = Merged` to stop the workflow.
|
||||
|
||||
---
|
||||
|
||||
## 2026-07-23 — assignee trigger over label trigger
|
||||
## 2026-07-23 -- assignee trigger over label trigger
|
||||
|
||||
**Decision**: Default to `trigger = "assignee"` instead of `trigger =
|
||||
"label"`. The daemon only claims issues explicitly assigned to the bot
|
||||
@@ -132,13 +132,13 @@ promiscuous for repos shared between humans and agents.
|
||||
|
||||
---
|
||||
|
||||
## 2026-07-23 — DeepSeek v4 Pro as primary model
|
||||
## 2026-07-23 -- DeepSeek v4 Pro as primary model
|
||||
|
||||
**Decision**: Use `deepseek/deepseek-v4-pro` as the planner and builder
|
||||
model. Qwythos-9B (local llama.cpp) is the fallback for offline/cheap
|
||||
tasks.
|
||||
|
||||
**Reasoning**: Qwythos couldn't complete the plan stage for tau — 0
|
||||
**Reasoning**: Qwythos couldn't complete the plan stage for tau -- 0
|
||||
iterations, timed_out. DeepSeek completed it in 21 iterations. Large
|
||||
repos need a larger model.
|
||||
|
||||
@@ -147,7 +147,7 @@ env var from Bitwarden Secrets Manager (bws).
|
||||
|
||||
---
|
||||
|
||||
## 2026-07-22 — v1.0.0 tagged
|
||||
## 2026-07-22 -- v1.0.0 tagged
|
||||
|
||||
**Decision**: Tagged `v1.0.0` at commit incorporating the daemon/agent
|
||||
split, NATS JetStream, Docker sandbox, Yaegi plugins, agentskills.io
|
||||
@@ -155,7 +155,7 @@ skills, and Gitea forge support.
|
||||
|
||||
---
|
||||
|
||||
## 2026-07-22 — Docker Compose stack with NATS + containers
|
||||
## 2026-07-22 -- Docker Compose stack with NATS + containers
|
||||
|
||||
**Decision**: The production deployment uses `docker-compose.yml` with
|
||||
NATS, archied, and archie-agent containers. Config at `config.docker.toml`.
|
||||
@@ -168,10 +168,10 @@ NATS, archied, and archie-agent containers. Config at `config.docker.toml`.
|
||||
|
||||
---
|
||||
|
||||
## 2026-07-22 — Worktree Prepare before Container Acquire
|
||||
## 2026-07-22 -- Worktree Prepare before Container Acquire
|
||||
|
||||
**Decision**: Clone the worktree (`Trees.Prepare()`) before acquiring
|
||||
a Docker container. Made `Prepare()` idempotent — skips if `.git`
|
||||
a Docker container. Made `Prepare()` idempotent -- skips if `.git`
|
||||
already exists.
|
||||
|
||||
**Reasoning**: Docker bind-mounts fail with "bind source path does not
|
||||
@@ -181,12 +181,12 @@ didn't exist on the host.
|
||||
|
||||
---
|
||||
|
||||
## 2026-07-22 — Gofumpt and Go tools must be on PATH
|
||||
## 2026-07-22 -- Gofumpt and Go tools must be on PATH
|
||||
|
||||
**Decision**: The daemon's `exec.Command` for gate checks inherits the
|
||||
process PATH. `~/go/bin` (where `gofumpt`, `golangci-lint`, etc. live)
|
||||
must be in the PATH before starting the daemon.
|
||||
|
||||
**Symptom**: `baseline red — gofumpt -w . fails` but manual run passes.
|
||||
**Symptom**: `baseline red -- gofumpt -w . fails` but manual run passes.
|
||||
Root cause: `which gofumpt` returns nothing because `~/go/bin` isn't on
|
||||
PATH in Hermes sessions.
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
**Author:** Archie (Hermes agent)
|
||||
**Date:** 2026-07-21 (implementation status updated 2026-07-22)
|
||||
**Status:** Final (substantially implemented — remaining aspirational items are pluggable storage backends and Layer 2 daemon plugin loader)
|
||||
**Status:** Final (substantially implemented -- remaining aspirational items are pluggable storage backends and Layer 2 daemon plugin loader)
|
||||
|
||||
---
|
||||
|
||||
@@ -19,9 +19,9 @@ This document describes a target end state. The table below is the ground truth;
|
||||
| `/data/` volume, `task.json` | **Partial** | `container.WriteTaskJSON()` writes task payload to the worktree before container acquire. The container pool bind-mounts the isolated task worktree at `/data/worktree`; configured repos also receive a persistent `/data/repo` Docker volume. Task payload travels over NATS as the primary channel; `/data/task.json` is a boot-time brief for the container. |
|
||||
| `[containers]` config block | **Implemented** | `ContainerConfig` struct in config.go: enabled, image, max_concurrency, max_uptime, pull_policy. Validated on load. |
|
||||
| Yaegi extensibility (gates, custom stages, skill scripts) | **Implemented** | Three surfaces: `.archie/gate.go`, `.archie/stages/*.go`, skill scripts via `run_go_script` tool. All in-process via Yaegi with generated symbol tables and panic recovery. Full detail in `docs/prds/yaegi-plugin-system.md`. |
|
||||
| Layer 1: skill-bundled plugins | **Implemented** | `skill.DiscoverPlugins()` scans `.agents/skills/<name>/plugins/*.go`. `skill.Plugin.Run()` executes them via Yaegi. `skillbuild.BuildWorkflow()` constructs `workflow.Workflow` from plugin-defined stages. `TaskContext.SkillPlugins` makes them available during stage execution. `skillbuild.BuildRegistry()` replaces the hardcoded `workflow.Registry` with catalog-driven construction — skills define workflows, plugins define stages. |
|
||||
| Layer 2: core daemon plugins | **Partial** | `internal/plugin/plugin.go`: `Plugin` interface (`Name()`, `Version()`), `Registry` type, `LoadDir()` using Yaegi to interpret `.go` files. No `~/.config/archie/plugins/` loader wired into `cmd/archied/main.go` yet — the interface and registry exist but are not connected to the daemon's startup. |
|
||||
| Skills (agentskills.io spec) | **Implemented** | `internal/skill/skill.go`: parses SKILL.md YAML frontmatter, discovers skills from `.agents/skills/*/SKILL.md`, extracts body. Skills follow `archie-wf-*` naming convention. Progressive disclosure: `Catalog()` (Tier 1 — frontmatter-only scan, ~100 tokens per entry), `LoadBody()` (Tier 2 — full body on activation), `Discover()` (Tier 3 — full parse with plugins). `metadata.archie.workflow` declares skill→workflow affinity. `skill.SkillForWorkflow()` is catalog-driven, no hardcoded maps. `skillbuild.BuildRegistry()` constructs the daemon's workflow registry from the catalog. |
|
||||
| Layer 1: skill-bundled plugins | **Implemented** | `skill.DiscoverPlugins()` scans `.agents/skills/<name>/plugins/*.go`. `skill.Plugin.Run()` executes them via Yaegi. `skillbuild.BuildWorkflow()` constructs `workflow.Workflow` from plugin-defined stages. `TaskContext.SkillPlugins` makes them available during stage execution. `skillbuild.BuildRegistry()` replaces the hardcoded `workflow.Registry` with catalog-driven construction -- skills define workflows, plugins define stages. |
|
||||
| Layer 2: core daemon plugins | **Partial** | `internal/plugin/plugin.go`: `Plugin` interface (`Name()`, `Version()`), `Registry` type, `LoadDir()` using Yaegi to interpret `.go` files. No `~/.config/archie/plugins/` loader wired into `cmd/archied/main.go` yet -- the interface and registry exist but are not connected to the daemon's startup. |
|
||||
| Skills (agentskills.io spec) | **Implemented** | `internal/skill/skill.go`: parses SKILL.md YAML frontmatter, discovers skills from `.agents/skills/*/SKILL.md`, extracts body. Skills follow `archie-wf-*` naming convention. Progressive disclosure: `Catalog()` (Tier 1 -- frontmatter-only scan, ~100 tokens per entry), `LoadBody()` (Tier 2 -- full body on activation), `Discover()` (Tier 3 -- full parse with plugins). `metadata.archie.workflow` declares skill→workflow affinity. `skill.SkillForWorkflow()` is catalog-driven, no hardcoded maps. `skillbuild.BuildRegistry()` constructs the daemon's workflow registry from the catalog. |
|
||||
| Worktree/repo management | **Implemented** | Each issue keeps an isolated worktree. Repos with `persistent_storage = true` use a per-repo bare Git object cache to avoid repeated full network clones; caches and Archie-owned repo volumes expire via `containers.volume_ttl`. |
|
||||
| Config schema | **Closer to sec.4** | `[agent]` block: mode (inprocess/subprocess/nats) + command + env. `[nats]` block: url + token_env. `[containers]` block: enabled, image, max_concurrency, max_uptime, volume_ttl, pull_policy. Per-repo `persistent_storage` is supported as a boolean Docker-volume/Git-cache opt-in. |
|
||||
|
||||
|
||||
@@ -36,9 +36,9 @@ Hermes gateway (`gateway/run.py`, GatewayRunner) manages full lifecycle: adapter
|
||||
|
||||
| Feature | archie-core status | Priority |
|
||||
|---|---|---|
|
||||
| Adapter lifecycle (connect/disconnect/reconnect) | None — 3-method Gateway interface | **P0** |
|
||||
| MessageEvent data model (types, media, reply context) | None — 3-field Message struct | **P0** |
|
||||
| SendResult with retry/error classification | None — fire-and-forget | **P1** |
|
||||
| Adapter lifecycle (connect/disconnect/reconnect) | None -- 3-method Gateway interface | **P0** |
|
||||
| MessageEvent data model (types, media, reply context) | None -- 3-field Message struct | **P0** |
|
||||
| SendResult with retry/error classification | None -- fire-and-forget | **P1** |
|
||||
| Session management (SessionSource + AsyncSessionStore) | None | **P0** |
|
||||
| Platform config (Platform enum, PlatformConfig) | None | **P0** |
|
||||
| Streaming delivery (token streaming with edit/draft) | None | **P1** |
|
||||
@@ -54,7 +54,7 @@ Hermes has 30+ platform adapters: Telegram, Discord, Slack, Matrix, WhatsApp, Si
|
||||
|
||||
| Feature | archie-core status | Priority |
|
||||
|---|---|---|
|
||||
| BasePlatformAdapter ABC (20+ methods, capability flags) | None — 3-method Gateway interface | **P0** |
|
||||
| BasePlatformAdapter ABC (20+ methods, capability flags) | None -- 3-method Gateway interface | **P0** |
|
||||
| Platform adapter registry + plugin discovery | None | **P0** |
|
||||
| Media handling (image/video/audio/document send) | None | **P1** |
|
||||
| Typing indicators | None | **P2** |
|
||||
@@ -110,7 +110,7 @@ Hermes has: 60+ CLI commands, TUI interface, command registry with plugin contri
|
||||
|
||||
| Feature | archie-core status | Priority |
|
||||
|---|---|---|
|
||||
| Interactive CLI with command registry | None — 4 flags | **P1** |
|
||||
| Interactive CLI with command registry | None -- 4 flags | **P1** |
|
||||
| Config subcommands (get/set/unset/edit/wizard) | None | **P1** |
|
||||
| .env file support | None | **P2** |
|
||||
| Self-update mechanism | None | **P2** |
|
||||
@@ -171,10 +171,10 @@ Hermes has: FastAPI web server (Vite/React frontend), OpenAI-compatible API serv
|
||||
|
||||
## Total: ~60 feature gaps across 11 subsystems
|
||||
|
||||
**P0 (must-have for baseline parity):** 7 items — adapter lifecycle, message model, session management, platform config, tool registry, MCP client, memory provider ABC
|
||||
**P0 (must-have for baseline parity):** 7 items -- adapter lifecycle, message model, session management, platform config, tool registry, MCP client, memory provider ABC
|
||||
|
||||
**P1 (near-term):** 13 items — send result, streaming, dedup, media handling, guardrails, progressive disclosure, tool persistence, session hooks, history store, pairing/auth, CLI, config subcommands, profiles, readiness
|
||||
**P1 (near-term):** 13 items -- send result, streaming, dedup, media handling, guardrails, progressive disclosure, tool persistence, session hooks, history store, pairing/auth, CLI, config subcommands, profiles, readiness
|
||||
|
||||
**P2 (medium-term):** 22 items — interactive UX, subagents, browser/search/file tools, compression, session splitting, slash access, secrets CLI, cron, dashboard, API server, delivery, drain, scale-to-zero
|
||||
**P2 (medium-term):** 22 items -- interactive UX, subagents, browser/search/file tools, compression, session splitting, slash access, secrets CLI, cron, dashboard, API server, delivery, drain, scale-to-zero
|
||||
|
||||
**P3 (future):** 3 items — billing, OAuth, desktop app
|
||||
**P3 (future):** 3 items -- billing, OAuth, desktop app
|
||||
@@ -161,7 +161,7 @@ pieces where isolation adds cost without benefit:
|
||||
Decision rationale: per-identity goroutines guarantee failure isolation (one
|
||||
identity's forge outage cannot block another's poll tick), each identity
|
||||
gets its own forge rate-limit domain, and the existing `Daemon` struct maps
|
||||
cleanly — each goroutine holds a thin `Identity` value (forge client + config
|
||||
cleanly -- each goroutine holds a thin `Identity` value (forge client + config
|
||||
subset + worktree manager + NATS subject prefix) and dispatches tasks with
|
||||
an `identity_name` column on the task row. The shared NATS connection
|
||||
multiplexes subjects by identity prefix; the shared store already handles
|
||||
@@ -170,7 +170,7 @@ the identity name so agent containers (which consume from NATS) route
|
||||
responses back to the correct daemon identity.
|
||||
|
||||
This design resolves the open question in section 4 of the original PRD
|
||||
draft (per-identity goroutine vs single loop iterating identities — the
|
||||
draft (per-identity goroutine vs single loop iterating identities -- the
|
||||
former, for failure isolation).
|
||||
|
||||
## 5. Priority / phasing
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# archie-core TypeScript Plugin Engine — PRD
|
||||
# archie-core TypeScript Plugin Engine -- PRD
|
||||
|
||||
**Author:** Archie (Hermes agent)
|
||||
**Date:** 2026-07-21
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
## Summary
|
||||
|
||||
A TypeScript-based plugin engine that lets repositories ship interpreted, dynamically-loaded workflow extensions. Plugins are `.ts` files placed in `.archie/workflows/`. archie-core discovers them on its next poll cycle, transpiles them to JavaScript via esbuild, and executes them in an embedded [goja](https://github.com/dop251/goja) runtime — a pure-Go ECMAScript interpreter with zero CGO dependencies.
|
||||
A TypeScript-based plugin engine that lets repositories ship interpreted, dynamically-loaded workflow extensions. Plugins are `.ts` files placed in `.archie/workflows/`. archie-core discovers them on its next poll cycle, transpiles them to JavaScript via esbuild, and executes them in an embedded [goja](https://github.com/dop251/goja) runtime -- a pure-Go ECMAScript interpreter with zero CGO dependencies.
|
||||
|
||||
---
|
||||
|
||||
@@ -20,7 +20,7 @@ TypeScript is the most widely understood language among developers writing autom
|
||||
|
||||
Having a TypeScript-native plugin engine means:
|
||||
- Plugin authors get familiar syntax, type safety, and IDE support
|
||||
- No separate toolchain — just `.ts` files in a folder
|
||||
- No separate toolchain -- just `.ts` files in a folder
|
||||
- Skills, gates, and workflow stages share the same language
|
||||
|
||||
### Why goja
|
||||
@@ -29,12 +29,12 @@ Having a TypeScript-native plugin engine means:
|
||||
|---|---|
|
||||
| V8 CGO bindings | Requires CGO, ~50MB static libraries, platform-specific builds |
|
||||
| QuickJS CGO | Requires CGO, smaller than V8 but still a C dependency |
|
||||
| QJS (Wazero) | Pure Go WASM, but sandboxed — can't expose Go functions efficiently |
|
||||
| QJS (Wazero) | Pure Go WASM, but sandboxed -- can't expose Go functions efficiently |
|
||||
| Ramune | Heavy dependency, bundles an entire TypeScript 7 compiler |
|
||||
| Node.js subprocess | Process overhead per execution, IPC serialization cost |
|
||||
|
||||
goja is a pure-Go ECMAScript 5.1+ interpreter at ~20k lines. It:
|
||||
- Has **zero CGO** — cross-compiles everywhere Go does
|
||||
- Has **zero CGO** -- cross-compiles everywhere Go does
|
||||
- Passes nearly all TC39 Test262 tests for ES5.1 + significant ES6 coverage
|
||||
- Can run Babel and the TypeScript compiler itself (proven capability)
|
||||
- Provides direct Go↔JS interop via `Set()`/`Get()`/`Runtime.RunString()`
|
||||
@@ -114,7 +114,7 @@ export function check(ctx: GateContext): Finding[] {
|
||||
if (line.includes("panic(")) {
|
||||
findings.push({
|
||||
level: "error",
|
||||
message: "new panic() call — use error returns instead"
|
||||
message: "new panic() call -- use error returns instead"
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -128,7 +128,7 @@ export function check(ctx: GateContext): Finding[] {
|
||||
findings.push({
|
||||
level: "warn",
|
||||
file: file,
|
||||
message: "time.Sleep in non-test code — use time.Ticker instead"
|
||||
message: "time.Sleep in non-test code -- use time.Ticker instead"
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -217,7 +217,7 @@ All file operations are **jailed to the worktree**. `archie.readFile("/etc/passw
|
||||
|
||||
### Reload cycle
|
||||
|
||||
Plugins are loaded fresh on every poll cycle — archie-core already fresh-clones per task. No hot-reload complexity, no cache invalidation. The worktree is the source of truth.
|
||||
Plugins are loaded fresh on every poll cycle -- archie-core already fresh-clones per task. No hot-reload complexity, no cache invalidation. The worktree is the source of truth.
|
||||
|
||||
For the rare case where a plugin errors at parse/transpile time, archie-core comments on the issue with the diagnostic and parks the task. The plugin author fixes the `.ts` file and requeues.
|
||||
|
||||
@@ -294,7 +294,7 @@ func (l *Loader) LoadPlugins(worktreeDir string) ([]Plugin, error) {
|
||||
dir := filepath.Join(worktreeDir, ".archie", "workflows")
|
||||
entries, err := os.ReadDir(dir)
|
||||
if os.IsNotExist(err) {
|
||||
return nil, nil // no plugins — not an error
|
||||
return nil, nil // no plugins -- not an error
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -388,7 +388,7 @@ goja natively supports ES5.1 with significant ES6 features. Modern syntax like `
|
||||
| Generators | ❌ not supported |
|
||||
| `Proxy` | ❌ not supported |
|
||||
|
||||
For gate scripts, this is fine — gates are synchronous by nature. If async is genuinely needed later, the Bun backend (via `tsgo`) is the escape hatch.
|
||||
For gate scripts, this is fine -- gates are synchronous by nature. If async is genuinely needed later, the Bun backend (via `tsgo`) is the escape hatch.
|
||||
|
||||
### Performance
|
||||
|
||||
@@ -417,7 +417,7 @@ Plugins can't `import` from npm or other files. They're self-contained modules.
|
||||
| **Plugin folder** | `.archie/workflows/` | `.archie/workflows/` |
|
||||
| **Best for** | Custom stages needing Go's stdlib, tight daemon integration | Custom gates and scripts where author familiarity matters |
|
||||
|
||||
**Recommendation: support both.** They solve different problems. Yaegi for repo owners who want full Go power in their custom stages. goja for repo owners who want to write gates and scripts in TypeScript. Both load from `.archie/workflows/` — archie-core discovers which engine to use by file extension (`.go` → Yaegi, `.ts` → goja+esbuild).
|
||||
**Recommendation: support both.** They solve different problems. Yaegi for repo owners who want full Go power in their custom stages. goja for repo owners who want to write gates and scripts in TypeScript. Both load from `.archie/workflows/` -- archie-core discovers which engine to use by file extension (`.go` → Yaegi, `.ts` → goja+esbuild).
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# archie-core Yaegi Plugin System — PRD
|
||||
# archie-core Yaegi Plugin System -- PRD
|
||||
|
||||
**Author:** Archie (Hermes agent)
|
||||
**Date:** 2026-07-21
|
||||
@@ -23,11 +23,11 @@ Embed the [Yaegi](https://github.com/traefik/yaegi) Go interpreter to let archie
|
||||
- "All public functions in `pkg/api/` must be documented"
|
||||
- "No `time.Sleep` in production code paths"
|
||||
|
||||
These are rules that need to read the diff, parse Go ASTs, or walk the worktree — things shell scripts can do but shouldn't have to.
|
||||
These are rules that need to read the diff, parse Go ASTs, or walk the worktree -- things shell scripts can do but shouldn't have to.
|
||||
|
||||
### Why not shell scripts?
|
||||
|
||||
Shell scripts for gates are fine until they're not. They can't import the archie-core types, can't use the Go parser, and are a second language to maintain alongside the daemon. Yaegi runs Go — the same language as the daemon, the same language as the repos archie-core works on.
|
||||
Shell scripts for gates are fine until they're not. They can't import the archie-core types, can't use the Go parser, and are a second language to maintain alongside the daemon. Yaegi runs Go -- the same language as the daemon, the same language as the repos archie-core works on.
|
||||
|
||||
### Why not Go's native `plugin` package?
|
||||
|
||||
@@ -37,7 +37,7 @@ Go's `plugin` package (`.so` files) requires:
|
||||
- No unload
|
||||
- Painful distribution
|
||||
|
||||
Yaegi interprets `.go` source files directly — no compilation step, portable everywhere, loads from filesystem paths.
|
||||
Yaegi interprets `.go` source files directly -- no compilation step, portable everywhere, loads from filesystem paths.
|
||||
|
||||
### Production precedent
|
||||
|
||||
@@ -52,7 +52,7 @@ Yaegi interprets `.go` source files directly — no compilation step, portable e
|
||||
|
||||
| Surface | Location | When loaded | What it does |
|
||||
|---|---|---|---|
|
||||
| **Custom gate functions** | `.archie/gate.go` | During the gate stage (after shell commands) | Returns `[]Finding` — each finding has severity, message, file, line |
|
||||
| **Custom gate functions** | `.archie/gate.go` | During the gate stage (after shell commands) | Returns `[]Finding` -- each finding has severity, message, file, line |
|
||||
| **Custom workflow stages** | `.archie/stages/<name>.go` | When the workflow references the stage name | Returns a `workflow.Stage` implementation |
|
||||
| **Skill scripts** | `.archie/skills/<skill>/scripts/*.go` | When the parent skill is activated | Called by the skill's instructions |
|
||||
|
||||
@@ -61,7 +61,7 @@ Yaegi interprets `.go` source files directly — no compilation step, portable e
|
||||
The most important extension surface. After the shell-based gate passes, archie-core loads and evaluates `.archie/gate.go` in the worktree directory. The script exposes a `Check` function:
|
||||
|
||||
```go
|
||||
// .archie/gate.go — per-repo gate rules interpreted at runtime
|
||||
// .archie/gate.go -- per-repo gate rules interpreted at runtime
|
||||
package gate
|
||||
|
||||
import (
|
||||
@@ -104,7 +104,7 @@ func Check(ctx GateContext) []Finding {
|
||||
if strings.Contains(line, "panic(") {
|
||||
findings = append(findings, Finding{
|
||||
Level: "error",
|
||||
Message: "new panic() call — use error returns instead",
|
||||
Message: "new panic() call -- use error returns instead",
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -124,7 +124,7 @@ func Check(ctx GateContext) []Finding {
|
||||
findings = append(findings, Finding{
|
||||
Level: "warn",
|
||||
File: f,
|
||||
Message: "time.Sleep in non-test code — use time.Ticker or context.WithTimeout instead",
|
||||
Message: "time.Sleep in non-test code -- use time.Ticker or context.WithTimeout instead",
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -205,7 +205,7 @@ Via `i.Use()`, the daemon pre-loads symbols that interpreted code can import:
|
||||
| `archie-core/internal/gate` | `GateContext`, `Finding`, `Block` |
|
||||
| `stdlib` | Full Go standard library (stdlib.Symbols) |
|
||||
|
||||
Generated with `yaegi extract` — same approach Traefik and Vikunja use. A `//go:generate yaegi extract ...` line in the source triggers symbol table generation during `go generate`.
|
||||
Generated with `yaegi extract` -- same approach Traefik and Vikunja use. A `//go:generate yaegi extract ...` line in the source triggers symbol table generation during `go generate`.
|
||||
|
||||
---
|
||||
|
||||
@@ -213,10 +213,10 @@ Generated with `yaegi extract` — same approach Traefik and Vikunja use. A `//g
|
||||
|
||||
From Yaegi's own docs:
|
||||
- **No assembly files** (`.s` not supported)
|
||||
- **No CGo** (can't call C code — the daemon is pure Go, so this doesn't matter)
|
||||
- **No compiler/linker directives** (no `//go:embed`, etc. — fine for gate scripts)
|
||||
- **Interfaces from pre-compiled code can't be added dynamically** — the daemon must pre-compile wrapper types for any interface interpreted code needs to implement
|
||||
- **Slower than compiled code** — gate scripts run once per commit, not in hot paths; negligible impact
|
||||
- **No CGo** (can't call C code -- the daemon is pure Go, so this doesn't matter)
|
||||
- **No compiler/linker directives** (no `//go:embed`, etc. -- fine for gate scripts)
|
||||
- **Interfaces from pre-compiled code can't be added dynamically** -- the daemon must pre-compile wrapper types for any interface interpreted code needs to implement
|
||||
- **Slower than compiled code** -- gate scripts run once per commit, not in hot paths; negligible impact
|
||||
|
||||
The Vikunja PR documents a specific Yaegi quirk: **typed factory functions required.** You can't do `v.Interface().(MyInterface)` on a value returned from interpreted code. Each interface needs its own factory:
|
||||
|
||||
@@ -229,31 +229,31 @@ func NewReportable() Reportable { return &MyGate{} }
|
||||
|
||||
## Implementation phases
|
||||
|
||||
### Phase 1: Gate functions — implemented
|
||||
### Phase 1: Gate functions -- implemented
|
||||
- `yaegi` added as a dependency
|
||||
- Symbol table for `GateContext`, `Finding` generated via `yaegi extract` into `internal/gate/gateextract` (a separate package from `internal/gate` itself, avoiding the self-import cycle extracting a package's own symbols creates)
|
||||
- `internal/gate/gateeval.Evaluate`: loads `.archie/gate.go` from the worktree, interprets it, calls `Check()`; panics are recovered
|
||||
- Wired in as `workflow.StageYaegiGate`, run after the final commit in both the `implement` and `tdd` workflows
|
||||
- Error findings park the task; warn findings are logged only
|
||||
|
||||
### Phase 2: Custom stages — implemented
|
||||
### Phase 2: Custom stages -- implemented
|
||||
- Symbol table for `workflow.Stage`/`TaskContext`/`Outcome` generated into `internal/workflow/wfextract`
|
||||
- `internal/workflow/wfeval.Discover` scans `.archie/stages/*.go` in filename order and calls each file's exported `Stage()` function
|
||||
- `TaskContext.CustomStages` is an injected `func(dir string) ([]Stage, error)` — the composition root (`cmd/archied`) wires it to `wfeval.Discover`, keeping `internal/workflow` decoupled from its own generated symbol table
|
||||
- `TaskContext.CustomStages` is an injected `func(dir string) ([]Stage, error)` -- the composition root (`cmd/archied`) wires it to `wfeval.Discover`, keeping `internal/workflow` decoupled from its own generated symbol table
|
||||
- `workflow.StageRepoStages` runs discovered stages in order right after the worktree is prepared, in both `implement` and `tdd`
|
||||
- Simplification vs. the original sketch: stages are auto-discovered and always run (like `.archie/gate.go`) rather than referenced by name from `config.toml` — the workflow engine has no data-driven stage graph today, so wiring arbitrary named stages into arbitrary positions would need a larger config-driven rework. Auto-run-in-order covers the PRD's actual use case (a repo-defined pre-flight/setup hook) without it.
|
||||
- Simplification vs. the original sketch: stages are auto-discovered and always run (like `.archie/gate.go`) rather than referenced by name from `config.toml` -- the workflow engine has no data-driven stage graph today, so wiring arbitrary named stages into arbitrary positions would need a larger config-driven rework. Auto-run-in-order covers the PRD's actual use case (a repo-defined pre-flight/setup hook) without it.
|
||||
|
||||
### Phase 3: Skill scripts — implemented
|
||||
### Phase 3: Skill scripts -- implemented
|
||||
- `internal/skillscript.Run` interprets a `.go` file via `i.EvalPath`, which (like `go run`) evaluates and calls its `main()`; stdout/stderr are captured via `interp.Options`
|
||||
- Uses `stdlib.Symbols` + `stdlib/unrestricted.Symbols` (not just `stdlib`) — `os/exec` lives in the unrestricted set, and the PRD's own example script shells out via `os/exec`
|
||||
- No archie-core-specific symbol table needed here — skill scripts only touch the Go standard library
|
||||
- Uses `stdlib.Symbols` + `stdlib/unrestricted.Symbols` (not just `stdlib`) -- `os/exec` lives in the unrestricted set, and the PRD's own example script shells out via `os/exec`
|
||||
- No archie-core-specific symbol table needed here -- skill scripts only touch the Go standard library
|
||||
- Exposed to the agent loop as a new `run_go_script` tool (`internal/agentexec/inprocess.go`), available in every agent stage; path is validated to stay inside the workspace
|
||||
- This is how "the skill's instructions reference a script" cashes out concretely: the agent calls `run_go_script` with the path instead of needing a Go toolchain in the sandbox
|
||||
|
||||
### Phase 4: Hot reload — not needed, by construction
|
||||
- All three loaders (`gate.Evaluate`, `wfeval.Discover`, `skillscript.Run`) read their `.go` source from disk on every call — no in-memory cache exists anywhere in the implementation
|
||||
### Phase 4: Hot reload -- not needed, by construction
|
||||
- All three loaders (`gate.Evaluate`, `wfeval.Discover`, `skillscript.Run`) read their `.go` source from disk on every call -- no in-memory cache exists anywhere in the implementation
|
||||
- Every task additionally gets a fresh `git clone` (`worktree.Manager.Prepare` removes and re-clones the worktree directory per task)
|
||||
- Consequently every stage already re-reads `.archie/gate.go`, `.archie/stages/*.go`, and skill scripts fresh, every run — there is no stale state a file watcher would ever need to invalidate
|
||||
- Consequently every stage already re-reads `.archie/gate.go`, `.archie/stages/*.go`, and skill scripts fresh, every run -- there is no stale state a file watcher would ever need to invalidate
|
||||
- A file-watching daemon-runtime reload mechanism would add machinery with nothing to do given this architecture; revisit only if the daemon starts reusing long-lived worktrees across tasks
|
||||
|
||||
---
|
||||
@@ -262,6 +262,6 @@ func NewReportable() Reportable { return &MyGate{} }
|
||||
|
||||
1. **Symbol table generation:** Run `yaegi extract` as a `go generate` step, or generate on daemon startup?
|
||||
2. **Error handling:** If the interpreted gate panics or times out, park the task? Or fall back to shell-only gate?
|
||||
3. **Budget:** Interpreted gate scripts run in the gate stage — should they have their own timeout/step budget?
|
||||
3. **Budget:** Interpreted gate scripts run in the gate stage -- should they have their own timeout/step budget?
|
||||
4. **Template system:** Should archie-core ship with common gate templates (e.g. `go: no panic, no Sleep, no hardcoded paths`)?
|
||||
5. **Remote gates:** Could `.archie/gate.go` be pulled from a shared remote registry, like skills?
|
||||
Reference in new issue
Block a user