opencode-gitlab-dap 1.1.2 → 1.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.
- package/README.md +121 -60
- package/dist/index.cjs +1972 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1972 -16
- package/dist/index.js.map +1 -1
- package/package.json +9 -2
package/README.md
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
# opencode-gitlab-dap
|
|
2
2
|
|
|
3
|
-
An [opencode](https://opencode.ai) plugin
|
|
4
|
-
from the
|
|
5
|
-
|
|
3
|
+
An [opencode](https://opencode.ai) plugin for the [GitLab Duo Agent Platform (DAP)](https://docs.gitlab.com/user/duo_agent_platform/).
|
|
4
|
+
Discovers agents and flows from the GitLab AI Catalog, injects them into opencode,
|
|
5
|
+
and provides tools for managing and executing DAP workflows.
|
|
6
6
|
|
|
7
7
|
## Requirements
|
|
8
8
|
|
|
9
9
|
- opencode with the `gitlab` provider configured and Duo Workflow (DWS) enabled
|
|
10
10
|
- GitLab OAuth or PAT authentication (via `opencode-gitlab-auth` or manual config)
|
|
11
|
-
- GitLab project with AI Catalog agents enabled
|
|
12
|
-
- `gitlab-ai-provider` >= 6.
|
|
11
|
+
- GitLab project with AI Catalog agents/flows enabled
|
|
12
|
+
- `gitlab-ai-provider` >= 6.3.0 (peer dependency, bundled with opencode's gitlab provider)
|
|
13
|
+
- `@opencode-ai/plugin` >= 1.2.24
|
|
13
14
|
|
|
14
15
|
## Install
|
|
15
16
|
|
|
@@ -27,92 +28,152 @@ Or add to your `~/.config/opencode/opencode.json`:
|
|
|
27
28
|
|
|
28
29
|
No further configuration needed. The plugin reads GitLab auth and model cache automatically.
|
|
29
30
|
|
|
30
|
-
##
|
|
31
|
+
## Features
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
### Agent & Flow Discovery
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
2. Reads the already-cached GitLab workflow model from `gitlab-ai-provider`'s model cache (no extra network call)
|
|
36
|
-
3. Queries two GitLab GraphQL APIs in parallel:
|
|
37
|
-
- `aiFoundationalChatAgents` — project-scoped foundational agents (Planner, Data Analyst, Security Analyst, GitLab Duo, etc.)
|
|
38
|
-
- `aiCatalogConfiguredItems` — custom agents explicitly enabled for the project
|
|
39
|
-
4. Injects all discovered agents into opencode's config via the `config` hook — they appear in the `/agents` dialog and the Tab agent picker
|
|
40
|
-
5. Each agent runs through GitLab Duo Agent Platform (DWS), with tool actions executed locally by opencode
|
|
35
|
+
On startup, the plugin discovers all agents and flows enabled for your project:
|
|
41
36
|
|
|
42
|
-
|
|
37
|
+
- **Foundational agents** (Planner, Data Analyst, Security Analyst, etc.) via `aiFoundationalChatAgents`
|
|
38
|
+
- **Custom agents** and **flows** via `aiCatalogConfiguredItems`
|
|
39
|
+
- Agents appear in `/agents` dialog and Tab agent picker
|
|
40
|
+
- Flows appear in the `@` mention menu as subagents
|
|
43
41
|
|
|
44
|
-
###
|
|
42
|
+
### Flow Execution via `@` Menu
|
|
45
43
|
|
|
46
|
-
|
|
44
|
+
Type `@Flow Name` followed by your goal to execute a flow:
|
|
47
45
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
```
|
|
47
|
+
@Fix CI/CD Pipeline fix the failing pipeline for MR !12
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
The plugin:
|
|
51
|
+
|
|
52
|
+
1. Intercepts the `@` mention via `chat.message` hook
|
|
53
|
+
2. Dispatches a subagent that fetches the flow definition
|
|
54
|
+
3. Gathers required inputs using available GitLab tools
|
|
55
|
+
4. Executes the flow via `POST /api/v4/ai/duo_workflows/workflows`
|
|
56
|
+
5. Monitors workflow status until it starts running
|
|
57
|
+
6. Reports the workflow URL for tracking in GitLab UI
|
|
58
|
+
|
|
59
|
+
### 13 DAP Tools
|
|
60
|
+
|
|
61
|
+
| Tool | Description |
|
|
62
|
+
| ------------------------------ | ------------------------------------------ |
|
|
63
|
+
| `gitlab_list_agents` | Search agents in the global AI Catalog |
|
|
64
|
+
| `gitlab_get_agent` | Get agent details by ID |
|
|
65
|
+
| `gitlab_list_project_agents` | List agents enabled for a project |
|
|
66
|
+
| `gitlab_enable_project_agent` | Enable an agent in a project |
|
|
67
|
+
| `gitlab_disable_project_agent` | Disable an agent in a project |
|
|
68
|
+
| `gitlab_list_flows` | Search flows in the global AI Catalog |
|
|
69
|
+
| `gitlab_get_flow` | Get flow details by ID |
|
|
70
|
+
| `gitlab_list_project_flows` | List flows enabled for a project |
|
|
71
|
+
| `gitlab_enable_project_flow` | Enable a flow in a project |
|
|
72
|
+
| `gitlab_disable_project_flow` | Disable a flow in a project |
|
|
73
|
+
| `gitlab_execute_project_flow` | Execute a flow via DWS REST API |
|
|
74
|
+
| `gitlab_get_flow_definition` | Get flow YAML config (inputs, components) |
|
|
75
|
+
| `gitlab_get_workflow_status` | Monitor workflow execution status and logs |
|
|
76
|
+
|
|
77
|
+
### Dynamic Refresh
|
|
78
|
+
|
|
79
|
+
After enabling or disabling an agent/flow, the plugin automatically refreshes the
|
|
80
|
+
agent list. Restart opencode to update the `@` menu.
|
|
81
|
+
|
|
82
|
+
### Vendored Foundational Flow Configs
|
|
83
|
+
|
|
84
|
+
Foundational flow definitions (from `gitlab-org/modelops/applied-ml/code-suggestions/ai-assist`)
|
|
85
|
+
are vendored and embedded at build time. This provides flow input schemas for
|
|
86
|
+
foundational flows whose configs are not available via the GitLab API.
|
|
87
|
+
|
|
88
|
+
## Agent Types
|
|
89
|
+
|
|
90
|
+
### Foundational Agents
|
|
91
|
+
|
|
92
|
+
Built-in GitLab agents. Appear in `/agents` with `[GitLab Foundational Agent]` label.
|
|
93
|
+
|
|
94
|
+
### Custom Agents
|
|
95
|
+
|
|
96
|
+
User-defined agents from the AI Catalog. Appear in `/agents` with `[GitLab Custom Agent]` label.
|
|
54
97
|
|
|
55
|
-
|
|
98
|
+
### Flows (Foundational & Custom)
|
|
56
99
|
|
|
57
|
-
|
|
100
|
+
Multi-step workflows. Appear in `@` menu with `[GitLab Flow]` label. Executed via subagent dispatch.
|
|
58
101
|
|
|
59
|
-
|
|
60
|
-
Custom agents must be explicitly enabled for the project to appear.
|
|
102
|
+
### External Agents
|
|
61
103
|
|
|
62
|
-
|
|
63
|
-
|
|
104
|
+
Third-party agents (Claude Code, Codex, etc.) are excluded — they work via CI/CD triggers,
|
|
105
|
+
not through opencode.
|
|
64
106
|
|
|
65
|
-
##
|
|
107
|
+
## Flow Definition Lookup
|
|
66
108
|
|
|
67
|
-
|
|
109
|
+
The plugin uses a 3-tier strategy to fetch flow YAML configs:
|
|
68
110
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
111
|
+
| Tier | Source | Used For |
|
|
112
|
+
| ---- | ----------------------------------------------- | ------------------ |
|
|
113
|
+
| 1 | Vendored configs (`vendor/foundational-flows/`) | Foundational flows |
|
|
114
|
+
| 2 | `FlowVersion.definition` GraphQL field | Custom flows |
|
|
115
|
+
| 3 | `aiCatalogAgentFlowConfig` GraphQL query | Custom agents |
|
|
72
116
|
|
|
73
|
-
## Self-
|
|
117
|
+
## Self-Hosted GitLab
|
|
74
118
|
|
|
75
119
|
For OAuth-based auth, the `enterpriseUrl` from `opencode-gitlab-auth` is used automatically.
|
|
76
120
|
|
|
77
|
-
For PAT-based auth
|
|
121
|
+
For PAT-based auth:
|
|
78
122
|
|
|
79
123
|
```bash
|
|
80
124
|
export GITLAB_INSTANCE_URL=https://your-instance.com
|
|
81
125
|
```
|
|
82
126
|
|
|
83
|
-
##
|
|
127
|
+
## Development
|
|
84
128
|
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
├─ aiFoundationalChatAgents (GraphQL) → foundational agents
|
|
91
|
-
└─ aiCatalogConfiguredItems (GraphQL) → custom agents
|
|
92
|
-
└─ aiCatalogAgentFlowConfig (GraphQL) → per-agent flow config YAML
|
|
93
|
-
└─ config hook mutates cfg.agent in-place
|
|
94
|
-
└─ Agent.Service reads the same config object → agents appear in picker
|
|
95
|
-
|
|
96
|
-
Per prompt (via gitlab-ai-provider):
|
|
97
|
-
└─ providerOptions.gitlab.workflowDefinition → DWS workflow type
|
|
98
|
-
└─ providerOptions.gitlab.flowConfig → custom agent flow config
|
|
99
|
-
└─ providerOptions.gitlab.aiCatalogItemVersionId → links session in GitLab UI
|
|
129
|
+
```bash
|
|
130
|
+
npm install
|
|
131
|
+
npm test # Run tests (48 tests)
|
|
132
|
+
npm run build # Build (auto-runs vendor:generate)
|
|
133
|
+
npm run type-check
|
|
100
134
|
```
|
|
101
135
|
|
|
102
|
-
|
|
136
|
+
### Vendor Scripts
|
|
103
137
|
|
|
104
138
|
```bash
|
|
105
|
-
#
|
|
106
|
-
|
|
139
|
+
npm run vendor:update # Fetch flow configs from gitlab.com API
|
|
140
|
+
npm run vendor:generate # Generate TypeScript from vendored YAMLs
|
|
141
|
+
npm run vendor # Both: update + generate
|
|
142
|
+
```
|
|
107
143
|
|
|
108
|
-
|
|
109
|
-
npm test
|
|
144
|
+
To update vendored configs when DWS releases new flow versions:
|
|
110
145
|
|
|
111
|
-
|
|
146
|
+
```bash
|
|
147
|
+
npm run vendor
|
|
112
148
|
npm run build
|
|
149
|
+
git add vendor/ src/generated/
|
|
150
|
+
git commit -m "chore: update vendored foundational flow definitions"
|
|
151
|
+
```
|
|
113
152
|
|
|
114
|
-
|
|
115
|
-
|
|
153
|
+
## Architecture
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
Plugin init
|
|
157
|
+
├─ readAuth() reads ~/.local/share/opencode/auth.json
|
|
158
|
+
├─ GitLabModelCache reads model cache (no network call)
|
|
159
|
+
├─ fetchCatalogAgents()
|
|
160
|
+
│ ├─ aiFoundationalChatAgents (GraphQL) → foundational agents
|
|
161
|
+
│ └─ aiCatalogConfiguredItems (GraphQL) → custom agents + flows
|
|
162
|
+
│ └─ aiCatalogAgentFlowConfig (GraphQL) → flow config YAML
|
|
163
|
+
├─ config hook injects agents (primary) + flows (subagent)
|
|
164
|
+
├─ chat.message hook intercepts @flow mentions → subagent dispatch
|
|
165
|
+
└─ tool hook 13 DAP tools
|
|
166
|
+
|
|
167
|
+
Flow execution (@FlowName):
|
|
168
|
+
├─ chat.message hook replaces AgentPart with subagent instructions
|
|
169
|
+
├─ Primary agent dispatches Task subagent
|
|
170
|
+
├─ Subagent Step 1 gitlab_get_flow_definition → read inputs
|
|
171
|
+
├─ Subagent Step 2 GitLab tools → gather input values
|
|
172
|
+
├─ Subagent Step 3 gitlab_execute_project_flow → POST to DWS
|
|
173
|
+
└─ Subagent Step 4 gitlab_get_workflow_status → confirm started
|
|
174
|
+
|
|
175
|
+
Enable/disable:
|
|
176
|
+
└─ refreshAgents() clears cache, re-fetches, updates cfg.agent
|
|
116
177
|
```
|
|
117
178
|
|
|
118
179
|
## License
|