Conversation
- Default analysis depth is now limited to 1 (direct calls only) to reduce token usage. - Enabled full recursive analysis when the `--verbose` (`-v`) flag is provided. - Fixed a bug in MarkdownExporter where Javadocs were rendered as raw JavaParser object strings by switching to `toText()`. - Updated ContextExtractor to support depth control via `verbose` parameter.
- Update download URLs for install.sh and install.ps1 in README.md - Update download URLs for install.sh and install.ps1 in README.ko.md - Point to the 'develop' branch instead of 'main' for latest script updates
- Rebuild j-focus-1.0.0-all.jar using Gradle - Update EXPECTED_SHA256 in install.sh and install.ps1 to match the latest build - Hash: 64d38039c8731215635e8bc609ff95b9e0bc7c7309fb13361e27a7605cbed923
📝 WalkthroughWalkthroughUpdated installer URLs to the develop branch and adjusted installer SHA256s; refactored the CLI annotation and propagated a verbose flag into context extraction; added a new extractContext overload to toggle shallow vs deep traversal; changed non-verbose JavaDoc export to use clean text. Changes
Sequence DiagramsequenceDiagram
participant User as User/CLI
participant JFocusCli as JFocusCli
participant ContextExtractor as ContextExtractor
participant MarkdownExporter as MarkdownExporter
User->>JFocusCli: run command (may include --verbose)
JFocusCli->>ContextExtractor: extractContext(targetMethod, verbose)
alt verbose = true
ContextExtractor->>ContextExtractor: extractRecursive(target, verbose=true)
Note over ContextExtractor: deep recursion (follow dependencies)
else verbose = false
ContextExtractor->>ContextExtractor: extractRecursive(target, verbose=false)
Note over ContextExtractor: shallow traversal (direct dependencies only)
end
ContextExtractor-->>JFocusCli: ContextResult
JFocusCli->>MarkdownExporter: format ContextResult (pass verbose)
alt verbose = true
MarkdownExporter->>MarkdownExporter: include JavaDoc via toString()
else verbose = false
MarkdownExporter->>MarkdownExporter: include JavaDoc via toText()
end
MarkdownExporter-->>User: output markdown
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly Related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/main/java/com/jher235/jfocus/core/ContextExtractor.java (1)
26-42:⚠️ Potential issue | 🟡 MinorStale and incomplete Javadoc on the two
extractContextoverloads.Two issues:
- Line 27: The no-arg overload's Javadoc still says "recursively", but its default behavior is now shallow (
verbose=false). The description should reflect the shallow-by-default semantics.- Lines 37–42: The new overload's Javadoc documents
@param verbosebut is missing@param targetMethodand@return.📝 Suggested Javadoc fix
- /** - * Extracts the full context for the given target method recursively. - * - * `@param` targetMethod The method to analyze - * `@return` Categorized context (target + internal + external + fields) - */ - // Backward-compatible default: non-verbose (shallow) + /** + * Extracts the shallow context for the given target method (direct calls only). + * Equivalent to {`@code` extractContext(targetMethod, false)}. + * + * `@param` targetMethod The method to analyze + * `@return` Categorized context (target + internal + external + fields) + */ public ContextResult extractContext(MethodDeclaration targetMethod) { return extractContext(targetMethod, false); } - /** - * `@param` verbose if true, recursively traverses internal methods to collect - * their external calls as well (deep mode). - * if false, only collects direct (1-depth) calls of the target - * method (shallow mode). - */ + /** + * Extracts the context for the given target method. + * + * `@param` targetMethod The method to analyze + * `@param` verbose if true, recursively traverses all dependencies (deep mode); + * if false, only collects direct (1-depth) calls (shallow mode). + * `@return` Categorized context (target + internal + external + fields) + */ public ContextResult extractContext(MethodDeclaration targetMethod, boolean verbose) {🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/main/java/com/jher235/jfocus/core/ContextExtractor.java` around lines 26 - 42, Update the Javadoc for both extractContext overloads: for extractContext(MethodDeclaration) change the description to state it returns a shallow (non-recursive) context by default and remove the word "recursively"; for extractContext(MethodDeclaration, boolean) add missing `@param` targetMethod and `@return` tags and clarify `@param` verbose semantics (true = deep/recursive traversal collecting internal methods' external calls, false = shallow/1-depth direct calls only). Ensure the method signatures referenced (extractContext(MethodDeclaration) and extractContext(MethodDeclaration, boolean)) are mentioned in the comments so the docs accurately reflect behavior.scripts/install.ps1 (1)
1-5:⚠️ Potential issue | 🟡 MinorConsider adding a UTF-8 BOM for cross-environment safety.
PSScriptAnalyzer reports
PSUseBOMForUnicodeEncodedFilebecause the file contains non-ASCII characters (emojis). Whileiwr ... | iexworks on modern PowerShell (5.1+/7+), saving this script locally and executing it in older or non-default console configurations can result in garbled emoji output. Adding a UTF-8 BOM ensures the encoding is unambiguous across all execution contexts.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@scripts/install.ps1` around lines 1 - 5, The script contains non-ASCII characters (emojis) and triggers PSUseBOMForUnicodeEncodedFile; update the install script header (the top of the file where $ErrorActionPreference is set) to be saved as UTF-8 with a BOM so PowerShell reliably recognizes the encoding across environments—re-save the file as "UTF-8 with BOM" (or configure the repository CI/editor to write a BOM for this file) so the emojis and output are not garbled when executed on older/non-default consoles.
🧹 Nitpick comments (1)
src/main/java/com/jher235/jfocus/core/ContextExtractor.java (1)
53-54: Optional: replaceshallow = !verboseinversion with directverbosethreading.The
!verbosenegation at the call site and the inverse semantics ofshallowinextractRecursivecreate a mental context-switch. Renamingshallowtoverboseand flipping the guard condition would make the two methods read consistently.♻️ Proposed optional refactor
- // shallow = !verbose: in shallow mode, stop recursing after the first level - extractRecursive(targetMethod, targetMethod, result, visited, !verbose); + extractRecursive(targetMethod, targetMethod, result, visited, verbose);- private void extractRecursive(MethodDeclaration rootTarget, - MethodDeclaration currentMethod, - ContextResult result, - Set<String> visited, - boolean shallow) { + private void extractRecursive(MethodDeclaration rootTarget, + MethodDeclaration currentMethod, + ContextResult result, + Set<String> visited, + boolean verbose) { ... - // In shallow mode, do not recurse further beyond the first level - if (!shallow) { - extractRecursive(rootTarget, dep, result, visited, shallow); - } + // In verbose (deep) mode, continue recursion beyond the first level + if (verbose) { + extractRecursive(rootTarget, dep, result, visited, verbose); + }Also applies to: 68-72, 99-102
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/main/java/com/jher235/jfocus/core/ContextExtractor.java` around lines 53 - 54, The code passes !verbose into extractRecursive as the shallow flag which inverts semantics and forces cognitive flips; rename the extractRecursive parameter from shallow to verbose (or add an overload) and invert its internal guard so the parameter now means "verbose", then update all call sites (including the calls from ContextExtractor that currently pass !verbose at the lines around the existing extractRecursive invocation(s)) to pass verbose directly; ensure you update the parameter name in the method signature (extractRecursive) and any internal checks that used shallow to use the new verbose meaning so logic remains equivalent but more readable.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@README.ko.md`:
- Line 142: The README curl line currently references the unstable 'develop'
branch ("curl -sL
https://raw.githubusercontent.com/jher235/j-focus/develop/scripts/install.sh |
bash"); update this to point to a stable branch or tag (for example replace
'develop' with 'main' or a specific release tag) and make the same change for
the other occurrence noted (same command at the other line). Ensure both
README.ko.md and README.md use the identical stable branch/tag string so the
install command is consistent across both files.
In `@README.md`:
- Line 142: The README uses a one-liner that curls the install script from the
mutable "develop" branch which is unsafe; update the two occurrences of the curl
command string ("curl -sL
https://raw.githubusercontent.com/jher235/j-focus/develop/scripts/install.sh |
bash") to reference an immutable ref such as the v1.0.0 tag
(https://raw.githubusercontent.com/jher235/j-focus/v1.0.0/scripts/install.sh) or
the stable main branch, and document the chosen immutable ref in the README so
users run a pinned, auditable installer.
---
Outside diff comments:
In `@scripts/install.ps1`:
- Around line 1-5: The script contains non-ASCII characters (emojis) and
triggers PSUseBOMForUnicodeEncodedFile; update the install script header (the
top of the file where $ErrorActionPreference is set) to be saved as UTF-8 with a
BOM so PowerShell reliably recognizes the encoding across environments—re-save
the file as "UTF-8 with BOM" (or configure the repository CI/editor to write a
BOM for this file) so the emojis and output are not garbled when executed on
older/non-default consoles.
In `@src/main/java/com/jher235/jfocus/core/ContextExtractor.java`:
- Around line 26-42: Update the Javadoc for both extractContext overloads: for
extractContext(MethodDeclaration) change the description to state it returns a
shallow (non-recursive) context by default and remove the word "recursively";
for extractContext(MethodDeclaration, boolean) add missing `@param` targetMethod
and `@return` tags and clarify `@param` verbose semantics (true = deep/recursive
traversal collecting internal methods' external calls, false = shallow/1-depth
direct calls only). Ensure the method signatures referenced
(extractContext(MethodDeclaration) and extractContext(MethodDeclaration,
boolean)) are mentioned in the comments so the docs accurately reflect behavior.
---
Nitpick comments:
In `@src/main/java/com/jher235/jfocus/core/ContextExtractor.java`:
- Around line 53-54: The code passes !verbose into extractRecursive as the
shallow flag which inverts semantics and forces cognitive flips; rename the
extractRecursive parameter from shallow to verbose (or add an overload) and
invert its internal guard so the parameter now means "verbose", then update all
call sites (including the calls from ContextExtractor that currently pass
!verbose at the lines around the existing extractRecursive invocation(s)) to
pass verbose directly; ensure you update the parameter name in the method
signature (extractRecursive) and any internal checks that used shallow to use
the new verbose meaning so logic remains equivalent but more readable.
ℹ️ Review info
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
README.ko.mdREADME.mdscripts/install.ps1scripts/install.shsrc/main/java/com/jher235/jfocus/cli/JFocusCli.javasrc/main/java/com/jher235/jfocus/core/ContextExtractor.javasrc/main/java/com/jher235/jfocus/core/MarkdownExporter.java
There was a problem hiding this comment.
> [!CAUTION]
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)scripts/install.ps1 (1)
1-70:⚠️ Potential issue | 🟡 MinorPSScriptAnalyzer: add UTF-8 BOM to prevent emoji corruption on Windows PowerShell 5.x.
The file uses emoji characters (🚀, 📂, ⬇️, etc.) throughout
Write-Hostcalls. Without a UTF-8 BOM, Windows PowerShell 5.x may misinterpret the multi-byte sequences, garbling or breaking the output. PowerShell 7+ handles BOM-less UTF-8 correctly, but the install audience is likely broad.Save the file as UTF-8 with BOM (e.g.,
UTF-8-BOMin VS Code, orOut-File -Encoding utf8BOMin PowerShell).🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@scripts/install.ps1` around lines 1 - 70, The script contains emoji in several Write-Host calls (e.g., the "🚀 Starting J-Focus installation..." and other Write-Host lines) which can be garbled on Windows PowerShell 5.x if the file has no BOM; fix by saving scripts/install.ps1 with UTF-8 BOM encoding (use your editor's "UTF-8 with BOM" option or re-save the file using PowerShell's UTF-8-BOM save option) so $ErrorActionPreference and all Write-Host output render correctly across PowerShell versions.
🧹 Nitpick comments (1)
scripts/install.ps1 (1)
30-30: Prefer enabling TLS 1.2 and 1.3 rather than locking to TLS 1.2 only.Pinning to
Tls12exclusively preventsInvoke-WebRequestfrom negotiating TLS 1.3 even when both the client and GitHub's servers support it. The original intent was to work around .NET Framework ≤4.5 defaulting to TLS 1.0/1.1, but this also caps the ceiling.🔒 Proposed fix
- [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 -bor [Net.SecurityProtocolType]::Tls13🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@scripts/install.ps1` at line 30, The current assignment to [Net.ServicePointManager]::SecurityProtocol forces TLS 1.2 only; change it so the SecurityProtocol value includes both TLS 1.2 and TLS 1.3 (use a bitwise OR of the SecurityProtocolType flags) so Invoke-WebRequest can negotiate TLS 1.3 when available; update the assignment to set [Net.ServicePointManager]::SecurityProtocol to include both [Net.SecurityProtocolType]::Tls12 and [Net.SecurityProtocolType]::Tls13 (using -bor) in the scripts/install.ps1 code path where [Net.ServicePointManager]::SecurityProtocol is set.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@scripts/install.ps1`:
- Around line 1-70: The script contains emoji in several Write-Host calls (e.g.,
the "🚀 Starting J-Focus installation..." and other Write-Host lines) which can
be garbled on Windows PowerShell 5.x if the file has no BOM; fix by saving
scripts/install.ps1 with UTF-8 BOM encoding (use your editor's "UTF-8 with BOM"
option or re-save the file using PowerShell's UTF-8-BOM save option) so
$ErrorActionPreference and all Write-Host output render correctly across
PowerShell versions.
---
Nitpick comments:
In `@scripts/install.ps1`:
- Line 30: The current assignment to [Net.ServicePointManager]::SecurityProtocol
forces TLS 1.2 only; change it so the SecurityProtocol value includes both TLS
1.2 and TLS 1.3 (use a bitwise OR of the SecurityProtocolType flags) so
Invoke-WebRequest can negotiate TLS 1.3 when available; update the assignment to
set [Net.ServicePointManager]::SecurityProtocol to include both
[Net.SecurityProtocolType]::Tls12 and [Net.SecurityProtocolType]::Tls13 (using
-bor) in the scripts/install.ps1 code path where
[Net.ServicePointManager]::SecurityProtocol is set.
ℹ️ Review info
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
scripts/install.ps1scripts/install.sh
🚧 Files skipped from review as they are similar to previous changes (1)
- scripts/install.sh
- Rename confusing 'shallow' parameter to 'verbose' in extractRecursive - Invert recursion logic to align with verbose naming convention - Update Javadoc for extractContext methods to accurately reflect behavior - Simplify method calls by removing unnecessary boolean negation
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/java/com/jher235/jfocus/core/ContextExtractor.java (1)
72-107:rootClassis recomputed on every recursive invocation despite being invariant.
rootTargetnever changes throughout the recursion, sorootTarget.findAncestor(ClassOrInterfaceDeclaration.class)at line 80 always produces the same result. In verbose (deep) mode with large call graphs, this is redundant AST traversal on every frame.Consider computing it once in
extractContextand threading it through as a parameter:♻️ Proposed refactor
public ContextResult extractContext(MethodDeclaration targetMethod, boolean verbose) { ContextResult result = new ContextResult(targetMethod); result.setUsedFields(dependencyResolver.resolveFields(targetMethod)); Set<String> visited = new HashSet<>(); visited.add(AstUtils.createMethodId(targetMethod)); - extractRecursive(targetMethod, targetMethod, result, visited, verbose); + ClassOrInterfaceDeclaration rootClass = targetMethod + .findAncestor(ClassOrInterfaceDeclaration.class) + .orElse(null); + extractRecursive(rootClass, targetMethod, result, visited, verbose); return result; } private void extractRecursive( - MethodDeclaration rootTarget, + ClassOrInterfaceDeclaration rootClass, MethodDeclaration currentMethod, ContextResult result, Set<String> visited, boolean verbose) { List<MethodDeclaration> dependencies = dependencyResolver.resolveMethods(currentMethod); - ClassOrInterfaceDeclaration rootClass = rootTarget.findAncestor(ClassOrInterfaceDeclaration.class) - .orElse(null); for (MethodDeclaration dep : dependencies) { ... if (verbose) { - extractRecursive(rootTarget, dep, result, visited, verbose); + extractRecursive(rootClass, dep, result, visited, verbose); } } }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/main/java/com/jher235/jfocus/core/ContextExtractor.java` around lines 72 - 107, The method extractRecursive repeatedly computes rootClass via rootTarget.findAncestor(...) even though rootTarget is invariant; compute rootClass once in extractContext and pass it into extractRecursive as an extra parameter (e.g., add ClassOrInterfaceDeclaration rootClassParam to extractRecursive signature), update all calls (including recursive calls inside extractRecursive) to use this parameter instead of recomputing, and remove the local recomputation and related null handling inside extractRecursive.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/main/java/com/jher235/jfocus/core/ContextExtractor.java`:
- Around line 72-107: The method extractRecursive repeatedly computes rootClass
via rootTarget.findAncestor(...) even though rootTarget is invariant; compute
rootClass once in extractContext and pass it into extractRecursive as an extra
parameter (e.g., add ClassOrInterfaceDeclaration rootClassParam to
extractRecursive signature), update all calls (including recursive calls inside
extractRecursive) to use this parameter instead of recomputing, and remove the
local recomputation and related null handling inside extractRecursive.
📝 Description
This Pull Request introduces significant improvements to the
j-focustool, focusing on optimizing context extraction, enhancing output quality, and streamlining the installation process. The primary goal is to provide more efficient and accurate code context for LLM prompting, while also ensuring a smoother and more secure user experience during setup.✨ What does this PR do?
ContextExtractorhas been limited to 1 (direct calls only). This change aims to reduce token usage for common LLM prompting scenarios, making the tool more efficient.--verbose(-v) flag is provided, allowing users to retrieve comprehensive call chain context when needed.ContextExtractorhas been updated to accept theverboseparameter for controlling analysis depth.MarkdownExporterwhere Javadocs were incorrectly rendered as raw JavaParser object strings.toText(), ensuring Javadoc content is displayed correctly and legibly in the generated Markdown.install.shandinstall.ps1in bothREADME.mdandREADME.ko.mdhave been updated to point to thedevelopbranch. This ensures users always download the latest versions of the installation scripts.scripts/install.shandscripts/install.ps1have been updated to reflect the latestj-focusJAR, enhancing the security and integrity verification during the installation process.Summary by CodeRabbit
Documentation
New Features
Updates
Bug Fixes