* codegraph_node render for a symbol whose file changed on disk after the * last index sync (issue #1474). The indexed line range is no longer * trustworthy, so no slice is emitted: a small file gets its full CURRENT * source (Read-parity — sufficiency preserved, the agent still doesn't nee
(cg: CodeGraph, node: Node, includeCode: boolean)
| 8469 | * possibly shifted. |
| 8470 | */ |
| 8471 | private renderStaleNodeSection(cg: CodeGraph, node: Node, includeCode: boolean): string { |
| 8472 | const lines: string[] = [ |
| 8473 | `**${node.name}** (${node.kind})`, |
| 8474 | '', |
| 8475 | `**Location:** ${node.filePath}${node.startLine ? `:${node.startLine}` : ''} — ⚠ as of the last index sync; the file has changed on disk since, so this line may be shifted`, |
| 8476 | ]; |
| 8477 | if (node.signature) { |
| 8478 | lines.push(`**Signature:** \`${node.signature}\``); |
| 8479 | } |
| 8480 | lines.push(''); |
| 8481 | let embedded = false; |
| 8482 | if (includeCode) { |
| 8483 | try { |
| 8484 | const absPath = validatePathWithinRoot(cg.getProjectRoot(), node.filePath); |
| 8485 | if (absPath && existsSync(absPath) && !isConfigLeafNode(node)) { |
| 8486 | const content = readFileSync(absPath, 'utf-8'); |
| 8487 | const body = content.replace(/\n+$/, ''); |
| 8488 | if ( |
| 8489 | body.length <= ToolHandler.STALE_WHOLE_FILE_MAX_CHARS && |
| 8490 | body.split('\n').length <= ToolHandler.STALE_WHOLE_FILE_MAX_LINES |
| 8491 | ) { |
| 8492 | lines.push( |
| 8493 | `> ⚠ \`${node.filePath}\` changed on disk after it was last indexed, so the indexed line range for this symbol may no longer match. Showing the file's full CURRENT source instead (Read-parity — treat it as already Read):`, |
| 8494 | '', |
| 8495 | '```' + (node.language || ''), |
| 8496 | numberSourceLines(body, 1), |
| 8497 | '```', |
| 8498 | ); |
| 8499 | embedded = true; |
| 8500 | } |
| 8501 | } |
| 8502 | } catch { |
| 8503 | /* fall through to the notice */ |
| 8504 | } |
| 8505 | } |
| 8506 | if (!embedded) { |
| 8507 | lines.push( |
| 8508 | `> ⚠ \`${node.filePath}\` changed on disk after it was last indexed — the indexed line range for this symbol no longer reliably matches, so its body is omitted rather than risk showing a different symbol's code. For current content, call codegraph_node with \`file: "${node.filePath}"\` (no symbol; \`offset\`/\`limit\` narrow it like Read), or Read the file. The change is picked up automatically on that project's next index sync.`, |
| 8509 | ); |
| 8510 | } |
| 8511 | return lines.join('\n') + this.formatTrail(cg, node); |
| 8512 | } |
| 8513 | |
| 8514 | /** |
| 8515 | * Build the "trail" for a symbol: its direct callees (what it calls) and |
no test coverage detected