opencode-swarm-plugin 0.51.0 → 0.53.0
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/bin/commands/log.test.ts +117 -0
- package/bin/commands/log.ts +362 -0
- package/bin/swarm.ts +53 -2
- package/dist/bin/swarm.js +1392 -1332
- package/dist/compaction-hook.d.ts.map +1 -1
- package/dist/examples/plugin-wrapper-template.ts +271 -23
- package/dist/index.js +130 -6
- package/dist/plugin.js +130 -6
- package/dist/swarm-insights.d.ts +54 -0
- package/dist/swarm-insights.d.ts.map +1 -1
- package/dist/swarm-prompts.js +89 -2
- package/dist/swarm-strategies.d.ts.map +1 -1
- package/examples/plugin-wrapper-template.ts +271 -23
- package/package.json +2 -2
- package/dist/tools/ubs/index.d.ts +0 -28
- package/dist/tools/ubs/index.d.ts.map +0 -1
- package/dist/tools/ubs/patterns/stub-patterns.d.ts +0 -43
- package/dist/tools/ubs/patterns/stub-patterns.d.ts.map +0 -1
- package/dist/tools/ubs/scanner.d.ts +0 -49
- package/dist/tools/ubs/scanner.d.ts.map +0 -1
- package/dist/tools/ubs/types.d.ts +0 -46
- package/dist/tools/ubs/types.d.ts.map +0 -1
|
@@ -349,43 +349,193 @@ function logCompaction(
|
|
|
349
349
|
}
|
|
350
350
|
|
|
351
351
|
/**
|
|
352
|
-
*
|
|
352
|
+
* Get date-stamped log file path
|
|
353
|
+
* Format: ~/.config/swarm-tools/logs/{type}-YYYY-MM-DD.log
|
|
354
|
+
*/
|
|
355
|
+
function getDateStampedLogPath(type: "tools" | "swarmmail" | "errors"): string {
|
|
356
|
+
const today = new Date().toISOString().split("T")[0]; // YYYY-MM-DD
|
|
357
|
+
return join(LOG_DIR, `${type}-${today}.log`);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Rotate old log files (delete files older than 7 days)
|
|
362
|
+
*
|
|
363
|
+
* Runs silently - never breaks the plugin if rotation fails.
|
|
364
|
+
*/
|
|
365
|
+
function rotateLogFiles(): void {
|
|
366
|
+
try {
|
|
367
|
+
ensureLogDir();
|
|
368
|
+
const { readdirSync, unlinkSync, statSync } = require("node:fs");
|
|
369
|
+
const files = readdirSync(LOG_DIR);
|
|
370
|
+
const now = Date.now();
|
|
371
|
+
const sevenDaysMs = 7 * 24 * 60 * 60 * 1000;
|
|
372
|
+
|
|
373
|
+
for (const file of files) {
|
|
374
|
+
// Only rotate date-stamped files (tools-*, swarmmail-*, errors-*)
|
|
375
|
+
if (!/^(tools|swarmmail|errors)-\d{4}-\d{2}-\d{2}\.log$/.test(file)) {
|
|
376
|
+
continue;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
const filePath = join(LOG_DIR, file);
|
|
380
|
+
const stats = statSync(filePath);
|
|
381
|
+
const age = now - stats.mtimeMs;
|
|
382
|
+
|
|
383
|
+
if (age > sevenDaysMs) {
|
|
384
|
+
unlinkSync(filePath);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
} catch {
|
|
388
|
+
// Silently fail - rotation failures shouldn't break the plugin
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Log a tool invocation to date-stamped file
|
|
394
|
+
*
|
|
395
|
+
* @param toolName - Tool name (e.g., "hive_create", "swarm_status")
|
|
396
|
+
* @param args - Tool arguments
|
|
397
|
+
* @param result - Tool result (optional, for successful calls)
|
|
398
|
+
* @param error - Error message (optional, for failed calls)
|
|
399
|
+
*/
|
|
400
|
+
function logTool(
|
|
401
|
+
toolName: string,
|
|
402
|
+
args: Record<string, unknown>,
|
|
403
|
+
result?: string,
|
|
404
|
+
error?: string,
|
|
405
|
+
): void {
|
|
406
|
+
try {
|
|
407
|
+
ensureLogDir();
|
|
408
|
+
rotateLogFiles(); // Rotate on every log call (cheap operation)
|
|
409
|
+
|
|
410
|
+
const logPath = getDateStampedLogPath("tools");
|
|
411
|
+
const entry = JSON.stringify({
|
|
412
|
+
time: new Date().toISOString(),
|
|
413
|
+
level: error ? "error" : "info",
|
|
414
|
+
msg: `tool_call: ${toolName}`,
|
|
415
|
+
tool: toolName,
|
|
416
|
+
args,
|
|
417
|
+
...(result && { result }),
|
|
418
|
+
...(error && { error }),
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
appendFileSync(logPath, entry + "\n");
|
|
422
|
+
} catch {
|
|
423
|
+
// Silently fail - logging should never break the plugin
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Log a Swarm Mail event to date-stamped file
|
|
353
429
|
*
|
|
354
|
-
*
|
|
355
|
-
*
|
|
430
|
+
* @param event - Event type (e.g., "message_sent", "inbox_fetched")
|
|
431
|
+
* @param data - Event data
|
|
432
|
+
*/
|
|
433
|
+
function logSwarmMail(
|
|
434
|
+
event: string,
|
|
435
|
+
data: Record<string, unknown>,
|
|
436
|
+
): void {
|
|
437
|
+
try {
|
|
438
|
+
ensureLogDir();
|
|
439
|
+
rotateLogFiles();
|
|
440
|
+
|
|
441
|
+
const logPath = getDateStampedLogPath("swarmmail");
|
|
442
|
+
const entry = JSON.stringify({
|
|
443
|
+
time: new Date().toISOString(),
|
|
444
|
+
level: "info",
|
|
445
|
+
msg: event,
|
|
446
|
+
...data,
|
|
447
|
+
});
|
|
448
|
+
|
|
449
|
+
appendFileSync(logPath, entry + "\n");
|
|
450
|
+
} catch {
|
|
451
|
+
// Silently fail
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* Log an error to date-stamped file
|
|
457
|
+
*
|
|
458
|
+
* @param error - Error message
|
|
459
|
+
* @param data - Additional error context
|
|
460
|
+
*/
|
|
461
|
+
function logError(
|
|
462
|
+
error: string,
|
|
463
|
+
data?: Record<string, unknown>,
|
|
464
|
+
): void {
|
|
465
|
+
try {
|
|
466
|
+
ensureLogDir();
|
|
467
|
+
rotateLogFiles();
|
|
468
|
+
|
|
469
|
+
const logPath = getDateStampedLogPath("errors");
|
|
470
|
+
const entry = JSON.stringify({
|
|
471
|
+
time: new Date().toISOString(),
|
|
472
|
+
level: "error",
|
|
473
|
+
msg: error,
|
|
474
|
+
...data,
|
|
475
|
+
});
|
|
476
|
+
|
|
477
|
+
appendFileSync(logPath, entry + "\n");
|
|
478
|
+
} catch {
|
|
479
|
+
// Silently fail
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* Capture compaction event for evals (INLINED - do not import from opencode-swarm-plugin)
|
|
485
|
+
*
|
|
486
|
+
* Writes COMPACTION events directly to session JSONL file.
|
|
487
|
+
* This is inlined to avoid import issues - plugin wrapper must be 100% self-contained.
|
|
488
|
+
*
|
|
489
|
+
* Matches the structure of captureCompactionEvent from eval-capture.ts but writes
|
|
490
|
+
* ONLY to JSONL (not libSQL) to avoid swarm-mail dependency.
|
|
356
491
|
*
|
|
357
492
|
* @param sessionID - Session ID
|
|
358
493
|
* @param epicID - Epic ID (or "unknown" if not detected)
|
|
359
|
-
* @param compactionType - Event type (detection_complete, prompt_generated, context_injected)
|
|
494
|
+
* @param compactionType - Event type (detection_complete, prompt_generated, context_injected, resumption_started, tool_call_tracked)
|
|
360
495
|
* @param payload - Event-specific data (full prompts, detection results, etc.)
|
|
361
496
|
*/
|
|
362
497
|
async function captureCompaction(
|
|
363
498
|
sessionID: string,
|
|
364
499
|
epicID: string,
|
|
365
|
-
compactionType: "detection_complete" | "prompt_generated" | "context_injected",
|
|
500
|
+
compactionType: "detection_complete" | "prompt_generated" | "context_injected" | "resumption_started" | "tool_call_tracked",
|
|
366
501
|
payload: any,
|
|
367
502
|
): Promise<void> {
|
|
368
503
|
try {
|
|
369
|
-
//
|
|
370
|
-
const
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
"
|
|
375
|
-
|
|
376
|
-
|
|
504
|
+
// Build the CoordinatorEvent object matching eval-capture.ts schema
|
|
505
|
+
const event = {
|
|
506
|
+
session_id: sessionID,
|
|
507
|
+
epic_id: epicID,
|
|
508
|
+
timestamp: new Date().toISOString(),
|
|
509
|
+
event_type: "COMPACTION",
|
|
510
|
+
compaction_type: compactionType,
|
|
511
|
+
payload: payload,
|
|
512
|
+
};
|
|
513
|
+
|
|
514
|
+
// Session directory: ~/.config/swarm-tools/sessions/
|
|
515
|
+
const sessionDir = process.env.SWARM_SESSIONS_DIR ||
|
|
516
|
+
join(homedir(), ".config", "swarm-tools", "sessions");
|
|
377
517
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
518
|
+
// Ensure directory exists
|
|
519
|
+
if (!existsSync(sessionDir)) {
|
|
520
|
+
mkdirSync(sessionDir, { recursive: true });
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
// Write to JSONL (append mode)
|
|
524
|
+
const sessionPath = join(sessionDir, `${sessionID}.jsonl`);
|
|
525
|
+
const line = `${JSON.stringify(event)}\n`;
|
|
526
|
+
appendFileSync(sessionPath, line, "utf-8");
|
|
527
|
+
|
|
528
|
+
logCompaction("debug", "compaction_event_captured", {
|
|
529
|
+
session_id: sessionID,
|
|
530
|
+
epic_id: epicID,
|
|
531
|
+
compaction_type: compactionType,
|
|
532
|
+
session_path: sessionPath,
|
|
381
533
|
});
|
|
382
|
-
|
|
383
|
-
// Don't wait - capture is non-blocking
|
|
384
|
-
proc.unref();
|
|
385
534
|
} catch (err) {
|
|
386
535
|
// Non-fatal - capture failures shouldn't break compaction
|
|
387
536
|
logCompaction("warn", "compaction_capture_failed", {
|
|
388
537
|
session_id: sessionID,
|
|
538
|
+
epic_id: epicID,
|
|
389
539
|
compaction_type: compactionType,
|
|
390
540
|
error: err instanceof Error ? err.message : String(err),
|
|
391
541
|
});
|
|
@@ -451,6 +601,14 @@ async function execTool(
|
|
|
451
601
|
try {
|
|
452
602
|
const result = JSON.parse(stdout);
|
|
453
603
|
if (result.success && result.data !== undefined) {
|
|
604
|
+
// Log successful tool call
|
|
605
|
+
logTool(name, args, typeof result.data === "string" ? result.data : JSON.stringify(result.data));
|
|
606
|
+
|
|
607
|
+
// Log Swarm Mail events separately
|
|
608
|
+
if (name.startsWith("swarmmail_")) {
|
|
609
|
+
logSwarmMail(`tool_${name}`, { args, result: result.data });
|
|
610
|
+
}
|
|
611
|
+
|
|
454
612
|
// Unwrap the data for cleaner tool output
|
|
455
613
|
resolve(
|
|
456
614
|
typeof result.data === "string"
|
|
@@ -463,17 +621,30 @@ async function execTool(
|
|
|
463
621
|
const errorMsg = typeof result.error === "string"
|
|
464
622
|
? result.error
|
|
465
623
|
: (result.error.message || "Tool execution failed");
|
|
624
|
+
|
|
625
|
+
// Log failed tool call
|
|
626
|
+
logTool(name, args, undefined, errorMsg);
|
|
627
|
+
logError(`Tool ${name} failed`, { args, error: errorMsg });
|
|
628
|
+
|
|
466
629
|
reject(new Error(errorMsg));
|
|
467
630
|
} else {
|
|
631
|
+
// Log successful (non-standard response)
|
|
632
|
+
logTool(name, args, stdout);
|
|
468
633
|
resolve(stdout);
|
|
469
634
|
}
|
|
470
635
|
} catch {
|
|
636
|
+
// Log successful (unparseable response)
|
|
637
|
+
logTool(name, args, stdout);
|
|
471
638
|
resolve(stdout);
|
|
472
639
|
}
|
|
473
640
|
} else if (code === 2) {
|
|
474
|
-
|
|
641
|
+
const errorMsg = `Unknown tool: ${name}`;
|
|
642
|
+
logError(errorMsg, { args });
|
|
643
|
+
reject(new Error(errorMsg));
|
|
475
644
|
} else if (code === 3) {
|
|
476
|
-
|
|
645
|
+
const errorMsg = `Invalid JSON args: ${stderr}`;
|
|
646
|
+
logError(errorMsg, { tool: name, args });
|
|
647
|
+
reject(new Error(errorMsg));
|
|
477
648
|
} else {
|
|
478
649
|
// Tool returned error
|
|
479
650
|
try {
|
|
@@ -483,15 +654,27 @@ async function execTool(
|
|
|
483
654
|
const errorMsg = typeof result.error === "string"
|
|
484
655
|
? result.error
|
|
485
656
|
: (result.error.message || `Tool failed with code ${code}`);
|
|
657
|
+
|
|
658
|
+
logTool(name, args, undefined, errorMsg);
|
|
659
|
+
logError(`Tool ${name} failed with code ${code}`, { args, error: errorMsg });
|
|
660
|
+
|
|
486
661
|
reject(new Error(errorMsg));
|
|
487
662
|
} else {
|
|
663
|
+
const errorMsg = stderr || stdout || `Tool failed with code ${code}`;
|
|
664
|
+
logTool(name, args, undefined, errorMsg);
|
|
665
|
+
logError(`Tool ${name} failed with code ${code}`, { args, stderr, stdout });
|
|
666
|
+
|
|
488
667
|
reject(
|
|
489
|
-
new Error(
|
|
668
|
+
new Error(errorMsg),
|
|
490
669
|
);
|
|
491
670
|
}
|
|
492
671
|
} catch {
|
|
672
|
+
const errorMsg = stderr || stdout || `Tool failed with code ${code}`;
|
|
673
|
+
logTool(name, args, undefined, errorMsg);
|
|
674
|
+
logError(`Tool ${name} failed with code ${code}`, { args, stderr, stdout });
|
|
675
|
+
|
|
493
676
|
reject(
|
|
494
|
-
new Error(
|
|
677
|
+
new Error(errorMsg),
|
|
495
678
|
);
|
|
496
679
|
}
|
|
497
680
|
}
|
|
@@ -669,6 +852,42 @@ const beads_link_thread = tool({
|
|
|
669
852
|
execute: (args, ctx) => execTool("beads_link_thread", args, ctx),
|
|
670
853
|
});
|
|
671
854
|
|
|
855
|
+
// =============================================================================
|
|
856
|
+
// Session Handoff Tools (Chainlink-inspired)
|
|
857
|
+
// =============================================================================
|
|
858
|
+
|
|
859
|
+
const hive_session_start = tool({
|
|
860
|
+
description: `Start a new work session with optional handoff notes from previous session.
|
|
861
|
+
|
|
862
|
+
Chainlink-inspired session management for context preservation across sessions.
|
|
863
|
+
Returns previous session's handoff notes if available.
|
|
864
|
+
|
|
865
|
+
Credit: Chainlink session handoff pattern from https://github.com/dollspace-gay/chainlink`,
|
|
866
|
+
args: {
|
|
867
|
+
active_cell_id: tool.schema
|
|
868
|
+
.string()
|
|
869
|
+
.optional()
|
|
870
|
+
.describe("ID of cell being worked on"),
|
|
871
|
+
},
|
|
872
|
+
execute: (args, ctx) => execTool("hive_session_start", args, ctx),
|
|
873
|
+
});
|
|
874
|
+
|
|
875
|
+
const hive_session_end = tool({
|
|
876
|
+
description: `End current session with handoff notes for next session.
|
|
877
|
+
|
|
878
|
+
Save context for the next agent/session to pick up where you left off.
|
|
879
|
+
Include: what was done, what's next, any blockers or gotchas.
|
|
880
|
+
|
|
881
|
+
Credit: Chainlink session handoff pattern from https://github.com/dollspace-gay/chainlink`,
|
|
882
|
+
args: {
|
|
883
|
+
handoff_notes: tool.schema
|
|
884
|
+
.string()
|
|
885
|
+
.optional()
|
|
886
|
+
.describe("Notes for next session (e.g., 'Completed X. Next: do Y. Watch out for Z.')"),
|
|
887
|
+
},
|
|
888
|
+
execute: (args, ctx) => execTool("hive_session_end", args, ctx),
|
|
889
|
+
});
|
|
890
|
+
|
|
672
891
|
// =============================================================================
|
|
673
892
|
// Swarm Mail Tools (Embedded)
|
|
674
893
|
// =============================================================================
|
|
@@ -1184,6 +1403,30 @@ const swarm_review_feedback = tool({
|
|
|
1184
1403
|
execute: (args, ctx) => execTool("swarm_review_feedback", args, ctx),
|
|
1185
1404
|
});
|
|
1186
1405
|
|
|
1406
|
+
// =============================================================================
|
|
1407
|
+
// Adversarial Review Tools (VDD/Chainlink-inspired)
|
|
1408
|
+
// =============================================================================
|
|
1409
|
+
|
|
1410
|
+
const swarm_adversarial_review = tool({
|
|
1411
|
+
description: `VDD-style adversarial code review using hostile, fresh-context agent.
|
|
1412
|
+
|
|
1413
|
+
Spawns Sarcasmotron - a hyper-critical reviewer with zero tolerance for slop.
|
|
1414
|
+
Fresh context per review prevents "relationship drift" (becoming lenient over time).
|
|
1415
|
+
|
|
1416
|
+
Returns structured critique with verdict:
|
|
1417
|
+
- APPROVED: Code is solid
|
|
1418
|
+
- NEEDS_CHANGES: Real issues found
|
|
1419
|
+
- HALLUCINATING: Adversary invented issues (code is excellent!)
|
|
1420
|
+
|
|
1421
|
+
Credit: VDD methodology from https://github.com/Vomikron/VDD
|
|
1422
|
+
Credit: Chainlink patterns from https://github.com/dollspace-gay/chainlink`,
|
|
1423
|
+
args: {
|
|
1424
|
+
diff: tool.schema.string().describe("Git diff of changes to review"),
|
|
1425
|
+
test_output: tool.schema.string().optional().describe("Test output (optional)"),
|
|
1426
|
+
},
|
|
1427
|
+
execute: (args, ctx) => execTool("swarm_adversarial_review", args, ctx),
|
|
1428
|
+
});
|
|
1429
|
+
|
|
1187
1430
|
// =============================================================================
|
|
1188
1431
|
// Skills Tools
|
|
1189
1432
|
// =============================================================================
|
|
@@ -2579,6 +2822,9 @@ const SwarmPlugin: Plugin = async (
|
|
|
2579
2822
|
hive_cells,
|
|
2580
2823
|
hive_sync,
|
|
2581
2824
|
beads_link_thread,
|
|
2825
|
+
// Session Handoff (Chainlink)
|
|
2826
|
+
hive_session_start,
|
|
2827
|
+
hive_session_end,
|
|
2582
2828
|
// Swarm Mail (Embedded)
|
|
2583
2829
|
swarmmail_init,
|
|
2584
2830
|
swarmmail_send,
|
|
@@ -2617,6 +2863,8 @@ const SwarmPlugin: Plugin = async (
|
|
|
2617
2863
|
// Structured Review
|
|
2618
2864
|
swarm_review,
|
|
2619
2865
|
swarm_review_feedback,
|
|
2866
|
+
// Adversarial Review (VDD/Chainlink)
|
|
2867
|
+
swarm_adversarial_review,
|
|
2620
2868
|
// Skills
|
|
2621
2869
|
skills_list,
|
|
2622
2870
|
skills_read,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-swarm-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.53.0",
|
|
4
4
|
"description": "Multi-agent swarm coordination for OpenCode with learning capabilities, beads integration, and Agent Mail",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"minimatch": "^10.1.1",
|
|
65
65
|
"pino": "^9.6.0",
|
|
66
66
|
"pino-roll": "^1.3.0",
|
|
67
|
-
"swarm-mail": "1.
|
|
67
|
+
"swarm-mail": "1.9.0",
|
|
68
68
|
"yaml": "^2.8.2",
|
|
69
69
|
"zod": "4.1.8"
|
|
70
70
|
},
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* UBS (Ultimate Bug Scanner)
|
|
3
|
-
*
|
|
4
|
-
* Multi-language bug scanner for catching issues before they ship.
|
|
5
|
-
* Inspired by Chainlink's post-edit-check.py stub detection.
|
|
6
|
-
*
|
|
7
|
-
* Credit: Chainlink project (https://github.com/dollspace-gay/chainlink)
|
|
8
|
-
* for the stub pattern catalog.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```typescript
|
|
12
|
-
* import { scanFile, formatFindings } from "./tools/ubs";
|
|
13
|
-
*
|
|
14
|
-
* const code = `
|
|
15
|
-
* function example() {
|
|
16
|
-
* // TODO: implement this
|
|
17
|
-
* return null;
|
|
18
|
-
* }
|
|
19
|
-
* `;
|
|
20
|
-
*
|
|
21
|
-
* const findings = scanFile(code, "example.ts");
|
|
22
|
-
* console.log(formatFindings(findings));
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
export type { Finding, ScanResult, Severity, Category } from "./types";
|
|
26
|
-
export { scanFile, scanFiles, formatFindings, type ScanConfig, } from "./scanner";
|
|
27
|
-
export { detectStubs, STUB_PATTERNS, type StubPattern } from "./patterns/stub-patterns";
|
|
28
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/ubs/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAGH,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAGvE,OAAO,EACL,QAAQ,EACR,SAAS,EACT,cAAc,EACd,KAAK,UAAU,GAChB,MAAM,WAAW,CAAC;AAGnB,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,KAAK,WAAW,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Stub Pattern Detection
|
|
3
|
-
*
|
|
4
|
-
* Detects incomplete/placeholder code patterns that AI (and humans) tend to leave behind.
|
|
5
|
-
* Inspired by Chainlink's post-edit-check.py stub detection:
|
|
6
|
-
* https://github.com/dollspace-gay/chainlink
|
|
7
|
-
*
|
|
8
|
-
* Credit: Chainlink project by @dollspace-gay for the stub pattern catalog
|
|
9
|
-
*
|
|
10
|
-
* These patterns catch "AI slop" - code that looks complete but isn't:
|
|
11
|
-
* - TODO/FIXME/XXX/HACK comments
|
|
12
|
-
* - Empty function bodies
|
|
13
|
-
* - Placeholder returns (None, null with "stub" comment)
|
|
14
|
-
* - Language-specific stub markers (pass, ..., unimplemented!(), todo!())
|
|
15
|
-
*/
|
|
16
|
-
import type { Finding } from "../types";
|
|
17
|
-
/**
|
|
18
|
-
* Pattern definition for stub detection
|
|
19
|
-
*/
|
|
20
|
-
export interface StubPattern {
|
|
21
|
-
/** Regex pattern to match */
|
|
22
|
-
pattern: RegExp;
|
|
23
|
-
/** Human-readable description */
|
|
24
|
-
description: string;
|
|
25
|
-
/** Optional suggestion for fix */
|
|
26
|
-
suggestion?: string;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Stub detection patterns adapted from Chainlink
|
|
30
|
-
*
|
|
31
|
-
* These patterns are language-agnostic where possible, but include
|
|
32
|
-
* language-specific markers for Python, Rust, JavaScript/TypeScript.
|
|
33
|
-
*/
|
|
34
|
-
export declare const STUB_PATTERNS: StubPattern[];
|
|
35
|
-
/**
|
|
36
|
-
* Detect stub patterns in code
|
|
37
|
-
*
|
|
38
|
-
* @param code - Source code to scan
|
|
39
|
-
* @param filePath - Path to file being scanned
|
|
40
|
-
* @returns Array of findings
|
|
41
|
-
*/
|
|
42
|
-
export declare function detectStubs(code: string, filePath: string): Finding[];
|
|
43
|
-
//# sourceMappingURL=stub-patterns.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stub-patterns.d.ts","sourceRoot":"","sources":["../../../../src/tools/ubs/patterns/stub-patterns.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAExC;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,6BAA6B;IAC7B,OAAO,EAAE,MAAM,CAAC;IAEhB,iCAAiC;IACjC,WAAW,EAAE,MAAM,CAAC;IAEpB,kCAAkC;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;GAKG;AACH,eAAO,MAAM,aAAa,EAAE,WAAW,EA4EtC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,EAAE,CAyBrE"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* UBS (Ultimate Bug Scanner) - Main Scanner Module
|
|
3
|
-
*
|
|
4
|
-
* Coordinates pattern detection across multiple categories.
|
|
5
|
-
* Currently supports:
|
|
6
|
-
* - Stub detection (incomplete/placeholder code)
|
|
7
|
-
*
|
|
8
|
-
* Future categories:
|
|
9
|
-
* - Null safety
|
|
10
|
-
* - Security (XSS, injection)
|
|
11
|
-
* - Async/await issues
|
|
12
|
-
* - Memory leaks
|
|
13
|
-
* - Type coercion
|
|
14
|
-
*/
|
|
15
|
-
import type { Finding, ScanResult } from "./types";
|
|
16
|
-
/**
|
|
17
|
-
* Scanner configuration
|
|
18
|
-
*/
|
|
19
|
-
export interface ScanConfig {
|
|
20
|
-
/** Categories to scan (empty = all) */
|
|
21
|
-
categories?: Array<"stub" | "null-safety" | "security">;
|
|
22
|
-
/** Minimum severity to report */
|
|
23
|
-
minSeverity?: "low" | "medium" | "high" | "critical";
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Scan a single file for issues
|
|
27
|
-
*
|
|
28
|
-
* @param code - Source code to scan
|
|
29
|
-
* @param filePath - Path to file being scanned
|
|
30
|
-
* @param config - Scanner configuration
|
|
31
|
-
* @returns Array of findings
|
|
32
|
-
*/
|
|
33
|
-
export declare function scanFile(code: string, filePath: string, config?: ScanConfig): Finding[];
|
|
34
|
-
/**
|
|
35
|
-
* Scan multiple files
|
|
36
|
-
*
|
|
37
|
-
* @param files - Map of file path to file content
|
|
38
|
-
* @param config - Scanner configuration
|
|
39
|
-
* @returns Scan result with all findings
|
|
40
|
-
*/
|
|
41
|
-
export declare function scanFiles(files: Map<string, string>, config?: ScanConfig): ScanResult;
|
|
42
|
-
/**
|
|
43
|
-
* Format findings for display
|
|
44
|
-
*
|
|
45
|
-
* @param findings - Findings to format
|
|
46
|
-
* @returns Formatted string
|
|
47
|
-
*/
|
|
48
|
-
export declare function formatFindings(findings: Finding[]): string;
|
|
49
|
-
//# sourceMappingURL=scanner.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scanner.d.ts","sourceRoot":"","sources":["../../../src/tools/ubs/scanner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEnD;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,uCAAuC;IACvC,UAAU,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,aAAa,GAAG,UAAU,CAAC,CAAC;IAExD,iCAAiC;IACjC,WAAW,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAC;CACtD;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CACtB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,MAAM,GAAE,UAAe,GACtB,OAAO,EAAE,CAwBX;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAC1B,MAAM,GAAE,UAAe,GACtB,UAAU,CAcZ;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,MAAM,CAoB1D"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* UBS (Ultimate Bug Scanner) Type Definitions
|
|
3
|
-
*
|
|
4
|
-
* Core types for bug detection and reporting.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Severity levels for findings
|
|
8
|
-
*/
|
|
9
|
-
export type Severity = "low" | "medium" | "high" | "critical";
|
|
10
|
-
/**
|
|
11
|
-
* Category of finding
|
|
12
|
-
*/
|
|
13
|
-
export type Category = "null-safety" | "security" | "async-await" | "memory-leak" | "type-coercion" | "stub" | "other";
|
|
14
|
-
/**
|
|
15
|
-
* A detected issue in code
|
|
16
|
-
*/
|
|
17
|
-
export interface Finding {
|
|
18
|
-
/** Category of the issue */
|
|
19
|
-
category: Category;
|
|
20
|
-
/** Human-readable description */
|
|
21
|
-
message: string;
|
|
22
|
-
/** File path where issue was found */
|
|
23
|
-
file: string;
|
|
24
|
-
/** Line number (1-based) */
|
|
25
|
-
line: number;
|
|
26
|
-
/** Column number (1-based), if available */
|
|
27
|
-
column?: number;
|
|
28
|
-
/** Severity of the issue */
|
|
29
|
-
severity: Severity;
|
|
30
|
-
/** Suggested fix, if available */
|
|
31
|
-
suggestion?: string;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Result of a scan operation
|
|
35
|
-
*/
|
|
36
|
-
export interface ScanResult {
|
|
37
|
-
/** All findings */
|
|
38
|
-
findings: Finding[];
|
|
39
|
-
/** Files scanned */
|
|
40
|
-
filesScanned: number;
|
|
41
|
-
/** Timestamp of scan */
|
|
42
|
-
timestamp: string;
|
|
43
|
-
/** Exit code (0 = no issues, 1 = issues found) */
|
|
44
|
-
exitCode: number;
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/tools/ubs/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAC;AAE9D;;GAEG;AACH,MAAM,MAAM,QAAQ,GAChB,aAAa,GACb,UAAU,GACV,aAAa,GACb,aAAa,GACb,eAAe,GACf,MAAM,GACN,OAAO,CAAC;AAEZ;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,4BAA4B;IAC5B,QAAQ,EAAE,QAAQ,CAAC;IAEnB,iCAAiC;IACjC,OAAO,EAAE,MAAM,CAAC;IAEhB,sCAAsC;IACtC,IAAI,EAAE,MAAM,CAAC;IAEb,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAC;IAEb,4CAA4C;IAC5C,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,4BAA4B;IAC5B,QAAQ,EAAE,QAAQ,CAAC;IAEnB,kCAAkC;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,mBAAmB;IACnB,QAAQ,EAAE,OAAO,EAAE,CAAC;IAEpB,oBAAoB;IACpB,YAAY,EAAE,MAAM,CAAC;IAErB,wBAAwB;IACxB,SAAS,EAAE,MAAM,CAAC;IAElB,kDAAkD;IAClD,QAAQ,EAAE,MAAM,CAAC;CAClB"}
|