@deveco-test/deveco-cli-common 1.3.11-Test.3 → 1.3.11-Test.4
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 +64 -21
- package/THIRD-PARTY-LICENSES +33 -3
- package/dist/cli.js +213 -165
- package/dist/design2arkts-engine/LICENSE +21 -0
- package/dist/design2arkts-engine/dist/index.d.ts +2739 -0
- package/dist/design2arkts-engine/dist/index.js +6207 -0
- package/dist/design2arkts-engine/package.json +40 -0
- package/dist/design2arkts-engine/pixso-arkts.mjs +98 -0
- package/dist/design2arkts-engine/resources/skill/LICENSE +21 -0
- package/dist/design2arkts-engine/resources/skill/SKILL.md +176 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-arkts-logic-completer/INSTRUCTIONS.md +310 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-arkts-logic-completer/evals/evals.json +249 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-arkts-logic-completer/references/basics-and-display.md +146 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-arkts-logic-completer/references/containers-and-navigation.md +527 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-arkts-logic-completer/references/feedback-and-overlay.md +275 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-arkts-logic-completer/references/hds-components.md +667 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-arkts-logic-completer/references/input-and-selection.md +382 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-arkts-logic-completer/references/patterns/data-and-form.md +440 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-arkts-logic-completer/references/patterns/state-management.md +213 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-arkui-scoring-workflow/INSTRUCTIONS.md +164 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-arkui2hds/INSTRUCTIONS.md +138 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-arkui2hds/references/components.md +777 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-arkui2hds/references/migration-patterns.md +187 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-react-to-arkui/INSTRUCTIONS.md +350 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-react-to-arkui/references/arkui-basic-mapping.md +455 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-react-to-arkui/references/arkui-common-issues.md +516 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-react-to-arkui/references/arkui-knowledge-base/api-cards/button.md +104 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-react-to-arkui/references/arkui-knowledge-base/api-cards/flex.md +115 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-react-to-arkui/references/arkui-knowledge-base/api-cards/grid.md +121 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-react-to-arkui/references/arkui-knowledge-base/api-cards/image.md +118 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-react-to-arkui/references/arkui-knowledge-base/api-cards/list.md +152 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-react-to-arkui/references/arkui-knowledge-base/api-cards/location.md +160 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-react-to-arkui/references/arkui-knowledge-base/api-cards/richeditor.md +132 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-react-to-arkui/references/arkui-knowledge-base/api-cards/row-column.md +118 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-react-to-arkui/references/arkui-knowledge-base/api-cards/stack.md +106 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-react-to-arkui/references/arkui-knowledge-base/api-cards/swiper.md +117 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-react-to-arkui/references/arkui-knowledge-base/api-cards/tabs.md +163 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-react-to-arkui/references/arkui-knowledge-base/api-cards/text-input.md +147 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-react-to-arkui/references/arkui-knowledge-base/api-cards/text.md +145 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-react-to-arkui/references/arkui-knowledge-base/api-cards/waterflow.md +116 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-react-to-arkui/references/arkui-knowledge-base/index.md +23 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-react-to-arkui/references/arkui-knowledge-base/matching.md +127 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-react-to-arkui/references/clarification-template.md +53 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-repo-understand/INSTRUCTIONS.md +163 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-repo-understand/references/architecture-patterns/api-architecture.md +17 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-repo-understand/references/architecture-patterns/data-architecture.md +17 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-repo-understand/references/architecture-patterns/logic-architecture.md +17 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-repo-understand/references/architecture-patterns/ui-architecture.md +23 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-repo-understand/references/methodology/behavior-audit.md +143 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-repo-understand/references/methodology/diff-analysis.md +115 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-repo-understand/references/methodology/dimension-identification.md +86 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-repo-understand/references/methodology/output-format.md +347 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-repo-understand/references/methodology/understanding-modes.md +214 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-responsive-layout-generator/INSTRUCTIONS.md +86 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-responsive-layout-generator/references/breakpoints.md +86 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-responsive-layout-generator/references/chunks.md +48 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-responsive-layout-generator/references/dsl-schema.md +151 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-responsive-layout-generator/references/patterns.md +147 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-responsive-layout-generator/references/rules.md +115 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-solution-design/INSTRUCTIONS.md +572 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-solution-design/assets/template-ui-page.md +293 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-solution-design/references/animation-design.md +84 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-ui-reconstruction-score/INSTRUCTIONS.md +195 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-ui-reconstruction-score/references/analysis_workflow.md +119 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-ui-reconstruction-score/references/scoring_schema.md +83 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-ui-reconstruction-score/references/vlm_prompt.md +61 -0
- package/dist/design2arkts-engine/resources/skill/references/capabilities/hmos-d2a-ui-reconstruction-score/scripts/ui_score.py +691 -0
- package/dist/design2arkts-engine/resources/skill/references/cli-integration.md +94 -0
- package/dist/design2arkts-engine/resources/skill/references/design-doc-auto-recovery.md +91 -0
- package/dist/design2arkts-engine/resources/skill/references/figma/fast/stages/01-acquire-figma-react-source.md +96 -0
- package/dist/design2arkts-engine/resources/skill/references/figma/fast/stages/02-convert-react-to-arkui.md +92 -0
- package/dist/design2arkts-engine/resources/skill/references/figma/fast/stages/03-complete-interaction-logic.md +26 -0
- package/dist/design2arkts-engine/resources/skill/references/figma/fast/stages/04-quality-and-build.md +43 -0
- package/dist/design2arkts-engine/resources/skill/references/figma/fast/stages/05-summary.md +36 -0
- package/dist/design2arkts-engine/resources/skill/references/figma/full/stages/01-acquire-figma-react-source.md +161 -0
- package/dist/design2arkts-engine/resources/skill/references/figma/full/stages/02-convert-react-to-arkui.md +219 -0
- package/dist/design2arkts-engine/resources/skill/references/figma/full/stages/03-complete-interaction-logic.md +31 -0
- package/dist/design2arkts-engine/resources/skill/references/figma/full/stages/04-quality-and-build.md +28 -0
- package/dist/design2arkts-engine/resources/skill/references/figma/full/stages/05-visual-calibration.md +190 -0
- package/dist/design2arkts-engine/resources/skill/references/figma/full/stages/06-summary.md +29 -0
- package/dist/design2arkts-engine/resources/skill/references/figma/stage-catalog-fast.json +40 -0
- package/dist/design2arkts-engine/resources/skill/references/figma/stage-catalog-full.json +47 -0
- package/dist/design2arkts-engine/resources/skill/references/host-vision.md +56 -0
- package/dist/design2arkts-engine/resources/skill/references/mcp-dependency.md +62 -0
- package/dist/design2arkts-engine/resources/skill/references/page-revisions.md +42 -0
- package/dist/design2arkts-engine/resources/skill/references/pixso/fast/stages/01-acquire-pixso-dsl.md +287 -0
- package/dist/design2arkts-engine/resources/skill/references/pixso/fast/stages/02-generate-skeleton-and-assets.md +245 -0
- package/dist/design2arkts-engine/resources/skill/references/pixso/fast/stages/03-understand-repository.md +133 -0
- package/dist/design2arkts-engine/resources/skill/references/pixso/fast/stages/05-design-component-tree.md +222 -0
- package/dist/design2arkts-engine/resources/skill/references/pixso/fast/stages/06-implement-static-layout.md +143 -0
- package/dist/design2arkts-engine/resources/skill/references/pixso/fast/stages/07-complete-interaction-logic.md +131 -0
- package/dist/design2arkts-engine/resources/skill/references/pixso/fast/stages/08-quality-build-and-audits.md +343 -0
- package/dist/design2arkts-engine/resources/skill/references/pixso/fast/stages/09-summary.md +103 -0
- package/dist/design2arkts-engine/resources/skill/references/pixso/full/stages/01-acquire-pixso-dsl.md +287 -0
- package/dist/design2arkts-engine/resources/skill/references/pixso/full/stages/02-generate-skeleton-and-assets.md +245 -0
- package/dist/design2arkts-engine/resources/skill/references/pixso/full/stages/03-understand-repository.md +133 -0
- package/dist/design2arkts-engine/resources/skill/references/pixso/full/stages/05-design-and-confirm-component-tree.md +282 -0
- package/dist/design2arkts-engine/resources/skill/references/pixso/full/stages/06-implement-static-layout.md +143 -0
- package/dist/design2arkts-engine/resources/skill/references/pixso/full/stages/07-complete-interaction-logic.md +131 -0
- package/dist/design2arkts-engine/resources/skill/references/pixso/full/stages/08-quality-build-and-audits.md +343 -0
- package/dist/design2arkts-engine/resources/skill/references/pixso/full/stages/09-visual-calibration.md +190 -0
- package/dist/design2arkts-engine/resources/skill/references/pixso/full/stages/10-summary.md +105 -0
- package/dist/design2arkts-engine/resources/skill/references/pixso/stage-catalog-fast.json +58 -0
- package/dist/design2arkts-engine/resources/skill/references/pixso/stage-catalog-full.json +64 -0
- package/dist/design2arkts-engine/resources/skill/references/requirement-clarification.md +131 -0
- package/dist/design2arkts-engine/resources/skill/references/resource-revisions.md +13 -0
- package/dist/design2arkts-engine/resources/skill/references/runtime-contract.md +435 -0
- package/dist/design2arkts-engine/resources/skill/references/score-engine.json +5 -0
- package/dist/design2arkts-engine/resources/skill/references/source-tools.md +17 -0
- package/dist/design2arkts-engine/resources/skill/references/standalone-capabilities.md +63 -0
- package/dist/design2arkts-engine/resources/skill/references/workflow-origin.json +96 -0
- package/dist/design2arkts-engine/resources/skill/scripts/file-lock.mjs +131 -0
- package/dist/design2arkts-engine/resources/skill/scripts/workflow.mjs +3672 -0
- package/dist/design2arkts-engine/runner.mjs +44 -0
- package/dist/internal/telemetry-upload-background.js +3 -3
- package/package.json +10 -5
- package/skills/deveco-cli/SKILL.md +55 -14
- package/skills/hmos-arkui-develop-skill/SKILL.md +77 -0
- package/skills/hmos-arkui-develop-skill/references/quick-apis/01-layout.md +634 -0
- package/skills/hmos-arkui-develop-skill/references/quick-apis/02-basic-components.md +649 -0
- package/skills/hmos-arkui-develop-skill/references/quick-apis/03-data-display.md +81 -0
- package/skills/hmos-arkui-develop-skill/references/quick-apis/04-selectors.md +109 -0
- package/skills/hmos-arkui-develop-skill/references/quick-apis/05-media.md +90 -0
- package/skills/hmos-arkui-develop-skill/references/quick-apis/06-advanced.md +32 -0
- package/skills/hmos-arkui-develop-skill/references/quick-apis/07-security.md +30 -0
- package/skills/hmos-arkui-develop-skill/references/quick-apis/08-state-decorators.md +120 -0
- package/skills/hmos-arkui-develop-skill/references/quick-apis/09-animation.md +118 -0
- package/skills/hmos-arkui-develop-skill/references/quick-apis/10-gesture.md +89 -0
- package/skills/hmos-arkui-develop-skill/references/quick-apis/11-dialog-menu.md +152 -0
- package/skills/hmos-arkui-develop-skill/references/quick-apis/12-navigation.md +127 -0
- package/skills/hmos-arkui-develop-skill/references/quick-apis/13-rendering.md +52 -0
- package/skills/hmos-arkui-develop-skill/references/quick-apis/14-extension.md +22 -0
- package/skills/hmos-arkui-develop-skill/references/quick-apis/15-theme-style.md +10 -0
- package/skills/hmos-arkui-develop-skill/references/quick-apis/16-enums.md +128 -0
- package/skills/hmos-arkui-develop-skill/references/quick-apis/17-resources.md +401 -0
- package/skills/hmos-arkui-develop-skill/references/quick-apis/18-error-code.md +24 -0
- package/skills/hmos-arkui-develop-skill/references/quick-apis/_index.md +76 -0
- package/skills/hmos-arkui-develop-skill/references/quick-rules/00-arkts-syntax.md +229 -0
- package/skills/hmos-arkui-develop-skill/references/quick-rules/01-import.md +116 -0
- package/skills/hmos-arkui-develop-skill/references/quick-rules/02-uicontext.md +56 -0
- package/skills/hmos-arkui-develop-skill/references/quick-rules/03-component.md +105 -0
- package/skills/hmos-arkui-develop-skill/references/quick-rules/04-build.md +41 -0
- package/skills/hmos-arkui-develop-skill/references/quick-rules/05-state.md +300 -0
- package/skills/hmos-arkui-develop-skill/references/quick-rules/06-rendering.md +67 -0
- package/skills/hmos-arkui-develop-skill/references/quick-rules/07-attribute-params.md +219 -0
- package/skills/hmos-arkui-develop-skill/references/quick-rules/08-navigation.md +102 -0
- package/skills/hmos-arkui-develop-skill/references/quick-rules/09-dialog.md +72 -0
- package/skills/hmos-arkui-develop-skill/references/quick-rules/10-style.md +90 -0
- package/skills/hmos-arkui-develop-skill/references/quick-rules/11-extension.md +54 -0
- package/skills/hmos-arkui-develop-skill/references/quick-rules/12-layout.md +69 -0
- package/skills/hmos-arkui-develop-skill/references/quick-rules/13-performance.md +27 -0
- package/skills/hmos-arkui-develop-skill/references/quick-rules/14-deprecated.md +28 -0
- package/skills/hmos-arkui-develop-skill/references/quick-rules/_index.md +79 -0
- package/skills/hmos-arkui-develop-skill/references/style-guide.md +491 -0
- package/skills/hmos-arkui-develop-skill/test-cases/code_gen_cases.json +292 -0
- package/skills/hmos-dfx-analyzer/SKILL.md +683 -0
- package/skills/hmos-dfx-analyzer/changelog/CHANGELOG.md +17 -0
- package/skills/hmos-dfx-analyzer/evals/evals.json +119 -0
- package/skills/hmos-dfx-analyzer/references/appfreeze/analyzer.md +471 -0
- package/skills/hmos-dfx-analyzer/references/appfreeze/references/fault-mode-library.md +94 -0
- package/skills/hmos-dfx-analyzer/references/appfreeze/references/ffrt-freeze-analysis.md +132 -0
- package/skills/hmos-dfx-analyzer/references/appfreeze/references/libuv-freeze-analysis.md +116 -0
- package/skills/hmos-dfx-analyzer/references/appfreeze/scripts/freeze/__init__.py +40 -0
- package/skills/hmos-dfx-analyzer/references/appfreeze/scripts/freeze/binder.py +343 -0
- package/skills/hmos-dfx-analyzer/references/appfreeze/scripts/freeze/collector.py +84 -0
- package/skills/hmos-dfx-analyzer/references/appfreeze/scripts/freeze/common.py +132 -0
- package/skills/hmos-dfx-analyzer/references/appfreeze/scripts/freeze/faultlog.py +212 -0
- package/skills/hmos-dfx-analyzer/references/appfreeze/scripts/freeze/main.py +81 -0
- package/skills/hmos-dfx-analyzer/references/appfreeze/scripts/freeze/report.py +675 -0
- package/skills/hmos-dfx-analyzer/references/appfreeze/scripts/freeze/sections.py +377 -0
- package/skills/hmos-dfx-analyzer/references/appfreeze/scripts/freeze/stack.py +165 -0
- package/skills/hmos-dfx-analyzer/references/appfreeze/scripts/llvm_addr2line.py +123 -0
- package/skills/hmos-dfx-analyzer/references/appfreeze/scripts/match_so.py +120 -0
- package/skills/hmos-dfx-analyzer/references/appfreeze/scripts/sample_stack_analyzer.py +209 -0
- package/skills/hmos-dfx-analyzer/references/cppcrash/analyzer.md +470 -0
- package/skills/hmos-dfx-analyzer/references/cppcrash/references/arkdata.md +325 -0
- package/skills/hmos-dfx-analyzer/references/cppcrash/references/arkui.md +266 -0
- package/skills/hmos-dfx-analyzer/references/cppcrash/references/arkweb.md +144 -0
- package/skills/hmos-dfx-analyzer/references/cppcrash/references/fault_mode.md +178 -0
- package/skills/hmos-dfx-analyzer/references/cppcrash/references/gwp_asan.md +300 -0
- package/skills/hmos-dfx-analyzer/references/cppcrash/references/jsruntime.md +339 -0
- package/skills/hmos-dfx-analyzer/references/cppcrash/references/jsvm.md +203 -0
- package/skills/hmos-dfx-analyzer/references/cppcrash/references/libuv.md +166 -0
- package/skills/hmos-dfx-analyzer/references/cppcrash/references/memory_corruption.md +348 -0
- package/skills/hmos-dfx-analyzer/references/cppcrash/references/memory_corruption_second_scene.md +74 -0
- package/skills/hmos-dfx-analyzer/references/cppcrash/references/multithreading.md +284 -0
- package/skills/hmos-dfx-analyzer/references/cppcrash/references/render_service.md +300 -0
- package/skills/hmos-dfx-analyzer/references/cppcrash/references/rosen_text.md +41 -0
- package/skills/hmos-dfx-analyzer/references/cppcrash/scripts/__init__.py +36 -0
- package/skills/hmos-dfx-analyzer/references/cppcrash/scripts/collector.py +93 -0
- package/skills/hmos-dfx-analyzer/references/cppcrash/scripts/common.py +68 -0
- package/skills/hmos-dfx-analyzer/references/cppcrash/scripts/crash_log.py +275 -0
- package/skills/hmos-dfx-analyzer/references/cppcrash/scripts/extract_hilog.py +69 -0
- package/skills/hmos-dfx-analyzer/references/cppcrash/scripts/hints.py +251 -0
- package/skills/hmos-dfx-analyzer/references/cppcrash/scripts/main.py +82 -0
- package/skills/hmos-dfx-analyzer/references/cppcrash/scripts/match_so.py +120 -0
- package/skills/hmos-dfx-analyzer/references/cppcrash/scripts/ohos_llvm_tools.py +279 -0
- package/skills/hmos-dfx-analyzer/references/cppcrash/scripts/report.py +226 -0
- package/skills/hmos-dfx-analyzer/references/jscrash/analyzer.md +174 -0
- package/skills/hmos-dfx-analyzer/references/jscrash/references/fault-mode-library.md +107 -0
- package/skills/hmos-dfx-analyzer/references/jscrash/references/jscrash-patterns.md +92 -0
- package/skills/hmos-dfx-analyzer/references/jscrash/references/sourcemap-symbolication.md +67 -0
- package/skills/hmos-dfx-analyzer/references/jscrash/scripts/hstack/bin/hstack +25 -0
- package/skills/hmos-dfx-analyzer/references/jscrash/scripts/hstack/bin/hstack.bat +26 -0
- package/skills/hmos-dfx-analyzer/references/jscrash/scripts/hstack/lib/index.js +2 -0
- package/skills/hmos-dfx-analyzer/references/jscrash/scripts/hstack/lib/index.js.LICENSE.txt +1 -0
- package/skills/hmos-dfx-analyzer/references/jscrash/scripts/hstack/lib/mappings.wasm +0 -0
- package/skills/hmos-dfx-analyzer/references/white-screen/analyzer.md +129 -0
- package/skills/hmos-dfx-analyzer/scripts/collect/collect-hilog.mjs +120 -0
- package/skills/hmos-dfx-analyzer/scripts/collect/jscrash-report.mjs +138 -0
- package/skills/hmos-dfx-analyzer/scripts/collect/parse-jscrash-log.mjs +126 -0
- package/skills/hmos-dfx-analyzer/scripts/collect/shared/deveco-cli.mjs +79 -0
- package/skills/hmos-dfx-analyzer/scripts/collect/shared/jscrash-parse.mjs +389 -0
- package/skills/hmos-dfx-analyzer/scripts/collect/shared/utils.mjs +27 -0
- package/skills/hmos-dfx-analyzer/scripts/export_report.py +373 -0
- package/skills/hmos-dfx-analyzer/scripts/identify_fault_log.py +500 -0
- package/skills/hmos-dfx-analyzer/scripts/report_template.html +103 -0
- package/skills/hmos-dfx-analyzer/test-cases/functional.md +112 -0
- package/skills/hmos-dfx-analyzer/test-cases/smoke.md +86 -0
- package/skills/hmos-dfx-analyzer/test-cases/test-prompts.md +35 -0
- package/skills/hmos-dfx-analyzer/test-cases/trigger.md +121 -0
- package/skills/index.json +17 -0
- package/src/resources/arkts-check.cjs +163 -1
|
@@ -0,0 +1,500 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Deterministic HarmonyOS fault-log type identifier.
|
|
3
|
+
|
|
4
|
+
DFX scenario-routing primitive, ported 1:1 from the former identify_fault_log
|
|
5
|
+
builtin tool. It inspects log content structure (never the filename, never the
|
|
6
|
+
user's description) and prints a structured JSON verdict:
|
|
7
|
+
|
|
8
|
+
{type, subtype, confidence, completeness, evidence, excluded, candidates,
|
|
9
|
+
memory_corruption_suspect, out_of_scope}
|
|
10
|
+
|
|
11
|
+
`type` is one of:
|
|
12
|
+
- cpp_crash / js_crash / app_freeze : the three supported fault types
|
|
13
|
+
- sample_stack : freeze enhanced log (freeze-cpuinfo-ext-* sampled stacks).
|
|
14
|
+
Companion evidence for app_freeze analysis, NOT an independent fault log:
|
|
15
|
+
its native frames are periodic snapshots and must never be treated as
|
|
16
|
+
crash evidence. Detected by content markers only, never by filename.
|
|
17
|
+
- unknown
|
|
18
|
+
|
|
19
|
+
Arbitration: when a complete faultlog (header region present) coexists with
|
|
20
|
+
sample-stack markers in the same input, the faultlog type wins and the
|
|
21
|
+
sample-stack markers are noted as companion evidence; when sample-stack
|
|
22
|
+
markers appear without a complete faultlog, the verdict is sample_stack and
|
|
23
|
+
fragment-mode fault detections from its snapshot frames are suppressed.
|
|
24
|
+
|
|
25
|
+
JSCrash compatibility: jscrash faultlogs embed a HiLog section whose stream
|
|
26
|
+
lines can push the hilog-line ratio past the 60% threshold. Before declaring
|
|
27
|
+
hilog_stream the identifier therefore checks for JSCrash structural markers
|
|
28
|
+
(line-anchored Reason/Error message/Stacktrace fields plus JS frames); inputs
|
|
29
|
+
with at least two of them go through to normal fault classification instead of
|
|
30
|
+
being excluded as a pure hilog stream.
|
|
31
|
+
|
|
32
|
+
Contract (SR1 TR-FR-03/04):
|
|
33
|
+
- same input always yields the same structured output (AC-T16)
|
|
34
|
+
- `content` (stdin) and `path` go through the same classify pipeline (AC-19)
|
|
35
|
+
- files larger than 20MB are rejected explicitly, never silently truncated
|
|
36
|
+
(AC-T15); files up to 512KB are read whole, larger files (512KB-20MB) are
|
|
37
|
+
judged via head/tail structural sampling (256KB head + 256KB tail)
|
|
38
|
+
|
|
39
|
+
Usage:
|
|
40
|
+
python3 identify_fault_log.py --path <faultlog-file>
|
|
41
|
+
python3 identify_fault_log.py --stdin < pasted.log
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
import argparse
|
|
45
|
+
import json
|
|
46
|
+
import os
|
|
47
|
+
import re
|
|
48
|
+
import sys
|
|
49
|
+
|
|
50
|
+
# Force UTF-8 on stdin/stdout/stderr regardless of the host locale (Windows
|
|
51
|
+
# GBK consoles or stripped environments would otherwise garble the Chinese
|
|
52
|
+
# evidence strings emitted with ensure_ascii=False below).
|
|
53
|
+
for _stream in (sys.stdin, sys.stdout, sys.stderr):
|
|
54
|
+
if hasattr(_stream, "reconfigure"):
|
|
55
|
+
_stream.reconfigure(encoding="utf-8")
|
|
56
|
+
|
|
57
|
+
MAX_BYTES = 20 * 1024 * 1024
|
|
58
|
+
SAMPLE_HEAD = 256 * 1024
|
|
59
|
+
SAMPLE_TAIL = 256 * 1024
|
|
60
|
+
|
|
61
|
+
NATIVE_FRAME = re.compile(r"^\s*#\d+\s+pc\s+[0-9a-fA-F]+\s+\S+")
|
|
62
|
+
JS_FRAME = re.compile(r"^\s*at\s+\S+\s*\([^)]*\.(ets|ts|js):\d+:\d+\)")
|
|
63
|
+
HEADER_REASON = re.compile(r"(?:^|\n)\s*Reason\s*:([^\n]*)")
|
|
64
|
+
HEADER_REGISTERS = re.compile(r"(?:^|\n)\s*Registers\s*:", re.IGNORECASE)
|
|
65
|
+
HEADER_TIMESTAMP = re.compile(r"(?:^|\n)\s*Timestamp\s*:", re.IGNORECASE)
|
|
66
|
+
HEADER_PID = re.compile(r"(?:^|\n)\s*(?:Pid|Process)\s*:", re.IGNORECASE)
|
|
67
|
+
HEADER_FAULT_THREAD = re.compile(r"(?:^|\n)\s*Fault thread info\s*:", re.IGNORECASE)
|
|
68
|
+
HEADER_PROCESS_LIFE = re.compile(r"(?:^|\n)\s*Process life time\s*:", re.IGNORECASE)
|
|
69
|
+
HEADER_ERROR_MESSAGE = re.compile(r"(?:^|\n)\s*Error message\s*:", re.IGNORECASE)
|
|
70
|
+
HEADER_STACKTRACE = re.compile(r"(?:^|\n)\s*Stacktrace\s*:", re.IGNORECASE)
|
|
71
|
+
HEADER_MSG = re.compile(r"(?:^|\n)\s*MSG\s*(?::|=)", re.IGNORECASE)
|
|
72
|
+
FREEZE_EVENT = re.compile(r"\b(THREAD_BLOCK_6S|APP_INPUT_BLOCK|LIFECYCLE_TIMEOUT)\b")
|
|
73
|
+
THREAD_SECTION = re.compile(r"(?:^|\n)\s*(?:Tid|Name)\s*:")
|
|
74
|
+
SIGNAL_REASON = re.compile(r"\b(SIGSEGV|SIGABRT|SIGBUS|SIGILL|SIGFPE|SIGPIPE|Signal)\b", re.IGNORECASE)
|
|
75
|
+
JS_ERROR_REASON = re.compile(r"\b(TypeError|SyntaxError|RangeError|ReferenceError|EvalError|URIError|BusinessError|Error)\b")
|
|
76
|
+
HILOG_LINE = re.compile(r"^\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2}\.\d+\s+")
|
|
77
|
+
ANDROID_LOGCAT = re.compile(r"^(-+\s+beginning\s+of\s+\w+\s+-+$|\[\s*\d+-\d+\s+\d+:\d+:\d+\.\d+\s+\d+:\d+\s+\w+/)")
|
|
78
|
+
|
|
79
|
+
# 采样栈(增强日志,freeze-cpuinfo-ext-*)结构标记。这些段名/字段名只出现在
|
|
80
|
+
# 采样栈文件中,三类 faultlog 均不含(faultlog 的栈前导是 Timestamp:,非 SnapshotTime:)。
|
|
81
|
+
SAMPLE_STACK_MARKERS = (
|
|
82
|
+
(re.compile(r"#Basic Statistical", re.IGNORECASE), "#Basic Statistical 统计段"),
|
|
83
|
+
(re.compile(r"#CpuFreq Usage", re.IGNORECASE), "#CpuFreq Usage 频点段"),
|
|
84
|
+
(re.compile(r"#ThreadInfos\s+Tid\s*:", re.IGNORECASE), "#ThreadInfos Tid 线程信息头"),
|
|
85
|
+
(re.compile(r"(?:^|\n)\s*SnapshotTime\s*:", re.IGNORECASE), "SnapshotTime 快照时间戳字段"),
|
|
86
|
+
(re.compile(r"SubmitterStacktrace"), "SubmitterStacktrace 提交者栈段"),
|
|
87
|
+
(re.compile(r"(?:^|\n)\s*StaticsDuration\s*:", re.IGNORECASE), "StaticsDuration 统计时长字段"),
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def normalize_crlf(text):
|
|
92
|
+
return text.replace("\r\n", "\n").replace("\r", "\n")
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def strip_bom(text):
|
|
96
|
+
return text[1:] if text.startswith("\ufeff") else text
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def match_one(text, pattern):
|
|
100
|
+
m = pattern.search(text)
|
|
101
|
+
return m.group(1).strip() if m and m.group(1) else None
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def has_header_region(sample):
|
|
105
|
+
hits = 0
|
|
106
|
+
for pattern in (
|
|
107
|
+
HEADER_REASON,
|
|
108
|
+
HEADER_REGISTERS,
|
|
109
|
+
HEADER_TIMESTAMP,
|
|
110
|
+
HEADER_PID,
|
|
111
|
+
HEADER_FAULT_THREAD,
|
|
112
|
+
HEADER_PROCESS_LIFE,
|
|
113
|
+
HEADER_ERROR_MESSAGE,
|
|
114
|
+
HEADER_STACKTRACE,
|
|
115
|
+
HEADER_MSG,
|
|
116
|
+
FREEZE_EVENT,
|
|
117
|
+
):
|
|
118
|
+
if pattern.search(sample):
|
|
119
|
+
hits += 1
|
|
120
|
+
return hits >= 2
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def collect_native_frames(sample):
|
|
124
|
+
out = []
|
|
125
|
+
for line in sample.split("\n"):
|
|
126
|
+
if NATIVE_FRAME.match(line):
|
|
127
|
+
out.append(line.strip())
|
|
128
|
+
if len(out) >= 3:
|
|
129
|
+
break
|
|
130
|
+
return out
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def collect_js_frames(sample):
|
|
134
|
+
out = []
|
|
135
|
+
for line in sample.split("\n"):
|
|
136
|
+
if JS_FRAME.match(line):
|
|
137
|
+
out.append(line.strip())
|
|
138
|
+
if len(out) >= 3:
|
|
139
|
+
break
|
|
140
|
+
return out
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def count_thread_sections(sample):
|
|
144
|
+
return len([line for line in sample.split("\n") if THREAD_SECTION.search(line)])
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def detect_cpp_crash(sample, full):
|
|
148
|
+
evidence = []
|
|
149
|
+
reason = match_one(sample, HEADER_REASON)
|
|
150
|
+
if reason and SIGNAL_REASON.search(reason):
|
|
151
|
+
evidence.append("Reason 字段为 Signal 形态:%s" % reason)
|
|
152
|
+
if HEADER_REGISTERS.search(sample):
|
|
153
|
+
evidence.append("存在 Registers 段")
|
|
154
|
+
if HEADER_FAULT_THREAD.search(sample):
|
|
155
|
+
evidence.append("存在 Fault thread info 段")
|
|
156
|
+
if HEADER_PROCESS_LIFE.search(sample):
|
|
157
|
+
evidence.append("存在 Process life time 段")
|
|
158
|
+
frames = collect_native_frames(sample)
|
|
159
|
+
if frames:
|
|
160
|
+
evidence.append("Native 栈帧形如 #NN pc <地址> <路径>(命中 %d 帧)" % len(frames))
|
|
161
|
+
|
|
162
|
+
if full:
|
|
163
|
+
if reason and SIGNAL_REASON.search(reason) and len(evidence) >= 3:
|
|
164
|
+
return {"type": "cpp_crash", "evidence": evidence}
|
|
165
|
+
return None
|
|
166
|
+
# Fragment mode: only positive signals, missing fields never count against.
|
|
167
|
+
return {"type": "cpp_crash", "evidence": evidence} if frames else None
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def detect_js_crash(sample, full):
|
|
171
|
+
evidence = []
|
|
172
|
+
reason = match_one(sample, HEADER_REASON)
|
|
173
|
+
if reason and JS_ERROR_REASON.search(reason):
|
|
174
|
+
evidence.append("Reason 字段为 JS 错误类名:%s" % reason)
|
|
175
|
+
if HEADER_ERROR_MESSAGE.search(sample):
|
|
176
|
+
evidence.append("存在 Error message 字段")
|
|
177
|
+
if HEADER_STACKTRACE.search(sample):
|
|
178
|
+
evidence.append("存在 Stacktrace 字段")
|
|
179
|
+
frames = collect_js_frames(sample)
|
|
180
|
+
if frames:
|
|
181
|
+
evidence.append("JS 栈帧形如 at f(path.ets:行:列)(命中 %d 帧)" % len(frames))
|
|
182
|
+
|
|
183
|
+
if full:
|
|
184
|
+
if reason and JS_ERROR_REASON.search(reason) and len(evidence) >= 3:
|
|
185
|
+
return {"type": "js_crash", "evidence": evidence}
|
|
186
|
+
return None
|
|
187
|
+
return {"type": "js_crash", "evidence": evidence} if frames else None
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
def detect_app_freeze(sample, full):
|
|
191
|
+
evidence = []
|
|
192
|
+
m = FREEZE_EVENT.search(sample)
|
|
193
|
+
if m:
|
|
194
|
+
evidence.append("Reason/事件名为冻屏类型:%s" % m.group(1))
|
|
195
|
+
if HEADER_MSG.search(sample):
|
|
196
|
+
evidence.append("存在 MSG 字段(承载主线程队列)")
|
|
197
|
+
sections = count_thread_sections(sample)
|
|
198
|
+
if sections >= 2:
|
|
199
|
+
evidence.append("多线程分节结构(Tid/Name 分块)")
|
|
200
|
+
|
|
201
|
+
if full:
|
|
202
|
+
if m and len(evidence) >= 3:
|
|
203
|
+
return {"type": "app_freeze", "evidence": evidence}
|
|
204
|
+
return None
|
|
205
|
+
return {"type": "app_freeze", "evidence": evidence} if (sections >= 2 or m) else None
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
def detect_sample_stack(sample):
|
|
209
|
+
"""检出采样栈(增强日志)结构标记;命中不足 2 项不判(避免单字段巧合)。"""
|
|
210
|
+
return [label for pattern, label in SAMPLE_STACK_MARKERS if pattern.search(sample)]
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
def has_js_crash_structure(sample):
|
|
214
|
+
"""JSCrash faultlog 的结构特征计数(行首字段 + JS 栈帧,纯 HiLog 流水不会命中)。
|
|
215
|
+
|
|
216
|
+
JSCrash faultlog 内嵌 HiLog 段,hilog 行占比可能远超 60%;判 hilog_stream 前先
|
|
217
|
+
用此函数排除该情形。命中不足 2 项不豁免:流水日志打印出的 JS 栈帧等单一特征
|
|
218
|
+
不构成 faultlog 结构,不足以否定 hilog_stream 判定。
|
|
219
|
+
"""
|
|
220
|
+
reason = match_one(sample, HEADER_REASON)
|
|
221
|
+
hits = 0
|
|
222
|
+
if reason and JS_ERROR_REASON.search(reason):
|
|
223
|
+
hits += 1
|
|
224
|
+
if HEADER_ERROR_MESSAGE.search(sample):
|
|
225
|
+
hits += 1
|
|
226
|
+
if HEADER_STACKTRACE.search(sample):
|
|
227
|
+
hits += 1
|
|
228
|
+
if collect_js_frames(sample):
|
|
229
|
+
hits += 1
|
|
230
|
+
return hits >= 2
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
def detect_out_of_scope(sample):
|
|
234
|
+
if sample.strip() == "":
|
|
235
|
+
return {"reason": "empty", "detail": "输入为空文件或无内容"}
|
|
236
|
+
|
|
237
|
+
lines = [l for l in sample.split("\n") if l.strip() != ""]
|
|
238
|
+
if not lines:
|
|
239
|
+
return {"reason": "empty", "detail": "输入为空文件或无内容"}
|
|
240
|
+
|
|
241
|
+
hilog_hits = len([l for l in lines if HILOG_LINE.match(l)])
|
|
242
|
+
# JSCrash faultlog 内嵌 HiLog 段可致 hilog 占比超阈值,须先排除其结构特征。
|
|
243
|
+
if hilog_hits / len(lines) > 0.6 and not has_js_crash_structure(sample):
|
|
244
|
+
return {"reason": "hilog_stream", "detail": "输入为 HiLog 流水日志,非 FaultLog,无法进行故障类型分诊"}
|
|
245
|
+
if ANDROID_LOGCAT.match(lines[0]):
|
|
246
|
+
return {"reason": "non_harmonyos", "detail": "输入为 Android logcat 等非鸿蒙平台日志"}
|
|
247
|
+
return None
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
def detect_memory_corruption(sample, fault_type):
|
|
251
|
+
if fault_type != "cpp_crash":
|
|
252
|
+
return None
|
|
253
|
+
evidence = []
|
|
254
|
+
reason = match_one(sample, HEADER_REASON) or ""
|
|
255
|
+
if re.search(r"\bSIGSEGV\b", reason, re.IGNORECASE):
|
|
256
|
+
addr = re.search(r"0x[0-9a-fA-F]+", reason, re.IGNORECASE)
|
|
257
|
+
if addr:
|
|
258
|
+
v = int(addr.group(0), 16)
|
|
259
|
+
if 0 < v < 0x10000:
|
|
260
|
+
evidence.append("崩溃地址 %s 落在低地址区间,疑似踩内存目标" % addr.group(0))
|
|
261
|
+
if re.search(r"0x[a-fA-F0-9]{8}\b", sample, re.IGNORECASE):
|
|
262
|
+
fill = re.search(r"\b0x(61616161|deadbeef|beefbeef|00)+\b", sample, re.IGNORECASE)
|
|
263
|
+
if fill:
|
|
264
|
+
evidence.append("疑似填充模式命中:0x%s" % fill.group(1))
|
|
265
|
+
if re.search(r"SIGABRT", reason, re.IGNORECASE) and re.search(r"stack|overflow|corrupt", sample, re.IGNORECASE):
|
|
266
|
+
evidence.append("SIGABRT 且上下文含 stack/corrupt 关键字")
|
|
267
|
+
if not evidence:
|
|
268
|
+
return {"suspected": False, "confidence": "low", "evidence": ["未命中踩内存正向特征"]}
|
|
269
|
+
confidence = "medium" if len(evidence) >= 2 else "low"
|
|
270
|
+
return {"suspected": True, "confidence": confidence, "evidence": evidence}
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
def confidence_for(hit, full, arbitrated):
|
|
274
|
+
if not full:
|
|
275
|
+
return "medium" if arbitrated else "low"
|
|
276
|
+
if hit["type"] == "app_freeze":
|
|
277
|
+
return "high" if len(hit["evidence"]) >= 3 else "medium"
|
|
278
|
+
return "high" if len(hit["evidence"]) >= 4 else "medium"
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
def exclusion_reason(fault_type, sample, full):
|
|
282
|
+
if not full:
|
|
283
|
+
if fault_type == "cpp_crash":
|
|
284
|
+
return "未命中 Native 栈帧正向特征"
|
|
285
|
+
if fault_type == "js_crash":
|
|
286
|
+
return "未命中 JS 栈帧正向特征"
|
|
287
|
+
return "未命中多线程分节或冻屏事件名正向特征"
|
|
288
|
+
|
|
289
|
+
reason = match_one(sample, HEADER_REASON)
|
|
290
|
+
if fault_type == "cpp_crash":
|
|
291
|
+
missing = []
|
|
292
|
+
if not (reason and SIGNAL_REASON.search(reason)):
|
|
293
|
+
missing.append("Signal 形态的 Reason")
|
|
294
|
+
if not HEADER_REGISTERS.search(sample):
|
|
295
|
+
missing.append("Registers 段")
|
|
296
|
+
if not collect_native_frames(sample):
|
|
297
|
+
missing.append("Native 栈帧")
|
|
298
|
+
elif fault_type == "js_crash":
|
|
299
|
+
missing = []
|
|
300
|
+
if not (reason and JS_ERROR_REASON.search(reason)):
|
|
301
|
+
missing.append("JS 错误类名的 Reason")
|
|
302
|
+
if not HEADER_ERROR_MESSAGE.search(sample):
|
|
303
|
+
missing.append("Error message 字段")
|
|
304
|
+
if not HEADER_STACKTRACE.search(sample):
|
|
305
|
+
missing.append("Stacktrace 字段")
|
|
306
|
+
if not collect_js_frames(sample):
|
|
307
|
+
missing.append("JS 栈帧")
|
|
308
|
+
else:
|
|
309
|
+
missing = []
|
|
310
|
+
if not FREEZE_EVENT.search(sample):
|
|
311
|
+
missing.append("冻屏事件名")
|
|
312
|
+
if not HEADER_MSG.search(sample):
|
|
313
|
+
missing.append("MSG 字段")
|
|
314
|
+
if count_thread_sections(sample) < 2:
|
|
315
|
+
missing.append("多线程分节")
|
|
316
|
+
return "缺少:%s" % "、".join(missing) if missing else "正向特征未达到完整日志判定阈值"
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
def build_excluded(hits, full, sample):
|
|
320
|
+
present = set(h["type"] for h in hits)
|
|
321
|
+
return [
|
|
322
|
+
{"type": t, "reason": exclusion_reason(t, sample, full)}
|
|
323
|
+
for t in ("cpp_crash", "js_crash", "app_freeze")
|
|
324
|
+
if t not in present
|
|
325
|
+
]
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
def classify(sample):
|
|
329
|
+
out_of_scope = detect_out_of_scope(sample)
|
|
330
|
+
if out_of_scope:
|
|
331
|
+
return {
|
|
332
|
+
"type": "unknown",
|
|
333
|
+
"confidence": "low",
|
|
334
|
+
"completeness": "fragment",
|
|
335
|
+
"evidence": [],
|
|
336
|
+
"excluded": [],
|
|
337
|
+
"candidates": [],
|
|
338
|
+
"out_of_scope": out_of_scope,
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
full = has_header_region(sample)
|
|
342
|
+
sample_markers = detect_sample_stack(sample)
|
|
343
|
+
hits = []
|
|
344
|
+
for detect in (detect_cpp_crash, detect_js_crash, detect_app_freeze):
|
|
345
|
+
hit = detect(sample, full)
|
|
346
|
+
if hit:
|
|
347
|
+
hits.append(hit)
|
|
348
|
+
|
|
349
|
+
# 完整 faultlog 与采样栈标记共存(两份内容合入同一输入)时,faultlog 类型优先。
|
|
350
|
+
if hits and full:
|
|
351
|
+
result = verdict_from_hits(hits, full, sample)
|
|
352
|
+
if sample_markers:
|
|
353
|
+
result["evidence"] = result["evidence"] + [
|
|
354
|
+
"同时检出采样栈(增强日志)结构标记(%d 项),可作为冻屏分析配套证据" % len(sample_markers)
|
|
355
|
+
]
|
|
356
|
+
return result
|
|
357
|
+
|
|
358
|
+
# 采样栈标记存在而无完整 faultlog:其 native 帧为周期快照采样,不作为崩溃证据,
|
|
359
|
+
# 片段模式的故障命中一律让位于 sample_stack 判定。
|
|
360
|
+
if sample_markers:
|
|
361
|
+
strong = len(sample_markers) >= 3
|
|
362
|
+
return {
|
|
363
|
+
"type": "sample_stack",
|
|
364
|
+
"confidence": "high" if strong else "medium",
|
|
365
|
+
"completeness": "full" if strong else "fragment",
|
|
366
|
+
"evidence": ["采样栈(增强日志)结构标记:%s" % "、".join(sample_markers)],
|
|
367
|
+
"excluded": [
|
|
368
|
+
{"type": "cpp_crash", "reason": "输入为采样栈(增强日志):native 帧为周期快照,非崩溃 faultlog"},
|
|
369
|
+
{"type": "js_crash", "reason": "输入为采样栈(增强日志):无 JS 错误 Reason / Stacktrace 结构"},
|
|
370
|
+
{"type": "app_freeze", "reason": "输入为采样栈(增强日志):无冻屏事件名 / MSG 字段,需配套冻屏 faultlog 定类"},
|
|
371
|
+
],
|
|
372
|
+
"candidates": [],
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
if not hits:
|
|
376
|
+
return {
|
|
377
|
+
"type": "unknown",
|
|
378
|
+
"confidence": "low",
|
|
379
|
+
"completeness": "full" if full else "fragment",
|
|
380
|
+
"evidence": [],
|
|
381
|
+
"excluded": build_excluded(hits, full, sample),
|
|
382
|
+
"candidates": [],
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
return verdict_from_hits(hits, full, sample)
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
def verdict_from_hits(hits, full, sample):
|
|
389
|
+
"""由故障检测结果产出最终判定(单命中 / 片段双栈仲裁 / 多候选澄清)。"""
|
|
390
|
+
if len(hits) == 1:
|
|
391
|
+
hit = hits[0]
|
|
392
|
+
result = {
|
|
393
|
+
"type": hit["type"],
|
|
394
|
+
"confidence": confidence_for(hit, full, False),
|
|
395
|
+
"completeness": "full" if full else "fragment",
|
|
396
|
+
"evidence": hit["evidence"],
|
|
397
|
+
"excluded": build_excluded(hits, full, sample),
|
|
398
|
+
"candidates": [],
|
|
399
|
+
}
|
|
400
|
+
if hit["type"] == "cpp_crash":
|
|
401
|
+
result["memory_corruption_suspect"] = detect_memory_corruption(sample, hit["type"])
|
|
402
|
+
if hit["type"] == "app_freeze":
|
|
403
|
+
m = FREEZE_EVENT.search(sample)
|
|
404
|
+
if m:
|
|
405
|
+
result["subtype"] = m.group(1)
|
|
406
|
+
return result
|
|
407
|
+
|
|
408
|
+
# Multi-candidate. Fragment dual-stack (native + js) -> deterministic arbitration, prefer cpp_crash.
|
|
409
|
+
types = set(h["type"] for h in hits)
|
|
410
|
+
if "cpp_crash" in types and "js_crash" in types and not full:
|
|
411
|
+
primary = next(h for h in hits if h["type"] == "cpp_crash")
|
|
412
|
+
secondary = next(h for h in hits if h["type"] == "js_crash")
|
|
413
|
+
return {
|
|
414
|
+
"type": "cpp_crash",
|
|
415
|
+
"confidence": "medium",
|
|
416
|
+
"completeness": "fragment",
|
|
417
|
+
"evidence": primary["evidence"],
|
|
418
|
+
"excluded": build_excluded([primary, secondary], full, sample),
|
|
419
|
+
"candidates": [
|
|
420
|
+
{"type": "js_crash", "confidence": "low", "evidence": secondary["evidence"]}
|
|
421
|
+
],
|
|
422
|
+
"memory_corruption_suspect": detect_memory_corruption(sample, "cpp_crash"),
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
# Multi-candidate, no deterministic arbitration rule available -> clarification.
|
|
426
|
+
return {
|
|
427
|
+
"type": "unknown",
|
|
428
|
+
"confidence": "low",
|
|
429
|
+
"completeness": "full" if full else "fragment",
|
|
430
|
+
"evidence": [],
|
|
431
|
+
"excluded": build_excluded(hits, full, sample),
|
|
432
|
+
"candidates": [
|
|
433
|
+
{
|
|
434
|
+
"type": h["type"],
|
|
435
|
+
"confidence": confidence_for(h, full, False),
|
|
436
|
+
"evidence": h["evidence"],
|
|
437
|
+
}
|
|
438
|
+
for h in hits
|
|
439
|
+
],
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
def sample_bytes(data, size):
|
|
444
|
+
total = len(data)
|
|
445
|
+
if total <= size:
|
|
446
|
+
text = data.decode("utf-8", errors="replace")
|
|
447
|
+
else:
|
|
448
|
+
half = size // 2
|
|
449
|
+
head = data[: half]
|
|
450
|
+
tail_start = max(0, total - half)
|
|
451
|
+
tail = data[tail_start:]
|
|
452
|
+
text = head.decode("utf-8", errors="replace") + "\n…(中段省略)…\n" + tail.decode("utf-8", errors="replace")
|
|
453
|
+
return strip_bom(normalize_crlf(text))
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
def run(args):
|
|
457
|
+
if not args.path and not args.stdin:
|
|
458
|
+
print("Error: identify_fault_log requires either --path or --stdin.", file=sys.stderr)
|
|
459
|
+
return 1
|
|
460
|
+
|
|
461
|
+
if args.stdin:
|
|
462
|
+
content = sys.stdin.read()
|
|
463
|
+
data = content.encode("utf-8")
|
|
464
|
+
if len(data) > MAX_BYTES:
|
|
465
|
+
print(
|
|
466
|
+
'Error: input oversize. {"reason": "oversize", "limit_mb": %d, "size": %d, "remediation": "head/tail 256KB sampling is built-in for inputs up to 20MB; for larger logs, extract the head and tail sections (header fields + fault thread stack) into a smaller file and retry."}'
|
|
467
|
+
% (MAX_BYTES // 1024 // 1024, len(data)),
|
|
468
|
+
file=sys.stderr,
|
|
469
|
+
)
|
|
470
|
+
return 1
|
|
471
|
+
else:
|
|
472
|
+
filepath = args.path
|
|
473
|
+
if not os.path.isfile(filepath):
|
|
474
|
+
print("Error: Fault log not found or not a regular file: %s" % filepath, file=sys.stderr)
|
|
475
|
+
return 1
|
|
476
|
+
size = os.path.getsize(filepath)
|
|
477
|
+
if size > MAX_BYTES:
|
|
478
|
+
print(
|
|
479
|
+
'Error: input oversize. {"reason": "oversize", "limit_mb": %d, "size": %d, "remediation": "head/tail 256KB sampling is built-in for inputs up to 20MB; for larger logs, extract the head and tail sections (header fields + fault thread stack) into a smaller file and retry."}'
|
|
480
|
+
% (MAX_BYTES // 1024 // 1024, size),
|
|
481
|
+
file=sys.stderr,
|
|
482
|
+
)
|
|
483
|
+
return 1
|
|
484
|
+
with open(filepath, "rb") as f:
|
|
485
|
+
data = f.read()
|
|
486
|
+
|
|
487
|
+
result = classify(sample_bytes(data, SAMPLE_HEAD + SAMPLE_TAIL))
|
|
488
|
+
print(json.dumps(result, ensure_ascii=False, indent=2))
|
|
489
|
+
return 0
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
def main():
|
|
493
|
+
parser = argparse.ArgumentParser(description="Deterministic HarmonyOS fault-log type identifier.")
|
|
494
|
+
parser.add_argument("--path", help="Path to a HarmonyOS faultlog file")
|
|
495
|
+
parser.add_argument("--stdin", action="store_true", help="Read pasted log content from stdin")
|
|
496
|
+
sys.exit(run(parser.parse_args()))
|
|
497
|
+
|
|
498
|
+
|
|
499
|
+
if __name__ == "__main__":
|
|
500
|
+
main()
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
+
<title>{{TITLE}}</title>
|
|
7
|
+
<style>
|
|
8
|
+
:root { color-scheme: light; }
|
|
9
|
+
* { box-sizing: border-box; }
|
|
10
|
+
html { scroll-behavior: smooth; }
|
|
11
|
+
body { font-family: -apple-system, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
|
|
12
|
+
color: #1f2328; background: #f6f8fa; margin: 0; padding: 24px; line-height: 1.65; }
|
|
13
|
+
.layout { max-width: 1232px; margin: 0 auto; display: flex; gap: 32px; align-items: flex-start; }
|
|
14
|
+
.page { flex: 1 1 auto; min-width: 0; max-width: 960px; background: #fff; border: 1px solid #d0d7de;
|
|
15
|
+
border-radius: 10px; padding: 32px 40px; box-shadow: 0 1px 3px rgba(31,35,40,.08); }
|
|
16
|
+
h1 { font-size: 22px; border-bottom: 1px solid #d8dee4; padding-bottom: 10px; margin-top: 0; }
|
|
17
|
+
h2 { font-size: 18px; border-bottom: 1px solid #eaeef2; padding-bottom: 6px; margin-top: 28px; }
|
|
18
|
+
h3 { font-size: 16px; margin-top: 22px; }
|
|
19
|
+
h4, h5, h6 { font-size: 14px; margin-top: 18px; }
|
|
20
|
+
h1, h2, h3, h4, h5, h6 { scroll-margin-top: 16px; }
|
|
21
|
+
.meta { color: #57606a; font-size: 13px; margin-bottom: 20px; }
|
|
22
|
+
.meta .badge { display: inline-block; background: #ddf4ff; color: #0969da; border: 1px solid #54aeff;
|
|
23
|
+
border-radius: 999px; padding: 1px 10px; margin-right: 10px; font-weight: 600; }
|
|
24
|
+
.table-wrap { overflow-x: auto; margin: 12px 0; }
|
|
25
|
+
table { border-collapse: collapse; width: 100%; margin: 0; font-size: 14px; }
|
|
26
|
+
th, td { border: 1px solid #d8dee4; padding: 6px 12px; text-align: left; vertical-align: top; }
|
|
27
|
+
th { background: #f6f8fa; }
|
|
28
|
+
code { font-family: ui-monospace, SFMono-Regular, 'JetBrains Mono', Consolas, monospace;
|
|
29
|
+
background: #eff1f3; border-radius: 4px; padding: 1px 5px; font-size: 13px; }
|
|
30
|
+
pre { background: #f6f8fa; border: 1px solid #d8dee4; border-radius: 8px; padding: 14px 16px;
|
|
31
|
+
overflow: auto; line-height: 1.5; max-height: 70vh; }
|
|
32
|
+
pre code { background: none; padding: 0; font-size: 13px; white-space: pre; }
|
|
33
|
+
.tok-kw { color: #cf222e; font-weight: 600; }
|
|
34
|
+
.tok-str { color: #0a3069; }
|
|
35
|
+
.tok-com { color: #6e7781; font-style: italic; }
|
|
36
|
+
.tok-num { color: #0550ae; }
|
|
37
|
+
.diff-ins { color: #116329; background: #dafbe1; display: block; }
|
|
38
|
+
.diff-del { color: #82071e; background: #ffebe9; display: block; }
|
|
39
|
+
.diff-hunk { color: #0550ae; background: #ddf4ff; display: block; }
|
|
40
|
+
.diff-file { color: #57606a; background: #eff1f3; display: block; }
|
|
41
|
+
.diff-txt { display: block; }
|
|
42
|
+
hr { border: none; border-top: 1px solid #d8dee4; margin: 20px 0; }
|
|
43
|
+
blockquote { border-left: 3px solid #54aeff; background: #f6f8fa; color: #57606a;
|
|
44
|
+
margin: 12px 0; padding: 8px 16px; border-radius: 0 6px 6px 0; }
|
|
45
|
+
blockquote p { margin: 4px 0; }
|
|
46
|
+
.footer { color: #6e7781; font-size: 12px; margin-top: 32px; border-top: 1px solid #eaeef2; padding-top: 12px; }
|
|
47
|
+
.toc { flex: 0 0 240px; position: sticky; top: 24px; max-height: calc(100vh - 48px);
|
|
48
|
+
overflow-y: auto; font-size: 13px; line-height: 1.5; padding: 6px 0 6px 14px;
|
|
49
|
+
border-left: 2px solid #eaeef2; }
|
|
50
|
+
.toc:empty { display: none; }
|
|
51
|
+
.toc .toc-title { font-weight: 600; color: #1f2328; margin-bottom: 6px; font-size: 12px;
|
|
52
|
+
letter-spacing: .5px; }
|
|
53
|
+
.toc a { display: block; color: #57606a; text-decoration: none; padding: 3px 6px; border-radius: 6px; }
|
|
54
|
+
.toc a:hover { color: #0969da; background: #f6f8fa; }
|
|
55
|
+
.toc a.active { color: #0969da; background: #ddf4ff; font-weight: 600; }
|
|
56
|
+
.toc a.toc-1 { font-weight: 600; }
|
|
57
|
+
.toc a.toc-2 { padding-left: 16px; }
|
|
58
|
+
@media (max-width: 1200px) { .toc { display: none; } }
|
|
59
|
+
@media print {
|
|
60
|
+
body { background: #fff; padding: 0; }
|
|
61
|
+
.layout { display: block; max-width: none; }
|
|
62
|
+
.page { border: none; box-shadow: none; max-width: none; }
|
|
63
|
+
.toc { display: none; }
|
|
64
|
+
pre { max-height: none; }
|
|
65
|
+
.table-wrap { overflow: visible; }
|
|
66
|
+
th, td { overflow-wrap: anywhere; }
|
|
67
|
+
}
|
|
68
|
+
</style>
|
|
69
|
+
</head>
|
|
70
|
+
<body>
|
|
71
|
+
<div class="layout">
|
|
72
|
+
<div class="page">
|
|
73
|
+
<h1>{{TITLE}}</h1>
|
|
74
|
+
<div class="meta"><span class="badge">{{TYPE_LABEL}}</span>生成时间:{{GENERATED_AT}}</div>
|
|
75
|
+
{{BODY}}
|
|
76
|
+
<div class="footer">本报告由 DevEco Code DFX 故障分析生成 · 代码块含语法高亮,修复建议含源码差异对比</div>
|
|
77
|
+
</div>
|
|
78
|
+
<nav class="toc" id="dfx-toc">{{TOC}}</nav>
|
|
79
|
+
</div>
|
|
80
|
+
<script>
|
|
81
|
+
(function () {
|
|
82
|
+
var nav = document.getElementById("dfx-toc");
|
|
83
|
+
var links = nav ? Array.prototype.slice.call(nav.querySelectorAll("a[href^='#']")) : [];
|
|
84
|
+
if (!links.length) return;
|
|
85
|
+
var targets = [];
|
|
86
|
+
links.forEach(function (a) {
|
|
87
|
+
var el = document.getElementById(a.getAttribute("href").slice(1));
|
|
88
|
+
if (el) targets.push(el);
|
|
89
|
+
});
|
|
90
|
+
function update() {
|
|
91
|
+
var pos = window.scrollY + 96;
|
|
92
|
+
var idx = 0;
|
|
93
|
+
for (var i = 0; i < targets.length; i++) {
|
|
94
|
+
if (targets[i].offsetTop <= pos) idx = i;
|
|
95
|
+
}
|
|
96
|
+
links.forEach(function (a, i) { a.classList.toggle("active", i === idx); });
|
|
97
|
+
}
|
|
98
|
+
window.addEventListener("scroll", update, { passive: true });
|
|
99
|
+
update();
|
|
100
|
+
})();
|
|
101
|
+
</script>
|
|
102
|
+
</body>
|
|
103
|
+
</html>
|