Files
oh-my-claudecode/dist/__tests__/plugin-setup-devpaths.test.js
Peter Gagarinov d7252572dc docs: document --plugin-dir, add CONTRIBUTING.md and omc doctor --plugin-dir
Adds the missing developer/contributor documentation for running OMC from a
local checkout, and teaches `omc doctor` to accept `--plugin-dir` in parity
with `omc` and `omc setup`.

Docs
- New CONTRIBUTING.md at repo root covering fork & upstream setup, three
  linking flows (plugin-dir, marketplace, no-plugin) with a comparison
  table, suggested shell aliases, rebuilding, tests/lint, and rebasing
  onto upstream/dev or upstream/main.
- New docs/REFERENCE.md "Plugin directory flags" section documenting
  omc --plugin-dir, claude --plugin-dir (direct), omc setup --plugin-dir-mode,
  omc doctor --plugin-dir (NEW), OMC_PLUGIN_ROOT env var, and a decision
  matrix. Also calls out --plugin-dir as the recommended local-dev flow
  (no plugin cache = hot iteration).
- docs/LOCAL_PLUGIN_INSTALL.md: adds a hot-reload caveat for the marketplace
  flow and a no-marketplace alternative subsection.
- docs/GETTING-STARTED.md: one-paragraph "running from a local checkout"
  callout.
- docs/DEVELOPERS.md: 3-line pointer to CONTRIBUTING.md.
- README.md and 11 translated READMEs: cross-links to the new REFERENCE
  section and a Contributing pointer. Translated files carry
  <!-- TODO(i18n) --> markers for maintainer-driven translation sync.

Code
- New src/lib/plugin-dir.ts exposing resolvePluginDirArg(), reused by
  src/cli/launch.ts (refactor, no behavior change) and src/cli/index.ts.
- omc doctor and omc doctor conflicts now accept --plugin-dir <path>.
  A preAction hook on the parent doctor command resolves the path,
  warns if it overrides a pre-existing OMC_PLUGIN_ROOT, and exits
  with a red error on empty/whitespace input instead of a raw stack.
- New npm run dev:full script running tsc --watch plus all six esbuild
  bundle steps in watch mode concurrently. scripts/build-*.mjs gained
  a --watch flag via esbuild.context().watch(). concurrently added as
  a devDependency.

Tests
- src/lib/__tests__/plugin-dir.test.ts: 6 unit tests covering absolute,
  relative, empty, whitespace-only, and ~-non-expansion edge cases.
- src/cli/__tests__/doctor-plugin-dir.test.ts: 10 tests including a real
  Commander parseAsync on `doctor conflicts --plugin-dir /tmp/foo` that
  would catch silent unwiring of the flag.

Constraint: Existing --plugin-dir launcher semantics in launch.ts must
not change (plugin-dir-capture tests still pass).
Constraint: REFERENCE.md must only gain additions; no existing sections
touched.
Rejected: Expanding ~ in resolvePluginDirArg | path.resolve() does not
and the behavior is now pinned by test + documented instead.
Rejected: Translating the 11 localized READMEs in-place | maintainer
handles i18n sync post-merge per upstream convention.
Confidence: high
Scope-risk: moderate
Directive: Any new --plugin-dir consumer must import resolvePluginDirArg
from src/lib/plugin-dir.ts rather than re-implementing path resolution.
Not-tested: dev:full watcher behavior on Windows (concurrently SIGINT
forwarding).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-08 22:48:51 +01:00

36 lines
1.8 KiB
JavaScript
Generated

import { describe, it, expect } from 'vitest';
import { readFileSync, existsSync } from 'node:fs';
import { join, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const PACKAGE_ROOT = join(__dirname, '..', '..');
const PLUGIN_SETUP_PATH = join(PACKAGE_ROOT, 'scripts', 'plugin-setup.mjs');
const HUD_WRAPPER_TEMPLATE = join(PACKAGE_ROOT, 'scripts', 'lib', 'hud-wrapper-template.txt');
/**
* Plan binary-weaving-mountain replaced the brittle hardcoded `devPaths`
* + `OMC_DEV=1` branch with a single `process.env.OMC_PLUGIN_ROOT` resolution
* step set automatically by `omc --plugin-dir <path>`.
*
* This test guards the migration: the dev-paths array must be GONE from
* both install paths, and the new env-var step must be present in the
* shared wrapper template.
*/
describe('HUD wrapper devPaths removal (binary-weaving-mountain)', () => {
it('plugin-setup.mjs no longer contains an inline devPaths array', () => {
const content = readFileSync(PLUGIN_SETUP_PATH, 'utf-8');
expect(content).not.toMatch(/const devPaths\s*=\s*\[/);
expect(content).not.toContain('Workspace/oh-my-claudecode/dist/hud/index.js');
expect(content).not.toContain('OMC_DEV');
});
it('shared HUD wrapper template exists and uses OMC_PLUGIN_ROOT', () => {
expect(existsSync(HUD_WRAPPER_TEMPLATE)).toBe(true);
const content = readFileSync(HUD_WRAPPER_TEMPLATE, 'utf-8');
expect(content).toContain('OMC_PLUGIN_ROOT');
expect(content).toContain('dist/hud/index.js');
expect(content).not.toContain('OMC_DEV');
expect(content).not.toContain('Workspace/oh-my-claudecode');
expect(content).not.toContain('projects/oh-my-claudecode');
});
});
//# sourceMappingURL=plugin-setup-devpaths.test.js.map