Initial commit: CarrotAssistant backend (Go + Gin + SQLite, OpenAI-compatible agent runtime)

This commit is contained in:
2026-07-06 16:10:55 +08:00
commit 5f84739b18
40 changed files with 4781 additions and 0 deletions

23
internal/server/paths.go Normal file
View File

@@ -0,0 +1,23 @@
package server
import (
"os"
"path/filepath"
)
// absSkillPath joins a skill's relative file path (stored as
// "<app_slug>/<skill_slug>.md") onto the configured skills root, yielding the
// absolute on-disk location of the markdown file.
func absSkillPath(skillsDir, relPath string) string {
return filepath.Join(skillsDir, filepath.Clean("/"+relPath))
}
// removeAppSkillDir deletes the per-app skill directory after an app is
// removed. Missing directory and non-empty errors are ignored; this is
// best-effort cleanup.
func removeAppSkillDir(skillsDir, appSlug string) {
if appSlug == "" {
return
}
_ = os.RemoveAll(filepath.Join(skillsDir, appSlug))
}