@learnpack/learnpack 5.0.186 → 5.0.191

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/README.md CHANGED
@@ -21,7 +21,7 @@ $ npm install -g @learnpack/learnpack
21
21
  $ learnpack COMMAND
22
22
  running command...
23
23
  $ learnpack (-v|--version|version)
24
- @learnpack/learnpack/5.0.186 win32-x64 node-v22.15.0
24
+ @learnpack/learnpack/5.0.191 win32-x64 node-v22.15.0
25
25
  $ learnpack --help [COMMAND]
26
26
  USAGE
27
27
  $ learnpack COMMAND
@@ -80,7 +80,7 @@ DESCRIPTION
80
80
  12. If there is a file within the exercises folder but not inside of any particular exercise's folder. (Warning)
81
81
  ```
82
82
 
83
- _See code: [src\commands\audit.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.186/src\commands\audit.ts)_
83
+ _See code: [src\commands\audit.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.191/src\commands\audit.ts)_
84
84
 
85
85
  ## `learnpack breakToken`
86
86
 
@@ -95,7 +95,7 @@ OPTIONS
95
95
  -y, --yes Skip all prompts and initialize an empty project
96
96
  ```
97
97
 
98
- _See code: [src\commands\breakToken.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.186/src\commands\breakToken.ts)_
98
+ _See code: [src\commands\breakToken.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.191/src\commands\breakToken.ts)_
99
99
 
100
100
  ## `learnpack clean`
101
101
 
@@ -110,7 +110,7 @@ DESCRIPTION
110
110
  Extra documentation goes here
111
111
  ```
112
112
 
113
- _See code: [src\commands\clean.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.186/src\commands\clean.ts)_
113
+ _See code: [src\commands\clean.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.191/src\commands\clean.ts)_
114
114
 
115
115
  ## `learnpack download [PACKAGE]`
116
116
 
@@ -128,7 +128,7 @@ DESCRIPTION
128
128
  Extra documentation goes here
129
129
  ```
130
130
 
131
- _See code: [src\commands\download.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.186/src\commands\download.ts)_
131
+ _See code: [src\commands\download.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.191/src\commands\download.ts)_
132
132
 
133
133
  ## `learnpack help [COMMAND]`
134
134
 
@@ -160,7 +160,7 @@ OPTIONS
160
160
  -y, --yes Skip all prompts and initialize an empty project
161
161
  ```
162
162
 
163
- _See code: [src\commands\init.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.186/src\commands\init.ts)_
163
+ _See code: [src\commands\init.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.191/src\commands\init.ts)_
164
164
 
165
165
  ## `learnpack login [PACKAGE]`
166
166
 
@@ -178,7 +178,7 @@ DESCRIPTION
178
178
  Extra documentation goes here
179
179
  ```
180
180
 
181
- _See code: [src\commands\login.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.186/src\commands\login.ts)_
181
+ _See code: [src\commands\login.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.191/src\commands\login.ts)_
182
182
 
183
183
  ## `learnpack logout [PACKAGE]`
184
184
 
@@ -196,7 +196,7 @@ DESCRIPTION
196
196
  Extra documentation goes here
197
197
  ```
198
198
 
199
- _See code: [src\commands\logout.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.186/src\commands\logout.ts)_
199
+ _See code: [src\commands\logout.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.191/src\commands\logout.ts)_
200
200
 
201
201
  ## `learnpack plugins`
202
202
 
@@ -328,7 +328,7 @@ OPTIONS
328
328
  -s, --strict strict mode
329
329
  ```
330
330
 
331
- _See code: [src\commands\publish.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.186/src\commands\publish.ts)_
331
+ _See code: [src\commands\publish.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.191/src\commands\publish.ts)_
332
332
 
333
333
  ## `learnpack serve`
334
334
 
@@ -345,7 +345,7 @@ OPTIONS
345
345
  -y, --yes Skip all prompts and initialize an empty project
346
346
  ```
347
347
 
348
- _See code: [src\commands\serve.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.186/src\commands\serve.ts)_
348
+ _See code: [src\commands\serve.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.191/src\commands\serve.ts)_
349
349
 
350
350
  ## `learnpack start`
351
351
 
@@ -367,7 +367,7 @@ OPTIONS
367
367
  -y, --yes Skip all prompts and initialize an empty project
368
368
  ```
369
369
 
370
- _See code: [src\commands\start.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.186/src\commands\start.ts)_
370
+ _See code: [src\commands\start.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.191/src\commands\start.ts)_
371
371
 
372
372
  ## `learnpack test [EXERCISESLUG]`
