vite-plus 0.1.2 → 0.1.3

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.
Files changed (41) hide show
  1. package/binding/index.cjs +2 -0
  2. package/binding/index.d.cts +32 -0
  3. package/dist/global/{prompts-CAIahN1u.js → agent-BE4Xze8Q.js} +380 -1280
  4. package/dist/global/{browser-CY4NBwxR.js → browser-CBapUTD0.js} +579 -1023
  5. package/dist/global/{browser-DFpJ6sKb.js → browser-EZnNDcaO.js} +2 -3
  6. package/dist/global/{chunk-CtfvYSle.js → chunk-CgnkrU7a.js} +13 -22
  7. package/dist/global/{cli-truncate-BxinOqz5.js → cli-truncate-Da6Y8aM8.js} +25 -74
  8. package/dist/global/config.js +86 -166
  9. package/dist/global/create.js +353 -496
  10. package/dist/global/{terminal-Cb-NuRkb.js → help-BAGHa8fD.js} +22 -54
  11. package/dist/global/{json-Bfvtp2rL.js → json-BRdVJ52a.js} +24 -58
  12. package/dist/global/{lib-CibYHP32.js → lib-DxappLRQ.js} +19 -43
  13. package/dist/global/{log-update-DdU6_LCN.js → log-update-C8WCYCbc.js} +102 -281
  14. package/dist/global/mcp.js +97 -169
  15. package/dist/global/migrate.js +223 -83
  16. package/dist/global/{package-Pq2biU7_.js → package-YAMvX5PJ.js} +6 -13
  17. package/dist/global/{slice-ansi-BhwAwMdF.js → slice-ansi-Fap0ehe9.js} +21 -52
  18. package/dist/global/{src-C6aLHRsS.js → src-DwSJ0s0I.js} +28 -110
  19. package/dist/global/staged.js +654 -1521
  20. package/dist/global/{strip-ansi-BL-dgd7n.js → strip-ansi-CE-VDMdw.js} +20 -67
  21. package/dist/global/version.js +16 -37
  22. package/dist/global/{workspace-MTwAF3M9.js → workspace-lRm8huz4.js} +1625 -2816
  23. package/dist/global/wrap-ansi-Ou9oAs-a.js +3 -0
  24. package/dist/global/{wrap-ansi-Iww6Ak1s.js → wrap-ansi-eywLlPVQ.js} +29 -80
  25. package/dist/index.d.ts +1 -1
  26. package/dist/init-config.js +10 -2
  27. package/dist/utils/agent.d.ts +15 -1
  28. package/dist/utils/agent.js +104 -20
  29. package/dist/utils/constants.d.ts +1 -0
  30. package/dist/utils/constants.js +2 -0
  31. package/dist/utils/editor.d.ts +16 -3
  32. package/dist/utils/editor.js +55 -17
  33. package/dist/utils/prompts.d.ts +32 -3
  34. package/dist/utils/prompts.js +32 -8
  35. package/dist/utils/tsconfig.d.ts +6 -0
  36. package/dist/utils/tsconfig.js +16 -0
  37. package/package.json +13 -13
  38. package/templates/monorepo/package.json +1 -1
  39. package/dist/global/wrap-ansi-BJxjUEQR.js +0 -4
  40. package/dist/oxlint-config.d.ts +0 -498
  41. package/dist/oxlint-config.js +0 -309
@@ -1,7 +1,6 @@
1
1
  import { dirname, join } from "node:path";
2
2
  import { existsSync, readFileSync, readdirSync } from "node:fs";
3
3
  import { fileURLToPath } from "node:url";
4
-
5
4
  //#region src/mcp/bin.ts
6
5
  const PROTOCOL_VERSION = "2024-11-05";
