@chronova/wiki-agent 1.1.4 → 1.2.1

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 CHANGED
@@ -109,85 +109,21 @@ Environment variables take priority over config files.
109
109
 
110
110
  ## GitHub Actions
111
111
 
112
- Running `wiki --init` automatically creates `.github/workflows/update-wiki.yml` in your repo. The workflow:
112
+ Running `wiki --init` automatically creates `.github/workflows/update-wiki.yml` in your repo. The workflow publishes generated pages to your repository's **GitHub Wiki tab**, not to the main repo's file tree:
113
113
 
114
114
  1. Generates a GitHub App token if `APP_CLIENT_ID` and `APP_PRIVATE_KEY` secrets are set (falls back to `GITHUB_TOKEN`)
115
- 2. Checks out your repo
116
- 3. Clones and builds wiki-agent from `nx-solutions-ug/wiki-agent`
117
- 4. Runs `wiki --update --print` with your Ollama Cloud credentials
118
- 5. Reads `.wiki/.last-update-report.md` and uses it as the PR body
119
- 6. Creates a pull request with the `.wiki/` changes
120
-
121
- ```yaml
122
- name: Wiki Update
123
- on:
124
- workflow_dispatch:
125
- push:
126
- branches:
127
- - main
128
- schedule:
129
- - cron: "0 8 * * *"
130
- permissions:
131
- contents: write
132
- pull-requests: write
133
- jobs:
134
- update:
135
- runs-on: ubuntu-latest
136
- steps:
137
- - name: Generate token
138
- id: token
139
- uses: actions/create-github-app-token@v3
140
- with:
141
- client-id: ${{ secrets.APP_CLIENT_ID }}
142
- private-key: ${{ secrets.APP_PRIVATE_KEY }}
143
- continue-on-error: true
144
-
145
- - uses: actions/checkout@v7
146
- with:
147
- token: ${{ steps.token.outputs.token || secrets.GITHUB_TOKEN }}
148
-
149
- - uses: actions/setup-node@v7
150
- with:
151
- node-version: "25"
152
-
153
- - name: Build Wiki Agent
154
- run: |
155
- git clone --branch main --depth 1 https://github.com/nx-solutions-ug/wiki-agent.git /tmp/wiki-agent
156
- cd /tmp/wiki-agent
157
- npm install
158
- npx tsc -p tsconfig.json
159
-
160
- - name: Run Wiki Agent
161
- run: node /tmp/wiki-agent/dist/cli.js --update --print
162
- env:
163
- WIKI_OLLAMA_MODE: cloud
164
- WIKI_OLLAMA_API_KEY: ${{ secrets.WIKI_OLLAMA_API_KEY }}
165
- WIKI_MODEL: ${{ vars.WIKI_MODEL || 'kimi-k2.7-code' }}
166
-
167
- - name: Generate timestamp
168
- id: timestamp
169
- run: echo "timestamp=$(date +%s)" >> $GITHUB_OUTPUT
170
-
171
- - name: Read update report
172
- id: report
173
- run: |
174
- if [ -f .wiki/.last-update-report.md ]; then
175
- echo "body<<EOF" >> $GITHUB_OUTPUT
176
- cat .wiki/.last-update-report.md >> $GITHUB_OUTPUT
177
- echo "EOF" >> $GITHUB_OUTPUT
178
- else
179
- echo "body=Automated wiki documentation update." >> $GITHUB_OUTPUT
180
- fi
181
-
182
- - uses: peter-evans/create-pull-request@v8
183
- with:
184
- token: ${{ steps.token.outputs.token || secrets.GITHUB_TOKEN }}
185
- add-paths: .wiki
186
- branch: wiki/update-${{ steps.timestamp.outputs.timestamp }}
187
- commit-message: "docs: update wiki"
188
- title: "docs: update wiki"
189
- body: ${{ steps.report.outputs.body }}
190
- ```
115
+ 2. Checks out your repo, clones and builds wiki-agent from `nx-solutions-ug/wiki-agent`
116
+ 3. Runs `wiki --update --print` with your Ollama Cloud credentials, staging pages under `.wiki/`
117
+ 4. Probes the wiki remote (`<repo>.wiki.git`) with `git ls-remote` to detect whether the wiki has been initialized
118
+ 5. If there are content changes and the wiki is initialized: clones `<repo>.wiki.git`, syncs the `.wiki/` content (excluding `config.json`, `.last-update-report.md`, `.last-updated.json`) via `rsync`, commits on a `wiki/update-<timestamp>` branch, and pushes
119
+ 6. Opens a pull request against the wiki repo (`--repo <owner>/<repo>.wiki`, base `master`) with `.wiki/.last-update-report.md` as the body — a human merges to make updates live
120
+ 7. Always opens a `docs: wiki staging snapshot` pull request against the main repo with the `.wiki/` changes, so the staged content stays auditable
121
+
122
+ ### Bootstrap the wiki first
123
+
124
+ GitHub wikis must be initialized once through the UI before they can be pushed to programmatically. Open the **Wiki** tab in your repository, create the first page (any content), then run the workflow. Until then the publish step is skipped with a warning; the staging PR still opens so you can inspect the generated content.
125
+
126
+ The full workflow is written to `.github/workflows/update-wiki.yml` by `wiki --init`. See that file (or the template in [`src/agent.ts`](src/agent.ts) `createWorkflowFile`) for the authoritative, current definition. The steps in brief: generate token → checkout → build wiki-agent → run `--update --print` → probe wiki remote → if there are content changes and the wiki is initialized, clone `<repo>.wiki.git`, `rsync` the staged `.wiki/` content (excluding `config.json` and the run metadata), commit on `wiki/update-<timestamp>`, push → open a PR against the wiki repo (base `master`) → open a `docs: wiki staging snapshot` PR against the main repo.
191
127
 
