@structured-world/gitlab-mcp 6.15.0 → 6.16.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.
@@ -0,0 +1,8 @@
1
+ import { ProjectConfig } from "./profiles";
2
+ export interface CliArgs {
3
+ profileName?: string;
4
+ noProjectConfig: boolean;
5
+ showProjectConfig: boolean;
6
+ }
7
+ export declare function parseCliArgs(argv?: string[]): CliArgs;
8
+ export declare function displayProjectConfig(config: ProjectConfig | null, output?: (msg: string) => void): void;
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseCliArgs = parseCliArgs;
4
+ exports.displayProjectConfig = displayProjectConfig;
5
+ const logger_1 = require("./logger");
6
+ const profiles_1 = require("./profiles");
7
+ function parseCliArgs(argv = process.argv) {
8
+ const args = argv.slice(2);
9
+ const result = {
10
+ noProjectConfig: false,
11
+ showProjectConfig: false,
12
+ };
13
+ let profileCount = 0;
14
+ for (let i = 0; i < args.length; i++) {
15
+ const arg = args[i];
16
+ if (arg === "--profile") {
17
+ const value = args[i + 1];
18
+ if (!value || value.startsWith("--")) {
19
+ logger_1.logger.error("--profile requires a profile name (e.g., --profile work)");
20
+ throw new Error("--profile requires a profile name");
21
+ }
22
+ profileCount++;
23
+ if (profileCount === 1) {
24
+ result.profileName = value;
25
+ }
26
+ i++;
27
+ }
28
+ else if (arg === "--no-project-config") {
29
+ result.noProjectConfig = true;
30
+ }
31
+ else if (arg === "--show-project-config") {
32
+ result.showProjectConfig = true;
33
+ }
34
+ }
35
+ if (profileCount > 1) {
36
+ logger_1.logger.warn({ count: profileCount }, "Multiple --profile flags detected, using first value");
37
+ }
38
+ return result;
39
+ }
40
+ function displayProjectConfig(config, output = console.log) {
41
+ if (!config) {
42
+ output("No project configuration found in current directory or parent directories.");
43
+ output("\nTo create a project config, add .gitlab-mcp/ directory with:");
44
+ output(" - preset.yaml (restrictions: scope, denied_actions, features)");
45
+ output(" - profile.yaml (tool selection: extends, additional_tools)");
46
+ return;
47
+ }
48
+ const summary = (0, profiles_1.getProjectConfigSummary)(config);
49
+ output("Project Configuration");
50
+ output("=====================");
51
+ output(`Path: ${config.configPath}`);
52
+ output("");
53
+ if (config.preset) {
54
+ output("Preset (restrictions):");
55
+ if (config.preset.description) {
56
+ output(` Description: ${config.preset.description}`);
57
+ }
58
+ if (config.preset.scope) {
59
+ if (config.preset.scope.project) {
60
+ output(` Scope: project "${config.preset.scope.project}"`);
61
+ }
62
+ else if (config.preset.scope.namespace) {
63
+ output(` Scope: namespace "${config.preset.scope.namespace}/*"`);
64
+ }
65
+ else if (config.preset.scope.projects) {
66
+ output(` Scope: ${config.preset.scope.projects.length} projects`);
67
+ for (const p of config.preset.scope.projects) {
68
+ output(` - ${p}`);
69
+ }
70
+ }
71
+ }
72
+ if (config.preset.read_only) {
73
+ output(" Read-only: yes");
74
+ }
75
+ if (config.preset.denied_actions?.length) {
76
+ output(` Denied actions: ${config.preset.denied_actions.join(", ")}`);
77
+ }
78
+ if (config.preset.denied_tools?.length) {
79
+ output(` Denied tools: ${config.preset.denied_tools.join(", ")}`);
80
+ }
81
+ if (config.preset.features) {
82
+ const features = Object.entries(config.preset.features)
83
+ .filter(([, v]) => v !== undefined)
84
+ .map(([k, v]) => `${k}=${v}`)
85
+ .join(", ");
86
+ if (features) {
87
+ output(` Features: ${features}`);
88
+ }
89
+ }
90
+ output("");
91
+ }
92
+ if (config.profile) {
93
+ output("Profile (tool selection):");
94
+ if (config.profile.description) {
95
+ output(` Description: ${config.profile.description}`);
96
+ }
97
+ if (config.profile.extends) {
98
+ output(` Extends: ${config.profile.extends}`);
99
+ }
100
+ if (config.profile.additional_tools?.length) {
101
+ output(` Additional tools: ${config.profile.additional_tools.join(", ")}`);
102
+ }
103
+ if (config.profile.denied_tools?.length) {
104
+ output(` Denied tools: ${config.profile.denied_tools.join(", ")}`);
105
+ }
106
+ if (config.profile.features) {
107
+ const features = Object.entries(config.profile.features)
108
+ .filter(([, v]) => v !== undefined)
109
+ .map(([k, v]) => `${k}=${v}`)
110
+ .join(", ");
111
+ if (features) {
112
+ output(` Features: ${features}`);
113
+ }
114
+ }
115
+ output("");
116
+ }
117
+ output("Summary:");
118
+ if (summary.presetSummary) {
119
+ output(` Preset: ${summary.presetSummary}`);
120
+ }
121
+ if (summary.profileSummary) {
122
+ output(` Profile: ${summary.profileSummary}`);
123
+ }
124
+ }
125
+ //# sourceMappingURL=cli-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-utils.js","sourceRoot":"","sources":["../../src/cli-utils.ts"],"names":[],"mappings":";;AAsBA,oCAoCC;AAOD,oDA0FC;AAtJD,qCAAkC;AAClC,yCAAoE;AAgBpE,SAAgB,YAAY,CAAC,OAAiB,OAAO,CAAC,IAAI;IACxD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC3B,MAAM,MAAM,GAAY;QACtB,eAAe,EAAE,KAAK;QACtB,iBAAiB,EAAE,KAAK;KACzB,CAAC;IAEF,IAAI,YAAY,GAAG,CAAC,CAAC;IAErB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAEpB,IAAI,GAAG,KAAK,WAAW,EAAE,CAAC;YACxB,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YAE1B,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;gBACrC,eAAM,CAAC,KAAK,CAAC,0DAA0D,CAAC,CAAC;gBACzE,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;YACvD,CAAC;YACD,YAAY,EAAE,CAAC;YACf,IAAI,YAAY,KAAK,CAAC,EAAE,CAAC;gBACvB,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CAAC,QAAQ,EAAE,CAAC;YAC5B,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC;iBACrD,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC;iBAClC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;iBAC5B,IAAI,CAAC,IAAI,CAAC,CAAC;YACd,IAAI,QAAQ,EAAE,CAAC;gBACb,MAAM,CAAC,eAAe,QAAQ,EAAE,CAAC,CAAC;YACpC,CAAC;QACH,CAAC;QACD,MAAM,CAAC,EAAE,CAAC,CAAC;IACb,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,CAAC;IACnB,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;QAC1B,MAAM,CAAC,aAAa,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;IAC/C,CAAC;IACD,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;QAC3B,MAAM,CAAC,cAAc,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IACjD,CAAC;AACH,CAAC"}
@@ -36,8 +36,8 @@ export declare const BrowseProjectsSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
36
36
  archived: z.ZodOptional<z.ZodPipe<z.ZodTransform<boolean, unknown>, z.ZodBoolean>>;
