content

package
v0.50.78 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package content provides content data helpers for harness file generation.

Package content provides skill transformation for multi-platform deployment.

Package content provides platform-specific reference replacement for skill content.

Package content는 스킬, 에이전트, 방법론 등 콘텐츠 정의 및 변환을 담당한다.

Index

Constants

View Source
const (
	SkillVisibilityShared       = "shared"
	SkillVisibilityCodexOnly    = "codex-only"
	SkillVisibilityOpenCodeOnly = "opencode-only"
	SkillVisibilityClaudeOnly   = "claude-only"
	SkillVisibilityExplicitOnly = "explicit-only"
)

Variables

This section is empty.

Functions

func ConvertAgentToPlatform

func ConvertAgentToPlatform(agent AgentDefinition, platform string) (string, error)

ConvertAgentToPlatform은 에이전트를 플랫폼 형식으로 변환한다. claude: .claude/agents/autopus/<name>.md codex: AGENTS.md 섹션 gemini: .gemini/skills/auto-agent-<name>/SKILL.md

func ConvertSkillToPlatform

func ConvertSkillToPlatform(skill SkillDefinition, platform string) (string, error)

ConvertSkillToPlatform은 스킬을 플랫폼 형식으로 변환한다. claude: .claude/skills/autopus/<name>.md codex: .codex/skills/auto-<name>/SKILL.md gemini: .gemini/skills/auto-<name>/SKILL.md (YAML frontmatter 포함)

func DetectPermissions

func DetectPermissions(projectRoot string, extra config.PermissionsConf) *adapter.PermissionSet

DetectPermissions는 프로젝트 루트를 분석하여 기본 권한을 생성한다.

func EmbeddedPath

func EmbeddedPath(parts ...string) string

EmbeddedPath builds slash-separated paths for embed.FS and normalizes Windows-style separators so the same lookup works cross-platform.

func FilterPlatformReferences

func FilterPlatformReferences(body string, platform string) string

FilterPlatformReferences removes platform-specific references from content. For Claude platform, content is returned unchanged. For other platforms, lines containing MCP calls, Agent() syntax, and .claude/ paths are removed.

func FormatActivationNotice

func FormatActivationNotice(results []ActivationResult) string

FormatActivationNotice formats an activation notice string for the given results. Returns an empty string when results is empty.

func FormatTransformReport added in v0.50.67

func FormatTransformReport(report *TransformReport) string

FormatTransformReport returns the user-facing platform transformation summary.

func GenerateAXInstruction

func GenerateAXInstruction() string

GenerateAXInstruction은 @AX 코드 어노테이션 규칙 지침을 생성한다.

func GenerateAllTemplates

func GenerateAllTemplates(contentDir, templateDir string) error

GenerateAllTemplates reads content sources and writes platform templates. contentDir is the path to the content/ directory (agents/, skills/ subdirs). templateDir is the path to the templates/ directory (codex/, gemini/ subdirs).

func GenerateConstraintInstruction

func GenerateConstraintInstruction(projectDir string, cfg config.ConstraintConf) string

GenerateConstraintInstruction produces the anti-pattern constraint section for agent prompt injection. Returns an empty string when constraints are disabled, the file is missing, or no patterns are defined.

func GenerateInstruction

func GenerateInstruction(def *MethodologyDef) string

GenerateInstruction은 방법론 정의에서 지침 텍스트를 생성한다. TDD: "테스트 전 코드 작성 시 거부" 규칙 포함 DDD: ANALYZE-PRESERVE-IMPROVE 사이클 DD: Discover→Define→Develop→Deliver

func GenerateIntentGateInstruction

func GenerateIntentGateInstruction(rules []IntentRule) string

GenerateIntentGateInstruction builds the intent gate instruction text from the provided routing rules, formatted for inclusion in a system prompt.

func GenerateRoutingInstruction

func GenerateRoutingInstruction(cfg config.RouterConf) string

GenerateRoutingInstruction은 RouterConf에서 라우팅 지침 텍스트를 생성한다.

func GenerateSkillActivationInstruction

func GenerateSkillActivationInstruction(results []ActivationResult) string

GenerateSkillActivationInstruction produces a supplementary instruction block that lists the auto-activated skills and their triggers for inclusion in the harness system prompt. Returns an empty string when results is empty.

