Skip to content

feat(sdk): resolve ServiceConfig.cwd lazily via callback#1

Merged
matej21 merged 2 commits into
mainfrom
fix/service-cwd-callback
Jul 4, 2026
Merged

feat(sdk): resolve ServiceConfig.cwd lazily via callback#1
matej21 merged 2 commits into
mainfrom
fix/service-cwd-callback

Conversation

@matej21

@matej21 matej21 commented Jun 29, 2026

Copy link
Copy Markdown
Member

What

ServiceConfig.cwd may now be a callback (args: { workspaceDir }) => string | Promise<string>, resolved at service start (when the workspace is populated) instead of statically. Both a string and a callback result are resolved relative to the workspace dir (absolute paths pass through).

Why

Lets a service detect its working directory lazily once the workspace exists — e.g. point a monorepo's dev server / sidecar at the web package (packages/web) rather than the workspace root. Consumed by webmaster's preview stack to fix monorepo sites (the web app isn't at the repo root).

Changes

  • schema.ts: cwd?: string | ((args: ServiceCwdArgs) => string | Promise<string>) + new ServiceCwdArgs { workspaceDir }
  • service.ts: resolve cwd at start (await callback), resolve(workspaceDir, raw)

Backward compatible: existing string cwds resolve identically (relative-to-workspace; previously used as-is, which for the existing callers — absolute or workspace-rooted — is unchanged).

🤖 Generated with Claude Code

matej21 and others added 2 commits June 29, 2026 16:06
cwd may now be a `(args: { workspaceDir }) => string | Promise<string>`
callback, resolved at service start when the workspace is populated. A
string (or callback result) is resolved relative to the workspace dir so
a relative path like `packages/web` lands inside the session worktree;
absolute paths pass through. Lets a monorepo preview point its dev server
at the web package detected at start, not the workspace root.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JgccNTPcbCLKrCcBczAqeZ
@matej21 matej21 merged commit 40f4a3b into main Jul 4, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant