recess-cli 3.18.0 → 3.18.1

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
@@ -1824,6 +1824,44 @@ function resolvedStudentDetails(student) {
1824
1824
  function goalTemplatePreviewUrl(webOrigin, templateId) {
1825
1825
  return new URL(`/challenges-v2/${encodeURIComponent(templateId)}`, webOrigin).toString();
1826
1826
  }
1827
+ /**
1828
+ * The classic-challenge fields passed as flags (`classic-create`/`-update`);
1829
+ * only flags present land, so an update changes exactly what was sent. The
1830
+ * server owns the real validation (`classic-challenge-source.ts`).
1831
+ */
1832
+ async function classicChallengeFlags(parsed) {
1833
+ const instructionsFile = flagString(parsed, "instructions-file");
1834
+ if (instructionsFile && flagString(parsed, "instructions") !== undefined) {
1835
+ throw new CliError("invalid_arguments", "Pass --instructions or --instructions-file, not both.");
1836
+ }
1837
+ const instructions = instructionsFile
1838
+ ? await fs.readFile(path.resolve(instructionsFile), "utf8")
1839
+ : flagString(parsed, "instructions");
1840
+ const integer = (flag, min, max) => {
1841
+ const value = flagNumber(parsed, flag);
1842
+ if (value !== undefined &&
1843
+ (!Number.isInteger(value) || value < min || value > max)) {
1844
+ throw new CliError("invalid_arguments", `--${flag} must be an integer from ${min} to ${max}.`);
1845
+ }
1846
+ return value;
1847
+ };
1848
+ const coinAmount = integer("coin-amount", 0, 1000);
1849
+ const estimatedMinutes = integer("estimated-minutes", 5, 600);
1850
+ const text = {
1851
+ title: flagString(parsed, "title"),
1852
+ description: flagString(parsed, "description"),
1853
+ instructions,
1854
+ submissionPrompt: flagString(parsed, "submission-prompt"),
1855
+ gradeTag: flagString(parsed, "grade-tag"),
1856
+ category: flagString(parsed, "category"),
1857
+ imageUrl: flagString(parsed, "image-url"),
1858
+ };
1859
+ return {
1860
+ ...Object.fromEntries(Object.entries(text).filter(([, value]) => value !== undefined)),
1861
+ ...(coinAmount === undefined ? {} : { coinAmount }),
1862
+ ...(estimatedMinutes === undefined ? {} : { estimatedMinutes }),
1863
+ };
1864
+ }
1827
1865
  /** Runs the template with Rocky as a kid would (staff only; ephemeral, never touches real todos). */
1828
1866
  function goalTemplatePlayTestUrl(webOrigin, templateId) {
1829
1867
  return new URL(`/challenges-v2/${encodeURIComponent(templateId)}?play=1`, webOrigin).toString();
@@ -4566,6 +4604,78 @@ export async function executeRecessCommand(argv, options = {}) {
4566
4604
  };
4567
4605
  });
4568
4606
  }
