@kurvball/ashlar 0.0.0-stage → 1.3.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.
Files changed (132) hide show
  1. package/CHANGELOG.md +238 -0
  2. package/LICENSE +21 -0
  3. package/README.md +145 -2
  4. package/dist/affected.d.ts +19 -0
  5. package/dist/affected.js +78 -0
  6. package/dist/areas.d.ts +2 -0
  7. package/dist/areas.js +20 -0
  8. package/dist/baseline.d.ts +27 -0
  9. package/dist/baseline.js +109 -0
  10. package/dist/beside.d.ts +1 -0
  11. package/dist/beside.js +4 -0
  12. package/dist/check.d.ts +39 -0
  13. package/dist/check.js +109 -0
  14. package/dist/cli.d.ts +2 -0
  15. package/dist/cli.js +211 -0
  16. package/dist/config.d.ts +84 -0
  17. package/dist/config.js +98 -0
  18. package/dist/configCheck.d.ts +2 -0
  19. package/dist/configCheck.js +204 -0
  20. package/dist/css.d.ts +13 -0
  21. package/dist/css.js +66 -0
  22. package/dist/drive.d.ts +77 -0
  23. package/dist/drive.js +188 -0
  24. package/dist/features.d.ts +32 -0
  25. package/dist/features.js +156 -0
  26. package/dist/git.d.ts +18 -0
  27. package/dist/git.js +140 -0
  28. package/dist/glob.d.ts +5 -0
  29. package/dist/glob.js +49 -0
  30. package/dist/graph.d.ts +16 -0
  31. package/dist/graph.js +83 -0
  32. package/dist/identity.d.ts +1 -0
  33. package/dist/identity.js +1 -0
  34. package/dist/index.d.ts +21 -0
  35. package/dist/index.js +18 -0
  36. package/dist/jsonc.d.ts +1 -0
  37. package/dist/jsonc.js +66 -0
  38. package/dist/knowledge/areas.d.ts +25 -0
  39. package/dist/knowledge/areas.js +86 -0
  40. package/dist/knowledge/decisions.d.ts +14 -0
  41. package/dist/knowledge/decisions.js +53 -0
  42. package/dist/knowledge/guards.d.ts +4 -0
  43. package/dist/knowledge/guards.js +60 -0
  44. package/dist/knowledge/rules.d.ts +12 -0
  45. package/dist/knowledge/rules.js +100 -0
  46. package/dist/knowledge/secrets.d.ts +6 -0
  47. package/dist/knowledge/secrets.js +58 -0
  48. package/dist/layout.d.ts +61 -0
  49. package/dist/layout.js +120 -0
  50. package/dist/ledger.d.ts +28 -0
  51. package/dist/ledger.js +44 -0
  52. package/dist/lint.d.ts +11 -0
  53. package/dist/lint.js +109 -0
  54. package/dist/map.d.ts +25 -0
  55. package/dist/map.js +37 -0
  56. package/dist/move.d.ts +18 -0
  57. package/dist/move.js +94 -0
  58. package/dist/onboard/applies.d.ts +11 -0
  59. package/dist/onboard/applies.js +28 -0
  60. package/dist/onboard/brief.d.ts +40 -0
  61. package/dist/onboard/brief.js +126 -0
  62. package/dist/onboard/guide.d.ts +7 -0
  63. package/dist/onboard/guide.js +150 -0
  64. package/dist/onboard/model.d.ts +15 -0
  65. package/dist/onboard/model.js +57 -0
  66. package/dist/onboard/onboard.d.ts +28 -0
  67. package/dist/onboard/onboard.js +86 -0
  68. package/dist/onboard/questions.d.ts +15 -0
  69. package/dist/onboard/questions.js +90 -0
  70. package/dist/onboard/snapshot.d.ts +28 -0
  71. package/dist/onboard/snapshot.js +58 -0
  72. package/dist/order.d.ts +1 -0
  73. package/dist/order.js +1 -0
  74. package/dist/origins.d.ts +6 -0
  75. package/dist/origins.js +51 -0
  76. package/dist/plugin/boundaries.d.ts +5 -0
  77. package/dist/plugin/boundaries.js +174 -0
  78. package/dist/plugin/exports.d.ts +2 -0
  79. package/dist/plugin/exports.js +41 -0
  80. package/dist/plugin/features.d.ts +4 -0
  81. package/dist/plugin/features.js +34 -0
  82. package/dist/plugin/here.d.ts +13 -0
  83. package/dist/plugin/here.js +69 -0
  84. package/dist/plugin/imports.d.ts +12 -0
  85. package/dist/plugin/imports.js +103 -0
  86. package/dist/plugin/index.d.ts +14 -0
  87. package/dist/plugin/index.js +19 -0
  88. package/dist/plugin/messages.d.ts +20 -0
  89. package/dist/plugin/messages.js +36 -0
  90. package/dist/plugin/names.d.ts +3 -0
  91. package/dist/plugin/names.js +68 -0
  92. package/dist/plugin/references.d.ts +5 -0
  93. package/dist/plugin/references.js +52 -0
  94. package/dist/plugin/text.d.ts +7 -0
  95. package/dist/plugin/text.js +87 -0
  96. package/dist/plugin/types.d.ts +87 -0
  97. package/dist/plugin/types.js +1 -0
  98. package/dist/reach.d.ts +82 -0
  99. package/dist/reach.js +163 -0
  100. package/dist/reachDrive.d.ts +31 -0
  101. package/dist/reachDrive.js +200 -0
  102. package/dist/reachReader.d.ts +1 -0
  103. package/dist/reachReader.js +31 -0
  104. package/dist/rehearse/dependents.d.ts +9 -0
  105. package/dist/rehearse/dependents.js +38 -0
  106. package/dist/rehearse/fill.d.ts +28 -0
  107. package/dist/rehearse/fill.js +44 -0
  108. package/dist/report.d.ts +6 -0
  109. package/dist/report.js +91 -0
  110. package/dist/resolve.d.ts +3 -0
  111. package/dist/resolve.js +114 -0
  112. package/dist/runner.d.ts +6 -0
  113. package/dist/runner.js +29 -0
  114. package/dist/skill.d.ts +23 -0
  115. package/dist/skill.js +235 -0
  116. package/dist/usage.d.ts +1 -0
  117. package/dist/usage.js +53 -0
  118. package/dist/workspace.d.ts +16 -0
  119. package/dist/workspace.js +125 -0
  120. package/ledger.json +201 -0
  121. package/package.json +73 -3
  122. package/schema/affected.v1.json +58 -0
  123. package/schema/brief.v1.json +205 -0
  124. package/schema/check.v1.json +151 -0
  125. package/schema/dependents.v1.json +30 -0
  126. package/schema/drive.v1.json +55 -0
  127. package/schema/ledger.v1.json +61 -0
  128. package/schema/map.v1.json +62 -0
  129. package/schema/move.v1.json +61 -0
  130. package/schema/onboard.v1.json +186 -0
  131. package/schema/rehearse.v1.json +91 -0
  132. package/schema/snapshot.v1.json +101 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,238 @@
