add project sandbox init setup

This commit is contained in:
Tienson Qin
2026-02-28 21:28:28 +08:00
parent 6a9bb26483
commit baf23961ea
11 changed files with 224 additions and 6 deletions

View File

@@ -52,6 +52,7 @@
(project-config project-page nil))
([project-page {:keys [base-branch]}]
(let [repo-url (blank->nil (pu/get-block-property-value project-page :logseq.property/git-repo))
sandbox-init-setup (blank->nil (pu/get-block-property-value project-page :logseq.property/project-sandbox-init-setup))
project-id (some-> (:block/uuid project-page) str)
title (blank->nil (:block/title project-page))
base-branch (blank->nil base-branch)]
@@ -59,7 +60,8 @@
(cond-> {:id project-id
:title title
:repo-url repo-url}
(string? base-branch) (assoc :base-branch base-branch))))))
(string? base-branch) (assoc :base-branch base-branch)
(string? sandbox-init-setup) (assoc :sandbox-init-setup sandbox-init-setup))))))
(defn- block-line-content
[block]

View File

@@ -84,7 +84,8 @@
:logseq.property/agent-api-token
:logseq.property/agent-auth-json]}]
["65.24" {:properties [:logseq.property/agent-session-created?]}]
["65.25" {:properties [:logseq.property/pr]}]])
["65.25" {:properties [:logseq.property/pr]}]
["65.26" {:properties [:logseq.property/project-sandbox-init-setup]}]])
(let [[major minor] (last (sort (map (comp (juxt :major :minor) db-schema/parse-schema-version first)
schema-version->updates)))]

View File

@@ -12,6 +12,24 @@
[frontend.state :as state]
[promesa.core :as p]))
(deftest build-session-body-includes-project-sandbox-init-setup-test
(let [project-page {:block/uuid #uuid "11111111-1111-1111-1111-111111111111"
:block/title "Project"}
block {:block/uuid #uuid "22222222-2222-2222-2222-222222222222"
:block/title "Task"
:logseq.property/project project-page
:logseq.property/agent {:block/title "Codex"}}]
(p/with-redefs [pu/get-block-property-value (fn [entity k]
(if (= entity project-page)
(case k
:logseq.property/git-repo "https://github.com/example/repo"
:logseq.property/project-sandbox-init-setup "yarn install"
nil)
(get entity k)))]
(is (= "yarn install"
(get-in (agent-handler/build-session-body block)
[:project :sandbox-init-setup]))))))
(deftest start-session-sends-initial-message-test
(async done
(let [calls (atom [])

View File

@@ -54,3 +54,16 @@
(is (= {:major 65 :minor 25}
(:kv/value (d/entity @conn :logseq.kv/schema-version))))
(is (some? (d/entity @conn property-ident)))))
(deftest migrate-adds-project-sandbox-init-setup-property-builtin
(let [conn (db-test/create-conn)
property-ident :logseq.property/project-sandbox-init-setup
_ (d/transact! conn [{:db/ident :logseq.kv/schema-version
:kv/value {:major 65 :minor 25}}])
existing-eid (d/entid @conn property-ident)
_ (when existing-eid
(d/transact! conn [[:db/retractEntity existing-eid]]))
_ (db-migrate/migrate conn :target-version "65.26")]
(is (= {:major 65 :minor 26}
(:kv/value (d/entity @conn :logseq.kv/schema-version))))
(is (some? (d/entity @conn property-ident)))))