proofscan 0.1.0

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.
Files changed (95) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +295 -0
  3. package/dist/cli.d.ts +7 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +38 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/commands/config.d.ts +6 -0
  8. package/dist/commands/config.d.ts.map +1 -0
  9. package/dist/commands/config.js +81 -0
  10. package/dist/commands/config.js.map +1 -0
  11. package/dist/commands/connectors.d.ts +6 -0
  12. package/dist/commands/connectors.d.ts.map +1 -0
  13. package/dist/commands/connectors.js +205 -0
  14. package/dist/commands/connectors.js.map +1 -0
  15. package/dist/commands/index.d.ts +5 -0
  16. package/dist/commands/index.d.ts.map +1 -0
  17. package/dist/commands/index.js +5 -0
  18. package/dist/commands/index.js.map +1 -0
  19. package/dist/commands/monitor.d.ts +6 -0
  20. package/dist/commands/monitor.d.ts.map +1 -0
  21. package/dist/commands/monitor.js +76 -0
  22. package/dist/commands/monitor.js.map +1 -0
  23. package/dist/commands/scan.d.ts +6 -0
  24. package/dist/commands/scan.d.ts.map +1 -0
  25. package/dist/commands/scan.js +76 -0
  26. package/dist/commands/scan.js.map +1 -0
  27. package/dist/config/import.d.ts +19 -0
  28. package/dist/config/import.d.ts.map +1 -0
  29. package/dist/config/import.js +113 -0
  30. package/dist/config/import.js.map +1 -0
  31. package/dist/config/index.d.ts +4 -0
  32. package/dist/config/index.d.ts.map +1 -0
  33. package/dist/config/index.js +4 -0
  34. package/dist/config/index.js.map +1 -0
  35. package/dist/config/manager.d.ts +29 -0
  36. package/dist/config/manager.d.ts.map +1 -0
  37. package/dist/config/manager.js +112 -0
  38. package/dist/config/manager.js.map +1 -0
  39. package/dist/config/schema.d.ts +21 -0
  40. package/dist/config/schema.d.ts.map +1 -0
  41. package/dist/config/schema.js +124 -0
  42. package/dist/config/schema.js.map +1 -0
  43. package/dist/events/index.d.ts +2 -0
  44. package/dist/events/index.d.ts.map +1 -0
  45. package/dist/events/index.js +2 -0
  46. package/dist/events/index.js.map +1 -0
  47. package/dist/events/store.d.ts +25 -0
  48. package/dist/events/store.d.ts.map +1 -0
  49. package/dist/events/store.js +91 -0
  50. package/dist/events/store.js.map +1 -0
  51. package/dist/index.d.ts +11 -0
  52. package/dist/index.d.ts.map +1 -0
  53. package/dist/index.js +11 -0
  54. package/dist/index.js.map +1 -0
  55. package/dist/scanner/index.d.ts +22 -0
  56. package/dist/scanner/index.d.ts.map +1 -0
  57. package/dist/scanner/index.js +179 -0
  58. package/dist/scanner/index.js.map +1 -0
  59. package/dist/transports/index.d.ts +2 -0
  60. package/dist/transports/index.d.ts.map +1 -0
  61. package/dist/transports/index.js +2 -0
  62. package/dist/transports/index.js.map +1 -0
  63. package/dist/transports/stdio.d.ts +50 -0
  64. package/dist/transports/stdio.d.ts.map +1 -0
  65. package/dist/transports/stdio.js +140 -0
  66. package/dist/transports/stdio.js.map +1 -0
  67. package/dist/types/config.d.ts +38 -0
  68. package/dist/types/config.d.ts.map +1 -0
  69. package/dist/types/config.js +8 -0
  70. package/dist/types/config.js.map +1 -0
  71. package/dist/types/events.d.ts +23 -0
  72. package/dist/types/events.d.ts.map +1 -0
  73. package/dist/types/events.js +10 -0
  74. package/dist/types/events.js.map +1 -0
  75. package/dist/types/index.d.ts +3 -0
  76. package/dist/types/index.d.ts.map +1 -0
  77. package/dist/types/index.js +3 -0
  78. package/dist/types/index.js.map +1 -0
  79. package/dist/utils/config-path.d.ts +15 -0
  80. package/dist/utils/config-path.d.ts.map +1 -0
  81. package/dist/utils/config-path.js +44 -0
  82. package/dist/utils/config-path.js.map +1 -0
  83. package/dist/utils/fs.d.ts +25 -0
  84. package/dist/utils/fs.d.ts.map +1 -0
  85. package/dist/utils/fs.js +80 -0
  86. package/dist/utils/fs.js.map +1 -0
  87. package/dist/utils/index.d.ts +4 -0
  88. package/dist/utils/index.d.ts.map +1 -0
  89. package/dist/utils/index.js +4 -0
  90. package/dist/utils/index.js.map +1 -0
  91. package/dist/utils/output.d.ts +22 -0
  92. package/dist/utils/output.d.ts.map +1 -0
  93. package/dist/utils/output.js +108 -0
  94. package/dist/utils/output.js.map +1 -0
  95. package/package.json +60 -0
