fix: close PI-140 cutover gaps

Back up unknown legacy Agents, reconnect settled Conversation observation, remove remaining active repository residue, and restore the bundled Python verifier import.
This commit is contained in:
2026-08-24 12:47:16 +08:00
parent 5a275b93a7
commit 7a15b1b49c
12 changed files with 286 additions and 247 deletions

View File

@@ -202,7 +202,7 @@ describe('coding project v1 to v2 migration', () => {
]);
expect(resolveLegacyModel).toHaveBeenCalledTimes(2);
expect(result.removedGeneratedAgents.sort()).toEqual(['no-account.md', 'unique.md']);
expect(result.backedUpUncertainAgents).toEqual(['unresolved.md']);
expect(result.backedUpUncertainAgents).toEqual(['custom.md', 'unresolved.md']);
expect(JSON.parse(await readFile(
path.join(staged.projectPath, '.niancode', 'conversations.json'),
'utf8',
@@ -215,8 +215,12 @@ describe('coding project v1 to v2 migration', () => {
path.join(result.backupDirectory, '.opencode', 'agent', 'unresolved.md'),
'utf8',
)).toBe('locally modified Agent\n');
expect(await readFile(
path.join(result.backupDirectory, '.opencode', 'agent', 'custom.md'),
'utf8',
)).toBe('unknown Agent\n');
await expect(readFile(unresolvedFile, 'utf8')).rejects.toMatchObject({ code: 'ENOENT' });
expect(await readFile(customFile, 'utf8')).toBe('unknown Agent\n');
await expect(readFile(customFile, 'utf8')).rejects.toMatchObject({ code: 'ENOENT' });
expect(await readFile(path.join(staged.projectPath, '.opencode', 'skills', 'keep.md'), 'utf8'))
.toBe('keep me');
@@ -249,6 +253,8 @@ describe('coding project v1 to v2 migration', () => {
it('restores retryable v1 state after a corrupt metadata write and succeeds on retry', async () => {
const staged = await stageLegacyProject();
const customFile = path.join(staged.projectPath, '.opencode', 'agent', 'custom.md');
await writeFile(customFile, 'unknown Agent\n', 'utf8');
let writeCount = 0;
const corruptingWriter = vi.fn(async (filePath: string, value: unknown) => {
writeCount += 1;
@@ -273,6 +279,7 @@ describe('coding project v1 to v2 migration', () => {
expect(await readFile(path.join(staged.projectPath, '.opencode', entry.relativePath), 'utf8'))
.toBe(entry.content);
}
expect(await readFile(customFile, 'utf8')).toBe('unknown Agent\n');
const retry = await migrateCodingProjectToV2(staged.projectPath, {
resolveLegacyModel: async ({ legacyModel }) => legacyModel === 'legacy/unique' ? MODEL : null,
@@ -283,5 +290,11 @@ describe('coding project v1 to v2 migration', () => {
path.join(staged.projectPath, '.niancode', 'conversations.json'),
'utf8',
))).toEqual({ schemaVersion: 2, conversations: [] });
expect(retry.backedUpUncertainAgents).toEqual(['custom.md']);
await expect(readFile(customFile, 'utf8')).rejects.toMatchObject({ code: 'ENOENT' });
expect(await readFile(
path.join(retry.backupDirectory, '.opencode', 'agent', 'custom.md'),
'utf8',
)).toBe('unknown Agent\n');
});
});