@rashidee/co2 1.2.5

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 (190) hide show
  1. package/dist/index.js +25449 -0
  2. package/drizzle/0000_remarkable_charles_xavier.sql +210 -0
  3. package/drizzle/0001_wise_wolf_cub.sql +13 -0
  4. package/drizzle/0002_secret_spyke.sql +16 -0
  5. package/drizzle/0003_workspace_config_singleton.sql +16 -0
  6. package/drizzle/0004_terminal_claim_v120.sql +11 -0
  7. package/drizzle/0005_brainstorm_v124.sql +10 -0
  8. package/drizzle/0006_project_v140.sql +6 -0
  9. package/drizzle/0007_prd_wizard_v124.sql +14 -0
  10. package/drizzle/0008_workflow_artifact_v126.sql +24 -0
  11. package/drizzle/0009_project_import_v150.sql +7 -0
  12. package/drizzle/0010_quality_v151.sql +3 -0
  13. package/drizzle/meta/0000_snapshot.json +1335 -0
  14. package/drizzle/meta/0001_snapshot.json +1416 -0
  15. package/drizzle/meta/0002_snapshot.json +1510 -0
  16. package/drizzle/meta/_journal.json +83 -0
  17. package/package.json +41 -0
  18. package/plugin/.claude-plugin/marketplace.json +36 -0
  19. package/plugin/.claude-plugin/plugin.json +22 -0
  20. package/plugin/README.md +625 -0
  21. package/plugin/SKILLS.md +350 -0
  22. package/plugin/co2.svg +5 -0
  23. package/plugin/commands/brainstorm-loop.md +129 -0
  24. package/plugin/skills/conductor-defect/SKILL.md +898 -0
  25. package/plugin/skills/conductor-feature-develop/SKILL.md +1383 -0
  26. package/plugin/skills/conductor-feature-develop/references/implementation-domain-template.md +131 -0
  27. package/plugin/skills/conductor-feature-develop/references/implementation-master-template.md +89 -0
  28. package/plugin/skills/conductor-feature-develop/references/playwright-setup.md +224 -0
  29. package/plugin/skills/conductor-feature-prepare/SKILL.md +604 -0
  30. package/plugin/skills/depgen-k8s/SKILL.md +468 -0
  31. package/plugin/skills/depgen-k8s/references/dockerfile-laravel.md +197 -0
  32. package/plugin/skills/depgen-k8s/references/dockerfile-nodejs.md +163 -0
  33. package/plugin/skills/depgen-k8s/references/dockerfile-spring-boot.md +174 -0
  34. package/plugin/skills/depgen-k8s/references/k8s-patterns.md +869 -0
  35. package/plugin/skills/mockgen-shadcn/SKILL.md +1067 -0
  36. package/plugin/skills/mockgen-shadcn/references/admin-layout-template.md +1467 -0
  37. package/plugin/skills/mockgen-shadcn/references/mockup-hub-template.md +498 -0
  38. package/plugin/skills/mockgen-shadcn/references/mockup-index-template.md +216 -0
  39. package/plugin/skills/mockgen-tailwind/SKILL.md +904 -0
  40. package/plugin/skills/mockgen-tailwind/references/admin-layout-template.md +720 -0
  41. package/plugin/skills/mockgen-tailwind/references/mockup-hub-template.md +498 -0
  42. package/plugin/skills/mockgen-tailwind/references/mockup-index-template.md +190 -0
  43. package/plugin/skills/modelgen-nosql/SKILL.md +617 -0
  44. package/plugin/skills/modelgen-nosql/references/model-extraction-methodology.md +497 -0
  45. package/plugin/skills/modelgen-nosql/references/nosql-design-guide.md +258 -0
  46. package/plugin/skills/modelgen-relational/SKILL.md +707 -0
  47. package/plugin/skills/modelgen-relational/references/model-extraction-methodology.md +499 -0
  48. package/plugin/skills/specgen-flutter-riverpod/SKILL.md +898 -0
  49. package/plugin/skills/specgen-flutter-riverpod/references/component-patterns.md +971 -0
  50. package/plugin/skills/specgen-flutter-riverpod/references/notification-patterns.md +457 -0
  51. package/plugin/skills/specgen-flutter-riverpod/references/routing-patterns.md +362 -0
  52. package/plugin/skills/specgen-flutter-riverpod/references/security-patterns.md +709 -0
  53. package/plugin/skills/specgen-flutter-riverpod/references/spec-template.md +1566 -0
  54. package/plugin/skills/specgen-flutter-riverpod/references/state-patterns.md +518 -0
  55. package/plugin/skills/specgen-flutter-riverpod/references/storage-patterns.md +370 -0
  56. package/plugin/skills/specgen-laravel-eloquent-bladehtmx/SKILL.md +984 -0
  57. package/plugin/skills/specgen-laravel-eloquent-bladehtmx/references/batch-patterns.md +359 -0
  58. package/plugin/skills/specgen-laravel-eloquent-bladehtmx/references/messaging-patterns.md +468 -0
  59. package/plugin/skills/specgen-laravel-eloquent-bladehtmx/references/modulith-patterns.md +461 -0
  60. package/plugin/skills/specgen-laravel-eloquent-bladehtmx/references/reporting-patterns.md +803 -0
  61. package/plugin/skills/specgen-laravel-eloquent-bladehtmx/references/security-patterns.md +501 -0
  62. package/plugin/skills/specgen-laravel-eloquent-bladehtmx/references/spec-template.md +1268 -0
  63. package/plugin/skills/specgen-laravel-eloquent-bladehtmx/references/web-patterns.md +301 -0
  64. package/plugin/skills/specgen-node-cli-web/SKILL.md +561 -0
  65. package/plugin/skills/specgen-node-cli-web/references/auth-patterns.md +293 -0
  66. package/plugin/skills/specgen-node-cli-web/references/cli-packaging-patterns.md +250 -0
  67. package/plugin/skills/specgen-node-cli-web/references/server-patterns.md +247 -0
  68. package/plugin/skills/specgen-node-cli-web/references/spec-template.md +401 -0
  69. package/plugin/skills/specgen-node-cli-web/references/testing-patterns.md +174 -0
  70. package/plugin/skills/specgen-react-mui/SKILL.md +789 -0
  71. package/plugin/skills/specgen-react-mui/references/component-patterns.md +1077 -0
  72. package/plugin/skills/specgen-react-mui/references/reporting-patterns.md +1998 -0
  73. package/plugin/skills/specgen-react-mui/references/routing-patterns.md +461 -0
  74. package/plugin/skills/specgen-react-mui/references/security-patterns.md +599 -0
  75. package/plugin/skills/specgen-react-mui/references/spec-template.md +1030 -0
  76. package/plugin/skills/specgen-react-mui/references/state-patterns.md +327 -0
  77. package/plugin/skills/specgen-react-tailwind/SKILL.md +859 -0
  78. package/plugin/skills/specgen-react-tailwind/references/component-patterns.md +1212 -0
  79. package/plugin/skills/specgen-react-tailwind/references/reporting-patterns.md +1529 -0
  80. package/plugin/skills/specgen-react-tailwind/references/routing-patterns.md +669 -0
  81. package/plugin/skills/specgen-react-tailwind/references/security-patterns.md +656 -0
  82. package/plugin/skills/specgen-react-tailwind/references/spec-template.md +1237 -0
  83. package/plugin/skills/specgen-react-tailwind/references/state-patterns.md +327 -0
  84. package/plugin/skills/specgen-sdk-java/SKILL.md +933 -0
  85. package/plugin/skills/specgen-sdk-java/references/api-extraction-patterns.md +247 -0
  86. package/plugin/skills/specgen-sdk-java/references/http-client-patterns.md +495 -0
  87. package/plugin/skills/specgen-sdk-java/references/packaging-patterns.md +366 -0
  88. package/plugin/skills/specgen-sdk-java/references/spec-template.md +956 -0
  89. package/plugin/skills/specgen-spring-jpa-jtehtmx/SKILL.md +1284 -0
  90. package/plugin/skills/specgen-spring-jpa-jtehtmx/references/batch-patterns.md +1224 -0
  91. package/plugin/skills/specgen-spring-jpa-jtehtmx/references/jasper-patterns.md +1638 -0
  92. package/plugin/skills/specgen-spring-jpa-jtehtmx/references/messaging-patterns.md +512 -0
  93. package/plugin/skills/specgen-spring-jpa-jtehtmx/references/modulith-patterns.md +354 -0
  94. package/plugin/skills/specgen-spring-jpa-jtehtmx/references/security-patterns.md +551 -0
  95. package/plugin/skills/specgen-spring-jpa-jtehtmx/references/spec-template.md +2502 -0
  96. package/plugin/skills/specgen-spring-jpa-jtehtmx/references/web-patterns.md +503 -0
  97. package/plugin/skills/specgen-spring-jpa-restapi/SKILL.md +990 -0
  98. package/plugin/skills/specgen-spring-jpa-restapi/references/batch-patterns.md +1224 -0
  99. package/plugin/skills/specgen-spring-jpa-restapi/references/messaging-patterns.md +512 -0
  100. package/plugin/skills/specgen-spring-jpa-restapi/references/modulith-patterns.md +279 -0
  101. package/plugin/skills/specgen-spring-jpa-restapi/references/reporting-patterns.md +1536 -0
  102. package/plugin/skills/specgen-spring-jpa-restapi/references/restapi-patterns.md +722 -0
  103. package/plugin/skills/specgen-spring-jpa-restapi/references/security-patterns.md +351 -0
  104. package/plugin/skills/specgen-spring-jpa-restapi/references/spec-template.md +553 -0
  105. package/plugin/skills/specgen-ts-cli/SKILL.md +861 -0
  106. package/plugin/skills/specgen-ts-cli/references/async-patterns.md +1101 -0
  107. package/plugin/skills/specgen-ts-cli/references/command-patterns.md +383 -0
  108. package/plugin/skills/specgen-ts-cli/references/config-patterns.md +430 -0
  109. package/plugin/skills/specgen-ts-cli/references/database-patterns.md +750 -0
  110. package/plugin/skills/specgen-ts-cli/references/packaging-patterns.md +426 -0
  111. package/plugin/skills/specgen-ts-cli/references/spec-template.md +1391 -0
  112. package/plugin/skills/specgen-ts-cli/references/testing-patterns.md +909 -0
  113. package/plugin/skills/testgen-functional/SKILL.md +1381 -0
  114. package/plugin/skills/tracegen-matrix/SKILL.md +243 -0
  115. package/plugin/skills/util-preparek8senv/SKILL.md +422 -0
  116. package/plugin/skills/util-projectinit/SKILL.md +307 -0
  117. package/plugin/skills/util-projectinit/reference/brainstorm-loop.md +129 -0
  118. package/plugin/skills/util-projectinit/reference/brainstorm-protocol.md +144 -0
  119. package/plugin/skills/util-projectinit/reference/brainstorm-setup-guide.md +153 -0
  120. package/plugin/skills/util-projectinit/reference/brainstorm-template-appdev.md +87 -0
  121. package/plugin/skills/util-projectinit/reference/co2-context-generation-guide.md +761 -0
  122. package/plugin/skills/util-projectsync/SKILL.md +501 -0
  123. package/plugin/skills/util-updprd/SKILL.md +324 -0
  124. package/plugin/skills/util-usanalyzer/SKILL.md +307 -0
  125. package/plugin/skills/util-ustagger/SKILL.md +154 -0
  126. package/static/assets/abnfDiagram-VRR7QNED-DvPuwyCV.js +1 -0
  127. package/static/assets/arc-DRKw7sjs.js +1 -0
  128. package/static/assets/architectureDiagram-ZJ3FMSHR-CaNcxUbC.js +36 -0
  129. package/static/assets/blockDiagram-677ZJIJ3-Demd4AOK.js +132 -0
  130. package/static/assets/c4Diagram-LMCZKHZV-PVKUfc2x.js +10 -0
  131. package/static/assets/channel-C2nVbuwv.js +1 -0
  132. package/static/assets/chunk-2Q5K7J3B-CExf8ww_.js +1 -0
  133. package/static/assets/chunk-32BRIVSS-CFPaoONF.js +1 -0
  134. package/static/assets/chunk-5VM5RSS4-DE2esM67.js +15 -0
  135. package/static/assets/chunk-EX3LRPZG-SON_YdDG.js +231 -0
  136. package/static/assets/chunk-JWPE2WC7-Qxah8LNr.js +1 -0
  137. package/static/assets/chunk-MOJQB5TN-BcWGQV3j.js +88 -0
  138. package/static/assets/chunk-RYQCIY6F-DkDj-OR5.js +1 -0
  139. package/static/assets/chunk-V7JOEXUC-BlI1Mrah.js +206 -0
  140. package/static/assets/chunk-VR4S4FIN-Agf__duj.js +1 -0
  141. package/static/assets/chunk-XXDRQBXY-B5CfAh85.js +1 -0
  142. package/static/assets/classDiagram-OUVF2IWQ-DXJIljsR.js +1 -0
  143. package/static/assets/classDiagram-v2-EOCWNBFH-DXJIljsR.js +1 -0
  144. package/static/assets/cose-bilkent-JH36ORCC-DO0cQkcy.js +1 -0
  145. package/static/assets/cynefin-VYW2F7L2-CfOnsnXc.js +178 -0
  146. package/static/assets/cynefinDiagram-TSTJHNR4-BJ8tULAv.js +62 -0
  147. package/static/assets/cytoscape.esm-DTSO7Bv0.js +331 -0
  148. package/static/assets/dagre-VKFMJZFB-DfjwzHqP.js +4 -0
  149. package/static/assets/defaultLocale-DX6XiGOO.js +1 -0
  150. package/static/assets/diagram-FQU43EPY-CndSOIIM.js +3 -0
  151. package/static/assets/diagram-G47NLZAW-Czf5hN0Z.js +24 -0
  152. package/static/assets/diagram-NH7WQ7WH-COAyojGh.js +24 -0
  153. package/static/assets/diagram-OA4YK3LP-H8PoiN2m.js +30 -0
  154. package/static/assets/diagram-WEI45ONY-DzcaVzjp.js +41 -0
  155. package/static/assets/ebnfDiagram-CCIWWBDH-DPazGYLJ.js +1 -0
  156. package/static/assets/erDiagram-Q63AITRT-Bo-fubgF.js +85 -0
  157. package/static/assets/flowDiagram-23GEKE2U-CSvxUDwh.js +156 -0
  158. package/static/assets/ganttDiagram-NO4QXBWP-DnBveWX6.js +292 -0
  159. package/static/assets/gitGraphDiagram-IHSO6WYX-B3rVL8c-.js +106 -0
  160. package/static/assets/graph-C9eacEi8.js +1 -0
  161. package/static/assets/index-LZSQkLE2.css +41 -0
  162. package/static/assets/index-y7XDSgMG.js +495 -0
  163. package/static/assets/infoDiagram-FWYZ7A6U-CvWV9yy2.js +2 -0
  164. package/static/assets/init-Gi6I4Gst.js +1 -0
  165. package/static/assets/ishikawaDiagram-FXEZZL3T-DF28a1N6.js +70 -0
  166. package/static/assets/journeyDiagram-5HDEW3XC-CB6CugYk.js +139 -0
  167. package/static/assets/kanban-definition-HUTT4EX6-ResSLF6d.js +89 -0
  168. package/static/assets/katex-C5jXJg4s.js +257 -0
  169. package/static/assets/layout-DEXfKzaS.js +1 -0
  170. package/static/assets/linear-CLO--ryk.js +1 -0
  171. package/static/assets/map-Czzmt4hB.js +1 -0
  172. package/static/assets/mindmap-definition-LN4V7U3C-BvW3EbxX.js +96 -0
  173. package/static/assets/ordinal-Cboi1Yqb.js +1 -0
  174. package/static/assets/pegDiagram-2B236MQR-BHCgqrrM.js +1 -0
  175. package/static/assets/pieDiagram-ENE6RG2P-DVmCQ5FA.js +39 -0
  176. package/static/assets/quadrantDiagram-ABIIQ3AL-B3e5KR52.js +7 -0
  177. package/static/assets/railroadDiagram-RFXS5EU6-Csv5ysLc.js +1 -0
  178. package/static/assets/requirementDiagram-TGXJPOKE-DOMVzvnB.js +84 -0
  179. package/static/assets/sankeyDiagram-HTMAVEWB-B1dcTOvy.js +40 -0
  180. package/static/assets/sequenceDiagram-DBY2YBRQ-BY414yeO.js +162 -0
  181. package/static/assets/sizeCapture-X5ZJPWSS-CuJfrfBN.js +1 -0
  182. package/static/assets/stateDiagram-2N3HPSRC-FX4rJkzV.js +1 -0
  183. package/static/assets/stateDiagram-v2-6OUMAXLB-BVufbO_H.js +1 -0
  184. package/static/assets/swimlanes-5IMT3BWC-Sfy58mmv.js +2 -0
  185. package/static/assets/swimlanesDiagram-G3AALYLV-wDCDw08H.js +8 -0
  186. package/static/assets/timeline-definition-FHXFAJF6-CmV7by8p.js +120 -0
  187. package/static/assets/vennDiagram-L72KCM5P-FqIyFZFt.js +34 -0
  188. package/static/assets/wardleyDiagram-EHGQE667-BZ06O45i.js +78 -0
  189. package/static/assets/xychartDiagram-FW5EYKEG-BOkffR06.js +7 -0
  190. package/static/index.html +24 -0
