Commit 171b625
authored
feat(profiles): add configuration profiles infrastructure (#60)
* feat(profiles): add configuration profiles infrastructure (#54)
Add support for named configuration profiles and presets:
- Profile: full config with host/auth (user-defined in ~/.config/gitlab-mcp/profiles.yaml)
- Preset: settings only, NO host/auth (built-in safe for testing)
Features:
- ProfileLoader class with caching and validation
- applyProfile() to map profile settings to env vars
- --profile CLI argument and GITLAB_PROFILE env var support
- Built-in presets: readonly, developer, admin
- Zod schemas for type-safe validation
- 67 unit tests covering loader, applicator, types
Security: Built-in presets NEVER contain host/auth to prevent
accidental requests to wrong GitLab instances during testing.
* chore: update Yarn to 4.12.0
* ci: update Yarn to 4.12.0 in workflows
* fix(ci): remove yarnPath from .yarnrc.yml (corepack handles it)
* feat(profiles): add applyPreset() and improve validation
- Add applyPreset() function for runtime built-in preset application
- Add .strict() to PresetSchema to reject unknown fields (security)
- Validate --profile CLI argument is not another flag
- Validate OAuth client_secret_env environment variable
- Validate cookie auth file path exists
* feat(profiles): add build asset copy and improve test coverage
- Add build:copy-assets script to copy YAML presets to dist
- Update getBuiltinDir() to use __dirname for npm package compatibility
- Add Node.js CommonJS globals to ESLint config
- Add 45+ tests for applyPreset, loadAndApplyProfile, loadAndApplyPreset
- Add validation tests for OAuth, cookie auth, and TLS paths
- Add profile handling tests for main.ts CLI integration
Closes #54
* fix(docker): update yarn version to 4.12.0 in Dockerfile
* fix(profiles): cross-platform build script and duplicate --profile warning
- Replace Unix shell commands with Node.js one-liner for cross-platform compatibility
- Add warning when multiple --profile flags are provided
* fix(ci): add explicit yarn 4.12.0 install to pr-check workflow
* fix(ci): remove pull_request_target from pr-check (uses base branch workflow)
* fix(profiles): add missing env var mappings
Add environment variable mappings for:
- allowed_groups -> GITLAB_ALLOWED_GROUP_IDS
- allowed_tools -> GITLAB_ALLOWED_TOOLS (in applyProfile)
- default_namespace -> GITLAB_DEFAULT_NAMESPACE
These fields were defined in the Profile type but not applied
to environment variables when the profile was loaded.
* fix(profiles): improve validation and address review feedback
- Improve denied_actions validation to check both tool and action parts
are non-empty (fixes ':action', 'tool:', ':' edge cases)
- Fix getProfileNameFromEnv JSDoc comment accuracy
- Move multiple --profile warning outside loop with count
- Add tests for denied_actions edge cases
* test(profiles): improve coverage for applicator and loader
Add tests for:
- allowed_groups, allowed_tools, default_namespace env var mapping
- validation warnings logging path
- getProfileNameFromEnv standalone function
Coverage improved:
- applicator.ts: 94.44% -> 99.3%
- loader.ts: 95.56% -> 96.2%
- Overall profiles: 91.07% -> 93.53%
* docs(ci): add comment explaining pull_request trigger choice
* test(profiles): improve coverage for loader
Add tests for:
- Alphabetical sorting within same profile category
- Config cache hit when loading multiple profiles
Coverage improved:
- loader.ts: 96.2% -> 97.46%
- Overall profiles: 93.53% -> 94.15%
* fix(profiles): add warning for denied_actions with extra whitespace
Warn users when denied_actions entries contain extra whitespace
around the colon (e.g., "tool : action"). The validation still
passes but logs a warning indicating the normalized form.
* refactor(profiles): extract validateDeniedActions helper method
Reduces code duplication between validateProfile and validatePreset
by extracting shared denied_actions validation logic into a private
helper method.1 parent afc1ecc commit 171b625
File tree
22 files changed
+3515
-78
lines changed- .github/workflows
- src
- profiles
- builtin
- utils
- tests/unit
- profiles
22 files changed
+3515
-78
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
158 | | - | |
| 158 | + | |
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
3 | 5 | | |
4 | 6 | | |
5 | 7 | | |
6 | | - | |
7 | | - | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
30 | 33 | | |
31 | 34 | | |
32 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
| 77 | + | |
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
122 | | - | |
| 122 | + | |
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
| |||
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
164 | | - | |
| 164 | + | |
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
28 | 33 | | |
29 | 34 | | |
30 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| |||
67 | 68 | | |
68 | 69 | | |
69 | 70 | | |
| 71 | + | |
70 | 72 | | |
71 | 73 | | |
72 | 74 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | | - | |
7 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
8 | 68 | | |
9 | 69 | | |
10 | 70 | | |
0 commit comments