@contentrain/mcp 1.2.1 → 1.4.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 (183) hide show
  1. package/README.md +93 -25
  2. package/dist/annotations-Clhbw2lh.mjs +126 -0
  3. package/dist/annotations-Clhbw2lh.mjs.map +1 -0
  4. package/dist/{apply-manager-BkPMfpsN.mjs → apply-manager-D5ym5Jba.mjs} +7 -7
  5. package/dist/{apply-manager-BkPMfpsN.mjs.map → apply-manager-D5ym5Jba.mjs.map} +1 -1
  6. package/dist/{astro-parser-BJ-54JGe.mjs → astro-parser-B-nLl0zE.mjs} +3 -3
  7. package/dist/{astro-parser-BJ-54JGe.mjs.map → astro-parser-B-nLl0zE.mjs.map} +1 -1
  8. package/dist/{branch-lifecycle-wGJg25LT.mjs → branch-lifecycle-CFVpTpNT.mjs} +33 -3
  9. package/dist/{branch-lifecycle-wGJg25LT.mjs.map → branch-lifecycle-CFVpTpNT.mjs.map} +1 -1
  10. package/dist/{compiler-rIC4ETHv.mjs → compiler-k4yttlzM.mjs} +2 -2
  11. package/dist/{compiler-rIC4ETHv.mjs.map → compiler-k4yttlzM.mjs.map} +1 -1
  12. package/dist/{compiler-sfc.cjs-BbD04rn_.mjs → compiler-sfc.cjs-D0d_OicF.mjs} +2 -2
  13. package/dist/{compiler-sfc.cjs-BbD04rn_.mjs.map → compiler-sfc.cjs-D0d_OicF.mjs.map} +1 -1
  14. package/dist/config-BIl5Ybj0.mjs +40 -0
  15. package/dist/config-BIl5Ybj0.mjs.map +1 -0
  16. package/dist/content-manager-DqDLSNQ-.d.mts +63 -0
  17. package/dist/content-manager-DqDLSNQ-.d.mts.map +1 -0
  18. package/dist/context-J0OU9Nfp.mjs +102 -0
  19. package/dist/context-J0OU9Nfp.mjs.map +1 -0
  20. package/dist/contracts-DfL0BfrD.mjs +2 -0
  21. package/dist/core/apply-manager.mjs +10 -10
  22. package/dist/core/config.d.mts +13 -0
  23. package/dist/core/config.d.mts.map +1 -1
  24. package/dist/core/config.mjs +2 -3
  25. package/dist/core/content-manager.d.mts +2 -45
  26. package/dist/core/content-manager.mjs +3 -4
  27. package/dist/core/context.d.mts +32 -2
  28. package/dist/core/context.d.mts.map +1 -1
  29. package/dist/core/context.mjs +7 -7
  30. package/dist/core/contracts/index.d.mts +2 -0
  31. package/dist/core/contracts/index.mjs +2 -0
  32. package/dist/core/doctor.d.mts +76 -0
  33. package/dist/core/doctor.d.mts.map +1 -0
  34. package/dist/core/doctor.mjs +8 -0
  35. package/dist/core/graph-builder.mjs +3 -4
  36. package/dist/core/meta-manager.mjs +2 -3
  37. package/dist/core/model-manager.d.mts +34 -1
  38. package/dist/core/model-manager.d.mts.map +1 -1
  39. package/dist/core/model-manager.mjs +3 -4
  40. package/dist/core/ops/index.d.mts +137 -0
  41. package/dist/core/ops/index.d.mts.map +1 -0
  42. package/dist/core/ops/index.mjs +4 -0
  43. package/dist/core/overlay-reader.d.mts +42 -0
  44. package/dist/core/overlay-reader.d.mts.map +1 -0
  45. package/dist/core/overlay-reader.mjs +2 -0
  46. package/dist/core/scan-config.mjs +2 -3
  47. package/dist/core/scanner.mjs +4 -5
  48. package/dist/core/validator/index.d.mts +129 -0
  49. package/dist/core/validator/index.d.mts.map +1 -0
  50. package/dist/core/validator/index.mjs +6 -0
  51. package/dist/{detect-DinOQAmK.mjs → detect-DL9mFmaS.mjs} +2 -2
  52. package/dist/{detect-DinOQAmK.mjs.map → detect-DL9mFmaS.mjs.map} +1 -1
  53. package/dist/doctor-CgBoT6h1.mjs +338 -0
  54. package/dist/doctor-CgBoT6h1.mjs.map +1 -0
  55. package/dist/{fs-BnIQ4dKj.mjs → fs-DLbVB-Ek.mjs} +2 -2
  56. package/dist/fs-DLbVB-Ek.mjs.map +1 -0
  57. package/dist/git/branch-lifecycle.d.mts +30 -1
  58. package/dist/git/branch-lifecycle.d.mts.map +1 -1
  59. package/dist/git/branch-lifecycle.mjs +4 -5
  60. package/dist/git/transaction.d.mts +2 -2
  61. package/dist/git/transaction.d.mts.map +1 -1
  62. package/dist/git/transaction.mjs +8 -8
  63. package/dist/{graph-builder-tM7zj-SX.mjs → graph-builder-DXv2JEp-.mjs} +3 -3
  64. package/dist/{graph-builder-tM7zj-SX.mjs.map → graph-builder-DXv2JEp-.mjs.map} +1 -1
  65. package/dist/{id-DV_T9Ic8.mjs → id-CIO9s0x_.mjs} +1 -1
  66. package/dist/{id-DV_T9Ic8.mjs.map → id-CIO9s0x_.mjs.map} +1 -1
  67. package/dist/index-D0wQJSgs.d.mts +2 -0
  68. package/dist/index.mjs +22 -17
  69. package/dist/index.mjs.map +1 -1
  70. package/dist/local-DvP4Y4T-.mjs +182 -0
  71. package/dist/local-DvP4Y4T-.mjs.map +1 -0
  72. package/dist/{meta-manager--0IwAPCl.mjs → meta-manager-C900rEyG.mjs} +2 -2
  73. package/dist/{meta-manager--0IwAPCl.mjs.map → meta-manager-C900rEyG.mjs.map} +1 -1
  74. package/dist/{model-manager-DW_fOGRM.mjs → model-manager-BhLsUgaB.mjs} +241 -49
  75. package/dist/model-manager-BhLsUgaB.mjs.map +1 -0
  76. package/dist/{node-Cbq5eR5i.mjs → node-DN9hZeil.mjs} +1 -1
  77. package/dist/{node-Cbq5eR5i.mjs.map → node-DN9hZeil.mjs.map} +1 -1
  78. package/dist/ops-DjEWi5Wa.mjs +486 -0
  79. package/dist/ops-DjEWi5Wa.mjs.map +1 -0
  80. package/dist/overlay-reader-DOdyDRIv.mjs +74 -0
  81. package/dist/overlay-reader-DOdyDRIv.mjs.map +1 -0
  82. package/dist/paths-C3xNyc7z.mjs +52 -0
  83. package/dist/paths-C3xNyc7z.mjs.map +1 -0
  84. package/dist/paths-CYl5vCBD.mjs +54 -0
  85. package/dist/paths-CYl5vCBD.mjs.map +1 -0
  86. package/dist/providers/github/index.d.mts +201 -0
  87. package/dist/providers/github/index.d.mts.map +1 -0
  88. package/dist/providers/github/index.mjs +494 -0
  89. package/dist/providers/github/index.mjs.map +1 -0
  90. package/dist/providers/gitlab/index.d.mts +158 -0
  91. package/dist/providers/gitlab/index.d.mts.map +1 -0
  92. package/dist/providers/gitlab/index.mjs +361 -0
  93. package/dist/providers/gitlab/index.mjs.map +1 -0
  94. package/dist/providers/local/index.d.mts +106 -0
  95. package/dist/providers/local/index.d.mts.map +1 -0
  96. package/dist/providers/local/index.mjs +12 -0
  97. package/dist/{scan-config-QgnJ1-52.mjs → scan-config-jC6XmiqF.mjs} +2 -2
  98. package/dist/{scan-config-QgnJ1-52.mjs.map → scan-config-jC6XmiqF.mjs.map} +1 -1
  99. package/dist/{scanner-DUoXnmtI.mjs → scanner-DKMwc03k.mjs} +7 -7
  100. package/dist/{scanner-DUoXnmtI.mjs.map → scanner-DKMwc03k.mjs.map} +1 -1
  101. package/dist/serialization-B1CEzR4H.mjs +2 -0
  102. package/dist/server/http/index.d.mts +107 -0
  103. package/dist/server/http/index.d.mts.map +1 -0
  104. package/dist/server/http/index.mjs +248 -0
  105. package/dist/server/http/index.mjs.map +1 -0
  106. package/dist/{server-Dtq8vqbK.mjs → server-BkhhtEE2.mjs} +486 -355
  107. package/dist/server-BkhhtEE2.mjs.map +1 -0
  108. package/dist/server-WqGx6ait.d.mts +50 -0
  109. package/dist/server-WqGx6ait.d.mts.map +1 -0
  110. package/dist/server.d.mts +2 -7
  111. package/dist/server.mjs +22 -17
  112. package/dist/{source-map-generator-DpO-ejrt.mjs → source-map-generator-BWDva49I.mjs} +1 -1
  113. package/dist/{source-map-generator-DpO-ejrt.mjs.map → source-map-generator-BWDva49I.mjs.map} +1 -1
  114. package/dist/{svelte-parser-1bBcMx3T.mjs → svelte-parser-Dr9mmZuk.mjs} +3 -3
  115. package/dist/{svelte-parser-1bBcMx3T.mjs.map → svelte-parser-Dr9mmZuk.mjs.map} +1 -1
  116. package/dist/templates/index.mjs +1 -1
  117. package/dist/{templates-bRPzYq4M.mjs → templates-VrLVqfe5.mjs} +1 -1
  118. package/dist/{templates-bRPzYq4M.mjs.map → templates-VrLVqfe5.mjs.map} +1 -1
  119. package/dist/testing/conformance.d.mts +59 -0
  120. package/dist/testing/conformance.d.mts.map +1 -0
  121. package/dist/testing/conformance.mjs +59 -0
  122. package/dist/testing/conformance.mjs.map +1 -0
  123. package/dist/tools/annotations.d.mts +24 -0
  124. package/dist/tools/annotations.d.mts.map +1 -0
  125. package/dist/tools/annotations.mjs +2 -0
  126. package/dist/{transaction-C_Pvux78.mjs → transaction-DgkNgWSI.mjs} +61 -32
  127. package/dist/transaction-DgkNgWSI.mjs.map +1 -0
  128. package/dist/tsx-parser-BOMZE_yQ.mjs +2 -0
  129. package/dist/{tsx-parser-BWiMGAIR.mjs → tsx-parser-CQc6nr-o.mjs} +1 -1
  130. package/dist/{tsx-parser-BWiMGAIR.mjs.map → tsx-parser-CQc6nr-o.mjs.map} +1 -1
  131. package/dist/util/detect.mjs +2 -3
  132. package/dist/util/fs.mjs +1 -2
  133. package/dist/util/id.mjs +1 -1
  134. package/dist/validator-B0nNRFeU.mjs +906 -0
  135. package/dist/validator-B0nNRFeU.mjs.map +1 -0
  136. package/dist/{vue-parser-DTPTN3Yb.mjs → vue-parser-COgjArqv.mjs} +3 -3
  137. package/dist/{vue-parser-DTPTN3Yb.mjs.map → vue-parser-COgjArqv.mjs.map} +1 -1
  138. package/package.json +82 -23
  139. package/testing/conformance/01-new-collection-entry/expected/.contentrain/config.json +15 -0
  140. package/testing/conformance/01-new-collection-entry/expected/.contentrain/content/blog/blog/en.json +6 -0
  141. package/testing/conformance/01-new-collection-entry/expected/.contentrain/context.json +22 -0
  142. package/testing/conformance/01-new-collection-entry/expected/.contentrain/meta/blog/en.json +7 -0
  143. package/testing/conformance/01-new-collection-entry/expected/.contentrain/models/blog.json +16 -0
  144. package/testing/conformance/01-new-collection-entry/scenario.json +19 -0
  145. package/testing/conformance/01-new-collection-entry/setup/.contentrain/config.json +15 -0
  146. package/testing/conformance/01-new-collection-entry/setup/.contentrain/models/blog.json +16 -0
  147. package/testing/conformance/02-new-singleton/expected/.contentrain/config.json +15 -0
  148. package/testing/conformance/02-new-singleton/expected/.contentrain/content/marketing/hero/en.json +4 -0
  149. package/testing/conformance/02-new-singleton/expected/.contentrain/context.json +22 -0
  150. package/testing/conformance/02-new-singleton/expected/.contentrain/meta/hero/en.json +5 -0
  151. package/testing/conformance/02-new-singleton/expected/.contentrain/models/hero.json +16 -0
  152. package/testing/conformance/02-new-singleton/scenario.json +18 -0
  153. package/testing/conformance/02-new-singleton/setup/.contentrain/config.json +15 -0
  154. package/testing/conformance/02-new-singleton/setup/.contentrain/models/hero.json +16 -0
  155. package/testing/conformance/03-new-dictionary/expected/.contentrain/config.json +15 -0
  156. package/testing/conformance/03-new-dictionary/expected/.contentrain/content/marketing/ui-strings/en.json +5 -0
  157. package/testing/conformance/03-new-dictionary/expected/.contentrain/context.json +22 -0
  158. package/testing/conformance/03-new-dictionary/expected/.contentrain/meta/ui-strings/en.json +5 -0
  159. package/testing/conformance/03-new-dictionary/expected/.contentrain/models/ui-strings.json +7 -0
  160. package/testing/conformance/03-new-dictionary/scenario.json +19 -0
  161. package/testing/conformance/03-new-dictionary/setup/.contentrain/config.json +15 -0
  162. package/testing/conformance/03-new-dictionary/setup/.contentrain/models/ui-strings.json +7 -0
  163. package/testing/conformance/README.md +77 -0
  164. package/testing/conformance/scenarios.json +36 -0
  165. package/dist/config-B5kc2oeV.mjs +0 -27
  166. package/dist/config-B5kc2oeV.mjs.map +0 -1
  167. package/dist/context-DIDt_TxX.mjs +0 -46
  168. package/dist/context-DIDt_TxX.mjs.map +0 -1
  169. package/dist/core/content-manager.d.mts.map +0 -1
  170. package/dist/core/validator.d.mts +0 -23
  171. package/dist/core/validator.d.mts.map +0 -1
  172. package/dist/core/validator.mjs +0 -7
  173. package/dist/fs-BnIQ4dKj.mjs.map +0 -1
  174. package/dist/model-manager-DW_fOGRM.mjs.map +0 -1
  175. package/dist/serializer-CnHTtmc1.mjs +0 -2
  176. package/dist/server-Dtq8vqbK.mjs.map +0 -1
  177. package/dist/server.d.mts.map +0 -1
  178. package/dist/transaction-C_Pvux78.mjs.map +0 -1
  179. package/dist/tsx-parser-BFLv292Y.mjs +0 -2
  180. package/dist/util/serializer.d.mts +0 -2
  181. package/dist/util/serializer.mjs +0 -2
  182. package/dist/validator-SQYUV2JP.mjs +0 -581
  183. package/dist/validator-SQYUV2JP.mjs.map +0 -1
