driftx 0.1.2 → 0.1.4

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/bin.js CHANGED
@@ -3,7 +3,7 @@
3
3
  // src/cli.ts
4
4
  import { Command } from "commander";
5
5
  import { createRequire } from "module";
6
- import { existsSync as existsSync7, mkdirSync as mkdirSync5, readFileSync as readFileSync10, readdirSync as readdirSync2, symlinkSync, unlinkSync as unlinkSync3, writeFileSync as writeFileSync6 } from "fs";
6
+ import { existsSync as existsSync7, mkdirSync as mkdirSync5, readFileSync as readFileSync10, readdirSync as readdirSync2, rmSync, symlinkSync, unlinkSync as unlinkSync3, writeFileSync as writeFileSync6 } from "fs";
7
7
  import { dirname as dirname5, join as join7, resolve as resolve2 } from "path";
8
8
  import { homedir as homedir2 } from "os";
9
9
  import { fileURLToPath as fileURLToPath2 } from "url";
@@ -3684,7 +3684,11 @@ function createProgram() {
3684
3684
  const result = await executor.openUrl(device, url);
3685
3685
  console.log(JSON.stringify(result, null, 2));
3686
3686
  });
3687
- program.command("setup-claude").description("Register driftx as a Claude Code plugin").action(() => {
3687
+ program.command("setup-claude").description("Register driftx as a Claude Code plugin").option("--silent", "suppress output").action((opts) => {
3688
+ const silent = !!opts.silent;
3689
+ const log = (...args) => {
3690
+ if (!silent) console.log(...args);
3691
+ };
3688
3692
  const claudeDir = join7(homedir2(), ".claude");
3689
3693
  const pluginsDir = join7(claudeDir, "plugins");
3690
3694
  const driftxPluginDir = join7(pluginsDir, "driftx");
@@ -3707,6 +3711,17 @@ function createProgram() {
3707
3711
  }
3708
3712
  }
3709
3713
  symlinkSync(skillSource, driftxPluginDir);
3714
+ const pluginJsonPath = join7(skillSource, ".claude-plugin", "plugin.json");
3715
+ try {
3716
+ const pluginJson = JSON.parse(readFileSync10(pluginJsonPath, "utf-8"));
3717
+ pluginJson.version = pkg.version;
3718
+ writeFileSync6(pluginJsonPath, JSON.stringify(pluginJson, null, 2) + "\n");
3719
+ } catch {
3720
+ }
3721
+ const cacheDir = join7(pluginsDir, "cache", "local", "driftx");
3722
+ if (existsSync7(cacheDir)) {
3723
+ rmSync(cacheDir, { recursive: true, force: true });
3724
+ }
3710
3725
  let registry = { version: 2, plugins: {} };
3711
3726
  try {
3712
3727
  registry = JSON.parse(readFileSync10(registryPath, "utf-8"));
@@ -3720,10 +3735,32 @@ function createProgram() {
3720
3735
  lastUpdated: (/* @__PURE__ */ new Date()).toISOString()
3721
3736
  }];
3722
3737
  writeFileSync6(registryPath, JSON.stringify(registry, null, 2));
3723
- console.log("driftx registered as Claude Code plugin.");
3724
- console.log(` Symlink: ${driftxPluginDir} -> ${skillSource}`);
3725
- console.log(` Registry: ${registryPath}`);
3726
- console.log("\nRestart Claude Code to pick up the driftx skill.");
3738
+ log("driftx registered as Claude Code plugin.");
3739
+ log(` Symlink: ${driftxPluginDir} -> ${skillSource}`);
3740
+ log(` Registry: ${registryPath}`);
3741
+ log("\nRestart Claude Code to pick up the driftx skill.");
3742
+ });
3743
+ program.command("setup-cursor").description("Add driftx skill to a Cursor project").action(() => {
3744
+ const packageRoot = resolve2(dirname5(fileURLToPath2(import.meta.url)), "..");
3745
+ const skillPath = join7(packageRoot, "driftx-plugin", "skills", "driftx", "SKILL.md");
3746
+ if (!existsSync7(skillPath)) {
3747
+ console.error(`SKILL.md not found at ${skillPath}`);
3748
+ process.exitCode = 1;
3749
+ return;
3750
+ }
3751
+ const skillContent = readFileSync10(skillPath, "utf-8").replace(/^---[\s\S]*?---\n*/, "");
3752
+ const rulesDir = join7(process.cwd(), ".cursor", "rules");
3753
+ mkdirSync5(rulesDir, { recursive: true });
3754
+ const targetPath = join7(rulesDir, "driftx.mdc");
3755
+ writeFileSync6(targetPath, `---
3756
+ description: driftx - Visual comparison, accessibility audit, layout regression, and device interaction for mobile apps
3757
+ globs:
3758
+ alwaysApply: true
3759
+ ---
3760
+
3761
+ ${skillContent}`);
3762
+ console.log(`driftx skill written to ${targetPath}`);
3763
+ console.log("Cursor will pick it up automatically.");
3727
3764
  });
3728
3765
  return program;
3729
3766
  }