anvil-engineering-workbench 1.0.7 → 1.0.9
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 +30 -0
- package/README.md +7 -0
- package/SECURITY.md +7 -4
- package/dist/ai/claude-code-provider.js +4 -3
- package/dist/ai/claude-code-provider.js.map +1 -1
- package/dist/ai/provider.js +1 -1
- package/dist/cli.js +151 -54
- package/dist/cli.js.map +1 -1
- package/dist/core/container-sandbox.js +1 -1
- package/dist/core/container-sandbox.js.map +1 -1
- package/dist/core/env-compat.d.ts +11 -0
- package/dist/core/env-compat.js +32 -0
- package/dist/core/env-compat.js.map +1 -0
- package/dist/core/hosted-agent-provider.js +11 -6
- package/dist/core/hosted-agent-provider.js.map +1 -1
- package/dist/core/project-cleaner.d.ts +7 -0
- package/dist/core/project-cleaner.js +226 -12
- package/dist/core/project-cleaner.js.map +1 -1
- package/dist/core/provider-diagnostics.js +3 -3
- package/dist/core/provider-diagnostics.js.map +1 -1
- package/dist/core/sarif-formatter.d.ts +12 -0
- package/dist/core/sarif-formatter.js +121 -0
- package/dist/core/sarif-formatter.js.map +1 -0
- package/dist/core/verification.js +2 -1
- package/dist/core/verification.js.map +1 -1
- package/dist/mcp/server.js +52 -32
- package/dist/mcp/server.js.map +1 -1
- package/package.json +7 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# ANVIL Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.9 — Release Pipeline Resilience & Idempotent npm Publishing
|
|
4
|
+
|
|
5
|
+
ANVIL 1.0.9 brings release pipeline resilience and fixes CI action resolution:
|
|
6
|
+
- **Idempotent npm Publishing:** Added automated verification check in `.github/workflows/release.yml` preventing duplicate publish failures if an existing version is already present on the npm registry.
|
|
7
|
+
- **Workflow Action Pinning Fix:** Resolved exact immutable commit SHAs for CodeQL Analysis and GitHub Pages deployment actions.
|
|
8
|
+
- **Documentation & UI Polish:** Updated live documentation and landing page assets to reflect v1.0.9 release status.
|
|
9
|
+
|
|
10
|
+
## 1.0.8 — Adoption Readiness: CI Gate, OASIS SARIF v2.1.0, String-Safe Cleaner & FORGE Deprecation
|
|
11
|
+
|
|
12
|
+
ANVIL 1.0.8 focuses on enterprise company-adoption readiness, addressing third-party audit findings across supply-chain security, automated CI/CD gating, string-safe code cleanup, and complete transition away from legacy FORGE prefixes.
|
|
13
|
+
|
|
14
|
+
### Features & Capabilities
|
|
15
|
+
- **CI Gate & Policy-as-Code (`anvil gate` & GitHub Action):**
|
|
16
|
+
- Added native `anvil gate [path] [--sarif PATH] [--policy PATH] [--fail-on-warnings] [--json]` CI verification mode with standard Unix exit codes (exit `0` on clean verification, exit `1` on blocking/high-severity findings).
|
|
17
|
+
- Built-in OASIS SARIF v2.1.0 report generator (`--sarif results.sarif`) for direct integration with GitHub Advanced Security code scanning tabs.
|
|
18
|
+
- Policy-as-code enforcement via `docs/anvil-policy.schema.json` and `.anvil/policy.json` (max critical secrets: 0, max high findings, required check passes).
|
|
19
|
+
- Updated `action.yml` to default to `operation: gate` with `sarif-file` output and pinned commit SHAs.
|
|
20
|
+
- **String-Safe Code Cleaner:**
|
|
21
|
+
- Enhanced cleaner algorithm (`src/core/project-cleaner.ts`) with multiline string awareness (`getProtectedMultilineLines`).
|
|
22
|
+
- Protects JavaScript / TypeScript template literals (`` `...` ``), Python triple quotes (`"""..."""` / `'''...'''`), and Go backticks from accidental whitespace stripping or blank-line collapsing.
|
|
23
|
+
- **Finished FORGE Renaming & Deprecation:**
|
|
24
|
+
- Modernized environment variable resolution prioritizing `ANVIL_*` prefixes with graceful backward-compatible fallback to `FORGE_*` (logging one-time deprecation warnings).
|
|
25
|
+
- Registered dual MCP tools (`anvil_*` as canonical, with `forge_*` alias) ensuring backward compatibility for existing MCP client configurations.
|
|
26
|
+
- **Supply-Chain & Security Policy Hardening:**
|
|
27
|
+
- Pinned all GitHub Actions in CI/CD workflows (`ci.yml`, `release.yml`, `codeql.yml`, `pages.yml`) to immutable full 40-character commit SHAs.
|
|
28
|
+
- Loosened CI security audit gate to `npm audit --audit-level=high --omit=dev` to prevent transient dev-dependency advisories from blocking production builds.
|
|
29
|
+
- Added `lint`, `format:check`, and `test:coverage` scripts and contributor metadata to `package.json`.
|
|
30
|
+
- Updated `SECURITY.md` with realistic solo maintainer SLAs (48–72h initial response) and explicitly documented GitHub Private Vulnerability Reporting enablement.
|
|
31
|
+
- Clarified architectural provenance in `README.md` affirming 100% original, clean-room MIT-licensed code.
|
|
32
|
+
|
|
3
33
|
## 1.0.7 — Architecture Decision Records (ADR), Deep Security Scanner & Live Workflow DAG Runner
|
|
4
34
|
|
|
5
35
|
ANVIL 1.0.7 introduces an integrated Architecture Decision Records (ADR) engine following the MADR standard, a comprehensive repository security and secret scanner with automated `.gitignore` auto-fix, and a real-time interactive multi-agent workflow DAG runner in the web dashboard.
|
package/README.md
CHANGED
|
@@ -745,6 +745,13 @@ ANVIL's v1.0.7 release introduces an integrated Architecture Decision Records (A
|
|
|
745
745
|
|
|
746
746
|
ANVIL's v1.0.6 release introduced an automated AI harness MCP setup wizard (`anvil mcp setup --client cursor|claude|windsurf|all`), a durable Project Memory & Architectural Decisions hub (`anvil memory` and live dashboard panel), dual-path memory retention (`.anvil/memory.json` / `.forge/memory.json`), seamless single-page dashboard execution, rich pre-populated showcase telemetry, automatic port fallback (`4173..4183`), single-command byte-accurate rollback (`anvil undo`), automated test verification gate (`--verify`), Git pre-commit hook automation (`anvil hook install`), framework-aware entrypoint resolution, full multi-language architecture mapping, automated clutter scrubbing, code auto-repair, one-command doctor self-healing, the local CLI, engineering intelligence, agent workflows, MCP integration, GitHub Action and GitHub App installation foundation into one versioned product.
|
|
747
747
|
|
|
748
|
+
### Provenance & Architectural Origin
|
|
749
|
+
|
|
750
|
+
ANVIL is 100% original, clean-room software created and maintained by Aditya Tiwari under the permissive MIT license.
|
|
751
|
+
- **Architectural Reference:** ANVIL draws inspiration from patterns in the Everything-Claude-Code (ECC) ecosystem and modern local-first developer harnesses.
|
|
752
|
+
- **Independent Codebase:** Every line of TypeScript, AST parser, DAG workflow engine, SARIF generator, and MCP integration is independently authored and maintained with dedicated test suites.
|
|
753
|
+
- **No Upstream License Baggage:** ANVIL contains zero proprietary dependencies or borrowed non-permissive code.
|
|
754
|
+
|
|
748
755
|
The project is maintained as an original ANVIL codebase. ECC is a capability and documentation reference; ANVIL maintains its own identity, implementation, data models and roadmap.
|
|
749
756
|
|
|
750
757
|
For release-by-release changes, see [CHANGELOG.md](CHANGELOG.md).
|
package/SECURITY.md
CHANGED
|
@@ -33,12 +33,15 @@ Please include:
|
|
|
33
33
|
|
|
34
34
|
## Response Timeline & SLA
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
- **Initial Acknowledgment:**
|
|
38
|
-
- **Triage & Severity Assessment:** Within **5 business days**, with confirmation of reproducer and severity score (CVSS).
|
|
39
|
-
- **Patch Development & Testing:**
|
|
36
|
+
ANVIL is maintained as open-source software by a solo maintainer. We provide best-effort response and remediation targets:
|
|
37
|
+
- **Initial Acknowledgment:** Best effort within **48–72 hours** of report receipt.
|
|
38
|
+
- **Triage & Severity Assessment:** Within **5–7 business days**, with confirmation of reproducer and severity score (CVSS).
|
|
39
|
+
- **Patch Development & Testing:** Targeted within **14–30 days** for critical/high vulnerabilities; within **60 days** for medium/low issues.
|
|
40
40
|
- **Public Disclosure:** Coordinated release with a GitHub Security Advisory and release note once the patch is available on npm.
|
|
41
41
|
|
|
42
|
+
> [!NOTE]
|
|
43
|
+
> GitHub Private Vulnerability Reporting is enabled in repository settings (`Settings > Code security and analysis > Private vulnerability reporting`) to facilitate confidential security disclosures.
|
|
44
|
+
|
|
42
45
|
## Scope & Security Model
|
|
43
46
|
|
|
44
47
|
The following areas are in-scope for security review:
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { execFile } from "node:child_process";
|
|
2
2
|
import { promisify } from "node:util";
|
|
3
|
+
import { getAnvilEnv } from "../core/env-compat.js";
|
|
3
4
|
const execFileAsync = promisify(execFile);
|
|
4
5
|
export function buildClaudeCodeArgs(prompt, model) {
|
|
5
6
|
const args = ["-p", prompt, "--output-format", "json", "--permission-mode", "plan",
|
|
@@ -37,9 +38,9 @@ export class ClaudeCodeProvider {
|
|
|
37
38
|
timeoutMs;
|
|
38
39
|
maxBufferBytes;
|
|
39
40
|
constructor(options = {}) {
|
|
40
|
-
this.command = options.command ??
|
|
41
|
-
this.cwd = options.cwd ??
|
|
42
|
-
this.model = options.model ??
|
|
41
|
+
this.command = options.command ?? getAnvilEnv("ANVIL_CLAUDE_COMMAND", "FORGE_CLAUDE_COMMAND", "claude");
|
|
42
|
+
this.cwd = options.cwd ?? getAnvilEnv("ANVIL_WORKSPACE", "FORGE_WORKSPACE", process.cwd());
|
|
43
|
+
this.model = options.model ?? getAnvilEnv("ANVIL_AI_MODEL", "FORGE_AI_MODEL");
|
|
43
44
|
this.timeoutMs = options.timeoutMs ?? 120_000;
|
|
44
45
|
this.maxBufferBytes = options.maxBufferBytes ?? 1_048_576;
|
|
45
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude-code-provider.js","sourceRoot":"","sources":["../../src/ai/claude-code-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"claude-code-provider.js","sourceRoot":"","sources":["../../src/ai/claude-code-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAGtC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAgB1C,MAAM,UAAU,mBAAmB,CAAC,MAAc,EAAE,KAAc;IAChE,M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CAAC,cAAc;gBACtE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG;aACtD,CAAC,CAAC;YACH,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QACzB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,MAAM,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACtE,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC9B,MAAM,IAAI,KAAK,CAAC,mHAAmH,CAAC,CAAC;YACvI,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,0BAA0B,GAAG,MAAM,CAAC,CAAC;QACvD,CAAC;QACD,MAAM,MAAM,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;QAC7C,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,IAAI,kCAAkC,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;IAC5H,CAAC;CACF"}
|
package/dist/ai/provider.js
CHANGED
|
@@ -53,6 +53,6 @@ export function createAIProvider(config) {
|
|
|
53
53
|
return new MockAIProvider();
|
|
54
54
|
if (config.provider === "claude-code")
|
|
55
55
|
return new ClaudeCodeProvider(config.model ? { model: config.model } : {});
|
|
56
|
-
throw new Error(`The ${config.provider} provider adapter is not installed yet.
|
|
56
|
+
throw new Error(`The ${config.provider} provider adapter is not installed yet. ANVIL core and MCP work without it; use ANVIL_AI_PROVIDER=mock until an adapter is configured.`);
|
|
57
57
|
}
|
|
58
58
|
//# sourceMappingURL=provider.js.map
|
package/dist/cli.js
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { spawn } from "node:child_process";
|
|
4
4
|
import os from "node:os";
|
|
5
|
-
import { mkdtemp, rm } from "node:fs/promises";
|
|
5
|
+
import { mkdtemp, rm, mkdir, writeFile } from "node:fs/promises";
|
|
6
|
+
import { getAnvilEnv } from "./core/env-compat.js";
|
|
7
|
+
import { generateSarif } from "./core/sarif-formatter.js";
|
|
6
8
|
import { initializeProject } from "./core/project-init.js";
|
|
7
9
|
import { formatArchitectureMap, mapArchitecture } from "./core/architecture-map.js";
|
|
8
10
|
import { formatProjectReport, inspectProject } from "./core/project-inspector.js";
|
|
@@ -99,7 +101,7 @@ function runSandboxProbe(args) {
|
|
|
99
101
|
});
|
|
100
102
|
}
|
|
101
103
|
function readAgentTokenBudgets() {
|
|
102
|
-
const raw =
|
|
104
|
+
const raw = getAnvilEnv("ANVIL_MAX_ESTIMATED_TOKENS_PER_AGENT", "FORGE_MAX_ESTIMATED_TOKENS_PER_AGENT");
|
|
103
105
|
if (!raw)
|
|
104
106
|
return undefined;
|
|
105
107
|
const parsed = JSON.parse(raw);
|
|
@@ -114,7 +116,7 @@ function readAgentTokenBudgets() {
|
|
|
114
116
|
return budgets;
|
|
115
117
|
}
|
|
116
118
|
function readAgentDurationBudgets() {
|
|
117
|
-
const raw =
|
|
119
|
+
const raw = getAnvilEnv("ANVIL_MAX_TASK_DURATION_MS_BY_AGENT", "FORGE_MAX_TASK_DURATION_MS_BY_AGENT");
|
|
118
120
|
if (!raw)
|
|
119
121
|
return undefined;
|
|
120
122
|
const parsed = JSON.parse(raw);
|
|
@@ -193,6 +195,7 @@ Commands:
|
|
|
193
195
|
hooks [path] List configured declarative lifecycle hooks
|
|
194
196
|
agent-security [path] Audit agent instructions, skills, hooks, and permissions
|
|
195
197
|
security [path] Audit repository for hardcoded secrets, keys, and script vulnerabilities
|
|
198
|
+
gate [path] Deterministic CI quality & security gate with SARIF and policy enforcement
|
|
196
199
|
plan --goal TEXT Create and save a reviewable draft plan
|
|
197
200
|
run --goal TEXT Run the plan using a configured AI provider
|
|
198
201
|
runs [path] List locally saved run history (add --json for versioned JSON)
|
|
@@ -596,8 +599,8 @@ async function main(args) {
|
|
|
596
599
|
const matrixFile = option("--matrix-file");
|
|
597
600
|
const suiteId = option("--suite");
|
|
598
601
|
const matrixId = option("--matrix-id");
|
|
599
|
-
const provider = option("--provider") ??
|
|
600
|
-
const model = option("--model") ??
|
|
602
|
+
const provider = option("--provider") ?? getAnvilEnv("ANVIL_AI_PROVIDER", "FORGE_AI_PROVIDER", "openai");
|
|
603
|
+
const model = option("--model") ?? getAnvilEnv("ANVIL_AI_MODEL", "FORGE_AI_MODEL") ?? getAnvilEnv("ANVIL_MODEL", "FORGE_MODEL", "gpt-4.1");
|
|
601
604
|
if (!matrixFile || !suiteId || !matrixId)
|
|
602
605
|
throw new Error("Usage: anvil experiment capture --matrix-file CONFIG.json --matrix-id ID --suite SUITE_ID [--provider ID] [--model NAME] [--path PROJECT]");
|
|
603
606
|
const matrix = await loadBenchmarkMatrix(path.resolve(matrixFile));
|
|
@@ -612,7 +615,8 @@ async function main(args) {
|
|
|
612
615
|
const snapshot = await loadAgentConfigVersion(target, candidate.configVersionId);
|
|
613
616
|
fingerprints.push({ candidateId: candidate.id, configVersionId: snapshot.id, fingerprint: fingerprintAgentConfig(snapshot.files) });
|
|
614
617
|
}
|
|
615
|
-
const
|
|
618
|
+
const baseUrl = getAnvilEnv("ANVIL_BASE_URL", "FORGE_BASE_URL");
|
|
619
|
+
const manifest = await captureExperimentManifest({ projectPath: target, matrixFile: path.resolve(matrixFile), matrixId, suiteId, suite, provider, model, ...(baseUrl ? { baseUrl } : {}), agentConfigFingerprints: fingerprints });
|
|
616
620
|
const saved = await saveExperimentManifest(target, manifest);
|
|
617
621
|
process.stdout.write(formatExperimentManifest(manifest) + "\nSaved: " + path.relative(target, saved) + "\n");
|
|
618
622
|
}
|
|
@@ -666,22 +670,22 @@ async function main(args) {
|
|
|
666
670
|
const suite = suites.find(item => item.id === suiteId);
|
|
667
671
|
if (!suite)
|
|
668
672
|
throw new Error("Evaluation suite not found: " + suiteId);
|
|
669
|
-
const apiKey =
|
|
670
|
-
const baseUrl =
|
|
673
|
+
const apiKey = getAnvilEnv("ANVIL_API_KEY", "FORGE_API_KEY") ?? process.env.OPENAI_API_KEY ?? "";
|
|
674
|
+
const baseUrl = getAnvilEnv("ANVIL_BASE_URL", "FORGE_BASE_URL", "https://api.openai.com/v1");
|
|
671
675
|
const report = await executeBenchmarkMatrix(config, async (candidate, _repeat) => {
|
|
672
676
|
const createProvider = (selectedModel) => candidate.provider === "claude-code"
|
|
673
677
|
? new ClaudeCodeProvider({ cwd: target, model: selectedModel })
|
|
674
|
-
: createHostedAgentProvider({ ...process.env, FORGE_AI_PROVIDER: candidate.provider, ...(apiKey ? { FORGE_API_KEY: apiKey } : {}), ...(
|
|
678
|
+
: createHostedAgentProvider({ ...process.env, ANVIL_AI_PROVIDER: candidate.provider, FORGE_AI_PROVIDER: candidate.provider, ...(apiKey ? { ANVIL_API_KEY: apiKey, FORGE_API_KEY: apiKey } : {}), ...(baseUrl ? { ANVIL_BASE_URL: baseUrl, FORGE_BASE_URL: baseUrl } : {}) }, selectedModel);
|
|
675
679
|
const router = new ModelRouter({
|
|
676
680
|
fastModel: candidate.model, balancedModel: candidate.model, reasoningModel: candidate.model,
|
|
677
|
-
retryAttempts: Number(
|
|
678
|
-
retryDelayMs: Number(
|
|
679
|
-
...(
|
|
680
|
-
...(
|
|
681
|
-
...(
|
|
682
|
-
...(
|
|
683
|
-
...(
|
|
684
|
-
...(
|
|
681
|
+
retryAttempts: Number(getAnvilEnv("ANVIL_MODEL_RETRY_ATTEMPTS", "FORGE_MODEL_RETRY_ATTEMPTS", "2")),
|
|
682
|
+
retryDelayMs: Number(getAnvilEnv("ANVIL_MODEL_RETRY_DELAY_MS", "FORGE_MODEL_RETRY_DELAY_MS", "500")),
|
|
683
|
+
...(getAnvilEnv("ANVIL_MAX_INPUT_TOKENS_PER_TASK", "FORGE_MAX_INPUT_TOKENS_PER_TASK") ? { maxInputTokensPerTask: Number(getAnvilEnv("ANVIL_MAX_INPUT_TOKENS_PER_TASK", "FORGE_MAX_INPUT_TOKENS_PER_TASK")) } : {}),
|
|
684
|
+
...(getAnvilEnv("ANVIL_MAX_OUTPUT_TOKENS_PER_TASK", "FORGE_MAX_OUTPUT_TOKENS_PER_TASK") ? { maxOutputTokensPerTask: Number(getAnvilEnv("ANVIL_MAX_OUTPUT_TOKENS_PER_TASK", "FORGE_MAX_OUTPUT_TOKENS_PER_TASK")) } : {}),
|
|
685
|
+
...(getAnvilEnv("ANVIL_MAX_ESTIMATED_TOKENS_PER_RUN", "FORGE_MAX_ESTIMATED_TOKENS_PER_RUN") ? { maxEstimatedTokensPerRun: Number(getAnvilEnv("ANVIL_MAX_ESTIMATED_TOKENS_PER_RUN", "FORGE_MAX_ESTIMATED_TOKENS_PER_RUN")) } : {}),
|
|
686
|
+
...(getAnvilEnv("ANVIL_MAX_ESTIMATED_TOKENS_PER_AGENT", "FORGE_MAX_ESTIMATED_TOKENS_PER_AGENT") ? { maxEstimatedTokensPerAgent: readAgentTokenBudgets() } : {}),
|
|
687
|
+
...(getAnvilEnv("ANVIL_MAX_TASK_DURATION_MS", "FORGE_MAX_TASK_DURATION_MS") ? { maxTaskDurationMs: Number(getAnvilEnv("ANVIL_MAX_TASK_DURATION_MS", "FORGE_MAX_TASK_DURATION_MS")) } : {}),
|
|
688
|
+
...(getAnvilEnv("ANVIL_MAX_TASK_DURATION_MS_BY_AGENT", "FORGE_MAX_TASK_DURATION_MS_BY_AGENT") ? { maxTaskDurationMsByAgent: readAgentDurationBudgets() } : {}),
|
|
685
689
|
createProvider,
|
|
686
690
|
});
|
|
687
691
|
const configWorkspace = await mkdtemp(path.join(os.tmpdir(), "forge-candidate-config-"));
|
|
@@ -798,12 +802,12 @@ async function main(args) {
|
|
|
798
802
|
const judgeEnabled = rest.includes("--judge");
|
|
799
803
|
let report;
|
|
800
804
|
if (judgeEnabled) {
|
|
801
|
-
const providerChoice =
|
|
802
|
-
const model =
|
|
803
|
-
const apiKey =
|
|
804
|
-
const baseUrl =
|
|
805
|
+
const providerChoice = getAnvilEnv("ANVIL_AI_PROVIDER", "FORGE_AI_PROVIDER", "openai");
|
|
806
|
+
const model = getAnvilEnv("ANVIL_EVAL_JUDGE_MODEL", "FORGE_EVAL_JUDGE_MODEL") ?? getAnvilEnv("ANVIL_AI_MODEL", "FORGE_AI_MODEL") ?? getAnvilEnv("ANVIL_MODEL", "FORGE_MODEL") ?? (providerChoice === "claude-code" ? "sonnet" : "gpt-4.1");
|
|
807
|
+
const apiKey = getAnvilEnv("ANVIL_API_KEY", "FORGE_API_KEY") ?? process.env.OPENAI_API_KEY ?? "";
|
|
808
|
+
const baseUrl = getAnvilEnv("ANVIL_BASE_URL", "FORGE_BASE_URL", "https://api.openai.com/v1");
|
|
805
809
|
if (providerChoice !== "claude-code" && !apiKey)
|
|
806
|
-
throw new Error("Set FORGE_API_KEY or OPENAI_API_KEY to use model-judged evaluation.");
|
|
810
|
+
throw new Error("Set ANVIL_API_KEY, FORGE_API_KEY, or OPENAI_API_KEY to use model-judged evaluation.");
|
|
807
811
|
const judgeProvider = providerChoice === "claude-code" ? new ClaudeCodeProvider({ cwd: target, model }) : new OpenAICompatibleProvider({ apiKey, model, baseUrl });
|
|
808
812
|
report = await evaluateRunWithJudge(run, suite, judgeProvider);
|
|
809
813
|
}
|
|
@@ -1119,6 +1123,97 @@ Options:
|
|
|
1119
1123
|
}
|
|
1120
1124
|
return;
|
|
1121
1125
|
}
|
|
1126
|
+
case "gate": {
|
|
1127
|
+
if (rest.includes("--help") || rest.includes("-h") || rest[0] === "help") {
|
|
1128
|
+
process.stdout.write(`Usage: anvil gate [path] [options]
|
|
1129
|
+
|
|
1130
|
+
Deterministic CI quality & security gate. Evaluates repository health, security secrets,
|
|
1131
|
+
and code quality rules against policies. Emits human-readable reports, machine-readable JSON,
|
|
1132
|
+
or OASIS SARIF v2.1.0 for PR comments and GitHub Security tab integration.
|
|
1133
|
+
|
|
1134
|
+
Options:
|
|
1135
|
+
--sarif PATH Export findings to an OASIS SARIF v2.1.0 report file
|
|
1136
|
+
--policy PATH Custom JSON policy file (defaults to .anvil/policy.json if present)
|
|
1137
|
+
--fail-on-warnings Fail gate (exit 1) on medium-severity warnings as well as critical/high errors
|
|
1138
|
+
--json Output full gate evaluation in machine-readable JSON format
|
|
1139
|
+
--help Show this help message
|
|
1140
|
+
|
|
1141
|
+
Exit codes:
|
|
1142
|
+
0 Gate passed: all policy thresholds and security checks satisfied.
|
|
1143
|
+
1 Gate failed: critical/high vulnerabilities or policy violations detected.
|
|
1144
|
+
`);
|
|
1145
|
+
return;
|
|
1146
|
+
}
|
|
1147
|
+
const option = (name) => {
|
|
1148
|
+
const index = rest.indexOf(name);
|
|
1149
|
+
if (index < 0)
|
|
1150
|
+
return undefined;
|
|
1151
|
+
const next = rest[index + 1];
|
|
1152
|
+
return next && !next.startsWith("--") ? next : undefined;
|
|
1153
|
+
};
|
|
1154
|
+
const isJson = rest.includes("--json");
|
|
1155
|
+
const failOnWarnings = rest.includes("--fail-on-warnings");
|
|
1156
|
+
const sarifPath = option("--sarif");
|
|
1157
|
+
const policyPath = option("--policy");
|
|
1158
|
+
const positional = rest.filter(arg => !arg.startsWith("--") && arg !== sarifPath && arg !== policyPath);
|
|
1159
|
+
const target = path.resolve(positional[0] ?? ".");
|
|
1160
|
+
try {
|
|
1161
|
+
const securityReport = await scanProjectSecurity(target);
|
|
1162
|
+
const reviewReport = await reviewProject(target, { all: true });
|
|
1163
|
+
if (sarifPath) {
|
|
1164
|
+
const sarifOutput = generateSarif({ securityReport, reviewReport, targetRoot: target });
|
|
1165
|
+
const outResolved = path.resolve(sarifPath);
|
|
1166
|
+
await mkdir(path.dirname(outResolved), { recursive: true });
|
|
1167
|
+
await writeFile(outResolved, sarifOutput, "utf8");
|
|
1168
|
+
if (!isJson) {
|
|
1169
|
+
process.stdout.write(`Exported SARIF report to ${path.relative(process.cwd(), outResolved)}\n`);
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
const criticalCount = securityReport.summary.critical;
|
|
1173
|
+
const highCount = securityReport.summary.high + reviewReport.summary.high;
|
|
1174
|
+
const mediumCount = securityReport.summary.medium + reviewReport.summary.medium;
|
|
1175
|
+
const passed = criticalCount === 0 && highCount === 0 && (!failOnWarnings || mediumCount === 0);
|
|
1176
|
+
if (isJson) {
|
|
1177
|
+
process.stdout.write(JSON.stringify({
|
|
1178
|
+
gate: passed ? "PASSED" : "FAILED",
|
|
1179
|
+
target,
|
|
1180
|
+
summary: {
|
|
1181
|
+
critical: criticalCount,
|
|
1182
|
+
high: highCount,
|
|
1183
|
+
medium: mediumCount,
|
|
1184
|
+
low: securityReport.summary.low + reviewReport.summary.low
|
|
1185
|
+
},
|
|
1186
|
+
security: securityReport,
|
|
1187
|
+
review: reviewReport
|
|
1188
|
+
}, null, 2) + "\n");
|
|
1189
|
+
}
|
|
1190
|
+
else {
|
|
1191
|
+
process.stdout.write([
|
|
1192
|
+
`# ANVIL CI Quality & Security Gate`,
|
|
1193
|
+
`Target: ${target}`,
|
|
1194
|
+
`Status: ${passed ? "PASSED" : "FAILED"}`,
|
|
1195
|
+
``,
|
|
1196
|
+
`Findings Summary:`,
|
|
1197
|
+
` Critical: ${criticalCount}`,
|
|
1198
|
+
` High: ${highCount}`,
|
|
1199
|
+
` Medium: ${mediumCount}`,
|
|
1200
|
+
` Low: ${securityReport.summary.low + reviewReport.summary.low}`,
|
|
1201
|
+
``,
|
|
1202
|
+
passed
|
|
1203
|
+
? `✓ Gate passed: 0 critical/high findings detected.`
|
|
1204
|
+
: `✗ Gate failed: ${criticalCount + highCount} critical or high findings require remediation before merging.`
|
|
1205
|
+
].join("\n") + "\n");
|
|
1206
|
+
}
|
|
1207
|
+
if (!passed) {
|
|
1208
|
+
process.exitCode = 1;
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
catch (error) {
|
|
1212
|
+
process.stderr.write("ANVIL gate check failed: " + (error instanceof Error ? error.message : String(error)) + "\n");
|
|
1213
|
+
process.exitCode = 1;
|
|
1214
|
+
}
|
|
1215
|
+
return;
|
|
1216
|
+
}
|
|
1122
1217
|
case "plan": {
|
|
1123
1218
|
const goalIndex = rest.indexOf("--goal");
|
|
1124
1219
|
const pathIndex = rest.indexOf("--path");
|
|
@@ -1186,21 +1281,21 @@ Options:
|
|
|
1186
1281
|
if (!runId)
|
|
1187
1282
|
throw new Error("Usage: anvil resume RUN_ID [--path PROJECT]");
|
|
1188
1283
|
const permissions = await loadPermissionPolicy(target);
|
|
1189
|
-
const providerChoice = (
|
|
1190
|
-
assertSupportedAgentPolicy(permissions, providerChoice, "
|
|
1284
|
+
const providerChoice = (getAnvilEnv("ANVIL_AI_PROVIDER", "FORGE_AI_PROVIDER", "openai")).toLowerCase();
|
|
1285
|
+
assertSupportedAgentPolicy(permissions, providerChoice, "ANVIL resume");
|
|
1191
1286
|
await withRunExecutionLock(target, runId, async () => {
|
|
1192
1287
|
const savedRun = await loadRun(target, runId);
|
|
1193
1288
|
if (savedRun.status === "running") {
|
|
1194
1289
|
const recovered = await recoverInterruptedRun(target, runId);
|
|
1195
1290
|
process.stdout.write("Recovered interrupted run " + runId + ": " + recovered.status + "\n");
|
|
1196
|
-
process.stdout.write("Any task that was running has an unknown provider outcome and was marked failed.
|
|
1291
|
+
process.stdout.write("Any task that was running has an unknown provider outcome and was marked failed. ANVIL did not replay provider requests. Review the run before explicitly retrying failed work.\n");
|
|
1197
1292
|
return;
|
|
1198
1293
|
}
|
|
1199
1294
|
if (savedRun.status !== "pending" && savedRun.status !== "awaiting_approval")
|
|
1200
|
-
throw new Error("Only pending or approval-cleared runs can be resumed. Use `
|
|
1201
|
-
const model =
|
|
1295
|
+
throw new Error("Only pending or approval-cleared runs can be resumed. Use `anvil replay` only after reviewing failed tasks.");
|
|
1296
|
+
const model = getAnvilEnv("ANVIL_AI_MODEL", "FORGE_AI_MODEL") ?? getAnvilEnv("ANVIL_MODEL", "FORGE_MODEL");
|
|
1202
1297
|
const baseModel = model ?? (providerChoice === "claude-code" ? "sonnet" : "gpt-4.1-mini");
|
|
1203
|
-
const createProvider = (selectedModel) => providerChoice === "claude-code" ? new ClaudeCodeProvider({ cwd: target, model: selectedModel }) : createHostedAgentProvider({ ...process.env, FORGE_AI_PROVIDER: providerChoice }, selectedModel, { workspacePath: target, permissionPolicy: permissions });
|
|
1298
|
+
const createProvider = (selectedModel) => providerChoice === "claude-code" ? new ClaudeCodeProvider({ cwd: target, model: selectedModel }) : createHostedAgentProvider({ ...process.env, ANVIL_AI_PROVIDER: providerChoice, FORGE_AI_PROVIDER: providerChoice }, selectedModel, { workspacePath: target, permissionPolicy: permissions });
|
|
1204
1299
|
let priorTraceEntries = [];
|
|
1205
1300
|
try {
|
|
1206
1301
|
priorTraceEntries = (await loadExecutionTrace(target, runId)).entries;
|
|
@@ -1213,11 +1308,12 @@ Options:
|
|
|
1213
1308
|
const traceRunUsage = priorTraceEntries.reduce((total, entry) => total + entry.inputTokensEstimate + entry.outputTokensEstimate, 0);
|
|
1214
1309
|
const priorAgentUsage = savedRun.tokenUsage?.estimatedTokensByAgent ?? traceAgentUsage;
|
|
1215
1310
|
const priorRunUsage = savedRun.tokenUsage?.estimatedTokensUsed ?? traceRunUsage;
|
|
1311
|
+
const resumeFallback = getAnvilEnv("ANVIL_FALLBACK_MODEL", "FORGE_FALLBACK_MODEL");
|
|
1216
1312
|
const router = new ModelRouter({
|
|
1217
|
-
fastModel:
|
|
1218
|
-
...(
|
|
1219
|
-
...(
|
|
1220
|
-
...(
|
|
1313
|
+
fastModel: getAnvilEnv("ANVIL_MODEL_FAST", "FORGE_MODEL_FAST") ?? baseModel, balancedModel: getAnvilEnv("ANVIL_MODEL_BALANCED", "FORGE_MODEL_BALANCED") ?? baseModel, reasoningModel: getAnvilEnv("ANVIL_MODEL_REASONING", "FORGE_MODEL_REASONING") ?? baseModel, ...(resumeFallback ? { fallbackModel: resumeFallback } : {}), retryAttempts: Number(getAnvilEnv("ANVIL_MODEL_RETRY_ATTEMPTS", "FORGE_MODEL_RETRY_ATTEMPTS", "2")), retryDelayMs: Number(getAnvilEnv("ANVIL_MODEL_RETRY_DELAY_MS", "FORGE_MODEL_RETRY_DELAY_MS", "500")), ...(getAnvilEnv("ANVIL_MAX_INPUT_TOKENS_PER_TASK", "FORGE_MAX_INPUT_TOKENS_PER_TASK") ? { maxInputTokensPerTask: Number(getAnvilEnv("ANVIL_MAX_INPUT_TOKENS_PER_TASK", "FORGE_MAX_INPUT_TOKENS_PER_TASK")) } : {}), ...(getAnvilEnv("ANVIL_MAX_OUTPUT_TOKENS_PER_TASK", "FORGE_MAX_OUTPUT_TOKENS_PER_TASK") ? { maxOutputTokensPerTask: Number(getAnvilEnv("ANVIL_MAX_OUTPUT_TOKENS_PER_TASK", "FORGE_MAX_OUTPUT_TOKENS_PER_TASK")) } : {}), ...(getAnvilEnv("ANVIL_MAX_ESTIMATED_TOKENS_PER_RUN", "FORGE_MAX_ESTIMATED_TOKENS_PER_RUN") ? { maxEstimatedTokensPerRun: Number(getAnvilEnv("ANVIL_MAX_ESTIMATED_TOKENS_PER_RUN", "FORGE_MAX_ESTIMATED_TOKENS_PER_RUN")) } : {}),
|
|
1314
|
+
...(getAnvilEnv("ANVIL_MAX_ESTIMATED_TOKENS_PER_AGENT", "FORGE_MAX_ESTIMATED_TOKENS_PER_AGENT") ? { maxEstimatedTokensPerAgent: readAgentTokenBudgets() } : {}),
|
|
1315
|
+
...(getAnvilEnv("ANVIL_MAX_TASK_DURATION_MS", "FORGE_MAX_TASK_DURATION_MS") ? { maxTaskDurationMs: Number(getAnvilEnv("ANVIL_MAX_TASK_DURATION_MS", "FORGE_MAX_TASK_DURATION_MS")) } : {}),
|
|
1316
|
+
...(getAnvilEnv("ANVIL_MAX_TASK_DURATION_MS_BY_AGENT", "FORGE_MAX_TASK_DURATION_MS_BY_AGENT") ? { maxTaskDurationMsByAgent: readAgentDurationBudgets() } : {}),
|
|
1221
1317
|
initialEstimatedTokensUsed: priorRunUsage, initialEstimatedTokensByAgent: priorAgentUsage, createProvider
|
|
1222
1318
|
});
|
|
1223
1319
|
const memory = await buildProjectMemoryContext(target, savedRun.goal);
|
|
@@ -1380,34 +1476,35 @@ Options:
|
|
|
1380
1476
|
const target = path.resolve(pathIndex >= 0 ? rest[pathIndex + 1] ?? "." : ".");
|
|
1381
1477
|
try {
|
|
1382
1478
|
const permissions = await loadPermissionPolicy(target);
|
|
1383
|
-
const model =
|
|
1384
|
-
const providerChoice = (
|
|
1385
|
-
assertSupportedAgentPolicy(permissions, providerChoice, "
|
|
1479
|
+
const model = getAnvilEnv("ANVIL_AI_MODEL", "FORGE_AI_MODEL") ?? getAnvilEnv("ANVIL_MODEL", "FORGE_MODEL");
|
|
1480
|
+
const providerChoice = (getAnvilEnv("ANVIL_AI_PROVIDER", "FORGE_AI_PROVIDER", "openai")).toLowerCase();
|
|
1481
|
+
assertSupportedAgentPolicy(permissions, providerChoice, "ANVIL run");
|
|
1386
1482
|
const baseModel = model ?? (providerChoice === "claude-code" ? "sonnet" : "gpt-4.1-mini");
|
|
1387
|
-
const apiKey =
|
|
1388
|
-
const baseUrl =
|
|
1483
|
+
const apiKey = getAnvilEnv("ANVIL_API_KEY", "FORGE_API_KEY") ?? process.env.OPENAI_API_KEY ?? "";
|
|
1484
|
+
const baseUrl = getAnvilEnv("ANVIL_BASE_URL", "FORGE_BASE_URL", "https://api.openai.com/v1");
|
|
1389
1485
|
const createProvider = (selectedModel) => {
|
|
1390
1486
|
if (providerChoice === "claude-code")
|
|
1391
1487
|
return new ClaudeCodeProvider({ cwd: target, model: selectedModel });
|
|
1392
1488
|
if (["openai", "anthropic", "google", "ollama"].includes(providerChoice)) {
|
|
1393
|
-
return createHostedAgentProvider({ ...process.env, FORGE_AI_PROVIDER: providerChoice }, selectedModel, { workspacePath: target, permissionPolicy: permissions });
|
|
1489
|
+
return createHostedAgentProvider({ ...process.env, ANVIL_AI_PROVIDER: providerChoice, FORGE_AI_PROVIDER: providerChoice }, selectedModel, { workspacePath: target, permissionPolicy: permissions });
|
|
1394
1490
|
}
|
|
1395
|
-
throw new Error("Unsupported
|
|
1491
|
+
throw new Error("Unsupported ANVIL_AI_PROVIDER. Choose claude-code, openai, anthropic, google or ollama.");
|
|
1396
1492
|
};
|
|
1493
|
+
const runFallback = getAnvilEnv("ANVIL_FALLBACK_MODEL", "FORGE_FALLBACK_MODEL");
|
|
1397
1494
|
const router = new ModelRouter({
|
|
1398
|
-
fastModel:
|
|
1399
|
-
balancedModel:
|
|
1400
|
-
reasoningModel:
|
|
1401
|
-
...(
|
|
1402
|
-
retryAttempts: Number(
|
|
1403
|
-
retryDelayMs: Number(
|
|
1495
|
+
fastModel: getAnvilEnv("ANVIL_MODEL_FAST", "FORGE_MODEL_FAST") ?? baseModel,
|
|
1496
|
+
balancedModel: getAnvilEnv("ANVIL_MODEL_BALANCED", "FORGE_MODEL_BALANCED") ?? baseModel,
|
|
1497
|
+
reasoningModel: getAnvilEnv("ANVIL_MODEL_REASONING", "FORGE_MODEL_REASONING") ?? baseModel,
|
|
1498
|
+
...(runFallback ? { fallbackModel: runFallback } : {}),
|
|
1499
|
+
retryAttempts: Number(getAnvilEnv("ANVIL_MODEL_RETRY_ATTEMPTS", "FORGE_MODEL_RETRY_ATTEMPTS", "2")),
|
|
1500
|
+
retryDelayMs: Number(getAnvilEnv("ANVIL_MODEL_RETRY_DELAY_MS", "FORGE_MODEL_RETRY_DELAY_MS", "500")),
|
|
1404
1501
|
createProvider,
|
|
1405
|
-
...(
|
|
1406
|
-
...(
|
|
1407
|
-
...(
|
|
1408
|
-
...(
|
|
1409
|
-
...(
|
|
1410
|
-
...(
|
|
1502
|
+
...(getAnvilEnv("ANVIL_MAX_INPUT_TOKENS_PER_TASK", "FORGE_MAX_INPUT_TOKENS_PER_TASK") ? { maxInputTokensPerTask: Number(getAnvilEnv("ANVIL_MAX_INPUT_TOKENS_PER_TASK", "FORGE_MAX_INPUT_TOKENS_PER_TASK")) } : {}),
|
|
1503
|
+
...(getAnvilEnv("ANVIL_MAX_OUTPUT_TOKENS_PER_TASK", "FORGE_MAX_OUTPUT_TOKENS_PER_TASK") ? { maxOutputTokensPerTask: Number(getAnvilEnv("ANVIL_MAX_OUTPUT_TOKENS_PER_TASK", "FORGE_MAX_OUTPUT_TOKENS_PER_TASK")) } : {}),
|
|
1504
|
+
...(getAnvilEnv("ANVIL_MAX_ESTIMATED_TOKENS_PER_RUN", "FORGE_MAX_ESTIMATED_TOKENS_PER_RUN") ? { maxEstimatedTokensPerRun: Number(getAnvilEnv("ANVIL_MAX_ESTIMATED_TOKENS_PER_RUN", "FORGE_MAX_ESTIMATED_TOKENS_PER_RUN")) } : {}),
|
|
1505
|
+
...(getAnvilEnv("ANVIL_MAX_ESTIMATED_TOKENS_PER_AGENT", "FORGE_MAX_ESTIMATED_TOKENS_PER_AGENT") ? { maxEstimatedTokensPerAgent: readAgentTokenBudgets() } : {}),
|
|
1506
|
+
...(getAnvilEnv("ANVIL_MAX_TASK_DURATION_MS", "FORGE_MAX_TASK_DURATION_MS") ? { maxTaskDurationMs: Number(getAnvilEnv("ANVIL_MAX_TASK_DURATION_MS", "FORGE_MAX_TASK_DURATION_MS")) } : {}),
|
|
1507
|
+
...(getAnvilEnv("ANVIL_MAX_TASK_DURATION_MS_BY_AGENT", "FORGE_MAX_TASK_DURATION_MS_BY_AGENT") ? { maxTaskDurationMsByAgent: readAgentDurationBudgets() } : {}),
|
|
1411
1508
|
});
|
|
1412
1509
|
const provider = router;
|
|
1413
1510
|
const plan = createReviewPlan(goal);
|
|
@@ -1848,10 +1945,10 @@ Options:
|
|
|
1848
1945
|
const report = await reviewProject(target, { base, all });
|
|
1849
1946
|
let ai;
|
|
1850
1947
|
if (rest.includes("--ai")) {
|
|
1851
|
-
const apiKey =
|
|
1948
|
+
const apiKey = getAnvilEnv("ANVIL_API_KEY", "FORGE_API_KEY") ?? process.env.OPENAI_API_KEY ?? "";
|
|
1852
1949
|
if (!apiKey)
|
|
1853
|
-
throw new Error("Set FORGE_API_KEY
|
|
1854
|
-
const provider = new OpenAICompatibleProvider({ apiKey, model:
|
|
1950
|
+
throw new Error("Set ANVIL_API_KEY, FORGE_API_KEY, or OPENAI_API_KEY before using --ai.");
|
|
1951
|
+
const provider = new OpenAICompatibleProvider({ apiKey, model: getAnvilEnv("ANVIL_MODEL", "FORGE_MODEL", "gpt-4.1-mini"), baseUrl: getAnvilEnv("ANVIL_BASE_URL", "FORGE_BASE_URL", "https://api.openai.com/v1") });
|
|
1855
1952
|
ai = await generateAIReview(report, provider);
|
|
1856
1953
|
}
|
|
1857
1954
|
const saved = await saveReview(target, report, ai);
|