From 4dc269f0c22a93befa0b444025a2f21a6d844cd9 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sun, 8 Mar 2026 00:29:33 -0700 Subject: [PATCH] =?UTF-8?q?feat(jsontypes):=20wire=20jsonpaths=20CLI=20to?= =?UTF-8?q?=20use=20RawPaths=E2=86=92Coalesce=20pipeline?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In anonymous mode (-anonymous), jsonpaths now uses the deterministic pipeline (RawPaths → Coalesce → Generate) instead of the legacy analyzer. Interactive mode still uses the old analyzer with resolver. --- tools/jsontypes/cmd/jsonpaths/main.go | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/tools/jsontypes/cmd/jsonpaths/main.go b/tools/jsontypes/cmd/jsonpaths/main.go index 8cff372..2d35c1e 100644 --- a/tools/jsontypes/cmd/jsonpaths/main.go +++ b/tools/jsontypes/cmd/jsonpaths/main.go @@ -166,9 +166,14 @@ func main() { os.Exit(1) } - var resolver jsontypes.Resolver + var formatted []string var pr *prompter - if !*anonymous { + if *anonymous { + // Pipeline mode: RawPaths → Coalesce → Generate (deterministic, no prompts). + raw := jsontypes.RawPaths(data) + formatted = jsontypes.Coalesce(raw) + } else { + // Interactive mode: use legacy analyzer with resolver. pr, err = newPrompter(inputIsStdin) if err != nil { fmt.Fprintf(os.Stderr, "error: %v\n", err) @@ -178,15 +183,14 @@ func main() { if baseName != "" { pr.loadAnswers(baseName + ".answers") } - resolver = newCLIResolver(pr) + resolver := newCLIResolver(pr) + a := jsontypes.New(jsontypes.AnalyzerConfig{ + Resolver: resolver, + AskTypes: *askTypes, + }) + rawPaths := a.Analyze(".", data) + formatted = jsontypes.FormatPaths(rawPaths) } - a := jsontypes.New(jsontypes.AnalyzerConfig{ - Resolver: resolver, - AskTypes: *askTypes, - }) - - rawPaths := a.Analyze(".", data) - formatted := jsontypes.FormatPaths(rawPaths) out, err := jsontypes.Generate(outFormat, formatted) if err != nil { @@ -202,7 +206,7 @@ func main() { fmt.Fprintf(os.Stderr, "warning: could not write %s: %v\n", pathsFile, err) } - if !*anonymous && pr != nil { + if pr != nil { answersFile := baseName + ".answers" if err := pr.saveAnswers(answersFile); err != nil { fmt.Fprintf(os.Stderr, "warning: could not write %s: %v\n", answersFile, err)