@leitwerk-dev/wiki 0.0.0-stage → 0.4.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/README.md +165 -2
- package/dist/LICENSE +13 -0
- package/dist/chunk-VDBICFJN.js +70 -0
- package/dist/chunk-VDBICFJN.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/instructions.d.ts +5 -0
- package/dist/instructions.d.ts.map +1 -0
- package/dist/integration.d.ts +22 -0
- package/dist/integration.d.ts.map +1 -0
- package/dist/integration.js +39 -0
- package/dist/integration.js.map +1 -0
- package/dist/model-D8KR8Be8.d.ts +50 -0
- package/dist/model.d.ts +48 -0
- package/dist/model.d.ts.map +1 -0
- package/dist/server/index.d.ts +5 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +422 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/routes.d.ts +6 -0
- package/dist/server/routes.d.ts.map +1 -0
- package/dist/server/schema.d.ts +178 -0
- package/dist/server/schema.d.ts.map +1 -0
- package/dist/server/store.d.ts +5 -0
- package/dist/server/store.d.ts.map +1 -0
- package/dist/server/test-fixture.d.ts +8 -0
- package/dist/server/test-fixture.d.ts.map +1 -0
- package/dist/server/tools.d.ts +5 -0
- package/dist/server/tools.d.ts.map +1 -0
- package/dist/store-qRZ3c4xC.d.ts +16 -0
- package/dist/store.d.ts +14 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/ui/WikiEntryEditor.svelte +156 -0
- package/dist/ui/WikiPage.svelte +334 -0
- package/dist/ui/index.d.ts +74 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +54 -0
- package/dist/ui/index.js.map +1 -0
- package/package.json +66 -5
- package/src/index.ts +3 -0
- package/src/instructions.ts +19 -0
- package/src/integration.ts +62 -0
- package/src/model.ts +96 -0
- package/src/server/index.ts +4 -0
- package/src/server/routes.ts +87 -0
- package/src/server/schema.ts +35 -0
- package/src/server/store.ts +201 -0
- package/src/server/test-fixture.ts +37 -0
- package/src/server/tools.ts +197 -0
- package/src/store.ts +30 -0
- package/src/ui/WikiEntryEditor.svelte +156 -0
- package/src/ui/WikiPage.svelte +334 -0
- package/src/ui/index.ts +132 -0
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isWikiPageId,
|
|
3
|
+
parseWikiPageContent,
|
|
4
|
+
wikiToolNames
|
|
5
|
+
} from "../chunk-VDBICFJN.js";
|
|
6
|
+
|
|
7
|
+
// src/server/routes.ts
|
|
8
|
+
import { asUnknownRecord } from "@leitwerk-dev/domain";
|
|
9
|
+
function registerTopicWikiRoutes(app, store, actorForRequest) {
|
|
10
|
+
app.get("/api/wiki/topics", async () => ({ topics: store.listTopics() }));
|
|
11
|
+
app.get("/api/wiki/topics/:topicId", async (request, reply) => {
|
|
12
|
+
const topic = store.getTopic(request.params.topicId);
|
|
13
|
+
if (!topic || topic.deleted)
|
|
14
|
+
return reply.code(404).send({ error: "Wiki group unavailable or deleted" });
|
|
15
|
+
return { topic, pages: store.listPages(topic.id) };
|
|
16
|
+
});
|
|
17
|
+
for (const [suffix, subject, conflict] of [
|
|
18
|
+
["", "wiki group", "Wiki group deletion conflict"],
|
|
19
|
+
["/pages/:pageId", "page", "Wiki deletion conflict"]
|
|
20
|
+
])
|
|
21
|
+
app.delete(`/api/wiki/topics/:topicId${suffix}`, async (request, reply) => {
|
|
22
|
+
const revision = Number(request.query.revision);
|
|
23
|
+
if (!Number.isSafeInteger(revision) || revision < 1)
|
|
24
|
+
return reply.code(400).send({ error: `A current ${subject} revision is required` });
|
|
25
|
+
try {
|
|
26
|
+
const { topicId, pageId } = request.params;
|
|
27
|
+
const actor = actorForRequest(request).id;
|
|
28
|
+
if (pageId !== void 0) store.deletePage(topicId, pageId, revision, actor);
|
|
29
|
+
else store.deleteTopic(topicId, revision, actor);
|
|
30
|
+
return { deleted: true };
|
|
31
|
+
} catch (error) {
|
|
32
|
+
return reply.code(409).send({ error: error instanceof Error ? error.message : conflict });
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
app.get(
|
|
36
|
+
"/api/wiki/topics/:topicId/pages/:pageId/history",
|
|
37
|
+
async (request, reply) => {
|
|
38
|
+
if (!store.readPage(request.params.topicId, request.params.pageId))
|
|
39
|
+
return reply.code(404).send({ error: "Wiki entry unavailable or deleted" });
|
|
40
|
+
return { revisions: store.history(request.params.topicId, request.params.pageId) };
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
app.put(
|
|
44
|
+
"/api/wiki/topics/:topicId/pages/:pageId",
|
|
45
|
+
async (request, reply) => {
|
|
46
|
+
const input = asUnknownRecord(request.body);
|
|
47
|
+
if (!input || !Number.isSafeInteger(input.expectedRevision) || Number(input.expectedRevision) < 1)
|
|
48
|
+
return reply.code(400).send({ error: "A current page revision is required" });
|
|
49
|
+
if (!isWikiPageId(request.params.pageId))
|
|
50
|
+
return reply.code(400).send({ error: "Use a stable alphanumeric wiki page ID" });
|
|
51
|
+
const current = store.readPage(request.params.topicId, request.params.pageId);
|
|
52
|
+
if (!current) return reply.code(404).send({ error: "Wiki entry unavailable or deleted" });
|
|
53
|
+
let content;
|
|
54
|
+
try {
|
|
55
|
+
content = parseWikiPageContent(input);
|
|
56
|
+
} catch (error) {
|
|
57
|
+
return reply.code(400).send({ error: error instanceof Error ? error.message : "Invalid wiki entry" });
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
return {
|
|
61
|
+
page: store.savePage(
|
|
62
|
+
{ ...current, ...content, updatedBy: actorForRequest(request) },
|
|
63
|
+
Number(input.expectedRevision)
|
|
64
|
+
)
|
|
65
|
+
};
|
|
66
|
+
} catch (error) {
|
|
67
|
+
return reply.code(409).send({
|
|
68
|
+
error: error instanceof Error ? error.message : "Wiki revision conflict; refresh before editing"
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// src/server/schema.ts
|
|
76
|
+
import { sqliteTable, text } from "drizzle-orm/sqlite-core";
|
|
77
|
+
var wikiTopics = sqliteTable("wiki_topics", {
|
|
78
|
+
/** @internal */
|
|
79
|
+
id: text("id").primaryKey(),
|
|
80
|
+
/** @internal */
|
|
81
|
+
key: text("key").notNull(),
|
|
82
|
+
/** @internal */
|
|
83
|
+
data: text("data").notNull()
|
|
84
|
+
});
|
|
85
|
+
var wikiPages = sqliteTable("wiki_pages", {
|
|
86
|
+
/** @internal */
|
|
87
|
+
id: text("id").primaryKey(),
|
|
88
|
+
/** @internal */
|
|
89
|
+
topicId: text("topic_id").notNull().references(() => wikiTopics.id),
|
|
90
|
+
/** @internal */
|
|
91
|
+
data: text("data").notNull()
|
|
92
|
+
});
|
|
93
|
+
var wikiRevisions = sqliteTable("wiki_revisions", {
|
|
94
|
+
/** @internal */
|
|
95
|
+
id: text("id").primaryKey(),
|
|
96
|
+
/** @internal */
|
|
97
|
+
pageId: text("page_id").notNull().references(() => wikiPages.id),
|
|
98
|
+
/** @internal */
|
|
99
|
+
data: text("data").notNull()
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
// src/server/store.ts
|
|
103
|
+
import { createHash } from "crypto";
|
|
104
|
+
import { eq } from "drizzle-orm";
|
|
105
|
+
function digest(value) {
|
|
106
|
+
return createHash("sha256").update(value).digest("hex");
|
|
107
|
+
}
|
|
108
|
+
function createTopicWikiRepo(db, changed = () => {
|
|
109
|
+
}) {
|
|
110
|
+
function rawPage(topicId, pageId) {
|
|
111
|
+
const row = db.select().from(wikiPages).where(eq(wikiPages.id, digest(JSON.stringify([topicId, pageId])))).get();
|
|
112
|
+
return row ? JSON.parse(row.data) : null;
|
|
113
|
+
}
|
|
114
|
+
function storePage(page) {
|
|
115
|
+
const id = digest(JSON.stringify([page.topicId, page.id]));
|
|
116
|
+
const data = JSON.stringify(page);
|
|
117
|
+
db.insert(wikiPages).values({ id, topicId: page.topicId, data }).onConflictDoUpdate({ target: wikiPages.id, set: { data } }).run();
|
|
118
|
+
db.insert(wikiRevisions).values({ id: `${id}:${page.revision}`, pageId: id, data }).run();
|
|
119
|
+
}
|
|
120
|
+
function storeTopic(topic) {
|
|
121
|
+
db.insert(wikiTopics).values({ id: topic.id, key: topic.key, data: JSON.stringify(topic) }).onConflictDoUpdate({ target: wikiTopics.id, set: { data: JSON.stringify(topic) } }).run();
|
|
122
|
+
}
|
|
123
|
+
function bumpTopic(topicId) {
|
|
124
|
+
const topic = store.getTopic(topicId);
|
|
125
|
+
if (!topic) throw new Error("Unknown wiki topic");
|
|
126
|
+
storeTopic({ ...topic, revision: (topic.revision ?? 1) + 1 });
|
|
127
|
+
}
|
|
128
|
+
function tombstone(current, actor, turnRecordId = "") {
|
|
129
|
+
return {
|
|
130
|
+
...current,
|
|
131
|
+
markdown: "",
|
|
132
|
+
applicability: "",
|
|
133
|
+
evidence: [],
|
|
134
|
+
deleted: true,
|
|
135
|
+
revision: current.revision + 1,
|
|
136
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
137
|
+
instanceId: actor,
|
|
138
|
+
turnRecordId,
|
|
139
|
+
updatedBy: void 0
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function invalidateDependents(topicId, pageId, updatedAt) {
|
|
143
|
+
for (const page of store.listPages(topicId))
|
|
144
|
+
if (page.links.includes(pageId))
|
|
145
|
+
storePage({
|
|
146
|
+
...page,
|
|
147
|
+
status: "needs_revalidation",
|
|
148
|
+
revision: page.revision + 1,
|
|
149
|
+
updatedAt
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
const store = {
|
|
153
|
+
ensureTopic(input) {
|
|
154
|
+
const id = digest(input.key);
|
|
155
|
+
const current = store.getTopic(id);
|
|
156
|
+
if (current?.deleted) return current;
|
|
157
|
+
const topic = { ...input, id, revision: current?.revision ?? 1, deleted: false };
|
|
158
|
+
if (JSON.stringify(current) === JSON.stringify(topic)) return topic;
|
|
159
|
+
if (current) topic.revision++;
|
|
160
|
+
storeTopic(topic);
|
|
161
|
+
changed(id);
|
|
162
|
+
return topic;
|
|
163
|
+
},
|
|
164
|
+
getTopic(id) {
|
|
165
|
+
const row = db.select().from(wikiTopics).where(eq(wikiTopics.id, id)).get();
|
|
166
|
+
if (!row) return null;
|
|
167
|
+
const topic = JSON.parse(row.data);
|
|
168
|
+
return { ...topic, revision: topic.revision ?? 1, deleted: topic.deleted ?? false };
|
|
169
|
+
},
|
|
170
|
+
listTopics() {
|
|
171
|
+
return db.select().from(wikiTopics).all().map((row) => {
|
|
172
|
+
const topic = JSON.parse(row.data);
|
|
173
|
+
return { ...topic, revision: topic.revision ?? 1, deleted: topic.deleted ?? false };
|
|
174
|
+
}).filter((topic) => !topic.deleted);
|
|
175
|
+
},
|
|
176
|
+
listPages(topicId) {
|
|
177
|
+
const topic = store.getTopic(topicId);
|
|
178
|
+
if (!topic || topic.deleted) return [];
|
|
179
|
+
const pages = db.select().from(wikiPages).where(eq(wikiPages.topicId, topicId)).all().map((row) => JSON.parse(row.data)).filter((page) => !page.deleted);
|
|
180
|
+
const ids = new Set(pages.map((page) => page.id));
|
|
181
|
+
const stale = new Set(
|
|
182
|
+
pages.filter(
|
|
183
|
+
(page) => page.sourceRevision !== topic?.sourceRevision || page.status === "needs_revalidation" || page.links.some((link) => !ids.has(link))
|
|
184
|
+
).map((page) => page.id)
|
|
185
|
+
);
|
|
186
|
+
let previousSize = -1;
|
|
187
|
+
while (previousSize !== stale.size) {
|
|
188
|
+
previousSize = stale.size;
|
|
189
|
+
for (const page of pages)
|
|
190
|
+
if (page.links.some((link) => stale.has(link))) stale.add(page.id);
|
|
191
|
+
}
|
|
192
|
+
return pages.map((page) => ({
|
|
193
|
+
...page,
|
|
194
|
+
status: stale.has(page.id) ? "needs_revalidation" : page.status
|
|
195
|
+
}));
|
|
196
|
+
},
|
|
197
|
+
readPage(topicId, pageId) {
|
|
198
|
+
return store.listPages(topicId).find((page) => page.id === pageId) ?? null;
|
|
199
|
+
},
|
|
200
|
+
history(topicId, pageId) {
|
|
201
|
+
if (!store.readPage(topicId, pageId)) return [];
|
|
202
|
+
return db.select().from(wikiRevisions).where(eq(wikiRevisions.pageId, digest(JSON.stringify([topicId, pageId])))).all().map((row) => JSON.parse(row.data)).sort((left, right) => right.revision - left.revision);
|
|
203
|
+
},
|
|
204
|
+
savePage(input, expectedRevision) {
|
|
205
|
+
const page = db.transaction(() => {
|
|
206
|
+
const current = rawPage(input.topicId, input.id);
|
|
207
|
+
if (current?.deleted || (current?.revision ?? 0) !== expectedRevision)
|
|
208
|
+
throw new Error("Wiki revision conflict or deleted page; refresh before editing");
|
|
209
|
+
const topic = store.getTopic(input.topicId);
|
|
210
|
+
if (!topic || topic.deleted) throw new Error("Wiki group unavailable or deleted");
|
|
211
|
+
for (const link of input.links)
|
|
212
|
+
if (!store.readPage(input.topicId, link) || link === input.id)
|
|
213
|
+
throw new Error("Wiki links must reference another current page in this topic");
|
|
214
|
+
const next = {
|
|
215
|
+
...input,
|
|
216
|
+
revision: expectedRevision + 1,
|
|
217
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
218
|
+
deleted: false
|
|
219
|
+
};
|
|
220
|
+
storePage(next);
|
|
221
|
+
if (current) invalidateDependents(input.topicId, input.id, next.updatedAt);
|
|
222
|
+
bumpTopic(input.topicId);
|
|
223
|
+
return next;
|
|
224
|
+
});
|
|
225
|
+
changed(input.topicId);
|
|
226
|
+
return page;
|
|
227
|
+
},
|
|
228
|
+
deletePage(topicId, pageId, expectedRevision, actor, turnRecordId) {
|
|
229
|
+
db.transaction(() => {
|
|
230
|
+
const current = rawPage(topicId, pageId);
|
|
231
|
+
if (!current || current.deleted || current.revision !== expectedRevision)
|
|
232
|
+
throw new Error("Wiki revision conflict; refresh before deleting");
|
|
233
|
+
storePage(tombstone(current, actor, turnRecordId));
|
|
234
|
+
invalidateDependents(topicId, pageId, (/* @__PURE__ */ new Date()).toISOString());
|
|
235
|
+
bumpTopic(topicId);
|
|
236
|
+
});
|
|
237
|
+
changed(topicId);
|
|
238
|
+
},
|
|
239
|
+
deleteTopic(topicId, expectedRevision, actor, turnRecordId) {
|
|
240
|
+
db.transaction(() => {
|
|
241
|
+
const topic = store.getTopic(topicId);
|
|
242
|
+
if (!topic || topic.deleted || topic.revision !== expectedRevision)
|
|
243
|
+
throw new Error("Wiki group revision conflict; refresh before deleting");
|
|
244
|
+
const pages = db.select().from(wikiPages).where(eq(wikiPages.topicId, topicId)).all();
|
|
245
|
+
for (const row of pages) {
|
|
246
|
+
const page = JSON.parse(row.data);
|
|
247
|
+
if (!page.deleted) storePage(tombstone(page, actor, turnRecordId));
|
|
248
|
+
}
|
|
249
|
+
storeTopic({
|
|
250
|
+
...topic,
|
|
251
|
+
deleted: true,
|
|
252
|
+
revision: expectedRevision + 1,
|
|
253
|
+
deletion: { actor, turnRecordId: turnRecordId ?? "", at: (/* @__PURE__ */ new Date()).toISOString() }
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
changed(topicId);
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
return store;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// src/server/tools.ts
|
|
263
|
+
import { stringArg } from "@leitwerk-dev/process-sdk";
|
|
264
|
+
function registerWikiTools(api, wiki) {
|
|
265
|
+
const contentKeys = ["title", "markdown", "applicability", "status", "evidence", "links"];
|
|
266
|
+
const fields = {
|
|
267
|
+
wiki_index: ["query"],
|
|
268
|
+
wiki_read: ["pageId"],
|
|
269
|
+
wiki_share: ["pageId", "expectedRevision", ...contentKeys],
|
|
270
|
+
wiki_edit: ["pageId", "expectedRevision", ...contentKeys],
|
|
271
|
+
wiki_delete: ["pageId", "expectedRevision"],
|
|
272
|
+
wiki_delete_group: ["expectedRevision"]
|
|
273
|
+
};
|
|
274
|
+
for (const name of wikiToolNames) {
|
|
275
|
+
const properties = {
|
|
276
|
+
pageId: {
|
|
277
|
+
type: "string",
|
|
278
|
+
description: "Use an entry ID returned by wiki_index, not the topic ID or an evidence revision. For a new wiki_share page, choose a stable alphanumeric ID with hyphens or underscores."
|
|
279
|
+
},
|
|
280
|
+
query: {
|
|
281
|
+
type: "string",
|
|
282
|
+
description: "Optional case-insensitive literal substring across title, applicability and text. Omit or use an empty string to discover all pages first. Long questions and keyword lists are not semantic search. If a filter returns no pages, retry without it before concluding no guidance exists."
|
|
283
|
+
},
|
|
284
|
+
expectedRevision: {
|
|
285
|
+
type: "integer",
|
|
286
|
+
minimum: name === "wiki_share" ? 0 : 1,
|
|
287
|
+
description: name === "wiki_delete_group" ? "The topic.revision returned by wiki_index, including all entry changes." : "The entry revision returned by wiki_read; 0 is only for new wiki_share pages."
|
|
288
|
+
},
|
|
289
|
+
title: {
|
|
290
|
+
type: "string",
|
|
291
|
+
description: "Name the reusable solution, not this process or its progress."
|
|
292
|
+
},
|
|
293
|
+
markdown: {
|
|
294
|
+
type: "string",
|
|
295
|
+
description: "Explain the new solution, why it works, and limitations. Exclude instructions already in the current ticket or shared source requirement. Failed attempts are supporting evidence only."
|
|
296
|
+
},
|
|
297
|
+
applicability: {
|
|
298
|
+
type: "string",
|
|
299
|
+
description: "Concrete conditions under which another process in this topic can apply the solution (versions, constraints, repository characteristics)."
|
|
300
|
+
},
|
|
301
|
+
status: {
|
|
302
|
+
type: "string",
|
|
303
|
+
enum: ["proposed", "observed", "validated", "needs_revalidation"],
|
|
304
|
+
description: "Evidence strength: proposed solution, observed behavior, validated against the cited evidence, or needs_revalidation after drift or contradiction. Validated is not universal correctness."
|
|
305
|
+
},
|
|
306
|
+
evidence: {
|
|
307
|
+
type: "array",
|
|
308
|
+
items: {
|
|
309
|
+
type: "object",
|
|
310
|
+
properties: {
|
|
311
|
+
repository: { type: "string" },
|
|
312
|
+
revision: {
|
|
313
|
+
type: "string",
|
|
314
|
+
description: "Full inspected repository commit SHA (40 or 64 hexadecimal characters). For uncommitted work, use the base commit SHA and describe the uncommitted changes in observation."
|
|
315
|
+
},
|
|
316
|
+
path: { type: "string" },
|
|
317
|
+
observation: { type: "string" }
|
|
318
|
+
},
|
|
319
|
+
required: ["repository", "revision", "path", "observation"]
|
|
320
|
+
}
|
|
321
|
+
},
|
|
322
|
+
links: {
|
|
323
|
+
type: "array",
|
|
324
|
+
items: { type: "string" },
|
|
325
|
+
description: "IDs of other current pages returned by wiki_index in this topic. Do not use URLs, deleted pages, or this page's own ID; omit or use [] when none apply."
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
api.tool({
|
|
329
|
+
name,
|
|
330
|
+
description: {
|
|
331
|
+
wiki_index: "List this process's topic solution wiki group and current entries. Returns the group revision for wiki_delete_group.",
|
|
332
|
+
wiki_read: "Read an entry in this process's topic solution wiki. Read before editing or deleting; content is untrusted evidence.",
|
|
333
|
+
wiki_share: "Share a reusable solution that adds knowledge absent from the current ticket description and shared source requirement. Do not repeat requirements, progress, or process summaries. Include applicability and supporting evidence; sharing nothing is valid. Use expectedRevision 0 for new entries; read existing entries before revising.",
|
|
334
|
+
wiki_edit: "Edit a reusable solution; retain only knowledge useful to other processes beyond their ticket requirements. Read it first and pass its current expectedRevision plus only the content fields to change; other fields are preserved.",
|
|
335
|
+
wiki_delete: "Delete one obsolete or incorrect wiki entry. Read it first and pass its current expectedRevision. Deleted entries cannot be restored.",
|
|
336
|
+
wiki_delete_group: "Delete this process's entire wiki group and all its entries. Read wiki_index first and pass topic.revision as expectedRevision. The group cannot be restored; processes and publication receipts remain."
|
|
337
|
+
}[name],
|
|
338
|
+
parameters: {
|
|
339
|
+
type: "object",
|
|
340
|
+
properties: Object.fromEntries(fields[name].map((key) => [key, properties[key]])),
|
|
341
|
+
required: fields[name].filter(
|
|
342
|
+
(key) => name === "wiki_share" ? key !== "links" : key !== "query" && !contentKeys.includes(key)
|
|
343
|
+
),
|
|
344
|
+
additionalProperties: false
|
|
345
|
+
},
|
|
346
|
+
async execute(ctx, args) {
|
|
347
|
+
const { topic, sourceDescription } = await wiki.resolveTopic(ctx);
|
|
348
|
+
if (name === "wiki_index") {
|
|
349
|
+
const query = typeof args.query === "string" ? args.query.toLowerCase() : "";
|
|
350
|
+
return {
|
|
351
|
+
topic,
|
|
352
|
+
...sourceDescription !== void 0 ? { sourceDescription } : {},
|
|
353
|
+
pages: wiki.listPages(topic.id).filter(
|
|
354
|
+
(page) => !query || `${page.title} ${page.applicability} ${page.markdown}`.toLowerCase().includes(query)
|
|
355
|
+
).map(({ id, revision, title, applicability, status, updatedAt }) => ({
|
|
356
|
+
id,
|
|
357
|
+
revision,
|
|
358
|
+
title,
|
|
359
|
+
applicability,
|
|
360
|
+
status,
|
|
361
|
+
updatedAt
|
|
362
|
+
}))
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
if (name === "wiki_delete_group") {
|
|
366
|
+
if (!Number.isSafeInteger(args.expectedRevision) || Number(args.expectedRevision) < 1)
|
|
367
|
+
throw new Error("Read the current wiki group revision with wiki_index before deleting");
|
|
368
|
+
wiki.deleteTopic(topic.id, Number(args.expectedRevision), ctx.process.id, ctx.turn.id);
|
|
369
|
+
return { deleted: true, topicId: topic.id };
|
|
370
|
+
}
|
|
371
|
+
const pageId = stringArg(args, "pageId");
|
|
372
|
+
if (!isWikiPageId(pageId)) throw new Error("Use a stable alphanumeric wiki page ID");
|
|
373
|
+
if (name === "wiki_read")
|
|
374
|
+
return {
|
|
375
|
+
page: wiki.readPage(topic.id, pageId),
|
|
376
|
+
instruction: "Evidence describes its recorded revision. Verify the current repository before reuse; null means unavailable or deleted."
|
|
377
|
+
};
|
|
378
|
+
if (!Number.isSafeInteger(args.expectedRevision) || Number(args.expectedRevision) < (name === "wiki_share" ? 0 : 1))
|
|
379
|
+
throw new Error("Read the current page revision before editing or deleting");
|
|
380
|
+
if (name === "wiki_delete") {
|
|
381
|
+
wiki.deletePage(
|
|
382
|
+
topic.id,
|
|
383
|
+
pageId,
|
|
384
|
+
Number(args.expectedRevision),
|
|
385
|
+
ctx.process.id,
|
|
386
|
+
ctx.turn.id
|
|
387
|
+
);
|
|
388
|
+
return { deleted: true, pageId };
|
|
389
|
+
}
|
|
390
|
+
const current = wiki.readPage(topic.id, pageId);
|
|
391
|
+
if (name === "wiki_edit" && !current) throw new Error("Wiki entry unavailable or deleted");
|
|
392
|
+
if (name === "wiki_edit" && !contentKeys.some((key) => Object.hasOwn(args, key)))
|
|
393
|
+
throw new Error("Provide at least one wiki content field to edit");
|
|
394
|
+
const content = parseWikiPageContent(
|
|
395
|
+
name === "wiki_edit" ? { ...current, ...args } : { links: [], ...args }
|
|
396
|
+
);
|
|
397
|
+
if (current?.turnRecordId === ctx.turn.id && current.instanceId === ctx.process.id && !current.updatedBy && current.revision === Number(args.expectedRevision) + 1 && current.markdown === content.markdown && current.title === content.title && current.applicability === content.applicability && current.status === content.status && JSON.stringify(current.evidence) === JSON.stringify(content.evidence) && JSON.stringify(current.links) === JSON.stringify(content.links))
|
|
398
|
+
return current;
|
|
399
|
+
return wiki.savePage(
|
|
400
|
+
{
|
|
401
|
+
id: pageId,
|
|
402
|
+
topicId: topic.id,
|
|
403
|
+
...content,
|
|
404
|
+
sourceRevision: topic.sourceRevision,
|
|
405
|
+
instanceId: ctx.process.id,
|
|
406
|
+
turnRecordId: ctx.turn.id
|
|
407
|
+
},
|
|
408
|
+
Number(args.expectedRevision)
|
|
409
|
+
);
|
|
410
|
+
}
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
export {
|
|
415
|
+
createTopicWikiRepo,
|
|
416
|
+
registerTopicWikiRoutes,
|
|
417
|
+
registerWikiTools,
|
|
418
|
+
wikiPages,
|
|
419
|
+
wikiRevisions,
|
|
420
|
+
wikiTopics
|
|
421
|
+
};
|
|
422
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/server/routes.ts","../../src/server/schema.ts","../../src/server/store.ts","../../src/server/tools.ts"],"sourcesContent":["import { type Actor, asUnknownRecord } from \"@leitwerk-dev/domain\";\nimport type { FastifyInstance, FastifyRequest } from \"fastify\";\nimport { isWikiPageId, parseWikiPageContent } from \"../model.js\";\nimport type { TopicWikiStore } from \"../store.js\";\n\n/** @internal */\nexport function registerTopicWikiRoutes(\n\tapp: FastifyInstance,\n\tstore: TopicWikiStore,\n\tactorForRequest: (request: FastifyRequest) => Actor,\n): void {\n\tapp.get(\"/api/wiki/topics\", async () => ({ topics: store.listTopics() }));\n\tapp.get<{ Params: { topicId: string } }>(\"/api/wiki/topics/:topicId\", async (request, reply) => {\n\t\tconst topic = store.getTopic(request.params.topicId);\n\t\tif (!topic || topic.deleted)\n\t\t\treturn reply.code(404).send({ error: \"Wiki group unavailable or deleted\" });\n\t\treturn { topic, pages: store.listPages(topic.id) };\n\t});\n\tfor (const [suffix, subject, conflict] of [\n\t\t[\"\", \"wiki group\", \"Wiki group deletion conflict\"],\n\t\t[\"/pages/:pageId\", \"page\", \"Wiki deletion conflict\"],\n\t] as const)\n\t\tapp.delete<{\n\t\t\tParams: { topicId: string; pageId?: string };\n\t\t\tQuerystring: { revision?: string };\n\t\t}>(`/api/wiki/topics/:topicId${suffix}`, async (request, reply) => {\n\t\t\tconst revision = Number(request.query.revision);\n\t\t\tif (!Number.isSafeInteger(revision) || revision < 1)\n\t\t\t\treturn reply.code(400).send({ error: `A current ${subject} revision is required` });\n\t\t\ttry {\n\t\t\t\tconst { topicId, pageId } = request.params;\n\t\t\t\tconst actor = actorForRequest(request).id;\n\t\t\t\tif (pageId !== undefined) store.deletePage(topicId, pageId, revision, actor);\n\t\t\t\telse store.deleteTopic(topicId, revision, actor);\n\t\t\t\treturn { deleted: true };\n\t\t\t} catch (error) {\n\t\t\t\treturn reply.code(409).send({ error: error instanceof Error ? error.message : conflict });\n\t\t\t}\n\t\t});\n\tapp.get<{ Params: { topicId: string; pageId: string } }>(\n\t\t\"/api/wiki/topics/:topicId/pages/:pageId/history\",\n\t\tasync (request, reply) => {\n\t\t\tif (!store.readPage(request.params.topicId, request.params.pageId))\n\t\t\t\treturn reply.code(404).send({ error: \"Wiki entry unavailable or deleted\" });\n\t\t\treturn { revisions: store.history(request.params.topicId, request.params.pageId) };\n\t\t},\n\t);\n\tapp.put<{ Params: { topicId: string; pageId: string }; Body: unknown }>(\n\t\t\"/api/wiki/topics/:topicId/pages/:pageId\",\n\t\tasync (request, reply) => {\n\t\t\tconst input = asUnknownRecord(request.body);\n\t\t\tif (\n\t\t\t\t!input ||\n\t\t\t\t!Number.isSafeInteger(input.expectedRevision) ||\n\t\t\t\tNumber(input.expectedRevision) < 1\n\t\t\t)\n\t\t\t\treturn reply.code(400).send({ error: \"A current page revision is required\" });\n\t\t\tif (!isWikiPageId(request.params.pageId))\n\t\t\t\treturn reply.code(400).send({ error: \"Use a stable alphanumeric wiki page ID\" });\n\t\t\tconst current = store.readPage(request.params.topicId, request.params.pageId);\n\t\t\tif (!current) return reply.code(404).send({ error: \"Wiki entry unavailable or deleted\" });\n\t\t\tlet content: ReturnType<typeof parseWikiPageContent>;\n\t\t\ttry {\n\t\t\t\tcontent = parseWikiPageContent(input);\n\t\t\t} catch (error) {\n\t\t\t\treturn reply\n\t\t\t\t\t.code(400)\n\t\t\t\t\t.send({ error: error instanceof Error ? error.message : \"Invalid wiki entry\" });\n\t\t\t}\n\t\t\ttry {\n\t\t\t\treturn {\n\t\t\t\t\tpage: store.savePage(\n\t\t\t\t\t\t{ ...current, ...content, updatedBy: actorForRequest(request) },\n\t\t\t\t\t\tNumber(input.expectedRevision),\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\treturn reply.code(409).send({\n\t\t\t\t\terror:\n\t\t\t\t\t\terror instanceof Error\n\t\t\t\t\t\t\t? error.message\n\t\t\t\t\t\t\t: \"Wiki revision conflict; refresh before editing\",\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t);\n}\n","import { sqliteTable, text } from \"drizzle-orm/sqlite-core\";\n\n/** @internal */\nexport const wikiTopics = sqliteTable(\"wiki_topics\", {\n\t/** @internal */\n\tid: text(\"id\").primaryKey(),\n\t/** @internal */\n\tkey: text(\"key\").notNull(),\n\t/** @internal */\n\tdata: text(\"data\").notNull(),\n});\n\n/** @internal */\nexport const wikiPages = sqliteTable(\"wiki_pages\", {\n\t/** @internal */\n\tid: text(\"id\").primaryKey(),\n\t/** @internal */\n\ttopicId: text(\"topic_id\")\n\t\t.notNull()\n\t\t.references(() => wikiTopics.id),\n\t/** @internal */\n\tdata: text(\"data\").notNull(),\n});\n\n/** @internal */\nexport const wikiRevisions = sqliteTable(\"wiki_revisions\", {\n\t/** @internal */\n\tid: text(\"id\").primaryKey(),\n\t/** @internal */\n\tpageId: text(\"page_id\")\n\t\t.notNull()\n\t\t.references(() => wikiPages.id),\n\t/** @internal */\n\tdata: text(\"data\").notNull(),\n});\n","import { createHash } from \"node:crypto\";\nimport { eq } from \"drizzle-orm\";\nimport type { drizzle } from \"drizzle-orm/node-sqlite\";\nimport type { WikiPage, WikiTopic } from \"../model.js\";\nimport type { TopicWikiStore } from \"../store.js\";\nimport { wikiPages, wikiRevisions, wikiTopics } from \"./schema.js\";\n\nfunction digest(value: string): string {\n\treturn createHash(\"sha256\").update(value).digest(\"hex\");\n}\n\n/** @internal */\nexport function createTopicWikiRepo(\n\tdb: ReturnType<typeof drizzle>,\n\tchanged: (topicId: string) => void = () => {},\n): TopicWikiStore {\n\tfunction rawPage(topicId: string, pageId: string): WikiPage | null {\n\t\tconst row = db\n\t\t\t.select()\n\t\t\t.from(wikiPages)\n\t\t\t.where(eq(wikiPages.id, digest(JSON.stringify([topicId, pageId]))))\n\t\t\t.get();\n\t\treturn row ? JSON.parse(row.data) : null;\n\t}\n\tfunction storePage(page: WikiPage): void {\n\t\tconst id = digest(JSON.stringify([page.topicId, page.id]));\n\t\tconst data = JSON.stringify(page);\n\t\tdb.insert(wikiPages)\n\t\t\t.values({ id, topicId: page.topicId, data })\n\t\t\t.onConflictDoUpdate({ target: wikiPages.id, set: { data } })\n\t\t\t.run();\n\t\tdb.insert(wikiRevisions)\n\t\t\t.values({ id: `${id}:${page.revision}`, pageId: id, data })\n\t\t\t.run();\n\t}\n\tfunction storeTopic(topic: WikiTopic): void {\n\t\tdb.insert(wikiTopics)\n\t\t\t.values({ id: topic.id, key: topic.key, data: JSON.stringify(topic) })\n\t\t\t.onConflictDoUpdate({ target: wikiTopics.id, set: { data: JSON.stringify(topic) } })\n\t\t\t.run();\n\t}\n\tfunction bumpTopic(topicId: string): void {\n\t\tconst topic = store.getTopic(topicId);\n\t\tif (!topic) throw new Error(\"Unknown wiki topic\");\n\t\tstoreTopic({ ...topic, revision: (topic.revision ?? 1) + 1 });\n\t}\n\tfunction tombstone(current: WikiPage, actor: string, turnRecordId = \"\"): WikiPage {\n\t\treturn {\n\t\t\t...current,\n\t\t\tmarkdown: \"\",\n\t\t\tapplicability: \"\",\n\t\t\tevidence: [],\n\t\t\tdeleted: true,\n\t\t\trevision: current.revision + 1,\n\t\t\tupdatedAt: new Date().toISOString(),\n\t\t\tinstanceId: actor,\n\t\t\tturnRecordId,\n\t\t\tupdatedBy: undefined,\n\t\t};\n\t}\n\tfunction invalidateDependents(topicId: string, pageId: string, updatedAt: string): void {\n\t\tfor (const page of store.listPages(topicId))\n\t\t\tif (page.links.includes(pageId))\n\t\t\t\tstorePage({\n\t\t\t\t\t...page,\n\t\t\t\t\tstatus: \"needs_revalidation\",\n\t\t\t\t\trevision: page.revision + 1,\n\t\t\t\t\tupdatedAt,\n\t\t\t\t});\n\t}\n\tconst store: TopicWikiStore = {\n\t\tensureTopic(input) {\n\t\t\tconst id = digest(input.key);\n\t\t\tconst current = store.getTopic(id);\n\t\t\tif (current?.deleted) return current;\n\t\t\tconst topic = { ...input, id, revision: current?.revision ?? 1, deleted: false };\n\t\t\tif (JSON.stringify(current) === JSON.stringify(topic)) return topic;\n\t\t\tif (current) topic.revision++;\n\t\t\tstoreTopic(topic);\n\t\t\tchanged(id);\n\t\t\treturn topic;\n\t\t},\n\t\tgetTopic(id) {\n\t\t\tconst row = db.select().from(wikiTopics).where(eq(wikiTopics.id, id)).get();\n\t\t\tif (!row) return null;\n\t\t\tconst topic = JSON.parse(row.data) as WikiTopic;\n\t\t\treturn { ...topic, revision: topic.revision ?? 1, deleted: topic.deleted ?? false };\n\t\t},\n\t\tlistTopics() {\n\t\t\treturn db\n\t\t\t\t.select()\n\t\t\t\t.from(wikiTopics)\n\t\t\t\t.all()\n\t\t\t\t.map((row) => {\n\t\t\t\t\tconst topic = JSON.parse(row.data) as WikiTopic;\n\t\t\t\t\treturn { ...topic, revision: topic.revision ?? 1, deleted: topic.deleted ?? false };\n\t\t\t\t})\n\t\t\t\t.filter((topic) => !topic.deleted);\n\t\t},\n\t\tlistPages(topicId) {\n\t\t\tconst topic = store.getTopic(topicId);\n\t\t\tif (!topic || topic.deleted) return [];\n\t\t\tconst pages = db\n\t\t\t\t.select()\n\t\t\t\t.from(wikiPages)\n\t\t\t\t.where(eq(wikiPages.topicId, topicId))\n\t\t\t\t.all()\n\t\t\t\t.map((row) => JSON.parse(row.data) as WikiPage)\n\t\t\t\t.filter((page) => !page.deleted);\n\t\t\tconst ids = new Set(pages.map((page) => page.id));\n\t\t\tconst stale = new Set(\n\t\t\t\tpages\n\t\t\t\t\t.filter(\n\t\t\t\t\t\t(page) =>\n\t\t\t\t\t\t\tpage.sourceRevision !== topic?.sourceRevision ||\n\t\t\t\t\t\t\tpage.status === \"needs_revalidation\" ||\n\t\t\t\t\t\t\tpage.links.some((link) => !ids.has(link)),\n\t\t\t\t\t)\n\t\t\t\t\t.map((page) => page.id),\n\t\t\t);\n\t\t\tlet previousSize = -1;\n\t\t\twhile (previousSize !== stale.size) {\n\t\t\t\tpreviousSize = stale.size;\n\t\t\t\tfor (const page of pages)\n\t\t\t\t\tif (page.links.some((link) => stale.has(link))) stale.add(page.id);\n\t\t\t}\n\t\t\treturn pages.map((page) => ({\n\t\t\t\t...page,\n\t\t\t\tstatus: stale.has(page.id) ? \"needs_revalidation\" : page.status,\n\t\t\t}));\n\t\t},\n\t\treadPage(topicId, pageId) {\n\t\t\treturn store.listPages(topicId).find((page) => page.id === pageId) ?? null;\n\t\t},\n\t\thistory(topicId, pageId) {\n\t\t\tif (!store.readPage(topicId, pageId)) return [];\n\t\t\treturn db\n\t\t\t\t.select()\n\t\t\t\t.from(wikiRevisions)\n\t\t\t\t.where(eq(wikiRevisions.pageId, digest(JSON.stringify([topicId, pageId]))))\n\t\t\t\t.all()\n\t\t\t\t.map((row) => JSON.parse(row.data) as WikiPage)\n\t\t\t\t.sort((left, right) => right.revision - left.revision);\n\t\t},\n\t\tsavePage(input, expectedRevision) {\n\t\t\tconst page = db.transaction(() => {\n\t\t\t\tconst current = rawPage(input.topicId, input.id);\n\t\t\t\tif (current?.deleted || (current?.revision ?? 0) !== expectedRevision)\n\t\t\t\t\tthrow new Error(\"Wiki revision conflict or deleted page; refresh before editing\");\n\t\t\t\tconst topic = store.getTopic(input.topicId);\n\t\t\t\tif (!topic || topic.deleted) throw new Error(\"Wiki group unavailable or deleted\");\n\t\t\t\tfor (const link of input.links)\n\t\t\t\t\tif (!store.readPage(input.topicId, link) || link === input.id)\n\t\t\t\t\t\tthrow new Error(\"Wiki links must reference another current page in this topic\");\n\t\t\t\tconst next: WikiPage = {\n\t\t\t\t\t...input,\n\t\t\t\t\trevision: expectedRevision + 1,\n\t\t\t\t\tupdatedAt: new Date().toISOString(),\n\t\t\t\t\tdeleted: false,\n\t\t\t\t};\n\t\t\t\tstorePage(next);\n\t\t\t\tif (current) invalidateDependents(input.topicId, input.id, next.updatedAt);\n\t\t\t\tbumpTopic(input.topicId);\n\t\t\t\treturn next;\n\t\t\t});\n\t\t\tchanged(input.topicId);\n\t\t\treturn page;\n\t\t},\n\t\tdeletePage(topicId, pageId, expectedRevision, actor, turnRecordId) {\n\t\t\tdb.transaction(() => {\n\t\t\t\tconst current = rawPage(topicId, pageId);\n\t\t\t\tif (!current || current.deleted || current.revision !== expectedRevision)\n\t\t\t\t\tthrow new Error(\"Wiki revision conflict; refresh before deleting\");\n\t\t\t\tstorePage(tombstone(current, actor, turnRecordId));\n\t\t\t\tinvalidateDependents(topicId, pageId, new Date().toISOString());\n\t\t\t\tbumpTopic(topicId);\n\t\t\t});\n\t\t\tchanged(topicId);\n\t\t},\n\t\tdeleteTopic(topicId, expectedRevision, actor, turnRecordId) {\n\t\t\tdb.transaction(() => {\n\t\t\t\tconst topic = store.getTopic(topicId);\n\t\t\t\tif (!topic || topic.deleted || topic.revision !== expectedRevision)\n\t\t\t\t\tthrow new Error(\"Wiki group revision conflict; refresh before deleting\");\n\t\t\t\tconst pages = db.select().from(wikiPages).where(eq(wikiPages.topicId, topicId)).all();\n\t\t\t\tfor (const row of pages) {\n\t\t\t\t\tconst page = JSON.parse(row.data) as WikiPage;\n\t\t\t\t\tif (!page.deleted) storePage(tombstone(page, actor, turnRecordId));\n\t\t\t\t}\n\t\t\t\tstoreTopic({\n\t\t\t\t\t...topic,\n\t\t\t\t\tdeleted: true,\n\t\t\t\t\trevision: expectedRevision + 1,\n\t\t\t\t\tdeletion: { actor, turnRecordId: turnRecordId ?? \"\", at: new Date().toISOString() },\n\t\t\t\t});\n\t\t\t});\n\t\t\tchanged(topicId);\n\t\t},\n\t};\n\treturn store;\n}\n","import { type ServerExtensionAPI, stringArg } from \"@leitwerk-dev/process-sdk\";\nimport { wikiToolNames } from \"../instructions.js\";\nimport type { WikiIntegration } from \"../integration.js\";\nimport { isWikiPageId, parseWikiPageContent } from \"../model.js\";\n\n/** Register once on the host; each turn still authorizes its tools explicitly. @internal */\nexport function registerWikiTools(\n\tapi: Pick<ServerExtensionAPI, \"tool\">,\n\twiki: WikiIntegration,\n): void {\n\tconst contentKeys = [\"title\", \"markdown\", \"applicability\", \"status\", \"evidence\", \"links\"];\n\tconst fields = {\n\t\twiki_index: [\"query\"],\n\t\twiki_read: [\"pageId\"],\n\t\twiki_share: [\"pageId\", \"expectedRevision\", ...contentKeys],\n\t\twiki_edit: [\"pageId\", \"expectedRevision\", ...contentKeys],\n\t\twiki_delete: [\"pageId\", \"expectedRevision\"],\n\t\twiki_delete_group: [\"expectedRevision\"],\n\t};\n\tfor (const name of wikiToolNames) {\n\t\tconst properties: Record<string, unknown> = {\n\t\t\tpageId: {\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription:\n\t\t\t\t\t\"Use an entry ID returned by wiki_index, not the topic ID or an evidence revision. For a new wiki_share page, choose a stable alphanumeric ID with hyphens or underscores.\",\n\t\t\t},\n\t\t\tquery: {\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription:\n\t\t\t\t\t\"Optional case-insensitive literal substring across title, applicability and text. Omit or use an empty string to discover all pages first. Long questions and keyword lists are not semantic search. If a filter returns no pages, retry without it before concluding no guidance exists.\",\n\t\t\t},\n\t\t\texpectedRevision: {\n\t\t\t\ttype: \"integer\",\n\t\t\t\tminimum: name === \"wiki_share\" ? 0 : 1,\n\t\t\t\tdescription:\n\t\t\t\t\tname === \"wiki_delete_group\"\n\t\t\t\t\t\t? \"The topic.revision returned by wiki_index, including all entry changes.\"\n\t\t\t\t\t\t: \"The entry revision returned by wiki_read; 0 is only for new wiki_share pages.\",\n\t\t\t},\n\t\t\ttitle: {\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: \"Name the reusable solution, not this process or its progress.\",\n\t\t\t},\n\t\t\tmarkdown: {\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription:\n\t\t\t\t\t\"Explain the new solution, why it works, and limitations. Exclude instructions already in the current ticket or shared source requirement. Failed attempts are supporting evidence only.\",\n\t\t\t},\n\t\t\tapplicability: {\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription:\n\t\t\t\t\t\"Concrete conditions under which another process in this topic can apply the solution (versions, constraints, repository characteristics).\",\n\t\t\t},\n\t\t\tstatus: {\n\t\t\t\ttype: \"string\",\n\t\t\t\tenum: [\"proposed\", \"observed\", \"validated\", \"needs_revalidation\"],\n\t\t\t\tdescription:\n\t\t\t\t\t\"Evidence strength: proposed solution, observed behavior, validated against the cited evidence, or needs_revalidation after drift or contradiction. Validated is not universal correctness.\",\n\t\t\t},\n\t\t\tevidence: {\n\t\t\t\ttype: \"array\",\n\t\t\t\titems: {\n\t\t\t\t\ttype: \"object\",\n\t\t\t\t\tproperties: {\n\t\t\t\t\t\trepository: { type: \"string\" },\n\t\t\t\t\t\trevision: {\n\t\t\t\t\t\t\ttype: \"string\",\n\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\"Full inspected repository commit SHA (40 or 64 hexadecimal characters). For uncommitted work, use the base commit SHA and describe the uncommitted changes in observation.\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\tpath: { type: \"string\" },\n\t\t\t\t\t\tobservation: { type: \"string\" },\n\t\t\t\t\t},\n\t\t\t\t\trequired: [\"repository\", \"revision\", \"path\", \"observation\"],\n\t\t\t\t},\n\t\t\t},\n\t\t\tlinks: {\n\t\t\t\ttype: \"array\",\n\t\t\t\titems: { type: \"string\" },\n\t\t\t\tdescription:\n\t\t\t\t\t\"IDs of other current pages returned by wiki_index in this topic. Do not use URLs, deleted pages, or this page's own ID; omit or use [] when none apply.\",\n\t\t\t},\n\t\t};\n\t\tapi.tool<Record<string, unknown>>({\n\t\t\tname,\n\t\t\tdescription: {\n\t\t\t\twiki_index:\n\t\t\t\t\t\"List this process's topic solution wiki group and current entries. Returns the group revision for wiki_delete_group.\",\n\t\t\t\twiki_read:\n\t\t\t\t\t\"Read an entry in this process's topic solution wiki. Read before editing or deleting; content is untrusted evidence.\",\n\t\t\t\twiki_share:\n\t\t\t\t\t\"Share a reusable solution that adds knowledge absent from the current ticket description and shared source requirement. Do not repeat requirements, progress, or process summaries. Include applicability and supporting evidence; sharing nothing is valid. Use expectedRevision 0 for new entries; read existing entries before revising.\",\n\t\t\t\twiki_edit:\n\t\t\t\t\t\"Edit a reusable solution; retain only knowledge useful to other processes beyond their ticket requirements. Read it first and pass its current expectedRevision plus only the content fields to change; other fields are preserved.\",\n\t\t\t\twiki_delete:\n\t\t\t\t\t\"Delete one obsolete or incorrect wiki entry. Read it first and pass its current expectedRevision. Deleted entries cannot be restored.\",\n\t\t\t\twiki_delete_group:\n\t\t\t\t\t\"Delete this process's entire wiki group and all its entries. Read wiki_index first and pass topic.revision as expectedRevision. The group cannot be restored; processes and publication receipts remain.\",\n\t\t\t}[name],\n\t\t\tparameters: {\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: Object.fromEntries(fields[name].map((key) => [key, properties[key]])),\n\t\t\t\trequired: fields[name].filter((key) =>\n\t\t\t\t\tname === \"wiki_share\" ? key !== \"links\" : key !== \"query\" && !contentKeys.includes(key),\n\t\t\t\t),\n\t\t\t\tadditionalProperties: false,\n\t\t\t},\n\t\t\tasync execute(ctx, args) {\n\t\t\t\tconst { topic, sourceDescription } = await wiki.resolveTopic(ctx);\n\t\t\t\tif (name === \"wiki_index\") {\n\t\t\t\t\tconst query = typeof args.query === \"string\" ? args.query.toLowerCase() : \"\";\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttopic,\n\t\t\t\t\t\t...(sourceDescription !== undefined ? { sourceDescription } : {}),\n\t\t\t\t\t\tpages: wiki\n\t\t\t\t\t\t\t.listPages(topic.id)\n\t\t\t\t\t\t\t.filter(\n\t\t\t\t\t\t\t\t(page) =>\n\t\t\t\t\t\t\t\t\t!query ||\n\t\t\t\t\t\t\t\t\t`${page.title} ${page.applicability} ${page.markdown}`\n\t\t\t\t\t\t\t\t\t\t.toLowerCase()\n\t\t\t\t\t\t\t\t\t\t.includes(query),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t.map(({ id, revision, title, applicability, status, updatedAt }) => ({\n\t\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t\trevision,\n\t\t\t\t\t\t\t\ttitle,\n\t\t\t\t\t\t\t\tapplicability,\n\t\t\t\t\t\t\t\tstatus,\n\t\t\t\t\t\t\t\tupdatedAt,\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tif (name === \"wiki_delete_group\") {\n\t\t\t\t\tif (!Number.isSafeInteger(args.expectedRevision) || Number(args.expectedRevision) < 1)\n\t\t\t\t\t\tthrow new Error(\"Read the current wiki group revision with wiki_index before deleting\");\n\t\t\t\t\twiki.deleteTopic(topic.id, Number(args.expectedRevision), ctx.process.id, ctx.turn.id);\n\t\t\t\t\treturn { deleted: true, topicId: topic.id };\n\t\t\t\t}\n\t\t\t\tconst pageId = stringArg(args, \"pageId\");\n\t\t\t\tif (!isWikiPageId(pageId)) throw new Error(\"Use a stable alphanumeric wiki page ID\");\n\t\t\t\tif (name === \"wiki_read\")\n\t\t\t\t\treturn {\n\t\t\t\t\t\tpage: wiki.readPage(topic.id, pageId),\n\t\t\t\t\t\tinstruction:\n\t\t\t\t\t\t\t\"Evidence describes its recorded revision. Verify the current repository before reuse; null means unavailable or deleted.\",\n\t\t\t\t\t};\n\t\t\t\tif (\n\t\t\t\t\t!Number.isSafeInteger(args.expectedRevision) ||\n\t\t\t\t\tNumber(args.expectedRevision) < (name === \"wiki_share\" ? 0 : 1)\n\t\t\t\t)\n\t\t\t\t\tthrow new Error(\"Read the current page revision before editing or deleting\");\n\t\t\t\tif (name === \"wiki_delete\") {\n\t\t\t\t\twiki.deletePage(\n\t\t\t\t\t\ttopic.id,\n\t\t\t\t\t\tpageId,\n\t\t\t\t\t\tNumber(args.expectedRevision),\n\t\t\t\t\t\tctx.process.id,\n\t\t\t\t\t\tctx.turn.id,\n\t\t\t\t\t);\n\t\t\t\t\treturn { deleted: true, pageId };\n\t\t\t\t}\n\t\t\t\tconst current = wiki.readPage(topic.id, pageId);\n\t\t\t\tif (name === \"wiki_edit\" && !current) throw new Error(\"Wiki entry unavailable or deleted\");\n\t\t\t\tif (name === \"wiki_edit\" && !contentKeys.some((key) => Object.hasOwn(args, key)))\n\t\t\t\t\tthrow new Error(\"Provide at least one wiki content field to edit\");\n\t\t\t\tconst content = parseWikiPageContent(\n\t\t\t\t\tname === \"wiki_edit\" ? { ...current, ...args } : { links: [], ...args },\n\t\t\t\t);\n\t\t\t\tif (\n\t\t\t\t\tcurrent?.turnRecordId === ctx.turn.id &&\n\t\t\t\t\tcurrent.instanceId === ctx.process.id &&\n\t\t\t\t\t!current.updatedBy &&\n\t\t\t\t\tcurrent.revision === Number(args.expectedRevision) + 1 &&\n\t\t\t\t\tcurrent.markdown === content.markdown &&\n\t\t\t\t\tcurrent.title === content.title &&\n\t\t\t\t\tcurrent.applicability === content.applicability &&\n\t\t\t\t\tcurrent.status === content.status &&\n\t\t\t\t\tJSON.stringify(current.evidence) === JSON.stringify(content.evidence) &&\n\t\t\t\t\tJSON.stringify(current.links) === JSON.stringify(content.links)\n\t\t\t\t)\n\t\t\t\t\treturn current;\n\t\t\t\treturn wiki.savePage(\n\t\t\t\t\t{\n\t\t\t\t\t\tid: pageId,\n\t\t\t\t\t\ttopicId: topic.id,\n\t\t\t\t\t\t...content,\n\t\t\t\t\t\tsourceRevision: topic.sourceRevision,\n\t\t\t\t\t\tinstanceId: ctx.process.id,\n\t\t\t\t\t\tturnRecordId: ctx.turn.id,\n\t\t\t\t\t},\n\t\t\t\t\tNumber(args.expectedRevision),\n\t\t\t\t);\n\t\t\t},\n\t\t});\n\t}\n}\n"],"mappings":";;;;;;;AAAA,SAAqB,uBAAuB;AAMrC,SAAS,wBACf,KACA,OACA,iBACO;AACP,MAAI,IAAI,oBAAoB,aAAa,EAAE,QAAQ,MAAM,WAAW,EAAE,EAAE;AACxE,MAAI,IAAqC,6BAA6B,OAAO,SAAS,UAAU;AAC/F,UAAM,QAAQ,MAAM,SAAS,QAAQ,OAAO,OAAO;AACnD,QAAI,CAAC,SAAS,MAAM;AACnB,aAAO,MAAM,KAAK,GAAG,EAAE,KAAK,EAAE,OAAO,oCAAoC,CAAC;AAC3E,WAAO,EAAE,OAAO,OAAO,MAAM,UAAU,MAAM,EAAE,EAAE;AAAA,EAClD,CAAC;AACD,aAAW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ClE,cAAM,UAAU;AAAA,UACf,SAAS,cAAc,EAAE,GAAG,SAAS,GAAG,KAAK,IAAI,EAAE,OAAO,CAAC,GAAG,GAAG,KAAK;AAAA,QACvE;AACA,YACC,SAAS,iBAAiB,IAAI,KAAK,MACnC,QAAQ,eAAe,IAAI,QAAQ,MACnC,CAAC,QAAQ,aACT,QAAQ,aAAa,OAAO,KAAK,gBAAgB,IAAI,KACrD,QAAQ,aAAa,QAAQ,YAC7B,QAAQ,UAAU,QAAQ,SAC1B,QAAQ,kBAAkB,QAAQ,iBAClC,QAAQ,WAAW,QAAQ,UAC3B,KAAK,UAAU,QAAQ,QAAQ,MAAM,KAAK,UAAU,QAAQ,QAAQ,KACpE,KAAK,UAAU,QAAQ,KAAK,MAAM,KAAK,UAAU,QAAQ,KAAK;AAE9D,iBAAO;AACR,eAAO,KAAK;AAAA,UACX;AAAA,YACC,IAAI;AAAA,YACJ,SAAS,MAAM;AAAA,YACf,GAAG;AAAA,YACH,gBAAgB,MAAM;AAAA,YACtB,YAAY,IAAI,QAAQ;AAAA,YACxB,cAAc,IAAI,KAAK;AAAA,UACxB;AAAA,UACA,OAAO,KAAK,gBAAgB;AAAA,QAC7B;AAAA,MACD;AAAA,IACD,CAAC;AAAA,EACF;AACD;","names":[]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Actor } from "@leitwerk-dev/domain";
|
|
2
|
+
import type { FastifyInstance, FastifyRequest } from "fastify";
|
|
3
|
+
import type { TopicWikiStore } from "../store.js";
|
|
4
|
+
/** @internal */
|
|
5
|
+
export declare function registerTopicWikiRoutes(app: FastifyInstance, store: TopicWikiStore, actorForRequest: (request: FastifyRequest) => Actor): void;
|
|
6
|
+
//# sourceMappingURL=routes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/server/routes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAmB,MAAM,sBAAsB,CAAC;AACnE,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,gBAAgB;AAChB,wBAAgB,uBAAuB,CACtC,GAAG,EAAE,eAAe,EACpB,KAAK,EAAE,cAAc,EACrB,eAAe,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,KAAK,GACjD,IAAI,CA4EN"}
|