Commit graph

28 commits

Author SHA1 Message Date
Snider
e66ea0512b fix: address re-review findings — nil pointer, races, curl, clone error
Important:
- Fix nil pointer dereference on resp.StatusCode when err!=nil (8 sites)
- Replace curl shell-out with net/http in monitor inbox check
- Handle clone failure in prep.go (was silently swallowed)
- Use GitHubOrg() instead of hardcoded "dAppCore"

Medium:
- Fix JSONL append race (read+write → os.OpenFile O_APPEND)
- Remove dead google/mcp/ directory

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 19:27:44 +00:00
Snider
6d04c893b7 fix: address all code review findings (medium + low)
- os.ReadFile/WriteFile → coreio.Local in monitor and remote packages
- Deduplicate agentName() → shared agentic.AgentName()
- Deduplicate workspaceRoot() → shared agentic.WorkspaceRoot()
- fileExists uses IsFile() instead of reading whole file
- Fix SPDX-Licence → SPDX-License typo
- Remove time.Now import hack
- Fix hardcoded PR #1 in review queue

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 19:19:04 +00:00
Snider
4832827da7 fix: address code review findings (critical + high)
Critical:
- Fix token leaked in URL query string (getLabelID) — now uses Authorization header
- Fix unchecked type assertion panic in parseMessages — safe toInt() helper

High:
- Remove dead canDispatch() function
- Remove time.Now import hack from mirror.go
- Remove invalid --no-force git flag from mirror.go
- Tidy go.mod (remove unused deps from deleted packages)

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 19:12:06 +00:00
Snider
7248928545 refactor: remove 28K lines of dead/legacy code
Removed:
- pkg/loop/ — superseded by Claude native tool use
- pkg/lifecycle/ — 14K lines, old PHP API polling client
- pkg/jobrunner/ — old CodeRabbit orchestration (rebuilt in verify.go)
- pkg/orchestrator/ — old AgentCI config (replaced by agents.yaml)
- pkg/workspace/ — empty stub
- pkg/plugin/ — empty stub
- cmd/agent/ — old fleet management CLI
- cmd/dispatch/ — old polling dispatcher
- cmd/workspace/ — unused CLI
- cmd/tasks/ — unused CLI
- cmd/taskgit/ — unused CLI

120 files deleted, 28,780 lines removed.
Remaining: 31 Go files, 6,666 lines — cmd/core-agent + pkg/agentic + pkg/brain + pkg/monitor.

All functionality preserved in the new MCP-native architecture.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 19:06:03 +00:00
Snider
742ca0799f fix: remove all hardcoded machine paths from Go code
- orchestrator: queue dir uses CoreRoot()/queue
- cmd/agent: queue dir resolved by config, not hardcoded
- cmd/workspace: specs path uses ~/Code/specs (no host-uk)
- Zero remaining /home/claude or host-uk references in Go

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 19:00:47 +00:00
Snider
327d78d08f fix: config search uses CoreRoot() — ~/Code/.core/agents.yaml
Config now found at:
1. ~/Code/.core/agents.yaml (shared, portable)
2. ~/Code/core/agent/config/agents.yaml (repo fallback)

Both Cladius and Charon find the same config.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 18:57:02 +00:00
Snider
e677d15bdd fix: remove hardcoded paths, gitignore binaries
- Add paths.go with WorkspaceRoot(), CoreRoot(), PlansRoot()
- All workspace paths now check CORE_WORKSPACE env var first
- Fallback: ~/Code/.core/workspace (works on any machine)
- Remove committed core-agent and mcp binaries from tracking
- Add .gitignore for compiled binaries

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 18:13:44 +00:00
Snider
90b03191b2 feat(agent): v0.2.0 — HTTP daemon, remote dispatch, review queue, verify+merge
Major additions:
- core-agent serve: persistent HTTP daemon with PID file, health check, registry
- agentic_dispatch_remote: dispatch tasks to remote agents (Charon) over MCP HTTP
- agentic_status_remote: check remote agent workspace status
- agentic_mirror: sync Forge repos to GitHub mirrors with file count limits
- agentic_review_queue: CodeRabbit/Codex review queue with rate-limit awareness
- verify.go: auto-verify (run tests) + auto-merge + retry with rebase + needs-review label
- monitor sync: checkin API integration for cross-agent repo sync
- PostToolUse inbox notification hook (check-notify.sh)

