@savestate/cli 0.1.0 โ†’ 0.2.0

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/README.md CHANGED
@@ -23,7 +23,6 @@ SaveState is an encrypted backup and restore system for AI agent state. Think **
23
23
  npx savestate init # Set up encryption + storage
24
24
  npx savestate snapshot # Capture current state
25
25
  npx savestate restore latest # Restore from last snapshot
26
- npx savestate search "cocktail recs" # Search across all snapshots
27
26
  npx savestate diff v3 v5 # What changed between snapshots
28
27
  ```
29
28
 
@@ -32,7 +31,6 @@ npx savestate diff v3 v5 # What changed between snapshots
32
31
  - ๐Ÿ” **Encrypted at rest** โ€” AES-256-GCM with scrypt key derivation. Your keys, your data.
33
32
  - ๐Ÿ“ฆ **Open archive format** โ€” The SaveState Archive Format (SAF) is an open spec. No vendor lock-in.
34
33
  - ๐Ÿ”Œ **Platform adapters** โ€” Works with ChatGPT, Claude, Gemini, Clawdbot, OpenAI Assistants, and more.
35
- - ๐Ÿ” **Searchable** โ€” Query across all snapshots without restoring. Find anything.
36
34
  - ๐Ÿ“Š **Incremental** โ€” Like git โ€” only captures what changed. Full history, tiny storage.
37
35
  - ๐Ÿ’พ **Flexible storage** โ€” Local filesystem, S3, R2, Backblaze, Dropbox, iCloud โ€” you choose.
38
36
  - โฐ **Scheduled backups** โ€” Set it and forget it. Auto-snapshot on your schedule.
@@ -54,9 +52,6 @@ savestate snapshot
54
52
  # List all snapshots
55
53
  savestate list
56
54
 
57
- # Search across snapshots
58
- savestate search "that recipe from last month"
59
-
60
55
  # Restore from a snapshot
61
56
  savestate restore latest
62
57
  ```
