ronds_ai 0.1.18 → 0.1.19

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.
Files changed (2) hide show
  1. package/lib/hooks_deploy.js +20 -16
  2. package/package.json +4 -1
@@ -1,6 +1,7 @@
1
1
  const fs = require('fs');
2
2
  const os = require('os');
3
3
  const path = require('path');
4
+ const commentJson = require('comment-json');
4
5
 
5
6
  const CURSOR_COMMAND = 'npx ronds_ai@latest record cursor';
6
7
  const CLAUDE_COMMAND = 'npx ronds_ai@latest record claude';
@@ -42,7 +43,10 @@ function readJsonFile(filePath, fallback) {
42
43
 
43
44
  let data;
44
45
  try {
45
- data = JSON.parse(raw);
46
+ // comment-json 容忍 JSONC 注释和尾随逗号。~/.claude/settings.json 等
47
+ // Claude/Cursor 配置文件官方支持 JSONC,必须容忍用户加的注释。
48
+ // 注意:写回时仍用 JSON.stringify,原文件中的注释会被丢弃。
49
+ data = commentJson.parse(raw);
46
50
  } catch (error) {
47
51
  const detail = error instanceof Error ? error.message : String(error);
48
52
  throw new Error(`Invalid JSON in ${filePath}: ${detail}`);
@@ -424,19 +428,19 @@ function generateRondsHookBlocks(newline) {
424
428
  ].join(newline);
425
429
  }
426
430
 
427
- function ensureCodexRequirementsToml(reqPath) {
428
- const exists = fs.existsSync(reqPath);
429
- let content = exists ? fs.readFileSync(reqPath, 'utf8') : '';
430
- if (content.charCodeAt(0) === 0xFEFF) {
431
- content = content.slice(1);
432
- }
433
- const newline = content.includes('\r\n') ? '\r\n' : '\n';
431
+ function ensureCodexRequirementsToml(reqPath) {
432
+ const exists = fs.existsSync(reqPath);
433
+ let content = exists ? fs.readFileSync(reqPath, 'utf8') : '';
434
+ if (content.charCodeAt(0) === 0xFEFF) {
435
+ content = content.slice(1);
436
+ }
437
+ const newline = content.includes('\r\n') ? '\r\n' : '\n';
434
438
 
435
439
  content = ensureCodexHooksFeatureFlag(content);
436
440
  content = ensureCodexManagedDir(content, reqPath);
437
441
  content = removeRondsBlocksFromToml(content);
438
- content = content.replace(/[\t ]*\r?\n*$/, newline);
439
- content += generateRondsHookBlocks(newline);
442
+ content = content.replace(/[\t ]*\r?\n*$/, newline);
443
+ content += generateRondsHookBlocks(newline);
440
444
 
441
445
  const changed = writeTextFileIfChanged(reqPath, content);
442
446
  return { exists, changed };
@@ -527,16 +531,16 @@ function cleanupClaudeLocalSettings(localCandidates, result) {
527
531
  }
528
532
  }
529
533
 
530
- // 将系统级 Codex requirements.toml 的权限错误转换成面向用户的部署提示。
531
- function wrapCodexPermissionError(error, codexRequirementsPath) {
532
- const code = isPlainObject(error) ? error.code : '';
534
+ // 将系统级 Codex requirements.toml 的权限错误转换成面向用户的部署提示。
535
+ function wrapCodexPermissionError(error, codexRequirementsPath) {
536
+ const code = isPlainObject(error) ? error.code : '';
533
537
  if (code !== 'EACCES' && code !== 'EPERM') {
534
538
  return error;
535
539
  }
536
540
 
537
- const wrapped = new Error(
538
- `Codex 部署需要管理员/root 权限,无法写入 ${codexRequirementsPath}。请以管理员身份重新运行 hooks deploy --scope user。`,
539
- );
541
+ const wrapped = new Error(
542
+ `Codex 部署需要管理员/root 权限,无法写入 ${codexRequirementsPath}。请以管理员身份重新运行 hooks deploy --scope user。`,
543
+ );
540
544
  wrapped.cause = error;
541
545
  wrapped.code = code;
542
546
  return wrapped;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ronds_ai",
3
- "version": "0.1.18",
3
+ "version": "0.1.19",
4
4
  "description": "CLI for reporting AI code edit events.",
5
5
  "bin": {
6
6
  "ronds_ai": "bin/ronds_ai.js"
@@ -12,5 +12,8 @@
12
12
  "engines": {
13
13
  "node": ">=16"
14
14
  },
15
+ "dependencies": {
16
+ "comment-json": "^4.2.5"
17
+ },
15
18
  "license": "MIT"
16
19
  }