Official Codebase of 3DCodeVerse
Python
agents: a harness session sees only the skills the harness routed
gaoypeng1220c9493f3b
diff --git a/harness/codeverse3d/agents/backends.py b/harness/codeverse3d/agents/backends.pyindex 89351750..ff51cbe3 100644--- a/harness/codeverse3d/agents/backends.py+++ b/harness/codeverse3d/agents/backends.py@@ -6,8 +6,8 @@ prompt on stdin (every backend: ``cli_common.invoke``).* env hardening: host secrets stripped, one pool key as ``GEMINI_API_KEY``,``GEMINI_CLI_SYSTEM_SETTINGS_PATH`` (per session, in the trajectory dir) forcingapi-key auth + dynamic model configuration (otherwise an unknown model is *silently*- substituted), ``skills.enabled``, the 3dcode MCP server and ``mcp.allowed``, Node heap- cap, no self-relaunch.+ substituted), ``skills.enabled`` with the CLI's own built-in skills disabled, the 3dcode+ MCP server and ``mcp.allowed``, Node heap cap, no self-relaunch.* gemini-cli's own chat record of the attempt (``~/.gemini/tmp/<project>/chats/session-*.jsonl``, found by ``gemini_chat_records``) is read once (``read_gemini_chats``):its tool calls become the transcript's ``tool_call`` rows (``cli_common.record_tool_calls``;@@ -77,6 +77,12 @@ from codeverse3d.proc import read_jsonl_lenient, run_subprocesslog = logging.getLogger(__name__)+#: the skills gemini-cli 0.53 ships in its own install (``bundle/builtin/``): listed to the model+#: next to the routed bundles, and ``skills.disabled`` is the only switch — by name (2026-09-22).+#: The user-level roots (``~/.gemini/skills``, ``~/.agents/skills``) have no settings switch at+#: all; none exist on this machine.+GEMINI_BUILTIN_SKILLS = ("skill-creator", "antigravity-support")+SYSTEM_SETTINGS = {# folderTrust must be OFF: with it on, gemini-cli silently disables the workspace# .gemini/settings.json mcpServers (even with --skip-trust) → no 3dcode tools. It is@@ -88,8 +94,9 @@ SYSTEM_SETTINGS = {"general": {"topicUpdateNarration": False},# default true in 0.53, but a user's ~/.gemini/settings.json (or an agent-written# ws/.gemini/settings.json) could turn it off; this file is merged LAST, so the routed- # bundles stay indexed and ``activate_skill`` stays registered (2026-09-22)- "skills": {"enabled": True},+ # bundles stay indexed and ``activate_skill`` stays registered (2026-09-22). The+ # CLI's own built-ins are off: a session sees the bundles the harness routed, nothing else+ "skills": {"enabled": True, "disabled": list(GEMINI_BUILTIN_SKILLS)},}#: gemini-cli's skill-activation tool (0.53: ``activate_skill``, arg ``name``); the body#: comes back in the tool result, so its call — not a file read — is the activation@@ -525,6 +532,19 @@ ALLOWED_TOOLS = ("Read", "Edit", "Write", "MultiEdit", "Glob", "Grep", "Skill","Bash(node:*)", "Bash(python:*)", "Bash(python3:*)", "Bash(ls:*)", f"mcp__{MCP_SERVER_NAME}__*")#: claude-code's skill-activation tool (2.1.280: input ``{"skill": <name>, "args"?}``)CLAUDE_SKILL_TOOL = "Skill"+#: A harness session sees the bundles the harness routed into ``<ws>/.claude/skills`` and+#: nothing else. claude-code 2.1.280 otherwise lists 26 more (2026-09-22 rig): the account-+#: synced skills and plugins (``anthropic-skills:*``, ``deep-research``, …) come with the+#: "user" setting source, so ``--setting-sources project`` drops them — and with them the+#: owner's ~/.claude/settings.json (hooks, env, effortLevel: sessions ran at its "xhigh" and+#: now run at the CLI's default "high"): a session no longer inherits whoever runs the+#: harness. The bundled skills go with ``CLAUDE_CODE_DISABLE_BUNDLED_SKILLS`` (build_env);+#: ``design`` and ``doctor`` survive that switch by design and are hidden by name through the+#: documented ``skillOverrides`` setting. Checked against a local fake API and in one live+#: subscription session (2026-09-22): the init event lists exactly the routed bundles, and+#: subscription auth does not need the user setting source.+CLAUDE_SETTING_SOURCES = "project"+CLAUDE_SETTINGS = {"skillOverrides": {"design": "off", "doctor": "off"}}def parse_claude_json(stdout: str) -> dict[str, Any] | None:@@ -675,6 +695,7 @@ class ClaudeCodeAgent(_CliAgent):argv = [self.binary, "-p", "--output-format", "stream-json", "--verbose","--dangerously-skip-permissions","--max-turns", str(job.max_turns), "--no-session-persistence",+ "--setting-sources", CLAUDE_SETTING_SOURCES, "--settings", json.dumps(CLAUDE_SETTINGS),"--allowedTools", ",".join(ALLOWED_TOOLS)]if self.model:argv += ["--model", self.model]@@ -696,7 +717,9 @@ class ClaudeCodeAgent(_CliAgent):def build_env(self, s: Session) -> dict[str, str]:# keep ANTHROPIC_API_KEY if the user relies on it; subscription auth needs nothing- return hardened_env(s.ws, s.job, keep={"ANTHROPIC_API_KEY", "CLAUDE_CODE_OAUTH_TOKEN"})+ env = hardened_env(s.ws, s.job, keep={"ANTHROPIC_API_KEY", "CLAUDE_CODE_OAUTH_TOKEN"})+ env["CLAUDE_CODE_DISABLE_BUNDLED_SKILLS"] = "1" # see CLAUDE_SETTINGS+ return envdef run(self, job: AgentJob) -> AgentResult:ok, why = self.available()@@ -750,6 +773,12 @@ class ClaudeCodeAgent(_CliAgent):# ===================================================================== codex+#: ``-c`` for every codex session: the routed bundles in ``<ws>/.agents/skills`` only. codex+#: 0.155.1 otherwise lists its five bundled ``.system`` skills (imagegen, openai-docs,+#: plugin-creator, skill-creator, skill-installer) next to them — gone with this switch+#: (``codex debug prompt-input``, 2026-09-22). User-level roots (``~/.codex/skills``,+#: ``~/.agents/skills``) have no stable switch; none exist on this machine.+CODEX_SKILL_OVERRIDES = ("-c", "skills.bundled.enabled=false")_TOOL_ITEMS = ("command_execution", "file_change", "mcp_tool_call", "web_search", "tool_call")#: the item fields a tool trace keeps: what was run, never what came back. codex has no#: skill tool — it lists skills in its prompt and opens SKILL.md with a shell command, so@@ -867,6 +896,7 @@ class CodexAgent(_CliAgent):if self.model:argv += ["--model", self.model]argv += effort_overrides(self.reasoning_effort)+ argv += CODEX_SKILL_OVERRIDESif job.spatial_tools:argv += codex_mcp_overrides(mcp_command_for(s.ws, job))argv.append("-")diff --git a/harness/tests/agents/test_claude_code.py b/harness/tests/agents/test_claude_code.pyindex 9d4b6aa5..9cbb1f1a 100644--- a/harness/tests/agents/test_claude_code.py+++ b/harness/tests/agents/test_claude_code.py@@ -47,6 +47,7 @@ prompt = sys.stdin.read()assert "--dangerously-skip-permissions" in args and "--output-format" in argsassert "--strict-mcp-config" in argsassert "FAKE_SERVICE_API_KEY" not in os.environ+assert args[args.index("--setting-sources") + 1] == "project" and os.environ["CLAUDE_CODE_DISABLE_BUNDLED_SKILLS"] == "1"mode = os.environ.get("FAKE_MODE", "ok")if mode == "usage_limit": # the subscription is spent: a result event, is_error, and claude's own wordsprint(json.dumps({"type": "result", "subtype": "success", "is_error": True, "num_turns": 1,@@ -110,6 +111,23 @@ def test_argv_includes_mcp_when_materialized(tmp_ws: Workspace):assert "--mcp-config" not in a.build_argv(s2)+def test_a_session_sees_only_the_routed_skills(tmp_ws: Workspace):+ """claude-code 2.1.280 listed 26 skills besides the routed bundles (2026-09-22 rig). No+ "user" setting source drops the account-synced skills and plugins; the env switch drops the+ bundled ones; the two that survive it by design are hidden by name. Checked against a local+ fake API: the init event then lists exactly the routed bundles."""+ from codeverse3d.agents.backends import CLAUDE_SETTINGS++ a = ClaudeCodeAgent("sonnet", binary="claude")+ s = begin_session(AgentJob(workspace=str(tmp_ws.root), prompt="p", spatial_tools=False), "claude-code")+ argv = a.build_argv(s)+ assert argv[argv.index("--setting-sources") + 1] == "project"+ assert json.loads(argv[argv.index("--settings") + 1]) == CLAUDE_SETTINGS == {+ "skillOverrides": {"design": "off", "doctor": "off"}}+ assert a.build_env(s)["CLAUDE_CODE_DISABLE_BUNDLED_SKILLS"] == "1"+ assert "--disable-slash-commands" not in argv # claude-code: "Disable all skills" — the routed ones too++def test_the_usage_limit_is_quota_not_a_transient_death(tmp_ws: Workspace, fake_bin, monkeypatch):a = ClaudeCodeAgent("sonnet", binary=fake_bin("claude", FAKE_CLAUDE))monkeypatch.setenv("FAKE_MODE", "usage_limit")diff --git a/harness/tests/agents/test_codex.py b/harness/tests/agents/test_codex.pyindex 5711cab8..ed183587 100644--- a/harness/tests/agents/test_codex.py+++ b/harness/tests/agents/test_codex.py@@ -30,6 +30,7 @@ ws = args[args.index("-C") + 1]assert args[-1] == "-", "the prompt comes on stdin"prompt = sys.stdin.read()assert "FAKE_SERVICE_API_KEY" not in os.environ+assert "skills.bundled.enabled=false" in argsos.makedirs(os.path.join(ws, "src"), exist_ok=True)open(os.path.join(ws, "src", "hello.txt"), "w").write(prompt[:5])mode = os.environ.get("FAKE_MODE", "ok")@@ -74,6 +75,8 @@ def test_argv_with_mcp_overrides(tmp_ws: Workspace):assert argv[argv.index("--sandbox") + 1] == "workspace-write" and "--skip-git-repo-check" in argvjoined = " ".join(argv)assert 'mcp_servers.3dcode.command="' in joined and "mcp_servers.3dcode.args=[" in joined and argv[-1] == "-"+ # the routed bundles only: codex's five bundled .system skills are switched off (codex debug prompt-input)+ assert argv[argv.index("skills.bundled.enabled=false") - 1] == "-c"# codex exec has nobody to answer the per-tool approval elicitation → every MCP call would be cancelledassert 'mcp_servers.3dcode.default_tools_approval_mode="approve"' in argvassert argv[argv.index("--model") + 1] == "gpt-5.6-sol"diff --git a/harness/tests/agents/test_tool_trace.py b/harness/tests/agents/test_tool_trace.pyindex f586908d..3ff2d337 100644--- a/harness/tests/agents/test_tool_trace.py+++ b/harness/tests/agents/test_tool_trace.py@@ -188,6 +188,14 @@ def test_gemini_system_settings_pin_skills_on_and_keep_the_workspace_trusted(tmpassert data["security"]["folderTrust"] == {"enabled": False}+def test_gemini_sessions_see_the_routed_bundles_and_not_the_clis_own(tmp_path):+ """0.53 lists its two built-in skills (bundle/builtin/) to the model next to the routed+ bundles — seen in the request body a local fake API received, 2026-09-22 — and+ ``skills.disabled`` (by name) is the only switch; the fake API then saw neither."""+ data = json.loads(write_system_settings(tmp_path / "s.json").read_text())+ assert data["skills"]["disabled"] == ["skill-creator", "antigravity-support"]++def test_the_chat_record_is_the_usage_of_a_session_that_printed_no_envelope(tmp_path):"""Every reply once (the record re-writes a message as it progresses), its tokens in theenvelope's ``stats.models`` shape — the sum reproduced two live envelopes to the token."""