opencode-pilot 0.1.0 → 0.2.1

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.
@@ -1,179 +0,0 @@
1
- #!/usr/bin/env bash
2
- #
3
- # Tests for poll-service.js - Polling orchestration service
4
- #
5
-
6
- set -euo pipefail
7
-
8
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
9
- source "$SCRIPT_DIR/test_helper.bash"
10
-
11
- SERVICE_DIR="$(dirname "$SCRIPT_DIR")/service"
12
-
13
- echo "Testing poll-service.js module..."
14
- echo ""
15
-
16
- # =============================================================================
17
- # File Structure Tests
18
- # =============================================================================
19
-
20
- test_poll_service_file_exists() {
21
- assert_file_exists "$SERVICE_DIR/poll-service.js"
22
- }
23
-
24
- test_poll_service_js_syntax() {
25
- if ! command -v node &>/dev/null; then
26
- echo "SKIP: node not available"
27
- return 0
28
- fi
29
- node --check "$SERVICE_DIR/poll-service.js" 2>&1 || {
30
- echo "poll-service.js has syntax errors"
31
- return 1
32
- }
33
- }
34
-
35
- # =============================================================================
36
- # Export Tests
37
- # =============================================================================
38
-
39
- test_poll_service_exports_start() {
40
- grep -q "export.*function startPolling\|export.*startPolling" "$SERVICE_DIR/poll-service.js" || {
41
- echo "startPolling export not found"
42
- return 1
43
- }
44
- }
45
-
46
- test_poll_service_exports_stop() {
47
- grep -q "export.*function stopPolling\|export.*stopPolling" "$SERVICE_DIR/poll-service.js" || {
48
- echo "stopPolling export not found"
49
- return 1
50
- }
51
- }
52
-
53
- test_poll_service_exports_poll_once() {
54
- grep -q "export.*function pollOnce\|export.*pollOnce" "$SERVICE_DIR/poll-service.js" || {
55
- echo "pollOnce export not found"
56
- return 1
57
- }
58
- }
59
-
60
- # =============================================================================
61
- # Implementation Tests
62
- # =============================================================================
63
-
64
- test_poll_service_uses_repo_config() {
65
- grep -q "repo-config\|getRepoConfig\|getAllSources" "$SERVICE_DIR/poll-service.js" || {
66
- echo "repo-config usage not found"
67
- return 1
68
- }
69
- }
70
-
71
- test_poll_service_uses_poller() {
72
- grep -q "poller\|pollSource" "$SERVICE_DIR/poll-service.js" || {
73
- echo "poller usage not found"
74
- return 1
75
- }
76
- }
77
-
78
- test_poll_service_uses_readiness() {
79
- grep -q "readiness\|evaluateReadiness" "$SERVICE_DIR/poll-service.js" || {
80
- echo "readiness usage not found"
81
- return 1
82
- }
83
- }
84
-
85
- test_poll_service_uses_actions() {
86
- grep -q "actions\|executeAction" "$SERVICE_DIR/poll-service.js" || {
87
- echo "actions usage not found"
88
- return 1
89
- }
90
- }
91
-
92
- test_poll_service_tracks_processed() {
93
- grep -q "isProcessed\|markProcessed" "$SERVICE_DIR/poll-service.js" || {
94
- echo "Processed tracking not found"
95
- return 1
96
- }
97
- }
98
-
99
- # =============================================================================
100
- # Functional Tests
101
- # =============================================================================
102
-
103
- test_poll_service_dry_run() {
104
- if ! command -v node &>/dev/null; then
105
- echo "SKIP: node not available"
106
- return 0
107
- fi
108
-
109
- local result
110
- result=$(node --experimental-vm-modules -e "
111
- import { pollOnce } from './service/poll-service.js';
112
-
113
- // Run with dry-run flag (no actual polling)
114
- const results = await pollOnce({ dryRun: true, skipMcp: true });
115
-
116
- // Should return results array (even if empty)
117
- if (!Array.isArray(results)) {
118
- console.log('FAIL: pollOnce should return an array');
119
- process.exit(1);
120
- }
121
- console.log('PASS');
122
- " 2>&1) || {
123
- echo "Functional test failed: $result"
124
- return 1
125
- }
126
-
127
- if ! echo "$result" | grep -q "PASS"; then
128
- echo "$result"
129
- return 1
130
- fi
131
- }
132
-
133
- # =============================================================================
134
- # Run Tests
135
- # =============================================================================
136
-
137
- echo "File Structure Tests:"
138
-
139
- for test_func in \
140
- test_poll_service_file_exists \
141
- test_poll_service_js_syntax
142
- do
143
- run_test "${test_func#test_}" "$test_func"
144
- done
145
-
146
- echo ""
147
- echo "Export Tests:"
148
-
149
- for test_func in \
150
- test_poll_service_exports_start \
151
- test_poll_service_exports_stop \
152
- test_poll_service_exports_poll_once
153
- do
154
- run_test "${test_func#test_}" "$test_func"
155
- done
156
-
157
- echo ""
158
- echo "Implementation Tests:"
159
-
160
- for test_func in \
161
- test_poll_service_uses_repo_config \
162
- test_poll_service_uses_poller \
163
- test_poll_service_uses_readiness \
164
- test_poll_service_uses_actions \
165
- test_poll_service_tracks_processed
166
- do
167
- run_test "${test_func#test_}" "$test_func"
168
- done
169
-
170
- echo ""
171
- echo "Functional Tests:"
172
-
173
- for test_func in \
174
- test_poll_service_dry_run
175
- do
176
- run_test "${test_func#test_}" "$test_func"
177
- done
178
-
179
- print_summary
@@ -1,120 +0,0 @@
1
- #!/usr/bin/env bash
2
- #
3
- # Tests for poller.js - MCP-based polling for automation sources
4
- #
5
-
6
- set -euo pipefail
7
-
8
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
9
- source "$SCRIPT_DIR/test_helper.bash"
10
-
11
- SERVICE_DIR="$(dirname "$SCRIPT_DIR")/service"
12
-
13
- echo "Testing poller.js module..."
14
- echo ""
15
-
16
- # =============================================================================
17
- # File Structure Tests
18
- # =============================================================================
19
-
20
- test_poller_file_exists() {
21
- assert_file_exists "$SERVICE_DIR/poller.js"
22
- }
23
-
24
- test_poller_js_syntax() {
25
- if ! command -v node &>/dev/null; then
26
- echo "SKIP: node not available"
27
- return 0
28
- fi
29
- node --check "$SERVICE_DIR/poller.js" 2>&1 || {
30
- echo "poller.js has syntax errors"
31
- return 1
32
- }
33
- }
34
-
35
- # =============================================================================
36
- # Export Tests
37
- # =============================================================================
38
-
39
- test_poller_exports_create_poller() {
40
- grep -q "export.*function createPoller\|export.*createPoller" "$SERVICE_DIR/poller.js" || {
41
- echo "createPoller export not found in poller.js"
42
- return 1
43
- }
44
- }
45
-
46
- test_poller_exports_poll_source() {
47
- grep -q "export.*function pollSource\|export.*pollSource" "$SERVICE_DIR/poller.js" || {
48
- echo "pollSource export not found in poller.js"
49
- return 1
50
- }
51
- }
52
-
53
- # =============================================================================
54
- # Implementation Tests
55
- # =============================================================================
56
-
57
- test_poller_supports_github_issues() {
58
- grep -q "github_issue\|github-issue" "$SERVICE_DIR/poller.js" || {
59
- echo "GitHub issue source type not found in poller.js"
60
- return 1
61
- }
62
- }
63
-
64
- test_poller_supports_linear_issues() {
65
- grep -q "linear_issue\|linear-issue" "$SERVICE_DIR/poller.js" || {
66
- echo "Linear issue source type not found in poller.js"
67
- return 1
68
- }
69
- }
70
-
71
- test_poller_uses_mcp_client() {
72
- grep -q "@modelcontextprotocol/sdk" "$SERVICE_DIR/poller.js" || {
73
- echo "MCP SDK import not found in poller.js"
74
- return 1
75
- }
76
- }
77
-
78
- test_poller_tracks_processed_items() {
79
- grep -q "processed\|state\|seen" "$SERVICE_DIR/poller.js" || {
80
- echo "Processed items tracking not found in poller.js"
81
- return 1
82
- }
83
- }
84
-
85
- # =============================================================================
86
- # Run Tests
87
- # =============================================================================
88
-
89
- echo "File Structure Tests:"
90
-
91
- for test_func in \
92
- test_poller_file_exists \
93
- test_poller_js_syntax
94
- do
95
- run_test "${test_func#test_}" "$test_func"
96
- done
97
-
98
- echo ""
99
- echo "Export Tests:"
100
-
101
- for test_func in \
102
- test_poller_exports_create_poller \
103
- test_poller_exports_poll_source
104
- do
105
- run_test "${test_func#test_}" "$test_func"
106
- done
107
-
108
- echo ""
109
- echo "Implementation Tests:"
110
-
111
- for test_func in \
112
- test_poller_supports_github_issues \
113
- test_poller_supports_linear_issues \
114
- test_poller_uses_mcp_client \
115
- test_poller_tracks_processed_items
116
- do
117
- run_test "${test_func#test_}" "$test_func"
118
- done
119
-
120
- print_summary
@@ -1,313 +0,0 @@
1
- #!/usr/bin/env bash
2
- #
3
- # Tests for readiness.js - Issue readiness evaluation for self-iteration
4
- #
5
-
6
- set -euo pipefail
7
-
8
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
9
- source "$SCRIPT_DIR/test_helper.bash"
10
-
11
- SERVICE_DIR="$(dirname "$SCRIPT_DIR")/service"
12
-
13
- echo "Testing readiness.js module..."
14
- echo ""
15
-
16
- # =============================================================================
17
- # File Structure Tests
18
- # =============================================================================
19
-
20
- test_readiness_file_exists() {
21
- assert_file_exists "$SERVICE_DIR/readiness.js"
22
- }
23
-
24
- test_readiness_js_syntax() {
25
- if ! command -v node &>/dev/null; then
26
- echo "SKIP: node not available"
27
- return 0
28
- fi
29
- node --check "$SERVICE_DIR/readiness.js" 2>&1 || {
30
- echo "readiness.js has syntax errors"
31
- return 1
32
- }
33
- }
34
-
35
- # =============================================================================
36
- # Export Tests
37
- # =============================================================================
38
-
39
- test_readiness_exports_evaluate() {
40
- grep -q "export.*function evaluateReadiness\|export.*evaluateReadiness" "$SERVICE_DIR/readiness.js" || {
41
- echo "evaluateReadiness export not found"
42
- return 1
43
- }
44
- }
45
-
46
- test_readiness_exports_check_labels() {
47
- grep -q "export.*function checkLabels\|export.*checkLabels" "$SERVICE_DIR/readiness.js" || {
48
- echo "checkLabels export not found"
49
- return 1
50
- }
51
- }
52
-
53
- test_readiness_exports_check_dependencies() {
54
- grep -q "export.*function checkDependencies\|export.*checkDependencies" "$SERVICE_DIR/readiness.js" || {
55
- echo "checkDependencies export not found"
56
- return 1
57
- }
58
- }
59
-
60
- test_readiness_exports_calculate_priority() {
61
- grep -q "export.*function calculatePriority\|export.*calculatePriority" "$SERVICE_DIR/readiness.js" || {
62
- echo "calculatePriority export not found"
63
- return 1
64
- }
65
- }
66
-
67
- # =============================================================================
68
- # Implementation Tests
69
- # =============================================================================
70
-
71
- test_readiness_checks_blocking_labels() {
72
- grep -q "block\|exclude" "$SERVICE_DIR/readiness.js" || {
73
- echo "Blocking label check not found"
74
- return 1
75
- }
76
- }
77
-
78
- test_readiness_checks_body_references() {
79
- grep -q "blocked by\|depends on\|body" "$SERVICE_DIR/readiness.js" || {
80
- echo "Body reference check not found"
81
- return 1
82
- }
83
- }
84
-
85
- test_readiness_calculates_priority_score() {
86
- grep -q "priority\|score\|weight" "$SERVICE_DIR/readiness.js" || {
87
- echo "Priority calculation not found"
88
- return 1
89
- }
90
- }
91
-
92
- # =============================================================================
93
- # Functional Tests
94
- # =============================================================================
95
-
96
- test_readiness_blocked_by_label() {
97
- if ! command -v node &>/dev/null; then
98
- echo "SKIP: node not available"
99
- return 0
100
- fi
101
-
102
- local result
103
- result=$(node --experimental-vm-modules -e "
104
- import { checkLabels } from './service/readiness.js';
105
-
106
- const issue = {
107
- labels: [{ name: 'blocked' }, { name: 'bug' }]
108
- };
109
-
110
- const config = {
111
- readiness: {
112
- labels: {
113
- exclude: ['blocked', 'wontfix']
114
- }
115
- }
116
- };
117
-
118
- const result = checkLabels(issue, config);
119
-
120
- if (result.ready !== false) {
121
- console.log('FAIL: Issue with blocked label should not be ready');
122
- process.exit(1);
123
- }
124
- if (!result.reason.includes('blocked')) {
125
- console.log('FAIL: Reason should mention blocked label');
126
- process.exit(1);
127
- }
128
- console.log('PASS');
129
- " 2>&1) || {
130
- echo "Functional test failed: $result"
131
- return 1
132
- }
133
-
134
- if ! echo "$result" | grep -q "PASS"; then
135
- echo "$result"
136
- return 1
137
- fi
138
- }
139
-
140
- test_readiness_passes_without_blocking_labels() {
141
- if ! command -v node &>/dev/null; then
142
- echo "SKIP: node not available"
143
- return 0
144
- fi
145
-
146
- local result
147
- result=$(node --experimental-vm-modules -e "
148
- import { checkLabels } from './service/readiness.js';
149
-
150
- const issue = {
151
- labels: [{ name: 'enhancement' }, { name: 'good first issue' }]
152
- };
153
-
154
- const config = {
155
- readiness: {
156
- labels: {
157
- exclude: ['blocked', 'wontfix']
158
- }
159
- }
160
- };
161
-
162
- const result = checkLabels(issue, config);
163
-
164
- if (result.ready !== true) {
165
- console.log('FAIL: Issue without blocked labels should be ready');
166
- process.exit(1);
167
- }
168
- console.log('PASS');
169
- " 2>&1) || {
170
- echo "Functional test failed: $result"
171
- return 1
172
- }
173
-
174
- if ! echo "$result" | grep -q "PASS"; then
175
- echo "$result"
176
- return 1
177
- fi
178
- }
179
-
180
- test_readiness_blocked_by_dependency() {
181
- if ! command -v node &>/dev/null; then
182
- echo "SKIP: node not available"
183
- return 0
184
- fi
185
-
186
- local result
187
- result=$(node --experimental-vm-modules -e "
188
- import { checkDependencies } from './service/readiness.js';
189
-
190
- const issue = {
191
- body: 'This feature is blocked by #123 which needs to be done first.'
192
- };
193
-
194
- const config = {
195
- readiness: {
196
- dependencies: {
197
- check_body_references: true
198
- }
199
- }
200
- };
201
-
202
- const result = checkDependencies(issue, config);
203
-
204
- if (result.ready !== false) {
205
- console.log('FAIL: Issue with dependency reference should not be ready');
206
- process.exit(1);
207
- }
208
- console.log('PASS');
209
- " 2>&1) || {
210
- echo "Functional test failed: $result"
211
- return 1
212
- }
213
-
214
- if ! echo "$result" | grep -q "PASS"; then
215
- echo "$result"
216
- return 1
217
- fi
218
- }
219
-
220
- test_readiness_priority_calculation() {
221
- if ! command -v node &>/dev/null; then
222
- echo "SKIP: node not available"
223
- return 0
224
- fi
225
-
226
- local result
227
- result=$(node --experimental-vm-modules -e "
228
- import { calculatePriority } from './service/readiness.js';
229
-
230
- const issue = {
231
- labels: [{ name: 'critical' }, { name: 'bug' }],
232
- created_at: new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString() // 7 days old
233
- };
234
-
235
- const config = {
236
- readiness: {
237
- priority: {
238
- labels: [
239
- { label: 'critical', weight: 100 },
240
- { label: 'high', weight: 50 }
241
- ],
242
- age_weight: 1
243
- }
244
- }
245
- };
246
-
247
- const score = calculatePriority(issue, config);
248
-
249
- if (score < 100) {
250
- console.log('FAIL: Critical issue should have score >= 100, got ' + score);
251
- process.exit(1);
252
- }
253
- console.log('PASS');
254
- " 2>&1) || {
255
- echo "Functional test failed: $result"
256
- return 1
257
- }
258
-
259
- if ! echo "$result" | grep -q "PASS"; then
260
- echo "$result"
261
- return 1
262
- fi
263
- }
264
-
265
- # =============================================================================
266
- # Run Tests
267
- # =============================================================================
268
-
269
- echo "File Structure Tests:"
270
-
271
- for test_func in \
272
- test_readiness_file_exists \
273
- test_readiness_js_syntax
274
- do
275
- run_test "${test_func#test_}" "$test_func"
276
- done
277
-
278
- echo ""
279
- echo "Export Tests:"
280
-
281
- for test_func in \
282
- test_readiness_exports_evaluate \
283
- test_readiness_exports_check_labels \
284
- test_readiness_exports_check_dependencies \
285
- test_readiness_exports_calculate_priority
286
- do
287
- run_test "${test_func#test_}" "$test_func"
288
- done
289
-
290
- echo ""
291
- echo "Implementation Tests:"
292
-
293
- for test_func in \
294
- test_readiness_checks_blocking_labels \
295
- test_readiness_checks_body_references \
296
- test_readiness_calculates_priority_score
297
- do
298
- run_test "${test_func#test_}" "$test_func"
299
- done
300
-
301
- echo ""
302
- echo "Functional Tests:"
303
-
304
- for test_func in \
305
- test_readiness_blocked_by_label \
306
- test_readiness_passes_without_blocking_labels \
307
- test_readiness_blocked_by_dependency \
308
- test_readiness_priority_calculation
309
- do
310
- run_test "${test_func#test_}" "$test_func"
311
- done
312
-
313
- print_summary