diff --git a/ECOSYSTEM.scm b/ECOSYSTEM.scm index 841a8b6..379721c 100644 --- a/ECOSYSTEM.scm +++ b/ECOSYSTEM.scm @@ -6,15 +6,81 @@ (version "1.0.0") (name "claude-gitlab-bridge") (type "project") - (purpose "> Bridge between Claude AI and GitLab for enhanced developer productivity") + (purpose "Bidirectional interface enabling Claude AI to interact with GitLab APIs") (position-in-ecosystem - "Part of hyperpolymath ecosystem. Follows RSR guidelines.") + "Part of hyperpolymath ecosystem. Follows RSR guidelines. Core integration layer for AI-assisted GitLab workflows.") + ;;; Internal Integrations + (integrations-internal + (all-projects + (purpose . "Deployment and management") + (protocol . "gitlab-api"))) + + ;;; External Integrations + (integrations-external + (gitlab + (purpose . "Primary API endpoint") + (protocol . "rest-api-v4") + (auth . "personal-access-token") + (base-url . "https://gitlab.com/api/v4") + (operations . (projects repositories issues merge-requests pipelines releases wikis))) + (claude + (purpose . "Command generation target") + (protocol . "json-commands") + (direction . "bidirectional") + (capabilities . (command-generation response-parsing context-management)))) + + ;;; API Interfaces + (apis + (cli + (interface . "deno-cli") + (modes . (interactive execute batch))) + (internal + (endpoint . "http://localhost:8888") + (protocol . "http") + (optional . #t))) + + ;;; Related Projects (related-projects - (project (name "rhodium-standard-repositories") - (url "https://github.com/hyperpolymath/rhodium-standard-repositories") - (relationship "standard"))) + (project + (name "rhodium-standard-repositories") + (url "https://github.com/hyperpolymath/rhodium-standard-repositories") + (relationship "standard")) + (project + (name "anthropic-sdk") + (url "https://github.com/anthropics/anthropic-sdk-typescript") + (relationship "dependency"))) + + ;;; Bridge Capabilities + (capabilities + (command-generation + (description . "Generate GitLab API commands from natural language") + (dry-run . #t)) + (batch-execution + (description . "Execute multiple GitLab operations in sequence") + (json-input . #t)) + (comprehensive-logging + (description . "Full audit trail of all operations") + (log-file . "~/.claude-gitlab-bridge/bridge.log")) + (error-handling + (description . "Automatic retries with exponential backoff") + (max-retries . 3))) + + ;;; What This Is / Is Not + (what-this-is + "Bidirectional bridge for Claude-GitLab interaction enabling: + - GitLab API operations (CRUD on projects, repos, issues, MRs) + - CI/CD pipeline control + - Command generation for Claude + - Batch operation execution + - Dry-run mode for safety") - (what-this-is "> Bridge between Claude AI and GitLab for enhanced developer productivity") - (what-this-is-not "- NOT exempt from RSR compliance")) + (what-this-is-not + "- NOT direct Claude API integration (generates commands only) + - NOT for self-hosted GitLab without modification + - NOT for git operations beyond GitLab API + - NOT for repository content analysis + - NOT for automated code review + - NOT for GitLab administration tasks + - NOT exempt from RSR compliance")) diff --git a/HANDOVER.md b/HANDOVER.md new file mode 100644 index 0000000..6791dc8 --- /dev/null +++ b/HANDOVER.md @@ -0,0 +1,192 @@ + + +# Claude-GitLab Bridge Project Handover Document + +## Project Identity + +- **Name**: Claude-GitLab Bridge +- **Repository**: `gitlab.com/hyperpolymath/claude-gitlab-bridge` +- **Purpose**: Bidirectional interface enabling Claude AI to interact with GitLab APIs +- **License**: MIT +- **Author**: Jonathan D.A. Jewell + +## Core Boundaries + +### IN SCOPE + +1. **GitLab API Operations** + - Project management (CRUD) + - Repository file operations + - CI/CD pipeline control + - Issue and merge request management + - Release and tag creation + - Wiki page management + +2. **Bridge Capabilities** + - Command generation for Claude + - Batch operation execution + - Dry-run mode for safety + - Comprehensive logging + - Error handling and retries + +3. **Integration Modes** + - Interactive CLI interface + - Single command execution + - Batch JSON operations + - Project deployment automation + - Repository synchronization + +4. **Security Features** + - Personal access token management + - TLS communication + - Operation auditing + - Rate limiting respect + +### OUT OF SCOPE + +- Direct Claude API integration +- GitLab self-hosted instances (without modification) +- Git operations beyond GitLab API +- Repository content analysis +- Code review automation +- GitLab administration tasks + +## Technical Architecture + +### Core Components + +``` +claude-gitlab-bridge/ +├── src/ +│ ├── bridge.ts # Main bridge class +│ ├── commands/ # Command implementations +│ │ ├── project.ts # Project operations +│ │ ├── repository.ts # Repo operations +│ │ ├── ci_cd.ts # Pipeline operations +│ │ └── issues.ts # Issue management +│ ├── generator.ts # Claude command generator +│ └── utils/ # Utilities +├── templates/ # Command templates +├── config/ # Configuration files +└── tests/ # Test suite +``` + +### Dependencies + +- Runtime: Node.js 18+ / Deno 1.40+ +- Languages: ReScript (primary), TypeScript (legacy) +- Packages: anthropic-sdk, gitlab-api client +- Optional: Redis (for caching) + +## State Management + +Configuration is managed via `STATE.scm` using Scheme syntax. Key settings include: + +- **Connection**: GitLab URL, API version, token environment variable +- **Settings**: Dry-run mode, max retries, timeout, caching +- **Logging**: Log level, file location, rotation settings +- **Rate Limiting**: Request limits, backoff strategy + +## Ecosystem Integration + +The project integrates with: + +### Internal +- All hyperpolymath projects via GitLab API for deployment and management + +### External +- **GitLab**: Primary API endpoint (REST API v4) +- **Claude**: Command generation target (JSON commands, bidirectional) + +### APIs +- **CLI**: Deno-based CLI with interactive, execute, and batch modes +- **Internal API**: Optional HTTP endpoint on port 8888 + +## Commands Reference + +### Project Operations +- `create`, `update`, `delete`, `list`, `get` + +### Repository Operations +- `clone`, `push`, `create-branch`, `merge-request` + +### File Operations +- `create`, `update`, `delete`, `get`, `upload-directory` + +### CI/CD Operations +- `create-pipeline`, `trigger-pipeline`, `get-status`, `cancel-pipeline` + +### Issue Operations +- `create`, `update`, `list`, `close`, `reopen`, `add-comment`, `boards` + +### Merge Request Operations +- `create`, `update`, `merge`, `approve`, `list` + +### Release Operations +- `create`, `tag`, `list`, `delete` + +### Wiki Operations +- `create`, `update`, `delete`, `list` + +## Security Configuration + +- **Authentication**: Personal access tokens via environment variables +- **TLS**: Required for all communications +- **Audit Logging**: Full operation audit trail +- **Token Scopes**: `api`, `read_repository`, `write_repository` +- **Webhook Validation**: Enabled for incoming webhooks + +## Development Guidelines + +### Language Policy (per RSR) + +- **Primary**: ReScript for new code +- **Fallback**: TypeScript for legacy compatibility +- **Banned**: Python, Ruby, Perl (per RSR language policy) + +### Code Style + +- Functional programming paradigm +- Type-safe implementations +- Comprehensive error handling +- Detailed logging for debugging + +### Testing Requirements + +- Unit tests: `vitest tests/unit/` +- Integration tests: `vitest tests/integration/` +- E2E tests: `vitest tests/e2e/` +- Coverage target: 80% +- Mock mode available for offline testing + +## Deployment Options + +1. **Standalone**: `deno run --allow-net --allow-env src/main.ts` +2. **Docker**: `docker run claude-gitlab-bridge` +3. **Systemd Service**: Available for production deployments + +## Next Steps + +1. Define TypeScript/ReScript interfaces for core types +2. Implement GitLab API client wrapper +3. Set up test infrastructure with mocking +4. Implement command generation logic +5. Add batch execution support +6. Create interactive CLI mode + +## Related Documentation + +- [META.scm](META.scm) - Project metadata and architecture decisions +- [ECOSYSTEM.scm](ECOSYSTEM.scm) - Integration definitions +- [STATE.scm](STATE.scm) - Current state and configuration +- [CLAUDE.md](CLAUDE.md) - Claude-specific instructions +- [README.adoc](README.adoc) - User-facing documentation + +## Contact + +- **Author**: Jonathan D.A. Jewell +- **Organization**: hyperpolymath +- **Email**: hello@hyperpolymath.dev diff --git a/META.scm b/META.scm index 007bd29..33c6d62 100644 --- a/META.scm +++ b/META.scm @@ -3,22 +3,141 @@ ;;; META.scm — claude-gitlab-bridge (define-module (claude-gitlab-bridge meta) - #:export (architecture-decisions development-practices design-rationale)) + #:export (project-metadata + boundaries + architecture-decisions + development-practices + design-rationale + dependencies + interfaces + commands + security + testing + deployment)) +;;; Project Metadata +(define project-metadata + '((name . "claude-gitlab-bridge") + (version . "1.0.0") + (description . "Bidirectional bridge for Claude-GitLab interaction") + (author . "Jonathan D.A. Jewell") + (license . "MIT") + (repository + (url . "https://gitlab.com/hyperpolymath/claude-gitlab-bridge.git") + (branch . "main")))) + +;;; Project Boundaries +(define boundaries + '((includes + . (gitlab-api-operations + command-generation + batch-execution + project-deployment + repository-sync + ci-cd-control + issue-management + merge-request-handling + wiki-page-management + release-tag-creation)) + (excludes + . (claude-api-direct ; No direct Claude API integration + self-hosted-gitlab ; Without modification + git-internals ; Beyond GitLab API + code-analysis ; Repository content analysis + code-review-automation ; Automated code review + gitlab-admin)))) ; GitLab administration tasks + +;;; Architecture Decisions (define architecture-decisions '((adr-001 (title . "RSR Compliance") (status . "accepted") (date . "2025-12-15") - (context . "> Bridge between Claude AI and GitLab for enhanced developer productivity") + (context . "Bridge between Claude AI and GitLab for enhanced developer productivity") (decision . "Follow Rhodium Standard Repository guidelines") - (consequences . ("RSR Gold target" "SHA-pinned actions" "SPDX headers" "Multi-platform CI"))))) + (consequences . ("RSR Gold target" "SHA-pinned actions" "SPDX headers" "Multi-platform CI"))) + (adr-002 + (title . "Language Selection") + (status . "accepted") + (date . "2025-12-15") + (context . "Need type-safe implementation for GitLab API interactions") + (decision . "Use ReScript as primary, TypeScript for legacy compatibility per RSR policy") + (consequences . ("Type safety" "Functional paradigm" "JavaScript interop"))))) +;;; Development Practices (define development-practices - '((code-style (languages . ("Just" "Scheme")) (formatter . "auto-detect") (linter . "auto-detect")) - (security (sast . "CodeQL") (credentials . "env vars only")) - (testing (coverage-minimum . 70)) - (versioning (scheme . "SemVer 2.0.0")))) + '((code-style + (languages . ("ReScript" "TypeScript" "Scheme")) + (formatter . "auto-detect") + (linter . "auto-detect")) + (security + (sast . "CodeQL") + (credentials . "env-vars-only") + (audit-log . #t)) + (testing + (coverage-minimum . 70) + (unit . "vitest") + (integration . "vitest") + (mock-mode . #t)) + (versioning + (scheme . "SemVer 2.0.0")))) +;;; Design Rationale (define design-rationale - '((why-rsr "RSR ensures consistency, security, and maintainability."))) + '((why-rsr . "RSR ensures consistency, security, and maintainability.") + (why-rescript . "Type safety with functional paradigm, compiles to clean JS.") + (why-bidirectional . "Claude generates commands, bridge executes and returns results."))) + +;;; Dependencies +(define dependencies + '((runtime + (node . "18+") + (deno . "1.40+")) + (packages + (anthropic-sdk . "latest") + (gitlab-api . "latest")) + (optional + (redis . "caching")))) + +;;; Interfaces +(define interfaces + '((cli + (command . "claude-gitlab-bridge") + (modes . (interactive execute batch deploy sync generate))) + (api + (internal-only . #t) + (port . 8888) + (protocol . "http")))) + +;;; Supported Commands +(define commands + '((project . (create update delete list get)) + (repository . (clone push create-branch merge-request)) + (files . (create update delete get upload-directory)) + (ci-cd . (create-pipeline trigger-pipeline get-status cancel-pipeline)) + (issues . (create update list close reopen add-comment boards)) + (merge-requests . (create update merge approve list)) + (releases . (create tag list delete)) + (wiki . (create update delete list)))) + +;;; Security Configuration +(define security + '((auth . "personal-access-token") + (tls . #t) + (audit-log . #t) + (token-scopes . (api read_repository write_repository)) + (webhook-validation . #t))) + +;;; Testing Configuration +(define testing + '((unit . "vitest tests/unit/") + (integration . "vitest tests/integration/") + (e2e . "vitest tests/e2e/") + (mock-mode . #t) + (coverage-target . 80))) + +;;; Deployment Options +(define deployment + '((standalone . "deno run --allow-net --allow-env src/main.ts") + (docker . "docker run claude-gitlab-bridge") + (systemd-service . #t))) diff --git a/STATE.scm b/STATE.scm index f0feeac..a6cc816 100644 --- a/STATE.scm +++ b/STATE.scm @@ -2,21 +2,103 @@ ;; SPDX-License-Identifier: AGPL-3.0-or-later ;; SPDX-FileCopyrightText: 2025 Jonathan D.A. Jewell +(define-module (claude-gitlab-bridge state) + #:export (metadata + connection-config + settings + logging-config + rate-limiting + current-position + blockers-and-issues + critical-next-actions + session-history + state-summary)) + +;;; Metadata (define metadata - '((version . "0.1.0") (updated . "2025-12-15") (project . "claude-gitlab-bridge"))) + '((version . "1.0.0") + (updated . "2025-12-15") + (project . "claude-gitlab-bridge"))) + +;;; Connection Configuration +(define connection-config + '((gitlab-url . "https://gitlab.com") + (api-version . "v4") + (username . "hyperpolymath") + (token-env . "GITLAB_TOKEN"))) + +;;; Application Settings +(define settings + '((dry-run . #f) + (max-retries . 3) + (timeout . 30) + (cache-enabled . #t) + (cache-dir . "~/.claude-gitlab-bridge/cache"))) + +;;; Logging Configuration +(define logging-config + '((enabled . #t) + (level . "INFO") + (file . "~/.claude-gitlab-bridge/bridge.log") + (rotate . #t) + (max-size . "10MB"))) + +;;; Rate Limiting +(define rate-limiting + '((respect-headers . #t) + (max-requests-per-minute . 60) + (backoff-strategy . "exponential"))) +;;; Current Position (define current-position - '((phase . "v0.1 - Initial Setup") - (overall-completion . 25) - (components ((rsr-compliance ((status . "complete") (completion . 100))))))) + '((phase . "v1.0 - Handover Documentation") + (overall-completion . 30) + (components + ((rsr-compliance + ((status . "complete") + (completion . 100))) + (documentation + ((status . "in-progress") + (completion . 80))) + (core-implementation + ((status . "pending") + (completion . 0))) + (testing + ((status . "pending") + (completion . 0))))))) -(define blockers-and-issues '((critical ()) (high-priority ()))) +;;; Blockers and Issues +(define blockers-and-issues + '((critical ()) + (high-priority + (("Implement core bridge functionality" . "requires architecture finalization"))))) +;;; Critical Next Actions (define critical-next-actions - '((immediate (("Verify CI/CD" . high))) (this-week (("Expand tests" . medium))))) + '((immediate + (("Complete handover documentation" . high) + ("Define TypeScript/ReScript interfaces" . high))) + (this-week + (("Implement GitLab API client" . medium) + ("Set up test infrastructure" . medium))) + (this-month + (("Implement command generation" . low) + ("Add batch execution support" . low))))) +;;; Session History (define session-history - '((snapshots ((date . "2025-12-15") (session . "initial") (notes . "SCM files added"))))) + '((snapshots + ((date . "2025-12-15") + (session . "initial") + (notes . "SCM files added")) + ((date . "2025-12-15") + (session . "handover") + (notes . "Added handover documentation to SCM files"))))) +;;; State Summary (define state-summary - '((project . "claude-gitlab-bridge") (completion . 25) (blockers . 0) (updated . "2025-12-15"))) + '((project . "claude-gitlab-bridge") + (completion . 30) + (blockers . 1) + (updated . "2025-12-15") + (next-milestone . "Core Implementation")))