yuanflow-cli 0.1.15 → 0.1.16
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
|
@@ -127,6 +127,8 @@ yuanflow-cli knowledge rule-detail --rule-code some_rule_code --output-format sh
|
|
|
127
127
|
|
|
128
128
|
Agent 应先查看 `knowledge docs`,再把用户需求整理成 `task_frame`,按接口返回的 `next_actions` 渐进查询。v2 接口不要求 `task_intent`;旧字段仅保留兼容。`packs`、`rules` 的 `data` 可能直接是数组,Agent 不应假设固定对象结构,应优先读取 `next_actions` 继续下钻。
|
|
129
129
|
|
|
130
|
+
`knowledge entry`、`knowledge packs`、`knowledge evaluate` 会按规则库实际校验要求本地检查 `task_frame.domain` 和 `task_frame.content_goal`,CLI 调用时必须传 `--domain` 和 `--content-goal`,或通过 `--task-frame-file` 提供同名字段。`rules` 和 `rule-detail` 用于按已选包/规则继续下钻,仍必须分别传 `--pack-code` 或 `--rule-code`。
|
|
131
|
+
|
|
130
132
|
### OSS 原子能力
|
|
131
133
|
|
|
132
134
|
OSS 能力独立封装为 `oss` 命令,用于临时上传、签名链接和对象复制:
|
package/package.json
CHANGED
|
@@ -46,7 +46,7 @@ description: 当用户需要做自媒体选题、开头钩子、脚本、文案
|
|
|
46
46
|
yuanflow-cli knowledge docs --format agent-json
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
2. 把用户需求整理为 `task_frame
|
|
49
|
+
2. 把用户需求整理为 `task_frame`,再进入知识库。`task_frame.domain` 和 `task_frame.content_goal` 是规则库实际要求的必填字段,CLI 调用时必须传 `--domain` 和 `--content-goal`,不要用空字符串占位:
|
|
50
50
|
|
|
51
51
|
```bash
|
|
52
52
|
yuanflow-cli knowledge entry \
|
|
@@ -100,6 +100,7 @@ yuanflow-cli knowledge rules \
|
|
|
100
100
|
- 不要让 Agent 自己拼 SQL。
|
|
101
101
|
- 不要使用 `/atomic/aliyun-db/query` 查询知识库内部表。
|
|
102
102
|
- 不要把知识库核心方法论静态写入回复,只按接口返回内容使用。
|
|
103
|
+
- `knowledge entry`、`knowledge packs`、`knowledge evaluate` 必须提供 `--domain` 和 `--content-goal`;也可以用 `--task-frame-file` 提供同名字段。
|
|
103
104
|
- 如果接口返回 `next_actions`,优先按它推荐的动作继续查询。
|
|
104
105
|
- v2 接口不要求 `task_intent`;旧字段只作为兼容字段,不要在新调用里默认填写。
|
|
105
106
|
- `packs`、`rules` 的 `data` 可能直接是数组,不要假设固定 `{ packs: [] }` 或 `{ rules: [] }` 结构。
|
package/src/knowledge-tools.js
CHANGED
|
@@ -46,10 +46,12 @@ export async function getKnowledgeDocs({ options }) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
export async function navigateKnowledge({ action, options }) {
|
|
49
|
+
const normalizedAction = normalizeAction(action);
|
|
49
50
|
const taskFrame = await buildTaskFrame(options);
|
|
50
51
|
const params = buildParams(action, options);
|
|
52
|
+
validateTaskFrame(normalizedAction, taskFrame);
|
|
51
53
|
const body = {
|
|
52
|
-
action:
|
|
54
|
+
action: normalizedAction,
|
|
53
55
|
task_frame: taskFrame,
|
|
54
56
|
params,
|
|
55
57
|
};
|
|
@@ -60,7 +62,7 @@ export async function navigateKnowledge({ action, options }) {
|
|
|
60
62
|
});
|
|
61
63
|
return {
|
|
62
64
|
ok: true,
|
|
63
|
-
action:
|
|
65
|
+
action: normalizedAction,
|
|
64
66
|
endpoint: { method: 'POST', path: KNOWLEDGE_NAVIGATE_PATH, kind: 'knowledge-base' },
|
|
65
67
|
request: { body },
|
|
66
68
|
response,
|
|
@@ -95,7 +97,7 @@ function taskFrameOptions() {
|
|
|
95
97
|
{ flag: '--task-intent', name: 'taskIntent', required: false, label: '兼容旧字段;v2 接口不要求填写。' },
|
|
96
98
|
{ flag: '--output-format', name: 'outputFormat', required: false, label: '输出格式,例如 short_video_script、social_post、any。' },
|
|
97
99
|
{ flag: '--domain', name: 'domain', required: false, label: '内容领域。' },
|
|
98
|
-
{ flag: '--content-goal', name: 'contentGoal', required:
|
|
100
|
+
{ flag: '--content-goal', name: 'contentGoal', required: true, label: '具体创作或评估目标;等同 task_frame.content_goal,不能为空。' },
|
|
99
101
|
{ flag: '--target-audience', name: 'targetAudience', required: false, label: '目标受众,例如 创业者、宝妈、普通用户。' },
|
|
100
102
|
{ flag: '--tone', name: 'tone', required: false, label: '语气风格。' },
|
|
101
103
|
{ flag: '--communication-mode', name: 'communicationMode', required: false, label: '表达方式,例如 口播、图文、文章。' },
|
|
@@ -144,6 +146,21 @@ function buildParams(action, options) {
|
|
|
144
146
|
return params;
|
|
145
147
|
}
|
|
146
148
|
|
|
149
|
+
function validateTaskFrame(action, taskFrame) {
|
|
150
|
+
if (!taskFrame || typeof taskFrame !== 'object' || Array.isArray(taskFrame)) {
|
|
151
|
+
throw new Error('task_frame 必须是对象。');
|
|
152
|
+
}
|
|
153
|
+
if (!['entry', 'packs', 'evaluate'].includes(action)) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
if (!cleanOptional(taskFrame.domain)) {
|
|
157
|
+
throw new Error('缺少 --domain 或 task_frame.domain。');
|
|
158
|
+
}
|
|
159
|
+
if (!cleanOptional(taskFrame.content_goal)) {
|
|
160
|
+
throw new Error('缺少 --content-goal 或 task_frame.content_goal。');
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
147
164
|
function normalizeAction(action) {
|
|
148
165
|
return action === 'rule-detail' ? 'rule_detail' : action;
|
|
149
166
|
}
|