sqlew 5.1.0 → 5.2.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/CHANGELOG.md +2140 -2081
- package/LICENSE +190 -190
- package/NOTICE +24 -24
- package/README.md +204 -190
- package/dist/adapters/mysql-adapter.js +3 -3
- package/dist/adapters/postgresql-adapter.js +3 -3
- package/dist/cli/db-export.js +32 -32
- package/dist/cli/db-import.js +30 -30
- package/dist/cli/hooks/codex-transcript.d.ts +23 -0
- package/dist/cli/hooks/codex-transcript.d.ts.map +1 -0
- package/dist/cli/hooks/codex-transcript.js +134 -0
- package/dist/cli/hooks/codex-transcript.js.map +1 -0
- package/dist/cli/hooks/on-exit-plan.d.ts.map +1 -1
- package/dist/cli/hooks/on-exit-plan.js +72 -4
- package/dist/cli/hooks/on-exit-plan.js.map +1 -1
- package/dist/cli/hooks/on-prompt.d.ts.map +1 -1
- package/dist/cli/hooks/on-prompt.js +38 -16
- package/dist/cli/hooks/on-prompt.js.map +1 -1
- package/dist/cli/hooks/plan-processor.d.ts.map +1 -1
- package/dist/cli/hooks/plan-processor.js +16 -2
- package/dist/cli/hooks/plan-processor.js.map +1 -1
- package/dist/cli/hooks/pr-adr.js +5 -5
- package/dist/cli/hooks/stdin-parser.d.ts +43 -0
- package/dist/cli/hooks/stdin-parser.d.ts.map +1 -1
- package/dist/cli/hooks/stdin-parser.js +212 -6
- package/dist/cli/hooks/stdin-parser.js.map +1 -1
- package/dist/cli/hooks/track-plan.d.ts +13 -0
- package/dist/cli/hooks/track-plan.d.ts.map +1 -1
- package/dist/cli/hooks/track-plan.js +73 -18
- package/dist/cli/hooks/track-plan.js.map +1 -1
- package/dist/cli.js +48 -48
- package/dist/config/global-config.d.ts +7 -1
- package/dist/config/global-config.d.ts.map +1 -1
- package/dist/config/global-config.js +5 -26
- package/dist/config/global-config.js.map +1 -1
- package/dist/database/migrations/v4/20251126000000_v4_bootstrap.js +32 -32
- package/dist/database/migrations/v4/20251126000001_v4_migrate_data.d.ts.map +1 -1
- package/dist/database/migrations/v4/20251126000001_v4_migrate_data.js +2 -1
- package/dist/database/migrations/v4/20251126000001_v4_migrate_data.js.map +1 -1
- package/dist/database/migrations/v4/20260102204000_v4_fix_decision_set_example.js +3 -3
- package/dist/help-data/constraint.toml +259 -259
- package/dist/help-data/decision.toml +845 -845
- package/dist/help-data/queue.toml +134 -134
- package/dist/server/tool-schemas.js +30 -30
- package/dist/tests/docker/native/db-init.js +9 -9
- package/dist/tests/unit/hooks/codex-hook-normalization.test.d.ts +7 -0
- package/dist/tests/unit/hooks/codex-hook-normalization.test.d.ts.map +1 -0
- package/dist/tests/unit/hooks/codex-hook-normalization.test.js +112 -0
- package/dist/tests/unit/hooks/codex-hook-normalization.test.js.map +1 -0
- package/dist/tests/unit/hooks/grok-hook-normalization.test.d.ts +9 -0
- package/dist/tests/unit/hooks/grok-hook-normalization.test.d.ts.map +1 -0
- package/dist/tests/unit/hooks/grok-hook-normalization.test.js +136 -0
- package/dist/tests/unit/hooks/grok-hook-normalization.test.js.map +1 -0
- package/dist/tests/unit/hooks/grok-plan-template-injection.test.d.ts +7 -0
- package/dist/tests/unit/hooks/grok-plan-template-injection.test.d.ts.map +1 -0
- package/dist/tests/unit/hooks/grok-plan-template-injection.test.js +55 -0
- package/dist/tests/unit/hooks/grok-plan-template-injection.test.js.map +1 -0
- package/dist/tests/utils/db-schema.js +48 -48
- package/dist/tests/utils/test-helpers.js +48 -48
- package/dist/tools/constraints/actions/get.js +5 -5
- package/dist/utils/path-normalize.d.ts +23 -0
- package/dist/utils/path-normalize.d.ts.map +1 -0
- package/dist/utils/path-normalize.js +38 -0
- package/dist/utils/path-normalize.js.map +1 -0
- package/dist/utils/project-root.d.ts +7 -3
- package/dist/utils/project-root.d.ts.map +1 -1
- package/dist/utils/project-root.js +17 -3
- package/dist/utils/project-root.js.map +1 -1
- package/dist/watcher/base-watcher.d.ts +0 -4
- package/dist/watcher/base-watcher.d.ts.map +1 -1
- package/dist/watcher/base-watcher.js +11 -22
- package/dist/watcher/base-watcher.js.map +1 -1
- package/docs/ADR_CONCEPTS.md +152 -152
- package/docs/CLI_USAGE.md +392 -392
- package/docs/CONFIGURATION.md +157 -157
- package/docs/CROSS_DATABASE.md +66 -66
- package/docs/DATABASE_AUTH.md +135 -135
- package/docs/HOOKS_GUIDE.md +116 -67
- package/docs/MIGRATION_TO_SAAS.md +176 -176
- package/docs/SHARED_DATABASE.md +108 -108
- package/package.json +88 -88
- package/scripts/copy-help-data.js +19 -19
- package/scripts/filter-test-output.js +78 -78
package/README.md
CHANGED
|
@@ -1,190 +1,204 @@
|
|
|
1
|
-
# sqlew
|
|
2
|
-
|
|
3
|
-

