vite-plugin-ai-annotator 1.14.16 → 1.16.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.
@@ -32,6 +32,14 @@ export interface AiAnnotatorOptions {
32
32
  * @default true
33
33
  */
34
34
  autoSetupSkills?: boolean;
35
+ /**
36
+ * Print a one-time hint pointing the user at the Claude Code channel plugin
37
+ * (claude-annotator-plugin) when it is not already enabled in their
38
+ * ~/.claude/settings.json. The hint is the install commands themselves —
39
+ * this plugin never modifies your global Claude Code config.
40
+ * @default true
41
+ */
42
+ autoSetupChannelPlugin?: boolean;
35
43
  }
36
44
  /**
37
45
  * AI-powered element annotator for Vite development.
@@ -2,7 +2,8 @@
2
2
  import { spawn } from "node:child_process";
3
3
  import { fileURLToPath } from "node:url";
4
4
  import { dirname as dirname2, join as join2, relative } from "node:path";
5
- import { existsSync as existsSync2 } from "node:fs";
5
+ import { existsSync as existsSync2, readFileSync as readFileSync2 } from "node:fs";
6
+ import { homedir } from "node:os";
6
7
 
7
8
  // node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
8
9
  var comma = ",".charCodeAt(0);
@@ -1218,6 +1219,27 @@ ${body}
1218
1219
  }
1219
1220
 
1220
1221
  // src/vite-plugin.ts
1222
+ var CHANNEL_PLUGIN_KEY = "claude-annotator-plugin@claude-annotator-plugin";
1223
+ var CHANNEL_PLUGIN_REPO = "nguyenvanduocit/claude-annotator-plugin";
1224
+ function isChannelPluginEnabled() {
1225
+ try {
1226
+ const settingsPath = join2(homedir(), ".claude", "settings.json");
1227
+ if (!existsSync2(settingsPath)) return false;
1228
+ const settings = JSON.parse(readFileSync2(settingsPath, "utf-8"));
1229
+ return Boolean(settings?.enabledPlugins?.[CHANNEL_PLUGIN_KEY]);
1230
+ } catch {
1231
+ return false;
1232
+ }
1233
+ }
1234
+ function printChannelPluginSuggestion() {
1235
+ console.log(
1236
+ `[ai-annotator] \u{1F4A1} Channel push plugin not detected. For instant push to Claude Code (instead of copy-paste), run once:
1237
+ /plugin marketplace add ${CHANNEL_PLUGIN_REPO}
1238
+ /plugin install ${CHANNEL_PLUGIN_KEY}
1239
+ claude --dangerously-load-development-channels plugin:${CHANNEL_PLUGIN_KEY}
1240
+ (Claude Code v2.1.80+; set autoSetupChannelPlugin: false in your vite.config to hide this.)`
1241
+ );
1242
+ }
1221
1243
  var SOURCE_LOC_ATTR = "data-source-loc";
1222
1244
  function injectSourceLocations(code, id, root) {
1223
1245
  if (!code.includes("<")) return null;
@@ -1301,7 +1323,8 @@ var AiAnnotatorServer = class {
1301
1323
  publicAddress: options.publicAddress ?? `http://${listenAddress}:${port}`,
1302
1324
  verbose: options.verbose ?? false,
1303
1325
  injectSourceLoc: options.injectSourceLoc ?? true,
1304
- autoSetupSkills: options.autoSetupSkills ?? true
1326
+ autoSetupSkills: options.autoSetupSkills ?? true,
1327
+ autoSetupChannelPlugin: options.autoSetupChannelPlugin ?? true
1305
1328
  };
1306
1329
  const currentFileDir = dirname2(fileURLToPath(import.meta.url));
1307
1330
  this.isRunningFromSource = currentFileDir.endsWith("/src") || currentFileDir.endsWith("\\src");
@@ -1451,6 +1474,9 @@ function aiAnnotator(options = {}) {
1451
1474
  console.log(`[ai-annotator] \u2705 AI skills updated: ${skillsResult.updated.map((f) => f.replace(root + "/", "")).join(", ")}`);
1452
1475
  }
1453
1476
  }
1477
+ if (options.autoSetupChannelPlugin !== false && !isChannelPluginEnabled()) {
1478
+ printChannelPluginSuggestion();
1479
+ }
1454
1480
  },
1455
1481
  async buildStart() {
1456
1482
  await serverManager.start();