@softure-ai/skills 0.15.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/WORKFLOW.md CHANGED
@@ -86,7 +86,10 @@ or languages.
86
86
  // "push": local --no-ff merge, then push <main> through the pre-push hook
87
87
  "remergeMain": "when-needed", // "when-needed" (default): merge <main> into the branch before the merge only when
88
88
  // wt-merge-check.py finds an overlapping file, a migration or a dependency change;
89
- // "always": before every merge
89
+ // "on-conflict": only when the merge would conflict (the forge reports the PR not
90
+ // mergeable, or a local trial merge conflicts); the merged result is then not tested
91
+ // before the merge, so an incompatible but non-conflicting change surfaces on <main>
92
+ // or in the release gate; "always": before every merge
90
93
  "relatedTests": null, // e.g. "npx vitest related --run {files}": the test gate after a merge of <main>, for the
91
94
  // files the branch changes; null = the full test gate
92
95
  "fullGatePaths": [], // extra globs that force the full gates after a merge of <main> (built in: lockfiles,
@@ -128,6 +131,10 @@ Parallel sessions push often, and every push can start the project's CI. The ski
128
131
  - a "finish" item does not start a run of its own under `cadence: "roadmap"`;
129
132
  - before a merge, `<main>` is merged into the branch only when needed (`autonomy.remergeMain`), and such a merge
130
133
  re-runs only what it can break (`autonomy.relatedTests`), so a merge without overlap costs no push and no hook.
134
+ In a busy repository nearly every merge sees a migration or a dependency change from the one before it, and
135
+ `"when-needed"` then re-merges almost every time; `"on-conflict"` merges a pull request on its green-at-READY
136
+ checks unless the merge would conflict. It trades a CI run per merge for testing the merged result only on
137
+ `<main>` and in the release gate.
131
138
 
132
139
  The project's side: when the git hooks already run the gates (`pre-commit`, `pre-push`), CI does not need to
133
140
  repeat them on every pushed branch. A pre-push hook needs a cheap path for a push whose changed files are all
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softure-ai/skills",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
4
4
  "description": "SOFTURE agent skills: a spec-driven delivery workflow (shape → prd → roadmap → plan → implement → review) plus parallel worktree orchestration",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -22,7 +22,8 @@
22
22
  },
23
23
  "scripts": {
24
24
  "postinstall": "node scripts/install.mjs --postinstall",
25
- "validate": "node scripts/validate.mjs"
25
+ "validate": "node scripts/validate.mjs",
26
+ "test": "python3 -m unittest discover -s tests"
26
27
  },
27
28
  "engines": {
28
29
  "node": ">=20"
package/rules/AGENTS.md CHANGED
@@ -206,7 +206,11 @@ Only a "stop" or "pause" from the owner, recorded in memory, holds it back.
206
206
  dependency change and no file the branch also changes): merge the pull request as it is; its checks
207
207
  were green at READY. `remerge`: merge the fresh main branch in, resolve conflicts yourself, run the
208
208
  `RUN` lines it prints, push. The main branch is the source of truth: what it has and the branch lacks
209
- is pulled in and wired. `"always"`: merge the main branch in before every merge.
209
+ is pulled in and wired. `"on-conflict"`: `merge-as-is` unless the merge would conflict (the forge
210
+ reports the pull request not mergeable: pass `--not-mergeable`; or the script's trial merge
211
+ conflicts); overlap, migrations and dependency changes alone do not force a merge of the main
212
+ branch, so the merged result is first tested on the main branch and in the release gate.
213
+ `"always"`: merge the main branch in before every merge.
210
214
  - **A merge of the main branch re-runs only what it can break:** every gate except the test gate, plus
211
215
  `autonomy.relatedTests` for the files the branch changes. The full suite runs again only when the
