wide-cli 0.3.101126 → 0.5.161126

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 (189) hide show
  1. package/README.md +6 -5
  2. package/dist/agent/context.d.ts.map +1 -1
  3. package/dist/agent/context.js +5 -1
  4. package/dist/agent/context.js.map +1 -1
  5. package/dist/agent/index.d.ts +33 -4
  6. package/dist/agent/index.d.ts.map +1 -1
  7. package/dist/agent/index.js +213 -79
  8. package/dist/agent/index.js.map +1 -1
  9. package/dist/completion.d.ts +13 -0
  10. package/dist/completion.d.ts.map +1 -0
  11. package/dist/completion.js +170 -0
  12. package/dist/completion.js.map +1 -0
  13. package/dist/config/index.d.ts +4 -1
  14. package/dist/config/index.d.ts.map +1 -1
  15. package/dist/config/index.js +35 -7
  16. package/dist/config/index.js.map +1 -1
  17. package/dist/config/logger.d.ts +4 -0
  18. package/dist/config/logger.d.ts.map +1 -0
  19. package/dist/config/logger.js +13 -0
  20. package/dist/config/logger.js.map +1 -0
  21. package/dist/decision/index.d.ts.map +1 -1
  22. package/dist/decision/index.js +9 -7
  23. package/dist/decision/index.js.map +1 -1
  24. package/dist/index.js +205 -40
  25. package/dist/index.js.map +1 -1
  26. package/dist/providers/claude.d.ts +2 -2
  27. package/dist/providers/claude.d.ts.map +1 -1
  28. package/dist/providers/claude.js +54 -38
  29. package/dist/providers/claude.js.map +1 -1
  30. package/dist/providers/gemini.d.ts +2 -2
  31. package/dist/providers/gemini.d.ts.map +1 -1
  32. package/dist/providers/gemini.js +50 -34
  33. package/dist/providers/gemini.js.map +1 -1
  34. package/dist/providers/index.d.ts +6 -0
  35. package/dist/providers/index.d.ts.map +1 -1
  36. package/dist/providers/index.js +26 -7
  37. package/dist/providers/index.js.map +1 -1
  38. package/dist/providers/ollama.d.ts +7 -2
  39. package/dist/providers/ollama.d.ts.map +1 -1
  40. package/dist/providers/ollama.js +90 -15
  41. package/dist/providers/ollama.js.map +1 -1
  42. package/dist/providers/openai.d.ts +2 -2
  43. package/dist/providers/openai.d.ts.map +1 -1
  44. package/dist/providers/openai.js +60 -44
  45. package/dist/providers/openai.js.map +1 -1
  46. package/dist/providers/retry.d.ts +7 -0
  47. package/dist/providers/retry.d.ts.map +1 -0
  48. package/dist/providers/retry.js +72 -0
  49. package/dist/providers/retry.js.map +1 -0
  50. package/dist/providers/types.d.ts +2 -1
  51. package/dist/providers/types.d.ts.map +1 -1
  52. package/dist/repl/commands.d.ts +18 -0
  53. package/dist/repl/commands.d.ts.map +1 -0
  54. package/dist/repl/commands.js +351 -0
  55. package/dist/repl/commands.js.map +1 -0
  56. package/dist/repl/history.d.ts +3 -0
  57. package/dist/repl/history.d.ts.map +1 -0
  58. package/dist/repl/history.js +57 -0
  59. package/dist/repl/history.js.map +1 -0
  60. package/dist/repl/index.d.ts +9 -1
  61. package/dist/repl/index.d.ts.map +1 -1
  62. package/dist/repl/index.js +326 -75
  63. package/dist/repl/index.js.map +1 -1
  64. package/dist/repl/mentions.d.ts +8 -0
  65. package/dist/repl/mentions.d.ts.map +1 -0
  66. package/dist/repl/mentions.js +100 -0
  67. package/dist/repl/mentions.js.map +1 -0
  68. package/dist/repl/sessions.d.ts +21 -0
  69. package/dist/repl/sessions.d.ts.map +1 -0
  70. package/dist/repl/sessions.js +117 -0
  71. package/dist/repl/sessions.js.map +1 -0
  72. package/dist/repl/setup.d.ts +4 -0
  73. package/dist/repl/setup.d.ts.map +1 -0
  74. package/dist/repl/setup.js +73 -0
  75. package/dist/repl/setup.js.map +1 -0
  76. package/dist/security/fuzzer.d.ts +11 -1
  77. package/dist/security/fuzzer.d.ts.map +1 -1
  78. package/dist/security/fuzzer.js +131 -60
  79. package/dist/security/fuzzer.js.map +1 -1
  80. package/dist/security/loader.d.ts +15 -1
  81. package/dist/security/loader.d.ts.map +1 -1
  82. package/dist/security/loader.js +251 -11
  83. package/dist/security/loader.js.map +1 -1
  84. package/dist/security/rules.d.ts +2 -0
  85. package/dist/security/rules.d.ts.map +1 -1
  86. package/dist/security/rules.js +108 -15
  87. package/dist/security/rules.js.map +1 -1
  88. package/dist/security/sca.d.ts +39 -0
  89. package/dist/security/sca.d.ts.map +1 -0
  90. package/dist/security/sca.js +464 -0
  91. package/dist/security/sca.js.map +1 -0
  92. package/dist/security/scanner.d.ts +19 -1
  93. package/dist/security/scanner.d.ts.map +1 -1
  94. package/dist/security/scanner.js +294 -77
  95. package/dist/security/scanner.js.map +1 -1
  96. package/dist/security/secrets.d.ts +5 -0
  97. package/dist/security/secrets.d.ts.map +1 -0
  98. package/dist/security/secrets.js +109 -0
  99. package/dist/security/secrets.js.map +1 -0
  100. package/dist/security/taint.d.ts +14 -0
  101. package/dist/security/taint.d.ts.map +1 -0
  102. package/dist/security/taint.js +517 -0
  103. package/dist/security/taint.js.map +1 -0
  104. package/dist/tools/browser.d.ts +63 -0
  105. package/dist/tools/browser.d.ts.map +1 -1
  106. package/dist/tools/browser.js +1736 -72
  107. package/dist/tools/browser.js.map +1 -1
  108. package/dist/tools/db.d.ts +106 -0
  109. package/dist/tools/db.d.ts.map +1 -0
  110. package/dist/tools/db.js +1526 -0
  111. package/dist/tools/db.js.map +1 -0
  112. package/dist/tools/fs.d.ts.map +1 -1
  113. package/dist/tools/fs.js +48 -14
  114. package/dist/tools/fs.js.map +1 -1
  115. package/dist/tools/http.d.ts.map +1 -1
  116. package/dist/tools/http.js +7 -2
  117. package/dist/tools/http.js.map +1 -1
  118. package/dist/tools/index.d.ts.map +1 -1
  119. package/dist/tools/index.js +24 -2
  120. package/dist/tools/index.js.map +1 -1
  121. package/dist/tools/risk.d.ts +9 -0
  122. package/dist/tools/risk.d.ts.map +1 -0
  123. package/dist/tools/risk.js +156 -0
  124. package/dist/tools/risk.js.map +1 -0
  125. package/dist/tools/search.d.ts.map +1 -1
  126. package/dist/tools/search.js +31 -7
  127. package/dist/tools/search.js.map +1 -1
  128. package/dist/tools/security.d.ts.map +1 -1
  129. package/dist/tools/security.js +26 -8
  130. package/dist/tools/security.js.map +1 -1
  131. package/dist/tools/shell.d.ts +8 -1
  132. package/dist/tools/shell.d.ts.map +1 -1
  133. package/dist/tools/shell.js +169 -30
  134. package/dist/tools/shell.js.map +1 -1
  135. package/dist/tools/types.d.ts +12 -0
  136. package/dist/tools/types.d.ts.map +1 -1
  137. package/dist/ui/banner.d.ts +22 -0
  138. package/dist/ui/banner.d.ts.map +1 -1
  139. package/dist/ui/banner.js +391 -11
  140. package/dist/ui/banner.js.map +1 -1
  141. package/dist/ui/diff.d.ts +13 -1
  142. package/dist/ui/diff.d.ts.map +1 -1
  143. package/dist/ui/diff.js +39 -10
  144. package/dist/ui/diff.js.map +1 -1
  145. package/dist/ui/spinner.d.ts +2 -0
  146. package/dist/ui/spinner.d.ts.map +1 -1
  147. package/dist/ui/spinner.js +22 -9
  148. package/dist/ui/spinner.js.map +1 -1
  149. package/package.json +12 -1
  150. package/.github/workflows/ci.yml +0 -29
  151. package/assets/logo.png +0 -0
  152. package/assets/wide-logo.png +0 -0
  153. package/src/agent/context.ts +0 -44
  154. package/src/agent/index.ts +0 -166
  155. package/src/config/index.ts +0 -88
  156. package/src/config/workspace.ts +0 -39
  157. package/src/decision/index.ts +0 -528
  158. package/src/index.ts +0 -180
  159. package/src/providers/claude.ts +0 -163
  160. package/src/providers/gemini.ts +0 -147
  161. package/src/providers/index.ts +0 -52
  162. package/src/providers/ollama.ts +0 -108
  163. package/src/providers/openai.ts +0 -159
  164. package/src/providers/types.ts +0 -29
  165. package/src/repl/index.ts +0 -100
  166. package/src/security/fuzzer.ts +0 -140
  167. package/src/security/loader.ts +0 -129
  168. package/src/security/payloads.ts +0 -95
  169. package/src/security/rules.ts +0 -300
  170. package/src/security/scanner.ts +0 -180
  171. package/src/tools/browser.ts +0 -528
  172. package/src/tools/fs.ts +0 -143
  173. package/src/tools/git.ts +0 -51
  174. package/src/tools/http.ts +0 -77
  175. package/src/tools/index.ts +0 -64
  176. package/src/tools/search.ts +0 -109
  177. package/src/tools/security.ts +0 -140
  178. package/src/tools/shell.ts +0 -56
  179. package/src/tools/types.ts +0 -33
  180. package/src/ui/banner.ts +0 -17
  181. package/src/ui/colors.ts +0 -19
  182. package/src/ui/diff.ts +0 -24
  183. package/src/ui/markdown.ts +0 -34
  184. package/src/ui/spinner.ts +0 -53
  185. package/tests/browser.test.mjs +0 -71
  186. package/tests/decision.test.mjs +0 -68
  187. package/tests/loader.test.mjs +0 -24
  188. package/tests/suite.test.mjs +0 -61
  189. package/tsconfig.json +0 -20
