@gracker/smartperfetto 1.0.18 → 1.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. package/dist/agent/core/conclusionContract.d.ts +1 -0
  2. package/dist/agent/core/conclusionContract.d.ts.map +1 -1
  3. package/dist/agent/tools/frameAnalyzer.d.ts.map +1 -1
  4. package/dist/agent/tools/frameAnalyzer.js +1 -0
  5. package/dist/agent/tools/frameAnalyzer.js.map +1 -1
  6. package/dist/agentOpenAI/openAiRuntime.d.ts +24 -0
  7. package/dist/agentOpenAI/openAiRuntime.d.ts.map +1 -1
  8. package/dist/agentOpenAI/openAiRuntime.js +171 -195
  9. package/dist/agentOpenAI/openAiRuntime.js.map +1 -1
  10. package/dist/agentRuntime/index.d.ts +1 -0
  11. package/dist/agentRuntime/index.d.ts.map +1 -1
  12. package/dist/agentRuntime/index.js +16 -1
  13. package/dist/agentRuntime/index.js.map +1 -1
  14. package/dist/agentRuntime/runtimeCommon.d.ts +34 -0
  15. package/dist/agentRuntime/runtimeCommon.d.ts.map +1 -0
  16. package/dist/agentRuntime/runtimeCommon.js +231 -0
  17. package/dist/agentRuntime/runtimeCommon.js.map +1 -0
  18. package/dist/agentv3/claudeConfig.d.ts +6 -2
  19. package/dist/agentv3/claudeConfig.d.ts.map +1 -1
  20. package/dist/agentv3/claudeConfig.js +50 -48
  21. package/dist/agentv3/claudeConfig.js.map +1 -1
  22. package/dist/agentv3/claudeMcpServer.d.ts.map +1 -1
  23. package/dist/agentv3/claudeMcpServer.js +74 -66
  24. package/dist/agentv3/claudeMcpServer.js.map +1 -1
  25. package/dist/agentv3/claudeRuntime.d.ts +18 -2
  26. package/dist/agentv3/claudeRuntime.d.ts.map +1 -1
  27. package/dist/agentv3/claudeRuntime.js +201 -268
  28. package/dist/agentv3/claudeRuntime.js.map +1 -1
  29. package/dist/agentv3/claudeSseBridge.js +1 -1
  30. package/dist/agentv3/claudeSseBridge.js.map +1 -1
  31. package/dist/agentv3/claudeSystemPrompt.d.ts.map +1 -1
  32. package/dist/agentv3/claudeSystemPrompt.js +14 -1
  33. package/dist/agentv3/claudeSystemPrompt.js.map +1 -1
  34. package/dist/agentv3/claudeVerifier.d.ts +1 -1
  35. package/dist/agentv3/claudeVerifier.d.ts.map +1 -1
  36. package/dist/agentv3/claudeVerifier.js +42 -19
  37. package/dist/agentv3/claudeVerifier.js.map +1 -1
  38. package/dist/agentv3/strategyLoader.d.ts +28 -0
  39. package/dist/agentv3/strategyLoader.d.ts.map +1 -1
  40. package/dist/agentv3/strategyLoader.js +35 -0
  41. package/dist/agentv3/strategyLoader.js.map +1 -1
  42. package/dist/cli/commands/validate.d.ts.map +1 -1
  43. package/dist/cli/commands/validate.js +120 -10
  44. package/dist/cli/commands/validate.js.map +1 -1
  45. package/dist/cli-user/bin.js +83 -2
  46. package/dist/cli-user/bin.js.map +1 -1
  47. package/dist/cli-user/commands/analyze.d.ts +2 -0
  48. package/dist/cli-user/commands/analyze.d.ts.map +1 -1
  49. package/dist/cli-user/commands/analyze.js +1 -0
  50. package/dist/cli-user/commands/analyze.js.map +1 -1
  51. package/dist/cli-user/commands/capture.d.ts +37 -2
  52. package/dist/cli-user/commands/capture.d.ts.map +1 -1
  53. package/dist/cli-user/commands/capture.js +184 -95
  54. package/dist/cli-user/commands/capture.js.map +1 -1
  55. package/dist/cli-user/commands/codebase.js +4 -4
  56. package/dist/cli-user/commands/codebase.js.map +1 -1
  57. package/dist/cli-user/commands/compare.d.ts +2 -0
  58. package/dist/cli-user/commands/compare.d.ts.map +1 -1
  59. package/dist/cli-user/commands/compare.js +1 -0
  60. package/dist/cli-user/commands/compare.js.map +1 -1
  61. package/dist/cli-user/commands/doctor.js +4 -0
  62. package/dist/cli-user/commands/doctor.js.map +1 -1
  63. package/dist/cli-user/services/androidCapture.d.ts +59 -0
  64. package/dist/cli-user/services/androidCapture.d.ts.map +1 -0
  65. package/dist/cli-user/services/androidCapture.js +375 -0
  66. package/dist/cli-user/services/androidCapture.js.map +1 -0
  67. package/dist/cli-user/services/captureConfig.d.ts +38 -0
  68. package/dist/cli-user/services/captureConfig.d.ts.map +1 -0
  69. package/dist/cli-user/services/captureConfig.js +434 -0
  70. package/dist/cli-user/services/captureConfig.js.map +1 -0
  71. package/dist/cli-user/services/captureTools.d.ts +11 -0
  72. package/dist/cli-user/services/captureTools.d.ts.map +1 -0
  73. package/dist/cli-user/services/captureTools.js +247 -0
  74. package/dist/cli-user/services/captureTools.js.map +1 -0
  75. package/dist/cli-user/services/cliAnalyzeService.d.ts +2 -0
  76. package/dist/cli-user/services/cliAnalyzeService.d.ts.map +1 -1
  77. package/dist/cli-user/services/cliAnalyzeService.js +1 -0
  78. package/dist/cli-user/services/cliAnalyzeService.js.map +1 -1
  79. package/dist/cli-user/services/runtimeGuard.d.ts +10 -0
  80. package/dist/cli-user/services/runtimeGuard.d.ts.map +1 -1
  81. package/dist/cli-user/services/runtimeGuard.js +48 -0
  82. package/dist/cli-user/services/runtimeGuard.js.map +1 -1
  83. package/dist/cli-user/services/turnRunner.d.ts +3 -0
  84. package/dist/cli-user/services/turnRunner.d.ts.map +1 -1
  85. package/dist/cli-user/services/turnRunner.js +4 -0
  86. package/dist/cli-user/services/turnRunner.js.map +1 -1
  87. package/dist/cli-user/types.d.ts +57 -0
  88. package/dist/cli-user/types.d.ts.map +1 -1
  89. package/dist/perfetto-recording-tools-pin.env +24 -0
  90. package/dist/routes/ragAdminRoutes.js +7 -7
  91. package/dist/routes/ragAdminRoutes.js.map +1 -1
  92. package/dist/services/agentResultNormalizer.d.ts.map +1 -1
  93. package/dist/services/agentResultNormalizer.js +32 -4
  94. package/dist/services/agentResultNormalizer.js.map +1 -1
  95. package/dist/services/codebase/pathSecurityGate.d.ts +2 -2
  96. package/dist/services/codebase/pathSecurityGate.d.ts.map +1 -1
  97. package/dist/services/codebase/pathSecurityGate.js +33 -9
  98. package/dist/services/codebase/pathSecurityGate.js.map +1 -1
  99. package/dist/services/evidence/evidenceContractBuilder.d.ts.map +1 -1
  100. package/dist/services/evidence/evidenceContractBuilder.js +17 -3
  101. package/dist/services/evidence/evidenceContractBuilder.js.map +1 -1
  102. package/dist/services/finalReportContractGate.d.ts +13 -0
  103. package/dist/services/finalReportContractGate.d.ts.map +1 -0
  104. package/dist/services/finalReportContractGate.js +48 -0
  105. package/dist/services/finalReportContractGate.js.map +1 -0
  106. package/dist/services/finalResultQualityGate.d.ts +3 -1
  107. package/dist/services/finalResultQualityGate.d.ts.map +1 -1
  108. package/dist/services/finalResultQualityGate.js +18 -1
  109. package/dist/services/finalResultQualityGate.js.map +1 -1
  110. package/dist/services/htmlReportGenerator.d.ts +12 -0
  111. package/dist/services/htmlReportGenerator.d.ts.map +1 -1
  112. package/dist/services/htmlReportGenerator.js +286 -33
  113. package/dist/services/htmlReportGenerator.js.map +1 -1
  114. package/dist/services/perfettoSqlSkill.d.ts.map +1 -1
  115. package/dist/services/perfettoSqlSkill.js +1 -0
  116. package/dist/services/perfettoSqlSkill.js.map +1 -1
  117. package/dist/services/providerManager/connectionTester.d.ts.map +1 -1
  118. package/dist/services/providerManager/connectionTester.js +4 -68
  119. package/dist/services/providerManager/connectionTester.js.map +1 -1
  120. package/dist/services/providerManager/index.d.ts +1 -0
  121. package/dist/services/providerManager/index.d.ts.map +1 -1
  122. package/dist/services/providerManager/index.js +8 -1
  123. package/dist/services/providerManager/index.js.map +1 -1
  124. package/dist/services/providerManager/providerService.d.ts.map +1 -1
  125. package/dist/services/providerManager/providerService.js +37 -106
  126. package/dist/services/providerManager/providerService.js.map +1 -1
  127. package/dist/services/providerManager/providerSnapshot.d.ts.map +1 -1
  128. package/dist/services/providerManager/providerSnapshot.js +13 -12
  129. package/dist/services/providerManager/providerSnapshot.js.map +1 -1
  130. package/dist/services/providerManager/runtimeCapabilities.d.ts +9 -0
  131. package/dist/services/providerManager/runtimeCapabilities.d.ts.map +1 -0
  132. package/dist/services/providerManager/runtimeCapabilities.js +105 -0
  133. package/dist/services/providerManager/runtimeCapabilities.js.map +1 -0
  134. package/dist/services/rag/aospSourceIngester.d.ts +1 -1
  135. package/dist/services/rag/aospSourceIngester.d.ts.map +1 -1
  136. package/dist/services/rag/aospSourceIngester.js +6 -4
  137. package/dist/services/rag/aospSourceIngester.js.map +1 -1
  138. package/dist/services/rag/appSourceIngester.d.ts +1 -1
  139. package/dist/services/rag/appSourceIngester.d.ts.map +1 -1
  140. package/dist/services/rag/appSourceIngester.js +6 -4
  141. package/dist/services/rag/appSourceIngester.js.map +1 -1
  142. package/dist/services/rag/kernelSourceIngester.d.ts +1 -1
  143. package/dist/services/rag/kernelSourceIngester.d.ts.map +1 -1
  144. package/dist/services/rag/kernelSourceIngester.js +6 -4
  145. package/dist/services/rag/kernelSourceIngester.js.map +1 -1
  146. package/dist/services/ragStore.d.ts +2 -0
  147. package/dist/services/ragStore.d.ts.map +1 -1
  148. package/dist/services/ragStore.js +6 -1
  149. package/dist/services/ragStore.js.map +1 -1
  150. package/dist/services/skillEngine/skillExecutor.d.ts +1 -0
  151. package/dist/services/skillEngine/skillExecutor.d.ts.map +1 -1
  152. package/dist/services/skillEngine/skillExecutor.js +64 -12
  153. package/dist/services/skillEngine/skillExecutor.js.map +1 -1
  154. package/package.json +5 -5
  155. package/prebuilts/android-platform-tools/README.md +13 -0
  156. package/prebuilts/perfetto-recording-tools/README.md +17 -0
  157. package/skills/atomic/cpu_topology_detection.skill.yaml +105 -159
  158. package/skills/atomic/cpu_topology_view.skill.yaml +2 -0
  159. package/strategies/prompt-openai-final-report-continuation-en.template.md +5 -1
  160. package/strategies/prompt-openai-final-report-continuation-zh.template.md +5 -1
  161. package/strategies/prompt-output-format.template.md +1 -1
  162. package/strategies/scrolling.strategy.md +22 -0
  163. package/strategies/startup.strategy.md +27 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gracker/smartperfetto",