37
37
  order_by: z.ZodOptional<z.ZodEnum<{
38
38
  name: "name";
39
- id: "id";
40
39
  path: "path";
40
+ id: "id";
41
41
  created_at: "created_at";
42
42
  last_activity_at: "last_activity_at";
43
43
  updated_at: "updated_at";
@@ -68,8 +68,8 @@ export declare const BrowseProjectsSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
68
68
  archived: z.ZodOptional<z.ZodPipe<z.ZodTransform<boolean, unknown>, z.ZodBoolean>>;
69
69
  order_by: z.ZodOptional<z.ZodEnum<{
70
70
  name: "name";
71
- id: "id";
72
71
  path: "path";
72
+ id: "id";
73
73
  created_at: "created_at";
74
74
  last_activity_at: "last_activity_at";
75
75
  updated_at: "updated_at";
@@ -140,8 +140,8 @@ export declare const BrowseEventsSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
140
140
  page: z.ZodOptional<z.ZodNumber>;
141
141
  action: z.ZodLiteral<"user">;
142
142
  target_type: z.ZodOptional<z.ZodEnum<{
143
- milestone: "milestone";
144
143
  project: "project";
144
+ milestone: "milestone";
145
145
  issue: "issue";
146
146
  merge_request: "merge_request";
147
147
  note: "note";
@@ -173,8 +173,8 @@ export declare const BrowseEventsSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
173
173
  action: z.ZodLiteral<"project">;
174
174
  project_id: z.ZodPipe<z.ZodTransform<{}, unknown>, z.ZodCoercedString<unknown>>;
175
175
  target_type: z.ZodOptional<z.ZodEnum<{
176
- milestone: "milestone";
177
176
  project: "project";
177
+ milestone: "milestone";
178
178
  issue: "issue";
179
179
  merge_request: "merge_request";
180
180
  note: "note";
@@ -45,8 +45,8 @@ export declare const BrowseMergeRequestsSchema: z.ZodDiscriminatedUnion<[z.ZodOb
45
45
  target_branch: z.ZodOptional<z.ZodString>;
46
46
  search: z.ZodOptional<z.ZodString>;
47
47
  in: z.ZodOptional<z.ZodEnum<{
48
- title: "title";
49
48
  description: "description";
49
+ title: "title";
50
50
  "title,description": "title,description";
51
51
  }>>;
52
52
  wip: z.ZodOptional<z.ZodEnum<{
@@ -135,10 +135,10 @@ export declare const BrowsePipelinesSchema: z.ZodDiscriminatedUnion<[z.ZodObject
135
135
  tags: "tags";
136
136
  }>>;
137
137
  status: z.ZodOptional<z.ZodEnum<{
138
+ success: "success";
138
139
  pending: "pending";
139
140
  failed: "failed";
140
141
  manual: "manual";
141
- success: "success";
142
142
  created: "created";
143
143
  running: "running";
144
144
  waiting_for_resource: "waiting_for_resource";
@@ -191,10 +191,10 @@ export declare const BrowsePipelinesSchema: z.ZodDiscriminatedUnion<[z.ZodObject
191
191
  project_id: z.ZodPipe<z.ZodTransform<{}, unknown>, z.ZodCoercedString<unknown>>;
192
192
  pipeline_id: z.ZodPipe<z.ZodTransform<{}, unknown>, z.ZodCoercedString<unknown>>;
193
193
  job_scope: z.ZodOptional<z.ZodArray<z.ZodEnum<{
194
+ success: "success";
194
195
  pending: "pending";
195
196
  failed: "failed";
196
197
  manual: "manual";
197
- success: "success";
198
198
  created: "created";
199
199
  running: "running";
200
200
  canceled: "canceled";
@@ -208,10 +208,10 @@ export declare const BrowsePipelinesSchema: z.ZodDiscriminatedUnion<[z.ZodObject
208
208
  project_id: z.ZodPipe<z.ZodTransform<{}, unknown>, z.ZodCoercedString<unknown>>;
209
209
  pipeline_id: z.ZodPipe<z.ZodTransform<{}, unknown>, z.ZodCoercedString<unknown>>;
210
210
  trigger_scope: z.ZodOptional<z.ZodArray<z.ZodEnum<{
211
+ success: "success";
211
212
  pending: "pending";
212
213
  failed: "failed";
213
214
  manual: "manual";
214
- success: "success";
215
215
  created: "created";
216
216
  running: "running";
217
217
  waiting_for_resource: "waiting_for_resource";
package/dist/src/main.js CHANGED
@@ -4,32 +4,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const server_1 = require("./server");
5
5
  const logger_1 = require("./logger");
6
6
  const profiles_1 = require("./profiles");
7
- function getProfileFromArgs() {
8
- const args = process.argv.slice(2);
9
- let profileName;
10
- let profileCount = 0;
11
- for (let i = 0; i < args.length; i++) {
12
- if (args[i] === "--profile") {
13
- const value = args[i + 1];
14
- if (!value || value.startsWith("--")) {
15
- logger_1.logger.error("--profile requires a profile name (e.g., --profile work)");
16
- process.exit(1);
17
- }
18
- profileCount++;
19
- if (profileCount === 1) {
20
- profileName = value;
21
- }
7
+ const cli_utils_1 = require("./cli-utils");
8
+ async function main() {
9
+ const cliArgs = (0, cli_utils_1.parseCliArgs)();
10
+ if (cliArgs.showProjectConfig) {
11
+ try {
12
+ const projectConfig = await (0, profiles_1.findProjectConfig)(process.cwd());
13
+ (0, cli_utils_1.displayProjectConfig)(projectConfig);
14
+ process.exit(0);
15
+ }
16
+ catch (error) {
17
+ const message = error instanceof Error ? error.message : String(error);
18
+ logger_1.logger.error({ error: message }, "Failed to load project config");
19
+ process.exit(1);
22
20
  }
23
21
  }
24
- if (profileCount > 1) {
25
- logger_1.logger.warn({ count: profileCount }, "Multiple --profile flags detected, using first value");
26
- }
27
- return profileName;
28
- }
29
- async function main() {
30
- const profileName = getProfileFromArgs();
31
22
  try {
32
- const result = await (0, profiles_1.tryApplyProfileFromEnv)(profileName);
23
+ const result = await (0, profiles_1.tryApplyProfileFromEnv)(cliArgs.profileName);
33
24
  if (result) {
34
25
  if ("profileName" in result) {
35
26
  logger_1.logger.info({ profile: result.profileName, host: result.host }, "Using configuration profile");
@@ -44,6 +35,23 @@ async function main() {
44
35
  logger_1.logger.error({ error: message }, "Failed to load profile");
45
36
  process.exit(1);
46
37
  }
38
+ if (!cliArgs.noProjectConfig) {
39
+ try {
40
+ const projectConfig = await (0, profiles_1.findProjectConfig)(process.cwd());
41
+ if (projectConfig) {
42
+ const summary = (0, profiles_1.getProjectConfigSummary)(projectConfig);
43
+ logger_1.logger.info({
44
+ path: projectConfig.configPath,
45
+ preset: summary.presetSummary,
46
+ profile: summary.profileSummary,
47
+ }, "Loaded project configuration");
48
+ }
49
+ }
50
+ catch (error) {
51
+ const message = error instanceof Error ? error.message : String(error);
52
+ logger_1.logger.warn({ error: message }, "Failed to load project config, continuing without it");
53
+ }
54
+ }
47
55
  await (0, server_1.startServer)();
48
56
  }
49
57
  main().catch((error) => {
@@ -1 +1 @@
1
- {"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":";;;AAEA,qCAAuC;AACvC,qCAAkC;AAClC,yCAAoD;AAKpD,SAAS,kBAAkB;IACzB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnC,IA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I,EAAE,aAAa,CAAC,UAAU;oBAC9B,MAAM,EAAE,OAAO,CAAC,aAAa;oBAC7B,OAAO,EAAE,OAAO,CAAC,cAAc;iBAChC,EACD,8BAA8B,CAC/B,CAAC;YAKJ,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAEf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACvE,eAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,sDAAsD,CAAC,CAAC;QAC1F,CAAC;IACH,CAAC;IAGD,MAAM,IAAA,oBAAW,GAAE,CAAC;AACtB,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IAC9B,eAAM,CAAC,KAAK,CAAC,sCAAsC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACpE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -1,3 +1,5 @@
1
- export { Profile, Preset, ProfilesConfig, ProfileInfo, ProfileValidationResult, AuthConfig, PatAuth, OAuthAuth, CookieAuth, FeatureFlags, ProfileSchema, PresetSchema, ProfilesConfigSchema, } from "./types";
1
+ export { Profile, Preset, ProfilesConfig, ProfileInfo, ProfileValidationResult, AuthConfig, PatAuth, OAuthAuth, CookieAuth, FeatureFlags, ProfileSchema, PresetSchema, ProfilesConfigSchema, ProjectPreset, ProjectProfile, ProjectConfig, ProjectPresetSchema, ProjectProfileSchema, } from "./types";
2
2
  export { ProfileLoader, loadProfile, getProfileNameFromEnv } from "./loader";
3
3
  export { applyProfile, applyPreset, loadAndApplyProfile, loadAndApplyPreset, tryApplyProfileFromEnv, ApplyProfileResult, ApplyPresetResult, } from "./applicator";
4
+ export { loadProjectConfig, findProjectConfig, validateProjectPreset, validateProjectProfile, getProjectConfigSummary, PROJECT_CONFIG_DIR, PROJECT_PRESET_FILE, PROJECT_PROFILE_FILE, } from "./project-loader";
5
+ export { ScopeEnforcer, ScopeViolationError, ScopeConfig, extractProjectsFromArgs, enforceArgsScope, } from "./scope-enforcer";
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.tryApplyProfileFromEnv = exports.loadAndApplyPreset = exports.loadAndApplyProfile = exports.applyPreset = exports.applyProfile = exports.getProfileNameFromEnv = exports.loadProfile = exports.ProfileLoader = exports.ProfilesConfigSchema = exports.PresetSchema = exports.ProfileSchema = void 0;
3
+ exports.enforceArgsScope = exports.extractProjectsFromArgs = exports.ScopeViolationError = exports.ScopeEnforcer = exports.PROJECT_PROFILE_FILE = exports.PROJECT_PRESET_FILE = exports.PROJECT_CONFIG_DIR = exports.getProjectConfigSummary = exports.validateProjectProfile = exports.validateProjectPreset = exports.findProjectConfig = exports.loadProjectConfig = exports.tryApplyProfileFromEnv = exports.loadAndApplyPreset = exports.loadAndApplyProfile = exports.applyPreset = exports.applyProfile = exports.getProfileNameFromEnv = exports.loadProfile = exports.ProfileLoader = exports.ProjectProfileSchema = exports.ProjectPresetSchema = exports.ProfilesConfigSchema = exports.PresetSchema = exports.ProfileSchema = void 0;
4
4
  var types_1 = require("./types");
5
5
  Object.defineProperty(exports, "ProfileSchema", { enumerable: true, get: function () { return types_1.ProfileSchema; } });
6
6
  Object.defineProperty(exports, "PresetSchema", { enumerable: true, get: function () { return types_1.PresetSchema; } });
7
7
  Object.defineProperty(exports, "ProfilesConfigSchema", { enumerable: true, get: function () { return types_1.ProfilesConfigSchema; } });
8
+ Object.defineProperty(exports, "ProjectPresetSchema", { enumerable: true, get: function () { return types_1.ProjectPresetSchema; } });
9
+ Object.defineProperty(exports, "ProjectProfileSchema", { enumerable: true, get: function () { return types_1.ProjectProfileSchema; } });
8
10
  var loader_1 = require("./loader");
9
11
  Object.defineProperty(exports, "ProfileLoader", { enumerable: true, get: function () { return loader_1.ProfileLoader; } });
10
12
  Object.defineProperty(exports, "loadProfile", { enumerable: true, get: function () { return loader_1.loadProfile; } });
@@ -15,4 +17,18 @@ Object.defineProperty(exports, "applyPreset", { enumerable: true, get: function
15
17
  Object.defineProperty(exports, "loadAndApplyProfile", { enumerable: true, get: function () { return applicator_1.loadAndApplyProfile; } });
16
18
  Object.defineProperty(exports, "loadAndApplyPreset", { enumerable: true, get: function () { return applicator_1.loadAndApplyPreset; } });
17
19
  Object.defineProperty(exports, "tryApplyProfileFromEnv", { enumerable: true, get: function () { return applicator_1.tryApplyProfileFromEnv; } });
20
+ var project_loader_1 = require("./project-loader");
21
+ Object.defineProperty(exports, "loadProjectConfig", { enumerable: true, get: function () { return project_loader_1.loadProjectConfig; } });
22
+ Object.defineProperty(exports, "findProjectConfig", { enumerable: true, get: function () { return project_loader_1.findProjectConfig; } });
23
+ Object.defineProperty(exports, "validateProjectPreset", { enumerable: true, get: function () { return project_loader_1.validateProjectPreset; } });
24
+ Object.defineProperty(exports, "validateProjectProfile", { enumerable: true, get: function () { return project_loader_1.validateProjectProfile; } });
25
+ Object.defineProperty(exports, "getProjectConfigSummary", { enumerable: true, get: function () { return project_loader_1.getProjectConfigSummary; } });
26
+ Object.defineProperty(exports, "PROJECT_CONFIG_DIR", { enumerable: true, get: function () { return project_loader_1.PROJECT_CONFIG_DIR; } });
27
+ Object.defineProperty(exports, "PROJECT_PRESET_FILE", { enumerable: true, get: function () { return project_loader_1.PROJECT_PRESET_FILE; } });
28
+ Object.defineProperty(exports, "PROJECT_PROFILE_FILE", { enumerable: true, get: function () { return project_loader_1.PROJECT_PROFILE_FILE; } });
29
+ var scope_enforcer_1 = require("./scope-enforcer");
30
+ Object.defineProperty(exports, "ScopeEnforcer", { enumerable: true, get: function () { return scope_enforcer_1.ScopeEnforcer; } });
31
+ Object.defineProperty(exports, "ScopeViolationError", { enumerable: true, get: function () { return scope_enforcer_1.ScopeViolationError; } });
32
+ Object.defineProperty(exports, "extractProjectsFromArgs", { enumerable: true, get: function () { return scope_enforcer_1.extractProjectsFromArgs; } });
33
+ Object.defineProperty(exports, "enforceArgsScope", { enumerable: true, get: function () { return scope_enforcer_1.enforceArgsScope; } });
18
34
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/profiles/index.ts"],"names":[],"mappings":";;;AAiBA,iCAciB;AAHf,sGAAA,aAAa,OAAA;AACb,qGAAA,YAAY,OAAA;AACZ,6GAAA,oBAAoB,OAAA;AAItB,mCAA6E;AAApE,uGAAA,aAAa,OAAA;AAAE,qGAAA,WAAW,OAAA;AAAE,+GAAA,qBAAqB,OAAA;AAG1D,2CAQsB;AAPpB,0GAAA,YAAY,OAAA;AACZ,yGAAA,WAAW,OAAA;AACX,iHAAA,mBAAmB,OAAA;AACnB,gHAAA,kBAAkB,OAAA;AAClB,oHAAA,sBAAsB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/profiles/index.ts"],"names":[],"mappings":";;;AAiBA,iCAoBiB;AATf,sGAAA,aAAa,OAAA;AACb,qGAAA,YAAY,OAAA;AACZ,6GAAA,oBAAoB,OAAA;AAKpB,4GAAA,mBAAmB,OAAA;AACnB,6GAAA,oBAAoB,OAAA;AAItB,mCAA6E;AAApE,uGAAA,aAAa,OAAA;AAAE,qGAAA,WAAW,OAAA;AAAE,+GAAA,qBAAqB,OAAA;AAG1D,2CAQsB;AAPpB,0GAAA,YAAY,OAAA;AACZ,yGAAA,WAAW,OAAA;AACX,iHAAA,mBAAmB,OAAA;AACnB,gHAAA,kBAAkB,OAAA;AAClB,oHAAA,sBAAsB,OAAA;AAMxB,mDAS0B;AARxB,mHAAA,iBAAiB,OAAA;AACjB,mHAAA,iBAAiB,OAAA;AACjB,uHAAA,qBAAqB,OAAA;AACrB,wHAAA,sBAAsB,OAAA;AACtB,yHAAA,uBAAuB,OAAA;AACvB,oHAAA,kBAAkB,OAAA;AAClB,qHAAA,mBAAmB,OAAA;AACnB,sHAAA,oBAAoB,OAAA;AAItB,mDAM0B;AALxB,+GAAA,aAAa,OAAA;AACb,qHAAA,mBAAmB,OAAA;AAEnB,yHAAA,uBAAuB,OAAA;AACvB,kHAAA,gBAAgB,OAAA"}
@@ -0,0 +1,12 @@
1
+ import { ProjectConfig, ProjectPreset, ProjectProfile, ProfileValidationResult } from "./types";
2
+ export declare const PROJECT_CONFIG_DIR = ".gitlab-mcp";
3
+ export declare const PROJECT_PRESET_FILE = "preset.yaml";
4
+ export declare const PROJECT_PROFILE_FILE = "profile.yaml";
5
+ export declare function loadProjectConfig(repoPath: string): Promise<ProjectConfig | null>;
6
+ export declare function findProjectConfig(startPath: string): Promise<ProjectConfig | null>;
7
+ export declare function validateProjectPreset(preset: ProjectPreset): ProfileValidationResult;
8
+ export declare function validateProjectProfile(profile: ProjectProfile, availablePresets: string[]): ProfileValidationResult;
9
+ export declare function getProjectConfigSummary(config: ProjectConfig): {
10
+ presetSummary: string | null;
11
+ profileSummary: string | null;
12
+ };
@@ -0,0 +1,214 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.PROJECT_PROFILE_FILE = exports.PROJECT_PRESET_FILE = exports.PROJECT_CONFIG_DIR = void 0;
37
+ exports.loadProjectConfig = loadProjectConfig;
38
+ exports.findProjectConfig = findProjectConfig;
39
+ exports.validateProjectPreset = validateProjectPreset;
40
+ exports.validateProjectProfile = validateProjectProfile;
41
+ exports.getProjectConfigSummary = getProjectConfigSummary;
42
+ const fs = __importStar(require("fs/promises"));
43
+ const path = __importStar(require("path"));
44
+ const yaml = __importStar(require("yaml"));
45
+ const types_1 = require("./types");
46
+ const logger_1 = require("../logger");
47
+ exports.PROJECT_CONFIG_DIR = ".gitlab-mcp";
48
+ exports.PROJECT_PRESET_FILE = "preset.yaml";
49
+ exports.PROJECT_PROFILE_FILE = "profile.yaml";
50
+ async function loadProjectConfig(repoPath) {
51
+ const configDir = path.join(repoPath, exports.PROJECT_CONFIG_DIR);
52
+ try {
53
+ const stat = await fs.stat(configDir);
54
+ if (!stat.isDirectory()) {
55
+ logger_1.logger.warn({ path: configDir }, "Project config path exists but is not a directory");
56
+ return null;
57
+ }
58
+ }
59
+ catch {
60
+ logger_1.logger.debug({ path: configDir }, "No project config directory found");
61
+ return null;
62
+ }
63
+ const config = {
64
+ configPath: configDir,
65
+ };
66
+ const presetPath = path.join(configDir, exports.PROJECT_PRESET_FILE);
67
+ try {
68
+ const content = await fs.readFile(presetPath, "utf8");
69
+ const parsed = yaml.parse(content);
70
+ config.preset = types_1.ProjectPresetSchema.parse(parsed);
71
+ logger_1.logger.debug({ path: presetPath }, "Loaded project preset");
72
+ }
73
+ catch (error) {
74
+ if (error.code !== "ENOENT") {
75
+ const message = error instanceof Error ? error.message : String(error);
76
+ logger_1.logger.error({ error: message, path: presetPath }, "Failed to parse project preset");
77
+ throw new Error(`Invalid project preset at ${presetPath}: ${message}`);
78
+ }
79
+ }
80
+ const profilePath = path.join(configDir, exports.PROJECT_PROFILE_FILE);
81
+ try {
82
+ const content = await fs.readFile(profilePath, "utf8");
83
+ const parsed = yaml.parse(content);
84
+ config.profile = types_1.ProjectProfileSchema.parse(parsed);
85
+ logger_1.logger.debug({ path: profilePath }, "Loaded project profile");
86
+ }
87
+ catch (error) {
88
+ if (error.code !== "ENOENT") {
89
+ const message = error instanceof Error ? error.message : String(error);
90
+ logger_1.logger.error({ error: message, path: profilePath }, "Failed to parse project profile");
91
+ throw new Error(`Invalid project profile at ${profilePath}: ${message}`);
92
+ }
93
+ }
94
+ if (!config.preset && !config.profile) {
95
+ logger_1.logger.debug({ path: configDir }, "Project config directory exists but contains no config files");
96
+ return null;
97
+ }
98
+ logger_1.logger.info({
99
+ path: configDir,
100
+ hasPreset: !!config.preset,
101
+ hasProfile: !!config.profile,
102
+ }, "Loaded project configuration");
103
+ return config;
104
+ }
105
+ async function findProjectConfig(startPath) {
106
+ let currentPath = path.resolve(startPath);
107
+ const root = path.parse(currentPath).root;
108
+ while (currentPath !== root) {
109
+ const configDir = path.join(currentPath, exports.PROJECT_CONFIG_DIR);
110
+ try {
111
+ await fs.access(configDir);
112
+ return loadProjectConfig(currentPath);
113
+ }
114
+ catch {
115
+ }
116
+ const gitDir = path.join(currentPath, ".git");
117
+ try {
118
+ await fs.access(gitDir);
119
+ logger_1.logger.debug({ path: currentPath }, "Found .git without .gitlab-mcp, stopping search");
120
+ return null;
121
+ }
122
+ catch {
123
+ }
124
+ currentPath = path.dirname(currentPath);
125
+ }
126
+ return null;
127
+ }
128
+ function validateProjectPreset(preset) {
129
+ const errors = [];
130
+ const warnings = [];
131
+ if (preset.scope) {
132
+ const { project, namespace, projects } = preset.scope;
133
+ if (namespace && !project && !projects?.length) {
134
+ warnings.push(`Scope restricts to namespace '${namespace}' - all projects in this group are allowed`);
135
+ }
136
+ }
137
+ if (preset.denied_actions) {
138
+ for (const action of preset.denied_actions) {
139
+ const colonIndex = action.indexOf(":");
140
+ if (colonIndex === -1) {
141
+ errors.push(`Invalid denied_action format '${action}', expected 'tool:action'`);
142
+ }
143
+ }
144
+ }
145
+ return {
146
+ valid: errors.length === 0,
147
+ errors,
148
+ warnings,
149
+ };
150
+ }
151
+ function validateProjectProfile(profile, availablePresets) {
152
+ const errors = [];
153
+ const warnings = [];
154
+ if (profile.extends) {
155
+ if (!availablePresets.includes(profile.extends)) {
156
+ errors.push(`Unknown preset '${profile.extends}' in extends field`);
157
+ }
158
+ }
159
+ if (profile.additional_tools && profile.denied_tools) {
160
+ const overlap = profile.additional_tools.filter(t => profile.denied_tools?.includes(t));
161
+ if (overlap.length > 0) {
162
+ warnings.push(`Tools appear in both additional_tools and denied_tools: ${overlap.join(", ")}`);
163
+ }
164
+ }
165
+ return {
166
+ valid: errors.length === 0,
167
+ errors,
168
+ warnings,
169
+ };
170
+ }
171
+ function getProjectConfigSummary(config) {
172
+ let presetSummary = null;
173
+ let profileSummary = null;
174
+ if (config.preset) {
175
+ const parts = [];
176
+ if (config.preset.description) {
177
+ parts.push(config.preset.description);
178
+ }
179
+ if (config.preset.scope?.project) {
180
+ parts.push(`scope: ${config.preset.scope.project}`);
181
+ }
182
+ else if (config.preset.scope?.namespace) {
183
+ parts.push(`scope: ${config.preset.scope.namespace}/*`);
184
+ }
185
+ else if (config.preset.scope?.projects) {
186
+ parts.push(`scope: ${config.preset.scope.projects.length} projects`);
187
+ }
188
+ if (config.preset.read_only) {
189
+ parts.push("read-only");
190
+ }
191
+ if (config.preset.denied_actions?.length) {
192
+ parts.push(`${config.preset.denied_actions.length} denied actions`);
193
+ }
194
+ presetSummary = parts.join(", ") || "custom restrictions";
195
+ }
196
+ if (config.profile) {
197
+ const parts = [];
198
+ if (config.profile.description) {
199
+ parts.push(config.profile.description);
200
+ }
201
+ if (config.profile.extends) {
202
+ parts.push(`extends: ${config.profile.extends}`);
203
+ }
204
+ if (config.profile.additional_tools?.length) {
205
+ parts.push(`+${config.profile.additional_tools.length} tools`);
206
+ }
207
+ if (config.profile.denied_tools?.length) {
208
+ parts.push(`-${config.profile.denied_tools.length} tools`);
209
+ }
210
+ profileSummary = parts.join(", ") || "custom tool selection";
211
+ }
212
+ return { presetSummary, profileSummary };
213
+ }
214
+ //# sourceMappingURL=project-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-loader.js","sourceRoot":"","sources":["../../../src/profiles/project-loader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,8CAsEC;AAWD,8CA6BC;AAKD,sDAgCC;AAKD,wDA6BC;AAKD,0DA8CC;AA5QD,gDAAkC;AAClC,2CAA6B;AAC7B,2CAA6B;AAC7B,mCAOiB;AACjB,sCAAmC;AAOtB,QAAA,kBAAkB,GAAG,aAAa,CAAC;AAGnC,QAAA,mBAAmB,GAAG,aAAa,CAAC;AAGpC,QAAA,oBAAoB,GAAG,cAAc,CAAC;AAY5C,KAAK,UAAU,iBAAiB,CAAC,QAAgB;IACtD,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,0BAAkB,CAAC,CAAC;IAG1D,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACtC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;YACxB,eAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,mDAAmD,CAAC,CAAC;YACtF,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,eAAM,CAAC,KAAK,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AM,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;YAC/B,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QACzC,CAAC;QACD,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;YAC3B,KAAK,CAAC,IAAI,CAAC,YAAY,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;QACnD,CAAC;QACD,IAAI,MAAM,CAAC,OAAO,CAAC,gBAAgB,EAAE,MAAM,EAAE,CAAC;YAC5C,KAAK,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,MAAM,QAAQ,CAAC,CAAC;QACjE,CAAC;QACD,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,EAAE,CAAC;YACxC,KAAK,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM,QAAQ,CAAC,CAAC;QAC7D,CAAC;QACD,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,uBAAuB,CAAC;IAC/D,CAAC;IAED,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { ProjectPreset } from "./types";
2
+ export interface ScopeConfig {
3
+ project?: string;
4
+ namespace?: string;
5
+ projects?: string[];
6
+ }
7
+ export declare class ScopeViolationError extends Error {
8
+ readonly attemptedTarget: string;
9
+ readonly allowedScope: ScopeConfig;
10
+ constructor(attemptedTarget: string, allowedScope: ScopeConfig);
11
+ }
12
+ export declare class ScopeEnforcer {
13
+ private readonly scope;
14
+ private readonly allowedProjectsSet;
15
+ constructor(scope: ScopeConfig);
16
+ static fromPreset(preset: ProjectPreset): ScopeEnforcer | null;
17
+ isAllowed(projectPath: string): boolean;
18
+ enforce(projectPath: string): void;
19
+ getScope(): ScopeConfig;
20
+ getScopeDescription(): string;
21
+ hasRestrictions(): boolean;
22
+ }
23
+ export declare function extractProjectsFromArgs(args: Record<string, unknown>): string[];
24
+ export declare function enforceArgsScope(enforcer: ScopeEnforcer, args: Record<string, unknown>): void;