-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcli.py
More file actions
136 lines (106 loc) · 2.78 KB
/
Copy pathcli.py
File metadata and controls
136 lines (106 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import sys
import typer
from dotenv import load_dotenv
from agent.code import explain_repo, pack_repo
from agent.kb import generate_kb_entry, list_kb_entries, remove_kb_entry
from agent.research import start_research
from agent.summary import generate_summary
from agent.think import deep_think
from agent.writer import write_article
load_dotenv()
app = typer.Typer(help="a command line interface for your tiny smart workers.")
kb_app = typer.Typer(help="Commands related to the knowledge base.")
code_app = typer.Typer(help="Commands related to the coding.")
@app.command()
def research(
config: str = typer.Argument(..., help="config file path"),
):
"""
Generate a deep research report for a given topic.
"""
start_research(config)
@app.command()
def think(
config: str = typer.Argument(..., help="config file path"),
):
"""
Deeply think about a given link.
"""
deep_think(config)
@app.command()
def write(
config: str = typer.Argument(None, help="config file path"),
):
"""
Write a new article.
"""
write_article(config)
@app.command()
def summarise(
config: str = typer.Argument(None, help="config file path"),
):
"""
Generate a summary for a given source.
"""
generate_summary(config)
@kb_app.command()
def list(
config: str = typer.Argument(None, help="config file path"),
):
"""
List all knowledge base entries
"""
list_kb_entries(config)
@kb_app.command()
def create(
file: str = typer.Argument(..., help="File for KB entry"),
config: str = typer.Option(None, help="config file path"),
):
"""
Create a new knowledge base entry.
"""
generate_kb_entry(file, config)
@kb_app.command()
def refresh(
file: str = typer.Argument(..., help="File for KB entry"),
config: str = typer.Option(None, help="config file path"),
):
"""
Create a new knowledge base entry.
"""
generate_kb_entry(file, config, True)
@kb_app.command()
def remove(
name: str = typer.Argument(..., help="name for KB entry"),
config: str = typer.Option(None, help="config file path"),
):
"""
Delete a knowledge base entry.
"""
remove_kb_entry(name, config)
@code_app.command()
def explain(
config: str = typer.Argument(..., help="config file path"),
):
"""
Explain a given code repo.
"""
explain_repo(config)
@code_app.command()
def pack(
config: str = typer.Argument(..., help="config file path"),
):
"""
Pack a given code repo.
"""
pack_repo(config)
app.add_typer(kb_app, name="kb")
app.add_typer(code_app, name="code")
def main():
if len(sys.argv) == 1:
sys.argv.append("--help")
elif len(sys.argv) == 2 and sys.argv[1] in ["kb", "code"]:
sys.argv.append("--help")
app()
if __name__ == "__main__":
main()