Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 113 additions & 0 deletions .github/workflows/action-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: Action

# Tests the action in `action.yml` as another repository would use it: with a
# released CodeWiki, on a small repository made here. `ci.yml` tests this
# repository's own code; this workflow tests only the action's steps.
on:
push:
branches: [main]
paths:
- action.yml
- .github/workflows/action-test.yml
pull_request:
paths:
- action.yml
- .github/workflows/action-test.yml
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
use:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, ubuntu-22.04, windows-latest]
runs-on: ${{ matrix.os }}
timeout-minutes: 15
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v7

# A repository of its own inside the workspace, in three languages.
- name: Make a small repository
run: |
mkdir -p fixture/src fixture/tools
cd fixture
git init -q -b main
git config user.name "CodeWiki action test"
git config user.email "[email protected]"
printf 'pub fn add(a: i32, b: i32) -> i32 {\n a + b\n}\n' > src/lib.rs
printf '[package]\nname = "fixture"\nversion = "0.1.0"\nedition = "2021"\n' > Cargo.toml
printf 'def greet(name):\n return "hello " + name\n' > tools/greet.py
printf 'Write-Output "hello"\n' > tools/hello.ps1
printf '# Fixture\n' > README.md
git add -A
git commit -q -m "a small repository"

- name: Check it and write its first wiki
id: first
uses: ./
with:
repo: fixture
wiki: update

- name: The first run wrote a report and a wiki
env:
REPORT: ${{ steps.first.outputs.report }}
VERSION: ${{ steps.first.outputs.version }}
CHANGED: ${{ steps.first.outputs.wiki-changed }}
run: |
echo "version $VERSION, report $REPORT, wiki changed $CHANGED"
test -n "$VERSION"
test -s "$REPORT"
grep -q '"version"' "$REPORT"
test "$CHANGED" = true
test -f fixture/obsidian/_HOME.md
test -f fixture/obsidian/.codewiki/manifest.json
# The program is on PATH for later steps.
codewiki --version
git -C fixture add -A
git -C fixture commit -q -m "the wiki"

- name: A wiki that is in sync passes
id: synced
uses: ./
with:
repo: fixture
check: "false"
wiki: check

- name: The sync changed nothing
env:
CHANGED: ${{ steps.synced.outputs.wiki-changed }}
run: |
test "$CHANGED" = false
git -C fixture checkout -q -- obsidian
printf 'pub fn sub(a: i32, b: i32) -> i32 {\n a - b\n}\n' >> fixture/src/lib.rs
git -C fixture commit -q -am "code without its wiki"

- name: Code that changed without its wiki fails
id: stale
continue-on-error: true
uses: ./
with:
repo: fixture
check: "false"
wiki: check

