merge: integrate upstream main with local Makelore changes

This commit is contained in:
inman
2026-08-31 10:55:48 +08:00
128 changed files with 8278 additions and 3030 deletions

View File

@@ -18,15 +18,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 =
@@ -210,9 +208,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');
@@ -225,7 +220,6 @@ export function normalizeCodingProjectConfigV2(value: unknown): CodingProjectCon
initialized: record.initialized === true,
agents,
knowledgeDirectory: 'knowledge',
legacyConversationNotice: record.legacyConversationNotice as LegacyConversationNotice,
createdAt,
updatedAt,
};
@@ -246,7 +240,6 @@ export function createCodingProjectConfigV2(
initialized: false,
agents: [],
knowledgeDirectory: 'knowledge',
legacyConversationNotice: 'none',
createdAt: now,
updatedAt: now,
};
@@ -293,7 +286,7 @@ export async function createCodingProjectMetadata(
}
const config = createCodingProjectConfigV2(options.now, options.projectType, options.projectId);
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);
@@ -330,17 +323,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);
}