@thanh01.pmt/curriculum-kit 1.0.5 → 1.0.7

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.
@@ -235,6 +235,36 @@ var MediaLedger = class {
235
235
  doneCount() {
236
236
  return this.listByStatus("done").length;
237
237
  }
238
+ /**
239
+ * Scan artifact content và seed pending entries cho mọi placeholder [IMAGE: slug].
240
+ * Được gọi sau khi agent sinh artifact (trước khi Curator duyệt) — đây là cầu nối
241
+ * duy nhất giữa "agent chèn placeholder" và "sổ cái có entry để Curator/Fulfiller xử".
242
+ * Idempotent: slug đã có entry active (pending/approved/done) → giữ nguyên;
243
+ * chỉ re-describe khi entry trước bị rejected/failed.
244
+ */
245
+ seedFromArtifact(artifactId, content) {
246
+ const seeded = [];
247
+ const re = /\[IMAGE\s*:\s*([a-z0-9][a-z0-9-]*)\s*\]/gi;
248
+ const seen = /* @__PURE__ */ new Set();
249
+ let m;
250
+ while ((m = re.exec(content)) !== null) {
251
+ const slug = m[1].toLowerCase();
252
+ if (seen.has(slug)) continue;
253
+ seen.add(slug);
254
+ const existing = this.entries.get(slug);
255
+ const isActive = existing && (existing.status === "pending" || existing.status === "approved" || existing.status === "done");
256
+ if (isActive) continue;
257
+ seeded.push(this.upsert({
258
+ slug,
259
+ artifactId,
260
+ name: slug.replace(/^(img-|image-)/, "").replace(/-/g, " "),
261
+ description: `Placeholder ch\xE8n b\u1EDFi agent trong artifact ${artifactId} \u2014 ch\u1EDD Curator enrich (m\xF4 t\u1EA3 g\u1ED1c ch\u01B0a c\xF3).`,
262
+ mode: "generate",
263
+ status: "pending"
264
+ }));
265
+ }
266
+ return seeded;
267
+ }
238
268
  };
239
269
 
240
270
  // src/errors/index.ts