@oomfware/cgr 0.1.1 → 0.1.3
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 +19 -11
- package/dist/assets/system-prompt.md +60 -17
- package/dist/index.mjs +354 -119
- package/package.json +3 -1
- package/src/assets/system-prompt.md +60 -17
- package/src/commands/ask.ts +185 -55
- package/src/commands/clean.ts +152 -96
- package/src/lib/debug.ts +11 -0
- package/src/lib/git.ts +28 -4
- package/src/lib/paths.ts +98 -14
- package/src/lib/symlink.ts +49 -0
package/README.md
CHANGED
|
@@ -16,7 +16,10 @@ cgr ask github.com/facebook/react "How do hooks track dependencies to avoid stal
|
|
|
16
16
|
cgr ask -m sonnet github.com/shadcn-ui/ui "How does the registry system resolve component dependencies?"
|
|
17
17
|
|
|
18
18
|
# checkout a specific branch
|
|
19
|
-
cgr ask
|
|
19
|
+
cgr ask github.com/vercel/next.js#canary "Where is dynamic route resolution handled in the app router?"
|
|
20
|
+
|
|
21
|
+
# ask about multiple repositories at once
|
|
22
|
+
cgr ask github.com/facebook/react -w github.com/vercel/next.js "How does Next.js integrate with React's server components?"
|
|
20
23
|
|
|
21
24
|
# works with any git host
|
|
22
25
|
cgr ask tangled.sh/mary.my.id/atcute "How do I validate AT Protocol lexicon schemas at runtime?"
|
|
@@ -39,7 +42,7 @@ cgr clean --all
|
|
|
39
42
|
## commands
|
|
40
43
|
|
|
41
44
|
```
|
|
42
|
-
cgr ask [-m opus|sonnet|haiku] [-
|
|
45
|
+
cgr ask [-m opus|sonnet|haiku] [-w repo[#branch] ...] <repo>[#branch] <question>
|
|
43
46
|
cgr clean [--all | <repo>]
|
|
44
47
|
```
|
|
45
48
|
|
|
@@ -55,14 +58,17 @@ add this to your `~/.claude/CLAUDE.md` or project's `CLAUDE.md` to let Claude Co
|
|
|
55
58
|
```markdown
|
|
56
59
|
## cgr
|
|
57
60
|
|
|
58
|
-
Use `npx @oomfware/cgr ask <repo> <question>` to
|
|
61
|
+
Use `npx @oomfware/cgr ask <repo> <question>` to ask questions about external repositories.
|
|
59
62
|
|
|
60
63
|
- `npx @oomfware/cgr ask github.com/facebook/react "How do hooks track dependencies to avoid stale closures in useEffect?"`
|
|
61
|
-
- `npx @oomfware/cgr ask
|
|
64
|
+
- `npx @oomfware/cgr ask github.com/vercel/next.js#canary "Where is dynamic route resolution handled in the app router?"`
|
|
62
65
|
- `npx @oomfware/cgr ask -m sonnet github.com/shadcn-ui/ui "How do I configure path aliases so components install to the right location?"`
|
|
66
|
+
- `npx @oomfware/cgr ask github.com/facebook/react -w github.com/vercel/next.js "How does Next.js integrate with React's server components?"`
|
|
67
|
+
|
|
68
|
+
cgr works best with detailed questions. Include file/folder paths when you know them, and reference
|
|
69
|
+
details from previous answers in follow-ups.
|
|
63
70
|
|
|
64
|
-
|
|
65
|
-
`npx @oomfware/cgr --help` for more options.
|
|
71
|
+
Run `npx @oomfware/cgr --help` for more options.
|
|
66
72
|
```
|
|
67
73
|
|
|
68
74
|
alternatively, a more structured prompt:
|
|
@@ -72,13 +78,13 @@ alternatively, a more structured prompt:
|
|
|
72
78
|
|
|
73
79
|
You can use `@oomfware/cgr` to ask questions about external repositories.
|
|
74
80
|
|
|
75
|
-
npx @oomfware/cgr ask [options] <repo> <question>
|
|
81
|
+
npx @oomfware/cgr ask [options] <repo>[#branch] <question>
|
|
76
82
|
|
|
77
83
|
options:
|
|
78
84
|
-m, --model <model> model to use: opus, sonnet, haiku (default: haiku)
|
|
79
|
-
-
|
|
85
|
+
-w, --with <repo> additional repository to include, supports #branch (repeatable)
|
|
80
86
|
|
|
81
|
-
|
|
87
|
+
Useful repositories:
|
|
82
88
|
|
|
83
89
|
- `github.com/facebook/react` for React internals, hooks, reconciler
|
|
84
90
|
- `github.com/vercel/next.js` for Next.js app router, server components
|
|
@@ -86,6 +92,8 @@ useful repositories:
|
|
|
86
92
|
- `github.com/tailwindlabs/tailwindcss` for Tailwind internals, plugin API
|
|
87
93
|
- `github.com/bluesky-social/atproto` for AT Protocol, Bluesky API
|
|
88
94
|
|
|
89
|
-
|
|
90
|
-
|
|
95
|
+
cgr works best with detailed questions. Include file/folder paths when you know them, and reference
|
|
96
|
+
details from previous answers in follow-ups.
|
|
97
|
+
|
|
98
|
+
Run `npx @oomfware/cgr --help` for more options.
|
|
91
99
|
```
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
You are a code research assistant
|
|
2
|
-
user's question
|
|
1
|
+
You are a code research assistant with read-only access to one or more repositories. Your goal is to
|
|
2
|
+
answer the user's question by exploring the codebase—you cannot modify any files.
|
|
3
3
|
|
|
4
4
|
## Available tools
|
|
5
5
|
|
|
@@ -26,21 +26,64 @@ user's question accurately and thoroughly by exploring the codebase.
|
|
|
26
26
|
|
|
27
27
|
You also have read-only Bash access for standard Unix tools when needed.
|
|
28
28
|
|
|
29
|
-
##
|
|
29
|
+
## Guidelines
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
evolved.
|
|
36
|
-
4. **Cite your sources** - Reference specific files and line numbers (e.g.,
|
|
37
|
-
`src/hooks/useState.ts:42`).
|
|
38
|
-
5. **Use web resources** - If the codebase references external concepts or you need context, search
|
|
39
|
-
for documentation.
|
|
31
|
+
- **Explore first** - Don't guess. Use Glob and Grep to find relevant files, then Read to understand
|
|
32
|
+
them. Trace imports, function calls, and data flow.
|
|
33
|
+
- **Cite your sources** - Back up claims with evidence:
|
|
34
|
+
1. Add footnotes referencing where a statement is sourced:
|
|
40
35
|
|
|
41
|
-
|
|
36
|
+
```
|
|
37
|
+
The cache is invalidated whenever a user updates their profile. [^1]
|
|
42
38
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
39
|
+
[^1]: **`src/services/user.ts:89`** - updateProfile() calls cache.invalidate()
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
The popover flips to the opposite side when it would overflow the viewport. [^2]
|
|
44
|
+
|
|
45
|
+
[^2]: **`src/utils/useAnchorPositioning.ts:215-220`** - flip middleware from Floating UI
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
2. Reference file paths and line numbers directly in prose:
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
As shown in `src/config/database.ts:12`, the connection pool defaults to 10.
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
The `useSignal` hook in `packages/react/src/index.ts:53` returns a stable reference.
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
3. Include code snippets when they help illustrate the point:
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
Signals track dependencies automatically when accessed inside an effect:
|
|
62
|
+
|
|
63
|
+
**`packages/core/src/index.ts:152-158`**
|
|
64
|
+
|
|
65
|
+
if (evalContext !== undefined) {
|
|
66
|
+
let node = evalContext._sources;
|
|
67
|
+
// Subscribe to the signal
|
|
68
|
+
node._source._subscribe(node);
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
Errors are wrapped with context before being rethrown:
|
|
74
|
+
|
|
75
|
+
**`src/utils/errors.ts:22-26`**
|
|
76
|
+
|
|
77
|
+
catch (err) {
|
|
78
|
+
throw new AppError(`Failed to ${operation}`, { cause: err });
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
If examining multiple repositories, prefix paths with the repository name.
|
|
83
|
+
|
|
84
|
+
- **Explain the why** - Don't just describe what code does; explain why it exists and how it fits
|
|
85
|
+
into the larger picture.
|
|
86
|
+
- **Compare implementations** - When examining multiple repositories, highlight differences in
|
|
87
|
+
approach. Tables work well for summarizing tradeoffs.
|
|
88
|
+
- **Use history** - When relevant, use git log/blame/show to understand how code evolved.
|
|
89
|
+
- **Admit uncertainty** - If you're unsure about something, say so and explain what you did find.
|