Skip to content

Commit 7df16fd

Browse files
πŸ“– [Docs]: Ways of working now follows the canonical issue model (#97)
Ways of Working now treats Epic and PBI as planning aggregates while Task and Bug delivery leaves own implementation and pull-request closure. Workflow is the single process entry point, and ordinary stage procedures live under Ways of Working. ## Changed: Agent setup remains actionable `AGENTS.md` retains the complete agent-only installation and operating contract: improvement/escalation, ecosystem setup, local identity, README/CONTRIBUTING orientation, worktree discipline, micro-commits, push-every-commit, and MSXOrg memory's direct-main policy. ## Changed: Docs use bare backing plus canonical worktree Each docs repository uses `docs.git` as a bare backing repository and `docs` as its clean readable default-branch worktree. Missing installs create that topology directly. Safe simple clones migrate with local branches/tags verified and a retained backup; canonical and legacy worktrees are reused; unsafe states fail with rollback/actionable guidance. Memory remains a simple checkout. ## Changed: Refresh-first discovery is enforced The copied bootstrap seed refreshes and proves an existing bare default branch before creating/loading the canonical worktree. The full bootstrap then validates every configured context repository before any index traversal. --- <details> <summary>Technical details</summary> - Makes `Workflow.md` the sole process and stage-routing owner. - Moves stage procedures to `Ways-of-Working/Workflow-Stages/`. - Restores all material root AGENTS policy without copying stages. - Aligns Git Worktrees and bootstrap on sibling `docs.git` + `docs` topology. - Preserves branches/tags during simple-clone migration and rolls back failures. - Tests the executable Markdown seeds and all supported/unsafe topology states hermetically. </details> <details> <summary>Relevant issues (or links)</summary> - Fixes #86 </details> --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 65591bd commit 7df16fd

43 files changed

Lines changed: 2215 additions & 644 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

β€ŽAGENTS.mdβ€Ž

Lines changed: 64 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,72 @@
1-
# Agents
1+
# Agent Instructions
22

33
## Main directive
44

5-
Everything is a work in progress and can be updated and improved.
6-
If you find a problem, fix it if it's small; otherwise, register it as an issue in the respective repo.
5+
Everything is a work in progress and can be updated and improved. Fix a small problem when it is directly in scope; register a larger or unrelated problem as an issue in the repository that owns it.
76

8-
## Install the ecosystem
7+
This repository belongs to `github.com/MSXOrg`.
98

10-
1. Create a folder in the home directory called `.msx`:
11-
2. Clone the ecosystem locally:
12-
1. <https://github.com/MSXOrg/docs> β€” requires PRs to be updated.
13-
- Clone as bare and use worktrees.
14-
- Create a worktree for every branch. Use a concise `<issue>-<slug>` worktree folder for a topic branch named `<type>/<issue>-<slug>`.
15-
2. <https://github.com/MSXOrg/memory/> β€” work directly towards main.
16-
- Simple clone, only main.
9+
## Install and synchronize the ecosystem
1710

18-
To install:
19-
- Clone the repos in the users home folder under a sub-folder named `.msx`.
20-
- Set configs locally to each of these repos using the GitHub username and email.
11+
The agent workspace lives under `~/.msx`:
2112

22-
## Working with the ecosystem
13+
| Repository | Local path | Purpose | Change model |
14+
| --- | --- | --- | --- |
15+
| `MSXOrg/docs` | `~/.msx/docs.git` + `~/.msx/docs` | Bare backing repository plus clean readable main worktree for reviewed organization context. | Pull requests through topic worktrees only. |
16+
| `MSXOrg/memory` | `~/.msx/memory` | Durable organization memory: prior decisions, gotchas, and reusable working knowledge. | Commit and push directly to `main`, per that repository's policy. |
2317

24-
1. Get to know this repo first:
25-
- [README](README.md) for what this repository is and how it builds.
26-
- [CONTRIBUTING](CONTRIBUTING.md) for how to contribute and the review process.
27-
2. Read `~/.msx/docs` - start with the index to get an overview of what is here.
28-
3. Read `~/.msx/memory` - start with the index to get an overview of what is here. Use this while working - commit your memories here for work inside the PSModule organization.
29-
4. While working with the code, do small micro commits and push on every commit. This will make it easier to review and merge your changes.
18+
From this repository, install missing context repositories and synchronize every existing clone before use:
19+
20+
```powershell
21+
pwsh bootstrap/Initialize-MsxWorkspace.ps1 `
22+
-UserName '<github-user>' `
23+
-UserEmail '<github-noreply-email>'
24+
```
25+
26+
Projects that add their own docs and memory provide plug-in coordinates without changing the synchronization implementation:
27+
28+
```powershell
29+
$projects = @(
30+
@{
31+
Name = 'MSXOrg'
32+
Path = ''
33+
DocsUrl = 'https://github.com/MSXOrg/docs.git'
34+
MemoryUrl = 'https://github.com/MSXOrg/memory.git'
35+
}
36+
@{
37+
Name = 'PSModule'
38+
Path = 'projects/PSModule'
39+
DocsUrl = 'https://github.com/PSModule/docs.git'
40+
MemoryUrl = 'https://github.com/PSModule/memory.git'
41+
}
42+
)
43+
& ./bootstrap/Initialize-MsxWorkspace.ps1 -Project $projects
44+
```
45+
46+
The bootstrap writes identity only to each context repository's local git configuration. It must succeed before any context is read; do not continue with missing, dirty, diverged, wrong-branch, unreachable, or stale context.
47+
48+
Use a dedicated worktree for every topic branch. Follow [Git Worktrees](src/docs/Ways-of-Working/Git-Worktrees.md) for the local layout and [Branching and Merging](src/docs/Ways-of-Working/Branching-and-Merging.md) for `<type>/<issue>-<slug>` branch names.
49+
50+
## Canonical context
51+
52+
- Docs root: [src/docs/index.md](src/docs/index.md)
53+
- Organization memory: `~/.msx/memory/index.md`
54+
55+
## Before acting
56+
57+
1. Segment the work by host, organization, repository, path, and task.
58+
2. Synchronize every canonical context repository to its remote default branch; stop if any context may be stale.
59+
3. Start at the docs root index and follow [Ways of Working](src/docs/Ways-of-Working/index.md) to the canonical [Workflow](src/docs/Ways-of-Working/Workflow.md).
60+
4. Infer the current stage from the task and its artifacts, then read the linked stage procedure.
61+
5. Read [README.md](README.md), [CONTRIBUTING.md](CONTRIBUTING.md), relevant standards, and organization memory.
62+
6. Apply path-specific local rules only when they match the files in scope.
63+
64+
## Working in this repository
65+
66+
1. Use [README.md](README.md) to understand what this repository is and how it builds.
67+
2. Use [CONTRIBUTING.md](CONTRIBUTING.md) for its contribution and review contract.
68+
3. Keep work reviewable with small, descriptive micro-commits.
69+
4. Push every commit so the remote branch, CI, and draft pull request reflect current work.
70+
5. Improve organization memory when a verified lesson is likely to matter again; commit and push MSXOrg memory directly to `main`.
71+
72+
This file owns bootstrap and repository-specific operating instructions. The linked documentation owns reusable process knowledge; this file does not redefine a workflow stage, coding standard, or review convention.

β€Žbootstrap/AGENTS.template.mdβ€Ž

Lines changed: 129 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,134 @@
22

33
The single starting point for any agent, in any repository. Before doing anything else, make sure the central workspace exists locally, then read from it.
44

5+
## Main directive
6+
7+
Everything is a work in progress and can be updated and improved. Fix a small problem when it is directly in scope; register a larger or unrelated problem as an issue in the repository that owns it.
8+
59
## First β€” bootstrap the workspace
610

7-
The workspace is a git-isolated clone of the central repositories under `~/.msx`. Set it up (idempotent β€” clones what is missing, attempts to fast-forward the rest):
11+
The workspace is a git-isolated clone of the central repositories under `~/.msx`. Set it up before reading context. Existing context repositories must be clean, on their default branch, and exactly synchronized with the remote:
812

913
```powershell
10-
$docs = Join-Path $HOME '.msx/docs'
14+
$workspaceRoot = if ($env:MSX_WORKSPACE_ROOT) { $env:MSX_WORKSPACE_ROOT } else { Join-Path $HOME '.msx' }
15+
$docsUrl = if ($env:MSX_DOCS_URL) { $env:MSX_DOCS_URL } else { 'https://github.com/MSXOrg/docs.git' }
16+
$memoryUrl = if ($env:MSX_MEMORY_URL) { $env:MSX_MEMORY_URL } else { 'https://github.com/MSXOrg/memory.git' }
17+
$docs = Join-Path $workspaceRoot 'docs'
18+
$docsBacking = "$docs.git"
1119
if ((Test-Path $docs) -and -not (Test-Path (Join-Path $docs '.git'))) {
1220
throw "$docs exists but is not a git repository. Remove it and re-run."
1321
}
1422
if (-not (Test-Path (Join-Path $docs '.git'))) {
15-
New-Item -ItemType Directory -Force -Path (Split-Path -Parent $docs) | Out-Null
16-
git clone https://github.com/MSXOrg/docs.git $docs
23+
if (-not (Test-Path $docsBacking)) {
24+
New-Item -ItemType Directory -Force -Path (Split-Path -Parent $docs) | Out-Null
25+
git clone --bare $docsUrl $docsBacking
26+
if ($LASTEXITCODE -ne 0) {
27+
throw "Bare clone of MSXOrg/docs failed (exit $LASTEXITCODE). Check network access and credentials."
28+
}
29+
}
30+
if ((git --git-dir=$docsBacking rev-parse --is-bare-repository) -ne 'true') {
31+
throw "$docsBacking exists but is not a bare repository."
32+
}
33+
if ((git --git-dir=$docsBacking remote get-url origin) -ne $docsUrl) {
34+
throw "$docsBacking origin does not match canonical $docsUrl."
35+
}
36+
$refspec = '+refs/heads/*:refs/remotes/origin/*'
37+
if ($refspec -notin @(git --git-dir=$docsBacking config --get-all remote.origin.fetch)) {
38+
git --git-dir=$docsBacking config --add remote.origin.fetch $refspec
39+
if ($LASTEXITCODE -ne 0) { throw "Could not configure $docsBacking." }
40+
}
41+
git --git-dir=$docsBacking fetch origin --prune --quiet
42+
if ($LASTEXITCODE -ne 0) { throw "Could not refresh $docsBacking. Do not use stale context." }
43+
git --git-dir=$docsBacking remote set-head origin --auto | Out-Null
44+
if ($LASTEXITCODE -ne 0) { throw "Could not detect the MSXOrg/docs default branch." }
45+
$defaultRef = (git --git-dir=$docsBacking symbolic-ref --short refs/remotes/origin/HEAD | Out-String).Trim()
46+
if ($LASTEXITCODE -ne 0) { throw "Could not resolve origin/HEAD in $docsBacking." }
47+
$defaultBranch = $defaultRef -replace '^origin/', ''
48+
$remoteHead = (git --git-dir=$docsBacking rev-parse $defaultRef | Out-String).Trim()
49+
if ($LASTEXITCODE -ne 0) { throw "Could not resolve $defaultRef in $docsBacking." }
50+
$localRef = "refs/heads/$defaultBranch"
51+
$localHead = (git --git-dir=$docsBacking rev-parse --verify $localRef 2>$null | Out-String).Trim()
52+
if ($LASTEXITCODE -eq 128) {
53+
git --git-dir=$docsBacking update-ref $localRef $remoteHead
54+
} elseif ($LASTEXITCODE -ne 0) {
55+
throw "Could not inspect $localRef in $docsBacking."
56+
} elseif ($localHead -ne $remoteHead) {
57+
git --git-dir=$docsBacking merge-base --is-ancestor $localHead $remoteHead
58+
if ($LASTEXITCODE -ne 0) { throw "$localRef is ahead or diverged in $docsBacking." }
59+
if ("branch $localRef" -in @(git --git-dir=$docsBacking worktree list --porcelain)) {
60+
throw "$localRef is checked out elsewhere. Update that worktree first."
61+
}
62+
git --git-dir=$docsBacking update-ref $localRef $remoteHead $localHead
63+
}
64+
if ($LASTEXITCODE -ne 0 -or (git --git-dir=$docsBacking rev-parse $localRef) -ne $remoteHead) {
65+
throw "$localRef is not exactly synchronized with $defaultRef."
66+
}
67+
git --git-dir=$docsBacking worktree add $docs $defaultBranch
68+
if ($LASTEXITCODE -ne 0) {
69+
throw "Could not create the canonical MSXOrg/docs worktree at $docs."
70+
}
71+
} else {
72+
if ((git -C $docs remote get-url origin) -ne $docsUrl) {
73+
throw "$docs origin does not match canonical $docsUrl."
74+
}
75+
$refspec = '+refs/heads/*:refs/remotes/origin/*'
76+
if ($refspec -notin @(git -C $docs config --get-all remote.origin.fetch)) {
77+
git -C $docs config --add remote.origin.fetch $refspec
78+
if ($LASTEXITCODE -ne 0) {
79+
throw "Could not configure remote tracking branches for MSXOrg/docs (exit $LASTEXITCODE)."
80+
}
81+
}
82+
git -C $docs fetch origin --prune --quiet
1783
if ($LASTEXITCODE -ne 0) {
18-
throw "git clone of MSXOrg/docs failed (exit $LASTEXITCODE). Check network access and github.com credentials, then re-run."
84+
throw "git fetch of MSXOrg/docs failed (exit $LASTEXITCODE). Do not use stale context."
85+
}
86+
git -C $docs remote set-head origin --auto | Out-Null
87+
if ($LASTEXITCODE -ne 0) { throw "Could not detect the MSXOrg/docs default branch." }
88+
$defaultRef = (git -C $docs symbolic-ref --short refs/remotes/origin/HEAD | Out-String).Trim()
89+
if ($LASTEXITCODE -ne 0) { throw "Could not resolve origin/HEAD in $docs." }
90+
$defaultBranch = $defaultRef -replace '^origin/', ''
91+
$branch = (git -C $docs branch --show-current | Out-String).Trim()
92+
if ($branch -ne $defaultBranch) {
93+
throw "$docs is on '$branch', not '$defaultBranch'. Switch branches before using this context."
94+
}
95+
if (@(git -C $docs status --porcelain).Count -gt 0) {
96+
throw "$docs has uncommitted changes. Resolve them before using this context."
97+
}
98+
git -C $docs merge --ff-only --quiet $defaultRef
99+
if ($LASTEXITCODE -ne 0) {
100+
throw "MSXOrg/docs cannot fast-forward to $defaultRef. Do not use stale context."
101+
}
102+
if ((git -C $docs rev-parse HEAD) -ne (git -C $docs rev-parse $defaultRef)) {
103+
throw "$docs is not exactly synchronized with $defaultRef. Reconcile local commits before using this context."
19104
}
20105
}
21-
pwsh (Join-Path $docs 'bootstrap/Initialize-MsxWorkspace.ps1')
106+
$projects = @(
107+
@{
108+
Name = 'MSXOrg'
109+
Path = ''
110+
DocsUrl = $docsUrl
111+
MemoryUrl = $memoryUrl
112+
}
113+
# Add project-specific entries when this template is adopted there:
114+
# @{
115+
# Name = 'PSModule'
116+
# Path = 'projects/PSModule'
117+
# DocsUrl = 'https://github.com/PSModule/docs.git'
118+
# MemoryUrl = 'https://github.com/PSModule/memory.git'
119+
# }
120+
)
121+
& (Join-Path $docs 'bootstrap/Initialize-MsxWorkspace.ps1') -Root $workspaceRoot -Project $projects
122+
if ($LASTEXITCODE -ne 0) {
123+
throw "Context synchronization failed. Do not read context until every project is current."
124+
}
22125
```
23126

127+
Keep the MSXOrg entry and add only the additional project coordinates required by repositories that inherit this template. Every project reuses the same synchronization and validation implementation.
128+
24129
This produces:
25130

26-
- `~/.msx/docs` β€” how work is done: ways of working, coding standards, and agent roles. The same content published at <https://msxorg.github.io/docs/>.
131+
- `~/.msx/docs.git` β€” bare backing repository for central docs.
132+
- `~/.msx/docs` β€” clean, readable main worktree containing ways of working, standards, and workflow guidance.
27133
- `~/.msx/memory` β€” what has been learned before: durable notes and prior session context.
28134

29135
Each clone has repository-local git config only; it never modifies the global git config or the repository being worked in (git still reads them, but only repository-local config is written).
@@ -32,10 +138,22 @@ Each clone has repository-local git config only; it never modifies the global gi
32138
33139
## Then β€” read before acting
34140

35-
1. Read the relevant pages under `~/.msx/docs` for the task at hand.
36-
2. Read `~/.msx/memory` for prior decisions, pitfalls, and context.
141+
1. Start at `~/.msx/docs/src/docs/index.md`.
142+
2. Follow the Ways of Working index to `Workflow.md`.
143+
3. Infer the current stage from the task and its artifacts, then read the linked stage procedure.
144+
4. Read the relevant standards, repository context, and `~/.msx/memory`.
145+
146+
Clear task language may shortcut the index trail: `Review this PR <link>` enters Review, `Make this issue <description>` enters Define, and `Implement <issue>` enters Implement. The linked documentation owns each procedure; this file does not define a separate agent or skill.
147+
148+
## Work in the selected repository
149+
150+
1. Read its `README.md` to understand the repository and its build.
151+
2. Read its `CONTRIBUTING.md` for the contribution and review contract.
152+
3. Use a dedicated worktree and the branch naming defined by the canonical Ways of Working.
153+
4. Make small, descriptive micro-commits and push every commit so remote state, CI, and the draft pull request stay current.
154+
5. Capture verified reusable lessons in organization memory, following that repository's own instructions.
37155

38156
## Two write rules
39157

40-
- **Docs change through pull requests.** Branch inside `~/.msx/docs` and open a pull request; never push its `main`.
41-
- **Memory pushes to main.** Commit and push notes directly inside `~/.msx/memory`; no pull request.
158+
- **Docs change through topic worktrees and pull requests.** Create a topic worktree from `~/.msx/docs.git`; never branch or work inside the canonical `~/.msx/docs` main worktree.
159+
- **Memory follows repository policy.** Read the selected memory repository's `AGENTS.md` and `CONTRIBUTING.md` before writing.

0 commit comments

Comments
Β (0)