bokata 2.0.1 → 3.0.0-beta.4
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/skills/bokata-acceptance-criteria/SKILL.md +6 -7
- package/.agents/skills/bokata-acceptance-criteria/resources/output-template-functional.md +3 -3
- package/.agents/skills/bokata-acceptance-criteria/resources/output-template.md +1 -1
- package/{commands/task-parallel/feature-map.md → .agents/skills/bokata-feature-map/SKILL.md} +79 -79
- package/.agents/skills/bokata-feature-map/resources/features-template.md +83 -0
- package/.agents/skills/bokata-feature-mapper/SKILL.md +4 -5
- package/.agents/skills/bokata-feature-mapper/resources/output-template.md +1 -1
- package/.agents/skills/bokata-feature-slicer/SKILL.md +176 -183
- package/.agents/skills/bokata-feature-slicer/resources/output-template-bites.md +21 -0
- package/.agents/skills/bokata-feature-slicer/resources/output-template-increments.md +9 -12
- package/.agents/skills/bokata-feature-slicer/resources/output-template-steps.md +6 -22
- package/.agents/skills/bokata-feature-slicer/resources/phase-2-increments.md +51 -79
- package/.agents/skills/bokata-feature-slicer/resources/phase-3-skeleton.md +152 -0
- package/.agents/skills/bokata-feature-slicer/resources/phase-4-bites.md +139 -0
- package/.agents/skills/bokata-plan/SKILL.md +110 -0
- package/.agents/skills/bokata-plan/resources/plan-template.md +35 -0
- package/.agents/skills/bokata-refactor/SKILL.md +69 -0
- package/.agents/skills/bokata-refactor/resources/smells.md +47 -0
- package/.agents/skills/bokata-refactor/resources/tidyings.md +31 -0
- package/.agents/skills/bokata-render/SKILL.md +68 -0
- package/.agents/skills/bokata-render/assets/story-map.html +428 -0
- package/.agents/skills/bokata-render/scripts/render.mjs +703 -0
- package/.agents/skills/bokata-shape/SKILL.md +117 -0
- package/.agents/skills/bokata-shape/resources/adr-template.md +24 -0
- package/.agents/skills/bokata-shape/resources/breadboarding.md +47 -0
- package/.agents/skills/bokata-shape/resources/pitch-template.md +42 -0
- package/.agents/skills/bokata-slice/SKILL.md +569 -0
- package/.agents/skills/bokata-slice/resources/inc-template.md +36 -0
- package/.agents/skills/bokata-slice/resources/slice-template.md +70 -0
- package/.agents/skills/bokata-status/SKILL.md +77 -0
- package/.agents/skills/bokata-tdd/SKILL.md +109 -0
- package/.agents/skills/bokata-tdd/resources/evidence-rules.md +27 -0
- package/LICENSE +21 -0
- package/README.md +224 -92
- package/agents/bokata-product-designer.md +49 -17
- package/agents/bokata-product-engineer.md +49 -16
- package/agents/bokata-product-manager.md +50 -18
- package/agents/code-executor.md +64 -0
- package/agents/design-reviewer.md +40 -0
- package/agents/feature-slicer.md +54 -0
- package/bin/bokata.js +40 -13
- package/package.json +20 -7
- package/src/agents.js +139 -0
- package/src/config.js +76 -0
- package/src/install.js +182 -205
- package/.agents/skills/bokata-feature-slicer/resources/phase-3-baby-steps.md +0 -311
- package/commands/codex/feature-map.md +0 -263
- package/commands/codex/slice-feature.md +0 -291
- package/commands/task-parallel/resources/html-template.md +0 -560
- package/commands/task-parallel/resources/story-map-template.md +0 -495
- package/commands/task-parallel/slice-feature.md +0 -301
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: bokata-refactor
|
|
3
|
+
description: Refactor safely in tiny behaviour-preserving moves — Kent Beck's four rules of simple design as the arbiter, Tidy First? tidyings, Fowler's code smells mapped to the move that fixes each, and coupling and cohesion as the reason to tidy. Use it in the refactor phase of a TDD step, before a step to make the change easy, when reviewing a diff for design, or when the user says refactor, tidy, clean up, code smell or simple design.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# bokata-refactor
|
|
7
|
+
|
|
8
|
+
A refactor changes **structure, never behaviour**. It is made of small moves, each one leaving
|
|
9
|
+
every test green, and it is committed apart from any behaviour change.
|
|
10
|
+
|
|
11
|
+
The project's constitution and coding standards (paths in `.bokata.json` → `memory`; defaults
|
|
12
|
+
`CONSTITUTION.md`, `CODING_STANDARDS.md`) win over everything here.
|
|
13
|
+
|
|
14
|
+
## The arbiter: four rules of simple design
|
|
15
|
+
|
|
16
|
+
Kent Beck's rules, in priority order. An earlier rule wins over a later one.
|
|
17
|
+
|
|
18
|
+
1. **Passes the tests.** Every test passes, guard tests included. Tests describe behaviour
|
|
19
|
+
from the scenarios, not the implementation: flag a test that asserts internals, a missing
|
|
20
|
+
edge case the scenario implies, or a test that would still pass if the code were wrong.
|
|
21
|
+
2. **Reveals intention.** Names come from the project's glossary and the scenarios, so a reader
|
|
22
|
+
understands the code without the plan. Vague names (`data`, `handle`, `util`, `tmp`),
|
|
23
|
+
functions that do two things, booleans that should be named states and magic numbers that
|
|
24
|
+
should be named constants all break it.
|
|
25
|
+
3. **No duplication.** Each piece of *knowledge* — a rule, a threshold, a shape, a mapping —
|
|
26
|
+
has one place, across every layer. Two lines that look alike but change for different
|
|
27
|
+
reasons are not duplication; leave them.
|
|
28
|
+
4. **Fewest elements.** Nothing the tests and the first three rules do not need: no unused
|
|
29
|
+
parameter, speculative option, single-use abstraction, wrapper layer, dead branch or file.
|
|
30
|
+
|
|
31
|
+
Stop when the code meets the four rules. Refactoring further is gold-plating.
|
|
32
|
+
|
|
33
|
+
## When to refactor
|
|
34
|
+
|
|
35
|
+
- **Before a step — make the change easy, then make the easy change.** If the next behaviour
|
|
36
|
+
would land awkwardly (scattered edits, a function that must grow a third branch), tidy
|
|
37
|
+
first, so the change itself is small.
|
|
38
|
+
- **After green** — the refactor phase of every TDD step.
|
|
39
|
+
- **Not otherwise.** Tidy what the current or next change touches. Code nobody is changing is
|
|
40
|
+
left alone (*tidy later* or *never*), however untidy it looks.
|
|
41
|
+
|
|
42
|
+
The reason to tidy is the cost of the next change, and that cost is **coupling**: elements that
|
|
43
|
+
must change together. Tidy toward **cohesion** — what changes together lives together — and
|
|
44
|
+
away from coupling across modules. If a tidying does not make a coming change cheaper or the
|
|
45
|
+
code easier to read now, skip it.
|
|
46
|
+
|
|
47
|
+
## How to move
|
|
48
|
+
|
|
49
|
+
1. Name what you see — the rule it breaks, or the smell from
|
|
50
|
+
[resources/smells.md](resources/smells.md) — and the move that fixes it.
|
|
51
|
+
2. Run the tests: they must be green before you start.
|
|
52
|
+
3. Make **one** move: a tidying from [resources/tidyings.md](resources/tidyings.md) or the
|
|
53
|
+
move the smell points to.
|
|
54
|
+
4. Run the tests. Green → next move. Red → **undo the move**; do not fix forward. A red test
|
|
55
|
+
during a refactor means behaviour changed, or the test is coupled to the implementation:
|
|
56
|
+
find out which and say so.
|
|
57
|
+
5. Commit structure on its own (`refactor(scope): …`), never mixed with `feat` or `fix`. If a
|
|
58
|
+
move needs a new test or widens behaviour, it is not a refactor: stop and treat it as a
|
|
59
|
+
step.
|
|
60
|
+
|
|
61
|
+
Keep moves small enough that undoing one costs nothing. Several moves can share one commit when
|
|
62
|
+
they serve one purpose.
|
|
63
|
+
|
|
64
|
+
## Principles, as evidence
|
|
65
|
+
|
|
66
|
+
SOLID, KISS, DRY, YAGNI and object calisthenics are not checked as rules on their own. Each one
|
|
67
|
+
shows up in the code as a smell; act on the smell you can point at, with
|
|
68
|
+
[resources/smells.md](resources/smells.md) as the map. A principle with no smell in the diff
|
|
69
|
+
is not a finding.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Smells and the moves that fix them
|
|
2
|
+
|
|
3
|
+
Each smell is a heuristic, never a hard violation: name it ("possible Feature Envy"), point at
|
|
4
|
+
the code, and propose the move. A documented project standard overrides any smell here.
|
|
5
|
+
Moves are Martin Fowler's (*Refactoring*); in functional code read "class" as "module" and
|
|
6
|
+
"method" as "function".
|
|
7
|
+
|
|
8
|
+
| Smell | What you see | Move |
|
|
9
|
+
|---|---|---|
|
|
10
|
+
| **Mysterious Name** | A name that does not say what it does or holds | Rename, using the glossary's word. No honest name comes? The design is murky — split it. |
|
|
11
|
+
| **Long Function** | You need comments or blank lines to follow it | Extract Function per chunk, named by intention |
|
|
12
|
+
| **Long Parameter List** | Many arguments, often passed through untouched | Introduce Parameter Object; or pass the whole value instead of its parts |
|
|
13
|
+
| **Duplicated Code** | The same knowledge in two places | Extract Function and call it from both; or Slide Statements until the shared shape shows |
|
|
14
|
+
| **Divergent Change** | One module edited for unrelated reasons | Split Phase, or Extract Module, so each changes for one reason |
|
|
15
|
+
| **Shotgun Surgery** | One change forces edits in many modules | Move Function / Combine into one module, so what changes together lives together |
|
|
16
|
+
| **Feature Envy** | A function works mostly on another module's data | Move Function next to the data it envies |
|
|
17
|
+
| **Data Clumps** | The same few values always travel together | Introduce Parameter Object or a type for the clump |
|
|
18
|
+
| **Primitive Obsession** | A string or number stands for a domain concept | Replace Primitive with a small type (value object, branded type) that owns its rules |
|
|
19
|
+
| **Repeated Switches** | The same `switch`/`if` chain on the same type in several places | One lookup map shared by both sites, or polymorphism |
|
|
20
|
+
| **Loops** | A loop that filters, maps and accumulates by hand | Replace Loop with Pipeline (`filter`/`map`/`reduce`) when it reads better |
|
|
21
|
+
| **Speculative Generality** | Parameters, hooks or abstractions for needs nobody has | Inline Function / Remove Parameter / Collapse Hierarchy |
|
|
22
|
+
| **Temporary Field** | A field or variable that is only set in some cases | Extract the case that uses it into its own function or type |
|
|
23
|
+
| **Message Chains** | `a.b().c().d()` the caller should not depend on | Hide Delegate: one function on the first object does the walk |
|
|
24
|
+
| **Middle Man** | A module that mostly forwards to another | Remove Middle Man; call the real target |
|
|
25
|
+
| **Mutable Data** | Shared state changed from several places | Encapsulate it, or return new values instead of mutating (copy-on-write) |
|
|
26
|
+
| **Global Data** | Anything can read or write it | Encapsulate it behind a function and narrow who can call it |
|
|
27
|
+
| **Comments** | A comment explains *what* the code does | Extract Function / Rename until the comment is redundant, then delete it. Keep comments that explain *why*. |
|
|
28
|
+
| **Refused Bequest** | An implementer ignores most of what it inherits | Replace inheritance with composition |
|
|
29
|
+
|
|
30
|
+
## Principles mapped to smells
|
|
31
|
+
|
|
32
|
+
| Principle | Look for |
|
|
33
|
+
|---|---|
|
|
34
|
+
| Single responsibility | Divergent Change, Long Function |
|
|
35
|
+
| Open/closed | Repeated Switches |
|
|
36
|
+
| Liskov | Refused Bequest |
|
|
37
|
+
| Interface segregation | Long Parameter List, a wide interface most callers use a sliver of |
|
|
38
|
+
| Dependency inversion | A dependency created inside instead of passed in at a seam |
|
|
39
|
+
| DRY | Duplicated Code — of *knowledge*, not of look-alike lines |
|
|
40
|
+
| KISS / YAGNI | Speculative Generality, rule 4 (fewest elements) |
|
|
41
|
+
| Coupling | Shotgun Surgery, Feature Envy, Message Chains, Global Data |
|
|
42
|
+
| Cohesion | Divergent Change, Data Clumps |
|
|
43
|
+
| Calisthenics: wrap primitives | Primitive Obsession |
|
|
44
|
+
| Calisthenics: first-class collections | Data Clumps around a collection, Repeated Switches over it |
|
|
45
|
+
| Calisthenics: one level of indentation, no `else` | Long Function → guard clauses, Extract Function |
|
|
46
|
+
| Calisthenics: no getters, tell don't ask | Feature Envy |
|
|
47
|
+
| Calisthenics: small entities | Long Function, Divergent Change |
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Tidyings
|
|
2
|
+
|
|
3
|
+
Kent Beck's tidyings (*Tidy First?*): the smallest structure changes, each safe on its own.
|
|
4
|
+
Reach for them first; most refactors are a few of these in a row.
|
|
5
|
+
|
|
6
|
+
| Tidying | Do it when |
|
|
7
|
+
|---|---|
|
|
8
|
+
| **Guard clauses** | Nested conditions hide the main path: return early on the edge cases |
|
|
9
|
+
| **Dead code** | Code nothing calls or no test needs: delete it (version control remembers) |
|
|
10
|
+
| **Normalize symmetries** | The same thing is done in two different ways: pick one and use it everywhere |
|
|
11
|
+
| **New interface, old implementation** | The interface you wish you had is missing: write it and call the old code from it |
|
|
12
|
+
| **Reading order** | A reader meets the parts in the wrong order: reorder them for the reader |
|
|
13
|
+
| **Cohesion order** | Elements that change together sit apart: move them next to each other |
|
|
14
|
+
| **Move declaration and initialization together** | A variable is declared far from where it gets its value |
|
|
15
|
+
| **Explaining variable** | A sub-expression needs a name to be understood |
|
|
16
|
+
| **Explaining constant** | A literal carries meaning (a limit, a threshold): name it |
|
|
17
|
+
| **Explicit parameters** | A function reads what it needs from a big bag or ambient state: pass it in |
|
|
18
|
+
| **Chunk statements** | A block does several things: separate the chunks with a blank line |
|
|
19
|
+
| **Extract helper** | A chunk has one purpose and a name: give it a function |
|
|
20
|
+
| **One pile** | Code is split so finely it can no longer be understood: inline it into one place first, then tidy again |
|
|
21
|
+
| **Explaining comment** | Something is not obvious from the code and cannot be made so: write down why |
|
|
22
|
+
| **Delete redundant comment** | A comment says what the code already says |
|
|
23
|
+
|
|
24
|
+
## Tidy first, after, later or never
|
|
25
|
+
|
|
26
|
+
- **First** — the tidying makes the next change cheaper and is quick.
|
|
27
|
+
- **After** — you will touch this code again soon, and now you understand it.
|
|
28
|
+
- **Later** — worth doing but not now: note it where the project tracks such work.
|
|
29
|
+
- **Never** — the code will not change again, or the tidying buys nothing.
|
|
30
|
+
|
|
31
|
+
Tidyings go in their own commit, separate from behaviour changes.
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: bokata-render
|
|
3
|
+
description: Render the initiative's story-map.html — one self-contained page with the map (Features and User Tasks as columns, one band of bite cards per increment, a Backlog band of untaken bites), a minimap, and a page per increment, bite, User Task and Feature — by running a script over features.md, slices/ and plan.md. Also validates that markdown (--check). Run by bokata-feature-map, bokata-slice, bokata-plan, bokata-status and code-executor whenever the markdown changes; no model is involved, so it is instant and always agrees with the markdown. Use it when the user asks to refresh, rebuild or validate the story map.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# bokata-render
|
|
7
|
+
|
|
8
|
+
`story-map.html` is a **derived file**: the markdown is the truth, a script draws the site. Same
|
|
9
|
+
markdown, same HTML. Nothing to edit by hand, nothing to keep in sync, and not worth committing
|
|
10
|
+
(add it to `.gitignore`).
|
|
11
|
+
|
|
12
|
+
## Run it
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
node .agents/skills/bokata-render/scripts/render.mjs <docs>/<initiative-slug>
|
|
16
|
+
# or, from a project with bokata installed: npx bokata render <docs>/<initiative-slug>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
`<docs>` is `docs` in `.bokata.json` (default `docs/initiatives`). It writes
|
|
20
|
+
`<docs>/<slug>/story-map.html` and prints one line:
|
|
21
|
+
`story-map.html updated (<done>/<total> increments, <done>/<total> steps, <n> bites left)`.
|
|
22
|
+
With `"story_map": false` in `.bokata.json` it renders nothing and says so. Options:
|
|
23
|
+
`--lang en|es` (the page's language, default `en`), `--date YYYY-MM-DD`, `--out <file>`.
|
|
24
|
+
|
|
25
|
+
**`--check`** parses everything with the same parser, prints every problem as `file:line: problem`
|
|
26
|
+
and writes nothing (exit 1 if there is any). `bokata-slice <nn> --check` runs it.
|
|
27
|
+
|
|
28
|
+
Run it in the foreground, after the markdown is final (a render takes milliseconds). If it exits
|
|
29
|
+
with an error, **show the user the `file:line: problem` it printed** and stop: the markdown broke
|
|
30
|
+
the contract below, fix the markdown, never the HTML.
|
|
31
|
+
|
|
32
|
+
## What the page shows
|
|
33
|
+
|
|
34
|
+
One file, no server: open it in a browser. Routes are in the URL hash.
|
|
35
|
+
|
|
36
|
+
- **Map** — a column per User Task under its Feature (zoom XS · S · M · L, fold a Feature into one
|
|
37
|
+
column, hide empty columns, minimap, filters by state and priority). Each slice is a stack of
|
|
38
|
+
**bands**, one per increment, holding the **bite cards** it took; a dashed band per proposed increment;
|
|
39
|
+
a **Backlog** band with the untaken bites by priority. Card colour = state (done, building, planned,
|
|
40
|
+
proposed, untaken).
|
|
41
|
+
- **Increment** (`#/inc/<slice>-<n>`) — "when it is done" (the outcome), what becomes possible, bites,
|
|
42
|
+
what is pending, the unknowns and, folded, the full detail of its `inc-<n>.md` (rules, Gherkin).
|
|
43
|
+
- **Bite** (`#/bite/<slice>-<id>`), **User Task** (`#/ut/<id>`: where it is covered in every slice) and
|
|
44
|
+
**Feature** (`#/feature/<code>`).
|
|
45
|
+
|
|
46
|
+
## What it reads
|
|
47
|
+
|
|
48
|
+
| File | Used for |
|
|
49
|
+
|---|---|
|
|
50
|
+
| `features.md` | `#### Feature: <name>` (+ `<!-- ID: … -->`) → header; `##### User Task: <name>` (+ `<!-- Task ID: … -->`) → one column each; `##### System Task …` → listed on the Feature page |
|
|
51
|
+
| `slices/<nn>-<name>.md` | the index: `- Status: open \| done`; `### Inc <n> — <name>` with `Outcome:` and `Bites:`; `## Backlog`: the bite lines and the `### Proposed increments` table |
|
|
52
|
+
| `slices/<nn>-<name>/slicing/F<k>.md` | `### User Task: <name>` and option lines `- F1-1.1 <name> — …` → which User Task each option (and so each bite) belongs to |
|
|
53
|
+
| `slices/<nn>-<name>/inc-<n>.md` | `- State: sliced \| planned \| done`, `Unknowns:`, the `Scenario:` lines, the `## Pending` list and the whole body for the Inc page |
|
|
54
|
+
| `plan.md` | `## Slice <nn>` → `### Inc <n>` and their `- [ ]` / `- [x]` boxes → *planned / building*, progress and the "Next" banner |
|
|
55
|
+
|
|
56
|
+
**State of an increment**: `State: done` in its `inc-<n>.md` (or a slice with `Status: done`) wins;
|
|
57
|
+
otherwise the steps in `plan.md` say planned / building / done; with no steps, its own `State` (sliced
|
|
58
|
+
by default). `plan.md` is temporary: when an Inc is done its section is deleted and nothing is lost.
|
|
59
|
+
|
|
60
|
+
A bite line is exactly the canonical one of `bokata-feature-slicer`
|
|
61
|
+
(`- **F1-a · <title>** (must-have) — F1-1.2 · depends on: … · value: … · check: …`; the skeleton
|
|
62
|
+
bites of Inc 1 are `F1-w1 … (skeleton) → Inc 1 — F1-1.1`). A bite is **taken** when an Inc lists it in
|
|
63
|
+
`Bites:` (its line then carries `→ Inc <n>`); an Inc with `Options:` and no `Bites:` (older slices) is
|
|
64
|
+
drawn as loose option cards. The tests in `test/render.test.js` (and `test/fixtures/initiative/`)
|
|
65
|
+
are the format specification.
|
|
66
|
+
|
|
67
|
+
The page is `assets/story-map.html` with the data of the initiative embedded; it is self-contained
|
|
68
|
+
(no external CSS, JS, fonts or images).
|