@chronova/wiki-agent 1.6.1 → 1.6.3
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 +17 -13
- package/dist/flatten-wiki.js +7 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,7 +16,9 @@ A standalone Ollama-only documentation agent. It inspects your source code and g
|
|
|
16
16
|
- **GitHub Actions** — `--init` automatically creates a scheduled update workflow in your repo
|
|
17
17
|
- **Repo instructions** — reads `AGENTS.md` or `CLAUDE.md` from the project root and follows all conventions documented there
|
|
18
18
|
- **Change reports** — each run writes `.wiki/.last-update-report.md` with created/edited pages, used as the staging PR body in CI
|
|
19
|
-
- **Restricted toolset** — the agent can only read files, write under `.wiki/`,
|
|
19
|
+
- **Restricted toolset** — the agent can only read files, write under `.wiki/`, run read-only git subcommands, and inspect pull requests via a read-only `gh` CLI tool; there is no shell tool
|
|
20
|
+
- **Staging PR staleness check** — before writing in update mode, the agent checks for open wiki staging PRs and abandons the update if a newer one already exists, preventing duplicate PRs
|
|
21
|
+
- **Frontmatter stripping** — YAML frontmatter is stripped before publishing to the GitHub Wiki tab, since GitHub Wiki renders frontmatter as literal text
|
|
20
22
|
|
|
21
23
|
## Quickstart
|
|
22
24
|
|
|
@@ -118,6 +120,7 @@ For cloud:
|
|
|
118
120
|
| `WIKI_OLLAMA_BASE_URL` | Override Ollama server URL | `http://localhost:11434` / `https://ollama.com` |
|
|
119
121
|
| `WIKI_MODEL` | Override model ID | from config |
|
|
120
122
|
| `WIKI_RECURSION_LIMIT` | Max agent iterations | `200` |
|
|
123
|
+
| `GH_TOKEN` | GitHub token for the read-only `gh` CLI tool (used in CI for the staging PR staleness check) | from environment |
|
|
121
124
|
|
|
122
125
|
Environment variables take priority over config files.
|
|
123
126
|
|
|
@@ -126,10 +129,10 @@ Environment variables take priority over config files.
|
|
|
126
129
|
Running `wiki --init --wiki` automatically creates `.github/workflows/update-wiki.yml` in your repo. With `--wiki`, the workflow publishes generated pages to your repository's **GitHub Wiki tab**; without `--wiki` it only stages `.wiki/` and opens a staging PR.
|
|
127
130
|
|
|
128
131
|
1. Generates a GitHub App token if `APP_CLIENT_ID` and `APP_PRIVATE_KEY` secrets are set (falls back to `GITHUB_TOKEN`)
|
|
129
|
-
2. Checks out your repo,
|
|
130
|
-
3. Runs `wiki --update --print --verbose`
|
|
132
|
+
2. Checks out your repo, sets up Bun and Node.js, and installs wiki-agent globally from npm
|
|
133
|
+
3. Runs `wiki --update --print --verbose --wiki` with `GH_TOKEN` set so the agent's `gh` tool can inspect open PRs, staging pages under `.wiki/`
|
|
131
134
|
4. Probes the wiki remote (`<repo>.wiki.git`) with `git ls-remote` to detect whether the wiki has been initialized
|
|
132
|
-
5. If there are content changes and the wiki is initialized:
|
|
135
|
+
5. If there are content changes and the wiki is initialized: flattens the `.wiki/` tree (stripping frontmatter, converting to flat wiki filenames), clones `<repo>.wiki.git`, rsyncs the flattened output, commits, and **pushes directly to `master`** — the wiki goes live immediately (no PR, no review gate)
|
|
133
136
|
6. Always opens a `docs: wiki staging snapshot` pull request against the main repo with the `.wiki/` changes, so the staged content stays auditable
|
|
134
137
|
|
|
135
138
|
### Bootstrap the wiki first
|
|
@@ -188,12 +191,13 @@ bun pm pack
|
|
|
188
191
|
## How it works
|
|
189
192
|
|
|
190
193
|
1. The agent reads `AGENTS.md` or `CLAUDE.md` from the project root and follows all conventions documented there
|
|
191
|
-
2. It inspects your source code using a restricted, read-only toolset: `read_file`, `ls`, `glob`, `grep`, `ast_grep`, `ast_search`,
|
|
192
|
-
3.
|
|
193
|
-
4.
|
|
194
|
-
5.
|
|
195
|
-
6.
|
|
196
|
-
7.
|
|
197
|
-
8.
|
|
198
|
-
|
|
199
|
-
|
|
194
|
+
2. It inspects your source code using a restricted, read-only toolset: `read_file`, `ls`, `glob`, `grep`, `ast_grep`, `ast_search`, a read-only `git` tool (whitelisted subcommands only — no mutating git, no shell), and a read-only `gh` CLI tool for inspecting pull requests and repository metadata
|
|
195
|
+
3. In update mode, it checks for open wiki staging PRs via `gh pr list` and compares branch timestamps against the latest commit — if a newer staging PR already exists, it abandons the update to prevent duplicates
|
|
196
|
+
4. It generates wiki pages under `.wiki/` with YAML frontmatter using `write_file` and `edit_file` (the only mutating tools, constrained to `.wiki/`)
|
|
197
|
+
5. After the run, `index.md` files are synchronized for each directory
|
|
198
|
+
6. `.last-updated.json` and `.last-update-report.md` are written
|
|
199
|
+
7. On `--init`, a GitHub Actions workflow is created for scheduled updates
|
|
200
|
+
8. In update mode, only pages affected by recent changes are refreshed
|
|
201
|
+
9. With `--wiki`, the workflow flattens the `.wiki/` tree (stripping frontmatter, converting nested paths to flat dash-joined filenames, rewriting links) and publishes to the GitHub Wiki tab by pushing directly to `<repo>.wiki.git` `master`
|
|
202
|
+
|
|
203
|
+
The agent uses a manual tool-calling loop with the Ollama chat API — no LangChain or LangGraph dependency. The recursion limit prevents infinite loops. There is no general-purpose shell tool; the agent cannot execute arbitrary commands on the host system. The `gh` tool is restricted to read-only subcommands (pr list, pr view, repo view, etc.) — mutating operations like create, merge, and close are blocked.
|
package/dist/flatten-wiki.js
CHANGED
|
@@ -227,11 +227,15 @@ export async function flattenWiki(wikiRoot, outputDir) {
|
|
|
227
227
|
const sidebar = generateSidebar(pageInfos);
|
|
228
228
|
await writeFile(path.join(outputDir, "_Sidebar.md"), sidebar, "utf8");
|
|
229
229
|
}
|
|
230
|
-
// CLI entrypoint:
|
|
231
|
-
|
|
230
|
+
// CLI entrypoint: wiki-flatten <wiki-root> <output-dir>
|
|
231
|
+
// Match both the compiled filename (flatten-wiki.js) and the bin symlink
|
|
232
|
+
// name (wiki-flatten) so it works under `node dist/flatten-wiki.js` and
|
|
233
|
+
// `wiki-flatten` (Bun/npm global install) alike.
|
|
234
|
+
const entrypoint = process.argv[1] ?? "";
|
|
235
|
+
if (entrypoint.endsWith("flatten-wiki.js") || entrypoint.endsWith("wiki-flatten")) {
|
|
232
236
|
const [wikiRoot, outputDir] = process.argv.slice(2);
|
|
233
237
|
if (!wikiRoot || !outputDir) {
|
|
234
|
-
console.error("Usage:
|
|
238
|
+
console.error("Usage: wiki-flatten <wiki-root> <output-dir>");
|
|
235
239
|
process.exit(1);
|
|
236
240
|
}
|
|
237
241
|
flattenWiki(wikiRoot, outputDir)
|