From 28c8644565de8e7ff1c4cd9cd9c202d37a446297 Mon Sep 17 00:00:00 2001 From: 2penheimer <2603237065@qq.com> Date: Sat, 29 Aug 2026 21:31:10 +0800 Subject: [PATCH 1/4] =?UTF-8?q?docs:=20=E8=A1=A5=E5=85=85=20MIT=20?= =?UTF-8?q?=E8=AE=B8=E5=8F=AF=E8=AF=81=E4=B8=8E=E6=9C=AC=E5=9C=B0=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 方便他人合法使用仓库,并按文档启动、测试和提交 PR。 Co-authored-by: Cursor --- LICENSE | 21 +++++++++++++++++++++ README.md | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..a400467 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 SATA260 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 76327f0..962acb8 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,47 @@ -CodeDock 是一个面向 Agent 的执行与协作平台骨架,提供 Agent 上下文、执行请求、过程事件和结果回报所需的服务端与 Web 端边界。 +# CodeDock -项目本身不绑定 Issue、Task、Review、Workspace 等具体业务域;业务能力应在明确需求后以独立模块加入。 +面向 Agent 的执行与协作平台骨架:提供会话、执行请求、过程事件和结果回报所需的服务端与 Web 端边界。不绑定 Issue、Task、Review、Workspace 等具体业务域。 + +改代码前请阅读 [`docs/architecture.md`](docs/architecture.md) 和 [`AGENTS.md`](AGENTS.md)。 + +## 本地运行 + +需要 [Go](https://go.dev/dl/) 1.26.5、[Node.js](https://nodejs.org/) 20+、[pnpm](https://pnpm.io/) 11.17.0。默认 `LLM_PROVIDER=fake`,不必配置模型 Key。 + +```bash +cp .env.example .env +cp apps/web/.env.example apps/web/.env.local +pnpm install +``` + +API(默认 `http://localhost:8080`): + +```bash +cd server +go run ./cmd/server +``` + +服务会从当前目录向上查找 `.env`,在 `server/` 下启动也能读到仓库根的 `.env`。 + +Web(默认 `http://localhost:3000`): + +```bash +pnpm dev:web +``` + +浏览器打开 [http://localhost:3000](http://localhost:3000)。完整环境变量见 [`.env.example`](.env.example),不要提交 `.env` 或密钥。 + +## 测试 + +```bash +cd server && go test ./... +pnpm test:client +``` + +## 参与 + +从 `main` 开分支,按架构文档放置代码。本地测试通过后,向 `main` 开 Pull Request,说明改了什么、怎么验证。一种改动一个 PR;较大的行为或边界变化请先开 Issue。 + +## License + +[MIT](LICENSE) From ac6d98844617e09692f5e46c816aacf776dd9a9a Mon Sep 17 00:00:00 2001 From: 2penheimer <2603237065@qq.com> Date: Sat, 29 Aug 2026 21:50:11 +0800 Subject: [PATCH 2/4] =?UTF-8?q?chore:=20=E5=A2=9E=E5=8A=A0=20CI=20?= =?UTF-8?q?=E4=B8=8E=E4=B8=AD=E8=8B=B1=20Issue/PR=20=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在 PR 上校验编译、测试和探活;用简短中英对照模板收集改动说明。修复 Web 构建时的类型检查,避免流水线失败。 Co-authored-by: Cursor --- .github/ISSUE_TEMPLATE/bug.md | 15 ++++ .github/ISSUE_TEMPLATE/config.yml | 1 + .github/ISSUE_TEMPLATE/discussion.md | 10 +++ .github/ISSUE_TEMPLATE/enhancement.md | 11 +++ .github/PULL_REQUEST_TEMPLATE.md | 10 +++ .github/workflows/ci.yml | 77 +++++++++++++++++++ .../views/chat/hooks/use-session-timeline.ts | 7 +- 7 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 .github/ISSUE_TEMPLATE/bug.md create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/ISSUE_TEMPLATE/discussion.md create mode 100644 .github/ISSUE_TEMPLATE/enhancement.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/workflows/ci.yml diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md new file mode 100644 index 0000000..9355f67 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -0,0 +1,15 @@ +--- +name: 缺陷 / Bug +about: 实际行为和预期不一致 / Something does not work as expected +labels: bug +--- + +## 现象 / What happened + + + +## 复现 / How to reproduce + + + +## 期望 / Expected diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..0086358 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1 @@ +blank_issues_enabled: true diff --git a/.github/ISSUE_TEMPLATE/discussion.md b/.github/ISSUE_TEMPLATE/discussion.md new file mode 100644 index 0000000..d26fa08 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/discussion.md @@ -0,0 +1,10 @@ +--- +name: 讨论 / Discussion +about: 架构、产品范围或模块边界 / Architecture, scope, or module boundaries +--- + +## 议题 / Topic + + + +## 倾向(可选) / Leanings (optional) diff --git a/.github/ISSUE_TEMPLATE/enhancement.md b/.github/ISSUE_TEMPLATE/enhancement.md new file mode 100644 index 0000000..a1e07b9 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/enhancement.md @@ -0,0 +1,11 @@ +--- +name: 改进 / Enhancement +about: 新能力或现有行为调整 / New capability or a change in existing behavior +labels: enhancement +--- + +## 想做什么 / What + + + +## 为什么 / Why diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..194ab52 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,10 @@ +## 改了什么 / What changed + + + +## 怎么验证 / How to verify + +- [ ] `cd server && go test ./...` +- [ ] `pnpm test:client` + +相关 Issue / Related issue: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..9bfdcfc --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,77 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + +concurrency: + group: ci-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + server: + runs-on: ubuntu-latest + defaults: + run: + working-directory: server + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version-file: server/go.mod + cache-dependency-path: server/go.sum + + - name: Test + run: go test ./... + + - name: Build + run: go build -o /tmp/codedock ./cmd/server + + - name: Smoke + env: + HTTP_ADDR: :18080 + LLM_PROVIDER: fake + LLM_MODEL: fake + DB_DSN: file:ci.db + LOG_LEVEL: info + run: | + set -euo pipefail + /tmp/codedock & + pid=$! + cleanup() { kill "$pid" 2>/dev/null || true; wait "$pid" 2>/dev/null || true; } + trap cleanup EXIT + for _ in $(seq 1 30); do + if curl -fsS http://127.0.0.1:18080/health >/dev/null; then + echo "health ok" + exit 0 + fi + sleep 1 + done + echo "server did not become healthy" >&2 + exit 1 + + web: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: pnpm/action-setup@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: pnpm + + - name: Install + run: pnpm install --frozen-lockfile + + - name: Test + run: pnpm test:client + + - name: Build + run: pnpm build:web diff --git a/packages/views/chat/hooks/use-session-timeline.ts b/packages/views/chat/hooks/use-session-timeline.ts index b902540..0437450 100644 --- a/packages/views/chat/hooks/use-session-timeline.ts +++ b/packages/views/chat/hooks/use-session-timeline.ts @@ -54,7 +54,12 @@ export function useSessionTimeline(sessionId: string | undefined) { ); const [error, setError] = useState(null); const [sending, setSending] = useState(false); - const [loading, setLoading] = useState(() => Boolean(sessionId) && !timelineCache.has(sessionId)); + const [loading, setLoading] = useState(() => { + if (!sessionId) { + return false; + } + return !timelineCache.has(sessionId); + }); const stateRef = useRef(state); const sessionRef = useRef(sessionId); stateRef.current = state; From 08cc184bbd1a77abac23f456249c085a86c814de Mon Sep 17 00:00:00 2001 From: 2penheimer <2603237065@qq.com> Date: Sat, 29 Aug 2026 21:53:10 +0800 Subject: [PATCH 3/4] =?UTF-8?q?chore:=20=E5=9C=A8=20CI=20=E4=B8=AD?= =?UTF-8?q?=E5=8A=A0=E5=85=A5=20gofmt=E3=80=81go=20vet=20=E4=B8=8E=20ESLin?= =?UTF-8?q?t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 用官方格式化和现有 Next ESLint 拦住风格与明显误用,并修正一处未对齐的结构体字段。 Co-authored-by: Cursor --- .github/workflows/ci.yml | 8 ++++++++ README.md | 5 ++++- package.json | 3 ++- server/internal/handler/message.go | 6 +++--- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9bfdcfc..2532962 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,6 +26,11 @@ jobs: go-version-file: server/go.mod cache-dependency-path: server/go.sum + - name: Lint + run: | + test -z "$(gofmt -l .)" || { echo "gofmt needed:"; gofmt -l .; exit 1; } + go vet ./... + - name: Test run: go test ./... @@ -70,6 +75,9 @@ jobs: - name: Install run: pnpm install --frozen-lockfile + - name: Lint + run: pnpm lint:web + - name: Test run: pnpm test:client diff --git a/README.md b/README.md index 962acb8..c3758f8 100644 --- a/README.md +++ b/README.md @@ -34,10 +34,13 @@ pnpm dev:web ## 测试 ```bash -cd server && go test ./... +cd server && go test ./... && go vet ./... pnpm test:client +pnpm lint:web ``` +Go 源文件用 `gofmt` 格式化(`gofmt -w .`)。CI 会检查未格式化的文件。 + ## 参与 从 `main` 开分支,按架构文档放置代码。本地测试通过后,向 `main` 开 Pull Request,说明改了什么、怎么验证。一种改动一个 PR;较大的行为或边界变化请先开 Issue。 diff --git a/package.json b/package.json index 13b5b1b..5d14c22 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "scripts": { "dev:web": "pnpm --filter web dev", "build:web": "pnpm --filter web build", - "test:client": "pnpm --filter @codedock/core test" + "test:client": "pnpm --filter @codedock/core test", + "lint:web": "pnpm --filter web lint" }, "packageManager": "pnpm@11.17.0" } diff --git a/server/internal/handler/message.go b/server/internal/handler/message.go index 0ec987b..ad1838f 100644 --- a/server/internal/handler/message.go +++ b/server/internal/handler/message.go @@ -10,9 +10,9 @@ import ( ) type CreateMessageRequest struct { - Content string `json:"content"` - InputMode InputMode `json:"input_mode"` - Mode pkgagent.AgentMode `json:"mode"` + Content string `json:"content"` + InputMode InputMode `json:"input_mode"` + Mode pkgagent.AgentMode `json:"mode"` Config *pkgagent.RunConfigSnapshot `json:"config,omitempty"` } From 546a3446c6c73761258e293d3f564675b97e191f Mon Sep 17 00:00:00 2001 From: 2penheimer <2603237065@qq.com> Date: Sat, 29 Aug 2026 21:56:59 +0800 Subject: [PATCH 4/4] =?UTF-8?q?fix:=20CI=20=E4=BD=BF=E7=94=A8=20Node=2022?= =?UTF-8?q?=20=E4=BB=A5=E5=8C=B9=E9=85=8D=20pnpm=2011?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit pnpm 11.17 需要 Node 22.13+,Actions 上的 Node 20 无法启动安装。 Co-authored-by: Cursor --- .github/workflows/ci.yml | 10 +++++----- README.md | 2 +- package.json | 5 ++++- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2532962..28d7ab8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,9 +19,9 @@ jobs: run: working-directory: server steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - - uses: actions/setup-go@v5 + - uses: actions/setup-go@v6 with: go-version-file: server/go.mod cache-dependency-path: server/go.sum @@ -63,13 +63,13 @@ jobs: web: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - uses: pnpm/action-setup@v4 - - uses: actions/setup-node@v4 + - uses: actions/setup-node@v6 with: - node-version: 20 + node-version: 22 cache: pnpm - name: Install diff --git a/README.md b/README.md index c3758f8..d3e5f9c 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ ## 本地运行 -需要 [Go](https://go.dev/dl/) 1.26.5、[Node.js](https://nodejs.org/) 20+、[pnpm](https://pnpm.io/) 11.17.0。默认 `LLM_PROVIDER=fake`,不必配置模型 Key。 +需要 [Go](https://go.dev/dl/) 1.26.5、[Node.js](https://nodejs.org/) 22.13+、[pnpm](https://pnpm.io/) 11.17.0。默认 `LLM_PROVIDER=fake`,不必配置模型 Key。 ```bash cp .env.example .env diff --git a/package.json b/package.json index 5d14c22..1bc9ce2 100644 --- a/package.json +++ b/package.json @@ -7,5 +7,8 @@ "test:client": "pnpm --filter @codedock/core test", "lint:web": "pnpm --filter web lint" }, - "packageManager": "pnpm@11.17.0" + "packageManager": "pnpm@11.17.0", + "engines": { + "node": ">=22.13.0" + } }