recess-cli 3.18.1 → 3.19.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
@@ -10,7 +10,6 @@ import { agentContext, buildCommandSchema, findCommandSchema, remoteCommands, sc
10
10
  import { runAdmissionsCommand } from "./commands/admissions.js";
11
11
  import { runApplicationsCommand } from "./commands/applications.js";
12
12
  import { runAppsCommand } from "./commands/apps.js";
13
- import { readAssignmentSelection, runGoalCurriculumCommand, } from "./commands/goal-curriculum.js";
14
13
  import { runChannelsCommand } from "./commands/channels.js";
15
14
  import { runChatLogsCommand } from "./commands/chat-logs.js";
16
15
  import { runDbCommand } from "./commands/db.js";
@@ -2143,6 +2142,39 @@ function remoteWriteCommand(argv, structuredInput, store) {
2143
2142
  }
2144
2143
  };
2145
2144
  }
2145
+ /** Selection files only supply explicit IDs; they never expand a filter into a mutation. */
2146
+ async function readAssignmentSelection(filePath) {
2147
+ const absolutePath = path.resolve(filePath);
2148
+ const stat = await fs.stat(absolutePath);
2149
+ if (!stat.isFile() || stat.size > 1024 * 1024) {
2150
+ throw new CliError("invalid_arguments", "The assignment selection must be a regular JSON file no larger than 1 MiB.");
2151
+ }
2152
+ const bytes = await fs.readFile(absolutePath);
2153
+ let document;
2154
+ try {
2155
+ document = JSON.parse(bytes.toString("utf8"));
2156
+ }
2157
+ catch {
2158
+ throw new CliError("invalid_arguments", "The assignment selection must contain valid JSON.");
2159
+ }
2160
+ if (!document ||
2161
+ typeof document !== "object" ||
2162
+ Array.isArray(document) ||
2163
+ Object.keys(document).length !== 1 ||
2164
+ !("todoIds" in document) ||
2165
+ !Array.isArray(document.todoIds) ||
2166
+ !document.todoIds.every((id) => typeof id === "string")) {
2167
+ throw new CliError("invalid_arguments", 'The selection file must contain exactly {"todoIds":["assignment-uuid", ...]}.');
2168
+ }
2169
+ return {
2170
+ todoIds: document.todoIds,
2171
+ file: {
2172
+ absolutePath,
2173
+ sizeBytes: bytes.byteLength,
2174
+ sha256: createHash("sha256").update(bytes).digest("hex"),
2175
+ },
2176
+ };
2177
+ }
2146
2178
  export async function executeRecessCommand(argv, options = {}) {
2147
2179
  const parsed = parseArgs(argv);
2148
2180
  const [noun, verb] = parsed.positionals;
@@ -4409,16 +4441,6 @@ export async function executeRecessCommand(argv, options = {}) {
4409
4441
  throw new CliError("invalid_arguments", "Use content-library search, status, set-stage, or submit.");
4410
4442
  }
4411
4443
  if (noun === "goal-templates") {
4412
- if (verb === "curriculum") {
4413
- return runGoalCurriculumCommand({
4414
- parsed,
4415
- api,
4416
- writeCommand,
4417
- resolveTemplateId: (value) => resolveGoalTemplateId(api, value),
4418
- previewBoundWrite: (args, preview, execute) => previewBoundWrite(args, preview, execute, true),
4419
- recoverExecutedPreview: (expected) => recoverExecutedPreview(parsed, expected),
4420
- });
4421
- }
4422
4444
  const readTemplateDocument = async () => {
4423
4445
  if (!isRemote) {
4424
4446
  return readJsonFile(flagString(parsed, "file", { required: true }), "Template file");
@@ -5424,12 +5446,7 @@ export async function executeRecessCommand(argv, options = {}) {
5424
5446
  changes: plan.changes,
5425
5447
  stampedKeys: plan.stampedKeys,
5426
5448
  dropped: plan.dropped,
5427
- ...(plan.killSwitchActive
5428
- ? {
5429
- killSwitch: "GOAL_CONTENT_SOURCE_OVERRIDE=COPY: no goal reads the course until it is lifted.",
5430
- }
5431
- : {}),
5432
- note: "Every kid on this course (SHARED goals) reads the new version from their next session; progress and notes are keyed by Item key. The confirmed publish is fenced to this exact plan digest.",
5449
+ note: "Every kid on this course reads the new version from their next session; progress and notes are keyed by Item key. The confirmed publish is fenced to this exact plan digest.",
5433
5450
  },
5434
5451
  };
5435
5452
  return previewBoundWrite(parsed, preview, async () => unwrap(await api.client.POST("/ai/goal-templates/{id}/publish", {
@@ -5459,13 +5476,13 @@ export async function executeRecessCommand(argv, options = {}) {
5459
5476
  if (action === "list")
5460
5477
  return notes;
5461
5478
  if (!lesson) {
5462
- return { goalId, contentSource: notes.contentSource, note: notes.goal };
5479
+ return { goalId, note: notes.goal };
5463
5480
  }
5464
5481
  const match = notes.lessons.find((entry) => entry.key === lesson || entry.ref === lesson);
5465
5482
  if (!match) {
5466
5483
  throw new CliError("not_found", `No lesson ${lesson} on goal ${goalId}; goals notes list shows each lesson's key.`);
5467
5484
  }
5468
- return { goalId, contentSource: notes.contentSource, lesson: match };
5485
+ return { goalId, lesson: match };
5469
5486
  }
5470
5487
  if (action === "set") {
5471
5488
  const textFile = flagString(parsed, "text-file");
@@ -5485,32 +5502,12 @@ export async function executeRecessCommand(argv, options = {}) {
5485
5502
  request: body,
5486
5503
  details: {
5487
5504
  ...resolvedStudentDetails(student),
5488
- note: "Notes exist only on shared-course goals. To change the lesson itself for every kid, edit the course and run goal-templates publish.",
5505
+ note: "To change the lesson itself for every kid, edit the course and run goal-templates publish.",
5489
5506
  },
5490
5507
  }, async () => unwrap(await api.client.PUT("/tutor/students/{studentId}/goals/{goalId}/notes", { ...params, body })));
5491
5508
  }
5492
5509
  throw new CliError("invalid_arguments", "Use goals notes list|get|set.");
5493
5510
  }
5494
- if (noun === "goals" && verb === "adaptations") {
5495
- const action = positional(parsed, 2, "goals adaptations action");
5496
- const student = await studentFlag(api, parsed, { required: true });
5497
- const studentId = student.id;
5498
- const goalId = flagString(parsed, "goal", { required: true });
5499
- if (action === "list") {
5500
- return unwrap(await api.client.GET("/tutor/students/{studentId}/goals/{goalId}/adaptations", { params: { path: { studentId, goalId } } }));
5501
- }
5502
- if (action === "diff") {
5503
- const runId = positional(parsed, 3, "adaptation run ID");
5504
- const path = flagString(parsed, "path");
5505
- return unwrap(await api.client.GET("/tutor/students/{studentId}/goals/{goalId}/adaptations/{runId}/diff", {
5506
- params: {
5507
- path: { studentId, goalId, runId },
5508
- query: path ? { path } : {},
5509
- },
5510
- }));
5511
- }
5512
- throw new CliError("invalid_arguments", "Use goals adaptations list|diff.");
5513
- }
5514
5511
  if (noun === "goals" &&
5515
5512
  verb !== "files" &&
5516
5513
  verb !== "pdf" &&
@@ -135,8 +135,6 @@ const FAMILY_AI_COMMANDS = new Set([
135
135
  "goal-templates set-metadata",
136
136
  "goal-templates snapshot-files",
137
137
  "goal-templates validate-spec",
138
- "goals adaptations diff",
139
- "goals adaptations list",
140
138
  "goals archive",
141
139
  "goals complete-module",
142
140
  "goals create",
package/dist/help.js CHANGED
@@ -447,18 +447,6 @@ Usage:
447
447
  recess [--json] goal-templates retire-assignments <template-id|slug> --goal ID
448
448
  [--todos ID,ID | --todos-file <path/selection.json>]
449
449
  --retirement-reason TEXT [--confirm --approval-token TOKEN]
450
- recess [--json] goal-templates curriculum backlog <template-id|slug>
451
- --goals ID,ID [--due-before YYYY-MM-DD]
452
- recess [--json] goal-templates curriculum preview <template-id|slug>
453
- --goals ID,ID --version N [--resolutions-file <path/resolutions.json>]
454
- recess [--json] goal-templates curriculum validate-resolutions <template-id|slug>
455
- --goals ID,ID --version N --resolutions-file <path/resolutions.json>
456
- recess [--json] goal-templates curriculum apply|reverse <template-id|slug>
457
- --goals ID,ID --version N [--resolutions-file <path/resolutions.json>]
458
- [--confirm --approval-token TOKEN]
459
- recess [--json] goal-templates curriculum status <template-id|slug> --job ID
460
- recess [--json] goal-templates curriculum retry <template-id|slug> --job ID
461
- [--confirm --approval-token TOKEN]
462
450
  recess [--json] goal-templates versions <template-id> [--version N]
463
451
  recess [--json] goal-templates validate-spec --file <path/template.json>
464
452
  recess [--json] goal-templates create --file <path/template.json>
@@ -573,9 +561,6 @@ Usage:
573
561
  [--lesson <item-key|module-ref>] (--text TEXT | --text-file <path>) [--append]
574
562
  [--confirm --approval-token TOKEN]
575
563
  recess [--json] goals progress --student <goal-owner-id> --goal <goal-id>
576
- recess [--json] goals adaptations list --student <goal-owner-id> --goal <goal-id>
577
- recess [--json] goals adaptations diff <run-id> --student <goal-owner-id>
578
- --goal <goal-id> [--path P]
579
564
  recess [--json] goals files list --student <goal-owner-id> --goal <goal-id>
580
565
  recess [--json] goals files read --student <goal-owner-id> --goal <goal-id> --path P
581
566
  recess [--json] goals files init --student <goal-owner-id> --draft <draft-slug>
@@ -604,11 +589,10 @@ bundled into this npm package. Load os-v2-goal-template-builder and its
604
589
  references/deterministic-workflow-setup.md BEFORE authoring a template; that is
605
590
  the same guidance the recess.gg/ai agent follows, so there is exactly one
606
591
  standard. Responses cache under ~/.recess-cli/skills-cache/ (--refresh re-fetches).
607
- Shared courses (a goal with contentSource SHARED): every kid reads the course's
608
- latest published version, so "goal-templates publish" is the one way to change a
609
- lesson; it previews "affects N kids (M mid-lesson)". Per-kid tailoring is a note
610
- ("goals notes set"), never a lesson edit: goal file pushes to lesson paths are
611
- refused. capture-snapshot and the curriculum commands are deprecated for them.
592
+ Shared courses: every kid on a template reads the course's latest published
593
+ version, so "goal-templates publish" is the one way to change a lesson; it previews
594
+ "affects N kids (M mid-lesson)". Per-kid tailoring is a note ("goals notes set"),
595
+ never a lesson edit (a goal that owns its lessons takes "goals files push").
612
596
  Goal file writes/pushes warn and refuse curriculum edits with unfinished assignments
613
597
  unless --allow-assigned-edits is supplied. This can change lessons while a student
614
598
  is working; assignments are not retired/completed and student answers are not merged.
@@ -1225,13 +1209,6 @@ export const COMMAND_SUMMARIES = {
1225
1209
  "goal-templates migrate-policy": "Migrate students' goals to the template policy.",
1226
1210
  "goal-templates student-policy": "Edit one student's goal policy.",
1227
1211
  "goal-templates retire-assignments": "Retire a goal's open assignments.",
1228
- "goal-templates curriculum backlog": "Show goals' curriculum backlog (deprecated for shared courses).",
1229
- "goal-templates curriculum preview": "Preview a curriculum version upgrade (deprecated for shared courses).",
1230
- "goal-templates curriculum validate-resolutions": "Validate curriculum-upgrade conflict resolutions (deprecated for shared courses).",
1231
- "goal-templates curriculum apply": "Apply a curriculum version to goals (deprecated for shared courses).",
1232
- "goal-templates curriculum reverse": "Reverse a curriculum upgrade on goals (deprecated for shared courses).",
1233
- "goal-templates curriculum status": "Check a curriculum job's status (deprecated for shared courses).",
1234
- "goal-templates curriculum retry": "Retry a failed curriculum job (deprecated for shared courses).",
1235
1212
  "goal-templates versions": "List a template's version history.",
1236
1213
  "goal-templates validate-spec": "Validate a template file (no write).",
1237
1214
  "goal-templates create": "Create a goal template from a file.",
@@ -1286,12 +1263,10 @@ export const COMMAND_SUMMARIES = {
1286
1263
  "tutor-templates create": "Create a tutor template.",
1287
1264
  "tutor-templates update": "Update a tutor template.",
1288
1265
  "tutor-templates delete": "Delete a tutor template.",
1289
- "goals notes list": "List Rocky's per-kid notes on a shared-course goal.",
1266
+ "goals notes list": "List Rocky's per-kid notes on a goal.",
1290
1267
  "goals notes get": "Read the goal's or one lesson's note.",
1291
1268
  "goals notes set": "Write Rocky's note for this kid on a lesson (never the lesson itself).",
1292
1269
  "goals progress": "Per-lesson progress for one kid's goal.",
1293
- "goals adaptations list": "List a goal's adaptation runs.",
1294
- "goals adaptations diff": "Diff the files an adaptation run changed.",
1295
1270
  "goals files list": "List a goal workspace's files.",
1296
1271
  "goals files read": "Read one goal workspace file.",
1297
1272
  "goals files init": "Start a new draft goal workspace locally.",
@@ -1336,7 +1311,7 @@ export const NOUN_SUMMARIES = {
1336
1311
  db: "Read-only SQL queries and who may run them.",
1337
1312
  "content-library": "Curated gem library: search, submit, admission stage.",
1338
1313
  skills: "Authoring skills to load before writing templates/goals.",
1339
- "goal-templates": "Goal templates: browse, author, apply, policy, curriculum.",
1314
+ "goal-templates": "Goal templates: browse, author, apply, policy, publish.",
1340
1315
  goals: "Kids' goals: create/edit, queue, workspace files, PDFs, videos.",
1341
1316
  todos: "Kids' todos: create, edit, complete, analysis, applets.",
1342
1317
  memories: "Kid memory files and the context Rocky sees.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "recess-cli",
3
- "version": "3.18.1",
3
+ "version": "3.19.0",
4
4
  "description": "Safe Recess administration and family AI tools from the command line.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -1,187 +0,0 @@
1
- import { createHash } from "node:crypto";
2
- import fs from "node:fs/promises";
3
- import path from "node:path";
4
- import { unwrap } from "../api.js";
5
- import { flagString } from "../args.js";
6
- import { CliError } from "../errors.js";
7
- import { flagInteger, positional } from "./shared.js";
8
- /** Selection files only supply explicit IDs; they never expand a filter into a mutation. */
9
- export async function readAssignmentSelection(filePath) {
10
- const absolutePath = path.resolve(filePath);
11
- const stat = await fs.stat(absolutePath);
12
- if (!stat.isFile() || stat.size > 1024 * 1024) {
13
- throw new CliError("invalid_arguments", "The assignment selection must be a regular JSON file no larger than 1 MiB.");
14
- }
15
- const bytes = await fs.readFile(absolutePath);
16
- let document;
17
- try {
18
- document = JSON.parse(bytes.toString("utf8"));
19
- }
20
- catch {
21
- throw new CliError("invalid_arguments", "The assignment selection must contain valid JSON.");
22
- }
23
- if (!document ||
24
- typeof document !== "object" ||
25
- Array.isArray(document) ||
26
- Object.keys(document).length !== 1 ||
27
- !("todoIds" in document) ||
28
- !Array.isArray(document.todoIds) ||
29
- !document.todoIds.every((id) => typeof id === "string")) {
30
- throw new CliError("invalid_arguments", 'The selection file must contain exactly {"todoIds":["assignment-uuid", ...]}.');
31
- }
32
- return {
33
- todoIds: document.todoIds,
34
- file: {
35
- absolutePath,
36
- sizeBytes: bytes.byteLength,
37
- sha256: createHash("sha256").update(bytes).digest("hex"),
38
- },
39
- };
40
- }
41
- async function readResolutions(filePath) {
42
- const absolutePath = path.resolve(filePath);
43
- let bytes;
44
- try {
45
- const stat = await fs.stat(absolutePath);
46
- if (!stat.isFile() || stat.size > 1024 * 1024) {
47
- throw new CliError("invalid_arguments", "The resolution file must be a regular JSON file no larger than 1 MiB.");
48
- }
49
- bytes = await fs.readFile(absolutePath);
50
- }
51
- catch (error) {
52
- if (error.code === "ENOENT") {
53
- throw new CliError("invalid_arguments", `File not found: ${absolutePath}`);
54
- }
55
- throw error;
56
- }
57
- let document;
58
- try {
59
- document = JSON.parse(bytes.toString("utf8"));
60
- }
61
- catch {
62
- throw new CliError("invalid_arguments", "The resolution file must contain valid JSON.");
63
- }
64
- if (!document || typeof document !== "object" || Array.isArray(document)) {
65
- throw new CliError("invalid_arguments", "The resolution file must contain a JSON object.");
66
- }
67
- // The backend validates document version, choices, conflict IDs, and whether
68
- // each choice is supported by the current three-way comparison.
69
- return {
70
- document: document,
71
- file: {
72
- absolutePath,
73
- sizeBytes: bytes.byteLength,
74
- sha256: createHash("sha256").update(bytes).digest("hex"),
75
- },
76
- };
77
- }
78
- export async function runGoalCurriculumCommand({ parsed, api, resolveTemplateId, previewBoundWrite, recoverExecutedPreview, }) {
79
- const verb = positional(parsed, 2, "curriculum operation");
80
- const [id, session] = await Promise.all([
81
- resolveTemplateId(positional(parsed, 3, "template ID or slug")),
82
- api.client.GET("/auth/admin-cli/session/").then(unwrap),
83
- ]);
84
- if (session.user.role !== "ADMIN" || session.cliScope !== "full_admin") {
85
- throw new CliError("forbidden", "Curriculum updates require a full-admin session.");
86
- }
87
- const environment = {
88
- actorId: session.user.id,
89
- apiOrigin: api.config.apiOrigin,
90
- };
91
- if (verb === "status" || verb === "retry") {
92
- const jobId = flagString(parsed, "job", { required: true });
93
- if (verb === "status") {
94
- return unwrap(await api.client.GET("/ai/goal-templates/{id}/curriculum/jobs/{jobId}", {
95
- params: { path: { id, jobId } },
96
- }));
97
- }
98
- const requestPreview = {
99
- action: "resume the previously approved curriculum job",
100
- target: { templateId: id, jobId, ...environment },
101
- request: {},
102
- };
103
- const receipt = await recoverExecutedPreview(requestPreview);
104
- const preview = receipt ?? {
105
- ...requestPreview,
106
- details: {
107
- job: unwrap(await api.client.GET("/ai/goal-templates/{id}/curriculum/jobs/{jobId}", {
108
- params: { path: { id, jobId } },
109
- })),
110
- note: "Resumes this job's stored scope and resolutions. Completed goals are not replayed; stale goals require a new preview.",
111
- },
112
- };
113
- return previewBoundWrite(parsed, preview, async () => unwrap(await api.client.POST("/ai/goal-templates/{id}/curriculum/jobs/{jobId}/retry", {
114
- params: { path: { id, jobId } },
115
- body: {},
116
- })));
117
- }
118
- const goalIds = flagString(parsed, "goals", { required: true })
119
- .split(",")
120
- .map((value) => value.trim());
121
- if (goalIds.some((value) => !value) ||
122
- new Set(goalIds).size !== goalIds.length) {
123
- throw new CliError("invalid_arguments", "--goals must list distinct, nonempty goal IDs.");
124
- }
125
- if (verb === "backlog") {
126
- const dueBefore = flagString(parsed, "due-before");
127
- return unwrap(await api.client.GET("/ai/goal-templates/{id}/curriculum/backlog", {
128
- params: {
129
- path: { id },
130
- query: { goalIds: goalIds.join(","), dueBefore },
131
- },
132
- }));
133
- }
134
- const targetVersion = flagInteger(parsed, "version", {
135
- required: true,
136
- min: 1,
137
- });
138
- const filePath = flagString(parsed, "resolutions-file", {
139
- required: verb === "validate-resolutions",
140
- });
141
- const resolutionFile = filePath ? await readResolutions(filePath) : undefined;
142
- const body = {
143
- goalIds,
144
- targetVersion,
145
- resolutions: resolutionFile?.document ?? { version: 1, resolutions: [] },
146
- };
147
- const requestPreview = {
148
- action: verb === "reverse"
149
- ? "merge a prior template curriculum version into the selected student goals"
150
- : "merge the selected template curriculum version into the selected student goals",
151
- target: { templateId: id, goalIds, ...environment },
152
- request: { ...body, resolutionFile: resolutionFile?.file ?? null },
153
- };
154
- const receipt = verb === "apply" || verb === "reverse"
155
- ? await recoverExecutedPreview(requestPreview)
156
- : null;
157
- const comparison = receipt
158
- ? receipt.details?.comparison
159
- : unwrap(await api.client.POST("/ai/goal-templates/{id}/curriculum/preview", {
160
- params: { path: { id } },
161
- body,
162
- }));
163
- if (verb === "preview" || verb === "validate-resolutions") {
164
- return { ...comparison, resolutionFile: resolutionFile?.file ?? null };
165
- }
166
- if (verb !== "apply" && verb !== "reverse") {
167
- throw new CliError("invalid_arguments", "Use curriculum backlog|preview|validate-resolutions|apply|status|retry|reverse.");
168
- }
169
- const preview = receipt ?? {
170
- ...requestPreview,
171
- details: {
172
- comparison,
173
- note: "Only the exact selected goals are included. Unresolved conflicts block their goal. Assignments and earned history remain protected; reverse updates preserve changes made since the earlier version.",
174
- },
175
- };
176
- return previewBoundWrite(parsed, preview, async () => unwrap(await api.client.POST("/ai/goal-templates/{id}/curriculum/apply", {
177
- params: { path: { id } },
178
- body: {
179
- ...body,
180
- fingerprint: comparison.fingerprint,
181
- operationKey: flagString(parsed, "operation-key", {
182
- required: true,
183
- }),
184
- },
185
- })));
186
- }
187
- //# sourceMappingURL=goal-curriculum.js.map