@andre-barbosa/opencode-commit 0.1.0 → 0.1.3

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/src/types.ts CHANGED
@@ -1,40 +1,53 @@
1
- export type ModelRef = {
2
- providerID: string;
3
- modelID: string;
4
- };
5
-
6
- export type PluginOptions = {
7
- agent?: string;
8
- maxDiffChars?: number;
9
- };
10
-
11
- export type ResolvedPluginConfig = {
12
- agent: string;
13
- maxDiffChars: number;
14
- };
15
-
16
- export const DEFAULT_AGENT = "commit-writer";
17
- export const DEFAULT_MAX_DIFF_CHARS = 12_000;
18
-
19
- export function resolveConfig(options?: PluginOptions): ResolvedPluginConfig {
20
- return {
21
- agent: options?.agent?.trim() || DEFAULT_AGENT,
22
- maxDiffChars:
23
- typeof options?.maxDiffChars === "number" && options.maxDiffChars > 0
24
- ? Math.floor(options.maxDiffChars)
25
- : DEFAULT_MAX_DIFF_CHARS,
26
- };
27
- }
28
-
29
- export type GitContext = {
30
- branch: string;
31
- stat: string;
32
- diff: string;
33
- recentCommits: string[];
34
- hasStagedChanges: boolean;
35
- };
36
-
37
- export type AgentInfo = {
38
- name: string;
39
- model?: ModelRef;
40
- };
1
+ export type ModelRef = {
2
+ providerID: string;
3
+ modelID: string;
4
+ };
5
+
6
+ export type PluginOptions = {
7
+ model?: string;
8
+ maxDiffChars?: number;
9
+ };
10
+
11
+ export type ResolvedPluginConfig = {
12
+ model?: string;
13
+ maxDiffChars: number;
14
+ };
15
+
16
+ export const DEFAULT_MAX_DIFF_CHARS = 12_000;
17
+
18
+ export function resolveConfig(options?: PluginOptions): ResolvedPluginConfig {
19
+ const model = typeof options?.model === "string" ? options.model.trim() : "";
20
+
21
+ return {
22
+ model: model || undefined,
23
+ maxDiffChars:
24
+ typeof options?.maxDiffChars === "number" && options.maxDiffChars > 0
25
+ ? Math.floor(options.maxDiffChars)
26
+ : DEFAULT_MAX_DIFF_CHARS,
27
+ };
28
+ }
29
+
30
+ export function parseModelRef(model: string): ModelRef {
31
+ const separator = model.indexOf("/");
32
+ if (separator <= 0 || separator === model.length - 1) {
33
+ throw new Error(
34
+ `Invalid commit model \`${model}\`. Use the format \`provider/model-id\`.`,
35
+ );
36
+ }
37
+
38
+ return {
39
+ providerID: model.slice(0, separator),
40
+ modelID: model.slice(separator + 1),
41
+ };
42
+ }
43
+
44
+ export type GitContext = {
45
+ branch: string;
46
+ stagedStat: string;
47
+ stagedDiff: string;
48
+ unstagedStat: string;
49
+ unstagedDiff: string;
50
+ untrackedFiles: string[];
51
+ recentCommits: string[];
52
+ hasUncommittedChanges: boolean;
53
+ };
@@ -1,27 +0,0 @@
1
- ---
2
- description: Generates conventional commit messages from git diffs
3
- mode: subagent
4
- hidden: true
5
- model: anthropic/claude-haiku-4-20250514
6
- temperature: 0.1
7
- permission:
8
- edit: deny
9
- bash: deny
10
- webfetch: deny
11
- ---
12
-
13
- You are a commit message writer. Given a git diff and context, produce a single commit message.
14
-
15
- You MUST follow Conventional Commits:
16
-
17
- - Subject: `type(scope): description` or `type: description`
18
- - Types: feat, fix, docs, style, refactor, perf, test, build, ci, chore
19
- - Scope: optional but preferred for localized changes (e.g. auth, api, ui)
20
- - Description: imperative, lowercase, no trailing period, max 72 chars for the subject line
21
- - Body: optional blank line then bullet points for non-obvious context
22
- - Breaking changes: `feat!:` / `fix!:` or a `BREAKING CHANGE:` footer
23
-
24
- Never output free-form subjects like "Update files", "WIP", or "Misc changes".
25
- Never wrap the message in code fences.
26
- Never add commentary before or after the commit message.
27
- Output only the commit message text.