@@ -0,0 +1,158 @@
1
+ import { c as MergeResult, d as RepoReader, i as CommitAuthor, l as ProviderCapabilities, n as Branch, o as FileDiff, r as Commit, t as ApplyPlanInput, u as RepoProvider } from "../../index-D0wQJSgs.mjs";
2
+ import { Gitlab } from "@gitbeaker/rest";
3
+
4
+ //#region src/providers/gitlab/capabilities.d.ts
5
+ /**
6
+ * Capability set for GitLabProvider.
7
+ *
8
+ * GitLab over REST has no working tree, so local worktree features,
9
+ * source-file access and AST scans are unavailable. Push, merge and
10
+ * branch-protection detection all work over the API. GitLab enforces
11
+ * merges through merge requests, so `pullRequestFallback` is `true` —
12
+ * `mergeBranch` opens an MR and auto-accepts it to match GitHub's
13
+ * `repos.merge` semantics while still leaving an audit trail.
14
+ */
15
+ declare const GITLAB_CAPABILITIES: ProviderCapabilities;
16
+ //#endregion
17
+ //#region src/providers/gitlab/client.d.ts
18
+ /**
19
+ * Type alias for a `Gitlab` instance from `@gitbeaker/rest`.
20
+ *
21
+ * Provider code operates against this narrow surface so callers can
22
+ * pass a fully constructed gitbeaker client, a carefully faked one for
23
+ * unit tests, or an instance created by {@link createGitLabClient} in
24
+ * `factory.ts`. The import is type-only so the runtime dependency
25
+ * stays a pure optional peer.
26
+ */
27
+ type GitLabClient = InstanceType<typeof Gitlab>;
28
+ //#endregion
29
+ //#region src/providers/gitlab/types.d.ts
30
+ /**
31
+ * A reference to a GitLab project.
32
+ *
33
+ * `projectId` accepts the numeric project ID or a URL-encoded path
34
+ * (`namespace/project`). Gitbeaker URL-encodes string paths internally,
35
+ * so either form is fine.
36
+ *
37
+ * `contentRoot` is the repo-relative directory prefix where Contentrain
38
+ * content lives. For a flat content repo it stays `''`; for a monorepo
39
+ * where Contentrain sits under `apps/web/.contentrain/` it holds that
40
+ * prefix. All reader/writer paths are joined against it.
41
+ *
42
+ * `host` points at a self-hosted GitLab instance. Leave undefined to
43
+ * use `https://gitlab.com` (gitbeaker's default).
44
+ */
45
+ interface ProjectRef {
46
+ projectId: string | number;
47
+ contentRoot?: string;
48
+ host?: string;
49
+ }
50
+ /**
51
+ * Authentication options for the GitLab provider.
52
+ *
53
+ * - `pat` — personal access token with the `api` scope. Simplest for
54
+ * self-hosted MCP or CI runners.
55
+ * - `oauth` — OAuth2 token. Used when the runner is driven by a GitLab
56
+ * OAuth flow.
57
+ * - `job` — CI job token (`CI_JOB_TOKEN`). Scoped to the running
58
+ * pipeline; useful for pipeline-driven content updates.
59
+ */
60
+ type GitLabAuth = {
61
+ type: 'pat';
62
+ token: string;
63
+ } | {
64
+ type: 'oauth';
65
+ oauthToken: string;
66
+ } | {
67
+ type: 'job';
68
+ jobToken: string;
69
+ };
70
+ /** Default author used when a call does not provide one. */
71
+ declare const DEFAULT_GITLAB_AUTHOR: CommitAuthor;
72
+ //#endregion
73
+ //#region src/providers/gitlab/provider.d.ts
74
+ /**
75
+ * GitLabProvider — `RepoProvider` backed by the gitbeaker-driven GitLab
76
+ * REST API.
77
+ *
78
+ * Transport-agnostic: the provider only talks to a `GitLabClient`
79
+ * (a `@gitbeaker/rest` `Gitlab` instance). `createGitLabProvider` in
80
+ * `factory.ts` wraps the dynamic import so consumers never touch
81
+ * `@gitbeaker/rest` directly unless they want to.
82
+ *
83
+ * Capability gaps versus `GitHubProvider`: none — both providers
84
+ * expose the same set. GitLab's merge flow routes through an MR under
85
+ * the hood, but `mergeBranch` presents the same `MergeResult` shape.
86
+ */
87
+ declare class GitLabProvider implements RepoProvider {
88
+ private readonly client;
89
+ readonly project: ProjectRef;
90
+ readonly capabilities: ProviderCapabilities;
91
+ private readonly reader;
92
+ constructor(client: GitLabClient, project: ProjectRef);
93
+ readFile(path: string, ref?: string): Promise<string>;
94
+ listDirectory(path: string, ref?: string): Promise<string[]>;
95
+ fileExists(path: string, ref?: string): Promise<boolean>;
96
+ applyPlan(input: ApplyPlanInput): Promise<Commit>;
97
+ listBranches(prefix?: string): Promise<Branch[]>;
98
+ createBranch(name: string, fromRef?: string): Promise<void>;
99
+ deleteBranch(name: string): Promise<void>;
100
+ getBranchDiff(branch: string, base?: string): Promise<FileDiff[]>;
101
+ mergeBranch(branch: string, into: string): Promise<MergeResult>;
102
+ isMerged(branch: string, into?: string): Promise<boolean>;
103
+ getDefaultBranch(): Promise<string>;
104
+ }
105
+ //#endregion
106
+ //#region src/providers/gitlab/factory.d.ts
107
+ /**
108
+ * Create a gitbeaker-backed `GitLabClient` from an auth configuration.
109
+ *
110
+ * The `@gitbeaker/rest` module is imported dynamically so it stays a
111
+ * pure optional peer dependency — self-hosted MCP on stdio runs fine
112
+ * without it. If the module is not installed, the import throws with
113
+ * a helpful hint pointing the operator at the peer dependency.
114
+ *
115
+ * Supported auth types: `pat`, `oauth`, `job`. All three are thin
116
+ * wrappers over gitbeaker's `token`, `oauthToken`, and `jobToken`
117
+ * constructor options.
118
+ */
119
+ declare function createGitLabClient(auth: GitLabAuth, host?: string): Promise<GitLabClient>;
120
+ /**
121
+ * Factory for the full provider — instantiates a gitbeaker client and
122
+ * wraps it in a `GitLabProvider`. Consumers who already hold a
123
+ * gitbeaker instance (HTTP server injecting shared clients, tests,
124
+ * etc.) should instantiate `GitLabProvider` directly instead.
125
+ */
126
+ declare function createGitLabProvider(opts: {
127
+ auth: GitLabAuth;
128
+ project: ProjectRef;
129
+ }): Promise<GitLabProvider>;
130
+ //#endregion
131
+ //#region src/providers/gitlab/reader.d.ts
132
+ /**
133
+ * GitLabReader — `RepoReader` backed by the GitLab REST API.
134
+ *
135
+ * File reads go through `RepositoryFiles.showRaw`, which returns the
136
+ * file content as UTF-8 text (or a `Blob` on browser/edge runtimes we
137
+ * decode with `.text()`). Directory listings go through
138
+ * `Repositories.allRepositoryTrees`. `fileExists` tries the file
139
+ * endpoint first and falls back to a tree listing so directories
140
+ * resolve to `true` as well — matching LocalReader / GitHubReader.
141
+ *
142
+ * `ref` is forwarded verbatim and may be a branch name, tag name or
143
+ * commit SHA. Callers should always pass the explicit `contentrain`
144
+ * tracking branch; GitLab's default resolution is the project's
145
+ * default branch, which is usually wrong for Contentrain flows.
146
+ */
147
+ declare class GitLabReader implements RepoReader {
148
+ private readonly client;
149
+ private readonly project;
150
+ constructor(client: GitLabClient, project: ProjectRef);
151
+ readFile(path: string, ref?: string): Promise<string>;
152
+ listDirectory(path: string, ref?: string): Promise<string[]>;
153
+ fileExists(path: string, ref?: string): Promise<boolean>;
154
+ private resolveDefaultRef;
155
+ }
156
+ //#endregion
157
+ export { DEFAULT_GITLAB_AUTHOR, GITLAB_CAPABILITIES, type GitLabAuth, type GitLabClient, GitLabProvider, GitLabReader, type ProjectRef, createGitLabClient, createGitLabProvider };
158
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../../src/providers/gitlab/capabilities.ts","../../../src/providers/gitlab/client.ts","../../../src/providers/gitlab/types.ts","../../../src/providers/gitlab/provider.ts","../../../src/providers/gitlab/factory.ts","../../../src/providers/gitlab/reader.ts"],"mappings":";;;;;;;AAYA;;;;;;;cAAa,mBAAA,EAAqB,oBAAA;;;;;;AAAlC;;;;;;KCDY,YAAA,GAAe,YAAA,QAAoB,MAAA;;;;;;ADC/C;;;;;;;;ACDA;;;;UCMiB,UAAA;EACf,SAAA;EACA,WAAA;EACA,IAAA;AAAA;;;;;;;;;AAaF;;KAAY,UAAA;EACN,IAAA;EAAa,KAAA;AAAA;EACb,IAAA;EAAe,UAAA;AAAA;EACf,IAAA;EAAa,QAAA;AAAA;AAGnB;AAAA,cAAa,qBAAA,EAAuB,YAAA;;;;AF3BpC;;;;;;;;ACDA;;;;cE0Ba,cAAA,YAA0B,YAAA;EA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AAA,QA8BhC,iBAAA;AAAA"}
@@ -0,0 +1,361 @@
1
+ import { n as isNotFoundError, t as resolveRepoPath } from "../../paths-C3xNyc7z.mjs";
2
+ import { CONTENTRAIN_BRANCH } from "@contentrain/types";
3
+ //#region src/providers/gitlab/capabilities.ts
4
+ /**
5
+ * Capability set for GitLabProvider.
6
+ *
7
+ * GitLab over REST has no working tree, so local worktree features,
8
+ * source-file access and AST scans are unavailable. Push, merge and
9
+ * branch-protection detection all work over the API. GitLab enforces
10
+ * merges through merge requests, so `pullRequestFallback` is `true` —
11
+ * `mergeBranch` opens an MR and auto-accepts it to match GitHub's
12
+ * `repos.merge` semantics while still leaving an audit trail.
13
+ */
14
+ const GITLAB_CAPABILITIES = {
15
+ localWorktree: false,
16
+ sourceRead: false,
17
+ sourceWrite: false,
18
+ pushRemote: true,
19
+ branchProtection: true,
20
+ pullRequestFallback: true,
21
+ astScan: false
22
+ };
23
+ //#endregion
24
+ //#region src/providers/gitlab/apply-plan.ts
25
+ /**
26
+ * Apply a plan to a GitLab repository as a single atomic commit via the
27
+ * Commits API. High-level flow:
28
+ *
29
+ * 1. Check whether the target branch exists. If it does not, GitLab's
30
+ * `startBranch` option forks a new branch from `input.base` (or the
31
+ * project's default branch) as part of the same commit.
32
+ * 2. For each `FileChange`, figure out the right GitLab action verb
33
+ * (`create` vs `update` vs `delete`) by probing the path against the
34
+ * resolved ref. GitLab validates this server-side and returns a 400
35
+ * for mismatches — we avoid the round trip by getting it right up
36
+ * front.
37
+ * 3. POST `/repository/commits` once with the full action set. No
38
+ * working tree, no multi-call tree-assembly dance — GitLab exposes
39
+ * a richer primitive than the GitHub Git Data API for this case.
40
+ *
41
+ * The commit is durable as soon as the call returns; GitLab's ref
42
+ * update happens inside the same request.
43
+ */
44
+ async function applyPlanToGitLab(client, project, input) {
45
+ const branchExists = await branchHasRef(client, project, input.branch);
46
+ const baseBranch = input.base ?? CONTENTRAIN_BRANCH;
47
+ const refForActionResolution = branchExists ? input.branch : baseBranch;
48
+ const actions = (await Promise.all(input.changes.map((change) => resolveAction(client, project, refForActionResolution, change)))).filter((a) => a !== null);
49
+ if (actions.length === 0) throw new Error("applyPlanToGitLab: plan contained no applicable actions");
50
+ const options = {
51
+ authorName: input.author.name,
52
+ authorEmail: input.author.email
53
+ };
54
+ if (!branchExists) options.startBranch = baseBranch;
55
+ const commit = await client.Commits.create(project.projectId, input.branch, input.message, actions, options);
56
+ const commitTimestamp = toIsoTimestamp(commit.created_at) ?? (/* @__PURE__ */ new Date()).toISOString();
57
+ return {
58
+ sha: commit.id,
59
+ message: commit.message ?? input.message,
60
+ author: {
61
+ name: commit.author_name ?? input.author.name,
62
+ email: commit.author_email ?? input.author.email
63
+ },
64
+ timestamp: commitTimestamp
65
+ };
66
+ }
67
+ async function resolveAction(client, project, ref, change) {
68
+ const filePath = resolveRepoPath(project.contentRoot, change.path);
69
+ const exists = await fileExistsAtRef(client, project, filePath, ref);
70
+ if (change.content === null) {
71
+ if (!exists) return null;
72
+ return {
73
+ action: "delete",
74
+ filePath
75
+ };
76
+ }
77
+ return {
78
+ action: exists ? "update" : "create",
79
+ filePath,
80
+ content: change.content,
81
+ encoding: "text"
82
+ };
83
+ }
84
+ async function branchHasRef(client, project, branch) {
85
+ try {
86
+ await client.Branches.show(project.projectId, branch);
87
+ return true;
88
+ } catch (error) {
89
+ if (isNotFoundError(error)) return false;
90
+ throw error;
91
+ }
92
+ }
93
+ async function fileExistsAtRef(client, project, filePath, ref) {
94
+ try {
95
+ await client.RepositoryFiles.show(project.projectId, filePath, ref);
96
+ return true;
97
+ } catch (error) {
98
+ if (isNotFoundError(error)) return false;
99
+ throw error;
100
+ }
101
+ }
102
+ function toIsoTimestamp(raw) {
103
+ if (typeof raw !== "string") return null;
104
+ const date = new Date(raw);
105
+ if (Number.isNaN(date.getTime())) return null;
106
+ return date.toISOString();
107
+ }
108
+ //#endregion
109
+ //#region src/providers/gitlab/branch-ops.ts
110
+ /**
111
+ * Branch / merge / diff helpers backed by the GitLab REST API.
112
+ *
113
+ * Pure functions so they can be composed into `GitLabProvider` or used
114
+ * standalone. 404s collapse to empty-ish results where that matches
115
+ * the `RepoProvider` contract (missing branch prefix → `[]`).
116
+ *
117
+ * Merge semantics: GitLab does not expose a direct branch-to-branch
118
+ * merge endpoint. Every merge flows through a merge request, so
119
+ * `mergeBranch` opens an MR and immediately accepts it. The resulting
120
+ * `MergeResult` mirrors GitHub's `repos.merge` return shape — callers
121
+ * see the same `{ merged, sha, pullRequestUrl }` envelope either way,
122
+ * with the MR URL available for audit.
123
+ */
124
+ async function getDefaultBranch(client, project) {
125
+ return (await client.Projects.show(project.projectId)).default_branch ?? "main";
126
+ }
127
+ async function listBranches(client, project, prefix) {
128
+ const options = {
129
+ perPage: 100,
130
+ maxPages: 10
131
+ };
132
+ if (prefix) options.search = prefix;
133
+ const rawBranches = await client.Branches.all(project.projectId, options);
134
+ return (Array.isArray(rawBranches) ? rawBranches : []).filter((b) => !prefix || b.name.startsWith(prefix)).map((b) => ({
135
+ name: b.name,
136
+ sha: b.commit.id,
137
+ protected: b.protected ?? false
138
+ }));
139
+ }
140
+ async function createBranch(client, project, name, fromRef) {
141
+ await client.Branches.create(project.projectId, name, fromRef);
142
+ }
143
+ async function deleteBranch(client, project, name) {
144
+ await client.Branches.remove(project.projectId, name);
145
+ }
146
+ async function getBranchDiff(client, project, branch, base) {
147
+ const response = await client.Repositories.compare(project.projectId, base, branch, { straight: false });
148
+ return (Array.isArray(response.diffs) ? response.diffs : []).map((d) => ({
149
+ path: d.new_file ? d.new_path : d.old_path,
150
+ status: d.deleted_file ? "removed" : d.new_file ? "added" : "modified",
151
+ before: null,
152
+ after: null
153
+ }));
154
+ }
155
+ async function mergeBranch(client, project, branch, into) {
156
+ const mr = await client.MergeRequests.create(project.projectId, branch, into, `[contentrain] merge ${branch} → ${into}`, { removeSourceBranch: false });
157
+ const accepted = await client.MergeRequests.accept(project.projectId, mr.iid, {
158
+ shouldRemoveSourceBranch: false,
159
+ squash: false
160
+ });
161
+ const mergeSha = accepted.merge_commit_sha ?? accepted.sha ?? null;
162
+ const webUrl = mr.web_url ?? null;
163
+ return {
164
+ merged: mergeSha !== null,
165
+ sha: mergeSha,
166
+ pullRequestUrl: webUrl
167
+ };
168
+ }
169
+ async function isMerged(client, project, branch, into) {
170
+ const response = await client.Repositories.compare(project.projectId, into, branch, { straight: false });
171
+ return (Array.isArray(response.commits) ? response.commits : []).length === 0;
172
+ }
173
+ //#endregion
174
+ //#region src/providers/gitlab/reader.ts
175
+ /**
176
+ * GitLabReader — `RepoReader` backed by the GitLab REST API.
177
+ *
178
+ * File reads go through `RepositoryFiles.showRaw`, which returns the
179
+ * file content as UTF-8 text (or a `Blob` on browser/edge runtimes we
180
+ * decode with `.text()`). Directory listings go through
181
+ * `Repositories.allRepositoryTrees`. `fileExists` tries the file
182
+ * endpoint first and falls back to a tree listing so directories
183
+ * resolve to `true` as well — matching LocalReader / GitHubReader.
184
+ *
185
+ * `ref` is forwarded verbatim and may be a branch name, tag name or
186
+ * commit SHA. Callers should always pass the explicit `contentrain`
187
+ * tracking branch; GitLab's default resolution is the project's
188
+ * default branch, which is usually wrong for Contentrain flows.
189
+ */
190
+ var GitLabReader = class {
191
+ constructor(client, project) {
192
+ this.client = client;
193
+ this.project = project;
194
+ }
195
+ async readFile(path, ref) {
196
+ const repoPath = resolveRepoPath(this.project.contentRoot, path);
197
+ const resolvedRef = ref ?? await this.resolveDefaultRef();
198
+ const raw = await this.client.RepositoryFiles.showRaw(this.project.projectId, repoPath, resolvedRef);
199
+ if (typeof raw === "string") return raw;
200
+ return raw.text();
201
+ }
202
+ async listDirectory(path, ref) {
203
+ const repoPath = resolveRepoPath(this.project.contentRoot, path);
204
+ const resolvedRef = ref ?? await this.resolveDefaultRef();
205
+ try {
206
+ const entries = await this.client.Repositories.allRepositoryTrees(this.project.projectId, {
207
+ path: repoPath,
208
+ ref: resolvedRef,
209
+ perPage: 100,
210
+ recursive: false
211
+ });
212
+ return Array.isArray(entries) ? entries.map((e) => e.name) : [];
213
+ } catch (error) {
214
+ if (isNotFoundError(error)) return [];
215
+ throw error;
216
+ }
217
+ }
218
+ async fileExists(path, ref) {
219
+ const repoPath = resolveRepoPath(this.project.contentRoot, path);
220
+ const resolvedRef = ref ?? await this.resolveDefaultRef();
221
+ try {
222
+ await this.client.RepositoryFiles.show(this.project.projectId, repoPath, resolvedRef);
223
+ return true;
224
+ } catch (error) {
225
+ if (!isNotFoundError(error)) throw error;
226
+ }
227
+ try {
228
+ const entries = await this.client.Repositories.allRepositoryTrees(this.project.projectId, {
229
+ path: repoPath,
230
+ ref: resolvedRef,
231
+ perPage: 1
232
+ });
233
+ return Array.isArray(entries) && entries.length > 0;
234
+ } catch (error) {
235
+ if (isNotFoundError(error)) return false;
236
+ throw error;
237
+ }
238
+ }
239
+ async resolveDefaultRef() {
240
+ return (await this.client.Projects.show(this.project.projectId)).default_branch ?? "main";
241
+ }
242
+ };
243
+ //#endregion
244
+ //#region src/providers/gitlab/provider.ts
245
+ /**
246
+ * GitLabProvider — `RepoProvider` backed by the gitbeaker-driven GitLab
247
+ * REST API.
248
+ *
249
+ * Transport-agnostic: the provider only talks to a `GitLabClient`
250
+ * (a `@gitbeaker/rest` `Gitlab` instance). `createGitLabProvider` in
251
+ * `factory.ts` wraps the dynamic import so consumers never touch
252
+ * `@gitbeaker/rest` directly unless they want to.
253
+ *
254
+ * Capability gaps versus `GitHubProvider`: none — both providers
255
+ * expose the same set. GitLab's merge flow routes through an MR under
256
+ * the hood, but `mergeBranch` presents the same `MergeResult` shape.
257
+ */
258
+ var GitLabProvider = class {
259
+ capabilities = GITLAB_CAPABILITIES;
260
+ reader;
261
+ constructor(client, project) {
262
+ this.client = client;
263
+ this.project = project;
264
+ this.reader = new GitLabReader(client, project);
265
+ }
266
+ readFile(path, ref) {
267
+ return this.reader.readFile(path, ref);
268
+ }
269
+ listDirectory(path, ref) {
270
+ return this.reader.listDirectory(path, ref);
271
+ }
272
+ fileExists(path, ref) {
273
+ return this.reader.fileExists(path, ref);
274
+ }
275
+ applyPlan(input) {
276
+ return applyPlanToGitLab(this.client, this.project, input);
277
+ }
278
+ listBranches(prefix) {
279
+ return listBranches(this.client, this.project, prefix);
280
+ }
281
+ async createBranch(name, fromRef) {
282
+ const resolved = fromRef ?? await getDefaultBranch(this.client, this.project);
283
+ await createBranch(this.client, this.project, name, resolved);
284
+ }
285
+ deleteBranch(name) {
286
+ return deleteBranch(this.client, this.project, name);
287
+ }
288
+ async getBranchDiff(branch, base) {
289
+ const resolved = base ?? await getDefaultBranch(this.client, this.project);
290
+ return getBranchDiff(this.client, this.project, branch, resolved);
291
+ }
292
+ mergeBranch(branch, into) {
293
+ return mergeBranch(this.client, this.project, branch, into);
294
+ }
295
+ async isMerged(branch, into) {
296
+ const resolved = into ?? await getDefaultBranch(this.client, this.project);
297
+ return isMerged(this.client, this.project, branch, resolved);
298
+ }
299
+ getDefaultBranch() {
300
+ return getDefaultBranch(this.client, this.project);
301
+ }
302
+ };
303
+ //#endregion
304
+ //#region src/providers/gitlab/factory.ts
305
+ /**
306
+ * Create a gitbeaker-backed `GitLabClient` from an auth configuration.
307
+ *
308
+ * The `@gitbeaker/rest` module is imported dynamically so it stays a
309
+ * pure optional peer dependency — self-hosted MCP on stdio runs fine
310
+ * without it. If the module is not installed, the import throws with
311
+ * a helpful hint pointing the operator at the peer dependency.
312
+ *
313
+ * Supported auth types: `pat`, `oauth`, `job`. All three are thin
314
+ * wrappers over gitbeaker's `token`, `oauthToken`, and `jobToken`
315
+ * constructor options.
316
+ */
317
+ async function createGitLabClient(auth, host) {
318
+ let GitlabCtor;
319
+ try {
320
+ ({Gitlab: GitlabCtor} = await import("@gitbeaker/rest"));
321
+ } catch (error) {
322
+ throw new Error("@gitbeaker/rest is required for the GitLabProvider but could not be loaded. Install it as a peer dependency: pnpm add @gitbeaker/rest.", { cause: error });
323
+ }
324
+ const config = host ? { host } : {};
325
+ switch (auth.type) {
326
+ case "pat":
327
+ config.token = auth.token;
328
+ break;
329
+ case "oauth":
330
+ config.oauthToken = auth.oauthToken;
331
+ break;
332
+ case "job":
333
+ config.jobToken = auth.jobToken;
334
+ break;
335
+ default: {
336
+ const { type } = auth;
337
+ throw new Error(`Unsupported GitLab auth type: "${type}"`);
338
+ }
339
+ }
340
+ return new GitlabCtor(config);
341
+ }
342
+ /**
343
+ * Factory for the full provider — instantiates a gitbeaker client and
344
+ * wraps it in a `GitLabProvider`. Consumers who already hold a
345
+ * gitbeaker instance (HTTP server injecting shared clients, tests,
346
+ * etc.) should instantiate `GitLabProvider` directly instead.
347
+ */
348
+ async function createGitLabProvider(opts) {
349
+ return new GitLabProvider(await createGitLabClient(opts.auth, opts.project.host), opts.project);
350
+ }
351
+ //#endregion
352
+ //#region src/providers/gitlab/types.ts
353
+ /** Default author used when a call does not provide one. */
354
+ const DEFAULT_GITLAB_AUTHOR = {
355
+ name: "Contentrain",
356
+ email: "mcp@contentrain.io"
357
+ };
358
+ //#endregion
359
+ export { DEFAULT_GITLAB_AUTHOR, GITLAB_CAPABILITIES, GitLabProvider, GitLabReader, createGitLabClient, createGitLabProvider };
360
+
361
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":["listBranchesOp","getDefaultBranchOp","createBranchOp","deleteBranchOp","getBranchDiffOp","mergeBranchOp","isMergedOp"],"sources":["../../../src/providers/gitlab/capabilities.ts","../../../src/providers/gitlab/apply-plan.ts","../../../src/providers/gitlab/branch-ops.ts","../../../src/providers/gitlab/reader.ts","../../../src/providers/gitlab/provider.ts","../../../src/providers/gitlab/factory.ts","../../../src/providers/gitlab/types.ts"],"sourcesContent":["import type { ProviderCapabilities } from '../../core/contracts/index.js'\n\n/**\n * Capability set for GitLabProvider.\n *\n * GitLab over REST has no working tree, so local worktree features,\n * source-file access and AST scans are unavailable. Push, merge and\n * branch-protection detection all work over the API. GitLab enforces\n * merges through merge requests, so `pullRequestFallback` is `true` —\n * `mergeBranch` opens an MR and auto-accepts it to match GitHub's\n * `repos.merge` semantics while still leaving an audit trail.\n */\nexport const GITLAB_CAPABILITIES: ProviderCapabilities = {\n localWorktree: false,\n sourceRead: false,\n sourceWrite: false,\n pushRemote: true,\n branchProtection: true,\n pullRequestFallback: true,\n astScan: false,\n}\n","import { CONTENTRAIN_BRANCH } from '@contentrain/types'\nimport type { ApplyPlanInput, Commit, FileChange } from '../../core/contracts/index.js'\nimport { isNotFoundError, resolveRepoPath } from '../shared/index.js'\nimport type { GitLabClient } from './client.js'\nimport type { ProjectRef } from './types.js'\n\ntype CommitActionType = 'create' | 'update' | 'delete'\n\ninterface CommitAction {\n action: CommitActionType\n filePath: string\n content?: string\n encoding?: 'text' | 'base64'\n}\n\n/**\n * Apply a plan to a GitLab repository as a single atomic commit via the\n * Commits API. High-level flow:\n *\n * 1. Check whether the target branch exists. If it does not, GitLab's\n * `startBranch` option forks a new branch from `input.base` (or the\n * project's default branch) as part of the same commit.\n * 2. For each `FileChange`, figure out the right GitLab action verb\n * (`create` vs `update` vs `delete`) by probing the path against the\n * resolved ref. GitLab validates this server-side and returns a 400\n * for mismatches — we avoid the round trip by getting it right up\n * front.\n * 3. POST `/repository/commits` once with the full action set. No\n * working tree, no multi-call tree-assembly dance — GitLab exposes\n * a richer primitive than the GitHub Git Data API for this case.\n *\n * The commit is durable as soon as the call returns; GitLab's ref\n * update happens inside the same request.\n */\nexport async function applyPlanToGitLab(\n client: GitLabClient,\n project: ProjectRef,\n input: ApplyPlanInput,\n): Promise<Commit> {\n const branchExists = await branchHasRef(client, project, input.branch)\n // Invariant: fork from the Contentrain content-tracking branch, not\n // the repo's default branch. See ApplyPlanInput.base docstring in\n // @contentrain/types.\n const baseBranch = input.base ?? CONTENTRAIN_BRANCH\n\n // Actions are computed against the HEAD of the feature branch when it\n // exists, otherwise against the fork point (baseBranch). GitLab\n // treats `create` / `update` / `delete` as a strict check against the\n // path's existence at that ref.\n const refForActionResolution = branchExists ? input.branch : baseBranch\n const rawActions = await Promise.all(\n input.changes.map(change => resolveAction(client, project, refForActionResolution, change)),\n )\n const actions = rawActions.filter((a): a is CommitAction => a !== null)\n\n if (actions.length === 0) {\n // Nothing to apply. Callers don't generally build empty plans, but\n // if they do we short-circuit before touching the API.\n throw new Error('applyPlanToGitLab: plan contained no applicable actions')\n }\n\n const options: Record<string, unknown> = {\n authorName: input.author.name,\n authorEmail: input.author.email,\n }\n if (!branchExists) {\n options.startBranch = baseBranch\n }\n\n const response = await client.Commits.create(\n project.projectId,\n input.branch,\n input.message,\n actions,\n options,\n )\n\n // Gitbeaker's generic-heavy response type widens string fields to\n // `string | Camelize<…>` — at runtime they are always strings under\n // the default (non-camelize) response mode we use. Cast narrows the\n // shape we actually touch.\n const commit = response as {\n id: string\n message?: string\n author_name?: string\n author_email?: string\n created_at?: string\n }\n const commitTimestamp = toIsoTimestamp(commit.created_at) ?? new Date().toISOString()\n return {\n sha: commit.id,\n message: commit.message ?? input.message,\n author: {\n name: commit.author_name ?? input.author.name,\n email: commit.author_email ?? input.author.email,\n },\n timestamp: commitTimestamp,\n }\n}\n\nasync function resolveAction(\n client: GitLabClient,\n project: ProjectRef,\n ref: string,\n change: FileChange,\n): Promise<CommitAction | null> {\n const filePath = resolveRepoPath(project.contentRoot, change.path)\n const exists = await fileExistsAtRef(client, project, filePath, ref)\n\n if (change.content === null) {\n // Filter out deletes against non-existent files — GitLab returns\n // 400 otherwise. The plan author asked us to \"make this file not\n // exist\", which is already satisfied.\n if (!exists) return null\n return { action: 'delete', filePath }\n }\n\n return {\n action: exists ? 'update' : 'create',\n filePath,\n content: change.content,\n encoding: 'text',\n }\n}\n\nasync function branchHasRef(\n client: GitLabClient,\n project: ProjectRef,\n branch: string,\n): Promise<boolean> {\n try {\n await client.Branches.show(project.projectId, branch)\n return true\n } catch (error) {\n if (isNotFoundError(error)) return false\n throw error\n }\n}\n\nasync function fileExistsAtRef(\n client: GitLabClient,\n project: ProjectRef,\n filePath: string,\n ref: string,\n): Promise<boolean> {\n try {\n await client.RepositoryFiles.show(project.projectId, filePath, ref)\n return true\n } catch (error) {\n if (isNotFoundError(error)) return false\n throw error\n }\n}\n\n\nfunction toIsoTimestamp(raw: unknown): string | null {\n if (typeof raw !== 'string') return null\n const date = new Date(raw)\n if (Number.isNaN(date.getTime())) return null\n return date.toISOString()\n}\n\n","import type { Branch, FileDiff, MergeResult } from '../../core/contracts/index.js'\nimport type { GitLabClient } from './client.js'\nimport type { ProjectRef } from './types.js'\n\n/**\n * Branch / merge / diff helpers backed by the GitLab REST API.\n *\n * Pure functions so they can be composed into `GitLabProvider` or used\n * standalone. 404s collapse to empty-ish results where that matches\n * the `RepoProvider` contract (missing branch prefix → `[]`).\n *\n * Merge semantics: GitLab does not expose a direct branch-to-branch\n * merge endpoint. Every merge flows through a merge request, so\n * `mergeBranch` opens an MR and immediately accepts it. The resulting\n * `MergeResult` mirrors GitHub's `repos.merge` return shape — callers\n * see the same `{ merged, sha, pullRequestUrl }` envelope either way,\n * with the MR URL available for audit.\n */\n\nexport async function getDefaultBranch(\n client: GitLabClient,\n project: ProjectRef,\n): Promise<string> {\n const p = await client.Projects.show(project.projectId) as { default_branch?: string }\n return p.default_branch ?? 'main'\n}\n\nexport async function listBranches(\n client: GitLabClient,\n project: ProjectRef,\n prefix?: string,\n): Promise<Branch[]> {\n // Gitbeaker's `all` supports a `search` string (substring match). For\n // Contentrain's `cr/*` naming the substring case is equivalent to a\n // prefix because the slug never appears anywhere except at the start.\n // Server-side filter + client-side prefix enforcement keeps us\n // correct even if the substring coincidence breaks someday.\n const options: Record<string, unknown> = {\n perPage: 100,\n maxPages: 10,\n }\n if (prefix) options.search = prefix\n\n const rawBranches = await client.Branches.all(project.projectId, options)\n const branches = Array.isArray(rawBranches) ? rawBranches : []\n\n return branches\n .filter((b: { name: string }) => !prefix || b.name.startsWith(prefix))\n .map((b: { name: string, commit: { id: string }, protected?: boolean }) => ({\n name: b.name,\n sha: b.commit.id,\n protected: b.protected ?? false,\n }))\n}\n\nexport async function createBranch(\n client: GitLabClient,\n project: ProjectRef,\n name: string,\n fromRef: string,\n): Promise<void> {\n await client.Branches.create(project.projectId, name, fromRef)\n}\n\nexport async function deleteBranch(\n client: GitLabClient,\n project: ProjectRef,\n name: string,\n): Promise<void> {\n await client.Branches.remove(project.projectId, name)\n}\n\nexport async function getBranchDiff(\n client: GitLabClient,\n project: ProjectRef,\n branch: string,\n base: string,\n): Promise<FileDiff[]> {\n const response = await client.Repositories.compare(\n project.projectId,\n base,\n branch,\n { straight: false },\n )\n const diffs = Array.isArray(response.diffs) ? response.diffs : []\n return diffs.map((d: { new_path: string, old_path: string, new_file?: boolean, deleted_file?: boolean }) => ({\n path: d.new_file ? d.new_path : d.old_path,\n status: d.deleted_file ? 'removed' : d.new_file ? 'added' : 'modified',\n before: null,\n after: null,\n }))\n}\n\nexport async function mergeBranch(\n client: GitLabClient,\n project: ProjectRef,\n branch: string,\n into: string,\n): Promise<MergeResult> {\n // 1. Open MR — GitLab rejects create when source === target or when\n // an MR is already open for this pair. Let the error propagate in\n // those cases; the caller retries or surfaces the message.\n const mr = await client.MergeRequests.create(\n project.projectId,\n branch,\n into,\n `[contentrain] merge ${branch} → ${into}`,\n { removeSourceBranch: false },\n )\n\n // 2. Accept the MR immediately. `shouldRemoveSourceBranch: false`\n // preserves the feature branch so audit/retry logic still has\n // access to it; Studio's cleanup flow deletes it separately.\n const accepted = await client.MergeRequests.accept(\n project.projectId,\n (mr as { iid: number }).iid,\n { shouldRemoveSourceBranch: false, squash: false },\n )\n\n const mergeSha = (accepted as { merge_commit_sha?: string | null, sha?: string | null }).merge_commit_sha\n ?? (accepted as { sha?: string | null }).sha\n ?? null\n const webUrl = (mr as { web_url?: string }).web_url ?? null\n\n return { merged: mergeSha !== null, sha: mergeSha, pullRequestUrl: webUrl }\n}\n\nexport async function isMerged(\n client: GitLabClient,\n project: ProjectRef,\n branch: string,\n into: string,\n): Promise<boolean> {\n // compare(from=into, to=branch) — commits list is empty when branch\n // is fully contained in into (i.e. already merged).\n const response = await client.Repositories.compare(\n project.projectId,\n into,\n branch,\n { straight: false },\n )\n const commits = Array.isArray(response.commits) ? response.commits : []\n return commits.length === 0\n}\n","import type { RepoReader } from '../../core/contracts/index.js'\nimport { isNotFoundError, resolveRepoPath } from '../shared/index.js'\nimport type { GitLabClient } from './client.js'\nimport type { ProjectRef } from './types.js'\n\n/**\n * GitLabReader — `RepoReader` backed by the GitLab REST API.\n *\n * File reads go through `RepositoryFiles.showRaw`, which returns the\n * file content as UTF-8 text (or a `Blob` on browser/edge runtimes we\n * decode with `.text()`). Directory listings go through\n * `Repositories.allRepositoryTrees`. `fileExists` tries the file\n * endpoint first and falls back to a tree listing so directories\n * resolve to `true` as well — matching LocalReader / GitHubReader.\n *\n * `ref` is forwarded verbatim and may be a branch name, tag name or\n * commit SHA. Callers should always pass the explicit `contentrain`\n * tracking branch; GitLab's default resolution is the project's\n * default branch, which is usually wrong for Contentrain flows.\n */\nexport class GitLabReader implements RepoReader {\n constructor(\n private readonly client: GitLabClient,\n private readonly project: ProjectRef,\n ) {}\n\n async readFile(path: string, ref?: string): Promise<string> {\n const repoPath = resolveRepoPath(this.project.contentRoot, path)\n const resolvedRef = ref ?? await this.resolveDefaultRef()\n const raw = await this.client.RepositoryFiles.showRaw(\n this.project.projectId,\n repoPath,\n resolvedRef,\n )\n if (typeof raw === 'string') return raw\n // Browser / edge runtimes return a Blob; decode as UTF-8.\n return (raw as Blob).text()\n }\n\n async listDirectory(path: string, ref?: string): Promise<string[]> {\n const repoPath = resolveRepoPath(this.project.contentRoot, path)\n const resolvedRef = ref ?? await this.resolveDefaultRef()\n try {\n const entries = await this.client.Repositories.allRepositoryTrees(\n this.project.projectId,\n {\n path: repoPath,\n ref: resolvedRef,\n perPage: 100,\n recursive: false,\n },\n )\n return Array.isArray(entries) ? entries.map(e => e.name) : []\n } catch (error) {\n if (isNotFoundError(error)) return []\n throw error\n }\n }\n\n async fileExists(path: string, ref?: string): Promise<boolean> {\n const repoPath = resolveRepoPath(this.project.contentRoot, path)\n const resolvedRef = ref ?? await this.resolveDefaultRef()\n\n // 1. Try as a file — cheap and most common case for Contentrain.\n try {\n await this.client.RepositoryFiles.show(\n this.project.projectId,\n repoPath,\n resolvedRef,\n )\n return true\n } catch (error) {\n if (!isNotFoundError(error)) throw error\n }\n\n // 2. Fall back to a tree listing — directories and empty dirs show\n // up here. Any non-404 result means the path resolves.\n try {\n const entries = await this.client.Repositories.allRepositoryTrees(\n this.project.projectId,\n { path: repoPath, ref: resolvedRef, perPage: 1 },\n )\n return Array.isArray(entries) && entries.length > 0\n } catch (error) {\n if (isNotFoundError(error)) return false\n throw error\n }\n }\n\n private async resolveDefaultRef(): Promise<string> {\n const project = await this.client.Projects.show(this.project.projectId) as { default_branch?: string }\n return project.default_branch ?? 'main'\n }\n}\n\n","import type {\n ApplyPlanInput,\n Branch,\n Commit,\n FileDiff,\n MergeResult,\n ProviderCapabilities,\n RepoProvider,\n} from '../../core/contracts/index.js'\nimport { applyPlanToGitLab } from './apply-plan.js'\nimport {\n createBranch as createBranchOp,\n deleteBranch as deleteBranchOp,\n getBranchDiff as getBranchDiffOp,\n getDefaultBranch as getDefaultBranchOp,\n isMerged as isMergedOp,\n listBranches as listBranchesOp,\n mergeBranch as mergeBranchOp,\n} from './branch-ops.js'\nimport { GITLAB_CAPABILITIES } from './capabilities.js'\nimport type { GitLabClient } from './client.js'\nimport { GitLabReader } from './reader.js'\nimport type { ProjectRef } from './types.js'\n\n/**\n * GitLabProvider — `RepoProvider` backed by the gitbeaker-driven GitLab\n * REST API.\n *\n * Transport-agnostic: the provider only talks to a `GitLabClient`\n * (a `@gitbeaker/rest` `Gitlab` instance). `createGitLabProvider` in\n * `factory.ts` wraps the dynamic import so consumers never touch\n * `@gitbeaker/rest` directly unless they want to.\n *\n * Capability gaps versus `GitHubProvider`: none — both providers\n * expose the same set. GitLab's merge flow routes through an MR under\n * the hood, but `mergeBranch` presents the same `MergeResult` shape.\n */\nexport class GitLabProvider implements RepoProvider {\n readonly capabilities: ProviderCapabilities = GITLAB_CAPABILITIES\n private readonly reader: GitLabReader\n\n constructor(\n private readonly client: GitLabClient,\n public readonly project: ProjectRef,\n ) {\n this.reader = new GitLabReader(client, project)\n }\n\n readFile(path: string, ref?: string): Promise<string> {\n return this.reader.readFile(path, ref)\n }\n listDirectory(path: string, ref?: string): Promise<string[]> {\n return this.reader.listDirectory(path, ref)\n }\n fileExists(path: string, ref?: string): Promise<boolean> {\n return this.reader.fileExists(path, ref)\n }\n\n applyPlan(input: ApplyPlanInput): Promise<Commit> {\n return applyPlanToGitLab(this.client, this.project, input)\n }\n\n listBranches(prefix?: string): Promise<Branch[]> {\n return listBranchesOp(this.client, this.project, prefix)\n }\n async createBranch(name: string, fromRef?: string): Promise<void> {\n const resolved = fromRef ?? await getDefaultBranchOp(this.client, this.project)\n await createBranchOp(this.client, this.project, name, resolved)\n }\n deleteBranch(name: string): Promise<void> {\n return deleteBranchOp(this.client, this.project, name)\n }\n async getBranchDiff(branch: string, base?: string): Promise<FileDiff[]> {\n const resolved = base ?? await getDefaultBranchOp(this.client, this.project)\n return getBranchDiffOp(this.client, this.project, branch, resolved)\n }\n mergeBranch(branch: string, into: string): Promise<MergeResult> {\n return mergeBranchOp(this.client, this.project, branch, into)\n }\n async isMerged(branch: string, into?: string): Promise<boolean> {\n const resolved = into ?? await getDefaultBranchOp(this.client, this.project)\n return isMergedOp(this.client, this.project, branch, resolved)\n }\n getDefaultBranch(): Promise<string> {\n return getDefaultBranchOp(this.client, this.project)\n }\n}\n","import type { GitLabClient } from './client.js'\nimport { GitLabProvider } from './provider.js'\nimport type { GitLabAuth, ProjectRef } from './types.js'\n\n/**\n * Create a gitbeaker-backed `GitLabClient` from an auth configuration.\n *\n * The `@gitbeaker/rest` module is imported dynamically so it stays a\n * pure optional peer dependency — self-hosted MCP on stdio runs fine\n * without it. If the module is not installed, the import throws with\n * a helpful hint pointing the operator at the peer dependency.\n *\n * Supported auth types: `pat`, `oauth`, `job`. All three are thin\n * wrappers over gitbeaker's `token`, `oauthToken`, and `jobToken`\n * constructor options.\n */\nexport async function createGitLabClient(\n auth: GitLabAuth,\n host?: string,\n): Promise<GitLabClient> {\n let GitlabCtor: typeof import('@gitbeaker/rest').Gitlab\n try {\n ({ Gitlab: GitlabCtor } = await import('@gitbeaker/rest'))\n } catch (error) {\n throw new Error(\n '@gitbeaker/rest is required for the GitLabProvider but could not be loaded. '\n + 'Install it as a peer dependency: pnpm add @gitbeaker/rest.',\n { cause: error },\n )\n }\n\n const config: Record<string, unknown> = host ? { host } : {}\n switch (auth.type) {\n case 'pat':\n config.token = auth.token\n break\n case 'oauth':\n config.oauthToken = auth.oauthToken\n break\n case 'job':\n config.jobToken = auth.jobToken\n break\n default: {\n const { type } = auth as { type: string }\n throw new Error(`Unsupported GitLab auth type: \"${type}\"`)\n }\n }\n\n return new GitlabCtor(config) as GitLabClient\n}\n\n/**\n * Factory for the full provider — instantiates a gitbeaker client and\n * wraps it in a `GitLabProvider`. Consumers who already hold a\n * gitbeaker instance (HTTP server injecting shared clients, tests,\n * etc.) should instantiate `GitLabProvider` directly instead.\n */\nexport async function createGitLabProvider(\n opts: { auth: GitLabAuth, project: ProjectRef },\n): Promise<GitLabProvider> {\n const client = await createGitLabClient(opts.auth, opts.project.host)\n return new GitLabProvider(client, opts.project)\n}\n","import type { CommitAuthor } from '../../core/contracts/index.js'\n\n/**\n * A reference to a GitLab project.\n *\n * `projectId` accepts the numeric project ID or a URL-encoded path\n * (`namespace/project`). Gitbeaker URL-encodes string paths internally,\n * so either form is fine.\n *\n * `contentRoot` is the repo-relative directory prefix where Contentrain\n * content lives. For a flat content repo it stays `''`; for a monorepo\n * where Contentrain sits under `apps/web/.contentrain/` it holds that\n * prefix. All reader/writer paths are joined against it.\n *\n * `host` points at a self-hosted GitLab instance. Leave undefined to\n * use `https://gitlab.com` (gitbeaker's default).\n */\nexport interface ProjectRef {\n projectId: string | number\n contentRoot?: string\n host?: string\n}\n\n/**\n * Authentication options for the GitLab provider.\n *\n * - `pat` — personal access token with the `api` scope. Simplest for\n * self-hosted MCP or CI runners.\n * - `oauth` — OAuth2 token. Used when the runner is driven by a GitLab\n * OAuth flow.\n * - `job` — CI job token (`CI_JOB_TOKEN`). Scoped to the running\n * pipeline; useful for pipeline-driven content updates.\n */\nexport type GitLabAuth =\n | { type: 'pat', token: string }\n | { type: 'oauth', oauthToken: string }\n | { type: 'job', jobToken: string }\n\n/** Default author used when a call does not provide one. */\nexport const DEFAULT_GITLAB_AUTHOR: CommitAuthor = {\n name: 'Contentrain',\n email: 'mcp@contentrain.io',\n}\n"],"mappings":";;;;;;;;;;;;;AAYA,MAAa,sBAA4C;CACvD,eAAe;CACf,YAAY;CACZ,aAAa;CACb,YAAY;CACZ,kBAAkB;CAClB,qBAAqB;CACrB,SAAS;CACV;;;;;;;;;;;;;;;;;;;;;;ACcD,eAAsB,kBACpB,QACA,SACA,OACiB;CACjB,MAAM,eAAe,MAAM,aAAa,QAAQ,SAAS,MAAM,OAAO;CAItE,MAAM,aAAa,MAAM,QAAQ;CAMjC,MAAM,yBAAyB,eAAe,MAAM,SAAS;CAI7D,MAAM,WAHa,MAAM,QAAQ,IAC/B,MAAM,QAAQ,KAAI,WAAU,cAAc,QAAQ,SAAS,wBAAwB,OAAO,CAAC,CAC5F,EAC0B,QAAQ,MAAyB,MAAM,KAAK;AAEvE,KAAI,QAAQ,WAAW,EAGrB,OAAM,IAAI,MAAM,0DAA0D;CAG5E,MAAM,UAAmC;EACvC,YAAY,MAAM,OAAO;EACzB,aAAa,MAAM,OAAO;EAC3B;AACD,KAAI,CAAC,aACH,SAAQ,cAAc;CAexB,MAAM,SAZW,MAAM,OAAO,QAAQ,OACpC,QAAQ,WACR,MAAM,QACN,MAAM,SACN,SACA,QACD;CAaD,MAAM,kBAAkB,eAAe,OAAO,WAAW,qBAAI,IAAI,MAAM,EAAC,aAAa;AACrF,QAAO;EACL,KAAK,OAAO;EACZ,SAAS,OAAO,WAAW,MAAM;E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