|
|
4
|
-
|
|
5
|
-
[](https://www.npmjs.com/package/sqlew)
|
|
6
|
-
[](https://opensource.org/licenses/Apache-2.0)
|
|
7
|
-
|
|
8
|
-
> **Design decisions, remembered by SQL** — an MCP server for AI agents
|
|
9
|
-
|
|
10
|
-
## What is sqlew?
|
|
11
|
-
|
|
12
|
-
### The Problem
|
|
13
|
-
|
|
14
|
-
Every AI coding session starts from scratch. Your agent doesn't remember that you chose PostgreSQL over MongoDB last week, or that the team agreed on a specific API versioning strategy. Without persistent memory, agents repeat mistakes, contradict earlier decisions, and waste tokens re-discovering context.
|
|
15
|
-
|
|
16
|
-
### The Solution
|
|
17
|
-
|
|
18
|
-
sqlew stores your architectural decisions in a structured SQL database. When a new session starts, the AI agent queries past decisions in milliseconds — not by reading through scattered Markdown files, but through efficient SQL lookups with metadata, tags, and similarity detection.
|
|
19
|
-
|
|
20
|
-
```
|
|
21
|
-
┌─────────────────────────────────────────────────────────────┐
|
|
22
|
-
│ Before sqlew │ After sqlew │
|
|
23
|
-
│───────────────────────────────│─────────────────────────────│
|
|
24
|
-
│ Session 1: "Use PostgreSQL" │ Session 1: "Use PostgreSQL"│
|
|
25
|
-
│ Session 2: "Use MongoDB?" │ → decision recorded │
|
|
26
|
-
│ Session 3: "Use PostgreSQL" │ Session 2: query → got it │
|
|
27
|
-
│ (same debate, every time) │ Session 3: query → got it │
|
|
28
|
-
│ │ (instant recall) │
|
|
29
|
-
└─────────────────────────────────────────────────────────────┘
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
sqlew is built on the [Model Context Protocol](https://modelcontextprotocol.io/) (MCP), so it works with any MCP-compatible AI coding tool.
|
|
33
|
-
|
|
34
|
-
> _This software does not send any data to external networks. We NEVER collect any data or usage statistics._
|
|
35
|
-
|
|
36
|
-
## Quick Start
|
|
37
|
-
|
|
38
|
-
### 1. Install
|
|
39
|
-
|
|
40
|
-
```bash
|
|
41
|
-
npm install -g sqlew
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
### 2. Setup
|
|
45
|
-
|
|
46
|
-
Choose the setup that matches your environment:
|
|
47
|
-
|
|
48
|
-
#### Claude Code (Plugin)
|
|
49
|
-
|
|
50
|
-
```bash
|
|
51
|
-
claude plugin marketplace add sqlew-io/sqlew-plugin
|
|
52
|
-
claude plugin install sqlew
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
The plugin automatically configures MCP server, Skills (Plan Mode guidance), and Hooks (automatic decision capture).
|
|
56
|
-
|
|
57
|
-
#### Codex CLI
|
|
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
|
-
|
|
1
|
+
# sqlew
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/sqlew)
|
|
6
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
7
|
+
|
|
8
|
+
> **Design decisions, remembered by SQL** — an MCP server for AI agents
|
|
9
|
+
|
|
10
|
+
## What is sqlew?
|
|
11
|
+
|
|
12
|
+
### The Problem
|
|
13
|
+
|
|
14
|
+
Every AI coding session starts from scratch. Your agent doesn't remember that you chose PostgreSQL over MongoDB last week, or that the team agreed on a specific API versioning strategy. Without persistent memory, agents repeat mistakes, contradict earlier decisions, and waste tokens re-discovering context.
|
|
15
|
+
|
|
16
|
+
### The Solution
|
|
17
|
+
|
|
18
|
+
sqlew stores your architectural decisions in a structured SQL database. When a new session starts, the AI agent queries past decisions in milliseconds — not by reading through scattered Markdown files, but through efficient SQL lookups with metadata, tags, and similarity detection.
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
22
|
+
│ Before sqlew │ After sqlew │
|
|
23
|
+
│───────────────────────────────│─────────────────────────────│
|
|
24
|
+
│ Session 1: "Use PostgreSQL" │ Session 1: "Use PostgreSQL"│
|
|
25
|
+
│ Session 2: "Use MongoDB?" │ → decision recorded │
|
|
26
|
+
│ Session 3: "Use PostgreSQL" │ Session 2: query → got it │
|
|
27
|
+
│ (same debate, every time) │ Session 3: query → got it │
|
|
28
|
+
│ │ (instant recall) │
|
|
29
|
+
└─────────────────────────────────────────────────────────────┘
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
sqlew is built on the [Model Context Protocol](https://modelcontextprotocol.io/) (MCP), so it works with any MCP-compatible AI coding tool.
|
|
33
|
+
|
|
34
|
+
> _This software does not send any data to external networks. We NEVER collect any data or usage statistics._
|
|
35
|
+
|
|
36
|
+
## Quick Start
|
|
37
|
+
|
|
38
|
+
### 1. Install
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm install -g sqlew
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### 2. Setup
|
|
45
|
+
|
|
46
|
+
Choose the setup that matches your environment:
|
|
47
|
+
|
|
48
|
+
#### Claude Code (Plugin)
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
claude plugin marketplace add sqlew-io/sqlew-plugin
|
|
52
|
+
claude plugin install sqlew
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The plugin automatically configures MCP server, Skills (Plan Mode guidance), and Hooks (automatic decision capture).
|
|
56
|
+
|
|
57
|
+
#### Codex CLI (Plugin)
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
codex plugin marketplace add sqlew-io/sqlew-plugin
|
|
61
|
+
codex plugin install sqlew --source sqlew-plugin
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
After install, open `/hooks` in Codex and trust the bundled sqlew hooks. Enable Plan Mode with `collaboration_modes = true` under `[features]` in your Codex config. The plugin configures MCP server, Skills (plan mode guidance), and Hooks (plan enforcement, PR ADR guard, decision extraction). See [Hooks Guide](docs/HOOKS_GUIDE.md) for caveats (do not duplicate skills in `~/.codex/skills/` or add `[mcp_servers.sqlew]` to `config.toml`).
|
|
65
|
+
|
|
66
|
+
#### Grok Build (Plugin)
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
npm install -g sqlew
|
|
70
|
+
grok plugin install sqlew-io/sqlew-plugin --trust
|
|
71
|
+
grok plugin update
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
The plugin configures MCP server, Skills (plan mode guidance), and Hooks (automatic decision capture on `exit_plan_mode`). See [Hooks Guide](docs/HOOKS_GUIDE.md) for setup details and caveats (do not duplicate hooks in `~/.grok/hooks/` or `config.toml`).
|
|
75
|
+
|
|
76
|
+
#### Manual
|
|
77
|
+
|
|
78
|
+
Add to `.mcp.json` in your project root:
|
|
79
|
+
|
|
80
|
+
```json
|
|
81
|
+
{
|
|
82
|
+
"mcpServers": {
|
|
83
|
+
"sqlew": {
|
|
84
|
+
"command": "sqlew"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
The database (`~/.config/sqlew/sqlew-shared.db`) and config are auto-created on first run. See [Shared Database](docs/SHARED_DATABASE.md) for details.
|
|
91
|
+
|
|
92
|
+
### 3. Just use Plan Mode!
|
|
93
|
+
|
|
94
|
+
That's it. Every time you create a plan and get user approval, your architectural decisions are **automatically recorded**.
|
|
95
|
+
|
|
96
|
+
No special commands needed — just plan your work normally, and sqlew captures the decisions in the background.
|
|
97
|
+
|
|
98
|
+
## Features
|
|
99
|
+
|
|
100
|
+
- **Structured Records** — Decisions stored as relational data with metadata, tags, layers, and version history
|
|
101
|
+
- **Fast Queries** — 2-50ms retrieval via SQL, even with thousands of decisions
|
|
102
|
+
- **Duplicate Detection** — Three-tier similarity scoring (0-100) prevents redundant decisions
|
|
103
|
+
- **Constraint Tracking** — Architectural rules and principles as first-class entities
|
|
104
|
+
- **Auto-Capture** — Hooks automatically record decisions from Plan Mode (Claude Code, Codex, and Grok Build via sqlew-plugin)
|
|
105
|
+
- **Multi-Database** — SQLite (default), PostgreSQL, MySQL/MariaDB, or Cloud
|
|
106
|
+
- **Git Worktree Ready** — Each worktree shares the same context database
|
|
107
|
+
|
|
108
|
+
## For Teams (sqlew.io)
|
|
109
|
+
|
|
110
|
+
Connect to [sqlew.io](https://sqlew.io) for team-shared decisions:
|
|
111
|
+
|
|
112
|
+
**Step 1: Get your API key**
|
|
113
|
+
|
|
114
|
+
Visit [sqlew.io](https://sqlew.io) and save your API key:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
# ~/.config/sqlew/.sqlew.env (shared across all projects)
|
|
118
|
+
SQLEW_API_KEY=your-api-key
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**Step 2: Configure each project**
|
|
122
|
+
|
|
123
|
+
```toml
|
|
124
|
+
# .sqlew/config.toml
|
|
125
|
+
[database]
|
|
126
|
+
type = "cloud"
|
|
127
|
+
|
|
128
|
+
[project]
|
|
129
|
+
name = "your-project-name"
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
**Benefits:**
|
|
133
|
+
- All team members share the same decision database
|
|
134
|
+
- Works seamlessly with Git worktree workflows
|
|
135
|
+
- No local database setup required
|
|
136
|
+
|
|
137
|
+
## Performance
|
|
138
|
+
|
|
139
|
+
| Metric | Value |
|
|
140
|
+
|--------|-------|
|
|
141
|
+
| Query speed | 2-50ms |
|
|
142
|
+
| Concurrent agents | 5+ simultaneous |
|
|
143
|
+
| Storage efficiency | ~140 bytes/decision |
|
|
144
|
+
| Token savings | 60-75% vs Markdown ADRs |
|
|
145
|
+
|
|
146
|
+
## Use Cases
|
|
147
|
+
|
|
148
|
+
- **Architecture Evolution** — Document major decisions with full context and alternatives considered
|
|
149
|
+
- **Pattern Standardization** — Establish coding patterns as constraints, enforce via AI code generation
|
|
150
|
+
- **Cross-Session Continuity** — AI maintains context across days/weeks without re-reading docs
|
|
151
|
+
- **Multi-Agent Coordination** — Multiple AI agents share architectural understanding
|
|
152
|
+
- **Onboarding Acceleration** — New AI sessions instantly understand project history
|
|
153
|
+
|
|
154
|
+
## Documentation
|
|
155
|
+
|
|
156
|
+
| Guide | Description |
|
|
157
|
+
|-------|-------------|
|
|
158
|
+
| [ADR Concepts](docs/ADR_CONCEPTS.md) | Architecture Decision Records explained |
|
|
159
|
+
| [Configuration](docs/CONFIGURATION.md) | Config file setup, database options |
|
|
160
|
+
| [Hooks Guide](docs/HOOKS_GUIDE.md) | Claude Code, Codex, and Grok Build integration |
|
|
161
|
+
| [Cross Database](docs/CROSS_DATABASE.md) | Multi-database support |
|
|
162
|
+
| [CLI Usage](docs/CLI_USAGE.md) | Database migration, export/import |
|
|
163
|
+
|
|
164
|
+
### Upgrade Guides
|
|
165
|
+
|
|
166
|
+
- [Migrating to SaaS](docs/MIGRATION_TO_SAAS.md) — Export local data to sqlew.io cloud
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
### MCP Tools
|
|
170
|
+
|
|
171
|
+
7 action-based tools: `decision`, `constraint`, `suggest`, `help`, `example`, `use_case`, `queue`
|
|
172
|
+
|
|
173
|
+
All tools support `action: "help"` for documentation.
|
|
174
|
+
|
|
175
|
+
## Support
|
|
176
|
+
|
|
177
|
+
Support development via [GitHub Sponsors](https://github.com/sponsors/sqlew-io).
|
|
178
|
+
|
|
179
|
+
## Version
|
|
180
|
+
|
|
181
|
+
Current version: **5.2.0**
|
|
182
|
+
|
|
183
|
+
See [CHANGELOG.md](CHANGELOG.md) for release history.
|
|
184
|
+
|
|
185
|
+
**What's New in v5.2.0:**
|
|
186
|
+
|
|
187
|
+
- **Grok Build support** — Plan-to-ADR via [sqlew-plugin](https://github.com/sqlew-io/sqlew-plugin) (`grok plugin install sqlew-io/sqlew-plugin --trust`)
|
|
188
|
+
- **Grok plan.md injection** — Decision/Constraint template appended on `enter_plan_mode`
|
|
189
|
+
- **Hook normalization** — Single CLI hook handlers work under both Claude Code and Grok Build
|
|
190
|
+
|
|
191
|
+
## License
|
|
192
|
+
|
|
193
|
+
Apache License 2.0 — Free for commercial and personal use. See [LICENSE](LICENSE) for details.
|
|
194
|
+
|
|
195
|
+
## Links
|
|
196
|
+
|
|
197
|
+
- [npm package](https://www.npmjs.com/package/sqlew)
|
|
198
|
+
- [GitHub](https://github.com/sqlew-io/sqlew)
|
|
199
|
+
- [Issues](https://github.com/sqlew-io/sqlew/issues)
|
|
200
|
+
- [Model Context Protocol](https://modelcontextprotocol.io/)
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
Built with [MCP SDK](https://github.com/modelcontextprotocol/sdk), [better-sqlite3](https://github.com/WiseLibs/better-sqlite3), and TypeScript.
|
|
@@ -130,9 +130,9 @@ export class MySQLAdapter extends BaseAdapter {
|
|
|
130
130
|
async tableExists(tableName) {
|
|
131
131
|
const knex = this.getKnex();
|
|
132
132
|
const database = this.config.connection.database;
|
|
133
|
-
const result = await knex.raw(`SELECT TABLE_NAME
|
|
134
|
-
FROM INFORMATION_SCHEMA.TABLES
|
|
135
|
-
WHERE TABLE_SCHEMA = ?
|
|
133
|
+
const result = await knex.raw(`SELECT TABLE_NAME
|
|
134
|
+
FROM INFORMATION_SCHEMA.TABLES
|
|
135
|
+
WHERE TABLE_SCHEMA = ?
|
|
136
136
|
AND TABLE_NAME = ?`, [database, tableName]);
|
|
137
137
|
return result[0].length > 0;
|
|
138
138
|
}
|
|
@@ -130,9 +130,9 @@ export class PostgreSQLAdapter extends BaseAdapter {
|
|
|
130
130
|
async tableExists(tableName) {
|
|
131
131
|
const knex = this.getKnex();
|
|
132
132
|
const database = this.config.connection.database;
|
|
133
|
-
const result = await knex.raw(`SELECT table_name
|
|
134
|
-
FROM information_schema.tables
|
|
135
|
-
WHERE table_catalog = ?
|
|
133
|
+
const result = await knex.raw(`SELECT table_name
|
|
134
|
+
FROM information_schema.tables
|
|
135
|
+
WHERE table_catalog = ?
|
|
136
136
|
AND table_name = ?`, [database, tableName]);
|
|
137
137
|
return result.rows.length > 0;
|
|
138
138
|
}
|
package/dist/cli/db-export.js
CHANGED
|
@@ -13,38 +13,38 @@ import { getDefaultDbPath } from '../config/global-config.js';
|
|
|
13
13
|
* Show help message for db:export command
|
|
14
14
|
*/
|
|
15
15
|
export function showDbExportHelp() {
|
|
16
|
-
console.log(`
|
|
17
|
-
sqlew db:export - Export project data to JSON format
|
|
18
|
-
|
|
19
|
-
USAGE:
|
|
20
|
-
npm run db:export -- [output-file] [key=value ...]
|
|
21
|
-
|
|
22
|
-
ARGUMENTS:
|
|
23
|
-
[output-file] Output file (optional, default: stdout)
|
|
24
|
-
|
|
25
|
-
OPTIONS (use key=value format):
|
|
26
|
-
project=<name> Export specific project (default: auto-detect from config.toml)
|
|
27
|
-
project=all Export all projects (explicit opt-in required)
|
|
28
|
-
db-path=<path> SQLite database path
|
|
29
|
-
config=<path> Config file path
|
|
30
|
-
|
|
31
|
-
EXAMPLES:
|
|
32
|
-
# Export current project (auto-detect from .sqlew/config.toml)
|
|
33
|
-
npm run db:export -- data.json
|
|
34
|
-
|
|
35
|
-
# Export specific project
|
|
36
|
-
npm run db:export -- data.json project=myproject
|
|
37
|
-
|
|
38
|
-
# Export all projects (explicit)
|
|
39
|
-
npm run db:export -- backup.json project=all
|
|
40
|
-
|
|
41
|
-
# Export to stdout
|
|
42
|
-
npm run db:export -- project=myproject
|
|
43
|
-
|
|
44
|
-
WORKFLOW:
|
|
45
|
-
1. Export: npm run db:export -- data.json project=myproject
|
|
46
|
-
2. Copy JSON to target
|
|
47
|
-
3. Import: npm run db:import -- data.json
|
|
16
|
+
console.log(`
|
|
17
|
+
sqlew db:export - Export project data to JSON format
|
|
18
|
+
|
|
19
|
+
USAGE:
|
|
20
|
+
npm run db:export -- [output-file] [key=value ...]
|
|
21
|
+
|
|
22
|
+
ARGUMENTS:
|
|
23
|
+
[output-file] Output file (optional, default: stdout)
|
|
24
|
+
|
|
25
|
+
OPTIONS (use key=value format):
|
|
26
|
+
project=<name> Export specific project (default: auto-detect from config.toml)
|
|
27
|
+
project=all Export all projects (explicit opt-in required)
|
|
28
|
+
db-path=<path> SQLite database path
|
|
29
|
+
config=<path> Config file path
|
|
30
|
+
|
|
31
|
+
EXAMPLES:
|
|
32
|
+
# Export current project (auto-detect from .sqlew/config.toml)
|
|
33
|
+
npm run db:export -- data.json
|
|
34
|
+
|
|
35
|
+
# Export specific project
|
|
36
|
+
npm run db:export -- data.json project=myproject
|
|
37
|
+
|
|
38
|
+
# Export all projects (explicit)
|
|
39
|
+
npm run db:export -- backup.json project=all
|
|
40
|
+
|
|
41
|
+
# Export to stdout
|
|
42
|
+
npm run db:export -- project=myproject
|
|
43
|
+
|
|
44
|
+
WORKFLOW:
|
|
45
|
+
1. Export: npm run db:export -- data.json project=myproject
|
|
46
|
+
2. Copy JSON to target
|
|
47
|
+
3. Import: npm run db:import -- data.json
|
|
48
48
|
`);
|
|
49
49
|
}
|
|
50
50
|
/**
|
package/dist/cli/db-import.js
CHANGED
|
@@ -13,36 +13,36 @@ import { getDefaultDbPath } from '../config/global-config.js';
|
|
|
13
13
|
* Show help message for db:import command
|
|
14
14
|
*/
|
|
15
15
|
export function showDbImportHelp() {
|
|
16
|
-
console.log(`
|
|
17
|
-
sqlew db:import - Import project data from JSON export
|
|
18
|
-
|
|
19
|
-
USAGE:
|
|
20
|
-
npm run db:import -- <source-file> [key=value ...]
|
|
21
|
-
|
|
22
|
-
ARGUMENTS:
|
|
23
|
-
<source-file> JSON export file (required)
|
|
24
|
-
|
|
25
|
-
OPTIONS (use key=value format):
|
|
26
|
-
project-name=<name> Target project name (default: from JSON)
|
|
27
|
-
skip-if-exists=true Skip if project exists (default: true)
|
|
28
|
-
dry-run=true Validate only, don't import
|
|
29
|
-
db-path=<path> SQLite database path
|
|
30
|
-
config=<path> Config file path
|
|
31
|
-
|
|
32
|
-
EXAMPLES:
|
|
33
|
-
# Import from JSON
|
|
34
|
-
npm run db:import -- data.json
|
|
35
|
-
|
|
36
|
-
# Import with custom project name
|
|
37
|
-
npm run db:import -- data.json project-name=newproject
|
|
38
|
-
|
|
39
|
-
# Dry run validation
|
|
40
|
-
npm run db:import -- data.json dry-run=true
|
|
41
|
-
|
|
42
|
-
WORKFLOW:
|
|
43
|
-
1. Export: npm run db:export -- data.json project=myproject
|
|
44
|
-
2. Copy JSON to target
|
|
45
|
-
3. Import: npm run db:import -- data.json
|
|
16
|
+
console.log(`
|
|
17
|
+
sqlew db:import - Import project data from JSON export
|
|
18
|
+
|
|
19
|
+
USAGE:
|
|
20
|
+
npm run db:import -- <source-file> [key=value ...]
|
|
21
|
+
|
|
22
|
+
ARGUMENTS:
|
|
23
|
+
<source-file> JSON export file (required)
|
|
24
|
+
|
|
25
|
+
OPTIONS (use key=value format):
|
|
26
|
+
project-name=<name> Target project name (default: from JSON)
|
|
27
|
+
skip-if-exists=true Skip if project exists (default: true)
|
|
28
|
+
dry-run=true Validate only, don't import
|
|
29
|
+
db-path=<path> SQLite database path
|
|
30
|
+
config=<path> Config file path
|
|
31
|
+
|
|
32
|
+
EXAMPLES:
|
|
33
|
+
# Import from JSON
|
|
34
|
+
npm run db:import -- data.json
|
|
35
|
+
|
|
36
|
+
# Import with custom project name
|
|
37
|
+
npm run db:import -- data.json project-name=newproject
|
|
38
|
+
|
|
39
|
+
# Dry run validation
|
|
40
|
+
npm run db:import -- data.json dry-run=true
|
|
41
|
+
|
|
42
|
+
WORKFLOW:
|
|
43
|
+
1. Export: npm run db:export -- data.json project=myproject
|
|
44
|
+
2. Copy JSON to target
|
|
45
|
+
3. Import: npm run db:import -- data.json
|
|
46
46
|
`);
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Codex transcript helpers for Plan-to-ADR extraction.
|
|
3
|
+
*
|
|
4
|
+
* Codex stores session rollouts as JSONL under ~/.codex/sessions/ rather than
|
|
5
|
+
* a dedicated plan.md file. These helpers locate the transcript and extract
|
|
6
|
+
* assistant plan text written during collaboration Plan mode.
|
|
7
|
+
*
|
|
8
|
+
* @since v5.2.1
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Recursively search ~/.codex/sessions for a rollout JSONL ending with sessionId.
|
|
12
|
+
*/
|
|
13
|
+
export declare function findCodexTranscriptPath(sessionId: string): string | null;
|
|
14
|
+
/**
|
|
15
|
+
* Extract assistant plan text from a Codex rollout JSONL transcript.
|
|
16
|
+
* Returns concatenated assistant output from turns that ran in Plan mode.
|
|
17
|
+
*/
|
|
18
|
+
export declare function extractPlanMarkdownFromCodexTranscript(transcriptPath: string): string | null;
|
|
19
|
+
/**
|
|
20
|
+
* Write extracted Codex plan text to a project-local temp markdown file.
|
|
21
|
+
*/
|
|
22
|
+
export declare function materializeCodexPlanFile(projectPath: string, sessionId: string, content: string): string;
|
|
23
|
+
//# sourceMappingURL=codex-transcript.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex-transcript.d.ts","sourceRoot":"","sources":["../../../src/cli/hooks/codex-transcript.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAQH;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAYxE;AAoCD;;;GAGG;AACH,wBAAgB,sCAAsC,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAoE5F;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAOxG"}
|