1
+ # Changelog
2
+
3
+ Every change a user would notice is written down here, newest first, and Ashlar uses
4
+ [semantic versioning](https://semver.org/spec/v2.0.0.html). From 1.0.2 on, each version's entries are the
5
+ changesets merged since the release before it, under its version and release date, grouped as major, minor
6
+ and patch changes; see [RELEASING.md](RELEASING.md). Versions up to 1.0.1 follow
7
+ [Keep a Changelog 1.1.0](https://keepachangelog.com/en/1.1.0/).
8
+
9
+ ## 1.3.0
10
+
11
+ _Released 2026-12-04._
12
+
13
+ ### Minor Changes
14
+
15
+ - Ashlar is on npm as `@kurvball/ashlar`: install it with `pnpm add -D @kurvball/ashlar`. Each version is published by the release workflow through npm's trusted publishing, with provenance naming the commit and the run that built it. Every install instruction in the README and the docs now uses npm.
16
+
17
+ ## 1.2.2
18
+
19
+ _Released 2026-12-04._
20
+
21
+ ### Patch Changes
22
+
23
+ - Ashlar's tests check what `ashlar dependents --json` and `ashlar rehearse --json` print against Rehearse 1.2.0's schemas, whose `$id`s are now on `https://rehearse.kurvball.ca/schema/v1/`.
24
+ - The docs and README link Rehearse, now public: its repository, and the page of its docs that each mention needs, from the Rehearse guide to the reference.
25
+
26
+ ## 1.2.1
27
+
28
+ _Released 2026-12-04._
29
+
30
+ ### Patch Changes
31
+
32
+ - The docs gain Recipes (run the check in GitHub Actions, give a library or a CLI its areas, keep fetch calls in the client), a title on every code block, and samples that a test runs. CI checks the docs' voice rules, and fails a major change that has no upgrade-guide entry.
33
+ - The docs follow Kurvball's docs standard: a sidebar in five groups (Start, Learn, Do, Look up, For agents), a short Get started and a Tutorial, an Agent skill page with llms.txt for agents, an Edit page link on every page, the documented version in the header, and a type on every page that the docs build checks.
34
+ - Every reference entry in the docs says the version it arrived in: each command, config key, JSON output and later JSON field. A new one reads "unreleased" until the release that ships it.
35
+
36
+ ## 1.2.0
37
+
38
+ _Released 2026-12-04._
39
+
40
+ ### Minor Changes
41
+
42
+ - `ashlar --version` prints the version that runs. `ashlar check` warns on stderr when an app's main side has files but none sits in a service area, where public-api-only used to count zero in silence (for example `main: ['.']` with the default areas). The adoption guide installs from the release's address and covers libraries and CLIs, a `fetch` bridge, counts and breaks, which branch a change is compared with, retaking the baseline, and the onboarding guide.
43
+
44
+ ## 1.1.3
45
+
46
+ _Released 2026-12-04._
47
+
48
+ ### Patch Changes
49
+
50
+ - The docs moved to https://ashlar.kurvball.ca, and package.json's homepage points there.
51
+
52
+ ## 1.1.2
53
+
54
+ _Released 2026-12-03._
55
+
56
+ ### Patch Changes
57
+
58
+ - Ashlar is MIT-licensed, copyright Kurvball. Contributing says what is likely to be accepted and where each request goes (questions and ideas to Discussions), with an AI policy, reply times, a private address for security and conduct reports (oss@kurvball.ca), and a supported-versions rule.
59
+
60
+ ## 1.1.1
61
+
62
+ _Released 2026-12-03._
63
+
64
+ ### Patch Changes
65
+
66
+ - The docs are on GitHub Pages at https://kurvball.github.io/ashlar/, and package.json's homepage points there. Every docs build checks each internal link and anchor of the built site.
67
+
68
+ ## 1.1.0
69
+
70
+ _Released 2026-12-03._
71
+
72
+ ### Minor Changes
73
+
74
+ - The package is now `@kurvball/ashlar`, made by Kurvball (https://www.kurvball.ca), and its repository is https://github.com/kurvball/ashlar. Import from `@kurvball/ashlar` and `@kurvball/ashlar/reach`, and install the tarball `kurvball-ashlar-<version>.tgz`. The command stays `ashlar`.
75
+
76
+ ### Patch Changes
77
+
78
+ - The docs, examples and changelog no longer name the private app Ashlar was first built in, and lead with Kurvball (https://www.kurvball.ca). CI fails when a file names a private project.
79
+
80
+ ## 1.0.2
81
+
82
+ _Released 2026-12-03._
83
+
84
+ ### Patch Changes
85
+
86
+ - A release pipeline: Changesets, a release workflow that tags, writes the GitHub Release and attaches the packed tarball, and RELEASING.md for releases and hotfixes.
87
+
88
+ ## [1.0.1] - 2026-12-03
89
+
90
+ ### Fixed
91
+
92
+ - `ashlar drive` through Rehearse sends `rehearse drive start` after its first `stop`, as Rehearse's drive
93
+ needs, and takes a first `stop` that finds nothing driven (`not_running`) as nothing to stop, not as a drive
94
+ Rehearse lacks. A failed `start` says what Rehearse said, gives it three minutes, and stops anything it
95
+ left; a first `stop` that Rehearse answers at all lets the walk go on.
96
+ - Checked against Rehearse 0.3.0's own `drive`: a reach walked to its end, a step that failed stopped with
97
+ Rehearse's words, and a project with no service said why `start` couldn't start it.
98
+
99
+ ## [1.0.0] - 2026-12-03
100
+
101
+ Ashlar fills Rehearse's blocks, and driving moves to Rehearse. Kurvball and a second, private app both run on
102
+ this version from scratch clones.
103
+
104
+ ### Added
105
+
106
+ - `ashlar dependents <files...> --json`: every file that reaches each file through imports, and the reach
107
+ script of each feature those files sit in, in Rehearse's `dependents` contract. Rehearse runs it for
108
+ `rehearse list --affected` whenever a project has `ashlar.config.*` and an `ashlar` binary.
109
+ - `ashlar affected --json` lists the features a change reaches (`features`), each with the reach script
110
+ Rehearse runs as its flow.
111
+ - `ashlar rehearse [--json]`: the blocks of `rehearse.yaml` Ashlar fills. Each feature's reach script is a
112
+ flow that covers its feature's folder; `--json` adds each flow as Rehearse's flow schema reads it.
113
+ - Gotchas guarded by Rehearse: a scenario named `*.guard.flow.yaml` or `*.guard.rehearse.yaml` is a gotcha of
114
+ its folder in the guide and in briefs (`onboard.guards` names other patterns), and a folder rule can point
115
+ at its guard with `guard:` in its frontmatter.
116
+ - `onboard.guards` in the config, and `guard` on each folder rule in the `onboard` and `brief` JSON (null when
117
+ there is none).
118
+ - `schema/dependents.v1.json` and `schema/rehearse.v1.json`, for the two commands that answer to Rehearse.
119
+ - Rehearse's v1 schemas, vendored in `test/fixtures/rehearse/`, and tests that validate both commands'
120
+ output against them.
121
+ - A guide, "Use Ashlar with Rehearse".
122
+
123
+ ### Changed
124
+
125
+ - Driving moves to Rehearse. With a `rehearse.yaml` and no `drive` in the config, `ashlar drive` walks a
126
+ reach through `rehearse drive`, and says plainly when Rehearse can't answer yet; the verify skill gives a
127
+ project that rehearses Rehearse's own drive steps. A `drive` in the config still wins, so a project keeps its
128
+ own until it chooses Rehearse's. Rehearse reads flows and answers `drive` from its 0.3.0; today it reads
129
+ Ashlar's graph for `list --affected`.
130
+ - Both examples' `prove.sh` run the adapter and validate its output against Rehearse's schemas, and every
131
+ other answer against Ashlar's own.
132
+
133
+ ## [0.4.0] - 2026-12-03
134
+
135
+ Kurvball and a second, private app, run on Ashlar and documented.
136
+
137
+ ### Added
138
+
139
+ - The private app's example says what that app changes to take this version: its imports, its dependency,
140
+ its framework detection, its rule messages, its verify skill's attach section and its onboarding owner.
141
+ - `examples/kurvball/README.md` says what the map, `onboard` and briefs show for an API and a worker with no
142
+ renderer, and how Ashlar sits beside Kurvball's own architecture gate.
143
+ - The docs' example pages give every command's answer on each clone, onboarding included.
144
+ - Both `prove.sh` validate every answer against Ashlar's own schemas (`examples/validate.mjs`), and the
145
+ private app's fails if any rule's count is above zero, as that app keeps no baseline.
146
+ - Kurvball's config leaves generated code out (`generated` in `ignore`).
147
+
148
+ ## [0.3.0] - 2026-12-03
149
+
150
+ The docs site, and the JSON contract every command prints.
151
+
152
+ ### Added
153
+
154
+ - A docs site in `docs/`, built with Astro Starlight: an overview, a quickstart, concepts (rules, the
155
+ ratchet, the feature map, corrections, onboarding), guides, a reference (the CLI, the config, the JSON
156
+ outputs), the examples, the agent skills and this changelog. `pnpm docs:build` fails on
157
+ any warning or broken link, and CI runs it.
158
+ - A JSON Schema for each command's `--json` output in `schema/`, shipped in the package as
159
+ `<package>/schema/<name>.v1.json`. A test runs each command and validates what it prints.
160
+ - The CLI reference, the JSON reference and the changelog page are generated from the usage text, the
161
+ schemas and this file, so they can't drift. A test checks that the config reference names every key.
162
+
163
+ ### Changed
164
+
165
+ - `check`, `affected`, `move` and `drive` now print a `version`, as `ledger` and `map` did. The field is new;
166
+ nothing else in their output changed.
167
+
168
+ ## [0.2.0] - 2026-12-03
169
+
170
+ Onboarding: the knowledge people and agents need about a codebase, from one source.
171
+
172
+ ### Added
173
+
174
+ - `DECISIONS.md`: one line per decision a person made, with its date, owner, areas and kind (`decision`,
175
+ `rule`, `trust`, `access`, `owner` or `setup`). A line that doesn't parse is an error naming its line.
176
+ - Folder rules in `.claude/rules/*.md`, scoped by Claude Code's `paths:` frontmatter, with an optional
177
+ `gotcha`, `owner` and `date`.
178
+ - `ashlar onboard` writes a guide from the map, the decisions and the rules: what the system is, a page per
179
+ area, and every unknown as a `TODO(@owner)` question routed to its owner. `--check` fails when the guide is
180
+ stale or was edited by hand; `--json` prints its model, questions included.
181
+ - `ashlar brief <paths...>` prints only what an agent needs for those files: the data rules, the rules that
182
+ apply there, the folder rules and gotchas, the decisions (never `access` lines), the features and the open
183
+ questions.
184
+ - `ashlar snapshot` prints where things stand today. It writes nothing.
185
+ - `ashlar skill onboard`: read your brief before you change files, and keep what people decide.
186
+ - `onboard` in the config: `out`, `decisions`, `rules`, `owner`, `owners`, `areas`, `documents` and
187
+ `dataRules`.
188
+ - A knowledge file that holds something shaped like a secret is refused, naming its file and line.
189
+ - Ashlar onboards itself: its `DECISIONS.md`, two folder rules and its guide in `onboarding/`, checked by
190
+ `pnpm lint`. Both examples onboard their clones.
191
+
192
+ ## [0.1.0] - 2026-12-03
193
+
194
+ Ashlar installs and runs on its own, from a packed tarball.
195
+
196
+ ### Added
197
+
198
+ - The config is checked as it loads: an unknown key or a value of the wrong type gets one line naming the key,
199
+ and every problem is listed at once.
200
+ - Ashlar also reads `ashlar.config.mts`, `ashlar.config.js` and `ashlar.config.mjs`.
201
+ - `rules` in the config turns a rule off for the whole project, as in `rules: { 'no-comment': 'off' }`. No
202
+ comment in code can.
203
+ - `messages` in the config replaces the message a rule prints.
204
+ - Each stack names the packages that reach the other side, and `client-only` and `shared-is-pure` use them:
205
+ `electron` for Electron, `@tauri-apps/api` and `@tauri-apps/plugin-*` for Tauri, none for web. An app's
206
+ `bridge.packages` replaces them.
207
+ - An app may have no renderer (`renderer: []`), as an API has none.
208
+ - `skills.verify.attach` in the config names a file whose text becomes the verify skill's attach section.
209
+ Without one, the skill asks the agent to name its screens and video in its report.
210
+ - Ashlar checks its own source with its own rules (`pnpm lint`), and a test keeps the names of the projects
211
+ that use it out of its source.
212
+ - A test pins the names each entry point exports.
213
+ - `examples/`: two projects' `ashlar.config.ts`, each with a `prove.sh` that runs Ashlar on a scratch clone
214
+ of it. One also seeds one break per rule and checks each fires.
215
+ - A smoke test (`pnpm smoke`) packs Ashlar, installs the tarball in a fresh project and runs its commands there.
216
+ - Open-source files: this changelog, a README, CONTRIBUTING, a Code of Conduct, a security policy, issue
217
+ templates and a pull request template.
218
+ - CI on GitHub Actions.
219
+
220
+ ### Changed
221
+
222
+ - The package is renamed from its name inside the app it came from to `ashlarjs`. The command stays `ashlar`.
223
+ Imports read `from 'ashlarjs'` and `from 'ashlarjs/reach'`.
224
+ - Ashlar builds to `dist/`, JavaScript with type declarations, and the `ashlar` bin and the exports point
225
+ there.
226
+ - `ledger.json` moved to the package root, and the package exports it as `<package>/ledger.json`.
227
+ - Rule messages no longer name the hooks of the app Ashlar came from.
228
+ - The verify skill ends at screens and a video. That app's own attach section moved to its example.
229
+ - Where a project has no lockfile Ashlar knows, the skill runs `npx --no-install ashlar`, never a bare
230
+ `npx ashlar`, which would fetch an unrelated package. With Bun it runs `bun run ashlar`.
231
+
232
+ ### Removed
233
+
234
+ - The Electron stack's default builds (`test/ui/**` and `*.electron.test.ts`). A config states its builds.
235
+
236
+ ## [0.0.0] - 2026-12-03
237
+
238
+ Extracted, with its history, from the app it was first built in.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kurvball
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 CHANGED
@@ -1,3 +1,146 @@
1
- # Temporary Holding Version
1
+ # Ashlar
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Ashlar is the rules for designing and building software with agents. It lints a TypeScript repository and
4
+ reads its import graph, and it keeps a baseline of each file's breaks that may only shrink: old code stays as
5
+ it is, and no file gets worse. Every rule comes from a correction a person made, and each tells the agent what
6
+ to do instead.
7
+
8
+ [Docs](https://ashlar.kurvball.ca) · [Contributing](CONTRIBUTING.md) · [Security](SECURITY.md) ·
9
+ [Changelog](CHANGELOG.md)
10
+
11
+ Questions and ideas go to [Discussions](https://github.com/kurvball/ashlar/discussions); bugs go to
12
+ [issues](https://github.com/kurvball/ashlar/issues/new/choose).
13
+
14
+ ## An example
15
+
16
+ `ashlar.config.ts`, at the root of a repository:
17
+
18
+ ```ts
19
+ import { defineConfig } from '@kurvball/ashlar';
20
+
21
+ export default defineConfig({
22
+ include: ['src'],
23
+ });
24
+ ```
25
+
26
+ Someone adds a comment to `src/total.ts`:
27
+
28
+ ```ts
29
+ // Adds up the prices in the cart.
30
+ export function total(prices: number[]): number {
31
+ return prices.reduce((sum, price) => sum + price, 0);
32
+ }
33
+ ```
34
+
35
+ ```console
36
+ $ pnpm exec ashlar check
37
+ Ashlar checked 1 file in 0.1 s: 1 count rose.
38
+
39
+ no-comment in src/total.ts: 1, up from 0
40
+ src/total.ts:1:1
41
+ Comments go stale and nothing checks them. Rename it, or write a test. Git leads from any line to the item or task that wrote it.
42
+ ```
43
+
44
+ The check exits with 1. The last line is the message the agent reads.
45
+
46
+ The example has no baseline, so every count must stay at zero. In a repository that already has breaks,
47
+ `ashlar check --shrink` takes the baseline the first time (`ashlar.baseline.json`). From then on, `check` fails
48
+ when a file's count rises above what the baseline holds for it, and `--shrink` only ever lowers it.
49
+
50
+ ## Install
51
+
52
+ Install Ashlar from npm, as a dev dependency:
53
+
54
+ ```sh
55
+ pnpm add -D @kurvball/ashlar
56
+ pnpm exec ashlar check
57
+ ```
58
+
59
+ With npm, `npm install -D @kurvball/ashlar`, then `npx --no-install ashlar check`. Each version is published by
60
+ Ashlar's release workflow with [provenance](https://docs.npmjs.com/generating-provenance-statements): its npm
61
+ page names the commit and the workflow run that built it. To try an unreleased change, `pnpm pack` this
62
+ repository and install the tarball from a folder of your project:
63
+ [Adopt Ashlar](https://ashlar.kurvball.ca/guides/adopt/) says how.
64
+
65
+ Never run a bare `npx ashlar`. A package named `ashlar` on npm is someone else's, and `npx` would download and
66
+ run it. Use `pnpm exec ashlar`, `yarn ashlar` or `npx --no-install ashlar`.
67
+
68
+ Ashlar needs Node 22.18 or later, which reads `ashlar.config.ts` without a build step, and Git. It checks
69
+ TypeScript. Its stacks are `electron`, `tauri` and `web`.
70
+
71
+ ## A config for an app
72
+
73
+ ```ts
74
+ import { defineConfig } from '@kurvball/ashlar';
75
+
76
+ export default defineConfig({
77
+ include: ['apps', 'packages'],
78
+ apps: [{ root: 'apps/desktop', stack: 'tauri' }],
79
+ rules: { 'no-dom-query': 'off' },
80
+ messages: { 'no-timer': 'Use `useClock` from `primitives/` instead of a timer.' },
81
+ });
82
+ ```
83
+
84
+ Each app names its stack, and the stack says where its sides live, such as `src/` and `src-tauri/` for Tauri.
85
+ An app's config can name other folders. `rules` turns a rule off for the whole project, since no comment in
86
+ code can. `messages` replaces the message agents read for a rule. A key Ashlar doesn't know, or a value of the
87
+ wrong type, gets one line saying which key and what is wrong.
88
+
89
+ ## Commands
90
+
91
+ | Command | What it does |
92
+ | ---------------------------- | --------------------------------------------------------------------------------------- |
93
+ | `ashlar check` | Fails when a file's count rises above the baseline. `--shrink` lowers it. |
94
+ | `ashlar affected <files...>` | Lists the tests that reach the files. `--since <ref>` takes a branch's changes. |
95
+ | `ashlar move <from> <to>` | Moves a file's or a folder's counts in the baseline to its new name. |
96
+ | `ashlar ledger` | Lists each rule, the correction it came from, its case and its message. |
97
+ | `ashlar map` | Lists each feature folder, its reach script and its tests. |
98
+ | `ashlar drive <feature>` | Walks a feature's reach script through the config's drive command, or `rehearse drive`. |
99
+ | `ashlar skill verify` | Prints the skill an agent follows to check its own work. |
100
+ | `ashlar onboard` | Writes the onboarding guide, with every unknown as a question for its owner. |
101
+ | `ashlar brief <paths...>` | Prints only what an agent needs before it changes those files. |
102
+ | `ashlar snapshot` | Prints where things stand today, and keeps nothing. |
103
+ | `ashlar skill onboard` | Prints the skill an agent follows to read its brief and keep decisions. |
104
+ | `ashlar dependents <files>` | Lists what reaches each file, for Rehearse's `rehearse list --affected`. |
105
+ | `ashlar rehearse` | Prints the blocks of `rehearse.yaml` Ashlar fills: each reach script a flow. |
106
+
107
+ A feature's reach script, `reach.ts` in its folder, lists the steps a person takes to get to it in the running
108
+ app. `affected` follows imports, stylesheets, setup files and builds. `skill verify --write` writes the skill
109
+ to `.claude/skills/verify/SKILL.md`.
110
+
111
+ Every command but `skill` takes `--json`, for tools that read Ashlar. `ashlar help` prints the full usage.
112
+ Ashlar exits with 0 when all is well, 1 when a check or a drive fails, and 2 when a command or the config is
113
+ wrong.
114
+
115
+ ## Who uses it
116
+
117
+ [Kurvball](https://www.kurvball.ca), where a team agrees on what to build, runs Ashlar on its repository: a
118
+ Tauri desktop app, a Fastify API and a worker, beside Kurvball's own architecture gate.
119
+ [examples/kurvball/](examples/kurvball/) holds its config, two reach scripts and the script that proves it on a
120
+ scratch clone. Kurvball's repository is private, so that script runs only with access to it.
121
+
122
+ Other tools read Ashlar only through the commands that print JSON.
123
+ [Rehearse](https://github.com/kurvball/rehearse), which tries a change on the running product, is one: see
124
+ [Use Ashlar with Rehearse](https://ashlar.kurvball.ca/guides/rehearse/), and
125
+ [Rehearse's docs](https://rehearse.kurvball.ca/).
126
+
127
+ ## The name
128
+
129
+ The project is Ashlar, and its command is `ashlar`. Its package is `@kurvball/ashlar`: Ashlar is made by
130
+ [Kurvball](https://www.kurvball.ca) and ships under Kurvball's scope. It is not published to npm yet.
131
+
132
+ ## More
133
+
134
+ - [CONTRIBUTING.md](CONTRIBUTING.md): how to set up, the house rules, and how changes merge.
135
+ - [The docs](https://ashlar.kurvball.ca), built from [docs/](docs/) with Astro Starlight and served
136
+ by GitHub Pages. Run `pnpm docs:dev` to read them locally, or `pnpm docs:build` to build them.
137
+ - [CHANGELOG.md](CHANGELOG.md): what each version added, changed and removed.
138
+ - [RELEASING.md](RELEASING.md): how a change gets its changeset, and how a release and a hotfix go.
139
+ - [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md), [SECURITY.md](SECURITY.md) and [AI_POLICY.md](AI_POLICY.md).
140
+
141
+ ## Licence
142
+
143
+ MIT, copyright 2026 Kurvball: see [LICENSE](LICENSE).
144
+
145
+ The licence covers the code, not the names. A project that uses "Ashlar" or "Kurvball" in its name says that
146
+ it isn't made by Kurvball or affiliated with it.
@@ -0,0 +1,19 @@
1
+ import type { Loaded } from './config.ts';
2
+ export interface AffectedFeature {
3
+ folder: string;
4
+ reach: string | null;
5
+ }
6
+ export interface AffectedReport {
7
+ changed: string[];
8
+ deleted: string[];
9
+ tests: string[];
10
+ features: AffectedFeature[];
11
+ unreached: string[];
12
+ seconds: number;
13
+ }
14
+ export interface AffectedOptions {
15
+ files: string[];
16
+ since?: string;
17
+ cwd?: string;
18
+ }
19
+ export declare function affected(config: Loaded, options: AffectedOptions): AffectedReport;
@@ -0,0 +1,78 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { join, relative, resolve } from 'node:path';
3
+ import { featureFolders } from './features.js';
4
+ import { atRef, changedSince, hasHead, mergeBase } from './git.js';
5
+ import { anyOf } from './glob.js';
6
+ import { dependents, graphOf, helpersOf } from './graph.js';
7
+ import { tidy, within } from './layout.js';
8
+ import { REACH_FILE } from './reach.js';
9
+ function buildsOf(config) {
10
+ return config.apps.flatMap((app) => app.builds.map((build) => ({
11
+ tests: anyOf(build.tests),
12
+ reach: anyOf(build.reach),
13
+ names: new Set(build.reach),
14
+ })));
15
+ }
16
+ function graphAtBase(config, since) {
17
+ const base = since ? mergeBase(config.root, since) : hasHead(config.root) ? 'HEAD' : null;
18
+ return base === null ? null : atRef(config, base, (tree) => graphOf(tree.config));
19
+ }
20
+ export function affected(config, options) {
21
+ const started = performance.now();
22
+ const cwd = options.cwd ?? process.cwd();
23
+ const changed = new Set(options.files.map((file) => tidy(relative(config.root, resolve(cwd, file)))));
24
+ if (options.since)
25
+ for (const file of changedSince(config.root, options.since))
26
+ changed.add(file);
27
+ const sorted = [...changed].sort();
28
+ const isTest = (path) => config.tests.some((suffix) => path.endsWith(suffix));
29
+ const exists = (path) => existsSync(join(config.root, path));
30
+ const deleted = sorted.filter((file) => !exists(file));
31
+ const checked = (file) => config.include.some((folder) => within(file, folder));
32
+ const now = graphOf(config);
33
+ const before = deleted.some(checked) ? graphAtBase(config, options.since) : null;
34
+ const helper = helpersOf(config);
35
+ const builds = buildsOf(config);
36
+ const takesIn = (build, path) => !isTest(path) && (helper(path) ? build.names.has(path) : build.reach(path));
37
+ const built = new Map();
38
+ const testsOf = (build) => {
39
+ let known = built.get(build);
40
+ if (!known) {
41
+ known = [...now.files].filter((file) => isTest(file) && build.tests(file));
42
+ built.set(build, known);
43
+ }
44
+ return known;
45
+ };
46
+ const tests = new Set();
47
+ const unreached = [];
48
+ const folders = featureFolders(config);
49
+ const touched = new Set();
50
+ for (const file of sorted) {
51
+ const gone = !exists(file);
52
+ const graph = gone ? before : now;
53
+ const reached = graph ? dependents(file, graph) : new Set([file]);
54
+ for (const folder of folders)
55
+ if ([...reached].some((path) => within(path, folder)))
56
+ touched.add(folder);
57
+ const found = [...reached].filter((path) => isTest(path) && exists(path));
58
+ for (const build of builds) {
59
+ if ([...reached].some((path) => takesIn(build, path)))
60
+ found.push(...testsOf(build));
61
+ }
62
+ if (found.length === 0 && !gone)
63
+ unreached.push(file);
64
+ for (const test of found)
65
+ tests.add(test);
66
+ }
67
+ return {
68
+ changed: sorted,
69
+ deleted,
70
+ tests: [...tests].sort(),
71
+ features: [...touched].sort().map((folder) => {
72
+ const reach = `${folder}/${REACH_FILE}`;
73
+ return { folder, reach: exists(reach) ? reach : null };
74
+ }),
75
+ unreached,
76
+ seconds: (performance.now() - started) / 1000,
77
+ };
78
+ }
@@ -0,0 +1,2 @@
1
+ import { type AppLayout } from './layout.ts';
2
+ export declare function areaWarnings(apps: readonly AppLayout[], files: readonly string[]): string[];
package/dist/areas.js ADDED
@@ -0,0 +1,20 @@
1
+ import { placeOf, unitOf } from './layout.js';
2
+ export function areaWarnings(apps, files) {
3
+ const all = [...apps];
4
+ return all.flatMap((app, index) => {
5
+ if (app.areas.length === 0)
6
+ return [];
7
+ const main = files.filter((file) => {
8
+ const place = placeOf(file, all);
9
+ return place.app === app && place.process === 'main';
10
+ });
11
+ if (main.length === 0 || main.some((file) => unitOf(file, app.areas) !== null))
12
+ return [];
13
+ const patterns = app.areas.map((area) => `\`${area}\``).join(', ');
14
+ return [
15
+ `apps[${index}] (${app.root || '.'}): none of its ${main.length} main-side files is in a service area, so ` +
16
+ `public-api-only counts nothing there. Its areas, ${patterns}, match none of them. Name them in ` +
17
+ "`areas`, such as `areas: ['*']` for each folder of the app's root, or give `areas: []` to say it has none.",
18
+ ];
19
+ });
20
+ }
@@ -0,0 +1,27 @@
1
+ import type { FileFindings } from './plugin/types.ts';
2
+ export type Counts = Record<string, Record<string, number>>;
3
+ export interface Rise {
4
+ rule: string;
5
+ file: string;
6
+ count: number;
7
+ baseline: number;
8
+ }
9
+ export declare const BASELINE_WORDS: {
10
+ readonly unreadable: (file: string, why: string) => string;
11
+ readonly perFolder: (file: string) => string;
12
+ };
13
+ export declare function add(counts: Counts, rule: string, file: string, size: number): void;
14
+ export declare function countsOf(files: Record<string, FileFindings>): Counts;
15
+ export declare function totalOf(counts: Counts, rule: string): number;
16
+ export declare function isPerFolder(counts: Counts): boolean;
17
+ export declare function readBaseline(file: string): Counts | null;
18
+ export declare function tidyCounts(counts: Counts): Counts;
19
+ export declare function writeBaseline(file: string, counts: Counts): boolean;
20
+ export declare function risesOf(counts: Counts, baseline: Counts): Rise[];
21
+ export declare function slackOf(counts: Counts, baseline: Counts): number;
22
+ export declare function shrunk(counts: Counts, baseline: Counts | null): Counts;
23
+ export declare function carried(baseline: Counts, renamed: readonly {
24
+ from: string;
25
+ to: string;
26
+ }[]): Counts;
27
+ export declare function holdsAny(baseline: Counts, file: string): boolean;
@@ -0,0 +1,109 @@
1
+ import { existsSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
2
+ import { AshlarError } from './config.js';
3
+ const READ = /\.(?:[cm]?[jt]sx?|vue|svelte|astro)$/;
4
+ export const BASELINE_WORDS = {
5
+ unreadable: (file, why) => `${file} isn't readable JSON: ${why}`,
6
+ perFolder: (file) => `${file} holds its counts per folder, and Ashlar now holds them per file. Take it again: delete it and run \`ashlar check --shrink\`.`,
7
+ };
8
+ export function add(counts, rule, file, size) {
9
+ const files = (counts[rule] ??= {});
10
+ files[file] = (files[file] ?? 0) + size;
11
+ }
12
+ export function countsOf(files) {
13
+ const counts = {};
14
+ for (const [file, findings] of Object.entries(files)) {
15
+ for (const found of findings.breaks)
16
+ add(counts, found.rule, file, found.size);
17
+ }
18
+ return counts;
19
+ }
20
+ export function totalOf(counts, rule) {
21
+ return Object.values(counts[rule] ?? {}).reduce((sum, count) => sum + count, 0);
22
+ }
23
+ export function isPerFolder(counts) {
24
+ return Object.values(counts).some((files) => Object.keys(files).some((key) => !READ.test(key)));
25
+ }
26
+ export function readBaseline(file) {
27
+ if (!existsSync(file))
28
+ return null;
29
+ let counts;
30
+ try {
31
+ counts = JSON.parse(readFileSync(file, 'utf8'));
32
+ }
33
+ catch (error) {
34
+ throw new AshlarError(BASELINE_WORDS.unreadable(file, error.message));
35
+ }
36
+ if (isPerFolder(counts))
37
+ throw new AshlarError(BASELINE_WORDS.perFolder(file));
38
+ return counts;
39
+ }
40
+ export function tidyCounts(counts) {
41
+ const out = {};
42
+ for (const rule of Object.keys(counts).sort()) {
43
+ const files = {};
44
+ for (const file of Object.keys(counts[rule]).sort()) {
45
+ const count = counts[rule][file];
46
+ if (count > 0)
47
+ files[file] = count;
48
+ }
49
+ if (Object.keys(files).length > 0)
50
+ out[rule] = files;
51
+ }
52
+ return out;
53
+ }
54
+ export function writeBaseline(file, counts) {
55
+ const tidy = tidyCounts(counts);
56
+ if (Object.keys(tidy).length === 0) {
57
+ rmSync(file, { force: true });
58
+ return false;
59
+ }
60
+ writeFileSync(file, `${JSON.stringify(tidy, null, 2)}\n`);
61
+ return true;
62
+ }
63
+ export function risesOf(counts, baseline) {
64
+ const rises = [];
65
+ for (const [rule, files] of Object.entries(counts)) {
66
+ for (const [file, count] of Object.entries(files)) {
67
+ const held = baseline[rule]?.[file] ?? 0;
68
+ if (count > held)
69
+ rises.push({ rule, file, count, baseline: held });
70
+ }
71
+ }
72
+ return rises.sort((a, b) => a.file.localeCompare(b.file) || a.rule.localeCompare(b.rule));
73
+ }
74
+ export function slackOf(counts, baseline) {
75
+ let slack = 0;
76
+ for (const [rule, files] of Object.entries(baseline)) {
77
+ for (const [file, held] of Object.entries(files)) {
78
+ slack += Math.max(0, held - (counts[rule]?.[file] ?? 0));
79
+ }
80
+ }
81
+ return slack;
82
+ }
83
+ export function shrunk(counts, baseline) {
84
+ if (!baseline)
85
+ return tidyCounts(counts);
86
+ const out = {};
87
+ for (const [rule, files] of Object.entries(baseline)) {
88
+ for (const [file, held] of Object.entries(files)) {
89
+ add(out, rule, file, Math.min(held, counts[rule]?.[file] ?? 0));
90
+ }
91
+ }
92
+ return tidyCounts(out);
93
+ }
94
+ export function carried(baseline, renamed) {
95
+ const out = structuredClone(baseline);
96
+ for (const { from, to } of renamed) {
97
+ for (const [rule, files] of Object.entries(baseline)) {
98
+ const held = files[from] ?? 0;
99
+ if (held === 0)
100
+ continue;
101
+ add(out, rule, from, -held);
102
+ add(out, rule, to, held);
103
+ }
104
+ }
105
+ return out;
106
+ }
107
+ export function holdsAny(baseline, file) {
108
+ return Object.values(baseline).some((files) => (files[file] ?? 0) > 0);
109
+ }
@@ -0,0 +1 @@
1
+ export declare const besideModule: (path: string, from: string) => string;