@structured-world/gitlab-mcp 6.15.0 → 6.17.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.
Files changed (40) hide show
  1. package/README.md +49 -0
  2. package/dist/src/cli-utils.d.ts +12 -0
  3. package/dist/src/cli-utils.js +151 -0
  4. package/dist/src/cli-utils.js.map +1 -0
  5. package/dist/src/discovery/auto.d.ts +22 -0
  6. package/dist/src/discovery/auto.js +170 -0
  7. package/dist/src/discovery/auto.js.map +1 -0
  8. package/dist/src/discovery/git-remote.d.ts +19 -0
  9. package/dist/src/discovery/git-remote.js +197 -0
  10. package/dist/src/discovery/git-remote.js.map +1 -0
  11. package/dist/src/discovery/index.d.ts +3 -0
  12. package/dist/src/discovery/index.js +16 -0
  13. package/dist/src/discovery/index.js.map +1 -0
  14. package/dist/src/discovery/profile-matcher.d.ts +8 -0
  15. package/dist/src/discovery/profile-matcher.js +40 -0
  16. package/dist/src/discovery/profile-matcher.js.map +1 -0
  17. package/dist/src/entities/core/schema-readonly.d.ts +4 -4
  18. package/dist/src/entities/mrs/schema-readonly.d.ts +1 -1
  19. package/dist/src/entities/pipelines/schema-readonly.d.ts +3 -3
  20. package/dist/src/main.js +120 -30
  21. package/dist/src/main.js.map +1 -1
  22. package/dist/src/profiles/index.d.ts +3 -1
  23. package/dist/src/profiles/index.js +17 -1
  24. package/dist/src/profiles/index.js.map +1 -1
  25. package/dist/src/profiles/project-loader.d.ts +12 -0
  26. package/dist/src/profiles/project-loader.js +214 -0
  27. package/dist/src/profiles/project-loader.js.map +1 -0
  28. package/dist/src/profiles/scope-enforcer.d.ts +24 -0
  29. package/dist/src/profiles/scope-enforcer.js +128 -0
  30. package/dist/src/profiles/scope-enforcer.js.map +1 -0
  31. package/dist/src/profiles/types.d.ts +55 -0
  32. package/dist/src/profiles/types.js +41 -1
  33. package/dist/src/profiles/types.js.map +1 -1
  34. package/dist/src/utils/namespace.d.ts +1 -0
  35. package/dist/src/utils/namespace.js +11 -0
  36. package/dist/src/utils/namespace.js.map +1 -1
  37. package/dist/structured-world-gitlab-mcp-6.17.0.tgz +0 -0
  38. package/dist/tsconfig.build.tsbuildinfo +1 -1
  39. package/package.json +1 -1
  40. package/dist/structured-world-gitlab-mcp-6.15.0.tgz +0 -0
