Documentation
¶
Overview ¶
Package langreg is the language registry for the AILANG eval harness. Each supported language (python, ailang, javascript, go, ...) registers itself via init() → Register(). Callers use Get(name) instead of switch statements, so adding a new language is one file + one init() call.
Index ¶
- func Names() []string
- func Register(lang Language)
- func SetAILANGRunnerFactory(f func(ctx context.Context, spec interface{}, taskID string) interface{})
- func SetGoRunnerFactory(f func(spec interface{}) interface{})
- func SetJSRunnerFactory(f func(spec interface{}) interface{})
- func SetPythonRunnerFactory(f func(spec interface{}) interface{})
- type Language
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Names ¶
func Names() []string
Names returns all registered language names, sorted alphabetically.
func Register ¶
func Register(lang Language)
Register adds a Language implementation to the registry. Calling Register with the same name twice is a no-op (idempotent). Panics if lang is nil.
func SetAILANGRunnerFactory ¶
func SetAILANGRunnerFactory(f func(ctx context.Context, spec interface{}, taskID string) interface{})
SetAILANGRunnerFactory registers the factory used by NewRunner. Must be called before any NewRunner call — eval_harness does this in its init.
func SetGoRunnerFactory ¶
func SetGoRunnerFactory(f func(spec interface{}) interface{})
SetGoRunnerFactory registers the factory used by NewRunner. Must be called before any NewRunner call — eval_harness does this in its init.
func SetJSRunnerFactory ¶
func SetJSRunnerFactory(f func(spec interface{}) interface{})
SetJSRunnerFactory registers the factory used by NewRunner. Must be called before any NewRunner call — eval_harness does this in its init.
func SetPythonRunnerFactory ¶
func SetPythonRunnerFactory(f func(spec interface{}) interface{})
SetPythonRunnerFactory registers the factory used by NewRunner. Must be called before any NewRunner call — eval_harness does this in its init.
Types ¶
type Language ¶
type Language interface {
// Name returns the canonical registry key ("python", "ailang", "javascript", "go").
Name() string
// DisplayName returns the human-readable name for prompt placeholders ("Python 3", "AILANG").
DisplayName() string
// FileExt returns the solution file extension (".py", ".ail", ".js", ".go").
FileExt() string
// SolutionFilename returns the expected output filename ("solution.py", "solution.ail").
SolutionFilename() string
// PromptTemplatePath returns the agent_prompt template file path.
// Empty string means use the AILANG fallback template.
PromptTemplatePath() string
// TaskTemplatePath returns the agent_task template file path.
TaskTemplatePath() string
// LoadSyntaxRef loads the teaching / syntax reference prompt.
// version is the requested prompt version ("" = active/default).
// Returns (content, versionUsed, error).
LoadSyntaxRef(version string) (string, string, error)
// DefaultPrompt returns a minimal fallback prompt when LoadSyntaxRef fails.
DefaultPrompt() string
// NewRunner constructs a language-specific runner.
// Returns a value satisfying eval_harness.LanguageRunner; callers type-assert.
// spec is *eval_harness.BenchmarkSpec (passed as interface{} to avoid circular import).
// Returns (runner interface{}, error).
NewRunner(ctx context.Context, spec interface{}, taskID string) (interface{}, error)
}
Language is the per-language descriptor used by the eval harness. Implement this interface and call Register() from init() to add a new language.