4607
+ // Classic challenges: one photo-upload module a guide approves, authored
4608
+ // from a few fields (`routes/ai/goal-templates/classic-routes.ts`).
4609
+ if (verb === "classic-create") {
4610
+ const fields = await classicChallengeFlags(parsed);
4611
+ const { title, description, instructions, gradeTag, coinAmount } = fields;
4612
+ if (!title ||
4613
+ !description ||
4614
+ !instructions ||
4615
+ !gradeTag ||
4616
+ coinAmount === undefined) {
4617
+ throw new CliError("invalid_arguments", "classic-create needs --title, --description, --instructions (or --instructions-file), --grade-tag and --coin-amount.");
4618
+ }
4619
+ const body = {
4620
+ ...fields,
4621
+ title,
4622
+ description,
4623
+ instructions,
4624
+ gradeTag,
4625
+ coinAmount,
4626
+ };
4627
+ return writeCommand(parsed, {
4628
+ action: "create a PRIVATE classic challenge (kid uploads photos; a guide approves from /challenges-v2/review)",
4629
+ target: { title },
4630
+ request: body,
4631
+ details: {
4632
+ note: "Starts PRIVATE. Card art is painted automatically when no --image-url is given. Publish with goal-templates set-metadata <id> --visibility PUBLIC once it looks right.",
4633
+ },
4634
+ }, async () => {
4635
+ const created = unwrap(await api.client.POST("/ai/goal-templates/classic", { body }));
4636
+ return {
4637
+ ...created,
4638
+ previewUrl: goalTemplatePreviewUrl(config.webOrigin, created.templateId),
4639
+ };
4640
+ });
4641
+ }
4642
+ if (verb === "classic-get" || verb === "classic-update") {
4643
+ const id = await resolveGoalTemplateId(api, positional(parsed, 2, "template ID or slug"));
4644
+ const current = unwrap(await api.client.GET("/ai/goal-templates/{id}/classic", {
4645
+ params: { path: { id } },
4646
+ }));
4647
+ if (verb === "classic-get") {
4648
+ return {
4649
+ ...current,
4650
+ previewUrl: goalTemplatePreviewUrl(config.webOrigin, id),
4651
+ };
4652
+ }
4653
+ const body = await classicChallengeFlags(parsed);
4654
+ const changed = Object.keys(body);
4655
+ if (changed.length === 0) {
4656
+ throw new CliError("invalid_arguments", "Pass at least one field to change (--title, --description, --instructions/--instructions-file, --submission-prompt, --grade-tag, --coin-amount, --estimated-minutes, --category, --image-url).");
4657
+ }
4658
+ const before = {
4659
+ ...current.source,
4660
+ imageUrl: current.imageUrl,
4661
+ };
4662
+ return writeCommand(parsed, {
4663
+ action: "edit a classic challenge (only the fields sent change; cuts a new version)",
4664
+ target: {
4665
+ templateId: id,
4666
+ title: current.source.title,
4667
+ version: current.version,
4668
+ visibility: current.visibility,
4669
+ },
4670
+ request: body,
4671
+ details: {
4672
+ current: Object.fromEntries(changed.map((key) => [key, before[key] ?? null])),
4673
+ },
4674
+ }, async () => unwrap(await api.client.PUT("/ai/goal-templates/{id}/classic", {
4675
+ params: { path: { id } },
4676
+ body,
4677
+ })));
4678
+ }
4569
4679
  if (verb === "policy") {
4570
4680
  const id = await resolveGoalTemplateId(api, positional(parsed, 2, "template ID or slug"));
4571
4681
  return unwrap(await api.client.GET("/ai/goal-templates/{id}/policy", {
@@ -5332,7 +5442,7 @@ export async function executeRecessCommand(argv, options = {}) {
5332
5442
  },
5333
5443
  })));
5334
5444
  }
5335
- throw new CliError("invalid_arguments", "Use goal-templates list|get|versions|validate-spec|create|patch-spec|set-metadata|generate-image|delete|snapshot-files|capture-snapshot|publish|answers-template|apply|apply-starter.");
5445
+ throw new CliError("invalid_arguments", "Use goal-templates list|get|versions|validate-spec|create|classic-create|classic-get|classic-update|patch-spec|set-metadata|generate-image|delete|snapshot-files|capture-snapshot|publish|answers-template|apply|apply-starter.");
5336
5446
  }
