@yourfam/yf-commit 0.1.0 → 0.1.1

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/README.md CHANGED
@@ -2,98 +2,164 @@
2
2
 
3
3
  AI commit message from your staged git diff.
4
4
 
5
- ```
6
- npx @yourfam/yf-commit
7
- ```
8
-
9
- Writes a conventional first line (`emoji type(scope): …`) plus WHY, WHAT CHANGED, and FILES IMPACTED. It does **not** run your test suite and does **not** append worktree / branch / machine trailers.
5
+ Writes `emoji type(scope): …` plus WHY, WHAT CHANGED, and FILES IMPACTED. Does **not** run your test suite. Does **not** append worktree / branch / machine trailers.
10
6
 
11
7
  YourFam does not give you an API key. Use your own OpenAI-compatible key.
12
8
 
9
+ - **Source / README:** https://github.com/YourFam/yf-commit
10
+ - **npm:** https://www.npmjs.com/package/@yourfam/yf-commit
11
+ - **Issues:** https://github.com/YourFam/yf-commit/issues
12
+
13
13
  ## Install
14
14
 
15
- Node 20+. Friend one-liner:
15
+ Node 20+.
16
16
 
17
17
  ```bash
18
- npx @yourfam/yf-commit
18
+ npm install -g @yourfam/yf-commit
19
19
  ```
20
20
 
21
- Or install once:
21
+ Then from any git repo:
22
22
 
23
23
  ```bash
24
- npm install -g @yourfam/yf-commit
25
24
  yf-commit
26
25
  ```
27
26
 
28
- The command is `yf-commit` (not `ai-commit` that name is already used by other packages).
27
+ The command is `yf-commit`. After a **global** install, npm prints a short hint (`yf-commit installed…`). That does not run for `-D`, CI, or `npx`.
29
28
 
30
- ## First run / `yf-commit init`
29
+ ## Alternate modes of install
31
30
 
32
- The first `yf-commit` with no key **is** setup (same idea as `gh auth login`).
31
+ **-g** = on **your machine** (global).
32
+ **-D** = in **this project** (devDependency).
33
33
 
34
- 1. Pick a provider (numbered list): OpenAI, DeepSeek, xAI (Grok), Groq, Ollama (local).
35
- 2. Pick a model. First item is always **Auto (recommended)** — a cheap, fast Chat Completions model for summarizing a diff. Named picks stay pinned; Auto tracks our lightweight default.
36
- 3. Paste an API key (hidden). Skipped for Ollama.
34
+ | | `npm install -g @yourfam/yf-commit` | `npm install -D @yourfam/yf-commit` |
35
+ |---|---|---|
36
+ | Where it goes | Global npm prefix (your user/system) | `node_modules/` + `package.json` of the current repo |
37
+ | Command | `yf-commit` from any folder | `npx yf-commit` (or a script) **in that repo** |
38
+ | Other repos | Works | Not installed there |
39
+ | Git | Not committed | Listed in `package.json`; teammates get it with `npm install` |
40
+ | Typical use | A CLI you want everywhere | A tool this project uses in scripts/CI |
37
41
 
38
- Saved to `~/.yf-commit/config.json` (Windows: `%USERPROFILE%\.yf-commit\config.json`). Mode `0600` where the OS allows. This file lives in your home directory; never commit it.
42
+ For `yf-commit` as a daily command, use **-g**. Use **-D** only if this one repo should own the tool.
43
+
44
+ With **-D**, the binary lives in that repo’s `node_modules/.bin/`. Your shell PATH does not include that, so **plain `yf-commit` will not work**. From that repo:
39
45
 
40
46
  ```bash
41
- yf-commit init # wizard
42
- yf-commit init --show # provider, model, base URL, masked key
43
- yf-commit init --reset # delete saved config
47
+ npx yf-commit
44
48
  ```
45
49
 
46
- Primary env var: **`YF_COMMIT_API_KEY`**. You can also:
50
+ A `package.json` script also works, because npm puts `node_modules/.bin` on PATH **for the script**:
51
+
52
+ ```json
53
+ "scripts": {
54
+ "commit": "yf-commit"
55
+ }
56
+ ```
47
57
 
48
58
  ```bash
49
- export YF_COMMIT_API_KEY=...
59
+ npm run commit
50
60
  ```
51
61
 
52
- `OPENAI_API_KEY` is also accepted if the others are unset.
62
+ Plain `yf-commit` anywhere on the machine is only after **-g**.
63
+
64
+ No install at all (npm fetches and runs the published package):
53
65
 
54
- Need a host we don't list? Set `YF_COMMIT_BASE_URL` and `YF_COMMIT_MODEL`.
66
+ ```bash
67
+ npx @yourfam/yf-commit
68
+ ```
55
69
 
56
- | Env | Config key | Default |
70
+ ## First run
71
+
72
+ The first `yf-commit` with no key is setup.
73
+
74
+ 1. Provider: OpenAI, DeepSeek, xAI (Grok), Groq, or Ollama (local).
75
+ 2. Model: **Auto (recommended)**, or a named model.
76
+ 3. API key (hidden). Skipped for Ollama.
77
+
78
+ Saved to `~/.yf-commit/config.json` (Windows: `%USERPROFILE%\.yf-commit\config.json`). Never commit that file.
79
+
80
+ ```bash
81
+ yf-commit init # wizard
82
+ yf-commit init --show # masked status
83
+ yf-commit init --reset # delete config
84
+ ```
85
+
86
+ Or set **`YF_COMMIT_API_KEY`**. `OPENAI_API_KEY` is also accepted if the others are unset.
87
+
88
+ Need a host we don’t list? Set `YF_COMMIT_BASE_URL` and `YF_COMMIT_MODEL`.
89
+
90
+ | Env | Config | Default |
57
91
  |---|---|---|
