@andre-barbosa/opencode-commit 0.1.4 → 0.1.5
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/dist/index.js +6 -14
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4,7 +4,6 @@ import { buildCommitGroups, parseCommitRequest, parseModelRef, resolveConfig, }
|
|
|
4
4
|
const COMMAND_NAME = "commit";
|
|
5
5
|
const COMMAND_DESCRIPTION = "Generate a commit message or split commit plan from uncommitted changes";
|
|
6
6
|
const COMMAND_TEMPLATE = "Handled by the opencode-commit plugin.";
|
|
7
|
-
const SKIP_ERROR = "skip";
|
|
8
7
|
function textPart(text) {
|
|
9
8
|
return { type: "text", text };
|
|
10
9
|
}
|
|
@@ -43,9 +42,6 @@ function formatOutput(input) {
|
|
|
43
42
|
function formatFolderList(folders) {
|
|
44
43
|
return folders.map((folder) => `\`${folder}\``).join(", ");
|
|
45
44
|
}
|
|
46
|
-
const skipCommand = () => {
|
|
47
|
-
throw new Error(SKIP_ERROR);
|
|
48
|
-
};
|
|
49
45
|
export const OpenCodeCommitPlugin = async ({ client, $, worktree }, options) => {
|
|
50
46
|
const config = resolveConfig(options);
|
|
51
47
|
const log = async (level, message, extra) => {
|
|
@@ -66,7 +62,6 @@ export const OpenCodeCommitPlugin = async ({ client, $, worktree }, options) =>
|
|
|
66
62
|
cfg.command[COMMAND_NAME] = {
|
|
67
63
|
description: COMMAND_DESCRIPTION,
|
|
68
64
|
template: COMMAND_TEMPLATE,
|
|
69
|
-
subtask: true,
|
|
70
65
|
};
|
|
71
66
|
if (config.model) {
|
|
72
67
|
cfg.command[COMMAND_NAME].model = config.model;
|
|
@@ -85,7 +80,7 @@ export const OpenCodeCommitPlugin = async ({ client, $, worktree }, options) =>
|
|
|
85
80
|
"`[\"@andre-barbosa/opencode-commit\", { \"model\": \"opencode-go/deepseek-v4-flash\" }]`",
|
|
86
81
|
].join("\n")),
|
|
87
82
|
];
|
|
88
|
-
return
|
|
83
|
+
return;
|
|
89
84
|
}
|
|
90
85
|
const model = parseModelRef(config.model);
|
|
91
86
|
const request = parseCommitRequest(input.arguments);
|
|
@@ -93,14 +88,14 @@ export const OpenCodeCommitPlugin = async ({ client, $, worktree }, options) =>
|
|
|
93
88
|
output.parts = [
|
|
94
89
|
textPart("Not a git repository. Run `/commit` from inside a git worktree."),
|
|
95
90
|
];
|
|
96
|
-
return
|
|
91
|
+
return;
|
|
97
92
|
}
|
|
98
93
|
const context = await gatherGitContext($, worktree, config.maxDiffChars);
|
|
99
94
|
if (!context.hasUncommittedChanges) {
|
|
100
95
|
output.parts = [
|
|
101
96
|
textPart("No uncommitted changes found. Make changes and run `/commit` again."),
|
|
102
97
|
];
|
|
103
|
-
return
|
|
98
|
+
return;
|
|
104
99
|
}
|
|
105
100
|
let groups;
|
|
106
101
|
let missingFolders = [];
|
|
@@ -113,7 +108,7 @@ export const OpenCodeCommitPlugin = async ({ client, $, worktree }, options) =>
|
|
|
113
108
|
? `requested folder(s): ${formatFolderList(request.folders)}`
|
|
114
109
|
: "changed folders";
|
|
115
110
|
output.parts = [textPart(`No changes found for ${target}.`)];
|
|
116
|
-
return
|
|
111
|
+
return;
|
|
117
112
|
}
|
|
118
113
|
}
|
|
119
114
|
await log("info", "Generating commit message", {
|
|
@@ -134,12 +129,9 @@ export const OpenCodeCommitPlugin = async ({ client, $, worktree }, options) =>
|
|
|
134
129
|
output.parts = [
|
|
135
130
|
textPart(formatOutput({ ...result, request, missingFolders })),
|
|
136
131
|
];
|
|
137
|
-
return
|
|
132
|
+
return;
|
|
138
133
|
}
|
|
139
134
|
catch (error) {
|
|
140
|
-
if (error instanceof Error && error.message === SKIP_ERROR) {
|
|
141
|
-
throw error;
|
|
142
|
-
}
|
|
143
135
|
await log("error", "Commit message generation failed", {
|
|
144
136
|
error: String(error),
|
|
145
137
|
sessionID: input.sessionID,
|
|
@@ -147,7 +139,7 @@ export const OpenCodeCommitPlugin = async ({ client, $, worktree }, options) =>
|
|
|
147
139
|
output.parts = [
|
|
148
140
|
textPart(`Failed to generate commit message: ${String(error)}`),
|
|
149
141
|
];
|
|
150
|
-
return
|
|
142
|
+
return;
|
|
151
143
|
}
|
|
152
144
|
},
|
|
153
145
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@andre-barbosa/opencode-commit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "OpenCode plugin that generates Conventional Commit messages and split commit plans via /commit using a configured model",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|