@redential/cli 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.
Files changed (46) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +217 -0
  3. package/dist/build-bundle.js +37 -0
  4. package/dist/categorize.js +25 -0
  5. package/dist/churn-exclusions.js +51 -0
  6. package/dist/cli.js +87 -0
  7. package/dist/config.js +13 -0
  8. package/dist/credentials.js +26 -0
  9. package/dist/errors.js +20 -0
  10. package/dist/git.js +141 -0
  11. package/dist/hash.js +4 -0
  12. package/dist/http-client.js +129 -0
  13. package/dist/import-detect.js +281 -0
  14. package/dist/login.js +133 -0
  15. package/dist/logout.js +6 -0
  16. package/dist/merkle.js +20 -0
  17. package/dist/prompt.js +70 -0
  18. package/dist/public-remote.js +43 -0
  19. package/dist/salt.js +20 -0
  20. package/dist/scan-command.js +24 -0
  21. package/dist/scan.js +145 -0
  22. package/dist/secret-scan.js +37 -0
  23. package/dist/skill-detect.js +234 -0
  24. package/dist/submit-command.js +49 -0
  25. package/dist/submit.js +71 -0
  26. package/dist/summary.js +148 -0
  27. package/dist/types.js +12 -0
  28. package/dist/version-check.js +62 -0
  29. package/package.json +48 -0
  30. package/signatures/ai/vector-search.json +39 -0
  31. package/signatures/ai/whisper.json +36 -0
  32. package/signatures/auth/firebase-auth.json +43 -0
  33. package/signatures/auth/oauth-oidc.json +41 -0
  34. package/signatures/auth/supabase-auth.json +29 -0
  35. package/signatures/backend/axum.json +24 -0
  36. package/signatures/db/activerecord.json +21 -0
  37. package/signatures/db/eloquent.json +22 -0
  38. package/signatures/db/supabase.json +31 -0
  39. package/signatures/frontend/tailwind.json +28 -0
  40. package/signatures/infra/docker.json +20 -0
  41. package/signatures/infra/github-actions.json +19 -0
  42. package/signatures/infra/kubernetes.json +21 -0
  43. package/signatures/infra/terraform.json +22 -0
  44. package/signatures/package-map.json +483 -0
  45. package/signatures/testing/jest.json +25 -0
  46. package/taxonomy.json +119 -0
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,217 @@
1
+ # Redential CLI
2
+
3
+ [![npm version](https://img.shields.io/npm/v/%40redential%2Fcli.svg)](https://www.npmjs.com/package/@redential/cli)
4
+ [![CI](https://github.com/Jppblue/redential-cli/actions/workflows/ci.yml/badge.svg)](https://github.com/Jppblue/redential-cli/actions/workflows/ci.yml)
5
+ [![License: Apache-2.0](https://img.shields.io/badge/License-Apache--2.0-blue.svg)](LICENSE)
6
+
7
+ Your best work is probably under an NDA.
8
+
9
+ The years you spent building payments infrastructure, hardening auth, or
10
+ carrying on-call — none of it can go in a portfolio, because none of it can
11
+ leave your employer's repo. `@redential/cli` reads your **local** git
12
+ history and turns it into a metadata-only proof: volume, span, cadence,
13
+ languages, technical categories, signed commits, ownership share. Never
14
+ the code itself.
15
+
16
+ ```bash
17
+ npx @redential/cli scan
18
+ ```
19
+
20
+ That's it — no login, no config, nothing installed globally. `scan` makes
21
+ zero network calls (it's structurally incapable of phoning home, not just
22
+ network-free by default — see [docs/principles.md](docs/principles.md)),
23
+ prints the exact JSON it would ever upload, and stops there. You review it.
24
+ If you like what you see:
25
+
26
+ ```bash
27
+ npx @redential/cli login # device flow, one time
28
+ npx @redential/cli submit # scans again, shows you the bundle, asks before uploading
29
+ npx @redential/cli logout # deletes the locally stored session
30
+ ```
31
+
32
+ Prefer a persistent install:
33
+
34
+ ```bash
35
+ npm install -g @redential/cli
36
+ redential scan
37
+ ```
38
+
39
+ ## What `scan` looks like
40
+
41
+ It prints the full JSON bundle first (see [docs/schema.md](docs/schema.md)
42
+ for every field), then — only when stdout is an interactive terminal — a
43
+ human-readable summary underneath it:
44
+
45
+ ```
46
+ {
47
+ "schema_version": "1.0.0",
48
+ "runner": "local",
49
+ "tool_version": "0.1.0",
50
+ "created_at": "2026-07-09T14:32:01.000Z",
51
+ "repo": { "host_type": "github", "age_days": 742, "repo_fingerprint": "a3f9…" },
52
+ "identity": { "author_identity_hashes": ["9c1e…"], "other_contributors_count": 3 },
53
+ "commits": { "user_total": 1847, "first_at": "2024-06-02T09:14:00Z", "last_at": "2026-07-08T21:05:00Z", "span_days": 767, "hour_histogram": [...], "weekday_histogram": [...] },
54
+ "signed": { "count": 831, "ratio": 0.45, "key_types": ["ssh"] },
55
+ "languages": [ { "extension": ".ts", "share": 0.62 }, { "extension": ".sql", "share": 0.14 } ],
56
+ "categories": [ { "name": "backend", "commit_count": 902, "churn_share": 0.51 }, { "name": "testing", "commit_count": 340, "churn_share": 0.18 } ],
57
+ "detected_skills": [ { "slug": "payments/stripe", "commit_count": 12, "first_seen": "2024-09-01T10:00:00Z", "last_seen": "2025-11-20T18:30:00Z" } ],
58
+ "ownership": { "user_commit_ratio": 0.78 },
59
+ "integrity": { "merkle_root": "7be2…", "algorithm": "sha256" },
60
+ "attestation": { "confirmed": true, "confirmed_at": "2026-07-09T14:32:01.000Z" }
61
+ }
62
+
63
+ ────────────────────────────────────────────────────────────
64
+
65
+ ╔════════════════════════════════════════════════════════════╗
66
+ ║ YOUR PRIVATE REPO, WRAPPED ║
67
+ ╚════════════════════════════════════════════════════════════╝
68
+
69
+ 2 years, 1,847 commits
70
+
71
+ COMMITS BY HOUR (UTC)
72
+ 0 6 12 18
73
+ ▁····▁▁▃▅█▇▄▃▂▂▁▁▁▁▁····
74
+
75
+ COMMITS BY WEEKDAY
76
+ Sun ██░░░░░░░░░░░░░░░░░░ 5
77
+ Mon ███████████████████░ 40
78
+
79
+ TOP LANGUAGES
80
+ .ts ████████████████████ 62%
81
+ .sql ████░░░░░░░░░░░░░░░░ 14%
82
+
83
+ SKILLS DETECTED
84
+ payments/stripe 12 commits
85
+
86
+ Ownership 78% of this repo's commits are yours
87
+ Signed commits 45% of your commits are cryptographically signed
88
+
89
+ Nothing left your machine. Verify: github.com/Jppblue/redential-cli
90
+ ```
91
+
92
+ Pipe it (`redential scan | jq`) or pass `--json` and you get only the raw
93
+ JSON above — the wrapped summary is a terminal-only convenience, not a
94
+ second source of data. Full command reference: [docs/scan.md](docs/scan.md).
95
+
96
+ ## Trust model
97
+
98
+ | Never leaves your machine | Only travels after you run `submit`, and only this |
99
+ |---|---|
100
+ | Source code, diffs, snippets | The bundle printed by `scan` — byte for byte |
101
+ | File and directory names | An extension (`.ts`) and an inferred category (`backend`) |
102
+ | Commit messages | Aggregate cadence: hour/weekday histograms |
103
+ | Other contributors' names or emails | An aggregate count of other contributors |
104
+ | The remote URL | Only the host *kind* (`github`, `gitlab`, …), never the URL |
105
+ | Secrets of any kind | Nothing — a secret-scan runs over the bundle and blocks output on any match |
106
+
107
+ Every row on the left is backed by an [executable test](test/privacy/), per
108
+ [docs/privacy-tests.md](docs/privacy-tests.md) — not just a policy
109
+ statement. `scan` itself makes zero network calls; `login` and `submit` are
110
+ the only two commands that touch the network at all, and `submit` uploads
111
+ nothing without your explicit confirmation. Full rationale:
112
+ [docs/principles.md](docs/principles.md).
113
+
114
+ ### Verifying the package itself
115
+
116
+ Every release is published from GitHub Actions on a tagged commit with npm
117
+ provenance (`npm publish --provenance`) — never from anyone's laptop.
118
+ Verify any installed version was built from this exact source:
119
+
120
+ ```bash
121
+ npm audit signatures
122
+ ```
123
+
124
+ See [docs/releasing.md](docs/releasing.md) for the full release process
125
+ and what the provenance attestation actually proves.
126
+
127
+ ## FAQ
128
+
129
+ **Can't I just import a bunch of libraries to inflate my skills list?**
130
+ No — a bare import alone rarely tags a skill. Most signatures require
131
+ either a distinctive, unambiguous import specifier (not a generic package
132
+ name shared across ecosystems) or an actual API-call shape from your own
133
+ diffs (`stripe.checkout`, not just `import Stripe`). See
134
+ [docs/signatures.md](docs/signatures.md) for the exact detection rules and
135
+ the discipline behind them. But the honest answer is bigger than detection
136
+ accuracy: this CLI only ever produces the **Attested** tier — the weakest
137
+ one on Redential, explicitly labeled as unverified metadata. Padding your
138
+ skills list gets you a slightly longer list on the weakest tier; it does
139
+ nothing for Proven or Verified, which require live code or a defended
140
+ session. Gaming metadata to look impressive on a tier that's already
141
+ labeled "take this with a grain of salt" isn't much of a prize.
142
+
143
+ **Can't I replay someone else's git history into a new repo and claim it?**
144
+ You could fabricate commit timestamps in a fresh repo — that's exactly why
145
+ local data is explicitly the *weakest* tier, not the strongest. A replayed
146
+ history still has to survive several partial anchors: signed commits (a
147
+ GPG/SSH signature can't be forged retroactively without the key), a
148
+ behavioral fingerprint (the hour/weekday cadence is compared against your
149
+ own verified public activity as a soft consistency check), and — above
150
+ all — the bundle only ever earns **Attested**, metadata only. Anything
151
+ above that requires an NDA-safe defense: a short recorded session where
152
+ you answer questions generated from your own bundle, live. Faking a git
153
+ history is cheap; defending fabricated experience under questioning, in
154
+ real time, is not. That gap is the actual security boundary, not the
155
+ detection heuristics.
156
+
157
+ **What exactly leaves my machine?**
158
+ The bundle `scan` printed to your terminal — byte for byte, nothing added
159
+ or enriched afterward. That's not a promise you have to take on faith:
160
+ [`test/privacy/submit-guardrail.test.ts`](test/privacy/submit-guardrail.test.ts)
161
+ asserts the literal string sent over HTTP by `submit` is `===` the string
162
+ `scan` printed, not a re-serialization of a parsed object. Every field is
163
+ documented in [docs/schema.md](docs/schema.md), and the schema itself
164
+ (`schema/bundle.v1.json`) sets `additionalProperties: false` everywhere —
165
+ an unlisted field makes the bundle invalid by construction, not just by
166
+ convention.
167
+
168
+ **Why should I trust a CLI with my employer's code?**
169
+ Because it never touches your employer's code in any form that leaves your
170
+ laptop. It's local-only (`scan` is structurally network-free, not merely
171
+ network-free by default), fully open source under Apache-2.0 so you can
172
+ read every line before running it, and its privacy claims are
173
+ [executable tests](test/privacy/) you run yourself (`npm test`) rather
174
+ than a page of prose. There's no telemetry, no analytics, no background
175
+ process — the only two network calls this CLI ever makes are the `login`
176
+ device flow and the `submit` upload, both requiring your explicit action.
177
+ And every published release carries a Sigstore-signed provenance
178
+ attestation you can verify (`npm audit signatures`), proving it was built
179
+ from this exact repository, not from someone's laptop.
180
+
181
+ **What does "Attested" actually prove?**
182
+ Honestly, not that much on its own — and that's by design, not an
183
+ oversight. "Attested" means: this person's local git history shows this
184
+ pattern of activity, self-reported and falsifiable, with partial anchors
185
+ (signed commits, behavioral fingerprint, server-side consistency checks)
186
+ but no independent verification of the underlying code. It is never
187
+ labeled or visually mixed with Proven or Verified, which require either
188
+ connecting a readable repository (via the GitHub App) or defending the
189
+ claim live. Think of Attested as "worth a follow-up question," not
190
+ "verified" — the CLI's whole design exists to keep that distinction
191
+ honest instead of letting a metadata bundle borrow credibility it hasn't
192
+ earned. See [docs/principles.md](docs/principles.md) (principle 6,
193
+ "Honest about trust") for the full reasoning.
194
+
195
+ ## Docs
196
+
197
+ - [docs/principles.md](docs/principles.md) — the six non-negotiable rules
198
+ - [docs/privacy-tests.md](docs/privacy-tests.md) — which test proves which rule
199
+ - [docs/scan.md](docs/scan.md) — full `scan` command reference
200
+ - [docs/login-submit.md](docs/login-submit.md) — `login`, `submit`, `logout`
201
+ - [docs/schema.md](docs/schema.md) — every bundle field, explained
202
+ - [docs/signatures.md](docs/signatures.md) — how skill detection works
203
+ - [docs/releasing.md](docs/releasing.md) — how a release is built and verified
204
+
205
+ If the repo you're scanning is your own and connectable, `scan` isn't the
206
+ better tool — the [GitHub App](https://redential.com) reads the actual code
207
+ and grants stronger tiers than local metadata ever can.
208
+
209
+ ## Contributing
210
+
211
+ See [CONTRIBUTING.md](CONTRIBUTING.md) — most contributions are a
212
+ one-line addition to a signature map. Bug reports and security issues:
213
+ [SECURITY.md](SECURITY.md).
214
+
215
+ ## License
216
+
217
+ Apache-2.0
@@ -0,0 +1,37 @@
1
+ import { runScan, listAuthors } from "./scan.js";
2
+ import { ScanError } from "./errors.js";
3
+ import { promptAuthors, promptConfirmAttestation } from "./prompt.js";
4
+ import { getRemoteUrl } from "./git.js";
5
+ import { publicHostWarning } from "./public-remote.js";
6
+ /**
7
+ * Shared by `scan` and `submit`: author selection, authorization
8
+ * confirmation, and the actual scan. `submit` calls this directly instead
9
+ * of re-deriving the bundle another way, so the bundle it uploads is
10
+ * produced by the exact same code path `scan` prints (principle 4,
11
+ * "User-reviewed").
12
+ */
13
+ export async function buildBundleInteractively(opts) {
14
+ const warn = opts.warn ?? console.error;
15
+ const warning = publicHostWarning(getRemoteUrl(opts.repoPath));
16
+ if (warning)
17
+ warn(warning);
18
+ let authors = opts.author;
19
+ if (authors.length === 0) {
20
+ const candidates = listAuthors(opts.repoPath);
21
+ if (candidates.length === 0) {
22
+ throw new ScanError("This repository has no commits yet — nothing to scan.");
23
+ }
24
+ authors = await (opts.promptAuthorsFn ?? promptAuthors)(candidates);
25
+ }
26
+ let confirmed = opts.yes;
27
+ if (!confirmed) {
28
+ confirmed = await (opts.promptConfirmFn ?? promptConfirmAttestation)();
29
+ }
30
+ return runScan({
31
+ repoPath: opts.repoPath,
32
+ authors,
33
+ confirmed,
34
+ toolVersion: opts.toolVersion,
35
+ configDir: opts.configDir,
36
+ });
37
+ }
@@ -0,0 +1,25 @@
1
+ // Order matters: first matching rule wins.
2
+ const RULES = [
3
+ [/(^|\/)(__tests__|tests?|specs?)(\/|$)|\.(test|spec)\.[jt]sx?$/i, "testing"],
4
+ [/(^|\/)(claude\.md|agents\.md|\.cursor|\.aider|copilot)/i, "ai-workflow"],
5
+ [
6
+ /(^|\/)(\.github\/workflows|dockerfile|docker-compose|terraform|k8s|kubernetes|infra)(\/|$|\.)/i,
7
+ "infra",
8
+ ],
9
+ [/(^|\/)(auth|authn|authz|session|oauth|login)(\/|$|[._-])/i, "auth"],
10
+ [/(^|\/)(pay|payments?|billing|checkout|stripe)(\/|$|[._-])/i, "payments"],
11
+ [/(^|\/)(migrations?|models?|schema)(\/|$)/i, "data"],
12
+ [/\.(md|mdx)$|(^|\/)docs(\/|$)/i, "docs"],
13
+ [
14
+ /(^|\/)(components?|pages|views|public|styles)(\/|$)|\.(tsx|jsx|css|scss|vue|svelte)$/i,
15
+ "frontend",
16
+ ],
17
+ [/(^|\/)(server|api|controllers?|services)(\/|$)|\.(go|rb|java|rs|py)$/i, "backend"],
18
+ ];
19
+ export function categorize(filePath) {
20
+ for (const [pattern, name] of RULES) {
21
+ if (pattern.test(filePath))
22
+ return name;
23
+ }
24
+ return "other";
25
+ }
@@ -0,0 +1,51 @@
1
+ // Checked-in artifacts, not authored work — see docs/schema.md's "What is
2
+ // excluded from churn" for the full, versioned list (part of the bundle's
3
+ // measurement contract, not an implementation detail). Without this, a
4
+ // single `npm install`/build commit can dwarf months of actual code in the
5
+ // languages/categories breakdown.
6
+ const LOCKFILE_BASENAMES = new Set(["package-lock.json", "yarn.lock", "pnpm-lock.yaml", "bun.lockb"]);
7
+ const MINIFIED_PATTERN = /\.min\.js$/i;
8
+ // Requires the name to be a full path segment (bounded by "/" or the start,
9
+ // and followed by "/") so it only matches build-output DIRECTORIES, never a
10
+ // substring like "redistribute/" or a same-named leaf file.
11
+ const GENERATED_DIR_PATTERN = /(^|\/)(dist|build|\.next|node_modules)\//i;
12
+ function basename(path) {
13
+ const idx = path.lastIndexOf("/");
14
+ return idx === -1 ? path : path.slice(idx + 1);
15
+ }
16
+ /** Lockfile, minified bundle, or build-output path — excluded by name/shape
17
+ * alone, with no need to look at commit history. */
18
+ export function isExcludedPath(path) {
19
+ return LOCKFILE_BASENAMES.has(basename(path)) || MINIFIED_PATTERN.test(path) || GENERATED_DIR_PATTERN.test(path);
20
+ }
21
+ // A file whose entire churn history (within the selected author's commits)
22
+ // is a single commit that added at least this many lines is almost always a
23
+ // vendored/generated artifact that happened to get committed — a bundled
24
+ // dependency, a lockfile format not already recognized by name, a one-time
25
+ // codegen dump — rather than authored work. 1000 is comfortably above any
26
+ // plausible hand-written single-file commit.
27
+ export const GENERATED_FILE_MIN_ADDED_LINES = 1000;
28
+ /**
29
+ * Paths whose only appearance across `commits` is one commit adding at
30
+ * least `GENERATED_FILE_MIN_ADDED_LINES` lines — "a single commit, no
31
+ * history before or after it". Operates over whatever commit set the caller
32
+ * passes in (the selected author's commits, in `scan.ts`), not the whole
33
+ * repo — this is a per-scan heuristic, not a repo-wide fact.
34
+ */
35
+ export function heuristicallyGeneratedPaths(commits) {
36
+ const touchCount = new Map();
37
+ const soleEntry = new Map();
38
+ for (const c of commits) {
39
+ for (const f of c.churn) {
40
+ touchCount.set(f.path, (touchCount.get(f.path) ?? 0) + 1);
41
+ soleEntry.set(f.path, f);
42
+ }
43
+ }
44
+ const generated = new Set();
45
+ for (const [path, count] of touchCount) {
46
+ if (count === 1 && soleEntry.get(path).added >= GENERATED_FILE_MIN_ADDED_LINES) {
47
+ generated.add(path);
48
+ }
49
+ }
50
+ return generated;
51
+ }
package/dist/cli.js ADDED
@@ -0,0 +1,87 @@
1
+ #!/usr/bin/env node
2
+ import { readFileSync } from "node:fs";
3
+ import { resolve } from "node:path";
4
+ import { Command } from "commander";
5
+ import { ScanError, AuthError, SubmitError, NetworkError } from "./errors.js";
6
+ import { executeScanCommand } from "./scan-command.js";
7
+ import { executeSubmitCommand } from "./submit-command.js";
8
+ import { runLogin } from "./login.js";
9
+ import { runLogout } from "./logout.js";
10
+ function getToolVersion() {
11
+ const pkgUrl = new URL("../package.json", import.meta.url);
12
+ const pkg = JSON.parse(readFileSync(pkgUrl, "utf8"));
13
+ return pkg.version;
14
+ }
15
+ function collect(value, previous) {
16
+ return previous.concat([value]);
17
+ }
18
+ /** The domain errors every command may throw — never wraps a raw fetch/fs
19
+ * error, so this catch can safely print `err.message` without risking a
20
+ * token or bundle leaking through an unsanitized underlying error. */
21
+ function isCliError(err) {
22
+ return (err instanceof ScanError ||
23
+ err instanceof AuthError ||
24
+ err instanceof SubmitError ||
25
+ err instanceof NetworkError);
26
+ }
27
+ async function run(action) {
28
+ try {
29
+ await action();
30
+ }
31
+ catch (err) {
32
+ if (isCliError(err)) {
33
+ console.error(`Error: ${err.message}`);
34
+ process.exitCode = 1;
35
+ return;
36
+ }
37
+ throw err;
38
+ }
39
+ }
40
+ const program = new Command();
41
+ program.name("redential").description("Local, metadata-only proof bundles from git history.");
42
+ program
43
+ .command("scan")
44
+ .description("Scan the local git history and print the proof bundle (nothing is uploaded).")
45
+ .option("--repo <path>", "path to the git repository to scan", ".")
46
+ .option("--author <email>", "author email that is yours (repeatable); enables non-interactive mode", collect, [])
47
+ .option("--yes", "confirm 'I am authorized to analyze this repository' non-interactively", false)
48
+ .option("--json", "force JSON-only output, even on an interactive terminal (default when piped)", false)
49
+ .action(async (options) => {
50
+ await run(() => executeScanCommand({
51
+ repoPath: resolve(options.repo),
52
+ author: options.author,
53
+ yes: options.yes,
54
+ toolVersion: getToolVersion(),
55
+ isTTY: process.stdout.isTTY === true,
56
+ json: options.json,
57
+ }));
58
+ });
59
+ program
60
+ .command("login")
61
+ .description("Authenticate via device flow and store a session token locally.")
62
+ .action(async () => {
63
+ await run(() => runLogin());
64
+ });
65
+ program
66
+ .command("logout")
67
+ .description("Delete the locally stored session token.")
68
+ .action(async () => {
69
+ await run(() => runLogout());
70
+ });
71
+ program
72
+ .command("submit")
73
+ .description("Scan, review, and upload a proof bundle. Requires a prior `redential login`.")
74
+ .option("--repo <path>", "path to the git repository to scan", ".")
75
+ .option("--author <email>", "author email that is yours (repeatable); enables non-interactive mode", collect, [])
76
+ .option("--yes", "confirm 'I am authorized to analyze this repository' non-interactively", false)
77
+ .option("--confirm-upload", "confirm the upload itself non-interactively (separate from --yes)", false)
78
+ .action(async (options) => {
79
+ await run(() => executeSubmitCommand({
80
+ repoPath: resolve(options.repo),
81
+ author: options.author,
82
+ yes: options.yes,
83
+ confirmUpload: options.confirmUpload,
84
+ toolVersion: getToolVersion(),
85
+ }));
86
+ });
87
+ program.parse();
package/dist/config.js ADDED
@@ -0,0 +1,13 @@
1
+ import { homedir } from "node:os";
2
+ import { join } from "node:path";
3
+ /** Same directory for the device salt (salt.ts) and the session token (credentials.ts). */
4
+ export const DEFAULT_CONFIG_DIR = join(homedir(), ".config", "redential");
5
+ /**
6
+ * Public by design (CLAUDE.md: "solo SITE_URL (pública)"). Overridable via
7
+ * REDENTIAL_SITE_URL so tests and staging can point the CLI at a local
8
+ * mock server instead of the real site.
9
+ */
10
+ export function getSiteUrl() {
11
+ const raw = process.env.REDENTIAL_SITE_URL ?? "https://www.redential.com";
12
+ return raw.replace(/\/$/, "");
13
+ }
@@ -0,0 +1,26 @@
1
+ import { existsSync, mkdirSync, readFileSync, writeFileSync, unlinkSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { DEFAULT_CONFIG_DIR } from "./config.js";
4
+ function credentialsPath(configDir = DEFAULT_CONFIG_DIR) {
5
+ return join(configDir, "credentials.json");
6
+ }
7
+ /** Never in the scanned repo's cwd — always the device-local config dir. */
8
+ export function readCredentials(configDir = DEFAULT_CONFIG_DIR) {
9
+ const path = credentialsPath(configDir);
10
+ if (!existsSync(path))
11
+ return null;
12
+ return JSON.parse(readFileSync(path, "utf8"));
13
+ }
14
+ /** 0600 — same permission pattern as salt.ts's device salt. */
15
+ export function saveCredentials(credentials, configDir = DEFAULT_CONFIG_DIR) {
16
+ mkdirSync(configDir, { recursive: true });
17
+ writeFileSync(credentialsPath(configDir), JSON.stringify(credentials), { mode: 0o600 });
18
+ }
19
+ /** True if a credentials file existed and was removed; false if there was nothing to do. */
20
+ export function deleteCredentials(configDir = DEFAULT_CONFIG_DIR) {
21
+ const path = credentialsPath(configDir);
22
+ if (!existsSync(path))
23
+ return false;
24
+ unlinkSync(path);
25
+ return true;
26
+ }