copperhead 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/NOTICE +1 -1
  2. package/README.md +6 -6
  3. package/dist/agent/filetools.js +24 -1
  4. package/dist/agent/filetools.js.map +1 -1
  5. package/dist/agent/ledger.js +24 -0
  6. package/dist/agent/ledger.js.map +1 -1
  7. package/dist/agent/loop.js +29 -58
  8. package/dist/agent/loop.js.map +1 -1
  9. package/dist/agent/prompts.js +4 -3
  10. package/dist/agent/prompts.js.map +1 -1
  11. package/dist/agent/providers/tool-protocol.js +21 -0
  12. package/dist/agent/providers/tool-protocol.js.map +1 -1
  13. package/dist/agent/recovery.js +95 -1
  14. package/dist/agent/recovery.js.map +1 -1
  15. package/dist/agent/tools.js +185 -1
  16. package/dist/agent/tools.js.map +1 -1
  17. package/dist/agent/transcript.js +2 -0
  18. package/dist/agent/transcript.js.map +1 -1
  19. package/dist/cli.js +75 -0
  20. package/dist/cli.js.map +1 -1
  21. package/dist/commands/check.js +33 -1
  22. package/dist/commands/check.js.map +1 -1
  23. package/dist/commands/create.js +177 -25
  24. package/dist/commands/create.js.map +1 -1
  25. package/dist/commands/doctor.js +50 -3
  26. package/dist/commands/doctor.js.map +1 -1
  27. package/dist/config.js +1 -0
  28. package/dist/config.js.map +1 -1
  29. package/dist/kicad/bootstrap.js +24 -3
  30. package/dist/kicad/bootstrap.js.map +1 -1
  31. package/dist/kicad/dossier.js +207 -0
  32. package/dist/kicad/dossier.js.map +1 -0
  33. package/dist/kicad/draft/draft.js +132 -0
  34. package/dist/kicad/draft/draft.js.map +1 -0
  35. package/dist/kicad/draft/engine.js +2389 -0
  36. package/dist/kicad/draft/engine.js.map +1 -0
  37. package/dist/kicad/draft/ir.js +368 -0
  38. package/dist/kicad/draft/ir.js.map +1 -0
  39. package/dist/kicad/draft/symsource.js +490 -0
  40. package/dist/kicad/draft/symsource.js.map +1 -0
  41. package/dist/kicad/emit.js +181 -0
  42. package/dist/kicad/emit.js.map +1 -0
  43. package/dist/kicad/fab.js +13 -0
  44. package/dist/kicad/fab.js.map +1 -1
  45. package/dist/kicad/legibility.js +561 -0
  46. package/dist/kicad/legibility.js.map +1 -0
  47. package/dist/kicad/score.js +261 -0
  48. package/dist/kicad/score.js.map +1 -0
  49. package/dist/kicad/sexp.js +239 -6
  50. package/dist/kicad/sexp.js.map +1 -1
  51. package/dist/kicad/symlib.js +346 -16
  52. package/dist/kicad/symlib.js.map +1 -1
  53. package/dist/memory/bom-table.js +75 -39
  54. package/dist/memory/bom-table.js.map +1 -1
  55. package/dist/memory/scaffold.js +6 -0
  56. package/dist/memory/scaffold.js.map +1 -1
  57. package/dist/util/redact.js +6 -0
  58. package/dist/util/redact.js.map +1 -1
  59. package/package.json +9 -7
  60. package/src/agent/filetools.ts +26 -1
  61. package/src/agent/ledger.ts +24 -0
  62. package/src/agent/loop.ts +28 -61
  63. package/src/agent/prompts.ts +4 -3
  64. package/src/agent/providers/tool-protocol.ts +22 -0
  65. package/src/agent/recovery.ts +94 -1
  66. package/src/agent/tools.ts +189 -1
  67. package/src/agent/transcript.ts +6 -0
  68. package/src/cli.ts +71 -0
  69. package/src/commands/check.ts +51 -1
  70. package/src/commands/create.ts +179 -20
  71. package/src/commands/doctor.ts +51 -3
  72. package/src/config.ts +24 -0
  73. package/src/kicad/bootstrap.ts +24 -3
  74. package/src/kicad/dossier.ts +217 -0
  75. package/src/kicad/draft/draft.ts +171 -0
  76. package/src/kicad/draft/engine.ts +2466 -0
  77. package/src/kicad/draft/ir.ts +416 -0
  78. package/src/kicad/draft/symsource.ts +535 -0
  79. package/src/kicad/emit.ts +236 -0
  80. package/src/kicad/fab.ts +15 -0
  81. package/src/kicad/legibility.ts +646 -0
  82. package/src/kicad/score.ts +323 -0
  83. package/src/kicad/sexp.ts +315 -6
  84. package/src/kicad/symlib.ts +364 -18
  85. package/src/memory/bom-table.ts +85 -38
  86. package/src/memory/scaffold.ts +6 -0
  87. package/src/util/redact.ts +6 -0
  88. package/dist/memory/synap.js +0 -152
  89. package/dist/memory/synap.js.map +0 -1
  90. package/src/memory/synap.ts +0 -217
