v2.1.4 add 100% reliable commit auto-recording
Added
-
Git Hook Auto-Record: Built-in Git Hook system for 100% reliable commit capture and recording
- Automatically installs post-commit hook to
.git/hooks/ - Captures commit metadata: hash, message, author, date, changed files
- Communicates via
.devmind/pending-commit.jsontrigger file - Cross-platform compatible (Windows/Unix/Mac)
- Compatible with existing hooks (appends instead of overwriting)
- Non-intrusive: Fails silently when Git is unavailable
- Location:
src/git-hook-installer.ts(249 lines)
- Automatically installs post-commit hook to
-
AI Tool Description Enhancement: Added MANDATORY recording rules in
record_contexttool description- AI self-check checklist: Must call record_context after git push/npm publish
- Language matching rules: Write content field based on conversation/project language
- Examples with correct/incorrect patterns: Chinese projects use Chinese, English projects use English
- Location:
src/mcp-server.ts:263-314
-
Local Test Script: Created
test-git-hook.cjsfor local Git Hook functionality testing- 6-step complete test workflow
- Simulated commit trigger
- Information parsing verification
- No actual git commit required
Improved
- Auto-Memory Reliability: Git commit auto-recording no longer depends on AI judgment, 100% reliable trigger
- Project Language Detection: Automatically detects project language and generates commit records in corresponding language
- Code Comments: All new code uses Chinese comments
Fixed
- File Parsing Bug: Fixed regex error in Git Hook file change parsing
- Issue:
/\\\\s+/should be/\s+/ - Impact: Unable to correctly parse file change list
- Solution: Corrected regex expression
- Location:
src/git-hook-installer.ts:197
- Issue:
Technical Details
-
New Files:
src/git-hook-installer.ts: Git Hook installer (249 lines)test-git-hook.cjs: Local test script (137 lines)
-
Modified Files:
src/mcp-server.ts: Added Git commit watcher and handler logic (+150 lines)- New methods:
setupGitCommitWatcher(),handleGitCommitRecord(),formatCommitContent()
-
Workflow:
User executes git commit ↓ .git/hooks/post-commit auto-triggered ↓ Generates .devmind/pending-commit.json ↓ MCP file watcher detects change ↓ Reads and parses commit info ↓ Auto-calls record_context({type: "commit"}) ↓ ✅ Recording complete, deletes pending file -
Safety Features:
- All operations wrapped in try-catch
- Hook installation failure doesn't affect MCP startup
- File watcher failure handled silently
- No modification to existing code logic
- Auto-skips when .git directory doesn't exist
-
Backward Compatibility: Fully compatible - existing projects and features unaffected
Testing
- ✅ All tests passed
- ✅ Hook installation successful
- ✅ File parsing correct (2 files)
- ✅ Cross-platform compatible
- ✅ Chinese comments