Dispatch improvements:
- --dangerously-skip-permissions (CLI flag changed)
- proc.CloseStdin() after spawn (Claude CLI stdin pipe fix)
- GOWORK=off in agent env and verify
- Exit code / BLOCKED.md / failure detection
- Monitor poke for instant notifications

New agent types:
- coderabbit: CodeRabbit CLI review (--plain --base)
- codex:review: OpenAI Codex review mode

Integrations:
- CODEX.md: OpenAI Codex conventions file
- Gemini extension: points at core-agent MCP (not Node server)
- Codex config: core-agent MCP server added
- GitHub webhook handler + CodeRabbit KPI tables (PHP)
- Forgejo provider for uptelligence webhooks
- Agent checkin endpoint for repo sync

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 17:45:04 +00:00
Snider
c639a848c2 fix: PID polling fallback for process completion detection
proc.Wait() hangs when Claude Code's child processes inherit pipes.
Added PID polling every 5s — when the main process is dead (Signal(0)
fails), force completion even if pipes are still open.

Fixes: empty agent logs, missing completion events, stuck queue drain.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 05:56:22 +00:00
Snider
ccfd68ca1a feat: fire resource subscription notification on agent status change
Monitor now calls Server.ResourceUpdated() for status://agents when
agent completions or inbox changes are detected. Clients subscribed
to this resource get notified automatically via MCP protocol.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 05:52:12 +00:00
Snider
0ca253fe68 feat: add monitor subsystem — background ecosystem watcher
Runs every 2 minutes while MCP server is active:
- Checks for newly completed agent workspaces
- Checks inbox for unread messages
- Pushes notifications via ServerSession.Log() to connected clients

Also registers status://agents resource for on-demand workspace status.

The MCP connection is bidirectional — monitor uses it to actively
notify rather than waiting for tool calls.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 05:37:57 +00:00
Snider
132ade1765 feat: add agentic_watch tool with MCP progress notifications
Watches running/queued agent workspaces until all complete.
Sends progress notifications via MCP protocol as each agent finishes.
Returns summary with completed/failed counts and PR URLs.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 04:31:19 +00:00
Snider
71decc26b2 feat: auto-create PR on Forge after agent completion
When a dispatched agent completes with commits:
1. Branch name threaded through PrepOutput → status.json
2. Completion goroutine pushes branch to forge
3. Auto-creates PR via Forge API with task description
4. PR URL stored in status.json for review

Agents now create PRs instead of committing to main. Combined
with sandbox restrictions, this closes the loop on controlled
agent contributions.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 04:19:48 +00:00
Snider
da1c45b4df feat: sandbox dispatched agents to workspace directory
Three-layer sandboxing:
1. --append-system-prompt with SANDBOX boundary instructions
2. PROMPT.md templates include SANDBOX BOUNDARY (HARD LIMIT) section
3. Agent starts in src/ with only cloned repo visible

Agents are instructed to reject absolute paths, cd .., and any
file operations outside the repository. Violations cause work rejection.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 04:12:54 +00:00
Snider
58749c87f8 feat: agent completion events + plugin hooks
spawnAgent() now writes completion events to events.jsonl.
Plugin hooks check for completions on:
- SessionStart: report agents that finished since last session
- Notification(idle_prompt): check when Claude is idle

Event format: {"type":"agent_completed","agent":"...","workspace":"...","timestamp":"..."}

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 03:05:26 +00:00
Snider
5eb26f90fc refactor: replace fmt.Errorf/os.* with go-io/go-log conventions
Replace all fmt.Errorf and errors.New in production code with
coreerr.E("caller.Method", "message", err) from go-log. Replace
all os.ReadFile/os.WriteFile/os.MkdirAll/os.Remove with coreio.Local
equivalents from go-io. Test files are intentionally untouched.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-16 21:48:31 +00:00
Snider
42788a2a88 refactor(dispatch): use go-process for agent spawning
Replace raw exec.Command with go-process.StartWithOptions for all agent
spawning (dispatch, queue, resume). Uses pipes for output capture instead
of file descriptor redirect — fixes Claude Code's empty log issue.

