cxgrd 0.1.12 → 0.1.13
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/LICENSE +21 -0
- package/README.md +112 -153
- package/package.json +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ContextGuard
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,221 +1,180 @@
|
|
|
1
|
-
# CXGRD CLI
|
|
1
|
+
# CXGRD CLI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> Make AI-assisted code changes without breaking your codebase.
|
|
4
|
+
> **[cxgrd.com](https://cxgrd.com)**
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## What is CXGRD?
|
|
9
|
+
|
|
10
|
+
Modern codebases are deeply interconnected — changing one file can silently break a dozen others. When you ask an AI assistant to refactor a service or add a feature, it typically has no awareness of your project's dependency graph, architectural layers, or downstream impact.
|
|
11
|
+
|
|
12
|
+
**CXGRD** solves this. It scans your project and builds a complete dependency graph, then uses that graph to:
|
|
6
13
|
|
|
7
|
-
|
|
8
|
-
**
|
|
14
|
+
- **Tell you exactly what will break** before you make a change
|
|
15
|
+
- **Enrich your AI prompts** with architectural context so the AI makes safer, smarter suggestions
|
|
16
|
+
- **Validate your code** for circular dependencies, orphaned files, and layer violations — both structurally and with compiler-backed checks
|
|
17
|
+
|
|
18
|
+
Think of it as giving your AI assistant a map of your codebase before it starts digging.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
9
23
|
|
|
10
|
-
**Syntax:**
|
|
11
24
|
```bash
|
|
12
|
-
|
|
25
|
+
npm install -g cxgrd
|
|
13
26
|
```
|
|
14
27
|
|
|
15
|
-
|
|
16
|
-
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Core Commands
|
|
17
31
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
- `graph.json` - Full dependency graph
|
|
21
|
-
- `symbols.json` - Exported symbols per file
|
|
22
|
-
- `arch.json` - Inferred architectural layers
|
|
23
|
-
- `meta.json` - Scan metadata
|
|
24
|
-
- `history.json` - Operation history
|
|
25
|
-
- `patterns.json` - Pattern analysis
|
|
32
|
+
### `cxgrd auth login`
|
|
33
|
+
**Authenticate with CXGRD before first use.**
|
|
26
34
|
|
|
27
|
-
**Example:**
|
|
28
35
|
```bash
|
|
29
|
-
cxgrd
|
|
36
|
+
cxgrd auth login
|
|
30
37
|
```
|
|
31
38
|
|
|
32
39
|
---
|
|
33
40
|
|
|
34
|
-
### cxgrd
|
|
35
|
-
**
|
|
41
|
+
### `cxgrd scan [path]`
|
|
42
|
+
**Build a complete dependency graph of your project.**
|
|
43
|
+
|
|
44
|
+
This is the first command to run. It recursively analyzes your source files and produces a `.cg/` directory containing the full dependency graph, exported symbols, architectural layers, and metadata.
|
|
36
45
|
|
|
37
|
-
**Syntax:**
|
|
38
46
|
```bash
|
|
39
|
-
cxgrd
|
|
47
|
+
cxgrd scan # scan current directory
|
|
48
|
+
cxgrd scan /path/to/myapp # scan a specific project
|
|
40
49
|
```
|
|
41
50
|
|
|
42
|
-
**
|
|
43
|
-
- `description` (required): What you're planning to change
|
|
44
|
-
- `--path` or `-p` (optional): Project path
|
|
51
|
+
**What gets created in `.cg/`:**
|
|
45
52
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
53
|
+
| File | Description |
|
|
54
|
+
|---|---|
|
|
55
|
+
| `graph.json` | Full dependency graph |
|
|
56
|
+
| `symbols.json` | Exported symbols per file |
|
|
57
|
+
| `arch.json` | Inferred architectural layers |
|
|
58
|
+
| `meta.json` | Scan metadata |
|
|
59
|
+
| `history.json` | Operation history |
|
|
60
|
+
| `patterns.json` | Pattern analysis |
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
### `cxgrd input "<description>"`
|
|
65
|
+
**Analyze the blast radius of a planned change.**
|
|
66
|
+
|
|
67
|
+
Before touching any code, describe what you're planning to change. CXGRD will tell you every file that will be affected, why it's affected, and how severe the impact is.
|
|
51
68
|
|
|
52
|
-
**Example:**
|
|
53
69
|
```bash
|
|
54
70
|
cxgrd input "rename AuthService to AuthController" --path /myapp
|
|
55
71
|
```
|
|
56
72
|
|
|
73
|
+
**Output includes:**
|
|
74
|
+
- List of affected files
|
|
75
|
+
- Severity levels (high / medium / low)
|
|
76
|
+
- Reason each file is impacted
|
|
77
|
+
- Total downstream impact count
|
|
78
|
+
|
|
79
|
+
Use this before making any significant refactor or before handing a task off to an AI assistant.
|
|
80
|
+
|
|
57
81
|
---
|
|
58
82
|
|
|
59
|
-
### cxgrd prompt <description>
|
|
60
|
-
**
|
|
83
|
+
### `cxgrd prompt "<description>"`
|
|
84
|
+
**Generate an architecturally-aware prompt for your AI assistant.**
|
|
85
|
+
|
|
86
|
+
Instead of giving your AI a vague instruction, CXGRD generates an enriched prompt that includes the relevant modules, symbols, dependencies, and architectural constraints. Your AI gets the full picture — not just your words.
|
|
61
87
|
|
|
62
|
-
**Syntax:**
|
|
63
88
|
```bash
|
|
64
|
-
cxgrd prompt "
|
|
89
|
+
cxgrd prompt "add OAuth2 authentication" --path /myapp
|
|
65
90
|
```
|
|
66
91
|
|
|
67
|
-
**
|
|
68
|
-
-
|
|
69
|
-
-
|
|
70
|
-
|
|
71
|
-
**Output:**
|
|
72
|
-
- Original request
|
|
73
|
-
- Affected modules
|
|
92
|
+
**The generated prompt includes:**
|
|
93
|
+
- Your original request
|
|
94
|
+
- Affected modules and files
|
|
74
95
|
- Architectural considerations
|
|
75
|
-
- Related symbols to
|
|
96
|
+
- Related symbols to be aware of
|
|
76
97
|
- Key dependencies
|
|
77
98
|
- AI-friendly recommendations
|
|
78
99
|
|
|
79
|
-
|
|
80
|
-
```bash
|
|
81
|
-
cxgrd prompt "add OAuth2 authentication" --path /myapp
|
|
82
|
-
```
|
|
100
|
+
Paste the output directly into Claude, ChatGPT, Cursor, or any AI tool.
|
|
83
101
|
|
|
84
102
|
---
|
|
85
103
|
|
|
86
|
-
|
|
87
|
-
**Purpose:** Structural graph validation + compiler-backed semantic checks
|
|
104
|
+
## Additional Commands
|
|
88
105
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
cxgrd check [projectPath] [--staged] [--changed] [--skip-compiler] [--skip-structural]
|
|
92
|
-
```
|
|
106
|
+
### `cxgrd check [path]`
|
|
107
|
+
Validates your project structurally and with compiler-backed checks. Catches circular dependencies, orphaned files, layer violations, and type/syntax errors.
|
|
93
108
|
|
|
94
|
-
**Options:**
|
|
95
|
-
- `projectPath` (optional): Path to analyze
|
|
96
|
-
- `--staged`: Only report issues in git staged files (used by pre-commit hooks)
|
|
97
|
-
- `--changed`: Staged + unstaged changed files
|
|
98
|
-
- `--skip-compiler`: Structural checks only
|
|
99
|
-
- `--skip-structural`: Compiler checks only
|
|
100
|
-
- `--strict`: Fail if a detected language's compiler was skipped (recommended for CI)
|
|
101
|
-
|
|
102
|
-
**Compiler tools (auto-detected per project):**
|
|
103
|
-
- TypeScript — programmatic `typescript` API per `tsconfig.json`
|
|
104
|
-
- Python — `pyright --outputjson` (skipped if pyright not on PATH)
|
|
105
|
-
- Rust — `cargo check --message-format=json`
|
|
106
|
-
|
|
107
|
-
**Output:**
|
|
108
|
-
- Structural: circular deps, orphans, layer violations
|
|
109
|
-
- Compiler: type/syntax errors with file, line, and diagnostic code
|
|
110
|
-
- `.cg/check-latest.json` with full result payload
|
|
111
|
-
|
|
112
|
-
**Examples:**
|
|
113
109
|
```bash
|
|
114
|
-
cxgrd check
|
|
115
|
-
cxgrd check . --staged
|
|
116
|
-
cxgrd check . --
|
|
117
|
-
cxgrd check . --strict # CI: fail if Pyright/cargo missing on detected projects
|
|
118
|
-
cxgrd doctor . # verify toolchain before enabling --strict
|
|
110
|
+
cxgrd check .
|
|
111
|
+
cxgrd check . --staged # only staged files (great for pre-commit hooks)
|
|
112
|
+
cxgrd check . --strict # fail if compiler tools are missing (recommended for CI)
|
|
119
113
|
```
|
|
120
114
|
|
|
121
|
-
|
|
122
|
-
|
|
115
|
+
Supports TypeScript, Python (Pyright), and Rust (cargo check) out of the box.
|
|
116
|
+
|
|
117
|
+
### `cxgrd doctor [path]`
|
|
118
|
+
Verifies your toolchain is ready before enabling strict checks.
|
|
123
119
|
|
|
124
|
-
**Syntax:**
|
|
125
120
|
```bash
|
|
126
|
-
cxgrd doctor # global toolchain
|
|
127
|
-
cxgrd doctor
|
|
121
|
+
cxgrd doctor # check global toolchain
|
|
122
|
+
cxgrd doctor . # check project-specific readiness
|
|
128
123
|
```
|
|
129
124
|
|
|
130
|
-
|
|
125
|
+
### `cxgrd init-hooks`
|
|
126
|
+
Sets up a pre-commit hook so CXGRD checks run automatically before every commit.
|
|
131
127
|
|
|
132
|
-
### cxgrd init-hooks
|
|
133
|
-
**Purpose:** Initialize pre-commit hooks to catch errors before commiting to git
|
|
134
|
-
|
|
135
|
-
**Syntax:**
|
|
136
128
|
```bash
|
|
137
|
-
cxgrd init-hooks
|
|
138
|
-
cxgrd init-hooks --threshold 80 --block-critical
|
|
139
|
-
cxgrd init-hooks --uninstall
|
|
129
|
+
cxgrd init-hooks
|
|
130
|
+
cxgrd init-hooks --threshold 80 --block-critical
|
|
131
|
+
cxgrd init-hooks --uninstall
|
|
140
132
|
```
|
|
141
133
|
|
|
142
|
-
### cxgrd watch
|
|
143
|
-
|
|
134
|
+
### `cxgrd watch`
|
|
135
|
+
Runs in the background and monitors your project for dependency changes in real time.
|
|
144
136
|
|
|
145
|
-
**Syntax:**
|
|
146
137
|
```bash
|
|
147
138
|
cxgrd watch
|
|
148
139
|
```
|
|
149
140
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
### graph.json Structure
|
|
153
|
-
```json
|
|
154
|
-
{
|
|
155
|
-
"files": {
|
|
156
|
-
"src/services/auth.ts": {
|
|
157
|
-
"path": "src/services/auth.ts",
|
|
158
|
-
"language": "typescript",
|
|
159
|
-
"dependencies": [
|
|
160
|
-
{
|
|
161
|
-
"from": "src/services/auth.ts",
|
|
162
|
-
"to": "./utils/crypto.ts",
|
|
163
|
-
"type": "import",
|
|
164
|
-
"line": 3
|
|
165
|
-
}
|
|
166
|
-
],
|
|
167
|
-
"symbols": ["authenticate", "AuthService", "validateToken"]
|
|
168
|
-
}
|
|
169
|
-
},
|
|
170
|
-
"stats": {
|
|
171
|
-
"totalFiles": 42,
|
|
172
|
-
"totalDependencies": 156,
|
|
173
|
-
"languages": {
|
|
174
|
-
"typescript": 32,
|
|
175
|
-
"python": 10
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
```
|
|
141
|
+
---
|
|
180
142
|
|
|
181
|
-
##
|
|
143
|
+
## Typical Workflow
|
|
182
144
|
|
|
183
|
-
### Installation
|
|
184
145
|
```bash
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
```
|
|
146
|
+
# 1. Authenticate
|
|
147
|
+
cxgrd auth login
|
|
188
148
|
|
|
189
|
-
|
|
149
|
+
# 2. Scan your project
|
|
150
|
+
cxgrd scan .
|
|
190
151
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
npm run dev -- scan /path/to/project
|
|
194
|
-
```
|
|
195
|
-
Analyzes the project and creates `.cg/` with dependency graph.
|
|
152
|
+
# 3. Before making a change — check the blast radius
|
|
153
|
+
cxgrd input "extract UserService into a separate module"
|
|
196
154
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
npm run dev -- input "describe your change here"
|
|
200
|
-
```
|
|
201
|
-
Shows which files will be affected by your proposed change.
|
|
155
|
+
# 4. Generate an enriched prompt for your AI
|
|
156
|
+
cxgrd prompt "extract UserService into a separate module"
|
|
202
157
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
158
|
+
# 5. Paste the prompt into your AI tool, make the changes
|
|
159
|
+
|
|
160
|
+
# 6. Validate the result
|
|
161
|
+
cxgrd check .
|
|
206
162
|
```
|
|
207
|
-
Creates an architecturally-aware prompt for your AI assistant.
|
|
208
163
|
|
|
209
|
-
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## Development
|
|
167
|
+
|
|
210
168
|
```bash
|
|
211
|
-
npm
|
|
212
|
-
|
|
213
|
-
Checks for circular dependencies, orphaned files, and architecture violations.
|
|
169
|
+
npm install
|
|
170
|
+
npm run build
|
|
214
171
|
|
|
215
|
-
|
|
172
|
+
# Run commands locally
|
|
173
|
+
npm run dev -- scan /path/to/project
|
|
174
|
+
npm run dev -- input "describe your change"
|
|
175
|
+
npm run dev -- prompt "describe your feature"
|
|
176
|
+
```
|
|
216
177
|
|
|
217
|
-
|
|
218
|
-
2. **Graph Builder** - Extracts dependencies and symbols
|
|
219
|
-
3. **CG Directory** - Manages `.cg/` persistence
|
|
220
|
-
4. **Commands** - User-facing CLI operations
|
|
178
|
+
---
|
|
221
179
|
|
|
180
|
+
**Learn more at [cxgrd.com](https://cxgrd.com)**
|