Commit graph

219 commits

Author SHA1 Message Date
Snider
4bcc04d890 feat(monitor): agent.started + agent.complete channel notifications
- emitStartEvent fires when agent spawns (dispatch.go)
- Monitor detects new "running" workspaces and pushes agent.started
  channel notification with repo and agent info
- agent.complete already included blocked/failed status — no change
- Both old and new workspace layouts supported

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 15:45:32 +00:00
Snider
abe5ef342a fix(monitor): scan new workspace layout for channel notifications
workspaceStatusPaths scans both old (*/status.json) and new
(*/*/*/status.json) workspace layouts. Fixes agent.complete
channel notifications not firing for org/repo/identifier paths.

Replaces filepath.Glob with core.PathGlob in harvest.go.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 15:45:32 +00:00
Snider
69f0acce0d fix(dispatch): model flag splice broke -o argument ordering
When model variant was specified, the splice inserted --model
between -o and its value, making Codex see -o with no file path.
Fixed by appending --model and prompt sequentially instead of
splicing into the middle of the args slice.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 15:45:16 +00:00
Snider
c73ea6ad7a fix(dispatch): strip model variant from log filename
Agent name like "codex:gpt-5.3-codex-spark" contains a colon which
breaks file paths. Use base name (before ":") for the log file.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 15:45:16 +00:00
Snider
d6864eb37c feat(dispatch): QA gate before auto-PR
After agent completes, run build + vet + test before creating PR.
If QA fails, mark workspace as failed with "QA check failed" —
bad code never gets PR'd.

Supports Go (build/vet/test), PHP (composer install/test),
and Node (npm install/test). Unknown languages pass through.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 15:45:16 +00:00
Snider
7e30f336cc feat(devops): 13 CLI-backed skills for forge, workspace, and diagnostics
Thin skill wrappers over core-agent CLI commands:
- workspace-list, workspace-clean
- issue-get, issue-list, issue-comment
- pr-get, pr-list, pr-merge
- repo-get, repo-list
- build-prompt, health-check

Each skill calls core-agent directly — no raw API calls,
no remembering flags. Edge cases fixed in the skill.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 15:45:16 +00:00
Snider
f416948660 feat: workspace CLI commands — list, clean, dispatch stub
workspace/list shows all workspaces with status/agent/repo.
workspace/clean removes completed/failed/blocked/merged workspaces.
workspace/dispatch stub for future CLI-driven dispatch.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 15:45:16 +00:00
Snider
7f84ac8348 refactor(agentic): use go-forge library instead of raw HTTP
Replace raw http.Client calls with go-forge typed API:
- prep.go: getIssueBody via forge.Issues.Get, pullWikiContent
  via forge.Wiki.ListPages/GetPage
- pr.go: forgeCreatePR via forge.Pulls.Create, commentOnIssue
  via forge.Issues.CreateComment, listRepoPRs via forge.Pulls.ListAll
- scan.go: listOrgRepos via forge.Repos.ListOrgRepos

Eliminates manual JSON marshalling, auth headers, pagination loops,
and anonymous struct declarations. One Forge client, one auth,
type-safe responses.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 15:45:16 +00:00
Snider
bfe70871a2 feat: Forge CLI commands — issue, PR, and repo operations
New commands via go-forge library:
  issue/get, issue/list, issue/comment
  pr/get, pr/list, pr/merge
  repo/get, repo/list

Enables CLI-driven Forge interaction for dispatch automation.
Agent can now read issues, create PRs, merge, and list repos
without MCP.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 15:45:16 +00:00
Snider
6e03287178 refactor(agentic): workspace = clone, prompt replaces files
Major simplification of the dispatch model:
- Workspace dir: .core/workspace/{org}/{repo}/{pr|task|branch|tag}/
- Clone into repo/ (not src/), metadata in .meta/
- One of issue, pr, branch, or tag required for dispatch
- All context (brain, consumers, git log, wiki, plan) assembled
  into prompt string — no TODO.md, PROMPT.md, CONTEXT.md files
