@chronova/wiki-agent 1.4.0 → 1.5.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/dist/agent.js +6 -12
- package/dist/flatten-wiki.d.ts +1 -0
- package/dist/flatten-wiki.js +19 -3
- package/package.json +3 -2
package/dist/agent.js
CHANGED
|
@@ -209,20 +209,14 @@ async function createWorkflowFile(projectRoot, wikiPublish) {
|
|
|
209
209
|
" with:",
|
|
210
210
|
" token: ${{ steps.token.outputs.token || secrets.GITHUB_TOKEN }}",
|
|
211
211
|
"",
|
|
212
|
-
" - name: Set up
|
|
213
|
-
" uses:
|
|
214
|
-
" with:",
|
|
215
|
-
' node-version: "25"',
|
|
212
|
+
" - name: Set up Bun",
|
|
213
|
+
" uses: oven-sh/setup-bun@v2",
|
|
216
214
|
"",
|
|
217
|
-
" - name:
|
|
218
|
-
" run:
|
|
219
|
-
" git clone --branch main --depth 1 https://github.com/nx-solutions-ug/wiki-agent.git /tmp/wiki-agent",
|
|
220
|
-
" cd /tmp/wiki-agent",
|
|
221
|
-
" npm install",
|
|
222
|
-
" npx tsc -p tsconfig.json",
|
|
215
|
+
" - name: Install Wiki Agent",
|
|
216
|
+
" run: bun add -g @chronova/wiki-agent",
|
|
223
217
|
"",
|
|
224
218
|
" - name: Run Wiki Agent",
|
|
225
|
-
` run:
|
|
219
|
+
` run: wiki ${runFlags}`,
|
|
226
220
|
" env:",
|
|
227
221
|
" WIKI_OLLAMA_MODE: cloud",
|
|
228
222
|
' WIKI_OLLAMA_API_KEY: ${{ secrets.WIKI_OLLAMA_API_KEY }}',
|
|
@@ -250,7 +244,7 @@ async function createWorkflowFile(projectRoot, wikiPublish) {
|
|
|
250
244
|
"",
|
|
251
245
|
];
|
|
252
246
|
if (wikiPublish) {
|
|
253
|
-
workflow.push(" - name: Repository coordinates", " id: coords", " run: echo \"owner_repo=${GITHUB_REPOSITORY}\" >> $GITHUB_OUTPUT", "", " - name: Detect wiki initialization", " id: wiki-init", " env:", " TOKEN: ${{ secrets.WIKI_PUSH_TOKEN || steps.token.outputs.token || secrets.GITHUB_TOKEN }}", " run: |", " REMOTE=\"https://x-access-token:${TOKEN}@github.com/${{ steps.coords.outputs.owner_repo }}.wiki.git\"", " if git ls-remote --exit-code \"$REMOTE\" HEAD >/dev/null 2>&1; then", " echo \"initialized=true\" >> $GITHUB_OUTPUT", " else", " echo \"initialized=false\" >> $GITHUB_OUTPUT", " 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", " fi", "", " - name: Publish to wiki repo", " id: publish", " if: steps.report.outputs.has_changes == 'true' && steps.wiki-init.outputs.initialized == 'true'", " env:", " TOKEN: ${{ secrets.WIKI_PUSH_TOKEN || steps.token.outputs.token || secrets.GITHUB_TOKEN }}", " run: |", " WIKI_URL=\"https://x-access-token:${TOKEN}@github.com/${{ steps.coords.outputs.owner_repo }}.wiki.git\"", " rm -rf /tmp/wiki /tmp/wiki-flat", "
|
|
247
|
+
workflow.push(" - name: Repository coordinates", " id: coords", " run: echo \"owner_repo=${GITHUB_REPOSITORY}\" >> $GITHUB_OUTPUT", "", " - name: Detect wiki initialization", " id: wiki-init", " env:", " TOKEN: ${{ secrets.WIKI_PUSH_TOKEN || steps.token.outputs.token || secrets.GITHUB_TOKEN }}", " run: |", " REMOTE=\"https://x-access-token:${TOKEN}@github.com/${{ steps.coords.outputs.owner_repo }}.wiki.git\"", " if git ls-remote --exit-code \"$REMOTE\" HEAD >/dev/null 2>&1; then", " echo \"initialized=true\" >> $GITHUB_OUTPUT", " else", " echo \"initialized=false\" >> $GITHUB_OUTPUT", " 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", " fi", "", " - name: Publish to wiki repo", " id: publish", " if: steps.report.outputs.has_changes == 'true' && steps.wiki-init.outputs.initialized == 'true'", " env:", " TOKEN: ${{ secrets.WIKI_PUSH_TOKEN || steps.token.outputs.token || secrets.GITHUB_TOKEN }}", " run: |", " WIKI_URL=\"https://x-access-token:${TOKEN}@github.com/${{ steps.coords.outputs.owner_repo }}.wiki.git\"", " rm -rf /tmp/wiki /tmp/wiki-flat", " wiki-flatten \"$GITHUB_WORKSPACE/.wiki\" /tmp/wiki-flat", " git clone \"$WIKI_URL\" /tmp/wiki", " cd /tmp/wiki", " # rsync the flattened wiki output (flat names, Home.md, _Sidebar.md).", " # --exclude='.git' protects the wiki clone's .git directory from --delete.", " rsync -a --delete \\", " --exclude='.git' \\", " /tmp/wiki-flat/ ./", " git add -A", " if ! git diff --cached --quiet; then", " git -c user.name='wiki-agent[bot]' -c user.email='bot@wiki-agent' \\", " commit -m \"docs: update wiki\"", " if ! git push origin master 2>&1 | tee /tmp/wiki-push.log; then", " 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.\"", " exit 1", " fi", " echo \"published=true\" >> $GITHUB_OUTPUT", " else", " echo \"::warning::No net wiki content changes after sync; skipping wiki push.\"", " echo \"published=false\" >> $GITHUB_OUTPUT", " fi");
|
|
254
248
|
}
|
|
255
249
|
workflow.push(" - name: Create wiki staging snapshot pull request", " uses: peter-evans/create-pull-request@v8", " if: steps.report.outputs.has_changes == 'true'", " with:", " token: ${{ secrets.WIKI_PUSH_TOKEN || steps.token.outputs.token || secrets.GITHUB_TOKEN }}", " branch: wiki/staging-${{ steps.timestamp.outputs.timestamp }}", " add-paths: .wiki", ' title: "docs: wiki staging snapshot"', ' body: ${{ steps.report.outputs.body }}');
|
|
256
250
|
await writeFile(workflowPath, workflow.join("\n") + "\n", "utf8");
|
package/dist/flatten-wiki.d.ts
CHANGED
package/dist/flatten-wiki.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
import { readFile, writeFile, mkdir, rm, readdir } from "node:fs/promises";
|
|
2
3
|
import path from "node:path";
|
|
3
4
|
/**
|
|
@@ -67,6 +68,19 @@ function extractTitle(content, wikiName) {
|
|
|
67
68
|
}
|
|
68
69
|
return wikiName.replace(/-/g, " ");
|
|
69
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Strips a leading YAML frontmatter block (`---\n...\n---`) from markdown
|
|
73
|
+
* content. GitHub Wiki does not process frontmatter — it renders the YAML
|
|
74
|
+
* as visible text — so the block must be removed before publishing.
|
|
75
|
+
* A single optional newline after the closing `---` is also trimmed so the
|
|
76
|
+
* body starts cleanly. Files without frontmatter are returned unchanged.
|
|
77
|
+
*/
|
|
78
|
+
function stripFrontmatter(content) {
|
|
79
|
+
const match = content.match(/^---\n[\s\S]*?\n---\n?/);
|
|
80
|
+
if (!match)
|
|
81
|
+
return content;
|
|
82
|
+
return content.slice(match[0].length);
|
|
83
|
+
}
|
|
70
84
|
/**
|
|
71
85
|
* Recursively walks the source .wiki/ directory and collects all .md files
|
|
72
86
|
* with their relative paths, excluding metadata and config files.
|
|
@@ -199,9 +213,11 @@ export async function flattenWiki(wikiRoot, outputDir) {
|
|
|
199
213
|
const wikiName = flatFile.replace(/\.md$/, "");
|
|
200
214
|
// Determine the source file's directory relative to .wiki/
|
|
201
215
|
const sourceRelDir = path.dirname(file.relPath) === "." ? "" : path.dirname(file.relPath);
|
|
202
|
-
// Rewrite links
|
|
203
|
-
|
|
204
|
-
|
|
216
|
+
// Rewrite links on the frontmatter-stripped body. GitHub Wiki renders
|
|
217
|
+
// frontmatter as literal text, so strip it before publishing.
|
|
218
|
+
const body = stripFrontmatter(content);
|
|
219
|
+
const rewritten = rewriteLinks(body, sourceRelDir, pathMap);
|
|
220
|
+
// Extract title for sidebar (uses the original content with frontmatter)
|
|
205
221
|
const title = extractTitle(content, wikiName);
|
|
206
222
|
pageInfos.push({ relPath: file.relPath, wikiName, title });
|
|
207
223
|
// Write the file
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chronova/wiki-agent",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"description": "Standalone Ollama-only documentation agent",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
|
-
"wiki": "dist/cli.js"
|
|
7
|
+
"wiki": "dist/cli.js",
|
|
8
|
+
"wiki-flatten": "dist/flatten-wiki.js"
|
|
8
9
|
},
|
|
9
10
|
"files": [
|
|
10
11
|
"dist",
|