- name: It failed, and said that the wiki changed
env:
OUTCOME: ${{ steps.stale.outcome }}
CHANGED: ${{ steps.stale.outputs.wiki-changed }}
run: |
echo "outcome $OUTCOME, wiki changed $CHANGED"
test "$OUTCOME" = failure
test "$CHANGED" = true
3 changes: 2 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,10 @@ After the zip, `package.ps1` builds `dist\CodeWiki-<version>-windows-x64-setup.e

## CI

`.github/workflows/` holds four workflows:
`.github/workflows/` holds five workflows, and the root holds an action:

- `ci.yml` runs the four commands above, with `--locked`: format, clippy and the tests on Windows, and `cargo deny` on Linux in two legs (advisories; bans and sources). The licenses of dependencies are not checked, by the owner's decision of 2026-11-20: `deny.toml` has no list of allowed licenses, so a bare `cargo deny check` fails on every crate. The advisories leg can fail with no change in this repository, when a new advisory is published: fix the dependency, or add the advisory's ID to `ignore` in `deny.toml` with a reason. Its job `wiki-check` runs CodeWiki on this repository, on Linux: `codewiki check` uploads its findings to code scanning and never fails the build, and `codewiki update` does fail it. The wiki in `obsidian/` must be what the commit's code generates: the sync there may change nothing but `last_indexed_commit` in the manifest. So a push that changes code, a script, a workflow or a manifest carries its `docs(wiki)` commit (`cargo run -p codewiki -- update` at the repository root); a change to README, ROADMAP, this file or the guide needs none. Three things keep the result the same on every machine. A source file is hashed with CRLF read as LF (`cw_core::source_hash`), because git hands out one file with either ending. The sync counts every file it finds, tracked or not, so sync in a tree with no stray files, and put a folder that is no part of the project into `.codewikiignore`, where `docs/guide/` is. And the job writes `codewiki.sarif` outside the checkout. Dependabot cannot sync, so its pull requests skip the step, and the push that merges one must bring the sync.
- `action.yml` at the root is a GitHub Action for other repositories (`uses: Fly-onlyone/CodeWiki@action-v1`; README, "GitHub Action"). It never builds this repository: it uses a released CodeWiki. On a Linux runner it puts a script named `codewiki` on `PATH` that runs the image `ghcr.io/fly-onlyone/codewiki:<version>` as the runner's user, with the workspace and the temporary folder mounted at their own paths; on a Windows runner it takes `codewiki.exe` from the release's zip and checks the `.sha256`. Then it runs `codewiki check` and, for `wiki: check` or `update`, the sync, with the same comparison as `wiki-check` here. `action-test.yml` uses it as a stranger would, on a small repository made in the job, on `ubuntu-latest`, `ubuntu-22.04` and `windows-latest`; it runs when either file changes. The action's tags are `action-v<n>` (move `action-v1` for a change that breaks no caller): a tag that starts with `v` starts `release.yml`. A release that renames the zip, moves the binary in the image or changes the commands' options breaks the action: run `action-test.yml` by hand (`workflow_dispatch`) after each release.
- `security.yml` runs gitleaks over new commits. Never commit a secret, not even a test value that looks real. A confirmed false positive goes in `.gitleaksignore` by its fingerprint.
- `release.yml` and `docker.yml` run on a `v*` tag. The tag must equal `v` plus the workspace `version` in the root `Cargo.toml`. A tag publishes the Windows zip, the setup program and a `.sha256` for each as a GitHub Release, and pushes the image to GHCR. `release.yml` also builds the package, without publishing, on pushes to main and on pull requests that change `scripts/setup/**`, `package.ps1`, `install.ps1`, `uninstall.ps1` or `release.yml`. Do not push a tag unless asked. The package carries the DSN of the repository variable `SENTRY_DSN`; after the release, the programs' debug files (`dist\symbols-<version>\`, written by `package.ps1` and never put in the zip) go to the Sentry project `fly-theonlyone/codewiki` with `sentry-cli`, when the secret `SENTRY_AUTH_TOKEN` is set. The token is given to that step alone, never to the build.

Expand Down
50 changes: 46 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ The wiki is an Obsidian vault of Markdown notes at `<repo>/obsidian/`. It lives
- **Works for any language.** A repository in a language CodeWiki has no parser for still gets a wiki: its folders and files, mapped at file level, until a parser for that language exists.
- **Keeps it current.** After new commits it rewrites only the notes whose source changed.
- **Protects your edits.** A note you edited is never overwritten. Proposed changes wait in a review queue until you approve or reject them. When the code a note describes is deleted, a note with written work goes only where git can bring it back, and notes you wrote yourself only after you approve. The Review page shows the queue beside the open proposal; you can select several (click, Ctrl, Shift or the checkboxes) and approve or reject them in one step.
- **Tells you what happens.** A small notice appears in the corner of the window, and a Windows notification takes its place while the window is hidden or minimized. It says when the app has connected to its backend again and when new proposals wait for review.
- **Reads in tabs.** Right-click a tab to close it, the others, those to its right or left, or all, to reveal its note in the sidebar, or to copy its path. Right-click a note in the sidebar to open it in a new tab, or Ctrl+click or middle-click it. Settings → Appearance → Tabs turns tabs off, or opens every note in a tab of its own.
- **Reconnects by itself.** If the backend stops answering, the app tries again on its own, and so does the Settings page when your embedding model server is not running yet. No restart needed.
- **Answers agents.** An MCP server gives Claude Code and other agents the wiki, symbol detail, search, risk and impact analysis.
- **Searches by meaning.** Full-text search, joined by vectors from a model server on your machine (LM Studio, Ollama, Llama for Windows, Lemonade or mistral.rs) that you run and choose the model of. Without one, CodeWiki matches word forms. No key needed, no text leaves the machine. The search box suggests notes, symbols and files as you type.
- **Analyses the code.** Hotspots, ownership, change coupling, blast radius, dead code, documentation drift, file health, test impact, coverage gaps, security patterns, refactoring suggestions, decision records and API contracts.

Symbols are extracted for Rust, Python, TypeScript, JavaScript, Java, Kotlin, C#, Go, C and C++. Source in any other language (Swift, Ruby, PHP, shell, SQL, HTML, CSS, XAML and the like, named from the file extension) is mapped at file level: a note for each project folder and each folder that holds three or more of its files, with the files, their language and their size in lines, and no symbols, imports or call links. Your coding agent explains those notes from the files themselves. Other files are indexed by path.
Expand Down Expand Up @@ -345,6 +341,52 @@ docker run --rm -p 127.0.0.1:7411:7411 -e CODEWIKI_TOKEN=<secret> -v codewiki-da

Each released version is also pushed as `ghcr.io/fly-onlyone/codewiki:<version>`. Point the app or the MCP program at it with `CODEWIKI_URL=http://127.0.0.1:7411` and the same `CODEWIKI_TOKEN`. Set `CODEWIKI_WEBHOOK_SECRET` to let a git host trigger updates through `POST /v1/hooks/git`.

### GitHub Action

To run CodeWiki in another repository's CI, use the action in this repository. It installs a released CodeWiki on the runner, runs `codewiki check`, and can hold the committed wiki to the code.

```yaml
jobs:
codewiki:
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write # only for the upload below
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0 # hotspots, ownership and change coupling read the history
- id: codewiki
uses: Fly-onlyone/CodeWiki@action-v1
with:
wiki: check
- if: always()
uses: github/codeql-action/upload-sarif@v4
with:
sarif_file: ${{ steps.codewiki.outputs.report }}
category: codewiki
```

| Input | Default | What it does |
|---|---|---|
| `version` | `latest` | The CodeWiki release to use, as in `0.6.0`. Name one to keep runs the same. |
| `repo` | `.` | The repository's root, from the workspace. |
| `check` | `true` | Runs `codewiki check`, every analysis, and writes the report. |
| `fail-on` | `never` | The lowest level of a finding that fails the job: `note`, `warning`, `error` or `never`. |
| `format` | `sarif` | The report's format: `sarif`, `junit` or `text`. |
| `report` | a file in the runner's temporary folder | Where the report is written. |
| `wiki` | `off` | `check` syncs the wiki in `obsidian/` and fails when the sync changes anything: code changed without its wiki. `update` syncs it, or writes it the first time, and leaves the changes for a later step to commit. |

The outputs are `version`, `report` (the report's path) and `wiki-changed` (`true` or `false`). After the action, `codewiki` is on `PATH` for the steps that follow.

It runs on Linux runners, where it uses the image `ghcr.io/fly-onlyone/codewiki` and so needs Docker (GitHub's runners have it), and on Windows runners, where it takes `codewiki.exe` from the release's zip and checks its checksum. There is no build for macOS runners.

For `wiki: check`:

- Commit `obsidian/` after every change to code: the check fails when the two disagree. A bot that cannot run the sync, such as Dependabot, needs to be left out with an `if:`.
- CodeWiki counts every file in the checkout. A step that writes a file into it before the action makes the wiki look out of date; write such files elsewhere, or name them in `.codewikiignore`.
- Up to 0.6.0 a source file is recorded by a hash of its bytes, line endings included. A wiki synced on a machine whose files have other line endings than the runner's checkout fails the check until a release after 0.6.0, which reads CRLF as LF.

## Develop

```
Expand Down
1 change: 1 addition & 0 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Status as of 2026-11-28. "Verified" means covered by automated tests or by a liv

- 17 crates. `cargo fmt --check`, `cargo clippy --workspace --all-targets -- -D warnings`, `cargo test --workspace` (1295 tests) and `cargo deny check advisories bans sources` all pass. The licenses of dependencies are no longer checked, by the owner's decision of 2026-11-20.
- Not released yet, on main since 2026-11-28: a source file hashes the same with CRLF and LF line endings. Until 0.6.0 the hash was that of the raw bytes, so the same commit gave other hashes in another checkout: notes were marked behind though nothing had changed, and a synced wiki was out of sync on the next machine. Found when CI was made to fail on a wiki that is not what the code generates (`wiki-check` in `ci.yml`); that check has passed on Linux against the wiki written on Windows. Unit tests only; no VM run.
- On main since 2026-11-28, and usable at once because it runs a released CodeWiki: a GitHub Action for other repositories (`action.yml`, `uses: Fly-onlyone/CodeWiki@action-v1`). It runs `codewiki check` and can fail a job whose committed wiki is not what the code generates. Verified by `action-test.yml` on `ubuntu-latest`, `ubuntu-22.04` and `windows-latest` with 0.6.0, on a small repository made in the job; not tried in a real second repository, and not on a self-hosted runner.
- Version 0.6.0 is the seventh release, tagged on 2026-11-28 as `v0.6.0`. It brings:
- parsers for C#, Go, Kotlin, C and C++, and a file-level map for every other language;
- TypeScript path aliases, Python packages without `__init__.py`, and pnpm, yarn and bun projects;
Expand Down
Loading
Loading