@sha3/code 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/AGENTS.md +75 -0
- package/README.md +554 -0
- package/ai/adapters/codex.md +7 -0
- package/ai/adapters/copilot.md +7 -0
- package/ai/adapters/cursor.md +7 -0
- package/ai/adapters/windsurf.md +8 -0
- package/ai/constitution.md +12 -0
- package/bin/code-standards.mjs +47 -0
- package/biome.json +37 -0
- package/index.mjs +11 -0
- package/lib/cli/parse-args.mjs +416 -0
- package/lib/cli/post-run-guidance.mjs +43 -0
- package/lib/cli/run-init.mjs +123 -0
- package/lib/cli/run-profile.mjs +46 -0
- package/lib/cli/run-refactor.mjs +152 -0
- package/lib/cli/run-verify.mjs +67 -0
- package/lib/constants.mjs +167 -0
- package/lib/contract/load-rule-catalog.mjs +12 -0
- package/lib/contract/render-agents.mjs +79 -0
- package/lib/contract/render-contract-json.mjs +7 -0
- package/lib/contract/resolve-contract.mjs +52 -0
- package/lib/paths.mjs +50 -0
- package/lib/profile.mjs +108 -0
- package/lib/project/ai-instructions.mjs +28 -0
- package/lib/project/biome-ignore.mjs +14 -0
- package/lib/project/managed-files.mjs +105 -0
- package/lib/project/package-metadata.mjs +132 -0
- package/lib/project/prompt-files.mjs +111 -0
- package/lib/project/template-resolution.mjs +70 -0
- package/lib/refactor/materialize-refactor-context.mjs +106 -0
- package/lib/refactor/preservation-questions.mjs +33 -0
- package/lib/refactor/public-contract-extractor.mjs +22 -0
- package/lib/refactor/render-analysis-summary.mjs +50 -0
- package/lib/refactor/source-analysis.mjs +74 -0
- package/lib/utils/fs.mjs +220 -0
- package/lib/utils/prompts.mjs +63 -0
- package/lib/utils/text.mjs +43 -0
- package/lib/verify/change-audit-verifier.mjs +140 -0
- package/lib/verify/change-context.mjs +36 -0
- package/lib/verify/error-handling-verifier.mjs +164 -0
- package/lib/verify/explain-rule.mjs +54 -0
- package/lib/verify/issue-helpers.mjs +132 -0
- package/lib/verify/project-layout-verifier.mjs +259 -0
- package/lib/verify/project-verifier.mjs +267 -0
- package/lib/verify/readme-public-api.mjs +237 -0
- package/lib/verify/readme-verifier.mjs +216 -0
- package/lib/verify/render-json-report.mjs +3 -0
- package/lib/verify/render-text-report.mjs +34 -0
- package/lib/verify/source-analysis.mjs +126 -0
- package/lib/verify/source-rule-verifier.mjs +453 -0
- package/lib/verify/testing-verifier.mjs +113 -0
- package/lib/verify/tooling-verifier.mjs +82 -0
- package/lib/verify/typescript-style-verifier.mjs +407 -0
- package/package.json +55 -0
- package/profiles/default.profile.json +40 -0
- package/profiles/schema.json +96 -0
- package/prompts/init-contract.md +25 -0
- package/prompts/init-phase-2-implement.md +25 -0
- package/prompts/init-phase-3-verify.md +23 -0
- package/prompts/init.prompt.md +24 -0
- package/prompts/refactor-contract.md +26 -0
- package/prompts/refactor-phase-2-rebuild.md +25 -0
- package/prompts/refactor-phase-3-verify.md +24 -0
- package/prompts/refactor.prompt.md +26 -0
- package/resources/ai/AGENTS.md +18 -0
- package/resources/ai/adapters/codex.md +5 -0
- package/resources/ai/adapters/copilot.md +5 -0
- package/resources/ai/adapters/cursor.md +5 -0
- package/resources/ai/adapters/windsurf.md +5 -0
- package/resources/ai/contract.schema.json +68 -0
- package/resources/ai/rule-catalog.json +878 -0
- package/resources/ai/rule-catalog.schema.json +66 -0
- package/resources/ai/templates/adapters/codex.template.md +7 -0
- package/resources/ai/templates/adapters/copilot.template.md +7 -0
- package/resources/ai/templates/adapters/cursor.template.md +7 -0
- package/resources/ai/templates/adapters/windsurf.template.md +7 -0
- package/resources/ai/templates/agents.project.template.md +141 -0
- package/resources/ai/templates/examples/demo/src/billing/billing.service.ts +73 -0
- package/resources/ai/templates/examples/demo/src/config.ts +3 -0
- package/resources/ai/templates/examples/demo/src/invoice/invoice.errors.ts +51 -0
- package/resources/ai/templates/examples/demo/src/invoice/invoice.service.ts +96 -0
- package/resources/ai/templates/examples/demo/src/invoice/invoice.types.ts +9 -0
- package/resources/ai/templates/examples/rules/async-bad.ts +52 -0
- package/resources/ai/templates/examples/rules/async-good.ts +56 -0
- package/resources/ai/templates/examples/rules/class-first-bad.ts +36 -0
- package/resources/ai/templates/examples/rules/class-first-good.ts +74 -0
- package/resources/ai/templates/examples/rules/constructor-bad.ts +68 -0
- package/resources/ai/templates/examples/rules/constructor-good.ts +71 -0
- package/resources/ai/templates/examples/rules/control-flow-bad.ts +31 -0
- package/resources/ai/templates/examples/rules/control-flow-good.ts +54 -0
- package/resources/ai/templates/examples/rules/errors-bad.ts +42 -0
- package/resources/ai/templates/examples/rules/errors-good.ts +23 -0
- package/resources/ai/templates/examples/rules/functions-bad.ts +48 -0
- package/resources/ai/templates/examples/rules/functions-good.ts +58 -0
- package/resources/ai/templates/examples/rules/returns-bad.ts +38 -0
- package/resources/ai/templates/examples/rules/returns-good.ts +44 -0
- package/resources/ai/templates/examples/rules/testing-bad.ts +34 -0
- package/resources/ai/templates/examples/rules/testing-good.ts +54 -0
- package/resources/ai/templates/rules/architecture.md +41 -0
- package/resources/ai/templates/rules/async.md +13 -0
- package/resources/ai/templates/rules/class-first.md +45 -0
- package/resources/ai/templates/rules/control-flow.md +13 -0
- package/resources/ai/templates/rules/errors.md +18 -0
- package/resources/ai/templates/rules/functions.md +29 -0
- package/resources/ai/templates/rules/naming.md +13 -0
- package/resources/ai/templates/rules/readme.md +36 -0
- package/resources/ai/templates/rules/returns.md +13 -0
- package/resources/ai/templates/rules/testing.md +18 -0
- package/resources/ai/templates/rules.project.template.md +66 -0
- package/resources/ai/templates/skills/change-synchronization/SKILL.md +42 -0
- package/resources/ai/templates/skills/feature-shaping/SKILL.md +45 -0
- package/resources/ai/templates/skills/http-api-conventions/SKILL.md +171 -0
- package/resources/ai/templates/skills/init-workflow/SKILL.md +52 -0
- package/resources/ai/templates/skills/readme-authoring/SKILL.md +51 -0
- package/resources/ai/templates/skills/refactor-workflow/SKILL.md +50 -0
- package/resources/ai/templates/skills/simplicity-audit/SKILL.md +41 -0
- package/resources/ai/templates/skills/test-scope-selection/SKILL.md +50 -0
- package/resources/ai/templates/skills.index.template.md +25 -0
- package/standards/architecture.md +72 -0
- package/standards/changelog-policy.md +12 -0
- package/standards/manifest.json +36 -0
- package/standards/readme.md +56 -0
- package/standards/schema.json +124 -0
- package/standards/style.md +106 -0
- package/standards/testing.md +20 -0
- package/standards/tooling.md +38 -0
- package/templates/node-lib/.biomeignore +10 -0
- package/templates/node-lib/.vscode/extensions.json +1 -0
- package/templates/node-lib/.vscode/settings.json +9 -0
- package/templates/node-lib/README.md +172 -0
- package/templates/node-lib/biome.json +37 -0
- package/templates/node-lib/gitignore +6 -0
- package/templates/node-lib/package.json +32 -0
- package/templates/node-lib/scripts/release-publish.mjs +106 -0
- package/templates/node-lib/scripts/run-tests.mjs +65 -0
- package/templates/node-lib/src/config.ts +3 -0
- package/templates/node-lib/src/index.ts +2 -0
- package/templates/node-lib/src/logger.ts +7 -0
- package/templates/node-lib/src/package-info/package-info.service.ts +47 -0
- package/templates/node-lib/test/package-info.test.ts +10 -0
- package/templates/node-lib/tsconfig.build.json +1 -0
- package/templates/node-lib/tsconfig.json +5 -0
- package/templates/node-service/.biomeignore +10 -0
- package/templates/node-service/.vscode/extensions.json +1 -0
- package/templates/node-service/.vscode/settings.json +9 -0
- package/templates/node-service/README.md +244 -0
- package/templates/node-service/biome.json +37 -0
- package/templates/node-service/ecosystem.config.cjs +3 -0
- package/templates/node-service/gitignore +6 -0
- package/templates/node-service/package.json +42 -0
- package/templates/node-service/scripts/release-publish.mjs +106 -0
- package/templates/node-service/scripts/run-tests.mjs +65 -0
- package/templates/node-service/src/app/service-runtime.service.ts +57 -0
- package/templates/node-service/src/app-info/app-info.service.ts +47 -0
- package/templates/node-service/src/config.ts +11 -0
- package/templates/node-service/src/http/http-server.service.ts +66 -0
- package/templates/node-service/src/index.ts +2 -0
- package/templates/node-service/src/logger.ts +7 -0
- package/templates/node-service/src/main.ts +5 -0
- package/templates/node-service/test/service-runtime.test.ts +13 -0
- package/templates/node-service/tsconfig.build.json +1 -0
- package/templates/node-service/tsconfig.json +5 -0
- package/tsconfig/base.json +16 -0
- package/tsconfig/node-lib.json +5 -0
- package/tsconfig/node-service.json +1 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: simplicity-audit
|
|
3
|
+
description: Use this skill before and after non-trivial implementation work. It defines the required anti-complexity review that removes gratuitous files, layers, wrappers, and speculative configuration before finalizing code.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Simplicity Audit
|
|
7
|
+
|
|
8
|
+
## When To Use
|
|
9
|
+
|
|
10
|
+
Use this skill before finalizing non-trivial implementation, especially when adding files, abstractions, classes, configuration, or transport layers.
|
|
11
|
+
|
|
12
|
+
## Audit Pass
|
|
13
|
+
|
|
14
|
+
Ask these questions in order:
|
|
15
|
+
|
|
16
|
+
1. Can the same behavior be implemented with fewer files?
|
|
17
|
+
2. Can a helper stay as a private or static method instead of becoming a new file?
|
|
18
|
+
3. Does each abstraction solve a real current complexity problem?
|
|
19
|
+
4. Does the design still look as direct as the template baseline?
|
|
20
|
+
5. Did any new config key, type, or wrapper appear without a real consumer?
|
|
21
|
+
|
|
22
|
+
## Remove First
|
|
23
|
+
|
|
24
|
+
- speculative factories
|
|
25
|
+
- wrapper services
|
|
26
|
+
- unused option objects
|
|
27
|
+
- premature `*.types.ts` files
|
|
28
|
+
- helper files that should stay inside a class
|
|
29
|
+
- transport or domain layers with only pass-through behavior
|
|
30
|
+
- configuration added for unimplemented scenarios
|
|
31
|
+
|
|
32
|
+
## Keep Only When Justified
|
|
33
|
+
|
|
34
|
+
- role-specific extra files with a clear current responsibility
|
|
35
|
+
- true cross-feature modules
|
|
36
|
+
- validation schemas with non-trivial validation logic
|
|
37
|
+
- public types that materially clarify the contract
|
|
38
|
+
|
|
39
|
+
## Final Check
|
|
40
|
+
|
|
41
|
+
Before finishing, compare the final structure to the simplest plausible design that still respects current boundaries. If the simpler design is still correct, the simpler design wins.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: test-scope-selection
|
|
3
|
+
description: Use this skill when code changes may affect behavior. It defines how to decide whether tests are required, which behavior deserves coverage, and what the minimum adequate test scope is.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Test Scope Selection
|
|
7
|
+
|
|
8
|
+
## When To Use
|
|
9
|
+
|
|
10
|
+
Use this skill when implementation changes introduce meaningful logic, regression risk, public contract changes, or runtime behavior changes.
|
|
11
|
+
|
|
12
|
+
## Decision Rules
|
|
13
|
+
|
|
14
|
+
Add or update tests when the change affects:
|
|
15
|
+
|
|
16
|
+
- observable behavior
|
|
17
|
+
- public API output
|
|
18
|
+
- transport contracts
|
|
19
|
+
- configuration-driven behavior
|
|
20
|
+
- branching logic
|
|
21
|
+
- regression-prone workflows
|
|
22
|
+
|
|
23
|
+
Do not add ad hoc tests for:
|
|
24
|
+
|
|
25
|
+
- trivial renames
|
|
26
|
+
- purely mechanical edits
|
|
27
|
+
- formatting-only changes
|
|
28
|
+
- behavior-neutral managed file regeneration
|
|
29
|
+
|
|
30
|
+
## Coverage Selection
|
|
31
|
+
|
|
32
|
+
Choose the smallest test set that proves the changed behavior:
|
|
33
|
+
|
|
34
|
+
1. cover the main success path
|
|
35
|
+
2. cover meaningful failure or edge behavior when it exists
|
|
36
|
+
3. avoid implementation-detail assertions
|
|
37
|
+
4. avoid duplicate tests that protect the same behavior
|
|
38
|
+
|
|
39
|
+
## Transport Notes
|
|
40
|
+
|
|
41
|
+
For HTTP changes, cover:
|
|
42
|
+
|
|
43
|
+
- status code
|
|
44
|
+
- response payload
|
|
45
|
+
- validation failure when applicable
|
|
46
|
+
- not-found or conflict behavior when applicable
|
|
47
|
+
|
|
48
|
+
## Final Check
|
|
49
|
+
|
|
50
|
+
If a behavior change would be risky to change again without a test, it should have a test.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Project Skills
|
|
2
|
+
|
|
3
|
+
`ai/contract.json` remains the machine-readable source of truth and `AGENTS.md` remains the always-on policy layer.
|
|
4
|
+
This file lists specialized workflows that should be loaded only when the task calls for them.
|
|
5
|
+
|
|
6
|
+
## How To Use Skills
|
|
7
|
+
|
|
8
|
+
1. Read `AGENTS.md`, `SKILLS.md`, and the relevant assistant adapter before implementation.
|
|
9
|
+
2. Open only the `skills/<skill-name>/SKILL.md` file that matches the task.
|
|
10
|
+
3. Load extra references only when that skill explicitly calls for them.
|
|
11
|
+
4. If a skill conflicts with `ai/contract.json` or `AGENTS.md`, the higher-priority contract wins.
|
|
12
|
+
|
|
13
|
+
## Default Workflow Skills
|
|
14
|
+
|
|
15
|
+
- `init-workflow`: Use when implementing the first behavior in a freshly generated scaffold. Read `skills/init-workflow/SKILL.md`.
|
|
16
|
+
- `refactor-workflow`: Use when refactoring an existing project or rebuilding legacy code on top of a regenerated scaffold. Read `skills/refactor-workflow/SKILL.md`.
|
|
17
|
+
- `feature-shaping`: Use when mapping a requested behavior into the scaffold and choosing the minimum justified structure. Read `skills/feature-shaping/SKILL.md`.
|
|
18
|
+
- `simplicity-audit`: Use before finalizing non-trivial changes to remove gratuitous complexity. Read `skills/simplicity-audit/SKILL.md`.
|
|
19
|
+
- `change-synchronization`: Use when behavior changes may affect tests, exports, config, scripts, or documentation. Read `skills/change-synchronization/SKILL.md`.
|
|
20
|
+
|
|
21
|
+
## Conditional Implementation Skills
|
|
22
|
+
|
|
23
|
+
- `readme-authoring`: Use when creating or updating `README.md` so the package documentation matches the real public behavior. Read `skills/readme-authoring/SKILL.md`.
|
|
24
|
+
- `test-scope-selection`: Use when deciding whether behavior changes need tests and what scope those tests should cover. Read `skills/test-scope-selection/SKILL.md`.
|
|
25
|
+
- `http-api-conventions`: Use when a project exposes HTTP endpoints and route design, params, validation, and responses must follow the standard service conventions. Read `skills/http-api-conventions/SKILL.md`.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Architecture Guide
|
|
2
|
+
|
|
3
|
+
Architecture strictness is **moderate**.
|
|
4
|
+
Simplicity policy is **minimal pragmatic (no speculative abstractions)**.
|
|
5
|
+
|
|
6
|
+
This is not optional guidance. Simplicity is a mandatory constraint:
|
|
7
|
+
|
|
8
|
+
- choose the smallest structure that works
|
|
9
|
+
- do not add layers, indirection, wrappers, or extra files without present need
|
|
10
|
+
- do not design for hypothetical future extension points
|
|
11
|
+
- when in doubt, remove complexity instead of adding it
|
|
12
|
+
- simplicity does not justify removing valid boundaries
|
|
13
|
+
- generated templates are the canonical simplicity baseline; if a rule makes them worse, the rule must be revised before the template
|
|
14
|
+
|
|
15
|
+
## Project Templates
|
|
16
|
+
|
|
17
|
+
Two templates are supported:
|
|
18
|
+
|
|
19
|
+
- `node-lib`
|
|
20
|
+
- `node-service`
|
|
21
|
+
|
|
22
|
+
## Default Layout
|
|
23
|
+
|
|
24
|
+
Both templates SHOULD keep this baseline structure:
|
|
25
|
+
|
|
26
|
+
- `src/` for implementation.
|
|
27
|
+
- `test/` for automated tests.
|
|
28
|
+
- `scripts/` for local automation scripts.
|
|
29
|
+
- `docs/` for technical documentation.
|
|
30
|
+
- `ai/` for generated assistant contract files.
|
|
31
|
+
- `config/` for non-TypeScript configuration files (JSON/YAML/TOML) when needed.
|
|
32
|
+
- Root tooling config files (`biome`, `tsconfig`) at project root.
|
|
33
|
+
- `src/config.ts` for non-parameterized hardcoded configuration values.
|
|
34
|
+
|
|
35
|
+
## Source Layout Standard
|
|
36
|
+
|
|
37
|
+
`src/` SHOULD follow a feature-first layout:
|
|
38
|
+
|
|
39
|
+
- `src/index.ts` as the entrypoint.
|
|
40
|
+
- `src/<feature>/` for feature modules.
|
|
41
|
+
- Feature folder names SHOULD be singular (for example: `src/user`, `src/invoice`, `src/billing`).
|
|
42
|
+
|
|
43
|
+
Optional shared boundaries:
|
|
44
|
+
|
|
45
|
+
- `src/app/` when composition/wiring becomes non-trivial.
|
|
46
|
+
- `src/shared/` when cross-feature modules actually exist.
|
|
47
|
+
|
|
48
|
+
Template-specific additions:
|
|
49
|
+
|
|
50
|
+
- `node-lib`: MAY add `src/public/` and `src/internal/` to separate stable API from private implementation.
|
|
51
|
+
- `node-service`: SHOULD keep transport concerns under `src/http/` (`routes`, `controllers`, `middleware`).
|
|
52
|
+
- If a service needs to expose an HTTP API, it MUST use the latest published major/minor version of `hono` as the HTTP framework.
|
|
53
|
+
|
|
54
|
+
Within each feature folder, files SHOULD be role-oriented and explicit (`*.service.ts`, `*.repository.ts`, `*.schema.ts`, `*.mapper.ts`, `*.helpers.ts`). Use `*.types.ts` only when shared feature types are substantial enough to deserve their own file. The domain base name SHOULD be singular (`invoice.service.ts`).
|
|
55
|
+
Files inside `src/<feature>/` MUST expose exactly one public class unless the file is `*.types.ts`.
|
|
56
|
+
|
|
57
|
+
## Boundary Rules
|
|
58
|
+
|
|
59
|
+
- Keep feature modules cohesive.
|
|
60
|
+
- Avoid cyclic dependencies.
|
|
61
|
+
- Keep hardcoded application configuration centralized in `src/config.ts`.
|
|
62
|
+
- `src/config.ts` MUST export a default object named `config` and consumers MUST import it as `import config from "./config.ts"`.
|
|
63
|
+
- Structured output with meaningful size (for example documents, emails, pages, prompts, markdown, HTML, text reports, or similar artifacts) MUST live in dedicated template files rather than being assembled inline in application code.
|
|
64
|
+
- Inline string construction is allowed only for very small fragments where a separate template file would add more noise than value.
|
|
65
|
+
- Template rendering technology is an implementation choice: use the lightest approach that fits the case, from simple placeholder replacement to a dedicated templating library.
|
|
66
|
+
- Prefer the smallest design that satisfies current requirements.
|
|
67
|
+
- Do not introduce extra files, layers, or abstractions unless they reduce real current complexity.
|
|
68
|
+
- Avoid speculative structure for future scenarios that are not implemented yet.
|
|
69
|
+
- If two designs are both correct, the less abstract and less indirect design MUST win.
|
|
70
|
+
- Respect cohesion and responsibility boundaries.
|
|
71
|
+
- If code already has clear, justified boundaries, keep them. Do not remove them only to make the structure look simpler.
|
|
72
|
+
- Generated README files MUST describe the real runtime or package behavior; they MUST NOT describe themselves as scaffold output outside `AI Workflow`.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Changelog Policy
|
|
2
|
+
|
|
3
|
+
## Versioning
|
|
4
|
+
|
|
5
|
+
Use semantic versioning for the published `@sha3/code` package.
|
|
6
|
+
|
|
7
|
+
## Rules
|
|
8
|
+
|
|
9
|
+
- Every release MUST include a concise changelog entry.
|
|
10
|
+
- Breaking changes MUST document migration steps.
|
|
11
|
+
- `npm run release:check` MUST pass before publishing.
|
|
12
|
+
- Use `npm run release:publish` to publish from repository root.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"meta": { "version": "v1", "scope": "@sha3", "packageManager": "npm", "moduleSystem": "esm" },
|
|
3
|
+
"language": { "runtime": "node", "typescript": true, "target": "ES2022" },
|
|
4
|
+
"formatting": {
|
|
5
|
+
"formatter": "biome",
|
|
6
|
+
"lineLength": 160,
|
|
7
|
+
"semi": true,
|
|
8
|
+
"singleQuote": false,
|
|
9
|
+
"simpleCallbackStyle": "prefer_concise_when_biome_keeps_it_concise"
|
|
10
|
+
},
|
|
11
|
+
"naming": {
|
|
12
|
+
"files": "kebab-case",
|
|
13
|
+
"directories": "kebab-case",
|
|
14
|
+
"typescript": {
|
|
15
|
+
"classes": "PascalCase_nouns",
|
|
16
|
+
"types": "PascalCase",
|
|
17
|
+
"interfaces": "PascalCase",
|
|
18
|
+
"functions": "camelCase_verbs",
|
|
19
|
+
"methods": "camelCase_verbs",
|
|
20
|
+
"variables": "camelCase",
|
|
21
|
+
"booleans": "camelCase_with_is_has_can_should_prefix",
|
|
22
|
+
"constants": "camelCase",
|
|
23
|
+
"moduleConstants": "SCREAMING_SNAKE_CASE",
|
|
24
|
+
"acronyms": "lowercase_in_identifiers_except_well_known_id_url_http_json",
|
|
25
|
+
"forbiddenGenericNames": ["data", "obj", "tmp", "val", "thing", "helper", "utils", "common"]
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"architecture": { "strictness": "moderate", "simplicity": "minimal_pragmatic_no_speculative_abstractions", "templates": ["node-lib", "node-service"] },
|
|
29
|
+
"testing": { "runner": "node-test-runner", "coverage": false, "testLocation": "test/" },
|
|
30
|
+
"tooling": {
|
|
31
|
+
"biomeConfig": "@sha3/code/biome",
|
|
32
|
+
"tsconfigPackage": "@sha3/code/tsconfig/node-lib.json",
|
|
33
|
+
"enforcement": "biome-plus-verify"
|
|
34
|
+
},
|
|
35
|
+
"ai": { "enabledByDefault": true, "assistants": ["codex", "cursor", "copilot", "windsurf"] }
|
|
36
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# README Guide
|
|
2
|
+
|
|
3
|
+
## Goal
|
|
4
|
+
|
|
5
|
+
Every repository README MUST be clear, actionable, and visually structured.
|
|
6
|
+
For libraries, README MUST be complete integration documentation because other LLMs will use it as source-of-truth.
|
|
7
|
+
README MUST read like documentation written by the package maintainer for another engineer.
|
|
8
|
+
Do not write README like a generated scaffold summary, code dump, or file inventory.
|
|
9
|
+
|
|
10
|
+
## Mandatory Sections
|
|
11
|
+
|
|
12
|
+
- Title and one-line value proposition.
|
|
13
|
+
- TL;DR or Quick Start with copy/paste commands.
|
|
14
|
+
- Why or motivation section that explains the concrete problem the package solves.
|
|
15
|
+
- Main capabilities section that explains the primary things the package lets a consumer do.
|
|
16
|
+
- Setup and usage examples.
|
|
17
|
+
- Installation requirements and exact install command.
|
|
18
|
+
- Public API reference (exports, parameters, return values, and behavior notes).
|
|
19
|
+
- Examples section with runnable copy/paste examples.
|
|
20
|
+
- Configuration reference (`src/config.ts` constants and impact).
|
|
21
|
+
- Compatibility and constraints (runtime, module format, TypeScript expectations).
|
|
22
|
+
- AI workflow section when the repository uses AI coding contracts.
|
|
23
|
+
- Troubleshooting or FAQ.
|
|
24
|
+
|
|
25
|
+
## Writing Rules
|
|
26
|
+
|
|
27
|
+
- Start from the consumer perspective: why this package exists, when to use it, and what stable surface it offers.
|
|
28
|
+
- README content MUST be written in English.
|
|
29
|
+
- Write like the package maintainer talking to another engineer, not like a scaffold narrator.
|
|
30
|
+
- Use concrete commands and expected execution order.
|
|
31
|
+
- Avoid vague claims without implementation detail.
|
|
32
|
+
- Keep headings and lists scannable.
|
|
33
|
+
- Document every public export from `src/index.ts`.
|
|
34
|
+
- If a public export is a class, document each public method with purpose, parameters, return value, and behavior notes.
|
|
35
|
+
- Document configuration keys as user-facing controls, not just constant names.
|
|
36
|
+
- Do not enumerate private methods, internal helpers, or implementation-only files unless they are necessary for consumers to operate the package.
|
|
37
|
+
- Do not describe the project as "scaffolded", "generated", or "template" documentation in the README itself.
|
|
38
|
+
- Do not describe the README itself, the scaffold, or the generation process outside the `AI Workflow` section.
|
|
39
|
+
- Put practical examples before the exhaustive API reference where possible.
|
|
40
|
+
- Use a structure inspired by high-quality package READMEs such as `ky`: fast value proposition, examples first, then detailed API reference.
|
|
41
|
+
- Update README with every behavior or command change.
|
|
42
|
+
|
|
43
|
+
## Verification Rubric
|
|
44
|
+
|
|
45
|
+
- README MUST contain runnable `bash` or `ts` examples that match the actual public surface.
|
|
46
|
+
- README MUST document every exported type/function/class and every public class method.
|
|
47
|
+
- README MUST cover each top-level `config` key with user-facing impact.
|
|
48
|
+
- README MUST avoid placeholder language, TODOs, and abstract filler.
|
|
49
|
+
- A good README may use different wording than the template as long as it meets the same coverage and quality bar.
|
|
50
|
+
|
|
51
|
+
## Quality Bar
|
|
52
|
+
|
|
53
|
+
A top-tier README lets a new engineer understand and run the project in under 5 minutes without asking additional questions.
|
|
54
|
+
For libraries, a top-tier README also lets another LLM integrate the library in a different codebase without opening source files or guessing public method behavior.
|
|
55
|
+
A weak README sounds like a machine summarized the codebase.
|
|
56
|
+
A strong README sounds like the author is explaining the package on purpose.
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://sha3.dev/code/schema.json",
|
|
4
|
+
"title": "Code Standards Manifest",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"required": ["meta", "language", "formatting", "naming", "architecture", "testing", "tooling", "ai"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"meta": {
|
|
10
|
+
"type": "object",
|
|
11
|
+
"additionalProperties": false,
|
|
12
|
+
"required": ["version", "scope", "packageManager", "moduleSystem"],
|
|
13
|
+
"properties": {
|
|
14
|
+
"version": { "type": "string", "pattern": "^v[0-9]+$" },
|
|
15
|
+
"scope": { "type": "string", "const": "@sha3" },
|
|
16
|
+
"packageManager": { "type": "string", "const": "npm" },
|
|
17
|
+
"moduleSystem": { "type": "string", "enum": ["esm"] }
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"language": {
|
|
21
|
+
"type": "object",
|
|
22
|
+
"additionalProperties": false,
|
|
23
|
+
"required": ["runtime", "typescript", "target"],
|
|
24
|
+
"properties": { "runtime": { "type": "string", "const": "node" }, "typescript": { "type": "boolean" }, "target": { "type": "string" } }
|
|
25
|
+
},
|
|
26
|
+
"formatting": {
|
|
27
|
+
"type": "object",
|
|
28
|
+
"additionalProperties": false,
|
|
29
|
+
"required": ["formatter", "lineLength", "semi", "singleQuote", "simpleCallbackStyle"],
|
|
30
|
+
"properties": {
|
|
31
|
+
"formatter": { "type": "string", "const": "biome" },
|
|
32
|
+
"lineLength": { "type": "integer", "minimum": 80, "maximum": 200 },
|
|
33
|
+
"semi": { "type": "boolean" },
|
|
34
|
+
"singleQuote": { "type": "boolean" },
|
|
35
|
+
"simpleCallbackStyle": { "type": "string", "enum": ["prefer_concise_when_biome_keeps_it_concise"] }
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"naming": {
|
|
39
|
+
"type": "object",
|
|
40
|
+
"additionalProperties": false,
|
|
41
|
+
"required": ["files", "directories", "typescript"],
|
|
42
|
+
"properties": {
|
|
43
|
+
"files": { "type": "string", "enum": ["kebab-case"] },
|
|
44
|
+
"directories": { "type": "string", "enum": ["kebab-case"] },
|
|
45
|
+
"typescript": {
|
|
46
|
+
"type": "object",
|
|
47
|
+
"additionalProperties": false,
|
|
48
|
+
"required": [
|
|
49
|
+
"classes",
|
|
50
|
+
"types",
|
|
51
|
+
"interfaces",
|
|
52
|
+
"functions",
|
|
53
|
+
"methods",
|
|
54
|
+
"variables",
|
|
55
|
+
"booleans",
|
|
56
|
+
"constants",
|
|
57
|
+
"moduleConstants",
|
|
58
|
+
"acronyms",
|
|
59
|
+
"forbiddenGenericNames"
|
|
60
|
+
],
|
|
61
|
+
"properties": {
|
|
62
|
+
"classes": { "type": "string", "enum": ["PascalCase_nouns"] },
|
|
63
|
+
"types": { "type": "string", "enum": ["PascalCase"] },
|
|
64
|
+
"interfaces": { "type": "string", "enum": ["PascalCase"] },
|
|
65
|
+
"functions": { "type": "string", "enum": ["camelCase_verbs"] },
|
|
66
|
+
"methods": { "type": "string", "enum": ["camelCase_verbs"] },
|
|
67
|
+
"variables": { "type": "string", "enum": ["camelCase"] },
|
|
68
|
+
"booleans": { "type": "string", "enum": ["camelCase_with_is_has_can_should_prefix"] },
|
|
69
|
+
"constants": { "type": "string", "enum": ["camelCase"] },
|
|
70
|
+
"moduleConstants": { "type": "string", "enum": ["SCREAMING_SNAKE_CASE"] },
|
|
71
|
+
"acronyms": { "type": "string", "enum": ["lowercase_in_identifiers_except_well_known_id_url_http_json"] },
|
|
72
|
+
"forbiddenGenericNames": {
|
|
73
|
+
"type": "array",
|
|
74
|
+
"items": { "type": "string" },
|
|
75
|
+
"minItems": 8,
|
|
76
|
+
"maxItems": 8,
|
|
77
|
+
"uniqueItems": true,
|
|
78
|
+
"const": ["data", "obj", "tmp", "val", "thing", "helper", "utils", "common"]
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
"architecture": {
|
|
85
|
+
"type": "object",
|
|
86
|
+
"additionalProperties": false,
|
|
87
|
+
"required": ["strictness", "simplicity", "templates"],
|
|
88
|
+
"properties": {
|
|
89
|
+
"strictness": { "type": "string", "enum": ["moderate"] },
|
|
90
|
+
"simplicity": { "type": "string", "enum": ["minimal_pragmatic_no_speculative_abstractions"] },
|
|
91
|
+
"templates": { "type": "array", "items": { "type": "string", "enum": ["node-lib", "node-service"] }, "minItems": 2, "uniqueItems": true }
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
"testing": {
|
|
95
|
+
"type": "object",
|
|
96
|
+
"additionalProperties": false,
|
|
97
|
+
"required": ["runner", "coverage", "testLocation"],
|
|
98
|
+
"properties": {
|
|
99
|
+
"runner": { "type": "string", "const": "node-test-runner" },
|
|
100
|
+
"coverage": { "type": "boolean" },
|
|
101
|
+
"testLocation": { "type": "string", "enum": ["test/"] }
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
"tooling": {
|
|
105
|
+
"type": "object",
|
|
106
|
+
"additionalProperties": false,
|
|
107
|
+
"required": ["biomeConfig", "tsconfigPackage", "enforcement"],
|
|
108
|
+
"properties": {
|
|
109
|
+
"biomeConfig": { "type": "string", "const": "@sha3/code/biome" },
|
|
110
|
+
"tsconfigPackage": { "type": "string", "const": "@sha3/code/tsconfig/node-lib.json" },
|
|
111
|
+
"enforcement": { "type": "string", "enum": ["biome-plus-verify"] }
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
"ai": {
|
|
115
|
+
"type": "object",
|
|
116
|
+
"additionalProperties": false,
|
|
117
|
+
"required": ["enabledByDefault", "assistants"],
|
|
118
|
+
"properties": {
|
|
119
|
+
"enabledByDefault": { "type": "boolean" },
|
|
120
|
+
"assistants": { "type": "array", "items": { "type": "string", "enum": ["codex", "cursor", "copilot", "windsurf"] }, "minItems": 4, "uniqueItems": true }
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# Style Guide
|
|
2
|
+
|
|
3
|
+
All code MUST follow the canonical rules in `standards/manifest.json`.
|
|
4
|
+
|
|
5
|
+
## Formatting
|
|
6
|
+
|
|
7
|
+
- Use Biome for formatting.
|
|
8
|
+
- Biome is the sole authority for wrapping, quoting, spacing, and final visual layout.
|
|
9
|
+
- Use a max line length of 160.
|
|
10
|
+
- Let Biome decide the final line wrapping.
|
|
11
|
+
- Prefer compact code, but do not force single-line layouts for constructs that Biome intentionally preserves as multiline.
|
|
12
|
+
- `verify` MUST NOT enforce a visual code shape that Biome can legitimately rewrite.
|
|
13
|
+
- Use semicolons.
|
|
14
|
+
- Use double quotes for strings.
|
|
15
|
+
|
|
16
|
+
## TypeScript
|
|
17
|
+
|
|
18
|
+
- Use strict TypeScript mode.
|
|
19
|
+
- Project implementation and tests MUST be TypeScript-only (`.ts`).
|
|
20
|
+
- JavaScript source files (`.js`, `.mjs`, `.cjs`) are not allowed in `src/` or `test/`.
|
|
21
|
+
- Simplicity is MANDATORY.
|
|
22
|
+
- Always choose the simplest correct implementation that solves the current requirement.
|
|
23
|
+
- Prefer fewer lines, fewer files, fewer layers, and fewer moving parts.
|
|
24
|
+
- Do not introduce abstractions, wrappers, helper layers, option objects, factories, interfaces, or indirection unless they are justified by a real current need.
|
|
25
|
+
- Avoid speculative design for possible future scenarios.
|
|
26
|
+
- Simplicity MUST NOT come at the cost of cohesion or clear responsibility boundaries.
|
|
27
|
+
- Do not remove justified modules, role-based files, or separations merely to make the structure smaller.
|
|
28
|
+
- Prefer concise arrow functions for simple callbacks (for example in `map`, `filter`, `reduce`, `some`, `every`, `find`, `forEach`) when writing new code and when Biome already keeps that form.
|
|
29
|
+
- Do not churn Biome-stable block-bodied callbacks solely to satisfy a style preference.
|
|
30
|
+
- Heuristic rules MUST NOT require an exact code shape; they may only report risks with concrete evidence.
|
|
31
|
+
- Avoid `any` unless there is no viable alternative.
|
|
32
|
+
- Prefer explicit return types for exported functions.
|
|
33
|
+
- Use type-only imports when possible.
|
|
34
|
+
- Throw plain `Error` by default; use custom error types only when control flow depends on distinguishing them.
|
|
35
|
+
- If a function/method needs many inputs, define a named `<FunctionName>Options` type and pass a single `options` parameter.
|
|
36
|
+
- Always use braces in control flow (`if`, `else`, `for`, `while`, `do`).
|
|
37
|
+
- In `src/`, business/domain logic MUST be implemented with classes by default.
|
|
38
|
+
- Module-level exported functions in `src/` SHOULD be limited to minimal entrypoint/bootstrap wrappers.
|
|
39
|
+
- Inside `src/<feature>/`, files MUST expose exactly one public class unless the file is `*.types.ts`.
|
|
40
|
+
- If a file exposes a public class, helper logic MUST stay inside that class as private or static methods rather than module-scope functions.
|
|
41
|
+
- Oversized classes MUST be split into smaller cohesive units with clear roles instead of accumulating into one monolithic file.
|
|
42
|
+
- `src/config.ts` MUST export a default object named `config` and it MUST always be imported as `import config from ".../config.ts"`.
|
|
43
|
+
|
|
44
|
+
## Standards Admission
|
|
45
|
+
|
|
46
|
+
- No new rule may be added to `resources/ai/rule-catalog.json` without a normative source in `standards/*`.
|
|
47
|
+
- Every new rule MUST declare implementation ownership, a positive fixture, a negative fixture, and an explicit non-overlap decision for `Biome` or other generic tooling.
|
|
48
|
+
|
|
49
|
+
## Naming
|
|
50
|
+
|
|
51
|
+
- Use English technical/domain terms for all identifiers.
|
|
52
|
+
- All generated project content MUST be written in English, including source code comments, README files, documentation, AI instruction files, examples, and user-facing template text.
|
|
53
|
+
- Use `kebab-case` for files and directories.
|
|
54
|
+
- Feature folder names MUST be singular (`src/invoice`, `src/user`, `src/billing`).
|
|
55
|
+
- Class names MUST be `PascalCase` nouns.
|
|
56
|
+
- Type and interface names MUST be `PascalCase`.
|
|
57
|
+
- Function and method names MUST be `camelCase` verbs.
|
|
58
|
+
- Variable and property names MUST be `camelCase`.
|
|
59
|
+
- Boolean identifiers MUST use `is*`, `has*`, `can*`, or `should*` prefixes.
|
|
60
|
+
- Module-level constants MUST use `SCREAMING_SNAKE_CASE`.
|
|
61
|
+
- Local constants (for example inside functions/methods) MUST use `camelCase`.
|
|
62
|
+
- `src/config.ts` default export `config` and `src/logger.ts` default export `logger` are canonical naming exceptions to module-level constant naming.
|
|
63
|
+
- Use lowercase acronyms in identifiers (`userId`, `statusUrl`, `httpServer`) except well-known compact tokens (`id`, `url`, `http`, `json`).
|
|
64
|
+
- Prefer explicit role-based file names:
|
|
65
|
+
- `<feature>.service.ts` for business services
|
|
66
|
+
- `<feature>.controller.ts` for transport controllers
|
|
67
|
+
- `<feature>.repository.ts` for persistence adapters
|
|
68
|
+
- `<feature>.types.ts` for shared feature-level types and DTOs when keeping them inline would add noise
|
|
69
|
+
- `<feature>.helpers.ts` for extracted feature-local helper logic when it is justified as its own cohesive unit
|
|
70
|
+
- `<feature>.schema.ts` for validation schemas
|
|
71
|
+
- `<feature>.mapper.ts` for data transformation logic
|
|
72
|
+
- `<feature>.constants.ts` for constants
|
|
73
|
+
- `<feature>` SHOULD be singular.
|
|
74
|
+
- Do not create `*.types.ts` files for small or local types that are clearer in place.
|
|
75
|
+
- Avoid ambiguous names such as `data`, `obj`, `tmp`, `val`, `thing`, `helper`, `utils`, `common`; use domain-specific names instead.
|
|
76
|
+
|
|
77
|
+
## Class File Comment Blocks
|
|
78
|
+
|
|
79
|
+
Class-oriented files MUST use 3-line JSDoc section markers in this exact order:
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
/**
|
|
83
|
+
* @section <block-name>
|
|
84
|
+
*/
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Required block names:
|
|
88
|
+
|
|
89
|
+
1. `imports:externals`
|
|
90
|
+
2. `imports:internals`
|
|
91
|
+
3. `consts`
|
|
92
|
+
4. `types`
|
|
93
|
+
5. `class`
|
|
94
|
+
6. `private:attributes`
|
|
95
|
+
7. `protected:attributes`
|
|
96
|
+
8. `public:properties`
|
|
97
|
+
9. `constructor`
|
|
98
|
+
10. `static:properties`
|
|
99
|
+
11. `factory`
|
|
100
|
+
12. `private:methods`
|
|
101
|
+
13. `protected:methods`
|
|
102
|
+
14. `public:methods`
|
|
103
|
+
15. `static:methods`
|
|
104
|
+
|
|
105
|
+
Section blocks without content MUST be omitted.
|
|
106
|
+
`class` MUST appear immediately before the exported class declaration and marks the start of the class body.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Testing Guide
|
|
2
|
+
|
|
3
|
+
Projects MUST use the Node test runner.
|
|
4
|
+
|
|
5
|
+
## Location
|
|
6
|
+
|
|
7
|
+
- Store tests under `test/`.
|
|
8
|
+
- Use `*.test.ts` naming only.
|
|
9
|
+
|
|
10
|
+
## Commands
|
|
11
|
+
|
|
12
|
+
- `npm run test` MUST execute all automated tests.
|
|
13
|
+
- `npm run check` MUST include test execution.
|
|
14
|
+
|
|
15
|
+
## Assertions
|
|
16
|
+
|
|
17
|
+
- Prefer `node:assert/strict`.
|
|
18
|
+
- Keep tests deterministic and isolated.
|
|
19
|
+
- Add or update tests when a change introduces meaningful logic, regression risk, or critical behavior that warrants automated coverage.
|
|
20
|
+
- Do not create ad hoc tests for trivial, mechanical, or low-risk changes with no meaningful behavior to protect.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Tooling Guide
|
|
2
|
+
|
|
3
|
+
All new projects MUST use this package and its subpath exports:
|
|
4
|
+
|
|
5
|
+
- `@sha3/code/biome`
|
|
6
|
+
- `@sha3/code/tsconfig/node-lib.json` or `node-service.json`
|
|
7
|
+
|
|
8
|
+
## Behavioral Policy
|
|
9
|
+
|
|
10
|
+
In addition to tooling, each generated project MUST include profile-driven AI instructions:
|
|
11
|
+
|
|
12
|
+
- `AGENTS.md` generated from the active style profile
|
|
13
|
+
- `ai/contract.json` as the machine-readable contract
|
|
14
|
+
- optional assistant adapters in `ai/*.md`
|
|
15
|
+
|
|
16
|
+
The generated contract files are the top local AI coding contract.
|
|
17
|
+
When generated instructions conflict with existing repository code, the generated `@sha3/code` conventions MUST win.
|
|
18
|
+
All generated artifacts MUST be written in English, including `AGENTS.md`, `ai/contract.json` string content, assistant adapter files, README files, docs, examples, and template-generated user-facing text.
|
|
19
|
+
|
|
20
|
+
## Enforcement
|
|
21
|
+
|
|
22
|
+
Enforcement is local and strict.
|
|
23
|
+
|
|
24
|
+
Required scripts:
|
|
25
|
+
|
|
26
|
+
- `npm run standards:check`
|
|
27
|
+
- `npm run check`
|
|
28
|
+
- `npm run fix`
|
|
29
|
+
- `npm run lint`
|
|
30
|
+
- `npm run format:check`
|
|
31
|
+
- `npm run typecheck` (MUST fail on any TypeScript error)
|
|
32
|
+
- `npm run test`
|
|
33
|
+
|
|
34
|
+
`npm run standards:check` MUST execute `code-standards verify`.
|
|
35
|
+
Default verification fails only on `error` severity; `--strict` also fails on `warning`.
|
|
36
|
+
`npm run lint` and `npm run format:*` MUST be backed by Biome.
|
|
37
|
+
|
|
38
|
+
No remote CI is required for v1.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "recommendations": ["biomejs.biome"], "unwantedRecommendations": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode", "rvest.vs-code-prettier-eslint"] }
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"editor.formatOnSave": true,
|
|
3
|
+
"editor.formatOnSaveMode": "file",
|
|
4
|
+
"editor.defaultFormatter": "biomejs.biome",
|
|
5
|
+
"[typescript]": { "editor.defaultFormatter": "biomejs.biome", "editor.formatOnSave": true },
|
|
6
|
+
"[javascript]": { "editor.defaultFormatter": "biomejs.biome", "editor.formatOnSave": true },
|
|
7
|
+
"[json]": { "editor.defaultFormatter": "biomejs.biome", "editor.formatOnSave": true },
|
|
8
|
+
"[jsonc]": { "editor.defaultFormatter": "biomejs.biome", "editor.formatOnSave": true }
|
|
9
|
+
}
|