Skip to content

Use each xmd repl session directory as its workspace #975

Open

Description

@taras

Story

As a person working with the Sidekick in xmd repl, I want the existing session directory to be its workspace, so components, copied inputs and generated files stay with the conversation and relative paths have a predictable starting point.

Common path

A session already has a directory containing its REPL and Sidekick journals. Startup also provides components/ inside that directory and makes those components available automatically.

The Sidekick writes components/Greeting.md; a subsequent entry invokes <Greeting /> without a manual include option or restart. XMD executed by the Sidekick uses the session workspace as its default working directory: writing notes.md or copying an input to inputs/request.md places those files beneath that session directory. The host establishes this default through XMD's existing contextual working-directory mechanism, as <Dir> does.

Reopening the session finds the same workspace, components, files and journals. A different session has its own workspace.

Current gap

The session directory stores conversation history but is not the default filesystem location described above. #896 owns creating, testing and reusing Sidekick components and leaves the directory's location and lifetime for a product decision. It does not establish the broader session workspace or the default working directory for Sidekick-executed XMD.

Accepted direction

  • Reuse the existing session directory as the workspace rather than creating a separate temporary artifact root. Establish it and its components/ directory before the first Sidekick evaluation or entry that uses them.
  • Include the workspace components directory automatically in ordinary component discovery, validation and execution. Definitions written before a subsequent entry are available to it; writing a component alone does not execute it.
  • Establish the workspace as the contextual working directory around Sidekick XMD evaluation, using the same scoped mechanism as <Dir>. Relative file reads, writes and copy destinations use that directory. An explicit nested <Dir> selects another authorized directory for its content; the enclosing directory is restored when it finishes. Success, failure and cancellation do not leak the session cwd into sibling or caller scopes. No new REPL.Environment field or workspace-discovery component is required.
  • Keep session-owned components, imported inputs, generated documents, handoffs, results and evidence in the workspace by default. This directory convention does not automatically ingest every file into a journal or make mutable files historical snapshots.
  • Preserve the workspace across exit and cold reopen. Resume the same session with its existing identities and recorded execution; completed operations are not rerun merely to rebuild history.
  • Preserve the originally selected project repository, worktrees and CLI path arguments when changing the default execution directory. Resolve project selection and invocation-relative options deliberately rather than accidentally treating the session directory as the project. Do not move or reset existing source checkouts or replace agent sessions as a side effect.
  • Preserve existing permission and component-name protections. A new working directory or include path grants no additional effects or filesystem access.

Decisions before implementation

  • Consider moving the REPL and Sidekick journals into a dot directory beneath the workspace to separate host-owned history from authored files. Its name and exact layout remain open. Define compatibility for existing sessions before moving any journal; preserve their complete histories.
  • Settle whether the workspace working-directory default also applies to every human-authored REPL entry. Sidekick evaluation and submitted-entry behavior must be explicit, without an accidental difference between validation and execution.
  • Settle include precedence with project components and --include, and behavior when existing workspace files are missing or malformed. Coordinate these decisions with Create, test and reuse Sidekick components in xmd repl #896 rather than creating a second component-authoring interface.

First bounded implementation slice

Set the existing session directory as the contextual cwd for Sidekick-executed XMD. Verify a relative file read/write lands there, a nested <Dir> uses its selected directory, and scope teardown restores the prior cwd on success, failure and cancellation. This slice reuses existing directory context; it introduces no environment-discovery interface.

This is independently testable before component-authoring integration or journal relocation. It does not settle the cwd default for human-authored ordinary entries. The complete story remains open until its other accepted requirements are delivered.

Acceptance and evidence

Use isolated session storage and temporary project repositories. Start a fresh production REPL without creating directories or supplying --include; observe its workspace and components directory. Create a component, invoke it in a later entry, write a relative document and copy a project input into the workspace. Confirm the exact destinations and returned contents. Confirm that the selected project repository and invocation-relative include paths still refer to the intended project.

Exit and reopen the session; the same files and component are present. A second session does not share them by default. Inspect completed history and show zero repeated file mutations or agent calls. Preserve existing journals and user files through the chosen old-session compatibility path. A failed component write or malformed component reports its actual failure without silently executing another definition.

Relationships and scope

Coordinate with #896 for automatic component availability and its authoring/testing journeys, #968 for external include paths, and #901 for session-owned TODO files and policy components. This is a REPL session workspace story; #218's provider-backed retained workflow Workspace is a separate contract. Update the REPL specification and agent-facing environment guidance when this behavior is delivered.

This story supplies the default session workspace and working-directory behavior. Ticket orchestration, artifact versioning and changes to workflow approval policy retain their separate scope.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions