Skip to content

Commit 3848ddd

Browse files
authored
fix(agents-md): include resolved workspace root (#58)
1 parent 3502f6f commit 3848ddd

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

data-machine-code.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,8 @@ function datamachine_code_load_chat_tools() {
313313

314314
// Data Machine — memory, automation, code, system.
315315
\DataMachine\Engine\AI\SectionRegistry::register( 'AGENTS.md', 'datamachine', 10, function () use ( $wp ) {
316+
$workspace_path = datamachine_code_resolve_workspace_path_for_agents_md();
317+
316318
return <<<MD
317319
## Data Machine
318320
@@ -346,6 +348,7 @@ function datamachine_code_load_chat_tools() {
346348
- External sites & handler tests: `{$wp} datamachine external|test`
347349
348350
**Code (data-machine-code):** All code changes go through the managed workspace and GitHub — never edit site files directly.
351+
- Workspace root: `{$workspace_path}`
349352
- Workspace: `{$wp} datamachine-code workspace clone|worktree|read|write|edit|ls|list|show|remove|git` — clone repos, create per-branch worktrees, edit files, commit, and push
350353
- GitHub: `{$wp} datamachine-code github issues|pulls|repos|comment` — create PRs, manage issues, comment on reviews
351354
- Git sync: `{$wp} datamachine-code gitsync` — sync workspace repos with remotes
@@ -483,3 +486,24 @@ function datamachine_code_resolve_wp_cli_cmd(): string {
483486
*/
484487
return apply_filters( 'datamachine_wp_cli_cmd', $default );
485488
}
489+
490+
/**
491+
* Resolve the live workspace path for agent-facing instructions.
492+
*
493+
* AGENTS.md can be recomposed long after setup. Resolve from Workspace at
494+
* compose time so custom DATAMACHINE_WORKSPACE_PATH installs do not regress to
495+
* generic/default workspace guidance after invalidation.
496+
*
497+
* @return string Resolved workspace path or a diagnostic fallback.
498+
*/
499+
function datamachine_code_resolve_workspace_path_for_agents_md(): string {
500+
if ( class_exists( '\DataMachineCode\Workspace\Workspace' ) ) {
501+
$workspace_path = ( new \DataMachineCode\Workspace\Workspace() )->get_path();
502+
503+
if ( '' !== $workspace_path ) {
504+
return $workspace_path;
505+
}
506+
}
507+
508+
return 'unavailable; run datamachine-code workspace path to diagnose';
509+
}

0 commit comments

Comments
 (0)