@artemiskit/cli 0.1.5 → 0.1.7
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/CHANGELOG.md +39 -0
- package/README.md +1 -0
- package/dist/index.js +19127 -20009
- package/dist/src/__tests__/helpers/index.d.ts +6 -0
- package/dist/src/__tests__/helpers/index.d.ts.map +1 -0
- package/dist/src/__tests__/helpers/mock-adapter.d.ts +87 -0
- package/dist/src/__tests__/helpers/mock-adapter.d.ts.map +1 -0
- package/dist/src/__tests__/helpers/test-utils.d.ts +47 -0
- package/dist/src/__tests__/helpers/test-utils.d.ts.map +1 -0
- package/dist/src/commands/compare.d.ts.map +1 -1
- package/dist/src/commands/history.d.ts.map +1 -1
- package/dist/src/commands/init.d.ts.map +1 -1
- package/dist/src/commands/redteam.d.ts.map +1 -1
- package/dist/src/commands/report.d.ts.map +1 -1
- package/dist/src/commands/run.d.ts.map +1 -1
- package/dist/src/commands/stress.d.ts.map +1 -1
- package/dist/src/ui/colors.d.ts +44 -0
- package/dist/src/ui/colors.d.ts.map +1 -0
- package/dist/src/ui/errors.d.ts +39 -0
- package/dist/src/ui/errors.d.ts.map +1 -0
- package/dist/src/ui/index.d.ts +16 -0
- package/dist/src/ui/index.d.ts.map +1 -0
- package/dist/src/ui/live-status.d.ts +82 -0
- package/dist/src/ui/live-status.d.ts.map +1 -0
- package/dist/src/ui/panels.d.ts +49 -0
- package/dist/src/ui/panels.d.ts.map +1 -0
- package/dist/src/ui/progress.d.ts +60 -0
- package/dist/src/ui/progress.d.ts.map +1 -0
- package/dist/src/ui/utils.d.ts +42 -0
- package/dist/src/ui/utils.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/__tests__/helpers/index.ts +6 -0
- package/src/__tests__/helpers/mock-adapter.ts +108 -0
- package/src/__tests__/helpers/test-utils.ts +205 -0
- package/src/__tests__/integration/compare-command.test.ts +236 -0
- package/src/__tests__/integration/config.test.ts +125 -0
- package/src/__tests__/integration/history-command.test.ts +251 -0
- package/src/__tests__/integration/init-command.test.ts +177 -0
- package/src/__tests__/integration/report-command.test.ts +245 -0
- package/src/__tests__/integration/ui.test.ts +230 -0
- package/src/commands/compare.ts +156 -49
- package/src/commands/history.ts +131 -30
- package/src/commands/init.ts +181 -21
- package/src/commands/redteam.ts +118 -75
- package/src/commands/report.ts +29 -14
- package/src/commands/run.ts +86 -66
- package/src/commands/stress.ts +61 -63
- package/src/ui/colors.ts +62 -0
- package/src/ui/errors.ts +248 -0
- package/src/ui/index.ts +42 -0
- package/src/ui/live-status.ts +259 -0
- package/src/ui/panels.ts +216 -0
- package/src/ui/progress.ts +139 -0
- package/src/ui/utils.ts +89 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/helpers/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mock adapter for CLI integration tests
|
|
3
|
+
*
|
|
4
|
+
* This module provides mock types and adapters for testing CLI commands
|
|
5
|
+
* without making actual LLM API calls.
|
|
6
|
+
*/
|
|
7
|
+
/** Message format for chat interactions */
|
|
8
|
+
export interface MockMessage {
|
|
9
|
+
role: 'system' | 'user' | 'assistant';
|
|
10
|
+
content: string;
|
|
11
|
+
}
|
|
12
|
+
/** Response from the mock adapter */
|
|
13
|
+
export interface MockLLMResponse {
|
|
14
|
+
content: string;
|
|
15
|
+
usage: {
|
|
16
|
+
input: number;
|
|
17
|
+
output: number;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/** Mock adapter interface */
|
|
21
|
+
export interface MockLLMAdapter {
|
|
22
|
+
chat: (messages: MockMessage[]) => Promise<MockLLMResponse>;
|
|
23
|
+
}
|
|
24
|
+
export interface MockResponse {
|
|
25
|
+
content: string;
|
|
26
|
+
latencyMs?: number;
|
|
27
|
+
tokens?: {
|
|
28
|
+
input: number;
|
|
29
|
+
output: number;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export interface MockAdapterOptions {
|
|
33
|
+
responses?: Map<string, MockResponse>;
|
|
34
|
+
defaultResponse?: MockResponse;
|
|
35
|
+
shouldFail?: boolean;
|
|
36
|
+
failureMessage?: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Creates a mock LLM adapter for testing
|
|
40
|
+
*/
|
|
41
|
+
export declare function createMockAdapter(options?: MockAdapterOptions): MockLLMAdapter;
|
|
42
|
+
/**
|
|
43
|
+
* Preset responses for common test scenarios
|
|
44
|
+
*/
|
|
45
|
+
export declare const mockResponses: {
|
|
46
|
+
greeting: {
|
|
47
|
+
content: string;
|
|
48
|
+
latencyMs: number;
|
|
49
|
+
tokens: {
|
|
50
|
+
input: number;
|
|
51
|
+
output: number;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
capitals: {
|
|
55
|
+
content: string;
|
|
56
|
+
latencyMs: number;
|
|
57
|
+
tokens: {
|
|
58
|
+
input: number;
|
|
59
|
+
output: number;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
math: {
|
|
63
|
+
content: string;
|
|
64
|
+
latencyMs: number;
|
|
65
|
+
tokens: {
|
|
66
|
+
input: number;
|
|
67
|
+
output: number;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
json: {
|
|
71
|
+
content: string;
|
|
72
|
+
latencyMs: number;
|
|
73
|
+
tokens: {
|
|
74
|
+
input: number;
|
|
75
|
+
output: number;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
code: {
|
|
79
|
+
content: string;
|
|
80
|
+
latencyMs: number;
|
|
81
|
+
tokens: {
|
|
82
|
+
input: number;
|
|
83
|
+
output: number;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
//# sourceMappingURL=mock-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-adapter.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/helpers/mock-adapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,2CAA2C;AAC3C,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qCAAqC;AACrC,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAC1C;AAED,6BAA6B;AAC7B,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,CAAC,QAAQ,EAAE,WAAW,EAAE,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC;CAC7D;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAC5C;AAED,MAAM,WAAW,kBAAkB;IACjC,SAAS,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACtC,eAAe,CAAC,EAAE,YAAY,CAAC;IAC/B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,kBAAuB,GAAG,cAAc,CAoClF;AAED;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BzB,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test utilities for CLI integration tests
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Creates a temporary directory for test isolation
|
|
6
|
+
*/
|
|
7
|
+
export declare function createTestDir(prefix?: string): Promise<string>;
|
|
8
|
+
/**
|
|
9
|
+
* Cleans up a test directory
|
|
10
|
+
*/
|
|
11
|
+
export declare function cleanupTestDir(testDir: string): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a test scenario file
|
|
14
|
+
*/
|
|
15
|
+
export declare function createScenarioFile(dir: string, name: string, content: string): Promise<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Creates a test config file
|
|
18
|
+
*/
|
|
19
|
+
export declare function createConfigFile(dir: string, config: Record<string, unknown>): Promise<string>;
|
|
20
|
+
/**
|
|
21
|
+
* Sample scenario templates for testing
|
|
22
|
+
*/
|
|
23
|
+
export declare const scenarioTemplates: {
|
|
24
|
+
simple: string;
|
|
25
|
+
multiCase: string;
|
|
26
|
+
withProvider: string;
|
|
27
|
+
exactMatch: string;
|
|
28
|
+
regexMatch: string;
|
|
29
|
+
failing: string;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Captures console output during test execution
|
|
33
|
+
*/
|
|
34
|
+
export declare class OutputCapture {
|
|
35
|
+
private originalLog;
|
|
36
|
+
private originalError;
|
|
37
|
+
private logs;
|
|
38
|
+
private errors;
|
|
39
|
+
start(): void;
|
|
40
|
+
stop(): {
|
|
41
|
+
logs: string[];
|
|
42
|
+
errors: string[];
|
|
43
|
+
};
|
|
44
|
+
getOutput(): string;
|
|
45
|
+
getErrors(): string;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=test-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-utils.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/helpers/test-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH;;GAEG;AACH,wBAAsB,aAAa,CAAC,MAAM,SAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,CAI5E;AAED;;GAEG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAMnE;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,CAAC,CAMjB;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,OAAO,CAAC,MAAM,CAAC,CAejB;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;CAgG7B,CAAC;AAEF;;GAEG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,WAAW,CAAmC;IACtD,OAAO,CAAC,aAAa,CAAuC;IAC5D,OAAO,CAAC,IAAI,CAAgB;IAC5B,OAAO,CAAC,MAAM,CAAgB;IAE9B,KAAK,IAAI,IAAI;IAeb,IAAI,IAAI;QAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAAC,MAAM,EAAE,MAAM,EAAE,CAAA;KAAE;IAM5C,SAAS,IAAI,MAAM;IAInB,SAAS,IAAI,MAAM;CAGpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compare.d.ts","sourceRoot":"","sources":["../../../src/commands/compare.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"compare.d.ts","sourceRoot":"","sources":["../../../src/commands/compare.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA2HpC,wBAAgB,cAAc,IAAI,OAAO,CAkFxC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../../src/commands/history.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../../src/commands/history.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA8FpC,wBAAgB,cAAc,IAAI,OAAO,CAiFxC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/commands/init.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/commands/init.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAoLpC,wBAAgB,WAAW,IAAI,OAAO,CAkFrC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redteam.d.ts","sourceRoot":"","sources":["../../../src/commands/redteam.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"redteam.d.ts","sourceRoot":"","sources":["../../../src/commands/redteam.ts"],"names":[],"mappings":"AAAA;;GAEG;AA8BH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAiCpC,wBAAgB,cAAc,IAAI,OAAO,CAyZxC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../../src/commands/report.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../../src/commands/report.ts"],"names":[],"mappings":"AAAA;;GAEG;AAWH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAoDpC,wBAAgB,aAAa,IAAI,OAAO,CA2EvC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/commands/run.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/commands/run.ts"],"names":[],"mappings":"AAAA;;GAEG;AASH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAmCpC,wBAAgB,UAAU,IAAI,OAAO,CA8MpC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stress.d.ts","sourceRoot":"","sources":["../../../src/commands/stress.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"stress.d.ts","sourceRoot":"","sources":["../../../src/commands/stress.ts"],"names":[],"mappings":"AAAA;;GAEG;AAiBH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAmCpC,wBAAgB,aAAa,IAAI,OAAO,CAoQvC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Consistent color scheme for CLI output
|
|
3
|
+
*/
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
export declare const colors: {
|
|
6
|
+
success: import("chalk").ChalkInstance;
|
|
7
|
+
error: import("chalk").ChalkInstance;
|
|
8
|
+
warning: import("chalk").ChalkInstance;
|
|
9
|
+
info: import("chalk").ChalkInstance;
|
|
10
|
+
muted: import("chalk").ChalkInstance;
|
|
11
|
+
passed: import("chalk").ChalkInstance;
|
|
12
|
+
failed: import("chalk").ChalkInstance;
|
|
13
|
+
skipped: import("chalk").ChalkInstance;
|
|
14
|
+
running: import("chalk").ChalkInstance;
|
|
15
|
+
border: import("chalk").ChalkInstance;
|
|
16
|
+
highlight: import("chalk").ChalkInstance;
|
|
17
|
+
label: import("chalk").ChalkInstance;
|
|
18
|
+
value: import("chalk").ChalkInstance;
|
|
19
|
+
percentGood: import("chalk").ChalkInstance;
|
|
20
|
+
percentWarn: import("chalk").ChalkInstance;
|
|
21
|
+
percentBad: import("chalk").ChalkInstance;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Returns appropriate color function based on percentage value
|
|
25
|
+
*/
|
|
26
|
+
export declare function colorByPercentage(value: number): typeof chalk;
|
|
27
|
+
/**
|
|
28
|
+
* Format a percentage value with appropriate coloring
|
|
29
|
+
*/
|
|
30
|
+
export declare function formatPercentage(value: number): string;
|
|
31
|
+
/**
|
|
32
|
+
* Status icons with colors
|
|
33
|
+
*/
|
|
34
|
+
export declare const icons: {
|
|
35
|
+
passed: string;
|
|
36
|
+
failed: string;
|
|
37
|
+
skipped: string;
|
|
38
|
+
running: string;
|
|
39
|
+
warning: string;
|
|
40
|
+
info: string;
|
|
41
|
+
arrow: string;
|
|
42
|
+
bullet: string;
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=colors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../../src/ui/colors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;CAwBlB,CAAC;AAEF;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,KAAK,CAI7D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGtD;AAED;;GAEG;AACH,eAAO,MAAM,KAAK;;;;;;;;;CASjB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enhanced error display formatting
|
|
3
|
+
*/
|
|
4
|
+
export interface ErrorContext {
|
|
5
|
+
/** Main error title */
|
|
6
|
+
title: string;
|
|
7
|
+
/** Reason for the error */
|
|
8
|
+
reason: string;
|
|
9
|
+
/** Actionable suggestions for the user */
|
|
10
|
+
suggestions?: string[];
|
|
11
|
+
/** Additional context details */
|
|
12
|
+
details?: Record<string, string>;
|
|
13
|
+
/** Error code (if applicable) */
|
|
14
|
+
code?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Render an enhanced error panel with context and suggestions
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* renderError({
|
|
21
|
+
* title: 'Failed to connect to Azure OpenAI',
|
|
22
|
+
* reason: 'Invalid API key or resource not found',
|
|
23
|
+
* suggestions: [
|
|
24
|
+
* 'Check AZURE_OPENAI_API_KEY is set correctly',
|
|
25
|
+
* 'Verify resource name: my-openai-resource',
|
|
26
|
+
* "Run 'artemiskit init' to reconfigure"
|
|
27
|
+
* ]
|
|
28
|
+
* })
|
|
29
|
+
*/
|
|
30
|
+
export declare function renderError(ctx: ErrorContext): string;
|
|
31
|
+
/**
|
|
32
|
+
* Render a warning panel (less severe than error)
|
|
33
|
+
*/
|
|
34
|
+
export declare function renderWarning(title: string, message: string, suggestions?: string[]): string;
|
|
35
|
+
/**
|
|
36
|
+
* Format provider-specific error messages with suggestions
|
|
37
|
+
*/
|
|
38
|
+
export declare function getProviderErrorContext(provider: string, error: Error): ErrorContext;
|
|
39
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/ui/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,MAAM,WAAW,YAAY;IAC3B,uBAAuB;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,2BAA2B;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,0CAA0C;IAC1C,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,iCAAiC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,iCAAiC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM,CAgFrD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAsD5F;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,YAAY,CAqEpF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI UI Components
|
|
3
|
+
*
|
|
4
|
+
* Centralized UI utilities for consistent CLI output formatting.
|
|
5
|
+
*/
|
|
6
|
+
export { colors, icons, colorByPercentage, formatPercentage } from './colors.js';
|
|
7
|
+
export { isTTY, getTerminalWidth, renderConditional, centerText, padText, stripAnsi, truncate, formatDuration, formatNumber, } from './utils.js';
|
|
8
|
+
export { renderProgressBar, ProgressBar, renderInlineProgress } from './progress.js';
|
|
9
|
+
export type { ProgressBarOptions } from './progress.js';
|
|
10
|
+
export { renderSummaryPanel, renderStressSummaryPanel, renderRedteamSummaryPanel, renderInfoBox, } from './panels.js';
|
|
11
|
+
export type { SummaryData, StressSummaryData, RedteamSummaryData } from './panels.js';
|
|
12
|
+
export { renderError, renderWarning, getProviderErrorContext } from './errors.js';
|
|
13
|
+
export type { ErrorContext } from './errors.js';
|
|
14
|
+
export { LiveTestStatus, Spinner, createSpinner } from './live-status.js';
|
|
15
|
+
export type { TestStatus } from './live-status.js';
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGjF,OAAO,EACL,KAAK,EACL,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,OAAO,EACP,SAAS,EACT,QAAQ,EACR,cAAc,EACd,YAAY,GACb,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrF,YAAY,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAGxD,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,yBAAyB,EACzB,aAAa,GACd,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGtF,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAClF,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGhD,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC1E,YAAY,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Real-time test status updates
|
|
3
|
+
*/
|
|
4
|
+
export type TestStatus = 'pending' | 'running' | 'passed' | 'failed' | 'skipped';
|
|
5
|
+
/**
|
|
6
|
+
* Live test status tracker with real-time updates
|
|
7
|
+
*/
|
|
8
|
+
export declare class LiveTestStatus {
|
|
9
|
+
private spinner;
|
|
10
|
+
private results;
|
|
11
|
+
private total;
|
|
12
|
+
private startTime;
|
|
13
|
+
constructor(total: number);
|
|
14
|
+
/**
|
|
15
|
+
* Start tracking a test
|
|
16
|
+
*/
|
|
17
|
+
start(testId: string, testName: string): void;
|
|
18
|
+
/**
|
|
19
|
+
* Mark a test as passed
|
|
20
|
+
*/
|
|
21
|
+
pass(testId: string, duration?: number): void;
|
|
22
|
+
/**
|
|
23
|
+
* Mark a test as failed
|
|
24
|
+
*/
|
|
25
|
+
fail(testId: string, error?: string, duration?: number): void;
|
|
26
|
+
/**
|
|
27
|
+
* Mark a test as skipped
|
|
28
|
+
*/
|
|
29
|
+
skip(testId: string): void;
|
|
30
|
+
/**
|
|
31
|
+
* Update spinner text
|
|
32
|
+
*/
|
|
33
|
+
private updateSpinner;
|
|
34
|
+
/**
|
|
35
|
+
* Format current status line
|
|
36
|
+
*/
|
|
37
|
+
private formatStatus;
|
|
38
|
+
/**
|
|
39
|
+
* Count results by status
|
|
40
|
+
*/
|
|
41
|
+
private countByStatus;
|
|
42
|
+
/**
|
|
43
|
+
* Complete tracking and print final status
|
|
44
|
+
*/
|
|
45
|
+
complete(): void;
|
|
46
|
+
/**
|
|
47
|
+
* Print final status for all tests
|
|
48
|
+
*/
|
|
49
|
+
private printFinalStatus;
|
|
50
|
+
/**
|
|
51
|
+
* Get icon for status
|
|
52
|
+
*/
|
|
53
|
+
private getStatusIcon;
|
|
54
|
+
/**
|
|
55
|
+
* Get summary statistics
|
|
56
|
+
*/
|
|
57
|
+
getSummary(): {
|
|
58
|
+
passed: number;
|
|
59
|
+
failed: number;
|
|
60
|
+
skipped: number;
|
|
61
|
+
duration: number;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Simple spinner wrapper with consistent styling
|
|
66
|
+
*/
|
|
67
|
+
export declare class Spinner {
|
|
68
|
+
private spinner;
|
|
69
|
+
constructor(text?: string);
|
|
70
|
+
start(text?: string): this;
|
|
71
|
+
update(text: string): this;
|
|
72
|
+
succeed(text?: string): this;
|
|
73
|
+
fail(text?: string): this;
|
|
74
|
+
warn(text?: string): this;
|
|
75
|
+
info(text?: string): this;
|
|
76
|
+
stop(): this;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Create a new spinner instance
|
|
80
|
+
*/
|
|
81
|
+
export declare function createSpinner(text?: string): Spinner;
|
|
82
|
+
//# sourceMappingURL=live-status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"live-status.d.ts","sourceRoot":"","sources":["../../../src/ui/live-status.ts"],"names":[],"mappings":"AAAA;;GAEG;AAQH,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AASjF;;GAEG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,OAAO,CAAM;IACrB,OAAO,CAAC,OAAO,CAAsC;IACrD,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,SAAS,CAAsB;gBAE3B,KAAK,EAAE,MAAM;IAQzB;;OAEG;IACH,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAU7C;;OAEG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI;IAS7C;;OAEG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI;IAU7D;;OAEG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAQ1B;;OAEG;IACH,OAAO,CAAC,aAAa;IAMrB;;OAEG;IACH,OAAO,CAAC,YAAY;IAepB;;OAEG;IACH,OAAO,CAAC,aAAa;IAIrB;;OAEG;IACH,QAAQ,IAAI,IAAI;IAOhB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAgBxB;;OAEG;IACH,OAAO,CAAC,aAAa;IAerB;;OAEG;IACH,UAAU,IAAI;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE;CAQpF;AAED;;GAEG;AACH,qBAAa,OAAO;IAClB,OAAO,CAAC,OAAO,CAAM;gBAET,IAAI,CAAC,EAAE,MAAM;IAQzB,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI;IAS1B,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAO1B,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI;IAS5B,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI;IASzB,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI;IASzB,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI;IASzB,IAAI,IAAI,IAAI;CAMb;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAEpD"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Panel rendering for summary displays
|
|
3
|
+
*/
|
|
4
|
+
export interface SummaryData {
|
|
5
|
+
passed: number;
|
|
6
|
+
failed: number;
|
|
7
|
+
skipped: number;
|
|
8
|
+
successRate: number;
|
|
9
|
+
duration: number;
|
|
10
|
+
title?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface StressSummaryData {
|
|
13
|
+
totalRequests: number;
|
|
14
|
+
successfulRequests: number;
|
|
15
|
+
failedRequests: number;
|
|
16
|
+
successRate: number;
|
|
17
|
+
duration: number;
|
|
18
|
+
avgLatency: number;
|
|
19
|
+
p50Latency: number;
|
|
20
|
+
p95Latency: number;
|
|
21
|
+
p99Latency: number;
|
|
22
|
+
throughput: number;
|
|
23
|
+
}
|
|
24
|
+
export interface RedteamSummaryData {
|
|
25
|
+
totalCases: number;
|
|
26
|
+
safeResponses: number;
|
|
27
|
+
unsafeResponses: number;
|
|
28
|
+
blockedResponses: number;
|
|
29
|
+
errorResponses: number;
|
|
30
|
+
defenseRate: number;
|
|
31
|
+
severityBreakdown?: Record<string, number>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Render a test results summary panel
|
|
35
|
+
*/
|
|
36
|
+
export declare function renderSummaryPanel(data: SummaryData): string;
|
|
37
|
+
/**
|
|
38
|
+
* Render a stress test summary panel
|
|
39
|
+
*/
|
|
40
|
+
export declare function renderStressSummaryPanel(data: StressSummaryData): string;
|
|
41
|
+
/**
|
|
42
|
+
* Render a red team summary panel
|
|
43
|
+
*/
|
|
44
|
+
export declare function renderRedteamSummaryPanel(data: RedteamSummaryData): string;
|
|
45
|
+
/**
|
|
46
|
+
* Render a simple info box
|
|
47
|
+
*/
|
|
48
|
+
export declare function renderInfoBox(title: string, lines: string[]): string;
|
|
49
|
+
//# sourceMappingURL=panels.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"panels.d.ts","sourceRoot":"","sources":["../../../src/ui/panels.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,iBAAiB;IAChC,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC5C;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,CAiC5D;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,iBAAiB,GAAG,MAAM,CA0DxE;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,kBAAkB,GAAG,MAAM,CA4C1E;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAsBpE"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Progress bar rendering utilities
|
|
3
|
+
*/
|
|
4
|
+
export interface ProgressBarOptions {
|
|
5
|
+
/** Width of the progress bar in characters */
|
|
6
|
+
width?: number;
|
|
7
|
+
/** Character for filled portion */
|
|
8
|
+
filledChar?: string;
|
|
9
|
+
/** Character for empty portion */
|
|
10
|
+
emptyChar?: string;
|
|
11
|
+
/** Show percentage */
|
|
12
|
+
showPercentage?: boolean;
|
|
13
|
+
/** Show count (current/total) */
|
|
14
|
+
showCount?: boolean;
|
|
15
|
+
/** Label to show before the bar */
|
|
16
|
+
label?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Render a progress bar
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* renderProgressBar(3, 10)
|
|
23
|
+
* // "████████░░░░░░░░░░░░ 3/10 (30%)"
|
|
24
|
+
*
|
|
25
|
+
* renderProgressBar(3, 10, { label: 'Running tests' })
|
|
26
|
+
* // "Running tests ████████░░░░░░░░░░░░ 3/10 (30%)"
|
|
27
|
+
*/
|
|
28
|
+
export declare function renderProgressBar(current: number, total: number, options?: ProgressBarOptions): string;
|
|
29
|
+
/**
|
|
30
|
+
* Create a progress bar manager for updating in-place
|
|
31
|
+
*/
|
|
32
|
+
export declare class ProgressBar {
|
|
33
|
+
private current;
|
|
34
|
+
private total;
|
|
35
|
+
private options;
|
|
36
|
+
private lastOutput;
|
|
37
|
+
constructor(total: number, options?: ProgressBarOptions);
|
|
38
|
+
/**
|
|
39
|
+
* Update progress and render
|
|
40
|
+
*/
|
|
41
|
+
update(current: number): void;
|
|
42
|
+
/**
|
|
43
|
+
* Increment progress by one
|
|
44
|
+
*/
|
|
45
|
+
increment(): void;
|
|
46
|
+
/**
|
|
47
|
+
* Render the progress bar
|
|
48
|
+
*/
|
|
49
|
+
private render;
|
|
50
|
+
/**
|
|
51
|
+
* Complete the progress bar and move to next line
|
|
52
|
+
*/
|
|
53
|
+
complete(): void;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Render a compact inline progress indicator
|
|
57
|
+
* Useful for spinners or status lines
|
|
58
|
+
*/
|
|
59
|
+
export declare function renderInlineProgress(current: number, total: number, label?: string): string;
|
|
60
|
+
//# sourceMappingURL=progress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../../../src/ui/progress.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,MAAM,WAAW,kBAAkB;IACjC,8CAA8C;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mCAAmC;IACnC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kCAAkC;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sBAAsB;IACtB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,iCAAiC;IACjC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,mCAAmC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAWD;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,kBAAuB,GAC/B,MAAM,CAyBR;AAED;;GAEG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,OAAO,CAA+B;IAC9C,OAAO,CAAC,UAAU,CAAM;gBAEZ,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,kBAAuB;IAK3D;;OAEG;IACH,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAK7B;;OAEG;IACH,SAAS,IAAI,IAAI;IAIjB;;OAEG;IACH,OAAO,CAAC,MAAM;IAYd;;OAEG;IACH,QAAQ,IAAI,IAAI;CAMjB;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAO3F"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UI utility functions for terminal handling
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Check if stdout is a TTY (interactive terminal)
|
|
6
|
+
*/
|
|
7
|
+
export declare const isTTY: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Get terminal width, with fallback for non-TTY environments
|
|
10
|
+
*/
|
|
11
|
+
export declare function getTerminalWidth(): number;
|
|
12
|
+
/**
|
|
13
|
+
* Render different output based on TTY availability
|
|
14
|
+
* @param ttyOutput Output for interactive terminals
|
|
15
|
+
* @param plainOutput Output for non-TTY (CI/CD) environments
|
|
16
|
+
*/
|
|
17
|
+
export declare function renderConditional(ttyOutput: string, plainOutput: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Center text within a given width
|
|
20
|
+
*/
|
|
21
|
+
export declare function centerText(text: string, width: number): string;
|
|
22
|
+
/**
|
|
23
|
+
* Pad text to a specific width (accounting for ANSI codes)
|
|
24
|
+
*/
|
|
25
|
+
export declare function padText(text: string, width: number, align?: 'left' | 'right' | 'center'): string;
|
|
26
|
+
/**
|
|
27
|
+
* Strip ANSI escape codes from string (for length calculations)
|
|
28
|
+
*/
|
|
29
|
+
export declare function stripAnsi(str: string): string;
|
|
30
|
+
/**
|
|
31
|
+
* Truncate text to fit within a width, adding ellipsis if needed
|
|
32
|
+
*/
|
|
33
|
+
export declare function truncate(text: string, maxWidth: number): string;
|
|
34
|
+
/**
|
|
35
|
+
* Format duration in a human-readable way
|
|
36
|
+
*/
|
|
37
|
+
export declare function formatDuration(ms: number): string;
|
|
38
|
+
/**
|
|
39
|
+
* Format a number with commas for readability
|
|
40
|
+
*/
|
|
41
|
+
export declare function formatNumber(num: number): string;
|
|
42
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/ui/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,eAAO,MAAM,KAAK,SAAgC,CAAC;AAEnD;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAEhF;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAK9D;AAED;;GAEG;AACH,wBAAgB,OAAO,CACrB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,KAAK,GAAE,MAAM,GAAG,OAAO,GAAG,QAAiB,GAC1C,MAAM,CAWR;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG7C;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAI/D;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAMjD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEhD"}
|
package/package.json
CHANGED