openuispec 0.1.37 → 0.1.38

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 (3) hide show
  1. package/README.md +3 -2
  2. package/cli/init.ts +60 -22
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -52,7 +52,7 @@ cd your-project
52
52
  openuispec init
53
53
  ```
54
54
 
55
- This scaffolds a spec directory, starter tokens, adds rules to `CLAUDE.md` / `AGENTS.md`, and configures the MCP server in `.claude.json` so AI assistants track spec changes automatically.
55
+ This scaffolds a spec directory, starter tokens, adds rules to `CLAUDE.md` / `AGENTS.md`, and configures the MCP server so AI assistants track spec changes automatically.
56
56
  Use `openuispec init --no-configure-targets` if you want to scaffold first and choose target stacks later.
57
57
 
58
58
  Then hand your spec to any AI code generator:
@@ -251,8 +251,9 @@ OpenUISpec includes an MCP (Model Context Protocol) server that exposes CLI comm
251
251
 
252
252
  ### Setup
253
253
 
254
- `openuispec init` automatically configures the MCP server in `.claude.json`. For existing projects, add it manually:
254
+ `openuispec init` automatically configures the MCP server for your coding agent. For existing projects, run `openuispec update-rules` or add the config manually:
255
255
 
256
+ **Claude Code** (`.mcp.json`), **VS Code / Copilot** (`.vscode/mcp.json`):
256
257
  ```json
