Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

fix(open-knowledge): keep create-prompt trailer out of the quoted brief (#2400)

miles-kt-inkeep0086332c0882
diff --git a/.changeset/create-prompt-trailer-own-paragraph.md b/.changeset/create-prompt-trailer-own-paragraph.md
new file mode 100644
index 000000000..2aabfce75
--- /dev/null
+++ b/.changeset/create-prompt-trailer-own-paragraph.md
@@ -0,0 +1,12 @@
+---
+"@inkeep/open-knowledge": patch
+---
+
+The create composer's "Open the OK editor in web view." directive now rides
+its own paragraph. It was appended to the last line of the prompt body, which
+glued it onto the final line of your blockquoted brief (or the last
+`@`-mention), so it read as part of your own quoted words — effectively
+invisible as an instruction to the receiving agent. Bare create prompts (no
+brief, no mentions) keep the same single-line shape as the other handoff
+prompts, and turning `appearance.preview.autoOpen` off still drops the
+directive entirely.
diff --git a/packages/core/src/handoff/prompt-composer.test.ts b/packages/core/src/handoff/prompt-composer.test.ts
index c7af2e3de..20bf929ed 100644
--- a/packages/core/src/handoff/prompt-composer.test.ts
+++ b/packages/core/src/handoff/prompt-composer.test.ts
@@ -262,8 +262,9 @@ test('composeCreatePrompt new-project blockquotes the brief + appends the scaffo
'\n' +
'> a wiki for my D&D campaign\n' +
'\n' +
- 'Scaffold the folders, templates, and AI-readable rules to match, using OpenKnowledge.' +
- ' Open the OK editor in web view.',
+ 'Scaffold the folders, templates, and AI-readable rules to match, using OpenKnowledge.\n' +
+ '\n' +
+ 'Open the OK editor in web view.',
);
});
@@ -287,13 +288,34 @@ test('composeCreatePrompt existing-repo does NOT say "new project" or scaffold f
expect(out).toBe(
"Here's what I'd like to do in this OpenKnowledge project:\n" +
'\n' +
- '> Read through this codebase and draft a technical spec.' +
- ' Open the OK editor in web view.',
+ '> Read through this codebase and draft a technical spec.\n' +
+ '\n' +
+ 'Open the OK editor in web view.',
);
expect(out).not.toContain('new OpenKnowledge project');
expect(out).not.toContain('Scaffold the folders');
});
+test('the autoOpen trailer is never glued into the blockquoted brief or the @-mention block', () => {
+ const cases = [
+ composeCreatePrompt('draft a spec', true, 'existing-repo', []),
+ composeCreatePrompt('draft a spec', true, 'existing-repo', ['src/index.ts']),
+ composeCreatePrompt('a wiki', true, 'new-project', []),
+ composeCreatePrompt('', true, 'new-project', ['notes/structure.md']),
+ ];
+ for (const out of cases) {
+ expect(out.endsWith('\n\nOpen the OK editor in web view.')).toBe(true);
+ for (const line of out.split('\n')) {
+ if (line.startsWith('> ') || line.startsWith('@')) {
+ expect(line).not.toContain('Open the OK editor');
+ }
+ }
+ }
+ expect(composeCreatePrompt('', true, 'existing-repo', [])).toBe(
+ "Let's work on this project using OpenKnowledge. Open the OK editor in web view.",
+ );
+});
+
test('composeCreatePrompt blockquotes every line of a multi-line brief', () => {
expect(
composeCreatePrompt('research notes\nwith weekly reviews', false, 'new-project', []),
diff --git a/packages/core/src/handoff/prompt-composer.ts b/packages/core/src/handoff/prompt-composer.ts
index 7eab9e791..bfa646ae2 100644
--- a/packages/core/src/handoff/prompt-composer.ts
+++ b/packages/core/src/handoff/prompt-composer.ts
@@ -98,7 +98,11 @@ export function composeCreatePrompt(
scenario: CreateScenario,
mentions: readonly string[],
): string {
- const openTrailer = autoOpen ? ' Open the OK editor in web view.' : '';
+ const trailer = autoOpen ? 'Open the OK editor in web view.' : '';
+ const withTrailer = (base: string): string => {
+ if (trailer === '') return base;
+ return base.includes('\n') ? [base, '', trailer].join('\n') : `${base} ${trailer}`;
+ };
const blockquote = (text: string): string =>
text
.split('\n')
@@ -118,7 +122,7 @@ export function composeCreatePrompt(
blockquote(trimmed),
].join('\n');
const base = mentionBlock === '' ? briefPart : [briefPart, '', mentionBlock].join('\n');
- return `${base}${openTrailer}`;
+ return withTrailer(base);
}
const scaffold =
@@ -136,7 +140,7 @@ export function composeCreatePrompt(
'',
scaffold,
].join('\n');
- return `${base}${openTrailer}`;
+ return withTrailer(base);
};
const fittedBrief = fitInstruction(