diff --git a/README.md b/README.md index 071e6a0..c379a1b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# VibeCoding Remote Compilation · 0.4 +# VibeCoding Remote Compilation · 0.8 Android Studio 本机编辑 → 增量上传 → 局域网服务编译 → 下载 APK → 本机 adb 安装。 @@ -111,6 +111,7 @@ Linux/macOS 在 `plugin/` 执行 `sh ./gradlew buildPlugin`。也可使用已安 0.5.0新增[专用Git编译工作区](docs/dedicated-workspaces.md):本机提交通过不含文件blob的bundle导入,未提交修改仍按清单增量同步。原远端仓库只读初始化,后续无需pull配合构建。新插件与服务端需一起升级;签名辅助文件可由管理员显式配置,旧客户端保持旧流程。下载APK保留原名,重名追加到秒的时间戳,同一秒继续加序号。 +0.6.0支持[服务端ADB安装](docs/remote-adb.md):按工程选择本机或服务端设备安装,服务端直接安装已保存产物,不依赖先下载到本机。 0.7.0支持在侧边栏维护[服务端私有文件清单](docs/private-files.md):IDE编辑路径清单、显式保存、检查并在构建前复制未跟踪的签名脚本和密钥文件。 diff --git a/docs/deployment-192.168.5.222.md b/docs/deployment-192.168.5.222.md index 128dec0..b619dcb 100644 --- a/docs/deployment-192.168.5.222.md +++ b/docs/deployment-192.168.5.222.md @@ -1,6 +1,6 @@ # Windows 192.168.5.222 部署记录 -日期:2026-11-24(Asia/Shanghai)。服务端版本:0.4.1(保留下方历史验收记录)。 +日期:2026-11-24(Asia/Shanghai),最近更新:2026-11-30。服务端当前版本:0.8.1(保留下方历史验收记录)。 ## 运行配置 @@ -154,3 +154,13 @@ Windows远端已替换0.4.9,备份原程序、XML和access.json。实际运行 ## 2026-11-27 全量部署0.8.0 空闲检查、程序摘要核验和配置备份后完成升级。服务账户及启动方式保留,原目录/任务授权、工具链、私有文件清单、签名映射、TLS/Token及历史APK未改动。HTTPS版本0.8.0/installActions能力、安装接口新字段校验、私有清单读取/认证、ADB列表和历史产物验证通过。使用无效设备和非法前置命令验证新参数,在任何ADB命令执行前拒绝;没有向真实设备执行配置命令、安装或启动。需安装0.8.0插件使用新选项。 + + +## 2026-11-30 部署0.8.1(Git 状态诊断) + +- 按用户要求在确认无活动构建后升级 Windows 222 服务端;上传文件摘要与本地一致,脚本含失败回滚。服务保持 RemoteCompile、Automatic/Running、NT AUTHORITY\LocalService。 +- 程序SHA-256:C03B2A7BB69FBF5352BA842B1354D4234672D0761359AF52E4CB053769CBCA90。原五个工程根目录、任务授权、TLS/Token、私有清单及历史成功构建6a5169f8c1063b9668543a9cb2b3d6fb和APK保留。 +- HTTPS health返回version=0.8.1,能力字段不变;未认证401;非法任务仍返回本机admin命令;未触发业务构建。 +- 用空 Git 快照检查 ElderlyDialer 服务端目录,确认新文案“服务端目录是 Git 仓库,但本机未提供 Git 状态…”。服务端只改提示,协议不变,兼容0.8.0插件。 +- 插件0.8.1(在本机检查结果中显示未安装git/非Git仓库/所有权异常的具体原因)需用户安装后使用,安装包为dist/remote-compilation-plugin-0.8.1.zip。 +- 该实例未开放SMB/RPC(445/135),远程部署仅通过SSH(plink/pscp)完成;升级脚本含空闲检查、备份和失败回滚,临时目录已清理。 diff --git a/docs/deployment-192.168.5.224.md b/docs/deployment-192.168.5.224.md index 226b296..42302ce 100644 --- a/docs/deployment-192.168.5.224.md +++ b/docs/deployment-192.168.5.224.md @@ -1,6 +1,6 @@ # Ubuntu 192.168.5.224 实机测试与部署记录 -更新日期:2026-11-25(Asia/Shanghai)。服务端 0.4.5,兼容插件 0.4.3。 +更新日期:2026-11-27(Asia/Shanghai)。服务端 0.8.0,兼容插件 0.8.0。 ## 实际系统和连接 diff --git a/docs/deployment-local-windows.md b/docs/deployment-local-windows.md index aaa4889..2c0c856 100644 --- a/docs/deployment-local-windows.md +++ b/docs/deployment-local-windows.md @@ -85,3 +85,11 @@ Get-Content 'C:\ProgramData\VibeCodingRemoteCompilation\logs\*.log' -Tail 50 ## 2026-11-27 全量部署0.8.0 空闲检查、程序摘要核验和配置备份后完成升级。服务账户及启动方式保留,原目录/任务授权、工具链、私有文件清单、签名映射、TLS/Token及历史APK未改动。HTTPS版本0.8.0/installActions能力、安装接口新字段校验、私有清单读取/认证、ADB列表和历史产物验证通过。使用无效设备和非法前置命令验证新参数,在任何ADB命令执行前拒绝;没有向真实设备执行配置命令、安装或启动。需安装0.8.0插件使用新选项。 + + +## 2026-11-30 升级0.8.1(Git 状态诊断) + +- 以管理员权限运行本机升级脚本,脚本先检查无活动构建并备份旧程序和配置,失败可回滚;服务保持 RemoteCompile、Automatic/Running、NT AUTHORITY\LocalService。 +- 程序SHA-256:C03B2A7BB69FBF5352BA842B1354D4234672D0761359AF52E4CB053769CBCA90,与222部署一致。 +- localhost HTTPS health返回version=0.8.1,能力字段不变;未认证401;历史成功构建7ee80c8f3c78c6a3d0ccf4971ff342c9仍为success且产物可读。 +- 原Token、TLS证书、工具链、授权任务与构建数据未改动;未执行同步、业务构建或设备安装。 diff --git a/docs/lan-direct.md b/docs/lan-direct.md index 14e70a1..09a515f 100644 --- a/docs/lan-direct.md +++ b/docs/lan-direct.md @@ -1,6 +1,6 @@ # 局域网 HTTPS 直连 -2026-11-24 状态:Windows 192.168.5.222 已升级为 0.2.0 并启用局域网 HTTPS,原 Token 与工作区保留。具体配置与验收结果见 [服务器部署记录](deployment-192.168.5.222.md)。 +2026-11-24 启用局域网 HTTPS,2026-11-27 服务端已升级到 0.8.0;原 Token 与工作区保留。具体配置与验收结果见 [服务器部署记录](deployment-192.168.5.222.md)。 连接:Android Studio → `https://192.168.5.222:8765` → 编译服务。本机无需监听 18765 或运行 SSH 隧道。 diff --git a/docs/project-workspaces.md b/docs/project-workspaces.md index a196854..91bd5f2 100644 --- a/docs/project-workspaces.md +++ b/docs/project-workspaces.md @@ -20,6 +20,7 @@ - 本机未提交修改可以正常上传。远程因此产生的脏工作树不影响下一次同步;若有人在服务器额外改动或添加源码,则停止并提示具体路径。 - 如果手动将服务端更新到与本机相同提交的干净工作树,可继续同步。 - 服务端没有 `.git` 时明确提示无法比较 Git 提交;仍可同步源码。多个客户端不能同时绑定同一目录或互相嵌套的目录。 +- 提示“服务端目录是 Git 仓库,但本机未提供 Git 状态”时,检查结果会同时给出本机原因:IDE 找不到 git 命令、本机目录不是 Git 仓库(复制工程丢失 `.git`),或 Git 以 dubious ownership 拒绝访问。本机无 Git 时不会与服务端比较提交;存在 `.gitignore` 时也会拒绝上传,避免忽略规则失效误传密钥。 ## 忽略与错误修复 diff --git a/docs/verification.md b/docs/verification.md index da25158..f6d65ae 100644 --- a/docs/verification.md +++ b/docs/verification.md @@ -173,3 +173,11 @@ Windows192.168.5.222、Ubuntu192.168.5.224和本机服务均升级0.7.0。Window ## 2026-11-27 三套服务部署0.8.0 Windows192.168.5.222、Ubuntu192.168.5.224、本机服务均升级0.8.0并正常运行,保留配置、权限策略、清单及历史APK。Windows保持Automatic/Running、LocalService;Ubuntuactive/remotecompile,备份/opt/remotecompile/upgrade-0.8.0-20261127-161249。三端HTTPS版本/installActions能力、安装新字段的执行前拒绝校验、原授权与任务拦截、私有清单接口/401认证、ADB设备查询及历史成功产物验证通过。不执行真实设备配置/安装/启动。插件仍需用户安装0.8.0。此前未部署记录由本轮更新。 + + +## 2026-11-30 Git状态诊断0.8.1与222部署 + +- 服务端compareGit文案改为“服务端目录是 Git 仓库,但本机未提供 Git 状态…”。插件检查结果区分三类本机原因:IDE找不到git命令、目录及其上级不是Git仓库、Git以dubious ownership拒绝;Remote Run的“Git 检查”行显示具体原因,无Git且存在.gitignore时的拒绝提示同样附带原因。Git调用增加stderr采集,snapshot读取失败信息包含git错误首行。本轮未实现safe.directory(B),也未允许无Git本机同步(C)。 +- Windows原生go vet及全部测试通过(59.834s)。插件0.8.1联网test/buildPlugin成功(7m18s,37项通过),新增1项诊断回归后离线重跑通过(3m15s,38项,SourceFilesTest=3),0.8.1 ZIP已复制dist并核对plugin.xml版本。 +- Windows192.168.5.222升级0.8.1,程序SHA-256 C03B2A7BB69FBF5352BA842B1354D4234672D0761359AF52E4CB053769CBCA90;服务保持Automatic/Running、LocalService。health version=0.8.1、能力字段不变、未认证401、非法任务返回admin命令、五个授权根目录与历史成功构建6a5169f8c1063b9668543a9cb2b3d6fb及APK保留;用空Git快照检查ElderlyDialer目录确认新文案。未同步源码、触发业务构建或安装设备。 +- 222未开放SMB/RPC(445/135),部署仅通过SSH完成;升级脚本含空闲检查、备份和失败回滚,远程临时目录已清理。本机服务已通过管理员权限脚本升级0.8.1(hash一致),localhost HTTPS版本/401/历史成功产物验证通过;Ubuntu224仍为0.8.0。0.8.0插件可继续连接0.8.1服务;需安装0.8.1插件查看本机具体原因。 diff --git a/plugin/build.gradle.kts b/plugin/build.gradle.kts index 03694ac..26ea15e 100644 --- a/plugin/build.gradle.kts +++ b/plugin/build.gradle.kts @@ -3,7 +3,7 @@ plugins { id("org.jetbrains.intellij.platform") version "2.5.0" } group = "studio.tongtong" -version = "0.8.0" +version = "0.8.1" repositories { mavenCentral() intellijPlatform { defaultRepositories() } diff --git a/plugin/src/main/kotlin/studio/tongtong/remotecompile/RemoteToolWindow.kt b/plugin/src/main/kotlin/studio/tongtong/remotecompile/RemoteToolWindow.kt index 59befb3..94031f2 100644 --- a/plugin/src/main/kotlin/studio/tongtong/remotecompile/RemoteToolWindow.kt +++ b/plugin/src/main/kotlin/studio/tongtong/remotecompile/RemoteToolWindow.kt @@ -335,7 +335,7 @@ class RemotePanel(private val project: Project) : JPanel(BorderLayout()), Dispos val checkBody = mapOf("workspacePath" to cfg.remoteFolder, "projectId" to cfg.projectId, "git" to localGit, "javaHome" to cfg.remoteJavaHome, "dedicated" to dedicated) val inspection = json(base, secret, "POST", "/projects/check", checkBody) append("远程位置:${inspection.get("workspacePath").asString}") - append("Git 检查:${inspection.get("message").asString};本机=$localGit;编译工作区基线=${inspection.get("git")}") + append("Git 检查:${inspection.get("message").asString};本机=${SourceFiles.describe(source, localGit)};编译工作区基线=${inspection.get("git")}") check(inspection.get("canSync").asBoolean) { inspection.get("message").asString } inspection.getAsJsonObject("preflight")?.let { report -> append(PreflightChecks.describe(report)) diff --git a/plugin/src/main/kotlin/studio/tongtong/remotecompile/Settings.kt b/plugin/src/main/kotlin/studio/tongtong/remotecompile/Settings.kt index 6e780d5..f593bca 100644 --- a/plugin/src/main/kotlin/studio/tongtong/remotecompile/Settings.kt +++ b/plugin/src/main/kotlin/studio/tongtong/remotecompile/Settings.kt @@ -325,7 +325,7 @@ private class RemoteSettingsPanel(private val project: Project) : JPanel(BorderL val response = ServerTls.client(cert).send(req, java.net.http.HttpResponse.BodyHandlers.ofString()) check(response.statusCode() == 200) { ServerErrors.describe(response.statusCode(), "/projects/check", response.body()) } val remote = com.google.gson.Gson().fromJson(response.body(), com.google.gson.JsonObject::class.java) - "${remote.get("message").asString}\n服务端位置:${remote.get("workspacePath").asString}\n本机 Git:$local\n编译工作区基线:${remote.get("git")}\n${PreflightChecks.describe(remote.getAsJsonObject("preflight"))}\n(上游差异使用已有本地引用,检查不会 fetch/pull,也不会修改文件)" + "${remote.get("message").asString}\n服务端位置:${remote.get("workspacePath").asString}\n本机 Git:${SourceFiles.describe(source, local)}\n编译工作区基线:${remote.get("git")}\n${PreflightChecks.describe(remote.getAsJsonObject("preflight"))}\n(上游差异使用已有本地引用,检查不会 fetch/pull,也不会修改文件)" }.getOrElse { (it.message ?: it.javaClass.simpleName).let { message -> if (secret.isEmpty()) message else message.replace(secret, "***") } } ApplicationManager.getApplication().invokeLater { if (!project.isDisposed) { checkRemote.isEnabled = true; checkResult.text = result } } } diff --git a/plugin/src/main/kotlin/studio/tongtong/remotecompile/SourceFiles.kt b/plugin/src/main/kotlin/studio/tongtong/remotecompile/SourceFiles.kt index 9864a50..9aee9fc 100644 --- a/plugin/src/main/kotlin/studio/tongtong/remotecompile/SourceFiles.kt +++ b/plugin/src/main/kotlin/studio/tongtong/remotecompile/SourceFiles.kt @@ -15,7 +15,9 @@ object SourceFiles { return parts.any { it in excluded } || leaf == "local.properties" || leaf.endsWith(".jks") || leaf.endsWith(".keystore") || leaf.startsWith(".env") || leaf in setOf("key.properties", "keystore.properties") } - internal fun git(root: Path, args: List, input: ByteArray = byteArrayOf()): Pair { + internal data class GitResult(val code: Int, val output: String, val error: String) + + internal fun gitResult(root: Path, args: List, input: ByteArray = byteArrayOf()): GitResult { val output = Files.createTempFile("remotecompile-git-", ".out") val stderr = Files.createTempFile("remotecompile-git-", ".err") val stdin = Files.createTempFile("remotecompile-git-", ".in") @@ -24,18 +26,40 @@ object SourceFiles { val process = ProcessBuilder(listOf("git", "-C", root.toString()) + args) .redirectInput(stdin.toFile()).redirectOutput(output.toFile()).redirectError(stderr.toFile()).start() if (!process.waitFor(60, TimeUnit.SECONDS)) { process.destroyForcibly(); error("Git 检查超时") } - return process.exitValue() to Files.readString(output) + return GitResult(process.exitValue(), Files.readString(output), Files.readString(stderr)) } finally { Files.deleteIfExists(output); Files.deleteIfExists(stderr); Files.deleteIfExists(stdin) } } + internal fun git(root: Path, args: List, input: ByteArray = byteArrayOf()): Pair = + gitResult(root, args, input).let { it.code to it.output } + private fun gitError(result: GitResult): String = + result.error.lineSequence().map { it.trim() }.firstOrNull { it.isNotEmpty() } ?: "git 退出码 ${result.code}" fun snapshot(root: Path): GitSnapshot? { - val repo = try { git(root, listOf("rev-parse", "--is-inside-work-tree")) } catch (_: java.io.IOException) { return null } - if (repo.first != 0 || repo.second.trim() != "true") return null + val repo = try { gitResult(root, listOf("rev-parse", "--is-inside-work-tree")) } catch (_: java.io.IOException) { return null } + if (repo.code != 0 || repo.output.trim() != "true") return null fun read(vararg args: String) = git(root, args.toList()).let { if (it.first == 0) it.second.trim() else "" } - check(git(root, listOf("status", "--porcelain", "--untracked-files=normal")).first == 0) { "无法读取本机 Git 状态" } + val status = gitResult(root, listOf("status", "--porcelain", "--untracked-files=normal")) + check(status.code == 0) { "无法读取本机 Git 状态:${gitError(status)}" } return GitSnapshot(read("rev-parse", "--verify", "HEAD"), read("symbolic-ref", "--short", "-q", "HEAD"), - read("status", "--porcelain", "--untracked-files=normal").isNotEmpty(), + status.output.isNotEmpty(), read("rev-parse", "--abbrev-ref", "@{upstream}"), read("rev-list", "--left-right", "--count", "HEAD...@{upstream}")) } + /** null when [snapshot] can read the work tree; otherwise a user-facing reason for the check result. */ + fun unavailableReason(root: Path): String? { + val repo = try { gitResult(root, listOf("rev-parse", "--is-inside-work-tree")) } + catch (_: java.io.IOException) { return "IDE 进程找不到 git 命令;请安装 Git 后重启 IDE" } + if (repo.code == 0 && repo.output.trim() == "true") { + val status = gitResult(root, listOf("status", "--porcelain", "--untracked-files=normal")) + return if (status.code == 0) null else "仓库可识别,但读取状态失败:${gitError(status)}" + } + val message = repo.error.lowercase() + return when { + "dubious ownership" in message -> "Git 因仓库所有权(dubious ownership)拒绝访问;请确认目录所有者,或为 Git 配置 safe.directory" + "not a git repository" in message -> "本机该目录及其上级目录都不是 Git 仓库;复制工程时可能丢失了 .git" + else -> "本机无法识别 Git 工作树:${gitError(repo)}" + } + } + fun describe(root: Path, snapshot: GitSnapshot?): String = + snapshot?.toString() ?: "未提供(${unavailableReason(root) ?: "原因未知"})" fun collect(root: Path, gitSnapshot: GitSnapshot?): List { val candidates = mutableListOf() var hasIgnore = false @@ -55,7 +79,9 @@ object SourceFiles { return FileVisitResult.CONTINUE } }) - check(gitSnapshot != null || !hasIgnore) { "存在 .gitignore,但无法读取 Git 工作树;请安装 Git 并确认该工程属于 Git 仓库,避免误传忽略文件" } + check(gitSnapshot != null || !hasIgnore) { + "存在 .gitignore,但无法读取 Git 工作树:${unavailableReason(root) ?: "原因未知"};为避免忽略规则失效误传密钥,已停止" + } val names = candidates.map { root.relativize(it).joinToString("/") } val ignored = if (gitSnapshot == null || names.isEmpty()) emptySet() else { val result = git(root, listOf("check-ignore", "--no-index", "-z", "--stdin"), (names.joinToString("\u0000") + "\u0000").toByteArray(Charsets.UTF_8)) diff --git a/plugin/src/test/kotlin/studio/tongtong/remotecompile/SourceFilesTest.kt b/plugin/src/test/kotlin/studio/tongtong/remotecompile/SourceFilesTest.kt index 49fd566..8e6ed1c 100644 --- a/plugin/src/test/kotlin/studio/tongtong/remotecompile/SourceFilesTest.kt +++ b/plugin/src/test/kotlin/studio/tongtong/remotecompile/SourceFilesTest.kt @@ -29,4 +29,21 @@ class SourceFilesTest { try { Files.writeString(root.resolve(".gitignore"), "private/\n"); assertThrows(IllegalStateException::class.java) { SourceFiles.collect(root, null) } } finally { root.toFile().deleteRecursively() } } + @Test fun describesWhyLocalGitStateIsUnavailable() { + val repo = Files.createTempDirectory("remote-git-ok") + val plain = Files.createTempDirectory("remote-git-absent") + try { + assertEquals(0, SourceFiles.git(repo, listOf("init", "-q")).first) + assertNull(SourceFiles.unavailableReason(repo)) + assertFalse(SourceFiles.describe(repo, SourceFiles.snapshot(repo)).startsWith("未提供")) + Files.writeString(plain.resolve(".gitignore"), "private/\n") + val reason = SourceFiles.unavailableReason(plain) + assertNotNull(reason) + assertTrue(reason!!.contains("不是 Git 仓库")) + assertTrue(SourceFiles.describe(plain, null).contains("未提供")) + } finally { + repo.toFile().deleteRecursively() + plain.toFile().deleteRecursively() + } + } } diff --git a/server/main.go b/server/main.go index 72f54b9..7b07c35 100644 --- a/server/main.go +++ b/server/main.go @@ -182,7 +182,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { parts := strings.Split(strings.Trim(r.URL.Path, "/"), "/") fail := func(e error) { http.Error(w, e.Error(), 400) } if r.URL.Path == "/api/v1/health" { - jsonOut(w, map[string]any{"version": "0.8.0", "installActions": true, "privateFileList": true, "remoteADB": true, "syncPreflight": true, "dedicatedGit": true, "adminCLI": true, "preflight": true, "textComparison": true, "jdkSelection": true, "workspaceSelection": true, "os": runtime.GOOS, "sync": "http-manifest", "recovery": true}) + jsonOut(w, map[string]any{"version": "0.8.1", "installActions": true, "privateFileList": true, "remoteADB": true, "syncPreflight": true, "dedicatedGit": true, "adminCLI": true, "preflight": true, "textComparison": true, "jdkSelection": true, "workspaceSelection": true, "os": runtime.GOOS, "sync": "http-manifest", "recovery": true}) return } if r.URL.Path == "/api/v1/environment" && r.Method == "GET" { diff --git a/server/workspace.go b/server/workspace.go index 68af4a1..fa9bbe2 100644 --- a/server/workspace.go +++ b/server/workspace.go @@ -404,7 +404,7 @@ func sourceInventoryMode(work string, dedicated bool) (map[string]File, error) { } func compareGit(local, remote *GitSnapshot) error { if remote != nil && local == nil { - return fmt.Errorf("服务端存在 Git 仓库,但本机无法读取 Git 状态") + return fmt.Errorf("服务端目录是 Git 仓库,但本机未提供 Git 状态;请确认本机工程是同一 Git 仓库且 Git 可用,或改用没有 .git 的服务端目录") } if local != nil && remote != nil && local.Head != remote.Head { return fmt.Errorf("两边 Git 提交不同,请先手动同步仓库;本机 HEAD=%s,服务端 HEAD=%s", local.Head, remote.Head)