Auto Loop Closed-Loop System — CMS Integration Guide
Version: v1.1 | Updated: 2026-07-05 | Applicable System: BossAgents v2.x
Table of Contents
- System Architecture Overview
- Core Concepts
- Batch Conversion of Docs to Articles
- Content Digital Employee Workflow
- Marketing Digital Employee Workflow
- CMS Experience Entry Point
- Sharing and Viral System
- Skill Experience System
- Closed-Loop Metrics and Configuration
- Complete API Reference
- Frequently Asked Questions
1. System Architecture Overview
1.1 Closed-Loop Process
docs/*.md ──→ DocsConverter ──→ ContentStore ──→ MarketingService ──→ 发布
│ │ │
│ Markdown→HTML │ 内容存储 │ 平台变体
│ LLM导语增强 │ 质量检查 │ 审核→发布
│ 体验Footer追加 │ 去AI味 │ WeChat/Zhihu/CSDN
│ │ │
└──── 体验入口(立即体验+Share) ◄────────────┘
│
分享裂变系统
(AES-256加密)
│
访客→注册转化
1.2 数据流向
| 阶段 | 输入 | 输出 | 存储 |
|------|------|------|------|
| Document Conversion | docs/*.md | HTML Articles | content-items.json |
| Content Generation | doc_assets | Generated Articles | content-items.json |
| Marketing Variants | Published Content | Platform Variants | marketing-items.json |
| Sharing and Virality | Skill Results | Encrypted Links | auto-loop-data.json |
| Conversion Tracking | Conversion Records | Status | docs-converted.json |
1.3 Key File Locations
| File | Path | Description |
|---|---|---|
| Documentation Directory | docs/*.md | 99 technical Markdown documents |
| Content Storage | server/data/content-items.json | All content assets |
| Marketing Variants | server/data/marketing-items.json | Platform variant content |
| Closed-loop Data | server/data/auto-loop-data.json | Shares/actions/metrics |
| Conversion Tracking | server/data/docs-converted.json | Document conversion records |
| Skill Configuration | server/config/auto-loop-skills.json | 5 Skill definitions |
| DocsConverter | server/core/docs-converter.js | Document conversion engine |
| MarketingService | server/core/marketing-service.js | Marketing variant engine |
| AutoLoopService | server/core/auto-loop-service.js | Closed-Loop Core Engine |
| ShareService | server/core/share-service.js | Share Encryption Service |
| API Routes | server/routes/auto-loop-api.js | 22 API Endpoints |
2. Core Concepts
2.1 Content Status Flow
draft → refined → published
│ │ │
│ │ └──→ 营销变体生成 → 审核 → 发布
│ └──→ 去AI味优化完成
└──→ 初始生成/转换
| 状态 | 说明 | 触发条件 |
|------|------|----------|
| draft | Draft | Newly generated or newly converted |
| refined | Optimized | De-AI processing completed |
| published | Published | Manually published or auto-published (quality score ≥80) |
| failed | Failed | Error occurred during generation process |
2.2 Content Source Tags
| source | Description |
|---|---|
| docs-converter | Converted from Markdown in docs/ directory |
| auto_loop | Auto-generated by AutoLoop Pipeline |
| digital-staff | Triggered by digital staff dispatch |
| manual | Manually created via frontend |
2.3 Platform Variants
| Platform | Code | Style | Word Count | Characteristics |
|---|---|---|---|---|
| WeChat Official Account | Friendly & Professional | 800-2000 | Short paragraphs, emojis allowed | |
| Zhihu | zhihu | Professional & In-depth | 1500-3000 | Clear logic, data-supported |
| CSDN | csdn | Technical & Practical | 1000-2500 | Code examples, clear steps |
| Toutiao | toutiao | Popular & Informative | 800-1500 | Rich in images & text, high information density |
3. Batch Conversion of Docs to Articles
3.1 How It Works
DocsConverter scans Markdown files in the docs/ directory and executes the following conversion process:
- Scan — Discover all .md files, compare with conversion records, identify unconverted files
- Parse — Extract title, abstract, keywords, category
- Convert — Markdown→HTML (headings/code blocks/lists/links/bold/italic)
- Enhance — Call LLM to generate 80-150-word introduction (can be disabled)
- Append Footer — Add "Try Now" + "Share with Colleagues" buttons
- Store — Write to ContentStore, status as draft
3.2 API Usage
#### Scan Documents
GET /api/auto-loop/docs/scan
响应示例:
json
{
"success": true,
"data": {
"total": 99,
"unconverted": ["ARCHITECTURE.md", "DEPLOY.md", ...],
"converted": 6
}
}
#### Convert Single Document
POST /api/auto-loop/docs/convert
Content-Type: application/json
{
"file": "ARCHITECTURE.md",
"options": {
"enhanceWithLlm": true,
"experienceFooter": true,
"autoPublish": false,
"force": false
}
}
| 参数 | 类型 | 默认 | 说明 |
|------|------|------|------|
| file | string | Required | Filename under docs/ |
| options.enhanceWithLlm | boolean | true | Whether to generate introduction using LLM |
| options.experienceFooter | boolean | true | Whether to append experience footer |
| options.autoPublish | boolean | false | Auto-publish after conversion |
| options.force | boolean | false | Force reconversion of already converted files |
#### Batch Conversion
POST /api/auto-loop/docs/convert
Content-Type: application/json
{
"options": {
"limit": 10,
"enhanceWithLlm": false,
"experienceFooter": true
}
}
No preferencefile时为批量模式,limit控制每次转换数量(默认10)。
Note: For initial batch conversion, it is recommended to disable enhanceWithLlm as LLM calls are slow. Convert all documents quickly first, then enhance them individually later.
#### Check Conversion Status
GET /api/auto-loop/docs/status
响应示例:
json
{
"success": true,
"data": {
"totalDocs": 99,
"convertedCount": 7,
"unconvertedCount": 92,
"lastScan": null,
"recentConversions": [
{
"file": "ARCHITECTURE.md",
"contentId": "CONTENT-00016",
"title": "Right-Hand Support — Technical Architecture Description",
"category": "System Architecture",
"keywords": ["ARCHITECTURE", "Architecture Documentation Index", ...],
"convertedAt": "2026-07-05T07:40:12.476Z"
}
]
}
}
3.3 Category Auto-Inference
The system automatically infers categories based on file names and content keywords:
| Keywords | Category |
|--------|------|
| SCSAI, aml | SCSAI Integration |
| architecture, framework, system | System Architecture |
| bom, process, manufacturing | Manufacturing Process |
| api, interface, route | API Documentation |
| deploy, deployment, docker | Deployment & Operations |
| agent, intelligent agent, digital | Intelligent Agent |
| content, marketing | Content Marketing |
| rule, rules | Rule Engine |
| doc, documentation | Documentation Management |
| Others | Technical Documentation |
3.4 Conversion Tracking
Conversion records are stored in server/data/docs-converted.json, including:
- Filename → Content ID mapping
- Title, category, keywords
- Conversion time
Converted files will not be processed again (unless force: true is set).
4. Content Digital Employee Pipeline
4.1 How It Works
AutoLoopService.runContentPipeline() reads approved documents from the doc_assets table, generates content via ContentEngine, performs quality checks and de-AI-fication, then stores it in ContentStore.
4.2 Manually Triggering the Pipeline
POST /api/auto-loop/pipeline/run
注意: Pipeline需要LLM可用,如果LLM不可用会超时。建议优先使用DocsConverter转换docs/目录文档。
4.3 Content Quality Check
The system automatically detects the following issues:
| Check Item | Description | Threshold |
|--------|------|------|
| AI Tone Detection | Detects AI-sounding phrases like "In summary," "It is worth mentioning" | Triggers de-AI-fication if aiScore > 30 |
| Internal Field Leakage | Detects SCSAI internal fields such as config_id, permission_id | Flagged upon occurrence |
| Content Completeness | Check Content Length |
4.4 Content API
| Endpoint | Method | Description |
|---|---|---|
| /api/content/list | GET | Content list (supports pagination, filtering) |
| /api/content/generate | POST | Generate new content |
| /api/content/refine | POST | Optimize to remove AI tone |
| /api/content/publish | POST | Publish content |
5. Marketing Digital Employee Workflow
5.1 Complete Process
已发布内容 → 发现可推广内容 → 生成平台变体 → 审核 → 发布
5.2 发现可推广内容
GET /api/auto-loop/marketing/discover
返回所有已发布(published/refined)但尚未生成营销变体的内容。
5.3 Generate Marketing Variants
#### Single-Platform Variant
POST /api/auto-loop/marketing/variant
Content-Type: application/json
{
"content_id": "CONTENT-00009",
"platforms": ["wechat"]
}
#### 多平台批量变体
POST /api/auto-loop/marketing/variant
Content-Type: application/json
{
"content_id": "CONTENT-00009",
"platforms": ["wechat", "zhihu", "csdn"]
}
5.4 审核变体
POST /api/auto-loop/marketing/variant/{variantId}/review
Content-Type: application/json
{
"action": "approve",
"note": "内容质量良好,可以发布"
}
| action | 说明 |
|--------|------|
| approve | Approved, status changes to approved |
| reject | Rejected, status changes to rejected |
5.5 Publish Variant
POST /api/auto-loop/marketing/variant/{variantId}/publish
只有approved状态的变体才能发布。
5.6 View Variant List
GET /api/auto-loop/marketing/variants?platform=wechat&status=published&page=1&pageSize=20
5.7 营销统计
GET /api/auto-loop/marketing/stats
响应示例:
json
{
"success": true,
"data": {
"total": 4,
"byStatus": { "draft": 1, "published": 3 },
"byPlatform": { "wechat": 4 }
}
}
6. CMS Experience Entry
6.1 Configuring the Experience Entry
Configure in Content Center → Settings page, under the "Experience Entry & Purchase Link" card:
| Configuration Item | Description | Example |
|--------|------|------|
| Enable Experience Footer | Whether to append an experience entry at the bottom of articles | Enable/Disable |
| Experience Link | URL redirected to when clicking the "Experience" button | https://miniapp.example.com/experience |
| Purchase/Consultation Link | URL redirected to when clicking the "Purchase" button | https://miniapp.example.com/buy |
| Share Link | URL redirected to when clicking the "Share" button | https://miniapp.example.com/share |
| Experience Button Text | Custom text for the experience button | "Free Trial" |
| Purchase Button Text | Custom text for the purchase button | "Buy Now" |
| Share Button Text | Custom text for the share button | "Share with Friends" |
| Brand Name | Footer Brand Logo | "Left Aid Right Arm · PLM Agent" |
| QR Code Image | Upload or paste Base64-encoded QR code | Supports PNG/JPG |
Mini Program Integration: Experience links and purchase links can point to mini program paths (e.g., WeChat Mini Program's weixin://dl/business/?appid=xxx). Users can click to jump directly to the mini program.
6.2 Configuration Storage
Configuration is stored in the experienceFooter field of server/config/content-config.json:
json
{
"experienceFooter": {
"enabled": true,
"experienceUrl": "https://miniapp.example.com/experience",
"purchaseUrl": "https://miniapp.example.com/buy",
"qrCodeBase64": "data:image/png;base64,...",
"shareUrl": "https://miniapp.example.com/share",
"experienceButtonText": "Free Trial",
"purchaseButtonText": "Buy Now",
"shareButtonText": "Share with Friends",
"brandName": "Zuobang Youbi · PLM Agent"
}
}
6.3 Experience the Footer Effect
The Footer automatically appended to the article bottom includes:
- Title — "Want to personally experience {Article Title}?"
- Experience Button — Links to the configured trial URL (white button, blue text)
- Purchase Button — Links to the configured purchase URL (red button, white text), displayed only when purchaseUrl is configured
- Share Button — Links to the configured share URL (semi-transparent white button)
- QR Code — Displayed when qrCodeBase64 is configured, with a "Scan to Experience" prompt
- Brand Identifier — The configured brandName
6.4 Configure via API
PUT /api/content/config
Content-Type: application/json
{
"experienceFooter": {
"enabled": true,
"experienceUrl": "https://your-miniapp.com/experience",
"purchaseUrl": "https://your-miniapp.com/buy",
"qrCodeBase64": "data:image/png;base64,...",
"shareUrl": "https://your-miniapp.com/share",
"experienceButtonText": "免费体验",
"purchaseButtonText": "立即购买",
"shareButtonText": "转发好友",
"brandName": "左帮右臂 · PLM智能体"
}
}
`
### 6.5 关闭体验Footer
方式一:设置页关闭"启用体验Footer"
方式二:转换时设置 `experienceFooter: false`:
`json
{ "file": "README.md", "options": { "experienceFooter": false } }
`
### 6.6 链接未配置时的行为
| 链接 | 未配置时 |
|------|----------|
| experienceUrl | 使用默认 `/experience?topic={标题}&category={Category}` |
| purchaseUrl | 不显示购买按钮 |
| shareUrl | 使用默认 `/share?title={标题}&source=docs` |
| qrCodeBase64 | 不显示二维码区域 |
---
## 7. 分享裂变系统
### 7.1 工作原理
分享系统使用**AES-256-CBC加密**生成分享Token,确保分享链接不可伪造:
1. 创建分享时,将`{sessionId, skillId, timestamp, nonce}`加密为Token
2. 分享链接格式:`/share/{encryptedToken}`
3. 解析分享时,解密Token获取原始信息
4. 记录点击次数和注册转化
### 7.2 创建分享链接
POST /api/auto-loop/share/create
Content-Type: application/json
{
"skill_id": "skill_content_gen",
"result_snapshot": {
"summary": "Manufacturing Industry Digital Transformation Practice",
"content": "..."
},
"session_id": "user-session-123"
}
响应:
`json
{
"success": true,
"data": {
"share_token": "+oJs5PazgWLSYmB...",
"share_url": "/share/+oJs5PazgWLSYmB...",
"expires_at": "2026-08-04T08:00:00.000Z",
"watermark_text": "Powered by SCSAi PLM"
}
}
`
### 7.3 解析分享链接
GET /api/auto-loop/share/{token}
响应包含原始Skill结果、是否过期、是否提示注册。
### 7.4 记录分享点击
POST /api/auto-loop/share/click
Content-Type: application/json
{
"token": "+oJs5PazgWLSYmB...",
"new_user_id": "newly-registered-user-id"
}
### 7.5 分享配置
| 配置项 | 默认值 | 说明 |
|--------|--------|------|
| `share_expire_days` | 30 | 分享链接过期天数 |
| `guest_daily_limit` | 10 | 访客每日体验次数 |
通过`PUT /api/auto-loop/config`修改。
---
## 8. Skill体验系统
### 8.1 可用Skill列表
| Skill ID | 名称 | 图标 | 说明 |
|----------|------|------|------|
| `skill_bom_compare` | BOMCompare | ? | 上传两份BOM数据,AI自动对比差异 |
| `skill_process_optimize` | 工艺优化 | ⚙️ | 输入工艺参数,AI分析优化建议 |
| `skill_content_gen` | 内容生成 | ✍️ | 输入主题关键词,AI生成文章 |
| `skill_data_health` | 数据健康检查 | ? | 一键检查PLM数据质量 |
| `skill_doc_chat` | 文档问答 | ? | 基于技术文档智能问答 |
### 8.2 执行Skill
POST /api/auto-loop/skill/execute
Content-Type: application/json
{
"skill_id": "skill_content_gen",
"input_params": {
"topic": "Manufacturing Industry Digital Transformation Practice",
"keywords": "PLM, BOM, Digitalization",
"style": "professional"
},
"session_id": "user-session-123"
}
响应:
`json
{
"success": true,
"data": {
"skill_id": "skill_content_gen",
"result": {
"summary": "内容生成结果",
"content": "<h2>制造业数字化转型实践</h2>..."
},
"result_template": { "type": "article" },
"is_demo": true,
"demo_label": "⚠️ 演示数据"
}
}
`
### 8.3 访客模式
- 无Bearer Token的请求默认为访客模式
- 访客获得演示数据(`is_demo: true`)
- 访客每日限制10次体验(可配置)
- 超出限制返回429错误
### 8.4 注册用户模式
- 携带有效Bearer Token的请求走真实API
- 调用Skill对应的`api_endpoint`
- 无次数限制
- 返回真实数据(`is_demo: false`)
### 8.5 查询使用次数
GET /api/auto-loop/skill/usage?session_id=user-session-123
响应:
`json
{
"success": true,
"data": {
"today_count": 3,
"daily_limit": 10,
"remaining": 7
}
}
`
---
## 9. 闭环指标与配置
### 9.1 闭环指标
GET /api/auto-loop/metrics?date=2026-07-05&period=day
| 指标 | 说明 |
|------|------|
| `content_generated` | 今日生成内容数 |
| `content_published` | 今日发布内容数 |
| `guest_visits` | 访客访问数 |
| `skill_executions` | Skill执行次数 |
| `share_count` | 分享创建数 |
| `share_clicks` | 分享点击数 |
| `share_conversions` | 分享转化注册数 |
| `knowledge_deposited` | 知识沉淀数 |
### 9.2 闭环配置
GET /api/auto-loop/config
PUT /api/auto-loop/config
Content-Type: application/json
{
"recommend_weight_threshold": 0.3,
"marketing_trigger_growth": 0.5,
"share_expire_days": 30,
"guest_daily_limit": 10,
"auto_publish_mode": "manual_review",
"evolution_cron": "0 2 *"
}
| 配置 | 默认 | 说明 |
|------|------|------|
| `auto_publish_mode` | `manual_review` | `auto_publish`自动发布(质量≥80),`manual_review`手动审核 |
| `share_expire_days` | 30 | 分享链接过期天数 |
| `guest_daily_limit` | 10 | 访客每日体验次数 |
| `evolution_cron` | `0 2 * * *` | 自进化分析定时 |
---
## 10. 完整API参考
### 10.1 Skill相关
| 端点 | 方法 | 说明 |
|------|------|------|
| `/api/auto-loop/skills` | GET | 获取Skill列表 |
| `/api/auto-loop/skill/execute` | POST | 执行Skill |
| `/api/auto-loop/skill/usage` | GET | 查询使用次数 |
### 10.2 文档转换
| 端点 | 方法 | 说明 |
|------|------|------|
| `/api/auto-loop/docs/scan` | GET | 扫描docs/目录 |
| `/api/auto-loop/docs/convert` | POST | 转换文档(单个或批量) |
| `/api/auto-loop/docs/status` | GET | 查看转换状态 |
### 10.3 内容链路
| 端点 | 方法 | 说明 |
|------|------|------|
| `/api/auto-loop/pipeline/run` | POST | 运行内容Pipeline |
### 10.4 营销变体
| 端点 | 方法 | 说明 |
|------|------|------|
| `/api/auto-loop/marketing/discover` | GET | 发现可推广内容 |
| `/api/auto-loop/marketing/variant` | POST | 生成营销变体 |
| `/api/auto-loop/marketing/variants` | GET | 变体列表 |
| `/api/auto-loop/marketing/variant/{id}/review` | POST | 审核变体 |
| `/api/auto-loop/marketing/variant/{id}/publish` | POST | 发布变体 |
| `/api/auto-loop/marketing/stats` | GET | 营销统计 |
### 10.5 分享裂变
| 端点 | 方法 | 说明 |
|------|------|------|
| `/api/auto-loop/share/create` | POST | 创建分享链接 |
| `/api/auto-loop/share/{token}` | GET | 解析分享链接 |
| `/api/auto-loop/share/click` | POST | 记录分享点击 |
### 10.6 行为与指标
| 端点 | 方法 | 说明 |
|------|------|------|
| `/api/auto-loop/behavior/report` | POST | 上报行为数据 |
| `/api/auto-loop/metrics` | GET | 闭环指标 |
| `/api/auto-loop/config` | GET/PUT | 闭环配置 |
| `/api/auto-loop/catalog` | GET | 数据目录 |
---
## 11. 常见问题
### Q1: 批量转换99篇文档太慢怎么办?
关闭LLM增强,先快速转换所有文档:
`json
POST /api/auto-loop/docs/convert
{ "options": { "limit": 99, "enhanceWithLlm": false, "experienceFooter": true } }
`
后续可对单篇文档设置`force: true`重新转换并启用LLM增强。
### Q2: 如何让文章自动发布?
修改闭环配置:
`json
PUT /api/auto-loop/config
{ "auto_publish_mode": "auto_publish" }
`
质量评分≥80的文章会自动发布。
### Q3: 分享链接如何集成到外部CMS?
1. 调用`POST /api/auto-loop/share/create`获取分享URL
2. 将`share_url`嵌入CMS文章或页面
3. 访客点击后看到Skill演示结果+注册引导
### Q4: 如何添加新的Skill?
编辑`server/config/auto-loop-skills.json`,添加新Skill配置:
`json
{
"skill_id": "skill_my_custom",
"name": "自定义Skill",
"description": "Skill描述",
"icon": "?",
"api_endpoint": "/api/my-endpoint",
"api_method": "POST",
"input_template": {
"fields": [
{ "key": "param1", "label": "参数1", "type": "text", "required": true }
]
},
"result_template": { "type": "list" },
"is_public": true,
"daily_limit_guest": 10,
"sort_order": 50
}
`
同时在`auto-loop-service.js`的`_getDemoData()`中添加对应的演示数据。
### Q5: 如何自定义体验Footer?
修改`server/core/docs-converter.js`中的`_appendExperienceFooter()`方法。可自定义:
- 按钮文字和链接
- 颜色和样式
- 二维码图片(使用`<img src="data:image/png;base64,...">`)
- 添加"咨询购买"按钮
### Q6: 营销变体的LLM生成失败怎么办?
系统会自动降级为简单适配(提取原文前15段),变体仍会创建,状态为`draft`,可手动编辑后审核发布。
### Q7: 如何查看所有已转换文档的内容?
GET /api/content/list?pageSize=100
``
Filter by source: docs-converter to view all converted documents.
Q8: What is the server port?
Default port is 3006, access address is https://ylxt.chat.
Q9: How to integrate with an external CMS system?
Option 1: API Pull
The external CMS periodically calls /api/content/list?status=published to pull published content.
Option 2: Webhook Push
Add a Webhook notification in marketing-service.js's publishVariant() to push to the external CMS after publishing.
Option 3: File Export
Call /api/content/list to retrieve content, export HTML as files, and import them into the CMS.
Appendix: Quick Start
One-click conversion and publishing of docs
bash
1. Start the server
node server.js
2. Batch convert docs (with LLM acceleration disabled)
curl -X POST https://ylxt.chat/api/auto-loop/docs/convert \
-H "Content-Type: application/json" \
-d '{"options": {"limit": 99, "enhanceWithLlm": false, "experienceFooter": true}}'
3. Check conversion status
curl https://ylxt.chat/api/auto-loop/docs/status
4. Discover promotable content
curl https://ylxt.chat/api/auto-loop/marketing/discover
5. Generate WeChat variant
curl -X POST https://ylxt.chat/api/auto-loop/marketing/variant \
-H "Content-Type: application/json" \
-d '{"content_id": "CONTENT-00001", "platforms": ["wechat"]}'
6. Review and publish
curl -X POST https://ylxt.chat/api/auto-loop/marketing/variant/MKT-xxx/review \
-H "Content-Type: application/json" \
-d '{"action": "approve"}'
curl -X POST https://ylxt.chat/api/auto-loop/marketing/variant/MKT-xxx/publish
7. View closed-loop metrics
curl https://ylxt.chat/api/auto-loop/metrics
`
BossAgents