@tvbs-ai/news-rd 0.3.2 → 0.3.3

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 +6 -4
  2. package/dist/cli.js +89 -83
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -69,13 +69,15 @@ news-rd prompt compile 2026-03-10 0600
69
69
  ### Shell Completion
70
70
 
71
71
  ```bash
72
- # Bash
73
- news-rd completion bash >> ~/.bashrc && source ~/.bashrc
72
+ # Bash — add to ~/.bashrc
73
+ echo 'source <(news-rd completion bash)' >> ~/.bashrc
74
74
 
75
- # Zsh
76
- news-rd completion zsh >> ~/.zshrc && source ~/.zshrc
75
+ # Zsh — add to ~/.zshrc
76
+ echo 'source <(news-rd completion zsh)' >> ~/.zshrc
77
77
  ```
78
78
 
79
+ Completion auto-updates when the CLI is updated.
80
+
79
81
  ## Update
80
82
 
81
83
  The CLI automatically checks for new versions and shows a hint after command output. To update:
package/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/cli.ts
4
- var CLI_VERSION = "0.3.2";
4
+ var CLI_VERSION = "0.3.3";
5
5
  var rawArgs = process.argv.slice(2);
6
6
  function parseArgs() {
7
7
  const options = {
@@ -201,9 +201,11 @@ Commands:
201
201
  bash Output bash completion script
202
202
  zsh Output zsh completion script
203
203
 
204
- Setup:
205
- news-rd completion bash >> ~/.bashrc && source ~/.bashrc
206
- news-rd completion zsh >> ~/.zshrc && source ~/.zshrc
204
+ Setup (add one line to your shell rc file):
205
+ echo 'source <(news-rd completion bash)' >> ~/.bashrc
206
+ echo 'source <(news-rd completion zsh)' >> ~/.zshrc
207
+
208
+ Then restart your shell or run: source ~/.zshrc
207
209
  `
208
210
  };
209
211
  function showGroupHelp(group) {
@@ -570,111 +572,115 @@ function handleCompletion(command) {
570
572
  process.exit(0);
571
573
  }
572
574
  }
575
+ var COMPLETION_DATA = {
576
+ groups: "config rundown news prompt token completion",
577
+ commands: {
578
+ config: "timeslots",
579
+ rundown: "get history",
580
+ news: "candidates trends keywords",
581
+ prompt: "list show variables resolve compile",
582
+ token: "generate",
583
+ completion: "bash zsh"
584
+ },
585
+ timeslots: "0600 0700 0800 1400 1500 1600",
586
+ optionsWithValue: "--base-url --token --category --content-type --limit --version --variables",
587
+ globalFlags: "--help --version --json"
588
+ };
573
589
  function generateBashCompletion() {
590
+ const d = COMPLETION_DATA;
574
591
  return `# bash completion for news-rd
592
+ # Setup: source <(news-rd completion bash)
593
+ # Persist: echo 'source <(news-rd completion bash)' >> ~/.bashrc
594
+
575
595
  _news_rd_completions() {
576
- local cur prev groups
596
+ local cur prev
577
597
  cur="\${COMP_WORDS[COMP_CWORD]}"
578
598
  prev="\${COMP_WORDS[COMP_CWORD-1]}"
579
- groups="config rundown news prompt token completion"
580
599
 
581
- case "\${COMP_WORDS[1]}" in
582
- config)
583
- COMPREPLY=($(compgen -W "timeslots" -- "$cur"))
584
- ;;
585
- rundown)
586
- COMPREPLY=($(compgen -W "get history" -- "$cur"))
587
- ;;
588
- news)
589
- COMPREPLY=($(compgen -W "candidates trends keywords" -- "$cur"))
590
- ;;
591
- prompt)
592
- COMPREPLY=($(compgen -W "list show variables resolve compile" -- "$cur"))
593
- ;;
594
- token)
595
- COMPREPLY=($(compgen -W "generate" -- "$cur"))
596
- ;;
597
- completion)
598
- COMPREPLY=($(compgen -W "bash zsh" -- "$cur"))
599
- ;;
600
- *)
601
- if [[ \${COMP_CWORD} -eq 1 ]]; then
602
- COMPREPLY=($(compgen -W "$groups --help --version --json" -- "$cur"))
603
- fi
600
+ # If previous word expects a value, don't complete
601
+ case "$prev" in
602
+ ${d.optionsWithValue.split(" ").join("|")})
603
+ COMPREPLY=()
604
+ return
604
605
  ;;
605
606
  esac
606
607
 
608
+ # Timeslot completion (position 4+: after group command date)
607
609
  case "$prev" in
608
- --base-url|--token|--category|--content-type|--limit|--version|--variables)
609
- COMPREPLY=()
610
- ;;
611
610
  get|history|candidates|trends|keywords|resolve|compile)
612
- # Suggest timeslots after date
613
611
  if [[ \${COMP_CWORD} -ge 4 ]]; then
614
- COMPREPLY=($(compgen -W "0600 0700 0800 1400 1500 1600" -- "$cur"))
612
+ COMPREPLY=($(compgen -W "${d.timeslots}" -- "$cur"))
613
+ return
615
614
  fi
616
615
  ;;
617
616
  esac
