ai-hero-cli 0.2.11 → 0.2.13

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/bin.cjs +52 -15
  2. package/package.json +1 -1
package/bin.cjs CHANGED
@@ -84342,6 +84342,15 @@ var GitService = class extends Effect_exports.Service()(
84342
84342
  );
84343
84343
  return (yield* Command_exports2.string(command2)).trim();
84344
84344
  });
84345
+ const runCommandWithExitCode = Effect_exports.fn(
84346
+ "runCommandWithExitCode"
84347
+ )(function* (...commandArgs) {
84348
+ const cwd = yield* Config_exports.string("cwd");
84349
+ const command2 = Command_exports2.make(...commandArgs).pipe(
84350
+ Command_exports2.workingDirectory(cwd)
84351
+ );
84352
+ return yield* Command_exports2.exitCode(command2);
84353
+ });
84345
84354
  return {
84346
84355
  ensureIsGitRepo: Effect_exports.fn("ensureIsGitRepo")(
84347
84356
  function* () {
@@ -84402,6 +84411,19 @@ var GitService = class extends Effect_exports.Service()(
84402
84411
  })
84403
84412
  );
84404
84413
  }
84414
+ yield* runCommandWithExitCode(
84415
+ "git",
84416
+ "branch",
84417
+ "-D",
84418
+ targetBranch
84419
+ );
84420
+ yield* runCommandWithExitCode(
84421
+ "git",
84422
+ "branch",
84423
+ "--track",
84424
+ targetBranch,
84425
+ `upstream/${targetBranch}`
84426
+ );
84405
84427
  }),
84406
84428
  getCurrentBranch: Effect_exports.fn("getCurrentBranch")(
84407
84429
  function* () {
@@ -84416,17 +84438,7 @@ var GitService = class extends Effect_exports.Service()(
84416
84438
  )).trim();
84417
84439
  }
84418
84440
  ),
84419
- runCommandWithExitCode: Effect_exports.fn(
84420
- "runCommandWithExitCode"
84421
- )(function* (...commandArgs) {
84422
- const cwd = yield* Config_exports.string("cwd");
84423
- const command2 = Command_exports2.make(...commandArgs).pipe(
84424
- Command_exports2.workingDirectory(cwd),
84425
- Command_exports2.stdout("inherit"),
84426
- Command_exports2.stderr("inherit")
84427
- );
84428
- return yield* Command_exports2.exitCode(command2);
84429
- }),
84441
+ runCommandWithExitCode,
84430
84442
  runCommandWithString
84431
84443
  };
84432
84444
  }),
@@ -85001,7 +85013,28 @@ var logReadmeFile = Effect_exports.fn("logReadmeFile")(
85001
85013
  }
85002
85014
  );
85003
85015
  var normalizeExerciseNumber = (str) => {
85004
- return str.replace(/\b0+(\d)/g, "$1");
85016
+ const variations = /* @__PURE__ */ new Set();
85017
+ variations.add(str);
85018
+ const dotIndex = str.indexOf(".");
85019
+ if (dotIndex !== -1) {
85020
+ const beforeDot = str.slice(0, dotIndex);
85021
+ const afterDot = str.slice(dotIndex + 1);
85022
+ variations.add(str);
85023
+ variations.add(beforeDot + afterDot);
85024
+ const beforeDotNoZeros = beforeDot.replace(/^0+/, "") || "0";
85025
+ const afterDotNoZeros = afterDot.replace(/^0+/, "") || "0";
85026
+ variations.add(`${beforeDotNoZeros}.${afterDotNoZeros}`);
85027
+ variations.add(beforeDotNoZeros + afterDotNoZeros);
85028
+ variations.add(`${beforeDotNoZeros}.${afterDot}`);
85029
+ variations.add(`${beforeDot}.${afterDotNoZeros}`);
85030
+ variations.add(beforeDotNoZeros + afterDot);
85031
+ variations.add(beforeDot + afterDotNoZeros);
85032
+ } else {
85033
+ const noZeros = str.replace(/^0+/, "") || "0";
85034
+ variations.add(noZeros);
85035
+ variations.add(str);
85036
+ }
85037
+ return Array.from(variations);
85005
85038
  };
85006
85039
  var chooseLessonAndRunIt = (opts) => Effect_exports.gen(function* () {
85007
85040
  const lessonService = yield* LessonParserService;
@@ -85021,11 +85054,15 @@ var chooseLessonAndRunIt = (opts) => Effect_exports.gen(function* () {
85021
85054
  description: lesson.name
85022
85055
  })),
85023
85056
  suggest: async (input, choices) => {
85024
- const normalizedInput = normalizeExerciseNumber(input);
85025
85057
  return choices.filter((choice6) => {
85026
85058
  const searchText = `${choice6.title}-${choice6.description}`;
85027
- const normalizedSearchText = normalizeExerciseNumber(searchText);
85028
- return searchText.includes(input) || normalizedSearchText.includes(normalizedInput);
85059
+ if (searchText.includes(input)) {
85060
+ return true;
85061
+ }
85062
+ const searchTextVariations = normalizeExerciseNumber(searchText);
85063
+ return searchTextVariations.some(
85064
+ (variation) => variation.includes(input) || input.includes(variation)
85065
+ );
85029
85066
  });
85030
85067
  }
85031
85068
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-hero-cli",
3
- "version": "0.2.11",
3
+ "version": "0.2.13",
4
4
  "type": "module",
5
5
  "description": "The CLI used to run exercises for the AI Hero course",
6
6
  "bin": "bin.cjs",