@gobing-ai/superskill 0.2.5 → 0.2.6
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/dist/index.js +278 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -40829,7 +40829,7 @@ var init_dist5 = __esm(() => {
|
|
|
40829
40829
|
});
|
|
40830
40830
|
|
|
40831
40831
|
// ../../packages/core/src/targets.ts
|
|
40832
|
-
var TARGETS, TARGET_TO_RULESYNC, TARGET_SKILLS_RELDIR, TARGET_TO_AGENT_NAME;
|
|
40832
|
+
var TARGETS, TARGET_TO_RULESYNC, TARGET_TO_RULESYNC_HOOKS, TARGET_SKILLS_RELDIR, TARGET_TO_AGENT_NAME;
|
|
40833
40833
|
var init_targets = __esm(() => {
|
|
40834
40834
|
TARGETS = [
|
|
40835
40835
|
"claude",
|
|
@@ -40848,6 +40848,12 @@ var init_targets = __esm(() => {
|
|
|
40848
40848
|
"antigravity-cli": "codexcli",
|
|
40849
40849
|
"antigravity-ide": "codexcli"
|
|
40850
40850
|
};
|
|
40851
|
+
TARGET_TO_RULESYNC_HOOKS = {
|
|
40852
|
+
codex: "codexcli",
|
|
40853
|
+
opencode: "opencode",
|
|
40854
|
+
"antigravity-cli": "antigravity-cli",
|
|
40855
|
+
"antigravity-ide": "antigravity-ide"
|
|
40856
|
+
};
|
|
40851
40857
|
TARGET_SKILLS_RELDIR = {
|
|
40852
40858
|
codex: ".agents/skills",
|
|
40853
40859
|
pi: ".agents/skills",
|
|
@@ -89666,9 +89672,10 @@ var init_dist9 = __esm(() => {
|
|
|
89666
89672
|
// ../../packages/core/src/rulesync.ts
|
|
89667
89673
|
import { homedir as homedir5 } from "os";
|
|
89668
89674
|
async function runRulesync(targets, features, inputRoot, options2) {
|
|
89675
|
+
const targetMap = options2.targetMap ?? TARGET_TO_RULESYNC;
|
|
89669
89676
|
const mappedTargets = [];
|
|
89670
89677
|
for (const target of targets) {
|
|
89671
|
-
const rt =
|
|
89678
|
+
const rt = targetMap[target];
|
|
89672
89679
|
if (rt)
|
|
89673
89680
|
mappedTargets.push(rt);
|
|
89674
89681
|
}
|
|
@@ -97508,6 +97515,259 @@ init_dist();
|
|
|
97508
97515
|
import { homedir as homedir7 } from "os";
|
|
97509
97516
|
import { join as join225 } from "path";
|
|
97510
97517
|
|
|
97518
|
+
// src/commands/hook-run.ts
|
|
97519
|
+
init_dist();
|
|
97520
|
+
import { spawnSync as spawnSync2 } from "child_process";
|
|
97521
|
+
|
|
97522
|
+
// ../../plugins/cc/scripts/anti-hallucination/ah_guard.ts
|
|
97523
|
+
var SOURCE_PATTERNS = [
|
|
97524
|
+
/\[Source:\s*[^\]]+\]/i,
|
|
97525
|
+
/Source:\s*\[?[^\n]+\]?/i,
|
|
97526
|
+
/Sources:\s*\n\s*-\s*\[?[^\n]+\]/i,
|
|
97527
|
+
/https?:\/\/[^\s)]+/i,
|
|
97528
|
+
/\*\*Source\*\*:\s*[^\n]+/i
|
|
97529
|
+
];
|
|
97530
|
+
var CONFIDENCE_PATTERNS = [
|
|
97531
|
+
/Confidence:\s*(HIGH|MEDIUM|LOW)/i,
|
|
97532
|
+
/\*\*Confidence\*\*:\s*(HIGH|MEDIUM|LOW)/i,
|
|
97533
|
+
/### Confidence/i
|
|
97534
|
+
];
|
|
97535
|
+
var TOOL_PATTERNS = [
|
|
97536
|
+
/ref_search_documentation/,
|
|
97537
|
+
/ref_read_url/,
|
|
97538
|
+
/searchCode/,
|
|
97539
|
+
/WebSearch/,
|
|
97540
|
+
/WebFetch/,
|
|
97541
|
+
/mcp__ref__ref_search_documentation/,
|
|
97542
|
+
/mcp__ref__ref_read_url/,
|
|
97543
|
+
/mcp__grep__searchCode/
|
|
97544
|
+
];
|
|
97545
|
+
var RED_FLAG_PATTERNS = [
|
|
97546
|
+
/I (?:think|believe|recall) (?:that|the)?/gi,
|
|
97547
|
+
/(?:It|This) (?:should|might|may|could)/gi,
|
|
97548
|
+
/Probably|Likely|Possibly/gi,
|
|
97549
|
+
/(?:As far as|If I) (?:know|recall)/gi
|
|
97550
|
+
];
|
|
97551
|
+
function extractLastAssistantMessage(context3) {
|
|
97552
|
+
const messages2 = context3.messages ?? [];
|
|
97553
|
+
for (let i2 = messages2.length - 1;i2 >= 0; i2--) {
|
|
97554
|
+
const message = messages2[i2];
|
|
97555
|
+
if (message?.role === "assistant") {
|
|
97556
|
+
const content = message.content;
|
|
97557
|
+
if (Array.isArray(content)) {
|
|
97558
|
+
const textParts = [];
|
|
97559
|
+
for (const part of content) {
|
|
97560
|
+
if (part.type === "text" && part.text) {
|
|
97561
|
+
textParts.push(part.text);
|
|
97562
|
+
}
|
|
97563
|
+
}
|
|
97564
|
+
return textParts.join(`
|
|
97565
|
+
`);
|
|
97566
|
+
}
|
|
97567
|
+
return String(content);
|
|
97568
|
+
}
|
|
97569
|
+
}
|
|
97570
|
+
const lastMsg = context3.last_message;
|
|
97571
|
+
if (lastMsg) {
|
|
97572
|
+
return String(lastMsg);
|
|
97573
|
+
}
|
|
97574
|
+
return;
|
|
97575
|
+
}
|
|
97576
|
+
function hasSourceCitations(text3) {
|
|
97577
|
+
if (!text3)
|
|
97578
|
+
return false;
|
|
97579
|
+
for (const pattern of SOURCE_PATTERNS) {
|
|
97580
|
+
if (pattern.test(text3)) {
|
|
97581
|
+
return true;
|
|
97582
|
+
}
|
|
97583
|
+
}
|
|
97584
|
+
return false;
|
|
97585
|
+
}
|
|
97586
|
+
function hasConfidenceLevel(text3) {
|
|
97587
|
+
if (!text3)
|
|
97588
|
+
return false;
|
|
97589
|
+
for (const pattern of CONFIDENCE_PATTERNS) {
|
|
97590
|
+
if (pattern.test(text3)) {
|
|
97591
|
+
return true;
|
|
97592
|
+
}
|
|
97593
|
+
}
|
|
97594
|
+
return false;
|
|
97595
|
+
}
|
|
97596
|
+
function hasToolUsageEvidence(text3) {
|
|
97597
|
+
if (!text3)
|
|
97598
|
+
return false;
|
|
97599
|
+
for (const pattern of TOOL_PATTERNS) {
|
|
97600
|
+
if (pattern.test(text3)) {
|
|
97601
|
+
return true;
|
|
97602
|
+
}
|
|
97603
|
+
}
|
|
97604
|
+
return false;
|
|
97605
|
+
}
|
|
97606
|
+
function hasRedFlags(text3) {
|
|
97607
|
+
if (!text3)
|
|
97608
|
+
return [];
|
|
97609
|
+
const foundFlags = [];
|
|
97610
|
+
for (const pattern of RED_FLAG_PATTERNS) {
|
|
97611
|
+
const matches = text3.match(pattern);
|
|
97612
|
+
if (matches) {
|
|
97613
|
+
foundFlags.push(...matches);
|
|
97614
|
+
}
|
|
97615
|
+
}
|
|
97616
|
+
return foundFlags;
|
|
97617
|
+
}
|
|
97618
|
+
function requiresExternalVerification(text3) {
|
|
97619
|
+
if (!text3)
|
|
97620
|
+
return false;
|
|
97621
|
+
const verificationKeywords = [
|
|
97622
|
+
"api",
|
|
97623
|
+
"library",
|
|
97624
|
+
"framework",
|
|
97625
|
+
"method",
|
|
97626
|
+
"function",
|
|
97627
|
+
"version",
|
|
97628
|
+
"documentation",
|
|
97629
|
+
"official",
|
|
97630
|
+
/recent\s+(?:change|update|release)/i,
|
|
97631
|
+
/\d+\.\d+(?:\.\d+)?/,
|
|
97632
|
+
/https?:\/\//
|
|
97633
|
+
];
|
|
97634
|
+
const textLower = text3.toLowerCase();
|
|
97635
|
+
for (const keyword of verificationKeywords) {
|
|
97636
|
+
if (typeof keyword === "string") {
|
|
97637
|
+
if (textLower.includes(keyword)) {
|
|
97638
|
+
return true;
|
|
97639
|
+
}
|
|
97640
|
+
} else if (keyword.test(textLower)) {
|
|
97641
|
+
return true;
|
|
97642
|
+
}
|
|
97643
|
+
}
|
|
97644
|
+
return false;
|
|
97645
|
+
}
|
|
97646
|
+
function verifyAntiHallucinationProtocol(text3) {
|
|
97647
|
+
if (!text3 || text3.trim().length < 50) {
|
|
97648
|
+
return { ok: true, reason: "Task is complete" };
|
|
97649
|
+
}
|
|
97650
|
+
const needsVerification = requiresExternalVerification(text3);
|
|
97651
|
+
if (!needsVerification) {
|
|
97652
|
+
return { ok: true, reason: "Task is complete (internal discussion)" };
|
|
97653
|
+
}
|
|
97654
|
+
const hasSources = hasSourceCitations(text3);
|
|
97655
|
+
const hasConfidence = hasConfidenceLevel(text3);
|
|
97656
|
+
const hasTools = hasToolUsageEvidence(text3);
|
|
97657
|
+
const redFlags = hasRedFlags(text3);
|
|
97658
|
+
const issues = [];
|
|
97659
|
+
if (!hasSources) {
|
|
97660
|
+
issues.push("source citations for API/library claims");
|
|
97661
|
+
}
|
|
97662
|
+
if (!hasConfidence) {
|
|
97663
|
+
issues.push("confidence level (HIGH/MEDIUM/LOW)");
|
|
97664
|
+
}
|
|
97665
|
+
if (redFlags.length > 0 && !hasTools) {
|
|
97666
|
+
const uniqueFlags = Array.from(new Set(redFlags)).slice(0, 3);
|
|
97667
|
+
issues.push(`uncertainty phrases detected: ${uniqueFlags.join(", ")}`);
|
|
97668
|
+
}
|
|
97669
|
+
if (issues.length > 0) {
|
|
97670
|
+
const reason = `Add verification for: ${issues.join(", ")}`;
|
|
97671
|
+
return { ok: false, reason, issues };
|
|
97672
|
+
}
|
|
97673
|
+
return { ok: true, reason: "Task is complete" };
|
|
97674
|
+
}
|
|
97675
|
+
if (false) {}
|
|
97676
|
+
|
|
97677
|
+
// src/commands/hook-run.ts
|
|
97678
|
+
function preToolUseDecision(decision, reason) {
|
|
97679
|
+
const out = {
|
|
97680
|
+
hookSpecificOutput: { hookEventName: "PreToolUse", permissionDecision: decision }
|
|
97681
|
+
};
|
|
97682
|
+
if (reason !== undefined)
|
|
97683
|
+
out.systemMessage = reason;
|
|
97684
|
+
return { output: JSON.stringify(out), exitCode: 0 };
|
|
97685
|
+
}
|
|
97686
|
+
function resolveSpurTaskOwnership(filePath, cwd5) {
|
|
97687
|
+
const res = spawnSync2("spur", ["task", "resolve", filePath, "--strict", "--json"], {
|
|
97688
|
+
cwd: cwd5,
|
|
97689
|
+
encoding: "utf-8",
|
|
97690
|
+
timeout: 8000
|
|
97691
|
+
});
|
|
97692
|
+
if (res.error || typeof res.status !== "number")
|
|
97693
|
+
return "unknown";
|
|
97694
|
+
return res.status === 0 ? "owned" : "unowned";
|
|
97695
|
+
}
|
|
97696
|
+
function runSpTaskWriteGuard(env, stdinText, resolveTaskOwnership = resolveSpurTaskOwnership) {
|
|
97697
|
+
if (env.SPUR_WRITE_GUARD === "off")
|
|
97698
|
+
return preToolUseDecision("allow");
|
|
97699
|
+
let payload;
|
|
97700
|
+
try {
|
|
97701
|
+
payload = JSON.parse(stdinText);
|
|
97702
|
+
} catch {
|
|
97703
|
+
return preToolUseDecision("allow");
|
|
97704
|
+
}
|
|
97705
|
+
const toolName = payload.tool_name ?? "";
|
|
97706
|
+
if (toolName !== "Write" && toolName !== "Edit")
|
|
97707
|
+
return preToolUseDecision("allow");
|
|
97708
|
+
const filePath = payload.tool_input?.file_path ?? "";
|
|
97709
|
+
if (filePath === "")
|
|
97710
|
+
return preToolUseDecision("allow");
|
|
97711
|
+
const ownership = resolveTaskOwnership(filePath, env.CLAUDE_PROJECT_DIR ?? process.cwd());
|
|
97712
|
+
if (ownership === "owned") {
|
|
97713
|
+
return preToolUseDecision("deny", `${filePath} is a task file owned by the spur corpus. Edit it through the spur CLI ` + "(e.g. `spur task update <wbs> --section <name> --from-file <file>`), not a raw " + "Write/Edit. Set SPUR_WRITE_GUARD=off to bypass.");
|
|
97714
|
+
}
|
|
97715
|
+
return preToolUseDecision("allow");
|
|
97716
|
+
}
|
|
97717
|
+
var spTaskWriteGuard = {
|
|
97718
|
+
run: runSpTaskWriteGuard
|
|
97719
|
+
};
|
|
97720
|
+
var ccAntiHallucination = {
|
|
97721
|
+
run(env) {
|
|
97722
|
+
const argumentsJson = env.ARGUMENTS ?? "{}";
|
|
97723
|
+
const allowStop = (feedback, ok) => ({
|
|
97724
|
+
output: JSON.stringify({ hookSpecificOutput: { allowStop: ok, feedback } }),
|
|
97725
|
+
exitCode: ok ? 0 : 1
|
|
97726
|
+
});
|
|
97727
|
+
let context3;
|
|
97728
|
+
try {
|
|
97729
|
+
context3 = JSON.parse(argumentsJson);
|
|
97730
|
+
} catch {
|
|
97731
|
+
return allowStop("Task is complete (invalid context ignored)", true);
|
|
97732
|
+
}
|
|
97733
|
+
const content = extractLastAssistantMessage(context3);
|
|
97734
|
+
if (content === undefined)
|
|
97735
|
+
return allowStop("No content to verify", true);
|
|
97736
|
+
const result = verifyAntiHallucinationProtocol(content);
|
|
97737
|
+
return allowStop(result.reason, result.ok);
|
|
97738
|
+
}
|
|
97739
|
+
};
|
|
97740
|
+
var HOOK_RUNNERS = {
|
|
97741
|
+
"sp/task-write-guard": spTaskWriteGuard,
|
|
97742
|
+
"cc/anti-hallucination": ccAntiHallucination
|
|
97743
|
+
};
|
|
97744
|
+
function hookRun(plugin, hookId, env, stdinText) {
|
|
97745
|
+
const runner = HOOK_RUNNERS[`${plugin}/${hookId}`];
|
|
97746
|
+
if (!runner) {
|
|
97747
|
+
echoError(`Error: unknown hook '${plugin} ${hookId}'. Known hooks: ${Object.keys(HOOK_RUNNERS).join(", ")}`);
|
|
97748
|
+
return 2;
|
|
97749
|
+
}
|
|
97750
|
+
const result = runner.run(env, stdinText);
|
|
97751
|
+
echo(result.output);
|
|
97752
|
+
return result.exitCode;
|
|
97753
|
+
}
|
|
97754
|
+
function registerHookRun(cmd, readInput) {
|
|
97755
|
+
cmd.command("run <plugin> <hook-id>").description("Run a registered plugin hook runner (the runtime command installed hook configs call)").action((plugin, hookId) => {
|
|
97756
|
+
let stdinText = "";
|
|
97757
|
+
if (readInput) {
|
|
97758
|
+
stdinText = readInput();
|
|
97759
|
+
} else {
|
|
97760
|
+
try {
|
|
97761
|
+
stdinText = __require("fs").readFileSync(0, "utf-8");
|
|
97762
|
+
} catch {
|
|
97763
|
+
stdinText = "";
|
|
97764
|
+
}
|
|
97765
|
+
}
|
|
97766
|
+
const code = hookRun(plugin, hookId, process.env, stdinText);
|
|
97767
|
+
process.exit(code);
|
|
97768
|
+
});
|
|
97769
|
+
}
|
|
97770
|
+
|
|
97511
97771
|
// src/commands/install.ts
|
|
97512
97772
|
init_src();
|
|
97513
97773
|
init_dist();
|
|
@@ -97687,7 +97947,7 @@ async function executeInstall(plugin, targets2, options2, dependencies = {}) {
|
|
|
97687
97947
|
const targetInputRoot = prepareTargetRulesyncInput(outputDir, target, plugin);
|
|
97688
97948
|
targetInputRoots.set(target, targetInputRoot);
|
|
97689
97949
|
}
|
|
97690
|
-
const rulesyncFeatures = ["skills",
|
|
97950
|
+
const rulesyncFeatures = ["skills", ...mapResult.mcp ? ["mcp"] : []];
|
|
97691
97951
|
const rulesyncTargets = targets2.filter((t) => t !== "claude" && t !== "hermes" && t !== "omp");
|
|
97692
97952
|
if (targets2.includes("omp") && !targets2.includes("pi")) {
|
|
97693
97953
|
if (!targetInputRoots.has("pi")) {
|
|
@@ -97726,6 +97986,20 @@ async function executeInstall(plugin, targets2, options2, dependencies = {}) {
|
|
|
97726
97986
|
resultCounts.subagentsCount += result.subagentsCount;
|
|
97727
97987
|
resultCounts.hooksCount += result.hooksCount;
|
|
97728
97988
|
}
|
|
97989
|
+
if (mapResult.hooks) {
|
|
97990
|
+
for (const target of rulesyncTargets) {
|
|
97991
|
+
if (!TARGET_TO_RULESYNC_HOOKS[target])
|
|
97992
|
+
continue;
|
|
97993
|
+
const hookResult = await runRulesyncImpl([target], ["hooks"], targetInputRoots.get(target) ?? outputDir, {
|
|
97994
|
+
global: options2.global,
|
|
97995
|
+
dryRun: options2.dryRun,
|
|
97996
|
+
verbose: options2.verbose,
|
|
97997
|
+
outputRoot: options2.outputRoot,
|
|
97998
|
+
targetMap: TARGET_TO_RULESYNC_HOOKS
|
|
97999
|
+
});
|
|
98000
|
+
resultCounts.hooksCount += hookResult.hooksCount;
|
|
98001
|
+
}
|
|
98002
|
+
}
|
|
97729
98003
|
if (options2.verbose) {
|
|
97730
98004
|
echo(` Skills written: ${resultCounts.skillsCount}, Commands: ${resultCounts.commandsCount}, Subagents: ${resultCounts.subagentsCount}, Hooks: ${resultCounts.hooksCount}`);
|
|
97731
98005
|
}
|
|
@@ -98005,6 +98279,7 @@ function registerHook(program2) {
|
|
|
98005
98279
|
addTargetOption(cmd.command("emit <name>").description("Emit a hook definition to a single target agent (thin wrapper over the install hook path)")).option("--global", "Install to user-level global directory (default)", true).option("--dry-run", "Preview without writing files", false).action(async (name, opts) => {
|
|
98006
98280
|
await runOperation(() => hookEmit({ name, ...opts }));
|
|
98007
98281
|
});
|
|
98282
|
+
registerHookRun(cmd);
|
|
98008
98283
|
}
|
|
98009
98284
|
|
|
98010
98285
|
// src/commands/magent.ts
|