@danypops/papyrus 0.34.0 → 0.34.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danypops/papyrus",
3
- "version": "0.34.0",
3
+ "version": "0.34.1",
4
4
  "description": "Daemon-backed graph artifacts, evidence-bearing tasks, rules, skills, and native TUI workflows for Pi",
5
5
  "type": "module",
6
6
  "keywords": ["pi-package"],
@@ -48,6 +48,13 @@ export interface ArtifactQuery {
48
48
  limit?: number;
49
49
  /** Trashed artifacts (see artifact-trash.ts) are excluded from every query by default; set true to include them, e.g. for a trash-listing view. */
50
50
  includeTrashed?: boolean;
51
+ /**
52
+ * Restrict to exactly these ids, still subject to every other filter (kind, trash exclusion,
53
+ * etc.) -- for a caller that already has a bounded candidate id set (e.g. Tasks.list's
54
+ * project/graph scope) and needs query()'s own trash-exclusion without a full-kind scan.
55
+ * Empty array is a real "match nothing", not "unset".
56
+ */
57
+ ids?: string[];
51
58
  }
52
59
 
53
60
  export interface ArtifactGraphOptions {
package/src/ops.ts CHANGED
@@ -290,6 +290,11 @@ export function queryArtifacts(db: Db, filter: ArtifactQuery): Artifact[] {
290
290
  const conditions: string[] = [];
291
291
  const params: unknown[] = [];
292
292
  if (!filter.includeTrashed) conditions.push("id NOT IN (SELECT artifact_id FROM artifact_trash)");
293
+ if (filter.ids) {
294
+ if (filter.ids.length === 0) return [];
295
+ conditions.push(`id IN (${filter.ids.map(() => "?").join(", ")})`);
296
+ params.push(...filter.ids);
297
+ }
293
298
  if (filter.kind) { conditions.push("kind = ?"); params.push(filter.kind); }
294
299
  if (filter.status) { conditions.push("status = ?"); params.push(filter.status); }
295
300
  if (filter.statuses) {
@@ -237,9 +237,16 @@ export class Tasks {
237
237
  const selectedIds = selection.mode === "graph" ? this.descendantIds(selection.rootTaskId!, ids) : new Set(ids);
238
238
  const text = filter.text?.toLowerCase();
239
239
  const labels = filter.labels ?? [];
240
+ // query(), unlike get(), excludes trash by default -- a trashed task's id stays in
241
+ // task_scopes until the retention window actually purges it, so building this candidate
242
+ // set from get() per id (deliberately trash-transparent, for show/restore) would otherwise
243
+ // leak a trashed task back into list results for the entire grace period. Scoped by ids
244
+ // rather than a bare kind query, so this stays bounded to exactly the already-bounded
245
+ // selectedIds set instead of scanning every task in the database.
246
+ const notTrashed = new Map(this.artifacts.query({ kind: "task", excludeSubtype: DISCUSSION_SUBTYPE, ids: [...selectedIds] }).map((task) => [task.id, task]));
240
247
  return [...selectedIds]
241
- .map((id) => this.artifacts.get(id))
242
- .filter((task): task is Artifact => task?.kind === "task" && !isDiscussionArtifact(task))
248
+ .map((id) => notTrashed.get(id))
249
+ .filter((task): task is Artifact => task !== undefined)
243
250
  .filter((task) => filter.status === undefined || task.status === filter.status)
244
251
  .filter((task) => text === undefined || task.title.toLowerCase().includes(text) || task.body.toLowerCase().includes(text))
245
252
  .filter((task) => labels.every((label) => task.labels.includes(label)))