@@ -0,0 +1,3 @@
1
+ export { parseGitRemote, parseRemoteUrl, parseGitConfig, selectBestRemote, listGitRemotes, GitRemoteInfo, ParseGitRemoteOptions, } from "./git-remote";
2
+ export { matchProfileByHost, findProfileByHost, ProfileMatchResult } from "./profile-matcher";
3
+ export { autoDiscover, formatDiscoveryResult, AutoDiscoveryOptions, AutoDiscoveryResult, } from "./auto";
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatDiscoveryResult = exports.autoDiscover = exports.findProfileByHost = exports.matchProfileByHost = exports.listGitRemotes = exports.selectBestRemote = exports.parseGitConfig = exports.parseRemoteUrl = exports.parseGitRemote = void 0;
4
+ var git_remote_1 = require("./git-remote");
5
+ Object.defineProperty(exports, "parseGitRemote", { enumerable: true, get: function () { return git_remote_1.parseGitRemote; } });
6
+ Object.defineProperty(exports, "parseRemoteUrl", { enumerable: true, get: function () { return git_remote_1.parseRemoteUrl; } });
7
+ Object.defineProperty(exports, "parseGitConfig", { enumerable: true, get: function () { return git_remote_1.parseGitConfig; } });
8
+ Object.defineProperty(exports, "selectBestRemote", { enumerable: true, get: function () { return git_remote_1.selectBestRemote; } });
9
+ Object.defineProperty(exports, "listGitRemotes", { enumerable: true, get: function () { return git_remote_1.listGitRemotes; } });
10
+ var profile_matcher_1 = require("./profile-matcher");
11
+ Object.defineProperty(exports, "matchProfileByHost", { enumerable: true, get: function () { return profile_matcher_1.matchProfileByHost; } });
12
+ Object.defineProperty(exports, "findProfileByHost", { enumerable: true, get: function () { return profile_matcher_1.findProfileByHost; } });
13
+ var auto_1 = require("./auto");
14
+ Object.defineProperty(exports, "autoDiscover", { enumerable: true, get: function () { return auto_1.autoDiscover; } });
15
+ Object.defineProperty(exports, "formatDiscoveryResult", { enumerable: true, get: function () { return auto_1.formatDiscoveryResult; } });
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/discovery/index.ts"],"names":[],"mappings":";;;AAsBA,2CAQsB;AAPpB,4GAAA,cAAc,OAAA;AACd,4GAAA,cAAc,OAAA;AACd,4GAAA,cAAc,OAAA;AACd,8GAAA,gBAAgB,OAAA;AAChB,4GAAA,cAAc,OAAA;AAMhB,qDAA8F;AAArF,qHAAA,kBAAkB,OAAA;AAAE,oHAAA,iBAAiB,OAAA;AAG9C,+BAKgB;AAJd,oGAAA,YAAY,OAAA;AACZ,6GAAA,qBAAqB,OAAA"}
@@ -0,0 +1,8 @@
1
+ import { ProfileLoader, ProfileInfo } from "../profiles";
2
+ export interface ProfileMatchResult {
3
+ profileName: string;
4
+ profile: ProfileInfo;
5
+ matchType: "exact" | "subdomain";
6
+ }
7
+ export declare function matchProfileByHost(host: string, profiles: ProfileInfo[]): ProfileMatchResult | null;
8
+ export declare function findProfileByHost(host: string, loader?: ProfileLoader): Promise<ProfileMatchResult | null>;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.matchProfileByHost = matchProfileByHost;
4
+ exports.findProfileByHost = findProfileByHost;
5
+ const profiles_1 = require("../profiles");
6
+ const logger_1 = require("../logger");
7
+ function matchProfileByHost(host, profiles) {
8
+ const normalizedHost = host.toLowerCase();
9
+ const userProfiles = profiles.filter((p) => typeof p.host === "string" && !p.isPreset);
10
+ for (const profile of userProfiles) {
11
+ const profileHost = profile.host.toLowerCase();
12
+ if (normalizedHost === profileHost) {
13
+ logger_1.logger.debug({ host, profile: profile.name, matchType: "exact" }, "Matched profile by exact host");
14
+ return {
15
+ profileName: profile.name,
16
+ profile,
17
+ matchType: "exact",
18
+ };
19
+ }
20
+ }
21
+ for (const profile of userProfiles) {
22
+ const profileHost = profile.host.toLowerCase();
23
+ if (normalizedHost.endsWith(`.${profileHost}`)) {
24
+ logger_1.logger.debug({ host, profile: profile.name, matchType: "subdomain" }, "Matched profile by subdomain");
25
+ return {
26
+ profileName: profile.name,
27
+ profile,
28
+ matchType: "subdomain",
29
+ };
30
+ }
31
+ }
32
+ logger_1.logger.debug({ host, availableHosts: userProfiles.map(p => p.host) }, "No profile match found");
33
+ return null;
34
+ }
35
+ async function findProfileByHost(host, loader) {
36
+ const profileLoader = loader ?? new profiles_1.ProfileLoader();
37
+ const profiles = await profileLoader.listProfiles();
38
+ return matchProfileByHost(host, profiles);
39
+ }
40
+ //# sourceMappingURL=profile-matcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profile-matcher.js","sourceRoot":"","sources":["../../../src/discovery/profile-matcher.ts"],"names":[],"mappings":";;AAqCA,gDA+CC;AASD,8CAOC;AA9FD,0CAAyD;AACzD,sCAAmC;AA8BnC,SAAgB,kBAAkB,CAChC,IAAY,EACZ,QAAuB;IAEvB,MAAM,cAAc,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IAI1C,MAAM,YAAY,GAAG,QAAQ,CAAC,MAAM,CAClC,CAAC,CAAC,EAAuC,EAAE,CAAC,OAAO,CAAC,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,CAAC,CAAC,QAAQ,CACtF,CAAC;IAGF,KAAK,MAAM,OAAO,IAAI,YAAY,EAAE,CAAC;QACnC,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;QAC/C,IAAI,cAAc,KAAK,WAAW,EAAE,CAAC;YACnC,eAAM,CAAC,KAAK,CACV,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,EACnD,+BAA+B,CAChC,CAAC;YACF,OAAO;gBACL,WAAW,EAAE,OAAO,CAAC,IAAI;gBACzB,OAAO;gBACP,SAAS,EAAE,OAAO;aACnB,CAAC;QACJ,CAAC;IACH,CAAC;IAID,KAAK,MAAM,OAAO,IAAI,YAAY,EAAE,CAAC;QACnC,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;QAC/C,IAAI,cAAc,CAAC,QAAQ,CAAC,IAAI,WAAW,EAAE,CAAC,EAAE,CAAC;YAC/C,eAAM,CAAC,KAAK,CACV,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,EACvD,8BAA8B,CAC/B,CAAC;YACF,OAAO;gBACL,WAAW,EAAE,OAAO,CAAC,IAAI;gBACzB,OAAO;gBACP,SAAS,EAAE,WAAW;aACvB,CAAC;QACJ,CAAC;IACH,CAAC;IAED,eAAM,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,wBAAwB,CAAC,CAAC;IAChG,OAAO,IAAI,CAAC;AACd,CAAC;AASM,KAAK,UAAU,iBAAiB,CACrC,IAAY,EACZ,MAAsB;IAEtB,MAAM,aAAa,GAAG,MAAM,IAAI,IAAI,wBAAa,EAAE,CAAC;IACpD,MAAM,QAAQ,GAAG,MAAM,aAAa,CAAC,YAAY,EAAE,CAAC;IACpD,OAAO,kBAAkB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAC5C,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,45 +4,135 @@ 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);
7
+ const cli_utils_1 = require("./cli-utils");
8
+ const discovery_1 = require("./discovery");
9
+ const namespace_1 = require("./utils/namespace");
10
+ async function main() {
11
+ const cliArgs = (0, cli_utils_1.parseCliArgs)();
12
+ if (cliArgs.showProjectConfig) {
13
+ try {
14
+ const projectConfig = await (0, profiles_1.findProjectConfig)(process.cwd());
15
+ (0, cli_utils_1.displayProjectConfig)(projectConfig);
16
+ process.exit(0);
17
+ }
18
+ catch (error) {
19
+ const message = error instanceof Error ? error.message : String(error);
20
+ logger_1.logger.error({ error: message }, "Failed to load project config");
21
+ process.exit(1);
22
+ }
23
+ }
24
+ let autoDiscoveryResult = null;
25
+ if (cliArgs.auto) {
26
+ try {
27
+ autoDiscoveryResult = await (0, discovery_1.autoDiscover)({
28
+ repoPath: cliArgs.cwd,
29
+ remoteName: cliArgs.remoteName,
30
+ noProjectConfig: true,
31
+ dryRun: cliArgs.dryRun,
32
+ });
33
+ if (autoDiscoveryResult) {
34
+ if (cliArgs.dryRun) {
35
+ console.log((0, discovery_1.formatDiscoveryResult)(autoDiscoveryResult));
36
+ process.exit(0);
37
+ }
38
+ logger_1.logger.info({
39
+ host: autoDiscoveryResult.host,
40
+ project: autoDiscoveryResult.projectPath,
41
+ profile: autoDiscoveryResult.matchedProfile?.profileName,
42
+ }, "Auto-discovery detected GitLab configuration");
17
43
  }
18
- profileCount++;
19
- if (profileCount === 1) {
20
- profileName = value;
44
+ else {
45
+ logger_1.logger.warn("Auto-discovery failed: not in a git repository or no remote found");
21
46
  }
22
47
  }
48
+ catch (error) {
49
+ const message = error instanceof Error ? error.message : String(error);
50
+ logger_1.logger.error({ error: message }, "Auto-discovery failed");
51
+ process.exit(1);
52
+ }
23
53
  }
24
- if (profileCount > 1) {
25
- logger_1.logger.warn({ count: profileCount }, "Multiple --profile flags detected, using first value");
54
+ if (cliArgs.profileName) {
55
+ try {
56
+ const result = await (0, profiles_1.tryApplyProfileFromEnv)(cliArgs.profileName);
57
+ if (result) {
58
+ if ("profileName" in result) {
59
+ logger_1.logger.info({ profile: result.profileName, host: result.host }, "Using CLI-specified profile");
60
+ }
61
+ else {
62
+ logger_1.logger.info({ preset: result.presetName }, "Using CLI-specified preset");
63
+ }
64
+ if (autoDiscoveryResult?.matchedProfile &&
65
+ autoDiscoveryResult.matchedProfile.profileName !== cliArgs.profileName) {
66
+ logger_1.logger.warn({
67
+ cliProfile: cliArgs.profileName,
68
+ autoProfile: autoDiscoveryResult.matchedProfile.profileName,
69
+ }, "Auto-discovered profile ignored: --profile takes precedence");
70
+ }
71
+ }
72
+ }
73
+ catch (error) {
74
+ const message = error instanceof Error ? error.message : String(error);
75
+ logger_1.logger.error({ error: message }, "Failed to load profile");
76
+ process.exit(1);
77
+ }
26
78
  }
27
- return profileName;
28
- }
29
- async function main() {
30
- const profileName = getProfileFromArgs();
31
- try {
32
- const result = await (0, profiles_1.tryApplyProfileFromEnv)(profileName);
33
- if (result) {
34
- if ("profileName" in result) {
35
- logger_1.logger.info({ profile: result.profileName, host: result.host }, "Using configuration profile");
79
+ else if (autoDiscoveryResult?.matchedProfile) {
80
+ try {
81
+ const result = await (0, profiles_1.tryApplyProfileFromEnv)(autoDiscoveryResult.matchedProfile.profileName);
82
+ if (result && "profileName" in result) {
83
+ logger_1.logger.info({ profile: result.profileName, host: result.host }, "Using auto-discovered profile");
36
84
  }
37
- else {
38
- logger_1.logger.info({ preset: result.presetName }, "Using configuration preset");
85
+ }
86
+ catch (error) {
87
+ const message = error instanceof Error ? error.message : String(error);
88
+ logger_1.logger.warn({ error: message }, "Failed to apply auto-discovered profile");
89
+ }
90
+ }
91
+ else {
92
+ try {
93
+ const result = await (0, profiles_1.tryApplyProfileFromEnv)();
94
+ if (result) {
95
+ if ("profileName" in result) {
96
+ logger_1.logger.info({ profile: result.profileName, host: result.host }, "Using configuration profile");
97
+ }
98
+ else {
99
+ logger_1.logger.info({ preset: result.presetName }, "Using configuration preset");
100
+ }
101
+ }
102
+ }
103
+ catch (error) {
104
+ const message = error instanceof Error ? error.message : String(error);
105
+ logger_1.logger.error({ error: message }, "Failed to load profile");
106
+ process.exit(1);
107
+ }
108
+ }
109
+ if (!cliArgs.noProjectConfig) {
110
+ try {
111
+ const projectConfig = await (0, profiles_1.findProjectConfig)(process.cwd());
112
+ if (projectConfig) {
113
+ const summary = (0, profiles_1.getProjectConfigSummary)(projectConfig);
114
+ logger_1.logger.info({
115
+ path: projectConfig.configPath,
116
+ preset: summary.presetSummary,
117
+ profile: summary.profileSummary,
118
+ }, "Loaded project configuration (restrictions applied)");
39
119
  }
40
120
  }
121
+ catch (error) {
122
+ const message = error instanceof Error ? error.message : String(error);
123
+ logger_1.logger.warn({ error: message }, "Failed to load project config, continuing without it");
124
+ }
41
125
  }
42
- catch (error) {
43
- const message = error instanceof Error ? error.message : String(error);
44
- logger_1.logger.error({ error: message }, "Failed to load profile");
45
- process.exit(1);
126
+ if (autoDiscoveryResult) {
127
+ process.env.GITLAB_DEFAULT_PROJECT ??= autoDiscoveryResult.projectPath;
128
+ const namespace = (0, namespace_1.extractNamespaceFromPath)(autoDiscoveryResult.projectPath);
129
+ if (namespace) {
130
+ process.env.GITLAB_DEFAULT_NAMESPACE ??= namespace;
131
+ }
132
+ logger_1.logger.debug({
133
+ defaultProject: process.env.GITLAB_DEFAULT_PROJECT,
134
+ defaultNamespace: process.env.GITLAB_DEFAULT_NAMESPACE,
135
+ }, "Default context set from auto-discovery");
46
136
  }
47
137
  await (0, server_1.startServer)();
48
138
  }
@@ -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,IAAI,WAA+B,CAAC;IACpC,IAAI,YAAY,GAAG,CAAC,CAAC;IAErB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CA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ACtB,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