@arbidocs/cli 0.3.16 → 0.3.18

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arbidocs/cli",
3
- "version": "0.3.16",
3
+ "version": "0.3.18",
4
4
  "description": "CLI tool for interacting with ARBI — login, manage workspaces, upload documents, query the RAG assistant",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -8,17 +8,20 @@
8
8
  },
9
9
  "files": [
10
10
  "dist",
11
+ "scripts",
11
12
  "CHANGELOG.md"
12
13
  ],
13
14
  "scripts": {
14
15
  "build": "tsup",
15
16
  "test": "vitest run",
16
- "typecheck": "tsc --noEmit"
17
+ "typecheck": "tsc --noEmit",
18
+ "postinstall": "node scripts/postinstall.js",
19
+ "preuninstall": "node scripts/preuninstall.js"
17
20
  },
18
21
  "dependencies": {
19
- "@arbidocs/sdk": "0.3.16",
20
- "@arbidocs/client": "0.3.16",
21
- "@arbidocs/tui": "0.3.16",
22
+ "@arbidocs/sdk": "0.3.18",
23
+ "@arbidocs/client": "0.3.18",
24
+ "@arbidocs/tui": "0.3.18",
22
25
  "@inquirer/prompts": "^8.2.0",
23
26
  "chalk": "^5.6.2",
24
27
  "commander": "^13.1.0"
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Auto-install shell tab completion on `npm install -g @arbidocs/cli`.
5
+ *
6
+ * Appends a completion function to ~/.bashrc or ~/.zshrc (idempotent).
7
+ * Runs silently — never fails the install.
8
+ */
9
+
10
+ const fs = require('node:fs')
11
+ const path = require('node:path')
12
+ const os = require('node:os')
13
+
14
+ const MARKER_START = '# arbi-cli completion start'
15
+ const MARKER_END = '# arbi-cli completion end'
16
+
17
+ const BASH_SNIPPET = `
18
+ ${MARKER_START}
19
+ _arbi_completions() {
20
+ local cur="\${COMP_WORDS[COMP_CWORD]}"
21
+ local candidates
22
+ candidates=$(arbi --get-completions "\${COMP_LINE}" 2>/dev/null)
23
+ COMPREPLY=($(compgen -W "$candidates" -- "$cur"))
24
+ }
25
+ complete -o default -F _arbi_completions arbi
26
+ ${MARKER_END}
27
+ `
28
+
29
+ const ZSH_SNIPPET = `
30
+ ${MARKER_START}
31
+ _arbi_completions() {
32
+ local candidates
33
+ candidates=(\${(f)"$(arbi --get-completions "\${words[*]}" 2>/dev/null)"})
34
+ compadd -a candidates
35
+ }
36
+ compdef _arbi_completions arbi
37
+ ${MARKER_END}
38
+ `
39
+
40
+ try {
41
+ const shell = process.env.SHELL || ''
42
+ const rcPath = shell.includes('zsh')
43
+ ? path.join(os.homedir(), '.zshrc')
44
+ : path.join(os.homedir(), '.bashrc')
45
+
46
+ // Already installed — skip
47
+ if (fs.existsSync(rcPath)) {
48
+ const content = fs.readFileSync(rcPath, 'utf-8')
49
+ if (content.includes(MARKER_START)) process.exit(0)
50
+ }
51
+
52
+ const snippet = shell.includes('zsh') ? ZSH_SNIPPET : BASH_SNIPPET
53
+ fs.appendFileSync(rcPath, snippet)
54
+ } catch {
55
+ // Never fail the install
56
+ }
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Auto-remove shell tab completion on `npm uninstall -g @arbidocs/cli`.
5
+ *
6
+ * Removes the completion block from ~/.bashrc or ~/.zshrc.
7
+ * Runs silently — never fails the uninstall.
8
+ */
9
+
10
+ const fs = require('node:fs')
11
+ const path = require('node:path')
12
+ const os = require('node:os')
13
+
14
+ const MARKER_START = '# arbi-cli completion start'
15
+ const MARKER_END = '# arbi-cli completion end'
16
+
17
+ try {
18
+ const shell = process.env.SHELL || ''
19
+ const rcPath = shell.includes('zsh')
20
+ ? path.join(os.homedir(), '.zshrc')
21
+ : path.join(os.homedir(), '.bashrc')
22
+
23
+ if (!fs.existsSync(rcPath)) process.exit(0)
24
+
25
+ const content = fs.readFileSync(rcPath, 'utf-8')
26
+ const startIdx = content.indexOf(MARKER_START)
27
+ const endIdx = content.indexOf(MARKER_END)
28
+ if (startIdx === -1 || endIdx === -1) process.exit(0)
29
+
30
+ const before = content.substring(0, startIdx).replace(/\n+$/, '')
31
+ const after = content.substring(endIdx + MARKER_END.length)
32
+ fs.writeFileSync(rcPath, before + after)
33
+ } catch {
34
+ // Never fail the uninstall
35
+ }