-
Notifications
You must be signed in to change notification settings - Fork 0
Fix/release #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/release #54
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -32,8 +32,20 @@ export class JudgeAgent extends PromptAgent implements RunnableAgent { | |||||||||||||||||||||||||||||
| private systemPrompt?: string; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| async initialize() { | ||||||||||||||||||||||||||||||
| // In production (dist/), agent files are in dist/agents/devhub/judge/ | ||||||||||||||||||||||||||||||
| // In development, they're alongside this file | ||||||||||||||||||||||||||||||
| const agentDir = path.dirname(fileURLToPath(import.meta.url)); | ||||||||||||||||||||||||||||||
| const systemPromptPath = path.join(agentDir, 'judge.agent.md'); | ||||||||||||||||||||||||||||||
| let systemPromptPath = path.join(agentDir, 'judge.agent.md'); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| // Check if running from dist/cli (bundled), need to go to dist/agents | ||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||
| await fs.access(systemPromptPath); | ||||||||||||||||||||||||||||||
| } catch { | ||||||||||||||||||||||||||||||
| // Fallback: look in dist/agents/devhub/judge/ | ||||||||||||||||||||||||||||||
| const distRoot = path.resolve(agentDir, '../../'); | ||||||||||||||||||||||||||||||
| systemPromptPath = path.join(distRoot, 'agents/devhub/judge/judge.agent.md'); | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
| systemPromptPath = path.join(distRoot, 'agents/devhub/judge/judge.agent.md'); | |
| systemPromptPath = path.join(distRoot, 'agents/devhub/judge/judge.agent.md'); | |
| try { | |
| await fs.access(systemPromptPath); | |
| } catch { | |
| throw new Error(`Could not locate judge.agent.md in either ${path.join(agentDir, 'judge.agent.md')} or ${systemPromptPath}`); | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The catch block is empty, which is generally discouraged as it can swallow important errors. For example, if fs.access fails due to a permissions issue on a parent directory, this code will silently proceed to the fallback path, masking the real problem.
Please add the error parameter to the catch block. Even if you don't log the error, it's better practice not to have a completely empty catch.
| try { | |
| await fs.access(systemPromptPath); | |
| } catch { | |
| // Fallback: look in dist/agents/devhub/judge/ | |
| const distRoot = path.resolve(agentDir, '../../'); | |
| systemPromptPath = path.join(distRoot, 'agents/devhub/judge/judge.agent.md'); | |
| } | |
| try { | |
| await fs.access(systemPromptPath); | |
| } catch (_error) { | |
| // Fallback: look in dist/agents/devhub/judge/ | |
| const distRoot = path.resolve(agentDir, '../../'); | |
| systemPromptPath = path.join(distRoot, 'agents/devhub/judge/judge.agent.md'); | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fallback path construction is quite fragile. It relies on a hardcoded relative path
../../and a long, specific path string'agents/devhub/judge/judge.agent.md'. This makes the code brittle and hard to maintain if the project structure or build output changes.While a larger refactor might be out of scope for this PR, consider defining these path segments as constants at the top of the file to improve readability and make them easier to update in one place.