5337
5447
  if (noun === "goals" && (verb === "notes" || verb === "progress")) {
5338
5448
  const student = await studentFlag(api, parsed, { required: true });
@@ -117,6 +117,10 @@ const FAMILY_AI_COMMANDS = new Set([
117
117
  "goal-templates apply",
118
118
  "goal-templates apply-starter",
119
119
  "goal-templates capture-snapshot",
120
+ "goal-templates classic-create",
121
+ // classic-get/-update: staff, or the author on their own PRIVATE draft.
122
+ "goal-templates classic-get",
123
+ "goal-templates classic-update",
120
124
  "goal-templates create",
121
125
  // set-metadata/delete/patch-spec: the server lets a non-staff author touch
122
126
  // only their own PRIVATE templates, plus unpublish (set-metadata
@@ -486,6 +486,38 @@ export async function runAdmissionsCommand({ parsed, api, writeCommand, }) {
486
486
  return json ? result : { help: await render(result.packet) };
487
487
  });
488
488
  }
489
+ if (verb === "set-paywall") {
490
+ const packetId = positional(parsed, 2, "packet ID");
491
+ const paywallRaw = flagString(parsed, "paywall")?.replace(/[$,]/g, "");
492
+ const paywall = paywallRaw === undefined ? undefined : Number(paywallRaw);
493
+ if (paywall !== undefined && (!Number.isFinite(paywall) || paywall <= 0)) {
494
+ throw new CliError("invalid_arguments", "--paywall must be a positive dollar amount; --no-paywall removes it.");
495
+ }
496
+ const offlinePaywall = hasFlag(parsed, "paywall-offline");
497
+ const noPaywall = hasFlag(parsed, "no-paywall");
498
+ if ([paywall !== undefined, noPaywall, offlinePaywall].filter(Boolean)
499
+ .length !== 1) {
500
+ throw new CliError("invalid_arguments", "Use exactly one of --paywall DOLLARS, --paywall-offline or --no-paywall.");
501
+ }
502
+ const note = flagString(parsed, "note")?.trim();
503
+ const body = {
504
+ ...(offlinePaywall
505
+ ? { paywallOutOfBand: true }
506
+ : { paywallCents: noPaywall ? null : Math.round(paywall * 100) }),
507
+ ...(note ? { note } : {}),
508
+ };
509
+ return writeCommand(parsed, {
510
+ action: `set admission packet ${packetId}'s paywall to ${offlinePaywall ? "the signed plan's first invoice, paid out of band" : noPaywall ? "none" : `${dollars(Math.round(paywall * 100))} by card`}, keeping the agreement and signature; a packet at the payment step reopens the new paywall or completes`,
511
+ target: { packetId },
512
+ request: body,
513
+ }, async () => {
514
+ const result = unwrap(await api.client.POST("/admin/admissions/{packetId}/paywall", {
515
+ params: { path: { packetId } },
516
+ body,
517
+ }));
518
+ return json ? result : { help: await render(result.packet) };
519
+ });
520
+ }
489
521
  if (verb === "contract") {
490
522
  const packetId = positional(parsed, 2, "packet ID");
491
523
  const option = flagString(parsed, "option");
@@ -540,6 +572,6 @@ export async function runAdmissionsCommand({ parsed, api, writeCommand, }) {
540
572
  };
541
573
  });
542
574
  }
543
- throw new CliError("invalid_arguments", "Usage: recess admissions create|get|list|resend|void|mark-signed|upload-signed|contract|mark-paid|requote|archive-agreement. See `recess help`.");
575
+ throw new CliError("invalid_arguments", "Usage: recess admissions create|get|list|resend|void|mark-signed|upload-signed|contract|mark-paid|set-paywall|requote|archive-agreement. See `recess help`.");
544
576
  }
545
577
  //# sourceMappingURL=admissions.js.map
package/dist/help.js CHANGED
@@ -226,6 +226,7 @@ Usage:
226
226
  [--paywall DOLLARS|--paywall-offline|--no-paywall] [--note TEXT] [--confirm]
227
227
  recess [--json] admissions archive-agreement <packet-id> [--confirm]
228
228
  recess [--json] admissions mark-paid <packet-id> [--note TEXT] [--confirm]
229
+ recess [--json] admissions set-paywall <packet-id> (--paywall DOLLARS | --paywall-offline | --no-paywall) [--note TEXT] [--confirm]
229
230
  recess [--json] admissions contract <packet-id> [--option <term:payment>] [--out <file>]
230
231
  recess [--json] admissions upload-signed <packet-id> --file <pdf> [--option <term:payment>] [--note TEXT] [--confirm]
231
232
  recess [--json] reports activity [--partner-school <slug|id>] [--guide <name|email|id>]
@@ -462,6 +463,15 @@ Usage:
462
463
  recess [--json] goal-templates validate-spec --file <path/template.json>
463
464
  recess [--json] goal-templates create --file <path/template.json>
464
465
  [--coin-amount N] [--confirm]
