@aistastudio/myc 0.3.1 → 0.3.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/README.md CHANGED
@@ -31,7 +31,7 @@ Installation is one command:
31
31
 
32
32
  ```bash
33
33
  bun install -g @aistastudio/myc # 3.20 MB, 10 files, no models pulled at install
34
- myc --version # myc 0.3.1 (schema 1)
34
+ myc --version # myc 0.3.3 (schema 1)
35
35
  ```
36
36
 
37
37
  The embedding model is **not** downloaded during install. Semantic search is
@@ -65,6 +65,63 @@ writing a config that silently won't start.
65
65
 
66
66
  Full command list: `./dist/myc --help`.
67
67
 
68
+ ## Heavy commands take turns
69
+
70
+ Several agents on one machine — in one tree or in neighbouring projects — each
71
+ run the heavy things: the full test suite, builds, benchmarks. Run at once, they
72
+ get in each other's way: full runs take twice as long, and latency budgets fail
73
+ because of the neighbour, not the code. `myc run` puts such a command into one
74
+ queue shared by every repository of the machine user (`~/.myc/queue.db`), waits
75
+ for a free slot (first come, first served) and then runs it with the terminal
76
+ and the exit code left alone:
77
+
78
+ ```bash
79
+ myc run -- bun test # waits its turn (--max-wait 5m by default), then runs
80
+ myc run --max-wait 15m -- make # a longer wait for a longer tool timeout
81
+ myc queue # who is running, who is waiting, for how long
82
+ ```
83
+
84
+ ```
85
+ $ myc queue
86
+ heavy · slots 1 · 1 running · 1 waiting · ~/.myc/queue.db
87
+ running #1 4s bun test ~/src/api session 6468c59d · orca term_efe4850f · pid 44815 · command pid 44827
88
+ waiting #2 3s bun run build ~/src/web session 6468c59d · orca term_efe4850f · pid 44850 (#1 in line)
89
+ ```
90
+
91
+ A waiting command says on stderr whom it waits for; past `--max-wait` it gives
92
+ up with exit code 9 and names what is ahead:
93
+
94
+ ```
95
+ myc run: waiting for a 'heavy' slot (1/1 busy, 1 waiting ahead), waited 0.0s of max 3s — held by 'bun test' in ~/src/api, session 6468c59d, orca term_efe4850f, pid 44815, running 13s
96
+ ```
97
+
98
+ A holder that dies — even by `SIGKILL` — frees its slot; a `myc run` nested
99
+ inside another one runs at once, in its parent's slot. One slot per lane by
100
+ default, `MYC_HEAVY_SLOTS=2` for two.
101
+
102
+ **Agents don't have to remember it.** `myc wire --queue-hook` installs a Claude
103
+ Code `PreToolUse` hook that rewrites a heavy Bash command into
104
+ `myc run -- <the same command>` before it runs. Heavy means a full test run or a
105
+ build: `bun test` with no paths, `bun run build` / `typecheck`, `npm` / `pnpm` /
106
+ `yarn` `test` and `build`, `cargo test` / `build`, `go test ./...`, `pytest`
107
+ with no paths, `make`. A targeted `bun test path/file.test.ts`, a command already
108
+ under `myc run`, a background one and a nested one pass untouched.
109
+ `MYC_QUEUE_HEAVY` replaces the list (`+…` adds to it, `off` turns the hook off).
110
+ It is opt-in: `wire` without the flag writes no such hook, and `unwire` removes
111
+ it. It is cheap, because it runs on every Bash call: a command that is not heavy
112
+ is let through by the host's own shell without starting bun or node — 3.4 ms at
113
+ the median and 4.3 ms at p99 in the run of 2026-09-11, against 30 ms for the
114
+ prime hook (`bun test packages/cli/src/hooks/queue-hook.multiprocess.test.ts`).
115
+
116
+ **`myc run` is not a way around permissions.** It runs whatever it is given, so
117
+ a queued command goes through without a question only when your own rules would
118
+ let the original command through — `Bash(bun test:*)` keeps `bun test` silent
119
+ under the queue as well. Otherwise Claude Code asks, and the question shows the
120
+ whole command; a deny or ask rule on the original command still holds. The same
121
+ goes for a `myc run -- <cmd>` an agent types itself. For the same reason `wire`
122
+ no longer writes the broad `Bash(myc:*)`: it allows myc's subcommands one by
123
+ one, and `run`, `statusline --then`, `wire` and `unwire` ask.
124
+
68
125
  ## What makes it different
69
126
 
70
127
  **Speed is a constraint, not an optimisation.** Every hot path has a budget
@@ -103,18 +160,18 @@ attempted, so exceeding the hook's timeout costs the summary, not the record:
103
160
 
104
161
  ```
105
162
  $ myc absorb-session --reason manual --transcript … --agent claude
106
- # myc: контекст сжимаетсявот что нельзя потерять
107
- эпизод sess-5jh8je4g050m сохранён (265 Б)
108
- ДАЛЬШЕ myc show sess-5jh8je4g050m · myc ready --claim
163
+ # myc: context is being compacted here is what must not be lost
164
+ episode sess-5jh8je4g050m saved (265 B)
165
+ NEXT myc show sess-5jh8je4g050m · myc ready --claim
109
166
  ```
110
167
 
111
168
  **A status line with what the agent cannot see.** `myc wire --status-line`
112
- puts one line under Claude Code's prompt — the task queue, the code index, the
113
- project's memory, and how many of this session's calls to myc actually returned
114
- something:
169
+ puts one line under Claude Code's prompt — how full the context is, the task
170
+ queue, the code index, the project's memory, and how many of this session's
171
+ calls to myc actually returned something:
115
172
 
116
173
  ```
117
- myc │ 61 ready · 34 blocked │ 612 files · 4268 symbols · 1h ago │ 101 notes │ 600/653 useful calls
174
+ myc │ ctx 42% │ 61 ready · 34 blocked │ 612 files · 4268 symbols · 1h ago │ 101 notes │ 600/653 useful calls
118
175
  ```
119
176
 
120
177
  "Useful" is counted from the host's own transcript, not guessed: an error, a
@@ -133,9 +190,10 @@ marks each row for what it is: `ses` own session, `ses*` someone else's, `prj`
133
190
  project-wide.
134
191
 
135
192
  ```
136
- $ MYC_SESSION_ID=s1 myc recall "ретраи" $ MYC_SESSION_ID=s2 myc recall "ретраи"
137
- 1.30 ses сессионное: ретраи… 1.30ses* сессионное: ретраи…
138
- 1.10 … ses* в сессии один: ретраи… 1.10 … ses* в сессии один: ретраи…
193
+ $ MYC_SESSION_ID=s1 myc recall "retries" $ MYC_SESSION_ID=s2 myc recall "retries"
194
+ prj project note: retries use jitter prj project note: retries use jitter
195
+ … ses session note: retries back off… … ses* session note: retries back off…
196
+ 3 of 3 · bm25 only 3 of 3 · bm25 only · 2 from other sessions
139
197
  ```
140
198
 
141
199
  **Memory has three independent axes**, and the surface says what it hid:
@@ -192,8 +250,12 @@ in git.** There is no server, no ACL and no team mode. Those are designed
192
250
  (`docs/design/03…`, `04…`, `05…`) and tracked, not implemented.
193
251
 
