Skip to content

[Misc] Follow platform conventions for the default work directory - #94

Open
ClementEXWiki wants to merge 4 commits into
xwiki:masterfrom
ClementEXWiki:feat/follow-dir-conventions
Open

[Misc] Follow platform conventions for the default work directory#94
ClementEXWiki wants to merge 4 commits into
xwiki:masterfrom
ClementEXWiki:feat/follow-dir-conventions

Conversation

@ClementEXWiki

Copy link
Copy Markdown

Jira URL

N/A

Changes

Description

  • Default work-directory root is now $XDG_STATE_HOME/xwiki-llm (falling back to ~/.local/state/xwiki-llm) on Linux/macOS, and %LOCALAPPDATA%\xwiki-llm on Windows, instead of the unconditional ~/.xwiki-llm/work used on every OS. XWIKI_LLM_WORK still overrides it.
  • Update README.md, xwiki-org.md and the two skill docs that restated the old default.
  • Bump the plugin version to 1.4.2.

Clarifications

Screenshots & Video

N/A

Executed Tests

N/A

Expected merging strategy

  • Prefers squash: Yes
  • Backport on branches:
    *

ClementEXWiki and others added 2 commits August 31, 2026 15:01
* Default work-directory root is now $XDG_STATE_HOME/xwiki-llm (falling
  back to ~/.local/state/xwiki-llm) on Linux/macOS, and
  %LOCALAPPDATA%\xwiki-llm on Windows, instead of the unconditional
  ~/.xwiki-llm/work used on every OS. XWIKI_LLM_WORK still overrides it.
* Update README.md, xwiki-org.md and the two skill docs that restated
  the old default.
* Bump the plugin version to 1.4.2.
* Resolve the plugin-version conflicts on master's 1.5.0, bumped to 1.5.1 for this change.
* Resolve the platform state root in a single place, xwiki/scripts/state-dir.mjs, and use it from
  both the SessionStart hook (work directory) and xwiki-it-slot.mjs (IT slot files), so the plugin
  owns one root per machine and the platform rules are written down once.
* Add the fallbacks the rule was missing: ~/.local/state/xwiki-llm/work when XDG_STATE_HOME is
  unset, and %USERPROFILE%\AppData\Local\xwiki-llm\work when LOCALAPPDATA is unset.
* Stop restating those rules in xwiki-org.md and the two skill docs — the hook injects the resolved
  absolute path (state-dir.mjs prints it for opencode, which has no hook), and README.md's
  XWIKI_LLM_WORK table row is the one human-readable copy.
* Tell the developer, once per session for as long as anything is still there, to move what the
  pre-1.5.1 default left in ~/.xwiki-llm/work.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@vmassol

vmassol commented Sep 1, 2026

Copy link
Copy Markdown
Member

I've pushed a merge of master onto this branch (7b59f33) that resolves the conflicts and follows up on two points. Summary of what changed and why:

Conflicts. They were version-only: master had moved to 1.5.0 while this branch carried 1.4.2. Resolved on 1.5.0 and bumped to 1.5.1 for this change, in all four manifests.

The rule was incomplete. defaultWorkRoot() did handle the unset case, but every doc restated only the env-var half ($XDG_STATE_HOME/xwiki-llm), which is not what a reader gets on a stock macOS or Windows box — neither variable is set by default there, so the fallback is the common path, not the edge case. The full resolution is now written out once, in the XWIKI_LLM_WORK row of README.md's environment-variable table:

platform variable set variable unset
Linux/macOS $XDG_STATE_HOME/xwiki-llm/work ~/.local/state/xwiki-llm/work
Windows %LOCALAPPDATA%\xwiki-llm\work %USERPROFILE%\AppData\Local\xwiki-llm\work

All four branches are verified by running the hook, simulating win32 for the two Windows ones.

Duplication. Two kinds, both removed:

  • In codemaster meanwhile added xwiki-it-slot.mjs, which computes its own ~/.xwiki-llm/it-slots. Left as it was, the plugin would own two unrelated roots on a developer's machine and follow the platform convention in only one of them. There is now a single xwiki/scripts/state-dir.mjs (stateRoot(), workRoot(), itSlotDir()), imported by both the SessionStart hook and the slot script, so the platform rules exist in exactly one place and everything lives under one root: <state>/xwiki-llm/{work,it-slots}.
  • In prose — the platform formula was restated in five places (README twice, xwiki-org.md, conversion-plan.md, the xwiki-doc-writing tools README). The hook already appends the resolved absolute path to the injected conventions, so those files no longer need the formula at all and now just say "the work directory". That also buys back bytes in xwiki-org.md, which is injected into every session and is budget-checked.

Two judgment calls worth calling out, happy to revert either:

  • The default root gained a /work segment (<state>/xwiki-llm/work, not <state>/xwiki-llm) so that it-slots can sit beside it under the one root — the exact analogue of the old ~/.xwiki-llm/work layout.
  • instructions/xwiki-org.md is read verbatim by opencode, which has no SessionStart hook to append the resolved path. Pointing it only at "the end of this file" would therefore have left opencode users with no definition at all, so state-dir.mjs is also runnable — node "$XWIKI_LLM_HOME/xwiki/scripts/state-dir.mjs" prints the work root — and the instruction names that as the fallback.

Migration. Since the default moves, the hook now checks ~/.xwiki-llm/work and, for as long as anything is still in it, appends a notice asking the developer to move its contents (or to point XWIKI_LLM_WORK at the old path), explicitly telling the agent not to move or delete anything itself. It disappears once the directory is empty or gone. Confirmed firing on a machine that still has files there.

node scripts/validate.mjs and claude plugin validate ./xwiki both pass, and CI is green.

vmassol and others added 2 commits September 1, 2026 16:27
* Five manifests carry one version, so every concurrent pull request conflicted with every other one
  on those same five lines, over something that was never part of either change. The release is now
  cut on master after the merge by scripts/release.mjs, and scripts/validate.mjs fails a branch that
  touches a version field.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

2 participants