3
- "version": "1.0.18",
3
+ "version": "1.0.20",
4
4
  "description": "SmartPerfetto CLI and backend runtime",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -55,7 +55,7 @@
55
55
  "prepack": "npm run build",
56
56
  "typecheck": "tsc --noEmit",
57
57
  "test": "jest",
58
- "test:core": "jest --runInBand --forceExit src/agent/communication/__tests__/agentMessageBus.test.ts src/agent/core/executors/__tests__/strategyExecutor.test.ts src/agent/core/executors/__tests__/hypothesisExecutor.test.ts src/agent/core/__tests__/modelRouter.test.ts src/agent/context/__tests__/enhancedSessionContext.test.ts src/tests/adbTools.test.ts src/services/__tests__/sessionLogger.test.ts src/agent/__tests__/llmAdapter.test.ts src/agent/agents/domain/__tests__/registry.test.ts src/agentv3/__tests__/sqlIncludeInjector.test.ts src/agentv3/__tests__/analysisPatternMemory.test.ts src/agentv3/__tests__/claudeRuntimeRuntimeSnapshots.test.ts src/agentv3/__tests__/claudeSseBridge.test.ts src/agentOpenAI/__tests__/openAiRuntime.test.ts src/agentRuntime/__tests__/runtimeSelection.test.ts src/middleware/__tests__/auth.test.ts src/assistant/application/__tests__/assistantApplicationService.test.ts src/assistant/application/__tests__/agentAnalyzeSessionService.test.ts src/services/__tests__/finalResultQualityGate.test.ts src/services/__tests__/persistAgentSession.test.ts src/services/__tests__/htmlReportGenerator.test.ts src/services/__tests__/analysisResultSnapshotPipeline.test.ts src/services/__tests__/rbac.test.ts src/routes/__tests__/agentRoutesRbac.test.ts src/routes/__tests__/ownerGuardRoutes.test.ts src/routes/__tests__/memoryRoutes.test.ts src/cli-user/services/__tests__/cliAnalyzeService.test.ts src/cli-user/services/__tests__/cliAnalyzeService.runTurn.test.ts src/middleware/__tests__/legacyApiCompatibility.test.ts src/services/__tests__/enterpriseDb.test.ts src/services/__tests__/enterpriseSchema.test.ts src/services/__tests__/enterpriseRepository.test.ts src/services/__tests__/processRss.test.ts src/services/__tests__/workingTraceProcessor.enterpriseIsolation.test.ts src/services/__tests__/traceProcessorLeaseStore.test.ts src/services/__tests__/traceProcessorLeaseModeDecision.test.ts src/services/__tests__/traceProcessorLeaseProcessorRouting.test.ts src/services/__tests__/traceProcessorSqlWorker.test.ts src/services/__tests__/traceProcessorRamBudget.test.ts src/scripts/__tests__/benchmarkTraceProcessorRss.test.ts src/scripts/__tests__/auditTraceProcessorRssMatrix.test.ts src/scripts/__tests__/enterpriseReadinessAudit.test.ts src/scripts/__tests__/enterpriseAcceptanceLoadTest.test.ts src/scripts/__tests__/enterpriseRuntimeIsolationChecklist.test.ts src/scripts/__tests__/enterpriseSecurityAuditChecklist.test.ts src/services/__tests__/analysisRunStore.test.ts src/services/__tests__/agentEventStore.test.ts src/services/__tests__/enterpriseKnowledgeScope.test.ts src/services/__tests__/enterpriseMigration.test.ts src/services/__tests__/runtimeSnapshotStore.test.ts src/services/providerManager/__tests__/localSecretStore.test.ts src/services/providerManager/__tests__/enterpriseProviderStore.test.ts src/services/providerManager/__tests__/providerSnapshot.test.ts src/routes/__tests__/enterpriseTraceMetadataRoutes.test.ts src/routes/__tests__/enterpriseTenantRoutes.test.ts src/routes/__tests__/traceProcessorProxyRoutes.test.ts src/routes/__tests__/enterpriseReportRoutes.test.ts src/routes/__tests__/enterpriseRuntimeDashboardRoutes.test.ts src/routes/__tests__/enterpriseRestartPersistence.test.ts",
58
+ "test:core": "jest --runInBand --forceExit src/agent/communication/__tests__/agentMessageBus.test.ts src/agent/core/executors/__tests__/strategyExecutor.test.ts src/agent/core/executors/__tests__/hypothesisExecutor.test.ts src/agent/core/__tests__/modelRouter.test.ts src/agent/context/__tests__/enhancedSessionContext.test.ts src/tests/adbTools.test.ts src/services/__tests__/sessionLogger.test.ts src/agent/__tests__/llmAdapter.test.ts src/agent/agents/domain/__tests__/registry.test.ts src/agentv3/__tests__/sqlIncludeInjector.test.ts src/agentv3/__tests__/analysisPatternMemory.test.ts src/agentv3/__tests__/claudeRuntimeRuntimeSnapshots.test.ts src/agentv3/__tests__/claudeSseBridge.test.ts src/agentOpenAI/__tests__/openAiRuntime.test.ts src/agentRuntime/__tests__/runtimeSelection.test.ts src/middleware/__tests__/auth.test.ts src/assistant/application/__tests__/assistantApplicationService.test.ts src/assistant/application/__tests__/agentAnalyzeSessionService.test.ts src/services/__tests__/finalResultQualityGate.test.ts src/services/__tests__/persistAgentSession.test.ts src/services/__tests__/htmlReportGenerator.test.ts src/services/__tests__/analysisResultSnapshotPipeline.test.ts src/services/__tests__/rbac.test.ts src/routes/__tests__/agentRoutesRbac.test.ts src/routes/__tests__/ownerGuardRoutes.test.ts src/routes/__tests__/memoryRoutes.test.ts src/cli-user/services/__tests__/cliAnalyzeService.test.ts src/cli-user/services/__tests__/cliAnalyzeService.runTurn.test.ts src/cli-user/services/__tests__/captureConfig.test.ts src/cli-user/services/__tests__/captureTools.test.ts src/cli-user/services/__tests__/androidCapture.test.ts src/middleware/__tests__/legacyApiCompatibility.test.ts src/services/__tests__/enterpriseDb.test.ts src/services/__tests__/enterpriseSchema.test.ts src/services/__tests__/enterpriseRepository.test.ts src/services/__tests__/processRss.test.ts src/services/__tests__/workingTraceProcessor.enterpriseIsolation.test.ts src/services/__tests__/traceProcessorLeaseStore.test.ts src/services/__tests__/traceProcessorLeaseModeDecision.test.ts src/services/__tests__/traceProcessorLeaseProcessorRouting.test.ts src/services/__tests__/traceProcessorSqlWorker.test.ts src/services/__tests__/traceProcessorRamBudget.test.ts src/scripts/__tests__/benchmarkTraceProcessorRss.test.ts src/scripts/__tests__/auditTraceProcessorRssMatrix.test.ts src/scripts/__tests__/enterpriseReadinessAudit.test.ts src/scripts/__tests__/enterpriseAcceptanceLoadTest.test.ts src/scripts/__tests__/enterpriseRuntimeIsolationChecklist.test.ts src/scripts/__tests__/enterpriseSecurityAuditChecklist.test.ts src/services/__tests__/analysisRunStore.test.ts src/services/__tests__/agentEventStore.test.ts src/services/__tests__/enterpriseKnowledgeScope.test.ts src/services/__tests__/enterpriseMigration.test.ts src/services/__tests__/runtimeSnapshotStore.test.ts src/services/providerManager/__tests__/localSecretStore.test.ts src/services/providerManager/__tests__/enterpriseProviderStore.test.ts src/services/providerManager/__tests__/providerSnapshot.test.ts src/routes/__tests__/enterpriseTraceMetadataRoutes.test.ts src/routes/__tests__/enterpriseTenantRoutes.test.ts src/routes/__tests__/traceProcessorProxyRoutes.test.ts src/routes/__tests__/enterpriseReportRoutes.test.ts src/routes/__tests__/enterpriseRuntimeDashboardRoutes.test.ts src/routes/__tests__/enterpriseRestartPersistence.test.ts",
59
59
  "test:watch": "jest --watch",
