Skip to content

Commit df6c106

Browse files
committed
(human) massive rework of agentic subsystem
1 parent 50f1e84 commit df6c106

File tree

124 files changed

+5505
-1379
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+5505
-1379
lines changed

.hof/shadow/cli/cmd/hof/cmd/agent.go

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,69 @@ import (
44
"fmt"
55
"os"
66

7+
"path/filepath"
8+
79
"github.com/spf13/cobra"
810

11+
"github.com/hofstadter-io/hof/lib/runtime"
12+
13+
libagentcmd "github.com/hofstadter-io/hof/lib/agent/cmd"
14+
15+
"github.com/hofstadter-io/hof/cmd/hof/cmd/agent"
16+
917
"github.com/hofstadter-io/hof/cmd/hof/flags"
1018

1119
"github.com/hofstadter-io/hof/cmd/hof/ga"
1220
)
1321

14-
var agentLong = `Run an agent`
22+
var agentLong = `build, use, evaluate, and serve agentic systems`
1523

1624
func init() {
1725

18-
flags.SetupAgentFlags(AgentCmd.Flags(), &(flags.AgentFlags))
26+
flags.SetupAgentPflags(AgentCmd.PersistentFlags(), &(flags.AgentPflags))
1927

2028
}
2129

30+
func AgentPersistentPreRun(args []string) (err error) {
31+
32+
err = runtime.EnsureInfra()
33+
34+
return err
35+
}
36+
2237
func AgentRun(args []string) (err error) {
2338

24-
// you can safely comment this print out
25-
fmt.Println("not implemented")
39+
err = libagentcmd.Main(args, flags.RootPflags, flags.AgentPflags, flags.Agent__ChatPflags)
2640

2741
return err
2842
}
2943

