@sculptor/cli 0.2.2 → 0.3.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/README.md CHANGED
@@ -4,34 +4,51 @@ The SculptorTS CLI is the user-facing command line for the framework.
4
4
 
5
5
  It handles:
6
6
 
7
- - New app scaffolding
8
- - Resource generation
9
- - Test generation and registry syncing
10
- - Dev and production startup paths
11
- - Help and version output
7
+ - new app scaffolding
8
+ - package-aware and unpackaged resource generation
9
+ - test generation and registry syncing
10
+ - dev and production startup paths
11
+ - package registry maintenance
12
+ - diagnostics and compatibility checks
13
+ - `AGENTS.md` generation
14
+ - app dependency recovery with `sc install deps`
15
+ - global CLI refresh with `sc update`
16
+ - scaffolded `.gitignore` generation
12
17
 
13
18
  ## Version Policy
14
19
 
15
- - Deprecated range: `0.2.0` through `0.2.1`
16
- - Current stable: `0.2.2`
17
- - Reason: the earlier release predates the current template-registry layout, the `sc config` command set, and the route/handler generation contract used by the current CLI.
20
+ - Release line: `v0.3.x`
21
+ - This line adds package-aware generation, `sc doctor`, `sc agents`, `sculptor.packages.json`, and package alias commands.
18
22
 
19
23
  ## Quick Command Sheet
20
24
 
21
25
  | Command | What it does |
22
26
  | --- | --- |
23
27
  | `sc new <app>` | Creates a new app |
28
+ | `sc agents` | Generates `AGENTS.md` |
29
+ | `sc agents refresh` | Regenerates `AGENTS.md` |
24
30
  | `sc dev` | Starts the app from source |
25
31
  | `sc start` | Starts the app in production-style mode |
26
32
  | `sc build` | Builds the app |
27
33
  | `sc lint` | Lints the app |
28
34
  | `sc test` | Runs the test suite |
35
+ | `sc sync` | Syncs and validates `sculptor.packages.json` |
36
+ | `sc ls` / `sc list` | Prints the tree and package diagnostics |
37
+ | `sc pkg` / `sc package` | Prints package diagnostics |
29
38
  | `sc config get <path>` | Reads a config value |
30
39
  | `sc config set <path=value>` | Writes a config value |
31
40
  | `sc config list` | Lists the merged config |
41
+ | `sc reg` / `sc register` / `sc r` | Registers a file in the package registry |
42
+ | `sc ureg` / `sc unreg` / `sc unregister` / `sc ur` | Unregisters a file from the package registry |
43
+ | `sc rm` / `sc remove` | Deletes a file and syncs the registry |
44
+ | `sc install deps` | Replays app dependency installs inside a Sculptor app |
45
+ | `sc i deps` | Alias for `sc install deps` |
46
+ | `sc update` | Updates the globally installed Sculptor CLI only |
47
+ | `sc doctor` | Runs project, registry, and compatibility diagnostics |
32
48
  | `sc generate` / `sc g` | Generates framework resources |
33
49
  | `sc g c user` | Generates a controller resource |
34
50
  | `sc g r user` | Generates a functional route and handler pair |
51
+ | `sc g pkg user` | Generates a package index and package-local resources |
35
52
  | `sc g c user in src/app/users` | Generates into a custom path |
36
53
  | `sc g c in src/app/users` | Infers the name from the path and generates there |
37
54
  | `sc g t user -e` | Generates an enum type file |
@@ -47,18 +64,20 @@ It handles:
47
64
  - Temporary Execution (via Package Runner): `npx sc` or `npx sculptor`
48
65
  - Programmatic API: `runCli()`
49
66
 
50
- Note: If the Binary: `sc` resolves to Windows Service Control or conflicts with any other Binary, use `sculptor` instead. Otherwise use `npx` as prefix to invoke the CLI via Package Runner.
67
+ If `sc` conflicts with another command on your system, use `sculptor` instead.
51
68
 
52
69
  ## Command Reference
53
70
 
54
71
  ### `sc new <app>`
