@staff0rd/assist 0.599.0 → 0.601.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/README.md CHANGED
@@ -41,6 +41,8 @@ After installation, the `assist` command will be available globally. You can als
41
41
  ## Claude Commands
42
42
 
43
43
  - `/add-command` - Add a new run command to assist.yml
44
+ - `/adopt-rules [path]` - Move a repo's existing rules into the canonical `## Rules` sections `assist rules` reads: inventories every `CLAUDE.md`, classifies each as rename (bullets already coded, just the heading is wrong), reword (prose or numbered lists, migrated one at a time via `assist rules add`) or leave, proposes the plan before touching anything, then records the scoped directories with `assist rules index`
45
+ - `/add-rule` - Capture a new `CLAUDE.md` rule from a review comment: words the rule from the note, infers the scope from the commented file (asking only when genuinely ambiguous, defaulting to the nearest `CLAUDE.md`), and writes it with `assist rules add`. Sent by the comment pane's **Add rule** button
44
46
  - `/branch <description> [--jira KEY]` - Create a branch off the fresh remote default, deriving a kebab-case slug from the description
45
47
  - `/bug` - File a bug with reproduction steps, expected and actual behavior
46
48
  - `/comment` - Add pending review comments to the current PR
@@ -235,6 +237,8 @@ The Config tab of the sessions web dashboard never receives secret values: `GET
235
237
  ### Rules
236
238
 
237
239
  - `assist rules list [path]` - List the rules in scope for a path (default: cwd), read from the `## Rules` section of every `CLAUDE.md` from that path's directory up to the repo root, nearest scope first, grouped by the file each rule came from. Rules are `- **<code>** — <text>` bullets
240
+ - `assist rules add <text> [--scope <path>]` - Add a rule to the `## Rules` section of the scope's `CLAUDE.md`, creating the section when absent and allocating the next repo-wide code. `--scope` takes a file or directory (resolved to the nearest existing `CLAUDE.md` at or above it, defaulting to cwd) or a `CLAUDE.md` path written to directly and created if absent. After writing, the root `CLAUDE.md` records the directories that carry their own `## Rules` so scoped rules stay discoverable from the root
241
+ - `assist rules index [path]` - Record the directories that carry their own `## Rules` in the repo root's `CLAUDE.md`, rewriting the line in place rather than duplicating it. `rules add` does this on every add; run it directly after hand-editing a `## Rules` section (e.g. renaming an existing heading)
238
242
 
239
243
  ### Devlog
240
244
 