60
60
  "test:coverage": "jest --coverage",
61
61
  "test:unit": "jest --testPathPatterns=src/tests",
@@ -86,7 +86,7 @@
86
86
  "test:scrolling": "tsx src/scripts/runScrollingTest.ts",
87
87
  "test:scrolling:real": "tsx src/scripts/runScrollingTestRealData.ts",
88
88
  "verify:agent-sse-scrolling": "tsx src/scripts/verifyAgentSseScrolling.ts",
89
- "verify:e2e:openai-startup": "SMARTPERFETTO_AGENT_RUNTIME=openai-agents-sdk tsx src/scripts/verifyAgentSseScrolling.ts --mode full --trace ../test-traces/lacunh_heavy.pftrace --query \"分析启动性能\" --output test-output/e2e-openai-startup-real.json --keep-session --require-conclusion-evidence --require-claim-verifier-ok --require-non-partial --require-final-report-heading --forbid-process-narration --forbid-degraded-fallback completed_plan_summary_fallback --max-analysis-completed-conclusion-chars 6500 --require-text \"冷启动\" --require-text \"ChaosTask\" --forbid-text \"完成综合结论输出\" --forbid-text \"分阶段证据摘要\" --forbid-text \"完整结构化报告已生成\" --forbid-text \"应维持温启动\" --forbid-text \"bindApplication 不存在\"",
89
+ "verify:e2e:openai-startup": "SMARTPERFETTO_AGENT_RUNTIME=openai-agents-sdk tsx src/scripts/verifyAgentSseScrolling.ts --mode full --trace ../test-traces/lacunh_heavy.pftrace --query \"分析启动性能\" --output test-output/e2e-openai-startup-real.json --keep-session --require-conclusion-evidence --require-claim-verifier-ok --require-non-partial --require-final-report-heading --forbid-process-narration --forbid-degraded-fallback completed_plan_summary_fallback --require-text \"冷启动\" --require-text \"ChaosTask\" --forbid-text \"完成综合结论输出\" --forbid-text \"分阶段证据摘要\" --forbid-text \"完整结构化报告已生成\" --forbid-text \"应维持温启动\" --forbid-text \"bindApplication 不存在\"",
90
90
  "generate:frontend-types": "tsx scripts/generateFrontendTypes.ts",
