@sha3/code-standards 0.1.3 → 0.1.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 (39) hide show
  1. package/README.md +42 -0
  2. package/bin/code-standards.mjs +507 -96
  3. package/eslint/test.mjs +1 -5
  4. package/package.json +1 -1
  5. package/prettier/index.cjs +1 -1
  6. package/profiles/default.profile.json +2 -0
  7. package/profiles/schema.json +7 -7
  8. package/resources/ai/templates/examples/demo/src/billing/billing-service.ts +18 -3
  9. package/resources/ai/templates/examples/demo/src/config.ts +3 -0
  10. package/resources/ai/templates/examples/demo/src/invoices/invoice-errors.ts +12 -0
  11. package/resources/ai/templates/examples/demo/src/invoices/invoice-service.ts +14 -1
  12. package/resources/ai/templates/examples/rules/async-bad.ts +12 -0
  13. package/resources/ai/templates/examples/rules/async-good.ts +12 -0
  14. package/resources/ai/templates/examples/rules/class-first-bad.ts +12 -0
  15. package/resources/ai/templates/examples/rules/class-first-good.ts +12 -0
  16. package/resources/ai/templates/examples/rules/constructor-bad.ts +12 -0
  17. package/resources/ai/templates/examples/rules/constructor-good.ts +12 -0
  18. package/resources/ai/templates/examples/rules/control-flow-bad.ts +12 -0
  19. package/resources/ai/templates/examples/rules/control-flow-good.ts +12 -0
  20. package/resources/ai/templates/examples/rules/errors-bad.ts +12 -0
  21. package/resources/ai/templates/examples/rules/errors-good.ts +12 -0
  22. package/resources/ai/templates/examples/rules/functions-bad.ts +12 -0
  23. package/resources/ai/templates/examples/rules/functions-good.ts +12 -0
  24. package/resources/ai/templates/examples/rules/returns-bad.ts +12 -0
  25. package/resources/ai/templates/examples/rules/returns-good.ts +12 -0
  26. package/resources/ai/templates/examples/rules/testing-bad.ts +12 -0
  27. package/resources/ai/templates/examples/rules/testing-good.ts +12 -0
  28. package/resources/ai/templates/rules/architecture.md +2 -0
  29. package/resources/ai/templates/rules/class-first.md +2 -0
  30. package/resources/ai/templates/rules/functions.md +2 -0
  31. package/standards/architecture.md +2 -1
  32. package/standards/manifest.json +1 -1
  33. package/standards/schema.json +2 -11
  34. package/standards/style.md +13 -9
  35. package/templates/node-lib/src/config.ts +1 -0
  36. package/templates/node-lib/src/index.ts +3 -1
  37. package/templates/node-service/src/config.ts +3 -0
  38. package/templates/node-service/src/index.ts +4 -3
  39. package/templates/node-service/test/smoke.test.ts +1 -1
package/README.md CHANGED
@@ -21,6 +21,12 @@ If you just want to start now:
21
21
  npx @sha3/code-standards init --template node-service --yes
22
22
  ```
23
23
 
24
+ If your project was already scaffolded and you updated this package:
25
+
26
+ ```bash
27
+ npx @sha3/code-standards refresh
28
+ ```
29
+
24
30
  Then in your AI chat, paste this:
25
31
 
26
32
  ```txt
@@ -53,12 +59,14 @@ Default generated contract includes structural class/file blocks such as:
53
59
  - `consts`
54
60
  - `types`
55
61
  - `private:attributes`
62
+ - `protected:attributes`
56
63
  - `private:properties`
57
64
  - `public:properties`
58
65
  - `constructor`
59
66
  - `static:properties`
60
67
  - `factory`
61
68
  - `private:methods`
69
+ - `protected:methods`
62
70
  - `public:methods`
63
71
  - `static:methods`
64
72
 
@@ -72,6 +80,7 @@ All blocks MUST exist even when empty (`// empty`).
72
80
 
73
81
  Additional blocking defaults:
74
82
 
83
+ - Max line length is 160 chars, and lines should stay on one line when they fit.
75
84
  - `if`/`else`/loop statements MUST always use braces.
76
85
  - README updates MUST follow a top-tier quality standard (see `standards/readme.md`).
77
86
 
@@ -107,8 +116,10 @@ After `init`, your new repo contains:
107
116
  - `ai/codex.md`, `ai/cursor.md`, `ai/copilot.md`, `ai/windsurf.md`
108
117
  - `ai/examples/rules/*.ts` (good/bad examples per rule)
109
118
  - `ai/examples/demo/src/*` (feature-folder demo with classes and section blocks)
119
+ - `src/config.ts` for centralized hardcoded configuration values
110
120
  - `.gitignore` preconfigured for Node/TypeScript output
111
121
  - lint/format/typecheck/test-ready project template
122
+ - `package.json.codeStandards` metadata used by `refresh` (`template`, `profilePath`, `withAiAdapters`, `lastRefreshWith`)
112
123
 
113
124
  That means the next step is **not** configuring tools. The next step is telling your assistant to obey `AGENTS.md` before coding.
114
125
 
@@ -120,6 +131,7 @@ Generated project code is TypeScript-only: implementation and tests live in `.ts
120
131
 
121
132
  Demo structure generated by default:
122
133
 
134
+ - `ai/examples/demo/src/config.ts`
123
135
  - `ai/examples/demo/src/invoices/invoice-service.ts`
124
136
  - `ai/examples/demo/src/invoices/invoice-errors.ts`
125
137
  - `ai/examples/demo/src/invoices/invoice-types.ts`
@@ -265,6 +277,22 @@ npm run check
265
277
 
266
278
  Then use the prompts above in your AI tool.
267
279
 
280
+ ### 4) Sync updates from `@sha3/code-standards`
281
+
282
+ Run this inside an already scaffolded project:
283
+
284
+ ```bash
285
+ npx @sha3/code-standards refresh
286
+ ```
287
+
288
+ `refresh` default behavior:
289
+
290
+ - scope `Managed + AI` (template files + `AGENTS.md` + `ai/*` + `ai/examples/*`)
291
+ - overwrite conflicts
292
+ - auto-detect template (or force with `--template`)
293
+ - selective merge for `package.json` (managed scripts/devDependencies updated, custom keys preserved)
294
+ - no dependency install unless `--install`
295
+
268
296
  ---
269
297
 
270
298
  ## CLI Reference
@@ -274,6 +302,8 @@ code-standards <command> [options]
274
302
 
275
303
  Commands:
276
304
  init Initialize a project in the current directory
305
+ refresh Re-apply managed standards files and AI instructions
306
+ update Alias of refresh
277
307
  profile Create or update the AI style profile
278
308
  ```
279
309
 
@@ -290,6 +320,18 @@ An existing `.git/` directory is allowed without `--force`.
290
320
  - `--no-ai-adapters`
291
321
  - `--profile <path>`
292
322
 
323
+ ### `refresh` options
324
+
325
+ `refresh` always uses the current working directory as target.
326
+
327
+ - `--template <node-lib|node-service>`
328
+ - `--profile <path>`
329
+ - `--with-ai-adapters`
330
+ - `--no-ai-adapters`
331
+ - `--dry-run`
332
+ - `--install`
333
+ - `--yes`
334
+
293
335
  ### `profile` options
294
336
 
295
337
  - `--profile <path>`