@davmash/bygone 0.8.0 → 0.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,26 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.8.3
6
+
7
+ - Fixed tour anchor gutter markers so active and persistent anchors are visibly rendered by Monaco, including after switching files in stacked tours
8
+ - Documented agent skill installation with `npx skills add davidmashburn/bygone -s pr-tour-guide`
9
+ - Expanded the PR Tour Guide skill with Bygone install instructions for Homebrew, npm, GitHub Releases, and source checkouts
10
+ - Included `skills/` in the `@davmash/bygone` npm package so the skill ships with CLI installs
11
+
12
+ ## 0.8.2
13
+
14
+ - Added persistent tour anchor gutter markers across two-way and stacked-diff scenes, including every applicable step on the open file
15
+ - Added click-to-jump navigation from tour anchor markers back to the matching tour step
16
+
17
+ ## 0.8.1
18
+
19
+ - Added familiar multi-cursor, selection, line, comment, indentation, folding, drag-and-drop, and context-menu editing across Bygone's two-way and multi-panel editors
20
+ - Added source-aware Monaco models and bounded syntax support while preserving comparison state, model disposal, tour rendering, and connector geometry
21
+ - Returned `Cmd/Ctrl+Alt+Up/Down` to Monaco's cursor controls and added change navigation through `F7`, `Shift+F7`, and simultaneous `Cmd/Ctrl+Shift+Up/Down`
22
+ - Added standalone Selection and Lines menus backed by allowlisted native Monaco actions
23
+ - Added action-oriented hover tooltips with current keybindings across comparison, history, file, search, tour, and sidebar navigation controls
24
+
5
25
  ## 0.8.0
6
26
 
7
27
  - Added full-surface search across visible panes, comparison panels, unopened change-set files, file history, authored tours, and repositories, plus previewable safe repository replacement
package/README.md CHANGED
@@ -117,7 +117,15 @@ Change tours can layer an authored, code-connected narrative over the complete g
117
117
 
118
118
  Packaged macOS builds register `.bygone` with the desktop app, so Finder can open a presentation directly. Windows and Linux builds currently require opening the file through Bygone or the `bygone` command; they do not install an operating-system file association.
119
119
 
120
- Agents can validate anchors and structure with `bygone tour validate <file.bygone> --json`, compile a portable manifest with `bygone tour compile`, and retrieve the authoring contract with `bygone tour schema`. See [Generating change tours with an LLM](./docs/generating-change-tours.md), or give a compatible agent the repository's vendor-neutral [`pr-tour-guide` skill](./skills/pr-tour-guide/SKILL.md).
120
+ Agents can validate anchors and structure with `bygone tour validate <file.bygone> --json`, compile a portable manifest with `bygone tour compile`, and retrieve the authoring contract with `bygone tour schema`. See [Generating change tours with an LLM](./docs/generating-change-tours.md).
121
+
122
+ Install the agent skill (Cursor, Codex, Claude Code, and other supported agents):
123
+
124
+ ```bash
125
+ npx skills add davidmashburn/bygone -s pr-tour-guide -g -y
126
+ ```
127
+
128
+ The skill includes Bygone install instructions for macOS Homebrew, npm, and source checkouts. It also ships inside the `@davmash/bygone` npm package under `skills/pr-tour-guide/`. Source: [`pr-tour-guide` skill](./skills/pr-tour-guide/SKILL.md).
121
129
 
122
130
  Contributors should consult the internal [product surface overview](./docs/product-surface.md) before adding a command, mode, tour scene, or packaged artifact.
123
131
 