194
252
  Code intelligence is built in, and it is the same engine the alternatives use:
195
- tree-sitter, with grammars fetched on demand rather than shipped (all 36 weigh
196
- 49 MB against a 12 MB package). `myc code index` builds it — on this repository,
253
+ tree-sitter, with grammars fetched on demand rather than shipped. Symbols,
254
+ callers and code search work for TypeScript, TSX, JavaScript (js, jsx, mjs,
255
+ cjs) and Python — the languages myc has definition rules for. The grammar
256
+ package holds 36; a language is added as a pair, a rule and a catalog entry,
257
+ so a grammar that would yield no symbols is never offered. Every other file
258
+ still gets `code grep`, anchors and staleness. `myc code index` builds it — on this repository,
197
259
  826 files and 3 949 symbols in 904 ms — and four commands read it:
198
260
 
199
261
  ```
@@ -3,4 +3,4 @@ var N0=Object.create;var{getPrototypeOf:I0,defineProperty:H0,getOwnPropertyNames
3
3
  `)[0],R=V.match(QUERY_WORD_REGEX)[0],T;switch(K){case 2:T=RangeError(`Bad node name '${R}'`);break;case 3:T=RangeError(`Bad field name '${R}'`);break;case 4:T=RangeError(`Bad capture name @${R}`);break;case 5:T=TypeError(`Bad pattern structure at offset ${D}: '${V}'...`),R="";break;default:T=SyntaxError(`Bad syntax at offset ${D}: '${V}'...`),R="";break}throw T.index=D,T.length=R.length,C._free($),T}let q=C._ts_query_string_count(J),H=C._ts_query_capture_count(J),U=C._ts_query_pattern_count(J),Y=Array(H),j=Array(q);for(let K=0;K<H;K++){let w=C._ts_query_capture_name_for_id(J,K,TRANSFER_BUFFER),D=getValue(TRANSFER_BUFFER,"i32");Y[K]=UTF8ToString(w,D)}for(let K=0;K<q;K++){let w=C._ts_query_string_value_for_id(J,K,TRANSFER_BUFFER),D=getValue(TRANSFER_BUFFER,"i32");j[K]=UTF8ToString(w,D)}let W=Array(U),k=Array(U),F=Array(U),z=Array(U),G=Array(U);for(let K=0;K<U;K++){let w=C._ts_query_predicates_for_pattern(J,K,TRANSFER_BUFFER),D=getValue(TRANSFER_BUFFER,"i32");z[K]=[],G[K]=[];let V=[],R=w;for(let T=0;T<D;T++){let S=getValue(R,"i32");R+=SIZE_OF_INT;let b=getValue(R,"i32");if(R+=SIZE_OF_INT,S===PREDICATE_STEP_TYPE_CAPTURE)V.push({type:"capture",name:Y[b]});else if(S===PREDICATE_STEP_TYPE_STRING)V.push({type:"string",value:j[b]});else if(V.length>0){if(V[0].type!=="string")throw Error("Predicates must begin with a literal value");let L=V[0].value,E=!0,h=!0,N;switch(L){case"any-not-eq?":case"not-eq?":E=!1;case"any-eq?":case"eq?":if(V.length!==3)throw Error(`Wrong number of arguments to \`#${L}\` predicate. Expected 2, got ${V.length-1}`);if(V[1].type!=="capture")throw Error(`First argument of \`#${L}\` predicate must be a capture. Got "${V[1].value}"`);if(h=!L.startsWith("any-"),V[2].type==="capture"){let B=V[1].name,_=V[2].name;G[K].push((A)=>{let O=[],I=[];for(let P of A){if(P.name===B)O.push(P.node);if(P.name===_)I.push(P.node)}let M=(P,f,v0)=>v0?P.text===f.text:P.text!==f.text;return h?O.every((P)=>I.some((f)=>M(P,f,E))):O.some((P)=>I.some((f)=>M(P,f,E)))})}else{N=V[1].name;let B=V[2].value,_=(O)=>O.text===B,A=(O)=>O.text!==B;G[K].push((O)=>{let I=[];for(let P of O)if(P.name===N)I.push(P.node);let M=E?_:A;return h?I.every(M):I.some(M)})}break;case"any-not-match?":case"not-match?":E=!1;case"any-match?":case"match?":if(V.length!==3)throw Error(`Wrong number of arguments to \`#${L}\` predicate. Expected 2, got ${V.length-1}.`);if(V[1].type!=="capture")throw Error(`First argument of \`#${L}\` predicate must be a capture. Got "${V[1].value}".`);if(V[2].type!=="string")throw Error(`Second argument of \`#${L}\` predicate must be a string. Got @${V[2].value}.`);N=V[1].name;let y=new RegExp(V[2].value);h=!L.startsWith("any-"),G[K].push((B)=>{let _=[];for(let O of B)if(O.name===N)_.push(O.node.text);let A=(O,I)=>I?y.test(O):!y.test(O);if(_.length===0)return!E;return h?_.every((O)=>A(O,E)):_.some((O)=>A(O,E))});break;case"set!":if(V.length<2||V.length>3)throw Error(`Wrong number of arguments to \`#set!\` predicate. Expected 1 or 2. Got ${V.length-1}.`);if(V.some((B)=>B.type!=="string"))throw Error('Arguments to `#set!` predicate must be a strings.".');if(!W[K])W[K]={};W[K][V[1].value]=V[2]?V[2].value:null;break;case"is?":case"is-not?":if(V.length<2||V.length>3)throw Error(`Wrong number of arguments to \`#${L}\` predicate. Expected 1 or 2. Got ${V.length-1}.`);if(V.some((B)=>B.type!=="string"))throw Error(`Arguments to \`#${L}\` predicate must be a strings.".`);let x=L==="is?"?k:F;if(!x[K])x[K]={};x[K][V[1].value]=V[2]?V[2].value:null;break;case"not-any-of?":E=!1;case"any-of?":if(V.length<2)throw Error(`Wrong number of arguments to \`#${L}\` predicate. Expected at least 1. Got ${V.length-1}.`);if(V[1].type!=="capture")throw Error(`First argument of \`#${L}\` predicate must be a capture. Got "${V[1].value}".`);for(let B=2;B<V.length;B++)if(V[B].type!=="string")throw Error(`Arguments to \`#${L}\` predicate must be a strings.".`);N=V[1].name;let q0=V.slice(2).map((B)=>B.value);G[K].push((B)=>{let _=[];for(let A of B)if(A.name===N)_.push(A.node.text);if(_.length===0)return!E;return _.every((A)=>q0.includes(A))===E});break;default:z[K].push({operator:L,operands:V.slice(1)})}V.length=0}}Object.freeze(W[K]),Object.freeze(k[K]),Object.freeze(F[K])}return C._free($),new Query(INTERNAL,J,Y,G,z,Object.freeze(W),Object.freeze(k),Object.freeze(F))}static load(Q){let Z;if(Q instanceof Uint8Array)Z=Promise.resolve(Q);else{let $=Q;if(typeof process<"u"&&process.versions&&process.versions.node){let J=t("fs");Z=Promise.resolve(J.readFileSync($))}else Z=fetch($).then((J)=>J.arrayBuffer().then((q)=>{if(J.ok)return new Uint8Array(q);else{let H=new TextDecoder("utf-8").decode(q);throw Error(`Language.load failed with status ${J.status}.
4
4
 
5
5
  ${H}`)}}))}return Z.then(($)=>loadWebAssemblyModule($,{loadAsync:!0})).then(($)=>{let J=Object.keys($),q=J.find((U)=>LANGUAGE_FUNCTION_REGEX.test(U)&&!U.includes("external_scanner_"));if(!q)console.log(`Couldn't find language function in WASM file. Symbols:
6
- ${JSON.stringify(J,null,2)}`);let H=$[q]();return new Language(INTERNAL,H)})}}class LookaheadIterable{constructor(Q,Z,$){assertInternal(Q),this[0]=Z,this.language=$}get currentTypeId(){return C._ts_lookahead_iterator_current_symbol(this[0])}get currentType(){return this.language.types[this.currentTypeId]||"ERROR"}delete(){C._ts_lookahead_iterator_delete(this[0]),this[0]=0}resetState(Q){return C._ts_lookahead_iterator_reset_state(this[0],Q)}reset(Q,Z){if(C._ts_lookahead_iterator_reset(this[0],Q[0],Z))return this.language=Q,!0;return!1}[Symbol.iterator](){let Q=this;return{next(){if(C._ts_lookahead_iterator_next(Q[0]))return{done:!1,value:Q.currentType};return{done:!0,value:""}}}}}class Query{constructor(Q,Z,$,J,q,H,U,Y){assertInternal(Q),this[0]=Z,this.captureNames=$,this.textPredicates=J,this.predicates=q,this.setProperties=H,this.assertedProperties=U,this.refutedProperties=Y,this.exceededMatchLimit=!1}delete(){C._ts_query_delete(this[0]),this[0]=0}matches(Q,{startPosition:Z=ZERO_POINT,endPosition:$=ZERO_POINT,startIndex:J=0,endIndex:q=0,matchLimit:H=4294967295,maxStartDepth:U=4294967295,timeoutMicros:Y=0}={}){if(typeof H!=="number")throw Error("Arguments must be numbers");marshalNode(Q),C._ts_query_matches_wasm(this[0],Q.tree[0],Z.row,Z.column,$.row,$.column,J,q,H,U,Y);let j=getValue(TRANSFER_BUFFER,"i32"),W=getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),k=getValue(TRANSFER_BUFFER+2*SIZE_OF_INT,"i32"),F=Array(j);this.exceededMatchLimit=Boolean(k);let z=0,G=W;for(let K=0;K<j;K++){let w=getValue(G,"i32");G+=SIZE_OF_INT;let D=getValue(G,"i32");G+=SIZE_OF_INT;let V=Array(D);if(G=unmarshalCaptures(this,Q.tree,G,V),this.textPredicates[w].every((R)=>R(V))){F[z]={pattern:w,captures:V};let R=this.setProperties[w];if(R)F[z].setProperties=R;let T=this.assertedProperties[w];if(T)F[z].assertedProperties=T;let S=this.refutedProperties[w];if(S)F[z].refutedProperties=S;z++}}return F.length=z,C._free(W),F}captures(Q,{startPosition:Z=ZERO_POINT,endPosition:$=ZERO_POINT,startIndex:J=0,endIndex:q=0,matchLimit:H=4294967295,maxStartDepth:U=4294967295,timeoutMicros:Y=0}={}){if(typeof H!=="number")throw Error("Arguments must be numbers");marshalNode(Q),C._ts_query_captures_wasm(this[0],Q.tree[0],Z.row,Z.column,$.row,$.column,J,q,H,U,Y);let j=getValue(TRANSFER_BUFFER,"i32"),W=getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),k=getValue(TRANSFER_BUFFER+2*SIZE_OF_INT,"i32"),F=[];this.exceededMatchLimit=Boolean(k);let z=[],G=W;for(let K=0;K<j;K++){let w=getValue(G,"i32");G+=SIZE_OF_INT;let D=getValue(G,"i32");G+=SIZE_OF_INT;let V=getValue(G,"i32");if(G+=SIZE_OF_INT,z.length=D,G=unmarshalCaptures(this,Q.tree,G,z),this.textPredicates[w].every((R)=>R(z))){let R=z[V],T=this.setProperties[w];if(T)R.setProperties=T;let S=this.assertedProperties[w];if(S)R.assertedProperties=S;let b=this.refutedProperties[w];if(b)R.refutedProperties=b;F.push(R)}}return C._free(W),F}predicatesForPattern(Q){return this.predicates[Q]}disableCapture(Q){let Z=lengthBytesUTF8(Q),$=C._malloc(Z+1);stringToUTF8(Q,$,Z+1),C._ts_query_disable_capture(this[0],$,Z),C._free($)}didExceedMatchLimit(){return this.exceededMatchLimit}}function getText(Q,Z,$){let J=$-Z,q=Q.textCallback(Z,null,$);Z+=q.length;while(Z<$){let H=Q.textCallback(Z,null,$);if(H&&H.length>0)Z+=H.length,q+=H;else break}if(Z>$)q=q.slice(0,J);return q}function unmarshalCaptures(Q,Z,$,J){for(let q=0,H=J.length;q<H;q++){let U=getValue($,"i32");$+=SIZE_OF_INT;let Y=unmarshalNode(Z,$);$+=SIZE_OF_NODE,J[q]={name:Q.captureNames[U],node:Y}}return $}function assertInternal(Q){if(Q!==INTERNAL)throw Error("Illegal constructor")}function isPoint(Q){return Q&&typeof Q.row==="number"&&typeof Q.column==="number"}function marshalNode(Q){let Z=TRANSFER_BUFFER;setValue(Z,Q.id,"i32"),Z+=SIZE_OF_INT,setValue(Z,Q.startIndex,"i32"),Z+=SIZE_OF_INT,setValue(Z,Q.startPosition.row,"i32"),Z+=SIZE_OF_INT,setValue(Z,Q.startPosition.column,"i32"),Z+=SIZE_OF_INT,setValue(Z,Q[0],"i32")}function unmarshalNode(Q,Z=TRANSFER_BUFFER){let $=getValue(Z,"i32");if(Z+=SIZE_OF_INT,$===0)return null;let J=getValue(Z,"i32");Z+=SIZE_OF_INT;let q=getValue(Z,"i32");Z+=SIZE_OF_INT;let H=getValue(Z,"i32");Z+=SIZE_OF_INT;let U=getValue(Z,"i32"),Y=new Node(INTERNAL,Q);return Y.id=$,Y.startIndex=J,Y.startPosition={row:q,column:H},Y[0]=U,Y}function marshalTreeCursor(Q,Z=TRANSFER_BUFFER){setValue(Z+0*SIZE_OF_INT,Q[0],"i32"),setValue(Z+1*SIZE_OF_INT,Q[1],"i32"),setValue(Z+2*SIZE_OF_INT,Q[2],"i32"),setValue(Z+3*SIZE_OF_INT,Q[3],"i32")}function unmarshalTreeCursor(Q){Q[0]=getValue(TRANSFER_BUFFER+0*SIZE_OF_INT,"i32"),Q[1]=getValue(TRANSFER_BUFFER+1*SIZE_OF_INT,"i32"),Q[2]=getValue(TRANSFER_BUFFER+2*SIZE_OF_INT,"i32"),Q[3]=getValue(TRANSFER_BUFFER+3*SIZE_OF_INT,"i32")}function marshalPoint(Q,Z){setValue(Q,Z.row,"i32"),setValue(Q+SIZE_OF_INT,Z.column,"i32")}function unmarshalPoint(Q){return{row:getValue(Q,"i32")>>>0,column:getValue(Q+SIZE_OF_INT,"i32")>>>0}}function marshalRange(Q,Z){marshalPoint(Q,Z.startPosition),Q+=SIZE_OF_POINT,marshalPoint(Q,Z.endPosition),Q+=SIZE_OF_POINT,setValue(Q,Z.startIndex,"i32"),Q+=SIZE_OF_INT,setValue(Q,Z.endIndex,"i32"),Q+=SIZE_OF_INT}function unmarshalRange(Q){let Z={};return Z.startPosition=unmarshalPoint(Q),Q+=SIZE_OF_POINT,Z.endPosition=unmarshalPoint(Q),Q+=SIZE_OF_POINT,Z.startIndex=getValue(Q,"i32")>>>0,Q+=SIZE_OF_INT,Z.endIndex=getValue(Q,"i32")>>>0,Z}function marshalEdit(Q){let Z=TRANSFER_BUFFER;marshalPoint(Z,Q.startPosition),Z+=SIZE_OF_POINT,marshalPoint(Z,Q.oldEndPosition),Z+=SIZE_OF_POINT,marshalPoint(Z,Q.newEndPosition),Z+=SIZE_OF_POINT,setValue(Z,Q.startIndex,"i32"),Z+=SIZE_OF_INT,setValue(Z,Q.oldEndIndex,"i32"),Z+=SIZE_OF_INT,setValue(Z,Q.newEndIndex,"i32"),Z+=SIZE_OF_INT}for(let Q of Object.getOwnPropertyNames(ParserImpl.prototype))Object.defineProperty(Parser.prototype,Q,{value:ParserImpl.prototype[Q],enumerable:!1,writable:!1});Parser.Language=Language,X.onRuntimeInitialized=()=>{ParserImpl.init(),resolveInitPromise()}})}}return Parser}();if(typeof m==="object")g.exports=m0});var d=g0(Y0(),1);import{delimiter as OQ,join as t0}from"path";import{existsSync as FQ,statSync as p0}from"fs";import{homedir as u0}from"os";import{delimiter as V0,dirname as c,join as u}from"path";import{fileURLToPath as a}from"url";var s={"web-tree-sitter":"0.24.7","tree-sitter-wasms":"0.1.13"};var l0=s["tree-sitter-wasms"];function i0(Q){return`https://cdn.jsdelivr.net/npm/tree-sitter-wasms@${l0}/out/tree-sitter-${Q}.wasm`}function p(Q,Z,$,J){return{name:Q,file:`tree-sitter-${Q}.wasm`,url:i0(Q),sha256:Z,bytes:$,langs:J}}var K0={typescript:p("typescript","8515404dceed38e1ed86aa34b09fcf3379fff1b4ff9dd3967bcd6d1eb5ac3d8f",2342690,["ts"]),tsx:p("tsx","6aa3b2c70e76f5d48eafef1093e9c4de383e13f2fdde2f4e9b98a378f6a8f1b6",2411272,["tsx"]),javascript:p("javascript","63812b9e275d26851264734868d27a1656bd44a2ef6eb3e85e6b03728c595ab5",647334,["js","jsx"]),python:p("python","9056d0fb0c337810d019fae350e8167786119da98f0f282aceae7ab89ee8253b",476105,["py"])},n0=(()=>{let Q={};for(let Z of Object.values(K0))for(let $ of Z.langs)Q[$]=Z.name;return Q})();function e(Q){let Z=n0[Q];if(Z===void 0)throw Error(`\u043D\u0435\u0442 \u0433\u0440\u0430\u043C\u043C\u0430\u0442\u0438\u043A\u0438 \u0434\u043B\u044F \u044F\u0437\u044B\u043A\u0430 "${Q}"`);return K0[Z]}function o0(Q=process.env){let Z=Q.MYC_GRAMMARS_DIR;if(Z!==void 0&&Z!=="")return Z;return u(u0(),".cache","myc","grammars")}function j0(Q){try{return u(c(a(import.meta.url)),"..","vendor",Q)}catch{return null}}function d0(){try{let Q=Bun.resolveSync("tree-sitter-wasms/package.json",c(a(import.meta.url)));return u(c(Q),"out")}catch{return null}}function Q0(Q=process.env){let Z=Q.MYC_TREE_SITTER_GRAMMAR_DIR;if(Z!==void 0&&Z!=="")return Z.split(V0).filter((H)=>H.length>0);let $=[o0(Q)],J=j0("tree-sitter-grammars");if(J!==null)$.push(J);let q=d0();if(q!==null)$.push(q);return $}function Z0(Q=process.env){let Z=Q.MYC_TREE_SITTER_DIR;if(Z!==void 0&&Z!=="")return Z.split(V0).filter((q)=>q.length>0);let $=[],J=j0("tree-sitter");if(J!==null)$.push(J);try{let q=Bun.resolveSync("web-tree-sitter/package.json",c(a(import.meta.url)));$.push(c(q))}catch{}return $}var l="tree-sitter.wasm";function W0(Q,Z,$){for(let J of Q){let q=u(J,Z);try{let H=p0(q);if(!H.isFile())continue;if($!==void 0&&H.size!==$)continue;return q}catch{continue}}return null}function z0(Q,Z=process.env){let $=e(Q);return W0(Q0(Z),$.file,$.bytes)}function C0(Q=process.env){return W0(Z0(Q),l)}function G0(Q){if(Q<1024)return`${Q} \u0411`;let Z=["\u041A\u0411","\u041C\u0411","\u0413\u0411"],$=Q/1024,J=0;while($>=1024&&J<Z.length-1)$/=1024,J++;return`${$.toFixed(1)} ${Z[J]}`}class F0 extends Error{lang;constructor(Q){super(`\u0433\u0440\u0430\u043C\u043C\u0430\u0442\u0438\u043A\u0430 tree-sitter \u0434\u043B\u044F "${Q}" \u043D\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043D\u0430: \u0432\u044B\u0437\u043E\u0432\u0438\u0442\u0435 await loadLang("${Q}") \u0434\u043E listDefs`);this.lang=Q;this.name="GrammarNotLoadedError"}}var n={function_declaration:"function",generator_function_declaration:"function",class_declaration:"class",abstract_class_declaration:"class",interface_declaration:"interface",enum_declaration:"enum",type_alias_declaration:"type",method_definition:"method"},r0={function_definition:"function",class_definition:"class"},s0=new Set(["arrow_function","function_expression","function","generator_function"]),w0={ts:{kinds:n,declarators:!0,methodByParent:[]},tsx:{kinds:n,declarators:!0,methodByParent:[]},js:{kinds:n,declarators:!0,methodByParent:[]},jsx:{kinds:n,declarators:!0,methodByParent:[]},py:{kinds:r0,declarators:!1,methodByParent:["block"]}},_Q=Object.keys(w0),o=null,$0=new Map,k0=new Map;class X0 extends Error{hint;constructor(Q,Z){super(Q);this.hint=Z;this.name="MissingResourceError"}}class R0 extends X0{searched;constructor(Q){super(`\u0440\u0430\u043D\u0442\u0430\u0439\u043C tree-sitter \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D: ${l} \u043D\u0435\u0442 \u043D\u0438 \u0432 \u043E\u0434\u043D\u043E\u043C \u0438\u0437 \u043A\u0430\u0442\u0430\u043B\u043E\u0433\u043E\u0432 `+`[${Q.join(", ")}]. \u041E\u043D \u043F\u043E\u0441\u0442\u0430\u0432\u043B\u044F\u0435\u0442\u0441\u044F \u0432\u043C\u0435\u0441\u0442\u0435 \u0441 myc, \u0438 \u0435\u0433\u043E \u043E\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 `+"\u043E\u0437\u043D\u0430\u0447\u0430\u0435\u0442 \u043F\u043E\u0432\u0440\u0435\u0436\u0434\u0451\u043D\u043D\u0443\u044E \u0443\u0441\u0442\u0430\u043D\u043E\u0432\u043A\u0443: \u043F\u0435\u0440\u0435\u0443\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u0435 \u043F\u0430\u043A\u0435\u0442 \u043B\u0438\u0431\u043E \u0443\u043A\u0430\u0436\u0438\u0442\u0435 \u043A\u0430\u0442\u0430\u043B\u043E\u0433 "+"\u0441 \u0444\u0430\u0439\u043B\u043E\u043C \u0432 MYC_TREE_SITTER_DIR","bun add -g @aistastudio/myc");this.searched=Q;this.name="RuntimeMissingError"}}class B0 extends X0{lang;searched;constructor(Q,Z){let $=e(Q);super(`\u0433\u0440\u0430\u043C\u043C\u0430\u0442\u0438\u043A\u0430 tree-sitter \u0434\u043B\u044F "${Q}" \u043D\u0435 \u0441\u043A\u0430\u0447\u0430\u043D\u0430: ${$.file} (${G0($.bytes)}) \u043D\u0435\u0442 \u043D\u0438 \u0432 \u043E\u0434\u043D\u043E\u043C \u0438\u0437 \u043A\u0430\u0442\u0430\u043B\u043E\u0433\u043E\u0432 [${Z.join(", ")}]`,`myc code fetch ${Q}`);this.lang=Q;this.searched=Z;this.name="GrammarMissingError"}}function a0(){let Q=C0();if(Q===null)throw new R0(Z0());return Q.slice(0,Q.length-l.length-1)}function e0(Q){let Z=z0(Q);if(Z===null)throw new B0(Q,Q0());return Z}async function QQ(){if(o===null){let Q=a0();o=d.default.init({locateFile:(Z)=>t0(Q,Z)}).catch((Z)=>{throw o=null,Z})}return o}async function T0(Q){let Z=$0.get(Q);if(Z===void 0)Z=(async()=>{await QQ();let $=await d.default.Language.load(e0(Q)),J=new d.default;return J.setLanguage($),J})().catch(($)=>{throw $0.delete(Q),$}),$0.set(Q,Z);k0.set(Q,await Z)}function ZQ(Q){let Z=k0.get(Q);if(Z===void 0)throw new F0(Q);return Z}function $Q(Q){let Z=Q.childForFieldName("name");if(Z===null)return null;let $=Z.text;return $.length>0?$:null}function XQ(Q){let Z=Q.childForFieldName("value");return Z!==null&&s0.has(Z.type)}function JQ(Q,Z){if(Z.length===0)return!1;let $=Q.parent;while($!==null&&$.type==="decorated_definition")$=$.parent;if($===null||!Z.includes($.type))return!1;let J=$.parent;return J!==null&&J.type.endsWith("class_definition")}function D0(Q,Z){let $=w0[Z],J=$.kinds[Q.type];if(J!==void 0)return JQ(Q,$.methodByParent)?"method":J;if($.declarators&&Q.type==="variable_declarator"&&XQ(Q))return"function";return null}function O0(Q){return $Q(Q)}function L0(Q,Z,$,J={}){let q=$.startPosition.row+1;return{name:Q,kind:Z,startLine:q,endLine:J.naiveEnd===!0?q:$.endPosition.row+1}}function _0(Q){return ZQ(Q)}var qQ=new Set(["identifier","type_identifier","property_identifier","shorthand_property_identifier"]),HQ=new Set(["formal_parameters","required_parameter","optional_parameter","rest_pattern","object_pattern","array_pattern","pair_pattern","object_assignment_pattern","import_clause","namespace_import","parameters","lambda_parameters","default_parameter","typed_parameter","typed_default_parameter","as_pattern_target"]),UQ=new Set(["import_specifier","export_specifier","aliased_import"]),YQ=new Set(["jsx_opening_element","jsx_self_closing_element","jsx_closing_element"]),E0=new Set(["call_expression","call"]),VQ=new Set(["member_expression","attribute"]);function v(Q,Z,$){let J=Q.childForFieldName(Z);return J!==null&&J.id===$.id}function KQ(Q){let Z=Q.parent,$=Z===null?null:Z.parent;return $!==null&&$.childForFieldName("source")!==null}function jQ(Q){let Z=Q.parent;if(Z===null)return null;if(E0.has(Z.type)&&v(Z,"function",Q))return"call";if(Z.type==="new_expression"&&v(Z,"constructor",Q))return"new";return null}function WQ(Q){let Z=Q.parent;if(Z===null)return null;let $=Z.type;if(UQ.has($)){if(!v(Z,"name",Q))return null;return $==="export_specifier"&&!KQ(Z)?"read":"import"}if(YQ.has($))return v(Z,"name",Q)?"read":null;if($==="jsx_attribute")return null;if(HQ.has($))return null;if(v(Z,"name",Q))return null;if($==="pair"&&v(Z,"key",Q))return null;if($==="keyword_argument"&&v(Z,"name",Q))return null;if($==="catch_clause"&&v(Z,"parameter",Q))return null;if(E0.has($)&&v(Z,"function",Q))return"call";if($==="new_expression"&&v(Z,"constructor",Q))return"new";if(VQ.has($)){if(v(Z,"property",Q)||v(Z,"attribute",Q))return jQ(Z)??"prop";return"read"}if($==="dotted_name")return"import";if(Q.type==="type_identifier")return"type";if($==="extends_clause"||$==="implements_clause")return"type";if(Q.type==="property_identifier")return"prop";return"read"}function A0(Q,Z,$={}){let q=_0(Z).parse(Q);try{let H=[],U=[],Y=new Set,j=[],W=$.naiveOwner===!0,k=(F)=>{let z=!1,G=D0(F,Z);if(G!==null){let K=O0(F);if(K!==null)H.push(L0(K,G,F,$)),j.push({name:K,start:F.startPosition.row+1}),z=!0}if(qQ.has(F.type)){let K=WQ(F);if(K!==null){let w=F.text;if(w.length>0){let D=W||j.length===0?null:j[j.length-1],V=F.startPosition.row+1,R=D===null?"":D.name,T=D===null?0:D.start,S=`${w}\x00${V}\x00${K}\x00${T}`;if(!Y.has(S))Y.add(S),U.push({name:w,line:V,kind:K,from:R,fromStart:T})}}}for(let K=0;K<F.namedChildCount;K++){let w=F.namedChild(K);if(w!==null)k(w)}if(z)j.pop()};return k(q.rootNode),{defs:H,refs:U}}finally{q.delete()}}var P0=process.env.MYC_TREE_SITTER_DIR,S0=process.env.MYC_TREE_SITTER_GRAMMAR_DIR;if(P0===void 0||P0===""||S0===void 0||S0==="")throw Error("\u0432\u043E\u0440\u043A\u0435\u0440 \u0440\u0430\u0437\u0431\u043E\u0440\u0430 \u0437\u0430\u043F\u0443\u0449\u0435\u043D \u0431\u0435\u0437 \u043A\u0430\u0442\u0430\u043B\u043E\u0433\u043E\u0432 tree-sitter: MYC_TREE_SITTER_DIR \u0438 "+"MYC_TREE_SITTER_GRAMMAR_DIR \u0432\u044B\u0441\u0442\u0430\u0432\u043B\u044F\u0435\u0442 \u0433\u043B\u0430\u0432\u043D\u044B\u0439 \u043F\u043E\u0442\u043E\u043A (ParsePool). \u0418\u0441\u043A\u0430\u0442\u044C \u0438\u0445 "+"\u0437\u0434\u0435\u0441\u044C \u043D\u0435\u0447\u0435\u043C \u2014 \u0437\u0430 \u0433\u0440\u0430\u043D\u0438\u0446\u0435\u0439 \u043F\u043E\u0442\u043E\u043A\u0430 node_modules \u043D\u0435\u0442");var J0=globalThis;J0.onmessage=(Q)=>{let{id:Z,source:$,lang:J}=Q.data;(async()=>{try{await T0(J);let{defs:q,refs:H}=A0($,J);J0.postMessage({id:Z,defs:q,refs:H})}catch(q){J0.postMessage({id:Z,error:q instanceof Error?q.message:String(q)})}})()};
6
+ ${JSON.stringify(J,null,2)}`);let H=$[q]();return new Language(INTERNAL,H)})}}class LookaheadIterable{constructor(Q,Z,$){assertInternal(Q),this[0]=Z,this.language=$}get currentTypeId(){return C._ts_lookahead_iterator_current_symbol(this[0])}get currentType(){return this.language.types[this.currentTypeId]||"ERROR"}delete(){C._ts_lookahead_iterator_delete(this[0]),this[0]=0}resetState(Q){return C._ts_lookahead_iterator_reset_state(this[0],Q)}reset(Q,Z){if(C._ts_lookahead_iterator_reset(this[0],Q[0],Z))return this.language=Q,!0;return!1}[Symbol.iterator](){let Q=this;return{next(){if(C._ts_lookahead_iterator_next(Q[0]))return{done:!1,value:Q.currentType};return{done:!0,value:""}}}}}class Query{constructor(Q,Z,$,J,q,H,U,Y){assertInternal(Q),this[0]=Z,this.captureNames=$,this.textPredicates=J,this.predicates=q,this.setProperties=H,this.assertedProperties=U,this.refutedProperties=Y,this.exceededMatchLimit=!1}delete(){C._ts_query_delete(this[0]),this[0]=0}matches(Q,{startPosition:Z=ZERO_POINT,endPosition:$=ZERO_POINT,startIndex:J=0,endIndex:q=0,matchLimit:H=4294967295,maxStartDepth:U=4294967295,timeoutMicros:Y=0}={}){if(typeof H!=="number")throw Error("Arguments must be numbers");marshalNode(Q),C._ts_query_matches_wasm(this[0],Q.tree[0],Z.row,Z.column,$.row,$.column,J,q,H,U,Y);let j=getValue(TRANSFER_BUFFER,"i32"),W=getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),k=getValue(TRANSFER_BUFFER+2*SIZE_OF_INT,"i32"),F=Array(j);this.exceededMatchLimit=Boolean(k);let z=0,G=W;for(let K=0;K<j;K++){let w=getValue(G,"i32");G+=SIZE_OF_INT;let D=getValue(G,"i32");G+=SIZE_OF_INT;let V=Array(D);if(G=unmarshalCaptures(this,Q.tree,G,V),this.textPredicates[w].every((R)=>R(V))){F[z]={pattern:w,captures:V};let R=this.setProperties[w];if(R)F[z].setProperties=R;let T=this.assertedProperties[w];if(T)F[z].assertedProperties=T;let S=this.refutedProperties[w];if(S)F[z].refutedProperties=S;z++}}return F.length=z,C._free(W),F}captures(Q,{startPosition:Z=ZERO_POINT,endPosition:$=ZERO_POINT,startIndex:J=0,endIndex:q=0,matchLimit:H=4294967295,maxStartDepth:U=4294967295,timeoutMicros:Y=0}={}){if(typeof H!=="number")throw Error("Arguments must be numbers");marshalNode(Q),C._ts_query_captures_wasm(this[0],Q.tree[0],Z.row,Z.column,$.row,$.column,J,q,H,U,Y);let j=getValue(TRANSFER_BUFFER,"i32"),W=getValue(TRANSFER_BUFFER+SIZE_OF_INT,"i32"),k=getValue(TRANSFER_BUFFER+2*SIZE_OF_INT,"i32"),F=[];this.exceededMatchLimit=Boolean(k);let z=[],G=W;for(let K=0;K<j;K++){let w=getValue(G,"i32");G+=SIZE_OF_INT;let D=getValue(G,"i32");G+=SIZE_OF_INT;let V=getValue(G,"i32");if(G+=SIZE_OF_INT,z.length=D,G=unmarshalCaptures(this,Q.tree,G,z),this.textPredicates[w].every((R)=>R(z))){let R=z[V],T=this.setProperties[w];if(T)R.setProperties=T;let S=this.assertedProperties[w];if(S)R.assertedProperties=S;let b=this.refutedProperties[w];if(b)R.refutedProperties=b;F.push(R)}}return C._free(W),F}predicatesForPattern(Q){return this.predicates[Q]}disableCapture(Q){let Z=lengthBytesUTF8(Q),$=C._malloc(Z+1);stringToUTF8(Q,$,Z+1),C._ts_query_disable_capture(this[0],$,Z),C._free($)}didExceedMatchLimit(){return this.exceededMatchLimit}}function getText(Q,Z,$){let J=$-Z,q=Q.textCallback(Z,null,$);Z+=q.length;while(Z<$){let H=Q.textCallback(Z,null,$);if(H&&H.length>0)Z+=H.length,q+=H;else break}if(Z>$)q=q.slice(0,J);return q}function unmarshalCaptures(Q,Z,$,J){for(let q=0,H=J.length;q<H;q++){let U=getValue($,"i32");$+=SIZE_OF_INT;let Y=unmarshalNode(Z,$);$+=SIZE_OF_NODE,J[q]={name:Q.captureNames[U],node:Y}}return $}function assertInternal(Q){if(Q!==INTERNAL)throw Error("Illegal constructor")}function isPoint(Q){return Q&&typeof Q.row==="number"&&typeof Q.column==="number"}function marshalNode(Q){let Z=TRANSFER_BUFFER;setValue(Z,Q.id,"i32"),Z+=SIZE_OF_INT,setValue(Z,Q.startIndex,"i32"),Z+=SIZE_OF_INT,setValue(Z,Q.startPosition.row,"i32"),Z+=SIZE_OF_INT,setValue(Z,Q.startPosition.column,"i32"),Z+=SIZE_OF_INT,setValue(Z,Q[0],"i32")}function unmarshalNode(Q,Z=TRANSFER_BUFFER){let $=getValue(Z,"i32");if(Z+=SIZE_OF_INT,$===0)return null;let J=getValue(Z,"i32");Z+=SIZE_OF_INT;let q=getValue(Z,"i32");Z+=SIZE_OF_INT;let H=getValue(Z,"i32");Z+=SIZE_OF_INT;let U=getValue(Z,"i32"),Y=new Node(INTERNAL,Q);return Y.id=$,Y.startIndex=J,Y.startPosition={row:q,column:H},Y[0]=U,Y}function marshalTreeCursor(Q,Z=TRANSFER_BUFFER){setValue(Z+0*SIZE_OF_INT,Q[0],"i32"),setValue(Z+1*SIZE_OF_INT,Q[1],"i32"),setValue(Z+2*SIZE_OF_INT,Q[2],"i32"),setValue(Z+3*SIZE_OF_INT,Q[3],"i32")}function unmarshalTreeCursor(Q){Q[0]=getValue(TRANSFER_BUFFER+0*SIZE_OF_INT,"i32"),Q[1]=getValue(TRANSFER_BUFFER+1*SIZE_OF_INT,"i32"),Q[2]=getValue(TRANSFER_BUFFER+2*SIZE_OF_INT,"i32"),Q[3]=getValue(TRANSFER_BUFFER+3*SIZE_OF_INT,"i32")}function marshalPoint(Q,Z){setValue(Q,Z.row,"i32"),setValue(Q+SIZE_OF_INT,Z.column,"i32")}function unmarshalPoint(Q){return{row:getValue(Q,"i32")>>>0,column:getValue(Q+SIZE_OF_INT,"i32")>>>0}}function marshalRange(Q,Z){marshalPoint(Q,Z.startPosition),Q+=SIZE_OF_POINT,marshalPoint(Q,Z.endPosition),Q+=SIZE_OF_POINT,setValue(Q,Z.startIndex,"i32"),Q+=SIZE_OF_INT,setValue(Q,Z.endIndex,"i32"),Q+=SIZE_OF_INT}function unmarshalRange(Q){let Z={};return Z.startPosition=unmarshalPoint(Q),Q+=SIZE_OF_POINT,Z.endPosition=unmarshalPoint(Q),Q+=SIZE_OF_POINT,Z.startIndex=getValue(Q,"i32")>>>0,Q+=SIZE_OF_INT,Z.endIndex=getValue(Q,"i32")>>>0,Z}function marshalEdit(Q){let Z=TRANSFER_BUFFER;marshalPoint(Z,Q.startPosition),Z+=SIZE_OF_POINT,marshalPoint(Z,Q.oldEndPosition),Z+=SIZE_OF_POINT,marshalPoint(Z,Q.newEndPosition),Z+=SIZE_OF_POINT,setValue(Z,Q.startIndex,"i32"),Z+=SIZE_OF_INT,setValue(Z,Q.oldEndIndex,"i32"),Z+=SIZE_OF_INT,setValue(Z,Q.newEndIndex,"i32"),Z+=SIZE_OF_INT}for(let Q of Object.getOwnPropertyNames(ParserImpl.prototype))Object.defineProperty(Parser.prototype,Q,{value:ParserImpl.prototype[Q],enumerable:!1,writable:!1});Parser.Language=Language,X.onRuntimeInitialized=()=>{ParserImpl.init(),resolveInitPromise()}})}}return Parser}();if(typeof m==="object")g.exports=m0});var d=g0(Y0(),1);import{delimiter as OQ,join as t0}from"path";import{existsSync as FQ,statSync as p0}from"fs";import{homedir as u0}from"os";import{delimiter as V0,dirname as c,join as u}from"path";import{fileURLToPath as a}from"url";var s={"web-tree-sitter":"0.24.7","tree-sitter-wasms":"0.1.13"};var l0=s["tree-sitter-wasms"];function i0(Q){return`https://cdn.jsdelivr.net/npm/tree-sitter-wasms@${l0}/out/tree-sitter-${Q}.wasm`}function p(Q,Z,$,J){return{name:Q,file:`tree-sitter-${Q}.wasm`,url:i0(Q),sha256:Z,bytes:$,langs:J}}var K0={typescript:p("typescript","8515404dceed38e1ed86aa34b09fcf3379fff1b4ff9dd3967bcd6d1eb5ac3d8f",2342690,["ts"]),tsx:p("tsx","6aa3b2c70e76f5d48eafef1093e9c4de383e13f2fdde2f4e9b98a378f6a8f1b6",2411272,["tsx"]),javascript:p("javascript","63812b9e275d26851264734868d27a1656bd44a2ef6eb3e85e6b03728c595ab5",647334,["js","jsx"]),python:p("python","9056d0fb0c337810d019fae350e8167786119da98f0f282aceae7ab89ee8253b",476105,["py"])},n0=(()=>{let Q={};for(let Z of Object.values(K0))for(let $ of Z.langs)Q[$]=Z.name;return Q})();function e(Q){let Z=n0[Q];if(Z===void 0)throw Error(`no grammar for language "${Q}"`);return K0[Z]}function o0(Q=process.env){let Z=Q.MYC_GRAMMARS_DIR;if(Z!==void 0&&Z!=="")return Z;return u(u0(),".cache","myc","grammars")}function j0(Q){try{return u(c(a(import.meta.url)),"..","vendor",Q)}catch{return null}}function d0(){try{let Q=Bun.resolveSync("tree-sitter-wasms/package.json",c(a(import.meta.url)));return u(c(Q),"out")}catch{return null}}function Q0(Q=process.env){let Z=Q.MYC_TREE_SITTER_GRAMMAR_DIR;if(Z!==void 0&&Z!=="")return Z.split(V0).filter((H)=>H.length>0);let $=[o0(Q)],J=j0("tree-sitter-grammars");if(J!==null)$.push(J);let q=d0();if(q!==null)$.push(q);return $}function Z0(Q=process.env){let Z=Q.MYC_TREE_SITTER_DIR;if(Z!==void 0&&Z!=="")return Z.split(V0).filter((q)=>q.length>0);let $=[],J=j0("tree-sitter");if(J!==null)$.push(J);try{let q=Bun.resolveSync("web-tree-sitter/package.json",c(a(import.meta.url)));$.push(c(q))}catch{}return $}var l="tree-sitter.wasm";function W0(Q,Z,$){for(let J of Q){let q=u(J,Z);try{let H=p0(q);if(!H.isFile())continue;if($!==void 0&&H.size!==$)continue;return q}catch{continue}}return null}function z0(Q,Z=process.env){let $=e(Q);return W0(Q0(Z),$.file,$.bytes)}function C0(Q=process.env){return W0(Z0(Q),l)}function G0(Q){if(Q<1024)return`${Q} B`;let Z=["KB","MB","GB"],$=Q/1024,J=0;while($>=1024&&J<Z.length-1)$/=1024,J++;return`${$.toFixed(1)} ${Z[J]}`}class F0 extends Error{lang;constructor(Q){super(`tree-sitter grammar for "${Q}" is not loaded: call await loadLang("${Q}") before listDefs`);this.lang=Q;this.name="GrammarNotLoadedError"}}var n={function_declaration:"function",generator_function_declaration:"function",class_declaration:"class",abstract_class_declaration:"class",interface_declaration:"interface",enum_declaration:"enum",type_alias_declaration:"type",method_definition:"method"},r0={function_definition:"function",class_definition:"class"},s0=new Set(["arrow_function","function_expression","function","generator_function"]),w0={ts:{kinds:n,declarators:!0,methodByParent:[]},tsx:{kinds:n,declarators:!0,methodByParent:[]},js:{kinds:n,declarators:!0,methodByParent:[]},jsx:{kinds:n,declarators:!0,methodByParent:[]},py:{kinds:r0,declarators:!1,methodByParent:["block"]}},_Q=Object.keys(w0),o=null,$0=new Map,k0=new Map;class X0 extends Error{hint;constructor(Q,Z){super(Q);this.hint=Z;this.name="MissingResourceError"}}class R0 extends X0{searched;constructor(Q){super(`tree-sitter runtime not found: ${l} is in none of the directories [${Q.join(", ")}]. It ships with myc, so its absence means a broken install: reinstall the package or set MYC_TREE_SITTER_DIR to the directory that has the file`,"bun add -g @aistastudio/myc");this.searched=Q;this.name="RuntimeMissingError"}}class B0 extends X0{lang;searched;constructor(Q,Z){let $=e(Q);super(`tree-sitter grammar for "${Q}" is not downloaded: ${$.file} (${G0($.bytes)}) is in none of the directories [${Z.join(", ")}]`,`myc code fetch ${Q}`);this.lang=Q;this.searched=Z;this.name="GrammarMissingError"}}function a0(){let Q=C0();if(Q===null)throw new R0(Z0());return Q.slice(0,Q.length-l.length-1)}function e0(Q){let Z=z0(Q);if(Z===null)throw new B0(Q,Q0());return Z}async function QQ(){if(o===null){let Q=a0();o=d.default.init({locateFile:(Z)=>t0(Q,Z)}).catch((Z)=>{throw o=null,Z})}return o}async function T0(Q){let Z=$0.get(Q);if(Z===void 0)Z=(async()=>{await QQ();let $=await d.default.Language.load(e0(Q)),J=new d.default;return J.setLanguage($),J})().catch(($)=>{throw $0.delete(Q),$}),$0.set(Q,Z);k0.set(Q,await Z)}function ZQ(Q){let Z=k0.get(Q);if(Z===void 0)throw new F0(Q);return Z}function $Q(Q){let Z=Q.childForFieldName("name");if(Z===null)return null;let $=Z.text;return $.length>0?$:null}function XQ(Q){let Z=Q.childForFieldName("value");return Z!==null&&s0.has(Z.type)}function JQ(Q,Z){if(Z.length===0)return!1;let $=Q.parent;while($!==null&&$.type==="decorated_definition")$=$.parent;if($===null||!Z.includes($.type))return!1;let J=$.parent;return J!==null&&J.type.endsWith("class_definition")}function D0(Q,Z){let $=w0[Z],J=$.kinds[Q.type];if(J!==void 0)return JQ(Q,$.methodByParent)?"method":J;if($.declarators&&Q.type==="variable_declarator"&&XQ(Q))return"function";return null}function O0(Q){return $Q(Q)}function L0(Q,Z,$,J={}){let q=$.startPosition.row+1;return{name:Q,kind:Z,startLine:q,endLine:J.naiveEnd===!0?q:$.endPosition.row+1}}function _0(Q){return ZQ(Q)}var qQ=new Set(["identifier","type_identifier","property_identifier","shorthand_property_identifier"]),HQ=new Set(["formal_parameters","required_parameter","optional_parameter","rest_pattern","object_pattern","array_pattern","pair_pattern","object_assignment_pattern","import_clause","namespace_import","parameters","lambda_parameters","default_parameter","typed_parameter","typed_default_parameter","as_pattern_target"]),UQ=new Set(["import_specifier","export_specifier","aliased_import"]),YQ=new Set(["jsx_opening_element","jsx_self_closing_element","jsx_closing_element"]),E0=new Set(["call_expression","call"]),VQ=new Set(["member_expression","attribute"]);function v(Q,Z,$){let J=Q.childForFieldName(Z);return J!==null&&J.id===$.id}function KQ(Q){let Z=Q.parent,$=Z===null?null:Z.parent;return $!==null&&$.childForFieldName("source")!==null}function jQ(Q){let Z=Q.parent;if(Z===null)return null;if(E0.has(Z.type)&&v(Z,"function",Q))return"call";if(Z.type==="new_expression"&&v(Z,"constructor",Q))return"new";return null}function WQ(Q){let Z=Q.parent;if(Z===null)return null;let $=Z.type;if(UQ.has($)){if(!v(Z,"name",Q))return null;return $==="export_specifier"&&!KQ(Z)?"read":"import"}if(YQ.has($))return v(Z,"name",Q)?"read":null;if($==="jsx_attribute")return null;if(HQ.has($))return null;if(v(Z,"name",Q))return null;if($==="pair"&&v(Z,"key",Q))return null;if($==="keyword_argument"&&v(Z,"name",Q))return null;if($==="catch_clause"&&v(Z,"parameter",Q))return null;if(E0.has($)&&v(Z,"function",Q))return"call";if($==="new_expression"&&v(Z,"constructor",Q))return"new";if(VQ.has($)){if(v(Z,"property",Q)||v(Z,"attribute",Q))return jQ(Z)??"prop";return"read"}if($==="dotted_name")return"import";if(Q.type==="type_identifier")return"type";if($==="extends_clause"||$==="implements_clause")return"type";if(Q.type==="property_identifier")return"prop";return"read"}function A0(Q,Z,$={}){let q=_0(Z).parse(Q);try{let H=[],U=[],Y=new Set,j=[],W=$.naiveOwner===!0,k=(F)=>{let z=!1,G=D0(F,Z);if(G!==null){let K=O0(F);if(K!==null)H.push(L0(K,G,F,$)),j.push({name:K,start:F.startPosition.row+1}),z=!0}if(qQ.has(F.type)){let K=WQ(F);if(K!==null){let w=F.text;if(w.length>0){let D=W||j.length===0?null:j[j.length-1],V=F.startPosition.row+1,R=D===null?"":D.name,T=D===null?0:D.start,S=`${w}\x00${V}\x00${K}\x00${T}`;if(!Y.has(S))Y.add(S),U.push({name:w,line:V,kind:K,from:R,fromStart:T})}}}for(let K=0;K<F.namedChildCount;K++){let w=F.namedChild(K);if(w!==null)k(w)}if(z)j.pop()};return k(q.rootNode),{defs:H,refs:U}}finally{q.delete()}}var P0=process.env.MYC_TREE_SITTER_DIR,S0=process.env.MYC_TREE_SITTER_GRAMMAR_DIR;if(P0===void 0||P0===""||S0===void 0||S0==="")throw Error("parse worker started without tree-sitter directories: MYC_TREE_SITTER_DIR and MYC_TREE_SITTER_GRAMMAR_DIR are set by the main thread (ParsePool). There is nothing "+"to look them up with here \u2014 node_modules does not exist across the thread boundary");var J0=globalThis;J0.onmessage=(Q)=>{let{id:Z,source:$,lang:J}=Q.data;(async()=>{try{await T0(J);let{defs:q,refs:H}=A0($,J);J0.postMessage({id:Z,defs:q,refs:H})}catch(q){J0.postMessage({id:Z,error:q instanceof Error?q.message:String(q)})}})()};