@dezkareid/osddt 1.11.8 → 1.11.10

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.
Files changed (2) hide show
  1. package/dist/index.js +34 -9
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -135,9 +135,11 @@ Use the following logic to determine the working directory:
135
135
  1. If arguments were provided, derive the feature name from them:
136
136
  - If the argument looks like a branch name (no spaces, kebab-case or slash-separated), use the last segment (after the last \`/\`, or the full value if no \`/\` is present).
137
137
  - Otherwise convert it to a feature name following the Feature Name Constraints.
138
- 2. Run \`${npxCommand} worktree-info\` (pass \`<feature-name>\` as argument if one was derived, otherwise run without arguments):
139
- - exit code **0**: parse the JSON and use the returned \`workingDir\` as the working directory.
140
- - exit code **1**: display the error output from \`worktree-info\` to the user, then **stop** and instruct them to re-run the command with the chosen feature name as an explicit argument (e.g. \`/osddt.continue <feature-name>\`).
138
+ 2. Run \`${npxCommand} worktree-info\` (pass \`<feature-name>\` as argument if one was derived, otherwise run without arguments). Parse the JSON from **stdout** and handle based on the output:
139
+ - JSON contains \`workingDir\`: use it as the working directory and continue.
140
+ - JSON contains \`{ "error": "multiple", "worktrees": [...] }\`: present the list to the user and ask them to choose a feature, then use the chosen entry's details as the working context do not re-run the command.
141
+ - JSON contains \`{ "error": "none" }\`: inform the user that no feature worktrees were found and stop.
142
+ - JSON contains \`{ "error": "not-found" }\`: inform the user that the specified feature was not found in any worktree and stop.
141
143
 
142
144
  **If \`worktree-repository\` is absent in \`.osddtrc\` (standard mode):**
143
145
 
@@ -800,7 +802,9 @@ function listFeatureWorktrees(barePath, mainBranch) {
800
802
  const featureName = path.basename(worktreePath);
801
803
  if (featureName === mainBranch)
802
804
  continue;
803
- const branch = branchMatch ? branchMatch[1].trim().replace(/^refs\/heads\//, '') : featureName;
805
+ if (!branchMatch)
806
+ continue;
807
+ const branch = branchMatch[1].trim().replace(/^refs\/heads\//, '');
804
808
  const workingDir = path.join(worktreePath, 'working-on', featureName);
805
809
  entries.push({ featureName, branch, worktreePath, workingDir });
806
810
  }
@@ -1298,6 +1302,27 @@ function startWorktreeCommand() {
1298
1302
  return cmd;
1299
1303
  }
1300
1304
 
1305
+ async function resolveWorkingDir(worktreePath, featureName) {
1306
+ const target = path.join('working-on', featureName);
1307
+ // Check root first (single repo)
1308
+ if (await fs.pathExists(path.join(worktreePath, target))) {
1309
+ return path.join(worktreePath, target);
1310
+ }
1311
+ // Search one level deep (monorepo packages)
1312
+ try {
1313
+ const entries = await fs.readdir(worktreePath);
1314
+ for (const entry of entries) {
1315
+ const candidate = path.join(worktreePath, entry, target);
1316
+ if (await fs.pathExists(candidate)) {
1317
+ return candidate;
1318
+ }
1319
+ }
1320
+ }
1321
+ catch {
1322
+ // worktreePath not accessible — fall through to default
1323
+ }
1324
+ return path.join(worktreePath, target);
1325
+ }
1301
1326
  async function runWorktreeInfo(featureName) {
1302
1327
  const cwd = process.cwd();
1303
1328
  const barePath = await resolveBarePath(cwd);
@@ -1313,25 +1338,25 @@ async function runWorktreeInfo(featureName) {
1313
1338
  if (featureName) {
1314
1339
  entry = entries.find(e => e.featureName === featureName);
1315
1340
  if (!entry) {
1316
- console.error(`No worktree found for feature: ${featureName}`);
1341
+ console.log(JSON.stringify({ error: 'not-found', featureName }));
1317
1342
  process.exit(1);
1318
1343
  }
1319
1344
  }
1320
1345
  else {
1321
1346
  if (entries.length === 0) {
1322
- console.error('No feature worktrees found.');
1347
+ console.log(JSON.stringify({ error: 'none' }));
1323
1348
  process.exit(1);
1324
1349
  }
1325
1350
  else if (entries.length === 1) {
1326
1351
  entry = entries[0];
1327
1352
  }
1328
1353
  else {
1329
- console.error('Multiple feature worktrees found. Re-run with a feature name:');
1330
- entries.forEach(e => console.error(` - ${e.featureName} (${e.branch})`));
1354
+ console.log(JSON.stringify({ error: 'multiple', worktrees: entries.map(e => ({ featureName: e.featureName, branch: e.branch })) }));
1331
1355
  process.exit(1);
1332
1356
  }
1333
1357
  }
1334
- console.log(JSON.stringify({ worktreePath: entry.worktreePath, workingDir: entry.workingDir, branch: entry.branch }));
1358
+ const workingDir = await resolveWorkingDir(entry.worktreePath, entry.featureName);
1359
+ console.log(JSON.stringify({ worktreePath: entry.worktreePath, workingDir, branch: entry.branch }));
1335
1360
  }
1336
1361
  function worktreeInfoCommand() {
1337
1362
  const cmd = new Command('worktree-info');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dezkareid/osddt",
3
- "version": "1.11.8",
3
+ "version": "1.11.10",
4
4
  "description": "Package for Spec-Driven Development workflow",
5
5
  "keywords": [
6
6
  "spec-driven",