Skip to content

fix(list): preserve flow-style skill metadata when toggling manual invocation - #970

Merged
runkids merged 5 commits into
runkids:mainfrom
salmonumbrella:fix/okf-v03-flow-invocation-v2
Nov 21, 2026
Merged

runkids merged 5 commits into
runkids:mainfrom
salmonumbrella:fix/okf-v03-flow-invocation-v2

Conversation

@salmonumbrella

@salmonumbrella salmonumbrella commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Type

  • Bug fix
  • Small improvement (docs, typo, minor refactor)
  • Feature proposal (proposals/ only — see CONTRIBUTING.md)
  • Approved feature or large change (the linked issue has the approved label)

What changed

  • When a skill's frontmatter is a flow-style mapping ({name: demo, metadata: {...}}), toggling disable-model-invocation (the m key in skillshare list) now makes one edit inside that mapping. It checks that the parsed result changes only that flag before writing, so nested metadata, comments, BOM, CRLF and the body are preserved.
  • If the flag is absent, the toggle inserts disable-model-invocation: true as the first entry (followed by , unless the mapping is empty). A first entry in that inserted form is removed on the next toggle, so absent -> on -> off restores the original bytes. An existing flag is removed when its current bytes match that first-entry form; otherwise its value is replaced in place. An explicit false is therefore not guaranteed to be restored.

Why

With a flow-style root, the toggle appended disable-model-invocation: true as a separate line after the {...} mapping. A line added outside the flow mapping doesn't set a root flag that the parser can read, and it can make the frontmatter invalid.

Not covered

  • Flag values the toggle can't edit safely, such as escaped spellings, aliases or merge-key flags, may be refused with an error and no write for that toggle. A flag inherited through a merge key can accept the first edit and then refuse to switch off. The list TUI doesn't show the error.
  • If the frontmatter is on a single line longer than 64 KiB, the existing reader's line limit can hide the manual-only state.

Usage

No usage change.

Testing

make check was not run. Only focused tests were run, in the devcontainer, and all four commands passed:

go test ./internal/utils -run 'ToggleFrontmatterFlag|ParseFrontmatterMap|SetFrontmatterValue' -count=1
go test ./internal/utils -run 'Flag|Frontmatter|Strict' -count=1
go test ./internal/sourcefs ./internal/sourcewalk -run 'Ratchet|Guard|Raw|Write' -count=1
go test ./cmd/skillshare -run 'TestModelInvocationKey|TestRenderDetailHeader_ShowsManualOnlyChip' -count=1

Checklist

  • I've read CONTRIBUTING.md, including its AI-assisted contributions section (pending author confirmation)
  • I've reviewed every line of the diff and can explain it (pending author confirmation)
  • Tests included and passing (make check) — for code changes
  • No unrelated changes in the diff
  • Scope is focused — one concern per PR

Refs #894

Edit flow flags without rewriting metadata, and verify the resulting map
before writing so unusual source forms cannot corrupt the skill. Preserve
exact bytes when reversing an inserted flag and keep existing flags operable
across multiline layouts and comments.
Count YAML line breaks when translating node positions so valid metadata
with Unicode separators does not block toggling or misplace the edit.
@salmonumbrella

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T15:00:23.280343Z f536ca2 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Use the existing first-match helper for flag values and inspect the first
entry directly, avoiding a duplicate search without changing toggle behavior.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 5dbced01f1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@salmonumbrella

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 82bd14fda2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@runkids

runkids commented Nov 20, 2026

Copy link
Copy Markdown
Owner

Thanks @salmonumbrella. The flow-root edit and the re-parse check hold up: the claims in the description match the code and tests, and nested metadata from #894 is untouched by a toggle.

Could you change a few things before we merge?

  1. Show the refusal in the list TUI. toggleModelInvocation (cmd/skillshare/list_tui.go:620) drops the error, so when the helper refuses a flow root, m does nothing and says nothing. For a skill in a tracked repo the user first accepts the "This edits SKILL.md…" prompt, then nothing happens. The refusal is new in this PR, so please surface it (for example as a status message) and add a test for it.
  2. The flow path refuses files the block path accepts. splitFrontmatterLines accepts an opening --- with trailing spaces or blank lines before it, but ParseFrontmatterMap uses strictBlock, so toggleFlowFlag always fails for those files. Either check with the same delimiter rule or make sure item 1's message covers it.
  3. Test table: TestToggleFrontmatterFlag_FlowRoot picks CRLF handling by case name (tc.name == "BOM CRLF comments" || …, line 135). Please make that a table field. Several rows also overlap (last / last trailing / only trailing, the three Unicode line-break rows, quoted true and false); one row per behaviour is enough.
  4. Checklist: please confirm the two author boxes (CONTRIBUTING.md and "reviewed every line") yourself.

Optional, not blocking: at() rebuilds the joined prefix on every call (up to three per toggle), and a toggle parses the YAML three times. Line-start offsets computed once would simplify it.

Show why a safe SKILL.md edit was refused so a direct toggle or a confirmed tracked-repo toggle no longer looks like a no-op. Keep the strict flow delimiter check and tell users how to fix the delimiters without rewriting their files.

Cover the visible refusal in the list TUI and consolidate equivalent flow cases with an explicit BOM/CRLF fixture field.
@runkids

runkids commented Nov 20, 2026

Copy link
Copy Markdown
Owner

Thanks @salmonumbrella, f536ca2 covers items 1-3: the refusal now shows on the note line (direct and after the tracked-repo prompt), the padded or late opener gets a message that says how to fix it, and the flow table uses a bomCRLF field with the overlapping rows gone.

One thing left before we merge: please tick the two author boxes in the description yourself (CONTRIBUTING.md and "reviewed every line"); they still say "pending author confirmation".

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: f536ca2b52

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@runkids
runkids merged commit 96de20e into runkids:main Nov 21, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants