vite-plugin-ai-annotator 1.2.3 → 1.3.2
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/annotator-toolbar.js +20 -1
- package/dist/auto-setup-mcp.d.ts +5 -1
- package/dist/index.cjs +7 -7
- package/dist/vite-plugin.js +25 -26
- package/dist/vite-plugin.js.map +2 -2
- package/package.json +1 -1
package/dist/vite-plugin.js
CHANGED
|
@@ -1155,29 +1155,12 @@ function detectExistingConfigs(projectRoot) {
|
|
|
1155
1155
|
];
|
|
1156
1156
|
return potentialConfigs.filter(existsSync);
|
|
1157
1157
|
}
|
|
1158
|
-
function printGenericInstructions(serverUrl, packageManager) {
|
|
1159
|
-
const config = buildMcpServerConfig(packageManager, serverUrl);
|
|
1160
|
-
const configJson = JSON.stringify({
|
|
1161
|
-
mcpServers: {
|
|
1162
|
-
[MCP_SERVER_NAME]: config
|
|
1163
|
-
}
|
|
1164
|
-
}, null, 2);
|
|
1165
|
-
console.log(`
|
|
1166
|
-
[ai-annotator] No MCP configuration files detected.
|
|
1167
|
-
|
|
1168
|
-
To enable MCP integration, create one of the following config files:
|
|
1169
|
-
|
|
1170
|
-
\u2022 .mcp.json (Claude Code)
|
|
1171
|
-
\u2022 .cursor/mcp.json (Cursor)
|
|
1172
|
-
\u2022 .vscode/mcp.json (VS Code + MCP extension)
|
|
1173
|
-
|
|
1174
|
-
Example configuration:
|
|
1175
|
-
|
|
1176
|
-
${configJson}
|
|
1177
|
-
`);
|
|
1178
|
-
}
|
|
1179
1158
|
function autoSetupMcp(options) {
|
|
1180
1159
|
const { projectRoot, serverUrl, verbose = false } = options;
|
|
1160
|
+
const result = {
|
|
1161
|
+
updated: [],
|
|
1162
|
+
alreadyConfigured: []
|
|
1163
|
+
};
|
|
1181
1164
|
const packageManager = detectPackageManager(projectRoot);
|
|
1182
1165
|
const serverConfig = buildMcpServerConfig(packageManager, serverUrl);
|
|
1183
1166
|
if (verbose) {
|
|
@@ -1185,17 +1168,25 @@ function autoSetupMcp(options) {
|
|
|
1185
1168
|
}
|
|
1186
1169
|
const existingConfigs = detectExistingConfigs(projectRoot);
|
|
1187
1170
|
if (existingConfigs.length === 0) {
|
|
1188
|
-
|
|
1189
|
-
|
|
1171
|
+
const defaultConfigPath = join(projectRoot, ".mcp.json");
|
|
1172
|
+
const wasUpdated = setupConfigFile(defaultConfigPath, serverConfig, verbose);
|
|
1173
|
+
if (wasUpdated) {
|
|
1174
|
+
result.updated.push(defaultConfigPath);
|
|
1190
1175
|
}
|
|
1191
|
-
return;
|
|
1176
|
+
return result;
|
|
1192
1177
|
}
|
|
1193
1178
|
if (verbose) {
|
|
1194
1179
|
console.log(`[ai-annotator] Found ${existingConfigs.length} MCP config file(s)`);
|
|
1195
1180
|
}
|
|
1196
1181
|
for (const configFile of existingConfigs) {
|
|
1197
|
-
setupConfigFile(configFile, serverConfig, verbose);
|
|
1182
|
+
const wasUpdated = setupConfigFile(configFile, serverConfig, verbose);
|
|
1183
|
+
if (wasUpdated) {
|
|
1184
|
+
result.updated.push(configFile);
|
|
1185
|
+
} else {
|
|
1186
|
+
result.alreadyConfigured.push(configFile);
|
|
1187
|
+
}
|
|
1198
1188
|
}
|
|
1189
|
+
return result;
|
|
1199
1190
|
}
|
|
1200
1191
|
|
|
1201
1192
|
// src/vite-plugin.ts
|
|
@@ -1329,6 +1320,9 @@ var AiAnnotatorServer = class {
|
|
|
1329
1320
|
if (this.options.verbose) {
|
|
1330
1321
|
args.push("--verbose");
|
|
1331
1322
|
}
|
|
1323
|
+
if (this.options.autoSetupMcp) {
|
|
1324
|
+
args.push("--skip-mcp-instructions");
|
|
1325
|
+
}
|
|
1332
1326
|
this.log(`Starting annotator server: ${cmd} ${args.join(" ")}`);
|
|
1333
1327
|
this.log(`Working directory: ${this.packageDir}`);
|
|
1334
1328
|
this.serverProcess = spawn(cmd, args, {
|
|
@@ -1422,11 +1416,16 @@ function aiAnnotator(options = {}) {
|
|
|
1422
1416
|
root = config.root;
|
|
1423
1417
|
if (options.autoSetupMcp) {
|
|
1424
1418
|
const serverUrl = `http://${options.listenAddress ?? "localhost"}:${options.port ?? 7318}`;
|
|
1425
|
-
autoSetupMcp({
|
|
1419
|
+
const result = autoSetupMcp({
|
|
1426
1420
|
projectRoot: root,
|
|
1427
1421
|
serverUrl,
|
|
1428
1422
|
verbose: options.verbose
|
|
1429
1423
|
});
|
|
1424
|
+
if (result.updated.length > 0) {
|
|
1425
|
+
console.log(`[ai-annotator] \u2705 MCP config updated: ${result.updated.map((f) => f.replace(root + "/", "")).join(", ")}`);
|
|
1426
|
+
} else if (result.alreadyConfigured.length > 0) {
|
|
1427
|
+
console.log(`[ai-annotator] \u2705 MCP config already up-to-date`);
|
|
1428
|
+
}
|
|
1430
1429
|
}
|
|
1431
1430
|
},
|
|
1432
1431
|
async buildStart() {
|