Documentation
¶
Index ¶
- func InjectMarkdownSection(existing, sectionID, content string) string
- func MergeJSONObjects(baseJSON []byte, overlayJSON []byte) ([]byte, error)
- func StripLegacyATLBlock(content string) string
- func StripLegacyPersonaBlock(content string) string
- func UpsertCodexEngramBlock(content, engramCmd string) string
- func UpsertTopLevelTOMLString(content, key, value string) string
- type WriteResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InjectMarkdownSection ¶
InjectMarkdownSection replaces or appends a marked section in a markdown file. Markers use HTML comments: <!-- gentle-ai:SECTION_ID --> ... <!-- /gentle-ai:SECTION_ID --> If the section already exists, its content is replaced. If it doesn't exist, it's appended at the end. Content outside markers is never touched. If content is empty, the section (including markers) is removed.
Before injection, orphan markers (an unpaired closer or opener) are stripped so that a file corrupted by a previous buggy sync run is repaired in place rather than having another duplicate block appended.
func StripLegacyATLBlock ¶
StripLegacyATLBlock removes the legacy Agent Teams Lite block that was written by the standalone ATL installer before gentle-ai superseded it. The block is wrapped in <!-- BEGIN:agent-teams-lite --> / <!-- END:agent-teams-lite --> HTML comment markers. Its content is now provided by the canonical <!-- gentle-ai:sdd-orchestrator --> section, so keeping both wastes ~150 lines of context per conversation.
Safe to call on any file: returns content unchanged if no ATL block is found. All ATL blocks are stripped (not just the first one).
func StripLegacyPersonaBlock ¶
StripLegacyPersonaBlock removes a free-text Gentleman persona block that was written to a markdown file outside of <!-- gentle-ai: --> markers.
It is safe to call on any file: if no legacy block is detected, the original content is returned unchanged. Stripping requires ALL fingerprints to be present in the pre-marker zone (the region before the first <!-- gentle-ai: --> marker). A fingerprint that exists only inside a marker section is ignored — this prevents false positives when a user's own section headers happen to match one or two of the fingerprint strings while the remaining fingerprints live inside a managed marker block.
func UpsertCodexEngramBlock ¶
UpsertCodexEngramBlock removes any existing [mcp_servers.engram] block from the given TOML content and appends a fresh block with the canonical engram MCP entry (including --tools=agent). All other sections are preserved.
engramCmd is the command string to use (e.g. an absolute path like "/usr/local/bin/engram"). If engramCmd is empty, it falls back to "engram".
This is a string-based helper (no TOML parser dependency) ported from engram/internal/setup/setup.go. It handles the limited TOML subset that Codex uses.
func UpsertTopLevelTOMLString ¶
UpsertTopLevelTOMLString inserts or replaces a top-level key = "value" pair in TOML content. The key is placed before the first [section] header so it remains a top-level (non-table) setting. Existing occurrences of the key are removed before inserting the new value (idempotent).
Ported from engram/internal/setup/setup.go.