| 1369 | } |
| 1370 | |
| 1371 | func resolveMemoryContentValue(deps commandDeps, raw string, stdin io.Reader) (string, error) { |
| 1372 | trimmed := strings.TrimSpace(raw) |
| 1373 | if trimmed == "" { |
| 1374 | return "", errors.New("memory.content_required: content is required") |
| 1375 | } |
| 1376 | if trimmed == "-" { |
| 1377 | content, err := readOptionalCommandInput(stdin) |
| 1378 | if err != nil { |
| 1379 | return "", err |
| 1380 | } |
| 1381 | if strings.TrimSpace(content) == "" { |
| 1382 | return "", errors.New("memory.content_required: stdin content is required") |
| 1383 | } |
| 1384 | return content, nil |
| 1385 | } |
| 1386 | if after, ok := strings.CutPrefix(trimmed, "@"); ok { |
| 1387 | path := strings.TrimSpace(after) |
| 1388 | if path == "" { |
| 1389 | return "", errors.New("memory.content_path_required: @ content path is required") |
| 1390 | } |
| 1391 | cleaned := filepath.Clean(path) |
| 1392 | if !filepath.IsAbs(cleaned) && deps.getwd != nil { |
| 1393 | wd, err := currentWorkingDirectory(deps) |
| 1394 | if err != nil { |
| 1395 | return "", err |
| 1396 | } |
| 1397 | cleaned = filepath.Join(wd, cleaned) |
| 1398 | } |
| 1399 | data, err := os.ReadFile(cleaned) |
| 1400 | if err != nil { |
| 1401 | return "", fmt.Errorf("memory.content_read_failed: read %s: %w", cleaned, err) |
| 1402 | } |
| 1403 | if strings.TrimSpace(string(data)) == "" { |
| 1404 | return "", errors.New("memory.content_required: file content is required") |
| 1405 | } |
| 1406 | return string(data), nil |
| 1407 | } |
| 1408 | return raw, nil |
| 1409 | } |
| 1410 | |
| 1411 | func readOptionalCommandInput(reader io.Reader) (string, error) { |
| 1412 | if reader == nil { |