Repository navigation
feat(sync): add the adapter core and the Markdown adapter - #988
Conversation
31e85d7 to
6cd3884
Compare
6cd3884 to
f17e19b
Compare
f17e19b to
506ef88
Compare
506ef88 to
32c01cd
Compare
32c01cd to
595a360
Compare
595a360 to
21dc118
Compare
There was a problem hiding this comment.
This doesn't seem to be used in this PR. we could move it to it's first reference #992 - or keep it. It seems reasonable to have this in place for later testing.
There was a problem hiding this comment.
Good call. The package now lands in #992 with the conformance tests, which are its only user. I updated both descriptions.
| "github.com/stretchr/testify/require" | ||
| "gopkg.in/yaml.v3" | ||
| ) | ||
|
|
There was a problem hiding this comment.
IMO, a nit that claude helped me find, but does crash the yaml reader given valid yaml:
yamlValueNode sends every !!int and !!float through strconv.ParseFloat (yamltree.go:252). That function rejects some valid YAML numbers, such as 0x10, 0o17, .inf, -.inf and .nan. All my test numbers cause it to crash file read with:
strconv.ParseFloat: parsing "0x10": invalid syntax (and the same error for the others).`
This is the test I ran to confirm the issue. It needs "github.com/launchdarkly/ldcli/internal/sync/adapter" in the imports):
func buildDocument(t *testing.T, source string) (*adapter.Node, error) {
t.Helper()
var document yaml.Node
require.NoError(t, yaml.Unmarshal([]byte(source), &document))
return Build([]byte(source), document.Content[0], 0, false)
}
func TestValidYAMLNumbersDoNotFailTheDocument(t *testing.T) {
for _, value := range []string{"0x10", "0o17", ".inf", "-.inf", ".nan"} {
t.Run(value, func(t *testing.T) {
root, err := buildDocument(t, "limit: "+value+"\nname: kept\n")
require.NoError(t, err)
assert.Equal(t, "kept", root.Fields["name"].Value)
})
}
}There was a problem hiding this comment.
Thanks for the test. Hex and octal now decode through the YAML library, so they are plain numbers. Infinity and NaN decode too, but they have no JSON form, so the builder keeps them as read-only text instead of a number that would fail later in a fingerprint. Your test is in yamltree_test.go as TestValidYAMLNumbersDoNotFailTheDocument, with the read-only check added.
21dc118 to
dc5f291
Compare
c783601 to
bb5ff9c
Compare
bb5ff9c to
d501e74
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit d501e74. Configure here.
Add the adapter contract: a format turns source bytes into a tree of logical nodes, and the core resolves select and map paths, builds projections, and plans exact edits. Add the YAML tree, the Markdown adapter with front matter, sections, and markers, and the Agent Skill adapter. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
d501e74 to
7abc71a
Compare

Context
Every source format needs the same contract. The shared core owns path resolution, projection building, and edit planning, so an adapter cannot get them wrong.
What changes
AGENTS.md,CLAUDE.md, Cursor rules, and Copilot instructions.Design notes
Parseis mode-agnostic. The planner converts the prompt to the mode of the config.Review focus
Verification
make buildgo test ./...golangci-lint run ./...Related changes
🤖 Generated with Claude Code
Note
Overview
Introduces
internal/sync/adapter, the shared layer between the sync engine and per-format parsers: registeredAdapterimplementations turn aSourceBundleinto a logicalNodetree with byte spans and encoders, while the core owns select/map path parsing and resolution, descriptor normalization, typed projections (variation, tool, skill), indexed-selection fingerprints, andUpdateSourceplanning of **TextEdit**s with read-only fallbacks when structure or capabilities block writes.Adds
yamltreefor YAML→nodes with exact scalar spans (shared by front matter and future YAML support), marking structural YAML, aliases, merge keys, and non-exact scalars read-only where appropriate.Adds
markdownandagent-skillformats: documents expose frontmatter, body, sections, and LaunchDarkly marker regions, with fenced/indented-code-aware parsing;markdowndefaults variation prompts tobody,agent-skillvalidates SKILL.md front matter and maps description + body for skills. Includes testdata/golden fixtures for common agent instruction file shapes.Reviewed by Cursor Bugbot for commit 7abc71a. Bugbot is set up for automated code reviews on this repo. Configure here.