Skip to content

Commit 2ecd8c7

Browse files
tninjaCopilot
andauthored
Feat: Support basic Symbol navigation inside AI coding session (#258)
* Linkify symbols near file links and add navigation * Add helm-gtags fallback for symbol navigation * Add Dired support to context files and tests * Revert "Add Dired support to context files and tests" This reverts commit b205107. * Support explaining multiple marked files in Dired * Linkify Java CamelCase and Python snake_case * Refactor symbol detection and relax file checks * Tighten Java CamelCase detection and tests * Update ai-code-session-link.el Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Add per-pass caching and optimize linkification * Improve nearby symbol scanning for file links * Use fixed 512-char 8-line symbol window * Add clickable session links, image, and tests * update HISTORY --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent a89174f commit 2ecd8c7

File tree

7 files changed

+874
-50
lines changed

7 files changed

+874
-50
lines changed

HISTORY.org

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Release history
33

44
** Main branch change
5+
- Feat: Support basic Symbol navigation inside AI coding session
56
- Feat: Add constraint bundles system with 20 tech stack presets (@rust-stack, @react-stack, etc.)
67
- Feat: Expand constraint catalog with 50+ constraints (testing, safety, error handling, performance, API design, logging)
78
- Feat: Auto-detect constraints from project config files (tsconfig.json, pyproject.toml, Cargo.toml, etc.)

README.org

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ Enable installation of packages from MELPA by adding an entry to package-archive
118118
- `yasnippet`: For snippet support in the prompt file. A library of snippets is included.
119119
- (emacs built-in) abbrev + skeleton is also a good way to expand prompt. [[./etc/prompt_expand_with_abbrev_skeleton.el][example abbrev to solve / iterate leetcode problem with tdd (need to set ai-code-auto-test-type with tdd)]], [[./examples/leetcode][example problem resolved]]
120120
- `projectile`: For project root initialization.
121-
- `helm-gtags`: For tags creation.
121+
- `helm-gtags`: For tags creation and symbol navigation fallback from clickable session symbols.
122122
- `python-pytest`: For running python tests in the TDD workflow.
123123
- `jest`: For running JavaScript / TypeScript tests in the TDD workflow.
124124

@@ -127,7 +127,8 @@ Enable installation of packages from MELPA by adding an entry to package-archive
127127
- *Transient-Driven Hub (`C-c a`)*: One keystroke opens a contextual transient menu that groups every capability (CLI control, code actions, agile workflows, utilities) so you never need to memorize scattered keybindings.
128128
- If the default wide layout does not fit your frame well, set `ai-code-menu-layout` to `two-columns` for a narrower menu with the same commands.
129129
- *AI CLI Session Management*: Start (`a`), resume (`R`), or jump back into (`z`) the active AI CLI buffer, instantly swap backends (`s`), upgrade them (`u`), install backend skills (`S`), edit backend configs (`g`), open backend agent file (`G`), and run prompts against the current file (`|`). It supports multiple sessions per project. The `S` entry is especially useful for installing shared skill packs such as [[https://github.com/obra/superpowers][obra/superpowers]].
130-
- *Clickable Session Links*: In AI session buffers, supported in-repo file references and `http` / `https` URLs are underlined and clickable. File links such as `src/foo.el:42`, `src/foo.el:42:7`, `src/foo.el:L42-L60`, or `src/foo.el#L42-L60` jump directly to the right location, while web links open in your browser. Set `ai-code-session-link-enabled` to `nil` if you want to disable this link rendering.
130+
- *Clickable Session Links*: In AI session buffers, supported in-repo file references, nearby code symbols, and `http` / `https` URLs are underlined and clickable. File links such as `src/foo.el:42`, `src/foo.el:42:7`, `src/foo.el:L42-L60`, or `src/foo.el#L42-L60` jump directly to the right location, nearby symbols such as `setq-local`, `ai-code-session-link-enabled`, or `UserService.processRequest()` trigger code navigation in the associated file, and web links open in your browser. Symbol navigation first tries `xref`, then `helm-gtags` when available, and finally falls back to searching in the opened file buffer. Set `ai-code-session-link-enabled` to `nil` if you want to disable this link rendering.
131+
[[./clickable_link_ai_session.png]]
131132
- *Context-Aware Code Actions*: The menu exposes dedicated entries for changing code (`c`), implementing TODOs (`i`), asking questions (`q`), explaining code (`x`), sending free-form commands (`<SPC>`), and refreshing AI context (`@`). Each command automatically captures the surrounding function, region, or clipboard contents (via `C-u`) to keep prompts precise.
132133
- *Agile Development Workflows*: Use the refactoring navigator (`r`), the guided TDD cycle (`t`), and the pull/review diff helper (`v`) to keep AI-assisted work aligned with agile best practices. Prompt authoring is first-class through quick access to the prompt file (`p`), build/test helper (`b`), and AI-assisted shell/file execution (`!`). In prompt files, send the current block with `C-c C-c`.
133134
- *Productivity & Debugging Utilities*: Initialize project navigation assets (`.`), investigate exceptions (`e`), auto-fix Flycheck issues in scope (`f`), copy or open file paths formatted for prompts (`k`, `o`), generate MCP inspector commands (`m`), capture session notes straight into Org (`n`), and toggle desktop notifications (`N`) to get alerted when AI responses are ready in background sessions.

ai-code-discussion.el

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -268,23 +268,36 @@ into the AI prompt file and optionally sends to AI."
268268
(defun ai-code--explain-dired ()
269269
"Handle explain for Dired buffer."
270270
(let* ((file-at-point (dired-get-filename nil t))
271-
(git-relative-path (when file-at-point
272-
(car (ai-code--get-git-relative-paths (list file-at-point)))))
273-
(files-context-string (when git-relative-path
274-
(concat "\nFiles:\n@" git-relative-path)))
271+
(all-marked (dired-get-marked-files))
272+
(has-marked-files (> (length all-marked) 1))
273+
(context-files (if has-marked-files
274+
all-marked
275+
(when file-at-point
276+
(list file-at-point))))
277+
(git-relative-paths (when context-files
278+
(ai-code--get-git-relative-paths context-files)))
279+
(files-context-string (when git-relative-paths
280+
(concat "\nFiles:\n"
281+
(mapconcat (lambda (path) (concat "@" path))
282+
git-relative-paths
283+
"\n"))))
275284
(file-type (if (and file-at-point (file-directory-p file-at-point))
276-
"directory"
277-
"file"))
278-
(initial-prompt (if git-relative-path
279-
(format "Please explain the %s at path @%s.\n\nProvide a clear explanation of what this %s contains, its purpose, and its role in the project structure.%s"
285+
"directory"
286+
"file"))
287+
(initial-prompt (cond
288+
(has-marked-files
289+
(format "Please explain the selected files or directories.\n\nProvide a clear explanation of what these files or directories contain, their purpose, and their role in the project structure.%s"
290+
(or files-context-string "")))
291+
((car git-relative-paths)
292+
(format "Please explain the %s at path @%s.\n\nProvide a clear explanation of what this %s contains, its purpose, and its role in the project structure.%s"
280293
file-type
281-
git-relative-path
294+
(car git-relative-paths)
282295
file-type
283-
(or files-context-string ""))
284-
"No file or directory found at cursor point."))
285-
(final-prompt (if git-relative-path
286-
(ai-code-read-string "Prompt: " initial-prompt)
287-
initial-prompt)))
296+
(or files-context-string "")))
297+
(t "No file or directory found at cursor point.")))
298+
(final-prompt (if git-relative-paths
299+
(ai-code-read-string "Prompt: " initial-prompt)
300+
initial-prompt)))
288301
(when final-prompt
289302
(ai-code--insert-prompt final-prompt))))
290303

0 commit comments

Comments
 (0)