kramscan 0.1.0 โ†’ 0.1.1

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.
Files changed (61) hide show
  1. package/README.md +197 -48
  2. package/dist/agent/confirmation.d.ts +34 -0
  3. package/dist/agent/confirmation.js +190 -0
  4. package/dist/agent/context.d.ts +81 -0
  5. package/dist/agent/context.js +228 -0
  6. package/dist/agent/index.d.ts +10 -0
  7. package/dist/agent/index.js +32 -0
  8. package/dist/agent/orchestrator.d.ts +61 -0
  9. package/dist/agent/orchestrator.js +328 -0
  10. package/dist/agent/prompts/system.d.ts +6 -0
  11. package/dist/agent/prompts/system.js +118 -0
  12. package/dist/agent/skill-registry.d.ts +78 -0
  13. package/dist/agent/skill-registry.js +202 -0
  14. package/dist/agent/skills/analyze-findings.d.ts +22 -0
  15. package/dist/agent/skills/analyze-findings.js +191 -0
  16. package/dist/agent/skills/generate-report.d.ts +26 -0
  17. package/dist/agent/skills/generate-report.js +436 -0
  18. package/dist/agent/skills/health-check.d.ts +28 -0
  19. package/dist/agent/skills/health-check.js +324 -0
  20. package/dist/agent/skills/index.d.ts +8 -0
  21. package/dist/agent/skills/index.js +15 -0
  22. package/dist/agent/skills/web-scan.d.ts +22 -0
  23. package/dist/agent/skills/web-scan.js +157 -0
  24. package/dist/agent/types.d.ts +141 -0
  25. package/dist/agent/types.js +16 -0
  26. package/dist/cli.d.ts +3 -0
  27. package/dist/cli.js +39 -3
  28. package/dist/commands/agent.d.ts +6 -0
  29. package/dist/commands/agent.js +250 -0
  30. package/dist/commands/analyze.js +1 -1
  31. package/dist/commands/config.js +8 -8
  32. package/dist/commands/doctor.js +2 -2
  33. package/dist/commands/onboard.js +24 -6
  34. package/dist/commands/report.js +1 -1
  35. package/dist/core/ai-client.d.ts +1 -1
  36. package/dist/core/ai-client.js +159 -16
  37. package/dist/core/config.d.ts +10 -6
  38. package/dist/core/config.js +198 -14
  39. package/dist/core/scanner.d.ts +15 -0
  40. package/dist/core/scanner.js +333 -52
  41. package/dist/core/vulnerability-detector.d.ts +15 -2
  42. package/dist/core/vulnerability-detector.js +334 -33
  43. package/package.json +27 -6
  44. package/dist/core/executor.d.ts +0 -2
  45. package/dist/core/executor.js +0 -74
  46. package/dist/core/logger.d.ts +0 -12
  47. package/dist/core/logger.js +0 -51
  48. package/dist/core/registry.d.ts +0 -3
  49. package/dist/core/registry.js +0 -35
  50. package/dist/core/storage.d.ts +0 -4
  51. package/dist/core/storage.js +0 -39
  52. package/dist/core/types.d.ts +0 -24
  53. package/dist/core/types.js +0 -2
  54. package/dist/skills/base.d.ts +0 -8
  55. package/dist/skills/base.js +0 -6
  56. package/dist/skills/builtin.d.ts +0 -4
  57. package/dist/skills/builtin.js +0 -71
  58. package/dist/skills/loader.d.ts +0 -2
  59. package/dist/skills/loader.js +0 -27
  60. package/dist/skills/types.d.ts +0 -46
  61. package/dist/skills/types.js +0 -2
package/README.md CHANGED
@@ -1,87 +1,236 @@
1
- # KramScan ๐Ÿ›ก๏ธ
1
+ <div align="center">
2
+ <img src="https://github.com/user-attachments/assets/6439c670-8d73-4bdd-b8fa-c74de949a31e" width="500" alt="KramScan Logo" />
2
3
 
