homegraph 1.0.0 → 1.1.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.
- package/LICENSE +21 -0
- package/README.md +243 -0
- package/dist/bin/fatal-handler.d.ts +20 -0
- package/dist/bin/fatal-handler.d.ts.map +1 -0
- package/dist/bin/fatal-handler.js +118 -0
- package/dist/bin/fatal-handler.js.map +1 -0
- package/dist/bin/homegraph.d.ts +26 -0
- package/dist/bin/homegraph.d.ts.map +1 -0
- package/dist/bin/homegraph.js +1995 -0
- package/dist/bin/homegraph.js.map +1 -0
- package/dist/bin/node-version-check.d.ts +37 -0
- package/dist/bin/node-version-check.d.ts.map +1 -0
- package/dist/bin/node-version-check.js +79 -0
- package/dist/bin/node-version-check.js.map +1 -0
- package/dist/bin/uninstall.d.ts +14 -0
- package/dist/bin/uninstall.d.ts.map +1 -0
- package/dist/bin/uninstall.js +36 -0
- package/dist/bin/uninstall.js.map +1 -0
- package/dist/context/formatter.d.ts +30 -0
- package/dist/context/formatter.d.ts.map +1 -0
- package/dist/context/formatter.js +263 -0
- package/dist/context/formatter.js.map +1 -0
- package/dist/context/index.d.ts +119 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/index.js +1296 -0
- package/dist/context/index.js.map +1 -0
- package/dist/context/markers.d.ts +19 -0
- package/dist/context/markers.d.ts.map +1 -0
- package/dist/context/markers.js +22 -0
- package/dist/context/markers.js.map +1 -0
- package/dist/db/index.d.ts +122 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +296 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/migrations.d.ts +44 -0
- package/dist/db/migrations.d.ts.map +1 -0
- package/dist/db/migrations.js +140 -0
- package/dist/db/migrations.js.map +1 -0
- package/dist/db/queries.d.ts +406 -0
- package/dist/db/queries.d.ts.map +1 -0
- package/dist/db/queries.js +1605 -0
- package/dist/db/queries.js.map +1 -0
- package/dist/db/schema.sql +152 -0
- package/dist/db/sqlite-adapter.d.ts +53 -0
- package/dist/db/sqlite-adapter.d.ts.map +1 -0
- package/dist/db/sqlite-adapter.js +117 -0
- package/dist/db/sqlite-adapter.js.map +1 -0
- package/dist/directory.d.ts +138 -0
- package/dist/directory.d.ts.map +1 -0
- package/dist/directory.js +515 -0
- package/dist/directory.js.map +1 -0
- package/dist/errors.d.ts +136 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +219 -0
- package/dist/errors.js.map +1 -0
- package/dist/extraction/astro-extractor.d.ts +79 -0
- package/dist/extraction/astro-extractor.d.ts.map +1 -0
- package/dist/extraction/astro-extractor.js +320 -0
- package/dist/extraction/astro-extractor.js.map +1 -0
- package/dist/extraction/context.d.ts +12 -0
- package/dist/extraction/context.d.ts.map +1 -0
- package/dist/extraction/context.js +29 -0
- package/dist/extraction/context.js.map +1 -0
- package/dist/extraction/dfm-extractor.d.ts +31 -0
- package/dist/extraction/dfm-extractor.d.ts.map +1 -0
- package/dist/extraction/dfm-extractor.js +151 -0
- package/dist/extraction/dfm-extractor.js.map +1 -0
- package/dist/extraction/extraction-version.d.ts +25 -0
- package/dist/extraction/extraction-version.d.ts.map +1 -0
- package/dist/extraction/extraction-version.js +28 -0
- package/dist/extraction/extraction-version.js.map +1 -0
- package/dist/extraction/function-ref.d.ts +118 -0
- package/dist/extraction/function-ref.d.ts.map +1 -0
- package/dist/extraction/function-ref.js +727 -0
- package/dist/extraction/function-ref.js.map +1 -0
- package/dist/extraction/generated-detection.d.ts +30 -0
- package/dist/extraction/generated-detection.d.ts.map +1 -0
- package/dist/extraction/generated-detection.js +83 -0
- package/dist/extraction/generated-detection.js.map +1 -0
- package/dist/extraction/grammars.d.ts +118 -0
- package/dist/extraction/grammars.d.ts.map +1 -0
- package/dist/extraction/grammars.js +499 -0
- package/dist/extraction/grammars.js.map +1 -0
- package/dist/extraction/index.d.ts +175 -0
- package/dist/extraction/index.d.ts.map +1 -0
- package/dist/extraction/index.js +1888 -0
- package/dist/extraction/index.js.map +1 -0
- package/dist/extraction/languages/arkts-viewtree.d.ts +22 -0
- package/dist/extraction/languages/arkts-viewtree.d.ts.map +1 -0
- package/dist/extraction/languages/arkts-viewtree.js +133 -0
- package/dist/extraction/languages/arkts-viewtree.js.map +1 -0
- package/dist/extraction/languages/arkts.d.ts +18 -0
- package/dist/extraction/languages/arkts.d.ts.map +1 -0
- package/dist/extraction/languages/arkts.js +1069 -0
- package/dist/extraction/languages/arkts.js.map +1 -0
- package/dist/extraction/languages/c-cpp.d.ts +12 -0
- package/dist/extraction/languages/c-cpp.d.ts.map +1 -0
- package/dist/extraction/languages/c-cpp.js +275 -0
- package/dist/extraction/languages/c-cpp.js.map +1 -0
- package/dist/extraction/languages/csharp.d.ts +25 -0
- package/dist/extraction/languages/csharp.d.ts.map +1 -0
- package/dist/extraction/languages/csharp.js +175 -0
- package/dist/extraction/languages/csharp.js.map +1 -0
- package/dist/extraction/languages/dart.d.ts +3 -0
- package/dist/extraction/languages/dart.d.ts.map +1 -0
- package/dist/extraction/languages/dart.js +374 -0
- package/dist/extraction/languages/dart.js.map +1 -0
- package/dist/extraction/languages/go.d.ts +3 -0
- package/dist/extraction/languages/go.d.ts.map +1 -0
- package/dist/extraction/languages/go.js +111 -0
- package/dist/extraction/languages/go.js.map +1 -0
- package/dist/extraction/languages/index.d.ts +10 -0
- package/dist/extraction/languages/index.d.ts.map +1 -0
- package/dist/extraction/languages/index.js +53 -0
- package/dist/extraction/languages/index.js.map +1 -0
- package/dist/extraction/languages/java.d.ts +3 -0
- package/dist/extraction/languages/java.d.ts.map +1 -0
- package/dist/extraction/languages/java.js +315 -0
- package/dist/extraction/languages/java.js.map +1 -0
- package/dist/extraction/languages/javascript.d.ts +3 -0
- package/dist/extraction/languages/javascript.d.ts.map +1 -0
- package/dist/extraction/languages/javascript.js +106 -0
- package/dist/extraction/languages/javascript.js.map +1 -0
- package/dist/extraction/languages/kotlin.d.ts +3 -0
- package/dist/extraction/languages/kotlin.d.ts.map +1 -0
- package/dist/extraction/languages/kotlin.js +379 -0
- package/dist/extraction/languages/kotlin.js.map +1 -0
- package/dist/extraction/languages/lua.d.ts +3 -0
- package/dist/extraction/languages/lua.d.ts.map +1 -0
- package/dist/extraction/languages/lua.js +150 -0
- package/dist/extraction/languages/lua.js.map +1 -0
- package/dist/extraction/languages/luau.d.ts +3 -0
- package/dist/extraction/languages/luau.d.ts.map +1 -0
- package/dist/extraction/languages/luau.js +37 -0
- package/dist/extraction/languages/luau.js.map +1 -0
- package/dist/extraction/languages/objc.d.ts +3 -0
- package/dist/extraction/languages/objc.d.ts.map +1 -0
- package/dist/extraction/languages/objc.js +175 -0
- package/dist/extraction/languages/objc.js.map +1 -0
- package/dist/extraction/languages/pascal.d.ts +3 -0
- package/dist/extraction/languages/pascal.d.ts.map +1 -0
- package/dist/extraction/languages/pascal.js +77 -0
- package/dist/extraction/languages/pascal.js.map +1 -0
- package/dist/extraction/languages/php.d.ts +3 -0
- package/dist/extraction/languages/php.d.ts.map +1 -0
- package/dist/extraction/languages/php.js +196 -0
- package/dist/extraction/languages/php.js.map +1 -0
- package/dist/extraction/languages/python.d.ts +3 -0
- package/dist/extraction/languages/python.d.ts.map +1 -0
- package/dist/extraction/languages/python.js +56 -0
- package/dist/extraction/languages/python.js.map +1 -0
- package/dist/extraction/languages/r.d.ts +3 -0
- package/dist/extraction/languages/r.d.ts.map +1 -0
- package/dist/extraction/languages/r.js +314 -0
- package/dist/extraction/languages/r.js.map +1 -0
- package/dist/extraction/languages/ruby.d.ts +3 -0
- package/dist/extraction/languages/ruby.d.ts.map +1 -0
- package/dist/extraction/languages/ruby.js +149 -0
- package/dist/extraction/languages/ruby.js.map +1 -0
- package/dist/extraction/languages/rust.d.ts +3 -0
- package/dist/extraction/languages/rust.d.ts.map +1 -0
- package/dist/extraction/languages/rust.js +142 -0
- package/dist/extraction/languages/rust.js.map +1 -0
- package/dist/extraction/languages/scala.d.ts +3 -0
- package/dist/extraction/languages/scala.d.ts.map +1 -0
- package/dist/extraction/languages/scala.js +209 -0
- package/dist/extraction/languages/scala.js.map +1 -0
- package/dist/extraction/languages/swift.d.ts +3 -0
- package/dist/extraction/languages/swift.d.ts.map +1 -0
- package/dist/extraction/languages/swift.js +152 -0
- package/dist/extraction/languages/swift.js.map +1 -0
- package/dist/extraction/languages/typescript.d.ts +16 -0
- package/dist/extraction/languages/typescript.d.ts.map +1 -0
- package/dist/extraction/languages/typescript.js +167 -0
- package/dist/extraction/languages/typescript.js.map +1 -0
- package/dist/extraction/liquid-extractor.d.ts +59 -0
- package/dist/extraction/liquid-extractor.d.ts.map +1 -0
- package/dist/extraction/liquid-extractor.js +357 -0
- package/dist/extraction/liquid-extractor.js.map +1 -0
- package/dist/extraction/mybatis-extractor.d.ts +48 -0
- package/dist/extraction/mybatis-extractor.d.ts.map +1 -0
- package/dist/extraction/mybatis-extractor.js +198 -0
- package/dist/extraction/mybatis-extractor.js.map +1 -0
- package/dist/extraction/parse-worker.d.ts +8 -0
- package/dist/extraction/parse-worker.d.ts.map +1 -0
- package/dist/extraction/parse-worker.js +97 -0
- package/dist/extraction/parse-worker.js.map +1 -0
- package/dist/extraction/razor-extractor.d.ts +42 -0
- package/dist/extraction/razor-extractor.d.ts.map +1 -0
- package/dist/extraction/razor-extractor.js +285 -0
- package/dist/extraction/razor-extractor.js.map +1 -0
- package/dist/extraction/svelte-extractor.d.ts +56 -0
- package/dist/extraction/svelte-extractor.d.ts.map +1 -0
- package/dist/extraction/svelte-extractor.js +275 -0
- package/dist/extraction/svelte-extractor.js.map +1 -0
- package/dist/extraction/tree-sitter-helpers.d.ts +28 -0
- package/dist/extraction/tree-sitter-helpers.d.ts.map +1 -0
- package/dist/extraction/tree-sitter-helpers.js +152 -0
- package/dist/extraction/tree-sitter-helpers.js.map +1 -0
- package/dist/extraction/tree-sitter-types.d.ts +239 -0
- package/dist/extraction/tree-sitter-types.d.ts.map +1 -0
- package/dist/extraction/tree-sitter-types.js +10 -0
- package/dist/extraction/tree-sitter-types.js.map +1 -0
- package/dist/extraction/tree-sitter.d.ts +647 -0
- package/dist/extraction/tree-sitter.d.ts.map +1 -0
- package/dist/extraction/tree-sitter.js +5597 -0
- package/dist/extraction/tree-sitter.js.map +1 -0
- package/dist/extraction/vue-extractor.d.ts +51 -0
- package/dist/extraction/vue-extractor.d.ts.map +1 -0
- package/dist/extraction/vue-extractor.js +254 -0
- package/dist/extraction/vue-extractor.js.map +1 -0
- package/dist/extraction/wasm/tree-sitter-c_sharp.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-lua.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-luau.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-r.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-scala.wasm +0 -0
- package/dist/extraction/wasm-runtime-flags.d.ts +38 -0
- package/dist/extraction/wasm-runtime-flags.d.ts.map +1 -0
- package/dist/extraction/wasm-runtime-flags.js +106 -0
- package/dist/extraction/wasm-runtime-flags.js.map +1 -0
- package/dist/graph/index.d.ts +8 -0
- package/dist/graph/index.d.ts.map +1 -0
- package/dist/graph/index.js +13 -0
- package/dist/graph/index.js.map +1 -0
- package/dist/graph/queries.d.ts +106 -0
- package/dist/graph/queries.d.ts.map +1 -0
- package/dist/graph/queries.js +339 -0
- package/dist/graph/queries.js.map +1 -0
- package/dist/graph/traversal.d.ts +127 -0
- package/dist/graph/traversal.d.ts.map +1 -0
- package/dist/graph/traversal.js +540 -0
- package/dist/graph/traversal.js.map +1 -0
- package/dist/index.d.ts +563 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1043 -0
- package/dist/index.js.map +1 -0
- package/dist/installer/config-writer.d.ts +28 -0
- package/dist/installer/config-writer.d.ts.map +1 -0
- package/dist/installer/config-writer.js +91 -0
- package/dist/installer/config-writer.js.map +1 -0
- package/dist/installer/index.d.ts +100 -0
- package/dist/installer/index.d.ts.map +1 -0
- package/dist/installer/index.js +524 -0
- package/dist/installer/index.js.map +1 -0
- package/dist/installer/instructions-template.d.ts +41 -0
- package/dist/installer/instructions-template.d.ts.map +1 -0
- package/dist/installer/instructions-template.js +53 -0
- package/dist/installer/instructions-template.js.map +1 -0
- package/dist/installer/targets/antigravity.d.ts +57 -0
- package/dist/installer/targets/antigravity.d.ts.map +1 -0
- package/dist/installer/targets/antigravity.js +308 -0
- package/dist/installer/targets/antigravity.js.map +1 -0
- package/dist/installer/targets/claude.d.ts +62 -0
- package/dist/installer/targets/claude.d.ts.map +1 -0
- package/dist/installer/targets/claude.js +456 -0
- package/dist/installer/targets/claude.js.map +1 -0
- package/dist/installer/targets/codebuddy.d.ts +17 -0
- package/dist/installer/targets/codebuddy.d.ts.map +1 -0
- package/dist/installer/targets/codebuddy.js +150 -0
- package/dist/installer/targets/codebuddy.js.map +1 -0
- package/dist/installer/targets/codex.d.ts +18 -0
- package/dist/installer/targets/codex.d.ts.map +1 -0
- package/dist/installer/targets/codex.js +185 -0
- package/dist/installer/targets/codex.js.map +1 -0
- package/dist/installer/targets/cursor.d.ts +35 -0
- package/dist/installer/targets/cursor.d.ts.map +1 -0
- package/dist/installer/targets/cursor.js +254 -0
- package/dist/installer/targets/cursor.js.map +1 -0
- package/dist/installer/targets/deveco.d.ts +28 -0
- package/dist/installer/targets/deveco.d.ts.map +1 -0
- package/dist/installer/targets/deveco.js +247 -0
- package/dist/installer/targets/deveco.js.map +1 -0
- package/dist/installer/targets/gemini.d.ts +26 -0
- package/dist/installer/targets/gemini.d.ts.map +1 -0
- package/dist/installer/targets/gemini.js +165 -0
- package/dist/installer/targets/gemini.js.map +1 -0
- package/dist/installer/targets/hermes.d.ts +18 -0
- package/dist/installer/targets/hermes.d.ts.map +1 -0
- package/dist/installer/targets/hermes.js +359 -0
- package/dist/installer/targets/hermes.js.map +1 -0
- package/dist/installer/targets/kiro.d.ts +27 -0
- package/dist/installer/targets/kiro.d.ts.map +1 -0
- package/dist/installer/targets/kiro.js +178 -0
- package/dist/installer/targets/kiro.js.map +1 -0
- package/dist/installer/targets/opencode.d.ts +38 -0
- package/dist/installer/targets/opencode.d.ts.map +1 -0
- package/dist/installer/targets/opencode.js +288 -0
- package/dist/installer/targets/opencode.js.map +1 -0
- package/dist/installer/targets/registry.d.ts +35 -0
- package/dist/installer/targets/registry.d.ts.map +1 -0
- package/dist/installer/targets/registry.js +95 -0
- package/dist/installer/targets/registry.js.map +1 -0
- package/dist/installer/targets/shared.d.ts +101 -0
- package/dist/installer/targets/shared.d.ts.map +1 -0
- package/dist/installer/targets/shared.js +264 -0
- package/dist/installer/targets/shared.js.map +1 -0
- package/dist/installer/targets/toml.d.ts +52 -0
- package/dist/installer/targets/toml.d.ts.map +1 -0
- package/dist/installer/targets/toml.js +147 -0
- package/dist/installer/targets/toml.js.map +1 -0
- package/dist/installer/targets/types.d.ts +108 -0
- package/dist/installer/targets/types.d.ts.map +1 -0
- package/dist/installer/targets/types.js +16 -0
- package/dist/installer/targets/types.js.map +1 -0
- package/dist/mcp/daemon-manager.d.ts +42 -0
- package/dist/mcp/daemon-manager.d.ts.map +1 -0
- package/dist/mcp/daemon-manager.js +129 -0
- package/dist/mcp/daemon-manager.js.map +1 -0
- package/dist/mcp/daemon-paths.d.ts +46 -0
- package/dist/mcp/daemon-paths.d.ts.map +1 -0
- package/dist/mcp/daemon-paths.js +125 -0
- package/dist/mcp/daemon-paths.js.map +1 -0
- package/dist/mcp/daemon-registry.d.ts +47 -0
- package/dist/mcp/daemon-registry.d.ts.map +1 -0
- package/dist/mcp/daemon-registry.js +229 -0
- package/dist/mcp/daemon-registry.js.map +1 -0
- package/dist/mcp/daemon.d.ts +220 -0
- package/dist/mcp/daemon.d.ts.map +1 -0
- package/dist/mcp/daemon.js +637 -0
- package/dist/mcp/daemon.js.map +1 -0
- package/dist/mcp/dynamic-boundaries.d.ts +41 -0
- package/dist/mcp/dynamic-boundaries.d.ts.map +1 -0
- package/dist/mcp/dynamic-boundaries.js +359 -0
- package/dist/mcp/dynamic-boundaries.js.map +1 -0
- package/dist/mcp/engine.d.ts +105 -0
- package/dist/mcp/engine.d.ts.map +1 -0
- package/dist/mcp/engine.js +278 -0
- package/dist/mcp/engine.js.map +1 -0
- package/dist/mcp/index.d.ts +113 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +499 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/liveness-watchdog.d.ts +18 -0
- package/dist/mcp/liveness-watchdog.d.ts.map +1 -0
- package/dist/mcp/liveness-watchdog.js +207 -0
- package/dist/mcp/liveness-watchdog.js.map +1 -0
- package/dist/mcp/ppid-watchdog.d.ts +44 -0
- package/dist/mcp/ppid-watchdog.d.ts.map +1 -0
- package/dist/mcp/ppid-watchdog.js +27 -0
- package/dist/mcp/ppid-watchdog.js.map +1 -0
- package/dist/mcp/proxy.d.ts +87 -0
- package/dist/mcp/proxy.d.ts.map +1 -0
- package/dist/mcp/proxy.js +641 -0
- package/dist/mcp/proxy.js.map +1 -0
- package/dist/mcp/server-instructions.d.ts +34 -0
- package/dist/mcp/server-instructions.d.ts.map +1 -0
- package/dist/mcp/server-instructions.js +106 -0
- package/dist/mcp/server-instructions.js.map +1 -0
- package/dist/mcp/session.d.ts +79 -0
- package/dist/mcp/session.d.ts.map +1 -0
- package/dist/mcp/session.js +330 -0
- package/dist/mcp/session.js.map +1 -0
- package/dist/mcp/stdin-teardown.d.ts +27 -0
- package/dist/mcp/stdin-teardown.d.ts.map +1 -0
- package/dist/mcp/stdin-teardown.js +49 -0
- package/dist/mcp/stdin-teardown.js.map +1 -0
- package/dist/mcp/tools.d.ts +534 -0
- package/dist/mcp/tools.d.ts.map +1 -0
- package/dist/mcp/tools.js +4101 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/mcp/transport.d.ts +188 -0
- package/dist/mcp/transport.d.ts.map +1 -0
- package/dist/mcp/transport.js +359 -0
- package/dist/mcp/transport.js.map +1 -0
- package/dist/mcp/version.d.ts +19 -0
- package/dist/mcp/version.d.ts.map +1 -0
- package/dist/mcp/version.js +71 -0
- package/dist/mcp/version.js.map +1 -0
- package/dist/project-config.d.ts +36 -0
- package/dist/project-config.d.ts.map +1 -0
- package/dist/project-config.js +235 -0
- package/dist/project-config.js.map +1 -0
- package/dist/reasoning/config.d.ts +45 -0
- package/dist/reasoning/config.d.ts.map +1 -0
- package/dist/reasoning/config.js +171 -0
- package/dist/reasoning/config.js.map +1 -0
- package/dist/reasoning/credentials.d.ts +5 -0
- package/dist/reasoning/credentials.d.ts.map +1 -0
- package/dist/reasoning/credentials.js +83 -0
- package/dist/reasoning/credentials.js.map +1 -0
- package/dist/reasoning/login.d.ts +21 -0
- package/dist/reasoning/login.d.ts.map +1 -0
- package/dist/reasoning/login.js +85 -0
- package/dist/reasoning/login.js.map +1 -0
- package/dist/reasoning/reasoner.d.ts +43 -0
- package/dist/reasoning/reasoner.d.ts.map +1 -0
- package/dist/reasoning/reasoner.js +308 -0
- package/dist/reasoning/reasoner.js.map +1 -0
- package/dist/resolution/c-fnptr-synthesizer.d.ts +33 -0
- package/dist/resolution/c-fnptr-synthesizer.d.ts.map +1 -0
- package/dist/resolution/c-fnptr-synthesizer.js +352 -0
- package/dist/resolution/c-fnptr-synthesizer.js.map +1 -0
- package/dist/resolution/callback-synthesizer.d.ts +15 -0
- package/dist/resolution/callback-synthesizer.d.ts.map +1 -0
- package/dist/resolution/callback-synthesizer.js +3014 -0
- package/dist/resolution/callback-synthesizer.js.map +1 -0
- package/dist/resolution/frameworks/arkts-entry.d.ts +12 -0
- package/dist/resolution/frameworks/arkts-entry.d.ts.map +1 -0
- package/dist/resolution/frameworks/arkts-entry.js +214 -0
- package/dist/resolution/frameworks/arkts-entry.js.map +1 -0
- package/dist/resolution/frameworks/arkts-napi.d.ts +3 -0
- package/dist/resolution/frameworks/arkts-napi.d.ts.map +1 -0
- package/dist/resolution/frameworks/arkts-napi.js +166 -0
- package/dist/resolution/frameworks/arkts-napi.js.map +1 -0
- package/dist/resolution/frameworks/astro.d.ts +9 -0
- package/dist/resolution/frameworks/astro.d.ts.map +1 -0
- package/dist/resolution/frameworks/astro.js +169 -0
- package/dist/resolution/frameworks/astro.js.map +1 -0
- package/dist/resolution/frameworks/cargo-workspace.d.ts +18 -0
- package/dist/resolution/frameworks/cargo-workspace.d.ts.map +1 -0
- package/dist/resolution/frameworks/cargo-workspace.js +225 -0
- package/dist/resolution/frameworks/cargo-workspace.js.map +1 -0
- package/dist/resolution/frameworks/csharp.d.ts +8 -0
- package/dist/resolution/frameworks/csharp.d.ts.map +1 -0
- package/dist/resolution/frameworks/csharp.js +241 -0
- package/dist/resolution/frameworks/csharp.js.map +1 -0
- package/dist/resolution/frameworks/drupal.d.ts +51 -0
- package/dist/resolution/frameworks/drupal.d.ts.map +1 -0
- package/dist/resolution/frameworks/drupal.js +367 -0
- package/dist/resolution/frameworks/drupal.js.map +1 -0
- package/dist/resolution/frameworks/expo-modules.d.ts +3 -0
- package/dist/resolution/frameworks/expo-modules.d.ts.map +1 -0
- package/dist/resolution/frameworks/expo-modules.js +148 -0
- package/dist/resolution/frameworks/expo-modules.js.map +1 -0
- package/dist/resolution/frameworks/express.d.ts +8 -0
- package/dist/resolution/frameworks/express.d.ts.map +1 -0
- package/dist/resolution/frameworks/express.js +308 -0
- package/dist/resolution/frameworks/express.js.map +1 -0
- package/dist/resolution/frameworks/fabric.d.ts +3 -0
- package/dist/resolution/frameworks/fabric.d.ts.map +1 -0
- package/dist/resolution/frameworks/fabric.js +354 -0
- package/dist/resolution/frameworks/fabric.js.map +1 -0
- package/dist/resolution/frameworks/go.d.ts +8 -0
- package/dist/resolution/frameworks/go.d.ts.map +1 -0
- package/dist/resolution/frameworks/go.js +161 -0
- package/dist/resolution/frameworks/go.js.map +1 -0
- package/dist/resolution/frameworks/goframe.d.ts +41 -0
- package/dist/resolution/frameworks/goframe.d.ts.map +1 -0
- package/dist/resolution/frameworks/goframe.js +112 -0
- package/dist/resolution/frameworks/goframe.js.map +1 -0
- package/dist/resolution/frameworks/index.d.ts +51 -0
- package/dist/resolution/frameworks/index.d.ts.map +1 -0
- package/dist/resolution/frameworks/index.js +177 -0
- package/dist/resolution/frameworks/index.js.map +1 -0
- package/dist/resolution/frameworks/java.d.ts +8 -0
- package/dist/resolution/frameworks/java.d.ts.map +1 -0
- package/dist/resolution/frameworks/java.js +509 -0
- package/dist/resolution/frameworks/java.js.map +1 -0
- package/dist/resolution/frameworks/laravel.d.ts +13 -0
- package/dist/resolution/frameworks/laravel.d.ts.map +1 -0
- package/dist/resolution/frameworks/laravel.js +257 -0
- package/dist/resolution/frameworks/laravel.js.map +1 -0
- package/dist/resolution/frameworks/nestjs.d.ts +26 -0
- package/dist/resolution/frameworks/nestjs.d.ts.map +1 -0
- package/dist/resolution/frameworks/nestjs.js +698 -0
- package/dist/resolution/frameworks/nestjs.js.map +1 -0
- package/dist/resolution/frameworks/play.d.ts +19 -0
- package/dist/resolution/frameworks/play.d.ts.map +1 -0
- package/dist/resolution/frameworks/play.js +111 -0
- package/dist/resolution/frameworks/play.js.map +1 -0
- package/dist/resolution/frameworks/python.d.ts +10 -0
- package/dist/resolution/frameworks/python.d.ts.map +1 -0
- package/dist/resolution/frameworks/python.js +400 -0
- package/dist/resolution/frameworks/python.js.map +1 -0
- package/dist/resolution/frameworks/react-native.d.ts +3 -0
- package/dist/resolution/frameworks/react-native.d.ts.map +1 -0
- package/dist/resolution/frameworks/react-native.js +410 -0
- package/dist/resolution/frameworks/react-native.js.map +1 -0
- package/dist/resolution/frameworks/react.d.ts +8 -0
- package/dist/resolution/frameworks/react.d.ts.map +1 -0
- package/dist/resolution/frameworks/react.js +334 -0
- package/dist/resolution/frameworks/react.js.map +1 -0
- package/dist/resolution/frameworks/ruby.d.ts +8 -0
- package/dist/resolution/frameworks/ruby.d.ts.map +1 -0
- package/dist/resolution/frameworks/ruby.js +302 -0
- package/dist/resolution/frameworks/ruby.js.map +1 -0
- package/dist/resolution/frameworks/rust.d.ts +8 -0
- package/dist/resolution/frameworks/rust.d.ts.map +1 -0
- package/dist/resolution/frameworks/rust.js +304 -0
- package/dist/resolution/frameworks/rust.js.map +1 -0
- package/dist/resolution/frameworks/svelte.d.ts +9 -0
- package/dist/resolution/frameworks/svelte.d.ts.map +1 -0
- package/dist/resolution/frameworks/svelte.js +253 -0
- package/dist/resolution/frameworks/svelte.js.map +1 -0
- package/dist/resolution/frameworks/swift-objc.d.ts +37 -0
- package/dist/resolution/frameworks/swift-objc.d.ts.map +1 -0
- package/dist/resolution/frameworks/swift-objc.js +252 -0
- package/dist/resolution/frameworks/swift-objc.js.map +1 -0
- package/dist/resolution/frameworks/swift.d.ts +10 -0
- package/dist/resolution/frameworks/swift.d.ts.map +1 -0
- package/dist/resolution/frameworks/swift.js +400 -0
- package/dist/resolution/frameworks/swift.js.map +1 -0
- package/dist/resolution/frameworks/vue.d.ts +9 -0
- package/dist/resolution/frameworks/vue.d.ts.map +1 -0
- package/dist/resolution/frameworks/vue.js +303 -0
- package/dist/resolution/frameworks/vue.js.map +1 -0
- package/dist/resolution/go-module.d.ts +26 -0
- package/dist/resolution/go-module.d.ts.map +1 -0
- package/dist/resolution/go-module.js +78 -0
- package/dist/resolution/go-module.js.map +1 -0
- package/dist/resolution/goframe-synthesizer.d.ts +28 -0
- package/dist/resolution/goframe-synthesizer.d.ts.map +1 -0
- package/dist/resolution/goframe-synthesizer.js +158 -0
- package/dist/resolution/goframe-synthesizer.js.map +1 -0
- package/dist/resolution/import-resolver.d.ts +78 -0
- package/dist/resolution/import-resolver.d.ts.map +1 -0
- package/dist/resolution/import-resolver.js +1849 -0
- package/dist/resolution/import-resolver.js.map +1 -0
- package/dist/resolution/index.d.ts +196 -0
- package/dist/resolution/index.d.ts.map +1 -0
- package/dist/resolution/index.js +1328 -0
- package/dist/resolution/index.js.map +1 -0
- package/dist/resolution/lru-cache.d.ts +24 -0
- package/dist/resolution/lru-cache.d.ts.map +1 -0
- package/dist/resolution/lru-cache.js +62 -0
- package/dist/resolution/lru-cache.js.map +1 -0
- package/dist/resolution/name-matcher.d.ts +93 -0
- package/dist/resolution/name-matcher.d.ts.map +1 -0
- package/dist/resolution/name-matcher.js +1212 -0
- package/dist/resolution/name-matcher.js.map +1 -0
- package/dist/resolution/path-aliases.d.ts +68 -0
- package/dist/resolution/path-aliases.d.ts.map +1 -0
- package/dist/resolution/path-aliases.js +238 -0
- package/dist/resolution/path-aliases.js.map +1 -0
- package/dist/resolution/strip-comments.d.ts +27 -0
- package/dist/resolution/strip-comments.d.ts.map +1 -0
- package/dist/resolution/strip-comments.js +443 -0
- package/dist/resolution/strip-comments.js.map +1 -0
- package/dist/resolution/swift-objc-bridge.d.ts +134 -0
- package/dist/resolution/swift-objc-bridge.d.ts.map +1 -0
- package/dist/resolution/swift-objc-bridge.js +256 -0
- package/dist/resolution/swift-objc-bridge.js.map +1 -0
- package/dist/resolution/types.d.ts +233 -0
- package/dist/resolution/types.d.ts.map +1 -0
- package/dist/resolution/types.js +8 -0
- package/dist/resolution/types.js.map +1 -0
- package/dist/resolution/workspace-packages.d.ts +48 -0
- package/dist/resolution/workspace-packages.d.ts.map +1 -0
- package/dist/resolution/workspace-packages.js +208 -0
- package/dist/resolution/workspace-packages.js.map +1 -0
- package/dist/search/query-parser.d.ts +57 -0
- package/dist/search/query-parser.d.ts.map +1 -0
- package/dist/search/query-parser.js +177 -0
- package/dist/search/query-parser.js.map +1 -0
- package/dist/search/query-utils.d.ts +87 -0
- package/dist/search/query-utils.d.ts.map +1 -0
- package/dist/search/query-utils.js +449 -0
- package/dist/search/query-utils.js.map +1 -0
- package/dist/sync/git-hooks.d.ts +45 -0
- package/dist/sync/git-hooks.d.ts.map +1 -0
- package/dist/sync/git-hooks.js +225 -0
- package/dist/sync/git-hooks.js.map +1 -0
- package/dist/sync/index.d.ts +19 -0
- package/dist/sync/index.d.ts.map +1 -0
- package/dist/sync/index.js +35 -0
- package/dist/sync/index.js.map +1 -0
- package/dist/sync/watch-policy.d.ts +48 -0
- package/dist/sync/watch-policy.d.ts.map +1 -0
- package/dist/sync/watch-policy.js +124 -0
- package/dist/sync/watch-policy.js.map +1 -0
- package/dist/sync/watcher.d.ts +350 -0
- package/dist/sync/watcher.d.ts.map +1 -0
- package/dist/sync/watcher.js +811 -0
- package/dist/sync/watcher.js.map +1 -0
- package/dist/sync/worktree.d.ts +54 -0
- package/dist/sync/worktree.d.ts.map +1 -0
- package/dist/sync/worktree.js +137 -0
- package/dist/sync/worktree.js.map +1 -0
- package/dist/telemetry/index.d.ts +143 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/index.js +541 -0
- package/dist/telemetry/index.js.map +1 -0
- package/dist/types.d.ts +392 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +82 -0
- package/dist/types.js.map +1 -0
- package/dist/ui/glyphs.d.ts +42 -0
- package/dist/ui/glyphs.d.ts.map +1 -0
- package/dist/ui/glyphs.js +78 -0
- package/dist/ui/glyphs.js.map +1 -0
- package/dist/ui/shimmer-progress.d.ts +11 -0
- package/dist/ui/shimmer-progress.d.ts.map +1 -0
- package/dist/ui/shimmer-progress.js +90 -0
- package/dist/ui/shimmer-progress.js.map +1 -0
- package/dist/ui/shimmer-worker.d.ts +2 -0
- package/dist/ui/shimmer-worker.d.ts.map +1 -0
- package/dist/ui/shimmer-worker.js +118 -0
- package/dist/ui/shimmer-worker.js.map +1 -0
- package/dist/ui/types.d.ts +17 -0
- package/dist/ui/types.d.ts.map +1 -0
- package/dist/ui/types.js +3 -0
- package/dist/ui/types.js.map +1 -0
- package/dist/upgrade/index.d.ts +132 -0
- package/dist/upgrade/index.d.ts.map +1 -0
- package/dist/upgrade/index.js +498 -0
- package/dist/upgrade/index.js.map +1 -0
- package/dist/utils.d.ts +224 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +583 -0
- package/dist/utils.js.map +1 -0
- package/package.json +57 -5
- package/scripts/add-lang/bench.sh +60 -0
- package/scripts/add-lang/check-grammar.mjs +75 -0
- package/scripts/add-lang/dump-ast.mjs +103 -0
- package/scripts/add-lang/verify-extraction.mjs +70 -0
- package/scripts/agent-eval/ab-adoption.sh +91 -0
- package/scripts/agent-eval/ab-hook.sh +86 -0
- package/scripts/agent-eval/ab-impl.sh +78 -0
- package/scripts/agent-eval/ab-new-vs-baseline.sh +102 -0
- package/scripts/agent-eval/ab-sufficiency.sh +78 -0
- package/scripts/agent-eval/arms-F.sh +21 -0
- package/scripts/agent-eval/arms-matrix.sh +37 -0
- package/scripts/agent-eval/audit.sh +68 -0
- package/scripts/agent-eval/bench-readme.sh +28 -0
- package/scripts/agent-eval/bench-why-repo.sh +22 -0
- package/scripts/agent-eval/block-read-hook.sh +19 -0
- package/scripts/agent-eval/hook-settings.json +15 -0
- package/scripts/agent-eval/itrun.sh +120 -0
- package/scripts/agent-eval/offload-eval-3arm.sh +72 -0
- package/scripts/agent-eval/offload-eval-cost.mjs +133 -0
- package/scripts/agent-eval/offload-eval-effort.mjs +108 -0
- package/scripts/agent-eval/offload-eval-frontload-matrix.sh +25 -0
- package/scripts/agent-eval/offload-eval-frontload.sh +47 -0
- package/scripts/agent-eval/offload-eval-ground-truth.json +18 -0
- package/scripts/agent-eval/offload-eval-hook.mjs +84 -0
- package/scripts/agent-eval/offload-eval-judge.mjs +103 -0
- package/scripts/agent-eval/offload-eval-matrix.sh +20 -0
- package/scripts/agent-eval/offload-eval-metrics.mjs +94 -0
- package/scripts/agent-eval/offload-eval-refs1.sh +50 -0
- package/scripts/agent-eval/offload-eval-setup.sh +24 -0
- package/scripts/agent-eval/offload-eval-styles.sh +72 -0
- package/scripts/agent-eval/offload-eval-summarize.mjs +68 -0
- package/scripts/agent-eval/offload-eval.md +76 -0
- package/scripts/agent-eval/parse-arms.mjs +116 -0
- package/scripts/agent-eval/parse-bench-readme.mjs +84 -0
- package/scripts/agent-eval/parse-run.mjs +45 -0
- package/scripts/agent-eval/parse-session.mjs +93 -0
- package/scripts/agent-eval/probe-context.mjs +21 -0
- package/scripts/agent-eval/probe-explore.mjs +40 -0
- package/scripts/agent-eval/probe-node.mjs +20 -0
- package/scripts/agent-eval/probe-sweep.mjs +119 -0
- package/scripts/agent-eval/probe-trace.mjs +20 -0
- package/scripts/agent-eval/redirect-read-hook.sh +38 -0
- package/scripts/agent-eval/run-agent.sh +34 -0
- package/scripts/agent-eval/run-all.sh +69 -0
- package/scripts/agent-eval/run-arms.sh +56 -0
- package/scripts/agent-eval/seq-matrix.mjs +137 -0
- package/scripts/build-bundle.sh +118 -0
- package/scripts/extract-release-notes.mjs +130 -0
- package/scripts/local-install.sh +41 -0
- package/scripts/npm-sdk.js +75 -0
- package/scripts/npm-shim.js +246 -0
- package/scripts/pack-npm.sh +119 -0
- package/scripts/prepare-release.mjs +270 -0
- package/scripts/qa_eval/README.md +404 -0
- package/scripts/qa_eval/_test_deveco_probe.py +41 -0
- package/scripts/qa_eval/agent_runner.py +526 -0
- package/scripts/qa_eval/data/.gitignore +4 -0
- package/scripts/qa_eval/data/test-set.jsonl +22 -0
- package/scripts/qa_eval/eval_metrics.py +233 -0
- package/scripts/qa_eval/external_agent.py +671 -0
- package/scripts/qa_eval/llm_config.py +92 -0
- package/scripts/qa_eval/memory_monitor.py +132 -0
- package/scripts/qa_eval/my_answer_accuracy.py +187 -0
- package/scripts/qa_eval/requirements.txt +2 -0
- package/scripts/qa_eval/run_pipeline.py +711 -0
- package/scripts/qa_eval/stats_efficiency.py +279 -0
- package/scripts/qa_eval/stats_scores.py +207 -0
|
@@ -0,0 +1,671 @@
|
|
|
1
|
+
"""Run qa_eval dataset through real Agent hosts: Claude Code CLI, DevEco Code (opencode CLI)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import logging
|
|
7
|
+
import os
|
|
8
|
+
import re
|
|
9
|
+
import shutil
|
|
10
|
+
import subprocess
|
|
11
|
+
import tempfile
|
|
12
|
+
import time
|
|
13
|
+
from datetime import datetime
|
|
14
|
+
from pathlib import Path
|
|
15
|
+
from typing import Any
|
|
16
|
+
|
|
17
|
+
from memory_monitor import sample_memory
|
|
18
|
+
|
|
19
|
+
logger = logging.getLogger(__name__)
|
|
20
|
+
|
|
21
|
+
TIME_FMT = "%Y-%m-%d %H:%M:%S.%f"
|
|
22
|
+
|
|
23
|
+
HOST_CLAUDE = "claude-code"
|
|
24
|
+
HOST_DEVECO = "deveco-code"
|
|
25
|
+
SUPPORTED_HOSTS = (HOST_CLAUDE, HOST_DEVECO)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _strip_ansi(text: str) -> str:
|
|
29
|
+
return re.sub(r"\x1b\[[0-9;]*m", "", text or "")
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def _extract_deveco_json_errors(text: str) -> str | None:
|
|
33
|
+
"""Parse deveco --format json error lines into a short message."""
|
|
34
|
+
messages: list[str] = []
|
|
35
|
+
for line in _strip_ansi(text).splitlines():
|
|
36
|
+
line = line.strip()
|
|
37
|
+
if not line.startswith("{"):
|
|
38
|
+
continue
|
|
39
|
+
try:
|
|
40
|
+
ev = json.loads(line)
|
|
41
|
+
except json.JSONDecodeError:
|
|
42
|
+
continue
|
|
43
|
+
if ev.get("type") != "error":
|
|
44
|
+
continue
|
|
45
|
+
err = ev.get("error") or {}
|
|
46
|
+
data = err.get("data") or {}
|
|
47
|
+
msg = data.get("message") or err.get("message") or err.get("name")
|
|
48
|
+
if msg and msg not in messages:
|
|
49
|
+
messages.append(str(msg))
|
|
50
|
+
if not messages:
|
|
51
|
+
return None
|
|
52
|
+
return "; ".join(messages)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def _cli_error_summary(stderr: str, stdout: str, *, max_len: int = 400) -> str:
|
|
56
|
+
"""Pick a short user-facing error from CLI stderr/stdout."""
|
|
57
|
+
for raw in (stderr, stdout):
|
|
58
|
+
deveco_err = _extract_deveco_json_errors(raw)
|
|
59
|
+
if deveco_err:
|
|
60
|
+
return deveco_err[:max_len]
|
|
61
|
+
for raw in (stderr, stdout):
|
|
62
|
+
clean = _strip_ansi(raw).strip()
|
|
63
|
+
if not clean:
|
|
64
|
+
continue
|
|
65
|
+
for line in clean.splitlines():
|
|
66
|
+
line = line.strip()
|
|
67
|
+
if not line or line.lower().startswith("error:"):
|
|
68
|
+
continue
|
|
69
|
+
if len(line) > 20:
|
|
70
|
+
return line[:max_len]
|
|
71
|
+
if clean:
|
|
72
|
+
return clean[:max_len]
|
|
73
|
+
return ""
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def auth_failure_reason(text: str) -> str | None:
|
|
77
|
+
"""Return a user-facing reason if output looks like an auth/login failure."""
|
|
78
|
+
t = _strip_ansi(text or "").lower()
|
|
79
|
+
if any(h in t for h in ("not logged in", "please run /login")) or (
|
|
80
|
+
"/login" in t and "run" in t
|
|
81
|
+
):
|
|
82
|
+
return "Claude Code 未登录,请先运行: claude login"
|
|
83
|
+
if "credentials cannot be decrypted" in t or "saved provider credentials are unavailable" in t:
|
|
84
|
+
return (
|
|
85
|
+
"DevEco Code 本地凭证无法解密。请运行: deveco providers reset,"
|
|
86
|
+
"然后在 TUI 中重新配置模型,或执行 deveco providers login"
|
|
87
|
+
)
|
|
88
|
+
if "deveco providers reset" in t or "deveco auth reset" in t:
|
|
89
|
+
return (
|
|
90
|
+
"DevEco Code 未配置或凭证无效。请运行: deveco providers reset,"
|
|
91
|
+
"然后重新登录/配置 provider"
|
|
92
|
+
)
|
|
93
|
+
if "model not found" in t:
|
|
94
|
+
return (
|
|
95
|
+
"DevEco 模型名无效。deveco 需要 provider/model 格式(如 zhipuai/glm-4.5-flash),"
|
|
96
|
+
"可用 `deveco models` 查看;勿把 Judge 的 --model 直接传给 deveco"
|
|
97
|
+
)
|
|
98
|
+
return "API Key 无效"
|
|
99
|
+
if "authentication required" in t or "unauthorized" in t:
|
|
100
|
+
return "未授权,请检查登录或 API Key"
|
|
101
|
+
return None
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def _log_line(log_file: Path | None, msg: str) -> None:
|
|
105
|
+
if log_file is None:
|
|
106
|
+
return
|
|
107
|
+
log_file.parent.mkdir(parents=True, exist_ok=True)
|
|
108
|
+
with log_file.open("a", encoding="utf-8") as f:
|
|
109
|
+
f.write(f"{datetime.now().strftime(TIME_FMT)} {msg}\n")
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def _log_memory(log_file: Path | None, mem: dict[str, float | None]) -> None:
|
|
113
|
+
if mem.get("peak_rss_mb") is not None:
|
|
114
|
+
_log_line(log_file, f"peakRssMb = {mem['peak_rss_mb']}")
|
|
115
|
+
if mem.get("avg_rss_mb") is not None:
|
|
116
|
+
_log_line(log_file, f"avgRssMb = {mem['avg_rss_mb']}")
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def find_claude_cli() -> str:
|
|
120
|
+
found = shutil.which("claude")
|
|
121
|
+
if not found:
|
|
122
|
+
raise FileNotFoundError(
|
|
123
|
+
"未找到 claude CLI。请安装 Claude Code 并确保 `claude` 在 PATH 中。"
|
|
124
|
+
)
|
|
125
|
+
return found
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def find_deveco_cli() -> str:
|
|
129
|
+
for name in ("deveco", "opencode"):
|
|
130
|
+
found = shutil.which(name)
|
|
131
|
+
if found:
|
|
132
|
+
return found
|
|
133
|
+
raise FileNotFoundError(
|
|
134
|
+
"未找到 DevEco Code / opencode CLI。请安装 DevEco Code 或 opencode 并加入 PATH。"
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def _popen_capture(cmd: list[str], *, cwd: str) -> subprocess.Popen:
|
|
139
|
+
"""Run CLI with UTF-8 stdout/stderr (Windows default locale is often GBK)."""
|
|
140
|
+
return subprocess.Popen(
|
|
141
|
+
cmd,
|
|
142
|
+
cwd=cwd,
|
|
143
|
+
stdout=subprocess.PIPE,
|
|
144
|
+
stderr=subprocess.PIPE,
|
|
145
|
+
text=True,
|
|
146
|
+
encoding="utf-8",
|
|
147
|
+
errors="replace",
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def write_mcp_config(path: Path, *, hg_command: str, hg_args: list[str]) -> None:
|
|
152
|
+
path.write_text(
|
|
153
|
+
json.dumps({"mcpServers": {"homegraph": {"command": hg_command, "args": hg_args}}}, indent=2)
|
|
154
|
+
+ "\n",
|
|
155
|
+
encoding="utf-8",
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def _split_hg_bin(hg_bin: str) -> tuple[str, list[str]]:
|
|
160
|
+
if hg_bin.startswith("node "):
|
|
161
|
+
parts = hg_bin.split(" ", 1)
|
|
162
|
+
return parts[0], parts[1].split() + ["serve", "--mcp"]
|
|
163
|
+
return hg_bin, ["serve", "--mcp"]
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def parse_claude_stream_json(raw: str) -> dict[str, Any]:
|
|
167
|
+
tool_trace: list[str] = []
|
|
168
|
+
answer_parts: list[str] = []
|
|
169
|
+
total_tokens = 0
|
|
170
|
+
max_turn = 0
|
|
171
|
+
duration_ms = 0
|
|
172
|
+
|
|
173
|
+
for line in raw.splitlines():
|
|
174
|
+
line = line.strip()
|
|
175
|
+
if not line:
|
|
176
|
+
continue
|
|
177
|
+
try:
|
|
178
|
+
ev = json.loads(line)
|
|
179
|
+
except json.JSONDecodeError:
|
|
180
|
+
continue
|
|
181
|
+
|
|
182
|
+
if ev.get("type") == "assistant" and ev.get("message", {}).get("content"):
|
|
183
|
+
max_turn += 1
|
|
184
|
+
for block in ev["message"]["content"]:
|
|
185
|
+
if block.get("type") == "text" and block.get("text"):
|
|
186
|
+
answer_parts.append(str(block["text"]))
|
|
187
|
+
if block.get("type") == "tool_use":
|
|
188
|
+
name = block.get("name", "?")
|
|
189
|
+
inp = block.get("input") or {}
|
|
190
|
+
tool_trace.append(
|
|
191
|
+
f"---\n{name}\nargs: {json.dumps(inp, ensure_ascii=False)[:500]}\n---"
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
if ev.get("type") == "result":
|
|
195
|
+
usage = ev.get("usage") or {}
|
|
196
|
+
total_tokens = int(
|
|
197
|
+
(usage.get("input_tokens") or 0)
|
|
198
|
+
+ (usage.get("cache_read_input_tokens") or 0)
|
|
199
|
+
+ (usage.get("cache_creation_input_tokens") or 0)
|
|
200
|
+
+ (usage.get("output_tokens") or 0)
|
|
201
|
+
)
|
|
202
|
+
duration_ms = int(ev.get("duration_ms") or 0)
|
|
203
|
+
if ev.get("num_turns"):
|
|
204
|
+
max_turn = max(max_turn, int(ev["num_turns"]))
|
|
205
|
+
if ev.get("result") and not answer_parts:
|
|
206
|
+
answer_parts.append(str(ev["result"]))
|
|
207
|
+
|
|
208
|
+
answer = "\n".join(answer_parts).strip()
|
|
209
|
+
output = "\n\n".join(tool_trace + ([answer] if answer else []))
|
|
210
|
+
auth_err = auth_failure_reason(answer) or auth_failure_reason(raw)
|
|
211
|
+
if auth_err:
|
|
212
|
+
return {
|
|
213
|
+
"output_answer": output,
|
|
214
|
+
"agent_status": "error",
|
|
215
|
+
"agent_error": auth_err,
|
|
216
|
+
"agent_turns": max_turn,
|
|
217
|
+
"agent_duration_ms": duration_ms,
|
|
218
|
+
"agent_usage": {"total_tokens": total_tokens} if total_tokens else {},
|
|
219
|
+
}
|
|
220
|
+
return {
|
|
221
|
+
"output_answer": output,
|
|
222
|
+
"agent_status": "success" if answer else "error",
|
|
223
|
+
"agent_turns": max_turn,
|
|
224
|
+
"agent_duration_ms": duration_ms,
|
|
225
|
+
"agent_usage": {"total_tokens": total_tokens} if total_tokens else {},
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
def parse_opencode_json_events(raw: str) -> dict[str, Any]:
|
|
230
|
+
tool_trace: list[str] = []
|
|
231
|
+
answer_parts: list[str] = []
|
|
232
|
+
total_tokens = 0
|
|
233
|
+
max_turn = 0
|
|
234
|
+
duration_ms = 0
|
|
235
|
+
stream_errors: list[str] = []
|
|
236
|
+
|
|
237
|
+
for line in raw.splitlines():
|
|
238
|
+
line = line.strip()
|
|
239
|
+
if not line:
|
|
240
|
+
continue
|
|
241
|
+
try:
|
|
242
|
+
ev = json.loads(line)
|
|
243
|
+
except json.JSONDecodeError:
|
|
244
|
+
continue
|
|
245
|
+
|
|
246
|
+
ev_type = ev.get("type") or ev.get("event")
|
|
247
|
+
part = ev.get("part") if isinstance(ev.get("part"), dict) else {}
|
|
248
|
+
|
|
249
|
+
if ev_type == "error":
|
|
250
|
+
err = ev.get("error") or {}
|
|
251
|
+
data = err.get("data") or {}
|
|
252
|
+
msg = data.get("message") or err.get("message") or err.get("name")
|
|
253
|
+
if msg:
|
|
254
|
+
stream_errors.append(str(msg))
|
|
255
|
+
|
|
256
|
+
# DevEco / opencode stream-json: {type:"text", part:{type:"text", text:"..."}}
|
|
257
|
+
if ev_type == "text" and part.get("text"):
|
|
258
|
+
text = str(part["text"]).strip()
|
|
259
|
+
if text:
|
|
260
|
+
answer_parts.append(text)
|
|
261
|
+
max_turn += 1
|
|
262
|
+
|
|
263
|
+
part_type = part.get("type") or ""
|
|
264
|
+
if ev_type in ("tool", "tool_call", "tool_use") or part_type in (
|
|
265
|
+
"tool",
|
|
266
|
+
"tool-invocation",
|
|
267
|
+
"tool_use",
|
|
268
|
+
"tool-call",
|
|
269
|
+
):
|
|
270
|
+
max_turn += 1
|
|
271
|
+
name = part.get("tool") or part.get("name") or ev.get("tool") or "?"
|
|
272
|
+
inp = part.get("input") or part.get("args") or part.get("state") or ev.get("input") or {}
|
|
273
|
+
tool_trace.append(
|
|
274
|
+
f"---\n{name}\nargs: {json.dumps(inp, ensure_ascii=False)[:500]}\n---"
|
|
275
|
+
)
|
|
276
|
+
|
|
277
|
+
if ev_type in ("message", "assistant"):
|
|
278
|
+
content = ev.get("content") or ev.get("text") or ev.get("message")
|
|
279
|
+
if isinstance(content, str) and content.strip():
|
|
280
|
+
answer_parts.append(content.strip())
|
|
281
|
+
max_turn += 1
|
|
282
|
+
elif isinstance(content, list):
|
|
283
|
+
max_turn += 1
|
|
284
|
+
for block in content:
|
|
285
|
+
if isinstance(block, dict):
|
|
286
|
+
if block.get("type") == "text" and block.get("text"):
|
|
287
|
+
answer_parts.append(str(block["text"]))
|
|
288
|
+
if block.get("type") == "tool_use":
|
|
289
|
+
tool_trace.append(
|
|
290
|
+
f"---\n{block.get('name', '?')}\n"
|
|
291
|
+
f"args: {json.dumps(block.get('input') or {}, ensure_ascii=False)[:500]}\n---"
|
|
292
|
+
)
|
|
293
|
+
|
|
294
|
+
usage = ev.get("usage") or ev.get("tokens")
|
|
295
|
+
if isinstance(usage, dict):
|
|
296
|
+
total = usage.get("total") or usage.get("total_tokens")
|
|
297
|
+
if total:
|
|
298
|
+
total_tokens = max(total_tokens, int(total))
|
|
299
|
+
|
|
300
|
+
if ev.get("duration_ms"):
|
|
301
|
+
duration_ms = max(duration_ms, int(ev["duration_ms"]))
|
|
302
|
+
|
|
303
|
+
part_time = part.get("time") if isinstance(part.get("time"), dict) else {}
|
|
304
|
+
if part_time.get("start") and part_time.get("end"):
|
|
305
|
+
duration_ms = max(duration_ms, int(part_time["end"]) - int(part_time["start"]))
|
|
306
|
+
|
|
307
|
+
answer = "\n".join(answer_parts).strip()
|
|
308
|
+
output = "\n\n".join(tool_trace + ([answer] if answer else []))
|
|
309
|
+
auth_err = auth_failure_reason(answer) or auth_failure_reason(raw)
|
|
310
|
+
if auth_err:
|
|
311
|
+
return {
|
|
312
|
+
"output_answer": output,
|
|
313
|
+
"agent_status": "error",
|
|
314
|
+
"agent_error": auth_err,
|
|
315
|
+
"agent_turns": max_turn,
|
|
316
|
+
"agent_duration_ms": duration_ms,
|
|
317
|
+
"agent_usage": {"total_tokens": total_tokens} if total_tokens else {},
|
|
318
|
+
}
|
|
319
|
+
if stream_errors and not answer:
|
|
320
|
+
return {
|
|
321
|
+
"output_answer": output,
|
|
322
|
+
"agent_status": "error",
|
|
323
|
+
"agent_error": "; ".join(stream_errors),
|
|
324
|
+
"agent_turns": max_turn,
|
|
325
|
+
"agent_duration_ms": duration_ms,
|
|
326
|
+
"agent_usage": {"total_tokens": total_tokens} if total_tokens else {},
|
|
327
|
+
}
|
|
328
|
+
return {
|
|
329
|
+
"output_answer": output,
|
|
330
|
+
"agent_status": "success" if answer else "error",
|
|
331
|
+
"agent_error": None if answer else "deveco 未返回可解析的文本回答",
|
|
332
|
+
"agent_turns": max_turn,
|
|
333
|
+
"agent_duration_ms": duration_ms,
|
|
334
|
+
"agent_usage": {"total_tokens": total_tokens} if total_tokens else {},
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
def verify_claude_login() -> None:
|
|
339
|
+
"""Fail fast before burning the whole dataset on 'Not logged in'."""
|
|
340
|
+
claude = find_claude_cli()
|
|
341
|
+
proc = subprocess.run(
|
|
342
|
+
[claude, "-p", "ping", "--output-format", "text", "--max-turns", "1"],
|
|
343
|
+
capture_output=True,
|
|
344
|
+
text=True,
|
|
345
|
+
timeout=45,
|
|
346
|
+
cwd=os.getcwd(),
|
|
347
|
+
)
|
|
348
|
+
combined = f"{proc.stdout}\n{proc.stderr}"
|
|
349
|
+
reason = auth_failure_reason(combined)
|
|
350
|
+
if reason:
|
|
351
|
+
raise RuntimeError(f"{reason}\n(探测输出: {combined.strip()[:200]})")
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
def run_claude_query(
|
|
355
|
+
repo: Path,
|
|
356
|
+
query: str,
|
|
357
|
+
*,
|
|
358
|
+
arm: str,
|
|
359
|
+
hg_bin: str,
|
|
360
|
+
log_file: Path | None,
|
|
361
|
+
task_id: int,
|
|
362
|
+
timeout_sec: int = 600,
|
|
363
|
+
) -> dict[str, Any]:
|
|
364
|
+
claude = find_claude_cli()
|
|
365
|
+
backend = f"claude-code-{'with' if arm == 'with' else 'without'}-homegraph"
|
|
366
|
+
|
|
367
|
+
with tempfile.TemporaryDirectory(prefix="qa-eval-mcp-") as tmp:
|
|
368
|
+
mcp_path = Path(tmp) / "mcp.json"
|
|
369
|
+
if arm == "with":
|
|
370
|
+
cmd, base_args = _split_hg_bin(hg_bin)
|
|
371
|
+
write_mcp_config(
|
|
372
|
+
mcp_path,
|
|
373
|
+
hg_command=cmd,
|
|
374
|
+
hg_args=[*base_args, "--path", str(repo.resolve())],
|
|
375
|
+
)
|
|
376
|
+
mcp_args = ["--strict-mcp-config", "--mcp-config", str(mcp_path)]
|
|
377
|
+
else:
|
|
378
|
+
mcp_path.write_text('{"mcpServers":{}}\n', encoding="utf-8")
|
|
379
|
+
mcp_args = ["--strict-mcp-config", "--mcp-config", str(mcp_path)]
|
|
380
|
+
|
|
381
|
+
cmd = [
|
|
382
|
+
claude,
|
|
383
|
+
"-p",
|
|
384
|
+
query,
|
|
385
|
+
"--output-format",
|
|
386
|
+
"stream-json",
|
|
387
|
+
"--verbose",
|
|
388
|
+
"--permission-mode",
|
|
389
|
+
"bypassPermissions",
|
|
390
|
+
*mcp_args,
|
|
391
|
+
]
|
|
392
|
+
|
|
393
|
+
_log_line(log_file, f"Evaluate {task_id}:")
|
|
394
|
+
_log_line(log_file, "the 1 turn")
|
|
395
|
+
t0 = time.time()
|
|
396
|
+
|
|
397
|
+
proc = _popen_capture(cmd, cwd=str(repo))
|
|
398
|
+
with sample_memory(proc.pid) as sampler:
|
|
399
|
+
try:
|
|
400
|
+
stdout, stderr = proc.communicate(timeout=timeout_sec)
|
|
401
|
+
except subprocess.TimeoutExpired:
|
|
402
|
+
proc.kill()
|
|
403
|
+
stdout, stderr = proc.communicate()
|
|
404
|
+
mem = sampler.last_stats
|
|
405
|
+
_log_memory(log_file, mem)
|
|
406
|
+
return {
|
|
407
|
+
"output_answer": "",
|
|
408
|
+
"agent_status": "error",
|
|
409
|
+
"agent_error": f"timeout after {timeout_sec}s",
|
|
410
|
+
"agent_backend": backend,
|
|
411
|
+
"agent_memory_mb": mem,
|
|
412
|
+
}
|
|
413
|
+
mem = sampler.last_stats
|
|
414
|
+
|
|
415
|
+
if proc.returncode != 0 and not (stdout or "").strip():
|
|
416
|
+
_log_memory(log_file, mem)
|
|
417
|
+
return {
|
|
418
|
+
"output_answer": (stderr or "")[:2000],
|
|
419
|
+
"agent_status": "error",
|
|
420
|
+
"agent_error": f"claude exit {proc.returncode}",
|
|
421
|
+
"agent_backend": backend,
|
|
422
|
+
"agent_memory_mb": mem,
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
_log_line(log_file, "first token")
|
|
426
|
+
combined = f"{stdout}\n{stderr}"
|
|
427
|
+
auth_err = auth_failure_reason(combined)
|
|
428
|
+
if auth_err:
|
|
429
|
+
_log_memory(log_file, mem)
|
|
430
|
+
return {
|
|
431
|
+
"output_answer": (stdout or stderr or "")[:2000],
|
|
432
|
+
"agent_status": "error",
|
|
433
|
+
"agent_error": auth_err,
|
|
434
|
+
"agent_backend": backend,
|
|
435
|
+
"agent_host": HOST_CLAUDE,
|
|
436
|
+
"agent_memory_mb": mem,
|
|
437
|
+
}
|
|
438
|
+
parsed = parse_claude_stream_json(stdout or "")
|
|
439
|
+
tokens = (parsed.get("agent_usage") or {}).get("total_tokens") or 0
|
|
440
|
+
if tokens:
|
|
441
|
+
_log_line(log_file, f"totalTokenCount = {tokens}")
|
|
442
|
+
_log_memory(log_file, mem)
|
|
443
|
+
|
|
444
|
+
duration_ms = parsed.get("agent_duration_ms") or int((time.time() - t0) * 1000)
|
|
445
|
+
return {
|
|
446
|
+
**parsed,
|
|
447
|
+
"agent_duration_ms": duration_ms,
|
|
448
|
+
"agent_backend": backend,
|
|
449
|
+
"agent_host": HOST_CLAUDE,
|
|
450
|
+
"ab_arm": "with-homegraph" if arm == "with" else "without-homegraph",
|
|
451
|
+
"agent_memory_mb": mem,
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
|
|
455
|
+
def _deveco_project_config_dir(repo: Path) -> Path:
|
|
456
|
+
"""Project-level deveco config (read before ~/.config/deveco/deveco.jsonc)."""
|
|
457
|
+
return repo / ".deveco"
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
def _write_deveco_project_mcp(repo: Path, *, arm: str, hg_bin: str) -> Path:
|
|
461
|
+
"""Write repo/.deveco/deveco.jsonc for MCP only; credentials stay in ~/.config/deveco."""
|
|
462
|
+
config_dir = _deveco_project_config_dir(repo)
|
|
463
|
+
config_dir.mkdir(parents=True, exist_ok=True)
|
|
464
|
+
config_path = config_dir / "deveco.jsonc"
|
|
465
|
+
if arm == "with":
|
|
466
|
+
if not hg_bin:
|
|
467
|
+
from agent_runner import find_homegraph_bin
|
|
468
|
+
|
|
469
|
+
hg_bin = find_homegraph_bin(None)
|
|
470
|
+
cmd, base_args = _split_hg_bin(hg_bin)
|
|
471
|
+
body = {
|
|
472
|
+
"$schema": "https://opencode.ai/config.json",
|
|
473
|
+
"mcp": {
|
|
474
|
+
"homegraph": {
|
|
475
|
+
"type": "local",
|
|
476
|
+
"command": [cmd, *base_args, "--path", str(repo.resolve())],
|
|
477
|
+
"enabled": True,
|
|
478
|
+
}
|
|
479
|
+
},
|
|
480
|
+
}
|
|
481
|
+
else:
|
|
482
|
+
body = {"$schema": "https://opencode.ai/config.json", "mcp": {}}
|
|
483
|
+
config_path.write_text(json.dumps(body, indent=2) + "\n", encoding="utf-8")
|
|
484
|
+
return config_path
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
DEFAULT_DEVECO_MODEL = "zhipuai/glm-4.5-flash"
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
def run_deveco_query(
|
|
491
|
+
repo: Path,
|
|
492
|
+
query: str,
|
|
493
|
+
*,
|
|
494
|
+
arm: str,
|
|
495
|
+
hg_bin: str,
|
|
496
|
+
log_file: Path | None,
|
|
497
|
+
task_id: int,
|
|
498
|
+
model: str | None = None,
|
|
499
|
+
timeout_sec: int = 600,
|
|
500
|
+
) -> dict[str, Any]:
|
|
501
|
+
cli = find_deveco_cli()
|
|
502
|
+
backend = f"deveco-code-{'with' if arm == 'with' else 'without'}-homegraph"
|
|
503
|
+
|
|
504
|
+
_write_deveco_project_mcp(repo, arm=arm, hg_bin=hg_bin)
|
|
505
|
+
|
|
506
|
+
run_cmd = [
|
|
507
|
+
cli,
|
|
508
|
+
"run",
|
|
509
|
+
query,
|
|
510
|
+
"--format",
|
|
511
|
+
"json",
|
|
512
|
+
"--dir",
|
|
513
|
+
str(repo),
|
|
514
|
+
"--dangerously-skip-permissions",
|
|
515
|
+
]
|
|
516
|
+
if model:
|
|
517
|
+
run_cmd.extend(["--model", model])
|
|
518
|
+
else:
|
|
519
|
+
run_cmd.extend(["--model", DEFAULT_DEVECO_MODEL])
|
|
520
|
+
|
|
521
|
+
_log_line(log_file, f"Evaluate {task_id}:")
|
|
522
|
+
_log_line(log_file, "the 1 turn")
|
|
523
|
+
t0 = time.time()
|
|
524
|
+
|
|
525
|
+
proc = _popen_capture(run_cmd, cwd=str(repo))
|
|
526
|
+
with sample_memory(proc.pid) as sampler:
|
|
527
|
+
try:
|
|
528
|
+
stdout, stderr = proc.communicate(timeout=timeout_sec)
|
|
529
|
+
except subprocess.TimeoutExpired:
|
|
530
|
+
proc.kill()
|
|
531
|
+
stdout, stderr = proc.communicate()
|
|
532
|
+
mem = sampler.last_stats
|
|
533
|
+
_log_memory(log_file, mem)
|
|
534
|
+
return {
|
|
535
|
+
"output_answer": "",
|
|
536
|
+
"agent_status": "error",
|
|
537
|
+
"agent_error": f"timeout after {timeout_sec}s",
|
|
538
|
+
"agent_backend": backend,
|
|
539
|
+
"agent_memory_mb": mem,
|
|
540
|
+
}
|
|
541
|
+
mem = sampler.last_stats
|
|
542
|
+
combined = f"{stdout or ''}\n{stderr or ''}"
|
|
543
|
+
|
|
544
|
+
if proc.returncode != 0:
|
|
545
|
+
auth_err = auth_failure_reason(combined)
|
|
546
|
+
detail = auth_err or _cli_error_summary(stderr, stdout)
|
|
547
|
+
err_msg = detail or f"{cli} exit {proc.returncode}"
|
|
548
|
+
_log_memory(log_file, mem)
|
|
549
|
+
return {
|
|
550
|
+
"output_answer": _strip_ansi(stderr or stdout or "")[:2000],
|
|
551
|
+
"agent_status": "error",
|
|
552
|
+
"agent_error": err_msg,
|
|
553
|
+
"agent_backend": backend,
|
|
554
|
+
"agent_host": HOST_DEVECO,
|
|
555
|
+
"agent_memory_mb": mem,
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
_log_line(log_file, "first token")
|
|
559
|
+
out = (stdout or "").strip()
|
|
560
|
+
err = (stderr or "").strip()
|
|
561
|
+
parsed = parse_opencode_json_events(out if out else err)
|
|
562
|
+
tokens = (parsed.get("agent_usage") or {}).get("total_tokens") or 0
|
|
563
|
+
if tokens:
|
|
564
|
+
_log_line(log_file, f"totalTokenCount = {tokens}")
|
|
565
|
+
_log_memory(log_file, mem)
|
|
566
|
+
|
|
567
|
+
duration_ms = parsed.get("agent_duration_ms") or int((time.time() - t0) * 1000)
|
|
568
|
+
result = {
|
|
569
|
+
**parsed,
|
|
570
|
+
"agent_duration_ms": duration_ms,
|
|
571
|
+
"agent_backend": backend,
|
|
572
|
+
"agent_host": HOST_DEVECO,
|
|
573
|
+
"ab_arm": "with-homegraph" if arm == "with" else "without-homegraph",
|
|
574
|
+
"agent_memory_mb": mem,
|
|
575
|
+
}
|
|
576
|
+
if result.get("agent_status") != "success" and not result.get("agent_error"):
|
|
577
|
+
result["agent_error"] = _extract_deveco_json_errors(combined) or "deveco 未返回可解析的文本回答"
|
|
578
|
+
return result
|
|
579
|
+
|
|
580
|
+
|
|
581
|
+
def run_external_dataset(
|
|
582
|
+
host: str,
|
|
583
|
+
repo: Path,
|
|
584
|
+
dataset: list[dict[str, Any]],
|
|
585
|
+
*,
|
|
586
|
+
arm: str,
|
|
587
|
+
output: Path,
|
|
588
|
+
log_file: Path | None,
|
|
589
|
+
hg_bin: str,
|
|
590
|
+
model: str | None = None,
|
|
591
|
+
) -> list[dict[str, Any]]:
|
|
592
|
+
if host not in SUPPORTED_HOSTS:
|
|
593
|
+
raise ValueError(f"unknown agent host: {host}")
|
|
594
|
+
|
|
595
|
+
from agent_runner import find_homegraph_bin, print_agent_progress, require_index, _arm_short
|
|
596
|
+
|
|
597
|
+
if arm == "with":
|
|
598
|
+
require_index(repo)
|
|
599
|
+
hg = find_homegraph_bin(hg_bin) if arm == "with" else ""
|
|
600
|
+
|
|
601
|
+
output.parent.mkdir(parents=True, exist_ok=True)
|
|
602
|
+
if log_file:
|
|
603
|
+
log_file.write_text("", encoding="utf-8")
|
|
604
|
+
|
|
605
|
+
results: list[dict[str, Any]] = []
|
|
606
|
+
total = len(dataset)
|
|
607
|
+
print(f" → [{host}] {_arm_short(arm)} 臂:共 {total} 题", flush=True)
|
|
608
|
+
|
|
609
|
+
auth_abort: str | None = None
|
|
610
|
+
with output.open("w", encoding="utf-8") as f:
|
|
611
|
+
for i, item in enumerate(dataset, 1):
|
|
612
|
+
if auth_abort:
|
|
613
|
+
meta = {
|
|
614
|
+
"output_answer": "",
|
|
615
|
+
"agent_status": "error",
|
|
616
|
+
"agent_error": auth_abort,
|
|
617
|
+
"agent_backend": f"{host}-{arm}",
|
|
618
|
+
"agent_host": host,
|
|
619
|
+
}
|
|
620
|
+
print_agent_progress(arm, i, total, str(item.get("id") or i), f"跳过: {auth_abort[:80]}")
|
|
621
|
+
row = {**item, **meta}
|
|
622
|
+
results.append(row)
|
|
623
|
+
f.write(json.dumps(row, ensure_ascii=False) + "\n")
|
|
624
|
+
f.flush()
|
|
625
|
+
continue
|
|
626
|
+
q = str(item["query"])
|
|
627
|
+
item_id = str(item.get("id") or i)
|
|
628
|
+
print_agent_progress(arm, i, total, item_id, f"[{host}] 开始…")
|
|
629
|
+
logger.info("[%s/%s] %s/%s %s", host, arm, i, total, item_id)
|
|
630
|
+
try:
|
|
631
|
+
common = dict(
|
|
632
|
+
arm=arm,
|
|
633
|
+
hg_bin=hg,
|
|
634
|
+
log_file=log_file,
|
|
635
|
+
task_id=i,
|
|
636
|
+
)
|
|
637
|
+
if host == HOST_CLAUDE:
|
|
638
|
+
meta = run_claude_query(repo, q, **common)
|
|
639
|
+
else:
|
|
640
|
+
meta = run_deveco_query(repo, q, model=model, **common)
|
|
641
|
+
except Exception as e:
|
|
642
|
+
logger.error("External agent failed %s: %s", item.get("id"), e)
|
|
643
|
+
meta = {
|
|
644
|
+
"output_answer": "",
|
|
645
|
+
"agent_status": "error",
|
|
646
|
+
"agent_error": str(e),
|
|
647
|
+
"agent_backend": f"{host}-{arm}",
|
|
648
|
+
"agent_host": host,
|
|
649
|
+
}
|
|
650
|
+
row = {**item, **meta}
|
|
651
|
+
results.append(row)
|
|
652
|
+
f.write(json.dumps(row, ensure_ascii=False) + "\n")
|
|
653
|
+
f.flush()
|
|
654
|
+
if meta.get("agent_status") == "success":
|
|
655
|
+
dur_ms = meta.get("agent_duration_ms")
|
|
656
|
+
dur_s = f"{dur_ms / 1000:.1f}s" if isinstance(dur_ms, (int, float)) else "?"
|
|
657
|
+
print_agent_progress(arm, i, total, item_id, f"[{host}] 完成 ({dur_s})")
|
|
658
|
+
else:
|
|
659
|
+
err = str(meta.get("agent_error") or meta.get("agent_status") or "error")
|
|
660
|
+
print_agent_progress(arm, i, total, item_id, f"[{host}] 失败: {err[:100]}")
|
|
661
|
+
if i == 1 and meta.get("agent_error") and (
|
|
662
|
+
"未登录" in str(meta["agent_error"])
|
|
663
|
+
or "DevEco Code" in str(meta["agent_error"])
|
|
664
|
+
or "DevEco 模型" in str(meta["agent_error"])
|
|
665
|
+
or "Model not found" in str(meta["agent_error"])
|
|
666
|
+
):
|
|
667
|
+
auth_abort = str(meta["agent_error"])
|
|
668
|
+
print(f"\n ✗ {auth_abort} — 后续题目跳过", flush=True)
|
|
669
|
+
ok = sum(1 for r in results if r.get("agent_status") == "success")
|
|
670
|
+
print(f" → [{host}] {_arm_short(arm)} 臂结束:{ok}/{total} 成功", flush=True)
|
|
671
|
+
return results
|