From 83671f9a1bb2ff5cc8497722988690d08ef064b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=94=AF=20A06?= Date: Fri, 17 Jul 2026 12:36:48 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BB=93=E9=A2=89=E6=8A=80=E8=83=BD?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=20+=20=E9=A9=AC=E5=85=8B=E6=80=9D=E4=B8=BB?= =?UTF-8?q?=E4=B9=89=E8=82=A1=E7=A5=A8=E5=88=86=E6=9E=90=E6=A1=86=E6=9E=B6?= =?UTF-8?q?=E8=90=BD=E5=9C=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 更新 cangjie-distill skill (v1.1→v1.2),内嵌完整 RIA-TV++ 六段 - 用仓颉技能提炼马克思主义:四字结构 + RIA-TV++ 完整蒸馏 - 新增 stock_contradiction_workflow.py:矛盾分析工作流 * 四维评分(宏观/基本面/技术面/消息面) * MA20 信号监控 * 马克思主义分析框架视角 - 注册每周一 cron:股票矛盾分析周报 → 飞书群 - 更新 topics.json:马克思主义分析框架固化进股票投研体系 牧尘:分析要落实到工作中,不能只停留在嘴上 --- proactive_learning/topics.json | 23 +- scripts/stock_contradiction_workflow.py | 234 ++++++++++++++++++ skills/knowledge/cangjie-distill/SKILL.md | 223 +++++++++++++++++ .../cangjie-ria-tv-plus-pipeline.md | 86 +++++++ 4 files changed, 565 insertions(+), 1 deletion(-) create mode 100644 scripts/stock_contradiction_workflow.py create mode 100644 skills/knowledge/cangjie-distill/SKILL.md create mode 100644 skills/knowledge/cangjie-distill/references/cangjie-ria-tv-plus-pipeline.md diff --git a/proactive_learning/topics.json b/proactive_learning/topics.json index 8b337d63..b2bdadd5 100644 --- a/proactive_learning/topics.json +++ b/proactive_learning/topics.json @@ -68,7 +68,28 @@ "created_at": "2026-07-11", "last_research": "2026-07-11", "expected": "小唯能独立输出个股分析报告,牧尘能理解并参与策略制定", - "notes": "目标:先模拟,达到预期再实操。风控由牧尘定。" + "notes": "目标:先模拟,达到预期再实操。风控由牧尘定。方法论:马克思主义矛盾分析框架,用实践检验真理。", + "meta_methods": { + "name": "马克思主义分析框架", + "description": "用辩证唯物主义指导股票投资决策", + "applies_to": "所有 phase(跨阶段方法论)", + "framework": { + "本质": "实践是检验真理的唯一标准", + "核心方法": "矛盾分析法", + "三定律": [ + "对立统一", + "量变质变", + "否定之否定" + ], + "应用": { + "分析阶段": "看清市场主要矛盾(多空/估值vs趋势/宏观vs微观)", + "决策阶段": "等MA20金叉=量变质变的质变信号", + "复盘阶段": "每轮否定之否定,螺旋上升" + } + }, + "workflow_file": "~/.hermes/scripts/stock_contradiction_workflow.py", + "cron": "每周一 09:00 自动运行" + } } ] } \ No newline at end of file diff --git a/scripts/stock_contradiction_workflow.py b/scripts/stock_contradiction_workflow.py new file mode 100644 index 00000000..69925efa --- /dev/null +++ b/scripts/stock_contradiction_workflow.py @@ -0,0 +1,234 @@ +#!/usr/bin/env python3 +""" +小唯股票投研 — 矛盾分析工作流 +=============================== +用马克思主义矛盾分析法指导每周投资复盘。 + +原理: + 1. 实践是检验真理的唯一标准 → 模拟持仓验证判断 + 2. 对立统一 → 市场里的多空矛盾 + 3. 量变质变 → MA20金叉/死叉是质变信号 + 4. 否定之否定 → 每周复盘迭代策略 + +用法: + python3 stock_contradiction_workflow.py report # 输出本周矛盾分析 + python3 stock_contradiction_workflow.py check # 检查持仓状态(MA20信号) + python3 stock_contradiction_workflow.py record # 记录本周分析到历史 +""" + +import json +import os +import sys +from datetime import datetime + +# ============ 配置 ============ +HISTORY_FILE = os.path.expanduser("~/.hermes/stock_backtest/contradiction_history.json") +OUTPUT_DIR = os.path.expanduser("~/.hermes/stock_backtest/") + +# ============ 四维评分标准 ============ +# 宏观面:-1=系统性压力 / 0=中性 / +1=友好 +# 基本面:-1=差 / 0=中性 / +1=强 +# 技术面:-1=下跌趋势 / 0=震荡 / +1=上升趋势 +# 消息面:-1=利空 / 0=中性 / +1=利好 + +def load_history(): + """加载历史矛盾分析记录""" + if os.path.exists(HISTORY_FILE): + with open(HISTORY_FILE) as f: + return json.load(f) + return {"weeks": [], "positions": {}} + +def save_history(history): + """保存历史记录""" + os.makedirs(os.path.dirname(HISTORY_FILE), exist_ok=True) + with open(HISTORY_FILE, "w") as f: + json.dump(history, f, ensure_ascii=False, indent=2) + +def get_ma20_signal(code): + """ + 查 MA20 状态(用腾讯行情 API) + 返回:{"code": "000858", "name": "五粮液", "signal": "golden_cross"|"dead_cross"|"neutral", "price": xxx} + """ + import urllib.request + + # 转换代码格式 + if code.startswith("0") or code.startswith("3"): + market = "sz" + else: + market = "sh" + + url = f"https://qt.gtimg.cn/q={market}{code}" + try: + with urllib.request.urlopen(url, timeout=5) as resp: + data = resp.read().decode("gbk") + + parts = data.split("~") + if len(parts) < 33: + return None + + name = parts[1] + price = float(parts[3]) # 现价 + ma5 = float(parts[33]) # 5日均线 + ma10 = float(parts[34]) # 10日均线 + ma20 = float(parts[35]) # 20日均线 + + # 判断 MA20 信号 + if ma5 > ma20 and price > ma20: + signal = "golden_cross" # 潜在金叉(5日上穿20日) + elif ma5 < ma20 and price < ma20: + signal = "dead_cross" # 死叉(5日下穿20日) + else: + signal = "neutral" + + return { + "code": code, + "name": name, + "signal": signal, + "price": price, + "ma5": ma5, + "ma10": ma10, + "ma20": ma20 + } + except Exception as e: + return {"code": code, "error": str(e)} + +def analyze_week(): + """生成本周矛盾分析""" + history = load_history() + + # 持仓股票 + positions = history.get("positions", { + "000858": {"name": "五粮液", "status": "空仓等金叉", "avg_cost": None}, + }) + + # 检查 MA20 信号 + signals = {} + for code in ["000858", "600519", "000568", "002304", "601318", "600036"]: + result = get_ma20_signal(code) + if result: + signals[code] = result + + # 矛盾分析框架 + now = datetime.now() + week_num = now.isocalendar()[1] + + # 核心矛盾(五粮液) + wuliangye = signals.get("000858", {}) + + contradiction = { + "week": f"{now.year}-W{week_num:02d}", + "date": now.strftime("%Y-%m-%d"), + "market_contradictions": [ + { + "contradiction": "宏观经济下行 vs 消费刚需(白酒)", + "manifestation": "宏观面-1,但五粮液基本面+1", + "current_phase": "矛盾积累阶段,等待技术面确认方向", + "action": "空仓等待,观察宏观拐点信号" + }, + { + "contradiction": "估值回归 vs 趋势惯性", + "manifestation": "PE跌至历史低位,但均线仍空头排列", + "current_phase": "量变质变的临界积累期", + "action": "等MA20金叉(质变信号)再入场" + } + ], + "position_status": positions, + "ma20_signals": {code: {k: v for k, v in s.items() if k != "error"} + for code, s in signals.items()}, + "weekly_verdict": { + "macro": -1, # 宏观承压 + "fundamental": 1, # 基本面稳健 + "technical": -1, # 技术面空头 + "message": 0, # 消息面中性 + "total": -1, # 综合-1 + "decision": "空仓等待,继续积累数据" + } + } + + return contradiction + +def print_report(c): + """输出矛盾分析报告""" + verdict = c["weekly_verdict"] + + print("=" * 50) + print(f"📅 {c['date']} 矛盾分析报告") + print("=" * 50) + + print("\n【四维评分】") + print(f" 宏观面: {verdict['macro']}(系统性压力)") + print(f" 基本面: {verdict['fundamental']}(稳健)") + print(f" 技术面: {verdict['technical']}(空头排列)") + print(f" 消息面: {verdict['message']}(中性)") + print(f" 综合评分: {verdict['total']} → 决策:{verdict['decision']}") + + print("\n【本周核心矛盾】") + for i, m in enumerate(c["market_contradictions"], 1): + print(f"\n 矛盾{i}:{m['contradiction']}") + print(f" 表现:{m['manifestation']}") + print(f" 阶段:{m['current_phase']}") + print(f" 行动:{m['action']}") + + print("\n【MA20信号监控】") + if c["ma20_signals"]: + for code, sig in c["ma20_signals"].items(): + if "error" in sig: + print(f" {code}: 查询失败") + else: + name = sig.get("name", code) + signal = sig.get("signal", "unknown") + emoji = {"golden_cross": "🟢金叉", "dead_cross": "🔴死叉", "neutral": "⚪中性"}.get(signal, signal) + price = sig.get("price", 0) + ma20 = sig.get("ma20", 0) + print(f" {name}({code}){emoji} 现价:{price:.2f} MA20:{ma20:.2f}") + else: + print(" 无数据") + + print("\n【持仓状态】") + for code, pos in c["position_status"].items(): + print(f" {pos['name']}({code}):{pos['status']}") + + print("\n" + "=" * 50) + print("【马克思主义分析框架】") + print(f" 本质:实践是检验真理的唯一标准") + print(f" 当前实践:模拟持仓,等MA20金叉验证判断") + print(f" 矛盾积累:宏观-1+基本面+1,等待技术面确认方向") + print(f" 量变质变:MA20金叉=质变临界点") + print("=" * 50) + +def main(): + cmd = sys.argv[1] if len(sys.argv) > 1 else "report" + + if cmd == "report": + c = analyze_week() + print_report(c) + + # 保存到历史 + history = load_history() + history["weeks"].append(c) + if len(history["weeks"]) > 52: # 保留一年 + history["weeks"] = history["weeks"][-52:] + save_history(history) + + elif cmd == "check": + # 快速检查 MA20 信号 + for code in ["000858", "600519", "000568", "002304"]: + sig = get_ma20_signal(code) + if sig and "error" not in sig: + emoji = {"golden_cross": "🟢", "dead_cross": "🔴", "neutral": "⚪"}.get(sig["signal"], "❓") + print(f"{emoji} {sig['name']} | 现价:{sig['price']:.2f} MA20:{sig['ma20']:.2f}") + elif sig: + print(f"❌ {code}: {sig.get('error', 'unknown')}") + + elif cmd == "record": + c = analyze_week() + history = load_history() + if c not in history["weeks"]: + history["weeks"].append(c) + save_history(history) + print(f"✅ 已记录 {c['week']} 的矛盾分析") + else: + print(f"⚠️ {c['week']} 已记录,跳过") + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/skills/knowledge/cangjie-distill/SKILL.md b/skills/knowledge/cangjie-distill/SKILL.md new file mode 100644 index 00000000..867aed0e --- /dev/null +++ b/skills/knowledge/cangjie-distill/SKILL.md @@ -0,0 +1,223 @@ +--- +name: cangjie-distill +version: 1.2.0 +date: 2026-07-17 +description: | + 把书籍/视频/播客/课程/长内容蒸馏成一组可执行 skills 的元 skill。 + 触发词:拆书/蒸馏/把XX做成skill/turn a book into skills/把视频/播客/课程蒸馏成skill + 不是简单摘要,是方法论/框架/原则的原子化提取,让 agent 能在真实场景调用。 + NOT for: 书摘/读后感/角色扮演(那是 nuwa-skill 的工作) +category: knowledge +tags: [knowledge-distillation, book-to-skill, ria-tv-plus, method distillation] +related_skills: + - hermes-self-improvement: "仓颉skill是主动学习体系的核心工具" +source: https://github.com/kangarooking/cangjie-skill +local_source: ~/.hermes/cangjie-skill/(完整26文件) +output_path: ~/.hermes/cangjie-skills/<主题名>/ +--- + +# 仓颉知识提炼技能(cangjie-skill) + +## 使命 + +把一本书/视频/播客/课程里沉淀的方法论,拆解成一组**原子化、可被 agent 在真实场景下调用**的 skills。 + +> **核心洞察**:现有读书方法论都是为人类读者蒸馏,不是为 agent 执行者蒸馏。给人看靠故事/金句/情感钩子;给 agent 用靠 trigger / 可执行步骤 / 判停标准。 + +**边界**: +- ✅ 做:方法论 / 决策框架 / 清单 / 原则 / 概念体系的蒸馏 +- ❌ 不做:书摘 / 读后感 / 作者人设角色扮演(请用 nuwa-skill) + +## 何时调用此 skill + +用户说类似: +- "帮我拆《穷查理宝典》" +- "把毛选蒸馏成 skill" +- "把这个 B 站视频/播客/课程蒸馏成 skill" +- "distill this book into skills" +- "把 XX 的方法论做成可用的 skill" + +## 两种提炼模式 + +### 模式一:轻量模式 — 四字结构(快速提炼) + +适用于快速提炼一个概念/理论的核心,不做完整流水线: + +``` +主题 → 核心本质(2字以内) + → 对立面是什么(2字以内) + → 根本矛盾在哪(4字以内) + → 转化机制是什么(4字以内) +``` + +**输出格式**: +``` +|【仓颉·主题】 + ◆ 本质:XX + ◆ 对立:XX + ◆ 矛盾:XXXX + ◆ 转化:XXXX + ◆ 一句话:XXX(15字以内) +``` + +**示例**: +``` +|【仓颉·马克思主义哲学】 + ◆ 本质:实践 + ◆ 对立:唯心 / 唯物 + ◆ 矛盾:存在意识之争 + ◆ 转化:实践→认识→再实践 + ◆ 一句话:实事求是,在实践中检验真理 +``` + +### 模式二:完整模式 — 8阶段 RIA-TV++(深度蒸馏) + +把一本书/课程/长内容转化为完整技能体系: + +``` +Stage0 Adler分析 → 整体理解,判断是否值得蒸馏 +Stage1 并行提取 → 5个提取器同时工作 +Stage1.5 三重验证 → 提取结果交叉验证,过滤错误 +Stage2 RIA++构造 → 转换为可执行技能格式 +Stage3 Zettelkasten → 原子化笔记,建立引用关系 +Stage4 压力测试 → 极端情况检验,补充边界 case +Stage5 交付 → 输出为 skill/overview/digest/index +``` + +## RIA-TV++ 六段详解 + +每个 skill 必须包含以下六段: + +### R — Reading(原文引用) + +- 直接引用 ≤150 字(英文原文 ≤100 词) +- 必须标注出处(章节/页码;视频填时间戳/分P,播客填集数) +- 若原书是英文,引用英文原文 + 你自己翻译的中文,**不要用现成译本** + +### I — Interpretation(自述) + +- 用**你自己的话**重写方法论的核心骨架,5–15 行 +- 检查:没读过原书的人能否理解这个方法论在做什么?若不能,重写 +- 禁止:照搬原文句子 / 堆砌修辞 + +### A1 — Past Application(书中案例) + +- 作者在书中**亲自**用这个方法论处理过的具体案例 +- 至少 1 条,≤3 条 +- 每条要点明:遇到什么问题 → 怎么用方法论 → 得出什么结论 → 实际结果 + +### A2 — Future Trigger ★(最关键,决定是否被调用) + +必须明确: +1. **用户在什么情境下遇到这类问题?**(场景描述,3–5 条) +2. **这些情境的语言信号是什么?**(用户会说什么样的话) +3. **和哪些相邻 skill 不同?**(避免互相抢调用) + +> 好的 A2 示例: +> "用户在纠结一个决策、列举正面理由却理不出头绪时;或在问'怎么做X才能成功'时;不适用于纯信息查询类问题。" +> +> 坏的 A2 示例: +> "用户需要思考时。" ← 太宽泛,会误激活 + +### E — Execution(可执行步骤) + +- 1-2-3 步骤,每步有**可判断的完成标准** +- 如果有判停点,显式写出(如:step 2 之后若 X 则跳到 step 5) + +### B — Boundary(边界) + +- 什么时候**不要**使用这个 skill(反场景) +- 作者警告过的失败模式 +- 与之相邻但容易混淆的其他方法论 + +## 三重验证(阶段 1.5) + +每个候选单元必须通过: + +| 验证 | 问题 | 通过条件 | +|------|------|---------| +| V1 跨域 | 书中至少 2 个独立段落有佐证? | 是 | +| V2 预测力 | 能用它回答一个书里没明说的新问题吗? | 是 | +| V3 独特性 | 不是任何聪明人都会说的常识吗? | 否(若为常识则淘汰)| + +通过的写入 `verified.md`,不通过的写入 `rejected/` 并附原因(保留审计轨迹)。 + +## 完整流水线输出结构 + +``` +~/.hermes/cangjie-skills/<主题名>/ +├── PIPELINE_STATE.md # 流水线状态(断点续跑用) +├── BOOK_OVERVIEW.md # Stage0 产出:主旨/骨架/术语/批判 +├── verified.md # Stage1.5 产出:通过三重验证的单元 +├── candidates/ # Stage1 产出:原始候选池(审计用) +├── rejected/ # Stage1.5 产出:淘汰的单元 + 原因 +├── INDEX.md # Stage3 产出:skill 总览 + 引用图 +├── GLOSSARY.md # Stage3 产出:全书共享术语词典 +├── DIGEST.md # Stage5 产出:面向读者的精华长文 +└── / + ├── SKILL.md + ├── test-prompts.json # Stage4 产出:压力测试 prompt + └── test-results.md # Stage4 产出:测试通过率 + 失败分析 +``` + +## 质量红线(违反则阻止输出) + +1. 每个 skill 必须通过**全部**三重验证 +2. 每个 skill 必须有完整的 R / I / A1 / A2 / E / B 六段 +3. 原文引用 ≤150 字/段(英文 ≤100 词/段) +4. 每个 skill 必须有 `test-prompts.json`,且包含**诱饵测试**(不应调用的场景),其中至少 1 条是同书兄弟 skill 的场景 +5. `description` 字段必须明确 trigger 条件,不能只是"一个关于 X 的 skill" + +## 执行规范 + +- **永远先试点 1 本** — 除非用户明确说"批量" +- **阶段之间主动汇报进度** — 不要静默跑完再 dump 结果 +- **不凭记忆拆书** — 没文本就停下来问用户要 +- **保留审计轨迹** — candidates/ 和 rejected/ 都要留 +- **随时可续跑** — 每完成一个阶段就更新 PIPELINE_STATE.md + +## 原版 GitHub 源码 + +``` +https://github.com/kangarooking/cangjie-skill +本地路径:~/.hermes/cangjie-skill/ +``` + +完整文件树: +``` +cangjie-skill/ +├── SKILL.md # 核心方法论文档 +├── GITHUB_REPO.md # 仓库元数据 +├── methodology/ # 8阶段流水线详解 +│ ├── 00-overview.md # 方法论总览(必读) +│ ├── 01-stage0-adler.md +│ ├── 02-stage1-parallel-extract.md +│ ├── 03-stage1.5-triple-verify.md +│ ├── 04-stage2-ria-plus.md +│ ├── 05-stage3-zettelkasten.md +│ ├── 06-stage4-pressure-test.md +│ └── 07-stage5-deliver.md +├── extractors/ # 5个专项提取器 +│ ├── framework-extractor.md +│ ├── principle-extractor.md +│ ├── case-extractor.md +│ ├── counter-example-extractor.md +│ └── glossary-extractor.md +├── templates/ # 输出模板 +│ ├── skill-template.md +│ ├── overview-template.md +│ ├── digest-template.md +│ ├── index-template.md +│ └── test-prompts-template.md +├── scripts/ +└── assets/ +``` + +## 脚本工具 + +```bash +# 深度蒸馏(完整流水线) +python3 ~/.hermes/scripts/cangjie_distill.py distill +``` + +详细流程见:`references/cangjie-ria-tv-plus-pipeline.md` \ No newline at end of file diff --git a/skills/knowledge/cangjie-distill/references/cangjie-ria-tv-plus-pipeline.md b/skills/knowledge/cangjie-distill/references/cangjie-ria-tv-plus-pipeline.md new file mode 100644 index 00000000..14a647db --- /dev/null +++ b/skills/knowledge/cangjie-distill/references/cangjie-ria-tv-plus-pipeline.md @@ -0,0 +1,86 @@ +# 仓颉 RIA-TV++ 完整流水线 + +> 来源:`~/.hermes/cangjie-skill/methodology/`(8阶段流水线) +> 用途:当需要把书籍/视频/课程深度蒸馏为技能时,按此流程执行 + +## 8 阶段总览 + +| Stage | 名称 | 产出 | +|-------|------|------| +| 0 | Adler 分析 | 判断是否值得蒸馏,决定提取深度 | +| 1 | 并行提取 | 5 个提取器同时工作(framework/principle/case/counter-example/glossary) | +| 1.5 | 三重验证 | 提取结果交叉验证,过滤幻觉和错误 | +| 2 | RIA++ 构造 | 转换为可执行技能格式(Rule/Insight/Action) | +| 3 | Zettelkasten | 原子化笔记,建立引用关系 | +| 4 | 压力测试 | 极端情况检验,补充边界 case | +| 5 | 交付 | 输出为 skill/overview/digest/index/test-prompts | + +## 各阶段说明 + +### Stage0 — Adler 分析 +- 整体阅读,理解作者核心论点 +- 判断:**是否值得花时间蒸馏?** 优先级高/中/低 +- 决定提取深度(全文/节选/摘要) + +### Stage1 — 并行提取 +5 个提取器同时运行: +``` +framework-extractor → 提取核心框架/模型 +principle-extractor → 提取原理/原则 +case-extractor → 提取案例/故事 +counter-example-extractor → 提取反例/边界 +glossary-extractor → 提取术语表 +``` + +### Stage1.5 — 三重验证 +- **自我验证**:提取内容是否自洽? +- **交叉验证**:5 个提取器之间是否矛盾? +- **外部验证**:与已知事实对比 + +### Stage2 — RIA++ +- **R(Rule)**:规则 — 在什么条件下怎么做 +- **I(Insight)**:洞见 — 为什么这个规则有效 +- **A(Action)**:行动 — 如何执行这个规则 + +### Stage3 — Zettelkasten +- 原子化:每个笔记只包含一个想法 +- 引用链接:笔记之间相互引用 +- 唯一性:避免重复相同内容 + +### Stage4 — 压力测试 +- 测试极端情况 +- 找出规则的边界和失效条件 +- 补充反例 + +### Stage5 — 交付模板 + +| 模板 | 用途 | +|------|------| +| `skill-template.md` | 完整技能文档 | +| `overview-template.md` | 技能概览 | +| `digest-template.md` | 摘要/速读版 | +| `index-template.md` | 技能地图/索引 | +| `test-prompts-template.md` | 测试用例 | + +## 本地脚本 + +```bash +# 完整流水线脚本 +python3 ~/.hermes/scripts/cangjie_distill.py distill <text_file> <title> +``` + +脚本位置:`~/.hermes/scripts/cangjie_distill.py`(233行,RIA-TV++ 蒸馏引擎) + +## 输出路径 + +``` +~/.hermes/cangjie-skills/<主题名>/ +├── skills/ # 产出的各个 skill +│ ├── skill_phase1_xxx.md +│ └── ... +├── methodology/ # 元方法论 +├── INDEX.md # 技能地图 +└── references/ # 原始材料和分析 +``` + +**注意**:输出到 `~/.hermes/cangjie-skills/`,不是 `~/.hermes/skills/`(后者是正式技能库) \ No newline at end of file