kimiflare 0.88.2 → 0.88.3

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/index.js CHANGED
@@ -11237,6 +11237,50 @@ Return a JSON array of strings. Example:
11237
11237
  }
11238
11238
  return { id: memory.id, superseded: supersededIds.length > 0 ? supersededIds : void 0 };
11239
11239
  }
11240
+ /**
11241
+ * Store a plan directly under a deterministic topic key.
11242
+ * Skips embedding, verification, and hypothetical queries so it is fast and
11243
+ * deterministic. Supersedes any previous plan stored under the same key.
11244
+ */
11245
+ async rememberPlan(plan, repoPath, sessionId, topicKey = "current_dev_plan") {
11246
+ if (!this.db) throw new Error("Memory DB not open");
11247
+ const safeContent = this.shouldRedact() ? redactSecrets(plan) : plan;
11248
+ if (!safeContent.trim()) {
11249
+ throw new Error("Plan content is empty after redaction");
11250
+ }
11251
+ const normalizedKey = topicKey.trim();
11252
+ if (!normalizedKey) {
11253
+ throw new Error("Plan topic key cannot be empty");
11254
+ }
11255
+ const supersededIds = [];
11256
+ const existing = findMemoriesByTopicKey(this.db, repoPath, normalizedKey);
11257
+ for (const old of existing) {
11258
+ supersedeMemory(this.db, old.id, "pending");
11259
+ supersededIds.push(old.id);
11260
+ }
11261
+ const zeroEmbedding = new Float32Array(DEFAULT_EMBEDDING_DIM);
11262
+ const memory = insertMemory(this.db, {
11263
+ content: safeContent,
11264
+ category: "task",
11265
+ sourceSessionId: sessionId,
11266
+ repoPath,
11267
+ importance: 4,
11268
+ topicKey: normalizedKey
11269
+ }, zeroEmbedding);
11270
+ for (const oldId of supersededIds) {
11271
+ supersedeMemory(this.db, oldId, memory.id);
11272
+ }
11273
+ return { id: memory.id, superseded: supersededIds.length > 0 ? supersededIds : void 0 };
11274
+ }
11275
+ /**
11276
+ * Recall the latest memory for an exact topic key.
11277
+ * Does not use embeddings; returns null if no matching memory exists.
11278
+ */
11279
+ getByTopicKey(repoPath, topicKey) {
11280
+ if (!this.db) return null;
11281
+ const rows = findMemoriesByTopicKey(this.db, repoPath, topicKey);
11282
+ return rows[0] ?? null;
11283
+ }
11240
11284
  /**
11241
11285
  * Count high-signal memories created since the given timestamp.
11242
11286
  * Used for KIMI.md drift detection (Trigger A: session-start check).
@@ -16823,6 +16867,32 @@ var init_distill = __esm({
16823
16867
  }
16824
16868
  });
16825
16869
 
16870
+ // src/agent/plan-resolver.ts
16871
+ function resolvePlanForFresh(opts2) {
16872
+ const { mode, messages, sessionPlan, memoryManager, memoryEnabled, repoPath } = opts2;
16873
+ if (mode !== "plan") {
16874
+ return null;
16875
+ }
16876
+ if (sessionPlan) {
16877
+ return sessionPlan;
16878
+ }
16879
+ if (memoryEnabled && memoryManager) {
16880
+ const stored = memoryManager.getByTopicKey(repoPath, PLAN_MEMORY_TOPIC_KEY);
16881
+ if (stored?.content) {
16882
+ return stored.content;
16883
+ }
16884
+ }
16885
+ return distillSessionPlan(messages);
16886
+ }
16887
+ var PLAN_MEMORY_TOPIC_KEY;
16888
+ var init_plan_resolver = __esm({
16889
+ "src/agent/plan-resolver.ts"() {
16890
+ "use strict";
16891
+ init_distill();
16892
+ PLAN_MEMORY_TOPIC_KEY = "current_dev_plan";
16893
+ }
16894
+ });
16895
+
16826
16896
  // src/agent/continuation-summary.ts
16827
16897
  import { execSync as execSync4 } from "child_process";
16828
16898
  function extractFirstUserGoal(messages) {
@@ -19909,6 +19979,10 @@ Executor opened PR: ${prUrl}` : plan });
19909
19979
  const plan = distillSessionPlan(messages);
19910
19980
  if (plan) {
19911
19981
  sessionPlan = plan;
19982
+ if (startupCfg?.memoryEnabled && memoryManager) {
19983
+ void memoryManager.rememberPlan(plan, process.cwd(), randomUUID2()).catch(() => {
19984
+ });
19985
+ }
19912
19986
  }
19913
19987
  }
19914
19988
  if (planOptionsRef.current && !currentController?.signal.aborted) {
@@ -21655,7 +21729,14 @@ changelog-image failed: ${err instanceof Error ? err.message : String(err)}
21655
21729
  return true;
21656
21730
  }
21657
21731
  void (async () => {
21658
- const summary = await generateContinuationSummary({
21732
+ const summary = currentMode === "plan" ? resolvePlanForFresh({
21733
+ mode: currentMode,
21734
+ messages,
21735
+ sessionPlan,
21736
+ memoryManager,
21737
+ memoryEnabled: startupCfg?.memoryEnabled,
21738
+ repoPath: process.cwd()
21739
+ }) : await generateContinuationSummary({
21659
21740
  messages,
21660
21741
  mode: currentMode,
21661
21742
  accountId: opts2.accountId,
@@ -21954,6 +22035,7 @@ var init_ui_mode = __esm({
21954
22035
  init_sessions();
21955
22036
  init_llm_summarize();
21956
22037
  init_distill();
22038
+ init_plan_resolver();
21957
22039
  init_continuation_summary();
21958
22040
  init_greetings();
21959
22041
  init_theme();
@@ -31507,6 +31589,7 @@ var init_slash_commands = __esm({
31507
31589
  init_session_store();
31508
31590
  init_deploy();
31509
31591
  init_tui_auth();
31592
+ init_plan_resolver();
31510
31593
  init_continuation_summary();
31511
31594
  init_clipboard();
31512
31595
  handleExit = (ctx) => {
@@ -31559,7 +31642,14 @@ var init_slash_commands = __esm({
31559
31642
  ]);
31560
31643
  return true;
31561
31644
  }
31562
- const summary = await generateContinuationSummary({
31645
+ const summary = ctx.mode === "plan" ? resolvePlanForFresh({
31646
+ mode: ctx.mode,
31647
+ messages: ctx.messagesRef.current,
31648
+ sessionPlan: ctx.sessionPlanRef.current,
31649
+ memoryManager: ctx.memoryManagerRef.current,
31650
+ memoryEnabled: cfg?.memoryEnabled,
31651
+ repoPath: process.cwd()
31652
+ }) : await generateContinuationSummary({
31563
31653
  messages: ctx.messagesRef.current,
31564
31654
  mode: ctx.mode,
31565
31655
  accountId: cfg?.accountId ?? "",
@@ -34999,7 +35089,14 @@ ${wcagWarnings.join("\n")}` }
34999
35089
  (picked) => {
35000
35090
  setShowPlanCompletePicker(false);
35001
35091
  if (!picked || picked === "continue") return;
35002
- const plan = sessionPlanRef.current ?? distillSessionPlan(messagesRef.current);
35092
+ const plan = resolvePlanForFresh({
35093
+ mode: "plan",
35094
+ messages: messagesRef.current,
35095
+ sessionPlan: sessionPlanRef.current,
35096
+ memoryManager: memoryManagerRef.current,
35097
+ memoryEnabled: cfg?.memoryEnabled,
35098
+ repoPath: process.cwd()
35099
+ });
35003
35100
  if (!plan) {
35004
35101
  setEvents((e) => [
35005
35102
  ...e,
@@ -35703,6 +35800,10 @@ ${conflicts.join("\n")}` }
35703
35800
  const plan = distillSessionPlan(messagesRef.current);
35704
35801
  if (plan) {
35705
35802
  sessionPlanRef.current = plan;
35803
+ if (cfg?.memoryEnabled && memoryManagerRef.current && sessionIdRef.current) {
35804
+ void memoryManagerRef.current.rememberPlan(plan, process.cwd(), sessionIdRef.current).catch(() => {
35805
+ });
35806
+ }
35706
35807
  setShowPlanCompletePicker(true);
35707
35808
  }
35708
35809
  }
@@ -36291,6 +36392,7 @@ var init_app = __esm({
36291
36392
  init_manager_init();
36292
36393
  init_run_compact();
36293
36394
  init_distill();
36395
+ init_plan_resolver();
36294
36396
  init_command_handlers();
36295
36397
  init_app_helpers();
36296
36398
  }