@shiyuphan/follow-me 0.1.0 → 0.2.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,45 @@
1
+ // @ts-check
2
+ // Pure wording for the end of a review: what the reviewer is about to hand over.
3
+
4
+ /**
5
+ * @typedef {{ anchor: { kind: string, commit?: number }, kind?: string }} SummaryComment
6
+ */
7
+
8
+ /** @param {number} n @param {string} word */
9
+ function count(n, word) {
10
+ return `${n} ${word}${n === 1 ? "" : "s"}`;
11
+ }
12
+
13
+ /**
14
+ * "2 comments on 2 commits and 1 on the whole plan, 1 question for the agent, 2 kept concerns",
15
+ * or "No comments". Questions count apart from change requests, since the agent answers them
16
+ * instead of changing the plan.
17
+ * @param {{ comments: readonly SummaryComment[], kept: number, unresolved: number,
18
+ * walk: boolean }} input
19
+ */
20
+ export function endSummary({ comments, kept, unresolved, walk }) {
21
+ const questions = comments.filter((c) => c.kind === "question");
22
+ const changes = comments.filter((c) => c.kind !== "question");
23
+ const onCommits = changes.filter((c) => c.anchor.kind !== "plan");
24
+ const general = changes.length - onCommits.length;
25
+ const commits = new Set(onCommits.map((c) => c.anchor.commit)).size;
26
+ /** @type {string[]} */
27
+ const parts = [];
28
+ if (onCommits.length > 0) {
29
+ parts.push(`${count(onCommits.length, "comment")} on ${count(commits, "commit")}`);
30
+ }
31
+ if (general > 0) parts.push(`${general} on the whole ${walk ? "branch" : "plan"}`);
32
+ const sentence = [parts.join(" and ")].filter(Boolean);
33
+ if (questions.length > 0) sentence.push(`${count(questions.length, "question")} for the agent`);
34
+ if (kept > 0) sentence.push(`${count(kept, "kept concern")}`);
35
+ if (unresolved > 0) sentence.push(`${count(unresolved, "answer")} not marked resolved`);
36
+ return sentence.length === 0 ? "No comments" : sentence.join(", ");
37
+ }
38
+
39
+ /**
40
+ * Where the report is saved, beside the review file.
41
+ * @param {string} saved path of reviews/vN.json
42
+ */
43
+ export function reportPath(saved) {
44
+ return saved.replace(/\.json$/, ".md");
45
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shiyuphan/follow-me",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Split a branch's final changes into fine, ordered commits that read like the author's thought process, review them hunk by hunk, and hand the review back to a coding agent.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -44,7 +44,9 @@
44
44
  "build": "rm -rf dist && tsc -p tsconfig.build.json && cp -R ui dist/ui"
45
45
  },
46
46
  "dependencies": {
47
- "@anthropic-ai/sdk": "0.135.0"
47
+ "@anthropic-ai/sdk": "0.135.0",
48
+ "mermaid": "12.2.0",
49
+ "prismjs": "1.30.0"
48
50
  },
