@nanonets/graft 0.13.0 → 0.16.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.
- package/README.md +26 -10
- package/dist/ai/crux.d.ts +14 -1
- package/dist/ai/crux.d.ts.map +1 -1
- package/dist/ai/crux.js +39 -51
- package/dist/ai/crux.js.map +1 -1
- package/dist/ai/failure.d.ts +13 -2
- package/dist/ai/failure.d.ts.map +1 -1
- package/dist/ai/failure.js +16 -4
- package/dist/ai/failure.js.map +1 -1
- package/dist/ai/llm/factory.d.ts +10 -1
- package/dist/ai/llm/factory.d.ts.map +1 -1
- package/dist/ai/llm/factory.js +16 -0
- package/dist/ai/llm/factory.js.map +1 -1
- package/dist/ai/llm/litellm.d.ts +34 -0
- package/dist/ai/llm/litellm.d.ts.map +1 -0
- package/dist/ai/llm/litellm.js +45 -0
- package/dist/ai/llm/litellm.js.map +1 -0
- package/dist/ai/llm/openai.d.ts.map +1 -1
- package/dist/ai/llm/openai.js +66 -7
- package/dist/ai/llm/openai.js.map +1 -1
- package/dist/ai/llm/orcarouter.d.ts +34 -0
- package/dist/ai/llm/orcarouter.d.ts.map +1 -0
- package/dist/ai/llm/orcarouter.js +45 -0
- package/dist/ai/llm/orcarouter.js.map +1 -0
- package/dist/ai/llm/recover-tool.d.ts +19 -0
- package/dist/ai/llm/recover-tool.d.ts.map +1 -0
- package/dist/ai/llm/recover-tool.js +109 -0
- package/dist/ai/llm/recover-tool.js.map +1 -0
- package/dist/ai/providers.d.ts.map +1 -1
- package/dist/ai/providers.js +15 -3
- package/dist/ai/providers.js.map +1 -1
- package/dist/ai/synthesize.d.ts.map +1 -1
- package/dist/ai/synthesize.js +19 -5
- package/dist/ai/synthesize.js.map +1 -1
- package/dist/app/checkout.d.ts +28 -0
- package/dist/app/checkout.d.ts.map +1 -0
- package/dist/app/checkout.js +100 -0
- package/dist/app/checkout.js.map +1 -0
- package/dist/app/events.d.ts +37 -0
- package/dist/app/events.d.ts.map +1 -0
- package/dist/app/events.js +59 -0
- package/dist/app/events.js.map +1 -0
- package/dist/app/identity.d.ts +54 -0
- package/dist/app/identity.d.ts.map +1 -0
- package/dist/app/identity.js +96 -0
- package/dist/app/identity.js.map +1 -0
- package/dist/app/main.d.ts +2 -0
- package/dist/app/main.d.ts.map +1 -0
- package/dist/app/main.js +56 -0
- package/dist/app/main.js.map +1 -0
- package/dist/app/pages.d.ts +39 -0
- package/dist/app/pages.d.ts.map +1 -0
- package/dist/app/pages.js +86 -0
- package/dist/app/pages.js.map +1 -0
- package/dist/app/queue.d.ts +40 -0
- package/dist/app/queue.d.ts.map +1 -0
- package/dist/app/queue.js +68 -0
- package/dist/app/queue.js.map +1 -0
- package/dist/app/review.d.ts +23 -0
- package/dist/app/review.d.ts.map +1 -0
- package/dist/app/review.js +139 -0
- package/dist/app/review.js.map +1 -0
- package/dist/app/server.d.ts +40 -0
- package/dist/app/server.d.ts.map +1 -0
- package/dist/app/server.js +117 -0
- package/dist/app/server.js.map +1 -0
- package/dist/ask/ask.d.ts +35 -0
- package/dist/ask/ask.d.ts.map +1 -1
- package/dist/ask/ask.js +427 -63
- package/dist/ask/ask.js.map +1 -1
- package/dist/ask/file-rank.d.ts +72 -0
- package/dist/ask/file-rank.d.ts.map +1 -0
- package/dist/ask/file-rank.js +160 -0
- package/dist/ask/file-rank.js.map +1 -0
- package/dist/ask/file-selection.d.ts +4 -0
- package/dist/ask/file-selection.d.ts.map +1 -1
- package/dist/ask/file-selection.js +25 -0
- package/dist/ask/file-selection.js.map +1 -1
- package/dist/ask/fuse.d.ts +16 -0
- package/dist/ask/fuse.d.ts.map +1 -1
- package/dist/ask/fuse.js +21 -4
- package/dist/ask/fuse.js.map +1 -1
- package/dist/ask/graphrank.d.ts +18 -0
- package/dist/ask/graphrank.d.ts.map +1 -1
- package/dist/ask/graphrank.js +65 -19
- package/dist/ask/graphrank.js.map +1 -1
- package/dist/blast/blast-cli.d.ts +5 -0
- package/dist/blast/blast-cli.d.ts.map +1 -1
- package/dist/blast/blast-cli.js +21 -30
- package/dist/blast/blast-cli.js.map +1 -1
- package/dist/blast/blast.d.ts +9 -0
- package/dist/blast/blast.d.ts.map +1 -1
- package/dist/blast/blast.js.map +1 -1
- package/dist/blast/name.d.ts +13 -0
- package/dist/blast/name.d.ts.map +1 -1
- package/dist/blast/name.js +36 -0
- package/dist/blast/name.js.map +1 -1
- package/dist/blast/owners.d.ts +85 -0
- package/dist/blast/owners.d.ts.map +1 -0
- package/dist/blast/owners.js +272 -0
- package/dist/blast/owners.js.map +1 -0
- package/dist/blast/render.d.ts.map +1 -1
- package/dist/blast/render.js +105 -0
- package/dist/blast/render.js.map +1 -1
- package/dist/blast/viz.d.ts.map +1 -1
- package/dist/blast/viz.js +10 -0
- package/dist/blast/viz.js.map +1 -1
- package/dist/claude/format.js +1 -1
- package/dist/claude/format.js.map +1 -1
- package/dist/claude/hooks.d.ts.map +1 -1
- package/dist/claude/hooks.js +132 -22
- package/dist/claude/hooks.js.map +1 -1
- package/dist/claude/init.d.ts +1 -0
- package/dist/claude/init.d.ts.map +1 -1
- package/dist/claude/init.js +1 -1
- package/dist/claude/init.js.map +1 -1
- package/dist/claude/session-metrics.d.ts +63 -0
- package/dist/claude/session-metrics.d.ts.map +1 -0
- package/dist/claude/session-metrics.js +181 -0
- package/dist/claude/session-metrics.js.map +1 -0
- package/dist/claude/settings-merge.d.ts +18 -1
- package/dist/claude/settings-merge.d.ts.map +1 -1
- package/dist/claude/settings-merge.js +70 -27
- package/dist/claude/settings-merge.js.map +1 -1
- package/dist/claude/state.d.ts +25 -0
- package/dist/claude/state.d.ts.map +1 -1
- package/dist/claude/state.js +14 -1
- package/dist/claude/state.js.map +1 -1
- package/dist/claude/statusline.d.ts +5 -3
- package/dist/claude/statusline.d.ts.map +1 -1
- package/dist/claude/statusline.js +6 -4
- package/dist/claude/statusline.js.map +1 -1
- package/dist/claude/tally.d.ts +23 -0
- package/dist/claude/tally.d.ts.map +1 -0
- package/dist/claude/tally.js +138 -0
- package/dist/claude/tally.js.map +1 -0
- package/dist/cli.js +145 -4
- package/dist/cli.js.map +1 -1
- package/dist/context/build.d.ts +11 -0
- package/dist/context/build.d.ts.map +1 -1
- package/dist/context/build.js +49 -9
- package/dist/context/build.js.map +1 -1
- package/dist/context/check.d.ts.map +1 -1
- package/dist/context/check.js +5 -12
- package/dist/context/check.js.map +1 -1
- package/dist/context/node-file.d.ts +2 -1
- package/dist/context/node-file.d.ts.map +1 -1
- package/dist/context/node-file.js +70 -3
- package/dist/context/node-file.js.map +1 -1
- package/dist/context/savings.d.ts +8 -0
- package/dist/context/savings.d.ts.map +1 -1
- package/dist/context/savings.js +14 -0
- package/dist/context/savings.js.map +1 -1
- package/dist/engine.d.ts +4 -0
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +2 -0
- package/dist/engine.js.map +1 -1
- package/dist/graph/bindings.d.ts +6 -5
- package/dist/graph/bindings.d.ts.map +1 -1
- package/dist/graph/bindings.js +117 -5
- package/dist/graph/bindings.js.map +1 -1
- package/dist/graph/build.d.ts +4 -0
- package/dist/graph/build.d.ts.map +1 -1
- package/dist/graph/build.js +7 -4
- package/dist/graph/build.js.map +1 -1
- package/dist/graph/cards.d.ts +4 -3
- package/dist/graph/cards.d.ts.map +1 -1
- package/dist/graph/cards.js +34 -6
- package/dist/graph/cards.js.map +1 -1
- package/dist/graph/check.d.ts.map +1 -1
- package/dist/graph/check.js +36 -6
- package/dist/graph/check.js.map +1 -1
- package/dist/graph/enrich.d.ts +4 -4
- package/dist/graph/enrich.d.ts.map +1 -1
- package/dist/graph/enrich.js +32 -6
- package/dist/graph/enrich.js.map +1 -1
- package/dist/graph/extract.d.ts +9 -2
- package/dist/graph/extract.d.ts.map +1 -1
- package/dist/graph/extract.js +356 -12
- package/dist/graph/extract.js.map +1 -1
- package/dist/graph/fingerprint.d.ts +6 -1
- package/dist/graph/fingerprint.d.ts.map +1 -1
- package/dist/graph/fingerprint.js +7 -3
- package/dist/graph/fingerprint.js.map +1 -1
- package/dist/graph/generic.d.ts +10 -0
- package/dist/graph/generic.d.ts.map +1 -1
- package/dist/graph/generic.js +20 -3
- package/dist/graph/generic.js.map +1 -1
- package/dist/graph/invariants.d.ts +3 -2
- package/dist/graph/invariants.d.ts.map +1 -1
- package/dist/graph/invariants.js +6 -3
- package/dist/graph/invariants.js.map +1 -1
- package/dist/graph/refresh.d.ts.map +1 -1
- package/dist/graph/refresh.js +6 -2
- package/dist/graph/refresh.js.map +1 -1
- package/dist/graph/resolve.d.ts +1 -1
- package/dist/graph/resolve.d.ts.map +1 -1
- package/dist/graph/resolve.js +106 -5
- package/dist/graph/resolve.js.map +1 -1
- package/dist/graph/scopes.d.ts.map +1 -1
- package/dist/graph/scopes.js +2 -1
- package/dist/graph/scopes.js.map +1 -1
- package/dist/graph/source-files.d.ts +7 -2
- package/dist/graph/source-files.d.ts.map +1 -1
- package/dist/graph/source-files.js +19 -6
- package/dist/graph/source-files.js.map +1 -1
- package/dist/graph/workspace-cli.d.ts +2 -0
- package/dist/graph/workspace-cli.d.ts.map +1 -1
- package/dist/graph/workspace-cli.js +3 -0
- package/dist/graph/workspace-cli.js.map +1 -1
- package/dist/graph/workspace.d.ts +2 -0
- package/dist/graph/workspace.d.ts.map +1 -1
- package/dist/graph/workspace.js +173 -6
- package/dist/graph/workspace.js.map +1 -1
- package/dist/hosts/antigravity.d.ts +2 -2
- package/dist/hosts/antigravity.d.ts.map +1 -1
- package/dist/hosts/codex-hooks.d.ts +2 -6
- package/dist/hosts/codex-hooks.d.ts.map +1 -1
- package/dist/hosts/codex-hooks.js +7 -30
- package/dist/hosts/codex-hooks.js.map +1 -1
- package/dist/hosts/config-write.d.ts +36 -0
- package/dist/hosts/config-write.d.ts.map +1 -0
- package/dist/hosts/config-write.js +63 -0
- package/dist/hosts/config-write.js.map +1 -0
- package/dist/hosts/cursor-hooks.d.ts +18 -0
- package/dist/hosts/cursor-hooks.d.ts.map +1 -0
- package/dist/hosts/cursor-hooks.js +100 -0
- package/dist/hosts/cursor-hooks.js.map +1 -0
- package/dist/hosts/init.d.ts +2 -2
- package/dist/hosts/init.d.ts.map +1 -1
- package/dist/hosts/init.js +8 -2
- package/dist/hosts/init.js.map +1 -1
- package/dist/hosts/mcp-config.d.ts +15 -5
- package/dist/hosts/mcp-config.d.ts.map +1 -1
- package/dist/hosts/mcp-config.js +51 -15
- package/dist/hosts/mcp-config.js.map +1 -1
- package/dist/hosts/plan.d.ts.map +1 -1
- package/dist/hosts/plan.js +2 -0
- package/dist/hosts/plan.js.map +1 -1
- package/dist/hosts/retract.d.ts +47 -0
- package/dist/hosts/retract.d.ts.map +1 -0
- package/dist/hosts/retract.js +473 -0
- package/dist/hosts/retract.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/ingest/fs.d.ts +39 -5
- package/dist/ingest/fs.d.ts.map +1 -1
- package/dist/ingest/fs.js +104 -11
- package/dist/ingest/fs.js.map +1 -1
- package/dist/mcp/tool-names.d.ts +20 -0
- package/dist/mcp/tool-names.d.ts.map +1 -0
- package/dist/mcp/tool-names.js +36 -0
- package/dist/mcp/tool-names.js.map +1 -0
- package/dist/mcp/tools.d.ts +11 -2
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +9 -21
- package/dist/mcp/tools.js.map +1 -1
- package/dist/telemetry/contract.d.ts.map +1 -1
- package/dist/telemetry/contract.js +17 -3
- package/dist/telemetry/contract.js.map +1 -1
- package/dist/telemetry/flush.d.ts.map +1 -1
- package/dist/telemetry/flush.js +1 -0
- package/dist/telemetry/flush.js.map +1 -1
- package/dist/telemetry/identity.d.ts +7 -0
- package/dist/telemetry/identity.d.ts.map +1 -1
- package/dist/telemetry/identity.js.map +1 -1
- package/dist/telemetry/index.d.ts +2 -2
- package/dist/telemetry/index.d.ts.map +1 -1
- package/dist/telemetry/index.js +2 -2
- package/dist/telemetry/index.js.map +1 -1
- package/dist/telemetry/sessions.d.ts +19 -2
- package/dist/telemetry/sessions.d.ts.map +1 -1
- package/dist/telemetry/sessions.js +57 -34
- package/dist/telemetry/sessions.js.map +1 -1
- package/dist/telemetry/track.d.ts +22 -3
- package/dist/telemetry/track.d.ts.map +1 -1
- package/dist/telemetry/track.js +34 -5
- package/dist/telemetry/track.js.map +1 -1
- package/dist/upkeep-run.js +1 -1
- package/dist/upkeep-run.js.map +1 -1
- package/dist/upkeep.d.ts +7 -4
- package/dist/upkeep.d.ts.map +1 -1
- package/dist/upkeep.js +2 -1
- package/dist/upkeep.js.map +1 -1
- package/dist/util/state.d.ts +12 -2
- package/dist/util/state.d.ts.map +1 -1
- package/dist/util/state.js +4 -0
- package/dist/util/state.js.map +1 -1
- package/dist/viewer/app.js +2 -1
- package/dist/viewer/style.css +14 -0
- package/dist/viz/assemble.d.ts +17 -0
- package/dist/viz/assemble.d.ts.map +1 -1
- package/dist/viz/assemble.js.map +1 -1
- package/package.json +12 -4
- package/scripts/graph-quality.mjs +3 -3
- package/scripts/postinstall.mjs +42 -3
- package/scripts/run-tests.mjs +14 -0
- package/scripts/tally-audit.mjs +140 -0
- package/dist/ai/llm/claude-cli.d.ts +0 -60
- package/dist/ai/llm/claude-cli.d.ts.map +0 -1
- package/dist/ai/llm/claude-cli.js +0 -417
- package/dist/ai/llm/claude-cli.js.map +0 -1
- package/dist/util/num.d.ts +0 -3
- package/dist/util/num.d.ts.map +0 -1
- package/dist/util/num.js +0 -20
- package/dist/util/num.js.map +0 -1
package/dist/viewer/app.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
var pe={part_of:"structure",contains:"structure",uses:"dependency",depends_on:"dependency",calls:"dependency",imports:"dependency",produces:"dependency",configures:"dependency",validates:"dependency",extends:"contract",implements:"contract",references:"association"};function Y(t){return pe[t]??"association"}var Lt={structure:85,dependency:145,contract:150,association:185};function tt(t){return Y(t)==="structure"?"part of":t==="calls"||t==="uses"||t==="depends_on"||t==="imports"?"uses":t.replace(/_/g," ")}var Nt={"part of":"where does this live? (contains, part of)",uses:"what breaks if the target changes? (calls, uses, depends on, imports)",produces:"where does this output come from?",configures:"what changes its behavior without a code change?",validates:"what checks or judges this? (tests, drift checks, scoring)",extends:"what contract must this honor? (inheritance)",implements:"what contract must this honor? (interface)",references:"mentioned but never called \u2014 possible dead coupling"},ge={system:"--sys",concept:"--con",file:"--fil",api:"--api",changed:"--fil",affected:"--sys"},me={file:"--k-file",class:"--k-class",function:"--k-fn",method:"--k-method",interface:"--k-iface",type:"--k-type",enum:"--k-enum"};function P(t,e){return(t==="code"?me:ge)[e]??"--edge"}function M(t){return getComputedStyle(document.documentElement).getPropertyValue(t).trim()}var F=globalThis.__GRAFT_DATA__;async function Tt(){return F?.contextGraph?F.contextGraph:await(await fetch("/api/context-graph")).json()}async function At(){let t;if(F){if(!F.codeGraph)return null;t=F.codeGraph}else{let i=await fetch("/api/code-graph");if(!i.ok)return null;t=await i.json()}let e=t.nodes.map(i=>({id:i.id,name:i.name,type:i.kind,summary:i.summary??i.signature??"",sources:[`${i.path} \xB7 ${i.span}`]})),n=new Set(e.map(i=>i.id)),r=t.edges.filter(i=>n.has(i.source)&&n.has(i.target)).map(i=>({source:i.source,target:i.target,relation:i.relation,confidence:i.confidence}));return{meta:{nodeCount:e.length,edgeCount:r.length},nodes:e,edges:r}}function St(t){if(F)return;let e=new EventSource("/events");e.onmessage=n=>{n.data==="change"&&t()}}function lt(t,e){var n,r=1;t==null&&(t=0),e==null&&(e=0);function i(){var o,a=n.length,p,d=0,s=0;for(o=0;o<a;++o)p=n[o],d+=p.x,s+=p.y;for(d=(d/a-t)*r,s=(s/a-e)*r,o=0;o<a;++o)p=n[o],p.x-=d,p.y-=s}return i.initialize=function(o){n=o},i.x=function(o){return arguments.length?(t=+o,i):t},i.y=function(o){return arguments.length?(e=+o,i):e},i.strength=function(o){return arguments.length?(r=+o,i):r},i}function $t(t){let e=+this._x.call(null,t),n=+this._y.call(null,t);return Vt(this.cover(e,n),e,n,t)}function Vt(t,e,n,r){if(isNaN(e)||isNaN(n))return t;var i,o=t._root,a={data:r},p=t._x0,d=t._y0,s=t._x1,l=t._y1,m,c,f,v,h,u,g,y;if(!o)return t._root=a,t;for(;o.length;)if((h=e>=(m=(p+s)/2))?p=m:s=m,(u=n>=(c=(d+l)/2))?d=c:l=c,i=o,!(o=o[g=u<<1|h]))return i[g]=a,t;if(f=+t._x.call(null,o.data),v=+t._y.call(null,o.data),e===f&&n===v)return a.next=o,i?i[g]=a:t._root=a,t;do i=i?i[g]=new Array(4):t._root=new Array(4),(h=e>=(m=(p+s)/2))?p=m:s=m,(u=n>=(c=(d+l)/2))?d=c:l=c;while((g=u<<1|h)===(y=(v>=c)<<1|f>=m));return i[y]=o,i[g]=a,t}function zt(t){var e,n,r=t.length,i,o,a=new Array(r),p=new Array(r),d=1/0,s=1/0,l=-1/0,m=-1/0;for(n=0;n<r;++n)isNaN(i=+this._x.call(null,e=t[n]))||isNaN(o=+this._y.call(null,e))||(a[n]=i,p[n]=o,i<d&&(d=i),i>l&&(l=i),o<s&&(s=o),o>m&&(m=o));if(d>l||s>m)return this;for(this.cover(d,s).cover(l,m),n=0;n<r;++n)Vt(this,a[n],p[n],t[n]);return this}function Gt(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var n=this._x0,r=this._y0,i=this._x1,o=this._y1;if(isNaN(n))i=(n=Math.floor(t))+1,o=(r=Math.floor(e))+1;else{for(var a=i-n||1,p=this._root,d,s;n>t||t>=i||r>e||e>=o;)switch(s=(e<r)<<1|t<n,d=new Array(4),d[s]=p,p=d,a*=2,s){case 0:i=n+a,o=r+a;break;case 1:n=i-a,o=r+a;break;case 2:i=n+a,r=o-a;break;case 3:n=i-a,r=o-a;break}this._root&&this._root.length&&(this._root=p)}return this._x0=n,this._y0=r,this._x1=i,this._y1=o,this}function Dt(){var t=[];return this.visit(function(e){if(!e.length)do t.push(e.data);while(e=e.next)}),t}function Ht(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function N(t,e,n,r,i){this.node=t,this.x0=e,this.y0=n,this.x1=r,this.y1=i}function It(t,e,n){var r,i=this._x0,o=this._y0,a,p,d,s,l=this._x1,m=this._y1,c=[],f=this._root,v,h;for(f&&c.push(new N(f,i,o,l,m)),n==null?n=1/0:(i=t-n,o=e-n,l=t+n,m=e+n,n*=n);v=c.pop();)if(!(!(f=v.node)||(a=v.x0)>l||(p=v.y0)>m||(d=v.x1)<i||(s=v.y1)<o))if(f.length){var u=(a+d)/2,g=(p+s)/2;c.push(new N(f[3],u,g,d,s),new N(f[2],a,g,u,s),new N(f[1],u,p,d,g),new N(f[0],a,p,u,g)),(h=(e>=g)<<1|t>=u)&&(v=c[c.length-1],c[c.length-1]=c[c.length-1-h],c[c.length-1-h]=v)}else{var y=t-+this._x.call(null,f.data),w=e-+this._y.call(null,f.data),x=y*y+w*w;if(x<n){var E=Math.sqrt(n=x);i=t-E,o=e-E,l=t+E,m=e+E,r=f.data}}return r}function Rt(t){if(isNaN(l=+this._x.call(null,t))||isNaN(m=+this._y.call(null,t)))return this;var e,n=this._root,r,i,o,a=this._x0,p=this._y0,d=this._x1,s=this._y1,l,m,c,f,v,h,u,g;if(!n)return this;if(n.length)for(;;){if((v=l>=(c=(a+d)/2))?a=c:d=c,(h=m>=(f=(p+s)/2))?p=f:s=f,e=n,!(n=n[u=h<<1|v]))return this;if(!n.length)break;(e[u+1&3]||e[u+2&3]||e[u+3&3])&&(r=e,g=u)}for(;n.data!==t;)if(i=n,!(n=n.next))return this;return(o=n.next)&&delete n.next,i?(o?i.next=o:delete i.next,this):e?(o?e[u]=o:delete e[u],(n=e[0]||e[1]||e[2]||e[3])&&n===(e[3]||e[2]||e[1]||e[0])&&!n.length&&(r?r[g]=n:this._root=n),this):(this._root=o,this)}function Pt(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this}function Bt(){return this._root}function Ot(){var t=0;return this.visit(function(e){if(!e.length)do++t;while(e=e.next)}),t}function jt(t){var e=[],n,r=this._root,i,o,a,p,d;for(r&&e.push(new N(r,this._x0,this._y0,this._x1,this._y1));n=e.pop();)if(!t(r=n.node,o=n.x0,a=n.y0,p=n.x1,d=n.y1)&&r.length){var s=(o+p)/2,l=(a+d)/2;(i=r[3])&&e.push(new N(i,s,l,p,d)),(i=r[2])&&e.push(new N(i,o,l,s,d)),(i=r[1])&&e.push(new N(i,s,a,p,l)),(i=r[0])&&e.push(new N(i,o,a,s,l))}return this}function Wt(t){var e=[],n=[],r;for(this._root&&e.push(new N(this._root,this._x0,this._y0,this._x1,this._y1));r=e.pop();){var i=r.node;if(i.length){var o,a=r.x0,p=r.y0,d=r.x1,s=r.y1,l=(a+d)/2,m=(p+s)/2;(o=i[0])&&e.push(new N(o,a,p,l,m)),(o=i[1])&&e.push(new N(o,l,p,d,m)),(o=i[2])&&e.push(new N(o,a,m,l,s)),(o=i[3])&&e.push(new N(o,l,m,d,s))}n.push(r)}for(;r=n.pop();)t(r.node,r.x0,r.y0,r.x1,r.y1);return this}function Ft(t){return t[0]}function Yt(t){return arguments.length?(this._x=t,this):this._x}function qt(t){return t[1]}function Xt(t){return arguments.length?(this._y=t,this):this._y}function B(t,e,n){var r=new ct(e??Ft,n??qt,NaN,NaN,NaN,NaN);return t==null?r:r.addAll(t)}function ct(t,e,n,r,i,o){this._x=t,this._y=e,this._x0=n,this._y0=r,this._x1=i,this._y1=o,this._root=void 0}function Kt(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var S=B.prototype=ct.prototype;S.copy=function(){var t=new ct(this._x,this._y,this._x0,this._y0,this._x1,this._y1),e=this._root,n,r;if(!e)return t;if(!e.length)return t._root=Kt(e),t;for(n=[{source:e,target:t._root=new Array(4)}];e=n.pop();)for(var i=0;i<4;++i)(r=e.source[i])&&(r.length?n.push({source:r,target:e.target[i]=new Array(4)}):e.target[i]=Kt(r));return t};S.add=$t;S.addAll=zt;S.cover=Gt;S.data=Dt;S.extent=Ht;S.find=It;S.remove=Rt;S.removeAll=Pt;S.root=Bt;S.size=Ot;S.visit=jt;S.visitAfter=Wt;S.x=Yt;S.y=Xt;function D(t){return function(){return t}}function z(t){return(t()-.5)*1e-6}function ve(t){return t.x+t.vx}function ye(t){return t.y+t.vy}function dt(t){var e,n,r,i=1,o=1;typeof t!="function"&&(t=D(t==null?1:+t));function a(){for(var s,l=e.length,m,c,f,v,h,u,g=0;g<o;++g)for(m=B(e,ve,ye).visitAfter(p),s=0;s<l;++s)c=e[s],h=n[c.index],u=h*h,f=c.x+c.vx,v=c.y+c.vy,m.visit(y);function y(w,x,E,A,$){var C=w.data,V=w.r,L=h+V;if(C){if(C.index>c.index){var I=f-C.x-C.vx,R=v-C.y-C.vy,H=I*I+R*R;H<L*L&&(I===0&&(I=z(r),H+=I*I),R===0&&(R=z(r),H+=R*R),H=(L-(H=Math.sqrt(H)))/H*i,c.vx+=(I*=H)*(L=(V*=V)/(u+V)),c.vy+=(R*=H)*L,C.vx-=I*(L=1-L),C.vy-=R*L)}return}return x>f+L||A<f-L||E>v+L||$<v-L}}function p(s){if(s.data)return s.r=n[s.data.index];for(var l=s.r=0;l<4;++l)s[l]&&s[l].r>s.r&&(s.r=s[l].r)}function d(){if(e){var s,l=e.length,m;for(n=new Array(l),s=0;s<l;++s)m=e[s],n[m.index]=+t(m,s,e)}}return a.initialize=function(s,l){e=s,r=l,d()},a.iterations=function(s){return arguments.length?(o=+s,a):o},a.strength=function(s){return arguments.length?(i=+s,a):i},a.radius=function(s){return arguments.length?(t=typeof s=="function"?s:D(+s),d(),a):t},a}function xe(t){return t.index}function Qt(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function ut(t){var e=xe,n=m,r,i=D(30),o,a,p,d,s,l=1;t==null&&(t=[]);function m(u){return 1/Math.min(p[u.source.index],p[u.target.index])}function c(u){for(var g=0,y=t.length;g<l;++g)for(var w=0,x,E,A,$,C,V,L;w<y;++w)x=t[w],E=x.source,A=x.target,$=A.x+A.vx-E.x-E.vx||z(s),C=A.y+A.vy-E.y-E.vy||z(s),V=Math.sqrt($*$+C*C),V=(V-o[w])/V*u*r[w],$*=V,C*=V,A.vx-=$*(L=d[w]),A.vy-=C*L,E.vx+=$*(L=1-L),E.vy+=C*L}function f(){if(a){var u,g=a.length,y=t.length,w=new Map(a.map((E,A)=>[e(E,A,a),E])),x;for(u=0,p=new Array(g);u<y;++u)x=t[u],x.index=u,typeof x.source!="object"&&(x.source=Qt(w,x.source)),typeof x.target!="object"&&(x.target=Qt(w,x.target)),p[x.source.index]=(p[x.source.index]||0)+1,p[x.target.index]=(p[x.target.index]||0)+1;for(u=0,d=new Array(y);u<y;++u)x=t[u],d[u]=p[x.source.index]/(p[x.source.index]+p[x.target.index]);r=new Array(y),v(),o=new Array(y),h()}}function v(){if(a)for(var u=0,g=t.length;u<g;++u)r[u]=+n(t[u],u,t)}function h(){if(a)for(var u=0,g=t.length;u<g;++u)o[u]=+i(t[u],u,t)}return c.initialize=function(u,g){a=u,s=g,f()},c.links=function(u){return arguments.length?(t=u,f(),c):t},c.id=function(u){return arguments.length?(e=u,c):e},c.iterations=function(u){return arguments.length?(l=+u,c):l},c.strength=function(u){return arguments.length?(n=typeof u=="function"?u:D(+u),v(),c):n},c.distance=function(u){return arguments.length?(i=typeof u=="function"?u:D(+u),h(),c):i},c}var we={value:()=>{}};function Jt(){for(var t=0,e=arguments.length,n={},r;t<e;++t){if(!(r=arguments[t]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new et(n)}function et(t){this._=t}function be(t,e){return t.trim().split(/^|\s+/).map(function(n){var r="",i=n.indexOf(".");if(i>=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!e.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}et.prototype=Jt.prototype={constructor:et,on:function(t,e){var n=this._,r=be(t+"",n),i,o=-1,a=r.length;if(arguments.length<2){for(;++o<a;)if((i=(t=r[o]).type)&&(i=ke(n[i],t.name)))return i;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++o<a;)if(i=(t=r[o]).type)n[i]=Zt(n[i],t.name,e);else if(e==null)for(i in n)n[i]=Zt(n[i],t.name,null);return this},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new et(t)},call:function(t,e){if((i=arguments.length-2)>0)for(var n=new Array(i),r=0,i,o;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(o=this._[t],r=0,i=o.length;r<i;++r)o[r].value.apply(e,n)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,o=r.length;i<o;++i)r[i].value.apply(e,n)}};function ke(t,e){for(var n=0,r=t.length,i;n<r;++n)if((i=t[n]).name===e)return i.value}function Zt(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=we,t=t.slice(0,r).concat(t.slice(r+1));break}return n!=null&&t.push({name:e,value:n}),t}var ft=Jt;var q=0,Q=0,K=0,te=1e3,nt,Z,it=0,O=0,rt=0,J=typeof performance=="object"&&performance.now?performance:Date,ee=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function gt(){return O||(ee(_e),O=J.now()+rt)}function _e(){O=0}function ht(){this._call=this._time=this._next=null}ht.prototype=ot.prototype={constructor:ht,restart:function(t,e,n){if(typeof t!="function")throw new TypeError("callback is not a function");n=(n==null?gt():+n)+(e==null?0:+e),!this._next&&Z!==this&&(Z?Z._next=this:nt=this,Z=this),this._call=t,this._time=n,pt()},stop:function(){this._call&&(this._call=null,this._time=1/0,pt())}};function ot(t,e,n){var r=new ht;return r.restart(t,e,n),r}function ne(){gt(),++q;for(var t=nt,e;t;)(e=O-t._time)>=0&&t._call.call(void 0,e),t=t._next;--q}function Ut(){O=(it=J.now())+rt,q=Q=0;try{ne()}finally{q=0,Me(),O=0}}function Ee(){var t=J.now(),e=t-it;e>te&&(rt-=e,it=t)}function Me(){for(var t,e=nt,n,r=1/0;e;)e._call?(r>e._time&&(r=e._time),t=e,e=e._next):(n=e._next,e._next=null,e=t?t._next=n:nt=n);Z=t,pt(r)}function pt(t){if(!q){Q&&(Q=clearTimeout(Q));var e=t-O;e>24?(t<1/0&&(Q=setTimeout(Ut,t-J.now()-rt)),K&&(K=clearInterval(K))):(K||(it=J.now(),K=setInterval(Ee,te)),q=1,ee(Ut))}}function ie(){let t=1;return()=>(t=(1664525*t+1013904223)%4294967296)/4294967296}function re(t){return t.x}function oe(t){return t.y}var Ce=10,Le=Math.PI*(3-Math.sqrt(5));function mt(t){var e,n=1,r=.001,i=1-Math.pow(r,1/300),o=0,a=.6,p=new Map,d=ot(m),s=ft("tick","end"),l=ie();t==null&&(t=[]);function m(){c(),s.call("tick",e),n<r&&(d.stop(),s.call("end",e))}function c(h){var u,g=t.length,y;h===void 0&&(h=1);for(var w=0;w<h;++w)for(n+=(o-n)*i,p.forEach(function(x){x(n)}),u=0;u<g;++u)y=t[u],y.fx==null?y.x+=y.vx*=a:(y.x=y.fx,y.vx=0),y.fy==null?y.y+=y.vy*=a:(y.y=y.fy,y.vy=0);return e}function f(){for(var h=0,u=t.length,g;h<u;++h){if(g=t[h],g.index=h,g.fx!=null&&(g.x=g.fx),g.fy!=null&&(g.y=g.fy),isNaN(g.x)||isNaN(g.y)){var y=Ce*Math.sqrt(.5+h),w=h*Le;g.x=y*Math.cos(w),g.y=y*Math.sin(w)}(isNaN(g.vx)||isNaN(g.vy))&&(g.vx=g.vy=0)}}function v(h){return h.initialize&&h.initialize(t,l),h}return f(),e={tick:c,restart:function(){return d.restart(m),e},stop:function(){return d.stop(),e},nodes:function(h){return arguments.length?(t=h,f(),p.forEach(v),e):t},alpha:function(h){return arguments.length?(n=+h,e):n},alphaMin:function(h){return arguments.length?(r=+h,e):r},alphaDecay:function(h){return arguments.length?(i=+h,e):+i},alphaTarget:function(h){return arguments.length?(o=+h,e):o},velocityDecay:function(h){return arguments.length?(a=1-h,e):1-a},randomSource:function(h){return arguments.length?(l=h,p.forEach(v),e):l},force:function(h,u){return arguments.length>1?(u==null?p.delete(h):p.set(h,v(u)),e):p.get(h)},find:function(h,u,g){var y=0,w=t.length,x,E,A,$,C;for(g==null?g=1/0:g*=g,y=0;y<w;++y)$=t[y],x=h-$.x,E=u-$.y,A=x*x+E*E,A<g&&(C=$,g=A);return C},on:function(h,u){return arguments.length>1?(s.on(h,u),e):s.on(h)}}}function vt(){var t,e,n,r,i=D(-30),o,a=1,p=1/0,d=.81;function s(f){var v,h=t.length,u=B(t,re,oe).visitAfter(m);for(r=f,v=0;v<h;++v)e=t[v],u.visit(c)}function l(){if(t){var f,v=t.length,h;for(o=new Array(v),f=0;f<v;++f)h=t[f],o[h.index]=+i(h,f,t)}}function m(f){var v=0,h,u,g=0,y,w,x;if(f.length){for(y=w=x=0;x<4;++x)(h=f[x])&&(u=Math.abs(h.value))&&(v+=h.value,g+=u,y+=u*h.x,w+=u*h.y);f.x=y/g,f.y=w/g}else{h=f,h.x=h.data.x,h.y=h.data.y;do v+=o[h.data.index];while(h=h.next)}f.value=v}function c(f,v,h,u){if(!f.value)return!0;var g=f.x-e.x,y=f.y-e.y,w=u-v,x=g*g+y*y;if(w*w/d<x)return x<p&&(g===0&&(g=z(n),x+=g*g),y===0&&(y=z(n),x+=y*y),x<a&&(x=Math.sqrt(a*x)),e.vx+=g*f.value*r/x,e.vy+=y*f.value*r/x),!0;if(f.length||x>=p)return;(f.data!==e||f.next)&&(g===0&&(g=z(n),x+=g*g),y===0&&(y=z(n),x+=y*y),x<a&&(x=Math.sqrt(a*x)));do f.data!==e&&(w=o[f.data.index]*r/x,e.vx+=g*w,e.vy+=y*w);while(f=f.next)}return s.initialize=function(f,v){t=f,n=v,l()},s.strength=function(f){return arguments.length?(i=typeof f=="function"?f:D(+f),l(),s):i},s.distanceMin=function(f){return arguments.length?(a=f*f,s):Math.sqrt(a)},s.distanceMax=function(f){return arguments.length?(p=f*f,s):Math.sqrt(p)},s.theta=function(f){return arguments.length?(d=f*f,s):Math.sqrt(d)},s}var Ne="http://www.w3.org/2000/svg";function T(t,e){let n=document.createElementNS(Ne,t);for(let[r,i]of Object.entries(e))n.setAttribute(r,String(i));return n}var st=class{svg;defs;viewport;sim=null;nodes=[];edges=[];edgeEls=[];nodeEls=[];view={x:0,y:0,k:1};tab="context";selected=null;query="";hiddenRels={};hiddenTypes={};onSelect=()=>{};constructor(e){this.svg=e,this.buildChrome(),this.bindPanZoom()}buildChrome(){this.svg.textContent="",this.defs=T("defs",{}),this.svg.appendChild(this.defs),this.viewport=T("g",{}),this.svg.appendChild(this.viewport),this.svg.addEventListener("click",()=>this.select(null))}ensureMarkers(){this.defs.textContent="";let e=T("marker",{id:"arr",viewBox:"0 0 10 10",refX:8,refY:5,markerWidth:4.5,markerHeight:4.5,orient:"auto-start-reverse"});e.appendChild(T("path",{d:"M2,1.5L8.5,5L2,8.5",fill:"none",stroke:M("--edge"),"stroke-width":1.8,"stroke-linecap":"round","stroke-linejoin":"round",opacity:.75}));let n=T("marker",{id:"arrH",viewBox:"0 0 12 12",refX:10,refY:6,markerWidth:6.5,markerHeight:6.5,orient:"auto-start-reverse"});n.appendChild(T("path",{d:"M1.5,1.5L10.5,6L1.5,10.5z",fill:M("--canvas"),stroke:M("--edge"),"stroke-width":1.4}));let r=T("marker",{id:"arrOut",viewBox:"0 0 10 10",refX:8,refY:5,markerWidth:5,markerHeight:5,orient:"auto-start-reverse"});r.appendChild(T("path",{d:"M1,1L9,5L1,9z",fill:M("--fil")}));let i=T("marker",{id:"arrIn",viewBox:"0 0 10 10",refX:8,refY:5,markerWidth:5,markerHeight:5,orient:"auto-start-reverse"});i.appendChild(T("path",{d:"M1,1L9,5L1,9z",fill:M("--accent")}));for(let o of[e,n,r,i])this.defs.appendChild(o)}setData(e,n){this.tab=n;let r=new Map(this.nodes.map(d=>[d.id,d])),i={};for(let d of e.edges)i[d.source]=(i[d.source]??0)+1,i[d.target]=(i[d.target]??0)+1;let o=this.svg.clientWidth||800,a=this.svg.clientHeight||600;this.nodes=e.nodes.map((d,s)=>{let l=r.get(d.id),m=s/Math.max(1,e.nodes.length)*Math.PI*2,c=i[d.id]??0;return{id:d.id,name:d.name,type:d.type,deg:c,r:11+Math.min(13,c*2.6),x:l?.x??o/2+Math.cos(m)*Math.min(o,a)/4,y:l?.y??a/2+Math.sin(m)*Math.min(o,a)/4,vx:l?.vx??0,vy:l?.vy??0}});let p=new Map(this.nodes.map(d=>[d.id,d]));this.edges=e.edges.map(d=>({source:p.get(d.source),target:p.get(d.target),relation:d.relation,description:d.description,confidence:d.confidence})).filter(d=>d.source&&d.target),this.sim?.stop(),this.sim=mt(this.nodes).force("charge",vt().strength(-220)).force("link",ut(this.edges).distance(d=>Lt[Y(d.relation)]).strength(.5)).force("center",lt(o/2,a/2)).force("collide",dt().radius(d=>d.r+6)).on("tick",()=>this.tick()),this.buildElements(),this.restyle()}buildElements(){this.ensureMarkers(),this.viewport.textContent="",this.edgeEls=this.edges.map(e=>{let n=T("path",{fill:"none","stroke-linecap":"round"}),r=T("title",{});r.textContent=e.relation.replace(/_/g," ")+(e.description?` \u2014 ${e.description}`:""),n.appendChild(r);let i=T("text",{"text-anchor":"middle","font-size":9.5,"font-weight":700,"stroke-width":3,"paint-order":"stroke",display:"none"});return i.textContent=e.relation.replace(/_/g," "),this.viewport.appendChild(n),this.viewport.appendChild(i),{path:n,label:i,edge:e}}),this.nodeEls=this.nodes.map(e=>{let n=T("g",{cursor:"pointer"}),r=T("circle",{fill:"none","stroke-width":1.6,opacity:0,r:e.r+5}),i=T("circle",{r:e.r,opacity:.92}),o=T("text",{y:e.r+15,"text-anchor":"middle","font-size":11.5,"font-weight":600});return o.textContent=e.name,n.append(r,i,o),n.addEventListener("click",a=>{a.stopPropagation(),this.select(e.id)}),this.bindDrag(n,e),this.viewport.appendChild(n),{group:n,circle:i,ring:r,label:o,node:e}})}tick(){for(let{path:e,label:n,edge:r}of this.edgeEls){let i=r.source,o=r.target,a=(o.x??0)-(i.x??0),p=(o.y??0)-(i.y??0),d=Math.sqrt(a*a+p*p)||1,s=a/d,l=p/d,m=(i.x??0)+s*(i.r+2),c=(i.y??0)+l*(i.r+2),f=(o.x??0)-s*(o.r+6),v=(o.y??0)-l*(o.r+6),h=(m+f)/2-l*10,u=(c+v)/2+s*10;e.setAttribute("d",`M${m},${c} Q${h},${u} ${f},${v}`),n.setAttribute("x",String((m+f)/2-l*14)),n.setAttribute("y",String((c+v)/2+s*14))}for(let{group:e,node:n}of this.nodeEls)e.setAttribute("transform",`translate(${n.x??0},${n.y??0})`)}restyle(){this.ensureMarkers();let e=new Set;if(this.selected)for(let i of this.edges)i.source.id===this.selected&&e.add(i.target.id),i.target.id===this.selected&&e.add(i.source.id);let n=this.query.toLowerCase(),r=i=>!this.hiddenTypes[i.type];for(let{path:i,label:o,edge:a}of this.edgeEls){let p=r(a.source)&&r(a.target)&&!this.hiddenRels[tt(a.relation)];if(i.style.display=p?"":"none",o.setAttribute("display","none"),!p)continue;let d=Y(a.relation),s=M("--edge"),l=1.3,m="none",c=.5,f="url(#arr)";d==="structure"?(l=2.4,c=.32,f="none"):d==="dependency"?(l=1.5,c=.55):d==="contract"?(c=.55,f="url(#arrH)"):(m="2 5",l=1.2,c=.28,f="none"),a.confidence==="inferred"&&(m="5 4"),n&&(c=.12);let v=this.selected?a.source.id===this.selected?"out":a.target.id===this.selected?"in":"far":"none";v==="out"?(s=M("--fil"),c=.95,l+=.7,f="url(#arrOut)"):v==="in"?(s=M("--accent"),c=.95,l+=.7,f="url(#arrIn)"):v==="far"&&(c=.06),i.setAttribute("stroke",s),i.setAttribute("stroke-width",String(l)),i.setAttribute("stroke-dasharray",m),i.setAttribute("opacity",String(c)),f==="none"?i.removeAttribute("marker-end"):i.setAttribute("marker-end",f),(v==="out"||v==="in")&&(o.removeAttribute("display"),o.setAttribute("fill",s),o.setAttribute("stroke",M("--canvas")))}for(let{group:i,circle:o,ring:a,label:p,node:d}of this.nodeEls){let s=r(d);if(i.style.display=s?"":"none",!s)continue;let m=!n||d.name.toLowerCase().includes(n)?1:.22;this.selected&&d.id!==this.selected&&!e.has(d.id)&&(m=Math.min(m,.2)),i.setAttribute("opacity",String(m));let c=M(P(this.tab,d.type));o.setAttribute("fill",c),a.setAttribute("stroke",c),a.setAttribute("opacity",d.id===this.selected?"0.55":"0"),p.setAttribute("fill",M("--ink"))}}select(e){this.selected=e,this.restyle(),this.onSelect(e)}focus(e){let n=this.nodes.find(o=>o.id===e);if(!n)return;let r=this.svg.clientWidth,i=this.svg.clientHeight;this.view.k=Math.max(this.view.k,1.4),this.view.x=r/2-(n.x??0)*this.view.k,this.view.y=i/2-(n.y??0)*this.view.k,this.applyView(),this.select(e)}firstMatch(){let e=this.query.toLowerCase();return this.nodes.find(n=>!this.hiddenTypes[n.type]&&n.name.toLowerCase().includes(e))}applyView(){this.viewport.setAttribute("transform",`translate(${this.view.x},${this.view.y}) scale(${this.view.k})`)}zoomBy(e){let n=this.svg.clientWidth/2,r=this.svg.clientHeight/2,i=Math.max(.35,Math.min(3,this.view.k*e));this.view.x=n-(n-this.view.x)*(i/this.view.k),this.view.y=r-(r-this.view.y)*(i/this.view.k),this.view.k=i,this.applyView()}resetView(){this.view={x:0,y:0,k:1},this.applyView()}reheat(){this.sim?.alpha(.6).restart()}bindDrag(e,n){e.addEventListener("pointerdown",r=>{r.stopPropagation(),e.setPointerCapture(r.pointerId);let i=a=>{let p=this.svg.getBoundingClientRect();n.fx=(a.clientX-p.left-this.view.x)/this.view.k,n.fy=(a.clientY-p.top-this.view.y)/this.view.k,this.sim?.alphaTarget(.25).restart()},o=()=>{n.fx=null,n.fy=null,this.sim?.alphaTarget(0),e.removeEventListener("pointermove",i),e.removeEventListener("pointerup",o)};e.addEventListener("pointermove",i),e.addEventListener("pointerup",o)})}bindPanZoom(){let e=null;this.svg.addEventListener("pointerdown",n=>{e={x:n.clientX-this.view.x,y:n.clientY-this.view.y}}),this.svg.addEventListener("pointermove",n=>{e&&(this.view.x=n.clientX-e.x,this.view.y=n.clientY-e.y,this.applyView())}),window.addEventListener("pointerup",()=>{e=null}),this.svg.addEventListener("wheel",n=>{n.preventDefault();let r=this.svg.getBoundingClientRect(),i=n.clientX-r.left,o=n.clientY-r.top,a=Math.max(.35,Math.min(3,this.view.k*Math.exp(-n.deltaY*.0016)));this.view.x=i-(i-this.view.x)*(a/this.view.k),this.view.y=o-(o-this.view.y)*(a/this.view.k),this.view.k=a,this.applyView()},{passive:!1})}};function G(t){return t.replace(/&/g,"&").replace(/</g,"<")}function Te(t){let e=t.lines.map(n=>`<div class="ev-l ${n.sign==="+"?"add":n.sign==="-"?"del":"ctx"}"><span class="ev-n">${n.n??""}</span><span class="ev-s">${n.sign===" "?"":n.sign}</span><span class="ev-t">${G(n.text)}</span></div>`).join("");return`<div class="ev"><div class="ev-h mono">${G(t.label)}${t.note?` <span class="ev-note">${G(t.note)}</span>`:""}</div><div class="ev-b mono">${e}</div>`+(t.more?`<div class="ev-more">+ ${t.more} more lines</div>`:"")+"</div>"}function se(t,e,n,r,i){if(!r||!e){t.innerHTML='<div class="empty">Select a node to view details</div>';return}let o=e.nodes.find(c=>c.id===r);if(!o){t.innerHTML='<div class="empty">Select a node to view details</div>';return}let a=M(P(n,o.type)),p=c=>e.nodes.find(f=>f.id===c)?.name??c,d=e.edges.filter(c=>c.source===r),s=e.edges.filter(c=>c.target===r),l=`<span class="d-type"><span class="sw" style="background:${a}"></span>${G(o.type)}</span>`;if(l+=`<h3>${G(o.name)}</h3>`,o.summary&&(l+=`<p class="summary">${G(o.summary)}</p>`),o.evidence?.length){l+=`<div class="d-label">Code \xB7 ${o.evidence.length}</div>`;for(let f of o.evidence)l+=Te(f);let c=o.sources.length-o.evidence.length;c>0&&(l+=`<div class="src mono">+ ${c} more, not shown</div>`)}else if(o.sources.length){l+=`<div class="d-label">Sources \xB7 ${o.sources.length}</div>`;for(let c of o.sources)l+=`<div class="src mono">${G(c)}</div>`}let m=(c,f,v,h)=>{if(c.length){l+=`<div class="d-label"><span class="dot" style="background:${f}"></span>${v} \xB7 ${c.length}</div>`;for(let u of c)l+=`<button class="lnk" data-go="${G(h(u))}"><span class="rel">${G(u.relation.replace(/_/g," "))}</span> <span class="to">${G(p(h(u)))}</span>`+(u.description?`<div class="desc">${G(u.description)}</div>`:"")+"</button>"}};m(d,M("--fil"),"Depends on",c=>c.target),m(s,M("--accent"),"Depended on by",c=>c.source),t.innerHTML=l,t.querySelectorAll("[data-go]").forEach(c=>{c.addEventListener("click",()=>i(c.dataset.go))})}function yt(t){return t.replace(/&/g,"&").replace(/</g,"<")}function X(t,e,n,r,i){let o=s=>e.edges.filter(l=>l.relation==="contains"&&l.source===s).map(l=>e.nodes.find(m=>m.id===l.target)).filter(l=>!!l),a=s=>{let l=o(s);return l.length+l.reduce((m,c)=>m+a(c.id),0)},p=e.nodes.filter(s=>s.type==="file"),d=s=>{let l=o(s.id),m=r[s.id]!==!1,c=`<button class="tree-row${m?" open":""}${n===s.id?" sel":""}" data-id="${yt(s.id)}" data-haskids="${l.length?1:0}"><span class="chev">${l.length?"\u25B6":""}</span><span class="k" style="background:${M(P("code",s.type))}"></span><span class="t${s.type==="file"?" mono":""}">${yt(s.name)}</span><span class="badge">${l.length?a(s.id)+" sym":yt(s.type)}</span></button>`;return l.length&&m&&(c+=`<div class="tree-kids">${l.map(d).join("")}</div>`),c};t.innerHTML='<div class="tree-tools"><button data-tool="expand">Expand all</button><button data-tool="collapse">Collapse all</button></div>'+p.map(d).join(""),t.querySelectorAll(".tree-row").forEach(s=>{s.addEventListener("click",()=>{let l=s.dataset.id;s.dataset.haskids==="1"&&(r[l]=r[l]===!1,X(t,e,l,r,i)),i(l)})}),t.querySelector('[data-tool="expand"]')?.addEventListener("click",()=>{for(let s of Object.keys(r))delete r[s];X(t,e,n,r,i)}),t.querySelector('[data-tool="collapse"]')?.addEventListener("click",()=>{for(let s of e.nodes)r[s.id]=!1;X(t,e,n,r,i)})}var k=t=>document.getElementById(t),_={tab:"context",context:null,code:null,outlineOpen:{}},b=new st(k("graphSvg"));function U(){return _.tab==="context"?_.context:_.code}function kt(){return _.tab==="code"||_.tab==="outline"?"code":"context"}function _t(){let t=k("edgeChips");t.innerHTML='<span class="cap">Edges</span>';let e=U();if(!e)return;let n=new Map;for(let i of e.edges){let o=tt(i.relation);n.set(o,(n.get(o)??0)+1)}let r=[...n.keys()].sort((i,o)=>{let a=p=>p==="part of"?0:p==="uses"?1:2;return a(i)-a(o)||i.localeCompare(o)});for(let i of r){let o=document.createElement("button");o.type="button",o.className="echip"+(b.hiddenRels[i]?"":" on"),o.innerHTML=`${Ae(i)} ${i} <span style="opacity:.55">${n.get(i)}</span>`,o.title=(Nt[i]??`"${i}" edges`)+" \u2014 click to "+(b.hiddenRels[i]?"show":"hide"),o.addEventListener("click",()=>{b.hiddenRels[i]=!b.hiddenRels[i],_t(),b.restyle(),Mt()}),t.appendChild(o)}}function Ae(t){let e=t==="part of"?"structure":t==="uses"?"dependency":Y(t.replace(/ /g,"_"));return{structure:'<svg width="20" height="8" aria-hidden="true"><line x1="1" y1="4" x2="19" y2="4" stroke="currentColor" stroke-width="3" opacity=".5"/></svg>',dependency:'<svg width="20" height="8" aria-hidden="true"><line x1="1" y1="4" x2="14" y2="4" stroke="currentColor" stroke-width="1.6"/><path d="M14,1 L19,4 L14,7 z" fill="currentColor"/></svg>',contract:'<svg width="20" height="8" aria-hidden="true"><line x1="1" y1="4" x2="13" y2="4" stroke="currentColor" stroke-width="1.4"/><path d="M13,1 L19,4 L13,7 z" fill="none" stroke="currentColor" stroke-width="1.2"/></svg>',association:'<svg width="20" height="8" aria-hidden="true"><line x1="1" y1="4" x2="19" y2="4" stroke="currentColor" stroke-width="1.4" stroke-dasharray="2 4" opacity=".7"/></svg>'}[e]}function Et(){let t=k("legend");t.innerHTML="";let e=U();if(!e)return;let n=new Map;for(let r of e.nodes)n.set(r.type,(n.get(r.type)??0)+1);for(let[r,i]of n){let o=document.createElement("button");o.type="button",o.className="lchip"+(b.hiddenTypes[r]?" off":""),o.innerHTML=`<span class="sw" style="background:${M(P(kt(),r))}"></span>${r} <span style="color:var(--muted);font-weight:500">${i}</span>`,o.addEventListener("click",()=>{b.hiddenTypes[r]=!b.hiddenTypes[r],Et(),b.restyle(),Mt()}),t.appendChild(o)}}function Mt(){let t=U();if(!t){k("lcount").textContent="";return}let e=t.nodes.filter(n=>!b.hiddenTypes[n.type]).length;k("lcount").textContent=`${e} / ${t.nodes.length} nodes shown`}function Se(){let t=k("counts");if(_.tab==="outline"&&_.code){let e=_.code.nodes.filter(n=>n.type==="file").length;t.textContent=`${e} files \xB7 ${_.code.nodes.length} symbols`}else{let e=U();t.textContent=e?`${e.meta.nodeCount} nodes \xB7 ${e.meta.edgeCount} links`:""}}function j(t){se(k("detail"),_.tab==="context"?_.context:_.code,kt(),t,e=>{_.tab==="outline"?(j(e),X(k("tree"),_.code,e,_.outlineOpen,j)):b.focus(e)})}b.onSelect=t=>j(t);function ce(t){_.tab=t,document.querySelectorAll(".tab").forEach(r=>{r.setAttribute("aria-selected",r.dataset.tab===t?"true":"false")});let e=t==="outline";k("canvasWrap").hidden=e,k("outlineView").hidden=!e,b.hiddenRels={},b.hiddenTypes={},b.selected=null,j(null);let n=k("graphEmpty");if(t==="outline")_.code?X(k("tree"),_.code,null,_.outlineOpen,j):(k("outlineView").hidden=!0,k("canvasWrap").hidden=!1,ae('No code graph yet \u2014 run <code>graft graph</code> to generate <span class="mono">graph.json</span>.'));else{let r=U();!r||r.nodes.length===0?ae(r?.meta.emptyNote?$e(r.meta.emptyNote):t==="code"?'No code graph yet \u2014 run <code>graft graph</code> to generate <span class="mono">graph.json</span>.':"No context graph \u2014 run <code>graft init</code> first."):(n.hidden=!0,b.resetView(),b.setData(r,kt()),b.reheat())}_t(),Et(),Mt(),Se()}function $e(t){return t.replace(/&/g,"&").replace(/</g,"<")}function ae(t){let e=k("graphEmpty");e.innerHTML=t,e.hidden=!1}document.querySelectorAll(".tab").forEach(t=>{t.addEventListener("click",()=>ce(t.dataset.tab))});var wt=k("search");wt.addEventListener("input",()=>{b.query=wt.value.trim(),b.restyle()});wt.addEventListener("keydown",t=>{if(t.key==="Enter"&&b.query){let e=b.firstMatch();e&&b.focus(e.id)}});k("zin").addEventListener("click",()=>b.zoomBy(1.25));k("zout").addEventListener("click",()=>b.zoomBy(1/1.25));k("zreset").addEventListener("click",()=>b.resetView());var de="graft-viz-theme",le=localStorage.getItem(de);le&&document.documentElement.setAttribute("data-theme",le);k("themeBtn").addEventListener("click",()=>{let t=document.documentElement,e=t.getAttribute("data-theme"),n=window.matchMedia("(prefers-color-scheme: dark)").matches,i=(e?e==="dark":n)?"light":"dark";t.setAttribute("data-theme",i),localStorage.setItem(de,i),b.restyle(),_t(),Et(),j(b.selected)});var ue="graft-viz-detail-w",bt=220,Ve=document.documentElement,ze=t=>Math.min(Math.max(bt,Math.round(window.innerWidth*.6)),Math.max(bt,Math.round(t)));function Ct(t,e=!0){let n=ze(t);Ve.style.setProperty("--detail-w",`${n}px`),e&&localStorage.setItem(ue,String(n))}var xt=Number(localStorage.getItem(ue));Number.isFinite(xt)&&xt>=bt&&Ct(xt,!1);var W=k("detailResizer"),at=!1;W.addEventListener("pointerdown",t=>{let e=t;at=!0,W.setPointerCapture(e.pointerId),document.body.style.cursor="col-resize",t.preventDefault()});W.addEventListener("pointermove",t=>{at&&Ct(window.innerWidth-t.clientX)});var fe=t=>{if(at){at=!1,document.body.style.cursor="";try{W.releasePointerCapture(t.pointerId)}catch{}b.reheat()}};W.addEventListener("pointerup",fe);W.addEventListener("pointercancel",fe);W.addEventListener("keydown",t=>{let e=t;if(e.key!=="ArrowLeft"&&e.key!=="ArrowRight")return;let n=e.shiftKey?40:16,r=k("detail").getBoundingClientRect().width;Ct(r+(e.key==="ArrowLeft"?n:-n)),b.reheat(),t.preventDefault()});async function he(){let[t,e]=await Promise.all([Tt(),At()]);_.context=t,_.code=e;let n=[t.meta.repoName,t.meta.subtitle].filter(Boolean).join(" \xB7 ");k("repoName").textContent=n,document.title=`graft viz \u2014 ${n}`;let r=t.meta.tabs;r&&document.querySelectorAll(".tab").forEach(o=>{o.hidden=!r.includes(o.dataset.tab)});let i=t.meta.defaultTab;ce(i&&i!==_.tab?i:_.tab)}St(()=>{let t=b.selected;he().then(()=>{t&&(b.selected=t,b.restyle(),j(t))})});he();
|
|
1
|
+
var mt={part_of:"structure",contains:"structure",uses:"dependency",depends_on:"dependency",calls:"dependency",imports:"dependency",produces:"dependency",configures:"dependency",validates:"dependency",extends:"contract",implements:"contract",references:"association"};function Y(e){return mt[e]??"association"}var $e={structure:85,dependency:145,contract:150,association:185};function ee(e){return Y(e)==="structure"?"part of":e==="calls"||e==="uses"||e==="depends_on"||e==="imports"?"uses":e.replace(/_/g," ")}var Le={"part of":"where does this live? (contains, part of)",uses:"what breaks if the target changes? (calls, uses, depends on, imports)",produces:"where does this output come from?",configures:"what changes its behavior without a code change?",validates:"what checks or judges this? (tests, drift checks, scoring)",extends:"what contract must this honor? (inheritance)",implements:"what contract must this honor? (interface)",references:"mentioned but never called \u2014 possible dead coupling"},gt={system:"--sys",concept:"--con",file:"--fil",api:"--api",changed:"--fil",affected:"--sys"},vt={file:"--k-file",class:"--k-class",function:"--k-fn",method:"--k-method",interface:"--k-iface",type:"--k-type",enum:"--k-enum"};function R(e,t){return(e==="code"?vt:gt)[t]??"--edge"}function k(e){return getComputedStyle(document.documentElement).getPropertyValue(e).trim()}var F=globalThis.__GRAFT_DATA__;async function Te(){return F?.contextGraph?F.contextGraph:await(await fetch("/api/context-graph")).json()}async function Ae(){let e;if(F){if(!F.codeGraph)return null;e=F.codeGraph}else{let r=await fetch("/api/code-graph");if(!r.ok)return null;e=await r.json()}let t=e.nodes.map(r=>({id:r.id,name:r.name,type:r.kind,summary:r.summary??r.signature??"",sources:[`${r.path} \xB7 ${r.span}`]})),n=new Set(t.map(r=>r.id)),i=e.edges.filter(r=>n.has(r.source)&&n.has(r.target)).map(r=>({source:r.source,target:r.target,relation:r.relation,confidence:r.confidence}));return{meta:{nodeCount:t.length,edgeCount:i.length},nodes:t,edges:i}}function Se(e){if(F)return;let t=new EventSource("/events");t.onmessage=n=>{n.data==="change"&&e()}}function ce(e,t){var n,i=1;e==null&&(e=0),t==null&&(t=0);function r(){var o,a=n.length,h,d=0,s=0;for(o=0;o<a;++o)h=n[o],d+=h.x,s+=h.y;for(d=(d/a-e)*i,s=(s/a-t)*i,o=0;o<a;++o)h=n[o],h.x-=d,h.y-=s}return r.initialize=function(o){n=o},r.x=function(o){return arguments.length?(e=+o,r):e},r.y=function(o){return arguments.length?(t=+o,r):t},r.strength=function(o){return arguments.length?(i=+o,r):i},r}function Ge(e){let t=+this._x.call(null,e),n=+this._y.call(null,e);return Ve(this.cover(t,n),t,n,e)}function Ve(e,t,n,i){if(isNaN(t)||isNaN(n))return e;var r,o=e._root,a={data:i},h=e._x0,d=e._y0,s=e._x1,l=e._y1,g,c,f,v,p,u,m,y;if(!o)return e._root=a,e;for(;o.length;)if((p=t>=(g=(h+s)/2))?h=g:s=g,(u=n>=(c=(d+l)/2))?d=c:l=c,r=o,!(o=o[m=u<<1|p]))return r[m]=a,e;if(f=+e._x.call(null,o.data),v=+e._y.call(null,o.data),t===f&&n===v)return a.next=o,r?r[m]=a:e._root=a,e;do r=r?r[m]=new Array(4):e._root=new Array(4),(p=t>=(g=(h+s)/2))?h=g:s=g,(u=n>=(c=(d+l)/2))?d=c:l=c;while((m=u<<1|p)===(y=(v>=c)<<1|f>=g));return r[y]=o,r[m]=a,e}function ze(e){var t,n,i=e.length,r,o,a=new Array(i),h=new Array(i),d=1/0,s=1/0,l=-1/0,g=-1/0;for(n=0;n<i;++n)isNaN(r=+this._x.call(null,t=e[n]))||isNaN(o=+this._y.call(null,t))||(a[n]=r,h[n]=o,r<d&&(d=r),r>l&&(l=r),o<s&&(s=o),o>g&&(g=o));if(d>l||s>g)return this;for(this.cover(d,s).cover(l,g),n=0;n<i;++n)Ve(this,a[n],h[n],e[n]);return this}function De(e,t){if(isNaN(e=+e)||isNaN(t=+t))return this;var n=this._x0,i=this._y0,r=this._x1,o=this._y1;if(isNaN(n))r=(n=Math.floor(e))+1,o=(i=Math.floor(t))+1;else{for(var a=r-n||1,h=this._root,d,s;n>e||e>=r||i>t||t>=o;)switch(s=(t<i)<<1|e<n,d=new Array(4),d[s]=h,h=d,a*=2,s){case 0:r=n+a,o=i+a;break;case 1:n=r-a,o=i+a;break;case 2:r=n+a,i=o-a;break;case 3:n=r-a,i=o-a;break}this._root&&this._root.length&&(this._root=h)}return this._x0=n,this._y0=i,this._x1=r,this._y1=o,this}function He(){var e=[];return this.visit(function(t){if(!t.length)do e.push(t.data);while(t=t.next)}),e}function Ie(e){return arguments.length?this.cover(+e[0][0],+e[0][1]).cover(+e[1][0],+e[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function L(e,t,n,i,r){this.node=e,this.x0=t,this.y0=n,this.x1=i,this.y1=r}function Oe(e,t,n){var i,r=this._x0,o=this._y0,a,h,d,s,l=this._x1,g=this._y1,c=[],f=this._root,v,p;for(f&&c.push(new L(f,r,o,l,g)),n==null?n=1/0:(r=e-n,o=t-n,l=e+n,g=t+n,n*=n);v=c.pop();)if(!(!(f=v.node)||(a=v.x0)>l||(h=v.y0)>g||(d=v.x1)<r||(s=v.y1)<o))if(f.length){var u=(a+d)/2,m=(h+s)/2;c.push(new L(f[3],u,m,d,s),new L(f[2],a,m,u,s),new L(f[1],u,h,d,m),new L(f[0],a,h,u,m)),(p=(t>=m)<<1|e>=u)&&(v=c[c.length-1],c[c.length-1]=c[c.length-1-p],c[c.length-1-p]=v)}else{var y=e-+this._x.call(null,f.data),b=t-+this._y.call(null,f.data),x=y*y+b*b;if(x<n){var M=Math.sqrt(n=x);r=e-M,o=t-M,l=e+M,g=t+M,i=f.data}}return i}function Re(e){if(isNaN(l=+this._x.call(null,e))||isNaN(g=+this._y.call(null,e)))return this;var t,n=this._root,i,r,o,a=this._x0,h=this._y0,d=this._x1,s=this._y1,l,g,c,f,v,p,u,m;if(!n)return this;if(n.length)for(;;){if((v=l>=(c=(a+d)/2))?a=c:d=c,(p=g>=(f=(h+s)/2))?h=f:s=f,t=n,!(n=n[u=p<<1|v]))return this;if(!n.length)break;(t[u+1&3]||t[u+2&3]||t[u+3&3])&&(i=t,m=u)}for(;n.data!==e;)if(r=n,!(n=n.next))return this;return(o=n.next)&&delete n.next,r?(o?r.next=o:delete r.next,this):t?(o?t[u]=o:delete t[u],(n=t[0]||t[1]||t[2]||t[3])&&n===(t[3]||t[2]||t[1]||t[0])&&!n.length&&(i?i[m]=n:this._root=n),this):(this._root=o,this)}function Be(e){for(var t=0,n=e.length;t<n;++t)this.remove(e[t]);return this}function je(){return this._root}function Pe(){var e=0;return this.visit(function(t){if(!t.length)do++e;while(t=t.next)}),e}function We(e){var t=[],n,i=this._root,r,o,a,h,d;for(i&&t.push(new L(i,this._x0,this._y0,this._x1,this._y1));n=t.pop();)if(!e(i=n.node,o=n.x0,a=n.y0,h=n.x1,d=n.y1)&&i.length){var s=(o+h)/2,l=(a+d)/2;(r=i[3])&&t.push(new L(r,s,l,h,d)),(r=i[2])&&t.push(new L(r,o,l,s,d)),(r=i[1])&&t.push(new L(r,s,a,h,l)),(r=i[0])&&t.push(new L(r,o,a,s,l))}return this}function Fe(e){var t=[],n=[],i;for(this._root&&t.push(new L(this._root,this._x0,this._y0,this._x1,this._y1));i=t.pop();){var r=i.node;if(r.length){var o,a=i.x0,h=i.y0,d=i.x1,s=i.y1,l=(a+d)/2,g=(h+s)/2;(o=r[0])&&t.push(new L(o,a,h,l,g)),(o=r[1])&&t.push(new L(o,l,h,d,g)),(o=r[2])&&t.push(new L(o,a,g,l,s)),(o=r[3])&&t.push(new L(o,l,g,d,s))}n.push(i)}for(;i=n.pop();)e(i.node,i.x0,i.y0,i.x1,i.y1);return this}function Ye(e){return e[0]}function Xe(e){return arguments.length?(this._x=e,this):this._x}function qe(e){return e[1]}function Ke(e){return arguments.length?(this._y=e,this):this._y}function B(e,t,n){var i=new de(t??Ye,n??qe,NaN,NaN,NaN,NaN);return e==null?i:i.addAll(e)}function de(e,t,n,i,r,o){this._x=e,this._y=t,this._x0=n,this._y0=i,this._x1=r,this._y1=o,this._root=void 0}function Qe(e){for(var t={data:e.data},n=t;e=e.next;)n=n.next={data:e.data};return t}var S=B.prototype=de.prototype;S.copy=function(){var e=new de(this._x,this._y,this._x0,this._y0,this._x1,this._y1),t=this._root,n,i;if(!t)return e;if(!t.length)return e._root=Qe(t),e;for(n=[{source:t,target:e._root=new Array(4)}];t=n.pop();)for(var r=0;r<4;++r)(i=t.source[r])&&(i.length?n.push({source:i,target:t.target[r]=new Array(4)}):t.target[r]=Qe(i));return e};S.add=Ge;S.addAll=ze;S.cover=De;S.data=He;S.extent=Ie;S.find=Oe;S.remove=Re;S.removeAll=Be;S.root=je;S.size=Pe;S.visit=We;S.visitAfter=Fe;S.x=Xe;S.y=Ke;function D(e){return function(){return e}}function z(e){return(e()-.5)*1e-6}function yt(e){return e.x+e.vx}function xt(e){return e.y+e.vy}function ue(e){var t,n,i,r=1,o=1;typeof e!="function"&&(e=D(e==null?1:+e));function a(){for(var s,l=t.length,g,c,f,v,p,u,m=0;m<o;++m)for(g=B(t,yt,xt).visitAfter(h),s=0;s<l;++s)c=t[s],p=n[c.index],u=p*p,f=c.x+c.vx,v=c.y+c.vy,g.visit(y);function y(b,x,M,A,G){var C=b.data,V=b.r,$=p+V;if(C){if(C.index>c.index){var I=f-C.x-C.vx,O=v-C.y-C.vy,H=I*I+O*O;H<$*$&&(I===0&&(I=z(i),H+=I*I),O===0&&(O=z(i),H+=O*O),H=($-(H=Math.sqrt(H)))/H*r,c.vx+=(I*=H)*($=(V*=V)/(u+V)),c.vy+=(O*=H)*$,C.vx-=I*($=1-$),C.vy-=O*$)}return}return x>f+$||A<f-$||M>v+$||G<v-$}}function h(s){if(s.data)return s.r=n[s.data.index];for(var l=s.r=0;l<4;++l)s[l]&&s[l].r>s.r&&(s.r=s[l].r)}function d(){if(t){var s,l=t.length,g;for(n=new Array(l),s=0;s<l;++s)g=t[s],n[g.index]=+e(g,s,t)}}return a.initialize=function(s,l){t=s,i=l,d()},a.iterations=function(s){return arguments.length?(o=+s,a):o},a.strength=function(s){return arguments.length?(r=+s,a):r},a.radius=function(s){return arguments.length?(e=typeof s=="function"?s:D(+s),d(),a):e},a}function wt(e){return e.index}function Ze(e,t){var n=e.get(t);if(!n)throw new Error("node not found: "+t);return n}function fe(e){var t=wt,n=g,i,r=D(30),o,a,h,d,s,l=1;e==null&&(e=[]);function g(u){return 1/Math.min(h[u.source.index],h[u.target.index])}function c(u){for(var m=0,y=e.length;m<l;++m)for(var b=0,x,M,A,G,C,V,$;b<y;++b)x=e[b],M=x.source,A=x.target,G=A.x+A.vx-M.x-M.vx||z(s),C=A.y+A.vy-M.y-M.vy||z(s),V=Math.sqrt(G*G+C*C),V=(V-o[b])/V*u*i[b],G*=V,C*=V,A.vx-=G*($=d[b]),A.vy-=C*$,M.vx+=G*($=1-$),M.vy+=C*$}function f(){if(a){var u,m=a.length,y=e.length,b=new Map(a.map((M,A)=>[t(M,A,a),M])),x;for(u=0,h=new Array(m);u<y;++u)x=e[u],x.index=u,typeof x.source!="object"&&(x.source=Ze(b,x.source)),typeof x.target!="object"&&(x.target=Ze(b,x.target)),h[x.source.index]=(h[x.source.index]||0)+1,h[x.target.index]=(h[x.target.index]||0)+1;for(u=0,d=new Array(y);u<y;++u)x=e[u],d[u]=h[x.source.index]/(h[x.source.index]+h[x.target.index]);i=new Array(y),v(),o=new Array(y),p()}}function v(){if(a)for(var u=0,m=e.length;u<m;++u)i[u]=+n(e[u],u,e)}function p(){if(a)for(var u=0,m=e.length;u<m;++u)o[u]=+r(e[u],u,e)}return c.initialize=function(u,m){a=u,s=m,f()},c.links=function(u){return arguments.length?(e=u,f(),c):e},c.id=function(u){return arguments.length?(t=u,c):t},c.iterations=function(u){return arguments.length?(l=+u,c):l},c.strength=function(u){return arguments.length?(n=typeof u=="function"?u:D(+u),v(),c):n},c.distance=function(u){return arguments.length?(r=typeof u=="function"?u:D(+u),p(),c):r},c}var bt={value:()=>{}};function Je(){for(var e=0,t=arguments.length,n={},i;e<t;++e){if(!(i=arguments[e]+"")||i in n||/[\s.]/.test(i))throw new Error("illegal type: "+i);n[i]=[]}return new te(n)}function te(e){this._=e}function kt(e,t){return e.trim().split(/^|\s+/).map(function(n){var i="",r=n.indexOf(".");if(r>=0&&(i=n.slice(r+1),n=n.slice(0,r)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:i}})}te.prototype=Je.prototype={constructor:te,on:function(e,t){var n=this._,i=kt(e+"",n),r,o=-1,a=i.length;if(arguments.length<2){for(;++o<a;)if((r=(e=i[o]).type)&&(r=_t(n[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++o<a;)if(r=(e=i[o]).type)n[r]=Ue(n[r],e.name,t);else if(t==null)for(r in n)n[r]=Ue(n[r],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new te(e)},call:function(e,t){if((r=arguments.length-2)>0)for(var n=new Array(r),i=0,r,o;i<r;++i)n[i]=arguments[i+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(o=this._[e],i=0,r=o.length;i<r;++i)o[i].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var i=this._[e],r=0,o=i.length;r<o;++r)i[r].value.apply(t,n)}};function _t(e,t){for(var n=0,i=e.length,r;n<i;++n)if((r=e[n]).name===t)return r.value}function Ue(e,t,n){for(var i=0,r=e.length;i<r;++i)if(e[i].name===t){e[i]=bt,e=e.slice(0,i).concat(e.slice(i+1));break}return n!=null&&e.push({name:t,value:n}),e}var he=Je;var X=0,Q=0,K=0,tt=1e3,ne,Z,re=0,j=0,ie=0,U=typeof performance=="object"&&performance.now?performance:Date,nt=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function ge(){return j||(nt(Et),j=U.now()+ie)}function Et(){j=0}function pe(){this._call=this._time=this._next=null}pe.prototype=oe.prototype={constructor:pe,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?ge():+n)+(t==null?0:+t),!this._next&&Z!==this&&(Z?Z._next=this:ne=this,Z=this),this._call=e,this._time=n,me()},stop:function(){this._call&&(this._call=null,this._time=1/0,me())}};function oe(e,t,n){var i=new pe;return i.restart(e,t,n),i}function rt(){ge(),++X;for(var e=ne,t;e;)(t=j-e._time)>=0&&e._call.call(void 0,t),e=e._next;--X}function et(){j=(re=U.now())+ie,X=Q=0;try{rt()}finally{X=0,Nt(),j=0}}function Mt(){var e=U.now(),t=e-re;t>tt&&(ie-=t,re=e)}function Nt(){for(var e,t=ne,n,i=1/0;t;)t._call?(i>t._time&&(i=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:ne=n);Z=e,me(i)}function me(e){if(!X){Q&&(Q=clearTimeout(Q));var t=e-j;t>24?(e<1/0&&(Q=setTimeout(et,e-U.now()-ie)),K&&(K=clearInterval(K))):(K||(re=U.now(),K=setInterval(Mt,tt)),X=1,nt(et))}}function it(){let e=1;return()=>(e=(1664525*e+1013904223)%4294967296)/4294967296}function ot(e){return e.x}function st(e){return e.y}var Ct=10,$t=Math.PI*(3-Math.sqrt(5));function ve(e){var t,n=1,i=.001,r=1-Math.pow(i,1/300),o=0,a=.6,h=new Map,d=oe(g),s=he("tick","end"),l=it();e==null&&(e=[]);function g(){c(),s.call("tick",t),n<i&&(d.stop(),s.call("end",t))}function c(p){var u,m=e.length,y;p===void 0&&(p=1);for(var b=0;b<p;++b)for(n+=(o-n)*r,h.forEach(function(x){x(n)}),u=0;u<m;++u)y=e[u],y.fx==null?y.x+=y.vx*=a:(y.x=y.fx,y.vx=0),y.fy==null?y.y+=y.vy*=a:(y.y=y.fy,y.vy=0);return t}function f(){for(var p=0,u=e.length,m;p<u;++p){if(m=e[p],m.index=p,m.fx!=null&&(m.x=m.fx),m.fy!=null&&(m.y=m.fy),isNaN(m.x)||isNaN(m.y)){var y=Ct*Math.sqrt(.5+p),b=p*$t;m.x=y*Math.cos(b),m.y=y*Math.sin(b)}(isNaN(m.vx)||isNaN(m.vy))&&(m.vx=m.vy=0)}}function v(p){return p.initialize&&p.initialize(e,l),p}return f(),t={tick:c,restart:function(){return d.restart(g),t},stop:function(){return d.stop(),t},nodes:function(p){return arguments.length?(e=p,f(),h.forEach(v),t):e},alpha:function(p){return arguments.length?(n=+p,t):n},alphaMin:function(p){return arguments.length?(i=+p,t):i},alphaDecay:function(p){return arguments.length?(r=+p,t):+r},alphaTarget:function(p){return arguments.length?(o=+p,t):o},velocityDecay:function(p){return arguments.length?(a=1-p,t):1-a},randomSource:function(p){return arguments.length?(l=p,h.forEach(v),t):l},force:function(p,u){return arguments.length>1?(u==null?h.delete(p):h.set(p,v(u)),t):h.get(p)},find:function(p,u,m){var y=0,b=e.length,x,M,A,G,C;for(m==null?m=1/0:m*=m,y=0;y<b;++y)G=e[y],x=p-G.x,M=u-G.y,A=x*x+M*M,A<m&&(C=G,m=A);return C},on:function(p,u){return arguments.length>1?(s.on(p,u),t):s.on(p)}}}function ye(){var e,t,n,i,r=D(-30),o,a=1,h=1/0,d=.81;function s(f){var v,p=e.length,u=B(e,ot,st).visitAfter(g);for(i=f,v=0;v<p;++v)t=e[v],u.visit(c)}function l(){if(e){var f,v=e.length,p;for(o=new Array(v),f=0;f<v;++f)p=e[f],o[p.index]=+r(p,f,e)}}function g(f){var v=0,p,u,m=0,y,b,x;if(f.length){for(y=b=x=0;x<4;++x)(p=f[x])&&(u=Math.abs(p.value))&&(v+=p.value,m+=u,y+=u*p.x,b+=u*p.y);f.x=y/m,f.y=b/m}else{p=f,p.x=p.data.x,p.y=p.data.y;do v+=o[p.data.index];while(p=p.next)}f.value=v}function c(f,v,p,u){if(!f.value)return!0;var m=f.x-t.x,y=f.y-t.y,b=u-v,x=m*m+y*y;if(b*b/d<x)return x<h&&(m===0&&(m=z(n),x+=m*m),y===0&&(y=z(n),x+=y*y),x<a&&(x=Math.sqrt(a*x)),t.vx+=m*f.value*i/x,t.vy+=y*f.value*i/x),!0;if(f.length||x>=h)return;(f.data!==t||f.next)&&(m===0&&(m=z(n),x+=m*m),y===0&&(y=z(n),x+=y*y),x<a&&(x=Math.sqrt(a*x)));do f.data!==t&&(b=o[f.data.index]*i/x,t.vx+=m*b,t.vy+=y*b);while(f=f.next)}return s.initialize=function(f,v){e=f,n=v,l()},s.strength=function(f){return arguments.length?(r=typeof f=="function"?f:D(+f),l(),s):r},s.distanceMin=function(f){return arguments.length?(a=f*f,s):Math.sqrt(a)},s.distanceMax=function(f){return arguments.length?(h=f*f,s):Math.sqrt(h)},s.theta=function(f){return arguments.length?(d=f*f,s):Math.sqrt(d)},s}function T(e){return e.replace(/&/g,"&").replace(/</g,"<")}function Lt(e){let t=e.lines.map(n=>`<div class="ev-l ${n.sign==="+"?"add":n.sign==="-"?"del":"ctx"}"><span class="ev-n">${n.n??""}</span><span class="ev-s">${n.sign===" "?"":n.sign}</span><span class="ev-t">${T(n.text)}</span></div>`).join("");return`<div class="ev"><div class="ev-h mono">${T(e.label)}${e.note?` <span class="ev-note">${T(e.note)}</span>`:""}</div><div class="ev-b mono">${t}</div>`+(e.more?`<div class="ev-more">+ ${e.more} more lines</div>`:"")+"</div>"}function xe(e){let t=e.split(/[\s._-]+/).filter(Boolean);return(t.length>=2?t[0][0]+t[1][0]:(t[0]??"?").slice(0,2)).toUpperCase()}function Tt(e,t=Date.now()){let n=Date.parse(`${e}T00:00:00Z`);if(!Number.isFinite(n))return e;let i=Math.max(0,Math.round((t-n)/864e5));if(i<1)return"today";if(i===1)return"yesterday";if(i<31)return`${i}d ago`;let r=Math.round(i/30);return r<24?`${r}mo ago`:`${Math.round(i/365)}y ago`}function At(e){let t=e.map(r=>{let o=r.handle?`@${T(r.handle)}`:T(r.name),a=r.handle?"own-name mono":"own-name";return`<div class="own"><span class="av">${T(xe(r.handle??r.name))}</span><span class="own-txt"><span class="${a}">${o}</span><span class="own-why">${r.commits} commit${r.commits===1?"":"s"} here \xB7 last ${T(Tt(r.last))}</span></span></div>`}).join(""),n=e.filter(r=>!r.handle),i=n.length?`<div class="own-note">\u26A0 ${T(n.map(r=>r.name).join(", "))} ${n.length===1?"has":"have"} no GitHub handle in their commit email.</div>`:"";return`<div class="owners">${t}${i}</div>`}function at(e,t,n,i,r){if(!i||!t){e.innerHTML='<div class="empty">Select a node to view details</div>';return}let o=t.nodes.find(c=>c.id===i);if(!o){e.innerHTML='<div class="empty">Select a node to view details</div>';return}let a=k(R(n,o.type)),h=c=>t.nodes.find(f=>f.id===c)?.name??c,d=t.edges.filter(c=>c.source===i),s=t.edges.filter(c=>c.target===i),l=`<span class="d-type"><span class="sw" style="background:${a}"></span>${T(o.type)}</span>`;if(l+=`<h3>${T(o.name)}</h3>`,o.summary&&(l+=`<p class="summary">${T(o.summary)}</p>`),o.owners?.length&&(l+=`<div class="d-label"><span class="dot" style="background:var(--con)"></span>Who knows this \xB7 ${o.owners.length}</div>`,l+=At(o.owners)),o.evidence?.length){l+=`<div class="d-label">Code \xB7 ${o.evidence.length}</div>`;for(let f of o.evidence)l+=Lt(f);let c=o.sources.length-o.evidence.length;c>0&&(l+=`<div class="src mono">+ ${c} more, not shown</div>`)}else if(o.sources.length){l+=`<div class="d-label">Sources \xB7 ${o.sources.length}</div>`;for(let c of o.sources)l+=`<div class="src mono">${T(c)}</div>`}let g=(c,f,v,p)=>{if(c.length){l+=`<div class="d-label"><span class="dot" style="background:${f}"></span>${v} \xB7 ${c.length}</div>`;for(let u of c)l+=`<button class="lnk" data-go="${T(p(u))}"><span class="rel">${T(u.relation.replace(/_/g," "))}</span> <span class="to">${T(h(p(u)))}</span>`+(u.description?`<div class="desc">${T(u.description)}</div>`:"")+"</button>"}};g(d,k("--fil"),"Depends on",c=>c.target),g(s,k("--accent"),"Depended on by",c=>c.source),e.innerHTML=l,e.querySelectorAll("[data-go]").forEach(c=>{c.addEventListener("click",()=>r(c.dataset.go))})}var St="http://www.w3.org/2000/svg",Gt=2;function N(e,t){let n=document.createElementNS(St,e);for(let[i,r]of Object.entries(t))n.setAttribute(i,String(r));return n}function Vt(e){let t=e.owners??[];if(t.length===0)return null;let n=t.slice(0,Gt),i=t.length-n.length,r=[...n.map(a=>xe(a.handle??a.name)),...i>0?[`+${i}`]:[]],o=N("g",{"pointer-events":"none"});return r.forEach((a,h)=>{let d=e.r*.72+h*13,s=-e.r*.72+h*8;o.appendChild(N("circle",{cx:d,cy:s,r:8,fill:k("--panel"),stroke:k("--con"),"stroke-width":1.2}));let l=N("text",{x:d,y:s+3,"text-anchor":"middle","font-size":7.5,"font-weight":700,fill:k("--con")});l.textContent=a;let g=N("title",{});g.textContent=t.map(c=>`${c.handle?`@${c.handle}`:c.name} \u2014 ${c.commits} commits`).join(`
|
|
2
|
+
`),o.append(l,g)}),o}var se=class{svg;defs;viewport;sim=null;nodes=[];edges=[];edgeEls=[];nodeEls=[];view={x:0,y:0,k:1};tab="context";selected=null;query="";hiddenRels={};hiddenTypes={};showOwners=!0;onSelect=()=>{};constructor(t){this.svg=t,this.buildChrome(),this.bindPanZoom()}buildChrome(){this.svg.textContent="",this.defs=N("defs",{}),this.svg.appendChild(this.defs),this.viewport=N("g",{}),this.svg.appendChild(this.viewport),this.svg.addEventListener("click",()=>this.select(null))}ensureMarkers(){this.defs.textContent="";let t=N("marker",{id:"arr",viewBox:"0 0 10 10",refX:8,refY:5,markerWidth:4.5,markerHeight:4.5,orient:"auto-start-reverse"});t.appendChild(N("path",{d:"M2,1.5L8.5,5L2,8.5",fill:"none",stroke:k("--edge"),"stroke-width":1.8,"stroke-linecap":"round","stroke-linejoin":"round",opacity:.75}));let n=N("marker",{id:"arrH",viewBox:"0 0 12 12",refX:10,refY:6,markerWidth:6.5,markerHeight:6.5,orient:"auto-start-reverse"});n.appendChild(N("path",{d:"M1.5,1.5L10.5,6L1.5,10.5z",fill:k("--canvas"),stroke:k("--edge"),"stroke-width":1.4}));let i=N("marker",{id:"arrOut",viewBox:"0 0 10 10",refX:8,refY:5,markerWidth:5,markerHeight:5,orient:"auto-start-reverse"});i.appendChild(N("path",{d:"M1,1L9,5L1,9z",fill:k("--fil")}));let r=N("marker",{id:"arrIn",viewBox:"0 0 10 10",refX:8,refY:5,markerWidth:5,markerHeight:5,orient:"auto-start-reverse"});r.appendChild(N("path",{d:"M1,1L9,5L1,9z",fill:k("--accent")}));for(let o of[t,n,i,r])this.defs.appendChild(o)}setData(t,n){this.tab=n;let i=new Map(this.nodes.map(d=>[d.id,d])),r={};for(let d of t.edges)r[d.source]=(r[d.source]??0)+1,r[d.target]=(r[d.target]??0)+1;let o=this.svg.clientWidth||800,a=this.svg.clientHeight||600;this.nodes=t.nodes.map((d,s)=>{let l=i.get(d.id),g=s/Math.max(1,t.nodes.length)*Math.PI*2,c=r[d.id]??0;return{id:d.id,name:d.name,type:d.type,owners:d.owners,deg:c,r:11+Math.min(13,c*2.6),x:l?.x??o/2+Math.cos(g)*Math.min(o,a)/4,y:l?.y??a/2+Math.sin(g)*Math.min(o,a)/4,vx:l?.vx??0,vy:l?.vy??0}});let h=new Map(this.nodes.map(d=>[d.id,d]));this.edges=t.edges.map(d=>({source:h.get(d.source),target:h.get(d.target),relation:d.relation,description:d.description,confidence:d.confidence})).filter(d=>d.source&&d.target),this.sim?.stop(),this.sim=ve(this.nodes).force("charge",ye().strength(-220)).force("link",fe(this.edges).distance(d=>$e[Y(d.relation)]).strength(.5)).force("center",ce(o/2,a/2)).force("collide",ue().radius(d=>d.r+6)).on("tick",()=>this.tick()),this.buildElements(),this.restyle()}buildElements(){this.ensureMarkers(),this.viewport.textContent="",this.edgeEls=this.edges.map(t=>{let n=N("path",{fill:"none","stroke-linecap":"round"}),i=N("title",{});i.textContent=t.relation.replace(/_/g," ")+(t.description?` \u2014 ${t.description}`:""),n.appendChild(i);let r=N("text",{"text-anchor":"middle","font-size":9.5,"font-weight":700,"stroke-width":3,"paint-order":"stroke",display:"none"});return r.textContent=t.relation.replace(/_/g," "),this.viewport.appendChild(n),this.viewport.appendChild(r),{path:n,label:r,edge:t}}),this.nodeEls=this.nodes.map(t=>{let n=N("g",{cursor:"pointer"}),i=N("circle",{fill:"none","stroke-width":1.6,opacity:0,r:t.r+5}),r=N("circle",{r:t.r,opacity:.92}),o=N("text",{y:t.r+15,"text-anchor":"middle","font-size":11.5,"font-weight":600});o.textContent=t.name;let a=Vt(t);return n.append(i,r,o),a&&n.appendChild(a),n.addEventListener("click",h=>{h.stopPropagation(),this.select(t.id)}),this.bindDrag(n,t),this.viewport.appendChild(n),{group:n,circle:r,ring:i,label:o,badges:a,node:t}})}tick(){for(let{path:t,label:n,edge:i}of this.edgeEls){let r=i.source,o=i.target,a=(o.x??0)-(r.x??0),h=(o.y??0)-(r.y??0),d=Math.sqrt(a*a+h*h)||1,s=a/d,l=h/d,g=(r.x??0)+s*(r.r+2),c=(r.y??0)+l*(r.r+2),f=(o.x??0)-s*(o.r+6),v=(o.y??0)-l*(o.r+6),p=(g+f)/2-l*10,u=(c+v)/2+s*10;t.setAttribute("d",`M${g},${c} Q${p},${u} ${f},${v}`),n.setAttribute("x",String((g+f)/2-l*14)),n.setAttribute("y",String((c+v)/2+s*14))}for(let{group:t,node:n}of this.nodeEls)t.setAttribute("transform",`translate(${n.x??0},${n.y??0})`)}restyle(){this.ensureMarkers();let t=new Set;if(this.selected)for(let r of this.edges)r.source.id===this.selected&&t.add(r.target.id),r.target.id===this.selected&&t.add(r.source.id);let n=this.query.toLowerCase(),i=r=>!this.hiddenTypes[r.type];for(let{path:r,label:o,edge:a}of this.edgeEls){let h=i(a.source)&&i(a.target)&&!this.hiddenRels[ee(a.relation)];if(r.style.display=h?"":"none",o.setAttribute("display","none"),!h)continue;let d=Y(a.relation),s=k("--edge"),l=1.3,g="none",c=.5,f="url(#arr)";d==="structure"?(l=2.4,c=.32,f="none"):d==="dependency"?(l=1.5,c=.55):d==="contract"?(c=.55,f="url(#arrH)"):(g="2 5",l=1.2,c=.28,f="none"),a.confidence==="inferred"&&(g="5 4"),n&&(c=.12);let v=this.selected?a.source.id===this.selected?"out":a.target.id===this.selected?"in":"far":"none";v==="out"?(s=k("--fil"),c=.95,l+=.7,f="url(#arrOut)"):v==="in"?(s=k("--accent"),c=.95,l+=.7,f="url(#arrIn)"):v==="far"&&(c=.06),r.setAttribute("stroke",s),r.setAttribute("stroke-width",String(l)),r.setAttribute("stroke-dasharray",g),r.setAttribute("opacity",String(c)),f==="none"?r.removeAttribute("marker-end"):r.setAttribute("marker-end",f),(v==="out"||v==="in")&&(o.removeAttribute("display"),o.setAttribute("fill",s),o.setAttribute("stroke",k("--canvas")))}for(let{group:r,circle:o,ring:a,label:h,badges:d,node:s}of this.nodeEls){let l=i(s);if(r.style.display=l?"":"none",!l)continue;let c=!n||s.name.toLowerCase().includes(n)?1:.22;this.selected&&s.id!==this.selected&&!t.has(s.id)&&(c=Math.min(c,.2)),r.setAttribute("opacity",String(c));let f=k(R(this.tab,s.type));o.setAttribute("fill",f),a.setAttribute("stroke",f),a.setAttribute("opacity",s.id===this.selected?"0.55":"0"),h.setAttribute("fill",k("--ink")),d&&(d.style.display=this.showOwners?"":"none")}}select(t){this.selected=t,this.restyle(),this.onSelect(t)}focus(t){let n=this.nodes.find(o=>o.id===t);if(!n)return;let i=this.svg.clientWidth,r=this.svg.clientHeight;this.view.k=Math.max(this.view.k,1.4),this.view.x=i/2-(n.x??0)*this.view.k,this.view.y=r/2-(n.y??0)*this.view.k,this.applyView(),this.select(t)}firstMatch(){let t=this.query.toLowerCase();return this.nodes.find(n=>!this.hiddenTypes[n.type]&&n.name.toLowerCase().includes(t))}applyView(){this.viewport.setAttribute("transform",`translate(${this.view.x},${this.view.y}) scale(${this.view.k})`)}zoomBy(t){let n=this.svg.clientWidth/2,i=this.svg.clientHeight/2,r=Math.max(.35,Math.min(3,this.view.k*t));this.view.x=n-(n-this.view.x)*(r/this.view.k),this.view.y=i-(i-this.view.y)*(r/this.view.k),this.view.k=r,this.applyView()}resetView(){this.view={x:0,y:0,k:1},this.applyView()}reheat(){this.sim?.alpha(.6).restart()}bindDrag(t,n){t.addEventListener("pointerdown",i=>{i.stopPropagation(),t.setPointerCapture(i.pointerId);let r=a=>{let h=this.svg.getBoundingClientRect();n.fx=(a.clientX-h.left-this.view.x)/this.view.k,n.fy=(a.clientY-h.top-this.view.y)/this.view.k,this.sim?.alphaTarget(.25).restart()},o=()=>{n.fx=null,n.fy=null,this.sim?.alphaTarget(0),t.removeEventListener("pointermove",r),t.removeEventListener("pointerup",o)};t.addEventListener("pointermove",r),t.addEventListener("pointerup",o)})}bindPanZoom(){let t=null;this.svg.addEventListener("pointerdown",n=>{t={x:n.clientX-this.view.x,y:n.clientY-this.view.y}}),this.svg.addEventListener("pointermove",n=>{t&&(this.view.x=n.clientX-t.x,this.view.y=n.clientY-t.y,this.applyView())}),window.addEventListener("pointerup",()=>{t=null}),this.svg.addEventListener("wheel",n=>{n.preventDefault();let i=this.svg.getBoundingClientRect(),r=n.clientX-i.left,o=n.clientY-i.top,a=Math.max(.35,Math.min(3,this.view.k*Math.exp(-n.deltaY*.0016)));this.view.x=r-(r-this.view.x)*(a/this.view.k),this.view.y=o-(o-this.view.y)*(a/this.view.k),this.view.k=a,this.applyView()},{passive:!1})}};function we(e){return e.replace(/&/g,"&").replace(/</g,"<")}function q(e,t,n,i,r){let o=s=>t.edges.filter(l=>l.relation==="contains"&&l.source===s).map(l=>t.nodes.find(g=>g.id===l.target)).filter(l=>!!l),a=s=>{let l=o(s);return l.length+l.reduce((g,c)=>g+a(c.id),0)},h=t.nodes.filter(s=>s.type==="file"),d=s=>{let l=o(s.id),g=i[s.id]!==!1,c=`<button class="tree-row${g?" open":""}${n===s.id?" sel":""}" data-id="${we(s.id)}" data-haskids="${l.length?1:0}"><span class="chev">${l.length?"\u25B6":""}</span><span class="k" style="background:${k(R("code",s.type))}"></span><span class="t${s.type==="file"?" mono":""}">${we(s.name)}</span><span class="badge">${l.length?a(s.id)+" sym":we(s.type)}</span></button>`;return l.length&&g&&(c+=`<div class="tree-kids">${l.map(d).join("")}</div>`),c};e.innerHTML='<div class="tree-tools"><button data-tool="expand">Expand all</button><button data-tool="collapse">Collapse all</button></div>'+h.map(d).join(""),e.querySelectorAll(".tree-row").forEach(s=>{s.addEventListener("click",()=>{let l=s.dataset.id;s.dataset.haskids==="1"&&(i[l]=i[l]===!1,q(e,t,l,i,r)),r(l)})}),e.querySelector('[data-tool="expand"]')?.addEventListener("click",()=>{for(let s of Object.keys(i))delete i[s];q(e,t,n,i,r)}),e.querySelector('[data-tool="collapse"]')?.addEventListener("click",()=>{for(let s of t.nodes)i[s.id]=!1;q(e,t,n,i,r)})}var _=e=>document.getElementById(e),E={tab:"context",context:null,code:null,outlineOpen:{}},w=new se(_("graphSvg"));function J(){return E.tab==="context"?E.context:E.code}function Ee(){return E.tab==="code"||E.tab==="outline"?"code":"context"}function Me(){let e=_("edgeChips");e.innerHTML='<span class="cap">Edges</span>';let t=J();if(!t)return;let n=new Map;for(let r of t.edges){let o=ee(r.relation);n.set(o,(n.get(o)??0)+1)}let i=[...n.keys()].sort((r,o)=>{let a=h=>h==="part of"?0:h==="uses"?1:2;return a(r)-a(o)||r.localeCompare(o)});for(let r of i){let o=document.createElement("button");o.type="button",o.className="echip"+(w.hiddenRels[r]?"":" on"),o.innerHTML=`${zt(r)} ${r} <span style="opacity:.55">${n.get(r)}</span>`,o.title=(Le[r]??`"${r}" edges`)+" \u2014 click to "+(w.hiddenRels[r]?"show":"hide"),o.addEventListener("click",()=>{w.hiddenRels[r]=!w.hiddenRels[r],Me(),w.restyle(),Ne()}),e.appendChild(o)}}function zt(e){let t=e==="part of"?"structure":e==="uses"?"dependency":Y(e.replace(/ /g,"_"));return{structure:'<svg width="20" height="8" aria-hidden="true"><line x1="1" y1="4" x2="19" y2="4" stroke="currentColor" stroke-width="3" opacity=".5"/></svg>',dependency:'<svg width="20" height="8" aria-hidden="true"><line x1="1" y1="4" x2="14" y2="4" stroke="currentColor" stroke-width="1.6"/><path d="M14,1 L19,4 L14,7 z" fill="currentColor"/></svg>',contract:'<svg width="20" height="8" aria-hidden="true"><line x1="1" y1="4" x2="13" y2="4" stroke="currentColor" stroke-width="1.4"/><path d="M13,1 L19,4 L13,7 z" fill="none" stroke="currentColor" stroke-width="1.2"/></svg>',association:'<svg width="20" height="8" aria-hidden="true"><line x1="1" y1="4" x2="19" y2="4" stroke="currentColor" stroke-width="1.4" stroke-dasharray="2 4" opacity=".7"/></svg>'}[t]}function ae(){let e=_("legend");e.innerHTML="";let t=J();if(!t)return;let n=new Map;for(let r of t.nodes)n.set(r.type,(n.get(r.type)??0)+1);for(let[r,o]of n){let a=document.createElement("button");a.type="button",a.className="lchip"+(w.hiddenTypes[r]?" off":""),a.innerHTML=`<span class="sw" style="background:${k(R(Ee(),r))}"></span>${r} <span style="color:var(--muted);font-weight:500">${o}</span>`,a.addEventListener("click",()=>{w.hiddenTypes[r]=!w.hiddenTypes[r],ae(),w.restyle(),Ne()}),e.appendChild(a)}if(t.nodes.some(r=>r.owners?.length)){let r=document.createElement("button");r.type="button",r.className="lchip lchip-people"+(w.showOwners?"":" off"),r.innerHTML=`<span class="sw" style="background:${k("--con")}"></span>people`,r.title="Show who has worked on each area",r.addEventListener("click",()=>{w.showOwners=!w.showOwners,ae(),w.restyle()}),e.appendChild(r)}}function Ne(){let e=J();if(!e){_("lcount").textContent="";return}let t=e.nodes.filter(n=>!w.hiddenTypes[n.type]).length;_("lcount").textContent=`${t} / ${e.nodes.length} nodes shown`}function Dt(){let e=_("counts");if(E.tab==="outline"&&E.code){let t=E.code.nodes.filter(n=>n.type==="file").length;e.textContent=`${t} files \xB7 ${E.code.nodes.length} symbols`}else{let t=J();e.textContent=t?`${t.meta.nodeCount} nodes \xB7 ${t.meta.edgeCount} links`:""}}function P(e){at(_("detail"),E.tab==="context"?E.context:E.code,Ee(),e,t=>{E.tab==="outline"?(P(t),q(_("tree"),E.code,t,E.outlineOpen,P)):w.focus(t)})}w.onSelect=e=>P(e);function dt(e){E.tab=e,document.querySelectorAll(".tab").forEach(i=>{i.setAttribute("aria-selected",i.dataset.tab===e?"true":"false")});let t=e==="outline";_("canvasWrap").hidden=t,_("outlineView").hidden=!t,w.hiddenRels={},w.hiddenTypes={},w.selected=null,P(null);let n=_("graphEmpty");if(e==="outline")E.code?q(_("tree"),E.code,null,E.outlineOpen,P):(_("outlineView").hidden=!0,_("canvasWrap").hidden=!1,lt('No code graph yet \u2014 run <code>graft graph</code> to generate <span class="mono">graph.json</span>.'));else{let i=J();!i||i.nodes.length===0?lt(i?.meta.emptyNote?Ht(i.meta.emptyNote):e==="code"?'No code graph yet \u2014 run <code>graft graph</code> to generate <span class="mono">graph.json</span>.':"No context graph \u2014 run <code>graft init</code> first."):(n.hidden=!0,w.resetView(),w.setData(i,Ee()),w.reheat())}Me(),ae(),Ne(),Dt()}function Ht(e){return e.replace(/&/g,"&").replace(/</g,"<")}function lt(e){let t=_("graphEmpty");t.innerHTML=e,t.hidden=!1}document.querySelectorAll(".tab").forEach(e=>{e.addEventListener("click",()=>dt(e.dataset.tab))});var ke=_("search");ke.addEventListener("input",()=>{w.query=ke.value.trim(),w.restyle()});ke.addEventListener("keydown",e=>{if(e.key==="Enter"&&w.query){let t=w.firstMatch();t&&w.focus(t.id)}});_("zin").addEventListener("click",()=>w.zoomBy(1.25));_("zout").addEventListener("click",()=>w.zoomBy(1/1.25));_("zreset").addEventListener("click",()=>w.resetView());var ut="graft-viz-theme",ct=localStorage.getItem(ut);ct&&document.documentElement.setAttribute("data-theme",ct);_("themeBtn").addEventListener("click",()=>{let e=document.documentElement,t=e.getAttribute("data-theme"),n=window.matchMedia("(prefers-color-scheme: dark)").matches,r=(t?t==="dark":n)?"light":"dark";e.setAttribute("data-theme",r),localStorage.setItem(ut,r),w.restyle(),Me(),ae(),P(w.selected)});var ft="graft-viz-detail-w",_e=220,It=document.documentElement,Ot=e=>Math.min(Math.max(_e,Math.round(window.innerWidth*.6)),Math.max(_e,Math.round(e)));function Ce(e,t=!0){let n=Ot(e);It.style.setProperty("--detail-w",`${n}px`),t&&localStorage.setItem(ft,String(n))}var be=Number(localStorage.getItem(ft));Number.isFinite(be)&&be>=_e&&Ce(be,!1);var W=_("detailResizer"),le=!1;W.addEventListener("pointerdown",e=>{let t=e;le=!0,W.setPointerCapture(t.pointerId),document.body.style.cursor="col-resize",e.preventDefault()});W.addEventListener("pointermove",e=>{le&&Ce(window.innerWidth-e.clientX)});var ht=e=>{if(le){le=!1,document.body.style.cursor="";try{W.releasePointerCapture(e.pointerId)}catch{}w.reheat()}};W.addEventListener("pointerup",ht);W.addEventListener("pointercancel",ht);W.addEventListener("keydown",e=>{let t=e;if(t.key!=="ArrowLeft"&&t.key!=="ArrowRight")return;let n=t.shiftKey?40:16,i=_("detail").getBoundingClientRect().width;Ce(i+(t.key==="ArrowLeft"?n:-n)),w.reheat(),e.preventDefault()});async function pt(){let[e,t]=await Promise.all([Te(),Ae()]);E.context=e,E.code=t;let n=[e.meta.repoName,e.meta.subtitle].filter(Boolean).join(" \xB7 ");_("repoName").textContent=n,document.title=`graft viz \u2014 ${n}`;let i=e.meta.tabs;i&&document.querySelectorAll(".tab").forEach(o=>{o.hidden=!i.includes(o.dataset.tab)});let r=e.meta.defaultTab;dt(r&&r!==E.tab?r:E.tab)}Se(()=>{let e=w.selected;pt().then(()=>{e&&(w.selected=e,w.restyle(),P(e))})});pt();
|
package/dist/viewer/style.css
CHANGED
|
@@ -138,3 +138,17 @@ svg.graph:active{cursor:grabbing}
|
|
|
138
138
|
.ev-l.add .ev-s{color:var(--ok,#2E9E6B)}
|
|
139
139
|
.ev-l.del .ev-s{color:var(--warn,#D9534F)}
|
|
140
140
|
.ev-more{font-size:11px;color:var(--muted);padding:3px 9px 5px}
|
|
141
|
+
|
|
142
|
+
/* ---- contributors: who has worked on an area (blast --export-viz) ---- */
|
|
143
|
+
.lchip.lchip-people{border-color:var(--con);color:var(--con)}
|
|
144
|
+
.owners{display:flex;flex-direction:column;gap:2px;margin:6px 0 2px}
|
|
145
|
+
.own{display:flex;align-items:center;gap:9px;padding:6px 8px;border-radius:7px;background:var(--panel2);border:1px solid var(--border2)}
|
|
146
|
+
.av{
|
|
147
|
+
width:25px;height:25px;border-radius:50%;flex:none;display:grid;place-items:center;
|
|
148
|
+
font-family:ui-monospace,"SF Mono",SFMono-Regular,Menlo,Consolas,monospace;
|
|
149
|
+
font-size:10px;font-weight:700;color:var(--con);background:var(--chip);border:1px solid var(--con);
|
|
150
|
+
}
|
|
151
|
+
.own-txt{display:flex;flex-direction:column;min-width:0;gap:1px}
|
|
152
|
+
.own-name{font-size:12.5px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
153
|
+
.own-why{font-size:11px;color:var(--muted);font-variant-numeric:tabular-nums}
|
|
154
|
+
.own-note{font-size:11px;color:var(--muted);padding:3px 8px 0;line-height:1.45}
|
package/dist/viz/assemble.d.ts
CHANGED
|
@@ -7,6 +7,23 @@ export interface VizNode {
|
|
|
7
7
|
/** Code to show under the node, in place of `sources`. Set by
|
|
8
8
|
* `blast --export-viz`, where every node stands for real changed lines. */
|
|
9
9
|
evidence?: Evidence[];
|
|
10
|
+
/** Who has worked on this area, best first. Set by `blast --export-viz`. */
|
|
11
|
+
owners?: NodeOwner[];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* One contributor on a node, as the exported page carries them.
|
|
15
|
+
*
|
|
16
|
+
* `last` is an ISO day rather than "9d ago" so the page stays truthful when it is
|
|
17
|
+
* opened a fortnight after it was published — the viewer does the arithmetic at
|
|
18
|
+
* read time. `handle` is absent whenever git carried no GitHub address for them,
|
|
19
|
+
* and the viewer must then render the name unlinked.
|
|
20
|
+
*/
|
|
21
|
+
export interface NodeOwner {
|
|
22
|
+
name: string;
|
|
23
|
+
handle?: string;
|
|
24
|
+
commits: number;
|
|
25
|
+
/** `YYYY-MM-DD` of their most recent commit in this area. */
|
|
26
|
+
last: string;
|
|
10
27
|
}
|
|
11
28
|
export interface VizEdge {
|
|
12
29
|
source: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assemble.d.ts","sourceRoot":"","sources":["../../src/viz/assemble.ts"],"names":[],"mappings":"AAiBA,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB;+EAC2E;IAC3E,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"assemble.d.ts","sourceRoot":"","sources":["../../src/viz/assemble.ts"],"names":[],"mappings":"AAiBA,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB;+EAC2E;IAC3E,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC;IACtB,4EAA4E;IAC5E,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC;CACtB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,6DAA6D;IAC7D,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,OAAO;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,uDAAuD;IACvD,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjB,IAAI,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;GAMG;AACH,MAAM,WAAW,QAAQ;IACvB,sEAAsE;IACtE,KAAK,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,yEAAyE;IACzE,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE;QACJ,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,YAAY,EAAE,MAAM,CAAC;QACrB,YAAY,EAAE,MAAM,CAAC;QACrB;;oEAE4D;QAC5D,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,KAAK,EAAE,OAAO,EAAE,CAAC;IACjB,KAAK,EAAE,OAAO,EAAE,CAAC;CAClB;AAED;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAKrD,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAErD;AAoBD,uEAAuE;AACvE,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,QAAQ,CAmDjE"}
|
package/dist/viz/assemble.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assemble.js","sourceRoot":"","sources":["../../src/viz/assemble.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,MAAM,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"assemble.js","sourceRoot":"","sources":["../../src/viz/assemble.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,MAAM,MAAM,aAAa,CAAC;AAkFjC;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAA2B;IACxD,UAAU,EAAE,YAAY;IACxB,QAAQ,EAAE,WAAW;IACrB,OAAO,EAAE,WAAW;IACpB,QAAQ,EAAE,WAAW;CACtB,CAAC;AAEF,MAAM,UAAU,iBAAiB,CAAC,GAAW;IAC3C,OAAO,kBAAkB,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC;AACxC,CAAC;AAED,MAAM,SAAS,GAAG,kCAAkC,CAAC;AACrD,MAAM,OAAO,GAAG,gCAAgC,CAAC;AACjD,MAAM,WAAW,GAAG,GAAG,CAAC;AAExB,mEAAmE;AACnE,SAAS,cAAc,CAAC,IAAY;IAClC,IAAI,IAAI,GAAG,IAAI,CAAC;IAChB,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACtC,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAClC,IAAI,KAAK,IAAI,CAAC,IAAI,GAAG,GAAG,KAAK;QAAE,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChF,yDAAyD;IACzD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAC3C,IAAI,OAAO,IAAI,CAAC;QAAE,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IAChD,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC;IAC9C,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IACnB,OAAO,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,OAAO,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;AACvF,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,oBAAoB,CAAC,UAAkB;IACrD,MAAM,KAAK,GAAc,EAAE,CAAC;IAC5B,MAAM,QAAQ,GAAc,EAAE,CAAC;IAC/B,IAAI,YAAY,GAAG,CAAC,CAAC;IAErB,IAAI,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC3B,KAAK,MAAM,KAAK,IAAI,WAAW,CAAC,UAAU,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;YACnD,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC;gBAAE,SAAS;YACrC,IAAI,MAAqC,CAAC;YAC1C,IAAI,CAAC;gBACH,MAAM,GAAG,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;YACjE,CAAC;YAAC,MAAM,CAAC;gBACP,YAAY,EAAE,CAAC;gBACf,SAAS;YACX,CAAC;YACD,MAAM,EAAE,GAAG,MAAM,CAAC,IAA+B,CAAC;YAClD,MAAM,EAAE,GAAG,MAAM,CAAC,EAAE,CAAC,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;YACzD,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAE,EAAE,CAAC,OAAuB,CAAC,CAAC,CAAC,EAAE,CAAC;YAC7E,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAE,EAAE,CAAC,KAAoB,CAAC,CAAC,CAAC,EAAE,CAAC;YACtE,KAAK,CAAC,IAAI,CAAC;gBACT,EAAE;gBACF,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC;gBAC3B,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,IAAI,IAAI,SAAS,CAAC;gBAClC,OAAO,EAAE,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC;gBACvC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;aACpC,CAAC,CAAC;YACH,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACzB,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,CAAC,EAAE,KAAK,QAAQ;oBAAE,SAAS;gBACnD,QAAQ,CAAC,IAAI,CAAC;oBACZ,MAAM,EAAE,EAAE;oBACV,MAAM,EAAE,IAAI,CAAC,EAAE;oBACf,QAAQ,EAAE,iBAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,CAAC;oBAC5D,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;iBAC/D,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC9C,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IAEjF,OAAO;QACL,IAAI,EAAE;YACJ,SAAS,EAAE,KAAK,CAAC,MAAM;YACvB,SAAS,EAAE,KAAK,CAAC,MAAM;YACvB,YAAY;YACZ,YAAY,EAAE,QAAQ,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM;SAC7C;QACD,KAAK;QACL,KAAK;KACN,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nanonets/graft",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "Build a repo's context graph as a folder of linked markdown files: a local, regenerable cache that every query keeps in sync with your code.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -67,17 +67,19 @@
|
|
|
67
67
|
"tree-sitter-php": "^0.23.4",
|
|
68
68
|
"tree-sitter-python": "^0.21.0",
|
|
69
69
|
"tree-sitter-r": "npm:@davisvaughan/tree-sitter-r@^1.3.0",
|
|
70
|
+
"tree-sitter-swift": "^0.7.1",
|
|
70
71
|
"tree-sitter-typescript": "^0.23.2",
|
|
71
|
-
"tree-sitter-wasm": "^1.1.
|
|
72
|
+
"tree-sitter-wasm": "^1.1.6",
|
|
72
73
|
"vscode-jsonrpc": "^8.2.1",
|
|
73
74
|
"vscode-languageserver-protocol": "^3.18.2",
|
|
74
|
-
"web-tree-sitter": "^0.
|
|
75
|
+
"web-tree-sitter": "^0.26.13"
|
|
75
76
|
},
|
|
76
77
|
"devDependencies": {
|
|
77
78
|
"@types/d3-force": "^3.0.10",
|
|
78
79
|
"@types/node": "^26.1.0",
|
|
79
80
|
"d3-force": "^3.0.0",
|
|
80
81
|
"esbuild": "^0.28.1",
|
|
82
|
+
"node-gyp": "^12.4.0",
|
|
81
83
|
"tsx": "^4.22.4",
|
|
82
84
|
"typescript": "^6.0.3"
|
|
83
85
|
},
|
|
@@ -92,6 +94,12 @@
|
|
|
92
94
|
"fsevents@2.3.3": true,
|
|
93
95
|
"tree-sitter-kotlin@0.3.8": true,
|
|
94
96
|
"tree-sitter-php@0.23.12": true,
|
|
95
|
-
"tree-sitter-r@1.3.0": true
|
|
97
|
+
"@davisvaughan/tree-sitter-r@1.3.0": true,
|
|
98
|
+
"tree-sitter-swift@0.7.1": true
|
|
99
|
+
},
|
|
100
|
+
"overrides": {
|
|
101
|
+
"tree-sitter-swift": {
|
|
102
|
+
"tree-sitter": "$tree-sitter"
|
|
103
|
+
}
|
|
96
104
|
}
|
|
97
105
|
}
|
|
@@ -48,8 +48,8 @@ for (const n of nodes) {
|
|
|
48
48
|
else if (Number(m[1]) > Number(m[2])) problems.push(`inverted span ${n.span}: ${n.id}`);
|
|
49
49
|
}
|
|
50
50
|
// an edge target may be a node id OR a deliberately-unresolved external string
|
|
51
|
-
// (import specifier / bare heritage name
|
|
52
|
-
// point at real nodes.
|
|
51
|
+
// (import specifier / bare heritage name / unresolved Java annotation type);
|
|
52
|
+
// only calls/contains must point at real nodes.
|
|
53
53
|
let dangling = 0, selfLoops = 0, unresolvedExternal = 0;
|
|
54
54
|
for (const e of edges) {
|
|
55
55
|
if (!RELATIONS.has(e.relation)) problems.push(`bad relation '${e.relation}'`);
|
|
@@ -57,7 +57,7 @@ for (const e of edges) {
|
|
|
57
57
|
if (!ids.has(e.source)) { problems.push(`dangling source: ${e.source}`); dangling++; }
|
|
58
58
|
const targetIsNode = ids.has(e.target);
|
|
59
59
|
if (!targetIsNode) {
|
|
60
|
-
if (e.relation === "imports" || e.relation === "extends" || e.relation === "implements") unresolvedExternal++;
|
|
60
|
+
if (e.relation === "imports" || e.relation === "extends" || e.relation === "implements" || e.relation === "references") unresolvedExternal++;
|
|
61
61
|
else { problems.push(`dangling ${e.relation} target: ${e.source} → ${e.target}`); dangling++; }
|
|
62
62
|
}
|
|
63
63
|
if (e.relation === "calls" && e.source === e.target) selfLoops++;
|
package/scripts/postinstall.mjs
CHANGED
|
@@ -1,9 +1,48 @@
|
|
|
1
|
-
// Prints a one-line nudge after install
|
|
1
|
+
// Prints a one-line nudge after install, and records the anonymous `install`
|
|
2
|
+
// event. Never fails the install.
|
|
3
|
+
import { existsSync } from 'node:fs';
|
|
4
|
+
import { spawn } from 'node:child_process';
|
|
5
|
+
import { dirname, join } from 'node:path';
|
|
6
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
7
|
+
|
|
8
|
+
const root = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Record the install, then hand the queue straight to a detached child.
|
|
12
|
+
*
|
|
13
|
+
* Sending here rather than letting the daily flush pick it up is the entire
|
|
14
|
+
* point of the event: the machine we most want to count is the one that installs
|
|
15
|
+
* graft and never runs a command, and that machine never reaches a flush. The
|
|
16
|
+
* child is detached with stdio ignored, so npm waits on no socket and an offline
|
|
17
|
+
* install looks like any other.
|
|
18
|
+
*
|
|
19
|
+
* Every gate still applies — a fork or a local build has no key, and CI,
|
|
20
|
+
* `DO_NOT_TRACK` and `graft telemetry disable` all close it. See TELEMETRY.md.
|
|
21
|
+
*/
|
|
22
|
+
async function recordInstall() {
|
|
23
|
+
// `dist/` is absent when this runs from a clone, where `prepare` builds AFTER
|
|
24
|
+
// postinstall. Nothing to record there, and a fork has no key regardless.
|
|
25
|
+
const entry = join(root, 'dist', 'telemetry', 'index.js');
|
|
26
|
+
const cli = join(root, 'dist', 'cli.js');
|
|
27
|
+
if (!existsSync(entry) || !existsSync(cli)) return;
|
|
28
|
+
const mod = await import(pathToFileURL(entry).href);
|
|
29
|
+
// A `dist/` from an older version has no such export. Absent, not broken.
|
|
30
|
+
if (typeof mod.trackInstallIfNew !== 'function') return;
|
|
31
|
+
// npm sets this for `npm i -g`; only its value 'true' means global.
|
|
32
|
+
mod.trackInstallIfNew({ global: process.env.npm_config_global === 'true' });
|
|
33
|
+
const child = spawn(process.execPath, [cli, '_telemetry-flush'], {
|
|
34
|
+
detached: true,
|
|
35
|
+
stdio: 'ignore',
|
|
36
|
+
});
|
|
37
|
+
child.unref();
|
|
38
|
+
}
|
|
39
|
+
|
|
2
40
|
try {
|
|
3
41
|
if (process.env.CI) process.exit(0);
|
|
4
|
-
const { existsSync } = await import('node:fs');
|
|
5
|
-
const { join } = await import('node:path');
|
|
6
42
|
const dir = process.env.INIT_CWD || process.cwd();
|
|
43
|
+
// Its own catch: the nudge is the part a user sees, and a telemetry fault must
|
|
44
|
+
// not be able to silence it.
|
|
45
|
+
try { await recordInstall(); } catch { /* telemetry is never worth an error */ }
|
|
7
46
|
if (existsSync(join(dir, '.claude', 'helpers', 'graft-statusline.cjs'))) process.exit(0);
|
|
8
47
|
console.log('\n Graft installed. Run `npx graft init` to enable the Claude Code integration (statusline + hooks + auto-sync).\n');
|
|
9
48
|
} catch {
|
package/scripts/run-tests.mjs
CHANGED
|
@@ -30,9 +30,23 @@ if (files.length === 0) {
|
|
|
30
30
|
process.exit(1);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
// Several tests `git init` a scratch repo and `git commit` into it to exercise the
|
|
34
|
+
// incremental/submodule/ingest git paths. Those commits inherit the developer's
|
|
35
|
+
// global git config — so a contributor who signs commits (gpg, or gitsign, whose
|
|
36
|
+
// x509 flow opens a browser for OIDC on EVERY commit) gets a signing storm from a
|
|
37
|
+
// run that has nothing to do with their identity. Inject config via GIT_CONFIG_*
|
|
38
|
+
// (git merges these over the user's config for this process tree only) so test
|
|
39
|
+
// commits never sign, without touching anyone's global settings.
|
|
40
|
+
const gitEnv = {
|
|
41
|
+
GIT_CONFIG_COUNT: "2",
|
|
42
|
+
GIT_CONFIG_KEY_0: "commit.gpgsign", GIT_CONFIG_VALUE_0: "false",
|
|
43
|
+
GIT_CONFIG_KEY_1: "tag.gpgsign", GIT_CONFIG_VALUE_1: "false",
|
|
44
|
+
};
|
|
45
|
+
|
|
33
46
|
const result = spawnSync(process.execPath, ["--import", "tsx", "--test", ...files], {
|
|
34
47
|
cwd: repoRoot,
|
|
35
48
|
stdio: "inherit",
|
|
49
|
+
env: { ...process.env, ...gitEnv },
|
|
36
50
|
});
|
|
37
51
|
|
|
38
52
|
if (result.error) {
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* "Saved vs said": how often does the agent actually TELL the user what graft saved?
|
|
3
|
+
*
|
|
4
|
+
* node scripts/tally-audit.mjs [transcript-dir] [--json]
|
|
5
|
+
*
|
|
6
|
+
* `savedTokens` (src/claude/state.ts) counts what graft *computed* — every
|
|
7
|
+
* `[graft] tokens saved ≈ N` footer the PostToolUse accumulator swept up. This
|
|
8
|
+
* script measures the other half, offline and in full detail: of the turns that
|
|
9
|
+
* used graft, how many closed with the one-line tally SKILL.md asks for, was the
|
|
10
|
+
* number right, and did it name the call count.
|
|
11
|
+
*
|
|
12
|
+
* The shipped metric (`graft_turns_bucket` / `reported_turns_bucket` on
|
|
13
|
+
* `session_summary`) is the same ratio at bucket resolution, which is all that
|
|
14
|
+
* can cross the wire. Run this locally when the aggregate says something
|
|
15
|
+
* surprising and you need to see which turns and why.
|
|
16
|
+
*
|
|
17
|
+
* Reads Claude Code's own transcript JSONL, which defaults to
|
|
18
|
+
* ~/.claude/projects/<slugified-cwd>/. Nothing leaves the machine.
|
|
19
|
+
*/
|
|
20
|
+
import { readFileSync, readdirSync, existsSync } from "node:fs";
|
|
21
|
+
import { join } from "node:path";
|
|
22
|
+
import { homedir } from "node:os";
|
|
23
|
+
|
|
24
|
+
const SAVED_FOOTER = /\[graft\] tokens saved ≈ ([\d,]+)/g;
|
|
25
|
+
const TALLY = /graft\s+saved\s*[~≈]?\s*([\d,.]+)\s*(k|m)?\s*(?:tok|tokens)/i;
|
|
26
|
+
const CALLS = /(\d+)\s*calls?/i;
|
|
27
|
+
/** How far past the tally to look for its call count. The tally is one line
|
|
28
|
+
* ("🌱 graft saved ~12,400 tokens this turn (3 calls)"); scanning the rest of
|
|
29
|
+
* the reply instead would match any unrelated "3 calls" further down and report
|
|
30
|
+
* near-perfect compliance for a field the agent mostly omits. */
|
|
31
|
+
const TALLY_WINDOW = 60;
|
|
32
|
+
/** Above this, a per-turn "saved" figure is an estimator artifact rather than a
|
|
33
|
+
* saving — a `--depth all` closure or a vendored tree summing whole-file
|
|
34
|
+
* baselines nobody would have read. Reported separately, never averaged in. */
|
|
35
|
+
const IMPLAUSIBLE_TOKENS = 1_000_000;
|
|
36
|
+
|
|
37
|
+
const args = process.argv.slice(2).filter((a) => a !== "--json");
|
|
38
|
+
const asJson = process.argv.includes("--json");
|
|
39
|
+
const dir = args[0] ?? defaultTranscriptDir();
|
|
40
|
+
|
|
41
|
+
function defaultTranscriptDir() {
|
|
42
|
+
const slug = process.cwd().replace(/[/.]/g, "-");
|
|
43
|
+
return join(homedir(), ".claude", "projects", slug);
|
|
44
|
+
}
|
|
45
|
+
function textOf(content) {
|
|
46
|
+
if (typeof content === "string") return content;
|
|
47
|
+
if (!Array.isArray(content)) return "";
|
|
48
|
+
return content.map((p) => (p?.type === "text" ? p.text ?? "" : "")).join("\n");
|
|
49
|
+
}
|
|
50
|
+
function isUserPrompt(o) {
|
|
51
|
+
if (o.type !== "user" || o.isSidechain || o.isMeta) return false;
|
|
52
|
+
const c = o.message?.content;
|
|
53
|
+
if (typeof c === "string") return true;
|
|
54
|
+
return Array.isArray(c) && !c.some((p) => p?.type === "tool_result");
|
|
55
|
+
}
|
|
56
|
+
function median(ns) {
|
|
57
|
+
if (!ns.length) return 0;
|
|
58
|
+
const s = [...ns].sort((a, b) => a - b);
|
|
59
|
+
const mid = s.length >> 1;
|
|
60
|
+
return s.length % 2 ? s[mid] : Math.round((s[mid - 1] + s[mid]) / 2);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (!existsSync(dir)) {
|
|
64
|
+
console.error(`no transcripts at ${dir}`);
|
|
65
|
+
process.exit(1);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const turns = [];
|
|
69
|
+
for (const file of readdirSync(dir).filter((f) => f.endsWith(".jsonl"))) {
|
|
70
|
+
let turn = null;
|
|
71
|
+
const flush = () => { if (turn?.calls > 0) turns.push(turn); };
|
|
72
|
+
for (const line of readFileSync(join(dir, file), "utf8").split("\n")) {
|
|
73
|
+
if (!line.trim()) continue;
|
|
74
|
+
let o;
|
|
75
|
+
try { o = JSON.parse(line); } catch { continue; }
|
|
76
|
+
if (o.isSidechain) continue; // a subagent's prose is not what the user read
|
|
77
|
+
if (isUserPrompt(o)) { flush(); turn = { file, calls: 0, saved: 0, said: null, statedCalls: null }; continue; }
|
|
78
|
+
if (!turn) continue;
|
|
79
|
+
if (o.type === "user") { // a tool_result wearing the user role
|
|
80
|
+
for (const m of JSON.stringify(o.message?.content ?? "").matchAll(SAVED_FOOTER)) {
|
|
81
|
+
turn.calls++;
|
|
82
|
+
turn.saved += Number(m[1].replace(/,/g, "")) || 0;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (o.type === "assistant") {
|
|
86
|
+
const m = TALLY.exec(textOf(o.message?.content));
|
|
87
|
+
if (m) {
|
|
88
|
+
let n = Number(m[1].replace(/,/g, ""));
|
|
89
|
+
if (m[2]?.toLowerCase() === "k") n *= 1e3;
|
|
90
|
+
if (m[2]?.toLowerCase() === "m") n *= 1e6;
|
|
91
|
+
turn.said = n;
|
|
92
|
+
const c = CALLS.exec(textOf(o.message?.content).slice(m.index, m.index + TALLY_WINDOW));
|
|
93
|
+
turn.statedCalls = c ? Number(c[1]) : null;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
flush();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const said = turns.filter((t) => t.said !== null);
|
|
101
|
+
const plausible = turns.filter((t) => t.saved < IMPLAUSIBLE_TOKENS);
|
|
102
|
+
const outliers = turns.filter((t) => t.saved >= IMPLAUSIBLE_TOKENS);
|
|
103
|
+
const fidelity = { exact: 0, over: 0, under: 0 };
|
|
104
|
+
for (const t of said.filter((t) => t.saved > 0)) {
|
|
105
|
+
const r = t.said / t.saved;
|
|
106
|
+
if (r >= 0.9 && r <= 1.1) fidelity.exact++;
|
|
107
|
+
else if (r > 1.1) fidelity.over++;
|
|
108
|
+
else fidelity.under++;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const report = {
|
|
112
|
+
transcripts: readdirSync(dir).filter((f) => f.endsWith(".jsonl")).length,
|
|
113
|
+
graft_turns: turns.length,
|
|
114
|
+
reported: said.length,
|
|
115
|
+
silent: turns.length - said.length,
|
|
116
|
+
reported_pct: turns.length ? Number(((said.length / turns.length) * 100).toFixed(1)) : 0,
|
|
117
|
+
stated_call_count: said.filter((t) => t.statedCalls !== null).length,
|
|
118
|
+
median_saved_per_turn: median(plausible.map((t) => t.saved)),
|
|
119
|
+
fidelity,
|
|
120
|
+
implausible_turns: outliers.length,
|
|
121
|
+
implausible_max: outliers.length ? Math.max(...outliers.map((t) => t.saved)) : 0,
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
if (asJson) {
|
|
125
|
+
console.log(JSON.stringify(report, null, 2));
|
|
126
|
+
} else {
|
|
127
|
+
const { graft_turns: n } = report;
|
|
128
|
+
console.log(`transcripts scanned: ${report.transcripts} (${dir})`);
|
|
129
|
+
console.log(`turns that used graft: ${n}`);
|
|
130
|
+
console.log(` ...reported a tally: ${report.reported} (${report.reported_pct}%)`);
|
|
131
|
+
console.log(` ...silent: ${report.silent}`);
|
|
132
|
+
console.log(` ...named the call count ${report.stated_call_count}/${report.reported}`);
|
|
133
|
+
console.log(`median saved per turn: ${report.median_saved_per_turn.toLocaleString()} tok`);
|
|
134
|
+
console.log(`reported number vs footer sum (±10%): exact ${fidelity.exact} · over ${fidelity.over} · under ${fidelity.under}`);
|
|
135
|
+
if (outliers.length) {
|
|
136
|
+
console.log(`\n⚠ ${outliers.length} turn(s) claim ≥${IMPLAUSIBLE_TOKENS.toLocaleString()} tokens saved ` +
|
|
137
|
+
`(max ${report.implausible_max.toLocaleString()}) — an estimator artifact, excluded from the median. ` +
|
|
138
|
+
`See savingsFor() in src/context/savings.ts.`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import type { ChatModel, ChatRequest, ChatResponse } from "./types.js";
|
|
2
|
-
export interface ClaudeCliResult {
|
|
3
|
-
code: number | null;
|
|
4
|
-
stdout: string;
|
|
5
|
-
stderr: string;
|
|
6
|
-
}
|
|
7
|
-
/** Injectable process runner — tests pass a stub so nothing is ever spawned. */
|
|
8
|
-
export type ClaudeCliRunner = (args: string[], stdin: string, timeoutMs: number) => Promise<ClaudeCliResult>;
|
|
9
|
-
export interface ClaudeCliChatModelOptions {
|
|
10
|
-
/** Model alias or full id (`sonnet`, `opus`, `claude-sonnet-5`, …). */
|
|
11
|
-
model: string;
|
|
12
|
-
/** Path to the CLI. Default: resolved from PATH (env GRAFT_CLAUDE_BIN wins). */
|
|
13
|
-
bin?: string;
|
|
14
|
-
label?: string;
|
|
15
|
-
/** Per-call wall clock. Default 300s — a crux pass over a big file is slow. */
|
|
16
|
-
timeoutMs?: number;
|
|
17
|
-
/** Optional spend ceiling passed through as `--max-budget-usd`. */
|
|
18
|
-
maxBudgetUsd?: number;
|
|
19
|
-
/** Inject a runner (tests stub it; production omits it). */
|
|
20
|
-
run?: ClaudeCliRunner;
|
|
21
|
-
}
|
|
22
|
-
export declare class ClaudeCliChatModel implements ChatModel {
|
|
23
|
-
readonly label: string;
|
|
24
|
-
private model;
|
|
25
|
-
private runner;
|
|
26
|
-
private timeoutMs;
|
|
27
|
-
private maxBudgetUsd?;
|
|
28
|
-
constructor(opts: ClaudeCliChatModelOptions);
|
|
29
|
-
create(req: ChatRequest): Promise<ChatResponse>;
|
|
30
|
-
/**
|
|
31
|
-
* Transport-level retry. A `--deep` build is thousands of sequential calls over
|
|
32
|
-
* hours, so a single blip — an overloaded upstream, a dropped connection, one
|
|
33
|
-
* slow file hitting the wall clock — would otherwise silently cost that file its
|
|
34
|
-
* summary. Only failures classified transient are retried; a bad login or an
|
|
35
|
-
* exhausted quota fails immediately, because sleeping on those just turns a
|
|
36
|
-
* clear error into a slow one.
|
|
37
|
-
*/
|
|
38
|
-
private invoke;
|
|
39
|
-
private invokeOnce;
|
|
40
|
-
}
|
|
41
|
-
export declare function isTransient(message: string): boolean;
|
|
42
|
-
/**
|
|
43
|
-
* Pull one JSON value out of a model reply. Handles the two ways a prompt-enforced
|
|
44
|
-
* schema leaks: a markdown fence around the object, and prose either side of it.
|
|
45
|
-
* Brace scanning is string- and escape-aware so a `}` inside a summary can't end
|
|
46
|
-
* the object early. Returns undefined when nothing parses.
|
|
47
|
-
*/
|
|
48
|
-
export declare function extractJson(text: string): unknown;
|
|
49
|
-
/**
|
|
50
|
-
* Resolve the CLI without a shell. Node's spawn only appends `.exe` on Windows,
|
|
51
|
-
* so PATHEXT is walked by hand — the native installer ships `claude.exe` but an
|
|
52
|
-
* `npm i -g` install leaves only the `claude.cmd` shim, and missing it would make
|
|
53
|
-
* this provider look uninstalled on a machine where it works fine.
|
|
54
|
-
*/
|
|
55
|
-
export declare function resolveClaudeBin(explicit?: string): string | undefined;
|
|
56
|
-
/** True when the `claude` CLI is installed. Cached — this runs per build, not per file. */
|
|
57
|
-
export declare function claudeCliAvailable(explicit?: string): boolean;
|
|
58
|
-
/** Test seam: drop the memoized lookup so a test can flip PATH. */
|
|
59
|
-
export declare function resetClaudeCliCache(): void;
|
|
60
|
-
//# sourceMappingURL=claude-cli.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"claude-cli.d.ts","sourceRoot":"","sources":["../../../src/ai/llm/claude-cli.ts"],"names":[],"mappings":"AAuCA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAA4B,MAAM,YAAY,CAAC;AAgBjG,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,gFAAgF;AAChF,MAAM,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC;AAE7G,MAAM,WAAW,yBAAyB;IACxC,uEAAuE;IACvE,KAAK,EAAE,MAAM,CAAC;IACd,gFAAgF;IAChF,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+EAA+E;IAC/E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mEAAmE;IACnE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,4DAA4D;IAC5D,GAAG,CAAC,EAAE,eAAe,CAAC;CACvB;AAiBD,qBAAa,kBAAmB,YAAW,SAAS;IAClD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,YAAY,CAAC,CAAS;gBAElB,IAAI,EAAE,yBAAyB;IAQrC,MAAM,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IAgDrD;;;;;;;OAOG;YACW,MAAM;YAeN,UAAU;CAmCzB;AAeD,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAGpD;AAkFD;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CA0CjD;AAcD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAgBtE;AAID,2FAA2F;AAC3F,wBAAgB,kBAAkB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAI7D;AAED,mEAAmE;AACnE,wBAAgB,mBAAmB,IAAI,IAAI,CAE1C"}
|