@chronova/wiki-agent 1.2.1 → 1.3.0
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.d.ts +1 -0
- package/dist/agent.js +12 -75
- package/dist/cli.js +8 -3
- package/dist/prompt.js +2 -0
- package/dist/tui/App.d.ts +2 -1
- package/dist/tui/App.js +2 -1
- package/dist/tui/RunView.d.ts +2 -1
- package/dist/tui/RunView.js +2 -1
- package/package.json +1 -1
package/dist/agent.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export interface RunOptions {
|
|
|
21
21
|
gitSummary?: string;
|
|
22
22
|
maxIterations?: number;
|
|
23
23
|
stream?: boolean;
|
|
24
|
+
wikiPublish?: boolean;
|
|
24
25
|
onEvent?: (event: AgentEvent) => void;
|
|
25
26
|
}
|
|
26
27
|
export declare function runAgent(client: Ollama, options: RunOptions): Promise<void>;
|
package/dist/agent.js
CHANGED
|
@@ -43,7 +43,7 @@ function normalizeToolCallArgs(args) {
|
|
|
43
43
|
return {};
|
|
44
44
|
}
|
|
45
45
|
export async function runAgent(client, options) {
|
|
46
|
-
const { command, projectRoot, model, gitSummary, maxIterations, stream = false, onEvent = () => { }, } = options;
|
|
46
|
+
const { command, projectRoot, model, gitSummary, maxIterations, stream = false, wikiPublish = false, onEvent = () => { }, } = options;
|
|
47
47
|
const maxIter = maxIterations ?? resolveMaxIterations();
|
|
48
48
|
const tools = createTools(projectRoot);
|
|
49
49
|
const systemPrompt = await createSystemPrompt(projectRoot);
|
|
@@ -156,8 +156,8 @@ export async function runAgent(client, options) {
|
|
|
156
156
|
});
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
|
-
await createWorkflowFile(projectRoot);
|
|
160
|
-
onEvent({ type: "tool", name: "create_workflow", result: "Created .github/workflows/update-wiki.yml" });
|
|
159
|
+
await createWorkflowFile(projectRoot, wikiPublish);
|
|
160
|
+
onEvent({ type: "tool", name: "create_workflow", result: wikiPublish ? "Created .github/workflows/update-wiki.yml (with wiki publish)" : "Created .github/workflows/update-wiki.yml" });
|
|
161
161
|
if (changedFiles.length === 0) {
|
|
162
162
|
onEvent({ type: "done", summary: "Wiki is already current. No files changed." });
|
|
163
163
|
return;
|
|
@@ -172,10 +172,11 @@ export async function runAgent(client, options) {
|
|
|
172
172
|
* Creates a GitHub Actions workflow file in the target repo that checks out
|
|
173
173
|
* the wiki-agent source, builds it, and runs --update --print on a schedule.
|
|
174
174
|
*/
|
|
175
|
-
async function createWorkflowFile(projectRoot) {
|
|
175
|
+
async function createWorkflowFile(projectRoot, wikiPublish) {
|
|
176
176
|
const workflowsDir = path.join(projectRoot, ".github", "workflows");
|
|
177
177
|
const workflowPath = path.join(workflowsDir, "update-wiki.yml");
|
|
178
178
|
await mkdir(workflowsDir, { recursive: true });
|
|
179
|
+
const runFlags = wikiPublish ? "--update --print --verbose --wiki" : "--update --print --verbose";
|
|
179
180
|
const workflow = [
|
|
180
181
|
"name: Wiki Update",
|
|
181
182
|
"",
|
|
@@ -221,7 +222,7 @@ async function createWorkflowFile(projectRoot) {
|
|
|
221
222
|
" npx tsc -p tsconfig.json",
|
|
222
223
|
"",
|
|
223
224
|
" - name: Run Wiki Agent",
|
|
224
|
-
|
|
225
|
+
` run: node /tmp/wiki-agent/dist/cli.js ${runFlags}`,
|
|
225
226
|
" env:",
|
|
226
227
|
" WIKI_OLLAMA_MODE: cloud",
|
|
227
228
|
' WIKI_OLLAMA_API_KEY: ${{ secrets.WIKI_OLLAMA_API_KEY }}',
|
|
@@ -231,23 +232,6 @@ async function createWorkflowFile(projectRoot) {
|
|
|
231
232
|
" id: timestamp",
|
|
232
233
|
" run: echo \"timestamp=$(date +%s)\" >> $GITHUB_OUTPUT",
|
|
233
234
|
"",
|
|
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
|
-
"",
|
|
251
235
|
" - name: Check for changes",
|
|
252
236
|
" id: report",
|
|
253
237
|
" run: |",
|
|
@@ -264,59 +248,12 @@ async function createWorkflowFile(projectRoot) {
|
|
|
264
248
|
" echo \"has_changes=false\" >> $GITHUB_OUTPUT",
|
|
265
249
|
" fi",
|
|
266
250
|
"",
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
" if: steps.report.outputs.has_changes == 'true' && steps.wiki-init.outputs.initialized == 'true'",
|
|
270
|
-
|
|
271
|
-
"
|
|
272
|
-
|
|
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",
|
|
310
|
-
" uses: peter-evans/create-pull-request@v8",
|
|
311
|
-
" if: steps.report.outputs.has_changes == 'true'",
|
|
312
|
-
" with:",
|
|
313
|
-
" token: ${{ secrets.WIKI_PUSH_TOKEN || steps.token.outputs.token || secrets.GITHUB_TOKEN }}",
|
|
314
|
-
" branch: wiki/staging-${{ steps.timestamp.outputs.timestamp }}",
|
|
315
|
-
" add-paths: .wiki",
|
|
316
|
-
' title: "docs: wiki staging snapshot"',
|
|
317
|
-
' body: ${{ steps.report.outputs.body }}',
|
|
318
|
-
].join("\n");
|
|
319
|
-
await writeFile(workflowPath, workflow, "utf8");
|
|
251
|
+
];
|
|
252
|
+
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: |", " BRANCH=\"wiki/update-${{ steps.timestamp.outputs.timestamp }}\"", " WIKI_URL=\"https://x-access-token:${TOKEN}@github.com/${{ steps.coords.outputs.owner_repo }}.wiki.git\"", " rm -rf /tmp/wiki", " git clone \"$WIKI_URL\" /tmp/wiki", " cd /tmp/wiki", " git checkout -b \"$BRANCH\"", " # --exclude='.git' protects the wiki clone's .git directory from --delete.", " rsync -a --delete \\", " --exclude='.git' \\", " --exclude='.last-update-report.md' \\", " --exclude='.last-updated.json' \\", " --exclude='config.json' \\", " \"$GITHUB_WORKSPACE/.wiki/\" ./", " 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 \"$BRANCH\" 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 \"branch=$BRANCH\" >> $GITHUB_OUTPUT", " else", " echo \"::warning::No net wiki content changes after sync; skipping wiki push.\"", " echo \"branch=\" >> $GITHUB_OUTPUT", " fi", "", " - name: Open wiki update pull request", " if: steps.report.outputs.has_changes == 'true' && steps.wiki-init.outputs.initialized == 'true' && steps.publish.outputs.branch != ''", " env:", " GH_TOKEN: ${{ secrets.WIKI_PUSH_TOKEN || steps.token.outputs.token || secrets.GITHUB_TOKEN }}", " run: |", " gh pr create --repo \"${{ steps.coords.outputs.owner_repo }}.wiki\" \\", " --head \"wiki/update-${{ steps.timestamp.outputs.timestamp }}\" \\", " --base master \\", " --title \"docs: update wiki\" \\", " --body-file .wiki/.last-update-report.md", "");
|
|
254
|
+
}
|
|
255
|
+
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
|
+
await writeFile(workflowPath, workflow.join("\n") + "\n", "utf8");
|
|
320
257
|
}
|
|
321
258
|
/**
|
|
322
259
|
* Generates a markdown report of what changed during this run.
|
package/dist/cli.js
CHANGED
|
@@ -9,7 +9,7 @@ import { getHelpText } from "./prompt.js";
|
|
|
9
9
|
import { App } from "./tui/App.js";
|
|
10
10
|
const execAsync = promisify(exec);
|
|
11
11
|
function parseArgs(argv) {
|
|
12
|
-
const args = { command: null, print: false, verbose: false, help: false };
|
|
12
|
+
const args = { command: null, print: false, verbose: false, wiki: false, help: false };
|
|
13
13
|
for (let i = 2; i < argv.length; i++) {
|
|
14
14
|
const arg = argv[i];
|
|
15
15
|
switch (arg) {
|
|
@@ -26,6 +26,9 @@ function parseArgs(argv) {
|
|
|
26
26
|
case "-v":
|
|
27
27
|
args.verbose = true;
|
|
28
28
|
break;
|
|
29
|
+
case "--wiki":
|
|
30
|
+
args.wiki = true;
|
|
31
|
+
break;
|
|
29
32
|
case "--model":
|
|
30
33
|
args.model = argv[++i];
|
|
31
34
|
break;
|
|
@@ -49,7 +52,7 @@ async function getGitSummary(cwd) {
|
|
|
49
52
|
return "(git not available or not a git repository)";
|
|
50
53
|
}
|
|
51
54
|
}
|
|
52
|
-
async function runHeadless(command, cwd, model, verbose) {
|
|
55
|
+
async function runHeadless(command, cwd, model, verbose, wiki) {
|
|
53
56
|
const config = await resolveConfig(cwd, model);
|
|
54
57
|
const client = createOllamaClient(config);
|
|
55
58
|
const gitSummary = await getGitSummary(cwd);
|
|
@@ -58,6 +61,7 @@ async function runHeadless(command, cwd, model, verbose) {
|
|
|
58
61
|
projectRoot: cwd,
|
|
59
62
|
model: config.model,
|
|
60
63
|
gitSummary,
|
|
64
|
+
wikiPublish: wiki,
|
|
61
65
|
stream: false,
|
|
62
66
|
onEvent: (event) => {
|
|
63
67
|
switch (event.type) {
|
|
@@ -95,7 +99,7 @@ async function main() {
|
|
|
95
99
|
process.exit(1);
|
|
96
100
|
}
|
|
97
101
|
if (args.print) {
|
|
98
|
-
await runHeadless(command, cwd, config.model, args.verbose);
|
|
102
|
+
await runHeadless(command, cwd, config.model, args.verbose, args.wiki);
|
|
99
103
|
}
|
|
100
104
|
else {
|
|
101
105
|
const { waitUntilExit } = inkRender(React.createElement(App, {
|
|
@@ -103,6 +107,7 @@ async function main() {
|
|
|
103
107
|
cwd,
|
|
104
108
|
config,
|
|
105
109
|
verbose: args.verbose,
|
|
110
|
+
wiki: args.wiki,
|
|
106
111
|
}));
|
|
107
112
|
await waitUntilExit();
|
|
108
113
|
}
|
package/dist/prompt.js
CHANGED
|
@@ -121,6 +121,7 @@ Usage
|
|
|
121
121
|
wiki --update --print Headless update (non-interactive)
|
|
122
122
|
wiki --init --print --model <id> Specify model
|
|
123
123
|
wiki --update --print --verbose Headless update with full tool logs
|
|
124
|
+
wiki --update --print --wiki Update and publish to the GitHub Wiki tab
|
|
124
125
|
wiki --help Show this help
|
|
125
126
|
|
|
126
127
|
Options
|
|
@@ -129,6 +130,7 @@ Options
|
|
|
129
130
|
--print Run headless (non-interactive, output to stdout)
|
|
130
131
|
--verbose, -v Show full tool call results (default: assistant prose only)
|
|
131
132
|
--model <id> Override the model ID
|
|
133
|
+
--wiki Publish to the GitHub Wiki tab (generates wiki-publish workflow)
|
|
132
134
|
--help, -h Show help
|
|
133
135
|
|
|
134
136
|
Environment variables
|
package/dist/tui/App.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ interface AppProps {
|
|
|
5
5
|
cwd: string;
|
|
6
6
|
config: ResolvedConfig;
|
|
7
7
|
verbose: boolean;
|
|
8
|
+
wiki: boolean;
|
|
8
9
|
}
|
|
9
|
-
export declare function App({ command, cwd, config, verbose }: AppProps): React.ReactElement;
|
|
10
|
+
export declare function App({ command, cwd, config, verbose, wiki }: AppProps): React.ReactElement;
|
|
10
11
|
export {};
|
package/dist/tui/App.js
CHANGED
|
@@ -2,7 +2,7 @@ import React, { useState, useCallback } from "react";
|
|
|
2
2
|
import { Box, Text, useApp, useInput } from "ink";
|
|
3
3
|
import { CredentialsSetup } from "./CredentialsSetup.js";
|
|
4
4
|
import { RunView } from "./RunView.js";
|
|
5
|
-
export function App({ command, cwd, config, verbose }) {
|
|
5
|
+
export function App({ command, cwd, config, verbose, wiki }) {
|
|
6
6
|
const [needsSetup, setNeedsSetup] = useState(config.mode === "cloud" && !config.apiKey);
|
|
7
7
|
const [resolvedConfig, setResolvedConfig] = useState(config);
|
|
8
8
|
const { exit } = useApp();
|
|
@@ -26,6 +26,7 @@ export function App({ command, cwd, config, verbose }) {
|
|
|
26
26
|
cwd,
|
|
27
27
|
config: resolvedConfig,
|
|
28
28
|
verbose,
|
|
29
|
+
wiki,
|
|
29
30
|
onExit: exit,
|
|
30
31
|
}));
|
|
31
32
|
}
|
package/dist/tui/RunView.d.ts
CHANGED
|
@@ -6,7 +6,8 @@ interface RunViewProps {
|
|
|
6
6
|
cwd: string;
|
|
7
7
|
config: ResolvedConfig;
|
|
8
8
|
verbose: boolean;
|
|
9
|
+
wiki: boolean;
|
|
9
10
|
onExit: () => void;
|
|
10
11
|
}
|
|
11
|
-
export declare function RunView({ command, cwd, config, verbose, onExit, }: RunViewProps): React.ReactElement;
|
|
12
|
+
export declare function RunView({ command, cwd, config, verbose, wiki, onExit, }: RunViewProps): React.ReactElement;
|
|
12
13
|
export {};
|
package/dist/tui/RunView.js
CHANGED
|
@@ -2,7 +2,7 @@ import React, { useState, useEffect, useRef } from "react";
|
|
|
2
2
|
import { Box, Text, useApp } from "ink";
|
|
3
3
|
import { runAgent } from "../agent.js";
|
|
4
4
|
import { createOllamaClient } from "../config.js";
|
|
5
|
-
export function RunView({ command, cwd, config, verbose, onExit, }) {
|
|
5
|
+
export function RunView({ command, cwd, config, verbose, wiki, onExit, }) {
|
|
6
6
|
const [events, setEvents] = useState([]);
|
|
7
7
|
const [running, setRunning] = useState(true);
|
|
8
8
|
const [error, setError] = useState(null);
|
|
@@ -15,6 +15,7 @@ export function RunView({ command, cwd, config, verbose, onExit, }) {
|
|
|
15
15
|
command,
|
|
16
16
|
projectRoot: cwd,
|
|
17
17
|
model: config.model,
|
|
18
|
+
wikiPublish: wiki,
|
|
18
19
|
stream: true,
|
|
19
20
|
onEvent: (event) => {
|
|
20
21
|
// Merge consecutive assistant chunks into one line so streaming
|