@webywz/vibe-commit 0.1.18 → 0.1.20

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/config.d.ts CHANGED
@@ -4,3 +4,13 @@ export interface ProjectConfig {
4
4
  vibe?: Vibe;
5
5
  }
6
6
  export declare function loadProjectConfig(cwd?: string): ProjectConfig | undefined;
7
+ /**
8
+ * Resolve locale with precedence: env (VIBE_COMMIT_LOCALE) > project config > default (en).
9
+ * Use this for contexts where CLI flags are not available (e.g., git hooks).
10
+ */
11
+ export declare function resolveLocale(env?: NodeJS.ProcessEnv, cwd?: string): Locale;
12
+ /**
13
+ * Resolve vibe with precedence: env (VIBE_COMMIT_VIBE or VIBE) > project config > default (pro).
14
+ * Use this for contexts where CLI flags are not available (e.g., git hooks).
15
+ */
16
+ export declare function resolveVibe(env?: NodeJS.ProcessEnv, cwd?: string): Vibe;
package/dist/config.js CHANGED
@@ -46,4 +46,34 @@ function normalizeConfig(raw) {
46
46
  }
47
47
  return config;
48
48
  }
49
+ /**
50
+ * Resolve locale with precedence: env (VIBE_COMMIT_LOCALE) > project config > default (en).
51
+ * Use this for contexts where CLI flags are not available (e.g., git hooks).
52
+ */
53
+ export function resolveLocale(env = process.env, cwd = process.cwd()) {
54
+ const envValue = env.VIBE_COMMIT_LOCALE?.trim().toLowerCase();
55
+ if (envValue && LOCALES.includes(envValue)) {
56
+ return envValue;
57
+ }
58
+ const projectConfig = loadProjectConfig(cwd);
59
+ if (projectConfig?.locale) {
60
+ return projectConfig.locale;
61
+ }
62
+ return "en";
63
+ }
64
+ /**
65
+ * Resolve vibe with precedence: env (VIBE_COMMIT_VIBE or VIBE) > project config > default (pro).
66
+ * Use this for contexts where CLI flags are not available (e.g., git hooks).
67
+ */
68
+ export function resolveVibe(env = process.env, cwd = process.cwd()) {
69
+ const envValue = (env.VIBE_COMMIT_VIBE ?? env.VIBE)?.trim().toLowerCase();
70
+ if (envValue && VIBES.includes(envValue)) {
71
+ return envValue;
72
+ }
73
+ const projectConfig = loadProjectConfig(cwd);
74
+ if (projectConfig?.vibe) {
75
+ return projectConfig.vibe;
76
+ }
77
+ return "pro";
78
+ }
49
79
  //# sourceMappingURL=config.js.map
package/dist/hook.js CHANGED
@@ -4,9 +4,8 @@ import { dirname, isAbsolute, join } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import { formatCommit } from "./format.js";
6
6
  import { assertRepo, GitError, inspectStaged } from "./git.js";
7
- import { defaultLocaleFromEnv, defaultVibeFromEnv } from "./parse-args.js";
8
7
  import { proposeMessage } from "./propose.js";
9
- import { loadProjectConfig } from "./config.js";
8
+ import { resolveLocale, resolveVibe } from "./config.js";
10
9
  export const HOOK_BEGIN = "# BEGIN VIBE-COMMIT";
11
10
  export const HOOK_END = "# END VIBE-COMMIT";
12
11
  export const HOOK_NAME = "prepare-commit-msg";
@@ -43,10 +42,9 @@ export async function runPrepareCommitMsg(messageFile, source, cwd = process.cwd
43
42
  const diff = inspectStaged(cwd);
44
43
  // Avoid hanging `git commit` on network — hooks stay offline unless opted in.
45
44
  const useAi = env.VIBE_COMMIT_HOOK_AI === "1";
46
- const projectConfig = loadProjectConfig(cwd);
47
45
  const message = await proposeMessage(diff, {
48
- vibe: projectConfig?.vibe ?? defaultVibeFromEnv(env),
49
- locale: projectConfig?.locale ?? defaultLocaleFromEnv(env),
46
+ vibe: resolveVibe(env, cwd),
47
+ locale: resolveLocale(env, cwd),
50
48
  preferAi: useAi,
51
49
  }, env);
52
50
  const formatted = formatCommit(message);
@@ -1,5 +1,5 @@
1
1
  import { COMMIT_TYPES, LOCALES, VIBES, } from "./types.js";
2
- import { loadProjectConfig } from "./config.js";
2
+ import { resolveLocale, resolveVibe } from "./config.js";
3
3
  const HELP = `vibe-commit — stylish conventional commits, offline-first
4
4
  有品味的 Conventional Commits(离线优先)
5
5
 
@@ -80,13 +80,12 @@ export function defaultLocaleFromEnv(env = process.env) {
80
80
  return LOCALES.includes(raw) ? raw : "en";
81
81
  }
82
82
  export function parseArgs(argv, env = process.env, cwd = process.cwd()) {
83
- const projectConfig = loadProjectConfig(cwd);
84
83
  const options = {
85
84
  command: "propose",
86
85
  commit: false,
87
86
  dryRun: false,
88
- vibe: projectConfig?.vibe ?? defaultVibeFromEnv(env),
89
- locale: projectConfig?.locale ?? defaultLocaleFromEnv(env),
87
+ vibe: resolveVibe(env, cwd),
88
+ locale: resolveLocale(env, cwd),
90
89
  noAi: false,
91
90
  json: false,
92
91
  github: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webywz/vibe-commit",
3
- "version": "0.1.18",
3
+ "version": "0.1.20",
4
4
  "description": "Stylish conventional commit messages with personality. Offline-first, AI-optional.",
5
5
  "keywords": [
6
6
  "git",