package/src/tools/git.ts DELETED
@@ -1,51 +0,0 @@
1
- import { exec } from "node:child_process";
2
- import type { Tool, ToolExecutionContext, ToolResult } from "./types.js";
3
-
4
- export const gitTool: Tool = {
5
- definition: {
6
- name: "git_inspection",
7
- description: "Inspect git repository status, diffs, or recent commit history.",
8
- parameters: {
9
- type: "object",
10
- properties: {
11
- action: {
12
- type: "string",
13
- description: "Git action to perform.",
14
- enum: ["status", "diff", "log"]
15
- },
16
- args: {
17
- type: "string",
18
- description: "Optional extra arguments for the git command."
19
- }
20
- },
21
- required: ["action"]
22
- }
23
- },
24
- async execute(params, context): Promise<ToolResult> {
25
- const action = params.action;
26
- let gitCmd = "git status --short";
27
-
28
- if (action === "diff") {
29
- gitCmd = `git diff ${params.args || ""}`;
30
- } else if (action === "log") {
31
- gitCmd = `git log -n ${params.args || "5"} --oneline`;
32
- }
33
-
34
- return new Promise((resolvePromise) => {
35
- exec(gitCmd, { cwd: context.workingDirectory }, (error, stdout, stderr) => {
36
- if (error) {
37
- resolvePromise({
38
- success: false,
39
- output: "",
40
- error: stderr || error.message
41
- });
42
- } else {
43
- resolvePromise({
44
- success: true,
45
- output: stdout || `[Empty ${action} output]`
46
- });
47
- }
48
- });
49
- });
50
- }
51
- };
package/src/tools/http.ts DELETED
@@ -1,77 +0,0 @@
1
- import type { Tool, ToolExecutionContext, ToolResult } from "./types.js";
2
-
3
- export const httpRequestTool: Tool = {
4
- definition: {
5
- name: "send_http_request",
6
- description: "Send an HTTP/HTTPS request to test an API endpoint or verify security patches.",
7
- parameters: {
8
- type: "object",
9
- properties: {
10
- url: { type: "string", description: "Target URL (must include http:// or https://)." },
11
- method: {
12
- type: "string",
13
- description: "HTTP method to use.",
14
- enum: ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD"]
15
- },
16
- headers: { type: "object", description: "Optional key-value pairs of request headers." },
17
- body: { type: "string", description: "Optional request body." },
18
- timeoutMs: { type: "number", description: "Request timeout in milliseconds (default: 15000)." }
19
- },
20
- required: ["url"]
21
- }
22
- },
23
- async execute(params, context): Promise<ToolResult> {
24
- const targetUrl = params.url;
25
- const method = (params.method || "GET").toUpperCase();
26
- const timeout = params.timeoutMs || 15000;
27
- const reqHeaders: Record<string, string> = params.headers || {};
28
-
29
- try {
30
- const controller = new AbortController();
31
- const timer = setTimeout(() => controller.abort(), timeout);
32
-
33
- const startTime = Date.now();
34
- const fetchOptions: RequestInit = {
35
- method,
36
- headers: reqHeaders,
37
- signal: controller.signal
38
- };
39
-
40
- if (params.body && method !== "GET" && method !== "HEAD") {
41
- fetchOptions.body = params.body;
42
- }
43
-
44
- const res = await fetch(targetUrl, fetchOptions);
45
- clearTimeout(timer);
46
- const durationMs = Date.now() - startTime;
47
-
48
- let resText = await res.text();
49
- if (resText.length > 8000) {
50
- resText = resText.slice(0, 8000) + "\n... [Body truncated]";
51
- }
52
-
53
- const resHeaders: string[] = [];
54
- res.headers.forEach((val, key) => {
55
- resHeaders.push(`${key}: ${val}`);
56
- });
57
-
58
- const output = [
59
- `Status: ${res.status} ${res.statusText}`,
60
- `Duration: ${durationMs}ms`,
61
- `Headers:\n${resHeaders.join("\n")}`,
62
- `Body:\n${resText || "[Empty Body]"}`
63
- ].join("\n\n");
64
-
65
- return {
66
- success: true,
67
- output
68
- };
69
- } catch (err: any) {
70
- return {
71
- success: false,
72
- output: "",
73
- error: `HTTP request failed: ${err.message}`
74
- };
75
- }
76
- }
77
- };
@@ -1,64 +0,0 @@
1
- import { readFileTool, writeFileTool, editFileTool } from "./fs.js";
2
- import { listDirTool, searchFilesTool } from "./search.js";
3
- import { runCommandTool } from "./shell.js";
4
- import { securityScanTool, fuzzEndpointTool, generatePayloadsTool } from "./security.js";
5
- import { httpRequestTool } from "./http.js";
6
- import { gitTool } from "./git.js";
7
- import {
8
- browserNavigateTool,
9
- browserClickTool,
10
- browserTypeTool,
11
- browserExtractTool,
12
- browserScreenshotTool,
13
- browserCloseTool
14
- } from "./browser.js";
15
- import type { Tool, ToolExecutionContext, ToolResult } from "./types.js";
16
-
17
- export const ALL_TOOLS: Record<string, Tool> = {
18
- read_file: readFileTool,
19
- write_file: writeFileTool,
20
- edit_file: editFileTool,
21
- list_dir: listDirTool,
22
- search_files: searchFilesTool,
23
- run_command: runCommandTool,
24
- run_security_scan: securityScanTool,
25
- fuzz_endpoint: fuzzEndpointTool,
26
- generate_payloads: generatePayloadsTool,
27
- send_http_request: httpRequestTool,
28
- git_inspection: gitTool,
29
- browser_navigate: browserNavigateTool,
30
- browser_click: browserClickTool,
31
- browser_type: browserTypeTool,
32
- browser_extract: browserExtractTool,
33
- browser_screenshot: browserScreenshotTool,
34
- browser_close: browserCloseTool,
35
- };
36
-
37
- export async function executeTool(
38
- toolName: string,
39
- params: Record<string, any>,
40
- context: ToolExecutionContext
41
- ): Promise<ToolResult> {
42
- const tool = ALL_TOOLS[toolName];
43
- if (!tool) {
44
- return {
45
- success: false,
46
- output: "",
47
- error: `Unknown tool: '${toolName}'. Available tools: ${Object.keys(ALL_TOOLS).join(", ")}`
48
- };
49
- }
50
-
51
- try {
52
- return await tool.execute(params, context);
53
- } catch (err: any) {
54
- return {
55
- success: false,
56
- output: "",
57
- error: `Error executing ${toolName}: ${err.message}`
58
- };
59
- }
60
- }
61
-
62
- export function getToolDefinitions() {
63
- return Object.values(ALL_TOOLS).map(t => t.definition);
64
- }
@@ -1,109 +0,0 @@
1
- import fg from "fast-glob";
2
- import { readdirSync, statSync, readFileSync } from "node:fs";
3
- import { resolve, relative, join } from "node:path";
4
- import type { Tool, ToolExecutionContext, ToolResult } from "./types.js";
5
-
6
- export const listDirTool: Tool = {
7
- definition: {
8
- name: "list_dir",
9
- description: "List files and directories in a given folder with file sizes.",
10
- parameters: {
11
- type: "object",
12
- properties: {
13
- path: { type: "string", description: "Folder path relative to current workspace. Defaults to '.'" },
14
- maxDepth: { type: "number", description: "Maximum recursion depth (default: 1)." }
15
- },
16
- required: []
17
- }
18
- },
19
- async execute(params, context): Promise<ToolResult> {
20
- try {
21
- const targetPath = resolve(context.workingDirectory, params.path || ".");
22
- const maxDepth = params.maxDepth || 1;
23
-
24
- const entries: string[] = [];
25
- const traverse = (dir: string, currentDepth: number) => {
26
- if (currentDepth > maxDepth) return;
27
- const items = readdirSync(dir, { withFileTypes: true });
28
- for (const item of items) {
29
- if (["node_modules", ".git", "dist", "build", ".next", ".cache"].includes(item.name)) continue;
30
- const full = join(dir, item.name);
31
- const rel = relative(targetPath, full);
32
- if (item.isDirectory()) {
33
- entries.push(`[DIR] ${rel}/`);
34
- traverse(full, currentDepth + 1);
35
- } else {
36
- const size = statSync(full).size;
37
- entries.push(`[FILE] ${rel} (${size} B)`);
38
- }
39
- }
40
- };
41
-
42
- traverse(targetPath, 1);
43
- return {
44
- success: true,
45
- output: entries.slice(0, 200).join("\n") + (entries.length > 200 ? `\n... (${entries.length - 200} more items)` : "")
46
- };
47
- } catch (err: any) {
48
- return { success: false, output: "", error: err.message };
49
- }
50
- }
51
- };
52
-
53
- export const searchFilesTool: Tool = {
54
- definition: {
55
- name: "search_files",
56
- description: "Search for a regex or string pattern inside files matching an optional glob pattern.",
57
- parameters: {
58
- type: "object",
59
- properties: {
60
- pattern: { type: "string", description: "Text or regex pattern to search for." },
61
- glob: { type: "string", description: "File glob filter (e.g. '**/*.ts', 'src/**/*.js'). Default: '**/*'" }
62
- },
63
- required: ["pattern"]
64
- }
65
- },
66
- async execute(params, context): Promise<ToolResult> {
67
- try {
68
- const globPattern = params.glob || "**/*";
69
- const files = await fg(globPattern, {
70
- cwd: context.workingDirectory,
71
- ignore: ["**/node_modules/**", "**/.git/**", "**/dist/**", "**/build/**"],
72
- onlyFiles: true,
73
- dot: false
74
- });
75
-
76
- const regex = new RegExp(params.pattern, "i");
77
- const matches: string[] = [];
78
- let totalMatches = 0;
79
-
80
- for (const file of files) {
81
- if (totalMatches >= 100) break;
82
- const full = resolve(context.workingDirectory, file);
83
- try {
84
- const content = readFileSync(full, "utf8");
85
- const lines = content.split("\n");
86
- for (let i = 0; i < lines.length; i++) {
87
- if (regex.test(lines[i])) {
88
- matches.push(`${file}:${i + 1}: ${lines[i].trim()}`);
89
- totalMatches++;
90
- if (totalMatches >= 100) break;
91
- }
92
- }
93
- } catch {
94
- }
95
- }
96
-
97
- if (matches.length === 0) {
98
- return { success: true, output: `No matches found for "${params.pattern}".` };
99
- }
100
-
101
- return {
102
- success: true,
103
- output: `Found ${matches.length} matches:\n\n${matches.join("\n")}`
104
- };
105
- } catch (err: any) {
106
- return { success: false, output: "", error: err.message };
107
- }
108
- }
109
- };
@@ -1,140 +0,0 @@
1
- import { SecurityScanner, type Finding } from "../security/scanner.js";
2
- import { fuzzTargetEndpoint } from "../security/fuzzer.js";
3
- import { getPayloadsForType, getAllPayloadTypes } from "../security/payloads.js";
4
- import type { Tool, ToolExecutionContext, ToolResult } from "./types.js";
5
-
6
- export const securityScanTool: Tool = {
7
- definition: {
8
- name: "run_security_scan",
9
- description: "Scan workspace code for security vulnerabilities, secrets, and injection flaws using Wide's native SAST engine.",
10
- parameters: {
11
- type: "object",
12
- properties: {
13
- path: { type: "string", description: "Target subdirectory or file to scan (default: entire workspace '.')." },
14
- rulesPath: { type: "string", description: "Optional path to custom rules.json file." },
15
- severityFilter: {
16
- type: "string",
17
- description: "Minimum severity to report: 'ALL', 'MEDIUM', 'HIGH', or 'CRITICAL'.",
18
- enum: ["ALL", "LOW", "MEDIUM", "HIGH", "CRITICAL"]
19
- }
20
- },
21
- required: []
22
- }
23
- },
24
- async execute(params, context): Promise<ToolResult> {
25
- try {
26
- const scanner = new SecurityScanner(context.workingDirectory, params.rulesPath);
27
- const filter = (params.severityFilter || "ALL") as Finding["severity"] | "ALL";
28
- const result = await scanner.scanPath(params.path || ".", filter);
29
- const report = scanner.formatCliReport(result);
30
-
31
- return {
32
- success: true,
33
- output: report
34
- };
35
- } catch (err: any) {
36
- return {
37
- success: false,
38
- output: "",
39
- error: `Security scan failed: ${err.message}`
40
- };
41
- }
42
- }
43
- };
44
-
45
- export const fuzzEndpointTool: Tool = {
46
- definition: {
47
- name: "fuzz_endpoint",
48
- description: "Actively probe a web API endpoint parameter with security payloads to detect or verify vulnerabilities.",
49
- parameters: {
50
- type: "object",
51
- properties: {
52
- url: { type: "string", description: "Target endpoint URL." },
53
- param: { type: "string", description: "Query or body parameter to fuzz." },
54
- payloadType: {
55
- type: "string",
56
- description: "Category of payloads to inject.",
57
- enum: ["sqli", "xss", "ssrf", "traversal", "cmd", "ssti"]
58
- },
59
- method: {
60
- type: "string",
61
- description: "HTTP method: 'GET' or 'POST' (default: 'GET').",
62
- enum: ["GET", "POST"]
63
- }
64
- },
65
- required: ["url", "param", "payloadType"]
66
- }
67
- },
68
- async execute(params, context): Promise<ToolResult> {
69
- try {
70
- const report = await fuzzTargetEndpoint(
71
- params.url,
72
- params.param,
73
- params.payloadType,
74
- params.method || "GET"
75
- );
76
-
77
- const lines: string[] = [
78
- `Fuzzing Target: ${report.url}`,
79
- `Tested Parameter: ${report.param}`,
80
- `Payload Type: ${report.payloadType.toUpperCase()}`,
81
- `Baseline HTTP: ${report.baselineStatus} (${report.baselineLength} bytes)`,
82
- `Verdict: ${report.isVulnerable ? "[VULNERABLE]" : "[SAFE / NO ANOMALY]"}`,
83
- `Summary: ${report.summary}\n`
84
- ];
85
-
86
- if (report.findings.length > 0) {
87
- lines.push("Confirmed Findings:");
88
- for (const f of report.findings) {
89
- lines.push(` Payload: ${f.payload}`);
90
- lines.push(` Status: ${f.statusCode}`);
91
- lines.push(` Indicator: ${f.indicator}\n`);
92
- }
93
- }
94
-
95
- return {
96
- success: true,
97
- output: lines.join("\n")
98
- };
99
- } catch (err: any) {
100
- return {
101
- success: false,
102
- output: "",
103
- error: `Fuzzing failed: ${err.message}`
104
- };
105
- }
106
- }
107
- };
108
-
109
- export const generatePayloadsTool: Tool = {
110
- definition: {
111
- name: "generate_payloads",
112
- description: "Generate targeted security test vectors and injection strings for penetration testing.",
113
- parameters: {
114
- type: "object",
115
- properties: {
116
- type: {
117
- type: "string",
118
- description: "Payload category: 'sqli', 'xss', 'ssrf', 'traversal', 'cmd', or 'ssti'.",
119
- enum: ["sqli", "xss", "ssrf", "traversal", "cmd", "ssti"]
120
- }
121
- },
122
- required: ["type"]
123
- }
124
- },
125
- async execute(params, context): Promise<ToolResult> {
126
- const list = getPayloadsForType(params.type);
127
- if (list.length === 0) {
128
- return {
129
- success: false,
130
- output: "",
131
- error: `Unknown category '${params.type}'. Available: ${getAllPayloadTypes().join(", ")}`
132
- };
133
- }
134
-
135
- return {
136
- success: true,
137
- output: `Wide Security Payloads (${params.type.toUpperCase()}):\n\n${list.map((p, i) => `${i + 1}. ${p}`).join("\n")}`
138
- };
139
- }
140
- };
@@ -1,56 +0,0 @@
1
- import { exec } from "node:child_process";
2
- import pc from "picocolors";
3
- import type { Tool, ToolExecutionContext, ToolResult } from "./types.js";
4
-
5
- export const runCommandTool: Tool = {
6
- definition: {
7
- name: "run_command",
8
- description: "Execute a shell command in the project directory and return stdout/stderr.",
9
- parameters: {
10
- type: "object",
11
- properties: {
12
- command: { type: "string", description: "The shell command line to execute." },
13
- timeoutMs: { type: "number", description: "Optional timeout in milliseconds (default: 30000)." }
14
- },
15
- required: ["command"]
16
- }
17
- },
18
- async execute(params, context): Promise<ToolResult> {
19
- const cmd = params.command;
20
- const timeout = params.timeoutMs || 30000;
21
-
22
- if (!context.autoApproveRun) {
23
- console.log(`\n${pc.yellow("[WARN] Agent requests command execution:")} ${pc.bold(cmd)}`);
24
- }
25
-
26
- return new Promise((resolvePromise) => {
27
- exec(cmd, {
28
- cwd: context.workingDirectory,
29
- timeout,
30
- maxBuffer: 1024 * 1024 * 2
31
- }, (error, stdout, stderr) => {
32
- let out = stdout || "";
33
- let err = stderr || "";
34
-
35
- if (out.length > 8000) {
36
- out = out.slice(0, 8000) + "\n... [Output truncated]";
37
- }
38
- if (err.length > 4000) {
39
- err = err.slice(0, 4000) + "\n... [Stderr truncated]";
40
- }
41
-
42
- const combined = [
43
- out ? `Stdout:\n${out}` : "",
44
- err ? `Stderr:\n${err}` : "",
45
- error ? `Exit Code: ${error.code || 1}` : "Exit Code: 0"
46
- ].filter(Boolean).join("\n\n");
47
-
48
- resolvePromise({
49
- success: !error,
50
- output: combined,
51
- error: error ? error.message : undefined
52
- });
53
- });
54
- });
55
- }
56
- };
@@ -1,33 +0,0 @@
1
- export interface ToolDefinition {
2
- name: string;
3
- description: string;
4
- parameters: {
5
- type: "object";
6
- properties: Record<string, {
7
- type: string;
8
- description: string;
9
- enum?: string[];
10
- items?: { type: string };
11
- }>;
12
- required: string[];
13
- };
14
- }
15
-
16
- export interface ToolExecutionContext {
17
- workingDirectory: string;
18
- autoApproveRead?: boolean;
19
- autoApproveWrite?: boolean;
20
- autoApproveRun?: boolean;
21
- }
22
-
23
- export interface ToolResult {
24
- success: boolean;
25
- output: string;
26
- error?: string;
27
- truncated?: boolean;
28
- }
29
-
30
- export interface Tool {
31
- definition: ToolDefinition;
32
- execute(params: Record<string, any>, context: ToolExecutionContext): Promise<ToolResult>;
33
- }
package/src/ui/banner.ts DELETED
@@ -1,17 +0,0 @@
1
- import pc from "picocolors";
2
-
3
- export function printBanner(version = "0.3101126") {
4
- const logo = `
5
- ██╗ ██╗██╗██████╗ ███████╗ ██████╗██╗ ██╗
6
- ██║ ██║██║██╔══██╗██╔════╝ ██╔════╝██║ ██║
7
- ██║ █╗ ██║██║██║ ██║█████╗ ██║ ██║ ██║
8
- ██║███╗██║██║██║ ██║██╔══╝ ██║ ██║ ██║
9
- ╚███╔███╔╝██║██████╔╝███████╗ ╚██████╗███████╗██║
10
- ╚══╝╚══╝ ╚═╝╚═════╝ ╚══════╝ ╚═════╝╚══════╝╚═╝`;
11
-
12
- console.log(pc.cyan(logo));
13
- console.log(
14
- ` ${pc.bold(pc.white("Wide CLI"))} ${pc.dim(`v${version}`)} - ${pc.gray("Security-First Autonomous AI Agent")}`
15
- );
16
- console.log(` ${pc.dim("Type")} ${pc.cyan("/help")} ${pc.dim("for available commands or")} ${pc.cyan("exit")} ${pc.dim("to quit.")}\n`);
17
- }
package/src/ui/colors.ts DELETED
@@ -1,19 +0,0 @@
1
- import pc from "picocolors";
2
-
3
- export const colors = {
4
- primary: pc.cyan,
5
- primaryBold: (t: string) => pc.bold(pc.cyan(t)),
6
- accent: pc.magenta,
7
- accentBold: (t: string) => pc.bold(pc.magenta(t)),
8
- success: pc.green,
9
- successBold: (t: string) => pc.bold(pc.green(t)),
10
- warning: pc.yellow,
11
- warningBold: (t: string) => pc.bold(pc.yellow(t)),
12
- error: pc.red,
13
- errorBold: (t: string) => pc.bold(pc.red(t)),
14
- muted: pc.gray,
15
- bold: pc.bold,
16
- dim: pc.dim,
17
- inverse: pc.inverse,
18
- underline: pc.underline,
19
- };
package/src/ui/diff.ts DELETED
@@ -1,24 +0,0 @@
1
- import { createPatch } from "diff";
2
- import pc from "picocolors";
3
-
4
- export function formatUnifiedDiff(filePath: string, oldStr: string, newStr: string): string {
5
- const patch = createPatch(filePath, oldStr, newStr, "original", "modified", { context: 3 });
6
- const lines = patch.split("\n");
7
- const coloredLines: string[] = [];
8
-
9
- for (const line of lines) {
10
- if (line.startsWith("---") || line.startsWith("+++")) {
11
- coloredLines.push(pc.bold(pc.gray(line)));
12
- } else if (line.startsWith("@@")) {
13
- coloredLines.push(pc.cyan(line));
14
- } else if (line.startsWith("+")) {
15
- coloredLines.push(pc.green(line));
16
- } else if (line.startsWith("-")) {
17
- coloredLines.push(pc.red(line));
18
- } else {
19
- coloredLines.push(pc.gray(line));
20
- }
21
- }
22
-
23
- return coloredLines.join("\n");
24
- }
@@ -1,34 +0,0 @@
1
- import pc from "picocolors";
2
-
3
- export function formatTerminalMarkdown(text: string): string {
4
- if (!text) return "";
5
-
6
- const lines = text.split("\n");
7
- const formatted: string[] = [];
8
- let inCodeBlock = false;
9
-
10
- for (const line of lines) {
11
- if (line.startsWith("```")) {
12
- inCodeBlock = !inCodeBlock;
13
- formatted.push(pc.gray(line));
14
- continue;
15
- }
16
-
17
- if (inCodeBlock) {
18
- formatted.push(pc.green(line));
19
- continue;
20
- }
21
-
22
- if (line.startsWith("# ")) {
23
- formatted.push(pc.bold(pc.cyan(line)));
24
- } else if (line.startsWith("## ") || line.startsWith("### ")) {
25
- formatted.push(pc.bold(pc.white(line)));
26
- } else {
27
- let l = line.replace(/`([^`]+)`/g, (_, code) => pc.yellow(code));
28
- l = l.replace(/\*\*([^*]+)\*\*/g, (_, bold) => pc.bold(bold));
29
- formatted.push(l);
30
- }
31
- }
32
-
33
- return formatted.join("\n");
34
- }
package/src/ui/spinner.ts DELETED
@@ -1,53 +0,0 @@
1
- import pc from "picocolors";
2
-
3
- const SPINNER_FRAMES = ["-", "\\", "|", "/"];
4
-
5
- export class Spinner {
6
- private timer: NodeJS.Timeout | null = null;
7
- private currentFrame = 0;
8
- private message: string;
9
-
10
- constructor(message = "Thinking...") {
11
- this.message = message;
12
- }
13
-
14
- public start(message?: string): this {
15
- if (message) this.message = message;
16
- if (this.timer) return this;
17
-
18
- process.stdout.write("\x1B[?25l");
19
- this.timer = setInterval(() => {
20
- const frame = SPINNER_FRAMES[this.currentFrame % SPINNER_FRAMES.length];
21
- process.stdout.write(`\r${pc.cyan(frame)} ${pc.dim(this.message)} `);
22
- this.currentFrame++;
23
- }, 80);
24
-
25
- return this;
26
- }
27
-
28
- public update(message: string): this {
29
- this.message = message;
30
- return this;
31
- }
32
-
33
- public stop(clear = true): void {
34
- if (this.timer) {
35
- clearInterval(this.timer);
36
- this.timer = null;
37
- }
38
- if (clear) {
39
- process.stdout.write("\r\x1B[K");
40
- }
41
- process.stdout.write("\x1B[?25h");
42
- }
43
-
44
- public succeed(message: string): void {
45
- this.stop(true);
46
- console.log(`${pc.green("[OK]")} ${message}`);
47
- }
48
-
49
- public fail(message: string): void {
50
- this.stop(true);
51
- console.log(`${pc.red("[FAIL]")} ${message}`);
52
- }
53
- }