ceulen 0.28.2 → 0.29.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/CHANGELOG.md +57 -0
- package/extensions/lib/registry.ts +2 -2
- package/extensions/modules/a2a/index.ts +1 -1
- package/extensions/modules/repair/configPanel.ts +8 -1
- package/extensions/modules/repair/index.ts +29 -6
- package/extensions/modules/repair/lib/persistent-bash.ts +440 -0
- package/extensions/modules/repair/lib/settings.ts +5 -1
- package/extensions/modules/repair/test/persistent-bash.test.ts +402 -0
- package/extensions/modules/repair/test/settings.test.ts +6 -3
- package/extensions/modules/steering/configPanel.ts +0 -15
- package/extensions/modules/steering/index.ts +26 -201
- package/extensions/modules/steering/lib/settings.ts +6 -7
- package/extensions/modules/steering/test/harness.ts +3 -3
- package/extensions/modules/steering/test/settings.test.ts +14 -19
- package/extensions/modules/steering/test/status.test.ts +6 -9
- package/package.json +1 -1
- package/extensions/modules/steering/lib/anchor.ts +0 -189
- package/extensions/modules/steering/test/anchor-plan.test.ts +0 -74
- package/extensions/modules/steering/test/anchor-regressions.test.ts +0 -123
- package/extensions/modules/steering/test/anchor-wiring.test.ts +0 -82
- package/extensions/modules/steering/test/anchor.test.ts +0 -162
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* anchor.ts — DeepSeek V4 Pro / V4.1 Flash minimal-mode bootstrap.
|
|
3
|
-
*
|
|
4
|
-
* DeepSeek v4 Pro GA appears overfitted to DeepSeek Harness (DSH) "minimal
|
|
5
|
-
* mode": a byte-stable system prompt of one line + only bash/str_replace_editor
|
|
6
|
-
* tools on the first request. Anchoring request #1 to that distribution
|
|
7
|
-
* unlocks the model's benchmark-level capability; after the first durable
|
|
8
|
-
* assistant signal, the session promotes back to Pi's full prompt + catalog.
|
|
9
|
-
*
|
|
10
|
-
* Two-phase design ported from hank9999/pi-ds-anchored (MIT), itself from
|
|
11
|
-
* xiaobright/dsh-anchored-standard (Project2 benchmark: 98/99).
|
|
12
|
-
*
|
|
13
|
-
* Fail-open by design: if the wire prompt or tool pair isn't available, leave
|
|
14
|
-
* both untouched.
|
|
15
|
-
*/
|
|
16
|
-
// ponytail: vendored from @bacnh85/pi-model-tools 0.9.5
|
|
17
|
-
// (extensions/lib/ds-anchor.ts). Local change: anchorEnabled() /
|
|
18
|
-
// weNeedDirectiveEnabled() env knobs dropped — `steering.dsAnchor` /
|
|
19
|
-
// `steering.weNeed` settings rows gate them (lib/settings.ts). The
|
|
20
|
-
// str_replace_editor TOOL is not part of this module (the repair module
|
|
21
|
-
// registers it); the anchor only filters a payload that already carries it.
|
|
22
|
-
|
|
23
|
-
/** Byte-identical to the DeepSeek Harness Minimal persona (do not edit). */
|
|
24
|
-
export const MINIMAL_SYSTEM_PROMPT = "You are a helpful software engineer assistant.";
|
|
25
|
-
|
|
26
|
-
/** Tools exposed during bootstrap request #1 — the REAL DSH Minimal pair.
|
|
27
|
-
* Not bash+read: dsh-anchored-standard issue #11 measured the Minimal schema
|
|
28
|
-
* (bash + str_replace_editor) anchoring "we need…" first lines 5/5, while
|
|
29
|
-
* pwsh/read and bash/read variants anchored standard-like 11/11. */
|
|
30
|
-
export const BOOTSTRAP_TOOLS: readonly string[] = ["bash", "str_replace_editor"];
|
|
31
|
-
|
|
32
|
-
/** Byte-exact DSH Minimal tool definitions (from the captured minimal-mode
|
|
33
|
-
* request payload; str_replace_editor description matches DSH source
|
|
34
|
-
* DEFAULT_DESCRIPTION). Injected wholesale for request #1 — the tool SCHEMA
|
|
35
|
-
* is the decisive anchor lever, so Pi's own serialization (strict flags,
|
|
36
|
-
* TypeBox enums, Pi bash description) must not leak into the bootstrap
|
|
37
|
-
* request. Descriptions are conditioning text for the training distribution,
|
|
38
|
-
* even where they describe DSH's environment (apt mirror, no internet). */
|
|
39
|
-
export const DSH_BOOTSTRAP_TOOL_DEFS = [
|
|
40
|
-
{
|
|
41
|
-
type: "function",
|
|
42
|
-
function: {
|
|
43
|
-
name: "bash",
|
|
44
|
-
description:
|
|
45
|
-
'Run commands in a bash shell\n* When invoking this tool, the contents of the "command" parameter does NOT need to be XML-escaped.\n* You don\'t have access to the internet via this tool.\n* You do have access to a mirror of common linux and python packages via apt and pip.\n* State is persistent across command calls and discussions with the user.\n* To inspect a particular line range of a file, e.g. lines 10-25, try \'sed -n 10,25p /path/to/the/file\'.\n* Please avoid commands that may produce a very large amount of output.\n* Please run long lived commands in the background, e.g. \'sleep 10 &\' or start a server in the background.',
|
|
46
|
-
parameters: {
|
|
47
|
-
type: "object",
|
|
48
|
-
properties: {
|
|
49
|
-
command: { type: "string", description: "The bash command to run. Relative path is preferred in the command." },
|
|
50
|
-
},
|
|
51
|
-
required: ["command"],
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
type: "function",
|
|
57
|
-
function: {
|
|
58
|
-
name: "str_replace_editor",
|
|
59
|
-
description:
|
|
60
|
-
"Custom editing tool for viewing, creating and editing files\n* State is persistent across command calls and discussions with the user\n* If `path` is a file, `view` displays the result of applying `cat -n`. If `path` is a directory, `view` lists non-hidden files and directories up to 2 levels deep\n* The `create` command cannot be used if the specified `path` already exists as a file\n* If a `command` generates a long output, it will be truncated and marked with ```\n\nNotes for using the `str_replace` command:\n* The `old_str` parameter should match EXACTLY one or more consecutive lines from the original file. Be mindful of whitespaces!\n* If the `old_str` parameter is not unique in the file, the replacement will not be performed. Make sure to include enough context in `old_str` to make it unique\n* The `new_str` parameter should contain the edited lines that should replace the `old_str`",
|
|
61
|
-
parameters: {
|
|
62
|
-
type: "object",
|
|
63
|
-
properties: {
|
|
64
|
-
command: {
|
|
65
|
-
type: "string",
|
|
66
|
-
description: "The commands to run. Allowed options are: `view`, `create`, `str_replace`, `insert`.",
|
|
67
|
-
enum: ["view", "create", "str_replace", "insert"],
|
|
68
|
-
},
|
|
69
|
-
path: { type: "string", description: "Absolute path to file or directory, e.g. `/repo/file.py` or `/repo`." },
|
|
70
|
-
file_text: { type: "string", description: "Required parameter of `create` command, with the content of the file to be created." },
|
|
71
|
-
insert_line: { type: "integer", description: "Required parameter of `insert` command. The `new_str` will be inserted AFTER the line `insert_line` of `path`." },
|
|
72
|
-
new_str: { type: "string", description: "Optional parameter of `str_replace` command containing the new string (if not given, no string will be added). Required parameter of `insert` command containing the string to insert." },
|
|
73
|
-
old_str: { type: "string", description: "Required parameter of `str_replace` command containing the string in `path` to replace." },
|
|
74
|
-
view_range: {
|
|
75
|
-
type: "array",
|
|
76
|
-
description: "Optional parameter of `view` command when `path` points to a file. If none is given, the full file is shown. If provided, the file will be shown in the indicated line number range, e.g. [11, 12] will show lines 11 and 12. Indexing at 1 to start. Setting `[start_line, -1]` shows all lines from `start_line` to the end of the file.",
|
|
77
|
-
items: { type: "integer" },
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
required: ["command", "path"],
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
] as const;
|
|
85
|
-
|
|
86
|
-
const TARGET_PATTERN = /deepseek-v4-pro|deepseek-v4\.1-flash/i;
|
|
87
|
-
|
|
88
|
-
/** The directive block, prepended verbatim when `steering.weNeed` is on. */
|
|
89
|
-
export const WE_NEED_DIRECTIVE = "When you think, start each thinking paragraph with \"We need…\".\n\n";
|
|
90
|
-
|
|
91
|
-
/** Match Pro and V4.1 Flash even behind router prefixes or revision suffixes. */
|
|
92
|
-
export function isAnchorTarget(modelId?: string): boolean {
|
|
93
|
-
return typeof modelId === "string" && TARGET_PATTERN.test(modelId);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/** Replace the wire prompt, not Pi's run-wide prompt. Unknown shapes fail open. */
|
|
97
|
-
export function withMinimalPrompt(payload: Record<string, unknown> | undefined, prompt: string): Record<string, unknown> | undefined {
|
|
98
|
-
if (!payload) return undefined;
|
|
99
|
-
// Anthropic Messages carries the prompt separately from the conversation.
|
|
100
|
-
if (typeof payload.system === "string") return { ...payload, system: prompt };
|
|
101
|
-
if (Array.isArray(payload.system)) return { ...payload, system: [{ type: "text", text: prompt }] };
|
|
102
|
-
// The router uses Chat Completions. Preserve the role and any message metadata.
|
|
103
|
-
if (!Array.isArray(payload.messages)) return undefined;
|
|
104
|
-
const [head, ...rest] = payload.messages;
|
|
105
|
-
if ((head?.role === "system" || head?.role === "developer") && typeof head.content === "string") {
|
|
106
|
-
return { ...payload, messages: [{ ...head, content: prompt }, ...rest] };
|
|
107
|
-
}
|
|
108
|
-
return undefined;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export interface AnchorEntry {
|
|
112
|
-
type?: string;
|
|
113
|
-
message?: { role?: string; content?: unknown };
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Policy "either": any durable assistant message (tool call or text) promotes.
|
|
118
|
-
* Append-only — matches upstream semantics.
|
|
119
|
-
*/
|
|
120
|
-
export function hasPromotionSignal(entries: readonly AnchorEntry[]): boolean {
|
|
121
|
-
return entries.some((entry) => {
|
|
122
|
-
if (entry?.type !== "message" || entry.message?.role !== "assistant") return false;
|
|
123
|
-
const content = entry.message.content;
|
|
124
|
-
if (Array.isArray(content)) {
|
|
125
|
-
// Any block (toolCall or text) counts.
|
|
126
|
-
return content.length > 0 && content.some((b: any) => b?.type);
|
|
127
|
-
}
|
|
128
|
-
return false;
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export interface BootstrapFilterResult {
|
|
133
|
-
ok: boolean;
|
|
134
|
-
tools: unknown[];
|
|
135
|
-
reason?: string;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
interface ToolDefLike {
|
|
139
|
-
name?: unknown;
|
|
140
|
-
function?: { name?: unknown };
|
|
141
|
-
parameters?: unknown;
|
|
142
|
-
description?: unknown;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
function toolDefinitionName(tool: ToolDefLike): string | undefined {
|
|
146
|
-
if (typeof tool?.name === "string") return tool.name;
|
|
147
|
-
if (typeof tool?.function?.name === "string") return tool.function.name;
|
|
148
|
-
return undefined;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Replace the payload's tools array with the byte-exact DSH Minimal pair,
|
|
153
|
-
* preserving the payload's tool serialization shape (flat {name,…} vs OpenAI
|
|
154
|
-
* function-wrapped {function:{name,…}}) so the provider never receives a
|
|
155
|
-
* shape it didn't ask for. Requires bash + str_replace_editor to be present
|
|
156
|
-
* first (registration/active proof — execution routes to the registered
|
|
157
|
-
* tools). Fail-open on any problem (missing pair, ambiguous shape).
|
|
158
|
-
*/
|
|
159
|
-
export function dshBootstrapTools(tools: unknown): BootstrapFilterResult {
|
|
160
|
-
const check = filterBootstrapTools(tools);
|
|
161
|
-
if (!check.ok) return check;
|
|
162
|
-
const first = Array.isArray(tools) ? (tools[0] as ToolDefLike | undefined) : undefined;
|
|
163
|
-
const flat = first !== undefined && typeof first.function?.name !== "string";
|
|
164
|
-
const defs = flat
|
|
165
|
-
? DSH_BOOTSTRAP_TOOL_DEFS.map((t) => ({
|
|
166
|
-
type: t.type,
|
|
167
|
-
name: t.function.name,
|
|
168
|
-
description: t.function.description,
|
|
169
|
-
parameters: t.function.parameters,
|
|
170
|
-
}))
|
|
171
|
-
: DSH_BOOTSTRAP_TOOL_DEFS.map((t) => ({ ...t }));
|
|
172
|
-
return { ok: true, tools: defs };
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Narrow a provider payload's tools array to the bootstrap set without
|
|
177
|
-
* introducing tools that were not already present. Fail-open: on any problem
|
|
178
|
-
* returns the original array with ok: false.
|
|
179
|
-
*/
|
|
180
|
-
export function filterBootstrapTools(tools: unknown): BootstrapFilterResult {
|
|
181
|
-
if (!Array.isArray(tools)) return { ok: false, tools: [], reason: "tools array unavailable" };
|
|
182
|
-
const names = tools.map((t) => toolDefinitionName(t as ToolDefLike));
|
|
183
|
-
const available = new Set(names.filter((n): n is string => n !== undefined));
|
|
184
|
-
if (!available.has("bash") || !available.has("str_replace_editor")) {
|
|
185
|
-
return { ok: false, tools, reason: `missing bash/str_replace_editor (found: ${[...available].join(", ") || "none"})` };
|
|
186
|
-
}
|
|
187
|
-
const keep = new Set<string>(BOOTSTRAP_TOOLS);
|
|
188
|
-
return { ok: true, tools: tools.filter((t) => { const n = toolDefinitionName(t as ToolDefLike); return n !== undefined && keep.has(n); }) };
|
|
189
|
-
}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
// ds-anchor × plan mode: the bootstrap DEFERS while plan mode is active.
|
|
2
|
-
// Plan mode strips the mutator tools (str_replace_editor is in plan's
|
|
3
|
-
// BLOCKED_TOOLS), so the DSH pair can never reach the payload — previously
|
|
4
|
-
// the anchor fail-opened PERMANENTLY there: warning + anchorPromoted latch +
|
|
5
|
-
// request #1 shipped with the minimal persona and NO plan-mode contract.
|
|
6
|
-
// Deferral keeps the session anchorable and the warning silent.
|
|
7
|
-
|
|
8
|
-
import assert from "node:assert";
|
|
9
|
-
import { after, before, describe, it } from "node:test";
|
|
10
|
-
import { createFakePi, isolateAgentDir } from "./harness.js";
|
|
11
|
-
import { setPlanActive } from "../../../lib/plan-bridge.ts";
|
|
12
|
-
|
|
13
|
-
const MINIMAL = "You are a helpful software engineer assistant.";
|
|
14
|
-
const TARGET = "combo/deepseek-v4.1-flash";
|
|
15
|
-
// Plan-mode-shaped catalog: reads + plan tools, NO mutator pair.
|
|
16
|
-
const PLAN_TOOLS = ["read", "bash", "grep", "find", "ls", "write_plan", "ask_user_question"];
|
|
17
|
-
|
|
18
|
-
describe("ds-anchor × plan mode", () => {
|
|
19
|
-
let restoreAgentDir: () => void;
|
|
20
|
-
before(() => { restoreAgentDir = isolateAgentDir("ceulen-steering-plan-").restore; });
|
|
21
|
-
after(() => { setPlanActive(false); restoreAgentDir(); });
|
|
22
|
-
|
|
23
|
-
it("defers while plan mode is active: no minimal prompt, no tool filter, no fail-open warning", () => {
|
|
24
|
-
setPlanActive(true);
|
|
25
|
-
const h = createFakePi(PLAN_TOOLS);
|
|
26
|
-
h.setEntries([]);
|
|
27
|
-
h.fire("session_start", {}, h.ctx(TARGET));
|
|
28
|
-
|
|
29
|
-
const r = h.fire("before_agent_start", { prompt: "plan it", systemPrompt: "FULL PI PROMPT", systemPromptOptions: {} }, h.ctx(TARGET));
|
|
30
|
-
assert.notEqual(r?.systemPrompt, MINIMAL, "no minimal prompt while planning");
|
|
31
|
-
assert.ok(r?.systemPrompt === undefined || r.systemPrompt.includes("FULL PI PROMPT"), "composed prompt preserved (plan contract survives)");
|
|
32
|
-
|
|
33
|
-
// The payload that triggered the live bug: plan-filtered catalog without str_replace_editor.
|
|
34
|
-
const out = h.fire("before_provider_request", { payload: { tools: PLAN_TOOLS.map((name) => ({ name })) } }, h.ctx(TARGET));
|
|
35
|
-
assert.equal(out?.tools, undefined, "no tool substitution while planning");
|
|
36
|
-
assert.equal(out?.max_tokens, undefined, "no budget pin while planning");
|
|
37
|
-
assert.equal(h.notifications.length, 0, "no fail-open warning");
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it("bootstrap engages on the first post-exit turn when no assistant reply landed", () => {
|
|
41
|
-
setPlanActive(true);
|
|
42
|
-
const h = createFakePi([...PLAN_TOOLS, "str_replace_editor"]);
|
|
43
|
-
h.setEntries([]);
|
|
44
|
-
h.fire("session_start", {}, h.ctx(TARGET));
|
|
45
|
-
h.fire("before_agent_start", { prompt: "plan it", systemPrompt: "FULL PI PROMPT", systemPromptOptions: {} }, h.ctx(TARGET));
|
|
46
|
-
h.fire("before_provider_request", { payload: { tools: PLAN_TOOLS.map((name) => ({ name })) } }, h.ctx(TARGET));
|
|
47
|
-
assert.equal(h.notifications.length, 0, "still no warning after exit");
|
|
48
|
-
|
|
49
|
-
setPlanActive(false);
|
|
50
|
-
h.fire("before_agent_start", { prompt: "now do it", systemPrompt: "FULL PI PROMPT", systemPromptOptions: {} }, h.ctx(TARGET));
|
|
51
|
-
const out = h.fire("before_provider_request", { payload: { messages: [{ role: "system", content: "FULL PI PROMPT" }], tools: [{ name: "bash" }, { name: "str_replace_editor" }] } }, h.ctx(TARGET));
|
|
52
|
-
assert.equal(out.messages[0].content, MINIMAL, "plan exit with no durable reply → bootstrap fires");
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it("plan-mode assistant replies promote naturally (no post-exit re-anchor)", () => {
|
|
56
|
-
setPlanActive(true);
|
|
57
|
-
const h = createFakePi(PLAN_TOOLS);
|
|
58
|
-
h.setEntries([]);
|
|
59
|
-
h.fire("session_start", {}, h.ctx(TARGET));
|
|
60
|
-
h.setEntries([{ type: "message", message: { role: "assistant", content: [{ type: "text" }] } }]);
|
|
61
|
-
|
|
62
|
-
setPlanActive(false);
|
|
63
|
-
const r = h.fire("before_agent_start", { prompt: "execute", systemPrompt: "FULL PI PROMPT", systemPromptOptions: {} }, h.ctx(TARGET));
|
|
64
|
-
assert.notEqual(r?.systemPrompt, MINIMAL, "history diverged from DSH distribution — no re-anchor");
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it("/steering status discloses the deferral", () => {
|
|
68
|
-
setPlanActive(true);
|
|
69
|
-
const h = createFakePi(PLAN_TOOLS);
|
|
70
|
-
h.setEntries([]);
|
|
71
|
-
h.fire("session_start", {}, h.ctx(TARGET));
|
|
72
|
-
assert.ok(h.status(h.ctx(TARGET)).includes("deferred (plan mode)"));
|
|
73
|
-
});
|
|
74
|
-
});
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
// Regression tests for reviewer-found ds-anchor defects (ported from
|
|
2
|
-
// pi-model-tools extensions/test/unit/ds-anchor-regressions.test.ts):
|
|
3
|
-
// 1. model_select away from target must NOT re-engage the bootstrap (stale
|
|
4
|
-
// sessionModel fallback) — minimal prompt/tool filter/budget pin must be
|
|
5
|
-
// inert for a non-target model after an explicit switch.
|
|
6
|
-
// 2. turn_end with stopReason error/aborted must NOT promote — the retry
|
|
7
|
-
// stays anchored.
|
|
8
|
-
// 3. anchorTrace is per-session (reset on session_start).
|
|
9
|
-
// 4. max_tokens pin emits exactly one budget field (no conflicting pair).
|
|
10
|
-
import assert from "node:assert";
|
|
11
|
-
import { describe, it } from "node:test";
|
|
12
|
-
import { createFakePi } from "./harness.js";
|
|
13
|
-
|
|
14
|
-
const MINIMAL = "You are a helpful software engineer assistant.";
|
|
15
|
-
const payload = { messages: [{ role: "system", content: "FULL" }], tools: [{ name: "bash" }, { name: "str_replace_editor" }, { name: "edit" }] };
|
|
16
|
-
const wirePrompt = (h: ReturnType<typeof createFakePi>, ctx: any) =>
|
|
17
|
-
h.fire("before_provider_request", { payload }, ctx)?.messages?.[0].content ?? payload.messages[0].content;
|
|
18
|
-
|
|
19
|
-
describe("ds-anchor regressions", () => {
|
|
20
|
-
it("model_select away from target keeps the anchor inert (no stale sessionModel re-engage)", () => {
|
|
21
|
-
const h = createFakePi();
|
|
22
|
-
h.setEntries([]);
|
|
23
|
-
h.fire("session_start", {}, h.ctx("deepseek-v4-pro-0813"));
|
|
24
|
-
// switch AWAY to flash
|
|
25
|
-
h.fire("model_select", { model: { id: "deepseek-v4-flash" }, previousModel: undefined, source: "set" }, h.ctx("deepseek-v4-flash"));
|
|
26
|
-
const r = h.fire("before_agent_start", { prompt: "x", systemPrompt: "FULL PI PROMPT", systemPromptOptions: {} }, h.ctx("deepseek-v4-flash"));
|
|
27
|
-
assert.notEqual(r?.systemPrompt, MINIMAL, "flash after switch-away must NOT get the minimal prompt");
|
|
28
|
-
const out = h.fire("before_provider_request", { payload: { tools: [{ name: "bash" }, { name: "str_replace_editor" }, { name: "edit" }] } }, h.ctx("deepseek-v4-flash"));
|
|
29
|
-
assert.equal(out?.tools, undefined, "no tool substitution after switch-away");
|
|
30
|
-
assert.equal(out?.max_tokens, undefined, "no budget pin after switch-away");
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it("model_select to target re-engages the bootstrap", () => {
|
|
34
|
-
const h = createFakePi();
|
|
35
|
-
h.setEntries([]);
|
|
36
|
-
h.fire("session_start", {}, h.ctx("deepseek-v4-flash"));
|
|
37
|
-
h.fire("model_select", { model: { id: "deepseek-v4-pro" }, previousModel: undefined, source: "set" }, h.ctx("deepseek-v4-pro"));
|
|
38
|
-
h.fire("before_agent_start", { prompt: "x", systemPrompt: "FULL PI PROMPT", systemPromptOptions: {} }, h.ctx("deepseek-v4-pro"));
|
|
39
|
-
assert.equal(wirePrompt(h, h.ctx("deepseek-v4-pro")), MINIMAL, "switch to pro engages the bootstrap");
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it("turn_end with stopReason error does NOT promote (retry stays anchored)", () => {
|
|
43
|
-
const h = createFakePi();
|
|
44
|
-
h.setEntries([]);
|
|
45
|
-
h.fire("session_start", {}, h.ctx("deepseek-v4-pro"));
|
|
46
|
-
h.fire("before_agent_start", { prompt: "x", systemPrompt: "FULL", systemPromptOptions: {} }, h.ctx("deepseek-v4-pro"));
|
|
47
|
-
h.fire("turn_end", { turnIndex: 0, message: { role: "assistant", stopReason: "error", content: [] }, toolResults: [] }, h.ctx("deepseek-v4-pro"));
|
|
48
|
-
h.fire("before_agent_start", { prompt: "retry", systemPrompt: "FULL", systemPromptOptions: {} }, h.ctx("deepseek-v4-pro"));
|
|
49
|
-
assert.equal(wirePrompt(h, h.ctx("deepseek-v4-pro")), MINIMAL, "error reply must not promote; retry re-anchors");
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it("turn_end with stopReason aborted does NOT promote", () => {
|
|
53
|
-
const h = createFakePi();
|
|
54
|
-
h.setEntries([]);
|
|
55
|
-
h.fire("session_start", {}, h.ctx("deepseek-v4-pro"));
|
|
56
|
-
h.fire("before_agent_start", { prompt: "x", systemPrompt: "FULL", systemPromptOptions: {} }, h.ctx("deepseek-v4-pro"));
|
|
57
|
-
h.fire("turn_end", { turnIndex: 0, message: { role: "assistant", stopReason: "aborted", content: [] }, toolResults: [] }, h.ctx("deepseek-v4-pro"));
|
|
58
|
-
h.fire("before_agent_start", { prompt: "retry", systemPrompt: "FULL", systemPromptOptions: {} }, h.ctx("deepseek-v4-pro"));
|
|
59
|
-
assert.equal(wirePrompt(h, h.ctx("deepseek-v4-pro")), MINIMAL, "aborted reply must not promote");
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it("turn_end with a real reply promotes", () => {
|
|
63
|
-
const h = createFakePi();
|
|
64
|
-
h.setEntries([]);
|
|
65
|
-
h.fire("session_start", {}, h.ctx("deepseek-v4-pro"));
|
|
66
|
-
h.fire("before_agent_start", { prompt: "x", systemPrompt: "FULL", systemPromptOptions: {} }, h.ctx("deepseek-v4-pro"));
|
|
67
|
-
h.fire("turn_end", { turnIndex: 0, message: { role: "assistant", stopReason: "stop", content: [{ type: "toolCall" }] }, toolResults: [] }, h.ctx("deepseek-v4-pro"));
|
|
68
|
-
h.fire("before_agent_start", { prompt: "next", systemPrompt: "FULL", systemPromptOptions: {} }, h.ctx("deepseek-v4-pro"));
|
|
69
|
-
assert.notEqual(wirePrompt(h, h.ctx("deepseek-v4-pro")), MINIMAL, "durable reply promotes");
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it("anchorTrace resets per session", () => {
|
|
73
|
-
const h = createFakePi();
|
|
74
|
-
h.setEntries([]);
|
|
75
|
-
h.fire("session_start", {}, h.ctx("deepseek-v4-pro"));
|
|
76
|
-
h.fire("before_agent_start", { prompt: "x", systemPrompt: "FULL", systemPromptOptions: {} }, h.ctx("deepseek-v4-pro"));
|
|
77
|
-
wirePrompt(h, h.ctx("deepseek-v4-pro"));
|
|
78
|
-
let s = h.status(h.ctx("deepseek-v4-pro"));
|
|
79
|
-
assert.match(s, /bootstrap: minimal prompt engaged/, "trace populated in session 1");
|
|
80
|
-
// new session
|
|
81
|
-
h.fire("session_start", {}, h.ctx("deepseek-v4-pro"));
|
|
82
|
-
s = h.status(h.ctx("deepseek-v4-pro"));
|
|
83
|
-
assert.doesNotMatch(s, /bootstrap: minimal prompt engaged/, "trace does not leak across sessions");
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
// pi 1.2.0: before_agent_start also fires for sendMessage({triggerTurn: true})
|
|
87
|
-
// runs (cron fires, auto-bg receipts) with messageType "custom" and NO prompt.
|
|
88
|
-
it("a custom-triggered run does NOT consume the bootstrap; the next user turn still gets it", () => {
|
|
89
|
-
const h = createFakePi();
|
|
90
|
-
h.setEntries([]);
|
|
91
|
-
h.fire("session_start", {}, h.ctx("deepseek-v4-pro"));
|
|
92
|
-
// cron-style custom run (no `prompt` field — pi's custom variant)
|
|
93
|
-
const custom = h.fire("before_agent_start", {
|
|
94
|
-
messageType: "custom", message: { customType: "ceulen-cron-fire", content: "job fired" },
|
|
95
|
-
systemPrompt: "FULL PI PROMPT", systemPromptOptions: {},
|
|
96
|
-
}, h.ctx("deepseek-v4-pro"));
|
|
97
|
-
assert.notEqual(custom?.systemPrompt, MINIMAL, "custom run must not get the minimal prompt");
|
|
98
|
-
const out = h.fire("before_provider_request", { payload: { tools: [{ name: "bash" }, { name: "str_replace_editor" }, { name: "edit" }] } }, h.ctx("deepseek-v4-pro"));
|
|
99
|
-
assert.equal(out?.tools, undefined, "custom run keeps the full tool catalog");
|
|
100
|
-
assert.equal(out?.max_tokens, undefined, "custom run gets no budget pin");
|
|
101
|
-
// the bootstrap stayed pending for the next user turn
|
|
102
|
-
h.fire("before_agent_start", { messageType: "user", prompt: "do a task", systemPrompt: "FULL PI PROMPT", systemPromptOptions: {} }, h.ctx("deepseek-v4-pro"));
|
|
103
|
-
assert.equal(wirePrompt(h, h.ctx("deepseek-v4-pro")), MINIMAL, "the next USER turn still bootstraps");
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it("a custom-triggered run gets no first-tool hints (no prompt to read)", () => {
|
|
107
|
-
const h = createFakePi(["bash", "read", "edit", "grep"]);
|
|
108
|
-
h.setEntries([]);
|
|
109
|
-
h.fire("session_start", {}, h.ctx("deepseek-v4-flash"));
|
|
110
|
-
const custom = h.fire("before_agent_start", {
|
|
111
|
-
messageType: "custom", message: { customType: "ceulen-cron-fire", content: "run the task" },
|
|
112
|
-
systemPrompt: "FULL", systemPromptOptions: {},
|
|
113
|
-
}, h.ctx("deepseek-v4-flash"));
|
|
114
|
-
// The static family guidance still composes; what must NOT appear is the
|
|
115
|
-
// prompt-derived dynamic hint (recognisable by its "Do NOT spawn a task
|
|
116
|
-
// agent" / task-shaped preamble). A user turn with the same text DOES add it.
|
|
117
|
-
const customDynamic = (custom?.systemPrompt ?? "").length;
|
|
118
|
-
const user = h.fire("before_agent_start", { messageType: "user", prompt: "refactor everything in the repo", systemPrompt: "FULL", systemPromptOptions: {} }, h.ctx("deepseek-v4-flash"));
|
|
119
|
-
assert.equal(user?.systemPrompt, custom?.systemPrompt, "a custom run adds no dynamic hint");
|
|
120
|
-
assert.ok(String(custom?.systemPrompt ?? "").startsWith("DeepSeek V4"), "static family guidance still composes on custom runs");
|
|
121
|
-
assert.ok(customDynamic > "FULL".length, "static guidance present");
|
|
122
|
-
});
|
|
123
|
-
});
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
// Drive the same bootstrap lifecycle for both target model IDs.
|
|
2
|
-
import assert from "node:assert/strict";
|
|
3
|
-
import { after, before, it } from "node:test";
|
|
4
|
-
import { createFakePi, isolateAgentDir, setSteeringSettings } from "./harness.js";
|
|
5
|
-
import { BOOTSTRAP_TOOLS, MINIMAL_SYSTEM_PROMPT, WE_NEED_DIRECTIVE } from "../lib/anchor.js";
|
|
6
|
-
|
|
7
|
-
const PRO = "deepseek-v4-pro-0813";
|
|
8
|
-
const FLASH = "combo/deepseek-v4.1-flash";
|
|
9
|
-
const TOOLS = ["bash", "str_replace_editor", "read", "find", "apply_patch", "codemode"];
|
|
10
|
-
let isolated: ReturnType<typeof isolateAgentDir>;
|
|
11
|
-
before(() => { isolated = isolateAgentDir("ceulen-steering-wiring-"); });
|
|
12
|
-
after(() => isolated.restore());
|
|
13
|
-
|
|
14
|
-
for (const id of [PRO, FLASH]) {
|
|
15
|
-
it(`${id}: anchors request #1 only, then restores the full composed prompt and catalog in the same turn`, () => {
|
|
16
|
-
const h = createFakePi(TOOLS);
|
|
17
|
-
const ctx = h.ctx(id);
|
|
18
|
-
h.fire("session_start", {}, ctx);
|
|
19
|
-
const { systemPrompt } = h.fire("before_agent_start", { prompt: "Read limits.ts", systemPrompt: "FULL PI PROMPT" }, ctx);
|
|
20
|
-
assert.match(systemPrompt, /FULL PI PROMPT/);
|
|
21
|
-
assert.match(systemPrompt, /Batch independent calls/);
|
|
22
|
-
const payload = { model: id, messages: [{ role: "system", content: systemPrompt }, { role: "user", content: "Read limits.ts" }], tools: TOOLS.map((name) => ({ function: { name } })), max_tokens: 384000 };
|
|
23
|
-
const out = h.fire("before_provider_request", { payload }, ctx);
|
|
24
|
-
assert.deepEqual(out.tools.map((t: any) => t.function.name), BOOTSTRAP_TOOLS);
|
|
25
|
-
assert.equal(out.messages[0].content, MINIMAL_SYSTEM_PROMPT);
|
|
26
|
-
assert.match(out.messages[1].content, /current workspace with bash \(`find \. -name/);
|
|
27
|
-
assert.doesNotMatch(out.messages[1].content, /Call find FIRST/, "no find-tool hint while find is unavailable");
|
|
28
|
-
assert.equal(out.max_tokens, 256000);
|
|
29
|
-
assert.match(h.status(ctx), /bootstrap: minimal prompt engaged; tools=\[bash,str_replace_editor\]/);
|
|
30
|
-
assert.equal(h.fire("tool_call", { toolName: "read", input: {} }, ctx)?.block, true);
|
|
31
|
-
assert.equal(h.fire("tool_call", { toolName: "str_replace_editor", input: { command: "view", path: "/x" } }, ctx), undefined);
|
|
32
|
-
h.fire("turn_end", { message: { role: "assistant", stopReason: "toolUse", content: [{ type: "toolCall" }] } }, ctx);
|
|
33
|
-
assert.equal(h.fire("tool_call", { toolName: "read", input: {} }, ctx), undefined);
|
|
34
|
-
const next = { ...payload, messages: [...payload.messages, { role: "tool", content: "result" }] };
|
|
35
|
-
assert.equal(h.fire("before_provider_request", { payload: next }, ctx), undefined);
|
|
36
|
-
assert.equal(next.messages[0].content, systemPrompt);
|
|
37
|
-
assert.equal(next.tools.length, TOOLS.length);
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
it("keeps guidance and loadout when the pair is absent or hidden", () => {
|
|
42
|
-
for (const active of [["read", "find"], TOOLS]) {
|
|
43
|
-
const h = createFakePi(active);
|
|
44
|
-
const ctx = h.ctx(FLASH);
|
|
45
|
-
h.fire("session_start", {}, ctx);
|
|
46
|
-
const hiddenTools = active === TOOLS ? ["bash", "str_replace_editor"] : [];
|
|
47
|
-
const { systemPrompt } = h.fire("before_agent_start", { prompt: "Read limits.ts", systemPrompt: "CHILD CONTRACT", systemPromptOptions: { selectedTools: active, hiddenTools } }, ctx);
|
|
48
|
-
const payload = { messages: [{ role: "system", content: systemPrompt }, { role: "user", content: "Read limits.ts" }], tools: active.filter((name) => !hiddenTools.includes(name)).map((name) => ({ name })) };
|
|
49
|
-
const out = h.fire("before_provider_request", { payload }, ctx);
|
|
50
|
-
assert.match(out.messages[0].content, /CHILD CONTRACT/);
|
|
51
|
-
assert.match(out.messages[1].content, /Call find FIRST/);
|
|
52
|
-
assert.deepEqual(out.tools, payload.tools);
|
|
53
|
-
assert.equal(out.max_tokens, undefined);
|
|
54
|
-
assert.equal(h.notifications.length, 0);
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("fails open atomically when the wire tools differ from the selected tools", () => {
|
|
59
|
-
const h = createFakePi(TOOLS);
|
|
60
|
-
const ctx = h.ctx(FLASH);
|
|
61
|
-
h.fire("session_start", {}, ctx);
|
|
62
|
-
h.fire("before_agent_start", { prompt: "hello", systemPrompt: "FULL" }, ctx);
|
|
63
|
-
const payload = { messages: [{ role: "system", content: "FULL" }], tools: [{ name: "bash" }, { name: "read" }] };
|
|
64
|
-
assert.equal(h.fire("before_provider_request", { payload }, ctx), undefined);
|
|
65
|
-
assert.equal(h.fire("tool_call", { toolName: "read", input: {} }, ctx), undefined);
|
|
66
|
-
assert.match(h.notifications[0], /full prompt and catalog preserved/);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it("anchors the proxied served model, honors the we-need flag and clamps to the model limit", () => {
|
|
70
|
-
setSteeringSettings(isolated.dir, { weNeed: true });
|
|
71
|
-
try {
|
|
72
|
-
const h = createFakePi(TOOLS);
|
|
73
|
-
h.fire("session_start", {}, h.ctx("deepseek-v4-flash"));
|
|
74
|
-
const ctx = h.ctx(FLASH, { model: { id: FLASH, provider: "router", maxTokens: 64000 } });
|
|
75
|
-
h.fire("before_agent_start", { prompt: "task", systemPrompt: "FULL" }, ctx);
|
|
76
|
-
const payload = { messages: [{ role: "developer", content: "FULL" }], tools: TOOLS.map((name) => ({ name })), max_tokens: 8192, max_completion_tokens: 8192 };
|
|
77
|
-
const out = h.fire("before_provider_request", { payload }, ctx);
|
|
78
|
-
assert.equal(out.messages[0].content, WE_NEED_DIRECTIVE + MINIMAL_SYSTEM_PROMPT);
|
|
79
|
-
assert.equal(out.max_completion_tokens, 64000);
|
|
80
|
-
assert.equal(out.max_tokens, undefined);
|
|
81
|
-
} finally { setSteeringSettings(isolated.dir, {}); }
|
|
82
|
-
});
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
// Ported from pi-model-tools extensions/test/unit/ds-anchor.test.ts.
|
|
2
|
-
// Local changes: the anchorEnabled / weNeedDirectiveEnabled env toggles are
|
|
3
|
-
// `steering.dsAnchor` / `steering.weNeed` settings rows (covered by
|
|
4
|
-
// settings.test.ts), and the byte-fidelity comparison against the registered
|
|
5
|
-
// str_replace_editor tool is dropped — that tool belongs to the repair module,
|
|
6
|
-
// so only the injected DSH definition itself is asserted here.
|
|
7
|
-
import assert from "node:assert";
|
|
8
|
-
import { describe, it } from "node:test";
|
|
9
|
-
import {
|
|
10
|
-
MINIMAL_SYSTEM_PROMPT,
|
|
11
|
-
BOOTSTRAP_TOOLS,
|
|
12
|
-
isAnchorTarget,
|
|
13
|
-
hasPromotionSignal,
|
|
14
|
-
filterBootstrapTools,
|
|
15
|
-
dshBootstrapTools,
|
|
16
|
-
DSH_BOOTSTRAP_TOOL_DEFS,
|
|
17
|
-
WE_NEED_DIRECTIVE,
|
|
18
|
-
} from "../lib/anchor.js";
|
|
19
|
-
|
|
20
|
-
describe("isAnchorTarget", () => {
|
|
21
|
-
it("matches V4 Pro and V4.1 Flash, not older Flash or other families", () => {
|
|
22
|
-
assert.equal(isAnchorTarget("deepseek-v4-pro"), true);
|
|
23
|
-
assert.equal(isAnchorTarget("deepseek-v4-pro-0813"), true);
|
|
24
|
-
assert.equal(isAnchorTarget("OCG/DeepSeek-V4-Pro"), true);
|
|
25
|
-
assert.equal(isAnchorTarget("router/combo/deepseek-v4.1-flash"), true);
|
|
26
|
-
assert.equal(isAnchorTarget("OCG/DeepSeek-V4.1-Flash-1017"), true);
|
|
27
|
-
assert.equal(isAnchorTarget("deepseek-v4-flash"), false);
|
|
28
|
-
assert.equal(isAnchorTarget("deepseek-chat"), false);
|
|
29
|
-
assert.equal(isAnchorTarget("deepseek-v3"), false);
|
|
30
|
-
assert.equal(isAnchorTarget("glm-5.2"), false);
|
|
31
|
-
assert.equal(isAnchorTarget(""), false);
|
|
32
|
-
assert.equal(isAnchorTarget(undefined), false);
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
describe("hasPromotionSignal", () => {
|
|
37
|
-
it("assistant message with tool call promotes", () => {
|
|
38
|
-
const entries = [
|
|
39
|
-
{ type: "message", message: { role: "user", content: [{ type: "text", text: "hi" }] } },
|
|
40
|
-
{ type: "message", message: { role: "assistant", content: [{ type: "toolCall", id: "t1" }] } },
|
|
41
|
-
];
|
|
42
|
-
assert.equal(hasPromotionSignal(entries), true);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it("text-only assistant message promotes", () => {
|
|
46
|
-
const entries = [
|
|
47
|
-
{ type: "message", message: { role: "assistant", content: [{ type: "text", text: "hello" }] } },
|
|
48
|
-
];
|
|
49
|
-
assert.equal(hasPromotionSignal(entries), true);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it("user-only entries do not promote", () => {
|
|
53
|
-
const entries = [
|
|
54
|
-
{ type: "message", message: { role: "user", content: [{ type: "text", text: "hi" }] } },
|
|
55
|
-
{ type: "message", message: { role: "toolResult", content: [] } },
|
|
56
|
-
];
|
|
57
|
-
assert.equal(hasPromotionSignal(entries), false);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it("empty entries do not promote", () => {
|
|
61
|
-
assert.equal(hasPromotionSignal([]), false);
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
describe("filterBootstrapTools", () => {
|
|
66
|
-
const mixed = [
|
|
67
|
-
{ name: "bash", parameters: {} },
|
|
68
|
-
{ name: "str_replace_editor", parameters: {} },
|
|
69
|
-
{ name: "edit", parameters: {} },
|
|
70
|
-
{ name: "read", parameters: {} },
|
|
71
|
-
{ type: "function", function: { name: "grep" } },
|
|
72
|
-
];
|
|
73
|
-
|
|
74
|
-
it("keeps only bash+str_replace_editor from a mixed catalog", () => {
|
|
75
|
-
const res = filterBootstrapTools(mixed);
|
|
76
|
-
assert.equal(res.ok, true);
|
|
77
|
-
assert.deepEqual(res.tools.map((t: any) => t.name ?? t.function?.name), ["bash", "str_replace_editor"]);
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it("OpenAI function.name shape is recognized", () => {
|
|
81
|
-
const openaiShape = [
|
|
82
|
-
{ type: "function", function: { name: "str_replace_editor", parameters: {} } },
|
|
83
|
-
{ type: "function", function: { name: "bash", parameters: {} } },
|
|
84
|
-
];
|
|
85
|
-
const res = filterBootstrapTools(openaiShape);
|
|
86
|
-
assert.equal(res.ok, true);
|
|
87
|
-
assert.equal(res.tools.length, 2);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it("missing str_replace_editor fails open with the original array", () => {
|
|
91
|
-
const noEditor = [{ name: "bash" }, { name: "read" }];
|
|
92
|
-
const res = filterBootstrapTools(noEditor);
|
|
93
|
-
assert.equal(res.ok, false);
|
|
94
|
-
assert.equal(res.tools, noEditor); // same reference — original returned
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it("missing bash fails open", () => {
|
|
98
|
-
const noBash = [{ name: "str_replace_editor" }];
|
|
99
|
-
const res = filterBootstrapTools(noBash);
|
|
100
|
-
assert.equal(res.ok, false);
|
|
101
|
-
assert.equal(res.tools, noBash);
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it("non-array tools fails open", () => {
|
|
105
|
-
const res = filterBootstrapTools(undefined);
|
|
106
|
-
assert.equal(res.ok, false);
|
|
107
|
-
assert.deepEqual(res.tools, []);
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
describe("dshBootstrapTools shape preservation", () => {
|
|
112
|
-
it("flat payload shape in → flat DSH defs out", () => {
|
|
113
|
-
const flat = [{ name: "bash", parameters: {} }, { name: "str_replace_editor", parameters: {} }, { name: "edit" }];
|
|
114
|
-
const res = dshBootstrapTools(flat);
|
|
115
|
-
assert.equal(res.ok, true);
|
|
116
|
-
assert.equal(res.tools.length, 2);
|
|
117
|
-
assert.equal((res.tools[0] as any).function, undefined, "no function wrapper for flat shape");
|
|
118
|
-
assert.equal((res.tools[0] as any).name, "bash");
|
|
119
|
-
assert.equal((res.tools[1] as any).name, "str_replace_editor");
|
|
120
|
-
assert.equal((res.tools[1] as any).parameters.properties.command.enum.length, 4);
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
it("function-wrapped payload shape in → function-wrapped defs out", () => {
|
|
124
|
-
const wrapped = [
|
|
125
|
-
{ type: "function", function: { name: "bash", parameters: {} } },
|
|
126
|
-
{ type: "function", function: { name: "str_replace_editor", parameters: {} } },
|
|
127
|
-
];
|
|
128
|
-
const res = dshBootstrapTools(wrapped);
|
|
129
|
-
assert.equal(res.ok, true);
|
|
130
|
-
assert.equal((res.tools[0] as any).function.name, "bash");
|
|
131
|
-
assert.equal((res.tools[1] as any).function.name, "str_replace_editor");
|
|
132
|
-
assert.equal((res.tools[0] as any).name, undefined, "function-wrapped defs keep the wrapper");
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
it("missing pair still fails open", () => {
|
|
136
|
-
const res = dshBootstrapTools([{ name: "bash" }, { name: "edit" }]);
|
|
137
|
-
assert.equal(res.ok, false);
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
describe("constants", () => {
|
|
142
|
-
it("minimal prompt is byte-stable and bootstrap set is the real Minimal pair", () => {
|
|
143
|
-
assert.equal(MINIMAL_SYSTEM_PROMPT, "You are a helpful software engineer assistant.");
|
|
144
|
-
assert.deepEqual([...BOOTSTRAP_TOOLS], ["bash", "str_replace_editor"]);
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
it("we-need directive is the DSH thinking directive", () => {
|
|
148
|
-
assert.match(WE_NEED_DIRECTIVE, /We need/);
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
it("DSH tool defs stay byte-faithful (no Pi serialization leaked in)", () => {
|
|
152
|
-
const [dshBash, dshEditor] = DSH_BOOTSTRAP_TOOL_DEFS;
|
|
153
|
-
assert.equal(dshBash.function.name, "bash");
|
|
154
|
-
assert.equal(dshEditor.function.name, "str_replace_editor");
|
|
155
|
-
assert.equal(dshEditor.function.parameters.required.join(","), "command,path", "DSH def requires command+path");
|
|
156
|
-
assert.equal(dshEditor.function.parameters.properties.command.enum.length, 4, "command enum intact");
|
|
157
|
-
assert.equal(dshEditor.function.parameters.properties.insert_line.type, "integer", "insert_line is integer in DSH def");
|
|
158
|
-
// No strict/extra fields in the injected def (byte fidelity).
|
|
159
|
-
assert.equal((DSH_BOOTSTRAP_TOOL_DEFS[1] as any).strict, undefined);
|
|
160
|
-
assert.equal((DSH_BOOTSTRAP_TOOL_DEFS[0] as any).strict, undefined);
|
|
161
|
-
});
|
|
162
|
-
});
|