claude-scope 0.1.2 → 0.1.4

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 (92) hide show
  1. package/dist/constants.d.ts +56 -0
  2. package/dist/constants.d.ts.map +1 -0
  3. package/dist/constants.js +57 -0
  4. package/dist/constants.js.map +1 -0
  5. package/dist/core/renderer.d.ts +33 -3
  6. package/dist/core/renderer.d.ts.map +1 -1
  7. package/dist/core/renderer.js +49 -7
  8. package/dist/core/renderer.js.map +1 -1
  9. package/dist/core/stdin-data-widget.d.ts +85 -0
  10. package/dist/core/stdin-data-widget.d.ts.map +1 -0
  11. package/dist/core/stdin-data-widget.js +75 -0
  12. package/dist/core/stdin-data-widget.js.map +1 -0
  13. package/dist/core/widget-types.d.ts +30 -0
  14. package/dist/core/widget-types.d.ts.map +1 -0
  15. package/dist/core/widget-types.js +30 -0
  16. package/dist/core/widget-types.js.map +1 -0
  17. package/dist/data/stdin-provider.d.ts +44 -0
  18. package/dist/data/stdin-provider.d.ts.map +1 -0
  19. package/dist/data/stdin-provider.js +83 -0
  20. package/dist/data/stdin-provider.js.map +1 -0
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +64 -21
  23. package/dist/index.js.map +1 -1
  24. package/dist/providers/git-provider.d.ts +55 -32
  25. package/dist/providers/git-provider.d.ts.map +1 -1
  26. package/dist/providers/git-provider.js +63 -40
  27. package/dist/providers/git-provider.js.map +1 -1
  28. package/dist/providers/stdin-provider.d.ts +16 -15
  29. package/dist/providers/stdin-provider.d.ts.map +1 -1
  30. package/dist/providers/stdin-provider.js +35 -66
  31. package/dist/providers/stdin-provider.js.map +1 -1
  32. package/dist/schemas/stdin-schema.d.ts +123 -0
  33. package/dist/schemas/stdin-schema.d.ts.map +1 -0
  34. package/dist/schemas/stdin-schema.js +81 -0
  35. package/dist/schemas/stdin-schema.js.map +1 -0
  36. package/dist/types.d.ts +13 -15
  37. package/dist/types.d.ts.map +1 -1
  38. package/dist/types.js +3 -0
  39. package/dist/types.js.map +1 -1
  40. package/dist/ui/utils/colors.d.ts +52 -0
  41. package/dist/ui/utils/colors.d.ts.map +1 -0
  42. package/dist/ui/utils/colors.js +54 -0
  43. package/dist/ui/utils/colors.js.map +1 -0
  44. package/dist/ui/utils/formatters.d.ts +56 -0
  45. package/dist/ui/utils/formatters.d.ts.map +1 -0
  46. package/dist/ui/utils/formatters.js +114 -0
  47. package/dist/ui/utils/formatters.js.map +1 -0
  48. package/dist/utils/colors.d.ts +16 -0
  49. package/dist/utils/colors.d.ts.map +1 -1
  50. package/dist/utils/colors.js +18 -0
  51. package/dist/utils/colors.js.map +1 -1
  52. package/dist/utils/formatters.d.ts +56 -0
  53. package/dist/utils/formatters.d.ts.map +1 -0
  54. package/dist/utils/formatters.js +114 -0
  55. package/dist/utils/formatters.js.map +1 -0
  56. package/dist/widgets/context-widget.d.ts +13 -0
  57. package/dist/widgets/context-widget.d.ts.map +1 -0
  58. package/dist/widgets/context-widget.js +31 -0
  59. package/dist/widgets/context-widget.js.map +1 -0
  60. package/dist/widgets/core/stdin-data-widget.d.ts +93 -0
  61. package/dist/widgets/core/stdin-data-widget.d.ts.map +1 -0
  62. package/dist/widgets/core/stdin-data-widget.js +84 -0
  63. package/dist/widgets/core/stdin-data-widget.js.map +1 -0
  64. package/dist/widgets/cost-widget.d.ts +13 -0
  65. package/dist/widgets/cost-widget.d.ts.map +1 -0
  66. package/dist/widgets/cost-widget.js +18 -0
  67. package/dist/widgets/cost-widget.js.map +1 -0
  68. package/dist/widgets/duration-widget.d.ts +13 -0
  69. package/dist/widgets/duration-widget.d.ts.map +1 -0
  70. package/dist/widgets/duration-widget.js +18 -0
  71. package/dist/widgets/duration-widget.js.map +1 -0
  72. package/dist/widgets/git/git-changes-widget.d.ts +38 -0
  73. package/dist/widgets/git/git-changes-widget.d.ts.map +1 -0
  74. package/dist/widgets/git/git-changes-widget.js +91 -0
  75. package/dist/widgets/git/git-changes-widget.js.map +1 -0
  76. package/dist/widgets/git/git-widget.d.ts +37 -0
  77. package/dist/widgets/git/git-widget.d.ts.map +1 -0
  78. package/dist/widgets/git/git-widget.js +67 -0
  79. package/dist/widgets/git/git-widget.js.map +1 -0
  80. package/dist/widgets/git-changes-widget.d.ts +16 -0
  81. package/dist/widgets/git-changes-widget.d.ts.map +1 -0
  82. package/dist/widgets/git-changes-widget.js +37 -0
  83. package/dist/widgets/git-changes-widget.js.map +1 -0
  84. package/dist/widgets/git-widget.d.ts +8 -2
  85. package/dist/widgets/git-widget.d.ts.map +1 -1
  86. package/dist/widgets/git-widget.js +9 -9
  87. package/dist/widgets/git-widget.js.map +1 -1
  88. package/dist/widgets/model-widget.d.ts +13 -0
  89. package/dist/widgets/model-widget.d.ts.map +1 -0
  90. package/dist/widgets/model-widget.js +15 -0
  91. package/dist/widgets/model-widget.js.map +1 -0
  92. package/package.json +14 -6
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Constants used throughout the application
3
+ */
4
+ /**
5
+ * Time-related constants
6
+ */
7
+ export declare const TIME: {
8
+ /** Milliseconds per second */
9
+ readonly MS_PER_SECOND: 1000;
10
+ /** Seconds per minute */
11
+ readonly SECONDS_PER_MINUTE: 60;
12
+ /** Seconds per hour */
13
+ readonly SECONDS_PER_HOUR: 3600;
14
+ };
15
+ /**
16
+ * Cost formatting thresholds
17
+ */
18
+ export declare const COST_THRESHOLDS: {
19
+ /** Below this value, show 4 decimal places ($0.0012) */
20
+ readonly SMALL: 0.01;
21
+ /** Above this value, show no decimal places ($123) */
22
+ readonly LARGE: 100;
23
+ };
24
+ /**
25
+ * Context usage color thresholds (percentages)
26
+ */
27
+ export declare const CONTEXT_THRESHOLDS: {
28
+ /** Below this: green (low usage) */
29
+ readonly LOW_MEDIUM: 50;
30
+ /** Below this: yellow (medium usage), above: red (high usage) */
31
+ readonly MEDIUM_HIGH: 80;
32
+ };
33
+ /**
34
+ * Default values
35
+ */
36
+ export declare const DEFAULTS: {
37
+ /** Default separator between widgets */
38
+ readonly SEPARATOR: " ";
39
+ /** Default width for progress bars in characters */
40
+ readonly PROGRESS_BAR_WIDTH: 20;
41
+ };
42
+ /**
43
+ * ANSI color codes
44
+ */
45
+ export declare const ANSI_COLORS: {
46
+ /** Green color */
47
+ readonly GREEN: "\u001B[32m";
48
+ /** Yellow color */
49
+ readonly YELLOW: "\u001B[33m";
50
+ /** Red color */
51
+ readonly RED: "\u001B[31m";
52
+ /** Reset color */
53
+ readonly RESET: "\u001B[0m";
54
+ };
55
+ export declare const DEFAULT_PROGRESS_BAR_WIDTH: 20;
56
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,eAAO,MAAM,IAAI;IACf,8BAA8B;;IAE9B,yBAAyB;;IAEzB,uBAAuB;;CAEf,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,eAAe;IAC1B,wDAAwD;;IAExD,sDAAsD;;CAE9C,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,kBAAkB;IAC7B,oCAAoC;;IAEpC,iEAAiE;;CAEzD,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,QAAQ;IACnB,wCAAwC;;IAExC,oDAAoD;;CAE5C,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,WAAW;IACtB,kBAAkB;;IAElB,mBAAmB;;IAEnB,gBAAgB;;IAEhB,kBAAkB;;CAEV,CAAC;AAGX,eAAO,MAAM,0BAA0B,IAA8B,CAAC"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Constants used throughout the application
3
+ */
4
+ /**
5
+ * Time-related constants
6
+ */
7
+ export const TIME = {
8
+ /** Milliseconds per second */
9
+ MS_PER_SECOND: 1000,
10
+ /** Seconds per minute */
11
+ SECONDS_PER_MINUTE: 60,
12
+ /** Seconds per hour */
13
+ SECONDS_PER_HOUR: 3600,
14
+ };
15
+ /**
16
+ * Cost formatting thresholds
17
+ */
18
+ export const COST_THRESHOLDS = {
19
+ /** Below this value, show 4 decimal places ($0.0012) */
20
+ SMALL: 0.01,
21
+ /** Above this value, show no decimal places ($123) */
22
+ LARGE: 100,
23
+ };
24
+ /**
25
+ * Context usage color thresholds (percentages)
26
+ */
27
+ export const CONTEXT_THRESHOLDS = {
28
+ /** Below this: green (low usage) */
29
+ LOW_MEDIUM: 50,
30
+ /** Below this: yellow (medium usage), above: red (high usage) */
31
+ MEDIUM_HIGH: 80,
32
+ };
33
+ /**
34
+ * Default values
35
+ */
36
+ export const DEFAULTS = {
37
+ /** Default separator between widgets */
38
+ SEPARATOR: ' ',
39
+ /** Default width for progress bars in characters */
40
+ PROGRESS_BAR_WIDTH: 20,
41
+ };
42
+ /**
43
+ * ANSI color codes
44
+ */
45
+ export const ANSI_COLORS = {
46
+ /** Green color */
47
+ GREEN: '\x1b[32m',
48
+ /** Yellow color */
49
+ YELLOW: '\x1b[33m',
50
+ /** Red color */
51
+ RED: '\x1b[31m',
52
+ /** Reset color */
53
+ RESET: '\x1b[0m',
54
+ };
55
+ // Re-export for backward compatibility
56
+ export const DEFAULT_PROGRESS_BAR_WIDTH = DEFAULTS.PROGRESS_BAR_WIDTH;
57
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG;IAClB,8BAA8B;IAC9B,aAAa,EAAE,IAAI;IACnB,yBAAyB;IACzB,kBAAkB,EAAE,EAAE;IACtB,uBAAuB;IACvB,gBAAgB,EAAE,IAAI;CACd,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,wDAAwD;IACxD,KAAK,EAAE,IAAI;IACX,sDAAsD;IACtD,KAAK,EAAE,GAAG;CACF,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,oCAAoC;IACpC,UAAU,EAAE,EAAE;IACd,iEAAiE;IACjE,WAAW,EAAE,EAAE;CACP,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,wCAAwC;IACxC,SAAS,EAAE,GAAG;IACd,oDAAoD;IACpD,kBAAkB,EAAE,EAAE;CACd,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,kBAAkB;IAClB,KAAK,EAAE,UAAU;IACjB,mBAAmB;IACnB,MAAM,EAAE,UAAU;IAClB,gBAAgB;IAChB,GAAG,EAAE,UAAU;IACf,kBAAkB;IAClB,KAAK,EAAE,SAAS;CACR,CAAC;AAEX,uCAAuC;AACvC,MAAM,CAAC,MAAM,0BAA0B,GAAG,QAAQ,CAAC,kBAAkB,CAAC"}
@@ -1,21 +1,51 @@
1
1
  /**
2
- * Unified rendering engine
2
+ * Unified rendering engine with error boundaries
3
3
  * Combines widget outputs into statusline
4
4
  */
