@videlic/connect 0.1.1 → 0.1.7
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/README.md +4 -0
- package/evidence.d.mts +172 -0
- package/evidence.mjs +3005 -0
- package/hook.mjs +1468 -42
- package/install.mjs +38 -4
- package/package.json +9 -1
package/install.mjs
CHANGED
|
@@ -71,6 +71,12 @@ ok("Key valid");
|
|
|
71
71
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
72
72
|
const hookDest = join(claudeDir, "videlic-hook.mjs");
|
|
73
73
|
copyFileSync(join(here, "hook.mjs"), hookDest);
|
|
74
|
+
// The hook imports this one at the moment it collects evidence, by a RELATIVE
|
|
75
|
+
// path, so the two must land in the same directory or the import throws — in a
|
|
76
|
+
// detached process, where the only sign would be a line in the log. Copied
|
|
77
|
+
// second and unconditionally: a machine left with a new hook beside an old
|
|
78
|
+
// collector is the one shape neither file can detect.
|
|
79
|
+
copyFileSync(join(here, "evidence.mjs"), join(claudeDir, "evidence.mjs"));
|
|
74
80
|
|
|
75
81
|
const configPath = join(claudeDir, "videlic.json");
|
|
76
82
|
writeFileSync(
|
|
@@ -90,10 +96,38 @@ ok("Hook installed");
|
|
|
90
96
|
const settingsPath = join(claudeDir, "settings.json");
|
|
91
97
|
let settings = {};
|
|
92
98
|
if (existsSync(settingsPath)) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
99
|
+
const raw = readFileSync(settingsPath, "utf8");
|
|
100
|
+
if (raw.trim()) {
|
|
101
|
+
try {
|
|
102
|
+
settings = JSON.parse(raw);
|
|
103
|
+
} catch (e) {
|
|
104
|
+
// NEVER fall back to `{}` here.
|
|
105
|
+
//
|
|
106
|
+
// This object is written straight back over settings.json thirteen
|
|
107
|
+
// lines down. Treating a file we could not parse as an empty one
|
|
108
|
+
// therefore deletes everything it held — model, permissions, env,
|
|
109
|
+
// statusLine, and every other tool's hooks — with no backup, and
|
|
110
|
+
// then prints "All set." A single trailing comma is enough to
|
|
111
|
+
// trigger it, which makes the victims precisely the people who
|
|
112
|
+
// edit the file by hand. Their configuration is worth more than
|
|
113
|
+
// our hook: refuse, say where the problem is, and change nothing.
|
|
114
|
+
fail(
|
|
115
|
+
"Your agent settings file has a syntax error, so Videlic left it untouched:\n" +
|
|
116
|
+
` ${settingsPath}\n` +
|
|
117
|
+
` ${e?.message ?? e}\n\n` +
|
|
118
|
+
" Your key is already saved. Fix that file and run this command again.",
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (settings === null || typeof settings !== "object" || Array.isArray(settings)) {
|
|
123
|
+
// Valid JSON, wrong shape ("null", "[]", a bare string). `settings.hooks ??= {}`
|
|
124
|
+
// would throw on null and silently discard the rest on an array, so stop here
|
|
125
|
+
// for the same reason as above.
|
|
126
|
+
fail(
|
|
127
|
+
"Your agent settings file does not contain a JSON object, so Videlic left it untouched:\n" +
|
|
128
|
+
` ${settingsPath}\n\n` +
|
|
129
|
+
" Your key is already saved. Fix that file and run this command again.",
|
|
130
|
+
);
|
|
97
131
|
}
|
|
98
132
|
}
|
|
99
133
|
settings.hooks ??= {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@videlic/connect",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Connect your coding agent to Videlic — installs a Stop hook that sends each finished session for review. Works on macOS, Windows, and Linux.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -9,8 +9,13 @@
|
|
|
9
9
|
"files": [
|
|
10
10
|
"install.mjs",
|
|
11
11
|
"hook.mjs",
|
|
12
|
+
"evidence.mjs",
|
|
13
|
+
"evidence.d.mts",
|
|
12
14
|
"README.md"
|
|
13
15
|
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"test": "vitest"
|
|
18
|
+
},
|
|
14
19
|
"engines": {
|
|
15
20
|
"node": ">=18"
|
|
16
21
|
},
|
|
@@ -18,5 +23,8 @@
|
|
|
18
23
|
"homepage": "https://videlic.dev",
|
|
19
24
|
"publishConfig": {
|
|
20
25
|
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"vitest": "^3.2.4"
|
|
21
29
|
}
|
|
22
30
|
}
|