smart-commit-copilot-cli 0.1.7 → 0.1.8
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/CHANGELOG.md +26 -0
- package/README.md +39 -15
- package/docs/configuration.md +82 -22
- package/docs/contracts.md +67 -6
- package/docs/getting-started.md +4 -1
- package/docs/publish.md +1 -1
- package/docs/releases/0.1.7-draft.md +8 -8
- package/docs/releases/0.1.8-draft.md +80 -0
- package/docs/verification.md +1 -0
- package/examples/config/smart-commit.json +28 -8
- package/out/cliApp.js +51 -12
- package/out/cliApp.js.map +1 -1
- package/out/commands/bridge.js +117 -46
- package/out/commands/bridge.js.map +1 -1
- package/out/commands/pullRequest.js +176 -0
- package/out/commands/pullRequest.js.map +1 -0
- package/out/commitMessage/protocol.js +6 -1
- package/out/commitMessage/protocol.js.map +1 -1
- package/out/config/cliArgs.js +103 -10
- package/out/config/cliArgs.js.map +1 -1
- package/out/config/constants.js +2 -1
- package/out/config/constants.js.map +1 -1
- package/out/config/env.js +79 -10
- package/out/config/env.js.map +1 -1
- package/out/config/file.js +98 -11
- package/out/config/file.js.map +1 -1
- package/out/config/legacySmartCommit.js +104 -21
- package/out/config/legacySmartCommit.js.map +1 -1
- package/out/config/merge.js +17 -3
- package/out/config/merge.js.map +1 -1
- package/out/config/schema.js +65 -10
- package/out/config/schema.js.map +1 -1
- package/out/contracts.js +152 -11
- package/out/contracts.js.map +1 -1
- package/out/git.js +108 -2
- package/out/git.js.map +1 -1
- package/out/output.js +4 -0
- package/out/output.js.map +1 -1
- package/out/pullRequest/api.js +528 -0
- package/out/pullRequest/api.js.map +1 -0
- package/out/pullRequest/client.js +17 -0
- package/out/pullRequest/client.js.map +1 -0
- package/out/pullRequest/config.js +18 -0
- package/out/pullRequest/config.js.map +1 -0
- package/out/pullRequest/contentPrompt.js +116 -0
- package/out/pullRequest/contentPrompt.js.map +1 -0
- package/out/pullRequest/contentService.js +77 -0
- package/out/pullRequest/contentService.js.map +1 -0
- package/out/pullRequest/index.js +25 -0
- package/out/pullRequest/index.js.map +1 -0
- package/out/pullRequest/platform.js +101 -0
- package/out/pullRequest/platform.js.map +1 -0
- package/out/pullRequest/redact.js +15 -0
- package/out/pullRequest/redact.js.map +1 -0
- package/out/pullRequest/workflow.js +153 -0
- package/out/pullRequest/workflow.js.map +1 -0
- package/out/renderOutput.js +29 -4
- package/out/renderOutput.js.map +1 -1
- package/out/reporting/aggregate.js +1 -1
- package/out/reporting/aggregate.js.map +1 -1
- package/out/reporting/mockProvider.js +5 -1
- package/out/reporting/mockProvider.js.map +1 -1
- package/out/reporting/openaiProvider.js +5 -1
- package/out/reporting/openaiProvider.js.map +1 -1
- package/out/reporting/prompt.js +145 -20
- package/out/reporting/prompt.js.map +1 -1
- package/out/reporting/render.js +24 -22
- package/out/reporting/render.js.map +1 -1
- package/out/reporting/timeWindow.js +101 -36
- package/out/reporting/timeWindow.js.map +1 -1
- package/out/reporting/types.js +3 -0
- package/out/reporting/types.js.map +1 -1
- package/out/review/mockProvider.js +25 -1
- package/out/review/mockProvider.js.map +1 -1
- package/out/{pullRequestSummary → stagedChangeSummary}/index.js +10 -10
- package/out/stagedChangeSummary/index.js.map +1 -0
- package/out/{pullRequestSummary → stagedChangeSummary}/mockProvider.js +5 -5
- package/out/stagedChangeSummary/mockProvider.js.map +1 -0
- package/out/stagedChangeSummary/openaiProvider.js +19 -0
- package/out/stagedChangeSummary/openaiProvider.js.map +1 -0
- package/out/{pullRequestSummary → stagedChangeSummary}/prompt.js +28 -12
- package/out/stagedChangeSummary/prompt.js.map +1 -0
- package/out/stagedChangeSummary/provider.js.map +1 -0
- package/out/{pullRequestSummary → stagedChangeSummary}/render.js +12 -12
- package/out/stagedChangeSummary/render.js.map +1 -0
- package/package.json +1 -1
- package/out/pullRequestSummary/index.js.map +0 -1
- package/out/pullRequestSummary/mockProvider.js.map +0 -1
- package/out/pullRequestSummary/openaiProvider.js +0 -19
- package/out/pullRequestSummary/openaiProvider.js.map +0 -1
- package/out/pullRequestSummary/prompt.js.map +0 -1
- package/out/pullRequestSummary/provider.js.map +0 -1
- package/out/pullRequestSummary/render.js.map +0 -1
- /package/out/{pullRequestSummary → stagedChangeSummary}/provider.js +0 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildPullRequestContentMessages = buildPullRequestContentMessages;
|
|
4
|
+
exports.buildPullRequestContentRepairMessages = buildPullRequestContentRepairMessages;
|
|
5
|
+
function buildPullRequestContentMessages(input) {
|
|
6
|
+
const promptTuning = buildPromptTuningSection(input.titlePrompt, input.descriptionPrompt);
|
|
7
|
+
const userPrompt = [
|
|
8
|
+
`Platform: ${input.platform}`,
|
|
9
|
+
`Repository: ${input.repositoryName}`,
|
|
10
|
+
`Source branch: ${input.sourceBranch}`,
|
|
11
|
+
`Target branch: ${input.targetBranch}`,
|
|
12
|
+
`Output language: ${input.language}`,
|
|
13
|
+
...buildLanguageRules(input.language),
|
|
14
|
+
`Full diff chars: ${input.fullDiffChars}`,
|
|
15
|
+
`Diff truncated before model input: ${input.truncated ? "yes" : "no"}`,
|
|
16
|
+
"",
|
|
17
|
+
...promptTuning,
|
|
18
|
+
`Changed files (${input.changedFiles.length}):`,
|
|
19
|
+
...input.changedFiles.map((file) => `- ${file}`),
|
|
20
|
+
"",
|
|
21
|
+
"Commit range messages:",
|
|
22
|
+
input.commitsText || "(none)",
|
|
23
|
+
"",
|
|
24
|
+
"Branch git diff:",
|
|
25
|
+
input.diff,
|
|
26
|
+
"",
|
|
27
|
+
"Return strict JSON only with this schema:",
|
|
28
|
+
"{",
|
|
29
|
+
' "title": "short PR/MR title",',
|
|
30
|
+
' "description": "Markdown PR/MR description"',
|
|
31
|
+
"}",
|
|
32
|
+
"",
|
|
33
|
+
"Rules:",
|
|
34
|
+
"- Generate both title and description specifically for a pull request / merge request.",
|
|
35
|
+
"- Do not reuse the git commit message verbatim as the title.",
|
|
36
|
+
"- Do not include review scores, review thresholds, or internal Smart Commit implementation details.",
|
|
37
|
+
"- Do not invent tests or behavior that is not supported by the diff or commit list.",
|
|
38
|
+
"- Keep the title concise and useful to reviewers.",
|
|
39
|
+
"- Use Markdown in description."
|
|
40
|
+
].join("\n");
|
|
41
|
+
return [
|
|
42
|
+
{
|
|
43
|
+
role: "system",
|
|
44
|
+
content: [
|
|
45
|
+
"You write high-quality pull request and merge request titles and descriptions for code reviewers.",
|
|
46
|
+
"You must obey the requested output language for natural-language fields.",
|
|
47
|
+
"Always return strict JSON only. Do not wrap the JSON in Markdown fences."
|
|
48
|
+
].join(" ")
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
role: "user",
|
|
52
|
+
content: userPrompt
|
|
53
|
+
}
|
|
54
|
+
];
|
|
55
|
+
}
|
|
56
|
+
function buildPullRequestContentRepairMessages(input) {
|
|
57
|
+
return [
|
|
58
|
+
{
|
|
59
|
+
role: "system",
|
|
60
|
+
content: "You repair invalid PR/MR content responses. Return strict JSON only."
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
role: "user",
|
|
64
|
+
content: [
|
|
65
|
+
"The previous response did not match the required PR/MR content protocol.",
|
|
66
|
+
"Validation issues:",
|
|
67
|
+
...input.validationIssues.map((issue) => `- ${issue}`),
|
|
68
|
+
"",
|
|
69
|
+
"Invalid response:",
|
|
70
|
+
input.invalidResponse,
|
|
71
|
+
"",
|
|
72
|
+
"Return strict JSON only with non-empty string fields: title, description."
|
|
73
|
+
].join("\n")
|
|
74
|
+
}
|
|
75
|
+
];
|
|
76
|
+
}
|
|
77
|
+
function buildPromptTuningSection(titlePrompt, descriptionPrompt) {
|
|
78
|
+
const lines = [];
|
|
79
|
+
if (titlePrompt.trim()) {
|
|
80
|
+
lines.push("Title prompt tuning:", titlePrompt.trim(), "");
|
|
81
|
+
}
|
|
82
|
+
if (descriptionPrompt.trim()) {
|
|
83
|
+
lines.push("Description prompt tuning:", descriptionPrompt.trim(), "");
|
|
84
|
+
}
|
|
85
|
+
return lines;
|
|
86
|
+
}
|
|
87
|
+
function buildLanguageRules(language) {
|
|
88
|
+
if (language === "zh-cn") {
|
|
89
|
+
return [
|
|
90
|
+
"Language rules:",
|
|
91
|
+
"- Write natural-language title and description content in Simplified Chinese.",
|
|
92
|
+
"- Keep code identifiers, file paths, configuration keys, ticket IDs, and exact code snippets in their original form."
|
|
93
|
+
];
|
|
94
|
+
}
|
|
95
|
+
if (language === "zh-tw") {
|
|
96
|
+
return [
|
|
97
|
+
"Language rules:",
|
|
98
|
+
"- Write natural-language title and description content in Traditional Chinese.",
|
|
99
|
+
"- Use Traditional Chinese characters and phrasing; do not write the final PR/MR content in Simplified Chinese.",
|
|
100
|
+
"- Keep code identifiers, file paths, configuration keys, ticket IDs, and exact code snippets in their original form."
|
|
101
|
+
];
|
|
102
|
+
}
|
|
103
|
+
if (language === "en") {
|
|
104
|
+
return [
|
|
105
|
+
"Language rules:",
|
|
106
|
+
"- Write natural-language title and description content in English.",
|
|
107
|
+
"- Do not use Chinese characters outside exact code identifiers or quoted snippets."
|
|
108
|
+
];
|
|
109
|
+
}
|
|
110
|
+
return [
|
|
111
|
+
"Language rules:",
|
|
112
|
+
`- Write natural-language title and description content in the selected language: ${language}.`,
|
|
113
|
+
"- Keep code identifiers, file paths, configuration keys, ticket IDs, and exact code snippets in their original form."
|
|
114
|
+
];
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=contentPrompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contentPrompt.js","sourceRoot":"","sources":["../../src/pullRequest/contentPrompt.ts"],"names":[],"mappings":";;AA2BA,0EAmDC;AAED,sFAoBC;AAzED,SAAgB,+BAA+B,CAAC,KAA2C;IACzF,MAAM,YAAY,GAAG,wBAAwB,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAC1F,MAAM,UAAU,GAAG;QACjB,aAAa,K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ACJ,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PullRequestContentProtocolError = void 0;
|
|
4
|
+
exports.generatePullRequestContent = generatePullRequestContent;
|
|
5
|
+
exports.parsePullRequestContentResponse = parsePullRequestContentResponse;
|
|
6
|
+
const responseCorrection_1 = require("../llm/responseCorrection");
|
|
7
|
+
const contentPrompt_1 = require("./contentPrompt");
|
|
8
|
+
class PullRequestContentProtocolError extends Error {
|
|
9
|
+
issues;
|
|
10
|
+
constructor(issues) {
|
|
11
|
+
super(issues.length > 0
|
|
12
|
+
? `Generated PR/MR content violated protocol: ${issues.join("; ")}`
|
|
13
|
+
: "Generated PR/MR content violated protocol.");
|
|
14
|
+
this.issues = issues;
|
|
15
|
+
this.name = "PullRequestContentProtocolError";
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.PullRequestContentProtocolError = PullRequestContentProtocolError;
|
|
19
|
+
async function generatePullRequestContent(input) {
|
|
20
|
+
const rawResponse = await input.client.complete((0, contentPrompt_1.buildPullRequestContentMessages)({
|
|
21
|
+
repositoryName: input.repositoryName,
|
|
22
|
+
platform: input.platform,
|
|
23
|
+
sourceBranch: input.sourceBranch,
|
|
24
|
+
targetBranch: input.targetBranch,
|
|
25
|
+
changedFiles: input.changedFiles,
|
|
26
|
+
diff: input.diff,
|
|
27
|
+
fullDiffChars: input.fullDiffChars,
|
|
28
|
+
truncated: input.truncated,
|
|
29
|
+
commitsText: input.commitsText,
|
|
30
|
+
language: input.language,
|
|
31
|
+
titlePrompt: input.titlePrompt,
|
|
32
|
+
descriptionPrompt: input.descriptionPrompt
|
|
33
|
+
}), input.abortSignal);
|
|
34
|
+
return (0, responseCorrection_1.runWithResponseCorrectionRetries)({
|
|
35
|
+
initialResponse: rawResponse,
|
|
36
|
+
maxCorrectionRetries: input.llmResponseCorrectionRetryCount,
|
|
37
|
+
validateResponse: async (response) => parsePullRequestContentResponse(response),
|
|
38
|
+
isRetryableError: isPullRequestContentProtocolError,
|
|
39
|
+
onRetryableError: ({ error }) => input.onRetryableError?.(error),
|
|
40
|
+
requestCorrection: async ({ error, invalidResponse }) => input.client.complete((0, contentPrompt_1.buildPullRequestContentRepairMessages)({
|
|
41
|
+
validationIssues: error.issues,
|
|
42
|
+
invalidResponse
|
|
43
|
+
}), input.abortSignal)
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function parsePullRequestContentResponse(raw) {
|
|
47
|
+
const trimmed = stripWrappingJsonFence(raw.trim()).trim();
|
|
48
|
+
let parsed;
|
|
49
|
+
try {
|
|
50
|
+
parsed = JSON.parse(trimmed);
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
54
|
+
throw new PullRequestContentProtocolError([`Response must be valid JSON: ${message}`]);
|
|
55
|
+
}
|
|
56
|
+
const issues = [];
|
|
57
|
+
const title = typeof parsed.title === "string" ? parsed.title.trim() : "";
|
|
58
|
+
const description = typeof parsed.description === "string" ? parsed.description.trim() : "";
|
|
59
|
+
if (!title) {
|
|
60
|
+
issues.push("title must be a non-empty string");
|
|
61
|
+
}
|
|
62
|
+
if (!description) {
|
|
63
|
+
issues.push("description must be a non-empty string");
|
|
64
|
+
}
|
|
65
|
+
if (issues.length > 0) {
|
|
66
|
+
throw new PullRequestContentProtocolError(issues);
|
|
67
|
+
}
|
|
68
|
+
return { title, description };
|
|
69
|
+
}
|
|
70
|
+
function isPullRequestContentProtocolError(error) {
|
|
71
|
+
return error instanceof PullRequestContentProtocolError;
|
|
72
|
+
}
|
|
73
|
+
function stripWrappingJsonFence(content) {
|
|
74
|
+
const match = content.match(/^```(?:json)?\s*\r?\n?([\s\S]*?)\r?\n?```$/i);
|
|
75
|
+
return match?.[1] ?? content;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=contentService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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AAC,CAAC,EAAE,CAAC;IAE5F,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;IAClD,CAAC;IACD,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC;IACxD,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,+BAA+B,CAAC,MAAM,CAAC,CAAC;IACpD,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC;AAChC,CAAC;AAED,SAAS,iCAAiC,CAAC,KAAc;IACvD,OAAO,KAAK,YAAY,+BAA+B,CAAC;AAC1D,CAAC;AAED,SAAS,sBAAsB,CAAC,OAAe;IAC7C,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,6CAA6C,CAAC,CAAC;IAC3E,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./api"), exports);
|
|
18
|
+
__exportStar(require("./client"), exports);
|
|
19
|
+
__exportStar(require("./config"), exports);
|
|
20
|
+
__exportStar(require("./contentPrompt"), exports);
|
|
21
|
+
__exportStar(require("./contentService"), exports);
|
|
22
|
+
__exportStar(require("./platform"), exports);
|
|
23
|
+
__exportStar(require("./redact"), exports);
|
|
24
|
+
__exportStar(require("./workflow"), exports);
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/pullRequest/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB;AACtB,2CAAyB;AACzB,2CAAyB;AACzB,kDAAgC;AAChC,mDAAiC;AACjC,6CAA2B;AAC3B,2CAAyB;AACzB,6CAA2B"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.detectPullRequestPlatform = detectPullRequestPlatform;
|
|
4
|
+
function detectPullRequestPlatform(remoteUrl, provider = "auto", configuredApiBaseUrl = "") {
|
|
5
|
+
const parsed = parseRemoteUrl(remoteUrl);
|
|
6
|
+
const normalizedHost = parsed.host.toLowerCase();
|
|
7
|
+
const projectPath = normalizeProjectPath(parsed.path);
|
|
8
|
+
const [owner, repository] = splitOwnerAndRepository(projectPath);
|
|
9
|
+
const kind = resolvePlatformKind(normalizedHost, provider);
|
|
10
|
+
if (kind === "github") {
|
|
11
|
+
return {
|
|
12
|
+
kind: "github",
|
|
13
|
+
host: normalizedHost,
|
|
14
|
+
owner,
|
|
15
|
+
repository,
|
|
16
|
+
projectPath,
|
|
17
|
+
htmlBaseUrl: buildHtmlBaseUrl("github", normalizedHost),
|
|
18
|
+
apiBaseUrl: buildApiBaseUrl("github", normalizedHost, configuredApiBaseUrl)
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
kind: "gitlab",
|
|
23
|
+
host: normalizedHost,
|
|
24
|
+
owner,
|
|
25
|
+
repository,
|
|
26
|
+
projectPath,
|
|
27
|
+
htmlBaseUrl: buildHtmlBaseUrl("gitlab", normalizedHost),
|
|
28
|
+
apiBaseUrl: buildApiBaseUrl("gitlab", normalizedHost, configuredApiBaseUrl)
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function parseRemoteUrl(remoteUrl) {
|
|
32
|
+
const trimmed = remoteUrl.trim();
|
|
33
|
+
if (!trimmed) {
|
|
34
|
+
throw new Error("Git remote URL is empty.");
|
|
35
|
+
}
|
|
36
|
+
const scpLikeMatch = trimmed.match(/^(?:[^@]+@)?([^:]+):(.+)$/);
|
|
37
|
+
if (scpLikeMatch && !trimmed.includes("://")) {
|
|
38
|
+
return {
|
|
39
|
+
host: scpLikeMatch[1],
|
|
40
|
+
path: scpLikeMatch[2]
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
let url;
|
|
44
|
+
try {
|
|
45
|
+
url = new URL(trimmed);
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
49
|
+
throw new Error(`Unsupported Git remote URL format: ${message}`);
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
host: url.host,
|
|
53
|
+
path: url.pathname
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function resolvePlatformKind(host, provider) {
|
|
57
|
+
if (provider === "github" || provider === "gitlab") {
|
|
58
|
+
return provider;
|
|
59
|
+
}
|
|
60
|
+
if (host === "github.com") {
|
|
61
|
+
return "github";
|
|
62
|
+
}
|
|
63
|
+
if (host === "gitlab.com") {
|
|
64
|
+
return "gitlab";
|
|
65
|
+
}
|
|
66
|
+
throw new Error(`Unsupported Git remote host for PR/MR creation: ${host}. Configure smartCommit.pullRequestProvider as "github" or "gitlab" for private deployments.`);
|
|
67
|
+
}
|
|
68
|
+
function buildHtmlBaseUrl(kind, host) {
|
|
69
|
+
if (kind === "github" && host === "github.com") {
|
|
70
|
+
return "https://github.com";
|
|
71
|
+
}
|
|
72
|
+
if (kind === "gitlab" && host === "gitlab.com") {
|
|
73
|
+
return "https://gitlab.com";
|
|
74
|
+
}
|
|
75
|
+
return `https://${host}`;
|
|
76
|
+
}
|
|
77
|
+
function buildApiBaseUrl(kind, host, configuredApiBaseUrl) {
|
|
78
|
+
const configured = configuredApiBaseUrl.trim().replace(/\/+$/, "");
|
|
79
|
+
if (configured) {
|
|
80
|
+
return configured;
|
|
81
|
+
}
|
|
82
|
+
if (kind === "github") {
|
|
83
|
+
return host === "github.com" ? "https://api.github.com" : `https://${host}/api/v3`;
|
|
84
|
+
}
|
|
85
|
+
return host === "gitlab.com" ? "https://gitlab.com/api/v4" : `https://${host}/api/v4`;
|
|
86
|
+
}
|
|
87
|
+
function normalizeProjectPath(input) {
|
|
88
|
+
const normalized = input.replace(/^\/+/, "").replace(/\.git$/i, "").replace(/\/+$/, "");
|
|
89
|
+
if (!normalized || !normalized.includes("/")) {
|
|
90
|
+
throw new Error(`Git remote URL does not contain an owner/project path: ${input}`);
|
|
91
|
+
}
|
|
92
|
+
return normalized;
|
|
93
|
+
}
|
|
94
|
+
function splitOwnerAndRepository(projectPath) {
|
|
95
|
+
const segments = projectPath.split("/").filter((segment) => segment.length > 0);
|
|
96
|
+
if (segments.length < 2) {
|
|
97
|
+
throw new Error(`Git remote project path must contain at least owner and repository: ${projectPath}`);
|
|
98
|
+
}
|
|
99
|
+
return [segments[0], segments[segments.length - 1]];
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=platform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../../src/pullRequest/platform.ts"],"names":[],"mappings":";;AAkBA,8DAgCC;AAhCD,SAAgB,yBAAyB,CACvC,SAAiB,EACjB,WAAgC,MAA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,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.redactSensitiveText = redactSensitiveText;
|
|
4
|
+
function redactSensitiveText(text, secrets) {
|
|
5
|
+
let redacted = text;
|
|
6
|
+
for (const secret of secrets) {
|
|
7
|
+
const trimmed = secret.trim();
|
|
8
|
+
if (trimmed.length < 8) {
|
|
9
|
+
continue;
|
|
10
|
+
}
|
|
11
|
+
redacted = redacted.split(trimmed).join("[REDACTED]");
|
|
12
|
+
}
|
|
13
|
+
return redacted;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=redact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redact.js","sourceRoot":"","sources":["../../src/pullRequest/redact.ts"],"names":[],"mappings":";;AAAA,kDAUC;AAVD,SAAgB,mBAAmB,CAAC,IAAY,EAAE,OAA0B;IAC1E,IAAI,QAAQ,GAAG,IAAI,CAAC;IACpB,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;QAC9B,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvB,SAAS;QACX,CAAC;QACD,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACxD,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.createPullRequestFromCurrentBranch = createPullRequestFromCurrentBranch;
|
|
37
|
+
const path = __importStar(require("node:path"));
|
|
38
|
+
const git_1 = require("../git");
|
|
39
|
+
const api_1 = require("./api");
|
|
40
|
+
const config_1 = require("./config");
|
|
41
|
+
const contentService_1 = require("./contentService");
|
|
42
|
+
const platform_1 = require("./platform");
|
|
43
|
+
async function createPullRequestFromCurrentBranch(input) {
|
|
44
|
+
const pullRequestConfig = input.pullRequestConfig ?? input.config.pullRequest;
|
|
45
|
+
(0, config_1.validatePullRequestCreationConfig)(pullRequestConfig);
|
|
46
|
+
const sourceBranch = await (0, git_1.getCurrentBranch)(input.repositoryPath);
|
|
47
|
+
if (!sourceBranch || sourceBranch === "HEAD") {
|
|
48
|
+
throw new Error("Cannot create a PR/MR from a detached HEAD or unnamed branch.");
|
|
49
|
+
}
|
|
50
|
+
const targetBranch = pullRequestConfig.targetBranch.trim();
|
|
51
|
+
if (sourceBranch === targetBranch) {
|
|
52
|
+
throw new Error("Current branch is the same as pullRequest.targetBranch; PR/MR creation was skipped.");
|
|
53
|
+
}
|
|
54
|
+
if (matchesAnyBranchPattern(sourceBranch, pullRequestConfig.skipBranches)) {
|
|
55
|
+
throw new Error(`Current branch ${sourceBranch} is blocked by pullRequest.skipBranches.`);
|
|
56
|
+
}
|
|
57
|
+
const upstream = await (0, git_1.getCurrentBranchUpstream)(input.repositoryPath);
|
|
58
|
+
const remoteUrl = await (0, git_1.getRemoteUrl)(input.repositoryPath, upstream.remote);
|
|
59
|
+
const platform = (0, platform_1.detectPullRequestPlatform)(remoteUrl, pullRequestConfig.provider, pullRequestConfig.apiBaseUrl);
|
|
60
|
+
input.onInfo?.(`[PR][INFO] Preparing ${platform.kind === "github" ? "pull request" : "merge request"} from ${sourceBranch} to ${targetBranch}.`);
|
|
61
|
+
const existing = await (0, api_1.findExistingPullRequests)({
|
|
62
|
+
platform,
|
|
63
|
+
config: pullRequestConfig,
|
|
64
|
+
sourceBranch,
|
|
65
|
+
targetBranch,
|
|
66
|
+
timeoutMs: input.config.connection.requestTimeoutMs
|
|
67
|
+
});
|
|
68
|
+
if (existing.length > 0) {
|
|
69
|
+
const first = existing[0];
|
|
70
|
+
return {
|
|
71
|
+
status: "existing",
|
|
72
|
+
platform: platform.kind,
|
|
73
|
+
sourceBranch,
|
|
74
|
+
targetBranch,
|
|
75
|
+
title: first.title,
|
|
76
|
+
url: first.url,
|
|
77
|
+
warnings: [],
|
|
78
|
+
existing
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
const comparison = await (0, api_1.getRemoteBranchComparison)({
|
|
82
|
+
platform,
|
|
83
|
+
config: pullRequestConfig,
|
|
84
|
+
sourceBranch,
|
|
85
|
+
targetBranch,
|
|
86
|
+
timeoutMs: input.config.connection.requestTimeoutMs
|
|
87
|
+
});
|
|
88
|
+
if (!comparison.fullDiff.trim()) {
|
|
89
|
+
throw new Error(`No branch diff found between ${targetBranch} and ${sourceBranch}.`);
|
|
90
|
+
}
|
|
91
|
+
const limitedDiff = (0, git_1.limitDiff)(comparison.fullDiff, pullRequestConfig.maxDiffChars, "[Diff truncated by smart-commit-cli for PR/MR creation]");
|
|
92
|
+
const content = await (0, contentService_1.generatePullRequestContent)({
|
|
93
|
+
client: input.client,
|
|
94
|
+
llmResponseCorrectionRetryCount: input.config.connection.llmResponseCorrectionRetryCount,
|
|
95
|
+
repositoryName: path.basename(input.repositoryPath),
|
|
96
|
+
platform: platform.kind,
|
|
97
|
+
sourceBranch,
|
|
98
|
+
targetBranch,
|
|
99
|
+
changedFiles: comparison.changedFiles,
|
|
100
|
+
diff: limitedDiff.diff,
|
|
101
|
+
fullDiffChars: comparison.fullDiffChars,
|
|
102
|
+
truncated: limitedDiff.truncated,
|
|
103
|
+
commitsText: comparison.commitsText || "(none)",
|
|
104
|
+
language: input.config.review.language,
|
|
105
|
+
titlePrompt: pullRequestConfig.titlePrompt,
|
|
106
|
+
descriptionPrompt: pullRequestConfig.descriptionPrompt,
|
|
107
|
+
onRetryableError: (error) => input.onInfo?.(`[PR][WARN] Generated PR/MR content did not match protocol: ${error.issues.join("; ")}`)
|
|
108
|
+
});
|
|
109
|
+
if (input.dryRun) {
|
|
110
|
+
return {
|
|
111
|
+
status: "ready",
|
|
112
|
+
platform: platform.kind,
|
|
113
|
+
sourceBranch,
|
|
114
|
+
targetBranch,
|
|
115
|
+
title: content.title,
|
|
116
|
+
url: null,
|
|
117
|
+
warnings: []
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
const pullRequest = await (0, api_1.createPullRequest)({
|
|
121
|
+
platform,
|
|
122
|
+
config: pullRequestConfig,
|
|
123
|
+
sourceBranch,
|
|
124
|
+
targetBranch,
|
|
125
|
+
timeoutMs: input.config.connection.requestTimeoutMs,
|
|
126
|
+
content
|
|
127
|
+
});
|
|
128
|
+
return {
|
|
129
|
+
status: "created",
|
|
130
|
+
platform: platform.kind,
|
|
131
|
+
sourceBranch,
|
|
132
|
+
targetBranch,
|
|
133
|
+
title: pullRequest.title,
|
|
134
|
+
url: pullRequest.url,
|
|
135
|
+
warnings: pullRequest.warnings,
|
|
136
|
+
pullRequest
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
function matchesAnyBranchPattern(branch, patterns) {
|
|
140
|
+
return patterns.some((pattern) => matchesBranchPattern(branch, pattern));
|
|
141
|
+
}
|
|
142
|
+
function matchesBranchPattern(branch, pattern) {
|
|
143
|
+
const trimmed = pattern.trim();
|
|
144
|
+
if (!trimmed) {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
if (!trimmed.includes("*")) {
|
|
148
|
+
return branch === trimmed;
|
|
149
|
+
}
|
|
150
|
+
const escaped = trimmed.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/\*/g, ".*");
|
|
151
|
+
return new RegExp(`^${escaped}$`).test(branch);
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=workflow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow.js","sourceRoot":"","sources":["../../src/pullRequest/workflow.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DA,gFAuHC;AAlLD,gDAAkC;AAElC,gCAKgB;AAChB,+BAMe;AACf,qCAAwF;AACxF,qDAAwF;AACxF,yCAA4E;AA0CrE,KAAK,UAAU,kCAAkC,CACtD,KAA8C;IAE9C,M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I,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,oBAAoB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAC3E,CAAC;AAED,SAAS,oBAAoB,CAAC,MAAc,EAAE,OAAe;IAC3D,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAC/B,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC3B,OAAO,MAAM,KAAK,OAAO,CAAC;IAC5B,CAAC;IACD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACnF,OAAO,IAAI,MAAM,CAAC,IAAI,OAAO,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AACjD,CAAC"}
|
package/out/renderOutput.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.resolveRequestedOutputFormat = resolveRequestedOutputFormat;
|
|
|
4
4
|
exports.renderConfigResolveOutput = renderConfigResolveOutput;
|
|
5
5
|
exports.renderBridgeOutput = renderBridgeOutput;
|
|
6
6
|
exports.renderReportOutput = renderReportOutput;
|
|
7
|
+
exports.renderPullRequestCreateOutput = renderPullRequestCreateOutput;
|
|
7
8
|
function resolveRequestedOutputFormat(argv, env, fallback = "json") {
|
|
8
9
|
for (let index = 0; index < argv.length; index += 1) {
|
|
9
10
|
const token = argv[index];
|
|
@@ -35,7 +36,7 @@ function renderConfigResolveOutput(payload, format) {
|
|
|
35
36
|
`Commit Language: ${payload.config.commitMessage.language}`,
|
|
36
37
|
`Commit Message Structure: ${payload.config.commitMessage.structure}`,
|
|
37
38
|
`Pass History Write Stage: ${payload.config.passHistory.writeStage}`,
|
|
38
|
-
`
|
|
39
|
+
`Staged Change Summary: ${String(payload.config.stagedChangeSummary.enabled)}`,
|
|
39
40
|
`Auto Commit: ${String(payload.config.git.autoCommit)}`,
|
|
40
41
|
`Auto Push: ${String(payload.config.git.autoPush)}`
|
|
41
42
|
]);
|
|
@@ -63,11 +64,14 @@ function renderBridgeOutput(payload, format) {
|
|
|
63
64
|
`Did Commit: ${String(payload.didCommit)}`,
|
|
64
65
|
`Did Push: ${String(payload.didPush)}`,
|
|
65
66
|
`Pass History Wrote: ${String(payload.passHistory.wrote)}`,
|
|
66
|
-
`
|
|
67
|
-
`
|
|
67
|
+
`Staged Change Summary Generated: ${String(payload.stagedChangeSummary.generated)}`,
|
|
68
|
+
`Staged Change Summary File: ${payload.stagedChangeSummary.outputFilePath ?? "(none)"}`,
|
|
69
|
+
`Pull Request Creation: ${payload.pullRequestCreation.status}`,
|
|
70
|
+
`Pull Request URL: ${payload.pullRequestCreation.url ?? "(none)"}`,
|
|
68
71
|
payload.error ? `Error Code: ${payload.error.code}` : "",
|
|
69
72
|
payload.error ? `Error Message: ${payload.error.message}` : "",
|
|
70
|
-
payload.
|
|
73
|
+
payload.stagedChangeSummary.error ? `Staged Change Summary Error: ${payload.stagedChangeSummary.error}` : "",
|
|
74
|
+
payload.pullRequestCreation.error ? `Pull Request Creation Error: ${payload.pullRequestCreation.error}` : ""
|
|
71
75
|
]);
|
|
72
76
|
}
|
|
73
77
|
function renderReportOutput(payload, format) {
|
|
@@ -89,6 +93,27 @@ function renderReportOutput(payload, format) {
|
|
|
89
93
|
payload.error ? `Error Message: ${payload.error.message}` : ""
|
|
90
94
|
]);
|
|
91
95
|
}
|
|
96
|
+
function renderPullRequestCreateOutput(payload, format) {
|
|
97
|
+
if (format === "json") {
|
|
98
|
+
return `${JSON.stringify(payload, null, 2)}\n`;
|
|
99
|
+
}
|
|
100
|
+
return toText([
|
|
101
|
+
"smart-commit pull-request create",
|
|
102
|
+
`Schema Version: ${payload.schemaVersion}`,
|
|
103
|
+
`Status: ${payload.status}`,
|
|
104
|
+
`Repository Path: ${payload.repositoryPath ?? "(none)"}`,
|
|
105
|
+
`Platform: ${payload.platform ?? "(none)"}`,
|
|
106
|
+
`Source Branch: ${payload.sourceBranch ?? "(none)"}`,
|
|
107
|
+
`Target Branch: ${payload.targetBranch ?? "(none)"}`,
|
|
108
|
+
`Title: ${payload.title ?? "(none)"}`,
|
|
109
|
+
`URL: ${payload.url ?? "(none)"}`,
|
|
110
|
+
`Dry Run: ${String(payload.dryRun)}`,
|
|
111
|
+
`Warnings: ${payload.warnings.length}`,
|
|
112
|
+
`Summary: ${payload.summary}`,
|
|
113
|
+
payload.error ? `Error Code: ${payload.error.code}` : "",
|
|
114
|
+
payload.error ? `Error Message: ${payload.error.message}` : ""
|
|
115
|
+
]);
|
|
116
|
+
}
|
|
92
117
|
function normalizeOutputFormat(value, fallback) {
|
|
93
118
|
const normalized = value?.trim().toLowerCase();
|
|
94
119
|
return normalized === "text" ? "text" : normalized === "json" ? "json" : fallback;
|
package/out/renderOutput.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderOutput.js","sourceRoot":"","sources":["../src/renderOutput.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"renderOutput.js","sourceRoot":"","sources":["../src/renderOutput.ts"],"names":[],"mappings":";;AAgBA,oEAiBC;AAED,8DAwBC;AAED,gDAkCC;AAED,gDAmBC;AAED,sEAqBC;AA3HD,SAAgB,4BAA4B,CAC1C,IAAuB,EACvB,GAAsB,EACtB,WAA4B,MAAM;IAElC,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QACpD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;QAC1B,IAAI,KAAK,KAAK,UAAU,EAAE,CAAC;YACzB,OAAO,qBAAqB,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;QAC1D,CAAC;QAED,IA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AC;IAED,IAAI,QAAQ,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QACzC,OAAO,KAAK,QAAQ,IAAI,UAAU,GAAG,CAAC;IACxC,CAAC;IAED,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,KAAK,QAAQ,GAAG,CAAC;IAC1B,CAAC;IAED,OAAO,UAAU,UAAU,GAAG,CAAC;AACjC,CAAC;AAED,SAAS,MAAM,CAAC,KAAe;IAC7B,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AAC/D,CAAC"}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.buildReportFacts = buildReportFacts;
|
|
4
4
|
const timeWindow_1 = require("./timeWindow");
|
|
5
5
|
function buildReportFacts(input) {
|
|
6
|
-
const window = (0, timeWindow_1.resolveReportTimeWindow)(input.periodType, input.weekStartsOn, input.now);
|
|
6
|
+
const window = (0, timeWindow_1.resolveReportTimeWindow)(input.periodType, input.weekStartsOn, input.now, input.language);
|
|
7
7
|
const records = input.records
|
|
8
8
|
.filter((record) => (0, timeWindow_1.isRecordInReportTimeWindow)(record.timestampMs, window))
|
|
9
9
|
.sort((left, right) => right.timestampMs - left.timestampMs);
|