@dezkareid/osddt 1.11.7 → 1.11.9

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 +19 -36
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -135,17 +135,19 @@ 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**: no matching worktree found fall back to the standard resolution below.
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
- **If \`worktree-repository\` is absent in \`.osddtrc\` (standard mode), or after a worktree-info fallback:**
144
+ **If \`worktree-repository\` is absent in \`.osddtrc\` (standard mode):**
143
145
 
144
146
  1. If arguments were provided, derive the feature name (same rules as above).
145
147
  2. If **no arguments were provided**:
146
148
  - List all folders under \`<project-path>/working-on/\`.
147
149
  - If there is **only one folder**, use it automatically and inform the user.
148
- - If there are **multiple folders**, present the list to the user and ask them to pick one.
150
+ - If there are **multiple folders**, display the list as a numbered enumeration, then **stop** and instruct the user to re-run the command with the chosen feature name as an explicit argument (e.g. \`/osddt.continue <feature-name>\`).
149
151
  - If there are **no folders**, inform the user that no in-progress features were found and stop.
150
152
 
151
153
  ## Instructions
@@ -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
  }
@@ -1196,7 +1200,7 @@ function remoteBranchExists(branch, cwd) {
1196
1200
  return false;
1197
1201
  }
1198
1202
  }
1199
- async function prompt$1(question) {
1203
+ async function prompt(question) {
1200
1204
  const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
1201
1205
  return new Promise((resolve) => {
1202
1206
  rl.question(question, (answer) => {
@@ -1208,7 +1212,7 @@ async function prompt$1(question) {
1208
1212
  async function createWorktree(branch, worktreePath, repoRoot, mainBranch) {
1209
1213
  if (await fs.pathExists(worktreePath)) {
1210
1214
  console.log(`\nDirectory already exists at: ${worktreePath}`);
1211
- const answer = await prompt$1('Resume or Abort? [R/a] ');
1215
+ const answer = await prompt('Resume or Abort? [R/a] ');
1212
1216
  if (answer.toLowerCase() === 'a') {
1213
1217
  console.log('Aborted.');
1214
1218
  process.exit(0);
@@ -1219,7 +1223,7 @@ async function createWorktree(branch, worktreePath, repoRoot, mainBranch) {
1219
1223
  const remoteExists = !localExists && remoteBranchExists(branch, repoRoot);
1220
1224
  if (localExists || remoteExists) {
1221
1225
  console.log(`\nBranch "${branch}" already exists ${localExists ? 'locally' : 'on remote'}.`);
1222
- const answer = await prompt$1('Resume or Abort? [R/a] ');
1226
+ const answer = await prompt('Resume or Abort? [R/a] ');
1223
1227
  if (answer.toLowerCase() === 'a') {
1224
1228
  console.log('Aborted.');
1225
1229
  process.exit(0);
@@ -1253,7 +1257,7 @@ async function runStartWorktree(featureName, options) {
1253
1257
  if (existingPath) {
1254
1258
  const workingDir = path.join(existingPath, 'working-on', featureName);
1255
1259
  console.log(`\nWorktree for "${featureName}" already exists at: ${existingPath}`);
1256
- const answer = await prompt$1('Resume or Abort? [R/a] ');
1260
+ const answer = await prompt('Resume or Abort? [R/a] ');
1257
1261
  if (answer.toLowerCase() === 'a') {
1258
1262
  console.log('Aborted.');
1259
1263
  process.exit(0);
@@ -1272,7 +1276,7 @@ async function runStartWorktree(featureName, options) {
1272
1276
  // Resolve working dir
1273
1277
  let projectPath;
1274
1278
  if (rc['repoType'] === 'monorepo') {
1275
- const pkg = options.dir ?? await prompt$1('Package path (e.g. packages/my-package): ');
1279
+ const pkg = options.dir ?? await prompt('Package path (e.g. packages/my-package): ');
1276
1280
  projectPath = path.join(worktreePath, pkg);
1277
1281
  }
1278
1282
  else {
@@ -1298,28 +1302,6 @@ function startWorktreeCommand() {
1298
1302
  return cmd;
1299
1303
  }
1300
1304
 
1301
- async function prompt(question) {
1302
- const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
1303
- return new Promise((resolve) => {
1304
- rl.question(question, (answer) => {
1305
- rl.close();
1306
- resolve(answer.trim());
1307
- });
1308
- });
1309
- }
1310
- async function selectWorktree(entries) {
1311
- console.log('\nMultiple feature worktrees found:');
1312
- entries.forEach((e, i) => {
1313
- console.log(` ${i + 1}) ${e.featureName} (${e.branch})`);
1314
- });
1315
- const answer = await prompt(`Select a feature [1-${entries.length}]: `);
1316
- const index = parseInt(answer, 10) - 1;
1317
- if (index < 0 || index >= entries.length || isNaN(index)) {
1318
- console.error('Invalid selection.');
1319
- process.exit(1);
1320
- }
1321
- return entries[index];
1322
- }
1323
1305
  async function runWorktreeInfo(featureName) {
1324
1306
  const cwd = process.cwd();
1325
1307
  const barePath = await resolveBarePath(cwd);
@@ -1335,20 +1317,21 @@ async function runWorktreeInfo(featureName) {
1335
1317
  if (featureName) {
1336
1318
  entry = entries.find(e => e.featureName === featureName);
1337
1319
  if (!entry) {
1338
- console.error(`No worktree found for feature: ${featureName}`);
1320
+ console.log(JSON.stringify({ error: 'not-found', featureName }));
1339
1321
  process.exit(1);
1340
1322
  }
1341
1323
  }
1342
1324
  else {
1343
1325
  if (entries.length === 0) {
1344
- console.error('No feature worktrees found.');
1326
+ console.log(JSON.stringify({ error: 'none' }));
1345
1327
  process.exit(1);
1346
1328
  }
1347
1329
  else if (entries.length === 1) {
1348
1330
  entry = entries[0];
1349
1331
  }
1350
1332
  else {
1351
- entry = await selectWorktree(entries);
1333
+ console.log(JSON.stringify({ error: 'multiple', worktrees: entries.map(e => ({ featureName: e.featureName, branch: e.branch })) }));
1334
+ process.exit(1);
1352
1335
  }
1353
1336
  }
1354
1337
  console.log(JSON.stringify({ worktreePath: entry.worktreePath, workingDir: entry.workingDir, branch: entry.branch }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dezkareid/osddt",
3
- "version": "1.11.7",
3
+ "version": "1.11.9",
4
4
  "description": "Package for Spec-Driven Development workflow",
5
5
  "keywords": [
6
6
  "spec-driven",