@evobug_com/safe-ts-skill 0.0.0-stage → 0.5.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.
- package/LICENSE-APACHE +201 -0
- package/LICENSE-MIT +21 -0
- package/README.md +15 -2
- package/install.mjs +86 -0
- package/package.json +35 -4
- package/safe-ts-migrate/SKILL.md +178 -0
- package/safe-ts-migrate/references/architecture.md +146 -0
- package/safe-ts-migrate/references/behaviour.md +86 -0
- package/safe-ts-migrate/references/census.md +136 -0
- package/safe-ts-migrate/references/escape-hatches.md +72 -0
- package/safe-ts-migrate/references/final-pass.md +46 -0
- package/safe-ts-migrate/references/fix-the-design.md +87 -0
- package/safe-ts-migrate/references/order-and-gates.md +101 -0
- package/safe-ts-migrate/references/patterns-core.md +2229 -0
- package/safe-ts-migrate/references/patterns-react.md +266 -0
- package/safe-ts-migrate/references/patterns-vue.md +713 -0
- package/safe-ts-migrate/references/review-checklist.md +70 -0
- package/safe-ts-migrate/references/templates.md +260 -0
- package/safe-ts-migrate/references/tool-gaps.md +394 -0
- package/safe-ts-migrate/scripts/census.mjs +870 -0
- package/safe-ts-migrate/scripts/safe-ts.mjs +79 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# Order of work and gates
|
|
2
|
+
|
|
3
|
+
## The order
|
|
4
|
+
|
|
5
|
+
1. **Setup** (one change): packages, tsconfig flags, oxlint preset, Vite plugin (or the Bun
|
|
6
|
+
plugin), the loader for Node processes, `"idiomatic": true`, `"requestFunctions"`, the gate
|
|
7
|
+
scripts and CI job ([templates.md](templates.md)).
|
|
8
|
+
Then the first census, then legacy markers on every file that doesn't pass yet, then the
|
|
9
|
+
census baseline. From here on the build is green and every gate runs.
|
|
10
|
+
2. **The shared foundation**: what every other area imports.
|
|
11
|
+
- The transport and the request functions (`Promise<Result<T, RequestError>>`, with a signal,
|
|
12
|
+
a time limit and `validate<T>`), and the error types.
|
|
13
|
+
- The absence conversion at the boundary, and the outgoing-`null` contract.
|
|
14
|
+
- The stores: their state, their actions returning `Result`, async state through `useTask`.
|
|
15
|
+
- Shared types and the sanctioned helpers from the architecture document.
|
|
16
|
+
Land this before anything that depends on it, so the areas don't each invent their own
|
|
17
|
+
bridge (a local `orNone`, a `UiLegacyNull`, a `must()`). The bridges that exist are std's:
|
|
18
|
+
`LegacyNull` for strict code with legacy callers that pass `null`, `trust<T>` for a named
|
|
19
|
+
trusted boundary ([patterns-core.md](patterns-core.md#strict-code-with-legacy-callers-that-pass-null)).
|
|
20
|
+
3. **Utilities and the component library**: the code the feature areas render with. Decide the
|
|
21
|
+
one form for optional props under `exactOptionalPropertyTypes` here, once, before 80
|
|
22
|
+
components each pick their own: the conditional spread of a one-key literal, or `x?: Option<T>`
|
|
23
|
+
for props a template always passes ([patterns-core.md](patterns-core.md#an-optional-key)).
|
|
24
|
+
4. **Feature areas, in parallel by dependency**: an area starts when what it imports is done.
|
|
25
|
+
Each area is one change with its own gates and hand-off report.
|
|
26
|
+
5. **Integration**: merge the areas, run every gate on the whole tree, the browser smoke on every
|
|
27
|
+
page, and the cross-area search for changed signatures (below).
|
|
28
|
+
6. **Removal of the legacy path**: bridges and adapters from the architecture document, the last
|
|
29
|
+
legacy markers, and the exceptions that had an end date.
|
|
30
|
+
7. **The final pass** ([final-pass.md](final-pass.md)) and the review
|
|
31
|
+
([review-checklist.md](review-checklist.md)).
|
|
32
|
+
|
|
33
|
+
### Legacy markers are scaffolding
|
|
34
|
+
|
|
35
|
+
`// @safe-ts legacy` (first lines of a `.ts` file; in a `.vue` file, the first line inside either
|
|
36
|
+
`<script>` block, or `<!-- @safe-ts legacy -->` at the top) lets the build stay green while a
|
|
37
|
+
file waits its turn. A marker anywhere else in a component marks nothing and is reported
|
|
38
|
+
(`vue-sfc`). The file must also be listed under `"legacyFiles"` in the package.json
|
|
39
|
+
(`"safe-ts": { "legacyFiles": ["src/old/report.ts"] }`): a marker in a file the list doesn't name
|
|
40
|
+
is reported (`unlisted-marker`) and the file checked, and `safe-ts check` prints the lines that
|
|
41
|
+
list every marked file. List each file by name rather than a directory, so the list shrinks with
|
|
42
|
+
the burn-down. It is never the end state:
|
|
43
|
+
|
|
44
|
+
- The census counts the marked files; the baseline holds the count, so no new file gets one.
|
|
45
|
+
The count per week or per release is the burn-down.
|
|
46
|
+
- Each area ends with no markers left in it.
|
|
47
|
+
- Strict code calling into a legacy file is still checked, through every import the checker
|
|
48
|
+
follows (relative paths, tsconfig `paths` aliases, workspace packages). An import it can't
|
|
49
|
+
resolve is named in a `could not resolve` warning: fix those first, the quarantine doesn't
|
|
50
|
+
reach behind them.
|
|
51
|
+
- The oxlint preset's non-SAFE-TS rules (`no-empty`, `unicorn/prefer-at`, ...) still report in
|
|
52
|
+
legacy files. The marker silences only `safe-ts/*` rules.
|
|
53
|
+
- The Vite plugin and the Node loader give a legacy file only the rewrites it needs to run
|
|
54
|
+
(prelude imports, `q`, `match`, validators), so its shipped code doesn't change until it is
|
|
55
|
+
migrated. Don't put legacy files in `safeTs({ exclude })`: an excluded file gets no prelude
|
|
56
|
+
imports either.
|
|
57
|
+
- A marker is for a file that waits its turn. One line in a migrated file that must stay as it
|
|
58
|
+
is takes `// safe-ts-ignore <rule>: <reason>` instead ([escape-hatches.md](escape-hatches.md)).
|
|
59
|
+
|
|
60
|
+
### Parallel builders
|
|
61
|
+
|
|
62
|
+
When several agents migrate areas at once:
|
|
63
|
+
|
|
64
|
+
- Each gets this skill, the architecture document, and the list of the foundation's exported
|
|
65
|
+
signatures.
|
|
66
|
+
- An area that changes an exported signature (a function or store member that now returns a
|
|
67
|
+
`Result`, a type from `T | null` to `Option<T>`) lists each changed name in its hand-off
|
|
68
|
+
report. The integrator searches every caller in every area (`rg -n '\bname\('`) and reads each
|
|
69
|
+
one. The checker reports a `Result` dropped through a store member, a returned object or a
|
|
70
|
+
factory, and (idiomatic) a `try` or `.catch` left around one, but not through a parameter, a
|
|
71
|
+
class field, a `ref` or a `Map`; and a caller's changed behaviour (a dialog that closed on a
|
|
72
|
+
throw) is no rule's business.
|
|
73
|
+
- Builders don't edit the foundation; a missing piece goes back to it as its own change.
|
|
74
|
+
|
|
75
|
+
## Gates per step
|
|
76
|
+
|
|
77
|
+
Every change passes all of these before it merges. Fixing a gate by weakening it (a new legacy
|
|
78
|
+
marker, a rule turned off, an `as`, a `void`, a baseline rewrite) is not a fix unless the
|
|
79
|
+
architecture document's exception list gains a line for it.
|
|
80
|
+
|
|
81
|
+
| Gate | Command (adapt to the project) | Passes when |
|
|
82
|
+
|---|---|---|
|
|
83
|
+
| Types | `tsc --noEmit`, or `vue-tsc --noEmit` for Vue, with `strict`, `noUncheckedIndexedAccess` and `exactOptionalPropertyTypes` on and std's strict-lib in `"types"` | no errors |
|
|
84
|
+
| Lint | `oxlint --deny-warnings` (add `--type-aware` if the project uses it) with the SAFE-TS preset | no warnings or errors |
|
|
85
|
+
| SAFE-TS | `safe-ts check <dirs or entries> --deny-warnings --baseline safe-ts-baseline.json`: the source directories (each file an entry), or the app's entry points plus the tests, scripts and workers nothing imports | exit 0: no findings, no `could not resolve` warning, no file not checked, no setup warning (all four fail `--deny-warnings`), no escape hatch or weakened rule added (legacy files report nothing) |
|
|
86
|
+
| Architecture | `node scripts/census.mjs --baseline safe-ts-census.json` | no count rose in any file |
|
|
87
|
+
| Tests | the project's runner; Node processes with `--import @evobug_com/safe-ts-transform/register` | pass |
|
|
88
|
+
| Build | `vite build` with `safeTs({ check: "error" })` (fails on errors; warnings are the SAFE-TS gate's) | succeeds, and its last line says `safe-ts: N files checked, ...` |
|
|
89
|
+
| Behaviour | the checks for the touched area in [behaviour.md](behaviour.md) | same bodies, smoke list clean |
|
|
90
|
+
|
|
91
|
+
An area is **done** when, in its directories, the gates pass, no file is legacy, and the census's
|
|
92
|
+
architecture patterns and the idiomatic rules' findings are at zero, or each remaining one is
|
|
93
|
+
an entry in the exception list. The hand-off report ([templates.md](templates.md)) says which.
|
|
94
|
+
|
|
95
|
+
Run the SAFE-TS gate in your own loop the way CI runs it, with `--deny-warnings`: a plain
|
|
96
|
+
`safe-ts check` exits 0 with every idiomatic finding still there, and with files it never
|
|
97
|
+
read. `--max-warnings <n>`, with `n`
|
|
98
|
+
the area's current count, lets a burn-down land in steps without letting the count rise.
|
|
99
|
+
|
|
100
|
+
Before a gate's fix text or a project rule names a replacement, check the replacement against
|
|
101
|
+
this skill's catalogue: a gate that sends people to the wrong form is followed faithfully.
|