mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
feat(opencode): accept -s/--session as resume aliases (#1042)
Map OpenCode-native session flags to resumeSessionId so `hapi opencode -s <id>` restores the session like --resume.
This commit is contained in:
@@ -68,6 +68,30 @@ describe('parseRemoteAgentCommandOptions', () => {
|
||||
expect(() => parseRemoteAgentCommandOptions(['--model'], OPENCODE_PERMISSION_MODES)).toThrow('Missing --model value')
|
||||
expect(() => parseRemoteAgentCommandOptions(['--model-reasoning-effort'], OPENCODE_PERMISSION_MODES)).toThrow('Missing --model-reasoning-effort value')
|
||||
})
|
||||
|
||||
it('accepts OpenCode-native -s / --session as resume aliases', () => {
|
||||
expect(parseRemoteAgentCommandOptions(
|
||||
['-s', 'opencode-sess-1'],
|
||||
OPENCODE_PERMISSION_MODES
|
||||
).resumeSessionId).toBe('opencode-sess-1')
|
||||
|
||||
expect(parseRemoteAgentCommandOptions(
|
||||
['--session', 'opencode-sess-2'],
|
||||
OPENCODE_PERMISSION_MODES
|
||||
).resumeSessionId).toBe('opencode-sess-2')
|
||||
})
|
||||
|
||||
it('rejects -s / --session with no value', () => {
|
||||
expect(() => parseRemoteAgentCommandOptions(['-s'], OPENCODE_PERMISSION_MODES)).toThrow('Missing -s value')
|
||||
expect(() => parseRemoteAgentCommandOptions(['--session'], OPENCODE_PERMISSION_MODES)).toThrow('Missing --session value')
|
||||
})
|
||||
|
||||
it('a later -s overrides a prior --resume (last-write-wins)', () => {
|
||||
expect(parseRemoteAgentCommandOptions(
|
||||
['--resume', 'first', '-s', 'second'],
|
||||
OPENCODE_PERMISSION_MODES
|
||||
).resumeSessionId).toBe('second')
|
||||
})
|
||||
})
|
||||
|
||||
describe('parseRemoteAgentCommandOptions — pi flavor', () => {
|
||||
|
||||
@@ -43,6 +43,13 @@ export function parseRemoteAgentCommandOptions<TPermissionMode extends Permissio
|
||||
throw new Error('Missing --resume value')
|
||||
}
|
||||
options.resumeSessionId = sessionId
|
||||
} else if (arg === '-s' || arg === '--session') {
|
||||
// OpenCode-native resume flags (hapi opencode -s / --session <id>)
|
||||
const sessionId = args[++i]
|
||||
if (!sessionId) {
|
||||
throw new Error(`Missing ${arg} value`)
|
||||
}
|
||||
options.resumeSessionId = sessionId
|
||||
} else if (arg === '--session-id') {
|
||||
// Pi uses --session-id for exact session resume (RPC mode)
|
||||
const sessionId = args[++i]
|
||||
|
||||
Reference in New Issue
Block a user