@newt-kit/plan 0.0.0-stage → 0.10.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 +35 -2
- package/cli/commands.ts +184 -0
- package/index.ts +14 -0
- package/map/app-map.ts +69 -0
- package/map/read-map.ts +453 -0
- package/package.json +53 -4
- package/plan/check.ts +154 -0
- package/plan/compare.ts +127 -0
- package/plan/diff.ts +50 -0
- package/plan/markdown.ts +50 -0
- package/plan/plan.schema.ts +75 -0
- package/plan/resolve.ts +314 -0
- package/plan/review.ts +34 -0
- package/render/browser.ts +16 -0
- package/render/page-data.ts +89 -0
- package/render/render.ts +38 -0
- package/render/template.html +888 -0
- package/skills/newt-plan/SKILL.md +88 -0
- package/skills/newt-review/SKILL.md +25 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: newt-plan
|
|
3
|
+
description: Use to plan a feature (a user story) of a newt application before writing it - split into steps, each a commit that leaves the application working - as a plan checked against the code and newt's rules and drawn as a page. Also when asked to "plan", "draw" or "map" what a story does to the application's modules, use cases and events.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Planning a story with @newt-kit/plan
|
|
7
|
+
|
|
8
|
+
What you write is the plan, a JSON file, and only what the story changes. The map (the
|
|
9
|
+
application as its code is) is read by `newt map`, never written. The page is always the
|
|
10
|
+
same: `newt map --plan` fills it. You never write or edit its HTML.
|
|
11
|
+
|
|
12
|
+
## 1. The story and where the plan goes
|
|
13
|
+
|
|
14
|
+
- The story comes as a file's path or as text. Read it whole.
|
|
15
|
+
- The plan's path is the person's: if they did not say it (`--out` or in words), ask
|
|
16
|
+
where to save it before writing anything. Never pick it yourself.
|
|
17
|
+
- Write the plan's words (title, whys, steps, rules) in the person's language, and set
|
|
18
|
+
`"language"` to it (`en` or `es`; any other, `en`).
|
|
19
|
+
|
|
20
|
+
## 2. Read what is there
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
bunx newt map --json > /tmp/map.json # in the application's folder (--tsconfig if not ./tsconfig.json)
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Read the modules the story touches (`*.module.ts`, `*.workers.ts`, `*.deps.ts`) and newt's
|
|
27
|
+
rules (`node_modules/@newt-kit/newt/AGENTS.md`): a plan that breaks them is wrong. Say the
|
|
28
|
+
map's warnings to the person if they matter to the story.
|
|
29
|
+
|
|
30
|
+
## 3. Write the plan, in steps
|
|
31
|
+
|
|
32
|
+
Split the story into steps the person could merge one by one: each a commit that compiles,
|
|
33
|
+
passes its tests and leaves the application working; the whole story is one branch and
|
|
34
|
+
one pull request. Few steps (2 to 6), each small, the first the smallest that works.
|
|
35
|
+
|
|
36
|
+
```jsonc
|
|
37
|
+
{
|
|
38
|
+
"version": 1,
|
|
39
|
+
"language": "es",
|
|
40
|
+
"title": "Abonar la factura de un pedido cancelado",
|
|
41
|
+
"subtitle": "Historia 12", // optional
|
|
42
|
+
"contexts": [], // { "name", "status": "new" | "removed" }
|
|
43
|
+
"modules": [ // new or removed ("status"); without status, only a why
|
|
44
|
+
{ "id": "sales/order", "why": "Su evento cancelled dispara el abono. No cambia." }
|
|
45
|
+
],
|
|
46
|
+
"pieces": [ // use cases, events, schedules: new, modified, removed
|
|
47
|
+
{ "id": "billing/invoice.creditFor", "kind": "useCase", "status": "new", "why": "…" },
|
|
48
|
+
{ "id": "billing/invoice.credited", "kind": "event", "status": "new" },
|
|
49
|
+
{ "id": "billing/invoice.nightly", "kind": "schedule", "status": "new", "cron": "0 3 * * *" }
|
|
50
|
+
],
|
|
51
|
+
"relations": [ // new or removed
|
|
52
|
+
{ "kind": "emits", "from": "billing/invoice.creditFor", "to": "billing/invoice.credited", "status": "new" },
|
|
53
|
+
{ "kind": "triggers", "from": "sales/order.cancelled", "to": "billing/invoice.creditFor", "status": "new" },
|
|
54
|
+
{ "kind": "calls", "from": "billing/invoice.creditFor", "to": "ports/mailer.send", "status": "new" }
|
|
55
|
+
],
|
|
56
|
+
"steps": [ // each a commit; a piece in braces is drawn as itself
|
|
57
|
+
{ "title": "La factura se abona", "text": "{billing/invoice.creditFor} la abona y emite {billing/invoice.credited}." },
|
|
58
|
+
{ "title": "Al cancelar un pedido, se abona", "text": "{sales/order.cancelled} dispara {billing/invoice.creditFor}." }
|
|
59
|
+
],
|
|
60
|
+
"rules": [ { "ok": true, "text": "creditFor dos veces no abona dos veces." } ] // checked by hand
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
- Ids are the map's: a module `<context>/<module>`, a piece `<context>/<module>.<name>`; an
|
|
65
|
+
event is its class's `eventName` (`invoice.credited`); a port is `ports/<field>.<method>`.
|
|
66
|
+
- `emits`: a use case to an event of its own module. `triggers`: an event or a schedule to
|
|
67
|
+
a use case (a worker). `calls`: a use case to another module's use case, or a port's.
|
|
68
|
+
- A step's pieces are those it names in braces (or its `focus`); a review finds the step
|
|
69
|
+
done when they, and the relations between them, are in the code.
|
|
70
|
+
- What touches a change but stays (an event it listens to, a use case it calls) is found,
|
|
71
|
+
not written. An existing use case that starts to emit or call is modified on its own.
|
|
72
|
+
|
|
73
|
+
## 4. Check it, until it fits
|
|
74
|
+
|
|
75
|
+
```sh
|
|
76
|
+
bunx newt map --plan <plan.json> --out <page.html>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
It exits with 1 for what the plan contradicts (a piece the code has not, a new one it
|
|
80
|
+
has, an event another module's use case emits…). Then it prints the rules: `!` is
|
|
81
|
+
something to change in the plan, or to tell the person why it stays.
|
|
82
|
+
|
|
83
|
+
## 5. The page, and its comments
|
|
84
|
+
|
|
85
|
+
Publish the page the command wrote exactly as it is, as an artifact with the `downloads`
|
|
86
|
+
capability (`capabilities: { downloads: true }`): its "Guardar plan" button saves the plan. Watch its comments: for each, change the plan (never
|
|
87
|
+
the page), check it again (step 4) and publish the new page to the same URL. Say in a
|
|
88
|
+
line what changed.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: newt-review
|
|
3
|
+
description: Use to review a branch of a newt application - what it adds, changes and takes away of modules, use cases, events and schedules, drawn as a page - and, with the story's plan, whether each step is done. Also when asked to check a pull request against its plan.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Reviewing a branch with @newt-kit/plan
|
|
7
|
+
|
|
8
|
+
`newt review` reads the code on disk and the code of a base (a branch, a tag), draws what
|
|
9
|
+
changed, checks newt's rules on it and, with a plan, holds the branch against it: each
|
|
10
|
+
thing done (✓), missing (✗), different (≠) or not planned (+), and each step done, half
|
|
11
|
+
done or not started, by what is in the code, not by the commits.
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
bunx newt review --base main --out review.html # what the branch changes
|
|
15
|
+
bunx newt review --base main --plan <plan.json> --out review.html # held against its plan
|
|
16
|
+
bunx newt review --base origin/main --plan <plan.json> --format markdown # for the pull request
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
- It exits with 1 when something is missing, different or not planned; `--warn-only` says it
|
|
20
|
+
and exits with 0. In CI, fetch the base (`fetch-depth: 0`).
|
|
21
|
+
- The plan's path is the person's: ask for it if they did not say it, never guess it.
|
|
22
|
+
- Publish the page as it is, as an artifact. It has a "Cargar plan" button: whoever opens it
|
|
23
|
+
can load a plan and see the branch held against it, with no command line.
|
|
24
|
+
- Read what it says to the person in a few lines: the steps' state, what is missing, what
|
|
25
|
+
was not planned and the rules marked `!`. Do not change code unless they ask.
|