5
5
  import type { IWidget } from './types.js';
6
6
  import type { RenderContext } from '../types.js';
7
7
  /**
8
- * Renderer for combining widget outputs
8
+ * Renderer configuration options
9
+ */
10
+ export interface RendererOptions {
11
+ /** Separator between widget outputs */
12
+ separator?: string;
13
+ /** Error handler callback for widget render failures */
14
+ onError?: (error: Error, widget: IWidget) => void;
15
+ /** Show error placeholder in output (for debugging) */
16
+ showErrors?: boolean;
17
+ }
18
+ /**
19
+ * Renderer for combining widget outputs with error boundaries
20
+ *
21
+ * Failed widgets are gracefully skipped, preventing single widget
22
+ * failures from breaking the entire statusline.
9
23
  */
10
24
  export declare class Renderer {
11
25
  private separator;
26
+ private onError?;
27
+ private showErrors;
28
+ constructor(options?: RendererOptions);
12
29
  /**
13
- * Render widgets into a single line
30
+ * Render widgets into a single line with error boundaries
31
+ *
32
+ * Widgets that throw errors are logged (via onError callback) and skipped,
33
+ * allowing other widgets to continue rendering.
34
+ *
35
+ * @param widgets - Array of widgets to render
36
+ * @param context - Render context with width and timestamp
37
+ * @returns Combined widget outputs separated by separator
14
38
  */
15
39
  render(widgets: IWidget[], context: RenderContext): Promise<string>;
16
40
  /**
17
41
  * Set custom separator
18
42
  */
19
43
  setSeparator(separator: string): void;
44
+ /**
45
+ * Handle widget render errors
46
+ *
47
+ * Calls the onError callback if provided, otherwise logs to console.warn
48
+ */
49
+ private handleError;
20
50
  }
