@hyperfixi/mcp-server 2.7.1 → 2.8.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 +71 -16
- package/dist/{esm-YPGJSQ36.js → esm-65HZKQ6R.js} +221 -226
- package/dist/index.js +135 -11
- package/package.json +38 -38
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @hyperfixi/mcp-server
|
|
2
2
|
|
|
3
|
-
MCP (Model Context Protocol) server for hyperscript and multilingual DSL development. Provides **
|
|
3
|
+
MCP (Model Context Protocol) server for hyperscript and multilingual DSL development. Provides **107 tools**, **9 resources**, and **9 prompts** spanning: GRAIL workflow orchestration, validation, compilation, analysis, patterns, LSP bridge, language profiles, code generation, route extraction, 9 domain DSLs, IR conversion, cross-domain dispatch, MCP sampling, AI-assisted debugging, template inventory, and the LSE round-trip pipeline.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -59,7 +59,9 @@ Or if installed globally:
|
|
|
59
59
|
|
|
60
60
|
See **[GRAIL.md](GRAIL.md)** for full documentation, schema reference, and examples.
|
|
61
61
|
|
|
62
|
-
## Available Tools
|
|
62
|
+
## Available Tools
|
|
63
|
+
|
|
64
|
+
The **102** tools below, plus the **5** GRAIL tools above, total **107**.
|
|
63
65
|
|
|
64
66
|
### Validation & Semantic Tools (8)
|
|
65
67
|
|
|
@@ -131,12 +133,15 @@ See **[GRAIL.md](GRAIL.md)** for full documentation, schema reference, and examp
|
|
|
131
133
|
| `get_role_markers` | Role markers (destination, source, patient, etc.) |
|
|
132
134
|
| `compare_language_profiles` | Find translation gaps between languages |
|
|
133
135
|
|
|
134
|
-
### IR Conversion (
|
|
136
|
+
### IR Conversion (5)
|
|
135
137
|
|
|
136
138
|
| Tool | Description |
|
|
137
139
|
| ------------------- | ---------------------------------------------------- |
|
|
138
140
|
| `convert_format` | Convert between explicit bracket syntax and LLM JSON |
|
|
139
141
|
| `validate_explicit` | Validate bracket syntax without compilation (fast) |
|
|
142
|
+
| `validate_protocol` | Validate protocol JSON against the LSE 2.0 schema |
|
|
143
|
+
| `to_envelope` | Wrap a node/protocol in a transport envelope |
|
|
144
|
+
| `from_envelope` | Unwrap an envelope back to a node/protocol |
|
|
140
145
|
|
|
141
146
|
### Route Extraction (2)
|
|
142
147
|
|
|
@@ -164,20 +169,70 @@ See **[GRAIL.md](GRAIL.md)** for full documentation, schema reference, and examp
|
|
|
164
169
|
| `translate_content` | Translate text between natural languages |
|
|
165
170
|
| `execute_llm` | Execute LLM command in natural language (8 languages) |
|
|
166
171
|
|
|
167
|
-
###
|
|
172
|
+
### AI-Assisted Debugging (4)
|
|
173
|
+
|
|
174
|
+
| Tool | Description |
|
|
175
|
+
| ------------------------ | --------------------------------------------------------------------- |
|
|
176
|
+
| `debug_analyze_snapshot` | Explain the current paused debugger state and predict the next step |
|
|
177
|
+
| `debug_explain_handler` | Break down an event handler step-by-step; flag issues and breakpoints |
|
|
178
|
+
| `debug_suggest_fix` | Analyze a snapshot where something went wrong; suggest causes + fixes |
|
|
179
|
+
| `debug_trace_variable` | Trace how a variable changed across an execution-history snapshot set |
|
|
180
|
+
|
|
181
|
+
### Template Inventory (2)
|
|
182
|
+
|
|
183
|
+
| Tool | Description |
|
|
184
|
+
| ----------------- | --------------------------------------------------------------------- |
|
|
185
|
+
| `scan_inventory` | Scan a directory for hyperscript (`_=`), htmx (`hx-*`), fixi (`fx-*`) |
|
|
186
|
+
| `query_inventory` | Search and filter within previously scanned inventory results |
|
|
187
|
+
|
|
188
|
+
### Training Data (1)
|
|
189
|
+
|
|
190
|
+
| Tool | Description |
|
|
191
|
+
| ------------------------ | -------------------------------------------------------------- |
|
|
192
|
+
| `generate_training_data` | Synthesize (natural language, LSE) pairs from schemas as JSONL |
|
|
193
|
+
|
|
194
|
+
### Feedback Loop (2)
|
|
195
|
+
|
|
196
|
+
| Tool | Description |
|
|
197
|
+
| --------------------------- | ----------------------------------------------------------------- |
|
|
198
|
+
| `lse_validate_and_feedback` | Validate LSE and return machine-actionable correction hints |
|
|
199
|
+
| `lse_pattern_stats` | Pattern hit-rate stats: success by command/language, top failures |
|
|
200
|
+
|
|
201
|
+
### LSE Pipeline (5)
|
|
202
|
+
|
|
203
|
+
| Tool | Description |
|
|
204
|
+
| ---------------------- | --------------------------------------------------------------- |
|
|
205
|
+
| `lse_from_hyperscript` | Parse hyperscript (24 languages) to LSE bracket + protocol JSON |
|
|
206
|
+
| `lse_to_hyperscript` | Validate/compile LSE or protocol JSON returned by an LLM |
|
|
207
|
+
| `execute_lse` | Parse LSE, compile to JS, and return the execution result |
|
|
208
|
+
| `validate_lse` | Validate LSE or protocol JSON without executing (pre-flight) |
|
|
209
|
+
| `translate_lse` | Translate LSE bracket syntax to natural language (24 languages) |
|
|
210
|
+
|
|
211
|
+
### LSE Correction (1)
|
|
212
|
+
|
|
213
|
+
| Tool | Description |
|
|
214
|
+
| ------------------------------ | --------------------------------------------------------------- |
|
|
215
|
+
| `lse_generate_with_correction` | Stateless LSE generation + self-correction loop (prompt/schema) |
|
|
216
|
+
|
|
217
|
+
### Domain DSL Tools (36)
|
|
218
|
+
|
|
219
|
+
Each of the 9 domains exposes `parse_`, `compile_`, `validate_`, and `translate_` tools (9 × 4 = 36). Language coverage comes in three tiers:
|
|
168
220
|
|
|
169
|
-
|
|
221
|
+
- **Bridge (11):** en, es, ja, ar, ko, zh, tr, fr, de, pt, ru
|
|
222
|
+
- **Classic (8):** en, es, ja, ar, ko, zh, tr, fr
|
|
223
|
+
- **Learn (10):** Bridge minus ru
|
|
170
224
|
|
|
171
|
-
| Domain | Languages
|
|
172
|
-
| -------------- |
|
|
173
|
-
| `sql` |
|
|
174
|
-
| `bdd` |
|
|
175
|
-
| `jsx` |
|
|
176
|
-
| `todo` |
|
|
177
|
-
| `behaviorspec` |
|
|
178
|
-
| `llm` |
|
|
179
|
-
| `flow` |
|
|
180
|
-
| `voice` |
|
|
225
|
+
| Domain | Languages | compile Output |
|
|
226
|
+
| -------------- | ----------- | --------------------------------- |
|
|
227
|
+
| `sql` | Bridge (11) | SQL query string |
|
|
228
|
+
| `bdd` | Classic (8) | Playwright test (Given/When/Then) |
|
|
229
|
+
| `jsx` | Bridge (11) | JSX/React markup |
|
|
230
|
+
| `todo` | Bridge (11) | Structured operation object |
|
|
231
|
+
| `behaviorspec` | Classic (8) | Playwright interaction test |
|
|
232
|
+
| `llm` | Bridge (11) | LLMPromptSpec JSON |
|
|
233
|
+
| `flow` | Bridge (11) | Reactive data flow JS |
|
|
234
|
+
| `voice` | Bridge (11) | DOM interaction command |
|
|
235
|
+
| `learn` | Learn (10) | Rendered sentence w/ morphology |
|
|
181
236
|
|
|
182
237
|
## Available Resources (5)
|
|
183
238
|
|
|
@@ -209,7 +264,7 @@ See **[GRAIL.md](GRAIL.md)** for full documentation, schema reference, and examp
|
|
|
209
264
|
|
|
210
265
|
```bash
|
|
211
266
|
npm run dev # Development mode
|
|
212
|
-
npm test # Run tests (
|
|
267
|
+
npm test # Run tests (420 tests)
|
|
213
268
|
npm run typecheck # TypeScript validation
|
|
214
269
|
npm run build # Build
|
|
215
270
|
```
|
|
@@ -129,8 +129,8 @@ function expand_(str, max, isTop) {
|
|
|
129
129
|
const pre = m.pre;
|
|
130
130
|
if (/\$$/.test(m.pre)) {
|
|
131
131
|
const post2 = m.post.length ? expand_(m.post, max, false) : [""];
|
|
132
|
-
for (let
|
|
133
|
-
const expansion = pre + "{" + m.body + "}" + post2[
|
|
132
|
+
for (let k = 0; k < post2.length && k < max; k++) {
|
|
133
|
+
const expansion = pre + "{" + m.body + "}" + post2[k];
|
|
134
134
|
expansions.push(expansion);
|
|
135
135
|
}
|
|
136
136
|
return expansions;
|
|
@@ -162,19 +162,19 @@ function expand_(str, max, isTop) {
|
|
|
162
162
|
}
|
|
163
163
|
let N;
|
|
164
164
|
if (isSequence && n[0] !== void 0 && n[1] !== void 0) {
|
|
165
|
-
const
|
|
165
|
+
const x = numeric(n[0]);
|
|
166
166
|
const y = numeric(n[1]);
|
|
167
167
|
const width = Math.max(n[0].length, n[1].length);
|
|
168
168
|
let incr = n.length === 3 && n[2] !== void 0 ? Math.max(Math.abs(numeric(n[2])), 1) : 1;
|
|
169
169
|
let test = lte;
|
|
170
|
-
const reverse = y <
|
|
170
|
+
const reverse = y < x;
|
|
171
171
|
if (reverse) {
|
|
172
172
|
incr *= -1;
|
|
173
173
|
test = gte;
|
|
174
174
|
}
|
|
175
175
|
const pad = n.some(isPadded);
|
|
176
176
|
N = [];
|
|
177
|
-
for (let i =
|
|
177
|
+
for (let i = x; test(i, y) && N.length < max; i += incr) {
|
|
178
178
|
let c;
|
|
179
179
|
if (isAlphaSequence) {
|
|
180
180
|
c = String.fromCharCode(i);
|
|
@@ -204,8 +204,8 @@ function expand_(str, max, isTop) {
|
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
206
|
for (let j2 = 0; j2 < N.length; j2++) {
|
|
207
|
-
for (let
|
|
208
|
-
const expansion = pre + N[j2] + post[
|
|
207
|
+
for (let k = 0; k < post.length && expansions.length < max; k++) {
|
|
208
|
+
const expansion = pre + N[j2] + post[k];
|
|
209
209
|
if (!isTop || isSequence || expansion) {
|
|
210
210
|
expansions.push(expansion);
|
|
211
211
|
}
|
|
@@ -280,7 +280,7 @@ var parseClass = (glob2, position) => {
|
|
|
280
280
|
}
|
|
281
281
|
}
|
|
282
282
|
if (c === "[" && !escaping) {
|
|
283
|
-
for (const [cls, [unip,
|
|
283
|
+
for (const [cls, [unip, u3, neg]] of Object.entries(posixClasses)) {
|
|
284
284
|
if (glob2.startsWith(cls, i)) {
|
|
285
285
|
if (rangeStart) {
|
|
286
286
|
return ["$.", false, glob2.length - pos, true];
|
|
@@ -290,7 +290,7 @@ var parseClass = (glob2, position) => {
|
|
|
290
290
|
negs.push(unip);
|
|
291
291
|
else
|
|
292
292
|
ranges.push(unip);
|
|
293
|
-
uflag = uflag ||
|
|
293
|
+
uflag = uflag || u3;
|
|
294
294
|
continue WHILE;
|
|
295
295
|
}
|
|
296
296
|
}
|
|
@@ -1808,37 +1808,38 @@ minimatch.unescape = unescape;
|
|
|
1808
1808
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
1809
1809
|
|
|
1810
1810
|
// ../../node_modules/lru-cache/dist/esm/node/index.min.js
|
|
1811
|
-
import { tracingChannel as
|
|
1812
|
-
var S =
|
|
1813
|
-
var W =
|
|
1814
|
-
var
|
|
1815
|
-
var
|
|
1811
|
+
import { tracingChannel as I, channel as G } from "diagnostics_channel";
|
|
1812
|
+
var S = G("lru-cache:metrics");
|
|
1813
|
+
var W = I("lru-cache");
|
|
1814
|
+
var C = typeof performance == "object" && performance && typeof performance.now == "function" ? performance : Date;
|
|
1815
|
+
var D = () => S.hasSubscribers || W.hasSubscribers;
|
|
1816
1816
|
var U = /* @__PURE__ */ new Set();
|
|
1817
|
-
var
|
|
1818
|
-
var
|
|
1819
|
-
typeof
|
|
1817
|
+
var L = typeof process == "object" && process ? process : {};
|
|
1818
|
+
var P = (u3, e, t, i) => {
|
|
1819
|
+
typeof L.emitWarning == "function" ? L.emitWarning(u3, e, t, i) : console.error(`[${t}] ${e}: ${u3}`);
|
|
1820
1820
|
};
|
|
1821
|
-
var H = (
|
|
1822
|
-
var
|
|
1823
|
-
var
|
|
1821
|
+
var H = (u3) => !U.has(u3);
|
|
1822
|
+
var X = Symbol("type");
|
|
1823
|
+
var F = (u3) => !!u3 && u3 === Math.floor(u3) && u3 > 0 && isFinite(u3);
|
|
1824
|
+
var j = (u3) => F(u3) ? u3 <= Math.pow(2, 8) ? Uint8Array : u3 <= Math.pow(2, 16) ? Uint16Array : u3 <= Math.pow(2, 32) ? Uint32Array : u3 <= Number.MAX_SAFE_INTEGER ? O : null : null;
|
|
1824
1825
|
var O = class extends Array {
|
|
1825
1826
|
constructor(e) {
|
|
1826
1827
|
super(e), this.fill(0);
|
|
1827
1828
|
}
|
|
1828
1829
|
};
|
|
1829
|
-
var
|
|
1830
|
+
var R = class u {
|
|
1830
1831
|
heap;
|
|
1831
1832
|
length;
|
|
1832
1833
|
static #o = false;
|
|
1833
1834
|
static create(e) {
|
|
1834
1835
|
let t = j(e);
|
|
1835
1836
|
if (!t) return [];
|
|
1836
|
-
|
|
1837
|
-
let i = new
|
|
1838
|
-
return
|
|
1837
|
+
u.#o = true;
|
|
1838
|
+
let i = new u(e, t);
|
|
1839
|
+
return u.#o = false, i;
|
|
1839
1840
|
}
|
|
1840
1841
|
constructor(e, t) {
|
|
1841
|
-
if (!
|
|
1842
|
+
if (!u.#o) throw new TypeError("instantiate Stack using Stack.create(n)");
|
|
1842
1843
|
this.heap = new t(e), this.length = 0;
|
|
1843
1844
|
}
|
|
1844
1845
|
push(e) {
|
|
@@ -1848,14 +1849,14 @@ var x = class d {
|
|
|
1848
1849
|
return this.heap[--this.length];
|
|
1849
1850
|
}
|
|
1850
1851
|
};
|
|
1851
|
-
var
|
|
1852
|
+
var M = class u2 {
|
|
1852
1853
|
#o;
|
|
1853
|
-
#
|
|
1854
|
-
#S;
|
|
1855
|
-
#O;
|
|
1854
|
+
#u;
|
|
1856
1855
|
#w;
|
|
1856
|
+
#x;
|
|
1857
|
+
#S;
|
|
1857
1858
|
#M;
|
|
1858
|
-
#
|
|
1859
|
+
#U;
|
|
1859
1860
|
#m;
|
|
1860
1861
|
get perf() {
|
|
1861
1862
|
return this.#m;
|
|
@@ -1875,15 +1876,14 @@ var I = class d2 {
|
|
|
1875
1876
|
allowStaleOnFetchAbort;
|
|
1876
1877
|
allowStaleOnFetchRejection;
|
|
1877
1878
|
ignoreFetchAbort;
|
|
1878
|
-
backgroundFetchSize;
|
|
1879
1879
|
#n;
|
|
1880
1880
|
#b;
|
|
1881
1881
|
#s;
|
|
1882
1882
|
#i;
|
|
1883
1883
|
#t;
|
|
1884
|
-
#l;
|
|
1885
|
-
#u;
|
|
1886
1884
|
#a;
|
|
1885
|
+
#c;
|
|
1886
|
+
#l;
|
|
1887
1887
|
#h;
|
|
1888
1888
|
#y;
|
|
1889
1889
|
#r;
|
|
@@ -1892,12 +1892,12 @@ var I = class d2 {
|
|
|
1892
1892
|
#d;
|
|
1893
1893
|
#g;
|
|
1894
1894
|
#T;
|
|
1895
|
-
#
|
|
1895
|
+
#W;
|
|
1896
1896
|
#f;
|
|
1897
|
-
#
|
|
1897
|
+
#j;
|
|
1898
1898
|
static unsafeExposeInternals(e) {
|
|
1899
|
-
return { starts: e.#F, ttls: e.#d, autopurgeTimers: e.#g, sizes: e.#_, keyMap: e.#s, keyList: e.#i, valList: e.#t, next: e.#
|
|
1900
|
-
return e.#
|
|
1899
|
+
return { starts: e.#F, ttls: e.#d, autopurgeTimers: e.#g, sizes: e.#_, keyMap: e.#s, keyList: e.#i, valList: e.#t, next: e.#a, prev: e.#c, get head() {
|
|
1900
|
+
return e.#l;
|
|
1901
1901
|
}, get tail() {
|
|
1902
1902
|
return e.#h;
|
|
1903
1903
|
}, free: e.#y, isBackgroundFetch: (t) => e.#e(t), backgroundFetch: (t, i, s, n) => e.#P(t, i, s, n), moveToTail: (t) => e.#L(t), indexes: (t) => e.#A(t), rindexes: (t) => e.#z(t), isStale: (t) => e.#p(t) };
|
|
@@ -1906,7 +1906,7 @@ var I = class d2 {
|
|
|
1906
1906
|
return this.#o;
|
|
1907
1907
|
}
|
|
1908
1908
|
get maxSize() {
|
|
1909
|
-
return this.#
|
|
1909
|
+
return this.#u;
|
|
1910
1910
|
}
|
|
1911
1911
|
get calculatedSize() {
|
|
1912
1912
|
return this.#b;
|
|
@@ -1918,139 +1918,134 @@ var I = class d2 {
|
|
|
1918
1918
|
return this.#M;
|
|
1919
1919
|
}
|
|
1920
1920
|
get memoMethod() {
|
|
1921
|
-
return this.#
|
|
1921
|
+
return this.#U;
|
|
1922
1922
|
}
|
|
1923
1923
|
get dispose() {
|
|
1924
|
-
return this.#
|
|
1924
|
+
return this.#w;
|
|
1925
1925
|
}
|
|
1926
1926
|
get onInsert() {
|
|
1927
|
-
return this.#
|
|
1927
|
+
return this.#x;
|
|
1928
1928
|
}
|
|
1929
1929
|
get disposeAfter() {
|
|
1930
|
-
return this.#
|
|
1930
|
+
return this.#S;
|
|
1931
1931
|
}
|
|
1932
1932
|
constructor(e) {
|
|
1933
|
-
let { max: t = 0, ttl: i, ttlResolution: s = 1, ttlAutopurge: n, updateAgeOnGet: o, updateAgeOnHas:
|
|
1934
|
-
if (
|
|
1935
|
-
if (this.#m =
|
|
1933
|
+
let { max: t = 0, ttl: i, ttlResolution: s = 1, ttlAutopurge: n, updateAgeOnGet: o, updateAgeOnHas: r, allowStale: h, dispose: l, onInsert: c, disposeAfter: f, noDisposeOnSet: g, noUpdateTTL: p, maxSize: T = 0, maxEntrySize: w = 0, sizeCalculation: y, fetchMethod: a, memoMethod: m, noDeleteOnFetchRejection: _, noDeleteOnStaleGet: b, allowStaleOnFetchRejection: d, allowStaleOnFetchAbort: A, ignoreFetchAbort: z, perf: x } = e;
|
|
1934
|
+
if (x !== void 0 && typeof x?.now != "function") throw new TypeError("perf option must have a now() method if specified");
|
|
1935
|
+
if (this.#m = x ?? C, t !== 0 && !F(t)) throw new TypeError("max option must be a nonnegative integer");
|
|
1936
1936
|
let v = t ? j(t) : Array;
|
|
1937
1937
|
if (!v) throw new Error("invalid max value: " + t);
|
|
1938
|
-
if (this.#o = t, this.#
|
|
1939
|
-
if (!this.#
|
|
1938
|
+
if (this.#o = t, this.#u = T, this.maxEntrySize = w || this.#u, this.sizeCalculation = y, this.sizeCalculation) {
|
|
1939
|
+
if (!this.#u && !this.maxEntrySize) throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");
|
|
1940
1940
|
if (typeof this.sizeCalculation != "function") throw new TypeError("sizeCalculation set to non-function");
|
|
1941
1941
|
}
|
|
1942
|
-
if (
|
|
1943
|
-
if (this.#
|
|
1944
|
-
if (this.#M = a, this.#
|
|
1945
|
-
if (this.#
|
|
1946
|
-
if (!
|
|
1942
|
+
if (m !== void 0 && typeof m != "function") throw new TypeError("memoMethod must be a function if defined");
|
|
1943
|
+
if (this.#U = m, a !== void 0 && typeof a != "function") throw new TypeError("fetchMethod must be a function if specified");
|
|
1944
|
+
if (this.#M = a, this.#W = !!a, this.#s = /* @__PURE__ */ new Map(), this.#i = Array.from({ length: t }).fill(void 0), this.#t = Array.from({ length: t }).fill(void 0), this.#a = new v(t), this.#c = new v(t), this.#l = 0, this.#h = 0, this.#y = R.create(t), this.#n = 0, this.#b = 0, typeof l == "function" && (this.#w = l), typeof c == "function" && (this.#x = c), typeof f == "function" ? (this.#S = f, this.#r = []) : (this.#S = void 0, this.#r = void 0), this.#T = !!this.#w, this.#j = !!this.#x, this.#f = !!this.#S, this.noDisposeOnSet = !!g, this.noUpdateTTL = !!p, this.noDeleteOnFetchRejection = !!_, this.allowStaleOnFetchRejection = !!d, this.allowStaleOnFetchAbort = !!A, this.ignoreFetchAbort = !!z, this.maxEntrySize !== 0) {
|
|
1945
|
+
if (this.#u !== 0 && !F(this.#u)) throw new TypeError("maxSize must be a positive integer if specified");
|
|
1946
|
+
if (!F(this.maxEntrySize)) throw new TypeError("maxEntrySize must be a positive integer if specified");
|
|
1947
1947
|
this.#X();
|
|
1948
1948
|
}
|
|
1949
|
-
if (this.allowStale = !!h, this.noDeleteOnStaleGet = !!b, this.updateAgeOnGet = !!o, this.updateAgeOnHas = !!
|
|
1950
|
-
if (!
|
|
1951
|
-
this.#
|
|
1949
|
+
if (this.allowStale = !!h, this.noDeleteOnStaleGet = !!b, this.updateAgeOnGet = !!o, this.updateAgeOnHas = !!r, this.ttlResolution = F(s) || s === 0 ? s : 1, this.ttlAutopurge = !!n, this.ttl = i || 0, this.ttl) {
|
|
1950
|
+
if (!F(this.ttl)) throw new TypeError("ttl must be a positive integer if specified");
|
|
1951
|
+
this.#H();
|
|
1952
1952
|
}
|
|
1953
|
-
if (this.#o === 0 && this.ttl === 0 && this.#
|
|
1954
|
-
if (!this.ttlAutopurge && !this.#o && !this.#
|
|
1955
|
-
let
|
|
1956
|
-
H(
|
|
1953
|
+
if (this.#o === 0 && this.ttl === 0 && this.#u === 0) throw new TypeError("At least one of max, maxSize, or ttl is required");
|
|
1954
|
+
if (!this.ttlAutopurge && !this.#o && !this.#u) {
|
|
1955
|
+
let E = "LRU_CACHE_UNBOUNDED";
|
|
1956
|
+
H(E) && (U.add(E), P("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.", "UnboundedCacheWarning", E, u2));
|
|
1957
1957
|
}
|
|
1958
1958
|
}
|
|
1959
1959
|
getRemainingTTL(e) {
|
|
1960
1960
|
return this.#s.has(e) ? 1 / 0 : 0;
|
|
1961
1961
|
}
|
|
1962
|
-
#
|
|
1962
|
+
#H() {
|
|
1963
1963
|
let e = new O(this.#o), t = new O(this.#o);
|
|
1964
1964
|
this.#d = e, this.#F = t;
|
|
1965
1965
|
let i = this.ttlAutopurge ? Array.from({ length: this.#o }) : void 0;
|
|
1966
|
-
this.#g = i, this.#
|
|
1967
|
-
t[
|
|
1968
|
-
}, this.#
|
|
1969
|
-
t[
|
|
1966
|
+
this.#g = i, this.#N = (r, h, l = this.#m.now()) => {
|
|
1967
|
+
t[r] = h !== 0 ? l : 0, e[r] = h, s(r, h);
|
|
1968
|
+
}, this.#D = (r) => {
|
|
1969
|
+
t[r] = e[r] !== 0 ? this.#m.now() : 0, s(r, e[r]);
|
|
1970
1970
|
};
|
|
1971
|
-
let s = this.ttlAutopurge ? (
|
|
1972
|
-
if (i?.[
|
|
1973
|
-
let
|
|
1974
|
-
this.#p(
|
|
1975
|
-
},
|
|
1976
|
-
|
|
1971
|
+
let s = this.ttlAutopurge ? (r, h) => {
|
|
1972
|
+
if (i?.[r] && (clearTimeout(i[r]), i[r] = void 0), h && h !== 0 && i) {
|
|
1973
|
+
let l = setTimeout(() => {
|
|
1974
|
+
this.#p(r) && this.#v(this.#i[r], "expire");
|
|
1975
|
+
}, h + 1);
|
|
1976
|
+
l.unref && l.unref(), i[r] = l;
|
|
1977
1977
|
}
|
|
1978
1978
|
} : () => {
|
|
1979
1979
|
};
|
|
1980
|
-
this.#
|
|
1981
|
-
if (e[
|
|
1982
|
-
let
|
|
1983
|
-
if (!
|
|
1984
|
-
|
|
1985
|
-
let
|
|
1986
|
-
|
|
1980
|
+
this.#E = (r, h) => {
|
|
1981
|
+
if (e[h]) {
|
|
1982
|
+
let l = e[h], c = t[h];
|
|
1983
|
+
if (!l || !c) return;
|
|
1984
|
+
r.ttl = l, r.start = c, r.now = n || o();
|
|
1985
|
+
let f = r.now - c;
|
|
1986
|
+
r.remainingTTL = l - f;
|
|
1987
1987
|
}
|
|
1988
1988
|
};
|
|
1989
1989
|
let n = 0, o = () => {
|
|
1990
|
-
let
|
|
1990
|
+
let r = this.#m.now();
|
|
1991
1991
|
if (this.ttlResolution > 0) {
|
|
1992
|
-
n =
|
|
1993
|
-
let
|
|
1994
|
-
|
|
1992
|
+
n = r;
|
|
1993
|
+
let h = setTimeout(() => n = 0, this.ttlResolution);
|
|
1994
|
+
h.unref && h.unref();
|
|
1995
1995
|
}
|
|
1996
|
-
return
|
|
1996
|
+
return r;
|
|
1997
1997
|
};
|
|
1998
|
-
this.getRemainingTTL = (
|
|
1999
|
-
let
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
let
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
this.#p = (h) => {
|
|
2009
|
-
let r = t[h], c = e[h];
|
|
2010
|
-
return !!c && !!r && (n || o()) - r > c;
|
|
1998
|
+
this.getRemainingTTL = (r) => {
|
|
1999
|
+
let h = this.#s.get(r);
|
|
2000
|
+
if (h === void 0) return 0;
|
|
2001
|
+
let l = e[h], c = t[h];
|
|
2002
|
+
if (!l || !c) return 1 / 0;
|
|
2003
|
+
let f = (n || o()) - c;
|
|
2004
|
+
return l - f;
|
|
2005
|
+
}, this.#p = (r) => {
|
|
2006
|
+
let h = t[r], l = e[r];
|
|
2007
|
+
return !!l && !!h && (n || o()) - h > l;
|
|
2011
2008
|
};
|
|
2012
2009
|
}
|
|
2013
|
-
#
|
|
2010
|
+
#D = () => {
|
|
2014
2011
|
};
|
|
2015
|
-
#
|
|
2012
|
+
#E = () => {
|
|
2016
2013
|
};
|
|
2017
|
-
#
|
|
2014
|
+
#N = () => {
|
|
2018
2015
|
};
|
|
2019
2016
|
#p = () => false;
|
|
2020
2017
|
#X() {
|
|
2021
2018
|
let e = new O(this.#o);
|
|
2022
|
-
this.#b = 0, this.#_ = e, this.#
|
|
2019
|
+
this.#b = 0, this.#_ = e, this.#R = (t) => {
|
|
2023
2020
|
this.#b -= e[t], e[t] = 0;
|
|
2024
|
-
}, this.#
|
|
2025
|
-
if (
|
|
2026
|
-
|
|
2027
|
-
if (n)
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
} else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
|
|
2031
|
-
}
|
|
2021
|
+
}, this.#k = (t, i, s, n) => {
|
|
2022
|
+
if (this.#e(i)) return 0;
|
|
2023
|
+
if (!F(s)) if (n) {
|
|
2024
|
+
if (typeof n != "function") throw new TypeError("sizeCalculation must be a function");
|
|
2025
|
+
if (s = n(i, t), !F(s)) throw new TypeError("sizeCalculation return invalid (expect positive integer)");
|
|
2026
|
+
} else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
|
|
2032
2027
|
return s;
|
|
2033
|
-
}, this.#
|
|
2034
|
-
if (e[t] = i, this.#
|
|
2035
|
-
let n = this.#
|
|
2028
|
+
}, this.#I = (t, i, s) => {
|
|
2029
|
+
if (e[t] = i, this.#u) {
|
|
2030
|
+
let n = this.#u - e[t];
|
|
2036
2031
|
for (; this.#b > n; ) this.#G(true);
|
|
2037
2032
|
}
|
|
2038
2033
|
this.#b += e[t], s && (s.entrySize = i, s.totalCalculatedSize = this.#b);
|
|
2039
2034
|
};
|
|
2040
2035
|
}
|
|
2041
|
-
#
|
|
2036
|
+
#R = (e) => {
|
|
2042
2037
|
};
|
|
2043
|
-
#
|
|
2038
|
+
#I = (e, t, i) => {
|
|
2044
2039
|
};
|
|
2045
|
-
#
|
|
2040
|
+
#k = (e, t, i, s) => {
|
|
2046
2041
|
if (i || s) throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");
|
|
2047
2042
|
return 0;
|
|
2048
2043
|
};
|
|
2049
2044
|
*#A({ allowStale: e = this.allowStale } = {}) {
|
|
2050
|
-
if (this.#n) for (let t = this.#h; this.#V(t) && ((e || !this.#p(t)) && (yield t), t !== this.#
|
|
2045
|
+
if (this.#n) for (let t = this.#h; this.#V(t) && ((e || !this.#p(t)) && (yield t), t !== this.#l); ) t = this.#c[t];
|
|
2051
2046
|
}
|
|
2052
2047
|
*#z({ allowStale: e = this.allowStale } = {}) {
|
|
2053
|
-
if (this.#n) for (let t = this.#
|
|
2048
|
+
if (this.#n) for (let t = this.#l; this.#V(t) && ((e || !this.#p(t)) && (yield t), t !== this.#h); ) t = this.#a[t];
|
|
2054
2049
|
}
|
|
2055
2050
|
#V(e) {
|
|
2056
2051
|
return e !== void 0 && this.#s.get(this.#i[e]) === e;
|
|
@@ -2103,7 +2098,7 @@ var I = class d2 {
|
|
|
2103
2098
|
}
|
|
2104
2099
|
purgeStale() {
|
|
2105
2100
|
let e = false;
|
|
2106
|
-
for (let t of this.#z({ allowStale: true })) this.#p(t) && (this.#
|
|
2101
|
+
for (let t of this.#z({ allowStale: true })) this.#p(t) && (this.#v(this.#i[t], "expire"), e = true);
|
|
2107
2102
|
return e;
|
|
2108
2103
|
}
|
|
2109
2104
|
info(e) {
|
|
@@ -2113,9 +2108,9 @@ var I = class d2 {
|
|
|
2113
2108
|
if (s === void 0) return;
|
|
2114
2109
|
let n = { value: s };
|
|
2115
2110
|
if (this.#d && this.#F) {
|
|
2116
|
-
let o = this.#d[t],
|
|
2117
|
-
if (o &&
|
|
2118
|
-
let h = o - (this.#m.now() -
|
|
2111
|
+
let o = this.#d[t], r = this.#F[t];
|
|
2112
|
+
if (o && r) {
|
|
2113
|
+
let h = o - (this.#m.now() - r);
|
|
2119
2114
|
n.ttl = h, n.start = Date.now();
|
|
2120
2115
|
}
|
|
2121
2116
|
}
|
|
@@ -2129,8 +2124,8 @@ var I = class d2 {
|
|
|
2129
2124
|
let o = { value: n };
|
|
2130
2125
|
if (this.#d && this.#F) {
|
|
2131
2126
|
o.ttl = this.#d[t];
|
|
2132
|
-
let
|
|
2133
|
-
o.start = Math.floor(Date.now() -
|
|
2127
|
+
let r = this.#m.now() - this.#F[t];
|
|
2128
|
+
o.start = Math.floor(Date.now() - r);
|
|
2134
2129
|
}
|
|
2135
2130
|
this.#_ && (o.size = this.#_[t]), e.unshift([i, o]);
|
|
2136
2131
|
}
|
|
@@ -2143,49 +2138,51 @@ var I = class d2 {
|
|
|
2143
2138
|
let s = Date.now() - i.start;
|
|
2144
2139
|
i.start = this.#m.now() - s;
|
|
2145
2140
|
}
|
|
2146
|
-
this.#
|
|
2141
|
+
this.#O(t, i.value, i);
|
|
2147
2142
|
}
|
|
2148
2143
|
}
|
|
2149
2144
|
set(e, t, i = {}) {
|
|
2150
2145
|
let { status: s = S.hasSubscribers ? {} : void 0 } = i;
|
|
2151
|
-
i.status = s, s && (s.op = "set", s.key = e, t !== void 0 && (s.value = t)
|
|
2152
|
-
let n = this.#
|
|
2146
|
+
i.status = s, s && (s.op = "set", s.key = e, t !== void 0 && (s.value = t));
|
|
2147
|
+
let n = this.#O(e, t, i);
|
|
2153
2148
|
return s && S.hasSubscribers && S.publish(s), n;
|
|
2154
2149
|
}
|
|
2155
|
-
#
|
|
2156
|
-
let { ttl:
|
|
2157
|
-
if (t === void 0) return
|
|
2158
|
-
let { noUpdateTTL:
|
|
2159
|
-
|
|
2160
|
-
let
|
|
2161
|
-
if (this.maxEntrySize &&
|
|
2162
|
-
let
|
|
2163
|
-
if (
|
|
2150
|
+
#O(e, t, i = {}) {
|
|
2151
|
+
let { ttl: s = this.ttl, start: n, noDisposeOnSet: o = this.noDisposeOnSet, sizeCalculation: r = this.sizeCalculation, status: h } = i;
|
|
2152
|
+
if (t === void 0) return h && (h.set = "deleted"), this.delete(e), this;
|
|
2153
|
+
let { noUpdateTTL: l = this.noUpdateTTL } = i;
|
|
2154
|
+
h && !this.#e(t) && (h.value = t);
|
|
2155
|
+
let c = this.#k(e, t, i.size || 0, r, h);
|
|
2156
|
+
if (this.maxEntrySize && c > this.maxEntrySize) return this.#v(e, "set"), h && (h.set = "miss", h.maxEntrySizeExceeded = true), this;
|
|
2157
|
+
let f = this.#n === 0 ? void 0 : this.#s.get(e);
|
|
2158
|
+
if (f === void 0) f = this.#n === 0 ? this.#h : this.#y.length !== 0 ? this.#y.pop() : this.#n === this.#o ? this.#G(false) : this.#n, this.#i[f] = e, this.#t[f] = t, this.#s.set(e, f), this.#a[this.#h] = f, this.#c[f] = this.#h, this.#h = f, this.#n++, this.#I(f, c, h), h && (h.set = "add"), l = false, this.#j && this.#x?.(t, e, "add");
|
|
2164
2159
|
else {
|
|
2165
|
-
this.#L(
|
|
2166
|
-
let g = this.#t[
|
|
2160
|
+
this.#L(f);
|
|
2161
|
+
let g = this.#t[f];
|
|
2167
2162
|
if (t !== g) {
|
|
2168
|
-
if (
|
|
2169
|
-
g
|
|
2170
|
-
let { __staleWhileFetching:
|
|
2171
|
-
|
|
2172
|
-
} else this.#T && this.#
|
|
2173
|
-
if (this.#
|
|
2174
|
-
|
|
2175
|
-
|
|
2163
|
+
if (this.#W && this.#e(g)) {
|
|
2164
|
+
g.__abortController.abort(new Error("replaced"));
|
|
2165
|
+
let { __staleWhileFetching: p } = g;
|
|
2166
|
+
p !== void 0 && !o && (this.#T && this.#w?.(p, e, "set"), this.#f && this.#r?.push([p, e, "set"]));
|
|
2167
|
+
} else o || (this.#T && this.#w?.(g, e, "set"), this.#f && this.#r?.push([g, e, "set"]));
|
|
2168
|
+
if (this.#R(f), this.#I(f, c, h), this.#t[f] = t, h) {
|
|
2169
|
+
h.set = "replace";
|
|
2170
|
+
let p = g && this.#e(g) ? g.__staleWhileFetching : g;
|
|
2171
|
+
p !== void 0 && (h.oldValue = p);
|
|
2176
2172
|
}
|
|
2177
|
-
} else
|
|
2173
|
+
} else h && (h.set = "update");
|
|
2174
|
+
this.#j && this.onInsert?.(t, e, t === g ? "update" : "replace");
|
|
2178
2175
|
}
|
|
2179
|
-
if (
|
|
2180
|
-
let g = this.#r,
|
|
2181
|
-
for (;
|
|
2176
|
+
if (s !== 0 && !this.#d && this.#H(), this.#d && (l || this.#N(f, s, n), h && this.#E(h, f)), !o && this.#f && this.#r) {
|
|
2177
|
+
let g = this.#r, p;
|
|
2178
|
+
for (; p = g?.shift(); ) this.#S?.(...p);
|
|
2182
2179
|
}
|
|
2183
2180
|
return this;
|
|
2184
2181
|
}
|
|
2185
2182
|
pop() {
|
|
2186
2183
|
try {
|
|
2187
2184
|
for (; this.#n; ) {
|
|
2188
|
-
let e = this.#t[this.#
|
|
2185
|
+
let e = this.#t[this.#l];
|
|
2189
2186
|
if (this.#G(true), this.#e(e)) {
|
|
2190
2187
|
if (e.__staleWhileFetching) return e.__staleWhileFetching;
|
|
2191
2188
|
} else if (e !== void 0) return e;
|
|
@@ -2193,19 +2190,17 @@ var I = class d2 {
|
|
|
2193
2190
|
} finally {
|
|
2194
2191
|
if (this.#f && this.#r) {
|
|
2195
2192
|
let e = this.#r, t;
|
|
2196
|
-
for (; t = e?.shift(); ) this.#
|
|
2193
|
+
for (; t = e?.shift(); ) this.#S?.(...t);
|
|
2197
2194
|
}
|
|
2198
2195
|
}
|
|
2199
2196
|
}
|
|
2200
2197
|
#G(e) {
|
|
2201
|
-
let t = this.#
|
|
2202
|
-
|
|
2203
|
-
let o = n ? s.__staleWhileFetching : s;
|
|
2204
|
-
return (this.#T || this.#f) && o !== void 0 && (this.#T && this.#S?.(o, i, "evict"), this.#f && this.#r?.push([o, i, "evict"])), this.#x(t), this.#g?.[t] && (clearTimeout(this.#g[t]), this.#g[t] = void 0), e && (this.#i[t] = void 0, this.#t[t] = void 0, this.#y.push(t)), this.#n === 1 ? (this.#a = this.#h = 0, this.#y.length = 0) : this.#a = this.#l[t], this.#s.delete(i), this.#n--, t;
|
|
2198
|
+
let t = this.#l, i = this.#i[t], s = this.#t[t];
|
|
2199
|
+
return this.#W && this.#e(s) ? s.__abortController.abort(new Error("evicted")) : (this.#T || this.#f) && (this.#T && this.#w?.(s, i, "evict"), this.#f && this.#r?.push([s, i, "evict"])), this.#R(t), this.#g?.[t] && (clearTimeout(this.#g[t]), this.#g[t] = void 0), e && (this.#i[t] = void 0, this.#t[t] = void 0, this.#y.push(t)), this.#n === 1 ? (this.#l = this.#h = 0, this.#y.length = 0) : this.#l = this.#a[t], this.#s.delete(i), this.#n--, t;
|
|
2205
2200
|
}
|
|
2206
2201
|
has(e, t = {}) {
|
|
2207
2202
|
let { status: i = S.hasSubscribers ? {} : void 0 } = t;
|
|
2208
|
-
t.status = i, i && (i.op = "has", i.key = e
|
|
2203
|
+
t.status = i, i && (i.op = "has", i.key = e);
|
|
2209
2204
|
let s = this.#Y(e, t);
|
|
2210
2205
|
return S.hasSubscribers && S.publish(i), s;
|
|
2211
2206
|
}
|
|
@@ -2214,14 +2209,14 @@ var I = class d2 {
|
|
|
2214
2209
|
if (n !== void 0) {
|
|
2215
2210
|
let o = this.#t[n];
|
|
2216
2211
|
if (this.#e(o) && o.__staleWhileFetching === void 0) return false;
|
|
2217
|
-
if (this.#p(n)) s && (s.has = "stale", this.#
|
|
2218
|
-
else return i && this.#
|
|
2212
|
+
if (this.#p(n)) s && (s.has = "stale", this.#E(s, n));
|
|
2213
|
+
else return i && this.#D(n), s && (s.has = "hit", this.#E(s, n)), true;
|
|
2219
2214
|
} else s && (s.has = "miss");
|
|
2220
2215
|
return false;
|
|
2221
2216
|
}
|
|
2222
2217
|
peek(e, t = {}) {
|
|
2223
|
-
let { status: i =
|
|
2224
|
-
i && (i.op = "peek", i.key = e
|
|
2218
|
+
let { status: i = D() ? {} : void 0 } = t;
|
|
2219
|
+
i && (i.op = "peek", i.key = e), t.status = i;
|
|
2225
2220
|
let s = this.#J(e, t);
|
|
2226
2221
|
return S.hasSubscribers && S.publish(i), s;
|
|
2227
2222
|
}
|
|
@@ -2231,67 +2226,67 @@ var I = class d2 {
|
|
|
2231
2226
|
i && (i.peek = n === void 0 ? "miss" : "stale");
|
|
2232
2227
|
return;
|
|
2233
2228
|
}
|
|
2234
|
-
let o = this.#t[n],
|
|
2235
|
-
return i && (
|
|
2229
|
+
let o = this.#t[n], r = this.#e(o) ? o.__staleWhileFetching : o;
|
|
2230
|
+
return i && (r !== void 0 ? (i.peek = "hit", i.value = r) : i.peek = "miss"), r;
|
|
2236
2231
|
}
|
|
2237
2232
|
#P(e, t, i, s) {
|
|
2238
2233
|
let n = t === void 0 ? void 0 : this.#t[t];
|
|
2239
2234
|
if (this.#e(n)) return n;
|
|
2240
|
-
let o = new AbortController(), { signal:
|
|
2241
|
-
|
|
2242
|
-
let h = { signal: o.signal, options: i, context: s },
|
|
2243
|
-
let { aborted: a } = o.signal,
|
|
2244
|
-
if (i.status && (a && !y ? (i.status.fetchAborted = true, i.status.fetchError = o.signal.reason,
|
|
2245
|
-
let b =
|
|
2246
|
-
return (
|
|
2247
|
-
}, c = (
|
|
2248
|
-
let { aborted: a } = o.signal,
|
|
2249
|
-
if (this.#t[t] ===
|
|
2250
|
-
if (
|
|
2251
|
-
},
|
|
2235
|
+
let o = new AbortController(), { signal: r } = i;
|
|
2236
|
+
r?.addEventListener("abort", () => o.abort(r.reason), { signal: o.signal });
|
|
2237
|
+
let h = { signal: o.signal, options: i, context: s }, l = (w, y = false) => {
|
|
2238
|
+
let { aborted: a } = o.signal, m = i.ignoreFetchAbort && w !== void 0, _ = i.ignoreFetchAbort || !!(i.allowStaleOnFetchAbort && w !== void 0);
|
|
2239
|
+
if (i.status && (a && !y ? (i.status.fetchAborted = true, i.status.fetchError = o.signal.reason, m && (i.status.fetchAbortIgnored = true)) : i.status.fetchResolved = true), a && !m && !y) return f(o.signal.reason, _);
|
|
2240
|
+
let b = p, d = this.#t[t];
|
|
2241
|
+
return (d === p || d === void 0 && m && y) && (w === void 0 ? b.__staleWhileFetching !== void 0 ? this.#t[t] = b.__staleWhileFetching : this.#v(e, "fetch") : (i.status && (i.status.fetchUpdated = true), this.#O(e, w, h.options))), w;
|
|
2242
|
+
}, c = (w) => (i.status && (i.status.fetchRejected = true, i.status.fetchError = w), f(w, false)), f = (w, y) => {
|
|
2243
|
+
let { aborted: a } = o.signal, m = a && i.allowStaleOnFetchAbort, _ = m || i.allowStaleOnFetchRejection, b = _ || i.noDeleteOnFetchRejection, d = p;
|
|
2244
|
+
if (this.#t[t] === p && (!b || !y && d.__staleWhileFetching === void 0 ? this.#v(e, "fetch") : m || (this.#t[t] = d.__staleWhileFetching)), _) return i.status && d.__staleWhileFetching !== void 0 && (i.status.returnedStale = true), d.__staleWhileFetching;
|
|
2245
|
+
if (d.__returned === d) throw w;
|
|
2246
|
+
}, g = (w, y) => {
|
|
2252
2247
|
let a = this.#M?.(e, n, h);
|
|
2253
|
-
o.signal.addEventListener("abort", () => {
|
|
2254
|
-
(!i.ignoreFetchAbort || i.allowStaleOnFetchAbort) && (
|
|
2255
|
-
})
|
|
2248
|
+
a && a instanceof Promise && a.then((m) => w(m === void 0 ? void 0 : m), y), o.signal.addEventListener("abort", () => {
|
|
2249
|
+
(!i.ignoreFetchAbort || i.allowStaleOnFetchAbort) && (w(void 0), i.allowStaleOnFetchAbort && (w = (m) => l(m, true)));
|
|
2250
|
+
});
|
|
2256
2251
|
};
|
|
2257
2252
|
i.status && (i.status.fetchDispatched = true);
|
|
2258
|
-
let
|
|
2259
|
-
return t === void 0 ? (this.#
|
|
2253
|
+
let p = new Promise(g).then(l, c), T = Object.assign(p, { __abortController: o, __staleWhileFetching: n, __returned: void 0 });
|
|
2254
|
+
return t === void 0 ? (this.#O(e, T, { ...h.options, status: void 0 }), t = this.#s.get(e)) : this.#t[t] = T, T;
|
|
2260
2255
|
}
|
|
2261
2256
|
#e(e) {
|
|
2262
|
-
if (!this.#
|
|
2257
|
+
if (!this.#W) return false;
|
|
2263
2258
|
let t = e;
|
|
2264
2259
|
return !!t && t instanceof Promise && t.hasOwnProperty("__staleWhileFetching") && t.__abortController instanceof AbortController;
|
|
2265
2260
|
}
|
|
2266
2261
|
fetch(e, t = {}) {
|
|
2267
|
-
let i = W.hasSubscribers, { status: s =
|
|
2262
|
+
let i = W.hasSubscribers, { status: s = D() ? {} : void 0 } = t;
|
|
2268
2263
|
t.status = s, s && t.context && (s.context = t.context);
|
|
2269
2264
|
let n = this.#B(e, t);
|
|
2270
2265
|
return s && i && (s.trace = true, W.tracePromise(() => n, s).catch(() => {
|
|
2271
2266
|
})), n;
|
|
2272
2267
|
}
|
|
2273
2268
|
async #B(e, t = {}) {
|
|
2274
|
-
let { allowStale: i = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: n = this.noDeleteOnStaleGet, ttl: o = this.ttl, noDisposeOnSet:
|
|
2275
|
-
if (a && (a.op = "fetch", a.key = e, y && (a.forceRefresh = true)
|
|
2276
|
-
let
|
|
2269
|
+
let { allowStale: i = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: n = this.noDeleteOnStaleGet, ttl: o = this.ttl, noDisposeOnSet: r = this.noDisposeOnSet, size: h = 0, sizeCalculation: l = this.sizeCalculation, noUpdateTTL: c = this.noUpdateTTL, noDeleteOnFetchRejection: f = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection: g = this.allowStaleOnFetchRejection, ignoreFetchAbort: p = this.ignoreFetchAbort, allowStaleOnFetchAbort: T = this.allowStaleOnFetchAbort, context: w, forceRefresh: y = false, status: a, signal: m } = t;
|
|
2270
|
+
if (a && (a.op = "fetch", a.key = e, y && (a.forceRefresh = true)), !this.#W) return a && (a.fetch = "get"), this.#C(e, { allowStale: i, updateAgeOnGet: s, noDeleteOnStaleGet: n, status: a });
|
|
2271
|
+
let _ = { allowStale: i, updateAgeOnGet: s, noDeleteOnStaleGet: n, ttl: o, noDisposeOnSet: r, size: h, sizeCalculation: l, noUpdateTTL: c, noDeleteOnFetchRejection: f, allowStaleOnFetchRejection: g, allowStaleOnFetchAbort: T, ignoreFetchAbort: p, status: a, signal: m }, b = this.#s.get(e);
|
|
2277
2272
|
if (b === void 0) {
|
|
2278
2273
|
a && (a.fetch = "miss");
|
|
2279
|
-
let
|
|
2280
|
-
return
|
|
2274
|
+
let d = this.#P(e, b, _, w);
|
|
2275
|
+
return d.__returned = d;
|
|
2281
2276
|
} else {
|
|
2282
|
-
let
|
|
2283
|
-
if (this.#e(
|
|
2284
|
-
let
|
|
2285
|
-
return a && (a.fetch = "inflight",
|
|
2277
|
+
let d = this.#t[b];
|
|
2278
|
+
if (this.#e(d)) {
|
|
2279
|
+
let E = i && d.__staleWhileFetching !== void 0;
|
|
2280
|
+
return a && (a.fetch = "inflight", E && (a.returnedStale = true)), E ? d.__staleWhileFetching : d.__returned = d;
|
|
2286
2281
|
}
|
|
2287
2282
|
let A = this.#p(b);
|
|
2288
|
-
if (!y && !A) return a && (a.fetch = "hit"), this.#L(b), s && this.#
|
|
2289
|
-
let z = this.#P(e, b,
|
|
2290
|
-
return a && (a.fetch = A ? "stale" : "refresh",
|
|
2283
|
+
if (!y && !A) return a && (a.fetch = "hit"), this.#L(b), s && this.#D(b), a && this.#E(a, b), d;
|
|
2284
|
+
let z = this.#P(e, b, _, w), v = z.__staleWhileFetching !== void 0 && i;
|
|
2285
|
+
return a && (a.fetch = A ? "stale" : "refresh", v && A && (a.returnedStale = true)), v ? z.__staleWhileFetching : z.__returned = z;
|
|
2291
2286
|
}
|
|
2292
2287
|
}
|
|
2293
2288
|
forceFetch(e, t = {}) {
|
|
2294
|
-
let i = W.hasSubscribers, { status: s =
|
|
2289
|
+
let i = W.hasSubscribers, { status: s = D() ? {} : void 0 } = t;
|
|
2295
2290
|
t.status = s, s && t.context && (s.context = t.context);
|
|
2296
2291
|
let n = this.#K(e, t);
|
|
2297
2292
|
return s && i && (s.trace = true, W.tracePromise(() => n, s).catch(() => {
|
|
@@ -2304,67 +2299,67 @@ var I = class d2 {
|
|
|
2304
2299
|
}
|
|
2305
2300
|
memo(e, t = {}) {
|
|
2306
2301
|
let { status: i = S.hasSubscribers ? {} : void 0 } = t;
|
|
2307
|
-
t.status = i, i && (i.op = "memo", i.key = e, t.context && (i.context = t.context)
|
|
2302
|
+
t.status = i, i && (i.op = "memo", i.key = e, t.context && (i.context = t.context));
|
|
2308
2303
|
let s = this.#Q(e, t);
|
|
2309
2304
|
return i && (i.value = s), S.hasSubscribers && S.publish(i), s;
|
|
2310
2305
|
}
|
|
2311
2306
|
#Q(e, t = {}) {
|
|
2312
|
-
let i = this.#
|
|
2307
|
+
let i = this.#U;
|
|
2313
2308
|
if (!i) throw new Error("no memoMethod provided to constructor");
|
|
2314
|
-
let { context: s, status: n, forceRefresh: o, ...
|
|
2309
|
+
let { context: s, status: n, forceRefresh: o, ...r } = t;
|
|
2315
2310
|
n && o && (n.forceRefresh = true);
|
|
2316
|
-
let h = this.#C(e,
|
|
2317
|
-
if (n && (n.memo =
|
|
2318
|
-
let c = i(e, h, { options:
|
|
2319
|
-
return n && (n.value = c), this.#
|
|
2311
|
+
let h = this.#C(e, r), l = o || h === void 0;
|
|
2312
|
+
if (n && (n.memo = l ? "miss" : "hit", l || (n.value = h)), !l) return h;
|
|
2313
|
+
let c = i(e, h, { options: r, context: s });
|
|
2314
|
+
return n && (n.value = c), this.#O(e, c, r), c;
|
|
2320
2315
|
}
|
|
2321
2316
|
get(e, t = {}) {
|
|
2322
2317
|
let { status: i = S.hasSubscribers ? {} : void 0 } = t;
|
|
2323
|
-
t.status = i, i && (i.op = "get", i.key = e
|
|
2318
|
+
t.status = i, i && (i.op = "get", i.key = e);
|
|
2324
2319
|
let s = this.#C(e, t);
|
|
2325
2320
|
return i && (s !== void 0 && (i.value = s), S.hasSubscribers && S.publish(i)), s;
|
|
2326
2321
|
}
|
|
2327
2322
|
#C(e, t = {}) {
|
|
2328
|
-
let { allowStale: i = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: n = this.noDeleteOnStaleGet, status: o } = t,
|
|
2329
|
-
if (
|
|
2323
|
+
let { allowStale: i = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: n = this.noDeleteOnStaleGet, status: o } = t, r = this.#s.get(e);
|
|
2324
|
+
if (r === void 0) {
|
|
2330
2325
|
o && (o.get = "miss");
|
|
2331
2326
|
return;
|
|
2332
2327
|
}
|
|
2333
|
-
let h = this.#t[
|
|
2334
|
-
return o && this.#
|
|
2328
|
+
let h = this.#t[r], l = this.#e(h);
|
|
2329
|
+
return o && this.#E(o, r), this.#p(r) ? l ? (o && (o.get = "stale-fetching"), i && h.__staleWhileFetching !== void 0 ? (o && (o.returnedStale = true), h.__staleWhileFetching) : void 0) : (n || this.#v(e, "expire"), o && (o.get = "stale"), i ? (o && (o.returnedStale = true), h) : void 0) : (o && (o.get = l ? "fetching" : "hit"), this.#L(r), s && this.#D(r), l ? h.__staleWhileFetching : h);
|
|
2335
2330
|
}
|
|
2336
2331
|
#$(e, t) {
|
|
2337
|
-
this.#
|
|
2332
|
+
this.#c[t] = e, this.#a[e] = t;
|
|
2338
2333
|
}
|
|
2339
2334
|
#L(e) {
|
|
2340
|
-
e !== this.#h && (e === this.#
|
|
2335
|
+
e !== this.#h && (e === this.#l ? this.#l = this.#a[e] : this.#$(this.#c[e], this.#a[e]), this.#$(this.#h, e), this.#h = e);
|
|
2341
2336
|
}
|
|
2342
2337
|
delete(e) {
|
|
2343
|
-
return this.#
|
|
2338
|
+
return this.#v(e, "delete");
|
|
2344
2339
|
}
|
|
2345
|
-
#
|
|
2346
|
-
S.hasSubscribers && S.publish({ op: "delete", delete: t, key: e
|
|
2340
|
+
#v(e, t) {
|
|
2341
|
+
S.hasSubscribers && S.publish({ op: "delete", delete: t, key: e });
|
|
2347
2342
|
let i = false;
|
|
2348
2343
|
if (this.#n !== 0) {
|
|
2349
2344
|
let s = this.#s.get(e);
|
|
2350
|
-
if (s !== void 0) if (this.#g?.[s] && (clearTimeout(this.#g[s]), this.#g[s] = void 0), i = true, this.#n === 1) this.#q(t);
|
|
2345
|
+
if (s !== void 0) if (this.#g?.[s] && (clearTimeout(this.#g?.[s]), this.#g[s] = void 0), i = true, this.#n === 1) this.#q(t);
|
|
2351
2346
|
else {
|
|
2352
|
-
this.#
|
|
2347
|
+
this.#R(s);
|
|
2353
2348
|
let n = this.#t[s];
|
|
2354
|
-
if (this.#e(n) ? n.__abortController.abort(new Error("deleted")) : (this.#T || this.#f) && (this.#T && this.#
|
|
2355
|
-
else if (s === this.#
|
|
2349
|
+
if (this.#e(n) ? n.__abortController.abort(new Error("deleted")) : (this.#T || this.#f) && (this.#T && this.#w?.(n, e, t), this.#f && this.#r?.push([n, e, t])), this.#s.delete(e), this.#i[s] = void 0, this.#t[s] = void 0, s === this.#h) this.#h = this.#c[s];
|
|
2350
|
+
else if (s === this.#l) this.#l = this.#a[s];
|
|
2356
2351
|
else {
|
|
2357
|
-
let o = this.#
|
|
2358
|
-
this.#
|
|
2359
|
-
let
|
|
2360
|
-
this.#
|
|
2352
|
+
let o = this.#c[s];
|
|
2353
|
+
this.#a[o] = this.#a[s];
|
|
2354
|
+
let r = this.#a[s];
|
|
2355
|
+
this.#c[r] = this.#c[s];
|
|
2361
2356
|
}
|
|
2362
2357
|
this.#n--, this.#y.push(s);
|
|
2363
2358
|
}
|
|
2364
2359
|
}
|
|
2365
2360
|
if (this.#f && this.#r?.length) {
|
|
2366
2361
|
let s = this.#r, n;
|
|
2367
|
-
for (; n = s?.shift(); ) this.#
|
|
2362
|
+
for (; n = s?.shift(); ) this.#S?.(...n);
|
|
2368
2363
|
}
|
|
2369
2364
|
return i;
|
|
2370
2365
|
}
|
|
@@ -2377,7 +2372,7 @@ var I = class d2 {
|
|
|
2377
2372
|
if (this.#e(i)) i.__abortController.abort(new Error("deleted"));
|
|
2378
2373
|
else {
|
|
2379
2374
|
let s = this.#i[t];
|
|
2380
|
-
this.#T && this.#
|
|
2375
|
+
this.#T && this.#w?.(i, s, e), this.#f && this.#r?.push([i, s, e]);
|
|
2381
2376
|
}
|
|
2382
2377
|
}
|
|
2383
2378
|
if (this.#s.clear(), this.#t.fill(void 0), this.#i.fill(void 0), this.#d && this.#F) {
|
|
@@ -2385,9 +2380,9 @@ var I = class d2 {
|
|
|
2385
2380
|
for (let t of this.#g ?? []) t !== void 0 && clearTimeout(t);
|
|
2386
2381
|
this.#g?.fill(void 0);
|
|
2387
2382
|
}
|
|
2388
|
-
if (this.#_ && this.#_.fill(0), this.#
|
|
2383
|
+
if (this.#_ && this.#_.fill(0), this.#l = 0, this.#h = 0, this.#y.length = 0, this.#b = 0, this.#n = 0, this.#f && this.#r) {
|
|
2389
2384
|
let t = this.#r, i;
|
|
2390
|
-
for (; i = t?.shift(); ) this.#
|
|
2385
|
+
for (; i = t?.shift(); ) this.#S?.(...i);
|
|
2391
2386
|
}
|
|
2392
2387
|
}
|
|
2393
2388
|
};
|
|
@@ -3326,7 +3321,7 @@ var ENOREALPATH = 512;
|
|
|
3326
3321
|
var ENOCHILD = ENOTDIR | ENOENT | ENOREALPATH;
|
|
3327
3322
|
var TYPEMASK = 1023;
|
|
3328
3323
|
var entToType = (s) => s.isFile() ? IFREG : s.isDirectory() ? IFDIR : s.isSymbolicLink() ? IFLNK : s.isCharacterDevice() ? IFCHR : s.isBlockDevice() ? IFBLK : s.isSocket() ? IFSOCK : s.isFIFO() ? IFIFO : UNKNOWN;
|
|
3329
|
-
var normalizeCache = new
|
|
3324
|
+
var normalizeCache = new M({ max: 2 ** 12 });
|
|
3330
3325
|
var normalize = (s) => {
|
|
3331
3326
|
const c = normalizeCache.get(s);
|
|
3332
3327
|
if (c)
|
|
@@ -3335,7 +3330,7 @@ var normalize = (s) => {
|
|
|
3335
3330
|
normalizeCache.set(s, n);
|
|
3336
3331
|
return n;
|
|
3337
3332
|
};
|
|
3338
|
-
var normalizeNocaseCache = new
|
|
3333
|
+
var normalizeNocaseCache = new M({ max: 2 ** 12 });
|
|
3339
3334
|
var normalizeNocase = (s) => {
|
|
3340
3335
|
const c = normalizeNocaseCache.get(s);
|
|
3341
3336
|
if (c)
|
|
@@ -3344,12 +3339,12 @@ var normalizeNocase = (s) => {
|
|
|
3344
3339
|
normalizeNocaseCache.set(s, n);
|
|
3345
3340
|
return n;
|
|
3346
3341
|
};
|
|
3347
|
-
var ResolveCache = class extends
|
|
3342
|
+
var ResolveCache = class extends M {
|
|
3348
3343
|
constructor() {
|
|
3349
3344
|
super({ max: 256 });
|
|
3350
3345
|
}
|
|
3351
3346
|
};
|
|
3352
|
-
var ChildrenCache = class extends
|
|
3347
|
+
var ChildrenCache = class extends M {
|
|
3353
3348
|
constructor(maxSize = 16 * 1024) {
|
|
3354
3349
|
super({
|
|
3355
3350
|
maxSize,
|
|
@@ -5320,7 +5315,7 @@ var SubWalks = class {
|
|
|
5320
5315
|
return subs;
|
|
5321
5316
|
}
|
|
5322
5317
|
entries() {
|
|
5323
|
-
return this.keys().map((
|
|
5318
|
+
return this.keys().map((k) => [k, this.store.get(k)]);
|
|
5324
5319
|
}
|
|
5325
5320
|
keys() {
|
|
5326
5321
|
return [...this.store.keys()].filter((t) => t.canReaddir());
|
package/dist/index.js
CHANGED
|
@@ -5,8 +5,109 @@ import {
|
|
|
5
5
|
} from "./chunk-P76KH42G.js";
|
|
6
6
|
|
|
7
7
|
// src/index.ts
|
|
8
|
+
import { createRequire as createRequire2 } from "module";
|
|
8
9
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
9
10
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
11
|
+
|
|
12
|
+
// src/freshness.ts
|
|
13
|
+
import { createRequire } from "module";
|
|
14
|
+
import { statSync, existsSync, readdirSync } from "fs";
|
|
15
|
+
import { dirname, join } from "path";
|
|
16
|
+
import { fileURLToPath } from "url";
|
|
17
|
+
var require_ = createRequire(import.meta.url);
|
|
18
|
+
var WORKSPACE_SCOPES = ["@lokascript/", "@hyperfixi/"];
|
|
19
|
+
var PROBE_TTL_MS = 1e3;
|
|
20
|
+
var watched = [];
|
|
21
|
+
var lastProbeAt = 0;
|
|
22
|
+
var lastResult = [];
|
|
23
|
+
function watchedPackages() {
|
|
24
|
+
const pkg = require_("../package.json");
|
|
25
|
+
const names = /* @__PURE__ */ new Set([
|
|
26
|
+
...Object.keys(pkg.dependencies ?? {}),
|
|
27
|
+
...Object.keys(pkg.peerDependencies ?? {})
|
|
28
|
+
]);
|
|
29
|
+
return [...names].filter((n) => WORKSPACE_SCOPES.some((s) => n.startsWith(s))).sort();
|
|
30
|
+
}
|
|
31
|
+
function resolveMarker(name) {
|
|
32
|
+
try {
|
|
33
|
+
const url = import.meta.resolve(name);
|
|
34
|
+
const path = fileURLToPath(url);
|
|
35
|
+
return existsSync(path) ? path : null;
|
|
36
|
+
} catch {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function captureFreshnessBaseline() {
|
|
41
|
+
watched = watchedPackages().flatMap((pkg) => {
|
|
42
|
+
const marker = resolveMarker(pkg);
|
|
43
|
+
if (!marker) return [];
|
|
44
|
+
return [{ pkg, marker, loadedMtimeMs: statSync(marker).mtimeMs }];
|
|
45
|
+
});
|
|
46
|
+
lastProbeAt = 0;
|
|
47
|
+
lastResult = [];
|
|
48
|
+
}
|
|
49
|
+
function staleSinceStartup(now = Date.now()) {
|
|
50
|
+
if (now - lastProbeAt < PROBE_TTL_MS) return lastResult;
|
|
51
|
+
lastProbeAt = now;
|
|
52
|
+
lastResult = watched.filter((w) => {
|
|
53
|
+
try {
|
|
54
|
+
return statSync(w.marker).mtimeMs !== w.loadedMtimeMs;
|
|
55
|
+
} catch {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
}).map((w) => w.pkg);
|
|
59
|
+
return lastResult;
|
|
60
|
+
}
|
|
61
|
+
function hasNewerTs(dir, builtAt) {
|
|
62
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
63
|
+
const p = join(dir, entry.name);
|
|
64
|
+
if (entry.isDirectory()) {
|
|
65
|
+
if (hasNewerTs(p, builtAt)) return true;
|
|
66
|
+
} else if (entry.name.endsWith(".ts") && statSync(p).mtimeMs > builtAt) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
function staleAtStartup() {
|
|
73
|
+
return watched.filter((w) => {
|
|
74
|
+
const srcDir = join(dirname(dirname(w.marker)), "src");
|
|
75
|
+
if (!existsSync(srcDir)) return false;
|
|
76
|
+
try {
|
|
77
|
+
return hasNewerTs(srcDir, statSync(w.marker).mtimeMs);
|
|
78
|
+
} catch {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
}).map((w) => ({ pkg: w.pkg, dir: dirname(dirname(w.marker)) }));
|
|
82
|
+
}
|
|
83
|
+
function staleToolError(stale) {
|
|
84
|
+
return {
|
|
85
|
+
content: [
|
|
86
|
+
{
|
|
87
|
+
type: "text",
|
|
88
|
+
text: `\u2717 This MCP server is serving STALE code and refused the call.
|
|
89
|
+
|
|
90
|
+
Rebuilt since the server started: ${stale.join(", ")}
|
|
91
|
+
|
|
92
|
+
The server resolves these packages' dist/ at startup and Node caches the module
|
|
93
|
+
graph, so it cannot pick up a rebuild without restarting. Any answer it gave now
|
|
94
|
+
would reflect the code as it was BEFORE the rebuild \u2014 silently.
|
|
95
|
+
|
|
96
|
+
Fix: restart the MCP server (in Claude Code: /mcp, then reconnect "lokascript").
|
|
97
|
+
|
|
98
|
+
If you are mid-arc and only need to probe the parser, prefer a direct tsx probe
|
|
99
|
+
(which imports fresh each run) over this server \u2014 see the probe recipe in
|
|
100
|
+
docs-internal/HANDOFF_foreign-validity-burndown.md.`
|
|
101
|
+
}
|
|
102
|
+
],
|
|
103
|
+
isError: true
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function freshnessSummary() {
|
|
107
|
+
return `watching ${watched.length} workspace dist entries`;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// src/index.ts
|
|
10
111
|
import {
|
|
11
112
|
CallToolRequestSchema,
|
|
12
113
|
GetPromptRequestSchema,
|
|
@@ -7977,7 +8078,7 @@ function createInlineExtractor() {
|
|
|
7977
8078
|
const fs = await import("fs");
|
|
7978
8079
|
const path = await import("path");
|
|
7979
8080
|
const crypto = await import("crypto");
|
|
7980
|
-
const { glob } = await import("./esm-
|
|
8081
|
+
const { glob } = await import("./esm-65HZKQ6R.js");
|
|
7981
8082
|
const globs = [
|
|
7982
8083
|
"**/*.html",
|
|
7983
8084
|
"**/*.htm",
|
|
@@ -10134,6 +10235,7 @@ function getLSEProtocolSpec() {
|
|
|
10134
10235
|
| Disabled flag | \`~name\` | \`~nullable\` |
|
|
10135
10236
|
| String literal | \`"..."\` or \`'...'\` | \`patient:"hello world"\` |
|
|
10136
10237
|
| Selector | \`#id\` \`.class\` \`[attr]\` \`@aria\` \`*wild\` | \`destination:#button\` |
|
|
10238
|
+
| Selector literal | \`<...selector.../>\` | \`patient:<ul > li/>\`, \`patient:<.a, .b/>\` |
|
|
10137
10239
|
| Boolean | \`true\` / \`false\` | \`goal:true\` |
|
|
10138
10240
|
| Number | digits with optional decimal | \`quantity:5\` |
|
|
10139
10241
|
| Duration | number + suffix | \`delay:500ms\`, \`timeout:2s\` |
|
|
@@ -10141,15 +10243,22 @@ function getLSEProtocolSpec() {
|
|
|
10141
10243
|
| Nested body | bracket command in value | \`body:[toggle patient:.active]\` |
|
|
10142
10244
|
| Compound | chain operator between commands | \`[add ...] then [fetch ...]\` |
|
|
10143
10245
|
|
|
10246
|
+
A selector containing a space, a combinator (\`>\` \`+\` \`~\`), or a comma must use a
|
|
10247
|
+
selector literal \u2014 the tokenizer would otherwise split it. Inside a structural role
|
|
10248
|
+
(\`body\`, \`then\`, \`else\`, \`condition\`, \`loop-body\`, \`variable\`, \`catch\`, \`finally\`)
|
|
10249
|
+
a \`[...]\` value is always a nested command, so an attribute selector there must also
|
|
10250
|
+
use the literal form: \`condition:<[data-active]/>\`.
|
|
10251
|
+
|
|
10144
10252
|
## Value Classification Priority (first match wins)
|
|
10145
10253
|
|
|
10146
|
-
1. **Selector** \u2014 starts with
|
|
10147
|
-
2. **
|
|
10148
|
-
3. **
|
|
10149
|
-
4. **
|
|
10150
|
-
5. **
|
|
10151
|
-
6. **
|
|
10152
|
-
7. **
|
|
10254
|
+
1. **Selector literal** \u2014 starts with \`<\` and ends with \`/>\`; delimiters stripped
|
|
10255
|
+
2. **Selector** \u2014 starts with \`#\`, \`.\`, \`[\`, \`@\`, \`*\`
|
|
10256
|
+
3. **String** \u2014 starts with \`"\` or \`'\`
|
|
10257
|
+
4. **Boolean** \u2014 exact: \`true\` or \`false\`
|
|
10258
|
+
5. **Reference** \u2014 \`me\`, \`you\`, \`it\`, \`result\`, \`event\`, \`target\`, \`body\`
|
|
10259
|
+
6. **Duration** \u2014 number + \`ms\`/\`s\`/\`m\`/\`h\`
|
|
10260
|
+
7. **Number** \u2014 integer or decimal
|
|
10261
|
+
8. **Plain** \u2014 fallback (any non-whitespace)
|
|
10153
10262
|
|
|
10154
10263
|
## Node Kinds
|
|
10155
10264
|
|
|
@@ -10388,10 +10497,11 @@ function readResource(uri) {
|
|
|
10388
10497
|
|
|
10389
10498
|
// src/index.ts
|
|
10390
10499
|
var registry = createDomainRegistry();
|
|
10500
|
+
var { version: pkgVersion } = createRequire2(import.meta.url)("../package.json");
|
|
10391
10501
|
var server = new Server(
|
|
10392
10502
|
{
|
|
10393
10503
|
name: "@hyperfixi/mcp-server",
|
|
10394
|
-
version:
|
|
10504
|
+
version: pkgVersion
|
|
10395
10505
|
},
|
|
10396
10506
|
{
|
|
10397
10507
|
capabilities: {
|
|
@@ -10428,6 +10538,10 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
10428
10538
|
});
|
|
10429
10539
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
10430
10540
|
const { name, arguments: args } = request.params;
|
|
10541
|
+
const stale = staleSinceStartup();
|
|
10542
|
+
if (stale.length > 0) {
|
|
10543
|
+
return staleToolError(stale);
|
|
10544
|
+
}
|
|
10431
10545
|
if (name.startsWith("analyze_") || name === "explain_code" || name === "recognize_intent") {
|
|
10432
10546
|
return handleAnalysisTool(name, args);
|
|
10433
10547
|
}
|
|
@@ -10484,7 +10598,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
10484
10598
|
if (name === "lse_validate_and_feedback" || name === "lse_pattern_stats") {
|
|
10485
10599
|
return handleFeedbackTool(name, args);
|
|
10486
10600
|
}
|
|
10487
|
-
if (name === "lse_from_hyperscript" || name === "lse_to_hyperscript") {
|
|
10601
|
+
if (name === "lse_from_hyperscript" || name === "lse_to_hyperscript" || name === "execute_lse" || name === "validate_lse" || name === "translate_lse") {
|
|
10488
10602
|
return handleLsePipelineTool(name, args);
|
|
10489
10603
|
}
|
|
10490
10604
|
if (name.startsWith("grail_")) {
|
|
@@ -10529,9 +10643,19 @@ server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
|
|
|
10529
10643
|
return readResource(uri);
|
|
10530
10644
|
});
|
|
10531
10645
|
async function main() {
|
|
10646
|
+
captureFreshnessBaseline();
|
|
10647
|
+
const bornStale = staleAtStartup();
|
|
10648
|
+
if (bornStale.length > 0) {
|
|
10649
|
+
console.error(
|
|
10650
|
+
`\u26A0 MCP server started against a STALE dist/ in: ${bornStale.map((s) => s.pkg).join(", ")} \u2014
|
|
10651
|
+
src/ is newer than the built output, so answers will reflect the last build, not the
|
|
10652
|
+
checkout. Rebuild, then restart this server:
|
|
10653
|
+
` + bornStale.map((s) => ` npm run build --prefix ${s.dir}`).join("\n")
|
|
10654
|
+
);
|
|
10655
|
+
}
|
|
10532
10656
|
const transport = new StdioServerTransport();
|
|
10533
10657
|
await server.connect(transport);
|
|
10534
|
-
console.error(
|
|
10658
|
+
console.error(`HyperFixi MCP server started (${freshnessSummary()})`);
|
|
10535
10659
|
}
|
|
10536
10660
|
main().catch((error) => {
|
|
10537
10661
|
console.error("Failed to start MCP server:", error);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperfixi/mcp-server",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
4
4
|
"description": "Model Context Protocol server for HyperFixi hyperscript development",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -37,31 +37,31 @@
|
|
|
37
37
|
"author": "LokaScript Contributors",
|
|
38
38
|
"license": "MIT",
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@hyperfixi/patterns-reference": "^2.
|
|
41
|
-
"@lokascript/compilation-service": "^2.
|
|
42
|
-
"@lokascript/domain-config": "^2.
|
|
43
|
-
"@lokascript/framework": "^2.
|
|
44
|
-
"@lokascript/planner": "^2.
|
|
45
|
-
"@lokascript/semantic": "^2.
|
|
40
|
+
"@hyperfixi/patterns-reference": "^2.8.0",
|
|
41
|
+
"@lokascript/compilation-service": "^2.8.0",
|
|
42
|
+
"@lokascript/domain-config": "^2.8.0",
|
|
43
|
+
"@lokascript/framework": "^2.8.0",
|
|
44
|
+
"@lokascript/planner": "^2.8.0",
|
|
45
|
+
"@lokascript/semantic": "^2.8.0",
|
|
46
46
|
"@modelcontextprotocol/sdk": "^1.25.0",
|
|
47
47
|
"yaml": "^2.8.3"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@hyperfixi/core": "^2.
|
|
51
|
-
"@hyperfixi/patterns-reference": "^2.
|
|
52
|
-
"@hyperfixi/server-bridge": "^2.
|
|
53
|
-
"@lokascript/compilation-service": "^2.
|
|
54
|
-
"@lokascript/domain-bdd": "^2.
|
|
55
|
-
"@lokascript/domain-behaviorspec": "^2.
|
|
56
|
-
"@lokascript/domain-flow": "^2.
|
|
57
|
-
"@lokascript/domain-jsx": "^2.
|
|
58
|
-
"@lokascript/domain-learn": "^2.
|
|
59
|
-
"@lokascript/domain-llm": "^2.
|
|
60
|
-
"@lokascript/domain-sql": "^2.
|
|
61
|
-
"@lokascript/domain-todo": "^2.
|
|
62
|
-
"@lokascript/domain-voice": "^2.
|
|
63
|
-
"@lokascript/framework": "^2.
|
|
64
|
-
"@lokascript/semantic": "^2.
|
|
50
|
+
"@hyperfixi/core": "^2.8.0",
|
|
51
|
+
"@hyperfixi/patterns-reference": "^2.8.0",
|
|
52
|
+
"@hyperfixi/server-bridge": "^2.8.0",
|
|
53
|
+
"@lokascript/compilation-service": "^2.8.0",
|
|
54
|
+
"@lokascript/domain-bdd": "^2.8.0",
|
|
55
|
+
"@lokascript/domain-behaviorspec": "^2.8.0",
|
|
56
|
+
"@lokascript/domain-flow": "^2.8.0",
|
|
57
|
+
"@lokascript/domain-jsx": "^2.8.0",
|
|
58
|
+
"@lokascript/domain-learn": "^2.8.0",
|
|
59
|
+
"@lokascript/domain-llm": "^2.8.0",
|
|
60
|
+
"@lokascript/domain-sql": "^2.8.0",
|
|
61
|
+
"@lokascript/domain-todo": "^2.8.0",
|
|
62
|
+
"@lokascript/domain-voice": "^2.8.0",
|
|
63
|
+
"@lokascript/framework": "^2.8.0",
|
|
64
|
+
"@lokascript/semantic": "^2.8.0"
|
|
65
65
|
},
|
|
66
66
|
"peerDependenciesMeta": {
|
|
67
67
|
"@lokascript/compilation-service": {
|
|
@@ -111,24 +111,24 @@
|
|
|
111
111
|
}
|
|
112
112
|
},
|
|
113
113
|
"devDependencies": {
|
|
114
|
-
"@hyperfixi/core": "^2.
|
|
115
|
-
"@hyperfixi/patterns-reference": "^2.
|
|
116
|
-
"@hyperfixi/server-bridge": "^2.
|
|
117
|
-
"@lokascript/compilation-service": "^2.
|
|
118
|
-
"@lokascript/domain-bdd": "^2.
|
|
119
|
-
"@lokascript/domain-behaviorspec": "^2.
|
|
120
|
-
"@lokascript/domain-flow": "^2.
|
|
121
|
-
"@lokascript/domain-jsx": "^2.
|
|
122
|
-
"@lokascript/domain-learn": "^2.
|
|
123
|
-
"@lokascript/domain-llm": "^2.
|
|
124
|
-
"@lokascript/domain-sql": "^2.
|
|
125
|
-
"@lokascript/domain-todo": "^2.
|
|
126
|
-
"@lokascript/domain-voice": "^2.
|
|
127
|
-
"@lokascript/framework": "^2.
|
|
128
|
-
"@lokascript/semantic": "^2.
|
|
114
|
+
"@hyperfixi/core": "^2.8.0",
|
|
115
|
+
"@hyperfixi/patterns-reference": "^2.8.0",
|
|
116
|
+
"@hyperfixi/server-bridge": "^2.8.0",
|
|
117
|
+
"@lokascript/compilation-service": "^2.8.0",
|
|
118
|
+
"@lokascript/domain-bdd": "^2.8.0",
|
|
119
|
+
"@lokascript/domain-behaviorspec": "^2.8.0",
|
|
120
|
+
"@lokascript/domain-flow": "^2.8.0",
|
|
121
|
+
"@lokascript/domain-jsx": "^2.8.0",
|
|
122
|
+
"@lokascript/domain-learn": "^2.8.0",
|
|
123
|
+
"@lokascript/domain-llm": "^2.8.0",
|
|
124
|
+
"@lokascript/domain-sql": "^2.8.0",
|
|
125
|
+
"@lokascript/domain-todo": "^2.8.0",
|
|
126
|
+
"@lokascript/domain-voice": "^2.8.0",
|
|
127
|
+
"@lokascript/framework": "^2.8.0",
|
|
128
|
+
"@lokascript/semantic": "^2.8.0",
|
|
129
129
|
"@types/node": "^20.0.0",
|
|
130
130
|
"tsup": "^8.0.0",
|
|
131
|
-
"tsx": "^4.
|
|
131
|
+
"tsx": "^4.23.1",
|
|
132
132
|
"typescript": "^5.0.0",
|
|
133
133
|
"vitest": "^4.1.5"
|
|
134
134
|
},
|