55
72
 
56
73
  What it does:
57
- - Creates a new Sculptor app in a sibling folder
58
- - Writes the initial framework files
59
- - Installs the package dependencies
74
+
75
+ - creates a new Sculptor app in a sibling folder
76
+ - writes the initial framework files
77
+ - installs the package dependencies
60
78
 
61
79
  How it is used:
80
+
62
81
  ```bash
63
82
  sc new my-app
64
83
  ```
@@ -81,458 +100,212 @@ Flags:
81
100
  | `--tsx` | Shortcut for `tsx` dev server |
82
101
  | `--nodemon` | Shortcut for `nodemon` dev server |
83
102
 
84
- Examples:
85
- ```bash
86
- sc new api
87
- sc new api --style=hybrid
88
- sc new api --dev-server=nodemon
89
- sc new api --framework-lock=false
90
- ```
103
+ ### `sc agents` and `sc agents refresh`
91
104
 
92
- What it solves:
93
- - You get a ready-to-run app with the framework defaults already wired
105
+ What they do:
94
106
 
95
- You will find it here:
96
- - [packages/cli/src/cli.ts](src/cli.ts)
97
- - [packages/cli/src/scaffold.ts](src/scaffold.ts)
107
+ - generate a concise `AGENTS.md`
108
+ - capture package-aware, registry-aware, DI-aware, and CLI-aware guidance for AI coding agents
98
109
 
99
- ### `sc dev`
110
+ Behavior:
100
111
 
101
- What it does:
102
- - Starts the app from source
103
- - Prints the CLI banner
112
+ - `sc agents` writes the file if it is missing
113
+ - `sc agents refresh` rewrites the file with the latest framework guidance
114
+ - both commands are safe to run repeatedly
104
115
 
105
- How it is used:
106
- ```bash
107
- sc dev
108
- sc dev --port=4000
109
- ```
110
-
111
- Flags:
116
+ ### `sc dev`
112
117
 
113
- | Flag | Meaning |
114
- | --- | --- |
115
- | `--port=<number>` | Sets `PORT` for the dev process |
118
+ What it does:
116
119
 
117
- What it solves:
118
- - You can restart the app quickly while editing source files
120
+ - starts the app from source
121
+ - prints the CLI banner
119
122
 
120
123
  Behavior:
121
- - Uses `nodemon` when `project.devServer` is `nodemon`
122
- - Uses `tsx` when `project.devServer` is `tsx`
123
- - Refuses to run outside a Sculptor app root
124
- - Suppresses the runtime banner by setting `SCULPTOR_SUPPRESS_BANNER=1`
124
+
125
+ - uses `nodemon` when `project.devServer` is `nodemon`
126
+ - uses `tsx` when `project.devServer` is `tsx`
127
+ - refuses to run outside a Sculptor app root
128
+ - suppresses the runtime banner by setting `SCULPTOR_SUPPRESS_BANNER=1`
125
129
 
126
130
  ### `sc start`
127
131
 
128
132
  What it does:
129
- - Starts the app in production-style mode
130
-
131
- How it is used:
132
- ```bash
133
- sc start
134
- sc start --port=4000
135
- sc start --watch
136
- ```
137
-
138
- Flags:
139
133
 
140
- | Flag | Meaning |
141
- | --- | --- |
142
- | `--port=<number>` | Sets `PORT` for the process |
143
- | `--watch` | Forces the dev path instead of the built path |
134
+ - starts the app in production-style mode
144
135
 
145
136
  Behavior:
146
- - If `dist/main.js` exists and `--watch` is not set, it runs the built app
147
- - If `--watch` is set, it behaves like `sc dev`
148
- - If no build output exists, it falls back to `tsx src/main.ts`
149
137
 
150
- What it solves:
151
- - The same command can be used for production-style startup and local fallback startup
138
+ - if `dist/main.js` exists and `--watch` is not set, it runs the built app
139
+ - if `--watch` is set, it behaves like `sc dev`
140
+ - if no build output exists, it falls back to `tsx src/main.ts`
152
141
 
