anvil-engineering-workbench 1.0.6 → 1.0.7
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/CHANGELOG.md +24 -2
- package/README.md +34 -35
- package/SECURITY.md +51 -10
- package/dist/ai/provider.js +6 -5
- package/dist/ai/provider.js.map +1 -1
- package/dist/cli.js +123 -6
- package/dist/cli.js.map +1 -1
- package/dist/core/adr-engine.d.ts +30 -0
- package/dist/core/adr-engine.js +163 -0
- package/dist/core/adr-engine.js.map +1 -0
- package/dist/core/code-review.js +6 -6
- package/dist/core/dashboard-server.js +222 -14
- package/dist/core/dashboard-server.js.map +1 -1
- package/dist/core/project-cleaner.js +32 -7
- package/dist/core/project-cleaner.js.map +1 -1
- package/dist/core/security-scanner.d.ts +37 -0
- package/dist/core/security-scanner.js +325 -0
- package/dist/core/security-scanner.js.map +1 -0
- package/package.json +3 -4
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export type AdrStatus = "Proposed" | "Accepted" | "Superseded" | "Deprecated" | "Rejected";
|
|
2
|
+
export interface AdrRecord {
|
|
3
|
+
id: string;
|
|
4
|
+
number: number;
|
|
5
|
+
title: string;
|
|
6
|
+
status: AdrStatus;
|
|
7
|
+
date: string;
|
|
8
|
+
filename: string;
|
|
9
|
+
path: string;
|
|
10
|
+
}
|
|
11
|
+
export interface CreateAdrOptions {
|
|
12
|
+
status?: AdrStatus | undefined;
|
|
13
|
+
context?: string | undefined;
|
|
14
|
+
decision?: string | undefined;
|
|
15
|
+
positiveConsequences?: string[] | undefined;
|
|
16
|
+
negativeConsequences?: string[] | undefined;
|
|
17
|
+
tags?: string[] | undefined;
|
|
18
|
+
}
|
|
19
|
+
export declare function adrDirectory(projectPath: string, customSubdir?: string): string;
|
|
20
|
+
export declare function slugifyTitle(title: string): string;
|
|
21
|
+
export declare function initAdrDirectory(projectPath: string, customSubdir?: string): Promise<{
|
|
22
|
+
created: boolean;
|
|
23
|
+
path: string;
|
|
24
|
+
}>;
|
|
25
|
+
export declare function listAdrs(projectPath: string, customSubdir?: string): Promise<AdrRecord[]>;
|
|
26
|
+
export declare function createAdr(projectPath: string, title: string, options?: CreateAdrOptions, customSubdir?: string): Promise<AdrRecord>;
|
|
27
|
+
export declare function syncMemoryToAdrs(projectPath: string, customSubdir?: string): Promise<{
|
|
28
|
+
syncedCount: number;
|
|
29
|
+
createdAdrs: AdrRecord[];
|
|
30
|
+
}>;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { mkdir, readdir, readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { listProjectMemory } from "./project-memory.js";
|
|
4
|
+
export function adrDirectory(projectPath, customSubdir = "docs/adr") {
|
|
5
|
+
return path.join(path.resolve(projectPath), customSubdir);
|
|
6
|
+
}
|
|
7
|
+
export function slugifyTitle(title) {
|
|
8
|
+
return title
|
|
9
|
+
.toLowerCase()
|
|
10
|
+
.trim()
|
|
11
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
12
|
+
.replace(/^-|-$/g, "")
|
|
13
|
+
.slice(0, 50) || "decision";
|
|
14
|
+
}
|
|
15
|
+
export async function initAdrDirectory(projectPath, customSubdir = "docs/adr") {
|
|
16
|
+
const dir = adrDirectory(projectPath, customSubdir);
|
|
17
|
+
await mkdir(dir, { recursive: true });
|
|
18
|
+
const firstFile = path.join(dir, "0001-record-architecture-decisions.md");
|
|
19
|
+
try {
|
|
20
|
+
await readFile(firstFile, "utf8");
|
|
21
|
+
return { created: false, path: dir };
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
const today = new Date().toISOString().slice(0, 10);
|
|
25
|
+
const content = `# 1. Record architecture decisions
|
|
26
|
+
|
|
27
|
+
* Status: Accepted
|
|
28
|
+
* Date: ${today}
|
|
29
|
+
|
|
30
|
+
## Context and Problem Statement
|
|
31
|
+
We need to record architectural decisions made on this project so that current and future contributors understand why the code is structured the way it is.
|
|
32
|
+
|
|
33
|
+
## Decision Drivers
|
|
34
|
+
* Need for clear provenance of architecture choices.
|
|
35
|
+
* Avoid relitigating settled tradeoffs.
|
|
36
|
+
* Alignment with ANVIL local-first engineering principles.
|
|
37
|
+
|
|
38
|
+
## Considered Options
|
|
39
|
+
* Do not record decisions (rely on commit messages)
|
|
40
|
+
* Wiki pages or external docs
|
|
41
|
+
* In-repo Architecture Decision Records (ADRs)
|
|
42
|
+
|
|
43
|
+
## Decision Outcome
|
|
44
|
+
Chosen option: "In-repo Architecture Decision Records (ADRs)", because it keeps architecture decisions versioned, reviewable in pull requests, and co-located with the codebase.
|
|
45
|
+
|
|
46
|
+
### Positive Consequences
|
|
47
|
+
* Clear historical context for design tradeoffs.
|
|
48
|
+
* Integrated with ANVIL project memory and local dashboard.
|
|
49
|
+
`;
|
|
50
|
+
await writeFile(firstFile, content, "utf8");
|
|
51
|
+
return { created: true, path: dir };
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export async function listAdrs(projectPath, customSubdir = "docs/adr") {
|
|
55
|
+
const dir = adrDirectory(projectPath, customSubdir);
|
|
56
|
+
const records = [];
|
|
57
|
+
try {
|
|
58
|
+
const entries = await readdir(dir, { withFileTypes: true });
|
|
59
|
+
for (const entry of entries) {
|
|
60
|
+
if (!entry.isFile() || !entry.name.endsWith(".md"))
|
|
61
|
+
continue;
|
|
62
|
+
const match = entry.name.match(/^(\d{4})-(.*)\.md$/);
|
|
63
|
+
if (!match)
|
|
64
|
+
continue;
|
|
65
|
+
const num = parseInt(match[1], 10);
|
|
66
|
+
const filePath = path.join(dir, entry.name);
|
|
67
|
+
const text = await readFile(filePath, "utf8");
|
|
68
|
+
// Extract title from first # Header
|
|
69
|
+
const titleMatch = text.match(/^#\s+(?:\d+\.\s*)?([^\r\n]+)/m);
|
|
70
|
+
const title = titleMatch ? titleMatch[1].trim() : match[2].replace(/-/g, " ");
|
|
71
|
+
// Extract status
|
|
72
|
+
const statusMatch = text.match(/\*\s*Status:\s*([^\r\n]+)/i);
|
|
73
|
+
const rawStatus = statusMatch ? statusMatch[1].trim() : "Proposed";
|
|
74
|
+
const status = (["Accepted", "Proposed", "Superseded", "Deprecated", "Rejected"].includes(rawStatus)
|
|
75
|
+
? rawStatus
|
|
76
|
+
: "Proposed");
|
|
77
|
+
// Extract date
|
|
78
|
+
const dateMatch = text.match(/\*\s*Date:\s*([^\r\n]+)/i);
|
|
79
|
+
const date = dateMatch ? dateMatch[1].trim() : new Date().toISOString().slice(0, 10);
|
|
80
|
+
records.push({
|
|
81
|
+
id: match[1],
|
|
82
|
+
number: num,
|
|
83
|
+
title,
|
|
84
|
+
status,
|
|
85
|
+
date,
|
|
86
|
+
filename: entry.name,
|
|
87
|
+
path: filePath,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
return [];
|
|
93
|
+
}
|
|
94
|
+
return records.sort((a, b) => a.number - b.number);
|
|
95
|
+
}
|
|
96
|
+
export async function createAdr(projectPath, title, options = {}, customSubdir = "docs/adr") {
|
|
97
|
+
const dir = adrDirectory(projectPath, customSubdir);
|
|
98
|
+
await mkdir(dir, { recursive: true });
|
|
99
|
+
const existing = await listAdrs(projectPath, customSubdir);
|
|
100
|
+
const nextNum = existing.length > 0 ? Math.max(...existing.map(r => r.number)) + 1 : 1;
|
|
101
|
+
const numStr = String(nextNum).padStart(4, "0");
|
|
102
|
+
const slug = slugifyTitle(title);
|
|
103
|
+
const filename = `${numStr}-${slug}.md`;
|
|
104
|
+
const filePath = path.join(dir, filename);
|
|
105
|
+
const status = options.status ?? "Accepted";
|
|
106
|
+
const date = new Date().toISOString().slice(0, 10);
|
|
107
|
+
const context = options.context ?? `We need to decide on: ${title}.`;
|
|
108
|
+
const decision = options.decision ?? `We will adopt ${title} as standard in this project.`;
|
|
109
|
+
const positive = options.positiveConsequences ?? ["Clear implementation standard across components."];
|
|
110
|
+
const negative = options.negativeConsequences ?? [];
|
|
111
|
+
const content = `# ${nextNum}. ${title.trim()}
|
|
112
|
+
|
|
113
|
+
* Status: ${status}
|
|
114
|
+
* Date: ${date}
|
|
115
|
+
|
|
116
|
+
## Context and Problem Statement
|
|
117
|
+
${context.trim()}
|
|
118
|
+
|
|
119
|
+
## Decision Outcome
|
|
120
|
+
${decision.trim()}
|
|
121
|
+
|
|
122
|
+
### Positive Consequences
|
|
123
|
+
${positive.map(p => `* ${p}`).join("\n")}
|
|
124
|
+
${negative.length ? `\n### Negative Consequences\n${negative.map(n => `* ${n}`).join("\n")}` : ""}
|
|
125
|
+
`;
|
|
126
|
+
await writeFile(filePath, content, "utf8");
|
|
127
|
+
return {
|
|
128
|
+
id: numStr,
|
|
129
|
+
number: nextNum,
|
|
130
|
+
title: title.trim(),
|
|
131
|
+
status,
|
|
132
|
+
date,
|
|
133
|
+
filename,
|
|
134
|
+
path: filePath,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
export async function syncMemoryToAdrs(projectPath, customSubdir = "docs/adr") {
|
|
138
|
+
await initAdrDirectory(projectPath, customSubdir);
|
|
139
|
+
const existingAdrs = await listAdrs(projectPath, customSubdir);
|
|
140
|
+
const existingTitles = new Set(existingAdrs.map(a => a.title.toLowerCase().trim()));
|
|
141
|
+
const memoryEntries = await listProjectMemory(projectPath);
|
|
142
|
+
const decisionEntries = memoryEntries.filter(e => e.kind === "decision" || e.kind === "architecture");
|
|
143
|
+
const createdAdrs = [];
|
|
144
|
+
for (const entry of decisionEntries) {
|
|
145
|
+
const rawTitle = entry.content.length > 60 ? entry.content.slice(0, 57) + "..." : entry.content;
|
|
146
|
+
const titleCandidate = rawTitle.replace(/\r?\n.*/s, "").trim();
|
|
147
|
+
if (existingTitles.has(titleCandidate.toLowerCase()))
|
|
148
|
+
continue;
|
|
149
|
+
const adr = await createAdr(projectPath, titleCandidate, {
|
|
150
|
+
status: "Accepted",
|
|
151
|
+
context: `Recorded from ANVIL project memory (${entry.id}). Tags: ${(entry.tags || []).join(", ") || "none"}.`,
|
|
152
|
+
decision: entry.content,
|
|
153
|
+
positiveConsequences: ["Co-located in version control for automated agent adherence."]
|
|
154
|
+
}, customSubdir);
|
|
155
|
+
existingTitles.add(titleCandidate.toLowerCase());
|
|
156
|
+
createdAdrs.push(adr);
|
|
157
|
+
}
|
|
158
|
+
return {
|
|
159
|
+
syncedCount: createdAdrs.length,
|
|
160
|
+
createdAdrs,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=adr-engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adr-engine.js","sourceRoot":"","sources":["../../src/core/adr-engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAuBxD,MAAM,UAAU,YAAY,CAAC,WAAmB,EAAE,YAAY,GAAG,UAAU;IACzE,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,YAAY,CAAC,CAAC;AAC5D,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,OAAO,KAAK;SACT,WAAW,EAAE;SACb,IAAI,EAAE;SACN,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC;SAC3B,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;SACrB,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,UAAU,CAAC;AAChC,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,WAAmB,EACnB,YAAY,GAAG,UAAU;IAEzB,MAAM,GAAG,GAAG,YAAY,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;IACpD,MAAM,KAAK,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAEtC,MAAM,S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C,8DAA8D,CAAC;SACvF,EACD,YAAY,CACb,CAAC;QAEF,cAAc,CAAC,GAAG,CAAC,cAAc,CAAC,WAAW,EAAE,CAAC,CAAC;QACjD,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;IAED,OAAO;QACL,WAAW,EAAE,WAAW,CAAC,MAAM;QAC/B,WAAW;KACZ,CAAC;AACJ,CAAC"}
|
package/dist/core/code-review.js
CHANGED
|
@@ -30,12 +30,12 @@ function inspectLines(file, source) {
|
|
|
30
30
|
const findings = [];
|
|
31
31
|
const lines = source.split(/\r?\n/);
|
|
32
32
|
const rules = [
|
|
33
|
-
{ id: "
|
|
34
|
-
{ id: "
|
|
35
|
-
{ id: "
|
|
36
|
-
{ id: "
|
|
37
|
-
{ id: "
|
|
38
|
-
{ id: "
|
|
33
|
+
{ id: "ANVIL-R001", severity: "high", title: "Dynamic code evaluation", pattern: /\beval\s*\(|\bnew\s+Function\s*\(/, recommendation: "Avoid evaluating generated strings. Prefer explicit parsers or allow-listed operations." },
|
|
34
|
+
{ id: "ANVIL-R002", severity: "medium", title: "Shell execution API usage", pattern: /\b(?:exec|execSync|execFile|execFileSync|spawn|spawnSync)\s*\(/, recommendation: "Review argument handling, executable allow-lists, and whether shell mode is enabled. Prefer argument arrays and avoid shell interpolation." },
|
|
35
|
+
{ id: "ANVIL-R003", severity: "medium", title: "HTML injection sink", pattern: /\.(?:innerHTML|outerHTML)\s*=/, recommendation: "Avoid assigning untrusted strings to HTML sinks. Use textContent or a vetted sanitizer." },
|
|
36
|
+
{ id: "ANVIL-R004", severity: "low", title: "TypeScript error suppression", pattern: /@ts-ignore\b/, recommendation: "Prefer @ts-expect-error with an explanation, or correct the underlying type mismatch." },
|
|
37
|
+
{ id: "ANVIL-R005", severity: "low", title: "Potentially empty catch block", pattern: /catch\s*(?:\([^)]*\))?\s*\{\s*\}/, recommendation: "Handle, report, or deliberately document the error instead of silently discarding it." },
|
|
38
|
+
{ id: "ANVIL-R006", severity: "medium", title: "Dangerously injected HTML property", pattern: /dangerouslySetInnerHTML/, recommendation: "Ensure content is trusted or sanitized immediately before rendering." }
|
|
39
39
|
];
|
|
40
40
|
for (let i = 0; i < lines.length; i++) {
|
|
41
41
|
const line = lines[i] ?? "";
|
|
@@ -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.
|
|
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"
|
|
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 &
|
|
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
|
|
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 &
|
|
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.
|
|
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.
|
|
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=>({"&":"&","<":"<",">":">",'"':""","'":"'"}[c]));
|
|
1003
1042
|
|
|
1004
|
-
let isShowcase =
|
|
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));
|