@developerz.ai/ui-debugger-mcp 1.1.0 → 1.3.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 +45 -10
- package/dist/adapters/android/adb.d.ts +34 -5
- package/dist/adapters/android/adb.js +74 -20
- package/dist/adapters/android/adb.js.map +1 -1
- package/dist/adapters/android/android-adapter.d.ts +23 -7
- package/dist/adapters/android/android-adapter.js +106 -36
- package/dist/adapters/android/android-adapter.js.map +1 -1
- package/dist/adapters/android/android-adapter.test-helpers.d.ts +52 -0
- package/dist/adapters/android/android-adapter.test-helpers.js +115 -0
- package/dist/adapters/android/android-adapter.test-helpers.js.map +1 -0
- package/dist/adapters/android/commands.d.ts +27 -4
- package/dist/adapters/android/commands.js +66 -4
- package/dist/adapters/android/commands.js.map +1 -1
- package/dist/adapters/android/ports.d.ts +32 -0
- package/dist/adapters/android/ports.js +47 -0
- package/dist/adapters/android/ports.js.map +1 -0
- package/dist/adapters/android/uiautomator.d.ts +10 -2
- package/dist/adapters/android/uiautomator.js +36 -4
- package/dist/adapters/android/uiautomator.js.map +1 -1
- package/dist/adapters/browser/browser-adapter.d.ts +16 -13
- package/dist/adapters/browser/browser-adapter.js +196 -313
- package/dist/adapters/browser/browser-adapter.js.map +1 -1
- package/dist/adapters/browser/cdp.d.ts +40 -2
- package/dist/adapters/browser/cdp.js +223 -19
- package/dist/adapters/browser/cdp.js.map +1 -1
- package/dist/adapters/browser/extractor.d.ts +53 -0
- package/dist/adapters/browser/extractor.js +224 -0
- package/dist/adapters/browser/extractor.js.map +1 -0
- package/dist/adapters/browser/filters.d.ts +15 -0
- package/dist/adapters/browser/filters.js +93 -0
- package/dist/adapters/browser/filters.js.map +1 -0
- package/dist/adapters/browser/launch.d.ts +41 -0
- package/dist/adapters/browser/launch.js +61 -0
- package/dist/adapters/browser/launch.js.map +1 -0
- package/dist/adapters/budget.d.ts +16 -0
- package/dist/adapters/budget.js +25 -0
- package/dist/adapters/budget.js.map +1 -0
- package/dist/adapters/contract.d.ts +82 -6
- package/dist/adapters/desktop/atspi.d.ts +15 -0
- package/dist/adapters/desktop/atspi.js +37 -17
- package/dist/adapters/desktop/atspi.js.map +1 -1
- package/dist/adapters/desktop/capture.js +8 -1
- package/dist/adapters/desktop/capture.js.map +1 -1
- package/dist/adapters/desktop/desktop-adapter.d.ts +9 -2
- package/dist/adapters/desktop/desktop-adapter.js +84 -32
- package/dist/adapters/desktop/desktop-adapter.js.map +1 -1
- package/dist/adapters/desktop/input.d.ts +16 -1
- package/dist/adapters/desktop/input.js +30 -0
- package/dist/adapters/desktop/input.js.map +1 -1
- package/dist/adapters/desktop/proc.d.ts +18 -3
- package/dist/adapters/desktop/proc.js +48 -5
- package/dist/adapters/desktop/proc.js.map +1 -1
- package/dist/adapters/factory.d.ts +3 -1
- package/dist/adapters/factory.js +6 -2
- package/dist/adapters/factory.js.map +1 -1
- package/dist/adapters/limit.d.ts +10 -0
- package/dist/adapters/limit.js +19 -0
- package/dist/adapters/limit.js.map +1 -0
- package/dist/agent/belt/act.d.ts +44 -9
- package/dist/agent/belt/act.js +176 -21
- package/dist/agent/belt/act.js.map +1 -1
- package/dist/agent/belt/look.d.ts +1 -1
- package/dist/agent/belt/look.js +31 -2
- package/dist/agent/belt/look.js.map +1 -1
- package/dist/agent/belt/observe.d.ts +42 -16
- package/dist/agent/belt/observe.js +134 -22
- package/dist/agent/belt/observe.js.map +1 -1
- package/dist/agent/belt/report.d.ts +29 -9
- package/dist/agent/belt/report.js +77 -10
- package/dist/agent/belt/report.js.map +1 -1
- package/dist/agent/belt/trail.d.ts +34 -0
- package/dist/agent/belt/trail.js +64 -0
- package/dist/agent/belt/trail.js.map +1 -0
- package/dist/agent/capabilities.d.ts +4 -4
- package/dist/agent/capabilities.js +41 -13
- package/dist/agent/capabilities.js.map +1 -1
- package/dist/agent/loop.d.ts +70 -21
- package/dist/agent/loop.js +146 -48
- package/dist/agent/loop.js.map +1 -1
- package/dist/agent/prompts/compose.d.ts +9 -1
- package/dist/agent/prompts/compose.js +5 -4
- package/dist/agent/prompts/compose.js.map +1 -1
- package/dist/agent/prompts/debug-agent.d.ts +13 -1
- package/dist/agent/prompts/debug-agent.js +98 -14
- package/dist/agent/prompts/debug-agent.js.map +1 -1
- package/dist/agent/prompts/desktop-addendum.d.ts +1 -1
- package/dist/agent/prompts/desktop-addendum.js +1 -1
- package/dist/agent/prompts/web-addendum.d.ts +1 -1
- package/dist/agent/prompts/web-addendum.js +84 -16
- package/dist/agent/prompts/web-addendum.js.map +1 -1
- package/dist/cli/control.d.ts +3 -1
- package/dist/cli/control.js +26 -40
- package/dist/cli/control.js.map +1 -1
- package/dist/cli/help.d.ts +3 -1
- package/dist/cli/help.js +6 -2
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/init.d.ts +3 -6
- package/dist/cli/init.js +64 -16
- package/dist/cli/init.js.map +1 -1
- package/dist/config/fingerprint.d.ts +32 -0
- package/dist/config/fingerprint.js +47 -0
- package/dist/config/fingerprint.js.map +1 -0
- package/dist/config/load.d.ts +7 -1
- package/dist/config/load.js +17 -4
- package/dist/config/load.js.map +1 -1
- package/dist/config/schema.d.ts +12 -5
- package/dist/config/schema.js +17 -7
- package/dist/config/schema.js.map +1 -1
- package/dist/errors.d.ts +14 -2
- package/dist/errors.js +24 -4
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/main.js +26 -8
- package/dist/main.js.map +1 -1
- package/dist/mcp/server.d.ts +16 -1
- package/dist/mcp/server.js +23 -2
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/server.test-helpers.d.ts +23 -0
- package/dist/mcp/server.test-helpers.js +49 -0
- package/dist/mcp/server.test-helpers.js.map +1 -0
- package/dist/mcp/tools/describe.js +5 -0
- package/dist/mcp/tools/describe.js.map +1 -1
- package/dist/mcp/tools/end-session.js +5 -0
- package/dist/mcp/tools/end-session.js.map +1 -1
- package/dist/mcp/tools/get-findings.js +23 -3
- package/dist/mcp/tools/get-findings.js.map +1 -1
- package/dist/mcp/tools/output.d.ts +50 -0
- package/dist/mcp/tools/output.js +55 -0
- package/dist/mcp/tools/output.js.map +1 -0
- package/dist/mcp/tools/result.d.ts +24 -1
- package/dist/mcp/tools/result.js +106 -5
- package/dist/mcp/tools/result.js.map +1 -1
- package/dist/mcp/tools/send-message.js +5 -0
- package/dist/mcp/tools/send-message.js.map +1 -1
- package/dist/mcp/tools/start-debug.js +7 -1
- package/dist/mcp/tools/start-debug.js.map +1 -1
- package/dist/services/debug-service.d.ts +47 -8
- package/dist/services/debug-service.js +185 -14
- package/dist/services/debug-service.js.map +1 -1
- package/dist/services/session-builder.d.ts +20 -3
- package/dist/services/session-builder.js +43 -13
- package/dist/services/session-builder.js.map +1 -1
- package/dist/services/summarize.d.ts +1 -1
- package/dist/services/summarize.js +8 -1
- package/dist/services/summarize.js.map +1 -1
- package/dist/session/atomic-write.d.ts +24 -0
- package/dist/session/atomic-write.js +39 -0
- package/dist/session/atomic-write.js.map +1 -0
- package/dist/session/findings-store.js +3 -4
- package/dist/session/findings-store.js.map +1 -1
- package/dist/session/process-identity.d.ts +16 -0
- package/dist/session/process-identity.js +29 -0
- package/dist/session/process-identity.js.map +1 -1
- package/dist/session/session.js +36 -4
- package/dist/session/session.js.map +1 -1
- package/dist/session/state-file.d.ts +64 -5
- package/dist/session/state-file.js +76 -9
- package/dist/session/state-file.js.map +1 -1
- package/dist/session/workspace.d.ts +11 -0
- package/dist/session/workspace.js +14 -1
- package/dist/session/workspace.js.map +1 -1
- package/package.json +4 -1
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Provider-agnostic — no vendor tricks; any competent model drives the same loop.
|
|
8
8
|
*/
|
|
9
|
-
export declare const WEB_ADDENDUM_PROMPT = "## Web target \u2014 CDP reach\n\nYour browser connection uses the Chrome DevTools Protocol (CDP).\
|
|
9
|
+
export declare const WEB_ADDENDUM_PROMPT = "## Web target \u2014 CDP reach\n\nYour browser connection uses the Chrome DevTools Protocol (CDP).\nIt reaches the current page: DOM, console, network, input, and screenshots.\nUse it deliberately.\n\n### CDP domains and when to reach for each\n\n| Domain | What it gives you | Use via |\n|-------------|-------------------|---------|\n| `Page` | navigate, wait for load, capture screenshot | `act({action:\"navigate\"})`, `observe({kind:\"screenshot\"})` |\n| `DOM` | read/query the element tree, attributes, text | `observe({kind:\"tree\"})` |\n| `Network` | request/response status, failed requests, timing | `observe({kind:\"network\"})` |\n| `Log` | browser console messages, JS errors | `observe({kind:\"console\"})` |\n\n### DOM-first rule\n\nAlways try the structured path before asking for vision:\n1. `observe({kind:\"tree\"})` \u2014 read element roles, names, bounds, enabled state.\n2. If an element is not visible in the tree, try scrolling or waiting, then re-observe.\n3. Use `observe({kind:\"console\"})` and `observe({kind:\"network\"})` (filtered \u2014 see\n below) after actions that plausibly trigger errors \u2014 errors land there before\n they surface visually.\n4. Only after the tree gives you no answer: call `look` for pixels.\n\n### Composing tree queries\n\n- `query` accepts: a bare HTML tag (`span`, `img`), CSS (`.cart span`),\n `role \"name\"` (`button \"Add to cart\"`), an explicit engine\n (`data-testid=cart-count`, `text=Subscribe`), or plain visible text.\n- Elements with a `data-testid` always appear in the default (no-query) tree with\n their `testid` \u2014 to read a counter/value, find its node and read `name` (the\n text content). Re-observe the same node after acting to verify a change.\n- `within` scopes the read: pass a selector string or a node OBJECT exactly as a\n previous observe returned it \u2014 never a JSON-stringified node.\n\n### Invisible text & contrast \u2014 no vision needed\n\nText-bearing nodes carry a `style` column = `{ color, backgroundColor, contrast }`\n(WCAG ratio 1\u201321). It is omitted by default \u2014 request it via `fields:[\"role\",\"name\",\"style\"]`\nor sweep all text in ONE call:\n`observe({kind:\"tree\", query:\"p, span, div, a, li\", filters:{contrast_lt: 4.5}})`\n(returns only hard-to-read text; empty = contrast is fine). Flag `contrast < 4.5`\nas a `medium` visual finding and `contrast < 1.5` as `high` (the text is\neffectively invisible). Always run one contrast sweep when the goal mentions\nreadability, contrast, or visual polish.\n\n### Follow links by CLICKING them \u2014 never invent URLs\n\nThe tree does not expose `href`s. To follow a link, `act({action:\"click\"})` its\nnode. Do NOT fabricate a URL from a link's label (e.g. label \"Help Center\" \u2192\nnavigating to `/help-center`): a guessed URL that 404s is YOUR error, not a site\nbug. Only `navigate` to URLs given in the goal or seen in network entries. If a\nlink's click target is hidden (e.g. inside a closed menu), click the parent menu\nitem first, then re-observe.\n\n### Verify input from the TREE, never from vision\n\nForm controls carry their LIVE state in the tree: `value` (what an\ninput/textarea/select currently holds) and `checked` (checkbox/radio). `name`\nstays the label, so you can still target the field by it.\n\nAfter typing or toggling, confirm with one `observe`:\n`observe({kind:\"tree\", query:\"input\", fields:[\"name\",\"value\",\"checked\"]})`\n\nNEVER spend a `look` asking \"did my text land?\" or \"is the box checked now?\" \u2014\nthe tree answers exactly, instantly, and for free. Vision is for how things LOOK,\nnot for reading back your own input.\n\n### Typing replaces nothing unless you say so\n\n`act({action:\"type\"})` APPENDS to whatever the field already holds. Re-typing a\nfield you have used before yields `old textnew text` \u2014 and that doubled value is\nYOUR bug, not the app's. Pass `clear: true` to replace the contents instead:\n`act({action:\"type\", target:\"...\", text:\"...\", clear:true})`.\n\nUse `clear` whenever the field may be non-empty: a retry, a second item through\nthe same form, or any field you have not just seen empty in the tree.\n\n### Login bypass\n\nIf the target has `?debug-ai=true` support (the app's captcha bypass gate),\nappend it to the login URL before navigating. This skips captcha only \u2014 not auth.\nThe app must have `ALLOW_AI_DEBUG_LOGIN=true` set in its environment.\n\n### Selectors \u2014 use the node's `target`, don't invent one\n\nMost actionable nodes from `observe({kind:\"tree\"})` carry a ready-to-use `target`\nstring (e.g. `data-testid=\"cart-count\"` when the element has a test id, else\n`role=button[name=\"Add to cart\" i]`, with `>> nth=N` when names repeat).\nWhen a node has a `target`, COPY it verbatim into `act({action, target})`.\nDo NOT hand-craft a selector \u2014 guessed CSS like `button[name=\"...\"]` will not resolve.\n\nIf a node has no `target` (unnamed/non-semantic, or a scoped `within`/`filters`\nread), you may pass its visible text as `target` (plain text resolves), or\n`role \"name\"`. Avoid XPath and positional CSS.\n\n### Console + network \u2014 filter, don't dump\n\nBoth channels support `filters` and `limit` \u2014 use them instead of reading\neverything every time:\n- `observe({kind:\"console\", filters:{level_eq:\"error\"}})` \u2014 just JS errors.\n- `observe({kind:\"network\", filters:{status_gte:400}})` \u2014 just failed requests.\n- `limit` caps rows returned when you only need the latest few.\n\nCheck both after actions that plausibly trigger errors (submits, navigations,\nAPI calls) \u2014 not mechanically after every single `act`.\n\nRecord any errors as `console` or `network` bugs with the request URL / error\nmessage as `detail` and the screenshot path as `evidence` when relevant.\n\n### Network entries carry the WHY, not just the status\n\nEach row is a full exchange: `method`, `url`, `status`, `ok`, `durationMs`,\nand for API calls (`fetch`/`xhr`) the `requestBody`, `responseBody`, and\nredacted `requestHeaders`/`responseHeaders`.\n\n**A failing request is only half-reported without its `responseBody`.** When a\nsubmit fails, do NOT stop at \"POST /api/x returned 400\" \u2014 read the row and quote\nwhat the server actually said (`{\"error\":\"password too short\"}`); that string is\nwhat turns a finding into a fix. Same for the `requestBody`: it shows whether the\nUI even sent what you typed.\n\nCredential header values arrive as `<redacted, N chars>`. That is deliberate \u2014\npresence is what you need (a missing `cookie` explains a 401), never the secret.\n\nOther reads that pay off:\n- `filters:{duration_gte:1000}` \u2014 requests slow enough to be a UX bug.\n- `filters:{body_contains:\"error\"}` \u2014 failures that still returned HTTP 200.\n\nA default `network` read hides successful static assets (scripts, styles,\nimages) and tells you how many via `hidden` \u2014 on a dev server they outnumber real\nAPI calls ~15:1 and would crowd out everything worth seeing. Failed assets are\nalways shown (a 404 image is a real bug). To inspect assets deliberately, ask:\n`observe({kind:\"network\", filters:{resource_in:[\"script\",\"stylesheet\",\"image\"]}})`.\n\n### iframes \u2014 already in the tree\n\n`observe({kind:\"tree\"})` reads embedded documents too (payment fields, editors,\nconsent screens). A node inside one carries `frame` = the iframe's URL; its\n`bounds` are page coordinates, so clicking it needs nothing special. If a\nselector mysteriously fails to resolve on a node you can see, check whether it\nhas a `frame` \u2014 and prefer clicking the node object over a hand-written selector.\n\n### Tabs \u2014 a click can open one\n\nWhen more than one tab is open, every `act` result carries a `tabs` array\n(`index`, `url`, `title`, `active`). A click on an external link, an OAuth\nbutton, or `target=\"_blank\"` opens a new tab and **you are still on the old one**\n\u2014 if a click seems to have done nothing, check `tabs` before concluding the\nbutton is broken.\n\n- `observe({kind:\"tabs\"})` \u2014 list them any time.\n- `act({action:\"switch_tab\", target:\"1\"})` \u2014 drive tab 1 from now on. Console and\n network capture follow you; what the previous tab recorded is kept.\n\nSwitch back the same way when the popup flow is done.\n";
|
|
@@ -10,9 +10,8 @@ export const WEB_ADDENDUM_PROMPT = `\
|
|
|
10
10
|
## Web target — CDP reach
|
|
11
11
|
|
|
12
12
|
Your browser connection uses the Chrome DevTools Protocol (CDP).
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
input, and screenshots. Use it deliberately.
|
|
13
|
+
It reaches the current page: DOM, console, network, input, and screenshots.
|
|
14
|
+
Use it deliberately.
|
|
16
15
|
|
|
17
16
|
### CDP domains and when to reach for each
|
|
18
17
|
|
|
@@ -28,8 +27,9 @@ input, and screenshots. Use it deliberately.
|
|
|
28
27
|
Always try the structured path before asking for vision:
|
|
29
28
|
1. \`observe({kind:"tree"})\` — read element roles, names, bounds, enabled state.
|
|
30
29
|
2. If an element is not visible in the tree, try scrolling or waiting, then re-observe.
|
|
31
|
-
3. Use \`observe({kind:"console"})\` and \`observe({kind:"network"})\`
|
|
32
|
-
|
|
30
|
+
3. Use \`observe({kind:"console"})\` and \`observe({kind:"network"})\` (filtered — see
|
|
31
|
+
below) after actions that plausibly trigger errors — errors land there before
|
|
32
|
+
they surface visually.
|
|
33
33
|
4. Only after the tree gives you no answer: call \`look\` for pixels.
|
|
34
34
|
|
|
35
35
|
### Composing tree queries
|
|
@@ -60,15 +60,31 @@ The tree does not expose \`href\`s. To follow a link, \`act({action:"click"})\`
|
|
|
60
60
|
node. Do NOT fabricate a URL from a link's label (e.g. label "Help Center" →
|
|
61
61
|
navigating to \`/help-center\`): a guessed URL that 404s is YOUR error, not a site
|
|
62
62
|
bug. Only \`navigate\` to URLs given in the goal or seen in network entries. If a
|
|
63
|
-
link's click target is hidden (e.g. inside a closed menu),
|
|
64
|
-
|
|
63
|
+
link's click target is hidden (e.g. inside a closed menu), click the parent menu
|
|
64
|
+
item first, then re-observe.
|
|
65
65
|
|
|
66
|
-
###
|
|
66
|
+
### Verify input from the TREE, never from vision
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
Form controls carry their LIVE state in the tree: \`value\` (what an
|
|
69
|
+
input/textarea/select currently holds) and \`checked\` (checkbox/radio). \`name\`
|
|
70
|
+
stays the label, so you can still target the field by it.
|
|
71
|
+
|
|
72
|
+
After typing or toggling, confirm with one \`observe\`:
|
|
73
|
+
\`observe({kind:"tree", query:"input", fields:["name","value","checked"]})\`
|
|
74
|
+
|
|
75
|
+
NEVER spend a \`look\` asking "did my text land?" or "is the box checked now?" —
|
|
76
|
+
the tree answers exactly, instantly, and for free. Vision is for how things LOOK,
|
|
77
|
+
not for reading back your own input.
|
|
78
|
+
|
|
79
|
+
### Typing replaces nothing unless you say so
|
|
80
|
+
|
|
81
|
+
\`act({action:"type"})\` APPENDS to whatever the field already holds. Re-typing a
|
|
82
|
+
field you have used before yields \`old textnew text\` — and that doubled value is
|
|
83
|
+
YOUR bug, not the app's. Pass \`clear: true\` to replace the contents instead:
|
|
84
|
+
\`act({action:"type", target:"...", text:"...", clear:true})\`.
|
|
85
|
+
|
|
86
|
+
Use \`clear\` whenever the field may be non-empty: a retry, a second item through
|
|
87
|
+
the same form, or any field you have not just seen empty in the tree.
|
|
72
88
|
|
|
73
89
|
### Login bypass
|
|
74
90
|
|
|
@@ -88,13 +104,65 @@ If a node has no \`target\` (unnamed/non-semantic, or a scoped \`within\`/\`filt
|
|
|
88
104
|
read), you may pass its visible text as \`target\` (plain text resolves), or
|
|
89
105
|
\`role "name"\`. Avoid XPath and positional CSS.
|
|
90
106
|
|
|
91
|
-
### Console + network —
|
|
107
|
+
### Console + network — filter, don't dump
|
|
92
108
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
109
|
+
Both channels support \`filters\` and \`limit\` — use them instead of reading
|
|
110
|
+
everything every time:
|
|
111
|
+
- \`observe({kind:"console", filters:{level_eq:"error"}})\` — just JS errors.
|
|
112
|
+
- \`observe({kind:"network", filters:{status_gte:400}})\` — just failed requests.
|
|
113
|
+
- \`limit\` caps rows returned when you only need the latest few.
|
|
114
|
+
|
|
115
|
+
Check both after actions that plausibly trigger errors (submits, navigations,
|
|
116
|
+
API calls) — not mechanically after every single \`act\`.
|
|
96
117
|
|
|
97
118
|
Record any errors as \`console\` or \`network\` bugs with the request URL / error
|
|
98
119
|
message as \`detail\` and the screenshot path as \`evidence\` when relevant.
|
|
120
|
+
|
|
121
|
+
### Network entries carry the WHY, not just the status
|
|
122
|
+
|
|
123
|
+
Each row is a full exchange: \`method\`, \`url\`, \`status\`, \`ok\`, \`durationMs\`,
|
|
124
|
+
and for API calls (\`fetch\`/\`xhr\`) the \`requestBody\`, \`responseBody\`, and
|
|
125
|
+
redacted \`requestHeaders\`/\`responseHeaders\`.
|
|
126
|
+
|
|
127
|
+
**A failing request is only half-reported without its \`responseBody\`.** When a
|
|
128
|
+
submit fails, do NOT stop at "POST /api/x returned 400" — read the row and quote
|
|
129
|
+
what the server actually said (\`{"error":"password too short"}\`); that string is
|
|
130
|
+
what turns a finding into a fix. Same for the \`requestBody\`: it shows whether the
|
|
131
|
+
UI even sent what you typed.
|
|
132
|
+
|
|
133
|
+
Credential header values arrive as \`<redacted, N chars>\`. That is deliberate —
|
|
134
|
+
presence is what you need (a missing \`cookie\` explains a 401), never the secret.
|
|
135
|
+
|
|
136
|
+
Other reads that pay off:
|
|
137
|
+
- \`filters:{duration_gte:1000}\` — requests slow enough to be a UX bug.
|
|
138
|
+
- \`filters:{body_contains:"error"}\` — failures that still returned HTTP 200.
|
|
139
|
+
|
|
140
|
+
A default \`network\` read hides successful static assets (scripts, styles,
|
|
141
|
+
images) and tells you how many via \`hidden\` — on a dev server they outnumber real
|
|
142
|
+
API calls ~15:1 and would crowd out everything worth seeing. Failed assets are
|
|
143
|
+
always shown (a 404 image is a real bug). To inspect assets deliberately, ask:
|
|
144
|
+
\`observe({kind:"network", filters:{resource_in:["script","stylesheet","image"]}})\`.
|
|
145
|
+
|
|
146
|
+
### iframes — already in the tree
|
|
147
|
+
|
|
148
|
+
\`observe({kind:"tree"})\` reads embedded documents too (payment fields, editors,
|
|
149
|
+
consent screens). A node inside one carries \`frame\` = the iframe's URL; its
|
|
150
|
+
\`bounds\` are page coordinates, so clicking it needs nothing special. If a
|
|
151
|
+
selector mysteriously fails to resolve on a node you can see, check whether it
|
|
152
|
+
has a \`frame\` — and prefer clicking the node object over a hand-written selector.
|
|
153
|
+
|
|
154
|
+
### Tabs — a click can open one
|
|
155
|
+
|
|
156
|
+
When more than one tab is open, every \`act\` result carries a \`tabs\` array
|
|
157
|
+
(\`index\`, \`url\`, \`title\`, \`active\`). A click on an external link, an OAuth
|
|
158
|
+
button, or \`target="_blank"\` opens a new tab and **you are still on the old one**
|
|
159
|
+
— if a click seems to have done nothing, check \`tabs\` before concluding the
|
|
160
|
+
button is broken.
|
|
161
|
+
|
|
162
|
+
- \`observe({kind:"tabs"})\` — list them any time.
|
|
163
|
+
- \`act({action:"switch_tab", target:"1"})\` — drive tab 1 from now on. Console and
|
|
164
|
+
network capture follow you; what the previous tab recorded is kept.
|
|
165
|
+
|
|
166
|
+
Switch back the same way when the popup flow is done.
|
|
99
167
|
`;
|
|
100
168
|
//# sourceMappingURL=web-addendum.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-addendum.js","sourceRoot":"","sources":["../../../src/agent/prompts/web-addendum.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG
|
|
1
|
+
{"version":3,"file":"web-addendum.js","sourceRoot":"","sources":["../../../src/agent/prompts/web-addendum.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8JlC,CAAC"}
|
package/dist/cli/control.d.ts
CHANGED
|
@@ -15,5 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
/** `ui-debugger-mcp status` — print the active run's state + findings summary. */
|
|
17
17
|
export declare function runStatus(cwd?: string): Promise<void>;
|
|
18
|
+
/** Signal seam — `process.kill` in production, a stub under test. */
|
|
19
|
+
export type Kill = (pid: number, signal: NodeJS.Signals) => void;
|
|
18
20
|
/** `ui-debugger-mcp stop` — signal the server to tear the run down, mark state stopped. */
|
|
19
|
-
export declare function runStop(cwd?: string): Promise<void>;
|
|
21
|
+
export declare function runStop(cwd?: string, kill?: Kill): Promise<void>;
|
package/dist/cli/control.js
CHANGED
|
@@ -17,38 +17,9 @@ import { readFile } from 'node:fs/promises';
|
|
|
17
17
|
import { isAbsolute, join } from 'node:path';
|
|
18
18
|
import { loadWorkspaceDir } from '../config/load.js';
|
|
19
19
|
import { FindingsSchema } from '../findings/schema.js';
|
|
20
|
-
import {
|
|
21
|
-
import { markStatus, readState } from '../session/state-file.js';
|
|
20
|
+
import { ownerAlive } from '../session/process-identity.js';
|
|
21
|
+
import { markStatus, readState, restoreRunning } from '../session/state-file.js';
|
|
22
22
|
import { resolveProject, workspacePaths } from '../session/workspace.js';
|
|
23
|
-
/** Whether `pid` is a live process this user can see (`kill(pid, 0)`). */
|
|
24
|
-
function isAlive(pid) {
|
|
25
|
-
try {
|
|
26
|
-
process.kill(pid, 0);
|
|
27
|
-
return true;
|
|
28
|
-
}
|
|
29
|
-
catch (err) {
|
|
30
|
-
// EPERM = the process exists but is owned by another user — still "alive".
|
|
31
|
-
return err.code === 'EPERM';
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Is the recorded server *genuinely* still alive — not an unrelated process that
|
|
36
|
-
* inherited a recycled PID? A verified `match` is alive; a `stale` PID (recycled)
|
|
37
|
-
* or a `gone` PID is dead. When the identity can't be verified (non-Linux), fall
|
|
38
|
-
* back to a bare liveness probe — best effort, same as before this guard existed.
|
|
39
|
-
*/
|
|
40
|
-
function serverAlive(pid, check) {
|
|
41
|
-
if (check === 'match')
|
|
42
|
-
return true;
|
|
43
|
-
if (check === 'stale' || check === 'gone')
|
|
44
|
-
return false;
|
|
45
|
-
return isAlive(pid);
|
|
46
|
-
}
|
|
47
|
-
/** Resolve the recorded run's liveness, guarding against PID reuse. */
|
|
48
|
-
function checkServer(pid, identity) {
|
|
49
|
-
const check = verifyIdentity(pid, identity);
|
|
50
|
-
return { check, alive: serverAlive(pid, check) };
|
|
51
|
-
}
|
|
52
23
|
/** Read + validate a session's `findings.json`; `null` when absent/malformed. */
|
|
53
24
|
async function readFindings(sessionDir) {
|
|
54
25
|
try {
|
|
@@ -75,7 +46,7 @@ export async function runStatus(cwd = process.cwd()) {
|
|
|
75
46
|
console.log(`ui-debugger-mcp: no debug run recorded for '${project}'.`);
|
|
76
47
|
return;
|
|
77
48
|
}
|
|
78
|
-
const { check, alive } =
|
|
49
|
+
const { check, alive } = ownerAlive(state.pid, state.identity);
|
|
79
50
|
const findings = await readFindings(state.sessionDir);
|
|
80
51
|
// Server up + nothing settled yet → trust findings' live status; else the recorded terminal.
|
|
81
52
|
const verdict = alive && state.status === 'running' ? (findings?.status ?? 'running') : state.status;
|
|
@@ -83,7 +54,14 @@ export async function runStatus(cwd = process.cwd()) {
|
|
|
83
54
|
? `${findings.bugs.length} bugs, ${findings.visual.length} visual, ${findings.steps.length} steps`
|
|
84
55
|
: 'no findings yet';
|
|
85
56
|
// A recycled PID owns a different process now — say so rather than imply our server lives.
|
|
86
|
-
|
|
57
|
+
// If state says running but the server is dead (check not stale), report the mismatch.
|
|
58
|
+
const serverState = check === 'stale'
|
|
59
|
+
? 'not running (PID reused)'
|
|
60
|
+
: alive
|
|
61
|
+
? 'running'
|
|
62
|
+
: state.status === 'running'
|
|
63
|
+
? 'unknown (server died)'
|
|
64
|
+
: 'not running';
|
|
87
65
|
console.log(`ui-debugger-mcp — ${project}`);
|
|
88
66
|
console.log(` run: ${state.sessionId}`);
|
|
89
67
|
console.log(` target: ${state.target}`);
|
|
@@ -95,7 +73,9 @@ export async function runStatus(cwd = process.cwd()) {
|
|
|
95
73
|
console.log(` session: ${state.sessionDir}`);
|
|
96
74
|
}
|
|
97
75
|
/** `ui-debugger-mcp stop` — signal the server to tear the run down, mark state stopped. */
|
|
98
|
-
export async function runStop(cwd = process.cwd()) {
|
|
76
|
+
export async function runStop(cwd = process.cwd(), kill = (pid, signal) => {
|
|
77
|
+
process.kill(pid, signal);
|
|
78
|
+
}) {
|
|
99
79
|
const { project, stateJson } = stateJsonPath(cwd);
|
|
100
80
|
const state = await readState(stateJson);
|
|
101
81
|
if (!state) {
|
|
@@ -109,7 +89,7 @@ export async function runStop(cwd = process.cwd()) {
|
|
|
109
89
|
console.log(`ui-debugger-mcp: no active debug run to stop for '${project}' (last run '${state.sessionId}' ${state.status}).`);
|
|
110
90
|
return;
|
|
111
91
|
}
|
|
112
|
-
const { check, alive } =
|
|
92
|
+
const { check, alive } = ownerAlive(state.pid, state.identity);
|
|
113
93
|
// The recorded PID is alive but now owns an *unrelated* process (it was recycled
|
|
114
94
|
// after our server died). Signaling it would kill an innocent process — don't.
|
|
115
95
|
// Our server is provably gone, so mark the run stopped without ever signaling.
|
|
@@ -119,15 +99,21 @@ export async function runStop(cwd = process.cwd()) {
|
|
|
119
99
|
return;
|
|
120
100
|
}
|
|
121
101
|
if (alive) {
|
|
122
|
-
|
|
102
|
+
// Record the terminal status BEFORE signaling. The server's SIGTERM handler
|
|
103
|
+
// ends the run and calls `markStatus('ended')`, whose read-modify-write can
|
|
104
|
+
// only preserve our `stopped` if it is already on disk when the signal lands.
|
|
105
|
+
// Marking afterwards races that handler and can leave `ended` — or nothing.
|
|
106
|
+
await markStatus(stateJson, 'stopped');
|
|
107
|
+
const signaled = signalStop(state.pid, kill);
|
|
123
108
|
if (!signaled.ok) {
|
|
124
109
|
// The signal failed for a reason other than the process already being gone
|
|
125
|
-
// (e.g. EPERM). Teardown did NOT happen —
|
|
110
|
+
// (e.g. EPERM). Teardown did NOT happen — roll the mark back rather than
|
|
111
|
+
// report a live run as stopped.
|
|
112
|
+
await restoreRunning(stateJson);
|
|
126
113
|
console.error(`ui-debugger-mcp: failed to signal server (pid ${state.pid}): ${signaled.reason}. Run '${state.sessionId}' left as-is.`);
|
|
127
114
|
process.exitCode = 1;
|
|
128
115
|
return;
|
|
129
116
|
}
|
|
130
|
-
await markStatus(stateJson, 'stopped');
|
|
131
117
|
const how = signaled.gone ? `pid ${state.pid} already exited` : `SIGTERM → pid ${state.pid}`;
|
|
132
118
|
console.log(`ui-debugger-mcp: stopping run '${state.sessionId}' (${how}).`);
|
|
133
119
|
return;
|
|
@@ -140,9 +126,9 @@ export async function runStop(cwd = process.cwd()) {
|
|
|
140
126
|
* the liveness check and here — teardown already happened) is treated as benign
|
|
141
127
|
* (`gone`); any other failure surfaces so the caller never reports a false stop.
|
|
142
128
|
*/
|
|
143
|
-
function signalStop(pid) {
|
|
129
|
+
function signalStop(pid, kill) {
|
|
144
130
|
try {
|
|
145
|
-
|
|
131
|
+
kill(pid, 'SIGTERM');
|
|
146
132
|
return { ok: true, gone: false };
|
|
147
133
|
}
|
|
148
134
|
catch (err) {
|
package/dist/cli/control.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"control.js","sourceRoot":"","sources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AACH,CAAC;AAED,sDAAsD;AACtD,SAAS,QAAQ,CAAC,CAAS,EAAE,GAAW;IACtC,OAAO,CAAC,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC;AACzD,CAAC"}
|
package/dist/cli/help.d.ts
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* No project config needed. Print and exit(0).
|
|
5
5
|
*/
|
|
6
|
-
/** Print usage
|
|
6
|
+
/** Print usage without exiting — lets a caller pick its own exit code afterward. */
|
|
7
|
+
export declare function printUsage(): void;
|
|
8
|
+
/** Print usage and exit 0 (the `--help`/`-h` path). */
|
|
7
9
|
export declare function runHelp(): void;
|
|
8
10
|
/** Print version and exit. */
|
|
9
11
|
export declare function runVersion(): void;
|
package/dist/cli/help.js
CHANGED
|
@@ -28,9 +28,13 @@ EXAMPLES:
|
|
|
28
28
|
DOCS:
|
|
29
29
|
https://github.com/developerz-ai/ui-debugger-mcp
|
|
30
30
|
`;
|
|
31
|
-
/** Print usage
|
|
32
|
-
export function
|
|
31
|
+
/** Print usage without exiting — lets a caller pick its own exit code afterward. */
|
|
32
|
+
export function printUsage() {
|
|
33
33
|
console.log(USAGE);
|
|
34
|
+
}
|
|
35
|
+
/** Print usage and exit 0 (the `--help`/`-h` path). */
|
|
36
|
+
export function runHelp() {
|
|
37
|
+
printUsage();
|
|
34
38
|
process.exit(0);
|
|
35
39
|
}
|
|
36
40
|
/** Print version and exit. */
|
package/dist/cli/help.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help.js","sourceRoot":"","sources":["../../src/cli/help.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,KAAK,GAAG,GAAG,IAAI;;;IAGjB,IAAI;;;;;;;;;;;;;;;;;;;;CAoBP,CAAC;AAEF,
|
|
1
|
+
{"version":3,"file":"help.js","sourceRoot":"","sources":["../../src/cli/help.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,KAAK,GAAG,GAAG,IAAI;;;IAGjB,IAAI;;;;;;;;;;;;;;;;;;;;CAoBP,CAAC;AAEF,oFAAoF;AACpF,MAAM,UAAU,UAAU;IACxB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACrB,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,OAAO;IACrB,UAAU,EAAE,CAAC;IACb,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,8BAA8B;AAC9B,MAAM,UAAU,UAAU;IACxB,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,KAAK,OAAO,EAAE,CAAC,CAAC;IACnC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"}
|
package/dist/cli/init.d.ts
CHANGED
|
@@ -4,15 +4,12 @@
|
|
|
4
4
|
* Idempotent: never clobbers existing files. Runs in `process.cwd()`.
|
|
5
5
|
*
|
|
6
6
|
* Steps:
|
|
7
|
-
* 1. mkdir
|
|
7
|
+
* 1. mkdir the workspace dir (an existing config's `workspace` wins over the
|
|
8
|
+
* `./tmp/ui-debugger-mcp` default — see {@link existingWorkspace})
|
|
8
9
|
* 2. write .ui-debugger-mcp.json (only if absent)
|
|
9
|
-
* 3. add
|
|
10
|
+
* 3. add the workspace dir to .gitignore (only if the line is missing)
|
|
10
11
|
* 4. print .mcp.json snippet (never writes the API key)
|
|
11
12
|
*/
|
|
12
|
-
import { UiDebuggerError } from '../errors.js';
|
|
13
|
-
export declare class InitError extends UiDebuggerError {
|
|
14
|
-
constructor(message: string);
|
|
15
|
-
}
|
|
16
13
|
/**
|
|
17
14
|
* Run the init scaffold in `cwd`.
|
|
18
15
|
* Throws `InitError` on filesystem failures.
|
package/dist/cli/init.js
CHANGED
|
@@ -4,22 +4,16 @@
|
|
|
4
4
|
* Idempotent: never clobbers existing files. Runs in `process.cwd()`.
|
|
5
5
|
*
|
|
6
6
|
* Steps:
|
|
7
|
-
* 1. mkdir
|
|
7
|
+
* 1. mkdir the workspace dir (an existing config's `workspace` wins over the
|
|
8
|
+
* `./tmp/ui-debugger-mcp` default — see {@link existingWorkspace})
|
|
8
9
|
* 2. write .ui-debugger-mcp.json (only if absent)
|
|
9
|
-
* 3. add
|
|
10
|
+
* 3. add the workspace dir to .gitignore (only if the line is missing)
|
|
10
11
|
* 4. print .mcp.json snippet (never writes the API key)
|
|
11
12
|
*/
|
|
12
13
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
13
|
-
import { join } from 'node:path';
|
|
14
|
-
import { DEFAULT_MODELS, DEFAULT_WORKSPACE } from '../config/load.js';
|
|
15
|
-
import {
|
|
16
|
-
export class InitError extends UiDebuggerError {
|
|
17
|
-
constructor(message) {
|
|
18
|
-
super(message);
|
|
19
|
-
this.name = 'InitError';
|
|
20
|
-
Object.setPrototypeOf(this, InitError.prototype);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
14
|
+
import { join, relative, resolve, sep } from 'node:path';
|
|
15
|
+
import { CONFIG_FILENAME, DEFAULT_MODELS, DEFAULT_WORKSPACE } from '../config/load.js';
|
|
16
|
+
import { InitError } from '../errors.js';
|
|
23
17
|
/** Starter project config written on `init` (only if absent). */
|
|
24
18
|
const STARTER_CONFIG = JSON.stringify({
|
|
25
19
|
models: {
|
|
@@ -49,13 +43,61 @@ const MCP_JSON_SNIPPET = `{
|
|
|
49
43
|
}
|
|
50
44
|
}
|
|
51
45
|
}`;
|
|
46
|
+
/** Default ignore line — matches the `workspace` default (`./tmp/ui-debugger-mcp`). */
|
|
47
|
+
const DEFAULT_IGNORE_LINE = 'tmp/';
|
|
48
|
+
/**
|
|
49
|
+
* Read the `workspace` field of an already-present `.ui-debugger-mcp.json`, if any.
|
|
50
|
+
* Deliberately lenient — not a full `ConfigSchema` parse — because `init` only needs
|
|
51
|
+
* to know where to mkdir/gitignore, not validate the whole file; a config with an
|
|
52
|
+
* unrelated schema error must not block re-running `init`. Falls back to
|
|
53
|
+
* {@link DEFAULT_WORKSPACE} when the file is absent, unparseable, or has no string
|
|
54
|
+
* `workspace` field.
|
|
55
|
+
*/
|
|
56
|
+
function existingWorkspace(cwd) {
|
|
57
|
+
const configPath = join(cwd, CONFIG_FILENAME);
|
|
58
|
+
if (!existsSync(configPath))
|
|
59
|
+
return DEFAULT_WORKSPACE;
|
|
60
|
+
let raw;
|
|
61
|
+
try {
|
|
62
|
+
raw = readFileSync(configPath, 'utf8');
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
throw new InitError(`Failed to read ${CONFIG_FILENAME}: ${e instanceof Error ? e.message : String(e)}`);
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
const data = JSON.parse(raw);
|
|
69
|
+
const workspace = data?.workspace;
|
|
70
|
+
if (typeof workspace === 'string' && workspace.length > 0)
|
|
71
|
+
return workspace;
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
// not JSON, or no usable `workspace` field — fall back to the default; full
|
|
75
|
+
// validation happens at server boot (`loadConfig`), not here.
|
|
76
|
+
}
|
|
77
|
+
return DEFAULT_WORKSPACE;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The `.gitignore` line for `workspaceDir`. The default workspace keeps the
|
|
81
|
+
* historical broad `tmp/` line; a custom workspace gets its own relative,
|
|
82
|
+
* trailing-slash line so it's actually ignored instead of missed. `null` when the
|
|
83
|
+
* workspace resolves outside `cwd` — nothing to add, the caller must handle it.
|
|
84
|
+
*/
|
|
85
|
+
function gitignoreLineFor(cwd, workspaceDir, workspaceValue) {
|
|
86
|
+
if (workspaceValue === DEFAULT_WORKSPACE)
|
|
87
|
+
return DEFAULT_IGNORE_LINE;
|
|
88
|
+
const rel = relative(cwd, workspaceDir);
|
|
89
|
+
if (rel.startsWith('..'))
|
|
90
|
+
return null;
|
|
91
|
+
return `${rel.split(sep).join('/')}/`;
|
|
92
|
+
}
|
|
52
93
|
/**
|
|
53
94
|
* Run the init scaffold in `cwd`.
|
|
54
95
|
* Throws `InitError` on filesystem failures.
|
|
55
96
|
*/
|
|
56
97
|
export function runInit(cwd = process.cwd()) {
|
|
57
|
-
// 1. mkdir workspace
|
|
58
|
-
const
|
|
98
|
+
// 1. mkdir workspace — respects an already-present config's `workspace` field.
|
|
99
|
+
const workspaceValue = existingWorkspace(cwd);
|
|
100
|
+
const workspaceDir = resolve(cwd, workspaceValue);
|
|
59
101
|
try {
|
|
60
102
|
mkdirSync(workspaceDir, { recursive: true });
|
|
61
103
|
}
|
|
@@ -77,9 +119,15 @@ export function runInit(cwd = process.cwd()) {
|
|
|
77
119
|
}
|
|
78
120
|
console.log(`✓ created .ui-debugger-mcp.json`);
|
|
79
121
|
}
|
|
80
|
-
// 3. add
|
|
122
|
+
// 3. add the workspace dir to .gitignore (only if the line is missing)
|
|
81
123
|
const gitignorePath = join(cwd, '.gitignore');
|
|
82
|
-
|
|
124
|
+
const ignoreLine = gitignoreLineFor(cwd, workspaceDir, workspaceValue);
|
|
125
|
+
if (ignoreLine) {
|
|
126
|
+
ensureGitignoreLine(gitignorePath, ignoreLine);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
console.log(` (skip) workspace is outside the project root — add it to .gitignore manually`);
|
|
130
|
+
}
|
|
83
131
|
// 4. print .mcp.json snippet
|
|
84
132
|
console.log(`
|
|
85
133
|
Paste into your .mcp.json (do NOT commit your API key):
|
package/dist/cli/init.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/cli/init.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3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,IAAI,IAAI,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detect that `.ui-debugger-mcp.json` changed after the server read it.
|
|
3
|
+
*
|
|
4
|
+
* Config is resolved ONCE at boot (`main.ts`): it decides the workspace layout,
|
|
5
|
+
* the provider, the per-role models and the self-look probe, all of which are
|
|
6
|
+
* wired into long-lived objects. Re-reading it mid-process would leave those
|
|
7
|
+
* half-updated, so the server keeps its boot-time view — correctly.
|
|
8
|
+
*
|
|
9
|
+
* What was NOT correct is doing that silently. Observed end-to-end: a run failed
|
|
10
|
+
* on a bad model id, the caller found the typo, fixed the file, started a new run
|
|
11
|
+
* — and got the identical error, because the server was still on the old config.
|
|
12
|
+
* From the caller's side the fix simply had no effect, with nothing anywhere
|
|
13
|
+
* saying why. It then retried the same thing again.
|
|
14
|
+
*
|
|
15
|
+
* So: fingerprint the file at boot, compare before each run, and if it moved,
|
|
16
|
+
* fail loud with the one instruction that actually resolves it. A stale config is
|
|
17
|
+
* a bad assumption, and the house rule is to crash on those rather than run on.
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Content fingerprint of the project's config file — `null` when it is absent or
|
|
21
|
+
* unreadable (a project running on defaults has nothing to drift from).
|
|
22
|
+
*
|
|
23
|
+
* Contents, not mtime: editors and formatters rewrite files without changing
|
|
24
|
+
* anything that matters, and a spurious "restart me" is its own kind of noise.
|
|
25
|
+
*/
|
|
26
|
+
export declare function configFingerprint(cwd: string): string | null;
|
|
27
|
+
/**
|
|
28
|
+
* A comparison against the fingerprint taken at boot. Returns whether the file
|
|
29
|
+
* has changed since — including a config that was created or deleted while the
|
|
30
|
+
* server was up, both of which change what a run would do.
|
|
31
|
+
*/
|
|
32
|
+
export declare function makeConfigWatch(cwd: string): () => boolean;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detect that `.ui-debugger-mcp.json` changed after the server read it.
|
|
3
|
+
*
|
|
4
|
+
* Config is resolved ONCE at boot (`main.ts`): it decides the workspace layout,
|
|
5
|
+
* the provider, the per-role models and the self-look probe, all of which are
|
|
6
|
+
* wired into long-lived objects. Re-reading it mid-process would leave those
|
|
7
|
+
* half-updated, so the server keeps its boot-time view — correctly.
|
|
8
|
+
*
|
|
9
|
+
* What was NOT correct is doing that silently. Observed end-to-end: a run failed
|
|
10
|
+
* on a bad model id, the caller found the typo, fixed the file, started a new run
|
|
11
|
+
* — and got the identical error, because the server was still on the old config.
|
|
12
|
+
* From the caller's side the fix simply had no effect, with nothing anywhere
|
|
13
|
+
* saying why. It then retried the same thing again.
|
|
14
|
+
*
|
|
15
|
+
* So: fingerprint the file at boot, compare before each run, and if it moved,
|
|
16
|
+
* fail loud with the one instruction that actually resolves it. A stale config is
|
|
17
|
+
* a bad assumption, and the house rule is to crash on those rather than run on.
|
|
18
|
+
*/
|
|
19
|
+
import { readFileSync } from 'node:fs';
|
|
20
|
+
import { join } from 'node:path';
|
|
21
|
+
import { CONFIG_FILENAME } from './load.js';
|
|
22
|
+
/**
|
|
23
|
+
* Content fingerprint of the project's config file — `null` when it is absent or
|
|
24
|
+
* unreadable (a project running on defaults has nothing to drift from).
|
|
25
|
+
*
|
|
26
|
+
* Contents, not mtime: editors and formatters rewrite files without changing
|
|
27
|
+
* anything that matters, and a spurious "restart me" is its own kind of noise.
|
|
28
|
+
*/
|
|
29
|
+
export function configFingerprint(cwd) {
|
|
30
|
+
try {
|
|
31
|
+
const raw = readFileSync(join(cwd, CONFIG_FILENAME), 'utf8');
|
|
32
|
+
return Bun.hash(raw).toString(16);
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A comparison against the fingerprint taken at boot. Returns whether the file
|
|
40
|
+
* has changed since — including a config that was created or deleted while the
|
|
41
|
+
* server was up, both of which change what a run would do.
|
|
42
|
+
*/
|
|
43
|
+
export function makeConfigWatch(cwd) {
|
|
44
|
+
const atBoot = configFingerprint(cwd);
|
|
45
|
+
return () => configFingerprint(cwd) !== atBoot;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=fingerprint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fingerprint.js","sourceRoot":"","sources":["../../src/config/fingerprint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAW;IAC3C,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,YAAY,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,EAAE,MAAM,CAAC,CAAC;QAC7D,OAAO,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACpC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,GAAW;IACzC,MAAM,MAAM,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;IACtC,OAAO,GAAG,EAAE,CAAC,iBAAiB,CAAC,GAAG,CAAC,KAAK,MAAM,CAAC;AACjD,CAAC"}
|
package/dist/config/load.d.ts
CHANGED
|
@@ -21,7 +21,13 @@ export declare const CONFIG_FILENAME = ".ui-debugger-mcp.json";
|
|
|
21
21
|
export declare const OPENROUTER_BASE_URL = "https://openrouter.ai/api/v1";
|
|
22
22
|
/** Default workspace dir (per-project sessions, profiles, logs). */
|
|
23
23
|
export declare const DEFAULT_WORKSPACE = "./tmp/ui-debugger-mcp";
|
|
24
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* Per-role model defaults — deepseek for text (driver + summary), qwen-vl for image.
|
|
26
|
+
*
|
|
27
|
+
* Plain catalog ids, no routing suffix: the router rejects `#uptime` outright
|
|
28
|
+
* (`… is not a valid model ID`, HTTP 400), so shipping it as the default driver
|
|
29
|
+
* made a fresh install fail on its very first run. See `idea/models.md`.
|
|
30
|
+
*/
|
|
25
31
|
export declare const DEFAULT_MODELS: ResolvedModels;
|
|
26
32
|
/** Fully resolved per-role models — every role present after defaulting. */
|
|
27
33
|
export interface ResolvedModels {
|