@andre-barbosa/opencode-commit 0.1.5 → 0.1.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.
Files changed (2) hide show
  1. package/dist/index.js +14 -21
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -7,6 +7,9 @@ const COMMAND_TEMPLATE = "Handled by the opencode-commit plugin.";
7
7
  function textPart(text) {
8
8
  return { type: "text", text };
9
9
  }
10
+ function replaceOutputParts(output, ...parts) {
11
+ output.parts.splice(0, output.parts.length, ...parts);
12
+ }
10
13
  function formatOutput(input) {
11
14
  if (input.request.mode === "split") {
12
15
  const missingFolders = input.missingFolders ?? [];
@@ -72,29 +75,23 @@ export const OpenCodeCommitPlugin = async ({ client, $, worktree }, options) =>
72
75
  return;
73
76
  try {
74
77
  if (!config.model) {
75
- output.parts = [
76
- textPart([
77
- "No commit model configured.",
78
- "",
79
- "Add a `model` option to the opencode-commit plugin config, for example:",
80
- "`[\"@andre-barbosa/opencode-commit\", { \"model\": \"opencode-go/deepseek-v4-flash\" }]`",
81
- ].join("\n")),
82
- ];
78
+ replaceOutputParts(output, textPart([
79
+ "No commit model configured.",
80
+ "",
81
+ "Add a `model` option to the opencode-commit plugin config, for example:",
82
+ "`[\"@andre-barbosa/opencode-commit\", { \"model\": \"opencode-go/deepseek-v4-flash\" }]`",
83
+ ].join("\n")));
83
84
  return;
84
85
  }
85
86
  const model = parseModelRef(config.model);
86
87
  const request = parseCommitRequest(input.arguments);
87
88
  if (!(await isGitRepo($, worktree))) {
88
- output.parts = [
89
- textPart("Not a git repository. Run `/commit` from inside a git worktree."),
90
- ];
89
+ replaceOutputParts(output, textPart("Not a git repository. Run `/commit` from inside a git worktree."));
91
90
  return;
92
91
  }
93
92
  const context = await gatherGitContext($, worktree, config.maxDiffChars);
94
93
  if (!context.hasUncommittedChanges) {
95
- output.parts = [
96
- textPart("No uncommitted changes found. Make changes and run `/commit` again."),
97
- ];
94
+ replaceOutputParts(output, textPart("No uncommitted changes found. Make changes and run `/commit` again."));
98
95
  return;
99
96
  }
100
97
  let groups;
@@ -107,7 +104,7 @@ export const OpenCodeCommitPlugin = async ({ client, $, worktree }, options) =>
107
104
  const target = request.folders.length > 0
108
105
  ? `requested folder(s): ${formatFolderList(request.folders)}`
109
106
  : "changed folders";
110
- output.parts = [textPart(`No changes found for ${target}.`)];
107
+ replaceOutputParts(output, textPart(`No changes found for ${target}.`));
111
108
  return;
112
109
  }
113
110
  }
@@ -126,9 +123,7 @@ export const OpenCodeCommitPlugin = async ({ client, $, worktree }, options) =>
126
123
  request,
127
124
  groups,
128
125
  });
129
- output.parts = [
130
- textPart(formatOutput({ ...result, request, missingFolders })),
131
- ];
126
+ replaceOutputParts(output, textPart(formatOutput({ ...result, request, missingFolders })));
132
127
  return;
133
128
  }
134
129
  catch (error) {
@@ -136,9 +131,7 @@ export const OpenCodeCommitPlugin = async ({ client, $, worktree }, options) =>
136
131
  error: String(error),
137
132
  sessionID: input.sessionID,
138
133
  });
139
- output.parts = [
140
- textPart(`Failed to generate commit message: ${String(error)}`),
141
- ];
134
+ replaceOutputParts(output, textPart(`Failed to generate commit message: ${String(error)}`));
142
135
  return;
143
136
  }
144
137
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andre-barbosa/opencode-commit",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
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",