@pimzino/sgrep 1.3.21 → 1.3.26
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/build/index.js +0 -0
- package/build/install/claude-code.js +4 -4
- package/build/install/claude-code.js.map +1 -1
- package/build/install/droid.d.ts.map +1 -1
- package/build/install/droid.js +13 -58
- package/build/install/droid.js.map +1 -1
- package/build/install/opencode.js +178 -178
- package/build/plugins/sgrep/.claude-plugin/plugin.json +1 -1
- package/build/plugins/sgrep/hooks/hooks.json +70 -70
- package/build/plugins/sgrep/hooks/sgrep_context.js +107 -91
- package/build/plugins/sgrep/hooks/sgrep_enhance.js +183 -183
- package/build/plugins/sgrep/hooks/sgrep_watch.js +227 -227
- package/build/utils/prompt-parser.d.ts.map +1 -1
- package/build/utils/prompt-parser.js +69 -45
- package/build/utils/prompt-parser.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
{
|
|
2
|
-
"description": "sgrep semantic search hooks - enhances prompts and manages index",
|
|
3
|
-
"hooks": {
|
|
4
|
-
"UserPromptSubmit": [
|
|
5
|
-
{
|
|
6
|
-
"hooks": [
|
|
7
|
-
{
|
|
8
|
-
"type": "command",
|
|
9
|
-
"command": "node ${CLAUDE_PLUGIN_ROOT}/hooks/sgrep_enhance.js",
|
|
10
|
-
"timeout": 60
|
|
11
|
-
}
|
|
12
|
-
]
|
|
13
|
-
}
|
|
14
|
-
],
|
|
15
|
-
"SessionStart": [
|
|
16
|
-
{
|
|
17
|
-
"matcher": "startup|resume",
|
|
18
|
-
"hooks": [
|
|
19
|
-
{
|
|
20
|
-
"type": "command",
|
|
21
|
-
"command": "node ${CLAUDE_PLUGIN_ROOT}/hooks/sgrep_watch.js",
|
|
22
|
-
"timeout": 15
|
|
23
|
-
}
|
|
24
|
-
]
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
"matcher": "startup|compact",
|
|
28
|
-
"hooks": [
|
|
29
|
-
{
|
|
30
|
-
"type": "command",
|
|
31
|
-
"command": "node ${CLAUDE_PLUGIN_ROOT}/hooks/sgrep_project_summary.js",
|
|
32
|
-
"timeout": 90
|
|
33
|
-
}
|
|
34
|
-
]
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
"matcher": "resume|clear",
|
|
38
|
-
"hooks": [
|
|
39
|
-
{
|
|
40
|
-
"type": "command",
|
|
41
|
-
"command": "node ${CLAUDE_PLUGIN_ROOT}/hooks/sgrep_context.js",
|
|
42
|
-
"timeout": 5
|
|
43
|
-
}
|
|
44
|
-
]
|
|
45
|
-
}
|
|
46
|
-
],
|
|
47
|
-
"SubagentStart": [
|
|
48
|
-
{
|
|
49
|
-
"hooks": [
|
|
50
|
-
{
|
|
51
|
-
"type": "command",
|
|
52
|
-
"command": "node ${CLAUDE_PLUGIN_ROOT}/hooks/sgrep_context.js",
|
|
53
|
-
"timeout": 5
|
|
54
|
-
}
|
|
55
|
-
]
|
|
56
|
-
}
|
|
57
|
-
],
|
|
58
|
-
"SessionEnd": [
|
|
59
|
-
{
|
|
60
|
-
"hooks": [
|
|
61
|
-
{
|
|
62
|
-
"type": "command",
|
|
63
|
-
"command": "node ${CLAUDE_PLUGIN_ROOT}/hooks/sgrep_watch_kill.js",
|
|
64
|
-
"timeout": 10
|
|
65
|
-
}
|
|
66
|
-
]
|
|
67
|
-
}
|
|
68
|
-
]
|
|
69
|
-
}
|
|
70
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"description": "sgrep semantic search hooks - enhances prompts and manages index",
|
|
3
|
+
"hooks": {
|
|
4
|
+
"UserPromptSubmit": [
|
|
5
|
+
{
|
|
6
|
+
"hooks": [
|
|
7
|
+
{
|
|
8
|
+
"type": "command",
|
|
9
|
+
"command": "node ${CLAUDE_PLUGIN_ROOT}/hooks/sgrep_enhance.js",
|
|
10
|
+
"timeout": 60
|
|
11
|
+
}
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"SessionStart": [
|
|
16
|
+
{
|
|
17
|
+
"matcher": "startup|resume",
|
|
18
|
+
"hooks": [
|
|
19
|
+
{
|
|
20
|
+
"type": "command",
|
|
21
|
+
"command": "node ${CLAUDE_PLUGIN_ROOT}/hooks/sgrep_watch.js",
|
|
22
|
+
"timeout": 15
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"matcher": "startup|compact",
|
|
28
|
+
"hooks": [
|
|
29
|
+
{
|
|
30
|
+
"type": "command",
|
|
31
|
+
"command": "node ${CLAUDE_PLUGIN_ROOT}/hooks/sgrep_project_summary.js",
|
|
32
|
+
"timeout": 90
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"matcher": "resume|clear",
|
|
38
|
+
"hooks": [
|
|
39
|
+
{
|
|
40
|
+
"type": "command",
|
|
41
|
+
"command": "node ${CLAUDE_PLUGIN_ROOT}/hooks/sgrep_context.js",
|
|
42
|
+
"timeout": 5
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
"SubagentStart": [
|
|
48
|
+
{
|
|
49
|
+
"hooks": [
|
|
50
|
+
{
|
|
51
|
+
"type": "command",
|
|
52
|
+
"command": "node ${CLAUDE_PLUGIN_ROOT}/hooks/sgrep_context.js",
|
|
53
|
+
"timeout": 5
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
],
|
|
58
|
+
"SessionEnd": [
|
|
59
|
+
{
|
|
60
|
+
"hooks": [
|
|
61
|
+
{
|
|
62
|
+
"type": "command",
|
|
63
|
+
"command": "node ${CLAUDE_PLUGIN_ROOT}/hooks/sgrep_watch_kill.js",
|
|
64
|
+
"timeout": 10
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -1,91 +1,107 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* sgrep_context.js - Injects sgrep awareness into Claude Code sessions
|
|
5
|
-
*
|
|
6
|
-
* This hook runs on
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
process.stdin.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
debugLog("
|
|
61
|
-
debugLog("
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* sgrep_context.js - Injects sgrep awareness into Claude Code sessions
|
|
5
|
+
*
|
|
6
|
+
* This hook runs on SessionStart (startup, resume, clear, compact) to ensure
|
|
7
|
+
* Claude is always aware of the sgrep semantic search tool after any context reset.
|
|
8
|
+
*
|
|
9
|
+
* Separated from sgrep_watch.js which handles the background watch process.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const fs = require("fs");
|
|
13
|
+
const path = require("path");
|
|
14
|
+
const os = require("os");
|
|
15
|
+
|
|
16
|
+
const DEBUG_ENABLED = process.env.SGREP_DEBUG === "1" || process.env.SGREP_DEBUG === "true";
|
|
17
|
+
const DEBUG_LOG_FILE = process.env.SGREP_CONTEXT_LOG || path.join(os.tmpdir(), "sgrep-context.log");
|
|
18
|
+
|
|
19
|
+
function debugLog(message) {
|
|
20
|
+
if (!DEBUG_ENABLED) return;
|
|
21
|
+
try {
|
|
22
|
+
const dir = path.dirname(DEBUG_LOG_FILE);
|
|
23
|
+
if (!fs.existsSync(dir)) {
|
|
24
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
25
|
+
}
|
|
26
|
+
const stamp = new Date().toISOString();
|
|
27
|
+
fs.appendFileSync(DEBUG_LOG_FILE, `[${stamp}] ${message}\n`);
|
|
28
|
+
} catch (e) {
|
|
29
|
+
// Ignore errors
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function readHookInput() {
|
|
34
|
+
return new Promise((resolve) => {
|
|
35
|
+
let data = "";
|
|
36
|
+
process.stdin.setEncoding("utf8");
|
|
37
|
+
process.stdin.on("data", (chunk) => {
|
|
38
|
+
data += chunk;
|
|
39
|
+
});
|
|
40
|
+
process.stdin.on("end", () => {
|
|
41
|
+
if (!data.trim()) {
|
|
42
|
+
debugLog("No input data received from stdin");
|
|
43
|
+
resolve(null);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
const parsed = JSON.parse(data);
|
|
48
|
+
debugLog(`Received hook input: ${JSON.stringify(parsed, null, 2)}`);
|
|
49
|
+
resolve(parsed);
|
|
50
|
+
} catch (e) {
|
|
51
|
+
debugLog(`Failed to decode JSON: ${e.message}`);
|
|
52
|
+
resolve(null);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async function main() {
|
|
59
|
+
debugLog("\n====================================================");
|
|
60
|
+
debugLog("SGREP CONTEXT HOOK TRIGGERED");
|
|
61
|
+
debugLog("====================================================");
|
|
62
|
+
|
|
63
|
+
const payload = await readHookInput();
|
|
64
|
+
if (!payload) {
|
|
65
|
+
debugLog("ERROR: No payload received - exiting with error");
|
|
66
|
+
process.exit(1);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const source = payload.source || "unknown";
|
|
70
|
+
debugLog(`Session source: ${source}`);
|
|
71
|
+
|
|
72
|
+
// Output the sgrep awareness context with XML structure for better model compliance
|
|
73
|
+
const sgrepInstruction = `
|
|
74
|
+
<sgrep-skill-instruction>
|
|
75
|
+
<priority>CRITICAL - Execute before other codebase exploration tools</priority>
|
|
76
|
+
<action>INVOKE the /sgrep skill using the Skill tool at the START of every session</action>
|
|
77
|
+
<requirement>
|
|
78
|
+
You MUST use sgrep as your PRIMARY tool for codebase exploration and understanding.
|
|
79
|
+
Before using Grep, Glob, Read, or Task(Explore), you MUST first try sgrep.
|
|
80
|
+
</requirement>
|
|
81
|
+
<commands>
|
|
82
|
+
<command name="search">sgrep "natural language query" - Find code by meaning/functionality</command>
|
|
83
|
+
<command name="ask">sgrep ask "question" - Get explanations about the codebase</command>
|
|
84
|
+
</commands>
|
|
85
|
+
<use-cases>
|
|
86
|
+
- Finding code by functionality (e.g., "authentication handling", "database queries")
|
|
87
|
+
- Understanding how features work
|
|
88
|
+
- Locating related files across the codebase
|
|
89
|
+
- Exploring unfamiliar architecture
|
|
90
|
+
</use-cases>
|
|
91
|
+
<advantage>sgrep searches by MEANING, not text patterns - far more effective than grep/glob for understanding code</advantage>
|
|
92
|
+
</sgrep-skill-instruction>`.trim();
|
|
93
|
+
|
|
94
|
+
const response = {
|
|
95
|
+
hookSpecificOutput: {
|
|
96
|
+
hookEventName: "SessionStart",
|
|
97
|
+
additionalContext: sgrepInstruction,
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
debugLog(`Outputting context: ${JSON.stringify(response, null, 2)}`);
|
|
102
|
+
console.log(JSON.stringify(response));
|
|
103
|
+
debugLog("====================================================\n");
|
|
104
|
+
process.exit(0);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
main();
|