specrails-core 1.7.3 → 2.1.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.
@@ -0,0 +1,106 @@
1
+ ---
2
+ name: sr-why
3
+ description: "sr:why — Search explanation records written by specrails agents during the OpenSpec implementation pipeline."
4
+ license: MIT
5
+ compatibility: "Requires git."
6
+ metadata:
7
+ author: specrails
8
+ version: "1.0"
9
+ ---
10
+
11
+ # /sr:why — In-Context Help
12
+
13
+ Searches explanation records written by sr-architect, sr-developer, and sr-reviewer agents
14
+ during the OpenSpec implementation pipeline.
15
+
16
+ Records are stored in `.claude/agent-memory/explanations/` as Markdown files with
17
+ YAML frontmatter (agent, feature, tags, date).
18
+
19
+ **Usage:**
20
+ - `/sr:why` — list the 20 most recent explanation records
21
+ - `/sr:why <query>` — search records by keyword or tag
22
+
23
+ ---
24
+
25
+ ## Step 1: Find explanation records
26
+
27
+ Glob all files matching `.claude/agent-memory/explanations/*.md`.
28
+
29
+ If the directory does not exist or contains no files:
30
+ Print:
31
+ ```
32
+ No explanation records found yet.
33
+
34
+ Explanation records are written by the sr-architect, sr-developer, and sr-reviewer agents
35
+ when they make significant decisions during feature implementation.
36
+
37
+ Run `/sr:implement` on a feature to generate your first explanation records.
38
+ ```
39
+ Then stop.
40
+
41
+ ## Step 2: Handle no-argument mode (listing)
42
+
43
+ If `$ARGUMENTS` is empty:
44
+
45
+ Read each explanation record file. Extract from frontmatter: `date`, `agent`, `feature`, `tags`.
46
+ Extract the first sentence of the `## Decision` section as the decision summary.
47
+
48
+ Sort records by `date` descending. Print the 20 most recent as a Markdown table:
49
+
50
+ ```
51
+ ## Recent Explanation Records
52
+
53
+ | Date | Agent | Feature | Tags | Decision |
54
+ |------|-------|---------|------|----------|
55
+ | 2026-03-14 | sr-architect | in-context-help | [templates, commands] | Chose flat directory over per-agent subdirectories. |
56
+ | ... | ... | ... | ... | ... |
57
+ ```
58
+
59
+ Then stop.
60
+
61
+ ## Step 3: Handle query mode (search)
62
+
63
+ If `$ARGUMENTS` is non-empty, treat the full string as the search query.
64
+
65
+ For each explanation record file:
66
+ 1. Read the full file content
67
+ 2. Score the record against the query:
68
+ - Filename contains a query word: +3 points per matching word
69
+ - Frontmatter `tags` array contains an exact query word: +3 points per matching tag
70
+ - Frontmatter `feature` contains a query word: +2 points
71
+ - Body text contains a query word: +1 point per occurrence (case-insensitive)
72
+ 3. Sum the score
73
+
74
+ Sort records by score descending. Take the top 5 records with score > 0.
75
+
76
+ If no records score > 0:
77
+ Print:
78
+ ```
79
+ No explanation records match "<query>".
80
+ ```
81
+ Then list all unique tags from existing records:
82
+ ```
83
+ ## Available Tags
84
+
85
+ [sorted list of all unique tags from all explanation records]
86
+
87
+ Try `/sr:why <tag>` with one of the tags above, or `/sr:why` to browse all records.
88
+ ```
89
+
90
+ If records match, print each matching record in full, separated by `---`:
91
+
92
+ ```
93
+ ## Results for "<query>" (N matches)
94
+
95
+ ---
96
+
97
+ **[date] [agent] — [feature]**
98
+ Tags: [tag1, tag2]
99
+
100
+ [full record body]
101
+
102
+ ---
103
+
104
+ **[date] [agent] — [feature]**
105
+ ...
106
+ ```