Expose preview status/logs/restart tools to the AI chat#59
Conversation
Registers get_doce_preview_status, read_doce_preview_logs, and restart_doce_preview in the chat tool registry, adds their service/schema skeleton, and updates the agent system prompt in DOCE.md to guide correct tool usage order. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…nking-about-exposing-more-internal-fde1ca
Generates 3 hidden OpenCode custom tools (get_doce_preview_status,
read_doce_preview_logs, restart_doce_preview) at startup under
${DATA_PATH}/opencode/tools/. Each tool resolves projectId from its
session directory, reads a per-project token, and POSTs to a new
internal API at /api/internal/ai-tools/preview/{action} that executes
the existing service layer scoped to the project owner.
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Tools now declare an optional getDetails({input,output,status}) that
returns a short summary string for the expanded panel. Default expanded
view falls back to a tiny raw output preview (instead of the full
Input/Output JSON blocks), or "No additional details." when there is
nothing to show. Drops the leftover colored iconClass on the doce
preview tools and registers focused summaries (status -> output
summary/error, logs -> summary + extracted signal, restart -> reason +
result summary).
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Two integration fixes for the OpenCode custom-tool wiring:
1. runtime: always re-emit ~/.config/opencode/{opencode.json,tools,plugins}
before deciding to reuse a running opencode. Previously these only got
written on a fresh spawn, so a running daemon would never see updated
tool sources.
2. tool sources: drop the `args` field on all three doce preview tools and
drop the node:path import. OpenCode 1.14.48 crashes any tool call that
declares an `args` object (even {}) with
"undefined is not an object (evaluating 'g.split')" inside its internal
wrapper. Tools without `args` execute correctly. The tools now read
sensible defaults from session context instead of taking model-provided
arguments.
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedPull request was closed or merged during review WalkthroughThis PR implements internal Doce preview tools for OpenCode that enable monitoring and management of Docker Compose preview services. It adds three new tools— 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
/api/internal/ai-tools/preview/{status,logs,restart}that the chat agent can call to check the doce preview server, read its logs, and restart itget_doce_preview_status,read_doce_preview_logs,restart_doce_preview) generated at runtime into${DATA_PATH}/opencode/tools/. Tools auto-resolveprojectId+ token fromcontext.directory; no agent-visible internal IDsgetDetails({input,output,status})field so each tool defines its own concise expanded view instead of raw JSON dumpsCaveats
args:field withundefined is not an object (evaluating 'g.split'). To work around it, the three tools take no arguments and use sensible defaults (logs always returns tail+signal; restart records a generic reason). Once that bug is fixed in opencode we can re-add typed args without other changes.Test plan
Preview Statustool call should render and the expanded panel should show a one-line summaryPreview Logsshould return the last error signal + tailsrc/pages/index.astro), then ask the agent to diagnose + fix — it should chain status → logs → restart as neededInput:blocks appear in expanded views🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Documentation