4242$ expected_generated_at = '<!-- generated at: {$generated_at} --> ' ;
4343$ expected_description = 'Regenerate via: wp datamachine memory compose AGENTS.md ' ;
4444$ stale_marker = 'datamachine agent compose AGENTS.md ' ;
45- $ expected_memory_agent_note = 'On multi-agent installs, pass `--agent=<slug>` to memory commands when auto-resolution is ambiguous. ' ;
46- $ expected_agent_cli = 'datamachine agent list|create|access|token|installed|install|diff ' ;
4745$ stale_agent_cli = 'datamachine agents list|create|access|tokens ' ;
4846// Workspace / GitHub subcommand lists are now generated from the
4947// command classes via CommandIntrospector (see #671) instead of hardcoded
5452$ expected_github_token = 'datamachine-code github {$github_subcmds} ' ;
5553$ expected_introspect_wiring = 'CommandIntrospector::pipe_list( ' ;
5654$ stale_hardcoded_workspace = 'workspace adopt|clone|list|show|path|hygiene|remove|worktree ' ;
57- $ expected_worktree_cli = 'datamachine-code workspace worktree add|list|remove|prune|cleanup|cleanup-artifacts|reconcile-metadata|refresh-context|finalize|mark-cleanup-eligible ' ;
55+ $ expected_worktree_token = 'datamachine-code workspace worktree {$worktree_subcmds} ' ;
5856$ expected_inventory_time = 'Generated {$generated_at} from cloned repos ' ;
5957$ expected_inventory_truth = 'workspace list` is the source of truth ' ;
6058$ expected_inventory_refresh = 'datamachine memory compose AGENTS.md{$agent_suffix} ' ;
6563$ expected_static_fresh = "'freshness' => 'static' " ;
6664$ expected_generated_fresh = "'freshness' => 'generated' " ;
6765$ expected_multisite_cond = "'conditions' => 'Only registered on multisite installs.' " ;
66+ $ expected_core_gate = 'datamachine_agents_md_enabled ' ;
6867
6968$ assert (
7069 'auto-generated marker uses memory compose command ' ,
7978 str_contains ($ source , $ expected_description )
8079);
8180$ assert (
82- 'stale agent compose command is absent ' ,
83- ! str_contains ($ source , $ stale_marker )
84- );
85- $ assert (
86- 'agent CLI guidance uses current singular command surface ' ,
87- str_contains ($ source , $ expected_agent_cli )
81+ 'AGENTS.md registration depends on Data Machine core gate ' ,
82+ str_contains ($ source , $ expected_core_gate )
8883);
8984$ assert (
90- 'memory guidance covers explicit agent slug on ambiguous installs ' ,
91- str_contains ($ source , $ expected_memory_agent_note )
85+ 'stale agent compose command is absent ' ,
86+ ! str_contains ($ source , $ stale_marker )
9287);
9388$ assert (
9489 'stale plural agent token guidance is absent ' ,
108103);
109104$ assert (
110105 'worktree guidance includes current maintenance surfaces ' ,
111- str_contains ($ source , $ expected_worktree_cli )
106+ str_contains ($ source , $ expected_worktree_token )
112107);
113108$ assert (
114109 'workspace inventory renders generation time ' ,
152147);
153148$ assert (
154149 'plugin entrypoint no longer contains AGENTS.md heredoc sections ' ,
155- ! str_contains ($ entrypoint , $ expected_agent_cli )
150+ ! str_contains ($ entrypoint , ' ## Data Machine Code ' )
156151);
157152
158153/*
@@ -211,6 +206,11 @@ function is_wp_error( $value ): bool {
211206 return false ;
212207 }
213208}
209+ if (! function_exists ('datamachine_agents_md_enabled ' ) ) {
210+ function datamachine_agents_md_enabled (): bool {
211+ return true ;
212+ }
213+ }
214214if (! class_exists ('DataMachine \\Engine \\AI \\MemoryFileRegistry ' ) ) {
215215 eval ('namespace DataMachine \\Engine \\AI; class MemoryFileRegistry { public const LAYER_SHARED = "shared"; public static array $files = array(); public static function register(...$args): void { self::$files[] = $args; } } ' );
216216}
@@ -221,10 +221,10 @@ function is_wp_error( $value ): bool {
221221require_once __DIR__ . '/../inc/Runtime/AgentsMdSections.php ' ;
222222\DataMachineCode \Runtime \AgentsMdSections::register ();
223223
224- $ datamachine_section = '' ;
224+ $ datamachine_code_section = '' ;
225225foreach ( \DataMachine \Engine \AI \SectionRegistry::$ sections as $ registered_section ) {
226- if ( isset ($ registered_section [1 ]) && 'datamachine ' === $ registered_section [1 ] && is_callable ($ registered_section [3 ] ?? null ) ) {
227- $ datamachine_section = (string ) call_user_func ($ registered_section [3 ]);
226+ if ( isset ($ registered_section [1 ]) && 'datamachine-code ' === $ registered_section [1 ] && is_callable ($ registered_section [3 ] ?? null ) ) {
227+ $ datamachine_code_section = (string ) call_user_func ($ registered_section [3 ]);
228228 break ;
229229 }
230230}
@@ -245,8 +245,8 @@ function is_wp_error( $value ): bool {
245245 false === $ command_autoloaded
246246);
247247$ assert (
248- 'Data Machine AGENTS.md section composes without WP_CLI_Command ' ,
249- str_contains ($ datamachine_section , 'datamachine-code workspace adopt|clone|list|show|path|hygiene|remove|worktree|read|write|grep|edit|git|patch|ls ' )
248+ 'Data Machine Code AGENTS.md section composes without WP_CLI_Command ' ,
249+ str_contains ($ datamachine_code_section , 'datamachine-code workspace adopt|clone|list|show|path|hygiene|remove|worktree|read|write|grep|edit|git|patch|ls ' )
250250);
251251
252252echo "\nCommandIntrospector against real command classes: \n" ;
0 commit comments