feihong-code 7.5.0 → 7.6.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/.github/workflows/ci.yml +193 -180
- package/.github/workflows/release.yml +203 -200
- package/.github/workflows/swebench-real.yml +84 -0
- package/CHANGELOG.md +117 -94
- package/CONTRIBUTING.md +9 -2
- package/README.md +636 -609
- package/README.self-evolve.md +279 -274
- package/dist/agent/change-manager.js +1 -1
- package/dist/agent/code-rag.js +1 -1
- package/dist/agent/code-review.js +1 -1
- package/dist/agent/code-writer.js +1 -1
- package/dist/agent/completion-postprocess.js +1 -1
- package/dist/agent/context-compactor.js +11 -0
- package/dist/agent/context-compactor.js.map +1 -1
- package/dist/agent/custom-agent.js +52 -52
- package/dist/agent/design-to-code.js +40 -40
- package/dist/agent/experience.js +1 -1
- package/dist/agent/layered-memory.js +1 -1
- package/dist/agent/lint.js +1 -1
- package/dist/agent/multi-agent.js +44 -44
- package/dist/agent/orchestrator.js +93 -18
- package/dist/agent/orchestrator.js.map +1 -1
- package/dist/agent/parallel-orchestrator.js +1 -1
- package/dist/agent/planner.js +8 -3
- package/dist/agent/planner.js.map +1 -1
- package/dist/agent/prompts.js +2 -2
- package/dist/agent/quality-gate.js +1 -1
- package/dist/agent/repo-context.js +1 -1
- package/dist/agent/repo-reader.js +1 -1
- package/dist/agent/repo-underwriter.js +1 -1
- package/dist/agent/self-correction.js +1 -1
- package/dist/agent/self-heal.js +5 -0
- package/dist/agent/self-heal.js.map +1 -1
- package/dist/agent/self-improver.js +1 -1
- package/dist/agent/subagent-summary.js +1 -1
- package/dist/agent/subagent.js +1 -1
- package/dist/agent/swe-agent.js +1 -1
- package/dist/agent/swe-verifier.js +1 -1
- package/dist/agent/symbol-index.js +1 -1
- package/dist/agent/team.js +1 -1
- package/dist/agent/type-checker.js +1 -1
- package/dist/cli/commands.js +7 -0
- package/dist/cli/commands.js.map +1 -1
- package/dist/cli/index.js +57 -2
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/repl.js +1 -1
- package/dist/cli/run.js +40 -3
- package/dist/cli/run.js.map +1 -1
- package/dist/cli/self-evolve-cli.js +168 -0
- package/dist/cli/tui-run.js +1 -1
- package/dist/cli/tui.js +1 -1
- package/dist/cli/version.js +3 -3
- package/dist/cli/version.js.map +1 -1
- package/dist/enterprise/audit.js +1 -1
- package/dist/enterprise/index.js +1 -1
- package/dist/enterprise/policy.js +1 -1
- package/dist/enterprise/quota.js +1 -1
- package/dist/enterprise/tenant.js +1 -1
- package/dist/harness/executor.js +1 -1
- package/dist/harness/index.js +1 -1
- package/dist/harness/loader.js +1 -1
- package/dist/harness/types.js +1 -1
- package/dist/harness/verifier.js +52 -12
- package/dist/harness/verifier.js.map +1 -1
- package/dist/hello.js +14 -0
- package/dist/hello.js.map +1 -0
- package/dist/integrations/feishu-bridge.js +348 -0
- package/dist/integrations/feishu-bridge.js.map +1 -0
- package/dist/integrations/github-mcp.js +137 -0
- package/dist/integrations/github-mcp.js.map +1 -0
- package/dist/integrations/wechat-bridge.js +499 -0
- package/dist/integrations/wechat-bridge.js.map +1 -0
- package/dist/integrations/yuanbao-bridge.js +326 -0
- package/dist/integrations/yuanbao-bridge.js.map +1 -0
- package/dist/lsp/lsp-client.js +1 -1
- package/dist/models/model-router.js +1 -1
- package/dist/models/model.dto.js +1 -1
- package/dist/models/providers/ollama.provider.js +1 -1
- package/dist/models/providers/openai-compatible.provider.js +1 -1
- package/dist/plugins/plugin-loader.js +1 -1
- package/dist/runtime/event-log.js +1 -1
- package/dist/runtime/git.js +1 -1
- package/dist/runtime/hooks.js +71 -4
- package/dist/runtime/hooks.js.map +1 -1
- package/dist/runtime/session-persist.js +1 -1
- package/dist/runtime/worktree.js +1 -1
- package/dist/self-evolve/hook.ts +80 -0
- package/dist/self-evolve/manager.d.ts +8 -0
- package/dist/self-evolve/manager.js +517 -401
- package/dist/self-evolve/self-heal-scheduler.js +160 -0
- package/dist/self-evolve/self-heal-scheduler.js.map +1 -0
- package/dist/shared/concurrency.js +1 -1
- package/dist/shared/config.js +4 -2
- package/dist/shared/config.js.map +1 -1
- package/dist/shared/errors.js +1 -1
- package/dist/shared/i18n.js +1 -1
- package/dist/shared/i18n.js.map +1 -1
- package/dist/shared/secure-store.js +12 -5
- package/dist/shared/secure-store.js.map +1 -1
- package/dist/shared/types.js +1 -1
- package/dist/skills/goal.js +1 -1
- package/dist/skills/grill.js +1 -1
- package/dist/skills/plan.js +1 -1
- package/dist/skills/pua-hooks.js +273 -0
- package/dist/skills/pua-hooks.js.map +1 -0
- package/dist/skills/self-heal.js +9 -3
- package/dist/skills/self-heal.js.map +1 -1
- package/dist/skills/skill-loader.js +1 -1
- package/dist/skills/skill-market.js +84 -8
- package/dist/skills/skill-market.js.map +1 -1
- package/dist/tools/analysis/code-analyzer.js +1 -1
- package/dist/tools/file/edit.tool.js +18 -3
- package/dist/tools/file/edit.tool.js.map +1 -1
- package/dist/tools/file/list.tool.js +1 -1
- package/dist/tools/file/read.tool.js +1 -1
- package/dist/tools/file/write.tool.js +1 -1
- package/dist/tools/generator/code-generator.js +1 -1
- package/dist/tools/generator/test-generator.js +1 -1
- package/dist/tools/index.js +1 -1
- package/dist/tools/mcp/index.js +1 -1
- package/dist/tools/mcp/mcp-client.js +1 -1
- package/dist/tools/safe-path.js +1 -1
- package/dist/tools/search/grep.tool.js +1 -1
- package/dist/tools/shell/exec.js +1 -1
- package/dist/tools/shell/run-shell.tool.js +1 -1
- package/dist/tools/skills/load-skill.tool.js +1 -1
- package/dist/tools/tool.registry.js +10 -1
- package/dist/tools/tool.registry.js.map +1 -1
- package/dist/tools/verify/build-check.tool.js +1 -1
- package/dist/tools/verify/test-run.tool.js +1 -1
- package/dist/tools/web/web.tool.js +1 -1
- package/dist/voice/voice-programming.js +32 -6
- package/dist/voice/voice-programming.js.map +1 -1
- package/dist/web/auth.js +34 -2
- package/dist/web/auth.js.map +1 -1
- package/dist/web/channels.js +1 -1
- package/dist/web/public/css/style.css +1751 -1724
- package/dist/web/public/index.html +1243 -1242
- package/dist/web/public/js/api.js +558 -555
- package/dist/web/public/js/app.js +2233 -2210
- package/dist/web/public/js/mock-api.js +259 -234
- package/dist/web/public/js/monaco-editor.js +363 -363
- package/dist/web/public/js/ui.js +2217 -2251
- package/dist/web/public/js/utils.js +214 -214
- package/dist/web/public/manifest.json +59 -59
- package/dist/web/public/service-worker.js +149 -173
- package/dist/web/public/vendor/monaco/vs/abap-D-t0cyap.js +1 -0
- package/dist/web/public/vendor/monaco/vs/apex-CcIm7xu6.js +1 -0
- package/dist/web/public/vendor/monaco/vs/assets/css.worker-URu8fCFR.js +97 -0
- package/dist/web/public/vendor/monaco/vs/assets/editor.worker-lj3bdIIn.js +30 -0
- package/dist/web/public/vendor/monaco/vs/assets/editorWebWorkerMain-CA_vMoUU.js +30 -0
- package/dist/web/public/vendor/monaco/vs/assets/html.worker-D1SL3iM8.js +474 -0
- package/dist/web/public/vendor/monaco/vs/assets/json.worker-CoJx_OPf.js +62 -0
- package/dist/web/public/vendor/monaco/vs/assets/ts.worker-BWKtMYOk.js +67722 -0
- package/dist/web/public/vendor/monaco/vs/azcli-BA0tQDCg.js +1 -0
- package/dist/web/public/vendor/monaco/vs/basic-languages/monaco.contribution.js +1 -0
- package/dist/web/public/vendor/monaco/vs/bat-C397hTD6.js +1 -0
- package/dist/web/public/vendor/monaco/vs/bicep-DF5aW17k.js +2 -0
- package/dist/web/public/vendor/monaco/vs/cameligo-plsz8qhj.js +1 -0
- package/dist/web/public/vendor/monaco/vs/clojure-Y2auQMzK.js +1 -0
- package/dist/web/public/vendor/monaco/vs/coffee-Bu45yuWE.js +1 -0
- package/dist/web/public/vendor/monaco/vs/cpp-CkKPQIni.js +1 -0
- package/dist/web/public/vendor/monaco/vs/csharp-CX28MZyh.js +1 -0
- package/dist/web/public/vendor/monaco/vs/csp-D8uWnyxW.js +1 -0
- package/dist/web/public/vendor/monaco/vs/css-CaeNmE3S.js +3 -0
- package/dist/web/public/vendor/monaco/vs/css.worker-CyhWkhHo.js +1 -0
- package/dist/web/public/vendor/monaco/vs/cssMode-CV6Ay48H.js +1 -0
- package/dist/web/public/vendor/monaco/vs/cypher-DVThT8BS.js +1 -0
- package/dist/web/public/vendor/monaco/vs/dart-CmGfCvrO.js +1 -0
- package/dist/web/public/vendor/monaco/vs/dockerfile-CZqqYdch.js +1 -0
- package/dist/web/public/vendor/monaco/vs/ecl-30fUercY.js +1 -0
- package/dist/web/public/vendor/monaco/vs/editor/editor.main.css +1 -0
- package/dist/web/public/vendor/monaco/vs/editor/editor.main.js +1 -0
- package/dist/web/public/vendor/monaco/vs/editor/editor.worker.js +1 -0
- package/dist/web/public/vendor/monaco/vs/editor-KLE6jdfb.js +831 -0
- package/dist/web/public/vendor/monaco/vs/editor.js +1 -0
- package/dist/web/public/vendor/monaco/vs/editorWorkerHost-fVE1cjcC.js +35 -0
- package/dist/web/public/vendor/monaco/vs/elixir-xjPaIfzF.js +1 -0
- package/dist/web/public/vendor/monaco/vs/flow9-DqtmStfK.js +1 -0
- package/dist/web/public/vendor/monaco/vs/freemarker2-FWreY7v7.js +3 -0
- package/dist/web/public/vendor/monaco/vs/fsharp-BOMdg4U1.js +1 -0
- package/dist/web/public/vendor/monaco/vs/go-D_hbi-Jt.js +1 -0
- package/dist/web/public/vendor/monaco/vs/graphql-CKUU4kLG.js +1 -0
- package/dist/web/public/vendor/monaco/vs/handlebars-CZi4pHCH.js +1 -0
- package/dist/web/public/vendor/monaco/vs/hcl-DTaboeZW.js +1 -0
- package/dist/web/public/vendor/monaco/vs/html-j_7ZTNRU.js +1 -0
- package/dist/web/public/vendor/monaco/vs/html.worker-CA3iAimZ.js +1 -0
- package/dist/web/public/vendor/monaco/vs/htmlMode-27by_KM4.js +1 -0
- package/dist/web/public/vendor/monaco/vs/index-049xrXrp.js +1 -0
- package/dist/web/public/vendor/monaco/vs/index-CBVt3dzv.js +5 -0
- package/dist/web/public/vendor/monaco/vs/index.js +1 -0
- package/dist/web/public/vendor/monaco/vs/ini-CsNwO04R.js +1 -0
- package/dist/web/public/vendor/monaco/vs/initialize-DL0l1TGY.js +1 -0
- package/dist/web/public/vendor/monaco/vs/java-CI4ZMsH9.js +1 -0
- package/dist/web/public/vendor/monaco/vs/javascript-DTJl4Jn1.js +1 -0
- package/dist/web/public/vendor/monaco/vs/json.worker-BizpAl9O.js +1 -0
- package/dist/web/public/vendor/monaco/vs/jsonMode-DLUiMUrI.js +1 -0
- package/dist/web/public/vendor/monaco/vs/julia-BwzEvaQw.js +1 -0
- package/dist/web/public/vendor/monaco/vs/kotlin-IUYPiTV8.js +1 -0
- package/dist/web/public/vendor/monaco/vs/language/css/css.worker.js +66 -0
- package/dist/web/public/vendor/monaco/vs/language/css/monaco.contribution.js +1 -0
- package/dist/web/public/vendor/monaco/vs/language/html/html.worker.js +443 -0
- package/dist/web/public/vendor/monaco/vs/language/html/monaco.contribution.js +1 -0
- package/dist/web/public/vendor/monaco/vs/language/json/json.worker.js +17 -0
- package/dist/web/public/vendor/monaco/vs/language/json/monaco.contribution.js +1 -0
- package/dist/web/public/vendor/monaco/vs/language/typescript/monaco.contribution.js +1 -0
- package/dist/web/public/vendor/monaco/vs/language/typescript/ts.worker.js +67693 -0
- package/dist/web/public/vendor/monaco/vs/less-C0eDYdqa.js +2 -0
- package/dist/web/public/vendor/monaco/vs/lexon-iON-Kj97.js +1 -0
- package/dist/web/public/vendor/monaco/vs/liquid-CLJYelW6.js +1 -0
- package/dist/web/public/vendor/monaco/vs/loader.js +1368 -0
- package/dist/web/public/vendor/monaco/vs/lspLanguageFeatures-BIkJOWLw.js +2 -0
- package/dist/web/public/vendor/monaco/vs/lua-DtygF91M.js +1 -0
- package/dist/web/public/vendor/monaco/vs/m3-CsR4AuFi.js +1 -0
- package/dist/web/public/vendor/monaco/vs/main-BEx-Fmlo.js +15 -0
- package/dist/web/public/vendor/monaco/vs/main-DsK8pnKg.js +3 -0
- package/dist/web/public/vendor/monaco/vs/markdown-C_rD0bIw.js +1 -0
- package/dist/web/public/vendor/monaco/vs/mdx-CpzZIPHF.js +1 -0
- package/dist/web/public/vendor/monaco/vs/mips-CiYP61RB.js +1 -0
- package/dist/web/public/vendor/monaco/vs/monaco.contribution-9cKT3C7t.js +1 -0
- package/dist/web/public/vendor/monaco/vs/monaco.contribution-BE88ZNGY.js +1 -0
- package/dist/web/public/vendor/monaco/vs/monaco.contribution-BPhsneLd.js +1 -0
- package/dist/web/public/vendor/monaco/vs/monaco.contribution-BgRy6xDf.js +1 -0
- package/dist/web/public/vendor/monaco/vs/msdax-C38-sJlp.js +1 -0
- package/dist/web/public/vendor/monaco/vs/mysql-CdtbpvbG.js +1 -0
- package/dist/web/public/vendor/monaco/vs/nls/lang/cs.d.ts +1 -0
- package/dist/web/public/vendor/monaco/vs/nls/lang/cs.js +9 -0
- package/dist/web/public/vendor/monaco/vs/nls/lang/de.d.ts +1 -0
- package/dist/web/public/vendor/monaco/vs/nls/lang/de.js +9 -0
- package/dist/web/public/vendor/monaco/vs/nls/lang/es.d.ts +1 -0
- package/dist/web/public/vendor/monaco/vs/nls/lang/es.js +9 -0
- package/dist/web/public/vendor/monaco/vs/nls/lang/fr.d.ts +1 -0
- package/dist/web/public/vendor/monaco/vs/nls/lang/fr.js +9 -0
- package/dist/web/public/vendor/monaco/vs/nls/lang/it.d.ts +1 -0
- package/dist/web/public/vendor/monaco/vs/nls/lang/it.js +9 -0
- package/dist/web/public/vendor/monaco/vs/nls/lang/ja.d.ts +1 -0
- package/dist/web/public/vendor/monaco/vs/nls/lang/ja.js +9 -0
- package/dist/web/public/vendor/monaco/vs/nls/lang/ko.d.ts +1 -0
- package/dist/web/public/vendor/monaco/vs/nls/lang/ko.js +9 -0
- package/dist/web/public/vendor/monaco/vs/nls/lang/pl.d.ts +1 -0
- package/dist/web/public/vendor/monaco/vs/nls/lang/pl.js +9 -0
- package/dist/web/public/vendor/monaco/vs/nls/lang/pt-br.d.ts +1 -0
- package/dist/web/public/vendor/monaco/vs/nls/lang/pt-br.js +9 -0
- package/dist/web/public/vendor/monaco/vs/nls/lang/ru.d.ts +1 -0
- package/dist/web/public/vendor/monaco/vs/nls/lang/ru.js +9 -0
- package/dist/web/public/vendor/monaco/vs/nls/lang/tr.d.ts +1 -0
- package/dist/web/public/vendor/monaco/vs/nls/lang/tr.js +9 -0
- package/dist/web/public/vendor/monaco/vs/nls/lang/zh-cn.d.ts +1 -0
- package/dist/web/public/vendor/monaco/vs/nls/lang/zh-cn.js +9 -0
- package/dist/web/public/vendor/monaco/vs/nls/lang/zh-tw.d.ts +1 -0
- package/dist/web/public/vendor/monaco/vs/nls/lang/zh-tw.js +9 -0
- package/dist/web/public/vendor/monaco/vs/nls.messages-loader.js +1 -0
- package/dist/web/public/vendor/monaco/vs/objective-c-CntZFaHX.js +1 -0
- package/dist/web/public/vendor/monaco/vs/pascal-r6kuqfl_.js +1 -0
- package/dist/web/public/vendor/monaco/vs/pascaligo-BiXoTmXh.js +1 -0
- package/dist/web/public/vendor/monaco/vs/perl-DABw_TcH.js +1 -0
- package/dist/web/public/vendor/monaco/vs/pgsql-me_jFXeX.js +1 -0
- package/dist/web/public/vendor/monaco/vs/php-D_kh-9LK.js +1 -0
- package/dist/web/public/vendor/monaco/vs/pla-VfZjczW0.js +1 -0
- package/dist/web/public/vendor/monaco/vs/postiats-BBSzz8Pk.js +1 -0
- package/dist/web/public/vendor/monaco/vs/powerquery-Dt-g_2cc.js +1 -0
- package/dist/web/public/vendor/monaco/vs/powershell-B-7ap1zc.js +1 -0
- package/dist/web/public/vendor/monaco/vs/protobuf-BmtuEB1A.js +2 -0
- package/dist/web/public/vendor/monaco/vs/pug-BRpRNeEb.js +1 -0
- package/dist/web/public/vendor/monaco/vs/python-CqWUUgfu.js +1 -0
- package/dist/web/public/vendor/monaco/vs/qsharp-BzsFaUU9.js +1 -0
- package/dist/web/public/vendor/monaco/vs/r-f8dDdrp4.js +1 -0
- package/dist/web/public/vendor/monaco/vs/razor-hok5y9Km.js +1 -0
- package/dist/web/public/vendor/monaco/vs/redis-fvZQY4PI.js +1 -0
- package/dist/web/public/vendor/monaco/vs/redshift-45Et0LQi.js +1 -0
- package/dist/web/public/vendor/monaco/vs/restructuredtext-C7UUFKFD.js +1 -0
- package/dist/web/public/vendor/monaco/vs/ruby-CZO8zYTz.js +1 -0
- package/dist/web/public/vendor/monaco/vs/rust-Bfetafyc.js +1 -0
- package/dist/web/public/vendor/monaco/vs/sb-3GYllVck.js +1 -0
- package/dist/web/public/vendor/monaco/vs/scala-foMgrKo1.js +1 -0
- package/dist/web/public/vendor/monaco/vs/scheme-CHdMtr7p.js +1 -0
- package/dist/web/public/vendor/monaco/vs/scss-C1cmLt9V.js +3 -0
- package/dist/web/public/vendor/monaco/vs/shell-ClXCKCEW.js +1 -0
- package/dist/web/public/vendor/monaco/vs/solidity-MZ6ExpPy.js +1 -0
- package/dist/web/public/vendor/monaco/vs/sophia-DWkuSsPQ.js +1 -0
- package/dist/web/public/vendor/monaco/vs/sparql-AUGFYSyk.js +1 -0
- package/dist/web/public/vendor/monaco/vs/sql-32GpJSV2.js +1 -0
- package/dist/web/public/vendor/monaco/vs/st-CuDFIVZ_.js +1 -0
- package/dist/web/public/vendor/monaco/vs/swift-t-PfMj7W.js +1 -0
- package/dist/web/public/vendor/monaco/vs/systemverilog-Ch4vA8Yt.js +1 -0
- package/dist/web/public/vendor/monaco/vs/tcl-D74tq1nH.js +1 -0
- package/dist/web/public/vendor/monaco/vs/toggleHighContrast-qGX7E9o7.js +61 -0
- package/dist/web/public/vendor/monaco/vs/ts.worker-2QLmBukE.js +1 -0
- package/dist/web/public/vendor/monaco/vs/tsMode-B0S_kp2q.js +11 -0
- package/dist/web/public/vendor/monaco/vs/twig-C6taOxMV.js +1 -0
- package/dist/web/public/vendor/monaco/vs/typescript-_2t_511t.js +1 -0
- package/dist/web/public/vendor/monaco/vs/typespec-8OfoLt6R.js +1 -0
- package/dist/web/public/vendor/monaco/vs/vb-Dyb2648j.js +1 -0
- package/dist/web/public/vendor/monaco/vs/wgsl-BhLXMOR0.js +298 -0
- package/dist/web/public/vendor/monaco/vs/workers-BBttULjf.js +1 -0
- package/dist/web/public/vendor/monaco/vs/xml-cZjNDqDT.js +1 -0
- package/dist/web/public/vendor/monaco/vs/yaml-A1fOIdH6.js +1 -0
- package/dist/web/server.js +81 -16
- package/dist/web/server.js.map +1 -1
- package/dist/web/task-queue.js +6 -21
- package/dist/web/task-queue.js.map +1 -1
- package/dist/web/web-config.js +143 -0
- package/dist/web/web-config.js.map +1 -0
- package/docs/App/344/275/277/347/224/250/350/257/264/346/230/216/344/271/246.md +1 -1
- package/docs/App/346/212/200/346/234/257/350/257/264/346/230/216/344/271/246.md +1 -1
- package/docs/BENCHMARK_REPORT_en.md +386 -386
- package/docs/BENCHMARK_REPORT_zh.md +386 -386
- package/docs/DPA.md +65 -63
- package/docs/DPA/346/225/260/346/215/256/345/244/204/347/220/206/345/215/217/350/256/256/346/250/241/346/235/277_v1.0.md +69 -67
- package/docs/Deployment_Guide_EN.md +1 -1
- package/docs/SECURITY_WHITEPAPER.md +2 -2
- package/docs/SELF-EVOLVE-GUIDE.md +1 -1
- package/docs/SWE_BENCH_REPORT.md +73 -55
- package/docs/TECHNICAL_SPEC_en.md +292 -292
- package/docs/TECHNICAL_SPEC_zh.md +292 -292
- package/docs/Technical_Manual_EN.md +1 -1
- package/docs/UPDATE_NOTES_en.md +159 -159
- package/docs/UPDATE_NOTES_zh.md +159 -159
- package/docs/UPGRADE_7.2.0.md +309 -309
- package/docs/UPGRADE_GUIDE_7_5.md +86 -86
- package/docs/UPGRADE_GUIDE_7_6.md +153 -0
- package/docs/User_Manual_EN.md +1 -1
- package/docs/VOLTAGENT_SKILLS_CATALOG.md +95 -0
- package/docs/error-codes.md +1 -1
- package/docs/geo-feihong-code.html +391 -391
- package/docs//344/272/247/345/223/201/345/274/200/345/217/221/346/226/207/346/241/243.md +5 -3
- package/docs//344/275/277/347/224/250/350/257/264/346/230/216/344/271/246.md +140 -231
- package/docs//345/205/250/351/235/242/345/244/215/347/233/230_50/350/275/256/346/267/261/345/272/246/345/256/241/350/256/241_v7.2.0.md +208 -208
- package/docs//345/205/250/351/235/242/345/244/215/347/233/230_6/351/241/271/351/207/215/347/202/271/346/240/270/346/237/245_v7.2.0.md +152 -152
- package/docs//345/205/250/351/235/242/345/244/215/347/233/230_/350/277/220/350/241/214/346/227/266/345/256/236/346/265/213/347/211/210_v7.2.0.md +271 -271
- package/docs//345/220/210/350/247/204/350/256/244/350/257/201/345/207/206/345/244/207/346/270/205/345/215/225_v7.2.0.md +59 -59
- package/docs//345/256/211/345/205/250/347/231/275/347/232/256/344/271/246_v7.2.0.md +84 -82
- package/docs//346/212/200/346/234/257/350/257/264/346/230/216/344/271/246.md +240 -149
- package/docs//351/203/250/347/275/262/350/257/264/346/230/216/344/271/246.md +2 -2
- package/electron/main.js +404 -404
- package/package.json +12 -5
- package/templates/skills/api-design/SKILL.md +1 -1
- package/templates/skills/code-review/SKILL.md +1 -1
- package/templates/skills/dependency-upgrade/SKILL.md +1 -1
- package/templates/skills/doc-gen/SKILL.md +1 -1
- package/templates/skills/git-flow/SKILL.md +1 -1
- package/templates/skills/onboarding/SKILL.md +1 -1
- package/templates/skills/performance/SKILL.md +1 -1
- package/templates/skills/refactor/SKILL.md +1 -1
- package/templates/skills/security-audit/SKILL.md +1 -1
- package/templates/skills/test-gen/SKILL.md +1 -1
- package/tool-schema.json +197 -197
|
@@ -1,234 +1,259 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 飞虹 Code - 安卓版 Mock API 层 (mock-api.js)
|
|
3
|
-
*
|
|
4
|
-
* 在 Android WebView 中无本地 Node.js 后端时提供离线演示数据。
|
|
5
|
-
* 通过拦截 window.fetch 对 /api/ 请求返回本地模拟数据,保证 UI 完整可用。
|
|
6
|
-
*
|
|
7
|
-
* 模式:
|
|
8
|
-
* - 默认:本地 Mock 模式(离线演示)
|
|
9
|
-
* - 可在设置中填写服务器地址切换为远程模式(真实调用后端)
|
|
10
|
-
*
|
|
11
|
-
* 此文件在 api.js 之前加载,必须在最顶部定义,保证 window.fetch 被优先拦截。
|
|
12
|
-
*/
|
|
13
|
-
(function () {
|
|
14
|
-
if (window.__feihongMockInstalled) return;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
//
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
{
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
{
|
|
42
|
-
{
|
|
43
|
-
{
|
|
44
|
-
{
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
{ id: '
|
|
50
|
-
{ id: '
|
|
51
|
-
{ id: '
|
|
52
|
-
{ id: '
|
|
53
|
-
];
|
|
54
|
-
|
|
55
|
-
var
|
|
56
|
-
{
|
|
57
|
-
{
|
|
58
|
-
{
|
|
59
|
-
{
|
|
60
|
-
{
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
if (lower === '/api/
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
if (lower.indexOf('/api/
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
if (lower
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
if (lower
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
if (lower
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
if (lower.indexOf('/api/
|
|
157
|
-
return ok({
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
//
|
|
166
|
-
if (lower
|
|
167
|
-
|
|
168
|
-
return ok({
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
if (
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
ok:
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
//
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 飞虹 Code - 安卓版 Mock API 层 (mock-api.js)
|
|
3
|
+
*
|
|
4
|
+
* 在 Android WebView 中无本地 Node.js 后端时提供离线演示数据。
|
|
5
|
+
* 通过拦截 window.fetch 对 /api/ 请求返回本地模拟数据,保证 UI 完整可用。
|
|
6
|
+
*
|
|
7
|
+
* 模式:
|
|
8
|
+
* - 默认:本地 Mock 模式(离线演示)
|
|
9
|
+
* - 可在设置中填写服务器地址切换为远程模式(真实调用后端)
|
|
10
|
+
*
|
|
11
|
+
* 此文件在 api.js 之前加载,必须在最顶部定义,保证 window.fetch 被优先拦截。
|
|
12
|
+
*/
|
|
13
|
+
(function () {
|
|
14
|
+
if (window.__feihongMockInstalled) return;
|
|
15
|
+
|
|
16
|
+
// ========== 环境检测:仅在安卓离线模式下激活 Mock ==========
|
|
17
|
+
// Web 控制台通过 http://localhost:8080 加载,有真实 Node.js 后端,不应拦截 fetch。
|
|
18
|
+
// 安卓 WebView 通过 file:// 或 content:// 加载本地 HTML,无后端,才需要 Mock。
|
|
19
|
+
var proto = (location.protocol || '').toLowerCase();
|
|
20
|
+
var isAndroid = /android/i.test(navigator.userAgent || '');
|
|
21
|
+
var isLocalFile = proto === 'file:' || proto === 'content:';
|
|
22
|
+
// 仅在「安卓 + 本地文件协议」下激活 Mock;其他情况(Web 控制台、远程服务器)直接放行
|
|
23
|
+
if (!(isAndroid && isLocalFile)) {
|
|
24
|
+
console.log('[MockAPI] 检测到 HTTP 环境,跳过 Mock 拦截(mode=passthrough)');
|
|
25
|
+
window.__feihongMockInstalled = true;
|
|
26
|
+
window.FeiHongApp = window.FeiHongApp || {};
|
|
27
|
+
window.FeiHongApp.isMock = function () { return false; };
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
window.__feihongMockInstalled = true;
|
|
32
|
+
|
|
33
|
+
// ========== 远程服务器配置 ==========
|
|
34
|
+
var REMOTE_KEY = 'fhcode.remote.base';
|
|
35
|
+
function getRemoteBase() {
|
|
36
|
+
try { return localStorage.getItem(REMOTE_KEY) || ''; } catch (e) { return ''; }
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// ========== Mock 数据 ==========
|
|
40
|
+
var MODELS = [
|
|
41
|
+
{ id: 'deepseek-chat', name: 'DeepSeek Chat', provider: 'deepseek', reasoning: false, enabled: true },
|
|
42
|
+
{ id: 'deepseek-reasoner', name: 'DeepSeek Reasoner', provider: 'deepseek', reasoning: true, enabled: true },
|
|
43
|
+
{ id: 'qwen-max', name: '通义千问 Max', provider: 'qwen', reasoning: false, enabled: true },
|
|
44
|
+
{ id: 'gpt-4o', name: 'GPT-4o', provider: 'openai', reasoning: false, enabled: true }
|
|
45
|
+
];
|
|
46
|
+
|
|
47
|
+
var SKILLS = [
|
|
48
|
+
{ id: 'code-review', name: '代码审查', desc: '自动审查代码质量与安全', enabled: true },
|
|
49
|
+
{ id: 'test-gen', name: '测试生成', desc: '自动生成单元测试用例', enabled: true },
|
|
50
|
+
{ id: 'doc-gen', name: '文档生成', desc: '自动生成 API 文档', enabled: true },
|
|
51
|
+
{ id: 'refactor', name: '重构专家', desc: '代码重构与优化', enabled: true },
|
|
52
|
+
{ id: 'bug-hunt', name: 'Bug 猎手', desc: '自动定位与修复 Bug', enabled: true }
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
var OFFICE_CAPS = [
|
|
56
|
+
{ title: '生成周报', icon: '📊', prompt: '帮我生成一份本周工作周报', desc: '自动生成结构化周报' },
|
|
57
|
+
{ title: '写邮件', icon: '✉️', prompt: '帮我写一封商务邮件', desc: '专业邮件撰写' },
|
|
58
|
+
{ title: 'PPT 大纲', icon: '📑', prompt: '帮我生成一份 PPT 大纲', desc: '结构化演示大纲' },
|
|
59
|
+
{ title: '会议纪要', icon: '📝', prompt: '帮我整理会议纪要', desc: '智能会议纪要' },
|
|
60
|
+
{ title: '数据分析', icon: '📈', prompt: '帮我分析这份数据', desc: '数据洞察分析' },
|
|
61
|
+
{ title: '翻译文档', icon: '🌐', prompt: '帮我翻译这段内容', desc: '中英互译' }
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
var ROLES = [
|
|
65
|
+
{ id: 'architect', name: '架构师', icon: '🏛️', desc: '系统设计、技术选型' },
|
|
66
|
+
{ id: 'developer', name: '开发者', icon: '💻', desc: '代码实现' },
|
|
67
|
+
{ id: 'tester', name: '测试工程师', icon: '🧪', desc: '测试用例设计' },
|
|
68
|
+
{ id: 'reviewer', name: '评审员', icon: '🔍', desc: '代码审查' }
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
var CUSTOM_AGENTS = [
|
|
72
|
+
{ id: 'builtin-代码审查员', name: '代码审查员', category: 'review', desc: '专业代码审查,安全漏洞/性能/最佳实践', useCount: 12 },
|
|
73
|
+
{ id: 'builtin-测试工程师', name: '测试工程师', category: 'testing', desc: '自动生成测试用例', useCount: 8 },
|
|
74
|
+
{ id: 'builtin-文档生成器', name: '文档生成器', category: 'documentation', desc: '自动生成代码文档', useCount: 6 },
|
|
75
|
+
{ id: 'builtin-重构专家', name: '重构专家', category: 'refactoring', desc: '代码重构优化', useCount: 9 },
|
|
76
|
+
{ id: 'builtin-Bug猎手', name: 'Bug 猎手', category: 'debugging', desc: 'Bug 分析和修复', useCount: 15 }
|
|
77
|
+
];
|
|
78
|
+
|
|
79
|
+
// ========== Mock 路由处理 ==========
|
|
80
|
+
function handleMock(path, method, body) {
|
|
81
|
+
var p = path.split('?')[0];
|
|
82
|
+
var lower = p.toLowerCase();
|
|
83
|
+
|
|
84
|
+
// 健康检查
|
|
85
|
+
if (lower === '/api/health') {
|
|
86
|
+
return ok({ product: '飞虹 Code', version: '7.0.0', enterprise: true, signature: '安卓版 · 离线演示模式', mode: 'mock', time: new Date().toISOString() });
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// 安全:加密公钥(Mock 模式下返回固定测试公钥,仅供前端加密流程演示)
|
|
90
|
+
if (lower === '/api/security/public-key') {
|
|
91
|
+
return ok({
|
|
92
|
+
ok: true,
|
|
93
|
+
publicKey: '-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmock-public-key-for-demo-only\n-----END PUBLIC KEY-----',
|
|
94
|
+
algorithm: 'RSA-OAEP-2048-SHA256'
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// 模型
|
|
99
|
+
if (lower === '/api/models' && method === 'GET') return ok({ models: MODELS });
|
|
100
|
+
if (lower === '/api/models' && method === 'POST') {
|
|
101
|
+
var m = body || {};
|
|
102
|
+
MODELS.push({ id: 'custom-' + Date.now(), name: m.name || '自定义模型', provider: 'custom', reasoning: !!m.reasoning, enabled: true });
|
|
103
|
+
return ok({ model: MODELS[MODELS.length - 1] });
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// 技能
|
|
107
|
+
if (lower === '/api/skills/installed') return ok({ skills: SKILLS });
|
|
108
|
+
if (lower === '/api/skills' ) return ok({ skills: SKILLS });
|
|
109
|
+
|
|
110
|
+
// 办公能力
|
|
111
|
+
if (lower === '/api/office/capabilities') return ok({ capabilities: OFFICE_CAPS });
|
|
112
|
+
|
|
113
|
+
// 多智能体角色
|
|
114
|
+
if (lower === '/api/multi-agent/roles') return ok({ roles: ROLES });
|
|
115
|
+
if (lower === '/api/multi-agent/run') {
|
|
116
|
+
var goal = (body && body.goal) || '完成任务';
|
|
117
|
+
return ok({
|
|
118
|
+
goal: goal,
|
|
119
|
+
rounds: [
|
|
120
|
+
{ role: '架构师', output: '设计方案:采用模块化架构,定义清晰接口边界。\n- 技术选型:TypeScript + 分层设计\n- 接口定义:RESTful API\n- 错误处理:统一异常捕获', score: 85 },
|
|
121
|
+
{ role: '开发者', output: '代码实现:完成核心模块开发。\n- 实现业务逻辑\n- 编写单元测试\n- 补充类型定义', score: 88 }
|
|
122
|
+
],
|
|
123
|
+
finalVerdict: '通过',
|
|
124
|
+
qualityScore: 86,
|
|
125
|
+
issues: []
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// 自定义 Agent
|
|
130
|
+
if (lower === '/api/custom-agents') return ok({ agents: CUSTOM_AGENTS });
|
|
131
|
+
if (lower.indexOf('/api/custom-agents/match') === 0) {
|
|
132
|
+
var inp = (body && body.input) || '';
|
|
133
|
+
var matched = CUSTOM_AGENTS.filter(function (a) {
|
|
134
|
+
return !inp || a.name.indexOf(inp) !== -1 || a.desc.indexOf(inp) !== -1;
|
|
135
|
+
}).slice(0, 3);
|
|
136
|
+
return ok({ agents: matched });
|
|
137
|
+
}
|
|
138
|
+
if (lower.indexOf('/api/custom-agents/') === 0 && method === 'GET') {
|
|
139
|
+
var id = p.split('/').pop();
|
|
140
|
+
var agent = CUSTOM_AGENTS.find(function (a) { return a.id === id; });
|
|
141
|
+
return ok({ agent: agent || CUSTOM_AGENTS[0] });
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// 事件驱动
|
|
145
|
+
if (lower === '/api/event-driven/config') return ok({ config: { enabled: true, tasks: [] } });
|
|
146
|
+
if (lower === '/api/event-driven/events') return ok({ events: [] });
|
|
147
|
+
if (lower === '/api/event-driven/cron') return ok({ tasks: [] });
|
|
148
|
+
|
|
149
|
+
// 记忆
|
|
150
|
+
if (lower === '/api/memory/history') return ok({ history: [] });
|
|
151
|
+
if (lower === '/api/memory/long') return ok({ content: '这是长期记忆区域。在安卓离线演示模式下,长期记忆功能暂未启用。\n\n连接远程服务器后,将自动同步您的记忆数据。' });
|
|
152
|
+
if (lower === '/api/memory/short') return ok({ content: '当天暂无记录' });
|
|
153
|
+
if (lower === '/api/memory/stats') return ok({ shortTermFiles: 0, longTermNotes: 0, lastSummarize: '暂无' });
|
|
154
|
+
|
|
155
|
+
// 补全
|
|
156
|
+
if (lower.indexOf('/api/completion') === 0) {
|
|
157
|
+
return ok({
|
|
158
|
+
completions: [
|
|
159
|
+
{ text: 'async function handleRequest(req, res) {\n try {\n const data = await fetchData(req.params.id);\n res.json({ ok: true, data });\n } catch (e) {\n res.status(500).json({ ok: false, error: e.message });\n }\n}', score: 0.95 },
|
|
160
|
+
{ text: 'function validate(input) {\n if (!input) throw new Error("input is required");\n return input.trim();\n}', score: 0.88 }
|
|
161
|
+
]
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// 会话 / 统计
|
|
166
|
+
if (lower === '/api/sessions') return ok({ sessions: [] });
|
|
167
|
+
if (lower.indexOf('/api/team') === 0) {
|
|
168
|
+
if (method === 'GET') return ok({ members: [], tasks: [] });
|
|
169
|
+
return ok({ ok: true });
|
|
170
|
+
}
|
|
171
|
+
if (lower.indexOf('/api/git') === 0) {
|
|
172
|
+
if (method === 'GET') return ok({ branches: [], status: { clean: true }, commits: [] });
|
|
173
|
+
return ok({ ok: true });
|
|
174
|
+
}
|
|
175
|
+
if (lower.indexOf('/api/design-to-code') === 0) {
|
|
176
|
+
return ok({ ok: true, html: '<!-- 安卓演示模式:设计稿转代码需连接远程服务器 -->' });
|
|
177
|
+
}
|
|
178
|
+
if (lower.indexOf('/api/solo') === 0) {
|
|
179
|
+
return ok({ ok: true, status: 'idle' });
|
|
180
|
+
}
|
|
181
|
+
if (lower.indexOf('/api/mcp') === 0) {
|
|
182
|
+
return ok({ servers: [] });
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// 登录/认证
|
|
186
|
+
if (lower === '/api/auth/login' || lower === '/api/login') {
|
|
187
|
+
return ok({ token: 'mock-token-' + Date.now(), user: { name: '演示用户', role: 'admin' } });
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// 对话 / Agent 执行
|
|
191
|
+
if (lower.indexOf('/api/chat') === 0 || lower.indexOf('/api/agent') === 0 || lower.indexOf('/api/task') === 0) {
|
|
192
|
+
var prompt = (body && (body.prompt || body.message || body.goal || body.input)) || '任务';
|
|
193
|
+
return ok({
|
|
194
|
+
id: 'mock-' + Date.now(),
|
|
195
|
+
answer: '【安卓离线演示】\n\n已收到任务:' + prompt + '\n\n当前处于离线演示模式,AI 生成能力需要连接远程飞虹 Code 服务器。\n\n在「设置」中填写服务器地址后,即可使用完整 AI 能力(多模型路由、Agent 执行、代码补全等)。',
|
|
196
|
+
done: true
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// 配置
|
|
201
|
+
if (lower === '/api/config' || lower === '/api/settings') {
|
|
202
|
+
return ok({ config: { mode: 'mock', remoteBase: getRemoteBase(), version: '7.0.0' } });
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// 兜底:GET 返回空结构,其他返回 ok
|
|
206
|
+
if (method === 'GET') return ok({ ok: true, data: [] });
|
|
207
|
+
return ok({ ok: true, data: [] });
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function ok(data) {
|
|
211
|
+
return {
|
|
212
|
+
ok: true,
|
|
213
|
+
status: 200,
|
|
214
|
+
json: function () { return Promise.resolve(data); },
|
|
215
|
+
text: function () { return Promise.resolve(JSON.stringify(data)); }
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// ========== 拦截 fetch ==========
|
|
220
|
+
var originalFetch = window.fetch;
|
|
221
|
+
window.fetch = function (input, init) {
|
|
222
|
+
var url = typeof input === 'string' ? input : input.url;
|
|
223
|
+
var method = ((init && init.method) || (input && input.method) || 'GET').toUpperCase();
|
|
224
|
+
|
|
225
|
+
// 远程模式:配置了服务器地址且请求的是 /api/ 相对路径时,转发到远程
|
|
226
|
+
var remoteBase = getRemoteBase();
|
|
227
|
+
if (remoteBase && url.indexOf('/api/') === 0) {
|
|
228
|
+
var remoteUrl = remoteBase.replace(/\/$/, '') + url;
|
|
229
|
+
return originalFetch.call(window, remoteUrl, init).catch(function (e) {
|
|
230
|
+
// 远程失败时降级到 Mock
|
|
231
|
+
return Promise.resolve(handleMock(url, method, parseBody(init)));
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// Mock 模式:拦截 /api/ 请求
|
|
236
|
+
if (url.indexOf('/api/') === 0) {
|
|
237
|
+
return Promise.resolve(handleMock(url, method, parseBody(init)));
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// 其他请求(静态资源等)正常处理
|
|
241
|
+
return originalFetch.apply(window, arguments);
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
function parseBody(init) {
|
|
245
|
+
if (!init || !init.body) return null;
|
|
246
|
+
try { return JSON.parse(init.body); } catch (e) { return null; }
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// ========== 暴露远程模式切换接口 ==========
|
|
250
|
+
window.FeiHongApp = window.FeiHongApp || {};
|
|
251
|
+
window.FeiHongApp.setRemote = function (base) {
|
|
252
|
+
try { localStorage.setItem(REMOTE_KEY, base || ''); } catch (e) {}
|
|
253
|
+
return base;
|
|
254
|
+
};
|
|
255
|
+
window.FeiHongApp.getRemote = function () { return getRemoteBase(); };
|
|
256
|
+
window.FeiHongApp.isMock = function () { return !getRemoteBase(); };
|
|
257
|
+
|
|
258
|
+
console.log('[MockAPI] 飞虹 Code 安卓离线 Mock 层已加载 (mode=' + (getRemoteBase() ? 'remote' : 'mock') + ')');
|
|
259
|
+
})();
|