chore(integration): snapshot local main worktree

This commit is contained in:
inman
2026-08-31 10:23:21 +08:00
parent 48a9189939
commit 33fb31fb28
116 changed files with 8108 additions and 3026 deletions

View File

@@ -1,7 +1,7 @@
// @vitest-environment node
import { spawn } from 'node:child_process';
import { mkdir, mkdtemp, readFile, readdir, rm } from 'node:fs/promises';
import { mkdir, mkdtemp, readFile, readdir, rm, writeFile } from 'node:fs/promises';
import { tmpdir } from 'node:os';
import path from 'node:path';
import { afterEach, describe, expect, it, vi } from 'vitest';
@@ -12,6 +12,7 @@ import {
import { atomicWriteJson } from '../../electron/coding-projects/atomic-json';
import {
createCodingProjectAgent,
createCodingProjectConfigV2,
readCodingProjectConfigV2,
} from '../../electron/coding-projects/project-config';
import {
@@ -117,6 +118,33 @@ describe('coding project schema v2', () => {
expect(conversationDurationMs).toBeLessThan(500);
});
it('uses .makelore as the only project metadata namespace', async () => {
const projectPath = await makeProjectPath();
const store = createCodingProjectStore(createMemoryCodingProjectStorage(), {
createId: () => 'project-makelore-only',
now: () => NOW,
});
await createLocalCodingProject({ projectPath, now: NOW }, store);
expect(JSON.parse(await readFile(
path.join(projectPath, '.makelore', 'project.json'),
'utf8',
))).toMatchObject({ schemaVersion: 2 });
await expect(readFile(
path.join(projectPath, '.niancode', 'project.json'),
'utf8',
)).rejects.toMatchObject({ code: 'ENOENT' });
const oldNamespaceOnly = await makeProjectPath();
await mkdir(path.join(oldNamespaceOnly, '.niancode'), { recursive: true });
await writeFile(
path.join(oldNamespaceOnly, '.niancode', 'project.json'),
JSON.stringify(createCodingProjectConfigV2(NOW)),
'utf8',
);
await expect(readCodingProjectConfigV2(oldNamespaceOnly)).resolves.toEqual({ status: 'missing' });
});
it('requires an explicit model selection when resolution is required', async () => {
const projectPath = await makeProjectPath();
const store = createCodingProjectStore(createMemoryCodingProjectStorage(), {
@@ -207,7 +235,7 @@ describe('coding Conversation schema v2', () => {
expect.objectContaining({ piSessionId: 'pi-session-1', sessionKey: 'session-opaque-1' }),
]);
expect(createBinding).toHaveBeenCalledTimes(1);
expect(JSON.parse(await readFile(path.join(projectPath, '.niancode', 'conversations.json'), 'utf8')))
expect(JSON.parse(await readFile(path.join(projectPath, '.makelore', 'conversations.json'), 'utf8')))
.toMatchObject({
schemaVersion: 2,
conversations: [{ piSessionId: 'pi-session-1', sessionKey: 'session-opaque-1' }],
@@ -216,7 +244,7 @@ describe('coding Conversation schema v2', () => {
it('atomically replaces JSON and cleans its temporary file after a failed replace', async () => {
const projectPath = await makeProjectPath();
const metadataDirectory = path.join(projectPath, '.niancode');
const metadataDirectory = path.join(projectPath, '.makelore');
const filePath = path.join(metadataDirectory, 'atomic.json');
await atomicWriteJson(filePath, { version: 1 });
await atomicWriteJson(filePath, { version: 2 });