@stackbilt/cli 0.1.19 → 0.2.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 (40) hide show
  1. package/LICENSE +190 -0
  2. package/README.md +137 -70
  3. package/dist/__tests__/hook.test.d.ts +2 -0
  4. package/dist/__tests__/hook.test.d.ts.map +1 -0
  5. package/dist/__tests__/hook.test.js +83 -0
  6. package/dist/__tests__/hook.test.js.map +1 -0
  7. package/dist/bin.js +0 -0
  8. package/dist/commands/adf.d.ts +8 -0
  9. package/dist/commands/adf.d.ts.map +1 -0
  10. package/dist/commands/adf.js +342 -0
  11. package/dist/commands/adf.js.map +1 -0
  12. package/dist/commands/audit.d.ts.map +1 -1
  13. package/dist/commands/audit.js +57 -22
  14. package/dist/commands/audit.js.map +1 -1
  15. package/dist/commands/drift.d.ts.map +1 -1
  16. package/dist/commands/drift.js +7 -2
  17. package/dist/commands/drift.js.map +1 -1
  18. package/dist/commands/hook.d.ts +8 -0
  19. package/dist/commands/hook.d.ts.map +1 -0
  20. package/dist/commands/hook.js +166 -0
  21. package/dist/commands/hook.js.map +1 -0
  22. package/dist/commands/init.d.ts.map +1 -1
  23. package/dist/commands/init.js +16 -2
  24. package/dist/commands/init.js.map +1 -1
  25. package/dist/commands/setup.d.ts.map +1 -1
  26. package/dist/commands/setup.js +188 -17
  27. package/dist/commands/setup.js.map +1 -1
  28. package/dist/commands/validate.d.ts.map +1 -1
  29. package/dist/commands/validate.js +90 -22
  30. package/dist/commands/validate.js.map +1 -1
  31. package/dist/commands/why.js +52 -25
  32. package/dist/commands/why.js.map +1 -1
  33. package/dist/config.d.ts +1 -0
  34. package/dist/config.d.ts.map +1 -1
  35. package/dist/config.js +30 -1
  36. package/dist/config.js.map +1 -1
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +9 -0
  39. package/dist/index.js.map +1 -1
  40. package/package.json +13 -12
package/LICENSE ADDED
@@ -0,0 +1,190 @@
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 the 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 the 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 any 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 reasonable and customary use in describing the
141
+ origin of the Work and 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 Additional Liability. 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 additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2026 StackBilt, Smart Brand Strategies LLC
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
package/README.md CHANGED
@@ -1,15 +1,21 @@
1
- # @stackbilt/cli
2
-
3
- CLI entry point for Charter Kit -- a local-first governance toolkit for software repositories. Orchestrates all other `@stackbilt/*` packages to parse commit trailers, score risk, detect blessed-stack drift, and classify change scope. No LLM calls at runtime.
4
-
5
- > **This is the only package most users need.** One install gives you the full Charter Kit toolkit.
6
-
1
+ # @stackbilt/cli
2
+
3
+ CLI entry point for Charter Kit -- a local-first governance toolkit for software repositories. Orchestrates all other `@stackbilt/*` packages to parse commit trailers, score risk, detect blessed-stack drift, and classify change scope. No LLM calls at runtime.
4
+
5
+ > **This is the only package most users need.** One install gives you the full Charter Kit toolkit.
6
+
7
7
  ## Install (Recommended)
8
8
 
9
9
  ```bash
10
10
  npm install --save-dev @stackbilt/cli
11
11
  ```
12
12
 
13
+ If using a pnpm workspace root:
14
+
15
+ ```bash
16
+ pnpm add -Dw @stackbilt/cli
17
+ ```
18
+
13
19
  Use with `npx` in each repository:
14
20
 
15
21
  ```bash
@@ -37,11 +43,11 @@ npx --no-install charter --version
37
43
  ```
38
44
 
39
45
  For CI pipelines, install as a dev dependency:
40
-
41
- ```bash
42
- npm install --save-dev @stackbilt/cli
43
- ```
44
-
46
+
47
+ ```bash
48
+ npm install --save-dev @stackbilt/cli
49
+ ```
50
+
45
51
  Requires Node >= 18.
46
52
 
47
53
  ## Quick Start
@@ -55,6 +61,10 @@ charter validate # validate commit governance trailers
55
61
  charter drift # scan for blessed-stack drift
56
62
  charter audit # generate governance audit report
57
63
  charter classify "migrate auth provider"