func GenerateWorkflow

func GenerateWorkflow(cfg *config.HarnessConfig) (string, error)

GenerateWorkflow는 HarnessConfig에서 WORKFLOW.md를 생성한다.

func IsCompatible

func IsCompatible(meta SkillMeta, platform string) bool

IsCompatible checks whether a skill is compatible with the given platform. If platforms is empty/nil, the skill is compatible with all platforms (R6).

func IsCoreSkill

func IsCoreSkill(name string) bool

IsCoreSkill reports whether the canonical skill should remain in shared/core surfaces.

func IsGeneratedTemplatePath added in v0.50.73

func IsGeneratedTemplatePath(relPath string) bool

IsGeneratedTemplatePath reports whether GenerateAllTemplates owns relPath. Static command, prompt, rule, shared, and auto-* route templates are excluded so reverse drift checks can flag obsolete generated residue without treating hand-authored templates as deleted-source artifacts.

func MapEffort added in v0.40.52

func MapEffort(effort, platform string) string

MapEffort returns the platform-specific effort value for a source effort tier.

func MapModel

func MapModel(model, platform string) string

MapModel returns the platform-specific model name for a source model tier.

func NormalizeAgentReferences

func NormalizeAgentReferences(body, platform string) string

NormalizeAgentReferences applies platform-specific path fixes that should be preserved across generated agent surfaces.

func ReplacePlatformReferences

func ReplacePlatformReferences(body string, platform string) string

ReplacePlatformReferences replaces Claude-specific references with platform equivalents. For Claude platforms, content is returned unchanged (backward compat — S8).

func ReplaceToolReferences

func ReplaceToolReferences(body, platform string) string

ReplaceToolReferences applies R3 tool reference mappings to body text. Delegates to ReplacePlatformReferences as the single source of truth.

func ResolveCatalogSkillRefPath

func ResolveCatalogSkillRefPath(catalog *SkillCatalog, name, platform string, cfg *config.HarnessConfig) string

ResolveCatalogSkillRefPath resolves platform-native skill references from the registry graph.

func SaveState

func SaveState(path string, state *SessionState) error

SaveState는 세션 상태를 파일에 저장한다. ContextSummary는 최대 2000 토큰 제한을 적용한다.

func TransformAgentForCodex

func TransformAgentForCodex(src AgentSource) string

TransformAgentForCodex produces a Codex TOML template from an agent source. The output contains Go template variables ({{.ProjectName}}, etc.) for later rendering.

func TransformAgentForGemini

func TransformAgentForGemini(src AgentSource) string

TransformAgentForGemini produces a Gemini MD template from an agent source.

func TransformAgentForOpenCode

func TransformAgentForOpenCode(src AgentSource) string

TransformAgentForOpenCode produces an OpenCode markdown agent definition.

Types

type ActivationContext

type ActivationContext struct {
	// UserQuery is the raw text request from the user.
	UserQuery string
	// ActiveFiles is the list of files currently being edited or referenced.
	ActiveFiles []string
	// FileExtensions contains deduplicated file extensions present in ActiveFiles.
	FileExtensions []string
	// ProjectMarkers lists detected project root markers (e.g., go.mod, package.json).
	ProjectMarkers []string
	// Language is the inferred primary programming language for the session.
	Language string
}

ActivationContext holds the context derived from the user's query and active files. It is used by the activator to select relevant skills and agents.

func DetectContext

func DetectContext(query string, files []string) ActivationContext

DetectContext builds an ActivationContext from the user query and the active file list. It probes the filesystem for project markers using the directories of the active files as well as the current working directory.

type ActivationResult

type ActivationResult struct {
	// Skill is the matched skill definition.
	Skill SkillDefinition
	// Score is the normalized match confidence in the range [0.0, 1.0].
	Score float64
	// Reason describes why the skill was activated (e.g., "keyword: debug").
	Reason string
	// Source identifies the activation mechanism: "keyword", "regex", "context", or "intent".
	Source string
}

ActivationResult holds the outcome of a single skill match evaluation.

func ActivateSkills

func ActivateSkills(activator *SkillActivator, ctx ActivationContext) ([]ActivationResult, string)

