@snelusha/noto 0.3.3 → 0.3.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/README.md +1 -5
- package/dist/cli.cjs +25 -26
- package/dist/cli.mjs +23 -26
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
<h1 align="center">noto ✨</h1>
|
|
2
2
|
<p align="center"><sup>(/nōto/, <em>notebook</em> in Japanese)</sup></p>
|
|
3
|
-
<img src="https://github.com/snelusha/static/blob/main/noto/banner.png?raw=true" align="center"></img>
|
|
4
|
-
|
|
5
|
-
<pre align="center">
|
|
6
|
-
<p>npm install -g <b>@snelusha/noto</b></p>
|
|
7
|
-
</pre>
|
|
3
|
+
<img src="https://github.com/snelusha/static/blob/main/noto/banner-minimal.png?raw=true" align="center"></img>
|
|
8
4
|
|
|
9
5
|
## Features
|
|
10
6
|
|
package/dist/cli.cjs
CHANGED
|
@@ -12,9 +12,10 @@ const os = require('node:os');
|
|
|
12
12
|
const process$1 = require('node:process');
|
|
13
13
|
require('which');
|
|
14
14
|
const ora = require('ora');
|
|
15
|
-
const
|
|
15
|
+
const simpleGit = require('simple-git');
|
|
16
16
|
const ai = require('ai');
|
|
17
17
|
const zod = require('zod');
|
|
18
|
+
const dedent = require('dedent');
|
|
18
19
|
|
|
19
20
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
20
21
|
|
|
@@ -26,6 +27,8 @@ const clipboardy__default = /*#__PURE__*/_interopDefaultCompat(clipboardy);
|
|
|
26
27
|
const os__default = /*#__PURE__*/_interopDefaultCompat(os);
|
|
27
28
|
const process__default = /*#__PURE__*/_interopDefaultCompat(process$1);
|
|
28
29
|
const ora__default = /*#__PURE__*/_interopDefaultCompat(ora);
|
|
30
|
+
const simpleGit__default = /*#__PURE__*/_interopDefaultCompat(simpleGit);
|
|
31
|
+
const dedent__default = /*#__PURE__*/_interopDefaultCompat(dedent);
|
|
29
32
|
|
|
30
33
|
function getDefaultExportFromCjs (x) {
|
|
31
34
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
@@ -3225,21 +3228,24 @@ async function dump() {
|
|
|
3225
3228
|
}
|
|
3226
3229
|
}
|
|
3227
3230
|
|
|
3228
|
-
function isGitRepository(
|
|
3229
|
-
|
|
3231
|
+
async function isGitRepository() {
|
|
3232
|
+
try {
|
|
3233
|
+
return await simpleGit__default().checkIsRepo();
|
|
3234
|
+
} catch {
|
|
3235
|
+
return false;
|
|
3236
|
+
}
|
|
3230
3237
|
}
|
|
3231
3238
|
async function getStagedDiff() {
|
|
3232
3239
|
try {
|
|
3233
|
-
|
|
3234
|
-
return diff;
|
|
3240
|
+
return await simpleGit__default().diff(["--cached"]);
|
|
3235
3241
|
} catch {
|
|
3236
3242
|
return null;
|
|
3237
3243
|
}
|
|
3238
3244
|
}
|
|
3239
3245
|
async function commit(message) {
|
|
3240
3246
|
try {
|
|
3241
|
-
const result = await
|
|
3242
|
-
return
|
|
3247
|
+
const result = await simpleGit__default().commit(message);
|
|
3248
|
+
return result.summary.changes > 0;
|
|
3243
3249
|
} catch {
|
|
3244
3250
|
return false;
|
|
3245
3251
|
}
|
|
@@ -5002,7 +5008,7 @@ async function generateCommitMessage(diff) {
|
|
|
5002
5008
|
messages: [
|
|
5003
5009
|
{
|
|
5004
5010
|
role: "system",
|
|
5005
|
-
content: `
|
|
5011
|
+
content: dedent__default`
|
|
5006
5012
|
You are a state-of-the-art AI model tasked with generating a precise Git commit message based on staged changes.
|
|
5007
5013
|
Adhere strictly to the following instructions, ranked by priority:
|
|
5008
5014
|
|
|
@@ -5018,15 +5024,14 @@ async function generateCommitMessage(diff) {
|
|
|
5018
5024
|
},
|
|
5019
5025
|
{
|
|
5020
5026
|
role: "user",
|
|
5021
|
-
content: `generate a commit message for the following staged changes
|
|
5022
|
-
${diff}`
|
|
5027
|
+
content: dedent__default`generate a commit message for the following staged changes:\n${diff}`
|
|
5023
5028
|
}
|
|
5024
5029
|
]
|
|
5025
5030
|
});
|
|
5026
5031
|
return object.message.trim();
|
|
5027
5032
|
}
|
|
5028
5033
|
|
|
5029
|
-
const version = "0.3.
|
|
5034
|
+
const version = "0.3.5";
|
|
5030
5035
|
|
|
5031
5036
|
yargs__default(helpers.hideBin(process.argv)).scriptName("noto").usage("$0 [args]").command(
|
|
5032
5037
|
"config",
|
|
@@ -5052,7 +5057,7 @@ yargs__default(helpers.hideBin(process.argv)).scriptName("noto").usage("$0 [args
|
|
|
5052
5057
|
c__default.bold("`noto`")
|
|
5053
5058
|
)} to generate your commit message!`
|
|
5054
5059
|
);
|
|
5055
|
-
|
|
5060
|
+
process.exit(0);
|
|
5056
5061
|
}
|
|
5057
5062
|
}
|
|
5058
5063
|
const response = await prompts({
|
|
@@ -5063,8 +5068,8 @@ yargs__default(helpers.hideBin(process.argv)).scriptName("noto").usage("$0 [args
|
|
|
5063
5068
|
});
|
|
5064
5069
|
if (response.apiKey) {
|
|
5065
5070
|
storage.apiKey = response.apiKey;
|
|
5066
|
-
dump();
|
|
5067
|
-
console.log("API key
|
|
5071
|
+
await dump();
|
|
5072
|
+
console.log("API key configured successfully!");
|
|
5068
5073
|
console.log(
|
|
5069
5074
|
`Use ${c__default.greenBright(
|
|
5070
5075
|
c__default.bold("`noto`")
|
|
@@ -5100,16 +5105,13 @@ yargs__default(helpers.hideBin(process.argv)).scriptName("noto").usage("$0 [args
|
|
|
5100
5105
|
process.exit(1);
|
|
5101
5106
|
}
|
|
5102
5107
|
const message = storage.lastGeneratedMessage;
|
|
5103
|
-
const copy = args.copy;
|
|
5104
|
-
const apply = args.apply;
|
|
5105
5108
|
spin.success(`Previous Commit Message: ${c__default.dim(c__default.bold(message))}`);
|
|
5106
|
-
if (copy) {
|
|
5109
|
+
if (args.copy) {
|
|
5107
5110
|
clipboardy__default.writeSync(message);
|
|
5108
5111
|
spin.success("Message copied to clipboard!");
|
|
5109
5112
|
}
|
|
5110
|
-
if (apply) {
|
|
5111
|
-
|
|
5112
|
-
if (!isGitRepository(cwd)) {
|
|
5113
|
+
if (args.apply) {
|
|
5114
|
+
if (!await isGitRepository()) {
|
|
5113
5115
|
console.log(
|
|
5114
5116
|
c__default.red("Oops! No Git repository found in the current directory.")
|
|
5115
5117
|
);
|
|
@@ -5164,8 +5166,7 @@ yargs__default(helpers.hideBin(process.argv)).scriptName("noto").usage("$0 [args
|
|
|
5164
5166
|
);
|
|
5165
5167
|
process.exit(1);
|
|
5166
5168
|
}
|
|
5167
|
-
|
|
5168
|
-
if (!isGitRepository(cwd)) {
|
|
5169
|
+
if (!await isGitRepository()) {
|
|
5169
5170
|
console.log(
|
|
5170
5171
|
c__default.red("Oops! No Git repository found in the current directory.")
|
|
5171
5172
|
);
|
|
@@ -5194,14 +5195,12 @@ yargs__default(helpers.hideBin(process.argv)).scriptName("noto").usage("$0 [args
|
|
|
5194
5195
|
const message = await generateCommitMessage(diff);
|
|
5195
5196
|
storage.lastGeneratedMessage = message;
|
|
5196
5197
|
await dump();
|
|
5197
|
-
const copy = args.copy;
|
|
5198
|
-
const apply = args.apply;
|
|
5199
5198
|
spin.success(`Commit Message: ${c__default.dim(c__default.bold(message))}`);
|
|
5200
|
-
if (copy) {
|
|
5199
|
+
if (args.copy) {
|
|
5201
5200
|
clipboardy__default.writeSync(message);
|
|
5202
5201
|
spin.success("Message copied to clipboard!");
|
|
5203
5202
|
}
|
|
5204
|
-
if (apply) {
|
|
5203
|
+
if (args.apply) {
|
|
5205
5204
|
if (!await commit(message)) {
|
|
5206
5205
|
spin.fail("Failed to commit staged changes.");
|
|
5207
5206
|
process.exit(1);
|
package/dist/cli.mjs
CHANGED
|
@@ -10,9 +10,10 @@ import os from 'node:os';
|
|
|
10
10
|
import process$1 from 'node:process';
|
|
11
11
|
import 'which';
|
|
12
12
|
import ora from 'ora';
|
|
13
|
-
import
|
|
13
|
+
import simpleGit from 'simple-git';
|
|
14
14
|
import { generateObject } from 'ai';
|
|
15
15
|
import { z } from 'zod';
|
|
16
|
+
import dedent from 'dedent';
|
|
16
17
|
|
|
17
18
|
function getDefaultExportFromCjs (x) {
|
|
18
19
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
@@ -3212,21 +3213,24 @@ async function dump() {
|
|
|
3212
3213
|
}
|
|
3213
3214
|
}
|
|
3214
3215
|
|
|
3215
|
-
function isGitRepository(
|
|
3216
|
-
|
|
3216
|
+
async function isGitRepository() {
|
|
3217
|
+
try {
|
|
3218
|
+
return await simpleGit().checkIsRepo();
|
|
3219
|
+
} catch {
|
|
3220
|
+
return false;
|
|
3221
|
+
}
|
|
3217
3222
|
}
|
|
3218
3223
|
async function getStagedDiff() {
|
|
3219
3224
|
try {
|
|
3220
|
-
|
|
3221
|
-
return diff;
|
|
3225
|
+
return await simpleGit().diff(["--cached"]);
|
|
3222
3226
|
} catch {
|
|
3223
3227
|
return null;
|
|
3224
3228
|
}
|
|
3225
3229
|
}
|
|
3226
3230
|
async function commit(message) {
|
|
3227
3231
|
try {
|
|
3228
|
-
const result = await
|
|
3229
|
-
return
|
|
3232
|
+
const result = await simpleGit().commit(message);
|
|
3233
|
+
return result.summary.changes > 0;
|
|
3230
3234
|
} catch {
|
|
3231
3235
|
return false;
|
|
3232
3236
|
}
|
|
@@ -4989,7 +4993,7 @@ async function generateCommitMessage(diff) {
|
|
|
4989
4993
|
messages: [
|
|
4990
4994
|
{
|
|
4991
4995
|
role: "system",
|
|
4992
|
-
content: `
|
|
4996
|
+
content: dedent`
|
|
4993
4997
|
You are a state-of-the-art AI model tasked with generating a precise Git commit message based on staged changes.
|
|
4994
4998
|
Adhere strictly to the following instructions, ranked by priority:
|
|
4995
4999
|
|
|
@@ -5005,15 +5009,14 @@ async function generateCommitMessage(diff) {
|
|
|
5005
5009
|
},
|
|
5006
5010
|
{
|
|
5007
5011
|
role: "user",
|
|
5008
|
-
content: `generate a commit message for the following staged changes
|
|
5009
|
-
${diff}`
|
|
5012
|
+
content: dedent`generate a commit message for the following staged changes:\n${diff}`
|
|
5010
5013
|
}
|
|
5011
5014
|
]
|
|
5012
5015
|
});
|
|
5013
5016
|
return object.message.trim();
|
|
5014
5017
|
}
|
|
5015
5018
|
|
|
5016
|
-
const version = "0.3.
|
|
5019
|
+
const version = "0.3.5";
|
|
5017
5020
|
|
|
5018
5021
|
yargs(hideBin(process.argv)).scriptName("noto").usage("$0 [args]").command(
|
|
5019
5022
|
"config",
|
|
@@ -5039,7 +5042,7 @@ yargs(hideBin(process.argv)).scriptName("noto").usage("$0 [args]").command(
|
|
|
5039
5042
|
c.bold("`noto`")
|
|
5040
5043
|
)} to generate your commit message!`
|
|
5041
5044
|
);
|
|
5042
|
-
|
|
5045
|
+
process.exit(0);
|
|
5043
5046
|
}
|
|
5044
5047
|
}
|
|
5045
5048
|
const response = await prompts({
|
|
@@ -5050,8 +5053,8 @@ yargs(hideBin(process.argv)).scriptName("noto").usage("$0 [args]").command(
|
|
|
5050
5053
|
});
|
|
5051
5054
|
if (response.apiKey) {
|
|
5052
5055
|
storage.apiKey = response.apiKey;
|
|
5053
|
-
dump();
|
|
5054
|
-
console.log("API key
|
|
5056
|
+
await dump();
|
|
5057
|
+
console.log("API key configured successfully!");
|
|
5055
5058
|
console.log(
|
|
5056
5059
|
`Use ${c.greenBright(
|
|
5057
5060
|
c.bold("`noto`")
|
|
@@ -5087,16 +5090,13 @@ yargs(hideBin(process.argv)).scriptName("noto").usage("$0 [args]").command(
|
|
|
5087
5090
|
process.exit(1);
|
|
5088
5091
|
}
|
|
5089
5092
|
const message = storage.lastGeneratedMessage;
|
|
5090
|
-
const copy = args.copy;
|
|
5091
|
-
const apply = args.apply;
|
|
5092
5093
|
spin.success(`Previous Commit Message: ${c.dim(c.bold(message))}`);
|
|
5093
|
-
if (copy) {
|
|
5094
|
+
if (args.copy) {
|
|
5094
5095
|
clipboardy.writeSync(message);
|
|
5095
5096
|
spin.success("Message copied to clipboard!");
|
|
5096
5097
|
}
|
|
5097
|
-
if (apply) {
|
|
5098
|
-
|
|
5099
|
-
if (!isGitRepository(cwd)) {
|
|
5098
|
+
if (args.apply) {
|
|
5099
|
+
if (!await isGitRepository()) {
|
|
5100
5100
|
console.log(
|
|
5101
5101
|
c.red("Oops! No Git repository found in the current directory.")
|
|
5102
5102
|
);
|
|
@@ -5151,8 +5151,7 @@ yargs(hideBin(process.argv)).scriptName("noto").usage("$0 [args]").command(
|
|
|
5151
5151
|
);
|
|
5152
5152
|
process.exit(1);
|
|
5153
5153
|
}
|
|
5154
|
-
|
|
5155
|
-
if (!isGitRepository(cwd)) {
|
|
5154
|
+
if (!await isGitRepository()) {
|
|
5156
5155
|
console.log(
|
|
5157
5156
|
c.red("Oops! No Git repository found in the current directory.")
|
|
5158
5157
|
);
|
|
@@ -5181,14 +5180,12 @@ yargs(hideBin(process.argv)).scriptName("noto").usage("$0 [args]").command(
|
|
|
5181
5180
|
const message = await generateCommitMessage(diff);
|
|
5182
5181
|
storage.lastGeneratedMessage = message;
|
|
5183
5182
|
await dump();
|
|
5184
|
-
const copy = args.copy;
|
|
5185
|
-
const apply = args.apply;
|
|
5186
5183
|
spin.success(`Commit Message: ${c.dim(c.bold(message))}`);
|
|
5187
|
-
if (copy) {
|
|
5184
|
+
if (args.copy) {
|
|
5188
5185
|
clipboardy.writeSync(message);
|
|
5189
5186
|
spin.success("Message copied to clipboard!");
|
|
5190
5187
|
}
|
|
5191
|
-
if (apply) {
|
|
5188
|
+
if (args.apply) {
|
|
5192
5189
|
if (!await commit(message)) {
|
|
5193
5190
|
spin.fail("Failed to commit staged changes.");
|
|
5194
5191
|
process.exit(1);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@snelusha/noto",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.5",
|
|
5
5
|
"description": "generate clean commit messages in a snap! ✨",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": {
|
|
@@ -43,12 +43,13 @@
|
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@ai-sdk/google": "^1.0.12",
|
|
45
45
|
"@posva/prompts": "^2.4.4",
|
|
46
|
-
"ai": "^4.0.
|
|
46
|
+
"ai": "^4.0.26",
|
|
47
47
|
"clipboardy": "^4.0.0",
|
|
48
|
+
"dedent": "^1.5.3",
|
|
48
49
|
"ora": "^8.1.1",
|
|
49
50
|
"picocolors": "^1.1.1",
|
|
50
|
-
"
|
|
51
|
-
"unbuild": "^3.0
|
|
51
|
+
"simple-git": "^3.27.0",
|
|
52
|
+
"unbuild": "^3.2.0",
|
|
52
53
|
"which": "^5.0.0",
|
|
53
54
|
"yargs": "^17.7.2",
|
|
54
55
|
"zod": "^3.24.1"
|