64
+ charter hook install --commit-msg
65
+ charter adf init # scaffold .ai/ context directory
66
+ charter adf fmt .ai/core.adf # reformat ADF to canonical form
67
+ charter adf bundle --task "fix React component"
58
68
  ```
59
69
 
60
70
  ## Human Onboarding (Copy/Paste)
@@ -65,6 +75,7 @@ Run this in the target repository:
65
75
  npm install -g @stackbilt/cli
66
76
  charter
67
77
  charter setup --ci github
78
+ charter classify "describe the planned change"
68
79
  charter doctor --format json
69
80
  charter validate --format text
70
81
  charter drift --format text
@@ -113,6 +124,7 @@ npm install --save-dev @stackbilt/cli@latest
113
124
  # setup
114
125
  npx charter setup --detect-only --format json
115
126
  npx charter setup --ci github --yes --format json
127
+ npx charter classify "describe the planned change" --format json
116
128
 
117
129
  # enforce on PR/build
118
130
  npx charter validate --ci --format json
@@ -123,9 +135,9 @@ npx charter audit --format json
123
135
  npx charter doctor --format json
124
136
  npx charter audit --format json
125
137
  ```
126
-
127
- ## Commands
128
-
138
+
139
+ ## Commands
140
+
129
141
  ### `charter` (no args)
130
142
 
131
143
  Default first-run experience. Shows:
@@ -160,85 +172,140 @@ Detection output includes `detected.sources` in JSON mode so agents can verify w
160
172
  Setup also adds optional root scripts when missing: `charter:detect` and `charter:setup`.
161
173
  Setup JSON now includes `mutationPlan` and `appliedMutations` so side effects are explicit before/after apply.
162
174
  Setup baseline mutation metadata now includes `configHashBefore`, `configHashAfter`, and `writesPerformed`.
163
-
175
+
164
176
  ### `charter init`
165
177
 
166
178
  Scaffold `.charter/` config templates only. Supports `--preset worker|frontend|backend|fullstack`.
167
-
168
- ### `charter doctor`
169
-
170
- Validate CLI installation and `.charter/` config.
171
-
179
+
180
+ ### `charter doctor`
181
+
182
+ Validate CLI installation and `.charter/` config.
183
+
172
184
  ### `charter validate`
173
185
 
174
186
  Validate git commits for `Governed-By` and `Resolves-Request` trailers.
175
-
176
- ```bash
187
+
188
+ ```bash
177
189
  charter validate --ci --format json
178
190
  charter validate --range HEAD~10..HEAD --format json