package/bin/bygone.js CHANGED
@@ -8,9 +8,16 @@ const { generateCompletion, SUPPORTED_SHELLS } = require('../cli/completions.js'
8
8
  const { renderCliHelp, tokenMatches } = require('../cli/commandSpec.js');
9
9
  const { startPresentation } = require('../cli/present.js');
10
10
  const { runTourCommand } = require('../cli/tour.js');
11
-
12
- const args = process.argv.slice(2);
13
- const cliCwd = process.cwd();
11
+ const { resolveWorkingDirectory } = require('../cli/workingDirectory.js');
12
+
13
+ let args;
14
+ let cliCwd;
15
+ try {
16
+ ({ args, cwd: cliCwd } = resolveWorkingDirectory(process.argv.slice(2), process.cwd()));
17
+ } catch (error) {
18
+ process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
19
+ process.exit(2);
20
+ }
14
21
  const packageRoot = path.join(__dirname, '..');
15
22
 
16
23
  if (args.some((arg) => tokenMatches('help', arg))) {
@@ -11,6 +11,7 @@ const CLI_SPEC = Object.freeze({
11
11
  'bygone --history <path>',
12
12
  'bygone --git-diff <ref1> <ref2> [<ref3>...]',
13
13
  'bygone review [<head>] [--base <base>]',
14
+ 'bygone -C <directory> <command-or-path> [...]',
14
15
  'bygone present [<head>] [--base <base>] [--tour <file.bygone>]',
15
16
  'bygone tour validate <file.bygone> [--json]',
16
17
  'bygone tour compile <file.bygone> [--output <tour.json>]',
@@ -106,6 +107,13 @@ const CLI_SPEC = Object.freeze({
106
107
  description: 'Use an authored .bygone presentation',
107
108
  argument: 'path'
108
109
  },
110
+ {
111
+ id: 'directory',
112
+ kind: 'global',
113
+ tokens: ['-C'],
114
+ description: 'Run as if Bygone started in this directory',
115
+ argument: 'path'
116
+ },
109
117
  {
110
118
  id: 'branch',
111
119
  kind: 'option',
@@ -138,6 +146,7 @@ const CLI_SPEC = Object.freeze({
138
146
  '`--git-diff` accepts branches, tags, SHAs, HEAD~1, stash@{0}, INDEX, and WORKTREE.',
139
147
  '`review` compares merge-base(BASE,HEAD) with HEAD and detects the default base when omitted.',
140
148
  '`present` turns the same range into an app-hosted, ordered change tour.',
149
+ '`-C <directory>` resolves relative paths and Git refs from that directory without changing the shell working directory.',
141
150
  '`tour validate` resolves every authored anchor; add `--json` for agent-readable output.',
142
151
  '`tour compile` writes a portable manifest to stdout or `--output`; `tour schema` prints its source schema.',
143
152
  '`tour context` emits compact, structured Git evidence for an LLM without invoking a model.',
@@ -0,0 +1,19 @@
1
+ const path = require('path');
2
+
3
+ function resolveWorkingDirectory(args, initialCwd) {
4
+ const remainingArgs = [...args];
5
+ let cwd = path.resolve(initialCwd);
6
+
7
+ while (remainingArgs[0] === '-C') {
8
+ const directory = remainingArgs[1];
9
+ if (!directory) {
10
+ throw new Error('-C requires a directory.');
11
+ }
12
+ cwd = path.resolve(cwd, directory);
13
+ remainingArgs.splice(0, 2);
14
+ }
15
+
16
+ return { args: remainingArgs, cwd };
17
+ }
18
+
19
+ module.exports = { resolveWorkingDirectory };
@@ -22,6 +22,7 @@ _bygone() {
22
22
  '--git-diff:Compare two or more Git sources'
23
23
  '--branch-diff:Legacy alias for branch review'
24
24
  '--test:Open the built-in test comparison'
25
+ '-C:Run as if Bygone started in this directory'
25
26
  '-h:Show command help'
26
27
  '--help:Show command help'
27
28
  '-v:Show the installed version'
@@ -12,7 +12,7 @@ _bygone() {
12
12
  first="${COMP_WORDS[1]}"
13
13
 
14
14
  if (( COMP_CWORD == 1 )); then
15
- COMPREPLY=( $(compgen -W 'review completion present tour --diff --history --git-diff --branch-diff --test -h --help -v --version' -- "$cur") $(compgen -f -- "$cur") )
15
+ COMPREPLY=( $(compgen -W 'review completion present tour --diff --history --git-diff --branch-diff --test -C -h --help -v --version' -- "$cur") $(compgen -f -- "$cur") )
16
16
  compopt -o filenames 2>/dev/null || true
17
17
  return
18
18
  fi
@@ -13,6 +13,7 @@ complete -c bygone -n '__fish_use_subcommand' -l history -r -d 'Open Git history
13
13
  complete -c bygone -n '__fish_use_subcommand' -l git-diff -d 'Compare two or more Git sources'
14
14
  complete -c bygone -n '__fish_use_subcommand' -l branch-diff -d 'Legacy alias for branch review'
15
15
  complete -c bygone -n '__fish_use_subcommand' -l test -d 'Open the built-in test comparison'
16
+ complete -c bygone -n '__fish_use_subcommand' -s C -r -d 'Run as if Bygone started in this directory'
16
17
  complete -c bygone -n '__fish_use_subcommand' -s h -l help -d 'Show command help'
17
18
  complete -c bygone -n '__fish_use_subcommand' -s v -l version -d 'Show the installed version'
18
19
  complete -c bygone -n '__fish_seen_subcommand_from completion' -a 'zsh bash fish' -d 'Shell'
@@ -4,6 +4,14 @@ Bygone treats an LLM as a narrative planner and evidence selector, not as the au
4
4
 
5
5
  For agents that support repository skills, use the agent-agnostic [`pr-tour-guide` skill](../skills/pr-tour-guide/SKILL.md). It packages the complete evidence, authoring, validation, and handoff workflow without depending on a particular agent vendor.
6
6
 
7
+ Install it with the skills CLI:
8
+
9
+ ```sh
10
+ npx skills add davidmashburn/bygone -s pr-tour-guide -g -y
11
+ ```
12
+
13
+ The skill documents how to install Bygone itself when the CLI is missing.
14
+
7
15
  ## Recommended loop
8
16
 
9
17
  1. Generate a deterministic change dossier instead of asking the model to rediscover the Git range:
@@ -0,0 +1,5 @@
1
+ "use strict";(()=>{function S(){}S.prototype={diff:function(e,t){var r,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i=o.callback;typeof o=="function"&&(i=o,o={}),this.options=o;var l=this;function a(L){return i?(setTimeout(function(){i(void 0,L)},0),!0):L}e=this.castInput(e),t=this.castInput(t),e=this.removeEmpty(this.tokenize(e)),t=this.removeEmpty(this.tokenize(t));var s=t.length,f=e.length,c=1,u=s+f;o.maxEditLength&&(u=Math.min(u,o.maxEditLength));var v=(r=o.timeout)!==null&&r!==void 0?r:1/0,b=Date.now()+v,m=[{oldPos:-1,lastComponent:void 0}],p=this.extractCommon(m[0],t,e,0);if(m[0].oldPos+1>=f&&p+1>=s)return a([{value:this.join(t),count:t.length}]);var g=-1/0,d=1/0;function h(){for(var L=Math.max(g,-c);L<=Math.min(d,c);L+=2){var x=void 0,y=m[L-1],I=m[L+1];y&&(m[L-1]=void 0);var N=!1;if(I){var V=I.oldPos-L;N=I&&0<=V&&V<s}var K=y&&y.oldPos+1<f;if(!N&&!K){m[L]=void 0;continue}if(!K||N&&y.oldPos+1<I.oldPos?x=l.addToPath(I,!0,void 0,0):x=l.addToPath(y,void 0,!0,1),p=l.extractCommon(x,t,e,L),x.oldPos+1>=f&&p+1>=s)return a(Le(l,x.lastComponent,t,e,l.useLongestToken));m[L]=x,x.oldPos+1>=f&&(d=Math.min(d,L-1)),p+1>=s&&(g=Math.max(g,L+1))}c++}if(i)(function L(){setTimeout(function(){if(c>u||Date.now()>b)return i();h()||L()},0)})();else for(;c<=u&&Date.now()<=b;){var w=h();if(w)return w}},addToPath:function(e,t,r,o){var i=e.lastComponent;return i&&i.added===t&&i.removed===r?{oldPos:e.oldPos+o,lastComponent:{count:i.count+1,added:t,removed:r,previousComponent:i.previousComponent}}:{oldPos:e.oldPos+o,lastComponent:{count:1,added:t,removed:r,previousComponent:i}}},extractCommon:function(e,t,r,o){for(var i=t.length,l=r.length,a=e.oldPos,s=a-o,f=0;s+1<i&&a+1<l&&this.equals(t[s+1],r[a+1]);)s++,a++,f++;return f&&(e.lastComponent={count:f,previousComponent:e.lastComponent}),e.oldPos=a,s},equals:function(e,t){return this.options.comparator?this.options.comparator(e,t):e===t||this.options.ignoreCase&&e.toLowerCase()===t.toLowerCase()},removeEmpty:function(e){for(var t=[],r=0;r<e.length;r++)e[r]&&t.push(e[r]);return t},castInput:function(e){return e},tokenize:function(e){return e.split("")},join:function(e){return e.join("")}};function Le(n,e,t,r,o){for(var i=[],l;e;)i.push(e),l=e.previousComponent,delete e.previousComponent,e=l;i.reverse();for(var a=0,s=i.length,f=0,c=0;a<s;a++){var u=i[a];if(u.removed){if(u.value=n.join(r.slice(c,c+u.count)),c+=u.count,a&&i[a-1].added){var b=i[a-1];i[a-1]=i[a],i[a]=b}}else{if(!u.added&&o){var v=t.slice(f,f+u.count);v=v.map(function(p,g){var d=r[c+g];return d.length>p.length?d:p}),u.value=n.join(v)}else u.value=n.join(t.slice(f,f+u.count));f+=u.count,u.added||(c+=u.count)}}var m=i[s-1];return s>1&&typeof m.value=="string"&&(m.added||m.removed)&&n.equals("",m.value)&&(i[s-2].value+=m.value,i.pop()),i}var xe=new S;function Z(n,e,t){return xe.diff(n,e,t)}var J=/^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/,j=/\S/,U=new S;U.equals=function(n,e){return this.options.ignoreCase&&(n=n.toLowerCase(),e=e.toLowerCase()),n===e||this.options.ignoreWhitespace&&!j.test(n)&&!j.test(e)};U.tokenize=function(n){for(var e=n.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/),t=0;t<e.length-1;t++)!e[t+1]&&e[t+2]&&J.test(e[t])&&J.test(e[t+2])&&(e[t]+=e[t+2],e.splice(t+1,2),t--);return e};function Q(n,e,t){return U.diff(n,e,t)}var ee=new S;ee.tokenize=function(n){this.options.stripTrailingCr&&(n=n.replace(/\r\n/g,`
2
+ `));var e=[],t=n.split(/(\n|\r\n)/);t[t.length-1]||t.pop();for(var r=0;r<t.length;r++){var o=t[r];r%2&&!this.options.newlineIsToken?e[e.length-1]+=o:(this.options.ignoreWhitespace&&(o=o.trim()),e.push(o))}return e};var ye=new S;ye.tokenize=function(n){return n.split(/(\S.+?[.!?])(?=\s+|$)/)};var Ie=new S;Ie.tokenize=function(n){return n.split(/([{}:;,]|\s+)/)};function _(n){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?_=function(e){return typeof e}:_=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_(n)}var Ne=Object.prototype.toString,D=new S;D.useLongestToken=!0;D.tokenize=ee.tokenize;D.castInput=function(n){var e=this.options,t=e.undefinedReplacement,r=e.stringifyReplacer,o=r===void 0?function(i,l){return typeof l>"u"?t:l}:r;return typeof n=="string"?n:JSON.stringify($(n,null,null,o),o," ")};D.equals=function(n,e){return S.prototype.equals.call(D,n.replace(/,([\r\n])/g,"$1"),e.replace(/,([\r\n])/g,"$1"))};function $(n,e,t,r,o){e=e||[],t=t||[],r&&(n=r(o,n));var i;for(i=0;i<e.length;i+=1)if(e[i]===n)return t[i];var l;if(Ne.call(n)==="[object Array]"){for(e.push(n),l=new Array(n.length),t.push(l),i=0;i<n.length;i+=1)l[i]=$(n[i],e,t,r,o);return e.pop(),t.pop(),l}if(n&&n.toJSON&&(n=n.toJSON()),_(n)==="object"&&n!==null){e.push(n),l={},t.push(l);var a=[],s;for(s in n)n.hasOwnProperty(s)&&a.push(s);for(a.sort(),i=0;i<a.length;i+=1)s=a[i],l[s]=$(n[s],e,t,r,s);e.pop(),t.pop()}else l=n;return l}var F=new S;F.tokenize=function(n){return n.slice()};F.join=F.removeEmpty=function(n){return n};function ne(n,e,t){return F.diff(n,e,t)}var Ee=500,Ae=100,te=we("BYGONE_MAX_INLINE_HIGHLIGHT_LINE_LENGTH",Ee),Me=we("BYGONE_DIFF_TIMEOUT_MS",Ae);function ge(n,e,t={}){let r=re(n),o=re(e),i=ne(r,o,{timeout:t.timeoutMs??Me});if(!i)return Re(r,o);let l=[],a=[],s=[],f=[],c=1,u=1;for(let b=0;b<i.length;b++){let m=i[b],p=m.removed?m.value:[],g=m.added?m.value:[];if(!m.added&&!m.removed){for(let d of m.value)a.push(A("context",d,c)),s.push(A("context",d,u)),l.push(T(E("context",d,c++),E("context",d,u++)));continue}if(m.removed&&b+1<i.length&&i[b+1].added){let d=i[b+1],h=a.length,w=s.length,L=ve(p,d.value);for(let{left:x,right:y}of L){let I,N;x!==void 0&&(I=A("removed",x,c),a.push(I)),y!==void 0&&(N=A("added",y,u),s.push(N)),I&&N&&Ve(I,N),l.push(T(x===void 0?R():E("removed",x,c++),y===void 0?R():E("added",y,u++)))}f.push(k("replace",h,a.length,w,s.length)),b++;continue}if(m.removed){let d=a.length,h=s.length;for(let w of p)a.push(A("removed",w,c)),l.push(T(E("removed",w,c++),R()));f.push(k("delete",d,a.length,h,s.length));continue}if(m.added){let d=a.length,h=s.length;for(let w of g)s.push(A("added",w,u)),l.push(T(R(),E("added",w,u++)));f.push(k("insert",d,a.length,h,s.length))}}let v=l.some(b=>b.left.kind!=="context"||b.right.kind!=="context");return{rows:l,leftLines:a,rightLines:s,blocks:f,hasChanges:v}}function Re(n,e){let t=n.map((l,a)=>A("removed",l,a+1)),r=e.map((l,a)=>A("added",l,a+1)),o=[...n.map((l,a)=>T(E("removed",l,a+1),R())),...e.map((l,a)=>T(R(),E("added",l,a+1)))],i="replace";return n.length===0?i="insert":e.length===0&&(i="delete"),{rows:o,leftLines:t,rightLines:r,blocks:o.length===0?[]:[k(i,0,n.length,0,e.length)],hasChanges:o.length>0}}function re(n){if(n.length===0)return[];let e=n.replace(/\r\n/g,`
3
+ `).split(`
4
+ `);return e[e.length-1]===""&&e.pop(),e}var pe=1e4,ie=2e3,Te=.52,De=.35,he=.38,Ce=.33,me=.86,G=.08,O=.05,H=-.12,oe=5e3,_e=2e3,se=4,Fe=8,z=4;function ve(n,e){if(n.length===0)return e.map(s=>({right:s}));if(e.length===0)return n.map(s=>({left:s}));if(n.length===1&&e.length===1){let s=Y(n[0],e[0]);return(s.eligible||s.score>=De)&&B(n[0],e[0])&&C(M(n[0]))&&C(M(e[0]))?[{left:n[0],right:e[0]}]:[{left:n[0]},{right:e[0]}]}if(n.length*e.length>pe)return Ge(n,e);let t=Oe(n,e),r=Array.from({length:n.length+1},()=>new Array(e.length+1).fill(Number.NEGATIVE_INFINITY)),o=Array.from({length:n.length+1},()=>new Array(e.length+1).fill(null));r[0][0]=0;for(let s=1;s<=n.length;s++)r[s][0]=r[s-1][0]+H,o[s][0]="left";for(let s=1;s<=e.length;s++)r[0][s]=r[0][s-1]+H,o[0][s]="right";for(let s=1;s<=n.length;s++)for(let f=1;f<=e.length;f++){let c=t[s-1][f-1],v=[{move:"left",score:r[s-1][f]+H},{move:"right",score:r[s][f-1]+H},{move:"match",score:c===null?Number.NEGATIVE_INFINITY:r[s-1][f-1]+c}].reduce((b,m)=>m.score>b.score?m:b);r[s][f]=v.score,o[s][f]=v.move}let i=[],l=n.length,a=e.length;for(;l>0||a>0;){let s=o[l][a];s==="match"?i.push({left:n[--l],right:e[--a]}):s==="left"?i.push({left:n[--l]}):i.push({right:e[--a]})}return i.reverse()}function Y(n,e){let t=M(n),r=M(e),o=C(t),i=C(r);if(!o||!i||t.length>ie||r.length>ie)return{score:0,eligible:!1,characterSimilarity:0,tokenSimilarity:0,lengthSimilarity:0};if(t===r)return{score:1,eligible:!0,characterSimilarity:1,tokenSimilarity:1,lengthSimilarity:1};let l=q(t),a=q(r),s=Ye(t,r),f=Xe(l,a),c=Math.min(t.length,r.length)/Math.max(t.length,r.length),u=qe(l,a),v=s*.52+f*.32+c*.1+u*.06,b=s>=.52||f>=.45||s>=.48&&f>=.28;return{score:v,eligible:b&&v>=Te,characterSimilarity:s,tokenSimilarity:f,lengthSimilarity:c}}function Oe(n,e){let t=n.map(p=>e.map(g=>Y(p,g))),r=be(n,e),o=t.map(p=>P(p)),i=e.map((p,g)=>P(t.map(d=>d[g]))),l=t.map((p,g)=>p.map((d,h)=>{if(r.has(`${g}:${h}`))return Math.max(d.score,1);if(!d.eligible)return null;let w=o[g],L=i[h],x=d.score===w.best&&d.score===L.best,y=d.score>=me?G/2:G,I=w.best-w.second>=y,N=L.best-L.second>=y;return x&&I&&N?d.score:null}));if(Math.max(n.length,e.length)>Fe||Math.abs(n.length-e.length)>z)return l;let a=(p,g,d)=>p.score>=he&&B(n[g],e[d])&&Math.abs(g-d)<=z,s=t.map((p,g)=>W(p,(d,h)=>a(d,g,h))),f=e.map((p,g)=>W(t.map(d=>d[g]),(d,h)=>a(d,h,g))),c=(p,g,d)=>p.score>=Ce&&B(n[g],e[d])&&Math.abs(g-d)<=z,u=t.map((p,g)=>W(p,(d,h)=>c(d,g,h))),v=e.map((p,g)=>W(t.map(d=>d[g]),(d,h)=>c(d,h,g))),b=(p,g)=>{let d=t[p][g];if(!a(d,p,g))return!1;let h=s[p],w=f[g];return d.score===h.best&&d.score===w.best&&h.best-h.second>=O&&w.best-w.second>=O},m=(p,g)=>{let d=t[p][g];if(!c(d,p,g))return!1;let h=u[p],w=v[g];return d.score===h.best&&d.score===w.best&&h.best-h.second>=O&&w.best-w.second>=O};return l.map((p,g)=>p.map((d,h)=>{if(d!==null)return d;let w=b(g,h)&&(He(l,g,h)||We(t,g,h,b)),L=ke(t,g,h,(x,y)=>c(t[x][y],x,y),m);return!w&&!L?null:t[g][h].score}))}function He(n,e,t){return e>0&&t>0&&n[e-1][t-1]!==null||e+1<n.length&&t+1<n[e+1].length&&n[e+1][t+1]!==null}function We(n,e,t,r){return e>0&&t>0&&r(e-1,t-1)||e+1<n.length&&t+1<n[e+1].length&&r(e+1,t+1)}function ke(n,e,t,r,o){let i=e,l=t;for(;i>0&&l>0&&r(i-1,l-1);)i--,l--;let a=e,s=t,f=n[e][t].score,c=1;for(;a+1<n.length&&s+1<n[a+1].length&&r(a+1,s+1);)a++,s++,f+=n[a][s].score,c++;for(let u=e-1,v=t-1;u>=i&&v>=l;u--,v--)f+=n[u][v].score,c++;return c>=3&&f/c>=he&&o(i,l)&&o(a,s)}function W(n,e){let t=Number.NEGATIVE_INFINITY,r=Number.NEGATIVE_INFINITY;return n.forEach((o,i)=>{e(o,i)&&(o.score>t?(r=t,t=o.score):o.score>r&&(r=o.score))}),{best:t,second:r}}function P(n){let e=Number.NEGATIVE_INFINITY,t=Number.NEGATIVE_INFINITY;for(let r of n)r.eligible&&(r.score>e?(t=e,e=r.score):r.score>t&&(t=r.score));return{best:e,second:t}}function Ge(n,e){let t=$e(n,e),r=[],o=0,i=0;for(let l of t)ce(r,n.slice(o,l.leftIndex),e.slice(i,l.rightIndex)),r.push({left:n[l.leftIndex],right:e[l.rightIndex]}),o=l.leftIndex+1,i=l.rightIndex+1;return ce(r,n.slice(o),e.slice(i)),r}function $e(n,e){let t=Ue(n,e);if(t===null)return[];let r=be(n,e),o=t.map(({leftIndex:f,rightIndex:c,exact:u})=>({leftIndex:f,rightIndex:c,exact:u,structural:r.has(`${f}:${c}`),match:Y(n[f],e[c])})).filter(f=>f.exact||f.structural||f.match.eligible),i=ae(o,"leftIndex"),l=ae(o,"rightIndex"),a=o.filter(f=>{if(f.exact||f.structural)return!0;let c=i.get(f.leftIndex),u=l.get(f.rightIndex);if(!c||!u||f.match.score!==c.best||f.match.score!==u.best)return!1;let v=f.match.score>=me?G/2:G;return c.best-c.second>=v&&u.best-u.second>=v}),s=Pe(a,e.length);return s.length<=_e?s:[]}function Ue(n,e){let t=le(n,M),r=le(e,M),o=new Map;for(let[a,s]of t){let f=r.get(a);if(!C(a)||s.length!==1||f?.length!==1)continue;let c=s[0],u=f[0];if(o.set(`${c}:${u}`,{leftIndex:c,rightIndex:u,exact:!0}),o.size>oe)return null}let i=fe(n),l=fe(e);for(let[a,s]of i){let f=l.get(a);if(!(!f||s.length>se||f.length>se))for(let c of s)for(let u of f){let v=`${c}:${u}`;if(!o.has(v)&&(o.set(v,{leftIndex:c,rightIndex:u,exact:!1}),o.size>oe))return null}}return[...o.values()]}function le(n,e){let t=new Map;return n.forEach((r,o)=>{let i=e(r),l=t.get(i)??[];l.push(o),t.set(i,l)}),t}function fe(n){let e=new Map;return n.forEach((t,r)=>{let o=new Set(q(M(t)).filter(ze));for(let i of o){let l=e.get(i)??[];l.push(r),e.set(i,l)}}),e}function ze(n){return n.length>=2&&/[\p{L}\p{N}_$]/u.test(n)}function ae(n,e){let t=new Map;for(let r of n){let o=t.get(r[e])??[];o.push(r.match),t.set(r[e],o)}return new Map([...t].map(([r,o])=>[r,P(o)]))}function Pe(n,e){let t=[...n].sort((f,c)=>f.leftIndex-c.leftIndex||f.rightIndex-c.rightIndex),r=new Array(e+2).fill(0),o=new Array(e+2).fill(-1),i=new Array(t.length).fill(0),l=new Array(t.length).fill(-1);for(let f=0;f<t.length;){let c=f+1;for(;c<t.length&&t[c].leftIndex===t[f].leftIndex;)c++;for(let u=f;u<c;u++){let v=ue(r,o,t[u].rightIndex),b=t[u].exact||t[u].structural?.5:0;i[u]=v.score+t[u].match.score+b,l[u]=v.candidateIndex}for(let u=f;u<c;u++)Be(r,o,t[u].rightIndex+1,i[u],u);f=c}let a=ue(r,o,e+1),s=[];for(let f=a.candidateIndex;f>=0;f=l[f])s.push({leftIndex:t[f].leftIndex,rightIndex:t[f].rightIndex});return s.reverse()}function ue(n,e,t){let r=0,o=-1;for(let i=t;i>0;i-=i&-i)n[i]>r&&(r=n[i],o=e[i]);return{score:r,candidateIndex:o}}function Be(n,e,t,r,o){for(let i=t;i<n.length;i+=i&-i)r>n[i]&&(n[i]=r,e[i]=o)}function ce(n,e,t){if(e.length*t.length<=pe){n.push(...ve(e,t));return}n.push(...e.map(r=>({left:r}))),n.push(...t.map(r=>({right:r})))}function M(n){return n.trim().replace(/\s+/g," ")}function be(n,e){let t=de(n),r=de(e),o=new Set;for(let[i,l]of t){let a=r.get(i);l.length===1&&a?.length===1&&o.add(`${l[0]}:${a[0]}`)}return o}function de(n){let e=new Map;return n.forEach((t,r)=>{let o=X(t);if(!o)return;let i=e.get(o)??[];i.push(r),e.set(o,i)}),e}function B(n,e){let t=X(n),r=X(e);return!t||!r?t===r:t.split(":",1)[0]===r.split(":",1)[0]}function X(n){let e=M(n),t=[["function",/^(?:(?:export|default)\s+)*(?:async\s+)?function\s*\*?\s*([\p{L}_$][\p{L}\p{N}_$]*)\s*\(/u],["function",/^(?:async\s+)?def\s+([\p{L}_][\p{L}\p{N}_]*)\s*\(/u],["function",/^(?:pub(?:\([^)]*\))?\s+)?(?:async\s+)?fn\s+([\p{L}_][\p{L}\p{N}_]*)\s*(?:<[^>]*>)?\s*\(/u],["function",/^func\s+(?:\([^)]*\)\s*)?([\p{L}_][\p{L}\p{N}_]*)\s*\(/u],["class",/^(?:(?:export|default|abstract|public)\s+)*class\s+([\p{L}_$][\p{L}\p{N}_$]*)\b/u]];for(let[r,o]of t){let i=e.match(o);if(i)return`${r}:${i[1]}`}return null}function C(n){return n.length<3?!1:/[\p{L}\p{N}_$]/u.test(n)&&!/^[\s()[\]{};,.:+\-*/=>|&!?'"`]+$/.test(n)}function q(n){return n.toLowerCase().match(/[\p{L}_$][\p{L}\p{N}_$]*|\p{N}+(?:\.\p{N}+)?|[^\s\p{L}\p{N}_$]/gu)??[]}function Xe(n,e){if(n.length+e.length===0)return 1;let t=new Map;n.forEach(o=>t.set(o,(t.get(o)??0)+1));let r=0;for(let o of e){let i=t.get(o)??0;i>0&&(r++,t.set(o,i-1))}return 2*r/(n.length+e.length)}function qe(n,e){if(n.length===0||e.length===0)return 0;let t=n[0]===e[0]?.5:0,r=n[n.length-1]===e[e.length-1]?.5:0;return t+r}function Ye(n,e){let t=n.length+e.length;return t===0?1:2*Z(n,e).filter(o=>!o.added&&!o.removed).reduce((o,i)=>o+i.value.length,0)/t}function Ve(n,e){if(n.content.length>te||e.content.length>te)return;let{leftSegments:t,rightSegments:r,hasInlineChanges:o}=Ke(n.content,e.content);o&&(n.segments=t,e.segments=r)}function Ke(n,e){let t=Q(n,e),r=[],o=[],i=!1;for(let l of t){let a=l.value;if(!l.added&&!l.removed){let f={kind:"context",text:a,emphasis:!1};r.push(f),o.push(f);continue}let s=/[^\s]/.test(a);i=i||s,l.removed&&r.push({kind:"removed",text:a,emphasis:s}),l.added&&o.push({kind:"added",text:a,emphasis:s})}return{leftSegments:r,rightSegments:o,hasInlineChanges:i}}function R(){return{kind:"placeholder",content:"",lineNumber:null}}function E(n,e,t){return{kind:n,content:e,lineNumber:t}}function A(n,e,t){return{kind:n,content:e,lineNumber:t}}function T(n,e){return{left:n,right:e}}function k(n,e,t,r,o){return{kind:n,leftStart:e,leftEnd:t,rightStart:r,rightEnd:o}}function we(n,e){let t=typeof process<"u"?process.env?.[n]:void 0,r=Number.parseInt(t??"",10);return Number.isFinite(r)&&r>0?r:e}self.addEventListener("message",n=>{let{id:e,leftContent:t,rightContent:r}=n.data||{};if(!(typeof e!="number"||typeof t!="string"||typeof r!="string"))try{let o=ge(t,r);self.postMessage({id:e,model:o})}catch(o){self.postMessage({id:e,error:o&&o.message||String(o)})}});})();
5
+ //# sourceMappingURL=diff.worker.js.map