@snelusha/noto 1.1.1 → 1.1.2

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.
Files changed (3) hide show
  1. package/README.md +3 -3
  2. package/dist/index.js +172 -91
  3. package/package.json +4 -4
package/README.md CHANGED
@@ -109,13 +109,13 @@ noto checkout
109
109
  To copy the selected branch to your clipboard immediately after choosing it, use the new `-c` flag:
110
110
 
111
111
  ```bash
112
- noto checkout -c
112
+ noto branch
113
113
  ```
114
114
 
115
- To list all branches, including remote branches, use the -r flag (note: while remote branches are listed, you currently cannot checkout to remote branches):
115
+ To list all branches, including remote branches, use the -r flag
116
116
 
117
117
  ```bash
118
- noto checkout -r
118
+ noto branch -r
119
119
  ```
120
120
 
121
121
  ## Pro Tips
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // src/index.ts
2
- import * as p7 from "@clack/prompts";
3
- import color8 from "picocolors";
2
+ import * as p8 from "@clack/prompts";
3
+ import color9 from "picocolors";
4
4
 
5
5
  // src/utils/parser.ts
6
6
  import arg from "arg";
@@ -12,21 +12,21 @@ var parse = (schema, raw) => {
12
12
  };
13
13
  };
14
14
  var safeParse = (schema, raw) => {
15
- let current = { ...schema };
15
+ let current2 = { ...schema };
16
16
  let iterations = 0;
17
- const maxIterations = Object.keys(current).filter(
18
- (key2) => current[key2] === String
17
+ const maxIterations = Object.keys(current2).filter(
18
+ (key2) => current2[key2] === String
19
19
  ).length;
20
20
  while (iterations++ < maxIterations) {
21
21
  try {
22
- return parse(current, raw);
22
+ return parse(current2, raw);
23
23
  } catch (error) {
24
24
  if (error.code === "ARG_MISSING_REQUIRED_LONGARG") {
25
25
  const match = error.message.match(/(--\w[\w-]*)/);
26
26
  if (match) {
27
27
  const missingFlag = match[0];
28
- if (current[missingFlag] === String) {
29
- current[missingFlag] = Boolean;
28
+ if (current2[missingFlag] === String) {
29
+ current2[missingFlag] = Boolean;
30
30
  continue;
31
31
  }
32
32
  }
@@ -34,7 +34,7 @@ var safeParse = (schema, raw) => {
34
34
  throw error;
35
35
  }
36
36
  }
37
- return parse(current, raw);
37
+ return parse(current2, raw);
38
38
  };
39
39
 
40
40
  // src/commands/noto.ts
@@ -62,9 +62,7 @@ var AvailableModelsSchema = z.enum([
62
62
  "gemini-1.5-flash-8b-latest",
63
63
  "gemini-1.5-pro",
64
64
  "gemini-1.5-pro-latest",
65
- "gemini-2.0-flash-lite-preview-02-05",
66
- "gemini-2.0-flash-exp",
67
- "gemini-2.0-pro-exp-02-05",
65
+ "gemini-2.0-flash-001",
68
66
  "gemini-2.5-pro-exp-03-25"
69
67
  ]);
70
68
 
@@ -274,7 +272,7 @@ var NotoError = class _NotoError extends Error {
274
272
  var google = createGoogleGenerativeAI({
275
273
  apiKey: (await StorageManager.get()).llm?.apiKey ?? "api-key"
276
274
  });
277
- var defaultModel = "gemini-2.0-pro-exp-02-05";
275
+ var defaultModel = "gemini-2.0-flash-001";
278
276
  var models = {
279
277
  "gemini-1.5-flash": google("gemini-1.5-flash"),
280
278
  "gemini-1.5-flash-latest": google("gemini-1.5-flash-latest"),
@@ -282,22 +280,18 @@ var models = {
282
280
  "gemini-1.5-flash-8b-latest": google("gemini-1.5-flash-8b-latest"),
283
281
  "gemini-1.5-pro": google("gemini-1.5-pro"),
284
282
  "gemini-1.5-pro-latest": google("gemini-1.5-pro-latest"),
285
- "gemini-2.0-flash-lite-preview-02-05": google(
286
- "gemini-2.0-flash-lite-preview-02-05"
287
- ),
288
- "gemini-2.0-flash-exp": google("gemini-2.0-flash-exp"),
289
- "gemini-2.0-pro-exp-02-05": google("gemini-2.0-pro-exp-02-05"),
283
+ "gemini-2.0-flash-001": google("gemini-2.0-flash-001"),
290
284
  "gemini-2.5-pro-exp-03-25": google("gemini-2.5-pro-exp-03-25")
291
285
  };
292
286
  var availableModels = Object.keys(models);
293
287
  var getModel = async () => {
294
288
  let model2 = (await StorageManager.get()).llm?.model;
295
- if (!model2) {
289
+ if (!model2 || model2 === "gemini-2.0-pro-exp-02-05") {
296
290
  model2 = defaultModel;
297
- await StorageManager.update((current) => ({
298
- ...current,
291
+ await StorageManager.update((current2) => ({
292
+ ...current2,
299
293
  llm: {
300
- ...current.llm,
294
+ ...current2.llm,
301
295
  model: model2
302
296
  }
303
297
  }));
@@ -441,8 +435,8 @@ var command = {
441
435
  message = editedMessage;
442
436
  p3.log.step(color3.green(message));
443
437
  }
444
- await StorageManager.update((current) => ({
445
- ...current,
438
+ await StorageManager.update((current2) => ({
439
+ ...current2,
446
440
  lastGeneratedMessage: message
447
441
  }));
448
442
  if (options["--copy"]) {
@@ -539,8 +533,8 @@ var command2 = {
539
533
  return await exit(1);
540
534
  }
541
535
  lastGeneratedMessage = editedMessage;
542
- await StorageManager.update((current) => ({
543
- ...current,
536
+ await StorageManager.update((current2) => ({
537
+ ...current2,
544
538
  lastGeneratedMessage: editedMessage
545
539
  }));
546
540
  p4.log.step(color4.green(lastGeneratedMessage));
@@ -581,22 +575,52 @@ var command2 = {
581
575
  };
582
576
  var prev_default = command2;
583
577
 
584
- // src/commands/checkout.ts
578
+ // src/commands/branch.ts
585
579
  import * as p5 from "@clack/prompts";
586
580
  import color5 from "picocolors";
587
581
  import clipboard3 from "clipboardy";
588
582
  import dedent5 from "dedent";
589
- var command3 = {
590
- name: "checkout",
591
- description: "checkout a branch",
592
- usage: "checkout [options]",
583
+ var current = {
584
+ name: "current",
585
+ description: "get current branch",
586
+ usage: "branch current",
593
587
  options: [
594
588
  {
595
589
  type: Boolean,
596
590
  flag: "--copy",
597
591
  alias: "-c",
598
592
  description: "copy the selected branch to clipboard"
593
+ }
594
+ ],
595
+ execute: withRepository(
596
+ async (options) => {
597
+ if (!options.isRepo) {
598
+ p5.log.error(
599
+ dedent5`${color5.red("no git repository found in cwd.")}
600
+ ${color5.dim(`run ${color5.cyan("`git init`")} to initialize a new repository.`)}`
601
+ );
602
+ return await exit(1);
603
+ }
604
+ const branch = await getCurrentBranch();
605
+ if (!branch) {
606
+ p5.log.error("failed to fetch current branch");
607
+ return await exit(1);
608
+ }
609
+ p5.log.success(`current branch: ${color5.bold(branch)}`);
610
+ if (options["--copy"]) {
611
+ clipboard3.writeSync(branch);
612
+ p5.log.success(`${color5.green("copied to clipboard!")}`);
613
+ }
614
+ await exit(0);
599
615
  },
616
+ { enabled: false }
617
+ )
618
+ };
619
+ var command3 = {
620
+ name: "branch",
621
+ description: "list branches",
622
+ usage: "branch [options]",
623
+ options: [
600
624
  {
601
625
  type: Boolean,
602
626
  flag: "--remote",
@@ -621,7 +645,7 @@ var command3 = {
621
645
  }
622
646
  const currentBranch = await getCurrentBranch();
623
647
  const branch = await p5.select({
624
- message: "select a branch to checkout",
648
+ message: "select a branch",
625
649
  options: branches.map((branch2) => ({
626
650
  value: branch2,
627
651
  label: color5.bold(
@@ -639,68 +663,125 @@ var command3 = {
639
663
  p5.log.error("no branch selected");
640
664
  return await exit(1);
641
665
  }
642
- if (options["--copy"]) {
643
- clipboard3.writeSync(branch);
644
- p5.log.success(`copied ${color5.green(branch)} to clipboard`);
645
- return await exit(0);
666
+ clipboard3.writeSync(branch);
667
+ p5.log.success(`${color5.green("copied to clipboard!")}`);
668
+ await exit(0);
669
+ },
670
+ { enabled: false }
671
+ ),
672
+ subCommands: [current]
673
+ };
674
+ var branch_default = command3;
675
+
676
+ // src/commands/checkout.ts
677
+ import * as p6 from "@clack/prompts";
678
+ import color6 from "picocolors";
679
+ import clipboard4 from "clipboardy";
680
+ import dedent6 from "dedent";
681
+ var command4 = {
682
+ name: "checkout",
683
+ description: "checkout a branch",
684
+ usage: "checkout [options]",
685
+ options: [
686
+ {
687
+ type: Boolean,
688
+ flag: "--copy",
689
+ alias: "-c",
690
+ description: "copy the selected branch to clipboard"
691
+ }
692
+ ],
693
+ execute: withRepository(
694
+ async (options) => {
695
+ if (!options.isRepo) {
696
+ p6.log.error(
697
+ dedent6`${color6.red("no git repository found in cwd.")}
698
+ ${color6.dim(`run ${color6.cyan("`git init`")} to initialize a new repository.`)}`
699
+ );
700
+ return await exit(1);
646
701
  }
647
- if (remote && branch.startsWith("remotes/")) {
648
- p5.log.error(color5.red("cannot checkout remote branch"));
702
+ const branches = await getBranches();
703
+ if (!branches) {
704
+ p6.log.error("failed to fetch branches");
649
705
  return await exit(1);
650
706
  }
707
+ const currentBranch = await getCurrentBranch();
708
+ const branch = await p6.select({
709
+ message: "select a branch to checkout",
710
+ options: branches.map((branch2) => ({
711
+ value: branch2,
712
+ label: color6.bold(
713
+ branch2 === currentBranch ? color6.green(branch2) : branch2
714
+ ),
715
+ hint: branch2 === currentBranch ? "current branch" : void 0
716
+ })),
717
+ initialValue: currentBranch
718
+ });
719
+ if (p6.isCancel(branch)) {
720
+ p6.log.error("nothing selected!");
721
+ return await exit(1);
722
+ }
723
+ if (!branch) {
724
+ p6.log.error("no branch selected");
725
+ return await exit(1);
726
+ }
727
+ if (options["--copy"]) {
728
+ clipboard4.writeSync(branch);
729
+ p6.log.success(`copied ${color6.green(branch)} to clipboard`);
730
+ return await exit(0);
731
+ }
651
732
  if (branch === currentBranch) {
652
- p5.log.error(`${color5.red("already on branch")}`);
733
+ p6.log.error(`${color6.red("already on branch")}`);
653
734
  return await exit(1);
654
735
  }
655
736
  const result = await checkout(branch);
656
737
  if (!result) {
657
- p5.log.error(`failed to checkout ${color5.bold(branch)}`);
738
+ p6.log.error(`failed to checkout ${color6.bold(branch)}`);
658
739
  return await exit(1);
659
740
  }
660
- p5.log.success(`checked out ${color5.green(branch)}`);
741
+ p6.log.success(`checked out ${color6.green(branch)}`);
661
742
  await exit(0);
662
743
  },
663
744
  { enabled: false }
664
745
  )
665
746
  };
666
- var checkout_default = command3;
747
+ var checkout_default = command4;
667
748
 
668
749
  // src/commands/config.ts
669
- import * as p6 from "@clack/prompts";
670
- import color6 from "picocolors";
750
+ import * as p7 from "@clack/prompts";
751
+ import color7 from "picocolors";
671
752
  var key = {
672
753
  name: "key",
673
754
  description: "configure api key",
674
755
  usage: "noto config key [options]",
675
756
  execute: async (options) => {
676
757
  if ((await StorageManager.get()).llm?.apiKey) {
677
- const confirm2 = await p6.confirm({
758
+ const confirm2 = await p7.confirm({
678
759
  message: "noto api key already configured, do you want to update it?"
679
760
  });
680
- if (p6.isCancel(confirm2) || !confirm2) {
681
- p6.log.error(color6.red("nothing changed!"));
761
+ if (p7.isCancel(confirm2) || !confirm2) {
762
+ p7.log.error(color7.red("nothing changed!"));
682
763
  return await exit(1);
683
764
  }
684
765
  }
685
766
  let apiKey = options._[0];
686
767
  if (!apiKey) {
687
- const result = await p6.text({
768
+ const result = await p7.text({
688
769
  message: "enter your noto api key"
689
770
  });
690
- if (p6.isCancel(result)) {
691
- p6.log.error(color6.red("nothing changed!"));
771
+ if (p7.isCancel(result)) {
772
+ p7.log.error(color7.red("nothing changed!"));
692
773
  return await exit(1);
693
774
  }
694
775
  apiKey = result;
695
776
  }
696
- await StorageManager.update((current) => ({
697
- ...current,
777
+ await StorageManager.update((current2) => ({
778
+ ...current2,
698
779
  llm: {
699
- ...current.llm,
780
+ ...current2.llm,
700
781
  apiKey
701
782
  }
702
783
  }));
703
- p6.log.success(color6.green("noto api key configured!"));
784
+ p7.log.success(color7.green("noto api key configured!"));
704
785
  console.log();
705
786
  }
706
787
  };
@@ -709,7 +790,7 @@ var model = {
709
790
  description: "configure model",
710
791
  usage: "noto config model [options]",
711
792
  execute: async () => {
712
- const model2 = await p6.select({
793
+ const model2 = await p7.select({
713
794
  message: "select a model",
714
795
  initialValue: (await StorageManager.get()).llm?.model,
715
796
  options: Object.keys(models).map((model3) => ({
@@ -717,27 +798,27 @@ var model = {
717
798
  value: model3
718
799
  }))
719
800
  });
720
- if (p6.isCancel(model2)) {
721
- p6.log.error(color6.red("nothing changed!"));
801
+ if (p7.isCancel(model2)) {
802
+ p7.log.error(color7.red("nothing changed!"));
722
803
  return await exit(1);
723
804
  }
724
805
  if (model2 === "gemini-2.5-pro-exp-03-25") {
725
- const confirm2 = await p6.confirm({
806
+ const confirm2 = await p7.confirm({
726
807
  message: "this model has a rate limit of 5 RPM (requests per minute) 50 requests per day, do you want to continue?"
727
808
  });
728
- if (p6.isCancel(confirm2) || !confirm2) {
729
- p6.log.error(color6.red("nothing changed!"));
809
+ if (p7.isCancel(confirm2) || !confirm2) {
810
+ p7.log.error(color7.red("nothing changed!"));
730
811
  return await exit(1);
731
812
  }
732
813
  }
733
- await StorageManager.update((current) => ({
734
- ...current,
814
+ await StorageManager.update((current2) => ({
815
+ ...current2,
735
816
  llm: {
736
- ...current.llm,
817
+ ...current2.llm,
737
818
  model: model2
738
819
  }
739
820
  }));
740
- p6.log.success(color6.green("model configured!"));
821
+ p7.log.success(color7.green("model configured!"));
741
822
  console.log();
742
823
  }
743
824
  };
@@ -746,37 +827,37 @@ var reset = {
746
827
  description: "reset configuration",
747
828
  usage: "noto config reset",
748
829
  execute: async () => {
749
- const confirm2 = await p6.confirm({
830
+ const confirm2 = await p7.confirm({
750
831
  message: "are you sure you want to reset the configuration?"
751
832
  });
752
- if (p6.isCancel(confirm2) || !confirm2) {
753
- p6.log.error(color6.red("nothing changed!"));
833
+ if (p7.isCancel(confirm2) || !confirm2) {
834
+ p7.log.error(color7.red("nothing changed!"));
754
835
  return await exit(1);
755
836
  }
756
837
  await StorageManager.clear();
757
- p6.log.success(color6.green("configuration reset!"));
838
+ p7.log.success(color7.green("configuration reset!"));
758
839
  console.log();
759
840
  }
760
841
  };
761
842
  var subCommands = [key, model, reset];
762
- var command4 = {
843
+ var command5 = {
763
844
  name: "config",
764
845
  description: "configure noto",
765
846
  usage: "noto config [subcommand]",
766
847
  execute: async (options) => {
767
- const command5 = await p6.select({
848
+ const command6 = await p7.select({
768
849
  message: "Select a subcommand",
769
850
  options: subCommands.map((cmd2) => ({
770
851
  label: cmd2.description,
771
852
  value: cmd2.name
772
853
  }))
773
854
  });
774
- if (p6.isCancel(command5)) {
855
+ if (p7.isCancel(command6)) {
775
856
  return await exit(1);
776
857
  }
777
- const cmd = getCommand(command5, subCommands);
858
+ const cmd = getCommand(command6, subCommands);
778
859
  if (!cmd) {
779
- p6.log.error(color6.red("unknown config command"));
860
+ p7.log.error(color7.red("unknown config command"));
780
861
  return await exit(1);
781
862
  }
782
863
  options._ = options._.slice(1);
@@ -784,34 +865,34 @@ var command4 = {
784
865
  },
785
866
  subCommands
786
867
  };
787
- var config_default = command4;
868
+ var config_default = command5;
788
869
 
789
870
  // src/commands/help.ts
790
- import color7 from "picocolors";
871
+ import color8 from "picocolors";
791
872
  var help = {
792
873
  name: "help",
793
874
  description: "show help",
794
875
  usage: "noto help [command]",
795
876
  execute: async (options) => {
796
- const command5 = getCommand(options._[0]);
797
- if (command5) {
877
+ const command6 = getCommand(options._[0]);
878
+ if (command6 && command6.name !== "help") {
798
879
  console.log();
799
- console.log(color7.bold("Usage"));
800
- console.log(` ${command5.usage}`);
880
+ console.log(color8.bold("Usage"));
881
+ console.log(` ${command6.usage}`);
801
882
  console.log();
802
- console.log(color7.bold("Description"));
803
- console.log(` ${command5.description}`);
883
+ console.log(color8.bold("Description"));
884
+ console.log(` ${command6.description}`);
804
885
  console.log();
805
886
  } else {
806
887
  const commands2 = listCommand();
807
888
  console.log();
808
- console.log(color7.bold("Usage"));
889
+ console.log(color8.bold("Usage"));
809
890
  console.log(` noto [command] [options]`);
810
891
  console.log();
811
- console.log(color7.bold("Commands"));
812
- commands2.forEach((command6) => {
892
+ console.log(color8.bold("Commands"));
893
+ commands2.forEach((command7) => {
813
894
  console.log(
814
- ` ${color7.bold(command6.name)} ${color7.dim(command6.description)}`
895
+ ` ${color8.bold(command7.name)} ${color8.dim(command7.description)}`
815
896
  );
816
897
  });
817
898
  console.log();
@@ -821,7 +902,7 @@ var help = {
821
902
  var help_default = help;
822
903
 
823
904
  // src/commands/index.ts
824
- var commands = [noto_default, prev_default, checkout_default, config_default, help_default];
905
+ var commands = [noto_default, prev_default, branch_default, checkout_default, config_default, help_default];
825
906
  var getCommand = (name, cmds = commands) => {
826
907
  return cmds.find((cmd) => cmd.name === name);
827
908
  };
@@ -830,7 +911,7 @@ var listCommand = () => {
830
911
  };
831
912
 
832
913
  // package.json
833
- var version = "1.1.1";
914
+ var version = "1.1.2";
834
915
 
835
916
  // src/index.ts
836
917
  var globalSpec = {
@@ -841,15 +922,15 @@ var globalSpec = {
841
922
  };
842
923
  function main() {
843
924
  const args = process.argv.slice(2);
844
- const { command: command5, options: globalOptions } = parse(globalSpec, args);
925
+ const { command: command6, options: globalOptions } = parse(globalSpec, args);
845
926
  console.log();
846
- p7.intro(`${color8.bgCyan(color8.black(" @snelusha/noto "))}`);
847
- if (globalOptions["--version"]) return p7.outro(version);
927
+ p8.intro(`${color9.bgCyan(color9.black(" @snelusha/noto "))}`);
928
+ if (globalOptions["--version"]) return p8.outro(version);
848
929
  if (globalOptions["--help"]) {
849
930
  getCommand("help")?.execute(globalOptions);
850
931
  return;
851
932
  }
852
- const cmd = getCommand(command5) ?? getCommand("noto");
933
+ const cmd = getCommand(command6) ?? getCommand("noto");
853
934
  if (!cmd) return getCommand("noto")?.execute(globalOptions);
854
935
  let commandArgs = args;
855
936
  let selectedCommand = cmd;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snelusha/noto",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "Generate clean commit messages in a snap! ✨",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -48,9 +48,9 @@
48
48
  "vitest": "^3.1.1"
49
49
  },
50
50
  "dependencies": {
51
- "@ai-sdk/google": "^1.2.7",
52
- "@clack/prompts": "^0.10.0",
53
- "ai": "^4.3.2",
51
+ "@ai-sdk/google": "^1.2.10",
52
+ "@clack/prompts": "^0.10.1",
53
+ "ai": "^4.3.4",
54
54
  "arg": "^5.0.2",
55
55
  "clipboardy": "^4.0.0",
56
56
  "dedent": "^1.5.3",