* 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)
| 8642 | * possibly shifted. |
| 8643 | */ |
| 8644 | private renderStaleNodeSection(cg: CodeGraph, node: Node, includeCode: boolean): string { |
| 8645 | const lines: string[] = [ |
| 8646 | `**${node.name}** (${node.kind})`, |
| 8647 | '', |
| 8648 | `**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`, |
| 8649 | ]; |
| 8650 | if (node.signature) { |
| 8651 | lines.push(`**Signature:** \`${node.signature}\``); |
| 8652 | } |
| 8653 | lines.push(''); |
| 8654 | let embedded = false; |
| 8655 | if (includeCode) { |
| 8656 | try { |
| 8657 | const absPath = validatePathWithinRoot(cg.getProjectRoot(), node.filePath); |
| 8658 | if (absPath && existsSync(absPath) && !isConfigLeafNode(node)) { |
| 8659 | const content = readFileSync(absPath, 'utf-8'); |
| 8660 | const body = content.replace(/\n+$/, ''); |
| 8661 | if ( |
| 8662 | body.length <= ToolHandler.STALE_WHOLE_FILE_MAX_CHARS && |
| 8663 | body.split('\n').length <= ToolHandler.STALE_WHOLE_FILE_MAX_LINES |
| 8664 | ) { |
| 8665 | lines.push( |
| 8666 | `> ⚠ \`${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):`, |
| 8667 | '', |
| 8668 | '```' + (node.language || ''), |
| 8669 | numberSourceLines(body, 1), |
| 8670 | '```', |
| 8671 | ); |
| 8672 | embedded = true; |
| 8673 | } |
| 8674 | } |
| 8675 | } catch { |
| 8676 | /* fall through to the notice */ |
| 8677 | } |
| 8678 | } |
| 8679 | if (!embedded) { |
| 8680 | lines.push( |
| 8681 | `> ⚠ \`${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.`, |
| 8682 | ); |
| 8683 | } |
| 8684 | return lines.join('\n') + this.formatTrail(cg, node); |
| 8685 | } |
| 8686 | |
| 8687 | /** |
| 8688 | * Build the "trail" for a symbol: its direct callees (what it calls) and |
no test coverage detected