schema

package
v0.6.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const PageSchemaV1 = "ctx.page.v1"

Variables

This section is empty.

Functions

func SanitizeContent added in v0.5.0

func SanitizeContent(s string) string

SanitizeContent removes characters that have no legitimate place in a knowledge page and are classic prompt-injection obfuscation vectors: terminal/ANSI escapes and other C0/C1 control codes (tab, newline, and carriage return are kept), Unicode bidirectional overrides, and zero-width / invisible characters. All visible text is preserved.

It is applied to shared page content before it reaches a consuming agent, so an attacker cannot smuggle hidden instructions (e.g. via a bidi override or a zero-width-spaced "ignore previous instructions") into a teammate's context.

func SerializePage

func SerializePage(p *Page) ([]byte, error)

SerializePage writes a Page to bytes with frontmatter + body, always LF line endings.

Types

type Page

type Page struct {
	Frontmatter PageFrontmatter
	Body        string
}

func ParsePage

func ParsePage(data []byte) (*Page, error)

ParsePage reads a markdown file with YAML frontmatter and returns a Page. Accepts LF or CRLF line endings on input.

type PageFrontmatter

type PageFrontmatter struct {
	Schema           string    `yaml:"schema"`
	Slug             string    `yaml:"slug"`
	Type             PageType  `yaml:"type"`
	Author           string    `yaml:"author"`
	Agent            string    `yaml:"agent,omitempty"`
	Created          time.Time `yaml:"created"`
	Updated          time.Time `yaml:"updated"`
	ParentSHA        string    `yaml:"parent_sha"`
	Sources          []string  `yaml:"sources,omitempty"`
	Related          []string  `yaml:"related,omitempty"`
	Tags             []string  `yaml:"tags,omitempty"`
	ReasoningSummary string    `yaml:"reasoning_summary,omitempty"`
}

func (*PageFrontmatter) RelPath

func (fm *PageFrontmatter) RelPath() string

RelPath returns the path under .contexo/ where a page of this type and slug lives.

func (*PageFrontmatter) Validate

func (fm *PageFrontmatter) Validate() error

type PageType

type PageType string
const (
	TypeConcept  PageType = "concept"
	TypeEntity   PageType = "entity"
	TypeSource   PageType = "source"
	TypeAnalysis PageType = "analysis"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL