dsh-mnemon-source-skills 0.5.1 → 0.5.2

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.
@@ -217,6 +217,8 @@ interface EvalCase {
217
217
  title: string;
218
218
  prompt: string;
219
219
  context?: string;
220
+ /** Explicitly depends on image input unavailable to the text-only simulator. */
221
+ requiresVision?: boolean;
220
222
  checks: EvalCheck[];
221
223
  origin: {
222
224
  kind: 'review' | 'trajectory' | 'manual';
@@ -251,6 +253,8 @@ interface CaseResult {
251
253
  answer: string;
252
254
  summary?: string;
253
255
  error?: string;
256
+ /** Kept under verdict=error so older readers also exclude it from scores. */
257
+ unmeasuredReason?: 'requires-vision';
254
258
  }
255
259
  type RunStatus = 'running' | 'completed' | 'failed' | 'interrupted';
256
260
  interface BacktestRun {
@@ -299,6 +303,39 @@ interface SkillsPolicy {
299
303
  maxPendingPerSession: number;
300
304
  }
301
305
  declare const DEFAULT_SKILLS_POLICY: Readonly<SkillsPolicy>;
306
+ /** One removed skill waiting in the Trash, and where it came from. */
307
+ interface TrashEntry {
308
+ /** The stored directory name: `<removal time>-<skill name>`. */
309
+ id: string;
310
+ name: string;
311
+ /** A bundle directory, or a single flat `.md` file. */
312
+ kind: 'bundle' | 'file';
313
+ trashedAt: string;
314
+ bytes: number;
315
+ /** The root it was removed from; absent for entries removed before this was recorded. */
316
+ root?: SkillRootKind;
317
+ key?: string;
318
+ /** Exact original file or bundle path; its parent must match the recorded root. */
319
+ originalPath?: string;
320
+ /** The project that owned a project-level skill, independent of the selected workspace. */
321
+ workspace?: string;
322
+ }
323
+ interface TrashRestoreInput {
324
+ id: string;
325
+ root?: SkillRootKind;
326
+ name?: string;
327
+ replace?: boolean;
328
+ expectedHash?: string;
329
+ }
330
+ interface TrashRestorePreview {
331
+ name: string;
332
+ roots: SkillRootKind[];
333
+ needsRoot: boolean;
334
+ path?: string;
335
+ conflict?: {
336
+ hash: string;
337
+ };
338
+ }
302
339
  interface SkillsOverview {
303
340
  counts: {
304
341
  skills: number;
@@ -309,6 +346,8 @@ interface SkillsOverview {
309
346
  trajectories: number;
310
347
  cases: number;
311
348
  runsRunning: number;
349
+ /** Skills waiting in the Trash. */
350
+ trash: number;
312
351
  };
313
352
  lastReviewAt?: string;
314
353
  /** Suggestions and drafts waiting for the user, newest first. */
@@ -553,4 +592,4 @@ interface MarketInstall {
553
592
  installedAt: string;
554
593
  }
555
594
  //#endregion
556
- export { BacktestRun, CaseResult, CatalogView, DEFAULT_SKILLS_POLICY, type DetectedSource, DraftStatus, DraftView, EVOLUTION_SIGNALS, EvalCase, EvalCheck, EvidencePack, EvidenceReference, EvolutionSignal, LocalizedText, MarketAudit, MarketEntry, MarketInstall, MarketInstallState, MarketItem, MarketPreview, MarketRegistry, MarketRegistryFile, MarketSearchResult, MarketSource, type MarketSourceKind, MarketView, ReviewLogEntry, ReviewRecordInput, ReviewRecordResult, ReviewScore, RunStatus, RunTarget, RunTargetKind, SKILL_ROOT_KINDS, SKILL_ROOT_RANK, SUGGESTION_STATUSES, SkillCatalog, SkillDocument, SkillDraft, SkillInvocation, SkillProblem, SkillRoot, SkillRootKind, SkillSuggestion, SkillSummary, SkillVersion, SkillVersionReason, SkillsOverview, SkillsPolicy, SuggestionStatus, SuggestionView, Trajectory, TrajectoryAnnotation, TrajectoryStats, TrajectoryStep, TrajectoryStepKind, TrajectorySummary };
595
+ export { BacktestRun, CaseResult, CatalogView, DEFAULT_SKILLS_POLICY, type DetectedSource, DraftStatus, DraftView, EVOLUTION_SIGNALS, EvalCase, EvalCheck, EvidencePack, EvidenceReference, EvolutionSignal, LocalizedText, MarketAudit, MarketEntry, MarketInstall, MarketInstallState, MarketItem, MarketPreview, MarketRegistry, MarketRegistryFile, MarketSearchResult, MarketSource, type MarketSourceKind, MarketView, ReviewLogEntry, ReviewRecordInput, ReviewRecordResult, ReviewScore, RunStatus, RunTarget, RunTargetKind, SKILL_ROOT_KINDS, SKILL_ROOT_RANK, SUGGESTION_STATUSES, SkillCatalog, SkillDocument, SkillDraft, SkillInvocation, SkillProblem, SkillRoot, SkillRootKind, SkillSuggestion, SkillSummary, SkillVersion, SkillVersionReason, SkillsOverview, SkillsPolicy, SuggestionStatus, SuggestionView, Trajectory, TrajectoryAnnotation, TrajectoryStats, TrajectoryStep, TrajectoryStepKind, TrajectorySummary, TrashEntry, TrashRestoreInput, TrashRestorePreview };
package/lib/index.js CHANGED
@@ -4,7 +4,7 @@ import { homedir } from "node:os";
4
4
  import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
5
5
  import { COMPOSABLE_MEMORY_API_VERSION } from "dsh-mnemon/contracts";
6
6
  import { createHash, randomUUID } from "node:crypto";
7
- import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
7
+ import { cpSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, readlinkSync, renameSync, rmSync, statSync, symlinkSync, writeFileSync } from "node:fs";
8
8
  import { parse } from "yaml";
9
9
  import { fileURLToPath } from "node:url";
10
10
  import { gunzipSync, inflateRawSync } from "node:zlib";
@@ -397,6 +397,32 @@ function array(value) {
397
397
  function keyDirectory(skillKey) {
398
398
  return createHash("sha256").update(skillKey).digest("hex").slice(0, 16);
399
399
  }
400
+ /** A dangling symlink still occupies its name and must never be overwritten. */
401
+ function entryExists(path) {
402
+ try {
403
+ lstatSync(path);
404
+ return true;
405
+ } catch (error) {
406
+ if (["ENOENT", "ENOTDIR"].includes(error.code ?? "")) return false;
407
+ throw error;
408
+ }
409
+ }
410
+ /** Bytes an entry occupies on disk; an unreadable entry reports 0. */
411
+ function trashSize(path) {
412
+ try {
413
+ const info = lstatSync(path);
414
+ if (info.isSymbolicLink()) return 0;
415
+ if (!info.isDirectory()) return info.size;
416
+ return readdirSync(path).reduce((total, name) => total + trashSize(join(path, name)), 0);
417
+ } catch {
418
+ return 0;
419
+ }
420
+ }
421
+ /** The removal time encoded in an entry id, for entries that predate sidecars. */
422
+ function trashStamp(id) {
423
+ const match = /^(\d{4}-\d{2}-\d{2})T(\d{2})-(\d{2})-(\d{2})-(\d{3})Z-/u.exec(id);
424
+ return match === null ? void 0 : `${match[1]}T${match[2]}:${match[3]}:${match[4]}.${match[5]}Z`;
425
+ }
400
426
  /**
401
427
  * The Skills Source's own files under `<dataDir>/skills`. Every file is
402
428
  * replaced atomically; callers serialize writes with the storage lock.
@@ -533,9 +559,21 @@ var SkillsStore = class {
533
559
  deleteRegistryCache(id) {
534
560
  if (/^[a-z0-9][a-z0-9-]{0,62}$/u.test(id)) rmSync(this.path(join("market", "cache", `${id}.json`)), { force: true });
535
561
  }
536
- /** Move a bundle or a flat file out of DSH's reach, never deleting it. */
537
- trash(path, name) {
538
- const target = this.path(join("trash", `${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/gu, "-")}-${name}${basename(path).endsWith(".md") && !existsSync(join(path, "SKILL.md")) ? ".md" : ""}`));
562
+ /**
563
+ * Move a bundle or a flat file out of DSH's reach, never deleting it, and
564
+ * record where it came from so the page can offer to put it back.
565
+ */
566
+ trash(path, name, source = {}) {
567
+ const file = basename(path).endsWith(".md") && !existsSync(join(path, "SKILL.md"));
568
+ const trashedAt = /* @__PURE__ */ new Date();
569
+ let id;
570
+ let target;
571
+ do {
572
+ id = `${trashedAt.toISOString().replace(/[:.]/gu, "-")}-${name}${file ? ".md" : ""}`;
573
+ target = this.path(join("trash", id));
574
+ if (!entryExists(target)) break;
575
+ trashedAt.setTime(trashedAt.getTime() + 1);
576
+ } while (true);
539
577
  mkdirSync(join(target, ".."), {
540
578
  recursive: true,
541
579
  mode: 448
@@ -553,14 +591,101 @@ var SkillsStore = class {
553
591
  force: true
554
592
  });
555
593
  }
594
+ try {
595
+ this.writeJson(join("trash", `${id}.json`), {
596
+ version: 1,
597
+ name,
598
+ kind: file ? "file" : "bundle",
599
+ trashedAt: trashedAt.toISOString(),
600
+ ...source
601
+ });
602
+ } catch {}
556
603
  return target;
557
604
  }
558
- trashed() {
605
+ /** Every entry waiting in the Trash, newest first; entries removed before records existed still list. */
606
+ trashEntries() {
607
+ let names;
559
608
  try {
560
- return readdirSync(this.path("trash")).sort().reverse();
609
+ names = readdirSync(this.path("trash"));
561
610
  } catch {
562
611
  return [];
563
612
  }
613
+ const entries = [];
614
+ for (const id of names) {
615
+ if (id.endsWith(".json")) continue;
616
+ let record;
617
+ try {
618
+ record = object$1(this.readJson(join("trash", `${id}.json`)));
619
+ } catch {}
620
+ const stored = record === void 0 ? void 0 : record;
621
+ const name = typeof stored?.name === "string" ? stored.name : /^\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}-\d{3}Z-(.+)$/u.exec(id)?.[1]?.replace(/\.md$/u, "") ?? id;
622
+ entries.push({
623
+ id,
624
+ name,
625
+ kind: stored?.kind === "file" || stored?.kind === "bundle" ? stored.kind : id.endsWith(".md") ? "file" : "bundle",
626
+ trashedAt: typeof stored?.trashedAt === "string" ? stored.trashedAt : trashStamp(id) ?? (/* @__PURE__ */ new Date(0)).toISOString(),
627
+ bytes: trashSize(this.path(join("trash", id))),
628
+ ...stored?.root === void 0 ? {} : { root: stored.root },
629
+ ...typeof stored?.key === "string" ? { key: stored.key } : {},
630
+ ...typeof stored?.originalPath === "string" ? { originalPath: stored.originalPath } : {},
631
+ ...typeof stored?.workspace === "string" ? { workspace: stored.workspace } : {}
632
+ });
633
+ }
634
+ return entries.sort((a, b) => b.trashedAt.localeCompare(a.trashedAt) || b.id.localeCompare(a.id));
635
+ }
636
+ /** The entry with this id, or a refusal: the caller names what it wants back or gone. */
637
+ trashEntry(id) {
638
+ const entry = this.trashEntries().find((candidate) => candidate.id === id);
639
+ if (entry === void 0) throw new Error("trash entry not found: " + id);
640
+ return entry;
641
+ }
642
+ /** Stage a complete restore beside the target before removing the recoverable entry. */
643
+ restoreTrash(entry, to, content) {
644
+ const from = this.path(join("trash", entry.id));
645
+ if (entryExists(to)) throw new Error(`${entry.name} already exists there; rename or remove it first`);
646
+ mkdirSync(dirname(to), {
647
+ recursive: true,
648
+ mode: 448
649
+ });
650
+ const staging = join(dirname(to), `.mnemon-restore-${randomUUID()}`);
651
+ try {
652
+ if (lstatSync(from).isSymbolicLink()) symlinkSync(readlinkSync(from), staging, entry.kind === "bundle" ? "dir" : "file");
653
+ else cpSync(from, staging, {
654
+ recursive: true,
655
+ force: false,
656
+ errorOnExist: true,
657
+ verbatimSymlinks: true
658
+ });
659
+ if (content !== void 0) {
660
+ const document = entry.kind === "file" ? staging : join(staging, "SKILL.md");
661
+ if (lstatSync(staging).isSymbolicLink() || lstatSync(document).isSymbolicLink()) throw new Error("a linked skill cannot be renamed during restore");
662
+ writeFileSync(document, content);
663
+ }
664
+ if (entryExists(to)) throw new Error(`${entry.name} already exists there; rename or remove it first`);
665
+ renameSync(staging, to);
666
+ rmSync(from, {
667
+ recursive: true,
668
+ force: true
669
+ });
670
+ rmSync(this.path(join("trash", `${entry.id}.json`)), { force: true });
671
+ } finally {
672
+ rmSync(staging, {
673
+ recursive: true,
674
+ force: true
675
+ });
676
+ }
677
+ return to;
678
+ }
679
+ trashContent(entry) {
680
+ return readFileSync(this.path(join("trash", entry.id, ...entry.kind === "file" ? [] : ["SKILL.md"])), "utf8");
681
+ }
682
+ /** Delete an entry for good. */
683
+ purgeTrash(entry) {
684
+ rmSync(this.path(join("trash", entry.id)), {
685
+ recursive: true,
686
+ force: true
687
+ });
688
+ rmSync(this.path(join("trash", `${entry.id}.json`)), { force: true });
564
689
  }
565
690
  };
566
691
  //#endregion
@@ -2906,7 +3031,8 @@ var SkillsService = class {
2906
3031
  drafts: ledger.drafts.filter((draft) => draft.status === "ready").length,
2907
3032
  trajectories: ledger.trajectories.length,
2908
3033
  cases: evals.cases.filter((entry) => entry.enabled).length,
2909
- runsRunning: evals.runs.filter((run) => staleRun(run, now.getTime()).status === "running").length
3034
+ runsRunning: evals.runs.filter((run) => staleRun(run, now.getTime()).status === "running").length,
3035
+ trash: this.store.trashEntries().length
2910
3036
  },
2911
3037
  ...ledger.reviews[0] === void 0 ? {} : { lastReviewAt: ledger.reviews[0].at },
2912
3038
  attention: attention.slice(0, 20),
@@ -3134,7 +3260,8 @@ var SkillsService = class {
3134
3260
  const previous = this.requireHash(skill, input.expectedHash);
3135
3261
  const ledger = this.store.ledger();
3136
3262
  if (ledger.versions.every((version) => version.skillKey !== skill.key)) this.recordVersion(ledger, skill.key, previous, "original", void 0);
3137
- const trashedTo = this.store.trash(skill.layout === "bundle" ? dirname(skill.path) : skill.path, skill.name);
3263
+ const path = skill.layout === "bundle" ? dirname(skill.path) : skill.path;
3264
+ const trashedTo = this.store.trash(path, skill.name, this.trashOrigin(skill, this.catalog(workspace)));
3138
3265
  const now = this.clock().toISOString();
3139
3266
  for (const suggestion of ledger.suggestions) if (suggestion.skillKey === skill.key && suggestion.action === "update" && OPEN_STATUSES.has(suggestion.status)) {
3140
3267
  suggestion.status = "invalidated";
@@ -3144,6 +3271,122 @@ var SkillsService = class {
3144
3271
  return { trashedTo };
3145
3272
  });
3146
3273
  }
3274
+ /** Skills removed and waiting in the Trash, newest first. */
3275
+ trashItems() {
3276
+ return this.store.trashEntries();
3277
+ }
3278
+ trashOrigin(skill, catalog) {
3279
+ return {
3280
+ root: skill.root,
3281
+ key: skill.key,
3282
+ originalPath: skill.layout === "bundle" ? dirname(skill.path) : skill.path,
3283
+ ...skill.root.startsWith("project-") && catalog.projectRoot !== void 0 ? { workspace: catalog.projectRoot } : {}
3284
+ };
3285
+ }
3286
+ trashTarget(workspace, input) {
3287
+ const entry = this.store.trashEntry(input.id);
3288
+ const name = input.name ?? entry.name;
3289
+ if (!isSkillName(name)) throw new Error("a skill name uses lowercase letters, digits and single hyphens (max 64)");
3290
+ const selected = this.catalog(workspace);
3291
+ const root = input.root ?? entry.root;
3292
+ if (root !== void 0 && !SKILL_ROOT_KINDS.includes(root)) throw new Error("unknown skill root: " + root);
3293
+ if (root === void 0 || input.root === void 0 && root.startsWith("project-") && entry.workspace === void 0) return {
3294
+ entry,
3295
+ name,
3296
+ roots: selected.roots.map((item) => item.kind),
3297
+ destination: void 0
3298
+ };
3299
+ const catalog = input.root === void 0 && entry.workspace !== void 0 ? this.catalog(entry.workspace) : selected;
3300
+ const directory = rootPath(catalog, root);
3301
+ let path = join(directory, entry.kind === "file" ? `${name}.md` : name);
3302
+ if (input.root === void 0 && name === entry.name && entry.originalPath !== void 0) {
3303
+ if (!isAbsolute(entry.originalPath) || resolve(dirname(entry.originalPath)) !== resolve(directory)) throw new Error("the original skill root has changed; choose a restore location");
3304
+ path = entry.originalPath;
3305
+ }
3306
+ const conflict = catalog.skills.find((skill) => skill.root === root && skill.name === name);
3307
+ const occupied = [
3308
+ path,
3309
+ join(directory, name),
3310
+ join(directory, `${name}.md`)
3311
+ ].filter(entryExists);
3312
+ const conflictPath = conflict === void 0 ? void 0 : conflict.layout === "bundle" ? dirname(conflict.path) : conflict.path;
3313
+ if (occupied.some((candidate) => candidate !== conflictPath)) throw new Error("the restore location already holds another file; choose a different name");
3314
+ return {
3315
+ entry,
3316
+ name,
3317
+ roots: selected.roots.map((item) => item.kind),
3318
+ destination: {
3319
+ root,
3320
+ path,
3321
+ catalog,
3322
+ conflict,
3323
+ conflictPath
3324
+ }
3325
+ };
3326
+ }
3327
+ previewTrashRestore(workspace, input) {
3328
+ const target = this.trashTarget(workspace, input);
3329
+ return {
3330
+ name: target.name,
3331
+ roots: target.roots,
3332
+ needsRoot: target.destination === void 0,
3333
+ ...target.destination === void 0 ? {} : { path: target.destination.path },
3334
+ ...target.destination?.conflict === void 0 ? {} : { conflict: { hash: target.destination.conflict.hash } }
3335
+ };
3336
+ }
3337
+ /** Restore to the recorded origin, or an explicitly selected root; replacement preserves its predecessor. */
3338
+ restoreTrash(workspace, input) {
3339
+ return this.write(() => {
3340
+ const { entry, name, destination } = this.trashTarget(workspace, input);
3341
+ if (destination === void 0) throw new Error("choose a root for this Trash entry; its original location is unknown");
3342
+ const { root, path, catalog, conflict, conflictPath } = destination;
3343
+ if (conflict !== void 0 && (input.replace !== true || input.expectedHash !== conflict.hash)) throw new Error(`${name} already exists in ${root}; rename it or confirm replacement of the current version`);
3344
+ let content;
3345
+ if (name !== entry.name) {
3346
+ content = setFrontmatterKey(this.store.trashContent(entry), "name", name);
3347
+ validateSkillContent(content, name);
3348
+ }
3349
+ let displaced;
3350
+ try {
3351
+ if (conflict !== void 0) displaced = this.store.trash(conflictPath, conflict.name, this.trashOrigin(conflict, catalog));
3352
+ this.store.restoreTrash(entry, path, content);
3353
+ } catch (error) {
3354
+ if (displaced !== void 0 && !existsSync(conflictPath)) try {
3355
+ renameSync(displaced, conflictPath);
3356
+ } catch {}
3357
+ throw error;
3358
+ }
3359
+ const key = `${root}:${name}`;
3360
+ const ledger = this.store.ledger();
3361
+ try {
3362
+ content ??= readFileSync(entry.kind === "file" ? path : join(path, "SKILL.md"), "utf8");
3363
+ } catch {}
3364
+ if (content !== void 0) this.recordVersion(ledger, key, content, "restore", void 0);
3365
+ this.store.saveLedger(ledger);
3366
+ return {
3367
+ key,
3368
+ path
3369
+ };
3370
+ });
3371
+ }
3372
+ /** Delete a Trash entry for good. */
3373
+ purgeTrash(input) {
3374
+ return this.write(() => {
3375
+ const entry = this.store.trashEntry(input.id);
3376
+ this.store.purgeTrash(entry);
3377
+ this.store.saveLedger(this.store.ledger());
3378
+ return { purged: entry.id };
3379
+ });
3380
+ }
3381
+ /** Delete everything waiting in the Trash for good, and say how much went. */
3382
+ emptyTrash() {
3383
+ return this.write(() => {
3384
+ const entries = this.store.trashEntries();
3385
+ for (const entry of entries) this.store.purgeTrash(entry);
3386
+ if (entries.length > 0) this.store.saveLedger(this.store.ledger());
3387
+ return { purged: entries.length };
3388
+ });
3389
+ }
3147
3390
  restoreVersion(workspace, input) {
3148
3391
  return this.write(() => {
3149
3392
  const skill = findSkill(this.catalog(workspace), input.key);
@@ -3224,6 +3467,7 @@ var SkillsService = class {
3224
3467
  });
3225
3468
  }
3226
3469
  normalizeCase(input, existing, origin) {
3470
+ if (input.requiresVision !== void 0 && typeof input.requiresVision !== "boolean") throw new Error("requiresVision must be a boolean");
3227
3471
  if (!isSkillName(input.skillName)) throw new Error("a case belongs to a skill with a valid name");
3228
3472
  const title = clip(input.title, 120);
3229
3473
  const prompt = clip(input.prompt, 4e3);
@@ -3242,6 +3486,7 @@ var SkillsService = class {
3242
3486
  title,
3243
3487
  prompt,
3244
3488
  ...input.context === void 0 || input.context.trim() === "" ? {} : { context: clip(input.context, 4e3) },
3489
+ ...(input.requiresVision ?? existing?.requiresVision) === true ? { requiresVision: true } : {},
3245
3490
  checks,
3246
3491
  origin: existing?.origin ?? origin,
3247
3492
  enabled: input.enabled ?? existing?.enabled ?? true,
@@ -3928,7 +4173,7 @@ var SkillsService = class {
3928
4173
  const previous = existing === void 0 ? void 0 : readFileSync(existing.path, "utf8");
3929
4174
  let trashed;
3930
4175
  try {
3931
- if (existing !== void 0) trashed = this.store.trash(target, name);
4176
+ if (existing !== void 0) trashed = this.store.trash(target, name, this.trashOrigin(existing, catalog));
3932
4177
  moveInto(staged, existing?.layout === "flat" ? join(dirname(target), name) : target);
3933
4178
  } catch (error) {
3934
4179
  rmSync(staged, {
@@ -4041,7 +4286,8 @@ function caseInput(value, skillName) {
4041
4286
  must: check.must === true
4042
4287
  };
4043
4288
  }),
4044
- ...typeof input.enabled === "boolean" ? { enabled: input.enabled } : {}
4289
+ ...typeof input.enabled === "boolean" ? { enabled: input.enabled } : {},
4290
+ ...input.requiresVision === void 0 ? {} : { requiresVision: bool(input.requiresVision, "requiresVision") }
4045
4291
  };
4046
4292
  }
4047
4293
  function runTarget(value) {
@@ -4060,6 +4306,8 @@ function caseResult(value) {
4060
4306
  const input = memoryInputRecord(value, "result");
4061
4307
  const verdict = input.verdict;
4062
4308
  if (verdict !== "pass" && verdict !== "fail" && verdict !== "error") throw new Error("verdict must be pass, fail or error");
4309
+ const unmeasuredReason = input.unmeasuredReason;
4310
+ if (unmeasuredReason !== void 0 && (unmeasuredReason !== "requires-vision" || verdict !== "error")) throw new Error("unmeasuredReason requires requires-vision and an ungraded error verdict");
4063
4311
  const score = typeof input.score === "number" && Number.isFinite(input.score) ? Math.min(1, Math.max(0, input.score)) : 0;
4064
4312
  const checks = Array.isArray(input.checks) ? input.checks.slice(0, 8).map((item) => {
4065
4313
  const check = memoryInputRecord(item, "check result");
@@ -4078,7 +4326,8 @@ function caseResult(value) {
4078
4326
  steps: memoryInputStringArray(input.steps, "steps", 40) ?? [],
4079
4327
  answer: typeof input.answer === "string" ? input.answer : "",
4080
4328
  ...typeof input.summary === "string" ? { summary: input.summary } : {},
4081
- ...typeof input.error === "string" ? { error: input.error } : {}
4329
+ ...typeof input.error === "string" ? { error: input.error } : {},
4330
+ ...unmeasuredReason === void 0 ? {} : { unmeasuredReason }
4082
4331
  };
4083
4332
  }
4084
4333
  function signal(value) {
@@ -4306,6 +4555,13 @@ function createSkillsMemorySource(config = {}) {
4306
4555
  case "market-preview": return service.marketPreview(memoryInputText(fields.registryId, "registryId", 80), memoryInputText(fields.name, "name", 300), request.signal);
4307
4556
  case "market-search": return service.searchMarket(root, memoryInputText(fields.query, "query", 200), request.signal);
4308
4557
  case "installs": return service.installs();
4558
+ case "trash":
4559
+ case "trash-list": return service.trashItems();
4560
+ case "trash-restore-preview": return service.previewTrashRestore(root, {
4561
+ id: memoryInputText(fields.id, "id", 300),
4562
+ ...rootKind(fields.root) === void 0 ? {} : { root: rootKind(fields.root) },
4563
+ ...optionalText(fields.name, "name", 64) === void 0 ? {} : { name: optionalText(fields.name, "name", 64) }
4564
+ });
4309
4565
  default: throw new Error("unsupported Skills read operation: " + request.operation);
4310
4566
  }
4311
4567
  };
@@ -4348,6 +4604,21 @@ function createSkillsMemorySource(config = {}) {
4348
4604
  expectedHash: memoryInputText(fields.expectedHash, "expectedHash", 100)
4349
4605
  });
4350
4606
  break;
4607
+ case "trash-restore":
4608
+ value = await service.restoreTrash(root, {
4609
+ id: memoryInputText(fields.id, "id", 300),
4610
+ ...rootKind(fields.root) === void 0 ? {} : { root: rootKind(fields.root) },
4611
+ ...optionalText(fields.name, "name", 64) === void 0 ? {} : { name: optionalText(fields.name, "name", 64) },
4612
+ ...fields.replace === true ? { replace: true } : {},
4613
+ ...optionalText(fields.expectedHash, "expectedHash", 100) === void 0 ? {} : { expectedHash: optionalText(fields.expectedHash, "expectedHash", 100) }
4614
+ });
4615
+ break;
4616
+ case "trash-purge":
4617
+ value = await service.purgeTrash({ id: memoryInputText(fields.id, "id", 300) });
4618
+ break;
4619
+ case "trash-empty":
4620
+ value = await service.emptyTrash();
4621
+ break;
4351
4622
  case "version-restore":
4352
4623
  value = await service.restoreVersion(root, {
4353
4624
  key: memoryInputText(fields.key, "key", 200),
@@ -1,11 +1,12 @@
1
1
  import type { MnemonSourceManagementClient } from 'dsh-mnemon/client';
2
- import type { BacktestRun, CatalogView, DraftView, EvalCase, MarketPreview, MarketRegistry, MarketSearchResult, MarketView, EvidencePack, ReviewLogEntry, ReviewRecordResult, RunTarget, SkillDocument, SkillDraft, SkillRootKind, SkillSuggestion, SkillSummary, SkillVersion, SkillsOverview, SuggestionStatus, SuggestionView, Trajectory, TrajectorySummary } from '../contracts.ts';
2
+ import type { BacktestRun, CatalogView, DraftView, EvalCase, MarketPreview, MarketRegistry, MarketSearchResult, MarketView, EvidencePack, ReviewLogEntry, ReviewRecordResult, RunTarget, SkillDocument, SkillDraft, SkillRootKind, SkillSuggestion, SkillSummary, SkillVersion, SkillsOverview, SuggestionStatus, SuggestionView, Trajectory, TrajectorySummary, TrashEntry, TrashRestoreInput, TrashRestorePreview } from '../contracts.ts';
3
3
  export interface CaseDraft {
4
4
  id?: string;
5
5
  skillName: string;
6
6
  title: string;
7
7
  prompt: string;
8
8
  context?: string;
9
+ requiresVision?: boolean;
9
10
  checks: Array<{
10
11
  id?: string;
11
12
  text: string;
@@ -56,6 +57,22 @@ export interface SkillsPageClient {
56
57
  deleteSkill(key: string, expectedHash: string): Promise<{
57
58
  trashedTo: string;
58
59
  }>;
60
+ /** Removed skills waiting in the Trash, newest first. */
61
+ trash(): Promise<TrashEntry[]>;
62
+ /** Put a removed skill back; a new root moves it out of the one it came from. */
63
+ previewTrashRestore(input: TrashRestoreInput): Promise<TrashRestorePreview>;
64
+ restoreTrash(input: TrashRestoreInput): Promise<{
65
+ key: string;
66
+ path: string;
67
+ }>;
68
+ /** Delete a Trash entry for good. */
69
+ purgeTrash(id: string): Promise<{
70
+ purged: string;
71
+ }>;
72
+ /** Delete everything waiting in the Trash. */
73
+ emptyTrash(): Promise<{
74
+ purged: number;
75
+ }>;
59
76
  restoreVersion(key: string, versionId: string, expectedHash: string): Promise<SkillSummary>;
60
77
  dismissSuggestion(id: string): Promise<SkillSuggestion>;
61
78
  pinTrajectory(id: string, pinned: boolean): Promise<TrajectorySummary>;
@@ -0,0 +1,11 @@
1
+ import { type JSX } from 'react';
2
+ import type { SkillsLocation, SkillsPageContext } from './ui.tsx';
3
+ /**
4
+ * Skills taken out of DSH's reach: every removal still sits on disk under the
5
+ * Source's `trash` directory, so it can be put back, and only here can it be
6
+ * deleted for good.
7
+ */
8
+ export declare function TrashPage(props: {
9
+ context: SkillsPageContext;
10
+ location: SkillsLocation;
11
+ }): JSX.Element;
@@ -1,7 +1,7 @@
1
1
  import { type ReactNode } from 'react';
2
2
  import { installMemorySourceUI, type MemorySourcePageProps } from 'dsh-mnemon/client';
3
3
  import { type SkillsPageClient } from './api.ts';
4
- export type SkillsTab = 'skills' | 'evolution' | 'evals' | 'market';
4
+ export type SkillsTab = 'skills' | 'evolution' | 'evals' | 'market' | 'trash';
5
5
  /** What 进化 lists: suggestions still waiting, those handled, or the conversations reviews read. */
6
6
  export type EvolutionFilter = 'pending' | 'done' | 'evidence';
7
7
  /** Where a link inside the page points: a tab, and what to select there. */
@@ -199,6 +199,8 @@ export interface EvalCase {
199
199
  title: string;
200
200
  prompt: string;
201
201
  context?: string;
202
+ /** Explicitly depends on image input unavailable to the text-only simulator. */
203
+ requiresVision?: boolean;
202
204
  checks: EvalCheck[];
203
205
  origin: {
204
206
  kind: 'review' | 'trajectory' | 'manual';
@@ -233,6 +235,8 @@ export interface CaseResult {
233
235
  answer: string;
234
236
  summary?: string;
235
237
  error?: string;
238
+ /** Kept under verdict=error so older readers also exclude it from scores. */
239
+ unmeasuredReason?: 'requires-vision';
236
240
  }
237
241
  export type RunStatus = 'running' | 'completed' | 'failed' | 'interrupted';
238
242
  export interface BacktestRun {
@@ -281,6 +285,39 @@ export interface SkillsPolicy {
281
285
  maxPendingPerSession: number;
282
286
  }
283
287
  export declare const DEFAULT_SKILLS_POLICY: Readonly<SkillsPolicy>;
288
+ /** One removed skill waiting in the Trash, and where it came from. */
289
+ export interface TrashEntry {
290
+ /** The stored directory name: `<removal time>-<skill name>`. */
291
+ id: string;
292
+ name: string;
293
+ /** A bundle directory, or a single flat `.md` file. */
294
+ kind: 'bundle' | 'file';
295
+ trashedAt: string;
296
+ bytes: number;
297
+ /** The root it was removed from; absent for entries removed before this was recorded. */
298
+ root?: SkillRootKind;
299
+ key?: string;
300
+ /** Exact original file or bundle path; its parent must match the recorded root. */
301
+ originalPath?: string;
302
+ /** The project that owned a project-level skill, independent of the selected workspace. */
303
+ workspace?: string;
304
+ }
305
+ export interface TrashRestoreInput {
306
+ id: string;
307
+ root?: SkillRootKind;
308
+ name?: string;
309
+ replace?: boolean;
310
+ expectedHash?: string;
311
+ }
312
+ export interface TrashRestorePreview {
313
+ name: string;
314
+ roots: SkillRootKind[];
315
+ needsRoot: boolean;
316
+ path?: string;
317
+ conflict?: {
318
+ hash: string;
319
+ };
320
+ }
284
321
  export interface SkillsOverview {
285
322
  counts: {
286
323
  skills: number;
@@ -291,6 +328,8 @@ export interface SkillsOverview {
291
328
  trajectories: number;
292
329
  cases: number;
293
330
  runsRunning: number;
331
+ /** Skills waiting in the Trash. */
332
+ trash: number;
294
333
  };
295
334
  lastReviewAt?: string;
296
335
  /** Suggestions and drafts waiting for the user, newest first. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-mnemon-source-skills",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "Skills Source for Composable View Memory: DSH skill management, evolution suggestions, evidence trajectories and eval sets.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -62,7 +62,7 @@
62
62
  "@types/node": "^22.0.0",
63
63
  "@types/react": "^18.3.0",
64
64
  "@types/react-dom": "^18.3.0",
65
- "dsh-mnemon": "^0.5.34",
65
+ "dsh-mnemon": "^0.5.35",
66
66
  "jsdom": "^26.0.0",
67
67
  "react": "^18.2.0",
68
68
  "react-dom": "^18.2.0",