Skip to content

Commit 8e85c87

Browse files
author
CodeBuddy Attribution Bot
committed
fix(attribution): Write 工具错误提示缺乏引导性,导致模型无法正确转换数据类型 (issue_mnrlm3si_7cqccf)
1 parent e04dbc5 commit 8e85c87

7 files changed

Lines changed: 15 additions & 4 deletions

File tree

config/codebuddy-plugin/rules/cloudbase_rules.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ updatedAt: 2026-03-27T00:00:00.000Z
3636
**2.2 工具结果写文件时先序列化**
3737
- 当使用通用写文件工具把 MCP 或其他工具结果保存到本地文件时,`content` 必须是字符串,不能直接传对象。
3838
- 如果目标文件是 JSON,先执行 `JSON.stringify(result, null, 2)`,再把返回的字符串写入文件。
39-
- 如果写文件工具提示 `content` 之类的参数期望 `string` 却收到了 `object`,不要原样重试;先序列化对象,再重试一次。
39+
- 如果写文件工具提示 `content` 之类的参数期望 `string` 却收到了 `object`,不要原样重试;先序列化对象,再重试一次,并确保重试时真正传入的是序列化后的字符串,而不是原始对象
4040

4141
**3. 认证区分平台**
4242
- Web 项目使用 CloudBase Web SDK 内置认证(如 `auth.toDefaultLoginPage()`

config/source/editor-config/guides/cloudbase-rules.mdc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ When the workspace already contains an existing application with explicit TODO m
2727
- Login or registration request -> read `{auth-tool}` first, then the platform auth rule.
2828
- Keep auth domains separate: management-side login uses `auth`; app-side auth configuration uses `queryAppAuth` / `manageAppAuth`.
2929
- When writing MCP or tool results to a local file with a generic file-writing tool, pass text rather than raw objects. For JSON files, serialize first with `JSON.stringify(result, null, 2)` and write that string.
30-
- If the file-writing tool says a parameter such as `content` expected a string but received an object, do not retry with the same raw object. Serialize the object first, then retry once with the serialized text.
30+
- If the file-writing tool says a parameter such as `content` expected a string but received an object, do not retry with the same raw object. Serialize the object first, then retry once with the serialized text, and make sure the retried call actually passes the serialized string rather than the original object.
3131
- UI request -> read `rules/ui-design/rule.md` first and output the design specification before code.
3232
- Native App / Flutter / React Native request -> route to `{http-api}`, not Web SDK rules.
3333
- Cloud Function request -> route to `{cloud-functions}`, not `cloudrun-development`, unless the task explicitly needs container service behavior.

config/source/guideline/cloudbase/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ If a skill points to its own `references/...` files, keep following those relati
3737
- If the same implementation path fails 2-3 times, stop retrying and reroute. Re-check the selected platform skill, runtime, auth domain, permission model, and SDK boundary before editing more code.
3838
- Always specify `EnvId` explicitly in code, configuration, and command examples when initializing CloudBase clients or manager operations. Do not rely on the current CLI-selected environment, implicit defaults, or copied local state.
3939
- When saving MCP or tool results to a local file with a generic file-writing tool, pass text, not raw objects. For JSON output files, serialize first with `JSON.stringify(result, null, 2)` and write that string as the file content.
40-
- If the file-writing tool reports that a field such as `content` expected a string but received an object, do not retry with the same raw object. Serialize the object first, then retry once with the serialized text.
40+
- If the file-writing tool reports that a field such as `content` expected a string but received an object, do not retry with the same raw object. Serialize the object first, then retry once with the serialized text, and make sure the retried call actually passes the serialized string rather than the original object.
4141
- Keep scenario-specific pitfall lists in the matching child skills instead of expanding this entry file.
4242

4343
### High-priority routing

config/source/skills/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ alwaysApply: true
4040
- If the same path fails 2-3 times, stop retrying and reroute. Check platform skill, auth domain, runtime, and permission model before editing more code.
4141
- Always specify `EnvId` explicitly in code, configuration, and command examples when initializing CloudBase clients or manager operations. Do not rely on the current CLI-selected environment or implicit defaults.
4242
- When saving MCP or tool results to a local file with a generic file-writing tool, pass text, not raw objects. For JSON output files, serialize first with `JSON.stringify(result, null, 2)` and write that string as the file content.
43-
- If the file-writing tool reports that a field such as `content` expected a string but received an object, do not retry with the same raw object. Serialize the object first, then retry once with the serialized text.
43+
- If the file-writing tool reports that a field such as `content` expected a string but received an object, do not retry with the same raw object. Serialize the object first, then retry once with the serialized text, and make sure the retried call actually passes the serialized string rather than the original object.
4444

4545
### Do NOT use this as
4646

tests/build-allinone-skill.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ test.skipIf(!hasNode24ViaNvm())(
9292
expect(mainSkill).toContain('references/auth-web/SKILL.md');
9393
expect(mainSkill).toContain('## Activation Contract');
9494
expect(mainSkill).toContain('Provider status and publishable key');
95+
expect(mainSkill).toContain('Serialize the object first, then retry once with the serialized text');
96+
expect(mainSkill).toContain('actually passes the serialized string rather than the original object');
9597
},
9698
);
9799

tests/build-compat-config.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ test('buildCompatConfig generates compatibility artifacts from minimal sources',
4242
).toBe(compatGuide);
4343
expect(compatGuide).toContain('## Activation Contract');
4444
expect(compatGuide).toContain('Native App / raw HTTP');
45+
expect(compatGuide).toContain('Serialize the object first, then retry once with the serialized text');
46+
expect(compatGuide).toContain('actually passes the serialized string rather than the original object');
4547

4648
expect(
4749
fs.readFileSync(path.join(compatDir, 'rules', 'auth-web', 'rule.md'), 'utf8'),

tests/build-skills-repo.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ test('build-skills-repo publishes skills and guideline from minimal sources', ()
2828
),
2929
).toBe(true);
3030

31+
const guideline = fs.readFileSync(
32+
path.join(OUTPUT_DIR, 'skills', 'cloudbase-guidelines', 'SKILL.md'),
33+
'utf8',
34+
);
35+
expect(guideline).toContain('Serialize the object first, then retry once with the serialized text');
36+
expect(guideline).toContain('actually passes the serialized string rather than the original object');
37+
3138
const readme = fs.readFileSync(path.join(OUTPUT_DIR, 'README.md'), 'utf8');
3239
expect(readme).toContain('cloudbase-guidelines');
3340
expect(readme).toContain('auth-web');

0 commit comments

Comments
 (0)