zam-core 0.15.6 → 0.16.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/app.js CHANGED
@@ -10745,7 +10745,7 @@ async function readWebLink(url) {
10745
10745
  redirect: "manual",
10746
10746
  signal: controller.signal,
10747
10747
  headers: {
10748
- "User-Agent": "ZAM-Content-Studio/0.15.6"
10748
+ "User-Agent": "ZAM-Content-Studio/0.16.0"
10749
10749
  }
10750
10750
  });
10751
10751
  if (res.status >= 300 && res.status < 400) {
@@ -12293,6 +12293,32 @@ function installCliShim(options = {}) {
12293
12293
  }
12294
12294
  }
12295
12295
 
12296
+ // src/cli/curriculum/concurrency.ts
12297
+ async function mapWithConcurrency(items, concurrency, mapper) {
12298
+ if (items.length === 0) return [];
12299
+ const workerCount = Math.max(
12300
+ 1,
12301
+ Math.min(items.length, Math.floor(concurrency) || 1)
12302
+ );
12303
+ const results = new Array(items.length);
12304
+ let nextIndex = 0;
12305
+ let failure;
12306
+ async function worker() {
12307
+ while (!failure) {
12308
+ const index = nextIndex++;
12309
+ if (index >= items.length) return;
12310
+ try {
12311
+ results[index] = await mapper(items[index], index);
12312
+ } catch (error) {
12313
+ failure ??= { error };
12314
+ }
12315
+ }
12316
+ }
12317
+ await Promise.all(Array.from({ length: workerCount }, () => worker()));
12318
+ if (failure) throw failure.error;
12319
+ return results;
12320
+ }
12321
+
12296
12322
  // src/cli/curriculum/breadcrumb.ts
12297
12323
  init_kernel();
12298
12324
  var LAST_SELECTION_KEY = "curriculum.lastSelection";
@@ -83620,20 +83646,29 @@ bridgeCommand.command("curriculum-preview-topic").description(
83620
83646
  parentTopicId: resolved.topicId
83621
83647
  });
83622
83648
  }
83649
+ const generationChunks = chunks.filter((chunk) => chunk.text.trim());
83650
+ const textProvider = await getProviderForRole(db, "text");
83651
+ const generatedChunks = await mapWithConcurrency(
83652
+ generationChunks,
83653
+ textProvider.local ? 1 : 3,
83654
+ async (chunk) => ({
83655
+ chunk,
83656
+ cards: await importCurriculumViaLLM(
83657
+ db,
83658
+ chunk.text,
83659
+ opts.domain,
83660
+ item.uri,
83661
+ { knowledgeContext: firstContext }
83662
+ )
83663
+ })
83664
+ );
83623
83665
  let proposalIndex = 0;
83624
- for (const chunk of chunks) {
83625
- if (!chunk.text.trim()) continue;
83626
- const cards = await importCurriculumViaLLM(
83627
- db,
83628
- chunk.text,
83629
- opts.domain,
83630
- item.uri,
83631
- { knowledgeContext: firstContext }
83632
- );
83666
+ for (const { chunk, cards } of generatedChunks) {
83633
83667
  const scopedTopicId = chunk.subTopicId ? `${resolved.topicId}@${chunk.subTopicId}` : resolved.topicId;
83634
83668
  for (const card of cards) {
83669
+ const targetDomain = (typeof opts.domain === "string" ? opts.domain.trim() : "") || card.domain;
83635
83670
  const slug = proposalBaseSlug(
83636
- card.domain,
83671
+ targetDomain.split("/")[0] || targetDomain,
83637
83672
  card.question,
83638
83673
  card.concept
83639
83674
  );
@@ -83643,7 +83678,7 @@ bridgeCommand.command("curriculum-preview-topic").description(
83643
83678
  const proposal = {
83644
83679
  question: card.question,
83645
83680
  concept: card.concept,
83646
- domain: card.domain,
83681
+ domain: targetDomain,
83647
83682
  bloom_level: card.bloom_level,
83648
83683
  symbiosis_mode: card.symbiosis_mode || "none",
83649
83684
  excerpt: card.context || "",
@@ -83661,7 +83696,7 @@ bridgeCommand.command("curriculum-preview-topic").description(
83661
83696
  symbiosis_mode: proposal.symbiosis_mode,
83662
83697
  excerpt: proposal.excerpt,
83663
83698
  isExisting: false,
83664
- selected: false,
83699
+ selected: true,
83665
83700
  subTopicId: chunk.subTopicId,
83666
83701
  parentTopicId: resolved.topicId,
83667
83702
  proposal