@titan-design/style-profile 0.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 +21 -0
- package/README.md +67 -0
- package/dist/index.d.ts +617 -0
- package/dist/index.js +974 -0
- package/dist/index.js.map +1 -0
- package/package.json +48 -0
- package/templates/naming.md.hbs +31 -0
- package/templates/patterns.md.hbs +38 -0
- package/templates/per-language.md.hbs +46 -0
- package/templates/skill.md.hbs +53 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Henry Jewkes
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# @titan-design/style-profile
|
|
2
|
+
|
|
3
|
+
Declare one code-style profile and export it as enforcement artifacts: an ESLint config, a
|
|
4
|
+
ruff config, an EditorConfig, Claude rules, Claude hooks, a Claude skill, and a markdown
|
|
5
|
+
style guide. Written standards become linters.
|
|
6
|
+
|
|
7
|
+
Tier 2 of the titan-platform DAG (TP-131). No titan dependencies. `zod` v4 is a peer;
|
|
8
|
+
`handlebars` is a regular dependency and renders the skill templates shipped in
|
|
9
|
+
`templates/`.
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install @titan-design/style-profile zod
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Profile
|
|
16
|
+
|
|
17
|
+
A profile is a JSON document validated by `ProfileSchema`. Six categories (`naming`,
|
|
18
|
+
`structure`, `documentation`, `errorHandling`, `formatting`, `patterns`) each map a rule
|
|
19
|
+
name to a `StyleRule`:
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
{ convention: "camelCase", confidence: 0.93, stability: "high", fixability: "safe",
|
|
23
|
+
description: "...", examples: [{ good: "...", bad: "..." }],
|
|
24
|
+
extensions: { eslint: { rule: "no-throw-literal" }, ruff: { codes: ["E501"] } } }
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
`confidence` decides severity through `severityThresholds` (default error 0.85, warn 0.60,
|
|
28
|
+
info 0.40). A rule below `info` is left out of every export.
|
|
29
|
+
|
|
30
|
+
`readProfile(path)` and `writeProfile(path, profile)` parse through the schema;
|
|
31
|
+
`validateProfile(data)` returns zod's `safeParse` result. `migrateProfile` walks the
|
|
32
|
+
migrations registered with `registerMigration` up to `SCHEMA_VERSION` (`1.0.0`, none
|
|
33
|
+
registered yet).
|
|
34
|
+
|
|
35
|
+
## Export
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
import { exportProfile, readProfile, SUPPORTED_FORMATS } from "@titan-design/style-profile";
|
|
39
|
+
|
|
40
|
+
const profile = await readProfile("code-style-profile.json");
|
|
41
|
+
for (const file of exportProfile(profile, "ruff")) {
|
|
42
|
+
// file.path is relative to the target repo, file.content is the full text
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
| Format | Files |
|
|
47
|
+
|---|---|
|
|
48
|
+
| `eslint` | `eslint.config.js` |
|
|
49
|
+
| `ruff` | `ruff.toml` |
|
|
50
|
+
| `editorconfig` | `.editorconfig` |
|
|
51
|
+
| `markdown` | `style-guide.md` |
|
|
52
|
+
| `claude-rules` | `.claude/rules/typescript.md` (none when no rule clears `info`) |
|
|
53
|
+
| `hooks` | `.claude/settings.json` |
|
|
54
|
+
| `skill` | `skill.md`, `references/naming.md`, `references/patterns.md`, `references/per-language/<lang>.md` |
|
|
55
|
+
|
|
56
|
+
Each format also has its own generator (`generateEslintExport`, `generateRuffExport`, and so
|
|
57
|
+
on). The rule builders in `eslint-rules` (`buildNamingConventionRule`,
|
|
58
|
+
`buildFunctionLengthRule`, `buildFileNamingRule`, `buildJsdocRules`, `buildImportOrderRule`)
|
|
59
|
+
return single `[ruleName, config]` pairs for callers that assemble their own ESLint config.
|
|
60
|
+
|
|
61
|
+
## Provenance
|
|
62
|
+
|
|
63
|
+
Ported unchanged from codewatch's `@codewatch/profile`. Generated headers and the hooks
|
|
64
|
+
command still name `codewatch`, because the artifacts are byte-identical to the original's.
|
|
65
|
+
|
|
66
|
+
The worked example and the gotchas live in the site's reference page,
|
|
67
|
+
`site/reference/style-profile.md`.
|