@kernlang/agon 0.1.2 → 0.1.4
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/{chunk-F72VMPTY.js → chunk-4LVYSUMN.js} +6 -4
- package/dist/{chunk-F72VMPTY.js.map → chunk-4LVYSUMN.js.map} +1 -1
- package/dist/chunk-6ANHPXGZ.js +102 -0
- package/dist/chunk-6ANHPXGZ.js.map +1 -0
- package/dist/chunk-ATUT2BUQ.js +2907 -0
- package/dist/chunk-ATUT2BUQ.js.map +1 -0
- package/dist/{chunk-7PMMOQZ7.js → chunk-C22VTCS6.js} +1129 -406
- package/dist/chunk-C22VTCS6.js.map +1 -0
- package/dist/{chunk-IA4AR2R4.js → chunk-FCCH7IPJ.js} +298 -554
- package/dist/chunk-FCCH7IPJ.js.map +1 -0
- package/dist/{chunk-GLQ5IQ5X.js → chunk-O6YP55RV.js} +10 -99
- package/dist/chunk-O6YP55RV.js.map +1 -0
- package/dist/chunk-WE32YJKT.js +489 -0
- package/dist/chunk-WE32YJKT.js.map +1 -0
- package/dist/engines/minimax-coding-plan-minimax-m3.json +27 -0
- package/dist/{forge-G274YAH7.js → forge-ES4RN7YM.js} +5 -4
- package/dist/index.js +1704 -3444
- package/dist/index.js.map +1 -1
- package/dist/{plan-mode-DCE7VGQV.js → plan-mode-4XRC2ZC7.js} +6 -4
- package/dist/{src-U2AWRNRL.js → src-WJGIOESS.js} +28 -2
- package/dist/update-HHN4PJQI.js +30 -0
- package/dist/update-HHN4PJQI.js.map +1 -0
- package/package.json +2 -2
- package/dist/chunk-7PMMOQZ7.js.map +0 -1
- package/dist/chunk-GLQ5IQ5X.js.map +0 -1
- package/dist/chunk-IA4AR2R4.js.map +0 -1
- /package/dist/{forge-G274YAH7.js.map → forge-ES4RN7YM.js.map} +0 -0
- /package/dist/{plan-mode-DCE7VGQV.js.map → plan-mode-4XRC2ZC7.js.map} +0 -0
- /package/dist/{src-U2AWRNRL.js.map → src-WJGIOESS.js.map} +0 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/generated/blocks/engine-helpers.ts
|
|
4
|
+
function parseToolInputPayload(input) {
|
|
5
|
+
const rawInput = String(input ?? "");
|
|
6
|
+
let parsed = {};
|
|
7
|
+
try {
|
|
8
|
+
if (rawInput.trim().startsWith("{")) {
|
|
9
|
+
parsed = JSON.parse(rawInput);
|
|
10
|
+
}
|
|
11
|
+
} catch (e) {
|
|
12
|
+
parsed = {};
|
|
13
|
+
}
|
|
14
|
+
return { rawInput, parsed };
|
|
15
|
+
}
|
|
16
|
+
function extractPatchText(rawInput, parsed) {
|
|
17
|
+
const values = [parsed?.patch, parsed?.content, parsed?.diff, parsed?.input].filter((value) => typeof value === "string" && value.trim().length > 0);
|
|
18
|
+
const fromParsed = values.find((value) => value.includes("*** Begin Patch") || value.includes("diff --git") || value.split("\n").some((line) => line.startsWith("@@")));
|
|
19
|
+
if (fromParsed) {
|
|
20
|
+
return fromParsed;
|
|
21
|
+
}
|
|
22
|
+
if (rawInput.includes("*** Begin Patch") || rawInput.includes("diff --git") || rawInput.split("\n").some((line) => line.startsWith("@@"))) {
|
|
23
|
+
return rawInput;
|
|
24
|
+
}
|
|
25
|
+
return values[0] ?? "";
|
|
26
|
+
}
|
|
27
|
+
function parsePatchPreview(rawInput, parsed) {
|
|
28
|
+
const patchText = extractPatchText(rawInput, parsed);
|
|
29
|
+
const files = [];
|
|
30
|
+
const lines = [];
|
|
31
|
+
let additions = 0;
|
|
32
|
+
let deletions = 0;
|
|
33
|
+
const addFile = (filePath) => {
|
|
34
|
+
const clean = filePath.trim().replace(/^["']|["']$/g, "");
|
|
35
|
+
if (clean && !files.includes(clean)) files.push(clean);
|
|
36
|
+
};
|
|
37
|
+
for (const line of patchText.split("\n")) {
|
|
38
|
+
const customFile = line.match(/^\*\*\* (?:Update|Add|Delete) File: (.+)$/);
|
|
39
|
+
if (customFile) {
|
|
40
|
+
addFile(customFile[1]);
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
const diffFile = line.match(/^diff --git a\/(.+?) b\/(.+)$/);
|
|
44
|
+
if (diffFile) {
|
|
45
|
+
addFile(diffFile[2]);
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (line.startsWith("+++ b/")) {
|
|
49
|
+
addFile(line.slice("+++ b/".length));
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (line.startsWith("--- a/")) {
|
|
53
|
+
addFile(line.slice("--- a/".length));
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (line.startsWith("@@")) {
|
|
57
|
+
lines.push(line);
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
if (line.startsWith("+") && !line.startsWith("+++")) {
|
|
61
|
+
additions += 1;
|
|
62
|
+
lines.push(line);
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
if (line.startsWith("-") && !line.startsWith("---")) {
|
|
66
|
+
deletions += 1;
|
|
67
|
+
lines.push(line);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return { files, lines, additions, deletions };
|
|
71
|
+
}
|
|
72
|
+
function extractSummary(text, maxLen) {
|
|
73
|
+
let s = text.replace(/<think>[\s\S]*?<\/think>\s*/gi, "");
|
|
74
|
+
s = s.replace(/^#+\s+.+\n/gm, "");
|
|
75
|
+
s = s.replace(/^\s*[-*]\s+/gm, "");
|
|
76
|
+
s = s.replace(/\*\*/g, "");
|
|
77
|
+
s = s.trim();
|
|
78
|
+
const firstSentence = s.match(/^[^.!?\n]{10,}[.!?]/);
|
|
79
|
+
const summary = firstSentence ? firstSentence[0] : s.slice(0, maxLen);
|
|
80
|
+
return summary.length > maxLen ? summary.slice(0, maxLen - 1) + "\u2026" : summary;
|
|
81
|
+
}
|
|
82
|
+
function stripReasoning(text) {
|
|
83
|
+
return text.replace(/<(think|thinking|reasoning)>[\s\S]*?<\/\1>\s*/gi, "").trim();
|
|
84
|
+
}
|
|
85
|
+
function stripTuiChrome(text) {
|
|
86
|
+
const hadChrome = /[·✢✳✶✻✽⎿]/.test(text);
|
|
87
|
+
let s = text.replace(/[·✢✳✴✵✶✷✸✹✺✻✼✽✾⎿]/g, "").replace(/❯/g, "");
|
|
88
|
+
if (hadChrome) {
|
|
89
|
+
s = s.replace(/[A-Z][^\n…]{0,40}…/g, "");
|
|
90
|
+
s = s.replace(/^[\s\d%]+/, "");
|
|
91
|
+
}
|
|
92
|
+
return s.replace(/[ \t]{2,}/g, " ").replace(/\n{3,}/g, "\n\n").trim();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export {
|
|
96
|
+
parseToolInputPayload,
|
|
97
|
+
parsePatchPreview,
|
|
98
|
+
extractSummary,
|
|
99
|
+
stripReasoning,
|
|
100
|
+
stripTuiChrome
|
|
101
|
+
};
|
|
102
|
+
//# sourceMappingURL=chunk-6ANHPXGZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/generated/blocks/engine-helpers.ts"],"sourcesContent":["// @generated by kern v3.5.7 — DO NOT EDIT. Source: src/kern/blocks/engine-helpers.kern\n\n// @kern-source: engine-helpers:1\nexport function parseToolInputPayload(input: string): any {\n const rawInput = String(input ?? '');\n let parsed: Record<string, unknown> = {};\n try {\n if (rawInput.trim().startsWith('{')) {\n parsed = JSON.parse(rawInput);\n }\n } catch (e) {\n parsed = {};\n }\n return { rawInput: rawInput, parsed: parsed };\n}\n\n// @kern-source: engine-helpers:12\nexport function extractPatchText(rawInput: string, parsed: any): string {\n const values = [parsed?.patch, parsed?.content, parsed?.diff, parsed?.input].filter((value: unknown): value is string => typeof value === 'string' && value.trim().length > 0);\n const fromParsed = values.find((value: string) => value.includes('*** Begin Patch') || value.includes('diff --git') || value.split('\\n').some((line: string) => line.startsWith('@@')));\n if (fromParsed) {\n return fromParsed;\n }\n if (rawInput.includes('*** Begin Patch') || rawInput.includes('diff --git') || rawInput.split('\\n').some((line: string) => line.startsWith('@@'))) {\n return rawInput;\n }\n return values[0] ?? '';\n}\n\n// @kern-source: engine-helpers:22\nexport function parsePatchPreview(rawInput: string, parsed: any): { files:string[]; lines:string[]; additions:number; deletions:number } {\n const patchText = extractPatchText(rawInput, parsed);\n const files: string[] = [];\n const lines: string[] = [];\n let additions = 0;\n let deletions = 0;\n const addFile = (filePath: string) => {\n const clean = filePath.trim().replace(/^[\"']|[\"']$/g, '');\n if (clean && !files.includes(clean)) files.push(clean);\n };\n\n for (const line of patchText.split('\\n')) {\n const customFile = line.match(/^\\*\\*\\* (?:Update|Add|Delete) File: (.+)$/);\n if (customFile) {\n addFile(customFile[1]);\n continue;\n }\n const diffFile = line.match(/^diff --git a\\/(.+?) b\\/(.+)$/);\n if (diffFile) {\n addFile(diffFile[2]);\n continue;\n }\n if (line.startsWith('+++ b/')) {\n addFile(line.slice('+++ b/'.length));\n continue;\n }\n if (line.startsWith('--- a/')) {\n addFile(line.slice('--- a/'.length));\n continue;\n }\n if (line.startsWith('@@')) {\n lines.push(line);\n continue;\n }\n if (line.startsWith('+') && !line.startsWith('+++')) {\n additions += 1;\n lines.push(line);\n continue;\n }\n if (line.startsWith('-') && !line.startsWith('---')) {\n deletions += 1;\n lines.push(line);\n }\n }\n\n return { files, lines, additions, deletions };\n}\n\n// @kern-source: engine-helpers:71\nexport function extractSummary(text: string, maxLen: number): string {\n let s = text.replace(/<think>[\\s\\S]*?<\\/think>\\s*/gi, '');\n s = s.replace(/^#+\\s+.+\\n/gm, '');\n s = s.replace(/^\\s*[-*]\\s+/gm, '');\n s = s.replace(/\\*\\*/g, '');\n s = s.trim();\n const firstSentence = s.match(/^[^.!?\\n]{10,}[.!?]/);\n const summary = firstSentence ? firstSentence[0] : s.slice(0, maxLen);\n return (summary.length > maxLen) ? (summary.slice(0, maxLen - 1) + '…') : summary;\n}\n\n/**\n * Remove reasoning-scaffolding blocks (<think>/<thinking>/<reasoning>) that reasoning models (MiniMax, DeepSeek, Qwen) emit before their real answer and sometimes leak into persisted output. Strips CLOSED blocks only — the common leak case — using a backreference so the open and close tags must match. Engine-agnostic: apply wherever raw engine output is persisted or parsed so scaffolding never reaches users or a structured-findings parser.\n */\n// @kern-source: engine-helpers:82\nexport function stripReasoning(text: string): string {\n return text.replace(/<(think|thinking|reasoning)>[\\s\\S]*?<\\/\\1>\\s*/gi, '').trim();\n}\n\n/**\n * Strip claude TUI thinking-animation chrome that leaks into pty-captured output. The animation redraws on one line, so ANSI-stripping flattens its frames into a glyph/label/counter soup ('·✢✳✶✻✽…This one needs a moment…Working through it…95%…Review …'). Spinner glyph frames and the input-bar prompt char (❯) are NEVER legitimate content, so they're always removed. The …-terminated spinner labels (claude invents endless ones — 'Cogitating…', 'Untangling some thoughts…' — so enumerating them is hopeless) and the leading token/elapsed counter residue are removed ONLY when glyph frames were present, i.e. proof this is TUI chrome. That glyph-gate means API engines (kimi/zai — no TUI) never have real content touched.\n */\n// @kern-source: engine-helpers:88\nexport function stripTuiChrome(text: string): string {\n const hadChrome = /[·✢✳✶✻✽⎿]/.test(text);\n let s = text.replace(/[·✢✳✴✵✶✷✸✹✺✻✼✽✾⎿]/g, '').replace(/❯/g, '');\n if (hadChrome) {\n s = s.replace(/[A-Z][^\\n…]{0,40}…/g, '');\n s = s.replace(/^[\\s\\d%]+/, '');\n }\n return s.replace(/[ \\t]{2,}/g, ' ').replace(/\\n{3,}/g, '\\n\\n').trim();\n}\n"],"mappings":";;;AAGO,SAAS,sBAAsB,OAAoB;AACxD,QAAM,WAAW,OAAO,SAAS,EAAE;AACnC,MAAI,SAAkC,CAAC;AACvC,MAAI;AACF,QAAI,SAAS,KAAK,EAAE,WAAW,GAAG,GAAG;AACnC,eAAS,KAAK,MAAM,QAAQ;AAAA,IAC9B;AAAA,EACF,SAAS,GAAG;AACV,aAAS,CAAC;AAAA,EACZ;AACA,SAAO,EAAE,UAAoB,OAAe;AAC9C;AAGO,SAAS,iBAAiB,UAAkB,QAAqB;AAC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