@thanh01.pmt/domain-kit 0.6.2 → 0.6.3

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.
@@ -1,5 +1,5 @@
1
1
  import '../chunk-HRSBIVAW.mjs';
2
- export { CIO_CODE_RE, CONCEPT_CODE_RE, LEARNER_CLAUSE, SIO_CODE_RE, ULO_CODE_RE, assignConceptCodes, auditDepthLayers, auditPhasePlan, auditSyllabusCoverage, authorDepthLayersHierarchically, breakPrerequisiteCycles, cioActionSlug, cioCode, conceptCodeFromName, detectPrerequisiteCycles, escalateAndMapConcepts, extractFeatureSteps, extractFeatureStepsBatched, extractProjectOverview, extractScaffold, generateHybridGraph, generateKnowledgeGraph, sioCode, standardStatement, techTagFor, uloCode, verifyKnowledgeGraph, verifyProjectGraph } from '../chunk-GVBDM746.mjs';
2
+ export { CIO_CODE_RE, CONCEPT_CODE_RE, LEARNER_CLAUSE, SIO_CODE_RE, ULO_CODE_RE, assignConceptCodes, auditDepthLayers, auditPhasePlan, auditSyllabusCoverage, authorDepthLayersHierarchically, breakPrerequisiteCycles, cioActionSlug, cioCode, conceptCodeFromName, detectPrerequisiteCycles, escalateAndMapConcepts, extractFeatureSteps, extractFeatureStepsBatched, extractProjectOverview, extractScaffold, generateHybridGraph, generateKnowledgeGraph, sioCode, standardStatement, techTagFor, uloCode, verifyKnowledgeGraph, verifyProjectGraph } from '../chunk-O6Z7F7XI.mjs';
3
3
  import '../chunk-7A2SG466.mjs';
4
4
  import '../chunk-IBVXXVGE.mjs';
5
5
  import '../chunk-T4Y2DE2W.mjs';
package/dist/index.cjs CHANGED
@@ -3963,11 +3963,13 @@ function excerpt(text, max) {
3963
3963
  const t = (text || "").trim();
3964
3964
  return t.length > max ? t.slice(0, max) + "..." : t;
3965
3965
  }
