@mgiles/perk 3.0.0 → 3.2.0

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 (89) hide show
  1. package/extension/adapters/planAdapterPlannotator.ts +12 -9
  2. package/extension/doors/address.ts +11 -0
  3. package/extension/doors/commitCompact.ts +98 -10
  4. package/extension/doors/draftReviewWaveTools.ts +43 -15
  5. package/extension/doors/dreamWaveTools.ts +489 -0
  6. package/extension/doors/land.ts +6 -0
  7. package/extension/doors/learn.ts +16 -3
  8. package/extension/doors/lifecycleGates.ts +36 -1
  9. package/extension/doors/objectiveReviewBrowser.ts +36 -13
  10. package/extension/doors/objectiveStack.ts +424 -24
  11. package/extension/doors/planReviewBrowser.ts +30 -8
  12. package/extension/doors/plannotatorHandoff.ts +80 -8
  13. package/extension/doors/prReview.ts +158 -50
  14. package/extension/doors/prReviewBrowser.ts +75 -27
  15. package/extension/doors/prReviewDynamic.ts +33 -13
  16. package/extension/doors/ready.ts +209 -17
  17. package/extension/doors/reviewWaveTools.ts +61 -17
  18. package/extension/doors/stackReviewBrowser.ts +573 -0
  19. package/extension/doors/submit.ts +36 -10
  20. package/extension/doors/submitPrReview.ts +116 -19
  21. package/extension/factories/objectiveDraft.ts +95 -27
  22. package/extension/factories/objectiveDreamReport.ts +347 -0
  23. package/extension/factories/objectivePlan.ts +12 -6
  24. package/extension/factories/objectiveSave.ts +77 -1
  25. package/extension/factories/planReview.ts +173 -10
  26. package/extension/index.ts +88 -16
  27. package/extension/substrate/agentScratch.ts +171 -0
  28. package/extension/substrate/bindingDelivery.ts +9 -11
  29. package/extension/substrate/cache.ts +92 -2
  30. package/extension/substrate/command.ts +9 -6
  31. package/extension/substrate/config.ts +10 -3
  32. package/extension/substrate/git.ts +85 -2
  33. package/extension/substrate/paths.ts +2 -7
  34. package/extension/substrate/resolverLease.ts +363 -0
  35. package/extension/substrate/result.ts +3 -2
  36. package/extension/substrate/sessionData.ts +6 -4
  37. package/extension/substrate/sessionPointers.ts +3 -4
  38. package/extension/substrate/toolGating.ts +25 -0
  39. package/extension/substrate/workflowState.ts +57 -5
  40. package/extension/surfaces/report.ts +38 -12
  41. package/extension/surfaces/surfaces.ts +129 -7
  42. package/extension/vendor/btw/btw.ts +38 -6
  43. package/extension/waves/adversarialReviewWave.ts +34 -3
  44. package/extension/waves/draftReviewWave.ts +17 -1
  45. package/extension/waves/dreamReducerWave.ts +700 -0
  46. package/extension/waves/dreamReport.ts +1494 -0
  47. package/extension/waves/dreamWave.ts +927 -0
  48. package/extension/waves/harvestWave.ts +1 -1
  49. package/extension/waves/ponytail.ts +104 -0
  50. package/extension/waves/prReviewDynamicWave.ts +115 -34
  51. package/extension/waves/prReviewWave.ts +122 -17
  52. package/extension/waves/reportWave.ts +103 -7
  53. package/extension/worker/readOnlySession.ts +2 -3
  54. package/package.json +6 -3
  55. package/prompts/_fixtures/live.yaml +112 -0
  56. package/prompts/commit-and-compact-continuation.md +13 -0
  57. package/prompts/contexts/adapters/plannotator-objective.md +7 -1
  58. package/prompts/contexts/adapters/plannotator-plan.md +7 -1
  59. package/prompts/contexts/adapters/tombell-plan.md +4 -0
  60. package/prompts/contexts/plan-authoring.md +6 -5
  61. package/prompts/stages/conflict-resolution-continuation.md +6 -0
  62. package/prompts/stages/conflict-resolution.md +2 -2
  63. package/prompts/stages/learn-dream.md +10 -0
  64. package/prompts/stages/objective-author/adopt.md +1 -1
  65. package/prompts/stages/objective-author/file.md +1 -1
  66. package/prompts/stages/objective-author/seed.md +1 -1
  67. package/prompts/stages/objective-reconcile-ready.md +7 -0
  68. package/prompts/stages/objective-review-browser.md +1 -1
  69. package/prompts/stages/objective-sync.md +1 -1
  70. package/prompts/stages/plan-review-browser.md +1 -1
  71. package/prompts/stages/pr-review-browser/active.md +1 -1
  72. package/prompts/stages/pr-review-browser/foreign.md +1 -1
  73. package/prompts/stages/pr-review-dynamic.md +5 -5
  74. package/prompts/stages/pr-review-terminal/active.md +1 -1
  75. package/prompts/stages/pr-review-terminal/foreign.md +1 -1
  76. package/prompts/stages/pr-review-terminal/local.md +1 -1
  77. package/prompts/stages/pr-review.md +5 -5
  78. package/prompts/stages/stack-review/cold.md +1 -0
  79. package/prompts/stages/stack-review-browser/stack.md +23 -0
  80. package/shared/README.md +0 -3
  81. package/shared/bindings.yaml +6 -0
  82. package/shared/contracts.md +3784 -1851
  83. package/shared/registry.yaml +28 -13
  84. package/shared/schemas/inputs/review-post-batch.schema.json +14 -1
  85. package/shared/schemas/outputs/objective-doctor.schema.json +39 -1
  86. package/shared/schemas/outputs/objective-stack-status.schema.json +172 -1
  87. package/shared/schemas/outputs/pr-land.schema.json +3 -3
  88. package/shared/schemas/outputs/pr-ready.schema.json +110 -2
  89. package/shared/contracts-history.md +0 -605
