@hegemonart/get-design-done 1.56.0 → 1.57.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.
@@ -0,0 +1,106 @@
1
+ ---
2
+ name: gdd-state
3
+ description: "Query, recover, or roll back the Phase 57 SQLite state backbone. Use when you need to inspect the decisions/blockers/plans tables with a raw SELECT, rebuild a corrupt state.sqlite from the markdown STATE.md, or revert to the markdown-only source of truth by removing state.sqlite. Activates for requests involving querying the SQLite state database, recovering from SQLite corruption, or reverting the migration (demigrate)."
4
+ argument-hint: "<query \"<sql>\" | recover | demigrate>"
5
+ user-invocable: true
6
+ tools: Read, Bash, Grep, Glob
7
+ ---
8
+
9
+ # /gdd:state
10
+
11
+ The Phase 57 SQLite state backbone is opt-in (`--migrate-state`) and fully reversible.
12
+ Markdown `.design/STATE.md` is always the human-editable SoT; SQLite is a faster query
13
+ layer derived from it. This skill exposes three subcommands for operating on that layer.
14
+
15
+ ## Subcommands
16
+
17
+ | Subcommand | What it does |
18
+ |---|---|
19
+ | `/gdd:state query "<sql>"` | Run a read-only SELECT against `.design/state.sqlite`. |
20
+ | `/gdd:state recover` | Rotate the current sqlite to a `.bak` and rebuild from markdown. |
21
+ | `/gdd:state demigrate` | Remove `.design/state.sqlite`; markdown becomes the SoT again. |
22
+
23
+ ---
24
+
25
+ ## query
26
+
27
+ Execute a read-only SELECT against the state database.
28
+
29
+ The engine opens the file with `readonly:true` so all writes are rejected at the
30
+ engine level. A first-token denylist (Set membership, no regex) additionally blocks
31
+ DROP, DELETE, UPDATE, INSERT, ALTER, ATTACH, CREATE, PRAGMA, VACUUM, ANALYZE,
32
+ REINDEX, and REPLACE before the connection is opened.
33
+
34
+ ```bash
35
+ node -e '
36
+ const qs = require("./scripts/lib/state/query-surface.cjs");
37
+ const result = qs.query(process.argv[1], { projectRoot: process.cwd() });
38
+ console.log(JSON.stringify(result, null, 2));
39
+ ' "<sql>"
40
+ ```
41
+
42
+ Outputs `{ rows: [...], backend: "sqlite" }` on success, or
43
+ `{ degraded: true, message: "..." }` when SQLite is not active.
44
+
45
+ Degrades gracefully (no throw) when `BACKEND==='markdown'` or when
46
+ `.design/state.sqlite` has not been created yet (run `--migrate-state` first).
47
+
48
+ ---
49
+
50
+ ## recover
51
+
52
+ Rotate the current (possibly corrupt) `.design/state.sqlite` to `.bak.0`, then
53
+ rebuild a fresh database from the markdown `.design/STATE.md` using
54
+ `migrate-to-sqlite.cjs` in force mode. Runs `PRAGMA integrity_check` on the
55
+ result and reports the outcome.
56
+
57
+ ```bash
58
+ node -e '
59
+ const qs = require("./scripts/lib/state/query-surface.cjs");
60
+ const result = qs.recover({ projectRoot: process.cwd() });
61
+ console.log(JSON.stringify(result, null, 2));
62
+ '
63
+ ```
64
+
65
+ Outputs `{ recovered: true, integrity: true, message: "..." }` on success.
66
+
67
+ Backup rotation keeps at most 10 files (`.bak.0` through `.bak.9`). The oldest
68
+ backup is overwritten when the cap is reached.
69
+
70
+ ---
71
+
72
+ ## demigrate
73
+
74
+ Remove `.design/state.sqlite` so the markdown `STATE.md` becomes the SoT again.
75
+ Idempotent: if the file does not exist, returns a clear no-op message without error.
76
+ A backup is taken in `.bak.0` before removal.
77
+
78
+ ```bash
79
+ node -e '
80
+ const qs = require("./scripts/lib/state/query-surface.cjs");
81
+ const result = qs.demigrate({ projectRoot: process.cwd() });
82
+ console.log(JSON.stringify(result, null, 2));
83
+ '
84
+ ```
85
+
86
+ Outputs `{ demigrated: true, message: "..." }` when the file was removed, or
87
+ `{ demigrated: false, message: "..." }` when it was already absent (no-op).
88
+
89
+ To re-enable SQLite after a demigrate, run `--migrate-state` again.
90
+
91
+ ---
92
+
93
+ ## Key design decisions
94
+
95
+ - **Markdown is always the SoT.** SQLite is opt-in via `--migrate-state` and
96
+ reversible via `demigrate`. The markdown file is never silently overwritten.
97
+ - **Read-only queries only.** The `query` subcommand enforces SELECT-only via both
98
+ the engine (`readonly:true`) and a defense-in-depth denylist. No writes
99
+ are possible through this skill.
100
+ - **Backup rotation cap.** `rotateBak` shifts `.bak.0..8` up by one index and caps
101
+ at `.bak.9` (10 files total). The oldest backup is overwritten automatically.
102
+ - **Graceful degradation.** All subcommands return a clear `{ degraded, message }`
103
+ object (no throw) when `better-sqlite3` is not installed or when
104
+ `GDD_STATE_BACKEND=markdown` is set.
105
+
106
+ ## STATE COMPLETE