mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
feat(commands): align built-in slash commands with OpenCode v2
Replace the split built-in command name list and switch with one typed registry, so a registered command without a handler is a compile error. Remove the broken themes/share/unshare/editor entries and the hardcoded init; server and custom commands now win on a name clash and built-ins dispatch by registry identity. Add /copy, /btw, /rename, /fork (message picker), /timeline, /model, /agent, /variants, /mcp, /skills, /settings and /connect. Open the model picker through state so /model and the select-model shortcut work while a response is running, load full session history in the fork picker, and keep attachments when a built-in command is submitted. Extract shared clipboard and primary-agent helpers, reuse CopyButton in the manager token settings, and update the Quick Start and chat docs.
This commit is contained in:
1 parent
7cac8baade
commit
7e93eb4c34
35 files changed
+2291
-767
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import {
|
||||
activateSkill,
|
||||
askSideQuestion,
|
||||
cancelForm,
|
||||
clearRevert,
|
||||
commitRevert,
|
||||
@@ -26,6 +27,7 @@ import {
|
||||
stageRevert,
|
||||
switchSessionAgent,
|
||||
switchSessionModel,
|
||||
SIDE_QUESTION_INSTRUCTIONS,
|
||||
} from './opencode'
|
||||
import { FetchError } from './fetchWrapper'
|
||||
|
||||
@@ -413,6 +415,20 @@ describe('OpenCode facade', () => {
|
||||
expect(lastRequest().init.method).toBe('POST')
|
||||
})
|
||||
|
||||
it('asks a side question through the session generate route with the shared instructions', async () => {
|
||||
fetchMock.mockResolvedValue(jsonResponse({ data: { text: ' answer \n' } }))
|
||||
|
||||
const answer = await askSideQuestion('ses_1', 'why?')
|
||||
|
||||
expect(lastRequest().url).toBe('http://localhost/api/opencode/api/session/ses_1/generate')
|
||||
expect(lastRequest().init.method).toBe('POST')
|
||||
const body = JSON.parse(String(lastRequest().init.body))
|
||||
expect(body.prompt).toBe(`${SIDE_QUESTION_INSTRUCTIONS}\n\nwhy?`)
|
||||
expect(body.prompt.startsWith(SIDE_QUESTION_INSTRUCTIONS)).toBe(true)
|
||||
expect(body.prompt.endsWith('\n\nwhy?')).toBe(true)
|
||||
expect(answer).toBe('answer')
|
||||
})
|
||||
|
||||
it('stages, commits, and clears a session revert', async () => {
|
||||
fetchMock.mockResolvedValue(jsonResponse({ data: { messageID: 'msg_1' } }))
|
||||
|
||||
|
||||
@@ -167,6 +167,23 @@ export async function runShell(sessionID: string, command: string): Promise<void
|
||||
await callOpenCode((api) => api.session.shell({ sessionID, command }))
|
||||
}
|
||||
|
||||
export const SIDE_QUESTION_INSTRUCTIONS =
|
||||
'The user is asking a quick side question about the conversation so far. Answer directly and concisely in markdown from what you already know. Do not call any tools and do not take any actions.'
|
||||
|
||||
export async function askSideQuestion(
|
||||
sessionID: string,
|
||||
question: string,
|
||||
signal?: AbortSignal,
|
||||
): Promise<string> {
|
||||
const result = await callOpenCode((api) =>
|
||||
api.session.generate(
|
||||
{ sessionID, prompt: [SIDE_QUESTION_INSTRUCTIONS, question].join('\n\n') },
|
||||
signal ? { signal } : undefined,
|
||||
),
|
||||
)
|
||||
return result.text.trim()
|
||||
}
|
||||
|
||||
export async function interruptSession(sessionID: string): Promise<void> {
|
||||
await callOpenCode((api) => api.session.interrupt({ sessionID }))
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user