mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
Add GitHub Copilot code review setup and CI workflow (#93)
This commit is contained in:
1 parent
485fc67aa7
commit
6dab89d6c4
5 files changed
+184
-8
No files matched your search
@@ -0,0 +1,51 @@
|
||||
# Copilot Code Review Instructions
|
||||
|
||||
## Technology Stack
|
||||
|
||||
- **Monorepo**: pnpm workspace with backend, frontend, and shared packages
|
||||
- **Backend**: Bun runtime + Hono framework + Better SQLite3
|
||||
- **Frontend**: React 19 + Vite 7 + Radix UI + Tailwind CSS 4
|
||||
- **Validation**: Zod schemas throughout
|
||||
- **State**: React Query + Zustand
|
||||
- **Language**: TypeScript (strict mode)
|
||||
|
||||
## Code Style Requirements
|
||||
|
||||
### Must Flag as Issues
|
||||
|
||||
- Any code comments (code must be self-documenting)
|
||||
- Console.log statements (use structured logging)
|
||||
- Use of `any` type without justification
|
||||
- Default exports (named exports only)
|
||||
- .then() chains (use async/await)
|
||||
- Unused variables, imports, or dead code
|
||||
- Direct state mutations in React components
|
||||
|
||||
### Import Patterns
|
||||
|
||||
- Backend: `import { Hono } from 'hono'`
|
||||
- Frontend: `import { Button } from '@/components/ui/button'`
|
||||
- Shared types: `import { ... } from '@opencode-manager/shared'`
|
||||
|
||||
### Architecture Patterns
|
||||
|
||||
- Backend routes in `backend/src/routes/`
|
||||
- Backend services in `backend/src/services/`
|
||||
- Frontend pages in `frontend/src/pages/`
|
||||
- Shared types/schemas in `shared/src/`
|
||||
|
||||
### Quality Standards
|
||||
|
||||
- Test coverage: 80% minimum
|
||||
- DRY: No duplicated logic
|
||||
- SOLID principles enforced
|
||||
- YAGNI: No speculative code
|
||||
- All functions should have single responsibility
|
||||
|
||||
### Review Focus Areas
|
||||
|
||||
1. TypeScript type safety (no implicit any)
|
||||
2. Error handling with try/catch
|
||||
3. React hooks rules compliance
|
||||
4. Zod validation on API boundaries
|
||||
5. Consistent async/await usage
|
||||
@@ -0,0 +1,16 @@
|
||||
## Summary
|
||||
|
||||
## Type of Change
|
||||
|
||||
- [ ] Bug fix
|
||||
- [ ] New feature
|
||||
- [ ] Refactor
|
||||
- [ ] Documentation
|
||||
|
||||
## Checklist
|
||||
|
||||
- [ ] Code follows project style (no comments, named imports)
|
||||
- [ ] TypeScript types are properly defined
|
||||
- [ ] Tests added/updated (80% coverage target)
|
||||
- [ ] `pnpm lint` passes locally
|
||||
- [ ] `pnpm typecheck` passes locally
|
||||
@@ -0,0 +1,100 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [main, dev]
|
||||
types: [labeled]
|
||||
pull_request_review:
|
||||
types: [submitted]
|
||||
|
||||
jobs:
|
||||
check-ready:
|
||||
name: Check if Ready for CI
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
should-run: ${{ steps.check.outputs.run }}
|
||||
steps:
|
||||
- name: Check trigger conditions
|
||||
id: check
|
||||
run: |
|
||||
if [[ "${{ github.event_name }}" == "pull_request_review" && "${{ github.event.review.state }}" == "approved" ]]; then
|
||||
echo "Triggered by PR approval"
|
||||
echo "run=true" >> $GITHUB_OUTPUT
|
||||
elif [[ "${{ github.event_name }}" == "pull_request" && "${{ github.event.label.name }}" == "ready-for-ci" ]]; then
|
||||
echo "Triggered by ready-for-ci label"
|
||||
echo "run=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "Conditions not met, skipping CI"
|
||||
echo "run=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
lint:
|
||||
name: Lint
|
||||
needs: check-ready
|
||||
if: needs.check-ready.outputs.should-run == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 10.28.1
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "22"
|
||||
cache: "pnpm"
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Run linter
|
||||
run: pnpm lint
|
||||
|
||||
typecheck:
|
||||
name: Type Check
|
||||
needs: check-ready
|
||||
if: needs.check-ready.outputs.should-run == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 10.28.1
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "22"
|
||||
cache: "pnpm"
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Run type check
|
||||
run: pnpm typecheck
|
||||
|
||||
test:
|
||||
name: Test
|
||||
needs: check-ready
|
||||
if: needs.check-ready.outputs.should-run == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
|
||||
- uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 10.28.1
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "22"
|
||||
cache: "pnpm"
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Run tests
|
||||
run: pnpm test
|
||||
@@ -146,7 +146,8 @@ export const PromptInput = forwardRef<PromptInputHandle, PromptInputProps>(funct
|
||||
onShowModelsDialog,
|
||||
onShowHelpDialog,
|
||||
onToggleDetails,
|
||||
onExportSession
|
||||
onExportSession,
|
||||
currentAgent: localMode || undefined
|
||||
})
|
||||
|
||||
const { files: searchResults } = useFileSearch(
|
||||
|
||||
@@ -18,6 +18,7 @@ interface CommandHandlerProps {
|
||||
onShowHelpDialog?: () => void
|
||||
onToggleDetails?: () => boolean
|
||||
onExportSession?: () => void
|
||||
currentAgent?: string
|
||||
}
|
||||
|
||||
export function useCommandHandler({
|
||||
@@ -28,11 +29,12 @@ export function useCommandHandler({
|
||||
onShowModelsDialog,
|
||||
onShowHelpDialog,
|
||||
onToggleDetails,
|
||||
onExportSession
|
||||
onExportSession,
|
||||
currentAgent
|
||||
}: CommandHandlerProps) {
|
||||
const navigate = useNavigate()
|
||||
const createSession = useCreateSession(opcodeUrl, directory)
|
||||
const { model } = useModelSelection(opcodeUrl, directory)
|
||||
const { model, modelString } = useModelSelection(opcodeUrl, directory)
|
||||
const setSessionStatus = useSessionStatus((state) => state.setStatus)
|
||||
const [loading, setLoading] = useState(false)
|
||||
|
||||
@@ -58,7 +60,9 @@ export function useCommandHandler({
|
||||
case 'themes':
|
||||
await client.sendCommand(sessionID, {
|
||||
command: command.name,
|
||||
arguments: args
|
||||
arguments: args,
|
||||
agent: currentAgent,
|
||||
model: modelString || undefined
|
||||
})
|
||||
break
|
||||
|
||||
@@ -128,14 +132,18 @@ export function useCommandHandler({
|
||||
case 'init':
|
||||
await client.sendCommand(sessionID, {
|
||||
command: command.name,
|
||||
arguments: args
|
||||
arguments: args,
|
||||
agent: currentAgent,
|
||||
model: modelString || undefined
|
||||
})
|
||||
break
|
||||
|
||||
|
||||
default:
|
||||
await client.sendCommand(sessionID, {
|
||||
command: command.name,
|
||||
arguments: args
|
||||
arguments: args,
|
||||
agent: currentAgent,
|
||||
model: modelString || undefined
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -145,7 +153,7 @@ export function useCommandHandler({
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}, [sessionID, opcodeUrl, directory, onShowSessionsDialog, onShowModelsDialog, onShowHelpDialog, onToggleDetails, onExportSession, createSession, navigate, model, setSessionStatus])
|
||||
}, [sessionID, opcodeUrl, directory, onShowSessionsDialog, onShowModelsDialog, onShowHelpDialog, onToggleDetails, onExportSession, createSession, navigate, model, modelString, currentAgent, setSessionStatus])
|
||||
|
||||
return {
|
||||
executeCommand,
|
||||
|
||||
Reference in new issue
Block a user