192
128
  ### Required secrets
193
129
 
@@ -196,6 +132,7 @@ jobs:
196
132
  | `WIKI_OLLAMA_API_KEY` | Yes | Ollama Cloud API key |
197
133
  | `APP_CLIENT_ID` | No | GitHub App client ID for token generation (falls back to `GITHUB_TOKEN`) |
198
134
  | `APP_PRIVATE_KEY` | No | GitHub App private key |
135
+ | `WIKI_PUSH_TOKEN` | No | PAT with `repo` scope used to push to the wiki repo. If unset, the GitHub App token or `GITHUB_TOKEN` is used. Set this only if the default token cannot push to the wiki repo. |
199
136
 
200
137
  ### Optional variables
201
138
 
package/dist/agent.js CHANGED
@@ -226,10 +226,28 @@ async function createWorkflowFile(projectRoot) {
226
226
  " WIKI_OLLAMA_MODE: cloud",
227
227
  ' WIKI_OLLAMA_API_KEY: ${{ secrets.WIKI_OLLAMA_API_KEY }}',
228
228
  " WIKI_MODEL: ${{ vars.WIKI_MODEL || 'kimi-k2.7-code' }}",
229
+ "",
229
230
  " - name: Generate timestamp",
230
231
  " id: timestamp",
231
232
  " run: echo \"timestamp=$(date +%s)\" >> $GITHUB_OUTPUT",
232
233
  "",
234
+ " - name: Repository coordinates",
235
+ " id: coords",
236
+ " run: echo \"owner_repo=${GITHUB_REPOSITORY}\" >> $GITHUB_OUTPUT",
237
+ "",
238
+ " - name: Detect wiki initialization",
239
+ " id: wiki-init",
240
+ " env:",
241
+ " TOKEN: ${{ secrets.WIKI_PUSH_TOKEN || steps.token.outputs.token || secrets.GITHUB_TOKEN }}",
242
+ " run: |",
243
+ " REMOTE=\"https://x-access-token:${TOKEN}@github.com/${{ steps.coords.outputs.owner_repo }}.wiki.git\"",
244
+ " if git ls-remote --exit-code \"$REMOTE\" HEAD >/dev/null 2>&1; then",
245
+ " echo \"initialized=true\" >> $GITHUB_OUTPUT",
246
+ " else",
247
+ " echo \"initialized=false\" >> $GITHUB_OUTPUT",
248
+ " echo \"::warning::Wiki is not initialized. Create the first page in the GitHub UI (Wiki tab -> New Page), then rerun. Staging PR will still be opened.\" >> $GITHUB_OUTPUT",
249
+ " fi",
250
+ "",
233
251
  " - name: Check for changes",
234
252
  " id: report",
235
253
  " run: |",
@@ -246,14 +264,56 @@ async function createWorkflowFile(projectRoot) {
246
264
  " echo \"has_changes=false\" >> $GITHUB_OUTPUT",
247
265
  " fi",
248
266
  "",
249
- " - name: Create Wiki update pull request",
267
+ " - name: Publish to wiki repo",
268
+ " id: publish",
269
+ " if: steps.report.outputs.has_changes == 'true' && steps.wiki-init.outputs.initialized == 'true'",
270
+ " env:",
271
+ " TOKEN: ${{ secrets.WIKI_PUSH_TOKEN || steps.token.outputs.token || secrets.GITHUB_TOKEN }}",
272
+ " run: |",
273
+ " BRANCH=\"wiki/update-${{ steps.timestamp.outputs.timestamp }}\"",
274
+ " WIKI_URL=\"https://x-access-token:${TOKEN}@github.com/${{ steps.coords.outputs.owner_repo }}.wiki.git\"",
275
+ " rm -rf /tmp/wiki",
276
+ " git clone \"$WIKI_URL\" /tmp/wiki",
277
+ " cd /tmp/wiki",
278
+ " git checkout -b \"$BRANCH\"",
279
+ " rsync -a --delete \\",
280
+ " --exclude='.last-update-report.md' \\",
281
+ " --exclude='.last-updated.json' \\",
282
+ " --exclude='config.json' \\",
283
+ " \"$GITHUB_WORKSPACE/.wiki/\" ./",
284
+ " git add -A",
285
+ " if ! git diff --cached --quiet; then",
286
+ " git -c user.name='wiki-agent[bot]' -c user.email='bot@wiki-agent' \\",
287
+ " commit -m \"docs: update wiki\"",
288
+ " if ! git push origin \"$BRANCH\" 2>&1 | tee /tmp/wiki-push.log; then",
289
+ " echo \"::error::Failed to push to the wiki repo. Ensure the GitHub App has contents:write on the repository (which covers the wiki), or set a WIKI_PUSH_TOKEN secret with repo scope.\"",
290
+ " exit 1",
291
+ " fi",
292
+ " echo \"branch=$BRANCH\" >> $GITHUB_OUTPUT",
293
+ " else",
294
+ " echo \"::warning::No net wiki content changes after sync; skipping wiki push.\"",
295
+ " echo \"branch=\" >> $GITHUB_OUTPUT",
296
+ " fi",
297
+ "",
298
+ " - name: Open wiki update pull request",
299
+ " if: steps.report.outputs.has_changes == 'true' && steps.wiki-init.outputs.initialized == 'true' && steps.publish.outputs.branch != ''",
300
+ " env:",
301
+ " GH_TOKEN: ${{ secrets.WIKI_PUSH_TOKEN || steps.token.outputs.token || secrets.GITHUB_TOKEN }}",
302
+ " run: |",
303
+ " gh pr create --repo \"${{ steps.coords.outputs.owner_repo }}.wiki\" \\",
304
+ " --head \"wiki/update-${{ steps.timestamp.outputs.timestamp }}\" \\",
305
+ " --base master \\",
306
+ " --title \"docs: update wiki\" \\",
307
+ " --body-file .wiki/.last-update-report.md",
308
+ "",
309
+ " - name: Create wiki staging snapshot pull request",
250
310
  " uses: peter-evans/create-pull-request@v8",
251
311
  " if: steps.report.outputs.has_changes == 'true'",
252
312
  " with:",
253
- " token: ${{ steps.token.outputs.token || secrets.GITHUB_TOKEN }}",
254
- " branch: wiki/update-${{ steps.timestamp.outputs.timestamp }}",
313
+ " token: ${{ secrets.WIKI_PUSH_TOKEN || steps.token.outputs.token || secrets.GITHUB_TOKEN }}",
314
+ " branch: wiki/staging-${{ steps.timestamp.outputs.timestamp }}",
255
315
  " add-paths: .wiki",
256
- ' title: "docs: update wiki"',
316
+ ' title: "docs: wiki staging snapshot"',
257
317
  ' body: ${{ steps.report.outputs.body }}',
258
318
  ].join("\n");
259
319
  await writeFile(workflowPath, workflow, "utf8");
package/dist/prompt.js CHANGED
@@ -39,6 +39,7 @@ You cannot run build tools, package managers, test runners, scripts, or any prog
39
39
 
40
40
  # Output location
41
41
  - Write documentation under .wiki/ in the project root. Use paths such as .wiki/quickstart.md, .wiki/architecture/overview.md, .wiki/cli/usage.md.
42
+ - Your output is published to the repository's GitHub Wiki tab after the run. Wiki page titles come from filenames, so never use the characters \ / : * ? " < > | in wiki file names.
42
43
  - Never write markdown files outside .wiki/.
43
44
  - Each wiki page must start with YAML frontmatter:
44
45
  ---
@@ -95,7 +96,7 @@ ${gitSummary ?? "(not available)"}
95
96
  `.trim();
96
97
  }
97
98
  return `
98
- Update the existing OpenWiki documentation for this repository.
99
+ Update the existing wiki documentation for this repository.
99
100
 
100
101
  Inspect .wiki/, identify recent source changes or newly relevant evidence, and refresh only the documentation pages directly affected by those changes. Use the git evidence below when available. Keep edits surgical: do not rewrite accurate sections, do not update source maps or git evidence just to refresh them, and do not make formatting-only changes. If the wiki is already current, do not edit files.
101
102
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chronova/wiki-agent",
3
- "version": "1.1.4",
3
+ "version": "1.2.1",
4
4
  "description": "Standalone Ollama-only documentation agent",
5
5
  "type": "module",
6
6
  "bin": {