pi-harness-runtime 1.1.330 → 1.1.332
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/harness/wiki-integration.ts +227 -25
- package/package.json +1 -1
- package/packages/a2a-adapter/package.json +1 -1
- package/packages/agent-policy/package.json +1 -1
- package/packages/architecture-generator/package.json +1 -1
- package/packages/auth/package.json +1 -1
- package/packages/autonomous-refactor/package.json +1 -1
- package/packages/autonomous-runtime/package.json +1 -1
- package/packages/cache-strategy/package.json +1 -1
- package/packages/capability-registry/package.json +1 -1
- package/packages/checkpoint/package.json +1 -1
- package/packages/cli-plugin-sdk/package.json +1 -1
- package/packages/clipboard/package.json +1 -1
- package/packages/clipboard-plugin/package.json +1 -1
- package/packages/code-generation/package.json +1 -1
- package/packages/code-review/package.json +1 -1
- package/packages/codex-adapter/package.json +1 -1
- package/packages/codex-watcher/package.json +1 -1
- package/packages/config-capture/package.json +1 -1
- package/packages/context-compiler/package.json +1 -1
- package/packages/context-discovery/package.json +1 -1
- package/packages/context-manager/package.json +1 -1
- package/packages/cookie-sanitizer/package.json +1 -1
- package/packages/cost-optimizer/package.json +1 -1
- package/packages/dependency-analyzer/package.json +1 -1
- package/packages/django-plugin/package.json +1 -1
- package/packages/doc-generator/package.json +1 -1
- package/packages/durable-review/package.json +1 -1
- package/packages/e2e-tester/package.json +1 -1
- package/packages/evaluation-engine/package.json +1 -1
- package/packages/evaluation-runner/package.json +1 -1
- package/packages/event-bus/package.json +1 -1
- package/packages/event-store/package.json +1 -1
- package/packages/experience-replay/package.json +1 -1
- package/packages/feedback-collector/package.json +1 -1
- package/packages/file-copy-helper/package.json +1 -1
- package/packages/framework-detector/package.json +1 -1
- package/packages/framework-plugin-sdk/package.json +1 -1
- package/packages/frappe-plugin/package.json +1 -1
- package/packages/generic-web-plugin/package.json +1 -1
- package/packages/health-monitor/package.json +1 -1
- package/packages/intent-analyzer/package.json +1 -1
- package/packages/jev-judge/package.json +1 -1
- package/packages/knowledge-graph/package.json +1 -1
- package/packages/knowledge-retrieval/package.json +1 -1
- package/packages/laravel-plugin/package.json +1 -1
- package/packages/learning-engine/package.json +1 -1
- package/packages/mcp-adapter/package.json +1 -1
- package/packages/memory-engine/package.json +1 -1
- package/packages/milestone-manager/package.json +1 -1
- package/packages/model-registry/package.json +1 -1
- package/packages/nextjs-plugin/package.json +1 -1
- package/packages/notification/package.json +1 -1
- package/packages/observability/package.json +1 -1
- package/packages/okf-indexer/package.json +1 -1
- package/packages/paperclip-integration/package.json +1 -1
- package/packages/performance-optimizer/package.json +1 -1
- package/packages/privilege-broker/package.json +1 -1
- package/packages/project-analyzer/package.json +1 -1
- package/packages/project-bootstrap/package.json +1 -1
- package/packages/projection-engine/package.json +1 -1
- package/packages/prompt-compiler/package.json +1 -1
- package/packages/prompt-versioning/package.json +1 -1
- package/packages/provider-adapter-sdk/package.json +1 -1
- package/packages/provider-router/package.json +1 -1
- package/packages/provider-selector/package.json +1 -1
- package/packages/providers/package.json +1 -1
- package/packages/qdrant-skills/package.json +1 -1
- package/packages/quota-manager/package.json +1 -1
- package/packages/rate-limiter/package.json +1 -1
- package/packages/react-vite-plugin/package.json +1 -1
- package/packages/release-manager/package.json +1 -1
- package/packages/requirement-compiler/package.json +1 -1
- package/packages/runtime/package.json +1 -1
- package/packages/scheduler/package.json +1 -1
- package/packages/scheduler-adapter/package.json +1 -1
- package/packages/session/package.json +1 -1
- package/packages/session-api/package.json +1 -1
- package/packages/session-export/package.json +1 -1
- package/packages/shared-context/package.json +1 -1
- package/packages/skill-mcp-client/package.json +1 -1
- package/packages/skill-registry/package.json +1 -1
- package/packages/skills/package.json +1 -1
- package/packages/sprint-planner/package.json +1 -1
- package/packages/subscription-engine/package.json +1 -1
- package/packages/task-compiler/package.json +1 -1
- package/packages/telegram/package.json +1 -1
- package/packages/tencentdb-memory/package.json +1 -1
- package/packages/tencentdb-sync/package.json +1 -1
- package/packages/test-data-generator/package.json +1 -1
- package/packages/test-generator/package.json +1 -1
- package/packages/todo-bd-sync/package.json +1 -1
- package/packages/token-estimation/package.json +1 -1
- package/packages/token-optimizer/package.json +1 -1
- package/packages/trajectory/package.json +1 -1
- package/packages/tui/package.json +1 -1
- package/packages/types/package.json +1 -1
- package/packages/webmcp-tester/package.json +1 -1
- package/packages/wiki/dist/index.d.ts +14 -0
- package/packages/wiki/dist/index.d.ts.map +1 -1
- package/packages/wiki/dist/index.js +63 -2
- package/packages/wiki/dist/index.js.map +1 -1
- package/packages/wiki/dist/storage.d.ts +5 -1
- package/packages/wiki/dist/storage.d.ts.map +1 -1
- package/packages/wiki/dist/storage.js +55 -15
- package/packages/wiki/dist/storage.js.map +1 -1
- package/packages/wiki/package.json +1 -1
- package/packages/wiki/src/index.ts +75 -2
- package/packages/wiki/src/storage.ts +55 -16
- package/packages/workflow-events/package.json +1 -1
- package/packages/workspace-scanner/package.json +1 -1
- package/packages/worktree/package.json +1 -1
- package/packages/write-review/package.json +1 -1
|
@@ -1,10 +1,61 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Wiki Integration for Pi
|
|
3
3
|
*
|
|
4
|
-
* Implements wiki commands per wiki/llm-wiki-integration-minimax-plan.md
|
|
4
|
+
* Implements wiki commands and tools per wiki/llm-wiki-integration-minimax-plan.md
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
7
|
+
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
8
|
+
import { Type } from "typebox";
|
|
9
|
+
import { realpathSync } from "node:fs";
|
|
10
|
+
import path from "node:path";
|
|
11
|
+
|
|
12
|
+
// Cache managers by workspace root to avoid recreating
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
+
// Cache managers by workspace root to avoid recreating
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
|
+
const wikiManagers = new Map<string, any>();
|
|
17
|
+
|
|
18
|
+
// Pre-load the wiki module for ESM compatibility
|
|
19
|
+
let wikiModule: typeof import("../packages/wiki/dist/index.js") | null = null;
|
|
20
|
+
async function getWikiModule() {
|
|
21
|
+
if (!wikiModule) {
|
|
22
|
+
wikiModule = await import("../packages/wiki/dist/index.js");
|
|
23
|
+
}
|
|
24
|
+
return wikiModule;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Get or create wiki manager for a workspace
|
|
29
|
+
*/
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
|
+
async function getWiki(workspaceRoot: string): Promise<any> {
|
|
32
|
+
let manager = wikiManagers.get(workspaceRoot);
|
|
33
|
+
if (!manager) {
|
|
34
|
+
const mod = await getWikiModule();
|
|
35
|
+
const projectId = path.basename(workspaceRoot) || "unknown";
|
|
36
|
+
manager = mod.createWikiManager(workspaceRoot, projectId);
|
|
37
|
+
wikiManagers.set(workspaceRoot, manager);
|
|
38
|
+
}
|
|
39
|
+
return manager;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Get current workspace from Pi context
|
|
44
|
+
*/
|
|
45
|
+
function getCurrentWorkspace(ctx?: ExtensionContext): string {
|
|
46
|
+
if (ctx?.cwd) {
|
|
47
|
+
try {
|
|
48
|
+
return realpathSync(ctx.cwd);
|
|
49
|
+
} catch {
|
|
50
|
+
return ctx.cwd;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
54
|
+
return realpathSync(process.cwd());
|
|
55
|
+
} catch {
|
|
56
|
+
return process.cwd();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
8
59
|
|
|
9
60
|
/**
|
|
10
61
|
* Initialize wiki integration
|
|
@@ -16,33 +67,181 @@ export async function initWiki(pi: ExtensionAPI): Promise<void> {
|
|
|
16
67
|
}
|
|
17
68
|
|
|
18
69
|
try {
|
|
19
|
-
const {
|
|
20
|
-
"../packages/wiki/dist/index.js"
|
|
21
|
-
);
|
|
70
|
+
const { isWikiEnabled } = await import("../packages/wiki/dist/index.js");
|
|
22
71
|
|
|
23
|
-
//
|
|
24
|
-
|
|
72
|
+
// ========================================================================
|
|
73
|
+
// Register Tools (for LLM use)
|
|
74
|
+
// ========================================================================
|
|
25
75
|
|
|
26
|
-
//
|
|
27
|
-
|
|
76
|
+
// Tool: wiki_search - Search pages by query
|
|
77
|
+
pi.registerTool({
|
|
78
|
+
name: "wiki_search",
|
|
79
|
+
label: "Wiki Search",
|
|
80
|
+
description: "Search wiki pages by query. Returns page titles, IDs, status, and snippets.",
|
|
81
|
+
parameters: Type.Object({
|
|
82
|
+
query: Type.String({ description: "Search query" }),
|
|
83
|
+
limit: Type.Optional(Type.Number({ description: "Max results (default 5)", default: 5 })),
|
|
84
|
+
}),
|
|
85
|
+
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
86
|
+
if (!isWikiEnabled()) {
|
|
87
|
+
return { content: [{ type: "text", text: "Wiki feature is disabled." }], details: {} };
|
|
88
|
+
}
|
|
89
|
+
try {
|
|
90
|
+
const wiki = getWiki(getCurrentWorkspace(ctx));
|
|
91
|
+
const results = wiki.search(params.query, undefined, params.limit ?? 5);
|
|
92
|
+
if (results.length === 0) {
|
|
93
|
+
return { content: [{ type: "text", text: "No results found." }], details: {} };
|
|
94
|
+
}
|
|
95
|
+
const lines = results.map((r: { page: { status: string; title: string; kind: string; id: string } }) =>
|
|
96
|
+
`[${r.page.status}] ${r.page.title} (${r.page.kind}): ${r.page.id}`
|
|
97
|
+
);
|
|
98
|
+
return { content: [{ type: "text", text: `Found ${results.length} result(s):\n${lines.join("\n")}` }], details: {} };
|
|
99
|
+
} catch (err) {
|
|
100
|
+
return { content: [{ type: "text", text: `Search failed: ${err}` }], details: {} };
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
});
|
|
28
104
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
105
|
+
// Tool: wiki_read - Read a specific page
|
|
106
|
+
pi.registerTool({
|
|
107
|
+
name: "wiki_read",
|
|
108
|
+
label: "Wiki Read",
|
|
109
|
+
description: "Read a wiki page by ID. Returns frontmatter and body content.",
|
|
110
|
+
parameters: Type.Object({
|
|
111
|
+
pageId: Type.String({ description: "Page ID to read" }),
|
|
112
|
+
}),
|
|
113
|
+
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
114
|
+
if (!isWikiEnabled()) {
|
|
115
|
+
return { content: [{ type: "text", text: "Wiki feature is disabled." }], details: {} };
|
|
116
|
+
}
|
|
117
|
+
try {
|
|
118
|
+
const wiki = getWiki(getCurrentWorkspace(ctx));
|
|
119
|
+
const page = wiki.loadPage(params.pageId);
|
|
120
|
+
if (!page) {
|
|
121
|
+
return { content: [{ type: "text", text: `Page not found: ${params.pageId}` }], details: {} };
|
|
122
|
+
}
|
|
123
|
+
const lines = [
|
|
124
|
+
`# ${page.frontmatter.title}`,
|
|
125
|
+
`ID: ${page.frontmatter.id}`,
|
|
126
|
+
`Status: ${page.frontmatter.status}`,
|
|
127
|
+
`Kind: ${page.frontmatter.kind}`,
|
|
128
|
+
`Updated: ${page.frontmatter.updatedAt}`,
|
|
129
|
+
``,
|
|
130
|
+
`---`,
|
|
131
|
+
page.body,
|
|
132
|
+
];
|
|
133
|
+
return { content: [{ type: "text", text: lines.join("\n") }], details: {} };
|
|
134
|
+
} catch (err) {
|
|
135
|
+
return { content: [{ type: "text", text: `Read failed: ${err}` }], details: {} };
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
// Tool: wiki_ingest - Ingest a source file
|
|
141
|
+
pi.registerTool({
|
|
142
|
+
name: "wiki_ingest",
|
|
143
|
+
label: "Wiki Ingest",
|
|
144
|
+
description: "Ingest a source file into the wiki. Creates a snapshot and returns the snapshot ID.",
|
|
145
|
+
parameters: Type.Object({
|
|
146
|
+
sourcePath: Type.String({ description: "Path to source file to ingest" }),
|
|
147
|
+
}),
|
|
148
|
+
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
149
|
+
if (!isWikiEnabled()) {
|
|
150
|
+
return { content: [{ type: "text", text: "Wiki feature is disabled." }], details: {} };
|
|
151
|
+
}
|
|
152
|
+
try {
|
|
153
|
+
const wiki = getWiki(getCurrentWorkspace(ctx));
|
|
154
|
+
const { page, snapshot, existing } = wiki.ingestAndCreatePage(params.sourcePath);
|
|
155
|
+
if (existing) {
|
|
156
|
+
return { content: [{ type: "text", text: `Already ingested: ${snapshot.id}` }], details: {} };
|
|
157
|
+
}
|
|
158
|
+
return {
|
|
159
|
+
content: [{
|
|
160
|
+
type: "text",
|
|
161
|
+
text: `Ingested: ${snapshot.id}\nPage: ${page.frontmatter.id}\nTitle: ${page.frontmatter.title}\nPath: ${snapshot.originalPath}\nHash: ${snapshot.contentHash.slice(0, 16)}...`,
|
|
162
|
+
}],
|
|
163
|
+
details: { pageId: page.frontmatter.id },
|
|
164
|
+
};
|
|
165
|
+
} catch (err) {
|
|
166
|
+
return { content: [{ type: "text", text: `Ingest failed: ${err}` }], details: {} };
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
// Tool: wiki_lint - Run lint checks
|
|
172
|
+
pi.registerTool({
|
|
173
|
+
name: "wiki_lint",
|
|
174
|
+
label: "Wiki Lint",
|
|
175
|
+
description: "Run lint checks on the wiki. Returns structural and semantic issues.",
|
|
176
|
+
parameters: Type.Object({}),
|
|
177
|
+
async execute(_toolCallId, _params, _signal, _onUpdate, ctx) {
|
|
178
|
+
if (!isWikiEnabled()) {
|
|
179
|
+
return { content: [{ type: "text", text: "Wiki feature is disabled." }], details: {} };
|
|
180
|
+
}
|
|
181
|
+
try {
|
|
182
|
+
const wiki = getWiki(getCurrentWorkspace(ctx));
|
|
183
|
+
const findings = wiki.lint();
|
|
184
|
+
if (findings.length === 0) {
|
|
185
|
+
return { content: [{ type: "text", text: "No issues found." }], details: {} };
|
|
186
|
+
}
|
|
187
|
+
const lines = findings.slice(0, 20).map((f: { severity: string; category: string; message: string }) =>
|
|
188
|
+
`[${f.severity}] ${f.category}: ${f.message}`
|
|
189
|
+
);
|
|
190
|
+
return { content: [{ type: "text", text: `${findings.length} issue(s):\n${lines.join("\n")}` }], details: {} };
|
|
191
|
+
} catch (err) {
|
|
192
|
+
return { content: [{ type: "text", text: `Lint failed: ${err}` }], details: {} };
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
// Tool: wiki_status - Show wiki stats
|
|
198
|
+
pi.registerTool({
|
|
199
|
+
name: "wiki_status",
|
|
200
|
+
label: "Wiki Status",
|
|
201
|
+
description: "Show wiki statistics: page count, kinds, statuses.",
|
|
202
|
+
parameters: Type.Object({}),
|
|
203
|
+
async execute(_toolCallId, _params, _signal, _onUpdate, ctx) {
|
|
204
|
+
if (!isWikiEnabled()) {
|
|
205
|
+
return { content: [{ type: "text", text: "Wiki feature is disabled." }], details: {} };
|
|
206
|
+
}
|
|
207
|
+
try {
|
|
208
|
+
const wiki = getWiki(getCurrentWorkspace(ctx));
|
|
209
|
+
const pages = wiki.getAllPages();
|
|
210
|
+
const kinds: Record<string, number> = {};
|
|
211
|
+
const statuses: Record<string, number> = {};
|
|
212
|
+
for (const p of pages) {
|
|
213
|
+
kinds[p.frontmatter.kind] = (kinds[p.frontmatter.kind] || 0) + 1;
|
|
214
|
+
statuses[p.frontmatter.status] = (statuses[p.frontmatter.status] || 0) + 1;
|
|
215
|
+
}
|
|
216
|
+
return {
|
|
217
|
+
content: [{
|
|
218
|
+
type: "text",
|
|
219
|
+
text: `Wiki Status\nPages: ${pages.length}\nKinds: ${JSON.stringify(kinds)}\nStatuses: ${JSON.stringify(statuses)}`,
|
|
220
|
+
}],
|
|
221
|
+
details: {},
|
|
222
|
+
};
|
|
223
|
+
} catch (err) {
|
|
224
|
+
return { content: [{ type: "text", text: `Status failed: ${err}` }], details: {} };
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
// ========================================================================
|
|
230
|
+
// Register Command (for user use)
|
|
231
|
+
// ========================================================================
|
|
35
232
|
|
|
36
|
-
// Register /harness-wiki command
|
|
37
233
|
pi.registerCommand("harness-wiki", {
|
|
38
234
|
description: "Manage project wiki: search, read, ingest, lint",
|
|
39
|
-
handler: async (args: string,
|
|
235
|
+
handler: async (args: string, ctx: unknown) => {
|
|
40
236
|
if (!isWikiEnabled()) {
|
|
41
237
|
console.log("Wiki feature is disabled. Set HARNESS_KNOWLEDGE_WIKI=1 to enable.");
|
|
42
238
|
return;
|
|
43
239
|
}
|
|
44
240
|
|
|
45
|
-
|
|
241
|
+
// Get workspace from context
|
|
242
|
+
const extCtx = ctx as ExtensionContext | undefined;
|
|
243
|
+
const workspace = getCurrentWorkspace(extCtx);
|
|
244
|
+
const wiki = getWiki(workspace);
|
|
46
245
|
const parts = args.trim().split(/\s+/);
|
|
47
246
|
const subcommand = parts[0] || "help";
|
|
48
247
|
const subargs = parts.slice(1).join(" ");
|
|
@@ -110,11 +309,12 @@ export async function initWiki(pi: ExtensionAPI): Promise<void> {
|
|
|
110
309
|
return;
|
|
111
310
|
}
|
|
112
311
|
try {
|
|
113
|
-
const { snapshot, existing } = wiki.
|
|
312
|
+
const { page, snapshot, existing } = wiki.ingestAndCreatePage(subargs);
|
|
114
313
|
if (existing) {
|
|
115
314
|
console.log(`Already ingested: ${snapshot.id}`);
|
|
116
315
|
} else {
|
|
117
316
|
console.log(`Ingested: ${snapshot.id}`);
|
|
317
|
+
console.log(` Page: ${page.frontmatter.id} - ${page.frontmatter.title}`);
|
|
118
318
|
console.log(` Path: ${snapshot.originalPath}`);
|
|
119
319
|
console.log(` Hash: ${snapshot.contentHash.slice(0, 16)}...`);
|
|
120
320
|
}
|
|
@@ -129,8 +329,8 @@ export async function initWiki(pi: ExtensionAPI): Promise<void> {
|
|
|
129
329
|
if (findings.length === 0) {
|
|
130
330
|
console.log("No issues found.");
|
|
131
331
|
} else {
|
|
132
|
-
const errors = findings.filter((f) => f.severity === "error");
|
|
133
|
-
const warnings = findings.filter((f) => f.severity === "warning");
|
|
332
|
+
const errors = findings.filter((f: { severity: string }) => f.severity === "error");
|
|
333
|
+
const warnings = findings.filter((f: { severity: string }) => f.severity === "warning");
|
|
134
334
|
console.log(`${errors.length} error(s), ${warnings.length} warning(s):`);
|
|
135
335
|
for (const f of findings.slice(0, 10)) {
|
|
136
336
|
console.log(` [${f.severity}] ${f.category}: ${f.message}`);
|
|
@@ -189,10 +389,12 @@ export function getWikiInstruction(): string {
|
|
|
189
389
|
return `
|
|
190
390
|
## Project Wiki
|
|
191
391
|
|
|
192
|
-
Project knowledge is available via
|
|
193
|
-
-
|
|
194
|
-
-
|
|
195
|
-
-
|
|
392
|
+
Project knowledge is available via wiki tools:
|
|
393
|
+
- wiki_search: Search pages by query
|
|
394
|
+
- wiki_read: Read a page by ID
|
|
395
|
+
- wiki_ingest: Ingest a source file
|
|
396
|
+
- wiki_lint: Check for issues
|
|
397
|
+
- wiki_status: Show statistics
|
|
196
398
|
|
|
197
399
|
The wiki contains:
|
|
198
400
|
- Design decisions with rationale
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-harness/capability-registry",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.332",
|
|
4
4
|
"description": "Capability Registry for pi-harness-runtime — tracks model capabilities and enables capability-based routing",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|