21
51
  //# sourceMappingURL=renderer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../src/core/renderer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD;;GAEG;AACH,qBAAa,QAAQ;IACnB,OAAO,CAAC,SAAS,CAAO;IAExB;;OAEG;IACG,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC;IAiBzE;;OAEG;IACH,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;CAGtC"}
1
+ {"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../src/core/renderer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGjD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,uCAAuC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wDAAwD;IACxD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IAClD,uDAAuD;IACvD,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;;;;GAKG;AACH,qBAAa,QAAQ;IACnB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,OAAO,CAAC,CAA0C;IAC1D,OAAO,CAAC,UAAU,CAAU;gBAEhB,OAAO,GAAE,eAAoB;IAMzC;;;;;;;;;OASG;IACG,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC;IA2BzE;;OAEG;IACH,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAIrC;;;;OAIG;IACH,OAAO,CAAC,WAAW;CAQpB"}
@@ -1,14 +1,32 @@
1
1
  /**
2
- * Unified rendering engine
2
+ * Unified rendering engine with error boundaries
3
3
  * Combines widget outputs into statusline
4
4
  */
5
+ import { DEFAULTS } from '../constants.js';
5
6
  /**
6
- * Renderer for combining widget outputs
7
+ * Renderer for combining widget outputs with error boundaries
8
+ *
9
+ * Failed widgets are gracefully skipped, preventing single widget
10
+ * failures from breaking the entire statusline.
7
11
  */
