Skip to content

Commit a146a04

Browse files
committed
Point docs loader to static/ and docusaurus/static; fallback to repo root
1 parent 8480c2c commit a146a04

File tree

1 file changed

+47
-15
lines changed
  • docusaurus/scripts/strapi-release-analyzer

1 file changed

+47
-15
lines changed

docusaurus/scripts/strapi-release-analyzer/index.js

Lines changed: 47 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const STRAPI_REPO_NAME = 'strapi';
1515
const DOC_REPO_OWNER = 'strapi';
1616
const DOC_REPO_NAME = 'documentation';
1717
// Default Claude model; override with env CLAUDE_MODEL or --model flag
18-
const CLAUDE_MODEL = process.env.CLAUDE_MODEL || 'claude-3-5-sonnet-latest';
18+
const CLAUDE_MODEL = process.env.CLAUDE_MODEL || 'claude-sonnet-4-5-20250929';
1919

2020
const octokit = new Octokit({
2121
auth: GITHUB_TOKEN,
@@ -50,24 +50,36 @@ const OPTIONS = {
5050
// Minimal loader for llms-full.txt (with graceful fallback to llms.txt)
5151
async function readLlmsFullIndex() {
5252
const repoRoot = process.cwd();
53-
const llmsFullPath = path.join(repoRoot, 'llms-full.txt');
54-
const llmsPath = path.join(repoRoot, 'llms.txt');
53+
const candidatesFull = [
54+
path.join(repoRoot, 'static', 'llms-full.txt'),
55+
path.join(repoRoot, 'docusaurus', 'static', 'llms-full.txt'),
56+
path.join(repoRoot, 'llms-full.txt'),
57+
];
58+
const candidatesLite = [
59+
path.join(repoRoot, 'static', 'llms.txt'),
60+
path.join(repoRoot, 'docusaurus', 'static', 'llms.txt'),
61+
path.join(repoRoot, 'llms.txt'),
62+
];
5563

56-
let text = '';
57-
let source = '';
58-
try {
59-
text = await fs.readFile(llmsFullPath, 'utf8');
60-
source = 'llms-full.txt';
61-
} catch {
62-
try {
63-
text = await fs.readFile(llmsPath, 'utf8');
64-
source = 'llms.txt';
65-
} catch {
66-
console.warn(' ⚠️ No llms-full.txt or llms.txt found at repo root; proceeding without docs index');
67-
return { source: null, pages: [], byTitle: new Map(), byUrl: new Map() };
64+
async function readFirstExisting(paths) {
65+
for (const p of paths) {
66+
try {
67+
const text = await fs.readFile(p, 'utf8');
68+
const rel = path.relative(repoRoot, p) || p;
69+
return { text, source: rel };
70+
} catch {}
6871
}
72+
return null;
6973
}
7074

75+
let loaded = await readFirstExisting(candidatesFull);
76+
if (!loaded) loaded = await readFirstExisting(candidatesLite);
77+
if (!loaded) {
78+
console.warn(' ⚠️ No llms-full.txt or llms.txt found (checked static/ and docusaurus/static); proceeding without docs index');
79+
return { source: null, pages: [], byTitle: new Map(), byUrl: new Map() };
80+
}
81+
const { text, source } = loaded;
82+
7183
const pages = [];
7284
const byTitle = new Map();
7385
const byUrl = new Map();
@@ -351,6 +363,18 @@ async function generateDocSuggestionsWithClaude(prAnalysis) {
351363
? diffSummary.slice(0, 100000) + '\n\n... (diff truncated due to size)'
352364
: diffSummary;
353365

366+
// Build candidate grounding block from llms-full index
367+
const candidates = Array.isArray(prAnalysis._docsCandidates) ? prAnalysis._docsCandidates : [];
368+
const candidatesBlock = candidates.length
369+
? `## Candidate Documentation Pages (from llms-full index)\n\n` +
370+
candidates.map((p, i) => {
371+
const anchors = Array.isArray(p.anchors) && p.anchors.length ? p.anchors.slice(0, 8).join(', ') : '—';
372+
return `- [${i + 1}] Title: ${p.title}\n URL: ${p.url || '(missing)'}\n Anchors: ${anchors}`;
373+
}).join('\n') + '\n\n'
374+
: '';
375+
376+
const signalsBlock = `## Signals\n\n- Heuristic summary: ${prAnalysis._summary || 'N/A'}\n- Heuristic impact: ${(prAnalysis._impact && prAnalysis._impact.verdict) || 'unknown'}${(prAnalysis._impact && prAnalysis._impact.reason) || ''}\n\n`;
377+
354378
const prompt = `You are a technical documentation analyst for Strapi CMS. Your expertise is in identifying documentation gaps and suggesting precise updates.
355379
356380
Analyze this pull request and provide specific, actionable documentation update suggestions.
@@ -365,6 +389,9 @@ Analyze this pull request and provide specific, actionable documentation update
365389
366390
${truncatedDiff}
367391
392+
${signalsBlock}
393+
${candidatesBlock}
394+
368395
## Your Task
369396
370397
**Important**: Strapi documentation structure:
@@ -432,6 +459,11 @@ Respond with a JSON object following this exact structure:
432459
- Minor typo fixes in code comments
433460
- Changes to development tooling
434461
462+
6. **Grounding and targeting**:
463+
- Prefer targets among the "Candidate Documentation Pages" when applicable.
464+
- If you suggest specific locations within a page, include an anchor from the page's anchors list when relevant.
465+
- Keep the response JSON-only (no markdown formatting, no prose outside the JSON).
466+
435467
If no documentation changes are needed, return empty suggestedChanges array with reasoning explaining why.
436468
437469
Respond ONLY with valid JSON, no markdown formatting, no additional text.`;

0 commit comments

Comments
 (0)