@thanh01.pmt/domain-kit 0.6.1 → 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.
@@ -0,0 +1,3 @@
1
+
2
+ //# sourceMappingURL=chunk-HRSBIVAW.mjs.map
3
+ //# sourceMappingURL=chunk-HRSBIVAW.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-ZKLT27T4.mjs"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-HRSBIVAW.mjs"}
@@ -1104,11 +1104,13 @@ function excerpt(text, max) {
1104
1104
  const t = (text || "").trim();
1105
1105
  return t.length > max ? t.slice(0, max) + "..." : t;
1106
1106
  }
1107
- async function chatJson(client, system, user, transport) {
1107
+ async function chatJson(client, system, user, onTransport) {
1108
1108
  const r = await client.chat(
1109
1109
  [{ role: "system", content: system }, { role: "user", content: user }],
1110
1110
  { temperature: 0.1, maxTokens: parseInt(process.env.KG_MAX_TOKENS || "65536", 10) }
1111
1111
  );
1112
+ const t = r._transport ?? transportResultFrom("9router", client.model, { framingStripped: true });
1113
+ onTransport?.(t);
1112
1114
  return parseJsonFromLlm(r.content);
1113
1115
  }
1114
1116
  var LO_BATCH_SIZE = 10;
@@ -1122,6 +1124,10 @@ async function authorDepthLayersHierarchically(client, concepts, techStack, warn
1122
1124
  const uloByConcept = {};
1123
1125
  const cioByConcept = {};
1124
1126
  const sioByConcept = {};
1127
+ let lastTransport;
1128
+ const setTransport = (t) => {
1129
+ lastTransport = t;
1130
+ };
1125
1131
  concepts.map((c) => "- " + c.id + ": " + c.name + (c.description ? " \u2014 " + excerpt(c.description, 160) : "")).join("\n");
1126
1132
  const uloSystem = [
1127
1133
  "You are a Curriculum Design Expert writing Universal Learning Objectives (ULO).",
@@ -1150,7 +1156,7 @@ async function authorDepthLayersHierarchically(client, concepts, techStack, warn
1150
1156
  for (const batch of chunkConcepts(concepts, LO_BATCH_SIZE)) {
1151
1157
  const batchList = batch.map((c) => "- " + c.id + " (" + c.name + ")" + (c.description ? ": " + excerpt(c.description, 160) : "")).join("\n");
1152
1158
  const batchUser = "Concepts:\n" + batchList + '\n\nReturn JSON:\n{"ulos":[{"concept_id":"C1","ulo":"..."}]}';
1153
- const uloRes = await chatJson(client, uloSystem, batchUser, transportResultFrom("9router", client.model, { framingStripped: true }));
1159
+ const uloRes = await chatJson(client, uloSystem, batchUser, setTransport);
1154
1160
  for (const u of uloRes.ulos ?? []) {
1155
1161
  if (u.concept_id && u.ulo) uloByConcept[u.concept_id] = standardStatement(u.ulo);
1156
1162
  }
@@ -1189,7 +1195,7 @@ async function authorDepthLayersHierarchically(client, concepts, techStack, warn
1189
1195
  new Set(batch.map((c) => c.id));
1190
1196
  const batchUloContext = batch.map((c) => "- " + c.id + " (" + c.name + "): " + (uloByConcept[c.id] || "(missing)")).join("\n");
1191
1197
  const batchCioUser = "Approved ULOs:\n" + batchUloContext + '\n\nReturn JSON:\n{"cios":[{"concept_id":"C1","cio":"..."}]}';
1192
- const cioRes = await chatJson(client, cioSystem, batchCioUser, transportResultFrom("9router", client.model, { framingStripped: true }));
1198
+ const cioRes = await chatJson(client, cioSystem, batchCioUser, setTransport);
1193
1199
  for (const x of cioRes.cios ?? []) {
1194
1200
  if (x.concept_id && x.cio) cioByConcept[x.concept_id] = standardStatement(x.cio);
1195
1201
  }
@@ -1242,7 +1248,7 @@ async function authorDepthLayersHierarchically(client, concepts, techStack, warn
1242
1248
  "Return JSON:",
1243
1249
  '{"sios":[{"concept_id":"C1","sio":["...","..."]}]}'
1244
1250
  ].join("\n");
1245
- const sioRes = await chatJson(client, sioSystem, batchSioUser, transportResultFrom("9router", client.model, { framingStripped: true }));
1251
+ const sioRes = await chatJson(client, sioSystem, batchSioUser, setTransport);
1246
1252
  for (const x of sioRes.sios ?? []) {
1247
1253
  if (x.concept_id && Array.isArray(x.sio)) sioByConcept[x.concept_id] = x.sio.map((item) => standardStatement(String(item)));
1248
1254
  }
@@ -1254,14 +1260,17 @@ async function authorDepthLayersHierarchically(client, concepts, techStack, warn
1254
1260
  }
1255
1261
  }
1256
1262
  concepts.map((c) => c.id);
1257
- const auditOnce = () => auditDepthLayers(concepts.map((c) => ({
1258
- id: c.id,
1259
- name: c.name,
1260
- keywords: c.keywords ?? [],
1261
- ulo: uloByConcept[c.id],
1262
- cio: cioByConcept[c.id],
1263
- sio: sioByConcept[c.id]
1264
- })));
1263
+ const auditOnce = () => auditDepthLayers(
1264
+ concepts.map((c) => ({
1265
+ id: c.id,
1266
+ name: c.name,
1267
+ keywords: c.keywords ?? [],
1268
+ ulo: uloByConcept[c.id],
1269
+ cio: cioByConcept[c.id],
1270
+ sio: sioByConcept[c.id]
1271
+ })),
1272
+ lastTransport
1273
+ );
1265
1274
  let audits = auditOnce();
1266
1275
  const repairRound = async (round) => {
1267
1276
  const failingNow = audits.filter((a) => !a.passed);
@@ -1307,7 +1316,7 @@ async function authorDepthLayersHierarchically(client, concepts, techStack, warn
1307
1316
  '{"repairs":[{"concept_id":"C1","ulo":"...","cio":"...","sio":["..."]}]}'
1308
1317
  ].join("\n");
1309
1318
  try {
1310
- const repairRes = await chatJson(client, repairSystem, repairUser);
1319
+ const repairRes = await chatJson(client, repairSystem, repairUser, setTransport);
1311
1320
  for (const r of repairRes.repairs ?? []) {
1312
1321
  if (!r.concept_id) continue;
1313
1322
  if (r.ulo) uloByConcept[r.concept_id] = standardStatement(r.ulo);
@@ -1343,7 +1352,7 @@ async function authorDepthLayersHierarchically(client, concepts, techStack, warn
1343
1352
  "Depth-layer contract audit failed after repair for: " + detail + " \u2014 regenerate or fix the prompt contract (fail-closed, no silent fallback)"
1344
1353
  );
1345
1354
  }
1346
- return { uloByConcept, cioByConcept, sioByConcept, audits, warnings, lastTransport: audits[0]?.transport };
1355
+ return { uloByConcept, cioByConcept, sioByConcept, audits, warnings, lastTransport: lastTransport ?? audits[0]?.transport };
1347
1356
  }
1348
1357
  function cell(v) {
1349
1358
  return (v || "").split(",").map((s) => s.trim()).filter(Boolean);
@@ -2269,6 +2278,6 @@ async function decomposePhases(args) {
2269
2278
  return phases;
2270
2279
  }
2271
2280
 
2272
- export { CIO_CODE_RE, CONCEPT_CODE_RE, LEARNER_CLAUSE, SIO_CODE_RE, ULO_CODE_RE, assignConceptCodes, auditDepthLayers, auditPhasePlan, auditSyllabusCoverage, breakPrerequisiteCycles, cioActionSlug, cioCode, conceptCodeFromName, detectPrerequisiteCycles, escalateAndMapConcepts, extractFeatureSteps, extractFeatureStepsBatched, extractProjectOverview, extractScaffold, generateHybridGraph, generateKnowledgeGraph, sioCode, standardStatement, techTagFor, uloCode, verifyKnowledgeGraph, verifyProjectGraph };
2273
- //# sourceMappingURL=chunk-4UCXYRM3.mjs.map
2274
- //# sourceMappingURL=chunk-4UCXYRM3.mjs.map
2281
+ 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 };
2282
+ //# sourceMappingURL=chunk-O6Z7F7XI.mjs.map
2283
+ //# sourceMappingURL=chunk-O6Z7F7XI.mjs.map