smart-commit-copilot-cli 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -0
- package/LICENSE +21 -0
- package/README.md +392 -0
- package/docs/configuration.md +262 -0
- package/docs/contracts.md +134 -0
- package/docs/getting-started.md +177 -0
- package/docs/integrations.md +85 -0
- package/docs/publish.md +135 -0
- package/docs/release-checklist.md +39 -0
- package/docs/releases/0.1.0-draft.md +52 -0
- package/docs/roadmap.md +94 -0
- package/examples/agent/bridge-agent.mjs +51 -0
- package/examples/agent/report-agent.mjs +48 -0
- package/examples/config/smart-commit.json +60 -0
- package/examples/hooks/cursor-bridge-wrapper.sh +12 -0
- package/examples/hooks/husky-pre-commit.sh +6 -0
- package/examples/hooks/smart-commit-bridge.sh +11 -0
- package/out/cli.js +19 -0
- package/out/cli.js.map +1 -0
- package/out/cliApp.js +239 -0
- package/out/cliApp.js.map +1 -0
- package/out/commands/bridge.js +607 -0
- package/out/commands/bridge.js.map +1 -0
- package/out/commands/report.js +266 -0
- package/out/commands/report.js.map +1 -0
- package/out/commands/types.js +3 -0
- package/out/commands/types.js.map +1 -0
- package/out/commitMessage/index.js +110 -0
- package/out/commitMessage/index.js.map +1 -0
- package/out/commitMessage/mockProvider.js +27 -0
- package/out/commitMessage/mockProvider.js.map +1 -0
- package/out/commitMessage/openaiProvider.js +44 -0
- package/out/commitMessage/openaiProvider.js.map +1 -0
- package/out/commitMessage/prompt.js +65 -0
- package/out/commitMessage/prompt.js.map +1 -0
- package/out/commitMessage/protocol.js +126 -0
- package/out/commitMessage/protocol.js.map +1 -0
- package/out/commitMessage/provider.js +3 -0
- package/out/commitMessage/provider.js.map +1 -0
- package/out/config/cliArgs.js +249 -0
- package/out/config/cliArgs.js.map +1 -0
- package/out/config/constants.js +47 -0
- package/out/config/constants.js.map +1 -0
- package/out/config/env.js +183 -0
- package/out/config/env.js.map +1 -0
- package/out/config/file.js +245 -0
- package/out/config/file.js.map +1 -0
- package/out/config/index.js +46 -0
- package/out/config/index.js.map +1 -0
- package/out/config/legacySmartCommit.js +200 -0
- package/out/config/legacySmartCommit.js.map +1 -0
- package/out/config/merge.js +70 -0
- package/out/config/merge.js.map +1 -0
- package/out/config/runtime.js +36 -0
- package/out/config/runtime.js.map +1 -0
- package/out/config/schema.js +204 -0
- package/out/config/schema.js.map +1 -0
- package/out/contracts.js +311 -0
- package/out/contracts.js.map +1 -0
- package/out/git.js +119 -0
- package/out/git.js.map +1 -0
- package/out/logger.js +17 -0
- package/out/logger.js.map +1 -0
- package/out/openaiCompatible.js +67 -0
- package/out/openaiCompatible.js.map +1 -0
- package/out/output.js +23 -0
- package/out/output.js.map +1 -0
- package/out/passHistory/index.js +119 -0
- package/out/passHistory/index.js.map +1 -0
- package/out/passHistory/store.js +252 -0
- package/out/passHistory/store.js.map +1 -0
- package/out/passHistory/types.js +6 -0
- package/out/passHistory/types.js.map +1 -0
- package/out/promptContext.js +72 -0
- package/out/promptContext.js.map +1 -0
- package/out/renderOutput.js +89 -0
- package/out/renderOutput.js.map +1 -0
- package/out/reporting/aggregate.js +113 -0
- package/out/reporting/aggregate.js.map +1 -0
- package/out/reporting/index.js +72 -0
- package/out/reporting/index.js.map +1 -0
- package/out/reporting/mockProvider.js +25 -0
- package/out/reporting/mockProvider.js.map +1 -0
- package/out/reporting/openaiProvider.js +19 -0
- package/out/reporting/openaiProvider.js.map +1 -0
- package/out/reporting/prompt.js +28 -0
- package/out/reporting/prompt.js.map +1 -0
- package/out/reporting/provider.js +3 -0
- package/out/reporting/provider.js.map +1 -0
- package/out/reporting/render.js +151 -0
- package/out/reporting/render.js.map +1 -0
- package/out/reporting/timeWindow.js +79 -0
- package/out/reporting/timeWindow.js.map +1 -0
- package/out/reporting/types.js +11 -0
- package/out/reporting/types.js.map +1 -0
- package/out/review/index.js +64 -0
- package/out/review/index.js.map +1 -0
- package/out/review/mockProvider.js +57 -0
- package/out/review/mockProvider.js.map +1 -0
- package/out/review/openaiProvider.js +40 -0
- package/out/review/openaiProvider.js.map +1 -0
- package/out/review/parser.js +92 -0
- package/out/review/parser.js.map +1 -0
- package/out/review/prompt.js +61 -0
- package/out/review/prompt.js.map +1 -0
- package/out/review/provider.js +3 -0
- package/out/review/provider.js.map +1 -0
- package/out/review/types.js +3 -0
- package/out/review/types.js.map +1 -0
- package/package.json +44 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
|
|
3
|
+
const repoPath = process.argv[2] ?? process.cwd();
|
|
4
|
+
const configPath = process.env.SMART_COMMIT_CONFIG_PATH ?? `${repoPath}/examples/config/smart-commit.json`;
|
|
5
|
+
|
|
6
|
+
const result = spawnSync(
|
|
7
|
+
"smart-commit",
|
|
8
|
+
[
|
|
9
|
+
"bridge",
|
|
10
|
+
"--repo",
|
|
11
|
+
repoPath,
|
|
12
|
+
"--config",
|
|
13
|
+
configPath,
|
|
14
|
+
"--no-commit",
|
|
15
|
+
"--no-push"
|
|
16
|
+
],
|
|
17
|
+
{
|
|
18
|
+
encoding: "utf8"
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
if (!result.stdout.trim()) {
|
|
23
|
+
console.error("smart-commit did not return JSON output.");
|
|
24
|
+
process.exit(result.status ?? 1);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const payload = JSON.parse(result.stdout);
|
|
28
|
+
|
|
29
|
+
if (payload.schemaVersion !== "1.0.0") {
|
|
30
|
+
console.error(`Unsupported schemaVersion: ${payload.schemaVersion}`);
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (payload.status === "blocked") {
|
|
35
|
+
console.error(`Bridge blocked: ${payload.error?.code ?? "UNKNOWN"} ${payload.error?.message ?? ""}`.trim());
|
|
36
|
+
process.exit(2);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (payload.status === "error") {
|
|
40
|
+
console.error(`Bridge failed: ${payload.error?.code ?? "UNKNOWN"} ${payload.error?.message ?? ""}`.trim());
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
console.log(JSON.stringify({
|
|
45
|
+
schemaVersion: payload.schemaVersion,
|
|
46
|
+
status: payload.status,
|
|
47
|
+
phase: payload.phase,
|
|
48
|
+
score: payload.score,
|
|
49
|
+
reviewDecision: payload.reviewDecision,
|
|
50
|
+
summary: payload.summary
|
|
51
|
+
}, null, 2));
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
|
|
3
|
+
const repoPath = process.argv[2] ?? process.cwd();
|
|
4
|
+
const configPath = process.env.SMART_COMMIT_CONFIG_PATH ?? `${repoPath}/examples/config/smart-commit.json`;
|
|
5
|
+
const period = process.argv[3] ?? "weekly";
|
|
6
|
+
|
|
7
|
+
const result = spawnSync(
|
|
8
|
+
"smart-commit",
|
|
9
|
+
[
|
|
10
|
+
"report",
|
|
11
|
+
"generate",
|
|
12
|
+
"--repo",
|
|
13
|
+
repoPath,
|
|
14
|
+
"--config",
|
|
15
|
+
configPath,
|
|
16
|
+
"--period",
|
|
17
|
+
period
|
|
18
|
+
],
|
|
19
|
+
{
|
|
20
|
+
encoding: "utf8"
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
if (!result.stdout.trim()) {
|
|
25
|
+
console.error("smart-commit did not return JSON output.");
|
|
26
|
+
process.exit(result.status ?? 1);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const payload = JSON.parse(result.stdout);
|
|
30
|
+
|
|
31
|
+
if (payload.schemaVersion !== "1.0.0") {
|
|
32
|
+
console.error(`Unsupported schemaVersion: ${payload.schemaVersion}`);
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (payload.status === "error") {
|
|
37
|
+
console.error(`Report generation failed: ${payload.error?.code ?? "UNKNOWN"} ${payload.error?.message ?? ""}`.trim());
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
console.log(JSON.stringify({
|
|
42
|
+
schemaVersion: payload.schemaVersion,
|
|
43
|
+
status: payload.status,
|
|
44
|
+
renderMode: payload.renderMode,
|
|
45
|
+
reportProvider: payload.reportProvider,
|
|
46
|
+
outputFilePath: payload.outputFilePath,
|
|
47
|
+
summary: payload.summary
|
|
48
|
+
}, null, 2));
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"smartCommitCli": {
|
|
3
|
+
"connection": {
|
|
4
|
+
"baseUrl": "https://api.openai.com/v1",
|
|
5
|
+
"apiKey": "env:SMART_COMMIT_API_KEY",
|
|
6
|
+
"model": "gpt-5"
|
|
7
|
+
},
|
|
8
|
+
"review": {
|
|
9
|
+
"threshold": 6,
|
|
10
|
+
"language": "zh",
|
|
11
|
+
"maxDiffChars": 100000,
|
|
12
|
+
"skill": {
|
|
13
|
+
"id": "code-review",
|
|
14
|
+
"path": "",
|
|
15
|
+
"promptTuning": ""
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"commitMessage": {
|
|
19
|
+
"input": "",
|
|
20
|
+
"language": "zh",
|
|
21
|
+
"autoGenerate": true,
|
|
22
|
+
"hybridGenerate": false,
|
|
23
|
+
"skill": {
|
|
24
|
+
"id": "conventional",
|
|
25
|
+
"path": "",
|
|
26
|
+
"promptTuning": ""
|
|
27
|
+
},
|
|
28
|
+
"validation": {
|
|
29
|
+
"protocol": "none",
|
|
30
|
+
"pattern": "",
|
|
31
|
+
"extractTicketIdFromBranch": true,
|
|
32
|
+
"requireTicketIdInMessage": false
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"git": {
|
|
36
|
+
"autoStageWhenNothingStaged": true,
|
|
37
|
+
"autoCommit": true,
|
|
38
|
+
"autoPush": true,
|
|
39
|
+
"pushTimeoutMs": 90000
|
|
40
|
+
},
|
|
41
|
+
"passHistory": {
|
|
42
|
+
"enabled": true,
|
|
43
|
+
"dirPath": ".smart-commit-cli",
|
|
44
|
+
"maxEntries": 5000
|
|
45
|
+
},
|
|
46
|
+
"reporting": {
|
|
47
|
+
"language": "zh",
|
|
48
|
+
"weekStartsOn": "monday",
|
|
49
|
+
"outputDirPath": ".smart-commit-cli/reports",
|
|
50
|
+
"prompt": "",
|
|
51
|
+
"ai": {
|
|
52
|
+
"enabled": false
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"output": {
|
|
56
|
+
"format": "json",
|
|
57
|
+
"logLevel": "info"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env sh
|
|
2
|
+
set -eu
|
|
3
|
+
|
|
4
|
+
REPO_ROOT="$(git rev-parse --show-toplevel)"
|
|
5
|
+
CONFIG_PATH="${SMART_COMMIT_CONFIG_PATH:-$REPO_ROOT/examples/config/smart-commit.json}"
|
|
6
|
+
|
|
7
|
+
smart-commit bridge \
|
|
8
|
+
--repo "$REPO_ROOT" \
|
|
9
|
+
--config "$CONFIG_PATH" \
|
|
10
|
+
--no-commit \
|
|
11
|
+
--no-push \
|
|
12
|
+
--output json
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env sh
|
|
2
|
+
set -eu
|
|
3
|
+
|
|
4
|
+
REPO_ROOT="$(git rev-parse --show-toplevel)"
|
|
5
|
+
CONFIG_PATH="${SMART_COMMIT_CONFIG_PATH:-$REPO_ROOT/examples/config/smart-commit.json}"
|
|
6
|
+
|
|
7
|
+
smart-commit bridge \
|
|
8
|
+
--repo "$REPO_ROOT" \
|
|
9
|
+
--config "$CONFIG_PATH" \
|
|
10
|
+
--no-commit \
|
|
11
|
+
--no-push
|
package/out/cli.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const cliApp_1 = require("./cliApp");
|
|
5
|
+
async function main() {
|
|
6
|
+
const argv = process.argv.slice(2);
|
|
7
|
+
const command = (0, cliApp_1.parseCliCommand)(argv).kind;
|
|
8
|
+
const useAsync = command === "bridge" || command === "report-generate";
|
|
9
|
+
const result = useAsync ? await (0, cliApp_1.runCliAsync)(argv, process.env) : (0, cliApp_1.runCli)(argv, process.env);
|
|
10
|
+
if (result.stdout) {
|
|
11
|
+
process.stdout.write(result.stdout);
|
|
12
|
+
}
|
|
13
|
+
if (result.stderr) {
|
|
14
|
+
process.stderr.write(result.stderr);
|
|
15
|
+
}
|
|
16
|
+
process.exitCode = result.exitCode;
|
|
17
|
+
}
|
|
18
|
+
void main();
|
|
19
|
+
//# sourceMappingURL=cli.js.map
|
package/out/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;AAEA,qCAAgE;AAEhE,KAAK,UAAU,IAAI;IACjB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnC,MAAM,OAAO,GAAG,IAAA,wBAAe,EAAC,IAAI,CAAC,CAAC,IAAI,CAAC;IAC3C,MAAM,QAAQ,GAAG,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,iBAAiB,CAAC;IACvE,MAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,MAAM,IAAA,oBAAW,EAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAA,eAAM,EAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IAC3F,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAClB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAClB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IACD,OAAO,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;AACrC,CAAC;AAED,KAAK,IAAI,EAAE,CAAC"}
|
package/out/cliApp.js
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runCli = runCli;
|
|
4
|
+
exports.runCliAsync = runCliAsync;
|
|
5
|
+
exports.parseCliCommand = parseCliCommand;
|
|
6
|
+
const bridge_1 = require("./commands/bridge");
|
|
7
|
+
const report_1 = require("./commands/report");
|
|
8
|
+
const config_1 = require("./config");
|
|
9
|
+
const contracts_1 = require("./contracts");
|
|
10
|
+
const logger_1 = require("./logger");
|
|
11
|
+
const output_1 = require("./output");
|
|
12
|
+
const renderOutput_1 = require("./renderOutput");
|
|
13
|
+
function runCli(argv, env = process.env) {
|
|
14
|
+
try {
|
|
15
|
+
const command = parseCommand(argv);
|
|
16
|
+
if (command.kind === "help") {
|
|
17
|
+
return {
|
|
18
|
+
exitCode: 0,
|
|
19
|
+
stdout: buildHelpText(),
|
|
20
|
+
stderr: ""
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
if (command.kind === "config-resolve") {
|
|
24
|
+
const resolved = (0, config_1.resolveCliConfig)({
|
|
25
|
+
argv: command.flags,
|
|
26
|
+
env,
|
|
27
|
+
validate: true,
|
|
28
|
+
requireConnection: false
|
|
29
|
+
});
|
|
30
|
+
const payload = {
|
|
31
|
+
schemaVersion: contracts_1.SMART_COMMIT_CLI_SCHEMA_VERSION,
|
|
32
|
+
status: "ok",
|
|
33
|
+
command: "config resolve",
|
|
34
|
+
runtime: resolved.runtime,
|
|
35
|
+
config: (0, output_1.redactCliConfig)(resolved.config)
|
|
36
|
+
};
|
|
37
|
+
return {
|
|
38
|
+
exitCode: 0,
|
|
39
|
+
stdout: (0, renderOutput_1.renderConfigResolveOutput)(payload, resolved.config.output.format),
|
|
40
|
+
stderr: (0, logger_1.shouldLog)(resolved.config.output.logLevel, "debug")
|
|
41
|
+
? (0, logger_1.formatLogLine)("debug", `Resolved config for config resolve with output=${resolved.config.output.format}.`)
|
|
42
|
+
: ""
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
if (command.kind === "bridge") {
|
|
46
|
+
throw new Error("bridge command must be handled asynchronously via runCliAsync.");
|
|
47
|
+
}
|
|
48
|
+
if (command.kind === "report-generate") {
|
|
49
|
+
throw new Error("report generate command must be handled asynchronously via runCliAsync.");
|
|
50
|
+
}
|
|
51
|
+
if (command.kind === "schema-print") {
|
|
52
|
+
return {
|
|
53
|
+
exitCode: 0,
|
|
54
|
+
stdout: `${JSON.stringify((0, contracts_1.getSchemaDocument)(command.target), null, 2)}\n`,
|
|
55
|
+
stderr: ""
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
exitCode: bridge_1.EXIT_CODE_CONFIG_ERROR,
|
|
60
|
+
stdout: "",
|
|
61
|
+
stderr: `Unknown command: ${command.raw}\n${buildHelpText()}`
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
66
|
+
return {
|
|
67
|
+
exitCode: 3,
|
|
68
|
+
stdout: "",
|
|
69
|
+
stderr: `${message}\n`
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
async function runCliAsync(argv, env = process.env) {
|
|
74
|
+
try {
|
|
75
|
+
const command = parseCommand(argv);
|
|
76
|
+
if (command.kind !== "bridge") {
|
|
77
|
+
if (command.kind !== "report-generate") {
|
|
78
|
+
return runCli(argv, env);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (command.kind === "report-generate") {
|
|
82
|
+
const result = await (0, report_1.runReportGenerateCommand)(command.flags, env);
|
|
83
|
+
const outputFormat = (0, renderOutput_1.resolveRequestedOutputFormat)(command.flags, env, result.payload.config.output.format);
|
|
84
|
+
let stderr = "";
|
|
85
|
+
if (result.payload.warnings.length > 0 && (0, logger_1.shouldLog)(result.payload.config.output.logLevel, "warn")) {
|
|
86
|
+
stderr += result.payload.warnings.map((warning) => (0, logger_1.formatLogLine)("warn", warning)).join("");
|
|
87
|
+
}
|
|
88
|
+
if ((0, logger_1.shouldLog)(result.payload.config.output.logLevel, "debug")) {
|
|
89
|
+
stderr += (0, logger_1.formatLogLine)("debug", `report generate completed with status=${result.payload.status}, renderMode=${result.payload.renderMode}, output=${outputFormat}.`);
|
|
90
|
+
}
|
|
91
|
+
if (result.payload.status === "error" && result.payload.error) {
|
|
92
|
+
stderr += `${result.payload.error.message}\n`;
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
exitCode: result.exitCode,
|
|
96
|
+
stdout: (0, renderOutput_1.renderReportOutput)(result.payload, outputFormat),
|
|
97
|
+
stderr
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
const result = await (0, bridge_1.runBridgeCommand)(command.flags, env);
|
|
101
|
+
const outputFormat = (0, renderOutput_1.resolveRequestedOutputFormat)(command.flags, env, result.payload.config.output.format);
|
|
102
|
+
let stderr = "";
|
|
103
|
+
if ((0, logger_1.shouldLog)(result.payload.config.output.logLevel, "debug")) {
|
|
104
|
+
stderr += (0, logger_1.formatLogLine)("debug", `bridge completed with status=${result.payload.status}, phase=${result.payload.phase}, output=${outputFormat}.`);
|
|
105
|
+
}
|
|
106
|
+
if (result.payload.status !== "ready" && result.payload.error) {
|
|
107
|
+
stderr += `${result.payload.error.message}\n`;
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
exitCode: result.exitCode,
|
|
111
|
+
stdout: (0, renderOutput_1.renderBridgeOutput)(result.payload, outputFormat),
|
|
112
|
+
stderr
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
117
|
+
return {
|
|
118
|
+
exitCode: 4,
|
|
119
|
+
stdout: "",
|
|
120
|
+
stderr: `${message}\n`
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
function parseCommand(argv) {
|
|
125
|
+
const positional = argv.filter((token) => !token.startsWith("--"));
|
|
126
|
+
if (argv.length === 0 || argv.includes("--help") || argv.includes("-h") || positional[0] === "help") {
|
|
127
|
+
return { kind: "help", raw: positional.join(" ") };
|
|
128
|
+
}
|
|
129
|
+
if (positional[0] === "config" && positional[1] === "resolve") {
|
|
130
|
+
return {
|
|
131
|
+
kind: "config-resolve",
|
|
132
|
+
raw: "config resolve",
|
|
133
|
+
flags: filterCommandTokens(argv, 2)
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
if (positional[0] === "bridge") {
|
|
137
|
+
return {
|
|
138
|
+
kind: "bridge",
|
|
139
|
+
raw: "bridge",
|
|
140
|
+
flags: filterCommandTokens(argv, 1)
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
if (positional[0] === "report" && positional[1] === "generate") {
|
|
144
|
+
return {
|
|
145
|
+
kind: "report-generate",
|
|
146
|
+
raw: "report generate",
|
|
147
|
+
flags: filterCommandTokens(argv, 2)
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
if (positional[0] === "schema" && positional[1] === "print") {
|
|
151
|
+
return {
|
|
152
|
+
kind: "schema-print",
|
|
153
|
+
raw: "schema print",
|
|
154
|
+
target: parseSchemaTarget(argv)
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
return {
|
|
158
|
+
kind: "unknown",
|
|
159
|
+
raw: positional.join(" ") || argv[0] || "(empty)"
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
function parseCliCommand(argv) {
|
|
163
|
+
return parseCommand(argv);
|
|
164
|
+
}
|
|
165
|
+
function filterCommandTokens(argv, positionalCount) {
|
|
166
|
+
const result = [];
|
|
167
|
+
let consumedPositional = 0;
|
|
168
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
169
|
+
const token = argv[index];
|
|
170
|
+
if (!token.startsWith("--") && consumedPositional < positionalCount) {
|
|
171
|
+
consumedPositional += 1;
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
result.push(token);
|
|
175
|
+
}
|
|
176
|
+
return result;
|
|
177
|
+
}
|
|
178
|
+
function buildHelpText() {
|
|
179
|
+
return [
|
|
180
|
+
"smart-commit CLI",
|
|
181
|
+
"",
|
|
182
|
+
"Usage:",
|
|
183
|
+
" smart-commit config resolve [flags]",
|
|
184
|
+
" smart-commit bridge [flags]",
|
|
185
|
+
" smart-commit report generate [flags]",
|
|
186
|
+
" smart-commit schema print --target <config-file|config-resolve|bridge|report-generate>",
|
|
187
|
+
" smart-commit --help",
|
|
188
|
+
"",
|
|
189
|
+
"Current commands:",
|
|
190
|
+
" config resolve Resolve and validate the merged CLI config",
|
|
191
|
+
" bridge Validate bridge inputs and emit a stable JSON contract",
|
|
192
|
+
" report generate Generate a Markdown work report from pass history",
|
|
193
|
+
" schema print Print the machine-facing JSON schema for a CLI contract",
|
|
194
|
+
"",
|
|
195
|
+
"Common flags:",
|
|
196
|
+
" --config <path>",
|
|
197
|
+
" --repo <path>",
|
|
198
|
+
" --base-url <url>",
|
|
199
|
+
" --api-key <key>",
|
|
200
|
+
" --model <model-id>",
|
|
201
|
+
" --threshold <number>",
|
|
202
|
+
" --review-language <lang>",
|
|
203
|
+
" --commit-language <lang>",
|
|
204
|
+
" --auto-generate-commit-message <true|false>",
|
|
205
|
+
" --hybrid-generate-commit-message <true|false>",
|
|
206
|
+
" --period <daily|weekly|monthly|quarterly|yearly>",
|
|
207
|
+
" --report-ai",
|
|
208
|
+
" --no-report-ai",
|
|
209
|
+
" --no-commit",
|
|
210
|
+
" --no-push",
|
|
211
|
+
" --dry-run"
|
|
212
|
+
].join("\n") + "\n";
|
|
213
|
+
}
|
|
214
|
+
function parseSchemaTarget(argv) {
|
|
215
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
216
|
+
const token = argv[index];
|
|
217
|
+
if (token === "--target") {
|
|
218
|
+
return validateSchemaTarget(argv[index + 1]);
|
|
219
|
+
}
|
|
220
|
+
if (token.startsWith("--target=")) {
|
|
221
|
+
return validateSchemaTarget(token.slice("--target=".length));
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
throw new Error("--target is required for schema print.");
|
|
225
|
+
}
|
|
226
|
+
function validateSchemaTarget(value) {
|
|
227
|
+
if (!value) {
|
|
228
|
+
throw new Error("--target requires a value.");
|
|
229
|
+
}
|
|
230
|
+
const normalized = value.trim().toLowerCase();
|
|
231
|
+
if (normalized === "config-file" ||
|
|
232
|
+
normalized === "config-resolve" ||
|
|
233
|
+
normalized === "bridge" ||
|
|
234
|
+
normalized === "report-generate") {
|
|
235
|
+
return normalized;
|
|
236
|
+
}
|
|
237
|
+
throw new Error("--target must be one of: config-file, config-resolve, bridge, report-generate.");
|
|
238
|
+
}
|
|
239
|
+
//# sourceMappingURL=cliApp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cliApp.js","sourceRoot":"","sources":["../src/cliApp.ts"],"names":[],"mappings":";;AAuBA,wBAkEC;AAED,kCAmEC;AAuDD,0CAEC;AAvND,8CAA6E;AAC7E,8CAA6D;AAC7D,qCAA4C;AAC5C,2CAIqB;AACrB,qCAAoD;AACpD,qCAA2C;AAC3C,iDAKwB;AAQxB,SAAgB,MAAM,CAAC,IAAuB,EAAE,MAAyB,OAAO,CAAC,GAAG;IAClF,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;QAEnC,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YAC5B,OAAO;gBACL,QAAQ,EAAE,CAAC;gBACX,MAAM,EAAE,aAAa,EAAE;gBACvB,MAAM,EAAE,EAAE;aACX,CA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