From 7226ffc63e6599d4401f2556f234d2de13cb6a75 Mon Sep 17 00:00:00 2001 From: tomeyer97 <107920881+tomeyer97@users.noreply.github.com> Date: Thu, 26 Nov 2026 23:32:00 +0100 Subject: [PATCH] The README and docs match the code: no promises it doesn't keep, a GitLab recipe that runs, one skip rule The README lists each VS Code default the extension changes with how to undo it, drops the gutter + and the status bar bell, and moves Development to CONTRIBUTING.md. The linked docs ship in the package. The GitLab recipe uses a regular stage so it runs as a project's only job, and skipping the check is stated as one rule everywhere. --- CHANGELOG.md | 12 +++++++- CONTRIBUTING.md | 15 ++++++++++ README.md | 33 +++++++------------- docs/understanding-check.md | 27 +++++++++-------- package.json | 4 ++- test/docs.test.ts | 60 +++++++++++++++++++++++++++++++++++++ 6 files changed, 113 insertions(+), 38 deletions(-) create mode 100644 CONTRIBUTING.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 7aa7496..58e91fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## Unreleased + +### Fixed + +- **Docs match the extension.** The GitLab recipe for the understanding check uses the `test` stage, so it also runs + as a project's only job (GitLab creates no pipeline with only `.post` jobs). Skipping the check is described as it + works: the label plus an approval by someone else. The README lists the two VS Code defaults the extension changes + and how to undo them, no longer mentions a gutter `+` or a status bar bell, and ships the docs it links; + development moved to CONTRIBUTING.md. + ## 0.26.0 ### Added @@ -39,7 +49,7 @@ (after a second miss) the explanation, naming the code as clickable links. The **Check** view in the sidebar lists the questions; the status bar says where the check stands; **Commit & push** finishes it. Answers are saved in `understanding/.json` for a merge request check that needs no model (`cli/understanding.mjs ci`, GitLab and - GitHub recipes in the README). The bundled `understanding-check` skill writes the questions. + GitHub recipes in [docs/understanding-check.md](docs/understanding-check.md)). The bundled `understanding-check` skill writes the questions. - **Finding journeys:** journeys have their own **Journeys** view: In this file, Continue, Checks, then All by area, with search and sort. The panel's Journeys list gets a search field, chips, the same sections and a preview of the selected journey (its map, small, and its steps); a click selects, Enter or **Walk** starts it. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..ee31b4b --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,15 @@ +# Contributing + +```sh +npm ci +npm run build # the extension, the CLI bundle and the pages (scripts/build.mjs) +npm run lint # ESLint, and the layers of src/ and their import cycles (scripts/check-layers.mjs) +npm test # unit tests, golden tests included (test/README.md) +npm run test:goldens # only the golden tests; UPDATE_GOLDENS=1 rewrites them +npm run test:integration # the extension in a real VS Code (needs a display, or xvfb) +npm run package # code-notes-.vsix +``` + +Open the folder in VS Code and press F5 ("Code Notes (dev)") for a window that reloads itself when the code changes. + +Releases: see [CHANGELOG.md](CHANGELOG.md). Pushing a tag `v` publishes that version. diff --git a/README.md b/README.md index b764800..ca463b9 100644 --- a/README.md +++ b/README.md @@ -13,11 +13,9 @@ Three things for understanding code you did not write, in VS Code: ## Notes -- **Add one:** select code, press **Ctrl+'** then **C**, type, Ctrl+Enter. Or use the gutter `+`, or right-click → - **Add Note**. A note can also be on a whole file or folder (right-click it in the Explorer). +- **Add one:** select code, press **Ctrl+'** then **C**, type, Ctrl+Enter. Or right-click → **Add Note**. A note can also be on a whole file or folder (right-click it in the Explorer). - **Threads:** each note is a comment thread on its lines. Reply in the thread. -- **Answers from an agent** arrive as unread: a dot in the sidebar, a badge on the Code Notes icon, a bell in the - status bar. With the [Claude Code](https://claude.com/claude-code) CLI installed, **Ask Claude** on a note answers +- **Answers from an agent** arrive as unread: a dot in the sidebar and a badge on the Code Notes icon. With the [Claude Code](https://claude.com/claude-code) CLI installed, **Ask Claude** on a note answers it right there; any other agent can answer by editing the note files (see [Storage](#storage)). - **Resolve:** ✓ on the thread or the list row; tick several and resolve them together. Resolved notes are hidden. - **Suggestions:** an agent's ` ```suggestion ` block gets **Apply suggestion**, which replaces the note's lines. @@ -108,9 +106,14 @@ too. ## Settings -The extension turns on smooth editor scrolling by default, so the editor glides between a journey's steps. Set -`editor.smoothScrolling` to `false` to switch that off. All other settings are under **Code Notes** in the Settings -editor, named by what they are about: +The extension changes two VS Code defaults; a value in your own settings wins: + +| Default | Why | To undo | +|---|---|---| +| `comments.openView`: `never` | the Comments panel doesn't pop up for every note (this applies to other comment extensions too) | `"comments.openView": "firstFile"` | +| `editor.smoothScrolling`: `true` | the editor glides between a journey's steps | `"editor.smoothScrolling": false` | + +All other settings are under **Code Notes** in the Settings editor, named by what they are about: | Prefix | About | |---|---| @@ -124,22 +127,6 @@ editor, named by what they are about: The settings that choose what runs (the CLI, the models, the skills) are taken only from your user settings in a workspace you have not trusted. -## Development - -```sh -npm ci -npm run build # the extension, the CLI bundle and the pages (scripts/build.mjs) -npm run lint # ESLint, and the layers of src/ and their import cycles (scripts/check-layers.mjs) -npm test # unit tests, golden tests included (test/README.md) -npm run test:goldens # only the golden tests; UPDATE_GOLDENS=1 rewrites them -npm run test:integration # the extension in a real VS Code (needs a display, or xvfb) -npm run package # code-notes-.vsix -``` - -Open the folder in VS Code and press F5 ("Code Notes (dev)") for a window that reloads itself when the code changes. - -Releases: see [CHANGELOG.md](CHANGELOG.md). Pushing a tag `v` publishes that version. - ## License [MIT](LICENSE) diff --git a/docs/understanding-check.md b/docs/understanding-check.md index eb5ebc4..c64be93 100644 --- a/docs/understanding-check.md +++ b/docs/understanding-check.md @@ -16,7 +16,7 @@ branch's change and ask a few questions about it (1 for a small change, document it is built this way, how it fails. The first question opens as a thread on its lines; the list is the **Check** view in the Code Notes sidebar. Answer in 1-3 sentences and press Ctrl+Enter: Claude checks the answer against the code and replies in the thread, naming the code it means as links you can click. A miss gets a hint and a second try; a second -miss gets the explanation, which you may say back in one sentence (a right one counts as passed). Ctrl+' D goes to +miss gets the explanation, which you may say back in one sentence (a right one counts as passed). **Next question ›** goes to the next open question. You can also answer in the Check view: the selected question has a box there (Ctrl+Enter sends, Esc goes back to the code). @@ -43,8 +43,8 @@ make you look, not to police. never count go in `exempt` (none by default). - **The change grew** by more than 40 code lines since the questions: run the command again; it adds 1-2 questions about the new part only. Merging the target branch in doesn't count. -- **Skip it:** label the merge request `skip-understanding`. Any approval by someone other than the author waives the - check (re-run the job after the approval; on GitHub the review re-runs it). +- **Skip it:** add the label `skip-understanding` and get an approval from someone other than the author, then re-run + the job (on GitHub the review re-runs it). - **Settings** for a repository (a merge request is judged by its target branch's): `understanding/config.json`, e.g. `{ "exempt": ["docs/**", "*.md", "package-lock.json"], "passRatio": 0.6, "maxDrift": 40, "skipLabel": "skip-understanding", "mrComment": true }`. @@ -80,7 +80,8 @@ The command line, [cli/understanding.mjs](../cli/understanding.mjs) (Node 18+, n (e.g. a bad merge of the file) — not a security measure. 6. **The answers help the reviewer.** Once the check is done, CI posts the questions and answers on the merge request (never while it is in progress: no grading in public). -7. **Good faith over enforcement.** Least friction wins: an approval waives the check, every message is one short line. +7. **Good faith over enforcement.** Least friction wins: the skip label and an approval waive the check, + every message is one short line. ## Flow @@ -114,7 +115,7 @@ The command line, [cli/understanding.mjs](../cli/understanding.mjs) (Node 18+, n **Next question ›** appears. An unsent answer is kept per question in the workspace's state (never in the file). The list is the **Check** view in the Code Notes sidebar (the only list of them: the Code Notes tree doesn't repeat them, and steps aside while a check is open and there are no other notes): where the check stands, - one row per question, one button (Start, Add questions, Commit & push). Ctrl+' D / A walk the open questions; + one row per question, one button (Start, Add questions, Commit & push). Ctrl+' D / A walk the open questions (the tour's steps while it is walked); journey lenses step aside in the function of an open question (the rest of the file keeps them); another branch's check threads (and notes made from them) are hidden. Threads follow the file on disk: a changed question gets a new thread, a removed one loses it, and an answer is stored only for the question text it was shown with. @@ -128,7 +129,7 @@ The command line, [cli/understanding.mjs](../cli/understanding.mjs) (Node 18+, n the smallest change: one sentence and a suggestion block with Apply; Undo takes it back), **Add TODO** (the whole concern, wrapped at 100 characters, above the line it names at its indentation, or inside the block a "} catch {" line opens; the thread says where it went), **Flag for reviewer** (independent of the TODO). After a grade the editor stays on the question and the - reply box is empty; **Next question ›** under the grade (or Ctrl+' D) moves on. + reply box is empty; **Next question ›** under the grade moves on (Ctrl+' D follows the tour while one is walked). "Ask Claude" on a check question asks what you want to know and answers in a separate note; Claude is told never to write the check's answer. 5. When the rule is met the status bar says `✓ Understanding` and the view offers **Commit & push** right under @@ -442,8 +443,8 @@ ask a reviewer to approve, then re-run this job." The size is honest: "3 questio ## Skipping No size limit: every change with code lines needs the check (only exempt files or comment-only changes pass by -themselves). To skip one: add the label `skip-understanding`; any approval by someone other than the author waives the -check (GitLab approvals API; GitHub reviews API). The feature relies on good faith, so no reason is asked; the job and the +themselves). To skip one: add the label `skip-understanding` and get an approval from someone other than the author +(GitLab approvals API; GitHub reviews API); neither alone skips. The feature relies on good faith, so no reason is asked; the job and the comment record "waived (approved by @bob)". GitLab doesn't re-run the job on an approval: the message says to re-run it (GitHub's recipe re-runs on the review). @@ -459,8 +460,8 @@ label. ```yaml understanding: image: node:22 - stage: .post # the last stage, so a missing check never skips lint or tests - needs: [] # but it starts at once: a failing test never skips it either + stage: test # if you list stages:, use your last one (not .post: see below) + needs: [] # it starts at once: a failing test never skips it rules: - if: $CI_PIPELINE_SOURCE == "merge_request_event" variables: @@ -508,9 +509,9 @@ comment work as usual, but a failure doesn't block: on GitLab the job exits 3 an To review the script once and keep it, commit a copy (e.g. `tools/understanding.mjs`) and run that instead. -GitLab: a job on `merge_request_event` that runs on its own (`stage: .post`, `needs: []`) with plain `node` (no LLM CLI, no model key); `GITLAB_TOKEN` (project token, -`api` scope) for labels/approvals/comment; `allow_failure: { exit_codes: [3] }`. The last stage, because GitLab skips every later stage after a failed job: in `.pre`, -a missing check would skip lint and tests. `needs: []` starts it at once anyway, so a failing test never skips it either. +GitLab: a job on `merge_request_event` that runs on its own (`needs: []`) with plain `node` (no LLM CLI, no model key); `GITLAB_TOKEN` (project token, +`api` scope) for labels/approvals/comment; `allow_failure: { exit_codes: [3] }`. In the last stage, because GitLab skips every later stage after a failed job, +but not in `.pre`/`.post`: GitLab creates no pipeline whose only jobs are there, so as a project's only job it would never run. GitHub Actions: same CLI, `GITHUB_TOKEN`. **Advisory mode** (`"mode": "advisory"`, or `UNDERSTANDING_MODE=advisory`, which overrides the file): start advisory for diff --git a/package.json b/package.json index dbe23e9..6417f04 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,10 @@ "skills/understanding-check/SKILL.md", "skills/understanding-check/scripts/questions.mjs", "cli/understanding.mjs", + "docs/agent-protocol.md", + "docs/journey-format.md", "docs/podcast-format.md", + "docs/understanding-check.md", "README.md", "CHANGELOG.md", "LICENSE" @@ -1643,7 +1646,6 @@ ], "configurationDefaults": { "comments.openView": "never", - "comments.maxHeight": false, "editor.smoothScrolling": true } }, diff --git a/test/docs.test.ts b/test/docs.test.ts index 0d75bca..3a392fd 100644 --- a/test/docs.test.ts +++ b/test/docs.test.ts @@ -29,3 +29,63 @@ test('the recipes pin each action to the commit this repository\'s CI uses', () assert.equal(ref, ours.get(action), `${action}: the commit this repository's CI uses`) } }) + +const readme = read('README.md') +const pkg = JSON.parse(read('package.json')) + +test('the README lists every VS Code default the extension changes, with how to undo it', () => { + for (const key of Object.keys(pkg.contributes.configurationDefaults)) { + const row = readme.split('\n').find((l) => l.startsWith(`| \`${key}\``)) + assert.ok(row, `${key}: a row in the README's Settings`) + assert.ok(row.split('|').at(-2)!.includes(`"${key}"`), `${key}: how to undo it`) + } +}) + +test('every docs/ file the README links ships in the package', () => { + const links = [...readme.matchAll(/\]\((docs\/[^)#\s]+)/g)].map((m) => m[1]).filter((l) => !l.startsWith('docs/images/')) + assert.ok(links.length >= 2, 'the README links docs') + for (const l of links) assert.ok(pkg.files.includes(l), l) +}) + +test('the README is for users: no Development section, no gutter +, no status bar bell', () => { + assert.doesNotMatch(readme, /^## Development/m) + assert.doesNotMatch(readme, /gutter `?\+/) + assert.doesNotMatch(readme, /\bbell\b/) +}) + +test('skipping is one rule: the label and an approval, never an approval alone', () => { + for (const text of [readme, doc]) { + assert.doesNotMatch(text, /any approval[^.]*waives/i) + assert.doesNotMatch(text, /approval waives the check/i) + } + const rule = /add the label `skip-understanding` and get an approval from someone other than the author/g + assert.equal([...doc.matchAll(rule)].length, 2, 'Using it and Skipping say the same') +}) + +/** The fenced yaml block that follows `heading` (a line starting with it). */ +function yamlAfter(heading: string): string { + const at = doc.split('\n').findIndex((l) => l.startsWith(heading)) + assert.ok(at >= 0, heading) + const m = /```yaml\n([\s\S]*?)```/.exec(doc.split('\n').slice(at).join('\n')) + assert.ok(m, `a yaml block after ${heading}`) + return m[1] +} + +test('the GitLab recipe is valid YAML in a regular stage, so it runs as a project\'s only job', () => { + const yaml = yamlAfter('GitLab (`.gitlab-ci.yml`)') + // A small structural check (no YAML parser among the dependencies): two-space indents, no tabs, every line a + // `key:` or a `- item` under a key. + const lines = yaml.split('\n').filter((l) => l.trim() && !l.trim().startsWith('#')) + for (const l of lines) { + assert.doesNotMatch(l, /\t/, l) + assert.equal((l.length - l.trimStart().length) % 2, 0, l) + assert.match(l.trim(), /^(- .+|[\w$.-]+:( .*)?)$/, l) + } + assert.match(lines[0], /^understanding:$/) + const stage = /^ {2}stage: (\S+)/m.exec(yaml)?.[1] + assert.ok(stage, 'the job names its stage') + // GitLab creates no pipeline whose only jobs are in .pre/.post. + assert.ok(!['.pre', '.post'].includes(stage), stage) + assert.match(yaml, /^ {2}needs: \[\]/m) + assert.match(yaml, /merge_request_event/) +})