gitlab-watcher 1.0.2__tar.gz → 2.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. gitlab_watcher-2.0.0/.github/DISCUSSION_TEMPLATE/ideas.yml +31 -0
  2. gitlab_watcher-2.0.0/.github/DISCUSSION_TEMPLATE/q-a.yml +47 -0
  3. gitlab_watcher-2.0.0/.github/DISCUSSION_TEMPLATE/show-and-tell.yml +31 -0
  4. gitlab_watcher-2.0.0/.github/ISSUE_TEMPLATE/bug_report.yml +102 -0
  5. gitlab_watcher-2.0.0/.github/ISSUE_TEMPLATE/config.yml +9 -0
  6. gitlab_watcher-2.0.0/.github/ISSUE_TEMPLATE/feature_request.yml +42 -0
  7. gitlab_watcher-2.0.0/.github/PULL_REQUEST_TEMPLATE.md +30 -0
  8. gitlab_watcher-2.0.0/.github/SECURITY.md +22 -0
  9. gitlab_watcher-2.0.0/.github/assets/social-preview-1280x640.png +0 -0
  10. gitlab_watcher-2.0.0/.github/assets/social-preview-16x9.jpg +0 -0
  11. gitlab_watcher-2.0.0/.github/dependabot.yml +14 -0
  12. gitlab_watcher-2.0.0/.github/workflows/codeql.yml +35 -0
  13. gitlab_watcher-2.0.0/.github/workflows/release.yml +46 -0
  14. gitlab_watcher-2.0.0/.gitignore +79 -0
  15. gitlab_watcher-2.0.0/.gitlab-ci.yml +108 -0
  16. gitlab_watcher-2.0.0/AGENTS.md +85 -0
  17. gitlab_watcher-2.0.0/CONTRIBUTING.md +68 -0
  18. gitlab_watcher-2.0.0/LICENSE +21 -0
  19. gitlab_watcher-2.0.0/PKG-INFO +405 -0
  20. gitlab_watcher-2.0.0/README.md +375 -0
  21. gitlab_watcher-2.0.0/docs/README.md +1287 -0
  22. gitlab_watcher-2.0.0/docs/code-review-report.md +710 -0
  23. gitlab_watcher-2.0.0/docs/code_review.md +45 -0
  24. gitlab_watcher-2.0.0/docs/fix-plan.md +1039 -0
  25. gitlab_watcher-2.0.0/docs/plans/2026-03-03-switchable-ollama.md +486 -0
  26. gitlab_watcher-2.0.0/docs/plans/2026-03-27-fix-security-vulnerabilities.md +36 -0
  27. gitlab_watcher-2.0.0/docs/plans/2026-07-03-scoped-agent-selection-for-opencode.md +62 -0
  28. gitlab_watcher-2.0.0/docs/testing.md +35 -0
  29. gitlab_watcher-2.0.0/gitlab-watcher.conf +128 -0
  30. {gitlab_watcher-1.0.2 → gitlab_watcher-2.0.0}/pyproject.toml +20 -5
  31. gitlab_watcher-2.0.0/scripts/changelog.py +237 -0
  32. gitlab_watcher-2.0.0/src/gitlab_watcher/__init__.py +17 -0
  33. gitlab_watcher-2.0.0/src/gitlab_watcher/_version.py +24 -0
  34. gitlab_watcher-2.0.0/src/gitlab_watcher/cli.py +157 -0
  35. gitlab_watcher-2.0.0/src/gitlab_watcher/config.py +379 -0
  36. gitlab_watcher-2.0.0/src/gitlab_watcher/constants.py +97 -0
  37. {gitlab_watcher-1.0.2 → gitlab_watcher-2.0.0}/src/gitlab_watcher/discord.py +79 -8
  38. gitlab_watcher-2.0.0/src/gitlab_watcher/git_ops.py +431 -0
  39. gitlab_watcher-2.0.0/src/gitlab_watcher/gitlab_client.py +632 -0
  40. gitlab_watcher-2.0.0/src/gitlab_watcher/logging_utils.py +113 -0
  41. gitlab_watcher-2.0.0/src/gitlab_watcher/processor.py +1406 -0
  42. {gitlab_watcher-1.0.2 → gitlab_watcher-2.0.0}/src/gitlab_watcher/protocols.py +42 -2
  43. gitlab_watcher-2.0.0/src/gitlab_watcher/state.py +430 -0
  44. gitlab_watcher-2.0.0/src/gitlab_watcher/watcher.py +800 -0
  45. gitlab_watcher-2.0.0/src/gitlab_watcher.egg-info/PKG-INFO +405 -0
  46. gitlab_watcher-2.0.0/src/gitlab_watcher.egg-info/SOURCES.txt +74 -0
  47. {gitlab_watcher-1.0.2 → gitlab_watcher-2.0.0}/src/gitlab_watcher.egg-info/entry_points.txt +1 -0
  48. {gitlab_watcher-1.0.2 → gitlab_watcher-2.0.0}/src/gitlab_watcher.egg-info/requires.txt +1 -2
  49. gitlab_watcher-2.0.0/src/gitlab_watcher.egg-info/scm_file_list.json +69 -0
  50. gitlab_watcher-2.0.0/src/gitlab_watcher.egg-info/scm_version.json +8 -0
  51. gitlab_watcher-2.0.0/tests/__init__.py +1 -0
  52. gitlab_watcher-2.0.0/tests/conftest.py +107 -0
  53. gitlab_watcher-2.0.0/tests/test_changelog.py +97 -0
  54. gitlab_watcher-2.0.0/tests/test_cli.py +187 -0
  55. {gitlab_watcher-1.0.2 → gitlab_watcher-2.0.0}/tests/test_config.py +158 -0
  56. {gitlab_watcher-1.0.2 → gitlab_watcher-2.0.0}/tests/test_config_extra.py +90 -0
  57. {gitlab_watcher-1.0.2 → gitlab_watcher-2.0.0}/tests/test_discord.py +101 -6
  58. {gitlab_watcher-1.0.2 → gitlab_watcher-2.0.0}/tests/test_git_ops.py +185 -18
  59. {gitlab_watcher-1.0.2 → gitlab_watcher-2.0.0}/tests/test_gitlab_client.py +111 -26
  60. gitlab_watcher-2.0.0/tests/test_input_validation.py +235 -0
  61. gitlab_watcher-2.0.0/tests/test_multi_mr.py +164 -0
  62. gitlab_watcher-2.0.0/tests/test_processor.py +1850 -0
  63. gitlab_watcher-2.0.0/tests/test_processor_errors.py +402 -0
  64. gitlab_watcher-2.0.0/tests/test_security_hardening.py +212 -0
  65. gitlab_watcher-2.0.0/tests/test_state.py +80 -0
  66. gitlab_watcher-2.0.0/tests/test_state_mr_failure.py +193 -0
  67. gitlab_watcher-2.0.0/tests/test_username_and_type_safety.py +75 -0
  68. gitlab_watcher-2.0.0/tests/test_watcher.py +1745 -0
  69. gitlab_watcher-1.0.2/PKG-INFO +0 -175
  70. gitlab_watcher-1.0.2/README.md +0 -147
  71. gitlab_watcher-1.0.2/src/gitlab_watcher/__init__.py +0 -3
  72. gitlab_watcher-1.0.2/src/gitlab_watcher/cli.py +0 -24
  73. gitlab_watcher-1.0.2/src/gitlab_watcher/config.py +0 -233
  74. gitlab_watcher-1.0.2/src/gitlab_watcher/git_ops.py +0 -138
  75. gitlab_watcher-1.0.2/src/gitlab_watcher/gitlab_client.py +0 -365
  76. gitlab_watcher-1.0.2/src/gitlab_watcher/logging_utils.py +0 -79
  77. gitlab_watcher-1.0.2/src/gitlab_watcher/processor.py +0 -445
  78. gitlab_watcher-1.0.2/src/gitlab_watcher/state.py +0 -201
  79. gitlab_watcher-1.0.2/src/gitlab_watcher/watcher.py +0 -268
  80. gitlab_watcher-1.0.2/src/gitlab_watcher.egg-info/PKG-INFO +0 -175
  81. gitlab_watcher-1.0.2/src/gitlab_watcher.egg-info/SOURCES.txt +0 -32
  82. gitlab_watcher-1.0.2/tests/test_processor.py +0 -808
  83. gitlab_watcher-1.0.2/tests/test_security_hardening.py +0 -35
  84. gitlab_watcher-1.0.2/tests/test_watcher.py +0 -885
  85. {gitlab_watcher-1.0.2 → gitlab_watcher-2.0.0}/setup.cfg +0 -0
  86. {gitlab_watcher-1.0.2 → gitlab_watcher-2.0.0}/src/gitlab_watcher/__main__.py +0 -0
  87. {gitlab_watcher-1.0.2 → gitlab_watcher-2.0.0}/src/gitlab_watcher/cache.py +0 -0
  88. {gitlab_watcher-1.0.2 → gitlab_watcher-2.0.0}/src/gitlab_watcher/exceptions.py +0 -0
  89. {gitlab_watcher-1.0.2 → gitlab_watcher-2.0.0}/src/gitlab_watcher.egg-info/dependency_links.txt +0 -0
  90. {gitlab_watcher-1.0.2 → gitlab_watcher-2.0.0}/src/gitlab_watcher.egg-info/top_level.txt +0 -0
  91. {gitlab_watcher-1.0.2 → gitlab_watcher-2.0.0}/tests/test_cache.py +0 -0
  92. {gitlab_watcher-1.0.2 → gitlab_watcher-2.0.0}/tests/test_logging_utils.py +0 -0