@@ -324,22 +324,29 @@ export async function routeObjectiveReviewDecision(
324
324
  }
325
325
 
326
326
  /**
327
- * The background open: start the plan-review browser on the RENDERED objective draft, prime
328
- * BOTH companion surfaces the moment the port is picked (the URL is deterministic — see the
329
- * header note), observe readiness and the human decision in background tasks, and inject the
330
- * guidance immediately. While plannotator sets up, its in-process `console.error` chatter
331
- * re-routes through the TUI-safe report() seam (the debounce restores once setup goes quiet,
332
- * with the `finally` as a backstop). `deps` is the injectable browser-open seam (tests drive a
333
- * fake port picker/probe/clock). `rendered` is the reviewed markdown; `artifactRaw` is the raw
334
- * structured `objective-draft.json` bytes captured at open the stale guard's baseline.
327
+ * The guidance-returning open core: start the plan-review browser on the RENDERED objective
328
+ * draft, prime BOTH companion surfaces the moment the port is picked (the URL is deterministic
329
+ * — see the header note), observe readiness and the human decision in background tasks, and
330
+ * RETURN the composed guidance string (template + the `command:objective-review-browser`
331
+ * binding suffix) the caller decides how to deliver it (the door wrapper injects it via
332
+ * `sendUserMessage`; `plan_review`'s wave arm returns it as a non-terminating tool result,
333
+ * contracts.md §8.23). Returns `null` on the synchronous port-pick failure arm loudly
334
+ * reported here, then CALLER-handled: the door wrapper simply injects nothing (the report
335
+ * already spoke), while `plan_review`'s wave arm — the one fallback caller — falls open to the
336
+ * plain blocking review. While plannotator sets up, its in-process `console.error`
337
+ * chatter re-routes through the TUI-safe report() seam (the debounce restores once setup goes
338
+ * quiet, with the `finally` as a backstop). `deps` is the injectable browser-open seam (tests
339
+ * drive a fake port picker/probe/clock). `rendered` is the reviewed markdown; `artifactRaw` is
340
+ * the raw structured `objective-draft.json` bytes captured at open — the stale guard's
341
+ * baseline.
335
342
  */
336
- export async function openObjectiveReviewAndGuide(
343
+ export async function openObjectiveReviewSurface(
337
344
  pi: ExtensionAPI,
338
345
  ctx: ExtensionContext,
339
346
  gating: ToolGating,
340
347
  opts: { rendered: string; artifactRaw: string; custom?: string },
341
348
  deps: StartBrowserDeps = {},
342
- ): Promise<void> {
349
+ ): Promise<string | null> {
343
350
  let started: StartedSurface<ReviewOutcome>;
344
351
  try {
345
352
  // The plan-review bridge sends arbitrary string bytes as `planContent` — the rendered
@@ -358,7 +365,7 @@ export async function openObjectiveReviewAndGuide(
358
365
  `could not pick a free local port for the plannotator plan-review server: ${detail}`,
359
366
  { alsoLog: true },
360
367
  );
361
- return;
368
+ return null;
362
369
  }
363
370
 
364
371
  // Prime BOTH companion surfaces the moment the port is picked: push_annotations serves this
@@ -421,13 +428,29 @@ export async function openObjectiveReviewAndGuide(
421
428
  ? `working objective draft → plannotator browser review + draft reviewers (custom lane: ${opts.custom}) → APPROVE auto-saves / DENY returns feedback`
422
429
  : "working objective draft → plannotator browser review + draft reviewers → APPROVE auto-saves / DENY returns feedback",
423
430
  );
424
- pi.sendUserMessage(
431
+ return (
425
432
  objectiveReviewBrowserGuidance({
426
433
  ...(opts.custom !== undefined ? { custom: opts.custom } : {}),
427
- }) + bindingSuffix(ctx.cwd, `command:${SCOPE}`),
434
+ }) + bindingSuffix(ctx.cwd, `command:${SCOPE}`)
428
435
  );
429
436
  }
430
437
 
438
+ /**
439
+ * The door-facing open: the thin `sendUserMessage` wrapper over `openObjectiveReviewSurface` —
440
+ * the command handler's delivery is the guidance injection; a `null` core return (port-pick
441
+ * failure, already loudly reported) injects nothing.
442
+ */
443
+ export async function openObjectiveReviewAndGuide(
444
+ pi: ExtensionAPI,
445
+ ctx: ExtensionContext,
446
+ gating: ToolGating,
447
+ opts: { rendered: string; artifactRaw: string; custom?: string },
448
+ deps: StartBrowserDeps = {},
449
+ ): Promise<void> {
450
+ const guidance = await openObjectiveReviewSurface(pi, ctx, gating, opts, deps);
451
+ if (guidance !== null) pi.sendUserMessage(guidance);
452
+ }
453
+
431
454
  // ------------------------------------------------------------------------ registration
432
455
 
433
456
  /** Register the warm `/objective-review-browser` command (no tools — the companions are global). */