plugin-git-manager 1.2.26 → 1.2.28

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 (108) hide show
  1. package/README.md +133 -108
  2. package/client-v2.d.ts +2 -2
  3. package/client-v2.js +1 -1
  4. package/client.d.ts +3 -3
  5. package/client.js +1 -1
  6. package/dist/client/{326.90c276058682b536.js → 313.d38fc1d40c4589b9.js} +1 -1
  7. package/dist/client/900.a48beac7e2ebee7d.js +10 -0
  8. package/dist/client/index.js +1 -1
  9. package/dist/client-v2/156.445366026c1cc9a8.js +10 -0
  10. package/dist/client-v2/{326.42b7b53651ffab3a.js → 313.3c867179c3a1e817.js} +1 -1
  11. package/dist/client-v2/434.19c7579c06b9077c.js +10 -0
  12. package/dist/client-v2/900.e6155002a9c97e7f.js +10 -0
  13. package/dist/client-v2/928.bba701b5a1ece58e.js +10 -0
  14. package/dist/client-v2/index.js +1 -1
  15. package/dist/externalVersion.js +9 -8
  16. package/dist/locale/en-US.json +307 -297
  17. package/dist/locale/vi-VN.json +295 -292
  18. package/dist/locale/zh-CN.json +61 -51
  19. package/dist/node_modules/simple-git/dist/cjs/index.js +25 -25
  20. package/dist/node_modules/simple-git/package.json +1 -1
  21. package/dist/node_modules/zod/index.cjs +1 -1
  22. package/dist/node_modules/zod/package.json +1 -1
  23. package/dist/server/actions/git-actions.js +90 -36
  24. package/dist/server/actions/gitlab-api.js +4 -2
  25. package/dist/server/actions/poller.js +5 -2
  26. package/dist/server/actions/review.js +20 -10
  27. package/dist/server/plugin.js +6 -4
  28. package/dist/server/poller.js +46 -45
  29. package/dist/server/request-method-policy.js +75 -0
  30. package/dist/server/services/registry-content-service.js +23 -10
  31. package/dist/server/utils/get-repo-account.js +3 -2
  32. package/dist/server/utils/url-security.js +24 -0
  33. package/package.json +61 -43
  34. package/server.d.ts +2 -2
  35. package/server.js +1 -1
  36. package/src/client/__tests__/RunReviewButton.test.tsx +73 -0
  37. package/src/client/ai-context.tsx +114 -114
  38. package/src/client/components/AIEmployeeSelect.tsx +63 -63
  39. package/src/client/components/CommitHistory.tsx +374 -374
  40. package/src/client/components/FileExplorer.tsx +386 -386
  41. package/src/client/components/GitAccounts.tsx +179 -179
  42. package/src/client/components/GitManagerSettings.tsx +160 -160
  43. package/src/client/components/GitOperations.tsx +220 -220
  44. package/src/client/components/LLMModelSelect.tsx +63 -63
  45. package/src/client/components/LLMServiceSelect.tsx +58 -58
  46. package/src/client/components/MarkdownView.tsx +80 -80
  47. package/src/client/components/MergeRequests.tsx +790 -790
  48. package/src/client/components/PollingStatus.tsx +225 -225
  49. package/src/client/components/RepositoryConfig.tsx +335 -335
  50. package/src/client/components/RepositoryPermissions.tsx +123 -123
  51. package/src/client/components/ReviewFlows.tsx +303 -303
  52. package/src/client/components/ReviewHistory.tsx +566 -566
  53. package/src/client/components/RunReviewButton.tsx +63 -55
  54. package/src/client/context/GitManagerContext.tsx +92 -92
  55. package/src/client/index.tsx +91 -82
  56. package/src/client/locale.ts +9 -9
  57. package/src/client/promptTemplates.ts +31 -31
  58. package/src/client-v2/ai-context.tsx +99 -0
  59. package/src/client-v2/components/SubtreeSplits.tsx +547 -547
  60. package/src/client-v2/index.tsx +1 -1
  61. package/src/client-v2/locale.ts +8 -8
  62. package/src/client-v2/plugin.tsx +67 -39
  63. package/src/index.ts +2 -2
  64. package/src/locale/en-US.json +307 -297
  65. package/src/locale/vi-VN.json +295 -292
  66. package/src/locale/zh-CN.json +61 -51
  67. package/src/server/__tests__/git-actions.test.ts +24 -24
  68. package/src/server/__tests__/git-security.test.ts +170 -0
  69. package/src/server/__tests__/plugin-url-security.test.ts +17 -17
  70. package/src/server/__tests__/poller-lifecycle.test.ts +71 -0
  71. package/src/server/__tests__/poller.test.ts +37 -37
  72. package/src/server/__tests__/repository-access.test.ts +752 -752
  73. package/src/server/__tests__/review.test.ts +137 -137
  74. package/src/server/__tests__/role-permissions.test.ts +147 -147
  75. package/src/server/__tests__/smoke.test.ts +139 -17
  76. package/src/server/__tests__/subtree.test.ts +85 -85
  77. package/src/server/actions/git-actions.ts +540 -480
  78. package/src/server/actions/gitlab-api.ts +422 -411
  79. package/src/server/actions/poller.ts +39 -27
  80. package/src/server/actions/review.ts +1388 -1369
  81. package/src/server/actions/role-permissions.ts +321 -321
  82. package/src/server/actions/subtree.ts +508 -508
  83. package/src/server/ai-tools.ts +319 -319
  84. package/src/server/collections/gitAccounts.ts +56 -56
  85. package/src/server/collections/gitCodeReviews.ts +199 -199
  86. package/src/server/collections/gitRepositories.ts +87 -87
  87. package/src/server/collections/gitReviewFlows.ts +108 -108
  88. package/src/server/collections/gitSubtreeConfigs.ts +38 -38
  89. package/src/server/collections/gitSubtreeRuns.ts +30 -30
  90. package/src/server/index.ts +2 -2
  91. package/src/server/migrations/20260508000000-add-auto-review-flow-id.ts +29 -29
  92. package/src/server/migrations/20260712000000-add-git-accounts.ts +198 -198
  93. package/src/server/migrations/20260730000000-migrate-legacy-repository-permissions.ts +81 -81
  94. package/src/server/plugin.ts +372 -361
  95. package/src/server/poller.ts +351 -352
  96. package/src/server/repository-access.ts +773 -773
  97. package/src/server/request-method-policy.ts +55 -0
  98. package/src/server/services/__tests__/registry-content-service.test.ts +359 -345
  99. package/src/server/services/registry-content-service.ts +33 -11
  100. package/src/server/utils/__tests__/redact.test.ts +56 -56
  101. package/src/server/utils/__tests__/url-security.test.ts +85 -85
  102. package/src/server/utils/get-repo-account.ts +51 -41
  103. package/src/server/utils/gitlab-url.ts +38 -38
  104. package/src/server/utils/redact.ts +87 -87
  105. package/src/server/utils/url-security.ts +128 -95
  106. package/dist/client/900.acf7d1fa22f95e71.js +0 -10
  107. package/dist/client-v2/434.7a27051db18526c0.js +0 -10
  108. package/dist/client-v2/900.f32b9dc85249fc0a.js +0 -10