373
373
 
@@ -384,7 +384,7 @@ OPTIONS
384
384
  -y, --yes Skip all prompts and initialize an empty project
385
385
  ```
386
386
 
387
- _See code: [src\commands\test.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.186/src\commands\test.ts)_
387
+ _See code: [src\commands\test.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.191/src\commands\test.ts)_
388
388
 
389
389
  ## `learnpack translate`
390
390
 
@@ -398,7 +398,7 @@ OPTIONS
398
398
  -y, --yes Skip all prompts and initialize an empty project
399
399
  ```
400
400
 
401
- _See code: [src\commands\translate.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.186/src\commands\translate.ts)_
401
+ _See code: [src\commands\translate.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.191/src\commands\translate.ts)_
402
402
  <!-- commandsstop -->
403
403
 
404
404
  > > > > > > > 0cb3e56d84c197f9d008836bb573eade212b7e57
@@ -63,7 +63,7 @@ async function processExercise(rigoToken, steps, packageContext, exercise, exerc
63
63
  tutorial_description: packageContext,
64
64
  lesson_description: description,
65
65
  kind: kind.toLowerCase(),
66
- });
66
+ }, "learnpack-lesson-writer");
67
67
  const duration = durationByKind[kind.toLowerCase()];
68
68
  let attempts = 0;
69
69
  let readability = (0, creatorUtilities_1.checkReadability)(readme.parsed.content, 200, duration || 1);
@@ -77,7 +77,7 @@ async function processExercise(rigoToken, steps, packageContext, exercise, exerc
77
77
  expected_number_words: PARAMS.max_words.toString(),
78
78
  fkgl_results: JSON.stringify(readability.fkglResult),
79
79
  expected_grade_level: PARAMS.expected_grade_level,
80
- });
80
+ }, "learnpack-lesson-writer");
81
81
  // console.log("REDUCED README START", reducedReadme, "REDUCED README END")
82
82
  if (!reducedReadme)
83
83
  break;
@@ -17,7 +17,7 @@ export declare const createLearnJson: (courseInfo: FormState) => {
17
17
  preview: string;
18
18
  };
19
19
  export declare const processImage: (bucket: Bucket, tutorialDir: string, url: string, description: string, rigoToken: string) => Promise<boolean>;
20
- export declare function processExercise(bucket: Bucket, rigoToken: string, steps: Lesson[], packageContext: string, exercise: Lesson, exercisesDir: string, courseSlug: string): Promise<string>;
20
+ export declare function processExercise(bucket: Bucket, rigoToken: string, steps: Lesson[], packageContext: string, exercise: Lesson, exercisesDir: string, courseSlug: string, purposeSlug: string): Promise<string>;
21
21
  interface Lesson {
22
22
  id: string;
23
23
  uid: string;
@@ -42,6 +42,7 @@ type FormState = {
42
42
  currentStep: string;
43
43
  title: string;
44
44
  technologies?: string[];
45
+ purpose: string;
45
46
  };
46
47
  export default class ServeCommand extends SessionCommand {
47
48
  static description: string;
@@ -74,9 +74,9 @@ const uploadImageToBucket = async (bucket, url, path) => {
74
74
  });
75
75
  };
76
76
  const PARAMS = {
77
- expected_grade_level: "7",
78
- max_fkgl: 9,
79
- max_words: 200,
77
+ expected_grade_level: "8",
78
+ max_fkgl: 10,
79
+ max_words: 250,
80
80
  max_rewrite_attempts: 2,
81
81
  max_title_length: 50,
82
82
  };
@@ -104,7 +104,7 @@ const createInitialSidebar = async (slugs) => {
104
104
  }
105
105
  return sidebar;
106
106
  };
107
- async function processExercise(bucket, rigoToken, steps, packageContext, exercise, exercisesDir, courseSlug) {
107
+ async function processExercise(bucket, rigoToken, steps, packageContext, exercise, exercisesDir, courseSlug, purposeSlug) {
108
108
  // const tid = toast.loading("Generating lesson...")
109
109
  const exSlug = (0, creatorUtilities_2.slugify)(exercise.id + "-" + exercise.title);
110
110
  console.log("exSlug", exSlug);
@@ -124,7 +124,7 @@ async function processExercise(bucket, rigoToken, steps, packageContext, exercis
124
124
  tutorial_description: packageContext,
125
125
  lesson_description: exercise.description,
126
126
  kind: exercise.type.toLowerCase(),
127
- });
127
+ }, purposeSlug);
128
128
  const duration = exercise.duration;
129
129
  let attempts = 0;
