Skip to content

依然无法获取项目级agents #128

@wkgcass

Description

@wkgcass

这个issue #73 似乎没有被正确修复。我似乎没有reopen权限,所以开了个新issue

重新clone了本项目,提交为f49c7d7e8c2ea4dae89bf3ab026c376797073a35
执行:bun install
然后运行的步骤同 issue #73 开头所述
还是无法获取项目级agents

又让mimo给我修了下,修好了,但是我没仔细看它怎么修的,就一路yes。。。

prompt:当前这个版本无法获取项目级agents,试着帮我修复,还有现在退出claude时,按ctrl-c会卡住,kill -INT则可以正常退出。帮我修复

diff --git a/src/main.tsx b/src/main.tsx
index b382aee..1cb7286 100644
--- a/src/main.tsx
+++ b/src/main.tsx
@@ -870,6 +870,8 @@ const _pendingSSH: PendingSSH | undefined = feature('SSH_REMOTE')
     }
   : undefined
 
+let hasGracefulShutdown = false
+
 export async function main() {
   profileCheckpoint('main_function_start')
 
@@ -891,6 +893,12 @@ export async function main() {
     if (process.argv.includes('-p') || process.argv.includes('--print')) {
       return
     }
+    // If setupGracefulShutdown() has already taken over (init() ran),
+    // let its handler do the proper cleanup (restore raw mode, exit alt
+    // screen, etc.) instead of force-exiting with a dirty terminal.
+    if (hasGracefulShutdown) {
+      return
+    }
     process.exit(0)
   })
   profileCheckpoint('main_warning_handler_initialized')
@@ -1256,6 +1264,10 @@ async function run(): Promise<CommanderCommand> {
     ])
     profileCheckpoint('preAction_after_mdm')
     await init()
+    // init() calls setupGracefulShutdown() which registers a proper SIGINT
+    // handler that restores terminal state. From this point on, the early
+    // SIGINT handler should yield to it instead of force-exiting.
+    hasGracefulShutdown = true
     profileCheckpoint('preAction_after_init')
 
     // process.title on Windows sets the console title directly; on POSIX,
diff --git a/src/utils/markdownConfigLoader.ts b/src/utils/markdownConfigLoader.ts
index 6872997..00d977d 100644
--- a/src/utils/markdownConfigLoader.ts
+++ b/src/utils/markdownConfigLoader.ts
@@ -11,7 +11,7 @@ import {
 import { getProjectRoot } from '../bootstrap/state.js'
 import { logForDebugging } from './debug.js'
 import { getClaudeConfigHomeDir, isEnvTruthy } from './envUtils.js'
-import { isFsInaccessible } from './errors.js'
+import { isENOENT, isFsInaccessible } from './errors.js'
 import { normalizePathForComparison } from './file.js'
 import type { FrontmatterData } from './frontmatterParser.js'
 import { parseFrontmatter } from './frontmatterParser.js'
@@ -552,7 +552,8 @@ async function loadMarkdownFiles(dir: string): Promise<
 > {
   // File search strategy:
   // - Default: ripgrep (faster, battle-tested)
-  // - Fallback: native Node.js (when CLAUDE_CODE_USE_NATIVE_FILE_SEARCH is set)
+  // - Fallback: native Node.js (when CLAUDE_CODE_USE_NATIVE_FILE_SEARCH is set
+  //   or when ripgrep is unavailable/broken)
   //
   // Why both? Ripgrep has poor startup performance in native builds.
   const useNative = isEnvTruthy(process.env.CLAUDE_CODE_USE_NATIVE_FILE_SEARCH)
@@ -570,8 +571,17 @@ async function loadMarkdownFiles(dir: string): Promise<
     // Handle missing/inaccessible dir directly instead of pre-checking
     // existence (TOCTOU). findMarkdownFilesNative already catches internally;
     // ripGrep rejects on inaccessible target paths.
-    if (isFsInaccessible(e)) return []
-    throw e
+    if (isFsInaccessible(e)) {
+      // If ripgrep itself is missing (ENOENT on the binary, not the dir),
+      // fall back to native file search instead of silently returning empty.
+      if (!useNative && isENOENT(e)) {
+        files = await findMarkdownFilesNative(dir, signal)
+      } else {
+        return []
+      }
+    } else {
+      throw e
+    }
   }
 
   const results = await Promise.all(

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions