Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(desktop): tighten built-in skill contracts

xd-bobo1a0b108b3ce8
diff --git a/apps/desktop/resources/system-skills/cindy-skill-creator/scripts/_frontmatter.py b/apps/desktop/resources/system-skills/cindy-skill-creator/scripts/_frontmatter.py
index 9f2353b2bb..494e1f84ed 100644
--- a/apps/desktop/resources/system-skills/cindy-skill-creator/scripts/_frontmatter.py
+++ b/apps/desktop/resources/system-skills/cindy-skill-creator/scripts/_frontmatter.py
@@ -155,16 +155,16 @@ def _validate_flow_mapping_entry(value, required):
if mapping_entry is None:
if required:
raise FrontmatterError("Flow mapping entry is missing ':'")
- _parse_scalar(value)
+ _parse_scalar(value, in_flow=True)
return
raw_key, raw_value = mapping_entry
if not raw_key.strip():
raise FrontmatterError("Flow mapping entry is missing a key")
- key = _parse_scalar(raw_key.strip())
+ key = _parse_scalar(raw_key.strip(), in_flow=True)
if not isinstance(key, (str, int, float, bool)):
raise FrontmatterError("Invalid flow mapping key")
- _parse_scalar(raw_value.strip())
+ _parse_scalar(raw_value.strip(), in_flow=True)
def _parse_flow_collection(value):
@@ -175,7 +175,7 @@ def _parse_flow_collection(value):
return {} if is_mapping else []
-def _parse_scalar(raw):
+def _parse_scalar(raw, in_flow=False):
value = _strip_plain_comment(raw)
if value.startswith('"'):
try:
@@ -214,6 +214,8 @@ def _parse_scalar(raw):
# so valid YAML bare scalars such as [Read, Grep] and {owner: me} do not
# require PyYAML or JSON syntax.
return _parse_flow_collection(value)
+ if in_flow and re.search(r"[\[\]{},]", value):
+ raise FrontmatterError("Plain flow scalar contains an unquoted delimiter")
if re.match(r"^(?:[-?:](?:[ \t]|$)|[,\]\}#&*!|>'\"%@`])", value):
raise FrontmatterError("Invalid leading indicator in plain scalar")
if re.search(r":[ \t]|:$", value):
diff --git a/apps/desktop/resources/system-skills/learn/SKILL.md b/apps/desktop/resources/system-skills/learn/SKILL.md
index b2f175483f..056db449a8 100644
--- a/apps/desktop/resources/system-skills/learn/SKILL.md
+++ b/apps/desktop/resources/system-skills/learn/SKILL.md
@@ -1,6 +1,6 @@
---
name: learn
-description: Distill a reusable Cindy Skill from the current task, a described workflow, or a SkillHub skill through Cindy's review flow when the user invokes /learn or explicitly asks to start Learn.
+description: Distill a reusable Cindy Skill from the current task, a described workflow, or a SkillHub skill through Cindy's review flow when the user directly invokes /learn or /skill:learn in Pi.
---
# Learn
diff --git a/apps/desktop/src/main/maker-host/__tests__/built-in-skills.test.ts b/apps/desktop/src/main/maker-host/__tests__/built-in-skills.test.ts
index 570bd64337..843d122018 100644
--- a/apps/desktop/src/main/maker-host/__tests__/built-in-skills.test.ts
+++ b/apps/desktop/src/main/maker-host/__tests__/built-in-skills.test.ts
@@ -79,7 +79,7 @@ describe('built-in Skills', () => {
);
fs.appendFileSync(path.join(input.source, 'SKILL.md'), '\nUpdated\n');
- const updated = await prepareBuiltInSkills({ ...input, bundleVersion: 2 });
+ const updated = await prepareBuiltInSkills({ ...input, bundleVersion: 3 });
expect(updated.changed).toBe(true);
expect(fs.readFileSync(path.join(descriptor.absolutePath, 'SKILL.md'), 'utf8')).toContain(
'Updated',
@@ -117,21 +117,21 @@ describe('built-in Skills', () => {
path.join(input.bundledRoot, 'learn', 'SKILL.md.missing'),
);
- const partial = await prepareBuiltInSkills({ ...input, bundleVersion: 2 });
+ const partial = await prepareBuiltInSkills({ ...input, bundleVersion: 3 });
const manifestPath = path.join(
path.dirname(partial.descriptors[0]!.absolutePath),
'.cindy-system-skills.json',
);
- expect(JSON.parse(fs.readFileSync(manifestPath, 'utf8')).bundleVersion).toBe(1);
+ expect(JSON.parse(fs.readFileSync(manifestPath, 'utf8')).bundleVersion).toBe(2);
expect(partial.warnings.join('\n')).toContain('missing SKILL.md');
fs.renameSync(
path.join(input.bundledRoot, 'learn', 'SKILL.md.missing'),
path.join(input.bundledRoot, 'learn', 'SKILL.md'),
);
- const retried = await prepareBuiltInSkills({ ...input, bundleVersion: 2 });
+ const retried = await prepareBuiltInSkills({ ...input, bundleVersion: 3 });
expect(retried.warnings).toEqual([]);
- expect(JSON.parse(fs.readFileSync(manifestPath, 'utf8')).bundleVersion).toBe(2);
+ expect(JSON.parse(fs.readFileSync(manifestPath, 'utf8')).bundleVersion).toBe(3);
expect(fs.readFileSync(path.join(
retried.descriptors.find((descriptor) => descriptor.name === 'learn')!.absolutePath,
'SKILL.md',
diff --git a/apps/desktop/src/main/maker-host/built-in-skills.ts b/apps/desktop/src/main/maker-host/built-in-skills.ts
index 8e05ad67cf..e976de9645 100644
--- a/apps/desktop/src/main/maker-host/built-in-skills.ts
+++ b/apps/desktop/src/main/maker-host/built-in-skills.ts
@@ -18,7 +18,7 @@ const BUILT_IN_SKILL_NAMES = [BUILT_IN_SKILL_CREATOR_NAME, BUILT_IN_LEARN_SKILL_
const MANIFEST_FILE = '.cindy-system-skills.json';
const BUILT_IN_SKILL_MUTATION_WAIT_MS = 5_000;
/** Increment whenever shipped built-in Skill bytes change between releases. */
-export const BUILT_IN_SKILLS_BUNDLE_VERSION = 1;
+export const BUILT_IN_SKILLS_BUNDLE_VERSION = 2;
export interface BuiltInSkillDescriptor {
name: string;
diff --git a/apps/desktop/src/shared/cindyBuiltInSkills.ts b/apps/desktop/src/shared/cindyBuiltInSkills.ts
index 1dadcf6b89..2aa7a6d62e 100644
--- a/apps/desktop/src/shared/cindyBuiltInSkills.ts
+++ b/apps/desktop/src/shared/cindyBuiltInSkills.ts
@@ -2,7 +2,7 @@ export const CINDY_SKILL_CREATOR_NAME = 'cindy-skill-creator';
export const CINDY_LEARN_NAME = 'learn';
export const CINDY_LEARN_SOURCE_DESCRIPTION =
- "Distill a reusable Cindy Skill from the current task, a described workflow, or a SkillHub skill through Cindy's review flow when the user invokes /learn or explicitly asks to start Learn.";
+ "Distill a reusable Cindy Skill from the current task, a described workflow, or a SkillHub skill through Cindy's review flow when the user directly invokes /learn or /skill:learn in Pi.";
const CINDY_BUILT_IN_NAMES = new Set([CINDY_SKILL_CREATOR_NAME, CINDY_LEARN_NAME]);