pi-harness-runtime 1.1.330 → 1.1.332

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.
Files changed (113) hide show
  1. package/harness/wiki-integration.ts +227 -25
  2. package/package.json +1 -1
  3. package/packages/a2a-adapter/package.json +1 -1
  4. package/packages/agent-policy/package.json +1 -1
  5. package/packages/architecture-generator/package.json +1 -1
  6. package/packages/auth/package.json +1 -1
  7. package/packages/autonomous-refactor/package.json +1 -1
  8. package/packages/autonomous-runtime/package.json +1 -1
  9. package/packages/cache-strategy/package.json +1 -1
  10. package/packages/capability-registry/package.json +1 -1
  11. package/packages/checkpoint/package.json +1 -1
  12. package/packages/cli-plugin-sdk/package.json +1 -1
  13. package/packages/clipboard/package.json +1 -1
  14. package/packages/clipboard-plugin/package.json +1 -1
  15. package/packages/code-generation/package.json +1 -1
  16. package/packages/code-review/package.json +1 -1
  17. package/packages/codex-adapter/package.json +1 -1
  18. package/packages/codex-watcher/package.json +1 -1
  19. package/packages/config-capture/package.json +1 -1
  20. package/packages/context-compiler/package.json +1 -1
  21. package/packages/context-discovery/package.json +1 -1
  22. package/packages/context-manager/package.json +1 -1
  23. package/packages/cookie-sanitizer/package.json +1 -1
  24. package/packages/cost-optimizer/package.json +1 -1
  25. package/packages/dependency-analyzer/package.json +1 -1
  26. package/packages/django-plugin/package.json +1 -1
  27. package/packages/doc-generator/package.json +1 -1
  28. package/packages/durable-review/package.json +1 -1
  29. package/packages/e2e-tester/package.json +1 -1
  30. package/packages/evaluation-engine/package.json +1 -1
  31. package/packages/evaluation-runner/package.json +1 -1
  32. package/packages/event-bus/package.json +1 -1
  33. package/packages/event-store/package.json +1 -1
  34. package/packages/experience-replay/package.json +1 -1
  35. package/packages/feedback-collector/package.json +1 -1
  36. package/packages/file-copy-helper/package.json +1 -1
  37. package/packages/framework-detector/package.json +1 -1
  38. package/packages/framework-plugin-sdk/package.json +1 -1
  39. package/packages/frappe-plugin/package.json +1 -1
  40. package/packages/generic-web-plugin/package.json +1 -1
  41. package/packages/health-monitor/package.json +1 -1
  42. package/packages/intent-analyzer/package.json +1 -1
  43. package/packages/jev-judge/package.json +1 -1
  44. package/packages/knowledge-graph/package.json +1 -1
  45. package/packages/knowledge-retrieval/package.json +1 -1
  46. package/packages/laravel-plugin/package.json +1 -1
  47. package/packages/learning-engine/package.json +1 -1
  48. package/packages/mcp-adapter/package.json +1 -1
  49. package/packages/memory-engine/package.json +1 -1
  50. package/packages/milestone-manager/package.json +1 -1
  51. package/packages/model-registry/package.json +1 -1
  52. package/packages/nextjs-plugin/package.json +1 -1
  53. package/packages/notification/package.json +1 -1
  54. package/packages/observability/package.json +1 -1
  55. package/packages/okf-indexer/package.json +1 -1
  56. package/packages/paperclip-integration/package.json +1 -1
  57. package/packages/performance-optimizer/package.json +1 -1
  58. package/packages/privilege-broker/package.json +1 -1
  59. package/packages/project-analyzer/package.json +1 -1
  60. package/packages/project-bootstrap/package.json +1 -1
  61. package/packages/projection-engine/package.json +1 -1
  62. package/packages/prompt-compiler/package.json +1 -1
  63. package/packages/prompt-versioning/package.json +1 -1
  64. package/packages/provider-adapter-sdk/package.json +1 -1
  65. package/packages/provider-router/package.json +1 -1
  66. package/packages/provider-selector/package.json +1 -1
  67. package/packages/providers/package.json +1 -1
  68. package/packages/qdrant-skills/package.json +1 -1
  69. package/packages/quota-manager/package.json +1 -1
  70. package/packages/rate-limiter/package.json +1 -1
  71. package/packages/react-vite-plugin/package.json +1 -1
  72. package/packages/release-manager/package.json +1 -1
  73. package/packages/requirement-compiler/package.json +1 -1
  74. package/packages/runtime/package.json +1 -1
  75. package/packages/scheduler/package.json +1 -1
  76. package/packages/scheduler-adapter/package.json +1 -1
  77. package/packages/session/package.json +1 -1
  78. package/packages/session-api/package.json +1 -1
  79. package/packages/session-export/package.json +1 -1
  80. package/packages/shared-context/package.json +1 -1
  81. package/packages/skill-mcp-client/package.json +1 -1
  82. package/packages/skill-registry/package.json +1 -1
  83. package/packages/skills/package.json +1 -1
  84. package/packages/sprint-planner/package.json +1 -1
  85. package/packages/subscription-engine/package.json +1 -1
  86. package/packages/task-compiler/package.json +1 -1
  87. package/packages/telegram/package.json +1 -1
  88. package/packages/tencentdb-memory/package.json +1 -1
  89. package/packages/tencentdb-sync/package.json +1 -1
  90. package/packages/test-data-generator/package.json +1 -1
  91. package/packages/test-generator/package.json +1 -1
  92. package/packages/todo-bd-sync/package.json +1 -1
  93. package/packages/token-estimation/package.json +1 -1
  94. package/packages/token-optimizer/package.json +1 -1
  95. package/packages/trajectory/package.json +1 -1
  96. package/packages/tui/package.json +1 -1
  97. package/packages/types/package.json +1 -1
  98. package/packages/webmcp-tester/package.json +1 -1
  99. package/packages/wiki/dist/index.d.ts +14 -0
  100. package/packages/wiki/dist/index.d.ts.map +1 -1
  101. package/packages/wiki/dist/index.js +63 -2
  102. package/packages/wiki/dist/index.js.map +1 -1
  103. package/packages/wiki/dist/storage.d.ts +5 -1
  104. package/packages/wiki/dist/storage.d.ts.map +1 -1
  105. package/packages/wiki/dist/storage.js +55 -15
  106. package/packages/wiki/dist/storage.js.map +1 -1
  107. package/packages/wiki/package.json +1 -1
  108. package/packages/wiki/src/index.ts +75 -2
  109. package/packages/wiki/src/storage.ts +55 -16
  110. package/packages/workflow-events/package.json +1 -1
  111. package/packages/workspace-scanner/package.json +1 -1
  112. package/packages/worktree/package.json +1 -1
  113. package/packages/write-review/package.json +1 -1
