@autopilot-harness/port-copilot-cli 0.5.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.
- package/LICENSE +21 -0
- package/dist/index.d.ts +167 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +631 -0
- package/dist/index.js.map +1 -0
- package/package.json +55 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Autopilot Harness contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { type PhaseActionConfig, type ReviewEngine, type StateStore } from "@autopilot-harness/core";
|
|
2
|
+
/** Copilot CLI userPromptSubmitted stdin (camelCase + VS Code compat). */
|
|
3
|
+
export interface CopilotSubmitPayload {
|
|
4
|
+
session_id?: string;
|
|
5
|
+
sessionId?: string;
|
|
6
|
+
prompt?: string;
|
|
7
|
+
/** Informational — store uses install-root projectRoot. */
|
|
8
|
+
cwd?: string;
|
|
9
|
+
transcript_path?: string;
|
|
10
|
+
transcriptPath?: string;
|
|
11
|
+
conversation_id?: string;
|
|
12
|
+
conversationId?: string;
|
|
13
|
+
permission_mode?: string;
|
|
14
|
+
permissionMode?: string;
|
|
15
|
+
turn_id?: string;
|
|
16
|
+
model?: string;
|
|
17
|
+
hook_event_name?: string;
|
|
18
|
+
hookEventName?: string;
|
|
19
|
+
timestamp?: number | string;
|
|
20
|
+
}
|
|
21
|
+
/** Copilot CLI userPromptTransformed stdin. */
|
|
22
|
+
export interface CopilotTransformPayload {
|
|
23
|
+
session_id?: string;
|
|
24
|
+
sessionId?: string;
|
|
25
|
+
conversation_id?: string;
|
|
26
|
+
conversationId?: string;
|
|
27
|
+
cwd?: string;
|
|
28
|
+
prompt?: string;
|
|
29
|
+
transformedPrompt?: string;
|
|
30
|
+
hook_event_name?: string;
|
|
31
|
+
hookEventName?: string;
|
|
32
|
+
timestamp?: number | string;
|
|
33
|
+
}
|
|
34
|
+
/** Copilot CLI postToolUse stdin (edit / create / …). */
|
|
35
|
+
export interface CopilotEditPayload {
|
|
36
|
+
session_id?: string;
|
|
37
|
+
sessionId?: string;
|
|
38
|
+
conversation_id?: string;
|
|
39
|
+
conversationId?: string;
|
|
40
|
+
cwd?: string;
|
|
41
|
+
tool_name?: string;
|
|
42
|
+
toolName?: string;
|
|
43
|
+
tool_input?: Record<string, unknown> | string;
|
|
44
|
+
toolInput?: Record<string, unknown> | string;
|
|
45
|
+
toolArgs?: Record<string, unknown> | string;
|
|
46
|
+
}
|
|
47
|
+
/** Copilot CLI agentStop / Stop stdin. */
|
|
48
|
+
export interface CopilotStopPayload {
|
|
49
|
+
session_id?: string;
|
|
50
|
+
sessionId?: string;
|
|
51
|
+
conversation_id?: string;
|
|
52
|
+
conversationId?: string;
|
|
53
|
+
cwd?: string;
|
|
54
|
+
transcript_path?: string;
|
|
55
|
+
transcriptPath?: string;
|
|
56
|
+
status?: string;
|
|
57
|
+
stop_hook_active?: boolean;
|
|
58
|
+
stopHookActive?: boolean;
|
|
59
|
+
stop_reason?: string;
|
|
60
|
+
stopReason?: string;
|
|
61
|
+
hook_event_name?: string;
|
|
62
|
+
hookEventName?: string;
|
|
63
|
+
last_assistant_message?: string;
|
|
64
|
+
turn_id?: string;
|
|
65
|
+
error?: unknown;
|
|
66
|
+
message?: unknown;
|
|
67
|
+
reason?: unknown;
|
|
68
|
+
timestamp?: number | string;
|
|
69
|
+
}
|
|
70
|
+
export interface CopilotPortConfig {
|
|
71
|
+
phaseActions?: PhaseActionConfig;
|
|
72
|
+
}
|
|
73
|
+
export declare const COPILOT_PLATFORM = "copilot-cli";
|
|
74
|
+
/**
|
|
75
|
+
* Public research (2026-09): no documented raise/disable for ~8 consecutive
|
|
76
|
+
* agentStop blocks. Ports must not claim unlimited Stop-continue.
|
|
77
|
+
*/
|
|
78
|
+
export declare const COPILOT_STOP_CAP_RAISE_FOUND = false;
|
|
79
|
+
/** Host runaway guard (CLI ≥1.0.72) when raise is absent. */
|
|
80
|
+
export declare const COPILOT_STOP_CONSECUTIVE_BLOCK_CAP = 8;
|
|
81
|
+
/** PostToolUse matcher for init (runtime toolName; camelCase hooks). */
|
|
82
|
+
export declare const COPILOT_POST_TOOL_USE_MATCHER = "edit|create";
|
|
83
|
+
export declare const MAX_NEED_PICK_SLUGS = 40;
|
|
84
|
+
export declare const MAX_NEED_PICK_CONTEXT_CHARS = 2000;
|
|
85
|
+
export declare const MAX_HOOK_STDIO_CHARS = 8192;
|
|
86
|
+
/** Bound hostile/huge toolArgs JSON before parse. */
|
|
87
|
+
export declare const MAX_TOOL_ARGS_JSON_CHARS = 1048576;
|
|
88
|
+
/** Bound gate file bytes (JSON record + margin). */
|
|
89
|
+
export declare const MAX_GATE_FILE_BYTES: number;
|
|
90
|
+
/**
|
|
91
|
+
* Durable UPS→Transform handoff (separate hook processes).
|
|
92
|
+
* File under `.autopilot/copilot-gate/` — session.last_error is not writable via upsertSession.
|
|
93
|
+
*/
|
|
94
|
+
export declare const COPILOT_GATE_DIR: string;
|
|
95
|
+
/** Stash kinds: needPick prepends; block replaces model-facing prompt. */
|
|
96
|
+
export type CopilotGateKind = "needPick" | "block";
|
|
97
|
+
export interface CopilotGateRecord {
|
|
98
|
+
kind: CopilotGateKind;
|
|
99
|
+
text: string;
|
|
100
|
+
}
|
|
101
|
+
/** UPS stdout is dropped by Copilot command hooks — result is for tests only. */
|
|
102
|
+
export interface CopilotSubmitResult {
|
|
103
|
+
/** Always ignored by Copilot command UPS — kept for unit tests / symmetry. */
|
|
104
|
+
_sideEffectsOnly?: true;
|
|
105
|
+
/** Test mirror of what was stashed for Transform. */
|
|
106
|
+
_stashedGate?: string;
|
|
107
|
+
}
|
|
108
|
+
export interface CopilotTransformResult {
|
|
109
|
+
modifiedTransformedPrompt?: string;
|
|
110
|
+
}
|
|
111
|
+
export interface CopilotStopResult {
|
|
112
|
+
decision?: "block" | "allow";
|
|
113
|
+
reason?: string;
|
|
114
|
+
continue?: boolean;
|
|
115
|
+
stopReason?: string;
|
|
116
|
+
}
|
|
117
|
+
export declare function loopCountFromStopHookActive(payload: CopilotStopPayload): number;
|
|
118
|
+
export declare function collectCopilotStopErrorText(payload: CopilotStopPayload): string;
|
|
119
|
+
export declare function normalizeCopilotStopStatus(payload: CopilotStopPayload, opts?: {
|
|
120
|
+
status?: "completed" | "error" | "aborted";
|
|
121
|
+
}): "completed" | "error" | "aborted";
|
|
122
|
+
/** Channel A needPick body (Transform injects; UPS does not rely on stdout). */
|
|
123
|
+
export declare function buildNeedPickContext(userMessage: unknown, candidates?: ReadonlyArray<{
|
|
124
|
+
slug?: string;
|
|
125
|
+
}>): string;
|
|
126
|
+
/**
|
|
127
|
+
* Paths from Copilot edit/create tools.
|
|
128
|
+
* Common fields: path / filePath / file_path / target_file.
|
|
129
|
+
*/
|
|
130
|
+
export declare function filePathsFromCopilotEdit(payload: CopilotEditPayload): string[];
|
|
131
|
+
/** File-mutating tools (bash relies on Stop dirty-arm). */
|
|
132
|
+
export declare function isCopilotEditTool(toolName: string): boolean;
|
|
133
|
+
/** Hash conversation id so sanitized collisions cannot cross-wire gates. */
|
|
134
|
+
export declare function safeGateFileId(conversationId: string): string;
|
|
135
|
+
/**
|
|
136
|
+
* Gate file path — always under `projectRoot/.autopilot/copilot-gate/`.
|
|
137
|
+
* Rejects empty roots and paths that resolve outside the project.
|
|
138
|
+
*/
|
|
139
|
+
export declare function submitGateFilePath(projectRoot: string, conversationId: string): string;
|
|
140
|
+
/** Stash gate text for Transform (busy / needPick / hard errors). Never throws. */
|
|
141
|
+
export declare function stashSubmitGate(projectRoot: string, conversationId: string, message: string, kind?: CopilotGateKind): string;
|
|
142
|
+
/** Read + clear submit gate; returns null if absent. Never throws. */
|
|
143
|
+
export declare function takeSubmitGate(projectRoot: string, conversationId: string): CopilotGateRecord | null;
|
|
144
|
+
/** Drop a stale gate so a later Transform cannot inject a previous turn's notice. */
|
|
145
|
+
export declare function clearSubmitGate(projectRoot: string, conversationId: string): void;
|
|
146
|
+
/**
|
|
147
|
+
* userPromptSubmitted → core triggers / FSM.
|
|
148
|
+
* Host drops command UPS stdout — visibility via Transform stash.
|
|
149
|
+
*/
|
|
150
|
+
export declare function handleUserPromptSubmit(store: StateStore, payload: CopilotSubmitPayload, projectRoot: string, portConfig?: CopilotPortConfig): CopilotSubmitResult;
|
|
151
|
+
/**
|
|
152
|
+
* userPromptTransformed — inject stashed UPS gate (needPick / busy / errors).
|
|
153
|
+
* needPick: prepend notice. block/busy: replace model-facing content (do not keep user RUN).
|
|
154
|
+
*/
|
|
155
|
+
export declare function handleUserPromptTransformed(store: StateStore, payload: CopilotTransformPayload, projectRoot: string): CopilotTransformResult;
|
|
156
|
+
/** postToolUse → markCodeEdited for edit/create product paths. */
|
|
157
|
+
export declare function handlePostToolUse(store: StateStore, payload: CopilotEditPayload, projectRoot: string): void;
|
|
158
|
+
/**
|
|
159
|
+
* agentStop → ReviewEngine.
|
|
160
|
+
* Continue: decision:block + reason.
|
|
161
|
+
* Hard stop: empty object (Copilot has no continue:false; do not invent Claude fields).
|
|
162
|
+
* Host caps ~8 consecutive blocks when COPILOT_STOP_CAP_RAISE_FOUND is false.
|
|
163
|
+
*/
|
|
164
|
+
export declare function handleStop(engine: ReviewEngine, payload: CopilotStopPayload, opts?: {
|
|
165
|
+
status?: "completed" | "error" | "aborted";
|
|
166
|
+
}): CopilotStopResult;
|
|
167
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAwBL,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,UAAU,EAChB,MAAM,yBAAyB,CAAC;AAEjC,0EAA0E;AAC1E,MAAM,WAAW,oBAAoB;IACnC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2DAA2D;IAC3D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,E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GAGG;AACH,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,GACrB,MAAM,CAgBR;AAED,mFAAmF;AACnF,wBAAgB,eAAe,CAC7B,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,EACtB,OAAO,EAAE,MAAM,EACf,IAAI,GAAE,eAAyB,GAC9B,MAAM,CAoCR;AAkCD,sEAAsE;AACtE,wBAAgB,cAAc,CAC5B,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,GACrB,iBAAiB,GAAG,IAAI,CA+B1B;AAED,qFAAqF;AACrF,wBAAgB,eAAe,CAC7B,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,GACrB,IAAI,CAON;AAmBD;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,oBAAoB,EAC7B,WAAW,EAAE,MAAM,EACnB,UAAU,CAAC,EAAE,iBAAiB,GAC7B,mBAAmB,CAWrB;AAkLD;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,uBAAuB,EAChC,WAAW,EAAE,MAAM,GAClB,sBAAsB,CAMxB;AA8ED,kEAAkE;AAClE,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,kBAAkB,EAC3B,WAAW,EAAE,MAAM,GAClB,IAAI,CAMN;AAgDD;;;;;GAKG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,kBAAkB,EAC3B,IAAI,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,GAAG,SAAS,CAAA;CAAE,GACpD,iBAAiB,CAMnB"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,631 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { applyOff, applyOn, applyReplan, applyResume, applyResumeReview, applyRun, applyTrackPick, ensureAmbientReviewSession, effectiveReviewingItemId, firstUnchecked, isChannelANeedPick, isHarnessFollowupMessage, isProductCodeEdit, isRecoverOrStuckFollowupMessage, isSafeTrackSlug, isUserAbortText, loadProjectHookConfig, loadProjectReviewConfig, notePlansDirEdit, parseAdvanceNextItemId, parseChecklist, parseTrigger, } from "@autopilot-harness/core";
|
|
5
|
+
export const COPILOT_PLATFORM = "copilot-cli";
|
|
6
|
+
/**
|
|
7
|
+
* Public research (2026-09): no documented raise/disable for ~8 consecutive
|
|
8
|
+
* agentStop blocks. Ports must not claim unlimited Stop-continue.
|
|
9
|
+
*/
|
|
10
|
+
export const COPILOT_STOP_CAP_RAISE_FOUND = false;
|
|
11
|
+
/** Host runaway guard (CLI ≥1.0.72) when raise is absent. */
|
|
12
|
+
export const COPILOT_STOP_CONSECUTIVE_BLOCK_CAP = 8;
|
|
13
|
+
/** PostToolUse matcher for init (runtime toolName; camelCase hooks). */
|
|
14
|
+
export const COPILOT_POST_TOOL_USE_MATCHER = "edit|create";
|
|
15
|
+
export const MAX_NEED_PICK_SLUGS = 40;
|
|
16
|
+
export const MAX_NEED_PICK_CONTEXT_CHARS = 2_000;
|
|
17
|
+
export const MAX_HOOK_STDIO_CHARS = 8_192;
|
|
18
|
+
/** Bound hostile/huge toolArgs JSON before parse. */
|
|
19
|
+
export const MAX_TOOL_ARGS_JSON_CHARS = 1_048_576;
|
|
20
|
+
/** Bound gate file bytes (JSON record + margin). */
|
|
21
|
+
export const MAX_GATE_FILE_BYTES = MAX_HOOK_STDIO_CHARS * 2 + 512;
|
|
22
|
+
/**
|
|
23
|
+
* Durable UPS→Transform handoff (separate hook processes).
|
|
24
|
+
* File under `.autopilot/copilot-gate/` — session.last_error is not writable via upsertSession.
|
|
25
|
+
*/
|
|
26
|
+
export const COPILOT_GATE_DIR = path.join(".autopilot", "copilot-gate");
|
|
27
|
+
function sid(p) {
|
|
28
|
+
return (p.session_id ??
|
|
29
|
+
p.sessionId ??
|
|
30
|
+
p.conversation_id ??
|
|
31
|
+
p.conversationId ??
|
|
32
|
+
"").trim();
|
|
33
|
+
}
|
|
34
|
+
function clipText(text, max = MAX_HOOK_STDIO_CHARS) {
|
|
35
|
+
if (text.length <= max)
|
|
36
|
+
return text;
|
|
37
|
+
return `${text.slice(0, max - 1)}…`;
|
|
38
|
+
}
|
|
39
|
+
function blockReason(message, fallback) {
|
|
40
|
+
const m = typeof message === "string" ? message.trim() : "";
|
|
41
|
+
return m || fallback;
|
|
42
|
+
}
|
|
43
|
+
export function loopCountFromStopHookActive(payload) {
|
|
44
|
+
const active = payload.stop_hook_active ?? payload.stopHookActive;
|
|
45
|
+
return active === true ? 1 : 0;
|
|
46
|
+
}
|
|
47
|
+
export function collectCopilotStopErrorText(payload) {
|
|
48
|
+
if (!payload || typeof payload !== "object")
|
|
49
|
+
return "";
|
|
50
|
+
const parts = [];
|
|
51
|
+
try {
|
|
52
|
+
const push = (value) => {
|
|
53
|
+
if (typeof value === "string" && value.trim()) {
|
|
54
|
+
parts.push(value);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
58
|
+
const o = value;
|
|
59
|
+
for (const key of ["message", "error", "name", "stack", "detail"]) {
|
|
60
|
+
const nested = o[key];
|
|
61
|
+
if (typeof nested === "string" && nested.trim())
|
|
62
|
+
parts.push(nested);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
push(payload.error);
|
|
67
|
+
push(payload.message);
|
|
68
|
+
push(payload.reason);
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return "";
|
|
72
|
+
}
|
|
73
|
+
return clipText(parts.join("\n"));
|
|
74
|
+
}
|
|
75
|
+
export function normalizeCopilotStopStatus(payload, opts) {
|
|
76
|
+
if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
|
|
77
|
+
return opts?.status ?? "completed";
|
|
78
|
+
}
|
|
79
|
+
const statusRaw = String(payload.status ?? "")
|
|
80
|
+
.toLowerCase()
|
|
81
|
+
.trim();
|
|
82
|
+
const errText = collectCopilotStopErrorText(payload);
|
|
83
|
+
if (statusRaw === "aborted" ||
|
|
84
|
+
statusRaw === "cancelled" ||
|
|
85
|
+
statusRaw === "canceled") {
|
|
86
|
+
return "aborted";
|
|
87
|
+
}
|
|
88
|
+
if (opts?.status === "aborted")
|
|
89
|
+
return "aborted";
|
|
90
|
+
if (statusRaw === "error" || statusRaw === "failed") {
|
|
91
|
+
if (isUserAbortText(errText))
|
|
92
|
+
return "aborted";
|
|
93
|
+
return "error";
|
|
94
|
+
}
|
|
95
|
+
if (opts?.status === "error") {
|
|
96
|
+
if (isUserAbortText(errText))
|
|
97
|
+
return "aborted";
|
|
98
|
+
return "error";
|
|
99
|
+
}
|
|
100
|
+
if (opts?.status === "completed")
|
|
101
|
+
return "completed";
|
|
102
|
+
if (!statusRaw && isUserAbortText(errText))
|
|
103
|
+
return "aborted";
|
|
104
|
+
return "completed";
|
|
105
|
+
}
|
|
106
|
+
/** Channel A needPick body (Transform injects; UPS does not rely on stdout). */
|
|
107
|
+
export function buildNeedPickContext(userMessage, candidates) {
|
|
108
|
+
const fromMessage = typeof userMessage === "string" && userMessage.trim().length > 0
|
|
109
|
+
? userMessage.trim()
|
|
110
|
+
: "";
|
|
111
|
+
const slugs = [
|
|
112
|
+
...new Set((candidates ?? [])
|
|
113
|
+
.map((c) => (c && typeof c.slug === "string" ? c.slug.trim() : ""))
|
|
114
|
+
.filter((s) => s.length > 0 && isSafeTrackSlug(s))),
|
|
115
|
+
].slice(0, MAX_NEED_PICK_SLUGS);
|
|
116
|
+
let ctx = fromMessage ||
|
|
117
|
+
(slugs.length > 0
|
|
118
|
+
? `Select a plan to execute:\n\n${slugs
|
|
119
|
+
.map((s, i) => ` ${i + 1}. ${s}`)
|
|
120
|
+
.join("\n")}\n\nReply with a number or /autopilot-run <slug>.`
|
|
121
|
+
: "Select a plan to execute. Reply with a number or /autopilot-run <slug>.");
|
|
122
|
+
if (ctx.length > MAX_NEED_PICK_CONTEXT_CHARS) {
|
|
123
|
+
ctx = `${ctx.slice(0, MAX_NEED_PICK_CONTEXT_CHARS - 1)}…`;
|
|
124
|
+
}
|
|
125
|
+
return ctx;
|
|
126
|
+
}
|
|
127
|
+
function toolInputObject(payload) {
|
|
128
|
+
const input = payload.tool_input ?? payload.toolInput ?? payload.toolArgs;
|
|
129
|
+
if (!input)
|
|
130
|
+
return null;
|
|
131
|
+
if (typeof input === "object" && !Array.isArray(input)) {
|
|
132
|
+
return input;
|
|
133
|
+
}
|
|
134
|
+
if (typeof input === "string") {
|
|
135
|
+
if (input.length > MAX_TOOL_ARGS_JSON_CHARS)
|
|
136
|
+
return null;
|
|
137
|
+
try {
|
|
138
|
+
const parsed = JSON.parse(input);
|
|
139
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
140
|
+
return parsed;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
catch {
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
function sanitizeEditPath(raw) {
|
|
150
|
+
const p = raw.trim();
|
|
151
|
+
if (!p || /[\0\r\n]/.test(p))
|
|
152
|
+
return null;
|
|
153
|
+
return p;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Paths from Copilot edit/create tools.
|
|
157
|
+
* Common fields: path / filePath / file_path / target_file.
|
|
158
|
+
*/
|
|
159
|
+
export function filePathsFromCopilotEdit(payload) {
|
|
160
|
+
const input = toolInputObject(payload);
|
|
161
|
+
if (!input)
|
|
162
|
+
return [];
|
|
163
|
+
const candidates = [
|
|
164
|
+
input.path,
|
|
165
|
+
input.file_path,
|
|
166
|
+
input.filePath,
|
|
167
|
+
input.target_file,
|
|
168
|
+
input.targetFile,
|
|
169
|
+
input.notebook_path,
|
|
170
|
+
input.notebookPath,
|
|
171
|
+
];
|
|
172
|
+
for (const c of candidates) {
|
|
173
|
+
if (typeof c === "string") {
|
|
174
|
+
const p = sanitizeEditPath(c);
|
|
175
|
+
if (p)
|
|
176
|
+
return [p];
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return [];
|
|
180
|
+
}
|
|
181
|
+
/** File-mutating tools (bash relies on Stop dirty-arm). */
|
|
182
|
+
export function isCopilotEditTool(toolName) {
|
|
183
|
+
const n = toolName.trim().toLowerCase();
|
|
184
|
+
return n === "edit" || n === "create";
|
|
185
|
+
}
|
|
186
|
+
function stampCopilotPlatform(store, conversationId, projectRoot) {
|
|
187
|
+
const session = store.getSession(conversationId);
|
|
188
|
+
if (!session || session.platform === COPILOT_PLATFORM)
|
|
189
|
+
return;
|
|
190
|
+
store.upsertSession({
|
|
191
|
+
conversation_id: conversationId,
|
|
192
|
+
project_root: session.project_root || projectRoot,
|
|
193
|
+
code_root: session.code_root || projectRoot,
|
|
194
|
+
platform: COPILOT_PLATFORM,
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
/** Hash conversation id so sanitized collisions cannot cross-wire gates. */
|
|
198
|
+
export function safeGateFileId(conversationId) {
|
|
199
|
+
return createHash("sha256")
|
|
200
|
+
.update(conversationId, "utf8")
|
|
201
|
+
.digest("hex")
|
|
202
|
+
.slice(0, 32);
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Gate file path — always under `projectRoot/.autopilot/copilot-gate/`.
|
|
206
|
+
* Rejects empty roots and paths that resolve outside the project.
|
|
207
|
+
*/
|
|
208
|
+
export function submitGateFilePath(projectRoot, conversationId) {
|
|
209
|
+
if (typeof projectRoot !== "string" || !projectRoot.trim()) {
|
|
210
|
+
throw new Error("copilot gate requires a non-empty projectRoot");
|
|
211
|
+
}
|
|
212
|
+
const root = path.resolve(projectRoot.trim());
|
|
213
|
+
const dir = path.resolve(root, COPILOT_GATE_DIR);
|
|
214
|
+
const file = path.resolve(dir, `${safeGateFileId(conversationId)}.txt`);
|
|
215
|
+
const relToRoot = path.relative(root, file);
|
|
216
|
+
if (!relToRoot ||
|
|
217
|
+
relToRoot.startsWith("..") ||
|
|
218
|
+
path.isAbsolute(relToRoot)) {
|
|
219
|
+
throw new Error("copilot gate path escaped project root");
|
|
220
|
+
}
|
|
221
|
+
return file;
|
|
222
|
+
}
|
|
223
|
+
/** Stash gate text for Transform (busy / needPick / hard errors). Never throws. */
|
|
224
|
+
export function stashSubmitGate(projectRoot, conversationId, message, kind = "block") {
|
|
225
|
+
const raw = typeof message === "string" ? message.trim() : "";
|
|
226
|
+
const text = clipText(raw || "Autopilot rejected this prompt.");
|
|
227
|
+
const gateKind = kind === "needPick" || kind === "block" ? kind : "block";
|
|
228
|
+
try {
|
|
229
|
+
const file = submitGateFilePath(projectRoot, conversationId);
|
|
230
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
231
|
+
const record = { kind: gateKind, text };
|
|
232
|
+
const body = JSON.stringify(record);
|
|
233
|
+
const tmp = `${file}.${process.pid}.${Date.now()}.tmp`;
|
|
234
|
+
try {
|
|
235
|
+
fs.writeFileSync(tmp, body, "utf8");
|
|
236
|
+
try {
|
|
237
|
+
fs.renameSync(tmp, file);
|
|
238
|
+
}
|
|
239
|
+
catch {
|
|
240
|
+
// Windows: rename cannot replace an existing destination.
|
|
241
|
+
try {
|
|
242
|
+
fs.unlinkSync(file);
|
|
243
|
+
}
|
|
244
|
+
catch {
|
|
245
|
+
/* ignore missing */
|
|
246
|
+
}
|
|
247
|
+
fs.renameSync(tmp, file);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
catch (err) {
|
|
251
|
+
try {
|
|
252
|
+
fs.unlinkSync(tmp);
|
|
253
|
+
}
|
|
254
|
+
catch {
|
|
255
|
+
/* ignore */
|
|
256
|
+
}
|
|
257
|
+
throw err;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
catch {
|
|
261
|
+
/* disk / path failures must not break UPS fail-open */
|
|
262
|
+
}
|
|
263
|
+
return text;
|
|
264
|
+
}
|
|
265
|
+
function parseGateRecord(raw) {
|
|
266
|
+
const trimmed = raw.trim();
|
|
267
|
+
if (!trimmed)
|
|
268
|
+
return null;
|
|
269
|
+
if (trimmed.length > MAX_HOOK_STDIO_CHARS * 2) {
|
|
270
|
+
return {
|
|
271
|
+
kind: "block",
|
|
272
|
+
text: clipText(trimmed.slice(0, MAX_HOOK_STDIO_CHARS)),
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
try {
|
|
276
|
+
const parsed = JSON.parse(trimmed);
|
|
277
|
+
if (parsed === null || typeof parsed !== "object") {
|
|
278
|
+
return { kind: "block", text: clipText(trimmed) };
|
|
279
|
+
}
|
|
280
|
+
if (Array.isArray(parsed))
|
|
281
|
+
return null;
|
|
282
|
+
const kind = parsed.kind;
|
|
283
|
+
const textRaw = parsed.text;
|
|
284
|
+
if ((kind === "needPick" || kind === "block") &&
|
|
285
|
+
typeof textRaw === "string" &&
|
|
286
|
+
textRaw.trim()) {
|
|
287
|
+
return { kind, text: clipText(textRaw.trim()) };
|
|
288
|
+
}
|
|
289
|
+
// Object JSON that is not our record — do not treat whole blob as user text.
|
|
290
|
+
return null;
|
|
291
|
+
}
|
|
292
|
+
catch {
|
|
293
|
+
/* legacy plain-text stash */
|
|
294
|
+
return { kind: "block", text: clipText(trimmed) };
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
/** Read + clear submit gate; returns null if absent. Never throws. */
|
|
298
|
+
export function takeSubmitGate(projectRoot, conversationId) {
|
|
299
|
+
try {
|
|
300
|
+
const file = submitGateFilePath(projectRoot, conversationId);
|
|
301
|
+
if (!fs.existsSync(file))
|
|
302
|
+
return null;
|
|
303
|
+
const st = fs.statSync(file);
|
|
304
|
+
if (!st.isFile() || st.size <= 0) {
|
|
305
|
+
try {
|
|
306
|
+
fs.unlinkSync(file);
|
|
307
|
+
}
|
|
308
|
+
catch {
|
|
309
|
+
/* ignore */
|
|
310
|
+
}
|
|
311
|
+
return null;
|
|
312
|
+
}
|
|
313
|
+
if (st.size > MAX_GATE_FILE_BYTES) {
|
|
314
|
+
try {
|
|
315
|
+
fs.unlinkSync(file);
|
|
316
|
+
}
|
|
317
|
+
catch {
|
|
318
|
+
/* ignore */
|
|
319
|
+
}
|
|
320
|
+
return null;
|
|
321
|
+
}
|
|
322
|
+
const msg = fs.readFileSync(file, "utf8");
|
|
323
|
+
try {
|
|
324
|
+
fs.unlinkSync(file);
|
|
325
|
+
}
|
|
326
|
+
catch {
|
|
327
|
+
/* best-effort clear */
|
|
328
|
+
}
|
|
329
|
+
return parseGateRecord(msg);
|
|
330
|
+
}
|
|
331
|
+
catch {
|
|
332
|
+
return null;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
/** Drop a stale gate so a later Transform cannot inject a previous turn's notice. */
|
|
336
|
+
export function clearSubmitGate(projectRoot, conversationId) {
|
|
337
|
+
try {
|
|
338
|
+
const file = submitGateFilePath(projectRoot, conversationId);
|
|
339
|
+
if (fs.existsSync(file))
|
|
340
|
+
fs.unlinkSync(file);
|
|
341
|
+
}
|
|
342
|
+
catch {
|
|
343
|
+
/* best-effort */
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
function gateFail(store, conversationId, projectRoot, userMessage, kind) {
|
|
347
|
+
stampCopilotPlatform(store, conversationId, projectRoot);
|
|
348
|
+
const stashed = stashSubmitGate(projectRoot, conversationId, blockReason(userMessage, "Autopilot rejected this prompt."), kind);
|
|
349
|
+
return { _sideEffectsOnly: true, _stashedGate: stashed };
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* userPromptSubmitted → core triggers / FSM.
|
|
353
|
+
* Host drops command UPS stdout — visibility via Transform stash.
|
|
354
|
+
*/
|
|
355
|
+
export function handleUserPromptSubmit(store, payload, projectRoot, portConfig) {
|
|
356
|
+
try {
|
|
357
|
+
return handleUserPromptSubmitInner(store, payload, projectRoot, portConfig);
|
|
358
|
+
}
|
|
359
|
+
catch {
|
|
360
|
+
return { _sideEffectsOnly: true };
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
function handleUserPromptSubmitInner(store, payload, projectRoot, portConfig) {
|
|
364
|
+
const conversationId = sid(payload);
|
|
365
|
+
if (!conversationId)
|
|
366
|
+
return { _sideEffectsOnly: true };
|
|
367
|
+
const prompt = typeof payload.prompt === "string" ? payload.prompt : "";
|
|
368
|
+
try {
|
|
369
|
+
store.clearPendingFollowupIf(conversationId, isRecoverOrStuckFollowupMessage);
|
|
370
|
+
}
|
|
371
|
+
catch {
|
|
372
|
+
/* best-effort */
|
|
373
|
+
}
|
|
374
|
+
const session = store.getSession(conversationId);
|
|
375
|
+
const hookCfg = loadProjectHookConfig(projectRoot);
|
|
376
|
+
const trigger = parseTrigger({
|
|
377
|
+
prompt,
|
|
378
|
+
conversationId,
|
|
379
|
+
projectRoot,
|
|
380
|
+
pendingAction: session?.pending_action,
|
|
381
|
+
triggers: hookCfg.triggers,
|
|
382
|
+
});
|
|
383
|
+
const actionConfig = {
|
|
384
|
+
...portConfig?.phaseActions,
|
|
385
|
+
plansDir: portConfig?.phaseActions?.plansDir ?? hookCfg.plansDir,
|
|
386
|
+
};
|
|
387
|
+
if (trigger) {
|
|
388
|
+
if (trigger.kind === "off") {
|
|
389
|
+
applyOff(store, conversationId);
|
|
390
|
+
stampCopilotPlatform(store, conversationId, projectRoot);
|
|
391
|
+
clearSubmitGate(projectRoot, conversationId);
|
|
392
|
+
return { _sideEffectsOnly: true };
|
|
393
|
+
}
|
|
394
|
+
if (trigger.kind === "on") {
|
|
395
|
+
const result = applyOn(store, conversationId, projectRoot, {
|
|
396
|
+
initialBrief: trigger.initialBrief,
|
|
397
|
+
slug: trigger.slug,
|
|
398
|
+
platform: COPILOT_PLATFORM,
|
|
399
|
+
});
|
|
400
|
+
if (!result.ok) {
|
|
401
|
+
return gateFail(store, conversationId, projectRoot, result.userMessage, "block");
|
|
402
|
+
}
|
|
403
|
+
stampCopilotPlatform(store, conversationId, projectRoot);
|
|
404
|
+
clearSubmitGate(projectRoot, conversationId);
|
|
405
|
+
return { _sideEffectsOnly: true };
|
|
406
|
+
}
|
|
407
|
+
if (trigger.kind === "resume") {
|
|
408
|
+
const result = applyResume(store, conversationId, {
|
|
409
|
+
slug: trigger.slug,
|
|
410
|
+
});
|
|
411
|
+
if (!result.ok) {
|
|
412
|
+
return gateFail(store, conversationId, projectRoot, result.userMessage, "block");
|
|
413
|
+
}
|
|
414
|
+
stampCopilotPlatform(store, conversationId, projectRoot);
|
|
415
|
+
clearSubmitGate(projectRoot, conversationId);
|
|
416
|
+
return { _sideEffectsOnly: true };
|
|
417
|
+
}
|
|
418
|
+
if (trigger.kind === "resume_review") {
|
|
419
|
+
applyResumeReview(store, conversationId);
|
|
420
|
+
stampCopilotPlatform(store, conversationId, projectRoot);
|
|
421
|
+
clearSubmitGate(projectRoot, conversationId);
|
|
422
|
+
return { _sideEffectsOnly: true };
|
|
423
|
+
}
|
|
424
|
+
if (trigger.kind === "run") {
|
|
425
|
+
const result = applyRun(store, conversationId, projectRoot, {
|
|
426
|
+
slug: trigger.slug,
|
|
427
|
+
config: actionConfig,
|
|
428
|
+
platform: COPILOT_PLATFORM,
|
|
429
|
+
});
|
|
430
|
+
if (!result.ok) {
|
|
431
|
+
if (isChannelANeedPick(result)) {
|
|
432
|
+
const ctx = buildNeedPickContext(result.userMessage, result.candidates);
|
|
433
|
+
return gateFail(store, conversationId, projectRoot, ctx, "needPick");
|
|
434
|
+
}
|
|
435
|
+
return gateFail(store, conversationId, projectRoot, result.userMessage, "block");
|
|
436
|
+
}
|
|
437
|
+
stampCopilotPlatform(store, conversationId, projectRoot);
|
|
438
|
+
clearSubmitGate(projectRoot, conversationId);
|
|
439
|
+
return { _sideEffectsOnly: true };
|
|
440
|
+
}
|
|
441
|
+
if (trigger.kind === "replan") {
|
|
442
|
+
const result = applyReplan(store, conversationId, projectRoot, {
|
|
443
|
+
slug: trigger.slug,
|
|
444
|
+
config: actionConfig,
|
|
445
|
+
platform: COPILOT_PLATFORM,
|
|
446
|
+
});
|
|
447
|
+
if (!result.ok) {
|
|
448
|
+
if (isChannelANeedPick(result)) {
|
|
449
|
+
const ctx = buildNeedPickContext(result.userMessage, result.candidates);
|
|
450
|
+
return gateFail(store, conversationId, projectRoot, ctx, "needPick");
|
|
451
|
+
}
|
|
452
|
+
return gateFail(store, conversationId, projectRoot, result.userMessage, "block");
|
|
453
|
+
}
|
|
454
|
+
stampCopilotPlatform(store, conversationId, projectRoot);
|
|
455
|
+
clearSubmitGate(projectRoot, conversationId);
|
|
456
|
+
return { _sideEffectsOnly: true };
|
|
457
|
+
}
|
|
458
|
+
if (trigger.kind === "track_pick" && trigger.trackPick) {
|
|
459
|
+
const result = applyTrackPick(store, conversationId, projectRoot, trigger.trackPick, { config: actionConfig, platform: COPILOT_PLATFORM });
|
|
460
|
+
if (!result.ok) {
|
|
461
|
+
if (isChannelANeedPick(result)) {
|
|
462
|
+
const ctx = buildNeedPickContext(result.userMessage, result.candidates);
|
|
463
|
+
return gateFail(store, conversationId, projectRoot, ctx, "needPick");
|
|
464
|
+
}
|
|
465
|
+
return gateFail(store, conversationId, projectRoot, result.userMessage, "block");
|
|
466
|
+
}
|
|
467
|
+
stampCopilotPlatform(store, conversationId, projectRoot);
|
|
468
|
+
clearSubmitGate(projectRoot, conversationId);
|
|
469
|
+
return { _sideEffectsOnly: true };
|
|
470
|
+
}
|
|
471
|
+
clearSubmitGate(projectRoot, conversationId);
|
|
472
|
+
return { _sideEffectsOnly: true };
|
|
473
|
+
}
|
|
474
|
+
if (!isHarnessFollowupMessage(prompt)) {
|
|
475
|
+
store.clearChainPending(conversationId);
|
|
476
|
+
}
|
|
477
|
+
stampCopilotPlatform(store, conversationId, projectRoot);
|
|
478
|
+
clearSubmitGate(projectRoot, conversationId);
|
|
479
|
+
return { _sideEffectsOnly: true };
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* userPromptTransformed — inject stashed UPS gate (needPick / busy / errors).
|
|
483
|
+
* needPick: prepend notice. block/busy: replace model-facing content (do not keep user RUN).
|
|
484
|
+
*/
|
|
485
|
+
export function handleUserPromptTransformed(store, payload, projectRoot) {
|
|
486
|
+
try {
|
|
487
|
+
return handleUserPromptTransformedInner(store, payload, projectRoot);
|
|
488
|
+
}
|
|
489
|
+
catch {
|
|
490
|
+
return {};
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
function handleUserPromptTransformedInner(store, payload, projectRoot) {
|
|
494
|
+
const conversationId = sid(payload);
|
|
495
|
+
if (!conversationId)
|
|
496
|
+
return {};
|
|
497
|
+
const gate = takeSubmitGate(projectRoot, conversationId);
|
|
498
|
+
if (!gate) {
|
|
499
|
+
stampCopilotPlatform(store, conversationId, projectRoot);
|
|
500
|
+
return {};
|
|
501
|
+
}
|
|
502
|
+
stampCopilotPlatform(store, conversationId, projectRoot);
|
|
503
|
+
if (gate.kind === "block") {
|
|
504
|
+
return {
|
|
505
|
+
modifiedTransformedPrompt: clipText(`[Autopilot]\n${gate.text}`, MAX_NEED_PICK_CONTEXT_CHARS + MAX_HOOK_STDIO_CHARS),
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
const baseRaw = typeof payload.transformedPrompt === "string"
|
|
509
|
+
? payload.transformedPrompt
|
|
510
|
+
: typeof payload.prompt === "string"
|
|
511
|
+
? payload.prompt
|
|
512
|
+
: "";
|
|
513
|
+
const notice = clipText(`[Autopilot]\n${gate.text}\n\n---\n\n${baseRaw}`, MAX_NEED_PICK_CONTEXT_CHARS + MAX_HOOK_STDIO_CHARS);
|
|
514
|
+
return { modifiedTransformedPrompt: notice };
|
|
515
|
+
}
|
|
516
|
+
function armCodeEdited(store, conversationId, projectRoot) {
|
|
517
|
+
const cfg = loadProjectReviewConfig(projectRoot);
|
|
518
|
+
if (cfg.reviewScope === "project") {
|
|
519
|
+
ensureAmbientReviewSession(store, conversationId, projectRoot, cfg.reviewScope, COPILOT_PLATFORM);
|
|
520
|
+
}
|
|
521
|
+
stampCopilotPlatform(store, conversationId, projectRoot);
|
|
522
|
+
const session = store.getSession(conversationId);
|
|
523
|
+
const checklistPath = session?.checklist_path?.trim() ?? "";
|
|
524
|
+
let checklistSnap = null;
|
|
525
|
+
if (checklistPath) {
|
|
526
|
+
try {
|
|
527
|
+
checklistSnap = parseChecklist(checklistPath, { projectRoot });
|
|
528
|
+
}
|
|
529
|
+
catch {
|
|
530
|
+
/* still arm */
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
store.markCodeEdited(conversationId, (chain) => {
|
|
534
|
+
const fromPending = parseAdvanceNextItemId(chain.pending_followup);
|
|
535
|
+
if (checklistSnap) {
|
|
536
|
+
if (fromPending && effectiveReviewingItemId(checklistSnap, fromPending)) {
|
|
537
|
+
return fromPending;
|
|
538
|
+
}
|
|
539
|
+
return firstUnchecked(checklistSnap)?.id ?? null;
|
|
540
|
+
}
|
|
541
|
+
return fromPending;
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
/** postToolUse → markCodeEdited for edit/create product paths. */
|
|
545
|
+
export function handlePostToolUse(store, payload, projectRoot) {
|
|
546
|
+
try {
|
|
547
|
+
handlePostToolUseInner(store, payload, projectRoot);
|
|
548
|
+
}
|
|
549
|
+
catch {
|
|
550
|
+
/* fail-open */
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
function handlePostToolUseInner(store, payload, projectRoot) {
|
|
554
|
+
const conversationId = sid(payload);
|
|
555
|
+
const toolName = String(payload.tool_name ?? payload.toolName ?? "").trim();
|
|
556
|
+
if (!conversationId || !isCopilotEditTool(toolName))
|
|
557
|
+
return;
|
|
558
|
+
const filePaths = filePathsFromCopilotEdit(payload);
|
|
559
|
+
if (filePaths.length === 0) {
|
|
560
|
+
stampCopilotPlatform(store, conversationId, projectRoot);
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
let plansDir;
|
|
564
|
+
try {
|
|
565
|
+
plansDir = loadProjectHookConfig(projectRoot).plansDir;
|
|
566
|
+
}
|
|
567
|
+
catch {
|
|
568
|
+
plansDir = undefined;
|
|
569
|
+
}
|
|
570
|
+
let armed = false;
|
|
571
|
+
for (const filePath of filePaths) {
|
|
572
|
+
try {
|
|
573
|
+
notePlansDirEdit(store, conversationId, projectRoot, filePath, plansDir);
|
|
574
|
+
}
|
|
575
|
+
catch {
|
|
576
|
+
/* best-effort */
|
|
577
|
+
}
|
|
578
|
+
if (!isProductCodeEdit(filePath, { projectRoot }))
|
|
579
|
+
continue;
|
|
580
|
+
if (!armed) {
|
|
581
|
+
armCodeEdited(store, conversationId, projectRoot);
|
|
582
|
+
armed = true;
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
if (!armed) {
|
|
586
|
+
stampCopilotPlatform(store, conversationId, projectRoot);
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
/**
|
|
590
|
+
* agentStop → ReviewEngine.
|
|
591
|
+
* Continue: decision:block + reason.
|
|
592
|
+
* Hard stop: empty object (Copilot has no continue:false; do not invent Claude fields).
|
|
593
|
+
* Host caps ~8 consecutive blocks when COPILOT_STOP_CAP_RAISE_FOUND is false.
|
|
594
|
+
*/
|
|
595
|
+
export function handleStop(engine, payload, opts) {
|
|
596
|
+
try {
|
|
597
|
+
return handleStopInner(engine, payload, opts);
|
|
598
|
+
}
|
|
599
|
+
catch {
|
|
600
|
+
return {};
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
function handleStopInner(engine, payload, opts) {
|
|
604
|
+
const conversationId = sid(payload);
|
|
605
|
+
if (!conversationId)
|
|
606
|
+
return {};
|
|
607
|
+
const status = normalizeCopilotStopStatus(payload, opts);
|
|
608
|
+
const transcriptRaw = payload.transcript_path ?? payload.transcriptPath;
|
|
609
|
+
const transcriptPath = typeof transcriptRaw === "string" && transcriptRaw.trim()
|
|
610
|
+
? transcriptRaw.trim()
|
|
611
|
+
: undefined;
|
|
612
|
+
const action = engine.handleStop({
|
|
613
|
+
conversationId,
|
|
614
|
+
status,
|
|
615
|
+
loopCount: loopCountFromStopHookActive(payload),
|
|
616
|
+
transcriptPath,
|
|
617
|
+
platform: COPILOT_PLATFORM,
|
|
618
|
+
});
|
|
619
|
+
if (!action?.message)
|
|
620
|
+
return {};
|
|
621
|
+
const reason = blockReason(action.message, "Autopilot followup");
|
|
622
|
+
if (!action.loop) {
|
|
623
|
+
// Copilot agentStop honors decision allow|block only — no continue:false.
|
|
624
|
+
return {};
|
|
625
|
+
}
|
|
626
|
+
return {
|
|
627
|
+
decision: "block",
|
|
628
|
+
reason,
|
|
629
|
+
};
|
|
630
|
+
}
|
|
631
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACL,QAAQ,EACR,OAAO,EACP,WAAW,EACX,WAAW,EACX,iBAAiB,EACjB,QAAQ,EACR,cAAc,EACd,0BAA0B,EAC1B,wBAAwB,EACxB,cAAc,EACd,kBAAkB,EAClB,wBAAwB,EACxB,iBAAiB,EACjB,+BAA+B,EAC/B,eAAe,EACf,eAAe,EACf,qBAAqB,EACrB,uBAAuB,EACvB,gBAAgB,EAChB,sBAAsB,EACtB,cAAc,EACd,YAAY,GAKb,MAAM,yBAAyB,CAAC;AA8EjC,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAAC;AAE9C;;;GAGG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,KAAK,CAAC;AAClD,6DAA6D;AAC7D,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC,CAAC;AAEpD,wEAAwE;AACxE,MAAM,CAAC,MAAM,6BAA6B,GAAG,aAAa,CAAC;AAE3D,MAAM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C;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED,SAAS,eAAe,CACtB,MAAoB,EACpB,OAA2B,EAC3B,IAAqD;IAErD,MAAM,cAAc,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC;IACpC,IAAI,CAAC,cAAc;QAAE,OAAO,EAAE,CAAC;IAE/B,MAAM,MAAM,GAAG,0BAA0B,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAEzD,MAAM,aAAa,GAAG,OAAO,CAAC,eAAe,IAAI,OAAO,CAAC,cAAc,CAAC;IACxE,MAAM,cAAc,GAClB,OAAO,aAAa,KAAK,QAAQ,IAAI,aAAa,CAAC,IAAI,EAAE;QACvD,CAAC,CAAC,aAAa,CAAC,IAAI,EAAE;QACtB,CAAC,CAAC,SAAS,CAAC;IAEhB,MAAM,MAAM,GAA0B,MAAM,CAAC,UAAU,CAAC;QACtD,cAAc;QACd,MAAM;QACN,SAAS,EAAE,2BAA2B,CAAC,OAAO,CAAC;QAC/C,cAAc;QACd,QAAQ,EAAE,gBAAgB;KAC3B,CAAC,CAAC;IAEH,IAAI,CAAC,MAAM,EAAE,OAAO;QAAE,OAAO,EAAE,CAAC;IAEhC,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC;IAEjE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QACjB,0EAA0E;QAC1E,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO;QACL,QAAQ,EAAE,OAAO;QACjB,MAAM;KACP,CAAC;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@autopilot-harness/port-copilot-cli",
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"description": "Autopilot harness host port for GitHub Copilot CLI hooks (degraded Stop consecutive ≤8 unless raise found)",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/mt2007/autopilot-harness.git",
|
|
9
|
+
"directory": "packages/ports/copilot-cli"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/mt2007/autopilot-harness#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/mt2007/autopilot-harness/issues"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"main": "./dist/index.js",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist"
|
|
26
|
+
],
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@autopilot-harness/core": "0.5.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"typescript": "^5.8.2"
|
|
32
|
+
},
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=22"
|
|
35
|
+
},
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
39
|
+
"author": "mt2007 (https://github.com/mt2007)",
|
|
40
|
+
"keywords": [
|
|
41
|
+
"autopilot",
|
|
42
|
+
"harness",
|
|
43
|
+
"agent",
|
|
44
|
+
"ai",
|
|
45
|
+
"vibecoding",
|
|
46
|
+
"copilot",
|
|
47
|
+
"github-copilot",
|
|
48
|
+
"checklist",
|
|
49
|
+
"code-review"
|
|
50
|
+
],
|
|
51
|
+
"scripts": {
|
|
52
|
+
"build": "tsc -p tsconfig.json",
|
|
53
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
54
|
+
}
|
|
55
|
+
}
|