codeassembly-guidance 0.5.0 → 0.6.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/.meta/changelog.json +306 -0
- package/CHANGELOG.md +73 -0
- package/README.md +55 -4
- package/content/_partials/finding-grades.md +4 -0
- package/content/codeassembly-content.yaml +2 -0
- package/content/collections/recommended.md +5 -2
- package/content/guidance/_harnesses/rovo/AGENTS.md +0 -1
- package/content/guidance/rulebooks/accessibility-conventions.md +26 -6
- package/content/guidance/rulebooks/cli-conventions.md +17 -2
- package/content/guidance/rulebooks/codeassembly-content-specification.md +11 -11
- package/content/guidance/rulebooks/machine-readable-output-conventions.md +85 -0
- package/content/guidance/rulebooks/ui-copy-conventions.md +2 -2
- package/content/guidance/rulebooks/williamthorsen-collaboration-preferences.md +10 -10
- package/content/guidance/rulebooks/williamthorsen-typescript-preferences.md +7 -3
- package/content/guidance/rulebooks/williamthorsen-workflow-preferences.md +3 -1
- package/content/guidance/rulebooks/williamthorsen-writing-preferences.md +5 -5
- package/content/scripts/check-prose.mjs +1 -1
- package/content/scripts/describe-change.mjs +68 -68
- package/content/skills/_data/action-items.md +2 -2
- package/content/skills/_data/artifact-conventions.md +20 -10
- package/content/skills/_data/concision.md +1 -1
- package/content/skills/_data/entry-points.md +37 -0
- package/content/skills/_data/recommendation-gradient.md +6 -6
- package/content/skills/_data/spike-conventions.md +13 -3
- package/content/skills/_data/ticket-source-resolution.md +21 -4
- package/content/skills/_data/title-templates.md +4 -4
- package/content/skills/_partials/commit-title-rendering.md +2 -1
- package/content/skills/_partials/next-steps-after-plan.md +4 -3
- package/content/skills/_partials/option-format.md +8 -8
- package/content/skills/_partials/plan-template.md +3 -1
- package/content/skills/_partials/resolve-plan-and-ticket.md +22 -0
- package/content/skills/_partials/split-launch-prompts.md +1 -1
- package/content/skills/_partials/ticket-criteria-conventions.md +2 -0
- package/content/skills/analyze-performance/SKILL.md +102 -0
- package/content/skills/analyze-performance/analyze-performance.mjs +70 -0
- package/content/skills/assess-code-health/SKILL.md +16 -14
- package/content/skills/assess-code-health/assess-code-health.mjs +29 -28
- package/content/skills/assess-usability/SKILL.md +5 -3
- package/content/skills/convert-agent-prompt/SKILL.md +60 -0
- package/content/skills/create-commit/SKILL.md +10 -5
- package/content/skills/create-pr/SKILL.md +11 -11
- package/content/skills/create-ticket/SKILL.md +1 -0
- package/content/skills/design-and-plan/SKILL.md +2 -2
- package/content/skills/implement-plan/SKILL.md +1 -28
- package/content/skills/index-prototypes/SKILL.md +36 -17
- package/content/skills/index-prototypes/index-prototypes.mjs +14 -14
- package/content/skills/investigate-spike/SKILL.md +48 -0
- package/content/skills/prepare-prototype-brief/SKILL.md +17 -13
- package/content/skills/refine-plan/SKILL.md +7 -4
- package/content/skills/refine-prototype/SKILL.md +5 -5
- package/content/skills/review-branch/SKILL.md +7 -7
- package/content/skills/review-criteria/SKILL.md +3 -3
- package/content/skills/review-gh-pr/SKILL.md +1 -1
- package/content/skills/revise-prose/SKILL.md +9 -8
- package/content/skills/revise-prose/revise-prose.mjs +2 -2
- package/content/skills/start-ticket/SKILL.md +27 -0
- package/content/skills/summarize-change/SKILL.md +17 -9
- package/content/skills/testing-conventions/SKILL.md +12 -1
- package/content/skills/triage-spike-findings/SKILL.md +31 -12
- package/content/skills/typescript-testing-conventions/SKILL.md +40 -0
- package/content/subagents/_data/claude.yaml +3 -0
- package/content/subagents/code-health-assessor.md +4 -4
- package/content/subagents/disposition-challenger.md +3 -4
- package/content/subagents/entry-drafter.md +2 -2
- package/content/subagents/handoff-reviewer.md +1 -1
- package/content/subagents/prototype-builder.md +69 -0
- package/content/subagents/usability-assessor.md +1 -1
- package/package.json +5 -4
- package/schemas/preferences.v1.json +1 -1
- package/schemas/work-types.v1.json +1 -1
- package/content/guidance/_harnesses/rovo/codeassembly-guidance.md +0 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: prepare-prototype-brief
|
|
3
|
-
description: Compose the shared brief and the lens sections for a round of competing prototypes, check the brief against the rules that builders over-apply, dispatch one builder per lens, and once the round is judged, take the developer through a decision on every prototype idea. Use when a ticket calls for two or more prototypes of one idea
|
|
3
|
+
description: Compose the shared brief and the lens sections for a round of competing prototypes, check the brief against the rules that builders over-apply, dispatch one builder per lens, and once the round is judged, take the developer through a decision on every prototype idea. Use when a ticket calls for two or more competing prototypes of one idea, or when the developer has judged such a round.
|
|
4
4
|
user-invocable: true
|
|
5
5
|
supported-harnesses: [claude]
|
|
6
6
|
---
|
|
@@ -61,9 +61,15 @@ The failure that this prevents: the lens paragraph reproduced as helper text und
|
|
|
61
61
|
|
|
62
62
|
### Require a salience order
|
|
63
63
|
|
|
64
|
-
Require a salience order in every working view: the current state in one place, the next thing to happen more prominent than the rest, and every action visibly an action. Name {rulebook:accessibility-conventions} and {rulebook:ui-copy-conventions} as the floor, and state that usability outranks restraint. Require that a status repeated on every row be a mark, a column, or a style, not a sentence.
|
|
64
|
+
Require a salience order in every working view: the current state in one place, the next thing to happen more prominent than the rest, and every action visibly an action. Name {rulebook:accessibility-conventions} and {rulebook:ui-copy-conventions} as the floor, including the accessibility rulebook's named-model, placement, toggle, glanceable-state, and button-at-rest rules, and state that usability outranks restraint: A calm or restrained direction never hides a state for which the reader scans. A builder departs from the named model only for a reason, which it reports with its distinctive ideas. Require that a status repeated on every row be a mark, a column, or a style, not a sentence.
|
|
65
65
|
|
|
66
|
-
The failure that this prevents: a page in one colour, in which the operator hunts for the control,
|
|
66
|
+
The failure that this prevents: a page in one colour, in which the operator hunts for the control, "Hidden from the players." written out on every hidden row, and an expiry column in plain text, in which the operator reads every row to find the expired ones.
|
|
67
|
+
|
|
68
|
+
### Bound every loop
|
|
69
|
+
|
|
70
|
+
Require that every iterative loop in a prototype, such as layout fitting, animation, simulation, or retry, stop after a fixed number of iterations or a time limit.
|
|
71
|
+
|
|
72
|
+
The failure that this prevents: one page whose loop does not end hangs its renderer, and every browser call queued behind it stalls, including the screenshots of the round.
|
|
67
73
|
|
|
68
74
|
### Write the brief in plain speech
|
|
69
75
|
|
|
@@ -79,10 +85,10 @@ Write the brief in this order, with these headings:
|
|
|
79
85
|
|
|
80
86
|
1. **Context.** The ticket, quoted. The developer's motivating picture, restated in plain speech.
|
|
81
87
|
2. **Settled intent.** Bullets. Each is a decision, with its reason when the reason constrains the design.
|
|
82
|
-
3. **Deliverable.** The file and its path per {skill:index-prototypes}; the constraints (self-contained, opens from `file://`, inline CSS and JavaScript, no framework, readable with JavaScript off, phone width); the mechanism that must run; the demo control that plays the written scene; a full-screen mode when the product has an audience view. The demo chrome (the demo control, scene captions, the lens note, the data-model note, the API list) is in a band visibly distinct from the product surface, and every part of it is inside an element that has the `data-demo` attribute. The band's first line is the id
|
|
88
|
+
3. **Deliverable.** The file and its path per {skill:index-prototypes}; the constraints (self-contained, opens from `file://`, inline CSS and JavaScript, no framework, readable with JavaScript off, phone width, every loop bounded by an iteration count or a time limit); the mechanism that must run; the demo control that plays the written scene; a full-screen mode when the product has an audience view. The demo chrome (the demo control, scene captions, the lens note, the data-model note, the API list) is in a band visibly distinct from the product surface, and every part of it is inside an element that has the `data-demo` attribute. The band's first line is the id from the dispatch block and the prototype's title, `{id} {title}`. The page's `<title>` is `{set title} - {id} {title}`, with the set title and the id from the dispatch block.
|
|
83
89
|
4. **Sections.** Numbered, each a noun phrase plus what it contains and a length bound. None asks for persuasion; one is the scene, exhibited; one is the data-model note when the product stores data; one is the API list when the product has an API.
|
|
84
90
|
5. **Quality bar.** Works, legible, accessible, and within the copy rules, with {rulebook:accessibility-conventions} and {rulebook:ui-copy-conventions} named, the design skill to invoke before markup, and the salience order required.
|
|
85
|
-
6. **How this round is judged.** The criteria, in the reviewer's voice, with the divergence between lenses named as the point of the round. One criterion is the copy: "Read every string on the product surface as its user opening the page for the tenth time. A string that explains the page, reassures, or repeats the brief, and any copy over the budget in {rulebook:ui-copy-conventions}, is a defect."
|
|
91
|
+
6. **How this round is judged.** The criteria, in the reviewer's voice, with the divergence between lenses named as the point of the round. One criterion is the copy: "Read every string on the product surface as its user opening the page for the tenth time. A string that explains the page, reassures, or repeats the brief, and any copy over the budget in {rulebook:ui-copy-conventions}, is a defect." Another is the glanceable state: "A list in which the reader must read each item to find a state for which the reader scans, such as expired or failing, is a defect, whatever restraint the lens asks for."
|
|
86
92
|
7. **Rules of engagement.** The write allowance from the inputs. The default: Write the output file and nothing else, modify nothing in the repository, install nothing. When the ask allows more, state what it allows. Then: Publish the prototype and report its artifact URL, a value for each of the set's note labels (listed here), and five lines of distinctive ideas.
|
|
87
93
|
|
|
88
94
|
Then add the lens sections, one per builder, in the developer's words after a plain-speech pass.
|
|
@@ -116,7 +122,7 @@ Resolve the set directory and the scratch directory per {skill:index-prototypes}
|
|
|
116
122
|
|
|
117
123
|
### 2. Gather the inputs
|
|
118
124
|
|
|
119
|
-
Take the ticket and the ask. Propose lenses when the ask lacks them. Take the write allowance from the ask, and apply the default when the ask does not state one. Choose a slug per lens and the set's note labels, per {skill:index-prototypes} "The set", before anything is built, and resolve the slugs' ids per the same section, in the order of the lens sections.
|
|
125
|
+
Take the ticket and the ask. Propose lenses when the ask lacks them. Take the write allowance from the ask, and apply the default when the ask does not state one. Choose the set title (or read it from the manifest), a slug per lens, and the set's note labels, per {skill:index-prototypes} "The set", before anything is built, and resolve the slugs' ids per the same section, in the order of the lens sections.
|
|
120
126
|
|
|
121
127
|
### 3. Compose and check the brief
|
|
122
128
|
|
|
@@ -129,8 +135,9 @@ Write the brief to `{scratch_dir}/brief.md`. Then check it against each rule abo
|
|
|
129
135
|
- Every `do not know`, `mystery`, `unknown to`, `without knowing` in an audience-facing instruction: rewritten as what the audience sees, without the withheld information.
|
|
130
136
|
- `cost`, `price`, `free`, `cheap`, `budget`: absent, or present once in the judging section.
|
|
131
137
|
- Every `state`, `say`, `tell`, `explain` in a requirement: rewritten as what the viewer can learn and at what moment.
|
|
132
|
-
- Salience order, the accessibility floor, and the copy rules: named in the quality bar, and the copy rules named again in "How this round is judged".
|
|
138
|
+
- Salience order, the accessibility floor, and the copy rules: named in the quality bar, and the copy rules and the glanceable state named again in "How this round is judged".
|
|
133
139
|
- The `data-demo` band: required in the deliverable.
|
|
140
|
+
- Bounded loops: required in the deliverable's constraints.
|
|
134
141
|
- The write allowance: stated in the rules of engagement.
|
|
135
142
|
- The note labels: listed in the rules of engagement.
|
|
136
143
|
|
|
@@ -144,7 +151,7 @@ Save the brief with {skill:save-artifact} as a ticket-level `brief` artifact, an
|
|
|
144
151
|
|
|
145
152
|
### 5. Dispatch the builders
|
|
146
153
|
|
|
147
|
-
Send one {tool:Task} call per lens
|
|
154
|
+
Each builder is a {subagent:prototype-builder}, which checks its page in a headless browser apart from this session's. Dispatch the builders one at a time, in the order of the lens sections, and wait for each reply before the next dispatch: Builders that run at once share one browser, and a page that hangs there stalls every builder. Send one {tool:Task} call per lens, `subagent_type: prototype-builder`, with this block and nothing else composed into it:
|
|
148
155
|
|
|
149
156
|
```dispatch
|
|
150
157
|
brief: {path to the saved brief}
|
|
@@ -152,14 +159,11 @@ lens: {lens name}
|
|
|
152
159
|
slug: {slug}
|
|
153
160
|
version: {n}
|
|
154
161
|
id: {number}.{n}
|
|
162
|
+
set-title: {set title}
|
|
155
163
|
output: {set_dir}/{slug}-v{n}.html
|
|
156
164
|
```
|
|
157
165
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
> Read the brief in full and build the prototype for the lens named above. Write only the files that the brief's rules of engagement allow. Put the id above and the prototype's title on the first line of the page's `data-demo` band. Invoke the design skill that the brief names before writing markup. Publish the output with the Artifact tool. When done, reply with the artifact URL, a short title, the lens, the inputs that you drew on, a one-sentence description, one line per note label in the brief as `{label}: {value}`, and five lines of the system's distinctive ideas. Nothing else.
|
|
161
|
-
|
|
162
|
-
Dispatch a builder once more with the same block when it returns without the file, with a file that does not open, or without an artifact URL. Report a second failure in the summary and leave the lens out of the round.
|
|
166
|
+
Dispatch a builder once more with the same block when it returns without the file, with a file that does not open, without an artifact URL, or with a page that it reports as still not responding. A builder whose browser call hangs on its own page cannot return, so stop a builder that has not replied 30 minutes after its dispatch, and count that as a failed attempt. Report a second failure in the summary and leave the lens out of the round.
|
|
163
167
|
|
|
164
168
|
### 6. Index and compare
|
|
165
169
|
|
|
@@ -31,9 +31,8 @@ Before every {tool:Task} call and after every phase completion, output a status
|
|
|
31
31
|
1. Read the plan file. If not found, report an error and stop.
|
|
32
32
|
2. Parse YAML frontmatter from the plan content. If a `provenance` block is present, store it as `{input-provenance}`. If the plan does not have frontmatter or a `provenance` block, set `{input-provenance}` to empty.
|
|
33
33
|
3. Resolve the ticket source:
|
|
34
|
-
- GitHub URL (`github.com/.../issues/...`)
|
|
35
|
-
- File path -> Read the file.
|
|
36
|
-
- Jira URL or key -> Fetch per the Jira entry in [platform-specific fetch](../_data/ticket-source-resolution.md#platform-specific-fetch).
|
|
34
|
+
- GitHub URL (`github.com/.../issues/...`), Jira URL, or Jira key -> Fetch the body and the comments per [platform-specific fetch](../_data/ticket-source-resolution.md#platform-specific-fetch).
|
|
35
|
+
- File path -> Read the file, then read its remote comments per [Comments](../_data/ticket-source-resolution.md#comments).
|
|
37
36
|
- Other URL -> Fetch the URL content.
|
|
38
37
|
|
|
39
38
|
Then report the ticket's open blockers per [Open blockers](../_data/ticket-source-resolution.md#open-blockers), and continue: A blocker does not stop the review.
|
|
@@ -161,7 +160,7 @@ Run `{harness_home_dir}/scripts/resolve-frontmatter.sh --format json` via Bash.
|
|
|
161
160
|
|
|
162
161
|
The `provenance:` block is **not** populated from the script. Construct it manually per the case branches below.
|
|
163
162
|
|
|
164
|
-
**Round-trip preservation:** The top-level canonical fields (`branch`, `commit`, etc.) are always re-resolved from current session context via the script; they are not copied from `{input-provenance}`. This is correct: The output is a new artifact at a new point in time on a potentially different branch. The `provenance:` block's camelCase convention (`baseSha`, `isInteractive`, `refinedBy`) is preserved as-is on both read and write; the keys are not renamed. Provenance fields copied from the input are `skill`, `baseSha`, `isInteractive`, and `iteration` (per the case branches).
|
|
163
|
+
**Round-trip preservation:** The top-level canonical fields (`branch`, `commit`, etc.) are always re-resolved from current session context via the script; they are not copied from `{input-provenance}`. This is correct: The output is a new artifact at a new point in time on a potentially different branch. The `provenance:` block's camelCase convention (`baseSha`, `isInteractive`, `refinedBy`) is preserved as-is on both read and write; the keys are not renamed. Provenance fields copied from the input are `skill`, `baseSha`, `isInteractive`, and `iteration` (per the case branches). `parent` is not copied: It is set from the input plan's file name, so that each revision names its own predecessor.
|
|
165
164
|
|
|
166
165
|
**When `{input-provenance}` is non-empty:**
|
|
167
166
|
|
|
@@ -170,6 +169,7 @@ The `provenance:` block is **not** populated from the script. Construct it manua
|
|
|
170
169
|
3. Construct updated provenance:
|
|
171
170
|
- `skill`: Preserve from `{input-provenance}` (the original authoring skill)
|
|
172
171
|
- `refinedBy`: Set to `refine-plan`
|
|
172
|
+
- `parent`: The file name of `{plan_path}`, without its directory
|
|
173
173
|
- `timestamp`: Use the script's `timestamp`
|
|
174
174
|
- `baseSha`: The script's value (or preserved original)
|
|
175
175
|
- `isInteractive`: Preserve from `{input-provenance}` if present
|
|
@@ -181,6 +181,7 @@ The `provenance:` block is **not** populated from the script. Construct it manua
|
|
|
181
181
|
provenance:
|
|
182
182
|
skill: design-and-plan
|
|
183
183
|
refinedBy: refine-plan
|
|
184
|
+
parent: 20260309-140000Z_example_plan.md
|
|
184
185
|
timestamp: 2026-03-10T08:00:00Z
|
|
185
186
|
baseSha: abc123def456...
|
|
186
187
|
isInteractive: true
|
|
@@ -201,6 +202,7 @@ The `provenance:` block is **not** populated from the script. Construct it manua
|
|
|
201
202
|
3. Construct provenance:
|
|
202
203
|
- `skill`: `unknown`
|
|
203
204
|
- `refinedBy`: `refine-plan`
|
|
205
|
+
- `parent`: The file name of `{plan_path}`, without its directory
|
|
204
206
|
- `timestamp`: Script's value
|
|
205
207
|
- `baseSha`: Script's value (omit when absent)
|
|
206
208
|
- `isInteractive`: Always `true`. `refine-plan` is an interactive user-invocable skill: When it stamps a plan without prior provenance, the stamp itself is always produced inside that interactive session.
|
|
@@ -212,6 +214,7 @@ The `provenance:` block is **not** populated from the script. Construct it manua
|
|
|
212
214
|
provenance:
|
|
213
215
|
skill: unknown
|
|
214
216
|
refinedBy: refine-plan
|
|
217
|
+
parent: 20260309-140000Z_example_plan.md
|
|
215
218
|
timestamp: 2026-03-10T08:00:00Z
|
|
216
219
|
baseSha: abc123def456...
|
|
217
220
|
isInteractive: true
|
|
@@ -29,8 +29,8 @@ Off:
|
|
|
29
29
|
On:
|
|
30
30
|
|
|
31
31
|
- The page is self-contained and opens from `file://`, with its demo chrome in a band whose every part is inside an element that has `data-demo`, as the brief that built it required.
|
|
32
|
-
- The band's first line is the page's id and title, `{number}.{version} {title}`, so that the developer reads which version they have open without returning to the index.
|
|
33
|
-
- {rulebook:accessibility-conventions} is the floor: Check contrast and size when a command changes a colour or a text size.
|
|
32
|
+
- The band's first line is the page's id and title, `{number}.{version} {title}`, so that the developer reads which version they have open without returning to the index, and the page's `<title>` follows the rule in {skill:index-prototypes} "The set". Every step that sets a new id on the working file sets both.
|
|
33
|
+
- {rulebook:accessibility-conventions} is the floor: Check contrast and size when a command changes a colour or a text size, apply its placement, toggle, and button-at-rest rules when a command adds or moves a control, and apply its glanceable-state rule when a command adds or changes a list.
|
|
34
34
|
- A new string on the product surface follows {rulebook:ui-copy-conventions}.
|
|
35
35
|
- One working file. A batch edits it in place; a fork is written next to it and is deleted once the developer picks.
|
|
36
36
|
|
|
@@ -48,7 +48,7 @@ node {harness_home_dir}/skills/index-prototypes/index-prototypes.mjs resolve-ids
|
|
|
48
48
|
--slugs {slug}
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
-
Copy the base's latest source to `{scratch_dir}/{slug}-v{n}.html`, the working file, and set the band's first line to the new id. A base reconstructed from a built product takes a new slug and starts at version 1, and its band's first line names the source after the id, such as `6.1 Start from as tabs, from the api-tokens page`.
|
|
51
|
+
Copy the base's latest source to `{scratch_dir}/{slug}-v{n}.html`, the working file, and set the band's first line and the `<title>` to the new id. A base reconstructed from a built product takes a new slug and starts at version 1, and its band's first line names the source after the id, such as `6.1 Start from as tabs, from the api-tokens page`. When the manifest does not have a set title yet, choose one per {skill:index-prototypes} "The set", and pass it as `--set-title` when the first snapshot is registered.
|
|
52
52
|
|
|
53
53
|
### 2. Serve the working file
|
|
54
54
|
|
|
@@ -78,7 +78,7 @@ Each turn, take every command in the developer's message as one batch:
|
|
|
78
78
|
4. Append each applied command to the session's log, under the id of the version that it will enter, with the developer's reason when they gave one and the source id when it was a transplant.
|
|
79
79
|
5. Reply with one line per command (applied, forked with its letters and their URLs, or refused with the reason), and nothing else. The developer looks at the browser, not at a description of it.
|
|
80
80
|
|
|
81
|
-
Propose a new number when a batch replaces the layout or the model to the point that the earlier version's verdicts and notes no longer describe the page. On yes, the working file takes a new slug and the id that `resolve-ids` gives it
|
|
81
|
+
Propose a new number when a batch replaces the layout or the model to the point that the earlier version's verdicts and notes no longer describe the page. On yes, the working file takes a new slug and the id that `resolve-ids` gives it in its band and its `<title>`, and its band names the version from which it came. The old slug keeps its last snapshot.
|
|
82
82
|
|
|
83
83
|
### 5. Snapshot
|
|
84
84
|
|
|
@@ -88,7 +88,7 @@ Snapshot when the developer asks for one, in any words ("snapshot", "keep this",
|
|
|
88
88
|
2. Publish it with the Artifact tool: to the slug's existing artifact URL when the manifest's latest entry for the slug has one, so that the index card's link stays current, or as a new artifact for a new slug.
|
|
89
89
|
3. Capture its screenshots per {skill:index-prototypes} step 3, and register it per its step 4 with `--number {number}`, `--source`, the set's note labels (copied from the latest entry, with any change that the batches made to them), and, for a new slug, a `--description` that names the version from which it came.
|
|
90
90
|
4. Update the set's summary per {skill:index-prototypes} step 5, naming the version in `changes`, then render and republish the index per its step 6.
|
|
91
|
-
5. The next batch opens the next version: Copy the snapshot to `{scratch_dir}/{slug}-v{n+1}.html` and set the band's id
|
|
91
|
+
5. The next batch opens the next version: Copy the snapshot to `{scratch_dir}/{slug}-v{n+1}.html` and set the band's id and the `<title>`.
|
|
92
92
|
|
|
93
93
|
### 6. Close
|
|
94
94
|
|
|
@@ -31,7 +31,7 @@ This skill is the canonical home of the shared review process. `review-pr` invok
|
|
|
31
31
|
- **Explicit `--ticket=<source>`**: Resolve per [ticket source resolution](../_data/ticket-source-resolution.md) and append as a `ticket` source. A fetched platform issue is `remote` with its `updatedAt` as `last_updated`; a file or plain-text source is `local_snapshot` with `last_updated` null when unknown. When the source resolves to a URL, persist it per [Stored ticket URL](../_data/ticket-source-resolution.md#stored-ticket-url). `--spec-source` does not apply on this path.
|
|
32
32
|
- **Auto-resolve** (when `--ticket` is omitted): Resolve up to two candidates and choose between them.
|
|
33
33
|
- _Remote candidate_: When `ticket_id` is non-null and resolves to a platform ticket (use `scm` from step 1), fetch the remote issue per [ticket source resolution](../_data/ticket-source-resolution.md#auto-resolve), but substitute the local fallback below for that section's "ask the user" terminal step. Its `last_updated` is the issue's `updatedAt`.
|
|
34
|
-
- _Local candidate_: The most recent `*_ticket.md` under `{artifact_base_dir}/projects/{project_slug}/tickets/{ticket_id}/`. Its `last_updated` is the filename's `YYYYMMDD-HHMMSSZ` prefix converted to ISO 8601 (`YYYY-MM-DDTHH:MM:SSZ`), so it shares the remote candidate's format; if the prefix is unparseable, treat the local candidate as unavailable. (The artifact filename keeps the compact form per `artifact-conventions.md`; only the recorded `last_updated` is normalized.) Read its frontmatter as well as its filename: `copies_remote` decides the selection below, per [ticket frontmatter](../_data/artifact-conventions.md#ticket-frontmatter).
|
|
34
|
+
- _Local candidate_: The most recent `*_ticket.md` under `{artifact_base_dir}/projects/{project_slug}/tickets/{ticket_id}/`. Its `last_updated` is the filename's `YYYYMMDD-HHMMSSZ` prefix converted to ISO 8601 (`YYYY-MM-DDTHH:MM:SSZ`), so it shares the remote candidate's format; if the prefix is unparseable, treat the local candidate as unavailable. (The artifact filename keeps the compact form per `artifact-conventions.md`; only the recorded `last_updated` is normalized.) Read its frontmatter as well as its filename: `copies_remote` decides the selection below, per [ticket frontmatter](../_data/artifact-conventions.md#ticket-frontmatter). When the selection chooses it and its frontmatter names a `ticket_ref`, add that remote ticket's comments per [Comments](../_data/ticket-source-resolution.md#comments), taking them from the remote candidate when that fetch succeeded.
|
|
35
35
|
- _Selection_:
|
|
36
36
|
- If `--spec-source=remote|local` is set, use that candidate. If the named candidate is unavailable (e.g. `--spec-source=local` without a snapshot, or `--spec-source=remote` with a failed/offline fetch or null `ticket_id`), stop and report the missing source rather than silently using the other side: An explicit instruction must not be redirected to the wrong contract. State the remedy (drop the flag to re-enable recency) in the message.
|
|
37
37
|
- Otherwise, if a remote candidate exists and the local candidate's frontmatter sets `copies_remote: true`, use the remote candidate. The snapshot's body is a copy of the ticket of record, so the remote contains at least the content that the snapshot froze, and the snapshot's later write time records the copying rather than a newer contract. A snapshot that does not make that claim falls through to the comparison below.
|
|
@@ -304,13 +304,13 @@ The next-steps block has four independent sub-blocks. Each is shown only when it
|
|
|
304
304
|
|
|
305
305
|
Use `~/`-relative paths when possible and absolute paths otherwise. Every line subordinate to an option (invocation guidance as much as a pro or con) is a nested list item, never a whitespace-indented continuation; see [option format](#option-format).
|
|
306
306
|
|
|
307
|
-
**Naming a skill in the render.** Name a skill in the rendered option only when the user must
|
|
307
|
+
**Naming a skill in the render.** Name a skill in the rendered option only when the user must run the invocation after a session boundary: clearing context, handing off to another session, or waiting for someone else to act. When the agent runs the skill in the current session, the skill name appears in the sub-block's Options table and the rendered line is a bare action. This limits each rendered line to the step that the user performs.
|
|
308
308
|
|
|
309
309
|
**Reviewer and author roles.** A review reports findings; the author disposes of them. The options below send the reviewer's output to the author or record what the review found; they never ask the reviewer to re-design, re-plan, or coordinate a workflow, none of which is the reviewer's job.
|
|
310
310
|
|
|
311
311
|
### Proposed-edit preview
|
|
312
312
|
|
|
313
|
-
Three of the sub-blocks below offer options that rewrite an artifact, one each: the Deviations sub-block rewrites the ticket's acceptance criteria, the source-divergence sub-block rewrites the PR description, and the Findings sub-block rewrites the source. The user consents to that rewrite by picking a number, so every such option renders a preview of the edit that it would make. The reviewer judges which criteria are genuinely in conflict with the implementation and which findings name a change that it can
|
|
313
|
+
Three of the sub-blocks below offer options that rewrite an artifact, one each: the Deviations sub-block rewrites the ticket's acceptance criteria, the source-divergence sub-block rewrites the PR description, and the Findings sub-block rewrites the source. The user consents to that rewrite by picking a number, so every such option renders a preview of the edit that it would make. The reviewer judges which criteria are genuinely in conflict with the implementation and which findings name a change that it can make; the preview makes those judgments reviewable instead of silent.
|
|
314
314
|
|
|
315
315
|
**Placement.** The preview renders above the numbered options, inside its sub-block, under a `Proposed edit to the {target}:` label naming what it would change; the source target's label is plural, `Proposed edits to the source:`, because it covers every open finding. Option lines stay bare actions: The preview is never a pro, a con, or a line nested beneath an option. An option that mutates nothing, such as "Leave as-is", does not render a preview.
|
|
316
316
|
|
|
@@ -320,7 +320,7 @@ Ticket and PR-description deltas render as a flat list, one line per change. Sou
|
|
|
320
320
|
|
|
321
321
|
- **Ticket targets** derive their delta from the in-conflict criteria rows of `## Specification compliance`'s ticket subsection, and from nothing else. Unplanned work is never a source: Implementation that goes beyond the criteria is not a deviation, so it does not yield a line. Because a ticket's `## Problem`, `## Context`, and `## Proposed solution` record what was known and proposed when it was written, this menu does not offer an edit that changes them; a divergence between one of them and the implementation is reported in the PR description instead.
|
|
322
322
|
- `Reword: {old} → {new}` for a criterion whose direction the implementation deliberately contradicts
|
|
323
|
-
- `Drop: {criterion}` for a criterion that the implementation deliberately abandoned, never for one that it has not yet
|
|
323
|
+
- `Drop: {criterion}` for a criterion that the implementation deliberately abandoned, never for one that it has not yet met
|
|
324
324
|
- **PR-description targets** render the concrete claim changes, each keyed to the divergent `D{n}` row from which it came: `D2: {claim as written} → {claim as built}`.
|
|
325
325
|
- **Source targets** derive their delta from the open findings, one entry per finding, keyed to its ID. An entry states two things: the surface that the change touches (source, test, comment, docs, config) and the substance of the edit. Its form follows the edit's own granularity rather than a fixed notation, so a literal single-site edit is a `{old} → {new}` clause, many sites sharing one edit are a table captioned with what is invariant across its rows, and a structural edit is a prose clause naming the shape of the resulting diff. A code snippet is one rendering among these, never the required form.
|
|
326
326
|
- When an entry covers several sites and deliberately leaves one of them alone, it names that site with the reason. The entry states its own boundary rather than leaving the reader to infer it from silence.
|
|
@@ -331,7 +331,7 @@ Do not render an exclusions line. A criterion genuinely arguable as in conflict
|
|
|
331
331
|
|
|
332
332
|
**Open findings.** When a ticket or PR-description delta line would settle or obviate an open finding, follow it with a sibling `⚠️` list item naming that finding, so that the user can see that accepting the edit pre-empts the finding's disposition. Those preview lists stay flat; nothing nests beneath a delta line.
|
|
333
333
|
|
|
334
|
-
**The preview is the contract.** The edit executed is the edit previewed.
|
|
334
|
+
**The preview is the contract.** The edit executed is the edit previewed. If making the edit reveals a change that the preview did not contain, stop and re-confirm with the new line shown; never widen the edit under consent already given.
|
|
335
335
|
|
|
336
336
|
**Empty delta.** When the judgment drops every line, the Deviations sub-block has nothing to propose and does not render at all; see its [trigger](#deviations-sub-block). When a source divergence proposes a PR-description edit, that delta is never empty, because a divergence that the implementation resolves in the ticket's favor always leaves a claim to reconcile.
|
|
337
337
|
|
|
@@ -413,7 +413,7 @@ Every case that renders offers both, so the pair is fixed; what varies by case i
|
|
|
413
413
|
|
|
414
414
|
#### Output format
|
|
415
415
|
|
|
416
|
-
Render the list per [option format](#option-format). Each option has a marker (■■■/■■□/■□□/□□□); the recommendation rules below determine which option takes the strongest marker per case. Option 1 renders its PR-description delta above the list, per [proposed-edit preview](#proposed-edit-preview); "Leave as-is" has none. Pros and cons are omitted by default; add a `➕` or `➖` line only when the specific divergence presents a tradeoff that survives the option-format tests (e.g., "the diverging AC was load-bearing for adjacent work that has already
|
|
416
|
+
Render the list per [option format](#option-format). Each option has a marker (■■■/■■□/■□□/□□□); the recommendation rules below determine which option takes the strongest marker per case. Option 1 renders its PR-description delta above the list, per [proposed-edit preview](#proposed-edit-preview); "Leave as-is" has none. Pros and cons are omitted by default; add a `➕` or `➖` line only when the specific divergence presents a tradeoff that survives the option-format tests (e.g., "the diverging AC was load-bearing for adjacent work that has already been merged"). Generic restatements are noise and must be omitted. That default applies to pros and cons alone: It never suppresses the proposed-edit preview, which is required content.
|
|
417
417
|
|
|
418
418
|
Case 2 (implementation matches ticket; PR description is the stale source):
|
|
419
419
|
|
|
@@ -457,7 +457,7 @@ The trigger does not include a tier condition; do not reintroduce one. Every fin
|
|
|
457
457
|
|
|
458
458
|
Stating the trigger as a list of tiers is the failure that this rule replaces: An enumeration goes stale the next time the finding scheme changes, and silently withdraws the menu from whichever tier it omits.
|
|
459
459
|
|
|
460
|
-
Legacy (`-L`) findings trigger the sub-block on the same terms, with the full option pool. Do not trim the author hand-offs for a legacy-only review: That would leave implementing-in-place as the only
|
|
460
|
+
Legacy (`-L`) findings trigger the sub-block on the same terms, with the full option pool. Do not trim the author hand-offs for a legacy-only review: That would leave implementing-in-place as the only option and forfeit the adversarial second look, which pre-existing code needs at least as much as authored code, since a legacy fix is not constrained by any ticket criterion or supported by any design discussion. The recommendation rules handle legacy findings without a carve-out: A legacy fix naming a single change satisfies rule 2 like any other, and one leaving its choice to the author falls through to a ticket or a hand-off.
|
|
461
461
|
|
|
462
462
|
The option set depends on whether the review covers a pull request. Select the variant by the review that the agent just produced: A `review-pr` run has a PR reference in the review header and a PR-description spec source, and its author is typically someone else; a `review-branch` run has neither, and its code is typically our own.
|
|
463
463
|
|
|
@@ -16,7 +16,7 @@ Evaluation criteria for code review. Apply proportionally: Match depth to risk.
|
|
|
16
16
|
|
|
17
17
|
- **Correctness**: Logic errors, unhandled error paths, data loss risks
|
|
18
18
|
- **Data changes**: A change that removes or renames data that deployed code still reads, or that depends on a migration run before merge (see {rulebook:shared-data-conventions})
|
|
19
|
-
- **Interfaces**: A change that defines or changes colour tokens, text styles, or a page or UI component (see {rulebook:accessibility-conventions}). For each new or changed interactive element, ask whether it shows that it is interactive, by the states that the rulebook names, and check it in a browser as the rulebook requires rather than by reading the diff alone
|
|
19
|
+
- **Interfaces**: A change that defines or changes colour tokens, text styles, or a page or UI component (see {rulebook:accessibility-conventions}). For each new or changed interactive element, ask whether it shows that it is interactive, by the states that the rulebook names, and check it in a browser as the rulebook requires rather than by reading the diff alone. For each new or changed list or table, ask whether each state for which its reader scans is visible without reading every item, per the rulebook's glanceable-state rule
|
|
20
20
|
- **Conventions**: Adherence to codebase patterns and project standards
|
|
21
21
|
- **Edge cases**: Boundary conditions, empty collections, zero values, undefined states
|
|
22
22
|
- **Test coverage**: Adequate tests for new functionality; tests that verify behavior and are worth keeping, not just coverage
|
|
@@ -87,7 +87,7 @@ Two defects against the placement rules in the `testing-conventions` skill are W
|
|
|
87
87
|
|
|
88
88
|
The same defects in tests that the change neither adds nor supersedes are Legacy.
|
|
89
89
|
|
|
90
|
-
## Database tests and setup
|
|
90
|
+
## Database tests and expensive setup
|
|
91
91
|
|
|
92
92
|
Three defects against the database and setup rules in the `testing-conventions` skill are Warnings:
|
|
93
93
|
|
|
@@ -119,7 +119,7 @@ A change that adds to what every session loads is a Warning unless nearly every
|
|
|
119
119
|
Conventions for how findings reference files and code locations.
|
|
120
120
|
|
|
121
121
|
1. **Repo-relative path required when localizable.** When a finding refers to specific code, the `- **Location:** ` line must be the first bullet under the finding heading, with a repo-relative path. Example: `packages/devtools-panel/config/renderReleaseNotesHtml.ts:69-76`, not `renderReleaseNotesHtml.ts:69-76`.
|
|
122
|
-
2. **Multi-range syntax.**
|
|
122
|
+
2. **Multi-range syntax.** Join multiple ranges or single lines in the same file with commas, dropping the path on subsequent entries: `path/to/file.ts:42, :69-76, :152-155`.
|
|
123
123
|
3. **Multiple files.** Findings that span multiple files use one `- **Location:** ` bullet per file.
|
|
124
124
|
4. **Prose may abbreviate after the canonical reference.** Once `Location:` establishes the path, the Description and Recommendation may refer to the file by basename.
|
|
125
125
|
|
|
@@ -98,7 +98,7 @@ Apply this cascade in order and use the first match:
|
|
|
98
98
|
node {harness_home_dir}/skills/review-gh-pr/select-pr-ticket.mjs < {pr_json}
|
|
99
99
|
```
|
|
100
100
|
|
|
101
|
-
It prints `{"number": <n or null>, "source": "<source>"}`. `source` is `closing-reference` (the first entry in `closingIssuesReferences`), `body-keyword` or `body-bare` (the earliest issue reference in the body outside code), or `none`, with `number` null. When `number` is not null, fetch the issue
|
|
101
|
+
It prints `{"number": <n or null>, "source": "<source>"}`. `source` is `closing-reference` (the first entry in `closingIssuesReferences`), `body-keyword` or `body-bare` (the earliest issue reference in the body outside code), or `none`, with `number` null. When `number` is not null, fetch the issue per [platform-specific fetch](../_data/ticket-source-resolution.md#platform-specific-fetch) and use it. When the helper exits non-zero, report its stderr and stop.
|
|
102
102
|
|
|
103
103
|
3. **No ticket**: When `source` is `none`, proceed with the PR description as the only spec source.
|
|
104
104
|
|
|
@@ -14,12 +14,13 @@ Apply is the default. `--dry-run` produces the report alone.
|
|
|
14
14
|
|
|
15
15
|
## Arguments
|
|
16
16
|
|
|
17
|
-
| Argument | Description
|
|
18
|
-
| ------------------------ |
|
|
19
|
-
| `<path>` | One or more files or directories narrowing the sweep. Repeatable.
|
|
20
|
-
| `--batch-budget <bytes>` | Ceiling on a batch's combined file bytes. Passed to the helper unchanged.
|
|
21
|
-
| `--dry-run` | Report and stop without dispatching a subagent, editing, or writing the record.
|
|
22
|
-
| `--
|
|
17
|
+
| Argument | Description | Required |
|
|
18
|
+
| ------------------------ | --------------------------------------------------------------------------------- | -------- |
|
|
19
|
+
| `<path>` | One or more files or directories narrowing the sweep. Repeatable. | No |
|
|
20
|
+
| `--batch-budget <bytes>` | Ceiling on a batch's combined file bytes. Passed to the helper unchanged. | No |
|
|
21
|
+
| `--dry-run` | Report and stop without dispatching a subagent, editing, or writing the record. | No |
|
|
22
|
+
| `--resweep` | Sweep every file again, whatever coverage the record lists. Passed to the helper. | No |
|
|
23
|
+
| `--rule <id>` | One rule that this document declares, narrowing the sweep. Repeatable. | No |
|
|
23
24
|
|
|
24
25
|
Without a path, the sweep covers the whole repository. That is this skill's default, because removing every violation from a repository requires a full sweep. It is how this skill differs from `{skill:revise-comments}`, whose default is the current branch's diff.
|
|
25
26
|
|
|
@@ -61,7 +62,7 @@ node {harness_home_dir}/skills/revise-prose/revise-prose.mjs detect {paths} \
|
|
|
61
62
|
--rule {unversioned-rule-id}={slug}
|
|
62
63
|
```
|
|
63
64
|
|
|
64
|
-
Pass one `--unit` per unit from step 1, and one `--rule` per rule that step 1 kept: `--rule plain-speech@{version}=plain-speech` for `plain-speech`, `--rule {id}@{rule-version}={unit}` for a rule whose marker declares a version, and `--rule {id}={unit}` for a rule whose marker declares none. Pass nothing for a rule that does not have a marker or whose block is not a unit, as step 1 directs. Add `--batch-budget {bytes}` if the invocation included one. Omit the paths for a whole-repository sweep.
|
|
65
|
+
Pass one `--unit` per unit from step 1, and one `--rule` per rule that step 1 kept: `--rule plain-speech@{version}=plain-speech` for `plain-speech`, `--rule {id}@{rule-version}={unit}` for a rule whose marker declares a version, and `--rule {id}={unit}` for a rule whose marker declares none. Pass nothing for a rule that does not have a marker or whose block is not a unit, as step 1 directs. Add `--batch-budget {bytes}` if the invocation included one. Add `--resweep` if the invocation included it: The helper then lists every versioned rule as `unswept` in every batch, and recorded rejections still suppress their sites. Omit the paths for a whole-repository sweep.
|
|
65
66
|
|
|
66
67
|
The helper prints one JSON object to stdout. On success it contains `ok: true`, the `root` that it swept, a `candidates` array, a `rejections` array containing the sites already adjudicated by an earlier sweep, a `batches` array in which each batch lists as `unswept` the versioned rules that its files still need, a `rules` object listing the named rules that it `detected` and those for which it does not have a detector as `undetected`, and a `summary`. On failure it contains `ok: false` with `invalid-args`, `invalid-record`, or `not-a-repository`, the last because the sweep reads what git tracks and has nothing to read outside a working tree. Report a failure and stop.
|
|
67
68
|
|
|
@@ -77,7 +78,7 @@ An empty `batches` array ends the run: Report the summary in one line and stop.
|
|
|
77
78
|
|
|
78
79
|
### 3. Pilot the first batch
|
|
79
80
|
|
|
80
|
-
Run the pilot if `.agents/revise-prose.yaml` is absent, or if it names none of this run's versioned rules under `rules:` and none of its units under `units:`. A rerun skips this step and goes to step 4.
|
|
81
|
+
Run the pilot if `.agents/revise-prose.yaml` is absent, or if it names none of this run's versioned rules under `rules:` and none of its units under `units:`. A rerun, including a run under `--resweep`, skips this step and goes to step 4.
|
|
81
82
|
|
|
82
83
|
Dispatch batch 0 alone, per step 4's dispatch shape, and run step 4's checks over it as a wave of one. Accumulate its `rejected` and `questionable` entries for step 5, as step 4 directs for every later wave, so that the pilot's questionables appear in the closing table. Then show the user its report and `git diff --stat`, and ask for a go-ahead before committing that batch and before dispatching anything else.
|
|
83
84
|
|
|
@@ -223,7 +223,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
223
223
|
`)}).map(i=>({...i,line:i.line+1}))}catch(i){if(i instanceof wt)return[];throw i}}s(I0,"extractFrontmatterProse");function N0(e,t){let r=t.split(`
|
|
224
224
|
`),i=E0(r),n=I0(e,r,i),o;function a(){o!==void 0&&o.texts.some(c=>c.trim()!=="")&&n.push({file:e,line:o.line,text:o.texts.join(`
|
|
225
225
|
`)}),o=void 0}for(s(a,"flush");i<r.length;){let c=r[i]??"",u=c.trim(),l=/^(?:`{3,}|~{3,})/.exec(u)?.[0];if(l!==void 0){a(),i=D0(r,i,l);continue}if(u.startsWith("<!--")){a(),i=j0(r,i);continue}if(u===""||z0(u)){a(),i+=1;continue}if(A0(u)){if(a(),!O0(u))for(let d of T0(u))d.trim()!==""&&n.push({file:e,line:i+1,text:uw(d)});i+=1;continue}(o===void 0||P0(c))&&(a(),o={line:i+1,texts:[]}),o.texts.push(uw(c)),i+=1}return a(),n}s(N0,"extractMarkdownProse");function P0(e){return/^\s*(?:#{1,6}\s|[-*+]\s|\d+[.)]\s)/.test(e)}s(P0,"isBlockStart");function z0(e){return/^\[[^\]]+]:\s/.test(e)}s(z0,"isLinkDefinition");function O0(e){return/^\|[\s:|-]+\|?$/.test(e)}s(O0,"isTableDelimiterRow");function A0(e){return e.startsWith("|")}s(A0,"isTableRow");function uw(e){return e.replace(/^\s*(?:#{1,6}\s+|[-*+]\s+|\d+[.)]\s+|>\s?)/,"").replace(/!\[([^\]]*)]\([^)]*\)/g,"$1").replace(/\[([^\]]+)]\([^)]*\)/g,"$1").replace(/\[([^\]]+)]\[[^\]]*]/g,"$1").replace(/<https?:\/\/[^>]*>/g,"").replace(/\bhttps?:\/\/\S+/g,"")}s(uw,"normalizeMarkdownLine");function D0(e,t,r){let i=r.startsWith("`")?"`":"~",n=new RegExp(String.raw`^\s*${i}{${r.length},}\s*$`);for(let o=t+1;o<e.length;o+=1)if(n.test(e[o]??""))return o+1;return e.length}s(D0,"skipFencedBlock");function E0(e){if(e[0]?.trim()!=="---")return 0;for(let t=1;t<e.length;t+=1)if(e[t]?.trim()==="---")return t+1;return 0}s(E0,"skipFrontmatter");function j0(e,t){for(let r=t;r<e.length;r+=1)if((e[r]??"").includes("-->"))return r+1;return e.length}s(j0,"skipHtmlComment");function T0(e){return e.replace(/^\|/,"").replace(/\|$/,"").split("|")}s(T0,"splitTableCells");import{execFileSync as C0}from"node:child_process";var qi={listFiles:R0},U0=256*1024*1024;function R0(e,t){let r=[...fw(e,[],t),...fw(e,["--others","--exclude-standard"],t)];return[...new Set(r)]}s(R0,"listFiles");function fw(e,t,r){return C0("git",["ls-files","-z",...t,"--",...r],{cwd:e,encoding:"utf8",maxBuffer:U0,stdio:["ignore","pipe","ignore"]}).split("\0").filter(i=>i!=="")}s(fw,"runLsFiles");var pw=lr(gn(),1);function mw(e,t){let r={};for(let[n,o]of t.rules){let a=e.units[o.unit];a===void 0||a.version!==t.units.get(o.unit)||(r[n]={version:o.version,"swept-at":a["swept-at"],detected:a.rules.includes(n),roots:a.roots})}let i=e.rejections.flatMap(n=>{let{unit:o,"unit-version":a,...c}=n,u=t.units.get(o);if(u===void 0)return[{...c,"rule-version":"0"}];let l=t.rules.get(n.rule);if(l===void 0)return[];let d=a===u&&l.unit===o;return[{...c,"rule-version":d?l.version:"0"}]});return{rules:r,rejections:i}}s(mw,"convertLegacyRecord");var Xt=".agents/revise-prose.yaml",Lh=/^[a-z][a-z0-9-]*$/,Zh=/^[1-9]\d*$/,Ht=j.string().regex(Lh,"rule must be a lowercase kebab-case name"),Mh=j.string().regex(/^\d{4}-\d{2}-\d{2}$/,"date must be an ISO calendar date (YYYY-MM-DD)"),L0=j.object({version:j.string().min(1),"swept-at":Mh,detected:j.boolean(),roots:j.array(j.string().min(1)).min(1)}),Z0=j.object({hash:j.string().min(1),rules:j.array(Ht)}),M0=j.object({rule:Ht,"rule-version":j.string().min(1),file:j.string().min(1),phrase:j.string().min(1),ground:j.string().min(1)}),F0=j.object({rules:j.record(Ht,L0).default({}),files:j.record(j.string().min(1),Z0).optional(),rejections:j.array(M0).default([])}),V0=j.object({units:j.record(j.string(),j.object({version:j.string().min(1),"swept-at":Mh,rules:j.array(Ht).default([]),roots:j.array(j.string().min(1)).min(1)})),rejections:j.array(j.object({rule:Ht,unit:j.string().min(1),"unit-version":j.string().min(1),file:j.string().min(1),phrase:j.string().min(1),ground:j.string().min(1)})).default([])}),B0=j.object({rule:Ht,file:j.string().min(1),phrase:j.string().min(1),ground:j.string().min(1)}),q0=j.object({sweptAt:Mh,roots:j.array(j.string().min(1)).min(1),units:j.record(j.string().min(1),j.string().min(1)),rules:j.record(Ht,j.object({unit:j.string().min(1),version:j.string().regex(Zh,"a sweep version must be a positive integer")})),rejections:j.array(B0).default([])}).superRefine((e,t)=>{for(let[r,{unit:i}]of Object.entries(e.rules))Object.hasOwn(e.units,i)||t.addIssue({code:"custom",path:["rules",r,"unit"],message:`unit "${i}" is not in units`})});function gw(e,t,r=Xt){let i=e.trim()===""?{}:(0,pw.parse)(e),n=typeof i=="object"&&i!==null&&Object.hasOwn(i,"units");if(n&&Object.hasOwn(i,"rules"))throw new Error(`Invalid sweep record in ${r}: (root): contains both units and rules`);if(n){let u=V0.safeParse(i);if(!u.success)throw new Error(`Invalid sweep record in ${r}: ${Rh(u.error)}`);return mw(u.data,t)}let o=F0.safeParse(i);if(!o.success)throw new Error(`Invalid sweep record in ${r}: ${Rh(o.error)}`);let{files:a,...c}=o.data;return a===void 0?c:{...c,files:a}}s(gw,"parseRecord");function hw(e){let t;try{t=JSON.parse(e)}catch(i){throw new Error(`Invalid run fold: ${i instanceof Error?i.message:String(i)}`,{cause:i})}let r=q0.safeParse(t);if(!r.success)throw new Error(`Invalid run fold: ${Rh(r.error)}`);return r.data}s(hw,"parseRunFold");function Rh(e){return e.issues.map(t=>`${t.path.join(".")||"(root)"}: ${t.message}`).join("; ")}s(Rh,"describeIssues");var or=class extends Error{static{s(this,"NotARepositoryError")}};async function Vh(e){let t=e.home??J0(),r=await tw(e.root,t),i=W0({root:e.root,paths:e.paths??[],artifactBaseDir:r,git:e.git??qi}),n=[],o={generated:0,ineligible:0,"machine-generated":0,unreadable:0,vendored:0},a=[];for(let c of i){let u=Th(c);if(u===void 0&&Fh.extname(c)!==""){o.ineligible+=1;continue}let l=ij(Fh.join(e.root,c));if(l===void 0){o.unreadable+=1;continue}let d=u??Ch(l);if(d===void 0){o.ineligible+=1;continue}if(nj(l,d)){o.generated+=1;continue}if(rj(l,d)){o.vendored+=1;continue}if(d!=="markdown"&&ej(l)){o["machine-generated"]+=1;continue}let f;try{f=Uh({file:c,content:l,kind:d})}catch(m){if(!(m instanceof wt))throw m;o.unreadable+=1;continue}d==="yaml"&&f.length===0||(a.push({file:c,bytes:Buffer.byteLength(l,"utf8")}),n.push(...f))}return{files:i,scannedFiles:a,skipped:o,spans:n}}s(Vh,"collectProse");function W0(e){let t;try{t=e.git.listFiles(e.root,e.paths)}catch{throw new or(`${e.root} is not inside a git working tree; the sweep reads what git tracks`)}return t.filter(r=>!tj({file:r,root:e.root,artifactBaseDir:e.artifactBaseDir}))}s(W0,"resolveTargetFiles");var G0="\0",Y0=[/^[ \t]*(?:#|\/\/|<!--|\*)?[ \t]*GENERATED FILE\b/m,/^[ \t]*<!-- codeassembly-/m],kt={markdown:"<!--",script:String.raw`\/\/|\/\*+|\*`,shell:"#",yaml:"#"},H0={markdown:sc(kt.markdown),script:sc(kt.script),shell:sc(kt.shell),yaml:sc(kt.yaml)},X0={markdown:cc(kt.markdown),script:cc(kt.script),shell:cc(kt.shell),yaml:cc(kt.yaml)},Q0=1e3;function vw(e){return String.raw`^[ \t]*(?:${e})[ \t]*`}s(vw,"buildCommentAnchor");function sc(e){let t=vw(e);return[new RegExp(String.raw`${t}(?:@[\w-]+[^\w\n]*)*@generated\b`,"m"),new RegExp(String.raw`${t}(?:code[ \t]+)?generated by\b.*\bdo not edit\b`,"im")]}s(sc,"buildGeneratorMarkers");function cc(e){return new RegExp(String.raw`${vw(e)}extracted verbatim from\b.*\bdo not edit\b`,"im")}s(cc,"buildVendorMarker");function ej(e){return e.split(`
|
|
226
|
-
`).some(t=>t.length>Q0)}s(ej,"hasMachineWidthLines");function tj(e){return e.file===Xt||KS(e.file)||ew(Fh.resolve(e.root,e.file),e.artifactBaseDir)}s(tj,"isExcludedPath");function nj(e,t){return Y0.some(r=>r.test(e))||H0[t].some(r=>r.test(e))}s(nj,"isGeneratedContent");function rj(e,t){return X0[t].test(e)}s(rj,"isVendoredContent");function ij(e){try{let t=K0(e,"utf8");return t.includes(G0)?void 0:t}catch{return}}s(ij,"readFileSafely");import{createHash as oj}from"node:crypto";var aj=16;function Bh(e,t){let r=new Map(t.map(i=>[i.file,[]]));for(let i of e)r.get(i.file)?.push(i.text);return new Map([...r].map(([i,n])=>[i,oj("sha256").update(JSON.stringify(n)).digest("hex").slice(0,aj)]))}s(Bh,"hashFileProse");function yw(e,t){let r=[],i=[];for(let n=0;n<e.length;n+=1){let o=e[n];if(o===void 0)continue;if(!o.startsWith("--")){r.push(o);continue}let a=sj(o,t);if(a===null)throw new Error(`unknown flag: ${o}`);let{spec:c,inlineValue:u}=a;if(!c.takesValue){if(u!==null)throw new Error(`--${c.name} does not take a value`);i.push({name:c.name,value:null});continue}if(u!==null){i.push({name:c.name,value:u});continue}let l=e[n+1]??null;if(l===null||l.startsWith("--"))throw new Error(`--${c.name} requires a value`);i.push({name:c.name,value:l}),n+=1}return{positionals:r,flags:i}}s(yw,"scanFlags");function sj(e,t){for(let r of t)for(let i of[r.name,...r.aliases??[]]){let n=`--${i}`;if(e===n)return{spec:r,inlineValue:null};if(e.startsWith(`${n}=`))return{spec:r,inlineValue:e.slice(n.length+1)}}return null}s(sj,"matchFlag");var cj=[{name:"batch-budget",takesValue:!0},{name:"rule",takesValue:!0},{name:"unit",takesValue:!0}];function bw(e){let t=yw(e,cj),r=new Map,i=[],n=98304;for(let o of t.flags){let a=o.value??"";if(o.name==="batch-budget"){if(n=Number(a),!Number.isSafeInteger(n)||n<=0)throw new Error(`--batch-budget must be a positive integer, got "${a}"`);continue}let[c,u]=uj(o.name,a);if(o.name==="unit"){r.set(c,u);continue}let[l,d]=lj(c);if(!Lh.test(l))throw new Error(`rule "${l}" is not a lowercase kebab-case name`);if(d!==void 0&&!Zh.test(d))throw new Error(`rule "${l}" names sweep version "${d}", which is not a positive integer`);let f=i.find(m=>m.rule===l);if(f!==void 0)throw new Error(`rule "${l}" is named twice, under units "${f.unit}" and "${u}"; a rule has one unit`);i.push({rule:l,unit:u,version:d})}for(let o of i)if(!r.has(o.unit))throw new Error(`rule "${o.rule}" names unit "${o.unit}", which is not declared by any --unit`);return{paths:t.positionals,rules:i,units:r,budget:n}}s(bw,"parseArgs");function $w(e){return e[0]==="detect"?e.slice(1):e}s($w,"stripCommand");function uj(e,t){let r=t.indexOf("="),i=r===-1?"":t.slice(0,r),n=r===-1?"":t.slice(r+1);if(i===""||n==="")throw new Error(`--${e} takes <name>=<value>, got "${t}"`);return[i,n]}s(uj,"splitPair");function lj(e){let t=e.indexOf("@");return t===-1?[e,void 0]:[e.slice(0,t),e.slice(t+1)]}s(lj,"splitVersion");var Ki=lr(gn(),1);function Sw(e,t,r){let i=new Map;for(let o of t.rejections){let a=qh(o.rule,o.file),c=i.get(a);c===void 0?i.set(a,[o]):c.push(o)}let n=[];for(let o of e){let a=(i.get(qh(o.rule,o.file))??[]).filter(c=>dj(c.phrase,o.phrase));if(a.length===0){n.push(o);continue}a.every(c=>xw(c,r))&&n.push({...o,stale:!0})}return n}s(Sw,"applyRejections");function ww(e,t,r,i,n){let o={...e.rules};for(let[m,{version:p}]of Object.entries(t.rules)){let h=i(m),g=e.rules[m],b=g!==void 0&&g.version===p&&g.detected===h?g.roots:[];o[m]={version:p,"swept-at":t.sweptAt,detected:h,roots:fj(b,t.roots)}}let a=Object.keys(t.rules),c=e.files??{},u={};for(let[m,p]of Object.entries(c))t.roots.every(h=>!Ji(m,h))&&(u[m]=p);for(let[m,p]of n){let h=c[m],g=h?.hash===p?[...new Set([...h.rules,...a])]:a;u[m]={hash:p,rules:g.toSorted()}}let l=t.rejections.map(m=>{let p=t.rules[m.rule]?.version;if(p===void 0)throw new Error(`rejection names rule "${m.rule}", which the fold does not version`);return{...m,"rule-version":p}}),d=new Set(l.map(m=>_w(m))),f=e.rejections.filter(m=>{if(d.has(_w(m)))return!1;let p=t.rules[m.rule];return p===void 0||t.roots.every(h=>!Ji(m.file,h))?!0:m["rule-version"]===p.version&&r(m)});return{rules:o,files:u,rejections:zw([...f,...l])}}s(ww,"composeRecord");function kw(e,t){return fe(e.prose.normalize("NFC")).includes(uc(t))?!0:fe(e.content.normalize("NFC")).includes(fe(t.normalize("NFC")))}s(kw,"containsPhrase");function xw(e,t){let r=t.get(e.rule);return r!==void 0&&r!==e["rule-version"]}s(xw,"isStaleRejection");function Iw(e,t,r,i,n){let o=[],a=e.files?.[i],c=n!==void 0&&a?.hash===n?new Set(a.rules):new Set;for(let[u,l]of t){let d=e.rules[u];d!==void 0&&d.version===l&&(d.detected||!r(u))&&d.roots.some(m=>Ji(i,m))&&c.has(u)||o.push(u)}return o}s(Iw,"listUnsweptRules");function Kh(e,t){if(e.files!==void 0)return e;let r={};for(let[i,n]of t){let o=Object.entries(e.rules).filter(([,a])=>a.roots.some(c=>Ji(i,c))).map(([a])=>a).toSorted();o.length>0&&(r[i]={hash:n,rules:o})}return{...e,files:r}}s(Kh,"seedFiles");function Nw(e,t,r){let i=new Set(r);return e.rejections.filter(n=>i.has(n.file)&&t.has(n.rule)&&!xw(n,t)).map(({rule:n,file:o,phrase:a})=>({rule:n,file:o,phrase:a}))}s(Nw,"selectPriorRejections");function Pw(e){let t=Object.fromEntries(Object.entries(e.rules).toSorted(([a],[c])=>a.localeCompare(c)).map(([a,c])=>[a,{version:c.version,"swept-at":c["swept-at"],detected:c.detected,roots:c.roots}])),r=e.files===void 0?void 0:Object.fromEntries(Object.entries(e.files).toSorted(([a],[c])=>a.localeCompare(c)).map(([a,c])=>[a,{hash:c.hash,rules:c.rules}])),i=zw(e.rejections).map(a=>({rule:a.rule,"rule-version":a["rule-version"],file:a.file,phrase:a.phrase,ground:a.ground})),n=new Ki.Document({rules:t,...r!==void 0&&{files:r},rejections:i},{aliasDuplicateObjects:!1}),o=n.get("files");if((0,Ki.isMap)(o))for(let a of o.items)(0,Ki.isMap)(a.value)&&(a.value.flow=!0);return n.toString({lineWidth:0})}s(Pw,"stringifyRecord");function qh(...e){return e.join("\0")}s(qh,"composeKey");function dj(e,t){let r=uc(e),i=uc(t);return r.includes(i)||i.includes(r)}s(dj,"coversPhrase");function Ji(e,t){return t==="."||e===t||e.startsWith(`${t}/`)}s(Ji,"isUnderRoot");function fj(e,t){let r=[...new Set([...e,...t])];return r.filter(i=>r.every(n=>n===i||!Ji(i,n))).toSorted()}s(fj,"mergeRoots");function uc(e){return fe(ac(e.normalize("NFC")))}s(uc,"normalizeForMatch");function _w(e){return qh(e.rule,e.file,uc(e.phrase))}s(_w,"rejectionKey");function zw(e){return[...e].toSorted((t,r)=>t.rule.localeCompare(r.rule)||t.file.localeCompare(r.file)||t.phrase.localeCompare(r.phrase))}s(zw,"sortRejections");function Ow(e){return e.flatMap(t=>St(t,yj).map(({line:r,sentence:i})=>({rule:"apostrophes",file:t.file,line:r,phrase:i,sentence:i})))}s(Ow,"detectDroppedApostrophes");var mj=["arent","cant","couldnt","couldve","didnt","doesnt","dont","hadnt","hasnt","havent","hed","heres","isnt","itll","ive","mustnt","neednt","shouldnt","shouldve","thatll","thats","theres","theyd","theyll","theyre","theyve","wasnt","werent","weve","whats","wheres","whos","wont","wouldnt","wouldve","youd","youll","youre","youve"],pj=["also","and","can","could","did","do","does","for","her","his","i","its","jointly","may","might","must","my","not","of","on","or","our","shall","should","still","that","their","they","to","we","which","who","whose","will","would","you","your"],gj=["a","all","an","any","each","every","her","his","it","its","my","our","some","that","the","their","them","these","this","those","your"],Wi=String.raw`[\p{L}\p{N}'\u{2019}]`,hj=String.raw`(?<!${Wi})(?!(?:${pj.join("|")})\s)[\p{L}\p{N}]+\s+own(?!${Wi})(?!\s+(?:${gj.join("|")})(?!${Wi}))`,vj=`(?<!${Wi})(?:${mj.join("|")})(?!${Wi})`,yj=new RegExp(`${hj}|${vj}`,"giu");function Aw(e){return e.flatMap(t=>St(t,bj).map(({line:r,sentence:i})=>({rule:"em-dash",file:t.file,line:r,phrase:i,sentence:i})))}s(Aw,"detectEmDashes");var bj=/\u{2014}/gu;var Le=new Set(["am","are","be","been","being","can","could","did","do","does","had","has","have","is","may","might","must","shall","should","was","were","will","would"]);function lc(e){let t=[],r=!1,i=/\S+/g,n=i.exec(e);for(;n!==null;){let o=n[0],a=o.length-o.replace(/^[^\p{L}\p{N}]+/u,"").length,c=o.replace(/^[^\p{L}\p{N}]+/u,"").replace(/[^\p{L}\p{N}]+$/u,""),u=o.slice(a+c.length);if(c==="")r=!0;else{r||=Dw.test(o.slice(0,a));let l=n.index+a;t.push({raw:c,word:c.toLowerCase(),start:l,end:l+c.length,afterBreak:r}),r=!1,r||=Dw.test(u)}n=i.exec(e)}return t}s(lc,"tokenize");var Dw=/[,;:.!?()[\]{}"\u{2013}\u{2014}]/u;function Tw(e){return e.flatMap(Pj)}s(Tw,"detectNegativeQuantifiers");var Jh=new Set(["a","an","any","each","every","her","his","its","my","our","some","the","their","these","this","those","your"]),$j=new Set(["are","be","been","being","is","was","were"]),_j=new Set(["there\u2019re","there\u2019s","there're","there's"]),Sj=3,wj=new Set(["doubt","longer","matter","one","sooner"]),kj=2,xj=3,Cw=new Set(["about","after","and","as","at","before","but","by","for","from","if","in","into","nor","on","or","so","than","that","to","when","where","which","who","whom","with","without"]),Ij=new Set(["that","which","who","whom"]);function Nj(e,t){if(Ej(e,t))return"existential";let r=e[t];return r!==void 0&&!r.afterBreak&&zj(e,t)!==void 0&&Oj(e,t)!==void 0?"relative":"other"}s(Nj,"classifyPosition");function Pj(e){let t=lc(e.text),r=[],i=-1;for(let[n,o]of t.entries()){if(o.word!=="no"||!Dj(t,n))continue;let a=Nj(t,n),c=rr(e.text,o.start,o.end),u=r.at(-1);if(u!==void 0&&c.start===i){u.positions.push(a);continue}i=c.start;let l=fe(e.text.slice(c.start,c.end));r.push({rule:"negative-quantifier",file:e.file,line:e.line+Ge(e.text,c.start),phrase:l,sentence:l,positions:[a]})}return r}s(Pj,"detectInSpan");function zj(e,t){let r=e[t-1];if(r===void 0)return;if(Ij.has(r.word)){let n=t-2,o=Ew(e[n]?.word??"")?0:kj;return jw(e,n,o)||Aj(e,n)?n:void 0}if(Ew(r.word))return;let i=t-1;return jw(e,i,0)?i:void 0}s(zj,"findHeadIndex");function Oj(e,t){for(let r=t+2;r<=t+1+xj;r+=1){let i=e[r];if(i===void 0||i.afterBreak||Cw.has(i.word))return;if(jj(i.word))return r}}s(Oj,"findVerbIndex");function Ew(e){return/(?:ing|ed)$/.test(e)||e.endsWith("s")&&!/(?:ss|us|is)$/.test(e)}s(Ew,"hasVerbEnding");function Aj(e,t){let r=e[t];if(r===void 0||!r.word.endsWith("s")||/(?:ss|us|is)$/.test(r.word)||ar(r.word)||Jh.has(r.word))return!1;let i=e[t-1];return i===void 0||r.afterBreak||ar(i.word)||i.word.endsWith("ing")}s(Aj,"isBarePluralHead");function jw(e,t,r){let i=e[t];if(i===void 0||i.afterBreak||ar(i.word)||Jh.has(i.word))return!1;for(let n=t-1;n>=Math.max(0,t-1-r);n-=1){let o=e[n];if(o===void 0||ar(o.word))return!1;if(Jh.has(o.word))return!0;if(o.afterBreak)return!1}return!1}s(jw,"isDeterminedHead");function Dj(e,t){let r=e[t+1];return r===void 0||r.afterBreak||ar(r.word)||wj.has(r.word)?!1:e[t+2]?.word!=="than"}s(Dj,"isDeterminer");function Ej(e,t){let r=e[t-1];return r===void 0?!1:_j.has(r.word)?!0:$j.has(r.word)?e.slice(Math.max(0,t-Sj),t-1).some(i=>i.word==="there"):!1}s(Ej,"isExistential");function jj(e){return Le.has(e)?!0:e.length>2&&e.endsWith("s")&&!/(?:ss|us|is)$/.test(e)&&!ar(e)}s(jj,"isFiniteVerb");function ar(e){return Cw.has(e)||Le.has(e)}s(ar,"isPhraseBreaker");var Wh=new Set(["accept","acknowledge","allow","apply","assume","avoid","begin","believe","bring","choose","compare","comprise","consider","contain","convey","create","decide","declare","define","deliver","describe","determine","discard","distinguish","emit","enable","encode","enforce","ensure","exclude","expect","explain","extend","extract","follow","forbid","govern","hide","ignore","imply","include","inherit","invoke","know","leave","lose","maintain","mean","mention","obtain","omit","perform","permit","prefer","prevent","produce","provide","receive","recognize","reduce","reject","remove","render","repeat","replace","require","resolve","retain","reveal","satisfy","seek","select","send","solve","suppose","surround","sustain","teach","tolerate","treat","understand","verify","want","withhold"]),dc=new Set(["am","are","be","been","being","is","was","were"]),Uw=new Set(["assigned","awarded","given","granted","handed","issued","offered","passed","sent","shown","taught","told"]),Gh=new Set(["appear","arise","become","belong","come","consist","depend","differ","emerge","exist","go","happen","matter","occur","persist","remain","stay","vary"]),Yh=new Set(["began","bought","broke","brought","built","caught","chose","dealt","drew","drove","found","gave","grew","held","kept","knew","laid","led","left","lent","lost","made","meant","met","paid","read","said","sent","sold","sought","spent","struck","swept","taught","thought","threw","told","took","understood","withheld","won","wrote"]),Rw=new Set(["did","do","does","had","has","have"]),fc=new Set(["always","hers","ours","perhaps","plus","sometimes","theirs","thus","versus","yes","yours"]);var Lw=new Set(["place","places","reason","reasons","time","times","way","ways"]),Zw=3,Mw=new Set(["better","bigger","broader","earlier","larger","later","longer","narrower","newer","older","shorter","smaller","wider","worse"]),mc=new Set(["and","but","nor","or"]),Fw=new Set(["more reliably","most notably","most often","most plausibly","most recently","no longer"]),Vw=new Set(["these","this","those"]),sr=new Set(["a","an","her","his","its","my","our","the","their","these","this","those","your"]),Bw=12,cr=new Set(["almost","also","barely","even","hardly","just","merely","nearly","only","simply"]),qw=new Set(["all","anybody","anyone","anything","enough","everybody","everyone","everything","less","more","much","nobody","none","nothing","somebody","someone","something","what","whatever","whoever"]),Kw=new Set(["any","every","no","some"]),Jw=new Set(["anomaly","assembly","comply","family","monopoly","multiply","reply","supply"]),Qt=new Set(["never","not"]),Ww=new Set(["other","own","same","single"]),en=new Set(["eight","eleven","five","four","nine","one","seven","six","ten","three","twelve","two"]),Hh=new Set(["her","him","me","them","us"]),Gw=new Set(["both","few","fewer","many","several","these","those"]),Gi=new Set(["about","above","across","after","against","along","among","around","as","at","before","behind","below","beneath","beside","besides","between","beyond","by","despite","down","during","except","for","from","in","inside","into","like","near","of","off","on","onto","out","outside","over","past","per","since","through","throughout","to","toward","towards","under","underneath","unlike","until","up","upon","via","with","within","without"]),Xh=new Set(["one","ones"]),Yw=new Set(["anybody","anyone","anything","everybody","everyone","everything","nobody","none","nothing","somebody","someone","something"]),tn=new Set(["all","another","any","both","each","either","enough","every","few","fewer","many","most","neither","no","nobody","none","nothing","several","some","such"]),pc=new Set(["that","when","where","which","who","whom","whose","why"]),Hw={bare:"bare",determiner:"definite",numeral:"quantified",pronoun:"pronoun",quantifier:"quantified","quantifier-pronoun":"quantified"},Yi=new Set(["he","i","it","one","she","they","we","you"]),Xw={bare:{min:1,max:1},demonstrative:{min:1,max:4},determiner:{min:2,max:4},numeral:{min:2,max:4},pronoun:{min:1,max:1},quantifier:{min:2,max:4},"quantifier-pronoun":{min:1,max:1}},Qw=new Set(["although","because","else","if","once","so","than","then","though","unless","until","whether","while","yet"]),Qh=new Set(["how","however","whose"]);function ek(e,t){let{carriedIndex:r,isPassive:i}=t;if(r!==void 0&&!(i&&!Cj(e,r)))return Tj(e,r)?r:void 0}s(ek,"closeOnCarriedVerb");function tk(e,t){if(ev(e,t))return!0;let r=e[t+1];return r!==void 0&&!r.afterBreak&&Qt.has(r.word)&&ev(e,t+1)}s(tk,"closesOnCopula");function nk(e,t,r){return r==="bare"&&Uj(e,t)?!1:tv(e[t]?.word??"")||Rj(e,t)}s(nk,"closesScannedClause");function tv(e){return xt(e)||fc.has(e)||Gh.has(e)?!1:Wh.has(e)||Yh.has(e)||/(?:ize|ise|ify)$/.test(e)||e.length>3&&e.endsWith("ed")?!0:e.length>2&&e.endsWith("s")&&!/(?:ss|us|is)$/.test(e)}s(tv,"isFiniteVerb");function xt(e){return Le.has(e)||mc.has(e)||sr.has(e)||cr.has(e)||en.has(e)||Hh.has(e)||Gi.has(e)||tn.has(e)||pc.has(e)||Yi.has(e)||Qw.has(e)}s(xt,"isFunctionWord");function nv(e){return e.length<=4||!e.endsWith("ly")?!1:!Wh.has(e)&&!Yh.has(e)&&!Jw.has(e)}s(nv,"isMannerAdverb");function ur(e){return e.length>3&&e.endsWith("s")&&!/(?:ss|us|is)$/.test(e)&&!xt(e)&&!fc.has(e)}s(ur,"isPluralNoun");function rk(e,t){let r=Math.min(t+Zw,e.length-1),i=t;for(let n=t+1;n<=r;n+=1){let o=e[n];if(o===void 0||o.afterBreak)break;if(Le.has(o.word)){i=n;continue}if(Qt.has(o.word)||nv(o.word))continue;if(xt(o.word))break;let a=e[i]?.word??"",c=dc.has(a)&&!o.word.endsWith("ing");return{carriedIndex:n,isPassive:c,lastAuxiliaryIndex:i}}return{carriedIndex:void 0,isPassive:!1,lastAuxiliaryIndex:i}}s(rk,"resolveAuxiliaryChain");function gc(e,t){return hc(e,t)&&ev(e,t+1)}s(gc,"strandsClauseFinalPreposition");function Tj(e,t){return!Gh.has(e[t]?.word??"")||hc(e,t)}s(Tj,"closesCarriedClause");function hc(e,t){let r=e[t+1];if(r===void 0||r.afterBreak||!Gi.has(r.word))return!1;let i=e[t+2];return i===void 0||i.afterBreak?!0:sr.has(i.word)||en.has(i.word)||tn.has(i.word)?!1:!Yi.has(i.word)&&!Hh.has(i.word)&&xt(i.word)}s(hc,"hasStrandedPreposition");function Cj(e,t){if(hc(e,t)||Uw.has(e[t]?.word??""))return!0;let r=e[t+1];if(r===void 0||r.afterBreak||r.word!=="to")return!1;let i=e[t+2];return i!==void 0&&!i.afterBreak&&!xt(i.word)}s(Cj,"hostsGap");function Uj(e,t){let r=e[t]?.word??"";if(r.length<=3||!r.endsWith("ed"))return!1;let i=e[t+1];return i!==void 0&&!i.afterBreak&&i.word==="by"}s(Uj,"isAgentiveParticiple");function ev(e,t){let r=e[t+1];return r===void 0||r.afterBreak}s(ev,"isClauseFinal");function Rj(e,t){let r=e[t]?.word??"";return r===""||xt(r)||fc.has(r)?!1:hc(e,t)}s(Rj,"isStrandedVerb");function ik(e,t){let r=e[t];if(r===void 0)return;let{word:i}=r;if(i!==ir)return Yi.has(i)?Zj(e,t)?void 0:"pronoun":sk(i)?"numeral":Yw.has(i)?"quantifier-pronoun":tn.has(i)?Lj(e,t)?void 0:"quantifier":Vw.has(i)?"demonstrative":sr.has(i)?"determiner":ur(i)?"bare":void 0}s(ik,"classifySubject");function ok(e,t){let r=t;for(;r>0;){let i=e[r];if(i===void 0||i.afterBreak)return;r-=1;let n=e[r];if(n===void 0||n.word===ir)return;if(!cr.has(n.word))return Xh.has(n.word)?Fj(e,r)?void 0:r:Bj(e,r)||xt(n.word)||qw.has(n.word)||Lw.has(n.word)||Qh.has(n.word)||Ww.has(n.word)||Vj(e,r)?void 0:Mj(e,r)?r:void 0}}s(ok,"findHeadIndex");function ak(e,t){for(let r=t-1;r>=0&&r>=t-2;r-=1){let i=e[r];if(i===void 0)return!1;if(ck(i.word,e[t]?.word??""))return!0;if(e[r+1]?.afterBreak===!0)return!1}return!1}s(ak,"isDeterminedPhrase");function Lj(e,t){let r=e[t+1];return r===void 0||r.afterBreak?!1:Fw.has(`${e[t]?.word??""} ${r.word}`)}s(Lj,"opensDegreeAdverbial");function Zj(e,t){let r=e[t];return r===void 0||r.afterBreak||!Xh.has(r.word)?!1:Mw.has(e[t-1]?.word??"")}s(Zj,"closesComparativePhrase");function Mj(e,t){let r=e[t];return r===void 0?!1:!tv(r.word)&&!r.word.endsWith("ing")?!0:r.afterBreak||t===0?!1:ck(e[t-1]?.word??"",r.word)}s(Mj,"isDeterminedHead");function Fj(e,t){return t===0||e[t]?.afterBreak===!0?!1:Kw.has(e[t-1]?.word??"")}s(Fj,"isFusedProForm");function sk(e){return en.has(e)||/^\d+$/.test(e)}s(sk,"isNumeral");function ck(e,t){return en.has(e)&&e!=="one"||Gw.has(e)||/^\d+$/.test(e)?e!=="1"&&ur(t):sr.has(e)||tn.has(e)||en.has(e)}s(ck,"isSpecifier");function Vj(e,t){let r=e[t];if(r===void 0)return!0;if(t===0||r.afterBreak)return!ur(r.word);let i=e[t-1]?.word??"",n=Qt.has(i)?e[t-2]?.word??"":i;return n==="to"||Le.has(n)}s(Vj,"isVerbPosition");function Bj(e,t){for(let r=t-1;r>=0;r-=1){let i=e[r+1];if(i===void 0||i.afterBreak)return!1;let n=e[r]?.word??"";if(Qh.has(n))return!0;if(!tn.has(n)&&!sk(n))return!1}return!1}s(Bj,"isWhMarkedHead");function uk(e){let t=[];for(let r of e)t.push(...Kj(r));return t}s(uk,"detectObjectRelatives");function lk(e){return!e.endsWith("s")}s(lk,"agreesWithPluralSubject");function qj(e){let{span:t,tokens:r,headIndex:i,subjectIndex:n,verbIndex:o,shape:a}=e,c=r[i],u=r[o];if(c===void 0||u===void 0)throw new Error("candidate resolved outside its token run");let l=r.slice(n,o).map(d=>d.word===ir?oc:d.raw).join(" ");return{rule:"reduced-object-relative",file:t.file,line:t.line+Ge(t.text,c.start),shape:a,head:c.raw,subject:l,verb:u.raw,phrase:fe(t.text.slice(c.start,u.end)),sentence:nw(t.text,c.start,u.end)}}s(qj,"buildCandidate");function Kj(e){let t=lc(e.text),r=[],i=-1;for(let n=1;n<t.length;n+=1){let o=ok(t,n);if(o===void 0)continue;let a=o<=i,c=ik(t,n);if(c===void 0||c==="bare"&&!ak(t,o))continue;let u=Jj(t,n,c);if(u===void 0||a&&u!==i)continue;i=u;let l=Wj({tokens:t,kind:c,subjectIndex:n,verbIndex:u}),d=qj({span:e,tokens:t,headIndex:o,subjectIndex:n,verbIndex:u,shape:l});a?r[r.length-1]=d:r.push(d)}return r}s(Kj,"detectInSpan");function Jj(e,t,r){let i=Xw[r],n=t+i.min,o=Math.min(t+i.max,e.length-1),a=!1;for(let c=t+1;c<=o;c+=1){let u=e[c];if(u===void 0||u.afterBreak||mc.has(u.word)||pc.has(u.word))return;if(Gi.has(u.word)&&u.word!=="of"){a=!0,o=Math.min(t+Bw,e.length-1);continue}if(dk(u.word)){o=Math.min(o+1,e.length-1);continue}if(u.word===ir)continue;let l=Le.has(u.word)&&c>=n?Yj({tokens:e,index:c,kind:r,crossedPreposition:a}):Hj({tokens:e,index:c,subjectIndex:t,first:n,kind:r,crossedPreposition:a});if(l.outcome==="close")return l.verbIndex;if(l.outcome==="stop")return}}s(Jj,"findVerbIndex");function Wj(e){let{tokens:t,kind:r,subjectIndex:i,verbIndex:n}=e;return r!=="demonstrative"?Hw[r]:Gj(t,i,n)?"pronoun":"definite"}s(Wj,"resolveShape");function Gj(e,t,r){for(let i=t+1;i<r;i+=1)if(!dk(e[i]?.word??""))return!1;return!0}s(Gj,"standsAlone");function dk(e){return Qt.has(e)||cr.has(e)||nv(e)}s(dk,"skipsAsModifier");function Yj(e){let{tokens:t,index:r,kind:i,crossedPreposition:n}=e,o=rk(t,r);if(o.carriedIndex!==void 0){let c=ek(t,o);return c===void 0?{outcome:"stop"}:n&&!gc(t,c)?{outcome:"stop"}:{outcome:"close",verbIndex:c}}let a=t[o.lastAuxiliaryIndex]?.word??"";return dc.has(a)&&tk(t,o.lastAuxiliaryIndex)?{outcome:"close",verbIndex:o.lastAuxiliaryIndex}:Rw.has(a)?n&&!gc(t,o.lastAuxiliaryIndex)?{outcome:"continue"}:i==="bare"&&!lk(t[r]?.word??"")?{outcome:"stop"}:{outcome:"close",verbIndex:o.lastAuxiliaryIndex}:{outcome:"continue"}}s(Yj,"resolveAuxiliaryStep");function Hj(e){let{tokens:t,index:r,subjectIndex:i,first:n,kind:o,crossedPreposition:a}=e,c=t[r]?.word??"";return r<n||!nk(t,r,o)?{outcome:"continue"}:o==="demonstrative"&&r===i+1&&ur(c)?{outcome:"continue"}:a&&!gc(t,r)?{outcome:"continue"}:o==="bare"&&!lk(c)?{outcome:"stop"}:{outcome:"close",verbIndex:r}}s(Hj,"resolveScannedStep");var Xj=new Map([["carry",["carries","carried","carrying"]],["cost",["costs","costing"]],["hold",["holds","held","holding"]],["land",["lands","landed","landing"]],["reach",["reaches","reached","reaching"]],["route",["routes","routed","routing"]],["ship",["ships","shipped","shipping"]],["sit",["sits","sat","sitting"]],["stand",["stands","stood","standing"]],["surface",["surfaces","surfaced","surfacing"]]]);function fk(e){return e.flatMap(tT)}s(fk,"detectOverusedWords");var mk=new Map([...Xj].flatMap(([e,t])=>[e,...t].map(r=>[r,e]))),Qj=new RegExp(String.raw`\b(?:${mk.keys().toArray().join("|")})\b`,"giu"),eT=/^\s+in\s+for\b/iu;function tT(e){let t=Yt(e.text),r=new Map;for(let i of e.text.matchAll(Qj)){let n=i.index,o=n+i[0].length;if(t.some(l=>n>=l.start&&n<l.end))continue;let a=mk.get(i[0].toLowerCase());if(a===void 0||a==="stand"&&eT.test(e.text.slice(o)))continue;let c=rr(e.text,n,o),u=r.get(c.start)??{end:c.end,words:[]};u.words.includes(a)||u.words.push(a),r.set(c.start,u)}return[...r].map(([i,{end:n,words:o}])=>{let a=fe(e.text.slice(i,n));return{rule:"overused-word",file:e.file,line:e.line+Ge(e.text,i),phrase:a,sentence:a,words:o}})}s(tT,"detectInSpan");function pk(e){return e.filter(t=>!iT(t.file)).flatMap(t=>St(t,rT).map(({line:r,sentence:i})=>({rule:"second-person",file:t.file,line:r,phrase:i,sentence:i})))}s(pk,"detectSecondPersonPronouns");var nT=/\.(?:markdown|md)$/i,rT=/\byou(?:rs?|rself|rselves)?\b/giu;function iT(e){let t=e.split("/"),r=t.at(-1)??"";if(r==="SKILL.md")return!0;if(!nT.test(r))return!1;let i=t.at(-2),n=t.at(-3);return i==="_partials"?n==="skills"||n==="subagents":i==="subagents"||i==="agents"&&n===".claude"}s(iT,"isAgentInstructionBody");function gk(e){return Map.groupBy(e,t=>t.file).values().flatMap(lT).toArray()}s(gk,"detectSoUses");var oT=["far","few","little","many","much","on"],aT=["did","do","does","doing","done","if","said","say","saying","says"],sT=/(?:[,;–—]|--|\band)\s*$/iu,cT=3,uT=new RegExp(String.raw`(?<!\b(?:${aT.join("|")})\s+)`+String.raw`(?:(?<=(?:^|[,;.!?])\s*)\bso\b|\bso\b(?!\s+(?:${oT.join("|")})\b))`+String.raw`(?!-|\s+that\b)`,"giu");function lT(e){let t=e.toSorted((i,n)=>i.line-n.line).flatMap(fT),r=[];for(let[i,n]of t.entries()){if(n.siteCount===0)continue;let o=t.slice(Math.max(0,i-cT),i),a=n.siteCount>1||o.some(c=>c.siteCount>0);!n.hasBareSite&&!a||r.push({rule:"so",file:n.file,line:n.line,phrase:n.text,sentence:n.text,trigger:n.hasBareSite?"bare":"repeat"})}return r}s(lT,"detectInFile");function dT(e){return/[\p{L}\p{N}]/u.test(e)&&!sT.test(e)}s(dT,"isBareSite");function fT(e){let t=Yt(e.text),r=e.text.matchAll(uT).map(i=>i.index).filter(i=>t.every(n=>i<n.start||i>=n.end)).toArray();return rw(e.text).map(({start:i,end:n})=>{let o=r.filter(a=>a>=i&&a<n);return{file:e.file,hasBareSite:o.some(a=>dT(e.text.slice(i,a))),line:e.line+Ge(e.text,i),siteCount:o.length,text:fe(e.text.slice(i,n))}})}s(fT,"listSiteSentences");function hk(e){return e.flatMap(t=>St(t,mT).map(({line:r,sentence:i})=>({rule:"where",file:t.file,line:r,phrase:i,sentence:i})))}s(hk,"detectWhereUses");var mT=/\bwhere\b/giu;var vk={apostrophes:Ow,"em-dash":Aw,"negative-quantifier":Tw,"overused-word":fk,"reduced-object-relative":uk,"second-person":pk,so:gk,where:hk};function yk(e,t){let r=new Map;for(let n of e)r.has(n.file)||r.set(n.file,r.size);return t.flatMap(n=>vk[n](e)).toSorted((n,o)=>(r.get(n.file)??0)-(r.get(o.file)??0)||n.line-o.line)}s(yk,"detectRules");function Hi(e){return Object.hasOwn(vk,e)}s(Hi,"isRuleId");var hT={rules:{},rejections:[]},vT=["reduced-object-relative"];async function yT(){try{let e=nn.argv.slice(2),t=e[0]==="record"?await $T({foldJson:await NT(),root:nn.cwd()}):await bT({argv:$w(e),root:nn.cwd()});nn.stdout.write(`${JSON.stringify(t,null,2)}
|
|
226
|
+
`).some(t=>t.length>Q0)}s(ej,"hasMachineWidthLines");function tj(e){return e.file===Xt||KS(e.file)||ew(Fh.resolve(e.root,e.file),e.artifactBaseDir)}s(tj,"isExcludedPath");function nj(e,t){return Y0.some(r=>r.test(e))||H0[t].some(r=>r.test(e))}s(nj,"isGeneratedContent");function rj(e,t){return X0[t].test(e)}s(rj,"isVendoredContent");function ij(e){try{let t=K0(e,"utf8");return t.includes(G0)?void 0:t}catch{return}}s(ij,"readFileSafely");import{createHash as oj}from"node:crypto";var aj=16;function Bh(e,t){let r=new Map(t.map(i=>[i.file,[]]));for(let i of e)r.get(i.file)?.push(i.text);return new Map([...r].map(([i,n])=>[i,oj("sha256").update(JSON.stringify(n)).digest("hex").slice(0,aj)]))}s(Bh,"hashFileProse");function yw(e,t){let r=[],i=[];for(let n=0;n<e.length;n+=1){let o=e[n];if(o===void 0)continue;if(!o.startsWith("--")){r.push(o);continue}let a=sj(o,t);if(a===null)throw new Error(`unknown flag: ${o}`);let{spec:c,inlineValue:u}=a;if(!c.takesValue){if(u!==null)throw new Error(`--${c.name} does not take a value`);i.push({name:c.name,value:null});continue}if(u!==null){i.push({name:c.name,value:u});continue}let l=e[n+1]??null;if(l===null||l.startsWith("--"))throw new Error(`--${c.name} requires a value`);i.push({name:c.name,value:l}),n+=1}return{positionals:r,flags:i}}s(yw,"scanFlags");function sj(e,t){for(let r of t)for(let i of[r.name,...r.aliases??[]]){let n=`--${i}`;if(e===n)return{spec:r,inlineValue:null};if(e.startsWith(`${n}=`))return{spec:r,inlineValue:e.slice(n.length+1)}}return null}s(sj,"matchFlag");var cj=[{name:"batch-budget",takesValue:!0},{name:"resweep",takesValue:!1},{name:"rule",takesValue:!0},{name:"unit",takesValue:!0}];function bw(e){let t=yw(e,cj),r=new Map,i=[],n=98304,o=!1;for(let a of t.flags){if(a.name==="resweep"){o=!0;continue}let c=a.value??"";if(a.name==="batch-budget"){if(n=Number(c),!Number.isSafeInteger(n)||n<=0)throw new Error(`--batch-budget must be a positive integer, got "${c}"`);continue}let[u,l]=uj(a.name,c);if(a.name==="unit"){r.set(u,l);continue}let[d,f]=lj(u);if(!Lh.test(d))throw new Error(`rule "${d}" is not a lowercase kebab-case name`);if(f!==void 0&&!Zh.test(f))throw new Error(`rule "${d}" names sweep version "${f}", which is not a positive integer`);let m=i.find(p=>p.rule===d);if(m!==void 0)throw new Error(`rule "${d}" is named twice, under units "${m.unit}" and "${l}"; a rule has one unit`);i.push({rule:d,unit:l,version:f})}for(let a of i)if(!r.has(a.unit))throw new Error(`rule "${a.rule}" names unit "${a.unit}", which is not declared by any --unit`);return{paths:t.positionals,rules:i,units:r,budget:n,resweep:o}}s(bw,"parseArgs");function $w(e){return e[0]==="detect"?e.slice(1):e}s($w,"stripCommand");function uj(e,t){let r=t.indexOf("="),i=r===-1?"":t.slice(0,r),n=r===-1?"":t.slice(r+1);if(i===""||n==="")throw new Error(`--${e} takes <name>=<value>, got "${t}"`);return[i,n]}s(uj,"splitPair");function lj(e){let t=e.indexOf("@");return t===-1?[e,void 0]:[e.slice(0,t),e.slice(t+1)]}s(lj,"splitVersion");var Ki=lr(gn(),1);function Sw(e,t,r){let i=new Map;for(let o of t.rejections){let a=qh(o.rule,o.file),c=i.get(a);c===void 0?i.set(a,[o]):c.push(o)}let n=[];for(let o of e){let a=(i.get(qh(o.rule,o.file))??[]).filter(c=>dj(c.phrase,o.phrase));if(a.length===0){n.push(o);continue}a.every(c=>xw(c,r))&&n.push({...o,stale:!0})}return n}s(Sw,"applyRejections");function ww(e,t,r,i,n){let o={...e.rules};for(let[m,{version:p}]of Object.entries(t.rules)){let h=i(m),g=e.rules[m],b=g!==void 0&&g.version===p&&g.detected===h?g.roots:[];o[m]={version:p,"swept-at":t.sweptAt,detected:h,roots:fj(b,t.roots)}}let a=Object.keys(t.rules),c=e.files??{},u={};for(let[m,p]of Object.entries(c))t.roots.every(h=>!Ji(m,h))&&(u[m]=p);for(let[m,p]of n){let h=c[m],g=h?.hash===p?[...new Set([...h.rules,...a])]:a;u[m]={hash:p,rules:g.toSorted()}}let l=t.rejections.map(m=>{let p=t.rules[m.rule]?.version;if(p===void 0)throw new Error(`rejection names rule "${m.rule}", which the fold does not version`);return{...m,"rule-version":p}}),d=new Set(l.map(m=>_w(m))),f=e.rejections.filter(m=>{if(d.has(_w(m)))return!1;let p=t.rules[m.rule];return p===void 0||t.roots.every(h=>!Ji(m.file,h))?!0:m["rule-version"]===p.version&&r(m)});return{rules:o,files:u,rejections:zw([...f,...l])}}s(ww,"composeRecord");function kw(e,t){return fe(e.prose.normalize("NFC")).includes(uc(t))?!0:fe(e.content.normalize("NFC")).includes(fe(t.normalize("NFC")))}s(kw,"containsPhrase");function xw(e,t){let r=t.get(e.rule);return r!==void 0&&r!==e["rule-version"]}s(xw,"isStaleRejection");function Iw(e,t,r,i,n){let o=[],a=e.files?.[i],c=n!==void 0&&a?.hash===n?new Set(a.rules):new Set;for(let[u,l]of t){let d=e.rules[u];d!==void 0&&d.version===l&&(d.detected||!r(u))&&d.roots.some(m=>Ji(i,m))&&c.has(u)||o.push(u)}return o}s(Iw,"listUnsweptRules");function Kh(e,t){if(e.files!==void 0)return e;let r={};for(let[i,n]of t){let o=Object.entries(e.rules).filter(([,a])=>a.roots.some(c=>Ji(i,c))).map(([a])=>a).toSorted();o.length>0&&(r[i]={hash:n,rules:o})}return{...e,files:r}}s(Kh,"seedFiles");function Nw(e,t,r){let i=new Set(r);return e.rejections.filter(n=>i.has(n.file)&&t.has(n.rule)&&!xw(n,t)).map(({rule:n,file:o,phrase:a})=>({rule:n,file:o,phrase:a}))}s(Nw,"selectPriorRejections");function Pw(e){let t=Object.fromEntries(Object.entries(e.rules).toSorted(([a],[c])=>a.localeCompare(c)).map(([a,c])=>[a,{version:c.version,"swept-at":c["swept-at"],detected:c.detected,roots:c.roots}])),r=e.files===void 0?void 0:Object.fromEntries(Object.entries(e.files).toSorted(([a],[c])=>a.localeCompare(c)).map(([a,c])=>[a,{hash:c.hash,rules:c.rules}])),i=zw(e.rejections).map(a=>({rule:a.rule,"rule-version":a["rule-version"],file:a.file,phrase:a.phrase,ground:a.ground})),n=new Ki.Document({rules:t,...r!==void 0&&{files:r},rejections:i},{aliasDuplicateObjects:!1}),o=n.get("files");if((0,Ki.isMap)(o))for(let a of o.items)(0,Ki.isMap)(a.value)&&(a.value.flow=!0);return n.toString({lineWidth:0})}s(Pw,"stringifyRecord");function qh(...e){return e.join("\0")}s(qh,"composeKey");function dj(e,t){let r=uc(e),i=uc(t);return r.includes(i)||i.includes(r)}s(dj,"coversPhrase");function Ji(e,t){return t==="."||e===t||e.startsWith(`${t}/`)}s(Ji,"isUnderRoot");function fj(e,t){let r=[...new Set([...e,...t])];return r.filter(i=>r.every(n=>n===i||!Ji(i,n))).toSorted()}s(fj,"mergeRoots");function uc(e){return fe(ac(e.normalize("NFC")))}s(uc,"normalizeForMatch");function _w(e){return qh(e.rule,e.file,uc(e.phrase))}s(_w,"rejectionKey");function zw(e){return[...e].toSorted((t,r)=>t.rule.localeCompare(r.rule)||t.file.localeCompare(r.file)||t.phrase.localeCompare(r.phrase))}s(zw,"sortRejections");function Ow(e){return e.flatMap(t=>St(t,yj).map(({line:r,sentence:i})=>({rule:"apostrophes",file:t.file,line:r,phrase:i,sentence:i})))}s(Ow,"detectDroppedApostrophes");var mj=["arent","cant","couldnt","couldve","didnt","doesnt","dont","hadnt","hasnt","havent","hed","heres","isnt","itll","ive","mustnt","neednt","shouldnt","shouldve","thatll","thats","theres","theyd","theyll","theyre","theyve","wasnt","werent","weve","whats","wheres","whos","wont","wouldnt","wouldve","youd","youll","youre","youve"],pj=["also","and","can","could","did","do","does","for","her","his","i","its","jointly","may","might","must","my","not","of","on","or","our","shall","should","still","that","their","they","to","we","which","who","whose","will","would","you","your"],gj=["a","all","an","any","each","every","her","his","it","its","my","our","some","that","the","their","them","these","this","those","your"],Wi=String.raw`[\p{L}\p{N}'\u{2019}]`,hj=String.raw`(?<!${Wi})(?!(?:${pj.join("|")})\s)[\p{L}\p{N}]+\s+own(?!${Wi})(?!\s+(?:${gj.join("|")})(?!${Wi}))`,vj=`(?<!${Wi})(?:${mj.join("|")})(?!${Wi})`,yj=new RegExp(`${hj}|${vj}`,"giu");function Aw(e){return e.flatMap(t=>St(t,bj).map(({line:r,sentence:i})=>({rule:"em-dash",file:t.file,line:r,phrase:i,sentence:i})))}s(Aw,"detectEmDashes");var bj=/\u{2014}/gu;var Le=new Set(["am","are","be","been","being","can","could","did","do","does","had","has","have","is","may","might","must","shall","should","was","were","will","would"]);function lc(e){let t=[],r=!1,i=/\S+/g,n=i.exec(e);for(;n!==null;){let o=n[0],a=o.length-o.replace(/^[^\p{L}\p{N}]+/u,"").length,c=o.replace(/^[^\p{L}\p{N}]+/u,"").replace(/[^\p{L}\p{N}]+$/u,""),u=o.slice(a+c.length);if(c==="")r=!0;else{r||=Dw.test(o.slice(0,a));let l=n.index+a;t.push({raw:c,word:c.toLowerCase(),start:l,end:l+c.length,afterBreak:r}),r=!1,r||=Dw.test(u)}n=i.exec(e)}return t}s(lc,"tokenize");var Dw=/[,;:.!?()[\]{}"\u{2013}\u{2014}]/u;function Tw(e){return e.flatMap(Pj)}s(Tw,"detectNegativeQuantifiers");var Jh=new Set(["a","an","any","each","every","her","his","its","my","our","some","the","their","these","this","those","your"]),$j=new Set(["are","be","been","being","is","was","were"]),_j=new Set(["there\u2019re","there\u2019s","there're","there's"]),Sj=3,wj=new Set(["doubt","longer","matter","one","sooner"]),kj=2,xj=3,Cw=new Set(["about","after","and","as","at","before","but","by","for","from","if","in","into","nor","on","or","so","than","that","to","when","where","which","who","whom","with","without"]),Ij=new Set(["that","which","who","whom"]);function Nj(e,t){if(Ej(e,t))return"existential";let r=e[t];return r!==void 0&&!r.afterBreak&&zj(e,t)!==void 0&&Oj(e,t)!==void 0?"relative":"other"}s(Nj,"classifyPosition");function Pj(e){let t=lc(e.text),r=[],i=-1;for(let[n,o]of t.entries()){if(o.word!=="no"||!Dj(t,n))continue;let a=Nj(t,n),c=rr(e.text,o.start,o.end),u=r.at(-1);if(u!==void 0&&c.start===i){u.positions.push(a);continue}i=c.start;let l=fe(e.text.slice(c.start,c.end));r.push({rule:"negative-quantifier",file:e.file,line:e.line+Ge(e.text,c.start),phrase:l,sentence:l,positions:[a]})}return r}s(Pj,"detectInSpan");function zj(e,t){let r=e[t-1];if(r===void 0)return;if(Ij.has(r.word)){let n=t-2,o=Ew(e[n]?.word??"")?0:kj;return jw(e,n,o)||Aj(e,n)?n:void 0}if(Ew(r.word))return;let i=t-1;return jw(e,i,0)?i:void 0}s(zj,"findHeadIndex");function Oj(e,t){for(let r=t+2;r<=t+1+xj;r+=1){let i=e[r];if(i===void 0||i.afterBreak||Cw.has(i.word))return;if(jj(i.word))return r}}s(Oj,"findVerbIndex");function Ew(e){return/(?:ing|ed)$/.test(e)||e.endsWith("s")&&!/(?:ss|us|is)$/.test(e)}s(Ew,"hasVerbEnding");function Aj(e,t){let r=e[t];if(r===void 0||!r.word.endsWith("s")||/(?:ss|us|is)$/.test(r.word)||ar(r.word)||Jh.has(r.word))return!1;let i=e[t-1];return i===void 0||r.afterBreak||ar(i.word)||i.word.endsWith("ing")}s(Aj,"isBarePluralHead");function jw(e,t,r){let i=e[t];if(i===void 0||i.afterBreak||ar(i.word)||Jh.has(i.word))return!1;for(let n=t-1;n>=Math.max(0,t-1-r);n-=1){let o=e[n];if(o===void 0||ar(o.word))return!1;if(Jh.has(o.word))return!0;if(o.afterBreak)return!1}return!1}s(jw,"isDeterminedHead");function Dj(e,t){let r=e[t+1];return r===void 0||r.afterBreak||ar(r.word)||wj.has(r.word)?!1:e[t+2]?.word!=="than"}s(Dj,"isDeterminer");function Ej(e,t){let r=e[t-1];return r===void 0?!1:_j.has(r.word)?!0:$j.has(r.word)?e.slice(Math.max(0,t-Sj),t-1).some(i=>i.word==="there"):!1}s(Ej,"isExistential");function jj(e){return Le.has(e)?!0:e.length>2&&e.endsWith("s")&&!/(?:ss|us|is)$/.test(e)&&!ar(e)}s(jj,"isFiniteVerb");function ar(e){return Cw.has(e)||Le.has(e)}s(ar,"isPhraseBreaker");var Wh=new Set(["accept","acknowledge","allow","apply","assume","avoid","begin","believe","bring","choose","compare","comprise","consider","contain","convey","create","decide","declare","define","deliver","describe","determine","discard","distinguish","emit","enable","encode","enforce","ensure","exclude","expect","explain","extend","extract","follow","forbid","govern","hide","ignore","imply","include","inherit","invoke","know","leave","lose","maintain","mean","mention","obtain","omit","perform","permit","prefer","prevent","produce","provide","receive","recognize","reduce","reject","remove","render","repeat","replace","require","resolve","retain","reveal","satisfy","seek","select","send","solve","suppose","surround","sustain","teach","tolerate","treat","understand","verify","want","withhold"]),dc=new Set(["am","are","be","been","being","is","was","were"]),Uw=new Set(["assigned","awarded","given","granted","handed","issued","offered","passed","sent","shown","taught","told"]),Gh=new Set(["appear","arise","become","belong","come","consist","depend","differ","emerge","exist","go","happen","matter","occur","persist","remain","stay","vary"]),Yh=new Set(["began","bought","broke","brought","built","caught","chose","dealt","drew","drove","found","gave","grew","held","kept","knew","laid","led","left","lent","lost","made","meant","met","paid","read","said","sent","sold","sought","spent","struck","swept","taught","thought","threw","told","took","understood","withheld","won","wrote"]),Rw=new Set(["did","do","does","had","has","have"]),fc=new Set(["always","hers","ours","perhaps","plus","sometimes","theirs","thus","versus","yes","yours"]);var Lw=new Set(["place","places","reason","reasons","time","times","way","ways"]),Zw=3,Mw=new Set(["better","bigger","broader","earlier","larger","later","longer","narrower","newer","older","shorter","smaller","wider","worse"]),mc=new Set(["and","but","nor","or"]),Fw=new Set(["more reliably","most notably","most often","most plausibly","most recently","no longer"]),Vw=new Set(["these","this","those"]),sr=new Set(["a","an","her","his","its","my","our","the","their","these","this","those","your"]),Bw=12,cr=new Set(["almost","also","barely","even","hardly","just","merely","nearly","only","simply"]),qw=new Set(["all","anybody","anyone","anything","enough","everybody","everyone","everything","less","more","much","nobody","none","nothing","somebody","someone","something","what","whatever","whoever"]),Kw=new Set(["any","every","no","some"]),Jw=new Set(["anomaly","assembly","comply","family","monopoly","multiply","reply","supply"]),Qt=new Set(["never","not"]),Ww=new Set(["other","own","same","single"]),en=new Set(["eight","eleven","five","four","nine","one","seven","six","ten","three","twelve","two"]),Hh=new Set(["her","him","me","them","us"]),Gw=new Set(["both","few","fewer","many","several","these","those"]),Gi=new Set(["about","above","across","after","against","along","among","around","as","at","before","behind","below","beneath","beside","besides","between","beyond","by","despite","down","during","except","for","from","in","inside","into","like","near","of","off","on","onto","out","outside","over","past","per","since","through","throughout","to","toward","towards","under","underneath","unlike","until","up","upon","via","with","within","without"]),Xh=new Set(["one","ones"]),Yw=new Set(["anybody","anyone","anything","everybody","everyone","everything","nobody","none","nothing","somebody","someone","something"]),tn=new Set(["all","another","any","both","each","either","enough","every","few","fewer","many","most","neither","no","nobody","none","nothing","several","some","such"]),pc=new Set(["that","when","where","which","who","whom","whose","why"]),Hw={bare:"bare",determiner:"definite",numeral:"quantified",pronoun:"pronoun",quantifier:"quantified","quantifier-pronoun":"quantified"},Yi=new Set(["he","i","it","one","she","they","we","you"]),Xw={bare:{min:1,max:1},demonstrative:{min:1,max:4},determiner:{min:2,max:4},numeral:{min:2,max:4},pronoun:{min:1,max:1},quantifier:{min:2,max:4},"quantifier-pronoun":{min:1,max:1}},Qw=new Set(["although","because","else","if","once","so","than","then","though","unless","until","whether","while","yet"]),Qh=new Set(["how","however","whose"]);function ek(e,t){let{carriedIndex:r,isPassive:i}=t;if(r!==void 0&&!(i&&!Cj(e,r)))return Tj(e,r)?r:void 0}s(ek,"closeOnCarriedVerb");function tk(e,t){if(ev(e,t))return!0;let r=e[t+1];return r!==void 0&&!r.afterBreak&&Qt.has(r.word)&&ev(e,t+1)}s(tk,"closesOnCopula");function nk(e,t,r){return r==="bare"&&Uj(e,t)?!1:tv(e[t]?.word??"")||Rj(e,t)}s(nk,"closesScannedClause");function tv(e){return xt(e)||fc.has(e)||Gh.has(e)?!1:Wh.has(e)||Yh.has(e)||/(?:ize|ise|ify)$/.test(e)||e.length>3&&e.endsWith("ed")?!0:e.length>2&&e.endsWith("s")&&!/(?:ss|us|is)$/.test(e)}s(tv,"isFiniteVerb");function xt(e){return Le.has(e)||mc.has(e)||sr.has(e)||cr.has(e)||en.has(e)||Hh.has(e)||Gi.has(e)||tn.has(e)||pc.has(e)||Yi.has(e)||Qw.has(e)}s(xt,"isFunctionWord");function nv(e){return e.length<=4||!e.endsWith("ly")?!1:!Wh.has(e)&&!Yh.has(e)&&!Jw.has(e)}s(nv,"isMannerAdverb");function ur(e){return e.length>3&&e.endsWith("s")&&!/(?:ss|us|is)$/.test(e)&&!xt(e)&&!fc.has(e)}s(ur,"isPluralNoun");function rk(e,t){let r=Math.min(t+Zw,e.length-1),i=t;for(let n=t+1;n<=r;n+=1){let o=e[n];if(o===void 0||o.afterBreak)break;if(Le.has(o.word)){i=n;continue}if(Qt.has(o.word)||nv(o.word))continue;if(xt(o.word))break;let a=e[i]?.word??"",c=dc.has(a)&&!o.word.endsWith("ing");return{carriedIndex:n,isPassive:c,lastAuxiliaryIndex:i}}return{carriedIndex:void 0,isPassive:!1,lastAuxiliaryIndex:i}}s(rk,"resolveAuxiliaryChain");function gc(e,t){return hc(e,t)&&ev(e,t+1)}s(gc,"strandsClauseFinalPreposition");function Tj(e,t){return!Gh.has(e[t]?.word??"")||hc(e,t)}s(Tj,"closesCarriedClause");function hc(e,t){let r=e[t+1];if(r===void 0||r.afterBreak||!Gi.has(r.word))return!1;let i=e[t+2];return i===void 0||i.afterBreak?!0:sr.has(i.word)||en.has(i.word)||tn.has(i.word)?!1:!Yi.has(i.word)&&!Hh.has(i.word)&&xt(i.word)}s(hc,"hasStrandedPreposition");function Cj(e,t){if(hc(e,t)||Uw.has(e[t]?.word??""))return!0;let r=e[t+1];if(r===void 0||r.afterBreak||r.word!=="to")return!1;let i=e[t+2];return i!==void 0&&!i.afterBreak&&!xt(i.word)}s(Cj,"hostsGap");function Uj(e,t){let r=e[t]?.word??"";if(r.length<=3||!r.endsWith("ed"))return!1;let i=e[t+1];return i!==void 0&&!i.afterBreak&&i.word==="by"}s(Uj,"isAgentiveParticiple");function ev(e,t){let r=e[t+1];return r===void 0||r.afterBreak}s(ev,"isClauseFinal");function Rj(e,t){let r=e[t]?.word??"";return r===""||xt(r)||fc.has(r)?!1:hc(e,t)}s(Rj,"isStrandedVerb");function ik(e,t){let r=e[t];if(r===void 0)return;let{word:i}=r;if(i!==ir)return Yi.has(i)?Zj(e,t)?void 0:"pronoun":sk(i)?"numeral":Yw.has(i)?"quantifier-pronoun":tn.has(i)?Lj(e,t)?void 0:"quantifier":Vw.has(i)?"demonstrative":sr.has(i)?"determiner":ur(i)?"bare":void 0}s(ik,"classifySubject");function ok(e,t){let r=t;for(;r>0;){let i=e[r];if(i===void 0||i.afterBreak)return;r-=1;let n=e[r];if(n===void 0||n.word===ir)return;if(!cr.has(n.word))return Xh.has(n.word)?Fj(e,r)?void 0:r:Bj(e,r)||xt(n.word)||qw.has(n.word)||Lw.has(n.word)||Qh.has(n.word)||Ww.has(n.word)||Vj(e,r)?void 0:Mj(e,r)?r:void 0}}s(ok,"findHeadIndex");function ak(e,t){for(let r=t-1;r>=0&&r>=t-2;r-=1){let i=e[r];if(i===void 0)return!1;if(ck(i.word,e[t]?.word??""))return!0;if(e[r+1]?.afterBreak===!0)return!1}return!1}s(ak,"isDeterminedPhrase");function Lj(e,t){let r=e[t+1];return r===void 0||r.afterBreak?!1:Fw.has(`${e[t]?.word??""} ${r.word}`)}s(Lj,"opensDegreeAdverbial");function Zj(e,t){let r=e[t];return r===void 0||r.afterBreak||!Xh.has(r.word)?!1:Mw.has(e[t-1]?.word??"")}s(Zj,"closesComparativePhrase");function Mj(e,t){let r=e[t];return r===void 0?!1:!tv(r.word)&&!r.word.endsWith("ing")?!0:r.afterBreak||t===0?!1:ck(e[t-1]?.word??"",r.word)}s(Mj,"isDeterminedHead");function Fj(e,t){return t===0||e[t]?.afterBreak===!0?!1:Kw.has(e[t-1]?.word??"")}s(Fj,"isFusedProForm");function sk(e){return en.has(e)||/^\d+$/.test(e)}s(sk,"isNumeral");function ck(e,t){return en.has(e)&&e!=="one"||Gw.has(e)||/^\d+$/.test(e)?e!=="1"&&ur(t):sr.has(e)||tn.has(e)||en.has(e)}s(ck,"isSpecifier");function Vj(e,t){let r=e[t];if(r===void 0)return!0;if(t===0||r.afterBreak)return!ur(r.word);let i=e[t-1]?.word??"",n=Qt.has(i)?e[t-2]?.word??"":i;return n==="to"||Le.has(n)}s(Vj,"isVerbPosition");function Bj(e,t){for(let r=t-1;r>=0;r-=1){let i=e[r+1];if(i===void 0||i.afterBreak)return!1;let n=e[r]?.word??"";if(Qh.has(n))return!0;if(!tn.has(n)&&!sk(n))return!1}return!1}s(Bj,"isWhMarkedHead");function uk(e){let t=[];for(let r of e)t.push(...Kj(r));return t}s(uk,"detectObjectRelatives");function lk(e){return!e.endsWith("s")}s(lk,"agreesWithPluralSubject");function qj(e){let{span:t,tokens:r,headIndex:i,subjectIndex:n,verbIndex:o,shape:a}=e,c=r[i],u=r[o];if(c===void 0||u===void 0)throw new Error("candidate resolved outside its token run");let l=r.slice(n,o).map(d=>d.word===ir?oc:d.raw).join(" ");return{rule:"reduced-object-relative",file:t.file,line:t.line+Ge(t.text,c.start),shape:a,head:c.raw,subject:l,verb:u.raw,phrase:fe(t.text.slice(c.start,u.end)),sentence:nw(t.text,c.start,u.end)}}s(qj,"buildCandidate");function Kj(e){let t=lc(e.text),r=[],i=-1;for(let n=1;n<t.length;n+=1){let o=ok(t,n);if(o===void 0)continue;let a=o<=i,c=ik(t,n);if(c===void 0||c==="bare"&&!ak(t,o))continue;let u=Jj(t,n,c);if(u===void 0||a&&u!==i)continue;i=u;let l=Wj({tokens:t,kind:c,subjectIndex:n,verbIndex:u}),d=qj({span:e,tokens:t,headIndex:o,subjectIndex:n,verbIndex:u,shape:l});a?r[r.length-1]=d:r.push(d)}return r}s(Kj,"detectInSpan");function Jj(e,t,r){let i=Xw[r],n=t+i.min,o=Math.min(t+i.max,e.length-1),a=!1;for(let c=t+1;c<=o;c+=1){let u=e[c];if(u===void 0||u.afterBreak||mc.has(u.word)||pc.has(u.word))return;if(Gi.has(u.word)&&u.word!=="of"){a=!0,o=Math.min(t+Bw,e.length-1);continue}if(dk(u.word)){o=Math.min(o+1,e.length-1);continue}if(u.word===ir)continue;let l=Le.has(u.word)&&c>=n?Yj({tokens:e,index:c,kind:r,crossedPreposition:a}):Hj({tokens:e,index:c,subjectIndex:t,first:n,kind:r,crossedPreposition:a});if(l.outcome==="close")return l.verbIndex;if(l.outcome==="stop")return}}s(Jj,"findVerbIndex");function Wj(e){let{tokens:t,kind:r,subjectIndex:i,verbIndex:n}=e;return r!=="demonstrative"?Hw[r]:Gj(t,i,n)?"pronoun":"definite"}s(Wj,"resolveShape");function Gj(e,t,r){for(let i=t+1;i<r;i+=1)if(!dk(e[i]?.word??""))return!1;return!0}s(Gj,"standsAlone");function dk(e){return Qt.has(e)||cr.has(e)||nv(e)}s(dk,"skipsAsModifier");function Yj(e){let{tokens:t,index:r,kind:i,crossedPreposition:n}=e,o=rk(t,r);if(o.carriedIndex!==void 0){let c=ek(t,o);return c===void 0?{outcome:"stop"}:n&&!gc(t,c)?{outcome:"stop"}:{outcome:"close",verbIndex:c}}let a=t[o.lastAuxiliaryIndex]?.word??"";return dc.has(a)&&tk(t,o.lastAuxiliaryIndex)?{outcome:"close",verbIndex:o.lastAuxiliaryIndex}:Rw.has(a)?n&&!gc(t,o.lastAuxiliaryIndex)?{outcome:"continue"}:i==="bare"&&!lk(t[r]?.word??"")?{outcome:"stop"}:{outcome:"close",verbIndex:o.lastAuxiliaryIndex}:{outcome:"continue"}}s(Yj,"resolveAuxiliaryStep");function Hj(e){let{tokens:t,index:r,subjectIndex:i,first:n,kind:o,crossedPreposition:a}=e,c=t[r]?.word??"";return r<n||!nk(t,r,o)?{outcome:"continue"}:o==="demonstrative"&&r===i+1&&ur(c)?{outcome:"continue"}:a&&!gc(t,r)?{outcome:"continue"}:o==="bare"&&!lk(c)?{outcome:"stop"}:{outcome:"close",verbIndex:r}}s(Hj,"resolveScannedStep");var Xj=new Map([["carry",["carries","carried","carrying"]],["cost",["costs","costing"]],["hold",["holds","held","holding"]],["land",["lands","landed","landing"]],["reach",["reaches","reached","reaching"]],["route",["routes","routed","routing"]],["ship",["ships","shipped","shipping"]],["sit",["sits","sat","sitting"]],["stand",["stands","stood","standing"]],["surface",["surfaces","surfaced","surfacing"]]]);function fk(e){return e.flatMap(tT)}s(fk,"detectOverusedWords");var mk=new Map([...Xj].flatMap(([e,t])=>[e,...t].map(r=>[r,e]))),Qj=new RegExp(String.raw`\b(?:${mk.keys().toArray().join("|")})\b`,"giu"),eT=/^\s+in\s+for\b/iu;function tT(e){let t=Yt(e.text),r=new Map;for(let i of e.text.matchAll(Qj)){let n=i.index,o=n+i[0].length;if(t.some(l=>n>=l.start&&n<l.end))continue;let a=mk.get(i[0].toLowerCase());if(a===void 0||a==="stand"&&eT.test(e.text.slice(o)))continue;let c=rr(e.text,n,o),u=r.get(c.start)??{end:c.end,words:[]};u.words.includes(a)||u.words.push(a),r.set(c.start,u)}return[...r].map(([i,{end:n,words:o}])=>{let a=fe(e.text.slice(i,n));return{rule:"overused-word",file:e.file,line:e.line+Ge(e.text,i),phrase:a,sentence:a,words:o}})}s(tT,"detectInSpan");function pk(e){return e.filter(t=>!iT(t.file)).flatMap(t=>St(t,rT).map(({line:r,sentence:i})=>({rule:"second-person",file:t.file,line:r,phrase:i,sentence:i})))}s(pk,"detectSecondPersonPronouns");var nT=/\.(?:markdown|md)$/i,rT=/\byou(?:rs?|rself|rselves)?\b/giu;function iT(e){let t=e.split("/"),r=t.at(-1)??"";if(r==="SKILL.md")return!0;if(!nT.test(r))return!1;let i=t.at(-2),n=t.at(-3);return i==="_partials"?n==="skills"||n==="subagents":i==="subagents"||i==="agents"&&n===".claude"}s(iT,"isAgentInstructionBody");function gk(e){return Map.groupBy(e,t=>t.file).values().flatMap(lT).toArray()}s(gk,"detectSoUses");var oT=["far","few","little","many","much","on"],aT=["did","do","does","doing","done","if","said","say","saying","says"],sT=/(?:[,;–—]|--|\band)\s*$/iu,cT=3,uT=new RegExp(String.raw`(?<!\b(?:${aT.join("|")})\s+)`+String.raw`(?:(?<=(?:^|[,;.!?])\s*)\bso\b|\bso\b(?!\s+(?:${oT.join("|")})\b))`+String.raw`(?!-|\s+that\b)`,"giu");function lT(e){let t=e.toSorted((i,n)=>i.line-n.line).flatMap(fT),r=[];for(let[i,n]of t.entries()){if(n.siteCount===0)continue;let o=t.slice(Math.max(0,i-cT),i),a=n.siteCount>1||o.some(c=>c.siteCount>0);!n.hasBareSite&&!a||r.push({rule:"so",file:n.file,line:n.line,phrase:n.text,sentence:n.text,trigger:n.hasBareSite?"bare":"repeat"})}return r}s(lT,"detectInFile");function dT(e){return/[\p{L}\p{N}]/u.test(e)&&!sT.test(e)}s(dT,"isBareSite");function fT(e){let t=Yt(e.text),r=e.text.matchAll(uT).map(i=>i.index).filter(i=>t.every(n=>i<n.start||i>=n.end)).toArray();return rw(e.text).map(({start:i,end:n})=>{let o=r.filter(a=>a>=i&&a<n);return{file:e.file,hasBareSite:o.some(a=>dT(e.text.slice(i,a))),line:e.line+Ge(e.text,i),siteCount:o.length,text:fe(e.text.slice(i,n))}})}s(fT,"listSiteSentences");function hk(e){return e.flatMap(t=>St(t,mT).map(({line:r,sentence:i})=>({rule:"where",file:t.file,line:r,phrase:i,sentence:i})))}s(hk,"detectWhereUses");var mT=/\bwhere\b/giu;var vk={apostrophes:Ow,"em-dash":Aw,"negative-quantifier":Tw,"overused-word":fk,"reduced-object-relative":uk,"second-person":pk,so:gk,where:hk};function yk(e,t){let r=new Map;for(let n of e)r.has(n.file)||r.set(n.file,r.size);return t.flatMap(n=>vk[n](e)).toSorted((n,o)=>(r.get(n.file)??0)-(r.get(o.file)??0)||n.line-o.line)}s(yk,"detectRules");function Hi(e){return Object.hasOwn(vk,e)}s(Hi,"isRuleId");var hT={rules:{},rejections:[]},vT=["reduced-object-relative"];async function yT(){try{let e=nn.argv.slice(2),t=e[0]==="record"?await $T({foldJson:await NT(),root:nn.cwd()}):await bT({argv:$w(e),root:nn.cwd()});nn.stdout.write(`${JSON.stringify(t,null,2)}
|
|
227
227
|
`)}catch(e){nn.stderr.write(`revise-prose: ${De(e)}
|
|
228
|
-
`),nn.exit(1)}}s(yT,"main");av(import.meta.url,"revise-prose")&&await yT();async function bT(e,t=qi){let r;try{r=bw(e.argv)}catch(a){return{ok:!1,error:"invalid-args",message:De(a)}}let i=_T(r),n=zT(i),o=hT;if(r.units.size>0)try{o=_k(e.root,i)}catch(a){return{ok:!1,error:"invalid-record",message:De(a)}}try{let{scannedFiles:a,skipped:c,spans:u}=await Vh({root:e.root,paths:r.paths,git:t,...e.home!==void 0&&{home:e.home}}),l=Bh(u,a);r.units.size>0&&(o=Kh(o,l));let d=r.rules.length===0?vT:PT(r.rules),f=yk(u,d),m=r.units.size===0?f:Sw(f,o,n),p=uv({files:a,candidates:m,budget:r.budget}),h=p.map($=>({...$,unswept:xT(o,n,$.files,l)})).filter($=>n.size===0||$.unswept.length>0),g=ST(h,n),b=m.filter($=>g($)),k=Nw(o,n,a.map($=>$.file)).filter($=>g($));return{ok:!0,root:e.root,candidates:b,rejections:k,batches:h,rules:{detected:d.toSorted(),undetected:r.rules.map($=>$.rule).filter($=>!Hi($)).toSorted()},summary:OT({candidates:b,scanned:a.length,skipped:c,batches:h,planned:p})}}catch(a){if(a instanceof or)return{ok:!1,error:"not-a-repository",message:a.message};throw a}}s(bT,"runDetect");async function $T(e,t=qi){let r;try{let n=hw(e.foldJson),o=_k(e.root,wT(n)),a=n.roots.includes(".")?[]:n.roots,c=await bk({...e,paths:a},t),u=o.files===void 0?Kh(o,a.length===0?c:await bk({...e,paths:[]},t)):o;r=ww(u,n,kT(e.root),Hi,c)}catch(n){return n instanceof or?{ok:!1,error:"not-a-repository",message:n.message}:{ok:!1,error:"invalid-record",message:De(n)}}let i=vc.join(e.root,Xt);return pT(vc.dirname(i),{recursive:!0}),gT(i,Pw(r),"utf8"),{ok:!0,path:Xt,rules:Object.keys(r.rules).length,rejections:r.rejections.length}}s($T,"runRecord");function _T(e){let t=new Map;for(let{rule:r,unit:i,version:n}of e.rules)n!==void 0&&t.set(r,{unit:i,version:n});return{units:e.units,rules:t}}s(_T,"buildArgVersions");function ST(e,t){let r=new Map;for(let i of e){let n=new Set(i.unswept);for(let o of i.files)r.set(o,n)}return i=>{let n=r.get(i.file);return n!==void 0&&(n.has(i.rule)||!t.has(i.rule))}}s(ST,"buildBatchScope");function wT(e){return{units:new Map(Object.entries(e.units)),rules:new Map(Object.entries(e.rules))}}s(wT,"buildFoldVersions");function kT(e){let t=new Map;return r=>{t.has(r.file)||t.set(r.file,IT(e,r.file));let i=t.get(r.file);return i!==void 0&&kw(i,r.phrase)}}s(kT,"buildSitePredicate");async function bk(e,t){let{scannedFiles:r,spans:i}=await Vh({root:e.root,paths:e.paths,git:t,...e.home!==void 0&&{home:e.home}});return Bh(i,r)}s(bk,"hashProseUnder");function xT(e,t,r,i){return[...new Set(r.flatMap(o=>Iw(e,t,Hi,o,i.get(o))))].toSorted()}s(xT,"listBatchUnsweptRules");function _k(e,t){let r;try{r=$k(vc.join(e,Xt),"utf8")}catch{return{rules:{},rejections:[]}}return gw(r,t)}s(_k,"readRecordFile");function IT(e,t){let r;try{r=$k(vc.join(e,t),"utf8")}catch{return}return{prose:dw({file:t,content:r}).map(n=>n.text).join(`
|
|
228
|
+
`),nn.exit(1)}}s(yT,"main");av(import.meta.url,"revise-prose")&&await yT();async function bT(e,t=qi){let r;try{r=bw(e.argv)}catch(a){return{ok:!1,error:"invalid-args",message:De(a)}}let i=_T(r),n=zT(i),o=hT;if(r.units.size>0)try{o=_k(e.root,i)}catch(a){return{ok:!1,error:"invalid-record",message:De(a)}}try{let{scannedFiles:a,skipped:c,spans:u}=await Vh({root:e.root,paths:r.paths,git:t,...e.home!==void 0&&{home:e.home}}),l=Bh(u,a);r.units.size>0&&(o=Kh(o,l));let d=r.rules.length===0?vT:PT(r.rules),f=yk(u,d),m=r.units.size===0?f:Sw(f,o,n),p=uv({files:a,candidates:m,budget:r.budget}),h=p.map($=>({...$,unswept:r.resweep?n.keys().toArray().toSorted():xT(o,n,$.files,l)})).filter($=>n.size===0||$.unswept.length>0),g=ST(h,n),b=m.filter($=>g($)),k=Nw(o,n,a.map($=>$.file)).filter($=>g($));return{ok:!0,root:e.root,candidates:b,rejections:k,batches:h,rules:{detected:d.toSorted(),undetected:r.rules.map($=>$.rule).filter($=>!Hi($)).toSorted()},summary:OT({candidates:b,scanned:a.length,skipped:c,batches:h,planned:p})}}catch(a){if(a instanceof or)return{ok:!1,error:"not-a-repository",message:a.message};throw a}}s(bT,"runDetect");async function $T(e,t=qi){let r;try{let n=hw(e.foldJson),o=_k(e.root,wT(n)),a=n.roots.includes(".")?[]:n.roots,c=await bk({...e,paths:a},t),u=o.files===void 0?Kh(o,a.length===0?c:await bk({...e,paths:[]},t)):o;r=ww(u,n,kT(e.root),Hi,c)}catch(n){return n instanceof or?{ok:!1,error:"not-a-repository",message:n.message}:{ok:!1,error:"invalid-record",message:De(n)}}let i=vc.join(e.root,Xt);return pT(vc.dirname(i),{recursive:!0}),gT(i,Pw(r),"utf8"),{ok:!0,path:Xt,rules:Object.keys(r.rules).length,rejections:r.rejections.length}}s($T,"runRecord");function _T(e){let t=new Map;for(let{rule:r,unit:i,version:n}of e.rules)n!==void 0&&t.set(r,{unit:i,version:n});return{units:e.units,rules:t}}s(_T,"buildArgVersions");function ST(e,t){let r=new Map;for(let i of e){let n=new Set(i.unswept);for(let o of i.files)r.set(o,n)}return i=>{let n=r.get(i.file);return n!==void 0&&(n.has(i.rule)||!t.has(i.rule))}}s(ST,"buildBatchScope");function wT(e){return{units:new Map(Object.entries(e.units)),rules:new Map(Object.entries(e.rules))}}s(wT,"buildFoldVersions");function kT(e){let t=new Map;return r=>{t.has(r.file)||t.set(r.file,IT(e,r.file));let i=t.get(r.file);return i!==void 0&&kw(i,r.phrase)}}s(kT,"buildSitePredicate");async function bk(e,t){let{scannedFiles:r,spans:i}=await Vh({root:e.root,paths:e.paths,git:t,...e.home!==void 0&&{home:e.home}});return Bh(i,r)}s(bk,"hashProseUnder");function xT(e,t,r,i){return[...new Set(r.flatMap(o=>Iw(e,t,Hi,o,i.get(o))))].toSorted()}s(xT,"listBatchUnsweptRules");function _k(e,t){let r;try{r=$k(vc.join(e,Xt),"utf8")}catch{return{rules:{},rejections:[]}}return gw(r,t)}s(_k,"readRecordFile");function IT(e,t){let r;try{r=$k(vc.join(e,t),"utf8")}catch{return}return{prose:dw({file:t,content:r}).map(n=>n.text).join(`
|
|
229
229
|
`),content:r}}s(IT,"readSiteText");async function NT(){let e=[];for await(let t of nn.stdin)e.push(t instanceof Uint8Array?t:Buffer.from(String(t),"utf8"));return Buffer.concat(e).toString("utf8")}s(NT,"readStdin");function PT(e){return e.map(t=>t.rule).filter(Hi)}s(PT,"selectDetectorRules");function zT(e){return new Map(e.rules.entries().map(([t,{version:r}])=>[t,r]))}s(zT,"selectRuleVersions");function OT(e){let t=new Map,r={quantified:0,definite:0,bare:0,pronoun:0},i={apostrophes:0,"em-dash":0,"negative-quantifier":0,"overused-word":0,"reduced-object-relative":0,"second-person":0,so:0,where:0};for(let o of e.candidates)t.set(o.file,(t.get(o.file)??0)+1),i[o.rule]+=1,o.rule==="reduced-object-relative"&&(r[o.shape]+=1);let n=[...t].map(([o,a])=>({file:o,count:a})).toSorted((o,a)=>a.count-o.count||o.file.localeCompare(a.file));return{total:e.candidates.length,filesScanned:e.scanned,filesSkipped:e.skipped,batchesPlanned:e.planned.length,batchesSkipped:e.planned.length-e.batches.length,stale:e.candidates.filter(o=>o.stale===!0).length,byFile:n,byRule:i,byShape:r}}s(OT,"summarize");export{bT as runDetect,$T as runRecord};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: start-ticket
|
|
3
|
+
description: Open the work in a ticket's worktree by choosing the entry-point skill from the ticket's state and its artifacts, and invoking it
|
|
4
|
+
user-invocable: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Start ticket
|
|
8
|
+
|
|
9
|
+
Open the work in a ticket's worktree with one fixed prompt. The skill resolves the ticket, reads its state and the artifacts in its ticket directory, chooses the skill that opens the work per [entry points](../_data/entry-points.md), and invokes that skill. It re-resolves everything from the environment, so a session started with it does not need a prompt written by an earlier session.
|
|
10
|
+
|
|
11
|
+
## Arguments
|
|
12
|
+
|
|
13
|
+
- Ticket source (optional): Issue URL, shorthand reference (`#99`), or file path. It overrides the ticket that the branch encodes.
|
|
14
|
+
|
|
15
|
+
## Process
|
|
16
|
+
|
|
17
|
+
1. **Get context**: Invoke `node {harness_home_dir}/skills/derive-session-context/derive-session-context.mjs` via Bash, and read `branch_name`, `ticket_id`, `ticket_ref`, `ticket_url`, `pr_url`, `project_slug`, and `artifact_base_dir` from the manifest JSON that it emits.
|
|
18
|
+
|
|
19
|
+
2. **Resolve the ticket** from the argument, or else by [auto-resolve](../_data/ticket-source-resolution.md#auto-resolve), requesting the ticket's state with its content. When the argument is absent and `ticket_id` is null, as on the default branch, say that the branch does not encode a ticket and ask for the ticket ref. Never guess a ticket from the branch's commits, the artifact directory, or the backlog. When the source resolves to a URL, persist it per [Stored ticket URL](../_data/ticket-source-resolution.md#stored-ticket-url), and report the ticket's open blockers per [Open blockers](../_data/ticket-source-resolution.md#open-blockers). A blocker does not stop the choice; the skill that opens the work decides what it means.
|
|
20
|
+
|
|
21
|
+
3. **Choose the entry point** by checking the routes of [entry points](../_data/entry-points.md) in order against the ticket, the branch's pull request, and the ticket directory. Stop at the first match.
|
|
22
|
+
|
|
23
|
+
4. **Announce** the route in one line: the skill, the reason that the route states, and, when the route names a plan, its path and timestamp. The announcement is how the developer catches a wrong route or a superseded plan before the chosen skill acts.
|
|
24
|
+
|
|
25
|
+
5. **Invoke the chosen skill** with the arguments that the route names, without asking first: The route is a determination under the rule, not a choice. A route that stops ends the run with its report. Do not repeat a check that the invoked skill makes itself, such as the blocker confirmation and the branch-currency check of {skill?:implement-plan} and {skill?:investigate-spike}.
|
|
26
|
+
|
|
27
|
+
<!-- include: ../_partials/action-items.md / -->
|