179
191
  ```
180
192
 
181
193
  When `--range` is omitted, JSON includes `effectiveRangeSource` and `defaultCommitRange` so automation can trace default selection behavior.
182
-
183
- ### `charter drift`
184
-
185
- Scan files against blessed-stack patterns in `.charter/patterns/*.json`.
186
-
187
- ```bash
188
- charter drift --path ./src --ci
189
- ```
190
-
194
+
195
+ Trailer formatting requirement:
196
+ - Governance trailers must be in one contiguous trailer block at the end of the commit message.
197
+ - A blank line inside the trailer section can make governance trailers unparsable by git trailer rules.
198
+
199
+ Valid:
200
+
201
+ ```text
202
+ feat: ship governance checks
203
+
204
+ Governed-By: ADR-012
205
+ Resolves-Request: REQ-078
206
+ Co-Authored-By: Dev <dev@example.com>
207
+ ```
208
+
209
+ Invalid (blank line splits the trailer block):
210
+
211
+ ```text
212
+ feat: ship governance checks
213
+
214
+ Governed-By: ADR-012
215
+ Resolves-Request: REQ-078
216
+
217
+ Co-Authored-By: Dev <dev@example.com>
218
+ ```
219
+
220
+ ### `charter drift`
221
+
222
+ Scan files against blessed-stack patterns in `.charter/patterns/*.json`.
223
+
224
+ ```bash
225
+ charter drift --path ./src --ci
226
+ ```
227
+
228
+ JSON output includes `patternsCustomized` when pattern files declare customization metadata.
229
+
191
230
  ### `charter audit`
192
231
 
193
232
  Generate a governance audit report covering trailers, risk, drift, and policy-section coverage quality.
194
233
  Use `--range <revset>` to audit the same commit window used by validation in reviews.
195
234
 
196
235
  If score is held down by trailer coverage, enforce `validate --ci` in PR checks and add commit-template guidance for required trailers.
197
-
236
+ Audit output includes whether preset pattern files are still uncustomized when metadata is present.
237
+
198
238
  ### `charter classify`
199
-
200
- Classify a change as `SURFACE`, `LOCAL`, or `CROSS_CUTTING`.
201
-
202
- ```bash
239
+
240
+ Classify a change as `SURFACE`, `LOCAL`, or `CROSS_CUTTING`.
241
+
242
+ ```bash
203
243
  charter classify "update button color"
204
244
  ```
205
-
206
- ## Global Options
207
-
208
- | Option | Description | Default |
209
- |---|---|---|
210
- | `--config <path>` | Path to `.charter/` directory | `.charter/` |
211
- | `--format <mode>` | Output: `text` or `json` | `text` |
212
- | `--ci` | CI mode: exit non-zero on WARN or FAIL | off |
245
+
246
+ ### `charter hook`
247
+
248
+ Install git hooks for commit-time trailer ergonomics.
249
+
250
+ ```bash
251
+ charter hook install --commit-msg
252
+ ```
253
+
254
+ `--force` (or global `--yes`) allows overwrite when a non-Charter `commit-msg` hook already exists.
255
+
256
+ ### `charter adf`
257
+
258
+ ADF (Attention-Directed Format) context management. Replaces monolithic `.cursorrules`/`claude.md` files with a modular, AST-backed `.ai/` directory.
259
+
260
+ ```bash
261
+ charter adf init [--ai-dir <dir>] [--force]
262
+ charter adf fmt <file> [--check] [--write]
263
+ charter adf patch <file> --ops '<json>'
264
+ charter adf bundle --task "Fix React component" [--ai-dir <dir>]
265
+ ```
266
+
267
+ - `init`: Scaffold `.ai/` with `manifest.adf`, `core.adf`, and `state.adf`.
268
+ - `fmt`: Parse and reformat to canonical ADF. `--check` exits 1 if not canonical. `--write` reformats in place. Default prints to stdout.
269
+ - `patch`: Apply typed delta operations (ADD_BULLET, REPLACE_BULLET, REMOVE_BULLET, ADD_SECTION, REPLACE_SECTION, REMOVE_SECTION).
270
+ - `bundle`: Read `manifest.adf`, resolve ON_DEMAND modules via keyword matching against the task, and output merged context with token estimate.
271
+
272
+ ## Global Options
273
+
274
+ | Option | Description | Default |
275
+ |---|---|---|
276
+ | `--config <path>` | Path to `.charter/` directory | `.charter/` |
277
+ | `--format <mode>` | Output: `text` or `json` | `text` |
278
+ | `--ci` | CI mode: exit non-zero on WARN or FAIL | off |
213
279
  | `--yes` | Auto-accept safe setup overwrites | off |
214
280
 
215
281
  Setup-only options:
216
282
  - `--preset <worker|frontend|backend|fullstack>`: override auto-detected preset
217
283
  - `--detect-only`: print stack detection result and selected preset without writing files
218
284
  - `--no-dependency-sync`: skip rewriting `devDependencies["@stackbilt/cli"]` during setup
219
-
220
- ## Exit Codes
221
-
222
- | Code | Meaning |
223
- |------|---------|
224
- | 0 | Success |
225
- | 1 | Policy violation (CI mode) |
226
- | 2 | Runtime or usage error |
227
-
228
- ## Related Packages
229
-
230
- - `@stackbilt/types` -- shared enums and interfaces
231
- - `@stackbilt/core` -- Zod schemas and sanitization helpers
232
- - `@stackbilt/git` -- trailer parsing and commit risk assessment
233
- - `@stackbilt/classify` -- heuristic change classification
234
- - `@stackbilt/drift` -- blessed-stack pattern drift detection
235
- - `@stackbilt/validate` -- citation validation and intent classification
236
- - `@stackbilt/ci` -- GitHub Actions integration helpers
237
-
238
- ## License
239
-
240
- Apache-2.0
241
-
242
- ## Repository
243
-
244
- [https://github.com/Stackbilt-dev/charter](https://github.com/Stackbilt-dev/charter)
285
+
286
+ ## Exit Codes
287
+
288
+ | Code | Meaning |
289
+ |------|---------|
290
+ | 0 | Success |
291
+ | 1 | Policy violation (CI mode) |
292
+ | 2 | Runtime or usage error |
293
+
294
+ ## Related Packages
295
+
296
+ - `@stackbilt/types` -- shared enums and interfaces
297
+ - `@stackbilt/core` -- Zod schemas and sanitization helpers
298
+ - `@stackbilt/git` -- trailer parsing and commit risk assessment
299
+ - `@stackbilt/classify` -- heuristic change classification
300
+ - `@stackbilt/drift` -- blessed-stack pattern drift detection
301
+ - `@stackbilt/validate` -- citation validation and intent classification
302
+ - `@stackbilt/adf` -- ADF parser, formatter, patcher, and bundler
303
+ - `@stackbilt/ci` -- GitHub Actions integration helpers
304
+
305
+ ## License
306
+
307
+ Apache-2.0
308
+
309
+ ## Repository
310
+
311
+ [https://github.com/Stackbilt-dev/charter](https://github.com/Stackbilt-dev/charter)
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=hook.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hook.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/hook.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ const vitest_1 = require("vitest");
37
+ const node_child_process_1 = require("node:child_process");
38
+ const fs = __importStar(require("node:fs"));
39
+ const os = __importStar(require("node:os"));
40
+ const path = __importStar(require("node:path"));
41
+ const hook_1 = require("../commands/hook");
42
+ const baseOptions = {
43
+ configPath: '.charter',
44
+ format: 'text',
45
+ ciMode: false,
46
+ yes: false,
47
+ };
48
+ (0, vitest_1.describe)('hookCommand', () => {
49
+ let originalCwd;
50
+ let tempDir;
51
+ (0, vitest_1.beforeEach)(() => {
52
+ originalCwd = process.cwd();
53
+ tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'charter-hook-test-'));
54
+ process.chdir(tempDir);
55
+ (0, node_child_process_1.execFileSync)('git', ['init'], { stdio: 'ignore' });
56
+ });
57
+ (0, vitest_1.afterEach)(() => {
58
+ process.chdir(originalCwd);
59
+ fs.rmSync(tempDir, { recursive: true, force: true });
60
+ vitest_1.vi.restoreAllMocks();
61
+ });
62
+ (0, vitest_1.it)('installs commit-msg hook', async () => {
63
+ vitest_1.vi.spyOn(console, 'log').mockImplementation(() => { });
64
+ const exitCode = await (0, hook_1.hookCommand)(baseOptions, ['install', '--commit-msg']);
65
+ (0, vitest_1.expect)(exitCode).toBe(0);
66
+ const hookPath = path.join(tempDir, '.git', 'hooks', 'commit-msg');
67
+ (0, vitest_1.expect)(fs.existsSync(hookPath)).toBe(true);
68
+ const content = fs.readFileSync(hookPath, 'utf-8');
69
+ (0, vitest_1.expect)(content).toContain('Managed by Charter: commit-msg trailer normalizer');
70
+ (0, vitest_1.expect)(content).toContain('git interpret-trailers --in-place');
71
+ });
72
+ (0, vitest_1.it)('skips existing non-charter hook without --force', async () => {
73
+ vitest_1.vi.spyOn(console, 'log').mockImplementation(() => { });
74
+ const hookPath = path.join(tempDir, '.git', 'hooks', 'commit-msg');
75
+ fs.mkdirSync(path.dirname(hookPath), { recursive: true });
76
+ fs.writeFileSync(hookPath, '#!/usr/bin/env sh\necho "custom"\n');
77
+ const exitCode = await (0, hook_1.hookCommand)(baseOptions, ['install', '--commit-msg']);
78
+ (0, vitest_1.expect)(exitCode).toBe(0);
79
+ const content = fs.readFileSync(hookPath, 'utf-8');
80
+ (0, vitest_1.expect)(content).toContain('echo "custom"');
81
+ });
82
+ });
83
+ //# sourceMappingURL=hook.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hook.test.js","sourceRoot":"","sources":["../../src/__tests__/hook.test.ts"],"names":[],"mappings":"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"}
package/dist/bin.js CHANGED
File without changes
@@ -0,0 +1,8 @@
1
+ /**
2
+ * charter adf
3
+ *
4
+ * ADF (Attention-Directed Format) subcommands: init, fmt, patch, bundle.
5
+ */
6
+ import type { CLIOptions } from '../index';
7
+ export declare function adfCommand(options: CLIOptions, args: string[]): Promise<number>;
8
+ //# sourceMappingURL=adf.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adf.d.ts","sourceRoot":"","sources":["../../src/commands/adf.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAaH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AA8C3C,wBAAsB,UAAU,CAAC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAqBrF"}