@countinghouse/ch-local 0.0.1-placeholder.0 → 1.0.1

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 (262) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +366 -0
  3. package/bin/ch-local.js +472 -0
  4. package/clients/claude-code/.claude-plugin/plugin.json +6 -0
  5. package/clients/claude-code/.mcp.json +11 -0
  6. package/clients/claude-code/bin/launch.js +235 -0
  7. package/clients/claude-code/bin/win-acl.js +420 -0
  8. package/clients/claude-code/skills/ci-failure-triage/SKILL.md +21 -0
  9. package/clients/claude-code/skills/countinghouse-module/SKILL.md +177 -0
  10. package/clients/claude-code/skills/countinghouse-setup/SKILL.md +74 -0
  11. package/lib/allowlist.js +65 -0
  12. package/lib/aside.js +16 -0
  13. package/lib/atomic.js +45 -0
  14. package/lib/auto-apply.js +245 -0
  15. package/lib/auto-upgrade.js +98 -0
  16. package/lib/availability.js +307 -0
  17. package/lib/ceiling.js +280 -0
  18. package/lib/clean-text.js +20 -0
  19. package/lib/cli-change.js +38 -0
  20. package/lib/client-conditions-fixtures.js +143 -0
  21. package/lib/client-conditions.js +656 -0
  22. package/lib/clients.js +179 -0
  23. package/lib/command-line.js +202 -0
  24. package/lib/conditions-command.js +116 -0
  25. package/lib/control.js +134 -0
  26. package/lib/credential-store.js +414 -0
  27. package/lib/credentials-command.js +344 -0
  28. package/lib/daemon-requests.js +137 -0
  29. package/lib/daemon.js +888 -0
  30. package/lib/describe-module.js +137 -0
  31. package/lib/description-check.js +175 -0
  32. package/lib/failed-json.js +43 -0
  33. package/lib/gc.js +274 -0
  34. package/lib/github-token.js +57 -0
  35. package/lib/handoff-io.js +73 -0
  36. package/lib/held-back.js +116 -0
  37. package/lib/hidden-input.js +64 -0
  38. package/lib/history.js +49 -0
  39. package/lib/home.js +372 -0
  40. package/lib/in-place.js +1036 -0
  41. package/lib/install-plan.js +142 -0
  42. package/lib/install.js +846 -0
  43. package/lib/installed-description.js +153 -0
  44. package/lib/integrity.js +7 -0
  45. package/lib/lock.js +456 -0
  46. package/lib/lockfile-rules.js +98 -0
  47. package/lib/machine.js +20 -0
  48. package/lib/module-credentials.js +403 -0
  49. package/lib/module-record.js +298 -0
  50. package/lib/module-roles.js +44 -0
  51. package/lib/module-seams.js +26 -0
  52. package/lib/module-store.js +202 -0
  53. package/lib/module-values.js +334 -0
  54. package/lib/names.js +31 -0
  55. package/lib/next-steps.js +8 -0
  56. package/lib/node-check.js +56 -0
  57. package/lib/npm-fetch.js +123 -0
  58. package/lib/npm-release.js +99 -0
  59. package/lib/npm-upgrade.js +146 -0
  60. package/lib/npm.js +41 -0
  61. package/lib/outside-edits.js +162 -0
  62. package/lib/own-applied.js +175 -0
  63. package/lib/own-command.js +380 -0
  64. package/lib/own-file.js +120 -0
  65. package/lib/own-record.js +96 -0
  66. package/lib/own-tree.js +336 -0
  67. package/lib/pack-table.js +290 -0
  68. package/lib/packs-command.js +570 -0
  69. package/lib/packs.js +219 -0
  70. package/lib/pins.js +64 -0
  71. package/lib/pipe-probe.js +82 -0
  72. package/lib/plain-read.js +63 -0
  73. package/lib/private-file.js +90 -0
  74. package/lib/private-write.js +33 -0
  75. package/lib/provenance.js +234 -0
  76. package/lib/record.js +82 -0
  77. package/lib/registry.js +22 -0
  78. package/lib/release-pins.js +350 -0
  79. package/lib/release-pins.json +4227 -0
  80. package/lib/release-tags.js +12 -0
  81. package/lib/release.js +36 -0
  82. package/lib/restart-command.js +161 -0
  83. package/lib/rollback.js +227 -0
  84. package/lib/run-liveness.js +15 -0
  85. package/lib/runtime-log.js +287 -0
  86. package/lib/sandbox-support.js +17 -0
  87. package/lib/semver-order.js +40 -0
  88. package/lib/session-socket.js +69 -0
  89. package/lib/session-table.js +238 -0
  90. package/lib/session.js +281 -0
  91. package/lib/settings-command.js +82 -0
  92. package/lib/settings.js +568 -0
  93. package/lib/shim-binary.js +152 -0
  94. package/lib/shim-config.js +159 -0
  95. package/lib/shim-install.js +365 -0
  96. package/lib/sigstore/README.md +44 -0
  97. package/lib/sigstore/npm-keys.json +18 -0
  98. package/lib/sigstore/trusted-root.json +126 -0
  99. package/lib/snippets.js +76 -0
  100. package/lib/start.js +721 -0
  101. package/lib/store-files.js +48 -0
  102. package/lib/store-paths.js +33 -0
  103. package/lib/swap-preload.js +38 -0
  104. package/lib/tar.js +220 -0
  105. package/lib/uninstall.js +314 -0
  106. package/lib/unpack.js +41 -0
  107. package/lib/upgrade-stamp.js +63 -0
  108. package/lib/upgrade.js +281 -0
  109. package/lib/watch.js +40 -0
  110. package/lib/win-acl.js +420 -0
  111. package/node_modules/@sigstore/bundle/LICENSE +202 -0
  112. package/node_modules/@sigstore/bundle/README.md +19 -0
  113. package/node_modules/@sigstore/bundle/dist/build.d.ts +18 -0
  114. package/node_modules/@sigstore/bundle/dist/build.js +100 -0
  115. package/node_modules/@sigstore/bundle/dist/bundle.d.ts +74 -0
  116. package/node_modules/@sigstore/bundle/dist/bundle.js +24 -0
  117. package/node_modules/@sigstore/bundle/dist/error.d.ts +4 -0
  118. package/node_modules/@sigstore/bundle/dist/error.js +25 -0
  119. package/node_modules/@sigstore/bundle/dist/index.d.ts +8 -0
  120. package/node_modules/@sigstore/bundle/dist/index.js +43 -0
  121. package/node_modules/@sigstore/bundle/dist/serialized.d.ts +74 -0
  122. package/node_modules/@sigstore/bundle/dist/serialized.js +49 -0
  123. package/node_modules/@sigstore/bundle/dist/utility.d.ts +14 -0
  124. package/node_modules/@sigstore/bundle/dist/utility.js +2 -0
  125. package/node_modules/@sigstore/bundle/dist/validate.d.ts +7 -0
  126. package/node_modules/@sigstore/bundle/dist/validate.js +199 -0
  127. package/node_modules/@sigstore/bundle/package.json +35 -0
  128. package/node_modules/@sigstore/core/LICENSE +202 -0
  129. package/node_modules/@sigstore/core/README.md +10 -0
  130. package/node_modules/@sigstore/core/dist/asn1/error.d.ts +4 -0
  131. package/node_modules/@sigstore/core/dist/asn1/error.js +24 -0
  132. package/node_modules/@sigstore/core/dist/asn1/index.d.ts +1 -0
  133. package/node_modules/@sigstore/core/dist/asn1/index.js +20 -0
  134. package/node_modules/@sigstore/core/dist/asn1/length.d.ts +3 -0
  135. package/node_modules/@sigstore/core/dist/asn1/length.js +62 -0
  136. package/node_modules/@sigstore/core/dist/asn1/obj.d.ts +14 -0
  137. package/node_modules/@sigstore/core/dist/asn1/obj.js +155 -0
  138. package/node_modules/@sigstore/core/dist/asn1/parse.d.ts +6 -0
  139. package/node_modules/@sigstore/core/dist/asn1/parse.js +124 -0
  140. package/node_modules/@sigstore/core/dist/asn1/tag.d.ts +16 -0
  141. package/node_modules/@sigstore/core/dist/asn1/tag.js +89 -0
  142. package/node_modules/@sigstore/core/dist/crypto.d.ts +6 -0
  143. package/node_modules/@sigstore/core/dist/crypto.js +69 -0
  144. package/node_modules/@sigstore/core/dist/dsse.d.ts +1 -0
  145. package/node_modules/@sigstore/core/dist/dsse.js +29 -0
  146. package/node_modules/@sigstore/core/dist/encoding.d.ts +2 -0
  147. package/node_modules/@sigstore/core/dist/encoding.js +27 -0
  148. package/node_modules/@sigstore/core/dist/index.d.ts +9 -0
  149. package/node_modules/@sigstore/core/dist/index.js +66 -0
  150. package/node_modules/@sigstore/core/dist/json.d.ts +1 -0
  151. package/node_modules/@sigstore/core/dist/json.js +60 -0
  152. package/node_modules/@sigstore/core/dist/oid.d.ts +3 -0
  153. package/node_modules/@sigstore/core/dist/oid.js +20 -0
  154. package/node_modules/@sigstore/core/dist/pem.d.ts +2 -0
  155. package/node_modules/@sigstore/core/dist/pem.js +43 -0
  156. package/node_modules/@sigstore/core/dist/rfc3161/error.d.ts +2 -0
  157. package/node_modules/@sigstore/core/dist/rfc3161/error.js +21 -0
  158. package/node_modules/@sigstore/core/dist/rfc3161/index.d.ts +1 -0
  159. package/node_modules/@sigstore/core/dist/rfc3161/index.js +20 -0
  160. package/node_modules/@sigstore/core/dist/rfc3161/timestamp.d.ts +36 -0
  161. package/node_modules/@sigstore/core/dist/rfc3161/timestamp.js +212 -0
  162. package/node_modules/@sigstore/core/dist/rfc3161/tstinfo.d.ts +12 -0
  163. package/node_modules/@sigstore/core/dist/rfc3161/tstinfo.js +72 -0
  164. package/node_modules/@sigstore/core/dist/stream.d.ts +21 -0
  165. package/node_modules/@sigstore/core/dist/stream.js +117 -0
  166. package/node_modules/@sigstore/core/dist/x509/cert.d.ts +43 -0
  167. package/node_modules/@sigstore/core/dist/x509/cert.js +245 -0
  168. package/node_modules/@sigstore/core/dist/x509/ext.d.ts +41 -0
  169. package/node_modules/@sigstore/core/dist/x509/ext.js +146 -0
  170. package/node_modules/@sigstore/core/dist/x509/index.d.ts +2 -0
  171. package/node_modules/@sigstore/core/dist/x509/index.js +23 -0
  172. package/node_modules/@sigstore/core/dist/x509/sct.d.ts +25 -0
  173. package/node_modules/@sigstore/core/dist/x509/sct.js +158 -0
  174. package/node_modules/@sigstore/core/package.json +31 -0
  175. package/node_modules/@sigstore/protobuf-specs/LICENSE +202 -0
  176. package/node_modules/@sigstore/protobuf-specs/README.md +5 -0
  177. package/node_modules/@sigstore/protobuf-specs/dist/__generated__/envelope.d.ts +44 -0
  178. package/node_modules/@sigstore/protobuf-specs/dist/__generated__/envelope.js +59 -0
  179. package/node_modules/@sigstore/protobuf-specs/dist/__generated__/events.d.ts +64 -0
  180. package/node_modules/@sigstore/protobuf-specs/dist/__generated__/events.js +174 -0
  181. package/node_modules/@sigstore/protobuf-specs/dist/__generated__/google/api/field_behavior.d.ts +74 -0
  182. package/node_modules/@sigstore/protobuf-specs/dist/__generated__/google/api/field_behavior.js +141 -0
  183. package/node_modules/@sigstore/protobuf-specs/dist/__generated__/google/protobuf/any.d.ts +74 -0
  184. package/node_modules/@sigstore/protobuf-specs/dist/__generated__/google/protobuf/any.js +35 -0
  185. package/node_modules/@sigstore/protobuf-specs/dist/__generated__/google/protobuf/descriptor.d.ts +1309 -0
  186. package/node_modules/@sigstore/protobuf-specs/dist/__generated__/google/protobuf/descriptor.js +2191 -0
  187. package/node_modules/@sigstore/protobuf-specs/dist/__generated__/google/protobuf/timestamp.d.ts +113 -0
  188. package/node_modules/@sigstore/protobuf-specs/dist/__generated__/google/protobuf/timestamp.js +29 -0
  189. package/node_modules/@sigstore/protobuf-specs/dist/__generated__/rekor/v2/dsse.d.ts +23 -0
  190. package/node_modules/@sigstore/protobuf-specs/dist/__generated__/rekor/v2/dsse.js +55 -0
  191. package/node_modules/@sigstore/protobuf-specs/dist/__generated__/rekor/v2/entry.d.ts +43 -0
  192. package/node_modules/@sigstore/protobuf-specs/dist/__generated__/rekor/v2/entry.js +81 -0
  193. package/node_modules/@sigstore/protobuf-specs/dist/__generated__/rekor/v2/hashedrekord.d.ts +22 -0
  194. package/node_modules/@sigstore/protobuf-specs/dist/__generated__/rekor/v2/hashedrekord.js +56 -0
  195. package/node_modules/@sigstore/protobuf-specs/dist/__generated__/rekor/v2/verifier.d.ts +35 -0
  196. package/node_modules/@sigstore/protobuf-specs/dist/__generated__/rekor/v2/verifier.js +74 -0
  197. package/node_modules/@sigstore/protobuf-specs/dist/__generated__/sigstore_bundle.d.ts +146 -0
  198. package/node_modules/@sigstore/protobuf-specs/dist/__generated__/sigstore_bundle.js +103 -0
  199. package/node_modules/@sigstore/protobuf-specs/dist/__generated__/sigstore_common.d.ts +304 -0
  200. package/node_modules/@sigstore/protobuf-specs/dist/__generated__/sigstore_common.js +612 -0
  201. package/node_modules/@sigstore/protobuf-specs/dist/__generated__/sigstore_monitor.d.ts +33 -0
  202. package/node_modules/@sigstore/protobuf-specs/dist/__generated__/sigstore_monitor.js +55 -0
  203. package/node_modules/@sigstore/protobuf-specs/dist/__generated__/sigstore_rekor.d.ts +144 -0
  204. package/node_modules/@sigstore/protobuf-specs/dist/__generated__/sigstore_rekor.js +137 -0
  205. package/node_modules/@sigstore/protobuf-specs/dist/__generated__/sigstore_trustroot.d.ts +386 -0
  206. package/node_modules/@sigstore/protobuf-specs/dist/__generated__/sigstore_trustroot.js +284 -0
  207. package/node_modules/@sigstore/protobuf-specs/dist/__generated__/sigstore_verification.d.ts +191 -0
  208. package/node_modules/@sigstore/protobuf-specs/dist/__generated__/sigstore_verification.js +281 -0
  209. package/node_modules/@sigstore/protobuf-specs/dist/index.d.ts +6 -0
  210. package/node_modules/@sigstore/protobuf-specs/dist/index.js +37 -0
  211. package/node_modules/@sigstore/protobuf-specs/dist/rekor/v2/index.d.ts +4 -0
  212. package/node_modules/@sigstore/protobuf-specs/dist/rekor/v2/index.js +35 -0
  213. package/node_modules/@sigstore/protobuf-specs/package.json +35 -0
  214. package/node_modules/@sigstore/verify/README.md +9 -0
  215. package/node_modules/@sigstore/verify/dist/bundle/dsse.d.ts +12 -0
  216. package/node_modules/@sigstore/verify/dist/bundle/dsse.js +44 -0
  217. package/node_modules/@sigstore/verify/dist/bundle/index.d.ts +4 -0
  218. package/node_modules/@sigstore/verify/dist/bundle/index.js +59 -0
  219. package/node_modules/@sigstore/verify/dist/bundle/message.d.ts +13 -0
  220. package/node_modules/@sigstore/verify/dist/bundle/message.js +54 -0
  221. package/node_modules/@sigstore/verify/dist/error.d.ts +16 -0
  222. package/node_modules/@sigstore/verify/dist/error.js +34 -0
  223. package/node_modules/@sigstore/verify/dist/index.d.ts +6 -0
  224. package/node_modules/@sigstore/verify/dist/index.js +28 -0
  225. package/node_modules/@sigstore/verify/dist/key/certificate.d.ts +21 -0
  226. package/node_modules/@sigstore/verify/dist/key/certificate.js +216 -0
  227. package/node_modules/@sigstore/verify/dist/key/index.d.ts +10 -0
  228. package/node_modules/@sigstore/verify/dist/key/index.js +75 -0
  229. package/node_modules/@sigstore/verify/dist/key/sct.d.ts +4 -0
  230. package/node_modules/@sigstore/verify/dist/key/sct.js +78 -0
  231. package/node_modules/@sigstore/verify/dist/policy.d.ts +5 -0
  232. package/node_modules/@sigstore/verify/dist/policy.js +50 -0
  233. package/node_modules/@sigstore/verify/dist/shared.types.d.ts +50 -0
  234. package/node_modules/@sigstore/verify/dist/shared.types.js +2 -0
  235. package/node_modules/@sigstore/verify/dist/timestamp/index.d.ts +11 -0
  236. package/node_modules/@sigstore/verify/dist/timestamp/index.js +24 -0
  237. package/node_modules/@sigstore/verify/dist/timestamp/tsa.d.ts +3 -0
  238. package/node_modules/@sigstore/verify/dist/timestamp/tsa.js +63 -0
  239. package/node_modules/@sigstore/verify/dist/tlog/checkpoint.d.ts +11 -0
  240. package/node_modules/@sigstore/verify/dist/tlog/checkpoint.js +154 -0
  241. package/node_modules/@sigstore/verify/dist/tlog/dsse.d.ts +6 -0
  242. package/node_modules/@sigstore/verify/dist/tlog/dsse.js +106 -0
  243. package/node_modules/@sigstore/verify/dist/tlog/hashedrekord.d.ts +6 -0
  244. package/node_modules/@sigstore/verify/dist/tlog/hashedrekord.js +94 -0
  245. package/node_modules/@sigstore/verify/dist/tlog/index.d.ts +5 -0
  246. package/node_modules/@sigstore/verify/dist/tlog/index.js +92 -0
  247. package/node_modules/@sigstore/verify/dist/tlog/intoto.d.ts +3 -0
  248. package/node_modules/@sigstore/verify/dist/tlog/intoto.js +62 -0
  249. package/node_modules/@sigstore/verify/dist/tlog/merkle.d.ts +3 -0
  250. package/node_modules/@sigstore/verify/dist/tlog/merkle.js +104 -0
  251. package/node_modules/@sigstore/verify/dist/tlog/set.d.ts +3 -0
  252. package/node_modules/@sigstore/verify/dist/tlog/set.js +60 -0
  253. package/node_modules/@sigstore/verify/dist/trust/filter.d.ts +8 -0
  254. package/node_modules/@sigstore/verify/dist/trust/filter.js +23 -0
  255. package/node_modules/@sigstore/verify/dist/trust/index.d.ts +5 -0
  256. package/node_modules/@sigstore/verify/dist/trust/index.js +90 -0
  257. package/node_modules/@sigstore/verify/dist/trust/trust.types.d.ts +29 -0
  258. package/node_modules/@sigstore/verify/dist/trust/trust.types.js +2 -0
  259. package/node_modules/@sigstore/verify/dist/verifier.d.ts +31 -0
  260. package/node_modules/@sigstore/verify/dist/verifier.js +160 -0
  261. package/node_modules/@sigstore/verify/package.json +36 -0
  262. package/package.json +36 -2
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,366 @@
1
+ # @countinghouse/ch-local
2
+
3
+ **Ready-made tools for your coding agent that do the data work on your
4
+ machine, so the raw data never reaches the model.**
5
+
6
+ ch-local installs [countinghouse](https://github.com/mchen6/countinghouse)
7
+ packs with one command, connects them to Claude Code, Cursor, VS Code
8
+ (Copilot) and Codex in a step per client, and keeps them running; upgrades
9
+ are one command, or automatic if you turn that on.
10
+
11
+ The first pack, **CI failure triage**, answers "why did CI fail?". It reads
12
+ the failed runs and their logs from GitHub, cleans and redacts them, compares
13
+ the failure with recent runs, and hands the agent only the few lines that
14
+ explain it, whether it is new, flaky or recurring, and a receipt of what was
15
+ read. Thousands of log lines stay on your machine.
16
+ On 9 recently failed CI runs in public Python projects, Claude Code using the CI triage pack through
17
+ ch-local was fully correct at least as often as with GitHub's MCP server, the `gh` CLI or Code Mode,
18
+ at a fifth to a third of their token cost ([results](https://github.com/mchen6/ch-pack-ci-failure-triage#how-it-compares)).
19
+
20
+ ## Quick start
21
+
22
+ 1. Node 24 (22.16 or later works): see [Before you start](docs/install/README.md#before-you-start).
23
+ 2. `npx @countinghouse/ch-local@latest install --pack ci-failure-triage`
24
+ 3. When it asks, add a read-only GitHub token. It stays on your machine, and
25
+ the pack talks only to GitHub.
26
+ 4. Connect your client: [Claude Code](docs/install/claude-code.md),
27
+ [Cursor](docs/install/cursor.md), [VS Code](docs/install/vscode.md) or
28
+ [Codex](docs/install/codex.md).
29
+
30
+ Then ask your agent: *"Why did CI fail?"*
31
+
32
+ Installs on Linux, macOS and Windows.
33
+
34
+ ## What it does
35
+
36
+ `ch-local snippet <claude-code|cursor|vscode|codex|claude-desktop>` prints
37
+ the client's config entry for the installed launcher on stdout, alone, so it
38
+ can be piped. On stderr it names the Node it pinned and how to reprint the
39
+ entry after a Node upgrade. Every entry runs `<absolute node>
40
+ <home>/bin/ch-local.js session --home <home>`, where
41
+ `<home>` is `$COUNTINGHOUSE_HOME` (absolute) or `~/.countinghouse` (`%LOCALAPPDATA%\countinghouse` on Windows).
42
+ At each session start, `session` runs the shared runtime through the native
43
+ shim install placed and recorded (`<home>/shim/ch-shim`), once it passes its
44
+ ownership and mode checks; otherwise (no shim for this platform, or one set
45
+ aside because a session still used the old one) the session runs its own
46
+ runtime, as `start --stdio`. The entry never names the shim, so it stays
47
+ right whichever way that goes.
48
+ A home must be yours alone, because what runs from it is given every stored
49
+ key. On Linux and macOS it must be yours and private (`0700`, as install makes
50
+ it); on Windows its DACL must be private. `install` refuses any other home
51
+ (exit 1), and `session`, `start` and the Claude Code plugin's launcher refuse
52
+ it with exit 2. Each names the fix. For a home only too open to read (`0755`)
53
+ that is the `chmod 700` line, and on Windows, for a home others can only read,
54
+ the lines for Windows PowerShell (`powershell.exe`), one to a line, each to be
55
+ run. On Windows a home someone else could change is moved aside and installed
56
+ again, as below, and for a home Codex's sandbox opened the fix is a home under
57
+ `%LOCALAPPDATA%`. On Linux and
58
+ macOS, a home that others could write in may already have been changed, so the
59
+ fix is to move it aside and install again, never a `chmod` that would trust
60
+ what is in it. The plugin's launcher, and a ch-local run
61
+ from outside the home (npx, a checkout), check the home before running any of
62
+ its code. An entry that runs the home's own launcher (`node <home>/bin/ch-local.js
63
+ session …`, as the other clients' snippets do) runs the home's code first, and
64
+ that code makes the same check, so it protects a home only while the home is
65
+ still yours. Keep it private from the start, as install makes it.
66
+ The folders above the home are checked too, along its path and
67
+ its real path. On Linux and macOS each must be yours or root's, and writable
68
+ by no one else, except a sticky one such as `/tmp` or your own primary
69
+ group's. Otherwise another user could move the home away and put theirs in
70
+ its place. Your primary group is accepted because most Linux systems give each
71
+ user a private group of their own, and a umask of `0002` leaves the folders in
72
+ a home group-writable with no one else in that group. If your primary group
73
+ is shared with other users, keep the home under folders that group can't
74
+ write in. On Windows the folders above the home are not checked: keep it under
75
+ `%LOCALAPPDATA%`, where the default puts it, and not in a folder directly in
76
+ your profile (`%USERPROFILE%\<folder>`): Codex's Windows sandbox gives its own
77
+ identities access to most of those every time it runs a command, so a home
78
+ there would not stay private, and once it isn't it is refused. On Windows `LOCALAPPDATA` must be
79
+ set to an absolute path, or `COUNTINGHOUSE_HOME` set; otherwise ch-local
80
+ refuses rather than guess where the home is.
81
+
82
+ No entry sets or forwards a credential: a module's credential is stored
83
+ with `ch-local credentials add <module>`, bound to the one address the
84
+ module declares, and a client's environment never supplies one.
85
+ A session's own runtime starts from an allowlisted environment, never the
86
+ client's whole one: `PATH`, the home and temporary directories, the locale
87
+ and time zone, `NODE_EXTRA_CA_CERTS`, and each module's key in a slot of
88
+ its own. Networks that reach the internet only through an HTTP proxy are
89
+ not supported yet: countinghouse makes no call through a proxy, so no
90
+ proxy variable is passed.
91
+ Claude Desktop gets a note instead of an entry: its route is a `.mcpb` bundle
92
+ that keeps the token in the OS keychain, not built yet.
93
+
94
+ **The Claude Code plugin.** This repository is also the plugin's marketplace:
95
+
96
+ claude plugin marketplace add mchen6/ch-local
97
+ claude plugin install ch-packs@ch-packs
98
+
99
+ The plugin (`clients/claude-code`) runs `bin/launch.js` with `node`, which
100
+ starts the installed launcher, passes it a stop, and fetches nothing. Its skill
101
+ tells Claude to call `ci_failure_triage` first when a CI run failed.
102
+
103
+ One install page per client is in [docs/install](docs/install/README.md).
104
+
105
+ ## Commands
106
+
107
+ `ch-local` here is `node ~/.countinghouse/bin/ch-local.js` (or `npx @countinghouse/ch-local`) unless you installed it globally. On Windows, `node "%LOCALAPPDATA%\countinghouse\bin\ch-local.js"` in cmd, or `node "$env:LOCALAPPDATA\countinghouse\bin\ch-local.js"` in PowerShell.
108
+
109
+ | Command | What it does |
110
+ |---|---|
111
+ | `ch-local install --pack ci-failure-triage` | fetches each package from npm and checks it against the version, sha512 integrity and provenance this launcher pins (a tarball not on the list, a wrong hash or a missing one stops it before anything runs). It builds `<home>/app` with the runtime (this launcher and countinghouse) as an npm project with its lockfile, pinned at release so every dependency's version and integrity is fixed too, by `npm ci --omit=optional --ignore-scripts`. The pack's own packages have no npm dependencies and are unpacked beside it by a strict tar reader (files and directories only, no links, size-capped); one that declares dependencies is refused. The new app is swapped in only when complete (the old one goes back if it cannot, and the one replaced is kept in `<home>/previous` for `rollback`). Install writes `<home>/bin/ch-local.js`, `<home>/modules.json` and `<home>/shim.json`, and places each module in `<home>/module-store/<package>/<version>/` (one already there at its pin is not placed again). Every other installed pack this release lists moves to its pins; one it no longer lists stays recorded, as withdrawn. From npm, or from a folder that holds this platform's shim, it also places that shim (below). `--from <dir>` takes only a prepared development release, with `--unreleased-pins` under `CH_LOCAL_DEV=1`. |
112
+ | `ch-local install` | with no `--pack`: installs again exactly what the home's record lists, at this ch-local's own release; it never adds a pack and never changes the release |
113
+ | `ch-local add-pack <name> --from <dir>` | adds another pack this release pins beside the installed ones, checked the same way; a part another pack already uses is shared at its pinned version, and one installed at another version stops it (run `upgrade` first). No client file changes: the entry runs `start`, which loads every pack |
114
+ | `ch-local remove-pack <name>` | removes the pack and each of its parts no other installed pack uses |
115
+ | `ch-local status` | lists each installed module, its version and what it is: on with its tools (one of your own may be taken up only when the runtime restarts: it says so), a part, or why it is not loaded (and, for one of your own, that it is still on in the running runtime, when it is), with the command that fixes it, and the credential it uses; then each pack and its module count, and a running client still on another ch-local; with a shared runtime, its shim, its log and how it is (serving, restarting, gave up with why, or not running) |
116
+ | `ch-local snippet <client>` | the client's config entry, on stdout alone |
117
+ | `ch-local add <cursor\|vscode\|codex>` | writes that entry into the client's file and records it in `<home>/installed-clients.json`; run again after a Node upgrade, it rewrites its own entry. It never writes over, or claims, an entry it did not write, and keeps a file's permissions and symlink |
118
+ | `ch-local uninstall [--keep-data]` | takes back exactly the recorded entries, lists `<home>` and asks once, and removes only the names ch-local owns there. While the shared runtime still serves, it removes nothing and says so: the runtime stops 10 minutes after the last client closes; `--keep-data` keeps the store, module data, usage and caches but removes the program, the identity secret and `auth.json`; ends by naming the credentials to revoke |
119
+ | `ch-local restart` | the shared runtime takes what is stored now, as any start reads it, the ceiling's bounds applied: a changed ch-local handed over to, else drained and started again, its sessions asked to resume. A client's own restart only attaches to the shared runtime again. With no shared runtime running, it says to restart the client |
120
+ | `ch-local session [--home <abs>]` | what a client's entry runs: the shared runtime through the installed shim, or else `start --stdio` (below) |
121
+ | `ch-local start --stdio [options]` | a session's own runtime: the installed runtime over stdio, in one per-user store under `<home>/store`, the sandbox enforced (on Windows too, with a runtime that has [countinghouse#195](https://github.com/mchen6/countinghouse/issues/195); with an older one, `audit`, said, until `ch-local upgrade`), no port. It loads each installed module that is on, allowed by the operator's ceiling, at its pins and with its credential in ch-local's store (never the environment), and your own modules under `enforce`; each one it doesn't load is said, with why. Each module's credential goes in a slot of its own, for its declared address only, and start names the variable it sends, never the value. Only `--moduleSandbox enforce` or `audit` (to diagnose: under audit, countinghouse logs what a pack reads and refuses its file writes outside its own area; it does not stop a module that starts a process, a thread or native code: enforce refuses those; start says so) may be passed; every other option is refused. What one start writes is in `<home>/run/<host>-<pid>-<random>/`, removed when it ends |
122
+ | `ch-local rollback [--yes]` | returns, in one step, to the release the last install replaced, which install keeps in `<home>/previous`: the runtime, packs and parts only; caches, usage records, settings, the identity secret and client entries are untouched. Running it again returns to the newer release. A pack the older release lacks stays recorded but is not loaded, and `status` says it needs the newer release. Undoing a release marked as a security fix names it, says what it fixed and asks, and without a terminal needs `--yes`. If one pack got worse, `remove-pack` it on the current release instead |
123
+ | `ch-local credentials [list \| add <module> [--to <origin>] \| remove <module>]` | a module's key, in ch-local's store: `add` asks for it at a terminal without showing it, after saying where it will be sent (for GitHub it can offer your `gh` login); with `--to <origin>` it reads the key from stdin, and the origin must be the one the module declares. `list` shows each variable, its origin and its source, never a value; `remove` deletes one. A running shared runtime restarts to use the change |
124
+ | `ch-local settings [get \| set <name> <value> \| reset]` | ch-local's settings; `settings modules [<module>]`, `settings set <module>.<setting> [<value>]` and `settings reset <module>[.<setting>]` for each module's own. A loosening is confirmed at a terminal, and every change is written to `<home>/history.jsonl` |
125
+ | `ch-local add-module <dir>` | adds a module of your own, after showing what it declares and the modules it calls and asking at a terminal; copied into the home under its code's hash |
126
+ | `ch-local remove-module <name>` | removes one of your own modules; its data and its key are kept |
127
+ | `ch-local upgrade --check` | shows what `upgrade` would show up to its question, then the line to run in your own terminal; it asks nothing, installs nothing and needs no terminal |
128
+ | `ch-local upgrade [--auto on\|off]` | shows installed and available versions from the npm registry (ch-local's only network call besides install and the opt-in automatic check; a running module reaches its own declared server), the release's security marking and its own change notes, and asks once. A release is installed as one: every installed pack it lists moves to its pins, whichever way each module's version moves, with no version asked; it shows each module that moves (saying when one moves back), each it no longer lists, and what it adds, judged against the modules this home has installed. `--auto` stores the opt-in automatic-upgrade setting, off by default |
129
+
130
+ A module that calls a module of another pack needs that pack installed
131
+ first. `install` and `add-pack` check each module against this release's
132
+ description of it, reading only what they place and what the home already
133
+ holds, so a call into a pack not installed is refused, naming the pack to
134
+ install first; a module of a withdrawn or held pack does not count. Two
135
+ packs whose modules call each other cannot be installed in release 1 (each
136
+ needs the other first). No pack in this release calls outside itself.
137
+
138
+ ## Troubleshooting
139
+
140
+ If a request answers "Device is not responding", it ran past its time limit (`ch-local settings get` lists it as requestTimeout, in milliseconds), which a first look at a large CI run can do. Ask again, or raise the limit (up to 120 seconds), for example `ch-local settings set requestTimeout 90s`, and answer y when it asks to confirm; if your client has its own limit for a tool call, that one applies too.
141
+
142
+ ## Verify it yourself
143
+
144
+ Three facts you can check on your own machine, with your home as `<home>`:
145
+
146
+ - **The packs' only remote host is `https://api.githubcopilot.com`**, GitHub's MCP server, reached by ch-access-github. `node <home>/bin/ch-local.js credentials list` shows each stored key's origin.
147
+ - **The triage cache holds no log text**: one `fingerprints.json` per repository (`/data/<owner>__<name>/fingerprints.json` inside the pack), with run and job ids, commit SHAs, times, the algorithm that signed each entry, GitHub's conclusion word for a run with no job, and hashes (the failure's signature, the step's name and the error lines, each hashed). `find <home>/module_data -name fingerprints.json` lists them.
148
+ - **Usage is recorded on this machine**, in `<home>/store/usage`. `node <home>/app/node_modules/countinghouse/bin/countinghouse-usage.js --usageDir <home>/store/usage` prints the report outside any conversation (`--since 7d`, `--groupBy tool`, `--json` or `--csv`).
149
+
150
+ `<home>` is `$COUNTINGHOUSE_HOME` (an absolute path) or `~/.countinghouse` (`%LOCALAPPDATA%\countinghouse` on Windows). Every
151
+ command first checks Node: below 22.16 it says so and prints how to install
152
+ Node 24 yourself, for your system.
153
+
154
+ Part of the countinghouse client packs. Each package has its own repository. The family's design and plan are in
155
+ [ch-packs](https://github.com/mchen6/ch-packs) (public); the end-to-end acceptance test, which installs every package and calls the
156
+ tool, runs in this repository's CI.
157
+
158
+ ## Development
159
+
160
+ ```
161
+ npm ci
162
+ npm test
163
+ ```
164
+
165
+ Pure JavaScript, no native module. Node 22.16 or later, as countinghouse; CI
166
+ tests Node 24 on Linux, macOS and Windows, and the 22.16 floor on Linux. The one native program is the shim (below), and
167
+ it is never part of `<home>/app`: that tree is built with `npm ci
168
+ --omit=optional --ignore-scripts`, so no optional or native package enters
169
+ it.
170
+
171
+ **Unreleased installs.** Until the first release this launcher pins nothing,
172
+ so `install` and `add-pack` take `--unreleased-pins <file>`, a JSON file of
173
+ `{"pins": {<package>: {"version", "integrity"}}, "runtimeLockfile": {...}, "modules": {...}}`
174
+ written from the tarballs you built (`node scripts/describe-release.js <tarballs>
175
+ --unreleased-pins <file>` writes `modules`, each pack module's description,
176
+ checked at install as a release's are). The home is recorded as unreleased:
177
+ `status` and every `start` say so on one line, and `upgrade` refuses until a
178
+ clean install from a release. It is for development only.
179
+
180
+ **Dogfood.** `node scripts/dogfood.js` builds pack 1 from the current mains
181
+ and installs it that way, then prints the line to add it to Claude Code; see
182
+ [docs/development/dogfood.md](docs/development/dogfood.md).
183
+
184
+ **The smoke test.** `test/smoke.test.js` installs a fixture pack with no
185
+ remotes (`test/fixtures/smoke`) that way and speaks MCP to it through
186
+ `ch-local start --stdio`. It needs a countinghouse tarball
187
+ (`CH_SMOKE_RUNTIME_TGZ=<path to countinghouse-<version>.tgz>`) and is skipped
188
+ without one; CI's smoke job packs countinghouse master.
189
+
190
+ ## Publishing
191
+
192
+ Releases are published by `.github/workflows/publish.yml` under npm
193
+ trusted publishing: a `v<version>` tag on a `main` commit whose
194
+ package.json carries that version. No npm token exists anywhere and no 2FA
195
+ code is typed for a release. One-time setup on npmjs.com, by the
196
+ maintainer: the package is first published by hand, as a placeholder: in an empty
197
+ directory, a package.json holding only name, version "0.0.1-placeholder.0"
198
+ and description "Placeholder for the first release; not for use. Install a
199
+ released version.", then `npm publish --access public --tag placeholder`
200
+ (2FA). The one-time placeholder publish uses a throwaway pre-release
201
+ version (e.g. 0.0.1-placeholder.0) under a dist-tag other than latest
202
+ (e.g. `--tag placeholder`), never the release's version; deprecate it once
203
+ the real version is out. Then check `npm dist-tag ls <package>`: if
204
+ `latest` names the placeholder, `npm install <package>` installs it until
205
+ the real version is published (publishing the real version without
206
+ `--tag` moves `latest` to it), so publish the real version before the
207
+ package's name is given to anyone. Then **Settings → Trusted publishing → GitHub
208
+ Actions** with owner `mchen6`, repository `ch-local`, workflow
209
+ `publish.yml`, environment `npm-release`, allowing `npm publish` as well as
210
+ `npm stage publish`;
211
+ then **Settings → Publishing access → Require two-factor authentication
212
+ and disallow tokens**. A new trusted-publisher configuration must publish
213
+ once within two days or it expires. The publish job runs in the
214
+ repository's `npm-release` environment and waits there for the
215
+ maintainer's approval before it publishes.
216
+
217
+ ## The shim (ch-shim)
218
+
219
+ `shim/` is ch-shim, the native program each client session runs when
220
+ countinghouse's shared runtime is in use. It relays the client's stdio to the
221
+ runtime, makes the handshake, reconnects, and replays its session's
222
+ tightenings (countinghouse's
223
+ `docs/superpowers/specs/2026-11-15-shared-runtime-design.md`). It follows
224
+ contract 2 of that spec: it attaches to the daemon's runtime and proves the
225
+ secret, relays every message, reattaches and resumes after a loss, and hands
226
+ the session to a runtime of its own when the shared one asks. It is Rust,
227
+ with no async runtime and a few widely used crates. `cargo audit` and `cargo
228
+ deny` check it in CI.
229
+
230
+ ### Why Rust
231
+
232
+ Every client session runs one shim for as long as the session lasts, so its
233
+ footprint is paid once per session. Measured on Linux x64
234
+ (`shim/bench/memory.py`, which runs the shim against a runtime written from
235
+ contract 2; 2026-11-15, the main branch's release build):
236
+
237
+ | | RSS | PSS |
238
+ |---|---|---|
239
+ | ch-shim, idle | 3.1 MB | 1.1 MB |
240
+ | ch-shim, after relaying 20 answers of 1 MiB each | 3.1 MB | 1.1 MB |
241
+
242
+ - What it replaces: the per-session Node relay of the design's revision 3,
243
+ measured then at 13 MB PSS each (countinghouse's
244
+ `docs/superpowers/specs/2026-11-15-shared-runtime-design.md`). The shim
245
+ is about a twelfth of that, per session.
246
+ - The shim streams each answer through without holding it, so its memory
247
+ stays flat however large the answers are.
248
+ - The binary is 0.7 MB (693,168 bytes on that build).
249
+ - A JS launcher would also put Node back in every session's process tree,
250
+ which is why the wrapper package below has no `bin`.
251
+
252
+ - **Build and test:** `cd shim && cargo test`. The toolchain is pinned in
253
+ `shim/rust-toolchain.toml`; the conformance vectors are
254
+ `shim/tests/vectors/contract-2.json`, copied from countinghouse.
255
+ - **CI:** `.github/workflows/shim.yml` tests and builds the six targets on
256
+ their own architectures: Linux, macOS and Windows, each on x64 and arm64.
257
+ Release 1 ships unsigned. The workflow's signing job is a disabled
258
+ placeholder for macOS notarization and Windows signing, due in a later
259
+ point release.
260
+ - **Packages:** `@countinghouse/ch-shim-<os>-<arch>`, one per target, each
261
+ holding its binary, and `@countinghouse/ch-shim`, which has an exact
262
+ optionalDependency on each, so npm installs only the matching one. That
263
+ wrapper is for installing the shim with npm directly. The wrapper has no
264
+ `bin`: a JS launcher would put Node back in every session's process tree.
265
+ Its `locate()` gives the binary's path. It also says when a supported
266
+ platform's package is missing (an install with `--omit=optional`, or a
267
+ lockfile made on another platform), so that is reported, never silently
268
+ run in the per-session mode. A platform with no ch-shim at all runs the
269
+ per-session mode. The Linux builds are static (musl), so they need no
270
+ particular glibc.
271
+ - **How ch-local installs it:** not through `<home>/app`'s optional
272
+ dependencies, which `--omit=optional` drops by design. An install from
273
+ npm fetches only this platform's `@countinghouse/ch-shim-<os>-<arch>`, at
274
+ the version this launcher pins, checked by its integrity and provenance as
275
+ each pack's tarballs are, and places it at `<home>/shim/ch-shim`. A
276
+ development install with `--from` places and records the folder's shim
277
+ the same way, checked by the sha512 its pins name; a folder with no shim for this
278
+ platform leaves the shim aside. Client entries never name it:
279
+ `session` runs it. A source checkout uses `shim/target/release/ch-shim`
280
+ (cargo's build), else the platform package in its own `node_modules`
281
+ (`lib/shim-binary.js`).
282
+
283
+ ### The daemon (`ch-local daemon`)
284
+
285
+ The shim starts `ch-local daemon --home <home>` when no shared runtime is
286
+ running. The daemon holds the runtime for every session of this user.
287
+ - **Its home and environment are fixed.** `--home` must be absolute, be
288
+ the daemon's working directory, and be owned by this user with no group or
289
+ world write. Its environment is `shim.json`'s allowlist (`PATH`, `HOME`,
290
+ `LANG`, `TMPDIR`; on Windows their equivalents), never a client's.
291
+ - **Its credentials are the store's.** Each module's key, stored with
292
+ `ch-local credentials add <module>` (or the gh login it was told to use,
293
+ asked with `gh auth token` at each start), goes to the runtime in a slot
294
+ of its own, `COUNTINGHOUSE_CREDENTIAL_<n>`, for that module and its
295
+ declared address only. A key added or removed while it runs restarts its
296
+ runtime once the calls in flight finish, waiting for them at most 40
297
+ seconds (so the other sessions keep theirs: a call still running then is
298
+ cut). A
299
+ module without one isn't loaded; the runtime still starts, with
300
+ ch-local's own tools, and `countinghouse_overview` lists the module as
301
+ held back for a missing credential, with the command that adds it. No session's environment gives a credential, so no
302
+ session runs its own runtime for one.
303
+ - **Installs and rollbacks are picked up while it runs.** `ch-local install`
304
+ and `ch-local rollback` leave an upgrade request in
305
+ `<home>/run/daemon/requests`. A daemon that's running then drains its
306
+ runtime (waiting for the calls in flight, at most 40 seconds) and restarts
307
+ it on the release now in place. If ch-local itself
308
+ changed, it hands over to a new daemon. Confirmed loosenings don't survive
309
+ a hand-over (each session is told), and tightenings do.
310
+ - **Where the runtime listens.**
311
+ - On Linux and macOS it's `<home>/run/daemon/sessions.sock`. When the home's path makes that too long for a socket (over 107 bytes on Linux, 103 on macOS), it's `$TMPDIR/ch-<uid>/sessions.sock` instead, a directory made 0700 and checked, where `TMPDIR` is `shim.json`'s (the one install recorded), else the system's temporary directory.
312
+ - On Windows it's a named pipe, `\\.\pipe\countinghouse-<32 hex>`, with a new random name at each runtime start, recorded in `daemon.json`.
313
+ - The secret always stays in `<home>/run/daemon`.
314
+ - **Where the shared runtime logs.** The daemon writes its own lines and the
315
+ shared runtime's log to `<home>/run/daemon/runtime.log`, readable by this user
316
+ only; `ch-local status` names it. It's kept until it reaches about 5 MiB,
317
+ then moved to `runtime.log.1` (one older copy kept); a restart or a
318
+ hand-over to a new daemon goes on in the same file. One line is at most
319
+ 8 KiB, and the runtime's own lines start with `[runtime]`. It may hold
320
+ what your modules print or report (repository names, your CI's log text,
321
+ file paths), so keep it as private as it is made. A session on a runtime of
322
+ its own logs to its client's MCP log, as before.
323
+ - **On Windows its files are owner-only by DACL.**
324
+ - `<home>\run` and `<home>\run\daemon` get a protected DACL: this user and SYSTEM only, inherited by what's made in them.
325
+ - The daemon refuses to start, naming what's wrong, unless the home, `<home>\run` and `<home>\run\daemon` each pass the private-DACL rule the shim applies to `<home>\run\daemon`.
326
+ - `daemon.json`, `failed.json` and `runtime.log` are created with an owner-only DACL; a `runtime.log` whose DACL isn't is set aside, never written to.
327
+
328
+ ### Publishing the shim
329
+
330
+ A tag `shim-v<version>` on a `main` commit, where `<version>` is
331
+ `shim/Cargo.toml`'s, makes shim.yml publish all seven packages under npm
332
+ trusted publishing: the six platform packages first, then the wrapper. The
333
+ repository holds no token.
334
+
335
+ **One-time setup, by the maintainer, in one sitting.** npm configures a
336
+ trusted publisher only on a package that already exists, so each of the
337
+ seven names is first published by hand, as a placeholder that holds no
338
+ binaries:
339
+
340
+ 1. `npm login`, with 2FA.
341
+ 2. For each of the six `@countinghouse/ch-shim-<os>-<arch>` names, then
342
+ `@countinghouse/ch-shim`: in an empty directory, a package.json holding
343
+ only name, version "0.0.1-placeholder.0" and description "Placeholder for
344
+ the first release; not for use. Install a released version.", then
345
+ `npm publish --access public --tag placeholder` (2FA). The one-time
346
+ placeholder publish uses a throwaway pre-release version (e.g.
347
+ 0.0.1-placeholder.0) under a dist-tag other than latest (e.g. `--tag
348
+ placeholder`), never the release's version; deprecate it once the real
349
+ version is out.
350
+ 3. Then check `npm dist-tag ls <package>`: if `latest` names the
351
+ placeholder, `npm install <package>` installs it until the real version
352
+ is published (publishing the real version without `--tag` moves `latest`
353
+ to it), so publish the real version before the package's name is given
354
+ to anyone.
355
+ 4. On npmjs.com, for each of the seven packages: **Settings → Trusted
356
+ publishing → GitHub Actions**, with owner `mchen6`, repository
357
+ `ch-local`, workflow `shim.yml` and environment `npm-release`. Then
358
+ **Settings → Publishing access → Require two-factor authentication and
359
+ disallow tokens**. shim.yml's publish job waits in `npm-release` for the
360
+ maintainer's approval.
361
+ 5. Tag the next version within two days, so each new trusted-publisher
362
+ configuration publishes once before it expires.
363
+
364
+ ## License
365
+
366
+ Apache-2.0.