claude-scope 0.2.0 → 0.2.2

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.
@@ -279,7 +279,7 @@ var GitWidget = class {
279
279
  if (!branch) {
280
280
  return null;
281
281
  }
282
- return ` ${branch}`;
282
+ return branch;
283
283
  } catch {
284
284
  return null;
285
285
  }
@@ -722,7 +722,8 @@ async function main() {
722
722
  try {
723
723
  const stdin = await readStdin();
724
724
  if (!stdin || stdin.trim().length === 0) {
725
- return "";
725
+ const fallback = await tryGitFallback();
726
+ return fallback;
726
727
  }
727
728
  const provider = new StdinProvider();
728
729
  const stdinData = await provider.parse(stdin);
@@ -748,6 +749,19 @@ async function main() {
748
749
  );
749
750
  return output || "";
750
751
  } catch (error) {
752
+ const fallback = await tryGitFallback();
753
+ return fallback;
754
+ }
755
+ }
756
+ async function tryGitFallback() {
757
+ try {
758
+ const cwd = process.cwd();
759
+ const widget = new GitWidget();
760
+ await widget.initialize({ config: {} });
761
+ await widget.update({ cwd, session_id: "fallback" });
762
+ const result = await widget.render({ width: 80, timestamp: Date.now() });
763
+ return result || "";
764
+ } catch {
751
765
  return "";
752
766
  }
753
767
  }
package/package.json CHANGED
@@ -1,16 +1,10 @@
1
1
  {
2
2
  "name": "claude-scope",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Claude Code plugin for session status and analytics",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
- "main": "dist/index.js",
8
- "exports": {
9
- ".": {
10
- "import": "dist/index.js",
11
- "types": "dist/index.d.ts"
12
- }
13
- },
7
+ "main": "dist/claude-scope.cjs",
14
8
  "bin": {
15
9
  "claude-scope": "dist/claude-scope.cjs"
16
10
  },
package/dist/index.js DELETED
@@ -1,78 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Claude Scope - Claude Code statusline plugin
4
- * Entry point
5
- */
6
- import { WidgetRegistry } from './core/widget-registry.js';
7
- import { Renderer } from './core/renderer.js';
8
- import { GitWidget } from './widgets/git/git-widget.js';
9
- import { ModelWidget } from './widgets/model-widget.js';
10
- import { ContextWidget } from './widgets/context-widget.js';
11
- import { CostWidget } from './widgets/cost-widget.js';
12
- import { DurationWidget } from './widgets/duration-widget.js';
13
- import { GitChangesWidget } from './widgets/git/git-changes-widget.js';
14
- import { StdinProvider } from './data/stdin-provider.js';
15
- /**
16
- * Read stdin as string
17
- */
18
- async function readStdin() {
19
- const chunks = [];
20
- for await (const chunk of process.stdin) {
21
- chunks.push(chunk);
22
- }
23
- return Buffer.concat(chunks).toString('utf8');
24
- }
25
- /**
26
- * Main entry point
27
- */
28
- export async function main() {
29
- try {
30
- // Read JSON from stdin
31
- const stdin = await readStdin();
32
- // If stdin is empty, return empty string
33
- if (!stdin || stdin.trim().length === 0) {
34
- return '';
35
- }
36
- // Parse and validate with StdinProvider
37
- const provider = new StdinProvider();
38
- const stdinData = await provider.parse(stdin);
39
- // Create registry
40
- const registry = new WidgetRegistry();
41
- // Register all widgets (no constructor args needed)
42
- await registry.register(new ModelWidget());
43
- await registry.register(new ContextWidget());
44
- await registry.register(new CostWidget());
45
- await registry.register(new DurationWidget());
46
- await registry.register(new GitWidget());
47
- await registry.register(new GitChangesWidget());
48
- // Create renderer with error handling configuration
49
- const renderer = new Renderer({
50
- separator: ' │ ',
51
- onError: (error, widget) => {
52
- // Silently ignore widget errors - they return null
53
- },
54
- showErrors: false
55
- });
56
- // Update all widgets with data
57
- for (const widget of registry.getAll()) {
58
- await widget.update(stdinData);
59
- }
60
- // Render
61
- const output = await renderer.render(registry.getEnabledWidgets(), { width: 80, timestamp: Date.now() });
62
- return output || '';
63
- }
64
- catch (error) {
65
- // Return empty string on any error
66
- return '';
67
- }
68
- }
69
- // Run when executed (works with both direct node and npx)
70
- main().then((output) => {
71
- if (output) {
72
- console.log(output);
73
- }
74
- }).catch(() => {
75
- // Silently fail - return empty status line
76
- process.exit(0);
77
- });
78
- //# sourceMappingURL=index.js.map