package/README.md CHANGED
@@ -1,108 +1,133 @@
1
- # plugin-git-manager
2
-
3
- ## Overview
4
- Manage Git repositories with PAT authentication and run AI-powered code reviews on
5
- merge requests. Combines repository operations (clone/pull/push/diff) with a configurable
6
- review pipeline backed by AI Employees.
7
-
8
- ## Features
9
-
10
- ### Repository management
11
- - **Clone, fetch, pull, push** to external Git providers (GitHub, GitLab, etc.).
12
- - **PAT authentication** — Personal Access Tokens are stored encrypted and redacted
13
- from API responses.
14
- - **File & diff browser** — view commits, changed files, and inline diffs from the
15
- NocoBase UI.
16
- - **Merge Request integration** — list, filter, and inspect GitLab MRs (overview,
17
- changes, comments).
18
-
19
- ### AI code review
20
- - **Review Flows** — configurable per repository or global (apply to all repos).
21
- Each flow binds an AI Employee, an optional LLM service / model override,
22
- trigger mode, post mode, branch filter (regex), and extra prompt instructions.
23
- - **Trigger modes**:
24
- - `manual` — run from the Merge Requests tab.
25
- - `onMergeRequestCreated` — auto-trigger when a new MR is detected by the poller.
26
- - `both` — manual + auto.
27
- - **Post modes**:
28
- - `auto` — review is posted to the MR as soon as it completes.
29
- - `manual` — review is held in the Review History tab pending approval.
30
- - `disabled` — review is generated and stored but never posted.
31
- - **Re-review on new commits** — every review tracks `headSha` (the SHA that was
32
- reviewed) and `latestSha` (the latest known SHA on the MR). The Merge Requests
33
- tab flags MRs whose `latestSha !== headSha` so reviewers can re-run the flow.
34
- - **One review per MR** — re-running a review UPSERTs the existing record, preserving
35
- history through `metadata` while keeping the row count bounded.
36
-
37
- ### Background poller
38
- - **5-minute interval** — polls open MRs for repos with `autoReview` enabled.
39
- - **Per-repo opt-in** — toggle `Auto Review` on the repository row to enable polling
40
- for that repo. Disabled repos are never queried.
41
- - **Smart re-poll** — uses GitLab `updated_after` (with a 1-second safety buffer) so
42
- each tick only fetches MRs that have changed since the last poll.
43
- - **No auto re-trigger** — auto-poll only triggers a review the **first time** an MR
44
- is seen. When new commits arrive on an already-reviewed MR, the poller refreshes
45
- `latestSha` only; re-review must be initiated manually.
46
- - **Status panel** — the Polling tab shows poller state (running/stopped), last tick,
47
- last error, and provides `Poll Now` / `Poll Now (All)` actions.
48
-
49
- ## Collections
50
- | Name | Purpose |
51
- |---|---|
52
- | `gitRepositories` | Connected repos, PAT, default branch, `autoReview` flag, `lastPolledAt`. |
53
- | `gitReviewFlows` | Review pipeline definitions (AI employee, trigger mode, post mode, branch filter). |
54
- | `gitCodeReviews` | Review records — one per MR target — with status, markdown output, metadata, post status. |
55
-
56
- ## Permissions
57
- The plugin registers two ACL snippets:
58
- - `pm.plugin-git-manager.read` — list/get on repos, flows, reviews + read-only Git
59
- operations (status, log, diff, MR queries, poller status).
60
- - `pm.plugin-git-manager.write` — create/update/destroy on collections + write Git
61
- operations (clone, pull, push, checkout) + review actions
62
- (`triggerReview`, `reviewApprovePost`, `reviewReject`, `pollNow`).
63
-
64
- ## Usage
65
-
66
- ### 1. Connect a repository
67
- 1. Open **Settings → Git Manager → Repositories**.
68
- 2. Click **Add Repository** and provide the clone URL, username, and PAT.
69
- 3. (Optional) Toggle **Auto Review** to enable background polling for this repo.
70
-
71
- ### 2. Configure a Review Flow
72
- 1. Open the **Review Flows** tab.
73
- 2. Click **Add Review Flow** and set:
74
- - **Repository** — leave empty for a global flow.
75
- - **AI Employee** — username of the AI Employee that will run the review.
76
- - **Trigger Mode** — `Manual`, `On Merge Request Created`, or `Both`.
77
- - **Post Mode** — `Auto post to MR`, `Manual approval before posting`, or
78
- `Do not post`.
79
- - **Branch Filter** — optional regex; only MRs whose source branch matches will
80
- be picked up.
81
- - **Additional Instructions** — extra prompt text appended to every review run.
82
-
83
- ### 3. Run a review
84
- - **Manual** — from the **Merge Requests** tab, click **Run Review** on any open MR.
85
- - **Automatic** — enable **Auto Review** on the repo and create a flow with
86
- trigger mode `On Merge Request Created` or `Both`. Within ~5 minutes the poller
87
- will detect new MRs and trigger reviews.
88
-
89
- ### 4. Approve or reject
90
- If the flow uses `manual` post mode, completed reviews land in the **Review History**
91
- tab with status **Pending Approval**. From there:
92
- - **Approve & Post** — posts the review as a note on the MR.
93
- - **Reject** — marks the review as rejected; nothing is posted.
94
- - **Edit before posting** — tweak the markdown before approving.
95
-
96
- ### 5. Re-review on new commits
97
- When new commits are pushed to an already-reviewed MR, the Merge Requests tab shows
98
- a **New commits** badge. Click **Re-run** to overwrite the existing review with a
99
- fresh one for the latest `headSha`.
100
-
101
- ## Notes & limits
102
- - The poller fetches at most 50 MRs per repo per tick (`per_page=50`). Repos with
103
- more than 50 open MRs may need manual `Poll Now` runs to catch up.
104
- - GitLab is the only fully-supported MR provider for the review pipeline; basic
105
- Git operations work against any provider.
106
- - The poller is in-process. In multi-instance deployments it runs on every node;
107
- the `isPolling` flag prevents overlap within a single process but not across
108
- nodes. Co-ordinate via a single primary node if needed.
1
+ # plugin-git-manager
2
+
3
+ ## Overview
4
+ Manage Git repositories with PAT authentication and run AI-powered code reviews on
5
+ merge requests. Combines repository operations (clone/pull/push/diff) with a configurable
6
+ review pipeline backed by AI Employees.
7
+
8
+ ## Upgrade to 1.2.28
9
+
10
+ This release includes the Skill Registry tree-limit contract and the Git Manager security fixes.
11
+
12
+ - Set each self-hosted GitLab account's **Base URL** to its HTTPS origin. A blank Base URL means
13
+ `https://gitlab.com` for GitLab and `https://github.com` for GitHub. Repository and account origins
14
+ must match, including the port. GitHub Enterprise API endpoints are not implemented.
15
+ - Use the final repository URL. Authenticated Git and provider API requests reject redirects.
16
+ - Use Git 2.31 or newer for process-scoped credential configuration. PATs are no longer written into
17
+ remote URLs or Git configuration. The plugin clears inherited Git command/config/trace overrides
18
+ for its Git subprocesses. `GIT_SSL_CAINFO` and `GIT_SSL_CAPATH` remain available for private CAs.
19
+ - Repository paths must resolve strictly below `GIT_REPOS_BASE_PATH`. The base directory itself,
20
+ traversal paths, and symlinks/junctions escaping the base are rejected, including clone destinations
21
+ below a linked parent. Keep that storage directory writable only by trusted service operators.
22
+ - Call mutation actions with **POST**, including `subtreeOptions` and `subtreePreview`, which fetch
23
+ remote refs. GET and HEAD return 405 before executing these actions. The bundled clients already use POST.
24
+ - Poller timers, in-flight guards and status belong to each application. Stopping one application
25
+ does not stop another application's poller. A running cycle retains its guard until it finishes.
26
+ - AI chat is optional in both clients. It uses the installed AI plugin manager and is disabled when
27
+ that plugin is absent. Standard Git screens can load without the AI module.
28
+
29
+ The HTTP integration test loads the real plugin and checks resource registration, method enforcement,
30
+ POST checkout and junction rejection. Additional tests cover credential origin matching, redirect
31
+ policy, credential-free Git config, lock recovery, poller isolation and optional AI chat.
32
+
33
+ ## Features
34
+
35
+ ### Repository management
36
+ - **Clone, fetch, pull, push** to external Git providers (GitHub, GitLab, etc.).
37
+ - **PAT authentication** — Personal Access Tokens are held in Git accounts and redacted
38
+ from API responses. Git operations receive credentials through the child process environment.
39
+ - **File & diff browser** — view commits, changed files, and inline diffs from the
40
+ NocoBase UI.
41
+ - **Merge Request integration** — list, filter, and inspect GitLab MRs (overview,
42
+ changes, comments).
43
+
44
+ ### AI code review
45
+ - **Review Flows** — configurable per repository or global (apply to all repos).
46
+ Each flow binds an AI Employee, an optional LLM service / model override,
47
+ trigger mode, post mode, branch filter (regex), and extra prompt instructions.
48
+ - **Trigger modes**:
49
+ - `manual` — run from the Merge Requests tab.
50
+ - `onMergeRequestCreated` — auto-trigger when a new MR is detected by the poller.
51
+ - `both` — manual + auto.
52
+ - **Post modes**:
53
+ - `auto` — review is posted to the MR as soon as it completes.
54
+ - `manual` — review is held in the Review History tab pending approval.
55
+ - `disabled` — review is generated and stored but never posted.
56
+ - **Re-review on new commits** — every review tracks `headSha` (the SHA that was
57
+ reviewed) and `latestSha` (the latest known SHA on the MR). The Merge Requests
58
+ tab flags MRs whose `latestSha !== headSha` so reviewers can re-run the flow.
59
+ - **One review per MR** — re-running a review UPSERTs the existing record, preserving
60
+ history through `metadata` while keeping the row count bounded.
61
+
62
+ ### Background poller
63
+ - **5-minute interval** — polls open MRs for repos with `autoReview` enabled.
64
+ - **Per-repo opt-in** — toggle `Auto Review` on the repository row to enable polling
65
+ for that repo. Disabled repos are never queried.
66
+ - **Smart re-poll** — uses GitLab `updated_after` (with a 1-second safety buffer) so
67
+ each tick only fetches MRs that have changed since the last poll.
68
+ - **No auto re-trigger** — auto-poll only triggers a review the **first time** an MR
69
+ is seen. When new commits arrive on an already-reviewed MR, the poller refreshes
70
+ `latestSha` only; re-review must be initiated manually.
71
+ - **Status panel** — the Polling tab shows poller state (running/stopped), last tick,
72
+ last error, and provides `Poll Now` / `Poll Now (All)` actions.
73
+
74
+ ## Collections
75
+ | Name | Purpose |
76
+ |---|---|
77
+ | `gitRepositories` | Connected repos, PAT, default branch, `autoReview` flag, `lastPolledAt`. |
78
+ | `gitReviewFlows` | Review pipeline definitions (AI employee, trigger mode, post mode, branch filter). |
79
+ | `gitCodeReviews` | Review records — one per MR target — with status, markdown output, metadata, post status. |
80
+
81
+ ## Permissions
82
+ The plugin registers two ACL snippets:
83
+ - `pm.plugin-git-manager.read` — list/get on repos, flows, reviews + read-only Git
84
+ operations (status, log, diff, MR queries, poller status).
85
+ - `pm.plugin-git-manager.write` — create/update/destroy on collections + write Git
86
+ operations (clone, pull, push, checkout) + review actions
87
+ (`triggerReview`, `reviewApprovePost`, `reviewReject`, `pollNow`).
88
+
89
+ ## Usage
90
+
91
+ ### 1. Connect a repository
92
+ 1. Open **Settings → Git Manager → Repositories**.
93
+ 2. Click **Add Repository** and provide the clone URL, username, and PAT.
94
+ 3. (Optional) Toggle **Auto Review** to enable background polling for this repo.
95
+
96
+ ### 2. Configure a Review Flow
97
+ 1. Open the **Review Flows** tab.
98
+ 2. Click **Add Review Flow** and set:
99
+ - **Repository** — leave empty for a global flow.
100
+ - **AI Employee** — username of the AI Employee that will run the review.
101
+ - **Trigger Mode** — `Manual`, `On Merge Request Created`, or `Both`.
102
+ - **Post Mode** — `Auto post to MR`, `Manual approval before posting`, or
103
+ `Do not post`.
104
+ - **Branch Filter** — optional regex; only MRs whose source branch matches will
105
+ be picked up.
106
+ - **Additional Instructions** — extra prompt text appended to every review run.
107
+
108
+ ### 3. Run a review
109
+ - **Manual** — from the **Merge Requests** tab, click **Run Review** on any open MR.
110
+ - **Automatic** — enable **Auto Review** on the repo and create a flow with
111
+ trigger mode `On Merge Request Created` or `Both`. Within ~5 minutes the poller
112
+ will detect new MRs and trigger reviews.
113
+
114
+ ### 4. Approve or reject
115
+ If the flow uses `manual` post mode, completed reviews land in the **Review History**
116
+ tab with status **Pending Approval**. From there:
117
+ - **Approve & Post** — posts the review as a note on the MR.
118
+ - **Reject** — marks the review as rejected; nothing is posted.
119
+ - **Edit before posting** — tweak the markdown before approving.
120
+
121
+ ### 5. Re-review on new commits
122
+ When new commits are pushed to an already-reviewed MR, the Merge Requests tab shows
123
+ a **New commits** badge. Click **Re-run** to overwrite the existing review with a
124
+ fresh one for the latest `headSha`.
125
+
126
+ ## Notes & limits
127
+ - The poller fetches at most 50 MRs per repo per tick (`per_page=50`). Repos with
128
+ more than 50 open MRs may need manual `Poll Now` runs to catch up.
129
+ - GitLab is the only fully-supported MR provider for the review pipeline; basic
130
+ Git operations work against any provider.
131
+ - The poller is in-process. In multi-instance deployments it runs on every node;
132
+ the `isPolling` flag prevents overlap within a single process but not across
133
+ nodes. Co-ordinate via a single primary node if needed.
package/client-v2.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from './dist/client-v2';
2
- export { default } from './dist/client-v2';
1
+ export * from './dist/client-v2';
2
+ export { default } from './dist/client-v2';
package/client-v2.js CHANGED
@@ -1 +1 @@
1
- module.exports = require('./dist/client-v2/index.js');
1
+ module.exports = require('./dist/client-v2/index.js');
package/client.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- // @ts-nocheck
2
- export * from './dist/client';
3
- export { default } from './dist/client';
1
+ // @ts-nocheck
2
+ export * from './dist/client';
3
+ export { default } from './dist/client';
package/client.js CHANGED
@@ -1 +1 @@
1
- module.exports = require('./dist/client/index.js');
1
+ module.exports = require('./dist/client/index.js');