257
258
  {
258
259
  "mcpServers": {
package/cli/init.ts CHANGED
@@ -14,6 +14,7 @@ import {
14
14
  readdirSync,
15
15
  existsSync,
16
16
  appendFileSync,
17
+ unlinkSync,
17
18
  } from "node:fs";
18
19
  import { join, relative, dirname, resolve } from "node:path";
19
20
  import { fileURLToPath } from "node:url";
@@ -263,7 +264,7 @@ Do NOT guess the file format — skipping this step will produce invalid YAML th
263
264
 
264
265
  ## MCP Tools (recommended for AI assistants)
265
266
 
266
- When the openuispec MCP server is configured (see \`.claude.json\`), AI assistants should use these tools instead of CLI commands:
267
+ When the openuispec MCP server is configured, AI assistants should use these tools instead of CLI commands:
267
268
 
268
269
  | Tool | When to use |
269
270
  |------|-------------|
@@ -481,35 +482,72 @@ const EXPECTED_MCP_CONFIG = {
481
482
  args: ["mcp"],
482
483
  };
483
484
 
485
+ /**
486
+ * MCP config files by agent:
487
+ * .mcp.json — Claude Code (project scope)
488
+ * .vscode/mcp.json — VS Code / Copilot Chat
489
+ *
490
+ * All use the same { mcpServers: { openuispec: { command, args } } } shape.
491
+ */
492
+ const MCP_CONFIG_PATHS = [
493
+ ".mcp.json",
494
+ join(".vscode", "mcp.json"),
495
+ ];
496
+
484
497
  function configureMcp(cwd: string, showRestart: boolean, quiet: boolean = false): void {
485
- const claudeJsonPath = join(cwd, ".claude.json");
498
+ for (const relPath of MCP_CONFIG_PATHS) {
499
+ const configPath = join(cwd, relPath);
500
+
501
+ // .vscode/mcp.json: only write if .vscode/ already exists
502
+ if (relPath.startsWith(".vscode") && !existsSync(join(cwd, ".vscode"))) continue;
486
503
 
487
- try {
488
- let claudeJson: Record<string, any> = {};
489
504
  try {
490
- claudeJson = JSON.parse(readFileSync(claudeJsonPath, "utf-8"));
505
+ let config: Record<string, any> = {};
506
+ try {
507
+ config = JSON.parse(readFileSync(configPath, "utf-8"));
508
+ } catch {
509
+ // file doesn't exist or isn't valid JSON — start fresh
510
+ }
511
+
512
+ if (!config.mcpServers) config.mcpServers = {};
513
+
514
+ const existing = config.mcpServers.openuispec;
515
+ const needsUpdate =
516
+ !existing ||
517
+ existing.command !== EXPECTED_MCP_CONFIG.command ||
518
+ JSON.stringify(existing.args) !== JSON.stringify(EXPECTED_MCP_CONFIG.args);
519
+
520
+ if (needsUpdate) {
521
+ config.mcpServers.openuispec = { ...EXPECTED_MCP_CONFIG };
522
+ writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n");
523
+ if (!quiet) console.log(` ${existing ? "update" : "create"} ${relPath} (MCP server configured)`);
524
+ } else {
525
+ if (!quiet) console.log(` skip ${relPath} (openuispec MCP already configured)`);
526
+ }
491
527
  } catch {
492
- // file doesn't exist or isn't valid JSON — start fresh
528
+ if (!quiet) console.log(` skip ${relPath} (could not configure MCP server)`);
493
529
  }
530
+ }
494
531
 
495
- if (!claudeJson.mcpServers) claudeJson.mcpServers = {};
496
-
497
- const existing = claudeJson.mcpServers.openuispec;
498
- const needsUpdate =
499
- !existing ||
500
- existing.command !== EXPECTED_MCP_CONFIG.command ||
501
- JSON.stringify(existing.args) !== JSON.stringify(EXPECTED_MCP_CONFIG.args);
532
+ if (showRestart) console.log(`\n Restart your AI coding agent to activate the MCP server.`);
502
533
 
503
- if (needsUpdate) {
504
- claudeJson.mcpServers.openuispec = { ...EXPECTED_MCP_CONFIG };
505
- writeFileSync(claudeJsonPath, JSON.stringify(claudeJson, null, 2) + "\n");
506
- if (!quiet) console.log(` ${existing ? "update" : "create"} .claude.json (MCP server configured)`);
507
- if (showRestart) console.log(`\n Restart Claude Code to activate the MCP server.`);
508
- } else {
509
- if (!quiet) console.log(` skip .claude.json (openuispec MCP already configured)`);
534
+ // Clean up stale .claude.json MCP config from older versions
535
+ const claudeJsonPath = join(cwd, ".claude.json");
536
+ try {
537
+ const claudeJson = JSON.parse(readFileSync(claudeJsonPath, "utf-8"));
538
+ if (claudeJson.mcpServers?.openuispec) {
539
+ delete claudeJson.mcpServers.openuispec;
540
+ if (Object.keys(claudeJson.mcpServers).length === 0) delete claudeJson.mcpServers;
541
+ if (Object.keys(claudeJson).length === 0) {
542
+ unlinkSync(claudeJsonPath);
543
+ if (!quiet) console.log(` remove .claude.json (migrated MCP config)`);
544
+ } else {
545
+ writeFileSync(claudeJsonPath, JSON.stringify(claudeJson, null, 2) + "\n");
546
+ if (!quiet) console.log(` update .claude.json (removed stale MCP config)`);
547
+ }
510
548
  }
511
549
  } catch {
512
- if (!quiet) console.log(` skip .claude.json (could not configure MCP server)`);
550
+ // .claude.json doesn't exist or not parseable nothing to clean up
513
551
  }
514
552
  }
515
553
 
@@ -825,7 +863,7 @@ Commands:
825
863
  openuispec drift --snapshot --target ios Save current state + git baseline after target output exists
826
864
 
827
865
  AI rules have been added to CLAUDE.md and AGENTS.md.
828
- MCP server configured in .claude.json (AI assistants will use openuispec tools automatically).
866
+ MCP server configured (AI assistants will use openuispec tools automatically).
829
867
 
830
868
  Docs: https://openuispec.rsteam.uz
831
869
  `);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openuispec",
3
- "version": "0.1.37",
3
+ "version": "0.1.38",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "A semantic UI specification format for AI-native, platform-native app development",