codehere 1.0.1 → 1.0.2

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 (163) hide show
  1. package/README.md +36 -192
  2. package/dist/application/use-cases/check-claimed-tests.js +81 -0
  3. package/dist/application/use-cases/detect-test-weakening.js +237 -0
  4. package/dist/application/use-cases/rerun-tests.js +110 -7
  5. package/dist/index.js +38 -1212
  6. package/dist/infrastructure/orchestration/artifacts-extractor.js +2 -323
  7. package/dist/presentation/cli/commands/check-command.js +178 -23
  8. package/dist/presentation/cli/commands/help-command.js +21 -285
  9. package/dist/ui.js +5 -236
  10. package/dist/utils/version.js +0 -6
  11. package/package.json +9 -38
  12. package/dist/application/services/verdict-service.js +0 -154
  13. package/dist/application/use-cases/assess-cross-vendor.js +0 -126
  14. package/dist/application/use-cases/build-cross-vendor-verdict.js +0 -118
  15. package/dist/application/use-cases/domain-trust.js +0 -110
  16. package/dist/application/use-cases/export-aat.js +0 -107
  17. package/dist/application/use-cases/generate-acceptance-criteria.js +0 -223
  18. package/dist/application/use-cases/generate-final-report.js +0 -259
  19. package/dist/application/use-cases/generate-narration.js +0 -130
  20. package/dist/application/use-cases/generate-thread-title.js +0 -181
  21. package/dist/application/use-cases/narrator-prompt-template.js +0 -158
  22. package/dist/application/use-cases/plan-auto-review.js +0 -57
  23. package/dist/application/use-cases/reconcile-audit.js +0 -100
  24. package/dist/application/use-cases/search-sessions.js +0 -70
  25. package/dist/application/use-cases/should-auto-review.js +0 -71
  26. package/dist/application/use-cases/thread-export.js +0 -245
  27. package/dist/application/use-cases/verify-claim.js +0 -456
  28. package/dist/application/use-cases/write-pass.js +0 -277
  29. package/dist/domain/audit.js +0 -11
  30. package/dist/domain/services/codebase-detector.js +0 -85
  31. package/dist/domain/task.js +0 -91
  32. package/dist/error-handler.js +0 -139
  33. package/dist/infrastructure/completion/bash-completion.js +0 -29
  34. package/dist/infrastructure/completion/fish-completion.js +0 -17
  35. package/dist/infrastructure/completion/zsh-completion.js +0 -25
  36. package/dist/infrastructure/config/config-manager.js +0 -174
  37. package/dist/infrastructure/config/product-context.js +0 -49
  38. package/dist/infrastructure/context/adapters/drawio-source.js +0 -157
  39. package/dist/infrastructure/context/adapters/figma-source.js +0 -198
  40. package/dist/infrastructure/context/adapters/github-issue-source.js +0 -160
  41. package/dist/infrastructure/context/adapters/linear-source.js +0 -190
  42. package/dist/infrastructure/context/context-resolver.js +0 -144
  43. package/dist/infrastructure/context/context-source.js +0 -114
  44. package/dist/infrastructure/context/github-api.js +0 -110
  45. package/dist/infrastructure/context/github-device-flow.js +0 -65
  46. package/dist/infrastructure/context/oauth-flow.js +0 -207
  47. package/dist/infrastructure/context/oauth-store.js +0 -122
  48. package/dist/infrastructure/context/registry-bootstrap.js +0 -95
  49. package/dist/infrastructure/context/write-pass-resolver.js +0 -106
  50. package/dist/infrastructure/cost/budget-config.js +0 -114
  51. package/dist/infrastructure/cost/cost-router.js +0 -97
  52. package/dist/infrastructure/cost/spend-aggregator.js +0 -222
  53. package/dist/infrastructure/cost/team-ledger.js +0 -355
  54. package/dist/infrastructure/discovery/discovery-log.js +0 -85
  55. package/dist/infrastructure/hooks/audit-tip-signature.js +0 -336
  56. package/dist/infrastructure/hooks/claude-sdk-hook.js +0 -1018
  57. package/dist/infrastructure/hooks/hook-mode.js +0 -87
  58. package/dist/infrastructure/hooks/mirror-tool-call-to-audit.js +0 -49
  59. package/dist/infrastructure/hooks/pre-prompt-scan.js +0 -122
  60. package/dist/infrastructure/hooks/session-analyzer.js +0 -177
  61. package/dist/infrastructure/observability/execution-tracer.js +0 -227
  62. package/dist/infrastructure/orchestration/agent-adapter.js +0 -13
  63. package/dist/infrastructure/orchestration/agent-installer.js +0 -101
  64. package/dist/infrastructure/orchestration/agents-config-seed.js +0 -68
  65. package/dist/infrastructure/orchestration/aider-adapter.js +0 -611
  66. package/dist/infrastructure/orchestration/cassette-recorder.js +0 -120
  67. package/dist/infrastructure/orchestration/claude-code-adapter.js +0 -592
  68. package/dist/infrastructure/orchestration/codex-adapter.js +0 -574
  69. package/dist/infrastructure/orchestration/conductor-adapter.js +0 -416
  70. package/dist/infrastructure/orchestration/context-handoff.js +0 -162
  71. package/dist/infrastructure/orchestration/control/codex-control-surface.js +0 -99
  72. package/dist/infrastructure/orchestration/control/control-surface.js +0 -15
  73. package/dist/infrastructure/orchestration/detect-ollama.js +0 -75
  74. package/dist/infrastructure/orchestration/failover-classifier.js +0 -151
  75. package/dist/infrastructure/orchestration/failover-config.js +0 -67
  76. package/dist/infrastructure/orchestration/failover-policy.js +0 -106
  77. package/dist/infrastructure/orchestration/gemini-adapter.js +0 -663
  78. package/dist/infrastructure/orchestration/generic-cli-adapter.js +0 -689
  79. package/dist/infrastructure/orchestration/graphify-context.js +0 -209
  80. package/dist/infrastructure/orchestration/memory-injector.js +0 -380
  81. package/dist/infrastructure/orchestration/mocks/mock-agent-repl.js +0 -388
  82. package/dist/infrastructure/orchestration/mocks/mock-codex-app-server.js +0 -73
  83. package/dist/infrastructure/orchestration/mocks/mock-synthesis.js +0 -83
  84. package/dist/infrastructure/orchestration/mocks/resolve-agent-spawn.js +0 -37
  85. package/dist/infrastructure/orchestration/opencode-adapter.js +0 -580
  86. package/dist/infrastructure/orchestration/progress-aggregator.js +0 -906
  87. package/dist/infrastructure/orchestration/readiness.js +0 -103
  88. package/dist/infrastructure/orchestration/session-manager.js +0 -1590
  89. package/dist/infrastructure/orchestration/session-persistence.js +0 -394
  90. package/dist/infrastructure/orchestration/thread-key-store.js +0 -127
  91. package/dist/infrastructure/orchestration/write-pass-store.js +0 -38
  92. package/dist/infrastructure/protocols/cloud-sync.js +0 -207
  93. package/dist/infrastructure/protocols/mcp-helpers.js +0 -25
  94. package/dist/infrastructure/protocols/mcp-server-impl.js +0 -3935
  95. package/dist/infrastructure/protocols/mcp-tools.js +0 -401
  96. package/dist/infrastructure/protocols/probe-port.js +0 -36
  97. package/dist/infrastructure/protocols/thread-phase.js +0 -105
  98. package/dist/infrastructure/protocols/ui/app-script-artifacts.js +0 -121
  99. package/dist/infrastructure/protocols/ui/app-script-audit-footer.js +0 -44
  100. package/dist/infrastructure/protocols/ui/app-script-audit-verify.js +0 -56
  101. package/dist/infrastructure/protocols/ui/app-script-composer-cost.js +0 -588
  102. package/dist/infrastructure/protocols/ui/app-script-context-sources.js +0 -168
  103. package/dist/infrastructure/protocols/ui/app-script-conversation.js +0 -67
  104. package/dist/infrastructure/protocols/ui/app-script-drawer.js +0 -115
  105. package/dist/infrastructure/protocols/ui/app-script-failover.js +0 -133
  106. package/dist/infrastructure/protocols/ui/app-script-github.js +0 -113
  107. package/dist/infrastructure/protocols/ui/app-script-observer.js +0 -104
  108. package/dist/infrastructure/protocols/ui/app-script-onboarding.js +0 -80
  109. package/dist/infrastructure/protocols/ui/app-script-overlay.js +0 -203
  110. package/dist/infrastructure/protocols/ui/app-script-recovery.js +0 -136
  111. package/dist/infrastructure/protocols/ui/app-script-render.js +0 -166
  112. package/dist/infrastructure/protocols/ui/app-script-share.js +0 -78
  113. package/dist/infrastructure/protocols/ui/app-script-sidebar.js +0 -194
  114. package/dist/infrastructure/protocols/ui/app-script-tour.js +0 -78
  115. package/dist/infrastructure/protocols/ui/app-script-wpass.js +0 -312
  116. package/dist/infrastructure/protocols/ui/app-script.js +0 -2998
  117. package/dist/infrastructure/protocols/ui/font-faces.js +0 -7
  118. package/dist/infrastructure/protocols/ui/styles.js +0 -2147
  119. package/dist/infrastructure/protocols/ui/tokens.js +0 -96
  120. package/dist/infrastructure/protocols/ui-page-v2.js +0 -320
  121. package/dist/infrastructure/protocols/verify-page.js +0 -1677
  122. package/dist/infrastructure/security/file-collection.js +0 -118
  123. package/dist/infrastructure/security/fix-code.js +0 -144
  124. package/dist/infrastructure/security/fix-secret.js +0 -89
  125. package/dist/infrastructure/security/permissions-config.js +0 -235
  126. package/dist/infrastructure/security/scan-types.js +0 -10
  127. package/dist/infrastructure/security/ship-scan.js +0 -195
  128. package/dist/infrastructure/security/trust-scorer.js +0 -724
  129. package/dist/infrastructure/security/vibe-checks.js +0 -99
  130. package/dist/infrastructure/storage/atomic-write.js +0 -86
  131. package/dist/infrastructure/storage/cross-tool-agents.js +0 -268
  132. package/dist/infrastructure/storage/project-thread-migration.js +0 -237
  133. package/dist/infrastructure/storage/project-thread-mirror.js +0 -671
  134. package/dist/infrastructure/storage/project-thread-reader.js +0 -409
  135. package/dist/infrastructure/storage/project-thread-title-backfill.js +0 -214
  136. package/dist/monitoring.js +0 -212
  137. package/dist/presentation/cli/commands/audit-command.js +0 -201
  138. package/dist/presentation/cli/commands/budget-command.js +0 -79
  139. package/dist/presentation/cli/commands/config-command.js +0 -125
  140. package/dist/presentation/cli/commands/context-source-command.js +0 -217
  141. package/dist/presentation/cli/commands/hook-command.js +0 -265
  142. package/dist/presentation/cli/commands/init-command.js +0 -590
  143. package/dist/presentation/cli/commands/memory-command.js +0 -1031
  144. package/dist/presentation/cli/commands/narrator-command.js +0 -101
  145. package/dist/presentation/cli/commands/permission-command.js +0 -105
  146. package/dist/presentation/cli/commands/protocols-builder.js +0 -254
  147. package/dist/presentation/cli/commands/protocols-command.js +0 -84
  148. package/dist/presentation/cli/commands/repo-map-builder.js +0 -247
  149. package/dist/presentation/cli/commands/report-command.js +0 -403
  150. package/dist/presentation/cli/commands/scan-command.js +0 -52
  151. package/dist/presentation/cli/commands/scan-tool-command.js +0 -110
  152. package/dist/presentation/cli/commands/search-command.js +0 -51
  153. package/dist/presentation/cli/commands/setup-command.js +0 -330
  154. package/dist/presentation/cli/commands/status-command.js +0 -614
  155. package/dist/presentation/cli/commands/team-command.js +0 -256
  156. package/dist/presentation/cli/commands/thread-command.js +0 -370
  157. package/dist/presentation/cli/commands/trust-command.js +0 -328
  158. package/dist/presentation/cli/commands/verify-command.js +0 -298
  159. package/dist/presentation/cli/error-display.js +0 -328
  160. package/dist/presentation/cli/repl.js +0 -805
  161. package/dist/presentation/cli/task-deliverable.js +0 -153
  162. package/dist/testing/cassette.js +0 -125
  163. package/dist/testing/replay-adapter.js +0 -147
