* 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)
| 4206 | * possibly shifted. |
| 4207 | */ |
| 4208 | private renderStaleNodeSection(cg: CodeGraph, node: Node, includeCode: boolean): string { |
| 4209 | const lines: string[] = [ |
| 4210 | `**${node.name}** (${node.kind})`, |
| 4211 | '', |
| 4212 | `**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`, |
| 4213 | ]; |
| 4214 | if (node.signature) { |
| 4215 | lines.push(`**Signature:** \`${node.signature}\``); |
| 4216 | } |
| 4217 | lines.push(''); |
| 4218 | let embedded = false; |
| 4219 | if (includeCode) { |
| 4220 | try { |
| 4221 | const absPath = validatePathWithinRoot(cg.getProjectRoot(), node.filePath); |
| 4222 | if (absPath && existsSync(absPath) && !isConfigLeafNode(node)) { |
| 4223 | const content = readFileSync(absPath, 'utf-8'); |
| 4224 | const body = content.replace(/\n+$/, ''); |
| 4225 | if ( |
| 4226 | body.length <= ToolHandler.STALE_WHOLE_FILE_MAX_CHARS && |
| 4227 | body.split('\n').length <= ToolHandler.STALE_WHOLE_FILE_MAX_LINES |
| 4228 | ) { |
| 4229 | lines.push( |
| 4230 | `> ⚠ \`${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):`, |
| 4231 | '', |
| 4232 | '```' + (node.language || ''), |
| 4233 | numberSourceLines(body, 1), |
| 4234 | '```', |
| 4235 | ); |
| 4236 | embedded = true; |
| 4237 | } |
| 4238 | } |
| 4239 | } catch { |
| 4240 | /* fall through to the notice */ |
| 4241 | } |
| 4242 | } |
| 4243 | if (!embedded) { |
| 4244 | lines.push( |
| 4245 | `> ⚠ \`${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.`, |
| 4246 | ); |
| 4247 | } |
| 4248 | return lines.join('\n') + this.formatTrail(cg, node); |
| 4249 | } |
| 4250 | |
| 4251 | /** |
| 4252 | * Build the "trail" for a symbol: its direct callees (what it calls) and |
no test coverage detected