Skip to content

Self-hosted workflows for coding-agent delivery. Orchestrate CodeBuddy, Codex and Claude Code with scripts and human approval gates. Includes Local workflows for coding assistants.

fix: keep executable bits when installing Classic hook scripts

roberttwangdde5507ea13e
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7ed84502..816e7bc7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,10 @@
English | [简体中文](CHANGELOG.zh-CN.md)
+## Unreleased
+
+- Keep executable bits when installing Classic host files so `run_hook.sh` can run after `npx loopforge-cli install`, restoring Agent Observability collection.
+
## 0.2.1
- Added `tools/tcmcp`, a Tencent Cloud read-only MCP Initializr that is documented and run separately from `loopforge install`. LoopForge version tags also publish `ghcr.io/tencent/loopforge-tcmcp`.
diff --git a/CHANGELOG.zh-CN.md b/CHANGELOG.zh-CN.md
index 5f7167f3..f12c7bd8 100644
--- a/CHANGELOG.zh-CN.md
+++ b/CHANGELOG.zh-CN.md
@@ -2,6 +2,10 @@
[English](CHANGELOG.md) | 简体中文
+## Unreleased
+
+- 安装 Classic 宿主文件时保留可执行权限,避免 `run_hook.sh` 装完无法执行,导致 Agent Observability 采不到数。
+
## 0.2.1
- 新增 `tools/tcmcp`:腾讯云只读 MCP Initializr,与 `loopforge install` 分开文档化与运行。LoopForge 版本 tag 同时发布 `ghcr.io/tencent/loopforge-tcmcp`。
diff --git a/src/devflow_cli/core.py b/src/devflow_cli/core.py
index 67d532a9..b04a8ac0 100644
--- a/src/devflow_cli/core.py
+++ b/src/devflow_cli/core.py
@@ -2,6 +2,7 @@ import hashlib
import json
import os
import shutil
+import stat
import subprocess
import sys
import tempfile
@@ -24,6 +25,25 @@ def digest(data: bytes) -> str:
return hashlib.sha256(data).hexdigest()
+def file_mode(path: Path) -> int:
+ mode = stat.S_IMODE(path.stat().st_mode)
+ if path.suffix == ".sh":
+ mode |= 0o111
+ return mode
+
+
+def apply_mode(path: Path, mode: int) -> None:
+ mode = stat.S_IMODE(mode)
+ if path.suffix == ".sh":
+ mode |= 0o111
+ path.chmod(mode)
+
+
+def write_payload(path: Path, data: bytes, mode: int) -> None:
+ path.write_bytes(data)
+ apply_mode(path, mode)
+
+
def asset_root() -> Path:
override = os.environ.get("DEVFLOW_ASSET_ROOT")
candidates = []
@@ -59,7 +79,7 @@ def save_state(project: Path, state: dict) -> None:
path.write_text(json.dumps(state, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
-def snapshot(root: Path) -> Dict[str, bytes]:
+def snapshot(root: Path) -> Dict[str, Tuple[bytes, int]]:
result = {}
for path in sorted(root.rglob("*")):
if not path.is_file() or "__pycache__" in path.parts or path.suffix == ".pyc":
@@ -67,7 +87,7 @@ def snapshot(root: Path) -> Dict[str, bytes]:
relative = str(path.relative_to(root))
if relative.endswith(".devflow-managed-skills.json"):
continue
- result[relative] = path.read_bytes()
+ result[relative] = (path.read_bytes(), file_mode(path))
return result
@@ -135,7 +155,7 @@ def materialize_classic(host: str, stage: Path) -> None:
copy_skill(source_dir, links / name)
-def build_plan(host: str, edition: str) -> Dict[str, bytes]:
+def build_plan(host: str, edition: str) -> Dict[str, Tuple[bytes, int]]:
from .targets import load
with tempfile.TemporaryDirectory(prefix="devflow-install-") as temporary:
@@ -224,7 +244,7 @@ def apply_install(
raise DevFlowError(f"尚未安装 {edition}/{host}")
old_files = {item["path"]: item for item in (previous or {}).get("files", [])}
conflicts = []
- for relative, data in plan.items():
+ for relative, (data, _mode) in plan.items():
destination = project / relative
parent_conflict = blocking_parent(project, destination)
if parent_conflict is not None:
@@ -270,7 +290,7 @@ def apply_install(
remove_path(destination)
elif destination.is_file() and not destination.is_symlink() and digest(destination.read_bytes()) == old["sha256"]:
destination.unlink()
- for relative, data in sorted(plan.items()):
+ for relative, (data, mode) in sorted(plan.items()):
destination = project / relative
if (
blocking_parent(project, destination) is None
@@ -278,13 +298,14 @@ def apply_install(
and not destination.is_symlink()
and destination.read_bytes() == data
):
+ apply_mode(destination, mode)
unchanged += 1
else:
if force:
prepare_forced_destination(project, destination)
else:
destination.parent.mkdir(parents=True, exist_ok=True)
- destination.write_bytes(data)
+ write_payload(destination, data, mode)
installed += 1
records.append({"path": relative, "sha256": digest(data)})
state["installations"][key] = {
diff --git a/tests/test_installer.py b/tests/test_installer.py
index 38500004..7c992e87 100644
--- a/tests/test_installer.py
+++ b/tests/test_installer.py
@@ -1,4 +1,5 @@
import os
+import stat
import subprocess
import sys
import tempfile
@@ -262,6 +263,31 @@ class InstallerTests(unittest.TestCase):
self.assertIn("permissionMode: bypassPermissions", text)
self.assertIn("enabledAutoRun: true", text)
+ def test_classic_install_makes_observability_hook_executable(self):
+ hooks = (
+ ("codebuddy", ".codebuddy/skills/agent-observability/scripts/run_hook.sh"),
+ ("cursor", ".cursor/skills/agent-observability/scripts/run_hook.sh"),
+ ("claude", ".claude/skills/agent-observability/scripts/run_hook.sh"),
+ )
+ for host, relative in hooks:
+ with self.subTest(host=host), tempfile.TemporaryDirectory() as temporary:
+ project = self.project(temporary)
+ apply_install(project, host, "classic")
+ hook = project / relative
+ self.assertTrue(hook.is_file(), relative)
+ self.assertTrue(hook.stat().st_mode & stat.S_IXUSR, relative)
+
+ def test_update_restores_missing_executable_bit_on_hook(self):
+ with tempfile.TemporaryDirectory() as temporary:
+ project = self.project(temporary)
+ apply_install(project, "codebuddy", "classic")
+ hook = project / ".codebuddy/skills/agent-observability/scripts/run_hook.sh"
+ hook.chmod(0o644)
+ written, unchanged = apply_install(project, "codebuddy", "classic", update_only=True)
+ self.assertEqual(0, written)
+ self.assertGreater(unchanged, 0)
+ self.assertTrue(hook.stat().st_mode & stat.S_IXUSR)
+
if __name__ == "__main__":
unittest.main()