@sudajs/cli 0.20.0 → 0.21.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/dist/index.d.ts +14 -1
- package/dist/index.js +74 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/templates/theme/AGENTS.md +13 -318
- package/templates/theme/CLAUDE.md +3 -1
- package/templates/theme/README.md +13 -0
- package/templates/theme/docs/agent-guides/component-authoring.md +35 -0
- package/templates/theme-skill/SKILL.md +63 -0
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,16 @@ interface ValidatedTheme {
|
|
|
16
16
|
interface ThemeRootOptions {
|
|
17
17
|
themeRoot?: string | undefined;
|
|
18
18
|
}
|
|
19
|
+
interface ThemeSkillAddOptions {
|
|
20
|
+
root?: string | undefined;
|
|
21
|
+
dryRun?: boolean | undefined;
|
|
22
|
+
force?: boolean | undefined;
|
|
23
|
+
}
|
|
24
|
+
type ThemeSkillAddStatus = "installed" | "already-installed" | "would-install" | "would-replace";
|
|
25
|
+
interface ThemeSkillAddResult {
|
|
26
|
+
destination: string;
|
|
27
|
+
status: ThemeSkillAddStatus;
|
|
28
|
+
}
|
|
19
29
|
interface CliAuthContext {
|
|
20
30
|
baseUrl: string;
|
|
21
31
|
token: string;
|
|
@@ -2249,6 +2259,8 @@ declare function validateThemePreviewLocales(root: string, previewLocales: strin
|
|
|
2249
2259
|
declare function toViteModuleUrl(root: string, absolutePath: string): string;
|
|
2250
2260
|
declare function buildTheme(root: string): Promise<ValidatedTheme>;
|
|
2251
2261
|
declare function finalizeTheme(root: string): Promise<ValidatedTheme>;
|
|
2262
|
+
declare function findThemeSkillWorkspaceRoot(startDirectory: string): string;
|
|
2263
|
+
declare function addThemeSkill(options?: ThemeSkillAddOptions): Promise<ThemeSkillAddResult>;
|
|
2252
2264
|
declare function findAnchorTagByHref(html: string, href: string): string | null;
|
|
2253
2265
|
declare const __testUtils: {
|
|
2254
2266
|
activateThemeOutputSchema: z.ZodDiscriminatedUnion<"status", [z.ZodObject<{
|
|
@@ -2709,6 +2721,7 @@ declare const __testUtils: {
|
|
|
2709
2721
|
}>]>;
|
|
2710
2722
|
findAnchorTagByHref: typeof findAnchorTagByHref;
|
|
2711
2723
|
formatMissingSharpWarning: typeof formatMissingSharpWarning;
|
|
2724
|
+
findThemeSkillWorkspaceRoot: typeof findThemeSkillWorkspaceRoot;
|
|
2712
2725
|
loadThemeScopedRenderer: typeof loadThemeScopedRenderer;
|
|
2713
2726
|
normalizePlaywrightModule: typeof normalizePlaywrightModule;
|
|
2714
2727
|
normalizeSharpModule: typeof normalizeSharpModule;
|
|
@@ -4760,4 +4773,4 @@ declare function initThemeWithKey(target: string, key: string): Promise<void>;
|
|
|
4760
4773
|
declare function buildProgram(): Command;
|
|
4761
4774
|
declare function main(): Promise<void>;
|
|
4762
4775
|
|
|
4763
|
-
export { __testUtils, buildProgram, buildTheme, finalizeTheme, initTheme, main, parseThemeRef, validateTheme, watchTheme };
|
|
4776
|
+
export { __testUtils, addThemeSkill, buildProgram, buildTheme, finalizeTheme, initTheme, main, parseThemeRef, validateTheme, watchTheme };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createHash } from 'crypto';
|
|
3
3
|
import { existsSync } from 'fs';
|
|
4
|
-
import fs, { readFile, mkdir, writeFile, stat, readdir, copyFile
|
|
4
|
+
import fs, { readFile, rm, mkdir, writeFile, stat, readdir, copyFile } from 'fs/promises';
|
|
5
5
|
import { createRequire } from 'module';
|
|
6
6
|
import path2 from 'path';
|
|
7
7
|
import { createInterface } from 'readline/promises';
|
|
@@ -735,6 +735,7 @@ var createProjectOutputSchema = z.object({
|
|
|
735
735
|
});
|
|
736
736
|
var packageRoot = path2.resolve(path2.dirname(fileURLToPath(import.meta.url)), "..");
|
|
737
737
|
var themeTemplateRoot = path2.join(packageRoot, "templates", "theme");
|
|
738
|
+
var themeSkillTemplateRoot = path2.join(packageRoot, "templates", "theme-skill");
|
|
738
739
|
function createHostReactShimPlugin() {
|
|
739
740
|
return {
|
|
740
741
|
name: "suda-host-react-shim",
|
|
@@ -1608,6 +1609,58 @@ async function copyDirectory(source, destination) {
|
|
|
1608
1609
|
await copyFile(sourcePath, destinationPath);
|
|
1609
1610
|
}
|
|
1610
1611
|
}
|
|
1612
|
+
function findThemeSkillWorkspaceRoot(startDirectory) {
|
|
1613
|
+
let candidate = path2.resolve(startDirectory);
|
|
1614
|
+
while (true) {
|
|
1615
|
+
if (existsSync(path2.join(candidate, ".git"))) {
|
|
1616
|
+
return candidate;
|
|
1617
|
+
}
|
|
1618
|
+
const parent = path2.dirname(candidate);
|
|
1619
|
+
if (parent === candidate) {
|
|
1620
|
+
return path2.resolve(startDirectory);
|
|
1621
|
+
}
|
|
1622
|
+
candidate = parent;
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
function resolveThemeSkillWorkspaceRoot(root) {
|
|
1626
|
+
return root === void 0 ? findThemeSkillWorkspaceRoot(process.cwd()) : path2.resolve(root);
|
|
1627
|
+
}
|
|
1628
|
+
async function readSkillName(skillDirectory) {
|
|
1629
|
+
const skillPath = path2.join(skillDirectory, "SKILL.md");
|
|
1630
|
+
if (!await pathExists(skillPath)) {
|
|
1631
|
+
return null;
|
|
1632
|
+
}
|
|
1633
|
+
const source = await readFile(skillPath, "utf8");
|
|
1634
|
+
return /^---\s*\nname:\s*([^\n]+)\n/m.exec(source)?.[1]?.trim() ?? null;
|
|
1635
|
+
}
|
|
1636
|
+
async function addThemeSkill(options = {}) {
|
|
1637
|
+
const workspaceRoot = resolveThemeSkillWorkspaceRoot(options.root);
|
|
1638
|
+
const destination = path2.join(workspaceRoot, ".agents", "skills", "sudacloud-theme");
|
|
1639
|
+
const exists = await pathExists(destination);
|
|
1640
|
+
if (exists) {
|
|
1641
|
+
const installedSkillName = await readSkillName(destination);
|
|
1642
|
+
if (installedSkillName !== "sudacloud-theme" && options.force !== true) {
|
|
1643
|
+
throw new Error(
|
|
1644
|
+
`${destination} already exists and is not a Suda theme skill. Use --force to replace it.`
|
|
1645
|
+
);
|
|
1646
|
+
}
|
|
1647
|
+
if (installedSkillName === "sudacloud-theme" && options.force !== true) {
|
|
1648
|
+
return { destination, status: "already-installed" };
|
|
1649
|
+
}
|
|
1650
|
+
if (options.dryRun === true) {
|
|
1651
|
+
return { destination, status: "would-replace" };
|
|
1652
|
+
}
|
|
1653
|
+
await rm(destination, { recursive: true, force: true });
|
|
1654
|
+
} else if (options.dryRun === true) {
|
|
1655
|
+
return { destination, status: "would-install" };
|
|
1656
|
+
}
|
|
1657
|
+
await copyDirectory(themeSkillTemplateRoot, destination);
|
|
1658
|
+
await copyDirectory(
|
|
1659
|
+
path2.join(themeTemplateRoot, "docs", "agent-guides"),
|
|
1660
|
+
path2.join(destination, "references")
|
|
1661
|
+
);
|
|
1662
|
+
return { destination, status: "installed" };
|
|
1663
|
+
}
|
|
1611
1664
|
var THEME_CHECK_WHITE_LABEL = {
|
|
1612
1665
|
visible: true,
|
|
1613
1666
|
text: "Powered by <strong>\u901F\u642D\u4E91</strong>",
|
|
@@ -1736,6 +1789,7 @@ var __testUtils = {
|
|
|
1736
1789
|
destructivePageOperationOutputSchema,
|
|
1737
1790
|
findAnchorTagByHref,
|
|
1738
1791
|
formatMissingSharpWarning,
|
|
1792
|
+
findThemeSkillWorkspaceRoot,
|
|
1739
1793
|
loadThemeScopedRenderer,
|
|
1740
1794
|
normalizePlaywrightModule,
|
|
1741
1795
|
normalizeSharpModule,
|
|
@@ -3783,6 +3837,24 @@ function buildProgram() {
|
|
|
3783
3837
|
const input = await resolveThemeInitInput(name);
|
|
3784
3838
|
await initThemeWithKey(path2.resolve(input.name), input.key);
|
|
3785
3839
|
});
|
|
3840
|
+
const themeSkill = theme.command("skill").description("Install Suda theme development guidance.");
|
|
3841
|
+
themeSkill.command("add").description("Install the Suda theme development skill in a repository.").option("--root <path>", "Repository or monorepo root to install into.").option("--dry-run", "Print the destination without writing files.").option("--force", "Replace an existing skill at the destination.").action(async (options) => {
|
|
3842
|
+
const result = await addThemeSkill(options);
|
|
3843
|
+
const target = style.path(result.destination);
|
|
3844
|
+
if (result.status === "installed") {
|
|
3845
|
+
console.log(success(`installed Suda theme skill in ${target}`));
|
|
3846
|
+
return;
|
|
3847
|
+
}
|
|
3848
|
+
if (result.status === "already-installed") {
|
|
3849
|
+
console.log(info(`Suda theme skill already installed in ${target}`));
|
|
3850
|
+
return;
|
|
3851
|
+
}
|
|
3852
|
+
if (result.status === "would-replace") {
|
|
3853
|
+
console.log(info(`would replace Suda theme skill in ${target}`));
|
|
3854
|
+
return;
|
|
3855
|
+
}
|
|
3856
|
+
console.log(info(`would install Suda theme skill in ${target}`));
|
|
3857
|
+
});
|
|
3786
3858
|
theme.command("validate").description("Validate a built theme artifact.").option("--theme-root <path>", "Theme source/artifact root.").action(async (options) => {
|
|
3787
3859
|
const result = await validateTheme(resolveThemeRoot(options));
|
|
3788
3860
|
console.log(
|
|
@@ -3956,6 +4028,6 @@ async function main() {
|
|
|
3956
4028
|
await program.parseAsync(argv);
|
|
3957
4029
|
}
|
|
3958
4030
|
|
|
3959
|
-
export { __testUtils, buildProgram, buildTheme, finalizeTheme, initTheme, main, parseThemeRef, validateTheme, watchTheme };
|
|
4031
|
+
export { __testUtils, addThemeSkill, buildProgram, buildTheme, finalizeTheme, initTheme, main, parseThemeRef, validateTheme, watchTheme };
|
|
3960
4032
|
//# sourceMappingURL=index.js.map
|
|
3961
4033
|
//# sourceMappingURL=index.js.map
|