cngkit 1.1.21 → 1.1.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +198 -4
- package/README.md +22 -12
- package/dist/{chunk-NGEWD4BW.js → chunk-25Q463MH.js} +1 -2
- package/dist/{chunk-SMTQ3W3F.js → chunk-3BATDTKU.js} +131 -112
- package/dist/chunk-3BATDTKU.js.map +1 -0
- package/dist/{chunk-DIJEVOVN.js → chunk-67FUBMNB.js} +71 -240
- package/dist/chunk-67FUBMNB.js.map +1 -0
- package/dist/chunk-AS7FIJWP.js +88 -0
- package/dist/chunk-AS7FIJWP.js.map +1 -0
- package/dist/chunk-BRFWVQI4.js +18 -0
- package/dist/chunk-BRFWVQI4.js.map +1 -0
- package/dist/{chunk-CVF2ODLP.js → chunk-BXS4IKUA.js} +300 -143
- package/dist/chunk-BXS4IKUA.js.map +1 -0
- package/dist/{chunk-YJXAH7D5.js → chunk-GYRLVNJX.js} +2 -2
- package/dist/chunk-GYRLVNJX.js.map +1 -0
- package/dist/{chunk-SKK2XLRZ.js → chunk-JNHW72SU.js} +21 -15
- package/dist/chunk-JNHW72SU.js.map +1 -0
- package/dist/chunk-U725ZHCI.js +67 -0
- package/dist/chunk-U725ZHCI.js.map +1 -0
- package/dist/chunk-VMTXY4KQ.js +111 -0
- package/dist/chunk-VMTXY4KQ.js.map +1 -0
- package/dist/chunk-WIEYHKQA.js +268 -0
- package/dist/chunk-WIEYHKQA.js.map +1 -0
- package/dist/chunk-YALWTRIP.js +102 -0
- package/dist/chunk-YALWTRIP.js.map +1 -0
- package/dist/cli.js +2 -2
- package/dist/cli.js.map +1 -1
- package/dist/commands/coderoom/index.js +4 -4
- package/dist/commands/coderoom/join.js +5 -5
- package/dist/commands/coderoom/share.js +8 -11
- package/dist/commands/coderoom/share.js.map +1 -1
- package/dist/commands/hookify/index.js +4 -4
- package/dist/commands/hookify/ingest.js +4 -4
- package/dist/commands/hooks/index.js +4 -4
- package/dist/commands/hooks/install.js +4 -4
- package/dist/commands/hooks/uninstall.js +4 -4
- package/dist/commands/index.js +3 -3
- package/dist/commands/knowledges/audiences.js +26 -8
- package/dist/commands/knowledges/audiences.js.map +1 -1
- package/dist/commands/knowledges/cat.js +26 -7
- package/dist/commands/knowledges/cat.js.map +1 -1
- package/dist/commands/knowledges/files.js +39 -8
- package/dist/commands/knowledges/files.js.map +1 -1
- package/dist/commands/knowledges/find.js +48 -8
- package/dist/commands/knowledges/find.js.map +1 -1
- package/dist/commands/knowledges/glob.js +41 -8
- package/dist/commands/knowledges/glob.js.map +1 -1
- package/dist/commands/knowledges/grep.js +73 -8
- package/dist/commands/knowledges/grep.js.map +1 -1
- package/dist/commands/knowledges/head.js +31 -8
- package/dist/commands/knowledges/head.js.map +1 -1
- package/dist/commands/knowledges/index.js +4 -4
- package/dist/commands/knowledges/list.js +39 -8
- package/dist/commands/knowledges/list.js.map +1 -1
- package/dist/commands/knowledges/ls.js +47 -8
- package/dist/commands/knowledges/ls.js.map +1 -1
- package/dist/commands/knowledges/read.js +46 -8
- package/dist/commands/knowledges/read.js.map +1 -1
- package/dist/commands/knowledges/realpath.js +23 -8
- package/dist/commands/knowledges/realpath.js.map +1 -1
- package/dist/commands/knowledges/search.js +34 -8
- package/dist/commands/knowledges/search.js.map +1 -1
- package/dist/commands/knowledges/stat.js +32 -8
- package/dist/commands/knowledges/stat.js.map +1 -1
- package/dist/commands/knowledges/status.js +26 -8
- package/dist/commands/knowledges/status.js.map +1 -1
- package/dist/commands/knowledges/tail.js +30 -8
- package/dist/commands/knowledges/tail.js.map +1 -1
- package/dist/commands/knowledges/tree.js +38 -8
- package/dist/commands/knowledges/tree.js.map +1 -1
- package/dist/commands/login.js +3 -3
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/scrub.js +3 -3
- package/dist/commands/scrub.js.map +1 -1
- package/dist/commands/transcripts.js +137 -119
- package/dist/commands/transcripts.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-52PGDSFU.js +0 -42
- package/dist/chunk-52PGDSFU.js.map +0 -1
- package/dist/chunk-5WTRGYAO.js +0 -658
- package/dist/chunk-5WTRGYAO.js.map +0 -1
- package/dist/chunk-CVF2ODLP.js.map +0 -1
- package/dist/chunk-DIJEVOVN.js.map +0 -1
- package/dist/chunk-SKK2XLRZ.js.map +0 -1
- package/dist/chunk-SMTQ3W3F.js.map +0 -1
- package/dist/chunk-YJXAH7D5.js.map +0 -1
- /package/dist/{chunk-NGEWD4BW.js.map → chunk-25Q463MH.js.map} +0 -0
package/LICENSE
CHANGED
|
@@ -1,7 +1,201 @@
|
|
|
1
|
-
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
1. Definitions.
|
|
6
8
|
|
|
7
|
-
|
|
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 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
|
+
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 [yyyy] [name of copyright owner]
|
|
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.
|
package/README.md
CHANGED
|
@@ -10,6 +10,19 @@ inspection, and terminal access to the hosted Harness knowledge catalog.
|
|
|
10
10
|
well in terminals, scripts, and coding assistants. Human-facing status lines use Ink
|
|
11
11
|
styling when the terminal supports color. Data-heavy output stays plain and easy to pipe.
|
|
12
12
|
|
|
13
|
+
## Important Notice
|
|
14
|
+
|
|
15
|
+
`cngkit` is a personal-use project. I publish it because it solves problems I run into
|
|
16
|
+
in my own operator workflow, not because it is a polished community-maintained open-source
|
|
17
|
+
platform.
|
|
18
|
+
|
|
19
|
+
Assume backend-backed commands send their inputs, metadata, and command context to the
|
|
20
|
+
owner-operated Curly.ng backend for processing. Do not use this package as a self-contained
|
|
21
|
+
offline tool or neutral third-party service boundary.
|
|
22
|
+
|
|
23
|
+
If you need this to become a real open-source project, a self-hostable system, or a package
|
|
24
|
+
with stronger data-processing guarantees, reach out first.
|
|
25
|
+
|
|
13
26
|
## Quick Start
|
|
14
27
|
|
|
15
28
|
Run it without installing:
|
|
@@ -59,8 +72,8 @@ The CLI currently has six main jobs:
|
|
|
59
72
|
## Coderoom
|
|
60
73
|
|
|
61
74
|
Coderoom is a live room for quickly sharing a working tree with another developer or agent.
|
|
62
|
-
One machine
|
|
63
|
-
|
|
75
|
+
One machine creates a server-owned room code, another asks to join with that code,
|
|
76
|
+
and the creator approves the request before files sync.
|
|
64
77
|
|
|
65
78
|
Start a room:
|
|
66
79
|
|
|
@@ -74,15 +87,11 @@ Join a room:
|
|
|
74
87
|
cngkit coderoom join <room-code>
|
|
75
88
|
```
|
|
76
89
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
Coderoom deliberately skips `.git/` and files ignored by `.gitignore`. It is a live relay,
|
|
84
|
-
not durable cloud storage or a backup system. The current conflict rule is simple: the latest
|
|
85
|
-
received change wins.
|
|
90
|
+
Coderoom deliberately skips `.git/` and files ignored by `.gitignore`. Room codes,
|
|
91
|
+
participants, join requests, and file IDs are created by the backend. The room Durable
|
|
92
|
+
Object stores the file tree and hashes, keeps small file bodies directly, and uses R2
|
|
93
|
+
for large file bodies. The current conflict rule is simple: the latest received change
|
|
94
|
+
wins.
|
|
86
95
|
|
|
87
96
|
## Harness Knowledges
|
|
88
97
|
|
|
@@ -409,4 +418,5 @@ The package build uses `tsup` to emit a file-preserving ESM build. The published
|
|
|
409
418
|
|
|
410
419
|
## License
|
|
411
420
|
|
|
412
|
-
|
|
421
|
+
Apache-2.0, with the personal-use and owner-operated backend notice above. If this helps
|
|
422
|
+
you, support the workshop: https://curly.ng/support
|
|
@@ -102,7 +102,6 @@ export {
|
|
|
102
102
|
GlobalOptionsSchema,
|
|
103
103
|
JsonOutputOptionsSchema,
|
|
104
104
|
OptionalPathArgsSchema,
|
|
105
|
-
OptionalRoomCodeArgsSchema,
|
|
106
105
|
RequiredRoomCodeArgsSchema,
|
|
107
106
|
OptionalQueryArgsSchema,
|
|
108
107
|
RequiredQueryArgsSchema,
|
|
@@ -113,4 +112,4 @@ export {
|
|
|
113
112
|
LimitOptionsSchema,
|
|
114
113
|
TranscriptArgsSchema
|
|
115
114
|
};
|
|
116
|
-
//# sourceMappingURL=chunk-
|
|
115
|
+
//# sourceMappingURL=chunk-25Q463MH.js.map
|
|
@@ -1,57 +1,7 @@
|
|
|
1
|
-
// src/features/hooks/
|
|
2
|
-
import fs from "fs/promises";
|
|
1
|
+
// src/features/hooks/hooks-targets.ts
|
|
3
2
|
import os from "os";
|
|
4
3
|
import path from "path";
|
|
5
|
-
import { createElement } from "react";
|
|
6
|
-
import { z } from "zod";
|
|
7
|
-
|
|
8
|
-
// src/features/hooks/hooks-output.tsx
|
|
9
|
-
import { Box, Text } from "ink";
|
|
10
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
-
function HookTargetResults({
|
|
12
|
-
results
|
|
13
|
-
}) {
|
|
14
|
-
return /* @__PURE__ */ jsx(Box, { flexDirection: "column", children: results.map((result) => /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [
|
|
15
|
-
/* @__PURE__ */ jsxs(Text, { color: "green", bold: true, children: [
|
|
16
|
-
result.action,
|
|
17
|
-
" ",
|
|
18
|
-
result.changedCount,
|
|
19
|
-
" ",
|
|
20
|
-
result.label,
|
|
21
|
-
" hook",
|
|
22
|
-
result.changedCount === 1 ? "" : "s"
|
|
23
|
-
] }),
|
|
24
|
-
/* @__PURE__ */ jsx(Text, { children: result.configPath }),
|
|
25
|
-
result.replacedCount !== void 0 ? /* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
|
|
26
|
-
"replaced ",
|
|
27
|
-
result.replacedCount,
|
|
28
|
-
" existing cngkit handler(s)"
|
|
29
|
-
] }) : null,
|
|
30
|
-
/* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
|
|
31
|
-
"events: ",
|
|
32
|
-
result.events.length > 0 ? result.events.join(", ") : "none"
|
|
33
|
-
] })
|
|
34
|
-
] }, `${result.label}-${result.configPath}`)) });
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// src/features/hooks/run-hooks-install-command.ts
|
|
38
4
|
var hookToolIds = ["all", "claude", "codex"];
|
|
39
|
-
var cngkitHookCommandPrefix = "cngkit hookify ingest --event ";
|
|
40
|
-
var legacyCngkitHookCommandPrefixes = [
|
|
41
|
-
"npx --yes cngkit@latest hookify ingest --event ",
|
|
42
|
-
"npm exec cngkit@latest hookify ingest --event ",
|
|
43
|
-
"npm exec --yes cngkit@latest hookify ingest --event "
|
|
44
|
-
];
|
|
45
|
-
var HookHandlerSchema = z.object({
|
|
46
|
-
command: z.string().optional()
|
|
47
|
-
}).passthrough();
|
|
48
|
-
var HookGroupSchema = z.object({
|
|
49
|
-
hooks: z.array(HookHandlerSchema).optional()
|
|
50
|
-
}).passthrough();
|
|
51
|
-
var HooksConfigSchema = z.record(z.string(), z.array(HookGroupSchema));
|
|
52
|
-
var AgentSettingsDocumentSchema = z.object({
|
|
53
|
-
hooks: HooksConfigSchema.optional()
|
|
54
|
-
}).passthrough();
|
|
55
5
|
var claudeHookEvents = [
|
|
56
6
|
"SessionStart",
|
|
57
7
|
"Setup",
|
|
@@ -96,24 +46,6 @@ var codexHookEvents = [
|
|
|
96
46
|
"SubagentStop",
|
|
97
47
|
"Stop"
|
|
98
48
|
];
|
|
99
|
-
async function runHooksInstallCommand(options, output) {
|
|
100
|
-
const targets = resolveInstallTargets(options.tool ?? "all");
|
|
101
|
-
const results = [];
|
|
102
|
-
for (const target of targets) {
|
|
103
|
-
const result = await installHooksForTarget(target, options.dryRun === true);
|
|
104
|
-
results.push(result);
|
|
105
|
-
}
|
|
106
|
-
output.component(createElement(HookTargetResults, { results }));
|
|
107
|
-
}
|
|
108
|
-
async function runHooksUninstallCommand(options, output) {
|
|
109
|
-
const targets = resolveInstallTargets(options.tool ?? "all");
|
|
110
|
-
const results = [];
|
|
111
|
-
for (const target of targets) {
|
|
112
|
-
const result = await uninstallHooksForTarget(target, options.dryRun === true);
|
|
113
|
-
results.push(result);
|
|
114
|
-
}
|
|
115
|
-
output.component(createElement(HookTargetResults, { results }));
|
|
116
|
-
}
|
|
117
49
|
function resolveInstallTargets(tool) {
|
|
118
50
|
const homeDirectory = os.homedir();
|
|
119
51
|
const targets = [
|
|
@@ -137,6 +69,112 @@ function resolveInstallTargets(tool) {
|
|
|
137
69
|
}
|
|
138
70
|
return targets.filter((target) => target.tool === tool);
|
|
139
71
|
}
|
|
72
|
+
|
|
73
|
+
// src/features/hooks/run-hooks-install-command.ts
|
|
74
|
+
import { createElement } from "react";
|
|
75
|
+
|
|
76
|
+
// src/features/hooks/hooks-output.tsx
|
|
77
|
+
import { Box, Text } from "ink";
|
|
78
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
79
|
+
function HookTargetResults({
|
|
80
|
+
results
|
|
81
|
+
}) {
|
|
82
|
+
return /* @__PURE__ */ jsx(Box, { flexDirection: "column", children: results.map((result) => /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [
|
|
83
|
+
/* @__PURE__ */ jsxs(Text, { color: "green", bold: true, children: [
|
|
84
|
+
result.action,
|
|
85
|
+
" ",
|
|
86
|
+
result.changedCount,
|
|
87
|
+
" ",
|
|
88
|
+
result.label,
|
|
89
|
+
" hook",
|
|
90
|
+
result.changedCount === 1 ? "" : "s"
|
|
91
|
+
] }),
|
|
92
|
+
/* @__PURE__ */ jsx(Text, { children: result.configPath }),
|
|
93
|
+
result.replacedCount !== void 0 ? /* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
|
|
94
|
+
"replaced ",
|
|
95
|
+
result.replacedCount,
|
|
96
|
+
" existing cngkit handler(s)"
|
|
97
|
+
] }) : null,
|
|
98
|
+
/* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
|
|
99
|
+
"events: ",
|
|
100
|
+
result.events.length > 0 ? result.events.join(", ") : "none"
|
|
101
|
+
] })
|
|
102
|
+
] }, `${result.label}-${result.configPath}`)) });
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// src/features/hooks/hooks-install-flow.ts
|
|
106
|
+
import fs2 from "fs/promises";
|
|
107
|
+
import path2 from "path";
|
|
108
|
+
|
|
109
|
+
// src/features/hooks/hooks-handler.ts
|
|
110
|
+
var cngkitHookCommandPrefix = "cngkit hookify ingest --event ";
|
|
111
|
+
var legacyCngkitHookCommandPrefixes = [
|
|
112
|
+
"npx --yes cngkit@latest hookify ingest --event ",
|
|
113
|
+
"npm exec cngkit@latest hookify ingest --event ",
|
|
114
|
+
"npm exec --yes cngkit@latest hookify ingest --event "
|
|
115
|
+
];
|
|
116
|
+
function isCngkitHookHandler(handler) {
|
|
117
|
+
const command = handler.command?.trimStart();
|
|
118
|
+
if (command === void 0) {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
return [cngkitHookCommandPrefix, ...legacyCngkitHookCommandPrefixes].some(
|
|
122
|
+
(prefix) => command.startsWith(prefix)
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
function createCngkitHookHandler(eventName, withStatusMessage) {
|
|
126
|
+
const handler = {
|
|
127
|
+
type: "command",
|
|
128
|
+
command: `${cngkitHookCommandPrefix}${eventName}`
|
|
129
|
+
};
|
|
130
|
+
if (!withStatusMessage) {
|
|
131
|
+
return handler;
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
...handler,
|
|
135
|
+
statusMessage: `Forwarding ${eventName} hook to cngkit`
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// src/features/hooks/hooks-document-io.ts
|
|
140
|
+
import fs from "fs/promises";
|
|
141
|
+
import { z as z2 } from "zod";
|
|
142
|
+
|
|
143
|
+
// src/features/hooks/hooks-schemas.ts
|
|
144
|
+
import { z } from "zod";
|
|
145
|
+
var HookHandlerSchema = z.object({
|
|
146
|
+
command: z.string().optional()
|
|
147
|
+
}).passthrough();
|
|
148
|
+
var HookGroupSchema = z.object({
|
|
149
|
+
hooks: z.array(HookHandlerSchema).optional()
|
|
150
|
+
}).passthrough();
|
|
151
|
+
var HooksConfigSchema = z.record(z.string(), z.array(HookGroupSchema));
|
|
152
|
+
var AgentSettingsDocumentSchema = z.object({
|
|
153
|
+
hooks: HooksConfigSchema.optional()
|
|
154
|
+
}).passthrough();
|
|
155
|
+
|
|
156
|
+
// src/features/hooks/hooks-document-io.ts
|
|
157
|
+
async function readJsonDocument(filePath) {
|
|
158
|
+
if (!await fileExists(filePath)) {
|
|
159
|
+
return {};
|
|
160
|
+
}
|
|
161
|
+
const content = await fs.readFile(filePath, "utf8");
|
|
162
|
+
return AgentSettingsDocumentSchema.parse(JSON.parse(content));
|
|
163
|
+
}
|
|
164
|
+
async function fileExists(filePath) {
|
|
165
|
+
return fs.access(filePath).then(
|
|
166
|
+
() => true,
|
|
167
|
+
() => false
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
function parseHookConfig(value) {
|
|
171
|
+
return z2.record(z2.string(), z2.array(HookGroupSchema)).catch({}).parse(value ?? {});
|
|
172
|
+
}
|
|
173
|
+
function parseHookGroups(value) {
|
|
174
|
+
return z2.array(HookGroupSchema).catch([]).parse(value ?? []);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// src/features/hooks/hooks-install-flow.ts
|
|
140
178
|
async function installHooksForTarget(target, dryRun) {
|
|
141
179
|
const document = await readJsonDocument(target.configPath);
|
|
142
180
|
const hooks = parseHookConfig(document.hooks);
|
|
@@ -148,8 +186,8 @@ async function installHooksForTarget(target, dryRun) {
|
|
|
148
186
|
}
|
|
149
187
|
document.hooks = hooks;
|
|
150
188
|
if (!dryRun) {
|
|
151
|
-
await
|
|
152
|
-
await
|
|
189
|
+
await fs2.mkdir(path2.dirname(target.configPath), { recursive: true });
|
|
190
|
+
await fs2.writeFile(target.configPath, `${JSON.stringify(document, null, 2)}
|
|
153
191
|
`);
|
|
154
192
|
}
|
|
155
193
|
const action = dryRun ? "Would install" : "Installed";
|
|
@@ -175,10 +213,12 @@ async function uninstallHooksForTarget(target, dryRun) {
|
|
|
175
213
|
}
|
|
176
214
|
hooks[eventName] = result.groups;
|
|
177
215
|
}
|
|
178
|
-
document.hooks = Object.fromEntries(
|
|
216
|
+
document.hooks = Object.fromEntries(
|
|
217
|
+
Object.entries(hooks).filter(([, groups]) => groups.length > 0)
|
|
218
|
+
);
|
|
179
219
|
if (!dryRun) {
|
|
180
|
-
await
|
|
181
|
-
await
|
|
220
|
+
await fs2.mkdir(path2.dirname(target.configPath), { recursive: true });
|
|
221
|
+
await fs2.writeFile(target.configPath, `${JSON.stringify(document, null, 2)}
|
|
182
222
|
`);
|
|
183
223
|
}
|
|
184
224
|
const action = dryRun ? "Would remove" : "Removed";
|
|
@@ -190,19 +230,6 @@ async function uninstallHooksForTarget(target, dryRun) {
|
|
|
190
230
|
events: removedEvents
|
|
191
231
|
};
|
|
192
232
|
}
|
|
193
|
-
async function readJsonDocument(filePath) {
|
|
194
|
-
if (!await fileExists(filePath)) {
|
|
195
|
-
return {};
|
|
196
|
-
}
|
|
197
|
-
const content = await fs.readFile(filePath, "utf8");
|
|
198
|
-
return AgentSettingsDocumentSchema.parse(JSON.parse(content));
|
|
199
|
-
}
|
|
200
|
-
async function fileExists(filePath) {
|
|
201
|
-
return fs.access(filePath).then(
|
|
202
|
-
() => true,
|
|
203
|
-
() => false
|
|
204
|
-
);
|
|
205
|
-
}
|
|
206
233
|
function installHookEvent(existingGroups, eventName, withStatusMessage) {
|
|
207
234
|
const result = uninstallHookEvent(existingGroups ?? []);
|
|
208
235
|
return {
|
|
@@ -234,33 +261,25 @@ function uninstallHookEvent(groups) {
|
|
|
234
261
|
});
|
|
235
262
|
return { groups: cleanedGroups, removedHandlers };
|
|
236
263
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
if (command === void 0) {
|
|
246
|
-
return false;
|
|
264
|
+
|
|
265
|
+
// src/features/hooks/run-hooks-install-command.ts
|
|
266
|
+
async function runHooksInstallCommand(options, output) {
|
|
267
|
+
const targets = resolveInstallTargets(options.tool ?? "all");
|
|
268
|
+
const results = [];
|
|
269
|
+
for (const target of targets) {
|
|
270
|
+
const result = await installHooksForTarget(target, options.dryRun === true);
|
|
271
|
+
results.push(result);
|
|
247
272
|
}
|
|
248
|
-
|
|
249
|
-
(prefix) => command.startsWith(prefix)
|
|
250
|
-
);
|
|
273
|
+
output.component(createElement(HookTargetResults, { results }));
|
|
251
274
|
}
|
|
252
|
-
function
|
|
253
|
-
const
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
return handler;
|
|
275
|
+
async function runHooksUninstallCommand(options, output) {
|
|
276
|
+
const targets = resolveInstallTargets(options.tool ?? "all");
|
|
277
|
+
const results = [];
|
|
278
|
+
for (const target of targets) {
|
|
279
|
+
const result = await uninstallHooksForTarget(target, options.dryRun === true);
|
|
280
|
+
results.push(result);
|
|
259
281
|
}
|
|
260
|
-
|
|
261
|
-
...handler,
|
|
262
|
-
statusMessage: `Forwarding ${eventName} hook to cngkit`
|
|
263
|
-
};
|
|
282
|
+
output.component(createElement(HookTargetResults, { results }));
|
|
264
283
|
}
|
|
265
284
|
|
|
266
285
|
export {
|
|
@@ -268,4 +287,4 @@ export {
|
|
|
268
287
|
runHooksInstallCommand,
|
|
269
288
|
runHooksUninstallCommand
|
|
270
289
|
};
|
|
271
|
-
//# sourceMappingURL=chunk-
|
|
290
|
+
//# sourceMappingURL=chunk-3BATDTKU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/features/hooks/hooks-targets.ts","../src/features/hooks/run-hooks-install-command.ts","../src/features/hooks/hooks-output.tsx","../src/features/hooks/hooks-install-flow.ts","../src/features/hooks/hooks-handler.ts","../src/features/hooks/hooks-document-io.ts","../src/features/hooks/hooks-schemas.ts"],"sourcesContent":["import os from \"node:os\";\nimport path from \"node:path\";\n\nexport const hookToolIds = [\"all\", \"claude\", \"codex\"] as const;\n\nexport type HookToolId = (typeof hookToolIds)[number];\n\nexport type InstallTarget = {\n readonly tool: Exclude<HookToolId, \"all\">;\n readonly label: string;\n readonly configPath: string;\n readonly events: readonly string[];\n readonly statusMessages: boolean;\n};\n\nexport const claudeHookEvents = [\n \"SessionStart\",\n \"Setup\",\n \"InstructionsLoaded\",\n \"UserPromptSubmit\",\n \"UserPromptExpansion\",\n \"MessageDisplay\",\n \"PreToolUse\",\n \"PermissionRequest\",\n \"PermissionDenied\",\n \"PostToolUse\",\n \"PostToolUseFailure\",\n \"PostToolBatch\",\n \"Notification\",\n \"SubagentStart\",\n \"SubagentStop\",\n \"TaskCreated\",\n \"TaskCompleted\",\n \"Stop\",\n \"StopFailure\",\n \"TeammateIdle\",\n \"ConfigChange\",\n \"CwdChanged\",\n \"FileChanged\",\n \"WorktreeCreate\",\n \"WorktreeRemove\",\n \"PreCompact\",\n \"PostCompact\",\n \"SessionEnd\",\n \"Elicitation\",\n \"ElicitationResult\",\n] as const;\n\nexport const codexHookEvents = [\n \"SessionStart\",\n \"SubagentStart\",\n \"PreToolUse\",\n \"PermissionRequest\",\n \"PostToolUse\",\n \"PreCompact\",\n \"PostCompact\",\n \"UserPromptSubmit\",\n \"SubagentStop\",\n \"Stop\",\n] as const;\n\nexport function resolveInstallTargets(tool: HookToolId): InstallTarget[] {\n const homeDirectory = os.homedir();\n const targets: InstallTarget[] = [\n {\n tool: \"claude\",\n label: \"Claude Code\",\n configPath: path.join(homeDirectory, \".claude\", \"settings.json\"),\n events: claudeHookEvents,\n statusMessages: false,\n },\n {\n tool: \"codex\",\n label: \"Codex\",\n configPath: path.join(homeDirectory, \".codex\", \"hooks.json\"),\n events: codexHookEvents,\n statusMessages: true,\n },\n ];\n\n if (tool === \"all\") {\n return targets;\n }\n\n return targets.filter((target) => target.tool === tool);\n}\n","// Public API entrypoint for hooks install/uninstall. Implementation lives in\n// `./hooks-{schemas,targets,handler,document-io,install-flow}.ts`; this file\n// just dispatches and renders the result.\n\nimport { createElement } from \"react\";\n\nimport type { CommandOutput } from \"../../shared/output/types.js\";\nimport { HookTargetResults } from \"./hooks-output.js\";\nimport {\n installHooksForTarget,\n uninstallHooksForTarget,\n} from \"./hooks-install-flow.js\";\nimport { hookToolIds, resolveInstallTargets, type HookToolId } from \"./hooks-targets.js\";\n\nexport { hookToolIds };\nexport type { HookToolId } from \"./hooks-targets.js\";\n\nexport type HooksInstallCommandOptions = {\n readonly dryRun?: boolean;\n readonly tool?: HookToolId;\n};\n\nexport type HooksUninstallCommandOptions = {\n readonly dryRun?: boolean;\n readonly tool?: HookToolId;\n};\n\nexport async function runHooksInstallCommand(\n options: HooksInstallCommandOptions,\n output: CommandOutput\n): Promise<void> {\n const targets = resolveInstallTargets(options.tool ?? \"all\");\n const results = [];\n\n for (const target of targets) {\n const result = await installHooksForTarget(target, options.dryRun === true);\n results.push(result);\n }\n\n output.component(createElement(HookTargetResults, { results }));\n}\n\nexport async function runHooksUninstallCommand(\n options: HooksUninstallCommandOptions,\n output: CommandOutput\n): Promise<void> {\n const targets = resolveInstallTargets(options.tool ?? \"all\");\n const results = [];\n\n for (const target of targets) {\n const result = await uninstallHooksForTarget(target, options.dryRun === true);\n results.push(result);\n }\n\n output.component(createElement(HookTargetResults, { results }));\n}\n","import { Box, Text } from \"ink\";\n\nexport type HookTargetResult = {\n readonly action: string;\n readonly label: string;\n readonly configPath: string;\n readonly changedCount: number;\n readonly replacedCount?: number;\n readonly events: readonly string[];\n};\n\nexport function HookTargetResults({\n results,\n}: {\n readonly results: readonly HookTargetResult[];\n}) {\n return (\n <Box flexDirection=\"column\">\n {results.map((result) => (\n <Box flexDirection=\"column\" key={`${result.label}-${result.configPath}`} marginBottom={1}>\n <Text color=\"green\" bold>\n {result.action} {result.changedCount} {result.label} hook\n {result.changedCount === 1 ? \"\" : \"s\"}\n </Text>\n <Text>{result.configPath}</Text>\n {result.replacedCount !== undefined ? (\n <Text dimColor>replaced {result.replacedCount} existing cngkit handler(s)</Text>\n ) : null}\n <Text dimColor>events: {result.events.length > 0 ? result.events.join(\", \") : \"none\"}</Text>\n </Box>\n ))}\n </Box>\n );\n}\n","import fs from \"node:fs/promises\";\nimport path from \"node:path\";\n\nimport type { HookTargetResult } from \"./hooks-output.js\";\nimport {\n createCngkitHookHandler,\n isCngkitHookHandler,\n} from \"./hooks-handler.js\";\nimport { parseHookConfig, parseHookGroups, readJsonDocument } from \"./hooks-document-io.js\";\nimport type { HookGroup } from \"./hooks-schemas.js\";\nimport type { InstallTarget } from \"./hooks-targets.js\";\n\nexport async function installHooksForTarget(\n target: InstallTarget,\n dryRun: boolean\n): Promise<HookTargetResult> {\n const document = await readJsonDocument(target.configPath);\n const hooks = parseHookConfig(document.hooks);\n let replacedHandlers = 0;\n\n for (const eventName of target.events) {\n const result = installHookEvent(hooks[eventName], eventName, target.statusMessages);\n hooks[eventName] = result.groups;\n replacedHandlers += result.removedHandlers;\n }\n\n document.hooks = hooks;\n\n if (!dryRun) {\n await fs.mkdir(path.dirname(target.configPath), { recursive: true });\n await fs.writeFile(target.configPath, `${JSON.stringify(document, null, 2)}\\n`);\n }\n\n const action = dryRun ? \"Would install\" : \"Installed\";\n return {\n action,\n label: target.label,\n configPath: target.configPath,\n changedCount: target.events.length,\n replacedCount: replacedHandlers,\n events: target.events,\n };\n}\n\nexport async function uninstallHooksForTarget(\n target: InstallTarget,\n dryRun: boolean\n): Promise<HookTargetResult> {\n const document = await readJsonDocument(target.configPath);\n const hooks = parseHookConfig(document.hooks);\n const removedEvents: string[] = [];\n let removedHandlers = 0;\n\n for (const [eventName, groups] of Object.entries(hooks)) {\n const result = uninstallHookEvent(groups);\n if (result.removedHandlers > 0) {\n removedEvents.push(eventName);\n removedHandlers += result.removedHandlers;\n }\n hooks[eventName] = result.groups;\n }\n\n document.hooks = Object.fromEntries(\n Object.entries(hooks).filter(([, groups]) => groups.length > 0)\n );\n\n if (!dryRun) {\n await fs.mkdir(path.dirname(target.configPath), { recursive: true });\n await fs.writeFile(target.configPath, `${JSON.stringify(document, null, 2)}\\n`);\n }\n\n const action = dryRun ? \"Would remove\" : \"Removed\";\n return {\n action,\n label: target.label,\n configPath: target.configPath,\n changedCount: removedHandlers,\n events: removedEvents,\n };\n}\n\nfunction installHookEvent(\n existingGroups: HookGroup[] | undefined,\n eventName: string,\n withStatusMessage: boolean\n): {\n readonly groups: HookGroup[];\n readonly removedHandlers: number;\n} {\n const result = uninstallHookEvent(existingGroups ?? []);\n\n return {\n groups: [\n ...result.groups,\n {\n hooks: [createCngkitHookHandler(eventName, withStatusMessage)],\n },\n ],\n removedHandlers: result.removedHandlers,\n };\n}\n\nfunction uninstallHookEvent(groups: HookGroup[] | undefined): {\n readonly groups: HookGroup[];\n readonly removedHandlers: number;\n} {\n let removedHandlers = 0;\n const cleanedGroups = parseHookGroups(groups)\n .map((group) => {\n if (group.hooks === undefined) {\n return group;\n }\n\n const hooks = group.hooks.filter((handler) => {\n const keep = !isCngkitHookHandler(handler);\n if (!keep) {\n removedHandlers += 1;\n }\n return keep;\n });\n\n return { ...group, hooks };\n })\n .filter((group) => {\n return group.hooks === undefined || group.hooks.length > 0;\n });\n\n return { groups: cleanedGroups, removedHandlers };\n}\n","import type { HookHandler } from \"./hooks-schemas.js\";\n\nexport const cngkitHookCommandPrefix = \"cngkit hookify ingest --event \";\n\nexport const legacyCngkitHookCommandPrefixes = [\n \"npx --yes cngkit@latest hookify ingest --event \",\n \"npm exec cngkit@latest hookify ingest --event \",\n \"npm exec --yes cngkit@latest hookify ingest --event \",\n] as const;\n\nexport function isCngkitHookHandler(handler: HookHandler): boolean {\n const command = handler.command?.trimStart();\n if (command === undefined) {\n return false;\n }\n\n return [cngkitHookCommandPrefix, ...legacyCngkitHookCommandPrefixes].some((prefix) =>\n command.startsWith(prefix)\n );\n}\n\nexport function createCngkitHookHandler(\n eventName: string,\n withStatusMessage: boolean\n): HookHandler {\n const handler: HookHandler = {\n type: \"command\",\n command: `${cngkitHookCommandPrefix}${eventName}`,\n };\n\n if (!withStatusMessage) {\n return handler;\n }\n\n return {\n ...handler,\n statusMessage: `Forwarding ${eventName} hook to cngkit`,\n };\n}\n","import fs from \"node:fs/promises\";\n\nimport { z } from \"zod\";\n\nimport {\n AgentSettingsDocumentSchema,\n HookGroupSchema,\n type AgentSettingsDocument,\n type HookConfig,\n type HookGroup,\n} from \"./hooks-schemas.js\";\n\nexport async function readJsonDocument(filePath: string): Promise<AgentSettingsDocument> {\n if (!(await fileExists(filePath))) {\n return {};\n }\n\n const content = await fs.readFile(filePath, \"utf8\");\n return AgentSettingsDocumentSchema.parse(JSON.parse(content));\n}\n\nexport async function fileExists(filePath: string): Promise<boolean> {\n return fs.access(filePath).then(\n () => true,\n () => false\n );\n}\n\nexport function parseHookConfig(value: AgentSettingsDocument[\"hooks\"]): HookConfig {\n // The runtime config may be malformed by other tools; fall back to an empty\n // hooks record so callers can still mutate and rewrite it without throwing.\n return z.record(z.string(), z.array(HookGroupSchema)).catch({}).parse(value ?? {});\n}\n\nexport function parseHookGroups(value: HookGroup[] | undefined): HookGroup[] {\n return z.array(HookGroupSchema).catch([]).parse(value ?? []);\n}\n","import { z } from \"zod\";\n\nexport const HookHandlerSchema = z\n .object({\n command: z.string().optional(),\n })\n .passthrough();\n\nexport const HookGroupSchema = z\n .object({\n hooks: z.array(HookHandlerSchema).optional(),\n })\n .passthrough();\n\nexport const HooksConfigSchema = z.record(z.string(), z.array(HookGroupSchema));\n\nexport const AgentSettingsDocumentSchema = z\n .object({\n hooks: HooksConfigSchema.optional(),\n })\n .passthrough();\n\nexport type HookHandler = z.infer<typeof HookHandlerSchema>;\nexport type HookGroup = z.infer<typeof HookGroupSchema>;\nexport type HookConfig = z.infer<typeof HooksConfigSchema>;\nexport type AgentSettingsDocument = z.infer<typeof AgentSettingsDocumentSchema>;\n"],"mappings":";AAA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