devwing 0.1.16 → 0.1.17

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 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 showToolCall("read_file", "src/auth/auth_controller.ts");
2498
- await showToolResult("Read 156 lines");
2499
- await showToolCall("read_file", "src/auth/auth_routes.ts");
2500
- await showToolResult("Read 89 lines");
2501
- await showToolCall("read_file", "src/middleware/index.ts");
2502
- await showToolResult("Read 23 lines");
2503
- await showToolCall("write_file", "src/auth/repositories/user.repository.ts");
2504
- await sleep(PAUSE_LONG);
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 showToolCall("read_file", "src/auth/auth_controller.ts");
2541
- await showToolResult("Read 89 lines");
2542
- await showToolCall("read_file", "src/middleware/jwt.middleware.ts");
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 showToolCall("write_file", "src/middleware/jwt.middleware.ts");
2568
- await sleep(PAUSE_LONG);
2569
- await showToolResult("Patched \u2014 Added RS256 signing, exp/iat validation, token rotation support");
2570
- await showToolCall("write_file", "src/auth/repositories/user.repository.ts");
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 showToolCall("read_file", "Dockerfile");
2601
- await showToolResult("Read 28 lines");
2602
- await showToolCall("read_file", "docker-compose.yml");
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 showToolCall("write_file", "Dockerfile");
2617
- await sleep(PAUSE_LONG);
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 showToolCall("read_file", "src/services/user_service.ts");
2638
- await showToolResult("Read 94 lines");
2639
- await showToolCall("git_diff", "");
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 showToolCall("write_file", "src/services/user_service.ts");
2655
- await sleep(PAUSE_LONG);
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 showToolCall("read_file", "src/auth/auth_controller.ts");
2676
- await showToolResult("Read 89 lines \u2014 4 functions to test");
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 showToolCall("write_file", "tests/auth/auth_controller.test.ts");
2681
- await sleep(PAUSE_LONG);
2682
- await showToolResult("Created \u2014 8 test cases: login, register, refresh, logout, edge cases");
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,67 @@ 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
- console.log(chalk7.yellow(` \u25B6 ${chalk7.bold(tool)}`));
2723
- if (args) console.log(chalk7.gray(` ${args}`));
2724
- await sleep(PAUSE_MEDIUM);
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 readline2 = await import('readline');
2697
+ const rl = readline2.createInterface({ input: process.stdin, output: process.stdout });
2698
+ const label = tool === "write_file" ? `Write ${args}?` : tool === "run_command" ? `Run command: ${chalk7.cyan(args)}?` : tool === "git_commit" ? `Create git commit?` : tool === "delete_file" ? `Delete ${args}?` : `Execute ${tool}?`;
2699
+ const answer = await new Promise((resolve) => {
2700
+ rl.question(
2701
+ ` ${chalk7.bold.yellow("DevWing")} wants to ${chalk7.white(label)} ${chalk7.dim("(y/N) ")}`,
2702
+ (ans) => {
2703
+ rl.close();
2704
+ resolve(ans.trim().toLowerCase());
2705
+ }
2706
+ );
2707
+ });
2708
+ if (answer !== "y" && answer !== "yes") {
2709
+ console.log(chalk7.dim(" \u2717 Skipped"));
2710
+ throw Object.assign(new Error("TOOL_SKIPPED"), { skipped: true });
2711
+ }
2712
+ console.log(chalk7.dim(" \u2713 Allowed"));
2713
+ console.log();
2714
+ } else {
2715
+ console.log(chalk7.cyan(` ${icon} ${chalk7.bold(tool)}`));
2716
+ if (args) console.log(chalk7.dim(` ${args}`));
2717
+ await sleep(PAUSE_MEDIUM);
2718
+ }
2725
2719
  }
2726
2720
  async function showToolResult(result) {
2727
2721
  console.log(chalk7.green(` \u2713 ${result}`));
2728
2722
  await sleep(PAUSE_SHORT);
2729
2723
  }
2724
+ async function runTool(tool, args, result) {
2725
+ try {
2726
+ await showToolCall(tool, args);
2727
+ await sleep(tool === "write_file" || tool === "run_command" ? PAUSE_LONG : PAUSE_MEDIUM);
2728
+ await showToolResult(result);
2729
+ } catch (err) {
2730
+ if (err?.skipped) return;
2731
+ throw err;
2732
+ }
2733
+ }
2730
2734
  async function showContextLoading(fileCount, mode) {
2731
2735
  logger.startSpinner("Analyzing codebase...");
2732
2736
  await sleep(1200);
@@ -2774,7 +2778,7 @@ function getVersion() {
2774
2778
  continue;
2775
2779
  }
2776
2780
  }
2777
- return "0.1.16";
2781
+ return "0.1.17";
2778
2782
  }
2779
2783
  var DEMO_USER2 = {
2780
2784
  id: "usr_a1b2c3d4-e5f6-7890-abcd-ef1234567890",