@@ -175,10 +175,11 @@ function datamachine_code_pos( string $haystack, string $needle, string $label )
175175 )
176176);
177177datamachine_code_context_assert (! is_wp_error ($ virtual_injection ), 'virtual context injection succeeds ' );
178- datamachine_code_context_assert (! is_link ($ virtual_agents ), 'virtual AGENTS.md projection is not a host symlink ' );
179- datamachine_code_context_assert (is_file ($ virtual_agents ), 'virtual AGENTS.md projection is written inline ' );
180- datamachine_code_context_assert (str_contains ((string ) file_get_contents ($ virtual_agents ), '# Virtual Memory ' ), 'inline virtual projection contains rendered context ' );
181- datamachine_code_context_assert (trim (file_get_contents ($ virtual_root . '/.datamachine/AGENTS.md.source ' )) === "inline \n/wordpress/AGENTS.md " , 'virtual projection marker records inline source ' );
178+ datamachine_code_context_assert (! file_exists ($ virtual_agents ) && ! is_link ($ virtual_agents ), 'virtual AGENTS.md projection is not written at the worktree root ' );
179+ $ virtual_config = json_decode ((string ) file_get_contents ($ virtual_root . '/.opencode/opencode.json ' ), true );
180+ datamachine_code_context_assert (is_array ($ virtual_config ), 'virtual context writes local OpenCode config ' );
181+ datamachine_code_context_assert (in_array ($ virtual_root . '/.claude/CLAUDE.local.md ' , $ virtual_config ['instructions ' ] ?? array (), true ), 'virtual context points OpenCode at host-visible local snapshot ' );
182+ datamachine_code_context_assert (! file_exists ($ virtual_root . '/.datamachine/AGENTS.md.source ' ), 'virtual context does not write root projection marker ' );
182183
183184$ existing_injection = \DataMachineCode \Workspace \WorktreeContextInjector::inject (
184185 $ existing_root ,
@@ -200,8 +201,8 @@ function datamachine_code_pos( string $haystack, string $needle, string $label )
200201datamachine_code_context_assert (! file_exists ($ worktree_root . '/.datamachine/AGENTS.md.source ' ), 'projection marker is gone after uninject ' );
201202datamachine_code_context_assert (! file_exists ($ worktree_root . '/.opencode/AGENTS.local.md ' ), 'uninject removes legacy fake OpenCode local snapshot ' );
202203$ virtual_removed = \DataMachineCode \Workspace \WorktreeContextInjector::uninject ($ virtual_root );
203- datamachine_code_context_assert (in_array ($ virtual_agents , $ virtual_removed ['removed ' ], true ), 'uninject removes inline virtual AGENTS.md projection ' );
204- datamachine_code_context_assert (! file_exists ($ virtual_agents ), 'inline virtual projection is gone after uninject ' );
204+ datamachine_code_context_assert (in_array ($ virtual_root . ' /.opencode/opencode.json ' , $ virtual_removed ['removed ' ], true ), 'uninject removes virtual OpenCode projection config ' );
205+ datamachine_code_context_assert (! file_exists ($ virtual_root . ' /.opencode/opencode.json ' ), 'virtual OpenCode projection config is gone after uninject ' );
205206$ existing_removed = \DataMachineCode \Workspace \WorktreeContextInjector::uninject ($ existing_root );
206207datamachine_code_context_assert (! file_exists ($ existing_root . '/.opencode/opencode.json ' ), 'uninject removes DMC-created OpenCode projection config ' );
207208datamachine_code_context_assert (in_array ($ existing_root . '/.opencode/opencode.json ' , $ existing_removed ['removed ' ], true ), 'removed OpenCode projection config is reported ' );
@@ -211,6 +212,7 @@ function datamachine_code_pos( string $haystack, string $needle, string $label )
211212array_map ('unlink ' , glob ($ existing_root . '/.claude/* ' ) ?: array ());
212213array_map ('unlink ' , glob ($ existing_root . '/.opencode/* ' ) ?: array ());
213214array_map ('unlink ' , glob ($ virtual_root . '/.claude/* ' ) ?: array ());
215+ array_map ('unlink ' , glob ($ virtual_root . '/.opencode/* ' ) ?: array ());
214216array_map ('rmdir ' , array_filter (glob ($ worktree_root . '/* ' ) ?: array (), 'is_dir ' ));
215217array_map ('rmdir ' , array_filter (glob ($ existing_root . '/* ' ) ?: array (), 'is_dir ' ));
216218array_map ('rmdir ' , array_filter (glob ($ virtual_root . '/* ' ) ?: array (), 'is_dir ' ));
@@ -223,6 +225,7 @@ function datamachine_code_pos( string $haystack, string $needle, string $label )
223225rmdir ($ existing_root . '/.opencode ' );
224226rmdir ($ existing_root . '/.datamachine ' );
225227rmdir ($ virtual_root . '/.claude ' );
228+ rmdir ($ virtual_root . '/.opencode ' );
226229rmdir ($ virtual_root . '/.datamachine ' );
227230rmdir ($ worktree_root );
228231rmdir ($ existing_root );
0 commit comments