153
142
  ### `sc build`
154
143
 
155
144
  What it does:
156
- - Runs TypeScript build for the current app
157
-
158
- How it is used:
159
- ```bash
160
- sc build
161
- ```
162
-
163
- What it solves:
164
- - Creates production JavaScript output from app source
165
145
 
166
- Behavior:
167
- - Only works inside a Sculptor app root
168
- - Uses the app-local `tsconfig.json`
146
+ - runs TypeScript build for the current app
147
+ - runs package validation before TypeScript compile in the current release line
169
148
 
170
149
  ### `sc lint`
171
150
 
172
151
  What it does:
173
- - Runs ESLint from the app root
174
-
175
- How it is used:
176
- ```bash
177
- sc lint
178
- ```
179
152
 
180
- What it solves:
181
- - Gives a single framework-aligned lint command
153
+ - runs ESLint from the app root
182
154
 
183
155
  ### `sc test`
184
156
 
185
157
  What it does:
186
- - Runs the app test suite
187
158
 
188
- How it is used:
189
- ```bash
190
- sc test
191
- ```
159
+ - runs the app test suite
192
160
 
193
161
  Behavior:
194
- - If `src/tests/runner.spec.ts` exists, runs `vitest run src/tests/runner.spec.ts`
195
- - If the runner does not exist, falls back to `vitest run`
196
162
 
197
- What it solves:
198
- - You can keep a generated test registry while still having a standard test command
163
+ - if `src/tests/runner.spec.ts` exists, it runs that entrypoint
164
+ - otherwise it falls back to `vitest run`
199
165
 
200
- ### `sc config`
166
+ ### `sc sync`
201
167
 
202
168
  What it does:
203
- - Reads, writes, and lists app config
204
169
 
205
- How it is used:
206
- ```bash
207
- sc config get logging
208
- sc config set logging.dogMode=false
209
- sc config list
210
- ```
170
+ - validates and refreshes `sculptor.packages.json`
171
+ - checks package ownership, stale files, missing files, and registry consistency
211
172
 
212
173
  Behavior:
213
- - `get` reads a dot-path from the merged config
214
- - `set` writes a dot-path assignment while preserving JSON formatting when possible
215
- - `list` prints the flattened merged config
216
- - `sculptor` supports the same command set as `sc`
217
174
 
218
- ### `sc generate` and `sc g`
175
+ - supports `-p`, `--p`, `-pkg`, `--pkg`, `-package`, and `--package`
176
+ - package targeting is exact and does not singularize or pluralize names
177
+ - warnings do not block the build path unless metadata is malformed or irrecoverable
219
178
 
220
- What it does:
221
- - Generates framework resources in the current app
179
+ ### `sc ls` / `sc list`
222
180
 
223
- How it is used:
224
- ```bash
225
- sc generate controller user
226
- sc g c user
227
- ```
228
-
229
- Supported kinds:
181
+ What they do:
230
182
 
231
- | Kind | Aliases |
232
- | --- | --- |
233
- | controller | `c`, `controller` |
234
- | service | `s`, `service` |
235
- | module | `m`, `mo`, `module` |
236
- | middleware | `mw`, `middleware` |
237
- | type | `t`, `type` |
238
- | route | `r`, `route`, `resource` |
183
+ - print package and tree diagnostics
184
+ - show registered files, missing files, and unregistered files
239
185
 
240
186
  Behavior:
241
- - Refuses to run outside a Sculptor app root
242
- - Controller generation is controller-first by default and can opt into paired functional route files with `--functional`
243
- - Route generation always writes the paired functional route and handler files
244
- - Rewrites the test registry when test generation is enabled
245
-
246
- What it solves:
247
- - Your app stays consistent as it grows
248
187
 
249
- ### `sc help`
188
+ - `-t`, `--tree`, `-tree`, and `--t` enable tree output
189
+ - package targeting uses the same exact-name flags as `sc sync`
250
190
 
251
- What it does:
252
- - Prints help text
191
+ ### `sc pkg` / `sc package`
253
192
 
