@vibe-x/agent-better-checkpoint 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.mjs +80 -0
- package/package.json +1 -1
- package/platform/unix/checkpoint.sh +4 -3
- package/platform/win/checkpoint.ps1 +5 -4
- package/skill/SKILL.md +4 -4
package/bin/cli.mjs
CHANGED
|
@@ -142,6 +142,80 @@ function writeJsonFile(filepath, data) {
|
|
|
142
142
|
writeFileSync(filepath, JSON.stringify(data, null, 2) + '\n', 'utf-8');
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
+
// ============================================================
|
|
146
|
+
// AGENTS.md block management
|
|
147
|
+
// ============================================================
|
|
148
|
+
|
|
149
|
+
const AGENTS_BLOCK_START = '<!-- [ABC:agent-better-checkpoint:start] -->';
|
|
150
|
+
const AGENTS_BLOCK_END = '<!-- [ABC:agent-better-checkpoint:end] -->';
|
|
151
|
+
|
|
152
|
+
const AGENTS_BLOCK_CONTENT = `${AGENTS_BLOCK_START}
|
|
153
|
+
## Checkpoint Commit Rule
|
|
154
|
+
|
|
155
|
+
After completing any file edit (write_to_file, replace_in_file, multi_replace_in_file, or similar),
|
|
156
|
+
you MUST:
|
|
157
|
+
|
|
158
|
+
1. Load the "agent-better-checkpoint" skill (if not already loaded)
|
|
159
|
+
2. Follow its instructions to create a checkpoint commit
|
|
160
|
+
3. Do NOT proceed to the next task until the commit is done
|
|
161
|
+
|
|
162
|
+
This ensures every meaningful code change is tracked with a semantic Git commit.
|
|
163
|
+
${AGENTS_BLOCK_END}`;
|
|
164
|
+
|
|
165
|
+
function injectAgentsMdBlock(targetDir) {
|
|
166
|
+
const agentsMdPath = join(targetDir, 'AGENTS.md');
|
|
167
|
+
let content = '';
|
|
168
|
+
|
|
169
|
+
if (existsSync(agentsMdPath)) {
|
|
170
|
+
content = readFileSync(agentsMdPath, 'utf-8');
|
|
171
|
+
// Check if block already exists
|
|
172
|
+
if (content.includes(AGENTS_BLOCK_START)) {
|
|
173
|
+
console.log(` AGENTS.md → block already exists (skipped)`);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// Append block to end of file (or create new file)
|
|
179
|
+
const newContent = content
|
|
180
|
+
? content.trimEnd() + '\n\n' + AGENTS_BLOCK_CONTENT + '\n'
|
|
181
|
+
: AGENTS_BLOCK_CONTENT + '\n';
|
|
182
|
+
|
|
183
|
+
writeFileSync(agentsMdPath, newContent, 'utf-8');
|
|
184
|
+
console.log(` AGENTS.md → ${agentsMdPath}`);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function removeAgentsMdBlock(targetDir) {
|
|
188
|
+
const agentsMdPath = join(targetDir, 'AGENTS.md');
|
|
189
|
+
|
|
190
|
+
if (!existsSync(agentsMdPath)) {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const content = readFileSync(agentsMdPath, 'utf-8');
|
|
195
|
+
|
|
196
|
+
if (!content.includes(AGENTS_BLOCK_START)) {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// Remove the block (including surrounding newlines)
|
|
201
|
+
const blockRegex = new RegExp(
|
|
202
|
+
`\\n*${AGENTS_BLOCK_START.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}[\\s\\S]*?${AGENTS_BLOCK_END.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\n*`,
|
|
203
|
+
'g'
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
let newContent = content.replace(blockRegex, '\n');
|
|
207
|
+
newContent = newContent.trim();
|
|
208
|
+
|
|
209
|
+
if (newContent === '') {
|
|
210
|
+
// If file is empty after removal, delete it
|
|
211
|
+
rmSync(agentsMdPath, { force: true });
|
|
212
|
+
console.log(` Removed ${agentsMdPath} (empty after cleanup)`);
|
|
213
|
+
} else {
|
|
214
|
+
writeFileSync(agentsMdPath, newContent + '\n', 'utf-8');
|
|
215
|
+
console.log(` Cleaned ${agentsMdPath}`);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
145
219
|
// ============================================================
|
|
146
220
|
// Install logic
|
|
147
221
|
// ============================================================
|
|
@@ -271,6 +345,9 @@ function installProjectOnly(targetDir, aiPlatform, osType) {
|
|
|
271
345
|
// Claude Code: settings.json 为全局,无项目级 hooks,仅安装 skill 和脚本
|
|
272
346
|
console.log(` Hooks → (Claude stop hook is global-only, skipped for project install)`);
|
|
273
347
|
}
|
|
348
|
+
|
|
349
|
+
// Inject AGENTS.md block (project-only)
|
|
350
|
+
injectAgentsMdBlock(root);
|
|
274
351
|
}
|
|
275
352
|
|
|
276
353
|
function uninstallProjectOnly(targetDir, aiPlatform) {
|
|
@@ -326,6 +403,9 @@ function uninstallProjectOnly(targetDir, aiPlatform) {
|
|
|
326
403
|
rmSync(hooksDir, { recursive: true, force: true });
|
|
327
404
|
}
|
|
328
405
|
}
|
|
406
|
+
|
|
407
|
+
// Remove AGENTS.md block
|
|
408
|
+
removeAgentsMdBlock(root);
|
|
329
409
|
}
|
|
330
410
|
|
|
331
411
|
function registerClaudeHook(osType) {
|
package/package.json
CHANGED
|
@@ -42,10 +42,11 @@ fi
|
|
|
42
42
|
# Platform detection
|
|
43
43
|
# ============================================================
|
|
44
44
|
detect_platform() {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
elif [[ -n "${CURSOR_VERSION:-}" ]] || [[ -n "${CURSOR_TRACE_ID:-}" ]]; then
|
|
45
|
+
# 优先检测运行时环境变量(谁在调用),而非安装态(command -v)
|
|
46
|
+
if [[ -n "${CURSOR_AGENT:-}" ]] || [[ -n "${CURSOR_TRACE_ID:-}" ]] || [[ -n "${CURSOR_VERSION:-}" ]]; then
|
|
48
47
|
echo "cursor"
|
|
48
|
+
elif [[ -n "${CLAUDE_CODE:-}" ]]; then
|
|
49
|
+
echo "claude-code"
|
|
49
50
|
else
|
|
50
51
|
echo "unknown"
|
|
51
52
|
fi
|
|
@@ -38,12 +38,13 @@ $ErrorActionPreference = "Stop"
|
|
|
38
38
|
# ============================================================
|
|
39
39
|
|
|
40
40
|
function Detect-Platform {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
if ($env:CURSOR_VERSION -or $env:CURSOR_TRACE_ID) {
|
|
41
|
+
# 优先检测运行时环境变量(谁在调用),而非安装态(Get-Command)
|
|
42
|
+
if ($env:CURSOR_AGENT -or $env:CURSOR_TRACE_ID -or $env:CURSOR_VERSION) {
|
|
45
43
|
return "cursor"
|
|
46
44
|
}
|
|
45
|
+
if ($env:CLAUDE_CODE) {
|
|
46
|
+
return "claude-code"
|
|
47
|
+
}
|
|
47
48
|
return "unknown"
|
|
48
49
|
}
|
|
49
50
|
|
package/skill/SKILL.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: agent-better-checkpoint
|
|
3
|
-
description: "
|
|
3
|
+
description: "Creates semantic Git checkpoint commits during AI coding sessions with Conventional Commits format and Git Trailers. Use after completing code edits, or when user says 'commit changes', 'create checkpoint', or 'save my progress'."
|
|
4
4
|
license: MIT
|
|
5
5
|
metadata:
|
|
6
|
-
version: "0.3.
|
|
6
|
+
version: "0.3.3"
|
|
7
7
|
author: "alienzhou"
|
|
8
8
|
category: "version-control"
|
|
9
9
|
---
|
|
@@ -31,7 +31,7 @@ Both `.sh` and `.ps1` are always installed regardless of current OS.
|
|
|
31
31
|
If neither exists, run:
|
|
32
32
|
|
|
33
33
|
```bash
|
|
34
|
-
npx @vibe-x/agent-better-checkpoint@0.3.
|
|
34
|
+
npx @vibe-x/agent-better-checkpoint@0.3.3
|
|
35
35
|
```
|
|
36
36
|
|
|
37
37
|
Without `--target`: installs globally. With `--target .`: project-only (skill + hooks in `.cursor/`, scripts in `.vibe-x/`), no global changes.
|
|
@@ -167,4 +167,4 @@ This should feel natural — commit as you go, like any good developer.
|
|
|
167
167
|
|
|
168
168
|
---
|
|
169
169
|
|
|
170
|
-
**Version**: 0.3.
|
|
170
|
+
**Version**: 0.3.3
|