@softure-ai/skills 0.0.0-stage → 0.1.1

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.
Files changed (34) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +71 -2
  3. package/WORKFLOW.md +308 -0
  4. package/package.json +31 -4
  5. package/rules/AGENTS.md +78 -0
  6. package/scripts/install.mjs +151 -0
  7. package/scripts/uninstall.mjs +49 -0
  8. package/skills/softure-archive/SKILL.md +100 -0
  9. package/skills/softure-code-review/SKILL.md +124 -0
  10. package/skills/softure-frame/SKILL.md +113 -0
  11. package/skills/softure-impl-review/SKILL.md +150 -0
  12. package/skills/softure-implement/SKILL.md +141 -0
  13. package/skills/softure-init/SKILL.md +131 -0
  14. package/skills/softure-lesson/SKILL.md +99 -0
  15. package/skills/softure-new/SKILL.md +127 -0
  16. package/skills/softure-plan/SKILL.md +157 -0
  17. package/skills/softure-plan/references/progress-format.md +79 -0
  18. package/skills/softure-plan-review/SKILL.md +152 -0
  19. package/skills/softure-prd/SKILL.md +132 -0
  20. package/skills/softure-research/SKILL.md +165 -0
  21. package/skills/softure-roadmap/SKILL.md +128 -0
  22. package/skills/softure-rule-review/SKILL.md +121 -0
  23. package/skills/softure-shape/SKILL.md +128 -0
  24. package/skills/softure-worktree/SKILL.md +888 -0
  25. package/skills/softure-worktree/scripts/wt-integration.sh +59 -0
  26. package/skills/softure-worktree/scripts/wt-open.sh +57 -0
  27. package/skills/softure-worktree/scripts/wt-roadmap.py +301 -0
  28. package/skills/softure-worktree/scripts/wt-status.sh +70 -0
  29. package/skills/softure-worktree/scripts/wt_config.py +109 -0
  30. package/skills/softure-worktree-manager/SKILL.md +553 -0
  31. package/skills/softure-worktree-manager/scripts/wm-launch.sh +52 -0
  32. package/skills/softure-worktree-manager/scripts/wm-report.sh +45 -0
  33. package/skills/softure-worktree-manager/scripts/wm-resume.sh +132 -0
  34. package/skills/softure-worktree-manager/scripts/wm-watch.sh +49 -0
