jhste-skills 0.1.0 → 0.1.2
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 +0 -1
- package/README.ko.md +0 -1
- package/README.md +4 -3
- package/README.zh.md +0 -1
- package/cli/install-actions/apply-plan.mjs +1 -0
- package/cli/install-actions/skills.mjs +76 -12
- package/cli/sync-core.mjs +10 -1
- package/docs/ACCEPTANCE_CHECK.md +3 -1
- package/docs/CLI.md +3 -2
- package/docs/CONFLICT_RESOLUTION.md +3 -1
- package/package.json +1 -1
- package/scripts/smoke/connect-scenarios.mjs +2 -2
- package/scripts/smoke/guard-and-hook-scenarios.mjs +5 -2
- package/scripts/smoke/helpers.mjs +4 -0
- package/scripts/smoke/install-scenarios.mjs +48 -6
- package/scripts/smoke/mode-scenarios.mjs +1 -1
- package/scripts/vendor-check.mjs +2 -3
- package/vendor/matt-pocock/allowlist.json +0 -1
- package/vendor/matt-pocock/source-lock.json +0 -8
- package/skills/diagnose/SKILL.md +0 -125
- package/skills/diagnose/scripts/hitl-loop.template.sh +0 -41
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
|
|
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
|
|
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
|
|
|
@@ -252,3 +251,5 @@ See [`docs/ACCEPTANCE_CHECK.md`](docs/ACCEPTANCE_CHECK.md) for release acceptanc
|
|
|
252
251
|
- Run a red-team code review before calling non-trivial work complete.
|
|
253
252
|
|
|
254
253
|
Fast agents need guardrails. `jhste-skills` gives them a repo-respecting engineering workflow.
|
|
254
|
+
|
|
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 时 |
|
|
@@ -15,6 +15,7 @@ export function applyPlan(plan) {
|
|
|
15
15
|
result.skillResults = installSkills(plan.skillsDir, {
|
|
16
16
|
force: plan.forceSkills ?? plan.force,
|
|
17
17
|
allowUnmanagedOverwrite: plan.allowUnmanagedSkillOverwrite,
|
|
18
|
+
adoptKnownSkills: Boolean(plan.adoptKnownSkills),
|
|
18
19
|
skillSet: plan.skillNames ?? plan.skillSet,
|
|
19
20
|
});
|
|
20
21
|
if (result.skillResults.some((item) => ['skipped-unmanaged-different', 'invalid-manifest'].includes(item.status))) {
|
|
@@ -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));
|
|
@@ -68,7 +75,38 @@ function packageVersion() {
|
|
|
68
75
|
}
|
|
69
76
|
}
|
|
70
77
|
|
|
71
|
-
function
|
|
78
|
+
function canAdoptKnownSkill({ manifest = null, adoptKnownSkills = false } = {}) {
|
|
79
|
+
return Boolean(adoptKnownSkills && manifest && !manifest.invalid);
|
|
80
|
+
}
|
|
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
|
+
|
|
103
|
+
function copyManagedSkill(source, destination, name, {
|
|
104
|
+
force = false,
|
|
105
|
+
allowUnmanagedOverwrite = false,
|
|
106
|
+
adoptKnownSkills = false,
|
|
107
|
+
manifest = null,
|
|
108
|
+
nextManifest,
|
|
109
|
+
} = {}) {
|
|
72
110
|
if (!fs.existsSync(source)) return { status: 'missing-source', source, destination };
|
|
73
111
|
const sourceHash = directoryDigest(source);
|
|
74
112
|
const destinationExists = fs.existsSync(destination);
|
|
@@ -91,7 +129,8 @@ function copyManagedSkill(source, destination, name, { force = false, allowUnman
|
|
|
91
129
|
return { status: 'unchanged', source, destination };
|
|
92
130
|
}
|
|
93
131
|
if (!force) return { status: 'skipped-existing-different', source, destination };
|
|
94
|
-
|
|
132
|
+
const adoptKnownSkill = !manifestOwnsDestination && canAdoptKnownSkill({ manifest, adoptKnownSkills });
|
|
133
|
+
if (!manifestOwnsDestination && !allowUnmanagedOverwrite && !adoptKnownSkill) {
|
|
95
134
|
return {
|
|
96
135
|
status: 'skipped-unmanaged-different',
|
|
97
136
|
source,
|
|
@@ -102,17 +141,18 @@ function copyManagedSkill(source, destination, name, { force = false, allowUnman
|
|
|
102
141
|
fs.rmSync(destination, { recursive: true, force: true });
|
|
103
142
|
fs.cpSync(source, destination, { recursive: true });
|
|
104
143
|
recordManaged();
|
|
105
|
-
return { status:
|
|
144
|
+
if (manifestOwnsDestination) return { status: 'overwritten-managed', source, destination };
|
|
145
|
+
if (adoptKnownSkill) return { status: 'adopted-managed', source, destination };
|
|
146
|
+
return { status: 'overwritten-unmanaged', source, destination };
|
|
106
147
|
}
|
|
107
148
|
|
|
108
|
-
function unmanagedSkillConflicts(selected, sourceRoot, skillsDir, currentManifest) {
|
|
149
|
+
function unmanagedSkillConflicts(selected, sourceRoot, skillsDir, currentManifest, { adoptKnownSkills = false } = {}) {
|
|
150
|
+
const canAdopt = canAdoptKnownSkill({ manifest: currentManifest, adoptKnownSkills });
|
|
109
151
|
const out = [];
|
|
110
152
|
for (const name of selected) {
|
|
111
153
|
const source = path.join(sourceRoot, name);
|
|
112
154
|
const destination = path.join(skillsDir, name);
|
|
113
|
-
if (
|
|
114
|
-
if (directoryDigest(source) === directoryDigest(destination)) continue;
|
|
115
|
-
if (!currentManifest?.skills?.[name]) {
|
|
155
|
+
if (fs.existsSync(source) && fs.existsSync(destination) && directoryDigest(source) !== directoryDigest(destination) && !currentManifest?.skills?.[name] && !canAdopt) {
|
|
116
156
|
out.push({
|
|
117
157
|
status: 'skipped-unmanaged-different',
|
|
118
158
|
source,
|
|
@@ -121,13 +161,30 @@ function unmanagedSkillConflicts(selected, sourceRoot, skillsDir, currentManifes
|
|
|
121
161
|
});
|
|
122
162
|
}
|
|
123
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
|
+
}
|
|
124
176
|
return out;
|
|
125
177
|
}
|
|
126
178
|
|
|
127
|
-
export function installSkills(skillsDir, {
|
|
179
|
+
export function installSkills(skillsDir, {
|
|
180
|
+
force = false,
|
|
181
|
+
skillSet = 'core',
|
|
182
|
+
allowUnmanagedOverwrite = false,
|
|
183
|
+
adoptKnownSkills = false,
|
|
184
|
+
} = {}) {
|
|
128
185
|
const sourceRoot = path.join(KIT_ROOT, 'skills');
|
|
129
186
|
ensureDir(skillsDir);
|
|
130
|
-
const selected = Array.isArray(skillSet) ? skillSet : skillNamesForSet(skillSet);
|
|
187
|
+
const selected = (Array.isArray(skillSet) ? skillSet : skillNamesForSet(skillSet)).map((name) => canonicalSkillName(name));
|
|
131
188
|
const currentManifest = loadSkillsManifest(skillsDir);
|
|
132
189
|
if (currentManifest?.invalid) return [{ status: 'invalid-manifest', source: '', destination: manifestPath(skillsDir), reason: currentManifest.reason }];
|
|
133
190
|
const nextManifest = currentManifest || { managed_by: MANIFEST_MANAGED_BY, version: packageVersion(), installed_at: nowIso(), skills: {} };
|
|
@@ -135,14 +192,21 @@ export function installSkills(skillsDir, { force = false, skillSet = 'core', all
|
|
|
135
192
|
nextManifest.version = packageVersion() || String(nextManifest.version || '0.0.0');
|
|
136
193
|
nextManifest.updated_at = nowIso();
|
|
137
194
|
nextManifest.skills ||= {};
|
|
138
|
-
const conflicts = force && !allowUnmanagedOverwrite
|
|
195
|
+
const conflicts = force && !allowUnmanagedOverwrite
|
|
196
|
+
? unmanagedSkillConflicts(selected, sourceRoot, skillsDir, currentManifest, { adoptKnownSkills })
|
|
197
|
+
: [];
|
|
139
198
|
if (conflicts.length) return conflicts;
|
|
199
|
+
const legacyResults = removeLegacySkillDirectories(skillsDir, selected, currentManifest, nextManifest, {
|
|
200
|
+
allowUnmanagedOverwrite,
|
|
201
|
+
adoptKnownSkills,
|
|
202
|
+
});
|
|
140
203
|
const results = selected.map((name) => copyManagedSkill(path.join(sourceRoot, name), path.join(skillsDir, name), name, {
|
|
141
204
|
force,
|
|
142
205
|
allowUnmanagedOverwrite,
|
|
206
|
+
adoptKnownSkills,
|
|
143
207
|
manifest: currentManifest,
|
|
144
208
|
nextManifest,
|
|
145
209
|
}));
|
|
146
210
|
writeSkillsManifest(skillsDir, nextManifest);
|
|
147
|
-
return results;
|
|
211
|
+
return [...legacyResults, ...results];
|
|
148
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
|
-
|
|
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) {
|
|
@@ -159,6 +167,7 @@ function buildSyncPlan(options, command) {
|
|
|
159
167
|
mode: 'sync',
|
|
160
168
|
yes: options.yes,
|
|
161
169
|
force: options.force,
|
|
170
|
+
adoptKnownSkills: true,
|
|
162
171
|
allowUnmanagedSkillOverwrite: options.allowUnmanagedSkillOverwrite,
|
|
163
172
|
forceSkills: true,
|
|
164
173
|
installMissing: false,
|
package/docs/ACCEPTANCE_CHECK.md
CHANGED
|
@@ -34,7 +34,7 @@ Rule modes are documented in `docs/RULES.md`, example profile defaults to adviso
|
|
|
34
34
|
|
|
35
35
|
## Conflict handling
|
|
36
36
|
|
|
37
|
-
`docs/CONFLICT_RESOLUTION.md` and installer behavior preserve existing repo instructions, skip existing differing profiles/skills by default, make bridge insertion marker-managed and idempotent,
|
|
37
|
+
`docs/CONFLICT_RESOLUTION.md` and installer behavior preserve existing repo instructions, skip existing differing profiles/skills by default, make bridge insertion marker-managed and idempotent, refuse to overwrite non-managed hooks even in Full mode or with `--force`, refuse unmanaged skill-directory overwrites without `--allow-unmanaged-skill-overwrite`, and let `sync`/`update` adopt additional known jhste skills into an already managed skills directory.
|
|
38
38
|
|
|
39
39
|
## Verification commands
|
|
40
40
|
|
|
@@ -52,3 +52,5 @@ 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`.
|
package/docs/CLI.md
CHANGED
|
@@ -95,7 +95,8 @@ Stable contract:
|
|
|
95
95
|
- only refreshes repo outputs that already look managed by jhste-skills (`.jhste/profile.yaml`, managed bridge markers, or managed hooks);
|
|
96
96
|
- does not bootstrap unmanaged repositories; use `install` or `connect` for first-time setup;
|
|
97
97
|
- preserves non-managed hooks and does not touch source files, CI, `package.json`, or lockfiles;
|
|
98
|
-
- `--force` still applies only to repo-managed outputs such as overwriting an existing managed profile; unmanaged differing skill directories require `--allow-unmanaged-skill-overwrite
|
|
98
|
+
- `--force` still applies only to repo-managed outputs such as overwriting an existing managed profile; unmanaged differing skill directories require `--allow-unmanaged-skill-overwrite`;
|
|
99
|
+
- `sync`/`update` may adopt additional known jhste skills into an already managed skills directory and refresh them without the extra overwrite flag.
|
|
99
100
|
|
|
100
101
|
## `update`
|
|
101
102
|
|
|
@@ -144,7 +145,7 @@ The JSON output starts with:
|
|
|
144
145
|
"schema_version": 1,
|
|
145
146
|
"summary": { "error": 0, "warning": 0, "info": 0, "baseline_matched": 0, "suppressed": 0, "failures": 0 },
|
|
146
147
|
"meta": {
|
|
147
|
-
"tool_version": "0.1.
|
|
148
|
+
"tool_version": "0.1.1",
|
|
148
149
|
"scope": "changed",
|
|
149
150
|
"files_considered": 0,
|
|
150
151
|
"files_scanned": 0,
|
|
@@ -18,7 +18,7 @@ If `.jhste/profile.yaml` exists, default install keeps it. Overwrite requires `-
|
|
|
18
18
|
|
|
19
19
|
## Existing skills
|
|
20
20
|
|
|
21
|
-
Installed skill directories are tracked in `.jhste-skills-manifest.json` inside the skills directory. If a target skill directory already exists and differs, default install skips it; `--force` can refresh manifest-managed copies, but unmanaged differing directories are refused unless `--allow-unmanaged-skill-overwrite` is also explicit. The manifest stores skill digests, not absolute local paths.
|
|
21
|
+
Installed skill directories are tracked in `.jhste-skills-manifest.json` inside the skills directory. If a target skill directory already exists and differs, default install skips it; `--force` can refresh manifest-managed copies, but unmanaged differing directories are refused unless `--allow-unmanaged-skill-overwrite` is also explicit. During `sync`/`update`, an already managed skills directory may adopt additional known jhste skills into the manifest and refresh them without the extra overwrite flag. The manifest stores skill digests, not absolute local paths.
|
|
22
22
|
|
|
23
23
|
## Bridge block
|
|
24
24
|
|
|
@@ -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/package.json
CHANGED
|
@@ -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 !==
|
|
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 !==
|
|
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
|
}
|
|
@@ -3,6 +3,7 @@ import path from 'node:path';
|
|
|
3
3
|
import {
|
|
4
4
|
fail,
|
|
5
5
|
hashFile,
|
|
6
|
+
packageVersion,
|
|
6
7
|
parseJsonOutput,
|
|
7
8
|
run,
|
|
8
9
|
runAny,
|
|
@@ -105,10 +106,11 @@ function assertDeepScanReport(report) {
|
|
|
105
106
|
|
|
106
107
|
function runGuardContracts(ctx) {
|
|
107
108
|
const { root, repo, report, tmp } = ctx;
|
|
109
|
+
const version = packageVersion(root);
|
|
108
110
|
const guardJson = run(process.execPath, [path.join(root, 'cli/guard.mjs'), '--repo', repo, '--scope', 'all', '--format', 'json', '--fail-on', 'none'], { cwd: repo }).stdout;
|
|
109
111
|
const guardResult = parseJsonOutput(guardJson, 'guard result');
|
|
110
112
|
if (guardResult.schema_version !== 1) fail('guard JSON schema_version missing');
|
|
111
|
-
if (guardResult.meta?.tool_version !==
|
|
113
|
+
if (guardResult.meta?.tool_version !== version) fail('guard JSON meta tool_version missing');
|
|
112
114
|
if (typeof guardResult.meta?.files_considered !== 'number') fail('guard JSON meta files_considered missing');
|
|
113
115
|
for (const [ruleId, message] of [
|
|
114
116
|
['silent.catch.empty', 'guard did not report empty catch'],
|
|
@@ -154,6 +156,7 @@ function assertGuardFailureModes({ root, repo, tmp }) {
|
|
|
154
156
|
}
|
|
155
157
|
|
|
156
158
|
function runProfileCommandAndHookContracts({ root, repo, profilePath, packageHashBefore }) {
|
|
159
|
+
const version = packageVersion(root);
|
|
157
160
|
const fakeOpenAiKey = 'sk-' + 'A'.repeat(24);
|
|
158
161
|
const fakeGithubToken = 'gh' + 'p_' + 'B'.repeat(36);
|
|
159
162
|
const fakeGenericSecret = 'C'.repeat(16);
|
|
@@ -191,7 +194,7 @@ function runProfileCommandAndHookContracts({ root, repo, profilePath, packageHas
|
|
|
191
194
|
const preCommit = path.join(repo, '.git', 'hooks', 'pre-commit');
|
|
192
195
|
const preCommitText = fs.readFileSync(preCommit, 'utf8');
|
|
193
196
|
if (!preCommitText.includes('jhste-skills managed hook start')) fail('managed pre-commit hook missing marker');
|
|
194
|
-
if (!preCommitText.includes(
|
|
197
|
+
if (!preCommitText.includes(`# jhste-skills version=${version}`)) fail('managed pre-commit hook missing version comment');
|
|
195
198
|
if (preCommitText.indexOf("node '") > preCommitText.indexOf('command -v jhste-skills')) fail('managed hook should prefer local CLI before global fallback');
|
|
196
199
|
const fakeBin = path.join(path.dirname(preCommit), 'fake-bin');
|
|
197
200
|
fs.mkdirSync(fakeBin);
|
|
@@ -36,6 +36,10 @@ export function hashFile(file) {
|
|
|
36
36
|
return fs.existsSync(file) ? crypto.createHash('sha256').update(fs.readFileSync(file)).digest('hex') : null;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
export function packageVersion(root) {
|
|
40
|
+
return JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8')).version;
|
|
41
|
+
}
|
|
42
|
+
|
|
39
43
|
export function skillDirs(dir) {
|
|
40
44
|
return fs.readdirSync(dir, { withFileTypes: true })
|
|
41
45
|
.filter((entry) => entry.isDirectory())
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
assertNoInstallSideEffects,
|
|
5
5
|
fail,
|
|
6
6
|
hashFile,
|
|
7
|
+
packageVersion,
|
|
7
8
|
run,
|
|
8
9
|
runAny,
|
|
9
10
|
skillDirs,
|
|
@@ -27,6 +28,15 @@ function initRepo(repo) {
|
|
|
27
28
|
run('git', ['init'], { cwd: repo });
|
|
28
29
|
}
|
|
29
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
|
+
|
|
30
40
|
function runRefusalScenarios({ root, tmp }) {
|
|
31
41
|
const nonInteractiveRepo = path.join(tmp, 'noninteractive-repo');
|
|
32
42
|
const nonInteractiveSkills = path.join(tmp, 'noninteractive-skills');
|
|
@@ -77,6 +87,7 @@ function runRefusalScenarios({ root, tmp }) {
|
|
|
77
87
|
|
|
78
88
|
function runDefaultInstall(ctx) {
|
|
79
89
|
const { root, repo, skillsDir } = ctx;
|
|
90
|
+
const version = packageVersion(root);
|
|
80
91
|
ctx.packageHashBefore = hashFile(path.join(repo, 'package.json'));
|
|
81
92
|
ctx.lockHashBefore = hashFile(path.join(repo, 'package-lock.json'));
|
|
82
93
|
const started = Date.now();
|
|
@@ -98,23 +109,29 @@ function runDefaultInstall(ctx) {
|
|
|
98
109
|
const defaultPreCommit = path.join(repo, '.git', 'hooks', 'pre-commit');
|
|
99
110
|
if (!fs.existsSync(defaultPreCommit)) fail('install did not create default advisory pre-commit hook');
|
|
100
111
|
if (!fs.readFileSync(defaultPreCommit, 'utf8').includes('mode=advisory')) fail('default pre-commit hook is not advisory');
|
|
101
|
-
if (!fs.readFileSync(defaultPreCommit, 'utf8').includes(
|
|
112
|
+
if (!fs.readFileSync(defaultPreCommit, 'utf8').includes(`# jhste-skills version=${version}`)) fail('default pre-commit hook missing version comment');
|
|
102
113
|
if (!fs.existsSync(path.join(skillsDir, 'jhste-red-team-review', 'SKILL.md'))) fail('install did not copy jhste-red-team-review skill');
|
|
103
114
|
if (!fs.existsSync(path.join(skillsDir, '.jhste-skills-manifest.json'))) fail('install did not write skills manifest');
|
|
104
|
-
const manifest =
|
|
115
|
+
const manifest = readManagedSkillsManifest(skillsDir);
|
|
105
116
|
if (manifest.managed_by !== 'jhste-skills' || !manifest.skills?.['jhste-red-team-review']?.digest) fail('skills manifest missing managed skill digest');
|
|
106
117
|
const defaultSkillDirs = skillDirs(skillsDir);
|
|
107
|
-
if (defaultSkillDirs.length !==
|
|
118
|
+
if (defaultSkillDirs.length !== 20) fail(`default install should copy 20 bundled skills, got ${defaultSkillDirs.length}`);
|
|
108
119
|
if (!defaultSkillDirs.includes('improve-codebase-architecture')) fail('default install should copy vendored workflow skills');
|
|
109
120
|
}
|
|
110
121
|
|
|
111
122
|
function runUpdateScenarios({ root, repo, skillsDir }) {
|
|
123
|
+
const version = packageVersion(root);
|
|
112
124
|
const skillPath = path.join(skillsDir, 'jhste-code-quality', 'SKILL.md');
|
|
113
125
|
const sourceSkillPath = path.join(root, 'skills', 'jhste-code-quality', 'SKILL.md');
|
|
126
|
+
const adoptedSkillName = 'triage';
|
|
127
|
+
const adoptedSkillPath = path.join(skillsDir, adoptedSkillName, 'SKILL.md');
|
|
128
|
+
const adoptedSourceSkillPath = path.join(root, 'skills', adoptedSkillName, 'SKILL.md');
|
|
114
129
|
const agentsPath = path.join(repo, 'AGENTS.md');
|
|
115
130
|
const preCommitPath = path.join(repo, '.git', 'hooks', 'pre-commit');
|
|
116
131
|
|
|
117
132
|
fs.writeFileSync(skillPath, '# stale local copy\n');
|
|
133
|
+
fs.mkdirSync(path.dirname(adoptedSkillPath), { recursive: true });
|
|
134
|
+
fs.writeFileSync(adoptedSkillPath, '# unmanaged but known skill copy\n');
|
|
118
135
|
|
|
119
136
|
const existingAgents = fs.readFileSync(agentsPath, 'utf8');
|
|
120
137
|
const staleAgents = existingAgents.replace(
|
|
@@ -136,6 +153,9 @@ run_jhste_skills guard --scope staged --format text --fail-on warning
|
|
|
136
153
|
if (fs.readFileSync(skillPath, 'utf8') !== fs.readFileSync(sourceSkillPath, 'utf8')) {
|
|
137
154
|
fail('update did not refresh an installed skill back to the current source version');
|
|
138
155
|
}
|
|
156
|
+
if (fs.readFileSync(adoptedSkillPath, 'utf8') !== fs.readFileSync(adoptedSourceSkillPath, 'utf8')) {
|
|
157
|
+
fail('update did not adopt and refresh a known jhste skill into an existing managed installation');
|
|
158
|
+
}
|
|
139
159
|
|
|
140
160
|
const updatedAgents = fs.readFileSync(agentsPath, 'utf8');
|
|
141
161
|
if (updatedAgents.includes('Old bridge text that should be replaced.')) {
|
|
@@ -148,9 +168,31 @@ run_jhste_skills guard --scope staged --format text --fail-on warning
|
|
|
148
168
|
const updatedPreCommit = fs.readFileSync(preCommitPath, 'utf8');
|
|
149
169
|
if (!updatedPreCommit.includes('mode=blocking')) fail('update did not preserve managed hook mode');
|
|
150
170
|
if (!updatedPreCommit.includes('--fail-on warning')) fail('update did not preserve managed hook fail-on behavior');
|
|
151
|
-
if (!updatedPreCommit.includes(
|
|
171
|
+
if (!updatedPreCommit.includes(`# jhste-skills version=${version}`)) fail('update did not refresh hook version comment');
|
|
152
172
|
if (updatedPreCommit.includes('stale hook')) fail('update did not replace stale managed hook content');
|
|
153
173
|
|
|
174
|
+
const managedManifest = readManagedSkillsManifest(skillsDir);
|
|
175
|
+
if (!managedManifest.skills?.[adoptedSkillName]?.digest) fail('update did not record adopted known skill in manifest');
|
|
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
|
+
|
|
154
196
|
const unmanagedSkills = path.join(path.dirname(skillsDir), 'unmanaged-skills');
|
|
155
197
|
fs.mkdirSync(path.join(unmanagedSkills, 'jhste-code-quality'), { recursive: true });
|
|
156
198
|
fs.writeFileSync(path.join(unmanagedSkills, 'jhste-code-quality', 'SKILL.md'), '# unmanaged local copy\n');
|
|
@@ -204,7 +246,7 @@ function runSkillSetScenarios({ root, tmp }) {
|
|
|
204
246
|
fs.writeFileSync(path.join(vendorRepo, 'AGENTS.md'), '# Vendor skill repo\n');
|
|
205
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 });
|
|
206
248
|
const vendorSkillDirs = skillDirs(vendorSkillsDir);
|
|
207
|
-
if (vendorSkillDirs.length !==
|
|
249
|
+
if (vendorSkillDirs.length !== 13) fail(`--skill-set vendor should copy 13 skills, got ${vendorSkillDirs.length}`);
|
|
208
250
|
if (!vendorSkillDirs.includes('improve-codebase-architecture')) fail('--skill-set vendor did not copy expected vendored skill');
|
|
209
251
|
if (vendorSkillDirs.includes('jhste-red-team-review')) fail('--skill-set vendor copied core skill');
|
|
210
252
|
|
|
@@ -214,7 +256,7 @@ function runSkillSetScenarios({ root, tmp }) {
|
|
|
214
256
|
fs.writeFileSync(path.join(allRepo, 'AGENTS.md'), '# All skill repo\n');
|
|
215
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 });
|
|
216
258
|
const allSkillDirs = skillDirs(allSkillsDir);
|
|
217
|
-
if (allSkillDirs.length !==
|
|
259
|
+
if (allSkillDirs.length !== 20) fail(`--skill-set all should copy 20 skills, got ${allSkillDirs.length}`);
|
|
218
260
|
if (!allSkillDirs.includes('jhste-red-team-review') || !allSkillDirs.includes('improve-codebase-architecture')) fail('--skill-set all missing core or vendored skill');
|
|
219
261
|
}
|
|
220
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 !==
|
|
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');
|
package/scripts/vendor-check.mjs
CHANGED
|
@@ -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
|
|
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
|
|
46
|
+
fail('source-lock must contain exactly 13 skills');
|
|
48
47
|
}
|
|
49
48
|
|
|
50
49
|
const seen = new Set();
|
|
@@ -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",
|
package/skills/diagnose/SKILL.md
DELETED
|
@@ -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"
|