sqlew 4.0.1 → 4.0.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/CHANGELOG.md +127 -0
- package/README.md +29 -113
- package/assets/claude-md-snippets/plan-mode-integration.md +13 -0
- package/assets/sample-commands/sqlew.md +144 -0
- package/assets/sample-skills/sqlew-plan-guidance/SKILL.md +55 -0
- package/dist/cli/db-dump.d.ts +4 -0
- package/dist/cli/db-dump.d.ts.map +1 -1
- package/dist/cli/db-dump.js +89 -114
- package/dist/cli/db-dump.js.map +1 -1
- package/dist/cli/db-export.d.ts +1 -0
- package/dist/cli/db-export.d.ts.map +1 -1
- package/dist/cli/db-export.js +46 -80
- package/dist/cli/db-export.js.map +1 -1
- package/dist/cli/db-import.d.ts +1 -0
- package/dist/cli/db-import.d.ts.map +1 -1
- package/dist/cli/db-import.js +52 -90
- package/dist/cli/db-import.js.map +1 -1
- package/dist/cli.d.ts +10 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +57 -59
- package/dist/cli.js.map +1 -1
- package/dist/database/migrations/v4/20251127000002_v4_seed_help_system.d.ts.map +1 -1
- package/dist/database/migrations/v4/20251127000002_v4_seed_help_system.js +7 -4
- package/dist/database/migrations/v4/20251127000002_v4_seed_help_system.js.map +1 -1
- package/dist/database/operations/inserts.d.ts.map +1 -1
- package/dist/database/operations/inserts.js +7 -0
- package/dist/database/operations/inserts.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +70 -48
- package/dist/index.js.map +1 -1
- package/dist/init-commands.d.ts +5 -2
- package/dist/init-commands.d.ts.map +1 -1
- package/dist/init-commands.js +36 -175
- package/dist/init-commands.js.map +1 -1
- package/dist/init-skills.d.ts +19 -0
- package/dist/init-skills.d.ts.map +1 -0
- package/dist/init-skills.js +104 -0
- package/dist/init-skills.js.map +1 -0
- package/dist/server/setup.d.ts.map +1 -1
- package/dist/server/setup.js +9 -0
- package/dist/server/setup.js.map +1 -1
- package/dist/tests/database/testing-config.d.ts +4 -0
- package/dist/tests/database/testing-config.d.ts.map +1 -1
- package/dist/tests/database/testing-config.js +1 -1
- package/dist/tests/database/testing-config.js.map +1 -1
- package/dist/tests/docker/native/test-harness.d.ts +56 -1
- package/dist/tests/docker/native/test-harness.d.ts.map +1 -1
- package/dist/tests/docker/native/test-harness.js +221 -5
- package/dist/tests/docker/native/test-harness.js.map +1 -1
- package/dist/tests/unit/case-insensitive-validator.test.d.ts +14 -0
- package/dist/tests/unit/case-insensitive-validator.test.d.ts.map +1 -0
- package/dist/tests/unit/case-insensitive-validator.test.js +390 -0
- package/dist/tests/unit/case-insensitive-validator.test.js.map +1 -0
- package/dist/tests/unit/utils/case-insensitive-validator.test.d.ts +2 -0
- package/dist/tests/unit/utils/case-insensitive-validator.test.d.ts.map +1 -0
- package/dist/tests/unit/utils/case-insensitive-validator.test.js +97 -0
- package/dist/tests/unit/utils/case-insensitive-validator.test.js.map +1 -0
- package/dist/tools/context/actions/create-policy.d.ts.map +1 -1
- package/dist/tools/context/actions/create-policy.js +5 -1
- package/dist/tools/context/actions/create-policy.js.map +1 -1
- package/dist/tools/tasks/actions/get.d.ts.map +1 -1
- package/dist/tools/tasks/actions/get.js +1 -4
- package/dist/tools/tasks/actions/get.js.map +1 -1
- package/dist/tools/tasks/internal/task-queries.d.ts.map +1 -1
- package/dist/tools/tasks/internal/task-queries.js +2 -8
- package/dist/tools/tasks/internal/task-queries.js.map +1 -1
- package/dist/types.d.ts +10 -6
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/case-insensitive-validator.d.ts +102 -0
- package/dist/utils/case-insensitive-validator.d.ts.map +1 -0
- package/dist/utils/case-insensitive-validator.js +144 -0
- package/dist/utils/case-insensitive-validator.js.map +1 -0
- package/dist/utils/exporter/export.d.ts +22 -7
- package/dist/utils/exporter/export.d.ts.map +1 -1
- package/dist/utils/exporter/export.js +33 -49
- package/dist/utils/exporter/export.js.map +1 -1
- package/dist/utils/importer/import.js +64 -27
- package/dist/utils/importer/import.js.map +1 -1
- package/dist/utils/importer/master-tables.d.ts +3 -1
- package/dist/utils/importer/master-tables.d.ts.map +1 -1
- package/dist/utils/importer/master-tables.js +7 -29
- package/dist/utils/importer/master-tables.js.map +1 -1
- package/dist/utils/sql-dump/core/generate-dump.d.ts.map +1 -1
- package/dist/utils/sql-dump/core/generate-dump.js +25 -5
- package/dist/utils/sql-dump/core/generate-dump.js.map +1 -1
- package/dist/utils/sql-dump/core/index-export.d.ts +3 -2
- package/dist/utils/sql-dump/core/index-export.d.ts.map +1 -1
- package/dist/utils/sql-dump/core/index-export.js +9 -9
- package/dist/utils/sql-dump/core/index-export.js.map +1 -1
- package/dist/utils/sql-dump/schema/indexes.d.ts +14 -0
- package/dist/utils/sql-dump/schema/indexes.d.ts.map +1 -1
- package/dist/utils/sql-dump/schema/indexes.js +81 -15
- package/dist/utils/sql-dump/schema/indexes.js.map +1 -1
- package/dist/utils/sql-dump/schema/tables.d.ts +4 -1
- package/dist/utils/sql-dump/schema/tables.d.ts.map +1 -1
- package/dist/utils/sql-dump/schema/tables.js +81 -51
- package/dist/utils/sql-dump/schema/tables.js.map +1 -1
- package/docs/SLASH_COMMANDS.md +192 -478
- package/docs/SPECIALIZED_AGENTS.md +81 -43
- package/docs/cli/DATABASE_MIGRATION.md +62 -58
- package/docs/cli/DATA_EXPORT_IMPORT.md +403 -103
- package/docs/cli/README.md +95 -45
- package/package.json +4 -6
- package/assets/sample-commands/sqw-documentor.md +0 -204
- package/assets/sample-commands/sqw-plan.md +0 -348
- package/assets/sample-commands/sqw-research.md +0 -359
- package/assets/sample-commands/sqw-review.md +0 -377
- package/assets/sample-commands/sqw-scrum.md +0 -457
package/docs/cli/README.md
CHANGED
|
@@ -7,55 +7,62 @@
|
|
|
7
7
|
sqlew provides CLI commands for advanced database operations that complement the main MCP server functionality. These
|
|
8
8
|
commands are useful for database administration, backup/restore, and cross-project data migration.
|
|
9
9
|
|
|
10
|
+
> **⚠️ Important**: Database CLI commands must be run via `npm run` from the project directory.
|
|
11
|
+
> `npx` is not supported for database operations.
|
|
12
|
+
|
|
10
13
|
## What is CLI Mode?
|
|
11
14
|
|
|
12
15
|
While the primary use of sqlew is as an **MCP server** (integrated with Claude Code via `.mcp.json`), it also provides
|
|
13
16
|
standalone **CLI commands** for:
|
|
14
17
|
|
|
15
|
-
- **Database Migration** - Generate SQL dumps for SQLite, MySQL,
|
|
18
|
+
- **Database Migration** - Generate SQL dumps for SQLite, MySQL, PostgreSQL migration
|
|
16
19
|
- **Project Export/Import** - Share project data across databases or team members
|
|
17
20
|
- **Backup/Restore** - Create SQL backups with schema and data
|
|
18
21
|
|
|
19
22
|
## MCP Server vs CLI Mode
|
|
20
23
|
|
|
21
|
-
| Feature | MCP Server (
|
|
24
|
+
| Feature | MCP Server (via `.mcp.json`) | CLI Mode |
|
|
22
25
|
|-----------------|----------------------------------------|----------------------------------------------|
|
|
23
26
|
| **Primary Use** | AI agent context management | Database administration |
|
|
24
27
|
| **Setup** | `.mcp.json` configuration | Per-project npm install |
|
|
25
28
|
| **Commands** | MCP tools (decision, task, file, etc.) | CLI commands (db:dump, db:export, db:import) |
|
|
26
29
|
| **When to Use** | Daily AI development workflow | Database migration, backup, data sharing |
|
|
27
30
|
|
|
28
|
-
##
|
|
31
|
+
## Usage
|
|
32
|
+
|
|
33
|
+
### Within mcp-sqlew Project (Development)
|
|
29
34
|
|
|
30
|
-
|
|
35
|
+
Use npm scripts with `--` to pass arguments:
|
|
31
36
|
|
|
32
37
|
```bash
|
|
33
|
-
|
|
34
|
-
npm
|
|
38
|
+
# Generate MySQL dump
|
|
39
|
+
npm run db:dump -- mysql backup.sql
|
|
40
|
+
|
|
41
|
+
# Export project to JSON
|
|
42
|
+
npm run db:export -- data.json project=myproject
|
|
43
|
+
|
|
44
|
+
# Import from JSON
|
|
45
|
+
npm run db:import -- data.json
|
|
35
46
|
```
|
|
36
47
|
|
|
37
|
-
###
|
|
48
|
+
### In Projects with sqlew as Dependency
|
|
38
49
|
|
|
39
50
|
Add to your `package.json`:
|
|
40
51
|
|
|
41
52
|
```json
|
|
42
53
|
{
|
|
43
54
|
"scripts": {
|
|
44
|
-
"
|
|
55
|
+
"db:dump": "node node_modules/sqlew/dist/cli.js db:dump",
|
|
56
|
+
"db:export": "node node_modules/sqlew/dist/cli.js db:export",
|
|
57
|
+
"db:import": "node node_modules/sqlew/dist/cli.js db:import"
|
|
45
58
|
}
|
|
46
59
|
}
|
|
47
60
|
```
|
|
48
61
|
|
|
49
|
-
Then
|
|
50
|
-
|
|
51
|
-
```bash
|
|
52
|
-
npm run sqlew db:dump --format=mysql --output=backup.sql
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
### Direct Command (Without Shortcut)
|
|
62
|
+
Then use:
|
|
56
63
|
|
|
57
64
|
```bash
|
|
58
|
-
|
|
65
|
+
npm run db:dump -- mysql backup.sql
|
|
59
66
|
```
|
|
60
67
|
|
|
61
68
|
## Available Commands
|
|
@@ -67,17 +74,20 @@ Generate complete SQL dumps (schema + data) for database migration or backup.
|
|
|
67
74
|
**Use Cases**:
|
|
68
75
|
|
|
69
76
|
- Full database backup with schema
|
|
70
|
-
- Cross-database migration (SQLite → MySQL/
|
|
77
|
+
- Cross-database migration (SQLite → MySQL/PostgreSQL)
|
|
71
78
|
- Development → Production deployment
|
|
72
79
|
|
|
73
80
|
**Quick Example**:
|
|
74
81
|
|
|
75
82
|
```bash
|
|
76
|
-
#
|
|
77
|
-
|
|
83
|
+
# Generate MySQL dump (positional format argument)
|
|
84
|
+
npm run db:dump -- mysql backup.sql
|
|
85
|
+
|
|
86
|
+
# Generate PostgreSQL dump
|
|
87
|
+
npm run db:dump -- postgresql backup.sql
|
|
78
88
|
|
|
79
|
-
#
|
|
80
|
-
|
|
89
|
+
# MySQL from PostgreSQL source
|
|
90
|
+
npm run db:dump -- mysql backup.sql from=postgresql
|
|
81
91
|
```
|
|
82
92
|
|
|
83
93
|
**📖 Full Documentation**: [DATABASE_MIGRATION.md](DATABASE_MIGRATION.md)
|
|
@@ -98,10 +108,10 @@ Export project data to JSON format for sharing or multi-project consolidation.
|
|
|
98
108
|
|
|
99
109
|
```bash
|
|
100
110
|
# Export specific project
|
|
101
|
-
|
|
111
|
+
npm run db:export -- project.json project=my-project
|
|
102
112
|
|
|
103
113
|
# Export all projects
|
|
104
|
-
|
|
114
|
+
npm run db:export -- all-projects.json
|
|
105
115
|
```
|
|
106
116
|
|
|
107
117
|
**📖 Full Documentation**: [DATA_EXPORT_IMPORT.md](DATA_EXPORT_IMPORT.md#export-command)
|
|
@@ -122,28 +132,69 @@ Import project data from JSON export files.
|
|
|
122
132
|
|
|
123
133
|
```bash
|
|
124
134
|
# Import from JSON export
|
|
125
|
-
|
|
135
|
+
npm run db:import -- project.json
|
|
126
136
|
|
|
127
137
|
# Import with custom name
|
|
128
|
-
|
|
138
|
+
npm run db:import -- project.json project-name=new-name
|
|
129
139
|
|
|
130
140
|
# Dry-run validation
|
|
131
|
-
|
|
141
|
+
npm run db:import -- project.json dry-run=true
|
|
132
142
|
```
|
|
133
143
|
|
|
134
144
|
**📖 Full Documentation**: [DATA_EXPORT_IMPORT.md](DATA_EXPORT_IMPORT.md#import-command)
|
|
135
145
|
|
|
136
146
|
---
|
|
137
147
|
|
|
148
|
+
## Recommended Data Migration Workflow
|
|
149
|
+
|
|
150
|
+
### Cross-Database Migration (Recommended: JSON)
|
|
151
|
+
|
|
152
|
+
For migrations between different database systems (e.g., SQLite to MySQL, PostgreSQL to MySQL), **use JSON format**:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
# Step 1: Export from source database
|
|
156
|
+
npm run db:export -- backup.json
|
|
157
|
+
|
|
158
|
+
# Step 2: Configure target database connection
|
|
159
|
+
# (Update your .sqlew/config.toml or environment variables)
|
|
160
|
+
|
|
161
|
+
# Step 3: Import to target database
|
|
162
|
+
npm run db:import -- backup.json
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
**Why JSON for cross-database migration?**
|
|
166
|
+
- Database-agnostic format - no SQL syntax differences
|
|
167
|
+
- Automatic ID remapping handles foreign key relationships
|
|
168
|
+
- Preserves all data integrity across different RDBMS
|
|
169
|
+
|
|
170
|
+
### SQL Dump (Same-RDBMS Only)
|
|
171
|
+
|
|
172
|
+
SQL dump (`db:dump`) is designed for **same-database-type operations only**:
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
# SQLite backup (restore to SQLite)
|
|
176
|
+
npm run db:dump -- sqlite backup.sql
|
|
177
|
+
|
|
178
|
+
# MySQL backup (restore to MySQL)
|
|
179
|
+
npm run db:dump -- mysql backup.sql
|
|
180
|
+
|
|
181
|
+
# PostgreSQL backup (restore to PostgreSQL)
|
|
182
|
+
npm run db:dump -- postgresql backup.sql
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
**Note**: SQL dump does NOT support cross-database migrations (e.g., SQLite to MySQL). The generated SQL contains database-specific syntax that may not be compatible with other RDBMS.
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
138
189
|
## Quick Comparison: When to Use Which Command
|
|
139
190
|
|
|
140
191
|
| Scenario | Use Command | Restore Capability |
|
|
141
192
|
|-----------------------------------------------|---------------------------|----------------------------|
|
|
142
|
-
| **Full database backup**
|
|
143
|
-
| **Cross-database migration** (SQLite
|
|
144
|
-
| **Share project with team** | `db:export` / `db:import` |
|
|
145
|
-
| **Consolidate multiple projects** | `db:export` / `db:import` |
|
|
146
|
-
| **Backup/restore same database** | `db:dump` |
|
|
193
|
+
| **Full database backup (same RDBMS)** | `db:dump` | Full restore |
|
|
194
|
+
| **Cross-database migration** (SQLite -> MySQL)| `db:export` / `db:import` | Full restore via JSON |
|
|
195
|
+
| **Share project with team** | `db:export` / `db:import` | Skips if project exists |
|
|
196
|
+
| **Consolidate multiple projects** | `db:export` / `db:import` | Skips if project exists |
|
|
197
|
+
| **Backup/restore same database** | `db:dump` | Full restore |
|
|
147
198
|
|
|
148
199
|
**⚠️ Important**: `db:export`/`db:import` uses `--skip-if-exists=true` by default, so it's NOT suitable for
|
|
149
200
|
backup/restore to the same database. Use `db:dump` for proper backup/restore.
|
|
@@ -154,7 +205,7 @@ backup/restore to the same database. Use `db:dump` for proper backup/restore.
|
|
|
154
205
|
|
|
155
206
|
```bash
|
|
156
207
|
# Create SQL backup with schema + data
|
|
157
|
-
|
|
208
|
+
npm run db:dump -- sqlite backup-$(date +%Y%m%d).sql
|
|
158
209
|
|
|
159
210
|
# Or simple SQLite file copy
|
|
160
211
|
cp .sqlew/sqlew.db .sqlew/backup-$(date +%Y%m%d).db
|
|
@@ -164,36 +215,35 @@ cp .sqlew/sqlew.db .sqlew/backup-$(date +%Y%m%d).db
|
|
|
164
215
|
|
|
165
216
|
```bash
|
|
166
217
|
# Developer A: Export project
|
|
167
|
-
|
|
218
|
+
npm run db:export -- feature-x.json project=feature-x
|
|
168
219
|
|
|
169
220
|
# Developer B: Import project (in their own database)
|
|
170
|
-
|
|
221
|
+
npm run db:import -- feature-x.json
|
|
171
222
|
```
|
|
172
223
|
|
|
173
224
|
### Workflow 3: Migrate to MySQL from SQLite
|
|
174
225
|
|
|
175
226
|
```bash
|
|
176
227
|
# Step 1: Generate MySQL dump
|
|
177
|
-
|
|
228
|
+
npm run db:dump -- mysql migrate-to-mysql.sql
|
|
178
229
|
|
|
179
230
|
# Step 2: Create MySQL database
|
|
180
231
|
mysql -e "CREATE DATABASE sqlew_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
|
|
181
232
|
|
|
182
233
|
# Step 3: Import dump
|
|
183
|
-
mysql sqlew_db < migrate-to-mysql.sql
|
|
234
|
+
mysql -u user -p sqlew_db < migrate-to-mysql.sql
|
|
184
235
|
```
|
|
185
236
|
|
|
186
|
-
### Workflow 4: Consolidate Multiple Projects
|
|
237
|
+
### Workflow 4: Consolidate Multiple Projects
|
|
187
238
|
|
|
188
239
|
```bash
|
|
189
240
|
# Export from each project
|
|
190
|
-
|
|
191
|
-
|
|
241
|
+
npm run db:export -- /tmp/a.json project=project-a
|
|
242
|
+
npm run db:export -- /tmp/b.json project=project-b
|
|
192
243
|
|
|
193
244
|
# Import all to shared database
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
node node_modules/sqlew/dist/cli.js db:import --source=/tmp/b.json
|
|
245
|
+
npm run db:import -- /tmp/a.json
|
|
246
|
+
npm run db:import -- /tmp/b.json
|
|
197
247
|
```
|
|
198
248
|
|
|
199
249
|
## Getting Help
|
|
@@ -201,9 +251,9 @@ node node_modules/sqlew/dist/cli.js db:import --source=/tmp/b.json
|
|
|
201
251
|
Show command-specific help:
|
|
202
252
|
|
|
203
253
|
```bash
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
254
|
+
npm run db:dump -- --help
|
|
255
|
+
npm run db:export -- --help
|
|
256
|
+
npm run db:import -- --help
|
|
207
257
|
```
|
|
208
258
|
|
|
209
259
|
## Detailed Documentation
|
package/package.json
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sqlew",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.3",
|
|
4
4
|
"description": "MCP server that gives AI agents a shared SQL-backed context repository for decisions, constraints, and tasks",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
8
8
|
"sqlew": "dist/index.js",
|
|
9
|
-
"sqlew-cli": "dist/cli.js",
|
|
10
|
-
"sqlew-init-agents": "dist/init-agents.js",
|
|
11
9
|
"sqlew-init-commands": "dist/init-commands.js"
|
|
12
10
|
},
|
|
13
11
|
"files": [
|
|
@@ -54,7 +52,6 @@
|
|
|
54
52
|
"test:sql-dump:verbose": "node --test --test-force-exit --import tsx \"src/tests/database/sql-dump/**/*.test.ts\"",
|
|
55
53
|
"test:all-features": "npm run build && node dist/tests/integration/all-features.standalone.js",
|
|
56
54
|
"test:docker": "npm run build && node --test --test-force-exit dist/tests/docker/**/*.test.js",
|
|
57
|
-
"test:cross-db": "npm run build && node --test dist/tests/docker/cross-database.test.js",
|
|
58
55
|
"test:native": "npm run build && node --test --test-concurrency=1 --test-force-exit dist/tests/docker/native/**/*.test.js | node scripts/filter-test-output.js",
|
|
59
56
|
"test:native:verbose": "npm run build && node --test --test-concurrency=1 --test-force-exit dist/tests/docker/native/**/*.test.js",
|
|
60
57
|
"test:migration-upgrade-paths": "echo 'v3 migration tests moved to v3 subdirectory - use test:native for v4 RDBMS tests'",
|
|
@@ -72,10 +69,11 @@
|
|
|
72
69
|
"seed:make": "npm run knex seed:make",
|
|
73
70
|
"seed:run": "npm run knex seed:run",
|
|
74
71
|
"db:dump": "node dist/cli.js db:dump",
|
|
75
|
-
"db:export": "node dist/cli.js db:export"
|
|
72
|
+
"db:export": "node dist/cli.js db:export",
|
|
73
|
+
"db:import": "node dist/cli.js db:import"
|
|
76
74
|
},
|
|
77
75
|
"engines": {
|
|
78
|
-
"node": ">=
|
|
76
|
+
"node": ">=20.0.0"
|
|
79
77
|
},
|
|
80
78
|
"repository": {
|
|
81
79
|
"type": "git",
|
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Records architectural decisions and constraints with full context (rationale, alternatives, tradeoffs)
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Sqlew Documentor Workflow
|
|
6
|
-
|
|
7
|
-
Decision documentation workflow for recording architectural decisions and constraints with full context.
|
|
8
|
-
|
|
9
|
-
## Agent Invocation
|
|
10
|
-
|
|
11
|
-
This workflow uses the specialized sqlew-architect agent:
|
|
12
|
-
|
|
13
|
-
```
|
|
14
|
-
Task tool → subagent_type: "sqlew-architect" (opus)
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
**Example:**
|
|
18
|
-
```typescript
|
|
19
|
-
Task({
|
|
20
|
-
subagent_type: "sqlew-architect",
|
|
21
|
-
prompt: "Document the following architectural decision: [decision topic]. Check for duplicates, record with rationale/alternatives/tradeoffs, establish constraints if needed."
|
|
22
|
-
})
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
---
|
|
26
|
-
|
|
27
|
-
**Agent Instructions (for sqlew-architect):**
|
|
28
|
-
|
|
29
|
-
You are an expert software architect specializing in decision documentation and architectural constraint management. You work with the sqlew MCP shared context server to maintain consistent architectural decisions across the project.
|
|
30
|
-
|
|
31
|
-
## Your Role
|
|
32
|
-
|
|
33
|
-
Document architectural decisions with full context (rationale, alternatives, tradeoffs) and establish architectural constraints to guide development.
|
|
34
|
-
|
|
35
|
-
## Available Tools
|
|
36
|
-
|
|
37
|
-
- **mcp__sqlew__suggest**: Check for related/duplicate items before creating new ones (v4.0)
|
|
38
|
-
- **Decision search** (default: `target: "decision"`): by_key, by_tags, by_context, check_duplicate
|
|
39
|
-
- **Constraint search** (`target: "constraint"`): by_text, by_tags, by_context, check_duplicate
|
|
40
|
-
- **mcp__sqlew__decision**: Record decisions with rich context (set, get, list, search_tags, search_layer, versions, add_decision_context)
|
|
41
|
-
- **Note**: `decision.set` automatically suggests related constraints (v4.0)
|
|
42
|
-
- **mcp__sqlew__constraint**: Define architectural rules and guidelines (add, get, deactivate)
|
|
43
|
-
|
|
44
|
-
## Workflow
|
|
45
|
-
|
|
46
|
-
### 1. Decision Documentation
|
|
47
|
-
|
|
48
|
-
When documenting a new architectural decision:
|
|
49
|
-
|
|
50
|
-
1. **Check for duplicates/related decisions** using `suggest`:
|
|
51
|
-
```typescript
|
|
52
|
-
suggest({ action: "check_duplicate", key: "proposed-decision-key" })
|
|
53
|
-
suggest({ action: "by_key", key: "related-pattern" })
|
|
54
|
-
suggest({ action: "by_tags", tags: ["relevant-tag"] })
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
2. **Discuss options** with the user if alternatives exist or if related decisions are found
|
|
58
|
-
|
|
59
|
-
3. **Record the decision** with comprehensive context:
|
|
60
|
-
```typescript
|
|
61
|
-
decision({
|
|
62
|
-
action: "set",
|
|
63
|
-
key: "decision-key",
|
|
64
|
-
value: "The chosen approach",
|
|
65
|
-
layer: "business", // or presentation, data, infrastructure, cross-cutting
|
|
66
|
-
rationale: "Why this decision was made",
|
|
67
|
-
alternatives_considered: "What other options were evaluated",
|
|
68
|
-
tradeoffs: "Benefits and drawbacks of this choice",
|
|
69
|
-
tags: ["relevant", "tags"]
|
|
70
|
-
})
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
4. **Link to related context** if needed:
|
|
74
|
-
```typescript
|
|
75
|
-
decision({
|
|
76
|
-
action: "add_decision_context",
|
|
77
|
-
key: "decision-key",
|
|
78
|
-
context_type: "related_decision",
|
|
79
|
-
context_value: "other-decision-key",
|
|
80
|
-
notes: "How these decisions relate"
|
|
81
|
-
})
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
### 2. Constraint Management (v4.0 Enhanced)
|
|
85
|
-
|
|
86
|
-
When establishing architectural constraints:
|
|
87
|
-
|
|
88
|
-
1. **Check for duplicates/similar constraints** using `suggest` (NEW in v4.0):
|
|
89
|
-
```typescript
|
|
90
|
-
suggest({ action: "check_duplicate", target: "constraint", text: "All API endpoints must verify JWT" })
|
|
91
|
-
suggest({ action: "by_text", target: "constraint", text: "authentication required" })
|
|
92
|
-
suggest({ action: "by_tags", target: "constraint", tags: ["security", "api"] })
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
2. **Discuss options** with the user if similar constraints exist
|
|
96
|
-
|
|
97
|
-
3. **Define the constraint** with clear guidance:
|
|
98
|
-
```typescript
|
|
99
|
-
constraint({
|
|
100
|
-
action: "add",
|
|
101
|
-
category: "architecture", // or performance, security, compatibility
|
|
102
|
-
description: "Clear statement of the rule",
|
|
103
|
-
priority: 3, // 1=low, 2=medium, 3=high, 4=critical
|
|
104
|
-
layer: "cross-cutting", // or specific layer if applicable
|
|
105
|
-
tags: ["relevant", "tags"]
|
|
106
|
-
})
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
4. **Link constraints to decisions** when they enforce architectural choices
|
|
110
|
-
|
|
111
|
-
**Note**: When you create a decision using `decision.set`, the system automatically suggests related constraints in the response. Review these suggestions and link relevant constraints.
|
|
112
|
-
|
|
113
|
-
## Command Usage
|
|
114
|
-
|
|
115
|
-
### Interactive Mode
|
|
116
|
-
```bash
|
|
117
|
-
/sqw-documentor
|
|
118
|
-
```
|
|
119
|
-
Prompts you through the decision/constraint workflow.
|
|
120
|
-
|
|
121
|
-
### With Arguments
|
|
122
|
-
```bash
|
|
123
|
-
/sqw-documentor document API authentication decision
|
|
124
|
-
/sqw-documentor create constraint for database access patterns
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
## Best Practices
|
|
128
|
-
|
|
129
|
-
1. **Always check for duplicates** before creating new decisions - prevents fragmentation
|
|
130
|
-
2. **Always check for duplicate constraints** (v4.0) - use `suggest` with `target: "constraint"` before creating
|
|
131
|
-
3. **Use descriptive keys** - kebab-case, 64 chars max (e.g., "api-authentication-method")
|
|
132
|
-
4. **Document rationale thoroughly** - future developers need to understand WHY
|
|
133
|
-
5. **Include alternatives considered** - shows the decision was thoughtful
|
|
134
|
-
6. **Be honest about tradeoffs** - every decision has costs
|
|
135
|
-
7. **Tag comprehensively** - enables discovery via search
|
|
136
|
-
8. **Use appropriate layers** - helps organize decisions by architectural concern
|
|
137
|
-
9. **Link related decisions** - builds decision context graph
|
|
138
|
-
10. **Review related_constraints** (v4.0) - decision.set returns suggested constraints, review and link
|
|
139
|
-
11. **Prioritize constraints correctly** - critical constraints must be enforced
|
|
140
|
-
|
|
141
|
-
## Layer Selection
|
|
142
|
-
|
|
143
|
-
- **presentation**: UI/UX decisions, frontend framework choices
|
|
144
|
-
- **business**: Domain logic, business rules, service architecture
|
|
145
|
-
- **data**: Database schema, data access patterns, ORM choices
|
|
146
|
-
- **infrastructure**: Deployment, scaling, infrastructure-as-code
|
|
147
|
-
- **cross-cutting**: Security, logging, error handling, monitoring
|
|
148
|
-
|
|
149
|
-
## Example Session
|
|
150
|
-
|
|
151
|
-
```markdown
|
|
152
|
-
User: We need to decide on our authentication approach
|
|
153
|
-
|
|
154
|
-
Architect: Let me check for existing authentication decisions...
|
|
155
|
-
|
|
156
|
-
*Runs suggest({ action: "by_tags", tags: ["authentication"] })*
|
|
157
|
-
|
|
158
|
-
I found 2 related decisions:
|
|
159
|
-
1. "api-authentication-method" - chose JWT tokens
|
|
160
|
-
2. "session-management-strategy" - stateless sessions
|
|
161
|
-
|
|
162
|
-
Are you looking to:
|
|
163
|
-
- Refine these existing decisions?
|
|
164
|
-
- Document a new aspect of authentication?
|
|
165
|
-
- Change direction on authentication approach?
|
|
166
|
-
|
|
167
|
-
User: We need to document the JWT token expiration policy
|
|
168
|
-
|
|
169
|
-
Architect: *Runs suggest({ action: "check_duplicate", key: "jwt-token-expiration" })*
|
|
170
|
-
|
|
171
|
-
No duplicates found. Let me document this decision:
|
|
172
|
-
|
|
173
|
-
*Runs decision({
|
|
174
|
-
action: "set",
|
|
175
|
-
key: "jwt-token-expiration-policy",
|
|
176
|
-
value: "Access tokens expire in 15 minutes, refresh tokens in 7 days",
|
|
177
|
-
layer: "business",
|
|
178
|
-
rationale: "Balance security (short-lived access tokens) with user experience (reasonable refresh window)",
|
|
179
|
-
alternatives_considered: "Considered 1h access tokens (too risky), 30d refresh (too long), no expiration (unacceptable security risk)",
|
|
180
|
-
tradeoffs: "15min requires more frequent token refreshes (network overhead) but limits exposure window. 7d refresh balances security with mobile offline scenarios.",
|
|
181
|
-
tags: ["authentication", "security", "jwt", "tokens"]
|
|
182
|
-
})*
|
|
183
|
-
|
|
184
|
-
Decision documented. Should I link this to the existing "api-authentication-method" decision?
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
## Token Efficiency Tips
|
|
188
|
-
|
|
189
|
-
- Use `suggest` actions to avoid redundant decision creation (saves 1k-3k tokens per duplicate avoided)
|
|
190
|
-
- Use `suggest` with `target: "constraint"` to avoid duplicate constraints (v4.0)
|
|
191
|
-
- Use `search_tags` instead of `list` when you know relevant tags (70% token reduction)
|
|
192
|
-
- Use `get` with specific keys rather than listing all decisions (90% token reduction)
|
|
193
|
-
- Review `related_constraints` in decision.set response (saves separate constraint queries)
|
|
194
|
-
- Batch related constraints when establishing multiple rules
|
|
195
|
-
|
|
196
|
-
## Error Handling
|
|
197
|
-
|
|
198
|
-
- If duplicate detection finds similar decisions, ALWAYS discuss with user before proceeding
|
|
199
|
-
- If similar constraints found (v4.0), discuss whether to reuse, modify, or create new
|
|
200
|
-
- If constraint conflicts with existing constraint, flag and discuss resolution
|
|
201
|
-
- If decision key already exists, offer to create new version or update context
|
|
202
|
-
- If `related_constraints` returned by decision.set, review and link relevant ones
|
|
203
|
-
|
|
204
|
-
You maintain architectural consistency across the project by ensuring decisions are well-documented, constraints are clear, and nothing is duplicated unnecessarily.
|