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

@@ -17,15 +17,13 @@ import type {
} from '../coding-runtime/contracts';
import { atomicWriteJson, readJsonFile, type JsonFileWriter } from './atomic-json';
export const CODING_PROJECT_CONFIG_PATH = '.niancode/project.json';
export const LEGACY_CONVERSATION_NOTICE_VALUES = ['none', 'pending', 'acknowledged'] as const;
export type LegacyConversationNotice = (typeof LEGACY_CONVERSATION_NOTICE_VALUES)[number];
// Makelore owns project metadata; Pi only consumes the resolved project resources.
export const CODING_PROJECT_CONFIG_PATH = '.makelore/project.json';
export interface CodingProjectAgentV2 extends CodingProjectAgent, ConversationModelState {}
export interface CodingProjectConfigV2 extends CodingProjectConfig {
agents: CodingProjectAgentV2[];
legacyConversationNotice: LegacyConversationNotice;
}
export type CodingProjectConfigReadResult =
@@ -188,9 +186,6 @@ export function normalizeCodingProjectConfigV2(value: unknown): CodingProjectCon
const createdAt = cleanString(record.createdAt);
const updatedAt = cleanString(record.updatedAt);
if (!createdAt || !updatedAt) throw new Error('Project timestamps are required');
if (!LEGACY_CONVERSATION_NOTICE_VALUES.includes(record.legacyConversationNotice as LegacyConversationNotice)) {
throw new Error('Legacy Conversation notice state is invalid');
}
const agents = record.agents.map(normalizeAgent);
if (new Set(agents.map((agent) => agent.id)).size !== agents.length) {
throw new Error('Duplicate project Agent id');
@@ -202,7 +197,6 @@ export function normalizeCodingProjectConfigV2(value: unknown): CodingProjectCon
initialized: record.initialized === true,
agents,
knowledgeDirectory: 'knowledge',
legacyConversationNotice: record.legacyConversationNotice as LegacyConversationNotice,
createdAt,
updatedAt,
};
@@ -218,7 +212,6 @@ export function createCodingProjectConfigV2(
initialized: false,
agents: [],
knowledgeDirectory: 'knowledge',
legacyConversationNotice: 'none',
createdAt: now,
updatedAt: now,
};
@@ -264,7 +257,7 @@ export async function createCodingProjectMetadata(
}
const config = createCodingProjectConfigV2(options.now, options.projectType);
await Promise.all([
mkdir(path.join(projectPath, '.niancode'), { recursive: true }),
mkdir(path.join(projectPath, '.makelore'), { recursive: true }),
mkdir(path.join(projectPath, 'knowledge'), { recursive: true }),
]);
await (options.writer ?? atomicWriteJson)(projectConfigPath(projectPath), config);
@@ -301,17 +294,3 @@ export async function createCodingProjectAgent(
}, options.writer);
return agent;
}
export async function acknowledgeLegacyConversationNotice(
projectPath: string,
options: { now?: string; writer?: JsonFileWriter } = {},
): Promise<CodingProjectConfigV2> {
const result = await readCodingProjectConfigV2(projectPath);
if (result.status !== 'valid') throw new Error('Coding project configuration is missing or invalid');
if (result.config.legacyConversationNotice !== 'pending') return result.config;
return await writeCodingProjectConfigV2(projectPath, {
...result.config,
legacyConversationNotice: 'acknowledged',
updatedAt: options.now ?? new Date().toISOString(),
}, options.writer);
}