refactor(skills): 技能库 - 将内置 Markdown 包移至 backend/builtin
This commit is contained in:
1 parent
a8a605519b
commit
83d3364802
83 files changed
+17
-7
No files matched your search
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,11 @@
|
|||||||
|
package builtin
|
||||||
|
|
||||||
|
import "embed"
|
||||||
|
|
||||||
|
// FS contains the built-in skill packages shipped with the backend.
|
||||||
|
//
|
||||||
|
// The Markdown packages live outside internal Go packages so they are easy to
|
||||||
|
// review and maintain as product content while remaining embedded in binaries.
|
||||||
|
//
|
||||||
|
//go:embed *
|
||||||
|
var FS embed.FS
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"version": 1,
|
"version": 1,
|
||||||
"updated": "2026-09-22",
|
"updated": "2026-09-22",
|
||||||
"note": "技能目录来自 backend/internal/skills/builtin/ 下的 Markdown 技能包;此文件只保存场景组合,不保存技能正文。",
|
"note": "技能目录来自 backend/builtin/ 下的 Markdown 技能包;此文件只保存场景组合,不保存技能正文。",
|
||||||
"presets": [
|
"presets": [
|
||||||
{
|
{
|
||||||
"presetId": "short-drama-starter",
|
"presetId": "short-drama-starter",
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package skills
|
package skills
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"embed"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
@@ -11,12 +10,12 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
|
|
||||||
|
builtinAssets "infinite-canvas/backend/builtin"
|
||||||
"infinite-canvas/backend/internal/kernel"
|
"infinite-canvas/backend/internal/kernel"
|
||||||
"infinite-canvas/backend/internal/model"
|
"infinite-canvas/backend/internal/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed builtin
|
var builtinSkillFiles = builtinAssets.FS
|
||||||
var builtinSkillFiles embed.FS
|
|
||||||
|
|
||||||
type builtinSkillMetadata struct {
|
type builtinSkillMetadata struct {
|
||||||
Name string
|
Name string
|
||||||
@@ -81,7 +80,7 @@ func (s *Service) EnsureBuiltinSkills() error {
|
|||||||
func loadBuiltinSkillPackages(tombstones interface {
|
func loadBuiltinSkillPackages(tombstones interface {
|
||||||
BuiltinSkillTombstoned(string) (bool, error)
|
BuiltinSkillTombstoned(string) (bool, error)
|
||||||
}) ([]builtinSkillPackage, error) {
|
}) ([]builtinSkillPackage, error) {
|
||||||
entries, err := builtinSkillFiles.ReadDir("builtin")
|
entries, err := builtinSkillFiles.ReadDir(".")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("读取内置技能目录失败: %w", err)
|
return nil, fmt.Errorf("读取内置技能目录失败: %w", err)
|
||||||
}
|
}
|
||||||
@@ -100,7 +99,7 @@ func loadBuiltinSkillPackages(tombstones interface {
|
|||||||
}
|
}
|
||||||
seen[skillID] = struct{}{}
|
seen[skillID] = struct{}{}
|
||||||
|
|
||||||
base := path.Join("builtin", skillID)
|
base := skillID
|
||||||
body, err := builtinSkillFiles.ReadFile(path.Join(base, "SKILL.md"))
|
body, err := builtinSkillFiles.ReadFile(path.Join(base, "SKILL.md"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("读取内置技能 %s 入口文件失败: %w", skillID, err)
|
return nil, fmt.Errorf("读取内置技能 %s 入口文件失败: %w", skillID, err)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
package skills
|
package skills
|
||||||
|
|
||||||
// Historical JSON seed definitions were migrated to builtin/<skill-id>/SKILL.md.
|
// Historical JSON seed definitions were migrated to backend/builtin/<skill-id>/SKILL.md.
|
||||||
// This file is intentionally kept as a migration marker so old package references
|
// This file is intentionally kept as a migration marker so old package references
|
||||||
// are easy to identify in downstream branches; it contains no runtime data.
|
// are easy to identify in downstream branches; it contains no runtime data.
|
||||||
Reference in new issue
Block a user