8
12
  export class Renderer {
9
- separator = ' ';
13
+ separator;
14
+ onError;
15
+ showErrors;
16
+ constructor(options = {}) {
17
+ this.separator = options.separator ?? DEFAULTS.SEPARATOR;
18
+ this.onError = options.onError;
19
+ this.showErrors = options.showErrors ?? false;
20
+ }
10
21
  /**
11
- * Render widgets into a single line
22
+ * Render widgets into a single line with error boundaries
23
+ *
24
+ * Widgets that throw errors are logged (via onError callback) and skipped,
25
+ * allowing other widgets to continue rendering.
26
+ *
27
+ * @param widgets - Array of widgets to render
28
+ * @param context - Render context with width and timestamp
29
+ * @returns Combined widget outputs separated by separator
12
30
  */
13
31
  async render(widgets, context) {
14
32
  const outputs = [];
@@ -16,9 +34,19 @@ export class Renderer {
16
34
  if (!widget.isEnabled()) {
17
35
  continue;
18
36
  }
19
- const output = await widget.render(context);
20
- if (output !== null) {
21
- outputs.push(output);
37
+ try {
38
+ const output = await widget.render(context);
39
+ if (output !== null) {
40
+ outputs.push(output);
41
+ }
42
+ }
43
+ catch (error) {
44
+ // Log error but continue rendering other widgets
45
+ this.handleError(error, widget);
46
+ // Optional: show error placeholder in output
47
+ if (this.showErrors) {
48
+ outputs.push(`${widget.id}:<err>`);
49
+ }
22
50
  }
23
51
  }
24
52
  return outputs.join(this.separator);
@@ -29,5 +57,19 @@ export class Renderer {
29
57
  setSeparator(separator) {
30
58
  this.separator = separator;
31
59
  }
60
+ /**
61
+ * Handle widget render errors
62
+ *
63
+ * Calls the onError callback if provided, otherwise logs to console.warn
64
+ */
65
+ handleError(error, widget) {
66
+ if (this.onError) {
67
+ this.onError(error, widget);
68
+ }
69
+ else {
70
+ // Default: silent fail with console.warn
71
+ console.warn(`[Widget ${widget.id}] ${error.message}`);
72
+ }
73
+ }
32
74
  }
33
75
  //# sourceMappingURL=renderer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"renderer.js","sourceRoot":"","sources":["../../src/core/renderer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH;;GAEG;AACH,MAAM,OAAO,QAAQ;IACX,SAAS,GAAG,GAAG,CAAC;IAExB;;OAEG;IACH,KAAK,CAAC,MAAM,CAAC,OAAkB,EAAE,OAAsB;QACrD,MAAM,OAAO,GAAa,EAAE,CAAC;QAE7B,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,EAAE,CAAC;gBACxB,SAAS;YACX,CAAC;YAED,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAC5C,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;gBACpB,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACvB,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACtC,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,SAAiB;QAC5B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;CACF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,CAAC,SAAS,CAAC,CAAC;IACtC,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,SAAiB;QAC5B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED;;;;OAIG;IACK,WAAW,CAAC,KAAY,EAAE,MAAe;QAC/C,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAC9B,CAAC;aAAM,CAAC;YACN,yCAAyC;YACzC,OAAO,CAAC,IAAI,CAAC,WAAW,MAAM,CAAC,EAAE,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACzD,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Base class for widgets that receive StdinData
3
+ *
4
+ * Eliminates duplicate data storage and update logic across widgets.
5
+ * Extending widgets only need to implement render() method.
6
+ */
7
+ import type { IWidget, IWidgetMetadata, WidgetContext, RenderContext } from './types.js';
8
+ import type { StdinData } from '../types.js';
9
+ /**
10
+ * Abstract base class for widgets working with StdinData
11
+ *
12
+ * Provides common functionality:
13
+ * - StdinData storage and retrieval
14
+ * - Enabled state management
15
+ * - Consistent update pattern
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * export class ModelWidget extends StdinDataWidget {
20
+ * readonly id = 'model';
21
+ * readonly metadata = {
22
+ * name: 'Model',
23
+ * description: 'Displays Claude model',
24
+ * version: '1.0.0',
25
+ * author: 'claude-scope'
26
+ * };
27
+ *
28
+ * async render(context: RenderContext): Promise<string | null> {
29
+ * const data = this.getData();
30
+ * return data.model.display_name;
31
+ * }
32
+ * }
33
+ * ```
34
+ */
35
+ export declare abstract class StdinDataWidget implements IWidget {
36
+ /**
37
+ * Stored stdin data from last update
38
+ */
39
+ protected data: StdinData | null;
40
+ /**
41
+ * Widget enabled state
42
+ */
43
+ protected enabled: boolean;
44
+ /**
45
+ * Unique widget identifier
46
+ */
47
+ abstract readonly id: string;
48
+ /**
49
+ * Widget metadata
50
+ */
51
+ abstract readonly metadata: IWidgetMetadata;
52
+ /**
53
+ * Initialize widget with context
54
+ * @param context - Widget initialization context
55
+ */
56
+ initialize(context: WidgetContext): Promise<void>;
57
+ /**
58
+ * Update widget with new stdin data
59
+ * @param data - Stdin data from Claude Code
60
+ */
61
+ update(data: StdinData): Promise<void>;
62
+ /**
63
+ * Check if widget is enabled
64
+ * @returns true if widget should render
65
+ */
66
+ isEnabled(): boolean;
67
+ /**
68
+ * Get stored stdin data
69
+ * @returns StdinData
70
+ * @throws Error if data not initialized (update() not called)
71
+ */
72
+ protected getData(): StdinData;
73
+ /**
74
+ * Render widget output
75
+ * @param context - Render context
76
+ * @returns Rendered string, or null if widget should not display
77
+ */
78
+ abstract render(context: RenderContext): Promise<string | null>;
79
+ /**
80
+ * Optional cleanup method
81
+ * Override if widget has resources to clean up
82
+ */
83
+ cleanup?(): Promise<void>;
84
+ }
85
+ //# sourceMappingURL=stdin-data-widget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stdin-data-widget.d.ts","sourceRoot":"","sources":["../../src/core/stdin-data-widget.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACzF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,8BAAsB,eAAgB,YAAW,OAAO;IACtD;;OAEG;IACH,SAAS,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,CAAQ;IAExC;;OAEG;IACH,SAAS,CAAC,OAAO,UAAQ;IAEzB;;OAEG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAE7B;;OAEG;IACH,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC;IAE5C;;;OAGG;IACG,UAAU,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvD;;;OAGG;IACG,MAAM,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAI5C;;;OAGG;IACH,SAAS,IAAI,OAAO;IAIpB;;;;OAIG;IACH,SAAS,CAAC,OAAO,IAAI,SAAS;IAS9B;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAE/D;;;OAGG;IACG,OAAO,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC;CAChC"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Base class for widgets that receive StdinData
3
+ *
4
+ * Eliminates duplicate data storage and update logic across widgets.
5
+ * Extending widgets only need to implement render() method.
6
+ */
7
+ /**
8
+ * Abstract base class for widgets working with StdinData
9
+ *
10
+ * Provides common functionality:
11
+ * - StdinData storage and retrieval
12
+ * - Enabled state management
13
+ * - Consistent update pattern
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * export class ModelWidget extends StdinDataWidget {
18
+ * readonly id = 'model';
19
+ * readonly metadata = {
20
+ * name: 'Model',
21
+ * description: 'Displays Claude model',
22
+ * version: '1.0.0',
23
+ * author: 'claude-scope'
24
+ * };
25
+ *
26
+ * async render(context: RenderContext): Promise<string | null> {
27
+ * const data = this.getData();
28
+ * return data.model.display_name;
29
+ * }
30
+ * }
31
+ * ```
32
+ */
33
+ export class StdinDataWidget {
34
+ /**
35
+ * Stored stdin data from last update
36
+ */
37
+ data = null;
38
+ /**
39
+ * Widget enabled state
40
+ */
41
+ enabled = true;
42
+ /**
43
+ * Initialize widget with context
44
+ * @param context - Widget initialization context
45
+ */
46
+ async initialize(context) {
47
+ this.enabled = context.config?.enabled !== false;
48
+ }
49
+ /**
50
+ * Update widget with new stdin data
51
+ * @param data - Stdin data from Claude Code
52
+ */
53
+ async update(data) {
54
+ this.data = data;
55
+ }
56
+ /**
57
+ * Check if widget is enabled
58
+ * @returns true if widget should render
59
+ */
60
+ isEnabled() {
61
+ return this.enabled;
62
+ }
63
+ /**
64
+ * Get stored stdin data
65
+ * @returns StdinData
66
+ * @throws Error if data not initialized (update() not called)
67
+ */
68
+ getData() {
69
+ if (!this.data) {
70
+ throw new Error(`Widget ${this.id} data not initialized. Call update() before render().`);
71
+ }
72
+ return this.data;
73
+ }
74
+ }
75
+ //# sourceMappingURL=stdin-data-widget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stdin-data-widget.js","sourceRoot":"","sources":["../../src/core/stdin-data-widget.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,OAAgB,eAAe;IACnC;;OAEG;IACO,IAAI,GAAqB,IAAI,CAAC;IAExC;;OAEG;IACO,OAAO,GAAG,IAAI,CAAC;IAYzB;;;OAGG;IACH,KAAK,CAAC,UAAU,CAAC,OAAsB;QACrC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,MAAM,EAAE,OAAO,KAAK,KAAK,CAAC;IACnD,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,MAAM,CAAC,IAAe;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED;;;OAGG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;;;OAIG;IACO,OAAO;QACf,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CACb,UAAU,IAAI,CAAC,EAAE,uDAAuD,CACzE,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;CAcF"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Widget type utilities and helpers
3
+ */
4
+ import type { IWidgetMetadata, IWidget } from './types.js';
5
+ /**
6
+ * Create widget metadata with defaults
7
+ *
8
+ * @param name - Widget name
9
+ * @param description - Widget description
10
+ * @param version - Widget version (default: '1.0.0')
11
+ * @param author - Widget author (default: 'claude-scope')
12
+ * @returns Widget metadata object
13
+ */
14
+ export declare function createWidgetMetadata(name: string, description: string, version?: string, author?: string): IWidgetMetadata;
15
+ /**
16
+ * Type for widget constructor
17
+ * Can be used with dependency injection
18
+ */
19
+ export type WidgetConstructor = new (...args: unknown[]) => IWidget;
20
+ /**
21
+ * Widget configuration options
22
+ */
23
+ export interface WidgetConfig {
24
+ enabled?: boolean;
25
+ }
26
+ /**
27
+ * Create widget config with defaults
28
+ */
29
+ export declare function createWidgetConfig(config?: WidgetConfig): WidgetConfig;
30
+ //# sourceMappingURL=widget-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"widget-types.d.ts","sourceRoot":"","sources":["../../src/core/widget-types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE3D;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,OAAO,SAAU,EACjB,MAAM,SAAiB,GACtB,eAAe,CAOjB;AAED;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC;AAEpE;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,GAAE,YAAiB,GAAG,YAAY,CAK1E"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Widget type utilities and helpers
3
+ */
4
+ /**
5
+ * Create widget metadata with defaults
6
+ *
7
+ * @param name - Widget name
8
+ * @param description - Widget description
9
+ * @param version - Widget version (default: '1.0.0')
10
+ * @param author - Widget author (default: 'claude-scope')
11
+ * @returns Widget metadata object
12
+ */
13
+ export function createWidgetMetadata(name, description, version = '1.0.0', author = 'claude-scope') {
14
+ return {
15
+ name,
16
+ description,
17
+ version,
18
+ author
19
+ };
20
+ }
21
+ /**
22
+ * Create widget config with defaults
23
+ */
24
+ export function createWidgetConfig(config = {}) {
25
+ return {
26
+ enabled: true,
27
+ ...config
28
+ };
29
+ }
30
+ //# sourceMappingURL=widget-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"widget-types.js","sourceRoot":"","sources":["../../src/core/widget-types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;;;;;;;GAQG;AACH,MAAM,UAAU,oBAAoB,CAClC,IAAY,EACZ,WAAmB,EACnB,OAAO,GAAG,OAAO,EACjB,MAAM,GAAG,cAAc;IAEvB,OAAO;QACL,IAAI;QACJ,WAAW;QACX,OAAO;QACP,MAAM;KACP,CAAC;AACJ,CAAC;AAeD;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,SAAuB,EAAE;IAC1D,OAAO;QACL,OAAO,EAAE,IAAI;QACb,GAAG,MAAM;KACV,CAAC;AACJ,CAAC"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Stdin provider for parsing JSON data from stdin
3
+ * Parses and validates Claude Code session data using Zod
4
+ */
5
+ import type { StdinData } from '../types.js';
6
+ /**
7
+ * Error thrown when stdin parsing fails
8
+ */
9
+ export declare class StdinParseError extends Error {
10
+ constructor(message: string);
11
+ }
12
+ /**
13
+ * Error thrown when stdin validation fails
14
+ */
15
+ export declare class StdinValidationError extends Error {
16
+ constructor(message: string);
17
+ }
18
+ /**
19
+ * Stdin provider for parsing and validating JSON data
20
+ */
21
+ export declare class StdinProvider {
22
+ /**
23
+ * Parse and validate JSON string from stdin
24
+ * @param input JSON string to parse
25
+ * @returns Validated StdinData object
26
+ * @throws StdinParseError if JSON is malformed
27
+ * @throws StdinValidationError if data doesn't match schema
28
+ */
29
+ parse(input: string): Promise<StdinData>;
30
+ /**
31
+ * Safe parse that returns result instead of throwing
32
+ * Useful for testing and optional validation
33
+ * @param input JSON string to parse
34
+ * @returns Result object with success flag
35
+ */
36
+ safeParse(input: string): Promise<{
37
+ success: true;
38
+ data: StdinData;
39
+ } | {
40
+ success: false;
41
+ error: string;
42
+ }>;
43
+ }
44
+ //# sourceMappingURL=stdin-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stdin-provider.d.ts","sourceRoot":"","sources":["../../src/data/stdin-provider.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAG7C;;GAEG;AACH,qBAAa,eAAgB,SAAQ,KAAK;gBAC5B,OAAO,EAAE,MAAM;CAI5B;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;gBACjC,OAAO,EAAE,MAAM;CAI5B;AAED;;GAEG;AACH,qBAAa,aAAa;IACxB;;;;;;OAMG;IACG,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IAmC9C;;;;;OAKG;IACG,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,IAAI,CAAC;QAAC,IAAI,EAAE,SAAS,CAAA;KAAE,GAAG;QAAE,OAAO,EAAE,KAAK,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CAQhH"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Stdin provider for parsing JSON data from stdin
3
+ * Parses and validates Claude Code session data using Zod
4
+ */
5
+ import { z } from 'zod';
6
+ import { StdinDataSchema } from '../schemas/stdin-schema.js';
7
+ /**
8
+ * Error thrown when stdin parsing fails
9
+ */
10
+ export class StdinParseError extends Error {
11
+ constructor(message) {
12
+ super(message);
13
+ this.name = 'StdinParseError';
14
+ }
15
+ }
16
+ /**
17
+ * Error thrown when stdin validation fails
18
+ */
19
+ export class StdinValidationError extends Error {
20
+ constructor(message) {
21
+ super(message);
22
+ this.name = 'StdinValidationError';
23
+ }
24
+ }
25
+ /**
26
+ * Stdin provider for parsing and validating JSON data
27
+ */
28
+ export class StdinProvider {
29
+ /**
30
+ * Parse and validate JSON string from stdin
31
+ * @param input JSON string to parse
32
+ * @returns Validated StdinData object
33
+ * @throws StdinParseError if JSON is malformed
34
+ * @throws StdinValidationError if data doesn't match schema
35
+ */
36
+ async parse(input) {
37
+ // Check for empty input
38
+ if (!input || input.trim().length === 0) {
39
+ throw new StdinParseError('stdin data is empty');
40
+ }
41
+ // Parse JSON
42
+ let data;
43
+ try {
44
+ data = JSON.parse(input);
45
+ }
46
+ catch (error) {
47
+ throw new StdinParseError(`Invalid JSON: ${error.message}`);
48
+ }
49
+ // Validate with Zod
50
+ try {
51
+ return StdinDataSchema.parse(data);
52
+ }
53
+ catch (error) {
54
+ if (error instanceof z.ZodError) {
55
+ // Format error messages nicely
56
+ const errorDetails = error.issues
57
+ .map((e) => {
58
+ const path = e.path.length > 0 ? e.path.join('.') : 'root';
59
+ return `${path}: ${e.message}`;
60
+ })
61
+ .join(', ');
62
+ throw new StdinValidationError(`Validation failed: ${errorDetails}`);
63
+ }
64
+ throw error;
65
+ }
66
+ }
67
+ /**
68
+ * Safe parse that returns result instead of throwing
69
+ * Useful for testing and optional validation
70
+ * @param input JSON string to parse
71
+ * @returns Result object with success flag
72
+ */
73
+ async safeParse(input) {
74
+ try {
75
+ const data = await this.parse(input);
76
+ return { success: true, data };
77
+ }
78
+ catch (error) {
79
+ return { success: false, error: error.message };
80
+ }
81
+ }
82
+ }
83
+ //# sourceMappingURL=stdin-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stdin-provider.js","sourceRoot":"","sources":["../../src/data/stdin-provider.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ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oBAC3D,OAAO,GAAG,IAAI,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC;gBACjC,CAAC,CAAC;qBACD,IAAI,CAAC,IAAI,CAAC,CAAC;gBAEd,MAAM,IAAI,oBAAoB,CAC5B,sBAAsB,YAAY,EAAE,CACrC,CAAC;YACJ,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,SAAS,CAAC,KAAa;QAC3B,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACrC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QACjC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAG,KAAe,CAAC,OAAO,EAAE,CAAC;QAC7D,CAAC;IACH,CAAC;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;GAGG;AAOH;;GAEG;AACH,wBAAsB,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CA4B5C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;GAGG;AA0BH;;GAEG;AACH,wBAAsB,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAkD5C"}