- Resume detection: skip clone if repo/.git exists
- Default agent changed to codex
- spawnAgent drops srcDir param, runs from repo/
- No --skip-git-repo-check (repo/ IS a git repo)
- All downstream files: srcDir → repoDir

Track PRs, not workspace iterations.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 15:45:16 +00:00
Snider
6e37bd22f0 feat: devops plugin, CLI commands, Codex dispatch fixes, AX sweep
DevOps plugin (5 skills):
- install-core-agent, repair-core-agent, merge-workspace,
  update-deps, clean-workspaces

CLI commands: version, check, extract for diagnostics.

Codex dispatch: --skip-git-repo-check, removed broken
--model-reasoning-effort, --sandbox workspace-write via
--full-auto. Workspace template extracts to wsDir not srcDir.

AX sweep (Codex-generated): sanitise.go extracted from prep/plan,
mirror.go JSON parsing via encoding/json, setup/config.go URL
parsing via net/url, strings/fmt imports eliminated from setup.

CODEX.md template updated with Env/Path patterns.
Review workspace template with audit-only PROMPT.md.
Marketplace updated with devops plugin.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 15:45:16 +00:00
Snider
98baa1b08f feat: inline tests + Fs zero-value fix + coverage 76.9% → 82.3%
Move all tests from tests/ to package root for proper coverage.
Fix Fs zero-value: path() and validatePath() default empty root
to "/" so &Fs{} works without New().

New tests: PathGlob, PathIsAbs, CleanPath, Cli.SetOutput,
ServiceShutdown, Core.Context, Fs zero-value, Fs protected
delete, Command lifecycle with implementation, error formatting
branches, PerformAsync completion/no-handler/after-shutdown,
Extract with templates, Embed path traversal.

