diff --git a/packages/action/dist/index.js b/packages/action/dist/index.js index a052b4e..5b6a255 100644 --- a/packages/action/dist/index.js +++ b/packages/action/dist/index.js @@ -204546,6 +204546,16 @@ async function applyCorrectionToRepo(cwd, graph, sectionId, correctedContent) { } // src/comment.ts +async function postStatusComment(octokit, ctx, message) { + await octokit.rest.issues.createComment({ + owner: ctx.owner, + repo: ctx.repo, + issue_number: ctx.prNumber, + body: `## Doc Check Results + +${message}` + }); +} async function postSummaryComment(octokit, ctx, summary2) { const verifiedAccurate = summary2.verdicts.filter((verdict) => !verdict.stale).length; const autoFixed = summary2.fixPr?.appliedSectionIds.length ?? 0; @@ -204678,14 +204688,27 @@ function loadPrContext() { } // src/index.ts +var SUPPORTED_LANGUAGES = "TypeScript, TSX, JavaScript, and Python"; async function run2() { const config = loadConfig(); const ctx = loadPrContext(); const cwd = process.cwd(); const octokit = getOctokit(config.githubToken); const llm = new GeminiClient({ apiKey: config.apiKey }); - info2("docmend: building code-to-docs link graph..."); + info2("docmend: parsing codebase..."); const chunks = await parseCodebase(cwd); + if (chunks.length === 0) { + info2("docmend: no parseable code found in this repository."); + setOutput("stale-sections-found", 0); + setOutput("corrections-generated", 0); + await postStatusComment( + octokit, + ctx, + `No functions, classes, or methods were detected in this repository. docmend currently parses ${SUPPORTED_LANGUAGES}, but doesn't yet recognize every code pattern (e.g. arrow-function-only declarations) - this could mean an unsupported language, or supported code docmend doesn't fully cover yet. Nothing to check.` + ); + return; + } + info2("docmend: building code-to-docs link graph..."); const sections = await parseDocs(cwd); const graph = await buildLinkGraph(chunks, sections, { llm, @@ -204698,6 +204721,7 @@ async function run2() { info2("docmend: no relevant changes in this PR."); setOutput("stale-sections-found", 0); setOutput("corrections-generated", 0); + await postStatusComment(octokit, ctx, "No relevant file changes in this PR. Nothing to check."); return; } const fileChanges = await resolveFileChanges( @@ -204711,6 +204735,8 @@ async function run2() { if (staleVerdicts.length === 0) { info2("docmend: docs look accurate for this PR."); setOutput("corrections-generated", 0); + const message = suspects.length === 0 ? "None of the changed code in this PR is referenced by any documentation section (or is in a language/pattern docmend doesn't recognize yet). Nothing to check." : `${suspects.length} linked documentation section(s) checked - all still accurate, nothing to fix.`; + await postStatusComment(octokit, ctx, message); return; } const repairResults = await repairStaleDocs(suspects, verdicts, llm, { diff --git a/packages/action/src/comment.ts b/packages/action/src/comment.ts index fd0acbd..e6b5895 100644 --- a/packages/action/src/comment.ts +++ b/packages/action/src/comment.ts @@ -11,6 +11,19 @@ export interface CommentSummary { fixPrError?: string; } +export async function postStatusComment( + octokit: InstanceType, + ctx: PrContext, + message: string, +): Promise { + await octokit.rest.issues.createComment({ + owner: ctx.owner, + repo: ctx.repo, + issue_number: ctx.prNumber, + body: `## Doc Check Results\n\n${message}`, + }); +} + export async function postSummaryComment( octokit: InstanceType, ctx: PrContext, diff --git a/packages/action/src/index.ts b/packages/action/src/index.ts index 046c1e8..23d1f50 100644 --- a/packages/action/src/index.ts +++ b/packages/action/src/index.ts @@ -14,11 +14,13 @@ import { repairStaleDocs, resolveFileChanges, } from '@docmend/core'; -import { postSummaryComment } from './comment.js'; +import { postStatusComment, postSummaryComment } from './comment.js'; import { loadConfig } from './config.js'; import { createFixPr } from './fix-pr.js'; import { loadPrContext } from './pr-context.js'; +const SUPPORTED_LANGUAGES = 'TypeScript, TSX, JavaScript, and Python'; + async function run(): Promise { const config = loadConfig(); const ctx = loadPrContext(); @@ -27,8 +29,26 @@ async function run(): Promise { const octokit = getOctokit(config.githubToken); const llm = new GeminiClient({ apiKey: config.apiKey }); - core.info('docmend: building code-to-docs link graph...'); + core.info('docmend: parsing codebase...'); const chunks = await parseCodebase(cwd); + + if (chunks.length === 0) { + // Checked before parseDocs/buildLinkGraph specifically to avoid burning + // an embed() call per doc section (buildEmbeddingLinks still embeds + // every section even with zero chunks to link against) on a run that's + // about to report there's nothing to do anyway. + core.info('docmend: no parseable code found in this repository.'); + core.setOutput('stale-sections-found', 0); + core.setOutput('corrections-generated', 0); + await postStatusComment( + octokit, + ctx, + `No functions, classes, or methods were detected in this repository. docmend currently parses ${SUPPORTED_LANGUAGES}, but doesn't yet recognize every code pattern (e.g. arrow-function-only declarations) - this could mean an unsupported language, or supported code docmend doesn't fully cover yet. Nothing to check.`, + ); + return; + } + + core.info('docmend: building code-to-docs link graph...'); const sections = await parseDocs(cwd); const graph = await buildLinkGraph(chunks, sections, { llm, @@ -43,6 +63,7 @@ async function run(): Promise { core.info('docmend: no relevant changes in this PR.'); core.setOutput('stale-sections-found', 0); core.setOutput('corrections-generated', 0); + await postStatusComment(octokit, ctx, 'No relevant file changes in this PR. Nothing to check.'); return; } @@ -60,6 +81,11 @@ async function run(): Promise { if (staleVerdicts.length === 0) { core.info('docmend: docs look accurate for this PR.'); core.setOutput('corrections-generated', 0); + const message = + suspects.length === 0 + ? 'None of the changed code in this PR is referenced by any documentation section (or is in a language/pattern docmend doesn\'t recognize yet). Nothing to check.' + : `${suspects.length} linked documentation section(s) checked - all still accurate, nothing to fix.`; + await postStatusComment(octokit, ctx, message); return; }