@tostudy-ai/cli 0.16.2 → 0.16.3

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/dist/cli.js CHANGED
@@ -2913,9 +2913,6 @@ __export(resolve_exports, {
2913
2913
  import fs7 from "node:fs/promises";
2914
2914
  import path9 from "node:path";
2915
2915
  import os6 from "node:os";
2916
- function courseSlug(title) {
2917
- return title.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "").slice(0, 60);
2918
- }
2919
2916
  async function resolveWorkspace(courseTitle, basePath = DEFAULT_BASE) {
2920
2917
  const slug = courseSlug(courseTitle);
2921
2918
  const candidate = path9.join(basePath, slug);
@@ -3001,11 +2998,13 @@ async function resolveActiveCourseFromWorkspace(options = {}) {
3001
2998
  const result = await findWorkspaceState2(options.cwd, options.homeDir);
3002
2999
  return result?.state ?? null;
3003
3000
  }
3004
- var DEFAULT_BASE, resolveActiveCourseWithOverride;
3001
+ var DEFAULT_BASE, courseSlug, resolveActiveCourseWithOverride;
3005
3002
  var init_resolve = __esm({
3006
3003
  "src/workspace/resolve.ts"() {
3007
3004
  "use strict";
3005
+ init_slug();
3008
3006
  DEFAULT_BASE = path9.join(os6.homedir(), "study");
3007
+ courseSlug = slugify;
3009
3008
  resolveActiveCourseWithOverride = resolveActiveCourseFromWorkspace;
3010
3009
  }
3011
3010
  });
@@ -3197,7 +3196,7 @@ var CLI_VERSION;
3197
3196
  var init_version = __esm({
3198
3197
  "src/version.ts"() {
3199
3198
  "use strict";
3200
- CLI_VERSION = true ? "0.16.2" : "0.7.1";
3199
+ CLI_VERSION = true ? "0.16.3" : "0.7.1";
3201
3200
  }
3202
3201
  });
3203
3202
 
@@ -20404,7 +20403,9 @@ function getStarterCode(structuredData) {
20404
20403
  return data?.starterCode ?? null;
20405
20404
  }
20406
20405
  async function extractExercise(input2) {
20407
- const { lessonData, exerciseTier, workspacePath } = input2;
20406
+ const { exerciseTier, workspacePath } = input2;
20407
+ const paths = input2.workspacePaths ?? { workspace: workspacePath, vault: "$VAULT" };
20408
+ const lessonData = resolveWorkspaceTokens(input2.lessonData, paths);
20408
20409
  const moduleDir = `${padOrder(lessonData.moduleOrder)}-${lessonData.moduleSlug}`;
20409
20410
  const lessonDir = `${padOrder(lessonData.lessonOrder)}-${lessonData.lessonSlug}`;
20410
20411
  const exercisePath = path16.join(workspacePath, "exercises", moduleDir, lessonDir);
@@ -20522,6 +20523,7 @@ var init_extract_exercise = __esm({
20522
20523
  "../../packages/tostudy-core/src/workspace/extract-exercise.ts"() {
20523
20524
  "use strict";
20524
20525
  init_templates();
20526
+ init_workspace_tokens();
20525
20527
  }
20526
20528
  });
20527
20529
 
@@ -20822,7 +20824,10 @@ var init_export = __esm({
20822
20824
  const result = await extractExercise({
20823
20825
  lessonData,
20824
20826
  exerciseTier: tier,
20825
- workspacePath: ws.workspacePath
20827
+ workspacePath: ws.workspacePath,
20828
+ // Same pair `output()` prints with (GH #1278), so the exercise files on
20829
+ // disk and the lesson text on screen name the same folder (GH #1284).
20830
+ workspacePaths: cliWorkspacePaths(ws.workspacePath, activeCourse.courseTitle)
20826
20831
  });
20827
20832
  if (opts.json) {
20828
20833
  process.stdout.write(JSON.stringify(result, null, 2) + "\n");
@@ -20972,6 +20977,7 @@ var init_vault2 = __esm({
20972
20977
  "use strict";
20973
20978
  init_dist();
20974
20979
  init_vault();
20980
+ init_workspace_tokens();
20975
20981
  init_courses();
20976
20982
  init_http();
20977
20983
  init_guards();
@@ -21017,12 +21023,11 @@ var init_vault2 = __esm({
21017
21023
  if (!data.success) {
21018
21024
  throw new Error("API returned success: false");
21019
21025
  }
21020
- const result = await writeVaultFiles(
21026
+ const files = resolveWorkspaceTokens(
21021
21027
  data.files,
21022
- vaultOutputPath,
21023
- activeCourse.courseId,
21024
- slug
21028
+ cliWorkspacePaths(workspacePath, activeCourse.courseTitle)
21025
21029
  );
21030
+ const result = await writeVaultFiles(files, vaultOutputPath, activeCourse.courseId, slug);
21026
21031
  logger21.info("Vault generated", {
21027
21032
  courseId: activeCourse.courseId,
21028
21033
  vaultPath: result.vaultPath,