ActivateSkills runs the full activation pipeline: match → resolve → format notice. It returns the activation results and a human-readable notice string. When autoActivate is disabled, Match returns nil and both return values are zero.

type AgentDefinition

type AgentDefinition struct {
	// Name은 에이전트 이름이다.
	Name string `yaml:"name"`
	// Role은 에이전트 역할 설명이다.
	Role string `yaml:"role"`
	// ModelTier는 에이전트가 사용하는 모델 티어이다 (opus, sonnet, haiku).
	ModelTier string `yaml:"model_tier"`
	// Category는 에이전트 카테고리이다.
	Category string `yaml:"category"`
	// Triggers는 에이전트 활성화 트리거이다.
	Triggers []string `yaml:"triggers"`
	// Skills는 에이전트가 사용하는 스킬 목록이다.
	Skills []string `yaml:"skills"`
	// Instructions는 에이전트 역할 지침이다.
	Instructions string `yaml:"-"`
}

AgentDefinition은 에이전트 정의이다.

func LoadAgents

func LoadAgents(dir string) ([]AgentDefinition, error)

LoadAgents는 디렉토리에서 에이전트 정의 파일을 로드한다.

func LoadAgentsFromFS

func LoadAgentsFromFS(fsys fs.FS, dir string) ([]AgentDefinition, error)

LoadAgentsFromFS loads agent definitions from an embedded filesystem.

type AgentSource

type AgentSource struct {
	Meta AgentSourceMeta
	Body string
}

AgentSource holds a parsed agent source file with metadata and body.

func LoadAgentSources

func LoadAgentSources(dir string) ([]AgentSource, error)

LoadAgentSources loads agent source files from a directory on disk.

func LoadAgentSourcesFromFS

func LoadAgentSourcesFromFS(fsys fs.FS, dir string) ([]AgentSource, error)

LoadAgentSourcesFromFS loads agent source files from an embedded filesystem.

type AgentSourceMeta

type AgentSourceMeta struct {
	Name           string   `yaml:"name"`
	Description    string   `yaml:"description"`
	Model          string   `yaml:"model"`
	Effort         string   `yaml:"effort"`
	Tools          string   `yaml:"tools"`
	PermissionMode string   `yaml:"permissionMode"`
	MaxTurns       int      `yaml:"maxTurns"`
	Skills         []string `yaml:"skills"`
}

