mirror of
https://github.com/wu736139669/hapi.git
synced 2026-10-28 23:01:34 +00:00
* feat(cli,web,hub): migrate Cursor remote sessions to ACP with model/effort pickers Move stream-json remote launcher to legacy path and add ACP launcher with set_config_option model/mode sync, optimistic keepalive on config changes, and shared catalog caching. Web gets dual base/effort Cursor pickers for session and new-session flows; hide composer status bar when Cursor sends no usage_update. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(cli,web,shared): Cursor model picker — ACP wires + CLI sku variants Enrich the web/mobile picker with agent --list-models SKUs grouped under ACP wire bases, fix session-open base highlight, and keep catalog discovery safe while the ACP transport holds the CLI lock. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(cursor-acp): apply ACP default model when web resets to Default Web sends model: null for Default; push session/set_config_option with the ACP default[] wire so Cursor backend matches hub state. Regression tests for setModel(null) and applyModelConfig(null). Co-authored-by: Cursor <cursoragent@cursor.com> * fix(acp): clear stale agent-acp lock when owning process is gone Check lock pid with signal 0; remove orphaned lock dirs after SIGKILL or crash so listCursorModels can run cold probes again. Regression tests for guard and catalog discovery. Co-authored-by: Cursor <cursoragent@cursor.com> * test(cursor): use live pid for ACP lock handler tests Stale-lock cleanup clears dead pids; handler tests must simulate an active lock with the current process pid to avoid cold probes/timeouts. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(acp): scope agent CLI lock guard to Cursor agent command only Gemini/OpenCode/Kimi ACP sessions must not register agent-acp-active; that blocked listCursorModels while unrelated backends were running. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(hub,web): reject Cursor model changes for local sessions Hub returns 409 when controlledByUser is set, matching Codex. Web hides model and variant pickers for local Cursor sessions so users do not hit a dead RPC path. Document pre-push-review in AGENTS.md. Verified: bun typecheck; bun run test (919 cli + 243 hub + 768 web + 46 shared). Co-authored-by: Cursor <cursoragent@cursor.com> * fix(web): send stable ids for Cursor ask_question replies Parse and submit question.id and option.id so ACP receives keys like { approach: ['a'] } instead of index/label. Verified: bun typecheck && bun run test. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
64 lines
4.1 KiB
TypeScript
64 lines
4.1 KiB
TypeScript
import type { SlashCommand } from './apiTypes'
|
|
|
|
export const BUILTIN_SLASH_COMMANDS = {
|
|
claude: [
|
|
{ name: 'clear', description: 'Clear conversation history and free up context', source: 'builtin' },
|
|
{ name: 'compact', description: 'Clear conversation history but keep a summary in context', source: 'builtin' },
|
|
{ name: 'context', description: 'Visualize current context usage as a colored grid', source: 'builtin' },
|
|
{ name: 'cost', description: 'Show the total cost and duration of the current session', source: 'builtin' },
|
|
{ name: 'doctor', description: 'Diagnose and verify your Claude Code installation and settings', source: 'builtin' },
|
|
{ name: 'plan', description: 'View or open the current session plan', source: 'builtin' },
|
|
{ name: 'stats', description: 'Show your Claude Code usage statistics and activity', source: 'builtin' },
|
|
{ name: 'status', description: 'Show Claude Code status including version, model, account, and API connectivity', source: 'builtin' },
|
|
],
|
|
codex: [
|
|
{ name: 'clear', description: 'Clear current Codex thread context', source: 'builtin' },
|
|
{ name: 'compact', description: 'Compact current Codex thread context', source: 'builtin' },
|
|
{ name: 'goal', description: 'Set, view, pause, resume, or clear a persistent Codex goal', source: 'builtin' },
|
|
{ name: 'help', description: 'Show supported HAPI Codex slash commands', source: 'builtin' },
|
|
{ name: 'plan', description: 'Enable plan mode; use /plan off to return to default', source: 'builtin' },
|
|
{ name: 'default', description: 'Return Codex collaboration mode to default', source: 'builtin' },
|
|
{ name: 'execute', description: 'Return Codex collaboration mode to default', source: 'builtin' },
|
|
{ name: 'status', description: 'Show current Codex session config', source: 'builtin' },
|
|
{ name: 'model', description: 'Show or set Codex model, e.g. /model gpt-5.5', source: 'builtin' },
|
|
{ name: 'reasoning', description: 'Show or set reasoning effort', source: 'builtin' },
|
|
{ name: 'effort', description: 'Alias for /reasoning', source: 'builtin' },
|
|
{ name: 'permissions', description: 'Show or set permission mode', source: 'builtin' },
|
|
{ name: 'permission', description: 'Alias for /permissions', source: 'builtin' },
|
|
],
|
|
gemini: [
|
|
{ name: 'about', description: 'Show version info', source: 'builtin' },
|
|
{ name: 'clear', description: 'Clear the screen and conversation history', source: 'builtin' },
|
|
{ name: 'compress', description: 'Compress the context by replacing it with a summary', source: 'builtin' },
|
|
{ name: 'stats', description: 'Check session stats', source: 'builtin' },
|
|
],
|
|
opencode: [
|
|
{ name: 'help', description: 'Show supported HAPI OpenCode slash commands', source: 'builtin' },
|
|
{ name: 'status', description: 'Show current OpenCode session config', source: 'builtin' },
|
|
{ name: 'plan', description: 'Enable plan mode; use /plan off to return to default', source: 'builtin' },
|
|
{ name: 'default', description: 'Return OpenCode permission mode to default', source: 'builtin' },
|
|
{ name: 'init', description: 'Generate or refresh AGENTS.md for this project', source: 'builtin' },
|
|
],
|
|
cursor: [
|
|
{ name: 'compress', description: 'Compress conversation context to free window space (pass-through to Cursor agent)', source: 'builtin' },
|
|
],
|
|
} as const satisfies Record<string, readonly SlashCommand[]>
|
|
|
|
export function getBuiltinSlashCommands(agent: string): SlashCommand[] {
|
|
const commands = BUILTIN_SLASH_COMMANDS[agent as keyof typeof BUILTIN_SLASH_COMMANDS]
|
|
?? BUILTIN_SLASH_COMMANDS.claude
|
|
return commands.map((command) => ({ ...command }))
|
|
}
|
|
|
|
export function mergeSlashCommands(commands: readonly SlashCommand[]): SlashCommand[] {
|
|
const commandMap = new Map<string, SlashCommand>()
|
|
for (const command of commands) {
|
|
const key = command.name.toLowerCase()
|
|
if (commandMap.has(key)) {
|
|
commandMap.delete(key)
|
|
}
|
|
commandMap.set(key, command)
|
|
}
|
|
return Array.from(commandMap.values())
|
|
}
|