-
Notifications
You must be signed in to change notification settings - Fork 0
Implement basic autonomous repository operations #115
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
694f3bc
40164ef
5e9bd05
d11ee2f
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 |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| name: AI Issue Triager | ||
|
|
||
| on: | ||
| issues: | ||
| types: [opened] | ||
|
|
||
| jobs: | ||
| triage: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| issues: write | ||
|
|
||
| steps: | ||
| - name: Checkout Repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20 | ||
| cache: 'npm' | ||
|
|
||
| - name: Install Dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Run AI Triage | ||
| run: | | ||
| npm run ai:triage | ||
| env: | ||
| ISSUE_BODY: ${{ github.event.issue.body }} | ||
| GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| name: AI PR Reviewer | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize] | ||
|
|
||
| jobs: | ||
| review: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
|
|
||
| steps: | ||
| - name: Checkout Repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20 | ||
| cache: 'npm' | ||
|
|
||
| - name: Install Dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Run AI PR Review | ||
| run: | | ||
| npm run ai:pr-review | ||
| env: | ||
| BASE_REF: ${{ github.base_ref }} | ||
| GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} | ||
|
|
||
| - name: Comment PR | ||
| uses: thollander/actions-comment-pull-request@v3 | ||
|
Check failure on line 37 in .github/workflows/ai-pr-reviewer.yml
|
||
| with: | ||
| file-path: 'pr_review.md' | ||
| comment-tag: 'ai-pr-review' | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| name: Autonomous Documentation | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| paths-ignore: | ||
| - 'docs/**' | ||
|
|
||
| jobs: | ||
| generate-docs: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
|
|
||
| steps: | ||
| - name: Checkout Repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20 | ||
| cache: 'npm' | ||
|
|
||
| - name: Install Dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Run Repo Analysis | ||
| run: npm run analyze:repo | ||
|
|
||
| - name: Generate Diagrams | ||
| run: npm run generate:diagrams | ||
|
|
||
| - name: Generate Knowledge Graph | ||
| run: npm run generate:knowledge-graph | ||
|
|
||
| - name: Commit and Push Changes | ||
| run: | | ||
| git config --global user.name "github-actions[bot]" | ||
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
| git add docs/ | ||
| git commit -m "docs: auto-update repository documentation and architecture diagrams" || exit 0 | ||
| git push | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,31 @@ | ||||||
| name: Continuous Improvement | ||||||
|
|
||||||
| on: | ||||||
| schedule: | ||||||
| - cron: '0 0 * * *' # Run daily at midnight | ||||||
| workflow_dispatch: | ||||||
|
|
||||||
| jobs: | ||||||
| improve: | ||||||
| runs-on: ubuntu-latest | ||||||
| permissions: | ||||||
| contents: write | ||||||
| pull-requests: write | ||||||
|
|
||||||
| steps: | ||||||
| - name: Checkout Repository | ||||||
| uses: actions/checkout@v4 | ||||||
|
|
||||||
| - name: Setup Node.js | ||||||
| uses: actions/setup-node@v4 | ||||||
| with: | ||||||
| node-version: 20 | ||||||
| cache: 'npm' | ||||||
|
|
||||||
| - name: Install Dependencies | ||||||
| run: npm ci | ||||||
|
|
||||||
| - name: Run Continuous Improvement Script | ||||||
| run: npm run ai:improve | ||||||
| env: | ||||||
| GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} | ||||||
|
Comment on lines
+30
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win Remove the unnecessary secret exposure. The Consider removing these lines, or wait to include them until the script is fully implemented to call the Gemini API. 🛡️ Proposed fix- env:
- GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| # Intelli-Credit Terminal AI Guidelines | ||
|
|
||
| This repository is designed to be an automated corporate credit appraisal application and a highly automated open-source repository. All AI assistants MUST adhere to the following directives: | ||
|
|
||
| ## 1. Automation First | ||
|
|
||
| Every repetitive task that can be automated must be automated. | ||
|
|
||
| - If you find yourself doing something manually that could be scripted, create a script in `scripts/automation/`. | ||
| - Ensure all automated tasks are self-contained and idempotent. | ||
|
|
||
| ## 2. Self-Healing | ||
|
|
||
| - Use `npm run fix` (which runs `lint:fix` and `format`) to automatically resolve linting and formatting issues. | ||
| - Attempt to continuously repair CI failures when safe to do so. | ||
| - When generating fixes or patches, use AI to automate simple conflicts and suggest solutions. | ||
|
|
||
| ## 3. Pre-Commit Validation | ||
|
|
||
| Before submitting any changes, you must validate your work by running: | ||
|
|
||
| 1. `npm test` | ||
| 2. `npm run typecheck` | ||
| 3. `npm run format` | ||
| 4. `npm run lint` | ||
|
|
||
| ## 4. Security Rules | ||
|
|
||
| - Prevent command injection: Do not use `execSync` or `exec` with concatenated strings in automation scripts. Use `execFileSync` with separated executable and argument arrays instead. | ||
| - Native APIs: Rewrite piped shell commands (`|`) using native Node.js logic since `execFileSync` does not support pipes. | ||
| - Audits: Run `npm audit --audit-level=high` regularly. Ensure dependencies are secure. | ||
|
|
||
| ## 5. Coding Standards | ||
|
|
||
| - Do NOT use `console.log`. The ESLint configuration prohibits it. | ||
| - Use `console.info`, `console.warn`, or `console.error` in automation scripts and application code. | ||
| - Ensure type safety by maintaining strict TypeScript typing. | ||
|
|
||
| ## 6. Continuous Knowledge | ||
|
|
||
| - The repository autonomously generates and maintains its knowledge graph and architecture diagrams in the `docs/` folder via the `npm run analyze:repo`, `npm run generate:diagrams`, and `npm run generate:knowledge-graph` scripts. Do not manually edit files in `docs/` that are auto-generated. | ||
| - Documentation must regenerate whenever the repository changes. | ||
|
|
||
| ## 7. GitHub Actions | ||
|
|
||
| - When writing or updating GitHub Actions, especially when using `thollander/actions-comment-pull-request@v3`, ensure inputs use kebab-case (e.g., `file-path`, `comment-tag`). | ||
| - Variables like `github.base_ref` and `github.head_ref` must be assigned to environment variables and referenced (e.g., `$BASE_REF`) in run scripts to prevent command injection vulnerabilities, rather than injected directly using `${{ }}`. | ||
| - When generating git diffs in PR triggers, use `git diff origin/$BASE_REF...HEAD`. | ||
|
|
||
| ## 8. AI Reviewer | ||
|
|
||
| - The repository automates pull request reviews using a dedicated AI PR Reviewer GitHub Action. | ||
| - The workflow generates feedback via artifacts or comments, utilizing the `GEMINI_API_KEY` secret. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| 1. **Create `AGENTS.md`**: Add guidelines for AI assistants, enforcing the automation of repetitive tasks, use of `npm run fix` for self-healing, and pre-commit validation using `npm test`, `npm run format`, and `npm run lint`. | ||
| 2. **Update `package.json`**: Add the required automation scripts (`fix`, `ai:triage`, `ai:improve`, `ai:pr-review`, `analyze:repo`, `generate:diagrams`, `generate:knowledge-graph`) pointing to `tsx scripts/automation/...`. | ||
| 3. **Implement Automation Scripts in `scripts/automation/`**: | ||
| - `self-heal.ts`: Executes `lint:fix`, `format`, etc., using `execFileSync` to prevent command injection and without `console.log`. | ||
| - `ai-triage.ts`: Mocks/Implements issue triaging using `@google/genai`. | ||
| - `ai-improve.ts`: Mocks/Implements continuous improvement loop. | ||
| - `ai-pr-review.ts`: Reads git diff safely (`origin/$BASE_REF...HEAD`), generates a PR review, and saves it to a file. | ||
| - `analyze-repo.ts`: Analyzes repo and outputs to `docs/`. | ||
| - `generate-diagrams.ts`: Generates architecture diagrams to `docs/`. | ||
| - `generate-knowledge-graph.ts`: Generates knowledge graph to `docs/`. | ||
| 4. **Create GitHub Actions Workflows**: | ||
| - `ai-pr-reviewer.yml`: Runs on PRs, assigns `github.base_ref` to `$BASE_REF`, runs `npm run ai:pr-review`, and posts the output using `thollander/actions-comment-pull-request@v3` with kebab-case inputs. | ||
| - `ai-issue-triager.yml`: Runs `npm run ai:triage` on issue creation. | ||
| - `continuous-improvement.yml`: Runs `npm run ai:improve` on a schedule. | ||
| - `autonomous-docs.yml`: Runs doc generation scripts on push to main and opens a PR or commits directly. | ||
| 5. **Pre-commit and Verify**: Run all verification steps and pre-commit instructions. | ||
| 6. **Submit**: Submit the changes. |
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.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
Add concurrency limits to prevent
git pushconflicts.Since this workflow commits and pushes to
main, concurrent runs triggered by rapid pushes can result ingit pushfailures due to diverging branches. Adding a concurrency group will queue the runs and prevent these conflicts.🛡️ Proposed fix
jobs: generate-docs: runs-on: ubuntu-latest + concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: false permissions:📝 Committable suggestion
🧰 Tools
🪛 zizmor (1.26.1)
[info] 11-11: workflow or action definition without a name (anonymous-definition): this job
(anonymous-definition)
🤖 Prompt for AI Agents