{"id":50998727,"url":"https://github.com/hugin-z/solution-drafter","last_synced_at":"2026-06-20T12:02:52.594Z","repository":{"id":364197136,"uuid":"1265931893","full_name":"Hugin-Z/solution-drafter","owner":"Hugin-Z","description":"可扩展的中文政企方案文档生成 Skill 框架 · 三层解耦架构 + 五阶段工作流(信息抽取→资料获取→模板填充→内容生成→评审修订)","archived":false,"fork":false,"pushed_at":"2026-06-12T02:40:58.000Z","size":159,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-12T04:18:17.717Z","etag":null,"topics":["agent","chinese-nlp","claude-skill","document-generation","llm"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Hugin-Z.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-11T07:37:54.000Z","updated_at":"2026-06-12T02:40:59.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/Hugin-Z/solution-drafter","commit_stats":null,"previous_names":["hugin-z/solution-drafter"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Hugin-Z/solution-drafter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hugin-Z%2Fsolution-drafter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hugin-Z%2Fsolution-drafter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hugin-Z%2Fsolution-drafter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hugin-Z%2Fsolution-drafter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Hugin-Z","download_url":"https://codeload.github.com/Hugin-Z/solution-drafter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hugin-Z%2Fsolution-drafter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34568743,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-20T02:00:06.407Z","response_time":98,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agent","chinese-nlp","claude-skill","document-generation","llm"],"created_at":"2026-06-20T12:02:51.812Z","updated_at":"2026-06-20T12:02:52.585Z","avatar_url":"https://github.com/Hugin-Z.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# solution-drafter\n\n[![CI](https://github.com/Hugin-Z/solution-drafter/actions/workflows/ci.yml/badge.svg)](https://github.com/Hugin-Z/solution-drafter/actions/workflows/ci.yml)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)\n[![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/)\n\n中文政企（toG / toB）方案文档生成框架 —— 把零散输入（聊天 / 会议纪要 / 邮件）装配成规范的政府格式 docx（需求方案 / 解决方案建议书 / 实施方案 等）。**Skill（纯文本契约）+ Python 工具链**形态：任何能读 `SKILL.md` 工作流的 LLM agent 都可驱动，下层 Python 负责把 markdown 装配成字体合规的 docx。\n\n\u003e 本仓库是一个**架构与工程实践的开源示范**。其中的公司 / 产品 / 项目 / 客户均为**虚构示例**，不指向任何真实主体。\n\n## 它解决什么\n\n政企方案文档的痛点是固定的：输入零散、输出必须规范（规范中文字体——默认正文宋体、可按 font_policy 切仿宋等 / 章节结构 / 政府格式）、内容要查历史素材、同一件事换个文档类型只需套不同骨架。solution-drafter 把这件事拆成**三层解耦 + 5 阶段调度**，让\"加新文档类型不动框架、换领域不动文档类型\"成为可执行的契约（有测试锁定）。\n\n## 三层解耦架构\n\n```\n┌─────────────────────────────────────────────────┐\n│  L1 框架层（与文档类型 / 领域无关）              │\n│  scripts/ 工具链 + system.md + 5 阶段 stages     │\n│  ── 加新文档类型 / 换领域都不动这一层 ──         │\n├─────────────────────────────────────────────────┤\n│  L2 文档类型层（与领域无关）                     │\n│  templates/\u003cdoc_type\u003e/outline.yaml               │\n│  + prompts/sections/\u003cdoc_type\u003e/ + template.docx  │\n│  需求方案 / 解决方案建议书 / 实施方案 / ...       │\n├─────────────────────────────────────────────────┤\n│  L3 领域插件层（可拔插 / run.py override 注入）  │\n│  prompts/domain/\u003cvendor\u003e/ 术语 + 决策 + 合规     │\n│  + 公司主体字段 / 默认空领域 / 示例虚构领域       │\n└─────────────────────────────────────────────────┘\n```\n\n## 5 阶段工作流\n\n| 阶段 | 输入 | 输出 | 用户参与 |\n|---|---|---|---|\n| S1 信息抽取 | 用户零散输入 | `intake.json` | 对话 ack |\n| S2 资料获取 | `intake.json` + asset_needs | `assets.json` | 无（agent 用环境手段主动获取 / 手段无关 / 框架只定义 `assets.json` 契约，不提供真实素材库）|\n| S3 模板填充 | `intake.json` + outline.yaml | `outline_filled.json` | 无（纯结构化映射）|\n| S4 内容生成 | `outline_filled.json` + assets + prompts | `draft.md` | 无（逐 section 落盘 / 长文档不断流）|\n| S5 评审修订 | `draft.md` | `final.md` + `final.docx` | 多轮对话迭代 |\n\n阶段间用 JSON / Markdown 文件传递（不靠 context 记忆），每阶段可独立重跑。\n\n## Quickstart\n\n```bash\npip install -r requirements.txt          # python-docx / PyYAML / lxml / opencc\n\n# 跑一个端到端 demo（虚构数据 → 字体合规的 docx）\npython examples/demo-需求方案/run.py            # 需求方案 / 默认空领域\npython examples/demo-槐序数据领域/run.py        # 接领域插件 → §公司实力由 own_* 填充\n\n# 校验一个文档类型配置\npython scripts/validate_outline.py templates/需求方案/outline.yaml --repo-root .\n\n# 跑测试（先装开发依赖 pytest）\npip install -r requirements-dev.txt\npython -m pytest -q\n```\n\n产物在 `examples/demo-*/output/`：`draft.md`（markdown 终稿）+ `\u003c项目名\u003e_\u003c类型\u003e.docx`（字体合规的政府格式 docx）。\n\n## 输出样例\n\n`python examples/demo-槐序数据领域/run.py`（虚构领域插件 + 虚构项目）生成的正文片段（节选）：\n\n```markdown\n# 云阙新区一体化数据服务平台一期建设项目 解决方案建议书\n\n## 公司实力\n\n### 公司简介\n\n槐序数据科技有限公司（虚构）成立于 2015 年，是一家面向政企客户的时空数据与一体化\n数据治理服务商。公司以自研的「方舆时空数据平台」与「编册数据中台」为核心，为各级\n政府和企事业单位提供数据汇聚、治理、共享与可视化的一体化解决方案……\n\n### 资质与认证\n\n（虚构资质示例）信息系统集成及服务资质、CMMI 五级、ITSS 三级、DCMM 三级；\nISO 9001 / ISO/IEC 27001 认证；国家高新技术企业。\n\n依据已获取的公司资质素材：【示例素材:公司资质】           ← ① S2 素材消费（acquired 织入正文）\n\n（业绩相关素材尚未获取，此处【待补充】。）                  ← ② 待补充占位（素材没获取到，诚实标注、不编造）\n```\n\n- **① 领域插件填充**：「公司实力」由 L3 领域插件 `prompts/domain/槐序数据/` 的 `own_*` 字段填充——对照默认空领域（`demo-解决方案建议书`）此处整段输出【待补充】，可直观看出 L3 接入前后差异。\n- **② S2→S4 素材消费 + 待补充占位**：S2 获取到的素材被实质织入正文，没获取到的诚实落「【待补充】」、不编造——这是本框架的核心机制（事实必须有来源）。\n\n\u003e 公司 / 产品 / 项目均为虚构示例（槐序数据 / 方舆 / 编册 / 云阙新区），不指向任何真实主体。\n\n## 怎么加一个新文档类型（不动框架）\n\n1. 加 `templates/\u003cdoc_type\u003e/outline.yaml`（intake_schema + outline + generation + output / 每 section 写 `asset_needs` + 注册 `s2_acquire` stage）。\n2. 加 `prompts/sections/\u003cdoc_type\u003e/\u003cNN\u003e.md`（每 section：anchor + intake 依赖 + 生成思路 + 输出格式 + 素材运用 + 红线）。\n3. 生成空 `template.docx`。\n4. `python scripts/validate_outline.py …` 校验通过。\n\n详见 `SKILL.md` §加新文档类型。\n\n## 怎么接一个领域插件（不动文档类型）\n\n在 `prompts/domain/\u003cvendor\u003e/` 放 4 个文件（`company-profile.md` 含 `own_*` 公司主体字段 + `glossary` / `client-logic` / `compliance`），在 run.py 内拼成 `domain_plugin` 注入（不改 outline.yaml）。`examples/demo-槐序数据领域/` 是一个完整的虚构领域活例子；对照 `demo-解决方案建议书/`（默认空领域 / 公司实力段输出【待补充】）即可看出 L3 接入前后的差异。\n\n详见 `SKILL.md` §自定义领域插件 howto。\n\n## 长文档不断流\n\nLLM 单次输出有 token 上限，几万~几十万字的方案文档一口气生成会被截断。框架的做法是**逐 section 落盘**：每生成完一个 section 立即 `append_markdown` + `save`，再生成下一个；单个 section 过长再按三级标题分批。即使中途断（上下文耗尽 / 进程中断），已写入磁盘的 section 也保住。断点续写本身依赖调用方是 agentic agent，框架诚实声明只保证\"逐段落盘不丢\"，不保证\"自动续写\"。\n\n## 仓库结构\n\n```text\nscripts/        L1 Python 工具链（docx 渲染 / 字体安全 / outline 校验）\nprompts/        system / stages（L1）/ sections（L2）/ domain（L3）\ntemplates/      各文档类型的 outline.yaml + 空 docx 母版\nexamples/       端到端 demo（含 1 个虚构领域 demo）\ntests/          pytest（outline 校验 / demo smoke / 字体安全 / 逐段落盘）\ndocs/           工程方法论笔记\n```\n\n## 设计取舍\n\n为什么这样分层、baseline 怎么锁、契约校验放哪、长文档怎么不断流 —— 这些\"踩坑 → 解决\"的工程笔记见 [`docs/engineering-notes.md`](docs/engineering-notes.md)。\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhugin-z%2Fsolution-drafter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhugin-z%2Fsolution-drafter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhugin-z%2Fsolution-drafter/lists"}