@linimin/pi-letscook 0.1.50 → 0.1.52

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.
@@ -14,6 +14,7 @@ import {
14
14
  markQueuedDriverPromptInFlight,
15
15
  registerCookCommand,
16
16
  } from "./driver";
17
+ import { handleCookNaturalLanguageTrigger } from "./input-routing";
17
18
  import {
18
19
  assessMissionAnchor,
19
20
  collectRecentDiscussionEntries,
@@ -41,6 +42,7 @@ import {
41
42
  buildContextProposalContinuationReason as buildExtractedContextProposalContinuationReason,
42
43
  buildEvaluationRoleContextLines as buildExtractedEvaluationRoleContextLines,
43
44
  buildEvaluationRoleReminderText as buildExtractedEvaluationRoleReminderText,
45
+ buildNaturalLanguageHandoffMetadataLines,
44
46
  buildResumeCapsule as buildExtractedResumeCapsule,
45
47
  buildSystemReminder as buildExtractedSystemReminder,
46
48
  maybeWriteContextProposalConfirmationSnapshot,
@@ -77,7 +79,7 @@ import {
77
79
  } from "./state-store";
78
80
  import { parseFirstNumber, parseYesNo } from "./transcription";
79
81
  import type { TranscriptionResult } from "./transcription";
80
- import type { CompletionStateSnapshot, CompletionRole, JsonRecord, LiveRoleActivity } from "./types";
82
+ import type { CompletionStateSnapshot, CompletionRole, CookNaturalLanguageHandoff, JsonRecord, LiveRoleActivity } from "./types";
81
83
 
82
84
  const PROTOCOL_ID = "completion";
83
85
  const ROLE_NAMES = [
@@ -207,9 +209,9 @@ function maybeWriteTestSnapshot(targetPath: string | undefined, content: string)
207
209
 
208
210
  const COOK_MAIN_CHAT_RERUN_GUIDANCE = "Discuss changes in the main chat and rerun /cook.";
209
211
  const COOK_BARE_ONLY_GUIDANCE =
210
- "/cook supports optional inline hints as high-priority intent cues, but mission selection still comes from recent discussion, repo truth, and the approval-only confirmation flow.";
212
+ "/cook remains the canonical workflow boundary. Natural-language routing can stay off, run in assist mode for short confirm-first handoffs, or run in router mode to review each non-bypass user turn before implementation starts, but the shared /cook flow still owns mission selection and confirmation.";
211
213
  const COOK_STRUCTURED_DISCUSSION_FAILURE_DETAIL =
212
- "/cook failed closed because recent discussion did not produce a clear execution-ready Mission/Scope/Constraints/Acceptance proposal for concrete repo changes. Clarify the concrete repo changes in the main chat and rerun /cook.";
214
+ "/cook failed closed because recent discussion did not produce a clear execution-ready Mission/Scope/Constraints/Acceptance proposal for concrete repo changes. Assist and router modes only offer the same /cook flow, and router recovery only replays to normal chat when you explicitly choose Send as normal chat, so clarify the concrete repo changes in the main chat and rerun /cook.";
213
215
 
214
216
  function buildCookCancellationMessage(prefix: string): string {
215
217
  return `${prefix}. ${COOK_MAIN_CHAT_RERUN_GUIDANCE}`;
@@ -894,18 +896,25 @@ function completionKickoff(
894
896
  evaluationProfile: string,
895
897
  intent: "auto" | "continue" | "refocus" = "auto",
896
898
  missionAnchor?: string,
899
+ naturalLanguageHandoff?: CookNaturalLanguageHandoff,
897
900
  ): string {
901
+ const naturalLanguageHandoffBlock = buildNaturalLanguageHandoffMetadataLines(naturalLanguageHandoff).join("\n");
898
902
  const intentBlock =
899
903
  intent === "continue" && missionAnchor
900
904
  ? `Existing canonical mission anchor:\n${missionAnchor}\n\nWorkflow intent:\n- Continue the existing workflow.\n- Treat the new user text as supplemental direction unless canonical reconciliation proves the mission itself must change.\n\n`
901
905
  : intent === "refocus" && missionAnchor
902
906
  ? `Updated canonical mission anchor:\n${missionAnchor}\n\nWorkflow intent:\n- The user explicitly refocused the workflow before this kickoff.\n- Re-read canonical .agent/** state and continue from the refocused mission.\n\n`
903
907
  : "";
904
- return `/skill:completion-protocol Start or continue the completion workflow for this repo.\n\nBefore acting, read:\n- ${SKILL_PATH}\n- ${REFERENCE_PATH}\n\nCanonical routing profile:\n- task_type: ${taskType}\n- evaluation_profile: ${evaluationProfile}\n\nUser goal:\n${goal}\n\n${intentBlock}Driver instructions:\n- Canonical truth is in .agent/**. Re-read .agent/state.json, .agent/plan.json, .agent/active-slice.json, and .agent/verification-evidence.json before acting when they exist.\n- If tracked completion contract files are missing or onboarding is required, invoke completion_role with role completion-bootstrapper.\n- Otherwise follow the mandatory dispatch rules from completion-protocol.\n- For selected, in-progress, committed, or done slices, treat .agent/active-slice.json as the canonical implementation contract and route to completion-regrounder if it drifts from the selected plan slice or the exact handoff is unclear.\n- Consume .agent/verification-evidence.json instead of temp-only verification summaries when it is populated.\n- Use completion_role for all completion-* role work. Do not directly implement tracked product changes yourself.\n- Continue dispatching mandatory roles while continuation_policy == continue.\n- Only stop for the user when continuation_policy is await_user_input, blocked, paused, or done.`;
908
+ return `/skill:completion-protocol Start or continue the completion workflow for this repo.\n\nBefore acting, read:\n- ${SKILL_PATH}\n- ${REFERENCE_PATH}\n\nCanonical routing profile:\n- task_type: ${taskType}\n- evaluation_profile: ${evaluationProfile}\n\nUser goal:\n${goal}\n\n${naturalLanguageHandoffBlock}${intentBlock}Driver instructions:\n- Canonical truth is in .agent/**. Re-read .agent/state.json, .agent/plan.json, .agent/active-slice.json, and .agent/verification-evidence.json before acting when they exist.\n- If tracked completion contract files are missing or onboarding is required, invoke completion_role with role completion-bootstrapper.\n- Otherwise follow the mandatory dispatch rules from completion-protocol.\n- For selected, in-progress, committed, or done slices, treat .agent/active-slice.json as the canonical implementation contract and route to completion-regrounder if it drifts from the selected plan slice or the exact handoff is unclear.\n- Consume .agent/verification-evidence.json instead of temp-only verification summaries when it is populated.\n- Use completion_role for all completion-* role work. Do not directly implement tracked product changes yourself.\n- Continue dispatching mandatory roles while continuation_policy == continue.\n- Only stop for the user when continuation_policy is await_user_input, blocked, paused, or done.`;
905
909
  }
906
910
 
907
- function completionResumePrompt(taskType: string, evaluationProfile: string): string {
908
- return `/skill:completion-protocol Resume the completion workflow from canonical state.\n\nBefore acting, read:\n- ${SKILL_PATH}\n- ${REFERENCE_PATH}\n\nCanonical routing profile:\n- task_type: ${taskType}\n- evaluation_profile: ${evaluationProfile}\n\nResume instructions:\n- Re-read .agent/state.json, .agent/plan.json, .agent/active-slice.json, and .agent/verification-evidence.json before acting.\n- If canonical state is missing, invalid, contradictory, stale, or ambiguous, route to completion-regrounder first.\n- For selected, in-progress, committed, or done slices, treat .agent/active-slice.json as the canonical implementation contract and route to completion-regrounder if it drifts from the selected plan slice or the exact handoff is unclear.\n- Consume .agent/verification-evidence.json instead of temp-only verification summaries when it is populated.\n- Continue from next_mandatory_role and next_mandatory_action.\n- Use completion_role for all completion-* role work.\n- Continue dispatching mandatory roles while continuation_policy == continue.\n- Only stop for the user when continuation_policy is await_user_input, blocked, paused, or done.`;
911
+ function completionResumePrompt(
912
+ taskType: string,
913
+ evaluationProfile: string,
914
+ naturalLanguageHandoff?: CookNaturalLanguageHandoff,
915
+ ): string {
916
+ const naturalLanguageHandoffBlock = buildNaturalLanguageHandoffMetadataLines(naturalLanguageHandoff).join("\n");
917
+ return `/skill:completion-protocol Resume the completion workflow from canonical state.\n\nBefore acting, read:\n- ${SKILL_PATH}\n- ${REFERENCE_PATH}\n\nCanonical routing profile:\n- task_type: ${taskType}\n- evaluation_profile: ${evaluationProfile}\n\n${naturalLanguageHandoffBlock}Resume instructions:\n- Re-read .agent/state.json, .agent/plan.json, .agent/active-slice.json, and .agent/verification-evidence.json before acting.\n- If canonical state is missing, invalid, contradictory, stale, or ambiguous, route to completion-regrounder first.\n- For selected, in-progress, committed, or done slices, treat .agent/active-slice.json as the canonical implementation contract and route to completion-regrounder if it drifts from the selected plan slice or the exact handoff is unclear.\n- Consume .agent/verification-evidence.json instead of temp-only verification summaries when it is populated.\n- Continue from next_mandatory_role and next_mandatory_action.\n- Use completion_role for all completion-* role work.\n- Continue dispatching mandatory roles while continuation_policy == continue.\n- Only stop for the user when continuation_policy is await_user_input, blocked, paused, or done.`;
909
918
  }
910
919
 
911
920
  export default function completionExtension(pi: ExtensionAPI) {
@@ -922,7 +931,7 @@ export default function completionExtension(pi: ExtensionAPI) {
922
931
  structuredDiscussionFailureDetail: COOK_STRUCTURED_DISCUSSION_FAILURE_DETAIL,
923
932
  mainChatRerunGuidance: COOK_MAIN_CHAT_RERUN_GUIDANCE,
924
933
  cookCommandSpec: {
925
- description: "/cook workflow: start, continue, refocus, or start the next round (optional hint supported)",
934
+ description: "/cook workflow: start, continue, refocus, or start the next round; /cook stays canonical while natural-language routing can be off, assist, or router",
926
935
  },
927
936
  buildContextProposalContinuationReason,
928
937
  completionKickoff,
@@ -952,6 +961,10 @@ export default function completionExtension(pi: ExtensionAPI) {
952
961
  shouldTreatBareActiveWorkflowProposalAsClearRefocus,
953
962
  };
954
963
 
964
+ pi.on("input", async (event, ctx) => {
965
+ return await handleCookNaturalLanguageTrigger(pi, event, ctx, driverDeps);
966
+ });
967
+
955
968
  pi.on("session_start", async (_event, ctx) => {
956
969
  await refreshCompletionStatus({ ctx, ...statusSurfaceArgs });
957
970
  if (shouldTestAutoContinueOnSessionStart()) {