zaileys 3.0.0 → 3.1.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.
Files changed (149) hide show
  1. package/.changeset/README.md +8 -0
  2. package/.changeset/config.json +11 -0
  3. package/.kelar/kelar-tools.cjs +829 -0
  4. package/.kelar/memory/INDEX.md +21 -0
  5. package/.kelar/memory/technical/issue-34-sendpresenceupdate-undefined.md +4 -0
  6. package/.kelar/memory/technical/lmdb-native-binary-fallback.md +4 -0
  7. package/.kelar/memory/technical/nedbadapter-ignoring-encoder-causes-buffer-typing-crash-err-invalid-arg-type.md +4 -0
  8. package/.kelar/memory/technical/signal-media-constructor-input-contract.md +4 -0
  9. package/.kelar/memory/technical/sticker-example-source-format.md +4 -0
  10. package/.kelar/memory/technical/ts2307-missing-seald-io-nedb.md +4 -0
  11. package/.kelar/memory/technical/ts2307-missing-zaileys-store-adapters.md +4 -0
  12. package/.kelar/plans/README.md +3 -0
  13. package/.kelar/research/README.md +3 -0
  14. package/.kelar/research/mysql-adapter-research.md +32 -0
  15. package/.kelar/state/ASSUMPTIONS.md +14 -0
  16. package/.kelar/state/DEBT.md +13 -0
  17. package/.kelar/state/DIARY.md +15 -0
  18. package/.kelar/state/HANDOFF.md +54 -0
  19. package/.kelar/state/PATTERNS.md +43 -0
  20. package/.kelar/state/STATE.md +37 -0
  21. package/.kelar/state/TASKS.md +146 -0
  22. package/AGENTS.md +108 -0
  23. package/CHANGELOG.md +12 -0
  24. package/GEMINI.md +58 -0
  25. package/dist/index.d.mts +14 -3
  26. package/dist/index.d.ts +14 -3
  27. package/dist/index.js +9 -27
  28. package/dist/index.mjs +9 -27
  29. package/package.json +16 -14
  30. package/packages/media-process/CHANGELOG.md +7 -0
  31. package/packages/media-process/LICENSE +21 -0
  32. package/packages/media-process/dist/index.d.mts +142 -0
  33. package/packages/media-process/dist/index.d.ts +142 -0
  34. package/packages/media-process/dist/index.mjs +3 -0
  35. package/packages/media-process/package.json +39 -0
  36. package/packages/media-process/tsconfig.json +15 -0
  37. package/packages/mysql-adapter/dist/index.d.mts +36 -0
  38. package/packages/mysql-adapter/dist/index.d.ts +36 -0
  39. package/packages/mysql-adapter/dist/index.js.map +1 -0
  40. package/packages/mysql-adapter/dist/index.mjs +101 -0
  41. package/packages/mysql-adapter/dist/index.mjs.map +1 -0
  42. package/packages/mysql-adapter/package.json +36 -0
  43. package/pnpm-workspace.yaml +3 -0
  44. package/.agent/skills/codebase-mapper/SKILL.md +0 -226
  45. package/.agent/skills/context-compressor/SKILL.md +0 -201
  46. package/.agent/skills/context-fetch/SKILL.md +0 -184
  47. package/.agent/skills/context-health-monitor/SKILL.md +0 -105
  48. package/.agent/skills/debugger/SKILL.md +0 -273
  49. package/.agent/skills/empirical-validation/SKILL.md +0 -97
  50. package/.agent/skills/executor/SKILL.md +0 -465
  51. package/.agent/skills/plan-checker/SKILL.md +0 -283
  52. package/.agent/skills/planner/SKILL.md +0 -485
  53. package/.agent/skills/token-budget/SKILL.md +0 -166
  54. package/.agent/skills/verifier/SKILL.md +0 -421
  55. package/.agent/workflows/add-phase.md +0 -96
  56. package/.agent/workflows/add-todo.md +0 -69
  57. package/.agent/workflows/audit-milestone.md +0 -107
  58. package/.agent/workflows/check-todos.md +0 -80
  59. package/.agent/workflows/complete-milestone.md +0 -135
  60. package/.agent/workflows/debug.md +0 -235
  61. package/.agent/workflows/discuss-phase.md +0 -103
  62. package/.agent/workflows/execute.md +0 -325
  63. package/.agent/workflows/health.md +0 -122
  64. package/.agent/workflows/help.md +0 -96
  65. package/.agent/workflows/insert-phase.md +0 -109
  66. package/.agent/workflows/install.md +0 -152
  67. package/.agent/workflows/list-phase-assumptions.md +0 -82
  68. package/.agent/workflows/map.md +0 -394
  69. package/.agent/workflows/new-milestone.md +0 -126
  70. package/.agent/workflows/new-project.md +0 -368
  71. package/.agent/workflows/pause.md +0 -176
  72. package/.agent/workflows/plan-milestone-gaps.md +0 -116
  73. package/.agent/workflows/plan.md +0 -380
  74. package/.agent/workflows/progress.md +0 -90
  75. package/.agent/workflows/quick.md +0 -128
  76. package/.agent/workflows/remove-phase.md +0 -139
  77. package/.agent/workflows/research-phase.md +0 -160
  78. package/.agent/workflows/resume.md +0 -131
  79. package/.agent/workflows/update.md +0 -203
  80. package/.agent/workflows/verify.md +0 -263
  81. package/.agent/workflows/web-search.md +0 -121
  82. package/.agent/workflows/whats-new.md +0 -80
  83. package/.gemini/GEMINI.md +0 -67
  84. package/.gsd/DEBUG.md +0 -26
  85. package/.gsd/GSD-STYLE.md +0 -272
  86. package/.gsd/PROJECT_RULES.md +0 -256
  87. package/.gsd/ROADMAP.md +0 -38
  88. package/.gsd/SPEC.md +0 -16
  89. package/.gsd/STATE.md +0 -10
  90. package/.gsd/adapters/CLAUDE.md +0 -77
  91. package/.gsd/adapters/GEMINI.md +0 -92
  92. package/.gsd/adapters/GPT_OSS.md +0 -130
  93. package/.gsd/docs/model-selection-playbook.md +0 -128
  94. package/.gsd/docs/runbook.md +0 -296
  95. package/.gsd/docs/token-optimization-guide.md +0 -207
  96. package/.gsd/model_capabilities.yaml +0 -108
  97. package/.gsd/phases/1/1-PLAN.md +0 -44
  98. package/.gsd/phases/1/2-PLAN.md +0 -54
  99. package/.gsd/phases/1/3-PLAN.md +0 -46
  100. package/.gsd/phases/1/4-PLAN.md +0 -39
  101. package/.gsd/phases/2/2-1-SUMMARY.md +0 -8
  102. package/.gsd/phases/2/2-PLAN.md +0 -47
  103. package/.gsd/phases/3/3-1-SUMMARY.md +0 -8
  104. package/.gsd/phases/3/3-PLAN.md +0 -43
  105. package/.gsd/phases/4/4-1-PLAN.md +0 -44
  106. package/.gsd/phases/4/4-1-SUMMARY.md +0 -8
  107. package/.gsd/phases/4/4-2-PLAN.md +0 -59
  108. package/.gsd/phases/4/4-2-SUMMARY.md +0 -8
  109. package/.gsd/phases/4/4-3-PLAN.md +0 -42
  110. package/.gsd/phases/4/4-3-SUMMARY.md +0 -8
  111. package/.gsd/phases/4/VERIFICATION.md +0 -8
  112. package/.gsd/phases/5/1-SUMMARY.md +0 -5
  113. package/.gsd/phases/5/5-PLAN.md +0 -47
  114. package/.gsd/phases/5/RESEARCH.md +0 -24
  115. package/.gsd/phases/5/VERIFICATION.md +0 -8
  116. package/.gsd/phases/6/1-SUMMARY.md +0 -6
  117. package/.gsd/phases/6/6-PLAN.md +0 -46
  118. package/.gsd/phases/6/RESEARCH.md +0 -33
  119. package/.gsd/phases/6/VERIFICATION.md +0 -7
  120. package/.gsd/phases/7/1-SUMMARY.md +0 -12
  121. package/.gsd/phases/7/7-PLAN.md +0 -78
  122. package/.gsd/phases/7/VERIFICATION.md +0 -7
  123. package/.gsd/templates/DEBUG.md +0 -123
  124. package/.gsd/templates/PLAN.md +0 -90
  125. package/.gsd/templates/RESEARCH.md +0 -75
  126. package/.gsd/templates/SUMMARY.md +0 -103
  127. package/.gsd/templates/UAT.md +0 -168
  128. package/.gsd/templates/VERIFICATION.md +0 -70
  129. package/.gsd/templates/architecture.md +0 -67
  130. package/.gsd/templates/context.md +0 -91
  131. package/.gsd/templates/decisions.md +0 -37
  132. package/.gsd/templates/discovery.md +0 -122
  133. package/.gsd/templates/journal.md +0 -46
  134. package/.gsd/templates/milestone.md +0 -91
  135. package/.gsd/templates/phase-summary.md +0 -52
  136. package/.gsd/templates/project.md +0 -124
  137. package/.gsd/templates/requirements.md +0 -92
  138. package/.gsd/templates/roadmap.md +0 -103
  139. package/.gsd/templates/spec.md +0 -51
  140. package/.gsd/templates/sprint.md +0 -57
  141. package/.gsd/templates/stack.md +0 -62
  142. package/.gsd/templates/state.md +0 -92
  143. package/.gsd/templates/state_snapshot.md +0 -132
  144. package/.gsd/templates/todo.md +0 -32
  145. package/.gsd/templates/token_report.md +0 -79
  146. package/.gsd/templates/user-setup.md +0 -116
  147. package/.husky/commit-msg +0 -1
  148. package/.husky/pre-commit +0 -1
  149. package/commitlint.config.js +0 -3