@@ -28,20 +28,83 @@ function isSeparatorRow(cells) {
28
28
  * whatever cells they split into — this function never throws.
29
29
  */
30
30
  export function parseMarkdownTables(md) {
31
- const rows = [];
32
- for (const line of md.split('\n')) {
31
+ return (scanTableGroups(md)
32
+ // A group opened by an un-piped line with no delimiter row is not a table:
33
+ // GFM requires the delimiter row for one to exist at all. Without this,
34
+ // ordinary prose such as `Second-source options: Yageo | Vishay | KOA`
35
+ // under a BOM table becomes a part in `export bom`, which `check` cannot
36
+ // catch because `parseCanonicalTables` drops the header-less group.
37
+ .filter((g) => g[0].piped || g.some((l) => l.separator))
38
+ .flat()
39
+ .filter((l) => !l.separator)
40
+ .map((l) => ({ cells: l.cells })));
41
+ }
42
+ /**
43
+ * Group a document's table lines, one group per table. Both readers below go
44
+ * through this so they cannot disagree about which documents are readable:
45
+ * `check` accepting a BOM.md that `export bom` reads as empty is how a clean
46
+ * check turns into a header-only ordering file.
47
+ *
48
+ * Lines inside a fenced code block are skipped. Docs legitimately show the
49
+ * table format as an example, and an example row is not a part or a pin.
50
+ */
51
+ function scanTableGroups(md) {
52
+ const groups = [];
53
+ let current = null;
54
+ let width = 0; // column count of the open group, set by its first line
55
+ // The open fence's delimiter, or null outside one. A fence closes only on the
56
+ // same character, at least as long (CommonMark). Toggling on any fence-like
57
+ // line would let a shorter or different delimiter *inside* a block end it
58
+ // early, and the example rows after it would be read as parts or pins.
59
+ let fence = null;
60
+ // Split on either line ending: a CRLF document would otherwise leave a
61
+ // trailing \r on every line, and \r is a line terminator that `.` does not
62
+ // match, so the fence patterns below would never fire on a CRLF file.
63
+ for (const line of md.split(/\r?\n/)) {
33
64
  const t = line.trim();
34
- if (!t.startsWith('|'))
65
+ // Matched against the raw line: CommonMark allows a fence up to three
66
+ // spaces of indentation, and four or more makes it content rather than a
67
+ // fence. Trimming first would let an indented delimiter inside a block
68
+ // read as a closer.
69
+ const delim = /^ {0,3}(`{3,}|~{3,})(.*)$/.exec(line);
70
+ if (delim) {
71
+ const marker = delim[1];
72
+ const char = marker[0];
73
+ if (!fence) {
74
+ fence = { char, length: marker.length };
75
+ current = null;
76
+ continue;
77
+ }
78
+ // A closing fence carries no info string; anything else stays content.
79
+ if (char === fence.char && marker.length >= fence.length && !delim[2].trim()) {
80
+ fence = null;
81
+ current = null;
82
+ continue;
83
+ }
84
+ }
85
+ if (fence || !t.includes('|')) {
86
+ current = null; // a blank, prose, or fenced line terminates the table
35
87
  continue;
36
- const cells = t
37
- .split('|')
38
- .slice(1, -1)
39
- .map((c) => c.trim());
40
- if (cells.every((c) => /^:?-+:?$/.test(c)))
41
- continue; // separator row
42
- rows.push({ cells });
88
+ }
89
+ const cells = splitRow(t);
90
+ // Outer pipes make a line unambiguously a table row. Without them, a
91
+ // pipe-bearing prose line (`Legend: A | B`) is indistinguishable from a
92
+ // row by shape alone, so the column count decides: matching the open
93
+ // table's width keeps it as a row, a mismatch ends the table there rather
94
+ // than reading the prose as a part/pin. The line still opens a new group,
95
+ // in case it is itself the header of an un-piped table.
96
+ if (current && !t.startsWith('|') && cells.length !== width)
97
+ current = null;
98
+ if (!current) {
99
+ current = [];
100
+ width = cells.length;
101
+ groups.push(current);
102
+ }
103
+ // The separator row stays in the group so the header can be located
104
+ // relative to it; it is dropped by the readers above and below.
105
+ current.push({ cells, separator: isSeparatorRow(cells), piped: t.startsWith('|') });
43
106
  }
44
- return rows;
107
+ return groups;
45
108
  }
46
109
  /** True for a table's header row. BOM.md and PINOUT.md both lead with a
47
110
  * Refdes or Pin column, so one check covers both doc types. */
@@ -77,35 +140,8 @@ export function parseCanonicalRows(md) {
77
140
  * it loops on finish forever. Resolving by header name fixes that.
78
141
  */
79
142
  export function parseCanonicalTables(md) {
80
- const groups = [];
81
- let current = null;
82
- let width = 0; // column count of the open group, set by its first line
83
- for (const line of md.split('\n')) {
84
- const t = line.trim();
85
- if (!t.includes('|')) {
86
- current = null; // a blank or prose line terminates the current table
87
- continue;
88
- }
89
- const cells = splitRow(t);
90
- // Outer pipes make a line unambiguously a table row. Without them, a
91
- // pipe-bearing prose line (`Legend: A | B`) is indistinguishable from a
92
- // row by shape alone, so the column count decides: matching the open
93
- // table's width keeps it as a row, a mismatch ends the table there rather
94
- // than reading the prose as a part/pin. The line still opens a new group,
95
- // in case it is itself the header of an un-piped table.
96
- if (current && !t.startsWith('|') && cells.length !== width)
97
- current = null;
98
- if (!current) {
99
- current = [];
100
- width = cells.length;
101
- groups.push(current);
102
- }
103
- // The separator row stays in the group so the header can be located
104
- // relative to it; it is dropped from the rows returned below.
105
- current.push({ cells, separator: isSeparatorRow(cells) });
106
- }
107
143
  const tables = [];
108
- for (const g of groups) {
144
+ for (const g of scanTableGroups(md)) {
109
145
  // The header is the row directly above the separator. Falling back to the
110
146
  // first row keeps a table that omits the separator working, and anchoring
111
147
  // on the separator means a stray pipe-bearing prose line immediately above
@@ -1 +1 @@
1
- {"version":3,"file":"bom-table.js","sourceRoot":"","sources":["../../src/memory/bom-table.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMD;;;;;GAKG;AACH,SAAS,QAAQ,CAAC,IAAY;IAC5B,OAAO,IAAI;SACR,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;SAClB,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;SAClB,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;AAC1B,CAAC;AAED,2EAA2E;AAC3E,SAAS,cAAc,CAAC,KAAe;IACrC,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AACpE,CAAC;AAED;;;;;GAKG;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AC,CAAC;YAC9B,MAAM,SAAS,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACjC,MAAM,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC5B,MAAM,KAAK,GAAa,EAAE,CAAC;YAC3B,IAAI,GAAG,KAAK,YAAY;gBAAE,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;iBAC9C,IAAI,CAAC,GAAG;gBAAE,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YACzC,GAAG,CAAC,IAAI,CAAC;gBACP,MAAM;gBACN,KAAK,EAAE,KAAK,IAAI,SAAS;gBACzB,SAAS,EAAE,SAAS,IAAI,SAAS;gBACjC,GAAG,EAAE,GAAG,IAAI,SAAS;gBACrB,KAAK;aACN,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -56,6 +56,11 @@ What the device is, top-level constraints and budgets.
56
56
  Every part: refdes, MPN, value, package, and WHY it was chosen. MPNs the agent
57
57
  introduces without a datasheet check are flagged UNVERIFIED.
58
58
 
59
+ Value holds the component value only ("4.7uF", "1M", "500mAh Li-Po") — the
60
+ schematic stage draws it as the symbol's Value field, so a description there
61
+ collides with neighbouring symbols and fails the legibility gate. Prose belongs
62
+ in Rationale. One row per refdes; a grouped row ("C5-C8") matches no symbol.
63
+
59
64
  ${bomTable(symbols)}
60
65
  `,
61
66
  'PINOUT.md': `# Pinout
@@ -105,6 +110,7 @@ Generated by \`copperhead init\`; regenerated on re-runs (do not hand-edit).
105
110
  - \`maxRepairCycles\`: ERC/DRC repair attempts before rollback (default 5)
106
111
  - \`budgets\`: free-form hard constraints (e.g. \`"sleep_current_uA": 25\`); surfaced verbatim into every run's system prompt
107
112
  - \`generatedHashes\`: content hashes of generated docs, used to detect hand edits on re-init
113
+ - \`legibility\` (optional): schematic legibility checker tuning. \`legibility.thresholds\` accepts \`gridPitch\` (default 1.27mm), \`minPitch\` (2.54mm edge-to-edge between symbol bodies), \`utilization\` (0.5 of the usable frame), \`maxWireLength\` (50.8mm), and \`familyCap\` (10 findings per family per sheet). \`legibility.severity.<kind>\` overrides any check family to \`error\`, \`advisory\`, or \`off\` (disables it). Absent keys use the defaults; \`check\` reports findings without failing, the \`create\` schematic stage gates on error-severity findings. \`legibility.score.weights.<metric>\` and \`legibility.score.floor\` tune the quantitative scorer.
108
114
 
109
115
  ## constraints.json
110
116
 
@@ -1 +1 @@
1
- {"version":3,"file":"scaffold.js","sourceRoot":"","sources":["../../src/memory/scaffold.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,OAAO,EAAqC,MAAM,kBAAkB,CAAC;AAC3F,OAAO,EAAE,UAAU,EAAE,UAAU,EAAyB,MAAM,cAAc,CAAC;AAE7E,MAAM,OAAO,SAAU,SAAQ,KAAK;CAAG;AAQvC,MAAM,GAAG,GAAG,CAAC,CAAS,EAAU,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAEhF,KAAK,UAAU,cAAc,CAAC,UAAkB;IAC9C,IAAI,GAAG,GAAkB,IAAI,CAAC;IAC9B,IAAI,GAAG,GAAkB,IAAI,CAAC;IAC9B,KAAK,UAAU,IAAI,CAAC,GAAW;QAC7B,KAAK,MAAM,KAAK,IAAI,MAAM,OAAO,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;YAChE,IAAI,KAAK,CAAC,IAAI,CAAC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AC;IAC/D,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -15,6 +15,12 @@ const PATTERNS = [
15
15
  /npm_[A-Za-z0-9-]{36,}/g,
16
16
  /gh[pousr]_[A-Za-z0-9]{36,}/g,
17
17
  /github_pat_[A-Za-z0-9_]{22,}/g,
18
+ // Gemini and Groq keys: same idea as sk- above, just a different prefix.
19
+ // Real keys are AIza + 35 chars, but AIzaSy (the common fifth/sixth pair)
20
+ // isn't the only prefix Google issues - match on AIza alone so other
21
+ // Google keys aren't left unredacted.
22
+ /AIza[A-Za-z0-9_-]{20,}/g,
23
+ /gsk_[A-Za-z0-9]{20,}/g,
18
24
  ];
19
25
  export function redactSecrets(text) {
20
26
  let out = text;
@@ -1 +1 @@
1
- {"version":3,"file":"redact.js","sourceRoot":"","sources":["../../src/util/redact.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,QAAQ,GAAa;IACzB,oBAAoB;IACpB,+EAA+E;IAC/E,6EAA6E;IAC7E,gDAAgD;IAChD,mCAAmC;IACnC,6EAA6E;IAC7E,oEAAoE;IACpE,oEAAoE;IACpE,wBAAwB;IACxB,6BAA6B;IAC7B,+BAA+B;CAChC,CAAC;AAEF,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,IAAI,GAAG,GAAG,IAAI,CAAC;IACf,KAAK,MAAM,EAAE,IAAI,QAAQ;QAAE,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,EAAE,EAAE,YAAY,CAAC,CAAC;IAC/D,OAAO,GAAG,CAAC;AACb,CAAC"}
1
+ {"version":3,"file":"redact.js","sourceRoot":"","sources":["../../src/util/redact.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,QAAQ,GAAa;IACzB,oBAAoB;IACpB,+EAA+E;IAC/E,6EAA6E;IAC7E,gDAAgD;IAChD,mCAAmC;IACnC,6EAA6E;IAC7E,oEAAoE;IACpE,oEAAoE;IACpE,wBAAwB;IACxB,6BAA6B;IAC7B,+BAA+B;IAC/B,yEAAyE;IACzE,0EAA0E;IAC1E,qEAAqE;IACrE,sCAAsC;IACtC,yBAAyB;IACzB,uBAAuB;CACxB,CAAC;AAEF,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,IAAI,GAAG,GAAG,IAAI,CAAC;IACf,KAAK,MAAM,EAAE,IAAI,QAAQ;QAAE,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,EAAE,EAAE,YAAY,CAAC,CAAC;IAC/D,OAAO,GAAG,CAAC;AACb,CAAC"}
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "copperhead",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "Cursor for circuit boards: an AI agent that designs, documents, and validates real PCBs on KiCad repositories",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Animesh Chouhan <animeshchouhan@outlook.com>",
7
7
  "homepage": "https://copperhead.sh",
8
8
  "repository": {
9
9
  "type": "git",
10
- "url": "git+https://github.com/chouhanindustries/copperhead.git"
10
+ "url": "git+https://github.com/copperheadhq/copperhead.git"
11
11
  },
12
12
  "bugs": {
13
- "url": "https://github.com/chouhanindustries/copperhead/issues"
13
+ "url": "https://github.com/copperheadhq/copperhead/issues"
14
14
  },
15
15
  "keywords": [
16
16
  "kicad",
@@ -44,7 +44,8 @@
44
44
  "provenance": true
45
45
  },
46
46
  "scripts": {
47
- "build": "tsc -p tsconfig.json",
47
+ "build": "tsc -p tsconfig.json && npm run postbuild",
48
+ "postbuild": "node -e \"require('fs').chmodSync('dist/cli.js', 0o755)\"",
48
49
  "prepublishOnly": "npm run typecheck && npm run build",
49
50
  "dev": "tsx src/cli.ts",
50
51
  "demo:simple": "bash scripts/demo-simple.sh",
@@ -55,7 +56,9 @@
55
56
  "typecheck": "tsc -p tsconfig.json --noEmit",
56
57
  "docs:dev": "npm --prefix docs run dev",
57
58
  "docs:build": "npm --prefix docs run build",
58
- "docs:preview": "npm --prefix docs run preview"
59
+ "docs:preview": "npm --prefix docs run preview",
60
+ "refboards": "bash scripts/draft-reference-boards.sh",
61
+ "realdesigns": "tsx scripts/draft-real-designs.ts"
59
62
  },
60
63
  "dependencies": {
61
64
  "@anthropic-ai/sdk": "^0.113.0",
@@ -64,8 +67,7 @@
64
67
  "openai": "^6.49.0"
65
68
  },
66
69
  "optionalDependencies": {
67
- "@anthropic-ai/claude-agent-sdk": "^0.3.217",
68
- "@maximem/synap-js-sdk": "^0.3.0"
70
+ "@anthropic-ai/claude-agent-sdk": "^0.3.217"
69
71
  },
70
72
  "devDependencies": {
71
73
  "@openai/codex-sdk": "^0.144.6",
@@ -75,6 +75,31 @@ export interface SearchMatch {
75
75
 
76
76
  const SKIP_DIRS = new Set(['.git', 'node_modules', 'dist', '.copperhead']);
77
77
 
78
+ /**
79
+ * Longest match line returned to the model, in characters.
80
+ *
81
+ * The file-size bound in `toolSearch` (5 MB) bounds the file, not the line, and
82
+ * on a one-object-per-line document those are very different limits. A
83
+ * `transcript.jsonl` line is an entire `{ts, type, data}` record with tool
84
+ * output inline, so a few matches inside one file can be hundreds of thousands
85
+ * of tokens. A live run died on exactly that — `Prompt is too long · the
86
+ * request is ~1003121 tokens (limit 1000000) but this conversation is only
87
+ * ~403383 tokens`, the balance being search results — and it cost a stage
88
+ * attempt. The agent had done nothing wrong: it searched the repo it was told
89
+ * to work in, and a `run-logs/` directory happened to be sitting in it.
90
+ *
91
+ * A match is a pointer, not a payload — enough to see the hit and decide
92
+ * whether to read the file. Truncation is marked so a clipped line is
93
+ * distinguishable from a short one.
94
+ */
95
+ const MAX_MATCH_CHARS = 400;
96
+
97
+ /** Clip one match line to `MAX_MATCH_CHARS`, marking it when clipped. */
98
+ function clipMatch(line: string): string {
99
+ const t = line.trim();
100
+ return t.length <= MAX_MATCH_CHARS ? t : `${t.slice(0, MAX_MATCH_CHARS)}… [+${t.length - MAX_MATCH_CHARS} chars]`;
101
+ }
102
+
78
103
  export function globToRegex(glob: string): RegExp {
79
104
  let out = '';
80
105
  for (let i = 0; i < glob.length; i++) {
@@ -125,7 +150,7 @@ export async function toolSearch(
125
150
  if (text.includes('\u0000')) continue; // binary
126
151
  const lines = text.split('\n');
127
152
  for (let i = 0; i < lines.length && matches.length < maxMatches; i++) {
128
- if (re.test(lines[i]!)) matches.push({ file: rel, line: i + 1, text: lines[i]!.trim() });
153
+ if (re.test(lines[i]!)) matches.push({ file: rel, line: i + 1, text: clipMatch(lines[i]!) });
129
154
  }
130
155
  }
131
156
  if (matches.length >= maxMatches) return;
@@ -7,6 +7,7 @@ export type ObligationKind =
7
7
  | 'erc'
8
8
  | 'drc'
9
9
  | 'drift'
10
+ | 'legibility'
10
11
  | 'changelog'
11
12
  | 'decision-log'
12
13
  | 'constraint-dual-write'
@@ -21,6 +22,18 @@ export interface Obligation {
21
22
  export class ObligationsLedger {
22
23
  private open: Obligation[] = [];
23
24
 
25
+ /**
26
+ * @param gateLegibility whether error-severity legibility findings block
27
+ * `finish`. True for repos whose schematic copperhead authored (create
28
+ * origin) — there the standard is copperhead's own responsibility. False for
29
+ * hand-drawn repos (`do` on an init-ed or hand-maintained project), where a
30
+ * pre-existing sheet could never satisfy the standard without a full redraw
31
+ * and the obligation would wedge every schematic-touching run; those repos
32
+ * get the same findings as advisory information via the tool and `check`
33
+ * (design C6: check reports, create gates).
34
+ */
35
+ constructor(private readonly gateLegibility = true) {}
36
+
24
37
  add(kind: ObligationKind, detail: string, openedBy: string): void {
25
38
  if (!this.open.some((o) => o.kind === kind && o.detail === detail)) {
26
39
  this.open.push({ kind, detail, openedBy });
@@ -45,6 +58,9 @@ export class ObligationsLedger {
45
58
  onKicadEdit(file: string): void {
46
59
  this.add('erc', 'ERC must pass after schematic edits', file);
47
60
  if (file.endsWith('.kicad_pcb')) this.add('drc', 'DRC must pass after board edits', file);
61
+ if (file.endsWith('.kicad_sch') && this.gateLegibility) {
62
+ this.add('legibility', 'check_legibility must run clean after schematic edits', file);
63
+ }
48
64
  this.add('drift', 'check_drift must run clean after KiCad edits', file);
49
65
  this.add('changelog', 'CHANGELOG.md entry for this run', file);
50
66
  }
@@ -53,6 +69,14 @@ export class ObligationsLedger {
53
69
  this.add('drift', 'check_drift must run clean after doc edits', file);
54
70
  }
55
71
 
72
+ /** A checker run updates the obligation: clean clears it, errors re-open it (gated repos only). */
73
+ onLegibilityResult(errorCount: number): void {
74
+ this.clear('legibility');
75
+ if (errorCount > 0 && this.gateLegibility) {
76
+ this.add('legibility', `${errorCount} error-severity legibility finding(s) unreconciled`, 'check_legibility');
77
+ }
78
+ }
79
+
56
80
  onConstraintChange(constraintKey: string, affects: string[]): void {
57
81
  this.add('constraint-dual-write', constraintKey, constraintKey);
58
82
  for (const item of affects) {
package/src/agent/loop.ts CHANGED
@@ -7,6 +7,7 @@ import { CachingProvider } from './response-cache.js';
7
7
  import { withTimeout, TurnTimeoutError } from './recovery.js';
8
8
  import { buildSystemPrompt } from './prompts.js';
9
9
  import { loadConstraints, reopenDeferredAffects } from '../memory/constraints.js';
10
+ import { isCreateProducedRepo, isEngineAuthoredSchematic } from '../kicad/fab.js';
10
11
  import {
11
12
  loadConfig,
12
13
  CONFIG_DIR,
@@ -30,7 +31,6 @@ import { AnthropicProvider } from './providers/anthropic.js';
30
31
  import { CodexProvider } from './providers/codex.js';
31
32
  import { ClaudeCodeProvider } from './providers/claude-code.js';
32
33
  import { CursorProvider } from './providers/cursor.js';
33
- import { openSynapMemory, type RunRecord, type SynapMemory } from '../memory/synap.js';
34
34
 
35
35
  /** What the user sees at the moment they decide whether to keep going. */
36
36
  export interface BudgetExhaustedStats {
@@ -202,16 +202,10 @@ async function appendChangelog(
202
202
  await writeFile(p, lines.join('\n'), 'utf8');
203
203
  }
204
204
 
205
- /**
206
- * Owns the Synap session for one run. The bridge is a subprocess, so the
207
- * shutdown in `finally` is what lets the CLI exit; without it the process
208
- * hangs after a successful run.
209
- */
210
205
  export async function runAgentLoop(opts: RunOptions): Promise<RunResult> {
211
- const memory = await openSynapMemory({ repoRoot: opts.repoRoot, log: opts.log });
212
206
  const providers = new Set<Provider>();
213
207
  try {
214
- return await runWithMemory(opts, memory, providers);
208
+ return await runWithProviders(opts, providers);
215
209
  } finally {
216
210
  for (const provider of providers) {
217
211
  try {
@@ -220,15 +214,10 @@ export async function runAgentLoop(opts: RunOptions): Promise<RunResult> {
220
214
  opts.log?.(`warning: ${provider.name} provider cleanup failed (${(err as Error).message})`);
221
215
  }
222
216
  }
223
- await memory?.close();
224
217
  }
225
218
  }
226
219
 
227
- async function runWithMemory(
228
- opts: RunOptions,
229
- memory: SynapMemory | null,
230
- providers: Set<Provider>,
231
- ): Promise<RunResult> {
220
+ async function runWithProviders(opts: RunOptions, providers: Set<Provider>): Promise<RunResult> {
232
221
  const r = opts.renderer ?? plainRenderer(opts.log ?? ((l: string) => console.log(l)));
233
222
  const log = (l: string): void => r.log(l);
234
223
  const repoRoot = opts.repoRoot;
@@ -240,11 +229,28 @@ async function runWithMemory(
240
229
 
241
230
  const transcript = new Transcript(repoRoot);
242
231
  await transcript.init();
232
+ // Legibility gates finish only where copperhead authored the sheet; a
233
+ // hand-drawn repo gets findings as information, never as a wedge (C6).
234
+ // Both conditions matter: the create-origin marker scopes the gate to repos
235
+ // this tool produced, and the generator stamp scopes it to sheets copperhead
236
+ // still owns. A human taking the sheet over in KiCad re-saves it under
237
+ // KiCad's generator, and from then on the gate must not defend a drawing
238
+ // the engine can no longer regenerate. A create repo whose schematic is not
239
+ // yet scaffolded keeps the gate: the sheet stage 4 will produce is
240
+ // copperhead-authored by construction.
241
+ let gateLegibility = isCreateProducedRepo(config);
242
+ if (gateLegibility && config.schematic) {
243
+ try {
244
+ gateLegibility = isEngineAuthoredSchematic(await readFile(path.join(repoRoot, config.schematic), 'utf8'));
245
+ } catch {
246
+ // schematic configured but absent (pre-scaffold): keep the gate
247
+ }
248
+ }
243
249
  const ctx: RunContext = {
244
250
  repoRoot,
245
251
  config,
246
252
  transcript,
247
- ledger: new ObligationsLedger(),
253
+ ledger: new ObligationsLedger(gateLegibility),
248
254
  runId: path.basename(transcript.dir),
249
255
  interactive: opts.interactive ?? false,
250
256
  confirm: opts.confirm ?? (async () => true),
@@ -254,6 +260,8 @@ async function runWithMemory(
254
260
  filesTouched: new Set(),
255
261
  decisions: [],
256
262
  lastErc: null,
263
+ lastLegibility: null,
264
+ lastScore: null,
257
265
  lastDrc: null,
258
266
  repairCycles: 0,
259
267
  finishRequest: null,
@@ -328,37 +336,12 @@ async function runWithMemory(
328
336
  ...reopened.map((r) => `- ${r.key} affects ${r.item}`),
329
337
  ].join('\n');
330
338
  }
331
- // Cross-run memory is appended after the repo's own docs and constraints so
332
- // that the in-repo sources of truth are what the model reads first.
333
- const recalled = memory ? await memory.recall(opts.request) : null;
334
- if (recalled) {
335
- await transcript.event('synap-recall', { chars: recalled.length });
336
- log('recalled prior context from Synap memory');
337
- }
338
- const system = recalled ? `${basePrompt}\n\n${recalled}` : basePrompt;
339
339
  const messages: Msg[] = [
340
- { role: 'system', content: system },
340
+ { role: 'system', content: basePrompt },
341
341
  { role: 'user', content: opts.stagePrompt ? `${opts.stagePrompt}\n\nRequest: ${opts.request}` : opts.request },
342
342
  ];
343
343
  await transcript.event('run-start', meta);
344
344
 
345
- /**
346
- * A memory write that fails is reported rather than swallowed, but it does
347
- * not change the run's outcome: discarding a verified commit because a
348
- * third-party write failed would be the worse trade.
349
- */
350
- const remember = async (run: RunRecord): Promise<void> => {
351
- if (!memory) return;
352
- try {
353
- await memory.record(run);
354
- await transcript.event('synap-record', { outcome: run.outcome });
355
- } catch (err) {
356
- const message = (err as Error).message;
357
- log(`warning: Synap memory write failed (${message}); this run was not recorded`);
358
- await transcript.event('synap-record-failed', { error: message });
359
- }
360
- };
361
-
362
345
  let tokensIn = 0;
363
346
  let tokensOut = 0;
364
347
  let turnsUsed = 0;
@@ -416,6 +399,8 @@ async function runWithMemory(
416
399
  filesTouched: [...ctx.filesTouched],
417
400
  ercResult: ctx.lastErc ? (ctx.lastErc.ok ? 'clean' : `${ctx.lastErc.violations.length} violations`) : null,
418
401
  drcResult: ctx.lastDrc ? (ctx.lastDrc.ok ? 'clean' : `${ctx.lastDrc.violations.length} violations`) : null,
402
+ legibilityResult: ctx.lastLegibility ? `${ctx.lastLegibility.error} error, ${ctx.lastLegibility.advisory} advisory` : null,
403
+ scoreResult: ctx.lastScore !== null ? `${ctx.lastScore}/100` : null,
419
404
  decisions: ctx.decisions,
420
405
  tokensIn,
421
406
  tokensOut,
@@ -648,17 +633,6 @@ async function runWithMemory(
648
633
  env: meta,
649
634
  stats: runStats,
650
635
  });
651
- // Refusals are the most valuable thing to remember: they encode a budget
652
- // or constraint that this user's designs keep running into.
653
- await remember({
654
- request: opts.request,
655
- outcome: 'refused',
656
- summary,
657
- changeId: ctx.changeId,
658
- filesTouched: [],
659
- decisions: ctx.decisions,
660
- verification: 'n/a (refused before verification)',
661
- });
662
636
  log(`refused: ${summary}`);
663
637
  r.finish(outcomeLine(runStats));
664
638
  return {
@@ -777,6 +751,8 @@ async function runWithMemory(
777
751
  filesTouched: files,
778
752
  ercResult: ctx.lastErc ? (ctx.lastErc.ok ? 'clean' : 'FAILING') : 'not run',
779
753
  drcResult: ctx.lastDrc ? (ctx.lastDrc.ok ? 'clean' : 'FAILING') : 'not run',
754
+ legibilityResult: ctx.lastLegibility ? `${ctx.lastLegibility.error} error, ${ctx.lastLegibility.advisory} advisory` : null,
755
+ scoreResult: ctx.lastScore !== null ? `${ctx.lastScore}/100` : null,
780
756
  decisions: ctx.decisions,
781
757
  tokensIn,
782
758
  tokensOut,
@@ -785,15 +761,6 @@ async function runWithMemory(
785
761
  env: meta,
786
762
  stats: runStats,
787
763
  });
788
- await remember({
789
- request: opts.request,
790
- outcome: 'success',
791
- summary,
792
- changeId: ctx.changeId,
793
- filesTouched: files,
794
- decisions: ctx.decisions,
795
- verification,
796
- });
797
764
  log(`committed ${commit.slice(0, 10)} (${files.length} file(s))`);
798
765
  r.finish(outcomeLine(runStats, `committed ${commit.slice(0, 10)}`));
799
766
  return {
@@ -19,9 +19,10 @@ const WORKFLOW = `Workflow for every run:
19
19
  2. Call propose_change with a change id (kebab-case), why, what changes, and tasks. Then call validate_change. Edit tools (edit_file, write_file) unlock only after validation passes.
20
20
  3. Make the edits. Use the exact same net names and refdes everywhere. For .kicad_sch/.kicad_pcb use edit_file with unique anchors from the actual file text (read the file first). For renaming a net or refdes across a file, one edit_file call with replace_all: true beats many small edits.
21
21
  4. Run run_erc after schematic edits (and run_drc after board edits). If violations: read them, fix, re-run.
22
- 5. Run check_drift; update any doc that references a changed value/part/pin in the same run.
23
- 6. Record every non-trivial decision with record_decision, and every stated/assumed/discovered constraint with record_constraint.
24
- 7. Call finish with outcome "done" when everything is verified, or outcome "refuse" (citing the violated budget/constraint) if the request should not be done. finish will list any unmet obligations; resolve them and call it again.
22
+ 5. After schematic edits also run check_legibility and reconcile every error-severity finding (advisories inform, they do not block). An electrically correct sheet that reads badly is not done: finish refuses while error findings are outstanding, the same way it refuses on a failing ERC.
23
+ 6. Run check_drift; update any doc that references a changed value/part/pin in the same run.
24
+ 7. Record every non-trivial decision with record_decision, and every stated/assumed/discovered constraint with record_constraint.
25
+ 8. Call finish with outcome "done" when everything is verified, or outcome "refuse" (citing the violated budget/constraint) if the request should not be done. finish will list any unmet obligations; resolve them and call it again.
25
26
 
26
27
  Turns are the scarce resource, not tool calls: the run has a hard turn budget, and every tool call in one reply executes in the same turn. When calls are independent — multiple record_constraint or resolve_affected calls (use resolutions: [...] to clear a backlog in one call), several read_file calls — issue them together in a single reply instead of one per turn.
27
28
  Always send a populated \`args\` object that matches the tool's JSON Schema (e.g. read_file needs {"path": "..."}). Never open a stage with an empty-args call to probe a tool — it only returns an error and burns a whole turn.`;
@@ -85,9 +85,14 @@ export interface ParsedToolTurn {
85
85
  * split so only an inner `{args}` with no `tool` key balanced), not the tool
86
86
  * being broken. Returns a one-line steer to re-emit it, or undefined when the
87
87
  * absence of a call is genuine (plain prose, no tool named).
88
+ *
89
+ * Also covers the mirror case (I18): well-formed JSON naming a tool that is NOT in
90
+ * the catalog — withheld by the edit lock, or invented. That call is correctly not
91
+ * dispatched, but it must not be silent either.
88
92
  */
89
93
  function detectMalformedCall(text: string, catalog: Set<string>): string | undefined {
90
94
  const re = /"tool"\s*:\s*"([^"]+)"/g;
95
+ const offCatalog: string[] = [];
91
96
  let m: RegExpExecArray | null;
92
97
  while ((m = re.exec(text)) !== null) {
93
98
  const name = m[1]!;
@@ -98,6 +103,23 @@ function detectMalformedCall(text: string, catalog: Set<string>): string | undef
98
103
  'Re-emit it as exactly one complete JSON object: {"tool": "...", "args": { ... }}.'
99
104
  );
100
105
  }
106
+ if (!offCatalog.includes(name)) offCatalog.push(name);
107
+ }
108
+ // A well-formed call naming a tool the turn did not advertise — a locked edit or
109
+ // drafting tool before propose_change/validate_change, or an invented name.
110
+ // `toToolCall` is right to refuse it (the lock is structural, D2), but dropping it
111
+ // to prose tells the model NOTHING, and it fills that silence: fabricating the
112
+ // result it never got (I15), or concluding the engine is absent from the build and
113
+ // refusing the stage outright (I18). Withholding the tool is the invariant; hiding
114
+ // the reason never was, so name it and print the real catalog.
115
+ if (offCatalog.length) {
116
+ const named = offCatalog.map((n) => `"${n}"`).join(', ');
117
+ return (
118
+ `No call ran: ${named} ${offCatalog.length > 1 ? 'are' : 'is'} not in this turn's tool ` +
119
+ 'catalog. Edit and drafting tools are withheld until a proposal validates — call ' +
120
+ 'propose_change, then validate_change, and they appear. Do not conclude a tool is ' +
121
+ `missing from the build. Available this turn: ${[...catalog].join(', ')}.`
122
+ );
101
123
  }
102
124
  return undefined;
103
125
  }