Commit Graph

4438 Commits

Author SHA1 Message Date
YeonGyu-Kim 1ea192b3f4 fix(background-task): retry transient missing output tasks
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-14 18:51:38 +09:00
YeonGyu-Kim b9beea1039 feat(team-mode): drive immediate teardown and recreate-to-reshape loop
Reframe the skill's Lifecycle section so the lead treats teams as
ephemeral, one-per-phase units. The moment a phase ends or the shape
no longer fits, call team_delete and spawn a fresh team. Restructure
through delete-then-create, never in place.

Also fixes a misframing in old step 5: team_shutdown_request is a
per-session self-shutdown signal, not a 'wind down the team' command.
team_delete is what tears the whole team down.
2026-05-14 18:22:30 +09:00
YeonGyu-Kim 9e6185266d fix(ralph-loop): guard compaction continuation ownership 2026-05-14 13:43:47 +09:00
YeonGyu-Kim 1e7a7600a2 docs(agents-md): regenerate hierarchical AGENTS.md knowledge base for v4.1.1
Refresh all AGENTS.md files to reflect codebase state at 5ffbe0e24 (was cd31d2a1a, 197 commits behind).

Key drift corrections across 45 modified + 1 new file:

Root AGENTS.md:
- TS file counts: 1967 -> 2034 in src/ (1337 source + 697 test)
- LOC: 278k -> 292k
- Barrel index.ts: 120 -> 122
- Hook tier composition: 52/59 -> 54/61 (base/with team-mode)
- Tool Guard hooks: 14 -> 16 (add fsync-skip-warning, bash-file-read-guard)
- Add boulder feature, agent-ordering schema, .agents/ directory, v4.1.1 release tag
- Add generated/ directory entry

src/AGENTS.md:
- Subsystem inventory: agents 96->102, hooks 570->581, tools 306->314,
  features 389->400, shared 258->278, cli 150->158, plugin 55->56
- LOC totals refreshed for every subsystem
- Schema files: 32 -> 30

src/hooks/AGENTS.md:
- Tier 2 (Tool Guard): 14 -> 16 hooks, add fsyncSkipWarning row
- Total: 52 base / 59 team-mode -> 54 base / 61 team-mode
- zauc-mocks count: 7 -> 5

src/features/AGENTS.md:
- background-agent: 47 -> 57 files, mention archive fallback
- opencode-skill-loader: 33 -> 30
- tmux-subagent: 34 -> 32

src/plugin/AGENTS.md:
- Tool Guard composer count: 14 -> 16
- Aggregator total: 43 -> 45

src/cli/AGENTS.md:
- Add new boulder subcommand (BoulderState inspector)
- Command count: 6 -> 7

NEW: src/features/boulder-state/AGENTS.md
- Document the new Boulder work tracking feature
- Schema v2 with BoulderState/BoulderWorkState/TaskSessionState
- Lifecycle, storage, integration points with atlas/ralph-loop hooks

All other AGENTS.md files: Generated date 2026-05-08 -> 2026-05-14.
2026-05-14 12:57:46 +09:00
YeonGyu-Kim 5ffbe0e24e fix(fallback): guard duplicate prompt injections 2026-05-14 01:03:19 +09:00
YeonGyu-Kim ea55c385bb fix(background-agent): defer busy parent notifications 2026-05-14 00:45:36 +09:00
YeonGyu-Kim f9b95f9e3e Merge pull request #3993 from code-yeongyu/fix/non-interactive-env-windows-shell
fix(non-interactive-env): respect Windows command shell
2026-05-13 23:45:23 +09:00
YeonGyu-Kim 47d60a74d3 fix(non-interactive-env): honor Windows ComSpec shell
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-13 22:47:37 +09:00
YeonGyu-Kim 95cc9e2d28 [sisyphus-dev] fix(delegate-task): canonicalize agent dedup key to close hidden filter bypass
mergeWithClaudeCodeAgents deduplicated by raw agent.name.toLowerCase() while
matchesRequestedAgent strips invisible characters, the numeric sort prefix,
and wrapper characters via stripAgentListSortPrefix. A project or user agent
named with a zero-width prefix, quote wrappers, or a sort prefix survived as
a visible duplicate of the hidden native build or demoted plan agent and
matched subagent_type="build" or "plan", which let an OMO orchestrator reach
the hidden execution agent the previous filter was meant to block.

