gitlab-watcher 1.0.2__tar.gz → 1.0.3__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.
- {gitlab_watcher-1.0.2 → gitlab_watcher-1.0.3}/PKG-INFO +10 -2
- {gitlab_watcher-1.0.2 → gitlab_watcher-1.0.3}/README.md +9 -1
- {gitlab_watcher-1.0.2 → gitlab_watcher-1.0.3}/pyproject.toml +1 -1
- {gitlab_watcher-1.0.2 → gitlab_watcher-1.0.3}/src/gitlab_watcher/config.py +2 -0
- {gitlab_watcher-1.0.2 → gitlab_watcher-1.0.3}/src/gitlab_watcher/processor.py +36 -7
- {gitlab_watcher-1.0.2 → gitlab_watcher-1.0.3}/src/gitlab_watcher/watcher.py +1 -0
- {gitlab_watcher-1.0.2 → gitlab_watcher-1.0.3}/src/gitlab_watcher.egg-info/PKG-INFO +10 -2
- {gitlab_watcher-1.0.2 → gitlab_watcher-1.0.3}/tests/test_config.py +23 -0
- {gitlab_watcher-1.0.2 → gitlab_watcher-1.0.3}/tests/test_processor.py +24 -3
- {gitlab_watcher-1.0.2 → gitlab_watcher-1.0.3}/setup.cfg +0 -0
- {gitlab_watcher-1.0.2 → gitlab_watcher-1.0.3}/src/gitlab_watcher/__init__.py +0 -0
- {gitlab_watcher-1.0.2 → gitlab_watcher-1.0.3}/src/gitlab_watcher/__main__.py +0 -0
- {gitlab_watcher-1.0.2 → gitlab_watcher-1.0.3}/src/gitlab_watcher/cache.py +0 -0
- {gitlab_watcher-1.0.2 → gitlab_watcher-1.0.3}/src/gitlab_watcher/cli.py +0 -0
- {gitlab_watcher-1.0.2 → gitlab_watcher-1.0.3}/src/gitlab_watcher/discord.py +0 -0
- {gitlab_watcher-1.0.2 → gitlab_watcher-1.0.3}/src/gitlab_watcher/exceptions.py +0 -0
- {gitlab_watcher-1.0.2 → gitlab_watcher-1.0.3}/src/gitlab_watcher/git_ops.py +0 -0
- {gitlab_watcher-1.0.2 → gitlab_watcher-1.0.3}/src/gitlab_watcher/gitlab_client.py +0 -0
- {gitlab_watcher-1.0.2 → gitlab_watcher-1.0.3}/src/gitlab_watcher/logging_utils.py +0 -0
- {gitlab_watcher-1.0.2 → gitlab_watcher-1.0.3}/src/gitlab_watcher/protocols.py +0 -0
- {gitlab_watcher-1.0.2 → gitlab_watcher-1.0.3}/src/gitlab_watcher/state.py +0 -0
- {gitlab_watcher-1.0.2 → gitlab_watcher-1.0.3}/src/gitlab_watcher.egg-info/SOURCES.txt +0 -0
- {gitlab_watcher-1.0.2 → gitlab_watcher-1.0.3}/src/gitlab_watcher.egg-info/dependency_links.txt +0 -0
- {gitlab_watcher-1.0.2 → gitlab_watcher-1.0.3}/src/gitlab_watcher.egg-info/entry_points.txt +0 -0
- {gitlab_watcher-1.0.2 → gitlab_watcher-1.0.3}/src/gitlab_watcher.egg-info/requires.txt +0 -0
- {gitlab_watcher-1.0.2 → gitlab_watcher-1.0.3}/src/gitlab_watcher.egg-info/top_level.txt +0 -0
- {gitlab_watcher-1.0.2 → gitlab_watcher-1.0.3}/tests/test_cache.py +0 -0
- {gitlab_watcher-1.0.2 → gitlab_watcher-1.0.3}/tests/test_config_extra.py +0 -0
- {gitlab_watcher-1.0.2 → gitlab_watcher-1.0.3}/tests/test_discord.py +0 -0
- {gitlab_watcher-1.0.2 → gitlab_watcher-1.0.3}/tests/test_git_ops.py +0 -0
- {gitlab_watcher-1.0.2 → gitlab_watcher-1.0.3}/tests/test_gitlab_client.py +0 -0
- {gitlab_watcher-1.0.2 → gitlab_watcher-1.0.3}/tests/test_logging_utils.py +0 -0
- {gitlab_watcher-1.0.2 → gitlab_watcher-1.0.3}/tests/test_security_hardening.py +0 -0
- {gitlab_watcher-1.0.2 → gitlab_watcher-1.0.3}/tests/test_watcher.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: gitlab-watcher
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.3
|
|
4
4
|
Summary: Monitor GitLab projects and automatically process issues and merge requests
|
|
5
5
|
Author: Gyengus
|
|
6
6
|
License-Expression: MIT
|
|
@@ -118,6 +118,9 @@ POLL_INTERVAL=30
|
|
|
118
118
|
# AI Tool implementation style (ollama, direct, opencode, custom)
|
|
119
119
|
AI_TOOL_MODE="ollama"
|
|
120
120
|
|
|
121
|
+
# Maximum execution time for AI tool in seconds (default: 3600 / 1 hour)
|
|
122
|
+
AI_TOOL_TIMEOUT=3600
|
|
123
|
+
|
|
121
124
|
# List of absolute paths to project directories to monitor
|
|
122
125
|
PROJECT_DIRS=(
|
|
123
126
|
"/path/to/project1"
|
|
@@ -141,15 +144,20 @@ The watcher supports multiple AI tools:
|
|
|
141
144
|
|------|-------------|
|
|
142
145
|
| `ollama` | Launches Claude via Ollama (requires both `ollama` and `claude`) (default) |
|
|
143
146
|
| `direct` | Direct Claude CLI execution (`claude`) |
|
|
144
|
-
| `opencode` | Opencode CLI execution
|
|
147
|
+
| `opencode` | Opencode CLI execution using `run` subcommand |
|
|
145
148
|
| `custom` | Custom command for any AI tool |
|
|
146
149
|
|
|
147
150
|
Configure in `config.conf`:
|
|
148
151
|
|
|
149
152
|
```bash
|
|
150
153
|
AI_TOOL_MODE="ollama" # or "direct", "opencode", "custom"
|
|
154
|
+
AI_TOOL_TIMEOUT=3600 # default is 1 hour
|
|
151
155
|
```
|
|
152
156
|
|
|
157
|
+
### Timeout Diagnostics
|
|
158
|
+
|
|
159
|
+
If an AI tool exceeds the configured `AI_TOOL_TIMEOUT`, the watcher will attempt to capture and display any partial output (`stdout`/`stderr`) generated before the process was terminated. This helps in diagnosing why a tool might be hanging or taking longer than expected.
|
|
160
|
+
|
|
153
161
|
## Development
|
|
154
162
|
|
|
155
163
|
```bash
|
|
@@ -90,6 +90,9 @@ POLL_INTERVAL=30
|
|
|
90
90
|
# AI Tool implementation style (ollama, direct, opencode, custom)
|
|
91
91
|
AI_TOOL_MODE="ollama"
|
|
92
92
|
|
|
93
|
+
# Maximum execution time for AI tool in seconds (default: 3600 / 1 hour)
|
|
94
|
+
AI_TOOL_TIMEOUT=3600
|
|
95
|
+
|
|
93
96
|
# List of absolute paths to project directories to monitor
|
|
94
97
|
PROJECT_DIRS=(
|
|
95
98
|
"/path/to/project1"
|
|
@@ -113,15 +116,20 @@ The watcher supports multiple AI tools:
|
|
|
113
116
|
|------|-------------|
|
|
114
117
|
| `ollama` | Launches Claude via Ollama (requires both `ollama` and `claude`) (default) |
|
|
115
118
|
| `direct` | Direct Claude CLI execution (`claude`) |
|
|
116
|
-
| `opencode` | Opencode CLI execution
|
|
119
|
+
| `opencode` | Opencode CLI execution using `run` subcommand |
|
|
117
120
|
| `custom` | Custom command for any AI tool |
|
|
118
121
|
|
|
119
122
|
Configure in `config.conf`:
|
|
120
123
|
|
|
121
124
|
```bash
|
|
122
125
|
AI_TOOL_MODE="ollama" # or "direct", "opencode", "custom"
|
|
126
|
+
AI_TOOL_TIMEOUT=3600 # default is 1 hour
|
|
123
127
|
```
|
|
124
128
|
|
|
129
|
+
### Timeout Diagnostics
|
|
130
|
+
|
|
131
|
+
If an AI tool exceeds the configured `AI_TOOL_TIMEOUT`, the watcher will attempt to capture and display any partial output (`stdout`/`stderr`) generated before the process was terminated. This helps in diagnosing why a tool might be hanging or taking longer than expected.
|
|
132
|
+
|
|
125
133
|
## Development
|
|
126
134
|
|
|
127
135
|
```bash
|
|
@@ -34,6 +34,7 @@ class Config:
|
|
|
34
34
|
poll_interval: int = 30
|
|
35
35
|
ai_tool_mode: str = "ollama"
|
|
36
36
|
ai_tool_custom_command: str = ""
|
|
37
|
+
ai_tool_timeout: int = 3600
|
|
37
38
|
default_branch: str = "master"
|
|
38
39
|
project_dirs: list[str] = field(default_factory=list)
|
|
39
40
|
projects: list[ProjectConfig] = field(default_factory=list)
|
|
@@ -173,6 +174,7 @@ def load_config(config_path: str) -> Config:
|
|
|
173
174
|
poll_interval=get_int("POLL_INTERVAL", 30),
|
|
174
175
|
ai_tool_mode=get_str("AI_TOOL_MODE", "ollama"),
|
|
175
176
|
ai_tool_custom_command=get_str("AI_TOOL_CUSTOM_COMMAND"),
|
|
177
|
+
ai_tool_timeout=get_int("AI_TOOL_TIMEOUT", 3600),
|
|
176
178
|
)
|
|
177
179
|
|
|
178
180
|
# Get project directories
|
|
@@ -30,8 +30,8 @@ MAX_DESCRIPTION_LENGTH = 50000
|
|
|
30
30
|
MAX_SLUG_LENGTH = 50
|
|
31
31
|
MAX_BRANCH_LENGTH = 100
|
|
32
32
|
|
|
33
|
-
#
|
|
34
|
-
|
|
33
|
+
# Default AI tool timeout (1 hour)
|
|
34
|
+
DEFAULT_AI_TOOL_TIMEOUT = 3600
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
class Processor:
|
|
@@ -47,6 +47,7 @@ class Processor:
|
|
|
47
47
|
label_review: str,
|
|
48
48
|
ai_tool_mode: str = "ollama",
|
|
49
49
|
ai_tool_custom_command: str = "",
|
|
50
|
+
ai_tool_timeout: int = DEFAULT_AI_TOOL_TIMEOUT,
|
|
50
51
|
default_branch: str = "master",
|
|
51
52
|
git_factory: Callable[[Path], GitOperations] = GitOps,
|
|
52
53
|
) -> None:
|
|
@@ -61,6 +62,7 @@ class Processor:
|
|
|
61
62
|
label_review: Label for issues under review
|
|
62
63
|
ai_tool_mode: AI tool mode ("ollama", "direct", "custom", "opencode", or "opencode-custom")
|
|
63
64
|
ai_tool_custom_command: Custom command for AI tool (used when mode is "custom")
|
|
65
|
+
ai_tool_timeout: Timeout for AI tool in seconds
|
|
64
66
|
default_branch: Default branch name (default: "master")
|
|
65
67
|
git_factory: Factory function to create GitOperations instances (for dependency injection)
|
|
66
68
|
"""
|
|
@@ -72,6 +74,7 @@ class Processor:
|
|
|
72
74
|
self.label_review = label_review
|
|
73
75
|
self.ai_tool_mode = ai_tool_mode
|
|
74
76
|
self.ai_tool_custom_command = ai_tool_custom_command
|
|
77
|
+
self.ai_tool_timeout = ai_tool_timeout
|
|
75
78
|
self.default_branch = default_branch
|
|
76
79
|
self.git_factory = git_factory
|
|
77
80
|
self.logger = logging.getLogger(__name__)
|
|
@@ -181,7 +184,7 @@ class Processor:
|
|
|
181
184
|
elif self.ai_tool_mode == "direct":
|
|
182
185
|
cmd = ["claude", "-p", safe_prompt, "--permission-mode", "acceptEdits"]
|
|
183
186
|
elif self.ai_tool_mode == "opencode":
|
|
184
|
-
cmd = ["opencode", "
|
|
187
|
+
cmd = ["opencode", "run", safe_prompt, "--print-logs"]
|
|
185
188
|
elif self.ai_tool_mode == "custom":
|
|
186
189
|
if not self.ai_tool_custom_command:
|
|
187
190
|
return False, "AI_TOOL_CUSTOM_COMMAND not set for custom mode"
|
|
@@ -202,13 +205,39 @@ class Processor:
|
|
|
202
205
|
capture_output=True,
|
|
203
206
|
text=True,
|
|
204
207
|
env=env,
|
|
205
|
-
timeout=
|
|
208
|
+
timeout=self.ai_tool_timeout,
|
|
206
209
|
)
|
|
207
210
|
return result.returncode == 0, result.stdout + result.stderr
|
|
208
|
-
except subprocess.TimeoutExpired:
|
|
209
|
-
|
|
211
|
+
except subprocess.TimeoutExpired as e:
|
|
212
|
+
output = ""
|
|
213
|
+
if e.stdout:
|
|
214
|
+
output += (
|
|
215
|
+
"\n--- STDOUT (partial) ---\n"
|
|
216
|
+
+ (
|
|
217
|
+
e.stdout.decode("utf-8")
|
|
218
|
+
if isinstance(e.stdout, bytes)
|
|
219
|
+
else e.stdout
|
|
220
|
+
)
|
|
221
|
+
+ "\n"
|
|
222
|
+
)
|
|
223
|
+
if e.stderr:
|
|
224
|
+
output += (
|
|
225
|
+
"\n--- STDERR (partial) ---\n"
|
|
226
|
+
+ (
|
|
227
|
+
e.stderr.decode("utf-8")
|
|
228
|
+
if isinstance(e.stderr, bytes)
|
|
229
|
+
else e.stderr
|
|
230
|
+
)
|
|
231
|
+
+ "\n"
|
|
232
|
+
)
|
|
233
|
+
|
|
234
|
+
tool_name = self.ai_tool_mode
|
|
235
|
+
if tool_name == "direct":
|
|
236
|
+
tool_name = "Claude"
|
|
237
|
+
|
|
238
|
+
return False, f"AI tool ({tool_name}) timed out after {self.ai_tool_timeout}s.{output}"
|
|
210
239
|
except FileNotFoundError:
|
|
211
|
-
return False, "
|
|
240
|
+
return False, f"AI tool CLI ({cmd[0]}) not found"
|
|
212
241
|
|
|
213
242
|
def process_issue(
|
|
214
243
|
self,
|
|
@@ -89,6 +89,7 @@ class Watcher:
|
|
|
89
89
|
label_review=self.config.label_review,
|
|
90
90
|
ai_tool_mode=self.config.ai_tool_mode,
|
|
91
91
|
ai_tool_custom_command=self.config.ai_tool_custom_command,
|
|
92
|
+
ai_tool_timeout=self.config.ai_tool_timeout,
|
|
92
93
|
default_branch=self.config.default_branch,
|
|
93
94
|
)
|
|
94
95
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: gitlab-watcher
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.3
|
|
4
4
|
Summary: Monitor GitLab projects and automatically process issues and merge requests
|
|
5
5
|
Author: Gyengus
|
|
6
6
|
License-Expression: MIT
|
|
@@ -118,6 +118,9 @@ POLL_INTERVAL=30
|
|
|
118
118
|
# AI Tool implementation style (ollama, direct, opencode, custom)
|
|
119
119
|
AI_TOOL_MODE="ollama"
|
|
120
120
|
|
|
121
|
+
# Maximum execution time for AI tool in seconds (default: 3600 / 1 hour)
|
|
122
|
+
AI_TOOL_TIMEOUT=3600
|
|
123
|
+
|
|
121
124
|
# List of absolute paths to project directories to monitor
|
|
122
125
|
PROJECT_DIRS=(
|
|
123
126
|
"/path/to/project1"
|
|
@@ -141,15 +144,20 @@ The watcher supports multiple AI tools:
|
|
|
141
144
|
|------|-------------|
|
|
142
145
|
| `ollama` | Launches Claude via Ollama (requires both `ollama` and `claude`) (default) |
|
|
143
146
|
| `direct` | Direct Claude CLI execution (`claude`) |
|
|
144
|
-
| `opencode` | Opencode CLI execution
|
|
147
|
+
| `opencode` | Opencode CLI execution using `run` subcommand |
|
|
145
148
|
| `custom` | Custom command for any AI tool |
|
|
146
149
|
|
|
147
150
|
Configure in `config.conf`:
|
|
148
151
|
|
|
149
152
|
```bash
|
|
150
153
|
AI_TOOL_MODE="ollama" # or "direct", "opencode", "custom"
|
|
154
|
+
AI_TOOL_TIMEOUT=3600 # default is 1 hour
|
|
151
155
|
```
|
|
152
156
|
|
|
157
|
+
### Timeout Diagnostics
|
|
158
|
+
|
|
159
|
+
If an AI tool exceeds the configured `AI_TOOL_TIMEOUT`, the watcher will attempt to capture and display any partial output (`stdout`/`stderr`) generated before the process was terminated. This helps in diagnosing why a tool might be hanging or taking longer than expected.
|
|
160
|
+
|
|
153
161
|
## Development
|
|
154
162
|
|
|
155
163
|
```bash
|
|
@@ -199,3 +199,26 @@ PROJECT_DIRS=(
|
|
|
199
199
|
|
|
200
200
|
assert config.ai_tool_mode == "ollama"
|
|
201
201
|
assert config.ai_tool_custom_command == ""
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
def test_load_config_with_timeout(tmp_path: Path) -> None:
|
|
205
|
+
"""Test loading config with AI_TOOL_TIMEOUT."""
|
|
206
|
+
config_file = tmp_path / "gitlab_watcher.conf"
|
|
207
|
+
config_file.write_text(
|
|
208
|
+
"""
|
|
209
|
+
GITLAB_URL="https://git.example.com"
|
|
210
|
+
GITLAB_TOKEN="test-token"
|
|
211
|
+
AI_TOOL_TIMEOUT=1234
|
|
212
|
+
PROJECT_DIRS=(
|
|
213
|
+
"{}"
|
|
214
|
+
)
|
|
215
|
+
""".format(tmp_path / "project")
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
project_dir = tmp_path / "project"
|
|
219
|
+
project_dir.mkdir()
|
|
220
|
+
(project_dir / "CLAUDE.md").write_text("Project ID: 42\n")
|
|
221
|
+
|
|
222
|
+
config = load_config(str(config_file))
|
|
223
|
+
|
|
224
|
+
assert config.ai_tool_timeout == 1234
|
|
@@ -131,12 +131,32 @@ class TestProcessorRunClaude:
|
|
|
131
131
|
project_config: ProjectConfig,
|
|
132
132
|
) -> None:
|
|
133
133
|
"""Test Claude timeout."""
|
|
134
|
-
mock_run.side_effect = subprocess.TimeoutExpired(cmd="ollama", timeout=
|
|
134
|
+
mock_run.side_effect = subprocess.TimeoutExpired(cmd="ollama", timeout=3600)
|
|
135
135
|
|
|
136
136
|
success, output = processor._run_claude("Fix the bug", project_config.path)
|
|
137
137
|
|
|
138
138
|
assert success is False
|
|
139
139
|
assert "timed out" in output.lower()
|
|
140
|
+
assert "ollama" in output
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
@patch("subprocess.run")
|
|
144
|
+
def test_run_claude_timeout_with_output(
|
|
145
|
+
self,
|
|
146
|
+
mock_run: Mock,
|
|
147
|
+
processor: Processor,
|
|
148
|
+
project_config: ProjectConfig,
|
|
149
|
+
) -> None:
|
|
150
|
+
"""Test Claude timeout with partial output."""
|
|
151
|
+
mock_run.side_effect = subprocess.TimeoutExpired(
|
|
152
|
+
cmd="ollama", timeout=3600, output="Partial output", stderr="Some error"
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
success, output = processor._run_claude("Fix the bug", project_config.path)
|
|
156
|
+
|
|
157
|
+
assert success is False
|
|
158
|
+
assert "Partial output" in output
|
|
159
|
+
assert "Some error" in output
|
|
140
160
|
|
|
141
161
|
@patch("subprocess.run")
|
|
142
162
|
def test_run_claude_not_found(
|
|
@@ -304,8 +324,9 @@ class TestProcessorAIToolModes:
|
|
|
304
324
|
assert success is True
|
|
305
325
|
args = mock_run.call_args[0][0]
|
|
306
326
|
assert args[0] == "opencode"
|
|
307
|
-
assert args[1] == "
|
|
308
|
-
assert
|
|
327
|
+
assert args[1] == "run"
|
|
328
|
+
assert "Fix the bug" in args
|
|
329
|
+
assert "--print-logs" in args
|
|
309
330
|
|
|
310
331
|
def test_run_claude_invalid_mode(
|
|
311
332
|
self,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{gitlab_watcher-1.0.2 → gitlab_watcher-1.0.3}/src/gitlab_watcher.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|