* 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)
| 8616 | * possibly shifted. |
| 8617 | */ |
| 8618 | private renderStaleNodeSection(cg: CodeGraph, node: Node, includeCode: boolean): string { |
| 8619 | const lines: string[] = [ |
| 8620 | `**${node.name}** (${node.kind})`, |
| 8621 | '', |
| 8622 | `**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`, |
| 8623 | ]; |
| 8624 | if (node.signature) { |
| 8625 | lines.push(`**Signature:** \`${node.signature}\``); |
| 8626 | } |
| 8627 | lines.push(''); |
| 8628 | let embedded = false; |
| 8629 | if (includeCode) { |
| 8630 | try { |
| 8631 | const absPath = validatePathWithinRoot(cg.getProjectRoot(), node.filePath); |
| 8632 | if (absPath && existsSync(absPath) && !isConfigLeafNode(node)) { |
| 8633 | const content = readFileSync(absPath, 'utf-8'); |
| 8634 | const body = content.replace(/\n+$/, ''); |
| 8635 | if ( |
| 8636 | body.length <= ToolHandler.STALE_WHOLE_FILE_MAX_CHARS && |
| 8637 | body.split('\n').length <= ToolHandler.STALE_WHOLE_FILE_MAX_LINES |
| 8638 | ) { |
| 8639 | lines.push( |
| 8640 | `> ⚠ \`${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):`, |
| 8641 | '', |
| 8642 | '```' + (node.language || ''), |
| 8643 | numberSourceLines(body, 1), |
| 8644 | '```', |
| 8645 | ); |
| 8646 | embedded = true; |
| 8647 | } |
| 8648 | } |
| 8649 | } catch { |
| 8650 | /* fall through to the notice */ |
| 8651 | } |
| 8652 | } |
| 8653 | if (!embedded) { |
| 8654 | lines.push( |
| 8655 | `> ⚠ \`${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.`, |
| 8656 | ); |
| 8657 | } |
| 8658 | return lines.join('\n') + this.formatTrail(cg, node); |
| 8659 | } |
| 8660 | |
| 8661 | /** |
| 8662 | * Build the "trail" for a symbol: its direct callees (what it calls) and |
no test coverage detected