Documentation
¶
Overview ¶
Package roles does one thing: map role names to allowed skills/tools/prompts.
Why session_id, not project_path ¶
The sessions table maps session_id → project_path. When a user copies a project to another directory, they update sessions.project_path and everything keyed by session_id follows. If we used project_path directly, every table referencing project_path would need updating — doubled work, doubled risk.
Schema ¶
role_configs (role TEXT, session_id INTEGER, skills TEXT, tools TEXT, prompt TEXT) UNIQUE(role, session_id) — one config per role per session
Fallback chain ¶
DB row exists? → use it No row → hardcoded: dev=all, expert=none, review=none
"all" vs "" ¶
In the skills/tools columns:
- "all" → ParseXxxList returns nil (no filtering; include everything)
- "" → ParseXxxList returns []string{} (explicitly nothing)
- "a,b" → ParseXxxList returns ["a","b"]
This convention lets callers do a single nil-check instead of comparing against both "all" and a full list.
Package roles manages role-to-skills/tools/prompt mappings stored in SQLite.
Each role (dev/expert/review) can have per-session configuration. The table is keyed by (role, session_id), not (role, project_path). This is intentional: session_id is a stable identifier that survives project relocation. When a user copies a project to a new directory, they only need to update sessions.project_path — role_configs follows automatically.
Fallback: when no row exists for a role+session, the system uses hardcoded defaults: dev gets all skills+tools, expert/review get none.
API conventions:
- "all" → nil slice (no filtering, include everything)
- "" → empty slice (explicitly nothing)
- "a,b" → ["a","b"] slice (filter to these names)
All exported functions take int64 sessionID, not string projectPath.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteRoleConfig ¶
DeleteRoleConfig deletes a role config.
func ParseSkillsList ¶
ParseSkillsList parses the skills field. Returns nil for "all" (no filtering), empty slice for "" (nothing), or names.
func ParseToolsList ¶
ParseToolsList parses the tools field. Returns nil for "all" (no filtering), empty slice for "" (nothing), or names.
Types ¶
type RoleConfig ¶
type RoleConfig struct {
ID int64
Role string // e.g. "dev", "expert", "review"
Skills string // "all", "", or comma-separated skill names
Tools string // "all", "", or comma-separated tool names
Prompt string // prompt template name; empty means use role name
SessionID int64 // FK to sessions.id
CreatedAt time.Time
UpdatedAt time.Time
}
RoleConfig maps a role to its skills, tools, and prompt template.
func GetRoleConfig ¶
func GetRoleConfig(role string, sessionID int64) (*RoleConfig, error)
GetRoleConfig retrieves the role config for a given role and session.
func ListRoleConfigs ¶
func ListRoleConfigs(sessionID int64) ([]RoleConfig, error)
ListRoleConfigs returns all role configs for a given session.
Source Files
¶
- doc.go
- role.go