firevault 0.2.0-beta.0 → 0.2.0-beta.2

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/docs/roadmap.md CHANGED
@@ -17,6 +17,8 @@ Status:
17
17
  - Documents are written one file per document.
18
18
  - Local Git snapshot workflow exists through separate `backup`, `commit`, and `snapshot` commands.
19
19
  - File-level change inspection exists through `changes` and `changes --last <window>`.
20
+ - Local recovery health inspection exists through `status`.
21
+ - Local setup validation exists through `doctor`.
20
22
  - Document and collection history inspection exists through `history <path>`.
21
23
  - Dry-run recovery inspection exists through `restore-preview <path> --from <commit>`.
22
24
  - Local backup-file recovery exists through `restore-local <path> --from <commit> --confirm`.
@@ -28,6 +30,7 @@ Status:
28
30
  - Public GitHub release docs cover quick start, security, contributing, and issue triage.
29
31
  - Firevault 0.2 uses `.firevault/config.json` and a dedicated `.firevault` recovery workspace as a breaking prerelease change.
30
32
  - Guided `firevault init` validates setup input, checks Git state, suggests local Firebase project settings, optionally lists Firestore collections, creates `.firevault/`, and applies workspace `.gitignore` safety entries.
33
+ - Local GitHub Actions workflow generation exists through `setup-github-action`.
31
34
 
32
35
  Next work:
33
36
 
@@ -37,6 +40,9 @@ Next work:
37
40
  - Add non-emulator unit tests for pure path and Git parsing helpers.
38
41
  - Review first npm prerelease feedback before widening restore scope.
39
42
  - Dogfood against real non-critical Firestore projects before expanding restore behavior.
43
+ - Expand `status` automation awareness without adding network dependencies.
44
+ - Validate and harden generated GitHub Actions workflow behavior through dogfooding.
45
+ - Dogfood `doctor` checks against real recovery workspaces and refine fix guidance.
40
46
 
41
47
  ## MVP
42
48
 
