@marcomigozzi/trailhead 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.it.md +28 -3
- package/README.md +38 -3
- package/bin/lib/codex-projection.js +16 -9
- package/bin/lib/codex-projection.test.js +39 -11
- package/bin/lib/install-verify.js +10 -5
- package/bin/lib/install-verify.test.js +51 -0
- package/bin/trailhead.js +37 -25
- package/bin/trailhead.test.js +162 -5
- package/package.json +4 -1
- package/plugins/trailhead/.claude-plugin/plugin.json +3 -2
- package/plugins/trailhead/commands/panel.md +10 -0
- package/plugins/trailhead/hooks/hooks.json +3 -18
- package/plugins/trailhead/hooks/lib/body-sources.js +795 -0
- package/plugins/trailhead/hooks/lib/gh-subcommand.js +92 -10
- package/plugins/trailhead/hooks/lib/gh-subcommand.test.js +55 -0
- package/plugins/trailhead/hooks/lib/mockup-link.js +21 -5
- package/plugins/trailhead/hooks/lib/shell-scan.js +496 -64
- package/plugins/trailhead/hooks/lib/shell-scan.test.js +420 -0
- package/plugins/trailhead/hooks/lib/unmodelled.js +345 -0
- package/plugins/trailhead/hooks/lib/unmodelled.test.js +173 -0
- package/plugins/trailhead/hooks/lib/work-state.test.js +252 -0
- package/plugins/trailhead/hooks/mod/README.md +187 -0
- package/plugins/trailhead/hooks/mod/map-pane-view.ts +453 -0
- package/plugins/trailhead/hooks/mod/map-pane.tsx +663 -0
- package/plugins/trailhead/hooks/mod/register.tsx +280 -0
- package/plugins/trailhead/hooks/mod/work-state-prompt.ts +69 -0
- package/plugins/trailhead/hooks/mod/work-state-view.ts +93 -0
- package/plugins/trailhead/hooks/trailhead-bash-guards.js +140 -0
- package/plugins/trailhead/hooks/trailhead-bash-guards.test.js +233 -0
- package/plugins/trailhead/hooks/trailhead-body-guard.js +145 -61
- package/plugins/trailhead/hooks/trailhead-body-guard.test.js +224 -3
- package/plugins/trailhead/hooks/trailhead-commit-guard.js +41 -14
- package/plugins/trailhead/hooks/trailhead-commit-guard.test.js +2 -1
- package/plugins/trailhead/hooks/trailhead-install-guard.js +22 -12
- package/plugins/trailhead/hooks/trailhead-install-guard.test.js +2 -1
- package/plugins/trailhead/hooks/trailhead-mockup-link-guard.js +48 -11
- package/plugins/trailhead/hooks/trailhead-mockup-link-guard.test.js +75 -3
- package/plugins/trailhead/hooks/trailhead-search-guard.js +19 -9
- package/plugins/trailhead/hooks/trailhead-search-guard.test.js +2 -1
- package/plugins/trailhead/hooks/trailhead-secret-guard.js +541 -57
- package/plugins/trailhead/hooks/trailhead-secret-guard.test.js +1000 -4
- package/plugins/trailhead/hooks/trailhead-secret-read-guard.js +171 -6
- package/plugins/trailhead/hooks/trailhead-secret-read-guard.test.js +170 -0
- package/plugins/trailhead/skills/_shared/choices.md +3 -1
- package/plugins/trailhead/skills/_shared/multi-map.md +1 -1
- package/plugins/trailhead/skills/_shared/session-handoff.md +1 -1
- package/plugins/trailhead/skills/_shared/teamwork.md +4 -2
- package/plugins/trailhead/skills/_shared/techniques/prototype.md +1 -1
- package/plugins/trailhead/skills/trailhead/SKILL.md +2 -2
- package/plugins/trailhead/skills/trailhead-work/SKILL.md +3 -2
- package/plugins/trailhead/skills/trailhead-work/references/auto.md +2 -0
- package/plugins/trailhead/skills/trailhead-work/references/ticket-engines.md +3 -1
- package/plugins/trailhead/templates/trailhead-work-state.js +199 -0
- package/plugins/trailhead/tests/map-pane-ui.test.ts +1374 -0
- package/plugins/trailhead/tests/map-pane-view.test.ts +565 -0
- package/plugins/trailhead/tests/mod.test.ts +14 -0
- package/plugins/trailhead/tests/work-state-prompt-hook.test.ts +207 -0
- package/plugins/trailhead/tests/work-state-prompt.test.ts +109 -0
- package/plugins/trailhead/tests/work-state-ui.test.ts +365 -0
- package/plugins/trailhead/tests/work-state-view.test.ts +86 -0
- package/plugins/trailhead/types/index.d.ts +69 -0
|
@@ -239,15 +239,26 @@ function detectSearchHygieneViolation(cmd) {
|
|
|
239
239
|
return null;
|
|
240
240
|
}
|
|
241
241
|
|
|
242
|
-
function
|
|
242
|
+
function blockVerdict(hit) {
|
|
243
243
|
const reason =
|
|
244
244
|
"trailhead search-hygiene: a 'cd <dir>' (or pushd/env -C) followed by a relative " +
|
|
245
245
|
`${hit.verb} read (\`${hit.file}\`) makes the read target non-static, which trips the ` +
|
|
246
246
|
'Read() deny rule under bypass permissions (prompting for manual approval instead of ' +
|
|
247
247
|
'running headless). Pass explicit paths instead and never cd first: ' +
|
|
248
248
|
'grep -niE "<patterns>" <abs>/<file>, git -C <abs> ..., or use the Grep/Read tools.';
|
|
249
|
-
|
|
250
|
-
|
|
249
|
+
return { kind: 'block', payload: { decision: 'block', code: 'SEARCH_HYGIENE_VIOLATION', reason } };
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// Pure verdict for one command: {kind:'allow'} or {kind:'block', payload}. Never
|
|
253
|
+
// exits or writes; any internal error falls through to allow.
|
|
254
|
+
function evaluate(cmd) {
|
|
255
|
+
try {
|
|
256
|
+
const hit = detectSearchHygieneViolation(cmd);
|
|
257
|
+
if (hit) return blockVerdict(hit);
|
|
258
|
+
} catch {
|
|
259
|
+
// fall through to allow: a guard must never wedge the workflow
|
|
260
|
+
}
|
|
261
|
+
return { kind: 'allow' };
|
|
251
262
|
}
|
|
252
263
|
|
|
253
264
|
function run(data) {
|
|
@@ -257,11 +268,10 @@ function run(data) {
|
|
|
257
268
|
} catch {
|
|
258
269
|
process.exit(0); // unparseable input: nothing to gate
|
|
259
270
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
// fall through to allow: a guard must never wedge the workflow
|
|
271
|
+
const v = evaluate(cmd);
|
|
272
|
+
if (v.kind === 'block') {
|
|
273
|
+
process.stdout.write(JSON.stringify(v.payload));
|
|
274
|
+
process.exit(2);
|
|
265
275
|
}
|
|
266
276
|
process.exit(0);
|
|
267
277
|
}
|
|
@@ -276,4 +286,4 @@ if (require.main === module) {
|
|
|
276
286
|
});
|
|
277
287
|
}
|
|
278
288
|
|
|
279
|
-
module.exports = { detectSearchHygieneViolation };
|
|
289
|
+
module.exports = { detectSearchHygieneViolation, evaluate };
|
|
@@ -5,7 +5,8 @@ const assert = require('assert');
|
|
|
5
5
|
const { execFileSync } = require('child_process');
|
|
6
6
|
const path = require('path');
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
// TRAILHEAD_GUARD_HOOK re-runs this suite through the merged trailhead-bash-guards.js.
|
|
9
|
+
const HOOK = process.env.TRAILHEAD_GUARD_HOOK || path.join(__dirname, 'trailhead-search-guard.js');
|
|
9
10
|
|
|
10
11
|
let passed = 0;
|
|
11
12
|
const ok = (name, cond) => { assert.ok(cond, name); passed++; };
|