@@ -0,0 +1,31 @@
1
+ title: "[Idea]: "
2
+ body:
3
+ - type: markdown
4
+ attributes:
5
+ value: |
6
+ Share an idea or brainstorm new workflows for GitLab Watcher before turning it into a formal feature request.
7
+
8
+ - type: textarea
9
+ id: summary
10
+ attributes:
11
+ label: Idea summary
12
+ description: What would you like GitLab Watcher to do, and what problem or workflow does it improve?
13
+ validations:
14
+ required: true
15
+
16
+ - type: textarea
17
+ id: workflow
18
+ attributes:
19
+ label: How do you envision it working?
20
+ description: Describe any CLI options, config settings, GitLab labels, or AI tool integrations you have in mind.
21
+ validations:
22
+ required: false
23
+
24
+ - type: textarea
25
+ id: context
26
+ attributes:
27
+ label: Additional context
28
+ description: Links, examples, or related workflows.
29
+ validations:
30
+ required: false
31
+
@@ -0,0 +1,47 @@
1
+ title: "[Q&A]: "
2
+ body:
3
+ - type: markdown
4
+ attributes:
5
+ value: |
6
+ Have a question about setting up, configuring, or running GitLab Watcher? Ask here!
7
+ Please remember to **redact `GITLAB_TOKEN`, Discord webhook URLs, and any secrets** before posting config snippets or logs.
8
+
9
+ - type: textarea
10
+ id: question
11
+ attributes:
12
+ label: What is your question?
13
+ description: Describe what you are trying to achieve or where you are stuck.
14
+ validations:
15
+ required: true
16
+
17
+ - type: dropdown
18
+ id: ai-tool
19
+ attributes:
20
+ label: AI tool mode
21
+ options:
22
+ - ollama
23
+ - direct (Claude CLI)
24
+ - opencode
25
+ - custom
26
+ - opencode-custom
27
+ - Not sure / N/A
28
+ validations:
29
+ required: false
30
+
31
+ - type: input
32
+ id: version
33
+ attributes:
34
+ label: GitLab Watcher version
35
+ placeholder: "e.g. 2.0.0"
36
+ validations:
37
+ required: false
38
+
39
+ - type: textarea
40
+ id: context
41
+ attributes:
42
+ label: What have you tried so far?
43
+ description: Share any sanitized configuration snippets, commands, or relevant context.
44
+ render: shell
45
+ validations:
46
+ required: false
47
+
@@ -0,0 +1,31 @@
1
+ title: "[Showcase]: "
2
+ body:
3
+ - type: markdown
4
+ attributes:
5
+ value: |
6
+ Using GitLab Watcher in an interesting setup? Share your workflow, custom AI commands, or `agent:` label setups with the community!
7
+
8
+ - type: textarea
9
+ id: overview
10
+ attributes:
11
+ label: What are you automating?
12
+ description: Tell us about your projects, workflow, and how GitLab Watcher fits in.
13
+ validations:
14
+ required: true
15
+
16
+ - type: textarea
17
+ id: setup
18
+ attributes:
19
+ label: Setup & configuration highlights
20
+ description: Which AI tool mode, failover setup, or custom `AGENTS.md` / `PROJECT.md` rules worked best for you? (Redact any tokens or webhooks.)
21
+ validations:
22
+ required: false
23
+
24
+ - type: textarea
25
+ id: tips
26
+ attributes:
27
+ label: Lessons learned or tips
28
+ description: Anything that could help other users get the most out of GitLab Watcher.
29
+ validations:
30
+ required: false
31
+
@@ -0,0 +1,102 @@
1
+ name: Bug Report
2
+ description: Report a bug or unexpected behavior in GitLab Watcher
3
+ title: "[Bug]: "
4
+ labels: ["bug", "triage"]
5
+ body:
6
+ - type: markdown
7
+ attributes:
8
+ value: |
9
+ Thanks for taking the time to report a bug! Please fill out the details below so we can reproduce and fix it quickly.
10
+ **Important:** Always redact `GITLAB_TOKEN`, Discord webhook URLs, and any other secrets before posting logs or config snippets.
11
+
12
+ - type: textarea
13
+ id: description
14
+ attributes:
15
+ label: Describe the bug
16
+ description: A clear and concise description of what the bug is.
17
+ validations:
18
+ required: true
19
+
20
+ - type: textarea
21
+ id: reproduce
22
+ attributes:
23
+ label: Steps to reproduce
24
+ description: Steps to reproduce the behavior.
25
+ placeholder: |
26
+ 1. Configure `gitlab-watcher.conf` with '...'
27
+ 2. Run `gitlab-watcher ...`
28
+ 3. Trigger an issue or MR comment
29
+ 4. See error
30
+ validations:
31
+ required: true
32
+
33
+ - type: textarea
34
+ id: expected
35
+ attributes:
36
+ label: Expected behavior
37
+ description: What you expected to happen instead.
38
+ validations:
39
+ required: true
40
+
41
+ - type: input
42
+ id: version
43
+ attributes:
44
+ label: GitLab Watcher version
45
+ description: Output of `gitlab-watcher --version` or commit hash.
46
+ placeholder: "e.g. 1.2.0"
47
+ validations:
48
+ required: true
49
+
50
+ - type: dropdown
51
+ id: python-version
52
+ attributes:
53
+ label: Python version
54
+ options:
55
+ - "3.11"
56
+ - "3.12"
57
+ - "3.13"
58
+ - "Other"
59
+ validations:
60
+ required: true
61
+
62
+ - type: dropdown
63
+ id: ai-tool
64
+ attributes:
65
+ label: AI tool configured
66
+ options:
67
+ - ollama
68
+ - direct (Claude CLI)
69
+ - opencode
70
+ - custom
71
+ - opencode-custom
72
+ - N/A
73
+ validations:
74
+ required: true
75
+
76
+ - type: dropdown
77
+ id: gitlab-env
78
+ attributes:
79
+ label: GitLab environment
80
+ options:
81
+ - GitLab.com
82
+ - Self-hosted GitLab
83
+ validations:
84
+ required: false
85
+
86
+ - type: input
87
+ id: os
88
+ attributes:
89
+ label: Operating System
90
+ placeholder: "e.g. Ubuntu 24.04, Debian 12, macOS 15"
91
+ validations:
92
+ required: false
93
+
94
+ - type: textarea
95
+ id: logs
96
+ attributes:
97
+ label: Relevant logs or configuration
98
+ description: Paste any relevant log output or sanitized config snippets. **Do NOT include tokens or webhooks.**
99
+ render: shell
100
+ validations:
101
+ required: false
102
+
@@ -0,0 +1,9 @@
1
+ blank_issues_enabled: false
2
+ contact_links:
3
+ - name: Documentation & Setup Guide
4
+ url: https://github.com/gyengus/gitlab-watcher#readme
5
+ about: Check the README and docs before opening an issue for setup or configuration questions.
6
+ - name: Report a Security Vulnerability
7
+ url: https://github.com/gyengus/gitlab-watcher/security/advisories/new
8
+ about: Please report security issues privately via GitHub Security Advisories instead of a public issue.
9
+
@@ -0,0 +1,42 @@
1
+ name: Feature Request
2
+ description: Suggest a new feature or enhancement for GitLab Watcher
3
+ title: "[Feature]: "
4
+ labels: ["enhancement"]
5
+ body:
6
+ - type: markdown
7
+ attributes:
8
+ value: |
9
+ Have an idea to improve GitLab Watcher? Please describe the use case and proposed behavior below.
10
+
11
+ - type: textarea
12
+ id: problem
13
+ attributes:
14
+ label: Problem or use case
15
+ description: What problem does this feature solve, or what workflow would it enable?
16
+ validations:
17
+ required: true
18
+
19
+ - type: textarea
20
+ id: solution
21
+ attributes:
22
+ label: Proposed solution
23
+ description: How would you like this to work (e.g., CLI flags, config options, labels, AI tool integration)?
24
+ validations:
25
+ required: true
26
+
27
+ - type: textarea
28
+ id: alternatives
29
+ attributes:
30
+ label: Alternatives considered
31
+ description: Any workarounds or alternative approaches you've thought about.
32
+ validations:
33
+ required: false
34
+
35
+ - type: textarea
36
+ id: context
37
+ attributes:
38
+ label: Additional context
39
+ description: Add any other context, examples, or references here.
40
+ validations:
41
+ required: false
42
+
@@ -0,0 +1,30 @@
1
+ ## Summary
2
+
3
+ <!-- Briefly describe what this pull request changes and why. -->
4
+
5
+ Closes #
6
+
7
+ ## Type of Change
8
+
9
+ - [ ] Bug fix (non-breaking change fixing an issue)
10
+ - [ ] New feature (non-breaking change adding functionality)
11
+ - [ ] Breaking change (fix or feature causing existing behavior to change)
12
+ - [ ] Refactoring / code quality improvement
13
+ - [ ] Documentation update
14
+ - [ ] CI / build / tooling change
15
+
16
+ ## Testing & Verification
17
+
18
+ <!-- Describe how you tested these changes. -->
19
+
20
+ - [ ] `pytest` passes without errors
21
+ - [ ] `pytest --cov=gitlab_watcher` maintains at least 85% coverage
22
+ - [ ] Added or updated unit/integration tests for the changes
23
+
24
+ ## Checklist
25
+
26
+ - [ ] Code follows project style (Python 3.11+, type hints, docstrings where appropriate)
27
+ - [ ] Commit messages are clear English without conventional commit prefixes (`feat:`, `fix:`, `chore:`, etc.) or sign-off lines
28
+ - [ ] No tokens, credentials, or sensitive data are hardcoded or logged
29
+ - [ ] Documentation (`README.md`, `docs/`, `gitlab-watcher.conf`) updated if configuration or behavior changed
30
+
@@ -0,0 +1,22 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ Security updates are applied to the latest release of `gitlab-watcher`.
6
+
7
+ ## Reporting a Vulnerability
8
+
9
+ Please **do not** report security vulnerabilities through public GitHub issues.
10
+
11
+ Instead, report them privately using [GitHub Security Advisories](https://github.com/gyengus/gitlab-watcher/security/advisories/new).
12
+
13
+ When reporting a vulnerability, please include:
14
+ - A clear description of the issue and potential impact
15
+ - Steps to reproduce or a minimal proof of concept
16
+ - Affected versions and configuration details (with all tokens/secrets redacted)
17
+
18
+ ## Security Considerations for Users
19
+
20
+ - Keep `GITLAB_TOKEN` and Discord webhook URLs in your configuration file with restricted file permissions (`chmod 600`).
21
+ - Review AI tool permissions and prompt sanitization settings before running `gitlab-watcher` against untrusted repositories or public issues.
22
+
@@ -0,0 +1,14 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "pip"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "weekly"
7
+ open-pull-requests-limit: 5
8
+
9
+ - package-ecosystem: "github-actions"
10
+ directory: "/"
11
+ schedule:
12
+ interval: "weekly"
13
+ open-pull-requests-limit: 5
14
+
@@ -0,0 +1,35 @@
1
+ name: "CodeQL Analysis"
2
+
3
+ on:
4
+ push:
5
+ branches: [ "master" ]
6
+ schedule:
7
+ - cron: '0 9 * * 1' # Every Monday at 09:00 UTC
8
+
9
+ jobs:
10
+ analyze:
11
+ name: Analyze
12
+ runs-on: "ubuntu-latest"
13
+ permissions:
14
+ actions: read
15
+ contents: read
16
+ security-events: write
17
+
18
+ strategy:
19
+ fail-fast: false
20
+ matrix:
21
+ language: [ 'python' ]
22
+
23
+ steps:
24
+ - name: Checkout repository
25
+ uses: actions/checkout@v4
26
+
27
+ - name: Initialize CodeQL
28
+ uses: github/codeql-action/init@v3
29
+ with:
30
+ languages: ${{ matrix.language }}
31
+
32
+ - name: Perform CodeQL Analysis
33
+ uses: github/codeql-action/analyze@v3
34
+ with:
35
+ category: "/language:${{matrix.language}}"
@@ -0,0 +1,46 @@
1
+ name: GitHub Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - '*.*.*'
7
+ - 'v*.*.*'
8
+ workflow_dispatch:
9
+ inputs:
10
+ tag_name:
11
+ description: 'Tag string to create the release for (e.g., 1.0.0)'
12
+ required: true
13
+ type: string
14
+
15
+ env:
16
+ FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
17
+
18
+ permissions:
19
+ contents: write
20
+
21
+ jobs:
22
+ release:
23
+ name: Auto-generate Release
24
+ runs-on: ubuntu-latest
25
+ steps:
26
+ - name: Checkout Code
27
+ uses: actions/checkout@v4
28
+ with:
29
+ fetch-depth: 0
30
+
31
+ - name: Set up Python
32
+ uses: actions/setup-python@v5
33
+ with:
34
+ python-version: "3.12"
35
+
36
+ - name: Generate Release Notes
37
+ env:
38
+ TARGET_TAG: ${{ inputs.tag_name || github.ref_name }}
39
+ run: python3 scripts/changelog.py --release-notes "$TARGET_TAG" > release_notes.md
40
+
41
+ - name: Create Release
42
+ uses: softprops/action-gh-release@v2
43
+ with:
44
+ tag_name: ${{ inputs.tag_name || github.ref_name }}
45
+ name: Release ${{ inputs.tag_name || github.ref_name }}
46
+ body_path: release_notes.md
@@ -0,0 +1,79 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ *.egg-info/
24
+ .installed.cfg
25
+ *.egg
26
+
27
+ # PyInstaller
28
+ *.manifest
29
+ *.spec
30
+
31
+ # Installer logs
32
+ pip-log.txt
33
+ pip-delete-this-directory.txt
34
+
35
+ # Unit test / coverage reports
36
+ .coverage
37
+ .coverage.*
38
+ coverage.xml
39
+ coverage.lcov
40
+ *.cover
41
+ *.py,cover
42
+ .hypothesis/
43
+ .pytest_cache/
44
+
45
+ # Translations
46
+ *.mo
47
+ *.pot
48
+
49
+ # Environments
50
+ .env
51
+ .venv
52
+ env/
53
+ venv/
54
+ ENV/
55
+ env.bak/
56
+ venv.bak/
57
+ .pytest_venv/
58
+ .venv_new/
59
+
60
+ # IDE
61
+ .idea/
62
+ .vscode/
63
+ *.swp
64
+ *.swo
65
+ *~
66
+
67
+ # mypy
68
+ .mypy_cache/
69
+ .dmypy.json
70
+ dmypy.json
71
+
72
+ # ruff
73
+ .ruff_cache/
74
+
75
+ # Project specific
76
+ .claude_session
77
+ .worktrees/
78
+ src/gitlab_watcher/_version.py
79
+
@@ -0,0 +1,108 @@
1
+ workflow:
2
+ rules:
3
+ - if: $CI_PIPELINE_SOURCE == "merge_request_event"
4
+ - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
5
+ when: never
6
+ - if: $CI_COMMIT_BRANCH
7
+ - if: $CI_COMMIT_TAG
8
+
9
+ image: python:3.12-slim
10
+
11
+ stages:
12
+ - security-scans
13
+ - test
14
+ - gemini-review
15
+ - deploy
16
+
17
+ include:
18
+ - template: Security/SAST.gitlab-ci.yml
19
+ - template: Security/Secret-Detection.gitlab-ci.yml
20
+ - project: 'ai/ai-code-reviewer'
21
+ ref: 'master'
22
+ file: 'templates/ai-code-review.yml'
23
+
24
+ variables:
25
+ SECRET_DETECTION_ENABLED: 'true'
26
+ SAST_EXCLUDED_PATHS: "spec, tmp, target, logs, .git, .mvn, .settings, .vscode"
27
+
28
+ .test_template:
29
+ before_script:
30
+ - apt-get update -qy && apt-get install -y git
31
+ - pip install -e ".[dev]"
32
+ script:
33
+ - pytest --tb=short --cov=src/gitlab_watcher --cov-report=xml --cov-report=lcov --cov-report=term-missing
34
+ coverage: '/TOTAL.+\s+([0-9]{1,3}%)/'
35
+ artifacts:
36
+ reports:
37
+ coverage_report:
38
+ coverage_format: cobertura
39
+ path: coverage.xml
40
+ paths:
41
+ - coverage.xml
42
+ - coverage.lcov
43
+ expire_in: 1 week
44
+
45
+ test:
46
+ extends: .test_template
47
+ stage: test
48
+
49
+ .build_template:
50
+ variables:
51
+ GIT_DEPTH: "0"
52
+ before_script:
53
+ - apt-get update -qy && apt-get install -y git
54
+ - python3 -m pip install --upgrade pip build twine
55
+
56
+ deploy_test:
57
+ extends: .build_template
58
+ stage: deploy
59
+ needs: [test]
60
+ rules:
61
+ - if: $CI_COMMIT_BRANCH == "test" || ($CI_PIPELINE_SOURCE == "pipeline" && $TEST_REPOSITORY_URL)
62
+ variables:
63
+ TWINE_USERNAME: $TEST_USERNAME
64
+ TWINE_PASSWORD: $TEST_PASSWORD
65
+ TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/
66
+ script:
67
+ # Build package with sdist and wheel formats
68
+ - python3 -m build --sdist --wheel --outdir dist/
69
+ - ls -la dist/ && find dist/ -type f | sort
70
+
71
+ # Verify build integrity before upload
72
+ - twine check dist/*
73
+
74
+ # Upload to test.pypi.org with skip-existing flag for both wheel and source distributions
75
+ # This handles case where package already exists on PyPI (non-fatal, handled by --skip-existing)
76
+ - twine upload dist/* --skip-existing --repository-url https://test.pypi.org/legacy/ 2>&1
77
+
78
+ deploy_production:
79
+ extends: .build_template
80
+ stage: deploy
81
+ needs: [test]
82
+ rules:
83
+ - if: $CI_COMMIT_TAG =~ /^\d+\.\d+\.\d+$/
84
+ variables:
85
+ TWINE_USERNAME: $PRODUCTION_USERNAME
86
+ TWINE_PASSWORD: $PRODUCTION_PASSWORD
87
+ TWINE_REPOSITORY_URL: https://pypi.org/legacy/
88
+ script:
89
+ # Build package with sdist and wheel formats
90
+ - python3 -m build --sdist --wheel --outdir dist/
91
+ - ls -la dist/ && find dist/ -type f | sort
92
+
93
+ # Upload to production PyPI with skip-existing flag for both wheel and source distributions
94
+ # Use skip-existing for safety when uploading existing versions
95
+ - twine upload dist/* --skip-existing --repository-url https://upload.pypi.org/legacy/ 2>&1
96
+
97
+ # Explicit overrides for security jobs to ensure they run in correct stages and MRs
98
+ semgrep-sast:
99
+ stage: security-scans
100
+ rules:
101
+ - if: $CI_PIPELINE_SOURCE == "merge_request_event"
102
+ - if: $CI_COMMIT_BRANCH
103
+
104
+ secret_detection:
105
+ stage: security-scans
106
+ rules:
107
+ - if: $CI_PIPELINE_SOURCE == "merge_request_event"
108
+ - if: $CI_COMMIT_BRANCH
@@ -0,0 +1,85 @@
1
+ # AGENTS.md
2
+
3
+ Project ID: 32
4
+
5
+ This file provides guidance to agents (such as Claude Code or OpenCode) when working with code in this repository.
6
+
7
+ ## Project Overview
8
+
9
+ GitLab Watcher is a Python daemon that monitors GitLab projects and automatically processes issues and merge requests using Claude CLI (via `ollama launch claude`). It acts as an AI-assisted development workflow automation tool.
10
+
11
+ ## Development Commands
12
+
13
+ ```bash
14
+ # Install in development mode with dev dependencies
15
+ pip install -e ".[dev]"
16
+
17
+ # Run tests
18
+ pytest
19
+
20
+ # Run tests with coverage
21
+ pytest --cov=gitlab_watcher
22
+
23
+ # Run a single test file
24
+ pytest tests/test_watcher.py
25
+
26
+ # Run a single test
27
+ pytest tests/test_watcher.py::TestStateManager::test_save_and_load
28
+ ```
29
+
30
+ ## Architecture
31
+
32
+ The codebase follows a layered architecture with clear separation of concerns:
33
+
34
+ ```
35
+ cli.py → Entry point (Click CLI)
36
+ watcher.py → Main loop, orchestrates all monitoring
37
+ processor.py → Business logic for processing issues/MR comments
38
+ gitlab_client.py → GitLab API client (issues, MRs, notes, labels)
39
+ git_ops.py → Git operations wrapper (subprocess-based)
40
+ config.py → Bash-style config file parsing + project discovery
41
+ state.py → Per-project state persistence (JSON files)
42
+ discord.py → Discord webhook notifications
43
+ ```
44
+
45
+ ### Key Flow
46
+
47
+ 1. **Issue Processing**: When an issue assigned to the configured user lacks workflow labels:
48
+ - Adds "In progress" label → Creates branch `{iid}-{slug}` → Runs Claude CLI → Pushes → Creates MR → Moves to "Review"
49
+
50
+ 2. **MR Comment Processing**: When a new comment appears on an open MR (not from bot user):
51
+ - Checks out MR's source branch → Runs Claude CLI with comment as feedback → Pushes changes
52
+
53
+ 3. **Post-Merge Cleanup**: When MR is detected as merged or closed:
54
+ - Switches to master → Pulls → Deletes feature branch → Resets state
55
+ - Cleanup is performed if the MR was created by the watcher OR if the branch name is known to the watcher.
56
+
57
+ ### Configuration Discovery
58
+
59
+ Projects are discovered by scanning `PROJECT_DIRS` from the config file. Each project directory must contain a `PROJECT.md`, `AGENTS.md`, or `CLAUDE.md` file with a `Project ID: <number>` entry. The watcher extracts the GitLab server URL from git remote URLs if not explicitly configured, but for security reasons, the `GITLAB_TOKEN` must always be provided in the configuration file.
60
+
61
+ ### State Management
62
+
63
+ Per-project state is stored in `/tmp/gitlab-watcher/state_{project_id}.json`:
64
+ - Tracks MR IIDs, last processed note IDs, current branches
65
+ - `processing` flag prevents concurrent operations on same project
66
+ - On startup, `init_state()` resets the processing flag (crash recovery)
67
+
68
+ ### AI Tool Integration
69
+
70
+ The `_run_ai_tool()` method in `processor.py` supports multiple AI tools:
71
+ - **ollama**: `ollama launch claude -- -p --permission-mode acceptEdits "<prompt>"`
72
+ - **direct**: `claude -p --permission-mode acceptEdits "<prompt>"`
73
+ - **opencode**: `opencode "<prompt>"`
74
+ - **custom**: Configurable command with `{prompt}` and `{cwd}` placeholders
75
+ - **opencode-custom**: Configurable opencode command with `{prompt}` and `{cwd}` placeholders
76
+
77
+ All modes use a 1-hour overall timeout and a 30-minute silence timeout, and `CLAUDECODE=""` environment variable to avoid conflicts.
78
+
79
+ ### Development Guidelines
80
+
81
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for comprehensive development guidelines including:
82
+ - Testing requirements (run all tests after each task, maintain 85%+ coverage)
83
+ - Commit message guidelines (avoid conventional prefixes, use English)
84
+ - Code quality standards
85
+ - Troubleshooting tips