fix(clean): correct project-tech field references and add sync vs clean disambiguation

- Fix Step 4.3: project.features → project.development_index,
  project.statistics → project._metadata
- Add project-guidelines.json learnings cleanup on session deletion
- Add sync vs clean disambiguation table explaining write vs reclaim
This commit is contained in:
catlog22
2026-02-25 22:34:15 +08:00
parent f96febe09a
commit c92754505a
9 changed files with 139 additions and 23 deletions

View File

@@ -475,21 +475,43 @@ if (selectedCategories.includes('Sessions')) {
}
}
// Update project-tech.json if features referenced deleted sessions
// Update project-tech.json: remove development_index entries referencing deleted sessions
const projectPath = '.workflow/project-tech.json'
if (fileExists(projectPath)) {
const project = JSON.parse(Read(projectPath))
const deletedPaths = new Set(results.deleted)
const deletedSessionIds = results.deleted
.filter(p => p.match(/WFS-|lite-plan/))
.map(p => p.split('/').pop())
project.features = project.features.filter(f =>
!deletedPaths.has(f.traceability?.archive_path)
)
project.statistics.total_features = project.features.length
project.statistics.last_updated = getUtc8ISOString()
if (project.development_index) {
for (const category of Object.keys(project.development_index)) {
project.development_index[category] = project.development_index[category].filter(entry =>
!deletedSessionIds.includes(entry.session_id)
)
}
}
project._metadata.last_updated = getUtc8ISOString()
Write(projectPath, JSON.stringify(project, null, 2))
}
// Update project-guidelines.json: remove learnings referencing deleted sessions
const guidelinesPath = '.workflow/project-guidelines.json'
if (fileExists(guidelinesPath)) {
const guidelines = JSON.parse(Read(guidelinesPath))
const deletedSessionIds = results.deleted
.filter(p => p.match(/WFS-|lite-plan/))
.map(p => p.split('/').pop())
if (guidelines.learnings) {
guidelines.learnings = guidelines.learnings.filter(l =>
!deletedSessionIds.includes(l.session_id)
)
}
guidelines._metadata.updated_at = getUtc8ISOString()
Write(guidelinesPath, JSON.stringify(guidelines, null, 2))
}
```
**Step 4.4: Report Results**
@@ -541,8 +563,10 @@ Cleanup manifest archived to: ${sessionFolder}/cleanup-manifest.json
| Manifest parse error | Regenerate from filesystem scan |
| Empty discovery | Report "codebase is clean" |
## Related Commands
- `/workflow:session:sync` - Sync session work to project-guidelines + project-tech (正向写入)
- `/workflow:session:complete` - Properly archive active sessions
- `memory-capture` skill - Save session memory before cleanup
- `workflow-execute` skill - View current workflow state