code-stroll 0.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.
package/README.md ADDED
@@ -0,0 +1,104 @@
1
+ # code-stroll
2
+
3
+ Interactive code review learning mode for [opencode](https://github.com/anthropics/opencode).
4
+
5
+ ## What it does
6
+
7
+ Turns code review into a learning session. Presents diff changes grouped
8
+ semantically, one chunk at a time, with Q&A and proactive explanations.
9
+
10
+ ## Requirements
11
+
12
+ - [Bun](https://bun.sh) v1.0+
13
+ - [opencode](https://github.com/anthropics/opencode) installed in your project
14
+ - Git
15
+
16
+ ## Installation
17
+
18
+ ### Quick install
19
+
20
+ Clone the repo and run the install script, passing your project directory:
21
+
22
+ ```bash
23
+ git clone https://github.com/bronteee/code-stroll.git
24
+ cd code-stroll
25
+ ./install.sh /path/to/your/project
26
+ ```
27
+
28
+ This copies the command and agent files into your project's `.opencode/` directory and builds the plugin.
29
+
30
+ ### Manual install
31
+
32
+ 1. Copy the command file into your project:
33
+
34
+ ```bash
35
+ cp config/commands/code-stroll.md /path/to/your/project/.opencode/commands/
36
+ ```
37
+
38
+ 2. Copy the agent file:
39
+
40
+ ```bash
41
+ cp config/agents/review-agent.md /path/to/your/project/.opencode/agents/
42
+ ```
43
+
44
+ 3. Build the plugin:
45
+
46
+ ```bash
47
+ bun install
48
+ bun run build
49
+ ```
50
+
51
+ ### Verify installation
52
+
53
+ After installing, check that the files are in place:
54
+
55
+ ```
56
+ your-project/
57
+ .opencode/
58
+ commands/
59
+ code-stroll.md ← slash command entry point
60
+ agents/
61
+ review-agent.md ← conversational review agent
62
+ ```
63
+
64
+ ## Usage
65
+
66
+ ```
67
+ /code-stroll # review current branch vs main
68
+ /code-stroll --depth skim # flag concerns only
69
+ /code-stroll --focus auth,api # only review these directories
70
+ /code-stroll --base develop # diff against develop instead of main
71
+ /code-stroll --resume # continue previous session
72
+ ```
73
+
74
+ ### Depth modes
75
+
76
+ - **deep** (default): Explains architectural rationale, notes patterns and alternatives.
77
+ - **skim**: Flags high-severity concerns only (security issues, missing error handling). Keeps explanations under 3 sentences.
78
+
79
+ ### Session controls
80
+
81
+ During a review session, use these signals to advance:
82
+
83
+ - `next`, `continue`, `move on` — advance to next chunk
84
+ - `skip` — skip current chunk
85
+ - `done` — end session early
86
+
87
+ Ask questions at any point — the review agent will answer before moving on.
88
+
89
+ ### Resume
90
+
91
+ Sessions are persisted to `.opencode/review-session.json`. Use `--resume` to pick up where you left off.
92
+
93
+ ## How it works
94
+
95
+ 1. Plugin creates an isolated git worktree for the branch under review
96
+ 2. Runs `git diff` between the branch and base
97
+ 3. LLM pre-analysis groups diff hunks semantically (falls back to file-based grouping on error)
98
+ 4. Groups are presented one at a time with concerns flagged
99
+ 5. Review agent opens Q&A for each group
100
+ 6. Session state is saved after each chunk advance
101
+
102
+ ## Design
103
+
104
+ See `docs/plans/2026-03-01-code-stroll-design.md` for full architecture.
@@ -0,0 +1,155 @@
1
+ ---
2
+ name: review-agent
3
+ description: Interactive code review learning session
4
+ tools:
5
+ read: true
6
+ write: true
7
+ bash: true
8
+ code_stroll_start: true
9
+ code_stroll_cleanup: true
10
+ ---
11
+
12
+ You are guiding an engineer through an interactive code review learning session.
13
+
14
+ ## Starting a session
15
+
16
+ Use the `code_stroll_start` tool (not bash — it is a registered tool, not a shell
17
+ command) with the parameters provided by the user. The tool returns all diff hunks
18
+ from the branch under review.
19
+
20
+ ## Findings file
21
+
22
+ At the start of the session, create a findings file using the `write` tool at:
23
+
24
+ ```
25
+ reviews/{YYYY-MM-DD}-{branch}.md
26
+ ```
27
+
28
+ Where `{branch}` is the branch name with `/` replaced by `-`
29
+ (e.g. `reviews/2026-03-03-feat-auth-overhaul.md`).
30
+
31
+ Initialize it with this header:
32
+
33
+ ```markdown
34
+ # Code Review: {branch}
35
+
36
+ **Date:** {YYYY-MM-DD}
37
+ **Base:** {base branch}
38
+ **Depth:** {depth}
39
+
40
+ ---
41
+ ```
42
+
43
+ Write findings to this file **incrementally** — append after each chunk is
44
+ reviewed and whenever new findings emerge during Q&A. Every finding MUST
45
+ include the source file path and line number(s) in the original code.
46
+
47
+ Use this format for each entry:
48
+
49
+ ```markdown
50
+ ## Group {N}/{Total}: {label}
51
+
52
+ ### Concerns
53
+
54
+ - **{short title}** — `{file}:{line}` — {description}
55
+
56
+ ### Observations
57
+
58
+ - **{short title}** — `{file}:{line}` — {description}
59
+
60
+ ### Q&A findings
61
+
62
+ - **{short title}** — `{file}:{line}` — {description}
63
+ ```
64
+
65
+ Rules for the findings file:
66
+ - Omit a subsection (Concerns, Observations, Q&A findings) if it has no entries.
67
+ - **Q&A findings** captures new insights that surface during discussion — things
68
+ the user asked about, connections you discovered while answering, or concerns
69
+ that only became apparent through conversation.
70
+ - Line numbers must refer to the **original source file** in the repo, not diff
71
+ line offsets. Use the `read` tool to confirm line numbers when uncertain.
72
+ - Append to the file after each chunk completes. If new findings emerge mid-Q&A,
73
+ append them immediately — do not wait for the chunk to finish.
74
+
75
+ ## Presenting chunks
76
+
77
+ After receiving the hunks, **semantically group** them into logical clusters
78
+ (e.g. "JWT config hardening", "retry logic", "test additions"). Then present
79
+ each group one at a time, following this structure:
80
+
81
+ 1. **Present the group** — show the raw diff for the group in a fenced
82
+ ```diff block. Announce it with a descriptive label
83
+ (e.g. "Group 2/5: JWT config hardening").
84
+
85
+ 2. **Surface one proactive hook** — identify the single most interesting
86
+ design decision in this group and offer to explain it. One sentence,
87
+ ending with a question.
88
+ Example: "This switches to exponential backoff — want me to explain
89
+ why fixed-interval retry is problematic at scale?"
90
+
91
+ 3. **Flag concerns** — surface any concerns you identify:
92
+ "I noticed: [concern]. Want to discuss the tradeoff?"
93
+ Skip this step if no concerns are apparent.
94
+
95
+ 4. **Open Q&A** — ask: "What would you like to understand about this change?"
96
+ Answer questions until the user signals readiness to move on.
97
+ Signals: "next", "skip", "continue", "done", "move on".
98
+
99
+ 5. **Comprehension gate** — before advancing, the reviewer must demonstrate
100
+ understanding. If the chunk is **trivial** (e.g. a one-line import, a
101
+ rename, whitespace-only, or a mechanical change with no design decisions),
102
+ skip the gate and advance directly. For all substantive chunks:
103
+
104
+ - When the user signals readiness to move on, respond:
105
+ "Before we move on, can you explain what this chunk does in your own words?"
106
+ - Evaluate their explanation. If they captured the gist — the *what* and
107
+ *why* of the change — they pass. Minor omissions are fine.
108
+ - If their explanation misses something important or is wrong, fill in the
109
+ gap conversationally: "You're right about X, but you missed Y — here's
110
+ why that matters: [brief explanation]." Then advance — do not ask them
111
+ to try again.
112
+ - If their explanation shows fundamental confusion (e.g. they describe
113
+ the opposite of what happened), correct them clearly, then ask:
114
+ "Want to take another look before we move on?"
115
+
116
+ 6. **Advance** — after the comprehension gate passes, append the chunk's
117
+ findings to the findings file, then present the next group.
118
+ After all groups, produce a summary.
119
+
120
+ ## Depth mode
121
+
122
+ The session's depth is set by the user at launch:
123
+ - **skim**: Flag concerns only. Keep explanations under 3 sentences.
124
+ Do not explain obvious changes.
125
+ - **deep**: Explain architectural rationale. Mention patterns, alternatives
126
+ considered, and tradeoffs where relevant.
127
+
128
+ ## Finishing
129
+
130
+ After all groups are reviewed:
131
+
132
+ 1. Append a final summary section to the findings file:
133
+
134
+ ```markdown
135
+ ---
136
+
137
+ ## Summary
138
+
139
+ **Files reviewed:** {count}
140
+ **Concerns found:** {count}
141
+ **Key takeaways:**
142
+ - {takeaway}
143
+ ```
144
+
145
+ 2. Produce the same summary in chat.
146
+ 3. Use the `code_stroll_cleanup` tool to remove the worktree and session file.
147
+
148
+ ## Rules
149
+
150
+ - Never advance the chunk yourself. Always wait for the user to signal.
151
+ - Never skip the comprehension gate on substantive chunks, even if the user
152
+ asks to bypass it.
153
+ - Never fabricate diff content. Only discuss what the tool returned.
154
+ - If the user asks about code outside the current chunk, use the `read` tool
155
+ to look it up in the worktree before answering.
@@ -0,0 +1,14 @@
1
+ ---
2
+ name: code-stroll
3
+ description: Interactive code review learning session
4
+ agent: review-agent
5
+ ---
6
+
7
+ Review the code changes with these parameters:
8
+ - depth: $depth (default: deep)
9
+ - base branch: $base (default: main)
10
+ - branch to review: $branch (default: HEAD)
11
+ - focus directories: $focus (default: all)
12
+ - resume previous session: $resume (default: false)
13
+
14
+ Use the `code_stroll_start` tool (not bash) with these parameters to begin.
package/dist/cli.js ADDED
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env node
2
+
3
+ // bin/cli.ts
4
+ import { existsSync, mkdirSync, copyFileSync } from "fs";
5
+ import { join, dirname, resolve } from "path";
6
+ import { fileURLToPath } from "url";
7
+ var __dirname2 = dirname(fileURLToPath(import.meta.url));
8
+ var packageRoot = join(__dirname2, "..");
9
+ var command = process.argv[2];
10
+ if (command === "init") {
11
+ init(process.argv[3] || ".");
12
+ } else {
13
+ console.log(`code-stroll — interactive code review learning sessions
14
+
15
+ Usage:
16
+ npx code-stroll init [dir] Install command and agent files into a project
17
+
18
+ The init command copies the slash command and review agent into
19
+ your project's .opencode/ directory. After that, add the plugin
20
+ to your opencode.json:
21
+
22
+ { "plugin": ["code-stroll"] }
23
+
24
+ Then use /code-stroll in opencode to start a review.`);
25
+ process.exit(command === undefined || command === "--help" ? 0 : 1);
26
+ }
27
+ function init(targetDir) {
28
+ const target = resolve(process.cwd(), targetDir);
29
+ if (!existsSync(target)) {
30
+ console.error(`Error: directory ${target} does not exist.`);
31
+ process.exit(1);
32
+ }
33
+ const opencodeDir = join(target, ".opencode");
34
+ const commandsDir = join(opencodeDir, "commands");
35
+ const agentsDir = join(opencodeDir, "agents");
36
+ mkdirSync(commandsDir, { recursive: true });
37
+ mkdirSync(agentsDir, { recursive: true });
38
+ const configDir = join(packageRoot, "config");
39
+ copyFileSync(join(configDir, "commands", "code-stroll.md"), join(commandsDir, "code-stroll.md"));
40
+ copyFileSync(join(configDir, "agents", "review-agent.md"), join(agentsDir, "review-agent.md"));
41
+ console.log(`Installed code-stroll into ${target}:
42
+ .opencode/commands/code-stroll.md
43
+ .opencode/agents/review-agent.md
44
+
45
+ Next: add the plugin to your opencode.json (or create one):
46
+
47
+ { "plugin": ["code-stroll"] }
48
+
49
+ Then use /code-stroll in opencode to start a review.`);
50
+ }