58
92
  | `YF_COMMIT_API_KEY` | `apiKey` | — |
59
93
  | `YF_COMMIT_BASE_URL` | `baseUrl` | `https://api.openai.com/v1` |
60
- | `YF_COMMIT_MODEL` | `model` | `auto` → lightweight model for that provider |
94
+ | `YF_COMMIT_MODEL` | `model` | `auto` |
95
+
96
+ ## Use
97
+
98
+ Flags combine. Typical paths:
99
+
100
+ **You stage, then generate**
101
+
102
+ ```bash
103
+ git add path/to/file
104
+ yf-commit # print draft → confirm → git commit
105
+ yf-commit -y # same, skip confirm (also --yes, --auto)
106
+ ```
61
107
 
62
- ## Usage
108
+ **Skip staging — let yf-commit `git add -A`**
63
109
 
64
- Stage files, then:
110
+ `--all` runs `git add -A` first (tracked changes and untracked files, except ignored), then the same as above.
65
111
 
66
112
  ```bash
67
- yf-commit # print draft in the terminal → confirm → git commit
68
- yf-commit -y # no confirm (also --yes, --auto)
69
- yf-commit --print # print only; do not commit
70
- yf-commit --all # git add -A, then same as default
113
+ yf-commit --all # add everything print draft → confirm → commit
114
+ yf-commit --all -y # add everything → commit now (no confirm)
115
+ ```
116
+
117
+ **Other flags (mix with `--all` / `-y` as needed)**
118
+
119
+ ```bash
120
+ yf-commit --print # print only; do not commit (still needs a staged diff, or add --all)
121
+ yf-commit --all --print
71
122
  yf-commit --type fix # force type
72
123
  yf-commit --type 4 # same (1–6: chore, docs, feat, fix, refactor, test)
124
+ yf-commit --all -y --type feat
73
125
  ```
74
126
 
75
- Default: the draft is printed in the terminal. Press Enter or `y` to commit, `n` or Ctrl+C to cancel. It does not open an editor.
127
+ Default prints the draft in the terminal. Enter or `y` to commit, `n` or Ctrl+C to cancel. It does not open an editor.
76
128
 
77
- If nothing is staged: one-line error, exit non-zero. It will not `git add -A` unless you pass `--all`.
129
+ Nothing staged error, exit 1. No `git add` unless `--all`.
78
130
 
79
- Non-interactive (CI / scripts): pass `--print` or `-y`. It will not hang waiting for a paste or a confirm.
131
+ Scripts / CI: `--print` or `-y`. It will not wait for a paste or a confirm.
80
132
 
81
- ## Message format
133
+ ## Format
82
134
 
83
135
  ```
84
136
  ✨ feat(cli): add --print to skip git commit
85
137
 
86
138
  💡 WHY:
87
- - Friends can preview a message without committing
139
+ - Preview a message without committing
88
140
 
89
141
  🔧 WHAT CHANGED:
90
- - Added a --print flag that writes the draft to stdout and exits
142
+ - --print writes the draft to stdout and exits
91
143
 
92
144
  📁 FILES IMPACTED:
93
145
  - src/index.js
94
146
  - README.md
95
147
  ```
96
148
 
149
+ ## Development
150
+
151
+ This is the GitHub repo, not a second package. Docs and source live here; `npx` / `npm install` still install whatever version is **published on npm**.
152
+
153
+ ```bash
154
+ git clone https://github.com/YourFam/yf-commit.git
155
+ cd yf-commit
156
+ npm install
157
+ npm test
158
+ node ./bin/yf-commit.js --help
159
+ ```
160
+
161
+ Maintainer: YourFam (`kamal-yourfam` on npm). License MIT.
162
+
97
163
  ## License
98
164
 
99
165
  MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yourfam/yf-commit",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "AI commit message from your staged git diff",
5
5
  "type": "module",
6
6
  "bin": {
@@ -16,6 +16,7 @@
16
16
  "node": ">=20"
17
17
  },
18
18
  "scripts": {
19
+ "postinstall": "node ./src/postinstall-run.js",
19
20
  "test": "node --test test/*.test.js",
20
21
  "yf-commit": "node ./bin/yf-commit.js"
21
22
  },
@@ -25,7 +26,11 @@
25
26
  "conventional-commits",
26
27
  "cli"
27
28
  ],
28
- "author": "YourFam",
29
+ "author": {
30
+ "name": "YourFam",
31
+ "email": "kamal@yourfam.co",
32
+ "url": "https://github.com/YourFam"
33
+ },
29
34
  "license": "MIT",
30
35
  "repository": {
31
36
  "type": "git",
@@ -0,0 +1,7 @@
1
+ import { runPostinstall } from "./postinstall.js";
2
+
3
+ try {
4
+ runPostinstall();
5
+ } catch {
6
+ // Never fail install.
7
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Print a short hint after `npm install -g` only.
3
+ * Stay silent for -D, CI, npx, and repo `npm install`.
4
+ */
5
+ export function isGlobalNpmInstall(env = process.env) {
6
+ return env.npm_config_global === "true";
7
+ }
8
+
9
+ export function installHint() {
10
+ return `yf-commit installed. Run: yf-commit
11
+ First time: provider → model → API key
12
+ Docs: https://github.com/YourFam/yf-commit`;
13
+ }
14
+
15
+ export function runPostinstall(
16
+ env = process.env,
17
+ write = (s) => process.stderr.write(s),
18
+ ) {
19
+ if (!isGlobalNpmInstall(env)) return false;
20
+ write(`${installHint()}\n`);
21
+ return true;
22
+ }