From 3575dc168fbe24e308d8a16848782dd8e4889721 Mon Sep 17 00:00:00 2001 From: mpstaton Date: Sat, 9 May 2026 16:31:28 -0500 Subject: [PATCH] fix(sources-footer): emit [N] format so cite-wide can convert to hex citations The previous footer used ordered-list style ("1. [Title](URL)"), which cite-wide's LLM citation parser ignores. Cite-wide's REFDEF_NUM_RE expects each line to start with [N] (square-bracketed digit), optionally followed by a colon, then the link. New format per source: [1] [Title](URL) [2] [Title](URL) This matches cite-wide/src/services/llmCitationParserService.ts:91 verbatim, so running cite-wide's "convert numeric citations to hex" command on a file generated by this plugin now picks up the footer references and rewrites them to the project's [^hexId] form. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/services/directoryTemplateService.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/services/directoryTemplateService.ts b/src/services/directoryTemplateService.ts index f60cec1..adb3b1b 100644 --- a/src/services/directoryTemplateService.ts +++ b/src/services/directoryTemplateService.ts @@ -63,12 +63,14 @@ function wrapThinkBlocks(text: string): string { function buildSourcesFooter(sources: PerplexitySource[]): string { if (!sources.length) return ''; + // Format matches cite-wide's REFDEF_NUM_RE (`[N] `) so the + // existing "convert to hex citations" command can process this footer. + // See cite-wide/src/services/llmCitationParserService.ts. const lines = sources.map((s, i) => { const n = i + 1; const title = (typeof s.title === 'string' && s.title) ? s.title : (s.url ?? 'Source'); const url = s.url ?? ''; - const date = (typeof s.date === 'string' && s.date) ? ` (${s.date})` : ''; - return url ? `${n}. [${title}](${url})${date}` : `${n}. ${title}${date}`; + return url ? `[${n.toString()}] [${title}](${url})` : `[${n.toString()}] ${title}`; }); return '\n\n## Sources\n\n' + lines.join('\n') + '\n'; }