3
- KramScan is a personal, AI-powered command-line interface (CLI) for web application security testing. It combines automated browser interactions (via Puppeteer) with AI analysis to identify vulnerabilities in modern web apps.
4
+ <h3 align="center">AI-Powered Web Application Security Testing CLI</h3>
5
+
6
+ <br />
7
+
8
+ [![npm version](https://img.shields.io/npm/v/kramscan?style=for-the-badge&logo=npm&logoColor=white&color=cb3837)](https://www.npmjs.com/package/kramscan)
9
+ [![npm downloads](https://img.shields.io/npm/dm/kramscan?style=for-the-badge&logo=npm&logoColor=white&color=blue)](https://www.npmjs.com/package/kramscan)
10
+ [![License](https://img.shields.io/github/license/shaikhakramshakil/kramscan?style=for-the-badge&logo=github&logoColor=white&color=green)](https://github.com/shaikhakramshakil/kramscan/blob/main/LICENSE)
11
+ [![Stars](https://img.shields.io/github/stars/shaikhakramshakil/kramscan?style=for-the-badge&logo=github&logoColor=white&color=yellow)](https://github.com/shaikhakramshakil/kramscan)
12
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.4-3178c6?style=for-the-badge&logo=typescript&logoColor=white)](https://www.typescriptlang.org)
13
+ [![Node.js](https://img.shields.io/badge/Node.js-%3E%3D18-brightgreen?style=for-the-badge&logo=nodedotjs&logoColor=white)](https://nodejs.org)
14
+
15
+ <br />
16
+
17
+ ๐Ÿ”ฌ **A next-generation security auditing tool that combines automated vulnerability scanning with multi-provider AI analysis.**
18
+
19
+ *Empowering developers and security researchers with institutional-grade insights and an interactive AI agent.*
20
+
21
+ <br />
22
+
23
+ [๐ŸŒ NPM Package](https://www.npmjs.com/package/kramscan) ยท [๐Ÿ“– Documentation](#-usage) ยท [๐Ÿž Report Bug](https://github.com/shaikhakramshakil/kramscan/issues)
24
+
25
+ </div>
4
26
 
5
27
  ---
6
28
 
7
- ## Quick Start
29
+ <br />
8
30
 
9
- ```bash
10
- # Install dependencies
11
- npm install
31
+ ## ๐Ÿš€ The Problem We Solve
32
+ Web security is complex and often fragmented. Developers rely on multiple disjointed tools for scanning, manual testing, and reporting. Traditional automated scanners generate noise without context, and manual pentesting is time-consuming and expensive.
33
+
34
+ **KramScan bridges this gap.** We provide a unified command-line interface that orchestrates headless browser scanning, scrapes critical security headers, and leverages **Generative AI** (OpenAI, Gemini, Anthropic) to analyze findings. It delivers actionable, human-readable insights alongside raw vulnerability dataโ€”all in seconds.
35
+
36
+ <br />
37
+
38
+ ---
12
39
 
13
- # Build the project
14
- npm run build
40
+ <br />
15
41
 
16
- # Link globally so you can use "kramscan" from anywhere
17
- npm link
42
+ ## โœจ Key Features
43
+ | Feature | Description |
44
+ | :--- | :--- |
45
+ | ๐Ÿ” **Automated Vulnerability Engine** | Detects XSS, SQL Injection, CSRF, and insecure headers using Puppeteer-powered crawling. |
46
+ | ๐Ÿค– **Interactive AI Agent** | A conversational security assistant that understands natural language commands like "scan example.com". |
47
+ | ๐Ÿง  **Multi-Provider AI Analysis** | Supports OpenAI, Anthropic, Google Gemini, Mistral, OpenRouter, and Kimi (Moonshot). |
48
+ | ๐Ÿ“„ **Professional Reporting** | Generates detailed DOCX, TXT, and JSON reports with executive summaries and remediation steps. |
49
+ | ๐ŸŒ **Headless Browser Testing** | Renders modern SPAs (Single Page Applications) to find vulnerabilities in dynamic content. |
50
+ | โšก **CLI-First Architecture** | Optimized for speed, scriptability, and seamless integration into CI/CD pipelines. |
18
51
 
19
- # Launch the interactive dashboard
20
- kramscan
52
+ <br />
53
+
54
+ ---
55
+
56
+ <br />
57
+
58
+ ## ๐Ÿ—๏ธ Architecture & Workflow
59
+
60
+ ```mermaid
61
+ graph LR
62
+ A[User Command] --> B{CLI Controller};
63
+ B --> C[Scanner Module<br/>Puppeteer / Cheerio];
64
+ B --> D[AI Agent<br/>NLP Processing];
65
+
66
+ C --> E[Vulnerability Detection<br/>XSS / SQLi / Headers];
67
+ C --> F[Data Aggregation];
68
+
69
+ E & F --> G[AI Analysis Engine<br/>LLM Provider];
70
+
71
+ G --> H[Risk Assessment<br/>Confidence Scoring];
72
+ H --> I[Report Generator<br/>DOCX / JSON / TXT];
73
+ I --> J((Final Output));
21
74
  ```
22
75
 
76
+ <br />
77
+
23
78
  ---
24
79
 
25
- ## Commands
80
+ <br />
81
+
82
+ ## ๐Ÿงช Tech Stack
83
+ <div align="center">
84
+
85
+ | Component | Technology |
86
+ | :--- | :--- |
87
+ | **Runtime** | Node.js โ‰ฅ 18 |
88
+ | **Language** | TypeScript 5.4 |
89
+ | **CLI Framework** | Commander.js, Inquirer.js |
90
+ | **Browser Automation** | Puppeteer (Headless Chrome) |
91
+ | **AI Integration** | OpenAI SDK, Google Generative AI, Anthropic SDK |
92
+ | **Reporting** | Docx, Chalk|
93
+ | **Package Manager** | NPM / Yarn / PNPM |
94
+
95
+ </div>
26
96
 
27
- | Command | Description | Status |
28
- |:-------------------|:-------------------------------------|:-------------|
29
- | `kramscan` | Launch interactive dashboard | โœ… Active |
30
- | `kramscan onboard` | First-time setup wizard | โœ… Active |
31
- | `kramscan scan` | Scan a target URL | ๐Ÿ”œ Coming |
32
- | `kramscan analyze` | AI-powered analysis of scan results | ๐Ÿ”œ Coming |
33
- | `kramscan report` | Generate a professional report | ๐Ÿ”œ Coming |
34
- | `kramscan doctor` | Check environment health | ๐Ÿ”œ Coming |
35
- | `kramscan --help` | Show all available commands | โœ… Active |
97
+ <br />
36
98
 
37
99
  ---
38
100
 
39
- ## Setup Wizard
101
+ <br />
40
102
 
41
- Run `kramscan onboard` to configure:
103
+ ## ๐Ÿง  Supported AI Providers
42
104
 
43
- 1. **AI Provider** โ€” OpenAI or Anthropic
44
- 2. **API Key** โ€” Your provider API key
45
- 3. **Default Model** โ€” e.g. `gpt-4`
46
- 4. **Report Format** โ€” Word, TXT, or JSON
47
- 5. **Scope Enforcement** โ€” Strict mode on/off
48
- 6. **Rate Limiting** โ€” Requests per second
105
+ | Provider | SDK / Integration | Default Model |
106
+ | :--- | :--- | :--- |
107
+ | **OpenAI** | `openai` | `gpt-4` |
108
+ | **Anthropic** | `@anthropic-ai/sdk` | `claude-3-5-sonnet-20241022` |
109
+ | **Google Gemini** | `@google/generative-ai` | `gemini-2.0-flash-exp` |
110
+ | **Mistral** | `@mistralai/mistralai` | `mistral-large-latest` |
111
+ | **OpenRouter** | OpenAI-compatible | `anthropic/claude-3.5-sonnet` |
112
+ | **Kimi** | OpenAI-compatible | `moonshot-v1-8k` |
49
113
 
50
- Configuration is saved to `~/.kramscan/config.json`.
114
+ > Switch providers instantly with `kramscan onboard` or by editing `~/.kramscan/config.json`.
115
+
116
+ <br />
51
117
 
52
118
  ---
53
119
 
54
- ## Development
120
+ <br />
121
+
122
+ ## ๐Ÿš€ Quick Start
123
+
124
+ ### 1. Installation
125
+ Install KramScan globally using npm:
126
+
127
+ ```bash
128
+ npm install -g kramscan
129
+ ```
130
+
131
+ ### 2. First-Time Setup
132
+ Initialize the configuration wizard to set up your AI provider and API keys:
55
133
 
56
134
  ```bash
57
- # Run without building (using tsx)
58
- npx tsx src/index.ts
135
+ kramscan onboard
136
+ ```
59
137
 
60
- # Run a specific command
61
- npx tsx src/index.ts onboard
138
+ ### 3. Run a Scan
139
+ Execute a full security scan on a target URL:
62
140
 
63
- # Build
64
- npm run build
141
+ ```bash
142
+ kramscan scan https://example.com
143
+ ```
144
+
145
+ <br />
146
+
147
+ ---
148
+
149
+ <br />
150
+
151
+ ## ๐Ÿ“– Usage & Commands
152
+
153
+ | Command | Description | Status |
154
+ | :--- | :--- | :---: |
155
+ | `kramscan` | Launch the interactive dashboard menu. | โœ… Stable |
156
+ | `kramscan scan <url>` | Run a comprehensive vulnerability scan. | โœ… Stable |
157
+ | `kramscan agent` | Start the conversational AI security assistant. | โœ… Stable |
158
+ | `kramscan analyze` | Analyze previous scan results using the configured AI. | โœ… Stable |
159
+ | `kramscan report` | Generate a professional report from scan data. | โœ… Stable |
160
+ | `kramscan onboard` | Run the configuration and setup wizard. | โœ… Stable |
161
+ | `kramscan doctor` | Verify environment health and dependencies. | โœ… Stable |
162
+ | `kramscan config` | View and edit current configuration settings. | โœ… Stable |
163
+
164
+ <br />
165
+
166
+ ### Example Agent Session
167
+ ```bash
168
+ $ kramscan agent
169
+ > scan https://example.com
170
+
171
+ Agent: I'll perform a comprehensive security scan of https://example.com.
172
+ Checking for XSS, SQLi, and missing headers...
173
+ [Scanning...]
174
+
175
+ Agent: Scan complete! Found 2 High severity issues.
176
+ Would you like me to generate a report?
65
177
  ```
66
178
 
179
+ <br />
180
+
67
181
  ---
68
182
 
69
- ## Tech Stack
183
+ <br />
184
+
185
+ ## ๐Ÿ—บ๏ธ Roadmap
70
186
 
71
- - **TypeScript** + **Node.js**
72
- - **Commander.js** โ€” CLI framework
73
- - **Inquirer.js** โ€” Interactive prompts
74
- - **Puppeteer** โ€” Browser automation
75
- - **ConfigStore** โ€” Persistent configuration
187
+ - [x] Core vulnerability scanner (XSS, SQLi, CSRF, headers)
188
+ - [x] Multi-provider AI analysis engine
189
+ - [x] Interactive AI agent mode
190
+ - [x] Professional report generation (DOCX, TXT, JSON)
191
+ - [x] Configuration wizard & management
192
+ - [ ] Plugin system for custom scan modules
193
+ - [ ] CI/CD integration (GitHub Actions, GitLab CI)
194
+ - [ ] PDF report generation
195
+ - [ ] Web-based dashboard UI
196
+
197
+ <br />
76
198
 
77
199
  ---
78
200
 
79
- ## Author
201
+ <br />
202
+
203
+ ## ๐Ÿ”’ Security & Privacy
204
+ - **Local Execution:** All scanning logic runs locally on your machine.
205
+ - **API Key Safety:** AI provider API keys are stored securely in your local home directory and are never sent to our servers.
206
+ - **Data Privacy:** Scan data is sent only to your chosen AI provider for analysis and is not stored by KramScan.
80
207
 
81
- **Akram** โ€” *KramScan*
208
+ <br />
82
209
 
83
210
  ---
84
211
 
85
- ## License
212
+ <br />
213
+
214
+ ## ๐Ÿ‘ค Author
215
+ <div align="center">
216
+
217
+ **Akram Shaikh**
218
+
219
+ [![Website](https://img.shields.io/badge/Website-akramshaikh.me-blue?style=for-the-badge&logo=google-chrome&logoColor=white)](https://akramshaikh.me)
220
+ [![GitHub](https://img.shields.io/badge/GitHub-shaikhakramshakil-181717?style=for-the-badge&logo=github&logoColor=white)](https://github.com/shaikhakramshakil)
221
+ [![LinkedIn](https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge&logo=linkedin&logoColor=white)](https://www.linkedin.com/in/shaikhakramshakil/)
222
+
223
+ </div>
224
+
225
+ <br />
226
+
227
+ ---
228
+
229
+ <br />
230
+
231
+ ## ๐Ÿ“„ License
232
+ This project is licensed under the **MIT License** โ€” see the [LICENSE](LICENSE) file for details.
86
233
 
87
- ISC
234
+ <div align="center">
235
+ <sub>Made with โค๏ธ by Akram Shaikh</sub>
236
+ </div>
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Confirmation Prompt System
3
+ * Handles user confirmation for skill execution with detailed risk assessment
4
+ */
5
+ import { ConfirmationPrompt } from "./types";
6
+ export interface ConfirmationResult {
7
+ confirmed: boolean;
8
+ showDetails: boolean;
9
+ cancelled: boolean;
10
+ }
11
+ export declare class ConfirmationHandler {
12
+ private rl;
13
+ constructor();
14
+ /**
15
+ * Display confirmation prompt and get user response
16
+ */
17
+ prompt(confirmation: ConfirmationPrompt): Promise<ConfirmationResult>;
18
+ /**
19
+ * Quick confirmation for low-risk actions
20
+ */
21
+ quickConfirm(action: string): Promise<boolean>;
22
+ /**
23
+ * Display detailed information about the action
24
+ */
25
+ showDetails(confirmation: ConfirmationPrompt): void;
26
+ /**
27
+ * Close the readline interface
28
+ */
29
+ close(): void;
30
+ private getUserInput;
31
+ private getRiskColor;
32
+ private getDetailedDescription;
33
+ private getSafetyInfo;
34
+ }
@@ -0,0 +1,190 @@
1
+ "use strict";
2
+ /**
3
+ * Confirmation Prompt System
4
+ * Handles user confirmation for skill execution with detailed risk assessment
5
+ */
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
19
+ }) : function(o, v) {
20
+ o["default"] = v;
21
+ });
22
+ var __importStar = (this && this.__importStar) || (function () {
23
+ var ownKeys = function(o) {
24
+ ownKeys = Object.getOwnPropertyNames || function (o) {
25
+ var ar = [];
26
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
27
+ return ar;
28
+ };
29
+ return ownKeys(o);
30
+ };
31
+ return function (mod) {
32
+ if (mod && mod.__esModule) return mod;
33
+ var result = {};
34
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
35
+ __setModuleDefault(result, mod);
36
+ return result;
37
+ };
38
+ })();
39
+ var __importDefault = (this && this.__importDefault) || function (mod) {
40
+ return (mod && mod.__esModule) ? mod : { "default": mod };
41
+ };
42
+ Object.defineProperty(exports, "__esModule", { value: true });
43
+ exports.ConfirmationHandler = void 0;
44
+ const readline = __importStar(require("readline"));
45
+ const chalk_1 = __importDefault(require("chalk"));
46
+ class ConfirmationHandler {
47
+ rl;
48
+ constructor() {
49
+ this.rl = readline.createInterface({
50
+ input: process.stdin,
51
+ output: process.stdout,
52
+ });
53
+ }
54
+ /**
55
+ * Display confirmation prompt and get user response
56
+ */
57
+ async prompt(confirmation) {
58
+ console.log("");
59
+ console.log(chalk_1.default.bold.yellow("โš ๏ธ Action Requires Confirmation"));
60
+ console.log(chalk_1.default.gray("โ”€".repeat(50)));
61
+ console.log("");
62
+ // Display action details
63
+ console.log(chalk_1.default.white("Action:"), chalk_1.default.cyan(confirmation.action));
64
+ console.log(chalk_1.default.white("Description:"), confirmation.description);
65
+ console.log("");
66
+ // Display risk level with color coding
67
+ const riskColor = this.getRiskColor(confirmation.risk);
68
+ console.log(chalk_1.default.white("Risk Level:"), riskColor(confirmation.risk.toUpperCase()));
69
+ console.log(chalk_1.default.white("Estimated Time:"), confirmation.estimatedTime);
70
+ console.log("");
71
+ // Display parameters
72
+ console.log(chalk_1.default.white("Parameters:"));
73
+ Object.entries(confirmation.parameters).forEach(([key, value]) => {
74
+ const displayValue = typeof value === "object" ? JSON.stringify(value) : String(value);
75
+ console.log(` ${chalk_1.default.gray(key)}: ${chalk_1.default.white(displayValue)}`);
76
+ });
77
+ console.log("");
78
+ // Risk warnings
79
+ if (confirmation.risk === "high") {
80
+ console.log(chalk_1.default.red.bold("โš ๏ธ WARNING: This action may have significant impact."));
81
+ }
82
+ else if (confirmation.risk === "medium") {
83
+ console.log(chalk_1.default.yellow("โš ๏ธ This action will interact with external systems."));
84
+ }
85
+ console.log("");
86
+ // Get user input
87
+ return this.getUserInput();
88
+ }
89
+ /**
90
+ * Quick confirmation for low-risk actions
91
+ */
92
+ async quickConfirm(action) {
93
+ return new Promise((resolve) => {
94
+ this.rl.question(chalk_1.default.gray(`${action} [Y/n]: `), (answer) => {
95
+ const normalized = answer.trim().toLowerCase();
96
+ resolve(normalized === "" || normalized === "y" || normalized === "yes");
97
+ });
98
+ });
99
+ }
100
+ /**
101
+ * Display detailed information about the action
102
+ */
103
+ showDetails(confirmation) {
104
+ console.log("");
105
+ console.log(chalk_1.default.bold.cyan("๐Ÿ“‹ Action Details"));
106
+ console.log(chalk_1.default.gray("โ”€".repeat(50)));
107
+ console.log("");
108
+ console.log(chalk_1.default.white("What will happen:"));
109
+ console.log(chalk_1.default.gray(this.getDetailedDescription(confirmation.action)));
110
+ console.log("");
111
+ console.log(chalk_1.default.white("Safety considerations:"));
112
+ console.log(chalk_1.default.gray(this.getSafetyInfo(confirmation.risk)));
113
+ console.log("");
114
+ if (confirmation.risk === "high") {
115
+ console.log(chalk_1.default.yellow("Recommendations:"));
116
+ console.log(chalk_1.default.gray("โ€ข Ensure you have proper authorization"));
117
+ console.log(chalk_1.default.gray("โ€ข Verify the target is correct"));
118
+ console.log(chalk_1.default.gray("โ€ข Consider testing in a safe environment first"));
119
+ console.log("");
120
+ }
121
+ }
122
+ /**
123
+ * Close the readline interface
124
+ */
125
+ close() {
126
+ this.rl.close();
127
+ }
128
+ async getUserInput() {
129
+ return new Promise((resolve) => {
130
+ const askQuestion = () => {
131
+ this.rl.question(chalk_1.default.gray("Proceed? [Y/n/details/cancel]: "), (answer) => {
132
+ const normalized = answer.trim().toLowerCase();
133
+ if (normalized === "" || normalized === "y" || normalized === "yes") {
134
+ resolve({ confirmed: true, showDetails: false, cancelled: false });
135
+ }
136
+ else if (normalized === "n" || normalized === "no") {
137
+ resolve({ confirmed: false, showDetails: false, cancelled: false });
138
+ }
139
+ else if (normalized === "details" || normalized === "d") {
140
+ resolve({ confirmed: false, showDetails: true, cancelled: false });
141
+ }
142
+ else if (normalized === "cancel" || normalized === "c") {
143
+ resolve({ confirmed: false, showDetails: false, cancelled: true });
144
+ }
145
+ else {
146
+ console.log(chalk_1.default.gray("Please enter: Y, n, details, or cancel"));
147
+ askQuestion();
148
+ }
149
+ });
150
+ };
151
+ askQuestion();
152
+ });
153
+ }
154
+ getRiskColor(risk) {
155
+ switch (risk) {
156
+ case "high":
157
+ return chalk_1.default.red.bold;
158
+ case "medium":
159
+ return chalk_1.default.yellow;
160
+ case "low":
161
+ return chalk_1.default.green;
162
+ default:
163
+ return chalk_1.default.gray;
164
+ }
165
+ }
166
+ getDetailedDescription(action) {
167
+ const descriptions = {
168
+ "Web Scan": "This will crawl the target website and test for common vulnerabilities including XSS, SQL injection, CSRF, and security header misconfigurations. The scan sends HTTP requests to the target.",
169
+ "Analyze Findings": "This will use AI to analyze previously discovered vulnerabilities and provide detailed remediation recommendations.",
170
+ "Generate Report": "This will create a professional security report document based on scan results.",
171
+ "Check Environment": "This will verify your system configuration, API keys, and dependencies.",
172
+ "View Configuration": "This will display your current KramScan configuration settings.",
173
+ };
174
+ return (descriptions[action] ||
175
+ "This action will execute the requested security operation.");
176
+ }
177
+ getSafetyInfo(risk) {
178
+ switch (risk) {
179
+ case "high":
180
+ return "This action may trigger security systems, generate significant network traffic, or have other notable effects. Use with caution.";
181
+ case "medium":
182
+ return "This action will make network requests to external systems. Ensure you have permission to test the target.";
183
+ case "low":
184
+ return "This is a safe, read-only operation that won't modify any external systems.";
185
+ default:
186
+ return "Please review the action details carefully before proceeding.";
187
+ }
188
+ }
189
+ }
190
+ exports.ConfirmationHandler = ConfirmationHandler;
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Conversation Context Manager
3
+ * Manages conversation history, user context, and session state
4
+ */
5
+ import { ConversationMessage, AgentContext, AgentConfig } from "./types";
6
+ export declare class ConversationContext {
7
+ private messages;
8
+ private context;
9
+ private config;
10
+ private historyFile;
11
+ constructor(config?: Partial<AgentConfig>);
12
+ private initializeContext;
13
+ /**
14
+ * Get the current agent context
15
+ */
16
+ getContext(): AgentContext;
17
+ /**
18
+ * Update the current target URL
19
+ */
20
+ setCurrentTarget(target: string): void;
21
+ /**
22
+ * Get the current target URL
23
+ */
24
+ getCurrentTarget(): string | undefined;
25
+ /**
26
+ * Store last scan results
27
+ */
28
+ setLastScanResults(results: unknown): void;
29
+ /**
30
+ * Get last scan results
31
+ */
32
+ getLastScanResults(): unknown | undefined;
33
+ /**
34
+ * Add a message to the conversation
35
+ */
36
+ addMessage(role: ConversationMessage["role"], content: string, toolCalls?: any[], toolCallResults?: any[]): ConversationMessage;
37
+ /**
38
+ * Get all conversation messages
39
+ */
40
+ getMessages(): ConversationMessage[];
41
+ /**
42
+ * Get recent messages (for AI context)
43
+ */
44
+ getRecentMessages(count?: number): ConversationMessage[];
45
+ /**
46
+ * Get the last message
47
+ */
48
+ getLastMessage(): ConversationMessage | undefined;
49
+ /**
50
+ * Get conversation summary for display
51
+ */
52
+ getSummary(): {
53
+ totalMessages: number;
54
+ sessionDuration: string;
55
+ currentTarget?: string;
56
+ hasScanResults: boolean;
57
+ };
58
+ /**
59
+ * Clear conversation history
60
+ */
61
+ clear(): void;
62
+ /**
63
+ * Trim history to max length
64
+ */
65
+ private trimHistory;
66
+ /**
67
+ * Persist conversation to disk
68
+ */
69
+ save(): Promise<void>;
70
+ /**
71
+ * Load conversation from disk
72
+ */
73
+ load(): Promise<boolean>;
74
+ /**
75
+ * Format messages for AI provider (OpenAI/Anthropic format)
76
+ */
77
+ formatForAI(): Array<{
78
+ role: string;
79
+ content: string;
80
+ }>;
81
+ }