linkgravity 1.6.1 → 1.7.0

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.
@@ -0,0 +1,50 @@
1
+ const fs = require('fs');
2
+ const os = require('os');
3
+ const path = require('path');
4
+
5
+ // bash and fish read these directories lazily, on the first completion attempt, so neither needs
6
+ // an rc line. zsh's default fpath has no home-directory entry, so it gets three.
7
+ const TARGETS = {
8
+ bash: { src: 'lgy.bash', dest: ['.local', 'share', 'bash-completion', 'completions', 'lgy'] },
9
+ zsh: { src: '_lgy', dest: ['.local', 'share', 'zsh', 'site-functions', '_lgy'], rc: '.zshrc' },
10
+ fish: { src: 'lgy.fish', dest: ['.config', 'fish', 'completions', 'lgy.fish'] },
11
+ };
12
+
13
+ const MARKER = '# linkgravity completion';
14
+
15
+ function zshRcBlock(dir) {
16
+ return [
17
+ '',
18
+ MARKER,
19
+ `fpath+=("${dir}")`,
20
+ 'autoload -Uz _lgy',
21
+ 'whence compdef > /dev/null && compdef _lgy lgy linkgravity',
22
+ '',
23
+ ].join('\n');
24
+ }
25
+
26
+ function installCompletion(shell = path.basename(process.env.SHELL || '')) {
27
+ const target = TARGETS[shell];
28
+ if (!target) return null;
29
+
30
+ const dest = path.join(os.homedir(), ...target.dest);
31
+ let rcUpdated = false;
32
+ try {
33
+ fs.mkdirSync(path.dirname(dest), { recursive: true });
34
+ fs.copyFileSync(path.join(__dirname, 'completions', target.src), dest);
35
+
36
+ if (target.rc) {
37
+ const rc = path.join(os.homedir(), target.rc);
38
+ const existing = fs.existsSync(rc) ? fs.readFileSync(rc, 'utf8') : '';
39
+ if (!existing.includes(MARKER)) {
40
+ fs.appendFileSync(rc, zshRcBlock(path.dirname(dest)));
41
+ rcUpdated = true;
42
+ }
43
+ }
44
+ } catch {
45
+ return null;
46
+ }
47
+ return { shell, file: dest, rc: rcUpdated ? path.join(os.homedir(), target.rc) : null };
48
+ }
49
+
50
+ module.exports = { installCompletion };
@@ -0,0 +1,33 @@
1
+ #compdef lgy linkgravity
2
+
3
+ local -a commands
4
+ commands=(
5
+ 'version:Print the installed version'
6
+ 'start:Start bot in the background'
7
+ 'stop:Stop the background bot'
8
+ 'restart:Restart the background bot'
9
+ 'logs:View bot logs'
10
+ 'status:Show daemon status'
11
+ 'enable:Start automatically on system boot'
12
+ 'disable:Remove bot from system boot'
13
+ 'setup:Run the configuration wizard'
14
+ 'update:Install a newer version if one exists'
15
+ 'help:Show the help message'
16
+ )
17
+
18
+ if (( CURRENT == 2 )); then
19
+ _describe 'command' commands
20
+ return
21
+ fi
22
+
23
+ case "$words[2]" in
24
+ logs)
25
+ [[ "$words[CURRENT-1]" == (-n|--tail) ]] && return
26
+ _values 'flag' \
27
+ '-f[Follow the log output]' \
28
+ '-n[Number of lines to show]' \
29
+ '--tail[Number of lines to show]' \
30
+ '-t[Show timestamps]' \
31
+ '--timestamp[Show timestamps]'
32
+ ;;
33
+ esac
@@ -0,0 +1,18 @@
1
+ _lgy_completion() {
2
+ local cur prev
3
+ cur="${COMP_WORDS[COMP_CWORD]}"
4
+ prev="${COMP_WORDS[COMP_CWORD - 1]}"
5
+
6
+ if [ "$COMP_CWORD" -eq 1 ]; then
7
+ COMPREPLY=($(compgen -W "version start stop restart logs status enable disable setup update help" -- "$cur"))
8
+ return
9
+ fi
10
+
11
+ if [ "${COMP_WORDS[1]}" = "logs" ]; then
12
+ case "$prev" in
13
+ -n | --tail) return ;;
14
+ esac
15
+ COMPREPLY=($(compgen -W "-f -n --tail -t --timestamp" -- "$cur"))
16
+ fi
17
+ }
18
+ complete -F _lgy_completion lgy linkgravity
@@ -0,0 +1,32 @@
1
+ complete -c lgy -n __fish_use_subcommand -a version -d 'Print the installed version'
2
+ complete -c lgy -n __fish_use_subcommand -a start -d 'Start bot in the background'
3
+ complete -c lgy -n __fish_use_subcommand -a stop -d 'Stop the background bot'
4
+ complete -c lgy -n __fish_use_subcommand -a restart -d 'Restart the background bot'
5
+ complete -c lgy -n __fish_use_subcommand -a logs -d 'View bot logs'
6
+ complete -c lgy -n __fish_use_subcommand -a status -d 'Show daemon status'
7
+ complete -c lgy -n __fish_use_subcommand -a enable -d 'Start automatically on system boot'
8
+ complete -c lgy -n __fish_use_subcommand -a disable -d 'Remove bot from system boot'
9
+ complete -c lgy -n __fish_use_subcommand -a setup -d 'Run the configuration wizard'
10
+ complete -c lgy -n __fish_use_subcommand -a update -d 'Install a newer version if one exists'
11
+ complete -c lgy -n __fish_use_subcommand -a help -d 'Show the help message'
12
+ complete -c lgy -n '__fish_seen_subcommand_from logs' -s f -d 'Follow the log output'
13
+ complete -c lgy -n '__fish_seen_subcommand_from logs' -s n -d 'Number of lines to show'
14
+ complete -c lgy -n '__fish_seen_subcommand_from logs' -l tail -d 'Number of lines to show'
15
+ complete -c lgy -n '__fish_seen_subcommand_from logs' -s t -d 'Show timestamps'
16
+ complete -c lgy -n '__fish_seen_subcommand_from logs' -l timestamp -d 'Show timestamps'
17
+ complete -c linkgravity -n __fish_use_subcommand -a version -d 'Print the installed version'
18
+ complete -c linkgravity -n __fish_use_subcommand -a start -d 'Start bot in the background'
19
+ complete -c linkgravity -n __fish_use_subcommand -a stop -d 'Stop the background bot'
20
+ complete -c linkgravity -n __fish_use_subcommand -a restart -d 'Restart the background bot'
21
+ complete -c linkgravity -n __fish_use_subcommand -a logs -d 'View bot logs'
22
+ complete -c linkgravity -n __fish_use_subcommand -a status -d 'Show daemon status'
23
+ complete -c linkgravity -n __fish_use_subcommand -a enable -d 'Start automatically on system boot'
24
+ complete -c linkgravity -n __fish_use_subcommand -a disable -d 'Remove bot from system boot'
25
+ complete -c linkgravity -n __fish_use_subcommand -a setup -d 'Run the configuration wizard'
26
+ complete -c linkgravity -n __fish_use_subcommand -a update -d 'Install a newer version if one exists'
27
+ complete -c linkgravity -n __fish_use_subcommand -a help -d 'Show the help message'
28
+ complete -c linkgravity -n '__fish_seen_subcommand_from logs' -s f -d 'Follow the log output'
29
+ complete -c linkgravity -n '__fish_seen_subcommand_from logs' -s n -d 'Number of lines to show'
30
+ complete -c linkgravity -n '__fish_seen_subcommand_from logs' -l tail -d 'Number of lines to show'
31
+ complete -c linkgravity -n '__fish_seen_subcommand_from logs' -s t -d 'Show timestamps'
32
+ complete -c linkgravity -n '__fish_seen_subcommand_from logs' -l timestamp -d 'Show timestamps'
package/bin/setup.js CHANGED
@@ -494,6 +494,21 @@ async function runSetup() {
494
494
  await platformMenu(choice);
495
495
  }
496
496
 
497
+ const { installCompletion } = require('./completion');
498
+ const installed = installCompletion();
499
+ if (installed) {
500
+ p.note(
501
+ [
502
+ `Installed for ${installed.shell} at ${installed.file}.`,
503
+ installed.rc ? `Added a line to ${installed.rc}.` : null,
504
+ 'Open a new shell to use it.',
505
+ ]
506
+ .filter(Boolean)
507
+ .join('\n'),
508
+ 'Tab completion',
509
+ );
510
+ }
511
+
497
512
  p.outro('Setup complete.');
498
513
  }
499
514
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linkgravity",
3
- "version": "1.6.1",
3
+ "version": "1.7.0",
4
4
  "description": "Discord/Telegram bot bridge for the Antigravity (agy) CLI, with voice interaction support",
5
5
  "scripts": {
6
6
  "start": "node npm-scripts/run-dev.js",