AgentSourceMeta holds the richer frontmatter from content/agents/*.md source files. This is distinct from AgentDefinition which uses a simpler schema.

type AgentTransformer

type AgentTransformer struct {
	// contains filtered or unexported fields
}

AgentTransformer loads agent source .md files and transforms them for target platforms.

func NewAgentTransformer

func NewAgentTransformer(sources []AgentSource) *AgentTransformer

NewAgentTransformer creates a transformer from pre-loaded sources.

func (*AgentTransformer) Sources

func (t *AgentTransformer) Sources() []AgentSource

Sources returns the loaded agent sources.

type CatalogSkill

type CatalogSkill struct {
	Name           string
	Description    string
	Category       string
	SourcePath     string
	Bundles        []string
	Visibility     string
	CompileTargets []string
	Dependencies   []string
}

CatalogSkill is the registry-layer representation of a canonical skill.

type FileSizeExclusion

type FileSizeExclusion struct {
	Pattern     string // glob pattern, e.g. "*_generated.go"
	Description string // brief description
}

FileSizeExclusion represents a generated file pattern excluded from the file size limit.

func FileSizeExclusions

func FileSizeExclusions(stack, framework string) []FileSizeExclusion

FileSizeExclusions returns exclusion patterns for the given stack and framework. Common exclusions are always included first, followed by stack-specific patterns, then framework-specific patterns.

type GitHookScript

type GitHookScript struct {
	// Path는 훅 파일 경로이다.
	Path string
	// Content는 스크립트 내용이다.
	Content string
}

GitHookScript는 Git 훅 스크립트이다.

func GenerateHookConfigs

func GenerateHookConfigs(cfg config.HooksConf, platform string, supportsHooks bool) ([]adapter.HookConfig, []GitHookScript, error)

GenerateHookConfigs는 설정에 따라 훅 설정을 생성한다. supportsHooks가 true이면 CLI 훅 설정을 반환하고, false이면 .git/hooks/ 스크립트를 반환한다.

func GenerateProjectHookConfigs

func GenerateProjectHookConfigs(cfg *config.HarnessConfig, platform string, supportsHooks bool) ([]adapter.HookConfig, []GitHookScript, error)

GenerateProjectHookConfigs generates hooks with access to feature flags.

type IntentRule

type IntentRule struct {
	// Pattern is the matching pattern (regular expression).
	Pattern string
	// TargetSkill is the target skill name (mutually exclusive with TargetAgent).
	TargetSkill string
	// TargetAgent is the target agent name (mutually exclusive with TargetSkill).
	TargetAgent string
	// Priority is the rule evaluation order; higher values are evaluated first.
	Priority int
}

IntentRule defines a single intent routing rule.

func DefaultRules

func DefaultRules() []IntentRule

DefaultRules returns the built-in set of intent routing rules.

type MethodologyDef

type MethodologyDef struct {
	// Name은 방법론 이름이다.
	Name string `yaml:"name"`
	// Stages는 방법론 단계 목록이다.
	Stages []Stage `yaml:"stages"`
	// EnforceRules는 강제 적용 규칙이다.
	EnforceRules []string `yaml:"enforce_rules"`
	// ReviewGate는 리뷰 게이트 활성화 여부이다.
	ReviewGate bool `yaml:"review_gate"`
}

MethodologyDef는 방법론 정의이다.

func LoadMethodology

func LoadMethodology(path string) (*MethodologyDef, error)

LoadMethodology는 YAML 파일에서 방법론을 로드한다.

func LoadMethodologyFromFS

func LoadMethodologyFromFS(fsys fs.FS, path string) (*MethodologyDef, error)

LoadMethodologyFromFS loads methodology from an embedded filesystem.

type Phase

type Phase struct {
	// Name은 단계 이름이다.
	Name string
	// Description은 단계 설명이다.
	Description string
}

Phase는 워크플로우 단계이다.

type Policy

type Policy struct {
	// Description은 정책 설명이다.
	Description string
}

Policy는 워크플로우 정책이다.

type ProfileDefinition

type ProfileDefinition struct {
	Name          string   `yaml:"name"`
	Stack         string   `yaml:"stack"`
	Framework     string   `yaml:"framework,omitempty"`
	Extends       string   `yaml:"extends,omitempty"`
	Tools         []string `yaml:"tools,omitempty"`
	TestFramework string   `yaml:"test_framework,omitempty"`
	Linter        string   `yaml:"linter,omitempty"`
	Instructions  string   `yaml:"-"`
	Source        string   `yaml:"-"`
}

ProfileDefinition represents an executor profile loaded from a markdown file. @AX:ANCHOR [AUTO] @AX:REASON: core data type — ProfileDefinition is consumed by planner, executor, and setup; do not rename or restructure without coordinating all consumers

func ApplyCustomOverride

func ApplyCustomOverride(base, override ProfileDefinition) ProfileDefinition

ApplyCustomOverride performs a shallow merge of override onto base. Only non-zero override fields replace base fields. Instructions are never overridden.

func LoadProfilesFromDir

func LoadProfilesFromDir(dir string) ([]ProfileDefinition, error)

LoadProfilesFromDir loads profile definitions from an OS filesystem directory.

func LoadProfilesFromFS

func LoadProfilesFromFS(fsys fs.FS, dir string) ([]ProfileDefinition, error)

LoadProfilesFromFS loads profile definitions from an embedded filesystem.

func LoadProfilesFromFSWithWarnings

func LoadProfilesFromFSWithWarnings(fsys fs.FS, dir string) ([]ProfileDefinition, []string, error)

LoadProfilesFromFSWithWarnings loads profiles and returns warnings for skipped files. @AX:NOTE [AUTO] @AX:REASON: public API boundary — primary profile loading entry point; R11 validation (skip missing name/stack) happens inside parseProfileData

func ResolveExtendsProfile

func ResolveExtendsProfile(profile ProfileDefinition, allProfiles map[string]ProfileDefinition) (ProfileDefinition, error)

ResolveExtendsProfile resolves extends inheritance for a profile. Base Instructions are prepended; child frontmatter fields override base.

func SelectProfile

func SelectProfile(profiles []ProfileDefinition, stack, framework string) (ProfileDefinition, bool)

SelectProfile selects the best matching profile by stack and framework. Priority: framework profile > language profile. @AX:NOTE [AUTO] @AX:REASON: design choice — R3 priority order (framework > language > none); changing order breaks profile assignment semantics

func SelectProfileWithConf

func SelectProfileWithConf(profiles []ProfileDefinition, stack, framework, defaultName string) (ProfileDefinition, bool)

SelectProfileWithConf selects a profile with a default name fallback. defaultName is the profiles.executor.default value from autopus.yaml.

type SessionState

type SessionState struct {
	// WorkflowPhase는 현재 워크플로우 단계이다.
	WorkflowPhase string `yaml:"workflow_phase"`
	// CompletedTasks는 완료된 태스크 목록이다.
	CompletedTasks []string `yaml:"completed_tasks,omitempty"`
	// PendingDecisions는 미결 의사결정 목록이다.
	PendingDecisions []string `yaml:"pending_decisions,omitempty"`
	// ContextSummary는 세션 컨텍스트 요약이다 (최대 2000 토큰).
	ContextSummary string `yaml:"context_summary,omitempty"`
}

SessionState는 세션 연속성 상태이다.

func LoadState

func LoadState(path string) (*SessionState, error)

LoadState는 파일에서 세션 상태를 로드한다.

type SkillActivator

type SkillActivator struct {
	// contains filtered or unexported fields
}

SkillActivator evaluates an ActivationContext against the skill registry and produces an ordered list of ActivationResult values.

func NewSkillActivator

func NewSkillActivator(
	registry *SkillRegistry,
	autoActivate bool,
	maxActive int,
	weights map[string]int,
) *SkillActivator

NewSkillActivator creates a SkillActivator backed by the given registry and config values.

func (*SkillActivator) Match

Match evaluates all registered skills against ctx and returns every skill whose trigger matched, sorted by score descending. Returns nil when autoActivate is false.

func (*SkillActivator) Resolve

func (a *SkillActivator) Resolve(results []ActivationResult) []ActivationResult

Resolve applies category weights, re-sorts by adjusted score, and trims the list to at most maxActive entries.

type SkillCatalog

type SkillCatalog struct {
	// contains filtered or unexported fields
}

SkillCatalog stores canonical skill metadata separately from compiled output.

func LoadSkillCatalog

func LoadSkillCatalog(dir string) (*SkillCatalog, error)

LoadSkillCatalog loads canonical skill metadata from a directory on disk.

func LoadSkillCatalogFromFS

func LoadSkillCatalogFromFS(fsys fs.FS, dir string) (*SkillCatalog, error)

LoadSkillCatalogFromFS loads canonical skill metadata from an embedded filesystem.

func (*SkillCatalog) Get

func (c *SkillCatalog) Get(name string) (CatalogSkill, bool)

Get returns a catalog skill by name.

func (*SkillCatalog) List

func (c *SkillCatalog) List() []CatalogSkill

List returns all catalog skills in deterministic order.

type SkillDefinition

type SkillDefinition struct {
	// Name은 스킬 이름이다.
	Name string `yaml:"name"`
	// Description은 스킬 설명이다.
	Description string `yaml:"description"`
	// Level1Metadata는 ~100 토큰 메타데이터이다 (항상 로드).
	Level1Metadata string `yaml:"level1_metadata"`
	// Level2Body는 ~5K 본문이다 (트리거 매칭 시 로드).
	Level2Body string `yaml:"-"`
	// Level3Resources는 온디맨드 리소스 목록이다.
	Level3Resources []string `yaml:"level3_resources"`
	// Triggers는 스킬 활성화 트리거 패턴이다.
	Triggers []string `yaml:"triggers"`
	// Category는 스킬 카테고리이다.
	Category string `yaml:"category"`
}

SkillDefinition은 3-tier Tiered Loading 스킬 정의이다.

type SkillMeta

type SkillMeta struct {
	Name        string   `yaml:"name"`
	Description string   `yaml:"description"`
	Platforms   []string `yaml:"platforms"`
	Triggers    []string `yaml:"triggers"`
	Category    string   `yaml:"category"`
	Bundles     []string `yaml:"bundles"`
	Visibility  string   `yaml:"visibility"`
}

SkillMeta holds parsed frontmatter metadata for platform compatibility checks.

type SkillRegistry

type SkillRegistry struct {
	// contains filtered or unexported fields
}

SkillRegistry는 스킬 레지스트리이다.

func (*SkillRegistry) Get

func (r *SkillRegistry) Get(name string) (SkillDefinition, error)

Get은 이름으로 스킬을 반환한다.

func (*SkillRegistry) List

func (r *SkillRegistry) List() []SkillDefinition

List는 모든 스킬을 반환한다.

func (*SkillRegistry) ListByCategory

func (r *SkillRegistry) ListByCategory(cat string) []SkillDefinition

ListByCategory는 카테고리별 스킬을 반환한다.

func (*SkillRegistry) Load

func (r *SkillRegistry) Load(dir string) error

Load는 디렉토리에서 스킬 파일을 로드한다.

func (*SkillRegistry) LoadFromFS

func (r *SkillRegistry) LoadFromFS(fsys fs.FS, dir string) error

LoadFromFS loads skill files from an embedded filesystem.

type SkillSurfaceState

type SkillSurfaceState struct {
	Registered bool
	Compiled   bool
	Visible    bool
	TargetPath string
}

SkillSurfaceState separates registry, compile, and visibility state.

func ResolveCatalogSkillState

func ResolveCatalogSkillState(skill CatalogSkill, platform string, cfg *config.HarnessConfig) SkillSurfaceState

ResolveCatalogSkillState evaluates registered/compiled/visible state for a skill.

type SkillTransformOptions

type SkillTransformOptions struct {
	ResolveSkillRef func(name string) string
	AllowSkill      func(meta SkillMeta) bool
}

SkillTransformOptions controls optional canonical reference rewrites.

type SkillTransformer

type SkillTransformer struct {
	// contains filtered or unexported fields
}

SkillTransformer loads skill files and transforms them for target platforms.

func NewSkillTransformer

func NewSkillTransformer(dir string) (*SkillTransformer, error)

NewSkillTransformer creates a transformer by loading all .md files from dir.

func NewSkillTransformerFromFS

func NewSkillTransformerFromFS(fsys fs.FS, dir string) (*SkillTransformer, error)

NewSkillTransformerFromFS creates a transformer by loading .md files from an embedded FS.

func (*SkillTransformer) TransformForPlatform

func (t *SkillTransformer) TransformForPlatform(platform string) ([]TransformedSkill, *TransformReport, error)

TransformForPlatform returns transformed skills and a report for the target platform.

func (*SkillTransformer) TransformForPlatformWithOptions

func (t *SkillTransformer) TransformForPlatformWithOptions(platform string, opts SkillTransformOptions) ([]TransformedSkill, *TransformReport, error)

TransformForPlatformWithOptions returns transformed skills and a report for the target platform.

type Stage

type Stage struct {
	// Name은 단계 이름이다.
	Name string `yaml:"name"`
	// Description은 단계 설명이다.
	Description string `yaml:"description"`
	// Rules는 단계별 규칙이다.
	Rules []string `yaml:"rules"`
	// RequiredBefore는 이전에 완료해야 할 단계이다.
	RequiredBefore string `yaml:"required_before"`
}

Stage는 방법론의 단일 단계이다.

type TransformReport

type TransformReport struct {
	Platform     string
	Compatible   []string
	Incompatible []string
}

TransformReport summarizes which skills are compatible or not for a platform.

type TransformedSkill

type TransformedSkill struct {
	Name        string
	Description string
	Content     string
}

TransformedSkill represents a skill after platform transformation.

type WorkflowDoc

type WorkflowDoc struct {
	// Policies는 워크플로우 정책 목록이다.
	Policies []Policy
	// Phases는 워크플로우 단계 목록이다.
	Phases []Phase
}

WorkflowDoc는 파싱된 워크플로우 문서이다.

func ParseWorkflow

func ParseWorkflow(content string) (*WorkflowDoc, error)

ParseWorkflow는 워크플로우 마크다운을 파싱한다.

Jump to

Keyboard shortcuts

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