feihong-code 8.0.0 → 8.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/.github/workflows/ci.yml +193 -193
  2. package/CHANGELOG.md +140 -117
  3. package/README.md +656 -636
  4. package/agent-team/.env.example +13 -0
  5. package/agent-team/README.md +42 -0
  6. package/agent-team/agents/__init__.py +0 -0
  7. package/agent-team/agents/l1_acquisition.py +207 -0
  8. package/agent-team/agents/l2_content.py +237 -0
  9. package/agent-team/agents/l3_conversion.py +148 -0
  10. package/agent-team/agents/l4_analysis.py +118 -0
  11. package/agent-team/agents/l5_management.py +52 -0
  12. package/agent-team/agents/registry.py +60 -0
  13. package/agent-team/config.py +39 -0
  14. package/agent-team/core/__init__.py +0 -0
  15. package/agent-team/core/agent.py +73 -0
  16. package/agent-team/core/models.py +347 -0
  17. package/agent-team/core/scheduler.py +150 -0
  18. package/agent-team/core/task.py +121 -0
  19. package/agent-team/feihongzhi.db +0 -0
  20. package/agent-team/llm/__init__.py +12 -0
  21. package/agent-team/llm/base.py +22 -0
  22. package/agent-team/llm/doubao_llm.py +52 -0
  23. package/agent-team/llm/mock_llm.py +42 -0
  24. package/agent-team/main.py +235 -0
  25. package/agent-team/requirements.txt +2 -0
  26. package/agent-team/skill_packager.py +248 -0
  27. package/agent-team/skills/01_AI/350/216/267/345/256/242/347/272/277/347/264/242/351/233/267/350/276/276/SKILL.md +40 -0
  28. package/agent-team/skills/01_AI/350/216/267/345/256/242/347/272/277/347/264/242/351/233/267/350/276/276/run.py +111 -0
  29. package/agent-team/skills/02_AI/351/224/200/345/224/256/350/267/237/350/277/233/351/224/200/345/206/240/SKILL.md +38 -0
  30. package/agent-team/skills/02_AI/351/224/200/345/224/256/350/267/237/350/277/233/351/224/200/345/206/240/run.py +108 -0
  31. package/agent-team/skills/03_/350/257/204/350/256/272/345/214/272/345/225/206/346/234/272/350/257/206/345/210/253/345/256/230/SKILL.md +38 -0
  32. package/agent-team/skills/03_/350/257/204/350/256/272/345/214/272/345/225/206/346/234/272/350/257/206/345/210/253/345/256/230/run.py +106 -0
  33. package/agent-team/skills/04_/345/256/242/346/210/267/350/201/212/345/244/251/346/210/220/344/272/244/345/210/206/346/236/220/345/256/230/SKILL.md +37 -0
  34. package/agent-team/skills/04_/345/256/242/346/210/267/350/201/212/345/244/251/346/210/220/344/272/244/345/210/206/346/236/220/345/256/230/run.py +107 -0
  35. package/agent-team/skills/05_/345/220/214/350/241/214/347/210/206/346/254/276/351/233/267/350/276/276/SKILL.md +38 -0
  36. package/agent-team/skills/05_/345/220/214/350/241/214/347/210/206/346/254/276/351/233/267/350/276/276/run.py +99 -0
  37. package/agent-team/skills/06_/346/257/217/346/227/245/347/262/276/345/207/206/350/216/267/345/256/242/351/200/211/351/242/230/345/256/230/SKILL.md +39 -0
  38. package/agent-team/skills/06_/346/257/217/346/227/245/347/262/276/345/207/206/350/216/267/345/256/242/351/200/211/351/242/230/345/256/230/run.py +103 -0
  39. package/agent-team/skills/07_AI/345/244/226/350/264/270/345/274/200/345/217/221/345/256/242/346/210/267/345/221/230/345/267/245/SKILL.md +39 -0
  40. package/agent-team/skills/07_AI/345/244/226/350/264/270/345/274/200/345/217/221/345/256/242/346/210/267/345/221/230/345/267/245/run.py +103 -0
  41. package/agent-team/skills/08_/345/260/217/347/272/242/344/271/246/347/262/276/345/207/206/350/216/267/345/256/242/345/221/230/345/267/245/SKILL.md +40 -0
  42. package/agent-team/skills/08_/345/260/217/347/272/242/344/271/246/347/262/276/345/207/206/350/216/267/345/256/242/345/221/230/345/267/245/run.py +97 -0
  43. package/agent-team/skills/09_/347/247/201/345/237/237/345/256/242/346/210/267/345/210/206/345/261/202/350/267/237/350/277/233/345/256/230/SKILL.md +38 -0
  44. package/agent-team/skills/09_/347/247/201/345/237/237/345/256/242/346/210/267/345/210/206/345/261/202/350/267/237/350/277/233/345/256/230/run.py +106 -0
  45. package/agent-team/skills/10_GEO/345/225/206/346/234/272/350/257/212/346/226/255/345/256/230/SKILL.md +38 -0
  46. package/agent-team/skills/10_GEO/345/225/206/346/234/272/350/257/212/346/226/255/345/256/230/run.py +108 -0
  47. package/agent-team/skills/11_/344/270/200/344/272/272/345/205/254/345/217/270AI/345/221/230/345/267/245/350/260/203/345/272/246/345/256/230/SKILL.md +37 -0
  48. package/agent-team/skills/11_/344/270/200/344/272/272/345/205/254/345/217/270AI/345/221/230/345/267/245/350/260/203/345/272/246/345/256/230/run.py +111 -0
  49. package/agent-team/skills/12_/350/200/201/346/235/277/347/237/255/350/247/206/351/242/221/350/216/267/345/256/242/350/204/232/346/234/254/345/256/230/SKILL.md +39 -0
  50. package/agent-team/skills/12_/350/200/201/346/235/277/347/237/255/350/247/206/351/242/221/350/216/267/345/256/242/350/204/232/346/234/254/345/256/230/run.py +104 -0
  51. package/agent-team/skills/13_/345/215/232/344/270/273/350/264/246/345/217/267/346/267/261/345/272/246/346/213/206/350/247/243/345/256/230/SKILL.md +37 -0
  52. package/agent-team/skills/13_/345/215/232/344/270/273/350/264/246/345/217/267/346/267/261/345/272/246/346/213/206/350/247/243/345/256/230/run.py +105 -0
  53. package/agent-team/skills/14_AI/347/237/255/350/247/206/351/242/221/350/207/252/345/212/250/345/211/252/350/276/221/345/270/210/SKILL.md +39 -0
  54. package/agent-team/skills/14_AI/347/237/255/350/247/206/351/242/221/350/207/252/345/212/250/345/211/252/350/276/221/345/270/210/run.py +108 -0
  55. package/agent-team/skills/15_/345/205/254/344/274/227/345/217/267/350/207/252/345/212/250/350/277/220/350/220/245/345/217/221/345/270/203/345/256/230/SKILL.md +38 -0
  56. package/agent-team/skills/15_/345/205/254/344/274/227/345/217/267/350/207/252/345/212/250/350/277/220/350/220/245/345/217/221/345/270/203/345/256/230/run.py +105 -0
  57. package/agent-team/skills/16_/350/241/214/344/270/232/346/267/261/345/272/246/345/210/206/346/236/220/345/270/210/SKILL.md +38 -0
  58. package/agent-team/skills/16_/350/241/214/344/270/232/346/267/261/345/272/246/345/210/206/346/236/220/345/270/210/run.py +108 -0
  59. package/agent-team/skills/17_/346/212/225/350/265/204/347/240/224/347/251/266/345/222/250/350/257/242/345/256/230/SKILL.md +38 -0
  60. package/agent-team/skills/17_/346/212/225/350/265/204/347/240/224/347/251/266/345/222/250/350/257/242/345/256/230/run.py +106 -0
  61. package/agent-team/tests/__init__.py +0 -0
  62. package/agent-team/tests/test_core.py +156 -0
  63. package/dist/agent/agent-session.js +103 -0
  64. package/dist/agent/agent-session.js.map +1 -0
  65. package/dist/agent/orchestrator.js +8 -0
  66. package/dist/agent/orchestrator.js.map +1 -1
  67. package/dist/agent/steer.js +52 -0
  68. package/dist/agent/steer.js.map +1 -0
  69. package/dist/cli/index.js +1 -0
  70. package/dist/cli/index.js.map +1 -1
  71. package/dist/cli/node-guard.js +17 -0
  72. package/dist/cli/node-guard.js.map +1 -0
  73. package/dist/cli/run.js +2 -0
  74. package/dist/cli/run.js.map +1 -1
  75. package/dist/cli/version.js +1 -1
  76. package/dist/enterprise/policy.js +40 -17
  77. package/dist/enterprise/policy.js.map +1 -1
  78. package/dist/tools/agents/agents-bridge.js +144 -0
  79. package/dist/tools/agents/agents-bridge.js.map +1 -0
  80. package/dist/tools/desktop/desktop-guard.js +81 -0
  81. package/dist/tools/desktop/desktop-guard.js.map +1 -0
  82. package/dist/tools/desktop/desktop.tool.js +201 -0
  83. package/dist/tools/desktop/desktop.tool.js.map +1 -0
  84. package/dist/tools/desktop/feihong-win.js +163 -0
  85. package/dist/tools/desktop/feihong-win.js.map +1 -0
  86. package/dist/tools/desktop/index.js +37 -0
  87. package/dist/tools/desktop/index.js.map +1 -0
  88. package/dist/tools/index.js +2 -0
  89. package/dist/tools/index.js.map +1 -1
  90. package/dist/tools/mcp/index.js +10 -2
  91. package/dist/tools/mcp/index.js.map +1 -1
  92. package/dist/tools/mcp/mcp-client.js +4 -0
  93. package/dist/tools/mcp/mcp-client.js.map +1 -1
  94. package/dist/tools/sandbox.js +28 -0
  95. package/dist/tools/sandbox.js.map +1 -1
  96. package/dist/web/public/public/css/style.css +1756 -0
  97. package/dist/web/public/public/favicon.svg +11 -0
  98. package/dist/web/public/public/index.html +1246 -0
  99. package/dist/web/public/public/js/api.js +558 -0
  100. package/dist/web/public/public/js/app.js +2233 -0
  101. package/dist/web/public/public/js/mock-api.js +259 -0
  102. package/dist/web/public/public/js/monaco-editor.js +363 -0
  103. package/dist/web/public/public/js/ui.js +2217 -0
  104. package/dist/web/public/public/js/utils.js +214 -0
  105. package/dist/web/public/public/manifest.json +59 -0
  106. package/dist/web/public/public/robots.txt +14 -0
  107. package/dist/web/public/public/service-worker.js +149 -0
  108. package/docs/AI/345/221/230/345/267/245/345/206/233/345/233/242-/346/225/264/345/220/210/350/257/264/346/230/216.md +68 -0
  109. package/docs/API.md +1 -1
  110. package/docs/App/346/212/200/346/234/257/350/257/264/346/230/216/344/271/246.md +3 -3
  111. package/docs/P1.1-P3-P5/345/267/245/347/250/213/345/256/236/346/226/275/346/200/273/347/273/223.md +328 -0
  112. package/docs/P5-Pi/345/257/271/347/205/247/350/257/204/346/265/213/346/212/245/345/221/212-mock/346/250/241/345/274/217.json +125 -0
  113. package/docs/P5-Pi/345/257/271/347/205/247/350/257/204/346/265/213/346/212/245/345/221/212-/347/234/237/345/256/236/346/250/241/345/236/213.json +138 -0
  114. package/docs/P5-pi-compare-real-report.json +138 -0
  115. package/docs/P5-pi-compare-report.json +125 -0
  116. package/docs/Pi-Agent/346/216/245/345/205/245/351/243/236/350/231/271Code-MVP/351/233/206/346/210/220/344/272/244/344/273/230/347/211/251.md +355 -0
  117. package/docs/Pi-Agent/346/216/245/345/205/245/351/243/236/350/231/271Code/344/273/267/345/200/274/345/210/206/346/236/220-/345/274/200/345/217/221/346/226/207/346/241/243.md +291 -0
  118. package/docs/Pi-Agent/346/216/245/345/205/245/351/243/236/350/231/271Code/344/273/267/345/200/274/351/207/215/344/274/260-/345/217/257/350/247/206/345/214/226.html +84 -0
  119. package/docs/SWE-bench-300-agnes-2.5-flash-/346/234/200/347/273/210/346/212/245/345/221/212.json +2012 -0
  120. package/docs/SWE-bench-300-agnes-2.5-flash-/350/267/221/345/210/206/346/212/245/345/221/212.md +74 -0
  121. package/docs/SWE-bench-Lite-DeepSeek-V4-Flash-/350/267/221/345/210/206/346/212/245/345/221/212.md +102 -0
  122. package/docs/TECHNICAL-SPECIFICATION.md +66 -0
  123. package/docs/TECHNICAL-SPECIFICATION.pdf +0 -0
  124. package/docs/Windows/346/211/213/350/204/232-POC/346/274/224/347/244/272/350/204/232/346/234/254.md +131 -0
  125. package/docs/Windows/346/211/213/350/204/232/346/216/245/345/205/245/346/214/207/345/215/227.md +181 -0
  126. package/docs//344/275/277/347/224/250/350/257/264/346/230/216/344/271/246-v8.0.1.md +146 -0
  127. package/docs//344/275/277/347/224/250/350/257/264/346/230/216/344/271/246.md +1 -1
  128. package/package.json +6 -3