49
51
  "devDependencies": {
50
52
  "@biomejs/biome": "^2.5.15",
@@ -8,7 +8,7 @@ description: Split the current branch's net change into fine, story-ordered comm
8
8
  follow-me rewrites a branch as small commits ordered so a reader follows your thinking. It never
9
9
  touches your working tree or index. It writes a new branch and keeps state in `.follow-me/<slug>/`.
10
10
 
11
- Run every command from the repo root. If `follow-me` is not on PATH, ask the user how it is installed.
11
+ Run every command from the repo root. If `follow-me` is not on PATH, ask the user how to run it.
12
12
 
13
13
  ## First pass
14
14
 
@@ -23,7 +23,9 @@ Run every command from the repo root. If `follow-me` is not on PATH, ask the use
23
23
  lines are real mistakes.
24
24
  5. `follow-me apply` freezes the plan as the next version and writes the branch.
25
25
  6. Tell the user to run `follow-me review`. It opens a local page where they comment on messages,
26
- positions, hunks and single lines.
26
+ positions, hunks and single lines. If you start it yourself, use `follow-me review --wait --no-open`,
27
+ which prints the page URL to give the user and returns once they end the review, so you can go
28
+ straight on to `follow-me feedback`; one server hosts every session the user has open.
27
29
 
28
30
  ## After a review
29
31
 
@@ -39,18 +41,24 @@ When the user says they finished reviewing:
39
41
  ## As a reviewer
40
42
 
41
43
  `follow-me walk` is for someone reading a branch they did not write. It plays the branch back
42
- commit by commit in the browser, typing each line out while it reads your narration aloud, and the
43
- reviewer comments on the code. Nothing is applied and no branch is written.
44
+ commit by commit in the browser, one chunk of change at a time: it reads your narration aloud,
45
+ then shows the lines it explains. The reviewer comments on the code. Nothing is applied and no branch is written.
44
46
 
45
47
  1. `follow-me walk [--branch <name>]` opens the session. If there is no plan yet and no API key, it
46
48
  prints two commands and stops. Run the first, `follow-me prompt --walk`, and read all of it.
47
49
  2. Write the draft it names. The order rules are the same, and every commit also gets a
48
50
  `narration`: what the author is thinking while writing it, first person, present tense, two or
49
51
  three sentences, no markdown. Give a unit narration as `{ "unit": "h_x:0-3", "narration": "..." }`
50
- when the why of that hunk is not obvious from the commit's narration.
52
+ when the why of that hunk is not obvious from the commit's narration. Narration is spoken, so
53
+ it names no symbols the listener has to see spelled out and never describes a picture.
54
+ Optionally add a `diagram`, Mermaid source drawn beside the code, to a commit or a unit
55
+ (`{ "unit": "h_x", "diagram": "flowchart LR\n a --> b" }`). Use one only for what prose
56
+ carries badly: data flow between modules, a state machine, a call graph, or the before and
57
+ after shape of a structure. Most commits need none. Its first line must name the diagram type,
58
+ such as `flowchart`, `sequenceDiagram` or `stateDiagram-v2`; `follow-me check` rejects others.
51
59
  3. `follow-me check` until green, then tell the user to run `follow-me walk` again. Do not apply.
52
60
 
53
- When you are the author's agent and `follow-me feedback` starts with `# Code review`, the review
61
+ When you are the author's agent and `follow-me feedback --walk` prints a `# Code review`, the review
54
62
  came from a walk. It quotes each commented line as a diff excerpt with its line number on the
55
63
  branch. Address every item in the code on the branch itself, then tell the user what you changed
56
64
  and what you declined and why. Do not write a follow-me draft or `responses` for it; those answer
@@ -63,13 +71,23 @@ plan reviews only.
63
71
  A bare `h_x` takes whatever lines no other commit claimed.
64
72
  - `f_` and `m_` units are whole; they never take line lists.
65
73
 
66
- ## Install
67
-
68
- Copy or symlink this folder into the repo you want to use it in:
69
-
70
- ```sh
71
- mkdir -p .claude/skills
72
- ln -s /path/to/follow-me/skills/follow-me .claude/skills/follow-me
73
- ```
74
-
75
- For every repo at once, link it into `~/.claude/skills/follow-me` instead.
74
+ ## Interactive loop
75
+
76
+ While the review page is open the reviewer comments and asks questions live, and you answer without
77
+ closing the page. Everything goes through the review server.
78
+
79
+ 1. `follow-me watch [--since <seq>] [--timeout <seconds>]` blocks until the reviewer does something and
80
+ prints it (`--json` for one JSON object per line, `--follow` to stream until the review ends). It
81
+ exits 0 with news, 2 when nothing happened, and prints the `--since` to use next. Run it again in a
82
+ loop; stop when it reports that the review ended.
83
+ 2. Answer a question or comment in place with `follow-me reply <commentId> --body "..."`, adding
84
+ `--diagram <file>` with Mermaid source when a picture explains it. This needs no new plan.
85
+ 3. When the plan itself should change, write a new draft whose `responses` answer the comments
86
+ (`"status": "answered"` with `"at"` for questions), `follow-me check`, then `follow-me apply`. While the
87
+ page is open, apply swaps it to the new version at the same URL and keeps the old comments.
88
+ 4. At the end, `follow-me report` prints one consolidated report of the issues you and the reviewer
89
+ raised, by file and line, with questions and answers last. It is also saved as
90
+ `.follow-me/<slug>/reviews/vN.md`. Give it to the author.
91
+
92
+ In a walk you may also raise `concerns` (see `follow-me prompt --walk`); the reviewer keeps or dismisses
93
+ each, and only kept ones reach the report.