@westbayberry/dg 1.3.3 → 2.0.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 (126) hide show
  1. package/LICENSE +1 -201
  2. package/NOTICE +1 -4
  3. package/README.md +293 -0
  4. package/dist/api/analyze.js +210 -0
  5. package/dist/audit/deep.js +180 -0
  6. package/dist/audit/detectors.js +247 -0
  7. package/dist/audit/events.js +41 -0
  8. package/dist/audit/rules.js +426 -0
  9. package/dist/audit-ui/AuditApp.js +39 -0
  10. package/dist/audit-ui/components/AuditHeader.js +24 -0
  11. package/dist/audit-ui/components/AuditResultsView.js +307 -0
  12. package/dist/audit-ui/components/DeepStatusRow.js +11 -0
  13. package/dist/audit-ui/export.js +85 -0
  14. package/dist/audit-ui/format.js +34 -0
  15. package/dist/audit-ui/launch.js +34 -0
  16. package/dist/auth/device-login.js +271 -0
  17. package/dist/auth/env-token.js +6 -0
  18. package/dist/auth/login-app.js +156 -0
  19. package/dist/auth/store.js +147 -0
  20. package/dist/bin/dg.js +71 -0
  21. package/dist/commands/audit.js +357 -0
  22. package/dist/commands/completion.js +116 -0
  23. package/dist/commands/config.js +99 -0
  24. package/dist/commands/doctor.js +39 -0
  25. package/dist/commands/explain.js +100 -0
  26. package/dist/commands/guard-commit.js +158 -0
  27. package/dist/commands/help.js +74 -0
  28. package/dist/commands/licenses.js +435 -0
  29. package/dist/commands/login.js +81 -0
  30. package/dist/commands/logout.js +37 -0
  31. package/dist/commands/router.js +98 -0
  32. package/dist/commands/scan.js +18 -0
  33. package/dist/commands/service.js +475 -0
  34. package/dist/commands/setup.js +302 -0
  35. package/dist/commands/status.js +115 -0
  36. package/dist/commands/suggest.js +35 -0
  37. package/dist/commands/types.js +4 -0
  38. package/dist/commands/unavailable.js +11 -0
  39. package/dist/commands/uninstall.js +111 -0
  40. package/dist/commands/update.js +210 -0
  41. package/dist/commands/verify.js +151 -0
  42. package/dist/commands/version.js +22 -0
  43. package/dist/commands/wrap.js +55 -0
  44. package/dist/config/settings.js +302 -0
  45. package/dist/install-ui/LiveInstall.js +24 -0
  46. package/dist/install-ui/block-render.js +83 -0
  47. package/dist/install-ui/live-install-app.js +48 -0
  48. package/dist/install-ui/prompt.js +24 -0
  49. package/dist/launcher/classify.js +116 -0
  50. package/dist/launcher/env.js +53 -0
  51. package/dist/launcher/live-install.js +50 -0
  52. package/dist/launcher/output-redaction.js +77 -0
  53. package/dist/launcher/preflight-prompt.js +139 -0
  54. package/dist/launcher/resolve-real-binary.js +73 -0
  55. package/dist/launcher/run.js +417 -0
  56. package/dist/policy/evaluate.js +128 -0
  57. package/dist/presentation/mode.js +52 -0
  58. package/dist/presentation/theme.js +29 -0
  59. package/dist/proxy/buffer-budget.js +64 -0
  60. package/dist/proxy/ca.js +126 -0
  61. package/dist/proxy/classify-host.js +26 -0
  62. package/dist/proxy/enforcement.js +102 -0
  63. package/dist/proxy/metadata-map.js +336 -0
  64. package/dist/proxy/server.js +909 -0
  65. package/dist/proxy/upstream-proxy.js +102 -0
  66. package/dist/proxy/worker.js +39 -0
  67. package/dist/publish-set/collect.js +51 -0
  68. package/dist/publish-set/no-exec-shell.js +19 -0
  69. package/dist/publish-set/npm.js +109 -0
  70. package/dist/publish-set/pack.js +36 -0
  71. package/dist/publish-set/pypi.js +59 -0
  72. package/dist/runtime/cli.js +17 -0
  73. package/dist/runtime/first-run.js +60 -0
  74. package/dist/runtime/node-version.js +58 -0
  75. package/dist/runtime/nudges.js +105 -0
  76. package/dist/scan/analyze-worker.js +21 -0
  77. package/dist/scan/collect.js +153 -0
  78. package/dist/scan/command.js +159 -0
  79. package/dist/scan/discovery.js +209 -0
  80. package/dist/scan/render.js +240 -0
  81. package/dist/scan/scanner-report.js +82 -0
  82. package/dist/scan/staged.js +173 -0
  83. package/dist/scan/types.js +1 -0
  84. package/dist/scan-ui/LegacyApp.js +156 -0
  85. package/dist/scan-ui/alt-screen.js +84 -0
  86. package/dist/scan-ui/api-aliases.js +1 -0
  87. package/dist/scan-ui/components/ErrorView.js +23 -0
  88. package/dist/scan-ui/components/InteractiveResultsView.js +1166 -0
  89. package/dist/scan-ui/components/ProgressBar.js +89 -0
  90. package/dist/scan-ui/components/ProjectSelector.js +62 -0
  91. package/dist/scan-ui/components/ScoreHeader.js +20 -0
  92. package/dist/scan-ui/components/SetupBanner.js +13 -0
  93. package/dist/scan-ui/components/Spinner.js +4 -0
  94. package/dist/scan-ui/format-helpers.js +40 -0
  95. package/dist/scan-ui/hooks/useExpandAnimation.js +40 -0
  96. package/dist/scan-ui/hooks/useScan.js +113 -0
  97. package/dist/scan-ui/hooks/useTerminalSize.js +24 -0
  98. package/dist/scan-ui/launch.js +27 -0
  99. package/dist/scan-ui/logo.js +91 -0
  100. package/dist/scan-ui/shims.js +30 -0
  101. package/dist/security/sanitize.js +28 -0
  102. package/dist/service/state.js +837 -0
  103. package/dist/service/trust-store.js +234 -0
  104. package/dist/service/worker.js +88 -0
  105. package/dist/setup/git-hook.js +244 -0
  106. package/dist/setup/optional-support.js +58 -0
  107. package/dist/setup/plan.js +899 -0
  108. package/dist/state/cleanup-registry.js +60 -0
  109. package/dist/state/index.js +5 -0
  110. package/dist/state/locks.js +161 -0
  111. package/dist/state/paths.js +24 -0
  112. package/dist/state/sessions.js +170 -0
  113. package/dist/state/store.js +50 -0
  114. package/dist/telemetry/events.js +40 -0
  115. package/dist/util/git.js +20 -0
  116. package/dist/util/tty-prompt.js +43 -0
  117. package/dist/verify/local.js +400 -0
  118. package/dist/verify/package-check.js +240 -0
  119. package/dist/verify/preflight.js +698 -0
  120. package/dist/verify/render.js +184 -0
  121. package/dist/verify/types.js +1 -0
  122. package/package.json +33 -50
  123. package/dist/index.mjs +0 -54116
  124. package/dist/postinstall.mjs +0 -731
  125. package/dist/python-hook/dg_pip_hook.pth +0 -1
  126. package/dist/python-hook/dg_pip_hook.py +0 -130
