@gitlab/opencode-gitlab-plugin 1.0.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/package.json ADDED
@@ -0,0 +1,87 @@
1
+ {
2
+ "name": "@gitlab/opencode-gitlab-plugin",
3
+ "version": "1.0.1",
4
+ "description": "GitLab tools plugin for OpenCode - provides GitLab API access for merge requests, issues, pipelines, and more",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "scripts",
17
+ ".npmrc",
18
+ "README.md",
19
+ "LICENSE",
20
+ "CHANGELOG.md"
21
+ ],
22
+ "publishConfig": {
23
+ "access": "public"
24
+ },
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git+https://gitlab.com/gitlab-org/editor-extensions/opencode-gitlab-plugin.git"
28
+ },
29
+ "homepage": "https://gitlab.com/gitlab-org/editor-extensions/opencode-gitlab-plugin#readme",
30
+ "bugs": {
31
+ "url": "https://gitlab.com/gitlab-org/editor-extensions/opencode-gitlab-plugin/-/issues"
32
+ },
33
+ "scripts": {
34
+ "build": "tsup src/index.ts --format esm --dts",
35
+ "dev": "tsup src/index.ts --format esm --dts --watch",
36
+ "lint": "eslint src --ext .ts",
37
+ "lint:fix": "eslint src --ext .ts --fix",
38
+ "format": "prettier --write \"src/**/*.ts\"",
39
+ "format:check": "prettier --check \"src/**/*.ts\"",
40
+ "type-check": "tsc --noEmit",
41
+ "test": "vitest run",
42
+ "test:watch": "vitest",
43
+ "test:ui": "vitest --ui",
44
+ "lint-staged": "lint-staged",
45
+ "prepare": "husky install",
46
+ "prepublishOnly": "npm run build",
47
+ "postinstall": "node scripts/postinstall.mjs",
48
+ "semantic-release": "semantic-release"
49
+ },
50
+ "dependencies": {
51
+ "@opencode-ai/plugin": "^1.0.127",
52
+ "zod": "4.1.8"
53
+ },
54
+ "devDependencies": {
55
+ "@commitlint/cli": "^18.4.3",
56
+ "@commitlint/config-conventional": "^18.4.3",
57
+ "@semantic-release/changelog": "^6.0.3",
58
+ "@semantic-release/git": "^10.0.1",
59
+ "@semantic-release/gitlab": "^13.0.3",
60
+ "@semantic-release/npm": "^11.0.2",
61
+ "@types/node": "^25.0.0",
62
+ "@typescript-eslint/eslint-plugin": "^6.15.0",
63
+ "@typescript-eslint/parser": "^6.15.0",
64
+ "@vitest/ui": "^4.0.15",
65
+ "eslint": "^8.56.0",
66
+ "eslint-config-prettier": "^9.1.0",
67
+ "husky": "^8.0.3",
68
+ "lint-staged": "^15.2.0",
69
+ "prettier": "^3.1.1",
70
+ "semantic-release": "^22.0.12",
71
+ "tsup": "^8.0.0",
72
+ "typescript": "^5.0.0",
73
+ "vitest": "^4.0.15"
74
+ },
75
+ "keywords": [
76
+ "opencode",
77
+ "plugin",
78
+ "gitlab",
79
+ "duo"
80
+ ],
81
+ "author": "Vladimir Glafirov",
82
+ "license": "MIT",
83
+ "engines": {
84
+ "node": ">=18.0.0",
85
+ "npm": ">=9.0.0"
86
+ }
87
+ }
@@ -0,0 +1,163 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Post-install script for opencode-gitlab-plugin
5
+ *
6
+ * This script ensures GitLab skills are copied to the OpenCode skills directory
7
+ * even when installed as a dependency.
8
+ */
9
+
10
+ import fs from 'fs';
11
+ import path from 'path';
12
+ import os from 'os';
13
+ import { fileURLToPath } from 'url';
14
+
15
+ const __filename = fileURLToPath(import.meta.url);
16
+ const __dirname = path.dirname(__filename);
17
+
18
+ /**
19
+ * Get the OpenCode cache directory
20
+ */
21
+ function getOpencodeSkillsDir() {
22
+ const xdgCache = process.env.XDG_CACHE_HOME || path.join(os.homedir(), '.cache');
23
+ return path.join(xdgCache, 'opencode', 'skills');
24
+ }
25
+
26
+ /**
27
+ * Recursively copy directory
28
+ */
29
+ function copyDirRecursive(src, dest) {
30
+ if (!fs.existsSync(dest)) {
31
+ fs.mkdirSync(dest, { recursive: true });
32
+ }
33
+
34
+ const entries = fs.readdirSync(src, { withFileTypes: true });
35
+
36
+ for (const entry of entries) {
37
+ const srcPath = path.join(src, entry.name);
38
+ const destPath = path.join(dest, entry.name);
39
+
40
+ if (entry.isDirectory()) {
41
+ copyDirRecursive(srcPath, destPath);
42
+ } else {
43
+ fs.copyFileSync(srcPath, destPath);
44
+ }
45
+ }
46
+ }
47
+
48
+ /**
49
+ * Find the gitlab-skills package directory
50
+ */
51
+ function findGitlabSkillsDir() {
52
+ // Try to find the package in node_modules
53
+ const possiblePaths = [
54
+ // When installed as dependency of this plugin
55
+ path.join(__dirname, '..', 'node_modules', '@vglafirov', 'gitlab-skills'),
56
+ // When this plugin is installed in another project
57
+ path.join(__dirname, '..', '..', '@vglafirov', 'gitlab-skills'),
58
+ // When running from the plugin's own directory
59
+ path.join(__dirname, '..', '..', '..', '@vglafirov', 'gitlab-skills'),
60
+ // When installed in OpenCode cache (global installation)
61
+ path.join(__dirname, '..', '..', '..', 'node_modules', '@vglafirov', 'gitlab-skills'),
62
+ // Alternative OpenCode cache structure
63
+ path.join(__dirname, '..', '..', '..', '..', 'node_modules', '@vglafirov', 'gitlab-skills'),
64
+ ];
65
+
66
+ console.log('šŸ” Searching for gitlab-skills package...');
67
+ console.log(` Script location: ${__dirname}`);
68
+
69
+ for (const pkgPath of possiblePaths) {
70
+ console.log(` Checking: ${pkgPath}`);
71
+ if (fs.existsSync(pkgPath)) {
72
+ console.log(` āœ“ Found at: ${pkgPath}`);
73
+ return pkgPath;
74
+ }
75
+ }
76
+
77
+ console.log(' āœ— Not found in any expected location');
78
+ return null;
79
+ }
80
+
81
+ /**
82
+ * Install skills to OpenCode skills directory
83
+ */
84
+ function installSkills() {
85
+ try {
86
+ const skillsDir = getOpencodeSkillsDir();
87
+ const sourceDir = findGitlabSkillsDir();
88
+
89
+ if (!sourceDir) {
90
+ console.log('āš ļø GitLab Skills package not found. Skills may not be available.');
91
+ return;
92
+ }
93
+
94
+ console.log('\nšŸ“¦ Installing GitLab Skills to OpenCode...\n');
95
+ console.log(` Source: ${sourceDir}`);
96
+ console.log(` Target: ${skillsDir}\n`);
97
+
98
+ // Create skills directory if it doesn't exist
99
+ if (!fs.existsSync(skillsDir)) {
100
+ fs.mkdirSync(skillsDir, { recursive: true });
101
+ console.log(`āœ“ Created OpenCode skills directory: ${skillsDir}`);
102
+ }
103
+
104
+ // List of skill directories to copy
105
+ const skillDirs = [
106
+ 'gitlab-code-review',
107
+ 'gitlab-documentation',
108
+ 'gitlab-engineering-velocity',
109
+ 'gitlab-issue-epic-creator',
110
+ 'gitlab-meeting-efficiency',
111
+ 'gitlab-mr-generator',
112
+ 'gitlab-prototyping'
113
+ ];
114
+
115
+ // Copy each skill directory
116
+ for (const skillDir of skillDirs) {
117
+ const sourcePath = path.join(sourceDir, skillDir);
118
+ const targetPath = path.join(skillsDir, skillDir);
119
+
120
+ if (fs.existsSync(sourcePath)) {
121
+ // Remove existing directory if it exists
122
+ if (fs.existsSync(targetPath)) {
123
+ fs.rmSync(targetPath, { recursive: true, force: true });
124
+ }
125
+
126
+ // Copy directory recursively
127
+ copyDirRecursive(sourcePath, targetPath);
128
+ console.log(`āœ“ Installed skill: ${skillDir}`);
129
+ } else {
130
+ console.log(`āš ļø Skill not found: ${skillDir}`);
131
+ }
132
+ }
133
+
134
+ // Copy docs directory
135
+ const docsSource = path.join(sourceDir, 'docs');
136
+ const docsTarget = path.join(skillsDir, 'docs');
137
+ if (fs.existsSync(docsSource)) {
138
+ if (fs.existsSync(docsTarget)) {
139
+ fs.rmSync(docsTarget, { recursive: true, force: true });
140
+ }
141
+ copyDirRecursive(docsSource, docsTarget);
142
+ console.log('āœ“ Installed documentation');
143
+ }
144
+
145
+ // Copy README
146
+ const readmeSource = path.join(sourceDir, 'README.md');
147
+ const readmeTarget = path.join(skillsDir, 'README.md');
148
+ if (fs.existsSync(readmeSource)) {
149
+ fs.copyFileSync(readmeSource, readmeTarget);
150
+ console.log('āœ“ Installed README.md');
151
+ }
152
+
153
+ console.log(`\nāœ… GitLab Skills successfully installed to: ${skillsDir}\n`);
154
+ } catch (error) {
155
+ console.error('\nāŒ Error installing GitLab Skills:', error.message);
156
+ console.error(' Skills may not be available in OpenCode.\n');
157
+ // Don't fail the installation if skills can't be copied
158
+ process.exit(0);
159
+ }
160
+ }
161
+
162
+ // Run installation
163
+ installSkills();