@neovate/code 0.27.1 → 0.28.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.
package/dist/index.d.ts CHANGED
@@ -171,6 +171,7 @@ export declare type Argv = {
171
171
  resume?: string;
172
172
  systemPrompt?: string;
173
173
  tools?: string;
174
+ disableContextCache: boolean;
174
175
  port?: number;
175
176
  plugin: string[];
176
177
  mcpConfig: string[];
@@ -301,6 +302,14 @@ declare type Config = {
301
302
  * - 'maxOrXhigh': Prefer xhigh if available, otherwise max
302
303
  */
303
304
  thinkingLevel?: 'low' | 'medium' | 'high' | 'max' | 'xhigh' | 'maxOrXhigh';
305
+ /**
306
+ * Controls whether rewind checkpoints are enabled.
307
+ * When enabled, snapshots are created after each AI response to allow
308
+ * rewinding to previous states with code restoration.
309
+ *
310
+ * @default true
311
+ */
312
+ checkpoints?: boolean;
304
313
  };
305
314
 
306
315
  declare type ConfigGetInput = {
@@ -369,6 +378,7 @@ export declare class Context {
369
378
  argvConfig: Record<string, any>;
370
379
  mcpManager: MCPManager;
371
380
  backgroundTaskManager: BackgroundTaskManager;
381
+ fileHistoryManager: FileHistoryManager;
372
382
  skillManager?: SkillManager;
373
383
  messageBus?: MessageBus;
374
384
  agentManager?: AgentManager;
@@ -390,6 +400,7 @@ declare type ContextCreateOpts = {
390
400
  plugins: (string | Plugin_2)[];
391
401
  messageBus?: MessageBus;
392
402
  fetch?: typeof globalThis.fetch;
403
+ noContextCache?: boolean;
393
404
  };
394
405
 
395
406
  declare type ContextOpts = {
@@ -403,6 +414,7 @@ declare type ContextOpts = {
403
414
  argvConfig: Record<string, any>;
404
415
  mcpManager: MCPManager;
405
416
  backgroundTaskManager: BackgroundTaskManager;
417
+ fileHistoryManager: FileHistoryManager;
406
418
  skillManager?: SkillManager;
407
419
  messageBus?: MessageBus;
408
420
  agentManager?: AgentManager;
@@ -466,6 +478,177 @@ declare type EventMessage = BaseMessage & {
466
478
  data: any;
467
479
  };
468
480
 
481
+ /**
482
+ * Backup metadata for a single file
483
+ */
484
+ declare type FileBackupMeta = {
485
+ /** Backup file name, format: {hash}@v{version}, null means file was deleted */
486
+ backupFileName: string | null;
487
+ /** Version number (incremental) */
488
+ version: number;
489
+ /** Backup time */
490
+ backupTime: Date;
491
+ };
492
+
493
+ declare type FileDiff = {
494
+ path: string;
495
+ oldContent: string;
496
+ newContent: string;
497
+ };
498
+
499
+ /**
500
+ * File diff content for UI display
501
+ */
502
+ declare type FileDiff_2 = {
503
+ path: string;
504
+ oldContent: string;
505
+ newContent: string;
506
+ };
507
+
508
+ declare class FileHistory {
509
+ private cwd;
510
+ private sessionId;
511
+ private backupDir;
512
+ private snapshots;
513
+ private trackedFiles;
514
+ private pendingBackups;
515
+ constructor(opts: {
516
+ cwd: string;
517
+ sessionId: string;
518
+ backupRoot?: string;
519
+ snapshots?: Snapshot[];
520
+ });
521
+ /**
522
+ * Factory method: Create FileHistory instance from session data
523
+ */
524
+ static fromSession(opts: {
525
+ cwd: string;
526
+ sessionId: string;
527
+ snapshots: SerializedSnapshot_2[];
528
+ backupRoot?: string;
529
+ }): FileHistory;
530
+ /**
531
+ * Add file to tracking list and create immediate backup.
532
+ * Accepts either absolute path or relative path (relative to cwd).
533
+ *
534
+ * This should be called BEFORE the file is modified, so we backup the OLD content.
535
+ */
536
+ trackFile(filePath: string): void;
537
+ /**
538
+ * Track a new file (does not exist yet) before it gets created.
539
+ * Records backupFileName as null to indicate the file was newly created.
540
+ */
541
+ trackNewFile(filePath: string): void;
542
+ /**
543
+ * Check if message has a snapshot
544
+ */
545
+ hasSnapshot(messageId: string): boolean;
546
+ /**
547
+ * Generate backup file name: SHA256(relativePath).slice(0,16)@v{version}
548
+ */
549
+ private generateBackupFileName;
550
+ /**
551
+ * Detect if file has changed compared to backup (metadata-first)
552
+ */
553
+ private hasFileChanged;
554
+ /**
555
+ * Create file backup
556
+ */
557
+ private createBackup;
558
+ /**
559
+ * Check if there are pending backups waiting to be snapshotted.
560
+ * Use this to determine if a snapshot should be created for this turn.
561
+ */
562
+ hasPendingBackups(): boolean;
563
+ /**
564
+ * Create snapshot using pending backups created by trackFile.
565
+ * Only files with pending backups (modified this turn) are included.
566
+ * Returns null if no files were modified this turn.
567
+ */
568
+ createSnapshot(messageId: string): Snapshot | null;
569
+ /**
570
+ * Get all snapshot previews
571
+ */
572
+ getSnapshotPreviews(): SnapshotPreview_2[];
573
+ /**
574
+ * Calculate file diff using real line-by-line comparison
575
+ */
576
+ private calculateDiff;
577
+ /**
578
+ * Restore single file
579
+ */
580
+ private restoreFile;
581
+ /**
582
+ * Rewind to specified message's snapshot.
583
+ * Restores files to the state AT the target snapshot, reverting all changes
584
+ * made by snapshots after the target.
585
+ */
586
+ rewindToMessage(messageId: string, dryRun?: boolean): RewindResult_2;
587
+ /**
588
+ * Read file content safely, returns empty string if file doesn't exist
589
+ */
590
+ private readFileContent;
591
+ /**
592
+ * Get file contents for diff display
593
+ */
594
+ private getFileDiffContents;
595
+ /**
596
+ * Preview rewind (dry run)
597
+ * @param cumulative - If true, calculates changes from this point to current state (for UI display)
598
+ * If false, only shows changes in this specific snapshot
599
+ */
600
+ previewRewind(messageId: string, cumulative?: boolean): RewindResult_2;
601
+ }
602
+
603
+ declare class FileHistoryManager {
604
+ private instances;
605
+ private cwd;
606
+ private backupRoot;
607
+ constructor(opts: FileHistoryManagerOpts);
608
+ /**
609
+ * Gets or creates a FileHistory instance for the given sessionId.
610
+ * If sessionLogPath is provided, attempts to load existing snapshots from session.jsonl.
611
+ *
612
+ * @param sessionId - Session ID (can be main session or agent session like 'agent-xxx')
613
+ * @param sessionLogPath - Optional path to session.jsonl for loading existing snapshots
614
+ * @returns FileHistory instance for the session
615
+ */
616
+ getOrCreate(sessionId: string, sessionLogPath?: string): FileHistory;
617
+ /**
618
+ * Directly sets a FileHistory instance for a session.
619
+ * Used by snapshot.loadFromSession handler.
620
+ *
621
+ * @param sessionId - Session ID
622
+ * @param fileHistory - FileHistory instance to set
623
+ */
624
+ set(sessionId: string, fileHistory: FileHistory): void;
625
+ /**
626
+ * Gets a FileHistory instance without creating it.
627
+ * Returns undefined if no instance exists.
628
+ *
629
+ * @param sessionId - Session ID
630
+ * @returns FileHistory instance or undefined
631
+ */
632
+ get(sessionId: string): FileHistory | undefined;
633
+ /**
634
+ * Clears FileHistory instance(s).
635
+ *
636
+ * @param sessionId - Optional session ID. If provided, clears only that session.
637
+ * If not provided, clears all sessions.
638
+ */
639
+ clear(sessionId?: string): void;
640
+ /**
641
+ * Destroys all FileHistory instances.
642
+ * Called when the Context is destroyed.
643
+ */
644
+ destroy(): void;
645
+ }
646
+
647
+ declare interface FileHistoryManagerOpts {
648
+ cwd: string;
649
+ backupRoot: string;
650
+ }
651
+
469
652
  declare type GitCloneInput = {
470
653
  url: string;
471
654
  destination: string;
@@ -691,6 +874,10 @@ declare type HandlerMap = {
691
874
  input: ModelsTestInput;
692
875
  output: ModelsTestOutput;
693
876
  };
877
+ 'models.getVariants': {
878
+ input: ModelsGetVariantsInput;
879
+ output: ModelsGetVariantsOutput;
880
+ };
694
881
  'outputStyles.list': {
695
882
  input: OutputStylesListInput;
696
883
  output: OutputStylesListOutput;
@@ -947,6 +1134,34 @@ declare type HandlerMap = {
947
1134
  input: ToolApprovalInput;
948
1135
  output: ToolApprovalOutput;
949
1136
  };
1137
+ 'snapshot.trackFile': {
1138
+ input: SnapshotTrackFileInput;
1139
+ output: SuccessResponse;
1140
+ };
1141
+ 'snapshot.create': {
1142
+ input: SnapshotCreateInput;
1143
+ output: SnapshotCreateOutput;
1144
+ };
1145
+ 'snapshot.list': {
1146
+ input: SnapshotListInput;
1147
+ output: SnapshotListOutput;
1148
+ };
1149
+ 'snapshot.has': {
1150
+ input: SnapshotHasInput;
1151
+ output: SnapshotHasOutput;
1152
+ };
1153
+ 'snapshot.rewind': {
1154
+ input: SnapshotRewindInput;
1155
+ output: SnapshotRewindOutput;
1156
+ };
1157
+ 'snapshot.previewRewind': {
1158
+ input: SnapshotPreviewRewindInput;
1159
+ output: SnapshotPreviewRewindOutput;
1160
+ };
1161
+ 'snapshot.loadFromSession': {
1162
+ input: SnapshotLoadFromSessionInput;
1163
+ output: SuccessResponse;
1164
+ };
950
1165
  };
951
1166
 
952
1167
  declare type ImagePart = {
@@ -1212,6 +1427,22 @@ declare interface ModelModalities {
1212
1427
  output: ('text' | 'audio' | 'image')[];
1213
1428
  }
1214
1429
 
1430
+ declare type ModelsGetVariantsInput = {
1431
+ cwd?: string;
1432
+ model: string;
1433
+ };
1434
+
1435
+ declare type ModelsGetVariantsOutput = {
1436
+ success: true;
1437
+ data: {
1438
+ model: string;
1439
+ variants: Record<string, any>;
1440
+ };
1441
+ } | {
1442
+ success: false;
1443
+ error: string;
1444
+ };
1445
+
1215
1446
  declare type ModelsListInput = {
1216
1447
  cwd: string;
1217
1448
  };
@@ -1325,6 +1556,7 @@ declare class Paths {
1325
1556
  globalConfigDir: string;
1326
1557
  globalProjectDir: string;
1327
1558
  projectConfigDir: string;
1559
+ fileHistoryDir: string;
1328
1560
  constructor(opts: {
1329
1561
  productName: string;
1330
1562
  cwd: string;
@@ -1855,6 +2087,30 @@ export declare function resumeSession(sessionId: string, options: SDKSessionOpti
1855
2087
 
1856
2088
  declare type ReturnDisplay = string | DiffViewerReturnDisplay | TodoWriteReturnDisplay | AgentResultReturnDisplay | PlanModeExitReturnDisplay;
1857
2089
 
2090
+ declare type RewindResult = {
2091
+ success: boolean;
2092
+ error?: string;
2093
+ filesChanged: string[];
2094
+ insertions: number;
2095
+ deletions: number;
2096
+ fileDiffs?: FileDiff[];
2097
+ };
2098
+
2099
+ /**
2100
+ * Rewind operation result
2101
+ */
2102
+ declare type RewindResult_2 = {
2103
+ success: boolean;
2104
+ error?: string;
2105
+ /** List of restored files */
2106
+ filesChanged: string[];
2107
+ /** Change statistics */
2108
+ insertions: number;
2109
+ deletions: number;
2110
+ /** File diffs for UI display (only in preview mode) */
2111
+ fileDiffs?: FileDiff_2[];
2112
+ };
2113
+
1858
2114
  export declare function runNeovate(opts: {
1859
2115
  productName: string;
1860
2116
  productASCIIArt?: string;
@@ -1945,6 +2201,29 @@ export declare type SDKUserMessage = {
1945
2201
  sessionId: string;
1946
2202
  };
1947
2203
 
2204
+ declare type SerializedSnapshot = {
2205
+ messageId: string;
2206
+ timestamp: string;
2207
+ trackedFileBackups: Record<string, {
2208
+ backupFileName: string | null;
2209
+ version: number;
2210
+ backupTime: string;
2211
+ }>;
2212
+ };
2213
+
2214
+ /**
2215
+ * Serialized snapshot data (for JSONL storage)
2216
+ */
2217
+ declare type SerializedSnapshot_2 = {
2218
+ messageId: string;
2219
+ timestamp: string;
2220
+ trackedFileBackups: Record<string, {
2221
+ backupFileName: string | null;
2222
+ version: number;
2223
+ backupTime: string;
2224
+ }>;
2225
+ };
2226
+
1948
2227
  declare type SessionAddMessagesInput = {
1949
2228
  cwd: string;
1950
2229
  sessionId: string;
@@ -2428,6 +2707,129 @@ declare type SlashCommandListOutput = {
2428
2707
  };
2429
2708
  };
2430
2709
 
2710
+ /**
2711
+ * File state snapshot at a specific message point
2712
+ */
2713
+ declare type Snapshot = {
2714
+ /** Associated message UUID */
2715
+ messageId: string;
2716
+ /** Snapshot creation time */
2717
+ timestamp: Date;
2718
+ /** Relative path -> backup metadata mapping */
2719
+ trackedFileBackups: Record<string, FileBackupMeta>;
2720
+ };
2721
+
2722
+ declare type SnapshotCreateInput = {
2723
+ cwd: string;
2724
+ sessionId: string;
2725
+ messageId: string;
2726
+ description?: string;
2727
+ };
2728
+
2729
+ declare type SnapshotCreateOutput = {
2730
+ success: boolean;
2731
+ data: {
2732
+ snapshot: SnapshotPreview | null;
2733
+ };
2734
+ };
2735
+
2736
+ declare type SnapshotHasInput = {
2737
+ cwd: string;
2738
+ sessionId: string;
2739
+ messageId: string;
2740
+ };
2741
+
2742
+ declare type SnapshotHasOutput = {
2743
+ success: boolean;
2744
+ data: {
2745
+ hasSnapshot: boolean;
2746
+ };
2747
+ };
2748
+
2749
+ declare type SnapshotListInput = {
2750
+ cwd: string;
2751
+ sessionId: string;
2752
+ };
2753
+
2754
+ declare type SnapshotListOutput = {
2755
+ success: boolean;
2756
+ data: {
2757
+ snapshots: SnapshotPreview[];
2758
+ };
2759
+ };
2760
+
2761
+ declare type SnapshotLoadFromSessionInput = {
2762
+ cwd: string;
2763
+ sessionId: string;
2764
+ snapshots: SerializedSnapshot[];
2765
+ };
2766
+
2767
+ declare type SnapshotPreview = {
2768
+ messageId: string;
2769
+ timestamp: Date;
2770
+ fileCount: number;
2771
+ changes?: {
2772
+ insertions: number;
2773
+ deletions: number;
2774
+ filesChanged: number;
2775
+ };
2776
+ };
2777
+
2778
+ /**
2779
+ * Snapshot preview info (for UI display)
2780
+ */
2781
+ declare type SnapshotPreview_2 = {
2782
+ messageId: string;
2783
+ timestamp: Date;
2784
+ fileCount: number;
2785
+ /** Change statistics relative to previous snapshot */
2786
+ changes?: {
2787
+ insertions: number;
2788
+ deletions: number;
2789
+ filesChanged: number;
2790
+ };
2791
+ };
2792
+
2793
+ declare type SnapshotPreviewRewindInput = {
2794
+ cwd: string;
2795
+ sessionId: string;
2796
+ messageId: string;
2797
+ cumulative?: boolean;
2798
+ };
2799
+
2800
+ declare type SnapshotPreviewRewindOutput = {
2801
+ success: true;
2802
+ data: {
2803
+ result: RewindResult;
2804
+ };
2805
+ } | {
2806
+ success: false;
2807
+ error: string;
2808
+ };
2809
+
2810
+ declare type SnapshotRewindInput = {
2811
+ cwd: string;
2812
+ sessionId: string;
2813
+ messageId: string;
2814
+ };
2815
+
2816
+ declare type SnapshotRewindOutput = {
2817
+ success: true;
2818
+ data: {
2819
+ result: RewindResult;
2820
+ };
2821
+ } | {
2822
+ success: false;
2823
+ error: string;
2824
+ };
2825
+
2826
+ declare type SnapshotTrackFileInput = {
2827
+ cwd: string;
2828
+ sessionId: string;
2829
+ filePath: string;
2830
+ isNewFile?: boolean;
2831
+ };
2832
+
2431
2833
  declare type Status = Record<string, {
2432
2834
  description?: string;
2433
2835
  items: string[];
@@ -2774,6 +3176,7 @@ declare type WorkspaceData = {
2774
3176
  repoPath: string;
2775
3177
  branch: string;
2776
3178
  worktreePath: string;
3179
+ globalProjectDir: string;
2777
3180
  sessionIds: string[];
2778
3181
  gitState: {
2779
3182
  currentCommit: string;