212
216
  incoming changes add a migration or touch dependencies, test setup or config (`wt-merge-check.py`
@@ -217,7 +221,8 @@ Only a "stop" or "pause" from the owner, recorded in memory, holds it back.
217
221
  green checks, merge it on the forge; the forge deletes the head branch. `"push"`: `git merge --no-ff`
218
222
  locally, then push the main branch through the pre-push hook.
219
223
  - When one thread has had to chase the main branch several times, the coordinator tells the others
220
- to hold their merges until it lands.
224
+ to hold their merges until it lands. Under `remergeMain: "on-conflict"` the go never asks for
225
+ "Update branch" or a merge of the main branch: the thread merges on `wt-merge-check.py`'s verdict.
221
226
  - Hooks stay on: never `--no-verify`, never force-push, never disable or loosen a test to get green.
222
227
  Long hooks run in the background with the longest timeout; a hung one is killed by its PID and
223
228
  re-run.
@@ -138,7 +138,7 @@ only when it was detected or the user asked for it:
138
138
  | `worktree.cloudState` | `"main"` (roadmap state on the main branch, branches never edit `roadmap.md`) | the user runs cloud sessions whose pre-push hook has no cheap path for `context/`-only pushes and wants the state on the branch (`"branch"`) |
139
139
  | `research.sources` | none | step 2 found docs, ADRs or a PRD (interactive: listed in the plan; `--auto`: only paths that exist) |
140
140
  | `install` | gitignore the skills, inject all rule sections | the user wants committed skills or fewer rule sections (the language section always ships; `allowNonEnglishCode: true` only on the owner's explicit word) |
141
- | `autonomy` | roadmap as the work source, merge via pull request, `<main>` merged into a branch only when needed (`remergeMain: "when-needed"`; add `relatedTests`, e.g. `npx vitest related --run {files}`, when the test runner has one), reports every 60 min around the clock (`reports.every`, `reports.hours: null`; routines fire at most hourly; the routine is also the run's heartbeat, so keep it 24/7) | `mode` is `autonomous` and the user names issues as the queue, merges by push, or another report cadence |
141
+ | `autonomy` | roadmap as the work source, merge via pull request, `<main>` merged into a branch only when needed (`remergeMain: "when-needed"`; `"on-conflict"` when the main branch takes a migration or a dependency change on nearly every merge and the owner accepts testing the merged result on main and in the release gate; add `relatedTests`, e.g. `npx vitest related --run {files}`, when the test runner has one), reports every 60 min around the clock (`reports.every`, `reports.hours: null`; routines fire at most hourly; the routine is also the run's heartbeat, so keep it 24/7) | `mode` is `autonomous` and the user names issues as the queue, merges by push, or another report cadence |
142
142
 
143
143
  Content of the README files, and a complete worked example (detection, plan, report) for a
144
144
  fictional repo: read `references/templates.md` **when writing the READMEs** and
@@ -125,9 +125,10 @@ Read `mode` at A0 (`python3 <S>/wt_config.py mode`; WORKFLOW §8, the project's
125
125
  3. then Phase B by `autonomy.merge`:
126
126
  - `"pr"` (default): the pull request was opened at READY (`Closes #N` when
127
127
  the change solves an issue). After the go, run
128
- `python3 <S>/wt-merge-check.py`. `VERDICT merge-as-is` and the forge
129
- reports the pull request mergeable → merge it as it is (its checks were
130
- green at READY). `VERDICT remerge` (or `autonomy.remergeMain: "always"`)
128
+ `python3 <S>/wt-merge-check.py` (add `--not-mergeable` when the forge
129
+ reports the pull request not mergeable). `VERDICT merge-as-is` and the
130
+ forge reports the pull request mergeable → merge it as it is (its checks
131
+ were green at READY). `VERDICT remerge` (or `autonomy.remergeMain: "always"`)
131
132
  → merge `origin/<main>` into the branch (A5), run the `RUN` lines it
132
133
  printed, push, and enable the forge's auto-merge for the pull request
133
134
  (`gh pr merge <N> --auto --merge` or the forge tool) so it merges on
@@ -847,6 +848,10 @@ merge-as-is` → skip the merge; READY says `<main> not merged in
847
848
  (wt-merge-check: merge-as-is)` and the pull request is merged as it is after
848
849
  the go. `VERDICT remerge` → merge as below, then run the `RUN` lines it printed
849
850
  (the gates the merge can break: `GATES related` or `full`) before pushing.
851
+ `autonomy.remergeMain: "on-conflict"` → `remerge` only when the merge would
852
+ conflict (its trial merge, or `--not-mergeable` when the forge says so);
853
+ overlap, migrations and dependency changes are printed but do not force it, and
854
+ a go under this policy never asks for "Update branch".
850
855
  `autonomy.remergeMain: "always"` → always merge. The same check runs again
851
856
  after the go (*Operating mode*), because `<main>` keeps moving. Otherwise
852
857
  (manual mode, or `autonomy.merge: "push"`) the branch is always made current:
@@ -2,7 +2,7 @@
2
2
  """Decide whether a change branch must merge the main branch in again before its merge, and which gates
3
3
  that merge has to re-run.
4
4
 
5
- wt-merge-check.py [--base <ref>] [--no-fetch]
5
+ wt-merge-check.py [--base <ref>] [--no-fetch] [--not-mergeable]
6
6
 
7
7
  Run in the change branch's checkout (worktree or cloud session), after the go and before merging the
8
8
  pull request. Compares what `<main>` brought since the branch last merged it (merge-base..origin/<main>)
@@ -10,12 +10,23 @@ with what the branch changes (merge-base..HEAD) and prints:
10
10
 
11
11
  VERDICT merge-as-is | remerge
12
12
  GATES none | related | full
13
- <one line per finding: incoming, overlap, migrations, dependencies, test setup/config>
13
+ <one line per finding: incoming, conflict, overlap, migrations, dependencies, test setup/config>
14
14
  RUN <command> (only with `remerge`: the gates to run on the merged tree, in order)
15
15
 
16
- `merge-as-is` — `<main>` has not moved, or (with `autonomy.remergeMain: "when-needed"`, the default) it
17
- brought no migration, no dependency change and no file the branch also changes. Merge the pull request
18
- as it is, provided the forge reports it mergeable and its checks were green at READY. No push, no hook.
16
+ `conflict` is a local trial merge (`git merge-tree --write-tree`, nothing is written to the branch or the
17
+ working tree): `none`, `yes` with the conflicting files, or `unknown` when this git cannot run it (2.38+
18
+ needed). Pass `--not-mergeable` when the forge reports the pull request not mergeable; it counts as a
19
+ conflict under every policy.
20
+
21
+ `merge-as-is` — `<main>` has not moved, or `autonomy.remergeMain` finds no reason to merge it in:
22
+ - `"when-needed"` (the default): `<main>` brought no migration, no dependency change and no file the
23
+ branch also changes (a conflict always comes with such a file);
24
+ - `"on-conflict"`: the merge does not conflict. Overlap, migrations and dependency changes are still
25
+ printed (and still decide GATES when a remerge does happen), but they do not force a remerge. The
26
+ merged result is then not tested before the merge: a change that is incompatible without conflicting
27
+ surfaces on `<main>` or in the release gate instead of on the branch.
28
+ Merge the pull request as it is, provided the forge reports it mergeable and its checks were green at
29
+ READY. No push, no hook.
19
30
 
20
31
  `remerge` — merge `origin/<main>` into the branch, resolve, run the RUN lines, push. GATES says what the
21
32
  merge can break:
@@ -40,6 +51,7 @@ sys.dont_write_bytecode = True # no __pycache__ inside the consumer's .claude/s
40
51
  sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
41
52
  from wt_config import load_config # noqa: E402
42
53
 
54
+ POLICIES = ("when-needed", "on-conflict", "always")
43
55
  DEPENDENCY_FILES = {
44
56
  "package.json", "package-lock.json", "npm-shrinkwrap.json", "pnpm-lock.yaml", "pnpm-workspace.yaml",
45
57
  "yarn.lock", "bun.lock", "bun.lockb", ".npmrc", ".nvmrc", ".node-version",
@@ -75,10 +87,27 @@ def listing(files: list[str], limit: int = 8) -> str:
75
87
  return ", ".join(files[:limit]) + more
76
88
 
77
89
 
90
+ def trial_merge(merge_base: str, head: str, base_sha: str) -> tuple[str, list[str]]:
91
+ """Merge `base_sha` into `head` in memory. Returns ("none" | "yes" | "unknown", conflicting files)."""
92
+ result = subprocess.run(
93
+ ["git", "merge-tree", "--write-tree", "--name-only", "--no-messages",
94
+ f"--merge-base={merge_base}", head, base_sha],
95
+ capture_output=True, text=True,
96
+ )
97
+ if result.returncode == 0:
98
+ return "none", []
99
+ if result.returncode == 1:
100
+ lines = [line for line in result.stdout.splitlines()[1:] if line]
101
+ return "yes", sorted(set(lines))
102
+ return "unknown", []
103
+
104
+
78
105
  def main() -> None:
79
106
  parser = argparse.ArgumentParser(add_help=True, description=__doc__.split("\n\n")[0])
80
107
  parser.add_argument("--base", help="ref of the main branch to compare with (default: origin/<main>)")
81
108
  parser.add_argument("--no-fetch", action="store_true")
109
+ parser.add_argument("--not-mergeable", action="store_true",
110
+ help="the forge reports the pull request not mergeable (a conflict with the main branch)")
82
111
  opts = parser.parse_args()
83
112
 
84
113
  config = load_config()
@@ -101,8 +130,18 @@ def main() -> None:
101
130
  setup = [f for f in incoming if matches(f, FULL_GATE_PATTERNS + list(autonomy.get("fullGatePaths") or []))]
102
131
 
103
132
  policy = autonomy.get("remergeMain") or "when-needed"
133
+ if policy not in POLICIES:
134
+ sys.exit(f"autonomy.remergeMain={policy!r} is not one of: {', '.join(POLICIES)}")
104
135
  moved = merge_base != base_sha
105
- needed = moved and (policy == "always" or bool(overlap or migrations or dependencies))
136
+ conflict, conflicting = trial_merge(merge_base, head, base_sha) if moved else ("none", [])
137
+ conflicts = opts.not_mergeable or conflict != "none" # unknown counts as a conflict: never guess clean
138
+ if policy == "always":
139
+ needed = moved or opts.not_mergeable
140
+ elif policy == "on-conflict":
141
+ needed = conflicts
142
+ else:
143
+ # a textual conflict always shows up as an overlapping file
144
+ needed = opts.not_mergeable or (moved and bool(overlap or migrations or dependencies))
106
145
  related_cmd = autonomy.get("relatedTests")
107
146
  full = bool(migrations or dependencies or setup) or not related_cmd
108
147
 
@@ -113,6 +152,14 @@ def main() -> None:
113
152
  else:
114
153
  count = int(git("rev-list", "--count", f"{merge_base}..{base_sha}").strip())
115
154
  print(f"incoming: {len(incoming)} files in {count} commits since {merge_base[:8]} ({base} {base_sha[:8]})")
155
+ if conflict == "yes":
156
+ print(f"conflict: yes — {listing(conflicting)}")
157
+ elif conflict == "unknown":
158
+ print("conflict: unknown — `git merge-tree --write-tree` failed (git 2.38+ needed); treated as a conflict")
159
+ else:
160
+ print("conflict: none")
161
+ if opts.not_mergeable:
162
+ print("forge: the pull request is not mergeable (--not-mergeable)")
116
163
  print(f"overlap: {listing(overlap)}")
117
164
  print(f"migrations: {listing(migrations)}")
118
165
  print(f"dependencies: {listing(dependencies)}")
@@ -9,7 +9,8 @@
9
9
  Always reads the config of the MAIN worktree (first entry of `git worktree list`), so every
10
10
  worktree and every script sees the same values. `mainBranch` falls back to origin's HEAD, then
11
11
  "main"; `worktree.maxParallel` to 4; `language` to "en"; `mode` to "manual";
12
- `autonomy.reports.every` to 60; `autonomy.remergeMain` to "when-needed".
12
+ `autonomy.reports.every` to 60; `autonomy.remergeMain` to "when-needed" ("on-conflict" and "always"
13
+ are the other values).
13
14
 
14
15
  Importable: `from wt_config import load_config, main_root, main_branch`.
15
16
  """