@fs/mycroft 0.1.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.
- package/README.md +73 -0
- package/bin/mycroft.js +2 -0
- package/completions/mycroft.bash +46 -0
- package/completions/mycroft.fish +40 -0
- package/completions/mycroft.zsh +54 -0
- package/dist/cli.js +1324 -0
- package/dist/cli.js.map +1 -0
- package/package.json +38 -0
package/README.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# mycroft-cli
|
|
2
|
+
|
|
3
|
+
Command-line tool that ingests EPUB files, builds a local searchable index, and answers questions using a retrieval-augmented workflow.
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
- Node.js >= 18
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install -g @fs/mycroft
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Ensure `node` is on your PATH (the CLI uses Node.js as its runtime).
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
mycroft book list
|
|
21
|
+
mycroft book ingest /path/to/book.epub
|
|
22
|
+
mycroft book ask <id> "What is the main conflict?"
|
|
23
|
+
mycroft config init
|
|
24
|
+
mycroft config resolve
|
|
25
|
+
mycroft config onboard
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Local dev
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install
|
|
32
|
+
npm run build
|
|
33
|
+
node dist/cli.js --help
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Config
|
|
37
|
+
|
|
38
|
+
Default config path:
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
~/.config/mycroft/config.json
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Default config:
|
|
45
|
+
|
|
46
|
+
```json
|
|
47
|
+
{
|
|
48
|
+
"dataDir": "~/.local/share/mycroft",
|
|
49
|
+
"askEnabled": true,
|
|
50
|
+
"models": {
|
|
51
|
+
"embedding": "text-embedding-3-small",
|
|
52
|
+
"summary": "gpt-5-nano",
|
|
53
|
+
"chat": "gpt-5.1"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Environment overrides:
|
|
59
|
+
|
|
60
|
+
- `MYCROFT_DATA_DIR`
|
|
61
|
+
- `MYCROFT_CONFIG`
|
|
62
|
+
- `OPENAI_API_KEY`
|
|
63
|
+
|
|
64
|
+
`OPENAI_API_KEY` is required for embeddings, search, and Q&A (and for summaries if enabled).
|
|
65
|
+
|
|
66
|
+
CLI overrides:
|
|
67
|
+
|
|
68
|
+
- `--data-dir <path>` (global)
|
|
69
|
+
- `--max-chapter <n>`
|
|
70
|
+
- `--top-k <n>`
|
|
71
|
+
- `--manual` (interactive chapter selection)
|
|
72
|
+
- `--summary`
|
|
73
|
+
- `--force`
|
package/bin/mycroft.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
_mycroft() {
|
|
2
|
+
local cur prev
|
|
3
|
+
cur="${COMP_WORDS[COMP_CWORD]}"
|
|
4
|
+
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
|
5
|
+
|
|
6
|
+
local top_commands="book config"
|
|
7
|
+
local global_flags="--help --version --data-dir"
|
|
8
|
+
local book_commands="ingest list show ask search delete"
|
|
9
|
+
local config_commands="path init resolve onboard"
|
|
10
|
+
|
|
11
|
+
if [[ ${COMP_CWORD} -le 1 ]]; then
|
|
12
|
+
COMPREPLY=( $(compgen -W "${top_commands} ${global_flags}" -- "${cur}") )
|
|
13
|
+
return 0
|
|
14
|
+
fi
|
|
15
|
+
|
|
16
|
+
case "${COMP_WORDS[1]}" in
|
|
17
|
+
book)
|
|
18
|
+
if [[ ${COMP_CWORD} -eq 2 ]]; then
|
|
19
|
+
COMPREPLY=( $(compgen -W "${book_commands} ${global_flags}" -- "${cur}") )
|
|
20
|
+
return 0
|
|
21
|
+
fi
|
|
22
|
+
case "${COMP_WORDS[2]}" in
|
|
23
|
+
ingest)
|
|
24
|
+
COMPREPLY=( $(compgen -W "--manual --no-summary" -- "${cur}") )
|
|
25
|
+
return 0
|
|
26
|
+
;;
|
|
27
|
+
ask|search)
|
|
28
|
+
COMPREPLY=( $(compgen -W "--top-k --max-chapter" -- "${cur}") )
|
|
29
|
+
return 0
|
|
30
|
+
;;
|
|
31
|
+
delete)
|
|
32
|
+
COMPREPLY=( $(compgen -W "--force" -- "${cur}") )
|
|
33
|
+
return 0
|
|
34
|
+
;;
|
|
35
|
+
esac
|
|
36
|
+
;;
|
|
37
|
+
config)
|
|
38
|
+
if [[ ${COMP_CWORD} -eq 2 ]]; then
|
|
39
|
+
COMPREPLY=( $(compgen -W "${config_commands} ${global_flags}" -- "${cur}") )
|
|
40
|
+
return 0
|
|
41
|
+
fi
|
|
42
|
+
;;
|
|
43
|
+
esac
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
complete -F _mycroft mycroft
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
function __mycroft_needs_command
|
|
2
|
+
set -l cmd (commandline -opc)
|
|
3
|
+
if test (count $cmd) -le 1
|
|
4
|
+
return 0
|
|
5
|
+
end
|
|
6
|
+
return 1
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
function __mycroft_using_command
|
|
10
|
+
set -l cmd (commandline -opc)
|
|
11
|
+
set -l sub $argv[1]
|
|
12
|
+
if test (count $cmd) -ge 2; and test $cmd[2] = $sub
|
|
13
|
+
return 0
|
|
14
|
+
end
|
|
15
|
+
return 1
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
complete -c mycroft -n '__mycroft_needs_command' -a 'book' -d 'Manage books and queries'
|
|
19
|
+
complete -c mycroft -n '__mycroft_needs_command' -a 'config' -d 'Manage configuration'
|
|
20
|
+
complete -c mycroft -s h -l help -d 'Show help'
|
|
21
|
+
complete -c mycroft -l version -d 'Show version'
|
|
22
|
+
complete -c mycroft -l data-dir -r -d 'Override data directory'
|
|
23
|
+
|
|
24
|
+
complete -c mycroft -n '__mycroft_using_command book' -a 'ingest' -d 'Ingest an EPUB file'
|
|
25
|
+
complete -c mycroft -n '__mycroft_using_command book' -a 'list' -d 'List indexed books'
|
|
26
|
+
complete -c mycroft -n '__mycroft_using_command book' -a 'show' -d 'Show full book metadata'
|
|
27
|
+
complete -c mycroft -n '__mycroft_using_command book' -a 'ask' -d 'Ask a question about a book'
|
|
28
|
+
complete -c mycroft -n '__mycroft_using_command book' -a 'search' -d 'Vector search without LLM'
|
|
29
|
+
complete -c mycroft -n '__mycroft_using_command book' -a 'delete' -d 'Remove book, EPUB, and vectors'
|
|
30
|
+
|
|
31
|
+
complete -c mycroft -n '__mycroft_using_command book; and __fish_seen_subcommand_from ingest' -l manual -d 'Interactive chapter selection'
|
|
32
|
+
complete -c mycroft -n '__mycroft_using_command book; and __fish_seen_subcommand_from ingest' -l no-summary -d 'Skip AI chapter summaries'
|
|
33
|
+
complete -c mycroft -n '__mycroft_using_command book; and __fish_seen_subcommand_from ask search' -l top-k -r -d 'Number of passages to retrieve'
|
|
34
|
+
complete -c mycroft -n '__mycroft_using_command book; and __fish_seen_subcommand_from ask search' -l max-chapter -r -d 'Spoiler-free limit'
|
|
35
|
+
complete -c mycroft -n '__mycroft_using_command book; and __fish_seen_subcommand_from delete' -l force -d 'Skip confirmation'
|
|
36
|
+
|
|
37
|
+
complete -c mycroft -n '__mycroft_using_command config' -a 'path' -d 'Print config path'
|
|
38
|
+
complete -c mycroft -n '__mycroft_using_command config' -a 'init' -d 'Create default config file'
|
|
39
|
+
complete -c mycroft -n '__mycroft_using_command config' -a 'resolve' -d 'Print resolved config values'
|
|
40
|
+
complete -c mycroft -n '__mycroft_using_command config' -a 'onboard' -d 'Initialize config and show next step'
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#compdef mycroft
|
|
2
|
+
|
|
3
|
+
_mycroft() {
|
|
4
|
+
local -a top_commands
|
|
5
|
+
top_commands=(book config)
|
|
6
|
+
|
|
7
|
+
local -a book_commands
|
|
8
|
+
book_commands=(ingest list show ask search delete)
|
|
9
|
+
|
|
10
|
+
local -a config_commands
|
|
11
|
+
config_commands=(path init resolve onboard)
|
|
12
|
+
|
|
13
|
+
local -a global_flags
|
|
14
|
+
global_flags=(--help --version --data-dir)
|
|
15
|
+
|
|
16
|
+
if (( CURRENT == 2 )); then
|
|
17
|
+
_describe -t commands "mycroft commands" top_commands
|
|
18
|
+
_describe -t flags "global flags" global_flags
|
|
19
|
+
return
|
|
20
|
+
fi
|
|
21
|
+
|
|
22
|
+
case ${words[2]} in
|
|
23
|
+
book)
|
|
24
|
+
if (( CURRENT == 3 )); then
|
|
25
|
+
_describe -t commands "book commands" book_commands
|
|
26
|
+
_describe -t flags "global flags" global_flags
|
|
27
|
+
return
|
|
28
|
+
fi
|
|
29
|
+
case ${words[3]} in
|
|
30
|
+
ingest)
|
|
31
|
+
_arguments "--manual[Interactive chapter selection]" "--no-summary[Skip AI chapter summaries]"
|
|
32
|
+
return
|
|
33
|
+
;;
|
|
34
|
+
ask|search)
|
|
35
|
+
_arguments "--top-k[Number of passages to retrieve]:n" "--max-chapter[Spoiler-free limit]:n"
|
|
36
|
+
return
|
|
37
|
+
;;
|
|
38
|
+
delete)
|
|
39
|
+
_arguments "--force[Skip confirmation]"
|
|
40
|
+
return
|
|
41
|
+
;;
|
|
42
|
+
esac
|
|
43
|
+
;;
|
|
44
|
+
config)
|
|
45
|
+
if (( CURRENT == 3 )); then
|
|
46
|
+
_describe -t commands "config commands" config_commands
|
|
47
|
+
_describe -t flags "global flags" global_flags
|
|
48
|
+
return
|
|
49
|
+
fi
|
|
50
|
+
;;
|
|
51
|
+
esac
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
_mycroft
|