Commit Graph

5944 Commits

Author SHA1 Message Date
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 100819f0bc ci: build plugin before running tests
The dist-bundle regression tests in
src/shared/dist-bundle-bun-globals.test.ts are guarded by
`test.skipIf(!existsSync("dist/index.js"))` and dist/ is
gitignored, so they silently skipped in CI which ran tests before
the build step. Adding the build step earlier ensures the
regression guard runs and a future raw `Bun.*` leak in the bundle
fails CI.
2026-05-12 12:46:50 +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
acamq 67f90a819e Merge pull request #3956 from code-yeongyu/fix/web-audit-dependencies
fix(web): patch audit dependency advisories
2026-05-11 16:42:36 -06:00
acamq 33f62c4d36 fix(web): patch audit dependency advisories 2026-05-11 16:37:47 -06:00
acamq 6a9cad1bf7 Merge pull request #3955 from acamq/fix/supply-chain-audit-deps
fix(deps): patch vulnerable MCP transitives
2026-05-11 16:23:46 -06:00
acamq 6b93fbfd65 ci: enforce frozen bun installs 2026-05-11 16:18:19 -06:00
acamq 5394b29589 fix(deps): patch vulnerable mcp transitives 2026-05-11 16:14:45 -06: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
YeonGyu-Kim 71a63c20ec Revert "fix(hooks): dedupe native agent instructions"
This reverts commit 78d52872f2.
2026-05-11 18:02:13 +09:00
YeonGyu-Kim 78d52872f2 fix(hooks): dedupe native agent instructions 2026-05-11 17:21:58 +09:00
YeonGyu-Kim c849d0cbbc fix(ralph-loop): suppress stale iteration toasts 2026-05-11 15:17:07 +09:00
YeonGyu-Kim 2c299d2d9e Merge pull request #3943 from code-yeongyu/feature/boulder-evolution-and-discipline-agents
feat: boulder evolution + discipline agents (multi-work, timings, CLI, hooks, Oracle phase gates, no-excuses retry)
2026-05-11 14:54:58 +09:00
YeonGyu-Kim 29c42485a8 fix(hooks/atlas): capture plan snapshot for .sisyphus paths
Oracle review of PR #3943 surfaced that endTaskTimer never fires for real Prometheus plans because their canonical path is .sisyphus/plans/ and the snapshot capture was nested inside the !isSisyphusPath branch intended for direct-work warning suppression. Move the snapshot/path tracking out of the warning gate so all plan-file edits are snapshotted regardless of .sisyphus prefix. Keep the warning branch isSisyphus-gated so Atlas does not yell at legitimate plan edits.

Regression test now uses a real .sisyphus/plans/ path and fails against HEAD before the fix.
2026-05-11 14:48:49 +09:00
YeonGyu-Kim cf5fe757df feat(hooks/atlas): parse task_key from delegation prompt for parallel batches 2026-05-11 14:28:56 +09:00
YeonGyu-Kim e3cddb3650 feat(hooks/atlas): end task timer when plan checkbox flips to checked via edit 2026-05-11 14:27:03 +09:00
YeonGyu-Kim b8c25b3b75 refactor(hooks/atlas): remove unused resolveSessionOrigin helper 2026-05-11 14:26:10 +09:00
YeonGyu-Kim 079a2cd65a fix(start-work): preserve existing works when starting an explicit new plan 2026-05-11 14:25:52 +09:00
YeonGyu-Kim dd5f77562a fix(boulder-state): missing plan file no longer reports isComplete=true 2026-05-11 14:25:35 +09:00
YeonGyu-Kim ce2f3af001 fix(boulder-state): make completeBoulder idempotent on already-completed works 2026-05-11 14:25:06 +09:00
YeonGyu-Kim 70351534d0 style(agents): replace em dashes with semicolons/periods
Comply with the no-em-dash constraint flagged in PR #3943 review.
Two single-line replacements:
- opus-4-7-prompt-sections.ts:149 retry guidance copy
- plan-generation.ts:65 Oracle gate guidance copy

No behavioral change.
2026-05-11 14:23:34 +09:00
YeonGyu-Kim 14b9a434d7 fix(cli/boulder): strip ANSI in formatter test so FORCE_COLOR CI passes
picocolors emits ANSI escape codes when FORCE_COLOR is set (GitHub
Actions default), so the literal toContain('status: active') assertion
fails against the wrapped 'status: \x1b[36mactive\x1b[39m' output.
Reuse the existing stripAnsi helper from src/cli/doctor/format-shared.ts
in the test before assertion.

