[{"data":1,"prerenderedAt":3229},["ShallowReactive",2],{"article-/topics/ai/ai-agent-event-sourcing-for-workflow-runtime":3,"related-ai":272,"content-query-JPUf6EqrR5":3041},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"topic":5,"author":11,"tags":12,"image":17,"imageQuery":18,"pexelsPhotoId":19,"pexelsUrl":20,"featured":6,"readingTime":21,"body":22,"_type":266,"_id":267,"_source":268,"_file":269,"_stem":270,"_extension":271},"/topics/ai/ai-agent-event-sourcing-for-workflow-runtime","ai",false,"","AI agent Workflow Runtime 的 Event Sourcing：为什么状态快照不够","仅存当前状态无法回答‘过程如何走到这里’。本文讲清 event sourcing 在 agent workflow runtime 的价值、代价与落地边界。","2026-05-30","HTMLPAGE 团队",[13,14,15,16],"AI agent","Event Sourcing","Workflow Runtime","Observability","/images/articles/ai-agent-event-sourcing-for-workflow-runtime-featured.jpg","data stream monitoring dashboard control room",32026165,"https://www.pexels.com/photo/futuristic-command-station-with-digital-displays-32026165/",14,{"type":23,"children":24,"toc":258},"root",[25,33,40,107,112,117,137,142,148,162,168,222,227],{"type":26,"tag":27,"props":28,"children":29},"element","p",{},[30],{"type":31,"value":32},"text","快照能告诉你现在是什么状态，但不能告诉你为什么到这里。对 AI agent 来说，这个缺口会直接影响审计、回放和补偿。",{"type":26,"tag":34,"props":35,"children":37},"h2",{"id":36},"为什么-runtime-需要事件流",[38],{"type":31,"value":39},"为什么 runtime 需要事件流",{"type":26,"tag":41,"props":42,"children":43},"table",{},[44,63],{"type":26,"tag":45,"props":46,"children":47},"thead",{},[48],{"type":26,"tag":49,"props":50,"children":51},"tr",{},[52,58],{"type":26,"tag":53,"props":54,"children":55},"th",{},[56],{"type":31,"value":57},"仅快照模式的问题",{"type":26,"tag":53,"props":59,"children":60},{},[61],{"type":31,"value":62},"事件流能补什么",{"type":26,"tag":64,"props":65,"children":66},"tbody",{},[67,81,94],{"type":26,"tag":49,"props":68,"children":69},{},[70,76],{"type":26,"tag":71,"props":72,"children":73},"td",{},[74],{"type":31,"value":75},"难以追踪状态迁移原因",{"type":26,"tag":71,"props":77,"children":78},{},[79],{"type":31,"value":80},"每次迁移有因果事件",{"type":26,"tag":49,"props":82,"children":83},{},[84,89],{"type":26,"tag":71,"props":85,"children":86},{},[87],{"type":31,"value":88},"回放粒度粗",{"type":26,"tag":71,"props":90,"children":91},{},[92],{"type":31,"value":93},"支持按事件重建路径",{"type":26,"tag":49,"props":95,"children":96},{},[97,102],{"type":26,"tag":71,"props":98,"children":99},{},[100],{"type":31,"value":101},"难以做增量审计",{"type":26,"tag":71,"props":103,"children":104},{},[105],{"type":31,"value":106},"事件可直接用于审计链",{"type":26,"tag":27,"props":108,"children":109},{},[110],{"type":31,"value":111},"event sourcing 不是替代快照，而是和快照共存。",{"type":26,"tag":34,"props":113,"children":115},{"id":114},"推荐结构",[116],{"type":31,"value":114},{"type":26,"tag":118,"props":119,"children":120},"ul",{},[121,127,132],{"type":26,"tag":122,"props":123,"children":124},"li",{},[125],{"type":31,"value":126},"事件流：append-only，记录事实",{"type":26,"tag":122,"props":128,"children":129},{},[130],{"type":31,"value":131},"状态快照：加速读取，按需重建",{"type":26,"tag":122,"props":133,"children":134},{},[135],{"type":31,"value":136},"ledger：跨系统对账索引",{"type":26,"tag":27,"props":138,"children":139},{},[140],{"type":31,"value":141},"三者分工清晰，才不会出现“日志像账本、账本像缓存”。",{"type":26,"tag":34,"props":143,"children":145},{"id":144},"失败案例只存终态导致争议无法复盘",[146],{"type":31,"value":147},"失败案例：只存终态导致争议无法复盘",{"type":26,"tag":27,"props":149,"children":150},{},[151,153,160],{"type":31,"value":152},"某平台仅保留 ",{"type":26,"tag":154,"props":155,"children":157},"code",{"className":156},[],[158],{"type":31,"value":159},"run_status=completed",{"type":31,"value":161},"，但客户质疑中间审批被跳过。由于没有审批事件链，团队无法证明流程是否按规则执行。后续补齐事件模型后，争议处理时间大幅缩短。",{"type":26,"tag":34,"props":163,"children":165},{"id":164},"checklist",[166],{"type":31,"value":167},"Checklist",{"type":26,"tag":118,"props":169,"children":172},{"className":170},[171],"contains-task-list",[173,186,195,204,213],{"type":26,"tag":122,"props":174,"children":177},{"className":175},[176],"task-list-item",[178,184],{"type":26,"tag":179,"props":180,"children":183},"input",{"disabled":181,"type":182},true,"checkbox",[],{"type":31,"value":185}," 关键状态迁移都有事件定义",{"type":26,"tag":122,"props":187,"children":189},{"className":188},[176],[190,193],{"type":26,"tag":179,"props":191,"children":192},{"disabled":181,"type":182},[],{"type":31,"value":194}," 事件包含 causationId 与 correlationId",{"type":26,"tag":122,"props":196,"children":198},{"className":197},[176],[199,202],{"type":26,"tag":179,"props":200,"children":201},{"disabled":181,"type":182},[],{"type":31,"value":203}," 快照可由事件重建校验",{"type":26,"tag":122,"props":205,"children":207},{"className":206},[176],[208,211],{"type":26,"tag":179,"props":209,"children":210},{"disabled":181,"type":182},[],{"type":31,"value":212}," 事件保留策略与合规要求一致",{"type":26,"tag":122,"props":214,"children":216},{"className":215},[176],[217,220],{"type":26,"tag":179,"props":218,"children":219},{"disabled":181,"type":182},[],{"type":31,"value":221}," replay 与审计基于事件链而非猜测",{"type":26,"tag":27,"props":223,"children":224},{},[225],{"type":31,"value":226},"延伸阅读：",{"type":26,"tag":118,"props":228,"children":229},{},[230,240,249],{"type":26,"tag":122,"props":231,"children":232},{},[233],{"type":26,"tag":234,"props":235,"children":237},"a",{"href":236},"/topics/ai/ai-agent-session-store-event-log-design",[238],{"type":31,"value":239},"AI agent Session Store 与 Event Log 设计",{"type":26,"tag":122,"props":241,"children":242},{},[243],{"type":26,"tag":234,"props":244,"children":246},{"href":245},"/topics/ai/ai-agent-run-ledger-audit-model",[247],{"type":31,"value":248},"AI agent Run Ledger 审计模型",{"type":26,"tag":122,"props":250,"children":251},{},[252],{"type":26,"tag":234,"props":253,"children":255},{"href":254},"/topics/ai/ai-agent-deterministic-replay-vs-semantic-replay",[256],{"type":31,"value":257},"AI agent Deterministic Replay vs Semantic Replay",{"title":7,"searchDepth":259,"depth":259,"links":260},3,[261,263,264,265],{"id":36,"depth":262,"text":39},2,{"id":114,"depth":262,"text":114},{"id":144,"depth":262,"text":147},{"id":164,"depth":262,"text":167},"markdown","content:topics:ai:ai-agent-event-sourcing-for-workflow-runtime.md","content","topics/ai/ai-agent-event-sourcing-for-workflow-runtime.md","topics/ai/ai-agent-event-sourcing-for-workflow-runtime","md",[273,1428,2378],{"_path":274,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":275,"description":276,"date":277,"topic":5,"author":11,"tags":278,"image":284,"imageAlt":285,"pexelsPhotoId":286,"pexelsUrl":287,"readingTime":288,"body":289,"_type":266,"_id":1425,"_source":268,"_file":1426,"_stem":1427,"_extension":271},"/topics/ai/cursor-keyboard-shortcuts-cheatsheet","Cursor 快捷键速查表（macOS/Windows）：从“会用”到“能提效”的 10 个工作流","把 Cursor 常用快捷键按任务分组（查代码、改代码、多文件、对话、审查与回滚），给出可直接照抄的工作流与最小回归清单，避免“快捷键背了也没变快”。","2026-03-02",[279,280,281,282,283],"Cursor","快捷键","AI IDE","VS Code","开发效率","/images/topics/ai/cursor-keyboard-shortcuts-cheatsheet.jpg","彩色机械键盘与鼠标的工作台面",34563105,"https://www.pexels.com/photo/colorful-mechanical-keyboard-and-mouse-setup-34563105/",12,{"type":23,"children":290,"toc":1399},[291,296,314,319,348,353,389,393,399,404,437,442,465,468,474,479,697,706,709,715,722,741,749,770,775,781,796,827,832,845,851,870,888,896,901,907,912,933,941,947,952,975,980,986,999,1005,1023,1041,1047,1058,1076,1082,1093,1099,1104,1147,1150,1156,1164,1217,1220,1226,1232,1237,1242,1265,1283,1288,1313,1316,1322,1328,1333,1339,1344,1350,1355,1358,1364],{"type":26,"tag":27,"props":292,"children":293},{},[294],{"type":31,"value":295},"如果你在搜“Cursor 快捷键”，你大概率不是想背一张表，而是想解决这类问题：",{"type":26,"tag":118,"props":297,"children":298},{},[299,304,309],{"type":26,"tag":122,"props":300,"children":301},{},[302],{"type":31,"value":303},"为什么我用了 AI，还是很慢？（对话来回太多、改动不可控）",{"type":26,"tag":122,"props":305,"children":306},{},[307],{"type":31,"value":308},"为什么它“看起来懂了”，却改错文件/改出回归？（上下文与范围没锁住）",{"type":26,"tag":122,"props":310,"children":311},{},[312],{"type":31,"value":313},"多文件改动怎么做得安全？（验收、回滚、最小回归集）",{"type":26,"tag":27,"props":315,"children":316},{},[317],{"type":31,"value":318},"这篇文章给你两份东西：",{"type":26,"tag":320,"props":321,"children":322},"ol",{},[323,336],{"type":26,"tag":122,"props":324,"children":325},{},[326,328,334],{"type":31,"value":327},"一张",{"type":26,"tag":329,"props":330,"children":331},"strong",{},[332],{"type":31,"value":333},"按任务分组",{"type":31,"value":335},"的快捷键表（不是按功能堆在一起）",{"type":26,"tag":122,"props":337,"children":338},{},[339,341,346],{"type":31,"value":340},"一套“从需求到落地”的",{"type":26,"tag":329,"props":342,"children":343},{},[344],{"type":31,"value":345},"最小闭环工作流",{"type":31,"value":347},"（每一步都有快捷键）",{"type":26,"tag":27,"props":349,"children":350},{},[351],{"type":31,"value":352},"想看系统玩法：",{"type":26,"tag":118,"props":354,"children":355},{},[356,367,378],{"type":26,"tag":122,"props":357,"children":358},{},[359,361],{"type":31,"value":360},"入门教程看：",{"type":26,"tag":234,"props":362,"children":364},{"href":363},"/topics/ai/cursor-tutorial",[365],{"type":31,"value":366},"Cursor 使用教程（2026）",{"type":26,"tag":122,"props":368,"children":369},{},[370,372],{"type":31,"value":371},"进阶玩法看：",{"type":26,"tag":234,"props":373,"children":375},{"href":374},"/topics/ai/cursor-editor-guide",[376],{"type":31,"value":377},"Cursor 编辑器深度玩法",{"type":26,"tag":122,"props":379,"children":380},{},[381,383],{"type":31,"value":382},"规则与忽略看：",{"type":26,"tag":234,"props":384,"children":386},{"href":385},"/topics/ai/cursor-rules-cursorrules",[387],{"type":31,"value":388},"Cursor Rules 与 .cursorrules",{"type":26,"tag":390,"props":391,"children":392},"hr",{},[],{"type":26,"tag":34,"props":394,"children":396},{"id":395},"先给结论提效不是按得快而是闭环更短",[397],{"type":31,"value":398},"先给结论：提效不是“按得快”，而是“闭环更短”",{"type":26,"tag":27,"props":400,"children":401},{},[402],{"type":31,"value":403},"你可以把 Cursor 的快捷键理解为 3 条流水线：",{"type":26,"tag":118,"props":405,"children":406},{},[407,417,427],{"type":26,"tag":122,"props":408,"children":409},{},[410,415],{"type":26,"tag":329,"props":411,"children":412},{},[413],{"type":31,"value":414},"改一小段",{"type":31,"value":416},"（内联编辑）：把改动限制在一个函数/一段样式",{"type":26,"tag":122,"props":418,"children":419},{},[420,425],{"type":26,"tag":329,"props":421,"children":422},{},[423],{"type":31,"value":424},"改一组文件",{"type":31,"value":426},"（Composer）：把改动限制在一组明确文件，并要求输出 diff + 验收点",{"type":26,"tag":122,"props":428,"children":429},{},[430,435],{"type":26,"tag":329,"props":431,"children":432},{},[433],{"type":31,"value":434},"聊清楚再动手",{"type":31,"value":436},"（侧边对话）：先对齐目标、范围、验收、回滚",{"type":26,"tag":27,"props":438,"children":439},{},[440],{"type":31,"value":441},"当你觉得“它乱改/改太大”时，往往不是快捷键没记住，而是缺了两件事：",{"type":26,"tag":118,"props":443,"children":444},{},[445,455],{"type":26,"tag":122,"props":446,"children":447},{},[448,450],{"type":31,"value":449},"没有在动手前锁定",{"type":26,"tag":329,"props":451,"children":452},{},[453],{"type":31,"value":454},"范围",{"type":26,"tag":122,"props":456,"children":457},{},[458,460],{"type":31,"value":459},"没有在接受改动前准备",{"type":26,"tag":329,"props":461,"children":462},{},[463],{"type":31,"value":464},"验收/回滚",{"type":26,"tag":390,"props":466,"children":467},{},[],{"type":26,"tag":34,"props":469,"children":471},{"id":470},"快捷键速查表按任务分组",[472],{"type":31,"value":473},"快捷键速查表（按任务分组）",{"type":26,"tag":27,"props":475,"children":476},{},[477],{"type":31,"value":478},"说明：下表按“你正在做什么”组织，而不是按“功能名字”组织。不同版本快捷键可能略有差异，但核心逻辑一致。",{"type":26,"tag":41,"props":480,"children":481},{},[482,508],{"type":26,"tag":45,"props":483,"children":484},{},[485],{"type":26,"tag":49,"props":486,"children":487},{},[488,493,498,503],{"type":26,"tag":53,"props":489,"children":490},{},[491],{"type":31,"value":492},"任务",{"type":26,"tag":53,"props":494,"children":495},{},[496],{"type":31,"value":497},"macOS",{"type":26,"tag":53,"props":499,"children":500},{},[501],{"type":31,"value":502},"Windows",{"type":26,"tag":53,"props":504,"children":505},{},[506],{"type":31,"value":507},"你该在什么时候用",{"type":26,"tag":64,"props":509,"children":510},{},[511,542,573,604,635,666],{"type":26,"tag":49,"props":512,"children":513},{},[514,519,528,537],{"type":26,"tag":71,"props":515,"children":516},{},[517],{"type":31,"value":518},"改一小段（最安全）",{"type":26,"tag":71,"props":520,"children":521},{},[522],{"type":26,"tag":154,"props":523,"children":525},{"className":524},[],[526],{"type":31,"value":527},"Cmd + K",{"type":26,"tag":71,"props":529,"children":530},{},[531],{"type":26,"tag":154,"props":532,"children":534},{"className":533},[],[535],{"type":31,"value":536},"Ctrl + K",{"type":26,"tag":71,"props":538,"children":539},{},[540],{"type":31,"value":541},"只想改一个函数/一段 CSS，不想动别的",{"type":26,"tag":49,"props":543,"children":544},{},[545,550,559,568],{"type":26,"tag":71,"props":546,"children":547},{},[548],{"type":31,"value":549},"打开 AI 对话（先对齐再动手）",{"type":26,"tag":71,"props":551,"children":552},{},[553],{"type":26,"tag":154,"props":554,"children":556},{"className":555},[],[557],{"type":31,"value":558},"Cmd + L",{"type":26,"tag":71,"props":560,"children":561},{},[562],{"type":26,"tag":154,"props":563,"children":565},{"className":564},[],[566],{"type":31,"value":567},"Ctrl + L",{"type":26,"tag":71,"props":569,"children":570},{},[571],{"type":31,"value":572},"需要澄清目标、制定步骤、给验收点",{"type":26,"tag":49,"props":574,"children":575},{},[576,581,590,599],{"type":26,"tag":71,"props":577,"children":578},{},[579],{"type":31,"value":580},"多文件编辑（有组织地改一组文件）",{"type":26,"tag":71,"props":582,"children":583},{},[584],{"type":26,"tag":154,"props":585,"children":587},{"className":586},[],[588],{"type":31,"value":589},"Cmd + I",{"type":26,"tag":71,"props":591,"children":592},{},[593],{"type":26,"tag":154,"props":594,"children":596},{"className":595},[],[597],{"type":31,"value":598},"Ctrl + I",{"type":26,"tag":71,"props":600,"children":601},{},[602],{"type":31,"value":603},"改动涉及多个文件：组件+样式+测试",{"type":26,"tag":49,"props":605,"children":606},{},[607,612,621,630],{"type":26,"tag":71,"props":608,"children":609},{},[610],{"type":31,"value":611},"把选中代码加入对话上下文",{"type":26,"tag":71,"props":613,"children":614},{},[615],{"type":26,"tag":154,"props":616,"children":618},{"className":617},[],[619],{"type":31,"value":620},"Cmd + Shift + L",{"type":26,"tag":71,"props":622,"children":623},{},[624],{"type":26,"tag":154,"props":625,"children":627},{"className":626},[],[628],{"type":31,"value":629},"Ctrl + Shift + L",{"type":26,"tag":71,"props":631,"children":632},{},[633],{"type":31,"value":634},"让 AI 只看你选的片段（降低噪音）",{"type":26,"tag":49,"props":636,"children":637},{},[638,643,652,661],{"type":26,"tag":71,"props":639,"children":640},{},[641],{"type":31,"value":642},"接受当前建议",{"type":26,"tag":71,"props":644,"children":645},{},[646],{"type":26,"tag":154,"props":647,"children":649},{"className":648},[],[650],{"type":31,"value":651},"Cmd + Y",{"type":26,"tag":71,"props":653,"children":654},{},[655],{"type":26,"tag":154,"props":656,"children":658},{"className":657},[],[659],{"type":31,"value":660},"Ctrl + Y",{"type":26,"tag":71,"props":662,"children":663},{},[664],{"type":31,"value":665},"你已经准备好验收/回滚，并确认改动范围",{"type":26,"tag":49,"props":667,"children":668},{},[669,674,683,692],{"type":26,"tag":71,"props":670,"children":671},{},[672],{"type":31,"value":673},"拒绝当前建议",{"type":26,"tag":71,"props":675,"children":676},{},[677],{"type":26,"tag":154,"props":678,"children":680},{"className":679},[],[681],{"type":31,"value":682},"Cmd + N",{"type":26,"tag":71,"props":684,"children":685},{},[686],{"type":26,"tag":154,"props":687,"children":689},{"className":688},[],[690],{"type":31,"value":691},"Ctrl + N",{"type":26,"tag":71,"props":693,"children":694},{},[695],{"type":31,"value":696},"改得太大、改错方向，立刻收手",{"type":26,"tag":698,"props":699,"children":700},"blockquote",{},[701],{"type":26,"tag":27,"props":702,"children":703},{},[704],{"type":31,"value":705},"小技巧：把“改一小段”当默认路径。只有当你能清晰写出“会改哪几类文件、怎么验收”时再进入多文件。",{"type":26,"tag":390,"props":707,"children":708},{},[],{"type":26,"tag":34,"props":710,"children":712},{"id":711},"_10-个可直接照抄的提效工作流每个都能闭环",[713],{"type":31,"value":714},"10 个可直接照抄的提效工作流（每个都能闭环）",{"type":26,"tag":716,"props":717,"children":719},"h3",{"id":718},"工作流-1需求计划小步改新手最稳",[720],{"type":31,"value":721},"工作流 1：需求→计划→小步改（新手最稳）",{"type":26,"tag":320,"props":723,"children":724},{},[725,736],{"type":26,"tag":122,"props":726,"children":727},{},[728,734],{"type":26,"tag":154,"props":729,"children":731},{"className":730},[],[732],{"type":31,"value":733},"Cmd/Ctrl + L",{"type":31,"value":735}," 打开对话",{"type":26,"tag":122,"props":737,"children":738},{},[739],{"type":31,"value":740},"先发这段（可复制）：",{"type":26,"tag":698,"props":742,"children":743},{},[744],{"type":26,"tag":27,"props":745,"children":746},{},[747],{"type":31,"value":748},"目标：……\n范围：只修改以下文件/模块：……\n非目标：……（明确不做）\n验收：……（可测试/可手动检查）\n输出格式：先给计划，再逐步执行；每一步写出 diff 摘要。",{"type":26,"tag":320,"props":750,"children":751},{"start":259},[752,757],{"type":26,"tag":122,"props":753,"children":754},{},[755],{"type":31,"value":756},"让 AI 先给“计划（3~6 步）”，你确认后再执行",{"type":26,"tag":122,"props":758,"children":759},{},[760,762,768],{"type":31,"value":761},"任何一步涉及改代码：优先回到编辑区，选中片段用 ",{"type":26,"tag":154,"props":763,"children":765},{"className":764},[],[766],{"type":31,"value":767},"Cmd/Ctrl + K",{"type":31,"value":769}," 小步改",{"type":26,"tag":27,"props":771,"children":772},{},[773],{"type":31,"value":774},"为什么有效：你把“想法”变成了“可执行约束”，这就是 GEO（面向 AI/模型的可理解结构）。",{"type":26,"tag":716,"props":776,"children":778},{"id":777},"工作流-2只改一个函数高频低风险",[779],{"type":31,"value":780},"工作流 2：只改一个函数（高频、低风险）",{"type":26,"tag":118,"props":782,"children":783},{},[784],{"type":26,"tag":122,"props":785,"children":786},{},[787,789,794],{"type":31,"value":788},"选中函数 → ",{"type":26,"tag":154,"props":790,"children":792},{"className":791},[],[793],{"type":31,"value":767},{"type":31,"value":795}," → 输入指令：",{"type":26,"tag":698,"props":797,"children":798},{},[799,804],{"type":26,"tag":27,"props":800,"children":801},{},[802],{"type":31,"value":803},"把这段改成更可读：",{"type":26,"tag":118,"props":805,"children":806},{},[807,812,817,822],{"type":26,"tag":122,"props":808,"children":809},{},[810],{"type":31,"value":811},"用 async/await",{"type":26,"tag":122,"props":813,"children":814},{},[815],{"type":31,"value":816},"错误处理不要吞掉",{"type":26,"tag":122,"props":818,"children":819},{},[820],{"type":31,"value":821},"添加类型（若可推断）",{"type":26,"tag":122,"props":823,"children":824},{},[825],{"type":31,"value":826},"不要改函数签名",{"type":26,"tag":27,"props":828,"children":829},{},[830],{"type":31,"value":831},"验收方式（强制）：",{"type":26,"tag":118,"props":833,"children":834},{},[835,840],{"type":26,"tag":122,"props":836,"children":837},{},[838],{"type":31,"value":839},"输出前后函数行为一致（输入/输出）",{"type":26,"tag":122,"props":841,"children":842},{},[843],{"type":31,"value":844},"失败分支有可观测日志（不要悄悄 return null）",{"type":26,"tag":716,"props":846,"children":848},{"id":847},"工作流-3多文件改动先定文件清单",[849],{"type":31,"value":850},"工作流 3：多文件改动（先定“文件清单”）",{"type":26,"tag":320,"props":852,"children":853},{},[854,865],{"type":26,"tag":122,"props":855,"children":856},{},[857,863],{"type":26,"tag":154,"props":858,"children":860},{"className":859},[],[861],{"type":31,"value":862},"Cmd/Ctrl + I",{"type":31,"value":864}," 进入多文件",{"type":26,"tag":122,"props":866,"children":867},{},[868],{"type":31,"value":869},"先让 AI 输出：",{"type":26,"tag":118,"props":871,"children":872},{},[873,878,883],{"type":26,"tag":122,"props":874,"children":875},{},[876],{"type":31,"value":877},"预计会改哪些文件（最多 5 个）",{"type":26,"tag":122,"props":879,"children":880},{},[881],{"type":31,"value":882},"每个文件改什么",{"type":26,"tag":122,"props":884,"children":885},{},[886],{"type":31,"value":887},"每一步怎么验收",{"type":26,"tag":320,"props":889,"children":890},{"start":259},[891],{"type":26,"tag":122,"props":892,"children":893},{},[894],{"type":31,"value":895},"你确认文件清单后再开始生成改动",{"type":26,"tag":27,"props":897,"children":898},{},[899],{"type":31,"value":900},"关键点：多文件最容易翻车的是“它把你没想到的文件也改了”。所以文件清单是第一道闸门。",{"type":26,"tag":716,"props":902,"children":904},{"id":903},"工作流-4把上下文噪音砍掉防跑偏",[905],{"type":31,"value":906},"工作流 4：把“上下文噪音”砍掉（防跑偏）",{"type":26,"tag":27,"props":908,"children":909},{},[910],{"type":31,"value":911},"当你怀疑它在胡说/乱改时：",{"type":26,"tag":118,"props":913,"children":914},{},[915,928],{"type":26,"tag":122,"props":916,"children":917},{},[918,920,926],{"type":31,"value":919},"只选择关键代码片段 → ",{"type":26,"tag":154,"props":921,"children":923},{"className":922},[],[924],{"type":31,"value":925},"Cmd/Ctrl + Shift + L",{"type":31,"value":927}," 加入对话",{"type":26,"tag":122,"props":929,"children":930},{},[931],{"type":31,"value":932},"然后在对话里要求：",{"type":26,"tag":698,"props":934,"children":935},{},[936],{"type":26,"tag":27,"props":937,"children":938},{},[939],{"type":31,"value":940},"只基于我提供的代码片段回答，不要假设其它文件存在。",{"type":26,"tag":716,"props":942,"children":944},{"id":943},"工作流-5生成变更说明让-code-review-变快",[945],{"type":31,"value":946},"工作流 5：生成变更说明（让 code review 变快）",{"type":26,"tag":27,"props":948,"children":949},{},[950],{"type":31,"value":951},"改完后在对话里让它输出：",{"type":26,"tag":118,"props":953,"children":954},{},[955,960,965,970],{"type":26,"tag":122,"props":956,"children":957},{},[958],{"type":31,"value":959},"改动摘要（3~7 条）",{"type":26,"tag":122,"props":961,"children":962},{},[963],{"type":31,"value":964},"风险点（依赖/边界条件）",{"type":26,"tag":122,"props":966,"children":967},{},[968],{"type":31,"value":969},"回滚方式",{"type":26,"tag":122,"props":971,"children":972},{},[973],{"type":31,"value":974},"验收步骤",{"type":26,"tag":27,"props":976,"children":977},{},[978],{"type":31,"value":979},"这套结构能直接贴进 PR 描述。",{"type":26,"tag":716,"props":981,"children":983},{"id":982},"工作流-6写最小回归集不写回归-等事故",[984],{"type":31,"value":985},"工作流 6：写“最小回归集”（不写回归 = 等事故）",{"type":26,"tag":27,"props":987,"children":988},{},[989,991,997],{"type":31,"value":990},"每次改动都至少做 10 条最小回归（见下文清单）。你可以把它写在 ",{"type":26,"tag":154,"props":992,"children":994},{"className":993},[],[995],{"type":31,"value":996},"README",{"type":31,"value":998}," 或团队 wiki。",{"type":26,"tag":716,"props":1000,"children":1002},{"id":1001},"工作流-7把接受建议变成最后一步",[1003],{"type":31,"value":1004},"工作流 7：把“接受建议”变成最后一步",{"type":26,"tag":27,"props":1006,"children":1007},{},[1008,1014,1016,1021],{"type":26,"tag":154,"props":1009,"children":1011},{"className":1010},[],[1012],{"type":31,"value":1013},"Cmd/Ctrl + Y",{"type":31,"value":1015}," 应该是",{"type":26,"tag":329,"props":1017,"children":1018},{},[1019],{"type":31,"value":1020},"最后一步",{"type":31,"value":1022},"：",{"type":26,"tag":118,"props":1024,"children":1025},{},[1026,1031,1036],{"type":26,"tag":122,"props":1027,"children":1028},{},[1029],{"type":31,"value":1030},"你已经看过 diff",{"type":26,"tag":122,"props":1032,"children":1033},{},[1034],{"type":31,"value":1035},"你能说清楚“怎么验收”",{"type":26,"tag":122,"props":1037,"children":1038},{},[1039],{"type":31,"value":1040},"你知道“怎么回滚”",{"type":26,"tag":716,"props":1042,"children":1044},{"id":1043},"工作流-8拒绝建议不是失败是风控动作",[1045],{"type":31,"value":1046},"工作流 8：拒绝建议不是失败，是风控动作",{"type":26,"tag":27,"props":1048,"children":1049},{},[1050,1056],{"type":26,"tag":154,"props":1051,"children":1053},{"className":1052},[],[1054],{"type":31,"value":1055},"Cmd/Ctrl + N",{"type":31,"value":1057}," 的使用时机：",{"type":26,"tag":118,"props":1059,"children":1060},{},[1061,1066,1071],{"type":26,"tag":122,"props":1062,"children":1063},{},[1064],{"type":31,"value":1065},"它开始改你没提过的东西（范围漂移）",{"type":26,"tag":122,"props":1067,"children":1068},{},[1069],{"type":31,"value":1070},"它改了 10 个文件但你只想改 1 个",{"type":26,"tag":122,"props":1072,"children":1073},{},[1074],{"type":31,"value":1075},"它为了“更优雅”引入新依赖/新抽象",{"type":26,"tag":716,"props":1077,"children":1079},{"id":1078},"工作流-9重复任务做成模板提示词不是一次性",[1080],{"type":31,"value":1081},"工作流 9：重复任务做成模板（提示词不是一次性）",{"type":26,"tag":27,"props":1083,"children":1084},{},[1085,1087,1091],{"type":31,"value":1086},"把高频任务（比如“写组件+样式+验收”）固化成模板，放进 Rules（见：",{"type":26,"tag":234,"props":1088,"children":1089},{"href":385},[1090],{"type":31,"value":388},{"type":31,"value":1092},"）。",{"type":26,"tag":716,"props":1094,"children":1096},{"id":1095},"工作流-10把快捷键表做成你自己的任务表",[1097],{"type":31,"value":1098},"工作流 10：把“快捷键表”做成你自己的任务表",{"type":26,"tag":27,"props":1100,"children":1101},{},[1102],{"type":31,"value":1103},"你不需要记住所有快捷键，只需要记住：",{"type":26,"tag":118,"props":1105,"children":1106},{},[1107,1117,1127,1137],{"type":26,"tag":122,"props":1108,"children":1109},{},[1110,1112],{"type":31,"value":1111},"小步改：",{"type":26,"tag":154,"props":1113,"children":1115},{"className":1114},[],[1116],{"type":31,"value":767},{"type":26,"tag":122,"props":1118,"children":1119},{},[1120,1122],{"type":31,"value":1121},"先对齐：",{"type":26,"tag":154,"props":1123,"children":1125},{"className":1124},[],[1126],{"type":31,"value":733},{"type":26,"tag":122,"props":1128,"children":1129},{},[1130,1132],{"type":31,"value":1131},"多文件：",{"type":26,"tag":154,"props":1133,"children":1135},{"className":1134},[],[1136],{"type":31,"value":862},{"type":26,"tag":122,"props":1138,"children":1139},{},[1140,1142],{"type":31,"value":1141},"上下文聚焦：",{"type":26,"tag":154,"props":1143,"children":1145},{"className":1144},[],[1146],{"type":31,"value":925},{"type":26,"tag":390,"props":1148,"children":1149},{},[],{"type":26,"tag":34,"props":1151,"children":1153},{"id":1152},"必交付物-1最小回归任务清单10-条通用",[1154],{"type":31,"value":1155},"必交付物 1：最小回归任务清单（10 条，通用）",{"type":26,"tag":698,"props":1157,"children":1158},{},[1159],{"type":26,"tag":27,"props":1160,"children":1161},{},[1162],{"type":31,"value":1163},"这份清单的意义：让每次 AI 改动都能“被验证”。否则你只是把不可控变成了更快的不可控。",{"type":26,"tag":320,"props":1165,"children":1166},{},[1167,1172,1177,1182,1187,1192,1197,1202,1207,1212],{"type":26,"tag":122,"props":1168,"children":1169},{},[1170],{"type":31,"value":1171},"关键路径能跑通（手动点击/请求一次）",{"type":26,"tag":122,"props":1173,"children":1174},{},[1175],{"type":31,"value":1176},"错误路径能触发（模拟一次失败输入）",{"type":26,"tag":122,"props":1178,"children":1179},{},[1180],{"type":31,"value":1181},"控制台无新增错误（至少关注 1 次真实操作）",{"type":26,"tag":122,"props":1183,"children":1184},{},[1185],{"type":31,"value":1186},"关键 UI 未错位（移动端/桌面端各看一眼）",{"type":26,"tag":122,"props":1188,"children":1189},{},[1190],{"type":31,"value":1191},"刷新后状态正确（尤其是表单/列表）",{"type":26,"tag":122,"props":1193,"children":1194},{},[1195],{"type":31,"value":1196},"路由跳转没断（从入口到目标页）",{"type":26,"tag":122,"props":1198,"children":1199},{},[1200],{"type":31,"value":1201},"相关接口未改变契约（字段名/类型）",{"type":26,"tag":122,"props":1203,"children":1204},{},[1205],{"type":31,"value":1206},"性能没有明显退化（首屏、交互卡顿）",{"type":26,"tag":122,"props":1208,"children":1209},{},[1210],{"type":31,"value":1211},"回滚方案可执行（知道回滚哪几个文件/commit）",{"type":26,"tag":122,"props":1213,"children":1214},{},[1215],{"type":31,"value":1216},"写下“这次改动解决了什么、风险是什么”（可贴 PR）",{"type":26,"tag":390,"props":1218,"children":1219},{},[],{"type":26,"tag":34,"props":1221,"children":1223},{"id":1222},"必交付物-2失败案例复盘真实会发生",[1224],{"type":31,"value":1225},"必交付物 2：失败案例复盘（真实会发生）",{"type":26,"tag":716,"props":1227,"children":1229},{"id":1228},"现象快捷键用得很熟但交付还是慢",[1230],{"type":31,"value":1231},"现象：快捷键用得很熟，但交付还是慢",{"type":26,"tag":27,"props":1233,"children":1234},{},[1235],{"type":31,"value":1236},"典型原因：你把 Cursor 当成“更聪明的搜索框”，不断对话，直到它给出你想要的答案。",{"type":26,"tag":27,"props":1238,"children":1239},{},[1240],{"type":31,"value":1241},"复现路径：",{"type":26,"tag":118,"props":1243,"children":1244},{},[1245,1250,1255,1260],{"type":26,"tag":122,"props":1246,"children":1247},{},[1248],{"type":31,"value":1249},"你直接说“把页面做得更好看、更高级”",{"type":26,"tag":122,"props":1251,"children":1252},{},[1253],{"type":31,"value":1254},"AI 开始大改样式、抽象组件、甚至引入新依赖",{"type":26,"tag":122,"props":1256,"children":1257},{},[1258],{"type":31,"value":1259},"你为了省事按了“接受建议”",{"type":26,"tag":122,"props":1261,"children":1262},{},[1263],{"type":31,"value":1264},"最后发现：设计没统一、移动端崩、甚至埋了性能问题",{"type":26,"tag":27,"props":1266,"children":1267},{},[1268,1270,1274,1276,1281],{"type":31,"value":1269},"根因：缺少",{"type":26,"tag":329,"props":1271,"children":1272},{},[1273],{"type":31,"value":454},{"type":31,"value":1275},"与",{"type":26,"tag":329,"props":1277,"children":1278},{},[1279],{"type":31,"value":1280},"验收",{"type":31,"value":1282},"。",{"type":26,"tag":27,"props":1284,"children":1285},{},[1286],{"type":31,"value":1287},"修复方式（可照抄）：",{"type":26,"tag":118,"props":1289,"children":1290},{},[1291,1296,1308],{"type":26,"tag":122,"props":1292,"children":1293},{},[1294],{"type":31,"value":1295},"把需求拆成 3 个可验证目标：例如“按钮样式统一”“首屏 CTA 更明显”“移动端间距不挤”",{"type":26,"tag":122,"props":1297,"children":1298},{},[1299,1301,1306],{"type":31,"value":1300},"每个目标只用 ",{"type":26,"tag":154,"props":1302,"children":1304},{"className":1303},[],[1305],{"type":31,"value":767},{"type":31,"value":1307}," 改一个局部",{"type":26,"tag":122,"props":1309,"children":1310},{},[1311],{"type":31,"value":1312},"每次接受建议前跑一遍“最小回归集”",{"type":26,"tag":390,"props":1314,"children":1315},{},[],{"type":26,"tag":34,"props":1317,"children":1319},{"id":1318},"faq高频问题",[1320],{"type":31,"value":1321},"FAQ（高频问题）",{"type":26,"tag":716,"props":1323,"children":1325},{"id":1324},"q1我应该先记快捷键还是先学工作流",[1326],{"type":31,"value":1327},"Q1：我应该先记快捷键还是先学工作流？",{"type":26,"tag":27,"props":1329,"children":1330},{},[1331],{"type":31,"value":1332},"先学工作流。快捷键只是把工作流的步骤变短。",{"type":26,"tag":716,"props":1334,"children":1336},{"id":1335},"q2为什么我一用多文件就容易翻车",[1337],{"type":31,"value":1338},"Q2：为什么我一用多文件就容易翻车？",{"type":26,"tag":27,"props":1340,"children":1341},{},[1342],{"type":31,"value":1343},"因为多文件意味着范围更大、依赖更多、验收更难。先锁定“文件清单 + 每步验收”，再让它动手。",{"type":26,"tag":716,"props":1345,"children":1347},{"id":1346},"q3有没有万能提示词",[1348],{"type":31,"value":1349},"Q3：有没有“万能提示词”？",{"type":26,"tag":27,"props":1351,"children":1352},{},[1353],{"type":31,"value":1354},"没有，但有“万能结构”：目标、范围、非目标、验收、输出格式。",{"type":26,"tag":390,"props":1356,"children":1357},{},[],{"type":26,"tag":34,"props":1359,"children":1361},{"id":1360},"延伸阅读建议按顺序",[1362],{"type":31,"value":1363},"延伸阅读（建议按顺序）",{"type":26,"tag":118,"props":1365,"children":1366},{},[1367,1374,1381,1388],{"type":26,"tag":122,"props":1368,"children":1369},{},[1370],{"type":26,"tag":234,"props":1371,"children":1372},{"href":363},[1373],{"type":31,"value":366},{"type":26,"tag":122,"props":1375,"children":1376},{},[1377],{"type":26,"tag":234,"props":1378,"children":1379},{"href":374},[1380],{"type":31,"value":377},{"type":26,"tag":122,"props":1382,"children":1383},{},[1384],{"type":26,"tag":234,"props":1385,"children":1386},{"href":385},[1387],{"type":31,"value":388},{"type":26,"tag":122,"props":1389,"children":1390},{},[1391,1393],{"type":31,"value":1392},"如果你更关心“网页制作落地”：看这篇 ",{"type":26,"tag":234,"props":1394,"children":1396},{"href":1395},"/topics/practical-tips/htmlpage-quick-landing-page",[1397],{"type":31,"value":1398},"3 分钟用 HTMLPAGE 做落地页",{"title":7,"searchDepth":259,"depth":259,"links":1400},[1401,1402,1403,1415,1416,1419,1424],{"id":395,"depth":262,"text":398},{"id":470,"depth":262,"text":473},{"id":711,"depth":262,"text":714,"children":1404},[1405,1406,1407,1408,1409,1410,1411,1412,1413,1414],{"id":718,"depth":259,"text":721},{"id":777,"depth":259,"text":780},{"id":847,"depth":259,"text":850},{"id":903,"depth":259,"text":906},{"id":943,"depth":259,"text":946},{"id":982,"depth":259,"text":985},{"id":1001,"depth":259,"text":1004},{"id":1043,"depth":259,"text":1046},{"id":1078,"depth":259,"text":1081},{"id":1095,"depth":259,"text":1098},{"id":1152,"depth":262,"text":1155},{"id":1222,"depth":262,"text":1225,"children":1417},[1418],{"id":1228,"depth":259,"text":1231},{"id":1318,"depth":262,"text":1321,"children":1420},[1421,1422,1423],{"id":1324,"depth":259,"text":1327},{"id":1335,"depth":259,"text":1338},{"id":1346,"depth":259,"text":1349},{"id":1360,"depth":262,"text":1363},"content:topics:ai:cursor-keyboard-shortcuts-cheatsheet.md","topics/ai/cursor-keyboard-shortcuts-cheatsheet.md","topics/ai/cursor-keyboard-shortcuts-cheatsheet",{"_path":1429,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":1430,"description":1431,"date":1432,"topic":5,"author":11,"tags":1433,"image":1437,"imageAlt":1438,"pexelsPhotoId":1439,"pexelsUrl":1440,"readingTime":1441,"body":1442,"_type":266,"_id":2375,"_source":268,"_file":2376,"_stem":2377,"_extension":271},"/topics/ai/cursor-vs-copilot-vscode-workflow","Cursor vs GitHub Copilot vs VS Code：怎么选、怎么搭配、怎么把风险关在笼子里","用“任务类型×风险×验收成本”的选择矩阵解释 Cursor/Copilot/VS Code 的差异，并给出一套可落地的协作工作流（范围闸门、最小回归集、回滚策略）。","2026-03-01",[279,1434,282,1435,1436],"GitHub Copilot","AI 编程","工作流","/images/topics/ai/cursor-vs-copilot-vscode-workflow.jpg","团队在电脑前进行协作讨论",1181371,"https://www.pexels.com/photo/man-wearing-blue-dress-shirt-1181371/",15,{"type":23,"children":1443,"toc":2353},[1444,1449,1454,1472,1477,1495,1498,1504,1509,1540,1545,1548,1554,1562,1766,1774,1787,1790,1796,1802,1815,1820,1833,1839,1844,1877,1883,1888,1906,1909,1915,1920,1926,1931,1964,1970,1983,1988,2001,2007,2019,2025,2030,2043,2048,2051,2057,2062,2183,2186,2192,2202,2211,2229,2238,2246,2255,2273,2276,2282,2288,2293,2299,2304,2307,2312],{"type":26,"tag":27,"props":1445,"children":1446},{},[1447],{"type":31,"value":1448},"“Cursor 和 Copilot 到底有什么区别？”",{"type":26,"tag":27,"props":1450,"children":1451},{},[1452],{"type":31,"value":1453},"这个问题问得越早越好，因为你一旦把工具选错，后面所有痛苦都不是“提示词不够好”，而是：",{"type":26,"tag":118,"props":1455,"children":1456},{},[1457,1462,1467],{"type":26,"tag":122,"props":1458,"children":1459},{},[1460],{"type":31,"value":1461},"改动不可控（范围漂移、改错文件）",{"type":26,"tag":122,"props":1463,"children":1464},{},[1465],{"type":31,"value":1466},"验收成本爆炸（不知道要测什么）",{"type":26,"tag":122,"props":1468,"children":1469},{},[1470],{"type":31,"value":1471},"团队协作崩盘（没有闸门、没有回滚）",{"type":26,"tag":27,"props":1473,"children":1474},{},[1475],{"type":31,"value":1476},"这篇文章用一张选择矩阵 + 一套可执行工作流，帮你做到两件事：",{"type":26,"tag":320,"props":1478,"children":1479},{},[1480,1485],{"type":26,"tag":122,"props":1481,"children":1482},{},[1483],{"type":31,"value":1484},"知道什么时候用 Cursor、什么时候用 Copilot、什么时候“纯 VS Code 更快”",{"type":26,"tag":122,"props":1486,"children":1487},{},[1488,1490],{"type":31,"value":1489},"就算用 AI，也能把风险关在笼子里：",{"type":26,"tag":329,"props":1491,"children":1492},{},[1493],{"type":31,"value":1494},"可审查、可验证、可回滚",{"type":26,"tag":390,"props":1496,"children":1497},{},[],{"type":26,"tag":34,"props":1499,"children":1501},{"id":1500},"结论先说三者不是互斥而是分工",[1502],{"type":31,"value":1503},"结论先说：三者不是互斥，而是分工",{"type":26,"tag":27,"props":1505,"children":1506},{},[1507],{"type":31,"value":1508},"你可以把它们看成三层能力：",{"type":26,"tag":118,"props":1510,"children":1511},{},[1512,1521,1531],{"type":26,"tag":122,"props":1513,"children":1514},{},[1515,1519],{"type":26,"tag":329,"props":1516,"children":1517},{},[1518],{"type":31,"value":282},{"type":31,"value":1520},"：编辑器与生态（调试、插件、任务、终端、语言服务）",{"type":26,"tag":122,"props":1522,"children":1523},{},[1524,1529],{"type":26,"tag":329,"props":1525,"children":1526},{},[1527],{"type":31,"value":1528},"Copilot",{"type":31,"value":1530},"：代码补全与局部建议（“我正在写这一行/这一段”）",{"type":26,"tag":122,"props":1532,"children":1533},{},[1534,1538],{"type":26,"tag":329,"props":1535,"children":1536},{},[1537],{"type":31,"value":279},{"type":31,"value":1539},"：以项目为单位的 AI 协作（对话、索引、多文件编辑、规则）",{"type":26,"tag":27,"props":1541,"children":1542},{},[1543],{"type":31,"value":1544},"最常见的误区是：把“局部补全能力”当作“能做架构与多文件落地”。",{"type":26,"tag":390,"props":1546,"children":1547},{},[],{"type":26,"tag":34,"props":1549,"children":1551},{"id":1550},"选择矩阵按任务类型选工具不是按偏好",[1552],{"type":31,"value":1553},"选择矩阵：按任务类型选工具（不是按偏好）",{"type":26,"tag":698,"props":1555,"children":1556},{},[1557],{"type":26,"tag":27,"props":1558,"children":1559},{},[1560],{"type":31,"value":1561},"你只要把自己的任务放进表格，就能得到推荐路径。",{"type":26,"tag":41,"props":1563,"children":1564},{},[1565,1597],{"type":26,"tag":45,"props":1566,"children":1567},{},[1568],{"type":26,"tag":49,"props":1569,"children":1570},{},[1571,1576,1582,1587,1592],{"type":26,"tag":53,"props":1572,"children":1573},{},[1574],{"type":31,"value":1575},"任务类型",{"type":26,"tag":53,"props":1577,"children":1579},{"align":1578},"right",[1580],{"type":31,"value":1581},"风险",{"type":26,"tag":53,"props":1583,"children":1584},{"align":1578},[1585],{"type":31,"value":1586},"验收成本",{"type":26,"tag":53,"props":1588,"children":1589},{},[1590],{"type":31,"value":1591},"更推荐",{"type":26,"tag":53,"props":1593,"children":1594},{},[1595],{"type":31,"value":1596},"为什么",{"type":26,"tag":64,"props":1598,"children":1599},{},[1600,1627,1660,1686,1713,1740],{"type":26,"tag":49,"props":1601,"children":1602},{},[1603,1608,1613,1617,1622],{"type":26,"tag":71,"props":1604,"children":1605},{},[1606],{"type":31,"value":1607},"写一段代码/补一个 if",{"type":26,"tag":71,"props":1609,"children":1610},{"align":1578},[1611],{"type":31,"value":1612},"低",{"type":26,"tag":71,"props":1614,"children":1615},{"align":1578},[1616],{"type":31,"value":1612},{"type":26,"tag":71,"props":1618,"children":1619},{},[1620],{"type":31,"value":1621},"Copilot / Cursor 内联编辑",{"type":26,"tag":71,"props":1623,"children":1624},{},[1625],{"type":31,"value":1626},"局部建议足够，成本最低",{"type":26,"tag":49,"props":1628,"children":1629},{},[1630,1635,1640,1644,1655],{"type":26,"tag":71,"props":1631,"children":1632},{},[1633],{"type":31,"value":1634},"重构一个函数",{"type":26,"tag":71,"props":1636,"children":1637},{"align":1578},[1638],{"type":31,"value":1639},"中",{"type":26,"tag":71,"props":1641,"children":1642},{"align":1578},[1643],{"type":31,"value":1639},{"type":26,"tag":71,"props":1645,"children":1646},{},[1647,1649],{"type":31,"value":1648},"Cursor ",{"type":26,"tag":154,"props":1650,"children":1652},{"className":1651},[],[1653],{"type":31,"value":1654},"内联编辑",{"type":26,"tag":71,"props":1656,"children":1657},{},[1658],{"type":31,"value":1659},"需要解释、需要约束输出",{"type":26,"tag":49,"props":1661,"children":1662},{},[1663,1668,1672,1676,1681],{"type":26,"tag":71,"props":1664,"children":1665},{},[1666],{"type":31,"value":1667},"改一个组件 + 样式",{"type":26,"tag":71,"props":1669,"children":1670},{"align":1578},[1671],{"type":31,"value":1639},{"type":26,"tag":71,"props":1673,"children":1674},{"align":1578},[1675],{"type":31,"value":1639},{"type":26,"tag":71,"props":1677,"children":1678},{},[1679],{"type":31,"value":1680},"Cursor（小范围多文件）",{"type":26,"tag":71,"props":1682,"children":1683},{},[1684],{"type":31,"value":1685},"需要同时改模板与样式",{"type":26,"tag":49,"props":1687,"children":1688},{},[1689,1694,1699,1703,1708],{"type":26,"tag":71,"props":1690,"children":1691},{},[1692],{"type":31,"value":1693},"改 3~5 个文件（组件+api+测试）",{"type":26,"tag":71,"props":1695,"children":1696},{"align":1578},[1697],{"type":31,"value":1698},"高",{"type":26,"tag":71,"props":1700,"children":1701},{"align":1578},[1702],{"type":31,"value":1698},{"type":26,"tag":71,"props":1704,"children":1705},{},[1706],{"type":31,"value":1707},"Cursor Composer + 闸门",{"type":26,"tag":71,"props":1709,"children":1710},{},[1711],{"type":31,"value":1712},"需要计划、验收、回滚",{"type":26,"tag":49,"props":1714,"children":1715},{},[1716,1721,1726,1730,1735],{"type":26,"tag":71,"props":1717,"children":1718},{},[1719],{"type":31,"value":1720},"重写一段架构/引入新依赖",{"type":26,"tag":71,"props":1722,"children":1723},{"align":1578},[1724],{"type":31,"value":1725},"很高",{"type":26,"tag":71,"props":1727,"children":1728},{"align":1578},[1729],{"type":31,"value":1725},{"type":26,"tag":71,"props":1731,"children":1732},{},[1733],{"type":31,"value":1734},"先人脑设计 + VS Code 实现",{"type":26,"tag":71,"props":1736,"children":1737},{},[1738],{"type":31,"value":1739},"AI 易发散，最好先设计再执行",{"type":26,"tag":49,"props":1741,"children":1742},{},[1743,1748,1752,1756,1761],{"type":26,"tag":71,"props":1744,"children":1745},{},[1746],{"type":31,"value":1747},"排查线上问题/性能抖动",{"type":26,"tag":71,"props":1749,"children":1750},{"align":1578},[1751],{"type":31,"value":1698},{"type":26,"tag":71,"props":1753,"children":1754},{"align":1578},[1755],{"type":31,"value":1725},{"type":26,"tag":71,"props":1757,"children":1758},{},[1759],{"type":31,"value":1760},"VS Code + 工具链优先，AI 辅助归纳",{"type":26,"tag":71,"props":1762,"children":1763},{},[1764],{"type":31,"value":1765},"需要证据，不要“猜”",{"type":26,"tag":27,"props":1767,"children":1768},{},[1769],{"type":26,"tag":329,"props":1770,"children":1771},{},[1772],{"type":31,"value":1773},"一句话规则：",{"type":26,"tag":118,"props":1775,"children":1776},{},[1777,1782],{"type":26,"tag":122,"props":1778,"children":1779},{},[1780],{"type":31,"value":1781},"当你的改动可以用“10 条最小回归集”覆盖时，用 Cursor。",{"type":26,"tag":122,"props":1783,"children":1784},{},[1785],{"type":31,"value":1786},"当你的改动无法验证时，先别让 AI 动手。",{"type":26,"tag":390,"props":1788,"children":1789},{},[],{"type":26,"tag":34,"props":1791,"children":1793},{"id":1792},"差异拆解到底差在哪里",[1794],{"type":31,"value":1795},"差异拆解：到底差在哪里？",{"type":26,"tag":716,"props":1797,"children":1799},{"id":1798},"_1-上下文来源补全-vs-项目索引",[1800],{"type":31,"value":1801},"1) 上下文来源：补全 vs 项目索引",{"type":26,"tag":118,"props":1803,"children":1804},{},[1805,1810],{"type":26,"tag":122,"props":1806,"children":1807},{},[1808],{"type":31,"value":1809},"Copilot 更擅长：你正在写的这几行、当前文件的局部上下文",{"type":26,"tag":122,"props":1811,"children":1812},{},[1813],{"type":31,"value":1814},"Cursor 更擅长：项目级索引 + 多文件关联理解",{"type":26,"tag":27,"props":1816,"children":1817},{},[1818],{"type":31,"value":1819},"因此：",{"type":26,"tag":118,"props":1821,"children":1822},{},[1823,1828],{"type":26,"tag":122,"props":1824,"children":1825},{},[1826],{"type":31,"value":1827},"写代码片段：Copilot 速度更快",{"type":26,"tag":122,"props":1829,"children":1830},{},[1831],{"type":31,"value":1832},"改一坨工程：Cursor 更有胜算（但更需要闸门）",{"type":26,"tag":716,"props":1834,"children":1836},{"id":1835},"_2-交互方式你能不能控制范围",[1837],{"type":31,"value":1838},"2) 交互方式：你能不能控制范围",{"type":26,"tag":27,"props":1840,"children":1841},{},[1842],{"type":31,"value":1843},"范围控制的三个层级：",{"type":26,"tag":320,"props":1845,"children":1846},{},[1847,1857,1867],{"type":26,"tag":122,"props":1848,"children":1849},{},[1850,1852],{"type":31,"value":1851},"内联编辑（选中一段）→ ",{"type":26,"tag":329,"props":1853,"children":1854},{},[1855],{"type":31,"value":1856},"最强范围控制",{"type":26,"tag":122,"props":1858,"children":1859},{},[1860,1862],{"type":31,"value":1861},"Composer 多文件（先列文件清单）→ ",{"type":26,"tag":329,"props":1863,"children":1864},{},[1865],{"type":31,"value":1866},"可控但要闸门",{"type":26,"tag":122,"props":1868,"children":1869},{},[1870,1872],{"type":31,"value":1871},"大对话（泛目标）→ ",{"type":26,"tag":329,"props":1873,"children":1874},{},[1875],{"type":31,"value":1876},"最容易跑偏",{"type":26,"tag":716,"props":1878,"children":1880},{"id":1879},"_3-输出形态建议-vs-可审查的变更",[1881],{"type":31,"value":1882},"3) 输出形态：建议 vs 可审查的变更",{"type":26,"tag":27,"props":1884,"children":1885},{},[1886],{"type":31,"value":1887},"最好的 AI 输出不是“给我一段代码”，而是：",{"type":26,"tag":118,"props":1889,"children":1890},{},[1891,1896,1901],{"type":26,"tag":122,"props":1892,"children":1893},{},[1894],{"type":31,"value":1895},"改动摘要（做了什么）",{"type":26,"tag":122,"props":1897,"children":1898},{},[1899],{"type":31,"value":1900},"diff 级别的可审查变更",{"type":26,"tag":122,"props":1902,"children":1903},{},[1904],{"type":31,"value":1905},"验收步骤与回滚方案",{"type":26,"tag":390,"props":1907,"children":1908},{},[],{"type":26,"tag":34,"props":1910,"children":1912},{"id":1911},"一套可落地的团队工作流把风险关住",[1913],{"type":31,"value":1914},"一套可落地的团队工作流（把风险关住）",{"type":26,"tag":27,"props":1916,"children":1917},{},[1918],{"type":31,"value":1919},"下面这套流程，你可以直接写进团队规范：",{"type":26,"tag":716,"props":1921,"children":1923},{"id":1922},"step-1先写任务单geo-友好结构",[1924],{"type":31,"value":1925},"Step 1：先写任务单（GEO 友好结构）",{"type":26,"tag":27,"props":1927,"children":1928},{},[1929],{"type":31,"value":1930},"模板：",{"type":26,"tag":118,"props":1932,"children":1933},{},[1934,1939,1944,1949,1954,1959],{"type":26,"tag":122,"props":1935,"children":1936},{},[1937],{"type":31,"value":1938},"目标：……",{"type":26,"tag":122,"props":1940,"children":1941},{},[1942],{"type":31,"value":1943},"背景：……",{"type":26,"tag":122,"props":1945,"children":1946},{},[1947],{"type":31,"value":1948},"范围：只改这些文件/模块：……",{"type":26,"tag":122,"props":1950,"children":1951},{},[1952],{"type":31,"value":1953},"非目标：不做哪些事情：……",{"type":26,"tag":122,"props":1955,"children":1956},{},[1957],{"type":31,"value":1958},"验收：如何判断完成（可测试/可观察）：……",{"type":26,"tag":122,"props":1960,"children":1961},{},[1962],{"type":31,"value":1963},"回滚：如果失败怎么撤回：……",{"type":26,"tag":716,"props":1965,"children":1967},{"id":1966},"step-2用范围闸门限制-ai",[1968],{"type":31,"value":1969},"Step 2：用“范围闸门”限制 AI",{"type":26,"tag":118,"props":1971,"children":1972},{},[1973,1978],{"type":26,"tag":122,"props":1974,"children":1975},{},[1976],{"type":31,"value":1977},"单文件改动：优先 Cursor 内联编辑",{"type":26,"tag":122,"props":1979,"children":1980},{},[1981],{"type":31,"value":1982},"多文件改动：必须先让 AI 输出“文件清单（≤5）+ 每步验收”",{"type":26,"tag":27,"props":1984,"children":1985},{},[1986],{"type":31,"value":1987},"如果 AI 输出的文件清单超过 5 个：",{"type":26,"tag":118,"props":1989,"children":1990},{},[1991,1996],{"type":26,"tag":122,"props":1992,"children":1993},{},[1994],{"type":31,"value":1995},"不是它太强，是任务太大",{"type":26,"tag":122,"props":1997,"children":1998},{},[1999],{"type":31,"value":2000},"你需要拆任务，而不是继续推进",{"type":26,"tag":716,"props":2002,"children":2004},{"id":2003},"step-3最小回归集10-条",[2005],{"type":31,"value":2006},"Step 3：最小回归集（10 条）",{"type":26,"tag":27,"props":2008,"children":2009},{},[2010,2012,2017],{"type":31,"value":2011},"每次接受改动前必须跑（可参考：",{"type":26,"tag":234,"props":2013,"children":2014},{"href":274},[2015],{"type":31,"value":2016},"Cursor 快捷键速查表",{"type":31,"value":2018}," 里的清单）。",{"type":26,"tag":716,"props":2020,"children":2022},{"id":2021},"step-4回滚策略不用等事故才想",[2023],{"type":31,"value":2024},"Step 4：回滚策略（不用等事故才想）",{"type":26,"tag":27,"props":2026,"children":2027},{},[2028],{"type":31,"value":2029},"回滚最常见的两条路：",{"type":26,"tag":118,"props":2031,"children":2032},{},[2033,2038],{"type":26,"tag":122,"props":2034,"children":2035},{},[2036],{"type":31,"value":2037},"git 回滚 commit",{"type":26,"tag":122,"props":2039,"children":2040},{},[2041],{"type":31,"value":2042},"对关键文件保留前版本（至少能快速恢复）",{"type":26,"tag":27,"props":2044,"children":2045},{},[2046],{"type":31,"value":2047},"你需要做到：任何一轮 AI 改动都能在 5 分钟内撤回。",{"type":26,"tag":390,"props":2049,"children":2050},{},[],{"type":26,"tag":34,"props":2052,"children":2054},{"id":2053},"必交付物对比矩阵可复制",[2055],{"type":31,"value":2056},"必交付物：对比矩阵（可复制）",{"type":26,"tag":27,"props":2058,"children":2059},{},[2060],{"type":31,"value":2061},"下面这张表可以直接贴到你的团队 wiki：",{"type":26,"tag":41,"props":2063,"children":2064},{},[2065,2088],{"type":26,"tag":45,"props":2066,"children":2067},{},[2068],{"type":26,"tag":49,"props":2069,"children":2070},{},[2071,2076,2080,2084],{"type":26,"tag":53,"props":2072,"children":2073},{},[2074],{"type":31,"value":2075},"维度",{"type":26,"tag":53,"props":2077,"children":2078},{},[2079],{"type":31,"value":282},{"type":26,"tag":53,"props":2081,"children":2082},{},[2083],{"type":31,"value":1528},{"type":26,"tag":53,"props":2085,"children":2086},{},[2087],{"type":31,"value":279},{"type":26,"tag":64,"props":2089,"children":2090},{},[2091,2114,2137,2160],{"type":26,"tag":49,"props":2092,"children":2093},{},[2094,2099,2104,2109],{"type":26,"tag":71,"props":2095,"children":2096},{},[2097],{"type":31,"value":2098},"强项",{"type":26,"tag":71,"props":2100,"children":2101},{},[2102],{"type":31,"value":2103},"工具链、调试、生态",{"type":26,"tag":71,"props":2105,"children":2106},{},[2107],{"type":31,"value":2108},"补全与局部建议",{"type":26,"tag":71,"props":2110,"children":2111},{},[2112],{"type":31,"value":2113},"项目上下文、多文件落地",{"type":26,"tag":49,"props":2115,"children":2116},{},[2117,2122,2127,2132],{"type":26,"tag":71,"props":2118,"children":2119},{},[2120],{"type":31,"value":2121},"适合任务",{"type":26,"tag":71,"props":2123,"children":2124},{},[2125],{"type":31,"value":2126},"排查、调试、验证",{"type":26,"tag":71,"props":2128,"children":2129},{},[2130],{"type":31,"value":2131},"写一段、补一段",{"type":26,"tag":71,"props":2133,"children":2134},{},[2135],{"type":31,"value":2136},"改一段、改一组文件",{"type":26,"tag":49,"props":2138,"children":2139},{},[2140,2145,2150,2155],{"type":26,"tag":71,"props":2141,"children":2142},{},[2143],{"type":31,"value":2144},"最大风险",{"type":26,"tag":71,"props":2146,"children":2147},{},[2148],{"type":31,"value":2149},"无",{"type":26,"tag":71,"props":2151,"children":2152},{},[2153],{"type":31,"value":2154},"过度依赖建议",{"type":26,"tag":71,"props":2156,"children":2157},{},[2158],{"type":31,"value":2159},"范围漂移、多文件回归",{"type":26,"tag":49,"props":2161,"children":2162},{},[2163,2168,2173,2178],{"type":26,"tag":71,"props":2164,"children":2165},{},[2166],{"type":31,"value":2167},"必须搭配",{"type":26,"tag":71,"props":2169,"children":2170},{},[2171],{"type":31,"value":2172},"规范与检查",{"type":26,"tag":71,"props":2174,"children":2175},{},[2176],{"type":31,"value":2177},"代码评审",{"type":26,"tag":71,"props":2179,"children":2180},{},[2181],{"type":31,"value":2182},"闸门 + 最小回归集",{"type":26,"tag":390,"props":2184,"children":2185},{},[],{"type":26,"tag":34,"props":2187,"children":2189},{"id":2188},"失败案例多文件看似成功实际埋雷",[2190],{"type":31,"value":2191},"失败案例：多文件“看似成功”，实际埋雷",{"type":26,"tag":27,"props":2193,"children":2194},{},[2195,2200],{"type":26,"tag":329,"props":2196,"children":2197},{},[2198],{"type":31,"value":2199},"现象",{"type":31,"value":2201},"：AI 说“我已经把所有地方都改了”，你也接受了，结果上线后 404 或样式错位。",{"type":26,"tag":27,"props":2203,"children":2204},{},[2205,2210],{"type":26,"tag":329,"props":2206,"children":2207},{},[2208],{"type":31,"value":2209},"复现条件",{"type":31,"value":1022},{"type":26,"tag":118,"props":2212,"children":2213},{},[2214,2219,2224],{"type":26,"tag":122,"props":2215,"children":2216},{},[2217],{"type":31,"value":2218},"你给了一个大目标（例如“把所有按钮统一成主题色”）",{"type":26,"tag":122,"props":2220,"children":2221},{},[2222],{"type":31,"value":2223},"它改了组件、样式、甚至主题配置",{"type":26,"tag":122,"props":2225,"children":2226},{},[2227],{"type":31,"value":2228},"你没有按页面模块走一遍，直接合并",{"type":26,"tag":27,"props":2230,"children":2231},{},[2232,2237],{"type":26,"tag":329,"props":2233,"children":2234},{},[2235],{"type":31,"value":2236},"根因",{"type":31,"value":1022},{"type":26,"tag":118,"props":2239,"children":2240},{},[2241],{"type":26,"tag":122,"props":2242,"children":2243},{},[2244],{"type":31,"value":2245},"改动范围大，但验收仍按“小改动”的方式做（只看一处）",{"type":26,"tag":27,"props":2247,"children":2248},{},[2249,2254],{"type":26,"tag":329,"props":2250,"children":2251},{},[2252],{"type":31,"value":2253},"修复",{"type":31,"value":1022},{"type":26,"tag":118,"props":2256,"children":2257},{},[2258,2263,2268],{"type":26,"tag":122,"props":2259,"children":2260},{},[2261],{"type":31,"value":2262},"强制把任务拆成“模块级目标”：Hero、Feature、Pricing、Form",{"type":26,"tag":122,"props":2264,"children":2265},{},[2266],{"type":31,"value":2267},"每个模块改完就验收一次",{"type":26,"tag":122,"props":2269,"children":2270},{},[2271],{"type":31,"value":2272},"验收通过再进入下一个模块",{"type":26,"tag":390,"props":2274,"children":2275},{},[],{"type":26,"tag":34,"props":2277,"children":2279},{"id":2278},"faq",[2280],{"type":31,"value":2281},"FAQ",{"type":26,"tag":716,"props":2283,"children":2285},{"id":2284},"q1我已经用了-cursor为什么还要用-copilot",[2286],{"type":31,"value":2287},"Q1：我已经用了 Cursor，为什么还要用 Copilot？",{"type":26,"tag":27,"props":2289,"children":2290},{},[2291],{"type":31,"value":2292},"因为“补全”这种高频低风险任务，Copilot 的交互成本更低；Cursor 更适合需要解释与约束的改动。",{"type":26,"tag":716,"props":2294,"children":2296},{"id":2295},"q2什么时候应该完全不用-ai",[2297],{"type":31,"value":2298},"Q2：什么时候应该完全不用 AI？",{"type":26,"tag":27,"props":2300,"children":2301},{},[2302],{"type":31,"value":2303},"当你无法定义验收标准时。比如“更高级”“更好看”这种目标，先做信息结构与设计规则，再让 AI 帮你落地局部。",{"type":26,"tag":390,"props":2305,"children":2306},{},[],{"type":26,"tag":34,"props":2308,"children":2310},{"id":2309},"延伸阅读",[2311],{"type":31,"value":2309},{"type":26,"tag":118,"props":2313,"children":2314},{},[2315,2324,2333,2342],{"type":26,"tag":122,"props":2316,"children":2317},{},[2318,2320],{"type":31,"value":2319},"Cursor 入门：",{"type":26,"tag":234,"props":2321,"children":2322},{"href":363},[2323],{"type":31,"value":366},{"type":26,"tag":122,"props":2325,"children":2326},{},[2327,2329],{"type":31,"value":2328},"Cursor 进阶：",{"type":26,"tag":234,"props":2330,"children":2331},{"href":374},[2332],{"type":31,"value":377},{"type":26,"tag":122,"props":2334,"children":2335},{},[2336,2338],{"type":31,"value":2337},"规则配置：",{"type":26,"tag":234,"props":2339,"children":2340},{"href":385},[2341],{"type":31,"value":388},{"type":26,"tag":122,"props":2343,"children":2344},{},[2345,2347],{"type":31,"value":2346},"Copilot 实战：",{"type":26,"tag":234,"props":2348,"children":2350},{"href":2349},"/topics/ai/github-copilot-tips",[2351],{"type":31,"value":2352},"GitHub Copilot 实用技巧",{"title":7,"searchDepth":259,"depth":259,"links":2354},[2355,2356,2357,2362,2368,2369,2370,2374],{"id":1500,"depth":262,"text":1503},{"id":1550,"depth":262,"text":1553},{"id":1792,"depth":262,"text":1795,"children":2358},[2359,2360,2361],{"id":1798,"depth":259,"text":1801},{"id":1835,"depth":259,"text":1838},{"id":1879,"depth":259,"text":1882},{"id":1911,"depth":262,"text":1914,"children":2363},[2364,2365,2366,2367],{"id":1922,"depth":259,"text":1925},{"id":1966,"depth":259,"text":1969},{"id":2003,"depth":259,"text":2006},{"id":2021,"depth":259,"text":2024},{"id":2053,"depth":262,"text":2056},{"id":2188,"depth":262,"text":2191},{"id":2278,"depth":262,"text":2281,"children":2371},[2372,2373],{"id":2284,"depth":259,"text":2287},{"id":2295,"depth":259,"text":2298},{"id":2309,"depth":262,"text":2309},"content:topics:ai:cursor-vs-copilot-vscode-workflow.md","topics/ai/cursor-vs-copilot-vscode-workflow.md","topics/ai/cursor-vs-copilot-vscode-workflow",{"_path":2379,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":2380,"description":2381,"date":2382,"topic":5,"author":11,"tags":2383,"image":2388,"featured":181,"readingTime":1441,"body":2389,"_type":266,"_id":3038,"_source":268,"_file":3039,"_stem":3040,"_extension":271},"/topics/ai/ai-debugging-troubleshooting-guide","AI 辅助调试与问题排查：让 AI 成为你的调试搭档","深入探讨如何利用 AI 工具提升调试效率，包括错误信息分析、日志解读、性能问题定位、复杂 bug 排查等实战场景，构建 AI 驱动的调试工作流。","2026-01-18",[2384,2385,2386,283,2387],"AI 调试","问题排查","Debug","错误处理","/images/topics/ai/ai-debugging-guide.jpg",{"type":23,"children":2390,"toc":3009},[2391,2397,2403,2408,2413,2418,2424,2430,2435,2443,2471,2479,2502,2508,2519,2528,2536,2544,2577,2585,2615,2628,2636,2641,2649,2657,2668,2674,2682,2693,2701,2710,2716,2722,2727,2736,2742,2747,2756,2762,2768,2777,2783,2792,2798,2809,2815,2821,2830,2836,2845,2851,2857,2865,2871,2880,2888,2896,2899,2905,2910,2929,2941,2944,2950,2955,2964,2969,2972,2978,2983,3001],{"type":26,"tag":34,"props":2392,"children":2394},{"id":2393},"ai-辅助调试与问题排查",[2395],{"type":31,"value":2396},"AI 辅助调试与问题排查",{"type":26,"tag":34,"props":2398,"children":2400},{"id":2399},"引言调试的痛与-ai-的解药",[2401],{"type":31,"value":2402},"引言：调试的痛与 AI 的解药",{"type":26,"tag":27,"props":2404,"children":2405},{},[2406],{"type":31,"value":2407},"调试是每个程序员的日常，也是最消耗时间和精力的工作之一。我们都有过这样的经历：盯着一个莫名其妙的错误信息，翻遍 Stack Overflow，尝试各种方案，几个小时后才发现是一个愚蠢的拼写错误。",{"type":26,"tag":27,"props":2409,"children":2410},{},[2411],{"type":31,"value":2412},"AI 工具的出现，正在改变调试的方式。不是替代你的思考，而是加速你的分析过程——帮你快速理解错误、缩小排查范围、验证假设。",{"type":26,"tag":27,"props":2414,"children":2415},{},[2416],{"type":31,"value":2417},"这篇文章分享我在实际项目中使用 AI 辅助调试的经验和方法论。",{"type":26,"tag":34,"props":2419,"children":2421},{"id":2420},"第一部分建立-ai-调试的思维模型",[2422],{"type":31,"value":2423},"第一部分：建立 AI 调试的思维模型",{"type":26,"tag":716,"props":2425,"children":2427},{"id":2426},"_11-ai-在调试中的角色",[2428],{"type":31,"value":2429},"1.1 AI 在调试中的角色",{"type":26,"tag":27,"props":2431,"children":2432},{},[2433],{"type":31,"value":2434},"把 AI 想象成一个经验丰富但不了解你项目的高级工程师。它：",{"type":26,"tag":27,"props":2436,"children":2437},{},[2438],{"type":26,"tag":329,"props":2439,"children":2440},{},[2441],{"type":31,"value":2442},"擅长的事情：",{"type":26,"tag":118,"props":2444,"children":2445},{},[2446,2451,2456,2461,2466],{"type":26,"tag":122,"props":2447,"children":2448},{},[2449],{"type":31,"value":2450},"解读错误信息的含义",{"type":26,"tag":122,"props":2452,"children":2453},{},[2454],{"type":31,"value":2455},"提供可能的原因列表",{"type":26,"tag":122,"props":2457,"children":2458},{},[2459],{"type":31,"value":2460},"给出排查方向建议",{"type":26,"tag":122,"props":2462,"children":2463},{},[2464],{"type":31,"value":2465},"解释复杂的技术概念",{"type":26,"tag":122,"props":2467,"children":2468},{},[2469],{"type":31,"value":2470},"生成调试代码片段",{"type":26,"tag":27,"props":2472,"children":2473},{},[2474],{"type":26,"tag":329,"props":2475,"children":2476},{},[2477],{"type":31,"value":2478},"不擅长的事情：",{"type":26,"tag":118,"props":2480,"children":2481},{},[2482,2487,2492,2497],{"type":26,"tag":122,"props":2483,"children":2484},{},[2485],{"type":31,"value":2486},"了解你的业务逻辑",{"type":26,"tag":122,"props":2488,"children":2489},{},[2490],{"type":31,"value":2491},"知道你的代码历史",{"type":26,"tag":122,"props":2493,"children":2494},{},[2495],{"type":31,"value":2496},"理解项目特定的约定",{"type":26,"tag":122,"props":2498,"children":2499},{},[2500],{"type":31,"value":2501},"做出架构级判断",{"type":26,"tag":716,"props":2503,"children":2505},{"id":2504},"_12-有效提问的结构",[2506],{"type":31,"value":2507},"1.2 有效提问的结构",{"type":26,"tag":2509,"props":2510,"children":2514},"pre",{"code":2511,"language":266,"meta":7,"className":2512},"## 高效的调试提问模板\n\n**问题描述**\n[简洁描述遇到的问题]\n\n**错误信息**\n",[2513],"language-markdown",[2515],{"type":26,"tag":154,"props":2516,"children":2517},{"__ignoreMap":7},[2518],{"type":31,"value":2511},{"type":26,"tag":27,"props":2520,"children":2521},{},[2522],{"type":26,"tag":2523,"props":2524,"children":2525},"span",{},[2526],{"type":31,"value":2527},"完整的错误信息，不要截断",{"type":26,"tag":2509,"props":2529,"children":2531},{"code":2530},"\n**相关代码**\n```javascript\n[精简但完整的相关代码]\n",[2532],{"type":26,"tag":154,"props":2533,"children":2534},{"__ignoreMap":7},[2535],{"type":31,"value":2530},{"type":26,"tag":27,"props":2537,"children":2538},{},[2539],{"type":26,"tag":329,"props":2540,"children":2541},{},[2542],{"type":31,"value":2543},"环境信息",{"type":26,"tag":118,"props":2545,"children":2546},{},[2547,2557,2567],{"type":26,"tag":122,"props":2548,"children":2549},{},[2550,2552],{"type":31,"value":2551},"运行环境：",{"type":26,"tag":2523,"props":2553,"children":2554},{},[2555],{"type":31,"value":2556},"Node 版本/浏览器版本",{"type":26,"tag":122,"props":2558,"children":2559},{},[2560,2562],{"type":31,"value":2561},"框架版本：",{"type":26,"tag":2523,"props":2563,"children":2564},{},[2565],{"type":31,"value":2566},"相关框架版本",{"type":26,"tag":122,"props":2568,"children":2569},{},[2570,2572],{"type":31,"value":2571},"操作系统：",{"type":26,"tag":2523,"props":2573,"children":2574},{},[2575],{"type":31,"value":2576},"如果相关",{"type":26,"tag":27,"props":2578,"children":2579},{},[2580],{"type":26,"tag":329,"props":2581,"children":2582},{},[2583],{"type":31,"value":2584},"已尝试的方案",{"type":26,"tag":118,"props":2586,"children":2587},{},[2588,2602],{"type":26,"tag":122,"props":2589,"children":2590},{},[2591,2596,2597],{"type":26,"tag":2523,"props":2592,"children":2593},{},[2594],{"type":31,"value":2595},"方案1",{"type":31,"value":1022},{"type":26,"tag":2523,"props":2598,"children":2599},{},[2600],{"type":31,"value":2601},"结果",{"type":26,"tag":122,"props":2603,"children":2604},{},[2605,2610,2611],{"type":26,"tag":2523,"props":2606,"children":2607},{},[2608],{"type":31,"value":2609},"方案2",{"type":31,"value":1022},{"type":26,"tag":2523,"props":2612,"children":2613},{},[2614],{"type":31,"value":2601},{"type":26,"tag":27,"props":2616,"children":2617},{},[2618,2623],{"type":26,"tag":329,"props":2619,"children":2620},{},[2621],{"type":31,"value":2622},"期望的结果",{"type":26,"tag":2523,"props":2624,"children":2625},{},[2626],{"type":31,"value":2627},"描述期望的行为",{"type":26,"tag":2509,"props":2629,"children":2631},{"code":2630},"\n### 1.3 分级调试策略\n\n",[2632],{"type":26,"tag":154,"props":2633,"children":2634},{"__ignoreMap":7},[2635],{"type":31,"value":2630},{"type":26,"tag":27,"props":2637,"children":2638},{},[2639],{"type":31,"value":2640},"┌───────────────────────────────────────────────────────────┐\n│                    AI 辅助调试决策树                        │\n├───────────────────────────────────────────────────────────┤\n│                                                           │\n│  Level 1：简单错误（5分钟内解决）                           │\n│  ├── 语法错误、拼写错误                                    │\n│  ├── 方法：直接复制错误信息给 AI                           │\n│  └── 工具：Copilot Chat / ChatGPT                        │\n│                                                           │\n│  Level 2：中等复杂度（30分钟内解决）                        │\n│  ├── 类型错误、逻辑错误、API 使用错误                      │\n│  ├── 方法：提供错误信息 + 相关代码 + 上下文                 │\n│  └── 工具：Cursor Chat / Claude                          │\n│                                                           │\n│  Level 3：复杂问题（需要深入分析）                          │\n│  ├── 竞态条件、内存泄漏、性能问题                          │\n│  ├── 方法：详细描述场景 + 提供多个文件 + 讨论               │\n│  └── 工具：Cursor Composer / 专门的 AI 会话                │\n│                                                           │\n│  Level 4：架构级问题                                       │\n│  ├── 设计缺陷、技术债务                                    │\n│  ├── 方法：AI 辅助分析 + 人工判断                          │\n│  └── 工具：与团队讨论 + AI 作为顾问                        │\n│                                                           │\n└───────────────────────────────────────────────────────────┘",{"type":26,"tag":2509,"props":2642,"children":2644},{"code":2643},"\n## 第二部分：错误信息分析\n\n### 2.1 前端错误分析\n\n**场景 1：React 错误边界触发**\n\n```typescript\n// 错误信息：\n// Error: Hydration failed because the initial UI does not match \n// what was rendered on the server.\n\n// 提问方式：\n/**\n * 我在 Next.js 14 App Router 项目中遇到这个错误：\n * \n * Error: Hydration failed because the initial UI does not match \n * what was rendered on the server.\n * \n * 相关代码：\n */\nfunction UserStatus() {\n  const [isLoggedIn, setIsLoggedIn] = useState(false);\n  \n  useEffect(() => {\n    setIsLoggedIn(localStorage.getItem('token') !== null);\n  }, []);\n  \n  return \u003Cdiv>{isLoggedIn ? '已登录' : '未登录'}\u003C/div>;\n}\n\n// AI 会分析出：\n// 1. 服务端渲染时 localStorage 不可用，默认 false\n// 2. 客户端 hydration 时可能是 true\n// 3. 导致服务端和客户端渲染结果不一致\n\n// AI 建议的解决方案：\nfunction UserStatus() {\n  const [isLoggedIn, setIsLoggedIn] = useState\u003Cboolean | null>(null);\n  \n  useEffect(() => {\n    setIsLoggedIn(localStorage.getItem('token') !== null);\n  }, []);\n  \n  // 初始状态显示加载中，避免 hydration 不匹配\n  if (isLoggedIn === null) {\n    return \u003Cdiv>加载中...\u003C/div>;\n  }\n  \n  return \u003Cdiv>{isLoggedIn ? '已登录' : '未登录'}\u003C/div>;\n}\n",[2645],{"type":26,"tag":154,"props":2646,"children":2647},{"__ignoreMap":7},[2648],{"type":31,"value":2643},{"type":26,"tag":27,"props":2650,"children":2651},{},[2652],{"type":26,"tag":329,"props":2653,"children":2654},{},[2655],{"type":31,"value":2656},"场景 2：Vue 响应式警告",{"type":26,"tag":2509,"props":2658,"children":2663},{"code":2659,"language":2660,"meta":7,"className":2661},"// 警告信息：\n// [Vue warn]: Property \"xxx\" was accessed during render but is not \n// defined on instance.\n\n// 提问方式：\n/**\n * Vue 3 项目中出现这个警告：\n * [Vue warn]: Property \"userInfo\" was accessed during render \n * but is not defined on instance.\n * \n * 组件代码：\n */\n\u003Ctemplate>\n  \u003Cdiv>{{ userInfo.name }}\u003C/div>\n\u003C/template>\n\n\u003Cscript setup>\nconst { data: userInfo } = await useFetch('/api/user');\n\u003C/script>\n\n// AI 分析：\n// 1. useFetch 是异步的，初始渲染时 userInfo 可能是 undefined\n// 2. 直接访问 userInfo.name 会报错\n\n// AI 建议：\n\u003Ctemplate>\n  \u003Cdiv v-if=\"userInfo\">{{ userInfo.name }}\u003C/div>\n  \u003Cdiv v-else>加载中...\u003C/div>\n\u003C/template>\n\n\u003Cscript setup>\nconst { data: userInfo, pending } = await useFetch('/api/user');\n\u003C/script>\n","typescript",[2662],"language-typescript",[2664],{"type":26,"tag":154,"props":2665,"children":2666},{"__ignoreMap":7},[2667],{"type":31,"value":2659},{"type":26,"tag":716,"props":2669,"children":2671},{"id":2670},"_22-后端错误分析",[2672],{"type":31,"value":2673},"2.2 后端错误分析",{"type":26,"tag":27,"props":2675,"children":2676},{},[2677],{"type":26,"tag":329,"props":2678,"children":2679},{},[2680],{"type":31,"value":2681},"场景 1：Node.js 内存问题",{"type":26,"tag":2509,"props":2683,"children":2688},{"code":2684,"language":2685,"meta":7,"className":2686},"// 错误信息：\n// FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - \n// JavaScript heap out of memory\n\n// 提问方式（包含上下文）：\n/**\n * Node.js 服务运行几小时后崩溃，错误信息：\n * FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - \n * JavaScript heap out of memory\n * \n * 服务功能：处理 CSV 文件上传，每次约 100MB\n * \n * 处理代码：\n */\nasync function processCSV(filePath) {\n  const content = fs.readFileSync(filePath, 'utf-8');\n  const rows = content.split('\\n');\n  const results = [];\n  \n  for (const row of rows) {\n    const processed = await processRow(row);\n    results.push(processed);\n  }\n  \n  return results;\n}\n\n// AI 分析会指出：\n// 1. 一次性读取整个文件到内存\n// 2. 所有处理结果累积在 results 数组\n// 3. 建议使用流式处理\n\n// AI 提供的优化方案：\nconst { createReadStream } = require('fs');\nconst { createInterface } = require('readline');\n\nasync function processCSVStream(filePath, onRow) {\n  const fileStream = createReadStream(filePath);\n  const rl = createInterface({\n    input: fileStream,\n    crlfDelay: Infinity\n  });\n  \n  let count = 0;\n  for await (const line of rl) {\n    await onRow(line);\n    count++;\n    \n    // 每处理 1000 行，给 GC 机会运行\n    if (count % 1000 === 0) {\n      await new Promise(r => setImmediate(r));\n    }\n  }\n}\n","javascript",[2687],"language-javascript",[2689],{"type":26,"tag":154,"props":2690,"children":2691},{"__ignoreMap":7},[2692],{"type":31,"value":2684},{"type":26,"tag":27,"props":2694,"children":2695},{},[2696],{"type":26,"tag":329,"props":2697,"children":2698},{},[2699],{"type":31,"value":2700},"场景 2：数据库连接问题",{"type":26,"tag":2509,"props":2702,"children":2705},{"code":2703,"language":2660,"meta":7,"className":2704},"// 错误信息：\n// Error: Connection pool exhausted - \n// max connections (10) already in use\n\n// 提问方式：\n/**\n * PostgreSQL 连接池耗尽错误，高并发时出现：\n * Error: Connection pool exhausted\n * \n * 当前配置：\n * - max connections: 10\n * - 并发请求: 约 100/秒\n * \n * 数据库调用代码：\n */\nasync function getUserData(userId: string) {\n  const client = await pool.connect();\n  try {\n    const user = await client.query('SELECT * FROM users WHERE id = $1', [userId]);\n    const orders = await client.query('SELECT * FROM orders WHERE user_id = $1', [userId]);\n    const payments = await client.query('SELECT * FROM payments WHERE user_id = $1', [userId]);\n    return { user: user.rows[0], orders: orders.rows, payments: payments.rows };\n  } finally {\n    client.release();\n  }\n}\n\n// AI 会分析出多个可能原因并给出综合方案\n",[2662],[2706],{"type":26,"tag":154,"props":2707,"children":2708},{"__ignoreMap":7},[2709],{"type":31,"value":2703},{"type":26,"tag":34,"props":2711,"children":2713},{"id":2712},"第三部分日志分析与问题定位",[2714],{"type":31,"value":2715},"第三部分：日志分析与问题定位",{"type":26,"tag":716,"props":2717,"children":2719},{"id":2718},"_31-结构化日志分析",[2720],{"type":31,"value":2721},"3.1 结构化日志分析",{"type":26,"tag":27,"props":2723,"children":2724},{},[2725],{"type":31,"value":2726},"当面对大量日志时，让 AI 帮你快速定位问题：",{"type":26,"tag":2509,"props":2728,"children":2731},{"code":2729,"language":2685,"meta":7,"className":2730},"// 提问示例：\n/**\n * 分析以下日志，找出导致请求失败的原因：\n * \n * 日志片段：\n */\nconst logs = `\n2024-01-15 10:23:45.123 INFO  [req-abc123] 收到请求 POST /api/order\n2024-01-15 10:23:45.125 DEBUG [req-abc123] 用户认证通过 userId=u001\n2024-01-15 10:23:45.130 DEBUG [req-abc123] 开始库存检查 productId=p001\n2024-01-15 10:23:45.145 DEBUG [req-abc123] 库存检查通过 available=50\n2024-01-15 10:23:45.150 DEBUG [req-abc123] 开始创建订单\n2024-01-15 10:23:45.200 DEBUG [req-abc123] 数据库连接获取成功\n2024-01-15 10:23:45.250 ERROR [req-abc123] 订单创建失败 error=\"deadlock detected\"\n2024-01-15 10:23:45.251 WARN  [req-abc123] 事务回滚\n2024-01-15 10:23:45.255 INFO  [req-abc123] 响应 500 耗时 132ms\n`;\n\n// AI 分析结果会包括：\n// 1. 问题定位：数据库死锁\n// 2. 可能原因：并发订单创建导致锁竞争\n// 3. 排查建议：检查事务隔离级别、锁顺序\n",[2687],[2732],{"type":26,"tag":154,"props":2733,"children":2734},{"__ignoreMap":7},[2735],{"type":31,"value":2729},{"type":26,"tag":716,"props":2737,"children":2739},{"id":2738},"_32-创建调试日志",[2740],{"type":31,"value":2741},"3.2 创建调试日志",{"type":26,"tag":27,"props":2743,"children":2744},{},[2745],{"type":31,"value":2746},"让 AI 帮你生成调试用的日志代码：",{"type":26,"tag":2509,"props":2748,"children":2751},{"code":2749,"language":2660,"meta":7,"className":2750},"// 请求：\n// \"为这个函数添加详细的调试日志，包括入参、关键步骤、耗时和结果\"\n\n// 原代码：\nasync function processOrder(order: Order): Promise\u003COrderResult> {\n  const inventory = await checkInventory(order.items);\n  const payment = await processPayment(order.userId, order.total);\n  const result = await createOrder(order, payment.transactionId);\n  return result;\n}\n\n// AI 生成的带日志版本：\nasync function processOrder(order: Order): Promise\u003COrderResult> {\n  const requestId = generateRequestId();\n  const startTime = performance.now();\n  \n  logger.info({\n    requestId,\n    event: 'order_processing_start',\n    orderId: order.id,\n    userId: order.userId,\n    itemCount: order.items.length,\n    total: order.total\n  });\n  \n  try {\n    // 库存检查\n    const inventoryStart = performance.now();\n    const inventory = await checkInventory(order.items);\n    logger.debug({\n      requestId,\n      event: 'inventory_check_complete',\n      duration: performance.now() - inventoryStart,\n      available: inventory.allAvailable\n    });\n    \n    // 支付处理\n    const paymentStart = performance.now();\n    const payment = await processPayment(order.userId, order.total);\n    logger.debug({\n      requestId,\n      event: 'payment_complete',\n      duration: performance.now() - paymentStart,\n      transactionId: payment.transactionId\n    });\n    \n    // 创建订单\n    const createStart = performance.now();\n    const result = await createOrder(order, payment.transactionId);\n    logger.debug({\n      requestId,\n      event: 'order_created',\n      duration: performance.now() - createStart,\n      resultOrderId: result.orderId\n    });\n    \n    logger.info({\n      requestId,\n      event: 'order_processing_complete',\n      duration: performance.now() - startTime,\n      success: true\n    });\n    \n    return result;\n  } catch (error) {\n    logger.error({\n      requestId,\n      event: 'order_processing_failed',\n      duration: performance.now() - startTime,\n      error: error.message,\n      stack: error.stack\n    });\n    throw error;\n  }\n}\n",[2662],[2752],{"type":26,"tag":154,"props":2753,"children":2754},{"__ignoreMap":7},[2755],{"type":31,"value":2749},{"type":26,"tag":34,"props":2757,"children":2759},{"id":2758},"第四部分性能问题排查",[2760],{"type":31,"value":2761},"第四部分：性能问题排查",{"type":26,"tag":716,"props":2763,"children":2765},{"id":2764},"_41-前端性能分析",[2766],{"type":31,"value":2767},"4.1 前端性能分析",{"type":26,"tag":2509,"props":2769,"children":2772},{"code":2770,"language":2660,"meta":7,"className":2771},"// 场景：页面加载慢，需要分析原因\n\n// 提问方式：\n/**\n * 页面首屏加载需要 5 秒，以下是 Performance API 数据，\n * 请分析性能瓶颈：\n */\nconst performanceData = {\n  // Navigation Timing\n  dns: 50,           // DNS 查询\n  tcp: 100,          // TCP 连接\n  ttfb: 800,         // 首字节时间\n  download: 200,     // 文档下载\n  domParsing: 300,   // DOM 解析\n  domContentLoaded: 1500,\n  load: 5000,\n  \n  // Resource Timing (主要资源)\n  resources: [\n    { name: 'main.js', size: '2.5MB', duration: 1200 },\n    { name: 'vendor.js', size: '1.8MB', duration: 900 },\n    { name: 'styles.css', size: '500KB', duration: 300 },\n    { name: 'hero-image.jpg', size: '3MB', duration: 1500 },\n  ],\n  \n  // Long Tasks\n  longTasks: [\n    { startTime: 1600, duration: 800, name: 'script-evaluation' },\n    { startTime: 2500, duration: 400, name: 'layout' }\n  ]\n};\n\n// AI 会分析出：\n// 1. JS bundle 过大（4.3MB），需要代码分割\n// 2. 图片未优化（3MB 的 hero 图片）\n// 3. 存在长任务阻塞主线程\n// 并给出具体优化建议\n",[2662],[2773],{"type":26,"tag":154,"props":2774,"children":2775},{"__ignoreMap":7},[2776],{"type":31,"value":2770},{"type":26,"tag":716,"props":2778,"children":2780},{"id":2779},"_42-内存泄漏排查",[2781],{"type":31,"value":2782},"4.2 内存泄漏排查",{"type":26,"tag":2509,"props":2784,"children":2787},{"code":2785,"language":2660,"meta":7,"className":2786},"// 场景：应用运行一段时间后变卡\n\n// 提问方式：\n/**\n * React 应用运行一段时间后内存持续增长，以下是 Heap Snapshot 对比：\n * \n * 初始状态：50MB\n * 运行 1 小时后：150MB\n * 运行 2 小时后：280MB\n * \n * Retained objects 增长最快的：\n * - (closure) - 增长 50MB\n * - HTMLDivElement - 增长 30MB\n * - Array - 增长 20MB\n * \n * 可疑代码：\n */\nfunction DataDashboard() {\n  const [data, setData] = useState([]);\n  const chartRef = useRef(null);\n  \n  useEffect(() => {\n    // 每秒刷新数据\n    const interval = setInterval(async () => {\n      const newData = await fetchLatestData();\n      setData(prev => [...prev, ...newData]);  // 数据不断累积\n    }, 1000);\n    \n    // 初始化图表\n    const chart = new Chart(chartRef.current, {\n      // 配置...\n    });\n    \n    // 没有 cleanup！\n  }, []);\n  \n  return \u003Ccanvas ref={chartRef} />;\n}\n\n// AI 会指出：\n// 1. interval 没有清理\n// 2. Chart 实例没有销毁\n// 3. data 无限增长\n// 并提供修复代码\n",[2662],[2788],{"type":26,"tag":154,"props":2789,"children":2790},{"__ignoreMap":7},[2791],{"type":31,"value":2785},{"type":26,"tag":716,"props":2793,"children":2795},{"id":2794},"_43-数据库查询优化",[2796],{"type":31,"value":2797},"4.3 数据库查询优化",{"type":26,"tag":2509,"props":2799,"children":2804},{"code":2800,"language":2801,"meta":7,"className":2802},"-- 场景：查询很慢，让 AI 分析执行计划\n\n-- 提问方式：\n-- 以下查询在数据量大时很慢（orders 表 1000 万行），\n-- 执行计划如下，请分析并优化：\n\nEXPLAIN ANALYZE\nSELECT o.*, u.name, u.email\nFROM orders o\nJOIN users u ON o.user_id = u.id\nWHERE o.status = 'pending'\n  AND o.created_at > '2024-01-01'\nORDER BY o.created_at DESC\nLIMIT 20;\n\n-- 执行计划：\n/*\nSort  (cost=156847.23..157847.23 rows=400000 width=250)\n  Sort Key: o.created_at DESC\n  ->  Hash Join  (cost=1500.00..89847.23 rows=400000 width=250)\n        Hash Cond: (o.user_id = u.id)\n        ->  Seq Scan on orders o  (cost=0.00..85000.00 rows=400000)\n              Filter: ((status = 'pending') AND (created_at > '2024-01-01'))\n        ->  Hash  (cost=1000.00..1000.00 rows=50000 width=100)\n              ->  Seq Scan on users u  (cost=0.00..1000.00 rows=50000)\nPlanning Time: 0.5 ms\nExecution Time: 3500 ms\n*/\n\n-- AI 会分析出问题并建议：\n-- 1. orders 表全表扫描 - 需要复合索引\n-- 2. 建议创建索引：\nCREATE INDEX idx_orders_status_created ON orders(status, created_at DESC);\n\n-- 3. 如果 status 选择性不高，考虑部分索引：\nCREATE INDEX idx_orders_pending ON orders(created_at DESC) \nWHERE status = 'pending';\n","sql",[2803],"language-sql",[2805],{"type":26,"tag":154,"props":2806,"children":2807},{"__ignoreMap":7},[2808],{"type":31,"value":2800},{"type":26,"tag":34,"props":2810,"children":2812},{"id":2811},"第五部分复杂-bug-排查",[2813],{"type":31,"value":2814},"第五部分：复杂 Bug 排查",{"type":26,"tag":716,"props":2816,"children":2818},{"id":2817},"_51-竞态条件",[2819],{"type":31,"value":2820},"5.1 竞态条件",{"type":26,"tag":2509,"props":2822,"children":2825},{"code":2823,"language":2660,"meta":7,"className":2824},"// 场景：偶发的数据不一致问题\n\n// 提问方式：\n/**\n * 用户反馈偶尔看到错误的账户余额，但刷新后正常。\n * 怀疑是竞态条件，以下是相关代码：\n */\nasync function updateBalance(userId: string, amount: number) {\n  // 读取当前余额\n  const user = await db.users.findOne({ id: userId });\n  const newBalance = user.balance + amount;\n  \n  // 更新余额\n  await db.users.update({ id: userId }, { balance: newBalance });\n  \n  // 记录交易\n  await db.transactions.create({\n    userId,\n    amount,\n    balanceAfter: newBalance,\n    createdAt: new Date()\n  });\n  \n  return newBalance;\n}\n\n// 并发调用场景：\n// 用户同时发起两笔交易：+100 和 -50\n// 期望结果：原余额 1000 → 1050\n// 实际可能：原余额 1000 → 1100 或 950\n\n// AI 会分析竞态条件并提供解决方案：\nasync function updateBalanceAtomic(userId: string, amount: number) {\n  // 方案 1：使用数据库原子操作\n  const result = await db.users.findOneAndUpdate(\n    { id: userId },\n    { $inc: { balance: amount } },\n    { returnDocument: 'after' }\n  );\n  \n  await db.transactions.create({\n    userId,\n    amount,\n    balanceAfter: result.balance,\n    createdAt: new Date()\n  });\n  \n  return result.balance;\n}\n\n// 方案 2：使用乐观锁\nasync function updateBalanceOptimistic(userId: string, amount: number) {\n  const maxRetries = 3;\n  \n  for (let i = 0; i \u003C maxRetries; i++) {\n    const user = await db.users.findOne({ id: userId });\n    const newBalance = user.balance + amount;\n    \n    const updated = await db.users.updateOne(\n      { id: userId, version: user.version },\n      { balance: newBalance, version: user.version + 1 }\n    );\n    \n    if (updated.modifiedCount === 1) {\n      await db.transactions.create({...});\n      return newBalance;\n    }\n    \n    // 版本冲突，重试\n    await sleep(10 * (i + 1));\n  }\n  \n  throw new Error('Update failed after retries');\n}\n",[2662],[2826],{"type":26,"tag":154,"props":2827,"children":2828},{"__ignoreMap":7},[2829],{"type":31,"value":2823},{"type":26,"tag":716,"props":2831,"children":2833},{"id":2832},"_52-分布式系统问题",[2834],{"type":31,"value":2835},"5.2 分布式系统问题",{"type":26,"tag":2509,"props":2837,"children":2840},{"code":2838,"language":2660,"meta":7,"className":2839},"// 场景：微服务间的数据不一致\n\n// 提问方式：\n/**\n * 订单服务和库存服务偶尔出现数据不一致：\n * - 订单显示已创建\n * - 库存未扣减\n * \n * 当前流程：\n */\n// Order Service\nasync function createOrder(orderData) {\n  // 1. 调用库存服务扣减库存\n  await inventoryService.deduct(orderData.items);\n  \n  // 2. 创建订单\n  const order = await orderRepository.create(orderData);\n  \n  // 3. 发送订单创建事件\n  await eventBus.publish('order.created', order);\n  \n  return order;\n}\n\n// 问题分析：如果步骤 2 或 3 失败，库存已经扣减但订单未创建\n\n// AI 会建议使用 Saga 模式或事务发件箱模式\n",[2662],[2841],{"type":26,"tag":154,"props":2842,"children":2843},{"__ignoreMap":7},[2844],{"type":31,"value":2838},{"type":26,"tag":34,"props":2846,"children":2848},{"id":2847},"第六部分ai-调试工作流",[2849],{"type":31,"value":2850},"第六部分：AI 调试工作流",{"type":26,"tag":716,"props":2852,"children":2854},{"id":2853},"_61-我的调试流程",[2855],{"type":31,"value":2856},"6.1 我的调试流程",{"type":26,"tag":2509,"props":2858,"children":2860},{"code":2859},"┌────────────────────────────────────────────────────────────┐\n│                    AI 辅助调试工作流                         │\n├────────────────────────────────────────────────────────────┤\n│                                                            │\n│  Step 1: 问题收集                                          │\n│  ├── 复制完整错误信息                                       │\n│  ├── 截图相关日志                                          │\n│  └── 记录复现步骤                                          │\n│                                                            │\n│  Step 2: 快速分析                                          │\n│  ├── 将错误信息发给 AI                                      │\n│  ├── 获取可能原因列表                                       │\n│  └── 评估哪些最可能                                         │\n│                                                            │\n│  Step 3: 深入调查                                          │\n│  ├── 根据 AI 建议添加日志/断点                              │\n│  ├── 收集更多信息                                          │\n│  └── 再次询问 AI（带新信息）                                │\n│                                                            │\n│  Step 4: 验证修复                                          │\n│  ├── AI 生成修复代码                                        │\n│  ├── 人工审查确认                                          │\n│  └── 测试验证                                               │\n│                                                            │\n│  Step 5: 预防措施                                          │\n│  ├── AI 建议类似问题的预防方法                              │\n│  ├── 添加相关测试用例                                       │\n│  └── 更新文档/知识库                                        │\n│                                                            │\n└────────────────────────────────────────────────────────────┘\n",[2861],{"type":26,"tag":154,"props":2862,"children":2863},{"__ignoreMap":7},[2864],{"type":31,"value":2859},{"type":26,"tag":716,"props":2866,"children":2868},{"id":2867},"_62-调试对话模板",[2869],{"type":31,"value":2870},"6.2 调试对话模板",{"type":26,"tag":2509,"props":2872,"children":2875},{"code":2873,"language":266,"meta":7,"className":2874},"## 第一轮：问题描述\n\n我遇到了一个问题：[简述问题]\n\n错误信息：\n",[2513],[2876],{"type":26,"tag":154,"props":2877,"children":2878},{"__ignoreMap":7},[2879],{"type":31,"value":2873},{"type":26,"tag":27,"props":2881,"children":2882},{},[2883],{"type":26,"tag":2523,"props":2884,"children":2885},{},[2886],{"type":31,"value":2887},"粘贴完整错误",{"type":26,"tag":2509,"props":2889,"children":2891},{"code":2890},"\n相关代码：\n```javascript\n[粘贴代码]\n",[2892],{"type":26,"tag":154,"props":2893,"children":2894},{"__ignoreMap":7},[2895],{"type":31,"value":2890},{"type":26,"tag":390,"props":2897,"children":2898},{},[],{"type":26,"tag":34,"props":2900,"children":2902},{"id":2901},"第二轮补充信息",[2903],{"type":31,"value":2904},"第二轮：补充信息",{"type":26,"tag":27,"props":2906,"children":2907},{},[2908],{"type":31,"value":2909},"根据你的建议，我添加了日志，发现：",{"type":26,"tag":118,"props":2911,"children":2912},{},[2913,2921],{"type":26,"tag":122,"props":2914,"children":2915},{},[2916],{"type":26,"tag":2523,"props":2917,"children":2918},{},[2919],{"type":31,"value":2920},"发现 1",{"type":26,"tag":122,"props":2922,"children":2923},{},[2924],{"type":26,"tag":2523,"props":2925,"children":2926},{},[2927],{"type":31,"value":2928},"发现 2",{"type":26,"tag":27,"props":2930,"children":2931},{},[2932,2934,2939],{"type":31,"value":2933},"这是否说明问题出在 ",{"type":26,"tag":2523,"props":2935,"children":2936},{},[2937],{"type":31,"value":2938},"你的猜测",{"type":31,"value":2940},"？",{"type":26,"tag":390,"props":2942,"children":2943},{},[],{"type":26,"tag":34,"props":2945,"children":2947},{"id":2946},"第三轮确认修复",[2948],{"type":31,"value":2949},"第三轮：确认修复",{"type":26,"tag":27,"props":2951,"children":2952},{},[2953],{"type":31,"value":2954},"我按照你的建议修改了代码：",{"type":26,"tag":2509,"props":2956,"children":2959},{"code":2957,"language":2685,"meta":7,"className":2958},"[粘贴修改后的代码]\n",[2687],[2960],{"type":26,"tag":154,"props":2961,"children":2962},{"__ignoreMap":7},[2963],{"type":31,"value":2957},{"type":26,"tag":27,"props":2965,"children":2966},{},[2967],{"type":31,"value":2968},"请确认这个修复是否正确，以及是否有其他潜在问题。",{"type":26,"tag":390,"props":2970,"children":2971},{},[],{"type":26,"tag":34,"props":2973,"children":2975},{"id":2974},"第四轮预防",[2976],{"type":31,"value":2977},"第四轮：预防",{"type":26,"tag":27,"props":2979,"children":2980},{},[2981],{"type":31,"value":2982},"这个问题已解决。请建议：",{"type":26,"tag":320,"props":2984,"children":2985},{},[2986,2991,2996],{"type":26,"tag":122,"props":2987,"children":2988},{},[2989],{"type":31,"value":2990},"如何防止类似问题再次发生？",{"type":26,"tag":122,"props":2992,"children":2993},{},[2994],{"type":31,"value":2995},"应该添加什么测试用例？",{"type":26,"tag":122,"props":2997,"children":2998},{},[2999],{"type":31,"value":3000},"有什么最佳实践可以参考？",{"type":26,"tag":2509,"props":3002,"children":3004},{"code":3003},"\n## 结语：AI 是放大器，不是替代品\n\nAI 调试工具能够显著加速问题排查过程，但它不能替代你的思考。最有价值的能力组合是：\n\n- **你的领域知识** + **AI 的广博见识**\n- **你对项目的理解** + **AI 的分析能力**\n- **你的判断力** + **AI 的执行速度**\n\n调试的本质是假设-验证的循环。AI 帮你更快地生成假设、更高效地验证假设，但做出最终判断的还是你。\n\n学会与 AI 高效协作调试，不是依赖 AI 给你答案，而是让 AI 帮你更快地找到自己的答案。\n\n---\n\n## 参考资源\n\n- [Chrome DevTools 官方文档](https://developer.chrome.com/docs/devtools)\n- [Node.js 调试指南](https://nodejs.org/en/docs/guides/debugging-getting-started)\n- [React DevTools 使用指南](https://react.dev/learn/react-developer-tools)\n",[3005],{"type":26,"tag":154,"props":3006,"children":3007},{"__ignoreMap":7},[3008],{"type":31,"value":3003},{"title":7,"searchDepth":259,"depth":259,"links":3010},[3011,3012,3013,3018,3022,3027,3031,3035,3036,3037],{"id":2393,"depth":262,"text":2396},{"id":2399,"depth":262,"text":2402},{"id":2420,"depth":262,"text":2423,"children":3014},[3015,3016,3017],{"id":2426,"depth":259,"text":2429},{"id":2504,"depth":259,"text":2507},{"id":2670,"depth":259,"text":2673},{"id":2712,"depth":262,"text":2715,"children":3019},[3020,3021],{"id":2718,"depth":259,"text":2721},{"id":2738,"depth":259,"text":2741},{"id":2758,"depth":262,"text":2761,"children":3023},[3024,3025,3026],{"id":2764,"depth":259,"text":2767},{"id":2779,"depth":259,"text":2782},{"id":2794,"depth":259,"text":2797},{"id":2811,"depth":262,"text":2814,"children":3028},[3029,3030],{"id":2817,"depth":259,"text":2820},{"id":2832,"depth":259,"text":2835},{"id":2847,"depth":262,"text":2850,"children":3032},[3033,3034],{"id":2853,"depth":259,"text":2856},{"id":2867,"depth":259,"text":2870},{"id":2901,"depth":262,"text":2904},{"id":2946,"depth":262,"text":2949},{"id":2974,"depth":262,"text":2977},"content:topics:ai:ai-debugging-troubleshooting-guide.md","topics/ai/ai-debugging-troubleshooting-guide.md","topics/ai/ai-debugging-troubleshooting-guide",{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"topic":5,"author":11,"tags":3042,"image":17,"imageQuery":18,"pexelsPhotoId":19,"pexelsUrl":20,"featured":6,"readingTime":21,"body":3043,"_type":266,"_id":267,"_source":268,"_file":269,"_stem":270,"_extension":271},[13,14,15,16],{"type":23,"children":3044,"toc":3223},[3045,3049,3053,3106,3110,3114,3129,3133,3137,3147,3151,3195,3199],{"type":26,"tag":27,"props":3046,"children":3047},{},[3048],{"type":31,"value":32},{"type":26,"tag":34,"props":3050,"children":3051},{"id":36},[3052],{"type":31,"value":39},{"type":26,"tag":41,"props":3054,"children":3055},{},[3056,3070],{"type":26,"tag":45,"props":3057,"children":3058},{},[3059],{"type":26,"tag":49,"props":3060,"children":3061},{},[3062,3066],{"type":26,"tag":53,"props":3063,"children":3064},{},[3065],{"type":31,"value":57},{"type":26,"tag":53,"props":3067,"children":3068},{},[3069],{"type":31,"value":62},{"type":26,"tag":64,"props":3071,"children":3072},{},[3073,3084,3095],{"type":26,"tag":49,"props":3074,"children":3075},{},[3076,3080],{"type":26,"tag":71,"props":3077,"children":3078},{},[3079],{"type":31,"value":75},{"type":26,"tag":71,"props":3081,"children":3082},{},[3083],{"type":31,"value":80},{"type":26,"tag":49,"props":3085,"children":3086},{},[3087,3091],{"type":26,"tag":71,"props":3088,"children":3089},{},[3090],{"type":31,"value":88},{"type":26,"tag":71,"props":3092,"children":3093},{},[3094],{"type":31,"value":93},{"type":26,"tag":49,"props":3096,"children":3097},{},[3098,3102],{"type":26,"tag":71,"props":3099,"children":3100},{},[3101],{"type":31,"value":101},{"type":26,"tag":71,"props":3103,"children":3104},{},[3105],{"type":31,"value":106},{"type":26,"tag":27,"props":3107,"children":3108},{},[3109],{"type":31,"value":111},{"type":26,"tag":34,"props":3111,"children":3112},{"id":114},[3113],{"type":31,"value":114},{"type":26,"tag":118,"props":3115,"children":3116},{},[3117,3121,3125],{"type":26,"tag":122,"props":3118,"children":3119},{},[3120],{"type":31,"value":126},{"type":26,"tag":122,"props":3122,"children":3123},{},[3124],{"type":31,"value":131},{"type":26,"tag":122,"props":3126,"children":3127},{},[3128],{"type":31,"value":136},{"type":26,"tag":27,"props":3130,"children":3131},{},[3132],{"type":31,"value":141},{"type":26,"tag":34,"props":3134,"children":3135},{"id":144},[3136],{"type":31,"value":147},{"type":26,"tag":27,"props":3138,"children":3139},{},[3140,3141,3146],{"type":31,"value":152},{"type":26,"tag":154,"props":3142,"children":3144},{"className":3143},[],[3145],{"type":31,"value":159},{"type":31,"value":161},{"type":26,"tag":34,"props":3148,"children":3149},{"id":164},[3150],{"type":31,"value":167},{"type":26,"tag":118,"props":3152,"children":3154},{"className":3153},[171],[3155,3163,3171,3179,3187],{"type":26,"tag":122,"props":3156,"children":3158},{"className":3157},[176],[3159,3162],{"type":26,"tag":179,"props":3160,"children":3161},{"disabled":181,"type":182},[],{"type":31,"value":185},{"type":26,"tag":122,"props":3164,"children":3166},{"className":3165},[176],[3167,3170],{"type":26,"tag":179,"props":3168,"children":3169},{"disabled":181,"type":182},[],{"type":31,"value":194},{"type":26,"tag":122,"props":3172,"children":3174},{"className":3173},[176],[3175,3178],{"type":26,"tag":179,"props":3176,"children":3177},{"disabled":181,"type":182},[],{"type":31,"value":203},{"type":26,"tag":122,"props":3180,"children":3182},{"className":3181},[176],[3183,3186],{"type":26,"tag":179,"props":3184,"children":3185},{"disabled":181,"type":182},[],{"type":31,"value":212},{"type":26,"tag":122,"props":3188,"children":3190},{"className":3189},[176],[3191,3194],{"type":26,"tag":179,"props":3192,"children":3193},{"disabled":181,"type":182},[],{"type":31,"value":221},{"type":26,"tag":27,"props":3196,"children":3197},{},[3198],{"type":31,"value":226},{"type":26,"tag":118,"props":3200,"children":3201},{},[3202,3209,3216],{"type":26,"tag":122,"props":3203,"children":3204},{},[3205],{"type":26,"tag":234,"props":3206,"children":3207},{"href":236},[3208],{"type":31,"value":239},{"type":26,"tag":122,"props":3210,"children":3211},{},[3212],{"type":26,"tag":234,"props":3213,"children":3214},{"href":245},[3215],{"type":31,"value":248},{"type":26,"tag":122,"props":3217,"children":3218},{},[3219],{"type":26,"tag":234,"props":3220,"children":3221},{"href":254},[3222],{"type":31,"value":257},{"title":7,"searchDepth":259,"depth":259,"links":3224},[3225,3226,3227,3228],{"id":36,"depth":262,"text":39},{"id":114,"depth":262,"text":114},{"id":144,"depth":262,"text":147},{"id":164,"depth":262,"text":167},1780105144441]