@ia-qa/pal 1.7.1 → 1.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.
@@ -0,0 +1,157 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.cliEntryPath = void 0;
37
+ exports.shortcutName = shortcutName;
38
+ exports.planPalShortcut = planPalShortcut;
39
+ exports.writeWindowsLnk = writeWindowsLnk;
40
+ exports.installPalShortcut = installPalShortcut;
41
+ const fs = __importStar(require("fs"));
42
+ const path = __importStar(require("path"));
43
+ const child_process_1 = require("child_process");
44
+ const shortcut_js_1 = require("@ia-qa/self-healing/dist/ui/shortcut.js");
45
+ const icon_js_1 = require("@ia-qa/self-healing/dist/ui/icon.js");
46
+ const quoteWin = (s) => `"${s.replace(/"/g, '""')}"`;
47
+ const quotePosix = (s) => `'${s.replace(/'/g, `'\\''`)}'`;
48
+ function shortcutName(projectDir) {
49
+ // The project in the name: one icon per project, and "ia-qa-pal" alone names nothing on a desktop holding three.
50
+ return `ia-qa-pal — ${path.basename(projectDir) || 'project'}`.replace(/[<>:"/\\|?*]/g, '-');
51
+ }
52
+ function planPalShortcut(opts) {
53
+ const name = shortcutName(opts.projectDir);
54
+ const description = 'Open ia-qa-pal on this project — ia-qa.com';
55
+ if (opts.platform === 'win32') {
56
+ const ico = path.join(opts.projectDir, '.ia-qa', 'pal', 'ia-qa-pal.ico');
57
+ return {
58
+ name,
59
+ files: [],
60
+ lnk: {
61
+ file: path.join(opts.desktop, `${name}.lnk`),
62
+ target: opts.nodePath,
63
+ args: `${quoteWin(opts.cliEntry)} ui --config ${quoteWin(opts.projectDir)}`,
64
+ workingDir: opts.projectDir,
65
+ iconPath: ico,
66
+ description,
67
+ },
68
+ icoPath: ico,
69
+ };
70
+ }
71
+ if (opts.platform === 'darwin') {
72
+ return {
73
+ name,
74
+ files: [
75
+ {
76
+ file: path.join(opts.desktop, `${name}.command`),
77
+ contents: `#!/bin/sh\n# ${description}\nexec ${quotePosix(opts.nodePath)} ${quotePosix(opts.cliEntry)} ui --config ${quotePosix(opts.projectDir)}\n`,
78
+ mode: 0o755,
79
+ },
80
+ ],
81
+ defaultIconOnly: true,
82
+ };
83
+ }
84
+ return {
85
+ name,
86
+ files: [
87
+ {
88
+ file: path.join(opts.desktop, `${name}.desktop`),
89
+ contents: `[Desktop Entry]\nType=Application\nName=${name}\nComment=${description}\nIcon=${opts.logoPath}\n` +
90
+ `Exec=${quotePosix(opts.nodePath)} ${quotePosix(opts.cliEntry)} ui --config ${quotePosix(opts.projectDir)}\n` +
91
+ `Terminal=false\nCategories=Development;\n`,
92
+ mode: 0o755,
93
+ },
94
+ ],
95
+ };
96
+ }
97
+ /** Every value travels as an environment variable, never inside the script: a path with a quote would run as PowerShell. */
98
+ function writeWindowsLnk(lnk) {
99
+ const script = '$s = (New-Object -ComObject WScript.Shell).CreateShortcut($env:IAQA_LNK); ' +
100
+ '$s.TargetPath = $env:IAQA_TARGET; $s.Arguments = $env:IAQA_ARGS; ' +
101
+ '$s.WorkingDirectory = $env:IAQA_CWD; $s.Description = $env:IAQA_DESC; $s.WindowStyle = 7; ' +
102
+ 'if (Test-Path $env:IAQA_ICON) { $s.IconLocation = $env:IAQA_ICON }; $s.Save()';
103
+ try {
104
+ (0, child_process_1.execFileSync)('powershell.exe', ['-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-Command', script], {
105
+ stdio: 'ignore',
106
+ timeout: 15000,
107
+ env: { ...process.env, IAQA_LNK: lnk.file, IAQA_TARGET: lnk.target, IAQA_ARGS: lnk.args, IAQA_CWD: lnk.workingDir, IAQA_DESC: lnk.description, IAQA_ICON: lnk.iconPath },
108
+ });
109
+ return fs.existsSync(lnk.file);
110
+ }
111
+ catch {
112
+ return false;
113
+ }
114
+ }
115
+ const cliEntryPath = () => path.join(__dirname, 'cli', 'index.js');
116
+ exports.cliEntryPath = cliEntryPath;
117
+ /**
118
+ * Write the icon for this project. `desktop` is injectable so a test never writes to a real one.
119
+ */
120
+ function installPalShortcut(projectDir, opts = {}) {
121
+ const desktop = opts.desktop === undefined ? (0, shortcut_js_1.desktopDir)() : opts.desktop;
122
+ if (!desktop)
123
+ return { ok: false, notes: [], error: 'Could not find your desktop folder, so nothing was written.' };
124
+ const cliEntry = opts.cliEntry ?? (0, exports.cliEntryPath)();
125
+ const plan = planPalShortcut({ platform: opts.platform ?? process.platform, desktop, projectDir, nodePath: process.execPath, cliEntry, logoPath: (0, icon_js_1.brandLogoPath)() });
126
+ const notes = [];
127
+ // npx runs from a cache it may clear: an icon pointing there works today and not next month.
128
+ if (/[\\/]_npx[\\/]/.test(cliEntry)) {
129
+ notes.push('pal is running from npx\'s temporary cache, which npm may clear — install it in the project (npm i -D @ia-qa/pal) and create the icon again, so it keeps working.');
130
+ }
131
+ try {
132
+ for (const f of plan.files) {
133
+ fs.writeFileSync(f.file, f.contents, 'utf8');
134
+ if (f.mode !== undefined)
135
+ fs.chmodSync(f.file, f.mode);
136
+ }
137
+ let icon = !plan.defaultIconOnly && !plan.lnk;
138
+ if (plan.lnk && plan.icoPath) {
139
+ const png = (0, icon_js_1.readBrandLogo)();
140
+ const ico = png ? (0, icon_js_1.pngToIco)(png) : null;
141
+ if (ico) {
142
+ fs.mkdirSync(path.dirname(plan.icoPath), { recursive: true });
143
+ fs.writeFileSync(plan.icoPath, ico);
144
+ icon = true;
145
+ }
146
+ if (!writeWindowsLnk(plan.lnk))
147
+ return { ok: false, notes, error: 'Windows refused to create the shortcut (PowerShell is blocked on this machine).' };
148
+ }
149
+ if (plan.defaultIconOnly)
150
+ notes.push('macOS opens it in Terminal and keeps its default icon.');
151
+ return { ok: true, file: plan.lnk?.file ?? plan.files[0].file, icon, notes };
152
+ }
153
+ catch (err) {
154
+ return { ok: false, notes, error: err instanceof Error ? err.message : String(err) };
155
+ }
156
+ }
157
+ //# sourceMappingURL=shortcut.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shortcut.js","sourceRoot":"","sources":["../src/shortcut.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,oCAGC;AAED,0CA6CC;AAGD,0CAgBC;AAgBD,gDA+BC;AA1JD,uCAAyB;AACzB,2CAA6B;AAC7B,iDAA6C;AAC7C,yEAAqE;AACrE,iEAA6F;AA+B7F,MAAM,QAAQ,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC;AAC7D,MAAM,UAAU,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAA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C;QACb,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;IACvF,CAAC;AACH,CAAC"}
package/dist/ui/page.js CHANGED
@@ -33,6 +33,8 @@ main{max-width:1000px;margin:0 auto;padding:22px 16px 60px}
33
33
  h1{font-size:24px;margin:0;letter-spacing:-.02em}
