devwing 0.1.16 → 0.1.18
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/dist/index.js +90 -87
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2494,27 +2494,14 @@ async function demoBackendRefactor() {
|
|
|
2494
2494
|
await sleep(PAUSE_MEDIUM);
|
|
2495
2495
|
await typeLine(chalk7.bold.magenta("## Executing Refactor"));
|
|
2496
2496
|
console.log();
|
|
2497
|
-
await
|
|
2498
|
-
await
|
|
2499
|
-
await
|
|
2500
|
-
await
|
|
2501
|
-
await
|
|
2502
|
-
await
|
|
2503
|
-
await
|
|
2504
|
-
await
|
|
2505
|
-
await showToolResult("Created \u2014 UserRepository with findByEmail, findById, create, updateLastLogin");
|
|
2506
|
-
await showToolCall("write_file", "src/middleware/jwt.middleware.ts");
|
|
2507
|
-
await sleep(PAUSE_MEDIUM);
|
|
2508
|
-
await showToolResult("Created \u2014 JWT validation middleware with token extraction and verification");
|
|
2509
|
-
await showToolCall("write_file", "src/middleware/rate-limiter.ts");
|
|
2510
|
-
await sleep(PAUSE_MEDIUM);
|
|
2511
|
-
await showToolResult("Created \u2014 Sliding window rate limiter: 10 req/min login, 5 req/min register");
|
|
2512
|
-
await showToolCall("write_file", "src/auth/auth_controller.ts");
|
|
2513
|
-
await sleep(PAUSE_LONG);
|
|
2514
|
-
await showToolResult("Refactored \u2014 156 lines \u2192 89 lines, clean separation of concerns");
|
|
2515
|
-
await showToolCall("run_command", "npm test -- --filter auth");
|
|
2516
|
-
await sleep(2e3);
|
|
2517
|
-
await showToolResult("All 12 tests passed");
|
|
2497
|
+
await runTool("read_file", "src/auth/auth_controller.ts", "Read 156 lines");
|
|
2498
|
+
await runTool("read_file", "src/auth/auth_routes.ts", "Read 89 lines");
|
|
2499
|
+
await runTool("read_file", "src/middleware/index.ts", "Read 23 lines");
|
|
2500
|
+
await runTool("write_file", "src/auth/repositories/user.repository.ts", "Created \u2014 UserRepository with findByEmail, findById, create, updateLastLogin");
|
|
2501
|
+
await runTool("write_file", "src/middleware/jwt.middleware.ts", "Created \u2014 JWT validation middleware with token extraction and verification");
|
|
2502
|
+
await runTool("write_file", "src/middleware/rate-limiter.ts", "Created \u2014 Sliding window rate limiter: 10 req/min login, 5 req/min register");
|
|
2503
|
+
await runTool("write_file", "src/auth/auth_controller.ts", "Refactored \u2014 156 lines \u2192 89 lines, clean separation of concerns");
|
|
2504
|
+
await runTool("run_command", "npm test -- --filter auth", "All 12 tests passed");
|
|
2518
2505
|
console.log();
|
|
2519
2506
|
await sleep(PAUSE_MEDIUM);
|
|
2520
2507
|
await typeLine(chalk7.bold.magenta("## Summary"));
|
|
@@ -2537,12 +2524,9 @@ async function demoSecurityScan() {
|
|
|
2537
2524
|
console.log();
|
|
2538
2525
|
await typeLine(chalk7.bold.magenta("## OWASP Security Scan \u2014 Auth Service"));
|
|
2539
2526
|
console.log();
|
|
2540
|
-
await
|
|
2541
|
-
await
|
|
2542
|
-
await
|
|
2543
|
-
await showToolResult("Read 34 lines");
|
|
2544
|
-
await showToolCall("read_file", "src/auth/repositories/user.repository.ts");
|
|
2545
|
-
await showToolResult("Read 52 lines");
|
|
2527
|
+
await runTool("read_file", "src/auth/auth_controller.ts", "Read 89 lines");
|
|
2528
|
+
await runTool("read_file", "src/middleware/jwt.middleware.ts", "Read 34 lines");
|
|
2529
|
+
await runTool("read_file", "src/auth/repositories/user.repository.ts", "Read 52 lines");
|
|
2546
2530
|
await sleep(PAUSE_LONG);
|
|
2547
2531
|
await typeLine(chalk7.bold.red("## Vulnerabilities Found: 3"));
|
|
2548
2532
|
console.log();
|
|
@@ -2564,18 +2548,10 @@ async function demoSecurityScan() {
|
|
|
2564
2548
|
await sleep(PAUSE_MEDIUM);
|
|
2565
2549
|
await typeLine(chalk7.bold.magenta("## Applying Security Patches"));
|
|
2566
2550
|
console.log();
|
|
2567
|
-
await
|
|
2568
|
-
await
|
|
2569
|
-
await
|
|
2570
|
-
await
|
|
2571
|
-
await sleep(PAUSE_MEDIUM);
|
|
2572
|
-
await showToolResult("Patched \u2014 Parameterized queries, input sanitization added");
|
|
2573
|
-
await showToolCall("write_file", "src/auth/validators/password.validator.ts");
|
|
2574
|
-
await sleep(PAUSE_MEDIUM);
|
|
2575
|
-
await showToolResult("Created \u2014 Min 12 chars, uppercase, number, special char, breach check");
|
|
2576
|
-
await showToolCall("run_command", "npm test -- --filter auth");
|
|
2577
|
-
await sleep(1500);
|
|
2578
|
-
await showToolResult("All 15 tests passed (3 new security tests added)");
|
|
2551
|
+
await runTool("write_file", "src/middleware/jwt.middleware.ts", "Patched \u2014 Added RS256 signing, exp/iat validation, token rotation support");
|
|
2552
|
+
await runTool("write_file", "src/auth/repositories/user.repository.ts", "Patched \u2014 Parameterized queries, input sanitization added");
|
|
2553
|
+
await runTool("write_file", "src/auth/validators/password.validator.ts", "Created \u2014 Min 12 chars, uppercase, number, special char, breach check");
|
|
2554
|
+
await runTool("run_command", "npm test -- --filter auth", "All 15 tests passed (3 new security tests added)");
|
|
2579
2555
|
console.log();
|
|
2580
2556
|
await typeLine(chalk7.bold.magenta("## Scan Complete"));
|
|
2581
2557
|
console.log();
|
|
@@ -2597,12 +2573,9 @@ async function demoDeployAssist(_prompt) {
|
|
|
2597
2573
|
console.log();
|
|
2598
2574
|
await typeLine(chalk7.bold.magenta("## Deployment Analysis"));
|
|
2599
2575
|
console.log();
|
|
2600
|
-
await
|
|
2601
|
-
await
|
|
2602
|
-
await
|
|
2603
|
-
await showToolResult("Read 45 lines");
|
|
2604
|
-
await showToolCall("read_file", ".github/workflows/deploy.yml");
|
|
2605
|
-
await showToolResult("Read 67 lines");
|
|
2576
|
+
await runTool("read_file", "Dockerfile", "Read 28 lines");
|
|
2577
|
+
await runTool("read_file", "docker-compose.yml", "Read 45 lines");
|
|
2578
|
+
await runTool("read_file", ".github/workflows/deploy.yml", "Read 67 lines");
|
|
2606
2579
|
await sleep(PAUSE_MEDIUM);
|
|
2607
2580
|
await typeLine("Current deployment configuration:");
|
|
2608
2581
|
console.log();
|
|
@@ -2613,12 +2586,8 @@ async function demoDeployAssist(_prompt) {
|
|
|
2613
2586
|
console.log();
|
|
2614
2587
|
await typeLine(chalk7.bold.magenta("## Optimizations Applied"));
|
|
2615
2588
|
console.log();
|
|
2616
|
-
await
|
|
2617
|
-
await
|
|
2618
|
-
await showToolResult("Optimized \u2014 Added layer caching, reduced image size from 340MB to 89MB");
|
|
2619
|
-
await showToolCall("write_file", "docker-compose.yml");
|
|
2620
|
-
await sleep(PAUSE_MEDIUM);
|
|
2621
|
-
await showToolResult("Added health checks, restart policies, resource limits");
|
|
2589
|
+
await runTool("write_file", "Dockerfile", "Optimized \u2014 Added layer caching, reduced image size from 340MB to 89MB");
|
|
2590
|
+
await runTool("write_file", "docker-compose.yml", "Added health checks, restart policies, resource limits");
|
|
2622
2591
|
console.log();
|
|
2623
2592
|
await typeLine(chalk7.green("\u2713") + " Docker image optimized: 340MB \u2192 89MB (74% smaller)");
|
|
2624
2593
|
await typeLine(chalk7.green("\u2713") + " Added proper health checks and restart policies");
|
|
@@ -2634,12 +2603,9 @@ async function demoBugFix(_prompt) {
|
|
|
2634
2603
|
console.log();
|
|
2635
2604
|
await typeLine(chalk7.bold.magenta("## Bug Analysis"));
|
|
2636
2605
|
console.log();
|
|
2637
|
-
await
|
|
2638
|
-
await
|
|
2639
|
-
await
|
|
2640
|
-
await showToolResult("3 files changed, 12 insertions, 4 deletions");
|
|
2641
|
-
await showToolCall("git_log", "last 5 commits");
|
|
2642
|
-
await showToolResult("Loaded recent history");
|
|
2606
|
+
await runTool("read_file", "src/services/user_service.ts", "Read 94 lines");
|
|
2607
|
+
await runTool("git_diff", "", "3 files changed, 12 insertions, 4 deletions");
|
|
2608
|
+
await runTool("git_log", "last 5 commits", "Loaded recent history");
|
|
2643
2609
|
await sleep(PAUSE_MEDIUM);
|
|
2644
2610
|
await typeLine("I found the issue. The bug is in " + chalk7.cyan("user_service.ts:67") + ":");
|
|
2645
2611
|
console.log();
|
|
@@ -2651,12 +2617,8 @@ async function demoBugFix(_prompt) {
|
|
|
2651
2617
|
await typeLine(" 1. SQL injection vulnerability");
|
|
2652
2618
|
await typeLine(" 2. Query failure when ID contains special characters");
|
|
2653
2619
|
console.log();
|
|
2654
|
-
await
|
|
2655
|
-
await
|
|
2656
|
-
await showToolResult("Fixed \u2014 Parameterized query binding");
|
|
2657
|
-
await showToolCall("run_command", "npm test -- --filter user");
|
|
2658
|
-
await sleep(1500);
|
|
2659
|
-
await showToolResult("All 8 tests passed");
|
|
2620
|
+
await runTool("write_file", "src/services/user_service.ts", "Fixed \u2014 Parameterized query binding");
|
|
2621
|
+
await runTool("run_command", "npm test -- --filter user", "All 8 tests passed");
|
|
2660
2622
|
console.log();
|
|
2661
2623
|
await typeLine(chalk7.green("\u2713") + " Bug fixed \u2014 parameterized SQL query");
|
|
2662
2624
|
await typeLine(chalk7.green("\u2713") + " SQL injection vulnerability closed");
|
|
@@ -2672,20 +2634,12 @@ async function demoWriteTests(_prompt) {
|
|
|
2672
2634
|
console.log();
|
|
2673
2635
|
await typeLine(chalk7.bold.magenta("## Generating Tests"));
|
|
2674
2636
|
console.log();
|
|
2675
|
-
await
|
|
2676
|
-
await
|
|
2677
|
-
await showToolCall("read_file", "src/auth/repositories/user.repository.ts");
|
|
2678
|
-
await showToolResult("Read 52 lines \u2014 5 methods to test");
|
|
2637
|
+
await runTool("read_file", "src/auth/auth_controller.ts", "Read 89 lines \u2014 4 functions to test");
|
|
2638
|
+
await runTool("read_file", "src/auth/repositories/user.repository.ts", "Read 52 lines \u2014 5 methods to test");
|
|
2679
2639
|
await sleep(PAUSE_MEDIUM);
|
|
2680
|
-
await
|
|
2681
|
-
await
|
|
2682
|
-
await
|
|
2683
|
-
await showToolCall("write_file", "tests/auth/user_repository.test.ts");
|
|
2684
|
-
await sleep(PAUSE_LONG);
|
|
2685
|
-
await showToolResult("Created \u2014 10 test cases: CRUD operations, error handling, constraints");
|
|
2686
|
-
await showToolCall("run_command", "npm test -- --filter auth");
|
|
2687
|
-
await sleep(2e3);
|
|
2688
|
-
await showToolResult("18 / 18 tests passed");
|
|
2640
|
+
await runTool("write_file", "tests/auth/auth_controller.test.ts", "Created \u2014 8 test cases: login, register, refresh, logout, edge cases");
|
|
2641
|
+
await runTool("write_file", "tests/auth/user_repository.test.ts", "Created \u2014 10 test cases: CRUD operations, error handling, constraints");
|
|
2642
|
+
await runTool("run_command", "npm test -- --filter auth", "18 / 18 tests passed");
|
|
2689
2643
|
console.log();
|
|
2690
2644
|
await typeLine(chalk7.bold.magenta("## Test Coverage"));
|
|
2691
2645
|
console.log();
|
|
@@ -2716,17 +2670,64 @@ async function demoGenericPrompt(prompt, options) {
|
|
|
2716
2670
|
await showUsage(1100, 620, 41e-4, mode);
|
|
2717
2671
|
logger.success("Done!");
|
|
2718
2672
|
}
|
|
2673
|
+
var DESTRUCTIVE_TOOLS = /* @__PURE__ */ new Set(["write_file", "run_command", "git_commit", "delete_file"]);
|
|
2674
|
+
var TOOL_ICONS = {
|
|
2675
|
+
read_file: "\u{1F4D6}",
|
|
2676
|
+
write_file: "\u270F\uFE0F ",
|
|
2677
|
+
delete_file: "\u{1F5D1}\uFE0F ",
|
|
2678
|
+
list_directory: "\u{1F4C2}",
|
|
2679
|
+
run_command: "\u26A1",
|
|
2680
|
+
git_diff: "\u{1F500}",
|
|
2681
|
+
git_log: "\u{1F4DC}",
|
|
2682
|
+
git_commit: "\u{1F4BE}",
|
|
2683
|
+
search_docs: "\u{1F50D}",
|
|
2684
|
+
http_request: "\u{1F310}",
|
|
2685
|
+
cve_lookup: "\u{1F512}"
|
|
2686
|
+
};
|
|
2719
2687
|
async function showToolCall(tool, args) {
|
|
2720
2688
|
await sleep(PAUSE_SHORT);
|
|
2721
2689
|
console.log();
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2690
|
+
const icon = TOOL_ICONS[tool] || "\u{1F527}";
|
|
2691
|
+
const isDestructive = DESTRUCTIVE_TOOLS.has(tool);
|
|
2692
|
+
if (isDestructive) {
|
|
2693
|
+
console.log(chalk7.yellow(` ${icon} ${chalk7.bold(tool)}`) + chalk7.dim(" \u2014 requires permission"));
|
|
2694
|
+
if (args) console.log(chalk7.dim(` ${args}`));
|
|
2695
|
+
console.log();
|
|
2696
|
+
const label = tool === "write_file" ? `Write ${args}` : tool === "run_command" ? `Run: ${args}` : tool === "git_commit" ? `Create git commit` : tool === "delete_file" ? `Delete ${args}` : `Execute ${tool}`;
|
|
2697
|
+
const { allowed } = await inquirer5.prompt([
|
|
2698
|
+
{
|
|
2699
|
+
type: "confirm",
|
|
2700
|
+
name: "allowed",
|
|
2701
|
+
message: `${chalk7.bold.yellow("DevWing")} wants to ${chalk7.white(label)}`,
|
|
2702
|
+
default: true
|
|
2703
|
+
}
|
|
2704
|
+
]);
|
|
2705
|
+
if (!allowed) {
|
|
2706
|
+
console.log(chalk7.dim(" \u2717 Skipped"));
|
|
2707
|
+
throw Object.assign(new Error("TOOL_SKIPPED"), { skipped: true });
|
|
2708
|
+
}
|
|
2709
|
+
console.log(chalk7.dim(" \u2713 Allowed"));
|
|
2710
|
+
console.log();
|
|
2711
|
+
} else {
|
|
2712
|
+
console.log(chalk7.cyan(` ${icon} ${chalk7.bold(tool)}`));
|
|
2713
|
+
if (args) console.log(chalk7.dim(` ${args}`));
|
|
2714
|
+
await sleep(PAUSE_MEDIUM);
|
|
2715
|
+
}
|
|
2725
2716
|
}
|
|
2726
2717
|
async function showToolResult(result) {
|
|
2727
2718
|
console.log(chalk7.green(` \u2713 ${result}`));
|
|
2728
2719
|
await sleep(PAUSE_SHORT);
|
|
2729
2720
|
}
|
|
2721
|
+
async function runTool(tool, args, result) {
|
|
2722
|
+
try {
|
|
2723
|
+
await showToolCall(tool, args);
|
|
2724
|
+
await sleep(tool === "write_file" || tool === "run_command" ? PAUSE_LONG : PAUSE_MEDIUM);
|
|
2725
|
+
await showToolResult(result);
|
|
2726
|
+
} catch (err) {
|
|
2727
|
+
if (err?.skipped) return;
|
|
2728
|
+
throw err;
|
|
2729
|
+
}
|
|
2730
|
+
}
|
|
2730
2731
|
async function showContextLoading(fileCount, mode) {
|
|
2731
2732
|
logger.startSpinner("Analyzing codebase...");
|
|
2732
2733
|
await sleep(1200);
|
|
@@ -2774,7 +2775,7 @@ function getVersion() {
|
|
|
2774
2775
|
continue;
|
|
2775
2776
|
}
|
|
2776
2777
|
}
|
|
2777
|
-
return "0.1.
|
|
2778
|
+
return "0.1.18";
|
|
2778
2779
|
}
|
|
2779
2780
|
var DEMO_USER2 = {
|
|
2780
2781
|
id: "usr_a1b2c3d4-e5f6-7890-abcd-ef1234567890",
|
|
@@ -3068,16 +3069,18 @@ var InteractiveSession = class {
|
|
|
3068
3069
|
}
|
|
3069
3070
|
console.log();
|
|
3070
3071
|
if (this.isDemo) {
|
|
3071
|
-
this.
|
|
3072
|
+
this.isBusy = true;
|
|
3073
|
+
this.rl.close();
|
|
3072
3074
|
try {
|
|
3073
3075
|
await demoPromptCommand(input, { ...this.options, mode: this.currentMode });
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
+
this.conversationHistory.push(
|
|
3077
|
+
{ role: "user", content: input, timestamp: /* @__PURE__ */ new Date() },
|
|
3078
|
+
{ role: "assistant", content: "[demo response]", timestamp: /* @__PURE__ */ new Date() }
|
|
3079
|
+
);
|
|
3080
|
+
} catch (error) {
|
|
3081
|
+
logger.error(error.message || "Command failed");
|
|
3076
3082
|
}
|
|
3077
|
-
this.
|
|
3078
|
-
{ role: "user", content: input, timestamp: /* @__PURE__ */ new Date() },
|
|
3079
|
-
{ role: "assistant", content: "[demo response]", timestamp: /* @__PURE__ */ new Date() }
|
|
3080
|
-
);
|
|
3083
|
+
this.recreateReadline();
|
|
3081
3084
|
return;
|
|
3082
3085
|
}
|
|
3083
3086
|
if (!this.sessionContext) {
|