feat: add td diff command for semantic code change analysis#72
Open
feat: add td diff command for semantic code change analysis#72
Conversation
Parses unified git diffs and uses Go AST analysis to identify symbol-level changes (functions/types/methods/imports added/removed/modified). Supports --staged, --ref HEAD~N, --issue (diff since start snapshot), and --json. Fixes correctness bug from v1: new file content is now retrieved from the working tree (non-staged) or git index (staged) instead of always reading from HEAD, which gave wrong results for staged diffs and uncommitted changes. Nightshift-Task: semantic-diff Nightshift-Ref: https://github.com/marcus/nightshift Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
td diffcommand that parses unified git diffs and uses Go AST analysis to identify symbol-level changes (functions, types, methods, imports added/removed/modified)--staged,--ref HEAD~N,--issue(diff since issue start snapshot), and--jsonoutputgit show :pathfor staged) instead of always reading from HEAD, which gave wrong results for staged diffs and uncommitted changesArchitecture
internal/diff/parse.go— unified diff parser:FileDiff,Hunk,Parse()internal/diff/semantic.go— Go AST symbol extraction and comparison:AnalyzeGoFile()internal/diff/summarize.go— orchestrator: reads old/new content, runs AST analysis on.gofiles, file-level categories for non-Gointernal/git/git.go— new helpers:GetDiffContent,GetDiffContentStaged,GetFileAtRef,GetStagedFilecmd/diff.go— cobra command wiring with flagsTest plan
internal/diffunit tests: parser (add/delete/modify/rename/multi-file), AST analysis (functions, types, methods, imports, consts, vars)cmdtests: command registration, flag defaults, parse+summarize integrationgo test ./...passesNightshift-Task: semantic-diff
🤖 Generated with Claude Code
Automated by nightshift