2.3 KiB
2.3 KiB
Implementation Plan - Integrating Enhanced Agent Communication
Goal Description
Integrate the new agent-prompt.mjs module (concise, direct, informative patterns) into the OpenQode TUI. Refactor server.js (if applicable) and primarily bin/opencode-ink.mjs and qwen-oauth.mjs to support dynamic system prompt injection and robust retry mechanisms for API calls.
User Review Required
Important
The
qwen-oauth.mjssendMessagesignature will be updated to acceptsystemPromptas a 5th argument. This is a non-breaking change as it defaults to null, but ensures future compatibility.
Proposed Changes
Core Logic
[MODIFY] qwen-oauth.mjs
- Update
sendMessageto acceptsystemPromptas the 5th argument. - Use the provided
systemPromptinstead of the hardcodedsystemContext. - Import
fetchWithRetryfromlib/retry-handler.mjs(module import). - Wrap
sendVisionMessage'sfetchcall withfetchWithRetry.
[MODIFY] bin/opencode-ink.mjs
- Import
getSystemPromptfrom../lib/agent-prompt.mjs. - Import
fetchWithRetryfrom../lib/retry-handler.mjs(forcallOpenCodeFree). - In
handleSubmit:- Gather context (CWD, project context, memories).
- Call
getSystemPrompt({ capabilities, cwd, context, projectContext })to generate the cleaner prompt. - Pass this
systemPrompttoqwen.sendMessageas the 5th argument. - PASS ONLY the user request (and maybe immediate context like "clipboard content") as the message content, removing the manual prompt concatenation.
- In
callOpenCodeFree:- Use
fetchWithRetryinstead of rawfetch.
- Use
Verification Plan
Automated Tests
- None available for TUI interaction.
Manual Verification
- System Prompt Check: Send a message like "create a file test.txt". Verify the agent responds concisely (OpenCode style) and uses the correct code block format, proving
getSystemPromptwas used. - Retry Check: Disconnect internet (if possible) or simulate a timeout to verify
fetchWithRetrylogs attempts and handles failure gracefully. - Vision Check: Send an image command (if possible via TUI) to verify
sendVisionMessagestill works with retry.