3044
var AgentCmd = &cobra.Command{
3145

32-
Use: "agent [args]",
46+
Use: "agent [...target] [% ...cue]",
3347

34-
Short: "run an agent",
48+
Short: "build, chat with, and serve agentic systems",
3549

3650
Long: agentLong,
3751

52+
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
53+
glob := toComplete + "*"
54+
matches, _ := filepath.Glob(glob)
55+
return matches, cobra.ShellCompDirectiveDefault
56+
},
57+
58+
PersistentPreRun: func(cmd *cobra.Command, args []string) {
59+
var err error
60+
61+
// Argument Parsing
62+
63+
err = AgentPersistentPreRun(args)
64+
if err != nil {
65+
fmt.Println(err)
66+
os.Exit(1)
67+
}
68+
},
69+
3870
Run: func(cmd *cobra.Command, args []string) {
3971

4072
ga.SendCommandPath(cmd.CommandPath())
@@ -85,4 +117,10 @@ func init() {
85117
AgentCmd.SetHelpFunc(thelp)
86118
AgentCmd.SetUsageFunc(tusage)
87119

120+
AgentCmd.AddCommand(cmdagent.ListCmd)
121+
AgentCmd.AddCommand(cmdagent.ChatCmd)
122+
AgentCmd.AddCommand(cmdagent.ServeCmd)
123+
AgentCmd.AddCommand(cmdagent.BulkCmd)
124+
AgentCmd.AddCommand(cmdagent.EvalCmd)
125+
88126
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
package cmdagent
2+
3+
import (
4+
"fmt"
5+
"os"
6+
7+
"github.com/spf13/cobra"
8+
9+
libagentcmd "github.com/hofstadter-io/hof/lib/agent/cmd"
10+
11+
"github.com/hofstadter-io/hof/cmd/hof/flags"
12+
13+
"github.com/hofstadter-io/hof/cmd/hof/ga"
14+
)
15+
16+
var bulkLong = `bulk process with agents`
17+
18+
func BulkRun(args []string) (err error) {
19+
20+
err = libagentcmd.Bulk(args, flags.RootPflags, flags.AgentPflags)
21+
22+
return err
23+
}
24+
25+
var BulkCmd = &cobra.Command{
26+
27+
Use: "bulk [...target] [% ...cue]",
28+
29+
Short: "bulk process with agents",
30+
31+
Long: bulkLong,
32+
33+
Run: func(cmd *cobra.Command, args []string) {
34+
35+
ga.SendCommandPath(cmd.CommandPath())
36+
37+
var err error
38+
39+
// Argument Parsing
40+
41+
err = BulkRun(args)
42+
if err != nil {
43+
fmt.Println(err)
44+
os.Exit(1)
45+
}
46+
},
47+
}
48+
49+
func init() {
50+
extra := func(cmd *cobra.Command) bool {
51+
52+
return false
53+
}
54+
55+
ohelp := BulkCmd.HelpFunc()
56+
ousage := BulkCmd.UsageFunc()
57+
58+
help := func(cmd *cobra.Command, args []string) {
59+
60+
ga.SendCommandPath(cmd.CommandPath() + " help")
61+
62+
if extra(cmd) {
63+
return
64+
}
65+
ohelp(cmd, args)
66+
}
67+
usage := func(cmd *cobra.Command) error {
68+
if extra(cmd) {
69+
return nil
70+
}
71+
return ousage(cmd)
72+
}
73+
74+
thelp := func(cmd *cobra.Command, args []string) {
75+
help(cmd, args)
76+
}
77+
tusage := func(cmd *cobra.Command) error {
78+
return usage(cmd)
79+
}
80+
BulkCmd.SetHelpFunc(thelp)
81+
BulkCmd.SetUsageFunc(tusage)
82+
83+
}
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
package cmdagent
2+
3+
import (
4+
"fmt"
5+
"os"
6+
7+
"path/filepath"
8+
9+
"github.com/spf13/cobra"
10+
11+
libagentcmd "github.com/hofstadter-io/hof/lib/agent/cmd"
12+
13+
"github.com/hofstadter-io/hof/cmd/hof/flags"
14+
15+
"github.com/hofstadter-io/hof/cmd/hof/cmd/agent/chat"
16+
17+
"github.com/hofstadter-io/hof/cmd/hof/flags"
18+
19+
"github.com/hofstadter-io/hof/cmd/hof/ga"
20+
)
21+
22+
var chatLong = `chat with an agent`
23+
24+
func init() {
25+
26+
flags.SetupAgent__ChatPflags(ChatCmd.PersistentFlags(), &(flags.Agent__ChatPflags))
27+
28+
}
29+
30+
func ChatRun(args []string) (err error) {
31+
32+
err = libagentcmd.Chat(args, flags.RootPflags, flags.AgentPflags, flags.Agent__ChatPflags)
33+
34+
return err
35+
}
36+
37+
var ChatCmd = &cobra.Command{
38+
39+
Use: "chat [...target] [% ...cue]",
40+
41+
Short: "chat with an agent",
42+
43+
Long: chatLong,
44+
45+
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
46+
glob := toComplete + "*"
47+
matches, _ := filepath.Glob(glob)
48+
return matches, cobra.ShellCompDirectiveDefault
49+
},
50+
51+
Run: func(cmd *cobra.Command, args []string) {
52+
53+
ga.SendCommandPath(cmd.CommandPath())
54+
55+
var err error
56+
57+
// Argument Parsing
58+
59+
err = ChatRun(args)
60+
if err != nil {
61+
fmt.Println(err)
62+
os.Exit(1)
63+
}
64+
},
65+
}
66+
67+
func init() {
68+
extra := func(cmd *cobra.Command) bool {
69+
70+
return false
71+
}
72+
73+
ohelp := ChatCmd.HelpFunc()
74+
ousage := ChatCmd.UsageFunc()
75+
76+
help := func(cmd *cobra.Command, args []string) {
77+
78+
ga.SendCommandPath(cmd.CommandPath() + " help")
79+
80+
if extra(cmd) {
81+
return
82+
}
83+
ohelp(cmd, args)
84+
}
85+
usage := func(cmd *cobra.Command) error {
86+
if extra(cmd) {
87+
return nil
88+
}
89+
return ousage(cmd)
90+
}
91+
92+
thelp := func(cmd *cobra.Command, args []string) {
93+
help(cmd, args)
94+
}
95+
tusage := func(cmd *cobra.Command) error {
96+
return usage(cmd)
97+
}
98+
ChatCmd.SetHelpFunc(thelp)
99+
ChatCmd.SetUsageFunc(tusage)
100+
101+
ChatCmd.AddCommand(cmdchat.InfoCmd)
102+
ChatCmd.AddCommand(cmdchat.ListCmd)
103+
ChatCmd.AddCommand(cmdchat.DeleteCmd)
104+
105+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
package cmdchat
2+
3+
import (
4+
"fmt"
5+
"os"
6+
7+
"github.com/spf13/cobra"
8+
9+
libagentcmd "github.com/hofstadter-io/hof/lib/agent/cmd"
10+
11+
"github.com/hofstadter-io/hof/cmd/hof/flags"
12+
13+
"github.com/hofstadter-io/hof/cmd/hof/ga"
14+
)
15+
16+
var deleteLong = `delete sessions for given targets`
17+
18+
func DeleteRun(args []string) (err error) {
19+
20+
err = libagentcmd.ChatList(args, flags.RootPflags, flags.AgentPflags, flags.Agent__ChatPflags)
21+
22+
return err
23+
}
24+
25+
var DeleteCmd = &cobra.Command{
26+
27+
Use: "delete [...target] [% ...cue]",
28+
29+
Short: "delete sessions for given targets",
30+
31+
Long: deleteLong,
32+
33+
Run: func(cmd *cobra.Command, args []string) {
34+
35+
ga.SendCommandPath(cmd.CommandPath())
36+
37+
var err error
38+
39+
// Argument Parsing
40+
41+
err = DeleteRun(args)
42+
if err != nil {
43+
fmt.Println(err)
44+
os.Exit(1)
45+
}
46+
},
47+
}
48+
49+
func init() {
50+
extra := func(cmd *cobra.Command) bool {
51+
52+
return false
53+
}
54+
55+
ohelp := DeleteCmd.HelpFunc()
56+
ousage := DeleteCmd.UsageFunc()
57+
58+
help := func(cmd *cobra.Command, args []string) {
59+
60+
ga.SendCommandPath(cmd.CommandPath() + " help")
61+
62+
if extra(cmd) {
63+
return
64+
}
65+
ohelp(cmd, args)
66+
}
67+
usage := func(cmd *cobra.Command) error {
68+
if extra(cmd) {
69+
return nil
70+
}
71+
return ousage(cmd)
72+
}
73+
74+
thelp := func(cmd *cobra.Command, args []string) {
75+
help(cmd, args)
76+
}
77+
tusage := func(cmd *cobra.Command) error {
78+
return usage(cmd)
79+
}
80+
DeleteCmd.SetHelpFunc(thelp)
81+
DeleteCmd.SetUsageFunc(tusage)
82+
83+
}

0 commit comments

Comments
 (0)