130
130
  let readability = (0, creatorUtilities_2.checkReadability)(readme.parsed.content, 200, duration || 1);
@@ -142,10 +142,10 @@ async function processExercise(bucket, rigoToken, steps, packageContext, exercis
142
142
  expected_number_words: PARAMS.max_words.toString(),
143
143
  fkgl_results: JSON.stringify(readability.fkglResult),
144
144
  expected_grade_level: PARAMS.expected_grade_level,
145
- });
145
+ }, purposeSlug);
146
146
  if (!reducedReadme)
147
147
  break;
148
- readability = (0, creatorUtilities_2.checkReadability)(reducedReadme.parsed.content, PARAMS.max_words, duration || 1);
148
+ readability = (0, creatorUtilities_2.checkReadability)(reducedReadme.parsed.content, PARAMS.max_words, duration || 2);
149
149
  attempts++;
150
150
  }
151
151
  await uploadFileToBucket(bucket, readability.newMarkdown, `${targetDir}/${readmeFilename}`);
@@ -354,51 +354,6 @@ class ServeCommand extends SessionCommand_1.default {
354
354
  return res.status(500).json({ error: error.message });
355
355
  }
356
356
  });
357
- app.post("/read-document", upload.single("file"), async (req, res) => {
358
- console.log("READING A DOCUMENT");
359
- const publicToken = req.header("x-public-token");
360
- if (!publicToken) {
361
- return res.status(400).json({ error: "Public token is required" });
362
- }
363
- try {
364
- // eslint-disable-next-line
365
- // @ts-ignore
366
- if (!req.file) {
367
- return res.status(400).json({ error: "Missing file" });
368
- }
369
- console.log("PUBLIC TOKEN", publicToken);
370
- const resultId = `document-read-${Date.now()}-${Math.floor(Math.random() * 1e6)}`;
371
- const webhookUrl = `${deploymentURL}/notifications/${resultId}`;
372
- console.log("WEBHOOK URL", webhookUrl);
373
- // Construir form-data para enviar al servidor proxy
374
- const formData = new FormData();
375
- // eslint-disable-next-line
376
- // @ts-ignore
377
- formData.append("file", req.file.buffer, {
378
- // eslint-disable-next-line
379
- // @ts-ignore
380
- filename: req.file.originalname,
381
- // eslint-disable-next-line
382
- // @ts-ignore
383
- contentType: req.file.mimetype,
384
- });
385
- formData.append("webhook_callback_url", webhookUrl);
386
- try {
387
- const response = await axios_1.default.post(`${api_1.RIGOBOT_HOST}/v1/learnpack/public/tools/read-document`, formData, {
388
- headers: Object.assign(Object.assign({}, formData.getHeaders()), { Authorization: `Token ${publicToken.trim()}` }),
389
- });
390
- }
391
- catch (error) {
392
- console.error("❌ Error in /read-document:", error);
393
- return res.status(500).json({ error: error.message });
394
- }
395
- return res.json({ notificationId: resultId, status: "PROCESSING" });
396
- }
397
- catch (error) {
398
- console.error("❌ Error in /read-document:", error);
399
- return res.status(500).json({ error: error.message });
400
- }
401
- });
402
357
  app.post("/notifications/:id", async (req, res) => {
403
358
  console.log("Receiving a webhook to notification id", req.params.id);
404
359
  const { id } = req.params;
@@ -700,7 +655,8 @@ class ServeCommand extends SessionCommand_1.default {
700
655
  }
701
656
  await uploadFileToBucket(bucket, JSON.stringify(learnJson), `${tutorialDir}/learn.json`);
702
657
  console.log("🔄 Learn.json uploaded to bucket to", tutorialDir);
703
- const lessonsPromises = syllabus.lessons.map(lesson => processExercise(bucket, rigoToken, syllabus.lessons, JSON.stringify(syllabus.courseInfo), lesson, tutorialDir + "/exercises", (0, creatorUtilities_2.slugify)(syllabus.courseInfo.title)));
658
+ console.log("🔄 Processing lessons with purpose", syllabus.courseInfo.purpose);
659
+ const lessonsPromises = syllabus.lessons.map(lesson => processExercise(bucket, rigoToken, syllabus.lessons, JSON.stringify(syllabus.courseInfo), lesson, tutorialDir + "/exercises", (0, creatorUtilities_2.slugify)(syllabus.courseInfo.title), syllabus.courseInfo.purpose));
704
660
  const readmeContents = await Promise.all(lessonsPromises);
705
661
  let imagesArray = [];
706
662
  for (const content of readmeContents) {