Shared spawnAgent() helper eliminates duplication across 3 files.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-16 17:52:55 +00:00
Snider
267a5e5e6d fix(dispatch): use --output-format text for claude agent logging
Claude -p output wasn't reaching the log file. Explicitly set
--output-format text, --permission-mode bypassPermissions (replaces
deprecated flag), and --no-session-persistence for ephemeral workers.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-16 17:37:58 +00:00
Snider
5f83cf902a fix: messaging routes use auth.api, fix InboxInput schema
- Remove messaging routes from core/agent (conflict with AgentApiAuth)
- Routes now only in host app with auth.api middleware (same as brain)
- Add Agent field to InboxInput so MCP schema isn't empty

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-16 15:11:10 +00:00
Snider
37f6d61368 feat: agent messaging — direct chronological messages between agents
New: agent_send, agent_inbox, agent_conversation MCP tools.
API: /v1/messages/send, /v1/messages/inbox, /v1/messages/conversation/{agent}
Model: AgentMessage with inbox, unread, conversation scopes.

Separate channel from semantic brain search. Messages are chronological,
not vector-searched. Agents can now have direct conversations.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-16 14:03:36 +00:00
Snider
85dd0555ac fix(brain): shared brain — don't filter by agent_id on recall
Was forcing agent isolation. Now all agents see all memories by default.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-16 11:50:20 +00:00
Snider
5fbaf4f211 fix(brain): use hostname-based agent_id instead of hardcoded cladius
Charon gets agent_id 'charon', Cladius gets 'cladius'.
Override with AGENT_NAME env var.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-16 11:24:59 +00:00
Snider
2ea50959f2 refactor: move brain + agentic packages into core/agent, use core/cli
Brain and agentic subsystems now live in core/agent/pkg/ instead of
core/mcp/pkg/mcp/. core-agent binary uses core/cli for proper command
framework. Usage: core-agent mcp

One repo, one clone, everything works.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-16 11:10:33 +00:00
Snider
6442cb85ad refactor: update import path from go-config to core/config
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-14 10:22:39 +00:00
Snider
e894cd3a7a refactor: update MCP import to core/mcp
Change forge.lthn.ai/core/go-ai/mcp → forge.lthn.ai/core/mcp/pkg/mcp.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 18:40:52 +00:00
Snider
5e0a18a110 test: add Claude plugin contract verification suite
18 tests validate the full plugin contract before tagging:
- Marketplace: valid JSON, required fields, unique names, versions
- Plugins: directory exists, manifest present, version consistency
- Commands: .md format, YAML frontmatter with name:
- Hooks: valid events, scripts exist + executable
- Scripts: executable, shebangs present
- Skills: SKILL.md present, scripts executable
- Cross-refs: all claude/ dirs listed in marketplace

fix: chmod +x on 8 skill scripts caught by contract tests

Co-Authored-By: Virgil <virgil@lethean.io>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 16:06:05 +00:00
Snider
c7c181ccf8 test: add contract verification for php-devops wishlist
18 tests verify the full workspace contract is implemented:
- repos.yaml: loads, required fields, valid types, deps exist,
  topological order, foundations, defaults, meta clone rules, domains
- workspace.yaml: loads, active package in registry
- .core/ folder: exists, has spec doc
- Scripts: setup.sh exists+executable, install scripts exist
- Plugins: marketplace.json exists, all plugins have manifests

Enables archival of core/php-devops and core/go-agent.

Co-Authored-By: Virgil <virgil@lethean.io>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 15:30:30 +00:00
Snider
e90a84eaa0 feat: merge go-agent + go-agentic + php-devops into unified agent repo
Combines three repositories into a single workspace:
- go-agent → pkg/orchestrator (Clotho), pkg/jobrunner, pkg/loop, cmd/
- go-agentic → pkg/lifecycle (allowance, sessions, plans, dispatch)
- php-devops → repos.yaml, setup.sh, scripts/, .core/

Module path: forge.lthn.ai/core/agent

All packages build, all tests pass.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-06 15:23:00 +00:00