zam-core 0.3.12 → 0.3.13

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/index.js CHANGED
@@ -1360,8 +1360,17 @@ async function deleteCardForUser(db, tokenId, userId) {
1360
1360
  await db.prepare("DELETE FROM cards WHERE id = ?").run(card.id);
1361
1361
  return { card, impact };
1362
1362
  }
1363
- async function getDueCards(db, userId, now) {
1363
+ async function getDueCards(db, userId, now, domain) {
1364
1364
  const cutoff = now ?? (/* @__PURE__ */ new Date()).toISOString();
1365
+ if (domain) {
1366
+ return await db.prepare(
1367
+ `SELECT c.*, t.slug, t.concept, t.domain, t.bloom_level
1368
+ FROM cards c
1369
+ JOIN tokens t ON t.id = c.token_id
1370
+ WHERE c.user_id = ? AND c.blocked = 0 AND c.due_at <= ? AND t.domain = ?
1371
+ ORDER BY t.bloom_level ASC, c.due_at ASC`
1372
+ ).all(userId, cutoff, domain);
1373
+ }
1365
1374
  return await db.prepare(
1366
1375
  `SELECT c.*, t.slug, t.concept, t.domain, t.bloom_level
1367
1376
  FROM cards c
@@ -5505,15 +5514,16 @@ function parseTokenUpdates(opts) {
5505
5514
  var bridgeCommand = new Command2("bridge").description(
5506
5515
  "Machine-readable JSON protocol for AI integration"
5507
5516
  );
5508
- bridgeCommand.command("check-due").description("Check due cards for a user (JSON)").option("--user <id>", "User ID (default: whoami)").action(async (opts) => {
5517
+ bridgeCommand.command("check-due").description("Check due cards for a user (JSON)").option("--user <id>", "User ID (default: whoami)").option("--domain <domain>", "Filter by knowledge domain").action(async (opts) => {
5509
5518
  await withDb2(async (db) => {
5510
5519
  const userId = await resolveUser(opts, db, { json: true });
5511
- const dueCards = await getDueCards(db, userId);
5520
+ const dueCards = await getDueCards(db, userId, void 0, opts.domain);
5512
5521
  const domains = [
5513
5522
  ...new Set(dueCards.map((c) => c.domain).filter(Boolean))
5514
5523
  ].sort();
5515
5524
  jsonOut2({
5516
5525
  userId,
5526
+ domain: opts.domain ?? null,
5517
5527
  dueCount: dueCards.length,
5518
5528
  domains,
5519
5529
  cards: dueCards.map((c) => ({
@@ -6348,10 +6358,10 @@ import { Command as Command3 } from "commander";
6348
6358
  var cardCommand = new Command3("card").description(
6349
6359
  "Manage spaced-repetition cards"
6350
6360
  );
6351
- cardCommand.command("due").description("Show due tokens for a user").option("--user <id>", "User ID (default: whoami)").option("--json", "Output as JSON").option("--summary", "Show only counts per domain (no slugs or concepts)").action(async (opts) => {
6361
+ cardCommand.command("due").description("Show due tokens for a user").option("--user <id>", "User ID (default: whoami)").option("--domain <domain>", "Filter by knowledge domain").option("--json", "Output as JSON").option("--summary", "Show only counts per domain (no slugs or concepts)").action(async (opts) => {
6352
6362
  await withDb(async (db) => {
6353
6363
  const userId = await resolveUser(opts, db);
6354
- const dueCards = await getDueCards(db, userId);
6364
+ const dueCards = await getDueCards(db, userId, void 0, opts.domain);
6355
6365
  if (opts.json) {
6356
6366
  console.log(JSON.stringify(dueCards, null, 2));
6357
6367
  return;
@@ -9141,7 +9151,7 @@ import { Command as Command18 } from "commander";
9141
9151
  var tokenCommand = new Command18("token").description(
9142
9152
  "Manage knowledge tokens"
9143
9153
  );
9144
- tokenCommand.command("register").description("Register a new knowledge token").requiredOption("--slug <slug>", "Unique token slug").requiredOption("--concept <concept>", "Concept description").option("--domain <domain>", "Knowledge domain", "").option("--bloom <level>", "Bloom taxonomy level (1-5)", "1").option("--source-link <link>", "Source file path or reference URL", "").option("--question <question>", "Specific question prompt for recall", "").option("--json", "Output as JSON").action(async (opts) => {
9154
+ tokenCommand.command("register").description("Register a new knowledge token").requiredOption("--slug <slug>", "Unique token slug").requiredOption("--concept <concept>", "Concept description").option("--domain <domain>", "Knowledge domain", "").option("--bloom <level>", "Bloom taxonomy level (1-5)", "1").option("--source-link <link>", "Source file path or reference URL", "").option("--question <question>", "Specific question prompt for recall", "").option("--json", "Output as JSON").option("--quiet", "Suppress output (exit code only)").action(async (opts) => {
9145
9155
  await withDb(async (db) => {
9146
9156
  let question = opts.question || null;
9147
9157
  if (!question) {
@@ -9159,6 +9169,7 @@ tokenCommand.command("register").description("Register a new knowledge token").r
9159
9169
  source_link: opts.sourceLink || null,
9160
9170
  question
9161
9171
  });
9172
+ if (opts.quiet) return;
9162
9173
  if (opts.json) {
9163
9174
  console.log(JSON.stringify(token, null, 2));
9164
9175
  } else {
@@ -9173,9 +9184,10 @@ tokenCommand.command("register").description("Register a new knowledge token").r
9173
9184
  }
9174
9185
  });
9175
9186
  });
9176
- tokenCommand.command("find").description("Fuzzy search for tokens").requiredOption("--query <query>", "Search query").option("--json", "Output as JSON").action(async (opts) => {
9187
+ tokenCommand.command("find").description("Fuzzy search for tokens").requiredOption("--query <query>", "Search query").option("--json", "Output as JSON").option("--quiet", "Suppress output (exit code only)").action(async (opts) => {
9177
9188
  await withDb(async (db) => {
9178
9189
  const results = await findTokens(db, opts.query);
9190
+ if (opts.quiet) return;
9179
9191
  if (opts.json) {
9180
9192
  console.log(JSON.stringify(results, null, 2));
9181
9193
  return;
@@ -9197,12 +9209,13 @@ tokenCommand.command("find").description("Fuzzy search for tokens").requiredOpti
9197
9209
  }
9198
9210
  });
9199
9211
  });
9200
- tokenCommand.command("list").description("List all tokens").option("--domain <domain>", "Filter by domain").option("--json", "Output as JSON").action(async (opts) => {
9212
+ tokenCommand.command("list").description("List all tokens").option("--domain <domain>", "Filter by domain").option("--json", "Output as JSON").option("--quiet", "Suppress output (exit code only)").action(async (opts) => {
9201
9213
  await withDb(async (db) => {
9202
9214
  const tokens = await listTokens(
9203
9215
  db,
9204
9216
  opts.domain ? { domain: opts.domain } : void 0
9205
9217
  );
9218
+ if (opts.quiet) return;
9206
9219
  if (opts.json) {
9207
9220
  console.log(JSON.stringify(tokens, null, 2));
9208
9221
  return;
@@ -9230,7 +9243,7 @@ tokenCommand.command("edit").description("Edit a token's mutable fields").requir
9230
9243
  ).option(
9231
9244
  "--source-link <link>",
9232
9245
  "Updated source file path or reference URL (blank allowed)"
9233
- ).option("--question <question>", "Updated question text (blank allowed)").option("--json", "Output as JSON").action(async (opts) => {
9246
+ ).option("--question <question>", "Updated question text (blank allowed)").option("--json", "Output as JSON").option("--quiet", "Suppress output (exit code only)").action(async (opts) => {
9234
9247
  await withDb(async (db) => {
9235
9248
  const updates = {};
9236
9249
  if (opts.concept !== void 0) updates.concept = opts.concept;
@@ -9253,6 +9266,7 @@ tokenCommand.command("edit").description("Edit a token's mutable fields").requir
9253
9266
  updates.symbiosis_mode = opts.mode === "none" ? null : opts.mode;
9254
9267
  }
9255
9268
  const token = await updateToken(db, opts.slug, updates);
9269
+ if (opts.quiet) return;
9256
9270
  if (opts.json) {
9257
9271
  jsonOut(token);
9258
9272
  return;
@@ -9267,7 +9281,7 @@ tokenCommand.command("edit").description("Edit a token's mutable fields").requir
9267
9281
  console.log(` Source: ${token.source_link || "(none)"}`);
9268
9282
  });
9269
9283
  });
9270
- tokenCommand.command("prereq").description("Add a prerequisite edge between tokens").requiredOption("--token <slug>", "Token that requires a prerequisite").requiredOption("--requires <slug>", "Required prerequisite token").option("--json", "Output as JSON").action(async (opts) => {
9284
+ tokenCommand.command("prereq").description("Add a prerequisite edge between tokens").requiredOption("--token <slug>", "Token that requires a prerequisite").requiredOption("--requires <slug>", "Required prerequisite token").option("--json", "Output as JSON").option("--quiet", "Suppress output (exit code only)").action(async (opts) => {
9271
9285
  await withDb(async (db) => {
9272
9286
  const token = await getTokenBySlug(db, opts.token);
9273
9287
  if (!token) {
@@ -9280,6 +9294,7 @@ tokenCommand.command("prereq").description("Add a prerequisite edge between toke
9280
9294
  process.exit(1);
9281
9295
  }
9282
9296
  await addPrerequisite(db, token.id, requires.id);
9297
+ if (opts.quiet) return;
9283
9298
  if (opts.json) {
9284
9299
  console.log(
9285
9300
  JSON.stringify(
@@ -9297,9 +9312,10 @@ tokenCommand.command("prereq").description("Add a prerequisite edge between toke
9297
9312
  });
9298
9313
  tokenCommand.command("deprecate").description(
9299
9314
  "Mark a token as deprecated (excluded from reviews, not deleted)"
9300
- ).requiredOption("--slug <slug>", "Token slug to deprecate").option("--json", "Output as JSON").action(async (opts) => {
9315
+ ).requiredOption("--slug <slug>", "Token slug to deprecate").option("--json", "Output as JSON").option("--quiet", "Suppress output (exit code only)").action(async (opts) => {
9301
9316
  await withDb(async (db) => {
9302
9317
  const token = await deprecateToken(db, opts.slug);
9318
+ if (opts.quiet) return;
9303
9319
  if (opts.json) {
9304
9320
  console.log(JSON.stringify(token, null, 2));
9305
9321
  } else {
@@ -9309,7 +9325,7 @@ tokenCommand.command("deprecate").description(
9309
9325
  }
9310
9326
  });
9311
9327
  });
9312
- tokenCommand.command("delete").description("Hard-delete a token and its dependent learning data").requiredOption("--slug <slug>", "Token slug to delete").option("--force", "Actually delete the token").option("--json", "Output as JSON").action(async (opts) => {
9328
+ tokenCommand.command("delete").description("Hard-delete a token and its dependent learning data").requiredOption("--slug <slug>", "Token slug to delete").option("--force", "Actually delete the token").option("--json", "Output as JSON").option("--quiet", "Suppress output (exit code only)").action(async (opts) => {
9313
9329
  await withDb(async (db) => {
9314
9330
  const impact = await getTokenDeleteImpact(db, opts.slug);
9315
9331
  if (!opts.force) {
@@ -9319,6 +9335,7 @@ tokenCommand.command("delete").description("Hard-delete a token and its dependen
9319
9335
  requiresForce: true,
9320
9336
  impact
9321
9337
  };
9338
+ if (opts.quiet) return;
9322
9339
  if (opts.json) {
9323
9340
  jsonOut(preview);
9324
9341
  return;
@@ -9339,6 +9356,7 @@ tokenCommand.command("delete").description("Hard-delete a token and its dependen
9339
9356
  return;
9340
9357
  }
9341
9358
  const result = await deleteToken(db, opts.slug);
9359
+ if (opts.quiet) return;
9342
9360
  if (opts.json) {
9343
9361
  jsonOut({
9344
9362
  slug: result.token.slug,
@@ -9354,7 +9372,7 @@ tokenCommand.command("delete").description("Hard-delete a token and its dependen
9354
9372
  console.log(` Agent skills updated: ${result.impact.agent_skills}`);
9355
9373
  });
9356
9374
  });
9357
- tokenCommand.command("status").description("Show full status of a token for a user").requiredOption("--token <slug>", "Token slug").option("--user <id>", "User ID (default: whoami)").option("--json", "Output as JSON").action(async (opts) => {
9375
+ tokenCommand.command("status").description("Show full status of a token for a user").requiredOption("--token <slug>", "Token slug").option("--user <id>", "User ID (default: whoami)").option("--json", "Output as JSON").option("--quiet", "Suppress output (exit code only)").action(async (opts) => {
9358
9376
  await withDb(async (db) => {
9359
9377
  const userId = await resolveUser(opts, db);
9360
9378
  const token = await getTokenBySlug(db, opts.token);
@@ -9371,6 +9389,7 @@ tokenCommand.command("status").description("Show full status of a token for a us
9371
9389
  prerequisites: prereqs,
9372
9390
  dependents
9373
9391
  };
9392
+ if (opts.quiet) return;
9374
9393
  if (opts.json) {
9375
9394
  console.log(JSON.stringify(status, null, 2));
9376
9395
  return;