scream-code 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/main.mjs +52 -17
  2. package/package.json +2 -2
package/dist/main.mjs CHANGED
@@ -55982,7 +55982,7 @@ var GoalMode = class {
55982
55982
  if (state === void 0 || state.status !== "active") return null;
55983
55983
  return this.toSnapshot(state);
55984
55984
  }
55985
- async createGoal(input, actor = "user") {
55985
+ async createGoal(input, _actor = "user") {
55986
55986
  const objective = input.objective.trim();
55987
55987
  if (objective.length === 0) throw new ScreamError(ErrorCodes.GOAL_OBJECTIVE_EMPTY, "Goal objective cannot be empty");
55988
55988
  if (objective.length > MAX_GOAL_OBJECTIVE_LENGTH) throw new ScreamError(ErrorCodes.GOAL_OBJECTIVE_TOO_LONG, `Goal objective cannot exceed ${MAX_GOAL_OBJECTIVE_LENGTH} characters`);
@@ -56056,7 +56056,7 @@ var GoalMode = class {
56056
56056
  this.appendStatusUpdate(state, actor, input.reason);
56057
56057
  return this.toSnapshot(state);
56058
56058
  }
56059
- async setBudgetLimits(input, actor = "user") {
56059
+ async setBudgetLimits(input, _actor = "user") {
56060
56060
  const state = this.requireState();
56061
56061
  state.budgetLimits = {
56062
56062
  ...state.budgetLimits,
@@ -73362,18 +73362,21 @@ var MemoryMemoStore = class {
73362
73362
  const record = JSON.parse(rawLine);
73363
73363
  if (record["type"] !== "memory_memo" || !record["entry"]) return void 0;
73364
73364
  const entry = record["entry"];
73365
- if (record["version"] === 1 || entry["userRequirement"] !== void 0 && entry["userNeed"] === void 0) return {
73366
- id: String(entry["id"] ?? ""),
73367
- sourceSessionId: String(entry["sourceSessionId"] ?? ""),
73368
- sourceSessionTitle: typeof entry["sourceSessionTitle"] === "string" ? entry["sourceSessionTitle"] : void 0,
73369
- userNeed: String(entry["userRequirement"] ?? ""),
73370
- approach: String(entry["solution"] ?? ""),
73371
- outcome: String(entry["completionStatus"] ?? ""),
73372
- whatFailed: String(entry["problemsEncountered"] ?? "none"),
73373
- whatWorked: "none",
73374
- extractionSource: entry["extractionSource"] === "exit" ? "exit" : "compaction",
73375
- recordedAt: Number(entry["recordedAt"] ?? 0)
73376
- };
73365
+ if (record["version"] === 1 || entry["userRequirement"] !== void 0 && entry["userNeed"] === void 0) {
73366
+ const str = (v, fallback = "") => typeof v === "string" ? v : fallback;
73367
+ return {
73368
+ id: str(entry["id"]),
73369
+ sourceSessionId: str(entry["sourceSessionId"]),
73370
+ sourceSessionTitle: str(entry["sourceSessionTitle"], void 0),
73371
+ userNeed: str(entry["userRequirement"]),
73372
+ approach: str(entry["solution"]),
73373
+ outcome: str(entry["completionStatus"]),
73374
+ whatFailed: str(entry["problemsEncountered"], "none"),
73375
+ whatWorked: "none",
73376
+ extractionSource: entry["extractionSource"] === "exit" ? "exit" : "compaction",
73377
+ recordedAt: typeof entry["recordedAt"] === "number" ? entry["recordedAt"] : 0
73378
+ };
73379
+ }
73377
73380
  return entry;
73378
73381
  } catch {
73379
73382
  return;
@@ -121887,7 +121890,7 @@ function wrap(text, width, maxLines) {
121887
121890
  let current = "";
121888
121891
  for (const word of words) {
121889
121892
  const candidate = current.length === 0 ? word : `${current} ${word}`;
121890
- if (candidate.length > width && current.length > 0) {
121893
+ if (visibleWidth(candidate) > width && current.length > 0) {
121891
121894
  lines.push(current);
121892
121895
  current = word;
121893
121896
  } else current = candidate;
@@ -130460,6 +130463,7 @@ var StreamingUIController = class {
130460
130463
  }
130461
130464
  this.host.setAppState({ streamingPhase: "idle" });
130462
130465
  this.host.resetLivePane();
130466
+ this.host.onTurnCompleted();
130463
130467
  notifyTerminalOnce(state, `turn-complete:${completedTurnKey}`, {
130464
130468
  title: "Scream Code 任务完成",
130465
130469
  body: state.appState.sessionTitle ?? void 0
@@ -133609,6 +133613,7 @@ var SessionManager = class {
133609
133613
  this.host.showError("历史回放期间无法启动新会话。");
133610
133614
  return;
133611
133615
  }
133616
+ await this.extractMemoriesBeforeSwitch();
133612
133617
  let session;
133613
133618
  try {
133614
133619
  session = await this.createSessionFromCurrentState();
@@ -133666,6 +133671,20 @@ var SessionManager = class {
133666
133671
  this.host.updateQueueDisplay();
133667
133672
  this.host.stopMemoryIdleTimer();
133668
133673
  }
133674
+ async extractMemoriesBeforeSwitch() {
133675
+ const session = this.host.session;
133676
+ if (session === void 0) return;
133677
+ if (this.host.state.appState.streamingPhase !== "idle") return;
133678
+ this.host.state.footer.setTransientHint("正在整理会话记忆...");
133679
+ this.host.state.ui.requestRender();
133680
+ try {
133681
+ await Promise.race([session.extractMemoriesOnExit(), new Promise((resolve) => setTimeout(resolve, 3e4))]);
133682
+ this.host.showStatus("已沉淀关键信息至记忆备忘录");
133683
+ } catch {} finally {
133684
+ this.host.state.footer.setTransientHint(null);
133685
+ this.host.state.ui.requestRender();
133686
+ }
133687
+ }
133669
133688
  requireSession() {
133670
133689
  if (this.host.session === void 0) throw new Error(NO_ACTIVE_SESSION_MESSAGE);
133671
133690
  return this.host.session;
@@ -134297,6 +134316,7 @@ function sourceLabel(source) {
134297
134316
  var MemoryPickerComponent = class extends Container {
134298
134317
  store;
134299
134318
  colors;
134319
+ ui;
134300
134320
  onCancel;
134301
134321
  onInject;
134302
134322
  focused = false;
@@ -134317,11 +134337,13 @@ var MemoryPickerComponent = class extends Container {
134317
134337
  this.total = opts.total;
134318
134338
  this.loading = opts.loading;
134319
134339
  this.colors = opts.colors;
134340
+ this.ui = opts.ui;
134320
134341
  this.onCancel = opts.onCancel;
134321
134342
  this.onInject = opts.onInject;
134322
134343
  }
134323
134344
  async loadMemos() {
134324
134345
  this.loading = true;
134346
+ this.ui?.requestRender();
134325
134347
  try {
134326
134348
  const result = await this.store.list({
134327
134349
  limit: 50,
@@ -134335,6 +134357,7 @@ var MemoryPickerComponent = class extends Container {
134335
134357
  this.total = 0;
134336
134358
  } finally {
134337
134359
  this.loading = false;
134360
+ this.ui?.requestRender();
134338
134361
  }
134339
134362
  }
134340
134363
  handleInput(data) {
@@ -134426,6 +134449,7 @@ var MemoryPickerComponent = class extends Container {
134426
134449
  this.detailMemo = null;
134427
134450
  }
134428
134451
  if (this.detailMemo) this.mode = "detail";
134452
+ this.ui?.requestRender();
134429
134453
  }
134430
134454
  async deleteAndReload(id) {
134431
134455
  try {
@@ -134434,6 +134458,7 @@ var MemoryPickerComponent = class extends Container {
134434
134458
  await this.loadMemos();
134435
134459
  this.mode = "list";
134436
134460
  if (this.selectedIndex >= this.memos.length) this.selectedIndex = Math.max(0, this.memos.length - 1);
134461
+ this.ui?.requestRender();
134437
134462
  }
134438
134463
  render(width) {
134439
134464
  const c = this.colors;
@@ -135449,6 +135474,7 @@ var DialogManager = class {
135449
135474
  total,
135450
135475
  loading: !hasData,
135451
135476
  colors: this.host.state.theme.colors,
135477
+ ui: this.host.state.ui,
135452
135478
  onCancel: () => {
135453
135479
  this.host.state.activeDialog = null;
135454
135480
  this.restoreEditor();
@@ -135819,16 +135845,25 @@ var ScreamTUI = class ScreamTUI {
135819
135845
  if (this.state.appState.isReplaying) return;
135820
135846
  const session = this.session;
135821
135847
  if (session === void 0) return;
135848
+ this.state.footer.setTransientHint("正在整理会话记忆...");
135849
+ this.state.ui.requestRender();
135822
135850
  try {
135823
135851
  await session.extractMemoriesOnExit();
135824
135852
  this.lastMemoryExtractionTime = Date.now();
135825
135853
  this.showStatus("已沉淀关键信息至记忆备忘录");
135826
- } catch {}
135854
+ } catch {} finally {
135855
+ this.state.footer.setTransientHint(null);
135856
+ this.state.ui.requestRender();
135857
+ }
135827
135858
  }
135828
135859
  /** Called after compaction extraction to avoid duplicate idle extraction within cooldown. */
135829
135860
  markMemoryExtracted() {
135830
135861
  this.lastMemoryExtractionTime = Date.now();
135831
135862
  }
135863
+ /** Called by StreamingUIController when a turn finishes with no queued continuations. */
135864
+ onTurnCompleted() {
135865
+ this.startMemoryIdleTimer();
135866
+ }
135832
135867
  /** Trigger an immediate cc-connect liveness poll. Called by /cc after start/stop/restart. */
135833
135868
  refreshCcStatus() {
135834
135869
  setTimeout(() => {
@@ -135910,7 +135945,7 @@ var ScreamTUI = class ScreamTUI {
135910
135945
  }
135911
135946
  this.persistInputHistory(text);
135912
135947
  dispatchInput(this, text);
135913
- this.startMemoryIdleTimer();
135948
+ this.stopMemoryIdleTimer();
135914
135949
  }
135915
135950
  sendNormalUserInput(text) {
135916
135951
  if (this.state.appState.model.trim().length === 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scream-code",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "The Starting Point for Next-Gen Agents",
5
5
  "license": "MIT",
6
6
  "author": "ScreamCli",
@@ -40,7 +40,7 @@
40
40
  },
41
41
  "publishConfig": {
42
42
  "access": "public",
43
- "provenance": true
43
+ "provenance": false
44
44
  },
45
45
  "scripts": {
46
46
  "build": "tsdown",