MCPcopy Create free account
hub / github.com/JordanCoin/codemap / extractFilePathFromStdin

Function extractFilePathFromStdin

cmd/hooks.go:1351–1374  ·  view source on GitHub ↗

extractFilePathFromStdin reads JSON from stdin and extracts file_path

()

Source from the content-addressed store, hash-verified

1349
1350// extractFilePathFromStdin reads JSON from stdin and extracts file_path
1351func extractFilePathFromStdin() (string, error) {
1352 input, err := io.ReadAll(os.Stdin)
1353 if err != nil {
1354 return "", err
1355 }
1356
1357 var data map[string]interface{}
1358 if err := json.Unmarshal(input, &data); err != nil {
1359 // Try regex fallback for non-JSON or partial JSON
1360 re := regexp.MustCompile(`"file_path"\s*:\s*"([^"]+)"`)
1361 matches := re.FindSubmatch(input)
1362 if len(matches) >= 2 {
1363 return string(matches[1]), nil
1364 }
1365 return "", err
1366 }
1367
1368 filePath, ok := data["file_path"].(string)
1369 if !ok {
1370 return "", nil
1371 }
1372
1373 return filePath, nil
1374}
1375
1376// checkFileImporters checks if a file is a hub and shows its importers
1377func checkFileImporters(root, filePath string) error {

Callers 3

hookPreEditFunction · 0.85
hookPostEditFunction · 0.85

Calls

no outgoing calls

Tested by 1