Initial commit: pi-project-map skill scaffolding
- Design doc with full spec (dense markdown format, hybrid AST+LLM pipeline, consumption model, stale data mitigation) - Implementation plan with 6 milestones and rollout strategy - TypeScript package structure with all source stubs - CLI entry point, formatter, discover, init, patch, validate, extract, merge - Pi SKILL.md with tool definitions and format documentation
This commit is contained in:
+42
@@ -0,0 +1,42 @@
|
||||
import { discoverProject } from './discover.js';
|
||||
import { renderPackageMap, type PackageMapData } from './format.js';
|
||||
import { extractFileLLM } from './llm-extract.js';
|
||||
import { extractFileAST } from './ast-extract.js';
|
||||
import { mergeFileData } from './merge.js';
|
||||
import { extractPackageLLM } from './llm-extract.js';
|
||||
import { writeFileSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
|
||||
export async function initProject(rootPath: string): Promise<void> {
|
||||
const entries = discoverProject(rootPath);
|
||||
|
||||
for (const entry of entries) {
|
||||
const fileData = [];
|
||||
for (const file of entry.files) {
|
||||
const filePath = join(entry.dirPath, file);
|
||||
const llmData = await extractFileLLM(filePath);
|
||||
const astData = await extractFileAST(filePath);
|
||||
fileData.push(mergeFileData(file, llmData, astData));
|
||||
}
|
||||
|
||||
const packageData = await extractPackageLLM(entry.relativePath, fileData);
|
||||
|
||||
const mapData: PackageMapData = {
|
||||
path: entry.relativePath,
|
||||
role: packageData.role,
|
||||
files: fileData,
|
||||
arch: packageData.arch,
|
||||
dirty: '-'
|
||||
};
|
||||
|
||||
const outPath = join(entry.dirPath, '.pi-map.md');
|
||||
writeFileSync(outPath, renderPackageMap(mapData));
|
||||
}
|
||||
|
||||
console.log(`Generated ${entries.length} .pi-map.md files`);
|
||||
}
|
||||
|
||||
export async function reinitPath(path: string): Promise<void> {
|
||||
// TODO: clear dirty markers and force regeneration
|
||||
await initProject(path);
|
||||
}
|
||||
Reference in New Issue
Block a user