From 45969315aa6f7a92643fe8049a1f027e6f92dc51 Mon Sep 17 00:00:00 2001 From: Bot Date: Wed, 25 Mar 2026 09:26:57 +0800 Subject: [PATCH] Fix issue #1 --- CONTRIBUTING.md | 44 +++++++++++++++++++++++++++++++++++ README.md | 2 ++ apply_fix.sh | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ fix_script.py | 59 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 167 insertions(+) create mode 100644 CONTRIBUTING.md create mode 100644 apply_fix.sh create mode 100644 fix_script.py diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..025da7181 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,44 @@ +# Contributing to agent-browser + +Thank you for your interest in contributing to agent-browser! Your contributions help make this project better for everyone. + +## Development Environment Setup + +1. Fork the repository and clone your fork: + ```bash + git clone https://github.com/YOUR_USERNAME/agent-browser.git + cd agent-browser + ``` +2. Install the dependencies: + ```bash + npm install + ``` +3. Run the build to verify your setup: + ```bash + npm run build + ``` +4. Run tests to ensure everything is working correctly: + ```bash + npm test + ``` + +## Coding Style Guidelines + +- **TypeScript**: We use TypeScript. Ensure your code is strongly typed and avoids using `any` wherever possible. +- **Formatting & Linting**: Follow the existing Prettier and ESLint configurations. Run `npm run lint` and format your code before submitting. +- **Testing**: Include unit tests for any new features or bug fixes (we use Vitest). +- **Documentation**: Document any new commands, complex logic, or architecture changes. + +## How to Submit a PR + +1. Create a new feature branch from the `main` branch: + ```bash + git checkout -b feature/my-new-feature + ``` +2. Make your changes and commit them with clear, descriptive commit messages. +3. Push your branch to your fork: + ```bash + git push origin feature/my-new-feature + ``` +4. Open a Pull Request against the main `dextonai/agent-browser` repository. +5. Provide a clear description of the changes, what problem they solve, and reference any related issues. diff --git a/README.md b/README.md index 7b0dfba9a..ab975d619 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # agent-browser +[![CI](https://github.com/dextonai/agent-browser/actions/workflows/ci.yml/badge.svg)](https://github.com/dextonai/agent-browser/actions) + Headless browser automation CLI for AI agents. Fast Rust CLI with Node.js fallback. ## Installation diff --git a/apply_fix.sh b/apply_fix.sh new file mode 100644 index 000000000..693ab9cbc --- /dev/null +++ b/apply_fix.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +cat << 'EOF' > CONTRIBUTING.md +# Contributing to agent-browser + +Thank you for your interest in contributing to agent-browser! Your contributions help make this project better for everyone. + +## Development Environment Setup + +1. Fork the repository and clone your fork: + ```bash + git clone https://github.com/YOUR_USERNAME/agent-browser.git + cd agent-browser + ``` +2. Install the dependencies: + ```bash + npm install + ``` +3. Run the build to verify your setup: + ```bash + npm run build + ``` +4. Run tests to ensure everything is working correctly: + ```bash + npm test + ``` + +## Coding Style Guidelines + +- **TypeScript**: We use TypeScript. Ensure your code is strongly typed and avoids using `any` wherever possible. +- **Formatting & Linting**: Follow the existing Prettier and ESLint configurations. Run `npm run lint` and format your code before submitting. +- **Testing**: Include unit tests for any new features or bug fixes (we use Vitest). +- **Documentation**: Document any new commands, complex logic, or architecture changes. + +## How to Submit a PR + +1. Create a new feature branch from the `main` branch: + ```bash + git checkout -b feature/my-new-feature + ``` +2. Make your changes and commit them with clear, descriptive commit messages. +3. Push your branch to your fork: + ```bash + git push origin feature/my-new-feature + ``` +4. Open a Pull Request against the main `dextonai/agent-browser` repository. +5. Provide a clear description of the changes, what problem they solve, and reference any related issues. +EOF + +if [ -f README.md ]; then + if grep -q "^# " README.md; then + awk '!c && /^# /{print; print "\n[![CI](https://github.com/dextonai/agent-browser/actions/workflows/ci.yml/badge.svg)](https://github.com/dextonai/agent-browser/actions)"; c=1; next}1' README.md > tmp.md && mv tmp.md README.md + else + awk 'NR==1{print "[![CI](https://github.com/dextonai/agent-browser/actions/workflows/ci.yml/badge.svg)](https://github.com/dextonai/agent-browser/actions)\n"; print; next}1' README.md > tmp.md && mv tmp.md README.md + fi +else + cat << 'EOF' > README.md +# agent-browser + +[![CI](https://github.com/dextonai/agent-browser/actions/workflows/ci.yml/badge.svg)](https://github.com/dextonai/agent-browser/actions) +EOF +fi \ No newline at end of file diff --git a/fix_script.py b/fix_script.py new file mode 100644 index 000000000..bff1b4c16 --- /dev/null +++ b/fix_script.py @@ -0,0 +1,59 @@ +import os +import requests +import json +import subprocess + +api_key = os.environ.get("OPENAI_API_KEY", "anything") +headers = { + "Content-Type": "application/json", + "Authorization": f"Bearer {api_key}" +} + +# 1. Read all TS/JS files in src/ +files_content = "" +for root, _, files in os.walk("src"): + for file in files: + if file.endswith((".ts", ".js", ".py", ".java")): + path = os.path.join(root, file) + with open(path, "r") as f: + files_content += f"--- {path} ---\n{f.read()}\n\n" + +prompt = f"""You are an expert engineer. +Issue: https://github.com/dextonai/agent-browser/issues/1 +Description: +## Add a README badge and contribution guide to agent-browser + +Add a contribution guide (CONTRIBUTING.md) and a status badge to the README.md in the dextonai/agent-browser repository. The CONTRIBUTING.md should include: how to set up the dev environment, coding style guidelines, and how to submit a PR. The README badge should show the build status. This is a simple documentation task. + +**Reward:** 1.000000000000000000 DXTN +**Mode:** competition +**Deadline:** None + +--- +To claim this bounty, submit a PR referencing `bounty:8e29b86d-2387-4a5a-bd72-69afaa74c4ad` in the PR body. + +_Managed by [DextonHub](https://dextonhub.com). [View bounty](https://dextonhub.com/app/bounties/8e29b86d-2387-4a5a-bd72-69afaa74c4ad)_ + +Files: +{files_content} + +Your job is to provide ONLY a valid bash script that patches the files using tools like sed, awk, or echoing entire rewritten files. +Do NOT use markdown code blocks, just raw bash commands so I can pipe it directly to bash. +""" + +payload = { + "model": "gemini-3.1-pro-preview", + "messages": [{"role": "user", "content": prompt}], + "max_tokens": 4096 +} + +resp = requests.post("http://172.25.176.1:4000/v1/chat/completions", headers=headers, json=payload) +data = resp.json() +bash_code = data["choices"][0]["message"]["content"].strip() +if bash_code.startswith("```bash"): + bash_code = bash_code[7:-3] +elif bash_code.startswith("```"): + bash_code = bash_code[3:-3] + +with open("apply_fix.sh", "w") as f: + f.write(bash_code)