iranti 0.2.43 → 0.2.45

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.
@@ -75,11 +75,11 @@ function printHelp() {
75
75
  'Notes:',
76
76
  ' - Registers a global Codex MCP entry using `codex mcp add`.',
77
77
  ' - Prefers the installed CLI path: `iranti mcp`.',
78
- ' - When a project binding is available, also writes or merges a project-local `.mcp.json` entry pinned to that binding.',
78
+ ' - When a project binding is available, also writes or merges project-local `.mcp.json` and `.vscode/mcp.json` entries pinned to that binding.',
79
79
  ' - By default does not pin IRANTI_PROJECT_ENV, so Codex can resolve .env.iranti from the active project/workspace at runtime.',
80
80
  ' - Use --project-env only when you deliberately want to pin Codex globally to one project binding.',
81
81
  ' - Use --local-script only if you need to point Codex at this repo build directly.',
82
- ' - Use --no-workspace-file only if you explicitly want global registration without a project-local `.mcp.json` update.',
82
+ ' - Use --no-workspace-file only if you explicitly want global registration without project-local MCP file updates.',
83
83
  ' - Does not store DATABASE_URL in Codex config; iranti-mcp loads project/instance env at runtime.',
84
84
  ' - Replaces any existing MCP entry with the same name.',
85
85
  ].join('\n'));
@@ -173,6 +173,29 @@ function makeWorkspaceMcpServer(options, projectEnv) {
173
173
  env,
174
174
  };
175
175
  }
176
+ function makeVsCodeWorkspaceMcpServer(options, projectEnv) {
177
+ const projectPath = node_path_1.default.dirname(projectEnv);
178
+ const env = {
179
+ IRANTI_MCP_DEFAULT_AGENT: options.agent,
180
+ IRANTI_MCP_DEFAULT_SOURCE: options.source,
181
+ };
182
+ if (options.provider) {
183
+ env.LLM_PROVIDER = options.provider;
184
+ }
185
+ const localBinding = node_path_1.default.join(projectPath, '.env.iranti');
186
+ if (node_path_1.default.resolve(projectEnv) !== node_path_1.default.resolve(localBinding)) {
187
+ env.IRANTI_PROJECT_ENV = projectEnv;
188
+ }
189
+ return {
190
+ type: 'stdio',
191
+ command: 'iranti',
192
+ args: ['mcp'],
193
+ ...(node_path_1.default.resolve(projectEnv) === node_path_1.default.resolve(localBinding)
194
+ ? { envFile: '${workspaceFolder}/.env.iranti' }
195
+ : {}),
196
+ env,
197
+ };
198
+ }
176
199
  function writeWorkspaceMcpFile(projectEnv, options) {
177
200
  const projectPath = node_path_1.default.dirname(projectEnv);
178
201
  const mcpFile = node_path_1.default.join(projectPath, '.mcp.json');
@@ -211,6 +234,46 @@ function writeWorkspaceMcpFile(projectEnv, options) {
211
234
  }, null, 2)}\n`, 'utf8');
212
235
  return { filePath: mcpFile, status: 'updated' };
213
236
  }
237
+ function writeWorkspaceVsCodeMcpFile(projectEnv, options) {
238
+ const projectPath = node_path_1.default.dirname(projectEnv);
239
+ const vscodeDir = node_path_1.default.join(projectPath, '.vscode');
240
+ const mcpFile = node_path_1.default.join(vscodeDir, 'mcp.json');
241
+ const nextServer = makeVsCodeWorkspaceMcpServer(options, projectEnv);
242
+ node_fs_1.default.mkdirSync(vscodeDir, { recursive: true });
243
+ if (!node_fs_1.default.existsSync(mcpFile)) {
244
+ node_fs_1.default.writeFileSync(mcpFile, `${JSON.stringify({
245
+ servers: {
246
+ iranti: nextServer,
247
+ },
248
+ }, null, 2)}\n`, 'utf8');
249
+ return { filePath: mcpFile, status: 'created' };
250
+ }
251
+ let existing;
252
+ try {
253
+ existing = JSON.parse(node_fs_1.default.readFileSync(mcpFile, 'utf8'));
254
+ }
255
+ catch {
256
+ throw new Error(`Existing .vscode/mcp.json is not valid JSON: ${mcpFile}`);
257
+ }
258
+ if (!existing || typeof existing !== 'object' || Array.isArray(existing)) {
259
+ throw new Error(`Existing .vscode/mcp.json must contain a JSON object: ${mcpFile}`);
260
+ }
261
+ const existingServers = existing.servers && typeof existing.servers === 'object' && !Array.isArray(existing.servers)
262
+ ? existing.servers
263
+ : {};
264
+ const currentIranti = existingServers.iranti;
265
+ if (JSON.stringify(currentIranti) === JSON.stringify(nextServer)) {
266
+ return { filePath: mcpFile, status: 'unchanged' };
267
+ }
268
+ node_fs_1.default.writeFileSync(mcpFile, `${JSON.stringify({
269
+ ...existing,
270
+ servers: {
271
+ ...existingServers,
272
+ iranti: nextServer,
273
+ },
274
+ }, null, 2)}\n`, 'utf8');
275
+ return { filePath: mcpFile, status: 'updated' };
276
+ }
214
277
  function canUseInstalledIranti(repoRoot) {
215
278
  try {
216
279
  run('iranti', ['mcp', '--help'], repoRoot);
@@ -267,8 +330,11 @@ function main() {
267
330
  const workspaceProjectEnv = options.writeWorkspaceFile
268
331
  ? resolveWorkspaceProjectEnv(options)
269
332
  : undefined;
270
- const workspaceMcpResult = workspaceProjectEnv
271
- ? writeWorkspaceMcpFile(workspaceProjectEnv, options)
333
+ const workspaceFilesResult = workspaceProjectEnv
334
+ ? {
335
+ mcp: writeWorkspaceMcpFile(workspaceProjectEnv, options),
336
+ vscode: writeWorkspaceVsCodeMcpFile(workspaceProjectEnv, options),
337
+ }
272
338
  : null;
273
339
  const registered = run('codex', ['mcp', 'get', options.name], repoRoot);
274
340
  console.log(registered);
@@ -296,11 +362,12 @@ function main() {
296
362
  console.log(`Launch with: codex -C "${repoRoot}"`);
297
363
  }
298
364
  if (options.writeWorkspaceFile) {
299
- if (workspaceMcpResult) {
300
- console.log(`Workspace .mcp.json: ${workspaceMcpResult.status} (${workspaceMcpResult.filePath})`);
365
+ if (workspaceFilesResult) {
366
+ console.log(`Workspace .mcp.json: ${workspaceFilesResult.mcp.status} (${workspaceFilesResult.mcp.filePath})`);
367
+ console.log(`Workspace .vscode/mcp.json: ${workspaceFilesResult.vscode.status} (${workspaceFilesResult.vscode.filePath})`);
301
368
  }
302
369
  else {
303
- console.log('Workspace .mcp.json: unchanged (no project binding found from the current working directory)');
370
+ console.log('Workspace MCP files: unchanged (no project binding found from the current working directory)');
304
371
  }
305
372
  }
306
373
  }