@@ -0,0 +1,101 @@
1
+ // src/index.ts
2
+ import { Mutex } from "async-mutex";
3
+ import mysql from "mysql2/promise";
4
+ var MySQLAdapter = class {
5
+ pool;
6
+ table;
7
+ batchInterval;
8
+ batchSize;
9
+ writeBuffer = /* @__PURE__ */ new Map();
10
+ deleteBuffer = /* @__PURE__ */ new Set();
11
+ mutex = new Mutex();
12
+ timer = null;
13
+ constructor(config, options = {}) {
14
+ this.pool = mysql.createPool({
15
+ ...config,
16
+ waitForConnections: true,
17
+ connectionLimit: 10,
18
+ queueLimit: 0
19
+ });
20
+ this.table = options.table || "zaileys_store";
21
+ this.batchInterval = options.batchInterval || 1e3;
22
+ this.batchSize = options.batchSize || 500;
23
+ this.init();
24
+ }
25
+ async init() {
26
+ await this.pool.execute(`
27
+ CREATE TABLE IF NOT EXISTS \`${this.table}\` (
28
+ \`id\` VARCHAR(255) PRIMARY KEY,
29
+ \`data\` JSON NOT NULL,
30
+ \`updatedAt\` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
31
+ )
32
+ `);
33
+ this.startTimer();
34
+ }
35
+ startTimer() {
36
+ if (this.timer) return;
37
+ this.timer = setInterval(() => this.flush(), this.batchInterval);
38
+ }
39
+ async get(id) {
40
+ if (this.deleteBuffer.has(id)) return null;
41
+ if (this.writeBuffer.has(id)) return this.writeBuffer.get(id);
42
+ const [rows] = await this.pool.execute(
43
+ `SELECT \`data\` FROM \`${this.table}\` WHERE \`id\` = ?`,
44
+ [id]
45
+ );
46
+ return rows.length ? rows[0].data : null;
47
+ }
48
+ async set(id, value) {
49
+ this.deleteBuffer.delete(id);
50
+ this.writeBuffer.set(id, value);
51
+ if (this.writeBuffer.size >= this.batchSize) {
52
+ await this.flush();
53
+ }
54
+ }
55
+ async del(id) {
56
+ this.writeBuffer.delete(id);
57
+ this.deleteBuffer.add(id);
58
+ if (this.deleteBuffer.size >= this.batchSize) {
59
+ await this.flush();
60
+ }
61
+ }
62
+ async flush() {
63
+ if (this.writeBuffer.size === 0 && this.deleteBuffer.size === 0) return;
64
+ await this.mutex.runExclusive(async () => {
65
+ const writes = Array.from(this.writeBuffer.entries());
66
+ const deletes = Array.from(this.deleteBuffer);
67
+ this.writeBuffer.clear();
68
+ this.deleteBuffer.clear();
69
+ try {
70
+ if (deletes.length > 0) {
71
+ await this.pool.query(
72
+ `DELETE FROM \`${this.table}\` WHERE \`id\` IN (?)`,
73
+ [deletes]
74
+ );
75
+ }
76
+ if (writes.length > 0) {
77
+ const values = writes.map(([id, data]) => [id, JSON.stringify(data)]);
78
+ await this.pool.query(
79
+ `INSERT INTO \`${this.table}\` (\`id\`, \`data\`) VALUES ?
80
+ ON DUPLICATE KEY UPDATE \`data\` = VALUES(\`data\`)`,
81
+ [values]
82
+ );
83
+ }
84
+ } catch (error) {
85
+ console.error(`[MySQLAdapter] Flush failed:`, error);
86
+ }
87
+ });
88
+ }
89
+ async close() {
90
+ if (this.timer) {
91
+ clearInterval(this.timer);
92
+ this.timer = null;
93
+ }
94
+ await this.flush();
95
+ await this.pool.end();
96
+ }
97
+ };
98
+ export {
99
+ MySQLAdapter
100
+ };
101
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { Mutex } from 'async-mutex';\nimport mysql, { Pool } from 'mysql2/promise';\n\n/**\n * Interface definition copied from zaileys/src/Types/store.ts\n * (Since we are in a sibling package, we'll keep it decoupled)\n */\nexport interface IStoreAdapter {\n get(id: string): Promise<any | null>;\n set(id: string, value: any): Promise<void>;\n del(id: string): Promise<void>;\n}\n\nexport interface MySQLAdapterOptions {\n table?: string;\n batchInterval?: number;\n batchSize?: number;\n}\n\nexport class MySQLAdapter implements IStoreAdapter {\n private pool: Pool;\n private table: string;\n private batchInterval: number;\n private batchSize: number;\n \n private writeBuffer = new Map<string, any>();\n private deleteBuffer = new Set<string>();\n private mutex = new Mutex();\n private timer: NodeJS.Timeout | null = null;\n\n constructor(config: mysql.PoolOptions, options: MySQLAdapterOptions = {}) {\n this.pool = mysql.createPool({\n ...config,\n waitForConnections: true,\n connectionLimit: 10,\n queueLimit: 0\n });\n\n this.table = options.table || 'zaileys_store';\n this.batchInterval = options.batchInterval || 1000;\n this.batchSize = options.batchSize || 500;\n\n this.init();\n }\n\n private async init() {\n await this.pool.execute(`\n CREATE TABLE IF NOT EXISTS \\`${this.table}\\` (\n \\`id\\` VARCHAR(255) PRIMARY KEY,\n \\`data\\` JSON NOT NULL,\n \\`updatedAt\\` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP\n )\n `);\n \n this.startTimer();\n }\n\n private startTimer() {\n if (this.timer) return;\n this.timer = setInterval(() => this.flush(), this.batchInterval);\n }\n\n async get(id: string): Promise<any | null> {\n // Check buffers first\n if (this.deleteBuffer.has(id)) return null;\n if (this.writeBuffer.has(id)) return this.writeBuffer.get(id);\n\n const [rows]: any = await this.pool.execute(\n `SELECT \\`data\\` FROM \\`${this.table}\\` WHERE \\`id\\` = ?`,\n [id]\n );\n\n return rows.length ? rows[0].data : null;\n }\n\n async set(id: string, value: any): Promise<void> {\n this.deleteBuffer.delete(id);\n this.writeBuffer.set(id, value);\n \n if (this.writeBuffer.size >= this.batchSize) {\n await this.flush();\n }\n }\n\n async del(id: string): Promise<void> {\n this.writeBuffer.delete(id);\n this.deleteBuffer.add(id);\n\n if (this.deleteBuffer.size >= this.batchSize) {\n await this.flush();\n }\n }\n\n async flush(): Promise<void> {\n if (this.writeBuffer.size === 0 && this.deleteBuffer.size === 0) return;\n\n await this.mutex.runExclusive(async () => {\n const writes = Array.from(this.writeBuffer.entries());\n const deletes = Array.from(this.deleteBuffer);\n\n // Reset buffers immediately\n this.writeBuffer.clear();\n this.deleteBuffer.clear();\n\n try {\n // Handle deletions\n if (deletes.length > 0) {\n await this.pool.query(\n `DELETE FROM \\`${this.table}\\` WHERE \\`id\\` IN (?)`,\n [deletes]\n );\n }\n\n // Handle upserts\n if (writes.length > 0) {\n const values = writes.map(([id, data]) => [id, JSON.stringify(data)]);\n await this.pool.query(\n `INSERT INTO \\`${this.table}\\` (\\`id\\`, \\`data\\`) VALUES ? \n ON DUPLICATE KEY UPDATE \\`data\\` = VALUES(\\`data\\`)`,\n [values]\n );\n }\n } catch (error) {\n console.error(`[MySQLAdapter] Flush failed:`, error);\n // Re-buffer on failure? (Optional: based on retry strategy)\n }\n });\n }\n\n async close() {\n if (this.timer) {\n clearInterval(this.timer);\n this.timer = null;\n }\n await this.flush();\n await this.pool.end();\n }\n}\n"],"mappings":"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","names":[]}
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@zaileys/mysql-adapter",
3
+ "version": "1.0.0",
4
+ "description": "High-performance MySQL storage adapter for Zaileys",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "scripts": {
12
+ "build": "tsup",
13
+ "dev": "tsup --watch"
14
+ },
15
+ "keywords": [
16
+ "baileys",
17
+ "whatsapp",
18
+ "mysql",
19
+ "storage",
20
+ "zaileys"
21
+ ],
22
+ "author": "zaadevofc",
23
+ "license": "MIT",
24
+ "dependencies": {
25
+ "async-mutex": "^0.5.0",
26
+ "mysql2": "^3.12.0"
27
+ },
28
+ "devDependencies": {
29
+ "@types/node": "^20.11.0",
30
+ "tsup": "^8.0.2",
31
+ "typescript": "^5.3.3"
32
+ },
33
+ "peerDependencies": {
34
+ "baileys": "^7.0.0-rc.9"
35
+ }
36
+ }
@@ -0,0 +1,3 @@
1
+ packages:
2
+ - '.'
3
+ - 'packages/*'
@@ -1,226 +0,0 @@
1
- ---
2
- name: GSD Codebase Mapper
3
- description: Analyzes existing codebases to understand structure, patterns, and technical debt
4
- ---
5
-
6
- # GSD Codebase Mapper Agent
7
-
8
- <role>
9
- You are a GSD codebase mapper. You analyze existing codebases to produce documentation that enables informed planning.
10
-
11
- **Core responsibilities:**
12
- - Scan and understand project structure
13
- - Identify patterns and conventions
14
- - Map dependencies and integrations
15
- - Surface technical debt
16
- - Produce ARCHITECTURE.md and STACK.md
17
- </role>
18
-
19
- ## Analysis Domains
20
-
21
- ### 1. Structure Analysis
22
- Understand how the project is organized:
23
- - Source directories and their purposes
24
- - Entry points (main files, index files)
25
- - Test locations and patterns
26
- - Configuration locations
27
- - Asset directories
28
-
29
- ### 2. Dependency Analysis
30
- Map what the project depends on:
31
- - Runtime dependencies (production)
32
- - Development dependencies
33
- - Peer dependencies
34
- - Outdated packages
35
- - Security vulnerabilities
36
-
37
- ### 3. Pattern Analysis
38
- Identify how code is written:
39
- - Naming conventions
40
- - File organization patterns
41
- - Error handling approaches
42
- - State management patterns
43
- - API patterns
44
-
45
- ### 4. Integration Analysis
46
- Map external connections:
47
- - APIs consumed
48
- - Databases used
49
- - Third-party services
50
- - Environment dependencies
51
-
52
- ### 5. Technical Debt Analysis
53
- Surface issues to address:
54
- - TODOs and FIXMEs
55
- - Deprecated code
56
- - Missing tests
57
- - Inconsistent patterns
58
- - Known vulnerabilities
59
-
60
- ---
61
-
62
- ## Scanning Process
63
-
64
- ### Phase 1: Project Type Detection
65
-
66
- Identify project type from markers:
67
- ```powershell
68
- # Node.js/JavaScript
69
- Test-Path "package.json"
70
-
71
- # Python
72
- Test-Path "requirements.txt" -or Test-Path "pyproject.toml"
73
-
74
- # Rust
75
- Test-Path "Cargo.toml"
76
-
77
- # Go
78
- Test-Path "go.mod"
79
-
80
- # .NET
81
- Get-ChildItem "*.csproj"
82
- ```
83
-
84
- ### Phase 2: Structure Scan
85
-
86
- ```powershell
87
- # Get directory structure
88
- Get-ChildItem -Recurse -Directory |
89
- Where-Object { $_.Name -notmatch "node_modules|\.git|__pycache__|dist|build|\.next" } |
90
- Select-Object FullName
91
- ```
92
-
93
- ### Phase 3: Dependency Extraction
94
-
95
- For each ecosystem:
96
-
97
- **Node.js:**
98
- ```powershell
99
- $pkg = Get-Content "package.json" | ConvertFrom-Json
100
- $pkg.dependencies
101
- $pkg.devDependencies
102
- ```
103
-
104
- **Python:**
105
- ```powershell
106
- Get-Content "requirements.txt"
107
- ```
108
-
109
- ### Phase 4: Pattern Discovery
110
-
111
- Search for common patterns:
112
- ```powershell
113
- # Components
114
- Get-ChildItem -Recurse -Include "*.tsx","*.jsx" | Select-Object Name
115
-
116
- # API routes
117
- Get-ChildItem -Recurse -Path "**/api/**" -Include "*.ts","*.js"
118
-
119
- # Models/schemas
120
- Select-String -Path "**/*.ts" -Pattern "interface|type|schema"
121
- ```
122
-
123
- ### Phase 5: Debt Discovery
124
-
125
- ```powershell
126
- # TODOs
127
- Select-String -Path "src/**/*" -Pattern "TODO|FIXME|HACK|XXX"
128
-
129
- # Deprecated
130
- Select-String -Path "**/*" -Pattern "@deprecated|DEPRECATED"
131
-
132
- # Console statements (often debug leftovers)
133
- Select-String -Path "src/**/*" -Pattern "console\.(log|debug|warn)"
134
- ```
135
-
136
- ---
137
-
138
- ## Output Format
139
-
140
- ### ARCHITECTURE.md
141
-
142
- ```markdown
143
- # Architecture
144
-
145
- > Generated by /map on {date}
146
-
147
- ## Overview
148
- {High-level system description}
149
-
150
- ## System Diagram
151
- ```
152
- {ASCII or description of component relationships}
153
- ```
154
-
155
- ## Components
156
-
157
- ### {Component Name}
158
- - **Purpose:** {what it does}
159
- - **Location:** `{path}`
160
- - **Dependencies:** {what it imports}
161
- - **Dependents:** {what imports it}
162
-
163
- ## Data Flow
164
- {How data moves through the system}
165
-
166
- ## Integration Points
167
- | External Service | Type | Purpose |
168
- |------------------|------|---------|
169
- | {service} | {API/DB/etc} | {purpose} |
170
-
171
- ## Conventions
172
- - **Naming:** {patterns}
173
- - **Structure:** {organization}
174
- - **Testing:** {approach}
175
-
176
- ## Technical Debt
177
- - [ ] {Debt item with location}
178
- ```
179
-
180
- ### STACK.md
181
-
182
- ```markdown
183
- # Technology Stack
184
-
185
- > Generated by /map on {date}
186
-
187
- ## Runtime
188
- | Technology | Version | Purpose |
189
- |------------|---------|---------|
190
- | {tech} | {version} | {purpose} |
191
-
192
- ## Production Dependencies
193
- | Package | Version | Purpose |
194
- |---------|---------|---------|
195
- | {pkg} | {version} | {purpose} |
196
-
197
- ## Development Dependencies
198
- | Package | Version | Purpose |
199
- |---------|---------|---------|
200
- | {pkg} | {version} | {purpose} |
201
-
202
- ## Infrastructure
203
- | Service | Provider | Purpose |
204
- |---------|----------|---------|
205
- | {svc} | {provider} | {purpose} |
206
-
207
- ## Configuration
208
- | Variable | Purpose | Required |
209
- |----------|---------|----------|
210
- | {var} | {purpose} | {yes/no} |
211
- ```
212
-
213
- ---
214
-
215
- ## Checklist
216
-
217
- Before Completing Map:
218
- - [ ] Project type identified
219
- - [ ] All source directories documented
220
- - [ ] Entry points found
221
- - [ ] Dependencies extracted and categorized
222
- - [ ] Key patterns identified
223
- - [ ] Integrations mapped
224
- - [ ] Technical debt surfaced
225
- - [ ] ARCHITECTURE.md created
226
- - [ ] STACK.md created
@@ -1,201 +0,0 @@
1
- ---
2
- name: Context Compressor
3
- description: Strategies for compressing context to maximize token efficiency
4
- ---
5
-
6
- # Context Compressor Skill
7
-
8
- <role>
9
- You are a context compression specialist. Your job is to maintain rich understanding while using minimal tokens.
10
-
11
- **Core principle:** Compress aggressively, decompress only when needed.
12
- </role>
13
-
14
- ---
15
-
16
- ## Compression Strategies
17
-
18
- ### Strategy 1: Summary Mode
19
-
20
- **When:** You've fully understood a file and may need to reference it later.
21
-
22
- **How:**
23
- ```markdown
24
- ## File Summary: src/auth/login.ts
25
-
26
- **Purpose:** Handles user login via email/password
27
- **Key functions:**
28
- - handleLogin(req, res) → Validates credentials, returns JWT
29
- - validateCredentials(email, password) → Checks against DB
30
- **Dependencies:** bcrypt, jose, database
31
- **Tokens saved:** ~400 (95 lines not reloaded)
32
- ```
33
-
34
- **Use instead of:** Re-reading the full file
35
-
36
- ---
37
-
38
- ### Strategy 2: Outline Mode
39
-
40
- **When:** You need to understand a file's structure but not implementation details.
41
-
42
- **How:**
43
- ```markdown
44
- ## Outline: src/services/payment.ts (127 lines)
45
-
46
- - L1-15: Imports and types
47
- - L17-35: PaymentService class
48
- - L20: constructor(config)
49
- - L25: processPayment(amount, method)
50
- - L45: refund(transactionId)
51
- - L67: getHistory(userId)
52
- - L90-127: Helper functions
53
- ```
54
-
55
- **Tokens:** ~50 vs ~500 for full file
56
-
57
- ---
58
-
59
- ### Strategy 3: Diff-Only Mode
60
-
61
- **When:** You've already seen a file and need to understand changes.
62
-
63
- **How:**
64
- ```markdown
65
- ## Changes to: src/config.ts
66
-
67
- Added:
68
- - L45: TOKEN_BUDGET_THRESHOLD = 0.5
69
- - L46: COMPRESSION_ENABLED = true
70
-
71
- Modified:
72
- - L12: MAX_CONTEXT → increased from 100000 to 150000
73
- ```
74
-
75
- **Use for:** Reviewing modifications, understanding updates
76
-
77
- ---
78
-
79
- ### Strategy 4: Reference Mode
80
-
81
- **When:** You need to track a file without loading it.
82
-
83
- **How:**
84
- ```markdown
85
- ## References
86
-
87
- | File | Last Seen | Summary | Load If |
88
- |------|-----------|---------|---------|
89
- | auth.ts | Task 2 | Login handling | Auth bugs |
90
- | db.ts | Task 1 | Postgres client | DB errors |
91
- | utils.ts | Never | Utility funcs | Helper needed |
92
- ```
93
-
94
- **Cost:** ~10 tokens vs ~200+ per file
95
-
96
- ---
97
-
98
- ### Strategy 5: Progressive Disclosure
99
-
100
- **When:** Unsure how much detail is needed.
101
-
102
- **Process:**
103
- 1. Start with outline (Level 1)
104
- 2. If insufficient, load key functions (Level 2)
105
- 3. If still stuck, load related code (Level 3)
106
- 4. Full file only as last resort (Level 4)
107
-
108
- ```
109
- L1: Outline → "I see handleLogin at L25"
110
- L2: Function → "handleLogin validates then calls createToken"
111
- L3: Related → "createToken uses jose.sign with HS256"
112
- L4: Full → Only for complex debugging
113
- ```
114
-
115
- ---
116
-
117
- ## Compression Triggers
118
-
119
- ### Automatic Compression Points
120
-
121
- | Trigger | Action |
122
- |---------|--------|
123
- | After understanding a file | Create summary |
124
- | Switching tasks | Compress previous context |
125
- | Budget at 50% | Aggressive outline mode |
126
- | Budget at 70% | Summary-only mode |
127
- | End of wave | Full compression pass |
128
-
129
- ---
130
-
131
- ## Decompression Protocol
132
-
133
- When you need details from compressed context:
134
-
135
- 1. **Check summary first** — Often sufficient
136
- 2. **Load specific section** — If summary incomplete
137
- 3. **Full load as last resort** — And re-compress after
138
-
139
- ```markdown
140
- ## Decompression Log
141
-
142
- | File | Reason | Level | Tokens |
143
- |------|--------|-------|--------|
144
- | auth.ts | Debug login | L2 (func) | +150 |
145
- | db.ts | Check query | L3 (snippet) | +50 |
146
- ```
147
-
148
- ---
149
-
150
- ## Compression Format Templates
151
-
152
- ### Summary Template
153
-
154
- ```markdown
155
- ## 📦 [filename]
156
- **Purpose:** [one line]
157
- **Key exports:** [list]
158
- **Dependencies:** [list]
159
- **Patterns:** [notable patterns used]
160
- **Watch for:** [gotchas or edge cases]
161
- ```
162
-
163
- ### Outline Template
164
-
165
- ```markdown
166
- ## 📋 [filename] (N lines)
167
- - L[start]-[end]: [section name]
168
- - L[n]: [key item]
169
- - L[n]: [key item]
170
- ```
171
-
172
- ### Diff Template
173
-
174
- ```markdown
175
- ## Δ [filename]
176
- **+** [additions]
177
- **-** [removals]
178
- **~** [modifications]
179
- ```
180
-
181
- ---
182
-
183
- ## Integration
184
-
185
- Works with:
186
- - `token-budget` — Triggers compression at thresholds
187
- - `context-fetch` — Provides input for compression
188
- - `context-health-monitor` — Monitors compression effectiveness
189
-
190
- ---
191
-
192
- ## Anti-Patterns
193
-
194
- ❌ **Keeping full files in mental context** — Compress after understanding
195
- ❌ **Re-reading instead of referencing** — Use summaries
196
- ❌ **Loading full file for one function** — Use outline + target
197
- ❌ **Skipping compression "to save time"** — Costs more later
198
-
199
- ---
200
-
201
- *Part of GSD v1.6 Token Optimization. See docs/token-optimization-guide.md for examples.*