Skip to content

Commit 3949c4a

Browse files
authored
fix: checkpoint & update evolt (#61)
1 parent c9af68d commit 3949c4a

File tree

6 files changed

+118
-54
lines changed

6 files changed

+118
-54
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "coderio",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "A modern CLI development tool built with TypeScript",
55
"type": "module",
66
"bin": {
@@ -69,7 +69,7 @@
6969
"better-sqlite3": "^11.10.0",
7070
"chalk": "^5.4.1",
7171
"commander": "^12.1.0",
72-
"evoltagent": "^1.1.2",
72+
"evoltagent": "1.1.5",
7373
"js-yaml": "^4.1.1",
7474
"pixelmatch": "^7.1.0",
7575
"prompts": "^2.4.2"

pnpm-lock.yaml

Lines changed: 5 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/graph.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@ export async function design2code(url: string, mode?: ValidationMode): Promise<v
2323

2424
// If not resuming, delete workspace and reinitialize checkpointer
2525
if (resume !== true) {
26-
// Exclude checkpoint directory to avoid EBUSY error on Windows (SQLite lock)
27-
workspaceManager.deleteWorkspace(workspace, ['checkpoint']);
26+
// Preserve only the database file to avoid EBUSY error on Windows (SQLite lock)
27+
workspaceManager.deleteWorkspace(workspace, [
28+
'checkpoint/coderio-cli.db',
29+
'checkpoint/coderio-cli.db-shm',
30+
'checkpoint/coderio-cli.db-wal',
31+
]);
2832
logger.printInfoLog('Starting fresh...');
2933

3034
// Clear existing checkpoints for this thread instead of deleting the file

src/nodes/code/prompt.ts

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,45 @@ const FILE_NAMING_CONVENTION = `
4747

4848
const OUTPUT_FORMAT = `
4949
<output_format>
50-
If only one file (TSX) is needed:
50+
**CRITICAL - Output Format Requirements:**
51+
52+
**CASE 1: Single File (TSX only)**
53+
- Return code wrapped in triple backticks with language identifier
54+
- NO file name header needed
55+
- Example:
5156
\`\`\`tsx
52-
// code...
57+
export default function Component() {
58+
return <div>...</div>;
59+
}
5360
\`\`\`
5461
55-
If multiple files are needed (e.g., TSX + Styles):
62+
**CASE 2: Multiple Files (TSX + Styles)**
63+
- **REQUIRED**: Each file MUST start with EXACTLY \`## \` (two hash symbols + one space) followed by filename
64+
- **REQUIRED**: Filename must be complete with extension (e.g., \`index.tsx\`, \`index.module.css\`)
65+
- **FORBIDDEN**: Do NOT use single \`#\`, do NOT omit filename, do NOT use other markers
66+
- Follow this exact structure:
67+
5668
## index.tsx
5769
\`\`\`tsx
58-
// code...
70+
export default function Component() {
71+
return <div>...</div>;
72+
}
5973
\`\`\`
6074
6175
## index.module.[css|less|scss]
6276
\`\`\`[css|less|scss]
63-
// styles...
77+
.container {
78+
/* styles */
79+
}
6480
\`\`\`
81+
82+
**VALIDATION CHECKLIST (for multiple files):**
83+
✓ Each file section starts with \`## \` (two hashes + space)
84+
✓ Filename includes full extension
85+
✓ Code wrapped in triple backticks with language
86+
✗ DO NOT use \`# filename\` (single hash)
87+
✗ DO NOT omit file headers
88+
✗ DO NOT use other separators
6589
</output_format>`;
6690

6791
// ============================================

src/utils/workspace.ts

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,23 +50,45 @@ class Workspace {
5050
/**
5151
* Delete all files and directories inside the workspace
5252
* @param workspace - The workspace structure
53-
* @param exclude - Optional list of file/directory names to exclude from deletion
53+
* @param preserve - Optional list of relative paths (from workspace root) to preserve from deletion
5454
*/
55-
deleteWorkspace(workspace: WorkspaceStructure, exclude: string[] = []): void {
55+
deleteWorkspace(workspace: WorkspaceStructure, preserve: string[] = []): void {
5656
try {
57-
if (fs.existsSync(workspace.root)) {
58-
// Read all entries in the workspace root
59-
const entries = fs.readdirSync(workspace.root);
57+
if (!fs.existsSync(workspace.root)) return;
6058

61-
// Delete each entry
59+
// Build set of normalized relative paths to preserve
60+
const preserveFiles = new Set(preserve.map(p => path.normalize(p)));
61+
62+
// Collect ancestor directories of preserved files
63+
const preserveDirs = new Set<string>();
64+
for (const p of preserveFiles) {
65+
let dir = path.dirname(p);
66+
while (dir !== '.') {
67+
preserveDirs.add(dir);
68+
dir = path.dirname(dir);
69+
}
70+
}
71+
72+
const deleteRecursive = (dirPath: string, relativeTo: string = '') => {
73+
const entries = fs.readdirSync(dirPath);
6274
for (const entry of entries) {
63-
if (exclude.includes(entry)) {
64-
continue;
75+
const fullPath = path.join(dirPath, entry);
76+
const relPath = relativeTo ? path.join(relativeTo, entry) : entry;
77+
78+
if (preserveFiles.has(relPath)) {
79+
continue; // This file is preserved
80+
}
81+
82+
if (preserveDirs.has(relPath)) {
83+
// Directory contains preserved files, recurse into it
84+
deleteRecursive(fullPath, relPath);
85+
} else {
86+
fs.rmSync(fullPath, { recursive: true, force: true });
6587
}
66-
const fullPath = path.join(workspace.root, entry);
67-
fs.rmSync(fullPath, { recursive: true, force: true });
6888
}
69-
}
89+
};
90+
91+
deleteRecursive(workspace.root);
7092
} catch (error) {
7193
const errorMessage = error instanceof Error ? error.message : String(error);
7294
logger.printWarnLog(`Failed to delete workspace: ${errorMessage}`);

0 commit comments

Comments
 (0)