feat: unify execution and add workspace file imports
Remove Ask/Execute modes and general product tool approvals so requests use the selected runtime, enabled capabilities, and execution account permissions. Migrate retired application metadata while preserving user content. Retire the Results page while retaining conversation images and stored artifacts. Add local and remote workspace file imports, timestamps and sorting, improve image discovery and saving, and refine workspace navigation and supervision responsiveness. Include the accompanying web-search changes, tests, probes, and product documentation. Remote imports require an updated Agent. Existing artifacts are not automatically copied into project directories. Validation evidence and outstanding failures remain documented in feature progress files; no full test suite or real-model calls were rerun for this commit. Release note: Run requests without switching work modes, import files into a selected local or remote workspace folder, sort workspace files by date, and keep using conversation images after removal of the Results page.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// @vitest-environment node
|
||||
import { mkdir, mkdtemp, readFile, readdir, rm, stat, writeFile } from 'node:fs/promises'
|
||||
import { mkdir, mkdtemp, readdir, rm, stat, writeFile } from 'node:fs/promises'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
@@ -29,7 +29,7 @@ async function fixture() {
|
||||
})
|
||||
const profile = { id: 'selected', name: 'Selected model', modelName: 'selected-model', baseUrl: 'https://provider.example/v1', authentication: 'api-key' as const, protocol: 'openai-chat-completions' as const, apiKey: 'provider-secret', requestHeaders: { 'x-provider-option': 'configured' } }
|
||||
const input: NativeTerminalClientInput = {
|
||||
projectId: 'project', projectName: 'Project', directory: root, runtime: 'opencode', workMode: 'ask',
|
||||
projectId: 'project', projectName: 'Project', directory: root, runtime: 'opencode',
|
||||
settings: { opencodeBinaryPath: '', opencodeModelProfile: profile } as unknown as ResolvedRuntimeSettings
|
||||
}
|
||||
return { root, client, create, fetcher, input }
|
||||
@@ -57,12 +57,8 @@ describe('native terminal client', () => {
|
||||
expect(headers.get('authorization')).toBe('Bearer provider-secret')
|
||||
expect(headers.get('x-provider-option')).toBe('configured')
|
||||
const configDirectory = launch.spawnSpec.env.OPENCODE_CONFIG_DIR!
|
||||
const pluginPath = new URL(config.plugin[0])
|
||||
const plugin = await import(/* @vite-ignore */ pluginPath.href)
|
||||
const hooks = await plugin.default()
|
||||
await expect(hooks['tool.execute.before']({ tool: 'read' })).resolves.toBeUndefined()
|
||||
await expect(hooks['tool.execute.before']({ tool: 'bash' })).rejects.toThrow('read-only')
|
||||
await expect(hooks['tool.execute.before']({ tool: 'mcp_write' })).rejects.toThrow('read-only')
|
||||
expect(config.permission).toBe('allow')
|
||||
expect(config.plugin).toBeUndefined()
|
||||
await launch.dispose()
|
||||
await expect(readdir(configDirectory)).rejects.toThrow()
|
||||
expect(await readdir(join(root, 'opencode'))).toHaveLength(1)
|
||||
@@ -97,32 +93,29 @@ describe('native terminal client', () => {
|
||||
expect(configDirectory).toBe(join(root, 'opencode-config'))
|
||||
const copied = (await stat(join(configDirectory, 'node_modules', 'plugin', 'index.js'))).mtimeMs
|
||||
await launches[0]!.dispose()
|
||||
await client.open(1, { ...input, workMode: 'execute' })
|
||||
await client.open(1, input)
|
||||
expect(launches[1]!.spawnSpec.env.OPENCODE_CONFIG_DIR).toBe(configDirectory)
|
||||
expect((await stat(join(configDirectory, 'node_modules', 'plugin', 'index.js'))).mtimeMs).toBe(copied)
|
||||
})
|
||||
|
||||
it('uses Execute permissions and explicit session MCP endpoints', async () => {
|
||||
it('uses normal permissions and explicit session MCP endpoints', async () => {
|
||||
const { client, input } = await fixture()
|
||||
await client.open(1, { ...input, workMode: 'execute', mcpServers: [{ name: 'tools', url: 'http://127.0.0.1:12345/mcp', headers: { Authorization: 'Bearer local-token' } }] })
|
||||
await client.open(1, { ...input, mcpServers: [{ name: 'tools', url: 'http://127.0.0.1:12345/mcp', headers: { Authorization: 'Bearer local-token' } }] })
|
||||
const launch = launches[0]!
|
||||
const config = JSON.parse(launch.spawnSpec.env.OPENCODE_CONFIG_CONTENT!)
|
||||
expect(config.permission).toBe('allow')
|
||||
expect(config.mcp.tools.url).toBe('http://127.0.0.1:12345/mcp')
|
||||
expect(await readFile(new URL(config.plugin[0]), 'utf8')).toContain('execute')
|
||||
expect(config.plugin).toBeUndefined()
|
||||
})
|
||||
|
||||
it('allows only the bound read tools through native OpenCode Ask permissions and execution hook', async () => {
|
||||
it('allows bound tools without a generated whitelist or execution hook', async () => {
|
||||
const { client, input } = await fixture()
|
||||
await client.open(1, { ...input, mcpServers: [{ name: 'goodbuddy-0', url: 'http://127.0.0.1:12345/mcp', headers: {},
|
||||
readOnlyTools: ['story_graph_search', 'story_graph_get_context', 'story_graph_read_source'] }] })
|
||||
await client.open(1, { ...input, mcpServers: [{ name: 'goodbuddy-0', url: 'http://127.0.0.1:12345/mcp', headers: {} }] })
|
||||
const config = JSON.parse(launches[0]!.spawnSpec.env.OPENCODE_CONFIG_CONTENT!)
|
||||
expect(config.mcp['goodbuddy-0']).toBeDefined()
|
||||
const hooks = await (await import(/* @vite-ignore */ new URL(config.plugin[0]).href)).default()
|
||||
for (const name of ['story_graph_search', 'story_graph_get_context', 'story_graph_read_source']) {
|
||||
expect(config.permission[`goodbuddy-0_${name}`]).toBe('allow')
|
||||
await expect(hooks['tool.execute.before']({ tool: `goodbuddy-0_${name}` })).resolves.toBeUndefined()
|
||||
}
|
||||
await expect(hooks['tool.execute.before']({ tool: 'goodbuddy-0_generate_image' })).rejects.toThrow('read-only')
|
||||
expect(config.permission).toBe('allow')
|
||||
expect(config.agent.build.permission).toBe('allow')
|
||||
expect(config.agent.plan.permission).toBe('allow')
|
||||
expect(config.plugin).toBeUndefined()
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user