91
91
  "check:types": "tsx scripts/checkTypesSync.ts",
92
92
  "types": "npm run generate:frontend-types"
@@ -100,7 +100,7 @@
100
100
  "author": "",
101
101
  "license": "AGPL-3.0-or-later",
102
102
  "dependencies": {
103
- "@anthropic-ai/claude-agent-sdk": "^0.2.141",
103
+ "@anthropic-ai/claude-agent-sdk": "^0.3.148",
104
104
  "@openai/agents": "^0.11.4",
105
105
  "@types/better-sqlite3": "^7.6.13",
106
106
  "@types/js-yaml": "^4.0.9",
@@ -120,7 +120,7 @@
120
120
  "@jest/globals": "^30.4.1",
121
121
  "@types/cors": "^2.8.19",
122
122
  "@types/express": "^5.0.6",
123
- "@types/glob": "^8.1.0",
123
+ "@types/glob": "^9.0.0",
124
124
  "@types/jest": "^30.0.0",
125
125
  "@types/markdown-it": "^14.1.2",
126
126
  "@types/multer": "^2.0.0",
@@ -0,0 +1,13 @@
1
+ # Android Platform-Tools Slot
2
+
3
+ This directory is reserved for approved bundled ADB binaries used by
4
+ `smp capture android`.
5
+
6
+ Resolution order is:
7
+
8
+ 1. `ADB_PATH`
9
+ 2. `prebuilts/android-platform-tools/<platform>/adb[.exe]`
10
+ 3. `adb` on `PATH`
11
+
12
+ Do not copy Google SDK Platform-Tools binaries here unless the release process
13
+ has explicitly approved the license and redistribution path.
@@ -0,0 +1,17 @@
1
+ # Perfetto Recording Tool Slot
2
+
3
+ This directory is reserved for approved `tracebox` prebuilts used by
4
+ `smp capture android --sideload` and Android devices older than API 29.
5
+
6
+ Expected layout:
7
+
8
+ ```text
9
+ prebuilts/perfetto-recording-tools/android-arm64/tracebox
10
+ prebuilts/perfetto-recording-tools/android-arm/tracebox
11
+ prebuilts/perfetto-recording-tools/android-x64/tracebox
12
+ prebuilts/perfetto-recording-tools/android-x86/tracebox
13
+ ```
14
+
15
+ The pin source is `scripts/perfetto-recording-tools-pin.env`. SmartPerfetto
16
+ does not download these binaries at capture time; use `--tracebox` to point at
17
+ a local binary until approved artifacts are packaged.
@@ -5,204 +5,167 @@
5
5
  # =============================================================================
6
6
  # CPU 拓扑动态检测 (CPU Topology Detection)
7
7
  # =============================================================================
8
- # cpufreq 最大值动态推断 CPU 集群类型
8
+ # Public compatibility wrapper around cpu_topology_view.
9
9
  #
10
- # 背景:
11
- # - 现代 SoC 使用异构多核设计 (big.LITTLE, DynamIQ)
12
- # - 不同芯片的 CPU 拓扑差异很大:
13
- # - Snapdragon 8 Gen 3: 2 小核 + 3 中核 + 1 Prime + 2 超大核
14
- # - Dimensity 9300: 4 大核 + 4 超大核 (全大核设计)
15
- # - Tensor G3: 4 小核 + 3 中核 + 1 大核
16
- #
17
- # 检测方法:
18
- # - 通过每个 CPU 核心的最大频率推断其类型
19
- # - 最高频率的 90%+ 归为 prime/big
20
- # - 60%-90% 归为 mid
21
- # - 60% 以下归为 little
10
+ # Keep CPU topology inference centralized in `_cpu_topology`; do not maintain
11
+ # another threshold-based classifier here. The shared view:
12
+ # - builds the CPU universe from observed trace evidence first;
13
+ # - ignores stale CPU table rows unless no observed CPU evidence exists;
14
+ # - classifies common Android layouts such as 6+2, 4+3+1, 4+4, 4+2, 4-only,
15
+ # and 10-core tri-cluster layouts from capacity/frequency scale clusters;
16
+ # - keeps unsupported/insufficient scale evidence explicit as `unknown`.
22
17
  # =============================================================================
23
18
 
24
19
  name: cpu_topology_detection
25
20
  version: "1.0"
26
- type: atomic
21
+ type: composite
27
22
  category: hardware
28
23
  tier: B
29
24
 
30
25
  meta:
31
26
  display_name: "CPU 拓扑检测"
32
- description: " cpufreq 动态检测 CPU 大小核拓扑"
27
+ description: "基于共享 _cpu_topology 视图检测 CPU 大小核拓扑"
33
28
  icon: "memory"
34
29
  tags: [cpu, topology, cluster, atomic]
35
30
 
36
- prerequisites:
37
- required_tables:
38
- - counter
39
- - cpu_counter_track
40
-
41
31
  inputs:
42
32
  - name: start_ts
43
33
  type: timestamp
44
34
  required: false
45
- description: "分析起始时间(可选)"
35
+ description: "分析起始时间(保留兼容;共享拓扑检测使用整条 trace 的观测证据)"
46
36
  - name: end_ts
47
37
  type: timestamp
48
38
  required: false
49
- description: "分析结束时间(可选)"
39
+ description: "分析结束时间(保留兼容;共享拓扑检测使用整条 trace 的观测证据)"
50
40
 
51
41
  steps:
52
- # Step 1: 检测每个 CPU 的最大频率
42
+ - id: init_cpu_topology
43
+ type: skill
44
+ name: "初始化 CPU 拓扑"
45
+ skill: cpu_topology_view
46
+ display:
47
+ level: hidden
48
+ optional: true
49
+
53
50
  - id: detect_cpu_clusters
54
51
  type: atomic
55
52
  name: "检测 CPU 集群"
56
53
  display:
57
54
  level: summary
55
+ layer: overview
58
56
  title: "CPU 拓扑检测结果"
57
+ columns:
58
+ - name: cpu
59
+ label: "CPU"
60
+ type: number
61
+ - name: cluster_type
62
+ label: "核心类型"
63
+ type: string
64
+ - name: max_freq_mhz
65
+ label: "Max Freq"
66
+ type: number
67
+ - name: capacity
68
+ label: "Capacity"
69
+ type: number
70
+ - name: topology_source
71
+ label: "判定来源"
72
+ type: string
73
+ - name: cluster_rank
74
+ label: "簇档位"
75
+ type: number
76
+ - name: cluster_count
77
+ label: "簇数量"
78
+ type: number
59
79
  sql: |
60
- WITH
61
- -- 获取时间范围
62
- time_bounds AS (
63
- SELECT
64
- COALESCE(${start_ts}, (SELECT MIN(ts) FROM counter)) as start_ts,
65
- COALESCE(${end_ts}, (SELECT MAX(ts) FROM counter)) as end_ts
66
- ),
67
- -- 获取每个 CPU 的最大频率
68
- cpu_max_freq AS (
69
- SELECT
70
- t.cpu,
71
- MAX(c.value) as max_freq_khz,
72
- MIN(c.value) as min_freq_khz,
73
- AVG(c.value) as avg_freq_khz,
74
- COUNT(*) as sample_count
75
- FROM counter c
76
- JOIN cpu_counter_track t ON c.track_id = t.id
77
- WHERE t.name = 'cpufreq'
78
- AND c.ts >= (SELECT start_ts FROM time_bounds)
79
- AND c.ts <= (SELECT end_ts FROM time_bounds)
80
- GROUP BY t.cpu
81
- ),
82
- -- 获取全局最大频率用于计算比例
83
- global_max AS (
84
- SELECT MAX(max_freq_khz) as global_max_freq FROM cpu_max_freq
85
- ),
86
- -- 根据最大频率比例推断集群类型
87
- cpu_clusters AS (
88
- SELECT
89
- cpu,
90
- max_freq_khz,
91
- min_freq_khz,
92
- ROUND(max_freq_khz / 1000.0, 0) as max_freq_mhz,
93
- ROUND(100.0 * max_freq_khz / (SELECT global_max_freq FROM global_max), 1) as freq_ratio_pct,
94
- CASE
95
- -- 最高频率的 90%+ 归为 prime (超大核)
96
- WHEN max_freq_khz >= (SELECT global_max_freq FROM global_max) * 0.95 THEN 'prime'
97
- -- 75%-95% 归为 big (大核)
98
- WHEN max_freq_khz >= (SELECT global_max_freq FROM global_max) * 0.75 THEN 'big'
99
- -- 50%-75% 归为 mid (中核)
100
- WHEN max_freq_khz >= (SELECT global_max_freq FROM global_max) * 0.50 THEN 'mid'
101
- -- 50% 以下归为 little (小核)
102
- ELSE 'little'
103
- END as cluster_type,
104
- sample_count
105
- FROM cpu_max_freq
106
- )
107
80
  SELECT
108
- cpu,
109
- cluster_type,
110
- max_freq_mhz,
111
- freq_ratio_pct,
112
- CASE cluster_type
81
+ cpu_id as cpu,
82
+ core_type as cluster_type,
83
+ CASE WHEN max_freq IS NULL THEN NULL ELSE ROUND(max_freq / 1000.0, 0) END as max_freq_mhz,
84
+ capacity,
85
+ topology_source,
86
+ cluster_rank,
87
+ cluster_count,
88
+ CASE core_type
113
89
  WHEN 'prime' THEN '超大核'
114
90
  WHEN 'big' THEN '大核'
115
- WHEN 'mid' THEN '中核'
116
- ELSE '小核'
91
+ WHEN 'medium' THEN '中核'
92
+ WHEN 'little' THEN '小核'
93
+ ELSE '未知'
117
94
  END as cluster_type_cn
118
- FROM cpu_clusters
119
- ORDER BY max_freq_khz DESC, cpu
95
+ FROM _cpu_topology
96
+ ORDER BY
97
+ CASE core_type
98
+ WHEN 'prime' THEN 1
99
+ WHEN 'big' THEN 2
100
+ WHEN 'medium' THEN 3
101
+ WHEN 'little' THEN 4
102
+ ELSE 5
103
+ END,
104
+ cpu_id
120
105
  save_as: cpu_clusters
121
106
 
122
- # Step 2: 集群汇总
123
107
  - id: cluster_summary
124
108
  type: atomic
125
109
  name: "集群汇总"
126
110
  display:
127
111
  level: summary
112
+ layer: overview
128
113
  title: "CPU 集群汇总"
114
+ columns:
115
+ - name: cluster_type
116
+ label: "核心类型"
117
+ type: string
118
+ - name: cpu_count
119
+ label: "CPU 数"
120
+ type: number
121
+ - name: cpus
122
+ label: "CPU 列表"
123
+ type: string
124
+ - name: max_freq_mhz
125
+ label: "最高频率"
126
+ type: number
127
+ - name: min_freq_mhz
128
+ label: "最低频率"
129
+ type: number
130
+ - name: topology_source
131
+ label: "判定来源"
132
+ type: string
129
133
  sql: |
130
- WITH
131
- cpu_max_freq AS (
132
- SELECT
133
- t.cpu,
134
- MAX(c.value) as max_freq_khz
135
- FROM counter c
136
- JOIN cpu_counter_track t ON c.track_id = t.id
137
- WHERE t.name = 'cpufreq'
138
- GROUP BY t.cpu
139
- ),
140
- global_max AS (
141
- SELECT MAX(max_freq_khz) as global_max_freq FROM cpu_max_freq
142
- ),
143
- cpu_clusters AS (
144
- SELECT
145
- cpu,
146
- max_freq_khz,
147
- CASE
148
- WHEN max_freq_khz >= (SELECT global_max_freq FROM global_max) * 0.95 THEN 'prime'
149
- WHEN max_freq_khz >= (SELECT global_max_freq FROM global_max) * 0.75 THEN 'big'
150
- WHEN max_freq_khz >= (SELECT global_max_freq FROM global_max) * 0.50 THEN 'mid'
151
- ELSE 'little'
152
- END as cluster_type
153
- FROM cpu_max_freq
154
- )
155
134
  SELECT
156
- cluster_type,
135
+ core_type as cluster_type,
157
136
  COUNT(*) as cpu_count,
158
- GROUP_CONCAT(cpu, ', ') as cpus,
159
- ROUND(MAX(max_freq_khz) / 1000.0, 0) as max_freq_mhz,
160
- ROUND(MIN(max_freq_khz) / 1000.0, 0) as min_freq_mhz,
161
- CASE cluster_type
137
+ GROUP_CONCAT(cpu_id, ', ') as cpus,
138
+ CASE WHEN MAX(max_freq) IS NULL THEN NULL ELSE ROUND(MAX(max_freq) / 1000.0, 0) END as max_freq_mhz,
139
+ CASE WHEN MIN(max_freq) IS NULL THEN NULL ELSE ROUND(MIN(max_freq) / 1000.0, 0) END as min_freq_mhz,
140
+ GROUP_CONCAT(DISTINCT topology_source) as topology_source,
141
+ CASE core_type
162
142
  WHEN 'prime' THEN 1
163
143
  WHEN 'big' THEN 2
164
- WHEN 'mid' THEN 3
165
- ELSE 4
144
+ WHEN 'medium' THEN 3
145
+ WHEN 'little' THEN 4
146
+ ELSE 5
166
147
  END as cluster_order
167
- FROM cpu_clusters
168
- GROUP BY cluster_type
148
+ FROM _cpu_topology
149
+ GROUP BY core_type
169
150
  ORDER BY cluster_order
170
151
  save_as: cluster_summary
171
152
 
172
- # Step 3: 导出供其他 skill 使用的集群映射
173
153
  - id: cluster_mapping
174
154
  type: atomic
175
155
  name: "集群映射"
176
156
  sql: |
177
- WITH
178
- cpu_max_freq AS (
179
- SELECT
180
- t.cpu,
181
- MAX(c.value) as max_freq_khz
182
- FROM counter c
183
- JOIN cpu_counter_track t ON c.track_id = t.id
184
- WHERE t.name = 'cpufreq'
185
- GROUP BY t.cpu
186
- ),
187
- global_max AS (
188
- SELECT MAX(max_freq_khz) as global_max_freq FROM cpu_max_freq
189
- )
190
157
  SELECT
191
- cpu,
192
- max_freq_khz,
158
+ cpu_id as cpu,
159
+ max_freq as max_freq_khz,
160
+ core_type as cluster_type,
193
161
  CASE
194
- WHEN max_freq_khz >= (SELECT global_max_freq FROM global_max) * 0.95 THEN 'prime'
195
- WHEN max_freq_khz >= (SELECT global_max_freq FROM global_max) * 0.75 THEN 'big'
196
- WHEN max_freq_khz >= (SELECT global_max_freq FROM global_max) * 0.50 THEN 'mid'
197
- ELSE 'little'
198
- END as cluster_type,
199
- -- 简化的 big/little 分类 (兼容旧逻辑)
200
- CASE
201
- WHEN max_freq_khz >= (SELECT global_max_freq FROM global_max) * 0.60 THEN 'big'
202
- ELSE 'little'
203
- END as simple_cluster_type
204
- FROM cpu_max_freq
205
- ORDER BY cpu
162
+ WHEN core_type IN ('prime', 'big', 'medium') THEN 'big'
163
+ WHEN core_type = 'little' THEN 'little'
164
+ ELSE 'unknown'
165
+ END as simple_cluster_type,
166
+ topology_source
167
+ FROM _cpu_topology
168
+ ORDER BY cpu_id
206
169
  save_as: cluster_mapping
207
170
 
208
171
  output:
@@ -214,20 +177,3 @@ output:
214
177
  description: "集群汇总(每种类型的核心数)"
215
178
  - name: cluster_mapping
216
179
  description: "集群映射表(供其他 skill 使用)"
217
-
218
- # =============================================================================
219
- # 使用示例
220
- # =============================================================================
221
- # 其他 skill 可以通过以下 CTE 使用动态检测的集群:
222
- #
223
- # WITH cpu_clusters AS (
224
- # -- 复制 cluster_mapping 的 SQL
225
- # )
226
- # SELECT
227
- # CASE
228
- # WHEN cpu IN (SELECT cpu FROM cpu_clusters WHERE cluster_type = 'prime') THEN 'prime'
229
- # WHEN cpu IN (SELECT cpu FROM cpu_clusters WHERE cluster_type = 'big') THEN 'big'
230
- # WHEN cpu IN (SELECT cpu FROM cpu_clusters WHERE cluster_type = 'mid') THEN 'mid'
231
- # ELSE 'little'
232
- # END as core_type
233
- # FROM ...
@@ -194,6 +194,7 @@ steps:
194
194
  cs.scale_bucket,
195
195
  CASE
196
196
  WHEN cs.scale_bucket IS NULL OR cs.scale_bucket <= 0 THEN 'unknown'
197
+ WHEN sc.cluster_count <= 1 AND (SELECT COUNT(*) FROM cpu_scale) <= 4 THEN 'little'
197
198
  WHEN sc.cluster_count <= 1 THEN 'unknown'
198
199
  WHEN sc.cluster_count = 2 AND sc.cluster_rank = sc.cluster_count THEN 'big'
199
200
  WHEN sc.cluster_rank = 1 THEN 'little'
@@ -205,6 +206,7 @@ steps:
205
206
  END as core_type,
206
207
  CASE
207
208
  WHEN cs.scale_bucket IS NULL OR cs.scale_bucket <= 0 THEN cs.topology_source
209
+ WHEN sc.cluster_count <= 1 AND (SELECT COUNT(*) FROM cpu_scale) <= 4 THEN cs.topology_source || '_uniform_four_little'
208
210
  WHEN sc.cluster_count <= 1 THEN cs.topology_source || '_uniform'
209
211
  ELSE cs.topology_source
210
212
  END as topology_source,
@@ -7,6 +7,10 @@ Now output only the final report body. The first line must be `## Final Conclusi
7
7
 
8
8
  The report must include: final conclusion, key evidence chain, root-cause breakdown, ruled-out factors, recommendations, and confidence/limitations.
9
9
 
10
+ Continue to obey the scene strategy, Final Report Contract, and latest next_phase_reminder constraints from this run. If the scene strategy or contract requires root-cause distributions, representative samples, phase-duration breakdowns, dual-audience recommendations, architecture branch judgments, or any other scene-specific structure, keep that structure in the final report instead of compressing it into a short summary.
11
+ When the Final Report Contract names required items, prefer explicit matching sections or labels, for example "Phase Duration Breakdown", "[App Layer]", and "[System/Platform Layer]", instead of only implying those items inside prose.
12
+ Output all structures required by the Final Report Contract before long trees, appendices, or expanded details. Do not place required recommendations, audience/layered recommendations, or limitations after a long code block or long tree where a truncated report could lose key conclusions.
13
+
10
14
  Do not merely restate phase summaries; synthesize the collected concrete values and evidence into a readable conclusion.
11
15
 
12
- Length requirement: at most 700 English words. Use 2-3 bullets per section; do not expand into a phase-by-phase log, do not copy artifact tables, do not output the evidence table index, and do not repeat raw SQL. If the evidence is sufficient, conclude directly.
16
+ Prioritize completeness. Use compact aggregation tables where helpful; do not expand into a phase-by-phase log, do not copy raw artifact tables, do not output the data-source/evidence-table index because the system will generate it, and do not repeat raw SQL. When evidence is abundant, prioritize the key evidence chain, structures required by the scene contract, and the highest-priority root causes; do not omit key conclusions or evidence just to shorten the report.
@@ -7,6 +7,10 @@
7
7
 
8
8
  报告必须包含:综合结论、关键证据链、根因拆解、已排除因素、优化建议、置信度/限制。
9
9
 
10
+ 必须继续遵守本轮场景策略、Final Report Contract 和最后一个 next_phase_reminder 的输出约束。若场景策略或契约要求根因分布、代表样本、阶段耗时拆分、双受众建议、架构分支判断或其他专属结构,最终报告必须保留这些结构,不能降级为短摘要。
11
+ 如果 Final Report Contract 给出了必检项名称,优先用同名小节或清晰标签呈现,例如“阶段耗时分解”、“[App层]”、“[系统/平台层]”,避免只把契约内容隐含在叙述里。
12
+ 先输出 Final Report Contract 要求的必需结构,再输出长树状图、附录或扩展说明;不要把必需的优化建议、分层建议、限制说明放在长代码块或长树之后,以免报告中途截断时缺失关键结论。
13
+
10
14
  不要只复述阶段摘要;必须把已采集到的具体数值和证据串成可读结论。
11
15
 
12
- 长度要求:最多 1200 个中文字符。每个小节 2-3 条要点即可;不要展开逐阶段流水账,不要复制 artifact 表格,不要重复 SQL 原文,不要输出证据表索引。若证据已经足够,直接收束。
16
+ 完整性优先。可以用小型聚合表压缩信息;不要展开逐阶段流水账,不要复制 artifact 原表,不要重复 SQL 原文,不要输出“数据来源索引/证据表索引”(系统会自动生成)。若证据很多,优先保留关键证据链、场景契约要求的结构和最高优先级根因,不要为了压缩长度裁剪关键结论或证据。
@@ -84,7 +84,7 @@ graph LR
84
84
  ```
85
85
 
86
86
  ### 结论结构
87
- 结论必须完整但克制:优先输出能支撑决策的证据链,避免把已经展示过的大表逐行搬进最终报告。中文目标长度控制在约 2500-3500 字符,英文目标长度控制在约 1200-1800 words;如果证据很多,用聚合表和证据索引压缩,不要生成会在 token 上限处截断的超长报告。
87
+ 结论必须完整但克制:优先输出能支撑决策的证据链,避免把已经展示过的大表逐行搬进最终报告。如果证据很多,用聚合表和证据索引压缩,降低重复信息密度;不要为了压缩长度裁剪关键结论或证据,也不要生成会在 token 上限处截断的超长报告。
88
88
 
89
89
  1. **概览**: 一句话总结性能状况。如果架构检测置信度 < 80%,在概览中标注(如"⚠️ 架构检测置信度 50%,分析策略可能不完全匹配"),帮助用户理解分析的局限性
90
90
  2. **关键发现**: 按严重程度排列的发现列表(含根因推理链 + 📚 背景知识)
@@ -52,6 +52,28 @@ keywords:
52
52
  - nativeactivity
53
53
  - drawfunctor
54
54
 
55
+ final_report_contract:
56
+ required_sections:
57
+ - id: root_cause_distribution
58
+ label: 全帧根因分布
59
+ description: '按 reason_code / 责任方聚合,列出帧数、占比、关键四象限或频率特征。'
60
+ pattern_groups:
61
+ - ['全帧根因分布', '根因分布', 'root[-\s]?cause distribution', 'reason_code']
62
+ - ['帧数', '占比', 'frame count', 'percentage', '\|\s*根因\s*\|', '\|\s*reason']
63
+ - id: representative_frames
64
+ label: 代表帧分析
65
+ description: '每个 CRITICAL/HIGH 根因至少给出 1 个代表样本,包含帧耗时、超预算倍数、vsync_missed、关键 slice/阻塞点和因果链。'
66
+ pattern_groups:
67
+ - ['代表帧', 'representative\s+frame']
68
+ - ['frame_id', 'guilty[_ ]?frame', '帧耗时', 'frame duration']
69
+ - ['vsync_missed', '超预算', 'budget overrun', 'missed[-\s]?vsync']
70
+ - id: peak_and_semantic_metrics
71
+ label: 峰值/口径指标
72
+ description: '说明总帧数、真实掉帧、假阳性/Buffer Stuffing、最长帧和最长连续丢帧等口径。'
73
+ pattern_groups:
74
+ - ['真实掉帧', 'real[_\s-]?jank']
75
+ - ['最长帧', 'longest frame', '峰值']
76
+
55
77
  phase_hints:
56
78
  - id: overview
57
79
  keywords: ['概览', 'overview', '帧', 'frame', 'jank', '卡顿', 'scrolling_analysis', '统计']
@@ -38,6 +38,32 @@ compound_patterns:
38
38
  - "打开.*(应用|app|软件)"
39
39
  - "打开.*(速度|时间|耗时)"
40
40
 
41
+ final_report_contract:
42
+ required_sections:
43
+ - id: startup_type_and_metrics
44
+ label: 启动类型与 TTID/TTFD
45
+ description: '明确 cold/warm/hot 判定,并给出 TTID/TTFD 或对应不可用原因。'
46
+ pattern_groups:
47
+ - ['启动类型', '冷启动', '温启动', '热启动', 'cold\s*start', 'warm\s*start', 'hot\s*start']
48
+ - ['TTID', 'TTFD', 'Time\s+to\s+initial\s+display', 'Time\s+to\s+full\s+display']
49
+ - id: phase_breakdown
50
+ label: 阶段耗时分解
51
+ description: '包含 startup_detail / phase breakdown 口径,并优先使用 self_ms 解释阶段贡献。'
52
+ pattern_groups:
53
+ - ['阶段耗时', '阶段分解', 'phase\s+breakdown', 'startup_detail', '根因分析树', 'Phase\s*\d+']
54
+ - ['self_ms', 'dur_ms', '耗时', '\d+(?:\.\d+)?\s*ms']
55
+ - id: root_cause_references
56
+ label: 根因编号引用
57
+ description: '关键根因需要引用 A1-A18、B1-B12 或 SRxx 编号,便于和启动知识库交叉核对。'
58
+ pattern_groups:
59
+ - ['\bA(?:1[0-8]?|[2-9])\b', '\bB(?:1[0-2]?|[2-9])\b', 'SR(?:09|1[0-9]|20)(?!\d)']
60
+ - id: audience_recommendations
61
+ label: App/系统分层建议
62
+ description: '优化建议必须区分 App 层和系统/平台/ROM 层。'
63
+ pattern_groups:
64
+ - ['App\s*层', '应用\s*层', 'App\s+layer']
65
+ - ['系统\s*/\s*平台\s*层', '系统\s*层', '平台\s*层', 'ROM\s*层', 'System/Platform', 'platform\s+layer']
66
+
41
67
  phase_hints:
42
68
  - id: detail_breakdown
43
69
  keywords: ['detail', '详情', '分解', 'breakdown', '阶段', 'startup_detail', '耗时']
@@ -618,7 +644,7 @@ TTID 和 TTFD 是两个不同的指标,必须区分:
618
644
  - **数据不足时**:标注"数据不足,无法归类"而非强行贴标签
619
645
  - **纯排除项**:编号可选(如"Binder 阻塞(B6) < 10ms ✓")
620
646
 
621
- 3. **根因分析树**:层级式展示启动耗时分解,**必须体现嵌套关系、使用 self_ms、标注根因编号**
647
+ 3. **根因分析树**:层级式展示启动耗时分解,**必须体现嵌套关系、使用 self_ms、标注根因编号**。树可以保持紧凑;不要让长树状图挤掉后面的 App/系统分层建议。
622
648
  ```
623
649
  启动总耗时 XXms
624
650
  ├── [Phase 1] bindApplication = XXms wall