@softure-ai/skills 0.24.0 → 0.25.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/README.md CHANGED
@@ -49,7 +49,8 @@ reader gets the codes through the forge API without a checkout.
49
49
  It fails on drift in `context/` (a roadmap left after its archive, archived changes not stamped,
50
50
  `## Summary` placeholders, a stale `context/state.json`, …; WORKFLOW §12). The installer prints the
51
51
  job until a workflow runs the doctor, and asks to rename a job that runs it under another name. `npx softure-skills state` regenerates `context/state.json`, which the
52
- scripts otherwise write themselves.
52
+ scripts otherwise write themselves. When nothing names the project, its first run (and the installer) writes the
53
+ repository name into `context/workflow.json` → `project`, so the name no longer depends on how the repository was cloned.
53
54
 
54
55
  **Rolling out to an existing project** (WORKFLOW §12.4). A project that adopted the package earlier
55
56
  usually fails on history. Put it right, in this order, one pass per repository:
package/WORKFLOW.md CHANGED
@@ -760,6 +760,13 @@ The skills run `python3 .claude/skills/softure-doctor/scripts/context_state.py w
760
760
  staged (so nobody's uncommitted edits leak in) and stages the result. By hand: `npx softure-skills state`.
761
761
  A project without the file gets it from the first of these runs; nothing has to be migrated.
762
762
 
763
+ `project` falls back to the repository name, and that name's letter case is the clone's (`owner/REPO` and
764
+ `owner/repo` are one repository on GitHub). So the first `write` that falls back to it, and the installer, write it
765
+ into `context/workflow.json` → `project` (in the spelling `state.json` already holds, else the forge's
766
+ `GITHUB_REPOSITORY` in CI, else `origin`'s URL); from then on the value is fixed in the repository. Until it is, the
767
+ doctor compares a repository-derived `project` without regard to letter case, and a rewrite keeps the committed
768
+ spelling.
769
+
763
770
  ```jsonc