Reproduced locally with FORCE_COLOR=1 bun test src/cli/boulder/formatter.test.ts.
2026-05-11 14:11:28 +09:00
YeonGyu-Kim de9c28a095 fix(hooks/atlas): align completion behavior tests with task-4 timing updates 2026-05-11 13:49:36 +09:00
YeonGyu-Kim 1ebf89cb9f feat(hooks/atlas): inject boulder-complete elapsed-time nudge once per work
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-11 13:43:40 +09:00
YeonGyu-Kim a1c6e6b77d fixup! feat(hooks/atlas): use getWorkForSession in boulder lookups and session tracking 2026-05-11 13:42:39 +09:00
YeonGyu-Kim c34508235f feat(cli/boulder): implement boulder() entry point and register subcommand 2026-05-11 13:41:18 +09:00
YeonGyu-Kim 30984939eb feat(cli/boulder): add types and formatter for boulder subcommand 2026-05-11 13:41:09 +09:00
YeonGyu-Kim fb2f696b47 docs(start-work): document multi-work resume flow in agent template
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-11 13:41:06 +09:00
YeonGyu-Kim d6f4199cab feat(start-work): use getWorkResumeOptions for multi-work resume selection
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-11 13:40:57 +09:00
YeonGyu-Kim 29b44fffd0 feat(hooks/atlas): call completeBoulder when progress.isComplete 2026-05-11 13:40:48 +09:00
YeonGyu-Kim 127112e1e2 feat(hooks/atlas): wire per-task timers via startTaskTimer/endTaskTimer 2026-05-11 13:39:47 +09:00
YeonGyu-Kim f2a5ef0966 feat(hooks/atlas): add BOULDER_COMPLETE_PROMPT template and SessionState guard
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-11 13:37:35 +09:00
YeonGyu-Kim 18af3d3617 feat(hooks/atlas): use getWorkForSession in boulder lookups and session tracking 2026-05-11 13:37:19 +09:00
YeonGyu-Kim 42db7078af feat(boulder-state): add formatDurationHuman utility
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-11 13:35:59 +09:00
YeonGyu-Kim 0c6805cc62 prompt(prometheus): add Oracle phase-gate verification between phases
Inserts blocking Oracle verification todos (plan-1b / plan-2b /
plan-6b in the canonical, plan-1b / plan-2b / plan-5b in the gpt and
gemini variants) between each major Prometheus phase. Each gate is a
single task(subagent_type=oracle) invocation that must return
VERDICT: GO; NO-GO is a directive to fix the cited issues and rerun on
the same Oracle session, not a license to skip.

Adds a new 'Oracle Verification (Phase Gates)' section to
plan-generation.ts with the concrete invocation prompts for each gate:
phase 1 verifies interview completeness, phase 2 verifies the generated
plan, phase 3 verifies plan readiness for execution before /start-work
handoff.

Also adds a plan-generation.test.ts smoke suite (9 cases) that pins
the new todo ids, the section name, the GO/NO-GO format, the
'fix the cited issues' fallback, and the relative ordering.
2026-05-11 13:32:38 +09:00
YeonGyu-Kim 8c238a11a2 prompt(atlas): replace retry cap with no-excuses policy and add boulder-complete response
Drops 'Maximum 3 retries' / 'document and move on' across every Atlas
variant (default, opus-4-7, gpt, kimi, gemini). New text forbids the
'false positive' excuse explicitly and instructs Atlas to keep iterating
on the same task_id, attaching a diagnosis plan, until verification
passes — and to spawn a different-angle subagent only when the original
loops.

Adds a shared <boulder_completion_response> section composed by
shared-prompt.ts. When the hook injects the BOULDER COMPLETE nudge,
Atlas now knows to print TOTAL ELAPSED + per-task elapsed times in the
exact summary shape, confirm boulder.json state, and only mark
pass-final-wave after the Final Wave reviewers approve.
2026-05-11 13:32:27 +09:00
YeonGyu-Kim 29c29da3a8 Merge pull request #3942 from code-yeongyu/fix/3819-compaction-agent-token-cache
fix(compaction): ignore compaction agent updates
2026-05-11 13:30:49 +09:00
YeonGyu-Kim 5d823b5078 feat(boulder-state): add task timer + completion helpers
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-11 13:30:29 +09:00
YeonGyu-Kim 9f500743d1 feat(boulder-state): add session-aware multi-work storage helpers
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-11 13:28:58 +09:00
YeonGyu-Kim 49ff4b5f8d fix(compaction): ignore compaction agent updates
Fixes #3819
2026-05-11 13:25:29 +09:00
YeonGyu-Kim 246e0dca80 feat(boulder-state): add BoulderWorkState and timing fields to types
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-11 13:24:28 +09:00
YeonGyu-Kim cfe94fc2a8 Merge pull request #3941 from code-yeongyu/fix/delegate-task-metadata
[codex] preserve native delegate task metadata
2026-05-11 13:20:10 +09:00