archive-labs 0.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Archive Labs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,357 @@
1
+ # Archive Labs CLI
2
+
3
+ Install:
4
+
5
+ ```bash
6
+ npm install -g archive-labs
7
+ archive
8
+ ```
9
+
10
+ Development:
11
+
12
+ ```bash
13
+ corepack pnpm install
14
+ corepack pnpm build
15
+ ```
16
+
17
+ The default `archive` launcher is interactive in a real terminal:
18
+
19
+ - use the arrow keys to move
20
+ - press `Enter` to run the highlighted command
21
+ - press `?` to open the full help screen
22
+ - press `Esc` to return from the help screen
23
+ - press `Ctrl+C` to exit
24
+ - the selected command is highlighted in the launcher
25
+
26
+ Login:
27
+
28
+ ```bash
29
+ archive login
30
+ ```
31
+
32
+ Supported sign-in methods:
33
+
34
+ - GitHub
35
+ - Google
36
+ - Microsoft
37
+ - email and password
38
+
39
+ For browser-based sign-in, the CLI opens the Archive Labs auth page and completes login through a localhost callback back into the terminal session.
40
+
41
+ After sign-in, the CLI now shows a minimal post-login summary with:
42
+
43
+ - who signed in
44
+ - the resolved workspace or repo context
45
+ - current sync state
46
+ - one clear next step, or a short set of suggested commands when the repo is already ready
47
+
48
+ No-install run:
49
+
50
+ ```bash
51
+ npx archive-labs
52
+ ```
53
+
54
+ The CLI surface follows the Archive V2 command groups below. Commands now route to the live Archive backend and return actionable errors when auth, repository access, or workspace setup is missing.
55
+
56
+ The CLI is the supported terminal interface. It uses authenticated Archive backend routes for setup, sync, status, impact, ask, and release workflows. The documented external HTTP API is the smaller `/v1` decision API in `../../docs/api/v1.md`; TypeScript integrations can use the SDK in `../sdk`.
57
+
58
+ `archive init` behavior:
59
+
60
+ - `archive init` is the setup-readiness command
61
+ - it saves the API and app targets for the current workspace, then immediately verifies what is actually ready
62
+ - it stays distinct from nearby setup commands:
63
+ - `archive ping` = narrow API connectivity check
64
+ - `archive doctor` = raw diagnostics and local wiring details
65
+ - `archive sync` = repository connection and indexing
66
+ - it never starts a sync automatically
67
+ - it always returns one exact next step:
68
+ - `archive login`
69
+ - `archive sync`
70
+ - `archive sync --wait`
71
+ - dashboard setup URL text
72
+ - or `archive status` when the repo is fully ready
73
+
74
+ `archive recent` behavior:
75
+
76
+ - `archive recent` shows locally stored recent Archive commands from this machine
77
+ - it is CLI-only and does not require backend or SQL changes
78
+ - default text output stays compact and scan-friendly
79
+ - the interactive launcher also surfaces a small `Recent` section for one-click reruns
80
+ - recent history includes both successes and failures, clearly labeled
81
+
82
+ `archive sync` behavior:
83
+
84
+ - in a terminal, `archive sync` waits by default and shows live indexing progress
85
+ - in non-interactive usage, `archive sync` starts or attaches and returns immediately by default
86
+ - use `--wait` to block until indexing finishes
87
+ - use `--no-wait` to return immediately even in an interactive terminal
88
+
89
+ `archive status` behavior:
90
+
91
+ - works as the instant daily health read for the current repo
92
+ - default terminal output stays compact: `Status`, `Integrity`, `Confidence`, one `Issue`, and one `Next Action` when needed
93
+ - returns partial status when secondary signals are unavailable instead of failing the whole command
94
+ - keeps follow-up guidance to a single next step only when action is needed
95
+
96
+ Machine-readable output:
97
+
98
+ ```bash
99
+ archive init -y --json
100
+ archive recent --json
101
+ archive doctor --json
102
+ archive ping --json
103
+ archive sync --json --repository acme/repo --no-wait
104
+ archive ask --json --repository acme/repo "where is auth handled?"
105
+ archive impact file --json --repository acme/repo src/app.ts
106
+ ```
107
+
108
+ `archive status --json` now includes the compatibility fields above plus `status`, `integrityScore`, `primaryIssue`, `verdict`, `confidenceLevel`, `missingSignals`, `nextAction`, and a stable `signals` object for UI and scripting consumers.
109
+
110
+ Command roles:
111
+
112
+ - setup commands (`init`, `login`, `sync`, `doctor`, `ping`) make the local and CI environment trustworthy
113
+ - awareness commands (`status`, `events`) explain current repository state
114
+ - advisory commands (`impact`, `ask`, `why`) explain blast radius, evidence, and intent without making merge decisions
115
+ - gate commands (`check pr`, `check diff`, `release risk`) produce `PASS`, `WARN`, or `BLOCK` where that workflow is appropriate
116
+
117
+ CI Gate:
118
+
119
+ Use `archive check pr` as the protected-branch CI gate. CI mode is non-interactive: it never opens prompts, never prints launcher navigation, and treats gate decisions as process outcomes. A failing Archive command blocks a merge only when the repository's CI and GitHub branch protection require that job or check. Add `--json` for machine-readable output; JSON mode emits exactly one JSON object on stdout, with no spinner, progress, ANSI, help text, or parser logs mixed in.
120
+
121
+ Protected-branch gate:
122
+
123
+ ```bash
124
+ archive check pr 182 --repository acme/payments --ci --json --strict
125
+ ```
126
+
127
+ `archive check diff` is best for local/pre-push checks unless CI passes a deterministic diff context. `archive release risk` is a release readiness gate, not a PR merge gate.
128
+
129
+ GitHub Actions example:
130
+
131
+ ```yaml
132
+ name: Archive Gate
133
+
134
+ on:
135
+ pull_request:
136
+
137
+ jobs:
138
+ archive:
139
+ runs-on: ubuntu-latest
140
+ steps:
141
+ - uses: actions/checkout@v4
142
+ with:
143
+ fetch-depth: 0
144
+ - uses: actions/setup-node@v4
145
+ with:
146
+ node-version: 22
147
+ - run: npm install -g archive-labs
148
+ - name: Archive PR gate
149
+ env:
150
+ ARCHIVE_TOKEN: ${{ secrets.ARCHIVE_TOKEN }}
151
+ ARCHIVE_GITHUB_TOKEN: ${{ secrets.ARCHIVE_GITHUB_TOKEN }}
152
+ CI: true
153
+ run: archive check pr "${{ github.event.pull_request.number }}" --repository "${{ github.repository }}" --ci --json --strict --timeout 600000
154
+ ```
155
+
156
+ Release gate example:
157
+
158
+ ```yaml
159
+ - name: Archive release risk
160
+ env:
161
+ ARCHIVE_TOKEN: ${{ secrets.ARCHIVE_TOKEN }}
162
+ ARCHIVE_GITHUB_TOKEN: ${{ secrets.ARCHIVE_GITHUB_TOKEN }}
163
+ CI: true
164
+ run: archive release risk "${{ github.ref_name }}" --repository "${{ github.repository }}" --ci --json --strict
165
+ ```
166
+
167
+ Exit codes are stable for CI:
168
+
169
+ - `0`: PASS, or WARN when `--strict` is not set
170
+ - `2`: usage or argument error
171
+ - `3`: risk or policy BLOCK, including WARN with `--strict`
172
+ - `4`: auth, config, or setup missing
173
+ - `5`: network, service, or API failure
174
+ - `6`: timeout
175
+ - `7`: internal CLI or tooling failure
176
+
177
+ JSON success envelope:
178
+
179
+ ```json
180
+ {
181
+ "ok": true,
182
+ "command": "archive check pr",
183
+ "mode": "pr",
184
+ "verdict": "pass",
185
+ "exitCode": 0,
186
+ "confidence": "high",
187
+ "repository": "acme/payments",
188
+ "branch": "main",
189
+ "summary": "No blocking guardrails found.",
190
+ "evidence": [],
191
+ "requiredActions": [],
192
+ "nextAction": null,
193
+ "meta": { "schemaVersion": 1, "ci": true, "strict": true }
194
+ }
195
+ ```
196
+
197
+ JSON failure envelope:
198
+
199
+ ```json
200
+ {
201
+ "ok": false,
202
+ "command": "archive check pr",
203
+ "exitCode": 4,
204
+ "error": {
205
+ "code": "auth_required",
206
+ "category": "setup",
207
+ "message": "Run archive login before using this command.",
208
+ "hint": "Run archive login to continue.",
209
+ "retryable": false,
210
+ "statusCode": null,
211
+ "requestId": null
212
+ },
213
+ "meta": { "schemaVersion": 1 }
214
+ }
215
+ ```
216
+
217
+ Gate outputs include normalized `verdict`, `confidence`, `riskScore`, `riskLevel`, `affectedFiles`, `affectedServices`, `owners`, `evidence`, `requiredActions`, and `nextAction` fields when Archive can derive them. Missing auth/config fails as setup, API and network failures fail as service, and bounded backend requests or polling exit `6` instead of hanging. The default total polling timeout is 10 minutes in CI and 20 minutes in an interactive terminal; override it with `--timeout <ms>`.
218
+
219
+ Config and token storage:
220
+
221
+ - CLI config is stored under `~/.archive-labs/config.json`
222
+ - default production targets are `https://api.archivelabs.dev` and `https://app.archivelabs.dev`; localhost targets are opt-in through flags, environment variables, or local config
223
+ - CI can provide `ARCHIVE_TOKEN` or `ARCHIVE_LABS_TOKEN`; GitHub-backed commands can also provide `ARCHIVE_GITHUB_TOKEN`
224
+ - malformed config fails clearly instead of being ignored
225
+ - token-bearing config is written with `0600` file permissions on Unix
226
+ - Windows currently uses plaintext file storage; secret handling is isolated behind a storage adapter so Windows Credential Manager support can be added without changing command behavior
227
+
228
+ `archive check` behavior:
229
+
230
+ - `archive check` is now a smart default
231
+ - when your working tree is dirty, it runs the local change gate and shows `Mode: Diff`
232
+ - when your working tree is clean, it runs the readiness/system-trust check and shows `Mode: Readiness`
233
+
234
+ `archive check diff` behavior:
235
+
236
+ - `archive check diff` now focuses only on the current working-tree changes
237
+ - it returns a decision-first guardrail result: `PASS`, `WARN`, or `BLOCK`
238
+ - risk stays separate from the decision with a numeric score and `Low` / `Moderate` / `High` labeling
239
+ - it stays distinct from `archive impact diff` by emphasizing safety, owners, visibility gaps, and the next action instead of a broader impact report
240
+
241
+ `archive check pr` behavior:
242
+
243
+ - `archive check pr` is the merge-decision command
244
+ - it combines impact, ownership, policy, confidence, and required actions into one short PR verdict
245
+ - Archive publishes the GitHub check as `Archive PR Check`
246
+ - without `--ci`, it exits `0` even when the decision is `BLOCK` so humans can inspect the result
247
+ - with `--ci`, `BLOCK` exits `3`; `WARN` exits `3` only when `--strict` is set
248
+
249
+ `archive impact file <path>` behavior:
250
+
251
+ - `archive impact file <path>` is the path-level impact explorer
252
+ - it answers one question: if this file changes, what does it affect?
253
+ - it stays non-gating and does not print a merge decision, score, or risk label
254
+ - it uses the shared impact engine first, then enriches the result with dependency-graph and ownership signals when available
255
+ - it prioritizes service-level consequences with visible owners and only falls back to `Downstream Files` when service mapping is too weak to explain the impact
256
+ - it keeps `Likely First Impact`, `Critical Surfaces`, `Visibility`, and `Next Step` intentionally rare so the default output stays focused
257
+
258
+ `archive impact diff` behavior:
259
+
260
+ - `archive impact diff` stays non-gating
261
+ - it analyzes the current working tree automatically: staged, unstaged, added, deleted, renamed, and untracked non-ignored changes
262
+ - it focuses on blast radius, affected services with visible owners, rare likely-first-impact hints, and one next step only when it is actually useful
263
+ - it only shows `Visibility` when Archive's dependency/impact view is degraded
264
+ - it does not print a merge decision or any risk score
265
+
266
+ `archive why <path>` behavior:
267
+
268
+ - `archive why <path>` is the file-memory command
269
+ - it is file-first and uses path-specific commits, PRs, code structure, and ownership before falling back to broader repo context
270
+ - it explains `Role`, `Why It Exists`, and only shows `Why It Looks Like This` when there is explicit structural evidence
271
+ - it keeps `Related` tight to high-signal memory aids such as owner, top related file, or top symbol
272
+ - it stays distinct from `archive ask` and `archive impact file` by focusing on intent and evidence, not open-ended Q&A or blast radius
273
+
274
+ `archive events` behavior:
275
+
276
+ - `archive events` is the curated repo-awareness command
277
+ - by default it shows up to 7 meaningful repo-level events from the last 7 days
278
+ - it stays chronological and quiet: no counters, no raw logs, no dashboard-style dump
279
+ - every event must explain `Why it matters`
280
+ - optional follow-up action stays rare and defaults to at most one clear next command
281
+ - use `archive events --since 24h`, `archive events --since 7d`, or `archive events --since 30d` to adjust the window quickly
282
+ - `archive release summarize <tag>` is the engineering handoff command
283
+ - it stays distinct from `archive release risk <tag>` by answering `What is in this release?`, not `Should we feel nervous shipping it?`
284
+ - it keeps the default output short and structured around summary, highlights, affected systems, and included changes
285
+ - it is explicit about first-tag inference, uncertain baselines, and partial coverage instead of pretending the release window is cleaner than it is
286
+ - `archive release risk <tag>` is the pre-ship confidence command
287
+ - it stays distinct from `archive release summarize <tag>` by answering `How risky is it to ship this release tag?`
288
+ - it reuses grouped release impact as the scoring spine, then overlays release-size, guardrail, ownership, and visibility signals
289
+ - it is explicit about first-tag inference, weak visibility, and uncertain baselines instead of pretending the release window is cleaner than it is
290
+
291
+ Local development:
292
+
293
+ ```bash
294
+ cd packages/cli
295
+ corepack pnpm install
296
+ corepack pnpm build
297
+ npm link
298
+ archive
299
+ archive help
300
+ archive-labs help
301
+ ```
302
+
303
+ Starter commands:
304
+
305
+ ```bash
306
+ archive
307
+ archive init
308
+ archive login
309
+ archive status
310
+ archive recent
311
+ archive events
312
+ archive events --since 24h
313
+ archive sync
314
+ archive check
315
+ archive check diff
316
+ archive check pr 182
317
+ archive impact file src/app.ts
318
+ archive impact diff
319
+ archive ask "Where is auth handled?"
320
+ archive why src/lib/auth.ts
321
+ archive release summarize v1.2.0
322
+ archive help
323
+ archive version
324
+ archive doctor
325
+ archive ping https://api.example.com
326
+ ```
327
+
328
+ Command catalog:
329
+
330
+ - `System`: `archive status`, `archive events`
331
+ - `Setup`: `archive init`, `archive sync`
332
+ - `Guardrails`: `archive check`, `archive check pr`, `archive check diff`
333
+ - `Impact`: `archive impact file <path>`, `archive impact diff`
334
+ - `Intelligence`: `archive ask "<question>"`, `archive why <path>`
335
+ - `Release`: `archive release summarize <tag>`, `archive release risk <tag>`
336
+ - `Utility`: `archive login`, `archive recent`, `archive version`, `archive help`, `archive doctor`, `archive ping`
337
+
338
+ Launch flow:
339
+
340
+ ```bash
341
+ archive init
342
+ archive login
343
+ archive sync
344
+ archive recent
345
+ archive ask "where is auth handled?"
346
+ archive impact file src/app.ts
347
+ archive why src/lib/auth.ts
348
+ ```
349
+
350
+ Publish flow:
351
+
352
+ ```bash
353
+ npm pack
354
+ npm publish
355
+ ```
356
+
357
+ This package is developed with pnpm and shipped through the npm registry.