coder-config 0.47.7-beta → 0.47.9-beta

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.
package/lib/constants.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * Constants and tool path configurations
3
3
  */
4
4
 
5
- const VERSION = '0.47.7-beta';
5
+ const VERSION = '0.47.9-beta';
6
6
 
7
7
  // Tool-specific path configurations
8
8
  const TOOL_PATHS = {
@@ -402,14 +402,18 @@ function workstreamInject(installDir, silent = false) {
402
402
  }
403
403
 
404
404
  /**
405
- * Detect workstream from current directory
405
+ * Detect workstream from current directory.
406
+ * Only matches when cwd is INSIDE a workstream project (not the reverse).
407
+ * When multiple match, prefer the most specific (longest) path match.
406
408
  */
407
409
  function workstreamDetect(installDir, dir = process.cwd()) {
408
410
  const data = loadWorkstreams(installDir);
409
411
  const absDir = path.resolve(dir.replace(/^~/, process.env.HOME || ''));
410
412
 
413
+ // Only match when cwd is inside a project directory (absDir starts with project path).
414
+ // The reverse (project inside cwd) caused false matches when cwd was a parent like ~/reg/my.
411
415
  const matches = data.workstreams.filter(ws =>
412
- ws.projects.some(p => absDir.startsWith(p) || p.startsWith(absDir))
416
+ ws.projects.some(p => absDir === p || absDir.startsWith(p + path.sep))
413
417
  );
414
418
 
415
419
  if (matches.length === 0) {
@@ -420,11 +424,27 @@ function workstreamDetect(installDir, dir = process.cwd()) {
420
424
  return matches[0];
421
425
  }
422
426
 
427
+ // When multiple match, prefer the workstream with the most specific (longest) matching project path
428
+ const scored = matches.map(ws => {
429
+ const bestMatch = ws.projects
430
+ .filter(p => absDir === p || absDir.startsWith(p + path.sep))
431
+ .reduce((longest, p) => p.length > longest.length ? p : longest, '');
432
+ return { ws, score: bestMatch.length };
433
+ });
434
+ scored.sort((a, b) => b.score - a.score);
435
+
436
+ // If there's a clear winner by specificity, use it
437
+ if (scored[0].score > scored[1].score) {
438
+ return scored[0].ws;
439
+ }
440
+
441
+ // Tiebreaker: check lastUsedByProject
423
442
  if (data.lastUsedByProject && data.lastUsedByProject[absDir]) {
424
443
  const lastUsed = matches.find(ws => ws.id === data.lastUsedByProject[absDir]);
425
444
  if (lastUsed) return lastUsed;
426
445
  }
427
446
 
447
+ // Final fallback: most recently updated
428
448
  return matches.sort((a, b) =>
429
449
  new Date(b.updatedAt) - new Date(a.updatedAt)
430
450
  )[0];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coder-config",
3
- "version": "0.47.7-beta",
3
+ "version": "0.47.9-beta",
4
4
  "description": "Configuration manager for AI coding tools - Claude Code, Gemini CLI, Codex CLI, Antigravity. Manage MCPs, rules, permissions, memory, and workstreams.",
5
5
  "author": "regression.io",
6
6
  "main": "config-loader.js",