Skip to content

feat(cli): check the setup a run needs with chartula doctor - #295

Merged
goldbarth merged 2 commits into
mainfrom
feat/doctor
Sep 30, 2026
Merged

goldbarth merged 2 commits into
mainfrom
feat/doctor

Conversation

@goldbarth

Copy link
Copy Markdown
Owner

Closes #254

  • Why: a first run failed on the setup more often than on the release, and each failure showed up on its own, often after the run had started. chartula doctor checks everything a run needs, one line per check, before anything is spent.
  • Decided in chartula doctor: check the setup before the first run #254: a subcommand; the endpoint check sends a minimal model request; the install scripts check with --version and point to doctor; "recent" is the last 30 merged pull requests; chartula init is its own issue.
  • Each check asks what a run asks, through the code a run uses: ReleaseTarget for tag and repository, ChartulaConfiguration plus Program.BuildServices for every setting, the key check of AddChartulaLlm, the model client with the messages from An answer the SDK cannot read is reported as an endpoint that could not be reached #263, the pull requests of the tag's commit as the first GitHub request of a run, and EnsureCanWriteAsync from generate finds out the token cannot publish only after every model call #262. So a failed check prints the message the run would print, and a later change to a run's checks reaches doctor without a second copy.
  • ok, warn, fail, skip: fail is what stops a run: git, checkout (not one, or shallow), tag, repository, configuration, a missing Anthropic key, the endpoint, reading the repository. warn is what limits it: no token, a token that may not publish (preview and --no-publish still run), titles without a prefix. A check whose prerequisite failed shows as skip, so one missing piece does not bury the report under follow-on errors.
  • Exit code: 0 when nothing failed, 1 otherwise, so a CI job can run it before generate.
  • What it costs: one model call per model a run uses (the thorough check's too, when it has a model of its own), capped at 16 output tokens; three GitHub requests. It writes nothing and publishes nothing; the publish check is generate-notes, which stores nothing.
  • Secrets: it names variables, never values.
  • Titles: ConventionalCommitCategorizer.HasKnownPrefix counts a prefix whose type maps to a category, so wip: counts as no prefix, the way the categorizer reads it. Up to three titles without one are quoted.
  • Seams, no new ports: doctor is a CLI concern, so it uses the Infrastructure adapters directly, like Program already uses GitCliRepositoryReader. Added: GitCliRepositoryReader.IsCheckoutAsync, IsShallowAsync, ReadCommitAsync; GitHubPullRequestReader.EnsureCanReadAsync, ReadRecentMergedTitlesAsync; a transport parameter on GitHubHttpClientFactory.Create and CreateChatClient; ReleaseTarget.ResolveTagAsync and ResolveRepositoryAsync, split out of ResolveAsync with its messages unchanged.
  • Install scripts: check the installed binary with --version and print it. A release pinned with CHARTULA_VERSION from before --version falls back to --help and is told to start with preview, since it has no doctor. The closing message names Anthropic as the default, links docs/providers.md for the others, and ends with chartula doctor.
  • docs/cli.md describes the command. docs/getting-started.md built around it is roadmap step 2.9, next.
  • Not in scope: the context window of a local server. A request of a few tokens cannot show that a window is too small for a release; the run's own message for it stays the source (CallValidity.cs).

Verified end to end with the binary from this branch, model on a local Ollama (qwen3:14b-ctx24k), no token spent:

$ chartula doctor                      # this repository, GITHUB_TOKEN set
  ok    git           /usr/bin/git
  ok    checkout      .../chartula-lane-a, with its full history
  ok    tag           v0.1.0-preview.3, the nearest tag reachable from HEAD. Pass --tag to choose another.
  ok    repository    goldbarth/chartula, from the 'origin' remote. Pass --repo to choose another.
  ok    config        .../chartula-lane-a/chartula.yaml
  ok    model         openai-compatible at http://localhost:11434/v1, model qwen3:14b-ctx24k, no key in OPENAI_API_KEY: a local server needs none
  ok    endpoint      qwen3:14b-ctx24k answered, 118 tokens
  ok    GitHub read   goldbarth/chartula at https://api.github.com/, token from GITHUB_TOKEN
  ok    GitHub write  the token can publish release notes to goldbarth/chartula, which generate needs
  ok    PR titles     all of the last 30 merged pull requests carry a Conventional Commits prefix
A run would start.                     # exit 0; gh release list unchanged before and after

Also run: without a token (warn on read and write, exit 0), outside a checkout, an Anthropic setup without a key, chartula.yaml and chartula.yml side by side, an unknown model id (the #263 message, 404 Not Found for model 'nope:1b'), a repository GitHub does not show, and a shallow clone. Each failed where a run would, with the run's message, and exited 1.

The install scripts were not run locally: install.yml runs install.sh in fresh containers against served binaries, and pwsh is not available here.

Tests: DoctorCommandTests (18: a ready setup, secrets and nothing written, one capped call per model, a thorough check on its own model, no git, not a checkout, shallow clone, no tag, a tag the checkout lacks, a configuration error, the file that is read, Anthropic without a key, an endpoint that does not serve the model, an unreadable repository, a token that may not publish, no token, titles without a prefix, closed pull requests not counted), with git real and GitHub and the model as handlers. Full suite passing, build without warnings, dotnet format clean.

@goldbarth goldbarth self-assigned this Sep 30, 2026
@goldbarth
goldbarth merged commit 05a7148 into main Sep 30, 2026
37 checks passed
@goldbarth
goldbarth deleted the feat/doctor branch September 30, 2026 12:19
goldbarth added a commit that referenced this pull request Oct 1, 2026
…s a run (#305)

Follows #295 and #286, which gave a user `chartula doctor` and `chartula
--version` to report from.

- **Why:** the bug report asked for the .NET version, which a user of a
release binary does not have, and for nothing a maintainer needs to run
the case again: not the command, the install method, the platform, the
model, or what the run printed. The feature request asked for a user
story and acceptance criteria, which is a maintainer's job, and not for
the workaround or who is affected.
- **The bug report is a form** (`bug_report.yml`), in the order a
reporter has the answers: what happened, the command, the output of
`chartula --version`, the install method, the platform as the eight
binaries of `docs/install.md` plus a build from source, provider and
model, the output of `chartula doctor`, the lines before the first step,
and the error or the run summary. No .NET version.
- **`doctor` and the header lines are optional, the rest required.** A
bug in `doctor` itself has no `doctor` output to paste; a run that
stopped at a usage error has no header. Both say why they help, so they
are filled in anyway.
- **The header field asks for every line up to `Range:`,** not only
`Model:` and `GitHub:`: a real run prints the announced `--tag` and
`--repo` defaults first, and those name the release the run worked on.
Its placeholder is copied from that run, with `thinking
provider-default` as `EndpointNotice.cs` prints it.
- **The form says its output is safe to paste,** since Chartula names
variables and never their values, and asks to replace a private
repository's name instead of withholding the report.
- **The feature request is a form** (`feature_request.yml`): the
problem, the current workaround, who is affected, all required; a
proposal, optional. It links `ROADMAP.md`, so a planned point is found
before it is requested again, and Discussions for a question.
- **Alpha feedback:** the version placeholder no longer names
`0.1.0-preview.3` with its commit, which aged with the next release; one
sentence says the alpha is the time before 1.0.0 and its releases carry
"preview" in the version, linking `versioning.md`.
- **`config.yml` links the Q&A category of Discussions** for questions,
above the security link. Blank issues stay enabled.
- The template file names `alpha-feedback.yml` and the chooser URL in
`troubleshooting.md` are unchanged, so every link to them still
resolves; nothing linked the two Markdown templates.

**Verified:**
- All four files validate against the SchemaStore schemas for issue
forms and the template chooser config (script, with a negative test).
- The header lines and their order are from a real `preview` with the
binary built from `main`, against an unreachable GitHub endpoint on
127.0.0.1; the error field's "last progress line and the message below
it" matches what that run printed.
- The labels `type:bug` and `type:feature` exist, and the Q&A category's
slug is `q-a` (GitHub API).

Tests: none, issue templates only.
goldbarth added a commit that referenced this pull request Oct 6, 2026
…hartula.yaml (#329)

Follows #295, which added `chartula doctor` (#254), and replaces the
planned `chartula init`.

- **Why:** a user who installed the binary has no copy of the
repository, so `chartula.example.yaml` existed for them only if they
knew where to look. `doctor` already said that no `chartula.yaml` was
found and the defaults apply; it now also says where the template is.
- **No `chartula init`:** what it would have set up is covered already.
`doctor` names a missing `chartula.yaml`, `docs/providers.md` gives the
`export` lines per provider, and the endpoint and key variable may not
go into the file anyway (ADR 0003). All that `init` could still write is
`llm.model`, which is not worth a command.
- **The link points at this version's tag, not at `main`:** an unknown
key in `chartula.yaml` is refused, and `main` may already list a key the
installed version does not know. A dev build between a version bump and
its tag links a tag that does not exist yet; that only affects
contributors.
- **Docs:** the sample `doctor` output in `getting-started.md` and
`troubleshooting.md` shows the new line.

**Verified:**
- The built CLI, run as `doctor` in a fresh checkout without
`chartula.yaml`, prints the line under `config`; the linked URL for
`v0.1.0-preview.3` answers 200.
- With a `chartula.yaml`, the line is absent.

Tests: `DoctorCommandTests` gains one test for the link and one
assertion that a present file gets no hint; 19 of 19 pass.
goldbarth added a commit that referenced this pull request Oct 7, 2026
Follows #344. Step 1 of `docs/development/releasing.md`.

- **Why now:** the launch points are merged, and the binary people
install is still `0.1.0-preview.3`, which has none of them. The
announcement needs a release that holds what the README and the docs on
`main` describe.
- **What ships since preview.3,** 63 commits:
- a first run: `chartula doctor` (#295, grouped in #341), `chartula
--version` (#286), a free `preview` (#292), progress while a run works
(#297, with a spinner and `--plain` in #340), a first tag from the first
commit with a confirmation for a large range (#282);
- what a release contains: commits without a pull request (#291), issue
numbers at every depth (#293), a sentence for a release with nothing for
developers (#307 in #333);
- checks and prompts: pull request text quoted and bounded (#338), no
false flag for a wrapped phrase or a fenced block (#336), flags set
apart from the entries (#331);
- publishing: the token checked before the first model call (#285), a
published release not replaced unless asked (#335);
- the files: `changelog.json` without descriptions and readable as text
(#294, #332).
- **Breaks to state in the notes,** as `docs/versioning.md` asks of a
preview:
- `changelog.json` is schema version 2: a change's `description` is gone
(#294). The run record is schema version 3 and holds the complete facts.
- `generate` stops on a tag whose release is already published;
`--replace-published` restores the old behaviour (#335).
- An option a command does not take stops the run (#301), and
`--whole-history` is gone (#282).
- The terminal output changed form (#340 to #342): the summary's first
line, audience headings in place of `--- Technical ---`, and `doctor`'s
last line. A script that reads those lines needs a look; exit codes and
the files are unchanged.
- The csproj `Version` is the single source; nothing else carries the
number.

**After merge:** tag the merge commit on `main` with `v0.1.0-preview.4`
and push it; `release.yml` builds the draft, `chartula generate --tag
v0.1.0-preview.4` writes the notes into it, and publishing runs
`install.yml`. The pinned `v0.1.0-preview.3` in `docs/ci.md` and
`docs/install.md`, and the template link in the `doctor` samples, move
to the new tag once the release exists, with the changelog pull request
of step 6.

**Verified:** the built CLI prints `chartula 0.1.0-preview.4+<commit>`.

Tests: no test changed. Full suite 1,010 passing, build without
warnings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chartula doctor: check the setup before the first run

1 participant