An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: 支持间隔复习 https://github.com/siyuan-note/siyuan/issues/6710
Liang Ding2abc5561b55a
diff --git a/kernel/api/riff.go b/kernel/api/riff.goindex 55d11a30d5..85251992b2 100644--- a/kernel/api/riff.go+++ b/kernel/api/riff.go@@ -67,7 +67,7 @@ func getRiffDueCards(c *gin.Context) {ret.Data = cards}-func removeRiffCard(c *gin.Context) {+func removeRiffCards(c *gin.Context) {ret := gulu.Ret.NewResult()defer c.JSON(http.StatusOK, ret)@@ -77,8 +77,12 @@ func removeRiffCard(c *gin.Context) {}deckID := arg["deckID"].(string)- blockID := arg["blockID"].(string)- err := model.RemoveFlashcard(blockID, deckID)+ blockIDsArg := arg["blockIDs"].([]interface{})+ var blockIDs []string+ for _, blockID := range blockIDsArg {+ blockIDs = append(blockIDs, blockID.(string))+ }+ err := model.RemoveFlashcards(deckID, blockIDs)if nil != err {ret.Code = -1ret.Msg = err.Error()@@ -86,7 +90,7 @@ func removeRiffCard(c *gin.Context) {}}-func addRiffCard(c *gin.Context) {+func addRiffCards(c *gin.Context) {ret := gulu.Ret.NewResult()defer c.JSON(http.StatusOK, ret)@@ -96,8 +100,12 @@ func addRiffCard(c *gin.Context) {}deckID := arg["deckID"].(string)- blockID := arg["blockID"].(string)- err := model.AddFlashcard(blockID, deckID)+ blockIDsArg := arg["blockIDs"].([]interface{})+ var blockIDs []string+ for _, blockID := range blockIDsArg {+ blockIDs = append(blockIDs, blockID.(string))+ }+ err := model.AddFlashcards(deckID, blockIDs)if nil != err {ret.Code = -1ret.Msg = err.Error()@@ -115,12 +123,13 @@ func createRiffDeck(c *gin.Context) {}name := arg["name"].(string)- err := model.CreateDeck(name)+ deck, err := model.CreateDeck(name)if nil != err {ret.Code = -1ret.Msg = err.Error()return}+ ret.Data = deck}func getRiffDecks(c *gin.Context) {diff --git a/kernel/api/router.go b/kernel/api/router.goindex 6e08ed0312..3263a27f08 100644--- a/kernel/api/router.go+++ b/kernel/api/router.go@@ -301,8 +301,8 @@ func ServeAPI(ginServer *gin.Engine) {ginServer.Handle("POST", "/api/riff/createRiffDeck", model.CheckAuth, createRiffDeck)ginServer.Handle("POST", "/api/riff/getRiffDecks", model.CheckAuth, getRiffDecks)- ginServer.Handle("POST", "/api/riff/addRiffCard", model.CheckAuth, addRiffCard)- ginServer.Handle("POST", "/api/riff/removeRiffCard", model.CheckAuth, removeRiffCard)+ ginServer.Handle("POST", "/api/riff/addRiffCards", model.CheckAuth, addRiffCards)+ ginServer.Handle("POST", "/api/riff/removeRiffCards", model.CheckAuth, removeRiffCards)ginServer.Handle("POST", "/api/riff/getRiffDueCards", model.CheckAuth, getRiffDueCards)ginServer.Handle("POST", "/api/riff/reviewRiffCard", model.CheckAuth, reviewRiffCard)diff --git a/kernel/go.mod b/kernel/go.modindex 3080361fa6..10f95c38a4 100644--- a/kernel/go.mod+++ b/kernel/go.mod@@ -45,7 +45,7 @@ require (github.com/siyuan-note/filelock v0.0.0-20221117095924-e1947438a35egithub.com/siyuan-note/httpclient v0.0.0-20221213030227-fa8d21fd9cf8github.com/siyuan-note/logging v0.0.0-20221031125421-9b7234d79d8a- github.com/siyuan-note/riff v0.0.0-20221221131148-653b342c7b6c+ github.com/siyuan-note/riff v0.0.0-20221221142532-2c074735104bgithub.com/steambap/captcha v1.4.1github.com/studio-b12/gowebdav v0.0.0-20221109171924-60ec5ad56012github.com/vmihailenco/msgpack/v5 v5.3.5diff --git a/kernel/go.sum b/kernel/go.sumindex f189599c70..2b9126cbdf 100644--- a/kernel/go.sum+++ b/kernel/go.sum@@ -387,6 +387,8 @@ github.com/siyuan-note/logging v0.0.0-20221031125421-9b7234d79d8a h1:b9VJCE8IccYgithub.com/siyuan-note/logging v0.0.0-20221031125421-9b7234d79d8a/go.mod h1:t1zRGxK13L/9ZFoGyTD39IbFCbee3CsypDj4b5dt4qM=github.com/siyuan-note/riff v0.0.0-20221221131148-653b342c7b6c h1:DaPdLs6t6JHbedko5+w+gfNuqXgThHWkLHrKiiHrbpQ=github.com/siyuan-note/riff v0.0.0-20221221131148-653b342c7b6c/go.mod h1:A3G3qOTyGVOu17ui9Qg9DNkAWOgwVMxHDzHYG8sQxHc=+github.com/siyuan-note/riff v0.0.0-20221221142532-2c074735104b h1:cDjWs67Y+glYE45+HWuB2oIXWipjJaZh3mYJRpV/FNQ=+github.com/siyuan-note/riff v0.0.0-20221221142532-2c074735104b/go.mod h1:A3G3qOTyGVOu17ui9Qg9DNkAWOgwVMxHDzHYG8sQxHc=github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=github.com/smartystreets/goconvey v1.6.7 h1:I6tZjLXD2Q1kjvNbIzB1wvQBsXmKXiVrhpRE8ZjP5jY=diff --git a/kernel/model/flashcard.go b/kernel/model/flashcard.goindex add8f3b8ef..fa4169e772 100644--- a/kernel/model/flashcard.go+++ b/kernel/model/flashcard.go@@ -71,12 +71,14 @@ func GetDueFlashcards(deckID string) (ret []*Flashcard, err error) {return}-func RemoveFlashcard(blockID string, deckID string) (err error) {+func RemoveFlashcards(deckID string, blockIDs []string) (err error) {deckLock.Lock()deck := Decks[deckID]deckLock.Unlock()- deck.RemoveCard(blockID)+ for _, blockID := range blockIDs {+ deck.RemoveCard(blockID)+ }err = deck.Save()if nil != err {logging.LogErrorf("save deck [%s] failed: %s", deckID, err)@@ -85,13 +87,15 @@ func RemoveFlashcard(blockID string, deckID string) (err error) {return}-func AddFlashcard(blockID string, deckID string) (err error) {+func AddFlashcards(deckID string, blockIDs []string) (err error) {deckLock.Lock()deck := Decks[deckID]deckLock.Unlock()- cardID := ast.NewNodeID()- deck.AddCard(cardID, blockID)+ for _, blockID := range blockIDs {+ cardID := ast.NewNodeID()+ deck.AddCard(cardID, blockID)+ }err = deck.Save()if nil != err {logging.LogErrorf("save deck [%s] failed: %s", deckID, err)@@ -128,10 +132,10 @@ func InitFlashcards() {}}-func CreateDeck(name string) (err error) {+func CreateDeck(name string) (deck *riff.Deck, err error) {riffSavePath := getRiffDir()deckID := ast.NewNodeID()- deck, err := riff.LoadDeck(riffSavePath, deckID)+ deck, err = riff.LoadDeck(riffSavePath, deckID)if nil != err {logging.LogErrorf("load deck [%s] failed: %s", deckID, err)return