254
- How it is used:
255
- ```bash
256
- sc help
257
- sc help generate
258
- sc help controller
259
- sc help module
260
- sc help middleware
261
- sc help type
262
- sc help route
263
- ```
193
+ What they do:
264
194
 
265
- ### `sc version`
195
+ - print package diagnostics
196
+ - show package path, index path, and tracked files
266
197
 
267
- What it does:
268
- - Prints the CLI version and the banner
198
+ ### `sc reg` / `sc register` / `sc r`
269
199
 
270
- How it is used:
271
- ```bash
272
- sc version
273
- sc v
274
- sc -v
275
- sc --v
276
- sc --version
277
- ```
200
+ What they do:
278
201
 
279
- ## Full Flag Reference
202
+ - register a file in `sculptor.packages.json`
280
203
 
281
- ### Global flags and aliases
204
+ ### `sc ureg` / `sc unreg` / `sc unregister` / `sc ur`
282
205
 
283
- | Input | Meaning |
284
- | --- | --- |
285
- | `-v` | Print version |
286
- | `--v` | Print version |
287
- | `--version` | Print version |
288
- | `version` | Print version |
289
- | `v` | Print version |
290
- | `-h` | Print help |
291
- | `--help` | Print help |
206
+ What they do:
292
207
 
293
- ### `sc new` flags
208
+ - unregister a file from `sculptor.packages.json`
294
209
 
295
- | Flag | Meaning |
296
- | --- | --- |
297
- | `--name` | App name |
298
- | `--version` | Scaffold version |
299
- | `--style` | Routing style |
300
- | `--decorator` | Decorator routing shortcut |
301
- | `--functional` | Functional routing shortcut |
302
- | `--hybrid` | Hybrid routing shortcut |
303
- | `--frameworkLock` | Framework lock |
304
- | `--frameworklock` | Framework lock |
305
- | `--framework-lock` | Framework lock |
306
- | `--dev-server` | Dev server selection |
307
- | `--devserver` | Dev server selection |
308
- | `--tsx` | Dev server shortcut |
309
- | `--nodemon` | Dev server shortcut |
310
-
311
- ### `sc dev` / `sc start` flags
210
+ ### `sc rm` / `sc remove`
312
211
 
313
- | Flag | Meaning |
314
- | --- | --- |
315
- | `--port` | Sets the process port |
316
- | `--watch` | Only used by `sc start` |
212
+ What they do:
317
213
 
318
- ### `sc generate` flags
214
+ - delete a file
215
+ - sync the registry after removal
319
216
 
320
- | Flag | Meaning |
321
- | --- | --- |
322
- | `--functional` | Use functional routing mode |
323
- | `--with-routes` | Alias for paired functional route generation |
324
- | `--decorator` | Use decorator routing mode |
325
- | `--hybrid` | Use hybrid routing mode |
326
- | `--style` | Explicitly set routing mode |
327
- | `in <path>` | Write files into a custom directory |
328
- | `-i` | Type generator creates `*.interface.ts` |
329
- | `-interface` | Type generator creates `*.interface.ts` |
330
- | `-c` | Type generator creates `*.class.ts` |
331
- | `-class` | Type generator creates `*.class.ts` |
332
- | `-e` | Type generator creates `*.enum.ts` |
333
- | `-enum` | Type generator creates `*.enum.ts` |
334
-
335
- ## Generator Behavior
336
-
337
- ### Controller generation
217
+ ### `sc config`
338
218
 
339
219
  What it does:
340
- - Writes `*.controller.ts` by default
341
- - Pass `--functional` or `--with-routes` to also write paired `*.route.ts` and `*.route.handler.ts` files
342
- - In functional-first app flows, the paired functional route files are the standard route shape
343
-
344
- Examples:
345
- ```bash
346
- sc generate controller user
347
- sc g c user
348
- sc g c user in src/app/users
349
- sc g c in src/app/users
350
- sc g c user --functional
351
- ```
352
-
353
- If you use `in <path>`:
354
- - the file location changes to that path
355
- - the file name still follows the generator suffix
356
- - if you do not provide a name, the CLI infers it from the last path segment
357
- - the generated test file, when enabled, is written under `src/tests`
358
220
 
