@devshub198211/devguard 2.0.2 → 2.0.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/MODULES.md +261 -102
- package/README.md +130 -139
- package/SETUP.md +66 -123
- package/dist/ai.d.ts +8 -0
- package/dist/ai.js +1 -1
- package/dist/{chunk-4WCL5IUZ.js → chunk-UXM7HRTI.js} +12 -2
- package/dist/cli.js +530 -173
- package/dist/index.js +1 -1
- package/package.json +13 -38
- package/dist/ai.cjs +0 -867
- package/dist/ai.d.cts +0 -169
- package/dist/api-contract-5kJEwFIh.d.cts +0 -157
- package/dist/auth.cjs +0 -787
- package/dist/auth.d.cts +0 -245
- package/dist/cli.cjs +0 -1162
- package/dist/cli.d.cts +0 -1
- package/dist/dx.cjs +0 -747
- package/dist/dx.d.cts +0 -96
- package/dist/index.cjs +0 -2655
- package/dist/index.d.cts +0 -38
- package/dist/security.cjs +0 -654
- package/dist/security.d.cts +0 -114
package/README.md
CHANGED
|
@@ -1,167 +1,151 @@
|
|
|
1
|
-
# devguard
|
|
1
|
+
# @devshub198211/devguard
|
|
2
2
|
|
|
3
|
-
> **One install. 14
|
|
4
|
-
> Security · AI Tooling · Auth · DX — everything a production Node.js
|
|
3
|
+
> **One install. 14 modules. Zero external dependencies.**
|
|
4
|
+
> Security · AI Tooling · Auth · DX — everything a production Node.js project needs.
|
|
5
5
|
|
|
6
6
|
```bash
|
|
7
|
-
npm install devguard
|
|
8
|
-
npx devguard # instant security scan — no install needed
|
|
7
|
+
npm install @devshub198211/devguard
|
|
9
8
|
```
|
|
10
9
|
|
|
11
|
-
[](https://www.npmjs.com/package/devguard)
|
|
12
|
-
[](LICENSE)
|
|
13
|
-
[](package.json)
|
|
14
|
-
|
|
15
|
-
---
|
|
16
|
-
|
|
17
|
-
## Features
|
|
18
|
-
|
|
19
|
-
| Category | Feature | What it does |
|
|
20
|
-
|----------|---------|-------------|
|
|
21
|
-
| 🔒 Security | `lockfile-guardian` | SHA-512 tamper detection for npm/yarn/pnpm lockfiles |
|
|
22
|
-
| 🔒 Security | `hook-scanner` | 23-rule malware scanner for install scripts (obfuscation-aware) |
|
|
23
|
-
| 🔒 Security | `token-rotator` | Live API verification + age alerts for npm/GitHub tokens |
|
|
24
|
-
| 🔒 Security | `dep-pincer` | Enforce exact version pins + SRI hash verification |
|
|
25
|
-
| 🤖 AI | `agent-schema` | Validate LLM JSON output, auto-retry on malformed responses |
|
|
26
|
-
| 🤖 AI | `mcp-server-kit` | Build Claude-compatible MCP tool servers in minutes |
|
|
27
|
-
| 🤖 AI | `agent-memory` | Durable agent state: Memory / FileSystem / Redis / DynamoDB |
|
|
28
|
-
| 🤖 AI | `llm-budget` | Token counting + cost tracking for OpenAI/Anthropic/Gemini |
|
|
29
|
-
| 🔑 Auth | `zero-trust-jwt` | JWT verify (HS256/RS256/JWKS), revocation, anomaly detection |
|
|
30
|
-
| 🔑 Auth | `bot-fence` | Multi-signal bot detection middleware for Express/Fastify |
|
|
31
|
-
| 🔑 Auth | `passkey-node` | Production WebAuthn passkey registration & authentication |
|
|
32
|
-
| 🛠 DX | `env-safe` | Typed .env validation with built-in parser — fail fast |
|
|
33
|
-
| 🛠 DX | `log-otlp` | Structured JSON logger with OpenTelemetry trace injection |
|
|
34
|
-
| 🛠 DX | `api-contract` | Zero-dep schema builder with full TypeScript type inference |
|
|
35
|
-
|
|
36
10
|
---
|
|
37
11
|
|
|
38
12
|
## Quick Start
|
|
39
13
|
|
|
40
|
-
### CLI
|
|
41
14
|
```bash
|
|
42
|
-
|
|
43
|
-
npx devguard
|
|
44
|
-
npx devguard lockfile verify # check integrity
|
|
45
|
-
npx devguard hooks # scan node_modules for malware
|
|
46
|
-
npx devguard pins --fix # auto-pin unpinned dependencies
|
|
47
|
-
npx devguard tokens --live # verify tokens via API
|
|
48
|
-
npx devguard --json # machine-readable output for CI
|
|
49
|
-
```
|
|
15
|
+
# Initialize DevGuard in your project
|
|
16
|
+
npx @devshub198211/devguard init
|
|
50
17
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
import { runAllChecks } from 'devguard';
|
|
18
|
+
# Run a full security audit
|
|
19
|
+
npx @devshub198211/devguard check
|
|
54
20
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (!report.passedAll) process.exit(1);
|
|
21
|
+
# AI-powered code refactor (free, runs locally)
|
|
22
|
+
npx @devshub198211/devguard refactor src/app.ts
|
|
58
23
|
```
|
|
59
24
|
|
|
60
|
-
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
import { JWTVerifier } from 'devguard/auth';
|
|
65
|
-
import { loadEnv } from 'devguard/dx';
|
|
25
|
+
For global CLI access:
|
|
26
|
+
```bash
|
|
27
|
+
npm install -g @devshub198211/devguard
|
|
28
|
+
devguard check
|
|
66
29
|
```
|
|
67
30
|
|
|
68
31
|
---
|
|
69
32
|
|
|
70
|
-
##
|
|
33
|
+
## All 14 Modules
|
|
34
|
+
|
|
35
|
+
| # | Category | Module | CLI Command | What It Does |
|
|
36
|
+
|---|----------|--------|-------------|--------------|
|
|
37
|
+
| 1 | 🔒 Security | `lockfile-guardian` | `check` / `snapshot` | SHA-512 lockfile tamper detection |
|
|
38
|
+
| 2 | 🔒 Security | `hook-scanner` | `scan` | 23-rule malware scanner for install scripts |
|
|
39
|
+
| 3 | 🔒 Security | `token-rotator` | `tokens` | Live API token verification + age alerts |
|
|
40
|
+
| 4 | 🔒 Security | `dep-pincer` | `pin --fix` | Enforce exact version pins + SRI hashes |
|
|
41
|
+
| 5 | 🤖 AI | `refactor-engine` | `refactor <file>` | Complexity analysis + security patching |
|
|
42
|
+
| 6 | 🤖 AI | `agent-schema` | `schema <json>` | Validate & auto-repair LLM JSON output |
|
|
43
|
+
| 7 | 🤖 AI | `mcp-server-kit` | `mcp` | Build Claude-compatible MCP tool servers |
|
|
44
|
+
| 8 | 🤖 AI | `agent-memory` | `memory --agent <id>` | Durable state for AI agents (FS/Redis) |
|
|
45
|
+
| 9 | 🤖 AI | `llm-budget` | `budget` | Token counting + cost tracking |
|
|
46
|
+
| 10 | 🔑 Auth | `zero-trust-jwt` | `jwt-verify` / `jwt-sign` | JWT sign & verify with anomaly detection |
|
|
47
|
+
| 11 | 🔑 Auth | `bot-fence` | `bot-check --ip <ip>` | Multi-signal bot detection middleware |
|
|
48
|
+
| 12 | 🔑 Auth | `passkey-node` | `passkey-verify` | WebAuthn passkey registration & auth |
|
|
49
|
+
| 13 | 🛠 DX | `env-safe` | `env-verify` | Typed .env validation — fail fast |
|
|
50
|
+
| 14 | 🛠 DX | `log-otlp` | `log --msg <text>` | Structured JSON logger + OpenTelemetry |
|
|
51
|
+
|
|
52
|
+
**Bonus:** `api-contract` — zero-dep schema builder with TypeScript inference.
|
|
71
53
|
|
|
72
|
-
|
|
73
|
-
```typescript
|
|
74
|
-
import { runAllChecks } from 'devguard';
|
|
75
|
-
const report = await runAllChecks();
|
|
76
|
-
console.log(`Security score: ${report.score}/100`);
|
|
77
|
-
```
|
|
54
|
+
---
|
|
78
55
|
|
|
79
|
-
|
|
80
|
-
```typescript
|
|
81
|
-
import { c, parseWithRetry } from 'devguard';
|
|
82
|
-
|
|
83
|
-
const TaskSchema = c.object({
|
|
84
|
-
title: c.string().min(1),
|
|
85
|
-
priority: c.string().enum(["high","medium","low"]),
|
|
86
|
-
dueDate: c.string().optional(),
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
const result = await parseWithRetry(TaskSchema, async (ctx) => {
|
|
90
|
-
return await callYourLLM(ctx); // your LLM call here
|
|
91
|
-
});
|
|
92
|
-
// result.data is fully typed: { title: string; priority: "high"|"medium"|"low"; dueDate?: string }
|
|
93
|
-
```
|
|
56
|
+
## Use From Any Language (Python, Go, Bash, etc.)
|
|
94
57
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
58
|
+
Every command supports `--json` output, making DevGuard usable from **any programming language**:
|
|
59
|
+
|
|
60
|
+
### Python
|
|
61
|
+
```python
|
|
62
|
+
import subprocess, json
|
|
98
63
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
64
|
+
result = subprocess.run(
|
|
65
|
+
["npx", "@devshub198211/devguard", "check", "--json"],
|
|
66
|
+
capture_output=True, text=True
|
|
67
|
+
)
|
|
68
|
+
report = json.loads(result.stdout)
|
|
69
|
+
print(f"Security Score: {report['score']}/100")
|
|
104
70
|
```
|
|
105
71
|
|
|
106
|
-
###
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
.addTool({
|
|
112
|
-
name: 'get_weather',
|
|
113
|
-
description: 'Get weather for a city',
|
|
114
|
-
inputSchema: { type:'object', properties:{ city:{type:'string'} }, required:['city'] },
|
|
115
|
-
handler: async ({ city }) => ({ temp: '22°C', city })
|
|
116
|
-
})
|
|
117
|
-
.startStdio(); // works with Claude Desktop + any MCP client
|
|
72
|
+
### Go
|
|
73
|
+
```go
|
|
74
|
+
cmd := exec.Command("npx", "@devshub198211/devguard", "scan", "--json")
|
|
75
|
+
output, _ := cmd.Output()
|
|
76
|
+
// Parse JSON output
|
|
118
77
|
```
|
|
119
78
|
|
|
120
|
-
###
|
|
121
|
-
```
|
|
122
|
-
|
|
79
|
+
### Bash
|
|
80
|
+
```bash
|
|
81
|
+
SCORE=$(npx @devshub198211/devguard check --json | jq '.score')
|
|
82
|
+
echo "Score: $SCORE"
|
|
123
83
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
84
|
+
# Sign a JWT
|
|
85
|
+
TOKEN=$(devguard jwt-sign --payload '{"sub":"user-1"}' --secret mykey --json | jq -r '.token')
|
|
86
|
+
|
|
87
|
+
# Check an IP
|
|
88
|
+
devguard bot-check --ip 203.0.113.5 --json | jq '.verdict'
|
|
127
89
|
```
|
|
128
90
|
|
|
129
|
-
###
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
const app = express();
|
|
135
|
-
app.use(createMiddleware({
|
|
136
|
-
blockThreshold: 70,
|
|
137
|
-
rateLimiter: new IPRateLimiter(100, 60_000)
|
|
138
|
-
}));
|
|
91
|
+
### Ruby
|
|
92
|
+
```ruby
|
|
93
|
+
result = `npx @devshub198211/devguard check --json`
|
|
94
|
+
report = JSON.parse(result)
|
|
95
|
+
puts "Score: #{report['score']}"
|
|
139
96
|
```
|
|
140
97
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## CLI Reference
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
# Core
|
|
104
|
+
devguard init # Set up project
|
|
105
|
+
devguard check [--json] # Full security audit
|
|
106
|
+
devguard refactor <file> [--json] # AI code refactor
|
|
107
|
+
devguard mcp # Start MCP server
|
|
108
|
+
|
|
109
|
+
# Security
|
|
110
|
+
devguard snapshot # Create lockfile baseline
|
|
111
|
+
devguard scan [--json] # Malware scan
|
|
112
|
+
devguard tokens [--json] # Token health check
|
|
113
|
+
devguard pin [--fix] [--json] # Pin dependencies
|
|
114
|
+
|
|
115
|
+
# AI
|
|
116
|
+
devguard schema '<json>' [--json] # Validate JSON
|
|
117
|
+
devguard memory [--agent <id>] [--json] # Query agent state
|
|
118
|
+
devguard budget [--json] # LLM cost summary
|
|
119
|
+
|
|
120
|
+
# Auth
|
|
121
|
+
devguard jwt-verify --token <t> --secret <s> # Verify JWT
|
|
122
|
+
devguard jwt-sign --payload '<json>' --secret <s> # Sign JWT
|
|
123
|
+
devguard bot-check --ip <ip> [--json] # Bot detection
|
|
124
|
+
|
|
125
|
+
# DX
|
|
126
|
+
devguard env-verify [--file .env] [--json] # Validate env
|
|
127
|
+
devguard log --msg <text> [--level info|warn|error] # Emit log
|
|
152
128
|
```
|
|
153
129
|
|
|
154
|
-
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## Programmatic Usage (Node.js / TypeScript)
|
|
133
|
+
|
|
155
134
|
```typescript
|
|
156
|
-
import {
|
|
135
|
+
import { runAllChecks } from '@devshub198211/devguard';
|
|
157
136
|
|
|
158
|
-
const
|
|
159
|
-
log
|
|
160
|
-
|
|
137
|
+
const report = await runAllChecks();
|
|
138
|
+
console.log(`Security Score: ${report.score}/100`);
|
|
139
|
+
if (!report.passedAll) process.exit(1);
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Tree-Shakeable Sub-Path Imports
|
|
161
143
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
144
|
+
```typescript
|
|
145
|
+
import { verifyLockfile } from '@devshub198211/devguard/security';
|
|
146
|
+
import { LLMBudget } from '@devshub198211/devguard/ai';
|
|
147
|
+
import { JWTVerifier } from '@devshub198211/devguard/auth';
|
|
148
|
+
import { loadEnv } from '@devshub198211/devguard/dx';
|
|
165
149
|
```
|
|
166
150
|
|
|
167
151
|
---
|
|
@@ -179,29 +163,36 @@ jobs:
|
|
|
179
163
|
- uses: actions/setup-node@v4
|
|
180
164
|
with: { node-version: '20' }
|
|
181
165
|
- run: npm ci
|
|
182
|
-
- run: npx devguard --json >
|
|
183
|
-
|
|
184
|
-
DEVGUARD_TOKENS: NPM_TOKEN,GITHUB_TOKEN
|
|
185
|
-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
186
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
187
|
-
- uses: actions/upload-artifact@v4
|
|
188
|
-
with: { name: security-report, path: devguard-report.json }
|
|
189
|
-
- run: node -e "const r=require('./devguard-report.json'); if(!r.passedAll) process.exit(1)"
|
|
166
|
+
- run: npx @devshub198211/devguard check --json > report.json
|
|
167
|
+
- run: node -e "const r=JSON.parse(require('fs').readFileSync('report.json'));if(!r.passedAll)process.exit(1)"
|
|
190
168
|
```
|
|
191
169
|
|
|
192
170
|
---
|
|
193
171
|
|
|
194
|
-
## Security
|
|
172
|
+
## Security Guarantees
|
|
195
173
|
|
|
196
174
|
- ✅ **Zero external runtime dependencies** — only Node.js built-ins
|
|
197
|
-
- ✅ **No network calls** at runtime except
|
|
175
|
+
- ✅ **No network calls** at runtime (except opt-in token verification)
|
|
198
176
|
- ✅ **No telemetry, no tracking, no phone-home**
|
|
199
|
-
- ✅ **Constant-time JWT comparison** —
|
|
177
|
+
- ✅ **Constant-time JWT comparison** — timing attack protection
|
|
200
178
|
- ✅ **Sign-count replay protection** in WebAuthn
|
|
179
|
+
- ✅ **Path traversal protection** — all file IDs are SHA-256 hashed
|
|
180
|
+
- ✅ **Prototype pollution prevention** in CBOR/JSON parsers
|
|
181
|
+
- ✅ **Atomic file writes** — no data corruption during crashes
|
|
201
182
|
- ✅ **Works fully offline** — all security checks are local
|
|
202
183
|
|
|
203
184
|
---
|
|
204
185
|
|
|
186
|
+
## Requirements
|
|
187
|
+
|
|
188
|
+
- Node.js >= 18.0.0
|
|
189
|
+
|
|
205
190
|
## License
|
|
206
191
|
|
|
207
192
|
MIT © DevGuard Contributors
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
*Your custom notes below:*
|
|
197
|
+
|
|
198
|
+
<!-- Add your personal notes, contact info, or acknowledgments here -->
|
package/SETUP.md
CHANGED
|
@@ -1,168 +1,111 @@
|
|
|
1
|
-
#
|
|
1
|
+
# DevGuard Setup Guide
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Get your project secured in under 2 minutes.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
```
|
|
7
|
-
node --version # must be >= 18.0.0
|
|
8
|
-
npm --version # must be >= 9.0.0
|
|
9
|
-
```
|
|
5
|
+
---
|
|
10
6
|
|
|
11
|
-
|
|
12
|
-
```
|
|
13
|
-
unzip devguard-final.zip
|
|
14
|
-
cd devguard-final
|
|
15
|
-
npm install
|
|
16
|
-
```
|
|
7
|
+
## Step 1: Install
|
|
17
8
|
|
|
18
|
-
|
|
9
|
+
```bash
|
|
10
|
+
npm install @devshub198211/devguard
|
|
19
11
|
```
|
|
20
|
-
npm run build
|
|
21
|
-
```
|
|
22
|
-
Generates dist/ with CJS + ESM + TypeScript declarations + CLI.
|
|
23
12
|
|
|
24
|
-
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
node dist/cli.js lockfile snapshot # create integrity baseline
|
|
28
|
-
node dist/cli.js lockfile verify # verify against baseline
|
|
29
|
-
node dist/cli.js hooks # scan for malicious scripts
|
|
30
|
-
node dist/cli.js pins --fix # auto-fix unpinned deps
|
|
31
|
-
node dist/cli.js tokens --live # live API token check
|
|
32
|
-
node dist/cli.js --json # machine-readable output
|
|
33
|
-
node dist/cli.js help # all commands
|
|
13
|
+
Or install globally for CLI access anywhere:
|
|
14
|
+
```bash
|
|
15
|
+
npm install -g @devshub198211/devguard
|
|
34
16
|
```
|
|
35
17
|
|
|
36
|
-
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
```typescript
|
|
42
|
-
import { runAllChecks } from 'devguard';
|
|
43
|
-
const report = await runAllChecks();
|
|
44
|
-
console.log(report.score); // 0-100
|
|
45
|
-
if (!report.passedAll) process.exit(1);
|
|
18
|
+
Or run instantly without installing:
|
|
19
|
+
```bash
|
|
20
|
+
npx @devshub198211/devguard check
|
|
46
21
|
```
|
|
47
22
|
|
|
48
23
|
---
|
|
49
24
|
|
|
50
|
-
##
|
|
51
|
-
|
|
52
|
-
### Step 1 — Create Account
|
|
53
|
-
1. https://www.npmjs.com/signup
|
|
54
|
-
2. Verify email
|
|
55
|
-
3. Enable 2FA (mandatory): https://www.npmjs.com/settings/~/profile
|
|
25
|
+
## Step 2: Initialize Your Project
|
|
56
26
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
npm login
|
|
60
|
-
npm whoami
|
|
27
|
+
```bash
|
|
28
|
+
devguard init
|
|
61
29
|
```
|
|
62
30
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
If taken, rename in package.json: "name": "@yourscope/devguard"
|
|
31
|
+
This creates:
|
|
32
|
+
- **`.devguardrc`** — Configuration file for security rules
|
|
33
|
+
- **`.devguard-memory/`** — Local storage for AI agent state
|
|
34
|
+
- **Security snapshot** — Baseline integrity hash of your lockfiles
|
|
68
35
|
|
|
69
|
-
|
|
70
|
-
```
|
|
71
|
-
npm publish --dry-run --access public
|
|
72
|
-
```
|
|
36
|
+
---
|
|
73
37
|
|
|
74
|
-
|
|
75
|
-
```
|
|
76
|
-
npm run build
|
|
77
|
-
npm publish --access public
|
|
78
|
-
```
|
|
38
|
+
## Step 3: Run Your First Audit
|
|
79
39
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
npm info devguard
|
|
83
|
-
npx devguard help
|
|
40
|
+
```bash
|
|
41
|
+
devguard check
|
|
84
42
|
```
|
|
85
43
|
|
|
86
|
-
|
|
87
|
-
```
|
|
88
|
-
npm version patch # 2.0.0 -> 2.0.1
|
|
89
|
-
npm run build
|
|
90
|
-
npm publish --access public
|
|
91
|
-
```
|
|
44
|
+
You'll see a score out of 100. A perfect project scores 100/100.
|
|
92
45
|
|
|
93
46
|
---
|
|
94
47
|
|
|
95
|
-
##
|
|
48
|
+
## Step 4: Refactor Code (Free, Runs Locally)
|
|
96
49
|
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
git add .
|
|
100
|
-
git commit -m "feat: devguard v2.0.0"
|
|
101
|
-
gh repo create devguard --public --push
|
|
50
|
+
```bash
|
|
51
|
+
devguard refactor src/your-file.ts
|
|
102
52
|
```
|
|
103
53
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
steps:
|
|
112
|
-
- uses: actions/checkout@v4
|
|
113
|
-
- uses: actions/setup-node@v4
|
|
114
|
-
with: { node-version: '20', cache: 'npm' }
|
|
115
|
-
- run: npm ci && npm run build
|
|
116
|
-
- run: node dist/cli.js --json
|
|
117
|
-
```
|
|
54
|
+
This opens a browser window showing:
|
|
55
|
+
- **Original code** on the left
|
|
56
|
+
- **Optimized code** on the right
|
|
57
|
+
- **Time complexity** analysis (e.g., O(n²) → O(n))
|
|
58
|
+
- **Security fixes** applied (eval removal, XSS patches)
|
|
59
|
+
|
|
60
|
+
Click "Apply" to save the changes.
|
|
118
61
|
|
|
119
62
|
---
|
|
120
63
|
|
|
121
|
-
##
|
|
64
|
+
## Step 5: Optional — Enable Cloud AI Mode
|
|
122
65
|
|
|
123
|
-
|
|
124
|
-
- GitHub Sponsors: github.com/sponsors/onboarding — $5/$15/$50 tiers
|
|
125
|
-
- Polar.sh: polar.sh — connect repo, create paid issues
|
|
126
|
-
- Target: $200-2000/month at 1k+ weekly downloads
|
|
66
|
+
For deeper AI-powered refactoring using Google Gemini:
|
|
127
67
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
68
|
+
1. Get a free API key: https://aistudio.google.com/app/apikey
|
|
69
|
+
2. Set it:
|
|
70
|
+
```bash
|
|
71
|
+
export DEVGUARD_AI_KEY="your_key_here"
|
|
72
|
+
```
|
|
73
|
+
3. Run refactor again — it will use Cloud AI automatically.
|
|
134
74
|
|
|
135
|
-
|
|
75
|
+
Without a key, all features still work using the built-in local analysis engine.
|
|
136
76
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Step 6: Add to CI/CD
|
|
140
80
|
|
|
141
|
-
|
|
142
|
-
Inline warnings for ^ ~ deps, missing env vars, security score in status bar.
|
|
143
|
-
Freemium: free basic, paid Pro ($4.99/month).
|
|
81
|
+
Add this to your GitHub Actions workflow:
|
|
144
82
|
|
|
145
|
-
|
|
146
|
-
|
|
83
|
+
```yaml
|
|
84
|
+
- run: npx @devshub198211/devguard check --json > report.json
|
|
85
|
+
```
|
|
147
86
|
|
|
148
87
|
---
|
|
149
88
|
|
|
150
|
-
##
|
|
89
|
+
## Troubleshooting
|
|
151
90
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
91
|
+
| Problem | Solution |
|
|
92
|
+
|---------|----------|
|
|
93
|
+
| `command not found: devguard` | Use `npx @devshub198211/devguard` instead |
|
|
94
|
+
| `missing script` error | Don't use `npm run devguard` — use `npx devguard` |
|
|
95
|
+
| Refactor opens blank page | Wait 2 seconds, then refresh the browser |
|
|
96
|
+
| Score is 0 | Run `devguard init` first to create a baseline |
|
|
155
97
|
|
|
156
98
|
---
|
|
157
99
|
|
|
158
|
-
##
|
|
100
|
+
## Uninstall
|
|
159
101
|
|
|
102
|
+
```bash
|
|
103
|
+
npm uninstall @devshub198211/devguard
|
|
104
|
+
rm -rf .devguardrc .devguard-memory .devguard-snapshot.json
|
|
160
105
|
```
|
|
161
|
-
npm install devguard
|
|
162
106
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
```
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
*Your custom notes below:*
|
|
110
|
+
|
|
111
|
+
<!-- Add your personal notes here -->
|
package/dist/ai.d.ts
CHANGED
|
@@ -162,6 +162,14 @@ declare class LLMBudget {
|
|
|
162
162
|
remaining: number;
|
|
163
163
|
isExceeded: boolean;
|
|
164
164
|
};
|
|
165
|
+
report(): {
|
|
166
|
+
totalCost: number;
|
|
167
|
+
recordCount: number;
|
|
168
|
+
monthlyLimitUSD: number;
|
|
169
|
+
remaining: number;
|
|
170
|
+
isOverBudget: boolean;
|
|
171
|
+
warnAtUSD: number | null;
|
|
172
|
+
};
|
|
165
173
|
getHistory(limit?: number): LLMUsage[];
|
|
166
174
|
reset(): void;
|
|
167
175
|
}
|
package/dist/ai.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { AgentMemory, FileSystemAdapter, LLMBudget, MCPServerBuilder, RedisAdapter, cleanLLMOutput, parseSchema, parseWithRetry } from './chunk-
|
|
1
|
+
export { AgentMemory, FileSystemAdapter, LLMBudget, MCPServerBuilder, RedisAdapter, cleanLLMOutput, parseSchema, parseWithRetry } from './chunk-UXM7HRTI.js';
|
|
2
2
|
export { c, c as s } from './chunk-KSFZPDFO.js';
|
|
@@ -127,7 +127,7 @@ async function parseWithRetry(schema, promptFn, maxRetries = 3) {
|
|
|
127
127
|
|
|
128
128
|
// src/ai/mcp-server-kit.ts
|
|
129
129
|
var ERR = { PARSE: -32700, INVALID: -32600, NOT_FOUND: -32601, PARAMS: -32602, INTERNAL: -32603 };
|
|
130
|
-
var MAX_MESSAGE_SIZE =
|
|
130
|
+
var MAX_MESSAGE_SIZE = 50 * 1024 * 1024;
|
|
131
131
|
var MAX_NAME_LENGTH = 256;
|
|
132
132
|
var HANDLER_TIMEOUT_MS = 3e4;
|
|
133
133
|
function validateToolInput(args, schema) {
|
|
@@ -447,7 +447,7 @@ var AgentMemory = class {
|
|
|
447
447
|
await this.adapter.clear(agentId);
|
|
448
448
|
}
|
|
449
449
|
};
|
|
450
|
-
var MAX_RECORDS =
|
|
450
|
+
var MAX_RECORDS = 5e4;
|
|
451
451
|
var LLMBudget = class {
|
|
452
452
|
constructor(config) {
|
|
453
453
|
this.records = [];
|
|
@@ -481,6 +481,16 @@ var LLMBudget = class {
|
|
|
481
481
|
isExceeded: this.totalCost >= this.config.monthlyLimitUSD
|
|
482
482
|
};
|
|
483
483
|
}
|
|
484
|
+
report() {
|
|
485
|
+
return {
|
|
486
|
+
totalCost: this.totalCost,
|
|
487
|
+
recordCount: this.records.length,
|
|
488
|
+
monthlyLimitUSD: this.config.monthlyLimitUSD,
|
|
489
|
+
remaining: Math.max(0, this.config.monthlyLimitUSD - this.totalCost),
|
|
490
|
+
isOverBudget: this.totalCost >= this.config.monthlyLimitUSD,
|
|
491
|
+
warnAtUSD: this.config.warnAtUSD ?? null
|
|
492
|
+
};
|
|
493
|
+
}
|
|
484
494
|
getHistory(limit = 100) {
|
|
485
495
|
return this.records.slice(-limit);
|
|
486
496
|
}
|