anvil-engineering-workbench 1.0.6 → 1.0.8

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 (38) hide show
  1. package/CHANGELOG.md +47 -2
  2. package/README.md +41 -35
  3. package/SECURITY.md +54 -10
  4. package/dist/ai/claude-code-provider.js +4 -3
  5. package/dist/ai/claude-code-provider.js.map +1 -1
  6. package/dist/ai/provider.js +7 -6
  7. package/dist/ai/provider.js.map +1 -1
  8. package/dist/cli.js +273 -59
  9. package/dist/cli.js.map +1 -1
  10. package/dist/core/adr-engine.d.ts +30 -0
  11. package/dist/core/adr-engine.js +163 -0
  12. package/dist/core/adr-engine.js.map +1 -0
  13. package/dist/core/code-review.js +6 -6
  14. package/dist/core/container-sandbox.js +1 -1
  15. package/dist/core/container-sandbox.js.map +1 -1
  16. package/dist/core/dashboard-server.js +222 -14
  17. package/dist/core/dashboard-server.js.map +1 -1
  18. package/dist/core/env-compat.d.ts +11 -0
  19. package/dist/core/env-compat.js +32 -0
  20. package/dist/core/env-compat.js.map +1 -0
  21. package/dist/core/hosted-agent-provider.js +11 -6
  22. package/dist/core/hosted-agent-provider.js.map +1 -1
  23. package/dist/core/project-cleaner.d.ts +7 -0
  24. package/dist/core/project-cleaner.js +258 -19
  25. package/dist/core/project-cleaner.js.map +1 -1
  26. package/dist/core/provider-diagnostics.js +3 -3
  27. package/dist/core/provider-diagnostics.js.map +1 -1
  28. package/dist/core/sarif-formatter.d.ts +12 -0
  29. package/dist/core/sarif-formatter.js +121 -0
  30. package/dist/core/sarif-formatter.js.map +1 -0
  31. package/dist/core/security-scanner.d.ts +37 -0
  32. package/dist/core/security-scanner.js +325 -0
  33. package/dist/core/security-scanner.js.map +1 -0
  34. package/dist/core/verification.js +2 -1
  35. package/dist/core/verification.js.map +1 -1
  36. package/dist/mcp/server.js +52 -32
  37. package/dist/mcp/server.js.map +1 -1
  38. package/package.json +9 -4
@@ -31,9 +31,12 @@ import { buildExperimentHistory } from "./experiment-history.js";
31
31
  import { createReplayRun, createTaskRetryRun } from "./run-replay.js";
32
32
  import { diagnoseProvider } from "./provider-diagnostics.js";
33
33
  import { createRunFromWorkflow, listWorkflows, loadWorkflow, saveWorkflow } from "./workflow-store.js";
34
+ import { advanceRun, DemoAgentProvider } from "./orchestrator.js";
34
35
  import { cleanProject, undoLastClean } from "./project-cleaner.js";
35
36
  import { runDoctorChecks } from "./doctor.js";
36
37
  import { listProjectMemory, addProjectMemory, removeProjectMemory } from "./project-memory.js";
38
+ import { listAdrs, createAdr, syncMemoryToAdrs } from "./adr-engine.js";
39
+ import { scanProjectSecurity, applySecurityFixes } from "./security-scanner.js";
37
40
  // --- SSE broadcast state ---
38
41
  const sseClients = new Set();
39
42
  let heartbeatInterval = null;
