@snelusha/noto 1.2.7 → 1.2.9

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/index.d.ts CHANGED
@@ -1,2 +0,0 @@
1
-
2
- export { }
package/dist/index.js CHANGED
@@ -12,21 +12,19 @@ var parse = (schema, raw) => {
12
12
  };
13
13
  };
14
14
  var safeParse = (schema, raw) => {
15
- let current2 = { ...schema };
15
+ let current = { ...schema };
16
16
  let iterations = 0;
17
- const maxIterations = Object.keys(current2).filter(
18
- (key2) => current2[key2] === String
19
- ).length;
17
+ const maxIterations = Object.keys(current).filter((key) => current[key] === String).length;
20
18
  while (iterations++ < maxIterations) {
21
19
  try {
22
- return parse(current2, raw);
20
+ return parse(current, raw);
23
21
  } catch (error) {
24
22
  if (error.code === "ARG_MISSING_REQUIRED_LONGARG") {
25
23
  const match = error.message.match(/(--\w[\w-]*)/);
26
24
  if (match) {
27
25
  const missingFlag = match[0];
28
- if (current2[missingFlag] === String) {
29
- current2[missingFlag] = Boolean;
26
+ if (current[missingFlag] === String) {
27
+ current[missingFlag] = Boolean;
30
28
  continue;
31
29
  }
32
30
  }
@@ -34,7 +32,7 @@ var safeParse = (schema, raw) => {
34
32
  throw error;
35
33
  }
36
34
  }
37
- return parse(current2, raw);
35
+ return parse(current, raw);
38
36
  };
39
37
 
40
38
  // src/commands/noto.ts
@@ -77,11 +75,9 @@ var StorageSchema = z2.object({
77
75
  }).optional(),
78
76
  lastGeneratedMessage: z2.string().optional()
79
77
  });
80
- var StorageManager = class {
81
- static storagePath = resolve(
82
- join(os.homedir(), ".noto"),
83
- "storage.sithi"
84
- );
78
+
79
+ class StorageManager {
80
+ static storagePath = resolve(join(os.homedir(), ".noto"), "storage.sithi");
85
81
  static storage = {};
86
82
  static async load() {
87
83
  try {
@@ -89,8 +85,10 @@ var StorageManager = class {
89
85
  const data = await fs.readFile(this.storagePath, "utf-8");
90
86
  const json = data ? JSON.parse(data) : {};
91
87
  const result = StorageSchema.safeParse(json);
92
- if (!result.success) this.storage = {};
93
- else this.storage = result.data;
88
+ if (!result.success)
89
+ this.storage = {};
90
+ else
91
+ this.storage = result.data;
94
92
  } catch {
95
93
  this.storage = {};
96
94
  }
@@ -102,18 +100,17 @@ var StorageManager = class {
102
100
  await fs.mkdir(directory, { recursive: true });
103
101
  const data = JSON.stringify(this.storage, null, 2);
104
102
  await fs.writeFile(this.storagePath, data, "utf-8");
105
- } catch {
106
- }
103
+ } catch {}
107
104
  }
108
105
  static async update(updater) {
109
106
  try {
110
107
  const updatedStorage = await updater(this.storage);
111
108
  const result = StorageSchema.safeParse(updatedStorage);
112
- if (!result.success) return this.storage;
109
+ if (!result.success)
110
+ return this.storage;
113
111
  this.storage = result.data;
114
112
  await this.save();
115
- } catch {
116
- }
113
+ } catch {}
117
114
  return this.storage;
118
115
  }
119
116
  static async get() {
@@ -124,7 +121,7 @@ var StorageManager = class {
124
121
  this.storage = {};
125
122
  await this.save();
126
123
  }
127
- };
124
+ }
128
125
 
129
126
  // src/utils/process.ts
130
127
  var exit = async (code) => {
@@ -139,10 +136,8 @@ var withAuth = (fn, options = { enabled: true }) => {
139
136
  const storage = await StorageManager.get();
140
137
  const apiKey = process.env.NOTO_API_KEY || storage.llm?.apiKey;
141
138
  if (!apiKey && options.enabled) {
142
- p.log.error(
143
- dedent`${color.red("noto api key is missing.")}
144
- ${color.dim(`run ${color.cyan("`noto config key`")} to set it up.`)}`
145
- );
139
+ p.log.error(dedent`${color.red("noto api key is missing.")}
140
+ ${color.dim(`run ${color.cyan("`noto config key`")} to set it up.`)}`);
146
141
  return await exit(1);
147
142
  }
148
143
  return fn(opts);
@@ -168,7 +163,8 @@ var getCommitCount = async () => {
168
163
  } catch (error) {
169
164
  const message = error.message;
170
165
  const regex = /(ambiguous argument.*HEAD|unknown revision or path.*HEAD)/;
171
- if (regex.test(message)) return 0;
166
+ if (regex.test(message))
167
+ return 0;
172
168
  throw error;
173
169
  }
174
170
  };
@@ -185,10 +181,10 @@ var getStagedDiff = async () => {
185
181
  };
186
182
  var commit = async (message, amend) => {
187
183
  try {
188
- const options = amend ? { "--amend": null } : void 0;
184
+ const options = amend ? { "--amend": null } : undefined;
189
185
  const {
190
186
  summary: { changes }
191
- } = await git.commit(message, void 0, options);
187
+ } = await git.commit(message, undefined, options);
192
188
  return Boolean(changes);
193
189
  } catch {
194
190
  return false;
@@ -248,20 +244,16 @@ var withRepository = (fn, options = { enabled: true }) => {
248
244
  return async (opts) => {
249
245
  const isRepo = await isGitRepository();
250
246
  if (!isRepo && options.enabled) {
251
- p2.log.error(
252
- dedent2`${color2.red("no git repository found in cwd.")}
253
- ${color2.dim(`run ${color2.cyan("`git init`")} to initialize a new repository.`)}`
254
- );
247
+ p2.log.error(dedent2`${color2.red("no git repository found in cwd.")}
248
+ ${color2.dim(`run ${color2.cyan("`git init`")} to initialize a new repository.`)}`);
255
249
  return await exit(1);
256
250
  }
257
251
  opts.isRepo = isRepo;
258
252
  if (isRepo) {
259
253
  const diff = await getStagedDiff();
260
254
  if (!diff && options.enabled) {
261
- p2.log.error(
262
- dedent2`${color2.red("no staged changes found.")}
263
- ${color2.dim(`run ${color2.cyan("`git add <file>`")} or ${color2.cyan("`git add .`")} to stage changes.`)}`
264
- );
255
+ p2.log.error(dedent2`${color2.red("no staged changes found.")}
256
+ ${color2.dim(`run ${color2.cyan("`git add <file>`")} or ${color2.cyan("`git add .`")} to stage changes.`)}`);
265
257
  return await exit(1);
266
258
  }
267
259
  opts.diff = diff;
@@ -290,33 +282,31 @@ var models = {
290
282
  "gemini-1.5-pro-latest": google("gemini-1.5-pro-latest"),
291
283
  "gemini-2.0-flash-001": google("gemini-2.0-flash-001"),
292
284
  "gemini-2.0-flash": google("gemini-2.0-flash"),
293
- "gemini-2.0-flash-lite-preview-02-05": google(
294
- "gemini-2.0-flash-lite-preview-02-05"
295
- ),
285
+ "gemini-2.0-flash-lite-preview-02-05": google("gemini-2.0-flash-lite-preview-02-05"),
296
286
  "gemini-2.5-flash-preview-04-17": google("gemini-2.5-flash-preview-04-17"),
297
287
  "gemini-2.5-pro-preview-05-06": google("gemini-2.5-pro-preview-05-06")
298
288
  };
299
289
  var availableModels = Object.keys(models);
300
290
  var getModel = async () => {
301
- let model2 = (await StorageManager.get()).llm?.model;
302
- if (!model2 || !availableModels.includes(model2)) {
303
- model2 = defaultModel;
304
- await StorageManager.update((current2) => ({
305
- ...current2,
291
+ let model = (await StorageManager.get()).llm?.model;
292
+ if (!model || !availableModels.includes(model)) {
293
+ model = defaultModel;
294
+ await StorageManager.update((current) => ({
295
+ ...current,
306
296
  llm: {
307
- ...current2.llm,
297
+ ...current.llm,
308
298
  model: defaultModel
309
299
  }
310
300
  }));
311
301
  }
312
- return models[model2];
302
+ return models[model];
313
303
  };
314
304
 
315
305
  // src/ai/index.ts
316
306
  var generateCommitMessage = async (diff, type, context) => {
317
- const model2 = await getModel();
307
+ const model = await getModel();
318
308
  const { object } = await generateObject({
319
- model: model2,
309
+ model,
320
310
  schema: z3.object({
321
311
  message: z3.string()
322
312
  }),
@@ -434,95 +424,119 @@ var command = {
434
424
  flag: "--push",
435
425
  alias: "-p",
436
426
  description: "commit and push the changes"
427
+ },
428
+ {
429
+ type: Boolean,
430
+ flag: "--manual",
431
+ description: "commit and push the changes"
437
432
  }
438
433
  ],
439
- execute: withAuth(
440
- withRepository(async (options) => {
441
- const spin = p3.spinner();
442
- try {
443
- const { diff } = options;
444
- const type = options["--type"];
445
- if (typeof type === "string" && !availableTypes.includes(type) || typeof type === "boolean") {
446
- const type2 = await p3.select({
447
- message: "select the type of commit message",
448
- options: commitTypeOptions
449
- });
450
- if (p3.isCancel(type2)) {
451
- p3.log.error(color3.red("nothing selected!"));
452
- return await exit(1);
453
- }
454
- options.type = type2;
455
- } else if (typeof type === "string") {
456
- options.type = type;
457
- }
458
- const context = options["--message"];
459
- if (typeof context === "string") {
460
- options.context = context;
461
- } else if (typeof context === "boolean") {
462
- const context2 = await p3.text({
463
- message: "provide context for the commit message",
464
- placeholder: "describe the changes"
465
- });
466
- if (p3.isCancel(context2)) {
467
- p3.log.error(color3.red("nothing changed!"));
468
- return await exit(1);
469
- }
470
- options.context = context2;
471
- }
472
- spin.start("generating commit message");
473
- let message = null;
474
- if (!await isFirstCommit()) {
475
- message = await generateCommitMessage(
476
- diff,
477
- options.type,
478
- options.context
479
- );
480
- } else {
481
- message = INIT_COMMIT_MESSAGE;
482
- }
483
- spin.stop(color3.white(message));
484
- const editedMessage = await p3.text({
434
+ execute: withAuth(withRepository(async (options) => {
435
+ const spin = p3.spinner();
436
+ try {
437
+ const { diff } = options;
438
+ const manual = options["--manual"];
439
+ if (manual) {
440
+ const message2 = await p3.text({
485
441
  message: "edit the generated commit message",
486
- initialValue: message,
487
- placeholder: message
442
+ placeholder: "chore: init repo"
488
443
  });
489
- if (p3.isCancel(editedMessage)) {
444
+ if (p3.isCancel(message2)) {
490
445
  p3.log.error(color3.red("nothing changed!"));
491
446
  return await exit(1);
492
447
  }
493
- message = editedMessage;
494
- p3.log.step(color3.green(message));
495
- await StorageManager.update((current2) => ({
496
- ...current2,
497
- lastGeneratedMessage: message
448
+ p3.log.step(color3.green(message2));
449
+ await StorageManager.update((current) => ({
450
+ ...current,
451
+ lastGeneratedMessage: message2
498
452
  }));
499
- if (options["--copy"]) {
500
- clipboard.writeSync(message);
501
- p3.log.step(color3.dim("copied commit message to clipboard"));
502
- }
503
453
  if (options["--apply"]) {
504
- const success = await commit(message);
454
+ const success = await commit(message2);
505
455
  if (success) {
506
456
  p3.log.step(color3.dim("commit successful"));
507
457
  } else {
508
458
  p3.log.error(color3.red("failed to commit changes"));
509
459
  }
510
460
  }
511
- if (options["--push"]) {
512
- const success = await push();
513
- if (success) {
514
- p3.log.step(color3.dim("push successful"));
515
- } else {
516
- p3.log.error(color3.red("failed to push changes"));
517
- }
518
- }
519
461
  return await exit(0);
520
- } catch {
521
- spin.stop(color3.red("failed to generate commit message"), 1);
462
+ }
463
+ const type = options["--type"];
464
+ if (typeof type === "string" && !availableTypes.includes(type) || typeof type === "boolean") {
465
+ const type2 = await p3.select({
466
+ message: "select the type of commit message",
467
+ options: commitTypeOptions
468
+ });
469
+ if (p3.isCancel(type2)) {
470
+ p3.log.error(color3.red("nothing selected!"));
471
+ return await exit(1);
472
+ }
473
+ options.type = type2;
474
+ } else if (typeof type === "string") {
475
+ options.type = type;
476
+ }
477
+ const context = options["--message"];
478
+ if (typeof context === "string") {
479
+ options.context = context;
480
+ } else if (typeof context === "boolean") {
481
+ const context2 = await p3.text({
482
+ message: "provide context for the commit message",
483
+ placeholder: "describe the changes"
484
+ });
485
+ if (p3.isCancel(context2)) {
486
+ p3.log.error(color3.red("nothing changed!"));
487
+ return await exit(1);
488
+ }
489
+ options.context = context2;
490
+ }
491
+ spin.start("generating commit message");
492
+ let message = null;
493
+ if (!await isFirstCommit()) {
494
+ message = await generateCommitMessage(diff, options.type, options.context);
495
+ } else {
496
+ message = INIT_COMMIT_MESSAGE;
497
+ }
498
+ spin.stop(color3.white(message));
499
+ const editedMessage = await p3.text({
500
+ message: "edit the generated commit message",
501
+ initialValue: message,
502
+ placeholder: message
503
+ });
504
+ if (p3.isCancel(editedMessage)) {
505
+ p3.log.error(color3.red("nothing changed!"));
522
506
  return await exit(1);
523
507
  }
524
- })
525
- )
508
+ message = editedMessage;
509
+ p3.log.step(color3.green(message));
510
+ await StorageManager.update((current) => ({
511
+ ...current,
512
+ lastGeneratedMessage: message
513
+ }));
514
+ if (options["--copy"]) {
515
+ clipboard.writeSync(message);
516
+ p3.log.step(color3.dim("copied commit message to clipboard"));
517
+ }
518
+ if (options["--apply"]) {
519
+ const success = await commit(message);
520
+ if (success) {
521
+ p3.log.step(color3.dim("commit successful"));
522
+ } else {
523
+ p3.log.error(color3.red("failed to commit changes"));
524
+ }
525
+ }
526
+ if (options["--push"]) {
527
+ const success = await push();
528
+ if (success) {
529
+ p3.log.step(color3.dim("push successful"));
530
+ } else {
531
+ p3.log.error(color3.red("failed to push changes"));
532
+ }
533
+ }
534
+ return await exit(0);
535
+ } catch {
536
+ spin.stop(color3.red("failed to generate commit message"), 1);
537
+ return await exit(1);
538
+ }
539
+ }))
526
540
  };
527
541
  var noto_default = command;
528
542
 
@@ -560,75 +574,60 @@ var command2 = {
560
574
  description: "amend the last commit with the last generated message"
561
575
  }
562
576
  ],
563
- execute: withAuth(
564
- withRepository(
565
- async (options) => {
566
- let lastGeneratedMessage = (await StorageManager.get()).lastGeneratedMessage;
567
- if (!lastGeneratedMessage) {
568
- p4.log.error(color4.red("no previous commit message found"));
569
- return await exit(1);
570
- }
571
- const isEditMode = options["--edit"];
572
- const isAmend = options["--amend"];
573
- if (isAmend && !isEditMode) {
574
- p4.log.error(
575
- color4.red("the --amend option requires the --edit option")
576
- );
577
- return await exit(1);
578
- }
579
- p4.log.step(
580
- isEditMode ? color4.white(lastGeneratedMessage) : color4.green(lastGeneratedMessage)
581
- );
582
- if (options["--edit"]) {
583
- const editedMessage = await p4.text({
584
- message: "edit the last generated commit message",
585
- initialValue: lastGeneratedMessage,
586
- placeholder: lastGeneratedMessage
587
- });
588
- if (p4.isCancel(editedMessage)) {
589
- p4.log.error(color4.red("nothing changed!"));
590
- return await exit(1);
591
- }
592
- lastGeneratedMessage = editedMessage;
593
- await StorageManager.update((current2) => ({
594
- ...current2,
595
- lastGeneratedMessage: editedMessage
596
- }));
597
- p4.log.step(color4.green(lastGeneratedMessage));
598
- }
599
- if (options["--copy"]) {
600
- clipboard2.writeSync(lastGeneratedMessage);
601
- p4.log.step(
602
- color4.dim("copied last generated commit message to clipboard")
603
- );
604
- }
605
- if (options["--apply"] || isAmend) {
606
- if (!options.isRepo) {
607
- p4.log.error(
608
- dedent4`${color4.red("no git repository found in cwd.")}
609
- ${color4.dim(`run ${color4.cyan("`git init`")} to initialize a new repository.`)}`
610
- );
611
- return await exit(1);
612
- }
613
- if (!options.diff && !isAmend) {
614
- p4.log.error(
615
- dedent4`${color4.red("no staged changes found.")}
616
- ${color4.dim(`run ${color4.cyan("`git add <file>`")} or ${color4.cyan("`git add .`")} to stage changes.`)}`
617
- );
618
- return await exit(1);
619
- }
620
- const success = await commit(lastGeneratedMessage, isAmend);
621
- if (success) {
622
- p4.log.step(color4.dim("commit successful"));
623
- } else {
624
- p4.log.error(color4.red("failed to commit changes"));
625
- }
626
- }
627
- return await exit(0);
628
- },
629
- { enabled: false }
630
- )
631
- )
577
+ execute: withAuth(withRepository(async (options) => {
578
+ let lastGeneratedMessage = (await StorageManager.get()).lastGeneratedMessage;
579
+ if (!lastGeneratedMessage) {
580
+ p4.log.error(color4.red("no previous commit message found"));
581
+ return await exit(1);
582
+ }
583
+ const isEditMode = options["--edit"];
584
+ const isAmend = options["--amend"];
585
+ if (isAmend && !isEditMode) {
586
+ p4.log.error(color4.red("the --amend option requires the --edit option"));
587
+ return await exit(1);
588
+ }
589
+ p4.log.step(isEditMode ? color4.white(lastGeneratedMessage) : color4.green(lastGeneratedMessage));
590
+ if (options["--edit"]) {
591
+ const editedMessage = await p4.text({
592
+ message: "edit the last generated commit message",
593
+ initialValue: lastGeneratedMessage,
594
+ placeholder: lastGeneratedMessage
595
+ });
596
+ if (p4.isCancel(editedMessage)) {
597
+ p4.log.error(color4.red("nothing changed!"));
598
+ return await exit(1);
599
+ }
600
+ lastGeneratedMessage = editedMessage;
601
+ await StorageManager.update((current) => ({
602
+ ...current,
603
+ lastGeneratedMessage: editedMessage
604
+ }));
605
+ p4.log.step(color4.green(lastGeneratedMessage));
606
+ }
607
+ if (options["--copy"]) {
608
+ clipboard2.writeSync(lastGeneratedMessage);
609
+ p4.log.step(color4.dim("copied last generated commit message to clipboard"));
610
+ }
611
+ if (options["--apply"] || isAmend) {
612
+ if (!options.isRepo) {
613
+ p4.log.error(dedent4`${color4.red("no git repository found in cwd.")}
614
+ ${color4.dim(`run ${color4.cyan("`git init`")} to initialize a new repository.`)}`);
615
+ return await exit(1);
616
+ }
617
+ if (!options.diff && !isAmend) {
618
+ p4.log.error(dedent4`${color4.red("no staged changes found.")}
619
+ ${color4.dim(`run ${color4.cyan("`git add <file>`")} or ${color4.cyan("`git add .`")} to stage changes.`)}`);
620
+ return await exit(1);
621
+ }
622
+ const success = await commit(lastGeneratedMessage, isAmend);
623
+ if (success) {
624
+ p4.log.step(color4.dim("commit successful"));
625
+ } else {
626
+ p4.log.error(color4.red("failed to commit changes"));
627
+ }
628
+ }
629
+ return await exit(0);
630
+ }, { enabled: false }))
632
631
  };
633
632
  var prev_default = command2;
634
633
 
@@ -649,29 +648,24 @@ var current = {
649
648
  description: "copy the selected branch to clipboard"
650
649
  }
651
650
  ],
652
- execute: withRepository(
653
- async (options) => {
654
- if (!options.isRepo) {
655
- p5.log.error(
656
- dedent5`${color5.red("no git repository found in cwd.")}
657
- ${color5.dim(`run ${color5.cyan("`git init`")} to initialize a new repository.`)}`
658
- );
659
- return await exit(1);
660
- }
661
- const branch = await getCurrentBranch();
662
- if (!branch) {
663
- p5.log.error("failed to fetch current branch");
664
- return await exit(1);
665
- }
666
- p5.log.success(`current branch: ${color5.bold(branch)}`);
667
- if (options["--copy"]) {
668
- clipboard3.writeSync(branch);
669
- p5.log.success(`${color5.green("copied to clipboard!")}`);
670
- }
671
- await exit(0);
672
- },
673
- { enabled: false }
674
- )
651
+ execute: withRepository(async (options) => {
652
+ if (!options.isRepo) {
653
+ p5.log.error(dedent5`${color5.red("no git repository found in cwd.")}
654
+ ${color5.dim(`run ${color5.cyan("`git init`")} to initialize a new repository.`)}`);
655
+ return await exit(1);
656
+ }
657
+ const branch = await getCurrentBranch();
658
+ if (!branch) {
659
+ p5.log.error("failed to fetch current branch");
660
+ return await exit(1);
661
+ }
662
+ p5.log.success(`current branch: ${color5.bold(branch)}`);
663
+ if (options["--copy"]) {
664
+ clipboard3.writeSync(branch);
665
+ p5.log.success(`${color5.green("copied to clipboard!")}`);
666
+ }
667
+ await exit(0);
668
+ }, { enabled: false })
675
669
  };
676
670
  var del = {
677
671
  name: "delete",
@@ -691,53 +685,48 @@ var del = {
691
685
  description: "select all branches except the current one"
692
686
  }
693
687
  ],
694
- execute: withRepository(
695
- async (options) => {
696
- if (!options.isRepo) {
697
- p5.log.error(
698
- dedent5`${color5.red("no git repository found in cwd.")}
699
- ${color5.dim(`run ${color5.cyan("`git init`")} to initialize a new repository.`)}`
700
- );
701
- return await exit(1);
702
- }
703
- const currentBranch = await getCurrentBranch();
704
- const branches = await getBranches();
705
- if (!currentBranch || !branches) {
706
- p5.log.error("failed to fetch branches");
707
- return await exit(1);
708
- }
709
- const selectedBranches = await p5.multiselect({
710
- message: "select branches to delete",
711
- initialValues: options["--all"] ? branches.filter((b) => b !== currentBranch) : [],
712
- options: branches.map((branch) => ({
713
- value: branch,
714
- label: color5.bold(branch),
715
- hint: branch === options["--current"] ? "current branch" : void 0
716
- }))
717
- });
718
- if (p5.isCancel(selectedBranches)) {
719
- p5.log.error("nothing selected!");
720
- return await exit(1);
721
- }
722
- if (!selectedBranches) {
723
- p5.log.error("no branch selected");
724
- return await exit(1);
725
- }
726
- const force = options["--force"];
727
- if (currentBranch && selectedBranches.includes(currentBranch)) {
728
- p5.log.error("cannot delete current branch");
729
- return await exit(1);
730
- }
731
- const deletedBranches = await deleteBranches(selectedBranches, force);
732
- if (!deletedBranches) {
733
- p5.log.error("failed to delete branches");
734
- return await exit(1);
735
- }
736
- p5.log.success("branches deleted successfully");
737
- await exit(0);
738
- },
739
- { enabled: false }
740
- )
688
+ execute: withRepository(async (options) => {
689
+ if (!options.isRepo) {
690
+ p5.log.error(dedent5`${color5.red("no git repository found in cwd.")}
691
+ ${color5.dim(`run ${color5.cyan("`git init`")} to initialize a new repository.`)}`);
692
+ return await exit(1);
693
+ }
694
+ const currentBranch = await getCurrentBranch();
695
+ const branches = await getBranches();
696
+ if (!currentBranch || !branches) {
697
+ p5.log.error("failed to fetch branches");
698
+ return await exit(1);
699
+ }
700
+ const selectedBranches = await p5.multiselect({
701
+ message: "select branches to delete",
702
+ initialValues: options["--all"] ? branches.filter((b) => b !== currentBranch) : [],
703
+ options: branches.map((branch) => ({
704
+ value: branch,
705
+ label: color5.bold(branch),
706
+ hint: branch === options["--current"] ? "current branch" : undefined
707
+ }))
708
+ });
709
+ if (p5.isCancel(selectedBranches)) {
710
+ p5.log.error("nothing selected!");
711
+ return await exit(1);
712
+ }
713
+ if (!selectedBranches) {
714
+ p5.log.error("no branch selected");
715
+ return await exit(1);
716
+ }
717
+ const force = options["--force"];
718
+ if (currentBranch && selectedBranches.includes(currentBranch)) {
719
+ p5.log.error("cannot delete current branch");
720
+ return await exit(1);
721
+ }
722
+ const deletedBranches = await deleteBranches(selectedBranches, force);
723
+ if (!deletedBranches) {
724
+ p5.log.error("failed to delete branches");
725
+ return await exit(1);
726
+ }
727
+ p5.log.success("branches deleted successfully");
728
+ await exit(0);
729
+ }, { enabled: false })
741
730
  };
742
731
  var command3 = {
743
732
  name: "branch",
@@ -769,48 +758,42 @@ var command3 = {
769
758
  description: "select all branches except the current one"
770
759
  }
771
760
  ],
772
- execute: withRepository(
773
- async (options) => {
774
- if (!options.isRepo) {
775
- p5.log.error(
776
- dedent5`${color5.red("no git repository found in cwd.")}
777
- ${color5.dim(`run ${color5.cyan("`git init`")} to initialize a new repository.`)}`
778
- );
779
- return await exit(1);
780
- }
781
- if (options["--delete"]) return del.execute(options);
782
- const remote = options["--remote"];
783
- const branches = await getBranches(remote);
784
- if (!branches) {
785
- p5.log.error("failed to fetch branches");
786
- return await exit(1);
787
- }
788
- const currentBranch = await getCurrentBranch();
789
- const branch = await p5.select({
790
- message: "select a branch",
791
- options: branches.map((branch2) => ({
792
- value: branch2,
793
- label: color5.bold(
794
- branch2 === currentBranch ? color5.green(branch2) : branch2
795
- ),
796
- hint: branch2 === currentBranch ? "current branch" : void 0
797
- })),
798
- initialValue: currentBranch
799
- });
800
- if (p5.isCancel(branch)) {
801
- p5.log.error("nothing selected!");
802
- return await exit(1);
803
- }
804
- if (!branch) {
805
- p5.log.error("no branch selected");
806
- return await exit(1);
807
- }
808
- clipboard3.writeSync(branch);
809
- p5.log.success(`${color5.green("copied to clipboard!")}`);
810
- await exit(0);
811
- },
812
- { enabled: false }
813
- ),
761
+ execute: withRepository(async (options) => {
762
+ if (!options.isRepo) {
763
+ p5.log.error(dedent5`${color5.red("no git repository found in cwd.")}
764
+ ${color5.dim(`run ${color5.cyan("`git init`")} to initialize a new repository.`)}`);
765
+ return await exit(1);
766
+ }
767
+ if (options["--delete"])
768
+ return del.execute(options);
769
+ const remote = options["--remote"];
770
+ const branches = await getBranches(remote);
771
+ if (!branches) {
772
+ p5.log.error("failed to fetch branches");
773
+ return await exit(1);
774
+ }
775
+ const currentBranch = await getCurrentBranch();
776
+ const branch = await p5.select({
777
+ message: "select a branch",
778
+ options: branches.map((branch2) => ({
779
+ value: branch2,
780
+ label: color5.bold(branch2 === currentBranch ? color5.green(branch2) : branch2),
781
+ hint: branch2 === currentBranch ? "current branch" : undefined
782
+ })),
783
+ initialValue: currentBranch
784
+ });
785
+ if (p5.isCancel(branch)) {
786
+ p5.log.error("nothing selected!");
787
+ return await exit(1);
788
+ }
789
+ if (!branch) {
790
+ p5.log.error("no branch selected");
791
+ return await exit(1);
792
+ }
793
+ clipboard3.writeSync(branch);
794
+ p5.log.success(`${color5.green("copied to clipboard!")}`);
795
+ await exit(0);
796
+ }, { enabled: false }),
814
797
  subCommands: [current, del]
815
798
  };
816
799
  var branch_default = command3;
@@ -838,117 +821,100 @@ var command4 = {
838
821
  description: "create a new branch"
839
822
  }
840
823
  ],
841
- execute: withRepository(
842
- async (options) => {
843
- const args = options._.slice(1);
844
- if (!options.isRepo) {
845
- p6.log.error(
846
- dedent6`${color6.red("no git repository found in cwd.")}
847
- ${color6.dim(`run ${color6.cyan("`git init`")} to initialize a new repository.`)}`
848
- );
824
+ execute: withRepository(async (options) => {
825
+ const args = options._.slice(1);
826
+ if (!options.isRepo) {
827
+ p6.log.error(dedent6`${color6.red("no git repository found in cwd.")}
828
+ ${color6.dim(`run ${color6.cyan("`git init`")} to initialize a new repository.`)}`);
829
+ return await exit(1);
830
+ }
831
+ const branches = await getBranches();
832
+ if (!branches) {
833
+ p6.log.error("failed to fetch branches");
834
+ return await exit(1);
835
+ }
836
+ const currentBranch = await getCurrentBranch();
837
+ const branchName = args[0];
838
+ if (options["--create"]) {
839
+ if (branches.includes(branchName)) {
840
+ p6.log.error(`branch ${color6.red(branchName)} already exists in the repository`);
849
841
  return await exit(1);
850
842
  }
851
- const branches = await getBranches();
852
- if (!branches) {
853
- p6.log.error("failed to fetch branches");
843
+ const result2 = await checkoutLocalBranch(branchName);
844
+ if (!result2) {
845
+ p6.log.error(`failed to create and checkout ${color6.bold(branchName)}`);
854
846
  return await exit(1);
855
847
  }
856
- const currentBranch = await getCurrentBranch();
857
- const branchName = args[0];
858
- if (options["--create"]) {
859
- if (branches.includes(branchName)) {
860
- p6.log.error(
861
- `branch ${color6.red(branchName)} already exists in the repository`
862
- );
863
- return await exit(1);
864
- }
865
- const result2 = await checkoutLocalBranch(branchName);
866
- if (!result2) {
867
- p6.log.error(
868
- `failed to create and checkout ${color6.bold(branchName)}`
869
- );
848
+ p6.log.success(`created and checked out ${color6.green(branchName)}`);
849
+ return await exit(0);
850
+ }
851
+ if (branchName) {
852
+ if (!branches.includes(branchName)) {
853
+ p6.log.error(`branch ${color6.red(branchName)} does not exist in the repository`);
854
+ const createBranch = await p6.confirm({
855
+ message: `do you want to create branch ${color6.green(branchName)}?`
856
+ });
857
+ if (p6.isCancel(createBranch)) {
858
+ p6.log.error("aborted");
870
859
  return await exit(1);
871
860
  }
872
- p6.log.success(`created and checked out ${color6.green(branchName)}`);
873
- return await exit(0);
874
- }
875
- if (branchName) {
876
- if (!branches.includes(branchName)) {
877
- p6.log.error(
878
- `branch ${color6.red(branchName)} does not exist in the repository`
879
- );
880
- const createBranch = await p6.confirm({
881
- message: `do you want to create branch ${color6.green(branchName)}?`
882
- });
883
- if (p6.isCancel(createBranch)) {
884
- p6.log.error("aborted");
861
+ if (createBranch) {
862
+ const result3 = await checkoutLocalBranch(branchName);
863
+ if (!result3) {
864
+ p6.log.error(`failed to create and checkout ${color6.bold(branchName)}`);
885
865
  return await exit(1);
886
866
  }
887
- if (createBranch) {
888
- const result3 = await checkoutLocalBranch(branchName);
889
- if (!result3) {
890
- p6.log.error(
891
- `failed to create and checkout ${color6.bold(branchName)}`
892
- );
893
- return await exit(1);
894
- }
895
- p6.log.success(`created and checked out ${color6.green(branchName)}`);
896
- return await exit(0);
897
- }
898
- return await exit(1);
867
+ p6.log.success(`created and checked out ${color6.green(branchName)}`);
868
+ return await exit(0);
899
869
  }
900
- if (branchName === currentBranch) {
901
- p6.log.error(
902
- `${color6.red("already on branch")} ${color6.green(branchName)}`
903
- );
904
- return await exit(1);
905
- }
906
- const result2 = await checkout(branchName);
907
- if (!result2) {
908
- p6.log.error(`failed to checkout ${color6.bold(branchName)}`);
909
- return await exit(1);
910
- }
911
- p6.log.success(`checked out ${color6.green(branchName)}`);
912
- return await exit(0);
913
- }
914
- const branch = await p6.select({
915
- message: "select a branch to checkout",
916
- options: branches.map((branch2) => ({
917
- value: branch2,
918
- label: color6.bold(
919
- branch2 === currentBranch ? color6.green(branch2) : branch2
920
- ),
921
- hint: branch2 === currentBranch ? "current branch" : void 0
922
- })),
923
- initialValue: currentBranch
924
- });
925
- if (p6.isCancel(branch)) {
926
- p6.log.error("nothing selected!");
927
- return await exit(1);
928
- }
929
- if (!branch) {
930
- p6.log.error("no branch selected");
931
870
  return await exit(1);
932
871
  }
933
- if (options["--copy"]) {
934
- clipboard4.writeSync(branch);
935
- p6.log.success(`copied ${color6.green(branch)} to clipboard`);
936
- return await exit(0);
937
- }
938
- if (branch === currentBranch) {
939
- p6.log.error(`${color6.red("already on branch")}`);
872
+ if (branchName === currentBranch) {
873
+ p6.log.error(`${color6.red("already on branch")} ${color6.green(branchName)}`);
940
874
  return await exit(1);
941
875
  }
942
- const result = await checkout(branch);
943
- if (!result) {
944
- p6.log.error(`failed to checkout ${color6.bold(branch)}`);
876
+ const result2 = await checkout(branchName);
877
+ if (!result2) {
878
+ p6.log.error(`failed to checkout ${color6.bold(branchName)}`);
945
879
  return await exit(1);
946
880
  }
947
- p6.log.success(`checked out ${color6.green(branch)}`);
948
- await exit(0);
949
- },
950
- { enabled: false }
951
- )
881
+ p6.log.success(`checked out ${color6.green(branchName)}`);
882
+ return await exit(0);
883
+ }
884
+ const branch = await p6.select({
885
+ message: "select a branch to checkout",
886
+ options: branches.map((branch2) => ({
887
+ value: branch2,
888
+ label: color6.bold(branch2 === currentBranch ? color6.green(branch2) : branch2),
889
+ hint: branch2 === currentBranch ? "current branch" : undefined
890
+ })),
891
+ initialValue: currentBranch
892
+ });
893
+ if (p6.isCancel(branch)) {
894
+ p6.log.error("nothing selected!");
895
+ return await exit(1);
896
+ }
897
+ if (!branch) {
898
+ p6.log.error("no branch selected");
899
+ return await exit(1);
900
+ }
901
+ if (options["--copy"]) {
902
+ clipboard4.writeSync(branch);
903
+ p6.log.success(`copied ${color6.green(branch)} to clipboard`);
904
+ return await exit(0);
905
+ }
906
+ if (branch === currentBranch) {
907
+ p6.log.error(`${color6.red("already on branch")}`);
908
+ return await exit(1);
909
+ }
910
+ const result = await checkout(branch);
911
+ if (!result) {
912
+ p6.log.error(`failed to checkout ${color6.bold(branch)}`);
913
+ return await exit(1);
914
+ }
915
+ p6.log.success(`checked out ${color6.green(branch)}`);
916
+ await exit(0);
917
+ }, { enabled: false })
952
918
  };
953
919
  var checkout_default = command4;
954
920
 
@@ -1090,16 +1056,14 @@ var help = {
1090
1056
  console.log(` ${command6.description}`);
1091
1057
  console.log();
1092
1058
  } else {
1093
- const commands2 = listCommand();
1059
+ const commands = listCommand();
1094
1060
  console.log();
1095
1061
  console.log(color8.bold("usage"));
1096
1062
  console.log(` noto [command] [options]`);
1097
1063
  console.log();
1098
1064
  console.log(color8.bold("commands"));
1099
- commands2.forEach((command7) => {
1100
- console.log(
1101
- ` ${color8.bold(command7.name)} ${color8.dim(command7.description)}`
1102
- );
1065
+ commands.forEach((command7) => {
1066
+ console.log(` ${color8.bold(command7.name)} ${color8.dim(command7.description)}`);
1103
1067
  });
1104
1068
  await exit(0);
1105
1069
  }
@@ -1115,9 +1079,8 @@ var getCommand = (name, cmds = commands) => {
1115
1079
  var listCommand = () => {
1116
1080
  return commands;
1117
1081
  };
1118
-
1119
1082
  // package.json
1120
- var version = "1.2.7";
1083
+ var version = "1.2.9";
1121
1084
 
1122
1085
  // src/index.ts
1123
1086
  var globalSpec = {
@@ -1131,20 +1094,20 @@ function main() {
1131
1094
  const { command: command6, options: globalOptions } = parse(globalSpec, args);
1132
1095
  console.log();
1133
1096
  p8.intro(`${color9.bgCyan(color9.black(" @snelusha/noto "))}`);
1134
- if (globalOptions["--version"]) return p8.outro(version);
1097
+ if (globalOptions["--version"])
1098
+ return p8.outro(version);
1135
1099
  if (globalOptions["--help"]) {
1136
1100
  getCommand("help")?.execute(globalOptions);
1137
1101
  return;
1138
1102
  }
1139
1103
  const cmd = getCommand(command6) ?? getCommand("noto");
1140
- if (!cmd) return getCommand("noto")?.execute(globalOptions);
1104
+ if (!cmd)
1105
+ return getCommand("noto")?.execute(globalOptions);
1141
1106
  let commandArgs = args;
1142
1107
  let selectedCommand = cmd;
1143
1108
  if (cmd.subCommands && commandArgs.length) {
1144
1109
  const possibleCommand = commandArgs[1];
1145
- const subCommand = cmd.subCommands.find(
1146
- (cmd2) => cmd2.name === possibleCommand || cmd2.aliases && cmd2.aliases.includes(possibleCommand)
1147
- );
1110
+ const subCommand = cmd.subCommands.find((cmd2) => cmd2.name === possibleCommand || cmd2.aliases && cmd2.aliases.includes(possibleCommand));
1148
1111
  if (subCommand) {
1149
1112
  selectedCommand = subCommand;
1150
1113
  commandArgs = commandArgs.slice(2);
@@ -1154,7 +1117,8 @@ function main() {
1154
1117
  acc[opt.flag] = opt.type ?? Boolean;
1155
1118
  if (Array.isArray(opt.alias))
1156
1119
  opt.alias.forEach((alias) => acc[alias] = opt.flag);
1157
- else if (opt.alias) acc[opt.alias] = opt.flag;
1120
+ else if (opt.alias)
1121
+ acc[opt.alias] = opt.flag;
1158
1122
  return acc;
1159
1123
  }, {});
1160
1124
  const { options: commandOptions } = safeParse(commandSpec, commandArgs);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snelusha/noto",
3
- "version": "1.2.7",
3
+ "version": "1.2.9",
4
4
  "description": "Generate clean commit messages in a snap! ✨",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -25,8 +25,8 @@
25
25
  "noto": "./bin/noto.mjs"
26
26
  },
27
27
  "scripts": {
28
- "build": "tsup --clean",
29
- "test": "tsup --clean && vitest",
28
+ "build": "bunup --clean",
29
+ "test": "bunup --clean && vitest",
30
30
  "clean": "git clean -xdf .cache .turbo node_modules"
31
31
  },
32
32
  "files": [
@@ -42,20 +42,20 @@
42
42
  ],
43
43
  "devDependencies": {
44
44
  "@types/node": "^22.15.23",
45
- "tsup": "^8.5.0",
46
45
  "typescript": "^5.8.3",
47
- "vitest": "^3.2.2"
46
+ "vitest": "^3.2.4"
48
47
  },
49
48
  "dependencies": {
50
- "@ai-sdk/google": "^1.2.19",
49
+ "@ai-sdk/google": "^1.2.22",
51
50
  "@clack/prompts": "^0.10.1",
52
- "ai": "^4.3.16",
51
+ "ai": "^4.3.19",
53
52
  "arg": "^5.0.2",
53
+ "bunup": "^0.9.0",
54
54
  "clipboardy": "^4.0.0",
55
55
  "dedent": "^1.6.0",
56
56
  "picocolors": "^1.1.1",
57
- "simple-git": "^3.27.0",
57
+ "simple-git": "^3.28.0",
58
58
  "tinyexec": "^0.3.2",
59
- "zod": "^3.25.51"
59
+ "zod": "^3.25.76"
60
60
  }
61
61
  }