@pimzino/sgrep 1.3.0
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 +413 -0
- package/build/.claude-plugin/marketplace.json +20 -0
- package/build/commands/ask.d.ts +11 -0
- package/build/commands/ask.d.ts.map +1 -0
- package/build/commands/ask.js +65 -0
- package/build/commands/ask.js.map +1 -0
- package/build/commands/enhance.d.ts +16 -0
- package/build/commands/enhance.d.ts.map +1 -0
- package/build/commands/enhance.js +107 -0
- package/build/commands/enhance.js.map +1 -0
- package/build/commands/search.d.ts +12 -0
- package/build/commands/search.d.ts.map +1 -0
- package/build/commands/search.js +65 -0
- package/build/commands/search.js.map +1 -0
- package/build/commands/watch.d.ts +13 -0
- package/build/commands/watch.d.ts.map +1 -0
- package/build/commands/watch.js +179 -0
- package/build/commands/watch.js.map +1 -0
- package/build/index.d.ts +3 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +124 -0
- package/build/index.js.map +1 -0
- package/build/install/claude-code.d.ts +10 -0
- package/build/install/claude-code.d.ts.map +1 -0
- package/build/install/claude-code.js +255 -0
- package/build/install/claude-code.js.map +1 -0
- package/build/install/codex.d.ts +4 -0
- package/build/install/codex.d.ts.map +1 -0
- package/build/install/codex.js +123 -0
- package/build/install/codex.js.map +1 -0
- package/build/install/cursor.d.ts +4 -0
- package/build/install/cursor.d.ts.map +1 -0
- package/build/install/cursor.js +91 -0
- package/build/install/cursor.js.map +1 -0
- package/build/install/droid.d.ts +4 -0
- package/build/install/droid.d.ts.map +1 -0
- package/build/install/droid.js +226 -0
- package/build/install/droid.js.map +1 -0
- package/build/install/opencode.d.ts +4 -0
- package/build/install/opencode.d.ts.map +1 -0
- package/build/install/opencode.js +276 -0
- package/build/install/opencode.js.map +1 -0
- package/build/plugins/sgrep/.claude-plugin/plugin.json +9 -0
- package/build/plugins/sgrep/hooks/hooks.json +39 -0
- package/build/plugins/sgrep/hooks/sgrep_enhance.js +160 -0
- package/build/plugins/sgrep/hooks/sgrep_watch.js +240 -0
- package/build/plugins/sgrep/hooks/sgrep_watch_kill.js +158 -0
- package/build/plugins/sgrep/skills/sgrep/SKILL.md +97 -0
- package/build/utils/config.d.ts +26 -0
- package/build/utils/config.d.ts.map +1 -0
- package/build/utils/config.js +106 -0
- package/build/utils/config.js.map +1 -0
- package/build/utils/context-manager.d.ts +33 -0
- package/build/utils/context-manager.d.ts.map +1 -0
- package/build/utils/context-manager.js +244 -0
- package/build/utils/context-manager.js.map +1 -0
- package/build/utils/context.d.ts +25 -0
- package/build/utils/context.d.ts.map +1 -0
- package/build/utils/context.js +132 -0
- package/build/utils/context.js.map +1 -0
- package/build/utils/file-walker.d.ts +20 -0
- package/build/utils/file-walker.d.ts.map +1 -0
- package/build/utils/file-walker.js +239 -0
- package/build/utils/file-walker.js.map +1 -0
- package/build/utils/output.d.ts +38 -0
- package/build/utils/output.d.ts.map +1 -0
- package/build/utils/output.js +150 -0
- package/build/utils/output.js.map +1 -0
- package/build/utils/prompt-parser.d.ts +12 -0
- package/build/utils/prompt-parser.d.ts.map +1 -0
- package/build/utils/prompt-parser.js +54 -0
- package/build/utils/prompt-parser.js.map +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import * as fs from "fs";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
// @ts-ignore - ignore package has complex export that TypeScript struggles with
|
|
4
|
+
import ignoreModule from "ignore";
|
|
5
|
+
const ignore = ignoreModule;
|
|
6
|
+
// Maximum file size to index (1MB as per SDK limit)
|
|
7
|
+
const MAX_FILE_SIZE = 1024 * 1024;
|
|
8
|
+
// Binary file extensions to skip
|
|
9
|
+
const BINARY_EXTENSIONS = new Set([
|
|
10
|
+
".png", ".jpg", ".jpeg", ".gif", ".bmp", ".ico", ".webp", ".svg",
|
|
11
|
+
".mp3", ".mp4", ".wav", ".avi", ".mov", ".webm",
|
|
12
|
+
".zip", ".tar", ".gz", ".rar", ".7z",
|
|
13
|
+
".pdf", ".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx",
|
|
14
|
+
".exe", ".dll", ".so", ".dylib", ".bin",
|
|
15
|
+
".woff", ".woff2", ".ttf", ".eot", ".otf",
|
|
16
|
+
".pyc", ".pyo", ".class", ".o", ".obj",
|
|
17
|
+
".lock", ".lockb",
|
|
18
|
+
]);
|
|
19
|
+
// Directories to always ignore
|
|
20
|
+
const ALWAYS_IGNORE_DIRS = new Set([
|
|
21
|
+
"node_modules",
|
|
22
|
+
".git",
|
|
23
|
+
".svn",
|
|
24
|
+
".hg",
|
|
25
|
+
"__pycache__",
|
|
26
|
+
".pytest_cache",
|
|
27
|
+
".mypy_cache",
|
|
28
|
+
".tox",
|
|
29
|
+
".nox",
|
|
30
|
+
".eggs",
|
|
31
|
+
"*.egg-info",
|
|
32
|
+
".venv",
|
|
33
|
+
"venv",
|
|
34
|
+
"env",
|
|
35
|
+
".env",
|
|
36
|
+
"dist",
|
|
37
|
+
"build",
|
|
38
|
+
"target",
|
|
39
|
+
".next",
|
|
40
|
+
".nuxt",
|
|
41
|
+
".output",
|
|
42
|
+
".cache",
|
|
43
|
+
".parcel-cache",
|
|
44
|
+
"coverage",
|
|
45
|
+
".nyc_output",
|
|
46
|
+
]);
|
|
47
|
+
/**
|
|
48
|
+
* Load ignore patterns from .gitignore and .augmentignore files
|
|
49
|
+
*/
|
|
50
|
+
function loadIgnorePatterns(directory) {
|
|
51
|
+
const ig = ignore();
|
|
52
|
+
// Add default patterns for always-ignored directories
|
|
53
|
+
for (const dir of ALWAYS_IGNORE_DIRS) {
|
|
54
|
+
ig.add(dir);
|
|
55
|
+
ig.add(`${dir}/`);
|
|
56
|
+
}
|
|
57
|
+
// Load .gitignore
|
|
58
|
+
const gitignorePath = path.join(directory, ".gitignore");
|
|
59
|
+
if (fs.existsSync(gitignorePath)) {
|
|
60
|
+
try {
|
|
61
|
+
const content = fs.readFileSync(gitignorePath, "utf-8");
|
|
62
|
+
ig.add(content);
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
// Ignore read errors
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
// Load .augmentignore (takes precedence)
|
|
69
|
+
const augmentignorePath = path.join(directory, ".augmentignore");
|
|
70
|
+
if (fs.existsSync(augmentignorePath)) {
|
|
71
|
+
try {
|
|
72
|
+
const content = fs.readFileSync(augmentignorePath, "utf-8");
|
|
73
|
+
ig.add(content);
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
// Ignore read errors
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return ig;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Check if a file should be skipped based on extension
|
|
83
|
+
*/
|
|
84
|
+
function isBinaryFile(filePath) {
|
|
85
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
86
|
+
return BINARY_EXTENSIONS.has(ext);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Check if file content appears to be binary
|
|
90
|
+
*/
|
|
91
|
+
function hasBinaryContent(content) {
|
|
92
|
+
// Check for null bytes which indicate binary content
|
|
93
|
+
return content.includes("\0");
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Recursively walk a directory and collect indexable files
|
|
97
|
+
*/
|
|
98
|
+
export async function walkDirectory(directory, options = {}) {
|
|
99
|
+
const files = [];
|
|
100
|
+
const ig = loadIgnorePatterns(directory);
|
|
101
|
+
const debugLog = options.debug ? (msg) => console.error(`[file-walker] ${msg}`) : () => { };
|
|
102
|
+
async function walk(dir, relativePath = "") {
|
|
103
|
+
let entries;
|
|
104
|
+
try {
|
|
105
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
debugLog(`Cannot read directory: ${dir}`);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
for (const entry of entries) {
|
|
112
|
+
const fullPath = path.join(dir, entry.name);
|
|
113
|
+
const relPath = relativePath ? path.join(relativePath, entry.name) : entry.name;
|
|
114
|
+
// Normalize path separators for ignore matching
|
|
115
|
+
const normalizedRelPath = relPath.replace(/\\/g, "/");
|
|
116
|
+
// Check if path should be ignored
|
|
117
|
+
if (ig.ignores(normalizedRelPath)) {
|
|
118
|
+
debugLog(`Ignoring: ${normalizedRelPath}`);
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
if (entry.isDirectory()) {
|
|
122
|
+
// Skip always-ignored directories by name
|
|
123
|
+
if (ALWAYS_IGNORE_DIRS.has(entry.name)) {
|
|
124
|
+
debugLog(`Skipping directory: ${entry.name}`);
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
await walk(fullPath, relPath);
|
|
128
|
+
}
|
|
129
|
+
else if (entry.isFile()) {
|
|
130
|
+
// Skip binary files
|
|
131
|
+
if (isBinaryFile(fullPath)) {
|
|
132
|
+
debugLog(`Skipping binary file: ${relPath}`);
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
// Check file size
|
|
136
|
+
let stats;
|
|
137
|
+
try {
|
|
138
|
+
stats = fs.statSync(fullPath);
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
debugLog(`Cannot stat file: ${fullPath}`);
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
if (stats.size > MAX_FILE_SIZE) {
|
|
145
|
+
debugLog(`Skipping large file (${stats.size} bytes): ${relPath}`);
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
if (stats.size === 0) {
|
|
149
|
+
debugLog(`Skipping empty file: ${relPath}`);
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
// Read file content
|
|
153
|
+
let content;
|
|
154
|
+
try {
|
|
155
|
+
content = fs.readFileSync(fullPath, "utf-8");
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
debugLog(`Cannot read file: ${fullPath}`);
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
// Skip files with binary content
|
|
162
|
+
if (hasBinaryContent(content)) {
|
|
163
|
+
debugLog(`Skipping file with binary content: ${relPath}`);
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
files.push({
|
|
167
|
+
path: normalizedRelPath,
|
|
168
|
+
contents: content,
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
debugLog(`Walking directory: ${directory}`);
|
|
174
|
+
await walk(directory);
|
|
175
|
+
debugLog(`Found ${files.length} indexable files`);
|
|
176
|
+
return files;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Read a single file for indexing
|
|
180
|
+
*/
|
|
181
|
+
export function readFileForIndex(directory, relativePath, options = {}) {
|
|
182
|
+
const debugLog = options.debug ? (msg) => console.error(`[file-walker] ${msg}`) : () => { };
|
|
183
|
+
const fullPath = path.join(directory, relativePath);
|
|
184
|
+
const normalizedRelPath = relativePath.replace(/\\/g, "/");
|
|
185
|
+
// Check if file exists
|
|
186
|
+
if (!fs.existsSync(fullPath)) {
|
|
187
|
+
debugLog(`File does not exist: ${fullPath}`);
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
// Skip binary files
|
|
191
|
+
if (isBinaryFile(fullPath)) {
|
|
192
|
+
debugLog(`Skipping binary file: ${relativePath}`);
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
// Check file size
|
|
196
|
+
let stats;
|
|
197
|
+
try {
|
|
198
|
+
stats = fs.statSync(fullPath);
|
|
199
|
+
}
|
|
200
|
+
catch {
|
|
201
|
+
debugLog(`Cannot stat file: ${fullPath}`);
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
204
|
+
if (stats.size > MAX_FILE_SIZE) {
|
|
205
|
+
debugLog(`Skipping large file (${stats.size} bytes): ${relativePath}`);
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
if (stats.size === 0) {
|
|
209
|
+
debugLog(`Skipping empty file: ${relativePath}`);
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
// Read file content
|
|
213
|
+
let content;
|
|
214
|
+
try {
|
|
215
|
+
content = fs.readFileSync(fullPath, "utf-8");
|
|
216
|
+
}
|
|
217
|
+
catch {
|
|
218
|
+
debugLog(`Cannot read file: ${fullPath}`);
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
// Skip files with binary content
|
|
222
|
+
if (hasBinaryContent(content)) {
|
|
223
|
+
debugLog(`Skipping file with binary content: ${relativePath}`);
|
|
224
|
+
return null;
|
|
225
|
+
}
|
|
226
|
+
return {
|
|
227
|
+
path: normalizedRelPath,
|
|
228
|
+
contents: content,
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Check if a path should be ignored based on ignore patterns
|
|
233
|
+
*/
|
|
234
|
+
export function shouldIgnorePath(directory, relativePath) {
|
|
235
|
+
const ig = loadIgnorePatterns(directory);
|
|
236
|
+
const normalizedPath = relativePath.replace(/\\/g, "/");
|
|
237
|
+
return ig.ignores(normalizedPath);
|
|
238
|
+
}
|
|
239
|
+
//# sourceMappingURL=file-walker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-walker.js","sourceRoot":"","sources":["../../src/utils/file-walker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,gFAAgF;AAChF,OAAO,YAAY,MAAM,QAAQ,CAAC;AAClC,MAAM,MAAM,GAAG,YAGd,CAAC;AAEF,oDAAoD;AACpD,MAAM,aAAa,GAAG,IAAI,GAAG,IAAI,CAAC;AAElC,iCAAiC;AACjC,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC;IAChC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IAChE,MAAM,EAAE,MAAM,E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AC,wBAAwB,KAAK,CAAC,IAAI,YAAY,YAAY,EAAE,CAAC,CAAC;QACvE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;QACrB,QAAQ,CAAC,wBAAwB,YAAY,EAAE,CAAC,CAAC;QACjD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,oBAAoB;IACpB,IAAI,OAAe,CAAC;IACpB,IAAI,CAAC;QACH,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC;IAAC,MAAM,CAAC;QACP,QAAQ,CAAC,qBAAqB,QAAQ,EAAE,CAAC,CAAC;QAC1C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,iCAAiC;IACjC,IAAI,gBAAgB,CAAC,OAAO,CAAC,EAAE,CAAC;QAC9B,QAAQ,CAAC,sCAAsC,YAAY,EAAE,CAAC,CAAC;QAC/D,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO;QACL,IAAI,EAAE,iBAAiB;QACvB,QAAQ,EAAE,OAAO;KAClB,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,SAAiB,EAAE,YAAoB;IACtE,MAAM,EAAE,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;IACzC,MAAM,cAAc,GAAG,YAAY,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACxD,OAAO,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export interface OutputOptions {
|
|
2
|
+
noColor?: boolean;
|
|
3
|
+
json?: boolean;
|
|
4
|
+
debug?: boolean;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Initialize output options. Should be called once at startup.
|
|
8
|
+
*/
|
|
9
|
+
export declare function initOutput(options: OutputOptions): void;
|
|
10
|
+
/**
|
|
11
|
+
* Print a debug message (only if debug mode is enabled).
|
|
12
|
+
*/
|
|
13
|
+
export declare function debug(message: string): void;
|
|
14
|
+
/**
|
|
15
|
+
* Print an error message to stderr.
|
|
16
|
+
*/
|
|
17
|
+
export declare function printError(message: string): void;
|
|
18
|
+
/**
|
|
19
|
+
* Print a warning message to stderr.
|
|
20
|
+
*/
|
|
21
|
+
export declare function printWarning(message: string): void;
|
|
22
|
+
/**
|
|
23
|
+
* Print an info message to stderr (doesn't pollute stdout for piping).
|
|
24
|
+
*/
|
|
25
|
+
export declare function printInfo(message: string): void;
|
|
26
|
+
/**
|
|
27
|
+
* Print search results in a formatted way.
|
|
28
|
+
*/
|
|
29
|
+
export declare function printSearchResults(results: string, maxResults?: number): void;
|
|
30
|
+
/**
|
|
31
|
+
* Print an answer from ask-codebase in a formatted way.
|
|
32
|
+
*/
|
|
33
|
+
export declare function printAnswer(answer: string): void;
|
|
34
|
+
/**
|
|
35
|
+
* Print setup instructions when authentication fails.
|
|
36
|
+
*/
|
|
37
|
+
export declare function printAuthError(): void;
|
|
38
|
+
//# sourceMappingURL=output.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/utils/output.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAID;;GAEG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAEvD;AAYD;;GAEG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAI3C;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAEhD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAElD;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE/C;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAoC7E;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAgDhD;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,IAAI,CAQrC"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
let outputOptions = {};
|
|
3
|
+
/**
|
|
4
|
+
* Initialize output options. Should be called once at startup.
|
|
5
|
+
*/
|
|
6
|
+
export function initOutput(options) {
|
|
7
|
+
outputOptions = options;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Apply styling if colors are enabled, otherwise return plain text.
|
|
11
|
+
*/
|
|
12
|
+
function colorize(text, colorFn) {
|
|
13
|
+
if (outputOptions.noColor) {
|
|
14
|
+
return text;
|
|
15
|
+
}
|
|
16
|
+
return colorFn(text);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Print a debug message (only if debug mode is enabled).
|
|
20
|
+
*/
|
|
21
|
+
export function debug(message) {
|
|
22
|
+
if (outputOptions.debug) {
|
|
23
|
+
console.error(colorize(`[debug] ${message}`, chalk.gray));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Print an error message to stderr.
|
|
28
|
+
*/
|
|
29
|
+
export function printError(message) {
|
|
30
|
+
console.error(colorize(`Error: ${message}`, chalk.red));
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Print a warning message to stderr.
|
|
34
|
+
*/
|
|
35
|
+
export function printWarning(message) {
|
|
36
|
+
console.error(colorize(`Warning: ${message}`, chalk.yellow));
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Print an info message to stderr (doesn't pollute stdout for piping).
|
|
40
|
+
*/
|
|
41
|
+
export function printInfo(message) {
|
|
42
|
+
console.error(colorize(message, chalk.blue));
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Print search results in a formatted way.
|
|
46
|
+
*/
|
|
47
|
+
export function printSearchResults(results, maxResults) {
|
|
48
|
+
if (outputOptions.json) {
|
|
49
|
+
// Parse the results string and output as JSON
|
|
50
|
+
const jsonOutput = {
|
|
51
|
+
type: "search",
|
|
52
|
+
results: results,
|
|
53
|
+
maxResults: maxResults,
|
|
54
|
+
};
|
|
55
|
+
console.log(JSON.stringify(jsonOutput, null, 2));
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
// The results from Augment SDK are already formatted
|
|
59
|
+
// We just add some coloring for better readability
|
|
60
|
+
const lines = results.split("\n");
|
|
61
|
+
let resultCount = 0;
|
|
62
|
+
for (const line of lines) {
|
|
63
|
+
// Highlight file paths (typically start with path separators or drive letters)
|
|
64
|
+
if (line.match(/^[A-Za-z]:[\\\/]|^[\/~]/)) {
|
|
65
|
+
console.log(colorize(line, chalk.cyan));
|
|
66
|
+
resultCount++;
|
|
67
|
+
if (maxResults && resultCount >= maxResults) {
|
|
68
|
+
console.log(colorize(`\n(Output limited to ${maxResults} results)`, chalk.yellow));
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
else if (line.startsWith("```") || line.endsWith("```")) {
|
|
73
|
+
// Code block markers
|
|
74
|
+
console.log(colorize(line, chalk.gray));
|
|
75
|
+
}
|
|
76
|
+
else if (line.match(/^\d+[:\|]/)) {
|
|
77
|
+
// Line numbers in code
|
|
78
|
+
console.log(colorize(line, chalk.gray));
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
console.log(line);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Print an answer from ask-codebase in a formatted way.
|
|
87
|
+
*/
|
|
88
|
+
export function printAnswer(answer) {
|
|
89
|
+
if (outputOptions.json) {
|
|
90
|
+
const jsonOutput = {
|
|
91
|
+
type: "answer",
|
|
92
|
+
answer: answer,
|
|
93
|
+
};
|
|
94
|
+
console.log(JSON.stringify(jsonOutput, null, 2));
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
// Format markdown-like output for terminal
|
|
98
|
+
const lines = answer.split("\n");
|
|
99
|
+
for (const line of lines) {
|
|
100
|
+
// Headers
|
|
101
|
+
if (line.startsWith("# ")) {
|
|
102
|
+
console.log(colorize(line, (s) => chalk.bold.blue(s)));
|
|
103
|
+
}
|
|
104
|
+
else if (line.startsWith("## ")) {
|
|
105
|
+
console.log(colorize(line, (s) => chalk.bold.cyan(s)));
|
|
106
|
+
}
|
|
107
|
+
else if (line.startsWith("### ")) {
|
|
108
|
+
console.log(colorize(line, chalk.bold));
|
|
109
|
+
}
|
|
110
|
+
// Code blocks
|
|
111
|
+
else if (line.startsWith("```")) {
|
|
112
|
+
console.log(colorize(line, chalk.gray));
|
|
113
|
+
}
|
|
114
|
+
// File paths / references
|
|
115
|
+
else if (line.match(/^[A-Za-z]:[\\\/]|^[\/~]/) || line.match(/`[^`]+\.(ts|js|py|go|rs|java|cpp|c|h)`/)) {
|
|
116
|
+
console.log(colorize(line, chalk.cyan));
|
|
117
|
+
}
|
|
118
|
+
// Bullet points
|
|
119
|
+
else if (line.match(/^\s*[-*]\s/)) {
|
|
120
|
+
console.log(colorize(line, chalk.white));
|
|
121
|
+
}
|
|
122
|
+
// Code/identifiers in backticks
|
|
123
|
+
else if (line.includes("`")) {
|
|
124
|
+
// Highlight backticked content
|
|
125
|
+
if (outputOptions.noColor) {
|
|
126
|
+
console.log(line);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
const highlighted = line.replace(/`([^`]+)`/g, (_, code) => chalk.yellow(code));
|
|
130
|
+
console.log(highlighted);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
console.log(line);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Print setup instructions when authentication fails.
|
|
140
|
+
*/
|
|
141
|
+
export function printAuthError() {
|
|
142
|
+
console.error("");
|
|
143
|
+
console.error(colorize("Authentication Error", chalk.red));
|
|
144
|
+
console.error("");
|
|
145
|
+
console.error("Make sure you have:");
|
|
146
|
+
console.error(colorize(" 1.", chalk.cyan) + " Installed auggie CLI: " + colorize("npm install -g @augmentcode/auggie@latest", chalk.yellow));
|
|
147
|
+
console.error(colorize(" 2.", chalk.cyan) + " Logged in to Augment: " + colorize("auggie login", chalk.yellow));
|
|
148
|
+
console.error("");
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/utils/output.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAQ1B,IAAI,aAAa,GAAkB,EAAE,CAAC;AAEtC;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,OAAsB;IAC/C,aAAa,GAAG,OAAO,CAAC;AAC1B,CAAC;AAED;;GAEG;AACH,SAAS,QAAQ,CAAC,IAAY,EAAE,OAA8B;IAC5D,IAAI,aAAa,CAAC,OAAO,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;AACvB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,KAAK,CAAC,OAAe;IACnC,IAAI,aAAa,CAAC,KAAK,EAAE,CAAC;QACxB,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,OAAO,EAAE,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IAC5D,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,OAAe;IACxC,OAAO,CAAC,KAAK,CAAC,QAAQ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CAAC,YAAY,EAAE,CAAC,CAAC,EAAE,IAAY,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;gBACxF,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC;aACI,CAAC;YACJ,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACpB,CAAC;IACH,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc;IAC5B,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAClB,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,sBAAsB,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3D,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAClB,OAAO,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACrC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,yBAAyB,GAAG,QAAQ,CAAC,2CAA2C,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IAC9I,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,yBAAyB,GAAG,QAAQ,CAAC,cAAc,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IACjH,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse the enhanced prompt from the AI response.
|
|
3
|
+
* Expects the response to contain content within <enhanced-prompt> tags.
|
|
4
|
+
*/
|
|
5
|
+
export declare function parseEnhancedPrompt(response: string): string | null;
|
|
6
|
+
/**
|
|
7
|
+
* Build the enhancement instruction prompt.
|
|
8
|
+
* This instructs the AI to enhance the user's prompt with codebase context
|
|
9
|
+
* while strictly preserving all user instructions, examples, and preferences.
|
|
10
|
+
*/
|
|
11
|
+
export declare function buildEnhancementInstruction(originalPrompt: string): string;
|
|
12
|
+
//# sourceMappingURL=prompt-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-parser.d.ts","sourceRoot":"","sources":["../../src/utils/prompt-parser.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAQnE;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAgC1E"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Regex for extracting enhanced prompt from AI response
|
|
3
|
+
*/
|
|
4
|
+
const ENHANCED_PROMPT_REGEX = /<enhanced-prompt>([\s\S]*?)<\/enhanced-prompt>/;
|
|
5
|
+
/**
|
|
6
|
+
* Parse the enhanced prompt from the AI response.
|
|
7
|
+
* Expects the response to contain content within <enhanced-prompt> tags.
|
|
8
|
+
*/
|
|
9
|
+
export function parseEnhancedPrompt(response) {
|
|
10
|
+
const match = response.match(ENHANCED_PROMPT_REGEX);
|
|
11
|
+
if (match?.[1]) {
|
|
12
|
+
return match[1].trim();
|
|
13
|
+
}
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Build the enhancement instruction prompt.
|
|
18
|
+
* This instructs the AI to enhance the user's prompt with codebase context
|
|
19
|
+
* while strictly preserving all user instructions, examples, and preferences.
|
|
20
|
+
*/
|
|
21
|
+
export function buildEnhancementInstruction(originalPrompt) {
|
|
22
|
+
return `You are enhancing a user's prompt with relevant codebase context.
|
|
23
|
+
|
|
24
|
+
## CRITICAL RULES (MUST FOLLOW):
|
|
25
|
+
1. PRESERVE the user's original intent, instructions, and examples COMPLETELY
|
|
26
|
+
2. NEVER remove, ignore, discard, or override ANYTHING the user specified
|
|
27
|
+
3. If the user mentions specific tools, libraries, projects, or approaches - KEEP THEM exactly as stated
|
|
28
|
+
4. ADD context from the codebase to supplement the prompt, don't replace the user's words
|
|
29
|
+
5. If the user says "use X as an example" or similar - that instruction MUST remain in the enhanced prompt
|
|
30
|
+
|
|
31
|
+
## Enhancement Guidelines:
|
|
32
|
+
1. Identify the prompt type (question, feature request, bug fix, refactor, code review, explanation, etc.)
|
|
33
|
+
2. Add relevant file paths, function names, class names, and code patterns from the codebase that relate to the prompt
|
|
34
|
+
3. Make implicit requirements explicit based on codebase conventions and patterns
|
|
35
|
+
4. Correct obvious typos or clarify ambiguous technical terms using terminology from the codebase
|
|
36
|
+
5. If the user provided code samples in backticks (\`\`\`), preserve them EXACTLY as written
|
|
37
|
+
6. Reference specific locations in the codebase (e.g., "see src/utils/config.ts for the existing pattern")
|
|
38
|
+
|
|
39
|
+
## What NOT to do:
|
|
40
|
+
- Do NOT remove user-specified constraints or preferences
|
|
41
|
+
- Do NOT change the fundamental request or goal
|
|
42
|
+
- Do NOT add unnecessary complexity or scope
|
|
43
|
+
- Do NOT contradict what the user explicitly stated
|
|
44
|
+
|
|
45
|
+
## Output Format:
|
|
46
|
+
Respond with ONLY the enhanced prompt wrapped in tags:
|
|
47
|
+
<enhanced-prompt>
|
|
48
|
+
[Enhanced version that INCLUDES all original user instructions plus added codebase context]
|
|
49
|
+
</enhanced-prompt>
|
|
50
|
+
|
|
51
|
+
## Original Prompt to Enhance:
|
|
52
|
+
${originalPrompt}`;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=prompt-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-parser.js","sourceRoot":"","sources":["../../src/utils/prompt-parser.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,qBAAqB,GAAG,gDAAgD,CAAC;AAE/E;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,QAAgB;IAClD,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;IAEpD,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACf,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACzB,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,2BAA2B,CAAC,cAAsB;IAChE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8BP,cAAc,EAAE,CAAC;AACnB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pimzino/sgrep",
|
|
3
|
+
"version": "1.3.0",
|
|
4
|
+
"description": "Semantic grep - search codebases by meaning using the Augment SDK",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "build/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"sgrep": "build/index.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"postbuild": "node scripts/postbuild.js",
|
|
13
|
+
"start": "node build/index.js",
|
|
14
|
+
"dev": "tsc --watch",
|
|
15
|
+
"prepublishOnly": "npm run build"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"build",
|
|
19
|
+
"README.md"
|
|
20
|
+
],
|
|
21
|
+
"keywords": [
|
|
22
|
+
"grep",
|
|
23
|
+
"semantic",
|
|
24
|
+
"search",
|
|
25
|
+
"codebase",
|
|
26
|
+
"augment",
|
|
27
|
+
"cli",
|
|
28
|
+
"ai",
|
|
29
|
+
"claude",
|
|
30
|
+
"claude-code",
|
|
31
|
+
"semantic-search",
|
|
32
|
+
"code-search"
|
|
33
|
+
],
|
|
34
|
+
"author": "pimzino",
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "git+https://github.com/pimzino/sgrep.git"
|
|
39
|
+
},
|
|
40
|
+
"bugs": {
|
|
41
|
+
"url": "https://github.com/pimzino/sgrep/issues"
|
|
42
|
+
},
|
|
43
|
+
"homepage": "https://github.com/pimzino/sgrep#readme",
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@augmentcode/auggie-sdk": "^0.1.13",
|
|
46
|
+
"chalk": "^5.3.0",
|
|
47
|
+
"chokidar": "^3.6.0",
|
|
48
|
+
"commander": "^12.0.0",
|
|
49
|
+
"ignore": "^5.3.0",
|
|
50
|
+
"ora": "^8.0.0"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@types/node": "^20.0.0",
|
|
54
|
+
"typescript": "^5.0.0"
|
|
55
|
+
},
|
|
56
|
+
"engines": {
|
|
57
|
+
"node": ">=18.0.0"
|
|
58
|
+
}
|
|
59
|
+
}
|