* 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)
| 8928 | * possibly shifted. |
| 8929 | */ |
| 8930 | private renderStaleNodeSection(cg: CodeGraph, node: Node, includeCode: boolean): string { |
| 8931 | const lines: string[] = [ |
| 8932 | `**${node.name}** (${node.kind})`, |
| 8933 | '', |
| 8934 | `**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`, |
| 8935 | ]; |
| 8936 | if (node.signature) { |
| 8937 | lines.push(`**Signature:** \`${node.signature}\``); |
| 8938 | } |
| 8939 | lines.push(''); |
| 8940 | let embedded = false; |
| 8941 | if (includeCode) { |
| 8942 | try { |
| 8943 | const absPath = validatePathWithinRoot(cg.getProjectRoot(), node.filePath); |
| 8944 | if (absPath && existsSync(absPath) && !isConfigLeafNode(node)) { |
| 8945 | const content = readFileSync(absPath, 'utf-8'); |
| 8946 | const body = content.replace(/\n+$/, ''); |
| 8947 | if ( |
| 8948 | body.length <= ToolHandler.STALE_WHOLE_FILE_MAX_CHARS && |
| 8949 | body.split('\n').length <= ToolHandler.STALE_WHOLE_FILE_MAX_LINES |
| 8950 | ) { |
| 8951 | lines.push( |
| 8952 | `> ⚠ \`${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):`, |
| 8953 | '', |
| 8954 | '```' + (node.language || ''), |
| 8955 | numberSourceLines(body, 1), |
| 8956 | '```', |
| 8957 | ); |
| 8958 | embedded = true; |
| 8959 | } |
| 8960 | } |
| 8961 | } catch { |
| 8962 | /* fall through to the notice */ |
| 8963 | } |
| 8964 | } |
| 8965 | if (!embedded) { |
| 8966 | lines.push( |
| 8967 | `> ⚠ \`${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.`, |
| 8968 | ); |
| 8969 | } |
| 8970 | return lines.join('\n') + this.formatTrail(cg, node); |
| 8971 | } |
| 8972 | |
| 8973 | /** |
| 8974 | * Build the "trail" for a symbol: its direct callees (what it calls) and |
no test coverage detected