Skip to content

Commit bbb1f37

Browse files
committed
refactor: remove unused monorepoDir parameter
- Remove MONOREPO_DIR constant from bin/opencode-link.js - Remove monorepoDir parameter from discoverPlugins() - Discovery now only uses global + local node_modules (as intended)
1 parent d1b60ac commit bbb1f37

2 files changed

Lines changed: 3 additions & 33 deletions

File tree

bin/opencode-link.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,6 @@ import { generateCombinedSchema, ensureProjectConfigSchema } from '../lib/schema
4747
const __filename = fileURLToPath(import.meta.url);
4848
const __dirname = path.dirname(__filename);
4949

50-
// PROJECT_ROOT is where npm install was run (the consuming project)
51-
const PROJECT_ROOT = process.cwd();
52-
53-
// MONOREPO_DIR is where this script lives (the opencode-plugins package)
54-
// Used for backwards compatibility with monorepo plugin structure
55-
const MONOREPO_DIR = path.resolve(__dirname, '..');
56-
5750
// Colors for terminal output
5851
const colors = {
5952
reset: '\x1b[0m',
@@ -637,8 +630,8 @@ async function main() {
637630
const { targetDir, source } = resolveTargetDir(cliTargetDir);
638631
TARGET_DIR = targetDir;
639632

640-
// Discover plugins (global + monorepo + local)
641-
PLUGINS = discoverPlugins(TARGET_DIR, MONOREPO_DIR);
633+
// Discover plugins (global + local)
634+
PLUGINS = discoverPlugins(TARGET_DIR);
642635
CONTENT_TYPES = getContentTypes(PLUGINS);
643636

644637
log('\nOpenCode Plugin Linker', 'bright');

lib/discovery.js

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,9 @@ function getGlobalDir() {
3838
* 2. Local: {targetDir}/node_modules/
3939
*
4040
* @param {string} targetDir - The .opencode directory (e.g., /project/.opencode)
41-
* @param {string} [monorepoDir] - Optional: Direct path to a monorepo (for development)
4241
* @returns {Map<string, PluginDescriptor>} Map of plugin name to descriptor
4342
*/
44-
export function discoverPlugins(targetDir, monorepoDir = null) {
43+
export function discoverPlugins(targetDir) {
4544
const globalDir = getGlobalDir();
4645

4746
// Scan all locations (order matters: last wins)
@@ -64,28 +63,6 @@ export function discoverPlugins(targetDir, monorepoDir = null) {
6463
allPlugins.set(name, descriptor);
6564
}
6665

67-
// Optional: Direct monorepo path (for when running from installed package or cloned repo)
68-
if (monorepoDir && fs.existsSync(monorepoDir)) {
69-
// Determine the correct location based on where the monorepo is installed
70-
const localNodeModules = path.join(targetDir, 'node_modules');
71-
72-
let monorepoLocation = 'local'; // default
73-
if (globalDir && monorepoDir.startsWith(globalDir)) {
74-
monorepoLocation = 'global';
75-
} else if (monorepoDir.startsWith(localNodeModules)) {
76-
monorepoLocation = 'local';
77-
}
78-
// If none match, it's likely a development clone - keep as 'local' (highest priority)
79-
80-
const monorepoPlugins = scanMonorepoSubdirs(monorepoDir, monorepoLocation);
81-
for (const [name, descriptor] of monorepoPlugins.entries()) {
82-
if (allPlugins.has(name)) {
83-
console.log(` ⚠️ Plugin "${name}" found in ${monorepoLocation} monorepo, overrides previous`);
84-
}
85-
allPlugins.set(name, descriptor);
86-
}
87-
}
88-
8966
return allPlugins;
9067
}
9168

0 commit comments

Comments
 (0)