@ultimat3/cli 31.51.0 → 31.53.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/CLAUDE.md +1 -1
- package/README.md +9 -9
- package/package.json +29 -29
- package/src/app-kit-disk.ts +39 -0
- package/src/app-kit-forms.ts +27 -0
- package/src/app-kit.ts +146 -0
- package/src/budgets.ts +3 -1
- package/src/catalog-layout.ts +194 -0
- package/src/cdp-shot-driver-screen.ts +72 -0
- package/src/cdp-shot-driver.ts +17 -1
- package/src/cmd-design-capture.ts +210 -0
- package/src/cmd-design-errors.ts +50 -0
- package/src/cmd-design-paths.ts +47 -0
- package/src/cmd-design-publish.ts +64 -0
- package/src/cmd-design-run.ts +229 -0
- package/src/cmd-design-spec.ts +47 -0
- package/src/cmd-design-theme.ts +107 -0
- package/src/cmd-design-url.ts +201 -0
- package/src/cmd-design.ts +188 -0
- package/src/cmd-doctor.ts +3 -0
- package/src/cmd-generate-spec.ts +5 -0
- package/src/cmd-generate.ts +3 -1
- package/src/cmd-i18n-spec.ts +4 -4
- package/src/cmd-i18n-split.ts +133 -0
- package/src/cmd-i18n.ts +46 -66
- package/src/cmd-kit-spec.ts +13 -0
- package/src/cmd-kit.ts +133 -0
- package/src/cmd-shot-against.ts +275 -0
- package/src/cmd-shot-spec.ts +9 -1
- package/src/cmd-shot.ts +19 -0
- package/src/cmd-upgrade.ts +11 -0
- package/src/codemods/agent-kit.ts +130 -0
- package/src/codemods/agents-md-budget.ts +47 -0
- package/src/codemods/docs-visual-quality.ts +198 -0
- package/src/codemods/index.ts +8 -0
- package/src/codemods/settings-kit-allow.ts +49 -0
- package/src/config-redact.ts +20 -4
- package/src/db-rollback-pass.ts +4 -1
- package/src/design-extract-script.ts +187 -0
- package/src/design-extract.ts +311 -0
- package/src/design-map-colors.ts +180 -0
- package/src/design-map.ts +288 -0
- package/src/dev-child-watch.ts +16 -0
- package/src/dev-db-migrate.ts +27 -46
- package/src/dev-db-migrator-hold.ts +131 -0
- package/src/dev-db-rollback.ts +11 -2
- package/src/dev-rebuild-schema.ts +7 -24
- package/src/doctor-kit.ts +25 -0
- package/src/error-catalog.ts +4 -2
- package/src/error-codes-kit.ts +24 -0
- package/src/error-codes.ts +12 -10
- package/src/generate-catalog-locales.ts +25 -2
- package/src/generate-files.ts +31 -1
- package/src/generate-follow-ups.ts +8 -3
- package/src/guards-shipped-names.ts +5 -0
- package/src/i18n-audit.ts +17 -33
- package/src/i18n-index.ts +108 -31
- package/src/i18n-locale-parity.ts +14 -6
- package/src/i18n-new-locale.ts +75 -0
- package/src/i18n-registration.ts +52 -27
- package/src/island-capture.ts +36 -7
- package/src/kit/agent-audit.ts +49 -0
- package/src/kit/agent-data.ts +32 -0
- package/src/kit/agent-server.ts +34 -0
- package/src/kit/agent-shape.ts +61 -0
- package/src/kit/agent-web.ts +49 -0
- package/src/kit/design-map.ts +106 -0
- package/src/kit/managed.ts +12 -0
- package/src/kit/registry.ts +89 -0
- package/src/kit/skill-design-research.ts +119 -0
- package/src/kit/skill-feature.ts +159 -0
- package/src/kit/skill-planx.ts +139 -0
- package/src/kit/skill-upgrade.ts +94 -0
- package/src/kit/skill-verify.ts +80 -0
- package/src/mcp-errors.ts +5 -0
- package/src/mcp-ui-diff.ts +13 -38
- package/src/mcp-ui.ts +30 -1
- package/src/merge-state.ts +3 -2
- package/src/messages-design.ts +104 -0
- package/src/messages-floor.ts +2 -0
- package/src/messages-upgrade.ts +9 -0
- package/src/messages.ts +4 -0
- package/src/registry.ts +4 -0
- package/src/serve-boot-telemetry.ts +106 -0
- package/src/serve-boot.ts +23 -4
- package/src/shot-blank.ts +70 -0
- package/src/shot-diff.ts +96 -0
- package/src/shot-gpu.ts +17 -5
- package/src/templates/catalog-barrel.ts +84 -0
- package/src/templates/guard-animated-layout-script.ts +173 -0
- package/src/templates/guard-effect-without-fallback.ts +117 -0
- package/src/templates/guard-motion-adapter.ts +161 -0
- package/src/templates/guard-raw-frame-loop.ts +134 -0
- package/src/templates/guard-raw-motion-script.ts +132 -0
- package/src/templates/guard-raw-motion-ts-scan.ts +95 -0
- package/src/templates/guard-released-forms.ts +12 -1
- package/src/templates/guard-untranslated-string.ts +27 -6
- package/src/templates/index.ts +1 -2
- package/src/templates/island.ts +55 -8
- package/src/templates/kit-released-forms.ts +63 -0
- package/src/templates/locales.ts +6 -0
- package/src/templates/motion-scale.ts +115 -0
- package/src/templates/scaffold-claude.ts +39 -26
- package/src/templates/scaffold-design.ts +41 -0
- package/src/templates/scaffold-docs.ts +31 -7
- package/src/templates/scaffold-gitattributes.ts +9 -2
- package/src/templates/scaffold-guards.ts +31 -2
- package/src/templates/scaffold-i18n.ts +10 -6
- package/src/templates/scaffold-verify-floor.ts +3 -0
- package/src/templates/shapes/blog-site.ts +15 -0
- package/src/templates/shapes/blog.ts +2 -0
- package/src/templates/shapes/content-site.ts +13 -0
- package/src/templates/shapes/content.ts +2 -0
- package/src/templates/shapes/dashboard-detail.ts +2 -0
- package/src/templates/shapes/dashboard-motion.ts +284 -0
- package/src/templates/shapes/dashboard.ts +19 -1
- package/src/templates/shapes/landing-motion.ts +67 -0
- package/src/templates/shapes/offline.ts +5 -2
- package/src/templates/shapes/saas.ts +4 -0
- package/src/test-ignores.ts +3 -2
- package/src/upgrade-gate.ts +14 -2
- package/src/upgrade-kit.ts +65 -0
- package/src/upgrade-report-kit.ts +28 -0
- package/src/upgrade-report.ts +3 -0
- package/src/verify-checks.ts +9 -1
- package/src/verify-floor.ts +9 -1
- package/src/verify-local-only.ts +66 -0
- package/src/verify-run.ts +17 -2
- package/src/workspace-checks.ts +3 -3
- package/wiki/Actions.md +1 -1
- package/wiki/Agents.md +33 -1
- package/wiki/Auth.md +3 -3
- package/wiki/Batching-And-Preloading.md +1 -0
- package/wiki/CLI-Reference-Data.md +241 -0
- package/wiki/CLI-Reference-Gate.md +572 -0
- package/wiki/CLI-Reference-Project.md +414 -0
- package/wiki/CLI-Reference-Ship.md +348 -0
- package/wiki/CLI-Reference-Tools.md +687 -0
- package/wiki/CLI-Reference.md +18 -2227
- package/wiki/Compared.md +8 -8
- package/wiki/Configuration.md +26 -2
- package/wiki/Deployment.md +1 -1
- package/wiki/Design-Research.md +96 -0
- package/wiki/Effects.md +83 -0
- package/wiki/Entities-And-Migrations.md +3 -2
- package/wiki/FAQ.md +1 -1
- package/wiki/Getting-Started.md +1 -1
- package/wiki/Home.md +2 -2
- package/wiki/I18n.md +39 -5
- package/wiki/Installation.md +1 -1
- package/wiki/Jobs-And-Workflows.md +29 -1
- package/wiki/Known-Gaps.md +6 -2
- package/wiki/MCP-And-AI.md +4 -0
- package/wiki/Motion.md +85 -0
- package/wiki/Observability.md +15 -1
- package/wiki/Outbound-HTTP.md +62 -2
- package/wiki/PWA-And-Offline.md +1 -1
- package/wiki/Policies-And-Authz.md +10 -0
- package/wiki/Project-Layout.md +1 -1
- package/wiki/Realtime.md +29 -2
- package/wiki/Static-Assets.md +1 -1
- package/wiki/Testing.md +33 -0
- package/wiki/Theming.md +31 -8
- package/wiki/Troubleshooting.md +1 -1
- package/wiki/Tutorial-02-First-Feature.md +1 -1
- package/wiki/UI-Components.md +2 -0
- package/wiki/Upgrading.md +9 -3
- package/src/templates/scaffold-claude-agents.ts +0 -161
- package/src/templates/scaffold-claude-commands.ts +0 -239
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// `x design`'s declaration, apart from its body: the parser, `x help` and the `errors` step read it
|
|
2
|
+
// without loading `cmd-design.ts`, which `registry.ts` imports only when the command runs.
|
|
3
|
+
|
|
4
|
+
import type { CommandSpec } from './parse';
|
|
5
|
+
|
|
6
|
+
export const DESIGN_SUBCOMMANDS = ['research'] as const;
|
|
7
|
+
|
|
8
|
+
export const designSpec: CommandSpec = {
|
|
9
|
+
name: 'design',
|
|
10
|
+
summary:
|
|
11
|
+
'research a reference site: shots, measured palette/type/spacing/motion, a defineTheme() proposal and a motion map',
|
|
12
|
+
usage:
|
|
13
|
+
'x design research <url…> [--follow <n>] [--out .x/design] [--viewport 390x844,1440x900] [--allow-hosts <h,…>] [--timeout <ms>] [--json] · x design research --list',
|
|
14
|
+
// No default: `research` drives a browser at the web, which is typed or not run.
|
|
15
|
+
subcommands: [...DESIGN_SUBCOMMANDS],
|
|
16
|
+
flags: [
|
|
17
|
+
{
|
|
18
|
+
name: 'follow',
|
|
19
|
+
type: 'string',
|
|
20
|
+
summary:
|
|
21
|
+
'also research up to n links of each reference: same origin, or a --allow-hosts host',
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: 'out',
|
|
25
|
+
type: 'string',
|
|
26
|
+
summary: 'where each reference directory is written (default .x/design, never committed)',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'viewport',
|
|
30
|
+
type: 'string',
|
|
31
|
+
summary:
|
|
32
|
+
'<w>x<h>[,<w>x<h>] — the sizes each reference is photographed at (default 390x844,1440x900)',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'allow-hosts',
|
|
36
|
+
type: 'string',
|
|
37
|
+
summary:
|
|
38
|
+
'extra public hosts --follow may visit; never widens what the browser may reach (private addresses stay refused)',
|
|
39
|
+
},
|
|
40
|
+
{ name: 'timeout', type: 'string', summary: 'ms one reference navigation may take' },
|
|
41
|
+
{
|
|
42
|
+
name: 'list',
|
|
43
|
+
type: 'boolean',
|
|
44
|
+
summary: 'the default reference catalogues and the licence posture each is held to',
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// `@ultimat3/ui`'s palette tables and `defineTheme`, reached at run time. The CLI does not depend on
|
|
2
|
+
// `@ultimat3/ui` (`error-catalog.ts` names it an optional host for the same reason), and an app that
|
|
3
|
+
// researches a design has it installed: resolved, the proposal's colours are contrast-checked and
|
|
4
|
+
// then handed to `defineTheme` itself; unresolved, the proposal carries no colours at all.
|
|
5
|
+
|
|
6
|
+
import type { DesignProposal, ThemeTables } from './design-map';
|
|
7
|
+
|
|
8
|
+
export interface ThemeHost {
|
|
9
|
+
readonly tables: ThemeTables;
|
|
10
|
+
/** `defineTheme`, which throws on a proposal it refuses. */
|
|
11
|
+
readonly defineTheme: (input: DesignProposal) => unknown;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const record = (value: unknown): Record<string, unknown> | undefined =>
|
|
15
|
+
typeof value === 'object' && value !== null ? (value as Record<string, unknown>) : undefined;
|
|
16
|
+
|
|
17
|
+
const stringTable = (value: unknown): Record<string, string> | undefined => {
|
|
18
|
+
const table = record(value);
|
|
19
|
+
if (table === undefined) return undefined;
|
|
20
|
+
return Object.values(table).every((entry) => typeof entry === 'string')
|
|
21
|
+
? (table as Record<string, string>)
|
|
22
|
+
: undefined;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const pairList = (value: unknown): ThemeTables['pairs'] =>
|
|
26
|
+
(Array.isArray(value) ? value : []).flatMap((entry: unknown) => {
|
|
27
|
+
const pair = record(entry);
|
|
28
|
+
const fg = pair?.['fg'];
|
|
29
|
+
const bg = pair?.['bg'];
|
|
30
|
+
const minimum = pair?.['minimum'];
|
|
31
|
+
return typeof fg === 'string' && typeof bg === 'string' && typeof minimum === 'number'
|
|
32
|
+
? [{ fg, bg, minimum }]
|
|
33
|
+
: [];
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
/** The module's exports read as `unknown` and checked: a version that renamed one is no host. */
|
|
37
|
+
export function themeHostOf(module: unknown): ThemeHost | undefined {
|
|
38
|
+
const ui = record(module);
|
|
39
|
+
const tokens = record(ui?.['colorTokens']);
|
|
40
|
+
const light = stringTable(tokens?.['light']);
|
|
41
|
+
const dark = stringTable(tokens?.['dark']);
|
|
42
|
+
const aliases = stringTable(ui?.['COLOR_ALIASES']);
|
|
43
|
+
const contrast = ui?.['contrastRatio'];
|
|
44
|
+
const define = ui?.['defineTheme'];
|
|
45
|
+
if (
|
|
46
|
+
light === undefined ||
|
|
47
|
+
dark === undefined ||
|
|
48
|
+
aliases === undefined ||
|
|
49
|
+
typeof contrast !== 'function' ||
|
|
50
|
+
typeof define !== 'function'
|
|
51
|
+
) {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
tables: {
|
|
56
|
+
colors: { light, dark },
|
|
57
|
+
aliases,
|
|
58
|
+
pairs: [...pairList(ui?.['CONTRAST_PAIRS']), ...pairList(ui?.['ALIAS_CONTRAST_PAIRS'])],
|
|
59
|
+
contrast: (a, b) => Number(contrast(a, b)),
|
|
60
|
+
},
|
|
61
|
+
defineTheme: (input) => define(input),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** The specifier is a value, not a literal: `tsc` must not resolve a package the CLI never declares. */
|
|
66
|
+
const UI_SPECIFIER = '@ultimat3/ui';
|
|
67
|
+
|
|
68
|
+
export async function loadThemeHost(
|
|
69
|
+
load: (specifier: string) => Promise<unknown> = (specifier) => import(specifier),
|
|
70
|
+
): Promise<ThemeHost | undefined> {
|
|
71
|
+
try {
|
|
72
|
+
return themeHostOf(await load(UI_SPECIFIER));
|
|
73
|
+
} catch {
|
|
74
|
+
// Not installed beside the CLI: the documented degraded path, reported in reference.json.
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The proposal `defineTheme` accepts, by `defineTheme`'s own verdict: as mapped, else without its
|
|
81
|
+
* colours (a palette rule this CLI predates), else `{}` marked unvalidated — never a proposal that
|
|
82
|
+
* would not boot, and never a thrown run.
|
|
83
|
+
*/
|
|
84
|
+
export function acceptedProposal(
|
|
85
|
+
proposal: DesignProposal,
|
|
86
|
+
host: ThemeHost | undefined,
|
|
87
|
+
): {
|
|
88
|
+
readonly proposal: DesignProposal;
|
|
89
|
+
readonly validated: boolean;
|
|
90
|
+
} {
|
|
91
|
+
if (host === undefined) return { proposal, validated: false };
|
|
92
|
+
if (accepts(host, proposal)) return { proposal, validated: true };
|
|
93
|
+
const { colors: _dropped, ...rest } = proposal;
|
|
94
|
+
if (accepts(host, rest)) return { proposal: rest, validated: true };
|
|
95
|
+
// A rule this CLI does not know refuses more than colours: an empty proposal is still a
|
|
96
|
+
// `defineTheme` argument, and a research run never dies over a token it could not validate.
|
|
97
|
+
return { proposal: {}, validated: false };
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const accepts = (host: ThemeHost, proposal: DesignProposal): boolean => {
|
|
101
|
+
try {
|
|
102
|
+
host.defineTheme(proposal);
|
|
103
|
+
return true;
|
|
104
|
+
} catch {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
};
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
// Which URLs `x design research` may reach: the typed reference, every link `--follow` visits, and —
|
|
2
|
+
// through the CDP driver's interception — every navigation, redirect and subresource the page asks
|
|
3
|
+
// for. One policy for all of them: public hosts only. The screen is core's (`hostDecision`'s address
|
|
4
|
+
// floor, `screenDial`'s resolve-and-classify), the one `@ultimat3/scraping`'s browser leg uses too.
|
|
5
|
+
|
|
6
|
+
import type { HostRule } from '@ultimat3/core';
|
|
7
|
+
import { ANY_HOST, classifyAddress, hostDecision, hostMatches } from '@ultimat3/core';
|
|
8
|
+
import type { DialResolve } from '@ultimat3/core/outbound';
|
|
9
|
+
import { resolveDialHost, screenDial } from '@ultimat3/core/outbound';
|
|
10
|
+
import { DEFAULT_PAGE_TIMEOUT_MS } from './cdp-shot-clock';
|
|
11
|
+
import type { DialRefusal } from './cdp-shot-driver-screen';
|
|
12
|
+
import { DesignReferenceUnreachableError, DesignUrlRefusedError } from './cmd-design-errors';
|
|
13
|
+
import { designSlug } from './cmd-design-paths';
|
|
14
|
+
import { BadFlagError } from './errors';
|
|
15
|
+
|
|
16
|
+
export interface DesignHostPolicy {
|
|
17
|
+
/** `*` plus any harness-trusted host: core's floor keeps the wildcard off every inward literal. */
|
|
18
|
+
readonly allowHosts: readonly HostRule[];
|
|
19
|
+
/** Exact hosts admitted without a resolve — a TEST HARNESS seam, never a flag. */
|
|
20
|
+
readonly trustedHosts: readonly string[];
|
|
21
|
+
readonly resolve: DialResolve;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* `trustedHosts` exists so a fixture server on 127.0.0.1 can be researched in a test: injected by
|
|
26
|
+
* the harness through the run's options, and deliberately absent from the command's flags — a
|
|
27
|
+
* flag that admitted loopback would be the SSRF this policy exists to refuse.
|
|
28
|
+
*/
|
|
29
|
+
export function designHostPolicy(input: {
|
|
30
|
+
readonly resolve?: DialResolve | undefined;
|
|
31
|
+
readonly trustedHosts?: readonly string[] | undefined;
|
|
32
|
+
}): DesignHostPolicy {
|
|
33
|
+
const trustedHosts = input.trustedHosts ?? [];
|
|
34
|
+
return {
|
|
35
|
+
allowHosts: [ANY_HOST, ...trustedHosts],
|
|
36
|
+
trustedHosts,
|
|
37
|
+
resolve: input.resolve ?? resolveDialHost,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** The reference as typed: http(s), no credentials. Anything else is refused by name. */
|
|
42
|
+
export function readReferenceUrl(raw: string): string {
|
|
43
|
+
let parsed: URL;
|
|
44
|
+
try {
|
|
45
|
+
parsed = new URL(raw);
|
|
46
|
+
} catch {
|
|
47
|
+
throw new DesignUrlRefusedError({ url: raw, reason: 'is not an absolute URL' });
|
|
48
|
+
}
|
|
49
|
+
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
|
|
50
|
+
throw new DesignUrlRefusedError({ url: raw, reason: `is ${parsed.protocol}, not http(s)` });
|
|
51
|
+
}
|
|
52
|
+
if (parsed.username !== '' || parsed.password !== '') {
|
|
53
|
+
throw new DesignUrlRefusedError({
|
|
54
|
+
url: raw,
|
|
55
|
+
reason: 'carries credentials, which would ride every request the page makes',
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return raw;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const hostnameOf = (url: URL): string => url.hostname.replace(/^\[|\]$/g, '');
|
|
62
|
+
|
|
63
|
+
const isTrusted = (hostname: string, policy: DesignHostPolicy): boolean =>
|
|
64
|
+
policy.trustedHosts.some((rule) => hostMatches(hostname, rule));
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The typed URL, screened before a browser exists: the address floor, then — for a name — every
|
|
68
|
+
* address it resolves to. A name that does not resolve is unreachable, not refused: nothing about
|
|
69
|
+
* it is inside the network, it is simply not there.
|
|
70
|
+
*/
|
|
71
|
+
export async function screenReference(url: string, policy: DesignHostPolicy): Promise<void> {
|
|
72
|
+
if (!hostDecision(url, policy.allowHosts).allowed) {
|
|
73
|
+
throw new DesignUrlRefusedError({
|
|
74
|
+
url,
|
|
75
|
+
reason: 'names a loopback, private or link-local address',
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
const parsed = new URL(url);
|
|
79
|
+
const hostname = hostnameOf(parsed);
|
|
80
|
+
if (classifyAddress(hostname) !== undefined || isTrusted(hostname, policy)) return;
|
|
81
|
+
const verdict = await screenDial(parsed, { resolve: policy.resolve });
|
|
82
|
+
if ('pin' in verdict) return;
|
|
83
|
+
if ('unresolved' in verdict) {
|
|
84
|
+
throw new DesignReferenceUnreachableError({
|
|
85
|
+
url,
|
|
86
|
+
reason: verdict.unresolved,
|
|
87
|
+
timeoutMs: DEFAULT_PAGE_TIMEOUT_MS,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
// The class, never the address: core's own rule for a refusal reason.
|
|
91
|
+
throw new DesignUrlRefusedError({ url, reason: `resolves to a ${verdict.refused} address` });
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** The schemes the browser dials by name. */
|
|
95
|
+
const DIALLED = new Set(['http:', 'https:', 'ws:', 'wss:']);
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* The driver's `dialScreen.screen`: `undefined` when the floor decides alone (a literal, a hostless
|
|
99
|
+
* scheme, a trusted host), else the refusal or `undefined` to release. A DEFINITE answer — every
|
|
100
|
+
* address public, or one not — is memoised per name for the session: a page asks for the same CDN a
|
|
101
|
+
* hundred times. A resolver failure or an empty answer is `unresolved` and asked again next time:
|
|
102
|
+
* a transient SERVFAIL proves nothing about where the name points, so it is never cached, and
|
|
103
|
+
* never reported as private.
|
|
104
|
+
*/
|
|
105
|
+
export function browserDialScreen(
|
|
106
|
+
policy: DesignHostPolicy,
|
|
107
|
+
): (url: string) => Promise<DialRefusal | undefined> | undefined {
|
|
108
|
+
const known = new Map<string, DialRefusal | 'public'>();
|
|
109
|
+
return (url) => {
|
|
110
|
+
let parsed: URL;
|
|
111
|
+
try {
|
|
112
|
+
parsed = new URL(url);
|
|
113
|
+
} catch {
|
|
114
|
+
return undefined;
|
|
115
|
+
}
|
|
116
|
+
if (!DIALLED.has(parsed.protocol)) return undefined;
|
|
117
|
+
const hostname = hostnameOf(parsed);
|
|
118
|
+
if (hostname === '' || classifyAddress(hostname) !== undefined) return undefined;
|
|
119
|
+
if (isTrusted(hostname, policy)) return undefined;
|
|
120
|
+
const held = known.get(hostname);
|
|
121
|
+
if (held !== undefined) return Promise.resolve(held === 'public' ? undefined : held);
|
|
122
|
+
return screenDial(parsed, { resolve: policy.resolve }).then(
|
|
123
|
+
(verdict): DialRefusal | undefined => {
|
|
124
|
+
if ('unresolved' in verdict) return 'unresolved';
|
|
125
|
+
known.set(hostname, 'pin' in verdict ? 'public' : 'private');
|
|
126
|
+
return 'pin' in verdict ? undefined : 'private';
|
|
127
|
+
},
|
|
128
|
+
(): DialRefusal => 'unresolved',
|
|
129
|
+
);
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* `--allow-hosts`: the hosts `--follow` may visit beyond the reference's own origin. A public name
|
|
135
|
+
* or a `*.` suffix; never `*`, `localhost` or an inward literal — the flag widens what is FOLLOWED,
|
|
136
|
+
* and it can never widen what the browser may reach.
|
|
137
|
+
*/
|
|
138
|
+
export function readDesignAllowHosts(raw: string | undefined): readonly string[] {
|
|
139
|
+
if (raw === undefined) return [];
|
|
140
|
+
return raw.split(',').map((entry) => {
|
|
141
|
+
const host = entry.trim().toLowerCase();
|
|
142
|
+
if (host === '' || host === ANY_HOST) {
|
|
143
|
+
throw new BadFlagError({
|
|
144
|
+
flag: 'allow-hosts',
|
|
145
|
+
command: 'design research',
|
|
146
|
+
reason: host === '' ? 'lists an empty host' : '* would follow every link on the web',
|
|
147
|
+
fix: 'x design research https://example.com/ --follow 5 --allow-hosts docs.example.com',
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
const literal = classifyAddress(host);
|
|
151
|
+
const name = host.replace(/\.$/, '');
|
|
152
|
+
if (
|
|
153
|
+
(literal !== undefined && literal !== 'public') ||
|
|
154
|
+
name === 'localhost' ||
|
|
155
|
+
name.endsWith('.localhost')
|
|
156
|
+
) {
|
|
157
|
+
throw new DesignUrlRefusedError({
|
|
158
|
+
url: host,
|
|
159
|
+
reason: 'names a loopback, private or link-local host',
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
return host;
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* The links `--follow <n>` visits: same origin as the reference, or a host `--allow-hosts` names;
|
|
168
|
+
* http(s) only, the fragment dropped, a page whose slug is already taken skipped, in page order,
|
|
169
|
+
* at most `n`. Each is screened again before it is visited, exactly like the reference.
|
|
170
|
+
*/
|
|
171
|
+
export function followTargets(
|
|
172
|
+
reference: string,
|
|
173
|
+
links: readonly string[],
|
|
174
|
+
allowHosts: readonly string[],
|
|
175
|
+
n: number,
|
|
176
|
+
): readonly string[] {
|
|
177
|
+
const origin = new URL(reference);
|
|
178
|
+
// Deduped on the DIRECTORY a page is written to, not its href: `/docs/`, `/docs?tab=2` and the
|
|
179
|
+
// reference's own `/docs` share one slug, and a followed page must never overwrite another's.
|
|
180
|
+
const seen = new Set([designSlug(reference)]);
|
|
181
|
+
const out: string[] = [];
|
|
182
|
+
for (const link of links) {
|
|
183
|
+
if (out.length >= n) break;
|
|
184
|
+
let parsed: URL;
|
|
185
|
+
try {
|
|
186
|
+
parsed = new URL(link);
|
|
187
|
+
} catch {
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') continue;
|
|
191
|
+
parsed.hash = '';
|
|
192
|
+
const allowed =
|
|
193
|
+
parsed.origin === origin.origin ||
|
|
194
|
+
allowHosts.some((rule) => hostMatches(parsed.hostname, rule));
|
|
195
|
+
const slug = designSlug(parsed.href);
|
|
196
|
+
if (!allowed || seen.has(slug)) continue;
|
|
197
|
+
seen.add(slug);
|
|
198
|
+
out.push(parsed.href);
|
|
199
|
+
}
|
|
200
|
+
return out;
|
|
201
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
// `x design research <url…>` — the command: flags read, a reference site measured into tokens,
|
|
2
|
+
// motion calls and effects entries, the result rendered.
|
|
3
|
+
//
|
|
4
|
+
// The mechanism; the `design-research` skill is the procedure that drives it. Never a gate step: it
|
|
5
|
+
// needs a browser and the public web. Everything captured lands in `.x/design/` (ignored):
|
|
6
|
+
// third-party pixels are never committed.
|
|
7
|
+
|
|
8
|
+
// why: Bun exposes no path primitives; `--out` resolves against the caller's cwd.
|
|
9
|
+
import { join, resolve } from 'node:path';
|
|
10
|
+
import { finiteCount } from '@ultimat3/core';
|
|
11
|
+
import type { DialResolve } from '@ultimat3/core/outbound';
|
|
12
|
+
import type { ShotDriver } from './browser-launcher-port';
|
|
13
|
+
import { DEFAULT_PAGE_TIMEOUT_MS } from './cdp-shot-clock';
|
|
14
|
+
import { cdpShotDriver } from './cdp-shot-driver';
|
|
15
|
+
import type { DesignDriverFor } from './cmd-design-capture';
|
|
16
|
+
import { DESIGN_DIR, DESIGN_VIEWPORTS } from './cmd-design-paths';
|
|
17
|
+
import { type ResearchOutcome, researchDesign, researchJson } from './cmd-design-run';
|
|
18
|
+
import { designSpec } from './cmd-design-spec';
|
|
19
|
+
import { loadThemeHost } from './cmd-design-theme';
|
|
20
|
+
import { designHostPolicy, readDesignAllowHosts } from './cmd-design-url';
|
|
21
|
+
import type { CliCommand, CommandContext } from './command';
|
|
22
|
+
import { BadFlagError, MissingPositionalError } from './errors';
|
|
23
|
+
import { intFlagOr } from './flag-number';
|
|
24
|
+
import { msg } from './messages';
|
|
25
|
+
import { DESIGN_SOURCES } from './messages-design';
|
|
26
|
+
import type { CommandResult } from './output';
|
|
27
|
+
import type { ParsedArgs } from './parse';
|
|
28
|
+
import { flagBool, flagString } from './parse';
|
|
29
|
+
import type { Env } from './runtime-bindings';
|
|
30
|
+
import { shotBrowserChoice } from './shot-browser';
|
|
31
|
+
import type { ShotViewport } from './shot-viewport';
|
|
32
|
+
import { parseViewports } from './shot-viewport';
|
|
33
|
+
|
|
34
|
+
/** Links per reference `--follow` may take: a catalogue page, not a crawl. */
|
|
35
|
+
export const FOLLOW_MAX = 20;
|
|
36
|
+
|
|
37
|
+
const EXAMPLE = 'x design research https://example.com/ --json';
|
|
38
|
+
|
|
39
|
+
const intFlag = (args: ParsedArgs, name: string, min: number, fallback: number, max?: number) =>
|
|
40
|
+
intFlagOr(
|
|
41
|
+
args,
|
|
42
|
+
{
|
|
43
|
+
name,
|
|
44
|
+
command: 'design research',
|
|
45
|
+
min,
|
|
46
|
+
...(max === undefined ? {} : { max }),
|
|
47
|
+
example: `x design research https://example.com/ --${name} ${String(fallback)}`,
|
|
48
|
+
},
|
|
49
|
+
fallback,
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
export interface DesignRunInput {
|
|
53
|
+
readonly urls: readonly string[];
|
|
54
|
+
readonly outDir: string;
|
|
55
|
+
readonly env: Env;
|
|
56
|
+
readonly follow?: number | undefined;
|
|
57
|
+
readonly viewports?: readonly ShotViewport[] | undefined;
|
|
58
|
+
readonly allowHosts?: readonly string[] | undefined;
|
|
59
|
+
readonly timeoutMs?: number | undefined;
|
|
60
|
+
/** Test seams, never flags: the browser, the resolver, and hosts admitted without one. */
|
|
61
|
+
readonly driver?: ((viewport: ShotViewport) => Promise<ShotDriver>) | undefined;
|
|
62
|
+
readonly resolve?: DialResolve | undefined;
|
|
63
|
+
readonly trustedHosts?: readonly string[] | undefined;
|
|
64
|
+
/** `ui.research`'s cancellation: no browser is launched, and nothing published, after it. */
|
|
65
|
+
readonly signal?: AbortSignal | undefined;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** The one body behind the command and `ui.research`. */
|
|
69
|
+
export async function runDesignResearch(input: DesignRunInput): Promise<ResearchOutcome> {
|
|
70
|
+
const driverFor: DesignDriverFor = async (viewport, dialScreen) => {
|
|
71
|
+
if (input.driver !== undefined) return input.driver(viewport);
|
|
72
|
+
// The same choice `x shot` makes, from the environment: a local Chrome or an attach URL.
|
|
73
|
+
const { cdpUrl, executablePath } = shotBrowserChoice({
|
|
74
|
+
cdpFlag: undefined,
|
|
75
|
+
browserFlag: undefined,
|
|
76
|
+
env: input.env,
|
|
77
|
+
});
|
|
78
|
+
return cdpShotDriver({
|
|
79
|
+
...(cdpUrl === undefined ? {} : { cdpUrl }),
|
|
80
|
+
...(executablePath === undefined ? {} : { executablePath }),
|
|
81
|
+
viewport,
|
|
82
|
+
dialScreen,
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
return researchDesign({
|
|
86
|
+
urls: input.urls,
|
|
87
|
+
// Screened here as well as by the flag reader: `ui.research` reaches this with an agent's number.
|
|
88
|
+
follow: finiteCount('x design research', 'follow', input.follow ?? 0),
|
|
89
|
+
outDir: input.outDir,
|
|
90
|
+
viewports: input.viewports ?? DESIGN_VIEWPORTS,
|
|
91
|
+
allowHosts: input.allowHosts ?? [],
|
|
92
|
+
timeoutMs: finiteCount(
|
|
93
|
+
'x design research',
|
|
94
|
+
'timeoutMs',
|
|
95
|
+
input.timeoutMs ?? DEFAULT_PAGE_TIMEOUT_MS,
|
|
96
|
+
1,
|
|
97
|
+
),
|
|
98
|
+
policy: designHostPolicy({ resolve: input.resolve, trustedHosts: input.trustedHosts }),
|
|
99
|
+
driverFor,
|
|
100
|
+
themeHost: await loadThemeHost(),
|
|
101
|
+
now: () => new Date(),
|
|
102
|
+
signal: input.signal,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function designListResult(): CommandResult {
|
|
107
|
+
return {
|
|
108
|
+
ok: true,
|
|
109
|
+
command: 'design',
|
|
110
|
+
summary: msg('cli.design.list', { count: DESIGN_SOURCES.length }),
|
|
111
|
+
lines: DESIGN_SOURCES.map((source) =>
|
|
112
|
+
msg('cli.design.source', {
|
|
113
|
+
name: source.name,
|
|
114
|
+
url: source.url,
|
|
115
|
+
posture: source.posture,
|
|
116
|
+
why: source.why,
|
|
117
|
+
}),
|
|
118
|
+
),
|
|
119
|
+
data: {
|
|
120
|
+
sources: DESIGN_SOURCES.map((source) => ({ ...source, hosts: [...source.hosts] })),
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function designResult(outcome: ResearchOutcome, out: string): CommandResult {
|
|
126
|
+
return {
|
|
127
|
+
ok: true,
|
|
128
|
+
command: 'design',
|
|
129
|
+
summary: msg('cli.design.summary', { count: outcome.references.length, out }),
|
|
130
|
+
lines: [
|
|
131
|
+
...outcome.references.flatMap((reference) => [
|
|
132
|
+
msg('cli.design.reference', { url: reference.url, dir: reference.dir }),
|
|
133
|
+
msg('cli.design.facts', {
|
|
134
|
+
colors: reference.colors,
|
|
135
|
+
animations: reference.animations,
|
|
136
|
+
refused: reference.refused,
|
|
137
|
+
}),
|
|
138
|
+
...(reference.validated ? [] : [msg('cli.design.unvalidated')]),
|
|
139
|
+
]),
|
|
140
|
+
...outcome.skipped.map((entry) =>
|
|
141
|
+
msg('cli.design.skipped', { url: entry.url, code: entry.code }),
|
|
142
|
+
),
|
|
143
|
+
],
|
|
144
|
+
data: researchJson(outcome),
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export const designCommand: CliCommand = {
|
|
149
|
+
spec: designSpec,
|
|
150
|
+
async run(ctx: CommandContext): Promise<CommandResult> {
|
|
151
|
+
const urls = ctx.args.positionals;
|
|
152
|
+
if (flagBool(ctx.args, 'list')) {
|
|
153
|
+
if (urls.length > 0) {
|
|
154
|
+
throw new BadFlagError({
|
|
155
|
+
flag: 'list',
|
|
156
|
+
command: 'design research',
|
|
157
|
+
reason: 'lists the reference catalogues; it researches no URL',
|
|
158
|
+
fix: 'x design research --list --json',
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
return designListResult();
|
|
162
|
+
}
|
|
163
|
+
if (urls.length === 0) {
|
|
164
|
+
throw new MissingPositionalError({
|
|
165
|
+
command: 'design research',
|
|
166
|
+
positional: 'url',
|
|
167
|
+
example: EXAMPLE,
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
// Every value read before a browser starts: a typo must not cost a launch to report.
|
|
171
|
+
const follow = intFlag(ctx.args, 'follow', 0, 0, FOLLOW_MAX);
|
|
172
|
+
const timeoutMs = intFlag(ctx.args, 'timeout', 1, DEFAULT_PAGE_TIMEOUT_MS);
|
|
173
|
+
const viewports = parseViewports(flagString(ctx.args, 'viewport'));
|
|
174
|
+
const allowHosts = readDesignAllowHosts(flagString(ctx.args, 'allow-hosts'));
|
|
175
|
+
const flag = flagString(ctx.args, 'out');
|
|
176
|
+
const outDir = flag === undefined ? join(ctx.cwd, DESIGN_DIR) : resolve(ctx.cwd, flag);
|
|
177
|
+
const outcome = await runDesignResearch({
|
|
178
|
+
urls,
|
|
179
|
+
outDir,
|
|
180
|
+
env: ctx.env,
|
|
181
|
+
follow,
|
|
182
|
+
viewports,
|
|
183
|
+
allowHosts,
|
|
184
|
+
timeoutMs,
|
|
185
|
+
});
|
|
186
|
+
return designResult(outcome, outDir);
|
|
187
|
+
},
|
|
188
|
+
};
|
package/src/cmd-doctor.ts
CHANGED
|
@@ -17,6 +17,7 @@ import { coverageExcludesProbe, withCoverageExcludes } from './doctor-coverage';
|
|
|
17
17
|
import { embeddedDatabaseFinding } from './doctor-database';
|
|
18
18
|
import { guardedCheck, guardedListing } from './doctor-guarded';
|
|
19
19
|
import { shippedGuardsProbe, vendoredGuardWarnings, withGuardListing } from './doctor-guards';
|
|
20
|
+
import { kitWarnings } from './doctor-kit';
|
|
20
21
|
import { offlineFallbackFinding } from './doctor-offline';
|
|
21
22
|
import { NO_POOLER_FACT, poolerFindings, withPoolerReport } from './doctor-pooler';
|
|
22
23
|
import { doctorPort, ownerAskedOnce, portFindings } from './doctor-port';
|
|
@@ -250,6 +251,7 @@ export async function reportDoctor(probe: DoctorReportProbe): Promise<CommandRes
|
|
|
250
251
|
const warnings = await guardedListing('warnings', failed, () => doctorWarnings(asked), []);
|
|
251
252
|
const superseded = await inApp('superseded workarounds', supersededFindings, []);
|
|
252
253
|
const floors = await inApp('advisory floors', advisoryFloorFindings, []);
|
|
254
|
+
const kit = await inApp('agent kit', kitWarnings, []);
|
|
253
255
|
// An `x upgrade` driven by a CLI older than the codemod engine left files it owed.
|
|
254
256
|
const codemods = await inApp(
|
|
255
257
|
'pending codemods',
|
|
@@ -264,6 +266,7 @@ export async function reportDoctor(probe: DoctorReportProbe): Promise<CommandRes
|
|
|
264
266
|
...browserWarnings(browser),
|
|
265
267
|
...superseded,
|
|
266
268
|
...floors,
|
|
269
|
+
...kit,
|
|
267
270
|
...codemods,
|
|
268
271
|
...failed,
|
|
269
272
|
]);
|
package/src/cmd-generate-spec.ts
CHANGED
|
@@ -26,6 +26,11 @@ export const generateSpec: CommandSpec = {
|
|
|
26
26
|
{ name: 'admin', type: 'boolean', summary: 'resource: also emit the admin override' },
|
|
27
27
|
{ name: 'locales', type: 'string', summary: 'comma-separated locales, default en' },
|
|
28
28
|
{ name: 'at', type: 'string', summary: 'island, admin:page: directory to write into' },
|
|
29
|
+
{
|
|
30
|
+
name: 'effect',
|
|
31
|
+
type: 'string',
|
|
32
|
+
summary: 'island: wrap the panel in an @ultimat3/effects entry',
|
|
33
|
+
},
|
|
29
34
|
{
|
|
30
35
|
name: 'app',
|
|
31
36
|
type: 'string',
|
package/src/cmd-generate.ts
CHANGED
|
@@ -19,7 +19,7 @@ import { appDisk, plannedDisk } from './generate-disk';
|
|
|
19
19
|
import { writtenExercises } from './generate-exercise';
|
|
20
20
|
import { assertFeatureExists } from './generate-feature';
|
|
21
21
|
import { assertSliceToRead } from './generate-feature-required';
|
|
22
|
-
import { DEFAULT_APP, generate, sliceDir } from './generate-files';
|
|
22
|
+
import { DEFAULT_APP, generate, readEffect, sliceDir } from './generate-files';
|
|
23
23
|
import { followUpEdits } from './generate-follow-ups';
|
|
24
24
|
import { formatWritten } from './generate-format-written';
|
|
25
25
|
import { runInvite } from './generate-invite';
|
|
@@ -99,6 +99,7 @@ export const generateCommand: CliCommand = {
|
|
|
99
99
|
const surface = readSurface(flagString(ctx.args, 'surface'), kind, name);
|
|
100
100
|
const locales = resolveLocales(await namedOrAppLocales(root, flagList(ctx.args, 'locales')));
|
|
101
101
|
const at = flagString(ctx.args, 'at');
|
|
102
|
+
const effect = readEffect(flagString(ctx.args, 'effect'), kind);
|
|
102
103
|
// The app workspace the slice lands in; `web` unless an app-local generator names another.
|
|
103
104
|
const app = readApp(flagString(ctx.args, 'app'), root, kind, name);
|
|
104
105
|
// Read with the two above, and refused here for their reason: the value is spliced into the
|
|
@@ -150,6 +151,7 @@ export const generateCommand: CliCommand = {
|
|
|
150
151
|
...(sliceEntity === undefined ? {} : { sliceEntity }),
|
|
151
152
|
...(sliceRepo === undefined ? {} : { sliceRepo }),
|
|
152
153
|
...(at === undefined ? {} : { at }),
|
|
154
|
+
...(effect === undefined ? {} : { effect }),
|
|
153
155
|
...(app === DEFAULT_APP ? {} : { app }),
|
|
154
156
|
...(permission === undefined ? {} : { permission }),
|
|
155
157
|
surface,
|
package/src/cmd-i18n-spec.ts
CHANGED
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
|
|
4
4
|
import type { CommandSpec } from './parse';
|
|
5
5
|
|
|
6
|
-
export const I18N_SUBCOMMANDS = ['check', 'add', 'sync'] as const;
|
|
6
|
+
export const I18N_SUBCOMMANDS = ['check', 'add', 'sync', 'split'] as const;
|
|
7
7
|
|
|
8
8
|
export const i18nSpec: CommandSpec = {
|
|
9
9
|
name: 'i18n',
|
|
10
|
-
summary: 'catalogs: add a locale, sync keys, check for gaps',
|
|
11
|
-
usage: 'x i18n [check|add <locale>|sync <locale>] [--json]',
|
|
10
|
+
summary: 'catalogs: add a locale, sync keys, check for gaps, split into namespace files',
|
|
11
|
+
usage: 'x i18n [check|add <locale>|sync <locale>|split [<locale>]] [--json]',
|
|
12
12
|
requiresApp: true,
|
|
13
13
|
subcommands: I18N_SUBCOMMANDS,
|
|
14
|
-
// The bare `x i18n` audits; `add` and `
|
|
14
|
+
// The bare `x i18n` audits; `add`, `sync` and `split` write catalogs and must be asked for.
|
|
15
15
|
defaultSubcommand: 'check',
|
|
16
16
|
};
|