MCPcopy Create free account
hub / github.com/ByteYellow/AgentProvenance / intentDiffCmd

Function intentDiffCmd

internal/cli/intent_cmd.go:27–65  ·  view source on GitHub ↗
(dataDir *string)

Source from the content-addressed store, hash-verified

25}
26
27func intentDiffCmd(dataDir *string) *cobra.Command {
28 var runID string
29 var jsonOut bool
30 cmd := &cobra.Command{
31 Use: "diff",
32 Short: "materialize the Intent-Runtime Diff for a run and show findings",
33 Args: cobra.NoArgs,
34 RunE: func(cmd *cobra.Command, args []string) error {
35 if runID == "" {
36 return fmt.Errorf("--run is required")
37 }
38 paths, err := store.Init(*dataDir)
39 if err != nil {
40 return err
41 }
42 db, err := store.Open(paths)
43 if err != nil {
44 return err
45 }
46 defer db.Close()
47
48 res, err := intent.Materialize(db, runID)
49 if err != nil {
50 return err
51 }
52 if jsonOut {
53 enc := json.NewEncoder(cmd.OutOrStdout())
54 enc.SetIndent("", " ")
55 return enc.Encode(res)
56 }
57 fmt.Fprintf(cmd.OutOrStdout(), "run=%s effects=%d contracts=%d diffs=%d mismatches=%d coverage_gaps=%d\n",
58 res.RunID, res.Effects, res.Contracts, res.Diffs, res.Mismatches, res.CoverageGaps)
59 return printIntentDiffs(cmd, db, runID)
60 },
61 }
62 cmd.Flags().StringVar(&runID, "run", "", "run id")
63 cmd.Flags().BoolVar(&jsonOut, "json", false, "emit the machine-readable materialize summary")
64 return cmd
65}
66
67func printIntentDiffs(cmd *cobra.Command, db *sql.DB, runID string) error {
68 rows, err := db.Query(`SELECT status, finding, contract_kind, operation, agent_id, round(confidence,2), mismatch_reason

Callers 1

intentCmdFunction · 0.85

Calls 5

InitFunction · 0.92
OpenFunction · 0.92
MaterializeFunction · 0.92
printIntentDiffsFunction · 0.85
CloseMethod · 0.45

Tested by

no test coverage detected