scream-code 0.10.0 → 0.10.2

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 CHANGED
@@ -6,7 +6,7 @@ const __dirname = __cjsShimDirname(__filename);
6
6
  import "./suppress-sqlite-warning-C2VB0doZ.mjs";
7
7
  //#region src/main.ts
8
8
  try {
9
- (await import("./app-Bda9iKUb.mjs")).main();
9
+ (await import("./app-VZDNiLvJ.mjs")).main();
10
10
  } catch (error) {
11
11
  process.stderr.write(`${error instanceof Error ? error.stack ?? error.message : String(error)}\n`);
12
12
  process.exit(1);
@@ -3,5 +3,5 @@ import { fileURLToPath as __cjsShimFileURLToPath } from 'node:url';
3
3
  import { dirname as __cjsShimDirname } from 'node:path';
4
4
  const __filename = __cjsShimFileURLToPath(import.meta.url);
5
5
  const __dirname = __cjsShimDirname(__filename);
6
- import { n as multiSearchWithTrace } from "./src-1LHYB0xM.mjs";
6
+ import { n as multiSearchWithTrace } from "./src-oeUnRY3N.mjs";
7
7
  export { multiSearchWithTrace };
@@ -214,7 +214,10 @@ var KnowledgeStore = class {
214
214
  }
215
215
  async init() {
216
216
  if (this.initPromise) return this.initPromise;
217
- this.initPromise = this._doInit();
217
+ this.initPromise = this._doInit().catch((error) => {
218
+ this.initPromise = null;
219
+ throw error;
220
+ });
218
221
  return this.initPromise;
219
222
  }
220
223
  async _doInit() {
@@ -225,8 +228,32 @@ var KnowledgeStore = class {
225
228
  this.db.exec("PRAGMA foreign_keys = ON;");
226
229
  this.db.exec("PRAGMA busy_timeout = 5000;");
227
230
  this.createSchema();
231
+ this.migrateFtsTokenization();
228
232
  this.initialized = true;
229
233
  }
234
+ /**
235
+ * One-time migration: FTS rows written before toFtsText pre-tokenization
236
+ * indexed raw text (CJK runs became single tokens and are unsearchable).
237
+ * Rebuild all three FTS tables from the content tables with toFtsText.
238
+ * Tracked via PRAGMA user_version so it runs exactly once.
239
+ */
240
+ migrateFtsTokenization() {
241
+ if (this.db === void 0) return;
242
+ if (this.db.prepare("PRAGMA user_version").get().user_version >= 1) return;
243
+ this.db.exec("DELETE FROM knowledge_chunks_fts");
244
+ this.db.exec("DELETE FROM knowledge_events_fts");
245
+ this.db.exec("DELETE FROM knowledge_entities_fts");
246
+ const chunks = this.db.prepare("SELECT rowid, heading, content FROM knowledge_chunks").all();
247
+ const insChunk = this.db.prepare("INSERT INTO knowledge_chunks_fts (rowid, heading, content) VALUES (?, ?, ?)");
248
+ for (const c of chunks) insChunk.run(c.rowid, toFtsText(c.heading ?? ""), toFtsText(c.content));
249
+ const events = this.db.prepare("SELECT rowid, title, summary, content FROM knowledge_events").all();
250
+ const insEvent = this.db.prepare("INSERT INTO knowledge_events_fts (rowid, title, summary, content) VALUES (?, ?, ?, ?)");
251
+ for (const e of events) insEvent.run(e.rowid, toFtsText(e.title), toFtsText(e.summary ?? ""), toFtsText(e.content));
252
+ const entities = this.db.prepare("SELECT rowid, name, description FROM knowledge_entities").all();
253
+ const insEntity = this.db.prepare("INSERT INTO knowledge_entities_fts (rowid, name, description) VALUES (?, ?, ?)");
254
+ for (const e of entities) insEntity.run(e.rowid, toFtsText(e.name), toFtsText(e.description ?? ""));
255
+ this.db.exec("PRAGMA user_version = 1");
256
+ }
230
257
  close() {
231
258
  if (this.db !== void 0) {
232
259
  this.db.exec("PRAGMA wal_checkpoint(TRUNCATE)");
@@ -392,7 +419,19 @@ var KnowledgeStore = class {
392
419
  async deleteSource(id) {
393
420
  await this.init();
394
421
  if (this.db === void 0) return false;
395
- return this.db.prepare("DELETE FROM knowledge_sources WHERE id = ?").run(id).changes > 0;
422
+ const chunkRows = this.db.prepare("SELECT rowid, heading, content FROM knowledge_chunks WHERE source_id = ?").all(id);
423
+ const eventRows = this.db.prepare("SELECT rowid, title, summary, content FROM knowledge_events WHERE source_id = ?").all(id);
424
+ const entityRows = this.db.prepare("SELECT rowid, name, description FROM knowledge_entities WHERE source_id = ?").all(id);
425
+ const result = this.db.prepare("DELETE FROM knowledge_sources WHERE id = ?").run(id);
426
+ if (result.changes > 0) {
427
+ const delChunk = this.db.prepare("INSERT INTO knowledge_chunks_fts (knowledge_chunks_fts, rowid, heading, content) VALUES ('delete', ?, ?, ?)");
428
+ for (const row of chunkRows) delChunk.run(row.rowid, toFtsText(row.heading ?? ""), toFtsText(row.content));
429
+ const delEvent = this.db.prepare("INSERT INTO knowledge_events_fts (knowledge_events_fts, rowid, title, summary, content) VALUES ('delete', ?, ?, ?, ?)");
430
+ for (const row of eventRows) delEvent.run(row.rowid, toFtsText(row.title), toFtsText(row.summary ?? ""), toFtsText(row.content));
431
+ const delEntity = this.db.prepare("INSERT INTO knowledge_entities_fts (knowledge_entities_fts, rowid, name, description) VALUES ('delete', ?, ?, ?)");
432
+ for (const row of entityRows) delEntity.run(row.rowid, toFtsText(row.name), toFtsText(row.description ?? ""));
433
+ }
434
+ return result.changes > 0;
396
435
  }
397
436
  async createDocument(params) {
398
437
  if (this.db === void 0) throw new Error("knowledge store not initialized");
@@ -440,7 +479,7 @@ var KnowledgeStore = class {
440
479
  (id, source_id, document_id, rank, heading, content, raw_content, embedding_json, created_at)
441
480
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(id, params.sourceId, params.documentId, params.rank, params.heading, params.content, params.rawContent, embeddingJson, createdAt);
442
481
  this.db.prepare(`INSERT INTO knowledge_chunks_fts (rowid, heading, content)
443
- VALUES ((SELECT rowid FROM knowledge_chunks WHERE id = ?), ?, ?)`).run(id, params.heading ?? "", params.content);
482
+ VALUES ((SELECT rowid FROM knowledge_chunks WHERE id = ?), ?, ?)`).run(id, toFtsText(params.heading ?? ""), toFtsText(params.content));
444
483
  return {
445
484
  id,
446
485
  sourceId: params.sourceId,
@@ -488,7 +527,7 @@ var KnowledgeStore = class {
488
527
  title_embedding_json, content_embedding_json, created_at)
489
528
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(id, params.sourceId, params.documentId, params.chunkId, params.rank, params.title, params.summary, params.content, params.category, JSON.stringify(params.keywords), vectorToJson(params.titleEmbedding), vectorToJson(params.contentEmbedding), createdAt);
490
529
  this.db.prepare(`INSERT INTO knowledge_events_fts (rowid, title, summary, content)
491
- VALUES ((SELECT rowid FROM knowledge_events WHERE id = ?), ?, ?, ?)`).run(id, params.title, params.summary ?? "", params.content);
530
+ VALUES ((SELECT rowid FROM knowledge_events WHERE id = ?), ?, ?, ?)`).run(id, toFtsText(params.title), toFtsText(params.summary ?? ""), toFtsText(params.content));
492
531
  return {
493
532
  id,
494
533
  sourceId: params.sourceId,
@@ -551,8 +590,24 @@ var KnowledgeStore = class {
551
590
  const normalizedName = normalizeName(params.name);
552
591
  const existing = this.db.prepare("SELECT * FROM knowledge_entities WHERE source_id = ? AND type = ? AND normalized_name = ?").get(params.sourceId, params.type, normalizedName);
553
592
  if (existing !== void 0) {
554
- if (params.description !== null && existing["description"] === null) this.db.prepare("UPDATE knowledge_entities SET description = ? WHERE id = ?").run(params.description, String(existing["id"]));
555
- if (params.embedding !== null && existing["embedding_json"] === null) this.db.prepare("UPDATE knowledge_entities SET embedding_json = ? WHERE id = ?").run(vectorToJson(params.embedding), String(existing["id"]));
593
+ const existingId = String(existing["id"]);
594
+ let descriptionChanged = false;
595
+ if (params.description !== null && existing["description"] === null) {
596
+ this.db.prepare("UPDATE knowledge_entities SET description = ? WHERE id = ?").run(params.description, existingId);
597
+ existing["description"] = params.description;
598
+ descriptionChanged = true;
599
+ }
600
+ if (params.embedding !== null && existing["embedding_json"] === null) {
601
+ this.db.prepare("UPDATE knowledge_entities SET embedding_json = ? WHERE id = ?").run(vectorToJson(params.embedding), existingId);
602
+ existing["embedding_json"] = vectorToJson(params.embedding);
603
+ }
604
+ if (descriptionChanged) {
605
+ const ftsRow = this.db.prepare("SELECT rowid, name, description FROM knowledge_entities WHERE id = ?").get(existingId);
606
+ if (ftsRow !== void 0) {
607
+ this.db.prepare("INSERT INTO knowledge_entities_fts (knowledge_entities_fts, rowid, name, description) VALUES ('delete', ?, ?, ?)").run(ftsRow.rowid, toFtsText(ftsRow.name), "");
608
+ this.db.prepare(`INSERT INTO knowledge_entities_fts (rowid, name, description) VALUES (?, ?, ?)`).run(ftsRow.rowid, toFtsText(ftsRow.name), toFtsText(ftsRow.description ?? ""));
609
+ }
610
+ }
556
611
  return rowToEntity(existing);
557
612
  }
558
613
  const id = generateId("ent");
@@ -561,7 +616,7 @@ var KnowledgeStore = class {
561
616
  (id, source_id, type, name, normalized_name, description, embedding_json, created_at)
562
617
  VALUES (?, ?, ?, ?, ?, ?, ?, ?)`).run(id, params.sourceId, params.type, params.name, normalizedName, params.description, vectorToJson(params.embedding), createdAt);
563
618
  this.db.prepare(`INSERT INTO knowledge_entities_fts (rowid, name, description)
564
- VALUES ((SELECT rowid FROM knowledge_entities WHERE id = ?), ?, ?)`).run(id, params.name, params.description ?? "");
619
+ VALUES ((SELECT rowid FROM knowledge_entities WHERE id = ?), ?, ?)`).run(id, toFtsText(params.name), toFtsText(params.description ?? ""));
565
620
  return {
566
621
  id,
567
622
  sourceId: params.sourceId,
@@ -3,5 +3,5 @@ import { fileURLToPath as __cjsShimFileURLToPath } from 'node:url';
3
3
  import { dirname as __cjsShimDirname } from 'node:path';
4
4
  const __filename = __cjsShimFileURLToPath(import.meta.url);
5
5
  const __dirname = __cjsShimDirname(__filename);
6
- import { t as TextInputDialogComponent } from "./text-input-dialog-os5jWxGT.mjs";
6
+ import { t as TextInputDialogComponent } from "./text-input-dialog-Cj7OClhs.mjs";
7
7
  export { TextInputDialogComponent };
@@ -209,6 +209,8 @@ const dictionaries = {
209
209
  "input.replay_blocked": "会话历史正在回放时无法发送输入。",
210
210
  "input.send_failed": "发送失败:{message}",
211
211
  "input.guide_failed": "引导失败:{message}",
212
+ "input.large_confirm": "输入内容为 {count} 字符,确认发送?(y/n)",
213
+ "input.large_cancelled": "输入已取消。",
212
214
  "welcome.config": "/config 配置模型",
213
215
  "welcome.sessions": "/sessions 恢复历史会话",
214
216
  "welcome.quick_menu": "/ 输入后打开快捷菜单",
@@ -1001,19 +1003,9 @@ const dictionaries = {
1001
1003
  "info.mcp_load_failed": "加载 MCP 服务器失败:{msg}",
1002
1004
  "config.plan_cleared": "计划已清除",
1003
1005
  "config.yolo_already_on": "YES 模式已开启",
1004
- "config.yolo_on": "YES 模式:开启",
1005
- "config.yolo_on_desc": "工作区工具自动批准。",
1006
1006
  "config.yolo_already_off": "YES 模式已关闭",
1007
- "config.yolo_off": "YES 模式:关闭",
1008
- "config.yolo_toggle_on": "YES 模式:开启",
1009
- "config.yolo_toggle_on_desc": "工作区工具已自动批准。",
1010
1007
  "config.auto_already_on": "自动模式已开启",
1011
- "config.auto_on": "自动模式:开启",
1012
- "config.auto_on_desc": "工具自动批准。代理不会提问。",
1013
1008
  "config.auto_already_off": "自动模式已关闭",
1014
- "config.auto_off": "自动模式:关闭",
1015
- "config.auto_toggle_on": "自动模式:开启",
1016
- "config.auto_toggle_on_desc": "工具自动批准。代理不会提问。",
1017
1009
  "settings.title": "设置",
1018
1010
  "settings.model": "模型",
1019
1011
  "settings.model_desc": "切换当前模型和思考模式。",
@@ -1241,6 +1233,8 @@ const dictionaries = {
1241
1233
  "input.replay_blocked": "Cannot send input while session history is replaying.",
1242
1234
  "input.send_failed": "Send failed: {message}",
1243
1235
  "input.guide_failed": "Guide failed: {message}",
1236
+ "input.large_confirm": "Input is {count} characters. Send anyway? (y/n)",
1237
+ "input.large_cancelled": "Input cancelled.",
1244
1238
  "welcome.config": "/config Configure model",
1245
1239
  "welcome.sessions": "/sessions Resume session",
1246
1240
  "welcome.quick_menu": "/ Open quick menu",
@@ -2033,19 +2027,9 @@ const dictionaries = {
2033
2027
  "info.mcp_load_failed": "Failed to load MCP server: {msg}",
2034
2028
  "config.plan_cleared": "Plan cleared",
2035
2029
  "config.yolo_already_on": "YES mode is already on",
2036
- "config.yolo_on": "YES mode: on",
2037
- "config.yolo_on_desc": "Workspace tools auto-approved.",
2038
2030
  "config.yolo_already_off": "YES mode is already off",
2039
- "config.yolo_off": "YES mode: off",
2040
- "config.yolo_toggle_on": "YES mode: on",
2041
- "config.yolo_toggle_on_desc": "Workspace tools have been auto-approved.",
2042
2031
  "config.auto_already_on": "Auto mode is already on",
2043
- "config.auto_on": "Auto mode: on",
2044
- "config.auto_on_desc": "Tools auto-approved. Agent will not ask questions.",
2045
2032
  "config.auto_already_off": "Auto mode is already off",
2046
- "config.auto_off": "Auto mode: off",
2047
- "config.auto_toggle_on": "Auto mode: on",
2048
- "config.auto_toggle_on_desc": "Tools auto-approved. Agent will not ask questions.",
2049
2033
  "settings.title": "Settings",
2050
2034
  "settings.model": "Model",
2051
2035
  "settings.model_desc": "Switch current model and thinking mode.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scream-code",
3
- "version": "0.10.0",
3
+ "version": "0.10.2",
4
4
  "description": "A terminal-native AI agent for builders",
5
5
  "license": "MIT",
6
6
  "author": "ScreamCli",
@@ -57,7 +57,7 @@
57
57
  "smoke": "node dist/main.mjs --version"
58
58
  },
59
59
  "dependencies": {
60
- "@liutod-scream/pi-tui": "^0.80.10",
60
+ "@liutod-scream/pi-tui": "^0.80.18",
61
61
  "@mariozechner/clipboard": "^0.3.2",
62
62
  "chalk": "^5.4.1",
63
63
  "cli-highlight": "^2.1.11",