diff --git a/.github/CODERABBIT-SETUP.md b/.github/CODERABBIT-SETUP.md index 6e01be4..1a6e525 100644 --- a/.github/CODERABBIT-SETUP.md +++ b/.github/CODERABBIT-SETUP.md @@ -21,12 +21,12 @@ on: Leaving `branches` out (as now) means “all branches”. -## 3. Add Codegen API key in GitHub +## 3. Add Cursor API key in GitHub 1. In your repo: **Settings → Secrets and variables → Actions**. -2. **Add new secret**: name exactly **`CODEGEN_API_KEY`**. -3. Value: your Codegen API key. -4. The workflow uses it as: `${{ secrets.CODEGEN_API_KEY }}`. +2. **Add new secret**: name exactly **`CURSOR_API_KEY`**. +3. Value: your Cursor API key. +4. The workflow uses it as: `${{ secrets.CURSOR_API_KEY }}`. ## 4. Branch structure (recommended) @@ -35,45 +35,43 @@ Leaving `branches` out (as now) means “all branches”. - **feature/*** – e.g. `feature/student-api`, `feature/new-login`. - **ai/*** – e.g. `ai/add-student-page`, `ai/cart-discount`. -Codegen/AI-created branches should follow **`ai/`**. The workflow does not depend on branch names; it runs on any branch that has a PR with a new review comment. +Cursor/AI-created branches should follow **`ai/`**. The workflow does not depend on branch names; it runs on any branch that has a PR with a new review comment. -## 5. Optional: apply fixes from Codegen +## 5. Optional: apply fixes from Cursor The workflow today: 1. Detects a comment from **coderabbitai**. 2. Checks out the PR branch. -3. Sends the comment to **Codegen** (`POST https://api.codegen.ai/fix`). +3. Sends the comment to **Cursor** (`POST https://api.codegen.ai/fix`). 4. Commits and pushes any **local** changes. -If Codegen returns the fix in the response (e.g. patch or file contents), you may need an **extra step** between “Send suggestion to Codegen AI” and “Commit fixes” that: +If Cursor returns the fix in the response (e.g. patch or file contents), you may need an **extra step** between “Send suggestion to Cursor AI” and “Commit fixes” that: - Reads the API response. - Writes or applies the fix in the repo (e.g. apply a patch or overwrite files). -Then the existing “Commit fixes” step will pick up those changes. If Codegen applies changes in another way (e.g. webhook that pushes to the repo), this step might not be needed. +Then the existing “Commit fixes” step will pick up those changes. If Cursor applies changes in another way (e.g. webhook that pushes to the repo), this step might not be needed. ## 6. What you need – checklist (GitHub, CodeRabbit, ClickUp) | System | Required? | What you need | |------------|-----------|----------------| -| **GitHub** | Yes | Repo with this workflow file. One secret: **`CODEGEN_API_KEY`**. | +| **GitHub** | Yes | Repo with this workflow file. One secret: **`CURSOR_API_KEY`**. | | **CodeRabbit** | Yes | CodeRabbit app installed on the repo (reviews PRs and leaves comments). | | **ClickUp** | No | Optional. Only if you want a comment posted to a ClickUp task: add **`CLICKUP_API_KEY`**. No need to set a task ID in secrets. | -Per-PR task resolution is optional; use **`process.md`**, the PR description/title, or a fallback secret (see below). +Per-PR task resolution is optional; use **`process.md`** or **`process.md.example`** at the repo root (see below). ### ClickUp (optional – task per branch / PR) If you want the workflow to post a comment to a **ClickUp task**: - Add secret **`CLICKUP_API_KEY`** (your ClickUp API token) in the repo. -- Resolve the task id in this **order**: - 1. **`process.md`** at the **repo root** on the PR branch, with `clickup_task:` (URL or raw id) and optional `branch:` (warns if it does not match the PR head branch). Copy from **`process.md.example`**. - 2. A ClickUp URL in the **PR title or description** (supports common `app.clickup.com/.../t/` shapes). - 3. Repository secret **`CLICKUP_TASK_ID`** as a last resort (same task for every run). +- Put **`clickup_task`** (and optional **`branch`**) in **`process.md`** or **`process.md.example`**, in that order: the workflow uses **`process.md`** first, then **`process.md.example`** if needed. It does **not** read the PR title/body or **`CLICKUP_TASK_ID`** for resolution. +- The ClickUp comment text uses the **task link** and **branch** from that file only (no PR or commit URLs). -If you don’t add `CLICKUP_API_KEY` or no task id is resolved, the workflow skips posting to ClickUp and still does CodeRabbit → Codegen → commit. +If you don’t add `CLICKUP_API_KEY` or no `clickup_task` is found in either file, the workflow skips posting to ClickUp and still does CodeRabbit → Cursor → commit. ## 7. Permissions @@ -82,4 +80,4 @@ If you don’t add `CLICKUP_API_KEY` or no task id is resolved, the workflow ski --- -**Summary:** You only **must** set **`CODEGEN_API_KEY`** in GitHub and have CodeRabbit installed. ClickUp is optional; if you use it, add **`CLICKUP_API_KEY`** and set **`process.md`** on the branch and/or a link in the PR, or **`CLICKUP_TASK_ID`** as fallback. +**Summary:** You only **must** set **`CURSOR_API_KEY`** in GitHub and have CodeRabbit installed. ClickUp is optional; if you use it, add **`CLICKUP_API_KEY`** and define **`clickup_task`** (and optional **`branch`**) in **`process.md`** or **`process.md.example`** on the branch. diff --git a/.github/workflows/coderabbit-auto-fix.yml b/.github/workflows/coderabbit-auto-fix.yml index 7b174c1..244d01c 100644 --- a/.github/workflows/coderabbit-auto-fix.yml +++ b/.github/workflows/coderabbit-auto-fix.yml @@ -58,27 +58,27 @@ jobs: exit 0 fi - # Optional Codegen integration - - name: Send suggestion to Codegen AI + # Optional Cursor integration + - name: Send suggestion to Cursor AI env: - CODEGEN_API_KEY: ${{ secrets.CODEGEN_API_KEY }} + CURSOR_API_KEY: ${{ secrets.CURSOR_API_KEY }} run: | - if [ -z "$CODEGEN_API_KEY" ]; then - echo "CODEGEN_API_KEY not configured, skipping Codegen step." + if [ -z "$CURSOR_API_KEY" ]; then + echo "CURSOR_API_KEY not configured, skipping Cursor step." exit 0 fi - echo "Sending suggestion to Codegen AI" + echo "Sending suggestion to Cursor AI" printf '%s' "$COMMENT_BODY" > /tmp/comment.txt BODY=$(jq -n --rawfile c /tmp/comment.txt '{comment:$c}') RESP=$(curl -s -w "\n%{http_code}" -X POST https://api.codegen.ai/fix \ - -H "Authorization: Bearer $CODEGEN_API_KEY" \ + -H "Authorization: Bearer $CURSOR_API_KEY" \ -H "Content-Type: application/json" \ -d "$BODY" || true) - echo "Codegen response:" + echo "Cursor response:" echo "$RESP" - name: Commit fixes if AI modified files @@ -98,11 +98,10 @@ jobs: - name: Extract ClickUp task ID env: HEAD_REF: ${{ github.event.pull_request.head.ref }} - PR_BODY: ${{ github.event.pull_request.body }} - PR_TITLE: ${{ github.event.pull_request.title }} - SECRET_TASK_ID: ${{ secrets.CLICKUP_TASK_ID }} run: | TASK_ID="" + PROC_BRANCH="" + PROC_TASK_URL="" proc_get() { local key="$1" @@ -123,50 +122,45 @@ jobs: echo "$id" } - if [ -f process.md ]; then - echo "Found process.md; parsing clickup_task and optional branch." - PROC_BRANCH=$(proc_get branch process.md || true) - PROC_TASK_RAW=$(proc_get clickup_task process.md || true) + # Task link and branch come only from process.md or process.md.example (no PR text, no secrets). + for PROC_FILE in process.md process.md.example; do + [ -f "$PROC_FILE" ] || continue + echo "Parsing $PROC_FILE for clickup_task and branch." + PROC_BRANCH=$(proc_get branch "$PROC_FILE" || true) + PROC_TASK_RAW=$(proc_get clickup_task "$PROC_FILE" || true) if [ -n "$PROC_BRANCH" ] && [ "$PROC_BRANCH" != "$HEAD_REF" ]; then - echo "::warning::process.md branch '$PROC_BRANCH' does not match PR head ref '$HEAD_REF'" + echo "::warning::$PROC_FILE branch '$PROC_BRANCH' does not match PR head ref '$HEAD_REF'" fi - if [ -n "$PROC_TASK_RAW" ]; then - if echo "$PROC_TASK_RAW" | grep -qi 'clickup\.com'; then - TASK_ID=$(id_from_clickup_string "$PROC_TASK_RAW") - else - CLEAN=$(echo "$PROC_TASK_RAW" | tr -d '\r') - if echo "$CLEAN" | grep -qE '^[a-zA-Z0-9_-]+$'; then - TASK_ID="$CLEAN" - fi - fi - if [ -n "$TASK_ID" ]; then - echo "ClickUp task id from process.md: $TASK_ID" - fi - fi - else - echo "No process.md in repo root; will try PR text then secret." - fi - - if [ -z "$TASK_ID" ]; then - TEXT="${PR_BODY} ${PR_TITLE}" - FIRST_URL=$(echo "$TEXT" | grep -oEi 'https?://[^[:space:]]*clickup\.com[^[:space:]]*' | head -1 || true) - if [ -n "$FIRST_URL" ]; then - TASK_ID=$(id_from_clickup_string "$FIRST_URL") + if [ -z "$PROC_TASK_RAW" ]; then + continue fi - if [ -z "$TASK_ID" ]; then - TASK_ID=$(echo "$TEXT" | grep -oEi 'clickup\.com/t/[a-z0-9]+' | head -1 | sed 's|.*/t/||' || true) + if echo "$PROC_TASK_RAW" | grep -qi 'clickup\.com'; then + TASK_ID=$(id_from_clickup_string "$PROC_TASK_RAW") + PROC_TASK_URL=$(echo "$PROC_TASK_RAW" | tr -d '\r' | sed 's/[[:space:]]*$//') + else + CLEAN=$(echo "$PROC_TASK_RAW" | tr -d '\r') + if echo "$CLEAN" | grep -qE '^[a-zA-Z0-9_-]+$'; then + TASK_ID="$CLEAN" + PROC_TASK_URL="https://app.clickup.com/t/${TASK_ID}" + fi fi if [ -n "$TASK_ID" ]; then - echo "ClickUp task id from PR title/body: $TASK_ID" + echo "ClickUp task id from $PROC_FILE: $TASK_ID" + break fi - fi + done - if [ -z "$TASK_ID" ] && [ -n "$SECRET_TASK_ID" ]; then - TASK_ID="$SECRET_TASK_ID" - echo "ClickUp task id from CLICKUP_TASK_ID secret." + if [ -z "$TASK_ID" ]; then + echo "No clickup_task found in process.md or process.md.example; skipping ClickUp comment." fi echo "TASK_ID=$TASK_ID" >> $GITHUB_ENV + { + echo "PROC_TASK_URL<<__PROC_EOF__" + echo "${PROC_TASK_URL:-}" + echo "__PROC_EOF__" + } >> $GITHUB_ENV + echo "PROC_BRANCH=$PROC_BRANCH" >> $GITHUB_ENV echo "Final ClickUp task id: ${TASK_ID:-}" - name: Post CodeRabbit suggestion to ClickUp @@ -178,13 +172,12 @@ jobs: $COMMENT_BODY" - COMMENT="@Codegen + COMMENT="@Cursor $SUMMARY - PR: ${{ github.event.pull_request.html_url }} - Repo: ${{ github.repository }} - Branch: ${{ github.event.pull_request.head.ref }}" + Task: ${{ env.PROC_TASK_URL }} + Branch: ${{ env.PROC_BRANCH }}" BODY=$(jq -n --arg text "$COMMENT" '{comment_text:$text, notify_all:false}') diff --git a/process.md.example b/process.md.example index 4674196..c1dd54b 100644 --- a/process.md.example +++ b/process.md.example @@ -1,6 +1,6 @@ # Branch process metadata -Copy this file to **`process.md`** on your branch and fill in the values. Commit `process.md` on the feature branch so the CodeRabbit → ClickUp workflow can resolve the task. +Copy this file to **`process.md`** on your branch and fill in the values, **or** commit **`process.md.example`** with real `clickup_task` / `branch` values. The workflow reads **`process.md`** first, then **`process.md.example`**. | Key | Required | Description | |-----|----------|-------------| @@ -10,17 +10,19 @@ Copy this file to **`process.md`** on your branch and fill in the values. Commit Example (replace with your real branch and task): ```text +base_branch: main branch: cr_code_check -clickup_task: https://app.clickup.com/t/86d22uk37 +clickup_task: https://app.clickup.com/t/86d2hj96n ``` Raw task id only is also accepted: ```text +base_branch: main branch: cr_code_check -clickup_task: 86d22uk37 +clickup_task: 86d2hj96n ``` Lines must start with the key (optional leading spaces). Use `key: value` on a single line. Inline `#` comments on the same line are stripped. -If `process.md` is missing or has no `clickup_task`, the workflow falls back to a ClickUp URL in the **PR title or description**, then to the **`CLICKUP_TASK_ID`** repository secret. +**Resolution order:** the workflow reads **`process.md`** first, then **`process.md.example`** if the first file is missing or has no `clickup_task`. It does **not** use the PR description, commit links, or repository secrets for the task or branch. The ClickUp comment includes the **task link** and **branch** from whichever file supplied `clickup_task` (not a PR or commit URL). diff --git a/src/Admissions.jsx b/src/Admissions.jsx index 35306c0..3537951 100644 --- a/src/Admissions.jsx +++ b/src/Admissions.jsx @@ -12,7 +12,8 @@ const COURSE_FEES = { export default function Admissions() { const navigate = useNavigate() - + + console.log('Admissions') const [admissions, setAdmissions] = useState([ { id: 1, name: 'John Doe', email: 'john@example.com', phone: '1234567890', course: 'Computer Science', status: 'pending' }, { id: 2, name: 'Jane Smith', email: 'jane@example.com', phone: '0987654321', course: 'Mathematics', status: 'approved' }, diff --git a/src/Settings.jsx b/src/Settings.jsx index 363c36a..15b1c73 100644 --- a/src/Settings.jsx +++ b/src/Settings.jsx @@ -15,6 +15,7 @@ export default function Settings() { } function handleSave() { + console.log('handleSave') localStorage.setItem('appSettings', JSON.stringify(settings)) alert('Settings saved successfully!') }