proofscan 0.10.53 → 0.10.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/shell/filter-mappers.d.ts +23 -0
- package/dist/shell/filter-mappers.d.ts.map +1 -0
- package/dist/shell/filter-mappers.js +36 -0
- package/dist/shell/filter-mappers.js.map +1 -0
- package/dist/shell/find-command.d.ts +54 -0
- package/dist/shell/find-command.d.ts.map +1 -0
- package/dist/shell/find-command.js +330 -0
- package/dist/shell/find-command.js.map +1 -0
- package/dist/shell/pager/index.d.ts +9 -0
- package/dist/shell/pager/index.d.ts.map +1 -0
- package/dist/shell/pager/index.js +8 -0
- package/dist/shell/pager/index.js.map +1 -0
- package/dist/shell/pager/less-pager.d.ts +31 -0
- package/dist/shell/pager/less-pager.d.ts.map +1 -0
- package/dist/shell/pager/less-pager.js +196 -0
- package/dist/shell/pager/less-pager.js.map +1 -0
- package/dist/shell/pager/more-pager.d.ts +31 -0
- package/dist/shell/pager/more-pager.d.ts.map +1 -0
- package/dist/shell/pager/more-pager.js +108 -0
- package/dist/shell/pager/more-pager.js.map +1 -0
- package/dist/shell/pager/renderer.d.ts +17 -0
- package/dist/shell/pager/renderer.d.ts.map +1 -0
- package/dist/shell/pager/renderer.js +125 -0
- package/dist/shell/pager/renderer.js.map +1 -0
- package/dist/shell/pager/types.d.ts +19 -0
- package/dist/shell/pager/types.d.ts.map +1 -0
- package/dist/shell/pager/types.js +7 -0
- package/dist/shell/pager/types.js.map +1 -0
- package/dist/shell/pager/utils.d.ts +28 -0
- package/dist/shell/pager/utils.d.ts.map +1 -0
- package/dist/shell/pager/utils.js +53 -0
- package/dist/shell/pager/utils.js.map +1 -0
- package/dist/shell/pipeline-types.d.ts +51 -0
- package/dist/shell/pipeline-types.d.ts.map +1 -0
- package/dist/shell/pipeline-types.js +8 -0
- package/dist/shell/pipeline-types.js.map +1 -0
- package/dist/shell/repl.d.ts +36 -0
- package/dist/shell/repl.d.ts.map +1 -1
- package/dist/shell/repl.js +408 -5
- package/dist/shell/repl.js.map +1 -1
- package/dist/shell/router-commands.d.ts +7 -0
- package/dist/shell/router-commands.d.ts.map +1 -1
- package/dist/shell/router-commands.js +121 -0
- package/dist/shell/router-commands.js.map +1 -1
- package/dist/shell/types.d.ts +14 -0
- package/dist/shell/types.d.ts.map +1 -1
- package/dist/shell/types.js +16 -1
- package/dist/shell/types.js.map +1 -1
- package/dist/shell/where-command.d.ts +31 -0
- package/dist/shell/where-command.d.ts.map +1 -0
- package/dist/shell/where-command.js +96 -0
- package/dist/shell/where-command.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where Command for psh Shell
|
|
3
|
+
*
|
|
4
|
+
* Filters pipeline rows using Filter DSL v0.1.
|
|
5
|
+
* Reuses parser and evaluator from src/filter/.
|
|
6
|
+
*/
|
|
7
|
+
import { parseFilter } from '../filter/parser.js';
|
|
8
|
+
import { evaluateFilter } from '../filter/evaluator.js';
|
|
9
|
+
import { rpcRowToFilterContext, sessionRowToFilterContext } from './filter-mappers.js';
|
|
10
|
+
/** Fields that only apply to RPC rows */
|
|
11
|
+
const RPC_ONLY_FIELDS = ['rpc.id', 'rpc.method', 'rpc.status', 'rpc.latency', 'tools.name', 'tools.method'];
|
|
12
|
+
/** Fields that only apply to Session rows */
|
|
13
|
+
const SESSION_ONLY_FIELDS = ['session.latency'];
|
|
14
|
+
/**
|
|
15
|
+
* Check if filter uses fields incompatible with the row type
|
|
16
|
+
* Returns warning message if incompatible, null if OK
|
|
17
|
+
*/
|
|
18
|
+
function checkFieldCompatibility(ast, rowType) {
|
|
19
|
+
const usedFields = ast.conditions.map(c => c.field);
|
|
20
|
+
if (rowType === 'session') {
|
|
21
|
+
const rpcFields = usedFields.filter(f => RPC_ONLY_FIELDS.includes(f));
|
|
22
|
+
if (rpcFields.length > 0) {
|
|
23
|
+
return `Field '${rpcFields[0]}' is only available at session level (cd into a session first)`;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (rowType === 'rpc') {
|
|
27
|
+
const sessionFields = usedFields.filter(f => SESSION_ONLY_FIELDS.includes(f));
|
|
28
|
+
if (sessionFields.length > 0) {
|
|
29
|
+
return `Field '${sessionFields[0]}' is only available at connector level`;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Normalize filter expression (strip "filter:" prefix for copy/paste compatibility)
|
|
36
|
+
*/
|
|
37
|
+
function normalizeExpr(expr) {
|
|
38
|
+
let trimmed = expr.trim();
|
|
39
|
+
if (trimmed.toLowerCase().startsWith('filter:')) {
|
|
40
|
+
trimmed = trimmed.slice(7).trim();
|
|
41
|
+
}
|
|
42
|
+
return trimmed;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Apply where filter to pipeline input
|
|
46
|
+
*
|
|
47
|
+
* @param input - Pipeline value (rows or text)
|
|
48
|
+
* @param expr - Filter expression (e.g., 'rpc.method == "tools/call"')
|
|
49
|
+
* @returns Filtered result or error
|
|
50
|
+
*/
|
|
51
|
+
export function applyWhere(input, expr) {
|
|
52
|
+
const normalized = normalizeExpr(expr);
|
|
53
|
+
// Empty expression → pass all through
|
|
54
|
+
if (!normalized) {
|
|
55
|
+
const total = input.kind === 'rows' ? input.rows.length : 0;
|
|
56
|
+
return { ok: true, result: input, stats: { matched: total, total } };
|
|
57
|
+
}
|
|
58
|
+
// Parse the filter expression
|
|
59
|
+
const parseResult = parseFilter(normalized);
|
|
60
|
+
if (!parseResult.ok) {
|
|
61
|
+
return { ok: false, error: parseResult.error, position: parseResult.position };
|
|
62
|
+
}
|
|
63
|
+
// Text input not supported
|
|
64
|
+
if (input.kind === 'text') {
|
|
65
|
+
return { ok: false, error: 'where expects rows; got text. Try `ls` first.' };
|
|
66
|
+
}
|
|
67
|
+
const { rows, rowType } = input;
|
|
68
|
+
// Check for field/rowType compatibility
|
|
69
|
+
const compatError = checkFieldCompatibility(parseResult.ast, rowType);
|
|
70
|
+
if (compatError) {
|
|
71
|
+
return { ok: false, error: compatError };
|
|
72
|
+
}
|
|
73
|
+
// Get appropriate mapper for row type
|
|
74
|
+
const mapper = rowType === 'rpc'
|
|
75
|
+
? rpcRowToFilterContext
|
|
76
|
+
: rowType === 'session'
|
|
77
|
+
? sessionRowToFilterContext
|
|
78
|
+
: null;
|
|
79
|
+
if (!mapper) {
|
|
80
|
+
return { ok: false, error: `Unsupported row type: ${rowType}` };
|
|
81
|
+
}
|
|
82
|
+
// Filter rows with proper type handling
|
|
83
|
+
const filtered = rows.filter((row) => {
|
|
84
|
+
// Use conditional mapper call instead of intersection type cast
|
|
85
|
+
const ctx = rowType === 'rpc'
|
|
86
|
+
? rpcRowToFilterContext(row)
|
|
87
|
+
: sessionRowToFilterContext(row);
|
|
88
|
+
return evaluateFilter(parseResult.ast, ctx);
|
|
89
|
+
});
|
|
90
|
+
return {
|
|
91
|
+
ok: true,
|
|
92
|
+
result: { kind: 'rows', rows: filtered, rowType },
|
|
93
|
+
stats: { matched: filtered.length, total: rows.length },
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=where-command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"where-command.js","sourceRoot":"","sources":["../../src/shell/where-command.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAGxD,OAAO,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAEvF,yCAAyC;AACzC,MAAM,eAAe,GAAG,CAAC,QAAQ,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,CAAC,CAAC;AAE5G,6CAA6C;AAC7C,MAAM,mBAAmB,GAAG,CAAC,iBAAiB,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