@@ -181,11 +181,21 @@ function parseValue(value: string): YamlValue {
181
181
  if (/^-?\d+(\.\d+)?$/.test(value)) {
182
182
  return parseFloat(value);
183
183
  }
184
- if (value.startsWith("[") && value.endsWith("]")) {
185
- const content = value.slice(1, -1);
184
+ // Handle JSON-serialized values (objects and arrays)
185
+ const trimmed = value.trim();
186
+ if ((trimmed.startsWith("{") && trimmed.endsWith("}")) ||
187
+ (trimmed.startsWith("[") && trimmed.endsWith("]"))) {
188
+ try {
189
+ return JSON.parse(trimmed);
190
+ } catch {
191
+ // Fall through to string parsing
192
+ }
193
+ }
194
+ if (trimmed.startsWith("[") && trimmed.endsWith("]")) {
195
+ const content = trimmed.slice(1, -1);
186
196
  return content ? content.split(",").map((s) => s.trim().replace(/^["']|["']$/g, "")) : [];
187
197
  }
188
- return value.replace(/^["']|["']$/g, "");
198
+ return trimmed.replace(/^["']|["']$/g, "");
189
199
  }
190
200
 
191
201
  /**
@@ -200,8 +210,8 @@ export function serializeFrontmatter(
200
210
  if (value === undefined || value === null) continue;
201
211
 
202
212
 
203
- // Special handling for sources array - use JSON for reliability
204
- if (key === "sources" && Array.isArray(value)) {
213
+ // Special handling for sources and verification - use JSON for reliability
214
+ if ((key === "sources" || key === "verification") && (Array.isArray(value) || typeof value === "object")) {
205
215
  lines.push(`${key}: ${JSON.stringify(value)}`);
206
216
  continue;
207
217
  }
@@ -255,6 +265,10 @@ export class WikiStorage {
255
265
  private operations: WikiOperation[] = [];
256
266
  private stagedChanges: Map<string, StagedChange> = new Map();
257
267
  private initialized = false;
268
+ // Track explicitly modified entries to prevent stale data overwrites
269
+ private modifiedIds: Set<string> = new Set();
270
+ // Track explicitly deleted IDs to prevent resurrecting deletions
271
+ private deletedIds: Set<string> = new Set();
258
272
 
259
273
  constructor(config: WikiConfig) {
260
274
  this.config = config;
@@ -415,35 +429,51 @@ verification:
415
429
  }
416
430
 
417
431
  /**
418
- * Save page index to disk (atomic, merges with existing entries)
432
+ * Save page index to disk (atomic)
433
+ * Only applies changes from this manager instance (tracked via modifiedIds)
434
+ * Respects deletions tracked via deletedIds
419
435
  */
420
436
  private saveIndex(): void {
421
- // Reload from disk to handle concurrent writes from other processes
437
+ // Load current disk state
422
438
  const diskEntries = this.loadIndexFromDisk();
423
-
424
- // Start with disk state, then apply current in-memory state
425
- // This ensures deletions are persisted (not in this.index) and additions are included
426
439
  const merged = new Map<string, PageIndexEntry>();
427
440
 
428
- // Add all disk entries first
441
+ // Start with disk entries, filtering out deleted ones
429
442
  for (const [id, entry] of diskEntries) {
430
- // Only keep if still exists on disk
443
+ // Skip if explicitly deleted by this manager
444
+ if (this.deletedIds.has(id)) {
445
+ continue;
446
+ }
447
+ // Skip if page file no longer exists
431
448
  const pageFile = join(this.config.knowledgeDir, `${id}.md`);
432
- if (existsSync(pageFile)) {
449
+ if (!existsSync(pageFile)) {
450
+ continue;
451
+ }
452
+ // Keep disk entry unless this manager modified it
453
+ if (!this.modifiedIds.has(id)) {
433
454
  merged.set(id, entry);
434
455
  }
435
456
  }
436
457
 
437
- // Apply in-memory changes (adds/updates)
438
- for (const [id, entry] of this.index) {
439
- merged.set(id, entry);
458
+ // Apply only this manager's modifications
459
+ for (const id of this.modifiedIds) {
460
+ const entry = this.index.get(id);
461
+ if (entry) {
462
+ merged.set(id, entry);
463
+ }
440
464
  }
441
465
 
442
466
  const entries = Array.from(merged.values());
443
467
  const content = JSON.stringify(entries, null, 2);
444
468
  const tmpFile = this.config.indexFile + ".tmp";
469
+ // Validate temp path for symlink containment
470
+ this.ensureWithinDirectory(tmpFile, this.config.harnessDir);
445
471
  writeFileSync(tmpFile, content, "utf8");
446
472
  renameSync(tmpFile, this.config.indexFile);
473
+
474
+ // Clear successfully persisted mutations
475
+ this.modifiedIds.clear();
476
+ this.deletedIds.clear();
447
477
  }
448
478
 
449
479
  /**
@@ -586,7 +616,9 @@ verification:
586
616
  const content = combinePage(page.frontmatter, page.body);
587
617
  const pageFile = join(this.config.knowledgeDir, `${page.frontmatter.id}.md`);
588
618
  this.ensureWithinDirectory(pageFile, this.config.knowledgeDir);
619
+ // Validate temp path to prevent symlink bypass
589
620
  const tmpFile = pageFile + ".tmp";
621
+ this.ensureWithinDirectory(tmpFile, this.config.knowledgeDir);
590
622
  writeFileSync(tmpFile, content, "utf8");
591
623
  renameSync(tmpFile, pageFile);
592
624
 
@@ -602,6 +634,10 @@ verification:
602
634
  codeVersion: page.frontmatter.codeVersion,
603
635
  };
604
636
  this.index.set(entry.id, entry);
637
+ // Track this entry as modified so saveIndex applies it
638
+ this.modifiedIds.add(entry.id);
639
+ // Clear from deleted set if it was previously deleted
640
+ this.deletedIds.delete(entry.id);
605
641
  this.saveIndex();
606
642
  }
607
643
 
@@ -693,6 +729,9 @@ verification:
693
729
  unlinkSync(pageFile);
694
730
  }
695
731
  this.index.delete(pageId);
732
+ // Track this ID as deleted so saveIndex excludes it
733
+ this.deletedIds.add(pageId);
734
+ this.modifiedIds.delete(pageId);
696
735
  this.saveIndex();
697
736
  this.stagedChanges.delete(pageId);
698
737
  this.saveStaged();
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/workflow-events",
3
- "version": "1.1.330",
3
+ "version": "1.1.332",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "exports": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/workspace-scanner",
3
- "version": "1.1.330",
3
+ "version": "1.1.332",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "exports": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/worktree",
3
- "version": "1.1.330",
3
+ "version": "1.1.332",
4
4
  "description": "pi-harness-runtime — worktree",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moocoding/write-review",
3
- "version": "1.1.330",
3
+ "version": "1.1.332",
4
4
  "description": "Two-agent write-review loop with blackboard coordination",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",