proofscan 0.6.2 → 0.6.3
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/context-applicator.d.ts +26 -0
- package/dist/shell/context-applicator.d.ts.map +1 -0
- package/dist/shell/context-applicator.js +222 -0
- package/dist/shell/context-applicator.js.map +1 -0
- package/dist/shell/index.d.ts +4 -2
- package/dist/shell/index.d.ts.map +1 -1
- package/dist/shell/index.js +3 -1
- package/dist/shell/index.js.map +1 -1
- package/dist/shell/prompt.d.ts +1 -1
- package/dist/shell/prompt.d.ts.map +1 -1
- package/dist/shell/prompt.js +25 -2
- package/dist/shell/prompt.js.map +1 -1
- package/dist/shell/repl.d.ts +4 -8
- package/dist/shell/repl.d.ts.map +1 -1
- package/dist/shell/repl.js +50 -53
- package/dist/shell/repl.js.map +1 -1
- package/dist/shell/router-commands.d.ts +71 -0
- package/dist/shell/router-commands.d.ts.map +1 -0
- package/dist/shell/router-commands.js +513 -0
- package/dist/shell/router-commands.js.map +1 -0
- package/dist/shell/types.d.ts +9 -0
- package/dist/shell/types.d.ts.map +1 -1
- package/dist/shell/types.js +4 -0
- package/dist/shell/types.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context Applicator - applies shell context to command arguments
|
|
3
|
+
*
|
|
4
|
+
* This module ensures that the current connector/session context
|
|
5
|
+
* is correctly injected into command arguments before execution.
|
|
6
|
+
*/
|
|
7
|
+
import type { ShellContext } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Result of applying context to command arguments
|
|
10
|
+
*/
|
|
11
|
+
export interface ApplyContextResult {
|
|
12
|
+
args: string[];
|
|
13
|
+
warnings: string[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Apply context to command arguments
|
|
17
|
+
*
|
|
18
|
+
* This function injects --connector, --session, --id options based on
|
|
19
|
+
* the current shell context and the command being executed.
|
|
20
|
+
*/
|
|
21
|
+
export declare function applyContext(tokens: string[], context: ShellContext): ApplyContextResult;
|
|
22
|
+
/**
|
|
23
|
+
* Generate context-aware hint message
|
|
24
|
+
*/
|
|
25
|
+
export declare function getContextHint(context: ShellContext): string;
|
|
26
|
+
//# sourceMappingURL=context-applicator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-applicator.d.ts","sourceRoot":"","sources":["../../src/shell/context-applicator.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AA0FD;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EAAE,EAChB,OAAO,EAAE,YAAY,GACpB,kBAAkB,CA0HpB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,CAQ5D"}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context Applicator - applies shell context to command arguments
|
|
3
|
+
*
|
|
4
|
+
* This module ensures that the current connector/session context
|
|
5
|
+
* is correctly injected into command arguments before execution.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Boolean flags that don't take values
|
|
9
|
+
*/
|
|
10
|
+
const BOOLEAN_FLAGS = new Set([
|
|
11
|
+
'--json',
|
|
12
|
+
'--verbose',
|
|
13
|
+
'-v',
|
|
14
|
+
'--help',
|
|
15
|
+
'-h',
|
|
16
|
+
'--errors',
|
|
17
|
+
'--fulltime',
|
|
18
|
+
'--full-time',
|
|
19
|
+
'--time-full',
|
|
20
|
+
'--with-sessions',
|
|
21
|
+
'--pairs',
|
|
22
|
+
'--pair',
|
|
23
|
+
'--sessions',
|
|
24
|
+
'--rpc',
|
|
25
|
+
'--rpc-all',
|
|
26
|
+
'--compact',
|
|
27
|
+
'--ids-only',
|
|
28
|
+
'--dry-run',
|
|
29
|
+
'--stdin',
|
|
30
|
+
'-f',
|
|
31
|
+
'--follow',
|
|
32
|
+
'-l',
|
|
33
|
+
]);
|
|
34
|
+
/**
|
|
35
|
+
* Check if a flag is a boolean flag (doesn't take a value)
|
|
36
|
+
*/
|
|
37
|
+
function isBooleanFlag(flag) {
|
|
38
|
+
return BOOLEAN_FLAGS.has(flag);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Check if args already contain a specific option
|
|
42
|
+
*/
|
|
43
|
+
function hasOption(args, ...optionNames) {
|
|
44
|
+
return optionNames.some(opt => args.includes(opt));
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Check if args have a positional argument at given position (0-indexed from command)
|
|
48
|
+
* Positional = non-option argument (doesn't start with -)
|
|
49
|
+
*/
|
|
50
|
+
function hasPositionalAt(args, position) {
|
|
51
|
+
let positionalCount = 0;
|
|
52
|
+
for (let i = 1; i < args.length; i++) {
|
|
53
|
+
if (!args[i].startsWith('-')) {
|
|
54
|
+
if (positionalCount === position) {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
positionalCount++;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
// Only skip next arg if this is a value-taking option
|
|
61
|
+
// Boolean flags don't consume the next argument
|
|
62
|
+
// Also check bounds before incrementing to avoid accessing past array end
|
|
63
|
+
if (!isBooleanFlag(args[i]) && i + 1 < args.length) {
|
|
64
|
+
i++;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Get positional argument at given position
|
|
72
|
+
*/
|
|
73
|
+
function getPositionalAt(args, position) {
|
|
74
|
+
let positionalCount = 0;
|
|
75
|
+
for (let i = 1; i < args.length; i++) {
|
|
76
|
+
if (!args[i].startsWith('-')) {
|
|
77
|
+
if (positionalCount === position) {
|
|
78
|
+
return args[i];
|
|
79
|
+
}
|
|
80
|
+
positionalCount++;
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
// Only skip next arg if this is a value-taking option
|
|
84
|
+
// Also check bounds before incrementing to avoid accessing past array end
|
|
85
|
+
if (!isBooleanFlag(args[i]) && i + 1 < args.length) {
|
|
86
|
+
i++;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Apply context to command arguments
|
|
94
|
+
*
|
|
95
|
+
* This function injects --connector, --session, --id options based on
|
|
96
|
+
* the current shell context and the command being executed.
|
|
97
|
+
*/
|
|
98
|
+
export function applyContext(tokens, context) {
|
|
99
|
+
const args = [...tokens];
|
|
100
|
+
const warnings = [];
|
|
101
|
+
const command = tokens[0];
|
|
102
|
+
const subcommand = tokens[1];
|
|
103
|
+
// === VIEW / V ===
|
|
104
|
+
// - `view <connector>` -> `view --connector <connector>`
|
|
105
|
+
// - Add --connector from context if not specified
|
|
106
|
+
// - Add --session from context if not specified
|
|
107
|
+
if (command === 'view' || command === 'v') {
|
|
108
|
+
// Handle positional connector: `view yfinance` -> `view --connector yfinance`
|
|
109
|
+
const positional = getPositionalAt(args, 0);
|
|
110
|
+
if (positional && !hasOption(args, '--connector')) {
|
|
111
|
+
// Remove positional and add as --connector
|
|
112
|
+
const idx = args.indexOf(positional);
|
|
113
|
+
args.splice(idx, 1);
|
|
114
|
+
args.push('--connector', positional);
|
|
115
|
+
}
|
|
116
|
+
// Add --connector from context if not specified
|
|
117
|
+
if (context.connector && !hasOption(args, '--connector')) {
|
|
118
|
+
args.push('--connector', context.connector);
|
|
119
|
+
}
|
|
120
|
+
// Add --session from context if not specified
|
|
121
|
+
if (context.session && !hasOption(args, '--session')) {
|
|
122
|
+
args.push('--session', context.session);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
// === TREE / T ===
|
|
126
|
+
// - Add --connector from context (tree uses positional connector)
|
|
127
|
+
if (command === 'tree' || command === 't') {
|
|
128
|
+
// tree takes positional connector, but we can also set context
|
|
129
|
+
// Only add if no positional argument
|
|
130
|
+
if (context.connector && !hasPositionalAt(args, 0) && !hasOption(args, '--connector')) {
|
|
131
|
+
// Insert connector as positional argument after command
|
|
132
|
+
args.splice(1, 0, context.connector);
|
|
133
|
+
}
|
|
134
|
+
// Add --session from context for tree
|
|
135
|
+
if (context.session && !hasOption(args, '--session')) {
|
|
136
|
+
args.push('--session', context.session);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
// === SCAN / S ===
|
|
140
|
+
// - `scan start` needs --id from context
|
|
141
|
+
// - `scan start <connector>` is positional
|
|
142
|
+
if (command === 'scan' || command === 's') {
|
|
143
|
+
if (subcommand === 'start' || (!subcommand?.startsWith('-') && tokens.length === 1)) {
|
|
144
|
+
// `scan start` or just `scan` (which becomes `scan start`)
|
|
145
|
+
const hasStartSubcmd = subcommand === 'start';
|
|
146
|
+
const positionalIdx = hasStartSubcmd ? 1 : 0;
|
|
147
|
+
// Check for positional connector after 'start'
|
|
148
|
+
const hasPositionalConnector = hasPositionalAt(args, positionalIdx);
|
|
149
|
+
if (!hasPositionalConnector && !hasOption(args, '--id') && context.connector) {
|
|
150
|
+
args.push('--id', context.connector);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
// === SESSIONS SHOW ===
|
|
155
|
+
// - `sessions show` needs --id from context.session
|
|
156
|
+
if (command === 'sessions' && subcommand === 'show') {
|
|
157
|
+
if (!hasOption(args, '--id') && context.session) {
|
|
158
|
+
args.push('--id', context.session);
|
|
159
|
+
}
|
|
160
|
+
else if (!hasOption(args, '--id') && !context.session) {
|
|
161
|
+
warnings.push('No session in context. Try: cc <connector>|<session>');
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
// === RPC LIST / RPC SHOW ===
|
|
165
|
+
// - Both need --session from context
|
|
166
|
+
if (command === 'rpc') {
|
|
167
|
+
if (!hasOption(args, '--session') && context.session) {
|
|
168
|
+
args.push('--session', context.session);
|
|
169
|
+
}
|
|
170
|
+
else if (!hasOption(args, '--session') && !context.session) {
|
|
171
|
+
warnings.push('No session in context. Try: cc <connector>|<session>');
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
// === SUMMARY ===
|
|
175
|
+
// - Needs --session from context
|
|
176
|
+
if (command === 'summary') {
|
|
177
|
+
if (!hasOption(args, '--session') && context.session) {
|
|
178
|
+
args.push('--session', context.session);
|
|
179
|
+
}
|
|
180
|
+
else if (!hasOption(args, '--session') && !context.session) {
|
|
181
|
+
warnings.push('No session in context. Try: cc <connector>|<session>');
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
// === PERMISSIONS ===
|
|
185
|
+
// - Needs --session from context
|
|
186
|
+
if (command === 'permissions') {
|
|
187
|
+
if (!hasOption(args, '--session') && context.session) {
|
|
188
|
+
args.push('--session', context.session);
|
|
189
|
+
}
|
|
190
|
+
else if (!hasOption(args, '--session') && !context.session) {
|
|
191
|
+
warnings.push('No session in context. Try: cc <connector>|<session>');
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
// === EVENTS ===
|
|
195
|
+
// - Can use --session from context
|
|
196
|
+
if (command === 'events') {
|
|
197
|
+
if (!hasOption(args, '--session') && context.session) {
|
|
198
|
+
args.push('--session', context.session);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
// === CONNECTORS SHOW ===
|
|
202
|
+
// - `connectors show` needs --id from context.connector
|
|
203
|
+
if ((command === 'connectors' || command === 'connector') && subcommand === 'show') {
|
|
204
|
+
if (!hasOption(args, '--id') && context.connector) {
|
|
205
|
+
args.push('--id', context.connector);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return { args, warnings };
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Generate context-aware hint message
|
|
212
|
+
*/
|
|
213
|
+
export function getContextHint(context) {
|
|
214
|
+
if (!context.connector && !context.session) {
|
|
215
|
+
return 'Try: cc <connector> or cc <connector>|<session>';
|
|
216
|
+
}
|
|
217
|
+
if (context.connector && !context.session) {
|
|
218
|
+
return `Try: cc <session> or ls (list sessions for ${context.connector})`;
|
|
219
|
+
}
|
|
220
|
+
return '';
|
|
221
|
+
}
|
|
222
|
+
//# sourceMappingURL=context-applicator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-applicator.js","sourceRoot":"","sources":["../../src/shell/context-applicator.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAYH;;GAEG;AACH,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC;IAC5B,QAAQ;IACR,WAAW;IACX,IAAI;IACJ,QAAQ;IACR,IAAI;IACJ,UAAU;IACV,YAAY;IACZ,aAAa;IACb,aAAa;IACb,iBAAiB;IACjB,SAAS;IACT,QAAQ;IACR,YAAY;IACZ,OAAO;IACP,WAAW;IACX,WAAW;IACX,YAAY;IACZ,WAAW;IACX,SAAS;IACT,IAAI;IACJ,UAAU;IACV,IAAI;CACL,CAAC,CAAC;AAEH;;GAEG;AACH,SAAS,aAAa,CAAC,IAAY;IACjC,OAAO,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACjC,CAAC;AAED;;GAEG;AACH,SAAS,SAAS,CAAC,IAAc,EAAE,GAAG,WAAqB;IACzD,OAAO,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;AACrD,CAAC;AAED;;;GAGG;AACH,SAAS,eAAe,CAAC,IAAc,EAAE,QAAgB;IACvD,IAAI,eAAe,GAAG,CAAC,CAAC;IACxB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,IAAI,CAAC,IAAI,CAAC,CAAC,C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CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
package/dist/shell/index.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ export { generatePrompt, supportsColor } from './prompt.js';
|
|
|
6
6
|
export { getHistoryPath, loadHistory, saveHistory } from './history.js';
|
|
7
7
|
export { createCompleter, getCompletions, type DynamicDataProvider } from './completer.js';
|
|
8
8
|
export { selectConnector, selectSession, canInteract } from './selector.js';
|
|
9
|
-
export type { ShellContext, CompletionResult } from './types.js';
|
|
10
|
-
export { TOP_LEVEL_COMMANDS, COMMAND_SUBCOMMANDS, SHELL_BUILTINS } from './types.js';
|
|
9
|
+
export type { ShellContext, CompletionResult, ProtoType } from './types.js';
|
|
10
|
+
export { TOP_LEVEL_COMMANDS, COMMAND_SUBCOMMANDS, SHELL_BUILTINS, ROUTER_COMMANDS } from './types.js';
|
|
11
|
+
export { applyContext } from './context-applicator.js';
|
|
12
|
+
export { handleCc, handleUp, handlePwd, handleLs, handleShow, detectProto, detectConnectorProto, getContextLevel, } from './router-commands.js';
|
|
11
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shell/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC3F,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5E,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shell/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC3F,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5E,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACtG,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,UAAU,EACV,WAAW,EACX,oBAAoB,EACpB,eAAe,GAChB,MAAM,sBAAsB,CAAC"}
|
package/dist/shell/index.js
CHANGED
|
@@ -6,5 +6,7 @@ export { generatePrompt, supportsColor } from './prompt.js';
|
|
|
6
6
|
export { getHistoryPath, loadHistory, saveHistory } from './history.js';
|
|
7
7
|
export { createCompleter, getCompletions } from './completer.js';
|
|
8
8
|
export { selectConnector, selectSession, canInteract } from './selector.js';
|
|
9
|
-
export { TOP_LEVEL_COMMANDS, COMMAND_SUBCOMMANDS, SHELL_BUILTINS } from './types.js';
|
|
9
|
+
export { TOP_LEVEL_COMMANDS, COMMAND_SUBCOMMANDS, SHELL_BUILTINS, ROUTER_COMMANDS } from './types.js';
|
|
10
|
+
export { applyContext } from './context-applicator.js';
|
|
11
|
+
export { handleCc, handleUp, handlePwd, handleLs, handleShow, detectProto, detectConnectorProto, getContextLevel, } from './router-commands.js';
|
|
10
12
|
//# sourceMappingURL=index.js.map
|
package/dist/shell/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/shell/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,cAAc,EAA4B,MAAM,gBAAgB,CAAC;AAC3F,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5E,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/shell/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,cAAc,EAA4B,MAAM,gBAAgB,CAAC;AAC3F,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5E,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACtG,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,UAAU,EACV,WAAW,EACX,oBAAoB,EACpB,eAAe,GAChB,MAAM,sBAAsB,CAAC"}
|
package/dist/shell/prompt.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export declare function supportsColor(): boolean;
|
|
|
12
12
|
export declare function shortenSessionId(sessionId: string, length?: number): string;
|
|
13
13
|
/**
|
|
14
14
|
* Generate the shell prompt string
|
|
15
|
-
* Format: proofscan|<connector>|<sessionPrefix>>
|
|
15
|
+
* Format: proofscan|<proto>|<connector>|<sessionPrefix>>
|
|
16
16
|
*/
|
|
17
17
|
export declare function generatePrompt(context: ShellContext): string;
|
|
18
18
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/shell/prompt.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAc/C;;GAEG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAQvC;AAYD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,GAAE,MAAU,GAAG,MAAM,CAE9E;
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/shell/prompt.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAc/C;;GAEG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAQvC;AAYD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,GAAE,MAAU,GAAG,MAAM,CAE9E;AAgBD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,CAsB5D;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,CAajE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAElD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAEhD;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE/C"}
|
package/dist/shell/prompt.js
CHANGED
|
@@ -38,21 +38,40 @@ function color(text, colorCode) {
|
|
|
38
38
|
export function shortenSessionId(sessionId, length = 8) {
|
|
39
39
|
return sessionId.slice(0, length);
|
|
40
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Get color for proto type
|
|
43
|
+
*/
|
|
44
|
+
function getProtoColor(proto) {
|
|
45
|
+
switch (proto) {
|
|
46
|
+
case 'mcp':
|
|
47
|
+
return COLORS.green;
|
|
48
|
+
case 'a2a':
|
|
49
|
+
return COLORS.cyan;
|
|
50
|
+
default:
|
|
51
|
+
return COLORS.dim;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
41
54
|
/**
|
|
42
55
|
* Generate the shell prompt string
|
|
43
|
-
* Format: proofscan|<connector>|<sessionPrefix>>
|
|
56
|
+
* Format: proofscan|<proto>|<connector>|<sessionPrefix>>
|
|
44
57
|
*/
|
|
45
58
|
export function generatePrompt(context) {
|
|
46
59
|
const parts = [];
|
|
47
60
|
// proofscan (dim)
|
|
48
61
|
parts.push(color('proofscan', COLORS.dim));
|
|
62
|
+
// proto (colored by type) or * if not set
|
|
63
|
+
const proto = context.proto || '*';
|
|
64
|
+
parts.push(color(proto, getProtoColor(proto)));
|
|
49
65
|
// connector (cyan) or * if not set
|
|
50
66
|
const connector = context.connector || '*';
|
|
51
67
|
parts.push(color(connector, COLORS.cyan));
|
|
52
|
-
// session prefix (yellow) if set
|
|
68
|
+
// session prefix (yellow) or * if connector is set but no session
|
|
53
69
|
if (context.session) {
|
|
54
70
|
parts.push(color(shortenSessionId(context.session), COLORS.yellow));
|
|
55
71
|
}
|
|
72
|
+
else if (context.connector) {
|
|
73
|
+
parts.push(color('*', COLORS.dim));
|
|
74
|
+
}
|
|
56
75
|
return parts.join('|') + '> ';
|
|
57
76
|
}
|
|
58
77
|
/**
|
|
@@ -60,10 +79,14 @@ export function generatePrompt(context) {
|
|
|
60
79
|
*/
|
|
61
80
|
export function generatePlainPrompt(context) {
|
|
62
81
|
const parts = ['proofscan'];
|
|
82
|
+
parts.push(context.proto || '*');
|
|
63
83
|
parts.push(context.connector || '*');
|
|
64
84
|
if (context.session) {
|
|
65
85
|
parts.push(shortenSessionId(context.session));
|
|
66
86
|
}
|
|
87
|
+
else if (context.connector) {
|
|
88
|
+
parts.push('*');
|
|
89
|
+
}
|
|
67
90
|
return parts.join('|') + '> ';
|
|
68
91
|
}
|
|
69
92
|
/**
|
package/dist/shell/prompt.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../src/shell/prompt.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,MAAM,MAAM,GAAG;IACb,KAAK,EAAE,SAAS;IAChB,GAAG,EAAE,SAAS;IACd,IAAI,EAAE,UAAU;IAChB,MAAM,EAAE,UAAU;IAClB,KAAK,EAAE,UAAU;IACjB,GAAG,EAAE,UAAU;CAChB,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,aAAa;IAC3B,wCAAwC;IACxC,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QACvC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,2BAA2B;IAC3B,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,KAAK,IAAI,CAAC;AACvC,CAAC;AAED;;GAEG;AACH,SAAS,KAAK,CAAC,IAAY,EAAE,SAAiB;IAC5C,IAAI,CAAC,aAAa,EAAE,EAAE,CAAC;QACrB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC;AAC9C,CAAC;AAED;;GAEG;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a line of input
|
|
41
41
|
*/
|
|
42
42
|
private processLine;
|
|
43
|
+
/**
|
|
44
|
+
* Handle router-style commands (cc, ls, show, ..)
|
|
45
|
+
*/
|
|
46
|
+
private handleRouterCommand;
|
|
43
47
|
/**
|
|
44
48
|
* Handle built-in shell commands
|
|
45
49
|
*/
|
|
@@ -64,13 +68,5 @@ export declare class ShellRepl {
|
|
|
64
68
|
* Execute a pfscan command
|
|
65
69
|
*/
|
|
66
70
|
private executeCommand;
|
|
67
|
-
/**
|
|
68
|
-
* Build command arguments with context applied
|
|
69
|
-
*/
|
|
70
|
-
private buildCommandArgs;
|
|
71
|
-
/**
|
|
72
|
-
* Check if command has a positional connector argument
|
|
73
|
-
*/
|
|
74
|
-
private hasPositionalConnector;
|
|
75
71
|
}
|
|
76
72
|
//# sourceMappingURL=repl.d.ts.map
|
package/dist/shell/repl.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repl.d.ts","sourceRoot":"","sources":["../../src/shell/repl.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"repl.d.ts","sourceRoot":"","sources":["../../src/shell/repl.ts"],"names":[],"mappings":"AAAA;;GAEG;AA6BH;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAG/C;AAUD;;GAEG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,OAAO,CAAe;IAC9B,OAAO,CAAC,EAAE,CAAmC;IAC7C,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,OAAO,CAAS;IAGxB,OAAO,CAAC,eAAe,CAAqC;IAC5D,OAAO,CAAC,aAAa,CAAgD;IACrE,OAAO,CAAC,SAAS,CAAgD;gBAErD,UAAU,EAAE,MAAM;IAY9B;;OAEG;IACH,OAAO,CAAC,eAAe;IAMvB;;OAEG;IACH,OAAO,CAAC,eAAe;IAwDvB;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA4D5B;;OAEG;YACW,WAAW;IA8BzB;;OAEG;YACW,mBAAmB;IAiBjC;;OAEG;YACW,aAAa;IAiC3B;;OAEG;IACH,OAAO,CAAC,QAAQ;IAoChB;;OAEG;IACH,OAAO,CAAC,WAAW;IAQnB;;OAEG;YACW,SAAS;IA+IvB;;OAEG;IACH,OAAO,CAAC,YAAY;IAOpB;;OAEG;YACW,cAAc;CAiD7B"}
|
package/dist/shell/repl.js
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import * as readline from 'readline';
|
|
5
5
|
import { spawn } from 'child_process';
|
|
6
|
-
import { SHELL_BUILTINS, TOP_LEVEL_COMMANDS } from './types.js';
|
|
6
|
+
import { SHELL_BUILTINS, TOP_LEVEL_COMMANDS, ROUTER_COMMANDS } from './types.js';
|
|
7
|
+
import { applyContext } from './context-applicator.js';
|
|
8
|
+
import { handleCc, handleUp, handlePwd, handleLs, handleShow, } from './router-commands.js';
|
|
7
9
|
import { generatePrompt, printSuccess, printError, printInfo, shortenSessionId } from './prompt.js';
|
|
8
10
|
import { loadHistory, saveHistory, addToHistory } from './history.js';
|
|
9
11
|
import { createCompleter } from './completer.js';
|
|
@@ -179,6 +181,11 @@ export class ShellRepl {
|
|
|
179
181
|
return;
|
|
180
182
|
const command = tokens[0];
|
|
181
183
|
const args = tokens.slice(1);
|
|
184
|
+
// Handle router-style commands first
|
|
185
|
+
if (ROUTER_COMMANDS.includes(command)) {
|
|
186
|
+
await this.handleRouterCommand(command, args);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
182
189
|
// Handle built-in commands
|
|
183
190
|
if (SHELL_BUILTINS.includes(command)) {
|
|
184
191
|
await this.handleBuiltin(command, args);
|
|
@@ -193,6 +200,25 @@ export class ShellRepl {
|
|
|
193
200
|
printError(`Unknown command: ${command}`);
|
|
194
201
|
printInfo('Type "help" for available commands');
|
|
195
202
|
}
|
|
203
|
+
/**
|
|
204
|
+
* Handle router-style commands (cc, ls, show, ..)
|
|
205
|
+
*/
|
|
206
|
+
async handleRouterCommand(command, args) {
|
|
207
|
+
switch (command) {
|
|
208
|
+
case 'cc':
|
|
209
|
+
await handleCc(args, this.context, this.configPath);
|
|
210
|
+
break;
|
|
211
|
+
case '..':
|
|
212
|
+
handleUp(this.context);
|
|
213
|
+
break;
|
|
214
|
+
case 'ls':
|
|
215
|
+
await handleLs(args, this.context, this.configPath, (tokens) => this.executeCommand(tokens));
|
|
216
|
+
break;
|
|
217
|
+
case 'show':
|
|
218
|
+
await handleShow(args, this.context, this.configPath, (tokens) => this.executeCommand(tokens));
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
196
222
|
/**
|
|
197
223
|
* Handle built-in shell commands
|
|
198
224
|
*/
|
|
@@ -210,7 +236,7 @@ export class ShellRepl {
|
|
|
210
236
|
console.clear();
|
|
211
237
|
break;
|
|
212
238
|
case 'pwd':
|
|
213
|
-
this.
|
|
239
|
+
handlePwd(this.context, this.configPath);
|
|
214
240
|
break;
|
|
215
241
|
case 'use':
|
|
216
242
|
await this.handleUse(args);
|
|
@@ -231,22 +257,32 @@ export class ShellRepl {
|
|
|
231
257
|
return;
|
|
232
258
|
}
|
|
233
259
|
console.log(`
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
260
|
+
Navigation (router-style):
|
|
261
|
+
cc Go to latest session (home)
|
|
262
|
+
cc / Go to root
|
|
263
|
+
cc <connector> Enter connector context
|
|
264
|
+
cc <session> Enter session (in connector context)
|
|
265
|
+
cc <conn>|<sess> Enter session directly
|
|
266
|
+
.. Go up one level
|
|
267
|
+
ls [-l] [--json] List items at current level
|
|
268
|
+
show [target] [--json] Show details
|
|
269
|
+
|
|
270
|
+
Legacy Commands:
|
|
271
|
+
use <connector> Set connector context
|
|
272
|
+
use session <prefix> Set session context
|
|
273
|
+
reset Clear context
|
|
274
|
+
pwd Show current context with path
|
|
239
275
|
help [command] Show help
|
|
240
276
|
clear Clear screen
|
|
241
277
|
exit, quit Exit shell
|
|
242
278
|
|
|
243
|
-
|
|
279
|
+
ProofScan Commands:
|
|
244
280
|
${TOP_LEVEL_COMMANDS.join(', ')}
|
|
245
281
|
|
|
246
282
|
Tips:
|
|
247
283
|
- Press TAB for auto-completion
|
|
248
|
-
-
|
|
249
|
-
- Commands
|
|
284
|
+
- Context is shown in prompt: proto|connector|session
|
|
285
|
+
- Commands auto-apply current context
|
|
250
286
|
`);
|
|
251
287
|
}
|
|
252
288
|
/**
|
|
@@ -400,9 +436,11 @@ Tips:
|
|
|
400
436
|
* Execute a pfscan command
|
|
401
437
|
*/
|
|
402
438
|
async executeCommand(tokens) {
|
|
403
|
-
//
|
|
404
|
-
const cmdArgs = this.
|
|
439
|
+
// Apply context to command arguments
|
|
440
|
+
const { args: cmdArgs, warnings } = applyContext(tokens, this.context);
|
|
405
441
|
const command = tokens[0];
|
|
442
|
+
// Show context-aware warnings
|
|
443
|
+
warnings.forEach(w => printInfo(w));
|
|
406
444
|
// Validate all arguments for safety (defense-in-depth with shell: false)
|
|
407
445
|
const invalidArgs = cmdArgs.filter(arg => !isValidArg(arg));
|
|
408
446
|
if (invalidArgs.length > 0) {
|
|
@@ -441,46 +479,5 @@ Tips:
|
|
|
441
479
|
});
|
|
442
480
|
});
|
|
443
481
|
}
|
|
444
|
-
/**
|
|
445
|
-
* Build command arguments with context applied
|
|
446
|
-
*/
|
|
447
|
-
buildCommandArgs(tokens) {
|
|
448
|
-
const args = [...tokens];
|
|
449
|
-
const command = tokens[0];
|
|
450
|
-
// Add --connector if context has connector and command supports it
|
|
451
|
-
const connectorCommands = ['view', 'v', 'tree', 't'];
|
|
452
|
-
if (this.context.connector && connectorCommands.includes(command)) {
|
|
453
|
-
if (!args.includes('--connector') && !this.hasPositionalConnector(args)) {
|
|
454
|
-
args.push('--connector', this.context.connector);
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
// Add --session if context has session and command supports it
|
|
458
|
-
const sessionCommands = ['rpc', 'summary', 'permissions', 'view', 'v'];
|
|
459
|
-
if (this.context.session && sessionCommands.includes(command)) {
|
|
460
|
-
if (!args.includes('--session')) {
|
|
461
|
-
args.push('--session', this.context.session);
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
// Add --id for scan start if context has connector
|
|
465
|
-
if (command === 'scan' || command === 's') {
|
|
466
|
-
if (args.includes('start') && !args.includes('--id') && this.context.connector) {
|
|
467
|
-
const hasPositional = args.length > 2 && !args[2].startsWith('-');
|
|
468
|
-
if (!hasPositional) {
|
|
469
|
-
args.push('--id', this.context.connector);
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
return args;
|
|
474
|
-
}
|
|
475
|
-
/**
|
|
476
|
-
* Check if command has a positional connector argument
|
|
477
|
-
*/
|
|
478
|
-
hasPositionalConnector(args) {
|
|
479
|
-
// For tree command, check if there's a positional argument
|
|
480
|
-
if (args[0] === 'tree' || args[0] === 't') {
|
|
481
|
-
return args.length > 1 && !args[1].startsWith('-');
|
|
482
|
-
}
|
|
483
|
-
return false;
|
|
484
|
-
}
|
|
485
482
|
}
|
|
486
483
|
//# sourceMappingURL=repl.js.map
|