Coverage: 76.9% → 82.3% (23 test files, 82 new test cases).

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 15:45:04 +00:00
7f87e4d52c Merge pull request '[agent/codex] Fix ALL high-severity AX findings in pkg/monitor/ (monitor.g...' (#10) from agent/fix-all-high-severity-ax-findings-in-pkg into dev 2026-03-22 13:41:29 +00:00
Snider
9aac4c19dd refactor(monitor): adopt core helpers
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 13:40:14 +00:00
850ff4bc03 Merge pull request '[agent/codex] Fix ALL AX findings in pkg/brain/direct.go. Read CODEX.md. O...' (#9) from agent/fix-all-ax-findings-in-pkg-brain-direct into dev 2026-03-22 13:03:19 +00:00
Snider
ed842122a2 fix(brain): resolve direct AX findings
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 13:02:37 +00:00
Snider
a422eb1b6b feat(lib): add go.work.tmpl to workspace template
Codex agents are sandboxed to src/ and don't get ~/Code/go.work.
This template creates a go.work with `use .` so the Go toolchain
works in workspace mode inside the sandbox.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 10:18:57 +00:00
Snider
6393bfe4da refactor(agentic): adopt core.Env() + core.Path() across package
Replace all os.UserHomeDir/os.Getenv/os.Hostname with core.Env().
Replace all filepath.Base/Dir/Glob/IsAbs with core.PathBase/PathDir/
PathGlob/PathIsAbs.

10 files migrated: paths, prep, review_queue, remote, dispatch,
ingest, mirror, plan, verify, watch.

Imports eliminated: 5x os, 7x filepath. All file I/O and path
construction now routes through Core primitives.

Bumps dappco.re/go/core to v0.6.0.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 10:15:15 +00:00
Snider
3022f05fb8 refactor(agentic): route file I/O through core.Fs
Replace raw os.* file operations with Core Fs equivalents:
- os.Stat → fs.Exists/fs.IsFile/fs.IsDir (resume, pr, plan, mirror, prep)
- os.ReadDir → fs.List (queue, status, plan, mirror, review_queue)
- os.Remove → fs.Delete (dispatch)
- os.OpenFile(append) → fs.Append (events, review_queue)
- strings.Replace → core.Replace (scan)

Eliminates os import from resume.go, pr.go. Eliminates strings
import from scan.go. Trades os for io in events.go.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 09:08:45 +00:00
Snider
ede5d6f561 feat(lib): migrate to Core Embed system with Result returns
- All public functions return core.Result instead of (string, error)
- Mount scopes basedir — no path prefix needed in ReadString calls
- Add Bundle struct replacing (string, map, error) anti-pattern
- listDir takes *core.Embed not embed.FS
- ListTasks/ListPersonas use FS() + BaseDirectory() for WalkDir
- Remove bytes, os, text/template imports
- 22 tests: Prompt, Task, TaskBundle, Flow, Persona, Template,
  List functions, ExtractWorkspace (Good/Bad patterns)

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 09:08:35 +00:00
Snider
3c5e6d6498 fix(lib): ExtractWorkspace now recurses into subdirectories
Was skipping directories entirely (`if entry.IsDir() { continue }`),
so .core/reference/ and its contents were never extracted.
Replaced fs.ReadDir loop with fs.WalkDir to handle nested dirs.

Added tests: CreatesFiles, CreatesSubdirectories, TemplateSubstitution.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 08:10:56 +00:00
Snider
e8ca0d856f feat(lib): embed Core documentation in workspace template
18 doc files from core/go/docs — getting-started, primitives,
services, commands, configuration, errors, lifecycle, messaging,
subsystems, testing. Agents can read full Core documentation
without network access.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 07:19:20 +00:00
Snider
5417f547ca feat(lib): add Core struct reference to CODEX.md template
Documents all subsystem accessors (App, Fs, Config, Data, Drive, Log,
Error, Cli, IPC, I18n, Options, Context), service lifecycle with
Startable/Stoppable interfaces, error logging (LogError/LogWarn/Must),
and async tasks (Perform/PerformAsync/Progress).

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 07:17:27 +00:00
Snider
71ee6124b7 feat(lib): complete CODEX.md with all Core patterns
Added: Embed/Mount/Extract, error wrapping/codes/introspection,
Print, Array[T], Config, IPC (Action/Query/Perform), Services,
Commands, Drive, I18n. Every Core primitive documented with
WRONG/CORRECT examples.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 07:15:20 +00:00
Snider
99e1d06fda feat(lib): add CODEX.md template to default workspace
Inline instructions for Codex agents — no spec references,
just the actual rules with code examples. Extracted into every
workspace automatically.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 07:13:12 +00:00
Snider
b9c30138fb fix(lib): rename .gitignore to .gitignore.tmpl in workspace template
Prevents git from ignoring template contents. ExtractWorkspace strips
the .tmpl suffix during extraction.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 07:02:32 +00:00
Snider
6f5b239da6 feat(lib): embed AX spec + Core source in default workspace template
Reference files (.core/reference/) are now part of the embedded
workspace template. ExtractWorkspace extracts them automatically —
no hardcoded filesystem paths, ships with the binary.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 06:59:52 +00:00
Snider
4f66eb4cca fix: resolve final AX audit findings
- cmd/main.go: keyed core.Result literals (go vet clean)
- pkg/brain/direct.go: compile-time mcp.Subsystem assertion
- pkg/monitor/monitor.go: compile-time Subsystem + CompletionNotifier assertions
- pkg/agentic/prep.go: alias stdlib io as goio
- pkg/agentic/remote_client.go: UK English (initialise/initialised)
- pkg/monitor/monitor_test.go: updated inbox tests for current contract

AX audit now returns 0 convention findings.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 06:42:42 +00:00
Snider
7873e0ebf7 feat: add Codex extension — agents, skills, rules, config
Parallel to the Claude Code plugin (claude/), core-agent now supports
Codex with full feature parity:

- .codex/config.toml — model, profiles (review/quick/implement/lem),
  MCP server, local model providers (Ollama/LM Studio)
- .codex/agents/ — reviewer, migrator, fixer (AX-aware)
- .codex/rules/ — Starlark rules for sandbox control
- .agents/skills/ — 9 skills matching Claude plugin
- AGENTS.md — Codex project instructions (like CLAUDE.md)

Supports --oss mode for local models (LEM via Ollama).
Same binary, two entry points.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 06:20:59 +00:00
Snider
a0dc9c32e7 refactor: migrate core/agent to Core primitives — reference implementation
Phase 1: go-io/go-log → core.Fs{}, core.E(), core.Error/Info/Warn
Phase 2: strings/fmt → core.Contains, core.Sprintf, core.Split etc
Phase 3: embed.FS → core.Mount/core.Embed, core.Extract
Phase 4: cmd/main.go → core.Command(), c.Cli().Run(), no cli package

All packages migrated:
- pkg/lib (Codex): core.Mount, core.Extract, Result returns, AX comments
- pkg/setup (Codex): core.Fs, core.E, fixed missing lib helpers
- pkg/brain (Codex): Core primitives, AX comments
- pkg/monitor (Codex): Core string/logging primitives
- pkg/agentic (Codex): 20 files, Core primitives throughout
- cmd/main.go: pure Core CLI, no fmt/log/filepath/strings/cli

Remaining stdlib: path/filepath (Core doesn't wrap OS paths),
fmt.Sscanf/strings.Map (no Core equivalent).

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 06:13:41 +00:00
Snider
6db0110b6f refactor(brain): consolidate newFs and agentName wrappers
Remove duplicated newFs() from brain package — use agentic.LocalFs() instead.
Inline agentName() wrapper — call agentic.AgentName() directly.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 03:47:08 +00:00
Snider
b266db5069 fix(pkg): address code review findings
- Fix import ordering in verify.go and remote_client.go (stdlib before third-party)
- Convert os.MkdirAll to fs.EnsureDir in prep.go
- Preserve underlying error in !r.OK branches (writeStatus, writePlan, planDelete, planList, resume)

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 03:45:50 +00:00
Snider
0f0764ff59 fix(agentic): update auto_pr.go to use exported DefaultBranch
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 03:43:17 +00:00
Snider
deaa06a54d refactor(pkg): migrate go-io/go-log to Core primitives
Replace separate go-io (coreio) and go-log (coreerr) packages with
Core's built-in Fs and error/logging functions. This is the reference
implementation for how all Core ecosystem packages should migrate.

Changes:
- coreio.Local.Read/Write/EnsureDir/Delete/IsFile → core.Fs methods
- coreerr.E() → core.E(), coreerr.Info/Warn/Error → core.Info/Warn/Error
- (value, error) return pattern → core.Result pattern (r.OK, r.Value)
- go-io and go-log moved from direct to indirect deps in go.mod
- Added AX usage-example comments on key public types
- Added newFs("/") helper for unrestricted filesystem access

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 03:41:07 +00:00
Snider
52c3e67692 fix(plugin): rename CoreAgent→core, CorePHP→core-php
Plugin names must match their directory/reference names.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 02:22:26 +00:00
162c2beeab Merge pull request 'chore: dappco.re migration + plugin version bump' (#5) from dev into main
Some checks failed
CI / test (push) Failing after 4s
2026-03-22 02:17:42 +00:00
Snider
0be5791fc4 chore: bump core-research plugin to 0.3.0
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 02:15:39 +00:00
Snider
3c49620548 chore: bump plugin version to 0.14.0
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 02:14:36 +00:00
Snider
c6490c175a refactor: migrate imports to dappco.re paths + bump mcp to v0.4.0
Update all go-* imports from forge.lthn.ai to dappco.re/go/core/*.
Bump mcp to v0.4.0 (Options{} struct API).
Versions: core v0.5.0, io v0.2.0, log v0.1.0, process v0.3.0,
ws v0.3.0, ai v0.2.0, webview v0.2.0, i18n v0.2.0.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 01:27:48 +00:00
94af637411 Merge pull request '[agent/claude] Write tests for /pkg/monitor/ to reach 80% coverage. Current...' (#2) from agent/write-tests-for--pkg-monitor--to-reach-8 into main
Some checks failed
CI / test (push) Failing after 2s
2026-03-22 00:46:00 +00:00
Snider
2d58145e65 test(monitor): add unit tests for completions, inbox, lifecycle
Cover checkCompletions, checkInbox, syncRepos, loop, Poke,
Start/Shutdown, New, initSyncTimestamp, and agentStatusResource.
Mock HTTP endpoints with httptest, use t.TempDir for workspace
scanning, and create fake status.json files for completions.

Also fix dispatch.go build error (removed unsupported RunOptions
fields: KillGroup, Timeout, GracePeriod).

Coverage: 23.2% → 86.5%

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-22 00:45:43 +00:00
ddaf950654 Merge pull request '[agent/claude] Write tests for /pkg/agentic/ to improve coverage. Current c...' (#4) from agent/write-tests-for--pkg-agentic--to-improve into main
Some checks are pending
CI / test (push) Waiting to run
2026-03-22 00:45:19 +00:00
e2d26dccc1 Merge pull request '[agent/claude] Write tests for /pkg/brain/ to reach 80% coverage. Current c...' (#3) from agent/write-tests-for--pkg-brain--to-reach-80 into main
Some checks are pending
CI / test (push) Waiting to run
2026-03-22 00:45:08 +00:00
Snider
05f120b166 Merge remote-tracking branch 'github/dev'
Some checks failed
CI / test (push) Failing after 3s
2026-03-22 00:29:11 +00:00
Snider
ddf765dee1 fix(dispatch): use correct Codex CLI flags (exec --full-auto)
Some checks failed
CI / test (push) Failing after 3s
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-21 21:26:13 +00:00
Snider
5393828ac6 feat(monitor): include message content in inbox channel events
Some checks failed
CI / test (push) Failing after 3s
inbox.message events now include full message objects (id, from,
subject, content) so recipients can read messages inline without
calling agent_inbox. Charon's messages arrive directly in session.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-21 20:08:13 +00:00
Snider
81806e5dcc chore: plugin v0.13.0, research v0.2.0, marketplace naming + MONITOR_INTERVAL
Some checks failed
CI / test (push) Failing after 3s
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-21 20:01:51 +00:00
Snider
0fda800e8b chore(monitor): remove debug logging from check cycle
Some checks failed
CI / test (push) Failing after 3s
Debug channel events and stderr logging removed — monitor runs
silently unless something actually happens. Only real events
(agent.complete, inbox.message, harvest.complete) fire now.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-21 19:42:38 +00:00
Snider
5a234c1179 fix(monitor): seed completions on startup, suppress initial flood
Some checks failed
CI / test (push) Failing after 3s
Both checkCompletions and checkInbox now seed on first run —
existing workspaces and messages are recorded without firing
channel events. Only genuinely new events trigger notifications.

Tests updated to pre-seed flags and filter debug events.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-21 19:38:03 +00:00
Snider
36dc76cce1 feat(monitor): ID-based inbox detection + channels fully working
Some checks failed
CI / test (push) Failing after 3s
Track inbox by highest message ID instead of unread count. Fixes:
- API pagination limit (max 20) no longer causes missed notifications
- Restart no longer floods with all existing unread messages (seeded)
- Each new message fires exactly once regardless of read state

Added MONITOR_INTERVAL env override and debugChannel helper for
faster iteration during channel development.

All three channel types confirmed working:
- agent.complete: workspace status changes
- inbox.message: new messages by ID tracking
- monitor.debug: real-time debug trace

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-21 19:31:11 +00:00