System prompt gets a one-line summary (~200 chars): OS, CPU, RAM, GPU, top runtimes, package count, PATH command count. Full details available on demand via system_info tool with sections: runtimes, packages, tools, hardware, all. LLM calls the tool when it needs specifics — saves thousands of tokens per request. Hardware detection: CPU model, core count, total RAM, GPU via lspci. Package manager: pacman/apt/dnf/brew with dev package filtering. PATH scan: 5541 executables. Runtime probing: 22 detected.
51 lines
1.3 KiB
Go
51 lines
1.3 KiB
Go
package sysinfo
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
|
|
"somegit.dev/Owlibou/gnoma/internal/tool"
|
|
"somegit.dev/Owlibou/gnoma/internal/tool/bash"
|
|
)
|
|
|
|
var paramSchema = json.RawMessage(`{
|
|
"type": "object",
|
|
"properties": {
|
|
"section": {
|
|
"type": "string",
|
|
"description": "Section to query: runtimes, packages, tools, hardware, all",
|
|
"enum": ["runtimes", "packages", "tools", "hardware", "all"]
|
|
}
|
|
}
|
|
}`)
|
|
|
|
// Tool provides queryable access to system inventory.
|
|
type Tool struct {
|
|
inventory *bash.SystemInventory
|
|
}
|
|
|
|
func New(inv *bash.SystemInventory) *Tool {
|
|
return &Tool{inventory: inv}
|
|
}
|
|
|
|
func (t *Tool) Name() string { return "system_info" }
|
|
func (t *Tool) Description() string { return "Query system information: installed runtimes, packages, tools, hardware" }
|
|
func (t *Tool) Parameters() json.RawMessage { return paramSchema }
|
|
func (t *Tool) IsReadOnly() bool { return true }
|
|
func (t *Tool) IsDestructive() bool { return false }
|
|
|
|
type sysInfoArgs struct {
|
|
Section string `json:"section,omitempty"`
|
|
}
|
|
|
|
func (t *Tool) Execute(_ context.Context, args json.RawMessage) (tool.Result, error) {
|
|
var a sysInfoArgs
|
|
if args != nil {
|
|
_ = json.Unmarshal(args, &a)
|
|
}
|
|
if a.Section == "" {
|
|
a.Section = "all"
|
|
}
|
|
return tool.Result{Output: t.inventory.QuerySection(a.Section)}, nil
|
|
}
|