@agimon-ai/po-style-system-tooling 0.2.14-alpha.1 → 0.2.14-alpha.11
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/LICENSE +149 -21
- package/README.md +1 -2
- package/dist/cli.cjs +9 -41
- package/dist/cli.mjs +10 -42
- package/dist/index.cjs +74 -7
- package/dist/index.d.cts +49 -34
- package/dist/index.d.mts +49 -34
- package/dist/index.mjs +72 -2
- package/dist/{stdio-B7ni5Bjf.mjs → stdio-B_NECMIh.mjs} +160 -538
- package/dist/{stdio-BqvjQLSc.cjs → stdio-DkQ5zJDm.cjs} +165 -543
- package/package.json +13 -5
- package/skills/style-system/SKILL.md +43 -21
package/LICENSE
CHANGED
|
@@ -1,21 +1,149 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
License text copyright © 2017 MariaDB Corporation Ab, All Rights Reserved.
|
|
2
|
+
"Business Source License" is a trademark of MariaDB Corporation Ab.
|
|
3
|
+
|
|
4
|
+
Parameters
|
|
5
|
+
|
|
6
|
+
Licensor: Agimon Pty Ltd
|
|
7
|
+
Licensed Work: Po, the software in the Po source repository and the
|
|
8
|
+
packages released from it, in each version released by
|
|
9
|
+
the Licensor.
|
|
10
|
+
The Licensed Work is (c) 2026 Agimon Pty Ltd.
|
|
11
|
+
Material identified as third-party in the "Third-party
|
|
12
|
+
components" section at the end of this file or in a
|
|
13
|
+
NOTICE file, and any package or directory whose own
|
|
14
|
+
license file grants a different license, is not part of
|
|
15
|
+
the Licensed Work and remains under its own license.
|
|
16
|
+
Additional Use Grant: You may make production use of the Licensed Work if
|
|
17
|
+
your use is Eligible Use. "Eligible Use" is production use that falls
|
|
18
|
+
within at least one of the following:
|
|
19
|
+
|
|
20
|
+
(a) Personal Use. Use by an individual for their own personal purposes,
|
|
21
|
+
and not on behalf of, or for the benefit of, an employer, client, or
|
|
22
|
+
other Organization. Use by an individual in the course of employment
|
|
23
|
+
or engagement by an Organization is use by that Organization.
|
|
24
|
+
|
|
25
|
+
(b) Small Organization Use. Use by or on behalf of an Organization whose
|
|
26
|
+
Annual Revenue is less than USD 1,000,000.
|
|
27
|
+
|
|
28
|
+
(c) Non-profit, Education and Research Use. Use, regardless of Annual
|
|
29
|
+
Revenue, by (i) an Organization registered or recognized as a
|
|
30
|
+
non-profit or charitable organization under the laws of its
|
|
31
|
+
jurisdiction, for its non-profit purposes; (ii) an accredited school,
|
|
32
|
+
college, or university, for teaching, learning, or academic research;
|
|
33
|
+
or (iii) a publicly funded research institution, for its research.
|
|
34
|
+
|
|
35
|
+
(d) Service Provider Use. Use by a consultant, contractor, agency, or other
|
|
36
|
+
service provider, regardless of its own Annual Revenue, solely to
|
|
37
|
+
build, deploy, host, operate, or support the Licensed Work for a client
|
|
38
|
+
whose own use would be Eligible Use under (a), (b), or (c). A service
|
|
39
|
+
provider's use for its own purposes is Eligible Use only if the service
|
|
40
|
+
provider itself qualifies under (b) or (c).
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
Hosted services. Offering the Licensed Work to third parties as a hosted
|
|
44
|
+
or managed service whose primary value is the Licensed Work is Eligible
|
|
45
|
+
Use only if each such third party's own use would be Eligible Use.
|
|
46
|
+
|
|
47
|
+
Definitions. "Organization" means any company, partnership, sole
|
|
48
|
+
proprietorship, trust, association, government body, or other entity, and
|
|
49
|
+
includes an individual acting in a business or professional capacity.
|
|
50
|
+
"Affiliate" means any entity that directly or indirectly controls, is
|
|
51
|
+
controlled by, or is under common control with an Organization, where
|
|
52
|
+
"control" means ownership of more than 50% of the voting interests of an
|
|
53
|
+
entity or the power to direct its management and policies by contract or
|
|
54
|
+
otherwise. "Annual Revenue" means the total gross revenue of an
|
|
55
|
+
Organization and all of its Affiliates combined, from all sources and
|
|
56
|
+
whether or not related to the Licensed Work, for its most recently
|
|
57
|
+
completed fiscal year, or, if it has not completed a fiscal year, for the
|
|
58
|
+
twelve months before the use (or since its formation, if shorter),
|
|
59
|
+
converted into US dollars at the average exchange rate for that period.
|
|
60
|
+
Proceeds of equity or debt financing are not revenue.
|
|
61
|
+
|
|
62
|
+
Threshold. If an Organization stops qualifying under (b), its existing
|
|
63
|
+
production use remains Eligible Use for 90 days after it stops
|
|
64
|
+
qualifying, after which it must obtain a commercial license or stop
|
|
65
|
+
production use. Use that was Eligible Use when it occurred never requires
|
|
66
|
+
a commercial license after the fact.
|
|
67
|
+
Change Date: Four years from the date a version of the Licensed Work
|
|
68
|
+
is first publicly released by the Licensor.
|
|
69
|
+
Change License: Apache License, Version 2.0
|
|
70
|
+
|
|
71
|
+
For information about alternative licensing arrangements for the Licensed
|
|
72
|
+
Work, please visit: https://agimon.ai/licensing
|
|
73
|
+
|
|
74
|
+
Notice
|
|
75
|
+
|
|
76
|
+
The Business Source License (this document, or the "License") is not an Open
|
|
77
|
+
Source license. However, the Licensed Work will eventually be made available
|
|
78
|
+
under an Open Source License, as stated in this License.
|
|
79
|
+
|
|
80
|
+
-----------------------------------------------------------------------------
|
|
81
|
+
|
|
82
|
+
Business Source License 1.1
|
|
83
|
+
|
|
84
|
+
Terms
|
|
85
|
+
|
|
86
|
+
The Licensor hereby grants you the right to copy, modify, create derivative
|
|
87
|
+
works, redistribute, and make non-production use of the Licensed Work. The
|
|
88
|
+
Licensor may make an Additional Use Grant, above, permitting limited
|
|
89
|
+
production use.
|
|
90
|
+
|
|
91
|
+
Effective on the Change Date, or the fourth anniversary of the first publicly
|
|
92
|
+
available distribution of a specific version of the Licensed Work under this
|
|
93
|
+
License, whichever comes first, the Licensor hereby grants you rights under
|
|
94
|
+
the terms of the Change License, and the rights granted in the paragraph
|
|
95
|
+
above terminate.
|
|
96
|
+
|
|
97
|
+
If your use of the Licensed Work does not comply with the requirements
|
|
98
|
+
currently in effect as described in this License, you must purchase a
|
|
99
|
+
commercial license from the Licensor, its affiliated entities, or authorized
|
|
100
|
+
resellers, or you must refrain from using the Licensed Work.
|
|
101
|
+
|
|
102
|
+
All copies of the original and modified Licensed Work, and derivative works
|
|
103
|
+
of the Licensed Work, are subject to this License. This License applies
|
|
104
|
+
separately for each version of the Licensed Work and the Change Date may vary
|
|
105
|
+
for each version of the Licensed Work released by Licensor.
|
|
106
|
+
|
|
107
|
+
You must conspicuously display this License on each original or modified copy
|
|
108
|
+
of the Licensed Work. If you receive the Licensed Work in original or
|
|
109
|
+
modified form from a third party, the terms and conditions set forth in this
|
|
110
|
+
License apply to your use of that work.
|
|
111
|
+
|
|
112
|
+
Any use of the Licensed Work in violation of this License will automatically
|
|
113
|
+
terminate your rights under this License for the current and all other
|
|
114
|
+
versions of the Licensed Work.
|
|
115
|
+
|
|
116
|
+
This License does not grant you any right in any trademark or logo of
|
|
117
|
+
Licensor or its affiliates (provided that you may use a trademark or logo of
|
|
118
|
+
Licensor as expressly required by this License).
|
|
119
|
+
|
|
120
|
+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
|
|
121
|
+
AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
|
|
122
|
+
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
|
|
123
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
|
|
124
|
+
TITLE.
|
|
125
|
+
|
|
126
|
+
MariaDB hereby grants you permission to use this License’s text to license
|
|
127
|
+
your works, and to refer to it using the trademark “Business Source License”,
|
|
128
|
+
as long as you comply with the Covenants of Licensor below.
|
|
129
|
+
|
|
130
|
+
Covenants of Licensor
|
|
131
|
+
|
|
132
|
+
In consideration of the right to use this License’s text and the “Business
|
|
133
|
+
Source License” name and trademark, Licensor covenants to MariaDB, and to all
|
|
134
|
+
other recipients of the licensed work to be provided by Licensor:
|
|
135
|
+
|
|
136
|
+
1. To specify as the Change License the GPL Version 2.0 or any later version,
|
|
137
|
+
or a license that is compatible with GPL Version 2.0 or a later version,
|
|
138
|
+
where “compatible” means that software provided under the Change License can
|
|
139
|
+
be included in a program with software provided under GPL Version 2.0 or a
|
|
140
|
+
later version. Licensor may specify additional Change Licenses without
|
|
141
|
+
limitation.
|
|
142
|
+
|
|
143
|
+
2. To either: (a) specify an additional grant of rights to use that does not
|
|
144
|
+
impose any additional restriction on the right granted in this License, as
|
|
145
|
+
the Additional Use Grant; or (b) insert the text “None”.
|
|
146
|
+
|
|
147
|
+
3. To specify a Change Date.
|
|
148
|
+
|
|
149
|
+
4. Not to modify this License in any other way.
|
package/README.md
CHANGED
|
@@ -21,7 +21,6 @@ style-system --help
|
|
|
21
21
|
| `get-css-classes` | Extract the valid CSS classes from a theme CSS file |
|
|
22
22
|
| `get-ui-component` | Render a component to a screenshot using the app's design-system config |
|
|
23
23
|
| `list-app-components` | List app-specific components and package components |
|
|
24
|
-
| `polish-component` | Design-system-aware component polish |
|
|
25
24
|
| `generate-oxlint-config` | Generate an oxlint `no-restricted-classes` config from theme tokens |
|
|
26
25
|
| `mcp-serve` | Run as an MCP server over stdio |
|
|
27
26
|
|
|
@@ -146,4 +145,4 @@ these commands.
|
|
|
146
145
|
|
|
147
146
|
## License
|
|
148
147
|
|
|
149
|
-
|
|
148
|
+
Business Source License 1.1: free for personal use, organisations under USD 1M revenue, non-profits and education. See [LICENSE](LICENSE) and https://agimon.ai/licensing.
|
package/dist/cli.cjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const require_stdio = require("./stdio-
|
|
2
|
+
const require_stdio = require("./stdio-DkQ5zJDm.cjs");
|
|
3
3
|
let node_fs = require("node:fs");
|
|
4
4
|
let node_path = require("node:path");
|
|
5
5
|
node_path = require_stdio.__toESM(node_path, 1);
|
|
6
6
|
let zod = require("zod");
|
|
7
|
-
let _agimon_ai_foundation_exec = require("@agimon-ai/foundation-exec");
|
|
8
7
|
let _modelcontextprotocol_server = require("@modelcontextprotocol/server");
|
|
9
8
|
require("reflect-metadata");
|
|
10
9
|
let commander = require("commander");
|
|
11
10
|
let chalk = require("chalk");
|
|
12
11
|
chalk = require_stdio.__toESM(chalk, 1);
|
|
12
|
+
let _agimon_ai_foundation_exec = require("@agimon-ai/foundation-exec");
|
|
13
13
|
let node_http = require("node:http");
|
|
14
14
|
let _modelcontextprotocol_node = require("@modelcontextprotocol/node");
|
|
15
15
|
//#region src/utils/print.ts
|
|
@@ -138,7 +138,8 @@ const REQUESTABLE_COLOR_SCHEMES = [LIGHT_COLOR_SCHEME, DARK_COLOR_SCHEME];
|
|
|
138
138
|
const getUiComponentCommand = new commander.Command("get-ui-component").description("Get a screenshot of a UI component rendered with app-specific design system configuration. Returns screenshot path and story file content.").requiredOption("-c, --component-name <name>", "The name of the component to capture (e.g., \"Button\", \"Card\")").requiredOption("-a, --app-path <path>", "The app path (relative or absolute) to load design system config from (e.g., \"apps/agiflow-app\")").option("-s, --story-name <name>", "The story name to render (e.g., \"Playground\", \"Default\")", "Playground").option("-d, --dark-mode", "Request dark mode for automatic-theme apps").option("--color-scheme <scheme>", "Request light or dark mode for automatic-theme apps").option("--width <pixels>", "Override the configured viewport width", Number).option("--height <pixels>", "Override the configured viewport height", Number).action(async (options) => {
|
|
139
139
|
try {
|
|
140
140
|
if (options.colorScheme !== void 0 && !REQUESTABLE_COLOR_SCHEMES.includes(options.colorScheme)) throw new Error("--color-scheme must be light or dark");
|
|
141
|
-
const
|
|
141
|
+
const sessionTemp = process.env.PO_SESSION_TEMP_DIR;
|
|
142
|
+
const tool = require_stdio.createContainer({ temporaryDirectory: sessionTemp ? (0, node_path.join)(sessionTemp, "previews") : void 0 }).get(require_stdio.STYLE_SYSTEM_TYPES.GetComponentVisualTool);
|
|
142
143
|
const darkMode = options.colorScheme === DARK_COLOR_SCHEME ? true : options.colorScheme === LIGHT_COLOR_SCHEME ? false : options.darkMode || void 0;
|
|
143
144
|
const result = await tool.execute({
|
|
144
145
|
componentName: options.componentName,
|
|
@@ -405,7 +406,11 @@ const mcpServeCommand = new commander.Command("mcp-serve").description("Start MC
|
|
|
405
406
|
console.error(`Dev server started at ${url} (port: ${port})`);
|
|
406
407
|
}
|
|
407
408
|
if (transportType === "stdio") {
|
|
408
|
-
const
|
|
409
|
+
const sessionTemp = process.env.PO_SESSION_TEMP_DIR;
|
|
410
|
+
const container = require_stdio.createContainer({
|
|
411
|
+
defaultThemePath: parsed.themePath,
|
|
412
|
+
temporaryDirectory: sessionTemp ? (0, node_path.join)(sessionTemp, "previews") : void 0
|
|
413
|
+
});
|
|
409
414
|
await startServer(new require_stdio.StdioTransportHandler(() => require_stdio.createServer(container)), bundlerService, devServerPort);
|
|
410
415
|
} else if (transportType === "http" && parsed.port !== void 0) {
|
|
411
416
|
const container = require_stdio.createContainer({ defaultThemePath: parsed.themePath });
|
|
@@ -420,42 +425,6 @@ const mcpServeCommand = new commander.Command("mcp-serve").description("Start MC
|
|
|
420
425
|
}
|
|
421
426
|
});
|
|
422
427
|
//#endregion
|
|
423
|
-
//#region src/commands/polish-component.ts
|
|
424
|
-
/**
|
|
425
|
-
* Polish Component Command
|
|
426
|
-
*
|
|
427
|
-
* DESIGN PATTERNS:
|
|
428
|
-
* - Command pattern with Commander for CLI argument parsing
|
|
429
|
-
* - Async/await pattern for asynchronous operations
|
|
430
|
-
* - Error handling pattern with try-catch and proper exit codes
|
|
431
|
-
*
|
|
432
|
-
* CODING STANDARDS:
|
|
433
|
-
* - Use async action handlers for asynchronous operations
|
|
434
|
-
* - Handle errors gracefully with process.exit()
|
|
435
|
-
*
|
|
436
|
-
* AVOID:
|
|
437
|
-
* - Synchronous blocking operations in action handlers
|
|
438
|
-
* - Missing error handling (always use try-catch)
|
|
439
|
-
* - Hardcoded values (use options or environment variables)
|
|
440
|
-
*/
|
|
441
|
-
const polishComponentCommand = new commander.Command("polish-component").description("Polish a UI component using Antigravity with design system context").argument("<file>", "Path to the component .tsx file to polish").option("-i, --instructions <text>", "Specific polishing instructions (e.g., \"improve spacing\")").action(async (file, options) => {
|
|
442
|
-
try {
|
|
443
|
-
const result = await require_stdio.createContainer().get(require_stdio.STYLE_SYSTEM_TYPES.PolishComponentTool).execute({
|
|
444
|
-
filePath: file,
|
|
445
|
-
instructions: options.instructions
|
|
446
|
-
});
|
|
447
|
-
if (result.isError) {
|
|
448
|
-
const firstContent = result.content[0];
|
|
449
|
-
const errorText = firstContent?.type === "text" ? firstContent.text : "Unknown error";
|
|
450
|
-
throw new Error(errorText);
|
|
451
|
-
}
|
|
452
|
-
for (const content of result.content) if (content.type === "text") console.error(content.text);
|
|
453
|
-
} catch (error) {
|
|
454
|
-
console.error("Error:", error instanceof Error ? error.message : String(error));
|
|
455
|
-
process.exit(1);
|
|
456
|
-
}
|
|
457
|
-
});
|
|
458
|
-
//#endregion
|
|
459
428
|
//#region src/cli.ts
|
|
460
429
|
/**
|
|
461
430
|
* MCP Server CLI Entry Point
|
|
@@ -488,7 +457,6 @@ async function main() {
|
|
|
488
457
|
program.addCommand(listThemesCommand);
|
|
489
458
|
program.addCommand(listSharedComponentsCommand);
|
|
490
459
|
program.addCommand(mcpServeCommand);
|
|
491
|
-
program.addCommand(polishComponentCommand);
|
|
492
460
|
await program.parseAsync(process.argv);
|
|
493
461
|
}
|
|
494
462
|
main();
|
package/dist/cli.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { A as STYLE_SYSTEM_TYPES, C as getAppDesignSystemConfig, N as DEFAULT_STYLE_SYSTEM_CONFIG, P as TailwindCSSClassesService, R as log, a as STYLE_SYSTEM_CLI_NAME,
|
|
2
|
+
import { A as STYLE_SYSTEM_TYPES, C as getAppDesignSystemConfig, N as DEFAULT_STYLE_SYSTEM_CONFIG, P as TailwindCSSClassesService, R as log, a as STYLE_SYSTEM_CLI_NAME, i as createServer$1, k as resolveStyleSystemThemePath, o as STYLE_SYSTEM_VERSION, r as generateRestrictedClassesConfig, s as createContainer, t as StdioTransportHandler, y as getBundlerServiceFromConfig } from "./stdio-B_NECMIh.mjs";
|
|
3
3
|
import { promises } from "node:fs";
|
|
4
|
-
import path from "node:path";
|
|
4
|
+
import path, { join } from "node:path";
|
|
5
5
|
import { z } from "zod";
|
|
6
|
-
import { registerManagedProcess } from "@agimon-ai/foundation-exec";
|
|
7
6
|
import { createMcpHandler } from "@modelcontextprotocol/server";
|
|
8
7
|
import "reflect-metadata";
|
|
9
8
|
import { Command } from "commander";
|
|
10
9
|
import * as chalkImport from "chalk";
|
|
10
|
+
import { registerManagedProcess } from "@agimon-ai/foundation-exec";
|
|
11
11
|
import { createServer } from "node:http";
|
|
12
12
|
import { localhostHostValidation, localhostOriginValidation, toNodeHandler } from "@modelcontextprotocol/node";
|
|
13
13
|
//#region src/utils/print.ts
|
|
@@ -136,7 +136,8 @@ const REQUESTABLE_COLOR_SCHEMES = [LIGHT_COLOR_SCHEME, DARK_COLOR_SCHEME];
|
|
|
136
136
|
const getUiComponentCommand = new Command("get-ui-component").description("Get a screenshot of a UI component rendered with app-specific design system configuration. Returns screenshot path and story file content.").requiredOption("-c, --component-name <name>", "The name of the component to capture (e.g., \"Button\", \"Card\")").requiredOption("-a, --app-path <path>", "The app path (relative or absolute) to load design system config from (e.g., \"apps/agiflow-app\")").option("-s, --story-name <name>", "The story name to render (e.g., \"Playground\", \"Default\")", "Playground").option("-d, --dark-mode", "Request dark mode for automatic-theme apps").option("--color-scheme <scheme>", "Request light or dark mode for automatic-theme apps").option("--width <pixels>", "Override the configured viewport width", Number).option("--height <pixels>", "Override the configured viewport height", Number).action(async (options) => {
|
|
137
137
|
try {
|
|
138
138
|
if (options.colorScheme !== void 0 && !REQUESTABLE_COLOR_SCHEMES.includes(options.colorScheme)) throw new Error("--color-scheme must be light or dark");
|
|
139
|
-
const
|
|
139
|
+
const sessionTemp = process.env.PO_SESSION_TEMP_DIR;
|
|
140
|
+
const tool = createContainer({ temporaryDirectory: sessionTemp ? join(sessionTemp, "previews") : void 0 }).get(STYLE_SYSTEM_TYPES.GetComponentVisualTool);
|
|
140
141
|
const darkMode = options.colorScheme === DARK_COLOR_SCHEME ? true : options.colorScheme === LIGHT_COLOR_SCHEME ? false : options.darkMode || void 0;
|
|
141
142
|
const result = await tool.execute({
|
|
142
143
|
componentName: options.componentName,
|
|
@@ -403,7 +404,11 @@ const mcpServeCommand = new Command("mcp-serve").description("Start MCP server w
|
|
|
403
404
|
console.error(`Dev server started at ${url} (port: ${port})`);
|
|
404
405
|
}
|
|
405
406
|
if (transportType === "stdio") {
|
|
406
|
-
const
|
|
407
|
+
const sessionTemp = process.env.PO_SESSION_TEMP_DIR;
|
|
408
|
+
const container = createContainer({
|
|
409
|
+
defaultThemePath: parsed.themePath,
|
|
410
|
+
temporaryDirectory: sessionTemp ? join(sessionTemp, "previews") : void 0
|
|
411
|
+
});
|
|
407
412
|
await startServer(new StdioTransportHandler(() => createServer$1(container)), bundlerService, devServerPort);
|
|
408
413
|
} else if (transportType === "http" && parsed.port !== void 0) {
|
|
409
414
|
const container = createContainer({ defaultThemePath: parsed.themePath });
|
|
@@ -418,42 +423,6 @@ const mcpServeCommand = new Command("mcp-serve").description("Start MCP server w
|
|
|
418
423
|
}
|
|
419
424
|
});
|
|
420
425
|
//#endregion
|
|
421
|
-
//#region src/commands/polish-component.ts
|
|
422
|
-
/**
|
|
423
|
-
* Polish Component Command
|
|
424
|
-
*
|
|
425
|
-
* DESIGN PATTERNS:
|
|
426
|
-
* - Command pattern with Commander for CLI argument parsing
|
|
427
|
-
* - Async/await pattern for asynchronous operations
|
|
428
|
-
* - Error handling pattern with try-catch and proper exit codes
|
|
429
|
-
*
|
|
430
|
-
* CODING STANDARDS:
|
|
431
|
-
* - Use async action handlers for asynchronous operations
|
|
432
|
-
* - Handle errors gracefully with process.exit()
|
|
433
|
-
*
|
|
434
|
-
* AVOID:
|
|
435
|
-
* - Synchronous blocking operations in action handlers
|
|
436
|
-
* - Missing error handling (always use try-catch)
|
|
437
|
-
* - Hardcoded values (use options or environment variables)
|
|
438
|
-
*/
|
|
439
|
-
const polishComponentCommand = new Command("polish-component").description("Polish a UI component using Antigravity with design system context").argument("<file>", "Path to the component .tsx file to polish").option("-i, --instructions <text>", "Specific polishing instructions (e.g., \"improve spacing\")").action(async (file, options) => {
|
|
440
|
-
try {
|
|
441
|
-
const result = await createContainer().get(STYLE_SYSTEM_TYPES.PolishComponentTool).execute({
|
|
442
|
-
filePath: file,
|
|
443
|
-
instructions: options.instructions
|
|
444
|
-
});
|
|
445
|
-
if (result.isError) {
|
|
446
|
-
const firstContent = result.content[0];
|
|
447
|
-
const errorText = firstContent?.type === "text" ? firstContent.text : "Unknown error";
|
|
448
|
-
throw new Error(errorText);
|
|
449
|
-
}
|
|
450
|
-
for (const content of result.content) if (content.type === "text") console.error(content.text);
|
|
451
|
-
} catch (error) {
|
|
452
|
-
console.error("Error:", error instanceof Error ? error.message : String(error));
|
|
453
|
-
process.exit(1);
|
|
454
|
-
}
|
|
455
|
-
});
|
|
456
|
-
//#endregion
|
|
457
426
|
//#region src/cli.ts
|
|
458
427
|
/**
|
|
459
428
|
* Main entry point
|
|
@@ -468,7 +437,6 @@ async function main() {
|
|
|
468
437
|
program.addCommand(listThemesCommand);
|
|
469
438
|
program.addCommand(listSharedComponentsCommand);
|
|
470
439
|
program.addCommand(mcpServeCommand);
|
|
471
|
-
program.addCommand(polishComponentCommand);
|
|
472
440
|
await program.parseAsync(process.argv);
|
|
473
441
|
}
|
|
474
442
|
main();
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_stdio = require("./stdio-
|
|
2
|
+
const require_stdio = require("./stdio-DkQ5zJDm.cjs");
|
|
3
3
|
let node_fs = require("node:fs");
|
|
4
4
|
let node_path = require("node:path");
|
|
5
5
|
node_path = require_stdio.__toESM(node_path, 1);
|
|
@@ -87,6 +87,76 @@ var StoryPreviewService = class {
|
|
|
87
87
|
}
|
|
88
88
|
};
|
|
89
89
|
//#endregion
|
|
90
|
+
//#region src/services/WarmStoryRenderer/WarmStoryRenderer.ts
|
|
91
|
+
/** The style-system tools a warm host exposes, by tool name. */
|
|
92
|
+
const WARM_RENDERER_TOOLS = {
|
|
93
|
+
get_component_visual: require_stdio.STYLE_SYSTEM_TYPES.GetComponentVisualTool,
|
|
94
|
+
get_css_classes: require_stdio.STYLE_SYSTEM_TYPES.GetCSSClassesTool,
|
|
95
|
+
list_themes: require_stdio.STYLE_SYSTEM_TYPES.ListThemesTool,
|
|
96
|
+
list_shared_components: require_stdio.STYLE_SYSTEM_TYPES.ListSharedComponentsTool,
|
|
97
|
+
list_app_components: require_stdio.STYLE_SYSTEM_TYPES.ListAppComponentsTool
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Keeps one browser and one Vite dev server warm across renders, so a render after the first
|
|
101
|
+
* skips the browser launch and the static build. Rendered screenshots come back as base64.
|
|
102
|
+
*/
|
|
103
|
+
function createWarmStoryRenderer(options = {}) {
|
|
104
|
+
let browser;
|
|
105
|
+
const sharedBrowser = () => {
|
|
106
|
+
browser ??= require_stdio.launchBrowserWithFallback().catch((error) => {
|
|
107
|
+
browser = void 0;
|
|
108
|
+
throw error;
|
|
109
|
+
});
|
|
110
|
+
return browser;
|
|
111
|
+
};
|
|
112
|
+
const container = require_stdio.createContainer({
|
|
113
|
+
sharedBrowser,
|
|
114
|
+
temporaryDirectory: options.temporaryDirectory
|
|
115
|
+
});
|
|
116
|
+
const bundler = require_stdio.createDefaultBundlerService();
|
|
117
|
+
let queue = Promise.resolve();
|
|
118
|
+
let disposed = false;
|
|
119
|
+
const ensureDevServer = async (appPath) => {
|
|
120
|
+
const resolved = node_path.default.resolve(appPath);
|
|
121
|
+
if (bundler.isServerRunning() && bundler.getCurrentAppPath() === resolved) return;
|
|
122
|
+
if (bundler.isServerRunning()) await bundler.cleanup();
|
|
123
|
+
await bundler.startDevServer(resolved);
|
|
124
|
+
};
|
|
125
|
+
const run = async (tool, input) => {
|
|
126
|
+
if (disposed) throw new Error("The story renderer is shut down.");
|
|
127
|
+
if (tool === "get_component_visual" && typeof input.appPath === "string") await ensureDevServer(input.appPath);
|
|
128
|
+
const result = await container.get(WARM_RENDERER_TOOLS[tool]).execute(input);
|
|
129
|
+
const text = result.content.flatMap((item) => item.type === "text" && item.text ? [item.text] : []).join("\n\n");
|
|
130
|
+
const images = [];
|
|
131
|
+
if (tool === "get_component_visual" && !result.isError) {
|
|
132
|
+
const imagePath = /"imagePath":\s*"([^"]+)"/u.exec(text)?.[1];
|
|
133
|
+
if (imagePath) images.push({
|
|
134
|
+
data: (await node_fs.promises.readFile(imagePath)).toString("base64"),
|
|
135
|
+
mimeType: "image/png"
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
text,
|
|
140
|
+
images,
|
|
141
|
+
isError: result.isError === true
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
return {
|
|
145
|
+
call(tool, input) {
|
|
146
|
+
const next = queue.then(() => run(tool, input));
|
|
147
|
+
queue = next.catch(() => void 0);
|
|
148
|
+
return next;
|
|
149
|
+
},
|
|
150
|
+
async dispose() {
|
|
151
|
+
disposed = true;
|
|
152
|
+
await queue;
|
|
153
|
+
const open = browser;
|
|
154
|
+
browser = void 0;
|
|
155
|
+
await Promise.allSettled([open?.then((instance) => instance.close()), bundler.cleanup()]);
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
//#endregion
|
|
90
160
|
exports.BaseBundlerService = require_stdio.BaseBundlerService;
|
|
91
161
|
exports.BaseCSSClassesService = require_stdio.BaseCSSClassesService;
|
|
92
162
|
Object.defineProperty(exports, "CSSClassesServiceFactory", {
|
|
@@ -133,12 +203,6 @@ Object.defineProperty(exports, "ListThemesTool", {
|
|
|
133
203
|
return require_stdio.ListThemesTool;
|
|
134
204
|
}
|
|
135
205
|
});
|
|
136
|
-
Object.defineProperty(exports, "PolishComponentTool", {
|
|
137
|
-
enumerable: true,
|
|
138
|
-
get: function() {
|
|
139
|
-
return require_stdio.PolishComponentTool;
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
206
|
exports.STYLE_SYSTEM_TYPES = require_stdio.STYLE_SYSTEM_TYPES;
|
|
143
207
|
exports.StdioTransportHandler = require_stdio.StdioTransportHandler;
|
|
144
208
|
Object.defineProperty(exports, "StoriesIndexService", {
|
|
@@ -157,10 +221,12 @@ Object.defineProperty(exports, "StyleSystemConfigLoader", {
|
|
|
157
221
|
exports.TailwindCSSClassesService = require_stdio.TailwindCSSClassesService;
|
|
158
222
|
exports.ThemeService = require_stdio.ThemeService;
|
|
159
223
|
exports.ViteReactBundlerService = require_stdio.ViteReactBundlerService;
|
|
224
|
+
exports.WARM_RENDERER_TOOLS = WARM_RENDERER_TOOLS;
|
|
160
225
|
exports.createContainer = require_stdio.createContainer;
|
|
161
226
|
exports.createDefaultBundlerService = require_stdio.createDefaultBundlerService;
|
|
162
227
|
exports.createServer = require_stdio.createServer;
|
|
163
228
|
exports.createStyleSystemModule = require_stdio.createStyleSystemModule;
|
|
229
|
+
exports.createWarmStoryRenderer = createWarmStoryRenderer;
|
|
164
230
|
exports.extractCustomTokenNames = require_stdio.extractCustomTokenNames;
|
|
165
231
|
exports.generateRestrictedClassesConfig = require_stdio.generateRestrictedClassesConfig;
|
|
166
232
|
exports.getAppDesignSystemConfig = require_stdio.getAppDesignSystemConfig;
|
|
@@ -168,6 +234,7 @@ exports.getBundlerService = require_stdio.getBundlerService;
|
|
|
168
234
|
exports.getBundlerServiceFromConfig = require_stdio.getBundlerServiceFromConfig;
|
|
169
235
|
exports.getSharedComponentTags = require_stdio.getSharedComponentTags;
|
|
170
236
|
exports.hasStyleSystemProjectConfig = require_stdio.hasStyleSystemProjectConfig;
|
|
237
|
+
exports.launchBrowserWithFallback = require_stdio.launchBrowserWithFallback;
|
|
171
238
|
exports.resetStyleSystemConfigCache = require_stdio.resetStyleSystemConfigCache;
|
|
172
239
|
exports.resolveAppDesignSystemConfig = require_stdio.resolveAppDesignSystemConfig;
|
|
173
240
|
exports.resolveStyleSystemThemePath = require_stdio.resolveStyleSystemThemePath;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { Container, ContainerModule } from "inversify";
|
|
2
|
+
import { Browser } from "playwright";
|
|
2
3
|
import "zod";
|
|
3
4
|
import { CallToolResult, Server } from "@modelcontextprotocol/server";
|
|
4
5
|
import { AliasOptions, Plugin, UserConfig } from "vite";
|
|
5
6
|
//#region src/container/module.d.ts
|
|
6
7
|
interface StyleSystemModuleOptions {
|
|
7
8
|
defaultThemePath?: string;
|
|
9
|
+
temporaryDirectory?: string;
|
|
10
|
+
/** A browser a long-lived host keeps warm across renders; one-shot CLI runs leave it unset. */
|
|
11
|
+
sharedBrowser?: () => Promise<Browser>;
|
|
8
12
|
}
|
|
9
13
|
export declare function createStyleSystemModule(optionsInput?: StyleSystemModuleOptions): ContainerModule;
|
|
10
14
|
//#endregion
|
|
@@ -15,7 +19,6 @@ export declare const STYLE_SYSTEM_TYPES: {
|
|
|
15
19
|
readonly GetComponentVisualTool: symbol;
|
|
16
20
|
readonly ListSharedComponentsTool: symbol;
|
|
17
21
|
readonly ListAppComponentsTool: symbol;
|
|
18
|
-
readonly PolishComponentTool: symbol;
|
|
19
22
|
readonly ThemeServiceFactory: symbol;
|
|
20
23
|
readonly CSSClassesServiceFactory: symbol;
|
|
21
24
|
readonly StoriesIndexService: symbol;
|
|
@@ -863,6 +866,9 @@ export declare class ComponentRendererService {
|
|
|
863
866
|
private themeService;
|
|
864
867
|
private appPath;
|
|
865
868
|
private bundlerFactory;
|
|
869
|
+
private log;
|
|
870
|
+
private readonly preserveOutput;
|
|
871
|
+
private readonly sharedBrowser;
|
|
866
872
|
/**
|
|
867
873
|
* Creates a new ComponentRendererService instance
|
|
868
874
|
* @param designSystemConfig - Design system configuration
|
|
@@ -871,6 +877,8 @@ export declare class ComponentRendererService {
|
|
|
871
877
|
*/
|
|
872
878
|
constructor(designSystemConfig: DesignSystemConfig, appPath: string, options?: {
|
|
873
879
|
bundlerFactory?: BundlerFactory;
|
|
880
|
+
temporaryDirectory?: string;
|
|
881
|
+
sharedBrowser?: () => Promise<Browser>;
|
|
874
882
|
});
|
|
875
883
|
/**
|
|
876
884
|
* Get the bundler service instance.
|
|
@@ -1981,38 +1989,6 @@ export declare class ListSharedComponentsTool implements Tool<ListSharedComponen
|
|
|
1981
1989
|
execute(input: ListSharedComponentsInput): Promise<CallToolResult>;
|
|
1982
1990
|
}
|
|
1983
1991
|
//#endregion
|
|
1984
|
-
//#region src/tools/PolishComponentTool.d.ts
|
|
1985
|
-
interface PolishComponentInput {
|
|
1986
|
-
filePath: string;
|
|
1987
|
-
instructions?: string;
|
|
1988
|
-
}
|
|
1989
|
-
export declare class PolishComponentTool implements Tool<PolishComponentInput> {
|
|
1990
|
-
static readonly TOOL_NAME = "polish_component";
|
|
1991
|
-
private antigravityService;
|
|
1992
|
-
private getUiComponentService;
|
|
1993
|
-
private cssClassesServiceFactory;
|
|
1994
|
-
private storiesIndexFactory;
|
|
1995
|
-
constructor(getUiComponentService: GetUiComponentService, cssClassesServiceFactory: CSSClassesServiceFactory, storiesIndexFactory: StoriesIndexFactory);
|
|
1996
|
-
getDefinition(): ToolDefinition;
|
|
1997
|
-
execute(input: PolishComponentInput): Promise<CallToolResult>;
|
|
1998
|
-
private detectPlatform;
|
|
1999
|
-
private buildSystemPrompt;
|
|
2000
|
-
/**
|
|
2001
|
-
* Read design tokens from config.themePath.
|
|
2002
|
-
* For web: extracts Tailwind CSS classes. For native: reads the TypeScript types file.
|
|
2003
|
-
*/
|
|
2004
|
-
private getDesignTokens;
|
|
2005
|
-
private findStoriesFile;
|
|
2006
|
-
/**
|
|
2007
|
-
* Find the app that owns a file, for style-system context.
|
|
2008
|
-
* Only apps declaring their own style-system.config.yaml are eligible.
|
|
2009
|
-
*/
|
|
2010
|
-
private findAppPath;
|
|
2011
|
-
private getComponentVisual;
|
|
2012
|
-
private getDesignPrinciples;
|
|
2013
|
-
private getSharedComponents;
|
|
2014
|
-
}
|
|
2015
|
-
//#endregion
|
|
2016
1992
|
//#region src/transports/stdio.d.ts
|
|
2017
1993
|
/** Modern MCP stdio only: reject legacy initialization explicitly. */
|
|
2018
1994
|
export declare class StdioTransportHandler {
|
|
@@ -2024,4 +2000,43 @@ export declare class StdioTransportHandler {
|
|
|
2024
2000
|
stop(): Promise<void>;
|
|
2025
2001
|
}
|
|
2026
2002
|
//#endregion
|
|
2027
|
-
|
|
2003
|
+
//#region src/utils/screenshot.d.ts
|
|
2004
|
+
/**
|
|
2005
|
+
* Attempts to launch a browser, trying multiple configurations in order of preference.
|
|
2006
|
+
* @returns Launched browser instance
|
|
2007
|
+
* @throws Error if no browser can be launched
|
|
2008
|
+
*/
|
|
2009
|
+
export declare function launchBrowserWithFallback(): Promise<Browser>;
|
|
2010
|
+
//#endregion
|
|
2011
|
+
//#region src/services/WarmStoryRenderer/WarmStoryRenderer.d.ts
|
|
2012
|
+
/** The style-system tools a warm host exposes, by tool name. */
|
|
2013
|
+
export declare const WARM_RENDERER_TOOLS: {
|
|
2014
|
+
readonly get_component_visual: symbol;
|
|
2015
|
+
readonly get_css_classes: symbol;
|
|
2016
|
+
readonly list_themes: symbol;
|
|
2017
|
+
readonly list_shared_components: symbol;
|
|
2018
|
+
readonly list_app_components: symbol;
|
|
2019
|
+
};
|
|
2020
|
+
type WarmRendererToolName = keyof typeof WARM_RENDERER_TOOLS;
|
|
2021
|
+
interface WarmRendererResult {
|
|
2022
|
+
text: string;
|
|
2023
|
+
images: {
|
|
2024
|
+
data: string;
|
|
2025
|
+
mimeType: string;
|
|
2026
|
+
}[];
|
|
2027
|
+
isError: boolean;
|
|
2028
|
+
}
|
|
2029
|
+
interface WarmStoryRenderer {
|
|
2030
|
+
/** Runs one tool. Calls are serialized: the dev server serves one app at a time. */
|
|
2031
|
+
call(tool: WarmRendererToolName, input: Record<string, unknown>): Promise<WarmRendererResult>;
|
|
2032
|
+
dispose(): Promise<void>;
|
|
2033
|
+
}
|
|
2034
|
+
/**
|
|
2035
|
+
* Keeps one browser and one Vite dev server warm across renders, so a render after the first
|
|
2036
|
+
* skips the browser launch and the static build. Rendered screenshots come back as base64.
|
|
2037
|
+
*/
|
|
2038
|
+
export declare function createWarmStoryRenderer(options?: {
|
|
2039
|
+
temporaryDirectory?: string;
|
|
2040
|
+
}): WarmStoryRenderer;
|
|
2041
|
+
//#endregion
|
|
2042
|
+
export type { CSSClassCategory, CSSClassValue, CSSClassesResult, DesignSystemConfig, OxlintRestrictedClassPattern, OxlintRestrictedClassesConfig, ResolvedDesignSystemConfig, StoryPreviewIdentity, StoryPreviewInput, StoryPreviewResult, StoryPreviewServiceOptions, StyleSystemConfig, StyleSystemModuleOptions, Tool, ToolDefinition, WarmRendererResult, WarmRendererToolName, WarmStoryRenderer };
|