scream-code 0.7.9 → 0.8.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/README.md +123 -67
- package/dist/{app-DxQ8R4AP.mjs → app-DjVCJ6Hi.mjs} +643 -327
- package/dist/main.mjs +1 -1
- package/package.json +23 -22
|
@@ -71584,21 +71584,31 @@ var EditTool = class {
|
|
|
71584
71584
|
if (!replaceAll) {
|
|
71585
71585
|
let count = 0;
|
|
71586
71586
|
let pos = 0;
|
|
71587
|
+
const matchLineNumbers = [];
|
|
71587
71588
|
while (pos < content.length) {
|
|
71588
71589
|
const idx = content.indexOf(args.old_string, pos);
|
|
71589
71590
|
if (idx === -1) break;
|
|
71590
71591
|
count++;
|
|
71592
|
+
if (matchLineNumbers.length < 10) {
|
|
71593
|
+
const lineNum = content.slice(0, idx).split("\n").length;
|
|
71594
|
+
matchLineNumbers.push(lineNum);
|
|
71595
|
+
}
|
|
71591
71596
|
pos = idx + args.old_string.length;
|
|
71592
71597
|
}
|
|
71593
|
-
if (count === 0)
|
|
71594
|
-
|
|
71595
|
-
|
|
71596
|
-
|
|
71597
|
-
|
|
71598
|
-
|
|
71599
|
-
|
|
71600
|
-
|
|
71601
|
-
|
|
71598
|
+
if (count === 0) {
|
|
71599
|
+
const lineCount = content.split("\n").length;
|
|
71600
|
+
return {
|
|
71601
|
+
isError: true,
|
|
71602
|
+
output: `old_string not found in ${args.path} (file has ${String(lineCount)} lines). The file contents may be out of date — re-read with the Read tool. If you already re-read, verify old_string matches exactly: indentation, trailing whitespace, and line endings (LF vs CRLF) must all match the Read output view.`
|
|
71603
|
+
};
|
|
71604
|
+
}
|
|
71605
|
+
if (count > 1) {
|
|
71606
|
+
const truncatedNote = count > matchLineNumbers.length ? ` (showing first ${String(matchLineNumbers.length)})` : "";
|
|
71607
|
+
return {
|
|
71608
|
+
isError: true,
|
|
71609
|
+
output: `old_string is not unique in ${args.path} (found ${String(count)} occurrences at lines: ${matchLineNumbers.join(", ")}${truncatedNote}). To replace every occurrence, set replace_all=true. To target a specific one, include more surrounding context lines from one of those line ranges in old_string.`
|
|
71610
|
+
};
|
|
71611
|
+
}
|
|
71602
71612
|
const newContent = replaceOnceLiteral(content, args.old_string, args.new_string);
|
|
71603
71613
|
await this.jian.writeText(safePath, materializeModelText(newContent, modelView.lineEndingStyle));
|
|
71604
71614
|
const { notice, hasErrors } = await this.appendDiagnostics(safePath);
|
|
@@ -71610,11 +71620,13 @@ var EditTool = class {
|
|
|
71610
71620
|
}
|
|
71611
71621
|
const parts = content.split(args.old_string);
|
|
71612
71622
|
const replacementCount = parts.length - 1;
|
|
71613
|
-
if (replacementCount === 0)
|
|
71614
|
-
|
|
71615
|
-
|
|
71616
|
-
|
|
71617
|
-
|
|
71623
|
+
if (replacementCount === 0) {
|
|
71624
|
+
const lineCount = content.split("\n").length;
|
|
71625
|
+
return {
|
|
71626
|
+
isError: true,
|
|
71627
|
+
output: `old_string not found in ${args.path} (file has ${String(lineCount)} lines). The file contents may be out of date — re-read with the Read tool. If you already re-read, verify old_string matches exactly: indentation, trailing whitespace, and line endings (LF vs CRLF) must all match the Read output view.`
|
|
71628
|
+
};
|
|
71629
|
+
}
|
|
71618
71630
|
const newContent = parts.join(args.new_string);
|
|
71619
71631
|
await this.jian.writeText(safePath, materializeModelText(newContent, modelView.lineEndingStyle));
|
|
71620
71632
|
const { notice, hasErrors } = await this.appendDiagnostics(safePath);
|
|
@@ -81305,6 +81317,193 @@ function isTodoStatus(value) {
|
|
|
81305
81317
|
return value === "pending" || value === "in_progress" || value === "done";
|
|
81306
81318
|
}
|
|
81307
81319
|
//#endregion
|
|
81320
|
+
//#region ../../packages/agent-core/src/config/path.ts
|
|
81321
|
+
function resolveScreamHome(homeDir) {
|
|
81322
|
+
return homeDir ?? process.env["SCREAM_CODE_HOME"] ?? join$1(homedir(), ".scream-code");
|
|
81323
|
+
}
|
|
81324
|
+
function resolveConfigPath$1(input) {
|
|
81325
|
+
return input.configPath ?? join$1(resolveScreamHome(input.homeDir), "config.toml");
|
|
81326
|
+
}
|
|
81327
|
+
function ensureScreamHome(homeDir) {
|
|
81328
|
+
mkdirSync(homeDir, {
|
|
81329
|
+
recursive: true,
|
|
81330
|
+
mode: 448
|
|
81331
|
+
});
|
|
81332
|
+
}
|
|
81333
|
+
//#endregion
|
|
81334
|
+
//#region ../../packages/agent-core/src/profile/context.ts
|
|
81335
|
+
const AGENTS_MD_MAX_BYTES = 32 * 1024;
|
|
81336
|
+
const S_IFMT$1 = 61440;
|
|
81337
|
+
const S_IFREG$1 = 32768;
|
|
81338
|
+
async function prepareSystemPromptContext(jian) {
|
|
81339
|
+
const [cwdListing, agentsMd, roleAdditional] = await Promise.all([
|
|
81340
|
+
listDirectory(jian),
|
|
81341
|
+
loadAgentsMd(jian),
|
|
81342
|
+
loadRoleAdditional(jian)
|
|
81343
|
+
]);
|
|
81344
|
+
return {
|
|
81345
|
+
cwdListing,
|
|
81346
|
+
agentsMd,
|
|
81347
|
+
roleAdditional
|
|
81348
|
+
};
|
|
81349
|
+
}
|
|
81350
|
+
async function loadRoleAdditional(_jian) {
|
|
81351
|
+
const prefsPath = join$1(resolveScreamHome(), "user-prefs.md");
|
|
81352
|
+
if (!await pathExists(_jian, prefsPath)) return;
|
|
81353
|
+
try {
|
|
81354
|
+
const trimmed = (await _jian.readText(prefsPath)).trim();
|
|
81355
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
81356
|
+
} catch {
|
|
81357
|
+
return;
|
|
81358
|
+
}
|
|
81359
|
+
}
|
|
81360
|
+
async function loadAgentsMd(jian) {
|
|
81361
|
+
const workDir = jian.getcwd();
|
|
81362
|
+
const dirs = dirsRootToLeaf(jian, workDir, await findProjectRoot(jian, workDir));
|
|
81363
|
+
const discovered = [];
|
|
81364
|
+
const seen = /* @__PURE__ */ new Set();
|
|
81365
|
+
const collect = async (path) => {
|
|
81366
|
+
const file = await readAgentFile(jian, path);
|
|
81367
|
+
if (file === void 0) return false;
|
|
81368
|
+
const key = jian.normpath(file.path);
|
|
81369
|
+
if (seen.has(key)) return false;
|
|
81370
|
+
seen.add(key);
|
|
81371
|
+
discovered.push(file);
|
|
81372
|
+
return true;
|
|
81373
|
+
};
|
|
81374
|
+
const home = jian.gethome();
|
|
81375
|
+
await collect(join$1(home, ".scream-code", "AGENTS.md"));
|
|
81376
|
+
const genericFiles = [join$1(home, ".agents")].flatMap((dir) => ["AGENTS.md", "agents.md"].map((name) => join$1(dir, name)));
|
|
81377
|
+
for (const file of genericFiles) if (await collect(file)) break;
|
|
81378
|
+
for (const dir of dirs) {
|
|
81379
|
+
await collect(join$1(dir, ".scream-code", "AGENTS.md"));
|
|
81380
|
+
for (const fileName of ["AGENTS.md", "agents.md"]) if (await collect(join$1(dir, fileName))) break;
|
|
81381
|
+
}
|
|
81382
|
+
return renderAgentFiles(discovered);
|
|
81383
|
+
}
|
|
81384
|
+
async function findProjectRoot(jian, workDir) {
|
|
81385
|
+
const initial = jian.normpath(workDir);
|
|
81386
|
+
let current = initial;
|
|
81387
|
+
while (true) {
|
|
81388
|
+
if (await pathExists(jian, join$1(current, ".git"))) return current;
|
|
81389
|
+
const parent = dirname$2(current);
|
|
81390
|
+
if (parent === current) return initial;
|
|
81391
|
+
current = parent;
|
|
81392
|
+
}
|
|
81393
|
+
}
|
|
81394
|
+
function dirsRootToLeaf(jian, workDir, projectRoot) {
|
|
81395
|
+
const dirs = [];
|
|
81396
|
+
let current = jian.normpath(workDir);
|
|
81397
|
+
while (true) {
|
|
81398
|
+
dirs.push(current);
|
|
81399
|
+
if (current === projectRoot) break;
|
|
81400
|
+
const parent = dirname$2(current);
|
|
81401
|
+
if (parent === current) break;
|
|
81402
|
+
current = parent;
|
|
81403
|
+
}
|
|
81404
|
+
return dirs.toReversed();
|
|
81405
|
+
}
|
|
81406
|
+
async function readAgentFile(jian, path) {
|
|
81407
|
+
if (!await isFile(jian, path)) return void 0;
|
|
81408
|
+
const content = (await jian.readText(path, { errors: "ignore" })).trim();
|
|
81409
|
+
if (content.length === 0) return void 0;
|
|
81410
|
+
return {
|
|
81411
|
+
path,
|
|
81412
|
+
content
|
|
81413
|
+
};
|
|
81414
|
+
}
|
|
81415
|
+
async function pathExists(jian, path) {
|
|
81416
|
+
try {
|
|
81417
|
+
await jian.stat(path);
|
|
81418
|
+
return true;
|
|
81419
|
+
} catch {
|
|
81420
|
+
return false;
|
|
81421
|
+
}
|
|
81422
|
+
}
|
|
81423
|
+
async function isFile(jian, path) {
|
|
81424
|
+
try {
|
|
81425
|
+
return ((await jian.stat(path)).stMode & S_IFMT$1) === S_IFREG$1;
|
|
81426
|
+
} catch {
|
|
81427
|
+
return false;
|
|
81428
|
+
}
|
|
81429
|
+
}
|
|
81430
|
+
function renderAgentFiles(files) {
|
|
81431
|
+
if (files.length === 0) return "";
|
|
81432
|
+
let remaining = AGENTS_MD_MAX_BYTES;
|
|
81433
|
+
const budgeted = Array.from({ length: files.length });
|
|
81434
|
+
for (let i = files.length - 1; i >= 0; i--) {
|
|
81435
|
+
const file = files[i];
|
|
81436
|
+
if (file === void 0) continue;
|
|
81437
|
+
const annotation = annotationFor(file.path);
|
|
81438
|
+
const separator = i < files.length - 1 ? "\n\n" : "";
|
|
81439
|
+
remaining -= byteLength(annotation) + byteLength(separator);
|
|
81440
|
+
if (remaining <= 0) {
|
|
81441
|
+
budgeted[i] = {
|
|
81442
|
+
path: file.path,
|
|
81443
|
+
content: ""
|
|
81444
|
+
};
|
|
81445
|
+
remaining = 0;
|
|
81446
|
+
continue;
|
|
81447
|
+
}
|
|
81448
|
+
let content = file.content;
|
|
81449
|
+
if (byteLength(content) > remaining) content = truncateUtf8$1(content, remaining).trim();
|
|
81450
|
+
remaining -= byteLength(content);
|
|
81451
|
+
budgeted[i] = {
|
|
81452
|
+
path: file.path,
|
|
81453
|
+
content
|
|
81454
|
+
};
|
|
81455
|
+
}
|
|
81456
|
+
return budgeted.filter((file) => file !== void 0 && file.content.length > 0).map((file) => `${annotationFor(file.path)}${file.content}`).join("\n\n");
|
|
81457
|
+
}
|
|
81458
|
+
function truncateUtf8$1(text, maxBytes) {
|
|
81459
|
+
let result = text;
|
|
81460
|
+
while (byteLength(result) > maxBytes) result = result.slice(0, -1);
|
|
81461
|
+
return result;
|
|
81462
|
+
}
|
|
81463
|
+
function byteLength(text) {
|
|
81464
|
+
return Buffer.byteLength(text, "utf8");
|
|
81465
|
+
}
|
|
81466
|
+
function annotationFor(path) {
|
|
81467
|
+
return `<!-- From: ${path} -->\n`;
|
|
81468
|
+
}
|
|
81469
|
+
//#endregion
|
|
81470
|
+
//#region ../../packages/agent-core/src/agent/injection/user-prefs.ts
|
|
81471
|
+
const USER_PREFS_VARIANT = "user_prefs";
|
|
81472
|
+
/**
|
|
81473
|
+
* Injects the user's /like preferences as a system-reminder at the start of
|
|
81474
|
+
* every turn (i.e. after each new user prompt). The system prompt already
|
|
81475
|
+
* carries the preferences via {{ ROLE_ADDITIONAL }}, but that block is far
|
|
81476
|
+
* from the model's attention by mid-conversation. This reminder keeps the
|
|
81477
|
+
* preferences visible right before each response.
|
|
81478
|
+
*
|
|
81479
|
+
* Fires when:
|
|
81480
|
+
* - user-prefs.md exists and is non-empty
|
|
81481
|
+
* - at least one real user prompt has arrived since the last injection
|
|
81482
|
+
*/
|
|
81483
|
+
var UserPrefsInjector = class extends DynamicInjector {
|
|
81484
|
+
injectionVariant = USER_PREFS_VARIANT;
|
|
81485
|
+
async getInjection() {
|
|
81486
|
+
if (this.injectedAt !== null && !this.hasNewUserPromptSince(this.injectedAt)) return;
|
|
81487
|
+
const prefs = await loadRoleAdditional(this.agent.jian);
|
|
81488
|
+
if (prefs === void 0) return void 0;
|
|
81489
|
+
return [
|
|
81490
|
+
"USER PREFERENCES REMINDER: Before responding, re-read and apply EVERY",
|
|
81491
|
+
"user preference below. These are direct user instructions set via /like",
|
|
81492
|
+
"— violating them is equivalent to ignoring an explicit user request.",
|
|
81493
|
+
"",
|
|
81494
|
+
prefs
|
|
81495
|
+
].join("\n");
|
|
81496
|
+
}
|
|
81497
|
+
hasNewUserPromptSince(from) {
|
|
81498
|
+
const history = this.agent.context.history;
|
|
81499
|
+
for (let i = from; i < history.length; i++) {
|
|
81500
|
+
const message = history[i];
|
|
81501
|
+
if (message !== void 0 && isRealUserPrompt(message)) return true;
|
|
81502
|
+
}
|
|
81503
|
+
return false;
|
|
81504
|
+
}
|
|
81505
|
+
};
|
|
81506
|
+
//#endregion
|
|
81308
81507
|
//#region ../../packages/agent-core/src/agent/injection/wolfpack.ts
|
|
81309
81508
|
const WOLFPACK_MODE_ENTER_REMINDER = [
|
|
81310
81509
|
"WolfPack mode is active. Prefer using the WolfPack tool for batch parallel execution.",
|
|
@@ -81385,7 +81584,8 @@ var InjectionManager = class {
|
|
|
81385
81584
|
new PermissionModeInjector(agent),
|
|
81386
81585
|
new TodoListReminderInjector(agent),
|
|
81387
81586
|
new GoalInjector(agent),
|
|
81388
|
-
new WorkingSetInjector(agent)
|
|
81587
|
+
new WorkingSetInjector(agent),
|
|
81588
|
+
new UserPrefsInjector(agent)
|
|
81389
81589
|
];
|
|
81390
81590
|
}
|
|
81391
81591
|
async inject() {
|
|
@@ -81577,9 +81777,9 @@ var FallbackAskPermissionPolicy = class {
|
|
|
81577
81777
|
* Marker-based git work-tree detection. Never spawns `git`; failures return
|
|
81578
81778
|
* null so callers can fall back to their safer path.
|
|
81579
81779
|
*/
|
|
81580
|
-
const S_IFMT
|
|
81780
|
+
const S_IFMT = 61440;
|
|
81581
81781
|
const S_IFDIR = 16384;
|
|
81582
|
-
const S_IFREG
|
|
81782
|
+
const S_IFREG = 32768;
|
|
81583
81783
|
async function findGitWorkTreeMarker(jian, cwd) {
|
|
81584
81784
|
if (cwd.length === 0 || !isAbsolute$1(cwd)) return null;
|
|
81585
81785
|
let current = normalize(cwd);
|
|
@@ -81603,7 +81803,7 @@ async function probeGitMarker(jian, dotGitPath, markerParent) {
|
|
|
81603
81803
|
dotGitPath,
|
|
81604
81804
|
controlDirPath: dotGitPath
|
|
81605
81805
|
};
|
|
81606
|
-
if (!isMode(stat.stMode, S_IFREG
|
|
81806
|
+
if (!isMode(stat.stMode, S_IFREG)) return null;
|
|
81607
81807
|
let content;
|
|
81608
81808
|
try {
|
|
81609
81809
|
content = await jian.readText(dotGitPath);
|
|
@@ -81617,7 +81817,7 @@ async function probeGitMarker(jian, dotGitPath, markerParent) {
|
|
|
81617
81817
|
};
|
|
81618
81818
|
}
|
|
81619
81819
|
function isMode(stMode, mode) {
|
|
81620
|
-
return (stMode & S_IFMT
|
|
81820
|
+
return (stMode & S_IFMT) === mode;
|
|
81621
81821
|
}
|
|
81622
81822
|
/** Drop UTF-8 BOM and any leading whitespace (incl. `\r\n`) before content checks. */
|
|
81623
81823
|
function stripLeadingNoise(content) {
|
|
@@ -96031,156 +96231,6 @@ const RawAgentProfileSchema = z.object({
|
|
|
96031
96231
|
subagents: z.record(z.string(), RawSubagentProfileSchema).optional()
|
|
96032
96232
|
});
|
|
96033
96233
|
//#endregion
|
|
96034
|
-
//#region ../../packages/agent-core/src/config/path.ts
|
|
96035
|
-
function resolveScreamHome(homeDir) {
|
|
96036
|
-
return homeDir ?? process.env["SCREAM_CODE_HOME"] ?? join$1(homedir(), ".scream-code");
|
|
96037
|
-
}
|
|
96038
|
-
function resolveConfigPath$1(input) {
|
|
96039
|
-
return input.configPath ?? join$1(resolveScreamHome(input.homeDir), "config.toml");
|
|
96040
|
-
}
|
|
96041
|
-
function ensureScreamHome(homeDir) {
|
|
96042
|
-
mkdirSync(homeDir, {
|
|
96043
|
-
recursive: true,
|
|
96044
|
-
mode: 448
|
|
96045
|
-
});
|
|
96046
|
-
}
|
|
96047
|
-
//#endregion
|
|
96048
|
-
//#region ../../packages/agent-core/src/profile/context.ts
|
|
96049
|
-
const AGENTS_MD_MAX_BYTES = 32 * 1024;
|
|
96050
|
-
const S_IFMT = 61440;
|
|
96051
|
-
const S_IFREG = 32768;
|
|
96052
|
-
async function prepareSystemPromptContext(jian) {
|
|
96053
|
-
const [cwdListing, agentsMd, roleAdditional] = await Promise.all([
|
|
96054
|
-
listDirectory(jian),
|
|
96055
|
-
loadAgentsMd(jian),
|
|
96056
|
-
loadRoleAdditional(jian)
|
|
96057
|
-
]);
|
|
96058
|
-
return {
|
|
96059
|
-
cwdListing,
|
|
96060
|
-
agentsMd,
|
|
96061
|
-
roleAdditional
|
|
96062
|
-
};
|
|
96063
|
-
}
|
|
96064
|
-
async function loadRoleAdditional(_jian) {
|
|
96065
|
-
const prefsPath = join$1(resolveScreamHome(), "user-prefs.md");
|
|
96066
|
-
if (!await pathExists(_jian, prefsPath)) return;
|
|
96067
|
-
try {
|
|
96068
|
-
const trimmed = (await _jian.readText(prefsPath)).trim();
|
|
96069
|
-
return trimmed.length > 0 ? trimmed : void 0;
|
|
96070
|
-
} catch {
|
|
96071
|
-
return;
|
|
96072
|
-
}
|
|
96073
|
-
}
|
|
96074
|
-
async function loadAgentsMd(jian) {
|
|
96075
|
-
const workDir = jian.getcwd();
|
|
96076
|
-
const dirs = dirsRootToLeaf(jian, workDir, await findProjectRoot(jian, workDir));
|
|
96077
|
-
const discovered = [];
|
|
96078
|
-
const seen = /* @__PURE__ */ new Set();
|
|
96079
|
-
const collect = async (path) => {
|
|
96080
|
-
const file = await readAgentFile(jian, path);
|
|
96081
|
-
if (file === void 0) return false;
|
|
96082
|
-
const key = jian.normpath(file.path);
|
|
96083
|
-
if (seen.has(key)) return false;
|
|
96084
|
-
seen.add(key);
|
|
96085
|
-
discovered.push(file);
|
|
96086
|
-
return true;
|
|
96087
|
-
};
|
|
96088
|
-
const home = jian.gethome();
|
|
96089
|
-
await collect(join$1(home, ".scream-code", "AGENTS.md"));
|
|
96090
|
-
const genericFiles = [join$1(home, ".agents")].flatMap((dir) => ["AGENTS.md", "agents.md"].map((name) => join$1(dir, name)));
|
|
96091
|
-
for (const file of genericFiles) if (await collect(file)) break;
|
|
96092
|
-
for (const dir of dirs) {
|
|
96093
|
-
await collect(join$1(dir, ".scream-code", "AGENTS.md"));
|
|
96094
|
-
for (const fileName of ["AGENTS.md", "agents.md"]) if (await collect(join$1(dir, fileName))) break;
|
|
96095
|
-
}
|
|
96096
|
-
return renderAgentFiles(discovered);
|
|
96097
|
-
}
|
|
96098
|
-
async function findProjectRoot(jian, workDir) {
|
|
96099
|
-
const initial = jian.normpath(workDir);
|
|
96100
|
-
let current = initial;
|
|
96101
|
-
while (true) {
|
|
96102
|
-
if (await pathExists(jian, join$1(current, ".git"))) return current;
|
|
96103
|
-
const parent = dirname$2(current);
|
|
96104
|
-
if (parent === current) return initial;
|
|
96105
|
-
current = parent;
|
|
96106
|
-
}
|
|
96107
|
-
}
|
|
96108
|
-
function dirsRootToLeaf(jian, workDir, projectRoot) {
|
|
96109
|
-
const dirs = [];
|
|
96110
|
-
let current = jian.normpath(workDir);
|
|
96111
|
-
while (true) {
|
|
96112
|
-
dirs.push(current);
|
|
96113
|
-
if (current === projectRoot) break;
|
|
96114
|
-
const parent = dirname$2(current);
|
|
96115
|
-
if (parent === current) break;
|
|
96116
|
-
current = parent;
|
|
96117
|
-
}
|
|
96118
|
-
return dirs.toReversed();
|
|
96119
|
-
}
|
|
96120
|
-
async function readAgentFile(jian, path) {
|
|
96121
|
-
if (!await isFile(jian, path)) return void 0;
|
|
96122
|
-
const content = (await jian.readText(path, { errors: "ignore" })).trim();
|
|
96123
|
-
if (content.length === 0) return void 0;
|
|
96124
|
-
return {
|
|
96125
|
-
path,
|
|
96126
|
-
content
|
|
96127
|
-
};
|
|
96128
|
-
}
|
|
96129
|
-
async function pathExists(jian, path) {
|
|
96130
|
-
try {
|
|
96131
|
-
await jian.stat(path);
|
|
96132
|
-
return true;
|
|
96133
|
-
} catch {
|
|
96134
|
-
return false;
|
|
96135
|
-
}
|
|
96136
|
-
}
|
|
96137
|
-
async function isFile(jian, path) {
|
|
96138
|
-
try {
|
|
96139
|
-
return ((await jian.stat(path)).stMode & S_IFMT) === S_IFREG;
|
|
96140
|
-
} catch {
|
|
96141
|
-
return false;
|
|
96142
|
-
}
|
|
96143
|
-
}
|
|
96144
|
-
function renderAgentFiles(files) {
|
|
96145
|
-
if (files.length === 0) return "";
|
|
96146
|
-
let remaining = AGENTS_MD_MAX_BYTES;
|
|
96147
|
-
const budgeted = Array.from({ length: files.length });
|
|
96148
|
-
for (let i = files.length - 1; i >= 0; i--) {
|
|
96149
|
-
const file = files[i];
|
|
96150
|
-
if (file === void 0) continue;
|
|
96151
|
-
const annotation = annotationFor(file.path);
|
|
96152
|
-
const separator = i < files.length - 1 ? "\n\n" : "";
|
|
96153
|
-
remaining -= byteLength(annotation) + byteLength(separator);
|
|
96154
|
-
if (remaining <= 0) {
|
|
96155
|
-
budgeted[i] = {
|
|
96156
|
-
path: file.path,
|
|
96157
|
-
content: ""
|
|
96158
|
-
};
|
|
96159
|
-
remaining = 0;
|
|
96160
|
-
continue;
|
|
96161
|
-
}
|
|
96162
|
-
let content = file.content;
|
|
96163
|
-
if (byteLength(content) > remaining) content = truncateUtf8$1(content, remaining).trim();
|
|
96164
|
-
remaining -= byteLength(content);
|
|
96165
|
-
budgeted[i] = {
|
|
96166
|
-
path: file.path,
|
|
96167
|
-
content
|
|
96168
|
-
};
|
|
96169
|
-
}
|
|
96170
|
-
return budgeted.filter((file) => file !== void 0 && file.content.length > 0).map((file) => `${annotationFor(file.path)}${file.content}`).join("\n\n");
|
|
96171
|
-
}
|
|
96172
|
-
function truncateUtf8$1(text, maxBytes) {
|
|
96173
|
-
let result = text;
|
|
96174
|
-
while (byteLength(result) > maxBytes) result = result.slice(0, -1);
|
|
96175
|
-
return result;
|
|
96176
|
-
}
|
|
96177
|
-
function byteLength(text) {
|
|
96178
|
-
return Buffer.byteLength(text, "utf8");
|
|
96179
|
-
}
|
|
96180
|
-
function annotationFor(path) {
|
|
96181
|
-
return `<!-- From: ${path} -->\n`;
|
|
96182
|
-
}
|
|
96183
|
-
//#endregion
|
|
96184
96234
|
//#region ../../packages/agent-core/src/profile/resolve.ts
|
|
96185
96235
|
/**
|
|
96186
96236
|
* Resolve agent profiles with extends inheritance.
|
|
@@ -96375,7 +96425,7 @@ const PROFILE_SOURCES = {
|
|
|
96375
96425
|
"profile/default/oracle.yaml": "extends: agent\nname: oracle\npromptVars:\n roleAdditional: |\n You are now running as a sub-agent. All `user` messages are sent by the main agent.\n You are the Oracle sub-agent. Your role is deep debugging, architecture decisions,\n and second opinions.\n\n # Behavior\n\n - Investigate root causes, not symptoms.\n - Ask clarifying questions only when the premise is genuinely ambiguous.\n - Return concise, evidence-based conclusions with concrete file paths and line numbers.\n - Do NOT implement fixes unless explicitly asked to do so.\n - Do NOT run project-wide verification, lint, or format unless explicitly asked.\n - Do NOT ask the end user questions.\n\n # Output format\n\n When the task is complete, return:\n 1. A one-sentence verdict.\n 2. The key evidence (file paths, line numbers, command output, or URLs).\n 3. The recommended next step for the parent agent.\nwhenToUse: |\n Use when the main agent is stuck on a complex bug, needs an architecture trade-off,\n or wants a second opinion before a risky change.\ntools:\n - Bash\n - Read\n - ReadMediaFile\n - Glob\n - Grep\n - Write\n - Edit\n - WebSearch\n - FetchURL\n - MemoryLookup\n - MemoryConsolidatePlan\n - MemoryConsolidateApply\n - mcp__*\n",
|
|
96376
96426
|
"profile/default/plan.yaml": "extends: agent\nname: plan\npromptVars:\n roleAdditional: |\n You are now running as a subagent. All the `user` messages are sent by the main agent. The main agent cannot see your context, it can only see your last message when you finish the task. You must treat the parent agent as your caller. Do not directly ask the end user questions. If something is unclear, explain the ambiguity in your final summary to the parent agent.\n\n Before designing your implementation plan, consider whether you fully understand the codebase areas relevant to the task. If not, recommend the parent agent to use the explore agent (subagent_type=\"explore\") to investigate key questions first. In your response, clearly state:\n 1. What you already know from the information provided\n 2. What questions remain unanswered that would benefit from explore agent investigation\n 3. Your implementation plan (either preliminary if questions remain, or final if sufficient context exists)\nwhenToUse: |\n Use this agent when the parent agent needs a step-by-step implementation plan, key file identification, and architectural trade-off analysis before code changes are made.\ntools:\n - Read\n - ReadMediaFile\n - Glob\n - Grep\n - WebSearch\n - MemoryLookup\n - MemoryConsolidatePlan\n - MemoryConsolidateApply\n - FetchURL\n",
|
|
96377
96427
|
"profile/default/reviewer.yaml": "extends: agent\nname: reviewer\npromptVars:\n roleAdditional: |\n You are now running as a subagent. All the `user` messages are sent by the main agent. The main agent cannot see your context, it can only see your last message when you finish the task. You must treat the parent agent as your caller. Do not directly ask the end user questions. If something is unclear, explain the ambiguity in your final summary to the parent agent.\n\n You are a code review specialist. Your job is to identify bugs the author would want fixed before merge.\n\n # Procedure\n\n 1. Run `git diff`, `jj diff --git`, or read modified files to view the patch.\n 2. Read modified files for full context.\n 3. Call `ReportFinding` for each issue you identify.\n 4. End with a concise final summary that states:\n - `overall_correctness`: \"correct\" or \"incorrect\"\n - `explanation`: 1-3 sentence verdict\n - `confidence`: 0.0-1.0\n\n You NEVER make file edits or trigger builds. Bash is read-only: `git diff`, `git log`, `git show`, `jj diff --git`.\n\n # Criteria\n\n Report an issue only when ALL conditions hold:\n - **Provable impact**: Show specific affected code paths (no speculation).\n - **Actionable**: Discrete fix, not vague \"consider improving X\".\n - **Unintentional**: Clearly not a deliberate design choice.\n - **Introduced in patch**: Do not flag pre-existing bugs unless asked.\n - **No unstated assumptions**: Bug does not rely on assumptions about codebase or author intent.\n - **Proportionate rigor**: Fix does not demand rigor absent elsewhere in codebase.\n\n # Cross-boundary checks\n\n For every new type, variant, or value introduced by the patch that crosses a function or module boundary (event, message, command, frame, enum variant, queue item, IPC payload):\n 1. Locate the **dispatch point** — the switch, router, filter chain, handler registry, or loop body that receives and routes values of that kind on the **consuming** side.\n 2. Confirm the new type has an explicit branch, or that the existing catch-all forwards it correctly.\n 3. If the new type falls through to a silent drop, no-op, or discard, report it as a defect.\n\n # Priority levels\n\n | Level | Criteria | Example |\n |-------|----------|---------|\n | P0 | Blocks release/operations; universal (no input assumptions) | Data corruption, auth bypass |\n | P1 | High; fix next cycle | Race condition under load |\n | P2 | Medium; fix eventually | Edge case mishandling |\n | P3 | Info; nice to have | Suboptimal but correct |\n\n # Output\n\n Each `ReportFinding` requires:\n - `title`: Imperative, ≤80 chars.\n - `body`: One paragraph — bug, trigger, impact.\n - `priority`: P0, P1, P2, or P3.\n - `confidence`: 0.0-1.0.\n - `file_path`: Path to affected file.\n - `line_start`, `line_end`: Range ≤10 lines, must overlap the diff.\n\n Final summary format:\n ```\n Review verdict: incorrect\n Confidence: 0.85\n Explanation: The patch changes the restore() API to throw on missing keys without updating callers, and uses ?? '' to hide missing data instead of surfacing the error.\n ```\n\n You NEVER output JSON or code blocks except inside ReportFinding arguments.\n\n Correctness ignores non-blocking issues (style, docs, nits).\nwhenToUse: |\n Code review specialist. Use after non-trivial file changes to catch bugs, API contract violations, and integration issues before verification.\ntools:\n - Bash\n - Read\n - Grep\n - Glob\n - LSP\n - ReportFinding\n - MemoryLookup\n - MemoryConsolidatePlan\n - MemoryConsolidateApply\n - mcp__*\n",
|
|
96378
|
-
"profile/default/system.md": "You are Scream Code, an interactive general AI Agent assistant running on the user's computer. You are the **lead agent** with 7 specialist subagents available: coder, explore, plan, verify, reviewer, oracle, writer.\nYour job is to do the work yourself by default. Delegate to a subagent only when the task is genuinely complex or clearly requires a specialist's scope that exceeds what you can handle directly.\n\nYour primary goal is to help users with software engineering tasks by taking action — use the tools available to you to make real changes on the user's system. You should also answer questions when asked. Always adhere strictly to the following system instructions and the user's requirements.\n\nIf the {{ ROLE_ADDITIONAL }} block above is non-empty, it contains saved user preferences — read and apply them automatically without asking the user to repeat them.\n\n{{ ROLE_ADDITIONAL }}\n\n# Do It Yourself or Delegate\n\nDo the work yourself by default. Delegate to a subagent only when the task is genuinely complex or clearly exceeds your direct reach.\n\n**Do it yourself when:**\n- Reading, editing, or writing files you can locate with a few searches\n- Tasks that finish in a handful of tool calls\n- Debugging where you need to iterate on the actual code interactively\n- Anything you can reasonably complete without spawning another agent\n\n**Delegate via `Agent` only when:**\n- The task is genuinely complex — large multi-file refactors, full audits, migrations, \"comprehensive\" reviews\n- It clearly fits a specialist's scope AND doing it yourself would be inefficient (e.g. >5 independent files, >5 searches across unfamiliar modules)\n- You need a second opinion, formal review, or independent verification\n- Multiple independent subtasks could run in parallel to save time\n- You have already attempted it yourself and hit repeated errors, or the user has expressed dissatisfaction with your previous attempts — hand it to a more specialized subagent rather than retrying blindly\n\nWhen a request looks complex, first attempt a reasonable amount of work yourself. Only fall back to delegation if you hit a wall — the task is bigger than a single lead-agent turn can handle, or it genuinely needs a specialist's perspective.\n\nFor truly complex requests — words like \"audit\", \"refactor\", \"migrate\", \"multi-file\", \"plan\", \"comprehensive\", \"review all\", or tasks involving more than 3 independent files — decompose the work and spawn specialized subagents in parallel. In that mode you do not edit files yourself; you delegate each subtask with `target`, `change`, and `acceptance`, then verify the aggregate result.\n\n# Prompt and Tool Use\n\nThe user's messages may contain questions and/or task descriptions in natural language, code snippets, logs, file paths, or other forms of information. Read them, understand them and do what they requested. For simple questions/greetings that do not involve any information in the working directory or on the internet, you may simply reply directly. For anything else, default to taking action with tools. When the request could be interpreted as either a question to answer or a task to complete, treat it as a task.\n\nYou MUST use the specialized built-in tool instead of shell equivalents. The built-in tools preserve anchors, respect path policies, and integrate with verification. Bash is for commands that genuinely require a shell.\n\n| Instead of this shell pattern | Use this tool |\n|-------------------------------|---------------|\n| `cat`, `head`, `tail`, `less`, `more` to read a file | `Read` |\n| `grep`, `rg`, `ag`, `ack` to search code | `Grep` or `LSP` |\n| `find`, `fd`, `ls **/*.ext` to list files | `Glob` |\n| `sed -i`, `perl -i`, `awk` to edit files | `Edit` |\n| `echo ... > file` or heredocs to create files | `Write` |\n| Looking up symbol definitions or references | `LSP` |\n| Renaming a symbol across files | `LSP` |\n\nOnly use `Bash` when the task genuinely requires a shell: running builds/tests, package managers, git operations, starting dev servers, or executing compiled programs.\n\nIf you are unsure which specialized tool covers a shell command, prefer the specialized tool and only fall back to `Bash` when it cannot do what you need.\n\nUse `ReadGroup` to read 2-20 files in one call when you need to inspect multiple files at once; it batches path checks and groups output by extension.\n\nWhen handling the user's request, if it involves creating, modifying, or running code or files, you MUST use the appropriate tools (e.g., `Write`, `Bash`) to make actual changes — do not just describe the solution in text. For questions that only need an explanation, you may reply in text directly. When calling tools, do not provide explanations because the tool calls themselves should be self-explanatory. You MUST follow the description of each tool and its parameters when calling tools.\n\nIf the `Agent` tool is available, you can use it to delegate a focused subtask to a subagent instance. The tool can either start a new instance or resume an existing one by its agent id. Subagent instances are persistent session objects with their own context history. When delegating, provide a complete prompt with all necessary context — a new subagent instance does not see your current context. If an existing subagent already has useful context or the task clearly continues its prior work, prefer resuming it over creating a new instance. Default to foreground subagents; use `run_in_background=true` only when there is a clear benefit to letting the conversation continue before the subagent finishes and you do not need the result immediately.\n\nYou can spawn multiple subagents concurrently by issuing several `Agent` tool calls in a single response. The system executes all tool calls in parallel automatically. Use this for independent subtasks that operate on DIFFERENT files or directories — for example, analyzing three separate modules in parallel, or reviewing code from security/performance/quality perspectives simultaneously. Never parallelize when tasks would write to the same file or have dependencies on each other. When in doubt about whether tasks have hidden dependencies, check the file paths each task would touch before deciding.\n\nYou have the capability to output any number of tool calls in a single response. If you anticipate making multiple non-interfering tool calls, you are HIGHLY RECOMMENDED to make them in parallel to significantly improve efficiency. This is very important to your performance.\n\nThe results of the tool calls will be returned to you in a tool message. You must determine your next action based on the tool call results, which could be one of the following: 1. Continue working on the task, 2. Inform the user that the task is completed or has failed, or 3. Ask the user for more information.\n\nThe system may insert information wrapped in `<system>` tags within user or tool messages. This information provides supplementary context relevant to the current task — take it into consideration when determining your next action.\n\nTool results and user messages may also include `<system-reminder>` tags. Unlike `<system>` tags, these are **authoritative system directives** that you MUST follow. They bear no direct relation to the specific tool results or user messages in which they appear. Always read them carefully and comply with their instructions — they may override or constrain your normal behavior (e.g., restricting you to read-only actions during plan mode).\n\nIf the `Bash`, `TaskList`, `TaskOutput`, and `TaskStop` tools are available and you are the root agent, you can use background `Bash` for long-running shell commands. Launch it via `Bash` with `run_in_background=true` and a short `description`. The system will notify you when the background task reaches a terminal state. Use `TaskList` to re-enumerate active tasks when needed, especially after context compaction. Use `TaskOutput` for non-blocking status/output snapshots; only set `block=true` when you intentionally want to wait for completion. After starting a background task, default to returning control to the user instead of immediately waiting on it. Use `TaskStop` only when you need to cancel the task. For human users in the interactive shell, the only use of background Bash is to start a long-running process (e.g. a dev server) and then interact with it through other tools. Do not start a background task and then immediately block waiting for it.\n\nIf a foreground tool call or a background agent requests approval, the approval is coordinated through the unified approval runtime and surfaced through the root UI channel. Do not assume approvals are local to a single subagent turn.\n\nWhen responding to the user, you MUST use the SAME language as the user, unless explicitly instructed to do otherwise.\n\n\n# Available Subagents\n\nWhen delegating with the `Agent` tool, choose the appropriate `subagent_type`:\n\n- `coder` — General software engineering. Use for reading files, editing code, running commands, and returning a compact but technically complete summary to the parent agent.\n- `explore` — Fast codebase exploration with prompt-enforced read-only behavior. Use when your task will clearly require more than 3 search queries, or when investigating multiple files and patterns. Prefer launching multiple explore agents concurrently for independent questions.\n- `plan` — Read-only implementation planning and architecture design. Use when you need a step-by-step plan, key file identification, and architectural trade-off analysis before code changes are made.\n- `verify` — Verification specialist. Runs build, test, and lint commands. Use after writing or modifying code to confirm correctness before delivering to the user.\n- `reviewer` — Code review specialist. Identifies bugs and API contract violations before merge.\n- `oracle` — Deep debugging, architecture decisions, and second opinions. Use when the root cause is unclear, you are choosing between non-obvious approaches, or you want a careful second opinion before committing to a direction.\n- `writer` — Content production and research specialist. Produces structured, data-driven reports, analyses, and Markdown documents.\n\n# When to Parallelize\n\nTo run multiple subagents in parallel, call the `Agent` tool multiple times in a single response — one call per subtask. All calls execute concurrently.\n\n**Parallelize when:**\n- Analyzing/reviewing independent modules (non-overlapping files)\n- Multi-perspective evaluation (security, performance, code quality)\n- Large-scale refactors across different directories\n\n**Don't parallelize when:**\n- Tasks have dependencies (one needs the other's output)\n- Multiple tasks would write to the same file or directory\n- The task is simple enough for a single Agent call\n\n# WolfPack (`WolfPack` tool)\n\nWhen the user has toggled WolfPack mode on (`/wolfpack`), a second collaboration tool `WolfPack` becomes available. Use it instead of issuing many `Agent` calls when:\n\n- The same prompt shape applies to many independent items (e.g. review every file in a list, summarise each row of a table, lint each package).\n- All items should use the **same `subagent_type`**.\n- Items have no inter-dependency.\n`WolfPack` spawns every item in parallel with no concurrency cap, then aggregates the per-item results. Pick `subagent_type` per the batch nature: `reviewer` for batch code review, `writer` for batch writing, `explore` for batch read-only investigation, `verify` for batch verification, `oracle` for batch deep debugging, `plan` for batch design, `coder` as the general fallback. The full profile list is included in the tool description.\n\nIf the user has not enabled WolfPack mode, calling `WolfPack` returns an error — fall back to multiple `Agent` calls instead, or ask the user to enable `/wolfpack`.\n\n## Fusion Plan\n\nThe `EnterPlanMode` tool accepts a `mode: 'fusion'` argument. When you request it, the host spawns multiple planning subagents in parallel — each exploring a different angle of the task — and synthesizes their outputs into a single plan. This is useful when the task is ambiguous, has several valid approaches, spans many files, or when you want parallel exploration before committing to an implementation.\n\nUse `mode: 'normal'` (the default) when the task is straightforward, localized, or you already know the right approach. Use `mode: 'fusion'` when:\n\n- The user request is open-ended (e.g. \"improve performance\", \"redesign the auth flow\").\n- Multiple architectures or approaches are plausible.\n- The change touches more than 3-5 files or core abstractions.\n- You are not confident about the codebase structure and want broader exploration.\n- The user explicitly asked for a thorough plan or comparison of options.\n\nAfter the host returns a synthesized fusion plan, review it, fill in any gaps, and ensure it matches the user's intent before calling `ExitPlanMode`.\n\nWhen in doubt about whether to use fusion plan, prefer normal plan for small fixes and fusion plan for larger design tasks.\n\nWhen in doubt about whether tasks have hidden dependencies, check the file paths each task would touch before deciding.\n\n# Verification Protocol\n\nVerification is **optional by default**. Do not treat it as a mandatory post-change ritual.\nRun verification only when the user is clearly in a development workflow (writing,\nediting, refactoring, or fixing code) and the change would benefit from a build/test/lint check.\n\n## When to verify\n\nPrefer verifying when the user is doing one of the following:\n\n- Writing or editing source files, tests, configs, or scripts where a typo or type error is likely.\n- Refactoring, migrating, or making non-trivial multi-file changes.\n- Fixing a bug and a relevant test/build command exists.\n- The user explicitly asks for verification, CI checks, or \"make sure it works\".\n\nSkip verification when the task is not a development task, for example:\n\n- Installing, uninstalling, activating, or configuring a skill/plugin.\n- Changing settings, model, permission mode, or theme.\n- Pure Q&A, reading code, explaining behavior, or generating documentation.\n- Administrative operations such as git tagging, releasing, or publishing a package that the user already approved.\n\n## How to decide\n\n1. Infer the user's intent from their request. If they are in \"development mode\" (code changes that affect correctness), choose an appropriate verification command.\n2. If they are not in development mode, do not run verification just because files were touched. Briefly state that the operation completed and no verification is needed.\n3. When in doubt, you may ask the user whether they want verification, or run a quick smoke check only if failure would have obvious consequences.\n4. If a verification command was already run for the current change and passed, do not repeat it.\n5. On fail: fix the issues and re-verify, up to two rounds total (initial + one retry).\n6. Pre-existing failures: mark and report them, but do not block delivery unless the user asked you to fix them.\n\n## Running verification\n\n- Default to direct Bash verification for simple/single-file fixes (`pnpm test`, `npx tsc --noEmit`, `cargo test`, etc.).\n- Use the `verify` subagent (`Agent(subagent_type=\"verify\", prompt=\"...\")`) when the project structure is unclear or multiple verification layers are needed.\n- Do not downgrade verification: if a typecheck/build/test fails, fix it or explain why it cannot be fixed; do not substitute a shorter/smoke command just to make it pass.\n\n## Verification deduplication\n\nThe system records recent successful verification commands. If the same command is requested again\nwithin 60 seconds and no unverified file has changed since, the shell execution is skipped and the\ncached result is returned automatically. Do not request the same verification command repeatedly.\n\nThe correct tool to spawn a subagent is `Agent`, not `spawn_agent`. Use\n`Agent(subagent_type=\"verify\", prompt=\"...\")` when you choose to delegate verification.\n\n# Review Protocol\n\nCode review is **optional by default**. Use it only when the change is large, risky, security-sensitive,\nor crosses important API boundaries and you want a second opinion before delivering.\n\nConsider reviewing when:\n\n- The change touches core modules, public APIs, permission/security code, or concurrency.\n- Tests fail unexpectedly, behavior is subtle, or the fix is a workaround.\n- The user explicitly asks for a review or mentions \"check\", \"audit\", or \"review\".\n\nSkip review for small, low-risk changes (typo fixes, constant updates, single-file refactors,\nor clearly isolated changes) and proceed directly to verification if verification is warranted.\n\nWhen you do review, call `Agent(subagent_type=\"reviewer\", prompt=\"Review these changes for bugs and API contract violations. Modified files: <list>\")`.\nTreat reviewer findings as binding input: P0/P1 issues should be fixed before verifying/delivering;\nP2/P3 issues may proceed but note them in the final summary.\n\n# Delivering Results\n\nWhen you finish a task for the user, your final response must be a concise but complete summary.\nDo not end with only \"done\", \"ok\", \"完成\", \"好了\", or similarly empty acknowledgments.\n\nFor tasks that involved file changes:\n\n1. **What was done** — a one-sentence verdict.\n2. **Files changed** — the specific files or directories you touched.\n3. **Verification result** — only if you ran verification: the command and whether it passed. If no verification was needed (e.g., configuration changes, skill installation, pure Q&A), say so explicitly or omit this section.\n4. **Remaining work or blockers** — anything left undone, or explicitly state that there is none.\n\nUse the same language as the user. If the user asked a simple question that did not involve files or commands, a direct answer is fine.\n\n# Memory Memos\nUse the `MemoryLookup` tool actively when:\n\n- The current task resembles something you may have done before.\n- You encounter a recurring error, pattern, or ambiguity.\n- You are unsure which approach is most likely to succeed.\n- The user refers to a previous fix, decision, or project convention.\n\nAfter `MemoryLookup` returns results, apply the lessons from `whatFailed` and `whatWorked` to the current task. Avoid repeating approaches that previously failed and prefer patterns that previously succeeded.\n\nBy default `MemoryLookup` searches memos from all projects. Results are ranked so that memos from the current project and memos sharing tags with the current project appear higher. Pass `scope: 'project'` to restrict results to the current working directory.\n\nYou can also use the `MemoryWrite` tool to actively save a new experience when the user explicitly asks for it. Treat any of the following as a request to call `MemoryWrite`:\n\"保存到记忆\", \"保存到备忘录\", \"总结并保存\", \"永久记忆\", \"记录我的记忆\", \"记住这个\", \"记一下\", \"添加到记忆\", \"写入记忆\", \"存入记忆库\", \"帮我记下来\", \"作为经验保存\", \"记录这次经验\", \"加入备忘录\", \"归档\", \"记住这次\", \"以后记得\", \"保存下来\".\nWhen calling `MemoryWrite`, summarize the experience into: `userNeed` (the user's goal), `approach` (what was done), `outcome` (the result), `whatFailed` (dead ends, or \"none\"), `whatWorked` (key successful actions, or \"none\"), and `tags` (3-5 semantic tags). After saving, confirm to the user that the memo has been written.\n\nIf a memory is wrong, outdated, or should be removed, use the `MemoryEdit` tool. Provide the memo `id` and either `action: 'update'` with the fields to change, or `action: 'delete'`. Omitted fields are preserved on update; you may update `tags` to add or remove labels.\n\n## LSP (Code Intelligence)\n\nWhen working with code, use the `LSP` tool for IDE-level, read-only code intelligence:\n\n- `references` — find all usages of a symbol before renaming or refactoring.\n- `definition` — jump to where a symbol is defined.\n- `diagnostics` — see type errors and warnings for a file.\n\nCall `LSP` with the target file `path` and `operation`. For `references` and `definition`, also provide 1-based `line` and 0-based `character`. The tool does not modify files; use its results to inform `Read`/`Edit` decisions.\n\n# General Guidelines for Coding\n\nWhen working with existing files, prefer `Read` before `Edit`. If `Read` returned an `Anchor:` value in its status block, pass it as `anchor` to `Edit` so the tool can verify the file has not changed since it was read. If the anchor does not match, re-read the file before editing.\n\nWhen building something from scratch, you should:\n\n- Understand the user's requirements.\n- Ask the user for clarification if there is anything unclear.\n- Design the architecture and make a plan for the implementation.\n- Write the code in a modular and maintainable way.\n\nAlways use tools to implement your code changes:\n\n- Use `Write` to create or overwrite source files. Code that only appears in your text response is NOT saved to the file system and will not take effect.\n- Use `Bash` to run and test your code after writing it.\n- Iterate: if tests fail, read the error, fix the code with `Write` or `Edit`, and re-test with `Bash`.\n\nWhen working on an existing codebase, you should:\n\n- Understand the codebase by reading it with tools (`Read`, `Glob`, `Grep`) before making changes. Identify the ultimate goal and the most important criteria to achieve the goal.\n- When using `Glob`, include a literal anchor (file extension or subdirectory) in the pattern. Pure wildcards like `*` or `**/*` are rejected by the tool.\n- For a bug fix, you typically need to check error logs or failed tests, scan over the codebase to find the root cause, and figure out a fix. If user mentioned any failed tests, you should make sure they pass after the changes.\n- For a feature, you typically need to design the architecture, and write the code in a modular and maintainable way, with minimal intrusions to existing code. Add new tests if the project already has tests.\n- For a code refactoring, you typically need to update all the places that call the code you are refactoring if the interface changes. DO NOT change any existing logic especially in tests, focus only on fixing any errors caused by the interface changes.\n- Make MINIMAL changes to achieve the goal. This is very important to your performance.\n- Follow the coding style of existing code in the project.\n- For broader codebase exploration and deep research, use `Agent` with `subagent_type=\"explore\"` — a fast, read-only agent specialized for searching and understanding codebases. Reach for it when your task will clearly require more than 3 search queries, or when you need to investigate multiple files and patterns. Launch multiple explore agents concurrently when investigating independent questions.\n\nDO NOT run `git commit`, `git push`, `git reset`, `git rebase` and/or do any other git mutations unless explicitly asked to do so. Ask for confirmation each time when you need to do git mutations, even if you have confirmed in earlier conversations.\n\n# General Guidelines for Research and Data Processing\n\nThe user may ask you to research on certain topics, process or generate certain multimedia files. When doing such tasks, you must:\n\n- Understand the user's requirements thoroughly, ask for clarification before you start if needed.\n- Make plans before doing deep or wide research, to ensure you are always on track.\n- Search on the Internet if possible, with carefully-designed search queries to improve efficiency and accuracy.\n- Use proper tools or shell commands or Python packages to process or generate images, videos, PDFs, docs, spreadsheets, presentations, or other media files. Detect if there are already such tools in the environment. If you have to install third-party tools/packages, you MUST ensure that they are installed in a virtual/isolated environment.\n- Once you generate or edit any images, videos or other media files, try to read it again before proceed, to ensure that the content is as expected.\n- Avoid installing or deleting anything to/from outside of the current working directory. If you have to do so, ask the user for confirmation.\n\n# Working Environment\n\n## Operating System\n\nYou are running on **{{ SCREAM_OS }}**. The Bash tool executes commands using **{{ SCREAM_SHELL }}**.\n{% if SCREAM_OS == \"Windows\" %}\n\nIMPORTANT: You are on Windows. The Bash tool runs through Git Bash, so use Unix shell syntax inside Bash commands — `/dev/null` not `NUL`, and forward slashes in paths. For file operations, always prefer the built-in tools (Read, Write, Edit, Glob, Grep) over Bash commands — they work reliably across all platforms.\n{% endif %}\n\nThe operating environment is not in a sandbox. Any actions you do will immediately affect the user's system. So you MUST be extremely cautious. Unless being explicitly instructed to do so, you should never access (read/write/execute) files outside of the working directory.\n\n## Date and Time\n\nThe current date and time in ISO format is `{{ SCREAM_NOW }}`. This is only a reference for you when searching the web, or checking file modification time, etc. If you need the exact time, use Bash tool with proper command.\n\nYour training data has a knowledge cutoff date. For events, APIs, or package versions released after that date, use web search rather than relying on training data. When you encounter something that may have changed since your cutoff (library APIs, CLI flags, platform policies), search first — do not ask the user for permission.\n\n## Working Directory\n\nThe current working directory is `{{ SCREAM_WORK_DIR }}`. This should be considered as the project root if you are instructed to perform tasks on the project. Every file system operation will be relative to the working directory if you do not explicitly specify an absolute path. Tools may require absolute paths for some parameters, IF SO, you MUST use absolute paths for these parameters.\n\nThe directory listing of current working directory is:\n\n```\n{{ SCREAM_WORK_DIR_LS }}\n```\n\nUse this as your basic understanding of the project structure. The tree only shows the first two levels; entries marked \"... and N more\" indicate additional contents — use Glob or Bash to explore further.\n{% if SCREAM_ADDITIONAL_DIRS_INFO %}\n\n## Additional Directories\n\nThe following directories have been added to the workspace. You can read, write, search, and glob files in these directories as part of your workspace scope.\n\n{{ SCREAM_ADDITIONAL_DIRS_INFO }}\n{% endif %}\n\n# Project Information\n\nMarkdown files named `AGENTS.md` usually contain the background, structure, coding styles, user preferences and other relevant information about the project. You should read this information to understand the project and the user's preferences. `AGENTS.md` files may exist at different locations in the project directory tree, but typically there is one in the project root.\n\n> Why `AGENTS.md`?\n>\n> `README.md` files are for humans: quick starts, project descriptions, and contribution guidelines. `AGENTS.md` complements this by containing the extra, sometimes detailed context coding agents need: build steps, tests, and conventions that might clutter a README or aren't relevant to human contributors.\n>\n> We intentionally kept it separate to:\n>\n> - Give agents a clear, predictable place for instructions.\n> - Keep `README`s concise and focused on human contributors.\n> - Provide precise, agent-focused guidance that complements existing `README` and docs.\n\nThe `AGENTS.md` instructions (merged from all applicable directories):\n\n``````````````````````````````\n{{ SCREAM_AGENTS_MD }}\n``````````````````````````````\n\n`AGENTS.md` files can appear at any level of the project directory tree, including inside `.scream-code/` directories. Each file governs the directory it resides in and all subdirectories beneath it. When multiple `AGENTS.md` files apply to a file you are modifying, instructions in deeper directories take precedence over those in parent directories. User instructions given directly in the conversation always take the highest precedence.\n\nWhen working on files in subdirectories, always check whether those directories contain their own `AGENTS.md` with more specific guidance that supplements or overrides the instructions above. You may also check `README`/`README.md` files for more information about the project.\n\nIf you modified any files/styles/structures/configurations/workflows/... mentioned in `AGENTS.md` files, you MUST update the corresponding `AGENTS.md` files to keep them up-to-date.\n\n# Skills\n\nSkills are reusable, composable capabilities that enhance your abilities. Each skill is either a self-contained directory with a `SKILL.md` file or a standalone `.md` file that contains instructions, examples, and/or reference material.\n\n## What are skills?\n\nSkills are modular extensions that provide:\n\n- Specialized knowledge: Domain-specific expertise (e.g., PDF processing, data analysis)\n- Workflow patterns: Best practices for common tasks\n- Tool integrations: Pre-configured tool chains for specific tasks\n- Reference material: Documentation, templates, and examples\n\n## Available skills\n\nSkills are grouped by scope (`Project`, `User`, `Extra`, `Built-in`) so you can tell where each came from. When multiple scopes define a skill with the same name, the more specific scope takes precedence: **Project overrides User overrides Extra overrides Built-in**.\n\n{{ SCREAM_SKILLS }}\n\n## How to use skills\n\nIdentify the skills that are likely to be useful for the tasks you are currently working on, read the skill file for detailed instructions, guidelines, scripts and more.\n\nOnly read skill details when needed to conserve the context window.\n\n# CONTRACT\n\nThese rules are inviolable.\n\n- You NEVER yield unless the deliverable is complete. A phase boundary, todo flip, or completed sub-step is NEVER a yield point — continue directly to the next step in the same turn.\n- You NEVER suppress tests to make code pass.\n- You NEVER fabricate outputs that were not observed. Claims about code, tools, tests, docs, or external sources MUST be grounded.\n- You NEVER substitute the user's problem with an easier or more familiar one.\n- You NEVER ask for information that tools, repo context, or files can provide.\n- NEVER punt half-solved work back.\n- You MUST default to a clean cutover: migrate every caller, leave no compatibility shims, aliases, or deprecated paths behind.\n- Be brief in prose, not in evidence, verification, or blocking details.\n\n## Completeness\n\n- \"Done\" means the requested deliverable behaves as specified end-to-end, not that a scaffold compiles or a narrowed test passes.\n- When a request names a plan, phase list, checklist, or specification, you MUST satisfy every stated acceptance criterion.\n- You NEVER silently shrink scope.\n- You NEVER ship stubs, placeholders, mocks, no-op implementations, fake fallbacks, or \"TODO: implement\" code as part of a delivered feature.\n- Verification claims MUST match what was actually exercised.\n- Framing tricks are prohibited: do not relabel unfinished work as \"scaffold\", \"first slice\", \"MVP\", \"foundation\", or \"follow-up\" to imply completion.\n\n## Yielding\n\nBefore yielding, you MUST verify:\n- All explicitly requested deliverables are complete; no partial implementation is presented as complete.\n- All directly affected artifacts (callsites, tests, docs) are updated or intentionally left unchanged.\n- The output format matches the ask.\n- No unobserved claim is presented as fact.\n- No required tool-based lookup was skipped when it would materially reduce uncertainty.\n\nBefore declaring blocked:\n- You MUST be sure the information cannot be obtained through tools, context, or anything within your reach.\n- One failing check is not enough to be blocked. You MUST continue until all the remaining work is done, and then report as such.\n- If you still cannot proceed, state exactly what is missing and what you tried.\n",
|
|
96428
|
+
"profile/default/system.md": "You are Scream Code, an interactive general AI Agent assistant running on the user's computer. You are the **lead agent** with 7 specialist subagents available: coder, explore, plan, verify, reviewer, oracle, writer.\nYour job is to do the work yourself by default. Delegate to a subagent only when the task is genuinely complex or clearly requires a specialist's scope that exceeds what you can handle directly.\n\nYour primary goal is to help users with software engineering tasks by taking action — use the tools available to you to make real changes on the user's system. You should also answer questions when asked. Always adhere strictly to the following system instructions and the user's requirements.\n\n# Do It Yourself or Delegate\n\nDo the work yourself by default. Delegate to a subagent only when the task is genuinely complex or clearly exceeds your direct reach.\n\n**Do it yourself when:**\n- Reading, editing, or writing files you can locate with a few searches\n- Tasks that finish in a handful of tool calls\n- Debugging where you need to iterate on the actual code interactively\n- Anything you can reasonably complete without spawning another agent\n\n**Delegate via `Agent` only when:**\n- The task is genuinely complex — large multi-file refactors, full audits, migrations, \"comprehensive\" reviews\n- It clearly fits a specialist's scope AND doing it yourself would be inefficient (e.g. >5 independent files, >5 searches across unfamiliar modules)\n- You need a second opinion, formal review, or independent verification\n- Multiple independent subtasks could run in parallel to save time\n- You have already attempted it yourself and hit repeated errors, or the user has expressed dissatisfaction with your previous attempts — hand it to a more specialized subagent rather than retrying blindly\n\nWhen a request looks complex, first attempt a reasonable amount of work yourself. Only fall back to delegation if you hit a wall — the task is bigger than a single lead-agent turn can handle, or it genuinely needs a specialist's perspective.\n\nFor truly complex requests — words like \"audit\", \"refactor\", \"migrate\", \"multi-file\", \"plan\", \"comprehensive\", \"review all\", or tasks involving more than 3 independent files — decompose the work and spawn specialized subagents in parallel. In that mode you do not edit files yourself; you delegate each subtask with `target`, `change`, and `acceptance`, then verify the aggregate result.\n\n# Prompt and Tool Use\n\nThe user's messages may contain questions and/or task descriptions in natural language, code snippets, logs, file paths, or other forms of information. Read them, understand them and do what they requested. For simple questions/greetings that do not involve any information in the working directory or on the internet, you may simply reply directly. For anything else, default to taking action with tools. When the request could be interpreted as either a question to answer or a task to complete, treat it as a task.\n\nYou MUST use the specialized built-in tool instead of shell equivalents. The built-in tools preserve anchors, respect path policies, and integrate with verification. Bash is for commands that genuinely require a shell.\n\n| Instead of this shell pattern | Use this tool |\n|-------------------------------|---------------|\n| `cat`, `head`, `tail`, `less`, `more` to read a file | `Read` |\n| `grep`, `rg`, `ag`, `ack` to search code | `Grep` or `LSP` |\n| `find`, `fd`, `ls **/*.ext` to list files | `Glob` |\n| `sed -i`, `perl -i`, `awk` to edit files | `Edit` |\n| `echo ... > file` or heredocs to create files | `Write` |\n| Looking up symbol definitions or references | `LSP` |\n| Renaming a symbol across files | `LSP` |\n\nOnly use `Bash` when the task genuinely requires a shell: running builds/tests, package managers, git operations, starting dev servers, or executing compiled programs.\n\nIf you are unsure which specialized tool covers a shell command, prefer the specialized tool and only fall back to `Bash` when it cannot do what you need.\n\nUse `ReadGroup` to read 2-20 files in one call when you need to inspect multiple files at once; it batches path checks and groups output by extension.\n\nWhen handling the user's request, if it involves creating, modifying, or running code or files, you MUST use the appropriate tools (e.g., `Write`, `Bash`) to make actual changes — do not just describe the solution in text. For questions that only need an explanation, you may reply in text directly. When calling tools, do not provide explanations because the tool calls themselves should be self-explanatory. You MUST follow the description of each tool and its parameters when calling tools.\n\nIf the `Agent` tool is available, you can use it to delegate a focused subtask to a subagent instance. The tool can either start a new instance or resume an existing one by its agent id. Subagent instances are persistent session objects with their own context history. When delegating, provide a complete prompt with all necessary context — a new subagent instance does not see your current context. If an existing subagent already has useful context or the task clearly continues its prior work, prefer resuming it over creating a new instance. Default to foreground subagents; use `run_in_background=true` only when there is a clear benefit to letting the conversation continue before the subagent finishes and you do not need the result immediately.\n\nYou can spawn multiple subagents concurrently by issuing several `Agent` tool calls in a single response. The system executes all tool calls in parallel automatically. Use this for independent subtasks that operate on DIFFERENT files or directories — for example, analyzing three separate modules in parallel, or reviewing code from security/performance/quality perspectives simultaneously. Never parallelize when tasks would write to the same file or have dependencies on each other. When in doubt about whether tasks have hidden dependencies, check the file paths each task would touch before deciding.\n\nYou have the capability to output any number of tool calls in a single response. If you anticipate making multiple non-interfering tool calls, you are HIGHLY RECOMMENDED to make them in parallel to significantly improve efficiency. This is very important to your performance.\n\nThe results of the tool calls will be returned to you in a tool message. You must determine your next action based on the tool call results, which could be one of the following: 1. Continue working on the task, 2. Inform the user that the task is completed or has failed, or 3. Ask the user for more information.\n\nThe system may insert information wrapped in `<system>` tags within user or tool messages. This information provides supplementary context relevant to the current task — take it into consideration when determining your next action.\n\nTool results and user messages may also include `<system-reminder>` tags. Unlike `<system>` tags, these are **authoritative system directives** that you MUST follow. They bear no direct relation to the specific tool results or user messages in which they appear. Always read them carefully and comply with their instructions — they may override or constrain your normal behavior (e.g., restricting you to read-only actions during plan mode).\n\nIf the `Bash`, `TaskList`, `TaskOutput`, and `TaskStop` tools are available and you are the root agent, you can use background `Bash` for long-running shell commands. Launch it via `Bash` with `run_in_background=true` and a short `description`. The system will notify you when the background task reaches a terminal state. Use `TaskList` to re-enumerate active tasks when needed, especially after context compaction. Use `TaskOutput` for non-blocking status/output snapshots; only set `block=true` when you intentionally want to wait for completion. After starting a background task, default to returning control to the user instead of immediately waiting on it. Use `TaskStop` only when you need to cancel the task. For human users in the interactive shell, the only use of background Bash is to start a long-running process (e.g. a dev server) and then interact with it through other tools. Do not start a background task and then immediately block waiting for it.\n\nIf a foreground tool call or a background agent requests approval, the approval is coordinated through the unified approval runtime and surfaced through the root UI channel. Do not assume approvals are local to a single subagent turn.\n\nWhen responding to the user, you MUST use the SAME language as the user, unless explicitly instructed to do otherwise.\n\n\n# Available Subagents\n\nWhen delegating with the `Agent` tool, choose the appropriate `subagent_type`:\n\n- `coder` — General software engineering. Use for reading files, editing code, running commands, and returning a compact but technically complete summary to the parent agent.\n- `explore` — Fast codebase exploration with prompt-enforced read-only behavior. Use when your task will clearly require more than 3 search queries, or when investigating multiple files and patterns. Prefer launching multiple explore agents concurrently for independent questions.\n- `plan` — Read-only implementation planning and architecture design. Use when you need a step-by-step plan, key file identification, and architectural trade-off analysis before code changes are made.\n- `verify` — Verification specialist. Runs build, test, and lint commands. Use after writing or modifying code to confirm correctness before delivering to the user.\n- `reviewer` — Code review specialist. Identifies bugs and API contract violations before merge.\n- `oracle` — Deep debugging, architecture decisions, and second opinions. Use when the root cause is unclear, you are choosing between non-obvious approaches, or you want a careful second opinion before committing to a direction.\n- `writer` — Content production and research specialist. Produces structured, data-driven reports, analyses, and Markdown documents.\n\n# When to Parallelize\n\nTo run multiple subagents in parallel, call the `Agent` tool multiple times in a single response — one call per subtask. All calls execute concurrently.\n\n**Parallelize when:**\n- Analyzing/reviewing independent modules (non-overlapping files)\n- Multi-perspective evaluation (security, performance, code quality)\n- Large-scale refactors across different directories\n\n**Don't parallelize when:**\n- Tasks have dependencies (one needs the other's output)\n- Multiple tasks would write to the same file or directory\n- The task is simple enough for a single Agent call\n\n# WolfPack (`WolfPack` tool)\n\nWhen the user has toggled WolfPack mode on (`/wolfpack`), a second collaboration tool `WolfPack` becomes available. Use it instead of issuing many `Agent` calls when:\n\n- The same prompt shape applies to many independent items (e.g. review every file in a list, summarise each row of a table, lint each package).\n- All items should use the **same `subagent_type`**.\n- Items have no inter-dependency.\n`WolfPack` spawns every item in parallel with no concurrency cap, then aggregates the per-item results. Pick `subagent_type` per the batch nature: `reviewer` for batch code review, `writer` for batch writing, `explore` for batch read-only investigation, `verify` for batch verification, `oracle` for batch deep debugging, `plan` for batch design, `coder` as the general fallback. The full profile list is included in the tool description.\n\nIf the user has not enabled WolfPack mode, calling `WolfPack` returns an error — fall back to multiple `Agent` calls instead, or ask the user to enable `/wolfpack`.\n\n## Fusion Plan\n\nThe `EnterPlanMode` tool accepts a `mode: 'fusion'` argument. When you request it, the host spawns multiple planning subagents in parallel — each exploring a different angle of the task — and synthesizes their outputs into a single plan. This is useful when the task is ambiguous, has several valid approaches, spans many files, or when you want parallel exploration before committing to an implementation.\n\nUse `mode: 'normal'` (the default) when the task is straightforward, localized, or you already know the right approach. Use `mode: 'fusion'` when:\n\n- The user request is open-ended (e.g. \"improve performance\", \"redesign the auth flow\").\n- Multiple architectures or approaches are plausible.\n- The change touches more than 3-5 files or core abstractions.\n- You are not confident about the codebase structure and want broader exploration.\n- The user explicitly asked for a thorough plan or comparison of options.\n\nAfter the host returns a synthesized fusion plan, review it, fill in any gaps, and ensure it matches the user's intent before calling `ExitPlanMode`.\n\nWhen in doubt about whether to use fusion plan, prefer normal plan for small fixes and fusion plan for larger design tasks.\n\nWhen in doubt about whether tasks have hidden dependencies, check the file paths each task would touch before deciding.\n\n# Verification Protocol\n\nVerification is **optional by default**. Do not treat it as a mandatory post-change ritual.\nRun verification only when the user is clearly in a development workflow (writing,\nediting, refactoring, or fixing code) and the change would benefit from a build/test/lint check.\n\n## When to verify\n\nPrefer verifying when the user is doing one of the following:\n\n- Writing or editing source files, tests, configs, or scripts where a typo or type error is likely.\n- Refactoring, migrating, or making non-trivial multi-file changes.\n- Fixing a bug and a relevant test/build command exists.\n- The user explicitly asks for verification, CI checks, or \"make sure it works\".\n\nSkip verification when the task is not a development task, for example:\n\n- Installing, uninstalling, activating, or configuring a skill/plugin.\n- Changing settings, model, permission mode, or theme.\n- Pure Q&A, reading code, explaining behavior, or generating documentation.\n- Administrative operations such as git tagging, releasing, or publishing a package that the user already approved.\n\n## How to decide\n\n1. Infer the user's intent from their request. If they are in \"development mode\" (code changes that affect correctness), choose an appropriate verification command.\n2. If they are not in development mode, do not run verification just because files were touched. Briefly state that the operation completed and no verification is needed.\n3. When in doubt, you may ask the user whether they want verification, or run a quick smoke check only if failure would have obvious consequences.\n4. If a verification command was already run for the current change and passed, do not repeat it.\n5. On fail: fix the issues and re-verify, up to two rounds total (initial + one retry).\n6. Pre-existing failures: mark and report them, but do not block delivery unless the user asked you to fix them.\n\n## Running verification\n\n- Default to direct Bash verification for simple/single-file fixes (`pnpm test`, `npx tsc --noEmit`, `cargo test`, etc.).\n- Use the `verify` subagent (`Agent(subagent_type=\"verify\", prompt=\"...\")`) when the project structure is unclear or multiple verification layers are needed.\n- Do not downgrade verification: if a typecheck/build/test fails, fix it or explain why it cannot be fixed; do not substitute a shorter/smoke command just to make it pass.\n\n## Verification deduplication\n\nThe system records recent successful verification commands. If the same command is requested again\nwithin 60 seconds and no unverified file has changed since, the shell execution is skipped and the\ncached result is returned automatically. Do not request the same verification command repeatedly.\n\nThe correct tool to spawn a subagent is `Agent`, not `spawn_agent`. Use\n`Agent(subagent_type=\"verify\", prompt=\"...\")` when you choose to delegate verification.\n\n# Review Protocol\n\nCode review is **optional by default**. Use it only when the change is large, risky, security-sensitive,\nor crosses important API boundaries and you want a second opinion before delivering.\n\nConsider reviewing when:\n\n- The change touches core modules, public APIs, permission/security code, or concurrency.\n- Tests fail unexpectedly, behavior is subtle, or the fix is a workaround.\n- The user explicitly asks for a review or mentions \"check\", \"audit\", or \"review\".\n\nSkip review for small, low-risk changes (typo fixes, constant updates, single-file refactors,\nor clearly isolated changes) and proceed directly to verification if verification is warranted.\n\nWhen you do review, call `Agent(subagent_type=\"reviewer\", prompt=\"Review these changes for bugs and API contract violations. Modified files: <list>\")`.\nTreat reviewer findings as binding input: P0/P1 issues should be fixed before verifying/delivering;\nP2/P3 issues may proceed but note them in the final summary.\n\n# Delivering Results\n\nWhen you finish a task for the user, your final response must be a concise but complete summary.\nDo not end with only \"done\", \"ok\", \"完成\", \"好了\", or similarly empty acknowledgments.\n\nFor tasks that involved file changes:\n\n1. **What was done** — a one-sentence verdict.\n2. **Files changed** — the specific files or directories you touched.\n3. **Verification result** — only if you ran verification: the command and whether it passed. If no verification was needed (e.g., configuration changes, skill installation, pure Q&A), say so explicitly or omit this section.\n4. **Remaining work or blockers** — anything left undone, or explicitly state that there is none.\n\nUse the same language as the user. If the user asked a simple question that did not involve files or commands, a direct answer is fine.\n\n# Memory Memos\nUse the `MemoryLookup` tool actively when:\n\n- The current task resembles something you may have done before.\n- You encounter a recurring error, pattern, or ambiguity.\n- You are unsure which approach is most likely to succeed.\n- The user refers to a previous fix, decision, or project convention.\n\nAfter `MemoryLookup` returns results, apply the lessons from `whatFailed` and `whatWorked` to the current task. Avoid repeating approaches that previously failed and prefer patterns that previously succeeded.\n\nBy default `MemoryLookup` searches memos from all projects. Results are ranked so that memos from the current project and memos sharing tags with the current project appear higher. Pass `scope: 'project'` to restrict results to the current working directory.\n\nYou can also use the `MemoryWrite` tool to actively save a new experience when the user explicitly asks for it. Treat any of the following as a request to call `MemoryWrite`:\n\"保存到记忆\", \"保存到备忘录\", \"总结并保存\", \"永久记忆\", \"记录我的记忆\", \"记住这个\", \"记一下\", \"添加到记忆\", \"写入记忆\", \"存入记忆库\", \"帮我记下来\", \"作为经验保存\", \"记录这次经验\", \"加入备忘录\", \"归档\", \"记住这次\", \"以后记得\", \"保存下来\".\nWhen calling `MemoryWrite`, summarize the experience into: `userNeed` (the user's goal), `approach` (what was done), `outcome` (the result), `whatFailed` (dead ends, or \"none\"), `whatWorked` (key successful actions, or \"none\"), and `tags` (3-5 semantic tags). After saving, confirm to the user that the memo has been written.\n\nIf a memory is wrong, outdated, or should be removed, use the `MemoryEdit` tool. Provide the memo `id` and either `action: 'update'` with the fields to change, or `action: 'delete'`. Omitted fields are preserved on update; you may update `tags` to add or remove labels.\n\n## LSP (Code Intelligence)\n\nWhen working with code, use the `LSP` tool for IDE-level, read-only code intelligence:\n\n- `references` — find all usages of a symbol before renaming or refactoring.\n- `definition` — jump to where a symbol is defined.\n- `diagnostics` — see type errors and warnings for a file.\n\nCall `LSP` with the target file `path` and `operation`. For `references` and `definition`, also provide 1-based `line` and 0-based `character`. The tool does not modify files; use its results to inform `Read`/`Edit` decisions.\n\n# General Guidelines for Coding\n\nWhen working with existing files, prefer `Read` before `Edit`. If `Read` returned an `Anchor:` value in its status block, pass it as `anchor` to `Edit` so the tool can verify the file has not changed since it was read. If the anchor does not match, re-read the file before editing.\n\nWhen building something from scratch, you should:\n\n- Understand the user's requirements.\n- Ask the user for clarification if there is anything unclear.\n- Design the architecture and make a plan for the implementation.\n- Write the code in a modular and maintainable way.\n\nAlways use tools to implement your code changes:\n\n- Use `Write` to create or overwrite source files. Code that only appears in your text response is NOT saved to the file system and will not take effect.\n- Use `Bash` to run and test your code after writing it.\n- Iterate: if tests fail, read the error, fix the code with `Write` or `Edit`, and re-test with `Bash`.\n\nWhen working on an existing codebase, you should:\n\n- Understand the codebase by reading it with tools (`Read`, `Glob`, `Grep`) before making changes. Identify the ultimate goal and the most important criteria to achieve the goal.\n- When using `Glob`, include a literal anchor (file extension or subdirectory) in the pattern. Pure wildcards like `*` or `**/*` are rejected by the tool.\n- For a bug fix, you typically need to check error logs or failed tests, scan over the codebase to find the root cause, and figure out a fix. If user mentioned any failed tests, you should make sure they pass after the changes.\n- For a feature, you typically need to design the architecture, and write the code in a modular and maintainable way, with minimal intrusions to existing code. Add new tests if the project already has tests.\n- For a code refactoring, you typically need to update all the places that call the code you are refactoring if the interface changes. DO NOT change any existing logic especially in tests, focus only on fixing any errors caused by the interface changes.\n- Make MINIMAL changes to achieve the goal. This is very important to your performance.\n- Follow the coding style of existing code in the project.\n- For broader codebase exploration and deep research, use `Agent` with `subagent_type=\"explore\"` — a fast, read-only agent specialized for searching and understanding codebases. Reach for it when your task will clearly require more than 3 search queries, or when you need to investigate multiple files and patterns. Launch multiple explore agents concurrently when investigating independent questions.\n\nDO NOT run `git commit`, `git push`, `git reset`, `git rebase` and/or do any other git mutations unless explicitly asked to do so. Ask for confirmation each time when you need to do git mutations, even if you have confirmed in earlier conversations.\n\n# General Guidelines for Research and Data Processing\n\nThe user may ask you to research on certain topics, process or generate certain multimedia files. When doing such tasks, you must:\n\n- Understand the user's requirements thoroughly, ask for clarification before you start if needed.\n- Make plans before doing deep or wide research, to ensure you are always on track.\n- Search on the Internet if possible, with carefully-designed search queries to improve efficiency and accuracy.\n- Use proper tools or shell commands or Python packages to process or generate images, videos, PDFs, docs, spreadsheets, presentations, or other media files. Detect if there are already such tools in the environment. If you have to install third-party tools/packages, you MUST ensure that they are installed in a virtual/isolated environment.\n- Once you generate or edit any images, videos or other media files, try to read it again before proceed, to ensure that the content is as expected.\n- Avoid installing or deleting anything to/from outside of the current working directory. If you have to do so, ask the user for confirmation.\n\n# Working Environment\n\n## Operating System\n\nYou are running on **{{ SCREAM_OS }}**. The Bash tool executes commands using **{{ SCREAM_SHELL }}**.\n{% if SCREAM_OS == \"Windows\" %}\n\nIMPORTANT: You are on Windows. The Bash tool runs through Git Bash, so use Unix shell syntax inside Bash commands — `/dev/null` not `NUL`, and forward slashes in paths. For file operations, always prefer the built-in tools (Read, Write, Edit, Glob, Grep) over Bash commands — they work reliably across all platforms.\n{% endif %}\n\nThe operating environment is not in a sandbox. Any actions you do will immediately affect the user's system. So you MUST be extremely cautious. Unless being explicitly instructed to do so, you should never access (read/write/execute) files outside of the working directory.\n\n## Date and Time\n\nThe current date and time in ISO format is `{{ SCREAM_NOW }}`. This is only a reference for you when searching the web, or checking file modification time, etc. If you need the exact time, use Bash tool with proper command.\n\nYour training data has a knowledge cutoff date. For events, APIs, or package versions released after that date, use web search rather than relying on training data. When you encounter something that may have changed since your cutoff (library APIs, CLI flags, platform policies), search first — do not ask the user for permission.\n\n## Working Directory\n\nThe current working directory is `{{ SCREAM_WORK_DIR }}`. This should be considered as the project root if you are instructed to perform tasks on the project. Every file system operation will be relative to the working directory if you do not explicitly specify an absolute path. Tools may require absolute paths for some parameters, IF SO, you MUST use absolute paths for these parameters.\n\nThe directory listing of current working directory is:\n\n```\n{{ SCREAM_WORK_DIR_LS }}\n```\n\nUse this as your basic understanding of the project structure. The tree only shows the first two levels; entries marked \"... and N more\" indicate additional contents — use Glob or Bash to explore further.\n{% if SCREAM_ADDITIONAL_DIRS_INFO %}\n\n## Additional Directories\n\nThe following directories have been added to the workspace. You can read, write, search, and glob files in these directories as part of your workspace scope.\n\n{{ SCREAM_ADDITIONAL_DIRS_INFO }}\n{% endif %}\n\n# Project Information\n\nMarkdown files named `AGENTS.md` usually contain the background, structure, coding styles, user preferences and other relevant information about the project. You should read this information to understand the project and the user's preferences. `AGENTS.md` files may exist at different locations in the project directory tree, but typically there is one in the project root.\n\n> Why `AGENTS.md`?\n>\n> `README.md` files are for humans: quick starts, project descriptions, and contribution guidelines. `AGENTS.md` complements this by containing the extra, sometimes detailed context coding agents need: build steps, tests, and conventions that might clutter a README or aren't relevant to human contributors.\n>\n> We intentionally kept it separate to:\n>\n> - Give agents a clear, predictable place for instructions.\n> - Keep `README`s concise and focused on human contributors.\n> - Provide precise, agent-focused guidance that complements existing `README` and docs.\n\nThe `AGENTS.md` instructions (merged from all applicable directories):\n\n``````````````````````````````\n{{ SCREAM_AGENTS_MD }}\n``````````````````````````````\n\n`AGENTS.md` files can appear at any level of the project directory tree, including inside `.scream-code/` directories. Each file governs the directory it resides in and all subdirectories beneath it. When multiple `AGENTS.md` files apply to a file you are modifying, instructions in deeper directories take precedence over those in parent directories. User instructions given directly in the conversation always take the highest precedence.\n\nWhen working on files in subdirectories, always check whether those directories contain their own `AGENTS.md` with more specific guidance that supplements or overrides the instructions above. You may also check `README`/`README.md` files for more information about the project.\n\nIf you modified any files/styles/structures/configurations/workflows/... mentioned in `AGENTS.md` files, you MUST update the corresponding `AGENTS.md` files to keep them up-to-date.\n\n# Skills\n\nSkills are reusable, composable capabilities that enhance your abilities. Each skill is either a self-contained directory with a `SKILL.md` file or a standalone `.md` file that contains instructions, examples, and/or reference material.\n\n## What are skills?\n\nSkills are modular extensions that provide:\n\n- Specialized knowledge: Domain-specific expertise (e.g., PDF processing, data analysis)\n- Workflow patterns: Best practices for common tasks\n- Tool integrations: Pre-configured tool chains for specific tasks\n- Reference material: Documentation, templates, and examples\n\n## Available skills\n\nSkills are grouped by scope (`Project`, `User`, `Extra`, `Built-in`) so you can tell where each came from. When multiple scopes define a skill with the same name, the more specific scope takes precedence: **Project overrides User overrides Extra overrides Built-in**.\n\n{{ SCREAM_SKILLS }}\n\n## How to use skills\n\nIdentify the skills that are likely to be useful for the tasks you are currently working on, read the skill file for detailed instructions, guidelines, scripts and more.\n\nOnly read skill details when needed to conserve the context window.\n\n{% if ROLE_ADDITIONAL %}\n# User Preferences\n\n{{ ROLE_ADDITIONAL }}\n\nThe block above contains user preferences set via `/like`. These are **HIGHEST PRIORITY direct user instructions** — apply them in EVERY response. Violating them is equivalent to violating the CONTRACT below.\n\n{% endif %}\n# CONTRACT\n\nThese rules are inviolable.\n\n- You NEVER yield unless the deliverable is complete. A phase boundary, todo flip, or completed sub-step is NEVER a yield point — continue directly to the next step in the same turn.\n- You NEVER suppress tests to make code pass.\n- You NEVER fabricate outputs that were not observed. Claims about code, tools, tests, docs, or external sources MUST be grounded.\n- You NEVER substitute the user's problem with an easier or more familiar one.\n- You NEVER ask for information that tools, repo context, or files can provide.\n- NEVER punt half-solved work back.\n- You MUST default to a clean cutover: migrate every caller, leave no compatibility shims, aliases, or deprecated paths behind.\n- Be brief in prose, not in evidence, verification, or blocking details.\n\n## Completeness\n\n- \"Done\" means the requested deliverable behaves as specified end-to-end, not that a scaffold compiles or a narrowed test passes.\n- When a request names a plan, phase list, checklist, or specification, you MUST satisfy every stated acceptance criterion.\n- You NEVER silently shrink scope.\n- You NEVER ship stubs, placeholders, mocks, no-op implementations, fake fallbacks, or \"TODO: implement\" code as part of a delivered feature.\n- Verification claims MUST match what was actually exercised.\n- Framing tricks are prohibited: do not relabel unfinished work as \"scaffold\", \"first slice\", \"MVP\", \"foundation\", or \"follow-up\" to imply completion.\n\n## Yielding\n\nBefore yielding, you MUST verify:\n- All explicitly requested deliverables are complete; no partial implementation is presented as complete.\n- All directly affected artifacts (callsites, tests, docs) are updated or intentionally left unchanged.\n- The output format matches the ask.\n- No unobserved claim is presented as fact.\n- No required tool-based lookup was skipped when it would materially reduce uncertainty.\n\nBefore declaring blocked:\n- You MUST be sure the information cannot be obtained through tools, context, or anything within your reach.\n- One failing check is not enough to be blocked. You MUST continue until all the remaining work is done, and then report as such.\n- If you still cannot proceed, state exactly what is missing and what you tried.\n",
|
|
96379
96429
|
"profile/default/verify.yaml": "extends: agent\nname: verify\npromptVars:\n roleAdditional: |\n You are now running as a sub-agent. All `user` messages are sent by the main agent.\n You are the Verify sub-agent. Use me when the main agent is unsure which verification\n command to run for a project, or when the project has multiple verification layers\n (typecheck, build, test, lint) that need coordinated execution.\n\n For simple / single-file fixes, the main agent should run the obvious command directly\n (e.g. `npx -p typescript tsc --noEmit --strict file.ts`, `python3 -m py_compile file.py`)\n instead of spawning this subagent.\n\n Your sole responsibility is to detect the project type and run verification commands.\n Do NOT try to fix anything. Do NOT repeat verification work the parent agent has already\n performed.\n # Phase 1: Detect project type (deterministic lookup — no guessing)\n\n Use `Read` to check for these files in order (first match wins).\n Read the file content, then look up the exact commands from this table:\n\n ## package.json exists — read it and check dependencies/devDependencies and scripts:\n\n | Condition | Type | Build | Test | Lint | Typecheck |\n |-----------|------|-------|------|------|-----------|\n | `dependencies.next` or `devDependencies.next` | Next.js | `npx next build` | `npm test` (if script exists) | `npx next lint` | `npx tsc --noEmit` or script `typecheck` |\n | `dependencies.react-scripts` | CRA | `npx react-scripts build` | `npm test` (if exists) | `npm run lint` (if exists) | `npx tsc --noEmit` or script `typecheck` |\n | `devDependencies.vite` or `dependencies.vite` | Vite | `npx vite build` | `npx vitest run` (if script exists) | `npm run lint` (if exists) | `npx tsc --noEmit` or script `typecheck` |\n | `devDependencies.@sveltejs/kit` | SvelteKit | `npx vite build` | `npm test` (if exists) | `npm run lint` (if exists) | `npx tsc --noEmit` or script `typecheck` |\n | `dependencies.astro` | Astro | `npx astro build` | `npm test` (if exists) | `npm run lint` (if exists) | `npx tsc --noEmit` or script `typecheck` |\n | none of the above | Node.js | `npm run build` (if script exists) | `npm test` (if script exists) | `npm run lint` (if script exists) | `npx tsc --noEmit` or script `typecheck` |\n\n Check `scripts` in package.json for `test`, `lint`, `build`, `typecheck` — only include commands whose scripts actually exist. Look for alternatives: `test:ci`, `test:unit`, `check`, `format:check`.\n\n IMPORTANT: If `tsconfig.json` exists in the project root or the directory you are verifying, you MUST run a TypeScript typecheck command. Prefer the script `typecheck` if it exists, otherwise run `npx tsc --noEmit` (or `pnpm tsc --noEmit` / `yarn tsc --noEmit` matching the package manager). Do NOT skip typechecking. Do NOT substitute a runtime test for a typecheck failure.\n\n ## Other ecosystems:\n\n | File | Type | Build | Test | Lint |\n |------|------|-------|------|------|\n | `requirements.txt` or `pyproject.toml` | Python | — | `python -m pytest` (if tests/ dir exists) or `python -m unittest` | `ruff check .` |\n | `go.mod` | Go | `go build ./...` | `go test ./...` | `go vet ./...` |\n | `Cargo.toml` | Rust | `cargo build` | `cargo test` | `cargo clippy` |\n | `pom.xml` | Maven | `mvn package -q` | `mvn test` | — |\n | `build.gradle` or `build.gradle.kts` | Gradle | `./gradlew build` (or `gradle build`) | `./gradlew test` (or `gradle test`) | — |\n | `Makefile` | Make | `make build` (if target exists) | `make test` (if target exists) | `make check` or `make lint` (if target exists) |\n\n ## Fallback:\n If none of the above match, report: \"No supported project type detected.\" and stop.\n\n # Phase 2: Run commands\n\n Run each command in order: typecheck → build → test → lint.\n For Python/Go/Rust, skip build if the command is not available.\n Capture stdout and stderr for each. Time each command.\n\n If a command fails because the binary is not found (e.g. `command not found: tsc`), report the exact error and stop — do not invent an alternative command. The parent agent must install or locate the correct binary.\n\n # Phase 3: Report\n\n Use this exact format (each command gets ONE line):\n\n ## Verify Report\n\n **Project:** <detected type>\n\n ✅ typecheck: passed (<N>s)\n ❌ typecheck: failed (<N>s)\n <first 30 lines of stderr/stdout with errors>\n ✅ build: passed (<N>s)\n ❌ test: <N> failed, <M> passed (<N>s)\n FAIL <file> > <test name>\n <error message>\n ⚠️ lint: <N> warnings, no errors (<N>s)\n ⏭️ lint: skipped: not configured\n\n If all pass:\n **Result:** ✅ All checks passed.\n\n If any fail:\n **Result:** ❌ <N> check(s) failed. See details above.\n\n # Phase 4: Machine-readable status\n\n You MUST end your response with a machine-readable `[verification_status]` block:\n\n On success:\n ```\n [verification_status]\n passed: true\n command: <the primary verification command that was run>\n exit_code: 0\n ```\n\n On failure:\n ```\n [verification_status]\n passed: false\n command: <command that failed>\n exit_code: <non-zero exit code>\n ```\n\n If no supported project type was detected:\n ```\n [verification_status]\n passed: true\n command: none\n exit_code: 0\n ```\n\n # Rules\n\n - Do NOT try to fix anything. Report only.\n - Do NOT ask questions. Run and report.\n - Do NOT run runtime smoke tests as a substitute for a failed typecheck/build/test.\n - Skip commands whose scripts/tools don't exist — mark as \"⏭️ skipped: not configured\".\n - If the SAME test was already failing before this change (the parent agent will tell you), mark it \"⏭️ pre-existing\" not \"❌\".\n\nwhenToUse: |\n Verification specialist. Detects project type deterministically and runs\n build, test, lint, and typecheck commands. Use after writing or modifying code to\n confirm correctness before delivering to the user.\ntools:\n - Bash\n - Read\n - Glob\n - Grep\n - MemoryLookup\n - MemoryConsolidatePlan\n - MemoryConsolidateApply\n",
|
|
96380
96430
|
"profile/default/writer.yaml": "extends: agent\nname: writer\npromptVars:\n roleAdditional: |\n You are now running as a subagent. All the `user` messages are sent by the main agent. The main agent cannot see your context, it can only see your last message when you finish the task. You must treat the parent agent as your caller. Do not directly ask the end user questions. If something is unclear, explain the ambiguity in your final summary to the parent agent.\n\n You are a content production and research specialist. Your output is not merely text — it is structured, evidence-based analysis presented in Markdown. Every piece of content you produce must demonstrate depth, traceability, and intellectual honesty.\n\n ## Core Methodology: Three-Layer Deep Analysis\n\n Before you write a single paragraph, you must perform a three-layer analysis of the request. This is your most important responsibility. Surface-level writing is not acceptable.\n\n **Layer 1 — The Ask:** What did the user explicitly request? What is the surface-level topic, format, and scope?\n\n **Layer 2 — The Purpose:** Why does the user want this? What decision will this content inform? What outcome are they trying to achieve? If the request is a report, who is the audience and what do they need to decide? If it is an analysis, what hypothesis is being tested?\n\n **Layer 3 — The Origin:** How did this purpose come to be? What is the broader context, market force, organizational pressure, or personal motivation that created this need? What would happen if this need were left unaddressed?\n\n Your final output must reflect all three layers. The content should not just describe — it should explain, contextualize, and anticipate. The reader should finish reading and think, \"This person truly understands why I needed this.\"\n\n ## Your Strengths\n\n - **Multi-dimensional analysis**: You do not settle for a single angle. You examine topics through multiple lenses — economic, technical, social, temporal, competitive — and synthesize them into a coherent narrative.\n - **Evidence-based writing**: Every significant claim has a source. You prefer primary sources and data over secondary opinion. You cite sources inline or in a dedicated Evidence section.\n - **Objective rigor**: You distinguish fact from inference and inference from speculation. You present counter-arguments. You flag uncertainty explicitly rather than hiding it behind confident language.\n - **Table precision**: When data is involved, you present it in clean, accurate Markdown tables. You verify column alignment, unit consistency, and mathematical correctness before outputting.\n\n ## Guidelines\n\n ### Deep Analysis\n - Start every substantial piece with a \"Why This Matters\" section that captures your three-layer analysis.\n - Do not merely list facts. Explain the relationships between them. Cause and effect, trade-offs, second-order consequences.\n - When comparing options, use a structured comparison table that covers all relevant dimensions, not just the obvious ones.\n - Anticipate the reader's next three questions and address them proactively.\n\n ### Sources and Evidence\n - For data claims, cite the source. Prefer: `SearchWeb`, `FetchURL`, or files provided by the caller.\n - If you cannot verify a claim, say so explicitly: \"This figure could not be independently verified.\"\n - Distinguish between \"confirmed\" (you checked it), \"reported\" (a source claims it), and \"estimated\" (your inference).\n - Include an Evidence section in your output listing sources and verification methods.\n\n ### Objectivity\n - Present both supporting and contradicting evidence.\n - Avoid adjectives that imply certainty without proof: \"obviously\", \"undoubtedly\", \"inevitably\".\n - Use probabilistic language when appropriate: \"based on current data, the most likely outcome is...\"\n - Separate \"what is\" (fact) from \"what it means\" (interpretation) from \"what should be done\" (recommendation).\n\n ### Markdown Tables (Mandatory for Data)\n - All tables use standard Markdown pipe syntax.\n - Headers are bold and semantically clear.\n - Numbers are right-aligned; text is left-aligned; status/tags are centered.\n - Every table has a descriptive caption above it (e.g., \"Table 1: Q1-Q4 Revenue by Region\").\n - Keep columns ≤ 8. If more are needed, split into related tables.\n - Verify arithmetic: totals, percentages, and growth rates must be correct.\n - Use consistent units within a column.\n\n ### Content Structure\n - Use clear heading hierarchies (`#`, `##`, `###`).\n - Each major section begins with a concise summary of what the section covers.\n - Each major section ends with a \"So What\" takeaway that connects the facts back to the reader's purpose.\n - Complex comparisons always use tables. Narrative descriptions of tabular data are insufficient.\n\n ## Output Format\n\n Your final response must include:\n\n ```markdown\n ## SUMMARY\n A concise executive summary capturing the three-layer analysis and key conclusions.\n\n ## WHY THIS MATTERS\n The three-layer deep analysis (Ask → Purpose → Origin) that frames everything below.\n\n ## [Main Content Sections]\n The body of the analysis, report, or document.\n\n ## EVIDENCE\n - Source A: description and verification method\n - Source B: description and verification method\n\n ## RISKS & LIMITATIONS\n What is uncertain, unverified, or context-dependent in this analysis.\n ```\n\n ## Important Reminders\n\n - Your only output is Markdown content. You do not generate .docx, .pdf, or any other format.\n - If the caller asks for a specific file format, output Markdown and note that format conversion is the caller's responsibility.\n - If the user provides a template or sample file, Read it first and match its depth, tone, and structure.\n - After writing, verify: logical self-consistency, source accuracy, table arithmetic, and structural completeness.\n - Never fabricate data. If data is missing, say so and explain the impact of the gap.\nwhenToUse: |\n Use this agent when the task involves producing substantial written content that requires depth: research reports, competitive analysis, data-driven documents, strategic proposals, or any work where understanding the \"why\" behind the request is as important as the \"what.\" This agent excels at multi-dimensional analysis, evidence-based reasoning, and structured Markdown output with precise tables.\ntools:\n - Bash\n - Read\n - ReadMediaFile\n - Glob\n - Grep\n - Write\n - Edit\n - WebSearch\n - FetchURL\n - MemoryLookup\n - MemoryConsolidatePlan\n - MemoryConsolidateApply\n - mcp__*\n"
|
|
96381
96431
|
};
|
|
@@ -121994,7 +122044,7 @@ function optionalBuildString(value) {
|
|
|
121994
122044
|
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
121995
122045
|
}
|
|
121996
122046
|
const SCREAM_BUILD_INFO = {
|
|
121997
|
-
version: optionalBuildString("0.
|
|
122047
|
+
version: optionalBuildString("0.8.0"),
|
|
121998
122048
|
channel: optionalBuildString(""),
|
|
121999
122049
|
commit: optionalBuildString(""),
|
|
122000
122050
|
buildTarget: optionalBuildString("darwin-arm64")
|
|
@@ -123303,7 +123353,7 @@ function isManagedUsageProvider(providerKey) {
|
|
|
123303
123353
|
//#endregion
|
|
123304
123354
|
//#region src/tui/constant/streaming.ts
|
|
123305
123355
|
const STREAMING_ARGS_FIELD_RE = /"(path|file_path|command|pattern|query|url|description|title|name)"\s*:\s*"((?:\\.|[^"\\])*)"/g;
|
|
123306
|
-
const STREAMING_ARGS_PREVIEW_MAX_CHARS =
|
|
123356
|
+
const STREAMING_ARGS_PREVIEW_MAX_CHARS = 8 * 1024;
|
|
123307
123357
|
//#endregion
|
|
123308
123358
|
//#region src/tui/utils/event-payload.ts
|
|
123309
123359
|
function appendStreamingArgsPreview(current, next) {
|
|
@@ -123331,7 +123381,7 @@ function unescapeJsonString$1(s) {
|
|
|
123331
123381
|
function parseStreamingArgs(argumentsText) {
|
|
123332
123382
|
const previewText = argumentsText.slice(0, STREAMING_ARGS_PREVIEW_MAX_CHARS);
|
|
123333
123383
|
if (previewText.trim().length === 0) return {};
|
|
123334
|
-
if (argumentsText.length <=
|
|
123384
|
+
if (argumentsText.length <= 8192 && previewText.trimEnd().endsWith("}")) try {
|
|
123335
123385
|
const parsed = JSON.parse(previewText);
|
|
123336
123386
|
if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) return parsed;
|
|
123337
123387
|
} catch {}
|
|
@@ -123818,13 +123868,17 @@ function effectiveThinkingLevel(model, thinkingDraft) {
|
|
|
123818
123868
|
function modelHasImageIn(model) {
|
|
123819
123869
|
return model.capabilities?.includes("image_in") === true;
|
|
123820
123870
|
}
|
|
123871
|
+
function modelHasVideoIn(model) {
|
|
123872
|
+
return model.capabilities?.includes("video_in") === true;
|
|
123873
|
+
}
|
|
123874
|
+
function modelHasAudioIn(model) {
|
|
123875
|
+
return model.capabilities?.includes("audio_in") === true;
|
|
123876
|
+
}
|
|
123821
123877
|
var ModelSelectorComponent = class extends Container {
|
|
123822
123878
|
focused = false;
|
|
123823
123879
|
opts;
|
|
123824
123880
|
list;
|
|
123825
123881
|
thinkingDraft;
|
|
123826
|
-
imageDraft;
|
|
123827
|
-
lastSelectedAlias;
|
|
123828
123882
|
constructor(opts) {
|
|
123829
123883
|
super();
|
|
123830
123884
|
this.opts = opts;
|
|
@@ -123840,8 +123894,6 @@ var ModelSelectorComponent = class extends Container {
|
|
|
123840
123894
|
});
|
|
123841
123895
|
const initialChoice = choices[selectedIdx];
|
|
123842
123896
|
this.thinkingDraft = initialChoice !== void 0 ? effectiveThinkingLevel(initialChoice.model, opts.currentThinkingLevel) : opts.currentThinkingLevel;
|
|
123843
|
-
this.imageDraft = initialChoice !== void 0 ? modelHasImageIn(initialChoice.model) : false;
|
|
123844
|
-
this.lastSelectedAlias = initialChoice?.alias;
|
|
123845
123897
|
}
|
|
123846
123898
|
handleInput(data) {
|
|
123847
123899
|
if (matchesKey(data, Key.escape)) {
|
|
@@ -123850,34 +123902,27 @@ var ModelSelectorComponent = class extends Container {
|
|
|
123850
123902
|
return;
|
|
123851
123903
|
}
|
|
123852
123904
|
const selected = this.list.selected();
|
|
123853
|
-
if (selected !== void 0 && selected.alias !== this.lastSelectedAlias) {
|
|
123854
|
-
this.imageDraft = modelHasImageIn(selected.model);
|
|
123855
|
-
this.lastSelectedAlias = selected.alias;
|
|
123856
|
-
}
|
|
123857
123905
|
if (selected !== void 0 && thinkingAvailability(selected.model) !== "unsupported") {
|
|
123858
123906
|
const levels = getThinkingLevels(selected.model);
|
|
123859
123907
|
const idx = levels.indexOf(this.thinkingDraft);
|
|
123860
123908
|
if (matchesKey(data, Key.left)) {
|
|
123861
123909
|
const nextIdx = idx <= 0 ? levels.length - 1 : idx - 1;
|
|
123862
123910
|
this.thinkingDraft = levels[nextIdx];
|
|
123911
|
+
this.opts.onChangeThinking?.(selected.alias, this.thinkingDraft);
|
|
123863
123912
|
return;
|
|
123864
123913
|
}
|
|
123865
123914
|
if (matchesKey(data, Key.right)) {
|
|
123866
123915
|
const nextIdx = idx === -1 || idx >= levels.length - 1 ? 0 : idx + 1;
|
|
123867
123916
|
this.thinkingDraft = levels[nextIdx];
|
|
123917
|
+
this.opts.onChangeThinking?.(selected.alias, this.thinkingDraft);
|
|
123868
123918
|
return;
|
|
123869
123919
|
}
|
|
123870
123920
|
}
|
|
123871
|
-
if (selected !== void 0 && !modelHasImageIn(selected.model) && matchesKey(data, Key.space)) {
|
|
123872
|
-
this.imageDraft = !this.imageDraft;
|
|
123873
|
-
return;
|
|
123874
|
-
}
|
|
123875
123921
|
if (matchesKey(data, Key.enter)) {
|
|
123876
123922
|
if (selected === void 0) return;
|
|
123877
123923
|
this.opts.onSelect({
|
|
123878
123924
|
alias: selected.alias,
|
|
123879
|
-
thinkingLevel: effectiveThinkingLevel(selected.model, this.thinkingDraft)
|
|
123880
|
-
imageEnabled: this.imageDraft
|
|
123925
|
+
thinkingLevel: effectiveThinkingLevel(selected.model, this.thinkingDraft)
|
|
123881
123926
|
});
|
|
123882
123927
|
return;
|
|
123883
123928
|
}
|
|
@@ -123888,13 +123933,9 @@ var ModelSelectorComponent = class extends Container {
|
|
|
123888
123933
|
const searchable = this.opts.searchable === true;
|
|
123889
123934
|
const view = this.list.view();
|
|
123890
123935
|
const choices = view.items;
|
|
123891
|
-
const navParts = [
|
|
123892
|
-
"↑↓ 模型",
|
|
123893
|
-
"←→ 思考等级",
|
|
123894
|
-
"Space(空格) vision识图"
|
|
123895
|
-
];
|
|
123936
|
+
const navParts = ["↑↓ 模型", "←→ 思考等级"];
|
|
123896
123937
|
if (view.page.pageCount > 1) navParts.push("PgUp/PgDn 翻页");
|
|
123897
|
-
navParts.push("Enter
|
|
123938
|
+
navParts.push("Enter 切换模型", "Esc 取消");
|
|
123898
123939
|
const titleSuffix = searchable && view.query.length === 0 ? chalk.hex(colors.textMuted)(" (输入搜索)") : "";
|
|
123899
123940
|
const lines = [chalk.hex(colors.primary)("─".repeat(width)), chalk.hex(colors.primary).bold(" 选择模型") + titleSuffix];
|
|
123900
123941
|
if (searchable && view.query.length > 0) lines.push(chalk.hex(colors.primary)(" 搜索:") + chalk.hex(colors.text)(view.query));
|
|
@@ -123913,12 +123954,16 @@ var ModelSelectorComponent = class extends Container {
|
|
|
123913
123954
|
lines.push(line);
|
|
123914
123955
|
}
|
|
123915
123956
|
lines.push("");
|
|
123916
|
-
lines.push(chalk.hex(colors.textMuted)(" Thinking"));
|
|
123957
|
+
lines.push(chalk.hex(colors.textMuted)(" Thinking(全局设置)"));
|
|
123917
123958
|
const selected = choices[view.selectedIndex];
|
|
123918
123959
|
if (selected !== void 0) lines.push(this.renderThinkingControl(selected.model));
|
|
123919
123960
|
lines.push("");
|
|
123920
|
-
lines.push(chalk.hex(colors.textMuted)("
|
|
123921
|
-
if (selected !== void 0)
|
|
123961
|
+
lines.push(chalk.hex(colors.textMuted)(" 多模态能力"));
|
|
123962
|
+
if (selected !== void 0) {
|
|
123963
|
+
lines.push(this.renderImageControl(selected.model));
|
|
123964
|
+
lines.push(this.renderVideoControl(selected.model));
|
|
123965
|
+
lines.push(this.renderAudioControl(selected.model));
|
|
123966
|
+
}
|
|
123922
123967
|
lines.push("");
|
|
123923
123968
|
if (view.page.pageCount > 1) lines.push(chalk.hex(colors.textMuted)(` Page ${String(view.page.page + 1)}/${String(view.page.pageCount)}`));
|
|
123924
123969
|
lines.push(chalk.hex(colors.primary)("─".repeat(width)));
|
|
@@ -123937,8 +123982,18 @@ var ModelSelectorComponent = class extends Container {
|
|
|
123937
123982
|
}
|
|
123938
123983
|
renderImageControl(model) {
|
|
123939
123984
|
const { colors } = this.opts;
|
|
123940
|
-
if (modelHasImageIn(model)) return ` ${chalk.hex(colors.
|
|
123941
|
-
return ` ${
|
|
123985
|
+
if (modelHasImageIn(model)) return ` ${chalk.hex(colors.textMuted)("识图")}: ${chalk.hex(colors.success).bold("✓ 支持")}`;
|
|
123986
|
+
return ` ${chalk.hex(colors.textMuted)("识图")}: ${chalk.hex(colors.textDim)("✗ 不支持")}`;
|
|
123987
|
+
}
|
|
123988
|
+
renderVideoControl(model) {
|
|
123989
|
+
const { colors } = this.opts;
|
|
123990
|
+
if (modelHasVideoIn(model)) return ` ${chalk.hex(colors.textMuted)("视频")}: ${chalk.hex(colors.success).bold("✓ 支持")}`;
|
|
123991
|
+
return ` ${chalk.hex(colors.textMuted)("视频")}: ${chalk.hex(colors.textDim)("✗ 不支持")}`;
|
|
123992
|
+
}
|
|
123993
|
+
renderAudioControl(model) {
|
|
123994
|
+
const { colors } = this.opts;
|
|
123995
|
+
if (modelHasAudioIn(model)) return ` ${chalk.hex(colors.textMuted)("音频")}: ${chalk.hex(colors.success).bold("✓ 支持")}`;
|
|
123996
|
+
return ` ${chalk.hex(colors.textMuted)("音频")}: ${chalk.hex(colors.textDim)("✗ 不支持")}`;
|
|
123942
123997
|
}
|
|
123943
123998
|
};
|
|
123944
123999
|
//#endregion
|
|
@@ -124152,6 +124207,33 @@ const THINKING_OPTIONS = [
|
|
|
124152
124207
|
label: "高强度思考"
|
|
124153
124208
|
}
|
|
124154
124209
|
];
|
|
124210
|
+
const IMAGE_OPTIONS = [{
|
|
124211
|
+
value: "off",
|
|
124212
|
+
label: "关闭识图",
|
|
124213
|
+
description: "模型不支持图片输入时请选择此项"
|
|
124214
|
+
}, {
|
|
124215
|
+
value: "on",
|
|
124216
|
+
label: "开启识图",
|
|
124217
|
+
description: "模型支持图片输入时开启,允许发送图片"
|
|
124218
|
+
}];
|
|
124219
|
+
const VIDEO_OPTIONS = [{
|
|
124220
|
+
value: "off",
|
|
124221
|
+
label: "关闭视频",
|
|
124222
|
+
description: "模型不支持视频输入时请选择此项"
|
|
124223
|
+
}, {
|
|
124224
|
+
value: "on",
|
|
124225
|
+
label: "开启视频",
|
|
124226
|
+
description: "模型支持视频输入时开启,允许发送视频"
|
|
124227
|
+
}];
|
|
124228
|
+
const AUDIO_OPTIONS = [{
|
|
124229
|
+
value: "off",
|
|
124230
|
+
label: "关闭音频",
|
|
124231
|
+
description: "模型不支持音频输入时请选择此项"
|
|
124232
|
+
}, {
|
|
124233
|
+
value: "on",
|
|
124234
|
+
label: "开启音频",
|
|
124235
|
+
description: "模型支持音频输入时开启,允许发送音频"
|
|
124236
|
+
}];
|
|
124155
124237
|
function promptWireType(host) {
|
|
124156
124238
|
return new Promise((resolve) => {
|
|
124157
124239
|
const picker = new ChoicePickerComponent({
|
|
@@ -124205,6 +124287,63 @@ function promptThinkingMode(host) {
|
|
|
124205
124287
|
host.mountEditorReplacement(picker);
|
|
124206
124288
|
});
|
|
124207
124289
|
}
|
|
124290
|
+
function promptImageMode(host) {
|
|
124291
|
+
return new Promise((resolve) => {
|
|
124292
|
+
const picker = new ChoicePickerComponent({
|
|
124293
|
+
title: "多模态配置 · 图片输入",
|
|
124294
|
+
hint: "模型不支持请选择关闭",
|
|
124295
|
+
options: IMAGE_OPTIONS,
|
|
124296
|
+
colors: host.state.theme.colors,
|
|
124297
|
+
onSelect: (value) => {
|
|
124298
|
+
host.restoreEditor();
|
|
124299
|
+
resolve(value === "on");
|
|
124300
|
+
},
|
|
124301
|
+
onCancel: () => {
|
|
124302
|
+
host.restoreEditor();
|
|
124303
|
+
resolve(void 0);
|
|
124304
|
+
}
|
|
124305
|
+
});
|
|
124306
|
+
host.mountEditorReplacement(picker);
|
|
124307
|
+
});
|
|
124308
|
+
}
|
|
124309
|
+
function promptVideoMode(host) {
|
|
124310
|
+
return new Promise((resolve) => {
|
|
124311
|
+
const picker = new ChoicePickerComponent({
|
|
124312
|
+
title: "多模态配置 · 视频输入",
|
|
124313
|
+
hint: "模型不支持请选择关闭",
|
|
124314
|
+
options: VIDEO_OPTIONS,
|
|
124315
|
+
colors: host.state.theme.colors,
|
|
124316
|
+
onSelect: (value) => {
|
|
124317
|
+
host.restoreEditor();
|
|
124318
|
+
resolve(value === "on");
|
|
124319
|
+
},
|
|
124320
|
+
onCancel: () => {
|
|
124321
|
+
host.restoreEditor();
|
|
124322
|
+
resolve(void 0);
|
|
124323
|
+
}
|
|
124324
|
+
});
|
|
124325
|
+
host.mountEditorReplacement(picker);
|
|
124326
|
+
});
|
|
124327
|
+
}
|
|
124328
|
+
function promptAudioMode(host) {
|
|
124329
|
+
return new Promise((resolve) => {
|
|
124330
|
+
const picker = new ChoicePickerComponent({
|
|
124331
|
+
title: "多模态配置 · 音频输入",
|
|
124332
|
+
hint: "模型不支持请选择关闭",
|
|
124333
|
+
options: AUDIO_OPTIONS,
|
|
124334
|
+
colors: host.state.theme.colors,
|
|
124335
|
+
onSelect: (value) => {
|
|
124336
|
+
host.restoreEditor();
|
|
124337
|
+
resolve(value === "on");
|
|
124338
|
+
},
|
|
124339
|
+
onCancel: () => {
|
|
124340
|
+
host.restoreEditor();
|
|
124341
|
+
resolve(void 0);
|
|
124342
|
+
}
|
|
124343
|
+
});
|
|
124344
|
+
host.mountEditorReplacement(picker);
|
|
124345
|
+
});
|
|
124346
|
+
}
|
|
124208
124347
|
//#endregion
|
|
124209
124348
|
//#region src/tui/commands/auth.ts
|
|
124210
124349
|
async function handleConnectCommand(host, args) {
|
|
@@ -124347,15 +124486,21 @@ async function handleDiyConfig(host) {
|
|
|
124347
124486
|
const maxContextTokens = parseInt(maxContextStr, 10) || 131072;
|
|
124348
124487
|
const thinkingLevel = await promptThinkingMode(host);
|
|
124349
124488
|
if (thinkingLevel === void 0) return;
|
|
124489
|
+
const imageEnabled = await promptImageMode(host);
|
|
124490
|
+
if (imageEnabled === void 0) return;
|
|
124491
|
+
const videoEnabled = await promptVideoMode(host);
|
|
124492
|
+
if (videoEnabled === void 0) return;
|
|
124493
|
+
const audioEnabled = await promptAudioMode(host);
|
|
124494
|
+
if (audioEnabled === void 0) return;
|
|
124350
124495
|
const providerId = `custom-${modelId.replaceAll(/[^A-Za-z0-9._-]/g, "-")}`;
|
|
124351
124496
|
const catalogModel = {
|
|
124352
124497
|
id: modelId,
|
|
124353
124498
|
name: modelId,
|
|
124354
124499
|
capability: {
|
|
124355
124500
|
max_context_tokens: maxContextTokens,
|
|
124356
|
-
image_in:
|
|
124357
|
-
video_in:
|
|
124358
|
-
audio_in:
|
|
124501
|
+
image_in: imageEnabled,
|
|
124502
|
+
video_in: videoEnabled,
|
|
124503
|
+
audio_in: audioEnabled,
|
|
124359
124504
|
thinking: thinkingLevel !== "off",
|
|
124360
124505
|
tool_use: true
|
|
124361
124506
|
},
|
|
@@ -124855,7 +125000,7 @@ const dark = {
|
|
|
124855
125000
|
gray50: "#F5F5F5",
|
|
124856
125001
|
gray100: "#E0E0E0",
|
|
124857
125002
|
gray500: "#888888",
|
|
124858
|
-
gray600: "#
|
|
125003
|
+
gray600: "#767676",
|
|
124859
125004
|
gray700: "#5A5A5A",
|
|
124860
125005
|
greenLight: "#7AD99B",
|
|
124861
125006
|
red: "#E85454",
|
|
@@ -124913,14 +125058,14 @@ const lightColors = {
|
|
|
124913
125058
|
primary: light.green,
|
|
124914
125059
|
accent: light.tangerine700,
|
|
124915
125060
|
planMode: "#00838F",
|
|
124916
|
-
fusionPlanMode: "#
|
|
125061
|
+
fusionPlanMode: "#8C7600",
|
|
124917
125062
|
text: light.gray900,
|
|
124918
125063
|
textStrong: light.gray900,
|
|
124919
125064
|
textDim: light.gray700,
|
|
124920
125065
|
textMuted: light.gray600,
|
|
124921
125066
|
mdLink: "#007A8A",
|
|
124922
125067
|
mdCodeBlock: "#1565C0",
|
|
124923
|
-
mdCodeBlockBorder: "#
|
|
125068
|
+
mdCodeBlockBorder: "#848484",
|
|
124924
125069
|
mdQuote: "#616161",
|
|
124925
125070
|
border: light.gray500,
|
|
124926
125071
|
borderFocus: light.gold700,
|
|
@@ -125653,24 +125798,82 @@ function showModelPicker(host, selectedValue = host.state.appState.model) {
|
|
|
125653
125798
|
currentThinkingLevel: host.state.appState.thinkingLevel,
|
|
125654
125799
|
colors: host.state.theme.colors,
|
|
125655
125800
|
searchable: true,
|
|
125656
|
-
onSelect: ({ alias, thinkingLevel
|
|
125801
|
+
onSelect: ({ alias, thinkingLevel }) => {
|
|
125657
125802
|
host.restoreEditor();
|
|
125658
|
-
performModelSwitch(host, alias, thinkingLevel
|
|
125803
|
+
performModelSwitch(host, alias, thinkingLevel);
|
|
125804
|
+
},
|
|
125805
|
+
onChangeThinking: (alias, level) => {
|
|
125806
|
+
changeThinkingLevel(host, alias, level);
|
|
125659
125807
|
},
|
|
125660
125808
|
onCancel: () => {
|
|
125661
125809
|
host.restoreEditor();
|
|
125662
125810
|
}
|
|
125663
125811
|
}));
|
|
125664
125812
|
}
|
|
125665
|
-
|
|
125813
|
+
/**
|
|
125814
|
+
* Apply a thinking-level change immediately (←/→ keys in the model selector).
|
|
125815
|
+
* Decoupled from performModelSwitch so the user can cycle thinking on the
|
|
125816
|
+
* currently-selected model without pressing Enter. If the alias is the active
|
|
125817
|
+
* model, the running session is updated too; otherwise only the default is
|
|
125818
|
+
* persisted.
|
|
125819
|
+
*/
|
|
125820
|
+
async function changeThinkingLevel(host, alias, level) {
|
|
125821
|
+
if (isBusy(host.state.appState)) {
|
|
125822
|
+
host.showError("Cannot change thinking while streaming — press Esc or Ctrl-C first.");
|
|
125823
|
+
return;
|
|
125824
|
+
}
|
|
125825
|
+
const prevLevel = host.state.appState.thinkingLevel;
|
|
125826
|
+
const isActiveModel = alias === host.state.appState.model;
|
|
125827
|
+
if (isActiveModel && level !== prevLevel) {
|
|
125828
|
+
const session = host.session;
|
|
125829
|
+
try {
|
|
125830
|
+
if (session === void 0) await host.authFlow.activateModelAfterLogin(alias, level);
|
|
125831
|
+
else await session.setThinking(level);
|
|
125832
|
+
} catch (error) {
|
|
125833
|
+
const msg = formatErrorMessage(error);
|
|
125834
|
+
host.showError(`Failed to set thinking: ${msg}`);
|
|
125835
|
+
return;
|
|
125836
|
+
}
|
|
125837
|
+
host.setAppState({ thinkingLevel: level });
|
|
125838
|
+
}
|
|
125839
|
+
let persisted = false;
|
|
125840
|
+
try {
|
|
125841
|
+
persisted = await persistThinkingDefault(host, alias, level);
|
|
125842
|
+
} catch (error) {
|
|
125843
|
+
const msg = formatErrorMessage(error);
|
|
125844
|
+
host.showError(`Failed to save thinking default: ${msg}`);
|
|
125845
|
+
return;
|
|
125846
|
+
}
|
|
125847
|
+
const status = isActiveModel && level !== prevLevel ? `Thinking set to ${level} for ${alias}.` : persisted ? `Saved thinking ${level} as default for ${alias}.` : `Thinking already ${level} for ${alias}.`;
|
|
125848
|
+
host.showStatus(status, host.state.theme.colors.success);
|
|
125849
|
+
}
|
|
125850
|
+
async function persistThinkingDefault(host, alias, level) {
|
|
125851
|
+
const config = await host.harness.getConfig({ reload: true });
|
|
125852
|
+
const effectiveThinking = level !== "off";
|
|
125853
|
+
const existingEffort = config.thinking?.effort;
|
|
125854
|
+
const newEffort = effectiveThinking ? level : existingEffort;
|
|
125855
|
+
if (!(config.defaultModel === alias)) return false;
|
|
125856
|
+
if (config.defaultThinking === effectiveThinking && existingEffort === newEffort) return false;
|
|
125857
|
+
await host.harness.setConfig({
|
|
125858
|
+
defaultThinking: effectiveThinking,
|
|
125859
|
+
thinking: {
|
|
125860
|
+
...config.thinking,
|
|
125861
|
+
mode: effectiveThinking ? "on" : "off",
|
|
125862
|
+
effort: newEffort
|
|
125863
|
+
}
|
|
125864
|
+
});
|
|
125865
|
+
return true;
|
|
125866
|
+
}
|
|
125867
|
+
async function performModelSwitch(host, alias, thinkingLevel) {
|
|
125666
125868
|
if (isBusy(host.state.appState)) {
|
|
125667
125869
|
host.showError("Cannot switch models while streaming — press Esc or Ctrl-C first.");
|
|
125668
125870
|
return;
|
|
125669
125871
|
}
|
|
125670
125872
|
const prevModel = host.state.appState.model;
|
|
125671
125873
|
const prevThinkingLevel = host.state.appState.thinkingLevel;
|
|
125672
|
-
const
|
|
125673
|
-
const
|
|
125874
|
+
const modelChanged = alias !== prevModel;
|
|
125875
|
+
const thinkingChanged = thinkingLevel !== prevThinkingLevel;
|
|
125876
|
+
const needsSessionActivation = modelChanged || thinkingChanged;
|
|
125674
125877
|
const overflow = alias !== prevModel ? contextOverflowForModel(host.state.appState, alias) : null;
|
|
125675
125878
|
if (overflow !== null) {
|
|
125676
125879
|
host.showNotice("Storm Breaker(风暴守护者)", `无法切换到模型「${alias}」:当前会话上下文 ${formatTokenCount$1(overflow.currentTokens)} 已超出该模型上限 ${formatTokenCount$1(overflow.maxContextTokens)}。建议先执行 /compact 压缩上下文,或选择上下文窗口更大的模型。`);
|
|
@@ -125678,10 +125881,10 @@ async function performModelSwitch(host, alias, thinkingLevel, imageEnabled) {
|
|
|
125678
125881
|
}
|
|
125679
125882
|
const session = host.session;
|
|
125680
125883
|
try {
|
|
125681
|
-
if (session === void 0 &&
|
|
125884
|
+
if (session === void 0 && needsSessionActivation) await host.authFlow.activateModelAfterLogin(alias, thinkingLevel);
|
|
125682
125885
|
else if (session !== void 0) {
|
|
125683
|
-
if (
|
|
125684
|
-
if (
|
|
125886
|
+
if (modelChanged) await session.setModel(alias);
|
|
125887
|
+
if (thinkingChanged) await session.setThinking(thinkingLevel);
|
|
125685
125888
|
}
|
|
125686
125889
|
} catch (error) {
|
|
125687
125890
|
const msg = formatErrorMessage(error);
|
|
@@ -125694,38 +125897,26 @@ async function performModelSwitch(host, alias, thinkingLevel, imageEnabled) {
|
|
|
125694
125897
|
});
|
|
125695
125898
|
let persisted = false;
|
|
125696
125899
|
try {
|
|
125697
|
-
persisted = await persistModelSelection(host, alias, thinkingLevel
|
|
125900
|
+
persisted = await persistModelSelection(host, alias, thinkingLevel);
|
|
125698
125901
|
} catch (error) {
|
|
125699
125902
|
const msg = formatErrorMessage(error);
|
|
125700
125903
|
host.showError(`Switched to ${alias}, but failed to save default: ${msg}`);
|
|
125701
125904
|
return;
|
|
125702
125905
|
}
|
|
125703
|
-
|
|
125704
|
-
|
|
125705
|
-
if (
|
|
125706
|
-
|
|
125707
|
-
|
|
125708
|
-
|
|
125709
|
-
[alias]: {
|
|
125710
|
-
...prevAlias,
|
|
125711
|
-
capabilities: nextCaps
|
|
125712
|
-
}
|
|
125713
|
-
} });
|
|
125714
|
-
}
|
|
125715
|
-
}
|
|
125716
|
-
const status = runtimeChanged ? `Switched to ${alias} with thinking ${thinkingLevel}.` : persisted ? `Saved ${alias} with thinking ${thinkingLevel} as default.` : `Already using ${alias} with thinking ${thinkingLevel}.`;
|
|
125906
|
+
const status = (() => {
|
|
125907
|
+
if (modelChanged) return `Switched to ${alias} with thinking ${thinkingLevel}.`;
|
|
125908
|
+
if (thinkingChanged) return `Thinking set to ${thinkingLevel} for ${alias}.`;
|
|
125909
|
+
if (persisted) return `Saved ${alias} with thinking ${thinkingLevel} as default.`;
|
|
125910
|
+
return `Already using ${alias} with thinking ${thinkingLevel}.`;
|
|
125911
|
+
})();
|
|
125717
125912
|
host.showStatus(status, host.state.theme.colors.success);
|
|
125718
125913
|
}
|
|
125719
|
-
async function persistModelSelection(host, alias, thinkingLevel
|
|
125914
|
+
async function persistModelSelection(host, alias, thinkingLevel) {
|
|
125720
125915
|
const config = await host.harness.getConfig({ reload: true });
|
|
125721
125916
|
const effectiveThinking = thinkingLevel !== "off";
|
|
125722
125917
|
const existingEffort = config.thinking?.effort;
|
|
125723
125918
|
const newEffort = effectiveThinking ? thinkingLevel : existingEffort;
|
|
125724
|
-
|
|
125725
|
-
const prevCaps = aliasCfg?.capabilities;
|
|
125726
|
-
const nextCaps = computeCapabilities(prevCaps, imageEnabled);
|
|
125727
|
-
const capsChanged = prevCaps?.includes("image_in") === true !== imageEnabled;
|
|
125728
|
-
if (config.defaultModel === alias && config.defaultThinking === effectiveThinking && existingEffort === newEffort && !capsChanged) return false;
|
|
125919
|
+
if (config.defaultModel === alias && config.defaultThinking === effectiveThinking && existingEffort === newEffort) return false;
|
|
125729
125920
|
await host.harness.setConfig({
|
|
125730
125921
|
defaultModel: alias,
|
|
125731
125922
|
defaultThinking: effectiveThinking,
|
|
@@ -125733,28 +125924,10 @@ async function persistModelSelection(host, alias, thinkingLevel, imageEnabled) {
|
|
|
125733
125924
|
...config.thinking,
|
|
125734
125925
|
mode: effectiveThinking ? "on" : "off",
|
|
125735
125926
|
effort: newEffort
|
|
125736
|
-
}
|
|
125737
|
-
models: capsChanged && aliasCfg !== void 0 ? { [alias]: {
|
|
125738
|
-
...aliasCfg,
|
|
125739
|
-
capabilities: nextCaps
|
|
125740
|
-
} } : void 0
|
|
125927
|
+
}
|
|
125741
125928
|
});
|
|
125742
125929
|
return true;
|
|
125743
125930
|
}
|
|
125744
|
-
/**
|
|
125745
|
-
* Returns the new capabilities array after toggling 'image_in'. Returns
|
|
125746
|
-
* `undefined` when the result would be empty, so legacy aliases without a
|
|
125747
|
-
* capabilities declaration stay clean (no `capabilities = []` in toml).
|
|
125748
|
-
*/
|
|
125749
|
-
function computeCapabilities(prev, imageEnabled) {
|
|
125750
|
-
if (imageEnabled) {
|
|
125751
|
-
if (prev === void 0) return ["image_in"];
|
|
125752
|
-
return prev.includes("image_in") ? [...prev] : [...prev, "image_in"];
|
|
125753
|
-
}
|
|
125754
|
-
if (prev === void 0) return void 0;
|
|
125755
|
-
const filtered = prev.filter((c) => c !== "image_in");
|
|
125756
|
-
return filtered.length === 0 ? void 0 : filtered;
|
|
125757
|
-
}
|
|
125758
125931
|
function showThemePicker(host) {
|
|
125759
125932
|
host.mountEditorReplacement(new ThemeSelectorComponent({
|
|
125760
125933
|
currentValue: host.state.appState.theme,
|
|
@@ -126495,9 +126668,25 @@ function dismissGoalPanel(host) {
|
|
|
126495
126668
|
host.state.ui.requestRender();
|
|
126496
126669
|
}
|
|
126497
126670
|
}
|
|
126498
|
-
const
|
|
126671
|
+
const BREATHE_CYCLE_MS = 2e3;
|
|
126672
|
+
let startTime = Date.now();
|
|
126673
|
+
/**
|
|
126674
|
+
* Reset the clock so the next cycle starts at frame 0.
|
|
126675
|
+
*
|
|
126676
|
+
* Call from each component's `startBreathing` — this aligns `startTime`
|
|
126677
|
+
* with the component's `setTimeout(BREATHE_CYCLE_MS)` so the 2 s stop
|
|
126678
|
+
* fires at frame 0 of a new cycle, not partway through a second one.
|
|
126679
|
+
* Without this, the gap between module load (which sets `startTime`)
|
|
126680
|
+
* and `startBreathing` (which starts the stop timeout) lets the frame
|
|
126681
|
+
* advance past 120 before the timeout fires, causing the logo to start
|
|
126682
|
+
* a second cycle and get cut off mid-blink.
|
|
126683
|
+
*/
|
|
126684
|
+
function resetBreathingClock() {
|
|
126685
|
+
startTime = Date.now();
|
|
126686
|
+
}
|
|
126499
126687
|
function getBreathingFrame() {
|
|
126500
|
-
|
|
126688
|
+
const stepMs = BREATHE_CYCLE_MS / 120;
|
|
126689
|
+
return Math.floor((Date.now() - startTime) / stepMs) % 120;
|
|
126501
126690
|
}
|
|
126502
126691
|
//#endregion
|
|
126503
126692
|
//#region src/tui/components/chrome/welcome.ts
|
|
@@ -126612,6 +126801,7 @@ var WelcomeComponent = class {
|
|
|
126612
126801
|
colors;
|
|
126613
126802
|
ui;
|
|
126614
126803
|
breatheTimer = null;
|
|
126804
|
+
breatheTimeout = null;
|
|
126615
126805
|
breathePalette;
|
|
126616
126806
|
recentSessions;
|
|
126617
126807
|
borderTitle = null;
|
|
@@ -126629,16 +126819,24 @@ var WelcomeComponent = class {
|
|
|
126629
126819
|
this.breatheTimer = null;
|
|
126630
126820
|
this.ui.requestRender();
|
|
126631
126821
|
}
|
|
126822
|
+
if (this.breatheTimeout !== null) {
|
|
126823
|
+
clearTimeout(this.breatheTimeout);
|
|
126824
|
+
this.breatheTimeout = null;
|
|
126825
|
+
}
|
|
126632
126826
|
}
|
|
126633
126827
|
startBreathing() {
|
|
126828
|
+
resetBreathingClock();
|
|
126634
126829
|
this.breatheTimer = setInterval(() => {
|
|
126635
126830
|
this.ui.requestRender();
|
|
126636
126831
|
}, 40);
|
|
126832
|
+
if (this.breatheTimeout === null) this.breatheTimeout = setTimeout(() => {
|
|
126833
|
+
this.stopBreathing();
|
|
126834
|
+
}, BREATHE_CYCLE_MS);
|
|
126637
126835
|
}
|
|
126638
126836
|
invalidate() {}
|
|
126639
126837
|
render(width) {
|
|
126640
126838
|
const breatheFrame = this.breatheTimer !== null ? getBreathingFrame() : 0;
|
|
126641
|
-
const breatheColor = this.breathePalette[breatheFrame] ?? this.colors.primary;
|
|
126839
|
+
const breatheColor = this.breatheTimer !== null ? this.breathePalette[breatheFrame] ?? this.colors.primary : this.colors.primary;
|
|
126642
126840
|
const boxColor = chalk.hex(breatheColor);
|
|
126643
126841
|
const dim = chalk.hex(this.colors.textDim);
|
|
126644
126842
|
const muted = chalk.hex(this.colors.textMuted);
|
|
@@ -126651,6 +126849,8 @@ var WelcomeComponent = class {
|
|
|
126651
126849
|
const isLoggedOut = !this.state.model;
|
|
126652
126850
|
const activeModel = this.state.availableModels[this.state.model];
|
|
126653
126851
|
const modelValue = isLoggedOut ? chalk.hex(this.colors.warning)("未设置") : activeModel?.displayName ?? activeModel?.model ?? this.state.model;
|
|
126852
|
+
const like = this.state.like;
|
|
126853
|
+
const likeValue = Boolean((like.nickname ?? "").trim() || (like.tone ?? "").trim() || (like.other ?? "").trim()) ? chalk.hex(this.colors.success)("like已激活") : chalk.hex(this.colors.textDim)("like未加载");
|
|
126654
126854
|
let versionValue;
|
|
126655
126855
|
if (this.state.hasNewVersion && this.state.latestVersion !== null) versionValue = chalk.hex(this.colors.warning)(this.state.version) + " " + dim("(" + this.state.latestVersion + ")");
|
|
126656
126856
|
else versionValue = this.state.version;
|
|
@@ -126684,7 +126884,8 @@ var WelcomeComponent = class {
|
|
|
126684
126884
|
centerText(logo[1], leftCol),
|
|
126685
126885
|
"",
|
|
126686
126886
|
centerText(dim(versionValue), leftCol),
|
|
126687
|
-
centerText(dim(modelValue), leftCol)
|
|
126887
|
+
centerText(dim(modelValue), leftCol),
|
|
126888
|
+
centerText(likeValue, leftCol)
|
|
126688
126889
|
];
|
|
126689
126890
|
const topPad = Math.max(0, Math.floor((rightRows.length - leftContent.length) / 2));
|
|
126690
126891
|
const bottomPad = Math.max(0, rightRows.length - leftContent.length - topPad);
|
|
@@ -126700,6 +126901,7 @@ var WelcomeComponent = class {
|
|
|
126700
126901
|
"",
|
|
126701
126902
|
centerText(dim(versionValue), leftCol),
|
|
126702
126903
|
centerText(dim(modelValue), leftCol),
|
|
126904
|
+
centerText(likeValue, leftCol),
|
|
126703
126905
|
""
|
|
126704
126906
|
];
|
|
126705
126907
|
const borderTitle = this.borderTitle ?? "";
|
|
@@ -126913,21 +127115,84 @@ function formatTokens$1(n) {
|
|
|
126913
127115
|
if (n >= 1e3) return `${(n / 1e3).toFixed(1)}k tok`;
|
|
126914
127116
|
return `${String(n)} tok`;
|
|
126915
127117
|
}
|
|
127118
|
+
const FADE_MS = 1200;
|
|
127119
|
+
function parseHex(hex) {
|
|
127120
|
+
const h = hex.replace("#", "");
|
|
127121
|
+
return [
|
|
127122
|
+
parseInt(h.slice(0, 2), 16),
|
|
127123
|
+
parseInt(h.slice(2, 4), 16),
|
|
127124
|
+
parseInt(h.slice(4, 6), 16)
|
|
127125
|
+
];
|
|
127126
|
+
}
|
|
127127
|
+
function toHex(r, g, b) {
|
|
127128
|
+
const c = (v) => Math.max(0, Math.min(255, Math.round(v))).toString(16).padStart(2, "0");
|
|
127129
|
+
return `#${c(r)}${c(g)}${c(b)}`;
|
|
127130
|
+
}
|
|
127131
|
+
function interpolateRgb(from, to, t) {
|
|
127132
|
+
const [r1, g1, b1] = parseHex(from);
|
|
127133
|
+
const [r2, g2, b2] = parseHex(to);
|
|
127134
|
+
return toHex(r1 + (r2 - r1) * t, g1 + (g2 - g1) * t, b1 + (b2 - b1) * t);
|
|
127135
|
+
}
|
|
127136
|
+
/**
|
|
127137
|
+
* Pre-compute the 12-bucket ramp from `accent` (age=0, just arrived) to
|
|
127138
|
+
* `ink` (age ≥ FADE_MS, fully settled). Both endpoints are inclusive.
|
|
127139
|
+
*/
|
|
127140
|
+
function buildFadeTable(accent, ink) {
|
|
127141
|
+
const table = [];
|
|
127142
|
+
for (let i = 0; i < 12; i++) {
|
|
127143
|
+
const t = i / 11;
|
|
127144
|
+
table.push(interpolateRgb(accent, ink, t));
|
|
127145
|
+
}
|
|
127146
|
+
return table;
|
|
127147
|
+
}
|
|
127148
|
+
/**
|
|
127149
|
+
* Look up the fade color for content that arrived `ageMs` ago.
|
|
127150
|
+
*
|
|
127151
|
+
* Returns `table[FADE_BUCKETS - 1]` (the settled `ink` color) when
|
|
127152
|
+
* `ageMs >= FADE_MS` or when reduced motion is requested.
|
|
127153
|
+
*/
|
|
127154
|
+
function fadeColor(ageMs, table, reduced) {
|
|
127155
|
+
const ink = table[11];
|
|
127156
|
+
if (reduced) return ink;
|
|
127157
|
+
if (ageMs >= 1200) return ink;
|
|
127158
|
+
if (ageMs <= 0) return table[0];
|
|
127159
|
+
const t = ageMs / FADE_MS;
|
|
127160
|
+
return table[Math.min(11, Math.floor(t * 11))];
|
|
127161
|
+
}
|
|
127162
|
+
/**
|
|
127163
|
+
* Whether the user has requested reduced motion via the
|
|
127164
|
+
* `SCREAM_REDUCED_MOTION` env var. Accepts `1`, `true`, `yes` (case
|
|
127165
|
+
* insensitive); `0` / `false` / unset → false.
|
|
127166
|
+
*/
|
|
127167
|
+
function isReducedMotion() {
|
|
127168
|
+
const v = process.env["SCREAM_REDUCED_MOTION"];
|
|
127169
|
+
if (v === void 0 || v === "") return false;
|
|
127170
|
+
const lower = v.toLowerCase();
|
|
127171
|
+
return lower !== "0" && lower !== "false" && lower !== "no" && lower !== "";
|
|
127172
|
+
}
|
|
126916
127173
|
//#endregion
|
|
126917
127174
|
//#region src/tui/components/messages/assistant-message.ts
|
|
127175
|
+
const FADE_TICK_MS = 100;
|
|
126918
127176
|
var AssistantMessageComponent = class {
|
|
126919
127177
|
contentContainer;
|
|
126920
127178
|
markdownTheme;
|
|
126921
127179
|
bulletColor;
|
|
127180
|
+
accentColor;
|
|
126922
127181
|
lastText = "";
|
|
126923
127182
|
showBullet;
|
|
126924
127183
|
cachedWidth;
|
|
126925
127184
|
cachedLines;
|
|
126926
127185
|
markdownChild;
|
|
126927
|
-
|
|
127186
|
+
ui;
|
|
127187
|
+
fadeStartMs;
|
|
127188
|
+
fadeTimer;
|
|
127189
|
+
fadeTable;
|
|
127190
|
+
constructor(markdownTheme, colors, showBullet = true, ui) {
|
|
126928
127191
|
this.markdownTheme = markdownTheme;
|
|
126929
127192
|
this.bulletColor = colors.roleAssistant;
|
|
127193
|
+
this.accentColor = colors.primary;
|
|
126930
127194
|
this.showBullet = showBullet;
|
|
127195
|
+
this.ui = ui;
|
|
126931
127196
|
this.contentContainer = new Container();
|
|
126932
127197
|
}
|
|
126933
127198
|
setShowBullet(show) {
|
|
@@ -126935,6 +127200,7 @@ var AssistantMessageComponent = class {
|
|
|
126935
127200
|
this.showBullet = show;
|
|
126936
127201
|
this.cachedWidth = void 0;
|
|
126937
127202
|
this.cachedLines = void 0;
|
|
127203
|
+
if (!show) this.stopFade();
|
|
126938
127204
|
}
|
|
126939
127205
|
updateContent(text) {
|
|
126940
127206
|
const trimmedText = text.trim();
|
|
@@ -126949,6 +127215,7 @@ var AssistantMessageComponent = class {
|
|
|
126949
127215
|
else if (trimmedText.length > 0) {
|
|
126950
127216
|
this.markdownChild = new Markdown(trimmedText, 0, 0, this.markdownTheme);
|
|
126951
127217
|
this.contentContainer.addChild(this.markdownChild);
|
|
127218
|
+
this.startFade();
|
|
126952
127219
|
}
|
|
126953
127220
|
}
|
|
126954
127221
|
invalidate() {
|
|
@@ -126956,21 +127223,55 @@ var AssistantMessageComponent = class {
|
|
|
126956
127223
|
this.cachedLines = void 0;
|
|
126957
127224
|
this.contentContainer.invalidate?.();
|
|
126958
127225
|
}
|
|
127226
|
+
dispose() {
|
|
127227
|
+
this.stopFade();
|
|
127228
|
+
}
|
|
126959
127229
|
render(width) {
|
|
126960
127230
|
if (this.cachedLines !== void 0 && this.cachedWidth === width) return this.cachedLines;
|
|
126961
127231
|
if (this.lastText.trim().length === 0) return [];
|
|
126962
127232
|
const prefix = this.showBullet ? STATUS_BULLET : " ";
|
|
126963
127233
|
const contentWidth = Math.max(1, width - visibleWidth(prefix));
|
|
126964
127234
|
const contentLines = this.contentContainer.render(contentWidth);
|
|
127235
|
+
const activeBulletColor = this.currentBulletColor();
|
|
126965
127236
|
const lines = [""];
|
|
126966
127237
|
for (let i = 0; i < contentLines.length; i++) {
|
|
126967
|
-
const p = i === 0 && this.showBullet ? chalk.hex(
|
|
127238
|
+
const p = i === 0 && this.showBullet ? chalk.hex(activeBulletColor)(STATUS_BULLET) : " ";
|
|
126968
127239
|
lines.push(p + contentLines[i]);
|
|
126969
127240
|
}
|
|
126970
127241
|
this.cachedWidth = width;
|
|
126971
127242
|
this.cachedLines = lines;
|
|
126972
127243
|
return lines;
|
|
126973
127244
|
}
|
|
127245
|
+
currentBulletColor() {
|
|
127246
|
+
if (this.fadeStartMs === void 0 || this.fadeTable === void 0) return this.bulletColor;
|
|
127247
|
+
return fadeColor(Date.now() - this.fadeStartMs, this.fadeTable, false);
|
|
127248
|
+
}
|
|
127249
|
+
startFade() {
|
|
127250
|
+
if (this.ui === void 0) return;
|
|
127251
|
+
if (!this.showBullet) return;
|
|
127252
|
+
if (isReducedMotion()) return;
|
|
127253
|
+
if (this.fadeTimer !== void 0) return;
|
|
127254
|
+
this.fadeTable = buildFadeTable(this.accentColor, this.bulletColor);
|
|
127255
|
+
this.fadeStartMs = Date.now();
|
|
127256
|
+
this.fadeTimer = setInterval(() => {
|
|
127257
|
+
const age = Date.now() - (this.fadeStartMs ?? 0);
|
|
127258
|
+
this.cachedWidth = void 0;
|
|
127259
|
+
this.cachedLines = void 0;
|
|
127260
|
+
this.ui?.requestRender();
|
|
127261
|
+
if (age >= 1200) this.stopFade();
|
|
127262
|
+
}, FADE_TICK_MS);
|
|
127263
|
+
this.ui.requestRender();
|
|
127264
|
+
}
|
|
127265
|
+
stopFade() {
|
|
127266
|
+
if (this.fadeTimer !== void 0) {
|
|
127267
|
+
clearInterval(this.fadeTimer);
|
|
127268
|
+
this.fadeTimer = void 0;
|
|
127269
|
+
}
|
|
127270
|
+
this.fadeStartMs = void 0;
|
|
127271
|
+
this.fadeTable = void 0;
|
|
127272
|
+
this.cachedWidth = void 0;
|
|
127273
|
+
this.cachedLines = void 0;
|
|
127274
|
+
}
|
|
126974
127275
|
};
|
|
126975
127276
|
//#endregion
|
|
126976
127277
|
//#region src/tui/components/messages/background-agent-status.ts
|
|
@@ -127447,6 +127748,52 @@ var ThinkingComponent = class {
|
|
|
127447
127748
|
}
|
|
127448
127749
|
};
|
|
127449
127750
|
//#endregion
|
|
127751
|
+
//#region src/tui/utils/cached-container.ts
|
|
127752
|
+
/**
|
|
127753
|
+
* A Container that caches its rendered lines until explicitly invalidated or
|
|
127754
|
+
* its child list changes.
|
|
127755
|
+
*
|
|
127756
|
+
* pi-tui's built-in `Container.render()` walks and concatenates every child on
|
|
127757
|
+
* every frame. For large static subtrees (e.g., committed transcript history)
|
|
127758
|
+
* this work is wasted because the children do not change between frames.
|
|
127759
|
+
*
|
|
127760
|
+
* This subclass caches the concatenated output. Callers are responsible for
|
|
127761
|
+
* invalidating the container when a child mutates internally; structural
|
|
127762
|
+
* changes (`addChild`, `removeChild`, `clear`) automatically mark the cache
|
|
127763
|
+
* dirty.
|
|
127764
|
+
*/
|
|
127765
|
+
var CachedContainer = class extends Container {
|
|
127766
|
+
cachedWidth;
|
|
127767
|
+
cachedLines;
|
|
127768
|
+
dirty = true;
|
|
127769
|
+
addChild(component) {
|
|
127770
|
+
super.addChild(component);
|
|
127771
|
+
this.markDirty();
|
|
127772
|
+
}
|
|
127773
|
+
removeChild(component) {
|
|
127774
|
+
super.removeChild(component);
|
|
127775
|
+
this.markDirty();
|
|
127776
|
+
}
|
|
127777
|
+
clear() {
|
|
127778
|
+
super.clear();
|
|
127779
|
+
this.markDirty();
|
|
127780
|
+
}
|
|
127781
|
+
invalidate() {
|
|
127782
|
+
super.invalidate();
|
|
127783
|
+
this.markDirty();
|
|
127784
|
+
}
|
|
127785
|
+
render(width) {
|
|
127786
|
+
if (!this.dirty && this.cachedWidth === width && this.cachedLines !== void 0) return this.cachedLines;
|
|
127787
|
+
this.cachedWidth = width;
|
|
127788
|
+
this.cachedLines = super.render(width);
|
|
127789
|
+
this.dirty = false;
|
|
127790
|
+
return this.cachedLines;
|
|
127791
|
+
}
|
|
127792
|
+
markDirty() {
|
|
127793
|
+
this.dirty = true;
|
|
127794
|
+
}
|
|
127795
|
+
};
|
|
127796
|
+
//#endregion
|
|
127450
127797
|
//#region src/tui/components/media/code-highlight.ts
|
|
127451
127798
|
/**
|
|
127452
127799
|
* Shared syntax-highlighting helpers for code previews
|
|
@@ -128640,7 +128987,7 @@ function extractPartialStringField(text, key) {
|
|
|
128640
128987
|
function parseArgsPreview(value) {
|
|
128641
128988
|
const previewText = value.slice(0, STREAMING_ARGS_PREVIEW_MAX_CHARS);
|
|
128642
128989
|
if (previewText.trim().length === 0) return {};
|
|
128643
|
-
if (value.length <=
|
|
128990
|
+
if (value.length <= 8192 && previewText.trimEnd().endsWith("}")) try {
|
|
128644
128991
|
const parsed = JSON.parse(previewText);
|
|
128645
128992
|
if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) return parsed;
|
|
128646
128993
|
} catch {}
|
|
@@ -128723,7 +129070,7 @@ var PrefixedWrappedLine = class {
|
|
|
128723
129070
|
return new Text(this.text, 0, 0).render(contentWidth).map((line, index) => index === 0 ? `${this.firstPrefix}${line}` : `${this.continuationPrefix}${line}`);
|
|
128724
129071
|
}
|
|
128725
129072
|
};
|
|
128726
|
-
var ToolCallComponent = class ToolCallComponent extends
|
|
129073
|
+
var ToolCallComponent = class ToolCallComponent extends CachedContainer {
|
|
128727
129074
|
workspaceDir;
|
|
128728
129075
|
expanded = false;
|
|
128729
129076
|
planExpanded = false;
|
|
@@ -128788,6 +129135,7 @@ var ToolCallComponent = class ToolCallComponent extends Container {
|
|
|
128788
129135
|
* only belong to one group at a time, so one listener slot is enough.
|
|
128789
129136
|
*/
|
|
128790
129137
|
onSnapshotChange;
|
|
129138
|
+
static HEADER_END_INDEX = 2;
|
|
128791
129139
|
constructor(toolCall, result, colors, ui, markdownTheme, workspaceDir) {
|
|
128792
129140
|
super();
|
|
128793
129141
|
this.workspaceDir = workspaceDir;
|
|
@@ -128858,6 +129206,7 @@ var ToolCallComponent = class ToolCallComponent extends Container {
|
|
|
128858
129206
|
this.disposed = true;
|
|
128859
129207
|
this.stopStreamingProgressTimer();
|
|
128860
129208
|
this.stopSubagentElapsedTimer();
|
|
129209
|
+
this.onSnapshotChange = void 0;
|
|
128861
129210
|
}
|
|
128862
129211
|
/**
|
|
128863
129212
|
* Injects plan body/path asynchronously. Only ExitPlanMode cards use
|
|
@@ -128868,7 +129217,7 @@ var ToolCallComponent = class ToolCallComponent extends Container {
|
|
|
128868
129217
|
setPlanInfo(info) {
|
|
128869
129218
|
if (this.toolCall.name !== "ExitPlanMode") return;
|
|
128870
129219
|
let changed = false;
|
|
128871
|
-
if (info.plan !== void 0 && info.plan.length > 0 && this.currentPlan !== info.plan) {
|
|
129220
|
+
if (str(this.toolCall.args["plan"]).length === 0 && info.plan !== void 0 && info.plan.length > 0 && this.currentPlan !== info.plan) {
|
|
128872
129221
|
this.currentPlan = info.plan;
|
|
128873
129222
|
changed = true;
|
|
128874
129223
|
}
|
|
@@ -129293,13 +129642,15 @@ var ToolCallComponent = class ToolCallComponent extends Container {
|
|
|
129293
129642
|
return (result.is_error ? chalk.hex(this.colors.error) : chalk.dim)(` · ${text}`);
|
|
129294
129643
|
}
|
|
129295
129644
|
rebuildContent() {
|
|
129645
|
+
this.markDirty();
|
|
129296
129646
|
while (this.children.length > this.callPreviewEndIndex) this.children.pop();
|
|
129297
129647
|
this.buildProgressBlock();
|
|
129298
129648
|
this.buildContent();
|
|
129299
129649
|
this.buildSubagentBlock();
|
|
129300
129650
|
}
|
|
129301
129651
|
rebuildBody() {
|
|
129302
|
-
|
|
129652
|
+
this.markDirty();
|
|
129653
|
+
while (this.children.length > ToolCallComponent.HEADER_END_INDEX) this.children.pop();
|
|
129303
129654
|
this.buildCallPreview();
|
|
129304
129655
|
this.callPreviewEndIndex = this.children.length;
|
|
129305
129656
|
this.buildProgressBlock();
|
|
@@ -132441,11 +132792,21 @@ function promptTextInput(host, title, opts) {
|
|
|
132441
132792
|
return promise;
|
|
132442
132793
|
}
|
|
132443
132794
|
function buildRoleAdditionalText(prefs) {
|
|
132444
|
-
const
|
|
132445
|
-
|
|
132446
|
-
|
|
132447
|
-
|
|
132448
|
-
|
|
132795
|
+
const lines = [
|
|
132796
|
+
"# USER PREFERENCES (set via /like — HIGHEST PRIORITY)",
|
|
132797
|
+
"",
|
|
132798
|
+
"The user has explicitly configured the following preferences via /like.",
|
|
132799
|
+
"These are direct user instructions and override default behavior. You MUST",
|
|
132800
|
+
"apply them in EVERY response. Violating them is equivalent to ignoring an",
|
|
132801
|
+
"explicit user request."
|
|
132802
|
+
];
|
|
132803
|
+
const items = [];
|
|
132804
|
+
if (prefs.nickname !== void 0 && prefs.nickname.trim().length > 0) items.push(`- Nickname: address the user as "${prefs.nickname.trim()}".`);
|
|
132805
|
+
if (prefs.tone !== void 0 && prefs.tone.trim().length > 0) items.push(`- Tone: respond in ${prefs.tone.trim()} tone.`);
|
|
132806
|
+
if (prefs.other !== void 0 && prefs.other.trim().length > 0) items.push(`- Other: ${prefs.other.trim()}`);
|
|
132807
|
+
if (items.length === 0) return "";
|
|
132808
|
+
lines.push("", ...items, "", "用户通过 /like 设置的偏好具有最高优先级,每次回复都必须遵守。");
|
|
132809
|
+
return lines.join("\n");
|
|
132449
132810
|
}
|
|
132450
132811
|
async function getUserPrefsPath() {
|
|
132451
132812
|
return join(getDataDir(), "user-prefs.md");
|
|
@@ -136015,7 +136376,7 @@ var StreamingUIController = class {
|
|
|
136015
136376
|
renderMode: "markdown",
|
|
136016
136377
|
content: ""
|
|
136017
136378
|
};
|
|
136018
|
-
const component = new AssistantMessageComponent(state.theme.markdownTheme, state.theme.colors);
|
|
136379
|
+
const component = new AssistantMessageComponent(state.theme.markdownTheme, state.theme.colors, true, state.ui);
|
|
136019
136380
|
this._streamingBlock = {
|
|
136020
136381
|
component,
|
|
136021
136382
|
entry
|
|
@@ -137491,52 +137852,6 @@ function basenameLike(raw) {
|
|
|
137491
137852
|
return raw.split(/[\\/]/).filter((part) => part.length > 0).at(-1) ?? raw;
|
|
137492
137853
|
}
|
|
137493
137854
|
//#endregion
|
|
137494
|
-
//#region src/tui/utils/cached-container.ts
|
|
137495
|
-
/**
|
|
137496
|
-
* A Container that caches its rendered lines until explicitly invalidated or
|
|
137497
|
-
* its child list changes.
|
|
137498
|
-
*
|
|
137499
|
-
* pi-tui's built-in `Container.render()` walks and concatenates every child on
|
|
137500
|
-
* every frame. For large static subtrees (e.g., committed transcript history)
|
|
137501
|
-
* this work is wasted because the children do not change between frames.
|
|
137502
|
-
*
|
|
137503
|
-
* This subclass caches the concatenated output. Callers are responsible for
|
|
137504
|
-
* invalidating the container when a child mutates internally; structural
|
|
137505
|
-
* changes (`addChild`, `removeChild`, `clear`) automatically mark the cache
|
|
137506
|
-
* dirty.
|
|
137507
|
-
*/
|
|
137508
|
-
var CachedContainer = class extends Container {
|
|
137509
|
-
cachedWidth;
|
|
137510
|
-
cachedLines;
|
|
137511
|
-
dirty = true;
|
|
137512
|
-
addChild(component) {
|
|
137513
|
-
super.addChild(component);
|
|
137514
|
-
this.markDirty();
|
|
137515
|
-
}
|
|
137516
|
-
removeChild(component) {
|
|
137517
|
-
super.removeChild(component);
|
|
137518
|
-
this.markDirty();
|
|
137519
|
-
}
|
|
137520
|
-
clear() {
|
|
137521
|
-
super.clear();
|
|
137522
|
-
this.markDirty();
|
|
137523
|
-
}
|
|
137524
|
-
invalidate() {
|
|
137525
|
-
super.invalidate();
|
|
137526
|
-
this.markDirty();
|
|
137527
|
-
}
|
|
137528
|
-
render(width) {
|
|
137529
|
-
if (!this.dirty && this.cachedWidth === width && this.cachedLines !== void 0) return this.cachedLines;
|
|
137530
|
-
this.cachedWidth = width;
|
|
137531
|
-
this.cachedLines = super.render(width);
|
|
137532
|
-
this.dirty = false;
|
|
137533
|
-
return this.cachedLines;
|
|
137534
|
-
}
|
|
137535
|
-
markDirty() {
|
|
137536
|
-
this.dirty = true;
|
|
137537
|
-
}
|
|
137538
|
-
};
|
|
137539
|
-
//#endregion
|
|
137540
137855
|
//#region src/tui/components/transcript/committed-transcript.ts
|
|
137541
137856
|
var CommittedMessageComponent = class {
|
|
137542
137857
|
entry;
|
|
@@ -137802,6 +138117,7 @@ var TranscriptController = class TranscriptController {
|
|
|
137802
138117
|
this.committedComponent = void 0;
|
|
137803
138118
|
this.liveComponentToEntry.clear();
|
|
137804
138119
|
this.pendingComponents.clear();
|
|
138120
|
+
for (const child of state.transcriptContainer.children) if (hasDispose(child)) child.dispose();
|
|
137805
138121
|
state.transcriptContainer.clear();
|
|
137806
138122
|
this.clearTerminalInlineImages();
|
|
137807
138123
|
state.todoPanel.clear();
|
|
@@ -139335,6 +139651,7 @@ var InputController = class {
|
|
|
139335
139651
|
host;
|
|
139336
139652
|
lastHistoryContent;
|
|
139337
139653
|
breatheTimer = null;
|
|
139654
|
+
breatheTimeout = null;
|
|
139338
139655
|
/** Once the user types, breathing stops permanently (same as welcome). */
|
|
139339
139656
|
breatheOnceStopped = false;
|
|
139340
139657
|
fusionPlanComponent;
|
|
@@ -139537,6 +139854,10 @@ var InputController = class {
|
|
|
139537
139854
|
/** Stop the idle breathing timer. Safe to call when not breathing. */
|
|
139538
139855
|
dispose() {
|
|
139539
139856
|
this.#stopBreathing();
|
|
139857
|
+
if (this.breatheTimeout !== null) {
|
|
139858
|
+
clearTimeout(this.breatheTimeout);
|
|
139859
|
+
this.breatheTimeout = null;
|
|
139860
|
+
}
|
|
139540
139861
|
}
|
|
139541
139862
|
/**
|
|
139542
139863
|
* Stop the editor border breathing animation while streaming. Called
|
|
@@ -139552,6 +139873,10 @@ var InputController = class {
|
|
|
139552
139873
|
#permanentlyStopBreathing() {
|
|
139553
139874
|
this.breatheOnceStopped = true;
|
|
139554
139875
|
this.#stopBreathing();
|
|
139876
|
+
if (this.breatheTimeout !== null) {
|
|
139877
|
+
clearTimeout(this.breatheTimeout);
|
|
139878
|
+
this.breatheTimeout = null;
|
|
139879
|
+
}
|
|
139555
139880
|
const colorToken = this.host.state.theme.colors.primary;
|
|
139556
139881
|
this.host.state.editor.borderColor = (s) => chalk.hex(colorToken)(s);
|
|
139557
139882
|
this.host.state.ui.requestRender();
|
|
@@ -139559,6 +139884,7 @@ var InputController = class {
|
|
|
139559
139884
|
#startBreathing() {
|
|
139560
139885
|
if (this.breatheTimer) return;
|
|
139561
139886
|
if (this.breatheOnceStopped) return;
|
|
139887
|
+
resetBreathingClock();
|
|
139562
139888
|
const primaryHex = this.host.state.theme.colors.primary;
|
|
139563
139889
|
const [r, g, b] = hexToRgb$1(primaryHex);
|
|
139564
139890
|
const [baseHue] = rgbToHsl$1(r, g, b);
|
|
@@ -139569,6 +139895,9 @@ var InputController = class {
|
|
|
139569
139895
|
editor.borderColor = (s) => chalk.hex(hex)(s);
|
|
139570
139896
|
ui.requestRender();
|
|
139571
139897
|
}, BREATHE_INTERVAL_MS);
|
|
139898
|
+
if (this.breatheTimeout === null) this.breatheTimeout = setTimeout(() => {
|
|
139899
|
+
this.#permanentlyStopBreathing();
|
|
139900
|
+
}, BREATHE_CYCLE_MS);
|
|
139572
139901
|
}
|
|
139573
139902
|
#stopBreathing() {
|
|
139574
139903
|
if (!this.breatheTimer) return;
|
|
@@ -140359,7 +140688,6 @@ function toTerminalHyperlink(text, url) {
|
|
|
140359
140688
|
}
|
|
140360
140689
|
//#endregion
|
|
140361
140690
|
//#region src/tui/components/chrome/footer.ts
|
|
140362
|
-
const MAX_CWD_SEGMENTS = 3;
|
|
140363
140691
|
const TOOLBAR_TIPS = [
|
|
140364
140692
|
{ text: "shift+tab: 计划模式" },
|
|
140365
140693
|
{ text: "/model: 切换模型" },
|
|
@@ -140432,16 +140760,6 @@ function modelDisplayName(state) {
|
|
|
140432
140760
|
const model = state.availableModels[state.model];
|
|
140433
140761
|
return model?.displayName ?? model?.model ?? state.model;
|
|
140434
140762
|
}
|
|
140435
|
-
function shortenCwd(path) {
|
|
140436
|
-
if (!path) return path;
|
|
140437
|
-
const home = process.env["HOME"] ?? "";
|
|
140438
|
-
let work = path;
|
|
140439
|
-
if (home && path === home) return "~";
|
|
140440
|
-
if (home && path.startsWith(home + "/")) work = "~" + path.slice(home.length);
|
|
140441
|
-
const segments = work.split("/").filter((s) => s.length > 0);
|
|
140442
|
-
if (segments.length <= MAX_CWD_SEGMENTS) return work;
|
|
140443
|
-
return `…/${segments.slice(-3).join("/")}`;
|
|
140444
|
-
}
|
|
140445
140763
|
function formatTokenCount(n) {
|
|
140446
140764
|
if (n >= 1e6) return `${(n / 1e6).toFixed(1)}M`;
|
|
140447
140765
|
if (n >= 1e3) return `${(n / 1e3).toFixed(1)}k`;
|
|
@@ -140635,8 +140953,6 @@ var FooterComponent = class {
|
|
|
140635
140953
|
const noun = this.backgroundAgentCount === 1 ? "个代理" : "个代理";
|
|
140636
140954
|
left.push(chalk.hex(colors.primary)(`[${String(this.backgroundAgentCount)}${noun} 运行中]`));
|
|
140637
140955
|
}
|
|
140638
|
-
const cwd = shortenCwd(state.workDir);
|
|
140639
|
-
if (cwd) left.push(chalk.hex(colors.status)(cwd));
|
|
140640
140956
|
const git = this.gitCache.getStatus();
|
|
140641
140957
|
if (git !== null) left.push(formatFooterGitBadge(git, colors));
|
|
140642
140958
|
const leftLine = left.join(" ");
|