Turn complex codebases into clear, navigable architecture diagrams with Claude Code.
TypeScript aiarchitectureclaude-codeclaude-code-skillclicodebase-visualizationdeveloper-toolsdiagramsdocumentationmermaid
feat: transition to plugin architecture with multi-platform omm setup (#1)
김승진fb385ddad9f3
diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.jsonnew file mode 100644index 0000000..1c91769--- /dev/null+++ b/.claude-plugin/marketplace.json@@ -0,0 +1,16 @@+{+ "name": "oh-my-mermaid",+ "owner": {+ "name": "oh-my-mermaid"+ },+ "plugins": [+ {+ "name": "oh-my-mermaid",+ "description": "Turn complex codebases into clear, navigable architecture diagrams with Mermaid",+ "version": "0.1.3",+ "source": "./",+ "category": "development",+ "homepage": "https://github.com/oh-my-mermaid/oh-my-mermaid"+ }+ ]+}diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.jsonnew file mode 100644index 0000000..2572d22--- /dev/null+++ b/.claude-plugin/plugin.json@@ -0,0 +1,17 @@+{+ "name": "oh-my-mermaid",+ "description": "Turn complex codebases into clear, navigable architecture diagrams",+ "version": "0.1.3",+ "author": {+ "name": "oh-my-mermaid"+ },+ "homepage": "https://github.com/oh-my-mermaid/oh-my-mermaid",+ "repository": "https://github.com/oh-my-mermaid/oh-my-mermaid",+ "license": "MIT",+ "keywords": [+ "architecture",+ "mermaid",+ "diagrams",+ "codebase-visualization"+ ]+}diff --git a/.claude/skills/omm-push/SKILL.md b/.claude/skills/omm-push/SKILL.mddeleted file mode 100644index 5e5235d..0000000--- a/.claude/skills/omm-push/SKILL.md+++ /dev/null@@ -1,52 +0,0 @@-----name: omm-push-description: Push architecture docs to oh-my-mermaid cloud. Handles login, link, and push workflow with error guidance. Use when the user says "omm push", "push to cloud", "deploy architecture", or "share architecture".------# omm-push — Cloud Push Workflow--## Purpose--Automate the full workflow of pushing .omm/ architecture docs to the oh-my-mermaid cloud service.--## Prerequisites--The `omm` CLI must be installed (`npm install -g oh-my-mermaid`).--## Workflow--### Step 1: Check Login Status--Run `omm share` via Bash. If it errors with "not logged in":-- Tell the user: "You need to log in first."-- Run `omm login` — this opens a browser for GitHub OAuth-- Wait for the user to complete login--### Step 2: Check Project Link--Run `omm share` via Bash. If it errors with "no project slug":-- Run `omm link` — this sets the cloud project slug from the directory name-- Confirm: "Linked to {slug}"--### Step 3: Push--Run `omm push` via Bash.--Handle errors:-- **401 Unauthorized**: "Login expired. Run `omm login` again."-- **403 Free plan limit**: "Free plan allows 1 project. Upgrade at https://ohmymermaid.com/pricing"-- **Network error**: "Cannot reach server. Check your connection."--### Step 4: Report--On success, output:-- Number of files uploaded-- View URL: `https://ohmymermaid.com/p/{slug}`-- Share URL (if Pro): "Run `omm share` to get the shareable link"--## Rules--- Always check login before pushing-- Always check link before pushing-- Do NOT skip steps — each depends on the previous-- If any step fails, stop and report the error with guidancediff --git a/.claude/skills/omm-scan/SKILL.md b/.claude/skills/omm-scan/SKILL.mddeleted file mode 100644index c65d23e..0000000--- a/.claude/skills/omm-scan/SKILL.md+++ /dev/null@@ -1,271 +0,0 @@-----name: omm-scan-description: Scan codebase architecture and generate/update .omm/ documentation. Without arguments does a full scan; with arguments focuses on a specific topic and auto-links to parent diagrams. Use when the user says "omm scan", "scan architecture", "update architecture", "refresh diagrams", "omm scan auth flow", "analyze the payment module", or "dive into auth".-argument-hint: "[topic]"------# omm-scan — Architecture Scanner (Full + Focused)--## Purpose--Analyze the codebase and generate/update `.omm/` architecture documentation using the `omm` CLI.-Operates in two modes based on whether arguments are provided.--## Prerequisites--The `omm` CLI must be installed (`npm install -g oh-my-mermaid` or available via npx).--## Mode Detection--- **No arguments** (`/omm-scan`): Full scan mode — analyze entire codebase-- **With arguments** (`/omm-scan auth flow`): Focused mode — analyze specific topic only-------## A. Full Scan Mode (no arguments)--### Step 1: Initialize--If `.omm/` does not exist, run `omm init` first.--```bash-omm init-```--### Step 2: Check Existing State--```bash-omm list-```--For each existing class, read current content:-```bash-omm <class> description-omm <class> diagram-```--### Step 3: Explore the Codebase--Use Glob and Read to understand the project:-- Read `package.json`, `tsconfig.json`, or equivalent config files-- List top-level directories to identify module boundaries-- Read key entry points (main, index, app files)-- Look for route definitions, service layers, database connections--### Step 4: Generate/Update Classes--**First run (no existing classes):** Create classes based on what a person new to this codebase most needs to understand. Always start with `overall-architecture`, then add perspectives from this list based on what exists in the code:--| Class name | When to create | What it answers |-|---|---|---|-| `overall-architecture` | Always | What exists and how pieces relate |-| `request-lifecycle` | Any server/API | How a request enters and gets handled end-to-end |-| `data-flow` | Any data processing | Where data comes from, transforms, and lands |-| `auth-flow` | Any auth/session logic | How identity is established and propagated |-| `dependency-map` | Complex module graph | What depends on what, what's shared |-| `state-transitions` | Stateful features | How state changes and what triggers it |-| `external-integrations` | External APIs/services | What the system connects to and why |--Only create a class if it meaningfully exists in the code. 3-5 classes is usually right; avoid forcing perspectives that don't exist.--**Subsequent runs:** Compare existing docs against current code, update only what changed.--For each class, call the CLI with **each field separately**:--```bash-omm <class> description - <<'EOF'-(1-2 sentences: what this diagram shows AND who should read it)-- e.g., "Shows how an HTTP request flows from entry point to response. Start here if you want to understand how the API handles a request."-EOF--omm <class> diagram - <<'MERMAID'-graph LR- (Accurate mermaid diagram based on actual code)-MERMAID--omm <class> context - <<'EOF'-(The most important field for human understanding: WHY this architecture exists)-- Key decisions made and why (e.g., "Chose event-driven over direct calls to decouple billing from orders")-- Constraints that shaped the design (e.g., "Must support offline mode — hence local-first storage")-- Alternatives considered and rejected-- Historical reasons if relevant-EOF--omm <class> constraint - <<'EOF'-(Rules that MUST be followed when changing this area)-- e.g., "API layer must never import from repository directly — always go through service"-EOF--omm <class> concern - <<'EOF'-(Risks, technical debt, known issues a reader should be aware of)-- e.g., "Auth service is a single point of failure — no fallback if it's down"-EOF--omm <class> todo - <<'EOF'-(Concrete next steps or planned improvements)-- e.g., "Add caching layer between service and repository"-EOF--omm <class> note - <<'EOF'-(Anything else a new reader would want to know that doesn't fit above)-EOF-```--### Step 5: Cross-References--Use `@class-name` convention for nodes that represent another class. For `@ref` nodes, do NOT add a path as the second line — instead, use a plain concept label:--```mermaid-graph LR- client["Browser Client\nsrc/client/"]- client -->|"HTTP request"| @api-layer["API Layer"]- client -->|"authenticate"| @auth-flow["Auth Service"]-```--The `@` prefix tells the viewer this node is a drill-down into another class. Adding a file path would be misleading since it represents a whole sub-diagram, not a single file.--### Step 6: Summarize--Report what was created/updated and suggest `omm serve` to view.-------## B. Focused Mode (with arguments)--### Step 1: Parse Topic--Convert `$ARGUMENTS` to a kebab-case class name:-- "auth flow" → `auth-flow`-- "payment service" → `payment-service`-- "database schema" → `database-schema`--### Step 2: Deep Analysis--Focus Glob and Read on code related to the topic:-- Search for files matching the topic (e.g., `*auth*`, `*payment*`)-- Trace imports and dependencies from those files-- Understand the full flow for this specific concern--### Step 3: Create/Update Class--Generate all fields via CLI (same as full scan, but for this one class only).--### Step 4: Auto-Link to Parent--This is the key differentiator from full scan:--1. Run `omm list` to get existing classes-2. For each existing class, run `omm <class> diagram` to read its diagram-3. Check if the new class is already referenced as `@new-class`-4. If NOT referenced, find the logical parent (usually `overall-architecture`) and update its diagram to include `@new-class[Label]` node--Example: After creating `auth-flow`, update `overall-architecture`:-```bash-# Read current parent diagram-omm overall-architecture diagram-# Add @auth-flow reference and rewrite-omm overall-architecture diagram - <<'MERMAID'-graph LR- Client --> @auth-flow[Auth Service]- ...existing nodes...-MERMAID-```--### Step 5: Verify and Summarize--```bash-omm refs <new-class>-```--Report: "auth-flow created, @auth-flow added to overall-architecture"-------### Nested Architecture Analysis--When analyzing the codebase, identify sub-systems that are complex enough to warrant their own diagram (5+ nodes). Create separate classes for these and reference them with `@class-name` in the parent diagram.--**When to nest:**-- A module has 5+ internal components with their own relationships-- A subsystem has distinct layers or flows worth documenting separately-- A feature area (auth, billing, data pipeline) has its own internal architecture--**How to nest:**-1. Create a new class: `omm <child-class> diagram - <<'MERMAID'...MERMAID`-2. In the parent diagram, use `@child-class[Label]` as the node ID-3. Fill all 7 fields for the child class (description, constraint, concern, context, todo, note)--**Example:**-If `overall-architecture` has an auth subsystem with 8+ nodes:-- Create `auth-flow` class with its own detailed diagram-- In `overall-architecture` diagram: `Client --> @auth-flow[Auth Service]`-- The viewer will render `@auth-flow` as a clickable, expandable sub-group--### Edge Labels--Every edge MUST have a meaningful label. The label should answer **"why does this connection exist?"** — not just the protocol.--**Format:** `A -->|"label"| B`--**What to include in labels (priority order):**-1. The purpose/intent: what does this relationship accomplish?-2. What data/result flows: what is actually transferred?-3. Protocol/method only if it adds clarity (HTTP, IPC, Event, etc.)--**Good examples:**-```mermaid-Client -->|"login request (HTTP POST)"| AuthService-AuthService -->|"issue session token"| Client-AuthService -->|"verify user exists"| UserRepository-OrderService -->|"request payment authorization"| PaymentGateway-PaymentGateway -->|"authorization result callback"| OrderService-EventBus -->|"emit: order.completed"| NotificationService-```--**Bad examples (avoid):**-```mermaid-A --> B-Client --> Server-AuthService -->|"HTTP"| UserRepository-```--The test: if you remove the label, does the reader lose important understanding? If yes, the label is good. If the label is just a protocol name, it's probably not enough.--## Rules (Both Modes)--- Write all content (node labels, edge labels, field text) in **English by default**. If the user wrote in another language, match that language throughout.-- ONLY document what actually exists in the code. Do not invent or speculate.-- **Node labels must use two-line format**: concept name on the first line, file/directory path on the second line, separated by `\n`:- ```- auth_service["Auth Service\nsrc/auth/service.ts"]- user_repo["User Repository\nsrc/user/repository.ts"]- payment_module["Payment Module\nsrc/payment/"]- ```- - First line: role/responsibility in plain language (what it does)- - Second line: actual path relative to project root (where to find it)- - The viewer renders the path smaller and muted below the concept name- - For modules/folders, use the directory path (e.g., `src/payment/`)- - For single files, use the file path (e.g., `src/auth/service.ts`)-- Keep diagrams readable — 5-15 nodes max per diagram.-- Use `graph LR` for most diagrams, `graph TD` for hierarchies.-- Do NOT rewrite classes that haven't changed.-- Do NOT delete classes — only report if obsolete.-- Write each field separately (constraint, concern, context, todo, note) — do NOT combine them.-- Use `omm diff <class>` after updating to verify changes.-- Use `classDef` to visually distinguish node roles — apply only when the distinction genuinely helps a reader:-- | Class | Color | When to use |- |---|---|---|- | `external` | muted gray `#585b70` | Third-party services, APIs outside your codebase (DB, S3, Stripe, etc.) |- | `concern` | red `#f38ba8` | Nodes that are a known risk or bottleneck (single point of failure, legacy code) |- | `entry` | blue `#89b4fa` | Entry points (HTTP handler, CLI, queue consumer) |- | `store` | green `#a6e3a1` | Persistent storage (DB, cache, file system) |-- ```- classDef external fill:#585b70,stroke:#585b70,color:#cdd6f4- classDef concern fill:#f38ba8,stroke:#f38ba8,color:#1e1e2e- classDef entry fill:#89b4fa,stroke:#89b4fa,color:#1e1e2e- classDef store fill:#a6e3a1,stroke:#a6e3a1,color:#1e1e2e- ```-- Do not overuse — if everything has a color, nothing stands out.diff --git a/README.md b/README.mdindex e2e1d03..fb8d83d 100644--- a/README.md+++ b/README.md@@ -3,9 +3,9 @@[](https://www.npmjs.com/package/oh-my-mermaid)[](./LICENSE)-**Turn complex codebases into clear, navigable architecture diagrams with Claude Code.**+**Turn complex codebases into clear, navigable architecture diagrams with AI coding tools.**-> `omm init` → `claude` → `/omm-scan` → done. Your architecture docs write themselves.+> `omm setup` → `/omm-scan` → done. Your architecture docs write themselves.@@ -15,34 +15,37 @@ Plain Mermaid diagrams are flat — one file, one diagram, no connections betweeomm structures your architecture as **interconnected classes** that you can drill into. Use `@class-name` references to nest diagrams inside each other, zoom out to see the full picture, or click into a subsystem to focus on the details. Each class carries not just a diagram, but also context, constraints, and concerns — so the *why* behind your architecture lives right next to the *what*.-[Claude Code](https://docs.anthropic.com/en/docs/claude-code) does the heavy lifting: it analyzes your code and generates everything automatically.+Your AI coding tool does the heavy lifting: it analyzes your code and generates everything automatically.```-Your code → Claude Code analyzes → .omm/ stores diagrams → Live viewer in browser+Your code → AI analyzes → .omm/ stores diagrams → Live viewer in browser```## Prerequisites- [Node.js](https://nodejs.org/) 18+-- [Claude Code](https://docs.anthropic.com/en/docs/claude-code) (`npm install -g @anthropic-ai/claude-code`)+- An AI coding tool: [Claude Code](https://docs.anthropic.com/en/docs/claude-code), [Codex](https://github.com/openai/codex), [Cursor](https://cursor.sh/), or [Antigravity](https://github.com/ArcadeAI/antigravity)## Install```bashnpm install -g oh-my-mermaid+omm setup```+`omm setup` auto-detects installed AI coding tools and registers the `/omm-scan` skill for each. Run `omm setup --list` to see what was detected.+## Quick Start```bash-# 1. Initialize in your project-cd your-project-omm init+# 1. Install+npm install -g oh-my-mermaid && omm setup-# 2. Launch Claude Code-claude+# 2. Open your AI coding tool in a project+cd your-project+claude # or codex, cursor, etc.-# 3. Scan your architecture (inside Claude Code)+# 3. Scan your architecture/omm-scan# 4. View in browser@@ -50,7 +53,7 @@ omm serve# → http://localhost:3000```-`/omm-scan` makes Claude analyze your code and generate architecture docs in the `.omm/` directory.+`/omm-scan` analyzes your code and generates architecture docs in the `.omm/` directory.To focus on a specific area, pass a topic: `/omm-scan auth flow`.## How It Works@@ -94,7 +97,8 @@ Click `@auth-flow` in the viewer to navigate to that class.### Basics```bash-omm init # Initialize .omm/ and install Claude Code skills+omm setup # Register skills with detected AI tools+omm setup --list # Show detected platforms and statusomm list # List all classesomm show <class> # Display all fields for a classomm status # Overview of all classes@@ -144,7 +148,7 @@ omm logout # Sign outOr use `/omm-push` inside Claude Code to handle login, link, and push in one step.-## Claude Code Skills+## AI Coding Tool Skills| Skill | Description ||-------|-------------|@@ -152,6 +156,16 @@ Or use `/omm-push` inside Claude Code to handle login, link, and push in one ste| `/omm-scan [topic]` | Focus on a specific area (e.g. `/omm-scan auth flow`) || `/omm-push` | Login + link + push to cloud in one step |+### Supported Platforms++| Platform | Status | Setup method |+|----------|--------|--------------|+| Claude Code | Supported | Plugin marketplace registration |+| Codex | Supported | Symlink to `~/.agents/skills/` |+| Cursor | Supported | `.cursor-plugin/` auto-discovery |+| OpenClaw | Supported | Symlink to `~/.openclaw/skills/` |+| Antigravity | Supported | Symlink to `~/.gemini/antigravity/skills/` |+## Development```bashdiff --git a/package-lock.json b/package-lock.jsonindex 5738eca..9e19336 100644--- a/package-lock.json+++ b/package-lock.json@@ -1,12 +1,12 @@{"name": "oh-my-mermaid",- "version": "0.1.0",+ "version": "0.1.3","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "oh-my-mermaid",- "version": "0.1.0",+ "version": "0.1.3","license": "MIT","dependencies": {"yaml": "^2.8.3"diff --git a/package.json b/package.jsonindex 4902547..8349fd1 100644--- a/package.json+++ b/package.json@@ -11,6 +11,7 @@"files": ["dist/","skills/",+ ".claude-plugin/","LICENSE"],"keywords": [@@ -27,7 +28,8 @@"build": "tsup","dev": "tsup --watch","test": "vitest run",- "prepublishOnly": "npm run build"+ "sync-version": "node scripts/sync-version.js",+ "prepublishOnly": "npm run build && npm run sync-version"},"author": "","license": "MIT",diff --git a/scripts/sync-version.js b/scripts/sync-version.jsnew file mode 100644index 0000000..0362fac--- /dev/null+++ b/scripts/sync-version.js@@ -0,0 +1,13 @@+import { readFileSync, writeFileSync } from 'node:fs';++const { version } = JSON.parse(readFileSync('package.json', 'utf8'));++for (const name of ['plugin', 'marketplace']) {+ const filePath = `.claude-plugin/${name}.json`;+ const json = JSON.parse(readFileSync(filePath, 'utf8'));+ if (name === 'marketplace') json.plugins[0].version = version;+ else json.version = version;+ writeFileSync(filePath, JSON.stringify(json, null, 2) + '\n');+}++process.stderr.write(`Synced version ${version} to .claude-plugin/ manifests\n`);diff --git a/skills/omm-push/SKILL.md b/skills/omm-push/SKILL.mdindex 5e5235d..89b618d 100644--- a/skills/omm-push/SKILL.md+++ b/skills/omm-push/SKILL.md@@ -11,7 +11,14 @@ Automate the full workflow of pushing .omm/ architecture docs to the oh-my-merma## Prerequisites-The `omm` CLI must be installed (`npm install -g oh-my-mermaid`).+Ensure the `omm` CLI is available:++```bash+command -v omm || npm install -g oh-my-mermaid+```++If the install command fails (permission denied), tell the user:+"Please run `npm install -g oh-my-mermaid` in your terminal, then try again."## Workflowdiff --git a/skills/omm-scan/SKILL.md b/skills/omm-scan/SKILL.mdindex c65d23e..53bd14b 100644--- a/skills/omm-scan/SKILL.md+++ b/skills/omm-scan/SKILL.md@@ -13,7 +13,14 @@ Operates in two modes based on whether arguments are provided.## Prerequisites-The `omm` CLI must be installed (`npm install -g oh-my-mermaid` or available via npx).+Ensure the `omm` CLI is available:++```bash+command -v omm || npm install -g oh-my-mermaid+```++If the install command fails (permission denied), tell the user:+"Please run `npm install -g oh-my-mermaid` in your terminal, then try again."## Mode Detection@@ -24,15 +31,7 @@ The `omm` CLI must be installed (`npm install -g oh-my-mermaid` or available via## A. Full Scan Mode (no arguments)-### Step 1: Initialize--If `.omm/` does not exist, run `omm init` first.--```bash-omm init-```--### Step 2: Check Existing State+### Step 1: Check Existing State```bashomm list@@ -44,7 +43,7 @@ omm <class> descriptionomm <class> diagram```-### Step 3: Explore the Codebase+### Step 2: Explore the CodebaseUse Glob and Read to understand the project:- Read `package.json`, `tsconfig.json`, or equivalent config files@@ -52,7 +51,7 @@ Use Glob and Read to understand the project:- Read key entry points (main, index, app files)- Look for route definitions, service layers, database connections-### Step 4: Generate/Update Classes+### Step 3: Generate/Update Classes**First run (no existing classes):** Create classes based on what a person new to this codebase most needs to understand. Always start with `overall-architecture`, then add perspectives from this list based on what exists in the code:@@ -111,7 +110,7 @@ omm <class> note - <<'EOF'EOF```-### Step 5: Cross-References+### Step 4: Cross-ReferencesUse `@class-name` convention for nodes that represent another class. For `@ref` nodes, do NOT add a path as the second line — instead, use a plain concept label:@@ -124,7 +123,7 @@ graph LRThe `@` prefix tells the viewer this node is a drill-down into another class. Adding a file path would be misleading since it represents a whole sub-diagram, not a single file.-### Step 6: Summarize+### Step 5: SummarizeReport what was created/updated and suggest `omm serve` to view.diff --git a/src/__tests__/store.test.ts b/src/__tests__/store.test.tsnew file mode 100644index 0000000..c873f62--- /dev/null+++ b/src/__tests__/store.test.ts@@ -0,0 +1,68 @@+import { describe, it, expect, beforeEach, afterEach } from 'vitest';+import fs from 'node:fs';+import path from 'node:path';+import os from 'node:os';+import { ensureOmmForWrite, ensureOmmForRead, writeField, initOmm } from '../lib/store.js';++let tmpDir: string;++beforeEach(() => {+ tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'omm-test-'));+});++afterEach(() => {+ fs.rmSync(tmpDir, { recursive: true, force: true });+});++describe('ensureOmmForWrite', () => {+ it('creates .omm/ and config.yaml when missing', () => {+ ensureOmmForWrite(tmpDir);+ expect(fs.existsSync(path.join(tmpDir, '.omm'))).toBe(true);+ expect(fs.existsSync(path.join(tmpDir, '.omm', 'config.yaml'))).toBe(true);+ });++ it('is a no-op when .omm/ already exists', () => {+ initOmm(tmpDir);+ const configBefore = fs.readFileSync(path.join(tmpDir, '.omm', 'config.yaml'), 'utf-8');+ ensureOmmForWrite(tmpDir);+ const configAfter = fs.readFileSync(path.join(tmpDir, '.omm', 'config.yaml'), 'utf-8');+ expect(configAfter).toBe(configBefore);+ });+});++describe('ensureOmmForRead', () => {+ it('returns false when .omm/ is missing (no auto-create)', () => {+ const result = ensureOmmForRead(tmpDir);+ expect(result).toBe(false);+ expect(fs.existsSync(path.join(tmpDir, '.omm'))).toBe(false);+ });++ it('returns true when .omm/ exists', () => {+ initOmm(tmpDir);+ const result = ensureOmmForRead(tmpDir);+ expect(result).toBe(true);+ });+});++describe('writeField with lazy-init', () => {+ it('creates .omm/ + config.yaml + field file when .omm/ missing', () => {+ writeField('test-class', 'description', 'hello world', tmpDir);+ expect(fs.existsSync(path.join(tmpDir, '.omm'))).toBe(true);+ expect(fs.existsSync(path.join(tmpDir, '.omm', 'config.yaml'))).toBe(true);+ expect(fs.existsSync(path.join(tmpDir, '.omm', 'test-class', 'description.md'))).toBe(true);+ const content = fs.readFileSync(path.join(tmpDir, '.omm', 'test-class', 'description.md'), 'utf-8');+ expect(content).toBe('hello world');+ });++ it('creates meta.yaml after writing a field', () => {+ writeField('test-class', 'diagram', 'graph LR; A-->B', tmpDir);+ expect(fs.existsSync(path.join(tmpDir, '.omm', 'test-class', 'meta.yaml'))).toBe(true);+ });++ it('works normally when .omm/ already exists', () => {+ initOmm(tmpDir);+ writeField('existing-class', 'constraint', 'no direct DB access', tmpDir);+ const content = fs.readFileSync(path.join(tmpDir, '.omm', 'existing-class', 'constraint.md'), 'utf-8');+ expect(content).toBe('no direct DB access');+ });+});diff --git a/src/cli.ts b/src/cli.tsindex ba9f8f4..ec67387 100644--- a/src/cli.ts+++ b/src/cli.ts@@ -15,15 +15,19 @@ import { commandPush } from './commands/push.js';import { commandPull } from './commands/pull.js';import { commandLink } from './commands/link.js';import { commandShare } from './commands/share.js';+import { commandSetup } from './commands/setup.js';-const GLOBAL_COMMANDS = ['init', 'list', 'show', 'delete', 'status', 'diff', 'refs', 'serve', 'login', 'logout', 'push', 'pull', 'link', 'share', 'help'];+const GLOBAL_COMMANDS = ['init', 'setup', 'list', 'show', 'delete', 'status', 'diff', 'refs', 'serve', 'login', 'logout', 'push', 'pull', 'link', 'share', 'help'];function printHelp(): void {const help = `oh-my-mermaid (omm) — Architecture mirror for vibe codingUsage:- omm init Initialize .omm/ and install skills+ omm init Initialize .omm/ directory (usually not needed)+ omm setup [platform] Register skills with AI coding tools+ omm setup --list Show detected platforms+ omm setup --teardown Unregister from all platformsomm list List all classesomm show <class> Show all fields for a classomm delete <class> Delete a class@@ -65,6 +69,10 @@ async function main(): Promise<void> {commandInit();return;+ case 'setup':+ await commandSetup(args.slice(1));+ return;+case 'list':commandList();return;diff --git a/src/commands/class-field.ts b/src/commands/class-field.tsindex 23fe698..03b6ec6 100644--- a/src/commands/class-field.ts+++ b/src/commands/class-field.ts@@ -1,4 +1,4 @@-import { ensureOmm, isValidField, readField, writeField, classExists } from '../lib/store.js';+import { ensureOmmForRead, isValidField, readField, writeField, classExists } from '../lib/store.js';import { VALID_FIELDS, type Field } from '../types.js';function readStdin(): Promise<string> {@@ -12,8 +12,6 @@ function readStdin(): Promise<string> {}export async function commandClassField(className: string, field: string, content?: string): Promise<void> {- ensureOmm();-if (!isValidField(field)) {process.stderr.write(`error: unknown field '${field}'. Valid: ${VALID_FIELDS.join(', ')}\n`);process.exit(1);@@ -23,6 +21,7 @@ export async function commandClassField(className: string, field: string, conten// Read mode: no content argumentif (content === undefined) {+ if (!ensureOmmForRead()) return;if (!classExists(className)) {process.stderr.write(`error: class '${className}' not found\n`);process.exit(1);@@ -36,7 +35,7 @@ export async function commandClassField(className: string, field: string, contenreturn;}- // Write mode: content is '-' means read from stdin+ // Write mode: writeField() handles lazy-init internallylet finalContent: string;if (content === '-') {finalContent = await readStdin();diff --git a/src/commands/delete.ts b/src/commands/delete.tsindex be5341f..ac82c40 100644--- a/src/commands/delete.ts+++ b/src/commands/delete.ts@@ -1,7 +1,7 @@-import { ensureOmm, deleteClass } from '../lib/store.js';+import { ensureOmmForRead, deleteClass } from '../lib/store.js';export function commandDelete(className: string): void {- ensureOmm();+ if (!ensureOmmForRead()) return;if (deleteClass(className)) {process.stderr.write(`deleted class '${className}'\n`);} else {diff --git a/src/commands/diff.ts b/src/commands/diff.tsindex c126b1b..edccf79 100644--- a/src/commands/diff.ts+++ b/src/commands/diff.ts@@ -1,8 +1,8 @@-import { ensureOmm, readField, readMeta, classExists } from '../lib/store.js';+import { ensureOmmForRead, readField, readMeta, classExists } from '../lib/store.js';import { diffMermaid, formatDiff } from '../lib/diff.js';export function commandDiff(className: string): void {- ensureOmm();+ if (!ensureOmmForRead()) return;if (!classExists(className)) {process.stderr.write(`error: class '${className}' not found\n`);diff --git a/src/commands/init.ts b/src/commands/init.tsindex bb45025..b442623 100644--- a/src/commands/init.ts+++ b/src/commands/init.ts@@ -1,63 +1,12 @@-import fs from 'node:fs';-import path from 'node:path';-import { fileURLToPath } from 'node:url';import { initOmm, ommExists } from '../lib/store.js';-const __filename = fileURLToPath(import.meta.url);-const __dirname = path.dirname(__filename);--function copySkills(cwd: string): void {- // Skills are at ../skills/ relative to dist/ (or src/ in dev)- const candidates = [- path.join(__dirname, '..', 'skills'), // from dist/cli.js- path.join(__dirname, '..', '..', 'skills'), // from src/commands/init.ts (dev)- ];-- let skillsSource: string | null = null;- for (const candidate of candidates) {- if (fs.existsSync(candidate)) {- skillsSource = candidate;- break;- }- }-- if (!skillsSource) {- process.stderr.write('warning: skills directory not found, skipping skill installation\n');- return;- }-- const targetDir = path.join(cwd, '.claude', 'skills');- const skillDirs = fs.readdirSync(skillsSource, { withFileTypes: true })- .filter(d => d.isDirectory());-- for (const skillDir of skillDirs) {- const src = path.join(skillsSource, skillDir.name);- const dst = path.join(targetDir, skillDir.name);-- if (fs.existsSync(dst)) {- process.stderr.write(` skill ${skillDir.name} already exists, skipping\n`);- continue;- }-- fs.mkdirSync(dst, { recursive: true });- const files = fs.readdirSync(src);- for (const file of files) {- fs.copyFileSync(path.join(src, file), path.join(dst, file));- }- process.stderr.write(` installed skill: ${skillDir.name}\n`);- }-}-export function commandInit(): void {const cwd = process.cwd();if (ommExists(cwd)) {- process.stderr.write('.omm/ already exists\n');+ process.stderr.write('.omm/ already initialized.\n');} else {initOmm(cwd);- process.stderr.write('created .omm/\n');+ process.stderr.write('Created .omm/ directory. Add to .gitignore if not wanted.\n');}-- copySkills(cwd);- process.stderr.write('omm initialized.\n');}diff --git a/src/commands/link.ts b/src/commands/link.tsindex 373d631..75bd1d5 100644--- a/src/commands/link.ts+++ b/src/commands/link.ts@@ -1,10 +1,10 @@import fs from 'node:fs';import path from 'node:path';import YAML from 'yaml';-import { ensureOmm, getOmmDir } from '../lib/store.js';+import { ensureOmmForWrite, getOmmDir } from '../lib/store.js';export function commandLink(slug?: string): void {- ensureOmm();+ ensureOmmForWrite();const resolvedSlug = slug || path.basename(process.cwd());diff --git a/src/commands/list.ts b/src/commands/list.tsindex 0e9917f..1569114 100644--- a/src/commands/list.ts+++ b/src/commands/list.ts@@ -1,7 +1,6 @@-import { ensureOmm, listClasses } from '../lib/store.js';+import { listClasses } from '../lib/store.js';export function commandList(): void {- ensureOmm();const classes = listClasses();if (classes.length === 0) {process.stderr.write('No classes found.\n');diff --git a/src/commands/pull.ts b/src/commands/pull.tsindex e6d5b61..0d45182 100644--- a/src/commands/pull.ts+++ b/src/commands/pull.ts@@ -2,10 +2,10 @@ import fs from 'node:fs';import path from 'node:path';import YAML from 'yaml';import { getToken, apiRequest } from '../lib/cloud.js';-import { ensureOmm, getOmmDir } from '../lib/store.js';+import { ensureOmmForWrite, getOmmDir } from '../lib/store.js';export async function commandPull(): Promise<void> {- ensureOmm();+ ensureOmmForWrite();const token = getToken();if (!token) {diff --git a/src/commands/push.ts b/src/commands/push.tsindex f983568..0db230e 100644--- a/src/commands/push.ts+++ b/src/commands/push.ts@@ -3,7 +3,7 @@ import path from 'node:path';import { execSync } from 'node:child_process';import YAML from 'yaml';import { getToken, getApiUrl, apiRequest } from '../lib/cloud.js';-import { ensureOmm, getOmmDir } from '../lib/store.js';+import { ensureOmmForRead, getOmmDir } from '../lib/store.js';function walkDir(dir: string, base: string): Array<{ path: string; content: string }> {const files: Array<{ path: string; content: string }> = [];@@ -32,7 +32,7 @@ function getGitCommit(): string | undefined {}export async function commandPush(): Promise<void> {- ensureOmm();+ if (!ensureOmmForRead()) return;const token = getToken();if (!token) {diff --git a/src/commands/refs.ts b/src/commands/refs.tsindex 1839f6d..a75796c 100644--- a/src/commands/refs.ts+++ b/src/commands/refs.ts@@ -1,8 +1,8 @@-import { ensureOmm, classExists } from '../lib/store.js';+import { ensureOmmForRead, classExists } from '../lib/store.js';import { getIncomingRefs, getOutgoingRefs } from '../lib/refs.js';export function commandRefs(className: string, reverse: boolean): void {- ensureOmm();+ if (!ensureOmmForRead()) return;if (!classExists(className)) {process.stderr.write(`error: class '${className}' not found\n`);diff --git a/src/commands/serve.ts b/src/commands/serve.tsindex 7f069c2..bd1f5e3 100644--- a/src/commands/serve.ts+++ b/src/commands/serve.ts@@ -1,7 +1,7 @@-import { ensureOmm } from '../lib/store.js';+import { ensureOmmForRead } from '../lib/store.js';import { startServer } from '../server/index.js';export function commandServe(port: number = 3000): void {- ensureOmm();+ if (!ensureOmmForRead()) return;startServer(port);}diff --git a/src/commands/setup.ts b/src/commands/setup.tsnew file mode 100644index 0000000..7740a74--- /dev/null+++ b/src/commands/setup.ts@@ -0,0 +1,69 @@+import { ALL_PLATFORMS, getPlatformById, getDetectedPlatforms } from '../lib/platforms/index.js';++export async function commandSetup(args: string[]): Promise<void> {+ const teardown = args.includes('--teardown');+ const listOnly = args.includes('--list');+ const platformId = args.find(a => !a.startsWith('--'));++ // omm setup --list+ if (listOnly) {+ process.stderr.write('Detected platforms:\n');+ for (const p of ALL_PLATFORMS) {+ const detected = p.detect();+ const setup = detected && p.isSetup();+ const status = !detected ? 'not installed' : setup ? 'ready' : 'not configured';+ process.stderr.write(` ${detected ? '●' : '○'} ${p.name} (${p.id}) — ${status}\n`);+ }+ return;+ }++ // omm setup <platform>+ if (platformId) {+ const platform = getPlatformById(platformId);+ if (!platform) {+ process.stderr.write(`error: unknown platform '${platformId}'. Available: ${ALL_PLATFORMS.map(p => p.id).join(', ')}\n`);+ process.exit(1);+ }+ if (!platform.detect()) {+ process.stderr.write(`error: ${platform.name} is not installed on this machine.\n`);+ process.exit(1);+ }+ if (teardown) {+ platform.teardown();+ process.stderr.write(`${platform.name}: teardown complete.\n`);+ } else {+ if (platform.isSetup()) {+ process.stderr.write(`${platform.name}: already configured.\n`);+ return;+ }+ process.stderr.write(`${platform.name}: setting up...\n`);+ await platform.setup();+ }+ return;+ }++ // omm setup (auto-detect all)+ const detected = getDetectedPlatforms();++ if (detected.length === 0) {+ process.stderr.write('No supported AI coding tools detected.\n');+ process.stderr.write('Supported: ' + ALL_PLATFORMS.map(p => p.name).join(', ') + '\n');+ return;+ }++ for (const platform of detected) {+ if (teardown) {+ platform.teardown();+ process.stderr.write(`${platform.name}: teardown complete.\n`);+ continue;+ }+ if (platform.isSetup()) {+ process.stderr.write(`${platform.name}: already configured.\n`);+ continue;+ }+ process.stderr.write(`${platform.name}: setting up...\n`);+ await platform.setup();+ }++ process.stderr.write('\nomm setup complete.\n');+}diff --git a/src/commands/share.ts b/src/commands/share.tsindex 936db9b..ad3d2ed 100644--- a/src/commands/share.ts+++ b/src/commands/share.ts@@ -2,14 +2,14 @@ import fs from 'node:fs';import path from 'node:path';import YAML from 'yaml';import { getApiUrl } from '../lib/cloud.js';-import { ensureOmm, getOmmDir } from '../lib/store.js';+import { ensureOmmForRead, getOmmDir } from '../lib/store.js';export function commandShare(): void {- ensureOmm();+ if (!ensureOmmForRead()) return;const configPath = path.join(getOmmDir(), 'config.yaml');if (!fs.existsSync(configPath)) {- process.stderr.write("error: .omm/config.yaml not found. Run 'omm init' first.\n");+ process.stderr.write("error: .omm/config.yaml not found. Run /omm-scan in Claude Code first.\n");process.exit(1);}diff --git a/src/commands/show.ts b/src/commands/show.tsindex 1315a9c..e203055 100644--- a/src/commands/show.ts+++ b/src/commands/show.ts@@ -1,8 +1,8 @@import YAML from 'yaml';-import { ensureOmm, showClass } from '../lib/store.js';+import { ensureOmmForRead, showClass } from '../lib/store.js';export function commandShow(className: string): void {- ensureOmm();+ if (!ensureOmmForRead()) return;const data = showClass(className);if (!data) {process.stderr.write(`error: class '${className}' not found\n`);diff --git a/src/commands/status.ts b/src/commands/status.tsindex 6988736..22cb64b 100644--- a/src/commands/status.ts+++ b/src/commands/status.ts@@ -1,7 +1,7 @@-import { ensureOmm, listClasses, readMeta } from '../lib/store.js';+import { ensureOmmForRead, listClasses, readMeta } from '../lib/store.js';export function commandStatus(): void {- ensureOmm();+ if (!ensureOmmForRead()) return;const classes = listClasses();if (classes.length === 0) {diff --git a/src/index.ts b/src/index.tsindex 0ed4d98..6c95630 100644--- a/src/index.ts+++ b/src/index.ts@@ -1,5 +1,5 @@// oh-my-mermaid public API-export { initOmm, listClasses, readField, writeField, showClass, deleteClass, classExists } from './lib/store.js';+export { initOmm, ensureOmmForRead, ensureOmmForWrite, listClasses, readField, writeField, showClass, deleteClass, classExists } from './lib/store.js';export { diffMermaid, parseMermaid, formatDiff } from './lib/diff.js';export { extractRefs, getIncomingRefs, getOutgoingRefs, buildRefGraph } from './lib/refs.js';export { VALID_FIELDS, FIELD_FILES } from './types.js';diff --git a/src/lib/platforms/antigravity.ts b/src/lib/platforms/antigravity.tsnew file mode 100644index 0000000..8904247--- /dev/null+++ b/src/lib/platforms/antigravity.ts@@ -0,0 +1,48 @@+import fs from 'node:fs';+import path from 'node:path';+import os from 'node:os';+import { execSync } from 'node:child_process';+import type { Platform } from './types.js';+import { getSkillsSource } from './utils.js';++const SKILLS_TARGET = path.join(os.homedir(), '.gemini', 'antigravity', 'skills', 'oh-my-mermaid');++export const antigravity: Platform = {+ name: 'Antigravity',+ id: 'antigravity',++ detect(): boolean {+ try {+ execSync('which antigravity', { stdio: 'ignore' });+ return true;+ } catch {+ return false;+ }+ },++ isSetup(): boolean {+ return fs.existsSync(SKILLS_TARGET);+ },++ async setup(): Promise<void> {+ const source = getSkillsSource();+ if (!source) {+ process.stderr.write(' Could not locate skills directory.\n');+ return;+ }++ fs.mkdirSync(path.dirname(SKILLS_TARGET), { recursive: true });++ if (fs.existsSync(SKILLS_TARGET)) {+ fs.rmSync(SKILLS_TARGET, { recursive: true });+ }+ fs.symlinkSync(source, SKILLS_TARGET, 'dir');+ process.stderr.write(` Symlinked skills → ${SKILLS_TARGET}\n`);+ },++ teardown(): void {+ if (fs.existsSync(SKILLS_TARGET)) {+ fs.rmSync(SKILLS_TARGET, { recursive: true });+ }+ },+};diff --git a/src/lib/platforms/claude.ts b/src/lib/platforms/claude.tsnew file mode 100644index 0000000..7f60414--- /dev/null+++ b/src/lib/platforms/claude.ts@@ -0,0 +1,46 @@+import { execSync } from 'node:child_process';+import type { Platform } from './types.js';++function run(cmd: string): { ok: boolean; out: string } {+ try {+ const out = execSync(cmd, { stdio: ['ignore', 'pipe', 'pipe'] }).toString().trim();+ return { ok: true, out };+ } catch {+ return { ok: false, out: '' };+ }+}++export const claude: Platform = {+ name: 'Claude Code',+ id: 'claude',++ detect(): boolean {+ return run('which claude').ok;+ },++ isSetup(): boolean {+ const { ok, out } = run('claude plugin list 2>&1');+ if (!ok) return false;+ return out.includes('oh-my-mermaid');+ },++ async setup(): Promise<void> {+ // Add marketplace (may already exist — ignore error)+ run('claude plugin marketplace add oh-my-mermaid/oh-my-mermaid');++ const { ok, out } = run('claude plugin install oh-my-mermaid 2>&1');+ if (!ok) {+ // If marketplace add failed, suggest manual install+ process.stderr.write(` Could not auto-install plugin. Run manually:\n`);+ process.stderr.write(` claude plugin marketplace add oh-my-mermaid/oh-my-mermaid\n`);+ process.stderr.write(` claude plugin install oh-my-mermaid\n`);+ return;+ }+ process.stderr.write(` ${out}\n`);+ },++ teardown(): void {+ run('claude plugin uninstall oh-my-mermaid 2>&1');+ run('claude plugin marketplace remove oh-my-mermaid 2>&1');+ },+};diff --git a/src/lib/platforms/codex.ts b/src/lib/platforms/codex.tsnew file mode 100644index 0000000..56e350e--- /dev/null+++ b/src/lib/platforms/codex.ts@@ -0,0 +1,48 @@+import fs from 'node:fs';+import path from 'node:path';+import os from 'node:os';+import { execSync } from 'node:child_process';+import type { Platform } from './types.js';+import { getSkillsSource } from './utils.js';++const SKILLS_TARGET = path.join(os.homedir(), '.agents', 'skills', 'oh-my-mermaid');++export const codex: Platform = {+ name: 'Codex',+ id: 'codex',++ detect(): boolean {+ try {+ execSync('which codex', { stdio: 'ignore' });+ return true;+ } catch {+ return false;+ }+ },++ isSetup(): boolean {+ return fs.existsSync(SKILLS_TARGET);+ },++ async setup(): Promise<void> {+ const source = getSkillsSource();+ if (!source) {+ process.stderr.write(' Could not locate skills directory.\n');+ return;+ }++ fs.mkdirSync(path.dirname(SKILLS_TARGET), { recursive: true });++ if (fs.existsSync(SKILLS_TARGET)) {+ fs.rmSync(SKILLS_TARGET, { recursive: true });+ }+ fs.symlinkSync(source, SKILLS_TARGET, 'dir');+ process.stderr.write(` Symlinked skills → ${SKILLS_TARGET}\n`);+ },++ teardown(): void {+ if (fs.existsSync(SKILLS_TARGET)) {+ fs.rmSync(SKILLS_TARGET, { recursive: true });+ }+ },+};diff --git a/src/lib/platforms/cursor.ts b/src/lib/platforms/cursor.tsnew file mode 100644index 0000000..a2b1864--- /dev/null+++ b/src/lib/platforms/cursor.ts@@ -0,0 +1,67 @@+import fs from 'node:fs';+import path from 'node:path';+import { execSync } from 'node:child_process';+import type { Platform } from './types.js';+import { getSkillsSource } from './utils.js';++const PLUGIN_DIR = '.cursor-plugin';+const PLUGIN_FILE = 'plugin.json';++function getCwd(): string {+ return process.cwd();+}++export const cursor: Platform = {+ name: 'Cursor',+ id: 'cursor',++ detect(): boolean {+ // Cursor is detected if the binary exists or we're inside a Cursor workspace+ try {+ execSync('which cursor', { stdio: 'ignore' });+ return true;+ } catch {+ // Also detect if .cursor/ directory exists in project+ return fs.existsSync(path.join(getCwd(), '.cursor'));+ }+ },++ isSetup(): boolean {+ return fs.existsSync(path.join(getCwd(), PLUGIN_DIR, PLUGIN_FILE));+ },++ async setup(): Promise<void> {+ const skillsSource = getSkillsSource();+ if (!skillsSource) {+ process.stderr.write(' Could not locate skills directory.\n');+ return;+ }++ const pluginDir = path.join(getCwd(), PLUGIN_DIR);+ fs.mkdirSync(pluginDir, { recursive: true });++ const manifest = {+ name: 'oh-my-mermaid',+ displayName: 'oh-my-mermaid',+ description: 'Turn complex codebases into clear, navigable architecture diagrams',+ version: '0.1.3',+ author: { name: 'oh-my-mermaid' },+ homepage: 'https://github.com/oh-my-mermaid/oh-my-mermaid',+ license: 'MIT',+ skills: skillsSource,+ };++ fs.writeFileSync(+ path.join(pluginDir, PLUGIN_FILE),+ JSON.stringify(manifest, null, 2) + '\n',+ );+ process.stderr.write(` Created ${PLUGIN_DIR}/${PLUGIN_FILE} in project\n`);+ },++ teardown(): void {+ const pluginDir = path.join(getCwd(), PLUGIN_DIR);+ if (fs.existsSync(pluginDir)) {+ fs.rmSync(pluginDir, { recursive: true });+ }+ },+};diff --git a/src/lib/platforms/index.ts b/src/lib/platforms/index.tsnew file mode 100644index 0000000..9cdad26--- /dev/null+++ b/src/lib/platforms/index.ts@@ -0,0 +1,18 @@+import type { Platform } from './types.js';+import { claude } from './claude.js';+import { codex } from './codex.js';+import { cursor } from './cursor.js';+import { openclaw } from './openclaw.js';+import { antigravity } from './antigravity.js';++export type { Platform };++export const ALL_PLATFORMS: Platform[] = [claude, codex, cursor, openclaw, antigravity];++export function getPlatformById(id: string): Platform | undefined {+ return ALL_PLATFORMS.find(p => p.id === id);+}++export function getDetectedPlatforms(): Platform[] {+ return ALL_PLATFORMS.filter(p => p.detect());+}diff --git a/src/lib/platforms/openclaw.ts b/src/lib/platforms/openclaw.tsnew file mode 100644index 0000000..bbd4804--- /dev/null+++ b/src/lib/platforms/openclaw.ts@@ -0,0 +1,48 @@+import fs from 'node:fs';+import path from 'node:path';+import os from 'node:os';+import { execSync } from 'node:child_process';+import type { Platform } from './types.js';+import { getSkillsSource } from './utils.js';++const SKILLS_TARGET = path.join(os.homedir(), '.openclaw', 'skills', 'oh-my-mermaid');++export const openclaw: Platform = {+ name: 'OpenClaw',+ id: 'openclaw',++ detect(): boolean {+ try {+ execSync('which openclaw', { stdio: 'ignore' });+ return true;+ } catch {+ return false;+ }+ },++ isSetup(): boolean {+ return fs.existsSync(SKILLS_TARGET);+ },++ async setup(): Promise<void> {+ const source = getSkillsSource();+ if (!source) {+ process.stderr.write(' Could not locate skills directory.\n');+ return;+ }++ fs.mkdirSync(path.dirname(SKILLS_TARGET), { recursive: true });++ if (fs.existsSync(SKILLS_TARGET)) {+ fs.rmSync(SKILLS_TARGET, { recursive: true });+ }+ fs.symlinkSync(source, SKILLS_TARGET, 'dir');+ process.stderr.write(` Symlinked skills → ${SKILLS_TARGET}\n`);+ },++ teardown(): void {+ if (fs.existsSync(SKILLS_TARGET)) {+ fs.rmSync(SKILLS_TARGET, { recursive: true });+ }+ },+};diff --git a/src/lib/platforms/types.ts b/src/lib/platforms/types.tsnew file mode 100644index 0000000..20bd133--- /dev/null+++ b/src/lib/platforms/types.ts@@ -0,0 +1,14 @@+export interface Platform {+ /** Display name (e.g. "Claude Code") */+ name: string;+ /** CLI-facing id (e.g. "claude") */+ id: string;+ /** Is the tool binary installed on this machine? */+ detect(): boolean;+ /** Are omm skills already registered? */+ isSetup(): boolean;+ /** Register omm skills/plugin */+ setup(): Promise<void>;+ /** Unregister omm skills/plugin */+ teardown(): void;+}diff --git a/src/lib/platforms/utils.ts b/src/lib/platforms/utils.tsnew file mode 100644index 0000000..5e8dc51--- /dev/null+++ b/src/lib/platforms/utils.ts@@ -0,0 +1,25 @@+import fs from 'node:fs';+import path from 'node:path';+import { fileURLToPath } from 'node:url';++const __filename = fileURLToPath(import.meta.url);+const __dirname = path.dirname(__filename);++/**+ * Locate the skills/ directory shipped with the npm package.+ * Works from both dist/ (production) and src/ (dev).+ */+export function getSkillsSource(): string | null {+ const candidates = [+ path.join(__dirname, '..', '..', 'skills'), // from dist/lib/platforms/+ path.join(__dirname, '..', '..', '..', 'skills'), // from src/lib/platforms/+ ];++ for (const candidate of candidates) {+ const resolved = path.resolve(candidate);+ if (fs.existsSync(resolved)) {+ return resolved;+ }+ }+ return null;+}diff --git a/src/lib/store.ts b/src/lib/store.tsindex e40d4f0..1d47668 100644--- a/src/lib/store.ts+++ b/src/lib/store.ts@@ -16,13 +16,27 @@ export function ommExists(cwd?: string): boolean {return fs.existsSync(getOmmDir(cwd));}-export function ensureOmm(cwd?: string): void {+/**+ * Write commands: auto-create .omm/ if missing (lazy-init).+ */+export function ensureOmmForWrite(cwd?: string): void {if (!ommExists(cwd)) {- process.stderr.write(`error: .omm/ not found. Run 'omm init' first.\n`);- process.exit(1);+ initOmm(cwd);+ process.stderr.write('Created .omm/ directory. Add to .gitignore if not wanted.\n');}}+/**+ * Read commands: return false if .omm/ missing (no auto-create).+ */+export function ensureOmmForRead(cwd?: string): boolean {+ if (!ommExists(cwd)) {+ process.stderr.write('No .omm/ directory found. Run /omm-scan in Claude Code to generate architecture docs.\n');+ return false;+ }+ return true;+}+export function isValidField(field: string): field is Field {return (VALID_FIELDS as readonly string[]).includes(field);}@@ -84,6 +98,7 @@ export function readField(className: string, field: Field, cwd?: string): string}export function writeField(className: string, field: Field, content: string, cwd?: string): number {+ ensureOmmForWrite(cwd);const dir = ensureClassDir(className, cwd);const filePath = path.join(dir, FIELD_FILES[field]);