You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use `--with-context` when a structural match is not enough by itself and the caller also needs the source block a human would inspect. This keeps `query` precise while adding neutral source facts such as the owning function, method, class, attached comments, and enclosing calls.
The default JSON fields remain available. With context enabled, each result can also include:
176
+
177
+
```json
178
+
{
179
+
"schema_version": "probe.query.context.v1",
180
+
"results": [
181
+
{
182
+
"file": "src/api.ts",
183
+
"lines": [4, 4],
184
+
"node_type": "match",
185
+
"content": "fetch(url)",
186
+
"column_start": 10,
187
+
"column_end": 20,
188
+
"language": "typescript",
189
+
"pattern": {
190
+
"source": "fetch($$$ARGS)",
191
+
"id": null
192
+
},
193
+
"match": {
194
+
"node_type": "call_expression",
195
+
"content": "fetch(url)",
196
+
"lines": [4, 4],
197
+
"columns": [10, 20]
198
+
},
199
+
"owner": {
200
+
"symbol": "loadProfile",
201
+
"qualified_symbol": "loadProfile",
202
+
"node_type": "function_declaration",
203
+
"scope": "function",
204
+
"lines": [2, 5],
205
+
"columns": [1, 2],
206
+
"comments": [
207
+
{
208
+
"kind": "leading",
209
+
"start_line": 1,
210
+
"end_line": 1,
211
+
"text": "// Network boundary: user profile API client."
212
+
}
213
+
]
214
+
}
215
+
}
216
+
]
217
+
}
218
+
```
219
+
220
+
Probe does not interpret comment contents or apply domain policy. Downstream tools decide whether a comment is a requirement, security annotation, checklist marker, or ordinary text.
Copy file name to clipboardExpand all lines: docs/reference/output-formats.md
+56-1Lines changed: 56 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -125,6 +125,61 @@ The `query` command's JSON output is similar to the search command but includes
125
125
}
126
126
```
127
127
128
+
When `--with-context` or `--owner-context` is used with `--format json`, Probe keeps the compatible result fields and adds source-block context for each structural match:
129
+
130
+
```json
131
+
{
132
+
"schema_version": "probe.query.context.v1",
133
+
"results": [
134
+
{
135
+
"file": "/path/to/api.ts",
136
+
"lines": [4, 4],
137
+
"node_type": "match",
138
+
"content": "fetch(url)",
139
+
"column_start": 10,
140
+
"column_end": 20,
141
+
"language": "typescript",
142
+
"pattern": {
143
+
"source": "fetch($$$ARGS)",
144
+
"id": null
145
+
},
146
+
"match": {
147
+
"node_type": "call_expression",
148
+
"content": "fetch(url)",
149
+
"lines": [4, 4],
150
+
"columns": [10, 20]
151
+
},
152
+
"owner": {
153
+
"symbol": "requestJSON",
154
+
"qualified_symbol": "requestJSON",
155
+
"node_type": "function_declaration",
156
+
"scope": "function",
157
+
"lines": [1, 5],
158
+
"columns": [1, 2],
159
+
"comments": [
160
+
{
161
+
"kind": "leading",
162
+
"start_line": 1,
163
+
"end_line": 1,
164
+
"text": "// Handles outbound API calls."
165
+
}
166
+
],
167
+
"enclosing_symbols": [],
168
+
"enclosing_calls": []
169
+
}
170
+
}
171
+
],
172
+
"summary": {
173
+
"count": 1,
174
+
"total_bytes": 10,
175
+
"total_tokens": 3
176
+
},
177
+
"version": "0.0.0"
178
+
}
179
+
```
180
+
181
+
The context fields are intentionally source facts only. Probe reports owner, match, comment, symbol, and enclosing-call metadata; it does not interpret requirements, policies, test frameworks, or annotation formats.
182
+
128
183
#### Example: Query JSON Output
129
184
130
185
```bash
@@ -622,4 +677,4 @@ Both JSON and XML formats handle special characters appropriately:
622
677
-**JSON**: Special characters in code are properly escaped according to JSON rules
623
678
-**XML**: Code blocks are wrapped in CDATA sections to preserve formatting and special characters
624
679
625
-
This ensures that the output can be reliably parsed regardless of the content of the code.
680
+
This ensures that the output can be reliably parsed regardless of the content of the code.
0 commit comments