@@ -0,0 +1,108 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ """AI短视频自动剪辑师(14)独立运行器。
4
+
5
+ 由 feihongzhi_agents 导出:自包含、仅标准库,可被其他智能体直接调用或安装为 Skill。
6
+ 用法:
7
+ python3 run.py --input '{"field": "value"}'
8
+ echo '{"field": "value"}' | python3 run.py
9
+ 可选接入真实大模型(设置环境变量后加 --llm):
10
+ LLM_API_KEY=xxx LLM_MODEL=xxx LLM_BASE_URL=https://ark.cn-beijing.volces.com/api/v3
11
+ python3 run.py --llm --input '...'
12
+ """
13
+ import argparse
14
+ import json
15
+ import sys
16
+ import time
17
+ import urllib.request
18
+ import urllib.error
19
+ from datetime import datetime
20
+
21
+ # ------------------------- 内嵌核心逻辑(自动生成) -------------------------
22
+ def _ts() -> str:
23
+ return datetime.now().strftime("%Y-%m-%d %H:%M:%S")
24
+
25
+
26
+ def run_logic_14(data, llm=None):
27
+ """AI 短视频自动剪辑:素材自动剪辑成片。"""
28
+ clips = data.get("clips") or ["clip_a.mp4", "clip_b.mp4", "clip_c.mp4"]
29
+ script = data.get("script", "")
30
+ template = data.get("template", "口播标准模板")
31
+ video = {
32
+ "asset_id": f"V{int(time.time()) % 100000000}",
33
+ "clips_used": clips,
34
+ "template": template,
35
+ "duration_sec": 45,
36
+ "subtitles": "auto(准确率≥95%)",
37
+ "status": "rendered",
38
+ "rendered_at": _ts(),
39
+ }
40
+ ai_note = ""
41
+ if llm is not None and getattr(llm, "provider", "mock") != "mock":
42
+ try:
43
+ ai_note = llm.complete(
44
+ f"脚本要点:{script[:100]},给出剪辑节奏建议,不超过 50 字。",
45
+ system="你是视频剪辑师。")
46
+ except Exception:
47
+ ai_note = ""
48
+ return {"video": video, "ai_note": ai_note}
49
+
50
+ # ------------------------- 极简 LLM 客户端(可选) -------------------------
51
+ class _MiniLLM:
52
+ provider = "doubao"
53
+ def __init__(self):
54
+ import os
55
+ self.key = os.environ.get("LLM_API_KEY", "")
56
+ self.model = os.environ.get("LLM_MODEL", "")
57
+ self.base = os.environ.get("LLM_BASE_URL", "https://ark.cn-beijing.volces.com/api/v3").rstrip("/")
58
+ if not self.key or not self.model:
59
+ raise RuntimeError("缺少 LLM_API_KEY / LLM_MODEL 环境变量")
60
+ def complete(self, prompt, system=""):
61
+ msgs = []
62
+ if system:
63
+ msgs.append({"role": "system", "content": system})
64
+ msgs.append({"role": "user", "content": prompt})
65
+ payload = {"model": self.model, "messages": msgs, "temperature": 0.7, "max_tokens": 1024}
66
+ req = urllib.request.Request(
67
+ self.base + "/chat/completions",
68
+ data=json.dumps(payload).encode("utf-8"),
69
+ headers={"Content-Type": "application/json", "Authorization": "Bearer " + self.key},
70
+ method="POST")
71
+ try:
72
+ with urllib.request.urlopen(req, timeout=60) as resp:
73
+ body = json.loads(resp.read().decode("utf-8"))
74
+ except urllib.error.HTTPError as e:
75
+ raise RuntimeError("LLM 调用失败 HTTP %s: %s" % (e.code, e.read().decode("utf-8", errors="ignore")[:200]))
76
+ return body["choices"][0]["message"]["content"].strip()
77
+
78
+ def _load_input(args):
79
+ if args.input:
80
+ return json.loads(args.input)
81
+ if not sys.stdin.isatty():
82
+ raw = sys.stdin.read()
83
+ if raw.strip():
84
+ return json.loads(raw)
85
+ return {}
86
+
87
+ def main():
88
+ ap = argparse.ArgumentParser(description="AI短视频自动剪辑师(14)")
89
+ ap.add_argument("--input", help="JSON 输入,如 '{\"topic\": \"AI获客\"}';或经 stdin 传入")
90
+ ap.add_argument("--llm", action="store_true", help="启用真实大模型(需 LLM_API_KEY/LLM_MODEL 环境变量)")
91
+ args = ap.parse_args()
92
+ data = _load_input(args)
93
+ llm = None
94
+ if args.llm:
95
+ try:
96
+ llm = _MiniLLM()
97
+ except Exception as e:
98
+ print(json.dumps({"ok": False, "error": "LLM 初始化失败: " + str(e)}, ensure_ascii=False))
99
+ sys.exit(1)
100
+ try:
101
+ out = run_logic_14(data, llm)
102
+ except Exception as e:
103
+ print(json.dumps({"ok": False, "error": str(e)}, ensure_ascii=False))
104
+ sys.exit(1)
105
+ print(json.dumps({"ok": True, "output": out}, ensure_ascii=False))
106
+
107
+ if __name__ == "__main__":
108
+ main()
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: 15_公众号自动运营发布官
3
+ description: 公众号内容生成、排期与定时发布。属于L2层,优先级P1。触发场景:用户需要公众号自动运营发布官、或涉及topic、schedule相关任务时调用。输出:article。
4
+ ---
5
+
6
+ # 15_公众号自动运营发布官(15)
7
+
8
+ 公众号内容生成、排期与定时发布
9
+
10
+ - **所属层级**:L2(优先级 P1)
11
+
12
+ ## 使用方式
13
+
14
+ ```bash
15
+ # 方式一:命令行参数
16
+ python3 run.py --input '{"topic": "示例输入"}'
17
+
18
+ # 方式二:标准输入
19
+ echo '{"topic": "示例输入"}' | python3 run.py
20
+
21
+ # 接入真实大模型(可选)
22
+ LLM_API_KEY=xxx LLM_MODEL=xxx python3 run.py --llm --input '{"topic": "示例输入"}'
23
+ ```
24
+
25
+ ## 输入字段
26
+
27
+ | 字段 | 说明 |
28
+ |---|---|
29
+ | topic | 选题 |
30
+ | schedule | 发布时间 |
31
+
32
+ ## 输出字段
33
+
34
+ - **article**:文章与排期
35
+
36
+ ## 安装为 Skill
37
+
38
+ 将本目录(含 SKILL.md 与 run.py)复制到目标 Skill 根目录即可被智能体发现调用。
@@ -0,0 +1,105 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ """公众号自动运营发布官(15)独立运行器。
4
+
5
+ 由 feihongzhi_agents 导出:自包含、仅标准库,可被其他智能体直接调用或安装为 Skill。
6
+ 用法:
7
+ python3 run.py --input '{"field": "value"}'
8
+ echo '{"field": "value"}' | python3 run.py
9
+ 可选接入真实大模型(设置环境变量后加 --llm):
10
+ LLM_API_KEY=xxx LLM_MODEL=xxx LLM_BASE_URL=https://ark.cn-beijing.volces.com/api/v3
11
+ python3 run.py --llm --input '...'
12
+ """
13
+ import argparse
14
+ import json
15
+ import sys
16
+ import time
17
+ import urllib.request
18
+ import urllib.error
19
+ from datetime import datetime
20
+
21
+ # ------------------------- 内嵌核心逻辑(自动生成) -------------------------
22
+ def _ts() -> str:
23
+ return datetime.now().strftime("%Y-%m-%d %H:%M:%S")
24
+
25
+
26
+ def run_logic_15(data, llm=None):
27
+ """公众号自动运营:内容生成与定时发布。"""
28
+ topic = data.get("topic", "AI 获客")
29
+ schedule = data.get("schedule", "明日 08:00")
30
+ article = {
31
+ "title": f"深度:{topic}的完整打法(建议收藏)",
32
+ "body": f"一、为什么{topic}是当下最大的红利;二、三步落地方案;三、真实数据复盘。",
33
+ "publish_time": schedule,
34
+ "status": "scheduled",
35
+ "created_at": _ts(),
36
+ }
37
+ ai_note = ""
38
+ if llm is not None and getattr(llm, "provider", "mock") != "mock":
39
+ try:
40
+ ai_note = llm.complete(
41
+ f"公众号选题 {topic},给 1 个标题备选,不超过 40 字。",
42
+ system="你是公众号主编。")
43
+ except Exception:
44
+ ai_note = ""
45
+ return {"article": article, "ai_note": ai_note}
46
+
47
+ # ------------------------- 极简 LLM 客户端(可选) -------------------------
48
+ class _MiniLLM:
49
+ provider = "doubao"
50
+ def __init__(self):
51
+ import os
52
+ self.key = os.environ.get("LLM_API_KEY", "")
53
+ self.model = os.environ.get("LLM_MODEL", "")
54
+ self.base = os.environ.get("LLM_BASE_URL", "https://ark.cn-beijing.volces.com/api/v3").rstrip("/")
55
+ if not self.key or not self.model:
56
+ raise RuntimeError("缺少 LLM_API_KEY / LLM_MODEL 环境变量")
57
+ def complete(self, prompt, system=""):
58
+ msgs = []
59
+ if system:
60
+ msgs.append({"role": "system", "content": system})
61
+ msgs.append({"role": "user", "content": prompt})
62
+ payload = {"model": self.model, "messages": msgs, "temperature": 0.7, "max_tokens": 1024}
63
+ req = urllib.request.Request(
64
+ self.base + "/chat/completions",
65
+ data=json.dumps(payload).encode("utf-8"),
66
+ headers={"Content-Type": "application/json", "Authorization": "Bearer " + self.key},
67
+ method="POST")
68
+ try:
69
+ with urllib.request.urlopen(req, timeout=60) as resp:
70
+ body = json.loads(resp.read().decode("utf-8"))
71
+ except urllib.error.HTTPError as e:
72
+ raise RuntimeError("LLM 调用失败 HTTP %s: %s" % (e.code, e.read().decode("utf-8", errors="ignore")[:200]))
73
+ return body["choices"][0]["message"]["content"].strip()
74
+
75
+ def _load_input(args):
76
+ if args.input:
77
+ return json.loads(args.input)
78
+ if not sys.stdin.isatty():
79
+ raw = sys.stdin.read()
80
+ if raw.strip():
81
+ return json.loads(raw)
82
+ return {}
83
+
84
+ def main():
85
+ ap = argparse.ArgumentParser(description="公众号自动运营发布官(15)")
86
+ ap.add_argument("--input", help="JSON 输入,如 '{\"topic\": \"AI获客\"}';或经 stdin 传入")
87
+ ap.add_argument("--llm", action="store_true", help="启用真实大模型(需 LLM_API_KEY/LLM_MODEL 环境变量)")
88
+ args = ap.parse_args()
89
+ data = _load_input(args)
90
+ llm = None
91
+ if args.llm:
92
+ try:
93
+ llm = _MiniLLM()
94
+ except Exception as e:
95
+ print(json.dumps({"ok": False, "error": "LLM 初始化失败: " + str(e)}, ensure_ascii=False))
96
+ sys.exit(1)
97
+ try:
98
+ out = run_logic_15(data, llm)
99
+ except Exception as e:
100
+ print(json.dumps({"ok": False, "error": str(e)}, ensure_ascii=False))
101
+ sys.exit(1)
102
+ print(json.dumps({"ok": True, "output": out}, ensure_ascii=False))
103
+
104
+ if __name__ == "__main__":
105
+ main()
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: 16_行业深度分析师
3
+ description: 输出行业趋势与竞争格局分析。属于L4层,优先级P3。触发场景:用户需要行业深度分析师、或涉及industry、scope相关任务时调用。输出:report。
4
+ ---
5
+
6
+ # 16_行业深度分析师(16)
7
+
8
+ 输出行业趋势与竞争格局分析
9
+
10
+ - **所属层级**:L4(优先级 P3)
11
+
12
+ ## 使用方式
13
+
14
+ ```bash
15
+ # 方式一:命令行参数
16
+ python3 run.py --input '{"industry": "示例输入"}'
17
+
18
+ # 方式二:标准输入
19
+ echo '{"industry": "示例输入"}' | python3 run.py
20
+
21
+ # 接入真实大模型(可选)
22
+ LLM_API_KEY=xxx LLM_MODEL=xxx python3 run.py --llm --input '{"industry": "示例输入"}'
23
+ ```
24
+
25
+ ## 输入字段
26
+
27
+ | 字段 | 说明 |
28
+ |---|---|
29
+ | industry | 行业 |
30
+ | scope | 范围 |
31
+
32
+ ## 输出字段
33
+
34
+ - **report**:行业分析报告
35
+
36
+ ## 安装为 Skill
37
+
38
+ 将本目录(含 SKILL.md 与 run.py)复制到目标 Skill 根目录即可被智能体发现调用。
@@ -0,0 +1,108 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ """行业深度分析师(16)独立运行器。
4
+
5
+ 由 feihongzhi_agents 导出:自包含、仅标准库,可被其他智能体直接调用或安装为 Skill。
6
+ 用法:
7
+ python3 run.py --input '{"field": "value"}'
8
+ echo '{"field": "value"}' | python3 run.py
9
+ 可选接入真实大模型(设置环境变量后加 --llm):
10
+ LLM_API_KEY=xxx LLM_MODEL=xxx LLM_BASE_URL=https://ark.cn-beijing.volces.com/api/v3
11
+ python3 run.py --llm --input '...'
12
+ """
13
+ import argparse
14
+ import json
15
+ import sys
16
+ import time
17
+ import urllib.request
18
+ import urllib.error
19
+ from datetime import datetime
20
+
21
+ # ------------------------- 内嵌核心逻辑(自动生成) -------------------------
22
+ def _ts() -> str:
23
+ return datetime.now().strftime("%Y-%m-%d %H:%M:%S")
24
+
25
+
26
+ def run_logic_16(data, llm=None):
27
+ """行业深度分析:输出行业趋势与竞争格局。"""
28
+ industry = data.get("industry", "企业服务")
29
+ scope = data.get("scope", "国内")
30
+ report = {
31
+ "industry": industry,
32
+ "scope": scope,
33
+ "market_size": "示例口径:120 亿元(需以权威数据源校准)",
34
+ "growth": "年增速约 18%",
35
+ "competition": "格局分散,头部集中度提升中",
36
+ "conclusion": "进入窗口期,建议聚焦细分场景建立壁垒",
37
+ "data_note": "本报告为分析框架示意,关键数据需接入权威数据源后校准",
38
+ "generated_at": _ts(),
39
+ }
40
+ ai_note = ""
41
+ if llm is not None and getattr(llm, "provider", "mock") != "mock":
42
+ try:
43
+ ai_note = llm.complete(
44
+ f"行业 {industry}、范围 {scope},给 1 条最关键的竞争判断,不超过 60 字。",
45
+ system="你是行业研究首席分析师。")
46
+ except Exception:
47
+ ai_note = ""
48
+ return {"report": report, "ai_note": ai_note}
49
+
50
+ # ------------------------- 极简 LLM 客户端(可选) -------------------------
51
+ class _MiniLLM:
52
+ provider = "doubao"
53
+ def __init__(self):
54
+ import os
55
+ self.key = os.environ.get("LLM_API_KEY", "")
56
+ self.model = os.environ.get("LLM_MODEL", "")
57
+ self.base = os.environ.get("LLM_BASE_URL", "https://ark.cn-beijing.volces.com/api/v3").rstrip("/")
58
+ if not self.key or not self.model:
59
+ raise RuntimeError("缺少 LLM_API_KEY / LLM_MODEL 环境变量")
60
+ def complete(self, prompt, system=""):
61
+ msgs = []
62
+ if system:
63
+ msgs.append({"role": "system", "content": system})
64
+ msgs.append({"role": "user", "content": prompt})
65
+ payload = {"model": self.model, "messages": msgs, "temperature": 0.7, "max_tokens": 1024}
66
+ req = urllib.request.Request(
67
+ self.base + "/chat/completions",
68
+ data=json.dumps(payload).encode("utf-8"),
69
+ headers={"Content-Type": "application/json", "Authorization": "Bearer " + self.key},
70
+ method="POST")
71
+ try:
72
+ with urllib.request.urlopen(req, timeout=60) as resp:
73
+ body = json.loads(resp.read().decode("utf-8"))
74
+ except urllib.error.HTTPError as e:
75
+ raise RuntimeError("LLM 调用失败 HTTP %s: %s" % (e.code, e.read().decode("utf-8", errors="ignore")[:200]))
76
+ return body["choices"][0]["message"]["content"].strip()
77
+
78
+ def _load_input(args):
79
+ if args.input:
80
+ return json.loads(args.input)
81
+ if not sys.stdin.isatty():
82
+ raw = sys.stdin.read()
83
+ if raw.strip():
84
+ return json.loads(raw)
85
+ return {}
86
+
87
+ def main():
88
+ ap = argparse.ArgumentParser(description="行业深度分析师(16)")
89
+ ap.add_argument("--input", help="JSON 输入,如 '{\"topic\": \"AI获客\"}';或经 stdin 传入")
90
+ ap.add_argument("--llm", action="store_true", help="启用真实大模型(需 LLM_API_KEY/LLM_MODEL 环境变量)")
91
+ args = ap.parse_args()
92
+ data = _load_input(args)
93
+ llm = None
94
+ if args.llm:
95
+ try:
96
+ llm = _MiniLLM()
97
+ except Exception as e:
98
+ print(json.dumps({"ok": False, "error": "LLM 初始化失败: " + str(e)}, ensure_ascii=False))
99
+ sys.exit(1)
100
+ try:
101
+ out = run_logic_16(data, llm)
102
+ except Exception as e:
103
+ print(json.dumps({"ok": False, "error": str(e)}, ensure_ascii=False))
104
+ sys.exit(1)
105
+ print(json.dumps({"ok": True, "output": out}, ensure_ascii=False))
106
+
107
+ if __name__ == "__main__":
108
+ main()
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: 17_投资研究咨询官
3
+ description: 项目 / 投资研究与尽调辅助。属于L4层,优先级P3。触发场景:用户需要投资研究咨询官、或涉及company、materials相关任务时调用。输出:report。
4
+ ---
5
+
6
+ # 17_投资研究咨询官(17)
7
+
8
+ 项目 / 投资研究与尽调辅助
9
+
10
+ - **所属层级**:L4(优先级 P3)
11
+
12
+ ## 使用方式
13
+
14
+ ```bash
15
+ # 方式一:命令行参数
16
+ python3 run.py --input '{"company": "示例输入"}'
17
+
18
+ # 方式二:标准输入
19
+ echo '{"company": "示例输入"}' | python3 run.py
20
+
21
+ # 接入真实大模型(可选)
22
+ LLM_API_KEY=xxx LLM_MODEL=xxx python3 run.py --llm --input '{"company": "示例输入"}'
23
+ ```
24
+
25
+ ## 输入字段
26
+
27
+ | 字段 | 说明 |
28
+ |---|---|
29
+ | company | 项目/公司 |
30
+ | materials | 材料摘要 |
31
+
32
+ ## 输出字段
33
+
34
+ - **report**:投研报告
35
+
36
+ ## 安装为 Skill
37
+
38
+ 将本目录(含 SKILL.md 与 run.py)复制到目标 Skill 根目录即可被智能体发现调用。
@@ -0,0 +1,106 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ """投资研究咨询官(17)独立运行器。
4
+
5
+ 由 feihongzhi_agents 导出:自包含、仅标准库,可被其他智能体直接调用或安装为 Skill。
6
+ 用法:
7
+ python3 run.py --input '{"field": "value"}'
8
+ echo '{"field": "value"}' | python3 run.py
9
+ 可选接入真实大模型(设置环境变量后加 --llm):
10
+ LLM_API_KEY=xxx LLM_MODEL=xxx LLM_BASE_URL=https://ark.cn-beijing.volces.com/api/v3
11
+ python3 run.py --llm --input '...'
12
+ """
13
+ import argparse
14
+ import json
15
+ import sys
16
+ import time
17
+ import urllib.request
18
+ import urllib.error
19
+ from datetime import datetime
20
+
21
+ # ------------------------- 内嵌核心逻辑(自动生成) -------------------------
22
+ def _ts() -> str:
23
+ return datetime.now().strftime("%Y-%m-%d %H:%M:%S")
24
+
25
+
26
+ def run_logic_17(data, llm=None):
27
+ """投资研究:项目 / 投资研究与尽调辅助。"""
28
+ company = data.get("company", "示例项目")
29
+ materials = data.get("materials", "BP 摘要")
30
+ report = {
31
+ "company": company,
32
+ "business_model": "B2B 订阅 + 增值服务",
33
+ "risks": ["获客成本偏高", "复购率待验证"],
34
+ "valuation_notes": "建议以 DCF + 可比公司交叉验证(需财务数据支撑)",
35
+ "conclusion": "方向成立,需补充现金流与复购数据后再决策",
36
+ "generated_at": _ts(),
37
+ }
38
+ ai_note = ""
39
+ if llm is not None and getattr(llm, "provider", "mock") != "mock":
40
+ try:
41
+ ai_note = llm.complete(
42
+ f"项目 {company}、材料 {materials[:100]},提示最需要核实的一个风险点,不超过 50 字。",
43
+ system="你是投资研究顾问。")
44
+ except Exception:
45
+ ai_note = ""
46
+ return {"report": report, "ai_note": ai_note}
47
+
48
+ # ------------------------- 极简 LLM 客户端(可选) -------------------------
49
+ class _MiniLLM:
50
+ provider = "doubao"
51
+ def __init__(self):
52
+ import os
53
+ self.key = os.environ.get("LLM_API_KEY", "")
54
+ self.model = os.environ.get("LLM_MODEL", "")
55
+ self.base = os.environ.get("LLM_BASE_URL", "https://ark.cn-beijing.volces.com/api/v3").rstrip("/")
56
+ if not self.key or not self.model:
57
+ raise RuntimeError("缺少 LLM_API_KEY / LLM_MODEL 环境变量")
58
+ def complete(self, prompt, system=""):
59
+ msgs = []
60
+ if system:
61
+ msgs.append({"role": "system", "content": system})
62
+ msgs.append({"role": "user", "content": prompt})
63
+ payload = {"model": self.model, "messages": msgs, "temperature": 0.7, "max_tokens": 1024}
64
+ req = urllib.request.Request(
65
+ self.base + "/chat/completions",
66
+ data=json.dumps(payload).encode("utf-8"),
67
+ headers={"Content-Type": "application/json", "Authorization": "Bearer " + self.key},
68
+ method="POST")
69
+ try:
70
+ with urllib.request.urlopen(req, timeout=60) as resp:
71
+ body = json.loads(resp.read().decode("utf-8"))
72
+ except urllib.error.HTTPError as e:
73
+ raise RuntimeError("LLM 调用失败 HTTP %s: %s" % (e.code, e.read().decode("utf-8", errors="ignore")[:200]))
74
+ return body["choices"][0]["message"]["content"].strip()
75
+
76
+ def _load_input(args):
77
+ if args.input:
78
+ return json.loads(args.input)
79
+ if not sys.stdin.isatty():
80
+ raw = sys.stdin.read()
81
+ if raw.strip():
82
+ return json.loads(raw)
83
+ return {}
84
+
85
+ def main():
86
+ ap = argparse.ArgumentParser(description="投资研究咨询官(17)")
87
+ ap.add_argument("--input", help="JSON 输入,如 '{\"topic\": \"AI获客\"}';或经 stdin 传入")
88
+ ap.add_argument("--llm", action="store_true", help="启用真实大模型(需 LLM_API_KEY/LLM_MODEL 环境变量)")
89
+ args = ap.parse_args()
90
+ data = _load_input(args)
91
+ llm = None
92
+ if args.llm:
93
+ try:
94
+ llm = _MiniLLM()
95
+ except Exception as e:
96
+ print(json.dumps({"ok": False, "error": "LLM 初始化失败: " + str(e)}, ensure_ascii=False))
97
+ sys.exit(1)
98
+ try:
99
+ out = run_logic_17(data, llm)
100
+ except Exception as e:
101
+ print(json.dumps({"ok": False, "error": str(e)}, ensure_ascii=False))
102
+ sys.exit(1)
103
+ print(json.dumps({"ok": True, "output": out}, ensure_ascii=False))
104
+
105
+ if __name__ == "__main__":
106
+ main()
File without changes