from __future__ import annotations from typing import Any from .ai_prompts_catalog import __all__ as PROMPT_CATALOG_EXPORTS PROMPT_FAMILY_CLASSIFICATION = "classification" PROMPT_FAMILY_EXTRACTION = "extraction" PROMPT_FAMILY_PLANNING = "planning" PROMPT_FAMILY_RESPONSE = "response" PROMPT_FAMILY_GOVERNANCE = "governance" PROMPT_FAMILY_ALLOWED = { PROMPT_FAMILY_CLASSIFICATION, PROMPT_FAMILY_EXTRACTION, PROMPT_FAMILY_PLANNING, PROMPT_FAMILY_RESPONSE, PROMPT_FAMILY_GOVERNANCE, } PROMPT_FAMILY_KEYWORD_RULES: tuple[tuple[str, str], ...] = ( ("CLASSIFICATION", PROMPT_FAMILY_CLASSIFICATION), ("EXTRACTION", PROMPT_FAMILY_EXTRACTION), ("PREFILL", PROMPT_FAMILY_EXTRACTION), ("INTENT", PROMPT_FAMILY_CLASSIFICATION), ("TASK_ORCHESTRATION", PROMPT_FAMILY_PLANNING), ("PLANNER", PROMPT_FAMILY_PLANNING), ("GENERATE", PROMPT_FAMILY_PLANNING), ("DECOMPOSE", PROMPT_FAMILY_PLANNING), ("RECOMMEND", PROMPT_FAMILY_PLANNING), ("DRAFT", PROMPT_FAMILY_PLANNING), ("TASK_BREAKDOWN", PROMPT_FAMILY_PLANNING), ("QA", PROMPT_FAMILY_RESPONSE), ("REPLY", PROMPT_FAMILY_RESPONSE), ) PROMPT_FAMILY_SCENARIO_RULES: tuple[tuple[str, str], ...] = ( ("分类", PROMPT_FAMILY_CLASSIFICATION), ("抽取", PROMPT_FAMILY_EXTRACTION), ("预填", PROMPT_FAMILY_EXTRACTION), ("规划", PROMPT_FAMILY_PLANNING), ("编排", PROMPT_FAMILY_PLANNING), ("草案", PROMPT_FAMILY_PLANNING), ("拆解", PROMPT_FAMILY_PLANNING), ("问答", PROMPT_FAMILY_RESPONSE), ("回复", PROMPT_FAMILY_RESPONSE), ) RESPONSIBILITY_SCOPE_BY_FAMILY: dict[str, str] = { PROMPT_FAMILY_CLASSIFICATION: "分类层:只负责识别请求类型、归属和优先级,不生成执行方案。", PROMPT_FAMILY_EXTRACTION: "抽取层:只负责结构化提取实体、槽位和证据,不做规划决策。", PROMPT_FAMILY_PLANNING: "规划层:只负责生成可执行规划、任务和负责人建议,不承担最终对话呈现。", PROMPT_FAMILY_RESPONSE: "呈现层:只负责面向用户输出结论与建议,不直接做写操作决策。", PROMPT_FAMILY_GOVERNANCE: "治理层:只负责约束、评估、同步与风控,不承担主对话生成。", } PROMPT_PRIORITY_BY_FAMILY: dict[str, str] = { PROMPT_FAMILY_CLASSIFICATION: "high", PROMPT_FAMILY_EXTRACTION: "high", PROMPT_FAMILY_PLANNING: "high", PROMPT_FAMILY_RESPONSE: "high", PROMPT_FAMILY_GOVERNANCE: "medium", } PROMPT_AUDIENCE_BY_FAMILY: dict[str, str] = { PROMPT_FAMILY_CLASSIFICATION: "signal_router", PROMPT_FAMILY_EXTRACTION: "signal_ingestion", PROMPT_FAMILY_PLANNING: "planning_orchestrator", PROMPT_FAMILY_RESPONSE: "assistant_response", PROMPT_FAMILY_GOVERNANCE: "risk_budget_guardrail", } def _normalize_family(prompt_family: str) -> str: value = str(prompt_family or "").strip().lower() if value in PROMPT_FAMILY_ALLOWED: return value return PROMPT_FAMILY_GOVERNANCE def _derive_prompt_family(prompt_key: str, business_scenario: str) -> str: key_text = str(prompt_key or "").strip().upper() scenario_text = str(business_scenario or "").strip() for keyword, family in PROMPT_FAMILY_KEYWORD_RULES: if keyword in key_text: return family for keyword, family in PROMPT_FAMILY_SCENARIO_RULES: if keyword in scenario_text: return family return PROMPT_FAMILY_GOVERNANCE def _derive_responsibility_scope(prompt_family: str) -> str: family = _normalize_family(prompt_family) return RESPONSIBILITY_SCOPE_BY_FAMILY[family] def _derive_priority(prompt_family: str) -> str: family = _normalize_family(prompt_family) return PROMPT_PRIORITY_BY_FAMILY[family] def _derive_audience(prompt_family: str) -> str: family = _normalize_family(prompt_family) return PROMPT_AUDIENCE_BY_FAMILY[family] def _entry( prompt_key: str, *, module: str, business_scenario: str, input_contract: str, output_contract: str, call_sites: tuple[str, ...] = (), prompt_family: str | None = None, responsibility_scope: str | None = None, priority: str | None = None, audience: str | None = None, runtime_source: str = "catalog", editable_policy: str = "managed_release", risk_level: str | None = None, ) -> dict[str, Any]: resolved_family = _normalize_family(prompt_family or _derive_prompt_family(prompt_key, business_scenario)) resolved_scope = str(responsibility_scope or "").strip() or _derive_responsibility_scope(resolved_family) resolved_priority = str(priority or "").strip().lower() or _derive_priority(resolved_family) resolved_audience = str(audience or "").strip() or _derive_audience(resolved_family) resolved_risk = str(risk_level or "").strip().lower() if resolved_risk not in {"critical", "high", "medium", "low"}: resolved_risk = "high" if resolved_family in {PROMPT_FAMILY_CLASSIFICATION, PROMPT_FAMILY_EXTRACTION, PROMPT_FAMILY_PLANNING} else "medium" return { "prompt_key": prompt_key, "module": module, "business_scenario": business_scenario, "call_sites": tuple(str(site) for site in call_sites if str(site or "").strip()), "input_contract": input_contract, "output_contract": output_contract, "prompt_family": resolved_family, "responsibility_scope": resolved_scope, "priority": resolved_priority, "audience": resolved_audience, "runtime_source": str(runtime_source or "catalog").strip() or "catalog", "editable_policy": str(editable_policy or "managed_release").strip() or "managed_release", "risk_level": resolved_risk, } JSON_INPUT = "输入为结构化 JSON 上下文。" JSON_OUTPUT = "输出严格 JSON 对象,不要 Markdown。" JSON_LIST_OUTPUT = "输出严格 JSON 数组,不要 Markdown。" QA_INPUT = "输入为问题文本 + 业务上下文。" QA_OUTPUT = "输出自然语言答复。" PLAN_INPUT = "输入为信号 / 项目 / 宪章 / 成员上下文。" PLAN_OUTPUT = "输出可执行规划 JSON。" SCORE_INPUT = "输入为对比对象 + 评分上下文。" SCORE_OUTPUT = "输出评分或建议 JSON。" FRAGMENT_INPUT = "输入为 prompt 片段占位内容。" FRAGMENT_OUTPUT = "输出为可拼接的 prompt 片段。" DEEP_GUARD_CALL_SITES = ("backend/app/services/adaptive_rag_service/mixin_deep_guard_answer.py",) AI_BUSINESS_TASKS_CALL_SITES = ("backend/app/services/ai_service_core/mixin_business_tasks.py",) AI_BUSINESS_ANALYSIS_CALL_SITES = ("backend/app/services/ai_service_core/mixin_business_analysis.py",) FEISHU_EXTRACT_CALL_SITES = ("backend/app/services/integrations/feishu_signal_pipeline/mixin_extraction.py",) FEISHU_REPLY_CALL_SITES = ("backend/app/services/integrations/feishu_integration_service/mixin_reply_llm_core.py",) FEISHU_PIPELINE_CALL_SITES = ("backend/app/services/integrations/feishu_signal_pipeline/mixin_task_orchestration_main.py",) FEISHU_SIGNAL_CLASSIFY_CALL_SITES = ("backend/app/services/signal/signal_capture_service/mixin_analysis_normalize.py",) SIGNAL_SOURCE_CALL_SITES = ("backend/app/services/signal/signal_source_orchestration/mixin_registry_execute.py",) DRAFT_GENERATOR_CALL_SITES = ("backend/app/services/signal/draft_generator_service.py",) PROJECT_REQUIREMENT_EXTRACTION_CALL_SITES = ( "backend/app/services/ai_steward_service/mixin_draft_generation.py", "backend/app/services/signal/signal_capture_service/mixin_new_project.py", ) RAG_INTENT_CALL_SITES = ("backend/app/services/adaptive_rag_service/mixin_core_intent.py",) RAG_DB_CALL_SITES = ("backend/app/services/adaptive_rag_service/mixin_fast_answer_semantic_p1.py",) SIGNAL_PLANNER_CALL_SITES = ("backend/app/services/signal/signal_planner/mixin_prompt.py", "backend/app/services/signal/signal_planner/mixin_analyze.py") SKILL_SCORE_CALL_SITES = ("backend/app/services/skill/skill_score_service.py",) WORKLOAD_CALL_SITES = ("backend/app/services/workload/ai_optimize.py",) RECIPE_CALL_SITES = ("backend/app/services/recipe/service.py",) PMO_INTENT_CALL_SITES: tuple[str, ...] = () PMO_BATCH_CALL_SITES = ("backend/app/services/ai_pmo/ai_pmo_typed_executor_discovery/mixin_analysis.py",) def _part_01_entries() -> tuple[dict[str, Any], ...]: return ( _entry( "PROMPT_IMPACT_ANALYSIS", module="part_01", business_scenario="需求变更影响分析", input_contract=JSON_INPUT, output_contract="输出 JSON 对象,包含影响结论、风险、建议。", ), _entry( "PROMPT_STRATEGIC_ANALYSIS_HEADER", module="part_01", business_scenario="战略分析上下文片段", input_contract=FRAGMENT_INPUT, output_contract=FRAGMENT_OUTPUT, ), _entry( "PROMPT_RAG_CONTEXT_HEADER", module="part_01", business_scenario="RAG 上下文 header 片段", input_contract=FRAGMENT_INPUT, output_contract=FRAGMENT_OUTPUT, ), _entry( "PROMPT_RAG_CONTEXT_ITEM", module="part_01", business_scenario="RAG 上下文 item 片段", input_contract=FRAGMENT_INPUT, output_contract=FRAGMENT_OUTPUT, ), _entry( "PROMPT_CODE_AUDIT", module="part_01", business_scenario="代码审计", input_contract=JSON_INPUT, output_contract="输出 JSON 对象,包含问题、证据、风险与修复建议。", ), _entry( "PROMPT_CONTEXT_INSIGHTS", module="part_01", business_scenario="上下文洞察", input_contract=JSON_INPUT, output_contract="输出 JSON 对象,包含关键洞察与下一步建议。", ), _entry( "PROMPT_FEISHU_HUMANIZED_REPLY", module="part_01", business_scenario="飞书回复润色", input_contract=QA_INPUT, output_contract=QA_OUTPUT, call_sites=FEISHU_REPLY_CALL_SITES, ), _entry( "PROMPT_FEISHU_QA_NATURAL_REPLY", module="part_01", business_scenario="飞书问答自然回复", input_contract="输入 question / answer / context_summary。", output_contract=QA_OUTPUT, call_sites=FEISHU_REPLY_CALL_SITES, ), _entry( "PROMPT_FEISHU_QA_NATURAL_REPLY_REWRITE", module="part_01", business_scenario="飞书问答自然回复改写", input_contract="输入原始回答、上下文摘要和语气约束。", output_contract=QA_OUTPUT, call_sites=FEISHU_REPLY_CALL_SITES, ), _entry( "PROMPT_FEISHU_PROJECT_SIGNAL_CLASSIFICATION", module="part_01", business_scenario="项目信号分类", input_contract=JSON_INPUT, output_contract="输出 JSON 对象,包含分类、优先级与推荐动作。", call_sites=FEISHU_SIGNAL_CLASSIFY_CALL_SITES, ), _entry( "PROMPT_FEISHU_LEVEL_CLASSIFICATION", module="part_01", business_scenario="飞书消息层级分类", input_contract=JSON_INPUT, output_contract="输出 JSON 对象,包含层级与判断原因。", call_sites=FEISHU_EXTRACT_CALL_SITES, ), ) def _part_02_entries() -> tuple[dict[str, Any], ...]: return ( _entry( "PROMPT_FEISHU_SIGNAL_EXTRACTION", module="part_02", business_scenario="飞书信号结构化抽取", input_contract=JSON_INPUT, output_contract="输出 JSON 对象,包含标题、摘要、优先级、匹配项目和建议动作。", call_sites=FEISHU_EXTRACT_CALL_SITES, ), _entry( "PROMPT_FEISHU_PROJECT_PREFILL", module="part_02", business_scenario="飞书项目预填", input_contract=JSON_INPUT, output_contract="输出 JSON 对象,包含项目名、描述、负责人、时间线与置信度。", call_sites=FEISHU_EXTRACT_CALL_SITES, ), _entry( "PROMPT_PROJECT_REQUIREMENT_EXTRACTION", module="part_02", business_scenario="项目需求抽取与信号源落点", input_contract=JSON_INPUT, output_contract="输出 JSON 对象,包含项目基础信息、核心痛点、MVP 功能与 requirement_items。", call_sites=PROJECT_REQUIREMENT_EXTRACTION_CALL_SITES, ), _entry( "PROMPT_FEISHU_TASK_ORCHESTRATION", module="part_02", business_scenario="飞书任务编排与负责人建议", input_contract="输入 project_json / charter_json / signal_json / members_json。", output_contract="输出 JSON 对象,包含任务列表、负责人建议与置信度。", call_sites=FEISHU_PIPELINE_CALL_SITES, ), _entry( "PROMPT_SIGNAL_SOURCE_ONBOARDING", module="part_02", business_scenario="信号源接入规划", input_contract=JSON_INPUT, output_contract="输出 JSON 对象,包含是否接入、信号源信息、角色分工与执行指令。", call_sites=SIGNAL_SOURCE_CALL_SITES, ), _entry( "PROMPT_AI_WORKER_SIGNAL_SOURCE_EXECUTION", module="part_02", business_scenario="信号源接入 worker 执行", input_contract=JSON_INPUT, output_contract="输出 JSON 对象,包含交付物、风险与下一步。", call_sites=SIGNAL_SOURCE_CALL_SITES, ), _entry( "PROMPT_AI_PMO_INTENT_CLASSIFICATION", module="part_02", business_scenario="AI PMO 意图识别", input_contract=JSON_INPUT, output_contract="输出 JSON 对象,包含 family / action / intent / confidence。", call_sites=PMO_INTENT_CALL_SITES, ), _entry( "PROMPT_AI_PMO_SIGNAL_BATCH_ANALYSIS", module="part_02", business_scenario="AI PMO 批量信号分析", input_contract=JSON_INPUT, output_contract="输出 JSON 对象,包含 signals 数组。", call_sites=PMO_BATCH_CALL_SITES, ), _entry( "PROMPT_DRAFT_GENERATOR", module="part_02", business_scenario="立项草案生成", input_contract="输入 request / project / active_projects / similar_projects / charter / members / recent_signals。", output_contract="输出 JSON 对象,包含项目草案、定位、核心痛点、MVP 分期、技术架构、商业模式、验证指标与风险。", call_sites=DRAFT_GENERATOR_CALL_SITES, ), _entry( "PROMPT_RAG_INTENT_CLASSIFICATION", module="part_02", business_scenario="RAG 意图识别", input_contract=QA_INPUT, output_contract="输出 JSON 对象,包含 intent / confidence / reason。", call_sites=RAG_INTENT_CALL_SITES, ), ) def _part_03_entries() -> tuple[dict[str, Any], ...]: return ( _entry( "PROMPT_RAG_ANSWER", module="part_03", business_scenario="RAG 问答生成", input_contract=QA_INPUT, output_contract=QA_OUTPUT, call_sites=DEEP_GUARD_CALL_SITES, ), _entry( "PROMPT_DECISION_QA", module="part_03", business_scenario="决策类问答", input_contract=QA_INPUT, output_contract="输出自然语言结论,必要时包含取舍理由。", call_sites=DEEP_GUARD_CALL_SITES, ), _entry( "PROMPT_RAG_DB_PROJECT_QA", module="part_03", business_scenario="项目知识库问答", input_contract=JSON_INPUT, output_contract=QA_OUTPUT, call_sites=RAG_DB_CALL_SITES, ), _entry( "PROMPT_GENERATE_CHARTER", module="part_03", business_scenario="宪章草案生成", input_contract="输入 request / project / active_projects / similar_projects / signal_context。", output_contract="输出 JSON 对象,包含 modules / field-level evidence / readiness / derived_artifacts。", call_sites=("backend/app/services/ai_service_core/mixin_business_tasks.py", "backend/app/services/sstc/charter_prefill_utils.py"), ), _entry( "PROMPT_DECOMPOSE_TASKS", module="part_03", business_scenario="任务拆解", input_contract="输入 request / project / charter / modules 的结构化上下文。", output_contract="输出 JSON 数组,包含任务名称、描述、工时、优先级和技能标签。", call_sites=("backend/app/services/ai_service_core/mixin_business_tasks.py", "backend/app/api/tasks.py", "backend/app/api/sstc_api/tasks_ai_breakdown.py"), ), _entry( "PROMPT_RECOMMEND_ASSIGNEES", module="part_03", business_scenario="负责人推荐", input_contract=JSON_INPUT, output_contract="输出 JSON 数组,包含候选人、匹配理由和负载信息。", call_sites=AI_BUSINESS_TASKS_CALL_SITES, ), _entry( "PROMPT_ALIGNMENT_SCORE", module="part_03", business_scenario="对齐度评分", input_contract=SCORE_INPUT, output_contract=SCORE_OUTPUT, call_sites=AI_BUSINESS_ANALYSIS_CALL_SITES, ), _entry( "PROMPT_COGNITIVE_CONFLICTS", module="part_03", business_scenario="认知冲突识别", input_contract=SCORE_INPUT, output_contract=SCORE_OUTPUT, call_sites=AI_BUSINESS_ANALYSIS_CALL_SITES, ), _entry( "PROMPT_EVALUATE_MODEL_REQUIREMENT", module="part_03", business_scenario="模型需求评估", input_contract=SCORE_INPUT, output_contract=SCORE_OUTPUT, call_sites=AI_BUSINESS_ANALYSIS_CALL_SITES, ), _entry( "PROMPT_ANALYZE_CAPABILITY_GAP", module="part_03", business_scenario="能力缺口分析", input_contract=SCORE_INPUT, output_contract=SCORE_OUTPUT, call_sites=AI_BUSINESS_ANALYSIS_CALL_SITES, ), _entry( "PROMPT_ANALYZE_COST_ROI", module="part_03", business_scenario="成本收益分析", input_contract=SCORE_INPUT, output_contract=SCORE_OUTPUT, call_sites=AI_BUSINESS_ANALYSIS_CALL_SITES, ), ) def _part_04_entries() -> tuple[dict[str, Any], ...]: return ( _entry( "PROMPT_ANALYZE_COST_OPTIMIZATION", module="part_04", business_scenario="成本优化分析", input_contract=JSON_INPUT, output_contract="输出 JSON 对象,包含降级、缓存、批处理与节省测算。", call_sites=AI_BUSINESS_ANALYSIS_CALL_SITES, ), _entry( "PROMPT_ASSESS_MODEL_UPDATE_IMPACT", module="part_04", business_scenario="模型升级影响评估", input_contract=JSON_INPUT, output_contract="输出 JSON 对象,包含成本变化、兼容风险与建议。", call_sites=("backend/app/services/model/model_capability/service.py",), ), _entry( "PROMPT_EXPERIMENT_SYNC_DECISION", module="part_04", business_scenario="实验结果同步决策", input_contract=JSON_INPUT, output_contract="输出 JSON 对象,包含置信度、是否自动同步与原因。", call_sites=("backend/app/services/ai_pmo/ai_pmo_cadence/mixin_builders.py",), ), _entry( "PROMPT_SKILL_SCORE_UPDATE", module="part_04", business_scenario="技能评分更新", input_contract=JSON_INPUT, output_contract="输出 JSON 对象,包含技能增量列表。", call_sites=SKILL_SCORE_CALL_SITES, ), _entry( "PROMPT_WORKLOAD_OPTIMIZATION", module="part_04", business_scenario="任务负载优化", input_contract=JSON_INPUT, output_contract="输出 JSON 对象,包含重分配建议。", call_sites=WORKLOAD_CALL_SITES, ), _entry( "PROMPT_ANALYZE_FOOD_CALORIES", module="part_04", business_scenario="食物热量估算", input_contract=QA_INPUT, output_contract="输出 JSON 对象,包含食物名、热量、营养和不确定因素。", call_sites=RECIPE_CALL_SITES, ), _entry( "PROMPT_SIGNAL_PLANNER", module="part_04", business_scenario="信号规划 / 任务编排建议", input_contract="输入 signal / project / charter_json / recent_signals / member_profiles。", output_contract="输出 JSON 对象,包含 summary、priority、负责人建议、执行计划和风险。", call_sites=SIGNAL_PLANNER_CALL_SITES, ), ) def _scene_entries() -> tuple[dict[str, Any], ...]: return ( _entry( "PROMPT_FEISHU_DIRECT_QA", module="part_scenes_01", business_scenario="飞书直接问答", input_contract="输入 question / system_snapshot / user_snapshot / context_blocks。", output_contract=QA_OUTPUT, call_sites=DEEP_GUARD_CALL_SITES, ), _entry( "PROMPT_FEISHU_MIXED_QA", module="part_scenes_02", business_scenario="飞书混合问答", input_contract="输入 project_id / message / question_part / signal_part / system_snapshot / context_blocks。", output_contract="输出先结论后入库说明的自然语言答复。", call_sites=DEEP_GUARD_CALL_SITES, ), _entry( "PROMPT_PROJECT_STATUS_QA", module="part_scenes_03", business_scenario="项目状态问答", input_contract="输入 question / project_id / system_snapshot / user_snapshot / context_blocks。", output_contract="输出项目状态结论、进度与下一步建议。", call_sites=DEEP_GUARD_CALL_SITES, ), _entry( "PROMPT_PROJECT_WEEKLY_REPORT_JSON", module="part_scenes_03", business_scenario="项目周报结构化输出", input_contract="输入 question / asks_risk_or_blockers / project_snapshot / internal_findings / external_updates。", output_contract="输出 JSON 对象,包含 summary / stage_judgement / evidence_summary / core_gap / external_impact / actions。", call_sites=("backend/app/services/adaptive_rag_service/mixin_fast_answer_project_main.py",), ), _entry( "PROMPT_MEMBER_WORKLOAD_QA", module="part_scenes_04", business_scenario="成员负载问答", input_contract="输入 question / system_snapshot / user_snapshot / context_blocks。", output_contract="输出成员负载与推荐建议。", call_sites=DEEP_GUARD_CALL_SITES, ), _entry( "PROMPT_AI_PMO_QA", module="part_scenes_05", business_scenario="AI PMO 问答", input_contract="输入 question / project_id / system_snapshot / user_snapshot / context_blocks。", output_contract="输出 AI PMO 视角的结论与建议。", call_sites=DEEP_GUARD_CALL_SITES, ), _entry( "PROMPT_AI_PMO_REQUIREMENT_PLAN_QA", module="part_scenes_05", business_scenario="AI PMO 需求收敛问答", input_contract="输入 question / project_id / world_model / conversation / context_blocks。", output_contract="输出需求收敛、选项澄清与下一步建议。", call_sites=DEEP_GUARD_CALL_SITES, ), _entry( "PROMPT_EXTERNAL_TREND_QA", module="part_scenes_06", business_scenario="外部趋势问答", input_contract="输入 question / project_id / system_snapshot / user_snapshot / context_blocks。", output_contract="输出行业/市场趋势判断与建议。", call_sites=DEEP_GUARD_CALL_SITES, ), _entry( "PROMPT_INDUSTRY_TREND_QA", module="part_scenes_06", business_scenario="行业趋势问答", input_contract="输入 question / project_id / system_snapshot / user_snapshot / context_blocks。", output_contract="输出行业趋势判断与建议。", call_sites=DEEP_GUARD_CALL_SITES, ), _entry( "PROMPT_EXTERNAL_DIRECT_FACT_QA", module="part_scenes_06", business_scenario="外部事实直答", input_contract="输入 question / plan_summary / evidence_blocks / source_summaries / time_range / uncertainties。", output_contract="输出仅基于外部证据的事实结论。", call_sites=("backend/app/services/external_query_service/presenter.py",), ), _entry( "PROMPT_EXTERNAL_SUMMARY_WITH_SOURCES_QA", module="part_scenes_06", business_scenario="外部事实总结", input_contract="输入 question / plan_summary / evidence_blocks / source_summaries / time_range / uncertainties。", output_contract="输出仅基于外部证据的总结性回答。", call_sites=("backend/app/services/external_query_service/presenter.py",), ), _entry( "PROMPT_EXTERNAL_COMPARE_WITH_SOURCES_QA", module="part_scenes_06", business_scenario="外部事实对比", input_contract="输入 question / plan_summary / evidence_blocks / source_summaries / time_range / uncertainties。", output_contract="输出仅基于外部证据的对比回答。", call_sites=("backend/app/services/external_query_service/presenter.py",), ), _entry( "PROMPT_EXTERNAL_SIGNAL_SOURCE_RECOMMENDATION_QA", module="part_scenes_06", business_scenario="外部信号源推荐问答", input_contract="输入 question / plan_summary / fit_brief_summary / recommendation_goal / project_object_anchors / signal_source_objectives / retrieval_status。", output_contract=QA_OUTPUT, call_sites=("backend/app/services/external_query_service/presenter.py",), ), _entry( "PROMPT_EXTERNAL_SIGNAL_SOURCE_RECOMMENDATION_PACKET", module="part_scenes_06", business_scenario="外部信号源推荐候选包", input_contract="输入 question / plan_summary / fit_brief_summary / recommendation_goal / project_object_anchors / signal_source_objectives / retrieval_status。", output_contract="输出 JSON 对象,包含 candidates 和 caveat。", call_sites=("backend/app/services/external_query_service/presenter.py",), ), _entry( "PROMPT_PMFLOW_LAUNCH_DRAFT", module="part_scenes_06", business_scenario="PMFlow 新项目启动草案", input_contract="输入用户创意文本与附件摘要。", output_contract="输出 JSON 对象,包含待确认项目草案、需求、任务、风险、决策和证据。", call_sites=("backend/app/services/pmflow_launch_service.py", "backend/app/services/space_saved_idea_service.py"), prompt_family=PROMPT_FAMILY_PLANNING, ), _entry( "PROMPT_PMFLOW_CHANGE_REVIEW_EXTRACTION", module="part_scenes_06", business_scenario="项目主链变更抽取", input_contract="输入项目线程消息与附件摘要。", output_contract="输出 JSON 对象,包含 change_summary、proposed_items、evidence、missing_info、warnings 和 confidence。", call_sites=("backend/app/services/pmflow_change_review_service.py",), prompt_family=PROMPT_FAMILY_EXTRACTION, ), _entry( "PROMPT_SAVED_IDEA_ENRICHMENT", module="part_scenes_06", business_scenario="暂存想法结构化整理", input_contract="输入用户保存的想法文本;需要识别问候、测试词、无意义短语等非想法输入。", output_contract="输出 JSON 对象,包含完整度、缺口、readiness_score 和状态。", call_sites=("backend/app/services/space_saved_idea_service.py",), prompt_family=PROMPT_FAMILY_EXTRACTION, ), ) def _runtime_guardrail_entries() -> tuple[dict[str, Any], ...]: return ( _entry( "PMFLOW_SEMANTIC_CONTEXT_DECISION_PROMPT", module="ai_prompts", business_scenario="PMFlow AI 上下文与主链边界决策", input_contract="输入 semantic_context_packet、conversation_scope、显式 reply/thread/work_item 锚点与 active workspace 摘要。", output_contract=JSON_OUTPUT, call_sites=("backend/app/services/ai_pmo/semantic_context/semantic_decision_service.py",), prompt_family=PROMPT_FAMILY_GOVERNANCE, responsibility_scope="治理层:判断 topic、workflow、draft follow-up、interaction boundary 与对象锚点,不执行检索、写入或最终回答。", risk_level="critical", editable_policy="guarded_release", ), _entry( "PROMPT_RAG_QUERY_SEMANTICS", module="ai_prompts", business_scenario="PMFlow AI 问答语义与来源策略规划", input_contract="输入用户消息、workflow bundle、业务对象绑定、上下文与 source policy hint。", output_contract=JSON_OUTPUT, call_sites=("backend/app/services/adaptive_rag_service/mixin_core_intent.py",), prompt_family=PROMPT_FAMILY_GOVERNANCE, responsibility_scope="治理层:把 query.answer 只读问题结构化为目标对象、答案形态和来源策略,不执行检索或答案生成。", risk_level="critical", editable_policy="guarded_release", ), _entry( "PROMPT_PMFLOW_AI_ROUTE_PLANNER", module="ai_prompts", business_scenario="PMFlow AI 用户侧旧路由规划(已从 Space 主链下线)", input_contract="仅供历史 replay/迁移参考;Space 用户侧运行时不再消费该 prompt 做主控。", output_contract=JSON_OUTPUT, call_sites=(), prompt_family=PROMPT_FAMILY_GOVERNANCE, responsibility_scope="legacy:旧 route_plan/source_strategy/allowed_executors 合同已由 TurnState + Action Loop 取代,不执行运行时路由、不生成最终答案。", risk_level="critical", editable_policy="deprecated", ), _entry( "PROMPT_PMFLOW_AI_AGENT_GOAL_FRAME", module="ai_prompts", business_scenario="PMFlow AI Agent Runtime 证据读取目标合同(非主控)", input_contract="输入用户问题、conversation_context、客户安全 surface_context 与工具合同;作为 Operating Runtime 的证据读取适配合同。", output_contract=JSON_OUTPUT, call_sites=("backend/app/services/pmflow_ai_agent_runtime/agent_goal_frame_runtime.py",), prompt_family=PROMPT_FAMILY_GOVERNANCE, responsibility_scope="治理层:只为旧 AgentRun 证据读取适配生成 GoalFrame;Space 主控必须先进入 OperatingMission,不得再把 GoalFrame 当用户侧 mission 主控。", risk_level="critical", editable_policy="guarded_release", ), _entry( "PROMPT_PMFLOW_AI_OPERATING_MISSION", module="ai_prompts", business_scenario="PMFlow AI Operating Mission 生成", input_contract="输入用户问题、conversation_context、客户安全 surface_context 与 specialist capability contracts。", output_contract="输出符合 PMFlowAIOperatingMission schema 的 JSON,包含经营目标、业务结果、对象范围、专业 agent、确认边界与下一轮策略。", call_sites=("backend/app/services/pmflow_ai_operating_runtime/mission_service.py",), prompt_family=PROMPT_FAMILY_GOVERNANCE, responsibility_scope="主控层:把用户输入升级为可经营 mission,决定对象、产物方向、专业 agent 和下一轮策略;不生成最终答案、不执行写入、不调用具体工具。", risk_level="critical", editable_policy="guarded_release", ), _entry( "PROMPT_PMFLOW_AI_SPECIALIST_WORK_PRODUCT", module="ai_prompts", business_scenario="PMFlow AI Specialist Agent 工作产物生成", input_contract="输入 agent capability contract、OperatingMission、ProjectWorldState 与 LearningLedger。", output_contract="输出 specialist work product JSON,包含 claims、recommendations、prepared_actions、blocked_actions、evidence_refs 与 verification。", call_sites=("backend/app/services/pmflow_ai_operating_runtime/specialist_agents.py",), prompt_family=PROMPT_FAMILY_GOVERNANCE, responsibility_scope="专业层:每个 specialist 只产出本角色 artifact,不写最终答案、不越权执行;证据不足时输出边界和下一步研究任务。", risk_level="critical", editable_policy="guarded_release", ), _entry( "PROMPT_PMFLOW_AI_OPERATING_ANSWER_COMPOSER", module="ai_prompts", business_scenario="PMFlow AI Operating Runtime 终局答案表达", input_contract="输入用户问题、OperatingMission、客户安全证据、specialist work products、Council/Autonomy 结果、可承接动作和早期证据答案。", output_contract="输出客户可见中文自然答案,必须消费专业产物并面向 PMFlow 从创意到变现执行闭环组织内容。", call_sites=("backend/app/services/pmflow_ai_operating_runtime/run_service.py",), prompt_family=PROMPT_FAMILY_GOVERNANCE, responsibility_scope="展示层:把 Operating Runtime 的产品/研究/MVP/变现/执行承接产物合成最终用户答案;不做路由、不执行写入、不暴露内部运行时。", risk_level="critical", editable_policy="guarded_release", ), _entry( "PROMPT_PMFLOW_AI_OPERATING_COUNCIL", module="ai_prompts", business_scenario="PMFlow AI Agent Council 会审与产物投影", input_contract="输入 OperatingMission、ProjectWorldState、specialist work products 与 LearningLedger。", output_contract="输出 council review / operating decision JSON,包含冲突、风险否决、优先级、产品对象投影、证据边界和下一轮触发。", call_sites=("backend/app/services/pmflow_ai_operating_runtime/council.py",), prompt_family=PROMPT_FAMILY_GOVERNANCE, responsibility_scope="会审层:检查目标覆盖、证据、产物化、可执行下一步、人类确认和越权风险;不生成自然答案、不执行写入。", risk_level="critical", editable_policy="guarded_release", ), _entry( "PROMPT_PMFLOW_AI_AGENT_STEP_PLANNER", module="ai_prompts", business_scenario="PMFlow AI Agent Runtime 下一步规划", input_contract="输入用户问题、含 GoalFrame/ledger 的 agent_workspace、conversation_context 与客户安全 surface_context。", output_contract=JSON_OUTPUT, call_sites=("backend/app/services/pmflow_ai_agent_runtime/agent_step_planner.py",), prompt_family=PROMPT_FAMILY_GOVERNANCE, responsibility_scope="治理层:只规划一个下一步 runtime action 或只读工具,不生成最终答案、不执行写入、不按业务场景枚举路由。", risk_level="critical", editable_policy="guarded_release", ), _entry( "PROMPT_PMFLOW_AI_AGENT_EVIDENCE_NORMALIZER", module="ai_prompts", business_scenario="PMFlow AI Agent Runtime 通用证据归一化", input_contract="输入用户问题、GoalFrame 和单条 raw observation。", output_contract=JSON_OUTPUT, call_sites=("backend/app/services/pmflow_ai_agent_runtime/agent_evidence_normalizer.py",), prompt_family=PROMPT_FAMILY_GOVERNANCE, responsibility_scope="治理层:把所有工具观察归一成 source_quality、usable claims、affordances、action_candidates、boundaries 与 gaps;raw observation 不直接进入最终答案。", risk_level="critical", editable_policy="guarded_release", ), _entry( "PROMPT_PMFLOW_AI_AGENT_STATE_CRITIC", module="ai_prompts", business_scenario="PMFlow AI Agent Runtime 状态充分性检查", input_contract="输入用户问题、含 GoalFrame/Claim Ledger/Boundary Ledger 的 agent_workspace、planner proposal 与 latest observation。", output_contract=JSON_OUTPUT, call_sites=("backend/app/services/pmflow_ai_agent_runtime/agent_state_critic.py",), prompt_family=PROMPT_FAMILY_GOVERNANCE, responsibility_scope="治理层:只判断 ledger 状态是否足以进入答案生成,或需要继续读取/请求用户补充;必须声明 retry 是否会改变状态,不生成最终正文。", risk_level="critical", editable_policy="guarded_release", ), _entry( "PROMPT_PMFLOW_AI_AGENT_ANSWER_COMPOSER", module="ai_prompts", business_scenario="PMFlow AI Agent Runtime 终局答案表达", input_contract="输入用户问题与客户安全 terminal_answer_state。", output_contract="输出客户可见中文自然答案,不暴露内部运行时术语、prompt、trace、函数名、表字段或供应商信息。", call_sites=("backend/app/services/pmflow_ai_agent_runtime/agent_answer_runtime.py",), prompt_family=PROMPT_FAMILY_GOVERNANCE, responsibility_scope="展示层:只消费 terminal ledgers、action_candidates、DeliverablePlan 与 AnswerIntentPlan 写自然答案,不做目标识别、来源选择、对象绑定、工具选择或写操作。", risk_level="critical", editable_policy="guarded_release", ), _entry( "PROMPT_PMFLOW_AI_AGENT_ANSWER_REVISER", module="ai_prompts", business_scenario="PMFlow AI Agent Runtime 答案质量修订", input_contract="输入用户问题、客户安全 terminal_answer_state、原答案与质量检查 findings。", output_contract="输出修订后的客户可见中文自然答案;保留原答案中有价值的安全内容,只修正质量问题。", call_sites=("backend/app/services/pmflow_ai_agent_runtime/agent_answer_runtime.py",), prompt_family=PROMPT_FAMILY_GOVERNANCE, responsibility_scope="展示层:根据质量门禁反馈修订答案,不做目标识别、来源选择、对象绑定、工具选择或写操作;修订失败后由代码 fail-closed。", risk_level="critical", editable_policy="guarded_release", ), _entry( "PROMPT_PMFLOW_AI_CONTEXT_MEMORY_COMPACTOR", module="ai_prompts", business_scenario="PMFlow AI 长上下文语义记忆压缩", input_contract="输入最新用户/助手回合、已有分层长期记忆和客户安全 context_pack。", output_contract="输出 thread/user/workspace/project 四层语义记忆 JSON,包含 summary、durable_facts、open_loops、decisions、preferences 和 object_refs。", call_sites=("backend/app/services/pmflow_ai_context_memory_service.py",), prompt_family=PROMPT_FAMILY_GOVERNANCE, responsibility_scope="治理层:只把对话压缩为客户安全长期记忆,不做路由、不生成最终答案、不执行写入项目记忆或外部动作。", risk_level="critical", editable_policy="guarded_release", ), _entry( "PROMPT_PMFLOW_AI_TURN_GOAL_STATE_ASSESSOR", module="ai_prompts", business_scenario="PMFlow AI TurnState 目标评估", input_contract="输入用户问题、project_id、conversation_context、tenant_project_context 与 visible_context_objects。", output_contract=JSON_OUTPUT, call_sites=("backend/app/services/pmflow_ai_turn_runtime_service.py",), prompt_family=PROMPT_FAMILY_GOVERNANCE, responsibility_scope="治理层:只把单轮用户目标、对象锚点、证据缺口和披露边界结构化为 TurnState 候选,不执行检索、不写入、不生成最终答案。", risk_level="critical", editable_policy="guarded_release", ), _entry( "PROMPT_PMFLOW_AI_TURN_STATE_ANSWER_SYNTHESIZER", module="ai_prompts", business_scenario="PMFlow AI TurnState 受控答案合成", input_contract="输入用户问题、final TurnState、Answer Runtime 计划、evidence_findings 和 project_operating_answer_verification。", output_contract="输出客户可见中文 Markdown 答案,不暴露内部运行时术语、prompt key、函数名、trace、表字段或供应商信息。", call_sites=("backend/app/services/pmflow_ai_turn_runtime_service.py",), prompt_family=PROMPT_FAMILY_GOVERNANCE, responsibility_scope="展示层:只消费 final TurnState 与客户安全证据合成最终答案,不做目标识别、来源选择、对象绑定、写操作或检索决策。", risk_level="critical", editable_policy="guarded_release", ), _entry( "PROMPT_CUSTOMER_ANSWER_COMPOSER", module="ai_prompts", business_scenario="PMFlow AI 客户答案表达生成", input_contract="输入 customer_evidence_packet 与用户问题,只允许使用 display_label / display_summary / business_values 等客户安全字段。", output_contract="输出客户可见中文答案文本,不暴露 raw source、trace、prompt key、函数名、表字段或供应商信息。", call_sites=("backend/app/services/customer_answer_presentation_service.py",), prompt_family=PROMPT_FAMILY_GOVERNANCE, responsibility_scope="展示层:只消费 customer-safe evidence packet 生成用户答案,不执行检索、路由拍板或写操作。", risk_level="critical", editable_policy="guarded_release", ), _entry( "PROMPT_SPACE_AI_INTERACTION_OPTION_PLANNER", module="ai_prompts", business_scenario="Space AI 追问选项规划", input_contract="输入 customer_evidence_packet、用户原始问题、已生成客户答案和 fallback interaction_request。", output_contract="输出 JSON interaction_request 片段,包含逐题 questions、客户安全 options、supplement 和 submit_label。", call_sites=("backend/app/services/customer_answer_presentation_service.py",), prompt_family=PROMPT_FAMILY_GOVERNANCE, responsibility_scope="展示交互层:只为已判定需要追问的问题生成客户可见候选选项,不做路由、检索、写操作或事实确认。", risk_level="critical", editable_policy="guarded_release", ), _entry( "PROMPT_CUSTOMER_ANSWER_VERIFIER", module="ai_prompts", business_scenario="PMFlow AI 客户答案质检", input_contract="输入 customer_evidence_packet、用户问题与候选答案。", output_contract=JSON_OUTPUT, call_sites=("backend/app/services/customer_answer_presentation_service.py",), prompt_family=PROMPT_FAMILY_GOVERNANCE, responsibility_scope="展示层 guardrail:检查答案是否泄露内部术语、未回答问题、越过证据或过度声称;只输出质检 JSON。", risk_level="critical", editable_policy="guarded_release", ), _entry( "PROMPT_RAG_FOLLOWUP_ANCHOR_SEMANTICS", module="ai_prompts", business_scenario="PMFlow AI 续问锚点归位", input_contract="输入当前问题、上一轮 QA/session state、对象锚点候选和 conversation scope。", output_contract=JSON_OUTPUT, call_sites=("backend/app/services/adaptive_rag_service/mixin_followup_anchor.py",), prompt_family=PROMPT_FAMILY_GOVERNANCE, responsibility_scope="治理层:判断“它/这个/刚才那个”等续问应回到哪个业务对象或澄清项,不生成最终答案。", risk_level="high", editable_policy="guarded_release", ), _entry( "PROMPT_RAG_PENDING_CLARIFICATION_SELECTION_SEMANTICS", module="ai_prompts", business_scenario="PMFlow AI 待澄清项选择", input_contract="输入当前回复、pending clarifications、会话上下文和对象绑定候选。", output_contract=JSON_OUTPUT, call_sites=("backend/app/services/adaptive_rag_service/mixin_followup_anchor.py",), prompt_family=PROMPT_FAMILY_GOVERNANCE, responsibility_scope="治理层:把用户补充绑定到正确 pending clarification,不做业务写入或答案生成。", risk_level="high", editable_policy="guarded_release", ), _entry( "PROMPT_INTERNAL_TARGET_RESOLUTION", module="ai_prompts", business_scenario="内部问答目标对象解析", input_contract=JSON_INPUT, output_contract=JSON_OUTPUT, call_sites=("backend/app/services/adaptive_rag_service/mixin_target_resolution.py",), prompt_family=PROMPT_FAMILY_GOVERNANCE, risk_level="critical", editable_policy="guarded_release", ), _entry( "PROMPT_EXTERNAL_QUERY_PLAN", module="ai_prompts", business_scenario="外部实时查询计划", input_contract="输入 question / route decision / source policy。", output_contract=JSON_OUTPUT, call_sites=("backend/app/services/external_query_service/planner.py",), prompt_family=PROMPT_FAMILY_PLANNING, risk_level="high", editable_policy="guarded_release", ), _entry( "PROMPT_RAG_ANSWER_SCENE_SEMANTICS", module="ai_prompts", business_scenario="RAG answer 场景选择", input_contract=JSON_INPUT, output_contract=JSON_OUTPUT, call_sites=("backend/app/services/adaptive_rag_service/mixin_deep_guard_answer.py",), prompt_family=PROMPT_FAMILY_GOVERNANCE, risk_level="high", editable_policy="guarded_release", ), _entry( "PMFLOW_REQUIREMENT_PLAN_ROUND_PROMPT", module="ai_prompts", business_scenario="需求收敛追问轮次", input_contract="输入 requirement_plan_packet。", output_contract=JSON_OUTPUT, call_sites=("backend/app/services/ai_pmo/ai_pmo_typed_executor_execute/mixin_execute_query_project.py",), prompt_family=PROMPT_FAMILY_PLANNING, risk_level="critical", editable_policy="guarded_release", ), _entry( "PMFLOW_REQUIREMENT_PLAN_DRAFT_PROMPT", module="ai_prompts", business_scenario="需求草稿生成", input_contract="输入 requirement_plan_draft_packet。", output_contract=JSON_OUTPUT, call_sites=("backend/app/services/ai_pmo/ai_pmo_typed_executor_execute/mixin_execute_query_project.py",), prompt_family=PROMPT_FAMILY_PLANNING, risk_level="critical", editable_policy="guarded_release", ), ) def _semantic_fact_entries() -> tuple[dict[str, Any], ...]: common = { "module": "ai_prompts", "input_contract": "输入对象快照、证据文本与抽取范围。", "output_contract": "输出 semantic facts JSON,不要 Markdown。", "call_sites": ("backend/app/services/semantic_fact_service/shared.py", "backend/app/services/semantic_fact_service/mixin_extract.py"), "prompt_family": PROMPT_FAMILY_EXTRACTION, "risk_level": "high", "editable_policy": "guarded_release", } return tuple( _entry(prompt_key, business_scenario=f"语义事实抽取:{label}", **common) for prompt_key, label in ( ("PROMPT_SEMANTIC_FACT_EXTRACT_PROJECT", "项目"), ("PROMPT_SEMANTIC_FACT_EXTRACT_TASK", "任务"), ("PROMPT_SEMANTIC_FACT_EXTRACT_SIGNAL", "信号"), ("PROMPT_SEMANTIC_FACT_EXTRACT_DOCUMENT", "文档"), ("PROMPT_SEMANTIC_FACT_EXTRACT_USER", "用户"), ("PROMPT_SEMANTIC_FACT_EXTRACT_REQUIREMENT", "需求"), ("PROMPT_SEMANTIC_FACT_EXTRACT_RELEASE", "发布"), ("PROMPT_SEMANTIC_FACT_EXTRACT_REVIEW", "复盘"), ) ) def _inline_discovered_entries() -> tuple[dict[str, Any], ...]: common = { "runtime_source": "inline_discovered", "editable_policy": "needs_migration", "risk_level": "medium", } return ( _entry("PROMPT_SIGNAL_WEBPAGE_VALUE_ANALYSIS", module="inline_discovered", business_scenario="网页信号价值分析", input_contract=JSON_INPUT, output_contract=JSON_OUTPUT, call_sites=("backend/app/services/signal/signal_capture_service/mixin_source_analyzers.py",), prompt_family=PROMPT_FAMILY_EXTRACTION, **common), _entry("PROMPT_SIGNAL_GITHUB_EVENT_VALUE_ANALYSIS", module="inline_discovered", business_scenario="GitHub 事件价值分析", input_contract=JSON_INPUT, output_contract=JSON_OUTPUT, call_sites=("backend/app/services/signal/signal_capture_service/mixin_source_analyzers.py",), prompt_family=PROMPT_FAMILY_EXTRACTION, **common), _entry("PROMPT_SIGNAL_HACKERNEWS_TREND_ANALYSIS", module="inline_discovered", business_scenario="HackerNews 趋势信号分析", input_contract=JSON_INPUT, output_contract=JSON_OUTPUT, call_sites=("backend/app/services/signal/signal_capture_service/mixin_source_analyzers.py",), prompt_family=PROMPT_FAMILY_EXTRACTION, **common), _entry("PROMPT_AUDIT_FUNCTIONALITY_REVIEW", module="inline_discovered", business_scenario="代码功能正确性审计", input_contract="输入任务、文件、diff 与可选完整文件内容。", output_contract=JSON_OUTPUT, call_sites=("backend/app/services/auditor_core/mixin_ai_score.py",), prompt_family=PROMPT_FAMILY_GOVERNANCE, **common), _entry("PROMPT_AUDIT_ARCHITECTURE_REVIEW", module="inline_discovered", business_scenario="代码架构审计", input_contract="输入任务、提交信息、diff 和变更文件。", output_contract=JSON_OUTPUT, call_sites=("backend/app/services/auditor_core/mixin_ai_score.py",), prompt_family=PROMPT_FAMILY_GOVERNANCE, **common), _entry("PROMPT_BLOCKER_CODE_ANALYSIS", module="inline_discovered", business_scenario="代码阻塞分析", input_contract=JSON_INPUT, output_contract=JSON_OUTPUT, call_sites=("backend/app/services/blocker_detection_core/mixin_ai.py",), prompt_family=PROMPT_FAMILY_EXTRACTION, **common), _entry("PROMPT_BLOCKER_TASK_ANALYSIS", module="inline_discovered", business_scenario="任务阻塞分析", input_contract=JSON_INPUT, output_contract=JSON_OUTPUT, call_sites=("backend/app/services/blocker_detection_core/mixin_ai.py",), prompt_family=PROMPT_FAMILY_EXTRACTION, **common), _entry("PROMPT_COGNITIVE_TASK_CHARTER_MISMATCH", module="inline_discovered", business_scenario="任务与宪章一致性检查", input_contract=JSON_INPUT, output_contract=JSON_OUTPUT, call_sites=("backend/app/services/cognitive_conflict_core/mixin_detection.py",), prompt_family=PROMPT_FAMILY_GOVERNANCE, **common), _entry("PROMPT_COGNITIVE_DEFINITION_CONFLICTS", module="inline_discovered", business_scenario="项目定义隐性冲突分析", input_contract=JSON_INPUT, output_contract=JSON_LIST_OUTPUT, call_sites=("backend/app/services/cognitive_conflict_core/mixin_detection.py",), prompt_family=PROMPT_FAMILY_GOVERNANCE, **common), _entry("PROMPT_COGNITIVE_CONFLICT_RESOLUTION", module="inline_discovered", business_scenario="认知冲突解决方案", input_contract=JSON_INPUT, output_contract=JSON_OUTPUT, call_sites=("backend/app/services/cognitive_conflict_core/mixin_resolution.py",), prompt_family=PROMPT_FAMILY_PLANNING, **common), _entry("PROMPT_COGNITIVE_CHARTER_CONFLICTS", module="inline_discovered", business_scenario="宪章潜在冲突分析", input_contract=JSON_INPUT, output_contract=JSON_LIST_OUTPUT, call_sites=("backend/app/services/cognitive_conflict_core/mixin_storage.py",), prompt_family=PROMPT_FAMILY_GOVERNANCE, **common), _entry("PROMPT_CODEGEN_FULL_CODE_DRAFT", module="inline_discovered", business_scenario="代码生成草案", input_contract="输入需求、战略分析和代码上下文。", output_contract=JSON_OUTPUT, call_sites=("backend/app/services/codegen_core/mixin_prompt_llm.py",), prompt_family=PROMPT_FAMILY_PLANNING, risk_level="high", **{k: v for k, v in common.items() if k != "risk_level"}), _entry("PROMPT_DAILY_BRIEFING_PERSONAL_SUMMARY", module="inline_discovered", business_scenario="每日个人工作摘要", input_contract=JSON_INPUT, output_contract=QA_OUTPUT, call_sites=("backend/app/services/daily_briefing_core/mixin_helpers_summary.py",), prompt_family=PROMPT_FAMILY_RESPONSE, **common), _entry("PROMPT_EVENT_SIGNAL_IMPACT_ASSESSMENT", module="inline_discovered", business_scenario="信号对项目影响评估", input_contract=JSON_INPUT, output_contract=JSON_OUTPUT, call_sites=("backend/app/services/event_workflow_core/mixin_helpers.py",), prompt_family=PROMPT_FAMILY_GOVERNANCE, **common), _entry("PROMPT_EVENT_BLOCKER_WORKAROUND", module="inline_discovered", business_scenario="阻塞绕过方案生成", input_contract=JSON_INPUT, output_contract=JSON_OUTPUT, call_sites=("backend/app/services/event_workflow_core/mixin_handlers_primary.py",), prompt_family=PROMPT_FAMILY_PLANNING, **common), _entry("PROMPT_EVENT_COMPETITOR_IMPACT", module="inline_discovered", business_scenario="竞品动态战略影响分析", input_contract=JSON_INPUT, output_contract=JSON_OUTPUT, call_sites=("backend/app/services/event_workflow_core/mixin_handlers_secondary.py",), prompt_family=PROMPT_FAMILY_GOVERNANCE, **common), _entry("PROMPT_AI_STEWARD_SIGNAL_IMPORTANCE", module="inline_discovered", business_scenario="手动信号重要性分析", input_contract=JSON_INPUT, output_contract=JSON_OUTPUT, call_sites=("backend/app/api/ai_steward_api/routes_capture.py",), prompt_family=PROMPT_FAMILY_EXTRACTION, **common), _entry("PROMPT_AI_STEWARD_CODE_BLOCKER_SOLUTION", module="inline_discovered", business_scenario="代码问题解决方案", input_contract=JSON_INPUT, output_contract=JSON_OUTPUT, call_sites=("backend/app/api/ai_steward_api/routes_brief_blockers.py",), prompt_family=PROMPT_FAMILY_PLANNING, **common), _entry("PROMPT_AI_STEWARD_COMPETITIVE_SIGNAL_DRAFT", module="inline_discovered", business_scenario="竞品分析信号草稿", input_contract=JSON_INPUT, output_contract=JSON_OUTPUT, call_sites=("backend/app/services/ai_steward_service/mixin_draft_generation.py",), prompt_family=PROMPT_FAMILY_PLANNING, **common), _entry("PROMPT_AI_STEWARD_CHARTER_DRAFT", module="inline_discovered", business_scenario="项目宪章草稿", input_contract=JSON_INPUT, output_contract=JSON_OUTPUT, call_sites=("backend/app/services/ai_steward_service/mixin_draft_generation.py",), prompt_family=PROMPT_FAMILY_PLANNING, **common), _entry("PROMPT_AI_PMO_SIGNAL_TITLE_REFINE", module="inline_discovered", business_scenario="信号标题提炼", input_contract=JSON_INPUT, output_contract="仅输出标题文本。", call_sites=("backend/app/services/ai_pmo/ai_pmo_typed_executor_execute/mixin_helpers.py",), prompt_family=PROMPT_FAMILY_RESPONSE, **common), _entry("PROMPT_LLM_TASK_BREAKDOWN_HELPER", module="inline_discovered", business_scenario="LLM helper 任务拆解", input_contract=QA_INPUT, output_contract=JSON_LIST_OUTPUT, call_sites=("backend/app/services/llm_service/mixin_task_helpers.py",), prompt_family=PROMPT_FAMILY_PLANNING, **common), _entry("PROMPT_LLM_CONTEXT_INSIGHTS_HELPER", module="inline_discovered", business_scenario="LLM helper 上下文洞察", input_contract=QA_INPUT, output_contract=JSON_OUTPUT, call_sites=("backend/app/services/llm_service/mixin_task_helpers.py",), prompt_family=PROMPT_FAMILY_EXTRACTION, **common), _entry("PROMPT_LLM_STRUCTURED_JSON_REPAIR", module="inline_discovered", business_scenario="结构化 JSON 修复", input_contract="输入原始任务 prompt、schema hint 和模型输出。", output_contract=JSON_OUTPUT, call_sites=("backend/app/services/llm_service/mixin_generate_db_structured.py",), prompt_family=PROMPT_FAMILY_GOVERNANCE, risk_level="high", **{k: v for k, v in common.items() if k != "risk_level"}), _entry("PROMPT_LLM_ENGINE_CONNECTION_TEST", module="inline_discovered", business_scenario="供应商连接测试", input_contract="输入测试 prompt。", output_contract="默认只返回 OK。", call_sites=("backend/app/services/llm_service/mixin_engine_admin.py", "backend/app/core/startup/model_probe.py"), prompt_family=PROMPT_FAMILY_GOVERNANCE, risk_level="low", **{k: v for k, v in common.items() if k != "risk_level"}), _entry("PROMPT_SSTC_CHARTER_SEED_LOCALIZE_ZH", module="inline_discovered", business_scenario="SSTC charter seed 中文本地化", input_contract=JSON_INPUT, output_contract=JSON_OUTPUT, call_sites=("backend/app/services/sstc/charter_seed_utils.py",), prompt_family=PROMPT_FAMILY_EXTRACTION, **common), ) PROMPT_REGISTRY: tuple[dict[str, Any], ...] = ( *_part_01_entries(), *_part_02_entries(), *_part_03_entries(), *_part_04_entries(), *_scene_entries(), *_runtime_guardrail_entries(), *_semantic_fact_entries(), *_inline_discovered_entries(), ) PROMPT_REGISTRY_MAP: dict[str, dict[str, Any]] = { entry["prompt_key"]: entry for entry in PROMPT_REGISTRY } def get_prompt_registry() -> list[dict[str, Any]]: return [dict(entry) for entry in PROMPT_REGISTRY] def get_prompt_registry_entry(prompt_key: str) -> dict[str, Any] | None: key = str(prompt_key or "").strip() if not key: return None entry = PROMPT_REGISTRY_MAP.get(key) return dict(entry) if entry is not None else None def iter_prompt_registry_keys() -> tuple[str, ...]: return tuple(entry["prompt_key"] for entry in PROMPT_REGISTRY) __all__ = [ "PROMPT_CATALOG_EXPORTS", "PROMPT_REGISTRY", "PROMPT_REGISTRY_MAP", "get_prompt_registry", "get_prompt_registry_entry", "iter_prompt_registry_keys", ]