quilltap 4.9.0-dev → 4.9.0-dev.100
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/README.md +5 -1
- package/bin/quilltap.js +42 -18
- package/lib/__tests__/completion-behavior.test.js +162 -0
- package/lib/__tests__/completion-coverage.test.js +95 -0
- package/lib/__tests__/dbkey-restore.test.js +162 -0
- package/lib/completion/bash.template +118 -26
- package/lib/completion/fish.template +18 -2
- package/lib/completion/zsh.template +340 -100
- package/lib/db-helpers.js +9 -32
- package/lib/dbkey-restore.js +347 -0
- package/lib/dbkey.js +188 -0
- package/lib/instances-commands.js +48 -0
- package/lib/instances.js +6 -30
- package/lib/lock-helpers.js +2 -4
- package/package.json +1 -1
|
@@ -3,6 +3,52 @@
|
|
|
3
3
|
# Bash completion for quilltap
|
|
4
4
|
# Source this file or place it in /etc/bash_completion.d/ or ~/.bash_completion.d/
|
|
5
5
|
|
|
6
|
+
# Fill COMPREPLY from newline-separated candidates on stdin. Store and
|
|
7
|
+
# instance names routinely contain spaces ("Project Files: The Estate"), which
|
|
8
|
+
# `compgen -W` would chop into separate candidates.
|
|
9
|
+
_quilltap_lines_compreply() {
|
|
10
|
+
local cur="$1" line
|
|
11
|
+
local oldifs="$IFS"
|
|
12
|
+
COMPREPLY=()
|
|
13
|
+
IFS=$'\n'
|
|
14
|
+
while read -r line; do
|
|
15
|
+
[[ -n "$line" ]] || continue
|
|
16
|
+
[[ "$line" == "$cur"* ]] && COMPREPLY+=("$(printf '%q' "$line")")
|
|
17
|
+
done
|
|
18
|
+
IFS="$oldifs"
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
# Which docs positionals name a document store, and which name a local path.
|
|
22
|
+
# move/copy/link take <srcMount> <srcPath> <dstMount> <dstPath>, so a store is
|
|
23
|
+
# wanted at both 2 and 4; every other store-taking verb takes it first.
|
|
24
|
+
_quilltap_docs_positional() {
|
|
25
|
+
local verb="$1" argpos="$2" cur="$3"
|
|
26
|
+
local store_verbs=" show files ls dir tree read export scan reindex embed write delete mkdir rmdir mvdir move copy link "
|
|
27
|
+
|
|
28
|
+
if [[ "$argpos" == "2" ]] && [[ "$store_verbs" == *" $verb "* ]]; then
|
|
29
|
+
_quilltap_lines_compreply "$cur" \
|
|
30
|
+
<<< "$(command quilltap docs list --names-only "${ctx_flags[@]}" 2>/dev/null)"
|
|
31
|
+
return
|
|
32
|
+
fi
|
|
33
|
+
|
|
34
|
+
case "$verb" in
|
|
35
|
+
move|copy|link)
|
|
36
|
+
if [[ "$argpos" == "4" ]]; then
|
|
37
|
+
_quilltap_lines_compreply "$cur" \
|
|
38
|
+
<<< "$(command quilltap docs list --names-only "${ctx_flags[@]}" 2>/dev/null)"
|
|
39
|
+
fi
|
|
40
|
+
;;
|
|
41
|
+
export)
|
|
42
|
+
# `docs export <mount> <outputDir>` — the second one is a local directory.
|
|
43
|
+
[[ "$argpos" == "3" ]] && COMPREPLY=($(compgen -d -- "$cur"))
|
|
44
|
+
;;
|
|
45
|
+
write)
|
|
46
|
+
# `docs write <mount> <path> [file]` — the optional source is local.
|
|
47
|
+
[[ "$argpos" == "4" ]] && COMPREPLY=($(compgen -f -- "$cur"))
|
|
48
|
+
;;
|
|
49
|
+
esac
|
|
50
|
+
}
|
|
51
|
+
|
|
6
52
|
_quilltap_complete() {
|
|
7
53
|
local cur prev words cword
|
|
8
54
|
COMPREPLY=()
|
|
@@ -17,23 +63,62 @@ _quilltap_complete() {
|
|
|
17
63
|
# Top-level subcommands
|
|
18
64
|
local top_cmds="db docs themes instances memories memory-diff recall-replay logs migrations maintenance file-verify completion"
|
|
19
65
|
|
|
66
|
+
# Flags that swallow the word after them. A flat list will not do: -o is the
|
|
67
|
+
# valueless global --open but themes' valued --output, and `memories`
|
|
68
|
+
# reserves -i for --ignore-case rather than --instance. Counting those wrong
|
|
69
|
+
# makes a flag's value look like the subcommand's verb, which is how
|
|
70
|
+
# `quilltap docs --limit 5 <TAB>` used to lose the verb list.
|
|
71
|
+
local vf_global=" -d --data-dir -i --instance -p --port --passphrase "
|
|
72
|
+
local vf_db=" --limit --grep --character --project --about --source --chat --message --field --tail --last --from --type --out --id --count "
|
|
73
|
+
local vf_docs=" --mount --folder --type --ext --limit --max --context --top --threshold --sort --depth --max-nodes --format "
|
|
74
|
+
local vf_themes=" -o --output -k --key -n --name "
|
|
75
|
+
local vf_memories=" -d --data-dir --instance --passphrase --port --character --about --source --chat --project --since --until --min-importance --min-reinforced --sort --limit --in --max --context --depth --max-nodes --top --threshold "
|
|
76
|
+
local vf_logs=" --stream --tail --grep "
|
|
77
|
+
local vf_memory_diff=" --concurrency --out "
|
|
78
|
+
local vf_recall_replay=" --turn --char --limit --port "
|
|
79
|
+
local vf_file_verify=" --stall-ms "
|
|
80
|
+
|
|
20
81
|
# Get the subcommand (first non-option word after quilltap)
|
|
21
82
|
local subcommand=""
|
|
22
83
|
local subverb=""
|
|
84
|
+
local -a ctx_flags=()
|
|
85
|
+
local positional_count=0
|
|
23
86
|
local i=1
|
|
24
87
|
while [[ $i -lt $cword ]]; do
|
|
25
88
|
local word="${words[$i]}"
|
|
89
|
+
|
|
90
|
+
# Which flags take a value depends on the subcommand seen so far; before
|
|
91
|
+
# one is seen, only the global flags are in play.
|
|
92
|
+
local valued="$vf_global"
|
|
93
|
+
case "$subcommand" in
|
|
94
|
+
db) valued="$vf_global$vf_db" ;;
|
|
95
|
+
docs) valued="$vf_global$vf_docs" ;;
|
|
96
|
+
themes) valued="$vf_global$vf_themes" ;;
|
|
97
|
+
memories) valued="$vf_memories" ;;
|
|
98
|
+
logs) valued="$vf_global$vf_logs" ;;
|
|
99
|
+
memory-diff) valued="$vf_global$vf_memory_diff" ;;
|
|
100
|
+
recall-replay) valued="$vf_global$vf_recall_replay" ;;
|
|
101
|
+
file-verify) valued="$vf_global$vf_file_verify" ;;
|
|
102
|
+
esac
|
|
103
|
+
|
|
104
|
+
if [[ "$valued" == *" $word "* ]]; then
|
|
105
|
+
# Remember how the user is addressing an instance so the live lookups
|
|
106
|
+
# below query that database rather than the default one.
|
|
107
|
+
case "$word" in
|
|
108
|
+
-d|--data-dir|-i|--instance|--passphrase)
|
|
109
|
+
if (( i + 1 < cword )); then
|
|
110
|
+
ctx_flags+=("$word" "${words[$((i + 1))]}")
|
|
111
|
+
fi
|
|
112
|
+
;;
|
|
113
|
+
esac
|
|
114
|
+
# Takes a value, skip the next word
|
|
115
|
+
((i += 2))
|
|
116
|
+
continue
|
|
117
|
+
fi
|
|
118
|
+
|
|
26
119
|
case "$word" in
|
|
27
|
-
-d|--data-dir|-i|--instance|-p|--port|--passphrase)
|
|
28
|
-
# These take a value, skip the next word
|
|
29
|
-
((i += 2))
|
|
30
|
-
;;
|
|
31
|
-
-o|--open|-v|--version|-h|--help|--update)
|
|
32
|
-
# Flags without values
|
|
33
|
-
((i += 1))
|
|
34
|
-
;;
|
|
35
120
|
-*)
|
|
36
|
-
#
|
|
121
|
+
# Valueless (or unknown) flag
|
|
37
122
|
((i += 1))
|
|
38
123
|
;;
|
|
39
124
|
*)
|
|
@@ -42,6 +127,10 @@ _quilltap_complete() {
|
|
|
42
127
|
elif [[ -z "$subverb" ]]; then
|
|
43
128
|
subverb="$word"
|
|
44
129
|
fi
|
|
130
|
+
# Counts the subcommand itself, so the word under the cursor sits at
|
|
131
|
+
# positional_count within the subcommand: 1 is its verb, 2 the verb's
|
|
132
|
+
# first argument, and so on.
|
|
133
|
+
((positional_count += 1))
|
|
45
134
|
((i += 1))
|
|
46
135
|
;;
|
|
47
136
|
esac
|
|
@@ -56,9 +145,9 @@ _quilltap_complete() {
|
|
|
56
145
|
if [[ "$prev" == "-p" ]] || [[ "$prev" == "--port" ]] || [[ "$prev" == "--passphrase" ]]; then
|
|
57
146
|
return
|
|
58
147
|
fi
|
|
59
|
-
if [[ "$prev" == "
|
|
60
|
-
|
|
61
|
-
|
|
148
|
+
if [[ "$prev" == "--instance" ]] || { [[ "$prev" == "-i" ]] && [[ "$subcommand" != "memories" ]]; }; then
|
|
149
|
+
_quilltap_lines_compreply "$cur" \
|
|
150
|
+
<<< "$(command quilltap instances list --names-only 2>/dev/null)"
|
|
62
151
|
return
|
|
63
152
|
fi
|
|
64
153
|
|
|
@@ -75,8 +164,8 @@ _quilltap_complete() {
|
|
|
75
164
|
# Shared flag-value completions for any subcommand
|
|
76
165
|
case "$prev" in
|
|
77
166
|
--mount)
|
|
78
|
-
|
|
79
|
-
|
|
167
|
+
_quilltap_lines_compreply "$cur" \
|
|
168
|
+
<<< "$(command quilltap docs list --names-only "${ctx_flags[@]}" 2>/dev/null)"
|
|
80
169
|
return
|
|
81
170
|
;;
|
|
82
171
|
--character|--about)
|
|
@@ -104,6 +193,10 @@ _quilltap_complete() {
|
|
|
104
193
|
COMPREPLY=($(compgen -W "combined error stdout stderr startup" -- "$cur"))
|
|
105
194
|
return
|
|
106
195
|
;;
|
|
196
|
+
--format)
|
|
197
|
+
COMPREPLY=($(compgen -W "args json" -- "$cur"))
|
|
198
|
+
return
|
|
199
|
+
;;
|
|
107
200
|
esac
|
|
108
201
|
|
|
109
202
|
# Subcommand-specific completion
|
|
@@ -137,16 +230,15 @@ _quilltap_complete() {
|
|
|
137
230
|
docs)
|
|
138
231
|
local docs_verbs="list show files ls dir tree read export scan write delete mkdir move copy link rmdir mvdir status docker-mounts find grep reindex embed"
|
|
139
232
|
local docs_flags="--mount --instance --data-dir --passphrase --port --json --help \
|
|
140
|
-
--force --rendered --links --folder --type --ext --limit --max --context --top --threshold \
|
|
141
|
-
--ignore-case -l --wait -R --recursive --sort -r --reverse --depth --max-nodes --long --semantic
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
COMPREPLY=($(compgen -W "$docs_flags" -- "$cur"))
|
|
145
|
-
else
|
|
146
|
-
COMPREPLY=($(compgen -W "$docs_verbs" -- "$cur"))
|
|
147
|
-
fi
|
|
148
|
-
else
|
|
233
|
+
--uri --base64 --force --rendered --links --folder --type --ext --limit --max --context --top --threshold \
|
|
234
|
+
--ignore-case -l --wait -R --recursive --sort -r --reverse --depth --max-nodes --long --semantic \
|
|
235
|
+
--format"
|
|
236
|
+
if [[ "$cur" == -* ]]; then
|
|
149
237
|
COMPREPLY=($(compgen -W "$docs_flags" -- "$cur"))
|
|
238
|
+
elif [[ -z "$subverb" ]]; then
|
|
239
|
+
COMPREPLY=($(compgen -W "$docs_verbs" -- "$cur"))
|
|
240
|
+
else
|
|
241
|
+
_quilltap_docs_positional "$subverb" "$positional_count" "$cur"
|
|
150
242
|
fi
|
|
151
243
|
;;
|
|
152
244
|
themes)
|
|
@@ -171,8 +263,8 @@ _quilltap_complete() {
|
|
|
171
263
|
fi
|
|
172
264
|
;;
|
|
173
265
|
instances)
|
|
174
|
-
local inst_verbs="list ls show path where add create remove rm delete set-passphrase passphrase default rename"
|
|
175
|
-
local inst_flags="--names-only --json --clear --help"
|
|
266
|
+
local inst_verbs="list ls show path where add create remove rm delete set-passphrase passphrase default rename restore-key rebuild-key"
|
|
267
|
+
local inst_flags="--names-only --json --clear --passphrase --no-passphrase --data-dir --force --yes --help"
|
|
176
268
|
if [[ -z "$subverb" ]]; then
|
|
177
269
|
if [[ "$cur" == -* ]]; then
|
|
178
270
|
COMPREPLY=($(compgen -W "$inst_flags" -- "$cur"))
|
|
@@ -182,7 +274,7 @@ _quilltap_complete() {
|
|
|
182
274
|
else
|
|
183
275
|
# Most instances verbs take a name as positional; offer registered names
|
|
184
276
|
case "$subverb" in
|
|
185
|
-
show|remove|rm|delete|set-passphrase|passphrase|default|rename)
|
|
277
|
+
show|remove|rm|delete|set-passphrase|passphrase|default|rename|restore-key|rebuild-key)
|
|
186
278
|
local instances=$(command quilltap instances list --names-only 2>/dev/null)
|
|
187
279
|
if [[ "$cur" == -* ]]; then
|
|
188
280
|
COMPREPLY=($(compgen -W "$inst_flags" -- "$cur"))
|
|
@@ -8,6 +8,10 @@ function __quilltap_instance_names
|
|
|
8
8
|
command quilltap instances list --names-only 2>/dev/null
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
+
function __quilltap_mount_names
|
|
12
|
+
command quilltap docs list --names-only 2>/dev/null
|
|
13
|
+
end
|
|
14
|
+
|
|
11
15
|
function __quilltap_no_subcommand
|
|
12
16
|
set -l cmd (commandline -opc)
|
|
13
17
|
if test (count $cmd) -lt 2
|
|
@@ -157,7 +161,7 @@ complete -c quilltap -n '__quilltap_using_subcommand docs' -f -a 'rmdir' -d 'Rem
|
|
|
157
161
|
complete -c quilltap -n '__quilltap_using_subcommand docs' -f -a 'mvdir' -d 'Rename or move a folder'
|
|
158
162
|
|
|
159
163
|
# docs flags
|
|
160
|
-
complete -c quilltap -n '__quilltap_using_subcommand docs' -l 'mount' -d 'Mount name or id' -x
|
|
164
|
+
complete -c quilltap -n '__quilltap_using_subcommand docs' -l 'mount' -d 'Mount name or id' -x -a '(__quilltap_mount_names)'
|
|
161
165
|
complete -c quilltap -n '__quilltap_using_subcommand docs' -l 'port' -s 'p' -d 'Server port' -x
|
|
162
166
|
complete -c quilltap -n '__quilltap_using_subcommand docs' -l 'folder' -d 'Folder filter' -x
|
|
163
167
|
complete -c quilltap -n '__quilltap_using_subcommand docs' -l 'force' -d 'Force operation'
|
|
@@ -180,6 +184,9 @@ complete -c quilltap -n '__quilltap_using_subcommand docs' -l 'depth' -d 'Maximu
|
|
|
180
184
|
complete -c quilltap -n '__quilltap_using_subcommand docs' -l 'max-nodes' -d 'Maximum graph nodes' -x
|
|
181
185
|
complete -c quilltap -n '__quilltap_using_subcommand docs' -l 'long' -d 'Long-form output'
|
|
182
186
|
complete -c quilltap -n '__quilltap_using_subcommand docs' -l 'semantic' -d 'Semantic search'
|
|
187
|
+
complete -c quilltap -n '__quilltap_using_subcommand docs' -l 'uri' -d 'Show canonical qtap:// URIs'
|
|
188
|
+
complete -c quilltap -n '__quilltap_using_subcommand docs' -l 'base64' -d 'Base64 transfer for binary files'
|
|
189
|
+
complete -c quilltap -n '__quilltap_using_subverb docs docker-mounts' -l 'format' -d 'Output shape' -x -a 'args json'
|
|
183
190
|
|
|
184
191
|
# ---------- themes verbs ----------
|
|
185
192
|
complete -c quilltap -n '__quilltap_using_subcommand themes' -f -a 'list' -d 'List themes'
|
|
@@ -218,14 +225,23 @@ complete -c quilltap -n '__quilltap_using_subcommand instances' -f -a 'set-passp
|
|
|
218
225
|
complete -c quilltap -n '__quilltap_using_subcommand instances' -f -a 'passphrase' -d 'Set passphrase'
|
|
219
226
|
complete -c quilltap -n '__quilltap_using_subcommand instances' -f -a 'default' -d 'Set/show/clear default instance'
|
|
220
227
|
complete -c quilltap -n '__quilltap_using_subcommand instances' -f -a 'rename' -d 'Rename instance'
|
|
228
|
+
complete -c quilltap -n '__quilltap_using_subcommand instances' -f -a 'restore-key' -d 'Rebuild .dbkey from the pepper'
|
|
229
|
+
complete -c quilltap -n '__quilltap_using_subcommand instances' -f -a 'rebuild-key' -d 'Rebuild .dbkey from the pepper'
|
|
221
230
|
|
|
222
231
|
# Instance names as positional for verbs that target one
|
|
223
|
-
for verb in show remove rm delete set-passphrase passphrase default rename
|
|
232
|
+
for verb in show remove rm delete set-passphrase passphrase default rename restore-key rebuild-key
|
|
224
233
|
complete -c quilltap -n "__quilltap_using_subverb instances $verb" -f -a '(__quilltap_instance_names)'
|
|
225
234
|
end
|
|
226
235
|
|
|
227
236
|
complete -c quilltap -n '__quilltap_using_subcommand instances' -l 'names-only' -d 'Print one name per line'
|
|
228
237
|
complete -c quilltap -n '__quilltap_using_subverb instances default' -l 'clear' -d 'Clear default instance'
|
|
238
|
+
for verb in restore-key rebuild-key
|
|
239
|
+
complete -c quilltap -n "__quilltap_using_subverb instances $verb" -l 'passphrase' -d 'Passphrase for the rebuilt .dbkey'
|
|
240
|
+
complete -c quilltap -n "__quilltap_using_subverb instances $verb" -l 'no-passphrase' -d 'Rebuild with no passphrase'
|
|
241
|
+
complete -c quilltap -n "__quilltap_using_subverb instances $verb" -s 'd' -l 'data-dir' -r -d 'Instance root to rebuild in'
|
|
242
|
+
complete -c quilltap -n "__quilltap_using_subverb instances $verb" -l 'force' -d 'Write with no database to prove against'
|
|
243
|
+
complete -c quilltap -n "__quilltap_using_subverb instances $verb" -s 'y' -l 'yes' -d 'Skip confirmation prompts'
|
|
244
|
+
end
|
|
229
245
|
|
|
230
246
|
# ---------- memories verbs ----------
|
|
231
247
|
complete -c quilltap -n '__quilltap_using_subcommand memories' -f -a 'ls' -d 'List memories'
|