@videlic/connect 0.1.1 → 0.1.2
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/install.mjs +32 -4
- package/package.json +2 -2
package/install.mjs
CHANGED
|
@@ -90,10 +90,38 @@ ok("Hook installed");
|
|
|
90
90
|
const settingsPath = join(claudeDir, "settings.json");
|
|
91
91
|
let settings = {};
|
|
92
92
|
if (existsSync(settingsPath)) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
const raw = readFileSync(settingsPath, "utf8");
|
|
94
|
+
if (raw.trim()) {
|
|
95
|
+
try {
|
|
96
|
+
settings = JSON.parse(raw);
|
|
97
|
+
} catch (e) {
|
|
98
|
+
// NEVER fall back to `{}` here.
|
|
99
|
+
//
|
|
100
|
+
// This object is written straight back over settings.json thirteen
|
|
101
|
+
// lines down. Treating a file we could not parse as an empty one
|
|
102
|
+
// therefore deletes everything it held — model, permissions, env,
|
|
103
|
+
// statusLine, and every other tool's hooks — with no backup, and
|
|
104
|
+
// then prints "All set." A single trailing comma is enough to
|
|
105
|
+
// trigger it, which makes the victims precisely the people who
|
|
106
|
+
// edit the file by hand. Their configuration is worth more than
|
|
107
|
+
// our hook: refuse, say where the problem is, and change nothing.
|
|
108
|
+
fail(
|
|
109
|
+
"Your agent settings file has a syntax error, so Videlic left it untouched:\n" +
|
|
110
|
+
` ${settingsPath}\n` +
|
|
111
|
+
` ${e?.message ?? e}\n\n` +
|
|
112
|
+
" Your key is already saved. Fix that file and run this command again.",
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (settings === null || typeof settings !== "object" || Array.isArray(settings)) {
|
|
117
|
+
// Valid JSON, wrong shape ("null", "[]", a bare string). `settings.hooks ??= {}`
|
|
118
|
+
// would throw on null and silently discard the rest on an array, so stop here
|
|
119
|
+
// for the same reason as above.
|
|
120
|
+
fail(
|
|
121
|
+
"Your agent settings file does not contain a JSON object, so Videlic left it untouched:\n" +
|
|
122
|
+
` ${settingsPath}\n\n` +
|
|
123
|
+
" Your key is already saved. Fix that file and run this command again.",
|
|
124
|
+
);
|
|
97
125
|
}
|
|
98
126
|
}
|
|
99
127
|
settings.hooks ??= {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@videlic/connect",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Connect your coding agent to Videlic
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Connect your coding agent to Videlic \u2014 installs a Stop hook that sends each finished session for review. Works on macOS, Windows, and Linux.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"connect": "install.mjs"
|