create-shallot 0.8.1 → 0.9.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 (2) hide show
  1. package/index.ts +31 -13
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -9,8 +9,8 @@ import { dirname, join, resolve } from "path";
9
9
  *
10
10
  * the project is pure data — a `shallot.json` manifest + plugin modules + `public/`, no vite
11
11
  * boilerplate. the CLI provides every harness over it: `shallot dev` runs it standalone with hot
12
- * reload, `shallot build` ships it (web + native targets). the emitted CLAUDE.md / AGENTS.md point an
13
- * agent at the installed engine's contract.
12
+ * reload, `shallot build` ships it (web + native targets). the emitted AGENTS.md points an agent at
13
+ * the installed engine's contract, and CLAUDE.md imports it.
14
14
  */
15
15
  export function template(name: string): Record<string, string> {
16
16
  return {
@@ -23,8 +23,8 @@ export function template(name: string): Record<string, string> {
23
23
  version: "0.0.0",
24
24
  private: true,
25
25
  type: "module",
26
- dependencies: { "@dylanebert/shallot": "latest" },
27
- devDependencies: { typescript: "^7.0.2" },
26
+ dependencies: { "@dylanebert/shallot": "latest", typegpu: "~0.11.9" },
27
+ devDependencies: { "unplugin-typegpu": "~0.11.6", typescript: "^7.0.2" },
28
28
  },
29
29
  null,
30
30
  2,
@@ -53,10 +53,21 @@ export function template(name: string): Record<string, string> {
53
53
  "public/scenes/scene.scene": SCENE,
54
54
  "README.md": readme(name),
55
55
  "AGENTS.md": agents(name),
56
- "CLAUDE.md": agents(name),
56
+ "CLAUDE.md": CLAUDE_IMPORT,
57
57
  };
58
58
  }
59
59
 
60
+ // one contract, two entrypoints: Codex reads AGENTS.md, Claude Code reads CLAUDE.md and expands the
61
+ // `@`-import. An import, not a symlink — a Windows checkout without developer mode gets a literal
62
+ // text file from a symlink. The trailing sentence is the cost of that choice: the import expands only
63
+ // for a session rooted in this file's own directory, so opened from a parent the line is literal text
64
+ // and the prose pointer is all the reader gets. Kept identical to the copy-out's stanza in
65
+ // `packages/shallot/bin/scaffold.ts`.
66
+ const CLAUDE_IMPORT = `@AGENTS.md
67
+
68
+ If the import line above is showing as literal text, this file was loaded from a parent directory; read the AGENTS.md next to this file before working here.
69
+ `;
70
+
60
71
  /** write a template file map under dir, creating parent directories as needed. */
61
72
  export function scaffold(dir: string, files: Record<string, string>): void {
62
73
  for (const [rel, content] of Object.entries(files)) {
@@ -107,8 +118,9 @@ plugin enablement) in your IDE.
107
118
  bunx shallot build
108
119
  \`\`\`
109
120
 
110
- Builds a web bundle to \`dist/\`. For native targets:
111
- \`bunx shallot build --target windows|mac|linux\` (add \`--release\` for an optimized build).
121
+ Builds a web bundle to \`dist/\`. Native targets
122
+ (\`--target windows|mac|linux\`) build from a shallot source checkout, not the
123
+ installed package: the rust crate they need isn't published to npm.
112
124
  `;
113
125
 
114
126
  const agents = (name: string) => `# ${name}
@@ -126,7 +138,7 @@ A WebGPU game built on \`@dylanebert/shallot\`.
126
138
  \`\`\`bash
127
139
  bunx tsc --noEmit # typecheck — run after every change
128
140
  bunx shallot dev # run with hot reload while you work
129
- bunx shallot build [--target windows|mac|linux] # ship it (web bundle, or a native app)
141
+ bunx shallot build # ship it (web bundle to dist/)
130
142
  bunx shallot verify # prove it: boot headless, check it renders, exit 0/nonzero
131
143
  \`\`\`
132
144
 
@@ -210,18 +222,19 @@ const SCENE = `<scene>
210
222
  </scene>
211
223
  `;
212
224
 
213
- if (import.meta.main) {
214
- const args = process.argv.slice(2);
215
- const name = args.find((a) => !a.startsWith("--"));
225
+ /** `bun create shallot <project-name>` — parse argv, guard the target dir, scaffold, report next steps.
226
+ * Returns the process exit code rather than calling `process.exit` itself, so it's callable directly. */
227
+ export function main(argv: string[]): number {
228
+ const name = argv.find((a) => !a.startsWith("--"));
216
229
  if (!name) {
217
230
  console.error("Usage: bun create shallot <project-name>");
218
- process.exit(1);
231
+ return 1;
219
232
  }
220
233
 
221
234
  const dir = resolve(name);
222
235
  if (existsSync(dir)) {
223
236
  console.error(`Directory "${name}" already exists`);
224
- process.exit(1);
237
+ return 1;
225
238
  }
226
239
 
227
240
  scaffold(dir, template(name));
@@ -232,4 +245,9 @@ if (import.meta.main) {
232
245
  console.log(` cd ${name}`);
233
246
  console.log(" bun install");
234
247
  console.log(" bunx shallot dev");
248
+ return 0;
249
+ }
250
+
251
+ if (import.meta.main) {
252
+ process.exit(main(process.argv.slice(2)));
235
253
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-shallot",
3
- "version": "0.8.1",
3
+ "version": "0.9.1",
4
4
  "type": "module",
5
5
  "bin": "./index.ts",
6
6
  "files": ["index.ts"],