mirror of
https://github.com/Kaelio/ktx.git
synced 2026-06-10 08:05:14 +02:00
Return wiki content after edits
This commit is contained in:
parent
6536c5da26
commit
d7a6d78c72
2 changed files with 12 additions and 3 deletions
|
|
@ -127,7 +127,7 @@ describe('WikiWriteTool', () => {
|
|||
baseContext,
|
||||
);
|
||||
|
||||
expect(result.structured).toEqual({ success: true, key: 'orbit-customers', action: 'updated' });
|
||||
expect(result.structured).toMatchObject({ success: true, key: 'orbit-customers', action: 'updated' });
|
||||
expect(wikiService.writePage).toHaveBeenCalledWith(
|
||||
'USER',
|
||||
'u',
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ interface WikiWriteStructured {
|
|||
success: boolean;
|
||||
key: string;
|
||||
action?: 'created' | 'updated';
|
||||
content?: string;
|
||||
}
|
||||
|
||||
function looksLikeEscapedMarkdown(content: string): boolean {
|
||||
|
|
@ -181,9 +182,17 @@ tags/refs/sl_refs use REPLACE semantics: omit to keep existing on update, [] to
|
|||
context.session.actions.push({ target: 'wiki', type: action, key: input.key, detail: input.summary });
|
||||
}
|
||||
|
||||
// When the LLM used `replacements` (edit mode), it doesn't have the
|
||||
// post-edit content cached. Returning the result here prevents the
|
||||
// common bug where a follow-up edit uses an oldText string that no
|
||||
// longer matches because a prior edit already changed the page.
|
||||
const markdown = hasReplacements
|
||||
? `Page "${input.key}" ${action}.\n\nCurrent content (use for subsequent edits):\n\n${finalContent}`
|
||||
: `Page "${input.key}" ${action}.`;
|
||||
|
||||
return {
|
||||
markdown: `Page "${input.key}" ${action}.`,
|
||||
structured: { success: true, key: input.key, action },
|
||||
markdown,
|
||||
structured: { success: true, key: input.key, action, content: finalContent },
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue