@czxingyu/xycomponents 0.1.4 → 0.1.6

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/cli.js CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import { resolve } from "node:path";
2
+ import { dirname, join, resolve } from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
+ import { cpSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
4
5
  //#region cli/component-lifecycle.ts
5
6
  var componentDeprecations = [];
6
7
  var retiredComponents = [{
@@ -7501,7 +7502,7 @@ const rows: XyTableRecord[] = [
7501
7502
  },
7502
7503
  {
7503
7504
  default: "false",
7504
- description: "Grow with content, ignore scroll.y, and disable virtual mode.",
7505
+ description: "Grow with content up to the parent height; scroll inside when overflowing; ignore scroll.y and disable virtual mode.",
7505
7506
  name: "autoHeight",
7506
7507
  type: "boolean"
7507
7508
  },
@@ -9936,6 +9937,139 @@ var packageMetadata = {
9936
9937
  schemaVersion: 1
9937
9938
  };
9938
9939
  //#endregion
9940
+ //#region cli/skills-install.ts
9941
+ var CONSUMER_SKILL_NAMES = [
9942
+ "xycomponents-shared",
9943
+ "xycomponents-cli",
9944
+ "xycomponents-contribute"
9945
+ ];
9946
+ var MAINTAINER_SKILL_NAMES = [...CONSUMER_SKILL_NAMES, "xycomponents-maintainer"];
9947
+ var SKILL_TARGETS = {
9948
+ agents: ".agents/skills",
9949
+ claude: ".claude/skills",
9950
+ codex: ".codex/skills",
9951
+ cursor: ".cursor/skills"
9952
+ };
9953
+ var AGENTS_GUIDE_START = "<!-- xycomponents:start -->";
9954
+ var AGENTS_GUIDE_END = "<!-- xycomponents:end -->";
9955
+ var AGENTS_GUIDE_BLOCK = `${AGENTS_GUIDE_START}
9956
+
9957
+ ## xycomponents Agent Guide
9958
+
9959
+ This project uses \`@czxingyu/xycomponents\`. Query component APIs with the **project-local** CLI (do not use a globally installed CLI):
9960
+
9961
+ \`\`\`bash
9962
+ pnpm exec xycomponents doctor --json
9963
+ pnpm exec xycomponents component <name> --json
9964
+ pnpm exec xycomponents snippet <name> --example <id>
9965
+ \`\`\`
9966
+
9967
+ Workflow skills are installed for multiple agents under \`.cursor/skills/\`, \`.claude/skills/\`, \`.codex/skills/\`, and \`.agents/skills/\`:
9968
+
9969
+ - \`xycomponents-shared\` — install, version alignment, Vue setup
9970
+ - \`xycomponents-cli\` — CLI commands and JSON metadata
9971
+ - \`xycomponents-contribute\` — GitHub Bug / Feature issues
9972
+
9973
+ Re-run \`pnpm exec xycomponents skills install\` after upgrading \`@czxingyu/xycomponents\` so agent guides stay in sync.
9974
+
9975
+ ${AGENTS_GUIDE_END}`;
9976
+ function moduleUrlToPath(moduleUrl) {
9977
+ return moduleUrl.startsWith("file:") ? fileURLToPath(moduleUrl) : moduleUrl;
9978
+ }
9979
+ function resolvePackageRoot(moduleUrl) {
9980
+ return resolve(dirname(moduleUrlToPath(moduleUrl)), "..");
9981
+ }
9982
+ function resolveSkillsSourceDir(moduleUrl) {
9983
+ return join(resolvePackageRoot(moduleUrl), "skills");
9984
+ }
9985
+ function resolveSkillNames(options) {
9986
+ if (options.maintainer) return [...MAINTAINER_SKILL_NAMES];
9987
+ if (options.consumer === false) return [...MAINTAINER_SKILL_NAMES];
9988
+ return [...CONSUMER_SKILL_NAMES];
9989
+ }
9990
+ function resolveSkillTargets(targets) {
9991
+ if (!targets || targets.length === 0) return Object.keys(SKILL_TARGETS);
9992
+ return targets.filter((target) => target in SKILL_TARGETS);
9993
+ }
9994
+ function readPackageVersion(packageRoot) {
9995
+ try {
9996
+ return JSON.parse(readFileSync(join(packageRoot, "package.json"), "utf8")).version ?? "unknown";
9997
+ } catch {
9998
+ return "unknown";
9999
+ }
10000
+ }
10001
+ function copySkillDirectory(source, destination, dryRun) {
10002
+ if (dryRun) return;
10003
+ mkdirSync(dirname(destination), { recursive: true });
10004
+ cpSync(source, destination, {
10005
+ force: true,
10006
+ recursive: true
10007
+ });
10008
+ }
10009
+ function upsertAgentsGuide(projectRoot, dryRun) {
10010
+ const agentsGuidePath = join(projectRoot, "AGENTS.md");
10011
+ const previous = existsSync(agentsGuidePath) ? readFileSync(agentsGuidePath, "utf8") : "";
10012
+ if (previous.includes(AGENTS_GUIDE_START) && previous.includes(AGENTS_GUIDE_END)) {
10013
+ const next = previous.replace(new RegExp(`${AGENTS_GUIDE_START}[\\s\\S]*?${AGENTS_GUIDE_END}`, "m"), AGENTS_GUIDE_BLOCK);
10014
+ if (!dryRun) writeFileSync(agentsGuidePath, next, "utf8");
10015
+ return {
10016
+ agentsGuide: previous === next ? "skipped" : "updated",
10017
+ agentsGuidePath
10018
+ };
10019
+ }
10020
+ const next = `${previous}${previous.length > 0 && !previous.endsWith("\n") ? "\n\n" : previous.length > 0 ? "\n" : ""}${AGENTS_GUIDE_BLOCK}\n`;
10021
+ if (!dryRun) writeFileSync(agentsGuidePath, next, "utf8");
10022
+ return {
10023
+ agentsGuide: previous.length > 0 ? "updated" : "created",
10024
+ agentsGuidePath
10025
+ };
10026
+ }
10027
+ function installSkills(options, moduleUrl = import.meta.url) {
10028
+ const projectRoot = resolve(options.projectRoot ?? process.cwd());
10029
+ const packageRoot = resolve(options.packageRoot ?? resolvePackageRoot(moduleUrl));
10030
+ const skillsSource = resolveSkillsSourceDir(moduleUrl);
10031
+ const skillNames = resolveSkillNames(options);
10032
+ const targets = resolveSkillTargets(options.targets);
10033
+ const installed = [];
10034
+ const skipped = [];
10035
+ if (!existsSync(skillsSource)) return {
10036
+ agentsGuide: "skipped",
10037
+ agentsGuidePath: join(projectRoot, "AGENTS.md"),
10038
+ installed,
10039
+ packageVersion: readPackageVersion(packageRoot),
10040
+ projectRoot,
10041
+ skillsSource,
10042
+ skipped: [`skills source missing: ${skillsSource}`],
10043
+ status: "fail"
10044
+ };
10045
+ for (const target of targets) {
10046
+ const targetRoot = join(projectRoot, SKILL_TARGETS[target]);
10047
+ for (const skillName of skillNames) {
10048
+ const sourceDir = join(skillsSource, skillName);
10049
+ const destinationDir = join(targetRoot, skillName);
10050
+ if (!existsSync(join(sourceDir, "SKILL.md"))) {
10051
+ skipped.push(`${skillName} (missing source for ${target})`);
10052
+ continue;
10053
+ }
10054
+ copySkillDirectory(sourceDir, destinationDir, options.dryRun === true);
10055
+ installed.push({
10056
+ path: join(SKILL_TARGETS[target], skillName, "SKILL.md"),
10057
+ skill: skillName,
10058
+ target
10059
+ });
10060
+ }
10061
+ }
10062
+ return {
10063
+ ...upsertAgentsGuide(projectRoot, options.dryRun === true),
10064
+ installed,
10065
+ packageVersion: readPackageVersion(packageRoot),
10066
+ projectRoot,
10067
+ skillsSource,
10068
+ skipped,
10069
+ status: installed.length > 0 ? "pass" : "fail"
10070
+ };
10071
+ }
10072
+ //#endregion
9939
10073
  //#region cli/index.ts
9940
10074
  function withTrailingNewline(value) {
9941
10075
  return value.endsWith("\n") ? value : `${value}\n`;
@@ -10005,6 +10139,7 @@ Usage:
10005
10139
  xycomponents migrate link --json
10006
10140
  xycomponents package --json
10007
10141
  xycomponents doctor --json
10142
+ xycomponents skills install --consumer --json
10008
10143
 
10009
10144
  Commands:
10010
10145
  components List every documented component
@@ -10012,7 +10147,8 @@ Commands:
10012
10147
  snippet <name> Print a component usage snippet
10013
10148
  migrate <name> Explain stable, deprecated, or retired migration status
10014
10149
  package Explain default and lite package entry contracts
10015
- doctor Print catalog and detailed-metadata coverage
10150
+ doctor Print catalog and detailed-metadata coverage
10151
+ skills install Install AI agent skills for Cursor, Claude Code, Codex, and AGENTS.md
10016
10152
  help Print this help message`);
10017
10153
  }
10018
10154
  function componentSummary(category) {
@@ -10067,6 +10203,39 @@ Lite: ${packageMetadata.entries.lite.import}
10067
10203
  Excludes: ${packageMetadata.entries.lite.excludedComponents.join(", ")}
10068
10204
  Docs: ${packageMetadata.docs}`);
10069
10205
  }
10206
+ function printSkillsInstall(flags, json) {
10207
+ const rawTargets = readFlag(flags, "target", "all").split(",").map((value) => value.trim()).filter(Boolean);
10208
+ const targets = rawTargets.length === 1 && rawTargets[0] === "all" ? resolveSkillTargets() : resolveSkillTargets(rawTargets);
10209
+ const report = installSkills({
10210
+ consumer: flags.has("consumer") || !flags.has("maintainer"),
10211
+ dryRun: flags.has("dry-run"),
10212
+ maintainer: flags.has("maintainer"),
10213
+ projectRoot: readFlag(flags, "project", process.cwd()),
10214
+ targets
10215
+ });
10216
+ if (json) {
10217
+ const payload = stringifyJson(report);
10218
+ return report.status === "pass" ? ok(payload) : {
10219
+ exitCode: 1,
10220
+ stderr: "",
10221
+ stdout: withTrailingNewline(payload)
10222
+ };
10223
+ }
10224
+ if (report.status !== "pass") return fail(["Failed to install xycomponents skills.", ...report.skipped].join("\n"));
10225
+ const lines = [
10226
+ `Installed ${report.installed.length} skill(s) for @czxingyu/xycomponents@${report.packageVersion}.`,
10227
+ `Project: ${report.projectRoot}`,
10228
+ `AGENTS.md: ${report.agentsGuide}`,
10229
+ "",
10230
+ "Targets:",
10231
+ ...Object.entries(SKILL_TARGETS).map(([name, directory]) => `- ${name}: ${directory}`),
10232
+ "",
10233
+ "Installed:",
10234
+ ...report.installed.map((item) => `- ${item.target}: ${item.path}`)
10235
+ ];
10236
+ if (report.skipped.length > 0) lines.push("", "Skipped:", ...report.skipped.map((item) => `- ${item}`));
10237
+ return ok(lines.join("\n"));
10238
+ }
10070
10239
  function printComponent(name, json) {
10071
10240
  if (!name) return fail("Missing component name.");
10072
10241
  const component = findComponent(name);
@@ -10154,10 +10323,15 @@ function runCli(argv) {
10154
10323
  if (argv.includes("-h")) return printHelp();
10155
10324
  const { flags, positionals } = parseArgs(argv);
10156
10325
  if (flags.has("help")) return printHelp();
10157
- const [rawCommand, componentName] = positionals;
10326
+ const [rawCommand, secondArg] = positionals;
10158
10327
  const command = rawCommand?.toLowerCase() ?? "help";
10159
10328
  const json = wantsJson(flags);
10160
10329
  if (command === "help") return printHelp();
10330
+ if (command === "skills") {
10331
+ if (secondArg?.toLowerCase() === "install") return printSkillsInstall(flags, json);
10332
+ return fail("Missing skills subcommand. Try \"xycomponents skills install\".");
10333
+ }
10334
+ const componentName = secondArg;
10161
10335
  if (command === "components" || command === "list") return printComponents(json, readFlag(flags, "category", "") || void 0, flags.has("include-retired"));
10162
10336
  if (command === "component" || command === "show") return printComponent(componentName, json);
10163
10337
  if (command === "snippet") return printSnippet(componentName, readFlag(flags, "example", "basic"), json);
package/dist/index.esm.js CHANGED
@@ -12,7 +12,7 @@ var qe = Object.create, Je = Object.defineProperty, Ye = Object.getOwnPropertyDe
12
12
  }, tt = (e, t, n) => (n = e == null ? {} : qe(Ze(e)), et(t || !e || !e.__esModule ? Je(n, "default", {
13
13
  value: e,
14
14
  enumerable: !0
15
- }) : n, e)), nt = "0.1.4";
15
+ }) : n, e)), nt = "0.1.5";
16
16
  //#endregion