@@ -0,0 +1,132 @@
1
+ #!/usr/bin/env bash
2
+ # Read-only: what a freshly started coordinator must do with changes already in flight.
3
+ #
4
+ # wm-resume.sh
5
+ #
6
+ # For every roadmap row in flight (`in_progress` or `ready_to_merge`) prints one line:
7
+ #
8
+ # RESUME <ID> <change-id> action=<ACTION> stage="…" wt=yes|no branch=yes|no|merged
9
+ # session=<short-id>|none proc=<status/state/pid|nopid> coord=<name>|? coord_alive=yes|no|?
10
+ # last="<hint from the worker's last assistant message>"
11
+ #
12
+ # ACTION (the skill's M0.1 table says what to do with each):
13
+ # MERGE row says ready_to_merge → M5 now
14
+ # ADOPT worker process alive and working → take over its merge
15
+ # NUDGE worker process alive but blocked (usage limit, sleep, network) → SendMessage "continue"
16
+ # RELAUNCH no live worker process, worktree/branch still there → claude stop <id>; wm-launch.sh
17
+ # FIX-ROW the main branch already has the merge commit, row not updated → fix the row
18
+ # REPORT in flight on the roadmap but no branch and no worktree → tell the owner
19
+ #
20
+ # Why: the owner clears the coordinator session and runs the skill again; workers keep running
21
+ # as background processes, and a fresh coordinator must merge them and wake the stuck ones
22
+ # instead of treating them as someone else's.
23
+ #
24
+ # WM_AGENTS_JSON overrides the session list — only for testing the NUDGE/RELAUNCH paths
25
+ # without touching live workers.
26
+ set -uo pipefail
27
+ MAIN="$(git rev-parse --path-format=absolute --git-common-dir | sed 's#/\.git$##')"
28
+ cd "$MAIN"
29
+ WT_SCRIPTS="$(cd "$(dirname "$0")/../../softure-worktree/scripts" 2>/dev/null && pwd || echo "$MAIN/.claude/skills/softure-worktree/scripts")"
30
+ MAIN_BRANCH="$(python3 "$WT_SCRIPTS/wt_config.py" mainBranch)"
31
+ AGENTS_JSON="${WM_AGENTS_JSON:-$(claude agents --json 2>/dev/null || echo '[]')}"
32
+
33
+ python3 - "$MAIN" "$AGENTS_JSON" "$MAIN_BRANCH" <<'PY'
34
+ import json, os, re, subprocess, sys
35
+
36
+ main, agents_raw, main_branch = sys.argv[1], sys.argv[2], sys.argv[3]
37
+ try:
38
+ agents = json.loads(agents_raw)
39
+ agents = agents if isinstance(agents, list) else agents.get("agents", [])
40
+ except ValueError:
41
+ agents = []
42
+ slug = re.sub(r"[/_.]", "-", main)
43
+ proj = os.path.expanduser(f"~/.claude/projects/{slug}")
44
+
45
+ def git(*a):
46
+ return subprocess.run(["git", "-C", main, *a], capture_output=True, text=True)
47
+
48
+ rows = []
49
+ for line in open(os.path.join(main, "context/foundation/roadmap.md"), encoding="utf-8"):
50
+ m = re.match(r"\| \*\*([A-Z]+-\d+)\*\* \| `([^`]+)` \|", line)
51
+ if not m:
52
+ continue
53
+ status = [c.strip() for c in line.strip().strip("|").split("|")][-1]
54
+ if "ready_to_merge" in status:
55
+ rows.append((m.group(1), m.group(2), "ready_to_merge"))
56
+ elif "in_progress" in status:
57
+ stage = re.search(r"\(([^,;)]+)", status)
58
+ rows.append((m.group(1), m.group(2), stage.group(1).strip() if stage else status))
59
+
60
+ wts = git("worktree", "list", "--porcelain").stdout
61
+ live_names = {a.get("name") for a in agents if a.get("pid")}
62
+ # "Merged" = the main branch carries the merge commit ("Merge <change-id> (<ID>): …").
63
+ # Not "branch is an ancestor of main": a freshly opened branch with no commits is one too.
64
+ merge_subjects = git("log", "--first-parent", "--merges", "--format=%s", main_branch).stdout.splitlines()
65
+
66
+ def transcript_lines(sid):
67
+ f = os.path.join(proj, f"{sid}.jsonl")
68
+ if not os.path.exists(f):
69
+ return []
70
+ out = []
71
+ for l in open(f, encoding="utf-8"):
72
+ try:
73
+ out.append(json.loads(l))
74
+ except ValueError:
75
+ pass
76
+ return out
77
+
78
+ def texts(d):
79
+ c = d.get("message", {}).get("content")
80
+ if isinstance(c, str):
81
+ return c
82
+ if isinstance(c, list):
83
+ return "".join(x.get("text", "") for x in c if isinstance(x, dict) and x.get("type") == "text")
84
+ return ""
85
+
86
+ if not rows:
87
+ print("RESUME none — no roadmap row in flight")
88
+
89
+ for rid, cid, stage in rows:
90
+ wt = "yes" if f"branch refs/heads/{cid}\n" in wts else "no"
91
+ has_branch = git("rev-parse", "--verify", "-q", f"refs/heads/{cid}").returncode == 0
92
+ merged = any(s.startswith((f"Merge {cid} ", f"Merge {cid}:", f"Merge branch '{cid}' into {main_branch}"))
93
+ for s in merge_subjects)
94
+ branch = "merged" if merged else ("yes" if has_branch else "no")
95
+
96
+ mine = sorted((a for a in agents if a.get("name") == cid), key=lambda a: a.get("startedAt", 0))
97
+ a = mine[-1] if mine else None
98
+ session = a.get("id", "?") if a else "none"
99
+ proc = (f"{a.get('status')}/{a.get('state')}/" + ("pid" if a.get("pid") else "nopid")) if a else "-"
100
+
101
+ coord, last = "?", ""
102
+ if a and a.get("sessionId"):
103
+ tl = transcript_lines(a["sessionId"])
104
+ for d in tl:
105
+ if d.get("type") == "user":
106
+ m = re.search(r"coordinator-session (\S+)", texts(d))
107
+ if m:
108
+ coord = m.group(1)
109
+ break
110
+ for d in reversed(tl):
111
+ if d.get("type") == "assistant" and texts(d).strip():
112
+ last = texts(d).strip().replace("\n", " ")[:120]
113
+ break
114
+ coord_alive = "?" if coord == "?" else ("yes" if coord in live_names else "no")
115
+
116
+ stuck = re.search(r"session limit|went to sleep|API Error|Can't reach|rate limit", last, re.I)
117
+ if stage == "ready_to_merge":
118
+ action = "MERGE"
119
+ elif merged:
120
+ action = "FIX-ROW"
121
+ elif not has_branch and wt == "no":
122
+ action = "REPORT"
123
+ elif a and a.get("pid") and (a.get("state") in ("working",) or a.get("status") == "busy") and not stuck:
124
+ action = "ADOPT"
125
+ elif a and a.get("pid"):
126
+ action = "NUDGE"
127
+ else:
128
+ action = "RELAUNCH"
129
+
130
+ print(f'RESUME {rid} {cid} action={action} stage="{stage}" wt={wt} branch={branch} '
131
+ f'session={session} proc={proc} coord={coord} coord_alive={coord_alive} last="{last}"')
132
+ PY
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env bash
2
+ # Event stream for Monitor: one line per change of a watched item.
3
+ #
4
+ # wm-watch.sh <ID>:<change-id> [<ID>:<change-id> …]
5
+ #
6
+ # Emits, per item, whenever it changes:
7
+ # STAGE <ID> <status cell of the roadmap row on the main branch's working copy>
8
+ # READY <ID> (row says ready_to_merge)
9
+ # SESSION <change-id> <kind>/<status>/<state> (background or peer session)
10
+ # GONE <change-id> (session vanished before READY)
11
+ #
12
+ # Covers the failure paths too (silence is not success): a session that ends or disappears
13
+ # without READY shows up as SESSION …/done or GONE. Polls every 60 s.
14
+ set -uo pipefail
15
+ MAIN="$(git rev-parse --path-format=absolute --git-common-dir | sed 's#/\.git$##')"
16
+ ROADMAP="$MAIN/context/foundation/roadmap.md"
17
+ ST="$(mktemp -d)"; trap 'rm -rf "$ST"' EXIT # plain files instead of associative arrays: works on bash 3.2
18
+ get() { cat "$ST/$1" 2>/dev/null || true; }
19
+
20
+ while true; do
21
+ for pair in "$@"; do
22
+ ID="${pair%%:*}"; CID="${pair#*:}"
23
+ row=$(python3 - "$ROADMAP" "$ID" <<'PY'
24
+ import sys
25
+ for line in open(sys.argv[1], encoding="utf-8"):
26
+ if line.startswith(f"| **{sys.argv[2]}** |"):
27
+ cells = [c.strip() for c in line.strip().strip("|").split("|")]
28
+ print(cells[-1])
29
+ break
30
+ PY
31
+ )
32
+ if [ "$(get "s$ID")" != "$row" ]; then
33
+ printf %s "$row" > "$ST/s$ID"; echo "STAGE $ID $row"
34
+ case "$row" in *ready_to_merge*) echo "READY $ID";; esac
35
+ fi
36
+ sess=$(claude agents --json 2>/dev/null | python3 -c '
37
+ import json,sys
38
+ d=json.load(sys.stdin); d=d if isinstance(d,list) else d.get("agents",[])
39
+ m=[x for x in d if x.get("name")==sys.argv[1]]
40
+ m.sort(key=lambda x:x.get("startedAt",0))
41
+ print("%s/%s/%s" % (m[-1].get("kind"), m[-1].get("status"), m[-1].get("state","-")) if m else "none")' "$CID" 2>/dev/null || echo "none")
42
+ if [ "$(get "p$CID")" != "$sess" ]; then
43
+ # adopted sessions (opened by hand) are not named after the change → "none" from the start, stay quiet
44
+ if [ "$sess" = "none" ]; then [ -n "$(get "p$CID")" ] && echo "GONE $CID"; else echo "SESSION $CID $sess"; fi
45
+ printf %s "$sess" > "$ST/p$CID"
46
+ fi
47
+ done
48
+ sleep 60
49
+ done