feat: add agent:prime script for agent-context indexing#3955
Conversation
This commit adds the `agent:prime` script to `package.json` to fix the missing script error during git post-hooks. It introduces the `scripts/agent-prime.mjs` script to generate an `.agent-context.json` file containing workspace metadata and submodule SHAs, along with unit tests in `tests/agent-prime.test.ts`. `vite.config.ts` was also updated to ensure the tests run.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
This commit adds the `agent:prime` script to `package.json` to fix the missing script error during git post-hooks. It introduces the `scripts/agent-prime.mjs` script to generate an `.agent-context.json` file containing workspace metadata and submodule SHAs, along with unit tests in `tests/agent-prime.test.ts`. `vite.config.ts` was also updated to ensure the tests run.
|
🚀 Deployment Details (Last updated: Jul 26, 2026, 10:54 AM PST) 🚀 Pushed to gh-pages; publish in progress
|
- Moves `tests/agent-prime.test.ts` to `tests/unit/agent-prime.test.ts` so Playwright doesn't attempt to run Vitest unit tests. - Fixes ESLint and Oxlint warnings by removing the unused `unlinkSync` import and the unused `context` assignment in the test assertions.
Reverts the `vite.config.ts` change to include `tests/*.test.ts` in vitest runner config because it breaks the Playwright runner.
🐙 GitHub Models Code Review
Reviewing: PR #3955 Model: gpt-4o-mini Code Review Feedback[ARCHITECTURE] ReviewUpon reviewing the changes in the Pull Request, I have identified several issues that need to be addressed. Below are the findings based on the provided diff and context. Findings
SummaryThe changes introduced in this PR have made significant progress, particularly with the addition of tests. However, there are still several critical issues that need to be addressed, particularly around performance, error handling, and security. Final VerdictGiven the presence of multiple blocking issues that could affect the functionality and security of the application, I must conclude that this PR cannot be merged until these issues are resolved. #### [PERFORMANCE] Review
Upon reviewing the provided pull request changes, I have identified the following issues based on the performance engineering perspective, focusing on expensive computations, redundant re-renders, large bundle impacts, and inefficient data structures.
### Findings
1. **Blocking Call with `execSync`**:
- **Snippet**:
```javascript
gitSha = execSync('git rev-parse HEAD', { cwd, encoding: 'utf8', stdio: 'pipe' }).trim();
```
- **Issue**: The use of `execSync` is a blocking call, which can lead to performance issues, especially if the command takes a long time to execute. This can stall the entire process until the command completes.
- **Status**: open
- **Confidence**: high
- **Counterexample**: If the Git repository is large or the command is run in a slow environment, the script could hang indefinitely, causing a poor user experience.
- **Fix Summary**: Consider using asynchronous alternatives such as `exec` from `child_process` or caching the result to avoid repeated calls.
2. **Error Handling for JSON Parsing**:
- **Snippet**:
```javascript
const pkgData = JSON.parse(readFileSync(pkgPath, 'utf8'));
```
- **Issue**: The error handling for JSON parsing is too lenient and lacks feedback. If the JSON is malformed, it will silently fall back to the default package name without informing the user adequately.
- **Status**: open
- **Confidence**: high
- **Counterexample**: If `package.json` contains invalid JSON, the user will not be notified of the issue, leading to confusion about why the default name is used.
- **Fix Summary**: Implement logging or throw an error to inform the user of the issue.
3. **Redundant Fallback for Git SHA Retrieval**:
- **Snippet**:
```javascript
console.warn(`[agent:prime] Command failed: "git rev-parse HEAD". Using fallback "unknown". Error: ${error.message}`);
```
- **Issue**: There is no logging to indicate that the Git SHA retrieval failed, which could be useful for debugging.
- **Status**: open
- **Confidence**: high
- **Counterexample**: If the command fails, users will not know why the SHA is 'unknown', leading to potential confusion.
- **Fix Summary**: Add logging to indicate that the Git SHA retrieval failed.
4. **Untrusted Input Path from `package.json`**:
- **Snippet**:
```javascript
const pkgData = JSON.parse(readFileSync(pkgPath, 'utf8'));
```
- **Issue**: Reading `package.json` without validation introduces a new untrusted input path. If an attacker can modify this file, they can manipulate the behavior of the script.
- **Status**: open
- **Confidence**: high
- **Counterexample**: If `package.json` is tampered with to include malicious code, it could lead to security vulnerabilities.
- **Fix Summary**: Implement validation checks on `pkgData` after parsing to ensure it meets expected criteria.
### Summary
The changes introduced in this pull request include a new script for generating agent context, which has several performance and security concerns that need to be addressed. The use of blocking calls, insufficient error handling, and lack of validation for untrusted input paths are critical issues that could affect the performance and security of the application.
Based on the findings, I recommend addressing the identified issues before merging this pull request.
```json
[SECURITY] ReviewUpon reviewing the provided pull request, I have identified the following issues related to security, specifically concerning untrusted input paths and data validation:
Based on the findings above, I recommend addressing the identified issues to ensure the security and robustness of the new functionality introduced in this pull request. [STYLE] ReviewUpon reviewing the provided changes in the Pull Request, I have identified several issues that need to be addressed. Below are the findings based on the diff and the context provided. Findings
SummaryThe PR has resolved the issue of lacking tests, but several other issues remain open that need to be addressed to ensure the code's robustness and maintainability. Final Verdict: JSON Findings Block---
*Generated by github-models-code-review* |
🤖 AI Technical AuditANTI-AI-SLOPThe implementation of FINAL RECOMMENDATIONApproved with Minor Changes DEFINITION OF DONE
Review automatically published via RepoAuditor. |
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Add the
agent:primescript entry topackage.json.Add
scripts/agent-prime.mjsto generate/update.agent-context.jsongracefully.Implement Vitest tests for the agent context indexing script.
Update
vite.config.tsto include.test.tsfiles inside/tests.PR created automatically by Jules for task 12915572335704980998 started by @arii