opencode-pilot 0.1.0
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.
- package/.devcontainer/devcontainer.json +16 -0
- package/.github/workflows/ci.yml +67 -0
- package/.releaserc.cjs +28 -0
- package/AGENTS.md +71 -0
- package/CONTRIBUTING.md +102 -0
- package/LICENSE +21 -0
- package/README.md +72 -0
- package/bin/opencode-pilot +809 -0
- package/dist/opencode-ntfy.tar.gz +0 -0
- package/examples/config.yaml +73 -0
- package/examples/templates/default.md +7 -0
- package/examples/templates/devcontainer.md +7 -0
- package/examples/templates/review-feedback.md +7 -0
- package/examples/templates/review.md +15 -0
- package/install.sh +246 -0
- package/package.json +40 -0
- package/plugin/config.js +76 -0
- package/plugin/index.js +260 -0
- package/plugin/logger.js +125 -0
- package/plugin/notifier.js +110 -0
- package/service/actions.js +334 -0
- package/service/io.opencode.ntfy.plist +29 -0
- package/service/logger.js +82 -0
- package/service/poll-service.js +246 -0
- package/service/poller.js +339 -0
- package/service/readiness.js +234 -0
- package/service/repo-config.js +222 -0
- package/service/server.js +1523 -0
- package/service/utils.js +21 -0
- package/test/run_tests.bash +34 -0
- package/test/test_actions.bash +263 -0
- package/test/test_cli.bash +161 -0
- package/test/test_config.bash +438 -0
- package/test/test_helper.bash +140 -0
- package/test/test_logger.bash +401 -0
- package/test/test_notifier.bash +310 -0
- package/test/test_plist.bash +125 -0
- package/test/test_plugin.bash +952 -0
- package/test/test_poll_service.bash +179 -0
- package/test/test_poller.bash +120 -0
- package/test/test_readiness.bash +313 -0
- package/test/test_repo_config.bash +406 -0
- package/test/test_service.bash +1342 -0
- package/test/unit/actions.test.js +235 -0
- package/test/unit/config.test.js +86 -0
- package/test/unit/paths.test.js +77 -0
- package/test/unit/poll-service.test.js +142 -0
- package/test/unit/poller.test.js +347 -0
- package/test/unit/repo-config.test.js +441 -0
- package/test/unit/utils.test.js +53 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "opencode-pilot",
|
|
3
|
+
"image": "mcr.microsoft.com/devcontainers/javascript-node:22",
|
|
4
|
+
"features": {
|
|
5
|
+
"ghcr.io/devcontainers/features/git:1": {},
|
|
6
|
+
"ghcr.io/devcontainers/features/github-cli:1": {}
|
|
7
|
+
},
|
|
8
|
+
"postCreateCommand": "sudo apt-get update && sudo apt-get install -y bats ripgrep && npm install -g opencode-ai@latest",
|
|
9
|
+
"customizations": {
|
|
10
|
+
"vscode": {
|
|
11
|
+
"extensions": [
|
|
12
|
+
"dbaeumer.vscode-eslint"
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: write
|
|
11
|
+
id-token: write # Enable OIDC for npm trusted publishing
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
test:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
with:
|
|
19
|
+
fetch-depth: 0
|
|
20
|
+
|
|
21
|
+
- name: Setup Node.js
|
|
22
|
+
uses: actions/setup-node@v4
|
|
23
|
+
with:
|
|
24
|
+
node-version: '22'
|
|
25
|
+
|
|
26
|
+
- name: Install dependencies
|
|
27
|
+
run: npm install
|
|
28
|
+
|
|
29
|
+
- name: Verify JavaScript syntax
|
|
30
|
+
run: |
|
|
31
|
+
for file in plugin/*.js; do
|
|
32
|
+
echo "Checking $file..."
|
|
33
|
+
node --check "$file"
|
|
34
|
+
done
|
|
35
|
+
|
|
36
|
+
- name: Run unit tests
|
|
37
|
+
run: npm test
|
|
38
|
+
|
|
39
|
+
# Note: Bash integration tests removed pending conversion to JS (see #63)
|
|
40
|
+
# The JS unit tests in test/unit/ provide coverage for core functionality
|
|
41
|
+
|
|
42
|
+
release:
|
|
43
|
+
needs: test
|
|
44
|
+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
45
|
+
runs-on: ubuntu-latest
|
|
46
|
+
outputs:
|
|
47
|
+
new_release_published: ${{ steps.semantic.outputs.new_release_published }}
|
|
48
|
+
new_release_version: ${{ steps.semantic.outputs.new_release_version }}
|
|
49
|
+
steps:
|
|
50
|
+
- uses: actions/checkout@v4
|
|
51
|
+
with:
|
|
52
|
+
fetch-depth: 0
|
|
53
|
+
|
|
54
|
+
- name: Setup Node.js
|
|
55
|
+
uses: actions/setup-node@v4
|
|
56
|
+
with:
|
|
57
|
+
node-version: '22'
|
|
58
|
+
|
|
59
|
+
- name: Install Node.js dependencies
|
|
60
|
+
run: npm install
|
|
61
|
+
|
|
62
|
+
- name: Run semantic-release
|
|
63
|
+
id: semantic
|
|
64
|
+
uses: cycjimmy/semantic-release-action@v4
|
|
65
|
+
env:
|
|
66
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
67
|
+
NPM_CONFIG_PROVENANCE: true
|
package/.releaserc.cjs
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
branches: [
|
|
3
|
+
'main'
|
|
4
|
+
],
|
|
5
|
+
|
|
6
|
+
plugins: [
|
|
7
|
+
// Analyze commits to determine release type
|
|
8
|
+
'@semantic-release/commit-analyzer',
|
|
9
|
+
|
|
10
|
+
// Generate release notes
|
|
11
|
+
'@semantic-release/release-notes-generator',
|
|
12
|
+
|
|
13
|
+
// Update version in package.json and publish to npm with provenance
|
|
14
|
+
['@semantic-release/npm', { provenance: true }],
|
|
15
|
+
|
|
16
|
+
// Commit the version changes
|
|
17
|
+
[
|
|
18
|
+
'@semantic-release/git',
|
|
19
|
+
{
|
|
20
|
+
assets: ['package.json', 'package-lock.json'],
|
|
21
|
+
message: 'chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}'
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
|
|
25
|
+
// Create GitHub release
|
|
26
|
+
'@semantic-release/github'
|
|
27
|
+
]
|
|
28
|
+
};
|
package/AGENTS.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Agent Instructions
|
|
2
|
+
|
|
3
|
+
## Pre-Commit: Documentation Check
|
|
4
|
+
|
|
5
|
+
Before committing changes, verify documentation is updated to reflect code changes:
|
|
6
|
+
|
|
7
|
+
1. **README.md** - Update if changes affect:
|
|
8
|
+
- Configuration options (config.yaml keys)
|
|
9
|
+
- CLI commands (`opencode-pilot <command>`)
|
|
10
|
+
- Notification types or behavior
|
|
11
|
+
- Installation or setup steps
|
|
12
|
+
- Service management
|
|
13
|
+
- Sources or polling behavior
|
|
14
|
+
|
|
15
|
+
2. **CONTRIBUTING.md** - Update if changes affect:
|
|
16
|
+
- Development setup or workflow
|
|
17
|
+
- Test commands or patterns
|
|
18
|
+
- Plugin architecture
|
|
19
|
+
|
|
20
|
+
## Post-PR: Release and Upgrade Workflow
|
|
21
|
+
|
|
22
|
+
After a PR is merged to main, follow this workflow to upgrade the local installation:
|
|
23
|
+
|
|
24
|
+
### 1. Watch CI Run
|
|
25
|
+
|
|
26
|
+
Watch the CI workflow until it completes (creates release via semantic-release and publishes to npm):
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
gh run watch -R athal7/opencode-pilot
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### 2. Verify Release Created
|
|
33
|
+
|
|
34
|
+
Confirm the new release was published:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
gh release list -R athal7/opencode-pilot -L 1
|
|
38
|
+
npm view opencode-pilot version
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### 3. Restart OpenCode
|
|
42
|
+
|
|
43
|
+
OpenCode auto-updates npm plugins. Simply restart any running OpenCode sessions to get the latest version.
|
|
44
|
+
|
|
45
|
+
### 4. Restart Service
|
|
46
|
+
|
|
47
|
+
If the callback service is running, restart it:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# Stop current service (Ctrl+C) and restart
|
|
51
|
+
npx opencode-pilot start
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### 5. Verify Upgrade
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
npx opencode-pilot status
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Configuration
|
|
61
|
+
|
|
62
|
+
Config file: `~/.config/opencode-pilot/config.yaml`
|
|
63
|
+
|
|
64
|
+
Configuration has three sections:
|
|
65
|
+
- `notifications` - ntfy settings (topic, server, callback, etc.)
|
|
66
|
+
- `repos` - per-repository settings (use YAML anchors to share config)
|
|
67
|
+
- `sources` - polling sources with generic MCP tool references
|
|
68
|
+
|
|
69
|
+
Template files: `~/.config/opencode-pilot/templates/*.md`
|
|
70
|
+
|
|
71
|
+
See [examples/config.yaml](examples/config.yaml) for a complete example.
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Contributing to opencode-ntfy
|
|
2
|
+
|
|
3
|
+
Thanks for your interest in contributing!
|
|
4
|
+
|
|
5
|
+
## Development Setup
|
|
6
|
+
|
|
7
|
+
1. Clone the repository:
|
|
8
|
+
```bash
|
|
9
|
+
git clone https://github.com/athal7/opencode-ntfy.git
|
|
10
|
+
cd opencode-ntfy
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
2. Install the plugin locally for testing:
|
|
14
|
+
```bash
|
|
15
|
+
./install.sh
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
3. Set required environment variables:
|
|
19
|
+
```bash
|
|
20
|
+
export NTFY_TOPIC=your-test-topic
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Running Tests
|
|
24
|
+
|
|
25
|
+
Run the full test suite:
|
|
26
|
+
```bash
|
|
27
|
+
./test/run_tests.bash
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
The test suite includes:
|
|
31
|
+
- **File structure tests** - Verify all plugin files exist
|
|
32
|
+
- **Syntax validation** - Run `node --check` on all JS files
|
|
33
|
+
- **Export structure tests** - Verify expected functions are exported
|
|
34
|
+
- **Integration tests** - Test plugin loads in OpenCode without hanging (requires opencode CLI)
|
|
35
|
+
|
|
36
|
+
## Writing Tests
|
|
37
|
+
|
|
38
|
+
Tests live in `test/` using bash test helpers from `test_helper.bash`.
|
|
39
|
+
|
|
40
|
+
Example test:
|
|
41
|
+
```bash
|
|
42
|
+
test_my_feature() {
|
|
43
|
+
# Use assertions from test_helper.bash
|
|
44
|
+
assert_file_exists "$PLUGIN_DIR/myfile.js"
|
|
45
|
+
assert_contains "$output" "expected string"
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
# Register and run
|
|
49
|
+
run_test "my_feature" "test_my_feature"
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
For JavaScript unit tests, use Node.js inline:
|
|
53
|
+
```bash
|
|
54
|
+
test_function_works() {
|
|
55
|
+
node --input-type=module -e "
|
|
56
|
+
import { myFunction } from '../plugin/module.js';
|
|
57
|
+
if (myFunction() !== 'expected') throw new Error('Failed');
|
|
58
|
+
console.log('PASS');
|
|
59
|
+
" || return 1
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Code Style
|
|
64
|
+
|
|
65
|
+
- Use ES modules (`import`/`export`)
|
|
66
|
+
- Use `async`/`await` for async operations
|
|
67
|
+
- Log with `[opencode-ntfy]` prefix
|
|
68
|
+
- Handle errors gracefully (log, don't crash OpenCode)
|
|
69
|
+
- No external dependencies (use Node.js built-ins only)
|
|
70
|
+
|
|
71
|
+
## Plugin Architecture
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
plugin/
|
|
75
|
+
├── index.js # Main entry point, event handlers
|
|
76
|
+
├── notifier.js # ntfy HTTP client
|
|
77
|
+
├── callback.js # HTTP callback server for interactive responses
|
|
78
|
+
├── hostname.js # Callback host discovery (Tailscale, env, localhost)
|
|
79
|
+
└── nonces.js # Single-use nonces for callback authentication
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Submitting Changes
|
|
83
|
+
|
|
84
|
+
1. Create a feature branch: `git checkout -b my-feature`
|
|
85
|
+
2. Make your changes
|
|
86
|
+
3. Run tests: `./test/run_tests.bash`
|
|
87
|
+
4. Commit with a clear message following conventional commits:
|
|
88
|
+
- `feat(#1): add idle notifications`
|
|
89
|
+
- `fix(#3): handle network timeout`
|
|
90
|
+
5. Push and open a pull request
|
|
91
|
+
|
|
92
|
+
## Releasing
|
|
93
|
+
|
|
94
|
+
Releases are automated via GitHub Actions. To create a release:
|
|
95
|
+
|
|
96
|
+
1. Tag the commit: `git tag v1.0.0`
|
|
97
|
+
2. Push the tag: `git push origin v1.0.0`
|
|
98
|
+
|
|
99
|
+
The release workflow will:
|
|
100
|
+
1. Run tests
|
|
101
|
+
2. Create a tarball
|
|
102
|
+
3. Create a GitHub release with release notes
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Andrew Thal
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# opencode-pilot
|
|
2
|
+
|
|
3
|
+
Automation layer for [OpenCode](https://github.com/sst/opencode) - notifications and workflow orchestration.
|
|
4
|
+
|
|
5
|
+
> **Note**: This is a community project and is not built by or affiliated with the OpenCode team.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Idle notifications** - Get notified when OpenCode has been waiting for input
|
|
10
|
+
- **Error alerts** - Stay informed when something needs attention
|
|
11
|
+
- **Polling automation** - Automatically start sessions from GitHub issues, Linear tickets, etc.
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
Add the plugin to your `~/.config/opencode/opencode.json`:
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"plugin": ["opencode-pilot"]
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
OpenCode auto-installs npm plugins on startup.
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
1. **Create config** - Copy [examples/config.yaml](examples/config.yaml) to `~/.config/opencode-pilot/config.yaml` and customize
|
|
28
|
+
|
|
29
|
+
2. **Start the service** (in a separate terminal):
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npx opencode-pilot start
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
3. **Run OpenCode** - notifications will be sent to your ntfy topic!
|
|
36
|
+
|
|
37
|
+
## Configuration
|
|
38
|
+
|
|
39
|
+
See [examples/config.yaml](examples/config.yaml) for a complete example with all options.
|
|
40
|
+
|
|
41
|
+
### Key Sections
|
|
42
|
+
|
|
43
|
+
- **`notifications`** - ntfy settings (topic, server, idle/error settings)
|
|
44
|
+
- **`repos`** - Repository paths and settings (use YAML anchors to share config)
|
|
45
|
+
- **`sources`** - What to poll (GitHub issues, Linear tickets, etc.)
|
|
46
|
+
- **`tools`** - Field mappings to normalize different MCP APIs
|
|
47
|
+
|
|
48
|
+
### Prompt Templates
|
|
49
|
+
|
|
50
|
+
Create prompt templates as markdown files in `~/.config/opencode-pilot/templates/`. Templates support placeholders like `{title}`, `{body}`, `{number}`, `{html_url}`, etc.
|
|
51
|
+
|
|
52
|
+
## Service Management
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
npx opencode-pilot start # Start the service (foreground)
|
|
56
|
+
npx opencode-pilot status # Check status
|
|
57
|
+
npx opencode-pilot test-source NAME # Test a source
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Troubleshooting
|
|
61
|
+
|
|
62
|
+
1. Check ntfy topic: `curl -d "test" ntfy.sh/your-topic`
|
|
63
|
+
2. Verify config: `npx opencode-pilot config`
|
|
64
|
+
3. Enable debug logging: set `notifications.debug: true` in config
|
|
65
|
+
|
|
66
|
+
## Related
|
|
67
|
+
|
|
68
|
+
- [opencode-devcontainers](https://github.com/athal7/opencode-devcontainers) - Run multiple devcontainer instances for OpenCode
|
|
69
|
+
|
|
70
|
+
## License
|
|
71
|
+
|
|
72
|
+
MIT
|