@@ -0,0 +1,140 @@
1
+ /**
2
+ * Stdio transport for MCP servers
3
+ * Spawns child process and communicates via stdin/stdout JSON-RPC
4
+ */
5
+ import { spawn } from 'child_process';
6
+ import { EventEmitter } from 'events';
7
+ export class StdioConnection extends EventEmitter {
8
+ process = null;
9
+ buffer = '';
10
+ transport;
11
+ requestId = 1;
12
+ pendingRequests = new Map();
13
+ constructor(transport) {
14
+ super();
15
+ this.transport = transport;
16
+ }
17
+ async connect() {
18
+ const { command, args = [], env, cwd } = this.transport;
19
+ this.process = spawn(command, args, {
20
+ stdio: ['pipe', 'pipe', 'pipe'],
21
+ env: { ...process.env, ...env },
22
+ cwd,
23
+ shell: false,
24
+ });
25
+ this.process.stdout?.setEncoding('utf8');
26
+ this.process.stderr?.setEncoding('utf8');
27
+ this.process.stdout?.on('data', (data) => {
28
+ this.handleData(data);
29
+ });
30
+ this.process.stderr?.on('data', (data) => {
31
+ this.emit('stderr', data);
32
+ });
33
+ this.process.on('error', (error) => {
34
+ this.emit('error', error);
35
+ });
36
+ this.process.on('close', (code, signal) => {
37
+ // Reject all pending requests
38
+ for (const [id, pending] of this.pendingRequests) {
39
+ clearTimeout(pending.timeout);
40
+ pending.reject(new Error(`Process exited with code ${code}`));
41
+ }
42
+ this.pendingRequests.clear();
43
+ this.emit('close', code, signal);
44
+ });
45
+ // Wait a brief moment for process to start
46
+ await new Promise((resolve, reject) => {
47
+ const timeout = setTimeout(() => resolve(), 100);
48
+ this.process?.on('error', (err) => {
49
+ clearTimeout(timeout);
50
+ reject(err);
51
+ });
52
+ // Check if process exited immediately
53
+ if (this.process && this.process.exitCode !== null) {
54
+ clearTimeout(timeout);
55
+ reject(new Error(`Process exited immediately with code ${this.process.exitCode}`));
56
+ }
57
+ });
58
+ }
59
+ handleData(data) {
60
+ this.buffer += data;
61
+ // Process complete lines (JSON-RPC messages are newline-delimited)
62
+ let newlineIndex;
63
+ while ((newlineIndex = this.buffer.indexOf('\n')) !== -1) {
64
+ const line = this.buffer.slice(0, newlineIndex).trim();
65
+ this.buffer = this.buffer.slice(newlineIndex + 1);
66
+ if (line) {
67
+ this.processLine(line);
68
+ }
69
+ }
70
+ }
71
+ processLine(line) {
72
+ try {
73
+ const msg = JSON.parse(line);
74
+ this.emit('message', msg, line);
75
+ // Handle responses to pending requests
76
+ if ('id' in msg && msg.id !== null && !('method' in msg)) {
77
+ const pending = this.pendingRequests.get(msg.id);
78
+ if (pending) {
79
+ clearTimeout(pending.timeout);
80
+ this.pendingRequests.delete(msg.id);
81
+ pending.resolve(msg);
82
+ }
83
+ }
84
+ }
85
+ catch (error) {
86
+ this.emit('error', new Error(`Failed to parse JSON-RPC message: ${line}`));
87
+ }
88
+ }
89
+ async sendRequest(method, params, timeoutMs = 30000) {
90
+ if (!this.process || this.process.killed) {
91
+ throw new Error('Connection not open');
92
+ }
93
+ const id = this.requestId++;
94
+ const request = {
95
+ jsonrpc: '2.0',
96
+ id,
97
+ method,
98
+ ...(params !== undefined && { params }),
99
+ };
100
+ const raw = JSON.stringify(request) + '\n';
101
+ return new Promise((resolve, reject) => {
102
+ const timeout = setTimeout(() => {
103
+ this.pendingRequests.delete(id);
104
+ reject(new Error(`Request timeout for method: ${method}`));
105
+ }, timeoutMs);
106
+ this.pendingRequests.set(id, { resolve, reject, timeout });
107
+ this.process.stdin?.write(raw, (err) => {
108
+ if (err) {
109
+ clearTimeout(timeout);
110
+ this.pendingRequests.delete(id);
111
+ reject(err);
112
+ }
113
+ });
114
+ // Emit event for the sent request
115
+ this.emit('message', request, raw.trim());
116
+ });
117
+ }
118
+ sendNotification(method, params) {
119
+ if (!this.process || this.process.killed) {
120
+ throw new Error('Connection not open');
121
+ }
122
+ const notification = {
123
+ jsonrpc: '2.0',
124
+ method,
125
+ ...(params !== undefined && { params }),
126
+ };
127
+ const raw = JSON.stringify(notification) + '\n';
128
+ this.process.stdin?.write(raw);
129
+ this.emit('message', notification, raw.trim());
130
+ }
131
+ close() {
132
+ if (this.process && !this.process.killed) {
133
+ this.process.kill();
134
+ }
135
+ }
136
+ isConnected() {
137
+ return this.process !== null && !this.process.killed;
138
+ }
139
+ }
140
+ //# sourceMappingURL=stdio.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stdio.js","sourceRoot":"","sources":["../../src/transports/stdio.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,EAAgB,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAoCtC,MAAM,OAAO,eAAgB,SAAQ,YAAY;IACvC,OAAO,GAAwB,IAAI,CAAC;IACpC,MAAM,GAAW,EAAE,CAAC;IACpB,SAAS,CAAiB;IAC1B,SAAS,GAAW,CAAC,CAAC;IACtB,eAAe,GAIlB,IAAI,GAAG,EAAE,CAAC;IAEf,YAAY,SAAyB;QACnC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,OAAO;QACX,MAAM,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC;QAExD,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE;YAClC,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;YAC/B,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,EAAE;YAC/B,GAAG;YACH,KAAK,EAAE,KAAK;SACb,CAAC,CAAC;QAEH,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAA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AAE,CAAC,CAAC;IACjD,CAAC;IAED,KAAK;QACH,IAAI,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YACzC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QACtB,CAAC;IACH,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAC,OAAO,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IACvD,CAAC;CACF"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Configuration types for proofscan
3
+ */
4
+ export type TransportType = 'stdio' | 'rpc-http' | 'rpc-sse';
5
+ export interface StdioTransport {
6
+ type: 'stdio';
7
+ command: string;
8
+ args?: string[];
9
+ env?: Record<string, string>;
10
+ cwd?: string;
11
+ }
12
+ export interface HttpTransport {
13
+ type: 'rpc-http';
14
+ url: string;
15
+ headers?: Record<string, string>;
16
+ }
17
+ export interface SseTransport {
18
+ type: 'rpc-sse';
19
+ url: string;
20
+ headers?: Record<string, string>;
21
+ }
22
+ export type Transport = StdioTransport | HttpTransport | SseTransport;
23
+ export interface ConnectorPlugins {
24
+ debug_monitor?: boolean;
25
+ inscribe?: boolean;
26
+ }
27
+ export interface Connector {
28
+ id: string;
29
+ enabled: boolean;
30
+ transport: Transport;
31
+ plugins?: ConnectorPlugins;
32
+ }
33
+ export interface Config {
34
+ version: 1;
35
+ connectors: Connector[];
36
+ }
37
+ export declare const DEFAULT_CONFIG: Config;
38
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,UAAU,GAAG,SAAS,CAAC;AAE7D,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,UAAU,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,SAAS,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,MAAM,MAAM,SAAS,GAAG,cAAc,GAAG,aAAa,GAAG,YAAY,CAAC;AAEtE,MAAM,WAAW,gBAAgB;IAC/B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,SAAS,CAAC;IACrB,OAAO,CAAC,EAAE,gBAAgB,CAAC;CAC5B;AAED,MAAM,WAAW,MAAM;IACrB,OAAO,EAAE,CAAC,CAAC;IACX,UAAU,EAAE,SAAS,EAAE,CAAC;CACzB;AAED,eAAO,MAAM,cAAc,EAAE,MAG5B,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Configuration types for proofscan
3
+ */
4
+ export const DEFAULT_CONFIG = {
5
+ version: 1,
6
+ connectors: [],
7
+ };
8
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AA2CH,MAAM,CAAC,MAAM,cAAc,GAAW;IACpC,OAAO,EAAE,CAAC;IACV,UAAU,EAAE,EAAE;CACf,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Event types for proofscan
3
+ */
4
+ export type EventDirection = 'client_to_server' | 'server_to_client';
5
+ export type EventKind = 'request' | 'response' | 'notification' | 'transport_event';
6
+ export interface ScanEvent {
7
+ event_id: string;
8
+ ts: string;
9
+ connector_id: string;
10
+ direction: EventDirection;
11
+ kind: EventKind;
12
+ method?: string;
13
+ rpc_id?: string | number;
14
+ ok?: boolean;
15
+ error?: {
16
+ code: number;
17
+ message: string;
18
+ };
19
+ raw?: string;
20
+ }
21
+ export declare const MAX_RAW_SIZE = 10000;
22
+ export declare function truncateRaw(raw: string): string;
23
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,cAAc,GAAG,kBAAkB,GAAG,kBAAkB,CAAC;AACrE,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,UAAU,GAAG,cAAc,GAAG,iBAAiB,CAAC;AAEpF,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,cAAc,CAAC;IAC1B,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,KAAK,CAAC,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,YAAY,QAAQ,CAAC;AAElC,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG/C"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Event types for proofscan
3
+ */
4
+ export const MAX_RAW_SIZE = 10000; // Truncate raw data if larger than 10KB
5
+ export function truncateRaw(raw) {
6
+ if (raw.length <= MAX_RAW_SIZE)
7
+ return raw;
8
+ return raw.slice(0, MAX_RAW_SIZE) + '... [truncated]';
9
+ }
10
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":"AAAA;;GAEG;AAqBH,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,CAAC,CAAC,wCAAwC;AAE3E,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,IAAI,GAAG,CAAC,MAAM,IAAI,YAAY;QAAE,OAAO,GAAG,CAAC;IAC3C,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,YAAY,CAAC,GAAG,iBAAiB,CAAC;AACxD,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './config.js';
2
+ export * from './events.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './config.js';
2
+ export * from './events.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Config path resolution utility
3
+ * Priority:
4
+ * 1) --config <path> (passed as argument)
5
+ * 2) PROOFSCAN_CONFIG environment variable
6
+ * 3) OS standard config location
7
+ */
8
+ export declare function getDefaultConfigDir(): string;
9
+ export declare function getDefaultConfigPath(): string;
10
+ export declare function getEventsDir(configDir?: string): string;
11
+ export interface ConfigPathOptions {
12
+ configPath?: string;
13
+ }
14
+ export declare function resolveConfigPath(options?: ConfigPathOptions): string;
15
+ //# sourceMappingURL=config-path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-path.d.ts","sourceRoot":"","sources":["../../src/utils/config-path.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,wBAAgB,mBAAmB,IAAI,MAAM,CAe5C;AAED,wBAAgB,oBAAoB,IAAI,MAAM,CAE7C;AAED,wBAAgB,YAAY,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED,MAAM,WAAW,iBAAiB;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,iBAAsB,GAAG,MAAM,CAczE"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Config path resolution utility
3
+ * Priority:
4
+ * 1) --config <path> (passed as argument)
5
+ * 2) PROOFSCAN_CONFIG environment variable
6
+ * 3) OS standard config location
7
+ */
8
+ import { homedir, platform } from 'os';
9
+ import { join } from 'path';
10
+ export function getDefaultConfigDir() {
11
+ const home = homedir();
12
+ const os = platform();
13
+ switch (os) {
14
+ case 'win32':
15
+ // Windows: %APPDATA%\proofscan
16
+ return join(process.env.APPDATA || join(home, 'AppData', 'Roaming'), 'proofscan');
17
+ case 'darwin':
18
+ // macOS: ~/Library/Application Support/proofscan
19
+ return join(home, 'Library', 'Application Support', 'proofscan');
20
+ default:
21
+ // Linux and others: ~/.config/proofscan
22
+ return join(process.env.XDG_CONFIG_HOME || join(home, '.config'), 'proofscan');
23
+ }
24
+ }
25
+ export function getDefaultConfigPath() {
26
+ return join(getDefaultConfigDir(), 'config.json');
27
+ }
28
+ export function getEventsDir(configDir) {
29
+ return join(configDir || getDefaultConfigDir(), 'events');
30
+ }
31
+ export function resolveConfigPath(options = {}) {
32
+ // Priority 1: --config argument
33
+ if (options.configPath) {
34
+ return options.configPath;
35
+ }
36
+ // Priority 2: PROOFSCAN_CONFIG environment variable
37
+ const envPath = process.env.PROOFSCAN_CONFIG;
38
+ if (envPath) {
39
+ return envPath;
40
+ }
41
+ // Priority 3: OS standard location
42
+ return getDefaultConfigPath();
43
+ }
44
+ //# sourceMappingURL=config-path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-path.js","sourceRoot":"","sources":["../../src/utils/config-path.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,MAAM,UAAU,mBAAmB;IACjC,MAAM,IAAI,GAAG,OAAO,EAAE,CAAC;IACvB,MAAM,EAAE,GAAG,QAAQ,EAAE,CAAC;IAEtB,QAAQ,EAAE,EAAE,CAAC;QACX,KAAK,OAAO;YACV,+BAA+B;YAC/B,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,CAAC,EAAE,WAAW,CAAC,CAAC;QACpF,KAAK,QAAQ;YACX,iDAAiD;YACjD,OAAO,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,qBAAqB,EAAE,WAAW,CAAC,CAAC;QACnE;YACE,wCAAwC;YACxC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,WAAW,CAAC,CAAC;IACnF,CAAC;AACH,CAAC;AAED,MAAM,UAAU,oBAAoB;IAClC,OAAO,IAAI,CAAC,mBAAmB,EAAE,EAAE,aAAa,CAAC,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,SAAkB;IAC7C,OAAO,IAAI,CAAC,SAAS,IAAI,mBAAmB,EAAE,EAAE,QAAQ,CAAC,CAAC;AAC5D,CAAC;AAMD,MAAM,UAAU,iBAAiB,CAAC,UAA6B,EAAE;IAC/D,gCAAgC;IAChC,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;QACvB,OAAO,OAAO,CAAC,UAAU,CAAC;IAC5B,CAAC;IAED,oDAAoD;IACpD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;IAC7C,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,mCAAmC;IACnC,OAAO,oBAAoB,EAAE,CAAC;AAChC,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * File system utilities with atomic write support
3
+ */
4
+ /**
5
+ * Atomic write: write to temp file then rename
6
+ * This ensures config file is never corrupted on crash
7
+ */
8
+ export declare function atomicWriteFile(filePath: string, content: string): Promise<void>;
9
+ /**
10
+ * Read file safely, return null if not found
11
+ */
12
+ export declare function readFileSafe(filePath: string): Promise<string | null>;
13
+ /**
14
+ * Check if file exists
15
+ */
16
+ export declare function fileExists(filePath: string): Promise<boolean>;
17
+ /**
18
+ * Append line to file (for JSONL event logging)
19
+ */
20
+ export declare function appendLine(filePath: string, line: string): Promise<void>;
21
+ /**
22
+ * Read last N lines from a file
23
+ */
24
+ export declare function readLastLines(filePath: string, n: number): Promise<string[]>;
25
+ //# sourceMappingURL=fs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../src/utils/fs.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH;;;GAGG;AACH,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBtF;AAED;;GAEG;AACH,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAS3E;AAED;;GAEG;AACH,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAOnE;AAED;;GAEG;AACH,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAI9E;AAED;;GAEG;AACH,wBAAsB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAWlF"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * File system utilities with atomic write support
3
+ */
4
+ import { promises as fs } from 'fs';
5
+ import { dirname, join } from 'path';
6
+ import { randomUUID } from 'crypto';
7
+ /**
8
+ * Atomic write: write to temp file then rename
9
+ * This ensures config file is never corrupted on crash
10
+ */
11
+ export async function atomicWriteFile(filePath, content) {
12
+ const dir = dirname(filePath);
13
+ await fs.mkdir(dir, { recursive: true });
14
+ const tmpPath = join(dir, `.${randomUUID()}.tmp`);
15
+ try {
16
+ await fs.writeFile(tmpPath, content, 'utf-8');
17
+ await fs.rename(tmpPath, filePath);
18
+ }
19
+ catch (error) {
20
+ // Clean up temp file on error
21
+ try {
22
+ await fs.unlink(tmpPath);
23
+ }
24
+ catch {
25
+ // Ignore cleanup errors
26
+ }
27
+ throw error;
28
+ }
29
+ }
30
+ /**
31
+ * Read file safely, return null if not found
32
+ */
33
+ export async function readFileSafe(filePath) {
34
+ try {
35
+ return await fs.readFile(filePath, 'utf-8');
36
+ }
37
+ catch (error) {
38
+ if (error instanceof Error && 'code' in error && error.code === 'ENOENT') {
39
+ return null;
40
+ }
41
+ throw error;
42
+ }
43
+ }
44
+ /**
45
+ * Check if file exists
46
+ */
47
+ export async function fileExists(filePath) {
48
+ try {
49
+ await fs.access(filePath);
50
+ return true;
51
+ }
52
+ catch {
53
+ return false;
54
+ }
55
+ }
56
+ /**
57
+ * Append line to file (for JSONL event logging)
58
+ */
59
+ export async function appendLine(filePath, line) {
60
+ const dir = dirname(filePath);
61
+ await fs.mkdir(dir, { recursive: true });
62
+ await fs.appendFile(filePath, line + '\n', 'utf-8');
63
+ }
64
+ /**
65
+ * Read last N lines from a file
66
+ */
67
+ export async function readLastLines(filePath, n) {
68
+ try {
69
+ const content = await fs.readFile(filePath, 'utf-8');
70
+ const lines = content.trim().split('\n').filter(Boolean);
71
+ return lines.slice(-n);
72
+ }
73
+ catch (error) {
74
+ if (error instanceof Error && 'code' in error && error.code === 'ENOENT') {
75
+ return [];
76
+ }
77
+ throw error;
78
+ }
79
+ }
80
+ //# sourceMappingURL=fs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs.js","sourceRoot":"","sources":["../../src/utils/fs.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,QAAgB,EAAE,OAAe;IACrE,MAAM,GAAG,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC9B,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAEzC,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,UAAU,EAAE,MAAM,CAAC,CAAC;IAClD,IAAI,CAAC;QACH,MAAM,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAC9C,MAAM,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACrC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,8BAA8B;QAC9B,IAAI,CAAC;YACH,MAAM,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC3B,CAAC;QAAC,MAAM,CAAC;YACP,wBAAwB;QAC1B,CAAC;QACD,MAAM,KAAK,CAA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AAO,CAAC,CAAC;QACzD,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACzB,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,IAAI,KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACzE,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './config-path.js';
2
+ export * from './fs.js';
3
+ export * from './output.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './config-path.js';
2
+ export * from './fs.js';
3
+ export * from './output.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Output utilities for CLI
3
+ */
4
+ export interface OutputOptions {
5
+ json?: boolean;
6
+ verbose?: boolean;
7
+ }
8
+ export declare function setOutputOptions(options: OutputOptions): void;
9
+ export declare function getOutputOptions(): OutputOptions;
10
+ export declare function output(data: unknown, humanReadable?: string): void;
11
+ export declare function outputError(message: string, error?: Error): void;
12
+ export declare function outputSuccess(message: string, data?: unknown): void;
13
+ export declare function outputTable(headers: string[], rows: string[][]): void;
14
+ /**
15
+ * Mask sensitive values for display
16
+ */
17
+ export declare function maskSecret(value: string, showChars?: number): string;
18
+ /**
19
+ * Mask secrets in an object (for display)
20
+ */
21
+ export declare function maskSecretsInObject(obj: unknown, secretKeys?: string[]): unknown;
22
+ //# sourceMappingURL=output.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/utils/output.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAID,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAE7D;AAED,wBAAgB,gBAAgB,IAAI,aAAa,CAEhD;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAMlE;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,CAYhE;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,CAanE;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,IAAI,CA4BrE;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,GAAE,MAAU,GAAG,MAAM,CAKvE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,EAAE,UAAU,GAAE,MAAM,EAAmD,GAAG,OAAO,CAqBhI"}
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Output utilities for CLI
3
+ */
4
+ let globalOptions = {};
5
+ export function setOutputOptions(options) {
6
+ globalOptions = { ...globalOptions, ...options };
7
+ }
8
+ export function getOutputOptions() {
9
+ return globalOptions;
10
+ }
11
+ export function output(data, humanReadable) {
12
+ if (globalOptions.json) {
13
+ console.log(JSON.stringify(data, null, 2));
14
+ }
15
+ else {
16
+ console.log(humanReadable ?? String(data));
17
+ }
18
+ }
19
+ export function outputError(message, error) {
20
+ if (globalOptions.json) {
21
+ console.error(JSON.stringify({
22
+ error: message,
23
+ details: error?.message,
24
+ }));
25
+ }
26
+ else {
27
+ console.error(`Error: ${message}`);
28
+ if (error && globalOptions.verbose) {
29
+ console.error(error.stack);
30
+ }
31
+ }
32
+ }
33
+ export function outputSuccess(message, data) {
34
+ if (globalOptions.json) {
35
+ const result = {
36
+ success: true,
37
+ message,
38
+ };
39
+ if (data !== undefined) {
40
+ result.data = data;
41
+ }
42
+ console.log(JSON.stringify(result));
43
+ }
44
+ else {
45
+ console.log(`✓ ${message}`);
46
+ }
47
+ }
48
+ export function outputTable(headers, rows) {
49
+ if (globalOptions.json) {
50
+ const objects = rows.map(row => {
51
+ const obj = {};
52
+ headers.forEach((h, i) => {
53
+ obj[h] = row[i] ?? '';
54
+ });
55
+ return obj;
56
+ });
57
+ console.log(JSON.stringify(objects, null, 2));
58
+ return;
59
+ }
60
+ // Calculate column widths
61
+ const widths = headers.map((h, i) => {
62
+ const cellWidths = [h.length, ...rows.map(r => (r[i] ?? '').length)];
63
+ return Math.max(...cellWidths);
64
+ });
65
+ // Print header
66
+ const headerLine = headers.map((h, i) => h.padEnd(widths[i])).join(' ');
67
+ console.log(headerLine);
68
+ console.log('-'.repeat(headerLine.length));
69
+ // Print rows
70
+ for (const row of rows) {
71
+ console.log(row.map((cell, i) => (cell ?? '').padEnd(widths[i])).join(' '));
72
+ }
73
+ }
74
+ /**
75
+ * Mask sensitive values for display
76
+ */
77
+ export function maskSecret(value, showChars = 4) {
78
+ if (value.length <= showChars * 2) {
79
+ return '****';
80
+ }
81
+ return value.slice(0, showChars) + '****' + value.slice(-showChars);
82
+ }
83
+ /**
84
+ * Mask secrets in an object (for display)
85
+ */
86
+ export function maskSecretsInObject(obj, secretKeys = ['token', 'key', 'secret', 'password', 'auth']) {
87
+ if (typeof obj !== 'object' || obj === null) {
88
+ return obj;
89
+ }
90
+ if (Array.isArray(obj)) {
91
+ return obj.map(item => maskSecretsInObject(item, secretKeys));
92
+ }
93
+ const masked = {};
94
+ for (const [key, value] of Object.entries(obj)) {
95
+ const isSecret = secretKeys.some(sk => key.toLowerCase().includes(sk));
96
+ if (isSecret && typeof value === 'string') {
97
+ masked[key] = maskSecret(value);
98
+ }
99
+ else if (typeof value === 'object' && value !== null) {
100
+ masked[key] = maskSecretsInObject(value, secretKeys);
101
+ }
102
+ else {
103
+ masked[key] = value;
104
+ }
105
+ }
106
+ return masked;
107
+ }
108
+ //# sourceMappingURL=output.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/utils/output.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,IAAI,aAAa,GAAkB,EAAE,CAAC;AAEtC,MAAM,UAAU,gBAAgB,CAAC,OAAsB;IACrD,aAAa,GAAG,EAAE,GAAG,aAAa,EAAE,GAAG,OAAO,EAAE,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,IAAa,EAAE,aAAsB;IAC1D,IAAI,aAAa,CAAC,IAAI,EAAE,CAAC;QACvB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC7C,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7C,CAAC;AACH,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,OAAe,EAAE,KAAa;IACxD,IAAI,aAAa,CAAC,IAAI,EAAE,CAAC;QACvB,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC;YAC3B,KAAK,EAAE,OAAO;YACd,OAAO,EAAE,KAAK,EAAE,OAAO;SACxB,CAAC,CAAC,CAAC;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