17
17
  //#region components/shared/install.ts
18
18
  function X(e) {
@@ -25427,7 +25427,7 @@ var ip = ["aria-busy"], ap = { key: 0 }, op = { key: 0 }, sp = ["colspan"], cp =
25427
25427
  }))), ve = s(() => Xf(ge.value, r.rowKey, M.value ? r.tree : void 0, de.value)), ye = s(() => Math.max(1, Math.ceil(me.value.total / me.value.pageSize))), be = s(() => new Set(ue.value)), xe = s(() => ve.value.filter((e) => !it(e.record)).map((e) => e.key)), Se = s(() => xe.value.length > 0 && xe.value.every((e) => be.value.has(e))), Ce = s(() => xe.value.some((e) => be.value.has(e))), we = s(() => !!r.pagination && (!r.pagination || !r.pagination.hideOnSinglePage || me.value.total > me.value.pageSize)), Te = s(() => (P.value ? Wp : 0) + S.value.reduce((e, t) => e + Re(t), 0)), Ee = s(() => ze(Kp) + _e.value.reduce((e, t) => e + ze(t.key), 0)), De = s(() => [P.value ? `${Wp}px` : "", ...S.value.map((e) => `${Re(e)}px`)].filter(Boolean).join(" ")), Oe = s(() => ({
25428
25428
  maxHeight: r.autoHeight ? void 0 : Uf(r.scroll?.y),
25429
25429
  overflowX: j.value ? "hidden" : r.scroll?.x ? "auto" : void 0,
25430
- overflowY: r.autoHeight || !r.scroll?.y ? void 0 : "auto",
25430
+ overflowY: r.autoHeight || r.scroll?.y ? "auto" : void 0,
25431
25431
  ...Ne.value.container
25432
25432
  })), ke = s(() => w.value ? {
25433
25433
  minWidth: `${Ee.value}px`,
@@ -25438,6 +25438,7 @@ var ip = ["aria-busy"], ap = { key: 0 }, op = { key: 0 }, sp = ["colspan"], cp =
25438
25438
  width: L.value ? `${Te.value}px` : r.scroll?.x ? void 0 : "100%",
25439
25439
  ...Ne.value.table
25440
25440
  }), Ae = s(() => ({
25441
+ "xy-table--auto-height": r.autoHeight,
25441
25442
  "xy-table--bordered": r.bordered,
25442
25443
  "xy-table--loading": r.loading,
25443
25444
  "xy-table--striped": r.striped,
@@ -26347,7 +26348,7 @@ var ip = ["aria-busy"], ap = { key: 0 }, op = { key: 0 }, sp = ["colspan"], cp =
26347
26348
  "total"
26348
26349
  ])) : l("", !0)], 14, ip));
26349
26350
  }
26350
- }), [["__scopeId", "data-v-e1a0865c"]])), Jp = ["aria-label", "aria-orientation"], Yp = [
26351
+ }), [["__scopeId", "data-v-1e60de17"]])), Jp = ["aria-label", "aria-orientation"], Yp = [
26351
26352
  "data-tab-key",
26352
26353
  "id",
26353
26354
  "aria-controls",
@@ -9,7 +9,7 @@ import qe from "dayjs/plugin/quarterOfYear.js";
9
9
  import Je from "dayjs/plugin/weekOfYear.js";
10
10
  import Ye from "dayjs/plugin/weekYear.js";
11
11
  //#region package.json
12
- var Xe = "0.1.4";
12
+ var Xe = "0.1.5";
13
13
  //#endregion
14
14
  //#region components/shared/install.ts
15
15
  function Z(e) {