ai-hero-cli 0.2.12 → 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 +29 -4
  2. package/package.json +1 -1
package/bin.cjs CHANGED
@@ -85013,7 +85013,28 @@ var logReadmeFile = Effect_exports.fn("logReadmeFile")(
85013
85013
  }
85014
85014
  );
85015
85015
  var normalizeExerciseNumber = (str) => {
85016
- 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);
85017
85038
  };
85018
85039
  var chooseLessonAndRunIt = (opts) => Effect_exports.gen(function* () {
85019
85040
  const lessonService = yield* LessonParserService;
@@ -85033,11 +85054,15 @@ var chooseLessonAndRunIt = (opts) => Effect_exports.gen(function* () {
85033
85054
  description: lesson.name
85034
85055
  })),
85035
85056
  suggest: async (input, choices) => {
85036
- const normalizedInput = normalizeExerciseNumber(input);
85037
85057
  return choices.filter((choice6) => {
85038
85058
  const searchText = `${choice6.title}-${choice6.description}`;
85039
- const normalizedSearchText = normalizeExerciseNumber(searchText);
85040
- 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
+ );
85041
85066
  });
85042
85067
  }
85043
85068
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-hero-cli",
3
- "version": "0.2.12",
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",