@snelusha/noto 1.2.0 → 1.2.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 +1 -1
- package/dist/index.js +82 -20
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -154,7 +154,7 @@ noto branch delete --force # simply: noto branch delete -f
|
|
|
154
154
|
|
|
155
155
|
## Pro Tips
|
|
156
156
|
|
|
157
|
-
- 🚀 Get fast commits on the fly with `noto -
|
|
157
|
+
- 🚀 Get fast commits on the fly with `noto -a` to streamline your workflow!
|
|
158
158
|
|
|
159
159
|
## Contributing
|
|
160
160
|
|
package/dist/index.js
CHANGED
|
@@ -323,7 +323,7 @@ var getModel = async () => {
|
|
|
323
323
|
};
|
|
324
324
|
|
|
325
325
|
// src/ai/index.ts
|
|
326
|
-
var generateCommitMessage = async (diff, type) => {
|
|
326
|
+
var generateCommitMessage = async (diff, type, context) => {
|
|
327
327
|
const model2 = await getModel();
|
|
328
328
|
const { object } = await generateObject({
|
|
329
329
|
model: model2,
|
|
@@ -334,27 +334,65 @@ var generateCommitMessage = async (diff, type) => {
|
|
|
334
334
|
{
|
|
335
335
|
role: "system",
|
|
336
336
|
content: dedent3`
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
337
|
+
## Persona
|
|
338
|
+
You are a highly specialized AI assistant engineered for generating precise, standards-compliant Git commit messages. Your function is to serve as an automated tool ensuring consistency and clarity in version control history, adhering strictly to predefined formatting rules optimized for software development workflows.
|
|
339
|
+
|
|
340
|
+
## Core Objective
|
|
341
|
+
Your objective is to meticulously analyze provided code changes (diffs) and synthesize a Git commit message that strictly conforms to the specified output requirements. The focus is on accuracy, conciseness, and unwavering adherence to the format.
|
|
342
|
+
|
|
343
|
+
## Input Specification
|
|
344
|
+
The input provided by the user will be structured as follows:
|
|
345
|
+
|
|
346
|
+
1. **Optional Type Override:** A line indicating the desired commit type, formatted as:
|
|
347
|
+
\`USER_SPECIFIED_TYPE: <value>\`
|
|
348
|
+
* The \`<value>\` will either be one of the valid types (\`chore\`, \`feat\`, \`fix\`, \`docs\`, \`refactor\`, \`perf\`, \`test\) or the special keyword \`[none]\` if the user does not wish to force a specific type.
|
|
349
|
+
2. **Optional User Context:** A section providing supplementary information about the changes, formatted as:
|
|
350
|
+
\`USER_PROVIDED_CONTEXT:\`
|
|
351
|
+
\`{context_placeholder or [none]}\`
|
|
352
|
+
* This context (e.g., issue details, goal description) is optional. If provided, use it to better understand the *purpose* and *intent* behind the code changes. If not provided, the value will be \`[none]\`.
|
|
353
|
+
3. **Diff Content:** The raw diff output, typically generated by \`git diff --staged\`, encapsulated within triple backticks.
|
|
354
|
+
|
|
355
|
+
**You must parse the \`USER_SPECIFIED_TYPE:\` and \`USER_PROVIDED_CONTEXT:\` inputs before analyzing the diff.**
|
|
351
356
|
|
|
352
|
-
|
|
357
|
+
## Output Specification & Constraints (Mandatory Adherence)
|
|
358
|
+
Adherence to the following specifications is mandatory and non-negotiable. Any deviation constitutes an incorrect output.
|
|
359
|
+
|
|
360
|
+
1. **Commit Message Format:**
|
|
361
|
+
* The output MUST strictly follow the single-line format: \`<type>: <description>\`
|
|
362
|
+
* A single colon (\`:\`) followed by a single space MUST separate the \`<type>\` and \`<description>\`.
|
|
363
|
+
* Scopes within the type (e.g., \`feat(api):\`) are explicitly disallowed.
|
|
364
|
+
* Message bodies and footers are explicitly disallowed. The output MUST be exactly one line.
|
|
365
|
+
|
|
366
|
+
2. **Type (\`<type>\`) - Determination Logic:**
|
|
367
|
+
* **Priority 1: User-Specified Type:** Check the value provided on the \`USER_SPECIFIED_TYPE:\` line. If this value is exactly one of \`chore\`, \`feat\`, \`fix\`, \`docs\`, \`refactor\`, \`perf\`, \`test\`, then you **MUST** use this user-specified type.
|
|
368
|
+
* **Priority 2: Diff & Context Analysis (Default Behavior):** If the value on the \`USER_SPECIFIED_TYPE:\` line is \`[none]\` or invalid, you **MUST** select the \`<type>\` exclusively from the predefined vocabulary (\`chore\`, \`feat\`, \`fix\`, \`docs\`, \`refactor\`, \`perf\`, \`test\`). Base your selection on your analysis of the diff, **informed by the \`USER_PROVIDED_CONTEXT\`** if available, to accurately reflect the primary semantic purpose of the changes.
|
|
369
|
+
|
|
370
|
+
3. **Description (\`<description>\`):**
|
|
371
|
+
* **Tense:** MUST employ the imperative, present tense (e.g.,\`add\`, \`fix\`, \`update\`, \`implement\`, \`refactor\`, \`remove\`).
|
|
372
|
+
* **Content:** Must succinctly convey the core semantic change introduced by the diff.
|
|
373
|
+
* **Leverage Context:** If \`USER_PROVIDED_CONTEXT\` is available and not \`[none]\`, use it to **refine the description**, ensuring it reflects the *intent* and *purpose* behind the changes, while still accurately summarizing *what* was changed in the diff.
|
|
374
|
+
* **Focus:** Prioritize the most significant aspects of the change.
|
|
375
|
+
* **File Name Reference:** Inclusion of file names should be exceptional, reserved only for renaming operations or when essential for disambiguating the change's primary focus.
|
|
376
|
+
* **Case Sensitivity:** The entire output string, encompassing both \`<type>\` and \`<description>\`, MUST be rendered in lowercase.
|
|
377
|
+
* **Punctuation:** The description MUST NOT conclude with any terminal punctuation (e.g., no period/full stop).
|
|
378
|
+
* **Length Constraint:** The total character count of the generated commit message line MUST NOT exceed 72 characters. **The description must be concise enough to fit within this limit alongside the chosen type.**`
|
|
353
379
|
},
|
|
354
380
|
{
|
|
355
381
|
role: "user",
|
|
356
|
-
content: dedent3`
|
|
357
|
-
|
|
382
|
+
content: dedent3`
|
|
383
|
+
\`\`\`text
|
|
384
|
+
USER_SPECIFIED_TYPE: ${type ?? "[none]"}
|
|
385
|
+
|
|
386
|
+
USER_PROVIDED_CONTEXT:
|
|
387
|
+
${context ?? "[none]"}
|
|
388
|
+
\`\`\`
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
\`\`\`diff
|
|
393
|
+
${diff}
|
|
394
|
+
\`\`\`
|
|
395
|
+
`
|
|
358
396
|
}
|
|
359
397
|
]
|
|
360
398
|
});
|
|
@@ -386,6 +424,12 @@ var command = {
|
|
|
386
424
|
alias: "-t",
|
|
387
425
|
description: "generate commit message based on type"
|
|
388
426
|
},
|
|
427
|
+
{
|
|
428
|
+
type: String,
|
|
429
|
+
flag: "--message",
|
|
430
|
+
alias: "-m",
|
|
431
|
+
description: "provide context for the commit message"
|
|
432
|
+
},
|
|
389
433
|
{
|
|
390
434
|
type: Boolean,
|
|
391
435
|
flag: "--copy",
|
|
@@ -424,10 +468,28 @@ var command = {
|
|
|
424
468
|
} else if (typeof type === "string") {
|
|
425
469
|
options.type = type;
|
|
426
470
|
}
|
|
471
|
+
const context = options["--message"];
|
|
472
|
+
if (typeof context === "string") {
|
|
473
|
+
options.context = context;
|
|
474
|
+
} else if (typeof context === "boolean") {
|
|
475
|
+
const context2 = await p3.text({
|
|
476
|
+
message: "provide context for the commit message",
|
|
477
|
+
placeholder: "describe the changes"
|
|
478
|
+
});
|
|
479
|
+
if (p3.isCancel(context2)) {
|
|
480
|
+
p3.log.error(color3.red("nothing changed!"));
|
|
481
|
+
return await exit(1);
|
|
482
|
+
}
|
|
483
|
+
options.context = context2;
|
|
484
|
+
}
|
|
427
485
|
spin.start("generating commit message");
|
|
428
486
|
let message = null;
|
|
429
487
|
if (!await isFirstCommit()) {
|
|
430
|
-
message = await generateCommitMessage(
|
|
488
|
+
message = await generateCommitMessage(
|
|
489
|
+
diff,
|
|
490
|
+
options.type,
|
|
491
|
+
options.context
|
|
492
|
+
);
|
|
431
493
|
} else {
|
|
432
494
|
message = INIT_COMMIT_MESSAGE;
|
|
433
495
|
}
|
|
@@ -995,7 +1057,7 @@ var listCommand = () => {
|
|
|
995
1057
|
};
|
|
996
1058
|
|
|
997
1059
|
// package.json
|
|
998
|
-
var version = "1.2.
|
|
1060
|
+
var version = "1.2.1";
|
|
999
1061
|
|
|
1000
1062
|
// src/index.ts
|
|
1001
1063
|
var globalSpec = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@snelusha/noto",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Generate clean commit messages in a snap! ✨",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -49,10 +49,10 @@
|
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@ai-sdk/google": "^1.2.14",
|
|
51
51
|
"@clack/prompts": "^0.10.1",
|
|
52
|
-
"ai": "^4.3.
|
|
52
|
+
"ai": "^4.3.13",
|
|
53
53
|
"arg": "^5.0.2",
|
|
54
54
|
"clipboardy": "^4.0.0",
|
|
55
|
-
"dedent": "^1.
|
|
55
|
+
"dedent": "^1.6.0",
|
|
56
56
|
"picocolors": "^1.1.1",
|
|
57
57
|
"simple-git": "^3.27.0",
|
|
58
58
|
"tinyexec": "^0.3.2",
|