@@ -362,13 +365,13 @@ body{
362
365
  <div class="mark">A.</div>
363
366
  <div>
364
367
  <strong>ANVIL</strong>
365
- <small>THE AI ENGINEERING WORKBENCH · v1.0.6</small>
368
+ <small>THE AI ENGINEERING WORKBENCH · v1.0.7</small>
366
369
  </div>
367
370
  </div>
368
371
  <div class="header-actions">
369
372
  <label class="showcase-pill" title="Toggle between pre-populated showcase simulation and raw local project data">
370
- <input type="checkbox" id="showcaseToggle" checked>
371
- <span>✨ Showcase Telemetry</span>
373
+ <input type="checkbox" id="showcaseToggle">
374
+ <span>✨ Showcase Telemetry (Demo)</span>
372
375
  </label>
373
376
  <button class="btn btn-cyan" id="quickDoctorBtn">⚡ Doctor Check</button>
374
377
  <button class="btn btn-primary" id="quickCleanBtn">🧹 Self-Healing Scan</button>
@@ -378,16 +381,16 @@ body{
378
381
 
379
382
  <nav class="tab-nav">
380
383
  <button class="tab-btn active" data-tab="tab-overview">📊 Overview & Health</button>
381
- <button class="tab-btn" data-tab="tab-cleaner">⚡ Self-Healing & Cleaner (v1.0.6)</button>
384
+ <button class="tab-btn" data-tab="tab-cleaner">⚡ Self-Healing & Security (v1.0.7)</button>
382
385
  <button class="tab-btn" data-tab="tab-agents">🤖 Agents & Workflow Studio</button>
383
386
  <button class="tab-btn" data-tab="tab-architecture">🗺️ Architecture & Graph</button>
384
387
  <button class="tab-btn" data-tab="tab-benchmarks">🔬 Benchmarks & Evaluation</button>
385
388
  <button class="tab-btn" data-tab="tab-workspace">🔍 Workspace & Search</button>
386
389
  </nav>
387
390
 
388
- <div id="showcaseNotice" class="showcase-banner">
391
+ <div id="showcaseNotice" class="showcase-banner" style="display:none">
389
392
  <div>
390
- <b>✨ Showcase Telemetry Mode Active:</b> <span>Displaying realistic multi-agent execution runs, benchmark matrices, token budgets, and verification trails so you can explore ANVIL without waiting to collect runs. Toggle switch above to see only raw local data.</span>
393
+ <b>⚠️ DEMO MODE — Synthetic Showcase Telemetry:</b> <span>Displaying simulated multi-agent execution runs, benchmark matrices, token budgets, and verification trails for demonstration. Toggle switch above off to view only raw local workspace data.</span>
391
394
  </div>
392
395
  </div>
393
396
 
@@ -459,6 +462,7 @@ body{
459
462
  <h2>Project Memory & Architectural Decisions</h2>
460
463
  <div class="actions">
461
464
  <span class="pill pill-cyan">CONTEXT STORE</span>
465
+ <button class="btn btn-cyan" id="syncMemoryToAdrBtn">⚡ Sync to ADRs</button>
462
466
  <button class="btn" id="refreshMemory">Refresh memory</button>
463
467
  </div>
464
468
  </div>
@@ -479,10 +483,10 @@ body{
479
483
  </section>
480
484
  </div>
481
485
 
482
- <!-- ==================== TAB 2: SELF-HEALING & CLEANER (v1.0.6) ==================== -->
486
+ <!-- ==================== TAB 2: SELF-HEALING, CLEANER & SECURITY (v1.0.7) ==================== -->
483
487
  <div id="tab-cleaner" class="tab-pane">
484
488
  <section class="hero">
485
- <div class="eyebrow">ANVIL v1.0.6 SELF-HEALING ENGINE</div>
489
+ <div class="eyebrow">ANVIL v1.0.7 SELF-HEALING & SECURITY ENGINE</div>
486
490
  <h1>Zero-Fear Workspace Cleaner & Rollback</h1>
487
491
  <p>Automatically eliminates junk clutter and fixes unused imports across TypeScript, JavaScript and Python with deterministic self-healing rollback verification.</p>
488
492
  </section>
@@ -544,6 +548,20 @@ body{
544
548
  </div>
545
549
  </div>
546
550
  </section>
551
+
552
+ <section class="section card">
553
+ <div class="section-head">
554
+ <h2>Repository Security & Secret Scanner</h2>
555
+ <div class="actions">
556
+ <span class="pill pill-emerald" id="securityStatusPill">SECURE</span>
557
+ <button class="btn btn-primary" id="autoFixSecurityBtn">🛡️ Auto-Fix Exclusions</button>
558
+ <button class="btn" id="refreshSecurityBtn">Refresh Audit</button>
559
+ </div>
560
+ </div>
561
+ <p class="run-meta">Local-first deep scan for leaked secrets, API keys, risky shell scripts, unencrypted dependencies, and unignored .env files.</p>
562
+ <div id="securitySummary" class="grid" style="margin:12px 0"></div>
563
+ <div id="securityFindings" class="list"><div class="loading">Scanning repository for secrets…</div></div>
564
+ </section>
547
565
  </div>
548
566
 
549
567
  <!-- ==================== TAB 3: AGENTS & WORKFLOW STUDIO ==================== -->
@@ -624,7 +642,7 @@ body{
624
642
  <div class="section-head"><h3 style="margin:0">Pipeline canvas</h3><span class="pill" id="workflowTaskCount">0 TASKS</span></div>
625
643
  <div id="workflowCanvas" class="activity"><div class="empty">Add a specialist task to start composing your pipeline.</div></div>
626
644
  <div class="actions"><button class="btn" id="applyWorkflowLinks">Apply selected links</button></div>
627
- <div class="actions"><button class="btn btn-primary" id="saveWorkflow">Save workflow</button><button class="btn btn-cyan" id="createWorkflowRun">Create draft run</button></div>
645
+ <div class="actions"><button class="btn btn-primary" id="saveWorkflow">Save workflow</button><button class="btn btn-cyan" id="createWorkflowRun">Create draft run</button><button class="btn btn-emerald" id="executeWorkflowRun">⚡ Simulate Pipeline Execution</button></div>
628
646
  <div id="workflowMessage" class="run-meta" aria-live="polite"></div>
629
647
  <div class="section-head" style="margin-top:18px"><h3 style="margin:0">Saved workflows</h3><button class="btn" id="refreshWorkflows">Refresh</button></div>
630
648
  <div id="savedWorkflows" class="activity"><div class="loading">Loading reusable workflows…</div></div>
@@ -779,6 +797,27 @@ body{
779
797
  <div id="timelineHistory" class="activity"></div>
780
798
  <div id="timelineNotes" class="run-meta"></div>
781
799
  </section>
800
+
801
+ <section class="section card">
802
+ <div class="section-head">
803
+ <h2>Architecture Decision Records (ADR Engine)</h2>
804
+ <div class="actions">
805
+ <span class="pill pill-cyan">DOCS/ADR</span>
806
+ <button class="btn btn-cyan" id="syncAdrBtn">⚡ Sync Memory to ADRs</button>
807
+ <button class="btn" id="refreshAdrBtn">Refresh ADRs</button>
808
+ </div>
809
+ </div>
810
+ <p class="run-meta">Version-controlled Architectural Decision Records stored locally in <code>docs/adr/</code>. Kept in sync with ANVIL project memory.</p>
811
+ <div style="display:flex;gap:8px;margin:12px 0;flex-wrap:wrap">
812
+ <input type="text" id="newAdrTitle" placeholder="e.g. Adopt Vitest for Unit and Integration Testing" style="flex:1;min-width:260px;background:var(--bg-card);border:1px solid var(--border);border-radius:6px;padding:6px 12px;color:var(--text);font-family:inherit;font-size:13px">
813
+ <select id="newAdrStatus" class="btn" style="padding:6px 12px">
814
+ <option value="Accepted">Accepted</option>
815
+ <option value="Proposed">Proposed</option>
816
+ </select>
817
+ <button class="btn btn-primary" id="createAdrBtn">+ New ADR</button>
818
+ </div>
819
+ <div id="adrList" class="list"><div class="loading">Loading Architecture Decision Records…</div></div>
820
+ </section>
782
821
  </div>
783
822
 
784
823
  <!-- ==================== TAB 5: BENCHMARKS & EVALUATION LAB ==================== -->
@@ -990,7 +1029,7 @@ body{
990
1029
  </div>
991
1030
 
992
1031
  <footer class="footer">
993
- <span>ANVIL v1.0.6 · THE AI ENGINEERING WORKBENCH</span>
1032
+ <span>ANVIL v1.0.7 · THE AI ENGINEERING WORKBENCH</span>
994
1033
  <span>Read-only local dashboard · Telemetry stays on your machine</span>
995
1034
  </footer>
996
1035
 
@@ -1001,7 +1040,7 @@ const el=id=>document.getElementById(id);
1001
1040
  const on=(id,event,handler)=>{const node=el(id);if(node)node.addEventListener(event,handler);};
1002
1041
  const esc=value=>String(value??"").replace(/[&<>"']/g,c=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"}[c]));
1003
1042
 
1004
- let isShowcase = true;
1043
+ let isShowcase = false;
1005
1044
  const showcaseToggle = el("showcaseToggle");
1006
1045
  const showcaseNotice = el("showcaseNotice");
1007
1046
  if(showcaseToggle){
@@ -1544,6 +1583,90 @@ async function deleteMemoryEntry(id){
1544
1583
  }catch(e){alert("Failed to remove memory: "+e.message);}
1545
1584
  }
1546
1585
 
1586
+ async function loadAdrs(){
1587
+ try{
1588
+ const res = await api("/api/adrs");
1589
+ let adrs = res.adrs || [];
1590
+ if(!adrs.length && isShowcase){
1591
+ adrs = [
1592
+ { id: "0001", number: 1, title: "Record architecture decisions", status: "Accepted", date: new Date().toISOString().slice(0, 10), filename: "0001-record-architecture-decisions.md" },
1593
+ { id: "0002", number: 2, title: "Local-first AST analysis for zero-telemetry polyglot code intelligence", status: "Accepted", date: new Date().toISOString().slice(0, 10), filename: "0002-local-first-ast-analysis.md" },
1594
+ { id: "0003", number: 3, title: "Deterministic automated test gate with instant rollback on clean", status: "Accepted", date: new Date().toISOString().slice(0, 10), filename: "0003-deterministic-test-gate.md" }
1595
+ ];
1596
+ }
1597
+ const container = el("adrList");
1598
+ if(!container) return;
1599
+ container.innerHTML = adrs.length ? adrs.map(item => {
1600
+ const statusPill = item.status === "Accepted" ? "pill-emerald" : item.status === "Proposed" ? "pill-cyan" : "pill-accent";
1601
+ return '<div class="rowitem"><div><div style="display:flex;gap:6px;align-items:center;margin-bottom:4px"><span class="pill ' + statusPill + '">' + esc(item.status.toUpperCase()) + '</span><span class="pill" style="font-size:10px">ADR-' + esc(item.id) + '</span><span class="run-meta">' + esc(item.date) + '</span></div><div style="font-size:13px;font-weight:600">' + esc(item.title) + '</div><div class="run-meta" style="font-size:11px">' + esc(item.filename) + '</div></div></div>';
1602
+ }).join("") : '<div class="empty">No Architecture Decision Records found. Click "+ New ADR" or "Sync Memory to ADRs" to initialize docs/adr/</div>';
1603
+ }catch(e){
1604
+ const container = el("adrList");
1605
+ if(container) container.innerHTML = '<div class="error">' + esc(e.message) + '</div>';
1606
+ }
1607
+ }
1608
+
1609
+ async function handleCreateAdr(){
1610
+ const titleEl = el("newAdrTitle");
1611
+ const statusEl = el("newAdrStatus");
1612
+ const title = titleEl ? titleEl.value.trim() : "";
1613
+ if(!title) return alert("Please enter an ADR title.");
1614
+ const status = statusEl ? statusEl.value : "Accepted";
1615
+ try{
1616
+ await fetch("/api/adrs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({title,status})});
1617
+ if(titleEl) titleEl.value = "";
1618
+ loadAdrs();
1619
+ }catch(e){alert("Failed to create ADR: "+e.message);}
1620
+ }
1621
+
1622
+ async function handleSyncAdrs(){
1623
+ try{
1624
+ const res = await fetch("/api/adrs/sync",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({})});
1625
+ const data = await res.json();
1626
+ alert(data.syncedCount > 0 ? "Synced " + data.syncedCount + " decisions to docs/adr/!" : "All project memory decisions already synced!");
1627
+ loadAdrs();
1628
+ }catch(e){alert("Failed to sync ADRs: "+e.message);}
1629
+ }
1630
+
1631
+ async function loadSecurityAudit(){
1632
+ try{
1633
+ const res = await api("/api/security");
1634
+ const summaryEl = el("securitySummary");
1635
+ const findingsEl = el("securityFindings");
1636
+ const pill = el("securityStatusPill");
1637
+ if(!summaryEl || !findingsEl) return;
1638
+
1639
+ if(pill){
1640
+ if(res.passed){
1641
+ pill.className = "pill pill-emerald";
1642
+ pill.textContent = "SECURE";
1643
+ }else{
1644
+ pill.className = "pill pill-accent";
1645
+ pill.textContent = res.summary.critical > 0 ? "CRITICAL RISK" : "HIGH RISK";
1646
+ }
1647
+ }
1648
+
1649
+ summaryEl.innerHTML = '<div class="card card-highlight"><div class="metric-label">Security Status</div><div class="metric" style="color:' + (res.passed ? 'var(--emerald)' : 'var(--accent)') + '">' + (res.passed ? 'SECURE' : 'ACTION REQUIRED') + '</div><div class="metric-sub">' + res.findings.length + ' total findings</div></div><div class="card"><div class="metric-label">Critical Secrets</div><div class="metric" style="color:var(--accent)">' + res.summary.critical + '</div><div class="metric-sub">API keys, tokens, keys</div></div><div class="card"><div class="metric-label">High Severity</div><div class="metric" style="color:var(--amber,#f59e0b)">' + res.summary.high + '</div><div class="metric-sub">Scripts, unencrypted deps</div></div><div class="card"><div class="metric-label">Scanned Scope</div><div class="metric" style="color:var(--cyan)">' + res.scannedFiles + '</div><div class="metric-sub">Files in ' + res.durationMs + 'ms</div></div>';
1650
+
1651
+ findingsEl.innerHTML = res.findings.length ? res.findings.map(f => {
1652
+ const sevClass = f.severity === "critical" ? "pill-accent" : f.severity === "high" ? "pill-amber" : "pill-cyan";
1653
+ return '<div class="rowitem"><div><div style="display:flex;gap:6px;align-items:center;margin-bottom:4px"><span class="pill ' + sevClass + '">' + esc(f.severity.toUpperCase()) + '</span><span class="pill" style="font-size:10px">' + esc(f.category) + '</span><span class="run-meta">' + esc(f.file + (f.line ? ':' + f.line : '')) + '</span></div><div style="font-size:13px;font-weight:600">' + esc(f.description) + '</div>' + (f.snippet ? '<div class="run-meta" style="font-family:monospace;font-size:11px">Snippet: ' + esc(f.snippet) + '</div>' : '') + '<div class="run-meta" style="font-size:11px;color:var(--text-muted)">Remediation: ' + esc(f.remediation) + '</div></div></div>';
1654
+ }).join("") : '<div class="empty" style="color:var(--emerald)">✓ Clean audit: No hardcoded secrets, dangerous scripts, or exposed credentials detected.</div>';
1655
+ }catch(e){
1656
+ const findingsEl = el("securityFindings");
1657
+ if(findingsEl) findingsEl.innerHTML = '<div class="error">' + esc(e.message) + '</div>';
1658
+ }
1659
+ }
1660
+
1661
+ async function handleAutoFixSecurity(){
1662
+ try{
1663
+ const res = await fetch("/api/security/fix",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({})});
1664
+ const data = await res.json();
1665
+ alert(data.fixedCount > 0 ? "Applied " + data.fixedCount + " security fixes:\n" + data.details.join("\n") : "No pending auto-fixable exclusions.");
1666
+ loadSecurityAudit();
1667
+ }catch(e){alert("Failed to apply security fixes: "+e.message);}
1668
+ }
1669
+
1547
1670
  on("runCleanDryRunBtn","click",runCleanerPreview);
1548
1671
  on("quickCleanBtn","click",()=>{
1549
1672
  document.querySelectorAll(".tab-btn").forEach(b=>b.classList.remove("active"));
@@ -1763,10 +1886,31 @@ on("createWorkflowRun","click",async()=>{
1763
1886
  try{await fetch("/api/workflows/"+encodeURIComponent(id)+"/run",{method:"POST",headers:{"content-type":"application/json"},body:"{}"});el("workflowMessage").textContent="Created draft run from "+name;loadRuns();}catch(e){el("workflowMessage").textContent=e.message;}
1764
1887
  });
1765
1888
 
1889
+ async function executeWorkflowById(id){
1890
+ const msgEl = el("workflowMessage");
1891
+ if(msgEl) msgEl.innerHTML = '<span style="color:var(--cyan)">⚡ Simulating multi-agent pipeline execution (DemoAgentProvider)...</span>';
1892
+ try{
1893
+ const res = await fetch("/api/workflows/"+encodeURIComponent(id)+"/execute",{method:"POST",headers:{"content-type":"application/json"},body:"{}"});
1894
+ const run = await res.json();
1895
+ if(msgEl) msgEl.innerHTML = '<span style="color:var(--emerald)">✓ Pipeline simulated: ' + esc(run.id) + ' (' + esc(run.status) + ')</span>';
1896
+ loadRuns();
1897
+ loadActivity();
1898
+ if(run.id) inspectRun(run.id);
1899
+ }catch(e){
1900
+ if(msgEl) msgEl.innerHTML = '<span style="color:var(--accent)">Execution failed: ' + esc(e.message) + '</span>';
1901
+ }
1902
+ }
1903
+
1904
+ on("executeWorkflowRun","click",async()=>{
1905
+ const name=el("workflowName").value.trim();if(!name)return alert("Please enter or load a workflow first.");
1906
+ const id=workflowSlug(name);
1907
+ await executeWorkflowById(id);
1908
+ });
1909
+
1766
1910
  async function refreshWorkflows(){
1767
1911
  try{
1768
1912
  const workflows=await api("/api/workflows");
1769
- el("savedWorkflows").innerHTML=workflows.length?workflows.map(w=>'<div class="run"><div class="run-title"><b>'+esc(w.name)+'</b><span class="pill">'+esc(w.tasks.length)+' TASKS</span></div><div class="run-meta">'+esc(w.id)+'</div></div>').join(""):'<div class="empty">No saved workflows yet.</div>';
1913
+ el("savedWorkflows").innerHTML=workflows.length?workflows.map(w=>'<div class="run"><div class="run-title"><b>'+esc(w.name)+'</b><span class="pill">'+esc(w.tasks.length)+' TASKS</span></div><div class="run-meta" style="display:flex;justify-content:space-between;align-items:center"><span>'+esc(w.id)+'</span><button class="btn btn-emerald" style="padding:3px 8px;font-size:11px" onclick="executeWorkflowById(\''+esc(w.id)+'\')">⚡ Simulate Execution</button></div></div>').join(""):'<div class="empty">No saved workflows yet.</div>';
1770
1914
  }catch(e){el("savedWorkflows").innerHTML='<div class="error">'+esc(e.message)+'</div>';}
1771
1915
  }
1772
1916
 
@@ -1849,12 +1993,19 @@ on("saveMemoryBtn","click",async()=>{
1849
1993
  }catch(e){alert("Failed to save decision: "+e.message);}
1850
1994
  });
1851
1995
 
1996
+ on("syncMemoryToAdrBtn","click",handleSyncAdrs);
1997
+ on("refreshAdrBtn","click",loadAdrs);
1998
+ on("syncAdrBtn","click",handleSyncAdrs);
1999
+ on("createAdrBtn","click",handleCreateAdr);
2000
+ on("autoFixSecurityBtn","click",handleAutoFixSecurity);
2001
+ on("refreshSecurityBtn","click",loadSecurityAudit);
2002
+
1852
2003
  function reloadAllViews(){
1853
2004
  loadOverview();loadAgents();loadRuns();loadActivity();loadObservability();
1854
2005
  loadEvaluationHistory();loadBenchmarkHistory();loadBenchmarkRegression();loadAgentPerformance();
1855
2006
  loadSkillExperiments();loadExperimentHistory();loadAgentOptimization();loadAgentIntelligence();
1856
2007
  loadHealth();loadRegression();loadReviews();loadQuality();loadVerifications();
1857
- loadCleanerBackups();loadMemory();
2008
+ loadCleanerBackups();loadMemory();loadAdrs();loadSecurityAudit();
1858
2009
  }
1859
2010
 
1860
2011
  reloadAllViews();
@@ -1888,7 +2039,7 @@ export async function startDashboard(options) {
1888
2039
  response.writeHead(405, { "content-type": "application/json" }).end(JSON.stringify({ error: "Method not allowed." }));
1889
2040
  return;
1890
2041
  }
1891
- if (request.method === "POST" && (requestUrl.pathname === "/api/memory" || requestUrl.pathname === "/api/memory/delete" || requestUrl.pathname === "/api/workflows" || requestUrl.pathname === "/api/clean/run" || requestUrl.pathname === "/api/clean/undo" || requestUrl.pathname === "/api/config-files" || requestUrl.pathname === "/api/config-snapshots" || /^\/api\/providers\/(?:openai|anthropic|google|ollama)\/diagnose$/.test(requestUrl.pathname) || requestUrl.pathname === "/api/config-releases" || /^\/api\/config-releases\/rel-[a-f0-9]{12}\/(?:approve|reject)$/.test(requestUrl.pathname) || requestUrl.pathname.endsWith("/run") && requestUrl.pathname.startsWith("/api/workflows/") || /^\/api\/runs\/[^/]+\/(?:replay|cancel)$/.test(requestUrl.pathname) || /^\/api\/runs\/[^/]+\/tasks\/[^/]+\/retry$/.test(requestUrl.pathname))) {
2042
+ if (request.method === "POST" && (requestUrl.pathname === "/api/memory" || requestUrl.pathname === "/api/memory/delete" || requestUrl.pathname === "/api/adrs" || requestUrl.pathname === "/api/adrs/sync" || requestUrl.pathname === "/api/security/fix" || requestUrl.pathname === "/api/workflows" || requestUrl.pathname === "/api/clean/run" || requestUrl.pathname === "/api/clean/undo" || requestUrl.pathname === "/api/config-files" || requestUrl.pathname === "/api/config-snapshots" || /^\/api\/providers\/(?:openai|anthropic|google|ollama)\/diagnose$/.test(requestUrl.pathname) || requestUrl.pathname === "/api/config-releases" || /^\/api\/config-releases\/rel-[a-f0-9]{12}\/(?:approve|reject)$/.test(requestUrl.pathname) || requestUrl.pathname.endsWith("/run") && requestUrl.pathname.startsWith("/api/workflows/") || requestUrl.pathname.endsWith("/execute") && requestUrl.pathname.startsWith("/api/workflows/") || /^\/api\/runs\/[^/]+\/(?:replay|cancel)$/.test(requestUrl.pathname) || /^\/api\/runs\/[^/]+\/tasks\/[^/]+\/retry$/.test(requestUrl.pathname))) {
1892
2043
  const origin = request.headers.origin;
1893
2044
  if (origin && new URL(origin).host !== request.headers.host) {
1894
2045
  response.writeHead(403, { "content-type": "application/json" }).end(JSON.stringify({ error: "Cross-origin requests are not allowed." }));
@@ -2029,6 +2180,53 @@ export async function startDashboard(options) {
2029
2180
  response.writeHead(200, { "content-type": "application/json; charset=utf-8" }).end(JSON.stringify({ success }));
2030
2181
  return;
2031
2182
  }
2183
+ if (requestUrl.pathname === "/api/adrs") {
2184
+ const record = (body && typeof body === "object" ? body : {});
2185
+ const title = String(record.title || "").trim();
2186
+ if (!title)
2187
+ throw new Error("ADR title is required.");
2188
+ const status = record.status || "Accepted";
2189
+ const context = record.context ? String(record.context) : undefined;
2190
+ const decision = record.decision ? String(record.decision) : undefined;
2191
+ const adr = await createAdr(projectPath, title, { status, context, decision });
2192
+ response.writeHead(201, { "content-type": "application/json; charset=utf-8" }).end(JSON.stringify(adr));
2193
+ return;
2194
+ }
2195
+ if (requestUrl.pathname === "/api/adrs/sync") {
2196
+ const result = await syncMemoryToAdrs(projectPath);
2197
+ response.writeHead(200, { "content-type": "application/json; charset=utf-8" }).end(JSON.stringify(result));
2198
+ return;
2199
+ }
2200
+ if (requestUrl.pathname === "/api/security/fix") {
2201
+ const scan = await scanProjectSecurity(projectPath);
2202
+ const result = await applySecurityFixes(projectPath, scan.findings);
2203
+ response.writeHead(200, { "content-type": "application/json; charset=utf-8" }).end(JSON.stringify(result));
2204
+ return;
2205
+ }
2206
+ if (requestUrl.pathname.endsWith("/execute") && requestUrl.pathname.startsWith("/api/workflows/")) {
2207
+ const workflowId = requestUrl.pathname.slice("/api/workflows/".length, -"/execute".length);
2208
+ const workflow = await loadWorkflow(projectPath, decodeURIComponent(workflowId));
2209
+ const run = createRunFromWorkflow(workflow);
2210
+ await saveRun(projectPath, run);
2211
+ broadcastEvent("workflow_started", { runId: run.id, workflowName: workflow.name, taskCount: run.tasks.length });
2212
+ const provider = new DemoAgentProvider();
2213
+ const completed = await advanceRun(run, provider, new Set(), {
2214
+ maxConcurrency: 4,
2215
+ onUpdate: async (updatedRun) => {
2216
+ await saveRun(projectPath, updatedRun);
2217
+ broadcastEvent("workflow_update", { runId: updatedRun.id, status: updatedRun.status, tasks: updatedRun.tasks });
2218
+ },
2219
+ onTaskSettled: async (updatedRun, settledTaskId) => {
2220
+ await saveRun(projectPath, updatedRun);
2221
+ const taskRecord = updatedRun.tasks.find(t => t.task.id === settledTaskId);
2222
+ broadcastEvent("workflow_task_settled", { runId: updatedRun.id, taskId: settledTaskId, status: taskRecord?.status, result: taskRecord?.result });
2223
+ }
2224
+ });
2225
+ await saveRun(projectPath, completed);
2226
+ broadcastEvent("workflow_completed", { runId: completed.id, status: completed.status });
2227
+ response.writeHead(200, { "content-type": "application/json; charset=utf-8" }).end(JSON.stringify({ id: completed.id, status: completed.status, taskCount: completed.tasks.length, tasks: completed.tasks }));
2228
+ return;
2229
+ }
2032
2230
  if (requestUrl.pathname === "/api/workflows") {
2033
2231
  const workflow = await saveWorkflow(projectPath, body);
2034
2232
  response.writeHead(201, { "content-type": "application/json; charset=utf-8" }).end(JSON.stringify(workflow));
@@ -2532,6 +2730,16 @@ export async function startDashboard(options) {
2532
2730
  response.writeHead(200, { "content-type": "application/json; charset=utf-8" }).end(JSON.stringify({ entries }));
2533
2731
  return;
2534
2732
  }
2733
+ if (requestUrl.pathname === "/api/adrs") {
2734
+ const adrs = await listAdrs(projectPath);
2735
+ response.writeHead(200, { "content-type": "application/json; charset=utf-8" }).end(JSON.stringify({ adrs }));
2736
+ return;
2737
+ }
2738
+ if (requestUrl.pathname === "/api/security") {
2739
+ const report = await scanProjectSecurity(projectPath);
2740
+ response.writeHead(200, { "content-type": "application/json; charset=utf-8" }).end(JSON.stringify(report));
2741
+ return;
2742
+ }
2535
2743
  if (requestUrl.pathname === "/api/architecture") {
2536
2744
  const map = await mapArchitecture(projectPath);
2537
2745
  response.writeHead(200, { "content-type": "application/json; charset=utf-8" }).end(JSON.stringify(map));