@@ -0,0 +1,426 @@
1
+ # Packaging & Distribution Patterns — tsup + @yao-pkg/pkg
2
+
3
+ This reference describes the build pipeline and cross-platform binary packaging strategy.
4
+ Include relevant content in Section 15 of the generated specification.
5
+
6
+ ---
7
+
8
+ ## Distribution Strategies Overview
9
+
10
+ ```
11
+ ┌──────────────────────────────────────────────────────────────────┐
12
+ │ Strategy A — npm distribution (default) │
13
+ │ │
14
+ │ TypeScript ──tsup──► dist/cli.js ──npm publish──► npm registry│
15
+ │ │
16
+ │ Users: npm install -g my-tool │
17
+ │ Requires: Node.js ≥ 22 on user's machine │
18
+ └──────────────────────────────────────────────────────────────────┘
19
+
20
+ ┌──────────────────────────────────────────────────────────────────┐
21
+ │ Strategy B — Standalone binary (select when Binary = yes) │
22
+ │ │
23
+ │ TypeScript ──tsup──► dist/cli.js ──pkg──► dist/bin/ │
24
+ │ │ ├── my-tool-linux │
25
+ │ │ ├── my-tool-macos │
26
+ │ │ └── my-tool.exe │
27
+ │ Upload to GitHub Releases (or Homebrew tap, Chocolatey, etc.) │
28
+ │ Users: download + chmod +x (no Node.js required) │
29
+ └──────────────────────────────────────────────────────────────────┘
30
+ ```
31
+
32
+ ---
33
+
34
+ ## tsup Build Configuration
35
+
36
+ ### tsup.config.ts
37
+
38
+ ```typescript
39
+ import { defineConfig } from 'tsup'
40
+
41
+ export default defineConfig({
42
+ entry: ['src/cli.ts'],
43
+ format: ['esm'],
44
+ target: 'node22',
45
+ platform: 'node',
46
+ outDir: 'dist',
47
+ clean: true,
48
+ sourcemap: process.env['NODE_ENV'] !== 'production',
49
+ minify: false, // pkg does its own minification; keep readable for npm
50
+ splitting: false, // single-file output is essential for pkg compatibility
51
+ bundle: true,
52
+ dts: false, // no type declarations needed for a CLI binary
53
+ shims: false, // we target Node.js natively — no CJS shims needed
54
+ banner: {
55
+ js: '#!/usr/bin/env node', // shebang injected at top of dist/cli.js
56
+ },
57
+ esbuildOptions(opts) {
58
+ opts.mainFields = ['module', 'main']
59
+ opts.conditions = ['import', 'default']
60
+ },
61
+ external: [
62
+ // These are Node.js builtins — never bundle them
63
+ 'node:fs', 'node:path', 'node:url', 'node:os', 'node:child_process',
64
+ 'node:crypto', 'node:stream', 'node:events',
65
+ ],
66
+ noExternal: [
67
+ // Force-bundle ESM-only packages that pkg cannot resolve at runtime
68
+ 'chalk', 'ora', 'boxen',
69
+ ],
70
+ })
71
+ ```
72
+
73
+ > **Splitting must be `false`** — pkg requires a single entry-point file; code splitting
74
+ > produces multiple chunks that confuse the static analyser.
75
+
76
+ ### Build Script in package.json
77
+
78
+ ```json
79
+ {
80
+ "scripts": {
81
+ "build": "tsup",
82
+ "build:prod": "NODE_ENV=production tsup",
83
+ "dev": "tsup --watch",
84
+ "typecheck": "tsc --noEmit"
85
+ }
86
+ }
87
+ ```
88
+
89
+ ### Verifying the Build
90
+
91
+ ```bash
92
+ node dist/cli.js --help # smoke test
93
+ node dist/cli.js --version # version output
94
+ ```
95
+
96
+ ---
97
+
98
+ ## pkg Configuration (Binary Packaging)
99
+
100
+ `@yao-pkg/pkg` is the actively maintained fork of `vercel/pkg`. It compiles the bundled
101
+ JS file plus a Node.js runtime into a single executable.
102
+
103
+ ### pkg field in package.json
104
+
105
+ ```json
106
+ {
107
+ "pkg": {
108
+ "scripts": "dist/cli.js",
109
+ "assets": [
110
+ "dist/**/*"
111
+ ],
112
+ "targets": [
113
+ "node22-linux-x64",
114
+ "node22-macos-x64",
115
+ "node22-macos-arm64",
116
+ "node22-win-x64"
117
+ ],
118
+ "outputPath": "dist/bin"
119
+ }
120
+ }
121
+ ```
122
+
123
+ **Target string format:** `node{version}-{os}-{arch}`
124
+ - OS: `linux`, `macos`, `win`
125
+ - Arch: `x64`, `arm64`
126
+ - Version: `22` (match the project's `engines.node`)
127
+
128
+ ### Binary Packaging Scripts
129
+
130
+ ```json
131
+ {
132
+ "scripts": {
133
+ "pkg:linux": "pkg . --target node22-linux-x64 --output dist/bin/{{BINARY_NAME}}-linux",
134
+ "pkg:macos-x64": "pkg . --target node22-macos-x64 --output dist/bin/{{BINARY_NAME}}-macos-x64",
135
+ "pkg:macos-arm64": "pkg . --target node22-macos-arm64 --output dist/bin/{{BINARY_NAME}}-macos-arm64",
136
+ "pkg:windows": "pkg . --target node22-win-x64 --output dist/bin/{{BINARY_NAME}}.exe",
137
+ "pkg:all": "npm run pkg:linux && npm run pkg:macos-x64 && npm run pkg:macos-arm64 && npm run pkg:windows",
138
+ "release": "npm run build:prod && npm run pkg:all"
139
+ }
140
+ }
141
+ ```
142
+
143
+ ### Asset Embedding
144
+
145
+ Files referenced at runtime that pkg cannot auto-detect must be declared in `assets`.
146
+ Common examples:
147
+
148
+ ```json
149
+ {
150
+ "pkg": {
151
+ "assets": [
152
+ "dist/**/*.json",
153
+ "dist/templates/**/*",
154
+ "node_modules/some-package/data/**/*"
155
+ ]
156
+ }
157
+ }
158
+ ```
159
+
160
+ ### ESM + pkg Compatibility Constraints
161
+
162
+ pkg has limited ESM support. These constraints apply when Binary Packaging = yes:
163
+
164
+ 1. **Use `tsup` to produce a single CJS file for pkg.** Even if the project is ESM,
165
+ add a separate pkg-specific tsup target:
166
+
167
+ ```typescript
168
+ // tsup.config.ts — add CJS output for pkg
169
+ export default defineConfig([
170
+ // Primary ESM build (for npm distribution)
171
+ {
172
+ entry: ['src/cli.ts'],
173
+ format: ['esm'],
174
+ outDir: 'dist',
175
+ banner: { js: '#!/usr/bin/env node' },
176
+ // ...
177
+ },
178
+ // CJS build for pkg binary packaging
179
+ {
180
+ entry: ['src/cli.ts'],
181
+ format: ['cjs'],
182
+ outDir: 'dist/cjs',
183
+ noExternal: ['chalk', 'ora', 'boxen', 'update-notifier'],
184
+ // ESM-only packages must be force-bundled
185
+ },
186
+ ])
187
+ ```
188
+
189
+ Then point pkg to the CJS output:
190
+ ```json
191
+ {
192
+ "pkg": {
193
+ "scripts": "dist/cjs/cli.cjs"
194
+ }
195
+ }
196
+ ```
197
+
198
+ 2. **Use `fileURLToPath(import.meta.url)` — never `__dirname`.** pkg understands
199
+ `import.meta.url` in ESM snapshots. For CJS bundles, tsup shims `__dirname`.
200
+
201
+ 3. **Dynamic `import()` is not statically analysed by pkg.** If you use
202
+ `import(someVariable)`, add the module to `pkg.assets` or `pkg.scripts`.
203
+
204
+ ---
205
+
206
+ ## GitHub Actions Release Workflow
207
+
208
+ This workflow triggers on `v*` tags (e.g., `v0.2.0`), builds all binaries, computes
209
+ SHA-256 checksums, and creates a GitHub Release.
210
+
211
+ ```yaml
212
+ # .github/workflows/release.yml
213
+ name: Release
214
+
215
+ on:
216
+ push:
217
+ tags:
218
+ - 'v*'
219
+
220
+ permissions:
221
+ contents: write
222
+
223
+ jobs:
224
+ build-binaries:
225
+ name: Build binaries
226
+ runs-on: ubuntu-latest
227
+ strategy:
228
+ matrix:
229
+ include:
230
+ - target: linux-x64
231
+ os: ubuntu-latest
232
+ - target: macos-x64
233
+ os: macos-latest
234
+ - target: macos-arm64
235
+ os: macos-latest
236
+ - target: windows-x64
237
+ os: windows-latest
238
+
239
+ steps:
240
+ - uses: actions/checkout@v4
241
+
242
+ - uses: actions/setup-node@v4
243
+ with:
244
+ node-version: '22'
245
+ cache: 'npm'
246
+
247
+ - run: npm ci
248
+
249
+ - name: Build
250
+ run: npm run build:prod
251
+
252
+ - name: Package binary
253
+ run: npx @yao-pkg/pkg . --target node22-${{ matrix.target }} --output dist/bin/{{BINARY_NAME}}-${{ matrix.target }}${{ matrix.target == 'windows-x64' && '.exe' || '' }}
254
+
255
+ - name: Compute checksum
256
+ run: |
257
+ BINARY="dist/bin/{{BINARY_NAME}}-${{ matrix.target }}${{ matrix.target == 'windows-x64' && '.exe' || '' }}"
258
+ sha256sum "$BINARY" > "${BINARY}.sha256"
259
+ shell: bash
260
+
261
+ - uses: actions/upload-artifact@v4
262
+ with:
263
+ name: binary-${{ matrix.target }}
264
+ path: dist/bin/
265
+
266
+ release:
267
+ name: Create GitHub Release
268
+ needs: build-binaries
269
+ runs-on: ubuntu-latest
270
+ steps:
271
+ - uses: actions/download-artifact@v4
272
+ with:
273
+ path: artifacts
274
+ merge-multiple: true
275
+
276
+ - name: Create Release
277
+ uses: softprops/action-gh-release@v2
278
+ with:
279
+ generate_release_notes: true
280
+ files: |
281
+ artifacts/**/*
282
+ ```
283
+
284
+ ---
285
+
286
+ ## npm-Only Distribution
287
+
288
+ When `Binary Packaging = no`, the CLI is published to npm. Checklist for the spec:
289
+
290
+ ### package.json fields
291
+
292
+ ```json
293
+ {
294
+ "name": "@scope/my-tool",
295
+ "version": "0.1.0",
296
+ "type": "module",
297
+ "bin": { "my-tool": "./dist/cli.js" },
298
+ "files": ["dist", "README.md"],
299
+ "engines": { "node": ">=22.0.0" },
300
+ "publishConfig": {
301
+ "access": "public"
302
+ },
303
+ "scripts": {
304
+ "prepublishOnly": "npm run typecheck && npm run test && npm run build"
305
+ }
306
+ }
307
+ ```
308
+
309
+ ### .npmignore
310
+
311
+ ```
312
+ src/
313
+ test/
314
+ *.config.ts
315
+ *.config.js
316
+ .eslintrc.*
317
+ tsconfig.json
318
+ .github/
319
+ *.test.ts
320
+ coverage/
321
+ ```
322
+
323
+ ### Local Testing Before Publish
324
+
325
+ ```bash
326
+ # Install locally from source
327
+ npm link
328
+
329
+ # Test the linked binary
330
+ my-tool --version
331
+ my-tool --help
332
+
333
+ # Unlink when done
334
+ npm unlink my-tool
335
+ ```
336
+
337
+ ### Semantic Versioning
338
+
339
+ | Change type | Version bump |
340
+ |--------------------------------------|--------------|
341
+ | Bug fix, minor improvement | Patch `0.0.x` |
342
+ | New option or command, backward-compat| Minor `0.x.0` |
343
+ | Breaking flag rename, removed option | Major `x.0.0` |
344
+
345
+ ---
346
+
347
+ ## Platform-Specific Notes
348
+
349
+ ### macOS Gatekeeper (Code Signing)
350
+
351
+ Unsigned binaries from GitHub Releases will be quarantined by macOS Gatekeeper.
352
+ Users will need to right-click → Open on first run, or run:
353
+ ```bash
354
+ xattr -c ./my-tool-macos-arm64
355
+ ```
356
+
357
+ For production tools distributed via Homebrew, add macOS ad-hoc signing to the
358
+ GitHub Actions workflow:
359
+ ```yaml
360
+ - name: Sign binary (macOS)
361
+ if: runner.os == 'macOS'
362
+ run: codesign --force --sign - dist/bin/{{BINARY_NAME}}-${{ matrix.target }}
363
+ ```
364
+
365
+ ### Windows SmartScreen
366
+
367
+ Self-signed or unsigned `.exe` files trigger Windows Defender SmartScreen. Users can
368
+ click "More info" → "Run anyway". For wide distribution, consider code signing with
369
+ a purchased certificate or distributing via Chocolatey/Scoop which handle trust.
370
+
371
+ ### Linux Permissions
372
+
373
+ The Linux binary needs `chmod +x` after download:
374
+ ```bash
375
+ chmod +x ./my-tool-linux
376
+ ./my-tool-linux --version
377
+ ```
378
+
379
+ Document this in the project README under "Installation".
380
+
381
+ ---
382
+
383
+ ## Homebrew Tap (Optional)
384
+
385
+ For macOS/Linux distribution via Homebrew:
386
+
387
+ ```ruby
388
+ # Formula/my-tool.rb
389
+ class MyTool < Formula
390
+ desc "{{APP_DESCRIPTION}}"
391
+ homepage "https://github.com/org/{{BINARY_NAME}}"
392
+ version "{{VERSION}}"
393
+
394
+ on_macos do
395
+ on_arm do
396
+ url "https://github.com/org/{{BINARY_NAME}}/releases/download/v#{version}/{{BINARY_NAME}}-macos-arm64"
397
+ sha256 "REPLACE_WITH_ACTUAL_SHA256"
398
+ end
399
+ on_intel do
400
+ url "https://github.com/org/{{BINARY_NAME}}/releases/download/v#{version}/{{BINARY_NAME}}-macos-x64"
401
+ sha256 "REPLACE_WITH_ACTUAL_SHA256"
402
+ end
403
+ end
404
+
405
+ on_linux do
406
+ on_intel do
407
+ url "https://github.com/org/{{BINARY_NAME}}/releases/download/v#{version}/{{BINARY_NAME}}-linux"
408
+ sha256 "REPLACE_WITH_ACTUAL_SHA256"
409
+ end
410
+ end
411
+
412
+ def install
413
+ bin.install Dir["{{BINARY_NAME}}-*"].first => "{{BINARY_NAME}}"
414
+ end
415
+
416
+ test do
417
+ system "#{bin}/{{BINARY_NAME}}", "--version"
418
+ end
419
+ end
420
+ ```
421
+
422
+ Host in a GitHub repo named `homebrew-tap`. Users install via:
423
+ ```bash
424
+ brew tap org/tap
425
+ brew install my-tool
426
+ ```