34
34
  .hello{opacity:.92;font-size:14px}
35
35
  .where{margin-top:10px;font-size:14px;opacity:.95;overflow-wrap:anywhere;position:relative;z-index:1}
36
+ .chip.chipBtn{margin-left:0;border:0;color:#fff;cursor:pointer;font:inherit;font-size:13px;font-weight:600}
37
+ .chip.chipBtn:hover:not(:disabled){background:#ffffff4d;box-shadow:none}
36
38
  .chip{margin-left:auto;display:inline-flex;align-items:center;gap:8px;background:#ffffff2e;border-radius:999px;padding:5px 12px;font-size:13px;font-weight:600}
37
39
  .dot{width:9px;height:9px;border-radius:50%;background:#fff;opacity:.7}
38
40
  .dot.live{background:#4ade80;opacity:1;box-shadow:0 0 0 0 #4ade80aa;animation:pulse 1.4s infinite}
@@ -82,6 +84,10 @@ li:first-child{border-top:0}
82
84
  .notice.bad{border-color:var(--bad);background:#ef444414}
83
85
  .notice.ok{border-color:var(--ok);background:#10b98114}
84
86
  .hidden{display:none!important}
87
+ input[type=url]{font:inherit;border:1px solid var(--line);background:var(--card);color:var(--ink);border-radius:10px;padding:7px 10px;min-width:min(420px,100%)}
88
+ .choices{display:grid;gap:6px;margin:6px 0}
89
+ .choices label{display:flex;gap:8px;align-items:flex-start;cursor:pointer;flex-wrap:wrap}
90
+ .q{font-weight:700;margin:14px 0 4px}
85
91
  footer{color:var(--muted);font-size:13px;margin-top:24px;text-align:center}
86
92
  #confetti{position:fixed;inset:0;pointer-events:none;overflow:hidden;z-index:9}
87
93
  #confetti i{position:absolute;top:-12px;width:9px;height:14px;border-radius:2px;animation:fall 2.6s ease-in forwards}
@@ -94,10 +100,40 @@ footer{color:var(--muted);font-size:13px;margin-top:24px;text-align:center}
94
100
  <div class="mascot">🧭</div>
95
101
  <div><h1>ia-qa-pal</h1><div class="hello" id="hello">Your QA pal — it walks your app and tells you what moved.</div></div>
96
102
  <span class="chip"><span class="dot" id="liveDot"></span><span id="liveWord">Idle</span></span>
103
+ <button class="chip chipBtn" id="healLink" title="ia-qa-heal ui — decide the rows the tour could not, apply repairs, see the drift history">🔧 Repair console ↗</button>
104
+ <button class="chip chipBtn" id="iconBtn" title="An icon on your desktop that opens pal on this project — no terminal next time">🖥️ Desktop icon</button>
97
105
  </div>
98
106
  <div class="where" id="where">loading…</div>
99
107
  </header>
100
108
 
109
+ <div id="browserBox" class="notice hidden"></div>
110
+
111
+ <section class="card hidden" id="setupCard">
112
+ <h2><span class="ic">🧰</span>Set this project up</h2>
113
+ <p class="muted">A few questions, then a preview of the one file this writes (<code>.ia-qa/config.json</code>). Nothing is written before you say so, no field takes a password, and an existing config is never overwritten.</p>
114
+ <div class="q">1. Where does the app live?</div>
115
+ <input type="url" id="setupUrl" placeholder="https://your-app.example" autocomplete="off" spellcheck="false">
116
+ <div class="q">2. Does it ask you to log in?</div>
117
+ <div class="choices">
118
+ <label><input type="radio" name="setupLogin" value="none" checked> No</label>
119
+ <label><input type="radio" name="setupLogin" value="browser"> Yes — I log in by hand in a browser (SSO, MFA, anything). A window opens for you right after.</label>
120
+ <label><input type="radio" name="setupLogin" value="session"> Yes — my tests already save a Playwright session file <input type="text" id="setupSession" placeholder="path/to/storageState.json" spellcheck="false"></label>
121
+ </div>
122
+ <div id="setupTestsBox" class="hidden">
123
+ <div class="q">3. Your tests</div>
124
+ <div class="choices" id="setupTests"></div>
125
+ <div class="row"><span class="muted">run with</span><input type="text" id="setupCommand" placeholder="npx playwright test" spellcheck="false"></div>
126
+ </div>
127
+ <p class="muted">Finding the pages reads <span id="setupHost">your app</span>'s sitemap.xml — a plain request to your app. Without one, it follows your app's links in a headless browser: same site, reading only, at most 50 pages.</p>
128
+ <div class="row"><button class="primary" id="setupPreview">Show me what it writes</button></div>
129
+ <div id="setupOut" class="hidden">
130
+ <div class="line" id="setupLines"></div>
131
+ <ul id="setupSummary"></ul>
132
+ <div class="row"><button class="primary" id="setupWrite">✅ Write it</button></div>
133
+ </div>
134
+ <div id="setupNotice" class="notice hidden"></div>
135
+ </section>
136
+
101
137
  <section class="card" id="whoCard">
102
138
  <h2><span class="ic">👥</span>Who the tour runs as</h2>
103
139
  <p class="muted" id="whoHelp">An admin and a guest see different apps. A tour never picks one for you.</p>
@@ -142,8 +178,15 @@ footer{color:var(--muted);font-size:13px;margin-top:24px;text-align:center}
142
178
  <div id="resultEmpty" class="idle"><span class="big">🗺️</span><span id="resultEmptyText">No finished tour yet — the first one draws the map everything else is compared with.</span></div>
143
179
  <div id="result" class="hidden">
144
180
  <div class="row"><span class="mood" id="mood"></span><span id="resultHead"></span></div>
181
+ <div class="muted" id="headline"></div>
182
+ <div id="readFirst"></div>
183
+ <div id="brokenBox" class="hidden">
184
+ <h2 style="margin:14px 0 6px"><span class="ic">🔴</span>Broken</h2>
185
+ <ul id="brokenList"></ul>
186
+ </div>
145
187
  <div class="stats" id="stats"></div>
146
188
  <div class="muted" id="resultCounts"></div>
189
+ <div id="healCta" class="notice hidden"><span id="healCtaText"></span> <button class="primary" id="healCtaBtn">🔧 Decide and repair in the repair console ↗</button></div>
147
190
  <div class="row"><a id="reportLink" target="_blank" rel="noopener">Open the full report →</a></div>
148
191
  </div>
149
192
  <h2 style="margin-top:18px"><span class="ic">📈</span>History</h2>
@@ -151,6 +194,15 @@ footer{color:var(--muted);font-size:13px;margin-top:24px;text-align:center}
151
194
  <ul id="history"></ul>
152
195
  </section>
153
196
 
197
+ <section class="card hidden" id="discCard">
198
+ <h2><span class="ic">🗺️</span>What exists — and what your tests miss</h2>
199
+ <p class="muted" id="discIntro">Every page a visitor can reach, with its forms and fields. The scan opens your app in a local browser — same site, reading only. Nothing is sent anywhere.</p>
200
+ <div id="discJob" class="notice hidden"></div>
201
+ <ul id="discScan"></ul>
202
+ <div id="discCov"></div>
203
+ <div class="row"><button id="discScanBtn">🔎 Scan the app</button><a id="discReport" class="hidden" target="_blank" rel="noopener">Open the app map →</a></div>
204
+ </section>
205
+
154
206
  <section class="card">
155
207
  <h2><span class="ic">🔐</span>Secrets</h2>
156
208
  <p class="muted">Listed by name only — a value is never shown here. You can type one in once, to store it in <span id="store"></span>; it goes nowhere else, and <code>.ia-qa/config.json</code> is not changed. A variable set in your shell still wins, so CI is unaffected. Secrets kept in AWS are not checked from this page — that would call AWS.</p>
@@ -205,7 +257,12 @@ footer{color:var(--muted);font-size:13px;margin-top:24px;text-align:center}
205
257
  function renderPersonas(p) {
206
258
  const list = q('personas'); list.textContent = '';
207
259
  const people = (p.personas || []);
208
- if (people.length === 0) list.appendChild(el('li', 'No named users yet — the tour runs with the single session, if there is one.', 'muted'));
260
+ if (people.length === 0) {
261
+ const li = el('li', null, 'muted');
262
+ li.appendChild(el('span', 'No named users yet — the tour runs with the single session, if there is one.'));
263
+ const b = el('button', '🔑 Log in'); b.onclick = () => startLogin(undefined);
264
+ li.appendChild(b); list.appendChild(li);
265
+ }
209
266
  for (const person of people) {
210
267
  const li = el('li');
211
268
  li.appendChild(avatar(person.name));
@@ -227,7 +284,7 @@ footer{color:var(--muted);font-size:13px;margin-top:24px;text-align:center}
227
284
  const running = run && run.status === 'running';
228
285
  show('nowIdle', !running); show('nowRun', running);
229
286
  q('liveDot').className = 'dot' + (running ? ' live' : ''); q('liveWord').textContent = running ? 'Tour running' : 'Idle';
230
- q('startTour').disabled = !!running || !(state && state.project.setUp);
287
+ q('startTour').disabled = !!running || !(state && state.project.setUp) || !!(state && state.browser && state.browser.status && !state.browser.status.ready);
231
288
  const failed = !running && run && run.status === 'failed';
232
289
  show('nowFail', !!failed);
233
290
  if (failed) {
@@ -250,10 +307,23 @@ footer{color:var(--muted);font-size:13px;margin-top:24px;text-align:center}
250
307
 
251
308
  function renderResult(s) {
252
309
  show('resultEmpty', !s); show('result', !!s);
253
- if (!s) { q('resultEmptyText').textContent = (state && state.history && state.history.length) ? 'The last run did not finish, so there is no result to show — earlier tours are in History below.' : 'No finished tour yet — the first one draws the map everything else is compared with.'; return; }
310
+ if (!s) { q('resultEmptyText').textContent = (state && state.run && state.run.status === 'running') ? 'A tour is walking your app right now — its result lands here when it finishes.' : (state && state.history && state.history.length) ? 'The last run did not finish, so there is no result to show — earlier tours are in History below.' : 'No finished tour yet — the first one draws the map everything else is compared with.'; return; }
254
311
  const [tone, icon, word] = MOOD[s.mood] || ['info', '•', s.mood];
255
312
  q('mood').className = 'mood ' + tone; q('mood').textContent = icon + ' ' + word;
256
313
  q('resultHead').textContent = (s.refused ? 'Refused: ' + s.refused.split('\\n')[0] : s.mode + ' tour') + (s.persona ? ' · as ' + s.persona : '');
314
+ q('headline').textContent = s.headline || '';
315
+ const rf = q('readFirst'); rf.textContent = '';
316
+ for (const g of s.readFirst || []) {
317
+ const n = el('div', '🧭 ' + g.text, 'notice');
318
+ for (const c of [g.command, g.paste]) if (c) { n.appendChild(el('div', c, 'line')); }
319
+ rf.appendChild(n);
320
+ }
321
+ const broken = s.broken || [];
322
+ show('brokenBox', broken.length > 0);
323
+ const bl = q('brokenList'); bl.textContent = '';
324
+ for (const b of broken) { const li = el('li'); li.appendChild(el('span', b.label, 'pill bad')); li.appendChild(el('span', b.text)); bl.appendChild(li); }
325
+ if (s.brokenTotal > broken.length) bl.appendChild(el('li', '…and ' + (s.brokenTotal - broken.length) + ' more in the full report', 'muted'));
326
+ if (s.knownDeadLinks > 0) bl.appendChild(el('li', s.knownDeadLinks + ' of these were already reported by a previous tour.', 'muted'));
257
327
  const box = q('stats'); box.textContent = '';
258
328
  box.appendChild(stat(s.underContract + ' of ' + s.configured, 'pages under contract', 'info'));
259
329
  const t = s.totals;
@@ -263,8 +333,32 @@ footer{color:var(--muted);font-size:13px;margin-top:24px;text-align:center}
263
333
  if (s.notMapped) box.appendChild(stat(s.notMapped, 'not mapped', 'warn'));
264
334
  q('resultCounts').textContent = '⏱ took ' + span(s.durationMs);
265
335
  q('reportLink').href = '/report?t=' + TOKEN;
336
+ // The moment heal's console is FOR: rows the tour could not settle, or repairs it proposed.
337
+ const repairs = s.totals ? (s.totals.healable || 0) : 0;
338
+ const toDecide = s.totals ? (s.totals.lost || 0) + (s.totals.ambiguous || 0) + (s.totals.rebound || 0) : 0;
339
+ const due = !s.refused && (s.verdict === 'BLOCK' || s.verdict === 'FIX' || toDecide > 0 || repairs > 0);
340
+ show('healCta', due);
341
+ if (due) q('healCtaText').textContent = (toDecide ? toDecide + ' element' + (toDecide > 1 ? 's' : '') + ' need a person to decide' : '') + (toDecide && repairs ? ' · ' : '') + (repairs ? repairs + ' repair' + (repairs > 1 ? 's are' : ' is') + ' ready' : '') + (toDecide || repairs ? '. ' : 'The tour was held back. ') + 'The repair console shows each one side by side, and applies nothing until you say so.';
266
342
  }
267
343
 
344
+ async function openHeal(btn) {
345
+ // Opened on the click itself — a window opened after an await is a popup the browser blocks.
346
+ const w = window.open('about:blank', '_blank');
347
+ const label = btn.textContent; btn.disabled = true; btn.textContent = '⏳ Opening…';
348
+ try {
349
+ const out = await (await api('/api/heal-console', {})).json();
350
+ if (out.url && w) w.location.href = out.url;
351
+ else { if (w) w.close(); note('tourNotice', out.url ? 'Your browser blocked the new tab — open ' + out.url : (out.error || 'The repair console did not start.'), out.url ? '' : 'bad'); }
352
+ } catch { if (w) w.close(); }
353
+ finally { btn.disabled = false; btn.textContent = label; }
354
+ }
355
+ q('healLink').onclick = () => openHeal(q('healLink'));
356
+ q('iconBtn').onclick = async () => {
357
+ const out = await (await api('/api/shortcut', {})).json();
358
+ note('tourNotice', out.ok ? '🖥️ Icon added to your desktop — double-click it next time to open pal on this project. ' + (out.notes || []).join(' ') : (out.error || 'No icon written.') + ' ' + (out.notes || []).join(' '), out.ok ? 'ok' : 'bad');
359
+ };
360
+ q('healCtaBtn').onclick = () => openHeal(q('healCtaBtn'));
361
+
268
362
  function renderHistory(h) {
269
363
  const list = q('history'); list.textContent = ''; const strip = q('strip'); strip.textContent = '';
270
364
  if (!h.length) { list.appendChild(el('li', 'Nothing yet — every finished tour lands here.', 'muted')); return; }
@@ -288,14 +382,182 @@ footer{color:var(--muted);font-size:13px;margin-top:24px;text-align:center}
288
382
  } else note('loginBox', job.message || '', job.status === 'done' ? 'ok' : 'bad');
289
383
  }
290
384
 
385
+ let installed = false;
386
+ function renderBrowser(b) {
387
+ const box = q('browserBox'); box.textContent = '';
388
+ if (!b || (!b.status && !b.installing)) { box.className = 'notice hidden'; return; }
389
+ if (b.installing) {
390
+ box.className = 'notice';
391
+ box.appendChild(el('div', '⬇️ Installing the browser… ' + b.notice));
392
+ if (b.lines.length) box.appendChild(el('div', b.lines[b.lines.length - 1], 'line'));
393
+ return;
394
+ }
395
+ if (b.status.ready) {
396
+ // Said once, after an install from this page. A browser that was simply there is not news.
397
+ box.className = installed ? 'notice ok' : 'notice hidden';
398
+ box.textContent = '✅ Browser ready: ' + b.status.using;
399
+ return;
400
+ }
401
+ box.className = 'notice bad';
402
+ box.appendChild(el('div', '🌐 No browser a tour can open' + (b.failed ? ' — ' + b.failed : '') + '. ' + b.notice));
403
+ const btn = el('button', '⬇️ Install the browser', 'primary');
404
+ btn.onclick = async () => { btn.disabled = true; installed = true; await api('/api/browser/install', {}); refresh(); };
405
+ const row = el('div', null, 'row'); row.appendChild(btn); row.appendChild(el('span', 'or by hand: ' + b.command, 'muted'));
406
+ box.appendChild(row);
407
+ }
408
+
409
+ let setupLoaded = false;
410
+ async function loadSetup() {
411
+ if (setupLoaded) return; setupLoaded = true;
412
+ const s = await (await api('/api/setup')).json();
413
+ const d = s.detected || { paths: [] };
414
+ show('setupTestsBox', d.paths.length > 0);
415
+ const box = q('setupTests'); box.textContent = '';
416
+ for (const pth of d.paths) {
417
+ const l = el('label'); const c = document.createElement('input'); c.type = 'checkbox'; c.checked = true; c.value = pth; c.className = 'setupTest';
418
+ l.appendChild(c); l.appendChild(el('span', 'read the tests in ' + pth + ' — repairs to their selectors, and which pages they never visit'));
419
+ box.appendChild(l);
420
+ }
421
+ if (d.command) q('setupCommand').value = d.command;
422
+ }
423
+ const setupBody = () => {
424
+ const login = (document.querySelector('input[name=setupLogin]:checked') || {}).value;
425
+ const tests = [...document.querySelectorAll('.setupTest')].filter((c) => c.checked).map((c) => c.value);
426
+ return { url: q('setupUrl').value.trim(), login, session: login === 'session' ? q('setupSession').value.trim() : undefined, tests, testCommand: tests.length ? q('setupCommand').value.trim() : undefined };
427
+ };
428
+ q('setupUrl').oninput = () => { try { q('setupHost').textContent = new URL(q('setupUrl').value).host; } catch { q('setupHost').textContent = 'your app'; } show('setupOut', false); };
429
+ for (const r of document.querySelectorAll('input[name=setupLogin]')) r.onchange = () => show('setupOut', false);
430
+ q('setupPreview').onclick = async () => {
431
+ const btn = q('setupPreview'); btn.disabled = true; btn.textContent = '⏳ Reading your app…'; note('setupNotice', ''); show('setupOut', false);
432
+ try {
433
+ const out = await (await api('/api/setup/preview', setupBody())).json();
434
+ if (out.problems && out.problems.length) { note('setupNotice', out.problems.join('\\n'), 'bad'); return; }
435
+ q('setupLines').textContent = (out.lines || []).join('\\n');
436
+ const ul = q('setupSummary'); ul.textContent = '';
437
+ const names = (out.pages || []).map((pg) => pg.name);
438
+ const from = { sitemap: 'from the sitemap', crawl: 'found by following links', home: 'the home page only' }[out.pagesFrom] || '';
439
+ ul.appendChild(el('li', '🌐 app · ' + out.baseUrl));
440
+ ul.appendChild(el('li', '📄 ' + names.length + ' page' + (names.length === 1 ? '' : 's') + ' ' + from + ': ' + names.slice(0, 12).join(', ') + (names.length > 12 ? ', +' + (names.length - 12) + ' more' : '')));
441
+ ul.appendChild(el('li', '🔑 login · ' + ({ none: 'none', browser: 'by hand in a browser — a window opens once this is written', session: 'the session file your tests save' }[out.login] || out.login)));
442
+ ul.appendChild(el('li', '🧪 tests · ' + (out.tests ? out.tests.join(', ') + (out.testCommand ? ' · run with ' + out.testCommand : '') : 'none')));
443
+ show('setupOut', true);
444
+ } finally { btn.disabled = false; btn.textContent = 'Show me what it writes'; }
445
+ };
446
+ q('setupWrite').onclick = async () => {
447
+ const btn = q('setupWrite'); btn.disabled = true;
448
+ try {
449
+ const body = setupBody();
450
+ const out = await (await api('/api/setup/write', body)).json();
451
+ if (!out.written) { note('setupNotice', (out.problems || ['Not written.']).join('\\n'), 'bad'); return; }
452
+ if (body.login === 'browser') { note('tourNotice', '✅ Set up. A browser window opens now — log in there as you usually do; it is saved by itself once the app opens.', 'ok'); await startLogin(undefined); }
453
+ else note('tourNotice', '✅ Set up. Start the first tour — it draws the map every later tour is compared with.', 'ok');
454
+ refresh();
455
+ } finally { btn.disabled = false; }
456
+ };
457
+
458
+ function renderDiscovery(d, setUp) {
459
+ show('discCard', !!(d && setUp));
460
+ if (!d || !setUp) return;
461
+ const running = d.job && d.job.status === 'running';
462
+ const jb = q('discJob');
463
+ if (running) { jb.className = 'notice'; jb.textContent = '🔎 Scanning your app… ' + (d.job.lines[d.job.lines.length - 1] || ''); }
464
+ else if (d.job && d.job.status === 'failed') { jb.className = 'notice bad'; jb.textContent = d.job.error || 'The scan failed.'; }
465
+ else jb.className = 'notice hidden';
466
+ q('discScanBtn').disabled = !!running || !!(state && state.run && state.run.status === 'running');
467
+ q('discScanBtn').textContent = d.scanned ? '🔎 Scan again' : '🔎 Scan the app';
468
+ q('discIntro').textContent = 'Every page a visitor can reach, with its forms and fields. The scan opens your app in a local browser — same site, reading only, as the user chosen in "Run a tour". Nothing is sent anywhere.' +
469
+ (d.formLoginOnly ? ' Your tours log in with the form in .ia-qa/config.json, which a scan cannot reuse: log in once above ("Log in") so the scan sees what is behind the login.' : '');
470
+ show('discReport', d.report); q('discReport').href = '/discovery/report?t=' + TOKEN;
471
+
472
+ const ul = q('discScan'); ul.textContent = '';
473
+ const s = d.job && d.job.scan;
474
+ if (s) {
475
+ ul.appendChild(el('li', '📄 ' + s.pagesCaptured + ' of ' + s.pagesFound + ' pages captured' + (s.failed.length ? ' · ' + s.failed.length + ' failed' : '')));
476
+ // A first scan "adds" every page: there was no last scan, so there is no news to state.
477
+ const first = s.added.length === s.pagesCaptured && !s.removed.length && !s.changed.length;
478
+ const moved = first ? [] : [['+ new', s.added], ['- gone', s.removed], ['~ changed', s.changed]].filter(([, l]) => l.length);
479
+ for (const [w, l] of moved) ul.appendChild(el('li', w + ' since the last scan: ' + l.slice(0, 8).join(', ') + (l.length > 8 ? ', …' : ''), 'muted'));
480
+ // A page count is not coverage: each way it can mislead is said beside it.
481
+ if (s.hrefBlind) ul.appendChild(el('li', '⚠️ No links were found, so only the first page was seen — this is one page, not the app.', 'muted'));
482
+ else if (s.loginWall.length > 1) ul.appendChild(el('li', '⚠️ ' + s.loginWall.length + ' pages still show a login form — this measured the login wall, not the app. Log in above, then scan again.', 'muted'));
483
+ else if (s.loginWall.length === 1 && !s.session) ul.appendChild(el('li', '⚠️ The app has a login and no session was used: this is the public part only. Log in above, then scan again.', 'muted'));
484
+ else if (s.session) ul.appendChild(el('li', '🔓 Scanned with the saved session' + (s.sessionSource === 'healing' ? ' (the one the tour uses)' : '') + '.', 'muted'));
485
+ }
486
+
487
+ const box = q('discCov'); box.textContent = '';
488
+ const c = d.coverage;
489
+ if (!c || !d.scanned) return;
490
+ if (c.error) { box.appendChild(el('div', c.error, 'notice bad')); return; }
491
+ if (!c.measured) {
492
+ const why = {
493
+ 'no-healing': 'Which pages do your tests never visit? Run a first tour, then this can compare.',
494
+ 'no-run': d.testsDeclared
495
+ ? 'Which pages do your tests never visit? Tick "also run my tests" on the next tour — it watches them run once, and this answers.'
496
+ : 'No test suite is declared for this project, so no page is tested yet — the pages above are the list to start from.',
497
+ }[c.reason];
498
+ if (why) box.appendChild(el('div', why, 'notice'));
499
+ return;
500
+ }
501
+ // What the scan could not see comes FIRST: a gap measured over the login page alone is not
502
+ // a small gap, it is no measurement of the rest — and read after the list, it is read too late.
503
+ const nm = c.notMeasured || { loginWall: [], hrefBlind: false, droppedByCap: 0, session: false };
504
+ const limits = [];
505
+ // Two causes share this symptom and only one is a session problem — measured on a real app
506
+ // whose landing page IS its login form, logged in or not. Name both; the Check button tells them apart.
507
+ if (nm.loginWall.length) limits.push(nm.session
508
+ ? 'These pages showed a login form even with a saved session: ' + nm.loginWall.join(', ') + '. Either the session no longer opens the app (Check it above), or that page is the login page itself — then nothing is wrong.'
509
+ : 'The scan met a login form (' + nm.loginWall.join(', ') + ') with no session — what is behind the login was not seen. Log in above, then scan again.');
510
+ if (nm.hrefBlind) limits.push('The scan found no links to follow, so it saw one page, not the app.');
511
+ if (nm.droppedByCap) limits.push(nm.droppedByCap + ' page' + (nm.droppedByCap === 1 ? ' was' : 's were') + ' left out by the scan\\'s page cap.');
512
+ if (c.contractedNotFound.length) limits.push('The scan did not reach ' + c.contractedNotFound.length + ' page' + (c.contractedNotFound.length === 1 ? '' : 's') + ' your tours know (' + c.contractedNotFound.slice(0, 6).join(', ') + (c.contractedNotFound.length > 6 ? ', …' : '') + ') — a limit of the scan, not pages that are gone.');
513
+ if (limits.length) { const w = el('div', null, 'notice'); w.appendChild(el('strong', '⚠️ Read this before the list — the scan saw only part of the app.')); for (const l of limits) w.appendChild(el('div', l)); box.appendChild(w); }
514
+
515
+ const n = el('div', null, 'notice' + (c.uncoveredTotal || limits.length ? '' : ' ok'));
516
+ const pages = (k) => k + ' page' + (k === 1 ? '' : 's');
517
+ n.appendChild(el('div', '🧪 Your tests visited ' + pages(c.visited.length) + '. ' + (c.uncoveredTotal ? 'Of the pages the scan found, ' + pages(c.uncoveredTotal) + (c.uncoveredTotal === 1 ? ' is' : ' are') + ' visited by no test:' : 'Every page the scan found is visited by a test' + (limits.length ? ' — of the part it could see.' : '.'))));
518
+ const list = el('ul');
519
+ for (const u of c.uncovered) {
520
+ const li = el('li'); li.appendChild(el('strong', u.page));
521
+ if (nm.loginWall.includes(u.page)) li.appendChild(el('span', 'the login page the scan stopped at', 'pill warn'));
522
+ if (u.factors.length) li.appendChild(el('span', u.factors.join(' · '), 'muted'));
523
+ list.appendChild(li);
524
+ }
525
+ if (c.uncoveredTotal > c.uncovered.length) list.appendChild(el('li', '…and ' + (c.uncoveredTotal - c.uncovered.length) + ' more in the app map', 'muted'));
526
+ n.appendChild(list);
527
+ if (c.cannotTell.length) n.appendChild(el('div', 'Could not tell for: ' + c.cannotTell.join(', ') + ' — several views share one address.', 'muted'));
528
+ // Both moments, always: the gap joins a test run and a scan taken at different times.
529
+ const when = (iso) => (iso && !isNaN(Date.parse(iso)) ? new Date(iso).toLocaleString() : 'unknown');
530
+ n.appendChild(el('div', 'Tests watched ' + when(c.recordedAt) + ' · app scanned ' + when(c.scannedAt) + '.', 'muted'));
531
+ // Silent on the same day: two halves of one moment need no caveat, and one that fires every run stops being read.
532
+ const day = (iso) => (iso ? iso.slice(0, 10) : '');
533
+ if (day(c.recordedAt) && day(c.scannedAt) && day(c.recordedAt) !== day(c.scannedAt)) {
534
+ n.appendChild(el('div', c.scannedAt < c.recordedAt
535
+ ? 'The scan is older than the test run: your tests may visit pages that scan never saw.'
536
+ : 'The test run is older than the scan: a page found since may simply have no test yet.', 'muted'));
537
+ }
538
+ box.appendChild(n);
539
+ }
540
+ q('discScanBtn').onclick = async () => {
541
+ const out = await (await api('/api/discovery/scan', { persona: q('tourPersona').value || undefined })).json();
542
+ if (!out.started) { const jb = q('discJob'); jb.className = 'notice bad'; jb.textContent = out.reason || 'Not started.'; }
543
+ refresh();
544
+ };
545
+
291
546
  async function refresh() {
292
547
  try {
293
548
  state = await (await api('/api/state')).json();
294
549
  const p = state.project;
295
- q('where').textContent = p.setUp ? '🌐 ' + p.baseUrl + ' · ' + p.pages + ' pages' + (p.baseline ? '' : ' · no baseline yet') : 'This folder is not set up yet — run ia-qa-pal setup here.';
550
+ q('where').textContent = p.setUp ? '🌐 ' + p.baseUrl + ' · ' + p.pages + ' pages' + (p.baseline ? '' : ' · no baseline yet') : 'This folder is not set up yet — a few questions below and you are ready.';
296
551
  if (p.setUp) renderPersonas(p);
552
+ show('setupCard', !p.setUp); show('whoCard', p.setUp);
553
+ if (!p.setUp) loadSetup();
554
+ renderBrowser(state.browser);
297
555
  const running = !!(state.run && state.run.status === 'running');
298
556
  renderRun(state.run); renderResult(state.summary); renderHistory(state.history || []); renderLogin(state.login);
557
+ renderDiscovery(state.discovery, p.setUp);
558
+ if (wasRunning && !running) note('tourNotice', '');
559
+ // A tour that ran the tests is the other half of the gap: recompute it as soon as it lands.
560
+ if (wasRunning && !running && state.discovery && state.discovery.scanned) api('/api/discovery/coverage', {}).then(() => refresh()).catch(() => {});
299
561
  // Only a tour that compared something and came back clean. A baseline measured nothing.
300
562
  if (wasRunning && !running && state.summary && state.summary.mood === 'clean') confetti();
301
563
  wasRunning = running;
@@ -309,7 +571,7 @@ footer{color:var(--muted);font-size:13px;margin-top:24px;text-align:center}
309
571
  }
310
572
 
311
573
  async function startLogin(name) {
312
- const r = await api('/api/persona/login', { persona: name });
574
+ const r = await api('/api/persona/login', name ? { persona: name } : {});
313
575
  if (!r.ok) note('loginBox', (await r.json()).reason, 'bad'); else refresh();
314
576
  }
315
577
 
@@ -1 +1 @@
1
- {"version":3,"file":"page.js","sourceRoot":"","sources":["../../src/ui/page.ts"],"names":[],"mappings":";;AAcA,8CAmWC;AAjXD;;;;;;;;;;;;;GAaG;AACH,SAAgB,iBAAiB,CAAC,KAAa;IAC7C,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA2JS,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAsMxB,CAAC;AAChB,CAAC"}
1
+ {"version":3,"file":"page.js","sourceRoot":"","sources":["../../src/ui/page.ts"],"names":[],"mappings":";;AAcA,8CAymBC;AAvnBD;;;;;;;;;;;;;GAaG;AACH,SAAgB,iBAAiB,CAAC,KAAa;IAC7C,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA+MS,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAwZxB,CAAC;AAChB,CAAC"}
@@ -1,4 +1,8 @@
1
1
  import { probeSession, performLogin, storeKind, writeSecret, readSecret, type SecureServer } from '@ia-qa/self-healing';
2
+ import { runSetup } from '../setup';
3
+ import type { PalLogin } from '../setup';
4
+ import { probeBrowser, installChromium } from '../browser';
5
+ import { installPalShortcut } from '../shortcut';
2
6
  /**
3
7
  * `ia-qa-pal ui` — launch a tour, follow it live, see what it found, manage who it runs as.
4
8
  *
@@ -35,13 +39,38 @@ export interface PalUiOptions {
35
39
  /** Injected so tests exercise the routes without a browser. */
36
40
  login?: typeof performLogin;
37
41
  probe?: typeof probeSession;
42
+ /** The heal CLI the repair console is started from. Default: the installed @ia-qa/self-healing. */
43
+ healEntry?: string;
38
44
  /** Injected so tests never write to the real credential store. */
39
45
  store?: {
40
46
  write: typeof writeSecret;
41
47
  read: typeof readSecret;
42
48
  kind: typeof storeKind;
43
49
  };
50
+ /** Injected so tests neither launch a browser nor download one. */
51
+ browserProbe?: typeof probeBrowser;
52
+ browserInstall?: typeof installChromium;
53
+ /** Injected so tests exercise the setup routes without reading a real site. */
54
+ setup?: typeof runSetup;
55
+ /** The discovery CLI scans and coverage run through. Default: the installed @ia-qa/qa-discovery. */
56
+ discoverEntry?: string;
57
+ /** Injected so tests never write to a real desktop. */
58
+ shortcut?: (dir: string) => ReturnType<typeof installPalShortcut>;
44
59
  }
60
+ /**
61
+ * The setup answers a request may carry. Every one is a string the person typed, checked for its
62
+ * type and nothing is added: `planSetup` (behind `runSetup`) is what validates them and what
63
+ * refuses a secret, the same door `ia-qa-pal setup` and `ia-qa-heal ui` write through.
64
+ */
65
+ export declare function setupAnswers(body: Record<string, unknown>): {
66
+ url?: string;
67
+ login?: PalLogin;
68
+ session?: string;
69
+ tests?: string[];
70
+ testCommand?: string;
71
+ } | {
72
+ error: string;
73
+ };
45
74
  interface LoginJob {
46
75
  persona: string;
47
76
  status: 'waiting' | 'done' | 'failed';
@@ -90,6 +119,24 @@ export declare function missingAuthSecrets(dir: string, config: {
90
119
  name: string;
91
120
  key: string;
92
121
  }>;
122
+ /** Where `ia-qa-heal` lives: the self-healing this package already depends on, never a PATH lookup. */
123
+ export declare function healCliEntry(): string;
124
+ /**
125
+ * Open heal's repair console on THIS project and hand back its address.
126
+ *
127
+ * A separate process, never an in-process `startUi`: both consoles keep "which project" in
128
+ * module-global state (`setBaseDir`), and two servers sharing one would let a request of one
129
+ * run against the other's folder. The argv is fixed — `ui --no-open --offline --config <dir>` —
130
+ * `--offline` because this page promises nothing leaves the machine, and heal's once-a-day update
131
+ * check would be a request nobody announced here. Heal reuses a console already open on the
132
+ * project, so a second click never starts a rival with a different token. Its output goes to a
133
+ * file rather than a pipe: a pipe closed after the URL is read would kill heal on its next line.
134
+ */
135
+ export declare function openHealConsole(dir: string, entry?: string, timeoutMs?: number): Promise<{
136
+ url: string;
137
+ } | {
138
+ error: string;
139
+ }>;
93
140
  /** A name a store entry may carry: the shape of an environment variable, so one name serves both. */
94
141
  export declare const SECRET_NAME: RegExp;
95
142
  export type SetSecretAnswer = {