create-geonosis 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,74 @@
1
+ # create-geonosis
2
+
3
+ **A repo that passes its own gates on day one.**
4
+
5
+ ```bash
6
+ npm create geonosis@latest pinecone -- \
7
+ --runtime pnpm --backend medusa --ui atoms-only --brand Pinecone
8
+ ```
9
+
10
+ There is **no default** for `--runtime`, `--backend` or `--ui`. Each decides the shape of the tree,
11
+ and a default borrowed from another repo would be that repo's stack hardcoded into this one.
12
+
13
+ | Flag | Choices |
14
+ |---|---|
15
+ | `--runtime` | `pnpm` · `bun` |
16
+ | `--backend` | `medusa` · `sagaflow-cf` · `none` |
17
+ | `--ui` | `tiered-shadcn` · `atoms-only` · `none` |
18
+ | `--brand <name>` | turns on `no-brand-names` for that word |
19
+ | `--themekit <name>` | consumes a themekit **by version**, never by copying it |
20
+ | `--marketplace <path>` | install the plugin from a local marketplace instead of GitHub |
21
+ | `--kit <path>` | read the kit from a workspace instead of the registry — a proof aid |
22
+ | `--no-install` | write the files and stop |
23
+
24
+ ## What it writes
25
+
26
+ - **One catalog of shared versions** — `pnpm-workspace.yaml` on pnpm, `workspaces.catalog` on bun.
27
+ A repo whose workspaces each pin their own typescript is a repo where one of them typechecks
28
+ against a compiler the others do not run.
29
+ - **An `exports` map and no barrel** in every workspace.
30
+ - **`typecheck` + `lint` + `test` in EVERY workspace** — Midday has several without, and turbo
31
+ silently skips those. Each `test` asks vitest for its own JSON report, because a runner's exit
32
+ code is not a verdict.
33
+ - **`docs/architecture.md`, and the edges table is the one place the graph is written.**
34
+ `geonosis-ledger sync` generates turbo's `boundaries.tags` AND the linter's `layer-walls` layers
35
+ from it, so a tag added there reaches both gates and neither can drift from the other. The
36
+ scaffold runs both splices for you.
37
+ - **`CLAUDE.md` under 60 lines**, plus a `docs/pipelines/` page template.
38
+ - **The five config files**: `geonosis.json` (verify tiers, ledger, walk, testbed, doctor),
39
+ `.oxlintrc.json` with the presets the answers imply, `geonosis.ratchet.json`, `gate-baseline.json`,
40
+ `.oxfmtrc.json`.
41
+ - **`lefthook.yml`** (staged oxfmt + oxlint), **`.github/workflows/ci.yml`** with nothing switched
42
+ off in it, **`skills-lock.json`** empty, **`.claude/settings.json`** installing the kit's plugin.
43
+ - **`lint-corpus/`** — see below.
44
+
45
+ ## The baseline, and the one number that is not zero
46
+
47
+ Every counter starts at **0**: a new repo has earned no debt. `lawLineCount` starts at the measured
48
+ length of the `CLAUDE.md` that was just written, because it counts something that already exists and
49
+ a 0 there would fail the first `ratchet` run over a clean tree.
50
+
51
+ ## `lint-corpus/` — the reach corpus a shipped one cannot be
52
+
53
+ `geonosis-doctor` asks whether every enabled rule can fire at all, against the corpus the **plugin**
54
+ ships. That answers for most rules and cannot answer for three: `layer-walls` fires on a repo's own
55
+ layer names, `no-brand-names` on its own brand, `plugin-route-namespaced` on its own package root —
56
+ and the plugin's corpus says `acme` and `layers/core`. So the scaffold writes a small corpus in
57
+ **this** repo's vocabulary, with a `manifest.json` naming exactly the rules it is evidence about.
58
+
59
+ It is deliberately broken code, so it is excluded from the repo's own lint, format and typecheck —
60
+ the same treatment the plugin gives its own fixtures. The corpus run copies it to a temp root and
61
+ lints with `--no-ignore`, so nothing is hidden from the check it exists for.
62
+
63
+ ## `--kit <path>`
64
+
65
+ A proof aid. It symlinks the kit's packages into `node_modules` **after** the install and rewrites
66
+ the manifest to declare them as `link:` — which is a declaration `geonosis-doctor` accepts and can
67
+ verify. It is done by hand because neither package manager can do it: pnpm resolves `link:` happily,
68
+ and bun refuses both `link:` and `file:` here, because it follows into the target and tries to
69
+ resolve the `workspace:*` specifiers the kit's own packages use.
70
+
71
+ ## Proven, not claimed
72
+
73
+ A repo scaffolded on **both** runtimes passes its own `geonosis-verify full` in a temp directory —
74
+ see `proofs/022-W10-scaffold/`.
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ // Committed, so `pnpm install` can link the bin on a fresh clone — before `pnpm build` has
3
+ // produced dist/. A bin that only exists after a build is a bin that is missing when you need it.
4
+ import '../dist/create-geonosis-cli.js'
@@ -0,0 +1,847 @@
1
+ // src/answers.ts
2
+ import { basename, resolve } from "path";
3
+ var RUNTIMES = ["bun", "pnpm"];
4
+ var BACKENDS = ["medusa", "none", "sagaflow-cf"];
5
+ var UIS = ["atoms-only", "none", "tiered-shadcn"];
6
+ var VALUED = /* @__PURE__ */ new Set([
7
+ "--backend",
8
+ "--brand",
9
+ "--kit",
10
+ "--marketplace",
11
+ "--runtime",
12
+ "--themekit",
13
+ "--ui"
14
+ ]);
15
+ var read = (argv) => {
16
+ const flags = {};
17
+ let dir;
18
+ for (let at = 0; at < argv.length; at += 1) {
19
+ const token = argv[at] ?? "";
20
+ if (!token.startsWith("--")) {
21
+ if (dir === void 0) dir = token;
22
+ continue;
23
+ }
24
+ const equals = token.indexOf("=");
25
+ if (equals !== -1) {
26
+ flags[token.slice(0, equals)] = token.slice(equals + 1);
27
+ continue;
28
+ }
29
+ if (!VALUED.has(token)) {
30
+ flags[token] = "true";
31
+ continue;
32
+ }
33
+ const value = argv[at + 1];
34
+ if (value === void 0) throw new Error(`${token} needs a value`);
35
+ flags[token] = value;
36
+ at += 1;
37
+ }
38
+ return { ...dir === void 0 ? {} : { dir }, flags };
39
+ };
40
+ var choose = (flag, given, allowed) => {
41
+ if (given === void 0) {
42
+ throw new Error(`${flag} is required \u2014 it is one of ${allowed.join(", ")}, and never a default`);
43
+ }
44
+ if (!allowed.includes(given)) {
45
+ throw new Error(`${flag} "${given}" is not one of ${allowed.join(", ")}`);
46
+ }
47
+ return given;
48
+ };
49
+ var scopeOf = (name) => `@${name.toLowerCase().replaceAll(/[^a-z0-9-]/g, "-")}`;
50
+ var parseAnswers = (argv, cwd) => {
51
+ const { dir, flags } = read(argv);
52
+ if (dir === void 0) {
53
+ throw new Error("create-geonosis needs a directory to write the repo into");
54
+ }
55
+ const name = basename(resolve(cwd, dir));
56
+ return {
57
+ backend: choose("--backend", flags["--backend"], BACKENDS),
58
+ ...flags["--brand"] === void 0 ? {} : { brand: flags["--brand"] },
59
+ dir: resolve(cwd, dir),
60
+ ...flags["--kit"] === void 0 ? {} : { kit: resolve(cwd, flags["--kit"]) },
61
+ ...flags["--marketplace"] === void 0 ? {} : { marketplace: flags["--marketplace"] },
62
+ name,
63
+ runtime: choose("--runtime", flags["--runtime"], RUNTIMES),
64
+ scope: scopeOf(name),
65
+ ...flags["--themekit"] === void 0 ? {} : { themekit: flags["--themekit"] },
66
+ ui: choose("--ui", flags["--ui"], UIS)
67
+ };
68
+ };
69
+ var wantsInstall = (argv) => !argv.includes("--no-install");
70
+
71
+ // src/corpus.ts
72
+ var CORPUS_DIR = "lint-corpus";
73
+ var PREFIX = "biological-architecture";
74
+ var corpusFor = (answers, workspaces) => {
75
+ const files = {};
76
+ const rules = [];
77
+ const walled = workspaces.find((one) => one.mayDependOn.length === 0);
78
+ const forbidden = workspaces.find((one) => one.tag === "app");
79
+ if (walled !== void 0 && forbidden !== void 0) {
80
+ rules.push(`${PREFIX}/layer-walls`);
81
+ files[`${CORPUS_DIR}/${walled.dir}/src/bad-reaches-up.ts`] = `// BREACH: the ${walled.tag} layer may import nothing, and this reaches ${forbidden.tag}.
82
+ import { boot } from '${forbidden.name}/boot'
83
+
84
+ export const reachesUp = () => boot
85
+ `;
86
+ }
87
+ if (answers.brand !== void 0) {
88
+ rules.push(`${PREFIX}/no-brand-names`);
89
+ files[`${CORPUS_DIR}/brand/bad-brand.ts`] = `// BREACH: the brand name spelled into source, which is what the rule is configured to find.
90
+ export const FOOTER_NOTE = 'Powered by ${answers.brand}'
91
+ `;
92
+ }
93
+ if (answers.backend === "medusa") {
94
+ rules.push(`${PREFIX}/plugin-route-namespaced`);
95
+ files[`${CORPUS_DIR}/packages/medusa-plugins/example/src/api/store/route.ts`] = `// BREACH: a store route with no namespace under it, in a plugin package.
96
+ export async function GET(req: unknown, res: { json: (body: unknown) => void }) {
97
+ res.json({ ok: true, req })
98
+ }
99
+ `;
100
+ }
101
+ if (answers.backend === "sagaflow-cf") {
102
+ rules.push(`${PREFIX}/step-opens-its-own-cell`);
103
+ files[`${CORPUS_DIR}/packages/backend/src/workflows/bad-engine-step.ts`] = `// BREACH: a saga inside the configured \`within\` reaching the engine's own step.
104
+ import { step } from 'sagaflow-js'
105
+
106
+ export const issue = step('issue', async () => ({ ok: true }))
107
+ `;
108
+ }
109
+ files[`${CORPUS_DIR}/manifest.json`] = `${JSON.stringify({ plugin: PREFIX, rules }, void 0, 2)}
110
+ `;
111
+ return files;
112
+ };
113
+
114
+ // src/layout.ts
115
+ var CORE = `export type Money = { amount: number; currency: string }
116
+
117
+ export const totalOf = (lines: readonly Money[], currency: string): Money => ({
118
+ amount: lines.filter((one) => one.currency === currency).reduce((sum, one) => sum + one.amount, 0),
119
+ currency,
120
+ })
121
+ `;
122
+ var CORE_TEST = (scope) => `import { describe, expect, it } from 'vitest'
123
+
124
+ import { totalOf } from './money'
125
+
126
+ describe('totalOf', () => {
127
+ it('adds the lines that share the currency', () => {
128
+ expect(totalOf([{ amount: 2, currency: 'EUR' }, { amount: 3, currency: 'EUR' }], 'EUR')).toEqual(
129
+ { amount: 5, currency: 'EUR' },
130
+ )
131
+ })
132
+
133
+ it('ignores the ones that do not \u2014 ${scope}/core never guesses a rate', () => {
134
+ expect(totalOf([{ amount: 2, currency: 'EUR' }, { amount: 9, currency: 'USD' }], 'EUR').amount)
135
+ .toBe(2)
136
+ })
137
+ })
138
+ `;
139
+ var BUTTON = `import type { ComponentProps } from 'react'
140
+
141
+ export function Button(props: ComponentProps<'button'>) {
142
+ return <button type="button" {...props} />
143
+ }
144
+ `;
145
+ var FIELD = (scope) => `import { Button } from '${scope}/ui/atoms/button'
146
+
147
+ export function Field({ label, onSubmit }: { label: string; onSubmit: () => void }) {
148
+ return (
149
+ <label>
150
+ {label}
151
+ <Button onClick={onSubmit}>Go</Button>
152
+ </label>
153
+ )
154
+ }
155
+ `;
156
+ var UI_TEST = `import { describe, expect, it } from 'vitest'
157
+
158
+ import { Button } from './atoms/button'
159
+
160
+ describe('Button', () => {
161
+ it('is a component, so a tier above can compose it', () => {
162
+ expect(typeof Button).toBe('function')
163
+ })
164
+ })
165
+ `;
166
+ var MEDUSA_SUBSCRIBER = `export const config = {
167
+ context: { subscriberId: 'order-placed' },
168
+ event: 'order.placed',
169
+ }
170
+
171
+ export default async function orderPlaced({ data }: { data: { id: string } }): Promise<string> {
172
+ return data.id
173
+ }
174
+ `;
175
+ var SAGAFLOW_STEP = `export const step = <Input, Output>(
176
+ name: string,
177
+ body: (input: Input) => Promise<Output>,
178
+ undo: (output: Output) => Promise<void>,
179
+ ) => ({ body, name, undo })
180
+ `;
181
+ var SAGAFLOW_FLOW = `import { step } from './step'
182
+
183
+ export const reserve = step(
184
+ 'reserve',
185
+ async (input: { id: string }) => ({ held: input.id }),
186
+ async () => undefined,
187
+ )
188
+ `;
189
+ var BACKEND_TEST = `import { describe, expect, it } from 'vitest'
190
+
191
+ import { handler } from './handler'
192
+
193
+ describe('the backend seam', () => {
194
+ it('answers with what it was asked about', async () => {
195
+ expect(await handler({ id: 'ord_1' })).toBe('ord_1')
196
+ })
197
+ })
198
+ `;
199
+ var HANDLER = `export const handler = async ({ id }: { id: string }): Promise<string> => id
200
+ `;
201
+ var APP = (scope, ui) => ui ? `import { totalOf } from '${scope}/core/money'
202
+ import { Button } from '${scope}/ui/atoms/button'
203
+
204
+ export const boot = () => ({ button: Button, total: totalOf([], 'EUR') })
205
+ ` : `import { totalOf } from '${scope}/core/money'
206
+
207
+ export const boot = () => ({ total: totalOf([], 'EUR') })
208
+ `;
209
+ var APP_TEST = `import { describe, expect, it } from 'vitest'
210
+
211
+ import { boot } from './boot'
212
+
213
+ describe('boot', () => {
214
+ it('starts with an empty total rather than a guess', () => {
215
+ expect(boot().total.amount).toBe(0)
216
+ })
217
+ })
218
+ `;
219
+ var workspacesOf = (answers) => {
220
+ const { scope, ui } = answers;
221
+ const list = [
222
+ {
223
+ dir: "packages/core",
224
+ mayDependOn: [],
225
+ name: `${scope}/core`,
226
+ sources: { "src/money.ts": CORE, "src/money.test.ts": CORE_TEST(scope) },
227
+ tag: "core"
228
+ }
229
+ ];
230
+ if (ui !== "none") {
231
+ list.push({
232
+ dir: "packages/ui",
233
+ mayDependOn: ["core"],
234
+ name: `${scope}/ui`,
235
+ sources: {
236
+ "src/atoms/button.tsx": BUTTON,
237
+ "src/button.test.ts": UI_TEST,
238
+ ...ui === "tiered-shadcn" ? { "src/molecules/field.tsx": FIELD(scope) } : {}
239
+ },
240
+ tag: "ui"
241
+ });
242
+ }
243
+ if (answers.backend !== "none") {
244
+ list.push({
245
+ dir: "packages/backend",
246
+ mayDependOn: ["core"],
247
+ name: `${scope}/backend`,
248
+ sources: {
249
+ "src/handler.ts": HANDLER,
250
+ "src/handler.test.ts": BACKEND_TEST,
251
+ ...answers.backend === "medusa" ? { "src/subscribers/order-placed.ts": MEDUSA_SUBSCRIBER } : { "src/workflows/step.ts": SAGAFLOW_STEP, "src/workflows/reserve.ts": SAGAFLOW_FLOW }
252
+ },
253
+ tag: "backend"
254
+ });
255
+ }
256
+ list.push({
257
+ dir: "apps/web",
258
+ mayDependOn: list.map((one) => one.tag),
259
+ name: `${scope}/web`,
260
+ sources: { "src/boot.ts": APP(scope, ui !== "none"), "src/boot.test.ts": APP_TEST },
261
+ tag: "app"
262
+ });
263
+ return list;
264
+ };
265
+
266
+ // src/files.ts
267
+ import { countersFor, rulesFor } from "@geonosis/cli";
268
+ var VERSION = "1.0.0";
269
+ var SCHEMA = "https://raw.githubusercontent.com/oxc-project/oxc/main/npm/oxlint/configuration_schema.json";
270
+ var CATALOG = {
271
+ "@types/node": "^24.3.0",
272
+ oxfmt: "^0.62.0",
273
+ oxlint: "^1.80.0",
274
+ typescript: "^5.9.2",
275
+ vitest: "^3.2.4"
276
+ };
277
+ var REACT = { "@types/react": "^19.0.0", react: "^19.0.0" };
278
+ var json = (value) => `${JSON.stringify(value, void 0, 2)}
279
+ `;
280
+ var exec = (runtime) => runtime === "bun" ? "bunx" : "npx";
281
+ var everyWorkspace = (runtime, script) => runtime === "bun" ? `bun run --filter '*' ${script}` : `pnpm -r ${script}`;
282
+ var presetsFor = (answers) => [
283
+ "tooling",
284
+ ...answers.ui === "none" ? [] : ["frontend"],
285
+ ...answers.backend === "none" ? [] : ["tenant-scoping"],
286
+ ...answers.backend === "medusa" ? ["backend-medusa"] : [],
287
+ ...answers.backend === "sagaflow-cf" ? ["backend-sagaflow-cf"] : [],
288
+ ...answers.themekit === void 0 ? [] : ["themekit"]
289
+ ];
290
+ var tokenPrefix = (name) => `--${name.toLowerCase().replaceAll(/[^a-z]/g, "").slice(0, 3)}-`;
291
+ var answersForRules = (answers) => ({
292
+ "layer-walls": ["error", { layers: [] }],
293
+ // The scope is allowed on purpose: a repo whose brand is also its package scope would otherwise
294
+ // have every one of its own import paths reported as a brand leak, and the first thing anybody
295
+ // would do about that is turn the rule off.
296
+ ...answers.brand === void 0 ? {} : {
297
+ "no-brand-names": [
298
+ "error",
299
+ { allowedSubstrings: [`${answers.scope}/`], brands: [answers.brand] }
300
+ ]
301
+ },
302
+ ...answers.ui === "none" ? {} : {
303
+ "no-raw-html-atoms": [
304
+ "error",
305
+ [{ atom: "Button", element: "button", importPath: `${answers.scope}/ui/atoms/button` }]
306
+ ]
307
+ },
308
+ ...answers.backend === "medusa" ? {
309
+ "plugin-route-namespaced": [
310
+ "error",
311
+ {
312
+ packages: [
313
+ {
314
+ name: `${answers.scope}/{dir}`,
315
+ namespaced: true,
316
+ under: "packages/medusa-plugins"
317
+ }
318
+ ]
319
+ }
320
+ ]
321
+ } : {},
322
+ ...answers.backend === "sagaflow-cf" ? {
323
+ "step-opens-its-own-cell": [
324
+ "error",
325
+ {
326
+ engine: "sagaflow-js",
327
+ within: "packages/backend/src/workflows/",
328
+ wrapper: "packages/backend/src/workflows/step\\.ts$"
329
+ }
330
+ ]
331
+ } : {},
332
+ ...answers.themekit === void 0 ? {} : {
333
+ "font-roles-only": ["error", { roles: ["body", "display"] }],
334
+ "tokens-only-colors": ["error", { tokenPrefix: [tokenPrefix(answers.name)] }]
335
+ }
336
+ });
337
+ var exportsOf = (workspace) => Object.fromEntries(
338
+ Object.keys(workspace.sources).filter((file) => !file.includes(".test.")).toSorted().map((file) => [`./${file.replace(/^src\//, "").replace(/\.tsx?$/, "")}`, `./${file}`])
339
+ );
340
+ var workspaceManifest = (workspace, answers, workspaces) => {
341
+ const react = workspace.dir === "packages/ui";
342
+ return json({
343
+ name: workspace.name,
344
+ version: "0.0.0",
345
+ private: true,
346
+ type: "module",
347
+ exports: exportsOf(workspace),
348
+ scripts: {
349
+ lint: "oxlint --config ../../.oxlintrc.json .",
350
+ // The runner is asked for its own report, never trusted for a status code.
351
+ test: "vitest run --reporter=default --reporter=json --outputFile=.geonosis/vitest.json",
352
+ typecheck: "tsc --noEmit"
353
+ },
354
+ devDependencies: {
355
+ "@types/node": "catalog:",
356
+ ...react ? { "@types/react": "catalog:", react: "catalog:" } : {},
357
+ oxlint: "catalog:",
358
+ typescript: "catalog:",
359
+ vitest: "catalog:"
360
+ },
361
+ dependencies: Object.fromEntries(
362
+ workspace.mayDependOn.flatMap((tag) => {
363
+ const found = workspaces.find((one) => one.tag === tag);
364
+ return found === void 0 || found.name === workspace.name ? [] : [[found.name, "workspace:*"]];
365
+ })
366
+ )
367
+ });
368
+ };
369
+ var kitDependencies = (answers) => ({
370
+ "@geonosis/cli": `^${VERSION}`,
371
+ "@geonosis/doctor": `^${VERSION}`,
372
+ "@geonosis/ledger": `^${VERSION}`,
373
+ "@geonosis/oxlint-plugin-biological-architecture": `^${VERSION}`,
374
+ "@geonosis/ratchet": `^${VERSION}`,
375
+ "@geonosis/verify": `^${VERSION}`,
376
+ ...answers.themekit === void 0 ? {} : { "@geonosis/themekit": `^${VERSION}` }
377
+ });
378
+ var rootManifest = (answers) => {
379
+ const { runtime } = answers;
380
+ const globs = ["apps/*", "packages/*"];
381
+ return json({
382
+ name: answers.name,
383
+ version: "0.0.0",
384
+ private: true,
385
+ type: "module",
386
+ ...runtime === "bun" ? {
387
+ workspaces: {
388
+ catalog: { ...CATALOG, ...answers.ui === "none" ? {} : REACT },
389
+ packages: globs
390
+ }
391
+ } : {},
392
+ scripts: {
393
+ doctor: "geonosis-doctor",
394
+ "format:check": "oxfmt --config .oxfmtrc.json --check .",
395
+ format: "oxfmt --config .oxfmtrc.json .",
396
+ lint: "oxlint --config .oxlintrc.json .",
397
+ ratchet: "geonosis-ratchet",
398
+ sync: "geonosis sync",
399
+ test: everyWorkspace(runtime, "test"),
400
+ typecheck: everyWorkspace(runtime, "typecheck"),
401
+ verify: "geonosis-verify"
402
+ },
403
+ devDependencies: {
404
+ // With --kit the kit is linked from a workspace AFTER the install, and the manifest is
405
+ // rewritten to say so. Declaring published versions here would make the install go looking
406
+ // for them first, which is the one thing --kit exists to avoid.
407
+ ...answers.kit === void 0 ? kitDependencies(answers) : {},
408
+ "@types/node": "catalog:",
409
+ ...answers.ui === "none" ? {} : { "@types/react": "catalog:", react: "catalog:" },
410
+ lefthook: "^2.1.0",
411
+ oxfmt: "catalog:",
412
+ oxlint: "catalog:",
413
+ turbo: "^2.10.0",
414
+ typescript: "catalog:",
415
+ vitest: "catalog:"
416
+ }
417
+ });
418
+ };
419
+ var workspaceYaml = (answers) => [
420
+ "packages:",
421
+ " - apps/*",
422
+ " - packages/*",
423
+ "",
424
+ "# One version of a shared dependency, named once. A repo whose workspaces each pin their own",
425
+ "# typescript is a repo where one of them typechecks against a compiler the others do not run.",
426
+ "catalog:",
427
+ ...Object.entries({ ...CATALOG, ...answers.ui === "none" ? {} : REACT }).toSorted(([a], [b]) => a.localeCompare(b)).map(([name, spec]) => ` '${name}': '${spec}'`),
428
+ "",
429
+ "# pnpm 11 runs no dependency's install script unless it is named here. esbuild fetches its",
430
+ "# platform binary in one, and without it vitest cannot start \u2014 a test suite that cannot run",
431
+ "# reports nothing, which is the shape of green this kit exists to refuse.",
432
+ "allowBuilds:",
433
+ " esbuild: true",
434
+ " lefthook: true",
435
+ ""
436
+ ].join("\n");
437
+ var architecture = (answers, workspaces) => [
438
+ `# ${answers.name} \u2014 target architecture`,
439
+ "",
440
+ "The edges table is the ONE place this graph is written down. `geonosis sync --target turbo`",
441
+ "generates turbo's `boundaries.tags` from it, and `--target layer-walls` generates the linter's",
442
+ "layers from it, so a tag added here reaches both gates and neither can drift from the other.",
443
+ "",
444
+ "| tag | packages | may depend on |",
445
+ "| --- | --- | --- |",
446
+ ...workspaces.map(
447
+ (one) => `| ${one.tag} | ${one.name} | ${one.mayDependOn.join(", ") || "\u2014"} |`
448
+ ),
449
+ "",
450
+ ...answers.backend === "medusa" ? [
451
+ "Medusa plugins go under `packages/medusa-plugins/<name>`; the `plugin-route-namespaced`",
452
+ "rule is configured for that root, so a store route without a namespace is refused.",
453
+ ""
454
+ ] : []
455
+ ].join("\n");
456
+ var pipeline = (answers) => [
457
+ "# Pipeline: order placed",
458
+ "",
459
+ "One page per pipeline, and this is the template. Say what enters, what each hop does to it, and",
460
+ "what leaves \u2014 then keep the diagram beside the code that implements it.",
461
+ "",
462
+ "```mermaid",
463
+ "graph LR",
464
+ ` IN[request] --> APP[${answers.scope}/web]`,
465
+ ` APP --> CORE[${answers.scope}/core]`,
466
+ ...answers.backend === "none" ? [] : [` APP --> BACK[${answers.scope}/backend]`],
467
+ " CORE --> OUT[response]",
468
+ "```",
469
+ "",
470
+ "| Hop | Owns | Fails how |",
471
+ "| --- | --- | --- |",
472
+ "| entry | shape of the request | refuses, never guesses |",
473
+ "| core | the calculation | pure, so it is tested without a server |",
474
+ "| exit | the response | one shape, named |",
475
+ ""
476
+ ].join("\n");
477
+ var law = (answers) => [
478
+ `# ${answers.name} \u2014 repo doctrine`,
479
+ "",
480
+ `A ${answers.runtime} monorepo on the geonosis kit. \`docs/architecture.md\` is the graph;`,
481
+ "`docs/pipelines/` is one page per flow. Depth belongs in skills and in the rules, never here.",
482
+ "",
483
+ "## The laws",
484
+ "",
485
+ "**1. RED \u2192 GREEN.** Every new rule, constraint or invariant begins with a failing test. Write",
486
+ "it, watch it fail, then write the code that makes it pass. A test written afterwards validates",
487
+ "what was built, not what was intended.",
488
+ "",
489
+ "**2. Never downgrade a rule.** Setting one to `warn` or `off`, narrowing its globs, adding a",
490
+ "file to `ignorePatterns` or silencing it with a disable comment \u2014 all forbidden without asking.",
491
+ "A gate breaking because real code violates a real invariant is enforcement working.",
492
+ "",
493
+ "**3. No suppression.** No `@ts-ignore`, no `@ts-expect-error`. Fix the type, or ask.",
494
+ "",
495
+ "**4. oxfmt only.** `pnpm format` writes, `pnpm format:check` verifies. Never prettier: it is",
496
+ "not a dependency here, so it downloads itself and reformats with its own defaults.",
497
+ "",
498
+ "**5. Nothing is hardcoded to a repo.** Every list a rule needs is an option.",
499
+ "",
500
+ "**6. Test what the code does, not how.** Never assert on class names or DOM structure.",
501
+ "",
502
+ "## The gates",
503
+ "",
504
+ "```bash",
505
+ "geonosis verify full # typecheck \u2192 lint \u2192 test \u2192 format \u2192 ratchet",
506
+ "geonosis doctor # loaded, exercised, baseline, runner, drift",
507
+ "```",
508
+ "",
509
+ "`gate-baseline.json` holds one number per counter, and a number may only shrink. A counter that",
510
+ "grew fails; one that shrank rewrites the baseline down in the commit that earned it.",
511
+ "",
512
+ "## The method",
513
+ "",
514
+ "The `geonosis` Claude Code plugin carries the hooks, agents and skills:",
515
+ "",
516
+ "```bash",
517
+ `claude plugin marketplace add ${answers.marketplace ?? "microcompanies/geonosis"}`,
518
+ "claude plugin install geonosis@geonosis",
519
+ "```",
520
+ "",
521
+ "`AGENTS.md` and `.cursor/rules/` are GENERATED from this file by `geonosis sync` \u2014 edit this",
522
+ "one. `lint-corpus/` is fixture code that must stay broken: it is how the doctor proves the rules",
523
+ "configured for this repo can fire at all.",
524
+ ""
525
+ ].join("\n");
526
+ var ci = (answers) => [
527
+ "name: verify",
528
+ "",
529
+ "on:",
530
+ " push:",
531
+ " branches: [main]",
532
+ " pull_request:",
533
+ "",
534
+ "jobs:",
535
+ " verify:",
536
+ " runs-on: ubuntu-latest",
537
+ " steps:",
538
+ " - uses: actions/checkout@v4",
539
+ ...answers.runtime === "bun" ? [" - uses: oven-sh/setup-bun@v2", " - run: bun install --frozen-lockfile"] : [
540
+ " - uses: pnpm/action-setup@v4",
541
+ " - uses: actions/setup-node@v4",
542
+ " with:",
543
+ " node-version: '24'",
544
+ " cache: 'pnpm'",
545
+ " - run: pnpm install --frozen-lockfile"
546
+ ],
547
+ ` - run: ${exec(answers.runtime)} geonosis-verify full`,
548
+ ` - run: ${exec(answers.runtime)} geonosis-doctor`,
549
+ "",
550
+ "# When @geonosis/testbed is installed, add its matrix here: one job per adapter the repo",
551
+ "# declares in geonosis.json \u2192 testbed.adapters. A job switched off in a condition is a job",
552
+ "# that lies, so the disabledCiJobs counter counts them and the ratchet holds the number at 0.",
553
+ ""
554
+ ].join("\n");
555
+ var settings = (answers) => json({
556
+ extraKnownMarketplaces: {
557
+ geonosis: answers.marketplace === void 0 ? { source: { repo: "microcompanies/geonosis", source: "github" } } : { source: { path: answers.marketplace, source: "directory" } }
558
+ },
559
+ enabledPlugins: { "geonosis@geonosis": true }
560
+ });
561
+ var tsconfigBase = (answers) => json({
562
+ compilerOptions: {
563
+ target: "ES2023",
564
+ lib: ["ES2023", ...answers.ui === "none" ? [] : ["DOM"]],
565
+ module: "ESNext",
566
+ moduleResolution: "bundler",
567
+ moduleDetection: "force",
568
+ ...answers.ui === "none" ? {} : { jsx: "react-jsx" },
569
+ types: ["node"],
570
+ strict: true,
571
+ noUncheckedIndexedAccess: true,
572
+ noImplicitOverride: true,
573
+ noFallthroughCasesInSwitch: true,
574
+ verbatimModuleSyntax: true,
575
+ isolatedModules: true,
576
+ skipLibCheck: true,
577
+ esModuleInterop: true,
578
+ resolveJsonModule: true,
579
+ noEmit: true
580
+ }
581
+ });
582
+ var filesFor = (answers) => {
583
+ const workspaces = workspacesOf(answers);
584
+ const counters = countersFor(answers.runtime);
585
+ const { rules } = rulesFor(presetsFor(answers), answersForRules(answers));
586
+ const files = {
587
+ "package.json": rootManifest(answers),
588
+ ...answers.runtime === "pnpm" ? { "pnpm-workspace.yaml": workspaceYaml(answers) } : {},
589
+ "CLAUDE.md": law(answers),
590
+ "docs/architecture.md": architecture(answers, workspaces),
591
+ "docs/pipelines/order-placed.md": pipeline(answers),
592
+ ".github/workflows/ci.yml": ci(answers),
593
+ ".claude/settings.json": settings(answers),
594
+ ".gitignore": ["node_modules/", "dist/", ".turbo/", ".geonosis/", "coverage/", ""].join("\n"),
595
+ ".oxfmtrc.json": json({
596
+ printWidth: 100,
597
+ singleQuote: true,
598
+ semi: false,
599
+ trailingComma: "all",
600
+ arrowParens: "always",
601
+ endOfLine: "lf",
602
+ tabWidth: 2,
603
+ quoteProps: "as-needed",
604
+ sortImports: true,
605
+ sortPackageJson: true,
606
+ ignorePatterns: [
607
+ "node_modules",
608
+ "dist",
609
+ ".turbo",
610
+ "coverage",
611
+ "**/*.md",
612
+ "**/*.json",
613
+ CORPUS_DIR
614
+ ]
615
+ }),
616
+ ".oxlintrc.json": json({
617
+ $schema: SCHEMA,
618
+ plugins: ["typescript", "unicorn"],
619
+ jsPlugins: ["@geonosis/oxlint-plugin-biological-architecture"],
620
+ categories: { correctness: "error", suspicious: "error" },
621
+ rules,
622
+ ignorePatterns: ["node_modules", "dist", "coverage", CORPUS_DIR]
623
+ }),
624
+ "geonosis.json": json({
625
+ verify: {
626
+ fast: ["pnpm typecheck", "pnpm lint", "pnpm test"].map(
627
+ (one) => answers.runtime === "bun" ? one.replace("pnpm ", "bun run ") : one
628
+ ),
629
+ full: [
630
+ "fast",
631
+ answers.runtime === "bun" ? "bun run format:check" : "pnpm format:check",
632
+ answers.runtime === "bun" ? "bun run ratchet" : "pnpm ratchet"
633
+ ]
634
+ },
635
+ doctor: { corpus: CORPUS_DIR },
636
+ ledger: {
637
+ architecture: "docs/architecture.md",
638
+ plans: "plans",
639
+ progress: "plans/PROGRESS.md",
640
+ proofs: "proofs"
641
+ },
642
+ walk: { probes: [], urls: [] },
643
+ testbed: {
644
+ adapters: answers.backend === "medusa" ? ["medusa-built"] : answers.backend === "sagaflow-cf" ? ["workerd"] : []
645
+ }
646
+ }),
647
+ "geonosis.ratchet.json": json({ baseline: "gate-baseline.json", counters }),
648
+ "gate-baseline.json": json(
649
+ Object.fromEntries(
650
+ counters.map((one) => [
651
+ typeof one.key === "string" ? one.key : String(one.counter),
652
+ // Zero is the floor for debt this repo has not earned. It is the wrong number for a
653
+ // counter that measures something already written: the law has its length the moment it
654
+ // lands, and a baseline of 0 would fail the first ratchet run over a clean tree.
655
+ one.counter === "lawLineCount" ? law(answers).split("\n").length - 1 : 0
656
+ ])
657
+ )
658
+ ),
659
+ "skills-lock.json": json({ skills: {}, version: 1 }),
660
+ "lefthook.yml": [
661
+ "# Staged scope only, so a commit never waits on a file it did not touch. When one fires, fix",
662
+ "# or delete the code \u2014 never downgrade the rule to get past it.",
663
+ "pre-commit:",
664
+ " parallel: true",
665
+ " commands:",
666
+ " fmt:",
667
+ " glob: '*.{ts,tsx,js,json}'",
668
+ ` run: ${exec(answers.runtime)} oxfmt --config .oxfmtrc.json --check {staged_files}`,
669
+ " lint:",
670
+ " glob: '*.{ts,tsx}'",
671
+ ` run: ${exec(answers.runtime)} oxlint --config .oxlintrc.json {staged_files}`,
672
+ ""
673
+ ].join("\n"),
674
+ "turbo.json": json({
675
+ $schema: "https://turborepo.dev/schema.json",
676
+ boundaries: { tags: {} },
677
+ tasks: {
678
+ build: { dependsOn: ["^build"] },
679
+ lint: {},
680
+ test: { dependsOn: ["^build"] },
681
+ typecheck: { dependsOn: ["^typecheck"] }
682
+ }
683
+ }),
684
+ "tsconfig.base.json": tsconfigBase(answers),
685
+ "tsconfig.json": json({
686
+ extends: "./tsconfig.base.json",
687
+ include: [
688
+ "apps/*/src/**/*.ts",
689
+ "apps/*/src/**/*.tsx",
690
+ "packages/*/src/**/*.ts",
691
+ "packages/*/src/**/*.tsx"
692
+ ],
693
+ exclude: ["**/dist/**", "**/node_modules/**", `${CORPUS_DIR}/**`]
694
+ }),
695
+ ...corpusFor(answers, workspaces)
696
+ };
697
+ for (const workspace of workspaces) {
698
+ files[`${workspace.dir}/package.json`] = workspaceManifest(workspace, answers, workspaces);
699
+ files[`${workspace.dir}/tsconfig.json`] = json({
700
+ extends: "../../tsconfig.base.json",
701
+ include: ["src"]
702
+ });
703
+ for (const [file, body] of Object.entries(workspace.sources)) {
704
+ files[`${workspace.dir}/${file}`] = body;
705
+ }
706
+ }
707
+ return files;
708
+ };
709
+ var presetsChosenBy = presetsFor;
710
+
711
+ // src/scaffold.ts
712
+ import { spawnSync } from "child_process";
713
+ import { chmodSync, existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from "fs";
714
+ import { dirname, join } from "path";
715
+ var KIT_PACKAGES = [
716
+ "cli",
717
+ "doctor",
718
+ "ledger",
719
+ "lint-parity",
720
+ "oxlint-plugin-biological-architecture",
721
+ "ratchet",
722
+ "themekit",
723
+ "verify"
724
+ ];
725
+ var write = (dir, file, body) => {
726
+ const path = join(dir, file);
727
+ mkdirSync(dirname(path), { recursive: true });
728
+ writeFileSync(path, body);
729
+ };
730
+ var writeScaffold = (answers) => {
731
+ if (existsSync(answers.dir) && readdirSync(answers.dir).length > 0) {
732
+ throw new Error(`${answers.dir} is not empty \u2014 nothing was written`);
733
+ }
734
+ const files = filesFor(answers);
735
+ mkdirSync(answers.dir, { recursive: true });
736
+ for (const [file, body] of Object.entries(files)) write(answers.dir, file, body);
737
+ return Object.keys(files).toSorted();
738
+ };
739
+ var run = (what, dir, command, args) => {
740
+ const done = spawnSync(command, args, { cwd: dir, encoding: "utf8", maxBuffer: 32 * 1024 * 1024 });
741
+ return {
742
+ code: done.error === void 0 ? done.status ?? 2 : 2,
743
+ output: `${done.stdout ?? ""}${done.stderr ?? ""}${done.error === void 0 ? "" : done.error.message}`,
744
+ what
745
+ };
746
+ };
747
+ var binsOf = (dir) => {
748
+ const manifest = JSON.parse(readFileSync(join(dir, "package.json"), "utf8"));
749
+ if (typeof manifest.bin === "string") return [[manifest.name ?? "", manifest.bin]];
750
+ return Object.entries(manifest.bin ?? {});
751
+ };
752
+ var linkKit = (answers, kit) => {
753
+ const modules = join(answers.dir, "node_modules");
754
+ const scope = join(modules, "@geonosis");
755
+ const bin = join(modules, ".bin");
756
+ mkdirSync(scope, { recursive: true });
757
+ mkdirSync(bin, { recursive: true });
758
+ const linked = [];
759
+ const manifestPath = join(answers.dir, "package.json");
760
+ const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
761
+ for (const name of KIT_PACKAGES) {
762
+ const from = join(kit, "packages", name);
763
+ if (!existsSync(from)) continue;
764
+ const at = join(scope, name);
765
+ if (!existsSync(at)) {
766
+ spawnSync("ln", ["-s", from, at]);
767
+ }
768
+ for (const [called, relative] of binsOf(from)) {
769
+ const shim = join(bin, called);
770
+ writeFileSync(shim, `#!/bin/sh
771
+ exec node "${join(from, relative)}" "$@"
772
+ `);
773
+ chmodSync(shim, 493);
774
+ }
775
+ const declared = JSON.parse(readFileSync(join(from, "package.json"), "utf8"));
776
+ if (declared.name !== void 0) {
777
+ manifest.devDependencies = { ...manifest.devDependencies, [declared.name]: `link:${from}` };
778
+ }
779
+ linked.push(name);
780
+ }
781
+ writeFileSync(manifestPath, `${JSON.stringify(manifest, void 0, 2)}
782
+ `);
783
+ return linked;
784
+ };
785
+ var installer = (answers) => answers.runtime === "bun" ? ["bun", ["install"]] : ["pnpm", ["install"]];
786
+ var finish = ({ answers, install }) => {
787
+ const steps = [];
788
+ if (install) {
789
+ const [command, args] = installer(answers);
790
+ const offline = answers.runtime === "pnpm" ? [...args, "--offline"] : args;
791
+ const first = run(`${command} install (offline)`, answers.dir, command, offline);
792
+ steps.push(first);
793
+ if (first.code !== 0) {
794
+ steps.push(run(`${command} install (network)`, answers.dir, command, args));
795
+ }
796
+ }
797
+ if (answers.kit !== void 0) {
798
+ const linked = linkKit(answers, answers.kit);
799
+ steps.push({
800
+ code: 0,
801
+ output: `${linked.join(", ")}
802
+ `,
803
+ what: `link the kit from ${answers.kit}`
804
+ });
805
+ }
806
+ const ledger = join(answers.dir, "node_modules/.bin/geonosis-ledger");
807
+ if (existsSync(ledger)) {
808
+ steps.push(
809
+ run("sync the edges table into turbo.json", answers.dir, ledger, [
810
+ "sync",
811
+ "--target",
812
+ "turbo",
813
+ "--write",
814
+ "turbo.json"
815
+ ]),
816
+ run("sync the edges table into .oxlintrc.json", answers.dir, ledger, [
817
+ "sync",
818
+ "--target",
819
+ "layer-walls",
820
+ "--write",
821
+ ".oxlintrc.json"
822
+ ])
823
+ );
824
+ }
825
+ const oxfmt = join(answers.dir, "node_modules/.bin/oxfmt");
826
+ if (existsSync(oxfmt)) {
827
+ steps.push(run("format", answers.dir, oxfmt, ["--config", ".oxfmtrc.json", "."]));
828
+ }
829
+ return steps;
830
+ };
831
+
832
+ export {
833
+ RUNTIMES,
834
+ BACKENDS,
835
+ UIS,
836
+ parseAnswers,
837
+ wantsInstall,
838
+ CORPUS_DIR,
839
+ corpusFor,
840
+ workspacesOf,
841
+ filesFor,
842
+ presetsChosenBy,
843
+ KIT_PACKAGES,
844
+ writeScaffold,
845
+ linkKit,
846
+ finish
847
+ };
@@ -0,0 +1,66 @@
1
+ import {
2
+ finish,
3
+ parseAnswers,
4
+ wantsInstall,
5
+ writeScaffold
6
+ } from "./chunk-UWL7ARNA.js";
7
+
8
+ // src/create-geonosis-cli.ts
9
+ var USAGE = `create-geonosis <dir> --runtime pnpm|bun --backend medusa|sagaflow-cf|none --ui tiered-shadcn|atoms-only|none
10
+ [--brand <name>] [--themekit <name>] [--marketplace <path>] [--kit <path>] [--no-install]
11
+
12
+ Writes a repo that passes its own gates on day one: a workspace with one catalog of shared versions,
13
+ an exports map and no barrel in every package, typecheck + lint + test scripts in every workspace,
14
+ an edges table that GENERATES turbo's boundaries and the linter's layers, a law under sixty lines,
15
+ the four geonosis config files, a lefthook, a CI workflow with nothing switched off in it, an empty
16
+ skills lock, and a reach corpus in this repo's own vocabulary so the doctor can prove its rules fire.
17
+
18
+ There is no default for --runtime, --backend or --ui. Each one decides the shape of the tree, and a
19
+ default borrowed from another repo would be that repo's stack hardcoded into this one.
20
+
21
+ --kit <path> read the kit from a workspace instead of the registry. A proof aid: it symlinks the
22
+ packages after the install and rewrites the manifest to say so.
23
+ --no-install write the files and stop. The gates cannot run until the two "geonosis sync
24
+ --target" commands below have been run, and they are printed for you.
25
+
26
+ Exit: 0 written \xB7 1 refused (a directory with something in it, an answer that is not one) \xB7 2 a run
27
+ that could not be made at all.`;
28
+ var main = () => {
29
+ const argv = process.argv.slice(2);
30
+ if (argv.length === 0 || argv.includes("--help") || argv.includes("-h")) {
31
+ process.stdout.write(`${USAGE}
32
+ `);
33
+ return argv.length === 0 ? 2 : 0;
34
+ }
35
+ const answers = parseAnswers(argv, process.cwd());
36
+ const written = writeScaffold(answers);
37
+ process.stdout.write(`create-geonosis \u2014 ${written.length} file(s) into ${answers.dir}
38
+ `);
39
+ const install = wantsInstall(argv);
40
+ for (const step of finish({ answers, install })) {
41
+ process.stdout.write(` ${step.code === 0 ? "ok " : "FAIL"} ${step.what}
42
+ `);
43
+ if (step.code !== 0) process.stdout.write(`${step.output}
44
+ `);
45
+ }
46
+ if (!install) {
47
+ process.stdout.write(
48
+ [
49
+ "",
50
+ " Nothing was installed, so the edges table has not reached the gates yet. Run:",
51
+ ` cd ${answers.dir} && ${answers.runtime} install`,
52
+ " geonosis sync --target turbo --into turbo.json",
53
+ " geonosis sync --target layer-walls --into .oxlintrc.json",
54
+ ""
55
+ ].join("\n")
56
+ );
57
+ }
58
+ return 0;
59
+ };
60
+ try {
61
+ process.exit(main());
62
+ } catch (error) {
63
+ process.stderr.write(`create-geonosis: ${error.message}
64
+ `);
65
+ process.exit(1);
66
+ }
@@ -0,0 +1,93 @@
1
+ declare const RUNTIMES: readonly ["bun", "pnpm"];
2
+ declare const BACKENDS: readonly ["medusa", "none", "sagaflow-cf"];
3
+ declare const UIS: readonly ["atoms-only", "none", "tiered-shadcn"];
4
+ type Runtime = (typeof RUNTIMES)[number];
5
+ type Backend = (typeof BACKENDS)[number];
6
+ type Ui = (typeof UIS)[number];
7
+ type Answers = {
8
+ backend: Backend;
9
+ brand?: string;
10
+ dir: string;
11
+ /** The kit read from a workspace instead of the registry — a proof aid, never the default. */
12
+ kit?: string;
13
+ marketplace?: string;
14
+ name: string;
15
+ runtime: Runtime;
16
+ scope: string;
17
+ themekit?: string;
18
+ ui: Ui;
19
+ };
20
+ declare const parseAnswers: (argv: readonly string[], cwd: string) => Answers;
21
+ declare const wantsInstall: (argv: readonly string[]) => boolean;
22
+
23
+ type Workspace = {
24
+ dir: string;
25
+ /** The files under this workspace, keyed by path relative to the workspace. */
26
+ sources: Record<string, string>;
27
+ name: string;
28
+ tag: string;
29
+ mayDependOn: string[];
30
+ };
31
+ /**
32
+ * The workspaces the answers imply, and the edge each one is allowed. Two at minimum — a pure-logic
33
+ * package and the app that composes it — because a wall needs something on the other side of it: a
34
+ * repo with one tag has no edge to violate, and a `layer-walls` that cannot fire is the inert rule
35
+ * this kit exists to catch.
36
+ */
37
+ declare const workspacesOf: (answers: Answers) => Workspace[];
38
+
39
+ declare const CORPUS_DIR = "lint-corpus";
40
+ /**
41
+ * A reach corpus a shipped one cannot be.
42
+ *
43
+ * `geonosis-doctor` asks whether every enabled rule can fire at all, and it asks the corpus the
44
+ * PLUGIN ships. That answers for most rules and cannot answer for three: `layer-walls` fires on a
45
+ * repo's own layer names, `no-brand-names` on its own brand, `plugin-route-namespaced` on its own
46
+ * package root. The plugin's corpus says "acme" and `layers/core`, so it is no evidence either way
47
+ * about a repo that says anything else — and today those rules read as firing nowhere.
48
+ *
49
+ * So the repo ships its own, in ITS vocabulary. The corpus is copied to a temp root and linted with
50
+ * `--no-ignore`, so the fixture paths mirror the repo's real ones and the layer patterns match.
51
+ */
52
+ declare const corpusFor: (answers: Answers, workspaces: Workspace[]) => Record<string, string>;
53
+
54
+ declare const filesFor: (answers: Answers) => Record<string, string>;
55
+ declare const presetsChosenBy: (answers: Answers) => string[];
56
+
57
+ /** The kit packages a scaffolded repo declares, and therefore the ones `--kit` has to link. */
58
+ declare const KIT_PACKAGES: string[];
59
+ /**
60
+ * Every file, and never over the top of anything. A scaffold that overwrote a tree is a scaffold
61
+ * nobody dares run in the wrong shell, and the tree it lands in is usually somebody's work.
62
+ */
63
+ declare const writeScaffold: (answers: Answers) => string[];
64
+ type Step = {
65
+ code: number;
66
+ output: string;
67
+ what: string;
68
+ };
69
+ /**
70
+ * The kit read from a workspace instead of the registry — a proof aid, and only that.
71
+ *
72
+ * It is done by hand, after the install, because neither package manager can do it: pnpm resolves
73
+ * `link:` happily, and bun refuses BOTH `link:` and `file:` here, because it follows into the target
74
+ * and tries to resolve the `workspace:*` specifiers the kit's own packages use. Symlinking the
75
+ * directories and writing the bin shims is the one form of the answer that is true on both.
76
+ *
77
+ * The manifest is then told what is on disk, because `geonosis-doctor` FAILS a config whose plugin
78
+ * no manifest declares — and it should. A link is a declaration it accepts and can verify.
79
+ */
80
+ declare const linkKit: (answers: Answers, kit: string) => string[];
81
+ /**
82
+ * What has to happen after the files exist, in the order it has to happen in.
83
+ *
84
+ * The two `sync` calls are why the scaffold does not compute a boundaries map or a layer list of
85
+ * its own: the edges table is the ONE place the graph is written, and the ledger is the one thing
86
+ * that reads it. A second generator here would be a second answer to the same question.
87
+ */
88
+ declare const finish: ({ answers, install }: {
89
+ answers: Answers;
90
+ install: boolean;
91
+ }) => Step[];
92
+
93
+ export { type Answers, BACKENDS, type Backend, CORPUS_DIR, KIT_PACKAGES, RUNTIMES, type Runtime, type Step, UIS, type Ui, type Workspace, corpusFor, filesFor, finish, linkKit, parseAnswers, presetsChosenBy, wantsInstall, workspacesOf, writeScaffold };
package/dist/index.js ADDED
@@ -0,0 +1,32 @@
1
+ import {
2
+ BACKENDS,
3
+ CORPUS_DIR,
4
+ KIT_PACKAGES,
5
+ RUNTIMES,
6
+ UIS,
7
+ corpusFor,
8
+ filesFor,
9
+ finish,
10
+ linkKit,
11
+ parseAnswers,
12
+ presetsChosenBy,
13
+ wantsInstall,
14
+ workspacesOf,
15
+ writeScaffold
16
+ } from "./chunk-UWL7ARNA.js";
17
+ export {
18
+ BACKENDS,
19
+ CORPUS_DIR,
20
+ KIT_PACKAGES,
21
+ RUNTIMES,
22
+ UIS,
23
+ corpusFor,
24
+ filesFor,
25
+ finish,
26
+ linkKit,
27
+ parseAnswers,
28
+ presetsChosenBy,
29
+ wantsInstall,
30
+ workspacesOf,
31
+ writeScaffold
32
+ };
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "create-geonosis",
3
+ "version": "1.0.0",
4
+ "description": "Scaffold a microcompany repo that passes its own geonosis gates on day one.",
5
+ "keywords": [
6
+ "scaffold",
7
+ "monorepo",
8
+ "create",
9
+ "geonosis",
10
+ "gates",
11
+ "turborepo"
12
+ ],
13
+ "homepage": "https://github.com/microcompanies/geonosis/tree/main/packages/create-geonosis",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/microcompanies/geonosis.git",
17
+ "directory": "packages/create-geonosis"
18
+ },
19
+ "license": "Apache-2.0",
20
+ "type": "module",
21
+ "main": "dist/index.js",
22
+ "bin": {
23
+ "create-geonosis": "bin/create-geonosis.mjs"
24
+ },
25
+ "exports": {
26
+ ".": "./dist/index.js"
27
+ },
28
+ "files": [
29
+ "bin",
30
+ "dist"
31
+ ],
32
+ "dependencies": {
33
+ "@geonosis/cli": "1.0.0"
34
+ },
35
+ "engines": {
36
+ "node": ">=22"
37
+ },
38
+ "publishConfig": {
39
+ "access": "public"
40
+ },
41
+ "scripts": {
42
+ "build": "tsup",
43
+ "typecheck": "tsc --noEmit"
44
+ }
45
+ }