Files
hapi/cli/src/modules/common/hapiMcpBridgePrompt.ts
T
Junmo KimandGitHub b9880693a7 fix(opencode): describe display tools via Code Mode execute for OpenCode v2 (#2307)
* fix(opencode): describe display tools via Code Mode execute for OpenCode v2

OpenCode v2 can list MCP tools only in a Code Mode catalog whose entries
are callable as JavaScript inside the execute tool, so the hapi_display_*
names and aliases HAPI advertised may not exist there. Replace the three
per-tool display hints used by the OpenCode instructions with one block
that prefers a direct tool and otherwise calls tools.hapi.<tool>({ path })
through execute. The block appears once in both the ACP first prompt and
the local hapi-instructions.md. Hints for other agents are unchanged.

* fix(opencode): do not re-display user-provided files unless asked

Agents sometimes called the display tools on a file the user had just
attached or asked them to read, which only echoes it back. Say in the
display tools block that the tools are for files the user has not been
shown, and that files the user attached, pasted, or pointed to are not
displayed again unless the user asks.
2026-11-06 15:51:12 +08:00

25 lines
1.6 KiB
TypeScript

import { trimIdent } from '@/utils/trimIdent';
import { DISPLAY_TOOLS_PROMPT_HAPI_MCP } from './displayImagePrompt';
/** Shell fallback for `hapi doctor inline-media` only — not injected into agent prompts. */
export const INLINE_MEDIA_SHELL_FALLBACK = trimIdent(`
If display_image / display_video / display_media tools are not in your tool list, inline media via shell from the HAPI repo (needs bun + @modelcontextprotocol/sdk):
cd <hapi-repo-root> && bun scripts/tooling/hapi-display-image.mjs <HAPI-session-id-prefix> <absolute-file-path> "title"
Use the HAPI session uuid prefix from the web URL /sessions/<uuid> (first 8 chars), not cursorSessionId or other agent-native ids.
Run hapi doctor inline-media to list active bridges and copy the exact command.
`);
/**
* Title + display_image / display_video / display_media instructions for OpenCode first-prompt /
* hapi-instructions.md. Cursor uses native MCP overlay + tool descriptions instead
* (no user-turn prepend — that path was prompt-taint).
*/
const HAPI_MCP_TITLE_INSTRUCTION = trimIdent(`
Use the title tool sparingly. For a new chat, call the tool "hapi_change_title" once after the user's initial request is clear, and set a concise task title. Do not rename the chat for routine progress, substeps, implementation details, or a slightly better wording. Rename only when the user's primary objective changes substantially and the existing title would be misleading.
`);
export const HAPI_MCP_BRIDGE_PROMPT = trimIdent(`
${HAPI_MCP_TITLE_INSTRUCTION}
${DISPLAY_TOOLS_PROMPT_HAPI_MCP}
`);