@@ -1,121 +0,0 @@
1
- /**
2
- * Structured artifacts — the comparison table, response mock and recommendation pick an agent
3
- * produces, rendered from a typed data array rather than hand-authored HTML, plus the JSON
4
- * tinting they use.
5
- *
6
- * Split out of app-script.ts (strangler fig, split 15). Verbatim slice, interpolated back where
7
- * it was cut so it keeps sharing the surrounding IIFE scope. Verified by hashing the composed
8
- * APP_SCRIPT before and after: same bytes.
9
- *
10
- * The primitive is real: these render from `t.artifacts.structured[]`, so what you see is what
11
- * the adapter actually emitted. That is the difference between a demo and a record.
12
- */
13
- export const ARTIFACTS = `// Structured artifacts · render the comparison table / response mock /
14
- // recommendation pick that an agent produces, from a typed data array — NOT
15
- // hand-authored HTML. The demo v12 weaves these into Phase 1; here they render
16
- // from t.artifacts.structured[] so the primitive is real (seeded today, real
17
- // adapter output later · demo-synth pattern).
18
- function renderArtifacts(arr){
19
- if(!Array.isArray(arr)||!arr.length)return'';
20
- function he(s){ return String(s==null?'':s).replace(/[&<>"]/g, c=>({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;'}[c])); }
21
- function tintJson(raw){
22
- return he(raw)
23
- .replace(/&quot;([^&]*?)&quot;(\\s*:)/g, '<span class="jk">&quot;$1&quot;</span>$2')
24
- .replace(/:\\s*&quot;([^&]*?)&quot;/g, ': <span class="js">&quot;$1&quot;</span>')
25
- .replace(/:\\s*(-?\\d+(?:\\.\\d+)?)/g, ': <span class="jn">$1</span>');
26
- }
27
- let out='<div class="panel"><div class="panel-title">Artifacts produced</div>';
28
- for(const a of arr){
29
- if(a.type==='comparison'){
30
- const cols=a.columns||[];
31
- let g='<div class="art-cmp" style="grid-template-columns:130px repeat('+cols.length+',1fr)">';
32
- g+='<div class="hd"></div>'+cols.map(c=>'<div class="hd">'+he(c)+'</div>').join('');
33
- for(const r of (a.rows||[])){
34
- g+='<div class="rl">'+he(r.label)+'</div>';
35
- for(const cell of (r.cells||[])){
36
- const mk = cell.mark==='pick'?'pick':cell.mark==='meh'?'meh':'';
37
- g+='<div class="cell">'+(mk?'<span class="'+mk+'">'+he(cell.text)+'</span>':he(cell.text))+'</div>';
38
- }
39
- }
40
- g+='</div>';
41
- out+='<div class="artifact-card" data-user-content>'+(a.title?'<div class="artifact-h">'+he(a.title)+'</div>':'')+g+'</div>';
42
- } else if(a.type==='mock'){
43
- out+='<div class="art-mock">'
44
- +'<div class="art-mock-head"><span class="status">'+he(a.status||'')+'</span>'+(a.contentType?'<span class="ct">'+he(a.contentType)+'</span>':'')+'</div>'
45
- +'<div class="art-mock-body">'+tintJson(a.body||'')+'</div>'
46
- +'</div>';
47
- } else if(a.type==='pick'){
48
- out+='<div class="art-pick">'
49
- +'<div class="k">'+he(a.title||'')+'</div>'
50
- +(a.what?'<div class="what">'+he(a.what)+'</div>':'')
51
- +(a.why?'<div class="why">'+he(a.why)+'</div>':'')
52
- +'</div>';
53
- } else if(a.type==='bench'){
54
- // Benchmark chart · horizontal bars · demo v12 .bench (phase audit 2.10)
55
- let rows=(a.rows||[]).map(function(r){
56
- const mk=r.mark==='allow'?' allow':r.mark==='warn'?' warn':'';
57
- const pct=Math.max(0,Math.min(100,Number(r.pct)||0));
58
- return '<div class="art-bench"><span class="bl">'+he(r.label)+'</span>'
59
- +'<span class="bb"><span class="bf'+mk+'" style="width:'+pct+'%"></span></span>'
60
- +'<span class="bv">'+he(r.value)+'</span></div>';
61
- }).join('');
62
- out+='<div class="artifact-card" data-user-content>'+(a.title?'<div class="artifact-h">'+he(a.title)+'</div>':'')+rows+'</div>';
63
- } else if(a.type==='checklist'){
64
- // Verifier severity grid · ✓/⚠ per check · demo v12 (phase audit 4.4/3.3)
65
- let items=(a.items||[]).map(function(it){
66
- const ok=it.ok!==false;
67
- return '<div class="art-check'+(ok?'':' warn')+'">'
68
- +'<span class="ci">'+(ok?'\\u2713':'\\u26A0')+'</span>'
69
- +'<span class="cl">'+he(it.label)+'</span>'
70
- +(it.note?'<span class="cn">'+he(it.note)+'</span>':'')
71
- +'</div>';
72
- }).join('');
73
- out+='<div class="artifact-card" data-user-content>'+(a.title?'<div class="artifact-h">'+he(a.title)+'</div>':'')+'<div class="art-checklist">'+items+'</div></div>';
74
- } else if(a.type==='sequence'){
75
- // Sequence diagram · inline SVG · auto-layout actors + messages from a typed
76
- // directive — NOT hand-authored SVG (demo v12 Artifact 2 · phase audit 1.13 · C-13).
77
- const parts=(a.participants||[]).map(String);
78
- const msgs=a.messages||[];
79
- const n=parts.length;
80
- if(n>=2){
81
- const colW=148, padX=14, padTop=12, boxH=26, headGap=20, rowH=34, padBot=16, loopW=42;
82
- const cx=i=>padX+74+colW*i; // center x of lifeline i
83
- const w=padX*2+148+colW*(n-1)+loopW; // right margin covers a trailing self-loop
84
- const topY=padTop+boxH;
85
- const h=topY+headGap+rowH*msgs.length+padBot;
86
- const cls=m=>m.mark==='allow'?'allow':m.mark==='warn'?'warn':m.ret?'ret':'';
87
- const head=m=>m.mark==='allow'?'ah-allow':m.mark==='warn'?'ah-warn':m.ret?'ah-ret':'ah';
88
- let svg='<svg class="seq-svg" viewBox="0 0 '+w+' '+h+'" width="'+w+'" height="'+h+'" preserveAspectRatio="xMidYMin meet">';
89
- svg+='<defs>';
90
- ['ah','ah-allow','ah-warn','ah-ret'].forEach(function(id){
91
- svg+='<marker id="seq-'+id+'" markerWidth="9" markerHeight="9" refX="6.5" refY="3.5" orient="auto"><path class="'+id+'" d="M0,0 L7,3.5 L0,7 Z"/></marker>';
92
- });
93
- svg+='</defs>';
94
- for(let i=0;i<n;i++){
95
- const x=cx(i), bw=Math.max(76,parts[i].length*7+18);
96
- svg+='<line class="ll" x1="'+x+'" y1="'+topY+'" x2="'+x+'" y2="'+(h-padBot)+'"/>';
97
- svg+='<rect class="box" x="'+(x-bw/2)+'" y="'+padTop+'" width="'+bw+'" height="'+boxH+'" rx="5"/>';
98
- svg+='<text class="at" x="'+x+'" y="'+(padTop+boxH/2+4)+'" text-anchor="middle" font-size="11" font-family="ui-monospace,monospace">'+he(parts[i])+'</text>';
99
- }
100
- msgs.forEach(function(m,mi){
101
- const fi=typeof m.from==='number'?m.from:parts.indexOf(m.from);
102
- const ti=typeof m.to==='number'?m.to:parts.indexOf(m.to);
103
- if(fi<0||ti<0)return;
104
- const y=topY+headGap+rowH*mi+rowH/2, x1=cx(fi), x2=cx(ti), c=cls(m), tc=(c==='allow'||c==='warn')?' '+c:'';
105
- if(fi===ti){ // self-message · small loop to the right
106
- svg+='<path class="msg '+c+'" d="M'+x1+','+(y-5)+' h'+loopW+' v10 h-'+loopW+'" marker-end="url(#seq-'+head(m)+')"/>';
107
- svg+='<text class="mt'+tc+'" x="'+(x1+loopW+5)+'" y="'+(y-8)+'" font-size="10" font-family="ui-monospace,monospace">'+he(m.label||'')+'</text>';
108
- } else {
109
- svg+='<line class="msg '+c+'" x1="'+x1+'" y1="'+y+'" x2="'+x2+'" y2="'+y+'" marker-end="url(#seq-'+head(m)+')"/>';
110
- svg+='<text class="mt'+tc+'" x="'+((x1+x2)/2)+'" y="'+(y-6)+'" text-anchor="middle" font-size="10" font-family="ui-monospace,monospace">'+he(m.label||'')+'</text>';
111
- }
112
- });
113
- svg+='</svg>';
114
- out+='<div class="artifact-card" data-user-content>'+(a.title?'<div class="artifact-h">'+he(a.title)+'</div>':'')+'<div class="art-seq">'+svg+'</div></div>';
115
- }
116
- }
117
- }
118
- out+='</div>';
119
- return out;
120
- }`;
121
- //# sourceMappingURL=app-script-artifacts.js.map
@@ -1,44 +0,0 @@
1
- /**
2
- * Audit-chain footer stats and activity dots — the always-visible summary of how much the
3
- * chain has recorded and whether it is still intact.
4
- *
5
- * Split out of app-script.ts (strangler fig). Verbatim slice, interpolated back at the
6
- * position it was cut from so it keeps sharing the surrounding IIFE scope — its functions
7
- * are still called from the code left behind. Verified by hashing the composed APP_SCRIPT
8
- * before and after: same bytes.
9
- */
10
- export const AUDIT_FOOTER = ` /* Audit-chain footer stats + activity dots · enriches the footer
11
- from a one-liner to a real status panel. Polls /api/audit/summary
12
- every 8s. */
13
- async function pollAuditStats(){
14
- try{
15
- const r = await fetch('/api/audit/summary');
16
- if(!r.ok) return;
17
- const d = await r.json();
18
- const statsEl = document.getElementById('audit-chain-stats');
19
- const dotsEl = document.getElementById('audit-chain-dots');
20
- if(statsEl){
21
- const actions = d.actions || 0;
22
- const blocked = d.blocked || 0;
23
- const agents = d.agents || 0;
24
- statsEl.textContent = actions+' entries last 24h · '+agents+' agent'+(agents===1?'':'s')+' · '+blocked+' blocked';
25
- }
26
- if(dotsEl){
27
- // Without per-entry recent[], approximate by drawing N=min(actions,12)
28
- // green dots and B=min(blocked, 12) red dots. Honest enough · still
29
- // gives the user visual "audit chain is alive" signal.
30
- const a = Math.min(d.actions||0, 12);
31
- const b = Math.min(d.blocked||0, 12);
32
- const greens = Math.max(0, a - b);
33
- let h = '';
34
- for(let i=0;i<b;i++) h += '<span class="dot block" title="blocked entry"></span>';
35
- for(let i=0;i<greens;i++) h += '<span class="dot allow" title="allowed entry"></span>';
36
- if(!a) for(let i=0;i<3;i++) h += '<span class="dot muted" title="no entries yet"></span>';
37
- dotsEl.innerHTML = h;
38
- }
39
- }catch{ /* ignore */ }
40
- }
41
- setInterval(pollAuditStats, 8000);
42
- pollAuditStats();
43
- `;
44
- //# sourceMappingURL=app-script-audit-footer.js.map
@@ -1,56 +0,0 @@
1
- /**
2
- * Audit-chain verification — the dashboard button that asks the daemon to re-walk the hash
3
- * chain and renders the verdict it gets back.
4
- *
5
- * Split out of app-script.ts (strangler fig). Verbatim slice, interpolated back at the
6
- * position it was cut from so it keeps sharing the surrounding IIFE scope. Verified by
7
- * hashing the composed APP_SCRIPT before and after: same bytes.
8
- */
9
- export const AUDIT_CHAIN_VERIFY = `// F-06 · audit chain verification · click handler for the dashboard panel.
10
- async function verifyAuditChain(){
11
- const btn=document.getElementById('audit-verify-btn');
12
- const res=document.getElementById('audit-result');
13
- if(!btn||!res)return;
14
- btn.textContent='Verifying...';
15
- btn.className='audit-chain-btn';
16
- try{
17
- const r=await fetch('/api/audit/verify').then(x=>x.json());
18
- if(r.error){
19
- res.innerHTML='<span class="fail">Failed: '+String(r.error).replace(/</g,'&lt;')+'</span>';
20
- btn.textContent='Verify chain'; return;
21
- }
22
- const counts='<div class="audit-chain-counts">'+r.totalEntries+' entries &middot; '+r.chainedEntries+' hash-chained &middot; '+r.legacyEntries+' legacy</div>';
23
- // Ask "is there anything here?" BEFORE "did it pass?", and never make the empty branch
24
- // depend on r.valid.
25
- //
26
- // This read \`r.valid && totalEntries===0\`, which was correct against the OLD API — back
27
- // when an empty chain returned valid:true, the lie that f030769 fixed. Making the API
28
- // honest (valid:false when there is nothing to verify) turned this branch unreachable, so
29
- // a fresh install clicking "verify log" got "× Chain BROKEN · 0 break point(s) detected"
30
- // in red. Self-contradictory on its face, and alarming for someone whose only mistake was
31
- // not having run an agent yet.
32
- //
33
- // Fixing valid without walking every consumer of valid is how a two-state control over a
34
- // three-state fact keeps producing a new lie in a new place. Empty is its own answer.
35
- if((r.totalEntries||0)===0 || r.verifiable===false){
36
- res.innerHTML='<div class="audit-chain-counts">Nothing recorded yet &middot; run an agent through codehere to start the chain.</div>';
37
- btn.textContent='Verify chain';
38
- btn.className='audit-chain-btn';
39
- } else if(r.valid){
40
- res.innerHTML='<span class="ok">&check; Chain intact &middot; every entry verified against its predecessor hash.</span>'+counts;
41
- btn.textContent='Chain intact';
42
- btn.className='audit-chain-btn verified';
43
- } else {
44
- const errs=(r.errors||[]).slice(0,5).map(function(e){
45
- return '<div class="audit-chain-error">line '+e.lineNumber+' &middot; '+e.reason+' &middot; '+String(e.detail||'').replace(/</g,'&lt;')+'</div>';
46
- }).join('');
47
- res.innerHTML='<span class="fail">&times; Chain BROKEN &middot; '+(r.errors||[]).length+' break point(s) detected.</span>'+counts+errs;
48
- btn.textContent='Re-verify';
49
- btn.className='audit-chain-btn broken';
50
- }
51
- }catch(e){
52
- res.innerHTML='<span class="fail">Failed to reach /api/audit/verify: '+(e&&e.message?e.message:String(e))+'</span>';
53
- btn.textContent='Verify chain';
54
- }
55
- }`;
56
- //# sourceMappingURL=app-script-audit-verify.js.map