@autopilot-harness/port-kimi-code 0.4.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 +123 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +485 -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,123 @@
|
|
|
1
|
+
import { type PhaseActionConfig, type ReviewEngine, type StateStore } from "@autopilot-harness/core";
|
|
2
|
+
/** Kimi Code UserPromptSubmit stdin fields. */
|
|
3
|
+
export interface KimiSubmitPayload {
|
|
4
|
+
session_id?: string;
|
|
5
|
+
sessionId?: string;
|
|
6
|
+
prompt?: string;
|
|
7
|
+
/** Informational only — store always uses install-root projectRoot. */
|
|
8
|
+
cwd?: string;
|
|
9
|
+
transcript_path?: string;
|
|
10
|
+
transcriptPath?: string;
|
|
11
|
+
conversation_id?: string;
|
|
12
|
+
conversationId?: string;
|
|
13
|
+
/** Kimi may send plan/default/… — Autopilot ignores (no auto-ON). */
|
|
14
|
+
permission_mode?: string;
|
|
15
|
+
permissionMode?: string;
|
|
16
|
+
turn_id?: string;
|
|
17
|
+
model?: string;
|
|
18
|
+
}
|
|
19
|
+
/** Kimi Code PostToolUse stdin (Write / Edit / Bash / …). */
|
|
20
|
+
export interface KimiEditPayload {
|
|
21
|
+
session_id?: string;
|
|
22
|
+
sessionId?: string;
|
|
23
|
+
conversation_id?: string;
|
|
24
|
+
conversationId?: string;
|
|
25
|
+
cwd?: string;
|
|
26
|
+
tool_name?: string;
|
|
27
|
+
toolName?: string;
|
|
28
|
+
tool_input?: Record<string, unknown> | string;
|
|
29
|
+
toolInput?: Record<string, unknown> | string;
|
|
30
|
+
}
|
|
31
|
+
/** Kimi Code Stop stdin (no StopFailure / SubagentStop in this port). */
|
|
32
|
+
export interface KimiStopPayload {
|
|
33
|
+
session_id?: string;
|
|
34
|
+
sessionId?: string;
|
|
35
|
+
conversation_id?: string;
|
|
36
|
+
conversationId?: string;
|
|
37
|
+
cwd?: string;
|
|
38
|
+
transcript_path?: string;
|
|
39
|
+
transcriptPath?: string;
|
|
40
|
+
status?: string;
|
|
41
|
+
stop_hook_active?: boolean;
|
|
42
|
+
stopHookActive?: boolean;
|
|
43
|
+
hook_event_name?: string;
|
|
44
|
+
hookEventName?: string;
|
|
45
|
+
last_assistant_message?: string;
|
|
46
|
+
turn_id?: string;
|
|
47
|
+
error?: unknown;
|
|
48
|
+
message?: unknown;
|
|
49
|
+
reason?: unknown;
|
|
50
|
+
}
|
|
51
|
+
export interface KimiPortConfig {
|
|
52
|
+
phaseActions?: PhaseActionConfig;
|
|
53
|
+
}
|
|
54
|
+
export declare const KIMI_PLATFORM = "kimi-code";
|
|
55
|
+
/** Cap needPick list for Kimi ~2500-token hook-output budget. */
|
|
56
|
+
export declare const MAX_NEED_PICK_SLUGS = 40;
|
|
57
|
+
export declare const MAX_NEED_PICK_CONTEXT_CHARS = 2000;
|
|
58
|
+
/** Bound hostile/huge apply_patch command parsing. */
|
|
59
|
+
export declare const MAX_APPLY_PATCH_COMMAND_CHARS = 1048576;
|
|
60
|
+
export declare const MAX_APPLY_PATCH_PATHS = 256;
|
|
61
|
+
/** Bound followup / gate text written to Kimi stdout/stderr. */
|
|
62
|
+
export declare const MAX_HOOK_STDIO_CHARS = 8192;
|
|
63
|
+
/**
|
|
64
|
+
* Kimi Code hook reply — CLI uses exit code + stdio (not Claude/Codex JSON).
|
|
65
|
+
* exit 0 + stdout → allow (UPS may append stdout to context).
|
|
66
|
+
* exit 2 + stderr → intentional block (Stop continue injects stderr as reason).
|
|
67
|
+
* Other non-zero / throw → host fail-open; Autopilot handlers should not throw.
|
|
68
|
+
*/
|
|
69
|
+
export interface KimiHookResult {
|
|
70
|
+
exitCode: 0 | 2;
|
|
71
|
+
/** Appended to context on UPS allow (exit 0). */
|
|
72
|
+
stdout?: string;
|
|
73
|
+
/** Block / Stop-continue reason (exit 2); printed via stderr by the hook entry. */
|
|
74
|
+
stderr?: string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Map Kimi stop_hook_active → ReviewEngine loopCount.
|
|
78
|
+
* true ⇒ in auto-continuation chain.
|
|
79
|
+
*/
|
|
80
|
+
export declare function loopCountFromStopHookActive(payload: KimiStopPayload): number;
|
|
81
|
+
export declare function collectKimiStopErrorText(payload: KimiStopPayload): string;
|
|
82
|
+
export declare function normalizeKimiStopStatus(payload: KimiStopPayload, opts?: {
|
|
83
|
+
status?: "completed" | "error" | "aborted";
|
|
84
|
+
}): "completed" | "error" | "aborted";
|
|
85
|
+
/**
|
|
86
|
+
* Channel A needPick via UPS allow + stdout context — never exit 2 for pick.
|
|
87
|
+
* Slugs capped for Kimi hook-output budget.
|
|
88
|
+
* @internal Exported for tests.
|
|
89
|
+
*/
|
|
90
|
+
export declare function allowNeedPickContext(userMessage: unknown, candidates?: ReadonlyArray<{
|
|
91
|
+
slug?: string;
|
|
92
|
+
}>): KimiHookResult;
|
|
93
|
+
/**
|
|
94
|
+
* Parse file paths from Kimi apply_patch `tool_input.command` text.
|
|
95
|
+
* Supports `*** Add|Update|Delete File:`, `*** Rename File: a -> b`, and `+++` lines.
|
|
96
|
+
*/
|
|
97
|
+
export declare function pathsFromApplyPatchCommand(command: string): string[];
|
|
98
|
+
/**
|
|
99
|
+
* Paths touched by this PostToolUse (0..n).
|
|
100
|
+
* apply_patch → parse command; Edit/Write → file_path-style fields.
|
|
101
|
+
*/
|
|
102
|
+
export declare function filePathsFromKimiEdit(payload: KimiEditPayload): string[];
|
|
103
|
+
/** File-mutating tools Autopilot arms from (Bash relies on dirty-arm on Stop). */
|
|
104
|
+
export declare function isKimiEditTool(toolName: string): boolean;
|
|
105
|
+
/**
|
|
106
|
+
* UserPromptSubmit → core triggers / fail-closed.
|
|
107
|
+
* needPick → exit 0 + stdout (Channel A). Busy/errors → exit 2 + stderr.
|
|
108
|
+
* Does not trust payload.cwd — store uses install-root projectRoot.
|
|
109
|
+
*/
|
|
110
|
+
export declare function handleUserPromptSubmit(store: StateStore, payload: KimiSubmitPayload, projectRoot: string, portConfig?: KimiPortConfig): KimiHookResult;
|
|
111
|
+
/** PostToolUse → markCodeEdited when any product path is touched. */
|
|
112
|
+
export declare function handlePostToolUse(store: StateStore, payload: KimiEditPayload, projectRoot: string): void;
|
|
113
|
+
/**
|
|
114
|
+
* Stop → ReviewEngine.
|
|
115
|
+
* Continue: exit 2 + stderr reason (Kimi CLI appends reason and continues).
|
|
116
|
+
* Hard-stop (loop:false): exit 0 (allow the model to end the turn).
|
|
117
|
+
* Never emit Claude/Codex JSON decision:block — hook entry maps this shape.
|
|
118
|
+
* No StopFailure / SubagentStop handler — hook boundary fail-open.
|
|
119
|
+
*/
|
|
120
|
+
export declare function handleStop(engine: ReviewEngine, payload: KimiStopPayload, opts?: {
|
|
121
|
+
status?: "completed" | "error" | "aborted";
|
|
122
|
+
}): KimiHookResult;
|
|
123
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAwBL,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,UAAU,EAChB,MAAM,yBAAyB,CAAC;AAEjC,+CAA+C;AAC/C,MAAM,WAAW,iBAAiB;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uEAAuE;IACvE,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,qEAAqE;IACrE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,6DAA6D;AAC7D,MAAM,WAAW,eAAe;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,GAAG,CAAC,EAAE,MAAM,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ClB,IAAI,CAMN;AAkDD;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,eAAe,EACxB,IAAI,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,GAAG,SAAS,CAAA;CAAE,GACpD,cAAc,CAMhB"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,485 @@
|
|
|
1
|
+
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";
|
|
2
|
+
export const KIMI_PLATFORM = "kimi-code";
|
|
3
|
+
/** Cap needPick list for Kimi ~2500-token hook-output budget. */
|
|
4
|
+
export const MAX_NEED_PICK_SLUGS = 40;
|
|
5
|
+
export const MAX_NEED_PICK_CONTEXT_CHARS = 2_000;
|
|
6
|
+
/** Bound hostile/huge apply_patch command parsing. */
|
|
7
|
+
export const MAX_APPLY_PATCH_COMMAND_CHARS = 1_048_576;
|
|
8
|
+
export const MAX_APPLY_PATCH_PATHS = 256;
|
|
9
|
+
/** Bound followup / gate text written to Kimi stdout/stderr. */
|
|
10
|
+
export const MAX_HOOK_STDIO_CHARS = 8_192;
|
|
11
|
+
function sid(p) {
|
|
12
|
+
return (p.session_id ??
|
|
13
|
+
p.sessionId ??
|
|
14
|
+
p.conversation_id ??
|
|
15
|
+
p.conversationId ??
|
|
16
|
+
"").trim();
|
|
17
|
+
}
|
|
18
|
+
function clipHookText(text) {
|
|
19
|
+
if (text.length <= MAX_HOOK_STDIO_CHARS)
|
|
20
|
+
return text;
|
|
21
|
+
return `${text.slice(0, MAX_HOOK_STDIO_CHARS - 1)}…`;
|
|
22
|
+
}
|
|
23
|
+
function allowResult(stdout) {
|
|
24
|
+
if (typeof stdout === "string" && stdout.trim().length > 0) {
|
|
25
|
+
return { exitCode: 0, stdout: clipHookText(stdout) };
|
|
26
|
+
}
|
|
27
|
+
return { exitCode: 0 };
|
|
28
|
+
}
|
|
29
|
+
function blockResult(stderr) {
|
|
30
|
+
return { exitCode: 2, stderr: clipHookText(stderr) };
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Map Kimi stop_hook_active → ReviewEngine loopCount.
|
|
34
|
+
* true ⇒ in auto-continuation chain.
|
|
35
|
+
*/
|
|
36
|
+
export function loopCountFromStopHookActive(payload) {
|
|
37
|
+
const active = payload.stop_hook_active ?? payload.stopHookActive;
|
|
38
|
+
return active === true ? 1 : 0;
|
|
39
|
+
}
|
|
40
|
+
export function collectKimiStopErrorText(payload) {
|
|
41
|
+
if (!payload || typeof payload !== "object")
|
|
42
|
+
return "";
|
|
43
|
+
const MAX_CHARS = 8_192;
|
|
44
|
+
const parts = [];
|
|
45
|
+
try {
|
|
46
|
+
const push = (value) => {
|
|
47
|
+
if (typeof value === "string" && value.trim()) {
|
|
48
|
+
parts.push(value);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
52
|
+
const o = value;
|
|
53
|
+
for (const key of ["message", "error", "name", "stack", "detail"]) {
|
|
54
|
+
const nested = o[key];
|
|
55
|
+
if (typeof nested === "string" && nested.trim())
|
|
56
|
+
parts.push(nested);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
push(payload.error);
|
|
61
|
+
push(payload.message);
|
|
62
|
+
push(payload.reason);
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return "";
|
|
66
|
+
}
|
|
67
|
+
const joined = parts.join("\n");
|
|
68
|
+
return joined.length > MAX_CHARS ? joined.slice(0, MAX_CHARS) : joined;
|
|
69
|
+
}
|
|
70
|
+
export function normalizeKimiStopStatus(payload, opts) {
|
|
71
|
+
if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
|
|
72
|
+
return opts?.status ?? "completed";
|
|
73
|
+
}
|
|
74
|
+
const statusRaw = String(payload.status ?? "")
|
|
75
|
+
.toLowerCase()
|
|
76
|
+
.trim();
|
|
77
|
+
const errText = collectKimiStopErrorText(payload);
|
|
78
|
+
if (statusRaw === "aborted" ||
|
|
79
|
+
statusRaw === "cancelled" ||
|
|
80
|
+
statusRaw === "canceled") {
|
|
81
|
+
return "aborted";
|
|
82
|
+
}
|
|
83
|
+
if (opts?.status === "aborted")
|
|
84
|
+
return "aborted";
|
|
85
|
+
if (statusRaw === "error" || statusRaw === "failed") {
|
|
86
|
+
if (isUserAbortText(errText))
|
|
87
|
+
return "aborted";
|
|
88
|
+
return "error";
|
|
89
|
+
}
|
|
90
|
+
if (opts?.status === "error") {
|
|
91
|
+
if (isUserAbortText(errText))
|
|
92
|
+
return "aborted";
|
|
93
|
+
return "error";
|
|
94
|
+
}
|
|
95
|
+
if (opts?.status === "completed")
|
|
96
|
+
return "completed";
|
|
97
|
+
if (!statusRaw && isUserAbortText(errText))
|
|
98
|
+
return "aborted";
|
|
99
|
+
return "completed";
|
|
100
|
+
}
|
|
101
|
+
function blockReason(message, fallback) {
|
|
102
|
+
const m = typeof message === "string" ? message.trim() : "";
|
|
103
|
+
return m || fallback;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Channel A needPick via UPS allow + stdout context — never exit 2 for pick.
|
|
107
|
+
* Slugs capped for Kimi hook-output budget.
|
|
108
|
+
* @internal Exported for tests.
|
|
109
|
+
*/
|
|
110
|
+
export function allowNeedPickContext(userMessage, candidates) {
|
|
111
|
+
const fromMessage = typeof userMessage === "string" && userMessage.trim().length > 0
|
|
112
|
+
? userMessage.trim()
|
|
113
|
+
: "";
|
|
114
|
+
const slugs = [
|
|
115
|
+
...new Set((candidates ?? [])
|
|
116
|
+
.map((c) => (c && typeof c.slug === "string" ? c.slug.trim() : ""))
|
|
117
|
+
.filter((s) => s.length > 0 && isSafeTrackSlug(s))),
|
|
118
|
+
].slice(0, MAX_NEED_PICK_SLUGS);
|
|
119
|
+
let ctx = fromMessage ||
|
|
120
|
+
(slugs.length > 0
|
|
121
|
+
? `Select a plan to execute:\n\n${slugs
|
|
122
|
+
.map((s, i) => ` ${i + 1}. ${s}`)
|
|
123
|
+
.join("\n")}\n\nReply with a number or /autopilot-run <slug>.`
|
|
124
|
+
: "Select a plan to execute. Reply with a number or /autopilot-run <slug>.");
|
|
125
|
+
if (ctx.length > MAX_NEED_PICK_CONTEXT_CHARS) {
|
|
126
|
+
ctx = `${ctx.slice(0, MAX_NEED_PICK_CONTEXT_CHARS - 1)}…`;
|
|
127
|
+
}
|
|
128
|
+
return allowResult(ctx);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Parse file paths from Kimi apply_patch `tool_input.command` text.
|
|
132
|
+
* Supports `*** Add|Update|Delete File:`, `*** Rename File: a -> b`, and `+++` lines.
|
|
133
|
+
*/
|
|
134
|
+
export function pathsFromApplyPatchCommand(command) {
|
|
135
|
+
if (typeof command !== "string" || !command.trim())
|
|
136
|
+
return [];
|
|
137
|
+
// Truncate oversized payloads before split (DoS / hostile hooks).
|
|
138
|
+
const text = command.length > MAX_APPLY_PATCH_COMMAND_CHARS
|
|
139
|
+
? command.slice(0, MAX_APPLY_PATCH_COMMAND_CHARS)
|
|
140
|
+
: command;
|
|
141
|
+
const found = [];
|
|
142
|
+
const seen = new Set();
|
|
143
|
+
const push = (raw) => {
|
|
144
|
+
if (found.length >= MAX_APPLY_PATCH_PATHS)
|
|
145
|
+
return;
|
|
146
|
+
let p = raw.trim();
|
|
147
|
+
if (!p || p === "/dev/null")
|
|
148
|
+
return;
|
|
149
|
+
// Reject NULs / newlines smuggled into a "path".
|
|
150
|
+
if (/[\0\r\n]/.test(p))
|
|
151
|
+
return;
|
|
152
|
+
// Strip optional a/ or b/ prefix from diff paths.
|
|
153
|
+
p = p.replace(/^[ab]\//, "");
|
|
154
|
+
if (!p || seen.has(p))
|
|
155
|
+
return;
|
|
156
|
+
seen.add(p);
|
|
157
|
+
found.push(p);
|
|
158
|
+
};
|
|
159
|
+
for (const line of text.split(/\r?\n/)) {
|
|
160
|
+
if (found.length >= MAX_APPLY_PATCH_PATHS)
|
|
161
|
+
break;
|
|
162
|
+
const rename = line.match(/^\*\*\*\s+Rename\s+File:\s*(.+?)\s*->\s*(.+?)\s*$/i);
|
|
163
|
+
if (rename?.[1] && rename[2]) {
|
|
164
|
+
push(rename[1]);
|
|
165
|
+
push(rename[2]);
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
const header = line.match(/^\*\*\*\s+(?:Add|Update|Delete)\s+File:\s*(.+?)\s*$/i);
|
|
169
|
+
if (header?.[1]) {
|
|
170
|
+
push(header[1]);
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
const plus = line.match(/^\+\+\+\s+(?:[ab]\/)?(.+?)\s*$/);
|
|
174
|
+
if (plus?.[1] && plus[1] !== "/dev/null") {
|
|
175
|
+
push(plus[1]);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return found;
|
|
179
|
+
}
|
|
180
|
+
function toolInputObject(payload) {
|
|
181
|
+
const input = payload.tool_input ?? payload.toolInput;
|
|
182
|
+
if (!input)
|
|
183
|
+
return null;
|
|
184
|
+
if (typeof input === "object" && !Array.isArray(input)) {
|
|
185
|
+
return input;
|
|
186
|
+
}
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Paths touched by this PostToolUse (0..n).
|
|
191
|
+
* apply_patch → parse command; Edit/Write → file_path-style fields.
|
|
192
|
+
*/
|
|
193
|
+
export function filePathsFromKimiEdit(payload) {
|
|
194
|
+
const toolName = String(payload.tool_name ?? payload.toolName ?? "").trim();
|
|
195
|
+
const rawInput = payload.tool_input ?? payload.toolInput;
|
|
196
|
+
if (toolName === "apply_patch" || toolName === "ApplyPatch") {
|
|
197
|
+
// Object `{ command }` or rare stringified command body.
|
|
198
|
+
if (typeof rawInput === "string") {
|
|
199
|
+
return pathsFromApplyPatchCommand(rawInput);
|
|
200
|
+
}
|
|
201
|
+
const input = toolInputObject(payload);
|
|
202
|
+
if (!input)
|
|
203
|
+
return [];
|
|
204
|
+
const cmd = input.command;
|
|
205
|
+
if (typeof cmd === "string")
|
|
206
|
+
return pathsFromApplyPatchCommand(cmd);
|
|
207
|
+
return [];
|
|
208
|
+
}
|
|
209
|
+
const input = toolInputObject(payload);
|
|
210
|
+
if (!input)
|
|
211
|
+
return [];
|
|
212
|
+
const candidates = [
|
|
213
|
+
input.file_path,
|
|
214
|
+
input.filePath,
|
|
215
|
+
input.path,
|
|
216
|
+
input.notebook_path,
|
|
217
|
+
input.notebookPath,
|
|
218
|
+
];
|
|
219
|
+
for (const c of candidates) {
|
|
220
|
+
if (typeof c !== "string")
|
|
221
|
+
continue;
|
|
222
|
+
const p = c.trim();
|
|
223
|
+
if (!p || /[\0\r\n]/.test(p))
|
|
224
|
+
continue;
|
|
225
|
+
return [p];
|
|
226
|
+
}
|
|
227
|
+
return [];
|
|
228
|
+
}
|
|
229
|
+
/** File-mutating tools Autopilot arms from (Bash relies on dirty-arm on Stop). */
|
|
230
|
+
export function isKimiEditTool(toolName) {
|
|
231
|
+
const n = toolName.trim();
|
|
232
|
+
return (n === "Write" ||
|
|
233
|
+
n === "Edit" ||
|
|
234
|
+
n === "StrReplace" ||
|
|
235
|
+
n === "MultiEdit" ||
|
|
236
|
+
n === "apply_patch" ||
|
|
237
|
+
n === "ApplyPatch");
|
|
238
|
+
}
|
|
239
|
+
function stampKimiPlatform(store, conversationId, projectRoot) {
|
|
240
|
+
const session = store.getSession(conversationId);
|
|
241
|
+
if (!session || session.platform === KIMI_PLATFORM)
|
|
242
|
+
return;
|
|
243
|
+
store.upsertSession({
|
|
244
|
+
conversation_id: conversationId,
|
|
245
|
+
project_root: session.project_root || projectRoot,
|
|
246
|
+
code_root: session.code_root || projectRoot,
|
|
247
|
+
platform: KIMI_PLATFORM,
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* UserPromptSubmit → core triggers / fail-closed.
|
|
252
|
+
* needPick → exit 0 + stdout (Channel A). Busy/errors → exit 2 + stderr.
|
|
253
|
+
* Does not trust payload.cwd — store uses install-root projectRoot.
|
|
254
|
+
*/
|
|
255
|
+
export function handleUserPromptSubmit(store, payload, projectRoot, portConfig) {
|
|
256
|
+
try {
|
|
257
|
+
return handleUserPromptSubmitInner(store, payload, projectRoot, portConfig);
|
|
258
|
+
}
|
|
259
|
+
catch {
|
|
260
|
+
// Port-level fail-open (Kimi treats non-0/2 as allow; we prefer clean 0).
|
|
261
|
+
return { exitCode: 0 };
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
function handleUserPromptSubmitInner(store, payload, projectRoot, portConfig) {
|
|
265
|
+
const conversationId = sid(payload);
|
|
266
|
+
if (!conversationId)
|
|
267
|
+
return { exitCode: 0 };
|
|
268
|
+
const prompt = typeof payload.prompt === "string" ? payload.prompt : "";
|
|
269
|
+
try {
|
|
270
|
+
store.clearPendingFollowupIf(conversationId, isRecoverOrStuckFollowupMessage);
|
|
271
|
+
}
|
|
272
|
+
catch {
|
|
273
|
+
/* best-effort */
|
|
274
|
+
}
|
|
275
|
+
const session = store.getSession(conversationId);
|
|
276
|
+
const hookCfg = loadProjectHookConfig(projectRoot);
|
|
277
|
+
const trigger = parseTrigger({
|
|
278
|
+
prompt,
|
|
279
|
+
conversationId,
|
|
280
|
+
projectRoot,
|
|
281
|
+
pendingAction: session?.pending_action,
|
|
282
|
+
triggers: hookCfg.triggers,
|
|
283
|
+
});
|
|
284
|
+
const actionConfig = {
|
|
285
|
+
...portConfig?.phaseActions,
|
|
286
|
+
plansDir: portConfig?.phaseActions?.plansDir ?? hookCfg.plansDir,
|
|
287
|
+
};
|
|
288
|
+
const gateFallback = "Autopilot rejected this prompt. Check `npx autopilot-harness status`.";
|
|
289
|
+
if (trigger) {
|
|
290
|
+
if (trigger.kind === "off") {
|
|
291
|
+
applyOff(store, conversationId);
|
|
292
|
+
stampKimiPlatform(store, conversationId, projectRoot);
|
|
293
|
+
return { exitCode: 0 };
|
|
294
|
+
}
|
|
295
|
+
if (trigger.kind === "on") {
|
|
296
|
+
const result = applyOn(store, conversationId, projectRoot, {
|
|
297
|
+
initialBrief: trigger.initialBrief,
|
|
298
|
+
slug: trigger.slug,
|
|
299
|
+
platform: KIMI_PLATFORM,
|
|
300
|
+
});
|
|
301
|
+
if (!result.ok) {
|
|
302
|
+
stampKimiPlatform(store, conversationId, projectRoot);
|
|
303
|
+
return blockResult(blockReason(result.userMessage, gateFallback));
|
|
304
|
+
}
|
|
305
|
+
return { exitCode: 0 };
|
|
306
|
+
}
|
|
307
|
+
if (trigger.kind === "resume") {
|
|
308
|
+
const result = applyResume(store, conversationId, {
|
|
309
|
+
slug: trigger.slug,
|
|
310
|
+
});
|
|
311
|
+
if (!result.ok) {
|
|
312
|
+
stampKimiPlatform(store, conversationId, projectRoot);
|
|
313
|
+
return blockResult(blockReason(result.userMessage, gateFallback));
|
|
314
|
+
}
|
|
315
|
+
stampKimiPlatform(store, conversationId, projectRoot);
|
|
316
|
+
return { exitCode: 0 };
|
|
317
|
+
}
|
|
318
|
+
if (trigger.kind === "resume_review") {
|
|
319
|
+
applyResumeReview(store, conversationId);
|
|
320
|
+
stampKimiPlatform(store, conversationId, projectRoot);
|
|
321
|
+
return { exitCode: 0 };
|
|
322
|
+
}
|
|
323
|
+
if (trigger.kind === "run") {
|
|
324
|
+
const result = applyRun(store, conversationId, projectRoot, {
|
|
325
|
+
slug: trigger.slug,
|
|
326
|
+
config: actionConfig,
|
|
327
|
+
platform: KIMI_PLATFORM,
|
|
328
|
+
});
|
|
329
|
+
if (!result.ok) {
|
|
330
|
+
stampKimiPlatform(store, conversationId, projectRoot);
|
|
331
|
+
if (isChannelANeedPick(result)) {
|
|
332
|
+
return allowNeedPickContext(result.userMessage, result.candidates);
|
|
333
|
+
}
|
|
334
|
+
return blockResult(blockReason(result.userMessage, gateFallback));
|
|
335
|
+
}
|
|
336
|
+
return { exitCode: 0 };
|
|
337
|
+
}
|
|
338
|
+
if (trigger.kind === "replan") {
|
|
339
|
+
const result = applyReplan(store, conversationId, projectRoot, {
|
|
340
|
+
slug: trigger.slug,
|
|
341
|
+
config: actionConfig,
|
|
342
|
+
platform: KIMI_PLATFORM,
|
|
343
|
+
});
|
|
344
|
+
if (!result.ok) {
|
|
345
|
+
stampKimiPlatform(store, conversationId, projectRoot);
|
|
346
|
+
return blockResult(blockReason(result.userMessage, gateFallback));
|
|
347
|
+
}
|
|
348
|
+
return { exitCode: 0 };
|
|
349
|
+
}
|
|
350
|
+
if (trigger.kind === "track_pick" && trigger.trackPick) {
|
|
351
|
+
const result = applyTrackPick(store, conversationId, projectRoot, trigger.trackPick, { config: actionConfig, platform: KIMI_PLATFORM });
|
|
352
|
+
if (!result.ok) {
|
|
353
|
+
stampKimiPlatform(store, conversationId, projectRoot);
|
|
354
|
+
if (isChannelANeedPick(result)) {
|
|
355
|
+
return allowNeedPickContext(result.userMessage, result.candidates);
|
|
356
|
+
}
|
|
357
|
+
return blockResult(blockReason(result.userMessage, gateFallback));
|
|
358
|
+
}
|
|
359
|
+
return { exitCode: 0 };
|
|
360
|
+
}
|
|
361
|
+
return { exitCode: 0 };
|
|
362
|
+
}
|
|
363
|
+
if (!isHarnessFollowupMessage(prompt)) {
|
|
364
|
+
store.clearChainPending(conversationId);
|
|
365
|
+
}
|
|
366
|
+
stampKimiPlatform(store, conversationId, projectRoot);
|
|
367
|
+
return { exitCode: 0 };
|
|
368
|
+
}
|
|
369
|
+
function armCodeEdited(store, conversationId, projectRoot) {
|
|
370
|
+
const cfg = loadProjectReviewConfig(projectRoot);
|
|
371
|
+
if (cfg.reviewScope === "project") {
|
|
372
|
+
ensureAmbientReviewSession(store, conversationId, projectRoot, cfg.reviewScope, KIMI_PLATFORM);
|
|
373
|
+
}
|
|
374
|
+
stampKimiPlatform(store, conversationId, projectRoot);
|
|
375
|
+
const session = store.getSession(conversationId);
|
|
376
|
+
const checklistPath = session?.checklist_path?.trim() ?? "";
|
|
377
|
+
let checklistSnap = null;
|
|
378
|
+
if (checklistPath) {
|
|
379
|
+
try {
|
|
380
|
+
checklistSnap = parseChecklist(checklistPath, { projectRoot });
|
|
381
|
+
}
|
|
382
|
+
catch {
|
|
383
|
+
/* still arm */
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
store.markCodeEdited(conversationId, (chain) => {
|
|
387
|
+
const fromPending = parseAdvanceNextItemId(chain.pending_followup);
|
|
388
|
+
if (checklistSnap) {
|
|
389
|
+
if (fromPending && effectiveReviewingItemId(checklistSnap, fromPending)) {
|
|
390
|
+
return fromPending;
|
|
391
|
+
}
|
|
392
|
+
return firstUnchecked(checklistSnap)?.id ?? null;
|
|
393
|
+
}
|
|
394
|
+
return fromPending;
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
/** PostToolUse → markCodeEdited when any product path is touched. */
|
|
398
|
+
export function handlePostToolUse(store, payload, projectRoot) {
|
|
399
|
+
try {
|
|
400
|
+
handlePostToolUseInner(store, payload, projectRoot);
|
|
401
|
+
}
|
|
402
|
+
catch {
|
|
403
|
+
/* fail-open */
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
function handlePostToolUseInner(store, payload, projectRoot) {
|
|
407
|
+
const conversationId = sid(payload);
|
|
408
|
+
const toolName = String(payload.tool_name ?? payload.toolName ?? "").trim();
|
|
409
|
+
if (!conversationId || !isKimiEditTool(toolName))
|
|
410
|
+
return;
|
|
411
|
+
const filePaths = filePathsFromKimiEdit(payload);
|
|
412
|
+
if (filePaths.length === 0) {
|
|
413
|
+
// apply_patch with unparsable command: still stamp platform; dirty-arm
|
|
414
|
+
// on Stop covers product paths. Do not false-arm without a path.
|
|
415
|
+
stampKimiPlatform(store, conversationId, projectRoot);
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
let plansDir;
|
|
419
|
+
try {
|
|
420
|
+
plansDir = loadProjectHookConfig(projectRoot).plansDir;
|
|
421
|
+
}
|
|
422
|
+
catch {
|
|
423
|
+
plansDir = undefined;
|
|
424
|
+
}
|
|
425
|
+
let armed = false;
|
|
426
|
+
for (const filePath of filePaths) {
|
|
427
|
+
try {
|
|
428
|
+
notePlansDirEdit(store, conversationId, projectRoot, filePath, plansDir);
|
|
429
|
+
}
|
|
430
|
+
catch {
|
|
431
|
+
/* best-effort */
|
|
432
|
+
}
|
|
433
|
+
if (!isProductCodeEdit(filePath, { projectRoot }))
|
|
434
|
+
continue;
|
|
435
|
+
if (!armed) {
|
|
436
|
+
armCodeEdited(store, conversationId, projectRoot);
|
|
437
|
+
armed = true;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
if (!armed) {
|
|
441
|
+
stampKimiPlatform(store, conversationId, projectRoot);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Stop → ReviewEngine.
|
|
446
|
+
* Continue: exit 2 + stderr reason (Kimi CLI appends reason and continues).
|
|
447
|
+
* Hard-stop (loop:false): exit 0 (allow the model to end the turn).
|
|
448
|
+
* Never emit Claude/Codex JSON decision:block — hook entry maps this shape.
|
|
449
|
+
* No StopFailure / SubagentStop handler — hook boundary fail-open.
|
|
450
|
+
*/
|
|
451
|
+
export function handleStop(engine, payload, opts) {
|
|
452
|
+
try {
|
|
453
|
+
return handleStopInner(engine, payload, opts);
|
|
454
|
+
}
|
|
455
|
+
catch {
|
|
456
|
+
return { exitCode: 0 };
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
function handleStopInner(engine, payload, opts) {
|
|
460
|
+
const conversationId = sid(payload);
|
|
461
|
+
if (!conversationId)
|
|
462
|
+
return { exitCode: 0 };
|
|
463
|
+
const status = normalizeKimiStopStatus(payload, opts);
|
|
464
|
+
const transcriptRaw = payload.transcript_path ?? payload.transcriptPath;
|
|
465
|
+
const transcriptPath = typeof transcriptRaw === "string" && transcriptRaw.trim()
|
|
466
|
+
? transcriptRaw.trim()
|
|
467
|
+
: undefined;
|
|
468
|
+
const action = engine.handleStop({
|
|
469
|
+
conversationId,
|
|
470
|
+
status,
|
|
471
|
+
loopCount: loopCountFromStopHookActive(payload),
|
|
472
|
+
transcriptPath,
|
|
473
|
+
platform: KIMI_PLATFORM,
|
|
474
|
+
});
|
|
475
|
+
if (!action?.message)
|
|
476
|
+
return { exitCode: 0 };
|
|
477
|
+
const reason = blockReason(action.message, "Autopilot followup");
|
|
478
|
+
if (!action.loop) {
|
|
479
|
+
// Allow the model to end the turn. Do not put reason on stdout — Kimi may
|
|
480
|
+
// append exit-0 stdout to context and blur "stop" vs "continue".
|
|
481
|
+
return { exitCode: 0 };
|
|
482
|
+
}
|
|
483
|
+
return blockResult(reason);
|
|
484
|
+
}
|
|
485
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,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;AA0DjC,MAAM,CAAC,MAAM,aAAa,GAAG,WAAW,CAAC;AAEzC,iEAAiE;AACjE,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AACtC,MAAM,CAAC,MAAM,2BAA2B,GAAG,KAAK,CAAC;AACjD,sDAAsD;AACtD,MAAM,CAAC,MAAM,6B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AAM,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,aAAa;KACxB,CAAC,CAAC;IAEH,IAAI,CAAC,MAAM,EAAE,OAAO;QAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;IAE7C,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC;IAEjE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QACjB,0EAA0E;QAC1E,iEAAiE;QACjE,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;IACzB,CAAC;IAED,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC;AAC7B,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@autopilot-harness/port-kimi-code",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "Autopilot harness host port for Kimi Code hooks (degraded Stop ≤1/turn)",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/mt2007/autopilot-harness.git",
|
|
9
|
+
"directory": "packages/ports/kimi-code"
|
|
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.4.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
|
+
"kimi-code",
|
|
47
|
+
"kimi",
|
|
48
|
+
"checklist",
|
|
49
|
+
"code-review"
|
|
50
|
+
],
|
|
51
|
+
"scripts": {
|
|
52
|
+
"build": "tsc -p tsconfig.json",
|
|
53
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
54
|
+
}
|
|
55
|
+
}
|