3966
- async function chatJson(client, system, user, transport) {
3966
+ async function chatJson(client, system, user, onTransport) {
3967
3967
  const r = await client.chat(
3968
3968
  [{ role: "system", content: system }, { role: "user", content: user }],
3969
3969
  { temperature: 0.1, maxTokens: parseInt(process.env.KG_MAX_TOKENS || "65536", 10) }
3970
3970
  );
3971
+ const t = r._transport ?? transportResultFrom("9router", client.model, { framingStripped: true });
3972
+ onTransport?.(t);
3971
3973
  return parseJsonFromLlm(r.content);
3972
3974
  }
3973
3975
  var LO_BATCH_SIZE = 10;
@@ -3981,6 +3983,10 @@ async function authorDepthLayersHierarchically(client, concepts, techStack, warn
3981
3983
  const uloByConcept = {};
3982
3984
  const cioByConcept = {};
3983
3985
  const sioByConcept = {};
3986
+ let lastTransport;
3987
+ const setTransport = (t) => {
3988
+ lastTransport = t;
3989
+ };
3984
3990
  concepts.map((c) => "- " + c.id + ": " + c.name + (c.description ? " \u2014 " + excerpt(c.description, 160) : "")).join("\n");
3985
3991
  const uloSystem = [
3986
3992
  "You are a Curriculum Design Expert writing Universal Learning Objectives (ULO).",
@@ -4009,7 +4015,7 @@ async function authorDepthLayersHierarchically(client, concepts, techStack, warn
4009
4015
  for (const batch of chunkConcepts(concepts, LO_BATCH_SIZE)) {
4010
4016
  const batchList = batch.map((c) => "- " + c.id + " (" + c.name + ")" + (c.description ? ": " + excerpt(c.description, 160) : "")).join("\n");
4011
4017
  const batchUser = "Concepts:\n" + batchList + '\n\nReturn JSON:\n{"ulos":[{"concept_id":"C1","ulo":"..."}]}';
4012
- const uloRes = await chatJson(client, uloSystem, batchUser, transportResultFrom("9router", client.model, { framingStripped: true }));
4018
+ const uloRes = await chatJson(client, uloSystem, batchUser, setTransport);
4013
4019
  for (const u of uloRes.ulos ?? []) {
4014
4020
  if (u.concept_id && u.ulo) uloByConcept[u.concept_id] = standardStatement(u.ulo);
4015
4021
  }
@@ -4048,7 +4054,7 @@ async function authorDepthLayersHierarchically(client, concepts, techStack, warn
4048
4054
  new Set(batch.map((c) => c.id));
4049
4055
  const batchUloContext = batch.map((c) => "- " + c.id + " (" + c.name + "): " + (uloByConcept[c.id] || "(missing)")).join("\n");
4050
4056
  const batchCioUser = "Approved ULOs:\n" + batchUloContext + '\n\nReturn JSON:\n{"cios":[{"concept_id":"C1","cio":"..."}]}';
4051
- const cioRes = await chatJson(client, cioSystem, batchCioUser, transportResultFrom("9router", client.model, { framingStripped: true }));
4057
+ const cioRes = await chatJson(client, cioSystem, batchCioUser, setTransport);
4052
4058
  for (const x of cioRes.cios ?? []) {
4053
4059
  if (x.concept_id && x.cio) cioByConcept[x.concept_id] = standardStatement(x.cio);
4054
4060
  }
@@ -4101,7 +4107,7 @@ async function authorDepthLayersHierarchically(client, concepts, techStack, warn
4101
4107
  "Return JSON:",
4102
4108
  '{"sios":[{"concept_id":"C1","sio":["...","..."]}]}'
4103
4109
  ].join("\n");
4104
- const sioRes = await chatJson(client, sioSystem, batchSioUser, transportResultFrom("9router", client.model, { framingStripped: true }));
4110
+ const sioRes = await chatJson(client, sioSystem, batchSioUser, setTransport);
4105
4111
  for (const x of sioRes.sios ?? []) {
4106
4112
  if (x.concept_id && Array.isArray(x.sio)) sioByConcept[x.concept_id] = x.sio.map((item) => standardStatement(String(item)));
4107
4113
  }
@@ -4113,14 +4119,17 @@ async function authorDepthLayersHierarchically(client, concepts, techStack, warn
4113
4119
  }
4114
4120
  }
4115
4121
  concepts.map((c) => c.id);
4116
- const auditOnce = () => auditDepthLayers(concepts.map((c) => ({
4117
- id: c.id,
4118
- name: c.name,
4119
- keywords: c.keywords ?? [],
4120
- ulo: uloByConcept[c.id],
4121
- cio: cioByConcept[c.id],
4122
- sio: sioByConcept[c.id]
4123
- })));
4122
+ const auditOnce = () => auditDepthLayers(
4123
+ concepts.map((c) => ({
4124
+ id: c.id,
4125
+ name: c.name,
4126
+ keywords: c.keywords ?? [],
4127
+ ulo: uloByConcept[c.id],
4128
+ cio: cioByConcept[c.id],
4129
+ sio: sioByConcept[c.id]
4130
+ })),
4131
+ lastTransport
4132
+ );
4124
4133
  let audits = auditOnce();
4125
4134
  const repairRound = async (round) => {
4126
4135
  const failingNow = audits.filter((a) => !a.passed);
@@ -4166,7 +4175,7 @@ async function authorDepthLayersHierarchically(client, concepts, techStack, warn
4166
4175
  '{"repairs":[{"concept_id":"C1","ulo":"...","cio":"...","sio":["..."]}]}'
4167
4176
  ].join("\n");
4168
4177
  try {
4169
- const repairRes = await chatJson(client, repairSystem, repairUser);
4178
+ const repairRes = await chatJson(client, repairSystem, repairUser, setTransport);
4170
4179
  for (const r of repairRes.repairs ?? []) {
4171
4180
  if (!r.concept_id) continue;
4172
4181
  if (r.ulo) uloByConcept[r.concept_id] = standardStatement(r.ulo);
@@ -4202,7 +4211,7 @@ async function authorDepthLayersHierarchically(client, concepts, techStack, warn
4202
4211
  "Depth-layer contract audit failed after repair for: " + detail + " \u2014 regenerate or fix the prompt contract (fail-closed, no silent fallback)"
4203
4212
  );
4204
4213
  }
4205
- return { uloByConcept, cioByConcept, sioByConcept, audits, warnings, lastTransport: audits[0]?.transport };
4214
+ return { uloByConcept, cioByConcept, sioByConcept, audits, warnings, lastTransport: lastTransport ?? audits[0]?.transport };
4206
4215
  }
4207
4216
  function cell(v) {
4208
4217
  return (v || "").split(",").map((s) => s.trim()).filter(Boolean);