359
- ### Service generation
221
+ - reads, writes, and lists app config
360
222
 
361
- What it does:
362
- - Writes `*.service.ts`
223
+ Behavior:
363
224
 
364
- Examples:
365
- ```bash
366
- sc generate service user
367
- sc g s user
368
- sc g s user in src/app/services
369
- ```
225
+ - `get` reads a dot-path from the merged config
226
+ - `set` writes a dot-path assignment while preserving JSON formatting when possible
227
+ - `list` prints the flattened merged config
228
+ - `sculptor` supports the same command set as `sc`
370
229
 
371
- ### Module generation
230
+ ### `sc install deps` and `sc i deps`
372
231
 
373
232
  What it does:
374
- - Writes `*.module.ts`
375
-
376
- Examples:
377
- ```bash
378
- sc generate module user
379
- sc g m user
380
- sc g mo user
381
- ```
382
233
 
383
- ### Middleware generation
234
+ - replays the standard Sculptor app dependency installation sequence
235
+ - runs inside an existing Sculptor app root
236
+ - helps recover after an interrupted `npm i` during setup
384
237
 
385
- What it does:
386
- - Writes `*.middleware.ts`
238
+ Behavior:
387
239
 
388
- Examples:
389
- ```bash
390
- sc generate middleware auth
391
- sc g mw auth
392
- sc g mw auth in src/app/middlewares
393
- ```
240
+ - uses `npm i` for the app package.json dependencies first
241
+ - installs the Sculptor runtime dependencies next
242
+ - reinstalls the Sculptor CLI/config/router dev dependencies last
243
+ - refuses to run outside a Sculptor app root
394
244
 
395
- ### Type generation
245
+ ### `sc update`
396
246
 
397
247
  What it does:
398
- - Writes one of:
399
- - `*.type.ts`
400
- - `*.interface.ts`
401
- - `*.class.ts`
402
- - `*.enum.ts`
403
-
404
- Examples:
405
- ```bash
406
- sc g t
407
- sc generate type user
408
- sc g t user
409
- sc generate type user -interface
410
- sc g t user -i
411
- sc generate type user -class
412
- sc g t user -c
413
- sc generate type user -enum
414
- sc g t user -e
415
- ```
416
248
 
417
- If you omit the name, the CLI falls back to `index` unless a custom output path lets it infer a name from the directory.
249
+ - updates the globally installed Sculptor CLI package only
418
250
 
419
- ### Route generation
420
-
421
- What it does:
422
- - Writes `*.route.ts` and `*.route.handler.ts`
423
- - Uses the Sculptor functional router builder
424
- - Generates a paired handler with try/catch and error middleware boilerplate
251
+ How it is used:
425
252
 
426
- Examples:
427
253
  ```bash
428
- sc generate route user
429
- sc g r user
430
- sc g r user in src/app/routes
254
+ sc update
431
255
  ```
432
256
 
433
- ## Test Generation
434
-
435
- Test generation is controlled by `testing.generate` in `sculptor.json`.
436
-
437
- | Setting | Result |
438
- | --- | --- |
439
- | `true` | Matching `*.spec.ts` files are generated |
440
- | `false` | No new spec files are generated |
257
+ Behavior:
441
258
 
442
- Generated spec names:
259
+ - only installs `@sculptor/cli`
260
+ - does not mutate runtime package dependencies globally
261
+ - remains separate from scaffold-time template-registry recovery
443
262
 
444
- - `user.controller.spec.ts`
445
- - `user.service.spec.ts`
446
- - `user.route.spec.ts`
447
- - `auth.middleware.spec.ts`
263
+ ## Alias Notes
448
264
 
449
- Default scaffold test files:
265
+ - `sc g` -> `sc generate`
266
+ - `pkg` -> `package`
267
+ - `ls` -> `list`
268
+ - `reg` -> `register`
269
+ - `ureg` -> `unreg` -> `unregister` -> `ur`
270
+ - `rm` -> `remove`
450
271
 
