chore: refactor agent to skill-first; structured skills dirs; enhance ReAct and tool logs

This commit is contained in:
whlaoding
2026-02-21 23:29:27 +08:00
parent c2bebb3457
commit e1c7822ed4
9 changed files with 333 additions and 107 deletions

View File

@@ -38,7 +38,7 @@ func (t *Tool) Description() string {
func (t *Tool) Call(_ context.Context, input string) (string, error) {
input = strings.TrimSpace(input)
if t.log != nil {
t.log.Debugf("file tool call input_len=%d", len(input))
t.log.Infof("file tool call input_len=%d input=%q", len(input), input)
}
if strings.HasPrefix(input, "read ") {
path := strings.TrimSpace(strings.TrimPrefix(input, "read "))

View File

@@ -58,12 +58,12 @@ func (t *Tool) Call(ctx context.Context, input string) (string, error) {
base := parts[0]
if _, ok := t.allowedCommands[base]; !ok {
if t.log != nil {
t.log.Warnf("shell command denied command=%s", base)
t.log.Warnf("shell command denied command=%s full_command=%q", base, trimmed)
}
return "", fmt.Errorf("command not allowed: %s", base)
}
if t.log != nil {
t.log.Infof("shell command start command=%s args=%d", base, len(parts)-1)
t.log.Infof("shell command start command=%s args=%d full_command=%q", base, len(parts)-1, trimmed)
}
runCtx, cancel := context.WithTimeout(ctx, t.timeout)
@@ -74,12 +74,12 @@ func (t *Tool) Call(ctx context.Context, input string) (string, error) {
out, err := cmd.CombinedOutput()
if err != nil {
if t.log != nil {
t.log.Errorf("shell command failed command=%s err=%v output_bytes=%d", base, err, len(out))
t.log.Errorf("shell command failed command=%s full_command=%q err=%v output_bytes=%d output=%q", base, trimmed, err, len(out), string(out))
}
return string(out), err
}
if t.log != nil {
t.log.Debugf("shell command success command=%s output_bytes=%d", base, len(out))
t.log.Infof("shell command success command=%s full_command=%q output_bytes=%d output=%q", base, trimmed, len(out), string(out))
}
return string(out), nil
}