466
+ recess [--json] goal-templates classic-create --title TEXT --description TEXT
467
+ (--instructions TEXT | --instructions-file <path.md>) --grade-tag "Grades 3-6"
468
+ --coin-amount N [--submission-prompt TEXT] [--estimated-minutes N]
469
+ [--category TEXT] [--image-url URL] [--confirm]
470
+ recess [--json] goal-templates classic-get <template-id|slug>
471
+ recess [--json] goal-templates classic-update <template-id|slug> [--title TEXT]
472
+ [--description TEXT] [--instructions TEXT | --instructions-file <path.md>]
473
+ [--grade-tag TEXT] [--coin-amount N] [--submission-prompt TEXT]
474
+ [--estimated-minutes N] [--category TEXT] [--image-url URL] [--confirm]
465
475
  recess [--json] goal-templates patch-spec <template-id|slug> [--expected-version N]
466
476
  --patches-file <path/patches.json> [--confirm --approval-token TOKEN]
467
477
  [--confirm-destructive-changes --destructive-change-token TOKEN]
@@ -622,6 +632,9 @@ the backend's own dryRun before the gate and previews the per-student outcome.
622
632
  "set-metadata", "delete", "patch-spec" and "set-policy" take an optional
623
633
  --expected-version; omitted, the current version is read and pinned into the
624
634
  preview, so a change before confirm is refused. A stale one 409s STALE_WRITE.
635
+ "classic-create" makes a single human-reviewed module (kid submits photos, a guide
636
+ approves from /challenges-v2/review) from a few fields, as a PRIVATE draft; publish
637
+ with "set-metadata <id> --visibility PUBLIC". Edit it with "classic-update", not patch-spec.
625
638
  --student on goal, todo, goal-file and template-apply commands takes an ID or an
626
639
  exact roster name. "answers-template" prints a fillable answers file for "apply". The spec is unreachable from "set-metadata"
627
640
  by design — an existing spec is edited only through the guarded /ai patch path.
@@ -869,7 +882,11 @@ plan flags as create, or --keep-plan to reopen the payment choice on the plan
869
882
  as it is; --paywall/--no-paywall changes the family share): the Documenso
870
883
  envelope is cancelled, the family signs again from the same link, and their
871
884
  account, consent and answers stand (a completed packet completes again on its
872
- own); paid packets need a refund first and voided ones a new packet. "mark-signed" records a signature taken outside the dashboard (or local
885
+ own); paid packets need a refund first and voided ones a new packet. "set-paywall" changes only the paywall (--paywall DOLLARS, --paywall-offline or
886
+ --no-paywall) with no re-signing: the agreement stands, an open admission
887
+ charge Stripe never saw is canceled, and a packet at the payment step reopens
888
+ the new paywall or completes. It refuses while the parent is mid-signing.
889
+ "mark-signed" records a signature taken outside the dashboard (or local
873
890
  testing without Documenso) so the parent can continue. Status moves on its own:
874
891
  the Documenso webhook marks SIGNED, each parent step advances it, and a packet
875
892
  with no paywall completes when the questions are in.
@@ -1218,6 +1235,9 @@ export const COMMAND_SUMMARIES = {
1218
1235
  "goal-templates versions": "List a template's version history.",
1219
1236
  "goal-templates validate-spec": "Validate a template file (no write).",
1220
1237
  "goal-templates create": "Create a goal template from a file.",
1238
+ "goal-templates classic-create": "Create a classic challenge: kid uploads photos, a guide approves (starts PRIVATE).",
1239
+ "goal-templates classic-get": "Read a classic challenge's editable fields.",
1240
+ "goal-templates classic-update": "Edit a classic challenge's fields (only those passed change).",
1221
1241
  "goal-templates patch-spec": "Patch a template's setup-workflow spec (own PRIVATE ones for guardians).",
1222
1242
  "goal-templates set-metadata": "Edit a template's title, art, tags, visibility (own PRIVATE ones for guardians, who may also unpublish their own: --visibility PRIVATE alone).",
1223
1243
  "goal-templates delete": "Delete a goal template (own PRIVATE ones for guardians).",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "recess-cli",
3
- "version": "3.18.0",
3
+ "version": "3.18.1",
4
4
  "description": "Safe Recess administration and family AI tools from the command line.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -1,4 +1,4 @@
1
1
  {
2
- "version": "3.4.0",
3
- "minCliVersion": "3.11.0"
2
+ "version": "3.5.0",
3
+ "minCliVersion": "3.18.0"
4
4
  }