Files
oh-my-pi/packages/coding-agent/test/marketplace/dev-ergonomics.test.ts
T
Miroslav Drbalandcan1357 4e199f93f7 feat: add marketplace plugin system
Add Claude Code-compatible marketplace plugin infrastructure:

- Registry: types, ID helpers, atomic read/write for marketplaces.json
  and installed_plugins.json (Claude Code format with version: 2)
- Fetcher: classifySource (6 ordered rules), parseMarketplaceCatalog,
  fetchMarketplace (local sources; git/http stubs for Phase 2)
- Resolver + Cache: resolvePluginSource with pathIsWithin containment,
  cachePlugin, removeCachedPlugin, cleanOrphanedCache
- MarketplaceManager: orchestrates add/remove/update marketplaces,
  install/uninstall/enable plugins, clearPluginRootsCache on mutation
- CLI: omp plugin marketplace add|remove|update|list,
  omp plugin discover, classifyInstallTarget for name@marketplace
- Discovery: listClaudePluginRoots reads OMP registry alongside
  Claude's, OMP authoritative for duplicate plugin IDs
- Args: --plugin-dir repeatable flag (parsing only, runtime wiring TBD)
- Slash command: /reload-plugins clears fs + roots cache
- Test fixtures and 130 tests across 8 test files
2026-03-30 13:44:53 +02:00

38 lines
1.3 KiB
TypeScript

import { describe, expect, it } from "bun:test";
// Cannot import parseArgs from cli/args.ts (transitively loads @oh-my-pi/pi-natives
// via ../tools). Instead, test the flag parsing logic by reimplementing the relevant
// subset. The actual integration is verified by bun check:ts (Args.pluginDirs exists
// and parseArgs populates it).
/** Minimal flag parser matching the --plugin-dir logic in parseArgs. */
function parsePluginDirFlags(args: string[]): string[] | undefined {
let result: string[] | undefined;
for (let i = 0; i < args.length; i++) {
const arg = args[i];
if (arg === "--plugin-dir" && i + 1 < args.length) {
result = result || [];
result.push(args[++i]);
}
}
return result;
}
describe("--plugin-dir flag parsing logic", () => {
it("parses single --plugin-dir", () => {
expect(parsePluginDirFlags(["--plugin-dir", "./my-plugin"])).toEqual(["./my-plugin"]);
});
it("parses multiple --plugin-dir flags", () => {
expect(parsePluginDirFlags(["--plugin-dir", "./a", "--plugin-dir", "./b"])).toEqual(["./a", "./b"]);
});
it("returns undefined when no --plugin-dir", () => {
expect(parsePluginDirFlags([])).toBeUndefined();
});
it("ignores --plugin-dir with no value", () => {
expect(parsePluginDirFlags(["--plugin-dir"])).toBeUndefined();
});
});