@devshub198211/devguard 2.0.1 → 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/SETUP.md ADDED
@@ -0,0 +1,111 @@
1
+ # DevGuard Setup Guide
2
+
3
+ Get your project secured in under 2 minutes.
4
+
5
+ ---
6
+
7
+ ## Step 1: Install
8
+
9
+ ```bash
10
+ npm install @devshub198211/devguard
11
+ ```
12
+
13
+ Or install globally for CLI access anywhere:
14
+ ```bash
15
+ npm install -g @devshub198211/devguard
16
+ ```
17
+
18
+ Or run instantly without installing:
19
+ ```bash
20
+ npx @devshub198211/devguard check
21
+ ```
22
+
23
+ ---
24
+
25
+ ## Step 2: Initialize Your Project
26
+
27
+ ```bash
28
+ devguard init
29
+ ```
30
+
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
35
+
36
+ ---
37
+
38
+ ## Step 3: Run Your First Audit
39
+
40
+ ```bash
41
+ devguard check
42
+ ```
43
+
44
+ You'll see a score out of 100. A perfect project scores 100/100.
45
+
46
+ ---
47
+
48
+ ## Step 4: Refactor Code (Free, Runs Locally)
49
+
50
+ ```bash
51
+ devguard refactor src/your-file.ts
52
+ ```
53
+
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.
61
+
62
+ ---
63
+
64
+ ## Step 5: Optional — Enable Cloud AI Mode
65
+
66
+ For deeper AI-powered refactoring using Google Gemini:
67
+
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.
74
+
75
+ Without a key, all features still work using the built-in local analysis engine.
76
+
77
+ ---
78
+
79
+ ## Step 6: Add to CI/CD
80
+
81
+ Add this to your GitHub Actions workflow:
82
+
83
+ ```yaml
84
+ - run: npx @devshub198211/devguard check --json > report.json
85
+ ```
86
+
87
+ ---
88
+
89
+ ## Troubleshooting
90
+
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 |
97
+
98
+ ---
99
+
100
+ ## Uninstall
101
+
102
+ ```bash
103
+ npm uninstall @devshub198211/devguard
104
+ rm -rf .devguardrc .devguard-memory .devguard-snapshot.json
105
+ ```
106
+
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-4WCL5IUZ.js';
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 = 10 * 1024 * 1024;
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 = 5e3;
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
  }