Apply the same canonicalization to the dedup key so visible aliases of hidden
server agents collapse onto the hidden entry instead of bypassing the filter.

Adds three regression tests covering ZWSP, quote-wrapper, and sort-prefix
bypass paths.

bun.lock: refresh platform optionalDependencies to 4.1.1 so frozen-lockfile
install succeeds in CI.
2026-05-13 20:31:17 +09:00
YeonGyu-Kim fef1d4530b fix(non-interactive-env): respect Windows command shell
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-13 20:07:46 +09:00
MoerAI 4bd81d2cdd fix(delegate-task): exclude hidden agents from task delegation discovery (fixes #3957)
OpenCode injects native execution agents like build (and a demoted plan in OMO mode) as { mode: 'subagent', hidden: true }. The dynamic agent discovery in subagent-discovery.ts only filtered by mode, so a hidden agent still resolved as a callable target via task(). This created a boundary leak: an OMO orchestrator (sisyphus, prometheus, etc.) could delegate work into the hidden native build/plan path instead of the OMO category/skill pipeline.

Add hidden?: boolean to AgentInfo, plumb it through mergeWithClaudeCodeAgents, and skip hidden agents in both findCallableAgentMatch and listCallableAgentNames so hidden natives are neither matched nor advertised in 'Available agents' error messages. The OpenCode SDK Agent type already exposes hidden?: boolean, so no schema work is required.

Verified by adding three regression tests in zauc-mocks-subagent-resolver/subagent-resolver.test.ts: hidden 'build' is rejected, hidden 'plan' is rejected, and hidden agents are excluded from the Available agents list. Full delegate-task suite (395 tests) and call-omo-agent suite (57 tests) pass; bun run typecheck is clean.
2026-05-13 19:37:54 +09:00
YeonGyu-Kim 61ba4e3b41 fix(ralph-loop): guard delayed start snapshots
Prevent delayed loop-start message counts from overwriting active Ralph Loop state after the loop has already advanced, so ULW completion can still enter Oracle verification instead of iterating forever.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-13 18:59:07 +09:00
YeonGyu-Kim 3b4d2431ee fix(hooks): guard stale idle prompts 2026-05-13 17:02:17 +09:00
YeonGyu-Kim a337635e3b fix(background-agent): defer active parent wakes 2026-05-13 17:02:17 +09:00
YeonGyu-Kim 36f51ddb16 fix(continuation): mark fallback resumes synthetic 2026-05-13 13:36:25 +09:00
YeonGyu-Kim 1189b96d42 fix(continuation): mark atlas resumes synthetic 2026-05-13 13:25:01 +09:00
YeonGyu-Kim 38b1433ff5 fix(continuation): mark resumes synthetic 2026-05-13 13:09:26 +09:00
YeonGyu-Kim 3f92264311 fix(interactive-bash): prohibit tmux kill-server 2026-05-13 13:07:13 +09:00
YeonGyu-Kim 75825eb9a6 fix(todo-description-override): add OpenCode schema contract for string priorities 2026-05-12 18:18:52 +09:00
YeonGyu-Kim c740ed8aca fix(delegate-task): route sync prompts by directory 2026-05-12 18:14:17 +09:00
YeonGyu-Kim 6035a551ad fix(background-agent): route session prompts by directory 2026-05-12 18:13:39 +09:00
YeonGyu-Kim d5fbada13d test: make unsafe test coercion explicit
Move test coercion out of a hidden global and require each test to import the helper so review tools and runtime scripts can see the unsafe boundary.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-12 15:51:31 +09:00
YeonGyu-Kim 2fc1786077 test(hashline): remove unsafe test assertions
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-12 15:48:46 +09:00
YeonGyu-Kim fb135d047c test(tools): remove unsafe test assertions
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-12 15:48:46 +09:00
YeonGyu-Kim 8b093a1115 test(shared): remove unsafe test assertions
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-12 15:41:17 +09:00
YeonGyu-Kim f05aeaa63a test(plugin): remove unsafe test assertions
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-12 15:41:17 +09:00
YeonGyu-Kim 0787867384 test(ralph-loop): remove unsafe fixture assertions
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-12 15:41:17 +09:00
YeonGyu-Kim 23211159c9 test(hooks): remove unsafe test assertions
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-12 15:41:17 +09:00
YeonGyu-Kim 11b3638493 test(features): remove unsafe test assertions
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-12 15:41:17 +09:00
YeonGyu-Kim 7365163885 test(cli): remove unsafe test assertions
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-12 15:41:17 +09:00
YeonGyu-Kim 9c6090a208 test: add typed test coercion helper
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-12 15:41:17 +09:00
YeonGyu-Kim 4150092e9a test: run suite through isolated mock runner 2026-05-12 15:30:45 +09:00
YeonGyu-Kim cde14b5e37 fix(call-omo-agent): restrict callable agents 2026-05-12 15:28:57 +09:00
YeonGyu-Kim 9ffef79dbb fix(ralph-loop): ignore synthetic idle replays 2026-05-12 15:28:46 +09:00
YeonGyu-Kim 07797e1975 fix(background-agent): preserve direct all-complete replies 2026-05-12 15:28:35 +09:00
YeonGyu-Kim d82f6a6024 fix(background-agent): refresh stale todo state 2026-05-12 13:28:40 +09:00
YeonGyu-Kim 2c0f8e4645 fix(ralph-loop): return prompt dispatch failures 2026-05-12 13:14:07 +09:00
YeonGyu-Kim 2d656bd6bf Merge pull request #3964 from code-yeongyu/fix/electron-bun-runtime-shims
fix(electron): eliminate raw Bun.* runtime calls so plugin loads on OpenCode Desktop
2026-05-12 13:00:49 +09:00
YeonGyu-Kim 8e07ef642e fix(mcp-oauth): use fixed localhost base for callback URL parsing
Cubic AI reviewer flagged the use of the untrusted Host header as the
URL base in startCallbackServer. The server only binds to 127.0.0.1,
so hardcoding "http://127.0.0.1" as the URL base is robust against
malformed or manipulated Host values and matches upstream behavior
prior to the node:http refactor.
2026-05-12 12:54:24 +09:00
YeonGyu-Kim db3256baf6 test: harden dist-bundle regression guard + Node smoke test
Existing test only checked `globalThis.Bun` top-level destructures
and `__require` calls. Add two new test cases:

1. Raw Bun runtime API scanner: scans dist/index.js for any
   `Bun.<anyMethod>(` or `Bun.<anyMethod>.` call outside shim-safe
   patterns (runtime.Bun, globalThis.Bun, typeof Bun, and the
   "Bun is not defined" error-message string). Uses a negative
   lookbehind so shim indirection (`runtime.Bun.foo`) passes.

2. Node smoke test: imports dist/index.js under
   `node --input-type=module` and asserts stderr contains no
   `ReferenceError` and no `Bun is not defined`. The existing
   case 3 only checked exit code, which masked lazy-evaluation
   crashes that fire after import. Reading exports forces lazy
   module-level evaluation paths to run.
2026-05-12 12:46:50 +09:00
YeonGyu-Kim 11529394aa refactor(cli): use Response(stream).text() instead of Bun.readableStreamToText
bun-install.ts streamToText() was reachable from the plugin bundle via
the cli/config-manager barrel re-export. Replace with the WHATWG
standard `new Response(stream).text()` pattern which works
identically in Bun and Node and avoids the last raw Bun.* runtime
call in dist/index.js.
2026-05-12 12:46:50 +09:00
YeonGyu-Kim 22c7e4eb8e refactor(mcp-oauth): replace Bun.serve with node:http in callback-server
The OAuth callback server was using Bun.serve, which would crash if
mcp-oauth code paths ever entered the plugin bundle. Switch to
node:http.createServer with the same WHATWG behavior:

- Binds to 127.0.0.1, preserves 200/400/404 status codes
- Translates fetch(Request)→Response to (req, res) callback style
- Clears OAuth timeout on success/error/missing-param paths
- Replaces server.stop(true) with server.close() for shutdown

Functional behavior and response bodies unchanged.
2026-05-12 12:46:50 +09:00
YeonGyu-Kim 2386cbd9b9 refactor(port-utils): drop Bun.serve in favor of node:net probe
isPortAvailable() previously bound a one-shot Bun.serve and stopped it.
That call was reachable from the plugin bundle through
src/shared/index.ts barrel re-export and crashed on Electron.

Switch to node:net.createServer().listen(port, host), which Bun fully
implements as well. Adds a 2s safety timeout and removes both
"error" and "listening" handlers on resolution to prevent listener
leaks. Behavior is bit-equivalent: returns true iff a server can bind
to (host, port) right now.

Test file is fully rewritten away from stale Bun.serve mocking. New
tests exercise: free-port detection via port 0, EADDRINUSE handling
via a real net.createServer blocker, findAvailablePort range
exhaustion, getAvailableServerPort auto-selection, 127.0.0.1 default
hostname binding, and probe-server resource cleanup.
2026-05-12 12:46:50 +09:00
YeonGyu-Kim 0aafe20a85 refactor: route raw Bun.file/write/hash/which/spawn through runtime shims
Eliminates 19 unguarded `Bun.*` runtime call sites in the plugin bundle
that crashed with `ReferenceError: Bun is not defined` under Electron.

Per-tool-call hot paths (executed on every Read/Edit):
- src/tools/hashline-edit/hash-computation.ts: Bun.hash.xxHash32 → bunHashXxh32
- src/tools/hashline-edit/hashline-edit-executor.ts: 8 sites via bunFile/bunWrite
- src/hooks/hashline-read-enhancer/hook.ts: Bun.file → bunFile
- src/hooks/hashline-edit-diff-enhancer/hook.ts: 2 sites via bunFile

Plugin-load paths:
- src/hooks/claude-code-hooks/config.ts and config-loader.ts: Bun.file → bunFile
- src/features/claude-code-mcp-loader/loader.ts: Bun.file → bunFile
- src/features/claude-code-plugin-loader/mcp-server-loader.ts: Bun.file → bunFile
- src/features/team-mode/deps.ts: Bun.spawn → spawn shim
- src/hooks/session-notification-utils.ts: Bun.which → bunWhich, also drops
  the bare `declare const Bun` ambient declaration
- src/shared/binary-downloader.ts: Bun.write → bunWrite

Pure mechanical API swaps. No control-flow or signature changes.
2026-05-12 12:46:50 +09:00
YeonGyu-Kim 4394f34225 feat(shim): add bun-file/hash/which shims with Node fallbacks
The plugin builds with `bun build --target bun` and runs under OpenCode
CLI (Bun SEA) but also under OpenCode Desktop (Electron / Node V8) where
`globalThis.Bun` does not exist. Mirror the existing `bun-spawn-shim.ts`
pattern for three more Bun runtime APIs:

- bun-file-shim: bunFile()/bunWrite() backed by node:fs/promises with
  ArrayBuffer slicing to avoid Node Buffer pool exposure
- bun-hash-shim: pure-JS XXH32, bit-exact with Bun.hash.xxHash32 verified
  by 1200-pair fuzz comparison so existing hashline LINE#ID tags remain
  stable across runtimes
- bun-which-shim: synchronous PATH walker with Windows .exe/.cmd/.bat/.com
  extensions plus isUnsafeCommandName guard that rejects path separators,
  parent traversal, drive letters and null bytes before any probe

Each shim uses the canonical `runtime.Bun !== undefined` detection and
delegates to native Bun under IS_BUN, otherwise uses Node primitives.
Each ships with a co-located test that exercises both branches via the
`node:vm.runInNewContext` pattern from bun-hash-shim.test.ts.
2026-05-12 12:46:50 +09:00
YeonGyu-Kim 4da48555ee fix(plugin): normalize event session ids
Handle OpenCode session events that carry the session ID under properties.info.id or properties.info.sessionID so background tasks and continuation hooks do not miss idle/error/delete events.

Add regression coverage for nested session.idle events completing background tasks and waking continuation hooks.
2026-05-12 12:32:26 +09:00
YeonGyu-Kim 0de6bd7253 fix(ralph-loop): reject promptAsync error responses 2026-05-12 12:06:49 +09:00
YeonGyu-Kim 1c05c60dcc fix(background-agent): replace system-reminder wake with queued notifications 2026-05-11 18:55:36 +09:00
YeonGyu-Kim 3ed4651b7a fix(compaction): skip autocontinue for compaction agent 2026-05-11 18:46:29 +09:00
YeonGyu-Kim 90f0971f4f fix(background-agent): handle idle status events 2026-05-11 18:06:22 +09:00