7
6
  const TOOLS = [
@@ -41,69 +40,50 @@ const TOOLS = [
41
40
  function findPackageRoot(from) {
42
41
  let dir = from;
43
42
  while (true) {
44
- if (existsSync(join(dir, "package.json"))) {
45
- return dir;
46
- }
43
+ if (existsSync(join(dir, "package.json"))) return dir;
47
44
  const parent = dirname(dir);
48
- if (parent === dir) {
49
- break;
50
- }
45
+ if (parent === dir) break;
51
46
  dir = parent;
52
47
  }
53
48
  throw new Error("Could not find package.json from: " + from);
54
49
  }
55
50
  function readPackageVersion(pkgRoot) {
56
51
  const raw = readFileSync(join(pkgRoot, "package.json"), "utf8");
57
- const pkg = JSON.parse(raw);
58
- return pkg.version ?? "0.0.0";
52
+ return JSON.parse(raw).version ?? "0.0.0";
59
53
  }
60
54
  function resolveDocsDir(pkgRoot) {
61
55
  const bundledDocsDir = join(pkgRoot, "skills", "vite-plus", "docs");
62
- if (existsSync(bundledDocsDir)) {
63
- return bundledDocsDir;
64
- }
56
+ if (existsSync(bundledDocsDir)) return bundledDocsDir;
65
57
  const workspaceDocsDir = join(pkgRoot, "..", "..", "docs");
66
- if (existsSync(workspaceDocsDir)) {
67
- return workspaceDocsDir;
68
- }
58
+ if (existsSync(workspaceDocsDir)) return workspaceDocsDir;
69
59
  throw new Error(`Vite+ docs directory not found. Expected bundled docs at: ${bundledDocsDir}`);
70
60
  }
71
61
  function collectMarkdownFiles(rootDir, relativeDir = "") {
72
- const currentDir = join(rootDir, relativeDir);
73
- const entries = readdirSync(currentDir, { withFileTypes: true });
62
+ const entries = readdirSync(join(rootDir, relativeDir), { withFileTypes: true });
74
63
  const files = [];
75
64
  for (const entry of entries) {
76
65
  const relPath = relativeDir ? `${relativeDir}/${entry.name}` : entry.name;
77
66
  if (entry.isDirectory()) {
78
- if (entry.name === "node_modules") {
79
- continue;
80
- }
67
+ if (entry.name === "node_modules") continue;
81
68
  files.push(...collectMarkdownFiles(rootDir, relPath));
82
69
  continue;
83
70
  }
84
- if (entry.isFile() && entry.name.endsWith(".md")) {
85
- files.push(relPath);
86
- }
71
+ if (entry.isFile() && entry.name.endsWith(".md")) files.push(relPath);
87
72
  }
88
73
  files.sort();
89
74
  return files;
90
75
  }
91
76
  function normalizeDocId(value) {
92
- const normalized = value.trim().replace(/\\/g, "/").replace(/^docs\//, "").replace(/\.md$/, "").replace(/\/index$/, "").replace(/^\/+|\/+$/g, "");
93
- return normalized || "index";
77
+ return value.trim().replace(/\\/g, "/").replace(/^docs\//, "").replace(/\.md$/, "").replace(/\/index$/, "").replace(/^\/+|\/+$/g, "") || "index";
94
78
  }
95
79
  function createSlug(relativePath) {
96
80
  const withoutExt = relativePath.replace(/\.md$/, "");
97
- if (withoutExt === "index") {
98
- return "index";
99
- }
100
- if (withoutExt.endsWith("/index")) {
101
- return withoutExt.slice(0, -"/index".length);
102
- }
81
+ if (withoutExt === "index") return "index";
82
+ if (withoutExt.endsWith("/index")) return withoutExt.slice(0, -6);
103
83
  return withoutExt;
104
84
  }
105
85
  function buildAliases(page, basenameCounts) {
106
- const aliases = new Set();
86
+ const aliases = /* @__PURE__ */ new Set();
107
87
  const relativeNoExt = page.relativePath.replace(/\.md$/, "");
108
88
  const flatSlug = page.slug.replaceAll("/", "-");
109
89
  const baseName = page.slug.split("/").at(-1);
@@ -123,45 +103,34 @@ function buildAliases(page, basenameCounts) {
123
103
  }
124
104
  function loadDocs(pkgRoot) {
125
105
  const docsDir = resolveDocsDir(pkgRoot);
126
- const files = collectMarkdownFiles(docsDir);
127
- const pages = files.map((relativePath) => {
128
- const raw = readFileSync(join(docsDir, relativePath), "utf8");
129
- const content = raw.replace(/^---\n[\s\S]*?\n---\n/, "");
106
+ const pages = collectMarkdownFiles(docsDir).map((relativePath) => {
107
+ const content = readFileSync(join(docsDir, relativePath), "utf8").replace(/^---\n[\s\S]*?\n---\n/, "");
130
108
  const titleMatch = content.match(/^#\s+(.+)/m);
131
109
  const slug = createSlug(relativePath);
132
- const title = titleMatch ? titleMatch[1].trim() : slug;
133
110
  return {
134
111
  slug,
135
112
  relativePath,
136
- title,
113
+ title: titleMatch ? titleMatch[1].trim() : slug,
137
114
  content
138
115
  };
139
116
  });
140
- const basenameCounts = new Map();
117
+ const basenameCounts = /* @__PURE__ */ new Map();
141
118
  for (const page of pages) {
142
119
  const baseName = page.slug.split("/").at(-1);
143
- if (!baseName) {
144
- continue;
145
- }
120
+ if (!baseName) continue;
146
121
  basenameCounts.set(baseName, (basenameCounts.get(baseName) ?? 0) + 1);
147
122
  }
148
- const aliasCounts = new Map();
149
- const aliasSources = new Map();
123
+ const aliasCounts = /* @__PURE__ */ new Map();
124
+ const aliasSources = /* @__PURE__ */ new Map();
150
125
  for (const page of pages) {
151
126
  const aliases = [...new Set(buildAliases(page, basenameCounts).map(normalizeDocId))];
152
127
  aliasSources.set(page, aliases);
153
- for (const alias of aliases) {
154
- aliasCounts.set(alias, (aliasCounts.get(alias) ?? 0) + 1);
155
- }
128
+ for (const alias of aliases) aliasCounts.set(alias, (aliasCounts.get(alias) ?? 0) + 1);
156
129
  }
157
- const byAlias = new Map();
158
- for (const page of pages) {
159
- for (const alias of aliasSources.get(page) ?? []) {
160
- if ((aliasCounts.get(alias) ?? 0) !== 1) {
161
- continue;
162
- }
163
- byAlias.set(alias, page);
164
- }
130
+ const byAlias = /* @__PURE__ */ new Map();
131
+ for (const page of pages) for (const alias of aliasSources.get(page) ?? []) {
132
+ if ((aliasCounts.get(alias) ?? 0) !== 1) continue;
133
+ byAlias.set(alias, page);
165
134
  }
166
135
  return {
167
136
  pages,
@@ -170,9 +139,7 @@ function loadDocs(pkgRoot) {
170
139
  }
171
140
  function searchDocs(pages, query) {
172
141
  const terms = query.toLowerCase().split(/\s+/).filter((term) => term.length > 0);
173
- if (terms.length === 0) {
174
- return [];
175
- }
142
+ if (terms.length === 0) return [];
176
143
  const scored = [];
177
144
  for (const page of pages) {
178
145
  const titleLower = page.title.toLowerCase();
@@ -188,23 +155,17 @@ function searchDocs(pages, query) {
188
155
  idx = 0;
189
156
  while ((idx = contentLower.indexOf(term, idx)) !== -1) {
190
157
  score += 1;
191
- if (firstMatchIndex === -1) {
192
- firstMatchIndex = idx;
193
- }
158
+ if (firstMatchIndex === -1) firstMatchIndex = idx;
194
159
  idx += term.length;
195
160
  }
196
161
  }
197
- if (score === 0) {
198
- continue;
199
- }
162
+ if (score === 0) continue;
200
163
  let snippet;
201
164
  if (firstMatchIndex !== -1) {
202
165
  const start = Math.max(0, firstMatchIndex - 80);
203
166
  const end = Math.min(page.content.length, firstMatchIndex + 120);
204
167
  snippet = (start > 0 ? "..." : "") + page.content.slice(start, end).trim() + (end < page.content.length ? "..." : "");
205
- } else {
206
- snippet = page.content.slice(0, 200).trim() + "...";
207
- }
168
+ } else snippet = page.content.slice(0, 200).trim() + "...";
208
169
  scored.push({
209
170
  slug: page.slug,
210
171
  title: page.title,
@@ -230,37 +191,29 @@ function makeErrorResponse(id, code, message) {
230
191
  }
231
192
  function handleRequest(index, serverVersion, req) {
232
193
  const { method, id, params } = req;
233
- if (method === "initialize") {
234
- return {
235
- jsonrpc: "2.0",
236
- id: id ?? null,
237
- result: {
238
- protocolVersion: PROTOCOL_VERSION,
239
- capabilities: { tools: {} },
240
- serverInfo: {
241
- name: "vite-plus",
242
- version: serverVersion
243
- }
194
+ if (method === "initialize") return {
195
+ jsonrpc: "2.0",
196
+ id: id ?? null,
197
+ result: {
198
+ protocolVersion: PROTOCOL_VERSION,
199
+ capabilities: { tools: {} },
200
+ serverInfo: {
201
+ name: "vite-plus",
202
+ version: serverVersion
244
203
  }
245
- };
246
- }
247
- if (method === "notifications/initialized" || method === "$/cancelRequest") {
248
- return null;
249
- }
250
- if (method === "ping") {
251
- return {
252
- jsonrpc: "2.0",
253
- id: id ?? null,
254
- result: {}
255
- };
256
- }
257
- if (method === "tools/list") {
258
- return {
259
- jsonrpc: "2.0",
260
- id: id ?? null,
261
- result: { tools: TOOLS }
262
- };
263
- }
204
+ }
205
+ };
206
+ if (method === "notifications/initialized" || method === "$/cancelRequest") return null;
207
+ if (method === "ping") return {
208
+ jsonrpc: "2.0",
209
+ id: id ?? null,
210
+ result: {}
211
+ };
212
+ if (method === "tools/list") return {
213
+ jsonrpc: "2.0",
214
+ id: id ?? null,
215
+ result: { tools: TOOLS }
216
+ };
264
217
  if (method === "tools/call") {
265
218
  const toolName = params?.name ?? "";
266
219
  const toolArgs = params?.arguments ?? {};
@@ -281,33 +234,29 @@ function handleRequest(index, serverVersion, req) {
281
234
  }
282
235
  if (toolName === "get_page") {
283
236
  const slug = toolArgs.slug;
284
- if (typeof slug !== "string" || slug.trim().length === 0) {
285
- return {
286
- jsonrpc: "2.0",
287
- id: id ?? null,
288
- result: {
289
- content: [{
290
- type: "text",
291
- text: "Missing required string argument: slug"
292
- }],
293
- isError: true
294
- }
295
- };
296
- }
237
+ if (typeof slug !== "string" || slug.trim().length === 0) return {
238
+ jsonrpc: "2.0",
239
+ id: id ?? null,
240
+ result: {
241
+ content: [{
242
+ type: "text",
243
+ text: "Missing required string argument: slug"
244
+ }],
245
+ isError: true
246
+ }
247
+ };
297
248
  const page = resolvePageBySlug(index, slug);
298
- if (!page) {
299
- return {
300
- jsonrpc: "2.0",
301
- id: id ?? null,
302
- result: {
303
- content: [{
304
- type: "text",
305
- text: `Page not found: ${slug}`
306
- }],
307
- isError: true
308
- }
309
- };
310
- }
249
+ if (!page) return {
250
+ jsonrpc: "2.0",
251
+ id: id ?? null,
252
+ result: {
253
+ content: [{
254
+ type: "text",
255
+ text: `Page not found: ${slug}`
256
+ }],
257
+ isError: true
258
+ }
259
+ };
311
260
  return {
312
261
  jsonrpc: "2.0",
313
262
  id: id ?? null,
@@ -319,19 +268,17 @@ function handleRequest(index, serverVersion, req) {
319
268
  }
320
269
  if (toolName === "search_docs") {
321
270
  const query = toolArgs.query;
322
- if (typeof query !== "string" || query.trim().length === 0) {
323
- return {
324
- jsonrpc: "2.0",
325
- id: id ?? null,
326
- result: {
327
- content: [{
328
- type: "text",
329
- text: "Missing required string argument: query"
330
- }],
331
- isError: true
332
- }
333
- };
334
- }
271
+ if (typeof query !== "string" || query.trim().length === 0) return {
272
+ jsonrpc: "2.0",
273
+ id: id ?? null,
274
+ result: {
275
+ content: [{
276
+ type: "text",
277
+ text: "Missing required string argument: query"
278
+ }],
279
+ isError: true
280
+ }
281
+ };
335
282
  const results = searchDocs(index.pages, query);
336
283
  return {
337
284
  jsonrpc: "2.0",
@@ -342,14 +289,10 @@ function handleRequest(index, serverVersion, req) {
342
289
  }] }
343
290
  };
344
291
  }
345
- if (id === undefined) {
346
- return null;
347
- }
292
+ if (id === void 0) return null;
348
293
  return makeErrorResponse(id, -32601, `Unknown tool: ${toolName}`);
349
294
  }
350
- if (id === undefined) {
351
- return null;
352
- }
295
+ if (id === void 0) return null;
353
296
  return makeErrorResponse(id, -32601, `Unknown method: ${method}`);
354
297
  }
355
298
  function writeMessage(payload) {
@@ -360,15 +303,11 @@ function writeMessage(payload) {
360
303
  function findHeadersBoundary(buffer) {
361
304
  const crlf = buffer.indexOf("\r\n\r\n");
362
305
  const lf = buffer.indexOf("\n\n");
363
- if (crlf === -1 && lf === -1) {
364
- return null;
365
- }
366
- if (crlf !== -1 && (lf === -1 || crlf < lf)) {
367
- return {
368
- end: crlf,
369
- separatorLength: 4
370
- };
371
- }
306
+ if (crlf === -1 && lf === -1) return null;
307
+ if (crlf !== -1 && (lf === -1 || crlf < lf)) return {
308
+ end: crlf,
309
+ separatorLength: 4
310
+ };
372
311
  return {
373
312
  end: lf,
374
313
  separatorLength: 2
@@ -380,9 +319,7 @@ function parseContentLength(rawHeaders) {
380
319
  const match = line.match(/^content-length:\s*(\d+)\s*$/i);
381
320
  if (match) {
382
321
  const value = Number.parseInt(match[1], 10);
383
- if (Number.isSafeInteger(value) && value >= 0) {
384
- return value;
385
- }
322
+ if (Number.isSafeInteger(value) && value >= 0) return value;
386
323
  return null;
387
324
  }
388
325
  }
@@ -400,11 +337,8 @@ function startStdioServer(index, serverVersion) {
400
337
  buffer = Buffer.concat([buffer, chunk]);
401
338
  while (true) {
402
339
  const boundary = findHeadersBoundary(buffer);
403
- if (!boundary) {
404
- break;
405
- }
406
- const headerText = buffer.subarray(0, boundary.end).toString("utf8");
407
- const contentLength = parseContentLength(headerText);
340
+ if (!boundary) break;
341
+ const contentLength = parseContentLength(buffer.subarray(0, boundary.end).toString("utf8"));
408
342
  const bodyStart = boundary.end + boundary.separatorLength;
409
343
  if (contentLength === null) {
410
344
  writeMessage(makeErrorResponse(null, -32600, "Missing or invalid Content-Length header"));
@@ -412,9 +346,7 @@ function startStdioServer(index, serverVersion) {
412
346
  continue;
413
347
  }
414
348
  const bodyEnd = bodyStart + contentLength;
415
- if (buffer.length < bodyEnd) {
416
- break;
417
- }
349
+ if (buffer.length < bodyEnd) break;
418
350
  const body = buffer.subarray(bodyStart, bodyEnd).toString("utf8");
419
351
  buffer = buffer.subarray(bodyEnd);
420
352
  let request;
@@ -429,20 +361,16 @@ function startStdioServer(index, serverVersion) {
429
361
  continue;
430
362
  }
431
363
  const response = handleRequest(index, serverVersion, request);
432
- if (response !== null) {
433
- writeMessage(response);
434
- }
364
+ if (response !== null) writeMessage(response);
435
365
  }
436
366
  });
437
367
  }
438
368
  try {
439
369
  const packageRoot = findPackageRoot(dirname(fileURLToPath(import.meta.url)));
440
370
  const serverVersion = readPackageVersion(packageRoot);
441
- const docs = loadDocs(packageRoot);
442
- startStdioServer(docs, serverVersion);
371
+ startStdioServer(loadDocs(packageRoot), serverVersion);
443
372
  } catch (err) {
444
373
  process.stderr.write(`[vite-plus mcp] Failed to start: ${err instanceof Error ? err.message : String(err)}\n`);
445
374
  process.exit(1);
446
375
  }
447
-
448
- //#endregion
376
+ //#endregion