@kosinal/claude-code-dashboard 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/bin.js +38 -8
  2. package/package.json +1 -1
package/dist/bin.js CHANGED
@@ -13,6 +13,7 @@ var MARKER_QUICK = "__claude_code_dashboard_quick__";
13
13
  var MARKER_INSTALL = "__claude_code_dashboard_install__";
14
14
  var MARKER_LEGACY = "__claude_code_dashboard__";
15
15
  var HOOK_EVENTS = ["SessionStart", "UserPromptSubmit", "Stop", "SessionEnd"];
16
+ var INTERACTIVE_TOOLS_MATCHER = "ExitPlanMode|AskUserQuestion";
16
17
  function getConfigDir(configDir) {
17
18
  return configDir ?? path.join(os.homedir(), ".claude");
18
19
  }
@@ -54,7 +55,7 @@ function backupSettings(configDir) {
54
55
  }
55
56
  function removeHooksByMarkers(settings, markers) {
56
57
  if (!settings.hooks) return;
57
- for (const event of HOOK_EVENTS) {
58
+ for (const event of Object.keys(settings.hooks)) {
58
59
  const groups = settings.hooks[event];
59
60
  if (!groups) continue;
60
61
  const filtered = [];
@@ -83,11 +84,11 @@ function installHooks(port, configDir) {
83
84
  if (!settings.hooks) {
84
85
  settings.hooks = {};
85
86
  }
87
+ const command = process.platform === "win32" ? `powershell -NoProfile -Command "$input | Invoke-WebRequest -Uri http://localhost:${port}/api/hook -Method POST -ContentType 'application/json' -ErrorAction SilentlyContinue | Out-Null"` : `curl -s -X POST -H "Content-Type: application/json" -d @- http://localhost:${port}/api/hook > /dev/null 2>&1`;
86
88
  for (const event of HOOK_EVENTS) {
87
89
  if (!settings.hooks[event]) {
88
90
  settings.hooks[event] = [];
89
91
  }
90
- const command = process.platform === "win32" ? `powershell -NoProfile -Command "$input | Invoke-WebRequest -Uri http://localhost:${port}/api/hook -Method POST -ContentType 'application/json' -ErrorAction SilentlyContinue | Out-Null"` : `curl -s -X POST -H "Content-Type: application/json" -d @- http://localhost:${port}/api/hook > /dev/null 2>&1`;
91
92
  settings.hooks[event].push({
92
93
  hooks: [
93
94
  {
@@ -99,6 +100,20 @@ function installHooks(port, configDir) {
99
100
  ]
100
101
  });
101
102
  }
103
+ if (!settings.hooks.PreToolUse) {
104
+ settings.hooks.PreToolUse = [];
105
+ }
106
+ settings.hooks.PreToolUse.push({
107
+ matcher: INTERACTIVE_TOOLS_MATCHER,
108
+ hooks: [
109
+ {
110
+ type: "command",
111
+ command,
112
+ async: true,
113
+ statusMessage: MARKER_QUICK
114
+ }
115
+ ]
116
+ });
102
117
  writeSettings(settings, configDir);
103
118
  }
104
119
  function installHooksWithCommand(command, configDir) {
@@ -123,6 +138,20 @@ function installHooksWithCommand(command, configDir) {
123
138
  ]
124
139
  });
125
140
  }
141
+ if (!settings.hooks.PreToolUse) {
142
+ settings.hooks.PreToolUse = [];
143
+ }
144
+ settings.hooks.PreToolUse.push({
145
+ matcher: INTERACTIVE_TOOLS_MATCHER,
146
+ hooks: [
147
+ {
148
+ type: "command",
149
+ command,
150
+ async: true,
151
+ statusMessage: MARKER_INSTALL
152
+ }
153
+ ]
154
+ });
126
155
  writeSettings(settings, configDir);
127
156
  }
128
157
  function removeHooks(configDir, mode) {
@@ -1333,9 +1362,10 @@ data: ${initData}
1333
1362
 
1334
1363
  // src/state.ts
1335
1364
  var EVENT_TO_STATUS = {
1336
- SessionStart: "waiting",
1365
+ SessionStart: "done",
1337
1366
  UserPromptSubmit: "running",
1338
- Stop: "waiting"
1367
+ Stop: "done",
1368
+ PreToolUse: "waiting"
1339
1369
  };
1340
1370
  function createStore() {
1341
1371
  const sessions = /* @__PURE__ */ new Map();
@@ -1662,11 +1692,11 @@ function startDashboard(port, noHooks, noOpen) {
1662
1692
  }
1663
1693
  throw err;
1664
1694
  });
1665
- if (!noHooks) {
1666
- installHooks(port);
1667
- }
1668
- writeLockFile(port);
1669
1695
  dashboard.listen(port, () => {
1696
+ if (!noHooks) {
1697
+ installHooks(port);
1698
+ }
1699
+ writeLockFile(port);
1670
1700
  const url = `http://localhost:${port}`;
1671
1701
  console.log(`Dashboard running at ${url}`);
1672
1702
  if (!noHooks) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kosinal/claude-code-dashboard",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "type": "module",
5
5
  "description": "Real-time browser dashboard for Claude Code session states",
6
6
  "bin": {