Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): validate nested block scalar indentation
xd-boboc9ef57175559
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.pyindex 8e86b45f80..80c84ffab4 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@@ -417,7 +417,7 @@ def _validate_nested_entry(text, line_number):)value = text[sequence_content_indent:] if sequence_entry else textif not value or value.startswith("#"):- return True, False, "sequence" if sequence_entry else "scalar"+ return True, False, False, "sequence" if sequence_entry else "scalar"mapping_entry = _split_mapping_entry(value)if mapping_entry is not None:@@ -429,28 +429,30 @@ def _validate_nested_entry(text, line_number):raise FrontmatterError(f"Invalid mapping key on line {line_number}")scalar_value = raw_value.lstrip()if not scalar_value or scalar_value.startswith("#"):- return True, False, "sequence" if sequence_entry else "mapping"+ return True, False, False, "sequence" if sequence_entry else "mapping"block_match = BLOCK_SCALAR_RE.match(scalar_value)if block_match:return (True,sequence_content_indent + (_block_indent_indicator(block_match) or 1),+ _block_indent_indicator(block_match) is None,"sequence" if sequence_entry else "mapping",)_parse_scalar(scalar_value)# A sequence item may start a mapping whose sibling keys are indented# beneath the dash even when this first key already has a value.- return sequence_entry, False, "sequence" if sequence_entry else "mapping"+ return sequence_entry, False, False, "sequence" if sequence_entry else "mapping"block_match = BLOCK_SCALAR_RE.match(value)if block_match:return (True,sequence_content_indent + (_block_indent_indicator(block_match) or 1),+ _block_indent_indicator(block_match) is None,"sequence" if sequence_entry else "scalar",)_parse_scalar(value)- return False, False, "sequence" if sequence_entry else "scalar"+ return False, False, False, "sequence" if sequence_entry else "scalar"def _parse_nested_block(lines, start):@@ -466,6 +468,7 @@ def _parse_nested_block(lines, start):previous_allows_child = Trueblock_scalar_parent_indent = Noneblock_scalar_required_indent = None+ block_scalar_indent_is_implicit = Falsecollection = Nonewhile cursor < len(lines):@@ -479,11 +482,15 @@ def _parse_nested_block(lines, start):stripped = line[indent:]if indent == 0:break- if stripped.startswith("#"):- cursor += 1- continueif block_scalar_parent_indent is not None:+ if block_scalar_indent_is_implicit and indent >= block_scalar_required_indent:+ # As at the top level, the first non-empty line fixes an+ # implicit block scalar's indentation for all remaining lines.+ block_scalar_required_indent = indent+ block_scalar_indent_is_implicit = False+ cursor += 1+ continueif indent >= block_scalar_required_indent:cursor += 1continue@@ -493,6 +500,11 @@ def _parse_nested_block(lines, start):)block_scalar_parent_indent = Noneblock_scalar_required_indent = None+ block_scalar_indent_is_implicit = False++ if stripped.startswith("#"):+ cursor += 1+ continueif not indent_levels:indent_levels.append([indent, None])@@ -507,7 +519,12 @@ def _parse_nested_block(lines, start):if not indent_levels or indent != indent_levels[-1][0]:raise FrontmatterError(f"Inconsistent indentation on line {cursor + 1}")- previous_allows_child, block_indent, entry_kind = _validate_nested_entry(+ (+ previous_allows_child,+ block_indent,+ block_indent_is_implicit,+ entry_kind,+ ) = _validate_nested_entry(stripped,cursor + 1,)@@ -518,6 +535,7 @@ def _parse_nested_block(lines, start):if block_indent is not False:block_scalar_parent_indent = indentblock_scalar_required_indent = indent + block_indent+ block_scalar_indent_is_implicit = block_indent_is_implicitcursor += 1return collection, cursordiff --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.tsindex 6116f47911..4bf3431c24 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@@ -105,7 +105,7 @@ describe('built-in Skills', () => {);fs.appendFileSync(path.join(input.source, 'SKILL.md'), '\nUpdated\n');- const updated = await prepareAndProjectBuiltInSkills({ ...input, bundleVersion: 6 });+ const updated = await prepareAndProjectBuiltInSkills({ ...input, bundleVersion: 7 });expect(updated.changed).toBe(true);expect(fs.readFileSync(path.join(descriptor.absolutePath, 'SKILL.md'), 'utf8')).toContain('Updated',@@ -206,12 +206,12 @@ describe('built-in Skills', () => {path.join(input.bundledRoot, 'learn', 'SKILL.md.missing'),);- const partial = await prepareBuiltInSkills({ ...input, bundleVersion: 6 });+ const partial = await prepareBuiltInSkills({ ...input, bundleVersion: 7 });const manifestPath = path.join(path.dirname(partial.descriptors[0]!.absolutePath),'.cindy-system-skills.json',);- expect(JSON.parse(fs.readFileSync(manifestPath, 'utf8')).bundleVersion).toBe(5);+ expect(JSON.parse(fs.readFileSync(manifestPath, 'utf8')).bundleVersion).toBe(6);expect(partial.warnings.join('\n')).toContain('missing SKILL.md');expect(fs.readFileSync(path.join(partial.descriptors[0]!.absolutePath, 'SKILL.md'), 'utf8'),@@ -221,9 +221,9 @@ describe('built-in Skills', () => {path.join(input.bundledRoot, 'learn', 'SKILL.md.missing'),path.join(input.bundledRoot, 'learn', 'SKILL.md'),);- const retried = await prepareBuiltInSkills({ ...input, bundleVersion: 6 });+ const retried = await prepareBuiltInSkills({ ...input, bundleVersion: 7 });expect(retried.warnings).toEqual([]);- expect(JSON.parse(fs.readFileSync(manifestPath, 'utf8')).bundleVersion).toBe(6);+ expect(JSON.parse(fs.readFileSync(manifestPath, 'utf8')).bundleVersion).toBe(7);expect(fs.readFileSync(path.join(diff --git a/apps/desktop/src/main/maker-host/built-in-skills.ts b/apps/desktop/src/main/maker-host/built-in-skills.tsindex c85ff55ed0..7cfedd148d 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 = 5;+export const BUILT_IN_SKILLS_BUNDLE_VERSION = 6;export interface BuiltInSkillDescriptor {name: string;