@inspecto-dev/cli 0.3.7 → 0.3.9

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.
@@ -202,14 +202,14 @@ var ViteStrategy = class {
202
202
  supports(tool) {
203
203
  return tool === "vite";
204
204
  }
205
- inject({ mod, detection }) {
205
+ inject({ mod, detection: _detection }) {
206
206
  addVitePlugin(mod, {
207
207
  from: "@inspecto-dev/plugin",
208
208
  constructor: "inspecto",
209
209
  imported: "vitePlugin"
210
210
  });
211
211
  }
212
- getManualInstructions(detection, reason) {
212
+ getManualInstructions(_detection, _reason) {
213
213
  return [
214
214
  `import { vitePlugin as inspecto } from '@inspecto-dev/plugin'`,
215
215
  "",
@@ -228,10 +228,10 @@ var WebpackStrategy = class {
228
228
  supports(tool) {
229
229
  return tool === "webpack";
230
230
  }
231
- inject(options) {
231
+ inject(_options) {
232
232
  throw new Error("Webpack requires manual plugin configuration");
233
233
  }
234
- getManualInstructions(detection, reason) {
234
+ getManualInstructions(detection, _reason) {
235
235
  const importPkg = detection.isLegacyWebpack ? "@inspecto-dev/plugin/legacy/webpack4" : "@inspecto-dev/plugin";
236
236
  const pluginName = detection.isLegacyWebpack ? "webpack4Plugin" : "webpackPlugin";
237
237
  const pluginCall = detection.isLegacyWebpack ? `process.env.NODE_ENV !== 'production' && inspecto({
@@ -256,10 +256,10 @@ var RspackStrategy = class {
256
256
  supports(tool) {
257
257
  return tool === "rspack";
258
258
  }
259
- inject(options) {
259
+ inject(_options) {
260
260
  throw new Error("Rspack requires manual plugin configuration");
261
261
  }
262
- getManualInstructions(detection, reason) {
262
+ getManualInstructions(detection, _reason) {
263
263
  const importPkg = detection.isLegacyRspack ? "@inspecto-dev/plugin/legacy/rspack" : "@inspecto-dev/plugin";
264
264
  const pluginCall = detection.isLegacyRspack ? `process.env.NODE_ENV !== 'production' && inspecto({
265
265
  pathType: 'absolute',
@@ -283,10 +283,10 @@ var RsbuildStrategy = class {
283
283
  supports(tool) {
284
284
  return tool === "rsbuild";
285
285
  }
286
- inject(options) {
286
+ inject(_options) {
287
287
  throw new Error("Rsbuild requires manual plugin configuration due to nested structure");
288
288
  }
289
- getManualInstructions(detection, reason) {
289
+ getManualInstructions(_detection, _reason) {
290
290
  return [
291
291
  `import { rspackPlugin as inspecto } from '@inspecto-dev/plugin'`,
292
292
  "",
@@ -308,10 +308,10 @@ var EsbuildStrategy = class {
308
308
  supports(tool) {
309
309
  return tool === "esbuild";
310
310
  }
311
- inject(options) {
311
+ inject(_options) {
312
312
  throw new Error("Esbuild requires manual plugin configuration");
313
313
  }
314
- getManualInstructions(detection, reason) {
314
+ getManualInstructions(detection, _reason) {
315
315
  return [
316
316
  `1. Update your esbuild config (${detection.configPath}):`,
317
317
  `import { esbuildPlugin as inspecto } from '@inspecto-dev/plugin'`,
@@ -339,10 +339,10 @@ var RollupStrategy = class {
339
339
  supports(tool) {
340
340
  return tool === "rollup";
341
341
  }
342
- inject(options) {
342
+ inject(_options) {
343
343
  throw new Error("Rollup requires manual plugin configuration");
344
344
  }
345
- getManualInstructions(detection, reason) {
345
+ getManualInstructions(detection, _reason) {
346
346
  return [
347
347
  `1. Update your rollup config (${detection.configPath}):`,
348
348
  `import { rollupPlugin as inspecto } from '@inspecto-dev/plugin'`,
@@ -1869,22 +1869,25 @@ import { createRequire as createRequire2 } from "module";
1869
1869
  var META_FRAMEWORK_MAP = {
1870
1870
  next: "react",
1871
1871
  nuxt: "vue",
1872
+ "@sveltejs/kit": "svelte",
1872
1873
  "@remix-run/react": "react",
1873
1874
  "@remix-run/dev": "react",
1874
1875
  "@vue/nuxt": "vue",
1875
1876
  "vite-plugin-vue": "vue",
1876
1877
  "@vitejs/plugin-vue": "vue",
1878
+ "@sveltejs/vite-plugin-svelte": "svelte",
1879
+ "vite-plugin-solid": "solid",
1877
1880
  "@vitejs/plugin-react": "react",
1878
1881
  "@vitejs/plugin-react-swc": "react"
1879
1882
  };
1880
1883
  var SUPPORTED_FRAMEWORKS = [
1881
1884
  { framework: "react", deps: ["react", "react-dom"] },
1882
- { framework: "vue", deps: ["vue"] }
1885
+ { framework: "vue", deps: ["vue"] },
1886
+ { framework: "svelte", deps: ["svelte"] },
1887
+ { framework: "solid", deps: ["solid-js"] },
1888
+ { framework: "astro", deps: ["astro"] }
1883
1889
  ];
1884
1890
  var UNSUPPORTED_FRAMEWORKS = [
1885
- { name: "Solid", dep: "solid-js" },
1886
- { name: "Svelte", dep: "svelte" },
1887
- { name: "SvelteKit", dep: "@sveltejs/kit" },
1888
1891
  { name: "Angular", dep: "@angular/core" },
1889
1892
  { name: "Preact", dep: "preact" },
1890
1893
  { name: "Lit", dep: "lit" },
@@ -2494,7 +2497,7 @@ function buildUmiMountSnippet() {
2494
2497
  " if (process.env.NODE_ENV !== 'production') {",
2495
2498
  " import('@inspecto-dev/core').then(({ mountInspector }) => {",
2496
2499
  " mountInspector({",
2497
- " serverUrl: 'http://127.0.0.1:' + ((window as any).__AI_INSPECTOR_PORT__ || 5678),",
2500
+ " serverUrl: 'http://0.0.0.0:' + ((window as { __AI_INSPECTOR_PORT__?: number }).__AI_INSPECTOR_PORT__ || 5678),",
2498
2501
  " })",
2499
2502
  " })",
2500
2503
  " }",
@@ -3376,21 +3379,29 @@ function resolveOnboardingTarget(input) {
3376
3379
  import prompts from "prompts";
3377
3380
  async function promptIDEChoice(detections) {
3378
3381
  if (!process.stdin.isTTY) {
3379
- log.warn("Multiple IDEs detected but stdin is not interactive");
3380
- log.hint(`Using: ${detections[0].ide} (first match)`);
3381
- return detections[0];
3382
+ if (detections.length > 0) {
3383
+ log.warn("Multiple IDEs detected but stdin is not interactive");
3384
+ log.hint(`Using: ${detections[0].ide} (first match)`);
3385
+ return detections[0];
3386
+ }
3387
+ return { ide: "none", supported: true };
3382
3388
  }
3389
+ const choices = detections.map((d) => ({
3390
+ title: `${d.ide} ${d.supported ? "(supported)" : "(unsupported/limited)"}`,
3391
+ value: d
3392
+ }));
3393
+ choices.push({
3394
+ title: "none (Standalone / MCP / Browser-only)",
3395
+ value: { ide: "none", supported: true }
3396
+ });
3383
3397
  const { choice } = await prompts({
3384
3398
  type: "select",
3385
3399
  name: "choice",
3386
- message: "Detected multiple IDEs, please choose one:",
3387
- choices: detections.map((d, i) => ({
3388
- title: `${d.ide} ${d.supported ? "(supported)" : "(unsupported/limited)"}`,
3389
- value: i
3390
- }))
3400
+ message: "Detected multiple IDEs, please choose one (or select none for standalone use):",
3401
+ choices
3391
3402
  });
3392
3403
  if (choice === void 0) return null;
3393
- return detections[choice];
3404
+ return choice;
3394
3405
  }
3395
3406
  async function promptProviderChoice(detections) {
3396
3407
  if (!process.stdin.isTTY) {
@@ -3565,7 +3576,7 @@ function printNextJsManualInstructions() {
3565
3576
  " useEffect(() => {",
3566
3577
  " if (process.env.NODE_ENV !== 'production') {",
3567
3578
  " import('@inspecto-dev/core').then(({ mountInspector }) => {",
3568
- " mountInspector({ serverUrl: 'http://127.0.0.1:5678' })",
3579
+ " mountInspector({ serverUrl: 'http://0.0.0.0:5678' })",
3569
3580
  " })",
3570
3581
  " }",
3571
3582
  " }, [])",
@@ -3721,10 +3732,14 @@ async function init(options) {
3721
3732
  "Please refer to the manual setup guide: https://inspecto-dev.github.io/inspecto/guide/manual-installation"
3722
3733
  );
3723
3734
  }
3724
- let selectedIDE = null;
3735
+ let selectedIDE;
3725
3736
  if (ideProbe.detected.length === 0) {
3726
- log.error("No IDE detected in current project");
3727
- log.hint("Please open this project in a supported IDE (like VS Code)");
3737
+ if (process.stdin.isTTY) {
3738
+ log.warn("No IDE detected in current project");
3739
+ selectedIDE = await promptIDEChoice([]);
3740
+ } else {
3741
+ selectedIDE = { ide: "none", supported: true };
3742
+ }
3728
3743
  } else if (ideProbe.detected.length === 1) {
3729
3744
  selectedIDE = ideProbe.detected[0];
3730
3745
  } else {
@@ -4300,8 +4315,311 @@ async function doctor(options = {}) {
4300
4315
  return writeCommandOutput(result, json, printDoctorResult);
4301
4316
  }
4302
4317
 
4303
- // src/onboarding/session.ts
4318
+ // src/commands/mcp.ts
4319
+ import fs6 from "fs";
4320
+ import os from "os";
4304
4321
  import path17 from "path";
4322
+ import crypto from "crypto";
4323
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
4324
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4325
+ import { INSPECTO_API_PATHS } from "@inspecto-dev/types";
4326
+ import { z } from "zod";
4327
+ var DEFAULT_MCP_SERVER_VERSION = "0.0.0";
4328
+ var INSPECTO_MCP_TOOLS = [
4329
+ {
4330
+ name: "inspecto_get_session",
4331
+ description: "Return one Inspecto annotation session by sessionId."
4332
+ },
4333
+ {
4334
+ name: "inspecto_claim_next",
4335
+ description: "Wait for the next unclaimed Inspecto annotation session, mark it acknowledged, and return full context."
4336
+ },
4337
+ {
4338
+ name: "inspecto_reply",
4339
+ description: "Append an agent reply to an Inspecto annotation session."
4340
+ },
4341
+ {
4342
+ name: "inspecto_resolve",
4343
+ description: "Resolve an Inspecto annotation session with an optional final message."
4344
+ },
4345
+ {
4346
+ name: "inspecto_dismiss",
4347
+ description: "Dismiss an Inspecto annotation session with an optional final message."
4348
+ }
4349
+ ];
4350
+ async function startMcpServer(options = {}) {
4351
+ const baseUrl = options.serverUrl ?? resolveInspectoServerBaseUrl(process.cwd());
4352
+ if (!baseUrl) {
4353
+ throw new Error(
4354
+ "Could not find a running Inspecto dev server. Start your local dev server or pass --server-url <url>."
4355
+ );
4356
+ }
4357
+ const server = createInspectoMcpServer({
4358
+ baseUrl,
4359
+ ...options.version ? { version: options.version } : {}
4360
+ });
4361
+ const transport = new StdioServerTransport();
4362
+ await server.connect(transport);
4363
+ }
4364
+ function createInspectoMcpServer(options) {
4365
+ const runtime = createInspectoMcpRuntime(options.baseUrl);
4366
+ const server = new McpServer({
4367
+ name: "inspecto-mcp",
4368
+ version: options.version ?? DEFAULT_MCP_SERVER_VERSION
4369
+ });
4370
+ server.registerTool(
4371
+ "inspecto_get_session",
4372
+ {
4373
+ description: getToolDescription("inspecto_get_session"),
4374
+ inputSchema: {
4375
+ sessionId: z.string().min(1)
4376
+ }
4377
+ },
4378
+ async ({ sessionId }) => {
4379
+ try {
4380
+ const result = await runtime.getSession({ sessionId });
4381
+ return toolSuccess(result);
4382
+ } catch (error) {
4383
+ return toolError(error);
4384
+ }
4385
+ }
4386
+ );
4387
+ server.registerTool(
4388
+ "inspecto_claim_next",
4389
+ {
4390
+ description: getToolDescription("inspecto_claim_next"),
4391
+ inputSchema: {
4392
+ timeoutMs: z.number().int().nonnegative().optional()
4393
+ }
4394
+ },
4395
+ async ({ timeoutMs }) => {
4396
+ try {
4397
+ const result = await runtime.claimNext({
4398
+ ...timeoutMs !== void 0 ? { timeoutMs } : {}
4399
+ });
4400
+ return toolSuccess(result);
4401
+ } catch (error) {
4402
+ return toolError(error);
4403
+ }
4404
+ }
4405
+ );
4406
+ server.registerTool(
4407
+ "inspecto_reply",
4408
+ {
4409
+ description: getToolDescription("inspecto_reply"),
4410
+ inputSchema: {
4411
+ sessionId: z.string().min(1),
4412
+ text: z.string().min(1)
4413
+ }
4414
+ },
4415
+ async ({ sessionId, text }) => {
4416
+ try {
4417
+ const result = await runtime.reply({ sessionId, text });
4418
+ return toolSuccess(result);
4419
+ } catch (error) {
4420
+ return toolError(error);
4421
+ }
4422
+ }
4423
+ );
4424
+ server.registerTool(
4425
+ "inspecto_resolve",
4426
+ {
4427
+ description: getToolDescription("inspecto_resolve"),
4428
+ inputSchema: {
4429
+ sessionId: z.string().min(1),
4430
+ message: z.string().optional()
4431
+ }
4432
+ },
4433
+ async ({ sessionId, message: message2 }) => {
4434
+ try {
4435
+ const result = await runtime.resolve({ sessionId, ...message2 ? { message: message2 } : {} });
4436
+ return toolSuccess(result);
4437
+ } catch (error) {
4438
+ return toolError(error);
4439
+ }
4440
+ }
4441
+ );
4442
+ server.registerTool(
4443
+ "inspecto_dismiss",
4444
+ {
4445
+ description: getToolDescription("inspecto_dismiss"),
4446
+ inputSchema: {
4447
+ sessionId: z.string().min(1),
4448
+ message: z.string().optional()
4449
+ }
4450
+ },
4451
+ async ({ sessionId, message: message2 }) => {
4452
+ try {
4453
+ const result = await runtime.dismiss({ sessionId, ...message2 ? { message: message2 } : {} });
4454
+ return toolSuccess(result);
4455
+ } catch (error) {
4456
+ return toolError(error);
4457
+ }
4458
+ }
4459
+ );
4460
+ return server;
4461
+ }
4462
+ function getToolDescription(name) {
4463
+ return INSPECTO_MCP_TOOLS.find((tool) => tool.name === name)?.description ?? name;
4464
+ }
4465
+ function createInspectoMcpRuntime(baseUrl) {
4466
+ return {
4467
+ async getSession(args) {
4468
+ return getSession(baseUrl, args.sessionId);
4469
+ },
4470
+ async claimNext(args = {}) {
4471
+ return await postJson(`${baseUrl}${INSPECTO_API_PATHS.SESSION_CLAIM_NEXT}`, {
4472
+ ...args.timeoutMs !== void 0 ? { timeoutMs: args.timeoutMs } : {}
4473
+ });
4474
+ },
4475
+ async reply(args) {
4476
+ return postJson(
4477
+ `${baseUrl}${INSPECTO_API_PATHS.SESSIONS}/${args.sessionId}${INSPECTO_API_PATHS.SESSION_REPLY_SUFFIX}`,
4478
+ {
4479
+ role: "agent",
4480
+ text: args.text.trim()
4481
+ }
4482
+ );
4483
+ },
4484
+ async resolve(args) {
4485
+ return postJson(
4486
+ `${baseUrl}${INSPECTO_API_PATHS.SESSIONS}/${args.sessionId}${INSPECTO_API_PATHS.SESSION_RESOLVE_SUFFIX}`,
4487
+ args.message?.trim() ? { message: args.message.trim() } : {}
4488
+ );
4489
+ },
4490
+ async dismiss(args) {
4491
+ return postJson(
4492
+ `${baseUrl}${INSPECTO_API_PATHS.SESSIONS}/${args.sessionId}${INSPECTO_API_PATHS.SESSION_DISMISS_SUFFIX}`,
4493
+ args.message?.trim() ? { message: args.message.trim() } : {}
4494
+ );
4495
+ }
4496
+ };
4497
+ }
4498
+ function resolveInspectoServerBaseUrl(cwd) {
4499
+ const ports = resolveServerPorts(cwd);
4500
+ const port = ports[0];
4501
+ return port ? `http://0.0.0.0:${port}` : null;
4502
+ }
4503
+ function resolveServerPorts(cwd) {
4504
+ const prioritized = readProjectScopedPorts(cwd);
4505
+ if (prioritized.length > 0) return prioritized;
4506
+ const legacyPortFile = path17.join(os.tmpdir(), "inspecto.port");
4507
+ try {
4508
+ const raw = fs6.readFileSync(legacyPortFile, "utf-8").trim();
4509
+ const port = parseInt(raw, 10);
4510
+ if (Number.isInteger(port) && port > 0 && port < 65536) {
4511
+ return [port];
4512
+ }
4513
+ } catch {
4514
+ }
4515
+ return Array.from({ length: 23 }, (_, index) => 5678 + index);
4516
+ }
4517
+ function toolSuccess(value) {
4518
+ return {
4519
+ content: [
4520
+ {
4521
+ type: "text",
4522
+ text: JSON.stringify(value, null, 2)
4523
+ }
4524
+ ],
4525
+ structuredContent: value
4526
+ };
4527
+ }
4528
+ function toolError(error) {
4529
+ const message2 = error instanceof Error ? error.message : String(error);
4530
+ return {
4531
+ content: [
4532
+ {
4533
+ type: "text",
4534
+ text: message2
4535
+ }
4536
+ ],
4537
+ structuredContent: {
4538
+ success: false,
4539
+ error: message2
4540
+ },
4541
+ isError: true
4542
+ };
4543
+ }
4544
+ async function getJson(url) {
4545
+ const response = await fetch(url);
4546
+ const payload = await response.json().catch(() => ({}));
4547
+ if (!response.ok) {
4548
+ throw new Error(String(payload["error"] ?? `Request failed with status ${response.status}.`));
4549
+ }
4550
+ return payload;
4551
+ }
4552
+ async function getSession(baseUrl, sessionId) {
4553
+ const trimmed = sessionId.trim();
4554
+ if (!trimmed) {
4555
+ throw new Error("Session id is required.");
4556
+ }
4557
+ const payload = await getJson(
4558
+ `${baseUrl}${INSPECTO_API_PATHS.SESSIONS}/${encodeURIComponent(trimmed)}`
4559
+ );
4560
+ if (!payload.success || !payload.session) {
4561
+ throw new Error(payload.error ?? "Session not found.");
4562
+ }
4563
+ return {
4564
+ success: true,
4565
+ session: payload.session
4566
+ };
4567
+ }
4568
+ async function postJson(url, body) {
4569
+ const response = await fetch(url, {
4570
+ method: "POST",
4571
+ headers: { "Content-Type": "application/json" },
4572
+ body: JSON.stringify(body)
4573
+ });
4574
+ const payload = await response.json().catch(() => ({}));
4575
+ if (!response.ok || payload["success"] === false) {
4576
+ throw new Error(String(payload["error"] ?? `Request failed with status ${response.status}.`));
4577
+ }
4578
+ return payload;
4579
+ }
4580
+ function readProjectScopedPorts(cwd) {
4581
+ const portFile = path17.join(os.tmpdir(), "inspecto.port.json");
4582
+ try {
4583
+ const raw = fs6.readFileSync(portFile, "utf-8").trim();
4584
+ const portData = JSON.parse(raw);
4585
+ const currentRootHashes = resolveCandidateRootHashes(cwd);
4586
+ const prioritized = [];
4587
+ const seen = /* @__PURE__ */ new Set();
4588
+ for (const rootHash of currentRootHashes) {
4589
+ const currentPort = portData[rootHash];
4590
+ if (currentPort && !seen.has(currentPort)) {
4591
+ prioritized.push(currentPort);
4592
+ seen.add(currentPort);
4593
+ }
4594
+ }
4595
+ for (const port of Object.values(portData)) {
4596
+ if (!seen.has(port)) {
4597
+ prioritized.push(port);
4598
+ seen.add(port);
4599
+ }
4600
+ }
4601
+ return prioritized;
4602
+ } catch {
4603
+ return [];
4604
+ }
4605
+ }
4606
+ function resolveCandidateRootHashes(cwd) {
4607
+ const normalized = path17.resolve(cwd);
4608
+ const candidates = /* @__PURE__ */ new Set();
4609
+ let currentDir = normalized;
4610
+ while (true) {
4611
+ candidates.add(crypto.createHash("md5").update(currentDir).digest("hex"));
4612
+ const parentDir = path17.dirname(currentDir);
4613
+ if (parentDir === currentDir) {
4614
+ break;
4615
+ }
4616
+ currentDir = parentDir;
4617
+ }
4618
+ return [...candidates];
4619
+ }
4620
+
4621
+ // src/onboarding/session.ts
4622
+ import path18 from "path";
4305
4623
  function normalizePackagePath2(packagePath) {
4306
4624
  if (!packagePath || packagePath === ".") return "";
4307
4625
  return packagePath.replace(/\\/g, "/").replace(/^\.\//, "").replace(/\/$/, "");
@@ -4325,7 +4643,7 @@ function getVerificationCommand(packageManager) {
4325
4643
  }
4326
4644
  }
4327
4645
  async function buildVerification(projectRoot, packageManager) {
4328
- const packageJson = await readJSON(path17.join(projectRoot, "package.json"));
4646
+ const packageJson = await readJSON(path18.join(projectRoot, "package.json"));
4329
4647
  if (packageJson?.scripts?.dev) {
4330
4648
  const devCommand = getVerificationCommand(packageManager);
4331
4649
  return {
@@ -4383,7 +4701,7 @@ async function detectFrameworkSupportByPackage2(repoRoot, context) {
4383
4701
  await Promise.all(
4384
4702
  Array.from(packagePaths).map(async (packagePath) => {
4385
4703
  const frameworkResult = await detectFrameworks(
4386
- packagePath ? path17.join(repoRoot, packagePath) : repoRoot
4704
+ packagePath ? path18.join(repoRoot, packagePath) : repoRoot
4387
4705
  );
4388
4706
  supportByPackage[packagePath] = frameworkResult.supported;
4389
4707
  })
@@ -4392,7 +4710,7 @@ async function detectFrameworkSupportByPackage2(repoRoot, context) {
4392
4710
  }
4393
4711
  async function buildTargetedContext(rootContext, target) {
4394
4712
  const packagePath = normalizePackagePath2(target.packagePath);
4395
- const projectRoot = packagePath ? path17.join(rootContext.root, packagePath) : rootContext.root;
4713
+ const projectRoot = packagePath ? path18.join(rootContext.root, packagePath) : rootContext.root;
4396
4714
  const [frameworks, ides, providers] = await Promise.all([
4397
4715
  detectFrameworks(projectRoot),
4398
4716
  detectIDE(projectRoot),
@@ -4467,7 +4785,21 @@ function buildConfirmation(plan2, summary, session, options) {
4467
4785
  question: "Proceed with Inspecto onboarding using the proposed default target and settings?"
4468
4786
  };
4469
4787
  }
4470
- function buildPreApplyResult(status, session) {
4788
+ async function buildDailyUsageHandoff(projectRoot) {
4789
+ const localSettings = await readJSON(path18.join(projectRoot, ".inspecto", "settings.local.json")) ?? {};
4790
+ const sharedSettings = await readJSON(path18.join(projectRoot, ".inspecto", "settings.json")) ?? {};
4791
+ const annotateDeliveryMode = localSettings["annotate.deliveryMode"] ?? sharedSettings["annotate.deliveryMode"];
4792
+ if (annotateDeliveryMode !== "agent") {
4793
+ return void 0;
4794
+ }
4795
+ return {
4796
+ mode: "agent",
4797
+ skill: "inspecto-agent",
4798
+ prompt: "Use $inspecto-agent to claim Inspecto tasks continuously",
4799
+ requiresMcp: true
4800
+ };
4801
+ }
4802
+ function buildPreApplyResult(status, session, dailyUsage) {
4471
4803
  const diagnostics = session.summary.risks.length > 0 || session.summary.manualFollowUp.length > 0 || session.plan.blockers.length > 0 ? {
4472
4804
  warnings: session.summary.risks,
4473
4805
  errors: session.plan.blockers.map((item) => item.message),
@@ -4493,6 +4825,7 @@ function buildPreApplyResult(status, session) {
4493
4825
  ...session.pendingSteps ? { pendingSteps: session.pendingSteps } : {},
4494
4826
  ...session.assistantPrompt ? { assistantPrompt: session.assistantPrompt } : {},
4495
4827
  ...session.patches ? { patches: session.patches } : {},
4828
+ ...dailyUsage ? { dailyUsage } : {},
4496
4829
  ...diagnostics ? { diagnostics } : {}
4497
4830
  };
4498
4831
  }
@@ -4533,6 +4866,7 @@ function buildExecutionDiagnostics(session, applyResult) {
4533
4866
  async function resolveOnboardingSession(root, options = {}) {
4534
4867
  const rootContext = await buildOnboardingContext(root);
4535
4868
  const rootVerification = await buildVerification(root, rootContext.packageManager);
4869
+ const rootDailyUsage = await buildDailyUsageHandoff(root);
4536
4870
  const frameworkSupportByPackage = await detectFrameworkSupportByPackage2(root, rootContext);
4537
4871
  const target = resolveOnboardingTarget({
4538
4872
  repoRoot: root,
@@ -4566,7 +4900,8 @@ async function resolveOnboardingSession(root, options = {}) {
4566
4900
  ...plan3.autoApplied ? { autoApplied: plan3.autoApplied } : {},
4567
4901
  ...plan3.pendingSteps ? { pendingSteps: plan3.pendingSteps } : {},
4568
4902
  ...plan3.assistantPrompt ? { assistantPrompt: plan3.assistantPrompt } : {},
4569
- ...plan3.patches ? { patches: plan3.patches } : {}
4903
+ ...plan3.patches ? { patches: plan3.patches } : {},
4904
+ ...rootDailyUsage ? { dailyUsage: rootDailyUsage } : {}
4570
4905
  };
4571
4906
  }
4572
4907
  if (target.status === "needs_selection") {
@@ -4590,6 +4925,7 @@ async function resolveOnboardingSession(root, options = {}) {
4590
4925
  }
4591
4926
  const context = await buildTargetedContext(rootContext, target.selected);
4592
4927
  const verification = await buildVerification(context.root, context.packageManager);
4928
+ const dailyUsage = await buildDailyUsageHandoff(context.root);
4593
4929
  const plan2 = createPlanResult(context);
4594
4930
  const summary = buildOnboardingSummary(plan2, context.root);
4595
4931
  const confirmation = buildConfirmation(
@@ -4633,11 +4969,13 @@ async function resolveOnboardingSession(root, options = {}) {
4633
4969
  ...plan2.autoApplied ? { autoApplied: plan2.autoApplied } : {},
4634
4970
  ...plan2.pendingSteps ? { pendingSteps: plan2.pendingSteps } : {},
4635
4971
  ...plan2.assistantPrompt ? { assistantPrompt: plan2.assistantPrompt } : {},
4636
- ...plan2.patches ? { patches: plan2.patches } : {}
4972
+ ...plan2.patches ? { patches: plan2.patches } : {},
4973
+ ...dailyUsage ? { dailyUsage } : {}
4637
4974
  };
4638
4975
  }
4639
4976
  async function applyResolvedOnboardingSession(session, options = {}) {
4640
4977
  const verification = await buildVerification(session.projectRoot, session.context.packageManager);
4978
+ const dailyUsage = await buildDailyUsageHandoff(session.projectRoot);
4641
4979
  const applyResult = await applyOnboardingPlan({
4642
4980
  repoRoot: process.cwd(),
4643
4981
  projectRoot: session.projectRoot,
@@ -4678,11 +5016,16 @@ async function applyResolvedOnboardingSession(session, options = {}) {
4678
5016
  ...session.pendingSteps ? { pendingSteps: session.pendingSteps } : {},
4679
5017
  ...session.assistantPrompt ? { assistantPrompt: session.assistantPrompt } : {},
4680
5018
  ...session.patches ? { patches: session.patches } : {},
5019
+ ...dailyUsage ? { dailyUsage } : {},
4681
5020
  ...diagnostics ? { diagnostics } : {}
4682
5021
  };
4683
5022
  }
4684
- function buildDeferredOnboardResult(session) {
4685
- return buildPreApplyResult(session.status, session);
5023
+ async function buildDeferredOnboardResult(session) {
5024
+ return buildPreApplyResult(
5025
+ session.status,
5026
+ session,
5027
+ await buildDailyUsageHandoff(session.projectRoot)
5028
+ );
4686
5029
  }
4687
5030
 
4688
5031
  // src/commands/onboard.ts
@@ -4712,7 +5055,8 @@ function buildAssistantHandoff(result) {
4712
5055
  ...result.autoApplied ? { autoApplied: result.autoApplied } : {},
4713
5056
  ...result.pendingSteps ? { pendingSteps: result.pendingSteps } : {},
4714
5057
  ...result.assistantPrompt ? { assistantPrompt: result.assistantPrompt } : {},
4715
- ...result.patches ? { patches: result.patches } : {}
5058
+ ...result.patches ? { patches: result.patches } : {},
5059
+ ...result.dailyUsage ? { dailyUsage: result.dailyUsage } : {}
4716
5060
  };
4717
5061
  }
4718
5062
  function normalizeOnboardResult(result) {
@@ -4760,6 +5104,9 @@ function printOnboardResult(result) {
4760
5104
  if (normalized.handoff?.assistantPrompt) {
4761
5105
  log.hint(normalized.handoff.assistantPrompt);
4762
5106
  }
5107
+ if (normalized.handoff?.dailyUsage?.prompt) {
5108
+ log.hint(normalized.handoff.dailyUsage.prompt);
5109
+ }
4763
5110
  if (normalized.confirmation.required && normalized.confirmation.question) {
4764
5111
  log.warn(normalized.confirmation.question);
4765
5112
  }
@@ -4774,7 +5121,7 @@ async function onboard(options = {}) {
4774
5121
  const session = await resolveOnboardingSession(root, options);
4775
5122
  if (session.status === "error" || session.status === "needs_target_selection" || session.status === "needs_confirmation") {
4776
5123
  return writeCommandOutput(
4777
- normalizeOnboardResult(buildDeferredOnboardResult(session)),
5124
+ normalizeOnboardResult(await buildDeferredOnboardResult(session)),
4778
5125
  options.json ?? false,
4779
5126
  printOnboardResult
4780
5127
  );
@@ -4817,11 +5164,11 @@ async function plan(json = false) {
4817
5164
  }
4818
5165
 
4819
5166
  // src/commands/teardown.ts
4820
- import path18 from "path";
5167
+ import path19 from "path";
4821
5168
  async function teardown() {
4822
5169
  const root = process.cwd();
4823
5170
  log.header("Inspecto Teardown");
4824
- const lockPath = path18.join(root, ".inspecto", "install.lock");
5171
+ const lockPath = path19.join(root, ".inspecto", "install.lock");
4825
5172
  const lock = await readJSON(lockPath);
4826
5173
  if (!lock) {
4827
5174
  log.warn("No .inspecto/install.lock found. Running in best-effort mode.");
@@ -4834,8 +5181,8 @@ async function teardown() {
4834
5181
  } catch {
4835
5182
  log.warn("Could not remove @inspecto-dev/plugin (may not be installed)");
4836
5183
  }
4837
- if (await exists(path18.join(root, ".inspecto"))) {
4838
- await removeDir(path18.join(root, ".inspecto"));
5184
+ if (await exists(path19.join(root, ".inspecto"))) {
5185
+ await removeDir(path19.join(root, ".inspecto"));
4839
5186
  log.success("Deleted .inspecto/ directory");
4840
5187
  }
4841
5188
  await cleanGitignore(root);
@@ -4884,7 +5231,7 @@ async function teardown() {
4884
5231
  }
4885
5232
  }
4886
5233
  }
4887
- await removeDir(path18.join(root, ".inspecto"));
5234
+ await removeDir(path19.join(root, ".inspecto"));
4888
5235
  log.success("Deleted .inspecto/ directory");
4889
5236
  await cleanGitignore(root);
4890
5237
  log.blank();
@@ -4893,13 +5240,13 @@ async function teardown() {
4893
5240
  }
4894
5241
 
4895
5242
  // src/commands/integration-install.ts
4896
- import fs6 from "fs/promises";
5243
+ import fs7 from "fs/promises";
4897
5244
  import { homedir as homedir2 } from "os";
4898
- import path21 from "path";
5245
+ import path22 from "path";
4899
5246
  import { fileURLToPath } from "url";
4900
5247
 
4901
5248
  // src/commands/integration-host-ide.ts
4902
- import path19 from "path";
5249
+ import path20 from "path";
4903
5250
  async function resolveIntegrationHostIde(options = {}) {
4904
5251
  if (isSupportedHostIde(options.explicitIde)) {
4905
5252
  return {
@@ -4964,8 +5311,8 @@ async function resolveIntegrationHostIde(options = {}) {
4964
5311
  }
4965
5312
  async function resolveConfiguredIde(cwd) {
4966
5313
  const settingsPaths = [
4967
- path19.join(cwd, ".inspecto", "settings.local.json"),
4968
- path19.join(cwd, ".inspecto", "settings.json")
5314
+ path20.join(cwd, ".inspecto", "settings.local.json"),
5315
+ path20.join(cwd, ".inspecto", "settings.json")
4969
5316
  ];
4970
5317
  for (const settingsPath of settingsPaths) {
4971
5318
  const settings = await readJSON(settingsPath);
@@ -4996,7 +5343,14 @@ function detectEnvHostIdes() {
4996
5343
  return Array.from(detected);
4997
5344
  }
4998
5345
  async function detectArtifactHostIdes(cwd) {
4999
- const artifactOrder = ["cursor", "trae", "trae-cn", "codebuddy", "codebuddy-cn", "vscode"];
5346
+ const artifactOrder = [
5347
+ "cursor",
5348
+ "trae",
5349
+ "trae-cn",
5350
+ "codebuddy",
5351
+ "codebuddy-cn",
5352
+ "vscode"
5353
+ ];
5000
5354
  const candidates = artifactOrder.map((ide) => ({
5001
5355
  ide,
5002
5356
  target: getHostIdeArtifactPath(ide, cwd)
@@ -5009,7 +5363,7 @@ async function detectArtifactHostIdes(cwd) {
5009
5363
 
5010
5364
  // src/commands/integration-dispatch-mode.ts
5011
5365
  import { homedir } from "os";
5012
- import path20 from "path";
5366
+ import path21 from "path";
5013
5367
  async function resolveIntegrationDispatchMode(options) {
5014
5368
  const assistantRule = getDualModeAssistantCapability(options.assistant);
5015
5369
  const home = options.homeDir ?? homedir();
@@ -5052,7 +5406,7 @@ async function isIdeExtensionInstalled(extensionId, extensionsDir) {
5052
5406
  } catch {
5053
5407
  return false;
5054
5408
  }
5055
- const obsoletePath = path20.join(extensionsDir, ".obsolete");
5409
+ const obsoletePath = path21.join(extensionsDir, ".obsolete");
5056
5410
  let obsoleteFolders = /* @__PURE__ */ new Set();
5057
5411
  if (await exists(obsoletePath)) {
5058
5412
  const obsolete = await readJSON(obsoletePath);
@@ -5388,7 +5742,7 @@ async function runIntegrationAutomation(assistant, options = {}, cwd) {
5388
5742
  };
5389
5743
  }
5390
5744
  }
5391
- function shouldAutoSend(assistant, ide) {
5745
+ function shouldAutoSend(assistant, _ide) {
5392
5746
  if (assistant === "copilot") return true;
5393
5747
  if (assistant === "codex") return true;
5394
5748
  return false;
@@ -5516,7 +5870,7 @@ async function installIntegration(assistant, options = {}) {
5516
5870
  if (await exists(asset.target)) {
5517
5871
  if (options.force) {
5518
5872
  } else if (manifest.type === "context-template") {
5519
- const originalContent = await fs6.readFile(asset.target, "utf-8");
5873
+ const originalContent = await fs7.readFile(asset.target, "utf-8");
5520
5874
  existingFiles.set(asset.target, originalContent);
5521
5875
  if (!silent) {
5522
5876
  log.info(`File ${asset.target} already exists. Content will be appended safely.`);
@@ -5553,7 +5907,7 @@ ${content}`;
5553
5907
  for (const { asset, content } of downloadedAssets) {
5554
5908
  await writeFile(asset.target, content);
5555
5909
  if (asset.executable) {
5556
- await fs6.chmod(asset.target, 493);
5910
+ await fs7.chmod(asset.target, 493);
5557
5911
  }
5558
5912
  }
5559
5913
  }
@@ -5668,23 +6022,30 @@ async function resolveProviderDefaultForAssistant(assistant, ide) {
5668
6022
  return `${assistant}.${mode}`;
5669
6023
  }
5670
6024
  async function persistProjectOnboardingDefaults(assistant, options) {
5671
- const settingsPath = path21.join(process.cwd(), ".inspecto", "settings.local.json");
6025
+ const settingsPath = path22.join(process.cwd(), ".inspecto", "settings.local.json");
5672
6026
  const existingSettings = await readJSON(settingsPath);
5673
6027
  const resolvedHostIde = await resolveIntegrationHostIde({
5674
6028
  explicitIde: options.ide,
5675
6029
  cwd: process.cwd()
5676
6030
  });
5677
6031
  const providerDefault = resolvedHostIde.ide && resolvedHostIde.confidence !== "low" ? await resolveProviderDefaultForAssistant(assistant, resolvedHostIde.ide) : void 0;
6032
+ const annotateDeliveryMode = resolveAnnotateDefaultDeliveryForAssistant(assistant);
5678
6033
  const mergedSettings = existingSettings && typeof existingSettings === "object" ? {
5679
6034
  ...existingSettings,
5680
6035
  ide: options.ide,
5681
- ...providerDefault ? { "provider.default": providerDefault } : {}
6036
+ ...providerDefault ? { "provider.default": providerDefault } : {},
6037
+ "annotate.deliveryMode": annotateDeliveryMode
5682
6038
  } : {
5683
6039
  ide: options.ide,
5684
- ...providerDefault ? { "provider.default": providerDefault } : {}
6040
+ ...providerDefault ? { "provider.default": providerDefault } : {},
6041
+ "annotate.deliveryMode": annotateDeliveryMode
5685
6042
  };
5686
6043
  await writeJSON(settingsPath, mergedSettings);
5687
6044
  }
6045
+ function resolveAnnotateDefaultDeliveryForAssistant(assistant) {
6046
+ void assistant;
6047
+ return "both";
6048
+ }
5688
6049
  function shouldSkipAutomationForInstall(options) {
5689
6050
  return options.scope === "user" && !options.preview;
5690
6051
  }
@@ -5835,28 +6196,39 @@ function resolveCodexPlan(options) {
5835
6196
  if (options.mode !== void 0) {
5836
6197
  throw new Error("`--mode` is not supported for codex.");
5837
6198
  }
5838
- const baseDir = scope === "user" ? path21.join(homedir2(), ".agents/skills/inspecto-onboarding-codex") : ".agents/skills/inspecto-onboarding-codex";
6199
+ const baseDir = scope === "user" ? path22.join(homedir2(), ".agents/skills/inspecto-onboarding-codex") : ".agents/skills/inspecto-onboarding-codex";
6200
+ const agentDir = scope === "user" ? path22.join(homedir2(), ".agents/skills/inspecto-agent-codex") : ".agents/skills/inspecto-agent-codex";
5839
6201
  return {
5840
6202
  assets: [
5841
6203
  {
5842
6204
  source: `${REPO_RAW_BASE}/skills/inspecto-onboarding-codex/SKILL.md`,
5843
- target: path21.join(baseDir, "SKILL.md"),
6205
+ target: path22.join(baseDir, "SKILL.md"),
5844
6206
  localSource: "skills/inspecto-onboarding-codex/SKILL.md"
5845
6207
  },
5846
6208
  {
5847
6209
  source: `${REPO_RAW_BASE}/skills/inspecto-onboarding-codex/agents/openai.yaml`,
5848
- target: path21.join(baseDir, "agents/openai.yaml"),
6210
+ target: path22.join(baseDir, "agents/openai.yaml"),
5849
6211
  localSource: "skills/inspecto-onboarding-codex/agents/openai.yaml"
5850
6212
  },
5851
6213
  {
5852
6214
  source: `${REPO_RAW_BASE}/skills/inspecto-onboarding-codex/scripts/run-inspecto.sh`,
5853
- target: path21.join(baseDir, "scripts/run-inspecto.sh"),
6215
+ target: path22.join(baseDir, "scripts/run-inspecto.sh"),
5854
6216
  executable: true,
5855
6217
  localSource: "skills/inspecto-onboarding-codex/scripts/run-inspecto.sh"
6218
+ },
6219
+ {
6220
+ source: `${REPO_RAW_BASE}/skills/inspecto-agent-codex/SKILL.md`,
6221
+ target: path22.join(agentDir, "SKILL.md"),
6222
+ localSource: "skills/inspecto-agent-codex/SKILL.md"
6223
+ },
6224
+ {
6225
+ source: `${REPO_RAW_BASE}/skills/inspecto-agent-codex/agents/openai.yaml`,
6226
+ target: path22.join(agentDir, "agents/openai.yaml"),
6227
+ localSource: "skills/inspecto-agent-codex/agents/openai.yaml"
5856
6228
  }
5857
6229
  ],
5858
- successMessage: `Installed Codex skill to ${baseDir}`,
5859
- nextStep: "Restart Codex or start a new Codex session to load the skill."
6230
+ successMessage: `Installed Codex skills to ${baseDir} and ${agentDir}`,
6231
+ nextStep: "Restart Codex or start a new Codex session to load the new skills."
5860
6232
  };
5861
6233
  }
5862
6234
  function resolveClaudeCodePlan(options) {
@@ -5870,22 +6242,22 @@ function resolveClaudeCodePlan(options) {
5870
6242
  if (scope !== "project" && scope !== "user") {
5871
6243
  throw new Error(`Unknown Claude Code scope: ${scope}`);
5872
6244
  }
5873
- const baseDir = scope === "user" ? path21.join(homedir2(), ".claude/skills/inspecto-onboarding-claude-code") : ".claude/skills/inspecto-onboarding-claude-code";
6245
+ const baseDir = scope === "user" ? path22.join(homedir2(), ".claude/skills/inspecto-onboarding-claude-code") : ".claude/skills/inspecto-onboarding-claude-code";
5874
6246
  return {
5875
6247
  assets: [
5876
6248
  {
5877
6249
  source: `${REPO_RAW_BASE}/skills/inspecto-onboarding-claude-code/SKILL.md`,
5878
- target: path21.join(baseDir, "SKILL.md"),
6250
+ target: path22.join(baseDir, "SKILL.md"),
5879
6251
  localSource: "skills/inspecto-onboarding-claude-code/SKILL.md"
5880
6252
  },
5881
6253
  {
5882
6254
  source: `${REPO_RAW_BASE}/skills/inspecto-onboarding-claude-code/agents/openai.yaml`,
5883
- target: path21.join(baseDir, "agents/openai.yaml"),
6255
+ target: path22.join(baseDir, "agents/openai.yaml"),
5884
6256
  localSource: "skills/inspecto-onboarding-claude-code/agents/openai.yaml"
5885
6257
  },
5886
6258
  {
5887
6259
  source: `${REPO_RAW_BASE}/skills/inspecto-onboarding-claude-code/scripts/run-inspecto.sh`,
5888
- target: path21.join(baseDir, "scripts/run-inspecto.sh"),
6260
+ target: path22.join(baseDir, "scripts/run-inspecto.sh"),
5889
6261
  executable: true,
5890
6262
  localSource: "skills/inspecto-onboarding-claude-code/scripts/run-inspecto.sh"
5891
6263
  }
@@ -5950,20 +6322,20 @@ async function loadAsset(asset) {
5950
6322
  if (asset.localSource) {
5951
6323
  const localPath = await resolveBundledAssetPath(asset.localSource);
5952
6324
  if (localPath) {
5953
- return await fs6.readFile(localPath, "utf-8");
6325
+ return await fs7.readFile(localPath, "utf-8");
5954
6326
  }
5955
6327
  }
5956
6328
  return await downloadAsset(asset.source);
5957
6329
  }
5958
6330
  async function resolveBundledAssetPath(relativePath) {
5959
- const startDir = path21.dirname(fileURLToPath(import.meta.url));
6331
+ const startDir = path22.dirname(fileURLToPath(import.meta.url));
5960
6332
  let currentDir = startDir;
5961
6333
  for (let depth = 0; depth < 8; depth += 1) {
5962
- const candidate = path21.join(currentDir, relativePath);
6334
+ const candidate = path22.join(currentDir, relativePath);
5963
6335
  if (await exists(candidate)) {
5964
6336
  return candidate;
5965
6337
  }
5966
- const parent = path21.dirname(currentDir);
6338
+ const parent = path22.dirname(currentDir);
5967
6339
  if (parent === currentDir) break;
5968
6340
  currentDir = parent;
5969
6341
  }
@@ -6077,6 +6449,10 @@ export {
6077
6449
  init,
6078
6450
  collectDoctorResult,
6079
6451
  doctor,
6452
+ startMcpServer,
6453
+ createInspectoMcpServer,
6454
+ createInspectoMcpRuntime,
6455
+ resolveInspectoServerBaseUrl,
6080
6456
  onboard,
6081
6457
  plan,
6082
6458
  teardown,