@@ -0,0 +1,218 @@
1
+ # firevault status Design
2
+
3
+ `firevault status` should answer one operational question:
4
+
5
+ > Am I protected right now?
6
+
7
+ It should be compact, local-first, and confidence-oriented. It should not become a broad diagnostic dump.
8
+
9
+ ## Scope
10
+
11
+ Phase 1 should use local filesystem and local Git metadata only.
12
+
13
+ Phase 1 must not:
14
+
15
+ - contact Firebase,
16
+ - call GitHub APIs,
17
+ - require network access,
18
+ - write files,
19
+ - stage or commit,
20
+ - push,
21
+ - create GitHub repositories.
22
+
23
+ ## Existing Code To Reuse
24
+
25
+ - `src/config/loadConfig.ts`
26
+ - `findWorkspaceRoot()` already walks upward and finds `.firevault/config.json`.
27
+ - `loadConfig()` validates config and returns:
28
+ - `workspaceRoot`,
29
+ - `configPath`,
30
+ - config-relative `outputDir`,
31
+ - absolute `outputDirPath`,
32
+ - config-relative and absolute service account paths.
33
+ - `src/git/git.ts`
34
+ - `isInsideGitRepository(cwd)` checks whether `.firevault` is a Git repo.
35
+ - `hasWorkingTreeChanges(cwd)` checks dirty state.
36
+ - `hasChangesUnder(path, cwd)` can report uncommitted backup changes under `outputDir`.
37
+ - existing Git functions already accept `cwd`, which lets status keep all Git checks scoped to `.firevault`.
38
+ - Existing command error style:
39
+ - user-facing config and Git errors are printed without stack traces.
40
+
41
+ ## Smallest Phase 1 Implementation
42
+
43
+ Phase 1 implements `firevault status` as a read-only command that:
44
+
45
+ 1. Discovers the workspace from the current directory.
46
+ 2. Reads and validates `.firevault/config.json`.
47
+ 3. Checks local backup and Git state under `.firevault`.
48
+ 4. Prints a short grouped summary.
49
+
50
+ Implementation note: missing workspace and invalid config set a non-zero exit code after printing the compact status context and next step/error. Missing Git repository is reported in the Git section but does not fail the command, because it is a recoverable setup state.
51
+
52
+ Suggested initial output:
53
+
54
+ ```txt
55
+ Firevault status
56
+
57
+ Workspace:
58
+ Path: .firevault
59
+ Config: OK
60
+
61
+ Firestore:
62
+ Project: my-project
63
+ Collections configured: 4
64
+
65
+ Backups:
66
+ Output directory: firestore-backups
67
+ Last snapshot: 2026-05-17T14:22:10Z
68
+ Uncommitted backup changes: none
69
+
70
+ Git:
71
+ Repository: OK
72
+ Branch: main
73
+ Working tree: clean
74
+ Remote origin: configured
75
+ Remote sync: unknown
76
+
77
+ Automation:
78
+ GitHub Actions workflow: not configured
79
+ ```
80
+
81
+ If something is missing, keep the output readable and specific:
82
+
83
+ ```txt
84
+ Firevault status
85
+
86
+ Workspace:
87
+ Path: not found
88
+ Config: missing
89
+
90
+ Next step:
91
+ Run `firevault init`
92
+ ```
93
+
94
+ ## Phase 1 Checks
95
+
96
+ Workspace:
97
+
98
+ - whether `.firevault/config.json` can be discovered,
99
+ - display workspace path relative to the current directory where practical,
100
+ - config status: `OK`, `missing`, or `invalid`.
101
+
102
+ Firestore:
103
+
104
+ - configured project ID,
105
+ - configured collection count.
106
+
107
+ Backups:
108
+
109
+ - configured output directory,
110
+ - whether `.firevault/<outputDir>` exists,
111
+ - whether there are uncommitted changes under `outputDir`,
112
+ - latest backup commit if any.
113
+
114
+ Latest backup commit should come from local Git history under the configured `outputDir`, for example:
115
+
116
+ ```bash
117
+ git log -1 --format=%cI -- firestore-backups
118
+ ```
119
+
120
+ Git:
121
+
122
+ - whether `.firevault` is a Git repo,
123
+ - current branch,
124
+ - clean or dirty working tree,
125
+ - whether remote `origin` is configured,
126
+ - ahead/behind if cheaply available from local Git metadata.
127
+
128
+ Automation:
129
+
130
+ - whether a local workflow file exists at `.github/workflows/firevault-snapshot.yml` in the parent app repo.
131
+ - Do not validate workflow contents in Phase 1.
132
+
133
+ ## Git Helper Additions
134
+
135
+ `src/git/git.ts` should expose small read-only helpers rather than putting `execFileSync` calls directly in `status.ts`.
136
+
137
+ Likely helpers:
138
+
139
+ - `getCurrentBranch(cwd): string | undefined`
140
+ - use `git branch --show-current`,
141
+ - fall back to `detached` or `unknown` if needed.
142
+ - `getRemoteUrl(name, cwd): string | undefined`
143
+ - use `git remote get-url origin`.
144
+ - `getLatestCommitDate(path, cwd): string | undefined`
145
+ - use `git log -1 --format=%cI -- <path>`.
146
+ - `getAheadBehind(cwd): { ahead: number; behind: number } | undefined`
147
+ - use local upstream metadata only.
148
+
149
+ ## Ahead/Behind Risk
150
+
151
+ Ahead/behind detection can be misleading if implemented with network calls or stale remote refs.
152
+
153
+ Phase 1 should avoid `git fetch` because status must be fast, local, and network-free. That means ahead/behind can only reflect locally known upstream refs.
154
+
155
+ Recommended behavior:
156
+
157
+ - if no upstream exists: `Remote sync: no upstream`,
158
+ - if upstream exists and local metadata is available: `Remote sync: ahead N, behind M`,
159
+ - if metadata is unavailable: `Remote sync: unknown`,
160
+ - do not imply offsite recovery is current unless remote refs prove it locally.
161
+
162
+ This keeps the distinction clear:
163
+
164
+ - local Git history means local rollback,
165
+ - pushed remote history means offsite recovery,
166
+ - Phase 1 can only inspect local evidence of remote setup.
167
+
168
+ ## Workflow Detection
169
+
170
+ Phase 1 can check only for local file existence:
171
+
172
+ ```txt
173
+ <app root>/.github/workflows/firevault-snapshot.yml
174
+ ```
175
+
176
+ The app root can be derived as `path.dirname(config.workspaceRoot)`.
177
+
178
+ Phase 2 should validate:
179
+
180
+ - a scheduled trigger exists,
181
+ - the workflow runs `firevault snapshot`,
182
+ - required secret names are present.
183
+
184
+ ## Likely Files To Change
185
+
186
+ Phase 1 implementation will likely change:
187
+
188
+ - `src/commands/status.ts`
189
+ - new command implementation and formatter.
190
+ - `src/index.ts`
191
+ - register `statusCommand`.
192
+ - `src/git/git.ts`
193
+ - add read-only helper functions.
194
+ - `package.json`
195
+ - add `"status": "tsx src/index.ts status"` script.
196
+ - `README.md`
197
+ - document `firevault status` and example output.
198
+ - `docs/architecture.md`
199
+ - document the status boundary and local-only Phase 1 behavior.
200
+ - `docs/roadmap.md`
201
+ - mark local recovery state status as the current milestone.
202
+ - `test/integration/firestore-emulator.test.ts` or a new non-emulator test file
203
+ - test workspace discovery and Git state without contacting Firebase.
204
+
205
+ ## Testing Plan
206
+
207
+ Phase 1 can be tested without Firebase:
208
+
209
+ - no workspace: prints missing workspace and suggests `firevault init`,
210
+ - valid `.firevault/config.json` without `.firevault/.git`: reports Git repo missing,
211
+ - workspace Git repo with no commits: reports no latest snapshot,
212
+ - backup output exists with uncommitted backup files: reports uncommitted backup changes,
213
+ - clean workspace with one backup commit: reports latest snapshot date,
214
+ - remote origin configured but no upstream: reports origin configured and sync unknown/no upstream,
215
+ - workflow file missing: reports not configured,
216
+ - workflow file present: reports configured.
217
+
218
+ Emulator tests are not required for Phase 1 because `status` should not contact Firebase.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "firevault",
3
- "version": "0.2.0-beta.0",
3
+ "version": "0.2.0-beta.2",
4
4
  "description": "Undo button for Firestore. Git-style history, rollback, and recovery for Firestore projects.",
5
5
  "keywords": [
6
6
  "firebase",
@@ -39,6 +39,9 @@
39
39
  "test:emulator": "tsx test/integration/run-firestore-emulator.ts",
40
40
  "backup": "tsx src/index.ts backup",
41
41
  "commit": "tsx src/index.ts commit",
42
+ "status": "tsx src/index.ts status",
43
+ "doctor": "tsx src/index.ts doctor",
44
+ "setup:github-action": "tsx src/index.ts setup-github-action",
42
45
  "changes": "tsx src/index.ts changes",
43
46
  "history": "tsx src/index.ts history",
44
47
  "restore-preview": "tsx src/index.ts restore-preview",