@narumitw/pi-plan-mode 0.58.0 → 0.58.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/dist/chunks/{chunk-QHHHBTDO.js → chunk-HF7ZEYIC.js} +29 -111
- package/dist/chunks/chunk-HF7ZEYIC.js.map +7 -0
- package/dist/chunks/{interactive-ui-UNJGC2RQ.js → interactive-ui-UK7IGPOE.js} +13 -41
- package/dist/chunks/interactive-ui-UK7IGPOE.js.map +7 -0
- package/dist/index.ts +25 -82
- package/dist/index.ts.map +2 -2
- package/package.json +50 -51
- package/src/active-implementation-menu.ts +57 -60
- package/src/command.ts +22 -22
- package/src/completion-tool.ts +53 -56
- package/src/extension-runtime.ts +5 -5
- package/src/finalization-request.ts +40 -44
- package/src/fresh-handoff-coordinator.ts +38 -41
- package/src/fresh-implementation.ts +293 -310
- package/src/implementation-models.ts +25 -30
- package/src/implementation-retention.ts +109 -123
- package/src/message-transform.ts +218 -252
- package/src/mode-contract.ts +46 -49
- package/src/plan-action-controller.ts +134 -155
- package/src/plan-action-menus.ts +390 -408
- package/src/plan-export-controller.ts +23 -28
- package/src/plan-export-screen.ts +13 -13
- package/src/plan-export.ts +85 -102
- package/src/plan-launch-menu.ts +119 -119
- package/src/plan-mode.ts +2017 -2098
- package/src/presentation.ts +84 -108
- package/src/prompt.ts +1 -1
- package/src/question-tool.ts +239 -267
- package/src/required-tools.ts +15 -19
- package/src/saved-plan-menu.ts +82 -84
- package/src/saved-plan-preflight.ts +29 -33
- package/src/settings-menu.ts +470 -513
- package/src/settings.ts +393 -452
- package/src/state.ts +167 -198
- package/src/tool-policy.ts +634 -699
- package/src/tool-selection.ts +39 -44
- package/src/workflow-mutex.ts +66 -66
- package/dist/chunks/chunk-QHHHBTDO.js.map +0 -7
- package/dist/chunks/interactive-ui-UNJGC2RQ.js.map +0 -7
|
@@ -3,46 +3,41 @@ import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
|
3
3
|
export const MAX_PENDING_IMPLEMENTATION_MODEL_IDENTIFIER_LENGTH = 512;
|
|
4
4
|
|
|
5
5
|
export interface ImplementationModelOverride {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
provider: string;
|
|
7
|
+
modelId: string;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export interface AvailableImplementationModel {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
provider: string;
|
|
12
|
+
id: string;
|
|
13
|
+
name?: string;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export function isPendingImplementationModelIdentifier(value: unknown): value is string {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
return (
|
|
18
|
+
typeof value === "string" &&
|
|
19
|
+
value.trim().length > 0 &&
|
|
20
|
+
value.length <= MAX_PENDING_IMPLEMENTATION_MODEL_IDENTIFIER_LENGTH
|
|
21
|
+
);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
export function snapshotAvailableImplementationModels(
|
|
25
|
-
|
|
26
|
-
):
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
);
|
|
36
|
-
return availableModel ? [availableModel] : [];
|
|
37
|
-
});
|
|
24
|
+
export function snapshotAvailableImplementationModels(ctx: ExtensionContext): AvailableImplementationModel[] {
|
|
25
|
+
const getAvailable = ctx.modelRegistry.getAvailable;
|
|
26
|
+
const availableModels = typeof getAvailable === "function" ? getAvailable.call(ctx.modelRegistry) : [];
|
|
27
|
+
const scopedModels = ctx.scopedModels ?? [];
|
|
28
|
+
if (scopedModels.length === 0) return availableModels;
|
|
29
|
+
return scopedModels.flatMap((entry) => {
|
|
30
|
+
const availableModel = availableModels.find(
|
|
31
|
+
(model) => model.provider === entry.model.provider && model.id === entry.model.id,
|
|
32
|
+
);
|
|
33
|
+
return availableModel ? [availableModel] : [];
|
|
34
|
+
});
|
|
38
35
|
}
|
|
39
36
|
|
|
40
37
|
export function findAvailableImplementationModel(
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
models: readonly AvailableImplementationModel[],
|
|
39
|
+
configured: ImplementationModelOverride | undefined,
|
|
43
40
|
): AvailableImplementationModel | undefined {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
(model) => model.provider === configured.provider && model.id === configured.modelId,
|
|
47
|
-
);
|
|
41
|
+
if (!configured) return undefined;
|
|
42
|
+
return models.find((model) => model.provider === configured.provider && model.id === configured.modelId);
|
|
48
43
|
}
|
|
@@ -1,146 +1,132 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
findHistoryImplementationArtifact,
|
|
3
|
+
injectActiveImplementationContext,
|
|
4
|
+
isEmptyAssistantMessage,
|
|
5
|
+
messageContainsExactPlanModeImplementationHandoff,
|
|
6
|
+
messageContainsInactivePlanModeArtifact,
|
|
7
|
+
messageContainsLegacyPlanModeContextArtifact,
|
|
8
|
+
messageContainsPlanModeImplementationContextArtifact,
|
|
9
|
+
messageContainsPlanModeImplementationHandoff,
|
|
10
|
+
stripPlanModeCompletionCallsFromMessage,
|
|
11
|
+
stripProposedPlanBlocksFromMessage,
|
|
12
12
|
} from "./message-transform.js";
|
|
13
13
|
import type { ImplementationPlanRetention } from "./settings.js";
|
|
14
14
|
import type { ActiveImplementationPlan, PlanModeState } from "./state.js";
|
|
15
15
|
|
|
16
16
|
export function retentionLabel(retention: ImplementationPlanRetention) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
return {
|
|
18
|
+
"clear-on-start": "Off — conversation history only",
|
|
19
|
+
"clear-after-first-run": "Through first implementation run",
|
|
20
|
+
keep: "Until manually cleared",
|
|
21
|
+
}[retention];
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export function implementationRetentionPreview(retention: ImplementationPlanRetention) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
return {
|
|
26
|
+
"clear-on-start": "Plan reinjection: Off; use conversation history only.",
|
|
27
|
+
"clear-after-first-run": "Plan reinjection: Through the first implementation run.",
|
|
28
|
+
keep: "Plan reinjection: Until /plan exit.",
|
|
29
|
+
}[retention];
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export interface ImplementationContextResult {
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
messages: unknown[];
|
|
34
|
+
clearActiveImplementationId?: string;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
export interface ImplementationRetentionCoordinator {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
): string | undefined;
|
|
43
|
-
reset(): void;
|
|
38
|
+
restore(activeImplementation: ActiveImplementationPlan | undefined): void;
|
|
39
|
+
transformContext(messages: unknown[], state: PlanModeState): ImplementationContextResult;
|
|
40
|
+
implementationSettled(activeImplementation: ActiveImplementationPlan | undefined): string | undefined;
|
|
41
|
+
reset(): void;
|
|
44
42
|
}
|
|
45
43
|
|
|
46
44
|
export function createImplementationRetentionCoordinator(): ImplementationRetentionCoordinator {
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
let implementationWithDeliveredContext: string | undefined;
|
|
46
|
+
let restoredImplementationAwaitingContext: string | undefined;
|
|
49
47
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
};
|
|
69
|
-
}
|
|
48
|
+
return {
|
|
49
|
+
restore(activeImplementation) {
|
|
50
|
+
restoredImplementationAwaitingContext =
|
|
51
|
+
activeImplementation && activeImplementation.retention !== "keep" ? activeImplementation.id : undefined;
|
|
52
|
+
},
|
|
53
|
+
transformContext(messages, state) {
|
|
54
|
+
const messagesWithoutLegacyContext = messages.filter(
|
|
55
|
+
(message) => !messageContainsLegacyPlanModeContextArtifact(message),
|
|
56
|
+
);
|
|
57
|
+
if (state.enabled) {
|
|
58
|
+
return {
|
|
59
|
+
messages: messagesWithoutLegacyContext.filter(
|
|
60
|
+
(message) =>
|
|
61
|
+
!messageContainsPlanModeImplementationContextArtifact(message) &&
|
|
62
|
+
!messageContainsPlanModeImplementationHandoff(message),
|
|
63
|
+
),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
70
66
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
stripPlanModeCompletionCallsFromMessage(
|
|
101
|
-
message,
|
|
102
|
-
message === historyToolCallMessage ? historyArtifact?.toolCallId : undefined,
|
|
103
|
-
),
|
|
104
|
-
)
|
|
105
|
-
.filter((message) => !isEmptyAssistantMessage(message));
|
|
106
|
-
if (!activeImplementation) return { messages: filteredMessages };
|
|
67
|
+
const activeImplementation = state.activeImplementation;
|
|
68
|
+
const inactiveMessages = activeImplementation
|
|
69
|
+
? messagesWithoutLegacyContext
|
|
70
|
+
: messagesWithoutLegacyContext.filter(
|
|
71
|
+
(message) =>
|
|
72
|
+
!messageContainsPlanModeImplementationContextArtifact(message) &&
|
|
73
|
+
!messageContainsPlanModeImplementationHandoff(message),
|
|
74
|
+
);
|
|
75
|
+
const historyArtifact = activeImplementation ? undefined : findHistoryImplementationArtifact(inactiveMessages);
|
|
76
|
+
const historyArtifactMessage = historyArtifact ? inactiveMessages[historyArtifact.messageIndex] : undefined;
|
|
77
|
+
const historyToolCallMessage =
|
|
78
|
+
historyArtifact?.toolCallMessageIndex !== undefined
|
|
79
|
+
? inactiveMessages[historyArtifact.toolCallMessageIndex]
|
|
80
|
+
: undefined;
|
|
81
|
+
const filteredMessages = inactiveMessages
|
|
82
|
+
.filter((message) => message === historyArtifactMessage || !messageContainsInactivePlanModeArtifact(message))
|
|
83
|
+
.map((message) =>
|
|
84
|
+
message === historyArtifactMessage && historyArtifact?.kind === "legacy"
|
|
85
|
+
? message
|
|
86
|
+
: stripProposedPlanBlocksFromMessage(message),
|
|
87
|
+
)
|
|
88
|
+
.map((message) =>
|
|
89
|
+
stripPlanModeCompletionCallsFromMessage(
|
|
90
|
+
message,
|
|
91
|
+
message === historyToolCallMessage ? historyArtifact?.toolCallId : undefined,
|
|
92
|
+
),
|
|
93
|
+
)
|
|
94
|
+
.filter((message) => !isEmptyAssistantMessage(message));
|
|
95
|
+
if (!activeImplementation) return { messages: filteredMessages };
|
|
107
96
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
);
|
|
119
|
-
if (!deliveredCurrentHandoff) return { messages: contextualMessages };
|
|
120
|
-
restoredImplementationAwaitingContext = undefined;
|
|
97
|
+
const contextualMessages = injectActiveImplementationContext(filteredMessages, activeImplementation);
|
|
98
|
+
// A busy /plan implement queues its handoff behind an older run. Do not arm cleanup
|
|
99
|
+
// until that exact handoff reaches context; a restored session has no older run to drain.
|
|
100
|
+
const deliveredCurrentHandoff =
|
|
101
|
+
restoredImplementationAwaitingContext === activeImplementation.id ||
|
|
102
|
+
filteredMessages.some((message) =>
|
|
103
|
+
messageContainsExactPlanModeImplementationHandoff(message, activeImplementation.plan),
|
|
104
|
+
);
|
|
105
|
+
if (!deliveredCurrentHandoff) return { messages: contextualMessages };
|
|
106
|
+
restoredImplementationAwaitingContext = undefined;
|
|
121
107
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
108
|
+
if (activeImplementation.retention === "clear-after-first-run") {
|
|
109
|
+
implementationWithDeliveredContext = activeImplementation.id;
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
messages: contextualMessages,
|
|
113
|
+
clearActiveImplementationId:
|
|
114
|
+
activeImplementation.retention === "clear-on-start" ? activeImplementation.id : undefined,
|
|
115
|
+
};
|
|
116
|
+
},
|
|
117
|
+
implementationSettled(activeImplementation) {
|
|
118
|
+
if (
|
|
119
|
+
activeImplementation?.retention !== "clear-after-first-run" ||
|
|
120
|
+
implementationWithDeliveredContext !== activeImplementation.id
|
|
121
|
+
) {
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
implementationWithDeliveredContext = undefined;
|
|
125
|
+
return activeImplementation.id;
|
|
126
|
+
},
|
|
127
|
+
reset() {
|
|
128
|
+
implementationWithDeliveredContext = undefined;
|
|
129
|
+
restoredImplementationAwaitingContext = undefined;
|
|
130
|
+
},
|
|
131
|
+
};
|
|
146
132
|
}
|