Skip to content

feat: session-aware mx work open, and initial worktrees on mx work new (3.4.0)#16

Merged
rousan merged 2 commits into
mainfrom
develop
Jul 5, 2026
Merged

feat: session-aware mx work open, and initial worktrees on mx work new (3.4.0)#16
rousan merged 2 commits into
mainfrom
develop

Conversation

@rousan

@rousan rousan commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Summary

Two changes, released together as 3.4.0.

mx work open (and mx work new -o) is now session-aware: it resumes the work's Claude session (one named after the work) when exactly one exists, creates a new named session when none exist, and errors when two or more share the name. A new session can be seeded with an initial prompt, taken from --prompt or a new session-prompt hook whose stdout becomes the prompt.

mx work new can also create initial worktrees: positional repos after the name, each repo:branch:base (branch and base optional). Per repo the branch falls back to --branch then the work name, and the base to --base then the pristine HEAD. Repos are validated up front, so a bad or duplicate repo fails before any work is created.

Runtime stays v3, no migration. typecheck, lint, tests (104), and build all pass.

rousan and others added 2 commits July 5, 2026 21:39
…sion-prompt hook (3.3.0)

`mx work open` / `mx work -n <name> open` / `-o` (and `mx work new -o`) are now
session-aware. They follow a per-work naming convention — one Claude Code session
named exactly <name> — and do the right thing:

- 0 sessions named <name>  -> create `claude -n <name>`, seeded with an initial
  prompt when one is resolved
- exactly 1                -> resume it (`claude --resume <id>`)
- 2 or more                -> MULTIPLE_SESSIONS error; resume manually

The name match is exact, so numbered parallel sessions (<name>-2, <name>-3) are
ignored and stay manual. Sessions are located by scanning the work's own Claude
project dir (~/.claude/projects/<work-path>/, keyed off the work folder's
realpath) and reading each transcript's custom title — the same field /rename and
`claude -n` write.

Initial prompt for a new session is dynamic via a new central `session-prompt`
hook: `mx work open --prompt <text>` wins, else the hook's stdout is used (cwd =
work folder; MX_WORK / MX_WORK_PATH / MX_SESSION_NAME), so it can be global or
varied per repo/work. Empty output -> clean session. Fires only on create.

- core: new claudeSessions.ts (claudeProjectDirName, readSessionTitle,
  findSessionsByName, ClaudeSession); session-prompt added to HOOK_EVENTS + a
  stamped no-op template
- cli: runHookCapture (stdout-capturing hook runner); openWorkLayout takes a
  launch command; --prompt flag; resume-or-create wiring in commands/work.ts
- tests: 6 new core cases; docs (commands, runtime-model, history, both READMEs,
  runtime CLAUDE.md template); version 3.2.0 -> 3.3.0

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…and base (3.4.0)

Positional args after the work name are pristine repos to create worktrees for
as part of `mx work new`, instead of a separate `mx work worktree add` per repo.
Each token is <repo>[:<branch>[:<base>]] (git refs can't contain ':', so the
split is unambiguous):

  mx work new feat app api                        # app + api on branch "feat"
  mx work new feat app:hotfix api                 # app on "hotfix", api on "feat"
  mx work new feat muze-ai:feat:app_ib_dev scaligent:feat:migration-to-mt-service-from-cf
  mx work new feat app::develop                   # default branch, forked from develop

Resolved per repo: branch = :<branch> -> --branch (a default for every repo
without its own) -> the work name; base (fork point) = :<base> -> --base ->
the pristine clone's HEAD. An empty branch segment (app::develop) means "use
the default branch". Repos are validated up front (unknown or duplicate repo
fails before anything is created, so no half-built work); each worktree fires
the pre/post-worktree-create hooks; combines with -o.

- core: parseInitWorktreeSpec + InitWorktreeSpec (repo/branch/base)
- cli: shared createWorktreeFiringHooks helper (used by `worktree add` and
  `work new`); new-handler parses/validates specs and creates worktrees with
  per-repo branch + base
- tests: 6 new parse cases (104 total); docs (commands, history, both READMEs,
  root CLAUDE.md, help); version 3.3.0 -> 3.4.0

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@rousan rousan changed the title feat: mx work open resumes-or-creates the work's Claude session + session-prompt hook (3.3.0) feat: session-aware mx work open, and initial worktrees on mx work new (3.4.0) Jul 5, 2026
@rousan
rousan merged commit 075c8eb into main Jul 5, 2026
1 check 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