@kimuson/claude-code-viewer 0.4.9 → 0.4.11

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/dist/main.js CHANGED
@@ -856,6 +856,7 @@ import {
856
856
  } from "@anthropic-ai/claude-code";
857
857
  import { Command, Path as Path7 } from "@effect/platform";
858
858
  import { Data, Effect as Effect10 } from "effect";
859
+ var isNpxShimPath = (path) => /_npx[/\\].*node_modules[\\/]\.bin/.test(path);
859
860
  var ClaudeCodePathNotFoundError = class extends Data.TaggedError(
860
861
  "ClaudeCodePathNotFoundError"
861
862
  ) {
@@ -874,38 +875,35 @@ var resolveClaudeCodePath = Effect10.gen(function* () {
874
875
  Command.make("which", "claude").pipe(
875
876
  Command.env({
876
877
  PATH: pathEnv
877
- }),
878
- Command.runInShell(true)
878
+ })
879
+ // DO NOT Specify `runInShell(true)` here, it causes resolve node_modules/.bin/claude to be executed.
879
880
  )
880
881
  ).pipe(
881
882
  Effect10.map((output) => output.trim()),
883
+ // npx 実行時に `.npm/_npx/.../node_modules/.bin/claude` が最優先で解決されるのを防ぐ
882
884
  Effect10.map((output) => output === "" ? null : output),
883
885
  // 存在しない時、空文字になる模様
884
886
  Effect10.catchAll(() => Effect10.succeed(null))
885
887
  );
886
- if (whichClaude !== null) {
888
+ if (whichClaude !== null && !isNpxShimPath(whichClaude)) {
887
889
  return whichClaude;
888
890
  }
889
- const projectClaudeCode = yield* Effect10.try(() => {
890
- const parts = __dirname.split("/");
891
- const packagePath = parts.slice(0, parts.indexOf("claude-code-viewer") + 1).join("/");
892
- return path.join(
893
- packagePath,
894
- "node_modules",
895
- "@anthropic-ai",
896
- "claude-code",
897
- "cli.js"
898
- );
899
- }).pipe(
900
- Effect10.catchAll(() => {
901
- return Effect10.fail(
902
- new ClaudeCodePathNotFoundError({
903
- message: "Claude Code CLI not found in any location"
904
- })
905
- );
906
- })
891
+ const buildInClaude = yield* Command.string(
892
+ Command.make("which", "claude").pipe(Command.runInShell(true))
893
+ ).pipe(
894
+ Effect10.map((output) => output.trim()),
895
+ Effect10.map((output) => output === "" ? null : output),
896
+ // 存在しない時、空文字になる模様
897
+ Effect10.catchAll(() => Effect10.succeed(null))
907
898
  );
908
- return projectClaudeCode;
899
+ if (buildInClaude === null || isNpxShimPath(buildInClaude)) {
900
+ return yield* Effect10.fail(
901
+ new ClaudeCodePathNotFoundError({
902
+ message: "Claude Code CLI not found in any location"
903
+ })
904
+ );
905
+ }
906
+ return buildInClaude;
909
907
  });
910
908
  var Config = Effect10.gen(function* () {
911
909
  const claudeCodeExecutablePath = yield* resolveClaudeCodePath;
@@ -6361,7 +6359,7 @@ import { z as z28 } from "zod";
6361
6359
  // package.json
6362
6360
  var package_default = {
6363
6361
  name: "@kimuson/claude-code-viewer",
6364
- version: "0.4.9",
6362
+ version: "0.4.11",
6365
6363
  type: "module",
6366
6364
  license: "MIT",
6367
6365
  repository: {