jhste-skills 0.1.1 → 0.1.3

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.ja.md CHANGED
@@ -158,7 +158,6 @@ Normal install では、Matt Pocock の [`mattpocock/skills`](https://github.com
158
158
 
159
159
  | Skill | いつ使うか |
160
160
  |---|---|
161
- | [`diagnose`](skills/diagnose/SKILL.md)<br>reproduce、minimize、hypothesize、instrument、fix、regression-check を強制する診断ループ skill | hard bug や performance regression を体系的に診断するとき |
162
161
  | [`diagnosing-bugs`](skills/diagnosing-bugs/SKILL.md)<br>高速な pass/fail feedback loop を中心に root cause を絞り込む debugging skill | reproduce → minimise → hypothesise → instrument → fix ループが必要なとき |
163
162
  | [`grill-me`](skills/grill-me/SKILL.md)<br>計画や設計の穴がなくなるまで粘り強く質問する skill | agent に計画や設計を明確になるまで質問させたいとき |
164
163
  | [`grill-with-docs`](skills/grill-with-docs/SKILL.md)<br>質問しながら domain terms と decisions を文書化する design validation skill | 質問プロセスで project vocabulary や docs/ADR も更新したいとき |
package/README.ko.md CHANGED
@@ -158,7 +158,6 @@ Normal install은 Matt Pocock의 [`mattpocock/skills`](https://github.com/mattpo
158
158
 
159
159
  | Skill | 언제 쓰나 |
160
160
  |---|---|
161
- | [`diagnose`](skills/diagnose/SKILL.md)<br>재현, 축소, 가설, 계측, 수정, 회귀 확인을 강제하는 진단 루프 스킬 | hard bug 또는 performance regression을 체계적으로 진단할 때 |
162
161
  | [`diagnosing-bugs`](skills/diagnosing-bugs/SKILL.md)<br>빠른 pass/fail feedback loop를 중심으로 원인을 좁혀가는 debugging 스킬 | reproduce → minimise → hypothesise → instrument → fix 루프가 필요할 때 |
163
162
  | [`grill-me`](skills/grill-me/SKILL.md)<br>계획이나 설계의 빈틈이 사라질 때까지 집요하게 질문하는 스킬 | agent가 계획이나 설계를 명확해질 때까지 질문하게 하고 싶을 때 |
164
163
  | [`grill-with-docs`](skills/grill-with-docs/SKILL.md)<br>질문 과정에서 도메인 용어와 의사결정을 문서화하는 설계 검증 스킬 | 질문 과정에서 project vocabulary와 docs/ADR까지 함께 정리하고 싶을 때 |
package/README.md CHANGED
@@ -154,11 +154,10 @@ These are the jhste-authored guardrail skills. They are installed by default as
154
154
 
155
155
  ## Bundled workflow skills
156
156
 
157
- Normal install also includes 14 workflow skills vendored from Matt Pocock's [`mattpocock/skills`](https://github.com/mattpocock/skills). These are useful for debugging, planning, architecture, issue workflows, prototyping, and handoffs. Use `--skill-set core` if you do not want them installed.
157
+ Normal install also includes 13 workflow skills vendored from Matt Pocock's [`mattpocock/skills`](https://github.com/mattpocock/skills). These are useful for debugging, planning, architecture, issue workflows, prototyping, and handoffs. Use `--skill-set core` if you do not want them installed.
158
158
 
159
159
  | Skill | Use it when |
160
160
  |---|---|
161
- | [`diagnose`](skills/diagnose/SKILL.md)<br>A diagnosis-loop skill that forces reproduce, minimize, hypothesize, instrument, fix, and regression-check steps | Diagnosing a hard bug or performance regression systematically |
162
161
  | [`diagnosing-bugs`](skills/diagnosing-bugs/SKILL.md)<br>A debugging skill that narrows root cause around a fast pass/fail feedback loop | You need a reproduce → minimise → hypothesise → instrument → fix loop |
163
162
  | [`grill-me`](skills/grill-me/SKILL.md)<br>A skill that asks persistent questions until a plan or design has no obvious gaps | You want the agent to question your plan or design until it becomes clear |
164
163
  | [`grill-with-docs`](skills/grill-with-docs/SKILL.md)<br>A design-challenge skill that documents domain terms and decisions while questioning the plan | You want project vocabulary and docs/ADRs updated during the questioning process |
@@ -175,7 +174,7 @@ Normal install also includes 14 workflow skills vendored from Matt Pocock's [`ma
175
174
 
176
175
  ## Attribution: Matt Pocock skills
177
176
 
178
- This repository vendors the 14 skills listed above from Matt Pocock's [`mattpocock/skills`](https://github.com/mattpocock/skills).
177
+ This repository vendors the 13 skills listed above from Matt Pocock's [`mattpocock/skills`](https://github.com/mattpocock/skills).
179
178
 
180
179
  Those skills are vendored under the upstream MIT License. This repository preserves the required copyright/license notice and records the imported sources.
181
180
 
@@ -253,4 +252,4 @@ See [`docs/ACCEPTANCE_CHECK.md`](docs/ACCEPTANCE_CHECK.md) for release acceptanc
253
252
 
254
253
  Fast agents need guardrails. `jhste-skills` gives them a repo-respecting engineering workflow.
255
254
 
256
- Installed skill directories are tracked with `.jhste-skills-manifest.json`. `--force` refreshes manifest-managed skill copies; overwriting unmanaged differing skill directories still requires the separate `--allow-unmanaged-skill-overwrite` flag after review. `sync` and `update` can also adopt additional known jhste skills into an already managed skills directory so older mixed installs can be reconciled without a manual overwrite flag.
255
+ Installed skill directories are tracked with `.jhste-skills-manifest.json`. `--force` refreshes manifest-managed skill copies; overwriting unmanaged differing skill directories still requires the separate `--allow-unmanaged-skill-overwrite` flag after review. `sync` and `update` can also adopt additional known jhste skills into an already managed skills directory so older mixed installs can be reconciled without a manual overwrite flag. Legacy vendored renames are also reconciled during `sync` and `update`, so older managed installs that still have `diagnose` are migrated to `diagnosing-bugs` without leaving duplicate skill directories.
package/README.zh.md CHANGED
@@ -158,7 +158,6 @@ Normal install 还会安装 14 个从 Matt Pocock 的 [`mattpocock/skills`](http
158
158
 
159
159
  | Skill | 何时使用 |
160
160
  |---|---|
161
- | [`diagnose`](skills/diagnose/SKILL.md)<br>强制执行 reproduce、minimize、hypothesize、instrument、fix、regression-check 的诊断循环 skill | 系统性诊断 hard bug 或 performance regression 时 |
162
161
  | [`diagnosing-bugs`](skills/diagnosing-bugs/SKILL.md)<br>围绕快速 pass/fail feedback loop 缩小 root cause 的 debugging skill | 需要 reproduce → minimise → hypothesise → instrument → fix 循环时 |
163
162
  | [`grill-me`](skills/grill-me/SKILL.md)<br>持续提问,直到计划或设计没有明显空洞的 skill | 希望 agent 持续追问计划或设计直到清晰时 |
164
163
  | [`grill-with-docs`](skills/grill-with-docs/SKILL.md)<br>在提问过程中记录 domain terms 和 decisions 的设计验证 skill | 希望在提问过程中更新 project vocabulary 和 docs/ADR 时 |
@@ -70,63 +70,6 @@ function addSharedScannerCandidates(file, text, findings, thresholds) {
70
70
  }
71
71
  }
72
72
 
73
- function hasUseClientDirective(text) {
74
- return /^\s*(?:"use client"|'use client')\s*;?/u.test(text);
75
- }
76
-
77
- function isScriptPipeline(file) {
78
- return /(^|\/)scripts\/(data|ops|import|imports|backfill|repair|migrate|migration)\//.test(file.rel)
79
- && /\.(ts|tsx|js|jsx|mjs|cjs|py)$/.test(file.rel);
80
- }
81
-
82
- function matchedResponsibilityHints(text, hintGroups) {
83
- return hintGroups
84
- .filter((group) => group.patterns.some((pattern) => pattern.test(text)))
85
- .map((group) => group.label);
86
- }
87
-
88
- function scanMixedResponsibilities(file, text, findings) {
89
- if (hasUseClientDirective(text)) {
90
- const hints = matchedResponsibilityHints(text, [
91
- { label: 'browser storage', patterns: [/\b(localStorage|sessionStorage)\b/] },
92
- { label: 'network/API', patterns: [/\bfetch\s*\(/, /\baxios\./, /\buse(Query|Mutation)\s*\(/] },
93
- { label: 'toast/notification', patterns: [/\btoast\b/, /\bnotify\b/] },
94
- { label: 'modal/dialog state', patterns: [/\b(Dialog|Modal|Sheet)\b/, /\bopen[A-Z]\w*\b/, /\bis[A-Z]\w*Open\b/] },
95
- { label: 'route navigation', patterns: [/\buseRouter\s*\(/, /\brouter\.(push|replace|refresh)\b/] },
96
- { label: 'heavy mapping', patterns: [/\.(map|filter|reduce)\s*\(/] },
97
- ]);
98
- if (hints.length >= 3) {
99
- candidate(findings.responsibilityBudget, 'mixed client responsibility candidate', file, 1, `client module mixes ${hints.slice(0, 4).join(', ')}; review hook/adapter/presentation split`, 'warning');
100
- }
101
- }
102
-
103
- const routeLike = /(^|\/)(api|routes?|controllers?|pages\/api)\//i.test(file.rel) || /route\.(ts|js)$/.test(file.rel);
104
- if (routeLike) {
105
- const hints = matchedResponsibilityHints(text, [
106
- { label: 'auth/session', patterns: [/\b(auth|session|permission|currentUser|getUser)\b/i] },
107
- { label: 'validation', patterns: [/\b(z\.object|safeParse|parseAsync|validate|schema)\b/] },
108
- { label: 'database', patterns: [/\b(prisma|pool\.query|client\.query|SELECT|INSERT|UPDATE|DELETE|db\.)\b/i] },
109
- { label: 'response formatting', patterns: [/\b(Response\.json|NextResponse\.json|res\.json)\b/] },
110
- ]);
111
- if (hints.length >= 3) {
112
- candidate(findings.responsibilityBudget, 'mixed route responsibility candidate', file, 1, `route/controller mixes ${hints.join(', ')}; review route/service/repository/response split`, 'warning');
113
- }
114
- }
115
-
116
- if (isScriptPipeline(file)) {
117
- const hints = matchedResponsibilityHints(text, [
118
- { label: 'CLI parsing', patterns: [/\b(process\.argv|argparse|ArgumentParser|commander)\b/] },
119
- { label: 'file IO', patterns: [/\b(readFile|writeFile|open\(|Path\(|fs\.)\b/] },
120
- { label: 'data transform', patterns: [/\.(map|filter|reduce)\s*\(/, /\bjson\.loads\b/i, /\bJSON\.parse\b/] },
121
- { label: 'persistence/network', patterns: [/\b(fetch|pool\.query|client\.query|INSERT|UPDATE|DELETE|requests\.)\b/i] },
122
- { label: 'reporting', patterns: [/\b(console\.|print\(|logger\.)\b/] },
123
- ]);
124
- if (hints.length >= 4) {
125
- candidate(findings.responsibilityBudget, 'mixed script responsibility candidate', file, 1, `script mixes ${hints.join(', ')}; review CLI/loader/transform/persist/report seams`, 'warning');
126
- }
127
- }
128
- }
129
-
130
73
  function newFindingsBag() {
131
74
  return {
132
75
  largeFiles: [],
@@ -157,7 +100,6 @@ export function scanFiles(files, thresholds) {
157
100
  try {
158
101
  const text = fs.readFileSync(file.full, 'utf8');
159
102
  addSharedScannerCandidates(file, text, findings, thresholds);
160
- scanMixedResponsibilities(file, text, findings);
161
103
  } catch (error) {
162
104
  const message = error instanceof Error ? error.message : String(error);
163
105
  candidate(findings.scanWarnings, 'scan warning', file, 1, `file could not be scanned and was omitted from rule candidates: ${message}`, 'warning');
@@ -18,6 +18,9 @@ export const FINDING_METADATA = {
18
18
  'responsibility.route.budget': { family: 'responsibility_budget', pack: 'core', scanner: 'scanResponsibilityBudget' },
19
19
  'responsibility.script.budget': { family: 'responsibility_budget', pack: 'core', scanner: 'scanResponsibilityBudget' },
20
20
  'responsibility.python_orchestrator.budget': { family: 'responsibility_budget', pack: 'core', scanner: 'scanResponsibilityBudget' },
21
+ 'responsibility.client.mixed': { family: 'responsibility_budget', pack: 'core', scanner: 'scanResponsibilityBudget' },
22
+ 'responsibility.route.mixed': { family: 'responsibility_budget', pack: 'core', scanner: 'scanResponsibilityBudget' },
23
+ 'responsibility.script.mixed': { family: 'responsibility_budget', pack: 'core', scanner: 'scanResponsibilityBudget' },
21
24
  'srp.function.length': { family: 'single_responsibility_advisory', pack: 'core', scanner: 'scanSingleResponsibility' },
22
25
  'srp.function.mixed_responsibility': { family: 'single_responsibility_advisory', pack: 'core', scanner: 'scanSingleResponsibility' },
23
26
  'srp.module.mixed_exports': { family: 'single_responsibility_advisory', pack: 'core', scanner: 'scanSingleResponsibility' },
@@ -66,7 +66,7 @@ function guidanceForFinding(item) {
66
66
  if (family === 'single_responsibility_advisory') {
67
67
  return {
68
68
  means: 'This class, module, or function may have more than one reason to change. The finding is heuristic and should be reviewed, not treated as proof.',
69
- next: 'Name the one main responsibility, then move only independently changing work behind a real seam; avoid extracting shallow pass-through wrappers.',
69
+ next: 'Name the one main responsibility, then move only independently changing work behind a real seam; keep always-cochanging contract pieces together and avoid shallow pass-through wrappers.',
70
70
  };
71
71
  }
72
72
  if (family === 'external_input_validation') {
@@ -1,6 +1,8 @@
1
1
  import path from 'node:path';
2
2
  import {
3
3
  hasUseClientDirective,
4
+ isRouteLikePath,
5
+ isScriptPipelinePath,
4
6
  isSourceCodePath,
5
7
  lineAt,
6
8
  violation,
@@ -119,6 +121,42 @@ export function scanFileSizeAdvisory(relPath, text, settings) {
119
121
  return [];
120
122
  }
121
123
 
124
+ function matchedResponsibilityHints(text, hintGroups) {
125
+ return hintGroups
126
+ .filter((group) => group.patterns.some((pattern) => pattern.test(text)))
127
+ .map((group) => group.label);
128
+ }
129
+
130
+ function mixedClientResponsibilityHints(text) {
131
+ return matchedResponsibilityHints(text, [
132
+ { label: 'browser storage', patterns: [/\b(localStorage|sessionStorage)\b/] },
133
+ { label: 'network/API', patterns: [/\bfetch\s*\(/, /\baxios\./, /\buse(Query|Mutation)\s*\(/] },
134
+ { label: 'toast/notification', patterns: [/\btoast\b/, /\bnotify\b/] },
135
+ { label: 'modal/dialog state', patterns: [/\b(Dialog|Modal|Sheet)\b/, /\bopen[A-Z]\w*\b/, /\bis[A-Z]\w*Open\b/] },
136
+ { label: 'route navigation', patterns: [/\buseRouter\s*\(/, /\brouter\.(push|replace|refresh)\b/] },
137
+ { label: 'heavy mapping', patterns: [/\.(map|filter|reduce)\s*\(/] },
138
+ ]);
139
+ }
140
+
141
+ function mixedRouteResponsibilityHints(text) {
142
+ return matchedResponsibilityHints(text, [
143
+ { label: 'auth/session', patterns: [/\b(auth|session|permission|currentUser|getUser)\b/i] },
144
+ { label: 'validation', patterns: [/\b(z\.object|safeParse|parseAsync|validate|schema)\b/] },
145
+ { label: 'database', patterns: [/\b(prisma|pool\.query|client\.query|SELECT|INSERT|UPDATE|DELETE|db\.)\b/i] },
146
+ { label: 'response formatting', patterns: [/\b(Response\.json|NextResponse\.json|res\.json)\b/] },
147
+ ]);
148
+ }
149
+
150
+ function mixedScriptResponsibilityHints(text) {
151
+ return matchedResponsibilityHints(text, [
152
+ { label: 'CLI parsing', patterns: [/\b(process\.argv|argparse|ArgumentParser|commander)\b/] },
153
+ { label: 'file IO', patterns: [/\b(readFile|writeFile|open\(|Path\(|fs\.)\b/] },
154
+ { label: 'data transform', patterns: [/\.(map|filter|reduce)\s*\(/, /\bjson\.loads\b/i, /\bJSON\.parse\b/] },
155
+ { label: 'persistence/network', patterns: [/\b(fetch|pool\.query|client\.query|INSERT|UPDATE|DELETE|requests\.)\b/i] },
156
+ { label: 'reporting', patterns: [/\b(console\.|print\(|logger\.)\b/] },
157
+ ]);
158
+ }
159
+
122
160
  export function scanResponsibilityBudget(relPath, text, settings) {
123
161
  const ext = path.extname(relPath).toLowerCase();
124
162
  if (!['.js', '.jsx', '.ts', '.tsx', '.mjs', '.cjs', '.py'].includes(ext)) return [];
@@ -131,17 +169,35 @@ export function scanResponsibilityBudget(relPath, text, settings) {
131
169
  if (hasUseClientDirective(text) && lineCount > settings.client_module_review_lines) {
132
170
  out.push(violation({ ruleId: 'responsibility.client.budget', severity: 'warning', relPath, symbol: 'use-client', message: `${lineCount} lines in client module; review hook/adapter/presentation split.`, confidence: 'medium' }));
133
171
  }
134
- const routeLike = /(^|\/)(api|routes?|controllers?|pages\/api)\//i.test(relPath) || /route\.(ts|js)$/.test(relPath);
172
+ const routeLike = isRouteLikePath(relPath);
135
173
  if (routeLike && lineCount >= settings.route_review_lines) {
136
174
  out.push(violation({ ruleId: 'responsibility.route.budget', severity: 'warning', relPath, symbol: 'route', message: `${lineCount} lines in route/controller-like file; review auth/validation/service/response seams.`, confidence: 'medium' }));
137
175
  }
138
- const scriptPipeline = /(^|\/)scripts\/(data|ops|import|imports|backfill|repair|migrate|migration)\//.test(relPath);
176
+ const scriptPipeline = isScriptPipelinePath(relPath);
139
177
  if (scriptPipeline && lineCount >= settings.import_ops_script_review_lines) {
140
178
  out.push(violation({ ruleId: 'responsibility.script.budget', severity: 'warning', relPath, symbol: 'script-pipeline', message: `${lineCount} lines in import/ops-style script; review CLI/loader/transform/persist/report seams.`, confidence: 'medium' }));
141
179
  }
142
180
  if (ext === '.py' && /(^|\/)(main|.*orchestrator|.*runner|stage_runner)\.py$/.test(relPath) && lineCount >= settings.python_orchestrator_review_lines) {
143
181
  out.push(violation({ ruleId: 'responsibility.python_orchestrator.budget', severity: 'warning', relPath, symbol: 'python-orchestrator', message: `${lineCount} lines in Python orchestrator/runner; review policy/IO/runtime/notification/result seams.`, confidence: 'medium' }));
144
182
  }
183
+ if (hasUseClientDirective(text)) {
184
+ const hints = mixedClientResponsibilityHints(text);
185
+ if (hints.length >= 3) {
186
+ out.push(violation({ ruleId: 'responsibility.client.mixed', severity: 'warning', relPath, symbol: 'use-client-mixed', message: `client module mixes ${hints.slice(0, 4).join(', ')}; review hook/adapter/presentation split.`, confidence: 'low' }));
187
+ }
188
+ }
189
+ if (routeLike) {
190
+ const hints = mixedRouteResponsibilityHints(text);
191
+ if (hints.length >= 3) {
192
+ out.push(violation({ ruleId: 'responsibility.route.mixed', severity: 'warning', relPath, symbol: 'route-mixed', message: `route/controller mixes ${hints.join(', ')}; review route/service/repository/response split.`, confidence: 'low' }));
193
+ }
194
+ }
195
+ if (scriptPipeline) {
196
+ const hints = mixedScriptResponsibilityHints(text);
197
+ if (hints.length >= 4) {
198
+ out.push(violation({ ruleId: 'responsibility.script.mixed', severity: 'warning', relPath, symbol: 'script-pipeline-mixed', message: `script mixes ${hints.join(', ')}; review CLI/loader/transform/persist/report seams.`, confidence: 'low' }));
199
+ }
200
+ }
145
201
  return out;
146
202
  }
147
203
 
@@ -12,11 +12,14 @@ const RESPONSIBILITY_HINTS = [
12
12
  { label: 'validation', patterns: [/\b(validate|validator|safeParse|parseAsync|schema|assert|parseEnv|errors\.push)\b/i] },
13
13
  { label: 'filesystem IO', patterns: [/\b(fs\.|readFile|writeFile|mkdir|rmSync|cpSync|readdirSync)\b/i] },
14
14
  { label: 'process/git/network IO', patterns: [/\b(spawnSync|execFileSync|fetch\(|axios\.|git\(|git\s+-C)\b/i] },
15
- { label: 'persistence', patterns: [/\b(prisma|pool\.query|client\.query|db\.|INSERT\s+INTO|UPDATE\s+\w|DELETE\s+FROM|SELECT\s+.+\s+FROM)\b/i] },
15
+ { label: 'persistence', patterns: [/\b(prisma|pool\.query|client\.query|db\.|INSERT\s+INTO|UPDATE\s+\w|DELETE\s+FROM|SELECT\s+.+\s+FROM)\b/i, /\b\w*(Repository|Repo|Store)\.(find|findMany|save|create|insert|update|delete|upsert|query|persist)\w*\s*\(/i] },
16
16
  { label: 'rendering/reporting', patterns: [/\b(console\.|Response\.json|NextResponse\.json|res\.json|render|markdown|tableRows|print|logger\.)\b/i] },
17
17
  { label: 'prompting', patterns: [/\b(ask\(|readline|question\(|prompt)\b/i] },
18
18
  { label: 'data transformation', patterns: [/\btransform|serialize|deserialize\b/i] },
19
19
  { label: 'time/crypto policy', patterns: [/\b(Date\.now|new Date\(|crypto\.|randomUUID|createHash)\b/i] },
20
+ { label: 'notification/email side effect', patterns: [/\b\w*(Email|Mail|Notification|Notifier)\w*\.(send|deliver|notify|enqueue|publish)\w*\s*\(/i, /\b(sendEmail|sendMail|sendWelcome|notifyUser)\w*\s*\(/i] },
21
+ { label: 'billing/payment side effect', patterns: [/\b\w*(Payment|Billing|Invoice|Subscription|Stripe)\w*\.(create|charge|capture|refund|update|cancel)\w*\s*\(/i] },
22
+ { label: 'event/queue side effect', patterns: [/\b(eventBus|queue|publisher|producer)\.(publish|send|enqueue|emit)\w*\s*\(/i] },
20
23
  ];
21
24
 
22
25
  const EXPORT_NAME_FAMILIES = [
@@ -56,6 +59,45 @@ function functionDeclarations(text) {
56
59
  return out;
57
60
  }
58
61
 
62
+ const CONTROL_FLOW_NAMES = new Set(['if', 'for', 'while', 'switch', 'catch', 'function']);
63
+
64
+ function braceDepthBetween(text, start, end) {
65
+ let depth = 0;
66
+ for (let index = start; index < end; index += 1) {
67
+ if (text[index] === '{') depth += 1;
68
+ if (text[index] === '}') depth -= 1;
69
+ }
70
+ return depth;
71
+ }
72
+
73
+ function classMethodDeclarations(text) {
74
+ const classPattern = /(?:^|\n)[ \t]*(?:export\s+)?(?:default\s+)?(?:abstract\s+)?class\s+([A-Za-z_$][\w$]*)[^{]*\{/gu;
75
+ const methodPattern = /(?:^|\n)([ \t]*(?:(?:public|private|protected|static|override|abstract|async|get|set)\s+)*([A-Za-z_$][\w$]*)\s*\([^)]*\)\s*(?::[^{;\n]+)?\s*\{)/gu;
76
+ const out = [];
77
+ for (const classMatch of text.matchAll(classPattern)) {
78
+ const className = classMatch[1] || 'AnonymousClass';
79
+ const classStart = (classMatch.index || 0) + (classMatch[0].startsWith('\n') ? 1 : 0);
80
+ const classOpen = text.indexOf('{', classStart);
81
+ if (classOpen === -1) continue;
82
+ const classEnd = matchingBraceIndex(text, classOpen);
83
+ if (classEnd === -1) continue;
84
+ const classBodyStart = classOpen + 1;
85
+ const classBody = text.slice(classBodyStart, classEnd);
86
+ for (const methodMatch of classBody.matchAll(methodPattern)) {
87
+ const methodName = methodMatch[2] || 'anonymous';
88
+ if (CONTROL_FLOW_NAMES.has(methodName)) continue;
89
+ const relativeStart = (methodMatch.index || 0) + (methodMatch[0].startsWith('\n') ? 1 : 0);
90
+ const start = classBodyStart + relativeStart;
91
+ if (braceDepthBetween(text, classOpen, start) !== 1) continue;
92
+ const openBrace = classBodyStart + (methodMatch.index || 0) + methodMatch[0].lastIndexOf('{');
93
+ const end = matchingBraceIndex(text, openBrace);
94
+ if (end === -1 || end > classEnd) continue;
95
+ out.push({ name: `${className}.${methodName}`, start, end, body: text.slice(start, end + 1) });
96
+ }
97
+ }
98
+ return out;
99
+ }
100
+
59
101
  function matchingBraceIndex(text, openBrace) {
60
102
  let depth = 0;
61
103
  let quote = '';
@@ -111,7 +153,8 @@ function pythonFunctionDeclarations(text) {
111
153
  }
112
154
 
113
155
  function declarationsForPath(relPath, text) {
114
- return relPath.endsWith('.py') ? pythonFunctionDeclarations(text) : functionDeclarations(text);
156
+ if (relPath.endsWith('.py')) return pythonFunctionDeclarations(text);
157
+ return [...functionDeclarations(text), ...classMethodDeclarations(text)].sort((left, right) => left.start - right.start);
115
158
  }
116
159
 
117
160
  function exportedCallableNames(text) {
@@ -5,6 +5,13 @@ import { readJsonFile, validateJsonObject, validateStringArray } from '../json-f
5
5
 
6
6
  export const SKILLS_MANIFEST_NAME = '.jhste-skills-manifest.json';
7
7
  export const MANIFEST_MANAGED_BY = 'jhste-skills';
8
+ export const LEGACY_SKILL_RENAMES = Object.freeze({
9
+ diagnose: 'diagnosing-bugs',
10
+ });
11
+
12
+ export function canonicalSkillName(name) {
13
+ return LEGACY_SKILL_RENAMES[name] || name;
14
+ }
8
15
 
9
16
  function vendoredSkillNames() {
10
17
  const allowlistPath = path.join(KIT_ROOT, 'vendor', 'matt-pocock', 'allowlist.json');
@@ -16,7 +23,7 @@ function vendoredSkillNames() {
16
23
 
17
24
  export function skillNamesForSet(skillSet) {
18
25
  const sourceRoot = path.join(KIT_ROOT, 'skills');
19
- const all = listDirectories(sourceRoot);
26
+ const all = listDirectories(sourceRoot).filter((name) => !Object.prototype.hasOwnProperty.call(LEGACY_SKILL_RENAMES, name));
20
27
  const vendored = vendoredSkillNames();
21
28
  if (skillSet === 'all') return all;
22
29
  if (skillSet === 'vendor') return all.filter((name) => vendored.has(name));
@@ -72,6 +79,27 @@ function canAdoptKnownSkill({ manifest = null, adoptKnownSkills = false } = {})
72
79
  return Boolean(adoptKnownSkills && manifest && !manifest.invalid);
73
80
  }
74
81
 
82
+ function canMigrateLegacySkill({ currentManifest, legacyName, allowUnmanagedOverwrite = false, adoptKnownSkills = false }) {
83
+ if (allowUnmanagedOverwrite) return true;
84
+ if (currentManifest?.skills?.[legacyName]) return true;
85
+ return canAdoptKnownSkill({ manifest: currentManifest, adoptKnownSkills });
86
+ }
87
+
88
+ function removeLegacySkillDirectories(skillsDir, selected, currentManifest, nextManifest, { allowUnmanagedOverwrite = false, adoptKnownSkills = false } = {}) {
89
+ const selectedSet = new Set(selected.map((name) => canonicalSkillName(name)));
90
+ const results = [];
91
+ for (const [legacyName, canonicalName] of Object.entries(LEGACY_SKILL_RENAMES)) {
92
+ delete nextManifest.skills[legacyName];
93
+ if (!selectedSet.has(canonicalName)) continue;
94
+ const legacyPath = path.join(skillsDir, legacyName);
95
+ if (!fs.existsSync(legacyPath)) continue;
96
+ if (!canMigrateLegacySkill({ currentManifest, legacyName, allowUnmanagedOverwrite, adoptKnownSkills })) continue;
97
+ fs.rmSync(legacyPath, { recursive: true, force: true });
98
+ results.push({ status: 'removed-legacy-renamed-skill', source: legacyPath, destination: path.join(skillsDir, canonicalName), legacyName, canonicalName });
99
+ }
100
+ return results;
101
+ }
102
+
75
103
  function copyManagedSkill(source, destination, name, {
76
104
  force = false,
77
105
  allowUnmanagedOverwrite = false,
@@ -124,9 +152,7 @@ function unmanagedSkillConflicts(selected, sourceRoot, skillsDir, currentManifes
124
152
  for (const name of selected) {
125
153
  const source = path.join(sourceRoot, name);
126
154
  const destination = path.join(skillsDir, name);
127
- if (!fs.existsSync(source) || !fs.existsSync(destination)) continue;
128
- if (directoryDigest(source) === directoryDigest(destination)) continue;
129
- if (!currentManifest?.skills?.[name] && !canAdopt) {
155
+ if (fs.existsSync(source) && fs.existsSync(destination) && directoryDigest(source) !== directoryDigest(destination) && !currentManifest?.skills?.[name] && !canAdopt) {
130
156
  out.push({
131
157
  status: 'skipped-unmanaged-different',
132
158
  source,
@@ -135,6 +161,18 @@ function unmanagedSkillConflicts(selected, sourceRoot, skillsDir, currentManifes
135
161
  });
136
162
  }
137
163
  }
164
+ for (const [legacyName, canonicalName] of Object.entries(LEGACY_SKILL_RENAMES)) {
165
+ if (!selected.includes(canonicalName)) continue;
166
+ const legacyPath = path.join(skillsDir, legacyName);
167
+ if (!fs.existsSync(legacyPath)) continue;
168
+ if (canMigrateLegacySkill({ currentManifest, legacyName, adoptKnownSkills })) continue;
169
+ out.push({
170
+ status: 'skipped-unmanaged-different',
171
+ source: legacyPath,
172
+ destination: path.join(skillsDir, canonicalName),
173
+ reason: `${legacyName} is an older skill name that is not recorded as managed by ${MANIFEST_MANAGED_BY}; pass --allow-unmanaged-skill-overwrite only after review`,
174
+ });
175
+ }
138
176
  return out;
139
177
  }
140
178
 
@@ -146,7 +184,7 @@ export function installSkills(skillsDir, {
146
184
  } = {}) {
147
185
  const sourceRoot = path.join(KIT_ROOT, 'skills');
148
186
  ensureDir(skillsDir);
149
- const selected = Array.isArray(skillSet) ? skillSet : skillNamesForSet(skillSet);
187
+ const selected = (Array.isArray(skillSet) ? skillSet : skillNamesForSet(skillSet)).map((name) => canonicalSkillName(name));
150
188
  const currentManifest = loadSkillsManifest(skillsDir);
151
189
  if (currentManifest?.invalid) return [{ status: 'invalid-manifest', source: '', destination: manifestPath(skillsDir), reason: currentManifest.reason }];
152
190
  const nextManifest = currentManifest || { managed_by: MANIFEST_MANAGED_BY, version: packageVersion(), installed_at: nowIso(), skills: {} };
@@ -158,6 +196,10 @@ export function installSkills(skillsDir, {
158
196
  ? unmanagedSkillConflicts(selected, sourceRoot, skillsDir, currentManifest, { adoptKnownSkills })
159
197
  : [];
160
198
  if (conflicts.length) return conflicts;
199
+ const legacyResults = removeLegacySkillDirectories(skillsDir, selected, currentManifest, nextManifest, {
200
+ allowUnmanagedOverwrite,
201
+ adoptKnownSkills,
202
+ });
161
203
  const results = selected.map((name) => copyManagedSkill(path.join(sourceRoot, name), path.join(skillsDir, name), name, {
162
204
  force,
163
205
  allowUnmanagedOverwrite,
@@ -166,5 +208,5 @@ export function installSkills(skillsDir, {
166
208
  nextManifest,
167
209
  }));
168
210
  writeSkillsManifest(skillsDir, nextManifest);
169
- return results;
211
+ return [...legacyResults, ...results];
170
212
  }
package/cli/sync-core.mjs CHANGED
@@ -12,6 +12,7 @@ import {
12
12
  readIfExists,
13
13
  } from './shared.mjs';
14
14
  import { applyPlan, preflightPlan, printApplyResult } from './install-actions.mjs';
15
+ import { LEGACY_SKILL_RENAMES, canonicalSkillName } from './install-actions/skills.mjs';
15
16
  import { gitHooksDir, HOOKS, isManagedHook } from './hook-utils.mjs';
16
17
  import { printConfigErrors, printPlanSummary } from './install-flow/output.mjs';
17
18
  import { readJsonFile, validateStringArray } from './json-file.mjs';
@@ -91,7 +92,14 @@ function sourceSkillNames() {
91
92
 
92
93
  function detectInstalledSkillNames(skillsDir) {
93
94
  const known = new Set(sourceSkillNames());
94
- return listDirectories(skillsDir).filter((name) => known.has(name));
95
+ const detected = new Set();
96
+ for (const name of listDirectories(skillsDir)) {
97
+ const canonicalName = canonicalSkillName(name);
98
+ if (known.has(canonicalName) || Object.prototype.hasOwnProperty.call(LEGACY_SKILL_RENAMES, name)) {
99
+ detected.add(canonicalName);
100
+ }
101
+ }
102
+ return [...detected];
95
103
  }
96
104
 
97
105
  function skillNamesForSet(skillSet) {
@@ -52,3 +52,11 @@ npm pack --dry-run
52
52
  Record actual command output in release notes before publishing a release.
53
53
 
54
54
  Release gates include dependency-free syntax checking, a first-run `install -> deep-scan -> tune --yes -> guard` smoke flow, `npm pack --dry-run` contents checks, and packed-tarball bin execution in a fresh temp consumer. These gates are not part of commit-time hooks.
55
+
56
+ - Verify `sync`/`update` migrates older managed vendored renames without leaving duplicate directories, including `diagnose` → `diagnosing-bugs`.
57
+
58
+ ## npm trusted publishing
59
+
60
+ Package publishing is handled by `.github/workflows/publish-npm.yml` on `v*.*.*` tags using GitHub Actions OIDC trusted publishing. The workflow grants `id-token: write`, runs `npm test`, and publishes with provenance, so it does not require a long-lived npm token, local `npm adduser`, or OAuth login in the release shell.
61
+
62
+ Before cutting a tag, confirm the npm package's trusted publisher settings match this repository and workflow file exactly: GitHub owner/repo `jhste102lab/jhste-skills`, workflow `publish-npm.yml`, and no environment unless one is added to the workflow.
@@ -56,3 +56,5 @@ If a similar section exists, the installer prints the snippet instead of editing
56
56
  ## Existing hooks
57
57
 
58
58
  Managed hooks are identified by the jhste-skills hook markers. Existing non-managed hooks are never overwritten, including in `Full` mode and with `--force`. Full may install multiple hook targets, but each target is reported separately as installed, refreshed, skipped because non-managed, or failed.
59
+
60
+ Legacy vendored renames are treated differently from unmanaged conflicts. During `sync` and `update`, an older managed `diagnose` install is migrated to `diagnosing-bugs` automatically so the skills directory does not keep both names.
package/docs/RULES.md CHANGED
@@ -89,6 +89,8 @@ The rule should be used with `advisory`, `changed-files`, or `baseline-new-only`
89
89
 
90
90
  `single_responsibility_advisory` is a heuristic review signal for changed classes, modules, and functions. It looks for long functions, functions that appear to mix several concern categories, and modules whose exports look like unrelated helper families. Treat findings as prompts to name one main responsibility and one reason to change; do not extract pass-through wrappers just to silence the warning. The rule remains advisory by default, but repositories can opt into changed-file blocking by setting the rule mode and `guard.fail_on: warning`.
91
91
 
92
+ SRP is not a "one function per file" or "smallest possible file" rule. A split is useful when the separated code has an independent reason to change, an understandable file-level responsibility, and a natural behavior or side-effect seam to test. If type definitions, select aliases, mappers, constants, or tiny wrappers always change together and force readers to chase several files to understand one contract, prefer a cohesive contract module instead. The built-in scanner only emits low-confidence static candidates; co-change history, call graphs, and reader navigation cost still require human review.
93
+
92
94
  ## Restricted profile format
93
95
 
94
96
  `.jhste/profile.yaml` uses a documented restricted YAML-like contract rather than arbitrary YAML. Supported operational sections are `mode`, `packs.<id>.mode`, `rules.<id>.mode`, file-size/responsibility/single-responsibility threshold keys, `baseline.enabled`, `baseline.path`, `guard.default_scope`, `guard.default_format`, `guard.fail_on`, `guard.exit_codes`, and `commands` with `cmd`/`args` or legacy `run`. Unknown pack ids, rule ids, guard keys, baseline keys, command keys, duplicate operational sections, and invalid numeric thresholds are config failures with exit `3`. Documentation-only metadata sections such as `recommendations`, `adapters`, `deep_scan`, `workflow`, and `strict` do not affect guard runtime settings.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jhste-skills",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Installable engineering guardrails and workflow skills for AI coding agents.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -33,7 +33,7 @@
33
33
  "LICENSE"
34
34
  ],
35
35
  "scripts": {
36
- "test": "npm run syntax:check && npm run docs:check && npm run vendor:check && npm run public-safety:check && npm run public-safety-fixtures:test && npm run profile-fixtures:test && npm run guard-fixtures:test && npm run single-responsibility-fixtures:test && npm run smoke:test && npm run release:gates",
36
+ "test": "npm run syntax:check && npm run docs:check && npm run vendor:check && npm run public-safety:check && npm run public-safety-fixtures:test && npm run profile-fixtures:test && npm run guard-fixtures:test && npm run responsibility-budget-fixtures:test && npm run single-responsibility-fixtures:test && npm run smoke:test && npm run release:gates",
37
37
  "syntax:check": "node scripts/syntax-check.mjs",
38
38
  "docs:check": "node scripts/docs-check.mjs",
39
39
  "vendor:check": "node scripts/vendor-check.mjs",
@@ -41,6 +41,7 @@
41
41
  "public-safety-fixtures:test": "node scripts/public-safety-fixtures-test.mjs",
42
42
  "profile-fixtures:test": "node scripts/profile-fixtures-test.mjs",
43
43
  "guard-fixtures:test": "node scripts/guard-fixtures-test.mjs",
44
+ "responsibility-budget-fixtures:test": "node scripts/responsibility-budget-fixtures-test.mjs",
44
45
  "single-responsibility-fixtures:test": "node scripts/single-responsibility-fixtures-test.mjs",
45
46
  "smoke:test": "node scripts/smoke-test.mjs",
46
47
  "release:gates": "node scripts/release-gates-test.mjs"
@@ -35,6 +35,9 @@ implementation:
35
35
  - responsibility.route.budget
36
36
  - responsibility.script.budget
37
37
  - responsibility.python_orchestrator.budget
38
+ - responsibility.client.mixed
39
+ - responsibility.route.mixed
40
+ - responsibility.script.mixed
38
41
  recommendation:
39
42
  changed_files: true
40
43
  baseline_supported: true
@@ -31,5 +31,5 @@ recommendation:
31
31
  baseline_supported: true
32
32
  default_enforcement: review_only
33
33
  public_safe_examples:
34
- bad: Keep adding parsing, validation, filesystem IO, prompting, transformation, persistence, and reporting to one function or shared utility bucket.
35
- good: Name the changed module or function's one responsibility, keep cohesive implementation inside deep modules, and extract only when a real seam improves locality.
34
+ bad: Keep adding parsing, validation, filesystem IO, prompting, transformation, persistence, and reporting to one function or split every type, select alias, mapper, and tiny wrapper into separate files that always change together.
35
+ good: Name the changed module or function's one responsibility and one independent reason to change; keep cohesive contracts together inside deep modules, and extract only when a real tested seam improves locality.
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env node
2
+ import path from 'node:path';
3
+ import {
4
+ fail,
5
+ guardJson,
6
+ hasRule,
7
+ makeRepo,
8
+ write,
9
+ } from './guard-fixtures/helpers.mjs';
10
+
11
+ {
12
+ const repo = makeRepo('responsibility-mixed');
13
+ write(path.join(repo, 'src/components/EventPanel.tsx'), `"use client";
14
+ export function EventPanel() {
15
+ const cached = localStorage.getItem('event');
16
+ fetch('/api/events');
17
+ toast.success(cached);
18
+ return <Dialog open={true} />;
19
+ }
20
+ `);
21
+ write(path.join(repo, 'src/app/api/events/route.ts'), `const schema = { safeParse(value) { return { success: true, data: value }; } };
22
+ export async function POST(request) {
23
+ const user = await requireUser();
24
+ const body = schema.safeParse(await request.json());
25
+ const rows = await prisma.event.findMany({ where: { userId: user.id } });
26
+ return Response.json({ body, rows });
27
+ }
28
+ `);
29
+ write(path.join(repo, 'scripts/import/events.ts'), `import fs from 'node:fs';
30
+ export async function main() {
31
+ const file = process.argv[2];
32
+ const rows = JSON.parse(fs.readFileSync(file, 'utf8')).map((row) => row.id);
33
+ await fetch('https://example.test/events');
34
+ console.log(rows.length);
35
+ }
36
+ `);
37
+ const result = guardJson(repo);
38
+ if (!hasRule(result, 'responsibility.client.mixed', 'EventPanel.tsx')) fail('mixed client responsibility was not reported by guard');
39
+ if (!hasRule(result, 'responsibility.route.mixed', 'events/route.ts')) fail('mixed route responsibility was not reported by guard');
40
+ if (!hasRule(result, 'responsibility.script.mixed', 'scripts/import/events.ts')) fail('mixed script responsibility was not reported by guard');
41
+ for (const ruleId of ['responsibility.client.mixed', 'responsibility.route.mixed', 'responsibility.script.mixed']) {
42
+ const item = result.violations.find((violation) => violation.rule_id === ruleId);
43
+ if (item.confidence !== 'low' || item.severity !== 'warning') fail(`${ruleId} should be low-confidence warning`);
44
+ }
45
+ }
46
+
47
+ console.log('responsibility-budget-fixtures-test passed: mixed responsibility candidates verified.');
@@ -61,6 +61,23 @@ export function importRows(argv) {
61
61
  if (item.confidence !== 'low' || item.severity !== 'warning') fail('mixed function SRP candidate should be low-confidence warning');
62
62
  }
63
63
 
64
+ {
65
+ const repo = makeRepo('class-method-mixed');
66
+ write(path.join(repo, 'src/UserService.ts'), `export class UserService {
67
+ async register(input) {
68
+ const user = await userRepository.save(input);
69
+ await emailService.sendWelcome(user.email);
70
+ await paymentClient.createCustomer(user.id);
71
+ return user;
72
+ }
73
+ }
74
+ `);
75
+ const result = guardJson(repo);
76
+ const item = result.violations.find((violation) => violation.rule_id === 'srp.function.mixed_responsibility' && violation.symbol === 'UserService.register');
77
+ if (!item) fail('mixed class method SRP candidate was not reported');
78
+ if (item.confidence !== 'low' || item.severity !== 'warning') fail('mixed class method SRP candidate should be low-confidence warning');
79
+ }
80
+
64
81
  {
65
82
  const repo = makeRepo('module-exports');
66
83
  write(path.join(repo, 'src/shared.ts'), `export function parseArgs() { return {}; }
@@ -13,7 +13,7 @@ export function runConnectScenarios({ root, tmp, skillsDir }) {
13
13
  fs.mkdirSync(nonGitCwd, { recursive: true });
14
14
  run(process.execPath, [path.join(root, 'cli/install.mjs'), '--yes', '--skills-dir', nonGitCwdSkills, '--skip-deep-scan'], { cwd: nonGitCwd });
15
15
  if (fs.existsSync(path.join(nonGitCwd, '.jhste'))) fail('install outside git repo created .jhste');
16
- if (skillDirs(nonGitCwdSkills).length !== 21) fail('install outside git repo did not install bundled skills');
16
+ if (skillDirs(nonGitCwdSkills).length !== 20) fail('install outside git repo did not install 20 bundled skills');
17
17
 
18
18
  const explicitNonGitRepo = path.join(tmp, 'explicit-non-git-repo');
19
19
  const explicitNonGitSkills = path.join(tmp, 'explicit-non-git-skills');
@@ -42,6 +42,6 @@ export function runConnectScenarios({ root, tmp, skillsDir }) {
42
42
  if (connectMissing.status !== 3) fail(`connect missing skills should exit 3, got ${connectMissing.status}`);
43
43
  if (fs.existsSync(path.join(connectMissingRepo, '.jhste'))) fail('connect missing skills created .jhste');
44
44
  run(process.execPath, [path.join(root, 'cli/connect.mjs'), '--mode', 'normal', '--yes', '--repo', connectMissingRepo, '--skills-dir', connectMissingSkills, '--skip-deep-scan', '--install-missing'], { cwd: connectMissingRepo });
45
- if (skillDirs(connectMissingSkills).length !== 21) fail('connect --install-missing did not install bundled skills');
45
+ if (skillDirs(connectMissingSkills).length !== 20) fail('connect --install-missing did not install 20 bundled skills');
46
46
  if (!fs.existsSync(path.join(connectMissingRepo, '.jhste', 'profile.yaml'))) fail('connect --install-missing did not create profile');
47
47
  }
@@ -28,6 +28,15 @@ function initRepo(repo) {
28
28
  run('git', ['init'], { cwd: repo });
29
29
  }
30
30
 
31
+ function readManagedSkillsManifest(skillsDir) {
32
+ const manifestPath = path.join(skillsDir, '.jhste-skills-manifest.json');
33
+ const parsed = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
34
+ if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) fail('skills manifest is not an object');
35
+ if (parsed.managed_by !== 'jhste-skills') fail('skills manifest managed_by is invalid');
36
+ if (!parsed.skills || typeof parsed.skills !== 'object' || Array.isArray(parsed.skills)) fail('skills manifest skills map is invalid');
37
+ return parsed;
38
+ }
39
+
31
40
  function runRefusalScenarios({ root, tmp }) {
32
41
  const nonInteractiveRepo = path.join(tmp, 'noninteractive-repo');
33
42
  const nonInteractiveSkills = path.join(tmp, 'noninteractive-skills');
@@ -103,10 +112,10 @@ function runDefaultInstall(ctx) {
103
112
  if (!fs.readFileSync(defaultPreCommit, 'utf8').includes(`# jhste-skills version=${version}`)) fail('default pre-commit hook missing version comment');
104
113
  if (!fs.existsSync(path.join(skillsDir, 'jhste-red-team-review', 'SKILL.md'))) fail('install did not copy jhste-red-team-review skill');
105
114
  if (!fs.existsSync(path.join(skillsDir, '.jhste-skills-manifest.json'))) fail('install did not write skills manifest');
106
- const manifest = JSON.parse(fs.readFileSync(path.join(skillsDir, '.jhste-skills-manifest.json'), 'utf8'));
115
+ const manifest = readManagedSkillsManifest(skillsDir);
107
116
  if (manifest.managed_by !== 'jhste-skills' || !manifest.skills?.['jhste-red-team-review']?.digest) fail('skills manifest missing managed skill digest');
108
117
  const defaultSkillDirs = skillDirs(skillsDir);
109
- if (defaultSkillDirs.length !== 21) fail(`default install should copy 21 bundled skills, got ${defaultSkillDirs.length}`);
118
+ if (defaultSkillDirs.length !== 20) fail(`default install should copy 20 bundled skills, got ${defaultSkillDirs.length}`);
110
119
  if (!defaultSkillDirs.includes('improve-codebase-architecture')) fail('default install should copy vendored workflow skills');
111
120
  }
112
121
 
@@ -162,9 +171,28 @@ run_jhste_skills guard --scope staged --format text --fail-on warning
162
171
  if (!updatedPreCommit.includes(`# jhste-skills version=${version}`)) fail('update did not refresh hook version comment');
163
172
  if (updatedPreCommit.includes('stale hook')) fail('update did not replace stale managed hook content');
164
173
 
165
- const managedManifest = JSON.parse(fs.readFileSync(path.join(skillsDir, '.jhste-skills-manifest.json'), 'utf8'));
174
+ const managedManifest = readManagedSkillsManifest(skillsDir);
166
175
  if (!managedManifest.skills?.[adoptedSkillName]?.digest) fail('update did not record adopted known skill in manifest');
167
176
 
177
+ const legacySkillName = 'diagnose';
178
+ const canonicalSkillName = 'diagnosing-bugs';
179
+ const legacySkillDir = path.join(skillsDir, legacySkillName);
180
+ fs.mkdirSync(legacySkillDir, { recursive: true });
181
+ fs.writeFileSync(path.join(legacySkillDir, 'SKILL.md'), '# stale legacy diagnose copy\n');
182
+ managedManifest.skills[legacySkillName] = { digest: 'legacy-digest' };
183
+ fs.writeFileSync(path.join(skillsDir, '.jhste-skills-manifest.json'), `${JSON.stringify(managedManifest, null, 2)}\n`);
184
+
185
+ run(process.execPath, [path.join(root, 'cli/update.mjs'), '--yes', '--repo', repo, '--skills-dir', skillsDir], { cwd: repo });
186
+
187
+ if (fs.existsSync(legacySkillDir)) fail('update did not remove legacy diagnose skill directory');
188
+ const canonicalSkillPath = path.join(skillsDir, canonicalSkillName, 'SKILL.md');
189
+ if (fs.readFileSync(canonicalSkillPath, 'utf8') !== fs.readFileSync(path.join(root, 'skills', canonicalSkillName, 'SKILL.md'), 'utf8')) {
190
+ fail('update did not keep canonical diagnosing-bugs skill content after legacy migration');
191
+ }
192
+ const migratedManifest = readManagedSkillsManifest(skillsDir);
193
+ if (migratedManifest.skills?.[legacySkillName]) fail('update left legacy diagnose entry in manifest after migration');
194
+ if (!migratedManifest.skills?.[canonicalSkillName]?.digest) fail('update did not keep canonical diagnosing-bugs entry in manifest after migration');
195
+
168
196
  const unmanagedSkills = path.join(path.dirname(skillsDir), 'unmanaged-skills');
169
197
  fs.mkdirSync(path.join(unmanagedSkills, 'jhste-code-quality'), { recursive: true });
170
198
  fs.writeFileSync(path.join(unmanagedSkills, 'jhste-code-quality', 'SKILL.md'), '# unmanaged local copy\n');
@@ -218,7 +246,7 @@ function runSkillSetScenarios({ root, tmp }) {
218
246
  fs.writeFileSync(path.join(vendorRepo, 'AGENTS.md'), '# Vendor skill repo\n');
219
247
  run(process.execPath, [path.join(root, 'cli/install.mjs'), '--yes', '--repo', vendorRepo, '--skills-dir', vendorSkillsDir, '--skip-deep-scan', '--skip-hooks', '--skill-set', 'vendor'], { cwd: vendorRepo });
220
248
  const vendorSkillDirs = skillDirs(vendorSkillsDir);
221
- if (vendorSkillDirs.length !== 14) fail(`--skill-set vendor should copy 14 skills, got ${vendorSkillDirs.length}`);
249
+ if (vendorSkillDirs.length !== 13) fail(`--skill-set vendor should copy 13 skills, got ${vendorSkillDirs.length}`);
222
250
  if (!vendorSkillDirs.includes('improve-codebase-architecture')) fail('--skill-set vendor did not copy expected vendored skill');
223
251
  if (vendorSkillDirs.includes('jhste-red-team-review')) fail('--skill-set vendor copied core skill');
224
252
 
@@ -228,7 +256,7 @@ function runSkillSetScenarios({ root, tmp }) {
228
256
  fs.writeFileSync(path.join(allRepo, 'AGENTS.md'), '# All skill repo\n');
229
257
  run(process.execPath, [path.join(root, 'cli/install.mjs'), '--yes', '--repo', allRepo, '--skills-dir', allSkillsDir, '--skip-deep-scan', '--skip-hooks', '--skill-set', 'all'], { cwd: allRepo });
230
258
  const allSkillDirs = skillDirs(allSkillsDir);
231
- if (allSkillDirs.length !== 21) fail(`--skill-set all should copy 21 skills, got ${allSkillDirs.length}`);
259
+ if (allSkillDirs.length !== 20) fail(`--skill-set all should copy 20 skills, got ${allSkillDirs.length}`);
232
260
  if (!allSkillDirs.includes('jhste-red-team-review') || !allSkillDirs.includes('improve-codebase-architecture')) fail('--skill-set all missing core or vendored skill');
233
261
  }
234
262
 
@@ -47,7 +47,7 @@ function runFullModeScenarios({ root, tmp }) {
47
47
  fs.writeFileSync(path.join(fullModeRepo, 'AGENTS.md'), '# Full mode repo\n');
48
48
  run(process.execPath, [path.join(root, 'cli/install.mjs'), '--mode', 'full', '--yes', '--repo', fullModeRepo, '--skills-dir', fullModeSkillsDir, '--skip-deep-scan'], { cwd: fullModeRepo });
49
49
  const fullModeSkillDirs = skillDirs(fullModeSkillsDir);
50
- if (fullModeSkillDirs.length !== 21) fail(`--mode full should copy 21 skills, got ${fullModeSkillDirs.length}`);
50
+ if (fullModeSkillDirs.length !== 20) fail(`--mode full should copy 20 skills, got ${fullModeSkillDirs.length}`);
51
51
  const fullPreCommit = path.join(fullModeRepo, '.git', 'hooks', 'pre-commit');
52
52
  const fullPrePush = path.join(fullModeRepo, '.git', 'hooks', 'pre-push');
53
53
  if (!fs.existsSync(fullPreCommit) || !fs.existsSync(fullPrePush)) fail('--mode full did not install pre-commit and pre-push');
@@ -6,7 +6,6 @@ import { readJsonFile, validateJsonObject, validateStringArray } from '../cli/js
6
6
 
7
7
  const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
8
8
  const expected = [
9
- 'diagnose',
10
9
  'grill-with-docs',
11
10
  'triage',
12
11
  'improve-codebase-architecture',
@@ -39,12 +38,12 @@ function readJson(file) {
39
38
 
40
39
  const allowlist = readJson('vendor/matt-pocock/allowlist.json');
41
40
  if (JSON.stringify(allowlist) !== JSON.stringify(expected)) {
42
- fail('allowlist does not match the exact 14 selected skills');
41
+ fail('allowlist does not match the exact 13 selected skills');
43
42
  }
44
43
 
45
44
  const sourceLock = readJson('vendor/matt-pocock/source-lock.json');
46
45
  if (!Array.isArray(sourceLock.skills) || sourceLock.skills.length !== expected.length) {
47
- fail('source-lock must contain exactly 14 skills');
46
+ fail('source-lock must contain exactly 13 skills');
48
47
  }
49
48
 
50
49
  const seen = new Set();
@@ -9,6 +9,8 @@ When reviewing a proposed change, ask:
9
9
  - Does this module hide complexity or merely pass it through?
10
10
  - Are repo-local docs using a more specific term or rule?
11
11
  - Where do caller contracts, mutation safety, or hot-path performance assumptions belong so they stay visible instead of leaking across seams?
12
+ - Do the proposed files change independently, or do they always move together as one cohesive contract?
13
+ - Would the split reduce the number of files touched for a typical change, or merely make readers chase more files?
12
14
 
13
15
  ## Bad / better / why skeletons
14
16
 
@@ -34,6 +36,12 @@ Change adjacent code only when it sits on the changed execution path and leaving
34
36
  - Better: each module owns one responsibility such as argument parsing, repository discovery, filesystem operations, prompting, or rendering; keep a compatibility facade only when it contains no policy and prevents churn.
35
37
  - Why: maintainers can name one reason to change the module, while callers do not learn unrelated helpers.
36
38
 
39
+ ### Over-fragmented contract split
40
+
41
+ - Bad: a cohesive feature contract is split into separate `*-types`, `*-select`, `*-mapper`, `*-aliases`, and tiny wrapper files that are hard to understand alone and usually change in the same commit.
42
+ - Better: keep type, select/shape alias, mapper, and small constants together when they describe one caller-facing contract; split only the independently changing query, policy, side effect, or behavior seam.
43
+ - Why: SRP is about independent reasons to change, not maximizing file count; good splits reduce change surface and test scope without increasing reader navigation cost.
44
+
37
45
  ### Function responsibility split
38
46
 
39
47
  - Bad: one function parses input, validates it, reads files, transforms data, writes output, prints a report, and decides exit behavior.
@@ -1,5 +1,4 @@
1
1
  [
2
- "diagnose",
3
2
  "grill-with-docs",
4
3
  "triage",
5
4
  "improve-codebase-architecture",
@@ -3,14 +3,6 @@
3
3
  "imported_at": "2026-06-18T10:53:47Z",
4
4
  "license": "MIT",
5
5
  "skills": [
6
- {
7
- "name": "diagnose",
8
- "source": "https://github.com/mattpocock/skills/tree/main/skills/engineering/diagnose",
9
- "commit": "694fa30311e02c2639942308513555e61ee84a6f",
10
- "license": "MIT; see vendor/matt-pocock/LICENSE",
11
- "vendored_path": "skills/diagnose",
12
- "imported_at": "2026-06-17T10:11:18Z"
13
- },
14
6
  {
15
7
  "name": "grill-with-docs",
16
8
  "source": "https://github.com/mattpocock/skills/tree/main/skills/engineering/grill-with-docs",
@@ -1,125 +0,0 @@
1
- ---
2
- name: diagnose
3
- description: Disciplined diagnosis loop for hard bugs and performance regressions. Reproduce → minimise → hypothesise → instrument → fix → regression-test. Use when user says "diagnose this" / "debug this", reports a bug, says something is broken/throwing/failing, or describes a performance regression.
4
- ---
5
-
6
- ## jhste compatibility
7
-
8
- - Repo-local instructions remain authoritative.
9
- - Use `jhste-engineering-judgment` for scope, seams, assumptions, and failure paths when it applies.
10
- - Vocabulary in this vendored skill is advisory unless adopted by repo-local docs; do not rename established repo concepts only to match this skill.
11
- - File, repo, command, issue, PR, or other external side effects require explicit approval unless the user already requested that exact side effect.
12
-
13
-
14
- # Diagnose
15
-
16
- A discipline for hard bugs. Skip phases only when explicitly justified.
17
-
18
- When exploring the codebase, use the project's domain glossary to get a clear mental model of the relevant modules, and check ADRs in the area you're touching.
19
-
20
- ## Phase 1 — Build a feedback loop
21
-
22
- **This is the skill.** Everything else is mechanical. If you have a fast, deterministic, agent-runnable pass/fail signal for the bug, you will find the cause — bisection, hypothesis-testing, and instrumentation all just consume that signal. If you don't have one, no amount of staring at code will save you.
23
-
24
- Spend disproportionate effort here. **Be aggressive. Be creative. Refuse to give up.**
25
-
26
- ### Ways to construct one — try them in roughly this order
27
-
28
- 1. **Failing test** at whatever seam reaches the bug — unit, integration, e2e.
29
- 2. **Curl / HTTP script** against a running dev server.
30
- 3. **CLI invocation** with a fixture input, diffing stdout against a known-good snapshot.
31
- 4. **Headless browser script** (Playwright / Puppeteer) — drives the UI, asserts on DOM/console/network.
32
- 5. **Replay a captured trace.** Save a real network request / payload / event log to disk; replay it through the code path in isolation.
33
- 6. **Throwaway harness.** Spin up a minimal subset of the system (one service, mocked deps) that exercises the bug code path with a single function call.
34
- 7. **Property / fuzz loop.** If the bug is "sometimes wrong output", run 1000 random inputs and look for the failure mode.
35
- 8. **Bisection harness.** If the bug appeared between two known states (commit, dataset, version), automate "boot at state X, check, repeat" so you can `git bisect run` it.
36
- 9. **Differential loop.** Run the same input through old-version vs new-version (or two configs) and diff outputs.
37
- 10. **HITL bash script.** Last resort. If a human must click, drive _them_ with `scripts/hitl-loop.template.sh` so the loop is still structured. Captured output feeds back to you.
38
-
39
- Build the right feedback loop, and the bug is 90% fixed.
40
-
41
- ### Iterate on the loop itself
42
-
43
- Treat the loop as a product. Once you have _a_ loop, ask:
44
-
45
- - Can I make it faster? (Cache setup, skip unrelated init, narrow the test scope.)
46
- - Can I make the signal sharper? (Assert on the specific symptom, not "didn't crash".)
47
- - Can I make it more deterministic? (Pin time, seed RNG, isolate filesystem, freeze network.)
48
-
49
- A 30-second flaky loop is barely better than no loop. A 2-second deterministic loop is a debugging superpower.
50
-
51
- ### Non-deterministic bugs
52
-
53
- The goal is not a clean repro but a **higher reproduction rate**. Loop the trigger 100×, parallelise, add stress, narrow timing windows, inject sleeps. A 50%-flake bug is debuggable; 1% is not — keep raising the rate until it's debuggable.
54
-
55
- ### When you genuinely cannot build a loop
56
-
57
- Stop and say so explicitly. List what you tried. Ask the user for: (a) access to whatever environment reproduces it, (b) a captured artifact (HAR file, log dump, core dump, screen recording with timestamps), or (c) permission to add temporary production instrumentation. Do **not** proceed to hypothesise without a loop.
58
-
59
- Do not proceed to Phase 2 until you have a loop you believe in.
60
-
61
- ## Phase 2 — Reproduce
62
-
63
- Run the loop. Watch the bug appear.
64
-
65
- Confirm:
66
-
67
- - [ ] The loop produces the failure mode the **user** described — not a different failure that happens to be nearby. Wrong bug = wrong fix.
68
- - [ ] The failure is reproducible across multiple runs (or, for non-deterministic bugs, reproducible at a high enough rate to debug against).
69
- - [ ] You have captured the exact symptom (error message, wrong output, slow timing) so later phases can verify the fix actually addresses it.
70
-
71
- Do not proceed until you reproduce the bug.
72
-
73
- ## Phase 3 — Hypothesise
74
-
75
- Generate **3–5 ranked hypotheses** before testing any of them. Single-hypothesis generation anchors on the first plausible idea.
76
-
77
- Each hypothesis must be **falsifiable**: state the prediction it makes.
78
-
79
- > Format: "If <X> is the cause, then <changing Y> will make the bug disappear / <changing Z> will make it worse."
80
-
81
- If you cannot state the prediction, the hypothesis is a vibe — discard or sharpen it.
82
-
83
- **Show the ranked list to the user before testing.** They often have domain knowledge that re-ranks instantly ("we just deployed a change to #3"), or know hypotheses they've already ruled out. Cheap checkpoint, big time saver. Don't block on it — proceed with your ranking if the user is AFK.
84
-
85
- ## Phase 4 — Instrument
86
-
87
- Each probe must map to a specific prediction from Phase 3. **Change one variable at a time.**
88
-
89
- Tool preference:
90
-
91
- 1. **Debugger / REPL inspection** if the env supports it. One breakpoint beats ten logs.
92
- 2. **Targeted logs** at the boundaries that distinguish hypotheses.
93
- 3. Never "log everything and grep".
94
-
95
- **Tag every debug log** with a unique prefix, e.g. `[DEBUG-a4f2]`. Cleanup at the end becomes a single grep. Untagged logs survive; tagged logs die.
96
-
97
- **Perf branch.** For performance regressions, logs are usually wrong. Instead: establish a baseline measurement (timing harness, `performance.now()`, profiler, query plan), then bisect. Measure first, fix second.
98
-
99
- ## Phase 5 — Fix + regression test
100
-
101
- Write the regression test **before the fix** — but only if there is a **correct seam** for it.
102
-
103
- A correct seam is one where the test exercises the **real bug pattern** as it occurs at the call site. If the only available seam is too shallow (single-caller test when the bug needs multiple callers, unit test that can't replicate the chain that triggered the bug), a regression test there gives false confidence.
104
-
105
- **If no correct seam exists, that itself is the finding.** Note it. The codebase architecture is preventing the bug from being locked down. Flag this for the next phase.
106
-
107
- If a correct seam exists:
108
-
109
- 1. Turn the minimised repro into a failing test at that seam.
110
- 2. Watch it fail.
111
- 3. Apply the fix.
112
- 4. Watch it pass.
113
- 5. Re-run the Phase 1 feedback loop against the original (un-minimised) scenario.
114
-
115
- ## Phase 6 — Cleanup + post-mortem
116
-
117
- Required before declaring done:
118
-
119
- - [ ] Original repro no longer reproduces (re-run the Phase 1 loop)
120
- - [ ] Regression test passes (or absence of seam is documented)
121
- - [ ] All `[DEBUG-...]` instrumentation removed (`grep` the prefix)
122
- - [ ] Throwaway prototypes deleted (or moved to a clearly-marked debug location)
123
- - [ ] The hypothesis that turned out correct is stated in the commit / PR message — so the next debugger learns
124
-
125
- **Then ask: what would have prevented this bug?** If the answer involves architectural change (no good test seam, tangled callers, hidden coupling) hand off to the `/improve-codebase-architecture` skill with the specifics. Make the recommendation **after** the fix is in, not before — you have more information now than when you started.
@@ -1,41 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Human-in-the-loop reproduction loop.
3
- # Copy this file, edit the steps below, and run it.
4
- # The agent runs the script; the user follows prompts in their terminal.
5
- #
6
- # Usage:
7
- # bash hitl-loop.template.sh
8
- #
9
- # Two helpers:
10
- # step "<instruction>" → show instruction, wait for Enter
11
- # capture VAR "<question>" → show question, read response into VAR
12
- #
13
- # At the end, captured values are printed as KEY=VALUE for the agent to parse.
14
-
15
- set -euo pipefail
16
-
17
- step() {
18
- printf '\n>>> %s\n' "$1"
19
- read -r -p " [Enter when done] " _
20
- }
21
-
22
- capture() {
23
- local var="$1" question="$2" answer
24
- printf '\n>>> %s\n' "$question"
25
- read -r -p " > " answer
26
- printf -v "$var" '%s' "$answer"
27
- }
28
-
29
- # --- edit below ---------------------------------------------------------
30
-
31
- step "Open the app at http://localhost:3000 and sign in."
32
-
33
- capture ERRORED "Click the 'Export' button. Did it throw an error? (y/n)"
34
-
35
- capture ERROR_MSG "Paste the error message (or 'none'):"
36
-
37
- # --- edit above ---------------------------------------------------------
38
-
39
- printf '\n--- Captured ---\n'
40
- printf 'ERRORED=%s\n' "$ERRORED"
41
- printf 'ERROR_MSG=%s\n' "$ERROR_MSG"