@@ -79,13 +74,13 @@ Community adapters welcome! See [Contributing](#contributing).
79
74
  ```
80
75
  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
81
76
  โ”‚ SaveState CLI โ”‚
82
- โ”‚ init ยท snapshot ยท restore ยท search ยท diff โ”‚
77
+ โ”‚ init ยท snapshot ยท restore ยท list ยท diff โ”‚
83
78
  โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
84
79
  โ”‚ Adapter Layer โ”‚
85
80
  โ”‚ clawdbot ยท chatgpt ยท claude ยท openai ยท custom โ”‚
86
81
  โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
87
82
  โ”‚ Core Engine โ”‚
88
- โ”‚ snapshot ยท restore ยท search ยท diff ยท format โ”‚
83
+ โ”‚ snapshot ยท restore ยท diff ยท format โ”‚
89
84
  โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
90
85
  โ”‚ Encryption Layer โ”‚
91
86
  โ”‚ AES-256-GCM ยท scrypt KDF ยท integrity check โ”‚
@@ -147,9 +142,6 @@ savestate restore [snapshot-id] Restore from a snapshot (default: latest)
147
142
  savestate list List all snapshots
148
143
  --json Output as JSON
149
144
  --limit <n> Max snapshots to show
150
- savestate search <query> Search across snapshots
151
- --type <types> Filter by content type
152
- --limit <n> Max results
153
145
  savestate diff <a> <b> Compare two snapshots
154
146
  savestate config View/edit configuration
155
147
  --set <key=value> Set a config value
@@ -225,13 +217,11 @@ src/
225
217
  โ”œโ”€โ”€ config.ts # Configuration management
226
218
  โ”œโ”€โ”€ snapshot.ts # Snapshot creation
227
219
  โ”œโ”€โ”€ restore.ts # Snapshot restoration
228
- โ”œโ”€โ”€ search.ts # Cross-snapshot search
229
220
  โ”œโ”€โ”€ commands/ # CLI command handlers
230
221
  โ”‚ โ”œโ”€โ”€ init.ts
231
222
  โ”‚ โ”œโ”€โ”€ snapshot.ts
232
223
  โ”‚ โ”œโ”€โ”€ restore.ts
233
224
  โ”‚ โ”œโ”€โ”€ list.ts
234
- โ”‚ โ”œโ”€โ”€ search.ts
235
225
  โ”‚ โ”œโ”€โ”€ diff.ts
236
226
  โ”‚ โ”œโ”€โ”€ config.ts
237
227
  โ”‚ โ””โ”€โ”€ adapters.ts
@@ -0,0 +1,113 @@
1
+ /**
2
+ * ChatGPT Adapter
3
+ *
4
+ * Export-based adapter for ChatGPT data.
5
+ * Captures conversations, memories, custom instructions, and user profile
6
+ * from a ChatGPT data export (Settings โ†’ Data Controls โ†’ Export Data).
7
+ *
8
+ * Export structure:
9
+ * conversations.json โ€” All conversations (tree-structured mapping)
10
+ * memories.json โ€” ChatGPT memories (newer exports)
11
+ * custom_instructions.json โ€” About user + response preferences
12
+ * user.json โ€” User profile metadata
13
+ * model_comparisons.json โ€” A/B testing data
14
+ * shared_conversations.json โ€” Publicly shared conversations
15
+ * message_feedback.json โ€” Thumbs up/down on messages
16
+ * chat.html โ€” HTML render of conversations
17
+ *
18
+ * Detection:
19
+ * - SAVESTATE_CHATGPT_EXPORT env var โ†’ path to export directory or zip
20
+ * - chatgpt-export/ or conversations.json in cwd
21
+ * - .savestate/imports/chatgpt/ extracted export
22
+ *
23
+ * Restore is partial โ€” ChatGPT has no public API for importing
24
+ * conversations. Generates chatgpt-restore-guide.md with data
25
+ * for manual re-entry.
26
+ */
27
+ import type { Adapter, PlatformMeta, Snapshot } from '../types.js';
28
+ export declare class ChatGPTAdapter implements Adapter {
29
+ readonly id = "chatgpt";
30
+ readonly name = "ChatGPT";
31
+ readonly platform = "chatgpt";
32
+ readonly version = "0.1.0";
33
+ private exportDir;
34
+ private warnings;
35
+ detect(): Promise<boolean>;
36
+ extract(): Promise<Snapshot>;
37
+ restore(snapshot: Snapshot): Promise<void>;
38
+ identify(): Promise<PlatformMeta>;
39
+ /**
40
+ * Resolve the export directory path from env var, cwd, or .savestate/imports/.
41
+ * Returns null if no valid export is found.
42
+ */
43
+ private resolveExportPath;
44
+ /**
45
+ * Check if a directory contains ChatGPT export files.
46
+ */
47
+ private hasExportFiles;
48
+ /**
49
+ * Safely read and parse a JSON file from the export directory.
50
+ */
51
+ private readJsonFile;
52
+ /**
53
+ * Read user.json for profile metadata.
54
+ */
55
+ private readUserJson;
56
+ /**
57
+ * Read custom_instructions.json and build personality string.
58
+ */
59
+ private readCustomInstructions;
60
+ /**
61
+ * Read memories.json into MemoryEntry array.
62
+ */
63
+ private readMemories;
64
+ /**
65
+ * Read conversations.json, walk tree structures, and produce metadata + entries.
66
+ */
67
+ private readConversations;
68
+ /**
69
+ * Walk the conversation tree (mapping) and produce a linear list of messages.
70
+ *
71
+ * Algorithm:
72
+ * 1. Find root node (parent is null or missing)
73
+ * 2. Walk children depth-first
74
+ * 3. When a node has multiple children (branching = user edited), take the last branch
75
+ * 4. Skip null/system messages without content
76
+ * 5. Collect messages in order
77
+ */
78
+ private walkConversationTree;
79
+ /**
80
+ * Recursively collect messages by walking the tree depth-first.
81
+ * For branches (multiple children), take the last child (most recent edit/branch).
82
+ */
83
+ private collectMessages;
84
+ /**
85
+ * Extract a Message from a ChatGPT message node.
86
+ * Returns null if the message should be skipped (system, empty, etc.)
87
+ */
88
+ private extractMessage;
89
+ /**
90
+ * Extract text from ChatGPT content structure.
91
+ * Handles content_type: "text", "code", "tether_browsing_display", etc.
92
+ */
93
+ private extractContent;
94
+ /**
95
+ * Build the chatgpt-restore-guide.md content.
96
+ */
97
+ private buildRestoreGuide;
98
+ /**
99
+ * Build a standalone memories document.
100
+ */
101
+ private buildMemoriesDoc;
102
+ /**
103
+ * Build a standalone custom instructions document.
104
+ */
105
+ private buildInstructionsDoc;
106
+ private log;
107
+ private warn;
108
+ /**
109
+ * Simple string hash for generating IDs when conversation_id is missing.
110
+ */
111
+ private hashString;
112
+ }
113
+ //# sourceMappingURL=chatgpt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chatgpt.d.ts","sourceRoot":"","sources":["../../src/adapters/chatgpt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAMH,OAAO,KAAK,EACV,OAAO,EACP,YAAY,EACZ,QAAQ,EAKT,MAAM,aAAa,CAAC;AAkFrB,qBAAa,cAAe,YAAW,OAAO;IAC5C,QAAQ,CAAC,EAAE,aAAa;IACxB,QAAQ,CAAC,IAAI,aAAa;IAC1B,QAAQ,CAAC,QAAQ,aAAa;IAC9B,QAAQ,CAAC,OAAO,WAAW;IAE3B,OAAO,CAAC,SAAS,CAAc;IAC/B,OAAO,CAAC,QAAQ,CAAgB;IAE1B,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC;IAK1B,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC;IAwH5B,OAAO,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IA8C1C,QAAQ,IAAI,OAAO,CAAC,YAAY,CAAC;IAUvC;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAmDzB;;OAEG;IACH,OAAO,CAAC,cAAc;IAOtB;;OAEG;YACW,YAAY;IAa1B;;OAEG;YACW,YAAY;IAc1B;;OAEG;YACW,sBAAsB;IA2BpC;;OAEG;YACW,YAAY;IAqB1B;;OAEG;YACW,iBAAiB;IAsF/B;;;;;;;;;OASG;IACH,OAAO,CAAC,oBAAoB;IAoB5B;;;OAGG;IACH,OAAO,CAAC,eAAe;IAwBvB;;;OAGG;IACH,OAAO,CAAC,cAAc;IAyCtB;;;OAGG;IACH,OAAO,CAAC,cAAc;IAwCtB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAuFzB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAmBxB;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAe5B,OAAO,CAAC,GAAG;IAIX,OAAO,CAAC,IAAI;IAIZ;;OAEG;IACH,OAAO,CAAC,UAAU;CAGnB"}