@vibe-x/agent-better-checkpoint 0.3.1 → 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 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibe-x/agent-better-checkpoint",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "Semantic Git checkpoint commits for AI coding sessions",
5
5
  "type": "module",
6
6
  "bin": {
@@ -42,10 +42,11 @@ fi
42
42
  # Platform detection
43
43
  # ============================================================
44
44
  detect_platform() {
45
- if [[ -n "${CLAUDE_CODE:-}" ]] || command -v claude &>/dev/null; then
46
- echo "claude-code"
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
- if ($env:CLAUDE_CODE -or (Get-Command claude -ErrorAction SilentlyContinue)) {
42
- return "claude-code"
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: "Automatically creates semantic Git checkpoint commits during AI coding sessions. Replaces opaque platform checkpoints with transparent, queryable Git commits using Conventional Commits format with Git Trailers. You MUST follow this skill whenever you make code changes commit after each meaningful edit."
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.1"
6
+ version: "0.3.3"
7
7
  author: "alienzhou"
8
8
  category: "version-control"
9
9
  ---
@@ -18,17 +18,20 @@ You are an AI coding assistant with **checkpoint awareness**. Every meaningful e
18
18
 
19
19
  ## 🔧 Installation Check
20
20
 
21
- Before your first commit, verify the checkpoint scripts are available:
21
+ Before your first commit, verify the checkpoint scripts are available.
22
22
 
23
- **Project-local (preferred):** Check if `.vibe-x/agent-better-checkpoint/checkpoint.sh` (or `.ps1`) exists in the workspace.
24
- **Global fallback:** Check if `~/.vibe-x/agent-better-checkpoint/scripts/checkpoint.sh` (or `.ps1`) exists.
23
+ **IMPORTANT: Use your file-listing/read tools (NOT shell `test -f`) to check existence.** Shell relative paths break when CWD ≠ workspace root.
24
+
25
+ Check in order (stop at first hit):
26
+ 1. **Project-local (preferred):** `.vibe-x/agent-better-checkpoint/checkpoint.sh` (or `.ps1`) relative to workspace root.
27
+ 2. **Global fallback:** `~/.vibe-x/agent-better-checkpoint/scripts/checkpoint.sh` (or `.ps1`).
25
28
 
26
29
  Both `.sh` and `.ps1` are always installed regardless of current OS.
27
30
 
28
31
  If neither exists, run:
29
32
 
30
33
  ```bash
31
- npx @vibe-x/agent-better-checkpoint@0.3.1
34
+ npx @vibe-x/agent-better-checkpoint@0.3.3
32
35
  ```
33
36
 
34
37
  Without `--target`: installs globally. With `--target .`: project-only (skill + hooks in `.cursor/`, scripts in `.vibe-x/`), no global changes.
@@ -164,4 +167,4 @@ This should feel natural — commit as you go, like any good developer.
164
167
 
165
168
  ---
166
169
 
167
- **Version**: 0.3.1
170
+ **Version**: 0.3.3