451
- - `src/tests/main.spec.ts`
452
- - `src/tests/health.controller.spec.ts`
453
- - `src/tests/health.route.spec.ts`
454
- - `src/tests/registry.ts`
455
- - `src/tests/runner.ts`
456
- - `src/tests/runner.spec.ts`
272
+ ## Package Target Flags
457
273
 
458
- ## Test Harness Behavior
274
+ Package-targeting flags accept either `=value` or separate `value` forms:
459
275
 
460
- What it does:
461
- - Discovers every `*.spec.ts` file under `src/tests`
462
- - Writes `src/tests/registry.ts`
463
- - Writes `src/tests/runner.ts`
464
- - Writes `src/tests/runner.spec.ts`
276
+ - `-p`
277
+ - `--p`
278
+ - `-pkg`
279
+ - `--pkg`
280
+ - `-package`
281
+ - `--package`
465
282
 
466
- How it is used:
467
- - `sc test` runs the registry runner when it exists
283
+ Examples:
468
284
 
469
- What it solves:
470
- - You do not have to manually keep your test suite entrypoint updated
285
+ ```bash
286
+ sc g pkg user -p=user
287
+ sc g pkg user --pkg user
288
+ sc g pkg user -package=user
289
+ sc ls -t --package user
290
+ ```
471
291
 
472
- ## App Root Rules
292
+ ## App Root Rule
473
293
 
474
- Only these commands work from outside a Sculptor app root:
294
+ The CLI only allows certain commands outside a Sculptor app root:
475
295
 
476
296
  - `sc new`
297
+ - `sc agents`
298
+ - `sc agents refresh`
477
299
  - `sc help`
478
300
  - `sc version`
301
+ - `sc doctor`
302
+ - `sc update`
479
303
 
480
- Everything else requires `sculptor.json` in the current directory.
481
-
482
- If you try to run a restricted command outside an app root, the CLI stops with a clear error.
483
-
484
- ## CLI Banner Behavior
485
-
486
- The version line in the banner is automatic.
487
-
488
- If the package version changes, the banner version changes too.
489
-
490
- ## Programmatic Use
491
-
492
- ```ts
493
- import { runCli } from "@sculptor/cli";
494
-
495
- await runCli(["node", "sc", "help"]);
496
- ```
497
-
498
- ## Exports
499
-
500
- `@sculptor/cli` re-exports:
501
-
502
- - `runCli`
503
- - `resolveProjectMetadata`
504
- - `scaffoldProject`
505
- - `generateResourceFiles`
506
- - `writeGeneratedFiles`
507
- - `syncTestHarness`
508
- - the scaffold help strings
509
-
510
- ## Package Scripts
511
-
512
- - `npm run cli` runs the CLI source with `tsx`
513
- - `npm run build` compiles the package
514
- - `npm run prepack` builds before packaging
515
-
516
- ## If You Only Remember One Thing
517
-
518
- If you are inside a Sculptor app root, use:
519
-
520
- ```bash
521
- sc dev
522
- sc generate controller user
523
- sc generate route user
524
- sc config list
525
- sc test
526
- ```
527
-
528
- If you are outside an app root, only use:
529
-
530
- ```bash
531
- sc new
532
- sc help
533
- sc version
534
- ```
304
+ The runtime commands require `sculptor.json` in the current app root.
535
305
 
536
- ## License
306
+ Next:
537
307
 
538
- MIT
308
+ - [packages/core/README.md](../core/README.md)
309
+ - [packages/di/README.md](../di/README.md)
310
+ - [packages/router/README.md](../router/README.md)
311
+ - [packages/template-registry/README.md](../template-registry/README.md)
package/bin/sc.js CHANGED
File without changes
@@ -0,0 +1,2 @@
1
+ export declare const buildAgentsMarkdown: (rootDir: string) => string;
2
+ export declare const writeAgentsMarkdown: (rootDir: string) => string;