diff --git a/.opencode/agents/COMMON_PATTERNS.md b/.opencode/agents/COMMON_PATTERNS.md new file mode 100644 index 000000000..131dc70a5 --- /dev/null +++ b/.opencode/agents/COMMON_PATTERNS.md @@ -0,0 +1,176 @@ +# Common Patterns for CleverAgents + +This document contains tested patterns and explicit instructions that agents should use +instead of discovering these patterns each time. + +## OpenCode Server API + +**Endpoint**: `http://localhost:4096` + +Common operations: +- Create session: `POST /session` with `{"title": "session name"}` +- Launch agent: `POST /session/{session_id}/prompt_async` +- Get session status: `GET /session/status` +- Get session messages: `GET /session/{session_id}/messages` + +## Git Remote Configuration + +**Standard pattern**: +- `origin` → Forgejo remote (https://git.cleverthis.com) +- `upstream` → Local filesystem (/app) + +To get repository info: +```bash +git remote get-url origin | sed 's#.*git.cleverthis.com/##' | sed 's/.git$//' +# Returns: owner/repo +``` + +## Nox Command Outputs and Exit Codes + +All nox commands follow this pattern: +- Exit code 0 = Success +- Exit code 1 = Failure +- Output format: `nox > [session info]` followed by actual output + +Common commands: +- `nox -e lint` - Runs ruff linter +- `nox -e typecheck` - Runs pyright type checker +- `nox -e unit_tests` - Runs Behave tests from features/ +- `nox -e integration_tests` - Runs Robot tests from robot/ +- `nox -e coverage_report` - Generates coverage XML in build/coverage.xml + +## Test Organization + +**Unit tests** (Behave BDD): +- Location: `features/` +- File pattern: `*.feature` +- Step definitions: `features/steps/` +- Run with: `nox -e unit_tests` + +**Integration tests** (Robot Framework): +- Location: `robot/` +- File pattern: `*.robot` +- Run with: `nox -e integration_tests` + +**NEVER use pytest** - All unit tests must be Behave BDD format. + +## CI Job Names + +Standard CI job names in Forgejo (case-sensitive): +- `lint` +- `typecheck` +- `unit_tests` +- `integration_tests` +- `coverage` +- `security` +- `quality` +- `build` +- `benchmark-regression` + +Status format in PR: `CI / {job_name} (pull_request)` + +## Forgejo Issue/PR Metadata Requirements + +**Required labels** (per CONTRIBUTING.md): +- Exactly ONE `State/*` label (State/Unverified, State/Verified, etc.) +- Exactly ONE `Type/*` label (Type/Bug, Type/Feature, etc.) +- Exactly ONE `Priority/*` label (Priority/Critical, Priority/High, etc.) +- Milestone assignment (except Epics and Legendaries) + +**PR Requirements**: +- Closing keyword: `Closes #123` or `Fixes #123` +- Milestone must match the linked issue +- Type label must match the linked issue + +**Issue Body Format**: +```markdown +## Background +[Context and motivation] + +## Acceptance Criteria +- [ ] Criterion 1 +- [ ] Criterion 2 + +## Metadata +- **Commit Message**: `type(scope): description` +- **Branch Name**: `issue-123-brief-description` + +## Subtasks +- [ ] Subtask 1 +- [ ] Subtask 2 + +## Definition of Done +- [ ] All subtasks complete +- [ ] Tests passing +- [ ] Documentation updated +``` + +## Bot Signature Format + +Every Forgejo comment/issue/PR must end with: +``` +--- +**Automated by CleverAgents Bot** +Supervisor: {supervisor_name} | Agent: {agent_name} +``` + +## Session State Issue + +- Created by product-builder at startup +- Title: `[SESSION STATE] {product_name} - {timestamp}` +- Labels: `Type/Task,State/In Progress,Priority/Medium,Type/Automation` +- Used for coordination between agents +- Health signals posted every 10-20 cycles + +## Common Error Patterns in CI Logs + +**Lint failures**: +``` +path/to/file.py:123:45: E501 line too long (92 > 88 characters) +path/to/file.py:45:1: F401 'module.name' imported but unused +``` + +**Type check failures**: +``` +path/to/file.py:123:45 - error: Argument of type "str" cannot be assigned to parameter "count" of type "int" +``` + +**Test failures (Behave)**: +``` +FAILED features/test.feature:10: Example Name - AssertionError: Expected X but got Y +``` + +**Test failures (Robot)**: +``` +FAIL : Expected '${result}' to be '42' but was '0' +``` + +## File Organization Paths + +**Source code**: `src/cleveragents/` +**Unit tests**: `features/` +**Integration tests**: `robot/` +**Documentation**: `docs/` +**Build artifacts**: `build/` +**Agent definitions**: `.opencode/agents/` +**CI workflows**: `.forgejo/workflows/` + +## Specification Location + +Check in this order: +1. `docs/specification/index.md` (split format) +2. `docs/specification.md` (monolithic format) + +## Timeline and Milestones + +Located in: `docs/timeline.md` + +Format includes PlantUML gantt chart and schedule adherence entries. + +## Branch Protection Settings + +Default for master/main: +- Require CI checks to pass +- Dismiss stale reviews +- No force push allowed +- No deletion allowed \ No newline at end of file diff --git a/.opencode/agents/PARSING_PATTERNS.md b/.opencode/agents/PARSING_PATTERNS.md new file mode 100644 index 000000000..ef6d3dbb5 --- /dev/null +++ b/.opencode/agents/PARSING_PATTERNS.md @@ -0,0 +1,251 @@ +# Common Parsing Patterns for CleverAgents + +This document contains tested regular expressions and parsing patterns that agents +should use instead of rediscovering them each time. + +## Nox Output Parsing + +### Lint Output (ruff) +```python +# Pattern: filename:line:column: CODE message +pattern = r'^(.*?):(\d+):(\d+): ([A-Z]\d+) (.*)$' +# Groups: (filename, line, column, error_code, message) + +# Example: +# src/file.py:123:45: E501 line too long (92 > 88 characters) +``` + +### Typecheck Output (pyright) +```python +# Pattern: filename:line:column - error: message +pattern = r'^(.*?):(\d+):(\d+) - error: (.*)$' +# Groups: (filename, line, column, message) + +# Example: +# src/file.py:123:45 - error: Argument of type "str" cannot be assigned to parameter "count" of type "int" +``` + +### Test Output (Behave) +```python +# Failure pattern +pattern = r'^FAILED (features/.*?\.feature):(\d+): (.*?) - (.*)$' +# Groups: (feature_file, line, scenario_name, error) + +# Summary pattern +pattern = r'^(\d+) features? passed, (\d+) failed' +# Groups: (passed_count, failed_count) +``` + +### Test Output (Robot) +```python +# Failure pattern +pattern = r'^(.*?\.robot) \| FAIL \| (.*)$' +# Groups: (robot_file, error_message) + +# Summary pattern +pattern = r'^(\d+) tests?, (\d+) passed, (\d+) failed' +# Groups: (total, passed, failed) +``` + +## Forgejo PR/Issue Parsing + +### Extract Metadata from Issue Body +```python +def extract_issue_metadata(body): + metadata = {} + + # Commit message + match = re.search(r'Commit Message[:\s]*`([^`]+)`', body, re.IGNORECASE) + if match: + metadata['commit_message'] = match.group(1) + + # Branch name + match = re.search(r'Branch[:\s]*`([^`]+)`', body, re.IGNORECASE) + if match: + metadata['branch_name'] = match.group(1) + + return metadata +``` + +### Extract Subtasks +```python +def extract_subtasks(body): + subtasks = [] + # Match checkbox lines + pattern = r'^\s*- \[([ xX])\] (.*)$' + for line in body.split('\n'): + match = re.match(pattern, line) + if match: + completed = match.group(1).lower() == 'x' + description = match.group(2).strip() + subtasks.append({ + 'completed': completed, + 'description': description + }) + return subtasks +``` + +## Git Patterns + +### Parse Remote URL +```python +def parse_git_remote(url): + # SSH format: git@git.cleverthis.com:owner/repo.git + ssh_pattern = r'git@[^:]+:([^/]+)/([^.]+)\.git$' + match = re.match(ssh_pattern, url) + if match: + return match.group(1), match.group(2) # (owner, repo) + + # HTTPS format: https://git.cleverthis.com/owner/repo.git + https_pattern = r'https://[^/]+/([^/]+)/([^.]+)(?:\.git)?$' + match = re.match(https_pattern, url) + if match: + return match.group(1), match.group(2) # (owner, repo) + + return None, None +``` + +### Extract SHA from Git Log +```python +# Full SHA pattern +pattern = r'^commit ([a-f0-9]{40})$' + +# Abbreviated SHA pattern (7-12 chars typical) +pattern = r'\b([a-f0-9]{7,12})\b' +``` + +## CI Status Patterns + +### PR Page CI Status +```html + +