764
771
  {
765
772
  "schema_version": 2, // 2 adds owner_queue[].id; read a version 1 file as one without ids
@@ -934,6 +941,10 @@ A project that adopted the package before the doctor existed usually fails on hi
934
941
  status values, archive indexes that link moved files, unticked Progress items and owner checks in roadmaps closed
935
942
  long ago. The history is put right, not hidden. One pass per repository, in this order:
936
943
 
944
+ 0. **Name the project once.** Set `project` in `context/workflow.json` (the name the project calls itself), or let
945
+ `npx softure-skills state` pin the repository name there, and commit it. Without it `state.json` → `project`
946
+ depends on how each checkout was cloned (§12.1).
947
+
937
948
  1. **Mechanical fixes.** Update the package, then `npx softure-skills doctor --fix` (review the printed edits) and
938
949
  `npx softure-skills doctor --fix --write`. Commit: `docs(context): mechanical history fixes (doctor --fix)`.
939
950
  2. **The sweep, worked by an agent.** `npx softure-skills doctor --sweep --json`, settled entry by entry as the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softure-ai/skills",
3
- "version": "0.24.0",
3
+ "version": "0.25.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": {
@@ -92,6 +92,19 @@ function runSubcommand(name, args) {
92
92
  return result.status ?? 1;
93
93
  }
94
94
 
95
+ // Fixes the repository-derived `project` in context/workflow.json the first time it is derived, so
96
+ // context/state.json no longer depends on how the checkout was cloned (`owner/REPO` vs `owner/repo`).
97
+ // Returns the action line, or null when there is nothing to do (no context/, a named project, no python3).
98
+ function pinProject(projectRoot, workflowConfig, options) {
99
+ if (workflowConfig.project || !fs.existsSync(path.join(projectRoot, "context"))) return null;
100
+ if (options.isDryRun) return null;
101
+ const result = spawnSync("python3", [path.join(DOCTOR_SCRIPTS, "context_state.py"), "pin-project", "--root", projectRoot],
102
+ { encoding: "utf8", timeout: 15000 });
103
+ if (result.error || result.status !== 0) return null;
104
+ const line = result.stdout.trim();
105
+ return line ? line : null;
106
+ }
107
+
95
108
  // How the project's GitHub workflows run the doctor: "named" (in a job whose id or name is CI_JOB),
96
109
  // "unnamed" (somewhere else), or "none".
97
110
  function doctorInCi(projectRoot) {
@@ -279,6 +292,9 @@ function install(options) {
279
292
  }
280
293
  }
281
294
 
295
+ const pinAction = pinProject(projectRoot, workflowConfig, options);
296
+ if (pinAction) actions.push(pinAction);
297
+
282
298
  const [labelAction, hasLabel] = ensureOwnerWordLabel(projectRoot, previous, options);
283
299
  if (labelAction) actions.push(labelAction);
284
300
 
@@ -306,8 +322,8 @@ function install(options) {
306
322
  const prefix = options.isDryRun ? "[softure-skills] (dry run)" : "[softure-skills]";
307
323
  for (const action of actions) console.log(`${prefix} ${action}`);
308
324
  console.log(`${prefix} ${PACKAGE.name}@${PACKAGE.version} -> ${projectRoot}`);
309
- if (fs.existsSync(path.join(projectRoot, WORKFLOW_CONFIG_PATH)) && !workflowConfig.project) {
310
- console.log(`${prefix} ${WORKFLOW_CONFIG_PATH}: add "project": "<the name the project calls itself>" (context/state.json falls back to the repository name; softure-init asks for it)`);
325
+ if (fs.existsSync(path.join(projectRoot, WORKFLOW_CONFIG_PATH)) && !readWorkflowConfig(projectRoot).project) {
326
+ console.log(`${prefix} ${WORKFLOW_CONFIG_PATH}: add "project": "<the name the project calls itself>" (context/state.json takes it from the active roadmap until then; softure-init asks for it)`);
311
327
  }
312
328
  const ci = doctorInCi(projectRoot);
313
329
  if (ci === "none") {
@@ -9,7 +9,7 @@
9
9
  "additionalProperties": false,
10
10
  "properties": {
11
11
  "schema_version": { "type": "integer", "enum": [1, 2], "description": "2 adds owner_queue[].id; a reader of version 1 files treats id as absent" },
12
- "project": { "type": "string", "description": "workflow.json `project`, else the active roadmap's `project`, else the repository name (origin's URL, else the folder); never null" },
12
+ "project": { "type": "string", "description": "workflow.json `project`, else the active roadmap's `project`, else the repository name (origin's URL, else the folder; GITHUB_REPOSITORY's spelling in CI; pinned in workflow.json by the first write that derives it; compared without letter case); never null" },
13
13
  "mode": { "type": "string", "enum": ["manual", "autonomous"] },
14
14
  "main_branch": { "type": ["string", "null"] },
15
15
  "updated_at": { "type": "string", "description": "UTC ISO 8601; changes only when the content does" },
@@ -4,6 +4,7 @@
4
4
  context_state.py write [--root <dir>] [--staged] regenerate context/state.json
5
5
  context_state.py print [--root <dir>] [--staged] print what `write` would write
6
6
  context_state.py check [--root <dir>] exit 1 when the file is missing or stale
7
+ context_state.py pin-project [--root <dir>] write the derived `project` into context/workflow.json
7
8
 
8
9
  The file is written only by scripts, never by hand: `wt-roadmap.py` (every mode) commits it together
9
10
  with `roadmap.md`, and `softure-archive` and `softure-roadmap` (record, promote, close) run
@@ -25,6 +26,11 @@ wording changed or its heading moved within the same file (the same item, or tex
25
26
  so a reader can follow one entry across rewrites and "oldest first" stays true. `updated_at` changes only when the
26
27
  content does.
27
28
 
29
+ `project` is workflow.json's `project`, else the active roadmap's, else the repository name. The repository name
30
+ depends on how the checkout was cloned (`owner/REPO` or `owner/repo`), so the first `write` that falls back to it
31
+ pins it in `context/workflow.json` (`project`), and `check` compares a name that came from the repository without
32
+ regard to letter case. `pin-project` does only the pinning (the installer runs it).
33
+
28
34
  Importable: `from context_state import build_state, render_state, FsReader, GitReader, IndexReader`.
29
35
  """
30
36
  from __future__ import annotations
@@ -406,17 +412,43 @@ def _last_release(reader) -> dict | None:
406
412
  return None
407
413
 
408
414
 
415
+ def read_workflow(reader) -> dict:
416
+ """`context/workflow.json` as a dict; {} when it is absent or not a JSON object."""
417
+ raw = reader.read(WORKFLOW_PATH)
418
+ if not raw:
419
+ return {}
420
+ try:
421
+ loaded = json.loads(raw)
422
+ except json.JSONDecodeError:
423
+ return {}
424
+ return loaded if isinstance(loaded, dict) else {}
425
+
426
+
427
+ def resolve_project(reader, workflow: dict | None = None, roadmap_text: str | None = None,
428
+ prior: dict | None = None) -> tuple[str, bool]:
429
+ """`(project, from_repository)`: workflow.json `project`, else the active roadmap's, else the repository name.
430
+
431
+ `from_repository` is True for the last fallback. Its letter case depends on the clone, so when `prior` (the
432
+ state.json already written) holds the same name in another case, that spelling is kept.
433
+ """
434
+ workflow = read_workflow(reader) if workflow is None else workflow
435
+ if workflow.get("project"):
436
+ return workflow["project"], False
437
+ if roadmap_text is None:
438
+ roadmap_text = reader.read(ROADMAP_PATH)
439
+ if roadmap_text and frontmatter(roadmap_text).get("project"):
440
+ return frontmatter(roadmap_text)["project"], False
441
+ name = repository_name(reader)
442
+ previous = (prior or {}).get("project")
443
+ if isinstance(previous, str) and previous.casefold() == name.casefold():
444
+ name = previous
445
+ return name, True
446
+
447
+
409
448
  def build_state(reader, prior: dict | None = None, now: str | None = None) -> dict:
410
449
  """The state of the project that `reader` sees. `prior` keeps the `since` of entries still present."""
411
450
  today = _today()
412
- workflow: dict = {}
413
- raw = reader.read(WORKFLOW_PATH)
414
- if raw:
415
- try:
416
- loaded = json.loads(raw)
417
- workflow = loaded if isinstance(loaded, dict) else {}
418
- except json.JSONDecodeError:
419
- workflow = {}
451
+ workflow = read_workflow(reader)
420
452
 
421
453
  owner_queue: list[dict] = []
422
454
  active = None
@@ -497,8 +529,7 @@ def build_state(reader, prior: dict | None = None, now: str | None = None) -> di
497
529
 
498
530
  state = {
499
531
  "schema_version": SCHEMA_VERSION,
500
- "project": (workflow.get("project") or (frontmatter(roadmap_text).get("project") if roadmap_text else None)
501
- or repository_name(reader)),
532
+ "project": resolve_project(reader, workflow, roadmap_text, prior)[0],
502
533
  "mode": workflow.get("mode") or "manual",
503
534
  "main_branch": workflow.get("mainBranch"),
504
535
  "updated_at": now or dt.datetime.now(dt.timezone.utc).replace(microsecond=0).isoformat().replace("+00:00", "Z"),
@@ -522,13 +553,54 @@ def repository_name(reader) -> str:
522
553
 
523
554
  The last fallback for `project`, so a project between roadmaps without `project` in workflow.json still
524
555
  has a name. The URL comes first because a checkout's folder can be named anything (a worktree, a clone
525
- into a temporary folder).
556
+ into a temporary folder). The URL's letter case is the clone's, not the forge's: in GitHub Actions the
557
+ forge's spelling (`GITHUB_REPOSITORY`) wins when it names the same repository.
526
558
  """
527
559
  folder = getattr(reader, "root", None) or getattr(reader, "repo", None) or os.getcwd()
528
560
  url = subprocess.run(["git", "-C", folder, "remote", "get-url", "origin"], capture_output=True,
529
561
  text=True).stdout.strip()
530
562
  name = re.split(r"[/:]", url.rstrip("/"))[-1] if url else os.path.basename(os.path.abspath(folder))
531
- return re.sub(r"\.git$", "", name) or "unnamed"
563
+ name = re.sub(r"\.git$", "", name) or "unnamed"
564
+ canonical = os.environ.get("GITHUB_REPOSITORY", "").rsplit("/", 1)[-1]
565
+ return canonical if canonical and canonical.casefold() == name.casefold() else name
566
+
567
+
568
+ def pin_project(root: str, staged: bool = False) -> str | None:
569
+ """Write the repository-derived `project` into `context/workflow.json`; the name written, else None.
570
+
571
+ Nothing is written when `project` does not come from the repository name (workflow.json or the active
572
+ roadmap names it). The spelling is the one `context/state.json` already holds when it matches, so the
573
+ pin never flips a committed name. With `staged` the file is read from and added to the index; a
574
+ workflow.json with unstaged edits is left alone, so nobody's uncommitted work is committed.
575
+ """
576
+ reader = IndexReader(root) if staged else FsReader(root)
577
+ project, from_repository = resolve_project(reader, prior=load_prior(reader))
578
+ if not from_repository:
579
+ return None
580
+ target = os.path.join(root, WORKFLOW_PATH)
581
+ raw = reader.read(WORKFLOW_PATH)
582
+ if staged:
583
+ on_disk = None
584
+ if os.path.exists(target):
585
+ with open(target, encoding="utf-8") as fh:
586
+ on_disk = fh.read()
587
+ if on_disk != raw:
588
+ return None
589
+ workflow: dict = {}
590
+ if raw:
591
+ try:
592
+ loaded = json.loads(raw)
593
+ except json.JSONDecodeError:
594
+ return None # a broken file is the doctor's to report, not ours to overwrite
595
+ if not isinstance(loaded, dict):
596
+ return None
597
+ workflow = loaded
598
+ workflow = {**workflow, "project": project} if "project" in workflow else {"project": project, **workflow}
599
+ with open(target, "w", encoding="utf-8") as fh:
600
+ fh.write(json.dumps(workflow, indent=2, ensure_ascii=False) + "\n")
601
+ if staged:
602
+ subprocess.run(["git", "-C", root, "add", "--", WORKFLOW_PATH], check=True)
603
+ return project
532
604
 
533
605
 
534
606
  def _start_order(text: str) -> str | None:
@@ -716,13 +788,24 @@ def main(argv: list[str] | None = None) -> int:
716
788
  del args[k:k + 2]
717
789
  staged = "--staged" in args
718
790
  args = [arg for arg in args if arg != "--staged"]
719
- if len(args) != 1 or args[0] not in ("write", "print", "check"):
791
+ if len(args) != 1 or args[0] not in ("write", "print", "check", "pin-project"):
720
792
  print(__doc__, file=sys.stderr)
721
793
  return 2
722
794
  root = os.path.abspath(root) if root else repo_root(os.getcwd())
723
795
  if not os.path.isdir(os.path.join(root, "context")):
724
796
  print(f"no context/ directory in {root}: nothing to do", file=sys.stderr)
725
797
  return 0 if args[0] != "check" else 1
798
+ if args[0] == "pin-project":
799
+ pinned = pin_project(root, staged)
800
+ if pinned:
801
+ print(f"wrote {WORKFLOW_PATH}: \"project\": {json.dumps(pinned, ensure_ascii=False)}"
802
+ + " (staged)" * staged)
803
+ return 0
804
+ if args[0] == "write":
805
+ pinned = pin_project(root, staged)
806
+ if pinned:
807
+ print(f"wrote {WORKFLOW_PATH}: \"project\": {json.dumps(pinned, ensure_ascii=False)} "
808
+ "(the repository name, fixed so it no longer depends on the clone)" + " (staged)" * staged)
726
809
  reader = IndexReader(root) if staged else FsReader(root)
727
810
  if args[0] == "check":
728
811
  problem = staleness(FsReader(root))