greprag 5.10.0 → 5.10.1
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/package.json +1 -1
- package/scripts/postinstall.js +73 -2
package/package.json
CHANGED
package/scripts/postinstall.js
CHANGED
|
@@ -1,4 +1,75 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// Runs automatically after `npm install -g greprag`.
|
|
3
|
-
//
|
|
4
|
-
|
|
3
|
+
//
|
|
4
|
+
// Two responsibilities:
|
|
5
|
+
// 1. Refresh installed bundled skills + chip-spawn doc from the freshly-
|
|
6
|
+
// installed package bundle. Only touches paths that ALREADY exist on
|
|
7
|
+
// the operator's machine — never creates new ones (that's `greprag
|
|
8
|
+
// init`'s job). Closes the staleness gap where `npm i -g greprag@<new>`
|
|
9
|
+
// updated the CLI binary but left `~/.claude/skills/<name>/` files
|
|
10
|
+
// pointing at the old version's expected CLI surface. Without this,
|
|
11
|
+
// the agent's mental model of the CLI drifts away from what the
|
|
12
|
+
// installed binary actually does — see CHANGELOG v5.10.0 (odyssey
|
|
13
|
+
// verb shipped, but local skill stayed at 3.7.0 with no odyssey refs).
|
|
14
|
+
// 2. Print the "run greprag init" prompt when there's nothing to refresh
|
|
15
|
+
// (fresh install, or skills never installed by init).
|
|
16
|
+
//
|
|
17
|
+
// Mirrors `commands/init.ts` Step 6 enumeration so any future advisor
|
|
18
|
+
// skill added under `packages/cli/skill/<name>/` auto-syncs on upgrade
|
|
19
|
+
// without touching this script.
|
|
20
|
+
|
|
21
|
+
const fs = require('fs');
|
|
22
|
+
const path = require('path');
|
|
23
|
+
const os = require('os');
|
|
24
|
+
|
|
25
|
+
const home = os.homedir();
|
|
26
|
+
const skillRoot = path.join(__dirname, '..', 'skill');
|
|
27
|
+
const skillsTarget = path.join(home, '.claude', 'skills');
|
|
28
|
+
const docsTarget = path.join(home, '.claude', 'docs');
|
|
29
|
+
|
|
30
|
+
function copyDir(src, dest) {
|
|
31
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
32
|
+
for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
|
|
33
|
+
const s = path.join(src, entry.name);
|
|
34
|
+
const d = path.join(dest, entry.name);
|
|
35
|
+
if (entry.isDirectory()) copyDir(s, d);
|
|
36
|
+
else fs.copyFileSync(s, d);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const refreshed = [];
|
|
41
|
+
|
|
42
|
+
// Refresh each bundled skill dir that already exists locally.
|
|
43
|
+
try {
|
|
44
|
+
if (fs.existsSync(skillRoot)) {
|
|
45
|
+
for (const entry of fs.readdirSync(skillRoot, { withFileTypes: true })) {
|
|
46
|
+
if (!entry.isDirectory()) continue;
|
|
47
|
+
const installed = path.join(skillsTarget, entry.name);
|
|
48
|
+
if (fs.existsSync(installed)) {
|
|
49
|
+
copyDir(path.join(skillRoot, entry.name), installed);
|
|
50
|
+
refreshed.push('skills/' + entry.name);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
} catch (err) {
|
|
55
|
+
// Postinstall must never break the install. Log and continue.
|
|
56
|
+
console.error(' greprag postinstall: skill refresh skipped (' + err.message + ')');
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Refresh chip-spawn template doc if installed.
|
|
60
|
+
const chipSpawnSrc = path.join(skillRoot, 'templates', 'chip-spawn.md');
|
|
61
|
+
const chipSpawnDest = path.join(docsTarget, 'chip-spawn.md');
|
|
62
|
+
try {
|
|
63
|
+
if (fs.existsSync(chipSpawnSrc) && fs.existsSync(chipSpawnDest)) {
|
|
64
|
+
fs.copyFileSync(chipSpawnSrc, chipSpawnDest);
|
|
65
|
+
refreshed.push('docs/chip-spawn.md');
|
|
66
|
+
}
|
|
67
|
+
} catch (err) {
|
|
68
|
+
console.error(' greprag postinstall: chip-spawn refresh skipped (' + err.message + ')');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (refreshed.length > 0) {
|
|
72
|
+
console.log('\n greprag installed. Refreshed: ' + refreshed.join(', ') + '\n');
|
|
73
|
+
} else {
|
|
74
|
+
console.log('\n greprag installed. Run `greprag init` to connect Claude Code memory.\n');
|
|
75
|
+
}
|