@@ -0,0 +1,45 @@
1
+ ---
2
+ description: Capture a new CLAUDE.md rule from a review comment
3
+ allowed_args: "[quoted text, file and note from the comment pane]"
4
+ ---
5
+
6
+ You are turning a review comment into a written rule in a `CLAUDE.md` file, so the same mistake is caught next time. `$ARGUMENTS` carries what the comment pane sent: an optional `File:` line, the quoted text in a fenced block, and the reviewer's note.
7
+
8
+ ## Step 1: Read what you were given
9
+
10
+ Pull three things out of `$ARGUMENTS`:
11
+
12
+ - **File** — the path the selection came from, if a `File:` line is present. The document preview pane has no path, so it may be missing.
13
+ - **Quote** — the selected text, the concrete example of the rule being broken.
14
+ - **Note** — the reviewer's words, the substance of the rule.
15
+
16
+ If `$ARGUMENTS` is empty, ask the user what rule they want to add and skip to Step 3.
17
+
18
+ ## Step 2: Word the rule
19
+
20
+ Write the rule as one short imperative sentence that generalises the note beyond this one instance — what to do (or not do), not what went wrong here. Keep it to a single line: it becomes a `- **<code>** — <text>` bullet.
21
+
22
+ Ask the user a clarifying question only when the note is genuinely too vague to word a rule from. One question, then write it.
23
+
24
+ ## Step 3: Work out the scope
25
+
26
+ The scope is the directory whose `CLAUDE.md` gets the rule. Infer it — do not ask by default:
27
+
28
+ - With a file path, the default is the nearest `CLAUDE.md` walking up from that file's directory to the repo root. `assist rules list <path>` shows what is already in scope there, which tells you where sibling rules live.
29
+ - If the note is clearly about a kind of document that lives in one directory (and the file sits in it), that directory's `CLAUDE.md` is the scope — pass `--scope <dir>/CLAUDE.md` to create it there when it does not exist yet.
30
+ - If the rule plainly applies repo-wide, use the root `CLAUDE.md`.
31
+ - Without a file path, use the repo root unless the note names a directory.
32
+
33
+ Ask the user only when two scopes are genuinely defensible and the choice changes where the rule applies. Otherwise take the nearest `CLAUDE.md` and say which one you chose.
34
+
35
+ ## Step 4: Write it
36
+
37
+ ```
38
+ assist rules add '<rule text>' --scope <path> 2>&1
39
+ ```
40
+
41
+ `--scope` takes a file, a directory, or a `CLAUDE.md` path directly. A file or directory resolves to the nearest existing `CLAUDE.md` at or above it; a `CLAUDE.md` path is written to as given, created if absent. The command allocates the next repo-wide code, creates the `## Rules` section when the file has none, and records the directories that carry their own `## Rules` in the root `CLAUDE.md`.
42
+
43
+ Use single quotes around the rule text to avoid shell escaping issues.
44
+
45
+ Show the command output — it names the allocated code and the file — then tell the user in one line which rule was added and where. Do not make any other edit: the rule is the whole task, and fixing the quoted text is not part of it unless the user asks.
@@ -0,0 +1,79 @@
1
+ ---
2
+ description: Move a repo's existing rules into the canonical `## Rules` sections
3
+ allowed_args: "[path to the repo or directory, defaults to cwd]"
4
+ ---
5
+
6
+ You are migrating a repo's existing written rules into the canonical `## Rules` sections that `assist rules` reads, so they become citable from the comment panes. `$ARGUMENTS` names the repo or directory to work on; default to the cwd.
7
+
8
+ Assist reads exactly one thing: a `## Rules` heading whose body holds `- **<code>** — <text>` bullets. Rules written any other way — numbered lists, prose sections, bullets under a differently-named heading — are invisible to the rule picker no matter how well written they are. This command finds them and moves them.
9
+
10
+ ## Step 1: Inventory
11
+
12
+ Find every `CLAUDE.md` in the repo:
13
+
14
+ ```
15
+ git -C <repo> ls-files '**/CLAUDE.md' 'CLAUDE.md' 2>&1
16
+ ```
17
+
18
+ Also check for untracked ones (`git status --short`) and mention any you find. Then, for each directory that has one, see what already parses:
19
+
20
+ ```
21
+ assist rules list <dir> 2>&1
22
+ ```
23
+
24
+ A directory that prints "No rules in scope" has nothing assist can read yet — that is what you are fixing.
25
+
26
+ ## Step 2: Find the rule-like content
27
+
28
+ Read each `CLAUDE.md` in full. A rule is a standing instruction to whoever writes in that scope — something you could be told you broke. Look for:
29
+
30
+ - Numbered lists of directives ("Every rule comes from a transcript…", "Numbered lists only.")
31
+ - `- **<code>** — <text>` bullets already in rule form but under a heading that is not `## Rules`
32
+ - Short prose sections that state one standing instruction ("Never hard-wrap.", "Attribute each quote as…")
33
+
34
+ Not rules, and left alone: where files live, what a directory is for, source locations, epic and project background, worked examples, anything describing the repo rather than constraining what you write in it.
35
+
36
+ ## Step 3: Classify each file
37
+
38
+ **Rename** — the section's bullets are already `- **<code>** — <text>` and the whole section is rules. Rename that heading to `## Rules`. Nothing else changes, and the existing codes are preserved. This is the cheapest and safest migration; prefer it whenever it applies.
39
+
40
+ **Reword** — the rules are prose or a numbered list. Word each as one short imperative line, then add them one at a time:
41
+
42
+ ```
43
+ assist rules add '<rule text>' --scope <path to that CLAUDE.md> 2>&1
44
+ ```
45
+
46
+ `rules add` allocates the next repo-wide code, creates the `## Rules` section when the file has none, and keeps the root index current. Then delete the prose you migrated, so the rule is not stated in two places. If a prose section carried context beyond the rule itself, keep the context where it is and take only the instruction.
47
+
48
+ **Leave** — the file has no standing rules. Say so and move on.
49
+
50
+ ## Constraints
51
+
52
+ - Assist reads only the **first** `## Rules` heading in a file. Never create a second one; merge into the existing section instead.
53
+ - Only rename a heading when _every_ bullet under it is a rule and each already carries a `**code**`. If the section mixes rules with prose, treat it as a reword.
54
+ - Preserve existing codes on a rename. Never renumber — a code that has been cited must keep meaning the same rule.
55
+ - Never hand-write a new code. Codes are unique repo-wide, and `assist rules add` is what allocates them.
56
+ - Keep the author's wording wherever it already reads as a rule. You are moving rules, not rewriting them.
57
+ - Do not hard-wrap: one line per bullet.
58
+
59
+ ## Step 4: Propose, then apply
60
+
61
+ Show the user the plan before touching anything: one line per file saying rename, reword (with the rules you would write) or leave. Ask for confirmation.
62
+
63
+ Then apply it **one file at a time**, showing what changed after each, so a wrong call is caught before it repeats across the repo.
64
+
65
+ ## Step 5: Record and verify
66
+
67
+ Once the files are migrated, record the scoped directories in the root `CLAUDE.md`:
68
+
69
+ ```
70
+ assist rules index <repo> 2>&1
71
+ ```
72
+
73
+ A rename does not update that index by itself, so run this even if you only renamed headings. Then verify each scope reads back:
74
+
75
+ ```
76
+ assist rules list <dir> 2>&1
77
+ ```
78
+
79
+ Report what is now in scope where, and name anything you deliberately left behind and why.