-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathoverview.txt
More file actions
339 lines (295 loc) · 15 KB
/
Copy pathoverview.txt
File metadata and controls
339 lines (295 loc) · 15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
================================================================================
PromptSync PRO v3.1.1
COMPLETE TECHNICAL OVERVIEW
================================================================================
"Your context. Synced with AI."
"Less typing, smarter AI, better results."
PromptSync is a privacy-first Chrome Extension (Manifest V3) that
automatically injects your personal context into AI chats. It remembers
your goals, preferences, and important notes, then silently prepends
them to every message — so you never repeat yourself and always get
better, more relevant responses.
Works on: ChatGPT · Claude · Gemini · Perplexity · DeepSeek
================================================================================
1. CORE CONCEPT
================================================================================
PROBLEM: Every new AI chat starts from zero. You type "I'm a developer,
I use React, keep answers short" hundreds of times.
SOLUTION: PromptSync stores your profile and context notes locally, then
auto-injects them into the input field before your message sends.
The AI sees your context + your question as a single prompt.
PIPELINE: User Input → Parse Commands → Build Context → Inject → Track Tokens
PRIVACY: All data stays in chrome.storage.local. Zero network requests.
No analytics. No telemetry. Nothing leaves your device. Ever.
================================================================================
2. FEATURE BREAKDOWN (16 FEATURES)
================================================================================
[F1] MULTI-PROFILE SYSTEM
Store multiple profiles (Default, Student, Developer, Custom).
Each profile has: name, role, goals, skills, preferences, notes.
Switch profiles from popup or let auto-switch handle it.
[F2] PROFILE AUTO-SWITCH PER WEBSITE
Map domains to profiles: claude.ai → Student, chatgpt.com → Developer.
On page load, detect domain and auto-switch profile.
Manual mapping only (no AI detection). Toggle on/off.
[F3] SMART CONTEXT INJECTION
Builds injection using customizable template with placeholders:
{user_name}, {user_role}, {user_goals}, {memories}, {instruction}
Section toggles: enable/disable name, role, goals, memory, instruction.
Wraps in [USER CONTEXT START]...[USER CONTEXT END] markers.
[F4] TOKEN-SAVING DEFAULT SYSTEM
Injects: "Answer as short as possible. No explanation unless asked."
Facts → direct answer. Best choice → only best option.
Disabled automatically when task mode is active.
Per-message override with /explain or /detail commands.
[F5] COMMAND SYSTEM (BUILT-IN + CUSTOM)
/research — Switch to Researcher role
/dev — Switch to Developer role
/design — Switch to Designer role
/business — Switch to Business role
/writer — Switch to Writer role
/no-memory — skip injection for this message
/only-profile — inject only profile (no saved notes)
/strict — ultra-minimal (name + pinned only)
/explain — allow full explanation
/detail — full context + detailed answer
/code — coding assistant mode
/short — force shortest answer
/reset — revert to default
/temp <text> — add session-only memory
+ User-defined custom commands
[F6] CUSTOM COMMANDS
Users create commands like /fast, /deep.
Each triggers predefined actions:
- Mode change (coding/study/short/custom)
- Enable/disable memory
- Inject custom instruction text
No arbitrary code execution. Only preset actions.
Create/edit/delete from Modes tab.
[F7] ROLE-BASED ENGINE
Researcher: "Think deeply, analyze critically..."
Developer: "Provide clean, optimized, production-ready code."
Designer: "Focus on modern, clean, user-friendly design."
Business: "Strategic business expert..."
Writer: "Write clearly, naturally..."
Strict injection format: [ROLE] ... [/ROLE] and [STYLE] ... [/STYLE].
Fail-safe: skips injection if user manually types "act as..." or "you are...".
[F8] SAVED CONTEXT NOTES
Add/edit/delete notes with text, tags, priority, pin status.
Enable/disable individual notes.
Drag-and-drop reorder. Bulk delete.
Smart keyword matching: notes relevant to your question auto-selected.
Priority scoring: high > medium > low. Pinned always included.
[F9] MEMORY DECAY
Tracks lastUsed timestamp on every note.
After configurable days (default: 7), suggests unused notes for removal.
Decay banner in Saved tab with one-click bulk remove.
Pinned notes are exempt from decay.
[F10] SECURITY GUARD
Scans text for sensitive patterns before saving:
- API keys: OpenAI (sk-), Stripe (pk_/sk_), AWS (AKIA), GitHub (ghp_)
- Passwords: password:, passwd=, secret: patterns
- Credit cards: 13-19 digit Luhn-validated numbers
- Private keys: -----BEGIN PRIVATE KEY-----
- Bearer tokens
Shows warning popup. User can override or cancel save.
[F11] CUSTOMIZABLE INJECTION TEMPLATE
Edit the exact format of injected context.
Placeholders: {user_name}, {user_role}, {user_goals}, {memories}, {instruction}
Section toggles: individually enable/disable each section.
Default wraps in [USER CONTEXT START]...[USER CONTEXT END].
[F12] RESPONSE CONTROL
Editable instruction appended to every injection.
Default: "Keep answer short. No extra explanation. Only give what is asked."
Users can customize to any instruction they want.
Toggle on/off globally.
[F13] FLOATING PANEL (TOKEN BADGE + CONTROL PANEL)
Badge: always visible on AI pages, shows "120 tok" count.
Click to expand into floating panel:
- Memory toggle ON/OFF
- Mode switcher dropdown
- Token breakdown: input, memory, session
- Context window progress bar with color coding
- Session reset button
Draggable (saves position). Outside click to collapse.
Settings: show badge only, show panel, hide completely.
[F14] REAL-TIME TOKEN TRACKING
Uses o200k_base BPE tokenizer for accurate counting.
Tracks: input tokens, injected memory tokens, session total.
Shows percentage of context window used per platform:
ChatGPT: 128K, Claude: 200K, Gemini: 1M, Perplexity: 16K, DeepSeek: 64K.
[F15] DARK MODE / THEME
Light, Dark, System (auto-detect OS preference).
Cycle with header button. CSS variables for smooth switching.
Glassmorphism effects on floating panel and toasts.
[F16] PREVIEW SYSTEM
Optionally intercept send action.
Injects context into the textbox but waits for manual user confirmation.
Allows editing the generated prompt.
[F17] SANDBOXED CLAUDE COUNTER
Independent script targeting ONLY claude.ai.
Complete token awareness without conflicting with PromptSync Core.
================================================================================
3. ARCHITECTURE
================================================================================
manifest.json (Manifest V3)
├── background/background.js — Service worker
│ ├── Context menu ("Save to PromptSync")
│ ├── Keyboard shortcut (Ctrl+Shift+M)
│ ├── Default settings, profiles, modes on first install
│ ├── Content script re-injection on update
│ └── Memory decay alarm (daily)
│
├── storage/storage.js — Central data layer
│ ├── Multi-profile CRUD (create/read/update/delete/switch)
│ ├── Memory items CRUD with migration
│ ├── Task modes CRUD
│ ├── Custom commands CRUD
│ ├── Settings with deep-merge defaults
│ ├── Injection template management
│ ├── Domain → profile auto-switch lookup
│ ├── Export/import (all data, all formats)
│ └── Settings cache with TTL for performance
│
├── utils/
│ ├── tokenizer.js — BPE token counter (o200k_base + heuristic fallback)
│ ├── contextEngine.js — Smart context selection + template engine
│ │ ├── Keyword extraction (stop word filtered)
│ │ ├── Relevance scoring (keyword match + priority + pin bonus)
│ │ ├── Template-based build with placeholder replacement
│ │ ├── Task mode instruction injection
│ │ ├── Response control injection
│ │ ├── Session memory management
│ │ └── lastUsed timestamp tracking
│ ├── commandParser.js — Slash command parser
│ │ ├── 10 built-in commands
│ │ ├── Dynamic custom command loading from storage
│ │ ├── Regex-based extraction without state issues
│ │ └── Human-readable command list generator
│ └── securityGuard.js — Sensitive data scanner
│ ├── 10 detection patterns (API keys, passwords, CC, etc.)
│ ├── Luhn checksum for credit card validation
│ └── Quick-check fast path
│
├── content/
│ ├── content.js — Core injection pipeline
│ │ ├── Platform detection (5 platforms)
│ │ ├── Input field discovery (multi-selector per platform)
│ │ ├── Send button interception (click + Enter)
│ │ ├── Injection pipeline (parse → build → inject → track)
│ │ ├── Auto-detect user info patterns
│ │ ├── Text selection save button
│ │ ├── SPA navigation detection
│ │ ├── Profile auto-switch per domain
│ │ ├── Security scanning on save
│ │ └── Debug mode logging
│ ├── content.css — All injected UI styles
│ ├── floatingPanel.js — Combined token badge + control panel
│ └── onboarding.js — First-run overlay
│
├── popup/
│ ├── popup.html — 5-tab dashboard
│ │ ├── Profile tab (switcher, form, preview, token bar)
│ │ ├── Saved tab (search, tags, priority, bulk ops, decay)
│ │ ├── Modes tab (task modes + custom commands)
│ │ ├── Settings tab (template, response, security, decay, auto-switch, platforms, advanced)
│ │ └── Help tab (commands, tips, onboarding reset)
│ ├── popup.js — All popup logic
│ └── popup.css — CSS variables, light/dark, all components
│
└── vendor/o200k_base.js — GPT tokenizer library
================================================================================
4. STORAGE SCHEMA
================================================================================
asm_profiles: {
default: { name, role, goals, skills, preferences, customNotes },
student: { ... },
developer: { ... },
custom_1: { ... }
}
asm_items: [
{
id: string (base36 + random),
text: string,
keywords: string[],
priority: "high" | "medium" | "low",
lastUsed: timestamp,
pinned: boolean,
enabled: boolean,
source: "manual" | "selection" | "context-menu" | "auto-detect",
timestamp: number,
tags: string[]
}
]
asm_settings: {
injectEnabled, compactMode, autoDetect, saveSelection,
showTokenCount, tokenSavingPrompt, focusMode, tokenIndicator,
injectionMode, darkMode, activeProfile, activeMode,
platforms: { chatgpt, claude, gemini, perplexity, deepseek },
responseControl: { enabled, text, perMessage },
security: { detectSensitive },
decay: { enabled, days },
advanced: { injectionDelay, maxMemories, strictMode, debugMode, maxTokenLimit },
autoSwitch: { enabled, mappings: { domain → profileName } },
onboarding: { completed, version },
floatingPanel: { mode, visible }
}
asm_task_modes: {
coding: { name, instruction, builtin },
study: { name, instruction, builtin },
short: { name, instruction, builtin },
custom: { name, instruction, builtin: false }
}
asm_custom_commands: [
{
name: "/fast",
description: "Quick short answer",
enabled: true,
actions: {
taskMode: "short",
disableMemory: true,
skipSystemPrompt: false,
instruction: "Be extremely brief."
}
}
]
asm_template: {
format: "[USER CONTEXT START]\nName: {user_name}\n...",
sections: { name, role, goals, memory, instruction }
}
================================================================================
5. SECURITY MODEL
================================================================================
- ALL data in chrome.storage.local (never leaves device)
- NO external API calls, analytics, or telemetry
- HTML-escaped output in all display contexts (XSS prevention)
- SecurityGuard scans before every save operation
- Custom commands limited to predefined actions only (no eval/exec)
- Input sanitization on import (length limits, type validation)
- Content script namespace isolation (asm- prefix on all DOM elements)
================================================================================
6. PERFORMANCE
================================================================================
- Settings cache with 2-second TTL (avoids repeated chrome.storage reads)
- Token calculation debounced at 300ms
- Auto-detect pattern matching debounced at 1500ms
- BPE tokenizer result cache (200 entries LRU)
- MutationObserver for DOM changes (no polling for input discovery)
- setInterval polling only for SPA URL changes (800ms) and safety checks
- Lazy loading: floating panel initializes only when setting enabled
================================================================================
7. PLATFORM SUPPORT
================================================================================
Each platform has custom selectors for:
- Input field (textarea, contenteditable, ProseMirror)
- Send button (various aria-labels, form submits, icon buttons)
ChatGPT: ProseMirror + data-testid send button
Claude: ProseMirror + aria-label Send Message
Gemini: rich-textarea contenteditable + send-button class
Perplexity: textarea + Submit aria-label
DeepSeek: textarea#chat-input + div role=button
SPA navigation handled via URL polling + popstate listener.
Content scripts re-injected on extension update.
================================================================================
PromptSync PRO v3.1.1 — Stop repeating. Start syncing.
================================================================================