Implement all stubs: parsePackageMap, LLM heuristics, tree-sitter AST, patch rewrite, reinit
- format.ts: Full parsePackageMap implementation with round-trip support
- llm-extract.ts: Heuristic-based extraction without LLM API (regex exports,
imports, purpose inference from filename patterns)
- ast-extract.ts: Tree-sitter integration for TypeScript/TSX with fallback
for other languages
- init.ts: Refactored to expose generateDirectoryMap helper, reinitPath
delegates to initProject
- patch.ts: Small packages now use generateDirectoryMap for full rewrite
- discover.ts: Cleaned up require('fs') to use proper ES import
- Tests: 8 tests covering format round-trip and LLM heuristics
- All TypeScript compiles clean, all tests pass
This commit is contained in:
+23
-23
@@ -1,32 +1,32 @@
|
||||
#!/usr/bin/env node
|
||||
import { initProject } from './init.js';
|
||||
import { patchFile } from './patch.js';
|
||||
import { validateMaps } from './validate.js';
|
||||
import { reinitPath } from './init.js';
|
||||
import { initProject } from "./init.js";
|
||||
import { patchFile } from "./patch.js";
|
||||
import { validateMaps } from "./validate.js";
|
||||
import { reinitPath } from "./init.js";
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
const command = args[0];
|
||||
|
||||
async function main() {
|
||||
switch (command) {
|
||||
case 'init':
|
||||
await initProject(args[1] || '.');
|
||||
break;
|
||||
case 'patch':
|
||||
await patchFile(args[1]);
|
||||
break;
|
||||
case 'validate': {
|
||||
const result = await validateMaps(args[1] || '.');
|
||||
process.exit(result.clean ? 0 : 1);
|
||||
break;
|
||||
}
|
||||
case 'reinit':
|
||||
await reinitPath(args[1] || '.');
|
||||
break;
|
||||
default:
|
||||
console.log(`Usage: project-map <init|patch|validate|reinit> [path]`);
|
||||
process.exit(1);
|
||||
}
|
||||
switch (command) {
|
||||
case "init":
|
||||
await initProject(args[1] || ".");
|
||||
break;
|
||||
case "patch":
|
||||
await patchFile(args[1]);
|
||||
break;
|
||||
case "validate": {
|
||||
const result = await validateMaps(args[1] || ".");
|
||||
process.exit(result.clean ? 0 : 1);
|
||||
break;
|
||||
}
|
||||
case "reinit":
|
||||
await reinitPath(args[1] || ".");
|
||||
break;
|
||||
default:
|
||||
console.log(`Usage: project-map <init|patch|validate|reinit> [path]`);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
|
||||
Reference in New Issue
Block a user