Files
deepseek-harness/packages/host/plugin-inventory/tests/persist.spec.ts
T
Pine 3e0eca752c feat(plugin-inventory): add setEnabled Remote that toggles and persists a plugin
pluginInventory/setEnabled calls ctx.loader.update({disabled}) for a live
effect and writes an explicit disabled override into the profile's user
patch layer so the choice survives a restart. The patch row id is the bare
entry options.id, not the group-prefixed tree id.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-14 13:53:24 +08:00

39 lines
1.6 KiB
TypeScript

import { mkdtempSync, readFileSync, writeFileSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { describe, expect, it } from 'vitest'
import { persistPluginDisabled } from '../src/persist.ts'
/** A scratch profile dir with a given starting patch. */
function profile(initial: string): string {
const dir = mkdtempSync(join(tmpdir(), 'dsh-plugin-persist-'))
writeFileSync(join(dir, 'cordis.patch.yml'), initial)
return dir
}
describe('persistPluginDisabled', () => {
it('appends a disabled override to an empty patch', () => {
const dir = profile('[]\n')
persistPluginDisabled(dir, 'image-recognition-http', true)
const text = readFileSync(join(dir, 'cordis.patch.yml'), 'utf8')
expect(text).toContain('image-recognition-http')
expect(text).toContain('disabled: true')
})
it('writes disabled: false to override a bundle-default disable', () => {
const dir = profile('- id: tool-web\n disabled: true\n')
persistPluginDisabled(dir, 'tool-web', false)
const text = readFileSync(join(dir, 'cordis.patch.yml'), 'utf8')
expect(text).toContain('tool-web')
expect(text).toContain('disabled: false')
})
it('replaces an existing override for the same row instead of duplicating', () => {
const dir = profile('- id: image-recognition-http\n disabled: true\n')
persistPluginDisabled(dir, 'image-recognition-http', false)
const text = readFileSync(join(dir, 'cordis.patch.yml'), 'utf8')
expect(text.match(/image-recognition-http/g)).toHaveLength(1)
expect(text).not.toContain('disabled: true')
})
})