@ui-workflow/core 0.1.0 → 0.1.1
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/layout-capture.mjs +14 -0
- package/package.json +3 -3
- package/studio-dist/assets/{AccountModal-BCsGPvx4.js → AccountModal-C415mM4f.js} +1 -1
- package/studio-dist/assets/{Connections-C9b3n4ss.js → Connections-BD_LstwM.js} +1 -1
- package/studio-dist/assets/Diagnostics-CuRX-uAp.js +10 -0
- package/studio-dist/assets/{Repositories-BPQd02x8.js → Repositories-DH7YyDwk.js} +1 -1
- package/studio-dist/assets/{ReviewStage-bicZ-iOy.js → ReviewStage-DJ1oRAkT.js} +1 -1
- package/studio-dist/assets/{Settings-CITjwtGY.js → Settings-8mMKFnYf.js} +1 -1
- package/studio-dist/assets/WorkflowVisualizer-CdwGjUIL.js +4 -0
- package/studio-dist/assets/{account-modal--3DWt5me.js → account-modal-Cm9Rsqyi.js} +1 -1
- package/studio-dist/assets/{index-KY1IHp8L.js → index-Dp8CdAV4.js} +27 -27
- package/studio-dist/assets/index-jTfIlhhN.css +1 -0
- package/studio-dist/index.html +2 -2
- package/studio-routes-projects.mjs +22 -5
- package/studio-server.mjs +31 -1
- package/studio-settings.mjs +83 -0
- package/ui-workflow-cli.mjs +37 -28
- package/windows-native.mjs +88 -9
- package/workflow-runner.mjs +33 -2
- package/studio-dist/assets/Diagnostics-D9o9AHSf.js +0 -10
- package/studio-dist/assets/WorkflowVisualizer-6llBlI2i.js +0 -4
- package/studio-dist/assets/index-Cv4BVYXJ.css +0 -1
package/studio-dist/index.html
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
<!doctype html><html lang="en" data-theme="system"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1"><meta name="color-scheme" content="light dark"><meta name="theme-color" content="#111318"><link rel="manifest" href="/manifest.webmanifest"><link rel="icon" type="image/svg+xml" href="/assets/favicon-DEEp3F3I.svg"><link rel="apple-touch-icon" href="/icon-192.png"><title>UI Design Studio — Local Workspace</title> <script type="module" crossorigin src="/assets/index-
|
|
1
|
+
<!doctype html><html lang="en" data-theme="system"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1"><meta name="color-scheme" content="light dark"><meta name="theme-color" content="#111318"><link rel="manifest" href="/manifest.webmanifest"><link rel="icon" type="image/svg+xml" href="/assets/favicon-DEEp3F3I.svg"><link rel="apple-touch-icon" href="/icon-192.png"><title>UI Design Studio — Local Workspace</title> <script type="module" crossorigin src="/assets/index-Dp8CdAV4.js"></script>
|
|
2
2
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-4tVxZq34.js">
|
|
3
3
|
<link rel="modulepreload" crossorigin href="/assets/react-vendor-CH5vucNG.js">
|
|
4
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
4
|
+
<link rel="stylesheet" crossorigin href="/assets/index-jTfIlhhN.css">
|
|
5
5
|
</head><body><div id="root"></div></body></html>
|
|
@@ -731,14 +731,31 @@ export async function handleProjectRoutes({
|
|
|
731
731
|
};
|
|
732
732
|
res.once('close', closed);
|
|
733
733
|
try {
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
await selectFolder({
|
|
734
|
+
let result;
|
|
735
|
+
try {
|
|
736
|
+
result = await selectFolder({
|
|
737
737
|
stateDir,
|
|
738
738
|
initialPath: input.initialPath ?? '',
|
|
739
739
|
signal: AbortSignal.any([folders.signal, disconnected.signal]),
|
|
740
|
-
})
|
|
741
|
-
)
|
|
740
|
+
});
|
|
741
|
+
} catch (pickerError) {
|
|
742
|
+
if (
|
|
743
|
+
pickerError?.code === 'native-platform' ||
|
|
744
|
+
pickerError?.code === 'native-picker-unavailable'
|
|
745
|
+
) {
|
|
746
|
+
result = {
|
|
747
|
+
path: null,
|
|
748
|
+
cancelled: false,
|
|
749
|
+
fallbackRequired: true,
|
|
750
|
+
reason:
|
|
751
|
+
pickerError.message ||
|
|
752
|
+
'No graphical folder picker is available on this host. Paste your project folder path below.',
|
|
753
|
+
};
|
|
754
|
+
} else {
|
|
755
|
+
throw pickerError;
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
json(res, result);
|
|
742
759
|
} finally {
|
|
743
760
|
res.off('close', closed);
|
|
744
761
|
}
|
package/studio-server.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** Trusted-local HTTP adapter over the same runner used by the CLI. No imported commands. */
|
|
2
2
|
import http from 'node:http';
|
|
3
3
|
import fs from 'node:fs/promises';
|
|
4
|
+
import os from 'node:os';
|
|
4
5
|
import path from 'node:path';
|
|
5
6
|
import { randomBytes } from 'node:crypto';
|
|
6
7
|
import { fileURLToPath } from 'node:url';
|
|
@@ -67,6 +68,26 @@ const sharedRefDigestCache = new Map();
|
|
|
67
68
|
const sharedCatalogCache = new Map();
|
|
68
69
|
const CORE_DIR = path.dirname(fileURLToPath(import.meta.url));
|
|
69
70
|
|
|
71
|
+
/** Returns true when a folder is the user's home directory or a filesystem root (unsafe to auto-inspect). */
|
|
72
|
+
export function isUnsafeAutoProjectDir(
|
|
73
|
+
candidatePath,
|
|
74
|
+
{ homeDir = os.homedir(), platform = process.platform } = {},
|
|
75
|
+
) {
|
|
76
|
+
if (typeof candidatePath !== 'string' || !candidatePath.trim()) return false;
|
|
77
|
+
const pathApi = platform === 'win32' ? path.win32 : path.posix;
|
|
78
|
+
const normalized = pathApi.resolve(candidatePath.trim());
|
|
79
|
+
const parsed = pathApi.parse(normalized);
|
|
80
|
+
if (normalized === parsed.root) return true;
|
|
81
|
+
if (typeof homeDir === 'string' && homeDir.trim()) {
|
|
82
|
+
const normHome = pathApi.resolve(homeDir.trim());
|
|
83
|
+
const stripTrail = (p) => (p.length > parsed.root.length ? p.replace(/[\\/]+$/, '') : p);
|
|
84
|
+
const a = stripTrail(normalized);
|
|
85
|
+
const b = stripTrail(normHome);
|
|
86
|
+
if (platform === 'win32' ? a.toLowerCase() === b.toLowerCase() : a === b) return true;
|
|
87
|
+
}
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
|
|
70
91
|
export async function computeStudioBuildStamp(publicDir) {
|
|
71
92
|
const targets = [
|
|
72
93
|
publicDir ? path.join(publicDir, 'index.html') : null,
|
|
@@ -195,6 +216,12 @@ async function createOwnedStudio(
|
|
|
195
216
|
onLog({ at: new Date().toISOString(), level, scope, message: safe.slice(0, 320) });
|
|
196
217
|
} catch {}
|
|
197
218
|
};
|
|
219
|
+
const effectiveDefaultProject =
|
|
220
|
+
typeof defaultProject === 'string' &&
|
|
221
|
+
defaultProject.trim() &&
|
|
222
|
+
!isUnsafeAutoProjectDir(defaultProject)
|
|
223
|
+
? defaultProject
|
|
224
|
+
: null;
|
|
198
225
|
const folders = new AbortController();
|
|
199
226
|
const startedBuildStamp = await computeStudioBuildStamp(publicDir);
|
|
200
227
|
let dispatcher,
|
|
@@ -1146,7 +1173,7 @@ async function createOwnedStudio(
|
|
|
1146
1173
|
origin,
|
|
1147
1174
|
stateDir,
|
|
1148
1175
|
hubRoot,
|
|
1149
|
-
defaultProject,
|
|
1176
|
+
defaultProject: effectiveDefaultProject,
|
|
1150
1177
|
publicDir,
|
|
1151
1178
|
draining,
|
|
1152
1179
|
clients,
|
|
@@ -1243,6 +1270,9 @@ async function createOwnedStudio(
|
|
|
1243
1270
|
detectedKind: error.detectedKind ?? 'static-html',
|
|
1244
1271
|
}
|
|
1245
1272
|
: {}),
|
|
1273
|
+
...(Array.isArray(error.suggestedSubfolders) && error.suggestedSubfolders.length > 0
|
|
1274
|
+
? { suggestedSubfolders: error.suggestedSubfolders }
|
|
1275
|
+
: {}),
|
|
1246
1276
|
},
|
|
1247
1277
|
status,
|
|
1248
1278
|
);
|
package/studio-settings.mjs
CHANGED
|
@@ -1311,6 +1311,81 @@ function formatDetectedLabel(detectedModules) {
|
|
|
1311
1311
|
return addons.length ? `${base} + ${addons.join(' + ')}` : base;
|
|
1312
1312
|
}
|
|
1313
1313
|
|
|
1314
|
+
const COMMON_WEB_SUBFOLDERS = ['frontend', 'client', 'web', 'app', 'website', 'site'];
|
|
1315
|
+
|
|
1316
|
+
async function classifyWebFolderCandidate(dirPath) {
|
|
1317
|
+
try {
|
|
1318
|
+
const stat = await fs.lstat(dirPath);
|
|
1319
|
+
if (!stat.isDirectory() || stat.isSymbolicLink()) return null;
|
|
1320
|
+
} catch {
|
|
1321
|
+
return null;
|
|
1322
|
+
}
|
|
1323
|
+
try {
|
|
1324
|
+
const raw = await readBounded(path.join(dirPath, 'package.json'), 64 * 1024);
|
|
1325
|
+
const pkg = JSON.parse(raw.toString('utf8'));
|
|
1326
|
+
const deps = { ...(pkg?.dependencies ?? {}), ...(pkg?.devDependencies ?? {}) };
|
|
1327
|
+
if (deps.next) return 'Next.js';
|
|
1328
|
+
if (deps.react || deps.vite) return 'React / Vite';
|
|
1329
|
+
} catch {
|
|
1330
|
+
// Not a Node/React package; check static HTML
|
|
1331
|
+
}
|
|
1332
|
+
try {
|
|
1333
|
+
const idx = await fs.lstat(path.join(dirPath, 'index.html'));
|
|
1334
|
+
if (idx.isFile() && !idx.isSymbolicLink()) return 'Static HTML';
|
|
1335
|
+
} catch {
|
|
1336
|
+
// No index.html
|
|
1337
|
+
}
|
|
1338
|
+
return null;
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
/** Scans 1 level deep (plus immediate children of apps/) for common web app subfolders. */
|
|
1342
|
+
export async function detectWebSubfolderHints(root) {
|
|
1343
|
+
const hints = [];
|
|
1344
|
+
const seen = new Set();
|
|
1345
|
+
const tryDir = async (rel) => {
|
|
1346
|
+
if (hints.length >= 4 || seen.has(rel)) return;
|
|
1347
|
+
seen.add(rel);
|
|
1348
|
+
const full = path.join(root, rel);
|
|
1349
|
+
const kind = await classifyWebFolderCandidate(full);
|
|
1350
|
+
if (kind) {
|
|
1351
|
+
hints.push({ relativePath: rel.replace(/\\/g, '/'), fullPath: full, kind });
|
|
1352
|
+
}
|
|
1353
|
+
};
|
|
1354
|
+
for (const name of COMMON_WEB_SUBFOLDERS) {
|
|
1355
|
+
await tryDir(name);
|
|
1356
|
+
}
|
|
1357
|
+
if (hints.length < 4) {
|
|
1358
|
+
const appsDir = path.join(root, 'apps');
|
|
1359
|
+
try {
|
|
1360
|
+
const appsStat = await fs.lstat(appsDir);
|
|
1361
|
+
if (appsStat.isDirectory() && !appsStat.isSymbolicLink()) {
|
|
1362
|
+
const children = await fs.readdir(appsDir, { withFileTypes: true });
|
|
1363
|
+
for (const child of children.slice(0, 16)) {
|
|
1364
|
+
if (hints.length >= 4) break;
|
|
1365
|
+
if (!child.isDirectory() || child.name.startsWith('.')) continue;
|
|
1366
|
+
await tryDir(path.join('apps', child.name));
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
} catch {
|
|
1370
|
+
// No apps/ directory
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
return hints;
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
function buildUnsupportedFolderMessage(baseMessage, subfolderHints) {
|
|
1377
|
+
if (Array.isArray(subfolderHints) && subfolderHints.length > 0) {
|
|
1378
|
+
const list = subfolderHints.map((s) => `${s.relativePath}/ (${s.kind})`).join(', ');
|
|
1379
|
+
return `This folder isn't a Static HTML, React/Vite, or Next.js root. Found web subfolder${subfolderHints.length === 1 ? '' : 's'}: ${list}. Select one of those folders, or click New project.`;
|
|
1380
|
+
}
|
|
1381
|
+
if (
|
|
1382
|
+
/index\.html|package\.json|react|vite|next|supported|entry/i.test(String(baseMessage ?? ''))
|
|
1383
|
+
) {
|
|
1384
|
+
return `This folder isn't a recognized Static HTML, React/Vite, or Next.js root. Select a web app folder (for example frontend/, client/, or web/) or click New project to create a starter.`;
|
|
1385
|
+
}
|
|
1386
|
+
return baseMessage;
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1314
1389
|
/** Read-only support detection. Uses the same bounded inspector as preflight. */
|
|
1315
1390
|
export async function inspectProjectSetup(project, policyOptions = {}) {
|
|
1316
1391
|
if (
|
|
@@ -1344,6 +1419,10 @@ export async function inspectProjectSetup(project, policyOptions = {}) {
|
|
|
1344
1419
|
inspectError.detectedRoot = candidate.relativeRoot;
|
|
1345
1420
|
inspectError.detectedKind = candidate.kind;
|
|
1346
1421
|
inspectError.message = `${inspectError.message} Use "Import clean website copy" to copy supported website files into work/ without running repo scripts.`;
|
|
1422
|
+
} else {
|
|
1423
|
+
const subfolderHints = await detectWebSubfolderHints(root).catch(() => []);
|
|
1424
|
+
if (subfolderHints.length > 0) inspectError.suggestedSubfolders = subfolderHints;
|
|
1425
|
+
inspectError.message = buildUnsupportedFolderMessage(inspectError.message, subfolderHints);
|
|
1347
1426
|
}
|
|
1348
1427
|
throw inspectError;
|
|
1349
1428
|
}
|
|
@@ -1400,6 +1479,10 @@ export async function inspectProjectSetup(project, policyOptions = {}) {
|
|
|
1400
1479
|
reactError.detectedRoot = candidate.relativeRoot;
|
|
1401
1480
|
reactError.detectedKind = candidate.kind;
|
|
1402
1481
|
reactError.message = `${reactError.message} Use "Import clean website copy" to create a bounded clean working snapshot inside work/ without running repo install or build scripts.`;
|
|
1482
|
+
} else {
|
|
1483
|
+
const subfolderHints = await detectWebSubfolderHints(root).catch(() => []);
|
|
1484
|
+
if (subfolderHints.length > 0) reactError.suggestedSubfolders = subfolderHints;
|
|
1485
|
+
reactError.message = buildUnsupportedFolderMessage(reactError.message, subfolderHints);
|
|
1403
1486
|
}
|
|
1404
1487
|
throw reactError;
|
|
1405
1488
|
}
|
package/ui-workflow-cli.mjs
CHANGED
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
} from './setup-modules.mjs';
|
|
35
35
|
import { connectAutoMcpClients, connectMcpClient } from './mcp-connect.mjs';
|
|
36
36
|
import { inspectClientMcpConfigs } from './client-integrations.mjs';
|
|
37
|
-
import { detectBrowserRuntime } from './layout-capture.mjs';
|
|
37
|
+
import { detectBrowserRuntime, formatBrowserDoctorRemediation } from './layout-capture.mjs';
|
|
38
38
|
import {
|
|
39
39
|
captureMultiRouteUrl,
|
|
40
40
|
detectLoopbackDevServer,
|
|
@@ -341,11 +341,12 @@ function parseArgs(argv) {
|
|
|
341
341
|
flags.url = targetArg;
|
|
342
342
|
flags.render = true;
|
|
343
343
|
}
|
|
344
|
+
const explicitProject = Boolean(flags.project || (targetArg && !/^https?:\/\//i.test(targetArg)));
|
|
344
345
|
const targetDir =
|
|
345
346
|
flags.project ??
|
|
346
347
|
(targetArg && !/^https?:\/\//i.test(targetArg) ? targetArg : null) ??
|
|
347
348
|
process.cwd();
|
|
348
|
-
return { command, targetDir: path.resolve(targetDir), flags };
|
|
349
|
+
return { command, targetDir: path.resolve(targetDir), explicitProject, flags };
|
|
349
350
|
}
|
|
350
351
|
|
|
351
352
|
function usageText() {
|
|
@@ -459,14 +460,9 @@ async function runDoctor({ targetDir, flags }) {
|
|
|
459
460
|
command: `Install Node.js >= ${MIN_DURABLE_NODE_VERSION} (with built-in node:sqlite) and reopen your terminal.`,
|
|
460
461
|
});
|
|
461
462
|
}
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
issue: 'No local browser engine found (required only for --render / --url browser checks).',
|
|
466
|
-
command:
|
|
467
|
-
pw.remediation ||
|
|
468
|
-
'Install Google Chrome or Microsoft Edge, set CHROME_PATH, or run: npx playwright install chromium',
|
|
469
|
-
});
|
|
463
|
+
const browserRemediation = formatBrowserDoctorRemediation(pw);
|
|
464
|
+
if (browserRemediation) {
|
|
465
|
+
remediations.push(browserRemediation);
|
|
470
466
|
}
|
|
471
467
|
if (dependencies && !dependencies.installed) {
|
|
472
468
|
remediations.push({
|
|
@@ -1247,8 +1243,9 @@ async function resolveStudioRuntimePaths(flags) {
|
|
|
1247
1243
|
return { publicDir, stateDir, hubRoot, inHubRepo };
|
|
1248
1244
|
}
|
|
1249
1245
|
|
|
1250
|
-
async function runStudio({ targetDir, flags }) {
|
|
1251
|
-
const { controlStudio, startOrAttachStudio } =
|
|
1246
|
+
async function runStudio({ targetDir, explicitProject = false, flags }) {
|
|
1247
|
+
const { controlStudio, startOrAttachStudio, isUnsafeAutoProjectDir } =
|
|
1248
|
+
await import('./studio-server.mjs');
|
|
1252
1249
|
const { publicDir, stateDir, hubRoot, inHubRepo } = await resolveStudioRuntimePaths(flags);
|
|
1253
1250
|
|
|
1254
1251
|
const rawPort = flags.port !== null ? flags.port : (process.env.STUDIO_PORT ?? '4318');
|
|
@@ -1291,27 +1288,32 @@ async function runStudio({ targetDir, flags }) {
|
|
|
1291
1288
|
);
|
|
1292
1289
|
}
|
|
1293
1290
|
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
projectStat = null;
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1291
|
+
const skipAutoProject = !explicitProject && isUnsafeAutoProjectDir(targetDir);
|
|
1292
|
+
const effectiveProject = skipAutoProject ? null : targetDir;
|
|
1293
|
+
|
|
1294
|
+
if (effectiveProject) {
|
|
1295
|
+
let projectStat = null;
|
|
1296
|
+
try {
|
|
1297
|
+
projectStat = await fs.stat(effectiveProject);
|
|
1298
|
+
} catch {
|
|
1299
|
+
projectStat = null;
|
|
1300
|
+
}
|
|
1301
|
+
if (!projectStat || !projectStat.isDirectory()) {
|
|
1302
|
+
throw new Error(`Project folder not found: ${effectiveProject}`);
|
|
1303
|
+
}
|
|
1302
1304
|
}
|
|
1303
1305
|
|
|
1304
1306
|
const runtimeOptions = {
|
|
1305
1307
|
publicDir,
|
|
1306
1308
|
stateDir,
|
|
1307
1309
|
hubRoot,
|
|
1308
|
-
defaultProject:
|
|
1310
|
+
defaultProject: effectiveProject,
|
|
1309
1311
|
port,
|
|
1310
1312
|
autoRestartStale: true,
|
|
1311
1313
|
};
|
|
1312
1314
|
|
|
1313
1315
|
// Persist recent project globally under ~/.ui-workflow/ when running outside the hub repo
|
|
1314
|
-
if (!inHubRepo) {
|
|
1316
|
+
if (!inHubRepo && effectiveProject) {
|
|
1315
1317
|
const globalRoot = path.join(os.homedir(), '.ui-workflow');
|
|
1316
1318
|
const recentFile = path.join(globalRoot, 'recent-projects.json');
|
|
1317
1319
|
try {
|
|
@@ -1321,7 +1323,10 @@ async function runStudio({ targetDir, flags }) {
|
|
|
1321
1323
|
const raw = JSON.parse(await fs.readFile(recentFile, 'utf8'));
|
|
1322
1324
|
if (Array.isArray(raw?.projects)) existing = raw.projects;
|
|
1323
1325
|
} catch {}
|
|
1324
|
-
const updated = [
|
|
1326
|
+
const updated = [effectiveProject, ...existing.filter((p) => p !== effectiveProject)].slice(
|
|
1327
|
+
0,
|
|
1328
|
+
10,
|
|
1329
|
+
);
|
|
1325
1330
|
await fs.writeFile(
|
|
1326
1331
|
recentFile,
|
|
1327
1332
|
`${JSON.stringify({ version: 1, projects: updated, updatedAt: new Date().toISOString() }, null, 2)}\n`,
|
|
@@ -1337,12 +1342,14 @@ async function runStudio({ targetDir, flags }) {
|
|
|
1337
1342
|
? await runWithAclRecovery(() => controlStudio({ ...runtimeOptions, action: 'restart' }))
|
|
1338
1343
|
: await runWithAclRecovery(() => startOrAttachStudio(runtimeOptions));
|
|
1339
1344
|
|
|
1340
|
-
const launchUrl =
|
|
1345
|
+
const launchUrl = effectiveProject
|
|
1346
|
+
? `${server.origin}/?project=${encodeURIComponent(effectiveProject)}`
|
|
1347
|
+
: `${server.origin}/`;
|
|
1341
1348
|
const payload = {
|
|
1342
1349
|
ok: true,
|
|
1343
1350
|
url: launchUrl,
|
|
1344
1351
|
origin: server.origin,
|
|
1345
|
-
project:
|
|
1352
|
+
project: effectiveProject,
|
|
1346
1353
|
stateDir: server.stateDir,
|
|
1347
1354
|
attached: Boolean(server.attached),
|
|
1348
1355
|
...(server.restarted ? { restarted: true } : {}),
|
|
@@ -1359,7 +1366,9 @@ async function runStudio({ targetDir, flags }) {
|
|
|
1359
1366
|
console.log('');
|
|
1360
1367
|
console.log(' UI Design Studio');
|
|
1361
1368
|
console.log(` URL ${launchUrl}`);
|
|
1362
|
-
console.log(
|
|
1369
|
+
console.log(
|
|
1370
|
+
` Project ${effectiveProject ?? '(none selected — pick a web project folder in Studio)'}`,
|
|
1371
|
+
);
|
|
1363
1372
|
console.log(` Status ${stateLabel}`);
|
|
1364
1373
|
console.log(` Controls ui-workflow studio --status | --restart | --stop`);
|
|
1365
1374
|
console.log('');
|
|
@@ -1648,7 +1657,7 @@ async function runDiff({ targetDir, flags }) {
|
|
|
1648
1657
|
}
|
|
1649
1658
|
|
|
1650
1659
|
export async function runCli(argv = process.argv, io = {}) {
|
|
1651
|
-
const { command, targetDir, flags } = parseArgs(argv);
|
|
1660
|
+
const { command, targetDir, explicitProject, flags } = parseArgs(argv);
|
|
1652
1661
|
if (flags.help) {
|
|
1653
1662
|
console.log(usageText());
|
|
1654
1663
|
return 0;
|
|
@@ -1668,7 +1677,7 @@ export async function runCli(argv = process.argv, io = {}) {
|
|
|
1668
1677
|
);
|
|
1669
1678
|
}
|
|
1670
1679
|
if (command === 'init') return runInit({ targetDir, flags }, io);
|
|
1671
|
-
if (command === 'studio') return runStudio({ targetDir, flags });
|
|
1680
|
+
if (command === 'studio') return runStudio({ targetDir, explicitProject, flags });
|
|
1672
1681
|
if (command === 'run') return runWorkflowRecipe({ targetDir, flags });
|
|
1673
1682
|
if (command === 'baseline') return runBaseline({ targetDir, flags });
|
|
1674
1683
|
if (command === 'diff') return runDiff({ targetDir, flags });
|
package/windows-native.mjs
CHANGED
|
@@ -53,17 +53,84 @@ export function parseNativeFolderResult(text){
|
|
|
53
53
|
if(result?.cancelled===false&&typeof result.path==='string'&&result.path.length<=32767&&path.win32.isAbsolute(result.path)&&!/[\u0000-\u001f]/.test(result.path))return{path:result.path,cancelled:false};
|
|
54
54
|
throw nativeError('native-picker-result-invalid','result','The folder window returned an invalid folder. Try again.');
|
|
55
55
|
}
|
|
56
|
+
function normalizePickedPosixPath(raw){
|
|
57
|
+
const trimmed=String(raw??'').trim();
|
|
58
|
+
if(!trimmed)return null;
|
|
59
|
+
const cleaned=trimmed.length>1?trimmed.replace(/\/+$/,''):trimmed;
|
|
60
|
+
if(!cleaned||cleaned.length>32767||!path.posix.isAbsolute(cleaned)||/[\u0000-\u001f]/.test(cleaned))return null;
|
|
61
|
+
return cleaned;
|
|
62
|
+
}
|
|
63
|
+
function isDisplayUnavailableError(error){
|
|
64
|
+
const msg=`${error?.stderr??''} ${error?.message??''}`.toLowerCase();
|
|
65
|
+
return msg.includes('cannot open display')||msg.includes('no display')||msg.includes('wayland')&&msg.includes('failed')||msg.includes('unable to open display')||msg.includes('could not connect to any x display');
|
|
66
|
+
}
|
|
67
|
+
async function selectMacOsFolder({startDir,signal,runCommand}){
|
|
68
|
+
const args=startDir
|
|
69
|
+
?['-e','on run argv','-e','POSIX path of (choose folder with prompt "Select a project folder" default location (POSIX file (item 1 of argv)))','-e','end run','--',startDir]
|
|
70
|
+
:['-e','POSIX path of (choose folder with prompt "Select a project folder")'];
|
|
71
|
+
try{
|
|
72
|
+
const {stdout}=await runCommand('osascript',args,{timeout:300000,maxBuffer:16384,encoding:'utf8',signal});
|
|
73
|
+
const chosen=normalizePickedPosixPath(stdout);
|
|
74
|
+
if(!chosen)throw nativeError('native-picker-result-invalid','result','The folder window returned an invalid folder. Try again.');
|
|
75
|
+
return{path:chosen,cancelled:false};
|
|
76
|
+
}catch(error){
|
|
77
|
+
if(error.name==='AbortError')return{path:null,cancelled:true};
|
|
78
|
+
if(error.code==='ENOENT'){
|
|
79
|
+
return{path:null,cancelled:false,fallbackRequired:true,reason:'No native folder picker is available on this system. Paste your project folder path below.'};
|
|
80
|
+
}
|
|
81
|
+
const stderr=String(error.stderr??error.message??'');
|
|
82
|
+
if(error.code===1&&(stderr.includes('-128')||/user canceled/i.test(stderr))){
|
|
83
|
+
return{path:null,cancelled:true};
|
|
84
|
+
}
|
|
85
|
+
if(error.killed||error.code==='ETIMEDOUT')throw nativeError('native-picker-timeout','launch','The folder window timed out. Try again or paste the project path.');
|
|
86
|
+
if(error.code?.startsWith('native-'))throw error;
|
|
87
|
+
return{path:null,cancelled:false,fallbackRequired:true,reason:'Could not open the macOS folder picker. Paste your project folder path below.'};
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
async function selectLinuxFolder({startDir,signal,runCommand}){
|
|
91
|
+
const zenityArgs=['--file-selection','--directory','--title=Select a project folder'];
|
|
92
|
+
if(startDir)zenityArgs.push(`--filename=${startDir.endsWith('/')?startDir:`${startDir}/`}`);
|
|
93
|
+
try{
|
|
94
|
+
const {stdout}=await runCommand('zenity',zenityArgs,{timeout:300000,maxBuffer:16384,encoding:'utf8',signal});
|
|
95
|
+
const chosen=normalizePickedPosixPath(stdout);
|
|
96
|
+
if(!chosen)return{path:null,cancelled:true};
|
|
97
|
+
return{path:chosen,cancelled:false};
|
|
98
|
+
}catch(error){
|
|
99
|
+
if(error.name==='AbortError')return{path:null,cancelled:true};
|
|
100
|
+
if(error.code===1||error.code===5){
|
|
101
|
+
if(!isDisplayUnavailableError(error))return{path:null,cancelled:true};
|
|
102
|
+
}else if(error.killed||error.code==='ETIMEDOUT'){
|
|
103
|
+
throw nativeError('native-picker-timeout','launch','The folder window timed out. Try again or paste the project path.');
|
|
104
|
+
}else if(error.code!=='ENOENT'&&!isDisplayUnavailableError(error)){
|
|
105
|
+
// Fall through to kdialog fallback
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
const kdialogArgs=['--getexistingdirectory',startDir||os.homedir(),'--title','Select a project folder'];
|
|
109
|
+
try{
|
|
110
|
+
const {stdout}=await runCommand('kdialog',kdialogArgs,{timeout:300000,maxBuffer:16384,encoding:'utf8',signal});
|
|
111
|
+
const chosen=normalizePickedPosixPath(stdout);
|
|
112
|
+
if(!chosen)return{path:null,cancelled:true};
|
|
113
|
+
return{path:chosen,cancelled:false};
|
|
114
|
+
}catch(error){
|
|
115
|
+
if(error.name==='AbortError')return{path:null,cancelled:true};
|
|
116
|
+
if(error.code===1&&!isDisplayUnavailableError(error))return{path:null,cancelled:true};
|
|
117
|
+
if(error.killed||error.code==='ETIMEDOUT'){
|
|
118
|
+
throw nativeError('native-picker-timeout','launch','The folder window timed out. Try again or paste the project path.');
|
|
119
|
+
}
|
|
120
|
+
return{
|
|
121
|
+
path:null,
|
|
122
|
+
cancelled:false,
|
|
123
|
+
fallbackRequired:true,
|
|
124
|
+
reason:'No graphical folder picker (zenity or kdialog) is available on this host. Paste your project folder path below.',
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
}
|
|
56
128
|
let choosing=false;
|
|
57
|
-
export async function selectNativeFolder({initialPath='',stateDir,signal}={}){
|
|
58
|
-
if(choosing)throw nativeError('native-picker-busy','launch','A folder chooser is already open.');
|
|
59
|
-
if(process.platform!=='win32')throw nativeError('native-platform','platform','Native folder picking is available on Windows; paste the project path on this host.');
|
|
129
|
+
export async function selectNativeFolder({initialPath='',stateDir,signal,platform=process.platform,runCommand=execute}={}){
|
|
60
130
|
if(signal?.aborted)return{path:null,cancelled:true};
|
|
131
|
+
if(choosing)throw nativeError('native-picker-busy','launch','A folder chooser is already open.');
|
|
61
132
|
choosing=true;let requestDirectory,stage='compile';
|
|
62
133
|
try{
|
|
63
|
-
const executable=await ensureWindowsHelper({kind:'folder-picker',stateDir,signal});
|
|
64
|
-
const directory=await nativeDirectory(stateDir);
|
|
65
|
-
requestDirectory=await fs.mkdtemp(path.join(directory,'picker-'));
|
|
66
|
-
const resultFile=path.join(requestDirectory,'result.json');stage='launch';
|
|
67
134
|
let startDir='';
|
|
68
135
|
const trimmed=typeof initialPath==='string'?initialPath.trim():'';
|
|
69
136
|
if(trimmed){
|
|
@@ -73,13 +140,25 @@ export async function selectNativeFolder({initialPath='',stateDir,signal}={}){
|
|
|
73
140
|
if(st.isDirectory())startDir=candidate;
|
|
74
141
|
}catch{}
|
|
75
142
|
}
|
|
76
|
-
|
|
143
|
+
if(platform==='darwin'){
|
|
144
|
+
stage='launch';
|
|
145
|
+
return await selectMacOsFolder({startDir,signal,runCommand});
|
|
146
|
+
}
|
|
147
|
+
if(platform!=='win32'){
|
|
148
|
+
stage='launch';
|
|
149
|
+
return await selectLinuxFolder({startDir,signal,runCommand});
|
|
150
|
+
}
|
|
151
|
+
const executable=await ensureWindowsHelper({kind:'folder-picker',stateDir,signal});
|
|
152
|
+
const directory=await nativeDirectory(stateDir);
|
|
153
|
+
requestDirectory=await fs.mkdtemp(path.join(directory,'picker-'));
|
|
154
|
+
const resultFile=path.join(requestDirectory,'result.json');stage='launch';
|
|
155
|
+
await runCommand(executable,[resultFile,startDir],{windowsHide:false,timeout:300000,maxBuffer:16384,encoding:'utf8',signal});
|
|
77
156
|
stage='result';return parseNativeFolderResult(await fs.readFile(resultFile,'utf8'));
|
|
78
157
|
}catch(error){
|
|
79
158
|
if(error.name==='AbortError')return{path:null,cancelled:true};
|
|
80
159
|
if(error.code?.startsWith('native-'))throw error;
|
|
81
160
|
if(error.killed||error.code==='ETIMEDOUT')throw nativeError('native-picker-timeout',stage,'The folder window timed out. Try again or paste the project path.');
|
|
82
|
-
throw nativeError(`native-picker-${stage}`,stage,`Could not complete the
|
|
161
|
+
throw nativeError(`native-picker-${stage}`,stage,`Could not complete the folder window (${stage}). Try again or paste the project path.`);
|
|
83
162
|
}finally{choosing=false;if(requestDirectory)await fs.rm(requestDirectory,{recursive:true,force:true}).catch(()=>{});}
|
|
84
163
|
}
|
|
85
164
|
|
package/workflow-runner.mjs
CHANGED
|
@@ -1198,6 +1198,7 @@ export async function executeWorkflowPipeline({
|
|
|
1198
1198
|
: [];
|
|
1199
1199
|
const gitState = shouldRunDiff ? await inspectGitState(absProject) : { isRepo: false };
|
|
1200
1200
|
|
|
1201
|
+
let gitMissingNotice = null;
|
|
1201
1202
|
if (shouldRunDiff && (baseRef || baselineName || (url && baseUrl) || baselines.length > 0 || (gitState.isRepo && gitState.headSha))) {
|
|
1202
1203
|
try {
|
|
1203
1204
|
const diffRes = await runVisualDiff({
|
|
@@ -1224,6 +1225,30 @@ export async function executeWorkflowPipeline({
|
|
|
1224
1225
|
threshold: diffThreshold,
|
|
1225
1226
|
});
|
|
1226
1227
|
}
|
|
1228
|
+
} else if (recipe?.id === 'branch-diff' && !gitState.isRepo) {
|
|
1229
|
+
gitMissingNotice =
|
|
1230
|
+
'No Git repository detected — run Quick Check / Audit instead, or initialize Git first.';
|
|
1231
|
+
ctx.visualDiff = {
|
|
1232
|
+
status: 'git-required',
|
|
1233
|
+
runId: null,
|
|
1234
|
+
threshold: diffThreshold,
|
|
1235
|
+
maxMismatchPercentage: 0,
|
|
1236
|
+
totalBoundingBoxes: 0,
|
|
1237
|
+
viewports: [],
|
|
1238
|
+
summary: gitMissingNotice,
|
|
1239
|
+
};
|
|
1240
|
+
} else if (recipe?.id === 'branch-diff' && gitState.isRepo && !gitState.headSha) {
|
|
1241
|
+
gitMissingNotice =
|
|
1242
|
+
'No base Git branch or commit detected — make an initial commit or run Quick Check / Audit instead.';
|
|
1243
|
+
ctx.visualDiff = {
|
|
1244
|
+
status: 'git-required',
|
|
1245
|
+
runId: null,
|
|
1246
|
+
threshold: diffThreshold,
|
|
1247
|
+
maxMismatchPercentage: 0,
|
|
1248
|
+
totalBoundingBoxes: 0,
|
|
1249
|
+
viewports: [],
|
|
1250
|
+
summary: gitMissingNotice,
|
|
1251
|
+
};
|
|
1227
1252
|
} else if (ctx.devServerUrl && stateDir) {
|
|
1228
1253
|
try {
|
|
1229
1254
|
ctx.livePlaywrightReport = await captureMultiRouteUrl({
|
|
@@ -1252,11 +1277,14 @@ export async function executeWorkflowPipeline({
|
|
|
1252
1277
|
const designLockFailed = strictDs && !ctx.designSystemLock.compliant;
|
|
1253
1278
|
const visualStatus = designLockFailed
|
|
1254
1279
|
? 'failed'
|
|
1255
|
-
:
|
|
1280
|
+
: gitMissingNotice ||
|
|
1281
|
+
!ctx.designSystemLock.compliant ||
|
|
1282
|
+
ctx.visualDiff.maxMismatchPercentage > diffThreshold * 100
|
|
1256
1283
|
? 'warning'
|
|
1257
1284
|
: 'passed';
|
|
1258
1285
|
|
|
1259
1286
|
const details = [
|
|
1287
|
+
...(gitMissingNotice ? [gitMissingNotice] : []),
|
|
1260
1288
|
`Component check: ${ctx.designSystemLock.compliant ? `clean (${ctx.designSystemLock.filesScanned} files)` : `${ctx.designSystemLock.violationCount} issue(s)`}`,
|
|
1261
1289
|
`Visual diff: ${ctx.visualDiff.summary}`,
|
|
1262
1290
|
...(ctx.branchDiff ? [`Comparison: ${ctx.branchDiff.comparisonLabel}`] : []),
|
|
@@ -1268,7 +1296,10 @@ export async function executeWorkflowPipeline({
|
|
|
1268
1296
|
return {
|
|
1269
1297
|
status: visualStatus,
|
|
1270
1298
|
source: ctx.branchDiff || ctx.livePlaywrightReport || ctx.visualDiff.viewports.length > 0 ? 'live' : 'static',
|
|
1271
|
-
summary:
|
|
1299
|
+
summary: gitMissingNotice
|
|
1300
|
+
? gitMissingNotice
|
|
1301
|
+
: `Components: ${ctx.designSystemLock.compliant ? 'clean' : `${ctx.designSystemLock.violationCount} issue(s)`} · ${ctx.visualDiff.viewports.length > 0 ? `${ctx.visualDiff.maxMismatchPercentage}% diff` : 'Static check'}`,
|
|
1302
|
+
...(gitMissingNotice ? { remediation: gitMissingNotice } : {}),
|
|
1272
1303
|
details,
|
|
1273
1304
|
output: {
|
|
1274
1305
|
compliant: ctx.designSystemLock.compliant,
|