recess-cli 3.26.0 → 3.28.0

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
@@ -13,6 +13,8 @@ import { runAppsCommand } from "./commands/apps.js";
13
13
  import { runChannelsCommand } from "./commands/channels.js";
14
14
  import { runChatLogsCommand } from "./commands/chat-logs.js";
15
15
  import { runLibraryBooksCommand } from "./commands/library-books.js";
16
+ import { runMathCurriculaCommand } from "./commands/math-curricula.js";
17
+ import { runReadingChecksCommand } from "./commands/reading-checks.js";
16
18
  import { runChallengeOfTheWeekCommand } from "./commands/challenge-of-the-week.js";
17
19
  import { runDbCommand } from "./commands/db.js";
18
20
  import { runRoomsCommand } from "./commands/rooms.js";
@@ -6048,6 +6050,12 @@ export async function executeRecessCommand(argv, options = {}) {
6048
6050
  if (noun === "library-books") {
6049
6051
  return runLibraryBooksCommand({ parsed, api, writeCommand });
6050
6052
  }
6053
+ if (noun === "math-curricula") {
6054
+ return runMathCurriculaCommand({ parsed, api, writeCommand });
6055
+ }
6056
+ if (noun === "reading-checks") {
6057
+ return runReadingChecksCommand({ parsed, api, writeCommand });
6058
+ }
6051
6059
  if (noun === "challenge-of-the-week") {
6052
6060
  return runChallengeOfTheWeekCommand({ parsed, api, writeCommand });
6053
6061
  }
@@ -280,6 +280,7 @@ const FAMILY_AI_COMMANDS = new Set([
280
280
  "goals queue set",
281
281
  "goals unarchive",
282
282
  "library-books add",
283
+ "library-books delete",
283
284
  "library-books get",
284
285
  "library-books list",
285
286
  "library-books search",
@@ -312,6 +313,13 @@ const STAFF_COMMANDS = new Set([
312
313
  "challenge-of-the-week queue",
313
314
  "challenge-of-the-week show",
314
315
  "challenge-of-the-week swap",
316
+ "library-books set-stage",
317
+ "library-books tag",
318
+ "math-curricula link",
319
+ "math-curricula list",
320
+ "math-curricula unlink",
321
+ "reading-checks passages list",
322
+ "reading-checks passages set-text",
315
323
  "students mastery",
316
324
  "apps link",
317
325
  "apps links",
@@ -1,7 +1,7 @@
1
1
  import { unwrap } from "../api.js";
2
2
  import { flagNumber, flagString } from "../args.js";
3
3
  import { CliError } from "../errors.js";
4
- import { assertChoice, positional } from "./shared.js";
4
+ import { assertChoice, flagIdList, flagInteger, positional, } from "./shared.js";
5
5
  const MD5 = /^[0-9a-f]{32}$/i;
6
6
  async function resolveAddBody({ parsed, api }) {
7
7
  const fromSearch = flagNumber(parsed, "from-search");
@@ -73,10 +73,56 @@ export async function runLibraryBooksCommand(context) {
73
73
  }
74
74
  if (verb === "list") {
75
75
  const q = flagString(parsed, "q");
76
+ const stage = flagInteger(parsed, "stage", { min: 1, max: 5 });
77
+ const tag = flagString(parsed, "tag");
76
78
  return unwrap(await api.client.GET("/library-books/", {
77
- params: { query: q === undefined ? {} : { q } },
79
+ params: {
80
+ query: {
81
+ ...(q === undefined ? {} : { q }),
82
+ ...(stage === undefined ? {} : { stage }),
83
+ ...(tag === undefined ? {} : { tag }),
84
+ },
85
+ },
78
86
  }));
79
87
  }
88
+ if (verb === "set-stage") {
89
+ const id = positional(parsed, 2, "library book ID");
90
+ const raw = positional(parsed, 3, "stage (1-5 or none)");
91
+ const readingStage = raw === "none"
92
+ ? null
93
+ : Number(assertChoice(raw, ["1", "2", "3", "4", "5"], "stage"));
94
+ const body = { readingStage };
95
+ return writeCommand(parsed, {
96
+ action: "set a library book's reader stage",
97
+ target: { id },
98
+ request: body,
99
+ details: {
100
+ consequence: readingStage === null
101
+ ? "The book leaves the reading plan."
102
+ : `The book shows on the stage ${readingStage} reading plan.`,
103
+ },
104
+ }, async () => unwrap(await api.client.PATCH("/library-books/{id}", {
105
+ params: { path: { id } },
106
+ body,
107
+ })));
108
+ }
109
+ if (verb === "tag") {
110
+ const id = positional(parsed, 2, "library book ID");
111
+ const tags = parsed.flags.has("clear") ? [] : flagIdList(parsed, "tags");
112
+ if (tags.length === 0 && !parsed.flags.has("clear")) {
113
+ throw new CliError("invalid_arguments", "Pass --tags a,b or --clear.");
114
+ }
115
+ const body = { tags };
116
+ return writeCommand(parsed, {
117
+ action: "replace a library book's tags",
118
+ target: { id },
119
+ request: body,
120
+ details: { consequence: "Replaces every tag on the book." },
121
+ }, async () => unwrap(await api.client.PATCH("/library-books/{id}", {
122
+ params: { path: { id } },
123
+ body,
124
+ })));
125
+ }
80
126
  if (verb === "get") {
81
127
  const id = positional(parsed, 2, "library book ID");
82
128
  const book = unwrap(await api.client.GET("/library-books/{id}", {
@@ -100,6 +146,24 @@ export async function runLibraryBooksCommand(context) {
100
146
  },
101
147
  }, async () => unwrap(await api.client.POST("/library-books/from-web", { body })));
102
148
  }
103
- throw new CliError("invalid_arguments", "Use library-books search|list|get|add.");
149
+ if (verb === "delete") {
150
+ const id = positional(parsed, 2, "library book ID");
151
+ const book = unwrap(await api.client.GET("/library-books/{id}", {
152
+ params: { path: { id } },
153
+ }));
154
+ return writeCommand(parsed, {
155
+ action: "delete a book from the shared library",
156
+ target: { id: book.id },
157
+ request: { id: book.id },
158
+ details: {
159
+ title: book.title,
160
+ author: book.author,
161
+ consequence: "Removes the book from the library; goals already built from it keep their chapters and PDF.",
162
+ },
163
+ }, async () => unwrap(await api.client.DELETE("/library-books/{id}", {
164
+ params: { path: { id: book.id } },
165
+ })));
166
+ }
167
+ throw new CliError("invalid_arguments", "Use library-books search|list|get|add|delete|set-stage|tag.");
104
168
  }
105
169
  //# sourceMappingURL=library-books.js.map
@@ -0,0 +1,42 @@
1
+ import { unwrap } from "../api.js";
2
+ import { CliError } from "../errors.js";
3
+ import { positional } from "./shared.js";
4
+ /** The server validates the key; `math-curricula list` shows the options. */
5
+ function curriculumArg(context) {
6
+ return positional(context.parsed, 2, "curriculum").toUpperCase();
7
+ }
8
+ export async function runMathCurriculaCommand(context) {
9
+ const { parsed, api, writeCommand } = context;
10
+ const verb = parsed.positionals[1];
11
+ if (verb === "list") {
12
+ return unwrap(await api.client.GET("/tutor/math-curricula/goals"));
13
+ }
14
+ if (verb === "link") {
15
+ const curriculum = curriculumArg(context);
16
+ const template = positional(parsed, 3, "goal template slug or ID");
17
+ const body = { template };
18
+ return writeCommand(parsed, {
19
+ action: "link a goal template to a math curriculum",
20
+ target: { curriculum, template },
21
+ request: body,
22
+ details: {
23
+ consequence: "Every later math review that picks this curriculum assigns the goal to the kid.",
24
+ },
25
+ }, async () => unwrap(await api.client.POST("/tutor/math-curricula/{curriculum}/goals", {
26
+ params: { path: { curriculum } },
27
+ body,
28
+ })));
29
+ }
30
+ if (verb === "unlink") {
31
+ const curriculum = curriculumArg(context);
32
+ const goalTemplateId = positional(parsed, 3, "goal template ID");
33
+ return writeCommand(parsed, {
34
+ action: "unlink a goal template from a math curriculum",
35
+ target: { curriculum, goalTemplateId },
36
+ request: {},
37
+ details: { consequence: "Goals kids already have stay." },
38
+ }, async () => unwrap(await api.client.DELETE("/tutor/math-curricula/{curriculum}/goals/{goalTemplateId}", { params: { path: { curriculum, goalTemplateId } } })));
39
+ }
40
+ throw new CliError("invalid_arguments", "Use math-curricula list|link|unlink.");
41
+ }
42
+ //# sourceMappingURL=math-curricula.js.map
@@ -0,0 +1,63 @@
1
+ import fs from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { unwrap } from "../api.js";
4
+ import { flagString, hasFlag } from "../args.js";
5
+ import { CliError } from "../errors.js";
6
+ import { positional } from "./shared.js";
7
+ const MAX_TEXT_CHARS = 10_000;
8
+ /** Plain text is read as is; the server pulls the text out of Word and PDF
9
+ * files, OCR'ing scans, so the preview shows exactly what kids will read. */
10
+ async function readPassageFile(context, file) {
11
+ const resolved = path.resolve(file);
12
+ if (!/\.(docx|pdf)$/i.test(file)) {
13
+ return (await fs.readFile(resolved, "utf8")).trim();
14
+ }
15
+ const bytes = await fs.readFile(resolved);
16
+ const { text } = unwrap(await context.api.client.POST("/reading-checks/passages/extract", {
17
+ body: {
18
+ fileName: path.basename(file),
19
+ base64: bytes.toString("base64"),
20
+ },
21
+ }));
22
+ return text.trim();
23
+ }
24
+ export async function runReadingChecksCommand(context) {
25
+ const { parsed, api, writeCommand } = context;
26
+ const [, group, verb] = parsed.positionals;
27
+ if (group === "passages" && verb === "list") {
28
+ return unwrap(await api.client.GET("/reading-checks/passages"));
29
+ }
30
+ if (group === "passages" && verb === "set-text") {
31
+ const passageId = positional(parsed, 3, "passage ID");
32
+ const file = flagString(parsed, "file");
33
+ const clear = hasFlag(parsed, "clear");
34
+ if (Boolean(file) === clear) {
35
+ throw new CliError("invalid_arguments", "Pass exactly one of --file <path> or --clear.");
36
+ }
37
+ const text = file ? await readPassageFile(context, file) : null;
38
+ if (text === "") {
39
+ throw new CliError("invalid_arguments", `${file} is empty.`);
40
+ }
41
+ if (text && text.length > MAX_TEXT_CHARS) {
42
+ throw new CliError("invalid_arguments", `${file} has ${text.length} characters; a passage is at most ${MAX_TEXT_CHARS}.`);
43
+ }
44
+ const body = { text };
45
+ return writeCommand(parsed, {
46
+ action: text
47
+ ? "set the page a kid reads aloud for a reading-check passage"
48
+ : "clear a reading-check passage's page text",
49
+ target: { passageId },
50
+ request: body,
51
+ details: {
52
+ consequence: text
53
+ ? "Checks on this passage show this page and score the read against it."
54
+ : "Kids read this passage from the book; the read is scored on pace alone.",
55
+ },
56
+ }, async () => unwrap(await api.client.PUT("/reading-checks/passages/{passageId}", {
57
+ params: { path: { passageId } },
58
+ body,
59
+ })));
60
+ }
61
+ throw new CliError("invalid_arguments", "Use reading-checks passages list|set-text.");
62
+ }
63
+ //# sourceMappingURL=reading-checks.js.map
package/dist/help.js CHANGED
@@ -628,11 +628,19 @@ Usage:
628
628
  [--visibility PUBLIC|STAFF] [--confirm]
629
629
  recess [--json] tutor-templates delete <slug> [--confirm]
630
630
  recess [--json] library-books search <query>
631
- recess [--json] library-books list [--q TEXT]
631
+ recess [--json] library-books list [--q TEXT] [--stage 1-5] [--tag TEXT]
632
632
  recess [--json] library-books get <book-id>
633
+ recess [--json] library-books set-stage <book-id> <1-5|none> [--confirm]
634
+ recess [--json] library-books tag <book-id> (--tags a,b | --clear) [--confirm]
633
635
  recess [--json] library-books add (--md5 <md5> --title TEXT [--author TEXT]
634
636
  --extension pdf|epub [--cover-url <url>] | --from-search N --query TEXT)
635
637
  [--confirm]
638
+ recess [--json] library-books delete <book-id> [--confirm]
639
+ recess [--json] math-curricula list
640
+ recess [--json] math-curricula link <curriculum> <template> [--confirm]
641
+ recess [--json] math-curricula unlink <curriculum> <template-id> [--confirm]
642
+ recess [--json] reading-checks passages list
643
+ recess [--json] reading-checks passages set-text <passage-id> (--file <path> | --clear) [--confirm]
636
644
  recess [--json] challenge-of-the-week list [--past N] [--ahead N]
637
645
  recess [--json] challenge-of-the-week show <week>
638
646
  recess [--json] challenge-of-the-week queue <template> --week <week> [--note TEXT] [--confirm]
@@ -1481,6 +1489,14 @@ export const COMMAND_SUMMARIES = {
1481
1489
  "library-books list": "List books in the shared library.",
1482
1490
  "library-books get": "Read one library book: status, pages, chapters.",
1483
1491
  "library-books add": "Add a web search result to the book library.",
1492
+ "library-books delete": "Remove a book from the book library.",
1493
+ "library-books set-stage": "Put a library book on a reader stage's reading plan (ADMIN, GUIDE).",
1494
+ "library-books tag": "Replace a library book's tags (ADMIN, GUIDE).",
1495
+ "math-curricula list": "Each math curriculum and its linked goal templates.",
1496
+ "math-curricula link": "Link a goal template to a math curriculum; math reviews that pick it assign the goal.",
1497
+ "math-curricula unlink": "Unlink a goal template from a math curriculum.",
1498
+ "reading-checks passages list": "Each reading-check passage, its stage, and whether its page text is set.",
1499
+ "reading-checks passages set-text": "Set the page a kid reads aloud for a passage, from a text, Word (.docx) or PDF file (scans are OCR'd); --clear goes back to reading from the book.",
1484
1500
  "challenge-of-the-week list": "List Challenge of the Week picks: past, this week, upcoming, and the bench.",
1485
1501
  "challenge-of-the-week show": "Read one week's Challenge of the Week pick and note.",
1486
1502
  "challenge-of-the-week queue": "Queue a challenge for an empty week, with an optional note for kids.",
@@ -1549,7 +1565,9 @@ export const NOUN_SUMMARIES = {
1549
1565
  memories: "Kid memory files and the context Rocky sees.",
1550
1566
  rocky: "A kid's Rocky personality settings; free Rocky grants and budgets.",
1551
1567
  "tutor-templates": "Tutor templates and their assignment to kids.",
1552
- "library-books": "Book library: search the web, add books, read status.",
1568
+ "library-books": "Book library: search the web, add and delete books, read status, reader stages, tags.",
1569
+ "math-curricula": "Math curricula and the goals a math review assigns (ADMIN, GUIDE).",
1570
+ "reading-checks": "Reading-check passages and the page text kids read (ADMIN, GUIDE).",
1553
1571
  "challenge-of-the-week": "Challenge of the Week: queue weekly picks and the bench (ADMIN, GUIDE).",
1554
1572
  mastery: "Mastery graphs and the content linked to them.",
1555
1573
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "recess-cli",
3
- "version": "3.26.0",
3
+ "version": "3.28.0",
4
4
  "description": "Safe Recess administration and family AI tools from the command line.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {