homegraph 1.2.0 → 1.5.0
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/README.md +48 -11
- package/dist/bin/homegraph.js +298 -72
- package/dist/bin/homegraph.js.map +1 -1
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +117 -11
- package/dist/context/index.js.map +1 -1
- package/dist/db/index.d.ts +207 -6
- package/dist/db/index.d.ts.map +1 -1
- package/dist/db/index.js +461 -20
- package/dist/db/index.js.map +1 -1
- package/dist/db/migrations.d.ts +1 -1
- package/dist/db/migrations.d.ts.map +1 -1
- package/dist/db/migrations.js +19 -1
- package/dist/db/migrations.js.map +1 -1
- package/dist/db/queries.d.ts +157 -3
- package/dist/db/queries.d.ts.map +1 -1
- package/dist/db/queries.js +426 -9
- package/dist/db/queries.js.map +1 -1
- package/dist/db/schema.sql +32 -1
- package/dist/db/sqlite-adapter.d.ts +24 -17
- package/dist/db/sqlite-adapter.d.ts.map +1 -1
- package/dist/db/sqlite-adapter.js +292 -36
- package/dist/db/sqlite-adapter.js.map +1 -1
- package/dist/db/wal-valve.d.ts +119 -0
- package/dist/db/wal-valve.d.ts.map +1 -0
- package/dist/db/wal-valve.js +290 -0
- package/dist/db/wal-valve.js.map +1 -0
- package/dist/directory.d.ts +9 -5
- package/dist/directory.d.ts.map +1 -1
- package/dist/directory.js +210 -19
- package/dist/directory.js.map +1 -1
- package/dist/extraction/arkts-batch-worker.js +3 -2
- package/dist/extraction/arkts-batch-worker.js.map +1 -1
- package/dist/extraction/cfml-extractor.d.ts +107 -0
- package/dist/extraction/cfml-extractor.d.ts.map +1 -0
- package/dist/extraction/cfml-extractor.js +494 -0
- package/dist/extraction/cfml-extractor.js.map +1 -0
- package/dist/extraction/default-ignore.d.ts +39 -0
- package/dist/extraction/default-ignore.d.ts.map +1 -0
- package/dist/extraction/default-ignore.js +221 -0
- package/dist/extraction/default-ignore.js.map +1 -0
- package/dist/extraction/grammars.d.ts +25 -1
- package/dist/extraction/grammars.d.ts.map +1 -1
- package/dist/extraction/grammars.js +177 -24
- package/dist/extraction/grammars.js.map +1 -1
- package/dist/extraction/index.d.ts +52 -14
- package/dist/extraction/index.d.ts.map +1 -1
- package/dist/extraction/index.js +521 -314
- package/dist/extraction/index.js.map +1 -1
- package/dist/extraction/languages/arkts.d.ts +90 -6
- package/dist/extraction/languages/arkts.d.ts.map +1 -1
- package/dist/extraction/languages/arkts.js +1579 -128
- package/dist/extraction/languages/arkts.js.map +1 -1
- package/dist/extraction/languages/c-cpp.d.ts +42 -0
- package/dist/extraction/languages/c-cpp.d.ts.map +1 -1
- package/dist/extraction/languages/c-cpp.js +369 -4
- package/dist/extraction/languages/c-cpp.js.map +1 -1
- package/dist/extraction/languages/cfquery.d.ts +12 -0
- package/dist/extraction/languages/cfquery.d.ts.map +1 -0
- package/dist/extraction/languages/cfquery.js +28 -0
- package/dist/extraction/languages/cfquery.js.map +1 -0
- package/dist/extraction/languages/cfscript.d.ts +3 -0
- package/dist/extraction/languages/cfscript.d.ts.map +1 -0
- package/dist/extraction/languages/cfscript.js +73 -0
- package/dist/extraction/languages/cfscript.js.map +1 -0
- package/dist/extraction/languages/cobol.d.ts +33 -0
- package/dist/extraction/languages/cobol.d.ts.map +1 -0
- package/dist/extraction/languages/cobol.js +499 -0
- package/dist/extraction/languages/cobol.js.map +1 -0
- package/dist/extraction/languages/erlang.d.ts +3 -0
- package/dist/extraction/languages/erlang.d.ts.map +1 -0
- package/dist/extraction/languages/erlang.js +350 -0
- package/dist/extraction/languages/erlang.js.map +1 -0
- package/dist/extraction/languages/index.d.ts.map +1 -1
- package/dist/extraction/languages/index.js +16 -0
- package/dist/extraction/languages/index.js.map +1 -1
- package/dist/extraction/languages/nix.d.ts +3 -0
- package/dist/extraction/languages/nix.d.ts.map +1 -0
- package/dist/extraction/languages/nix.js +294 -0
- package/dist/extraction/languages/nix.js.map +1 -0
- package/dist/extraction/languages/solidity.d.ts +3 -0
- package/dist/extraction/languages/solidity.d.ts.map +1 -0
- package/dist/extraction/languages/solidity.js +293 -0
- package/dist/extraction/languages/solidity.js.map +1 -0
- package/dist/extraction/languages/terraform.d.ts +3 -0
- package/dist/extraction/languages/terraform.d.ts.map +1 -0
- package/dist/extraction/languages/terraform.js +641 -0
- package/dist/extraction/languages/terraform.js.map +1 -0
- package/dist/extraction/languages/vbnet.d.ts +11 -0
- package/dist/extraction/languages/vbnet.d.ts.map +1 -0
- package/dist/extraction/languages/vbnet.js +141 -0
- package/dist/extraction/languages/vbnet.js.map +1 -0
- package/dist/extraction/mybatis-extractor.d.ts +30 -10
- package/dist/extraction/mybatis-extractor.d.ts.map +1 -1
- package/dist/extraction/mybatis-extractor.js +140 -38
- package/dist/extraction/mybatis-extractor.js.map +1 -1
- package/dist/extraction/parse-pool.d.ts +27 -1
- package/dist/extraction/parse-pool.d.ts.map +1 -1
- package/dist/extraction/parse-pool.js +75 -7
- package/dist/extraction/parse-pool.js.map +1 -1
- package/dist/extraction/parse-worker.js +9 -2
- package/dist/extraction/parse-worker.js.map +1 -1
- package/dist/extraction/store-worker.d.ts +20 -0
- package/dist/extraction/store-worker.d.ts.map +1 -0
- package/dist/extraction/store-worker.js +102 -0
- package/dist/extraction/store-worker.js.map +1 -0
- package/dist/extraction/store-writer.d.ts +48 -0
- package/dist/extraction/store-writer.d.ts.map +1 -0
- package/dist/extraction/store-writer.js +167 -0
- package/dist/extraction/store-writer.js.map +1 -0
- package/dist/extraction/tree-sitter-helpers.d.ts.map +1 -1
- package/dist/extraction/tree-sitter-helpers.js +1 -0
- package/dist/extraction/tree-sitter-helpers.js.map +1 -1
- package/dist/extraction/tree-sitter-types.d.ts +3 -1
- package/dist/extraction/tree-sitter-types.d.ts.map +1 -1
- package/dist/extraction/tree-sitter.d.ts +38 -0
- package/dist/extraction/tree-sitter.d.ts.map +1 -1
- package/dist/extraction/tree-sitter.js +801 -10
- package/dist/extraction/tree-sitter.js.map +1 -1
- package/dist/extraction/wasm/tree-sitter-arkts.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-cfml.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-cfquery.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-cfscript.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-cobol.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-erlang.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-nix.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-terraform.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-vbnet.wasm +0 -0
- package/dist/extraction/wasm-runtime-flags.d.ts +14 -4
- package/dist/extraction/wasm-runtime-flags.d.ts.map +1 -1
- package/dist/extraction/wasm-runtime-flags.js +55 -7
- package/dist/extraction/wasm-runtime-flags.js.map +1 -1
- package/dist/graph/traversal.d.ts.map +1 -1
- package/dist/graph/traversal.js +1 -1
- package/dist/graph/traversal.js.map +1 -1
- package/dist/index.d.ts +74 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +436 -55
- package/dist/index.js.map +1 -1
- package/dist/installer/index.d.ts +42 -0
- package/dist/installer/index.d.ts.map +1 -1
- package/dist/installer/index.js +97 -2
- package/dist/installer/index.js.map +1 -1
- package/dist/mcp/daemon.d.ts +25 -3
- package/dist/mcp/daemon.d.ts.map +1 -1
- package/dist/mcp/daemon.js +62 -8
- package/dist/mcp/daemon.js.map +1 -1
- package/dist/mcp/dynamic-boundaries.d.ts.map +1 -1
- package/dist/mcp/dynamic-boundaries.js +2 -1
- package/dist/mcp/dynamic-boundaries.js.map +1 -1
- package/dist/mcp/early-ppid.d.ts +26 -0
- package/dist/mcp/early-ppid.d.ts.map +1 -0
- package/dist/mcp/early-ppid.js +29 -0
- package/dist/mcp/early-ppid.js.map +1 -0
- package/dist/mcp/engine.d.ts +4 -5
- package/dist/mcp/engine.d.ts.map +1 -1
- package/dist/mcp/engine.js +27 -1
- package/dist/mcp/engine.js.map +1 -1
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +41 -6
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/liveness-watchdog.d.ts +18 -1
- package/dist/mcp/liveness-watchdog.d.ts.map +1 -1
- package/dist/mcp/liveness-watchdog.js +73 -13
- package/dist/mcp/liveness-watchdog.js.map +1 -1
- package/dist/mcp/memory-budget.d.ts +30 -0
- package/dist/mcp/memory-budget.d.ts.map +1 -0
- package/dist/mcp/memory-budget.js +123 -0
- package/dist/mcp/memory-budget.js.map +1 -0
- package/dist/mcp/proxy.d.ts.map +1 -1
- package/dist/mcp/proxy.js +88 -4
- package/dist/mcp/proxy.js.map +1 -1
- package/dist/mcp/query-cache.d.ts +35 -4
- package/dist/mcp/query-cache.d.ts.map +1 -1
- package/dist/mcp/query-cache.js +89 -19
- package/dist/mcp/query-cache.js.map +1 -1
- package/dist/mcp/query-pool.d.ts +46 -12
- package/dist/mcp/query-pool.d.ts.map +1 -1
- package/dist/mcp/query-pool.js +100 -23
- package/dist/mcp/query-pool.js.map +1 -1
- package/dist/mcp/query-worker.d.ts +2 -2
- package/dist/mcp/query-worker.js +2 -2
- package/dist/mcp/server-instructions.d.ts +4 -27
- package/dist/mcp/server-instructions.d.ts.map +1 -1
- package/dist/mcp/server-instructions.js +39 -84
- package/dist/mcp/server-instructions.js.map +1 -1
- package/dist/mcp/session.d.ts +14 -0
- package/dist/mcp/session.d.ts.map +1 -1
- package/dist/mcp/session.js +28 -1
- package/dist/mcp/session.js.map +1 -1
- package/dist/mcp/startup-handshake.d.ts +44 -0
- package/dist/mcp/startup-handshake.d.ts.map +1 -0
- package/dist/mcp/startup-handshake.js +73 -0
- package/dist/mcp/startup-handshake.js.map +1 -0
- package/dist/mcp/tools.d.ts +104 -4
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +2432 -217
- package/dist/mcp/tools.js.map +1 -1
- package/dist/mcp/transport.d.ts.map +1 -1
- package/dist/mcp/transport.js +18 -0
- package/dist/mcp/transport.js.map +1 -1
- package/dist/project-config.d.ts +38 -0
- package/dist/project-config.d.ts.map +1 -1
- package/dist/project-config.js +101 -2
- package/dist/project-config.js.map +1 -1
- package/dist/resolution/c-fnptr-synthesizer.d.ts +2 -1
- package/dist/resolution/c-fnptr-synthesizer.d.ts.map +1 -1
- package/dist/resolution/c-fnptr-synthesizer.js +178 -146
- package/dist/resolution/c-fnptr-synthesizer.js.map +1 -1
- package/dist/resolution/callback-synthesizer.d.ts +54 -10
- package/dist/resolution/callback-synthesizer.d.ts.map +1 -1
- package/dist/resolution/callback-synthesizer.js +1299 -257
- package/dist/resolution/callback-synthesizer.js.map +1 -1
- package/dist/resolution/cooperative-yield.d.ts +10 -2
- package/dist/resolution/cooperative-yield.d.ts.map +1 -1
- package/dist/resolution/cooperative-yield.js +6 -4
- package/dist/resolution/cooperative-yield.js.map +1 -1
- package/dist/resolution/frameworks/cics.d.ts +20 -0
- package/dist/resolution/frameworks/cics.d.ts.map +1 -0
- package/dist/resolution/frameworks/cics.js +90 -0
- package/dist/resolution/frameworks/cics.js.map +1 -0
- package/dist/resolution/frameworks/go.d.ts.map +1 -1
- package/dist/resolution/frameworks/go.js +29 -6
- package/dist/resolution/frameworks/go.js.map +1 -1
- package/dist/resolution/frameworks/index.d.ts.map +1 -1
- package/dist/resolution/frameworks/index.js +3 -0
- package/dist/resolution/frameworks/index.js.map +1 -1
- package/dist/resolution/frameworks/java.d.ts.map +1 -1
- package/dist/resolution/frameworks/java.js +14 -6
- package/dist/resolution/frameworks/java.js.map +1 -1
- package/dist/resolution/frameworks/terraform.d.ts +38 -0
- package/dist/resolution/frameworks/terraform.d.ts.map +1 -0
- package/dist/resolution/frameworks/terraform.js +277 -0
- package/dist/resolution/frameworks/terraform.js.map +1 -0
- package/dist/resolution/goframe-synthesizer.d.ts +2 -1
- package/dist/resolution/goframe-synthesizer.d.ts.map +1 -1
- package/dist/resolution/goframe-synthesizer.js +8 -3
- package/dist/resolution/goframe-synthesizer.js.map +1 -1
- package/dist/resolution/import-resolver.d.ts +9 -3
- package/dist/resolution/import-resolver.d.ts.map +1 -1
- package/dist/resolution/import-resolver.js +295 -11
- package/dist/resolution/import-resolver.js.map +1 -1
- package/dist/resolution/index.d.ts +146 -8
- package/dist/resolution/index.d.ts.map +1 -1
- package/dist/resolution/index.js +1089 -131
- package/dist/resolution/index.js.map +1 -1
- package/dist/resolution/memory-budget.d.ts +48 -0
- package/dist/resolution/memory-budget.d.ts.map +1 -0
- package/dist/resolution/memory-budget.js +162 -0
- package/dist/resolution/memory-budget.js.map +1 -0
- package/dist/resolution/name-matcher.d.ts +12 -4
- package/dist/resolution/name-matcher.d.ts.map +1 -1
- package/dist/resolution/name-matcher.js +793 -130
- package/dist/resolution/name-matcher.js.map +1 -1
- package/dist/resolution/resolver-pool.d.ts +106 -0
- package/dist/resolution/resolver-pool.d.ts.map +1 -0
- package/dist/resolution/resolver-pool.js +344 -0
- package/dist/resolution/resolver-pool.js.map +1 -0
- package/dist/resolution/resolver-worker.d.ts +17 -0
- package/dist/resolution/resolver-worker.d.ts.map +1 -0
- package/dist/resolution/resolver-worker.js +141 -0
- package/dist/resolution/resolver-worker.js.map +1 -0
- package/dist/resolution/strip-comments.d.ts +1 -1
- package/dist/resolution/strip-comments.d.ts.map +1 -1
- package/dist/resolution/strip-comments.js +49 -0
- package/dist/resolution/strip-comments.js.map +1 -1
- package/dist/resolution/types.d.ts +32 -0
- package/dist/resolution/types.d.ts.map +1 -1
- package/dist/resolution/workspace-packages.d.ts +10 -0
- package/dist/resolution/workspace-packages.d.ts.map +1 -1
- package/dist/resolution/workspace-packages.js +142 -4
- package/dist/resolution/workspace-packages.js.map +1 -1
- package/dist/search/identifier-segments.d.ts +60 -0
- package/dist/search/identifier-segments.d.ts.map +1 -0
- package/dist/search/identifier-segments.js +176 -0
- package/dist/search/identifier-segments.js.map +1 -0
- package/dist/search/query-utils.d.ts +201 -0
- package/dist/search/query-utils.d.ts.map +1 -1
- package/dist/search/query-utils.js +919 -2
- package/dist/search/query-utils.js.map +1 -1
- package/dist/spec/build/diff-parser.d.ts +55 -0
- package/dist/spec/build/diff-parser.d.ts.map +1 -0
- package/dist/spec/build/diff-parser.js +205 -0
- package/dist/spec/build/diff-parser.js.map +1 -0
- package/dist/spec/build/git-scanner.d.ts +93 -0
- package/dist/spec/build/git-scanner.d.ts.map +1 -0
- package/dist/spec/build/git-scanner.js +254 -0
- package/dist/spec/build/git-scanner.js.map +1 -0
- package/dist/spec/build/pipeline.d.ts +54 -0
- package/dist/spec/build/pipeline.d.ts.map +1 -0
- package/dist/spec/build/pipeline.js +170 -0
- package/dist/spec/build/pipeline.js.map +1 -0
- package/dist/spec/build/scan.d.ts +48 -0
- package/dist/spec/build/scan.d.ts.map +1 -0
- package/dist/spec/build/scan.js +89 -0
- package/dist/spec/build/scan.js.map +1 -0
- package/dist/spec/build/scope-resolver.d.ts +50 -0
- package/dist/spec/build/scope-resolver.d.ts.map +1 -0
- package/dist/spec/build/scope-resolver.js +105 -0
- package/dist/spec/build/scope-resolver.js.map +1 -0
- package/dist/spec/build/spec-extractor.d.ts +74 -0
- package/dist/spec/build/spec-extractor.d.ts.map +1 -0
- package/dist/spec/build/spec-extractor.js +344 -0
- package/dist/spec/build/spec-extractor.js.map +1 -0
- package/dist/spec/config.d.ts +35 -1
- package/dist/spec/config.d.ts.map +1 -1
- package/dist/spec/config.js +30 -5
- package/dist/spec/config.js.map +1 -1
- package/dist/spec/db/fts.d.ts.map +1 -1
- package/dist/spec/db/fts.js +19 -50
- package/dist/spec/db/fts.js.map +1 -1
- package/dist/spec/db/index.d.ts +5 -3
- package/dist/spec/db/index.d.ts.map +1 -1
- package/dist/spec/db/index.js +16 -1
- package/dist/spec/db/index.js.map +1 -1
- package/dist/spec/db/persist.d.ts +45 -0
- package/dist/spec/db/persist.d.ts.map +1 -0
- package/dist/spec/db/persist.js +66 -0
- package/dist/spec/db/persist.js.map +1 -0
- package/dist/spec/db/relations.d.ts +80 -1
- package/dist/spec/db/relations.d.ts.map +1 -1
- package/dist/spec/db/relations.js +175 -4
- package/dist/spec/db/relations.js.map +1 -1
- package/dist/spec/db/schema.d.ts +4 -0
- package/dist/spec/db/schema.d.ts.map +1 -1
- package/dist/spec/db/schema.js +4 -0
- package/dist/spec/db/schema.js.map +1 -1
- package/dist/spec/db/schema.sql +5 -1
- package/dist/spec/db/spec-node.d.ts +5 -0
- package/dist/spec/db/spec-node.d.ts.map +1 -1
- package/dist/spec/db/spec-node.js +11 -5
- package/dist/spec/db/spec-node.js.map +1 -1
- package/dist/spec/db/sql-utils.d.ts +11 -0
- package/dist/spec/db/sql-utils.d.ts.map +1 -0
- package/dist/spec/db/sql-utils.js +19 -0
- package/dist/spec/db/sql-utils.js.map +1 -0
- package/dist/spec/evolve/cluster-context.d.ts +30 -0
- package/dist/spec/evolve/cluster-context.d.ts.map +1 -0
- package/dist/spec/evolve/cluster-context.js +78 -0
- package/dist/spec/evolve/cluster-context.js.map +1 -0
- package/dist/spec/evolve/commit-spec-analyzer.d.ts +51 -0
- package/dist/spec/evolve/commit-spec-analyzer.d.ts.map +1 -0
- package/dist/spec/evolve/commit-spec-analyzer.js +88 -0
- package/dist/spec/evolve/commit-spec-analyzer.js.map +1 -0
- package/dist/spec/evolve/commit-spec-persister.d.ts +53 -0
- package/dist/spec/evolve/commit-spec-persister.d.ts.map +1 -0
- package/dist/spec/evolve/commit-spec-persister.js +93 -0
- package/dist/spec/evolve/commit-spec-persister.js.map +1 -0
- package/dist/spec/evolve/impact-locator.d.ts +23 -7
- package/dist/spec/evolve/impact-locator.d.ts.map +1 -1
- package/dist/spec/evolve/impact-locator.js +58 -14
- package/dist/spec/evolve/impact-locator.js.map +1 -1
- package/dist/spec/evolve/pipeline.d.ts +62 -25
- package/dist/spec/evolve/pipeline.d.ts.map +1 -1
- package/dist/spec/evolve/pipeline.js +436 -457
- package/dist/spec/evolve/pipeline.js.map +1 -1
- package/dist/spec/evolve/spec-rewriter.d.ts +13 -13
- package/dist/spec/evolve/spec-rewriter.d.ts.map +1 -1
- package/dist/spec/evolve/spec-rewriter.js +45 -45
- package/dist/spec/evolve/spec-rewriter.js.map +1 -1
- package/dist/spec/git/commits.d.ts +85 -0
- package/dist/spec/git/commits.d.ts.map +1 -0
- package/dist/spec/git/commits.js +218 -0
- package/dist/spec/git/commits.js.map +1 -0
- package/dist/spec/git/exec.d.ts +13 -0
- package/dist/spec/git/exec.d.ts.map +1 -0
- package/dist/spec/git/exec.js +19 -0
- package/dist/spec/git/exec.js.map +1 -0
- package/dist/spec/git/index.d.ts +9 -0
- package/dist/spec/git/index.d.ts.map +1 -0
- package/dist/spec/git/index.js +22 -0
- package/dist/spec/git/index.js.map +1 -0
- package/dist/spec/git-utils.d.ts +8 -0
- package/dist/spec/git-utils.d.ts.map +1 -0
- package/dist/spec/git-utils.js +14 -0
- package/dist/spec/git-utils.js.map +1 -0
- package/dist/spec/graph/index.d.ts +8 -0
- package/dist/spec/graph/index.d.ts.map +1 -0
- package/dist/spec/graph/index.js +17 -0
- package/dist/spec/graph/index.js.map +1 -0
- package/dist/spec/graph/queries.d.ts +6 -35
- package/dist/spec/graph/queries.d.ts.map +1 -1
- package/dist/spec/graph/queries.js +71 -248
- package/dist/spec/graph/queries.js.map +1 -1
- package/dist/spec/llm/agent-client.d.ts +59 -0
- package/dist/spec/llm/agent-client.d.ts.map +1 -0
- package/dist/spec/llm/agent-client.js +213 -0
- package/dist/spec/llm/agent-client.js.map +1 -0
- package/dist/spec/llm/agents/claude-code.d.ts +32 -0
- package/dist/spec/llm/agents/claude-code.d.ts.map +1 -0
- package/dist/spec/llm/agents/claude-code.js +125 -0
- package/dist/spec/llm/agents/claude-code.js.map +1 -0
- package/dist/spec/llm/agents/codex.d.ts +32 -0
- package/dist/spec/llm/agents/codex.d.ts.map +1 -0
- package/dist/spec/llm/agents/codex.js +145 -0
- package/dist/spec/llm/agents/codex.js.map +1 -0
- package/dist/spec/llm/agents/detect-utils.d.ts +28 -0
- package/dist/spec/llm/agents/detect-utils.d.ts.map +1 -0
- package/dist/spec/llm/agents/detect-utils.js +91 -0
- package/dist/spec/llm/agents/detect-utils.js.map +1 -0
- package/dist/spec/llm/agents/deveco-code.d.ts +33 -0
- package/dist/spec/llm/agents/deveco-code.d.ts.map +1 -0
- package/dist/spec/llm/agents/deveco-code.js +165 -0
- package/dist/spec/llm/agents/deveco-code.js.map +1 -0
- package/dist/spec/llm/agents/index.d.ts +31 -0
- package/dist/spec/llm/agents/index.d.ts.map +1 -0
- package/dist/spec/llm/agents/index.js +65 -0
- package/dist/spec/llm/agents/index.js.map +1 -0
- package/dist/spec/llm/agents/types.d.ts +76 -0
- package/dist/spec/llm/agents/types.d.ts.map +1 -0
- package/dist/spec/llm/agents/types.js +15 -0
- package/dist/spec/llm/agents/types.js.map +1 -0
- package/dist/spec/llm/client.d.ts +31 -11
- package/dist/spec/llm/client.d.ts.map +1 -1
- package/dist/spec/llm/client.js +143 -81
- package/dist/spec/llm/client.js.map +1 -1
- package/dist/spec/llm/factory.d.ts +41 -0
- package/dist/spec/llm/factory.d.ts.map +1 -0
- package/dist/spec/llm/factory.js +80 -0
- package/dist/spec/llm/factory.js.map +1 -0
- package/dist/spec/llm/prompts.d.ts +24 -8
- package/dist/spec/llm/prompts.d.ts.map +1 -1
- package/dist/spec/llm/prompts.js +100 -50
- package/dist/spec/llm/prompts.js.map +1 -1
- package/dist/spec/llm/retry.d.ts +53 -0
- package/dist/spec/llm/retry.d.ts.map +1 -0
- package/dist/spec/llm/retry.js +153 -0
- package/dist/spec/llm/retry.js.map +1 -0
- package/dist/spec/mine/clusterer.d.ts +63 -0
- package/dist/spec/mine/clusterer.d.ts.map +1 -0
- package/dist/spec/mine/clusterer.js +904 -0
- package/dist/spec/mine/clusterer.js.map +1 -0
- package/dist/spec/mine/clustering/features.d.ts +38 -0
- package/dist/spec/mine/clustering/features.d.ts.map +1 -0
- package/dist/spec/mine/clustering/features.js +108 -0
- package/dist/spec/mine/clustering/features.js.map +1 -0
- package/dist/spec/mine/clustering/index.d.ts +62 -0
- package/dist/spec/mine/clustering/index.d.ts.map +1 -0
- package/dist/spec/mine/clustering/index.js +259 -0
- package/dist/spec/mine/clustering/index.js.map +1 -0
- package/dist/spec/mine/clustering/leiden.d.ts +61 -0
- package/dist/spec/mine/clustering/leiden.d.ts.map +1 -0
- package/dist/spec/mine/clustering/leiden.js +489 -0
- package/dist/spec/mine/clustering/leiden.js.map +1 -0
- package/dist/spec/mine/clustering/text-similarity.d.ts +22 -0
- package/dist/spec/mine/clustering/text-similarity.d.ts.map +1 -0
- package/dist/spec/mine/clustering/text-similarity.js +98 -0
- package/dist/spec/mine/clustering/text-similarity.js.map +1 -0
- package/dist/spec/mine/generator.d.ts +54 -0
- package/dist/spec/mine/generator.d.ts.map +1 -0
- package/dist/spec/mine/generator.js +267 -0
- package/dist/spec/mine/generator.js.map +1 -0
- package/dist/spec/mine/persist.d.ts +37 -0
- package/dist/spec/mine/persist.d.ts.map +1 -0
- package/dist/spec/mine/persist.js +170 -0
- package/dist/spec/mine/persist.js.map +1 -0
- package/dist/spec/mine/pipeline.d.ts +41 -0
- package/dist/spec/mine/pipeline.d.ts.map +1 -0
- package/dist/spec/mine/pipeline.js +236 -0
- package/dist/spec/mine/pipeline.js.map +1 -0
- package/dist/spec/mine/progress-handler.d.ts +22 -0
- package/dist/spec/mine/progress-handler.d.ts.map +1 -0
- package/dist/spec/mine/progress-handler.js +108 -0
- package/dist/spec/mine/progress-handler.js.map +1 -0
- package/dist/spec/mine/progress.d.ts +23 -0
- package/dist/spec/mine/progress.d.ts.map +1 -0
- package/dist/spec/mine/progress.js +12 -0
- package/dist/spec/mine/progress.js.map +1 -0
- package/dist/spec/mine/scanner.d.ts +59 -0
- package/dist/spec/mine/scanner.d.ts.map +1 -0
- package/dist/spec/mine/scanner.js +383 -0
- package/dist/spec/mine/scanner.js.map +1 -0
- package/dist/spec/types.d.ts +32 -0
- package/dist/spec/types.d.ts.map +1 -1
- package/dist/spec/ui/index.d.ts +9 -0
- package/dist/spec/ui/index.d.ts.map +1 -0
- package/dist/spec/ui/index.js +16 -0
- package/dist/spec/ui/index.js.map +1 -0
- package/dist/spec/ui/progress-handler.d.ts +33 -0
- package/dist/spec/ui/progress-handler.d.ts.map +1 -0
- package/dist/spec/ui/progress-handler.js +132 -0
- package/dist/spec/ui/progress-handler.js.map +1 -0
- package/dist/spec/ui/progress.d.ts +24 -0
- package/dist/spec/ui/progress.d.ts.map +1 -0
- package/dist/spec/ui/progress.js +13 -0
- package/dist/spec/ui/progress.js.map +1 -0
- package/dist/spec/utils/fs.d.ts +45 -0
- package/dist/spec/utils/fs.d.ts.map +1 -0
- package/dist/spec/utils/fs.js +163 -0
- package/dist/spec/utils/fs.js.map +1 -0
- package/dist/spec/utils/index.d.ts +12 -0
- package/dist/spec/utils/index.d.ts.map +1 -0
- package/dist/spec/utils/index.js +26 -0
- package/dist/spec/utils/index.js.map +1 -0
- package/dist/spec/utils/meta.d.ts +32 -0
- package/dist/spec/utils/meta.d.ts.map +1 -0
- package/dist/spec/utils/meta.js +122 -0
- package/dist/spec/utils/meta.js.map +1 -0
- package/dist/spec/utils/truncate.d.ts +86 -0
- package/dist/spec/utils/truncate.d.ts.map +1 -0
- package/dist/spec/utils/truncate.js +172 -0
- package/dist/spec/utils/truncate.js.map +1 -0
- package/dist/spec/utils.d.ts +4 -16
- package/dist/spec/utils.d.ts.map +1 -1
- package/dist/spec/utils.js +6 -58
- package/dist/spec/utils.js.map +1 -1
- package/dist/sync/git-hooks.d.ts.map +1 -1
- package/dist/sync/git-hooks.js +2 -0
- package/dist/sync/git-hooks.js.map +1 -1
- package/dist/sync/watcher.d.ts +35 -6
- package/dist/sync/watcher.d.ts.map +1 -1
- package/dist/sync/watcher.js +127 -17
- package/dist/sync/watcher.js.map +1 -1
- package/dist/sync/worktree.d.ts.map +1 -1
- package/dist/sync/worktree.js +5 -0
- package/dist/sync/worktree.js.map +1 -1
- package/dist/telemetry/index.js +3 -3
- package/dist/telemetry/index.js.map +1 -1
- package/dist/types.d.ts +22 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +10 -0
- package/dist/types.js.map +1 -1
- package/dist/upgrade/index.d.ts +32 -0
- package/dist/upgrade/index.d.ts.map +1 -1
- package/dist/upgrade/index.js +162 -14
- package/dist/upgrade/index.js.map +1 -1
- package/dist/upgrade/remove-binary.d.ts +87 -0
- package/dist/upgrade/remove-binary.d.ts.map +1 -0
- package/dist/upgrade/remove-binary.js +289 -0
- package/dist/upgrade/remove-binary.js.map +1 -0
- package/dist/upgrade/update-check.d.ts +92 -0
- package/dist/upgrade/update-check.d.ts.map +1 -0
- package/dist/upgrade/update-check.js +258 -0
- package/dist/upgrade/update-check.js.map +1 -0
- package/package.json +6 -2
- package/scripts/agent-eval/run-all.sh +6 -0
- package/scripts/build-bundle.sh +5 -0
- package/scripts/npm-shim.js +8 -1
- package/scripts/exp_boundary_eval/__pycache__/_utils.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/analyze.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/deveco_arm.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/run_one.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/run_session.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/__pycache__/setup.cpython-310.pyc +0 -0
- package/scripts/exp_boundary_eval/data/agents.json +0 -109
- package/scripts/exp_boundary_eval/data/experiments.json +0 -140
- package/scripts/qa_eval/README.md +0 -407
- package/scripts/qa_eval/_test_deveco_probe.py +0 -41
- package/scripts/qa_eval/agent_runner.py +0 -526
- package/scripts/qa_eval/data/.gitignore +0 -4
- package/scripts/qa_eval/data/test-set.jsonl +0 -2
- package/scripts/qa_eval/eval_metrics.py +0 -274
- package/scripts/qa_eval/external_agent.py +0 -976
- package/scripts/qa_eval/llm_config.py +0 -92
- package/scripts/qa_eval/memory_monitor.py +0 -132
- package/scripts/qa_eval/my_answer_accuracy.py +0 -187
- package/scripts/qa_eval/requirements.txt +0 -2
- package/scripts/qa_eval/run_pipeline.py +0 -804
- package/scripts/qa_eval/stats_efficiency.py +0 -279
- package/scripts/qa_eval/stats_scores.py +0 -207
|
@@ -1,526 +0,0 @@
|
|
|
1
|
-
"""Multi-turn QA agent: with homegraph tools vs without (grep/read only). DashScope Qwen."""
|
|
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 time
|
|
12
|
-
from datetime import datetime
|
|
13
|
-
from pathlib import Path
|
|
14
|
-
from typing import Any
|
|
15
|
-
|
|
16
|
-
try:
|
|
17
|
-
from openai import OpenAI
|
|
18
|
-
except ImportError:
|
|
19
|
-
OpenAI = None # type: ignore[misc, assignment]
|
|
20
|
-
|
|
21
|
-
from memory_monitor import sample_memory
|
|
22
|
-
|
|
23
|
-
logger = logging.getLogger(__name__)
|
|
24
|
-
|
|
25
|
-
TIME_FMT = "%Y-%m-%d %H:%M:%S.%f"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
def _arm_short(arm: str) -> str:
|
|
29
|
-
return "WITH" if arm == "with" else "WITHOUT"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
def print_agent_progress(
|
|
33
|
-
arm: str,
|
|
34
|
-
index: int,
|
|
35
|
-
total: int,
|
|
36
|
-
item_id: str,
|
|
37
|
-
message: str,
|
|
38
|
-
*,
|
|
39
|
-
indent: int = 0,
|
|
40
|
-
) -> None:
|
|
41
|
-
prefix = " " * indent
|
|
42
|
-
print(f"{prefix}[{_arm_short(arm)} {index}/{total}] {item_id} — {message}", flush=True)
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
def print_agent_turn(task_id: int, turn: int, max_turns: int, message: str = "请求 LLM…") -> None:
|
|
46
|
-
print(f" · 第 {turn}/{max_turns} 轮 {message}", flush=True)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
def _log_line(log_file: Path | None, msg: str) -> None:
|
|
50
|
-
if log_file is None:
|
|
51
|
-
return
|
|
52
|
-
log_file.parent.mkdir(parents=True, exist_ok=True)
|
|
53
|
-
with log_file.open("a", encoding="utf-8") as f:
|
|
54
|
-
f.write(f"{datetime.now().strftime(TIME_FMT)} {msg}\n")
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
def _log_memory(log_file: Path | None, mem: dict[str, float | None]) -> None:
|
|
58
|
-
if mem.get("peak_rss_mb") is not None:
|
|
59
|
-
_log_line(log_file, f"peakRssMb = {mem['peak_rss_mb']}")
|
|
60
|
-
if mem.get("avg_rss_mb") is not None:
|
|
61
|
-
_log_line(log_file, f"avgRssMb = {mem['avg_rss_mb']}")
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
def find_homegraph_bin(explicit: str | None = None) -> str:
|
|
65
|
-
if explicit:
|
|
66
|
-
p = Path(explicit)
|
|
67
|
-
if p.is_file() and os.access(p, os.X_OK):
|
|
68
|
-
return str(p.resolve())
|
|
69
|
-
raise FileNotFoundError(f"homegraph binary not found: {explicit}")
|
|
70
|
-
|
|
71
|
-
# Prefer local dev build when testing unreleased changes
|
|
72
|
-
repo_root = Path(__file__).resolve().parents[2]
|
|
73
|
-
for local in (
|
|
74
|
-
repo_root / "dist" / "bin" / "homegraph.js",
|
|
75
|
-
repo_root / "dist" / "bin" / "homegraph.js",
|
|
76
|
-
):
|
|
77
|
-
if local.is_file():
|
|
78
|
-
return f"node {local.resolve()}"
|
|
79
|
-
|
|
80
|
-
for name in ("homegraph", "homegraph"):
|
|
81
|
-
found = shutil.which(name)
|
|
82
|
-
if found:
|
|
83
|
-
return found
|
|
84
|
-
raise FileNotFoundError(
|
|
85
|
-
"homegraph/homegraph not on PATH.\n"
|
|
86
|
-
" 在 homegraph 仓库里: npm run build\n"
|
|
87
|
-
" 或: python scripts/qa_eval/run_pipeline.py ab --homegraph-bin 'node /path/to/dist/bin/homegraph.js'"
|
|
88
|
-
)
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
def _hg_cmd(hg_bin: str, args: list[str]) -> list[str]:
|
|
92
|
-
if hg_bin.startswith("node "):
|
|
93
|
-
return hg_bin.split(" ", 1) + args
|
|
94
|
-
return [hg_bin, *args]
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
def require_index(repo: Path) -> None:
|
|
98
|
-
for name in (".homegraph", ".homegraph"):
|
|
99
|
-
d = repo / name
|
|
100
|
-
if (d / "homegraph.db").exists() or (d / "homegraph.db").exists():
|
|
101
|
-
return
|
|
102
|
-
raise RuntimeError(f"仓库未索引: {repo}\n请先运行: homegraph sync {repo}")
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
def tool_block(name: str, body: str) -> str:
|
|
106
|
-
return f"---\n{name}\n{body.strip()}\n---"
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
def homegraph_query(repo: Path, query: str, *, hg_bin: str, limit: int = 8) -> str:
|
|
110
|
-
proc = subprocess.run(
|
|
111
|
-
_hg_cmd(hg_bin, ["query", query, "-p", str(repo.resolve()), "-l", str(limit), "-j"]),
|
|
112
|
-
capture_output=True,
|
|
113
|
-
text=True,
|
|
114
|
-
timeout=120,
|
|
115
|
-
)
|
|
116
|
-
if proc.returncode != 0:
|
|
117
|
-
return f"(homegraph query failed: {(proc.stderr or proc.stdout)[-400:]})"
|
|
118
|
-
try:
|
|
119
|
-
hits = json.loads(proc.stdout)
|
|
120
|
-
except json.JSONDecodeError:
|
|
121
|
-
return proc.stdout[:4000]
|
|
122
|
-
lines: list[str] = []
|
|
123
|
-
for i, hit in enumerate(hits[:limit], 1):
|
|
124
|
-
node = hit.get("node") or {}
|
|
125
|
-
lines.append(
|
|
126
|
-
f"{i}. [{node.get('kind')}] {node.get('qualifiedName', node.get('name'))}\n"
|
|
127
|
-
f" file: {node.get('filePath')}:{node.get('startLine')}-{node.get('endLine')}\n"
|
|
128
|
-
f" sig: {node.get('signature', '')}"
|
|
129
|
-
)
|
|
130
|
-
return "\n".join(lines) if lines else "(no hits)"
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
def read_file(repo: Path, rel_path: str, start: int = 1, end: int | None = None, context: int = 0) -> str:
|
|
134
|
-
path = (repo / rel_path).resolve()
|
|
135
|
-
if not path.is_file() or not str(path).startswith(str(repo.resolve())):
|
|
136
|
-
return f"(file not found: {rel_path})"
|
|
137
|
-
lines = path.read_text(encoding="utf-8", errors="replace").splitlines()
|
|
138
|
-
if end is None:
|
|
139
|
-
end = min(len(lines), start + 80)
|
|
140
|
-
lo = max(1, start - context) - 1
|
|
141
|
-
hi = min(len(lines), end + context)
|
|
142
|
-
body = "\n".join(f"{i + 1:4}| {lines[i]}" for i in range(lo, hi))
|
|
143
|
-
return f"// {rel_path}:{start}-{end}\n{body}"
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
def find_rg_binary() -> str | None:
|
|
147
|
-
found = shutil.which("rg")
|
|
148
|
-
if found:
|
|
149
|
-
return found
|
|
150
|
-
candidates = [
|
|
151
|
-
Path.home() / ".cursor-server/bin/*/node_modules/@vscode/ripgrep/bin/rg",
|
|
152
|
-
]
|
|
153
|
-
import glob
|
|
154
|
-
|
|
155
|
-
for pattern in candidates:
|
|
156
|
-
for path in glob.glob(str(pattern)):
|
|
157
|
-
if os.path.isfile(path) and os.access(path, os.X_OK):
|
|
158
|
-
return path
|
|
159
|
-
return None
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
def search_text(repo: Path, pattern: str, max_hits: int = 20) -> str:
|
|
163
|
-
rg = find_rg_binary()
|
|
164
|
-
if not rg:
|
|
165
|
-
return "(rg not found on PATH; install: sudo apt install ripgrep)"
|
|
166
|
-
proc = subprocess.run(
|
|
167
|
-
[rg, "-n", "--no-heading", "-m", str(max_hits), pattern, str(repo)],
|
|
168
|
-
capture_output=True,
|
|
169
|
-
text=True,
|
|
170
|
-
timeout=60,
|
|
171
|
-
)
|
|
172
|
-
out = (proc.stdout or proc.stderr or "").strip()
|
|
173
|
-
return out[:6000] if out else "(no matches)"
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
def find_files(repo: Path, pattern: str, max_hits: int = 30) -> str:
|
|
177
|
-
"""Find files by glob. Invalid patterns return a hint instead of crashing the agent."""
|
|
178
|
-
pattern = pattern.strip().lstrip("/")
|
|
179
|
-
if not pattern:
|
|
180
|
-
return "(empty pattern)"
|
|
181
|
-
|
|
182
|
-
hits: list[str] = []
|
|
183
|
-
try:
|
|
184
|
-
# pathlib rglob: ** must be a whole path segment (e.g. **/*.ets, not */**/x)
|
|
185
|
-
if "**" in pattern and not pattern.startswith("**"):
|
|
186
|
-
# Fallback: treat as substring search via rg --files | rg
|
|
187
|
-
rg = shutil.which("rg")
|
|
188
|
-
if rg:
|
|
189
|
-
proc = subprocess.run(
|
|
190
|
-
[rg, "--files", str(repo)],
|
|
191
|
-
capture_output=True,
|
|
192
|
-
text=True,
|
|
193
|
-
timeout=60,
|
|
194
|
-
)
|
|
195
|
-
needle = pattern.replace("**", "").replace("*", "")
|
|
196
|
-
for line in (proc.stdout or "").splitlines():
|
|
197
|
-
if needle and needle.lower() in line.lower():
|
|
198
|
-
hits.append(line)
|
|
199
|
-
if len(hits) >= max_hits:
|
|
200
|
-
break
|
|
201
|
-
return "\n".join(hits) if hits else "(no files; try SearchText instead)"
|
|
202
|
-
return "(invalid glob: use pattern like **/*.ets or use SearchText)"
|
|
203
|
-
|
|
204
|
-
for p in sorted(repo.rglob(pattern)):
|
|
205
|
-
if p.is_file() and ".git" not in p.parts:
|
|
206
|
-
hits.append(str(p.relative_to(repo)))
|
|
207
|
-
if len(hits) >= max_hits:
|
|
208
|
-
break
|
|
209
|
-
except ValueError as e:
|
|
210
|
-
return f"(invalid glob pattern '{pattern}': {e}. Try **/*.ets or SearchText)"
|
|
211
|
-
except OSError as e:
|
|
212
|
-
return f"(find failed: {e})"
|
|
213
|
-
|
|
214
|
-
return "\n".join(hits) if hits else "(no files)"
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
WITH_TOOLS = [
|
|
218
|
-
{
|
|
219
|
-
"type": "function",
|
|
220
|
-
"function": {
|
|
221
|
-
"name": "HomegraphQuery",
|
|
222
|
-
"description": "Search symbols in the repo via homegraph index (preferred for finding functions/classes/files).",
|
|
223
|
-
"parameters": {
|
|
224
|
-
"type": "object",
|
|
225
|
-
"properties": {
|
|
226
|
-
"query": {"type": "string", "description": "Symbol name or search terms"},
|
|
227
|
-
"limit": {"type": "integer", "description": "Max hits", "default": 8},
|
|
228
|
-
},
|
|
229
|
-
"required": ["query"],
|
|
230
|
-
},
|
|
231
|
-
},
|
|
232
|
-
},
|
|
233
|
-
{
|
|
234
|
-
"type": "function",
|
|
235
|
-
"function": {
|
|
236
|
-
"name": "ReadFile",
|
|
237
|
-
"description": "Read source file lines from the repo.",
|
|
238
|
-
"parameters": {
|
|
239
|
-
"type": "object",
|
|
240
|
-
"properties": {
|
|
241
|
-
"path": {"type": "string"},
|
|
242
|
-
"start_line": {"type": "integer", "default": 1},
|
|
243
|
-
"end_line": {"type": "integer"},
|
|
244
|
-
},
|
|
245
|
-
"required": ["path"],
|
|
246
|
-
},
|
|
247
|
-
},
|
|
248
|
-
},
|
|
249
|
-
]
|
|
250
|
-
|
|
251
|
-
WITHOUT_TOOLS = [
|
|
252
|
-
{
|
|
253
|
-
"type": "function",
|
|
254
|
-
"function": {
|
|
255
|
-
"name": "SearchText",
|
|
256
|
-
"description": "Ripgrep search in the repo (like grep).",
|
|
257
|
-
"parameters": {
|
|
258
|
-
"type": "object",
|
|
259
|
-
"properties": {"pattern": {"type": "string"}},
|
|
260
|
-
"required": ["pattern"],
|
|
261
|
-
},
|
|
262
|
-
},
|
|
263
|
-
},
|
|
264
|
-
{
|
|
265
|
-
"type": "function",
|
|
266
|
-
"function": {
|
|
267
|
-
"name": "ReadFile",
|
|
268
|
-
"description": "Read source file lines from the repo.",
|
|
269
|
-
"parameters": {
|
|
270
|
-
"type": "object",
|
|
271
|
-
"properties": {
|
|
272
|
-
"path": {"type": "string"},
|
|
273
|
-
"start_line": {"type": "integer", "default": 1},
|
|
274
|
-
"end_line": {"type": "integer"},
|
|
275
|
-
},
|
|
276
|
-
"required": ["path"],
|
|
277
|
-
},
|
|
278
|
-
},
|
|
279
|
-
},
|
|
280
|
-
{
|
|
281
|
-
"type": "function",
|
|
282
|
-
"function": {
|
|
283
|
-
"name": "FindFiles",
|
|
284
|
-
"description": "Glob find files under repo. Use patterns like *.ets or **/BenchmarkHub*.ets (not */**/x).",
|
|
285
|
-
"parameters": {
|
|
286
|
-
"type": "object",
|
|
287
|
-
"properties": {"pattern": {"type": "string"}},
|
|
288
|
-
"required": ["pattern"],
|
|
289
|
-
},
|
|
290
|
-
},
|
|
291
|
-
},
|
|
292
|
-
]
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
def execute_tool(
|
|
296
|
-
repo: Path,
|
|
297
|
-
name: str,
|
|
298
|
-
args: dict[str, Any],
|
|
299
|
-
*,
|
|
300
|
-
arm: str,
|
|
301
|
-
hg_bin: str,
|
|
302
|
-
) -> str:
|
|
303
|
-
if name == "HomegraphQuery":
|
|
304
|
-
if arm != "with":
|
|
305
|
-
return "(homegraph disabled in without arm)"
|
|
306
|
-
return homegraph_query(repo, args["query"], hg_bin=hg_bin, limit=int(args.get("limit") or 8))
|
|
307
|
-
if name == "ReadFile":
|
|
308
|
-
return read_file(
|
|
309
|
-
repo,
|
|
310
|
-
args["path"],
|
|
311
|
-
start=int(args.get("start_line") or 1),
|
|
312
|
-
end=int(args["end_line"]) if args.get("end_line") else None,
|
|
313
|
-
)
|
|
314
|
-
if name == "SearchText":
|
|
315
|
-
return search_text(repo, args["pattern"])
|
|
316
|
-
if name == "FindFiles":
|
|
317
|
-
return find_files(repo, args["pattern"])
|
|
318
|
-
return f"(unknown tool: {name})"
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
def run_agent_on_query(
|
|
322
|
-
repo: Path,
|
|
323
|
-
query: str,
|
|
324
|
-
*,
|
|
325
|
-
arm: str,
|
|
326
|
-
api_key: str,
|
|
327
|
-
base_url: str,
|
|
328
|
-
model: str,
|
|
329
|
-
hg_bin: str,
|
|
330
|
-
log_file: Path | None = None,
|
|
331
|
-
task_id: int = 1,
|
|
332
|
-
max_turns: int = 8,
|
|
333
|
-
timeout_sec: int = 600,
|
|
334
|
-
extra_body: dict | None = None,
|
|
335
|
-
) -> dict[str, Any]:
|
|
336
|
-
if OpenAI is None:
|
|
337
|
-
raise RuntimeError("pip install openai")
|
|
338
|
-
|
|
339
|
-
client = OpenAI(api_key=api_key, base_url=base_url, timeout=timeout_sec)
|
|
340
|
-
tools = WITH_TOOLS if arm == "with" else WITHOUT_TOOLS
|
|
341
|
-
backend = "agent-with-homegraph" if arm == "with" else "agent-grep-read"
|
|
342
|
-
|
|
343
|
-
if arm == "with":
|
|
344
|
-
system = (
|
|
345
|
-
"你是鸿蒙 ArkTS 代码分析 Agent。可用 HomegraphQuery 检索符号、ReadFile 读源码。"
|
|
346
|
-
"先检索再读文件,基于仓库事实作答。回答简洁准确,中文。"
|
|
347
|
-
)
|
|
348
|
-
else:
|
|
349
|
-
system = (
|
|
350
|
-
"你是鸿蒙 ArkTS 代码分析 Agent。可用 SearchText(rg)、FindFiles、ReadFile 探索仓库。"
|
|
351
|
-
"没有 homegraph,请主动搜索和读文件后再答。回答简洁准确,中文。"
|
|
352
|
-
)
|
|
353
|
-
|
|
354
|
-
messages: list[dict[str, Any]] = [
|
|
355
|
-
{"role": "system", "content": system},
|
|
356
|
-
{"role": "user", "content": query},
|
|
357
|
-
]
|
|
358
|
-
tool_trace: list[str] = []
|
|
359
|
-
total_tokens = 0
|
|
360
|
-
t0 = time.time()
|
|
361
|
-
_log_line(log_file, f"Evaluate {task_id}:")
|
|
362
|
-
|
|
363
|
-
with sample_memory() as mem_sampler:
|
|
364
|
-
for turn in range(1, max_turns + 1):
|
|
365
|
-
_log_line(log_file, f"the {turn} turn")
|
|
366
|
-
print_agent_turn(task_id, turn, max_turns)
|
|
367
|
-
create_kwargs: dict[str, Any] = {
|
|
368
|
-
"model": model,
|
|
369
|
-
"messages": messages,
|
|
370
|
-
"tools": tools,
|
|
371
|
-
"temperature": 0.2,
|
|
372
|
-
}
|
|
373
|
-
if extra_body:
|
|
374
|
-
create_kwargs["extra_body"] = extra_body
|
|
375
|
-
resp = client.chat.completions.create(**create_kwargs)
|
|
376
|
-
if turn == 1:
|
|
377
|
-
_log_line(log_file, "first token")
|
|
378
|
-
if resp.usage:
|
|
379
|
-
total_tokens += int(resp.usage.total_tokens or 0)
|
|
380
|
-
_log_line(log_file, f"totalTokenCount = {resp.usage.total_tokens}")
|
|
381
|
-
|
|
382
|
-
msg = resp.choices[0].message
|
|
383
|
-
if msg.tool_calls:
|
|
384
|
-
names = ", ".join(tc.function.name for tc in msg.tool_calls)
|
|
385
|
-
print_agent_turn(task_id, turn, max_turns, f"工具: {names}")
|
|
386
|
-
messages.append(msg.model_dump())
|
|
387
|
-
for tc in msg.tool_calls:
|
|
388
|
-
fn = tc.function
|
|
389
|
-
try:
|
|
390
|
-
fn_args = json.loads(fn.arguments or "{}")
|
|
391
|
-
except json.JSONDecodeError:
|
|
392
|
-
fn_args = {}
|
|
393
|
-
result = execute_tool(repo, fn.name, fn_args, arm=arm, hg_bin=hg_bin)
|
|
394
|
-
arg_str = json.dumps(fn_args, ensure_ascii=False)
|
|
395
|
-
tool_trace.append(tool_block(fn.name, f"args: {arg_str}\nresult:\n{result[:3000]}"))
|
|
396
|
-
messages.append(
|
|
397
|
-
{
|
|
398
|
-
"role": "tool",
|
|
399
|
-
"tool_call_id": tc.id,
|
|
400
|
-
"content": result[:8000],
|
|
401
|
-
}
|
|
402
|
-
)
|
|
403
|
-
continue
|
|
404
|
-
|
|
405
|
-
answer = (msg.content or "").strip()
|
|
406
|
-
duration_ms = int((time.time() - t0) * 1000)
|
|
407
|
-
trace_text = "\n\n".join(tool_trace)
|
|
408
|
-
output = f"{trace_text}\n\n{answer}" if trace_text else answer
|
|
409
|
-
usage = resp.usage
|
|
410
|
-
mem = mem_sampler.last_stats
|
|
411
|
-
_log_memory(log_file, mem)
|
|
412
|
-
meta: dict[str, Any] = {
|
|
413
|
-
"output_answer": output,
|
|
414
|
-
"agent_status": "success" if answer else "error",
|
|
415
|
-
"agent_backend": backend,
|
|
416
|
-
"agent_host": "builtin",
|
|
417
|
-
"agent_model": model,
|
|
418
|
-
"agent_turns": turn,
|
|
419
|
-
"agent_duration_ms": duration_ms,
|
|
420
|
-
"ab_arm": "with-homegraph" if arm == "with" else "without-homegraph",
|
|
421
|
-
"agent_memory_mb": mem,
|
|
422
|
-
}
|
|
423
|
-
if usage:
|
|
424
|
-
meta["agent_usage"] = {
|
|
425
|
-
"prompt_tokens": usage.prompt_tokens,
|
|
426
|
-
"completion_tokens": usage.completion_tokens,
|
|
427
|
-
"total_tokens": usage.total_tokens,
|
|
428
|
-
}
|
|
429
|
-
if not answer:
|
|
430
|
-
meta["agent_error"] = "empty final answer"
|
|
431
|
-
return meta
|
|
432
|
-
|
|
433
|
-
mem = mem_sampler.last_stats
|
|
434
|
-
_log_memory(log_file, mem)
|
|
435
|
-
return {
|
|
436
|
-
"output_answer": "\n\n".join(tool_trace),
|
|
437
|
-
"agent_status": "error",
|
|
438
|
-
"agent_error": f"max turns ({max_turns}) exceeded",
|
|
439
|
-
"agent_backend": backend,
|
|
440
|
-
"agent_host": "builtin",
|
|
441
|
-
"agent_model": model,
|
|
442
|
-
"ab_arm": "with-homegraph" if arm == "with" else "without-homegraph",
|
|
443
|
-
"agent_memory_mb": mem,
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
def run_agent_dataset(
|
|
448
|
-
repo: Path,
|
|
449
|
-
dataset: list[dict[str, Any]],
|
|
450
|
-
*,
|
|
451
|
-
arm: str,
|
|
452
|
-
output: Path,
|
|
453
|
-
log_file: Path | None,
|
|
454
|
-
api_key: str,
|
|
455
|
-
base_url: str,
|
|
456
|
-
model: str,
|
|
457
|
-
hg_bin: str,
|
|
458
|
-
max_turns: int = 8,
|
|
459
|
-
extra_body: dict | None = None,
|
|
460
|
-
) -> list[dict[str, Any]]:
|
|
461
|
-
if arm == "with":
|
|
462
|
-
require_index(repo)
|
|
463
|
-
hg = find_homegraph_bin(hg_bin) if arm == "with" else ""
|
|
464
|
-
output.parent.mkdir(parents=True, exist_ok=True)
|
|
465
|
-
if log_file:
|
|
466
|
-
log_file.write_text("", encoding="utf-8")
|
|
467
|
-
|
|
468
|
-
results: list[dict[str, Any]] = []
|
|
469
|
-
auth_failed = False
|
|
470
|
-
total = len(dataset)
|
|
471
|
-
print(f" → {_arm_short(arm)} 臂:共 {total} 题", flush=True)
|
|
472
|
-
with output.open("w", encoding="utf-8") as f:
|
|
473
|
-
for i, item in enumerate(dataset, 1):
|
|
474
|
-
q = str(item["query"])
|
|
475
|
-
item_id = str(item.get("id") or i)
|
|
476
|
-
print_agent_progress(arm, i, total, item_id, "开始…")
|
|
477
|
-
logger.info("[%s] %s/%s %s", arm, i, total, item_id)
|
|
478
|
-
try:
|
|
479
|
-
agent_meta = run_agent_on_query(
|
|
480
|
-
repo,
|
|
481
|
-
q,
|
|
482
|
-
arm=arm,
|
|
483
|
-
api_key=api_key,
|
|
484
|
-
base_url=base_url,
|
|
485
|
-
model=model,
|
|
486
|
-
hg_bin=hg,
|
|
487
|
-
log_file=log_file,
|
|
488
|
-
task_id=i,
|
|
489
|
-
max_turns=max_turns,
|
|
490
|
-
extra_body=extra_body,
|
|
491
|
-
)
|
|
492
|
-
except Exception as e:
|
|
493
|
-
err = str(e)
|
|
494
|
-
logger.error("Agent failed %s: %s", item.get("id"), e)
|
|
495
|
-
if "401" in err or "invalid_api_key" in err or "Incorrect API key" in err:
|
|
496
|
-
auth_failed = True
|
|
497
|
-
agent_meta = {
|
|
498
|
-
"output_answer": "",
|
|
499
|
-
"agent_status": "error",
|
|
500
|
-
"agent_error": err,
|
|
501
|
-
"agent_backend": "agent-with-homegraph" if arm == "with" else "agent-grep-read",
|
|
502
|
-
}
|
|
503
|
-
row = {**item, **agent_meta}
|
|
504
|
-
results.append(row)
|
|
505
|
-
f.write(json.dumps(row, ensure_ascii=False) + "\n")
|
|
506
|
-
f.flush()
|
|
507
|
-
if agent_meta.get("agent_status") == "success":
|
|
508
|
-
turns = agent_meta.get("agent_turns", "?")
|
|
509
|
-
dur_ms = agent_meta.get("agent_duration_ms")
|
|
510
|
-
dur_s = f"{dur_ms / 1000:.1f}s" if isinstance(dur_ms, (int, float)) else "?"
|
|
511
|
-
print_agent_progress(arm, i, total, item_id, f"完成 ({turns} 轮, {dur_s})")
|
|
512
|
-
else:
|
|
513
|
-
err = str(agent_meta.get("agent_error") or agent_meta.get("agent_status") or "error")
|
|
514
|
-
print_agent_progress(arm, i, total, item_id, f"失败: {err[:100]}")
|
|
515
|
-
if auth_failed:
|
|
516
|
-
raise RuntimeError(
|
|
517
|
-
"LLM API 鉴权失败 (401)。智谱 Key 请用:\n"
|
|
518
|
-
" export ZHIPU_API_KEY='your-id.your-secret'\n"
|
|
519
|
-
" python scripts/qa_eval/run_pipeline.py ab --provider zhipu\n"
|
|
520
|
-
"DashScope Key 请用:\n"
|
|
521
|
-
" export DASHSCOPE_API_KEY='sk-...'\n"
|
|
522
|
-
" python scripts/qa_eval/run_pipeline.py ab --provider dashscope"
|
|
523
|
-
) from None
|
|
524
|
-
ok = sum(1 for r in results if r.get("agent_status") == "success")
|
|
525
|
-
print(f" → {_arm_short(arm)} 臂结束:{ok}/{total} 成功", flush=True)
|
|
526
|
-
return results
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
{"id": "R01", "level0": "camera", "level1": "ColorUtil", "category_l1": "检索", "category_l2": "函数", "difficulty": "简单", "language": "ArkTS", "query": "getColorString 函数在哪个文件里定义?", "reference_answer": "getColorString 定义在 camera/common/src/main/ets/utils/ColorUtil.ets,是一个 export function。"}
|
|
2
|
-
{"id": "R02", "level0": "platform", "level1": "BenchmarkHub", "category_l1": "检索", "category_l2": "函数", "difficulty": "简单", "language": "ArkTS", "query": "launchPhotosFromDesktop 函数定义在哪个文件?", "reference_answer": "launchPhotosFromDesktop 定义在 platform/src/main/ets/BenchmarkHub.ets,与 BenchmarkHub 类同文件导出。"}
|