package/LICENSE CHANGED
@@ -1,201 +1 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for describing the origin of the Work and
141
- reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Support. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or support.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- APPENDIX: How to apply the Apache License to your work.
179
-
180
- To apply the Apache License to your work, attach the following
181
- boilerplate notice, with the fields enclosed by brackets "[]"
182
- replaced with your own identifying information. (Don't include
183
- the brackets!) The text should be enclosed in the appropriate
184
- comment syntax for the file format. We also recommend that a
185
- file or class name and description of purpose be included on the
186
- same "printed" page as the copyright notice for easier
187
- identification within third-party archives.
188
-
189
- Copyright 2026 WestBayBerry
190
-
191
- Licensed under the Apache License, Version 2.0 (the "License");
192
- you may not use this file except in compliance with the License.
193
- You may obtain a copy of the License at
194
-
195
- http://www.apache.org/licenses/LICENSE-2.0
196
-
197
- Unless required by applicable law or agreed to in writing, software
198
- distributed under the License is distributed on an "AS IS" BASIS,
199
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
- See the License for the specific language governing permissions and
201
- limitations under the License.
1
+ UNLICENSED
package/NOTICE CHANGED
@@ -1,4 +1 @@
1
- Dependency Guardian CLI
2
- Copyright 2026 WestBayBerry
3
-
4
- This product includes software developed at WestBayBerry (https://westbayberry.com).
1
+ Dependency Guardian dg CLI
package/README.md ADDED
@@ -0,0 +1,293 @@
1
+ # @westbayberry/dg
2
+
3
+ Dependency Guardian's command-line scanner. It checks the packages you are
4
+ about to install or publish and tells you whether Dependency Guardian
5
+ verified them, flagged them, or blocked them — before they reach your machine.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install -g @westbayberry/dg
11
+ ```
12
+
13
+ Requires Node.js >= 22.14. The npm package is zero-footprint on install: it
14
+ adds only the `dg` binary and runs no install lifecycle scripts. Persistent
15
+ shell/shim changes happen only when you run `dg setup` explicitly.
16
+
17
+ ## Quickstart
18
+
19
+ Scan the project in the current directory:
20
+
21
+ ```bash
22
+ dg scan
23
+ ```
24
+
25
+ `dg scan` shows a full-screen results browser in an interactive terminal and
26
+ prints plain text or machine output otherwise. Exit code 0 means DG verified
27
+ the project, 2 means DG blocked it.
28
+
29
+ ## Core concepts
30
+
31
+ **Verdicts.** Every result is one of three states: **PASS** (DG verified),
32
+ **WARN** (DG flagged — review advised), or **BLOCK** (DG blocked — do not
33
+ install). The exit code follows the verdict.
34
+
35
+ **The server is the verdict source.** For authenticated registry checks and the
36
+ install firewall, the Dependency Guardian scanner returns the verdict and the
37
+ CLI displays it; the CLI never derives a verdict from a local score. If the
38
+ server is unreachable, `dg scan` falls back to local heuristics and marks the
39
+ report as such (`scannerUnavailable` in JSON output) rather than failing
40
+ silently.
41
+
42
+ **The install firewall.** Prefix a package-manager command with `dg`
43
+ (`dg npm install left-pad`) to route the install through Dependency Guardian.
44
+ The CLI streams the package manager's live output, computes each artifact's
45
+ SHA-256, asks the scanner for a verdict, and blocks the bytes before delivery
46
+ on a BLOCK verdict. A block exits 2 and prints the override command; a warn
47
+ prompts `Proceed? [y/N]` (default No) in a TTY. Passthrough commands (those
48
+ that fetch nothing) run without a proxy.
49
+
50
+ ## Common examples
51
+
52
+ Scan only staged files in a pre-commit context:
53
+
54
+ ```bash
55
+ dg scan --staged
56
+ ```
57
+
58
+ Verify a specific published package against the scanner:
59
+
60
+ ```bash
61
+ dg verify npm:left-pad@1.3.0
62
+ ```
63
+
64
+ Install a package through the firewall:
65
+
66
+ ```bash
67
+ dg npm install is-number@7.0.0
68
+ ```
69
+
70
+ Check what you are about to publish for leaked secrets and risky lifecycle
71
+ scripts, fully locally:
72
+
73
+ ```bash
74
+ dg audit . --local
75
+ ```
76
+
77
+ Produce CI-friendly machine output:
78
+
79
+ ```bash
80
+ dg scan --sarif --output dg-scan.sarif
81
+ ```
82
+
83
+ Protect every commit in a repository:
84
+
85
+ ```bash
86
+ dg guard-commit install
87
+ ```
88
+
89
+ ## Command reference
90
+
91
+ ### dg scan [path]
92
+
93
+ Scans package manifests and supported lockfiles for the project at `path` (the
94
+ current directory by default). Reads manifests only — it never runs package
95
+ scripts, installs dependencies, loads project-local config, or changes setup
96
+ state.
97
+
98
+ - Flags: `--staged`, `--json`, `--sarif`, `--output <file>`.
99
+ - Output: TUI in a rich TTY, text or machine output otherwise.
100
+ - Exit codes: 0 PASS, 1 WARN (strict mode upgrades WARN to 2), 2 BLOCK,
101
+ 4 analysis incomplete, 10 nothing to scan. Server unreachable falls back to
102
+ local heuristics and sets `scannerUnavailable` in JSON.
103
+
104
+ ### dg verify <spec | path | lockfile>
105
+
106
+ Two paths, one exit-code contract.
107
+
108
+ - `dg verify npm:<pkg>` / `dg verify pypi:<pkg>` runs an authenticated scanner
109
+ check and nudges you to sign in when logged out. Flags: `--json`, `--output`,
110
+ `--verbose`.
111
+ - `dg verify <path | lockfile>` runs a local advisory check on a package
112
+ directory, workspace, lockfile, or `.tgz`/`.tar.gz`/`.zip`/`.whl` archive.
113
+ Archive verification computes SHA-256 and checks archive paths before reading;
114
+ it never extracts to disk or runs package code. Flags: `--json`, `--sarif`,
115
+ `--output`.
116
+ - Exit codes (both paths): 0 PASS, 1 WARN (or scan error on the advisory path),
117
+ 2 BLOCK, 4 analysis incomplete (registry path).
118
+
119
+ ### dg audit [path]
120
+
121
+ Inspects exactly the resolved publish set of one package — never the whole
122
+ repo — for leaked secrets, private keys, source-control and build-artifact
123
+ leakage, and suspicious lifecycle-script strings. Basic checks run 100% locally
124
+ and upload nothing. On a paid plan, with org policy allowing it and only after
125
+ explicit consent, the deep audit uploads a packed copy of an npm package to the
126
+ scanner for a behavioral scan: no lifecycle scripts are run, raw bytes are never
127
+ retained, and only the verdict plus redacted findings reach your dashboard.
128
+
129
+ - Flags: `--json`, `--output`/`-o`, `--local` (skip the deep upload),
130
+ `--require-deep` (fail if the deep audit could not run), `--fail-on
131
+ <warn | block>`.
132
+ - Exit codes: 0 clean (WARN counts as clean under the default `--fail-on
133
+ block`), 1 WARN with `--fail-on warn`, 2 BLOCK, 3 deep audit required but
134
+ unavailable, 4 analysis incomplete.
135
+
136
+ ### dg licenses [path]
137
+
138
+ Reports license metadata from local manifests and supported lockfiles without
139
+ calling package managers or loading project-local config.
140
+
141
+ - Flags: `--json`, `--csv`, `--output <file>`, `--fail-on <risk[,risk...]>`,
142
+ `--deny-license <id>`.
143
+ - Exit codes: 0 clean, 1 when a license gate trips.
144
+
145
+ ### Package-manager prefixes (the install firewall)
146
+
147
+ `dg npm`, `dg npx`, `dg pnpm`, `dg pnpx`, `dg yarn`, `dg pip`, `dg pipx`,
148
+ `dg uv`, `dg uvx`, `dg cargo` route protected install/fetch commands through
149
+ the per-invocation proxy. `dg yarn` claims Yarn classic only; `dg bun`,
150
+ `dg conda`, and `dg mamba` and Yarn Berry remain gated and fail visibly before
151
+ spawning.
152
+
153
+ - Live output and stdin pass through; the install decision renders after the
154
+ child exits.
155
+ - A BLOCK exits 2 with an override hint. Override with `--dg-force-install`,
156
+ which is gated by `policy.allowForceOverride` and audited.
157
+ - A WARN prompts `Proceed? [y/N]` (default No) in a TTY.
158
+ - Signal deaths exit `128 + n`.
159
+
160
+ ### dg guard-commit
161
+
162
+ Installs a per-repo, reversible git pre-commit hook that scans staged changes.
163
+
164
+ - Subcommands/flags: `install`, `off` (`remove`/`uninstall`), `--check`,
165
+ `--print`, `--yes`.
166
+ - Chains any pre-existing pre-commit hook; `dg guard-commit off` removes only
167
+ the dg-owned hook.
168
+
169
+ ### dg setup / dg uninstall / dg doctor
170
+
171
+ - `dg setup` (POSIX only; `win32` exits 69) writes dg-owned package-manager
172
+ shims under `~/.dg/shims` and a sentinel block in your shell rc, recording
173
+ every write in the cleanup registry. `--print` shows the plan without
174
+ changing files; `--yes` applies it; `--service` opts into service mode.
175
+ - `dg uninstall` reverses dg-owned writes and leaves user content untouched.
176
+ Flags: `--yes`, `--keep-config`, `--all`, `--service`. `--all` conflicts
177
+ with `--keep-config`.
178
+ - `dg doctor` reports local setup health and prints concrete unavailable
179
+ status for optional gates (Windows, Python `.pth` hook, git hooks, Bun, Yarn
180
+ Berry, conda, mamba) instead of claiming them. `--json` for machine output.
181
+
182
+ ### dg service
183
+
184
+ Explicit, reversible service mode: `dg service start | stop | restart | status
185
+ | doctor | uninstall`, plus consent-gated `dg service trust install |
186
+ uninstall`. Trust records store only public certificate fingerprints, provider,
187
+ target, and timestamps — never private keys. `dg service status`/`doctor`
188
+ detect stale runtime state and `dg service restart` clears it.
189
+
190
+ ### dg login / dg logout
191
+
192
+ `dg login` stores a user-local auth token under the dg config directory and
193
+ prints only a redacted preview. `dg logout --yes` removes that auth file
194
+ without touching setup state or user config.
195
+
196
+ ### dg config
197
+
198
+ `dg config set <key> <value>`, `dg config get <key>`, `dg config list`
199
+ (`--json`). Keys: `api.baseUrl`, `org.id`, `policy.mode`,
200
+ `policy.trustProjectAllowlists`, `policy.allowForceOverride`,
201
+ `policy.scriptHardening`, `telemetry.enabled`, `webhooks.enabled`.
202
+
203
+ ### dg update / dg upgrade
204
+
205
+ Check the latest published version when registry metadata is available and
206
+ print the exact `npm install -g @westbayberry/dg@<version>` command. They never
207
+ run the package manager themselves. `upgrade` is an alias of `update`; `--json`
208
+ for machine output.
209
+
210
+ ### dg status / dg explain / dg completion
211
+
212
+ - `dg status` reports auth, API, and prefix-mode state for the current machine.
213
+ - `dg explain <id>` returns the explanation and next step for a firewall cause
214
+ or local scan finding.
215
+ - `dg completion <bash | zsh | fish>` prints a shell completion script.
216
+
217
+ ## Configuration
218
+
219
+ Config lives in `~/.dg/config.json` (mode 0600). Set values with `dg config
220
+ set`.
221
+
222
+ | Key | Purpose |
223
+ | --- | --- |
224
+ | `api.baseUrl` | Dependency Guardian API endpoint |
225
+ | `org.id` | Organization the CLI reports to |
226
+ | `policy.mode` | `off`, `warn`, `block`, or `strict` |
227
+ | `policy.trustProjectAllowlists` | Whether project-local allowlists are trusted |
228
+ | `policy.allowForceOverride` | Whether `--dg-force-install` is permitted |
229
+ | `policy.scriptHardening` | Preserve script-disabling flags; never re-enable scripts |
230
+ | `telemetry.enabled` | Telemetry (off by default) |
231
+ | `webhooks.enabled` | Webhook outbox delivery |
232
+
233
+ Project-local allowlists never suppress an install firewall block unless
234
+ user-global or org policy explicitly trusts them.
235
+
236
+ ### Environment variables
237
+
238
+ - `DG_API_TOKEN` — auth token; overrides the token stored in the config file.
239
+ - `DG_PRIVATE_REGISTRY_HOSTS` — comma-separated hosts whose URL-fallback
240
+ artifacts are eligible for private-registry scan upload.
241
+ - `DG_SCAN_TARBALL_UPLOAD` — set to `1` to enable private-registry artifact
242
+ upload to `/v1/scan-tarball` (requires `DG_API_TOKEN`).
243
+ - `DG_SERVICE_TRUST_STORE_BACKEND` / `DG_SERVICE_TRUST_STORE_DIR` — for
244
+ CI/Docker, set the backend to `file` and a directory to copy the active
245
+ public CA certificate into an image-local trust directory without touching
246
+ the host OS trust store.
247
+ - `NO_COLOR` / `FORCE_COLOR` — disable or force ANSI color output.
248
+
249
+ ## Exit codes
250
+
251
+ Codes shared by every command:
252
+
253
+ | Code | Meaning |
254
+ | --- | --- |
255
+ | 0 | PASS / clean |
256
+ | 1 | WARN |
257
+ | 2 | BLOCK, or a usage error |
258
+ | 4 | analysis incomplete |
259
+ | 69 | command unavailable or gated on this platform |
260
+ | 70 | internal error |
261
+ | 128 + n | child killed by signal n (firewall installs) |
262
+ | 130 / 143 | interrupted (SIGINT / SIGTERM) |
263
+
264
+ Per-command specifics:
265
+
266
+ - `dg scan`: strict mode upgrades WARN (1) to BLOCK (2); 10 means nothing to
267
+ scan.
268
+ - `dg audit`: 3 means a deep audit was required but unavailable; under the
269
+ default `--fail-on block`, WARN exits 0.
270
+ - `dg verify` (registry path): 4 means analysis incomplete; the advisory path
271
+ reports a scan error as 1.
272
+
273
+ ## Troubleshooting
274
+
275
+ Run `dg doctor` first — it reports Node version, package health, config
276
+ readability, shim/PATH state, and which optional gates are unavailable.
277
+
278
+ - "Scanner unavailable" / `scannerUnavailable` in JSON: the API was
279
+ unreachable and `dg scan` fell back to local heuristics. Check `api.baseUrl`
280
+ and network access.
281
+ - A safe package was blocked: confirm `policy.mode`; `strict` upgrades WARN to
282
+ BLOCK. Use `dg explain <id>` to see the cause.
283
+ - An install firewall block you need to override: rerun with
284
+ `--dg-force-install`, allowed only when `policy.allowForceOverride` is set;
285
+ the override is audited.
286
+ - `dg setup` exits 69 on Windows: setup is POSIX-only.
287
+ - An older `dg` runs instead of the installed one: run `which -a dg` and fix
288
+ PATH precedence.
289
+
290
+ ## Links
291
+
292
+ - Documentation: https://westbayberry.com/docs
293
+ - Pricing: https://westbayberry.com/pricing