617
+
618
+ # Command completion based on group (position 2)
619
+ if [[ \${COMP_CWORD} -eq 2 ]]; then
620
+ case "\${COMP_WORDS[1]}" in
621
+ ${Object.entries(d.commands).map(
622
+ ([g, cmds]) => ` ${g}) COMPREPLY=($(compgen -W "${cmds}" -- "$cur")) ;;`
623
+ ).join("\n")}
624
+ esac
625
+ return
626
+ fi
627
+
628
+ # Group completion (position 1)
629
+ if [[ \${COMP_CWORD} -eq 1 ]]; then
630
+ COMPREPLY=($(compgen -W "${d.groups} ${d.globalFlags}" -- "$cur"))
631
+ return
632
+ fi
618
633
  }
619
634
  complete -F _news_rd_completions news-rd`;
620
635
  }
621
636
  function generateZshCompletion() {
637
+ const d = COMPLETION_DATA;
622
638
  return `# zsh completion for news-rd
623
- #compdef news-rd
639
+ # Setup: source <(news-rd completion zsh)
640
+ # Persist: echo 'source <(news-rd completion zsh)' >> ~/.zshrc
624
641
 
625
642
  _news_rd() {
626
- local -a groups
627
- groups=(
628
- 'config:\u6642\u6BB5\u8207\u74B0\u5883\u8A2D\u5B9A'
629
- 'rundown:Rundown \u67E5\u8A62\u8207\u7248\u672C\u6BD4\u5C0D'
630
- 'news:\u5019\u9078\u65B0\u805E\u8207\u8DA8\u52E2\u95DC\u9375\u5B57'
631
- 'prompt:Prompt \u6A21\u677F\u3001\u8B8A\u6578\u8207\u7DE8\u8B6F'
632
- 'token:JWT Token \u7BA1\u7406'
633
- 'completion:Shell auto-completion'
634
- )
643
+ local cur="\${words[CURRENT]}"
644
+ local group="\${words[2]}"
635
645
 
636
- local -a timeslots
637
- timeslots=(0600 0700 0800 1400 1500 1600)
646
+ # Group completion (position 2)
647
+ if (( CURRENT == 2 )); then
648
+ local -a groups=(
649
+ 'config:\u6642\u6BB5\u8207\u74B0\u5883\u8A2D\u5B9A'
650
+ 'rundown:Rundown \u67E5\u8A62\u8207\u7248\u672C\u6BD4\u5C0D'
651
+ 'news:\u5019\u9078\u65B0\u805E\u8207\u8DA8\u52E2\u95DC\u9375\u5B57'
652
+ 'prompt:Prompt \u6A21\u677F\u3001\u8B8A\u6578\u8207\u7DE8\u8B6F'
653
+ 'token:JWT Token \u7BA1\u7406'
654
+ 'completion:Shell auto-completion'
655
+ )
656
+ _describe 'group' groups
657
+ return
658
+ fi
638
659
 
639
- _arguments -C \\
640
- '--base-url[API base URL]:url:' \\
641
- '--token[JWT token]:token:' \\
642
- '--json[Raw JSON output]' \\
643
- '--version[Show version]' \\
644
- '--help[Show help]' \\
645
- '1:group:->group' \\
646
- '*::arg:->args'
660
+ # Command completion (position 3)
661
+ if (( CURRENT == 3 )); then
662
+ case "$group" in
663
+ ${Object.entries(d.commands).map(([g, cmds]) => {
664
+ const items = cmds.split(" ").map((c) => `'${c}'`).join(" ");
665
+ return ` ${g}) compadd ${items} ;;`;
666
+ }).join("\n")}
667
+ esac
668
+ return
669
+ fi
647
670
 
648
- case $state in
649
- group)
650
- _describe 'group' groups
651
- ;;
652
- args)
653
- case \${words[1]} in
654
- config)
655
- _values 'command' 'timeslots[List timeslots]'
656
- ;;
657
- rundown)
658
- _values 'command' 'get[Get rundown]' 'history[Version history]'
659
- ;;
660
- news)
661
- _values 'command' 'candidates[Scored candidates]' 'trends[Google Trends]' 'keywords[NewsRadar keywords]'
662
- ;;
663
- prompt)
664
- _values 'command' 'list[List prompts]' 'show[Get template]' 'variables[List variables]' 'resolve[Resolve variables]' 'compile[Compiled prompt]'
665
- ;;
666
- token)
667
- _values 'command' 'generate[Generate JWT token]'
668
- ;;
669
- completion)
670
- _values 'command' 'bash[Bash completion]' 'zsh[Zsh completion]'
671
- ;;
672
- esac
673
- ;;
674
- esac
675
- }
671
+ # Timeslot completion (position 5: after date)
672
+ if (( CURRENT == 5 )); then
673
+ compadd ${d.timeslots}
674
+ return
675
+ fi
676
676
 
677
- _news_rd "$@"`;
677
+ # Flag completion
678
+ if [[ "$cur" == -* ]]; then
679
+ compadd -- ${d.globalFlags} ${d.optionsWithValue}
680
+ return
681
+ fi
682
+ }
683
+ if (( $+functions[compdef] )); then compdef _news_rd news-rd; fi`;
678
684
  }
679
685
  async function checkForUpdates() {
680
686
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tvbs-ai/news-rd",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "TVBS News Rundown AI CLI — query rundowns, candidates, trends, and prompts",
5
5
  "type": "module",
6
6
  "bin": {