scream-code 0.3.9 → 0.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.mjs +37 -30
- package/package.json +24 -24
package/dist/main.mjs
CHANGED
|
@@ -72470,7 +72470,9 @@ var MemoryMemoStore = class {
|
|
|
72470
72470
|
};
|
|
72471
72471
|
//#endregion
|
|
72472
72472
|
//#region ../../packages/memory/src/extractor.ts
|
|
72473
|
-
/**
|
|
72473
|
+
/**
|
|
72474
|
+
* Parse memory-memo blocks from LLM compaction output.
|
|
72475
|
+
*/
|
|
72474
72476
|
function parseMemoryMemos(text) {
|
|
72475
72477
|
const memos = [];
|
|
72476
72478
|
const regex = /```memory-memo[\s\S]*?\n([\s\S]*?)```/g;
|
|
@@ -72830,6 +72832,12 @@ var DreamTracker = class {
|
|
|
72830
72832
|
/** Max consecutive compaction failures before auto-compaction is
|
|
72831
72833
|
* disabled for the remainder of the turn. Resets each turn. */
|
|
72832
72834
|
const MAX_CONSECUTIVE_FAILURES = 3;
|
|
72835
|
+
/** Minimal system prompt used during compaction. The full agent system
|
|
72836
|
+
* prompt contains tool descriptions and runtime injections that contradict
|
|
72837
|
+
* the compaction instruction ("DO NOT CALL ANY TOOLS"). This compact prompt
|
|
72838
|
+
* keeps the LLM focused and explicitly references the memory-memo extraction
|
|
72839
|
+
* section inside compaction-instruction.md. */
|
|
72840
|
+
const COMPACTION_SYSTEM_PROMPT = "You are a conversation context compaction assistant. Your job is to summarize the conversation above into a structured summary. Output text only. DO NOT CALL ANY TOOLS. Follow the compaction instruction in the last user message exactly. Pay special attention to the Memory Memo Extraction section — you MUST output memory-memo blocks for every completed task loop.";
|
|
72833
72841
|
var FullCompaction = class {
|
|
72834
72842
|
agent;
|
|
72835
72843
|
compactionCountInTurn = 0;
|
|
@@ -72998,7 +73006,7 @@ var FullCompaction = class {
|
|
|
72998
73006
|
}];
|
|
72999
73007
|
class TruncatedError extends Error {}
|
|
73000
73008
|
try {
|
|
73001
|
-
const response = await this.agent.generate(this.agent.config.provider,
|
|
73009
|
+
const response = await this.agent.generate(this.agent.config.provider, COMPACTION_SYSTEM_PROMPT, [], messages, void 0, { signal });
|
|
73002
73010
|
if (response.finishReason === "truncated") throw new TruncatedError();
|
|
73003
73011
|
usage = response.usage;
|
|
73004
73012
|
summary = extractCompactionSummary(response);
|
|
@@ -73114,16 +73122,15 @@ var FullCompaction = class {
|
|
|
73114
73122
|
if (memos.length === 0) return;
|
|
73115
73123
|
const sessionId = this.agent.homedir ? basename$1(dirname$2(dirname$2(this.agent.homedir))) : "unknown";
|
|
73116
73124
|
const sessionTitle = await this.agent.getSessionTitle();
|
|
73117
|
-
|
|
73125
|
+
const failed = (await Promise.allSettled(memos.map((memo) => {
|
|
73118
73126
|
memo.sourceSessionId = sessionId;
|
|
73119
73127
|
memo.sourceSessionTitle = sessionTitle ?? "";
|
|
73120
|
-
memoStore.append(memo)
|
|
73121
|
-
|
|
73122
|
-
|
|
73123
|
-
|
|
73124
|
-
|
|
73125
|
-
|
|
73126
|
-
}
|
|
73128
|
+
return memoStore.append(memo);
|
|
73129
|
+
}))).filter((r) => r.status === "rejected").length;
|
|
73130
|
+
if (failed > 0) this.agent.log.warn("Some memory memos failed to store from compaction", {
|
|
73131
|
+
failed,
|
|
73132
|
+
total: memos.length
|
|
73133
|
+
});
|
|
73127
73134
|
this.agent.log.info("Extracted memory memos from compaction", {
|
|
73128
73135
|
count: memos.length,
|
|
73129
73136
|
sessionId
|
|
@@ -91534,17 +91541,17 @@ var Agent = class {
|
|
|
91534
91541
|
}]);
|
|
91535
91542
|
const memos = parseMemoryMemos(typeof response.message.content === "string" ? response.message.content : response.message.content.map((p) => p.type === "text" ? p.text : "").join(""));
|
|
91536
91543
|
if (memos.length === 0) return;
|
|
91537
|
-
|
|
91544
|
+
const store = this.memoStore;
|
|
91545
|
+
const failed = (await Promise.allSettled(memos.map((memo) => {
|
|
91538
91546
|
memo.sourceSessionId = sessionId;
|
|
91539
91547
|
memo.sourceSessionTitle = sessionTitle ?? "";
|
|
91540
91548
|
memo.extractionSource = "exit";
|
|
91541
|
-
|
|
91542
|
-
|
|
91543
|
-
|
|
91544
|
-
|
|
91545
|
-
|
|
91546
|
-
|
|
91547
|
-
}
|
|
91549
|
+
return store.append(memo);
|
|
91550
|
+
}))).filter((r) => r.status === "rejected").length;
|
|
91551
|
+
if (failed > 0) this.log.warn("Some memory memos failed to store from exit extraction", {
|
|
91552
|
+
failed,
|
|
91553
|
+
total: memos.length
|
|
91554
|
+
});
|
|
91548
91555
|
this.log.info("Extracted memory memos on session exit", {
|
|
91549
91556
|
count: memos.length,
|
|
91550
91557
|
sessionId
|
|
@@ -115245,10 +115252,10 @@ var Session = class {
|
|
|
115245
115252
|
}
|
|
115246
115253
|
async close() {
|
|
115247
115254
|
if (this.closed) return;
|
|
115248
|
-
this.closed = true;
|
|
115249
115255
|
try {
|
|
115250
115256
|
await Promise.race([this.extractMemoriesOnExit(), new Promise((resolve) => setTimeout(resolve, 3e4))]).catch(() => {});
|
|
115251
115257
|
} catch {}
|
|
115258
|
+
this.closed = true;
|
|
115252
115259
|
try {
|
|
115253
115260
|
await this.rpc.closeSession({ sessionId: this.id });
|
|
115254
115261
|
} finally {
|
|
@@ -133820,23 +133827,20 @@ var DialogManager = class {
|
|
|
133820
133827
|
}
|
|
133821
133828
|
}));
|
|
133822
133829
|
}
|
|
133823
|
-
showMemoryPicker() {
|
|
133830
|
+
showMemoryPicker(preloadedMemos, preloadedTotal) {
|
|
133824
133831
|
const store = new MemoryMemoStore(resolveProjectDir(getDataDir(), this.host.getCurrentWorkDir()));
|
|
133825
|
-
|
|
133826
|
-
|
|
133827
|
-
|
|
133828
|
-
|
|
133829
|
-
|
|
133830
|
-
|
|
133831
|
-
if (this.host.state.activeDialog === "memory-picker") this.showMemoryPicker();
|
|
133832
|
-
});
|
|
133833
|
-
} catch {}
|
|
133832
|
+
const hasData = preloadedMemos !== void 0;
|
|
133833
|
+
const memos = preloadedMemos ?? [];
|
|
133834
|
+
const total = preloadedTotal ?? 0;
|
|
133835
|
+
if (!hasData) store.list({ limit: 50 }).then((result) => {
|
|
133836
|
+
if (this.host.state.activeDialog === "memory-picker") this.showMemoryPicker(result.memos, result.total);
|
|
133837
|
+
}).catch(() => {});
|
|
133834
133838
|
this.host.state.activeDialog = "memory-picker";
|
|
133835
133839
|
this.mountEditorReplacement(new MemoryPickerComponent({
|
|
133836
133840
|
store,
|
|
133837
133841
|
memos,
|
|
133838
133842
|
total,
|
|
133839
|
-
loading:
|
|
133843
|
+
loading: !hasData,
|
|
133840
133844
|
colors: this.host.state.theme.colors,
|
|
133841
133845
|
onCancel: () => {
|
|
133842
133846
|
this.host.state.activeDialog = null;
|
|
@@ -134159,6 +134163,9 @@ var ScreamTUI = class {
|
|
|
134159
134163
|
for (const dispose of this.reverseRpcDisposers) dispose();
|
|
134160
134164
|
this.reverseRpcDisposers.length = 0;
|
|
134161
134165
|
this.disposeTerminalTracking();
|
|
134166
|
+
this.state.footer.setTransientHint("正在整理会话记忆...");
|
|
134167
|
+
this.state.ui.requestRender();
|
|
134168
|
+
await new Promise((r) => setTimeout(r, 0));
|
|
134162
134169
|
await this.closeSession();
|
|
134163
134170
|
await this.harness.close();
|
|
134164
134171
|
this.sessionEventHandler.stopAllMcpServerStatusSpinners();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scream-code",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.10",
|
|
4
4
|
"description": "The Starting Point for Next-Gen Agents",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "ScreamCli",
|
|
@@ -40,21 +40,7 @@
|
|
|
40
40
|
},
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public",
|
|
43
|
-
"provenance":
|
|
44
|
-
},
|
|
45
|
-
"scripts": {
|
|
46
|
-
"build": "tsdown",
|
|
47
|
-
"dev": "node scripts/dev.mjs",
|
|
48
|
-
"dev:cli-only": "tsx --import ../../build/register-raw-text-loader.mjs ./src/main.ts",
|
|
49
|
-
"dev:prod": "node dist/main.mjs",
|
|
50
|
-
"clean": "rm -rf dist",
|
|
51
|
-
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
52
|
-
"test": "pnpm -w run build:packages && vitest run",
|
|
53
|
-
"e2e": "pnpm -w run build:packages && SCREAM_E2E=1 vitest run test/e2e",
|
|
54
|
-
"e2e:real": "pnpm -w run build:packages && SCREAM_E2E_REAL=1 vitest run test/e2e/real-llm-smoke.e2e.test.ts",
|
|
55
|
-
"preinstall": "node -e \"console.log('\\n📦 正在安装 scream-code,请稍候...\\n')\"",
|
|
56
|
-
"postinstall": "node scripts/postinstall.mjs",
|
|
57
|
-
"smoke": "node dist/main.mjs --version"
|
|
43
|
+
"provenance": false
|
|
58
44
|
},
|
|
59
45
|
"dependencies": {
|
|
60
46
|
"@earendil-works/pi-tui": "^0.78.1",
|
|
@@ -68,16 +54,30 @@
|
|
|
68
54
|
},
|
|
69
55
|
"devDependencies": {
|
|
70
56
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
71
|
-
"@scream-cli/agent-core": "workspace:^",
|
|
72
|
-
"@scream-cli/config": "workspace:^",
|
|
73
|
-
"@scream-cli/migration-legacy": "workspace:^",
|
|
74
|
-
"@scream-cli/scream-code-sdk": "workspace:^",
|
|
75
|
-
"@scream-cli/scream-telemetry": "workspace:^",
|
|
76
|
-
"@scream-code/memory": "workspace:*",
|
|
77
57
|
"@types/semver": "^7.7.0",
|
|
78
|
-
"tsx": "^4.21.0"
|
|
58
|
+
"tsx": "^4.21.0",
|
|
59
|
+
"@scream-cli/agent-core": "^0.3.10",
|
|
60
|
+
"@scream-cli/config": "^0.3.10",
|
|
61
|
+
"@scream-cli/scream-code-sdk": "^0.3.10",
|
|
62
|
+
"@scream-cli/migration-legacy": "^0.3.10",
|
|
63
|
+
"@scream-cli/scream-telemetry": "^0.3.10",
|
|
64
|
+
"@scream-code/memory": "0.3.10"
|
|
79
65
|
},
|
|
80
66
|
"engines": {
|
|
81
67
|
"node": ">=22.19.0"
|
|
68
|
+
},
|
|
69
|
+
"scripts": {
|
|
70
|
+
"build": "tsdown",
|
|
71
|
+
"dev": "node scripts/dev.mjs",
|
|
72
|
+
"dev:cli-only": "tsx --import ../../build/register-raw-text-loader.mjs ./src/main.ts",
|
|
73
|
+
"dev:prod": "node dist/main.mjs",
|
|
74
|
+
"clean": "rm -rf dist",
|
|
75
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
76
|
+
"test": "pnpm -w run build:packages && vitest run",
|
|
77
|
+
"e2e": "pnpm -w run build:packages && SCREAM_E2E=1 vitest run test/e2e",
|
|
78
|
+
"e2e:real": "pnpm -w run build:packages && SCREAM_E2E_REAL=1 vitest run test/e2e/real-llm-smoke.e2e.test.ts",
|
|
79
|
+
"preinstall": "node -e \"console.log('\\n📦 正在安装 scream-code,请稍候...\\n')\"",
|
|
80
|
+
"postinstall": "node scripts/postinstall.mjs",
|
|
81
|
+
"smoke": "node dist/main.mjs --version"
|
|
82
82
|
}
|
|
83
|
-
}
|
|
83
|
+
}
|