@chronova/wiki-agent 1.1.4
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 +248 -0
- package/dist/agent.d.ts +35 -0
- package/dist/agent.js +317 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +113 -0
- package/dist/config.d.ts +44 -0
- package/dist/config.js +95 -0
- package/dist/index-middleware.d.ts +5 -0
- package/dist/index-middleware.js +135 -0
- package/dist/prompt.d.ts +4 -0
- package/dist/prompt.js +145 -0
- package/dist/tools.d.ts +24 -0
- package/dist/tools.js +471 -0
- package/dist/tui/App.d.ts +10 -0
- package/dist/tui/App.js +31 -0
- package/dist/tui/CredentialsSetup.d.ts +8 -0
- package/dist/tui/CredentialsSetup.js +74 -0
- package/dist/tui/RunView.d.ts +12 -0
- package/dist/tui/RunView.js +94 -0
- package/package.json +57 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import React, { useState, useEffect, useRef } from "react";
|
|
2
|
+
import { Box, Text, useApp } from "ink";
|
|
3
|
+
import { runAgent } from "../agent.js";
|
|
4
|
+
import { createOllamaClient } from "../config.js";
|
|
5
|
+
export function RunView({ command, cwd, config, verbose, onExit, }) {
|
|
6
|
+
const [events, setEvents] = useState([]);
|
|
7
|
+
const [running, setRunning] = useState(true);
|
|
8
|
+
const [error, setError] = useState(null);
|
|
9
|
+
const eventsRef = useRef([]);
|
|
10
|
+
const { exit } = useApp();
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
const client = createOllamaClient(config);
|
|
13
|
+
let toolCount = 0;
|
|
14
|
+
runAgent(client, {
|
|
15
|
+
command,
|
|
16
|
+
projectRoot: cwd,
|
|
17
|
+
model: config.model,
|
|
18
|
+
stream: true,
|
|
19
|
+
onEvent: (event) => {
|
|
20
|
+
// Merge consecutive assistant chunks into one line so streaming
|
|
21
|
+
// does not fragment prose into separate display rows.
|
|
22
|
+
if (event.type === "assistant") {
|
|
23
|
+
if (event.content) {
|
|
24
|
+
const last = eventsRef.current[eventsRef.current.length - 1];
|
|
25
|
+
if (last && last.type === "assistant") {
|
|
26
|
+
last.text += event.content;
|
|
27
|
+
setEvents([...eventsRef.current]);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
eventsRef.current = [
|
|
31
|
+
...eventsRef.current,
|
|
32
|
+
{ type: "assistant", text: event.content },
|
|
33
|
+
];
|
|
34
|
+
setEvents([...eventsRef.current]);
|
|
35
|
+
}
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
let display = null;
|
|
39
|
+
switch (event.type) {
|
|
40
|
+
case "tool":
|
|
41
|
+
// By default the TUI shows only assistant prose. In verbose
|
|
42
|
+
// mode, record the tool call (marker + result body) so the
|
|
43
|
+
// user can follow the full agent log.
|
|
44
|
+
if (event.result && verbose) {
|
|
45
|
+
toolCount += 1;
|
|
46
|
+
display = {
|
|
47
|
+
type: "tool",
|
|
48
|
+
text: event.result.slice(0, 1000),
|
|
49
|
+
toolName: event.name,
|
|
50
|
+
toolIndex: toolCount,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
break;
|
|
54
|
+
case "error":
|
|
55
|
+
display = { type: "error", text: event.message };
|
|
56
|
+
setError(event.message);
|
|
57
|
+
break;
|
|
58
|
+
case "done":
|
|
59
|
+
display = { type: "done", text: event.summary };
|
|
60
|
+
setRunning(false);
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
if (display) {
|
|
64
|
+
eventsRef.current = [...eventsRef.current, display];
|
|
65
|
+
setEvents([...eventsRef.current]);
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
}).catch((err) => {
|
|
69
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
70
|
+
setRunning(false);
|
|
71
|
+
});
|
|
72
|
+
}, [command, cwd, config, verbose]);
|
|
73
|
+
return React.createElement(Box, { flexDirection: "column", marginTop: 1 }, ...events.map((event, i) => React.createElement(EventLine, { key: i, event })), running
|
|
74
|
+
? React.createElement(Text, { color: "yellow" }, "⏳ Working...")
|
|
75
|
+
: React.createElement(Text, { color: "green" }, `✓ ${error ? "Failed: " + error : "Done"}`), !running
|
|
76
|
+
? React.createElement(Text, { color: "gray" }, "Press q or Ctrl+C to exit.")
|
|
77
|
+
: null);
|
|
78
|
+
}
|
|
79
|
+
function EventLine({ event, }) {
|
|
80
|
+
switch (event.type) {
|
|
81
|
+
case "assistant":
|
|
82
|
+
// Indent assistant prose with a cyan bullet so it reads as a
|
|
83
|
+
// distinct paragraph, not a continuation of tool output above.
|
|
84
|
+
return React.createElement(Box, { marginTop: 1 }, React.createElement(Text, { color: "cyan" }, "» "), React.createElement(Text, { color: "cyan" }, event.text));
|
|
85
|
+
case "tool":
|
|
86
|
+
return React.createElement(Box, { flexDirection: "column", marginTop: 1 }, React.createElement(Text, { color: "gray", dimColor: true }, `#${event.toolIndex ?? ""} → ${event.toolName}`), event.text
|
|
87
|
+
? React.createElement(Text, { color: "gray", dimColor: true }, event.text)
|
|
88
|
+
: null);
|
|
89
|
+
case "error":
|
|
90
|
+
return React.createElement(Text, { color: "red" }, `Error: ${event.text}`);
|
|
91
|
+
case "done":
|
|
92
|
+
return React.createElement(Text, { color: "green", bold: true }, event.text);
|
|
93
|
+
}
|
|
94
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@chronova/wiki-agent",
|
|
3
|
+
"version": "1.1.4",
|
|
4
|
+
"description": "Standalone Ollama-only documentation agent",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"wiki": "dist/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsc -p tsconfig.json",
|
|
15
|
+
"clean": "node -e \"require('fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
16
|
+
"prebuild": "bun run clean",
|
|
17
|
+
"test": "vitest run",
|
|
18
|
+
"pack": "bun pm pack",
|
|
19
|
+
"prepublishOnly": "npm run build",
|
|
20
|
+
"semantic-release": "semantic-release"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@ast-grep/cli": "^0.44.1",
|
|
24
|
+
"ink": "^7.0.0",
|
|
25
|
+
"ink-text-input": "^6.0.0",
|
|
26
|
+
"marked": "^18.0.0",
|
|
27
|
+
"ollama": "^0.6.3",
|
|
28
|
+
"react": "^19.1.0",
|
|
29
|
+
"yaml": "^2.7.1"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@semantic-release/changelog": "^6.0.3",
|
|
33
|
+
"@semantic-release/commit-analyzer": "^13.0.1",
|
|
34
|
+
"@semantic-release/git": "^10.0.1",
|
|
35
|
+
"@semantic-release/github": "^12.0.0",
|
|
36
|
+
"@semantic-release/npm": "^13.0.0",
|
|
37
|
+
"@semantic-release/release-notes-generator": "^14.0.3",
|
|
38
|
+
"@types/node": "^26.1.1",
|
|
39
|
+
"@types/react": "^19.1.0",
|
|
40
|
+
"semantic-release": "^25.0.0",
|
|
41
|
+
"tsx": "^4.20.0",
|
|
42
|
+
"typescript": "^5.9.0",
|
|
43
|
+
"vitest": "^4.0.0"
|
|
44
|
+
},
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=22"
|
|
47
|
+
},
|
|
48
|
+
"repository": {
|
|
49
|
+
"type": "git",
|
|
50
|
+
"url": "git+https://github.com/nx-solutions-ug/wiki-agent.git"
|
|
51
|
+
},
|
|
52
|
+
"homepage": "https://github.com/nx-solutions-ug/wiki-agent#readme",
|
|
53
|
+
"author": "nx-solutions-ug",
|
|
54
|
+
"publishConfig": {
|
|
55
|
+
"access": "public"
|
|
56
|
+
}
|
|
57
|
+
}
|