anvil-engineering-workbench 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -45,6 +45,7 @@ import { captureIntelligenceSnapshot, compareLatestIntelligence, formatIntellige
45
45
  import { analyzeDependencies, formatDependencyIntelligence } from "./core/dependency-intelligence.js";
46
46
  import { generateRemediationPlan, formatRemediationPlan } from "./core/remediation-planner.js";
47
47
  import { addProjectMemory, buildProjectMemoryContext, listProjectMemory, removeProjectMemory } from "./core/project-memory.js";
48
+ import { setupHarnessMcp, resolveMcpServerScript } from "./core/mcp-setup.js";
48
49
  import { formatSkillContext, loadSkillRegistry, selectSkills } from "./core/skill-registry.js";
49
50
  import { applyBeforeAgentHooks, loadHooks } from "./core/hook-engine.js";
50
51
  import { assertSupportedAgentPolicy, loadPermissionPolicy } from "./core/permission-policy.js";
@@ -125,7 +126,7 @@ function readAgentDurationBudgets() {
125
126
  }
126
127
  return budgets;
127
128
  }
128
- const VERSION = "1.0.3";
129
+ const VERSION = "1.0.6";
129
130
  const HELP = `
130
131
  ANVIL — The AI Engineering Workbench
131
132
 
@@ -184,6 +185,7 @@ Commands:
184
185
  map [path] Map source modules and import relationships
185
186
  agents [path] List built-in and workspace agent roles
186
187
  memory <action> Manage local project memory (add, list, remove, context)
188
+ mcp [setup] Model Context Protocol server and harness setup (cursor, claude, windsurf)
187
189
  skills [path] List built-in and workspace skills
188
190
  hooks [path] List configured declarative lifecycle hooks
189
191
  agent-security [path] Audit agent instructions, skills, hooks, and permissions
@@ -916,9 +918,14 @@ async function main(args) {
916
918
  }
917
919
  case "memory": {
918
920
  const [action = "list", ...memoryArgs] = rest;
919
- const targetIndex = memoryArgs.findIndex(arg => !arg.startsWith("--"));
920
- const target = path.resolve(targetIndex >= 0 ? memoryArgs[targetIndex] ?? "." : ".");
921
921
  const option = (name) => { const index = memoryArgs.indexOf(name); return index >= 0 ? memoryArgs[index + 1] : undefined; };
922
+ const skipValues = new Set();
923
+ for (let i = 0; i < memoryArgs.length; i++) {
924
+ if (memoryArgs[i]?.startsWith("--"))
925
+ skipValues.add(i + 1);
926
+ }
927
+ const positional = memoryArgs.filter((arg, i) => !arg.startsWith("--") && !skipValues.has(i));
928
+ const target = path.resolve(positional[0] ?? ".");
922
929
  try {
923
930
  if (action === "list") {
924
931
  const entries = await listProjectMemory(target);
@@ -932,7 +939,7 @@ async function main(args) {
932
939
  throw new Error("Usage: anvil memory add [path] --kind decision|architecture|constraint|preference|fact --content TEXT [--tags a,b]");
933
940
  const tags = option("--tags")?.split(",") ?? [];
934
941
  const entry = await addProjectMemory(target, { kind, content, tags });
935
- process.stdout.write(`Saved ${entry.id} to .forge/memory.json\n`);
942
+ process.stdout.write(`Saved ${entry.id} to project memory\n`);
936
943
  }
937
944
  else if (action === "remove") {
938
945
  const id = memoryArgs.find(arg => arg.startsWith("mem-"));
@@ -951,7 +958,48 @@ async function main(args) {
951
958
  }
952
959
  }
953
960
  catch (error) {
954
- process.stderr.write("FORGE memory command failed: " + (error instanceof Error ? error.message : String(error)) + "\n");
961
+ process.stderr.write("ANVIL memory command failed: " + (error instanceof Error ? error.message : String(error)) + "\n");
962
+ process.exitCode = 1;
963
+ }
964
+ return;
965
+ }
966
+ case "mcp": {
967
+ const [subcommand = "info", ...mcpArgs] = rest;
968
+ const option = (name) => { const index = mcpArgs.indexOf(name); return index >= 0 ? mcpArgs[index + 1] : undefined; };
969
+ const skipValues = new Set();
970
+ for (let i = 0; i < mcpArgs.length; i++) {
971
+ if (mcpArgs[i]?.startsWith("--"))
972
+ skipValues.add(i + 1);
973
+ }
974
+ const positional = mcpArgs.filter((arg, i) => !arg.startsWith("--") && !skipValues.has(i));
975
+ const target = path.resolve(positional[0] ?? ".");
976
+ try {
977
+ if (subcommand === "setup") {
978
+ const client = (option("--client") ?? "all");
979
+ const report = await setupHarnessMcp(target, client);
980
+ process.stdout.write(`\nANVIL Model Context Protocol Harness Setup\n`);
981
+ process.stdout.write(`Project: ${report.projectPath}\n`);
982
+ process.stdout.write(`MCP Server: ${report.serverScriptPath}\n\n`);
983
+ for (const res of report.results) {
984
+ process.stdout.write(`✓ [${res.client.toUpperCase()}]: ${res.details}\n`);
985
+ }
986
+ process.stdout.write(`\nYour AI harness is ready to use ANVIL tools!\n`);
987
+ }
988
+ else if (subcommand === "server" || subcommand === "start") {
989
+ const script = resolveMcpServerScript();
990
+ await import(script);
991
+ }
992
+ else {
993
+ const script = resolveMcpServerScript();
994
+ process.stdout.write(`ANVIL Model Context Protocol (MCP) Server\n\n`);
995
+ process.stdout.write(`Server entrypoint: ${script}\n\n`);
996
+ process.stdout.write(`Commands:\n`);
997
+ process.stdout.write(` anvil mcp setup [--client cursor|claude|windsurf|vscode|all] Configure your AI harness\n`);
998
+ process.stdout.write(` anvil mcp start Run MCP stdio transport\n\n`);
999
+ }
1000
+ }
1001
+ catch (error) {
1002
+ process.stderr.write("ANVIL MCP command failed: " + (error instanceof Error ? error.message : String(error)) + "\n");
955
1003
  process.exitCode = 1;
956
1004
  }
957
1005
  return;
@@ -1398,9 +1446,29 @@ async function main(args) {
1398
1446
  return;
1399
1447
  }
1400
1448
  try {
1401
- const dashboard = await startDashboard({ projectPath: target, port: portValue });
1449
+ let dashboard;
1450
+ let chosenPort = portValue;
1451
+ if (portIndex < 0) {
1452
+ for (let p = portValue; p < portValue + 10; p++) {
1453
+ try {
1454
+ dashboard = await startDashboard({ projectPath: target, port: p });
1455
+ chosenPort = p;
1456
+ break;
1457
+ }
1458
+ catch (err) {
1459
+ if (err && typeof err === "object" && "code" in err && err.code === "EADDRINUSE" && p < portValue + 9)
1460
+ continue;
1461
+ throw err;
1462
+ }
1463
+ }
1464
+ }
1465
+ else {
1466
+ dashboard = await startDashboard({ projectPath: target, port: portValue });
1467
+ }
1468
+ if (!dashboard)
1469
+ throw new Error("Could not bind an available dashboard port.");
1402
1470
  const address = dashboard.server.address();
1403
- const actualPort = address && typeof address !== "string" ? address.port : portValue;
1471
+ const actualPort = address && typeof address !== "string" ? address.port : chosenPort;
1404
1472
  process.stdout.write(`ANVIL dashboard: http://127.0.0.1:${actualPort}\nProject: ${target}\nPress Ctrl+C to stop.\n`);
1405
1473
  const shutdown = () => dashboard.server.close(() => process.exit(0));
1406
1474
  process.once("SIGINT", shutdown);