@chenshu2026/qianchuan-auto 0.0.0-stage → 1.0.1

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.
package/README.md CHANGED
@@ -1,3 +1,148 @@
1
- # Temporary Holding Version
1
+ # 千川自动化投放(qianchuan-auto)
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 一个 DeepSeek Harness(DSH)Host 插件,接入**巨量千川 Marketing API**,内置规则引擎,实现乘方/全域调控任务的自动化:加预算、调出价、异常暂停、每日建量、账本记账。
4
+
5
+ > 插件自包含:规则、状态、账本都在插件自己的 `data/` 目录,拷走即可用。
6
+
7
+ ## 功能
8
+
9
+ - **API 工具**:授权、账户、计划、报表、素材、可控任务、乘方计划、一键调速等 17 个工具。
10
+ - **规则引擎**(`qianchuan_engine_run`):
11
+ - **R4**:任意任务 ROI < 素材平均×50% 且消耗≥500 → 暂停/重建(首次确认)
12
+ - **R5**:放量 成交÷预算≥9 → 预算+500;控成本 消耗>预算×80% 且 ROI≥10 → 预算+1000(自动)
13
+ - **R6**:控成本 Δ<25%×H1 → 出价×1.066;Δ>75%×H1 → 出价×0.934(自动,取整,250~350)
14
+ - **R7**:控成本 消耗时长>2h 且 ROI<素材平均×70% → 暂停/重建(首次确认)
15
+ - **R8**:连续 4 次巡检成交无新增 → 暂停/重建(首次确认)
16
+ - **每日建量**:06:10 提议建 直投-放 / 主-放 / 次-放(首次确认)
17
+ - **账本**:`data/ops_ledger.jsonl`,记录每次加预算/调价,卡单日≤4次。
18
+
19
+ ---
20
+
21
+ ## 一、安装(5 步)
22
+
23
+ 1. **拿到插件**:解压 `qianchuan-auto` 到他本地,例如 `C:\Users\他\qianchuan-auto`。
24
+ 2. **安装**:DSH → Plugins → **Add plugin** →
25
+ - 输入包名 `@chenshu2026/qianchuan-auto`(**安装源选「npm 官方源」**,镜像可能只有占位版),或
26
+ - 输入插件文件夹的绝对路径(本地装),或
27
+ - 让 DSH 的 agent 调 `plugin_manager install_bundle`(target = 文件夹路径)。
28
+ 装完点 **Enable now**。
29
+ 3. **改账户**(详见下方「二、新用户上手」第 1 步)
30
+ 4. **授权**(详见「二、新用户上手」第 2 步)
31
+ 5. **启用自动化**:
32
+ - `cordis.patch.yml` 的 `config.polling.enabled: true`(每 30 分钟自动跑),或
33
+ - 建 DSH 定时任务,每 30 分钟调 `qianchuan_engine_run`。
34
+
35
+ ---
36
+
37
+ ## 二、新用户上手(第 3、4 步详解)
38
+
39
+ ### 第 1 步:改 `data/ruleset.json`
40
+
41
+ **① 找到文件**
42
+
43
+ - 用 **npm 包装的**:
44
+ ```
45
+ C:\Users\<用户名>\.dsh\profiles\desktop\node_modules\@chenshu2026\qianchuan-auto\data\ruleset.json
46
+ ```
47
+ - 用 **本地文件夹装的**:
48
+ ```
49
+ <插件文件夹>\data\ruleset.json
50
+ ```
51
+
52
+ > 找不到就直接问 DSH 的 agent:「千川插件的 ruleset.json 在哪?」
53
+
54
+ **② 用记事本打开**(右键 → 打开方式 → 记事本,或 VS Code)
55
+
56
+ **③ 改这两行**
57
+
58
+ ```json
59
+ "account": {
60
+ "advertiserId": "",
61
+ "planId": "",
62
+ "planName": ""
63
+ }
64
+ ```
65
+
66
+ - `advertiserId`:广告主 ID(千川后台 → 账户信息里那串数字;或让 agent 调 `qianchuan_list_advertisers` 列出)
67
+ - `planId`:乘方计划 ID(千川后台 → 乘方计划列表 → 点开计划看 URL/详情;或让 agent 调 `qianchuan_uni_promotion` 的 list 查)
68
+
69
+ **④ 保存 → 关掉**
70
+
71
+ ### 第 2 步:授权他自己的账户
72
+
73
+ `qianchuan_*` 是 DSH 插件工具,**不用自己敲命令**,在 DSH 对话框里跟 agent 说即可:
74
+
75
+ 1. **保存 App ID / Secret**
76
+ > 帮我保存千川凭据,app_id 是 `1234567890`,secret 是 `abcdef...`
77
+ → agent 调 `qianchuan_save_credentials`
78
+
79
+ 2. **生成授权链接**
80
+ > 生成千川授权链接
81
+ → agent 调 `qianchuan_get_auth_url`,给你一条链接
82
+
83
+ 3. **浏览器授权**
84
+ 打开链接 → 登录千川 → 同意授权 → 回调页会带一个 **`auth_code`** → 复制它
85
+
86
+ 4. **用 auth_code 完成授权**
87
+ > 用 auth_code 是 `xxxxx`,完成千川授权
88
+ → agent 调 `qianchuan_save_credentials`(带 `auth_code`)→ 换取 `access_token`/`refresh_token`
89
+
90
+ 5. **验证**
91
+ > 看下千川授权状态
92
+ → agent 调 `qianchuan_status`,能看到账户列表就成功
93
+
94
+ > 授权需要**自己的千川开放平台应用**(App ID / Secret),不能共用别人的。
95
+
96
+ ---
97
+
98
+ ## 三、配置
99
+
100
+ `cordis.patch.yml` 的 `config`:
101
+
102
+ ```yaml
103
+ config:
104
+ advertiserId: '' # 默认广告主 ID,留空则用授权账户
105
+ planId: '' # 乘方计划 ID,留空则用 ruleset.account.planId
106
+ dataDir: '' # 数据目录,留空 = 插件自己的 data/
107
+ polling:
108
+ enabled: true # 开启后台引擎
109
+ intervalMinutes: 30
110
+ ```
111
+
112
+ ## 四、规则参数(`data/ruleset.json` 的 `params`)
113
+
114
+ ```json
115
+ "params": {
116
+ "R4": { "enabled": true, "roiFactor": 0.5, "minCost": 500 },
117
+ "R5": { "enabled": true, "boostRatio": 9, "boostAdd": 500, "controlSpendPct": 0.8, "controlMinRoi": 10, "controlAdd": 1000, "dailyLimit": 4 },
118
+ "R6": { "enabled": true, "lowPct": 0.25, "highPct": 0.75, "bidUp": 1.066, "bidDown": 0.934, "bidMin": 250, "bidMax": 350 },
119
+ "R7": { "enabled": true, "minAgeHours": 2, "roiFactor": 0.7 },
120
+ "R8": { "enabled": true, "consecutiveRuns": 4 },
121
+ "dailyCreate": { "enabled": true, "roiFactor": 0.8, "top": 9, "from": 10, "to": 18, "budgetPerHour": 100 }
122
+ }
123
+ ```
124
+
125
+ 新增/修改规则 = 改 `params` 或 `dailyCreate`,**不用改代码**。
126
+
127
+ ## 五、注意
128
+
129
+ - **凭据不打包**:每位使用者用自己的 App ID/Secret 授权,插件目录不含任何密钥。
130
+ - **19 位 material_id 精度**:建任务时用精确整数(引擎已处理),不要直接用 JS 数字。
131
+ - **R4/R7/R8 与每日建量是「首次触发需确认」**,不会自动删任务。
132
+ - **接口频控**:引擎有「指标全 0 则整轮跳过」的护栏,避免误触发。
133
+ - **npm 镜像可能滞后**:安装时若报「没有声明 dsh.bundle」,说明镜像只有占位版 `0.0.0-stage`,请把安装源切到 npm 官方源。
134
+
135
+ ## 六、分享前建议
136
+
137
+ - 清空 `data/rule_state.json`(`snapshots` 置空)和 `data/ops_ledger.jsonl`(清空)。
138
+ - 保留 `data/ruleset.json` 作为模板,把 `account.advertiserId/planId` 留成占位符。
139
+
140
+ ## 七、发版(维护者)
141
+
142
+ ```powershell
143
+ # 改 package.json 的 version(如 1.0.1)后:
144
+ cd <插件目录>
145
+ pnpm publish --access public --no-git-checks
146
+ ```
147
+
148
+ > 发布需要 npm 2FA 或「Bypass 2FA」的 granular token。新包首个版本可能先出现 `0.0.0-stage` 占位,待 npm 审核通过后 `latest` 指向真实版本。
@@ -0,0 +1,4 @@
1
+ - insert:
2
+ - id: qianchuan-auto
3
+ name: '@chenshu2026/qianchuan-auto'
4
+ config: {}
@@ -0,0 +1,51 @@
1
+ {
2
+ "rulesetName": "千川乘方自动化投放规则集(自包含)",
3
+ "version": "2026-12-02",
4
+ "account": {
5
+ "advertiserId": "",
6
+ "planId": "",
7
+ "planName": "把你的乘方计划名填这里"
8
+ },
9
+ "params": {
10
+ "R4": { "enabled": true, "roiFactor": 0.5, "minCost": 500 },
11
+ "R5": { "enabled": true, "boostRatio": 9, "boostAdd": 500, "controlSpendPct": 0.8, "controlMinRoi": 10, "controlAdd": 1000, "dailyLimit": 4 },
12
+ "R6": { "enabled": true, "lowPct": 0.25, "highPct": 0.75, "bidUp": 1.066, "bidDown": 0.934, "bidMin": 250, "bidMax": 350 },
13
+ "R7": { "enabled": true, "minAgeHours": 2, "roiFactor": 0.7 },
14
+ "R8": { "enabled": true, "consecutiveRuns": 4 },
15
+ "dailyCreate": { "enabled": true, "roiFactor": 0.8, "top": 9, "from": 10, "to": 18, "budgetPerHour": 100 }
16
+ },
17
+ "dailyCreate": {
18
+ "openCheck": "DELIVERY_OK / DELIVERYING 才继续,否则跳过",
19
+ "duration": "创建时刻 → 次日 01:00 的小时数",
20
+ "tasks": [
21
+ { "name": "直投-放", "material": "直播间画面素材", "mode": "放量" },
22
+ { "name": "主-放", "material": "近3天 · 消耗降序 · ROI≥平均×80% · 前9条", "mode": "放量" },
23
+ { "name": "次-放", "material": "近3天 · 消耗降序 · ROI≥平均×80% · 第10~18条", "mode": "放量" }
24
+ ],
25
+ "budget": "时长 × 100",
26
+ "disabled": ["高ROI-放"]
27
+ },
28
+ "monitorRules": [
29
+ { "id": "R4", "name": "ROI过低", "condition": "总ROI < 素材平均×50%,累计消耗≥500", "action": "删除重建(首次确认)" },
30
+ { "id": "R5", "name": "加预算", "condition": "控成本:消耗>预算×80% 且 ROI≥10;放量:成交÷预算≥9", "action": "控成本 +1000;放量 +500;单日限4次" },
31
+ { "id": "R6", "name": "控成本调价", "condition": "控成本:Δ<上一个小时消耗×25% → 出价×1.066;Δ>75% → 出价×0.934", "action": "取整;自动执行" },
32
+ { "id": "R7", "name": "控成本超2小时低ROI", "condition": "控成本:消耗时长>2h 且 总ROI<素材平均×70%", "action": "删除重建(首次确认)" },
33
+ { "id": "R8", "name": "连续4次无新增成交", "condition": "所有任务:连续4次巡检成交无新增", "action": "删除重建(首次确认)" }
34
+ ],
35
+ "guards": {
36
+ "bidMin": 250,
37
+ "bidMax": 350,
38
+ "maxRebuildPerTaskPerDay": 6,
39
+ "maxBudgetAddPerTaskPerDay": 4,
40
+ "readonlyWindow": "00:00-05:59",
41
+ "ledgerPath": "data/ops_ledger.jsonl"
42
+ },
43
+ "execution": {
44
+ "R4": { "mode": "confirm_first" },
45
+ "R5": { "mode": "auto" },
46
+ "R6": { "mode": "auto" },
47
+ "R7": { "mode": "confirm_first" },
48
+ "R8": { "mode": "confirm_first" },
49
+ "dailyCreate": { "mode": "confirm_first" }
50
+ }
51
+ }
package/icon.svg ADDED
@@ -0,0 +1,14 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" viewBox="0 0 128 128" role="img" aria-label="Qianchuan auto delivery">
2
+ <defs>
3
+ <linearGradient id="bg" x1="0" y1="0" x2="1" y2="1">
4
+ <stop offset="0" stop-color="#4f7cff"/>
5
+ <stop offset="1" stop-color="#7a5cff"/>
6
+ </linearGradient>
7
+ </defs>
8
+ <rect x="4" y="4" width="120" height="120" rx="28" fill="url(#bg)"/>
9
+ <path d="M28 88 L52 62 L66 72 L92 42" fill="none" stroke="#ffffff" stroke-width="10" stroke-linecap="round" stroke-linejoin="round"/>
10
+ <path d="M76 42 L92 42 L92 58" fill="none" stroke="#ffffff" stroke-width="10" stroke-linecap="round" stroke-linejoin="round"/>
11
+ <circle cx="52" cy="62" r="6" fill="#ffffff"/>
12
+ <circle cx="66" cy="72" r="6" fill="#ffffff"/>
13
+ <circle cx="92" cy="42" r="6" fill="#ffffff"/>
14
+ </svg>