chief-clancy 0.5.4 → 0.5.6
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.
- package/README.md +3 -3
- package/dist/bundle/clancy-once.js +54 -29
- package/dist/installer/install.js +1 -1
- package/dist/installer/install.js.map +1 -1
- package/dist/schemas/bitbucket-pr.d.ts +122 -0
- package/dist/schemas/bitbucket-pr.d.ts.map +1 -0
- package/dist/schemas/bitbucket-pr.js +69 -0
- package/dist/schemas/bitbucket-pr.js.map +1 -0
- package/dist/schemas/env.d.ts +12 -0
- package/dist/schemas/env.d.ts.map +1 -1
- package/dist/schemas/env.js +4 -0
- package/dist/schemas/env.js.map +1 -1
- package/dist/schemas/github.d.ts +60 -0
- package/dist/schemas/github.d.ts.map +1 -1
- package/dist/schemas/github.js +32 -0
- package/dist/schemas/github.js.map +1 -1
- package/dist/schemas/gitlab-mr.d.ts +62 -0
- package/dist/schemas/gitlab-mr.d.ts.map +1 -0
- package/dist/schemas/gitlab-mr.js +31 -0
- package/dist/schemas/gitlab-mr.js.map +1 -0
- package/dist/scripts/once/once.d.ts.map +1 -1
- package/dist/scripts/once/once.js +181 -23
- package/dist/scripts/once/once.js.map +1 -1
- package/dist/scripts/shared/git-ops/git-ops.d.ts +9 -0
- package/dist/scripts/shared/git-ops/git-ops.d.ts.map +1 -1
- package/dist/scripts/shared/git-ops/git-ops.js +20 -0
- package/dist/scripts/shared/git-ops/git-ops.js.map +1 -1
- package/dist/scripts/shared/progress/progress.d.ts +41 -0
- package/dist/scripts/shared/progress/progress.d.ts.map +1 -1
- package/dist/scripts/shared/progress/progress.js +96 -1
- package/dist/scripts/shared/progress/progress.js.map +1 -1
- package/dist/scripts/shared/prompt/prompt.d.ts +27 -0
- package/dist/scripts/shared/prompt/prompt.d.ts.map +1 -1
- package/dist/scripts/shared/prompt/prompt.js +32 -7
- package/dist/scripts/shared/prompt/prompt.js.map +1 -1
- package/dist/scripts/shared/pull-request/bitbucket/bitbucket.d.ts +41 -9
- package/dist/scripts/shared/pull-request/bitbucket/bitbucket.d.ts.map +1 -1
- package/dist/scripts/shared/pull-request/bitbucket/bitbucket.js +182 -0
- package/dist/scripts/shared/pull-request/bitbucket/bitbucket.js.map +1 -1
- package/dist/scripts/shared/pull-request/github/github.d.ts +34 -1
- package/dist/scripts/shared/pull-request/github/github.d.ts.map +1 -1
- package/dist/scripts/shared/pull-request/github/github.js +106 -2
- package/dist/scripts/shared/pull-request/github/github.js.map +1 -1
- package/dist/scripts/shared/pull-request/gitlab/gitlab.d.ts +32 -9
- package/dist/scripts/shared/pull-request/gitlab/gitlab.d.ts.map +1 -1
- package/dist/scripts/shared/pull-request/gitlab/gitlab.js +127 -0
- package/dist/scripts/shared/pull-request/gitlab/gitlab.js.map +1 -1
- package/dist/scripts/shared/pull-request/pr-body/pr-body.d.ts.map +1 -1
- package/dist/scripts/shared/pull-request/pr-body/pr-body.js +7 -0
- package/dist/scripts/shared/pull-request/pr-body/pr-body.js.map +1 -1
- package/dist/scripts/shared/pull-request/rework-comment/rework-comment.d.ts +23 -0
- package/dist/scripts/shared/pull-request/rework-comment/rework-comment.d.ts.map +1 -0
- package/dist/scripts/shared/pull-request/rework-comment/rework-comment.js +30 -0
- package/dist/scripts/shared/pull-request/rework-comment/rework-comment.js.map +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/remote.d.ts +9 -0
- package/dist/types/remote.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/roles/planner/commands/approve-plan.md +7 -0
- package/src/roles/planner/commands/plan.md +11 -1
- package/src/roles/planner/workflows/approve-plan.md +478 -0
- package/src/roles/planner/workflows/plan.md +171 -49
- package/src/roles/reviewer/workflows/logs.md +7 -3
- package/src/roles/setup/commands/help.md +3 -2
- package/src/roles/setup/workflows/init.md +68 -2
- package/src/roles/setup/workflows/scaffold.md +41 -0
- package/src/roles/setup/workflows/settings.md +41 -6
- package/src/templates/CLAUDE.md +2 -0
- package/src/roles/planner/commands/approve.md +0 -7
- package/src/roles/planner/workflows/approve.md +0 -237
|
@@ -33,6 +33,33 @@ type PromptInput = {
|
|
|
33
33
|
* });
|
|
34
34
|
* ```
|
|
35
35
|
*/
|
|
36
|
+
export type ReworkPromptInput = {
|
|
37
|
+
key: string;
|
|
38
|
+
title: string;
|
|
39
|
+
description: string;
|
|
40
|
+
provider: BoardProvider;
|
|
41
|
+
feedbackComments: string[];
|
|
42
|
+
/** Git diff or git log output from the previous implementation. */
|
|
43
|
+
previousContext?: string;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Build the Claude prompt for reworking a ticket based on reviewer feedback.
|
|
47
|
+
*
|
|
48
|
+
* @param input - The rework ticket data and feedback.
|
|
49
|
+
* @returns The complete rework prompt string.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* const prompt = buildReworkPrompt({
|
|
54
|
+
* key: 'PROJ-123',
|
|
55
|
+
* title: 'Add login page',
|
|
56
|
+
* description: 'Create a login page with email/password fields.',
|
|
57
|
+
* provider: 'jira',
|
|
58
|
+
* feedbackComments: ['Button colour is wrong', 'Missing validation'],
|
|
59
|
+
* });
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export declare function buildReworkPrompt(input: ReworkPromptInput): string;
|
|
36
63
|
export declare function buildPrompt(input: PromptInput): string;
|
|
37
64
|
export {};
|
|
38
65
|
//# sourceMappingURL=prompt.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../../../src/scripts/shared/prompt/prompt.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtD,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,aAAa,CAAC;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,sFAAsF;IACtF,UAAU,EAAE,MAAM,CAAC;IACnB,gFAAgF;IAChF,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AA6BF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAkCtD"}
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../../../src/scripts/shared/prompt/prompt.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtD,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,aAAa,CAAC;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,sFAAsF;IACtF,UAAU,EAAE,MAAM,CAAC;IACnB,gFAAgF;IAChF,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AA6BF;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,aAAa,CAAC;IACxB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,mEAAmE;IACnE,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,CA4BlE;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAkCtD"}
|
|
@@ -24,23 +24,48 @@ function parentLabel(provider) {
|
|
|
24
24
|
return provider === 'github' ? 'Milestone' : 'Epic';
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
|
-
* Build the
|
|
27
|
+
* Build the Claude prompt for reworking a ticket based on reviewer feedback.
|
|
28
28
|
*
|
|
29
|
-
* @param input - The ticket data
|
|
30
|
-
* @returns The complete prompt string.
|
|
29
|
+
* @param input - The rework ticket data and feedback.
|
|
30
|
+
* @returns The complete rework prompt string.
|
|
31
31
|
*
|
|
32
32
|
* @example
|
|
33
33
|
* ```ts
|
|
34
|
-
* const prompt =
|
|
35
|
-
* provider: 'jira',
|
|
34
|
+
* const prompt = buildReworkPrompt({
|
|
36
35
|
* key: 'PROJ-123',
|
|
37
36
|
* title: 'Add login page',
|
|
38
37
|
* description: 'Create a login page with email/password fields.',
|
|
39
|
-
*
|
|
40
|
-
*
|
|
38
|
+
* provider: 'jira',
|
|
39
|
+
* feedbackComments: ['Button colour is wrong', 'Missing validation'],
|
|
41
40
|
* });
|
|
42
41
|
* ```
|
|
43
42
|
*/
|
|
43
|
+
export function buildReworkPrompt(input) {
|
|
44
|
+
const feedbackSection = input.feedbackComments.length > 0
|
|
45
|
+
? input.feedbackComments.map((c, i) => `${i + 1}. ${c}`).join('\n')
|
|
46
|
+
: 'No reviewer comments found. Review the existing implementation and fix any issues.';
|
|
47
|
+
const previousSection = input.previousContext
|
|
48
|
+
? `\n\n## Previous Implementation\n\n\`\`\`\n${input.previousContext}\n\`\`\``
|
|
49
|
+
: '';
|
|
50
|
+
return `You are fixing review feedback on [${input.key}] ${input.title}.
|
|
51
|
+
|
|
52
|
+
Description:
|
|
53
|
+
${input.description}
|
|
54
|
+
|
|
55
|
+
## Reviewer Feedback
|
|
56
|
+
|
|
57
|
+
${feedbackSection}${previousSection}
|
|
58
|
+
|
|
59
|
+
Address the specific feedback above. Don't re-implement unrelated areas. Focus only on what was flagged.
|
|
60
|
+
|
|
61
|
+
Steps:
|
|
62
|
+
1. Read core docs in .clancy/docs/: STACK.md, ARCHITECTURE.md, CONVENTIONS.md, GIT.md, DEFINITION-OF-DONE.md, CONCERNS.md
|
|
63
|
+
Also read if relevant to this ticket: INTEGRATIONS.md (external APIs/services/auth), TESTING.md (tests/specs/coverage), DESIGN-SYSTEM.md (UI/components/styles), ACCESSIBILITY.md (accessibility/ARIA/WCAG)
|
|
64
|
+
2. Follow the conventions in GIT.md exactly
|
|
65
|
+
3. Fix the issues identified in the reviewer feedback
|
|
66
|
+
4. Commit your work following the conventions in GIT.md
|
|
67
|
+
5. When done, confirm you are finished.`;
|
|
68
|
+
}
|
|
44
69
|
export function buildPrompt(input) {
|
|
45
70
|
const label = ticketLabel(input.provider);
|
|
46
71
|
const pLabel = parentLabel(input.provider);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../../../src/scripts/shared/prompt/prompt.ts"],"names":[],"mappings":"AAmBA;;;;;GAKG;AACH,SAAS,WAAW,CAAC,QAAuB;IAC1C,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,MAAM;YACT,OAAO,aAAa,CAAC;QACvB,KAAK,QAAQ;YACX,OAAO,cAAc,CAAC;QACxB,KAAK,QAAQ;YACX,OAAO,cAAc,CAAC;IAC1B,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAS,WAAW,CAAC,QAAuB;IAC1C,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC;AACtD,CAAC;
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../../../src/scripts/shared/prompt/prompt.ts"],"names":[],"mappings":"AAmBA;;;;;GAKG;AACH,SAAS,WAAW,CAAC,QAAuB;IAC1C,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,MAAM;YACT,OAAO,aAAa,CAAC;QACvB,KAAK,QAAQ;YACX,OAAO,cAAc,CAAC;QACxB,KAAK,QAAQ;YACX,OAAO,cAAc,CAAC;IAC1B,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAS,WAAW,CAAC,QAAuB;IAC1C,OAAO,QAAQ,KA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AAC,UAAU,GAAG,WAAW;;;EAGzC,KAAK,CAAC,WAAW;;;WAGR,KAAK,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,6BAA6B,CAAC,CAAC,CAAC,gCAAgC,oBAAoB,KAAK,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ;;;;wBAIrJ,KAAK,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ;yBAC/C,KAAK,CAAC,GAAG;;wDAEsB,KAAK,CAAC,GAAG;;;SAGxD,KAAK,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ;;;;mBAItC,KAAK,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ;;wCAE3B,CAAC;AACzC,CAAC"}
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Bitbucket pull request creation.
|
|
3
|
-
*
|
|
4
|
-
* Supports both Bitbucket Cloud (api.bitbucket.org/2.0) and
|
|
5
|
-
* Bitbucket Server/Data Center (rest/api/1.0).
|
|
6
|
-
*
|
|
7
|
-
* Auth: Cloud uses HTTP Basic Auth, Server uses Bearer token.
|
|
8
|
-
*/
|
|
9
|
-
import type { PrCreationResult } from '../../../../types/index.js';
|
|
1
|
+
import type { PrCreationResult, PrReviewState } from '../../../../types/index.js';
|
|
10
2
|
/**
|
|
11
3
|
* Create a pull request on Bitbucket Cloud.
|
|
12
4
|
*
|
|
@@ -35,4 +27,44 @@ export declare function createPullRequest(username: string, token: string, works
|
|
|
35
27
|
* @returns A result with the PR URL and ID on success, or an error message.
|
|
36
28
|
*/
|
|
37
29
|
export declare function createServerPullRequest(token: string, apiBase: string, projectKey: string, repoSlug: string, sourceBranch: string, targetBranch: string, title: string, description: string): Promise<PrCreationResult>;
|
|
30
|
+
/**
|
|
31
|
+
* Check the review state of an open PR on Bitbucket Cloud for a given branch.
|
|
32
|
+
*
|
|
33
|
+
* Finds the open PR, fetches all comments. Inline comments (with `inline`
|
|
34
|
+
* property) always trigger rework. General conversation comments only
|
|
35
|
+
* trigger rework when prefixed with `Rework:`.
|
|
36
|
+
*
|
|
37
|
+
* @param since - ISO 8601 timestamp; only comments created after this time trigger rework.
|
|
38
|
+
* @returns The review state, or `undefined` if no open PR exists.
|
|
39
|
+
*/
|
|
40
|
+
export declare function checkPrReviewState(username: string, token: string, workspace: string, repoSlug: string, branch: string, since?: string): Promise<PrReviewState | undefined>;
|
|
41
|
+
/**
|
|
42
|
+
* Fetch feedback comments on a Bitbucket Cloud PR.
|
|
43
|
+
*
|
|
44
|
+
* Inline comments (with `inline` property) are always included — they
|
|
45
|
+
* inherently represent change requests. General conversation comments are
|
|
46
|
+
* only included when prefixed with `Rework:` (prefix stripped).
|
|
47
|
+
* Inline comments are prefixed with `[path]`.
|
|
48
|
+
*/
|
|
49
|
+
export declare function fetchPrReviewComments(username: string, token: string, workspace: string, repoSlug: string, prId: number, since?: string): Promise<string[]>;
|
|
50
|
+
/**
|
|
51
|
+
* Check the review state of an open PR on Bitbucket Server/DC for a given branch.
|
|
52
|
+
*
|
|
53
|
+
* Finds the open PR, fetches all comments. Inline comments (with `anchor`
|
|
54
|
+
* property) always trigger rework. General conversation comments only
|
|
55
|
+
* trigger rework when prefixed with `Rework:`.
|
|
56
|
+
*
|
|
57
|
+
* @param since - ISO 8601 timestamp; only comments created after this time trigger rework.
|
|
58
|
+
* @returns The review state, or `undefined` if no open PR exists.
|
|
59
|
+
*/
|
|
60
|
+
export declare function checkServerPrReviewState(token: string, apiBase: string, projectKey: string, repoSlug: string, branch: string, since?: string): Promise<PrReviewState | undefined>;
|
|
61
|
+
/**
|
|
62
|
+
* Fetch feedback comments on a Bitbucket Server/DC PR.
|
|
63
|
+
*
|
|
64
|
+
* Inline comments (with `anchor` property) are always included — they
|
|
65
|
+
* inherently represent change requests. General conversation comments are
|
|
66
|
+
* only included when prefixed with `Rework:` (prefix stripped).
|
|
67
|
+
* Inline comments are prefixed with `[path]`.
|
|
68
|
+
*/
|
|
69
|
+
export declare function fetchServerPrReviewComments(token: string, apiBase: string, projectKey: string, repoSlug: string, prId: number, since?: string): Promise<string[]>;
|
|
38
70
|
//# sourceMappingURL=bitbucket.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bitbucket.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/shared/pull-request/bitbucket/bitbucket.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bitbucket.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/shared/pull-request/bitbucket/bitbucket.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAQxE;;;;;;;;;;;;GAYG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,gBAAgB,CAAC,CAuB3B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,uBAAuB,CAC3C,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,gBAAgB,CAAC,CAkC3B;AAMD;;;;;;;;;GASG;AACH,wBAAsB,kBAAkB,CACtC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAyCpC;AAED;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,MAAM,EAAE,CAAC,CA8BnB;AAMD;;;;;;;;;GASG;AACH,wBAAsB,wBAAwB,CAC5C,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CA+CpC;AAED;;;;;;;GAOG;AACH,wBAAsB,2BAA2B,CAC/C,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,MAAM,EAAE,CAAC,CAgCnB"}
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bitbucket pull request creation and review state checking.
|
|
3
|
+
*
|
|
4
|
+
* Supports both Bitbucket Cloud (api.bitbucket.org/2.0) and
|
|
5
|
+
* Bitbucket Server/Data Center (rest/api/1.0).
|
|
6
|
+
*
|
|
7
|
+
* Auth: Cloud uses HTTP Basic Auth, Server uses Bearer token.
|
|
8
|
+
*/
|
|
9
|
+
import { bitbucketCommentsSchema, bitbucketPrListSchema, bitbucketServerActivitiesSchema, bitbucketServerPrListSchema, } from '../../../../schemas/bitbucket-pr.js';
|
|
1
10
|
import { basicAuth, postPullRequest } from '../post-pr/post-pr.js';
|
|
11
|
+
import { extractReworkContent, isReworkComment, } from '../rework-comment/rework-comment.js';
|
|
2
12
|
/**
|
|
3
13
|
* Create a pull request on Bitbucket Cloud.
|
|
4
14
|
*
|
|
@@ -66,4 +76,176 @@ export async function createServerPullRequest(token, apiBase, projectKey, repoSl
|
|
|
66
76
|
};
|
|
67
77
|
}, (status, text) => status === 409 && text.includes('already exists'));
|
|
68
78
|
}
|
|
79
|
+
// ---------------------------------------------------------------------------
|
|
80
|
+
// Cloud — review state & comments
|
|
81
|
+
// ---------------------------------------------------------------------------
|
|
82
|
+
/**
|
|
83
|
+
* Check the review state of an open PR on Bitbucket Cloud for a given branch.
|
|
84
|
+
*
|
|
85
|
+
* Finds the open PR, fetches all comments. Inline comments (with `inline`
|
|
86
|
+
* property) always trigger rework. General conversation comments only
|
|
87
|
+
* trigger rework when prefixed with `Rework:`.
|
|
88
|
+
*
|
|
89
|
+
* @param since - ISO 8601 timestamp; only comments created after this time trigger rework.
|
|
90
|
+
* @returns The review state, or `undefined` if no open PR exists.
|
|
91
|
+
*/
|
|
92
|
+
export async function checkPrReviewState(username, token, workspace, repoSlug, branch, since) {
|
|
93
|
+
try {
|
|
94
|
+
const prUrl = `https://api.bitbucket.org/2.0/repositories/${workspace}/${repoSlug}/pullrequests` +
|
|
95
|
+
`?q=source.branch.name="${branch}"&state=OPEN`;
|
|
96
|
+
const prRes = await fetch(prUrl, {
|
|
97
|
+
headers: { Authorization: basicAuth(username, token) },
|
|
98
|
+
});
|
|
99
|
+
if (!prRes.ok)
|
|
100
|
+
return undefined;
|
|
101
|
+
const parsed = bitbucketPrListSchema.parse(await prRes.json());
|
|
102
|
+
if (parsed.values.length === 0)
|
|
103
|
+
return undefined;
|
|
104
|
+
const pr = parsed.values[0];
|
|
105
|
+
const htmlUrl = pr.links.html?.href ?? '';
|
|
106
|
+
const commentsUrl = `https://api.bitbucket.org/2.0/repositories/${workspace}/${repoSlug}/pullrequests/${pr.id}/comments` +
|
|
107
|
+
`?pagelen=100`;
|
|
108
|
+
const commentsRes = await fetch(commentsUrl, {
|
|
109
|
+
headers: { Authorization: basicAuth(username, token) },
|
|
110
|
+
});
|
|
111
|
+
if (!commentsRes.ok)
|
|
112
|
+
return undefined;
|
|
113
|
+
const comments = bitbucketCommentsSchema.parse(await commentsRes.json());
|
|
114
|
+
const relevant = since
|
|
115
|
+
? comments.values.filter((c) => c.created_on > since)
|
|
116
|
+
: comments.values;
|
|
117
|
+
const hasInline = relevant.some((c) => c.inline != null);
|
|
118
|
+
const hasReworkConvo = relevant.some((c) => c.inline == null && isReworkComment(c.content.raw));
|
|
119
|
+
const changesRequested = hasInline || hasReworkConvo;
|
|
120
|
+
return { changesRequested, prNumber: pr.id, prUrl: htmlUrl };
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
return undefined;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Fetch feedback comments on a Bitbucket Cloud PR.
|
|
128
|
+
*
|
|
129
|
+
* Inline comments (with `inline` property) are always included — they
|
|
130
|
+
* inherently represent change requests. General conversation comments are
|
|
131
|
+
* only included when prefixed with `Rework:` (prefix stripped).
|
|
132
|
+
* Inline comments are prefixed with `[path]`.
|
|
133
|
+
*/
|
|
134
|
+
export async function fetchPrReviewComments(username, token, workspace, repoSlug, prId, since) {
|
|
135
|
+
try {
|
|
136
|
+
const url = `https://api.bitbucket.org/2.0/repositories/${workspace}/${repoSlug}/pullrequests/${prId}/comments` +
|
|
137
|
+
`?pagelen=100`;
|
|
138
|
+
const res = await fetch(url, {
|
|
139
|
+
headers: { Authorization: basicAuth(username, token) },
|
|
140
|
+
});
|
|
141
|
+
if (!res.ok)
|
|
142
|
+
return [];
|
|
143
|
+
const parsed = bitbucketCommentsSchema.parse(await res.json());
|
|
144
|
+
const relevant = since
|
|
145
|
+
? parsed.values.filter((c) => c.created_on > since)
|
|
146
|
+
: parsed.values;
|
|
147
|
+
const comments = [];
|
|
148
|
+
for (const c of relevant) {
|
|
149
|
+
if (c.inline != null) {
|
|
150
|
+
const prefix = c.inline.path ? `[${c.inline.path}] ` : '';
|
|
151
|
+
comments.push(`${prefix}${c.content.raw}`);
|
|
152
|
+
}
|
|
153
|
+
else if (isReworkComment(c.content.raw)) {
|
|
154
|
+
comments.push(extractReworkContent(c.content.raw));
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return comments;
|
|
158
|
+
}
|
|
159
|
+
catch {
|
|
160
|
+
return [];
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
// ---------------------------------------------------------------------------
|
|
164
|
+
// Server/DC — review state & comments
|
|
165
|
+
// ---------------------------------------------------------------------------
|
|
166
|
+
/**
|
|
167
|
+
* Check the review state of an open PR on Bitbucket Server/DC for a given branch.
|
|
168
|
+
*
|
|
169
|
+
* Finds the open PR, fetches all comments. Inline comments (with `anchor`
|
|
170
|
+
* property) always trigger rework. General conversation comments only
|
|
171
|
+
* trigger rework when prefixed with `Rework:`.
|
|
172
|
+
*
|
|
173
|
+
* @param since - ISO 8601 timestamp; only comments created after this time trigger rework.
|
|
174
|
+
* @returns The review state, or `undefined` if no open PR exists.
|
|
175
|
+
*/
|
|
176
|
+
export async function checkServerPrReviewState(token, apiBase, projectKey, repoSlug, branch, since) {
|
|
177
|
+
try {
|
|
178
|
+
const prUrl = `${apiBase}/projects/${projectKey}/repos/${repoSlug}/pull-requests` +
|
|
179
|
+
`?state=OPEN&at=refs/heads/${branch}`;
|
|
180
|
+
const prRes = await fetch(prUrl, {
|
|
181
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
182
|
+
});
|
|
183
|
+
if (!prRes.ok)
|
|
184
|
+
return undefined;
|
|
185
|
+
const parsed = bitbucketServerPrListSchema.parse(await prRes.json());
|
|
186
|
+
if (parsed.values.length === 0)
|
|
187
|
+
return undefined;
|
|
188
|
+
const pr = parsed.values[0];
|
|
189
|
+
const htmlUrl = pr.links.self?.[0]?.href ?? '';
|
|
190
|
+
const activitiesUrl = `${apiBase}/projects/${projectKey}/repos/${repoSlug}/pull-requests/${pr.id}/activities` +
|
|
191
|
+
`?limit=100`;
|
|
192
|
+
const activitiesRes = await fetch(activitiesUrl, {
|
|
193
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
194
|
+
});
|
|
195
|
+
if (!activitiesRes.ok)
|
|
196
|
+
return undefined;
|
|
197
|
+
const activities = bitbucketServerActivitiesSchema.parse(await activitiesRes.json());
|
|
198
|
+
const sinceMs = since ? Date.parse(since) : undefined;
|
|
199
|
+
const commentActivities = activities.values.filter((a) => a.action === 'COMMENTED' &&
|
|
200
|
+
a.comment &&
|
|
201
|
+
(sinceMs == null || a.comment.createdDate > sinceMs));
|
|
202
|
+
const hasInline = commentActivities.some((a) => a.comment.anchor != null);
|
|
203
|
+
const hasReworkConvo = commentActivities.some((a) => a.comment.anchor == null && isReworkComment(a.comment.text));
|
|
204
|
+
const changesRequested = hasInline || hasReworkConvo;
|
|
205
|
+
return { changesRequested, prNumber: pr.id, prUrl: htmlUrl };
|
|
206
|
+
}
|
|
207
|
+
catch {
|
|
208
|
+
return undefined;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Fetch feedback comments on a Bitbucket Server/DC PR.
|
|
213
|
+
*
|
|
214
|
+
* Inline comments (with `anchor` property) are always included — they
|
|
215
|
+
* inherently represent change requests. General conversation comments are
|
|
216
|
+
* only included when prefixed with `Rework:` (prefix stripped).
|
|
217
|
+
* Inline comments are prefixed with `[path]`.
|
|
218
|
+
*/
|
|
219
|
+
export async function fetchServerPrReviewComments(token, apiBase, projectKey, repoSlug, prId, since) {
|
|
220
|
+
try {
|
|
221
|
+
const url = `${apiBase}/projects/${projectKey}/repos/${repoSlug}/pull-requests/${prId}/activities` +
|
|
222
|
+
`?limit=100`;
|
|
223
|
+
const res = await fetch(url, {
|
|
224
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
225
|
+
});
|
|
226
|
+
if (!res.ok)
|
|
227
|
+
return [];
|
|
228
|
+
const parsed = bitbucketServerActivitiesSchema.parse(await res.json());
|
|
229
|
+
const sinceMs = since ? Date.parse(since) : undefined;
|
|
230
|
+
const comments = [];
|
|
231
|
+
for (const a of parsed.values) {
|
|
232
|
+
if (a.action !== 'COMMENTED' || !a.comment)
|
|
233
|
+
continue;
|
|
234
|
+
if (sinceMs != null && a.comment.createdDate <= sinceMs)
|
|
235
|
+
continue;
|
|
236
|
+
const c = a.comment;
|
|
237
|
+
if (c.anchor != null) {
|
|
238
|
+
const prefix = c.anchor.path ? `[${c.anchor.path}] ` : '';
|
|
239
|
+
comments.push(`${prefix}${c.text}`);
|
|
240
|
+
}
|
|
241
|
+
else if (isReworkComment(c.text)) {
|
|
242
|
+
comments.push(extractReworkContent(c.text));
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return comments;
|
|
246
|
+
}
|
|
247
|
+
catch {
|
|
248
|
+
return [];
|
|
249
|
+
}
|
|
250
|
+
}
|
|
69
251
|
//# sourceMappingURL=bitbucket.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bitbucket.js","sourceRoot":"","sources":["../../../../../src/scripts/shared/pull-request/bitbucket/bitbucket.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bitbucket.js","sourceRoot":"","sources":["../../../../../src/scripts/shared/pull-request/bitbucket/bitbucket.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EACrB,+BAA+B,EAC/B,2BAA2B,GAC5B,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EACL,oBAAoB,EACpB,eAAe,GAChB,MAAM,qCAAqC,CAAC;AAE7C;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,QAAgB,EAChB,KAAa,EACb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BACnC,QAAQ,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;YAC9C,CAAC;QACH,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
|
|
@@ -1,4 +1,37 @@
|
|
|
1
|
-
import type { PrCreationResult } from '../../../../types/index.js';
|
|
1
|
+
import type { PrCreationResult, PrReviewState } from '../../../../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Check the review state of an open PR for a given branch.
|
|
4
|
+
*
|
|
5
|
+
* Finds the open PR matching the branch, fetches inline and conversation
|
|
6
|
+
* comments. Any inline comment (left on a specific line) triggers rework.
|
|
7
|
+
* Conversation comments only trigger rework when prefixed with `Rework:`.
|
|
8
|
+
*
|
|
9
|
+
* @param token - The GitHub personal access token.
|
|
10
|
+
* @param repo - The repository in `owner/repo` format.
|
|
11
|
+
* @param branch - The source branch name.
|
|
12
|
+
* @param owner - The repository owner (used for `head` filter).
|
|
13
|
+
* @param apiBase - The API base URL (defaults to `https://api.github.com`).
|
|
14
|
+
* @param since - ISO 8601 timestamp; only comments created after this time trigger rework.
|
|
15
|
+
* @returns The review state, or `undefined` if no open PR or on error.
|
|
16
|
+
*/
|
|
17
|
+
export declare function checkPrReviewState(token: string, repo: string, branch: string, owner: string, apiBase?: string, since?: string): Promise<PrReviewState | undefined>;
|
|
18
|
+
/**
|
|
19
|
+
* Fetch feedback comments (inline + conversation) for a PR.
|
|
20
|
+
*
|
|
21
|
+
* Inline comments (left on specific lines) are always included — they
|
|
22
|
+
* inherently represent change requests. Conversation comments are only
|
|
23
|
+
* included when they start with `Rework:` (case-insensitive), with the
|
|
24
|
+
* prefix stripped. Inline comments are prefixed with `[path]` when a
|
|
25
|
+
* file path is available.
|
|
26
|
+
*
|
|
27
|
+
* @param token - The GitHub personal access token.
|
|
28
|
+
* @param repo - The repository in `owner/repo` format.
|
|
29
|
+
* @param prNumber - The PR number.
|
|
30
|
+
* @param apiBase - The API base URL (defaults to `https://api.github.com`).
|
|
31
|
+
* @param since - ISO 8601 timestamp; only comments created after this time are returned.
|
|
32
|
+
* @returns An array of feedback descriptions, or `[]` on error.
|
|
33
|
+
*/
|
|
34
|
+
export declare function fetchPrReviewComments(token: string, repo: string, prNumber: number, apiBase?: string, since?: string): Promise<string[]>;
|
|
2
35
|
/**
|
|
3
36
|
* Create a pull request on GitHub.
|
|
4
37
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/shared/pull-request/github/github.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/shared/pull-request/github/github.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAQxE;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,OAAO,SAAa,EACpB,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAoDpC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,qBAAqB,CACzC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,OAAO,SAAa,EACpB,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,MAAM,EAAE,CAAC,CA6CnB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,OAAO,SAAa,GACnB,OAAO,CAAC,gBAAgB,CAAC,CAW3B"}
|
|
@@ -1,13 +1,117 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* GitHub pull request creation.
|
|
2
|
+
* GitHub pull request creation and review state checking.
|
|
3
3
|
*
|
|
4
|
-
* Uses the GitHub REST API to create pull requests
|
|
4
|
+
* Uses the GitHub REST API to create pull requests, check review state,
|
|
5
|
+
* and fetch review comments.
|
|
5
6
|
* Supports both github.com and GitHub Enterprise (GHE).
|
|
6
7
|
*
|
|
7
8
|
* Auth: `Authorization: Bearer` header (personal access token with `repo` scope).
|
|
8
9
|
*/
|
|
10
|
+
import { githubCommentsResponseSchema, githubPrCommentsSchema, githubPrListSchema, } from '../../../../schemas/github.js';
|
|
9
11
|
import { GITHUB_API, githubHeaders } from '../../../../scripts/shared/http/http.js';
|
|
10
12
|
import { postPullRequest } from '../post-pr/post-pr.js';
|
|
13
|
+
import { extractReworkContent, isReworkComment, } from '../rework-comment/rework-comment.js';
|
|
14
|
+
/**
|
|
15
|
+
* Check the review state of an open PR for a given branch.
|
|
16
|
+
*
|
|
17
|
+
* Finds the open PR matching the branch, fetches inline and conversation
|
|
18
|
+
* comments. Any inline comment (left on a specific line) triggers rework.
|
|
19
|
+
* Conversation comments only trigger rework when prefixed with `Rework:`.
|
|
20
|
+
*
|
|
21
|
+
* @param token - The GitHub personal access token.
|
|
22
|
+
* @param repo - The repository in `owner/repo` format.
|
|
23
|
+
* @param branch - The source branch name.
|
|
24
|
+
* @param owner - The repository owner (used for `head` filter).
|
|
25
|
+
* @param apiBase - The API base URL (defaults to `https://api.github.com`).
|
|
26
|
+
* @param since - ISO 8601 timestamp; only comments created after this time trigger rework.
|
|
27
|
+
* @returns The review state, or `undefined` if no open PR or on error.
|
|
28
|
+
*/
|
|
29
|
+
export async function checkPrReviewState(token, repo, branch, owner, apiBase = GITHUB_API, since) {
|
|
30
|
+
try {
|
|
31
|
+
const headers = githubHeaders(token);
|
|
32
|
+
const prRes = await fetch(`${apiBase}/repos/${repo}/pulls?head=${owner}:${branch}&state=open`, { headers });
|
|
33
|
+
if (!prRes.ok)
|
|
34
|
+
return undefined;
|
|
35
|
+
const prs = githubPrListSchema.parse(await prRes.json());
|
|
36
|
+
if (prs.length === 0)
|
|
37
|
+
return undefined;
|
|
38
|
+
const pr = prs[0];
|
|
39
|
+
const sinceParam = since ? `&since=${since}` : '';
|
|
40
|
+
const [inlineRes, convoRes] = await Promise.all([
|
|
41
|
+
fetch(`${apiBase}/repos/${repo}/pulls/${pr.number}/comments?per_page=100${sinceParam}`, {
|
|
42
|
+
headers,
|
|
43
|
+
}),
|
|
44
|
+
fetch(`${apiBase}/repos/${repo}/issues/${pr.number}/comments?per_page=100${sinceParam}`, {
|
|
45
|
+
headers,
|
|
46
|
+
}),
|
|
47
|
+
]);
|
|
48
|
+
if (!inlineRes.ok || !convoRes.ok)
|
|
49
|
+
return undefined;
|
|
50
|
+
const inlineComments = githubPrCommentsSchema.parse(await inlineRes.json());
|
|
51
|
+
const convoComments = githubCommentsResponseSchema.parse(await convoRes.json());
|
|
52
|
+
const hasInlineComments = inlineComments.length > 0;
|
|
53
|
+
const hasReworkConvo = convoComments.some((c) => c.body && isReworkComment(c.body));
|
|
54
|
+
const hasRework = hasInlineComments || hasReworkConvo;
|
|
55
|
+
return {
|
|
56
|
+
changesRequested: hasRework,
|
|
57
|
+
prNumber: pr.number,
|
|
58
|
+
prUrl: pr.html_url,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Fetch feedback comments (inline + conversation) for a PR.
|
|
67
|
+
*
|
|
68
|
+
* Inline comments (left on specific lines) are always included — they
|
|
69
|
+
* inherently represent change requests. Conversation comments are only
|
|
70
|
+
* included when they start with `Rework:` (case-insensitive), with the
|
|
71
|
+
* prefix stripped. Inline comments are prefixed with `[path]` when a
|
|
72
|
+
* file path is available.
|
|
73
|
+
*
|
|
74
|
+
* @param token - The GitHub personal access token.
|
|
75
|
+
* @param repo - The repository in `owner/repo` format.
|
|
76
|
+
* @param prNumber - The PR number.
|
|
77
|
+
* @param apiBase - The API base URL (defaults to `https://api.github.com`).
|
|
78
|
+
* @param since - ISO 8601 timestamp; only comments created after this time are returned.
|
|
79
|
+
* @returns An array of feedback descriptions, or `[]` on error.
|
|
80
|
+
*/
|
|
81
|
+
export async function fetchPrReviewComments(token, repo, prNumber, apiBase = GITHUB_API, since) {
|
|
82
|
+
try {
|
|
83
|
+
const headers = githubHeaders(token);
|
|
84
|
+
const sinceParam = since ? `&since=${since}` : '';
|
|
85
|
+
const [inlineRes, convoRes] = await Promise.all([
|
|
86
|
+
fetch(`${apiBase}/repos/${repo}/pulls/${prNumber}/comments?per_page=100${sinceParam}`, {
|
|
87
|
+
headers,
|
|
88
|
+
}),
|
|
89
|
+
fetch(`${apiBase}/repos/${repo}/issues/${prNumber}/comments?per_page=100${sinceParam}`, {
|
|
90
|
+
headers,
|
|
91
|
+
}),
|
|
92
|
+
]);
|
|
93
|
+
if (!inlineRes.ok || !convoRes.ok)
|
|
94
|
+
return [];
|
|
95
|
+
const inlineComments = githubPrCommentsSchema.parse(await inlineRes.json());
|
|
96
|
+
const convoComments = githubCommentsResponseSchema.parse(await convoRes.json());
|
|
97
|
+
const combined = [];
|
|
98
|
+
for (const c of inlineComments) {
|
|
99
|
+
if (!c.body)
|
|
100
|
+
continue;
|
|
101
|
+
const prefix = c.path ? `[${c.path}] ` : '';
|
|
102
|
+
combined.push(`${prefix}${c.body}`);
|
|
103
|
+
}
|
|
104
|
+
for (const c of convoComments) {
|
|
105
|
+
if (c.body && isReworkComment(c.body)) {
|
|
106
|
+
combined.push(extractReworkContent(c.body));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return combined;
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
return [];
|
|
113
|
+
}
|
|
114
|
+
}
|
|
11
115
|
/**
|
|
12
116
|
* Create a pull request on GitHub.
|
|
13
117
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github.js","sourceRoot":"","sources":["../../../../../src/scripts/shared/pull-request/github/github.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"github.js","sourceRoot":"","sources":["../../../../../src/scripts/shared/pull-request/github/github.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EACL,4BAA4B,EAC5B,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAG1E,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EACL,oBAAoB,EACpB,eAAe,GAChB,MAAM,qCAAqC,CAAC;AAE7C;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,KAAa,EACb,IAAY,EACZ,MAAc,EACd,KAAa,EACb,OAAO,GAAG,UAAU,EACpB,KAAc;IAEd,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;QAErC,MAAM,KAAK,GAAG,MAAM,KAAK,CACvB,GAAG,OAAO,UAAU,IAAI,eAAe,KAAK,IAAI,MAAM,aAAa,EACnE,EAAE,OAAO,EAAE,CACZ,CAAC;QACF,IAAI,CAAC,KAAK,CAAC,EAAE;YAAE,OAAO,SAAS,CAAC;QAEhC,MAAM,GAAG,GAAG,kBAAkB,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;QACzD,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,SAAS,CAAC;QAEvC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;QAElB,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,CAAC,UAAU,KA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CAAC,EAAE,CAAC;gBACtC,QAAQ,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;YAC9C,CAAC;QACH,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,KAAa,EACb,IAAY,EACZ,IAAY,EACZ,IAAY,EACZ,KAAa,EACb,IAAY,EACZ,OAAO,GAAG,UAAU;IAEpB,OAAO,eAAe,CACpB,GAAG,OAAO,UAAU,IAAI,QAAQ,EAChC,aAAa,CAAC,KAAK,CAAC,EACpB,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,EAC3B,CAAC,IAAI,EAAE,EAAE;QACP,MAAM,IAAI,GAAG,IAA8C,CAAC;QAC5D,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,QAAQ,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;IAChE,CAAC,EACD,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,MAAM,KAAK,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CACpE,CAAC;AACJ,CAAC"}
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* GitLab merge request creation.
|
|
3
|
-
*
|
|
4
|
-
* Uses the GitLab REST API v4 to create merge requests.
|
|
5
|
-
* Supports both gitlab.com and self-hosted instances.
|
|
6
|
-
*
|
|
7
|
-
* Auth: `PRIVATE-TOKEN` header (personal access token with `api` scope).
|
|
8
|
-
*/
|
|
9
|
-
import type { PrCreationResult } from '../../../../types/index.js';
|
|
1
|
+
import type { PrCreationResult, PrReviewState } from '../../../../types/index.js';
|
|
10
2
|
/**
|
|
11
3
|
* Create a merge request on GitLab.
|
|
12
4
|
*
|
|
@@ -20,4 +12,35 @@ import type { PrCreationResult } from '../../../../types/index.js';
|
|
|
20
12
|
* @returns A result with the MR URL and IID on success, or an error message.
|
|
21
13
|
*/
|
|
22
14
|
export declare function createMergeRequest(token: string, apiBase: string, projectPath: string, sourceBranch: string, targetBranch: string, title: string, description: string): Promise<PrCreationResult>;
|
|
15
|
+
/**
|
|
16
|
+
* Check the review state of an open MR for a given branch.
|
|
17
|
+
*
|
|
18
|
+
* Finds the open MR matching the source branch, fetches all discussions.
|
|
19
|
+
* Inline notes (type `DiffNote`) always trigger rework. General conversation
|
|
20
|
+
* notes only trigger rework when prefixed with `Rework:`.
|
|
21
|
+
*
|
|
22
|
+
* @param token - The GitLab personal access token.
|
|
23
|
+
* @param apiBase - The API base URL (e.g. `https://gitlab.com/api/v4`).
|
|
24
|
+
* @param projectPath - The raw project path (e.g. `group/subgroup/project`). URL-encoded internally.
|
|
25
|
+
* @param branch - The source branch to look up.
|
|
26
|
+
* @param since - ISO 8601 timestamp; only notes created after this time trigger rework.
|
|
27
|
+
* @returns The review state if an open MR exists, otherwise `undefined`.
|
|
28
|
+
*/
|
|
29
|
+
export declare function checkMrReviewState(token: string, apiBase: string, projectPath: string, branch: string, since?: string): Promise<PrReviewState | undefined>;
|
|
30
|
+
/**
|
|
31
|
+
* Fetch feedback comments from an MR's discussions.
|
|
32
|
+
*
|
|
33
|
+
* Inline notes (type `DiffNote`) are always included — they inherently
|
|
34
|
+
* represent change requests. General conversation notes are only included
|
|
35
|
+
* when they start with `Rework:` (case-insensitive), with the prefix
|
|
36
|
+
* stripped. Inline notes are prefixed with `[new_path]` when available.
|
|
37
|
+
*
|
|
38
|
+
* @param token - The GitLab personal access token.
|
|
39
|
+
* @param apiBase - The API base URL (e.g. `https://gitlab.com/api/v4`).
|
|
40
|
+
* @param projectPath - The raw project path. URL-encoded internally.
|
|
41
|
+
* @param mrIid - The MR internal ID (iid).
|
|
42
|
+
* @param since - ISO 8601 timestamp; only notes created after this time are returned.
|
|
43
|
+
* @returns An array of feedback descriptions.
|
|
44
|
+
*/
|
|
45
|
+
export declare function fetchMrReviewComments(token: string, apiBase: string, projectPath: string, mrIid: number, since?: string): Promise<string[]>;
|
|
23
46
|
//# sourceMappingURL=gitlab.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitlab.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/shared/pull-request/gitlab/gitlab.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"gitlab.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/shared/pull-request/gitlab/gitlab.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAQxE;;;;;;;;;;;GAWG;AACH,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,gBAAgB,CAAC,CAmB3B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,EACd,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAyDpC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,qBAAqB,CACzC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,MAAM,EAAE,CAAC,CAsCnB"}
|