rulesync 43.9.2 → 43.10.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.md +1 -1
- package/dist/cli/index.cjs +4 -4
- package/dist/cli/index.js +4 -4
- package/dist/cli/index.js.map +1 -1
- package/dist/{import-C8KKmzZS.js → import-CDUGMCum.js} +1382 -291
- package/dist/{import-C8KKmzZS.js.map → import-CDUGMCum.js.map} +1 -1
- package/dist/{import-BYa6wJXz.cjs → import-CjgB8F-w.cjs} +1398 -307
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +17 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -827,7 +827,8 @@ const skillsProcessorToolTargetTuple = [
|
|
|
827
827
|
"zed",
|
|
828
828
|
"zoocode",
|
|
829
829
|
"dsh",
|
|
830
|
-
"lettacode"
|
|
830
|
+
"lettacode",
|
|
831
|
+
"openclaw"
|
|
831
832
|
];
|
|
832
833
|
const hooksProcessorToolTargetTuple = [
|
|
833
834
|
"amp",
|
|
@@ -5183,7 +5184,8 @@ const HookDefinitionSchema = z.looseObject({
|
|
|
5183
5184
|
asyncRewake: z.optional(z.boolean()),
|
|
5184
5185
|
rewakeMessage: z.optional(safeString),
|
|
5185
5186
|
rewakeSummary: z.optional(safeString),
|
|
5186
|
-
continueOnBlock: z.optional(z.boolean())
|
|
5187
|
+
continueOnBlock: z.optional(z.boolean()),
|
|
5188
|
+
strictJsonOutput: z.optional(z.boolean())
|
|
5187
5189
|
});
|
|
5188
5190
|
/**
|
|
5189
5191
|
* All canonical hook event names.
|
|
@@ -6824,41 +6826,55 @@ const JUNIE_TO_CANONICAL_EVENT_NAMES = invertRecord(CANONICAL_TO_JUNIE_EVENT_NAM
|
|
|
6824
6826
|
/**
|
|
6825
6827
|
* Map canonical camelCase event names to Mistral Vibe snake_case.
|
|
6826
6828
|
*
|
|
6827
|
-
*
|
|
6828
|
-
*
|
|
6829
|
-
*
|
|
6830
|
-
*
|
|
6829
|
+
* The canonical `stop` and `subagentStop` events both map to Vibe's
|
|
6830
|
+
* `post_agent` (fires after every assistant turn ending without pending tool
|
|
6831
|
+
* calls); the adapter tells them apart with the hook's `match` on the agent
|
|
6832
|
+
* name (`main` for the main agent). v3.1.1 added `pre_agent`, `notification`,
|
|
6833
|
+
* `session_start` and `session_end`, and v3.1.3 added `pre_llm` and
|
|
6834
|
+
* `post_llm`.
|
|
6831
6835
|
*
|
|
6832
|
-
* These are the v2.21.0 names; the pre-2.21.0 spellings (`before_tool`,
|
|
6836
|
+
* These are the v2.21.0+ names; the pre-2.21.0 spellings (`before_tool`,
|
|
6833
6837
|
* `after_tool`, `post_agent_turn`) are rejected by Vibe's strict `HookType`
|
|
6834
6838
|
* enum.
|
|
6835
|
-
* @see https://github.com/mistralai/mistral-vibe/blob/
|
|
6839
|
+
* @see https://github.com/mistralai/mistral-vibe/blob/v3.1.3/vibe/core/hooks/models.py
|
|
6836
6840
|
*/
|
|
6837
6841
|
const CANONICAL_TO_VIBE_EVENT_NAMES = {
|
|
6838
6842
|
preToolUse: "pre_tool",
|
|
6839
6843
|
postToolUse: "post_tool",
|
|
6840
6844
|
stop: "post_agent",
|
|
6841
|
-
subagentStop: "post_agent"
|
|
6845
|
+
subagentStop: "post_agent",
|
|
6846
|
+
beforeSubmitPrompt: "pre_agent",
|
|
6847
|
+
notification: "notification",
|
|
6848
|
+
sessionStart: "session_start",
|
|
6849
|
+
sessionEnd: "session_end",
|
|
6850
|
+
preModelInvocation: "pre_llm",
|
|
6851
|
+
postModelInvocation: "post_llm"
|
|
6842
6852
|
};
|
|
6843
6853
|
/**
|
|
6844
6854
|
* Hook events supported by Mistral Vibe (mistral-vibe).
|
|
6845
6855
|
*
|
|
6846
|
-
* Vibe
|
|
6847
|
-
* `
|
|
6848
|
-
* `
|
|
6849
|
-
*
|
|
6850
|
-
*
|
|
6851
|
-
*
|
|
6852
|
-
*
|
|
6853
|
-
*
|
|
6854
|
-
* `
|
|
6855
|
-
*
|
|
6856
|
-
*
|
|
6857
|
-
*
|
|
6858
|
-
*
|
|
6859
|
-
* `
|
|
6860
|
-
*
|
|
6861
|
-
*
|
|
6856
|
+
* Vibe reads hooks from `.vibe/hooks.toml`: `pre_tool` ← `preToolUse`,
|
|
6857
|
+
* `post_tool` ← `postToolUse`, `post_agent` ← `stop` / `subagentStop`,
|
|
6858
|
+
* `pre_agent` ← `beforeSubmitPrompt`, `notification` ← `notification`,
|
|
6859
|
+
* `session_start` ← `sessionStart`, `session_end` ← `sessionEnd`, `pre_llm` ←
|
|
6860
|
+
* `preModelInvocation` and `post_llm` ← `postModelInvocation`.
|
|
6861
|
+
*
|
|
6862
|
+
* `post_agent`, `pre_agent`, `pre_llm` and `post_llm` take a `match` on the
|
|
6863
|
+
* agent whose turn it is: the reserved alias `main` selects the main agent, so
|
|
6864
|
+
* canonical `stop` and `beforeSubmitPrompt` are written with `match = "main"`.
|
|
6865
|
+
* `session_start` matches the source (`startup` / `resume` / `clear` /
|
|
6866
|
+
* `fork`), `session_end` the reason (`exit` / `clear` / `other`) and
|
|
6867
|
+
* `notification` the notification type (`approval_requested` /
|
|
6868
|
+
* `question_asked` / `turn_completed` / `turn_failed`). The `strict` flag is
|
|
6869
|
+
* valid on `pre_tool`, `post_tool`, `pre_agent`, `pre_llm` and `post_llm`
|
|
6870
|
+
* (`STRICT_HOOK_TYPES`). Only `type: "command"` hooks are relevant.
|
|
6871
|
+
*
|
|
6872
|
+
* v2.21.0 graduated hooks from experimental and renamed all three original
|
|
6873
|
+
* types (`before_tool` → `pre_tool`, `after_tool` → `post_tool`,
|
|
6874
|
+
* `post_agent_turn` → `post_agent`). `HookType` is a strict enum, so an entry
|
|
6875
|
+
* using an old name is rejected outright and reported as a `HookConfigIssue`.
|
|
6876
|
+
* @see https://github.com/mistralai/mistral-vibe/blob/v3.1.3/vibe/core/hooks/models.py
|
|
6877
|
+
* @see https://github.com/mistralai/mistral-vibe/blob/v3.1.3/vibe/plugins/builtins/vibe/skills/vibe/SKILL.md
|
|
6862
6878
|
*/
|
|
6863
6879
|
const VIBE_HOOK_EVENTS = eventsOf(CANONICAL_TO_VIBE_EVENT_NAMES);
|
|
6864
6880
|
/**
|
|
@@ -8428,6 +8444,31 @@ const ClaudecodePermissionsOverrideSchema = z.looseObject({
|
|
|
8428
8444
|
sandbox: z.optional(z.looseObject({}))
|
|
8429
8445
|
});
|
|
8430
8446
|
/**
|
|
8447
|
+
* Tool-scoped override block for Command Code. The `permissions` object of
|
|
8448
|
+
* `.commandcode/settings.json` carries three documented non-list fields with
|
|
8449
|
+
* no canonical permission category: `defaultMode` (the session-start mode:
|
|
8450
|
+
* `default`, `accept-edits`, `plan`, `yolo` or `dont-ask`, plus the aliases
|
|
8451
|
+
* Command Code accepts such as `bypassPermissions` or `acceptEdits`),
|
|
8452
|
+
* `additionalDirectories` (extra directories treated as inside the workspace)
|
|
8453
|
+
* and `disableBypass` (`"disable"` or `true` makes `yolo` impossible to enter). Only
|
|
8454
|
+
* these three are written; the managed `allow`/`ask`/`deny` lists stay driven
|
|
8455
|
+
* by the shared `permission` block, and any other key placed here is ignored
|
|
8456
|
+
* with a warning. Values that widen trust are written with a warning.
|
|
8457
|
+
*
|
|
8458
|
+
* @example
|
|
8459
|
+
* { "permissions": { "defaultMode": "plan", "disableBypass": true } }
|
|
8460
|
+
* @see https://commandcode.ai/docs/permissions
|
|
8461
|
+
*/
|
|
8462
|
+
const CommandcodePermissionsFieldsSchema = z.looseObject({
|
|
8463
|
+
defaultMode: z.optional(z.string()),
|
|
8464
|
+
additionalDirectories: z.optional(z.array(z.string())),
|
|
8465
|
+
disableBypass: z.optional(z.union([z.literal("disable"), z.boolean()]))
|
|
8466
|
+
});
|
|
8467
|
+
const CommandcodePermissionsOverrideSchema = z.looseObject({
|
|
8468
|
+
permission: z.optional(ToolScopedPermissionSchema),
|
|
8469
|
+
permissions: z.optional(CommandcodePermissionsFieldsSchema)
|
|
8470
|
+
});
|
|
8471
|
+
/**
|
|
8431
8472
|
* Tool-scoped override block for Mistral Vibe. Vibe's per-tool `BaseToolConfig`
|
|
8432
8473
|
* carries a `sensitive_patterns` list — patterns that escalate to ASK even when
|
|
8433
8474
|
* the tool's base permission is ALWAYS (allow). The canonical model can only set
|
|
@@ -9703,7 +9744,7 @@ const PermissionsConfigSchema = z.looseObject({
|
|
|
9703
9744
|
continue: z.optional(CanonicalPermissionsOverrideSchema),
|
|
9704
9745
|
copilot: z.optional(CopilotPermissionsOverrideSchema),
|
|
9705
9746
|
codebuddy: z.optional(CodebuddyPermissionsOverrideSchema),
|
|
9706
|
-
commandcode: z.optional(
|
|
9747
|
+
commandcode: z.optional(CommandcodePermissionsOverrideSchema),
|
|
9707
9748
|
lettacode: z.optional(CanonicalPermissionsOverrideSchema),
|
|
9708
9749
|
crush: z.optional(CanonicalPermissionsOverrideSchema),
|
|
9709
9750
|
goose: z.optional(CanonicalPermissionsOverrideSchema),
|
|
@@ -11544,6 +11585,15 @@ const RulesyncSkillFrontmatterSchema = z.looseObject({
|
|
|
11544
11585
|
"disable-model-invocation": z.optional(z.boolean()),
|
|
11545
11586
|
"user-invocable": z.optional(z.boolean())
|
|
11546
11587
|
})),
|
|
11588
|
+
openclaw: z.optional(z.looseObject({
|
|
11589
|
+
homepage: z.optional(z.string()),
|
|
11590
|
+
"user-invocable": z.optional(z.boolean()),
|
|
11591
|
+
"disable-model-invocation": z.optional(z.boolean()),
|
|
11592
|
+
"command-dispatch": z.optional(z.string()),
|
|
11593
|
+
"command-tool": z.optional(z.string()),
|
|
11594
|
+
"command-arg-mode": z.optional(z.string()),
|
|
11595
|
+
metadata: z.optional(z.looseObject({}))
|
|
11596
|
+
})),
|
|
11547
11597
|
reasonix: z.optional(z.looseObject({
|
|
11548
11598
|
invocation: z.optional(z.string()),
|
|
11549
11599
|
"disable-model-invocation": z.optional(z.boolean()),
|
|
@@ -11623,6 +11673,13 @@ const RulesyncSkillFrontmatterSchema = z.looseObject({
|
|
|
11623
11673
|
"when-to-use": z.optional(z.string()),
|
|
11624
11674
|
paths: z.optional(z.union([z.string(), z.array(z.string())]))
|
|
11625
11675
|
})),
|
|
11676
|
+
firebender: z.optional(z.looseObject({
|
|
11677
|
+
version: z.optional(z.unknown()),
|
|
11678
|
+
autoTrigger: z.optional(z.boolean()),
|
|
11679
|
+
"disable-model-invocation": z.optional(z.boolean()),
|
|
11680
|
+
projectTypes: z.optional(z.union([z.string(), z.array(z.string())])),
|
|
11681
|
+
icon: z.optional(z.string())
|
|
11682
|
+
})),
|
|
11626
11683
|
zcode: z.optional(z.looseObject({
|
|
11627
11684
|
when_to_use: z.optional(z.string()),
|
|
11628
11685
|
license: z.optional(z.string()),
|
|
@@ -11912,9 +11969,9 @@ async function getLocalSkillDirNames(sourceTree) {
|
|
|
11912
11969
|
* The rulesync skill frontmatter exposes a root-level `disable-model-invocation`
|
|
11913
11970
|
* default that applies to every tool supporting the flag (claudecode, codebuddy, copilot,
|
|
11914
11971
|
* copilotcli, crush, cursor, zed, pi, omp, qwencode, vibe, grokcli, factorydroid, dsh, reasonix,
|
|
11915
|
-
* commandcode, lettacode, opencode, opencodev1, mimocode, xum). Each tool's own section
|
|
11916
|
-
* default with a per-target value. A defined section value
|
|
11917
|
-
* always wins over the root default.
|
|
11972
|
+
* commandcode, lettacode, opencode, opencodev1, mimocode, xum, firebender). Each tool's own section
|
|
11973
|
+
* may override that default with a per-target value. A defined section value
|
|
11974
|
+
* (including `false`) always wins over the root default.
|
|
11918
11975
|
*
|
|
11919
11976
|
* `devin` also consumes the root-level value — it maps `true` onto a user-only
|
|
11920
11977
|
* `triggers` list (see `devin-skill.ts`) — but has no section key of the same
|
|
@@ -17489,7 +17546,7 @@ const COMMANDCODE_SKILLS_DIR_PATH = join(COMMANDCODE_DIR, "skills");
|
|
|
17489
17546
|
* (Command Code would send it as prompt text; a rulesync command carries its
|
|
17490
17547
|
* own frontmatter) and only the body is kept.
|
|
17491
17548
|
*
|
|
17492
|
-
* @see https://commandcode.ai/docs/custom-slash-commands
|
|
17549
|
+
* @see https://commandcode.ai/docs/reference/slash-commands#custom-slash-commands
|
|
17493
17550
|
*/
|
|
17494
17551
|
var CommandcodeCommand = class CommandcodeCommand extends ToolCommand {
|
|
17495
17552
|
static getSettablePaths(_options = {}) {
|
|
@@ -26437,18 +26494,86 @@ var FactorydroidSkill = class FactorydroidSkill extends ToolSkill {
|
|
|
26437
26494
|
};
|
|
26438
26495
|
// src/features/skills/firebender-skill.ts
|
|
26439
26496
|
/**
|
|
26497
|
+
* The Agent Skills standard keys the `agentsskills` section carries. On import
|
|
26498
|
+
* they go back there, exactly as for the `agentsskills` target, and every other
|
|
26499
|
+
* key besides `name` / `description` goes into the `firebender` section.
|
|
26500
|
+
*/
|
|
26501
|
+
const AGENT_SKILLS_STANDARD_KEYS$1 = /* @__PURE__ */ new Set([
|
|
26502
|
+
"name",
|
|
26503
|
+
"description",
|
|
26504
|
+
"license",
|
|
26505
|
+
"compatibility",
|
|
26506
|
+
"metadata",
|
|
26507
|
+
"allowed-tools"
|
|
26508
|
+
]);
|
|
26509
|
+
/**
|
|
26440
26510
|
* Firebender skills follow the Agent Skills layout (`<name>/SKILL.md` with the
|
|
26441
26511
|
* required `name` and `description` frontmatter, plus optional supporting
|
|
26442
26512
|
* files), so this target reuses {@link AgentsSkillsSkill} with Firebender's
|
|
26443
26513
|
* recommended locations: `.firebender/skills/` (project) and
|
|
26444
26514
|
* `~/.firebender/skills/` (user).
|
|
26445
26515
|
*
|
|
26516
|
+
* On top of the standard fields, Firebender reads `version`, `autoTrigger`,
|
|
26517
|
+
* `disable-model-invocation` (the inverse of `autoTrigger`, which wins when
|
|
26518
|
+
* both are set), `projectTypes` and `icon`. Those come from the `firebender`
|
|
26519
|
+
* section of the rulesync skill and are written verbatim;
|
|
26520
|
+
* `disable-model-invocation` falls back to the root-level rulesync value.
|
|
26521
|
+
*
|
|
26446
26522
|
* @see https://docs.firebender.com/api-reference/skills
|
|
26447
26523
|
*/
|
|
26448
|
-
var FirebenderSkill = class extends AgentsSkillsSkill {
|
|
26524
|
+
var FirebenderSkill = class FirebenderSkill extends AgentsSkillsSkill {
|
|
26449
26525
|
static getSettablePaths(_options = {}) {
|
|
26450
26526
|
return { relativeDirPath: FIREBENDER_SKILLS_DIR_PATH };
|
|
26451
26527
|
}
|
|
26528
|
+
toRulesyncSkill() {
|
|
26529
|
+
const base = super.toRulesyncSkill();
|
|
26530
|
+
const firebenderSection = Object.fromEntries(Object.entries(this.getFrontmatter()).filter(([key]) => !AGENT_SKILLS_STANDARD_KEYS$1.has(key)));
|
|
26531
|
+
if (Object.keys(firebenderSection).length === 0) return base;
|
|
26532
|
+
const rulesyncFrontmatter = {
|
|
26533
|
+
...base.getFrontmatter(),
|
|
26534
|
+
firebender: firebenderSection
|
|
26535
|
+
};
|
|
26536
|
+
return this.toRulesyncSkillWith(rulesyncFrontmatter);
|
|
26537
|
+
}
|
|
26538
|
+
static fromRulesyncSkill({ outputRoot = process.cwd(), rulesyncSkill, validate = true, global = false, logger }) {
|
|
26539
|
+
const settablePaths = FirebenderSkill.getSettablePaths({ global });
|
|
26540
|
+
const rulesyncFrontmatter = rulesyncSkill.getFrontmatter();
|
|
26541
|
+
const dirName = rulesyncSkill.getDirName();
|
|
26542
|
+
const firebenderSection = {};
|
|
26543
|
+
const ignoredKeys = [];
|
|
26544
|
+
for (const [key, value] of Object.entries(rulesyncFrontmatter.firebender ?? {})) if (AGENT_SKILLS_STANDARD_KEYS$1.has(key)) ignoredKeys.push(key);
|
|
26545
|
+
else firebenderSection[key] = value;
|
|
26546
|
+
if (ignoredKeys.length > 0) warnWithFallback(logger, `${join(outputRoot, settablePaths.relativeDirPath, dirName, SKILL_FILE_NAME)}: the firebender section sets ${ignoredKeys.map(quoteValueForWarning).join(", ")}, which ${ignoredKeys.length === 1 ? "is" : "are"} ignored there; set name/description at the root and the Agent Skills standard fields at the root or in the agentsskills section.`);
|
|
26547
|
+
const disableModelInvocation = resolveDisableModelInvocation({
|
|
26548
|
+
rootFrontmatter: rulesyncFrontmatter,
|
|
26549
|
+
section: rulesyncFrontmatter.firebender
|
|
26550
|
+
});
|
|
26551
|
+
const frontmatter = {
|
|
26552
|
+
name: rulesyncFrontmatter.name,
|
|
26553
|
+
description: rulesyncFrontmatter.description,
|
|
26554
|
+
...toSpecConformantAgentSkillFields(resolveAgentsSkillsSection(rulesyncFrontmatter)),
|
|
26555
|
+
...firebenderSection,
|
|
26556
|
+
...disableModelInvocation !== void 0 && { "disable-model-invocation": disableModelInvocation }
|
|
26557
|
+
};
|
|
26558
|
+
AgentsSkillsSkill.reportSpecViolations({
|
|
26559
|
+
outputRoot,
|
|
26560
|
+
relativeDirPath: settablePaths.relativeDirPath,
|
|
26561
|
+
dirName,
|
|
26562
|
+
frontmatter,
|
|
26563
|
+
sourceAllowedTools: rulesyncFrontmatter.agentsskills?.["allowed-tools"],
|
|
26564
|
+
logger
|
|
26565
|
+
});
|
|
26566
|
+
return new FirebenderSkill({
|
|
26567
|
+
outputRoot,
|
|
26568
|
+
relativeDirPath: settablePaths.relativeDirPath,
|
|
26569
|
+
dirName,
|
|
26570
|
+
frontmatter,
|
|
26571
|
+
body: rulesyncSkill.getBody(),
|
|
26572
|
+
otherFiles: rulesyncSkill.getOtherFiles(),
|
|
26573
|
+
validate,
|
|
26574
|
+
global
|
|
26575
|
+
});
|
|
26576
|
+
}
|
|
26452
26577
|
static toolTarget = "firebender";
|
|
26453
26578
|
};
|
|
26454
26579
|
// src/features/skills/gitlabduo-skill.ts
|
|
@@ -26675,39 +26800,22 @@ var GrokcliSkill = class GrokcliSkill extends ToolSkill {
|
|
|
26675
26800
|
return new GrokcliSkill(this.forDeletionParams(params));
|
|
26676
26801
|
}
|
|
26677
26802
|
};
|
|
26678
|
-
// src/
|
|
26679
|
-
const JunieSkillFrontmatterSchema = z.looseObject({
|
|
26680
|
-
name: z.string(),
|
|
26681
|
-
description: z.string()
|
|
26682
|
-
});
|
|
26803
|
+
// src/utils/markdown-paragraph.ts
|
|
26683
26804
|
/** An ATX markdown heading line (`#` … `######`). */
|
|
26684
26805
|
const HEADING_LINE = /^#{1,6}(\s|$)/;
|
|
26685
26806
|
/**
|
|
26686
|
-
*
|
|
26687
|
-
* `description` is not provided in the frontmatter, Junie CLI extracts the
|
|
26688
|
-
* first paragraph of the body content as the description." Headings do not
|
|
26689
|
-
* count as that paragraph — "If the body is also empty or contains only
|
|
26690
|
-
* headings, the skill will fail to load."
|
|
26691
|
-
*
|
|
26692
|
-
* This is import-only. The canonical `RulesyncSkillFrontmatter` requires a
|
|
26693
|
-
* description, so without the fallback a skill Junie itself loads fine aborts
|
|
26694
|
-
* the whole import; generation keeps emitting an explicit description, which
|
|
26695
|
-
* the same docs recommend.
|
|
26696
|
-
*
|
|
26697
|
-
* Heading lines are therefore skipped rather than taken: a body opening with
|
|
26698
|
-
* `# Skill Name` would otherwise import that title as the description and —
|
|
26699
|
-
* because the next generate writes it out explicitly — replace Junie's own
|
|
26700
|
-
* correct fallback with the wrong value everywhere, canonical config included.
|
|
26701
|
-
*
|
|
26702
|
-
* A paragraph runs to the first blank line or heading, and is collapsed onto
|
|
26703
|
-
* one line because it becomes a YAML frontmatter value. A fenced code block is
|
|
26704
|
-
* not treated specially: it is ordinary content, so a body whose first
|
|
26705
|
-
* paragraph is a fence yields the fence text. Returns an empty string when the
|
|
26706
|
-
* body holds no such paragraph, which the caller turns into a skipped skill.
|
|
26807
|
+
* The first non-heading paragraph of a Markdown body, collapsed onto one line.
|
|
26707
26808
|
*
|
|
26708
|
-
*
|
|
26809
|
+
* JetBrains Junie falls back to this paragraph as the description of a skill
|
|
26810
|
+
* or subagent whose frontmatter omits one. Heading lines are skipped rather
|
|
26811
|
+
* than taken, so a body opening with `# Title` does not yield the title. A
|
|
26812
|
+
* paragraph runs to the first blank line or heading, and is collapsed onto one
|
|
26813
|
+
* line because callers store it as a YAML frontmatter value. A fenced code
|
|
26814
|
+
* block is not treated specially: it is ordinary content, so a body whose
|
|
26815
|
+
* first paragraph is a fence yields the fence text. Returns an empty string
|
|
26816
|
+
* when the body holds no such paragraph.
|
|
26709
26817
|
*/
|
|
26710
|
-
function
|
|
26818
|
+
function firstNonHeadingParagraph(body) {
|
|
26711
26819
|
const paragraph = [];
|
|
26712
26820
|
for (const rawLine of body.split(/\r?\n/)) {
|
|
26713
26821
|
const line = rawLine.trim();
|
|
@@ -26721,6 +26829,11 @@ function deriveDescriptionFromBody(body) {
|
|
|
26721
26829
|
}
|
|
26722
26830
|
return paragraph.join(" ").trim();
|
|
26723
26831
|
}
|
|
26832
|
+
// src/features/skills/junie-skill.ts
|
|
26833
|
+
const JunieSkillFrontmatterSchema = z.looseObject({
|
|
26834
|
+
name: z.string(),
|
|
26835
|
+
description: z.string()
|
|
26836
|
+
});
|
|
26724
26837
|
/**
|
|
26725
26838
|
* Represents a JetBrains Junie skill directory.
|
|
26726
26839
|
* Skills are stored under the .junie/skills directory with SKILL.md files.
|
|
@@ -26791,7 +26904,7 @@ var JunieSkill = class JunieSkill extends ToolSkill {
|
|
|
26791
26904
|
});
|
|
26792
26905
|
let frontmatter = loaded.frontmatter;
|
|
26793
26906
|
if (isRecord(frontmatter) && frontmatter.description === void 0) {
|
|
26794
|
-
const derived =
|
|
26907
|
+
const derived = firstNonHeadingParagraph(loaded.body);
|
|
26795
26908
|
if (derived === "") throw new Error(`Cannot import ${join(loaded.outputRoot, loaded.relativeDirPath, loaded.dirName, SKILL_FILE_NAME)}: it has no description and its body has no paragraph to derive one from, so Junie cannot load it either. Add a description to the frontmatter.`);
|
|
26796
26909
|
frontmatter = {
|
|
26797
26910
|
...frontmatter,
|
|
@@ -27825,6 +27938,125 @@ var PiSkill = class extends ToolSkill {
|
|
|
27825
27938
|
var OmpSkill = class extends PiSkill {
|
|
27826
27939
|
static layout = OMP_LAYOUT;
|
|
27827
27940
|
};
|
|
27941
|
+
// src/constants/openclaw-paths.ts
|
|
27942
|
+
const OPENCLAW_WORKSPACE_DIR_PATH = join(".openclaw", "workspace");
|
|
27943
|
+
const OPENCLAW_RULE_FILE_NAME = "AGENTS.md";
|
|
27944
|
+
const OPENCLAW_CONFIG_DIR_PATH = ".openclaw";
|
|
27945
|
+
const OPENCLAW_CONFIG_FILE_NAME = "openclaw.json";
|
|
27946
|
+
const OPENCLAW_MCP_SERVERS_KEY = "servers";
|
|
27947
|
+
const OPENCLAW_PROJECT_SKILLS_DIR_PATH = join(".agents", "skills");
|
|
27948
|
+
const OPENCLAW_GLOBAL_SKILLS_DIR_PATH = join(OPENCLAW_CONFIG_DIR_PATH, "skills");
|
|
27949
|
+
// src/features/skills/openclaw-skill.ts
|
|
27950
|
+
const OpenclawSkillFrontmatterSchema = z.looseObject({
|
|
27951
|
+
name: z.string(),
|
|
27952
|
+
description: z.string(),
|
|
27953
|
+
homepage: z.optional(z.string()),
|
|
27954
|
+
"user-invocable": z.optional(z.boolean()),
|
|
27955
|
+
"disable-model-invocation": z.optional(z.boolean()),
|
|
27956
|
+
"command-dispatch": z.optional(z.string()),
|
|
27957
|
+
"command-tool": z.optional(z.string()),
|
|
27958
|
+
"command-arg-mode": z.optional(z.string()),
|
|
27959
|
+
metadata: z.optional(z.looseObject({}))
|
|
27960
|
+
});
|
|
27961
|
+
/**
|
|
27962
|
+
* Represents an OpenClaw skill directory.
|
|
27963
|
+
*
|
|
27964
|
+
* Project mode writes the execution folder's `.agents/skills/<name>/SKILL.md`,
|
|
27965
|
+
* which OpenClaw loads when a session runs from that folder (the same mechanism
|
|
27966
|
+
* that loads the folder's `AGENTS.md`). Global mode writes the managed/local
|
|
27967
|
+
* `~/.openclaw/skills/<name>/SKILL.md` root, visible to every agent sharing the
|
|
27968
|
+
* default state directory. The execution folder's `skills/` and the personal
|
|
27969
|
+
* `~/.agents/skills` roots are left alone (see `openclaw-paths.ts`).
|
|
27970
|
+
*
|
|
27971
|
+
* Every key beyond `name`/`description` is carried in the `openclaw` section of
|
|
27972
|
+
* the rulesync skill; the two invocation flags and `metadata` fall back to the
|
|
27973
|
+
* shared root-level defaults when the section omits them.
|
|
27974
|
+
*
|
|
27975
|
+
* @see https://docs.openclaw.ai/tools/skills
|
|
27976
|
+
*/
|
|
27977
|
+
var OpenclawSkill = class OpenclawSkill extends ToolSkill {
|
|
27978
|
+
constructor({ outputRoot = process.cwd(), relativeDirPath = OPENCLAW_PROJECT_SKILLS_DIR_PATH, dirName, frontmatter, body, otherFiles = [], validate = true, global = false }) {
|
|
27979
|
+
super({
|
|
27980
|
+
outputRoot,
|
|
27981
|
+
relativeDirPath,
|
|
27982
|
+
dirName,
|
|
27983
|
+
mainFile: {
|
|
27984
|
+
name: SKILL_FILE_NAME,
|
|
27985
|
+
body,
|
|
27986
|
+
frontmatter: { ...frontmatter }
|
|
27987
|
+
},
|
|
27988
|
+
otherFiles,
|
|
27989
|
+
global
|
|
27990
|
+
});
|
|
27991
|
+
if (validate) {
|
|
27992
|
+
const result = this.validate();
|
|
27993
|
+
if (!result.success) throw result.error;
|
|
27994
|
+
}
|
|
27995
|
+
}
|
|
27996
|
+
static getSettablePaths({ global = false } = {}) {
|
|
27997
|
+
return { relativeDirPath: global ? OPENCLAW_GLOBAL_SKILLS_DIR_PATH : OPENCLAW_PROJECT_SKILLS_DIR_PATH };
|
|
27998
|
+
}
|
|
27999
|
+
getFrontmatter() {
|
|
28000
|
+
return OpenclawSkillFrontmatterSchema.parse(this.requireMainFileFrontmatter());
|
|
28001
|
+
}
|
|
28002
|
+
validate() {
|
|
28003
|
+
return this.validateMainFileFrontmatter(OpenclawSkillFrontmatterSchema);
|
|
28004
|
+
}
|
|
28005
|
+
toRulesyncSkill() {
|
|
28006
|
+
const { name, description, ...section } = this.getFrontmatter();
|
|
28007
|
+
const rulesyncFrontmatter = {
|
|
28008
|
+
name,
|
|
28009
|
+
description,
|
|
28010
|
+
targets: ["*"],
|
|
28011
|
+
...Object.keys(section).length > 0 && { openclaw: section }
|
|
28012
|
+
};
|
|
28013
|
+
return this.toRulesyncSkillWith(rulesyncFrontmatter);
|
|
28014
|
+
}
|
|
28015
|
+
static fromRulesyncSkill({ outputRoot = process.cwd(), rulesyncSkill, validate = true, global = false }) {
|
|
28016
|
+
const rulesyncFrontmatter = rulesyncSkill.getFrontmatter();
|
|
28017
|
+
const { name: _sectionName, description: _sectionDescription, ...section } = rulesyncFrontmatter.openclaw ?? {};
|
|
28018
|
+
const disableModelInvocation = resolveDisableModelInvocation({
|
|
28019
|
+
rootFrontmatter: rulesyncFrontmatter,
|
|
28020
|
+
section
|
|
28021
|
+
});
|
|
28022
|
+
const userInvocable = resolveUserInvocable({
|
|
28023
|
+
rootFrontmatter: rulesyncFrontmatter,
|
|
28024
|
+
section
|
|
28025
|
+
});
|
|
28026
|
+
const metadata = resolveMetadata({
|
|
28027
|
+
rootFrontmatter: rulesyncFrontmatter,
|
|
28028
|
+
section
|
|
28029
|
+
});
|
|
28030
|
+
const frontmatter = {
|
|
28031
|
+
...section,
|
|
28032
|
+
name: rulesyncFrontmatter.name,
|
|
28033
|
+
description: rulesyncFrontmatter.description,
|
|
28034
|
+
...metadata !== void 0 && { metadata },
|
|
28035
|
+
...disableModelInvocation !== void 0 && { "disable-model-invocation": disableModelInvocation },
|
|
28036
|
+
...userInvocable !== void 0 && { "user-invocable": userInvocable }
|
|
28037
|
+
};
|
|
28038
|
+
return new OpenclawSkill({
|
|
28039
|
+
outputRoot,
|
|
28040
|
+
relativeDirPath: OpenclawSkill.getSettablePaths({ global }).relativeDirPath,
|
|
28041
|
+
dirName: rulesyncSkill.getDirName(),
|
|
28042
|
+
frontmatter,
|
|
28043
|
+
body: rulesyncSkill.getBody(),
|
|
28044
|
+
otherFiles: rulesyncSkill.getOtherFiles(),
|
|
28045
|
+
validate,
|
|
28046
|
+
global
|
|
28047
|
+
});
|
|
28048
|
+
}
|
|
28049
|
+
static toolTarget = "openclaw";
|
|
28050
|
+
static async fromDir(params) {
|
|
28051
|
+
return new OpenclawSkill(await this.loadStandardSkillParams({
|
|
28052
|
+
params,
|
|
28053
|
+
schema: OpenclawSkillFrontmatterSchema
|
|
28054
|
+
}));
|
|
28055
|
+
}
|
|
28056
|
+
static forDeletion(params) {
|
|
28057
|
+
return new OpenclawSkill(this.forDeletionParams(params));
|
|
28058
|
+
}
|
|
28059
|
+
};
|
|
27828
28060
|
// src/features/skills/opencodev1-skill.ts
|
|
27829
28061
|
/**
|
|
27830
28062
|
* Skill generator for **OpenCode V1** (OpenCode 1.x). Skills live in the same
|
|
@@ -29888,6 +30120,14 @@ const toolSkillFactories = /* @__PURE__ */ new Map([
|
|
|
29888
30120
|
supportsSimulated: false,
|
|
29889
30121
|
supportsGlobal: true
|
|
29890
30122
|
}
|
|
30123
|
+
}],
|
|
30124
|
+
["openclaw", {
|
|
30125
|
+
class: OpenclawSkill,
|
|
30126
|
+
meta: {
|
|
30127
|
+
supportsProject: true,
|
|
30128
|
+
supportsSimulated: false,
|
|
30129
|
+
supportsGlobal: true
|
|
30130
|
+
}
|
|
29891
30131
|
}]
|
|
29892
30132
|
]);
|
|
29893
30133
|
const defaultGetFactory$5 = (target) => {
|
|
@@ -32381,7 +32621,7 @@ function warnAboutReservedAgentName({ name, relativeFilePath, logger }) {
|
|
|
32381
32621
|
* `.commandcode/agents/` (project) or `~/.commandcode/agents/` (user); the
|
|
32382
32622
|
* body is the agent's system prompt.
|
|
32383
32623
|
*
|
|
32384
|
-
* @see https://commandcode.ai/docs/
|
|
32624
|
+
* @see https://commandcode.ai/docs/agents
|
|
32385
32625
|
*/
|
|
32386
32626
|
var CommandcodeSubagent = class extends FrontmatterMarkdownToolSubagent {
|
|
32387
32627
|
static getSettablePaths(_options = {}) {
|
|
@@ -34135,7 +34375,7 @@ var HermesagentSubagent = class HermesagentSubagent extends ToolSubagent {
|
|
|
34135
34375
|
*/
|
|
34136
34376
|
const JunieSubagentFrontmatterSchema = z.looseObject({
|
|
34137
34377
|
name: z.optional(z.string()),
|
|
34138
|
-
description: z.string(),
|
|
34378
|
+
description: z.optional(z.string()),
|
|
34139
34379
|
tools: z.optional(z.union([z.string(), z.array(z.string())])),
|
|
34140
34380
|
disallowedTools: z.optional(z.union([z.string(), z.array(z.string())])),
|
|
34141
34381
|
mcpServers: z.optional(z.union([z.string(), z.array(z.string())])),
|
|
@@ -34146,6 +34386,34 @@ const JunieSubagentFrontmatterSchema = z.looseObject({
|
|
|
34146
34386
|
skills: z.optional(z.union([z.string(), z.array(z.string())])),
|
|
34147
34387
|
allowPromptArgument: z.optional(z.boolean())
|
|
34148
34388
|
});
|
|
34389
|
+
/** Junie truncates a body-derived subagent description to this many characters. */
|
|
34390
|
+
const JUNIE_DERIVED_DESCRIPTION_MAX_LENGTH = 1024;
|
|
34391
|
+
/**
|
|
34392
|
+
* Junie's fallback when a subagent's frontmatter has no `description`: the
|
|
34393
|
+
* first non-heading paragraph of the body, truncated to 1,024 characters.
|
|
34394
|
+
* Returns `undefined` when the body has no such paragraph.
|
|
34395
|
+
*
|
|
34396
|
+
* @see https://junie.jetbrains.com/docs/junie-cli-subagents.html
|
|
34397
|
+
*/
|
|
34398
|
+
function deriveDescriptionFromBody(body) {
|
|
34399
|
+
const paragraph = firstNonHeadingParagraph(body);
|
|
34400
|
+
if (paragraph === "") return void 0;
|
|
34401
|
+
return truncateText({
|
|
34402
|
+
text: paragraph,
|
|
34403
|
+
maxLength: JUNIE_DERIVED_DESCRIPTION_MAX_LENGTH,
|
|
34404
|
+
suffix: ""
|
|
34405
|
+
});
|
|
34406
|
+
}
|
|
34407
|
+
function isMissingDescription(value) {
|
|
34408
|
+
return value === void 0 || value === null || typeof value === "string" && value.trim() === "";
|
|
34409
|
+
}
|
|
34410
|
+
/**
|
|
34411
|
+
* Junie's fallback subagent name: the file name without its `.agent.md` or
|
|
34412
|
+
* `.md` extension.
|
|
34413
|
+
*/
|
|
34414
|
+
function nameFromFileName(relativeFilePath) {
|
|
34415
|
+
return relativeFilePath.replace(/(\.agent)?\.md$/, "");
|
|
34416
|
+
}
|
|
34149
34417
|
var JunieSubagent = class JunieSubagent extends ToolSubagent {
|
|
34150
34418
|
frontmatter;
|
|
34151
34419
|
body;
|
|
@@ -34177,8 +34445,8 @@ var JunieSubagent = class JunieSubagent extends ToolSubagent {
|
|
|
34177
34445
|
outputRoot: ".",
|
|
34178
34446
|
frontmatter: {
|
|
34179
34447
|
targets: ["*"],
|
|
34180
|
-
name: name ?? this.getRelativeFilePath()
|
|
34181
|
-
description,
|
|
34448
|
+
name: name ?? nameFromFileName(this.getRelativeFilePath()),
|
|
34449
|
+
...description !== void 0 && { description },
|
|
34182
34450
|
...Object.keys(junieSection).length > 0 && { junie: junieSection }
|
|
34183
34451
|
},
|
|
34184
34452
|
body: this.body,
|
|
@@ -34237,7 +34505,16 @@ var JunieSubagent = class JunieSubagent extends ToolSubagent {
|
|
|
34237
34505
|
const dirPath = relativeDirPath ?? this.getSettablePaths({ global }).relativeDirPath;
|
|
34238
34506
|
const filePath = join(outputRoot, dirPath, relativeFilePath);
|
|
34239
34507
|
const fileContent = await readFileContent(filePath);
|
|
34240
|
-
const { frontmatter, body: content } = parseFrontmatter(fileContent, filePath);
|
|
34508
|
+
const { frontmatter: parsedFrontmatter, body: content } = parseFrontmatter(fileContent, filePath);
|
|
34509
|
+
let frontmatter = parsedFrontmatter;
|
|
34510
|
+
if (isRecord(frontmatter) && isMissingDescription(frontmatter.description)) {
|
|
34511
|
+
const { description: _missing, ...rest } = frontmatter;
|
|
34512
|
+
const derived = deriveDescriptionFromBody(content);
|
|
34513
|
+
frontmatter = derived === void 0 ? rest : {
|
|
34514
|
+
...rest,
|
|
34515
|
+
description: derived
|
|
34516
|
+
};
|
|
34517
|
+
}
|
|
34241
34518
|
const result = JunieSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
34242
34519
|
if (!result.success) throw new Error(`Invalid frontmatter in ${filePath}: ${formatError(result.error)}`);
|
|
34243
34520
|
return new JunieSubagent({
|
|
@@ -46059,12 +46336,6 @@ var OmpRule = class OmpRule extends ToolRule {
|
|
|
46059
46336
|
}
|
|
46060
46337
|
static toolTarget = "omp";
|
|
46061
46338
|
};
|
|
46062
|
-
// src/constants/openclaw-paths.ts
|
|
46063
|
-
const OPENCLAW_WORKSPACE_DIR_PATH = join(".openclaw", "workspace");
|
|
46064
|
-
const OPENCLAW_RULE_FILE_NAME = "AGENTS.md";
|
|
46065
|
-
const OPENCLAW_CONFIG_DIR_PATH = ".openclaw";
|
|
46066
|
-
const OPENCLAW_CONFIG_FILE_NAME = "openclaw.json";
|
|
46067
|
-
const OPENCLAW_MCP_SERVERS_KEY = "servers";
|
|
46068
46339
|
// src/features/rules/openclaw-rule.ts
|
|
46069
46340
|
/**
|
|
46070
46341
|
* Rule generator for OpenClaw, the always-on assistant gateway.
|
|
@@ -54594,12 +54865,23 @@ function toolMatcherEntryToCanonical({ rawEntry, eventName, converterConfig, war
|
|
|
54594
54865
|
* tool-native keys through verbatim — so documented native triggers (e.g.
|
|
54595
54866
|
* kiro-ide's `PostFileSave`) survive an import → generate round-trip instead
|
|
54596
54867
|
* of failing canonical validation.
|
|
54868
|
+
*
|
|
54869
|
+
* An event key named `__proto__`, `constructor` or `prototype` is dropped with
|
|
54870
|
+
* a warning: no tool documents such an event, and carrying it into
|
|
54871
|
+
* `.rulesync/hooks.jsonc` would make the next `generate` fail the
|
|
54872
|
+
* prototype-pollution key validation.
|
|
54597
54873
|
*/
|
|
54598
|
-
function buildImportedHooksConfig({ hooks, overrideKey, version = 1, extraOverride }) {
|
|
54874
|
+
function buildImportedHooksConfig({ hooks, overrideKey, version = 1, extraOverride, logger }) {
|
|
54599
54875
|
const canonical = {};
|
|
54600
54876
|
const native = {};
|
|
54601
|
-
for (const [event, defs] of Object.entries(hooks))
|
|
54602
|
-
|
|
54877
|
+
for (const [event, defs] of Object.entries(hooks)) {
|
|
54878
|
+
if (isPrototypePollutionKey(event)) {
|
|
54879
|
+
logger?.warn(`Skipping imported ${overrideKey} hooks event ${quoteValueForWarning(event)}: reserved key names cannot be used as hook events.`);
|
|
54880
|
+
continue;
|
|
54881
|
+
}
|
|
54882
|
+
if (isHookEvent(event)) canonical[event] = defs;
|
|
54883
|
+
else native[event] = defs;
|
|
54884
|
+
}
|
|
54603
54885
|
const override = { ...extraOverride };
|
|
54604
54886
|
if (Object.keys(native).length > 0) override.hooks = native;
|
|
54605
54887
|
const config = {
|
|
@@ -54849,6 +55131,7 @@ var AntigravityHooks = class extends ToolHooks {
|
|
|
54849
55131
|
});
|
|
54850
55132
|
const overrideKey = this.constructor.getOverrideKey();
|
|
54851
55133
|
return this.toRulesyncHooksDefault({ fileContent: JSON.stringify(buildImportedHooksConfig({
|
|
55134
|
+
logger,
|
|
54852
55135
|
hooks,
|
|
54853
55136
|
overrideKey
|
|
54854
55137
|
}), null, 2) });
|
|
@@ -55233,6 +55516,7 @@ var AugmentcodeHooks = class AugmentcodeHooks extends ToolHooks {
|
|
|
55233
55516
|
converterConfig: AUGMENTCODE_CONVERTER_CONFIG
|
|
55234
55517
|
});
|
|
55235
55518
|
return this.toRulesyncHooksDefault({ fileContent: JSON.stringify(buildImportedHooksConfig({
|
|
55519
|
+
logger,
|
|
55236
55520
|
hooks,
|
|
55237
55521
|
overrideKey: "augmentcode"
|
|
55238
55522
|
}), null, 2) });
|
|
@@ -55309,6 +55593,7 @@ var AugmentcodePluginHooks = class AugmentcodePluginHooks extends ToolHooks {
|
|
|
55309
55593
|
converterConfig: AUGMENTCODE_PLUGIN_CONVERTER_CONFIG
|
|
55310
55594
|
});
|
|
55311
55595
|
return this.toRulesyncHooksDefault({ fileContent: JSON.stringify(buildImportedHooksConfig({
|
|
55596
|
+
logger,
|
|
55312
55597
|
hooks,
|
|
55313
55598
|
overrideKey: "augmentcode"
|
|
55314
55599
|
}), null, 2) });
|
|
@@ -55870,6 +56155,7 @@ var SettingsJsonHooks = class extends ToolHooks {
|
|
|
55870
56155
|
converterConfig: ctor.getConverterConfig()
|
|
55871
56156
|
});
|
|
55872
56157
|
return this.toRulesyncHooksDefault({ fileContent: JSON.stringify(buildImportedHooksConfig({
|
|
56158
|
+
logger,
|
|
55873
56159
|
hooks,
|
|
55874
56160
|
overrideKey: spec.overrideKey
|
|
55875
56161
|
}), null, 2) });
|
|
@@ -56663,13 +56949,14 @@ var CodewhaleHooks = class CodewhaleHooks extends ToolHooks {
|
|
|
56663
56949
|
global
|
|
56664
56950
|
});
|
|
56665
56951
|
}
|
|
56666
|
-
toRulesyncHooks() {
|
|
56952
|
+
toRulesyncHooks({ logger } = {}) {
|
|
56667
56953
|
const parsed = this.parseFileContentOrThrow({
|
|
56668
56954
|
displayName: "Codewhale",
|
|
56669
56955
|
parse: (fileContent) => parseCodewhaleToml(fileContent)
|
|
56670
56956
|
});
|
|
56671
56957
|
const rawHooks = this.global ? isPlainObject(parsed.hooks) ? parsed.hooks.hooks : void 0 : parsed.hooks;
|
|
56672
56958
|
return this.toRulesyncHooksDefault({ fileContent: JSON.stringify(buildImportedHooksConfig({
|
|
56959
|
+
logger,
|
|
56673
56960
|
hooks: codewhaleHooksToCanonical(rawHooks),
|
|
56674
56961
|
overrideKey: "codewhale"
|
|
56675
56962
|
}), null, 2) });
|
|
@@ -56907,6 +57194,7 @@ var CodexcliHooks = class CodexcliHooks extends ToolHooks {
|
|
|
56907
57194
|
logger
|
|
56908
57195
|
});
|
|
56909
57196
|
return this.toRulesyncHooksDefault({ fileContent: JSON.stringify(buildImportedHooksConfig({
|
|
57197
|
+
logger,
|
|
56910
57198
|
hooks,
|
|
56911
57199
|
overrideKey: "codexcli"
|
|
56912
57200
|
}), null, 2) });
|
|
@@ -57003,6 +57291,7 @@ var CommandcodeHooks = class CommandcodeHooks extends ToolHooks {
|
|
|
57003
57291
|
converterConfig: COMMANDCODE_CONVERTER_CONFIG
|
|
57004
57292
|
});
|
|
57005
57293
|
return this.toRulesyncHooksDefault({ fileContent: JSON.stringify(buildImportedHooksConfig({
|
|
57294
|
+
logger,
|
|
57006
57295
|
hooks,
|
|
57007
57296
|
overrideKey: "commandcode"
|
|
57008
57297
|
}), null, 2) });
|
|
@@ -57302,6 +57591,7 @@ var CopilotHooks = class CopilotHooks extends ToolHooks {
|
|
|
57302
57591
|
parse: (fileContent) => JSON.parse(fileContent)
|
|
57303
57592
|
}).hooks, options?.logger);
|
|
57304
57593
|
return this.toRulesyncHooksDefault({ fileContent: JSON.stringify(buildImportedHooksConfig({
|
|
57594
|
+
logger: options?.logger,
|
|
57305
57595
|
hooks,
|
|
57306
57596
|
overrideKey: "copilot"
|
|
57307
57597
|
}), null, 2) });
|
|
@@ -57754,6 +58044,7 @@ var CopilotcliHooks = class CopilotcliHooks extends ToolHooks {
|
|
|
57754
58044
|
parse: (fileContent) => JSON.parse(fileContent)
|
|
57755
58045
|
}).hooks, options?.logger);
|
|
57756
58046
|
return this.toRulesyncHooksDefault({ fileContent: JSON.stringify(buildImportedHooksConfig({
|
|
58047
|
+
logger: options?.logger,
|
|
57757
58048
|
hooks,
|
|
57758
58049
|
overrideKey: "copilotcli",
|
|
57759
58050
|
...this.disableAllHooks !== void 0 && { extraOverride: { disableAllHooks: this.disableAllHooks } }
|
|
@@ -58199,9 +58490,10 @@ var CrushHooks = class CrushHooks extends ToolHooks {
|
|
|
58199
58490
|
global
|
|
58200
58491
|
});
|
|
58201
58492
|
}
|
|
58202
|
-
toRulesyncHooks() {
|
|
58493
|
+
toRulesyncHooks({ logger } = {}) {
|
|
58203
58494
|
const hooks = crushHooksToCanonical(this.json[CRUSH_HOOKS_KEY]);
|
|
58204
58495
|
return this.toRulesyncHooksDefault({ fileContent: JSON.stringify(buildImportedHooksConfig({
|
|
58496
|
+
logger,
|
|
58205
58497
|
hooks,
|
|
58206
58498
|
overrideKey: "crush"
|
|
58207
58499
|
}), null, 2) });
|
|
@@ -58298,7 +58590,7 @@ var CursorHooks = class CursorHooks extends ToolHooks {
|
|
|
58298
58590
|
static supportsPreserveUnowned() {
|
|
58299
58591
|
return true;
|
|
58300
58592
|
}
|
|
58301
|
-
toRulesyncHooks() {
|
|
58593
|
+
toRulesyncHooks({ logger } = {}) {
|
|
58302
58594
|
const content = this.getFileContent();
|
|
58303
58595
|
const parsed = JSON.parse(content);
|
|
58304
58596
|
const cursorHooks = parsed.hooks ?? {};
|
|
@@ -58312,6 +58604,7 @@ var CursorHooks = class CursorHooks extends ToolHooks {
|
|
|
58312
58604
|
}
|
|
58313
58605
|
const version = parsed.version ?? 1;
|
|
58314
58606
|
return this.toRulesyncHooksDefault({ fileContent: JSON.stringify(buildImportedHooksConfig({
|
|
58607
|
+
logger,
|
|
58315
58608
|
hooks: canonicalHooks,
|
|
58316
58609
|
overrideKey: "cursor",
|
|
58317
58610
|
version
|
|
@@ -58329,6 +58622,22 @@ var CursorHooks = class CursorHooks extends ToolHooks {
|
|
|
58329
58622
|
};
|
|
58330
58623
|
// src/features/hooks/deepagents-hooks.ts
|
|
58331
58624
|
/**
|
|
58625
|
+
* deepagents-code 0.2.11+ spells the canonical `failClosed` as a per-handler
|
|
58626
|
+
* `onError: "continue" | "deny"`. Only `"deny"` changes behavior: a failed,
|
|
58627
|
+
* timed-out or invalid-output `PreToolUse` handler then denies the tool call.
|
|
58628
|
+
* `"continue"` is the default, so `false` is omitted; upstream ignores the
|
|
58629
|
+
* field on every other event, so a `true` there is dropped with a warning.
|
|
58630
|
+
* Older dcode versions ignore the field and keep failing open.
|
|
58631
|
+
* https://github.com/langchain-ai/deepagents/blob/main/libs/code/HOOKS.md
|
|
58632
|
+
*/
|
|
58633
|
+
const DEEPAGENTS_KEYWORD_FIELDS = [{
|
|
58634
|
+
canonical: "failClosed",
|
|
58635
|
+
tool: "onError",
|
|
58636
|
+
trueValue: "deny",
|
|
58637
|
+
falseValue: "continue",
|
|
58638
|
+
events: /* @__PURE__ */ new Set(["preToolUse"])
|
|
58639
|
+
}];
|
|
58640
|
+
/**
|
|
58332
58641
|
* Convert the canonical hooks config to the deepagents Hooks v2 document.
|
|
58333
58642
|
*
|
|
58334
58643
|
* ```json
|
|
@@ -58338,7 +58647,8 @@ var CursorHooks = class CursorHooks extends ToolHooks {
|
|
|
58338
58647
|
* Definitions sharing an event and matcher land in one group, preserving their
|
|
58339
58648
|
* authored order — upstream runs a group's handlers in sequence.
|
|
58340
58649
|
*/
|
|
58341
|
-
function canonicalToDeepagentsHooks(config) {
|
|
58650
|
+
function canonicalToDeepagentsHooks(config, logger) {
|
|
58651
|
+
const warn = warnOnce(logger);
|
|
58342
58652
|
const supported = new Set(DEEPAGENTS_HOOK_EVENTS);
|
|
58343
58653
|
const effectiveHooks = {
|
|
58344
58654
|
...config.hooks,
|
|
@@ -58361,6 +58671,13 @@ function canonicalToDeepagentsHooks(config) {
|
|
|
58361
58671
|
};
|
|
58362
58672
|
if (def.timeout !== void 0 && def.timeout !== null && def.timeout > 0) handler.timeout = def.timeout;
|
|
58363
58673
|
if (def.statusMessage !== void 0 && def.statusMessage !== null) handler.statusMessage = def.statusMessage;
|
|
58674
|
+
Object.assign(handler, emitKeywordFields({
|
|
58675
|
+
def,
|
|
58676
|
+
hookType: "command",
|
|
58677
|
+
eventName: canonicalEvent,
|
|
58678
|
+
fields: DEEPAGENTS_KEYWORD_FIELDS,
|
|
58679
|
+
warn
|
|
58680
|
+
}));
|
|
58364
58681
|
const matcher = def.matcher !== void 0 && def.matcher !== null && def.matcher !== "" ? def.matcher : void 0;
|
|
58365
58682
|
const groups = hooks[deepagentsEvent] ??= [];
|
|
58366
58683
|
const group = groups.find((candidate) => candidate.matcher === matcher);
|
|
@@ -58376,7 +58693,8 @@ function canonicalToDeepagentsHooks(config) {
|
|
|
58376
58693
|
/**
|
|
58377
58694
|
* Convert the Hooks v2 document back to the canonical hooks record.
|
|
58378
58695
|
*/
|
|
58379
|
-
function deepagentsToCanonicalHooks(hooks) {
|
|
58696
|
+
function deepagentsToCanonicalHooks(hooks, logger) {
|
|
58697
|
+
const warn = warnOnce(logger);
|
|
58380
58698
|
const canonical = {};
|
|
58381
58699
|
for (const [deepagentsEvent, groups] of Object.entries(hooks)) {
|
|
58382
58700
|
const canonicalEvent = lookupOwn({
|
|
@@ -58395,6 +58713,19 @@ function deepagentsToCanonicalHooks(hooks) {
|
|
|
58395
58713
|
if (typeof group.matcher === "string" && group.matcher !== "") def.matcher = group.matcher;
|
|
58396
58714
|
if (typeof handler.timeout === "number") def.timeout = handler.timeout;
|
|
58397
58715
|
if (typeof handler.statusMessage === "string") def.statusMessage = handler.statusMessage;
|
|
58716
|
+
let keywordSource = handler;
|
|
58717
|
+
if (canonicalEvent === "preToolUse" && handler.onError !== void 0 && handler.onError !== "deny" && handler.onError !== "continue") {
|
|
58718
|
+
warn(`Dropping "onError" from an imported "command" hook on "${canonicalEvent}": ${quoteValueForWarning(handler.onError)} is not "deny" or "continue", so the hook is imported without "failClosed" and fails open on the next generate.`);
|
|
58719
|
+
const { onError: _dropped, ...rest } = handler;
|
|
58720
|
+
keywordSource = rest;
|
|
58721
|
+
}
|
|
58722
|
+
Object.assign(def, importKeywordFields({
|
|
58723
|
+
h: keywordSource,
|
|
58724
|
+
hookType: "command",
|
|
58725
|
+
eventName: canonicalEvent,
|
|
58726
|
+
fields: DEEPAGENTS_KEYWORD_FIELDS,
|
|
58727
|
+
warn
|
|
58728
|
+
}));
|
|
58398
58729
|
(canonical[canonicalEvent] ??= []).push(def);
|
|
58399
58730
|
}
|
|
58400
58731
|
}
|
|
@@ -58453,8 +58784,8 @@ var DeepagentsHooks = class DeepagentsHooks extends ToolHooks {
|
|
|
58453
58784
|
global
|
|
58454
58785
|
});
|
|
58455
58786
|
}
|
|
58456
|
-
static fromRulesyncHooks({ outputRoot = process.cwd(), rulesyncHooks, validate = true, global = false }) {
|
|
58457
|
-
const hooks = canonicalToDeepagentsHooks(rulesyncHooks.getJson());
|
|
58787
|
+
static fromRulesyncHooks({ outputRoot = process.cwd(), rulesyncHooks, validate = true, global = false, logger }) {
|
|
58788
|
+
const hooks = canonicalToDeepagentsHooks(rulesyncHooks.getJson(), logger);
|
|
58458
58789
|
const fileContent = JSON.stringify({ hooks }, null, 2);
|
|
58459
58790
|
const paths = DeepagentsHooks.getSettablePaths({ global });
|
|
58460
58791
|
return new DeepagentsHooks({
|
|
@@ -58465,19 +58796,20 @@ var DeepagentsHooks = class DeepagentsHooks extends ToolHooks {
|
|
|
58465
58796
|
validate
|
|
58466
58797
|
});
|
|
58467
58798
|
}
|
|
58468
|
-
toRulesyncHooks() {
|
|
58799
|
+
toRulesyncHooks({ logger } = {}) {
|
|
58469
58800
|
const parsed = this.parseFileContentOrThrow({
|
|
58470
58801
|
displayName: "deepagents",
|
|
58471
58802
|
parse: (fileContent) => JSON.parse(fileContent)
|
|
58472
58803
|
});
|
|
58473
58804
|
const rawHooks = isRecord(parsed) ? parsed.hooks : void 0;
|
|
58474
|
-
const hooks = Array.isArray(rawHooks) ? deepagentsLegacyToCanonicalHooks(rawHooks) : isRecord(rawHooks) ? deepagentsToCanonicalHooks(rawHooks) : {};
|
|
58805
|
+
const hooks = Array.isArray(rawHooks) ? deepagentsLegacyToCanonicalHooks(rawHooks) : isRecord(rawHooks) ? deepagentsToCanonicalHooks(rawHooks, logger) : {};
|
|
58475
58806
|
return this.toRulesyncHooksDefault({
|
|
58476
58807
|
outputRoot: getDeepagentsRulesyncOutputRoot({
|
|
58477
58808
|
nativeOutputRoot: this.outputRoot,
|
|
58478
58809
|
global: this.global
|
|
58479
58810
|
}),
|
|
58480
58811
|
fileContent: JSON.stringify(buildImportedHooksConfig({
|
|
58812
|
+
logger,
|
|
58481
58813
|
hooks,
|
|
58482
58814
|
overrideKey: "deepagents"
|
|
58483
58815
|
}), null, 2)
|
|
@@ -58583,6 +58915,7 @@ var DevinHooks = class extends ToolHooks {
|
|
|
58583
58915
|
logger
|
|
58584
58916
|
});
|
|
58585
58917
|
return this.toRulesyncHooksDefault({ fileContent: JSON.stringify(buildImportedHooksConfig({
|
|
58918
|
+
logger,
|
|
58586
58919
|
hooks,
|
|
58587
58920
|
overrideKey: "devin"
|
|
58588
58921
|
}), null, 2) });
|
|
@@ -58808,6 +59141,7 @@ var FactorydroidHooks = class FactorydroidHooks extends ToolHooks {
|
|
|
58808
59141
|
logger
|
|
58809
59142
|
});
|
|
58810
59143
|
return this.toRulesyncHooksDefault({ fileContent: JSON.stringify(buildImportedHooksConfig({
|
|
59144
|
+
logger,
|
|
58811
59145
|
hooks,
|
|
58812
59146
|
overrideKey: "factorydroid"
|
|
58813
59147
|
}), null, 2) });
|
|
@@ -58892,9 +59226,10 @@ var FirebenderHooks = class FirebenderHooks extends ToolHooks {
|
|
|
58892
59226
|
static supportsPreserveUnowned() {
|
|
58893
59227
|
return true;
|
|
58894
59228
|
}
|
|
58895
|
-
toRulesyncHooks() {
|
|
59229
|
+
toRulesyncHooks({ logger } = {}) {
|
|
58896
59230
|
const parsed = JSON.parse(this.getFileContent());
|
|
58897
59231
|
return this.toRulesyncHooksDefault({ fileContent: JSON.stringify(buildImportedHooksConfig({
|
|
59232
|
+
logger,
|
|
58898
59233
|
hooks: parsed.hooks ?? {},
|
|
58899
59234
|
overrideKey: "firebender",
|
|
58900
59235
|
version: parsed.version ?? 1
|
|
@@ -58962,6 +59297,7 @@ var GitlabduoHooks = class GitlabduoHooks extends ToolHooks {
|
|
|
58962
59297
|
logger
|
|
58963
59298
|
});
|
|
58964
59299
|
return this.toRulesyncHooksDefault({ fileContent: JSON.stringify(buildImportedHooksConfig({
|
|
59300
|
+
logger,
|
|
58965
59301
|
hooks,
|
|
58966
59302
|
overrideKey: "gitlabduo"
|
|
58967
59303
|
}), null, 2) });
|
|
@@ -59031,6 +59367,7 @@ var GooseHooks = class GooseHooks extends ToolHooks {
|
|
|
59031
59367
|
logger
|
|
59032
59368
|
});
|
|
59033
59369
|
return this.toRulesyncHooksDefault({ fileContent: JSON.stringify(buildImportedHooksConfig({
|
|
59370
|
+
logger,
|
|
59034
59371
|
hooks,
|
|
59035
59372
|
overrideKey: "goose"
|
|
59036
59373
|
}), null, 2) });
|
|
@@ -59113,6 +59450,7 @@ var GrokcliHooks = class GrokcliHooks extends ToolHooks {
|
|
|
59113
59450
|
logger
|
|
59114
59451
|
});
|
|
59115
59452
|
return this.toRulesyncHooksDefault({ fileContent: JSON.stringify(buildImportedHooksConfig({
|
|
59453
|
+
logger,
|
|
59116
59454
|
hooks,
|
|
59117
59455
|
overrideKey: "grokcli"
|
|
59118
59456
|
}), null, 2) });
|
|
@@ -59406,7 +59744,7 @@ var HermesagentHooks = class HermesagentHooks extends ToolHooks {
|
|
|
59406
59744
|
}) }
|
|
59407
59745
|
});
|
|
59408
59746
|
}
|
|
59409
|
-
toRulesyncHooks() {
|
|
59747
|
+
toRulesyncHooks({ logger } = {}) {
|
|
59410
59748
|
const hooks = hermesHooksToCanonical(parseSharedConfig({
|
|
59411
59749
|
format: "yaml",
|
|
59412
59750
|
fileContent: this.getFileContent()
|
|
@@ -59417,6 +59755,7 @@ var HermesagentHooks = class HermesagentHooks extends ToolHooks {
|
|
|
59417
59755
|
global: this.global
|
|
59418
59756
|
}),
|
|
59419
59757
|
fileContent: JSON.stringify(buildImportedHooksConfig({
|
|
59758
|
+
logger,
|
|
59420
59759
|
hooks,
|
|
59421
59760
|
overrideKey: "hermesagent"
|
|
59422
59761
|
}), null, 2)
|
|
@@ -59446,13 +59785,20 @@ const JUNIE_CONVERTER_CONFIG = {
|
|
|
59446
59785
|
projectDirVar: "",
|
|
59447
59786
|
supportedHookTypes: /* @__PURE__ */ new Set(["command"]),
|
|
59448
59787
|
noMatcherEvents: /* @__PURE__ */ new Set(["beforeSubmitPrompt", "stop"]),
|
|
59449
|
-
booleanPassthroughFields: [
|
|
59450
|
-
|
|
59451
|
-
|
|
59452
|
-
|
|
59453
|
-
|
|
59454
|
-
|
|
59455
|
-
|
|
59788
|
+
booleanPassthroughFields: [
|
|
59789
|
+
{
|
|
59790
|
+
canonical: "failClosed",
|
|
59791
|
+
tool: "blockOnError"
|
|
59792
|
+
},
|
|
59793
|
+
{
|
|
59794
|
+
canonical: "async",
|
|
59795
|
+
tool: "async"
|
|
59796
|
+
},
|
|
59797
|
+
{
|
|
59798
|
+
canonical: "strictJsonOutput",
|
|
59799
|
+
tool: "strictJsonOutput"
|
|
59800
|
+
}
|
|
59801
|
+
]
|
|
59456
59802
|
};
|
|
59457
59803
|
var JunieHooks = class JunieHooks extends ToolHooks {
|
|
59458
59804
|
isDeletable() {
|
|
@@ -59504,6 +59850,7 @@ var JunieHooks = class JunieHooks extends ToolHooks {
|
|
|
59504
59850
|
logger
|
|
59505
59851
|
});
|
|
59506
59852
|
return this.toRulesyncHooksDefault({ fileContent: JSON.stringify(buildImportedHooksConfig({
|
|
59853
|
+
logger,
|
|
59507
59854
|
hooks,
|
|
59508
59855
|
overrideKey: "junie"
|
|
59509
59856
|
}), null, 2) });
|
|
@@ -59642,33 +59989,255 @@ const SHELL_EVENT_TOOL_GATES = {
|
|
|
59642
59989
|
}
|
|
59643
59990
|
};
|
|
59644
59991
|
/**
|
|
59645
|
-
* Canonical events whose command receives
|
|
59646
|
-
* stdin
|
|
59647
|
-
*
|
|
59648
|
-
*
|
|
59649
|
-
*
|
|
59650
|
-
* protection example in the plugins doc).
|
|
59651
|
-
*
|
|
59652
|
-
* The payload mirrors Claude Code's `PreToolUse` input: `hook_event_name`,
|
|
59653
|
-
* `session_id` (`input.sessionID`), `tool_use_id` (`input.callID`),
|
|
59654
|
-
* `tool_name` (the raw OpenCode tool name — `bash`, `edit`, `<server>_<tool>`
|
|
59655
|
-
* for MCP — the same subject a `matcher` is tested against), `tool_input`
|
|
59656
|
-
* (`output.args`) and `cwd` (the plugin context's `directory`, falling back to
|
|
59657
|
-
* `process.cwd()`). It is serialized lazily, on the first handler whose
|
|
59658
|
-
* matcher matches, so a tool call no hook applies to pays nothing for it.
|
|
59659
|
-
*
|
|
59660
|
-
* Bun Shell has no stdin option on a command and rejects redirections on a
|
|
59661
|
-
* subshell, so the payload is piped in by the shell's builtin `echo`
|
|
59662
|
-
* (`echo ${payload} | <command>`); Bun escapes the interpolated value, so the
|
|
59663
|
-
* payload never reaches the shell as syntax. The pipe feeds the first
|
|
59664
|
-
* pipeline of the command — a compound `a && b` or `a; b` gives the payload
|
|
59665
|
-
* to `a` only, so multi-step guards belong in a script.
|
|
59992
|
+
* Canonical events whose command receives Claude Code's JSON input for the
|
|
59993
|
+
* event on stdin (every other command gets an empty stdin), with the fields
|
|
59994
|
+
* besides `hook_event_name` and `cwd`. `tool_name` is the raw OpenCode tool
|
|
59995
|
+
* name, the subject a `matcher` is tested against. A payload is serialized
|
|
59996
|
+
* lazily, once per invocation, by the first handler that runs.
|
|
59666
59997
|
*
|
|
59667
59998
|
* @see https://opencode.ai/docs/plugins/
|
|
59668
59999
|
* @see https://bun.sh/docs/runtime/shell
|
|
59669
60000
|
* @see https://code.claude.com/docs/en/hooks
|
|
59670
60001
|
*/
|
|
59671
|
-
const
|
|
60002
|
+
const STDIN_PAYLOADS = {
|
|
60003
|
+
preToolUse: {
|
|
60004
|
+
name: "PreToolUse",
|
|
60005
|
+
fields: [
|
|
60006
|
+
"session_id: input.sessionID",
|
|
60007
|
+
"tool_use_id: input.callID",
|
|
60008
|
+
"tool_name: input.tool",
|
|
60009
|
+
"tool_input: output?.args"
|
|
60010
|
+
]
|
|
60011
|
+
},
|
|
60012
|
+
postToolUse: {
|
|
60013
|
+
name: "PostToolUse",
|
|
60014
|
+
fields: [
|
|
60015
|
+
"session_id: input.sessionID",
|
|
60016
|
+
"tool_use_id: input.callID",
|
|
60017
|
+
"tool_name: input.tool",
|
|
60018
|
+
"tool_input: input.args",
|
|
60019
|
+
"tool_response: output"
|
|
60020
|
+
]
|
|
60021
|
+
},
|
|
60022
|
+
stop: {
|
|
60023
|
+
name: "Stop",
|
|
60024
|
+
fields: ["session_id: event.properties?.sessionID"]
|
|
60025
|
+
}
|
|
60026
|
+
};
|
|
60027
|
+
/**
|
|
60028
|
+
* V1 hooks that run before the action they belong to — every named hook but
|
|
60029
|
+
* `tool.execute.after`: like the Bun Shell call earlier versions emitted, a
|
|
60030
|
+
* failing command throws there, which aborts the action. Everywhere else a
|
|
60031
|
+
* failure is only logged.
|
|
60032
|
+
*/
|
|
60033
|
+
const BLOCKING_HOOKS = new Set(Object.keys(NAMED_HOOK_MATCHER_SUBJECTS).filter((hook) => hook !== "tool.execute.after"));
|
|
60034
|
+
/**
|
|
60035
|
+
* Helpers of every plugin with a handler. Bun Shell cannot give a command a
|
|
60036
|
+
* stdin of its own, and one that inherits OpenCode's (the TTY, or the pipe of
|
|
60037
|
+
* `opencode serve --stdio`) blocks forever once any part of it reads stdin. So
|
|
60038
|
+
* `__rulesyncRunCommand` runs the command in the host's own Bun-compiled binary
|
|
60039
|
+
* as the Bun CLI (`BUN_BE_BUN=1`, without the project's `.env`): `exec` runs it
|
|
60040
|
+
* with the same Bun Shell, parsing the text the template literal of earlier
|
|
60041
|
+
* versions held, with the payload as stdin. The script clears `BUN_BE_BUN` for
|
|
60042
|
+
* the programs the command starts: Bun Shell has no `unset`, so it exports an
|
|
60043
|
+
* empty value, which Bun treats as unset (only a non-empty value other than
|
|
60044
|
+
* `0` makes a Bun-compiled binary act as the Bun CLI). A host without the Bun
|
|
60045
|
+
* CLI fails the probe and falls back to Bun Shell, piping the payload into the
|
|
60046
|
+
* first command only (a probe still running after 10 s is killed; it, a
|
|
60047
|
+
* failing one or one that prints anything but `rulesync` means no Bun CLI for
|
|
60048
|
+
* 5 minutes). Ordinary commands write to the host's stdout and stderr, as Bun
|
|
60049
|
+
* Shell echoed them; a `preToolUse` command's are read, 1 MiB each kept (more
|
|
60050
|
+
* stdout denies; on the Bun Shell fallback the whole output is buffered before
|
|
60051
|
+
* that check). Output
|
|
60052
|
+
* pipes a background process keeps open are read for 1 s after the command
|
|
60053
|
+
* exits; what arrived by then is kept, and the reads are then cancelled, as
|
|
60054
|
+
* they are at a timeout. The OpenCode 1.x-style `event` hooks (`inProcess`)
|
|
60055
|
+
* take the Bun Shell path too: starting the child takes about
|
|
60056
|
+
* 250 ms, and OpenCode 1.x's one-shot `opencode run` exits right after
|
|
60057
|
+
* `session.idle`, before a `stop` command run that way could start.
|
|
60058
|
+
* A command that outlives its timeout (counted from its start) resolves to
|
|
60059
|
+
* `null` and is killed. On POSIX its process tree, read from procfs or else
|
|
60060
|
+
* `ps`, gets SIGTERM and, 2 s later, SIGKILL for each of those processes still
|
|
60061
|
+
* alive (same start time, wherever it was reparented) and what it started
|
|
60062
|
+
* since; the command's own process is signalled through its Bun handle only,
|
|
60063
|
+
* so a PID reused after it exited is never signalled. The command keeps
|
|
60064
|
+
* OpenCode's process group, so it keeps the terminal
|
|
60065
|
+
* and Ctrl-C, but a process that left the tree before the timeout (orphaned or
|
|
60066
|
+
* `setsid`) escapes, and without procfs and `ps` only
|
|
60067
|
+
* the command's own process is killed (logged). The pending SIGKILL keeps the
|
|
60068
|
+
* host alive for those 2 s. On Windows, `taskkill /T /F` ends the tree as
|
|
60069
|
+
* linked by parent PID at that moment, then the child is ended through its
|
|
60070
|
+
* handle; a process whose parent had already exited is not reached. Bun Shell
|
|
60071
|
+
* (the fallback) cannot kill: it stops waiting, and the command keeps running.
|
|
60072
|
+
* On a failure, `__rulesyncRunHook` throws in a blocking hook or logs it
|
|
60073
|
+
* otherwise.
|
|
60074
|
+
*
|
|
60075
|
+
* @see https://bun.sh/docs/bundler/executables
|
|
60076
|
+
*/
|
|
60077
|
+
function buildRunHelperLinesFor(cwdExpression) {
|
|
60078
|
+
const spawn = (script, stdin, stdout = "\"pipe\"", stderr = stdout) => `Bun.spawn([process.execPath, "--no-env-file", "exec", ${script}], { cwd: ${cwdExpression}, env: { ...process.env, BUN_BE_BUN: "1" }, stdin: ${stdin}, stdout: ${stdout}, stderr: ${stderr}, windowsHide: true })`;
|
|
60079
|
+
return [
|
|
60080
|
+
"const __rulesyncRead = (stream, limit = 1048576) => {",
|
|
60081
|
+
" const chunks = [];",
|
|
60082
|
+
" let size = 0;",
|
|
60083
|
+
" const reader = stream.getReader();",
|
|
60084
|
+
" let reading = true;",
|
|
60085
|
+
" const done = (async () => {",
|
|
60086
|
+
" for (let read; reading && !(read = await reader.read()).done; ) {",
|
|
60087
|
+
" if (reading && (size += read.value.length) <= limit) chunks.push(read.value);",
|
|
60088
|
+
" }",
|
|
60089
|
+
" })().catch(() => {});",
|
|
60090
|
+
" const stop = () => {",
|
|
60091
|
+
" if (reading) (reading = false), reader.cancel().catch(() => {});",
|
|
60092
|
+
" };",
|
|
60093
|
+
" return { done, stop, text: () => Buffer.concat(chunks).toString(), overflow: () => size > limit };",
|
|
60094
|
+
"};",
|
|
60095
|
+
"let __rulesyncCanExec;",
|
|
60096
|
+
"let __rulesyncRetryAt = 0;",
|
|
60097
|
+
"// pid -> [ppid, start time], from procfs or else ps; a reused PID gets a new start time.",
|
|
60098
|
+
"const __rulesyncProcesses = () => {",
|
|
60099
|
+
" const processes = new Map();",
|
|
60100
|
+
" try {",
|
|
60101
|
+
" const fs = require(\"node:fs\");",
|
|
60102
|
+
" for (const pid of fs.readdirSync(\"/proc\").filter((name) => /^\\d+$/.test(name))) {",
|
|
60103
|
+
" try {",
|
|
60104
|
+
" const stat = fs.readFileSync(\"/proc/\" + pid + \"/stat\", \"utf8\");",
|
|
60105
|
+
" const fields = stat.slice(stat.lastIndexOf(\")\") + 2).split(\" \");",
|
|
60106
|
+
" processes.set(pid, [fields[1], fields[19]]);",
|
|
60107
|
+
" } catch {}",
|
|
60108
|
+
" }",
|
|
60109
|
+
" if (processes.size > 0) return processes;",
|
|
60110
|
+
" } catch {}",
|
|
60111
|
+
" try {",
|
|
60112
|
+
" // The C locale keeps `lstart` in one format; it is compared as text, never parsed.",
|
|
60113
|
+
" const env = { ...process.env, LC_ALL: \"C\", LANG: \"C\" };",
|
|
60114
|
+
" const ps = Bun.spawnSync([\"ps\", \"-A\", \"-o\", \"pid=,ppid=,lstart=\"], { env, timeout: 5000 });",
|
|
60115
|
+
" if (ps.exitCode === 0) {",
|
|
60116
|
+
" for (const line of ps.stdout.toString().trim().split(\"\\n\")) {",
|
|
60117
|
+
" const [pid, ppid, ...started] = line.trim().split(/\\s+/);",
|
|
60118
|
+
" processes.set(pid, [ppid, started.join(\" \")]);",
|
|
60119
|
+
" }",
|
|
60120
|
+
" return processes;",
|
|
60121
|
+
" }",
|
|
60122
|
+
" } catch {}",
|
|
60123
|
+
" console.error(\"[rulesync-hooks] neither /proc nor ps is available: only the hook process is killed\");",
|
|
60124
|
+
"};",
|
|
60125
|
+
"const __rulesyncTree = (roots, processes) => {",
|
|
60126
|
+
" const tree = [...roots];",
|
|
60127
|
+
" for (let size = -1; size !== tree.length; ) {",
|
|
60128
|
+
" size = tree.length;",
|
|
60129
|
+
" for (const [pid, [ppid]] of processes ?? []) if (tree.includes(ppid) && !tree.includes(pid)) tree.push(pid);",
|
|
60130
|
+
" }",
|
|
60131
|
+
" return tree;",
|
|
60132
|
+
"};",
|
|
60133
|
+
"// The child itself is signalled only through its handle, a no-op once Bun has reaped it, so a",
|
|
60134
|
+
"// reused PID is never signalled; its descendants only while it is running (not reaped, its PID",
|
|
60135
|
+
"// cannot be reused), and in the SIGKILL round only with both snapshots: the first snapshot's",
|
|
60136
|
+
"// descendants that are the same processes (same start time), and what they and the child,",
|
|
60137
|
+
"// if it ran across the second snapshot, have started since.",
|
|
60138
|
+
"const __rulesyncKillTree = (proc) => {",
|
|
60139
|
+
" const kill = (pids, signal) => pids.forEach((pid) => { try { process.kill(Number(pid), signal); } catch {} });",
|
|
60140
|
+
" const running = () => proc.exitCode === null && proc.signalCode === null;",
|
|
60141
|
+
" const root = String(proc.pid);",
|
|
60142
|
+
" const before = running() ? __rulesyncProcesses() : undefined;",
|
|
60143
|
+
" const first = before && running() ? __rulesyncTree([root], before).slice(1) : [];",
|
|
60144
|
+
" proc.kill(\"SIGTERM\");",
|
|
60145
|
+
" kill(first, \"SIGTERM\");",
|
|
60146
|
+
" setTimeout(() => {",
|
|
60147
|
+
" const alive = running();",
|
|
60148
|
+
" const now = before && __rulesyncProcesses();",
|
|
60149
|
+
" if (!now) return proc.kill(\"SIGKILL\");",
|
|
60150
|
+
" // Every first-snapshot descendant that is still the same process, wherever it was",
|
|
60151
|
+
" // reparented (to PID 1 or a subreaper), and the child if it survived SIGTERM, with what",
|
|
60152
|
+
" // they have started since. The child is killed first, so it starts nothing more.",
|
|
60153
|
+
" const same = first.filter((pid) => now.get(pid)?.[1] === before.get(pid)?.[1]);",
|
|
60154
|
+
" const own = alive && running() && now.get(root)?.[1] === before.get(root)?.[1];",
|
|
60155
|
+
" proc.kill(\"SIGKILL\");",
|
|
60156
|
+
" kill(__rulesyncTree(own ? [root, ...same] : same, now).filter((pid) => pid !== root), \"SIGKILL\");",
|
|
60157
|
+
" }, 2000);",
|
|
60158
|
+
"};",
|
|
60159
|
+
"// `proc.kill()` is TerminateProcess on the child alone. A libuv program (node) that dies takes",
|
|
60160
|
+
"// the children it spawned along through its job object, but not ones started through another",
|
|
60161
|
+
"// program (cmd.exe) or detached. taskkill /T ends the tree as linked by parent PID at that",
|
|
60162
|
+
"// moment; System32's copy, so a taskkill earlier on PATH is never run.",
|
|
60163
|
+
"const __rulesyncKillWindowsTree = (proc) => {",
|
|
60164
|
+
" if (proc.exitCode === null && proc.signalCode === null) {",
|
|
60165
|
+
" const taskkill = (process.env.SystemRoot ?? \"C:\\\\Windows\") + \"\\\\System32\\\\taskkill.exe\";",
|
|
60166
|
+
" try {",
|
|
60167
|
+
" Bun.spawnSync([taskkill, \"/T\", \"/F\", \"/PID\", String(proc.pid)], { stdout: \"ignore\", stderr: \"ignore\", windowsHide: true, timeout: 5000 });",
|
|
60168
|
+
" } catch {}",
|
|
60169
|
+
" }",
|
|
60170
|
+
" proc.kill();",
|
|
60171
|
+
"};",
|
|
60172
|
+
"const __rulesyncRunCommand = async ({ command, input, seconds, inProcess = false, echo = false }) => {",
|
|
60173
|
+
" // A probe that printed `rulesync` is kept; one past its deadline, failing or printing",
|
|
60174
|
+
" // anything else means no Bun CLI for 5 minutes; one that threw is dropped, so the next",
|
|
60175
|
+
" // command probes again.",
|
|
60176
|
+
" if (!inProcess && (__rulesyncCanExec === undefined || (__rulesyncRetryAt && Date.now() >= __rulesyncRetryAt))) {",
|
|
60177
|
+
" __rulesyncRetryAt = 0;",
|
|
60178
|
+
" const probing = (__rulesyncCanExec = (async () => {",
|
|
60179
|
+
` const probe = ${spawn("\"echo rulesync\"", "\"ignore\"", "\"pipe\"", "\"ignore\"")};`,
|
|
60180
|
+
" const output = __rulesyncRead(probe.stdout, 1024);",
|
|
60181
|
+
" let timer;",
|
|
60182
|
+
" // Settles on its own, even if the probe ignores the kill or a process holds its stdout.",
|
|
60183
|
+
" const deadline = new Promise((resolve) => (timer = setTimeout(resolve, 10000, null)));",
|
|
60184
|
+
" const exited = Promise.all([probe.exited, output.done]).then(([code]) => code);",
|
|
60185
|
+
" const exitCode = await Promise.race([exited, deadline]).finally(() => clearTimeout(timer));",
|
|
60186
|
+
" if (exitCode === null) probe.kill(\"SIGKILL\"), output.stop();",
|
|
60187
|
+
" const found = exitCode === 0 && output.text().trim() === \"rulesync\";",
|
|
60188
|
+
" if (!found) __rulesyncRetryAt = Date.now() + 300000;",
|
|
60189
|
+
" return found;",
|
|
60190
|
+
" })().catch(() => {",
|
|
60191
|
+
" if (__rulesyncCanExec === probing) __rulesyncCanExec = undefined;",
|
|
60192
|
+
" return false;",
|
|
60193
|
+
" }));",
|
|
60194
|
+
" }",
|
|
60195
|
+
" let timer;",
|
|
60196
|
+
" const timeout = () => new Promise((resolve) => (timer = setTimeout(resolve, seconds * 1000, null)));",
|
|
60197
|
+
" if (inProcess || !(await __rulesyncCanExec)) {",
|
|
60198
|
+
` const run = Bun.$\`echo \${input} | \${{ raw: command }}\`.cwd(${cwdExpression}).nothrow();`,
|
|
60199
|
+
" const result = await Promise.race([echo ? run : run.quiet(), timeout()]).finally(() => clearTimeout(timer));",
|
|
60200
|
+
" if (!result || echo) return result && { exitCode: result.exitCode };",
|
|
60201
|
+
" const { exitCode, stdout, stderr } = result;",
|
|
60202
|
+
" return { exitCode, stdout: stdout.toString(), stderr: stderr.toString(), overflow: stdout.length > 1048576 };",
|
|
60203
|
+
" }",
|
|
60204
|
+
" // An ordinary command writes to the host's stdout and stderr; a preToolUse one is read.",
|
|
60205
|
+
" const output = echo ? \"inherit\" : \"pipe\";",
|
|
60206
|
+
` const proc = ${spawn("\"export BUN_BE_BUN=\\n\" + command", "new TextEncoder().encode(input + \"\\n\")", "output")};`,
|
|
60207
|
+
" const [stdout, stderr] = echo ? [] : [__rulesyncRead(proc.stdout), __rulesyncRead(proc.stderr)];",
|
|
60208
|
+
" const exitCode = await Promise.race([proc.exited, timeout()]).finally(() => clearTimeout(timer));",
|
|
60209
|
+
" if (exitCode === null) {",
|
|
60210
|
+
" stdout?.stop(), stderr?.stop();",
|
|
60211
|
+
" if (process.platform === \"win32\") __rulesyncKillWindowsTree(proc);",
|
|
60212
|
+
" else __rulesyncKillTree(proc);",
|
|
60213
|
+
" return null;",
|
|
60214
|
+
" }",
|
|
60215
|
+
" if (echo) return { exitCode };",
|
|
60216
|
+
" await Promise.race([Promise.all([stdout.done, stderr.done]), Bun.sleep(1000)]);",
|
|
60217
|
+
" stdout.stop(), stderr.stop();",
|
|
60218
|
+
" return { exitCode, stdout: stdout.text(), stderr: stderr.text(), overflow: stdout.overflow() };",
|
|
60219
|
+
"};",
|
|
60220
|
+
"const __rulesyncRunHook = async ({ label, command, input, blocking, seconds, inProcess = false }) => {",
|
|
60221
|
+
" let result;",
|
|
60222
|
+
" try {",
|
|
60223
|
+
" result = await __rulesyncRunCommand({ command, input, seconds, inProcess, echo: true });",
|
|
60224
|
+
" } catch (error) {",
|
|
60225
|
+
" if (blocking) throw error;",
|
|
60226
|
+
" console.error(\"[rulesync-hooks] \" + label + \" hook failed:\", error);",
|
|
60227
|
+
" return;",
|
|
60228
|
+
" }",
|
|
60229
|
+
" if (result === null) {",
|
|
60230
|
+
" const message = \"[rulesync-hooks] \" + label + \" hook timed out after \" + seconds + \"s\";",
|
|
60231
|
+
" if (blocking) throw new Error(message);",
|
|
60232
|
+
" return console.error(message);",
|
|
60233
|
+
" }",
|
|
60234
|
+
" if (result.exitCode === 0) return;",
|
|
60235
|
+
" const message = \"[rulesync-hooks] \" + label + \" hook exited with code \" + result.exitCode;",
|
|
60236
|
+
" if (blocking) throw new Error(message);",
|
|
60237
|
+
" console.error(message);",
|
|
60238
|
+
"};"
|
|
60239
|
+
];
|
|
60240
|
+
}
|
|
59672
60241
|
/**
|
|
59673
60242
|
* Name of the helper the generated plugin defines when a `preToolUse` handler
|
|
59674
60243
|
* is present. It interprets the command's result like Claude Code does for a
|
|
@@ -59678,7 +60247,10 @@ const STDIN_PAYLOAD_EVENTS = { preToolUse: "PreToolUse" };
|
|
|
59678
60247
|
* - exit code 0 with JSON stdout whose `hookSpecificOutput.permissionDecision`
|
|
59679
60248
|
* is `"deny"` → deny, with `permissionDecisionReason` as the reason;
|
|
59680
60249
|
* - exit code 0 otherwise → allow;
|
|
59681
|
-
* - any other non-zero exit → deny too, with stderr or the exit code
|
|
60250
|
+
* - any other non-zero exit → deny too, with stderr or the exit code;
|
|
60251
|
+
* - more than 1 MiB of stdout → deny, without parsing it;
|
|
60252
|
+
* - a command past its timeout → deny, like a non-zero exit, unless the hook
|
|
60253
|
+
* sets `failClosed: false`, which allows the call and logs the timeout.
|
|
59682
60254
|
*
|
|
59683
60255
|
* Every reason goes through the `sanitizeBlockReason` helper shared with the
|
|
59684
60256
|
* Pi extension (`hook-block-reason.ts`): control and format characters are
|
|
@@ -59694,7 +60266,12 @@ const PRE_TOOL_USE_RESULT_HELPER = "__rulesyncEnforcePreToolUseResult";
|
|
|
59694
60266
|
const PRE_TOOL_USE_RESULT_HELPER_LINES = [
|
|
59695
60267
|
...buildBlockReasonSanitizerLines({ typed: false }),
|
|
59696
60268
|
"",
|
|
59697
|
-
`const ${PRE_TOOL_USE_RESULT_HELPER} = (result) => {`,
|
|
60269
|
+
`const ${PRE_TOOL_USE_RESULT_HELPER} = (result, failClosed) => {`,
|
|
60270
|
+
" if (result === null) {",
|
|
60271
|
+
" if (failClosed !== false) throw new Error(\"preToolUse hook timed out.\");",
|
|
60272
|
+
" return console.error(\"[rulesync-hooks] preToolUse hook timed out\");",
|
|
60273
|
+
" }",
|
|
60274
|
+
" if (result.overflow) throw new Error(\"preToolUse hook wrote more than 1 MiB to stdout.\");",
|
|
59698
60275
|
" const stderr = result.stderr.toString();",
|
|
59699
60276
|
" if (result.exitCode === 0) {",
|
|
59700
60277
|
" let parsed;",
|
|
@@ -59728,15 +60305,70 @@ function escapeForTemplateLiteral(command) {
|
|
|
59728
60305
|
function validateAndSanitizeMatcher(matcher) {
|
|
59729
60306
|
return sanitizeMatcherRegex(matcher).replace(/\\/g, "\\\\").replace(/"/g, "\\\"");
|
|
59730
60307
|
}
|
|
59731
|
-
/**
|
|
60308
|
+
/**
|
|
60309
|
+
* A hook's `timeout` in seconds, Claude Code's default of 600 when it sets none,
|
|
60310
|
+
* capped at what `setTimeout` can wait (larger values fire at once), and its
|
|
60311
|
+
* `failClosed` as written: unset is not `false`.
|
|
60312
|
+
*/
|
|
60313
|
+
function hookTimingOf(def) {
|
|
60314
|
+
const timeout = def.timeout !== void 0 && def.timeout > 0 ? def.timeout : 600;
|
|
60315
|
+
return {
|
|
60316
|
+
timeout: Math.min(timeout, 2147483),
|
|
60317
|
+
failClosed: def.failClosed
|
|
60318
|
+
};
|
|
60319
|
+
}
|
|
60320
|
+
const FAIL_CLOSED_TOOL_LABELS = {
|
|
60321
|
+
kilo: "Kilo Code",
|
|
60322
|
+
mimocode: "MiMo Code",
|
|
60323
|
+
opencode: "OpenCode",
|
|
60324
|
+
opencodev1: "OpenCode V1"
|
|
60325
|
+
};
|
|
60326
|
+
/**
|
|
60327
|
+
* Canonical events other than `preToolUse` whose hook runs before its action in
|
|
60328
|
+
* every OpenCode-style plugin (V1 and V2): a failing or timed-out command always
|
|
60329
|
+
* aborts the action there. A test checks it against `BLOCKING_HOOKS` and the V2
|
|
60330
|
+
* generator's `isBlockingOpencodeV2Target`.
|
|
60331
|
+
*/
|
|
60332
|
+
const ALWAYS_BLOCKING_EVENTS = /* @__PURE__ */ new Set([
|
|
60333
|
+
"beforeShellExecution",
|
|
60334
|
+
"beforeSubmitPrompt",
|
|
60335
|
+
"preModelInvocation",
|
|
60336
|
+
"userPromptExpansion",
|
|
60337
|
+
"preCompact"
|
|
60338
|
+
]);
|
|
60339
|
+
/**
|
|
60340
|
+
* Warn about each `failClosed` the generated plugin ignores where it changes
|
|
60341
|
+
* the outcome: the plugin only reads it on `preToolUse`, to decide what a
|
|
60342
|
+
* timed-out command does. Elsewhere a hook that runs before its action always
|
|
60343
|
+
* fails on a timeout, so a `false` there is ignored (a `true` already holds),
|
|
60344
|
+
* and any other hook only logs it, so a `true` there is ignored (a `false`
|
|
60345
|
+
* already holds, like the other targets treat an omitted `false`).
|
|
60346
|
+
*/
|
|
60347
|
+
function warnIgnoredFailClosed({ config, supportedEvents, toolConfigKey, logger }) {
|
|
60348
|
+
const configHooks = {
|
|
60349
|
+
...config.hooks,
|
|
60350
|
+
...config[toolConfigKey]?.hooks
|
|
60351
|
+
};
|
|
60352
|
+
const plugin = `the generated ${FAIL_CLOSED_TOOL_LABELS[toolConfigKey]} plugin`;
|
|
60353
|
+
for (const [event, definitions] of Object.entries(configHooks)) {
|
|
60354
|
+
if (event === "preToolUse" || !supportedEvents.includes(event)) continue;
|
|
60355
|
+
const blocking = ALWAYS_BLOCKING_EVENTS.has(event);
|
|
60356
|
+
for (const def of definitions) {
|
|
60357
|
+
if (def.failClosed !== !blocking) continue;
|
|
60358
|
+
logger?.warn(blocking ? `failClosed: false on "${event}" hook will be ignored — ${plugin} always blocks the action when this hook fails or times out, and only supports failClosed on preToolUse` : `failClosed on "${event}" hook will be ignored — ${plugin} only supports failClosed on preToolUse`);
|
|
60359
|
+
}
|
|
60360
|
+
}
|
|
60361
|
+
}
|
|
60362
|
+
/** The per-canonical-event gates and payload every handler of it carries. */
|
|
59732
60363
|
function handlerExtrasFor(canonicalEvent) {
|
|
59733
60364
|
const shellGate = SHELL_EVENT_TOOL_GATES[canonicalEvent];
|
|
59734
60365
|
const propertyGate = GENERIC_EVENT_PROPERTY_GATES[canonicalEvent];
|
|
59735
|
-
const
|
|
60366
|
+
const payload = shellGate ? void 0 : STDIN_PAYLOADS[canonicalEvent];
|
|
59736
60367
|
return {
|
|
60368
|
+
event: canonicalEvent,
|
|
59737
60369
|
...shellGate ? { toolGate: shellGate.tool } : {},
|
|
59738
60370
|
...propertyGate ? { propertyGate } : {},
|
|
59739
|
-
...
|
|
60371
|
+
...payload ? { payload } : {}
|
|
59740
60372
|
};
|
|
59741
60373
|
}
|
|
59742
60374
|
/**
|
|
@@ -59749,7 +60381,8 @@ function collectOpencodeStyleHandlers({ effectiveHooks, eventMap, namedEventHand
|
|
|
59749
60381
|
const extras = handlerExtrasFor(canonicalEvent);
|
|
59750
60382
|
const toolEvent = shellGate?.toolEvent ?? eventMap[canonicalEvent];
|
|
59751
60383
|
if (!toolEvent) continue;
|
|
59752
|
-
const
|
|
60384
|
+
const isNamedHook = Object.hasOwn(NAMED_HOOK_MATCHER_SUBJECTS, toolEvent);
|
|
60385
|
+
const matcherSupported = !shellGate && isNamedHook && NAMED_HOOK_MATCHER_SUBJECTS[toolEvent] !== null;
|
|
59753
60386
|
const handlers = [];
|
|
59754
60387
|
for (const def of definitions) {
|
|
59755
60388
|
if ((def.type ?? "command") !== "command") continue;
|
|
@@ -59758,11 +60391,14 @@ function collectOpencodeStyleHandlers({ effectiveHooks, eventMap, namedEventHand
|
|
|
59758
60391
|
handlers.push({
|
|
59759
60392
|
command: def.command,
|
|
59760
60393
|
matcher: def.matcher ? def.matcher : void 0,
|
|
60394
|
+
blocking: BLOCKING_HOOKS.has(toolEvent),
|
|
60395
|
+
...hookTimingOf(def),
|
|
60396
|
+
inProcess: !isNamedHook,
|
|
59761
60397
|
...extras
|
|
59762
60398
|
});
|
|
59763
60399
|
}
|
|
59764
60400
|
if (handlers.length > 0) {
|
|
59765
|
-
const grouped =
|
|
60401
|
+
const grouped = isNamedHook ? namedEventHandlers : genericEventHandlers;
|
|
59766
60402
|
const existing = grouped[toolEvent];
|
|
59767
60403
|
if (existing) existing.push(...handlers);
|
|
59768
60404
|
else grouped[toolEvent] = handlers;
|
|
@@ -59778,13 +60414,17 @@ function buildGenericEventBodyLines(genericEventHandlers) {
|
|
|
59778
60414
|
for (const [eventName, handlers] of Object.entries(genericEventHandlers)) {
|
|
59779
60415
|
bodyLines.push(` ${isFirst ? "if" : "else if"} (event.type === "${eventName}") {`);
|
|
59780
60416
|
isFirst = false;
|
|
60417
|
+
for (const line of buildPayloadClosureLines({
|
|
60418
|
+
handlers,
|
|
60419
|
+
cwdExpression: V1_CWD_EXPRESSION
|
|
60420
|
+
})) bodyLines.push(` ${line}`);
|
|
59781
60421
|
for (const handler of handlers) {
|
|
59782
|
-
const
|
|
60422
|
+
const runStatement = buildRunStatement(handler);
|
|
59783
60423
|
if (handler.propertyGate) {
|
|
59784
60424
|
bodyLines.push(` if (${handler.propertyGate}) {`);
|
|
59785
|
-
bodyLines.push(`
|
|
60425
|
+
bodyLines.push(` ${runStatement}`);
|
|
59786
60426
|
bodyLines.push(" }");
|
|
59787
|
-
} else bodyLines.push(`
|
|
60427
|
+
} else bodyLines.push(` ${runStatement}`);
|
|
59788
60428
|
}
|
|
59789
60429
|
bodyLines.push(" }");
|
|
59790
60430
|
}
|
|
@@ -59794,39 +60434,61 @@ function buildGenericEventBodyLines(genericEventHandlers) {
|
|
|
59794
60434
|
function stdinPayloadVariable(stdinEvent) {
|
|
59795
60435
|
return `__rulesync${stdinEvent}Input`;
|
|
59796
60436
|
}
|
|
60437
|
+
/** The `cwd` a V1 payload reports: the session directory, else the process's. */
|
|
60438
|
+
const V1_CWD_EXPRESSION = "directory ?? process.cwd()";
|
|
60439
|
+
/** Lazily serialized closures for the payloads the handlers use (internal tables only). */
|
|
60440
|
+
function buildPayloadClosureLines({ handlers, cwdExpression }) {
|
|
60441
|
+
const payloads = /* @__PURE__ */ new Map();
|
|
60442
|
+
for (const handler of handlers) if (handler.payload) payloads.set(handler.payload.name, handler.payload);
|
|
60443
|
+
const lines = [];
|
|
60444
|
+
for (const payload of payloads.values()) {
|
|
60445
|
+
const variable = stdinPayloadVariable(payload.name);
|
|
60446
|
+
lines.push(`let ${variable}Cache;`, `const ${variable} = () =>`);
|
|
60447
|
+
lines.push(` (${variable}Cache ??= JSON.stringify({`);
|
|
60448
|
+
lines.push(` hook_event_name: "${payload.name}",`);
|
|
60449
|
+
lines.push(...payload.fields.map((field) => ` ${field},`));
|
|
60450
|
+
lines.push(` cwd: ${cwdExpression},`, " }));");
|
|
60451
|
+
}
|
|
60452
|
+
return lines;
|
|
60453
|
+
}
|
|
59797
60454
|
/**
|
|
59798
|
-
* The statement that runs a handler's command
|
|
59799
|
-
*
|
|
59800
|
-
*
|
|
60455
|
+
* The statement that runs a handler's command with its stdin payload, or an
|
|
60456
|
+
* empty stdin. The command keeps the escaping it had in the template literal
|
|
60457
|
+
* earlier versions emitted, so `bun exec` parses the same text.
|
|
59801
60458
|
*/
|
|
59802
60459
|
function buildRunStatement(handler) {
|
|
59803
|
-
const
|
|
59804
|
-
|
|
59805
|
-
|
|
59806
|
-
|
|
59807
|
-
|
|
59808
|
-
|
|
60460
|
+
const command = JSON.stringify(escapeForTemplateLiteral(handler.command));
|
|
60461
|
+
const input = handler.payload ? `${stdinPayloadVariable(handler.payload.name)}()` : "\"\"";
|
|
60462
|
+
if (handler.payload?.name === "PreToolUse") {
|
|
60463
|
+
const failClosed = handler.failClosed === void 0 ? "" : `, ${handler.failClosed}`;
|
|
60464
|
+
return `${PRE_TOOL_USE_RESULT_HELPER}(await __rulesyncRunCommand({ command: ${command}, input: ${input}, seconds: ${handler.timeout} })${failClosed});`;
|
|
60465
|
+
}
|
|
60466
|
+
return `await __rulesyncRunHook({ ${[
|
|
60467
|
+
`label: ${JSON.stringify(handler.event)}`,
|
|
60468
|
+
`command: ${command}`,
|
|
60469
|
+
`input: ${input}`,
|
|
60470
|
+
`blocking: ${handler.blocking}`,
|
|
60471
|
+
`seconds: ${handler.timeout}`,
|
|
60472
|
+
...handler.inProcess ? ["inProcess: true"] : []
|
|
60473
|
+
].join(", ")} });`;
|
|
60474
|
+
}
|
|
60475
|
+
/** The helpers a plugin body defines before its handlers, run in `cwdExpression`. */
|
|
60476
|
+
function buildRunHelperLines({ handlers, cwdExpression }) {
|
|
60477
|
+
if (handlers.length === 0) return [];
|
|
60478
|
+
const usesPreToolUse = handlers.some((handler) => handler.payload?.name === "PreToolUse");
|
|
60479
|
+
return [...buildRunHelperLinesFor(cwdExpression), ...usesPreToolUse ? ["", ...PRE_TOOL_USE_RESULT_HELPER_LINES] : []];
|
|
59809
60480
|
}
|
|
59810
60481
|
/** Emit the named (`tool.execute.*`) handler blocks. */
|
|
59811
60482
|
function buildNamedEventBodyLines(namedEventHandlers) {
|
|
59812
60483
|
const bodyLines = [];
|
|
59813
60484
|
for (const [eventName, handlers] of Object.entries(namedEventHandlers)) {
|
|
59814
60485
|
const matcherSubject = NAMED_HOOK_MATCHER_SUBJECTS[eventName] ?? null;
|
|
59815
|
-
const
|
|
59816
|
-
|
|
59817
|
-
|
|
59818
|
-
|
|
59819
|
-
|
|
59820
|
-
|
|
59821
|
-
bodyLines.push(` (${payload}Cache ??= JSON.stringify({`);
|
|
59822
|
-
bodyLines.push(` hook_event_name: "${stdinEvent}",`);
|
|
59823
|
-
bodyLines.push(" session_id: input.sessionID,");
|
|
59824
|
-
bodyLines.push(" tool_use_id: input.callID,");
|
|
59825
|
-
bodyLines.push(" tool_name: input.tool,");
|
|
59826
|
-
bodyLines.push(" tool_input: output?.args,");
|
|
59827
|
-
bodyLines.push(" cwd: directory ?? process.cwd(),");
|
|
59828
|
-
bodyLines.push(" }));");
|
|
59829
|
-
}
|
|
60486
|
+
const payloadLines = buildPayloadClosureLines({
|
|
60487
|
+
handlers,
|
|
60488
|
+
cwdExpression: V1_CWD_EXPRESSION
|
|
60489
|
+
});
|
|
60490
|
+
bodyLines.push(` "${eventName}": async (${payloadLines.length > 0 ? "input, output" : "input"}) => {`);
|
|
60491
|
+
bodyLines.push(...payloadLines.map((line) => ` ${line}`));
|
|
59830
60492
|
for (const handler of handlers) {
|
|
59831
60493
|
const runStatement = buildRunStatement(handler);
|
|
59832
60494
|
if (handler.toolGate) {
|
|
@@ -59849,7 +60511,7 @@ function buildNamedEventBodyLines(namedEventHandlers) {
|
|
|
59849
60511
|
}
|
|
59850
60512
|
/** Wrap the handler body lines in the requested export shape. */
|
|
59851
60513
|
function wrapInExportShape({ preambleLines, bodyLines, exportStyle }) {
|
|
59852
|
-
const pluginContextPattern = preambleLines.length > 0 ? "{
|
|
60514
|
+
const pluginContextPattern = preambleLines.length > 0 ? "{ directory }" : "{ $ }";
|
|
59853
60515
|
const lines = [];
|
|
59854
60516
|
if (exportStyle === "default") {
|
|
59855
60517
|
lines.push("export default {");
|
|
@@ -59890,7 +60552,10 @@ function generateOpencodeStylePluginCode(config, supportedEvents, toolConfigKey,
|
|
|
59890
60552
|
});
|
|
59891
60553
|
const bodyLines = [...buildGenericEventBodyLines(genericEventHandlers), ...buildNamedEventBodyLines(namedEventHandlers)];
|
|
59892
60554
|
return wrapInExportShape({
|
|
59893
|
-
preambleLines:
|
|
60555
|
+
preambleLines: buildRunHelperLines({
|
|
60556
|
+
handlers: [...Object.values(namedEventHandlers), ...Object.values(genericEventHandlers)].flat(),
|
|
60557
|
+
cwdExpression: V1_CWD_EXPRESSION
|
|
60558
|
+
}),
|
|
59894
60559
|
bodyLines,
|
|
59895
60560
|
exportStyle
|
|
59896
60561
|
}).join("\n");
|
|
@@ -59924,8 +60589,15 @@ var KiloHooks = class KiloHooks extends ToolHooks {
|
|
|
59924
60589
|
validate
|
|
59925
60590
|
});
|
|
59926
60591
|
}
|
|
59927
|
-
static fromRulesyncHooks({ outputRoot = process.cwd(), rulesyncHooks, validate = true, global = false }) {
|
|
59928
|
-
const
|
|
60592
|
+
static fromRulesyncHooks({ outputRoot = process.cwd(), rulesyncHooks, validate = true, global = false, logger }) {
|
|
60593
|
+
const config = rulesyncHooks.getJson();
|
|
60594
|
+
warnIgnoredFailClosed({
|
|
60595
|
+
config,
|
|
60596
|
+
supportedEvents: KILO_HOOK_EVENTS,
|
|
60597
|
+
toolConfigKey: "kilo",
|
|
60598
|
+
logger
|
|
60599
|
+
});
|
|
60600
|
+
const fileContent = generateOpencodeStylePluginCode(config, KILO_HOOK_EVENTS, "kilo", CANONICAL_TO_KILO_EVENT_NAMES, "default");
|
|
59929
60601
|
const paths = KiloHooks.getSettablePaths({ global });
|
|
59930
60602
|
return new KiloHooks({
|
|
59931
60603
|
outputRoot,
|
|
@@ -60133,7 +60805,7 @@ var KimiCodeHooks = class KimiCodeHooks extends ToolHooks {
|
|
|
60133
60805
|
global: true
|
|
60134
60806
|
});
|
|
60135
60807
|
}
|
|
60136
|
-
toRulesyncHooks() {
|
|
60808
|
+
toRulesyncHooks({ logger } = {}) {
|
|
60137
60809
|
const config = parseSharedConfig({
|
|
60138
60810
|
format: "toml",
|
|
60139
60811
|
fileContent: this.getFileContent()
|
|
@@ -60146,6 +60818,7 @@ var KimiCodeHooks = class KimiCodeHooks extends ToolHooks {
|
|
|
60146
60818
|
relativeDirPath: RULESYNC_RELATIVE_DIR_PATH,
|
|
60147
60819
|
relativeFilePath: RULESYNC_HOOKS_FILE_NAME,
|
|
60148
60820
|
fileContent: JSON.stringify(buildImportedHooksConfig({
|
|
60821
|
+
logger,
|
|
60149
60822
|
hooks: kimiCodeHooksToCanonical(config.hooks),
|
|
60150
60823
|
overrideKey: "kimi-code"
|
|
60151
60824
|
}), null, 2)
|
|
@@ -60370,12 +61043,13 @@ var KiroIdeHooks = class extends ToolHooks {
|
|
|
60370
61043
|
validate
|
|
60371
61044
|
});
|
|
60372
61045
|
}
|
|
60373
|
-
toRulesyncHooks() {
|
|
61046
|
+
toRulesyncHooks({ logger } = {}) {
|
|
60374
61047
|
const hooks = kiroIdeHooksToCanonical(this.parseFileContentOrThrow({
|
|
60375
61048
|
displayName: "Kiro IDE",
|
|
60376
61049
|
parse: (fileContent) => KiroIdeHooksFileSchema.parse(JSON.parse(fileContent))
|
|
60377
61050
|
}).hooks ?? []);
|
|
60378
61051
|
return this.toRulesyncHooksDefault({ fileContent: JSON.stringify(buildImportedHooksConfig({
|
|
61052
|
+
logger,
|
|
60379
61053
|
hooks,
|
|
60380
61054
|
overrideKey: KIRO_HOOKS_OVERRIDE_KEY
|
|
60381
61055
|
}), null, 2) });
|
|
@@ -60560,12 +61234,13 @@ var KiroHooks = class KiroHooks extends ToolHooks {
|
|
|
60560
61234
|
validate
|
|
60561
61235
|
});
|
|
60562
61236
|
}
|
|
60563
|
-
toRulesyncHooks() {
|
|
61237
|
+
toRulesyncHooks({ logger } = {}) {
|
|
60564
61238
|
const hooks = kiroHooksToCanonical(this.parseFileContentOrThrow({
|
|
60565
61239
|
displayName: "Kiro",
|
|
60566
61240
|
parse: (fileContent) => JSON.parse(fileContent)
|
|
60567
61241
|
}).hooks);
|
|
60568
61242
|
return this.toRulesyncHooksDefault({ fileContent: JSON.stringify(buildImportedHooksConfig({
|
|
61243
|
+
logger,
|
|
60569
61244
|
hooks,
|
|
60570
61245
|
overrideKey: "kiro"
|
|
60571
61246
|
}), null, 2) });
|
|
@@ -60719,6 +61394,7 @@ var LettacodeHooks = class LettacodeHooks extends ToolHooks {
|
|
|
60719
61394
|
converterConfig: LETTACODE_CONVERTER_CONFIG
|
|
60720
61395
|
});
|
|
60721
61396
|
return this.toRulesyncHooksDefault({ fileContent: JSON.stringify(buildImportedHooksConfig({
|
|
61397
|
+
logger,
|
|
60722
61398
|
hooks,
|
|
60723
61399
|
overrideKey: "lettacode"
|
|
60724
61400
|
}), null, 2) });
|
|
@@ -60737,10 +61413,7 @@ var LettacodeHooks = class LettacodeHooks extends ToolHooks {
|
|
|
60737
61413
|
* option; the per-type checks inside the loop stay, so an older 2.x that
|
|
60738
61414
|
* ignores it still runs each command only for its own event).
|
|
60739
61415
|
*
|
|
60740
|
-
* Commands run
|
|
60741
|
-
* plugin runs inside the Bun-built OpenCode binary) whose working directory is
|
|
60742
|
-
* the plugin location's directory, so the global `Bun.$` defaults other
|
|
60743
|
-
* plugins see are left alone.
|
|
61416
|
+
* Commands run in the plugin location's directory (see `buildRunHelperLines`).
|
|
60744
61417
|
*
|
|
60745
61418
|
* @see https://opencode.ai/v2/docs/build/plugins/
|
|
60746
61419
|
*/
|
|
@@ -60763,13 +61436,33 @@ const OPENCODE_V2_HANDLER_GATES = {
|
|
|
60763
61436
|
permissionDenied: "event.data?.reply === \"reject\""
|
|
60764
61437
|
};
|
|
60765
61438
|
/**
|
|
60766
|
-
*
|
|
60767
|
-
*
|
|
60768
|
-
* `execute.before` hook fails the tool call with the error message, which the
|
|
60769
|
-
* model sees — the same contract the V1 plugin implements, interpreted by the
|
|
60770
|
-
* shared `PRE_TOOL_USE_RESULT_HELPER`.
|
|
61439
|
+
* The V2 counterparts of the V1 stdin payloads (`STDIN_PAYLOADS`), plus
|
|
61440
|
+
* Claude Code's `PostToolUseFailure` input for a failed call.
|
|
60771
61441
|
*/
|
|
60772
|
-
const
|
|
61442
|
+
const TOOL_CALL_FIELDS = [
|
|
61443
|
+
"session_id: event.sessionID",
|
|
61444
|
+
"tool_use_id: event.id",
|
|
61445
|
+
"tool_name: event.tool",
|
|
61446
|
+
"tool_input: event.input"
|
|
61447
|
+
];
|
|
61448
|
+
const OPENCODE_V2_STDIN_PAYLOADS = {
|
|
61449
|
+
preToolUse: {
|
|
61450
|
+
name: "PreToolUse",
|
|
61451
|
+
fields: TOOL_CALL_FIELDS
|
|
61452
|
+
},
|
|
61453
|
+
postToolUse: {
|
|
61454
|
+
name: "PostToolUse",
|
|
61455
|
+
fields: [...TOOL_CALL_FIELDS, "tool_response: event.result"]
|
|
61456
|
+
},
|
|
61457
|
+
postToolUseFailure: {
|
|
61458
|
+
name: "PostToolUseFailure",
|
|
61459
|
+
fields: [...TOOL_CALL_FIELDS, "error: event.error?.message ?? event.error"]
|
|
61460
|
+
},
|
|
61461
|
+
stop: {
|
|
61462
|
+
name: "Stop",
|
|
61463
|
+
fields: ["session_id: event.data?.sessionID"]
|
|
61464
|
+
}
|
|
61465
|
+
};
|
|
60773
61466
|
/**
|
|
60774
61467
|
* Helper the generated plugin defines when a handler has a matcher. A matcher
|
|
60775
61468
|
* is tested against the V2 tool name and, for a tool OpenCode 2.x renamed,
|
|
@@ -60806,28 +61499,21 @@ function buildHookRegistrationLines(hookPoint, handlers) {
|
|
|
60806
61499
|
const lines = [];
|
|
60807
61500
|
lines.push("__rulesyncRegistrations.push(");
|
|
60808
61501
|
lines.push(` await ctx.${domain}.hook("${name}", async (event) => {`);
|
|
60809
|
-
|
|
60810
|
-
|
|
60811
|
-
|
|
60812
|
-
|
|
60813
|
-
lines.push(` const ${payload} = () =>`);
|
|
60814
|
-
lines.push(` (${payload}Cache ??= JSON.stringify({`);
|
|
60815
|
-
lines.push(` hook_event_name: "${stdinEvent}",`);
|
|
60816
|
-
lines.push(" session_id: event.sessionID,");
|
|
60817
|
-
lines.push(" tool_use_id: event.id,");
|
|
60818
|
-
lines.push(" tool_name: event.tool,");
|
|
60819
|
-
lines.push(" tool_input: event.input,");
|
|
60820
|
-
lines.push(" cwd: directory,");
|
|
60821
|
-
lines.push(" }));");
|
|
60822
|
-
}
|
|
61502
|
+
lines.push(...buildPayloadClosureLines({
|
|
61503
|
+
handlers,
|
|
61504
|
+
cwdExpression: "directory"
|
|
61505
|
+
}).map((line) => ` ${line}`));
|
|
60823
61506
|
for (const handler of handlers) lines.push(...wrapInConditions(handler, buildRunStatement(handler), " "));
|
|
60824
61507
|
lines.push(" }),");
|
|
60825
61508
|
lines.push(");");
|
|
60826
61509
|
return lines;
|
|
60827
61510
|
}
|
|
60828
61511
|
/**
|
|
60829
|
-
* Emit the event-stream loop.
|
|
60830
|
-
* a failing
|
|
61512
|
+
* Emit the event-stream loop. Event handlers are non-blocking, so
|
|
61513
|
+
* `__rulesyncRunHook` logs a failing command instead of throwing, and it
|
|
61514
|
+
* neither skips its siblings nor ends the subscription. Each handler also runs
|
|
61515
|
+
* in its own try/catch, so a throw while evaluating its gate or building its
|
|
61516
|
+
* payload, outside `__rulesyncRunHook`, is logged the same way. The
|
|
60831
61517
|
* subscription passes `types` so the server delivers only the handled events.
|
|
60832
61518
|
*/
|
|
60833
61519
|
function buildEventLoopLines(eventHandlers) {
|
|
@@ -60843,11 +61529,16 @@ function buildEventLoopLines(eventHandlers) {
|
|
|
60843
61529
|
for (const [eventType, handlers] of eventHandlers) {
|
|
60844
61530
|
lines.push(` ${isFirst ? "if" : "} else if"} (event.type === "${eventType}") {`);
|
|
60845
61531
|
isFirst = false;
|
|
61532
|
+
lines.push(...buildPayloadClosureLines({
|
|
61533
|
+
handlers,
|
|
61534
|
+
cwdExpression: "directory"
|
|
61535
|
+
}).map((line) => ` ${line}`));
|
|
60846
61536
|
for (const handler of handlers) {
|
|
60847
61537
|
lines.push(" try {");
|
|
60848
61538
|
lines.push(...wrapInConditions(handler, buildRunStatement(handler), " "));
|
|
60849
61539
|
lines.push(" } catch (error) {");
|
|
60850
|
-
|
|
61540
|
+
const message = JSON.stringify(`[rulesync-hooks] ${handler.event} hook failed:`);
|
|
61541
|
+
lines.push(` console.error(${message}, error);`);
|
|
60851
61542
|
lines.push(" }");
|
|
60852
61543
|
}
|
|
60853
61544
|
}
|
|
@@ -60856,10 +61547,17 @@ function buildEventLoopLines(eventHandlers) {
|
|
|
60856
61547
|
lines.push("})().catch(() => {});");
|
|
60857
61548
|
return lines;
|
|
60858
61549
|
}
|
|
61550
|
+
/**
|
|
61551
|
+
* Every hook point but `execute.after` runs before its action, which a throw
|
|
61552
|
+
* aborts; the event stream only observes.
|
|
61553
|
+
*/
|
|
61554
|
+
function isBlockingOpencodeV2Target(target) {
|
|
61555
|
+
return !target.startsWith("event:") && target !== "tool:execute.after";
|
|
61556
|
+
}
|
|
60859
61557
|
/** Build the handlers of one canonical event's command definitions. */
|
|
60860
61558
|
function buildHandlersFor({ canonicalEvent, definitions, target }) {
|
|
60861
61559
|
const gate = OPENCODE_V2_HANDLER_GATES[canonicalEvent];
|
|
60862
|
-
const
|
|
61560
|
+
const payload = OPENCODE_V2_STDIN_PAYLOADS[canonicalEvent];
|
|
60863
61561
|
const matcherSupported = !(canonicalEvent === "beforeShellExecution" || canonicalEvent === "afterShellExecution") && OPENCODE_V2_MATCHABLE_HOOKS.has(target);
|
|
60864
61562
|
const handlers = [];
|
|
60865
61563
|
for (const def of definitions) {
|
|
@@ -60868,9 +61566,12 @@ function buildHandlersFor({ canonicalEvent, definitions, target }) {
|
|
|
60868
61566
|
if (def.matcher && !matcherSupported) continue;
|
|
60869
61567
|
handlers.push({
|
|
60870
61568
|
command: def.command,
|
|
61569
|
+
event: canonicalEvent,
|
|
61570
|
+
blocking: isBlockingOpencodeV2Target(target),
|
|
61571
|
+
...hookTimingOf(def),
|
|
60871
61572
|
...def.matcher ? { matcher: def.matcher } : {},
|
|
60872
61573
|
...gate ? { gate } : {},
|
|
60873
|
-
...
|
|
61574
|
+
...payload ? { payload } : {}
|
|
60874
61575
|
});
|
|
60875
61576
|
}
|
|
60876
61577
|
return handlers;
|
|
@@ -60878,13 +61579,14 @@ function buildHandlersFor({ canonicalEvent, definitions, target }) {
|
|
|
60878
61579
|
/** Emit the statements of the `setup` function body. */
|
|
60879
61580
|
function buildSetupBodyLines({ hookHandlers, eventHandlers }) {
|
|
60880
61581
|
if (hookHandlers.size === 0 && eventHandlers.size === 0) return [];
|
|
60881
|
-
const usesStdinPayload = [...hookHandlers.values()].some((handlers) => handlers.some((handler) => handler.stdinEvent !== void 0));
|
|
60882
61582
|
const body = [
|
|
60883
61583
|
"const directory = ctx.location?.directory ?? process.cwd();",
|
|
60884
|
-
"
|
|
60885
|
-
|
|
61584
|
+
"",
|
|
61585
|
+
...buildRunHelperLines({
|
|
61586
|
+
handlers: [...hookHandlers.values(), ...eventHandlers.values()].flat(),
|
|
61587
|
+
cwdExpression: "directory"
|
|
61588
|
+
})
|
|
60886
61589
|
];
|
|
60887
|
-
if (usesStdinPayload) body.push("", ...PRE_TOOL_USE_RESULT_HELPER_LINES);
|
|
60888
61590
|
if ([...hookHandlers.values()].some((handlers) => handlers.some((handler) => handler.matcher !== void 0))) body.push("", ...TOOL_MATCHER_HELPER_LINES);
|
|
60889
61591
|
const cleanup = [];
|
|
60890
61592
|
if (hookHandlers.size > 0) {
|
|
@@ -60957,8 +61659,14 @@ var OpencodeHooks = class extends ToolHooks {
|
|
|
60957
61659
|
validate
|
|
60958
61660
|
});
|
|
60959
61661
|
}
|
|
60960
|
-
static fromRulesyncHooks({ outputRoot = process.cwd(), rulesyncHooks, validate = true, global = false }) {
|
|
61662
|
+
static fromRulesyncHooks({ outputRoot = process.cwd(), rulesyncHooks, validate = true, global = false, logger }) {
|
|
60961
61663
|
const config = rulesyncHooks.getJson();
|
|
61664
|
+
warnIgnoredFailClosed({
|
|
61665
|
+
config,
|
|
61666
|
+
supportedEvents: this.layout.configVersion === "v2" ? OPENCODE_V2_HOOK_EVENTS : OPENCODE_HOOK_EVENTS,
|
|
61667
|
+
toolConfigKey: this.layout.toolTarget,
|
|
61668
|
+
logger
|
|
61669
|
+
});
|
|
60962
61670
|
const fileContent = this.layout.configVersion === "v2" ? generateOpencodeV2PluginCode({
|
|
60963
61671
|
config,
|
|
60964
61672
|
supportedEvents: OPENCODE_V2_HOOK_EVENTS,
|
|
@@ -61711,9 +62419,10 @@ var PoolHooks = class PoolHooks extends ToolHooks {
|
|
|
61711
62419
|
global
|
|
61712
62420
|
});
|
|
61713
62421
|
}
|
|
61714
|
-
toRulesyncHooks() {
|
|
62422
|
+
toRulesyncHooks({ logger } = {}) {
|
|
61715
62423
|
const hooks = poolHooksToCanonical(this.settings[POOL_HOOKS_KEY]);
|
|
61716
62424
|
return this.toRulesyncHooksDefault({ fileContent: JSON.stringify(buildImportedHooksConfig({
|
|
62425
|
+
logger,
|
|
61717
62426
|
hooks,
|
|
61718
62427
|
overrideKey: "pool"
|
|
61719
62428
|
}), null, 2) });
|
|
@@ -62110,12 +62819,13 @@ var QwencodeHooks = class QwencodeHooks extends ToolHooks {
|
|
|
62110
62819
|
static supportsPreserveUnowned() {
|
|
62111
62820
|
return true;
|
|
62112
62821
|
}
|
|
62113
|
-
toRulesyncHooks() {
|
|
62822
|
+
toRulesyncHooks({ logger } = {}) {
|
|
62114
62823
|
const settings = this.parseFileContentOrThrow({
|
|
62115
62824
|
displayName: "Qwen Code",
|
|
62116
62825
|
parse: (fileContent) => JSON.parse(fileContent)
|
|
62117
62826
|
});
|
|
62118
62827
|
const canonical = buildImportedHooksConfig({
|
|
62828
|
+
logger,
|
|
62119
62829
|
hooks: qwencodeHooksToCanonical(settings.hooks),
|
|
62120
62830
|
overrideKey: "qwencode",
|
|
62121
62831
|
...typeof settings.disableAllHooks === "boolean" && { extraOverride: { disableAllHooks: settings.disableAllHooks } }
|
|
@@ -62320,12 +63030,13 @@ var ReasonixHooks = class ReasonixHooks extends ToolHooks {
|
|
|
62320
63030
|
validate
|
|
62321
63031
|
});
|
|
62322
63032
|
}
|
|
62323
|
-
toRulesyncHooks() {
|
|
63033
|
+
toRulesyncHooks({ logger } = {}) {
|
|
62324
63034
|
const hooks = reasonixHooksToCanonical(this.parseFileContentOrThrow({
|
|
62325
63035
|
displayName: "Reasonix",
|
|
62326
63036
|
parse: (fileContent) => JSON.parse(fileContent)
|
|
62327
63037
|
}).hooks);
|
|
62328
63038
|
return this.toRulesyncHooksDefault({ fileContent: JSON.stringify(buildImportedHooksConfig({
|
|
63039
|
+
logger,
|
|
62329
63040
|
hooks,
|
|
62330
63041
|
overrideKey: "reasonix"
|
|
62331
63042
|
}), null, 2) });
|
|
@@ -62550,13 +63261,14 @@ var TabnineHooks = class TabnineHooks extends ToolHooks {
|
|
|
62550
63261
|
validate
|
|
62551
63262
|
});
|
|
62552
63263
|
}
|
|
62553
|
-
toRulesyncHooks() {
|
|
63264
|
+
toRulesyncHooks({ logger } = {}) {
|
|
62554
63265
|
const configPath = join(this.getRelativeDirPath(), this.getRelativeFilePath());
|
|
62555
63266
|
const hooks = tabnineHooksToCanonical(this.parseFileContentOrThrow({
|
|
62556
63267
|
displayName: "Tabnine CLI",
|
|
62557
63268
|
parse: (fileContent) => parseTabnineSettings(fileContent, configPath)
|
|
62558
63269
|
}).hooks);
|
|
62559
63270
|
return this.toRulesyncHooksDefault({ fileContent: JSON.stringify(buildImportedHooksConfig({
|
|
63271
|
+
logger,
|
|
62560
63272
|
hooks,
|
|
62561
63273
|
overrideKey: "tabnine"
|
|
62562
63274
|
}), null, 2) });
|
|
@@ -62621,13 +63333,31 @@ var TraeHooks = class extends SettingsJsonHooks {
|
|
|
62621
63333
|
const VIBE_DIR = ".vibe";
|
|
62622
63334
|
const VIBE_HOOKS_FILE_NAME = "hooks.toml";
|
|
62623
63335
|
/**
|
|
62624
|
-
* Vibe scopes the tool-name `match` glob
|
|
62625
|
-
*
|
|
62626
|
-
*
|
|
62627
|
-
*
|
|
62628
|
-
*
|
|
63336
|
+
* Vibe scopes the tool-name `match` glob to tool hooks (`pre_tool` /
|
|
63337
|
+
* `post_tool`). The other events take a `match` too, on something other than a
|
|
63338
|
+
* tool name: the agent whose turn it is on `post_agent` / `pre_agent` /
|
|
63339
|
+
* `pre_llm` / `post_llm`, and the source, reason or notification type on
|
|
63340
|
+
* `session_start` / `session_end` / `notification`.
|
|
63341
|
+
* @see https://github.com/mistralai/mistral-vibe/blob/v3.1.3/vibe/plugins/builtins/vibe/skills/vibe/SKILL.md
|
|
62629
63342
|
*/
|
|
62630
63343
|
const VIBE_TOOL_EVENTS = /* @__PURE__ */ new Set(["pre_tool", "post_tool"]);
|
|
63344
|
+
/**
|
|
63345
|
+
* The events where a failing hook may block, and so the only ones that accept
|
|
63346
|
+
* `strict`. Vibe's `HookConfig` validator rejects a `strict` entry of any
|
|
63347
|
+
* other type.
|
|
63348
|
+
* @see https://github.com/mistralai/mistral-vibe/blob/v3.1.3/vibe/core/hooks/models.py
|
|
63349
|
+
*/
|
|
63350
|
+
const VIBE_STRICT_EVENTS = /* @__PURE__ */ new Set([
|
|
63351
|
+
"pre_tool",
|
|
63352
|
+
"post_tool",
|
|
63353
|
+
"pre_agent",
|
|
63354
|
+
"pre_llm",
|
|
63355
|
+
"post_llm"
|
|
63356
|
+
]);
|
|
63357
|
+
/** The canonical matcher for a `pre_agent` hook that runs for every agent. */
|
|
63358
|
+
const VIBE_ANY_AGENT_MATCHER = "*";
|
|
63359
|
+
/** The Vibe event canonical `beforeSubmitPrompt` becomes. */
|
|
63360
|
+
const VIBE_PRE_AGENT_EVENT = "pre_agent";
|
|
62631
63361
|
/** The Vibe event both canonical `stop` and `subagentStop` become. */
|
|
62632
63362
|
const VIBE_POST_AGENT_EVENT = "post_agent";
|
|
62633
63363
|
/**
|
|
@@ -62675,11 +63405,69 @@ function fromVibeHookMatch(match) {
|
|
|
62675
63405
|
return match.toLowerCase() === VIBE_SHELL_HOOK_MATCH ? "Bash" : match;
|
|
62676
63406
|
}
|
|
62677
63407
|
/**
|
|
63408
|
+
* The `match` for an event whose matcher is not a tool name, or `undefined`
|
|
63409
|
+
* when the canonical matcher selects everything.
|
|
63410
|
+
*/
|
|
63411
|
+
function toVibeOptionalMatch(matcher) {
|
|
63412
|
+
if (typeof matcher !== "string" || matcher === "" || matcher === "*") return;
|
|
63413
|
+
return matcher;
|
|
63414
|
+
}
|
|
63415
|
+
/**
|
|
63416
|
+
* The `match` of the Vibe entry a canonical hook becomes: a string, `undefined`
|
|
63417
|
+
* to leave the key out, or null to skip the hook.
|
|
63418
|
+
*/
|
|
63419
|
+
function toVibeEntryMatch({ event, vibeEvent, matcher, logger }) {
|
|
63420
|
+
if (VIBE_TOOL_EVENTS.has(vibeEvent)) return toVibeHookMatch(matcher);
|
|
63421
|
+
if (event === "subagentStop") return toVibeSubagentMatch({
|
|
63422
|
+
matcher,
|
|
63423
|
+
logger
|
|
63424
|
+
});
|
|
63425
|
+
if (vibeEvent === VIBE_POST_AGENT_EVENT) return VIBE_MAIN_AGENT_MATCH;
|
|
63426
|
+
if (vibeEvent === VIBE_PRE_AGENT_EVENT) {
|
|
63427
|
+
if (typeof matcher !== "string" || matcher === "") return VIBE_MAIN_AGENT_MATCH;
|
|
63428
|
+
return toVibeOptionalMatch(matcher);
|
|
63429
|
+
}
|
|
63430
|
+
return toVibeOptionalMatch(matcher);
|
|
63431
|
+
}
|
|
63432
|
+
/**
|
|
63433
|
+
* The canonical event and matcher a Vibe entry's `type` and `match` become.
|
|
63434
|
+
*/
|
|
63435
|
+
function fromVibeEntryMatch({ vibeEvent, canonicalEvent, match }) {
|
|
63436
|
+
if (VIBE_TOOL_EVENTS.has(vibeEvent)) return {
|
|
63437
|
+
canonicalEvent,
|
|
63438
|
+
matcher: fromVibeHookMatch(match)
|
|
63439
|
+
};
|
|
63440
|
+
const optionalMatch = toVibeOptionalMatch(match);
|
|
63441
|
+
const isMainAgent = optionalMatch === void 0 || optionalMatch.toLowerCase() === VIBE_MAIN_AGENT_MATCH;
|
|
63442
|
+
if (vibeEvent === VIBE_POST_AGENT_EVENT) return isMainAgent ? {
|
|
63443
|
+
canonicalEvent,
|
|
63444
|
+
matcher: void 0
|
|
63445
|
+
} : {
|
|
63446
|
+
canonicalEvent: "subagentStop",
|
|
63447
|
+
matcher: optionalMatch
|
|
63448
|
+
};
|
|
63449
|
+
if (vibeEvent === VIBE_PRE_AGENT_EVENT) {
|
|
63450
|
+
if (optionalMatch === void 0) return {
|
|
63451
|
+
canonicalEvent,
|
|
63452
|
+
matcher: VIBE_ANY_AGENT_MATCHER
|
|
63453
|
+
};
|
|
63454
|
+
return {
|
|
63455
|
+
canonicalEvent,
|
|
63456
|
+
matcher: isMainAgent ? void 0 : optionalMatch
|
|
63457
|
+
};
|
|
63458
|
+
}
|
|
63459
|
+
return {
|
|
63460
|
+
canonicalEvent,
|
|
63461
|
+
matcher: optionalMatch
|
|
63462
|
+
};
|
|
63463
|
+
}
|
|
63464
|
+
/**
|
|
62678
63465
|
* Build the flat `[[hooks]]` array for `.vibe/hooks.toml` from a canonical
|
|
62679
63466
|
* hooks config. Vibe uses a flat array where each entry carries its own event
|
|
62680
|
-
* `type`, `match` glob/regex (a tool name for tool hooks, an agent name
|
|
62681
|
-
*
|
|
62682
|
-
*
|
|
63467
|
+
* `type`, `match` glob/regex (a tool name for tool hooks, an agent name for
|
|
63468
|
+
* `post_agent` / `pre_agent` / `pre_llm` / `post_llm`, a source, reason or
|
|
63469
|
+
* notification type for the session and notification hooks), and `command`.
|
|
63470
|
+
* Only `type: "command"` canonical hooks are emitted: a Vibe hook is a shell command line. (v2.25.1
|
|
62683
63471
|
* to v2.25.4 briefly exec'd it without a shell under the unified harness and
|
|
62684
63472
|
* skipped any command containing a backslash; v2.25.5 restored shell
|
|
62685
63473
|
* execution — "Hook commands using pipes, `&&`, redirects, globs or `$VAR`
|
|
@@ -62704,27 +63492,23 @@ function canonicalToVibeHooks({ config, toolOverride, logger }) {
|
|
|
62704
63492
|
for (const def of defs) {
|
|
62705
63493
|
if ((def.type ?? "command") !== "command") continue;
|
|
62706
63494
|
if (typeof def.command !== "string") continue;
|
|
62707
|
-
const
|
|
62708
|
-
|
|
62709
|
-
|
|
62710
|
-
|
|
62711
|
-
|
|
62712
|
-
|
|
62713
|
-
|
|
62714
|
-
});
|
|
62715
|
-
if (subagentMatch === null) continue;
|
|
62716
|
-
match = subagentMatch;
|
|
62717
|
-
} else match = VIBE_MAIN_AGENT_MATCH;
|
|
63495
|
+
const match = toVibeEntryMatch({
|
|
63496
|
+
event,
|
|
63497
|
+
vibeEvent,
|
|
63498
|
+
matcher: def.matcher,
|
|
63499
|
+
logger
|
|
63500
|
+
});
|
|
63501
|
+
if (match === null) continue;
|
|
62718
63502
|
const index = nextIndexByVibeEvent.get(vibeEvent) ?? 0;
|
|
62719
63503
|
const entry = {
|
|
62720
63504
|
name: typeof def.name === "string" ? def.name : `${vibeEvent}-${index}`,
|
|
62721
63505
|
type: vibeEvent,
|
|
62722
|
-
match,
|
|
63506
|
+
...match !== void 0 && { match },
|
|
62723
63507
|
command: def.command
|
|
62724
63508
|
};
|
|
62725
63509
|
if (typeof def.timeout === "number") entry.timeout = def.timeout;
|
|
62726
63510
|
const strict = def.strict;
|
|
62727
|
-
if (
|
|
63511
|
+
if (VIBE_STRICT_EVENTS.has(vibeEvent) && typeof strict === "boolean") entry.strict = strict;
|
|
62728
63512
|
if (typeof def.description === "string") entry.description = def.description;
|
|
62729
63513
|
hooks.push(entry);
|
|
62730
63514
|
nextIndexByVibeEvent.set(vibeEvent, index + 1);
|
|
@@ -62739,22 +63523,22 @@ function vibeEntryToCanonicalDef(raw) {
|
|
|
62739
63523
|
const vibeEvent = typeof entry.type === "string" ? entry.type : void 0;
|
|
62740
63524
|
if (vibeEvent === void 0) return null;
|
|
62741
63525
|
if (isPrototypePollutionKey(vibeEvent)) return null;
|
|
62742
|
-
|
|
63526
|
+
const mappedEvent = lookupOwn({
|
|
62743
63527
|
record: VIBE_TO_CANONICAL_EVENT_NAMES,
|
|
62744
63528
|
key: vibeEvent
|
|
62745
63529
|
}) ?? vibeEvent;
|
|
62746
63530
|
const def = { type: "command" };
|
|
62747
63531
|
if (typeof entry.command === "string") def.command = entry.command;
|
|
62748
|
-
|
|
62749
|
-
|
|
62750
|
-
|
|
62751
|
-
|
|
62752
|
-
|
|
62753
|
-
|
|
62754
|
-
|
|
62755
|
-
|
|
62756
|
-
|
|
62757
|
-
|
|
63532
|
+
const resolved = fromVibeEntryMatch({
|
|
63533
|
+
vibeEvent: lookupOwn({
|
|
63534
|
+
record: CANONICAL_TO_VIBE_EVENT_NAMES,
|
|
63535
|
+
key: mappedEvent
|
|
63536
|
+
}) ?? vibeEvent,
|
|
63537
|
+
canonicalEvent: mappedEvent,
|
|
63538
|
+
match: entry.match
|
|
63539
|
+
});
|
|
63540
|
+
const canonicalEvent = resolved.canonicalEvent;
|
|
63541
|
+
if (resolved.matcher !== void 0) def.matcher = resolved.matcher;
|
|
62758
63542
|
if (typeof entry.timeout === "number") def.timeout = entry.timeout;
|
|
62759
63543
|
if (typeof entry.name === "string") def.name = entry.name;
|
|
62760
63544
|
if (typeof entry.description === "string") def.description = entry.description;
|
|
@@ -62788,22 +63572,55 @@ function vibeHooksToCanonical(parsed) {
|
|
|
62788
63572
|
/** Vibe reads a `match` with a `re:` prefix or glob metacharacters as a pattern. */
|
|
62789
63573
|
const VIBE_PATTERN_MATCH = /^re:|[*?[]/;
|
|
62790
63574
|
/**
|
|
62791
|
-
*
|
|
62792
|
-
* them
|
|
62793
|
-
*
|
|
62794
|
-
*
|
|
62795
|
-
*
|
|
63575
|
+
* The canonical events whose imported hooks are kept Vibe-only once any of
|
|
63576
|
+
* them carries a matcher, with the reason for the warning. Their matcher
|
|
63577
|
+
* selects Vibe agents, which other tools either drop (Claude Code, with a
|
|
63578
|
+
* warning) or read as their own matcher syntax, so a hook scoped to one agent
|
|
63579
|
+
* — or, for `pre_agent`, to every agent including subagents — would fire
|
|
63580
|
+
* everywhere there. A `subagentStop` hook needs a matcher anyway, so only a
|
|
63581
|
+
* pattern (which may also select the main agent) moves it.
|
|
63582
|
+
*/
|
|
63583
|
+
const VIBE_ONLY_AGENT_SCOPED_EVENTS = [
|
|
63584
|
+
{
|
|
63585
|
+
event: "subagentStop",
|
|
63586
|
+
vibeEvent: "post_agent",
|
|
63587
|
+
isVibeOnly: (matcher) => VIBE_PATTERN_MATCH.test(matcher)
|
|
63588
|
+
},
|
|
63589
|
+
{
|
|
63590
|
+
event: "beforeSubmitPrompt",
|
|
63591
|
+
vibeEvent: "pre_agent",
|
|
63592
|
+
isVibeOnly: () => true
|
|
63593
|
+
},
|
|
63594
|
+
{
|
|
63595
|
+
event: "preModelInvocation",
|
|
63596
|
+
vibeEvent: "pre_llm",
|
|
63597
|
+
isVibeOnly: () => true
|
|
63598
|
+
},
|
|
63599
|
+
{
|
|
63600
|
+
event: "postModelInvocation",
|
|
63601
|
+
vibeEvent: "post_llm",
|
|
63602
|
+
isVibeOnly: () => true
|
|
63603
|
+
}
|
|
63604
|
+
];
|
|
63605
|
+
/**
|
|
63606
|
+
* Move the imported hooks of an agent-matched event into the `vibe` override
|
|
63607
|
+
* when any of them is scoped in a way other tools cannot express (see
|
|
63608
|
+
* {@link VIBE_ONLY_AGENT_SCOPED_EVENTS}). The override replaces the shared
|
|
62796
63609
|
* list for its event, so the whole list moves to keep every entry on Vibe.
|
|
62797
63610
|
*/
|
|
62798
|
-
function
|
|
62799
|
-
const
|
|
62800
|
-
|
|
62801
|
-
|
|
62802
|
-
|
|
62803
|
-
|
|
62804
|
-
|
|
62805
|
-
|
|
62806
|
-
|
|
63611
|
+
function takeVibeOnlyAgentScopedHooks({ hooks, logger }) {
|
|
63612
|
+
const taken = {};
|
|
63613
|
+
for (const { event, vibeEvent, isVibeOnly } of VIBE_ONLY_AGENT_SCOPED_EVENTS) {
|
|
63614
|
+
const defs = lookupOwn({
|
|
63615
|
+
record: hooks,
|
|
63616
|
+
key: event
|
|
63617
|
+
});
|
|
63618
|
+
if (defs === void 0 || !defs.some((def) => typeof def.matcher === "string" && isVibeOnly(def.matcher))) continue;
|
|
63619
|
+
delete hooks[event];
|
|
63620
|
+
taken[event] = defs;
|
|
63621
|
+
logger?.warn(`Vibe hooks: a ${vibeEvent} hook is scoped by agent in a way other tools cannot express, so its ${event} hooks are imported into the vibe override instead of the shared hooks.`);
|
|
63622
|
+
}
|
|
63623
|
+
return taken;
|
|
62807
63624
|
}
|
|
62808
63625
|
function parseVibeToml(fileContent) {
|
|
62809
63626
|
const parsed = smolToml.parse(fileContent || smolToml.stringify({}));
|
|
@@ -62855,21 +63672,22 @@ var VibeHooks = class extends ToolHooks {
|
|
|
62855
63672
|
displayName: "Vibe",
|
|
62856
63673
|
parse: (fileContent) => parseVibeToml(fileContent)
|
|
62857
63674
|
}));
|
|
62858
|
-
const
|
|
63675
|
+
const vibeOnly = takeVibeOnlyAgentScopedHooks({
|
|
62859
63676
|
hooks,
|
|
62860
63677
|
logger: options.logger
|
|
62861
63678
|
});
|
|
62862
63679
|
const config = buildImportedHooksConfig({
|
|
63680
|
+
logger: options.logger,
|
|
62863
63681
|
hooks,
|
|
62864
63682
|
overrideKey: "vibe"
|
|
62865
63683
|
});
|
|
62866
|
-
if (
|
|
63684
|
+
if (Object.keys(vibeOnly).length > 0) {
|
|
62867
63685
|
const override = config.vibe ?? {};
|
|
62868
63686
|
config.vibe = {
|
|
62869
63687
|
...override,
|
|
62870
63688
|
hooks: {
|
|
62871
63689
|
...override.hooks,
|
|
62872
|
-
|
|
63690
|
+
...vibeOnly
|
|
62873
63691
|
}
|
|
62874
63692
|
};
|
|
62875
63693
|
}
|
|
@@ -63077,6 +63895,7 @@ var ZcodeHooks = class ZcodeHooks extends ToolHooks {
|
|
|
63077
63895
|
logger
|
|
63078
63896
|
});
|
|
63079
63897
|
return this.toRulesyncHooksDefault({ fileContent: JSON.stringify(buildImportedHooksConfig({
|
|
63898
|
+
logger,
|
|
63080
63899
|
hooks,
|
|
63081
63900
|
overrideKey: "zcode"
|
|
63082
63901
|
}), null, 2) });
|
|
@@ -63161,6 +63980,7 @@ var ZcodePluginHooks = class ZcodePluginHooks extends ToolHooks {
|
|
|
63161
63980
|
logger
|
|
63162
63981
|
});
|
|
63163
63982
|
return this.toRulesyncHooksDefault({ fileContent: JSON.stringify(buildImportedHooksConfig({
|
|
63983
|
+
logger,
|
|
63164
63984
|
hooks,
|
|
63165
63985
|
overrideKey: "zcode"
|
|
63166
63986
|
}), null, 2) });
|
|
@@ -78726,6 +79546,15 @@ const PERMISSION_ACTION_PRIORITY = {
|
|
|
78726
79546
|
deny: 2
|
|
78727
79547
|
};
|
|
78728
79548
|
/**
|
|
79549
|
+
* A pattern map reordered allow, then ask, then deny, keeping the authored
|
|
79550
|
+
* order within each action. A tool that applies the last matching pattern
|
|
79551
|
+
* then lets the strictest matching rule win. `Object.fromEntries` defines own
|
|
79552
|
+
* properties, so even a `__proto__` pattern survives.
|
|
79553
|
+
*/
|
|
79554
|
+
function sortRulesByActionPriority(rules) {
|
|
79555
|
+
return Object.fromEntries(Object.entries(rules).toSorted(([, a], [, b]) => PERMISSION_ACTION_PRIORITY[a] - PERMISSION_ACTION_PRIORITY[b]));
|
|
79556
|
+
}
|
|
79557
|
+
/**
|
|
78729
79558
|
* Whether `action` should replace `existing` when two canonical rules collapse
|
|
78730
79559
|
* onto one entry: an empty slot always takes it, otherwise only a strictly
|
|
78731
79560
|
* stricter action (deny > ask > allow) does.
|
|
@@ -80396,7 +81225,13 @@ function splitUrlPattern(withoutScheme) {
|
|
|
80396
81225
|
* (so an allowed `example.com` overlaps a restricted `*.pdf`), and an overlap
|
|
80397
81226
|
* from any of them counts. A host ending in a DNS root dot (`example.com.`)
|
|
80398
81227
|
* is also compared with one and with all trailing dots removed, in addition
|
|
80399
|
-
* to its original reading, so this only ever adds overlaps.
|
|
81228
|
+
* to its original reading, so this only ever adds overlaps. The allow is also
|
|
81229
|
+
* compared without its userinfo, query and fragment
|
|
81230
|
+
* (`https://user@example.com/x?y=1#z` as `example.com/x`), which name no other
|
|
81231
|
+
* host or path, again in addition to its original reading. Only a `?` or `#`
|
|
81232
|
+
* in the path counts as a query or fragment start there, so a `?` glob in the
|
|
81233
|
+
* host is left alone (one in the path is read as a query start for this extra
|
|
81234
|
+
* reading, which can only add overlaps). A pattern holding
|
|
80400
81235
|
* whitespace names no URL. Callers pass the restriction as `left` and the
|
|
80401
81236
|
* allow as `right`.
|
|
80402
81237
|
*/
|
|
@@ -80419,12 +81254,7 @@ function urlPatternsOverlap(left, right) {
|
|
|
80419
81254
|
*/
|
|
80420
81255
|
function wholeStringsOverlap(left, right) {
|
|
80421
81256
|
const normalizedLeft = normalizeUrlPattern(left);
|
|
80422
|
-
|
|
80423
|
-
return [
|
|
80424
|
-
[left, right],
|
|
80425
|
-
[normalizedLeft, normalizedRight],
|
|
80426
|
-
...normalizedLeft.includes("/") ? [] : [[normalizedLeft, withAnyPath(normalizedRight)]]
|
|
80427
|
-
].some(([restriction = "", allow = ""]) => createShadowingRestrictionsTest([{
|
|
81257
|
+
return [[left, right], ...allowReadings(normalizeUrlPattern(right)).flatMap((normalizedRight) => [[normalizedLeft, normalizedRight], ...normalizedLeft.includes("/") ? [] : [[normalizedLeft, withAnyPath(normalizedRight)]]])].some(([restriction = "", allow = ""]) => createShadowingRestrictionsTest([{
|
|
80428
81258
|
pattern: restriction,
|
|
80429
81259
|
fromAllToolsCategory: false
|
|
80430
81260
|
}])(allow).length > 0);
|
|
@@ -80433,8 +81263,25 @@ function wholeStringsOverlap(left, right) {
|
|
|
80433
81263
|
function withAnyPath(withoutScheme) {
|
|
80434
81264
|
return stripUrlSchemeKeepingPathCase(withoutScheme).includes("/") ? withoutScheme : `${withoutScheme}/*`;
|
|
80435
81265
|
}
|
|
81266
|
+
/**
|
|
81267
|
+
* A scheme-less allow pattern as written, plus (when they differ) the same
|
|
81268
|
+
* pattern without the userinfo before its host and the query and fragment
|
|
81269
|
+
* after its path, so `user:pass@example.com/x?y=1` is also read as
|
|
81270
|
+
* `example.com/x`. A `?` is a single-character glob in Rulesync patterns, so
|
|
81271
|
+
* only a `?` or `#` in the path (after the first `/`) is read as a query or
|
|
81272
|
+
* fragment start; the host keeps it (`git?ub.com` is not cut to `git`). The
|
|
81273
|
+
* original reading stays first, so a caller that ORs the readings only ever
|
|
81274
|
+
* gains overlaps.
|
|
81275
|
+
*/
|
|
81276
|
+
function allowReadings(withoutScheme) {
|
|
81277
|
+
const slash = withoutScheme.indexOf("/");
|
|
81278
|
+
const hostPort = slash === -1 ? withoutScheme : withoutScheme.slice(0, slash);
|
|
81279
|
+
const path = slash === -1 ? "" : withoutScheme.slice(slash).replace(/[?#].*$/s, "");
|
|
81280
|
+
const stripped = `${hostPort.slice(hostPort.lastIndexOf("@") + 1)}${path}`;
|
|
81281
|
+
return stripped === withoutScheme || stripped === "" ? [withoutScheme] : [withoutScheme, stripped];
|
|
81282
|
+
}
|
|
80436
81283
|
function urlPartsOverlap(left, right) {
|
|
80437
|
-
const readings = (pattern) => [.../* @__PURE__ */ new Set([stripUrlSchemeKeepingPathCase(pattern), stripUrlSchemeLoosely(pattern)])].map(splitUrlPattern).flatMap((parts) => parts.host.endsWith(".") ? [
|
|
81284
|
+
const readings = (pattern, { asAllow = false } = {}) => [.../* @__PURE__ */ new Set([stripUrlSchemeKeepingPathCase(pattern), stripUrlSchemeLoosely(pattern)])].flatMap((withoutScheme) => asAllow ? allowReadings(withoutScheme) : [withoutScheme]).map(splitUrlPattern).flatMap((parts) => parts.host.endsWith(".") ? [
|
|
80438
81285
|
parts,
|
|
80439
81286
|
{
|
|
80440
81287
|
...parts,
|
|
@@ -80445,7 +81292,8 @@ function urlPartsOverlap(left, right) {
|
|
|
80445
81292
|
host: parts.host.replace(/\.+$/, "")
|
|
80446
81293
|
}
|
|
80447
81294
|
] : [parts]);
|
|
80448
|
-
|
|
81295
|
+
const allowParts = readings(right, { asAllow: true });
|
|
81296
|
+
return readings(left).some((a) => allowParts.some((b) => urlPartsPairOverlap(a, b)));
|
|
80449
81297
|
}
|
|
80450
81298
|
function urlPartsPairOverlap(a, b) {
|
|
80451
81299
|
const hosts = (host) => [host, `*.${host}`];
|
|
@@ -87514,6 +88362,173 @@ function parseCommandcodeRuleLists(permissions) {
|
|
|
87514
88362
|
return permission;
|
|
87515
88363
|
}
|
|
87516
88364
|
/**
|
|
88365
|
+
* The non-list `permissions` fields rulesync authors through the
|
|
88366
|
+
* `commandcode.permissions` override and imports back. Every other key of the
|
|
88367
|
+
* file's `permissions` object is kept as it is, never written from the source.
|
|
88368
|
+
*/
|
|
88369
|
+
const COMMANDCODE_PERMISSIONS_FIELD_KEYS = [
|
|
88370
|
+
"defaultMode",
|
|
88371
|
+
"additionalDirectories",
|
|
88372
|
+
"disableBypass"
|
|
88373
|
+
];
|
|
88374
|
+
const ACCEPT_EDITS_REASON = "workspace edits and safe filesystem shell commands then run without a prompt";
|
|
88375
|
+
const YOLO_REASON = "every session then starts in permission bypass, where only deny and ask rules still stop a tool";
|
|
88376
|
+
/**
|
|
88377
|
+
* The `permissions.defaultMode` values (aliases included) that start a session
|
|
88378
|
+
* with fewer prompts than `default`. `plan` and `dont-ask` are absent: `plan`
|
|
88379
|
+
* is read-only, and `dont-ask` is a fail-closed allowlist that denies whatever
|
|
88380
|
+
* policy does not already allow, so neither widens anything.
|
|
88381
|
+
*
|
|
88382
|
+
* @see https://commandcode.ai/docs/permissions
|
|
88383
|
+
*/
|
|
88384
|
+
const COMMANDCODE_WIDENING_DEFAULT_MODES = {
|
|
88385
|
+
"accept-edits": ACCEPT_EDITS_REASON,
|
|
88386
|
+
"auto-accept": ACCEPT_EDITS_REASON,
|
|
88387
|
+
acceptEdits: ACCEPT_EDITS_REASON,
|
|
88388
|
+
yolo: YOLO_REASON,
|
|
88389
|
+
bypass: YOLO_REASON,
|
|
88390
|
+
bypassPermissions: YOLO_REASON
|
|
88391
|
+
};
|
|
88392
|
+
/**
|
|
88393
|
+
* How many prompts each documented `defaultMode` (aliases included) removes:
|
|
88394
|
+
* `plan` and `dont-ask` (fail-closed) < `default` < `accept-edits` < `yolo`.
|
|
88395
|
+
* Used to notice an override that replaces a stricter mode already in the file.
|
|
88396
|
+
*/
|
|
88397
|
+
const COMMANDCODE_DEFAULT_MODE_LOOSENESS = {
|
|
88398
|
+
plan: 0,
|
|
88399
|
+
"dont-ask": 0,
|
|
88400
|
+
dontAsk: 0,
|
|
88401
|
+
default: 1,
|
|
88402
|
+
manual: 1,
|
|
88403
|
+
standard: 1,
|
|
88404
|
+
"accept-edits": 2,
|
|
88405
|
+
"auto-accept": 2,
|
|
88406
|
+
acceptEdits: 2,
|
|
88407
|
+
yolo: 3,
|
|
88408
|
+
bypass: 3,
|
|
88409
|
+
bypassPermissions: 3
|
|
88410
|
+
};
|
|
88411
|
+
/**
|
|
88412
|
+
* Command Code resolves settings project-local > project > user-global, and a
|
|
88413
|
+
* scalar from the more specific file overwrites the others (only the rule
|
|
88414
|
+
* lists and `additionalDirectories` union across files). A project-scope
|
|
88415
|
+
* `defaultMode` or `disableBypass` therefore replaces whatever the user set in
|
|
88416
|
+
* `~/.commandcode/settings.json`.
|
|
88417
|
+
*
|
|
88418
|
+
* @see https://commandcode.ai/docs/settings
|
|
88419
|
+
*/
|
|
88420
|
+
const PROJECT_SCALAR_OVERRIDES_GLOBAL = "a project value overrides ~/.commandcode/settings.json, so it also replaces a stricter user-global mode such as dont-ask or plan";
|
|
88421
|
+
/**
|
|
88422
|
+
* The widening entry for a `commandcode.permissions.defaultMode`, or `null`
|
|
88423
|
+
* when it does not widen. A mode that removes prompts always widens; at
|
|
88424
|
+
* project scope so does any mode looser than the strictest ones (`plan`,
|
|
88425
|
+
* `dont-ask`), because it overrides the user-global mode; and so does a mode
|
|
88426
|
+
* looser than the one already in the file. An undocumented mode is warned
|
|
88427
|
+
* about on its own.
|
|
88428
|
+
*/
|
|
88429
|
+
function defaultModeWideningEntry({ defaultMode, replaced, global, logger }) {
|
|
88430
|
+
const label = `permissions.defaultMode: "${defaultMode}"`;
|
|
88431
|
+
const projectNote = global ? [] : [PROJECT_SCALAR_OVERRIDES_GLOBAL];
|
|
88432
|
+
const reason = lookupOwn({
|
|
88433
|
+
record: COMMANDCODE_WIDENING_DEFAULT_MODES,
|
|
88434
|
+
key: defaultMode
|
|
88435
|
+
});
|
|
88436
|
+
if (reason !== void 0) return `${label} (${[reason, ...projectNote].join("; ")})`;
|
|
88437
|
+
const looseness = lookupOwn({
|
|
88438
|
+
record: COMMANDCODE_DEFAULT_MODE_LOOSENESS,
|
|
88439
|
+
key: defaultMode
|
|
88440
|
+
});
|
|
88441
|
+
if (looseness === void 0) {
|
|
88442
|
+
logger?.warn(`Command Code permissions: '${label}' is not a mode Command Code documents (default, accept-edits, plan, yolo, dont-ask and their aliases); it was written as authored.`);
|
|
88443
|
+
return null;
|
|
88444
|
+
}
|
|
88445
|
+
const replacedLooseness = typeof replaced === "string" ? lookupOwn({
|
|
88446
|
+
record: COMMANDCODE_DEFAULT_MODE_LOOSENESS,
|
|
88447
|
+
key: replaced
|
|
88448
|
+
}) : void 0;
|
|
88449
|
+
const notes = replacedLooseness !== void 0 && looseness > replacedLooseness ? [`replaces the stricter "${String(replaced)}" already in the file`] : [];
|
|
88450
|
+
if (looseness > 0) notes.push(...projectNote);
|
|
88451
|
+
return notes.length > 0 ? `${label} (${notes.join("; ")})` : null;
|
|
88452
|
+
}
|
|
88453
|
+
/**
|
|
88454
|
+
* Name, in one warning, every `commandcode.permissions` value that widens what
|
|
88455
|
+
* Command Code trusts. At project scope the scalars also override the
|
|
88456
|
+
* user-global file, which the warning says explicitly.
|
|
88457
|
+
*/
|
|
88458
|
+
function warnWideningCommandcodeFields({ fields, existingPermissions, global, logger }) {
|
|
88459
|
+
const widening = [];
|
|
88460
|
+
const { defaultMode, additionalDirectories, disableBypass } = fields;
|
|
88461
|
+
if (typeof defaultMode === "string") {
|
|
88462
|
+
const entry = defaultModeWideningEntry({
|
|
88463
|
+
defaultMode,
|
|
88464
|
+
replaced: existingPermissions.defaultMode,
|
|
88465
|
+
global,
|
|
88466
|
+
logger
|
|
88467
|
+
});
|
|
88468
|
+
if (entry !== null) widening.push(entry);
|
|
88469
|
+
}
|
|
88470
|
+
if (Array.isArray(additionalDirectories) && additionalDirectories.length > 0) widening.push("permissions.additionalDirectories (each directory then counts as inside the workspace for reads and writes)");
|
|
88471
|
+
if (disableBypass !== void 0 && disableBypass !== true && disableBypass !== "disable") widening.push(`permissions.disableBypass: ${JSON.stringify(disableBypass)} (` + (global ? "yolo mode then stays enterable from this file" : "a project value overrides the user-global setting, so yolo becomes enterable again even if ~/.commandcode/settings.json disables it") + ")");
|
|
88472
|
+
if (widening.length > 0) logger?.warn(`Command Code permissions: the commandcode override widens what Command Code trusts: ${widening.join("; ")}.`);
|
|
88473
|
+
}
|
|
88474
|
+
/**
|
|
88475
|
+
* The fields of the `commandcode.permissions` override to merge into the
|
|
88476
|
+
* settings file's `permissions` object. Only the documented
|
|
88477
|
+
* `COMMANDCODE_PERMISSIONS_FIELD_KEYS` are written: the `allow`/`ask`/`deny`
|
|
88478
|
+
* lists are rulesync's (built from the shared `permission` block) and any
|
|
88479
|
+
* other key is ignored, so the override can never smuggle a grant past the
|
|
88480
|
+
* list handling. A value that widens trust — a `defaultMode` that removes
|
|
88481
|
+
* prompts (or replaces a stricter one already in the file or, at project
|
|
88482
|
+
* scope, in the user-global file), a non-empty `additionalDirectories`, a
|
|
88483
|
+
* `disableBypass` that does not disable — is still written, but named in one
|
|
88484
|
+
* warning: this file is
|
|
88485
|
+
* shareable through `rulesync fetch`, and a loosening should not be silent.
|
|
88486
|
+
*/
|
|
88487
|
+
function commandcodePermissionsFields({ config, existingPermissions, global, logger }) {
|
|
88488
|
+
const override = config.commandcode?.permissions;
|
|
88489
|
+
if (!isRecord(override)) return {};
|
|
88490
|
+
const fields = {};
|
|
88491
|
+
for (const [key, value] of Object.entries(override)) {
|
|
88492
|
+
if (isPrototypePollutionKey(key) || value === void 0) continue;
|
|
88493
|
+
if (!COMMANDCODE_PERMISSIONS_FIELD_KEYS.includes(key)) {
|
|
88494
|
+
logger?.warn(`Command Code permissions: 'commandcode.permissions.${key}' is not written; only ${COMMANDCODE_PERMISSIONS_FIELD_KEYS.join(", ")} are authored there${key === "allow" || key === "ask" || key === "deny" ? " (the shared 'permission' block drives the allow/ask/deny lists)" : ""}.`);
|
|
88495
|
+
continue;
|
|
88496
|
+
}
|
|
88497
|
+
fields[key] = value;
|
|
88498
|
+
}
|
|
88499
|
+
warnWideningCommandcodeFields({
|
|
88500
|
+
fields,
|
|
88501
|
+
existingPermissions,
|
|
88502
|
+
global,
|
|
88503
|
+
logger
|
|
88504
|
+
});
|
|
88505
|
+
return fields;
|
|
88506
|
+
}
|
|
88507
|
+
/**
|
|
88508
|
+
* Read the documented non-list `permissions` fields back for the
|
|
88509
|
+
* `commandcode.permissions` override, verbatim. A value of a type Command Code
|
|
88510
|
+
* does not document is skipped with a warning rather than imported into a
|
|
88511
|
+
* source that would then fail validation; it stays in the settings file,
|
|
88512
|
+
* which a regenerate leaves untouched. Nothing here reaches the shared
|
|
88513
|
+
* `permission` block, so a mode or directory set for Command Code never turns
|
|
88514
|
+
* into a grant for another target.
|
|
88515
|
+
*/
|
|
88516
|
+
function importCommandcodePermissionsFields(permissions) {
|
|
88517
|
+
const fields = {};
|
|
88518
|
+
const skip = (key) => fallbackLogger.warn(`Command Code permissions: 'permissions.${key}' holds a value of a type Command Code does not document, so it was not imported; it stays in the Command Code settings.`);
|
|
88519
|
+
const { defaultMode, additionalDirectories, disableBypass } = permissions;
|
|
88520
|
+
if (typeof defaultMode === "string") fields.defaultMode = defaultMode;
|
|
88521
|
+
else if (defaultMode !== void 0) skip("defaultMode");
|
|
88522
|
+
if (Array.isArray(additionalDirectories)) {
|
|
88523
|
+
const directories = additionalDirectories.filter((entry) => typeof entry === "string");
|
|
88524
|
+
if (directories.length < additionalDirectories.length) fallbackLogger.warn("Command Code permissions: 'permissions.additionalDirectories' holds entries that are not strings; only the string entries were imported.");
|
|
88525
|
+
fields.additionalDirectories = directories;
|
|
88526
|
+
} else if (additionalDirectories !== void 0) skip("additionalDirectories");
|
|
88527
|
+
if (typeof disableBypass === "boolean" || disableBypass === "disable") fields.disableBypass = disableBypass;
|
|
88528
|
+
else if (disableBypass !== void 0) skip("disableBypass");
|
|
88529
|
+
return fields;
|
|
88530
|
+
}
|
|
88531
|
+
/**
|
|
87517
88532
|
* Permissions generator for Command Code.
|
|
87518
88533
|
*
|
|
87519
88534
|
* Rules live under the `permissions` key of `.commandcode/settings.json`
|
|
@@ -87521,8 +88536,10 @@ function parseCommandcodeRuleLists(permissions) {
|
|
|
87521
88536
|
* Claude-style entries: `deny` (always wins), `ask`, `allow`. The same key
|
|
87522
88537
|
* also carries `defaultMode`, `additionalDirectories` and `disableBypass`,
|
|
87523
88538
|
* and the file holds `hooks` and other settings, so writes go through the
|
|
87524
|
-
* shared-config gateway: rulesync replaces the three lists,
|
|
87525
|
-
*
|
|
88539
|
+
* shared-config gateway: rulesync replaces the three lists, merges those
|
|
88540
|
+
* three fields from the `commandcode.permissions` override (warning on values
|
|
88541
|
+
* that widen trust), keeps every other sibling key, and never deletes the
|
|
88542
|
+
* file. Import reads the three fields back into that override.
|
|
87526
88543
|
*
|
|
87527
88544
|
* Generate: `permission.<category>.<pattern>` becomes `Tool(pattern)` with
|
|
87528
88545
|
* the friendly names (`Shell`, `Read`, `Edit`, `Write`, `WebFetch`,
|
|
@@ -87573,12 +88590,21 @@ var CommandcodePermissions = class CommandcodePermissions extends ToolPermission
|
|
|
87573
88590
|
relativePath: join(paths.relativeDirPath, paths.relativeFilePath)
|
|
87574
88591
|
});
|
|
87575
88592
|
const existingPermissions = isRecord(existing[COMMANDCODE_PERMISSIONS_KEY]) ? existing[COMMANDCODE_PERMISSIONS_KEY] : {};
|
|
88593
|
+
const config = rulesyncPermissions.getJson();
|
|
87576
88594
|
const lists = buildCommandcodeRuleLists({
|
|
87577
|
-
config
|
|
88595
|
+
config,
|
|
87578
88596
|
existingPermissions,
|
|
87579
88597
|
logger
|
|
87580
88598
|
});
|
|
87581
|
-
const permissions = {
|
|
88599
|
+
const permissions = {
|
|
88600
|
+
...existingPermissions,
|
|
88601
|
+
...commandcodePermissionsFields({
|
|
88602
|
+
config,
|
|
88603
|
+
existingPermissions,
|
|
88604
|
+
global,
|
|
88605
|
+
logger
|
|
88606
|
+
})
|
|
88607
|
+
};
|
|
87582
88608
|
for (const key of [
|
|
87583
88609
|
"allow",
|
|
87584
88610
|
"ask",
|
|
@@ -87606,7 +88632,10 @@ var CommandcodePermissions = class CommandcodePermissions extends ToolPermission
|
|
|
87606
88632
|
relativePath: join(this.getRelativeDirPath(), this.getRelativeFilePath())
|
|
87607
88633
|
});
|
|
87608
88634
|
const permissions = isRecord(settings[COMMANDCODE_PERMISSIONS_KEY]) ? settings[COMMANDCODE_PERMISSIONS_KEY] : {};
|
|
87609
|
-
|
|
88635
|
+
const imported = { permission: parseCommandcodeRuleLists(permissions) };
|
|
88636
|
+
const fields = importCommandcodePermissionsFields(permissions);
|
|
88637
|
+
if (Object.keys(fields).length > 0) imported.commandcode = { permissions: fields };
|
|
88638
|
+
return this.toRulesyncPermissionsDefault({ fileContent: JSON.stringify(imported, null, 2) });
|
|
87610
88639
|
}
|
|
87611
88640
|
};
|
|
87612
88641
|
/**
|
|
@@ -88706,9 +89735,11 @@ function effectiveSafeCommandLine(entry) {
|
|
|
88706
89735
|
* and without a Windows executable suffix. A `*` in the command word may
|
|
88707
89736
|
* stand for a directory and part of a name, so when what follows it is the
|
|
88708
89737
|
* tail of a wrapper name, everything before it collapses into `*`
|
|
88709
|
-
* (`b*nice` -> `*nice`, `/u*v` -> `*v`; `rm*` is left alone). The rest of
|
|
88710
|
-
*
|
|
88711
|
-
*
|
|
89738
|
+
* (`b*nice` -> `*nice`, `/u*v` -> `*v`; `rm*` is left alone). The rest of
|
|
89739
|
+
* the pattern is lower-cased as well, for a nested wrapper spelled in another
|
|
89740
|
+
* case. Used only to compare against a lower-cased safe line, its `--` form
|
|
89741
|
+
* and its wrapper spellings. Lower-casing the arguments too can only withhold
|
|
89742
|
+
* more: a `go BUILD` deny also withholds `go build` (fail-closed).
|
|
88712
89743
|
*/
|
|
88713
89744
|
function normalizeRestrictionCommandWord(pattern) {
|
|
88714
89745
|
const space = pattern.indexOf(" ");
|
|
@@ -88725,9 +89756,9 @@ function normalizeRestrictionCommandWord(pattern) {
|
|
|
88725
89756
|
* rules govern a command Crush would approve through it? Besides the line
|
|
88726
89757
|
* itself, Crush approves it followed by `--` and behind a wrapper (or the
|
|
88727
89758
|
* `time` keyword), whose name it normalizes (`./nice`, `/usr/bin/env`, `NICE`,
|
|
88728
|
-
* `nohup.exe`). The line and its wrapper spellings are compared
|
|
88729
|
-
* restrictions as written
|
|
88730
|
-
*
|
|
89759
|
+
* `nohup.exe`). The line, its `--` form and its wrapper spellings are compared
|
|
89760
|
+
* against both the restrictions as written and those with their command word
|
|
89761
|
+
* normalized like Crush (including executable paths and case) — which keeps
|
|
88731
89762
|
* an unrelated `rm *` from withholding the line, as a leading wildcard on the
|
|
88732
89763
|
* spelling would. Canonically the stricter rule wins whatever its width
|
|
88733
89764
|
* (`deny > ask > allow`), so any overlap withholds the line.
|
|
@@ -88751,7 +89782,7 @@ function createSafeCommandShadowTest(permission) {
|
|
|
88751
89782
|
});
|
|
88752
89783
|
const withSeparator = (spellings) => spellings.flatMap((spelling) => [spelling, `${spelling} --*`]);
|
|
88753
89784
|
const wrapped = (base) => CRUSH_COMMAND_PREFIXES.map((prefix) => `${prefix}*${base}`);
|
|
88754
|
-
return (line) => uniq$1([...withSeparator([line, ...wrapped(line)]).flatMap((spelling) => test(spelling)), ...withSeparator(wrapped(line.toLowerCase())).flatMap((spelling) => testNormalized(spelling).map((pattern) => originalOf.get(pattern) ?? pattern))]);
|
|
89785
|
+
return (line) => uniq$1([...withSeparator([line, ...wrapped(line)]).flatMap((spelling) => test(spelling)), ...withSeparator([line.toLowerCase(), ...wrapped(line.toLowerCase())]).flatMap((spelling) => testNormalized(spelling).map((pattern) => originalOf.get(pattern) ?? pattern))]);
|
|
88755
89786
|
}
|
|
88756
89787
|
function uniq$1(values) {
|
|
88757
89788
|
return [...new Set(values)];
|
|
@@ -92522,7 +93553,14 @@ function convertJunieToRulesyncPermissions({ allowlist }) {
|
|
|
92522
93553
|
* restriction is restated at the end of every other key that holds a looser
|
|
92523
93554
|
* rule it overlaps, where it is matched after that rule. A `*` catch-all
|
|
92524
93555
|
* (`{"*": {"*": "ask"}}` followed by per-tool allows) is the documented way to
|
|
92525
|
-
* set an OpenCode default, so it is
|
|
93556
|
+
* set an OpenCode default, so it is not restated in the later keys.
|
|
93557
|
+
*
|
|
93558
|
+
* The `*` key's own patterns are reordered allow, then ask, then deny, so the
|
|
93559
|
+
* strictest matching one wins there too. This disables an allow carve-out
|
|
93560
|
+
* under a broader ask or deny in that key (`{"*": "deny", "src/**": "allow"}`
|
|
93561
|
+
* denies `src/**` as well), so a warning is logged whenever the order changes,
|
|
93562
|
+
* unless `<target>.permission["*"]` (`allToolsOverridden`) replaces the key
|
|
93563
|
+
* with an exact order anyway.
|
|
92526
93564
|
*
|
|
92527
93565
|
* A restated rule must never land after an overlapping stricter one, or it
|
|
92528
93566
|
* would loosen what that rule says. The tail of a key is therefore written
|
|
@@ -92531,15 +93569,23 @@ function convertJunieToRulesyncPermissions({ allowlist }) {
|
|
|
92531
93569
|
* then the restated `*` denies. A key whose own catch-all is a deny covers
|
|
92532
93570
|
* every input of a restated ask already, so such an ask is restated as a deny.
|
|
92533
93571
|
*/
|
|
92534
|
-
function restateAllToolsRestrictionsLast(sharedPermission) {
|
|
93572
|
+
function restateAllToolsRestrictionsLast({ sharedPermission, toolTarget, allToolsOverridden = false, logger }) {
|
|
92535
93573
|
const allToolsRules = Object.hasOwn(sharedPermission, "*") ? sharedPermission["*"] : void 0;
|
|
92536
93574
|
const restrictions = Object.entries(allToolsRules ?? {}).filter(([pattern, action]) => action !== "allow" && pattern !== "*" && !isPrototypePollutionKey(pattern));
|
|
92537
|
-
if (restrictions.length === 0) return sharedPermission;
|
|
93575
|
+
if (restrictions.length === 0 && !allToolsRules) return sharedPermission;
|
|
92538
93576
|
const result = {};
|
|
92539
|
-
for (const [key, rules] of Object.entries(sharedPermission))
|
|
92540
|
-
|
|
92541
|
-
|
|
92542
|
-
|
|
93577
|
+
for (const [key, rules] of Object.entries(sharedPermission)) {
|
|
93578
|
+
if (key !== "*") {
|
|
93579
|
+
result[key] = restateInKey({
|
|
93580
|
+
rules,
|
|
93581
|
+
restrictions
|
|
93582
|
+
});
|
|
93583
|
+
continue;
|
|
93584
|
+
}
|
|
93585
|
+
const sorted = sortRulesByActionPriority(rules);
|
|
93586
|
+
if (!allToolsOverridden && !isDeepStrictEqual(Object.keys(sorted), Object.keys(rules))) logger?.warn(`The all-tools "*" permission patterns were reordered allow, ask, deny because ${toolTarget} applies the last matching pattern and the stricter rule must win, which may disable a looser carve-out under a broader ask or deny pattern (e.g. "*": "deny", "src/**": "allow"). Set ${toolTarget}.permission["*"] to control the exact order.`);
|
|
93587
|
+
result[key] = sorted;
|
|
93588
|
+
}
|
|
92543
93589
|
return result;
|
|
92544
93590
|
}
|
|
92545
93591
|
function globsOverlap(left, right) {
|
|
@@ -92791,7 +93837,12 @@ var KiloPermissions = class KiloPermissions extends ToolPermissions {
|
|
|
92791
93837
|
const rulesyncJson = rulesyncPermissions.getJson();
|
|
92792
93838
|
const kiloOverride = rulesyncJson.kilo;
|
|
92793
93839
|
const incomingPermission = {
|
|
92794
|
-
...restateAllToolsRestrictionsLast(
|
|
93840
|
+
...restateAllToolsRestrictionsLast({
|
|
93841
|
+
sharedPermission: honorAllToolsOnBash(rulesyncJson.permission),
|
|
93842
|
+
toolTarget: "kilo",
|
|
93843
|
+
allToolsOverridden: Object.hasOwn(kiloOverride?.permission ?? {}, "*"),
|
|
93844
|
+
logger
|
|
93845
|
+
}),
|
|
92795
93846
|
...kiloOverride?.permission
|
|
92796
93847
|
};
|
|
92797
93848
|
if (!global && Object.hasOwn(incomingPermission, KILO_MARKDOWN_SOURCE_KEY)) {
|
|
@@ -94403,7 +95454,7 @@ function mergePatternRules(base, incoming) {
|
|
|
94403
95454
|
action,
|
|
94404
95455
|
existing: Object.hasOwn(merged, pattern) ? merged[pattern] : void 0
|
|
94405
95456
|
})) merged[pattern] = action;
|
|
94406
|
-
return
|
|
95457
|
+
return sortRulesByActionPriority(merged);
|
|
94407
95458
|
}
|
|
94408
95459
|
function toCanonicalPermissionKey(opencodeKey) {
|
|
94409
95460
|
return lookupOwn({
|
|
@@ -94464,7 +95515,7 @@ function fromOpencodeV2PermissionRules(rules) {
|
|
|
94464
95515
|
* written under the key OpenCode actually reads. A folded `write` is merged
|
|
94465
95516
|
* with any canonical `edit` rules rather than replacing them.
|
|
94466
95517
|
*/
|
|
94467
|
-
function toOpencodeSharedPermission({ permission, toolTarget, logger }) {
|
|
95518
|
+
function toOpencodeSharedPermission({ permission, toolTarget, allToolsOverridden, logger }) {
|
|
94468
95519
|
const sharedPermission = {};
|
|
94469
95520
|
for (const [category, value] of Object.entries(honorAllToolsOnBash(permission))) {
|
|
94470
95521
|
if (OPENCODE_UNSUPPORTED_PERMISSION_CATEGORIES.has(category)) {
|
|
@@ -94485,7 +95536,12 @@ function toOpencodeSharedPermission({ permission, toolTarget, logger }) {
|
|
|
94485
95536
|
sharedPermission[key] = merged;
|
|
94486
95537
|
} else sharedPermission[key] = value;
|
|
94487
95538
|
}
|
|
94488
|
-
return restateAllToolsRestrictionsLast(
|
|
95539
|
+
return restateAllToolsRestrictionsLast({
|
|
95540
|
+
sharedPermission,
|
|
95541
|
+
toolTarget,
|
|
95542
|
+
allToolsOverridden,
|
|
95543
|
+
logger
|
|
95544
|
+
});
|
|
94489
95545
|
}
|
|
94490
95546
|
const OpencodePermissionsConfigSchema = z.looseObject({
|
|
94491
95547
|
permission: z.optional(z.union([z.enum([
|
|
@@ -94589,6 +95645,7 @@ var OpencodePermissions = class extends ToolPermissions {
|
|
|
94589
95645
|
const sharedPermission = toOpencodeSharedPermission({
|
|
94590
95646
|
permission: rulesyncJson.permission ?? {},
|
|
94591
95647
|
toolTarget: this.layout.toolTarget,
|
|
95648
|
+
allToolsOverridden: Object.hasOwn(overridePermission, "*"),
|
|
94592
95649
|
logger
|
|
94593
95650
|
});
|
|
94594
95651
|
const isV2 = this.layout.configVersion === "v2";
|
|
@@ -100190,28 +101247,31 @@ function parseTraePermissionConfig({ fileContent, relativePath }) {
|
|
|
100190
101247
|
const moduleLogger = fallbackLogger;
|
|
100191
101248
|
/**
|
|
100192
101249
|
* Vibe's builtin tool names are the snake_case of each tool class
|
|
100193
|
-
* (`BaseTool.get_name()`): `Edit` → `edit`,
|
|
100194
|
-
* `
|
|
101250
|
+
* (`BaseTool.get_name()`): `Edit` → `edit`, alongside `read_file`,
|
|
101251
|
+
* `write_file` and `bash`.
|
|
100195
101252
|
* `edit` and `write_file` are distinct tools — `write_file` has been
|
|
100196
101253
|
* create-only since v2.14.0 — so the canonical `edit` and `write` categories
|
|
100197
101254
|
* must not collapse onto one name.
|
|
100198
101255
|
*
|
|
100199
|
-
* `grep` and `
|
|
100200
|
-
* the Unified Harness, which reads `[tools.*]`
|
|
100201
|
-
* (`RUST_BUILTIN_TOOL_SOURCES`). There is no grep
|
|
100202
|
-
* goes through the shell — and subagents are
|
|
100203
|
-
* `agents.spawn` tool, which the `enable_subagents`
|
|
100204
|
-
* a `[tools.task]` table.
|
|
101256
|
+
* `grep`, `agent`, `webfetch` and `websearch` have no table here: since
|
|
101257
|
+
* v3.0.0 every session runs on the Unified Harness, which reads `[tools.*]`
|
|
101258
|
+
* only for its Rust builtins (`RUST_BUILTIN_TOOL_SOURCES`). There is no grep
|
|
101259
|
+
* tool any more — searching goes through the shell — and subagents are
|
|
101260
|
+
* spawned by the built-in `agents.spawn` tool, which the `enable_subagents`
|
|
101261
|
+
* switch governs instead of a `[tools.task]` table. `web_fetch` and
|
|
101262
|
+
* `web_search` are in Vibe's `RETIRED_TOOL_NAMES`: pages are fetched and the
|
|
101263
|
+
* web searched by the `connector_web_search_open_url` /
|
|
101264
|
+
* `connector_web_search_web_search` connector tools. See
|
|
101265
|
+
* {@link VIBE_RETIRED_TOOL_TABLES}.
|
|
100205
101266
|
* @see https://github.com/mistralai/mistral-vibe/blob/v3.0.2/vibe/app_server/_unified_permissions.py
|
|
100206
101267
|
* @see https://github.com/mistralai/mistral-vibe/blob/v3.0.2/vibe/app_server/_ignored_tool_settings.py
|
|
101268
|
+
* @see https://github.com/mistralai/mistral-vibe/blob/v3.1.3/vibe/core/config/_setting_keys.py
|
|
100207
101269
|
*/
|
|
100208
101270
|
const CANONICAL_TO_VIBE_TOOL_NAMES = {
|
|
100209
101271
|
bash: "bash",
|
|
100210
101272
|
read: "read_file",
|
|
100211
101273
|
edit: "edit",
|
|
100212
|
-
write: "write_file"
|
|
100213
|
-
webfetch: "web_fetch",
|
|
100214
|
-
websearch: "web_search"
|
|
101274
|
+
write: "write_file"
|
|
100215
101275
|
};
|
|
100216
101276
|
/**
|
|
100217
101277
|
* The tables earlier rulesync versions wrote for canonical categories that
|
|
@@ -100219,15 +101279,38 @@ const CANONICAL_TO_VIBE_TOOL_NAMES = {
|
|
|
100219
101279
|
* effect"), `[tools.task]` for the subagent tool v3.0.0 renamed to
|
|
100220
101280
|
* `agents.*`, and `[tools.external_directory]` — Vibe has no such tool, and
|
|
100221
101281
|
* its unused-settings check skips unknown tool names as custom/MCP tools, so
|
|
100222
|
-
* that deny was silently inert.
|
|
100223
|
-
* the
|
|
101282
|
+
* that deny was silently inert. `[tools.web_fetch]` / `[tools.web_search]`
|
|
101283
|
+
* are inert for the same reason: Vibe 3.x retired both tools, and v3.1.3 warns
|
|
101284
|
+
* about a tool filter naming them. A regenerate that configures the category
|
|
101285
|
+
* removes them — and the matching `disabled_tools` entry — instead of leaving
|
|
101286
|
+
* an inert table.
|
|
100224
101287
|
* Import still reads them (see {@link VIBE_TO_CANONICAL_TOOL_NAMES}), so a
|
|
100225
101288
|
* Vibe 2.x config is lifted into the canonical categories rather than lost.
|
|
100226
101289
|
*/
|
|
100227
101290
|
const VIBE_RETIRED_TOOL_TABLES = {
|
|
100228
101291
|
grep: "grep",
|
|
100229
101292
|
agent: "task",
|
|
100230
|
-
external_directory: "external_directory"
|
|
101293
|
+
external_directory: "external_directory",
|
|
101294
|
+
webfetch: "web_fetch",
|
|
101295
|
+
websearch: "web_search"
|
|
101296
|
+
};
|
|
101297
|
+
/**
|
|
101298
|
+
* The connector tools that replaced Vibe's retired web builtins, by canonical
|
|
101299
|
+
* category, so the skip warning can say where to write the rule instead.
|
|
101300
|
+
* rulesync does not write them itself: whether their `allowlist` / `denylist`
|
|
101301
|
+
* keys carry the old tools' semantics is not documented upstream.
|
|
101302
|
+
* @see https://github.com/mistralai/mistral-vibe/blob/v3.1.3/vibe/core/config/_setting_keys.py
|
|
101303
|
+
* @see https://github.com/mistralai/mistral-vibe/blob/v3.1.3/vibe/plugins/builtins/vibe/skills/vibe/SKILL.md
|
|
101304
|
+
*/
|
|
101305
|
+
const VIBE_WEB_CONNECTOR_TOOLS = {
|
|
101306
|
+
webfetch: {
|
|
101307
|
+
retired: "web_fetch",
|
|
101308
|
+
connector: "connector_web_search_open_url"
|
|
101309
|
+
},
|
|
101310
|
+
websearch: {
|
|
101311
|
+
retired: "web_search",
|
|
101312
|
+
connector: "connector_web_search_web_search"
|
|
101313
|
+
}
|
|
100231
101314
|
};
|
|
100232
101315
|
/** The canonical category Vibe's `enable_subagents` switch expresses. */
|
|
100233
101316
|
const VIBE_SUBAGENT_CATEGORY = "agent";
|
|
@@ -100603,7 +101686,7 @@ function retireLegacyToolTables({ permission, tools, disabledTools, logger }) {
|
|
|
100603
101686
|
}
|
|
100604
101687
|
if (disabledTools.delete(legacyToolName)) removed.push(`disabled_tools entry '${legacyToolName}'`);
|
|
100605
101688
|
}
|
|
100606
|
-
if (removed.length > 0) logger?.warn(`Removed ${removed.join(", ")} from the Vibe config: Vibe 3.x does not read [tools.grep], the former 'task' subagent tool
|
|
101689
|
+
if (removed.length > 0) logger?.warn(`Removed ${removed.join(", ")} from the Vibe config: Vibe 3.x does not read [tools.grep], the former 'task' subagent tool, an 'external_directory' tool (the 'external_directory' category is written to outside_workdir instead) or the retired 'web_fetch' / 'web_search' tools, so those entries had no effect.`);
|
|
100607
101690
|
}
|
|
100608
101691
|
/**
|
|
100609
101692
|
* Report the rules of a category that has no Vibe tool table. `grep` gets its
|
|
@@ -100619,6 +101702,14 @@ function warnOnUnmappedCategory({ category, rules, logger }) {
|
|
|
100619
101702
|
logger?.warn(`Vibe has no grep tool (searching goes through the shell, so 'rg' and 'grep' follow [tools.bash]); skipping ${ruleCount} 'grep' rule(s). Author a 'bash' rule such as "grep *" or "rg *" to restrict searching on Vibe.`);
|
|
100620
101703
|
return;
|
|
100621
101704
|
}
|
|
101705
|
+
const webTool = lookupOwn({
|
|
101706
|
+
record: VIBE_WEB_CONNECTOR_TOOLS,
|
|
101707
|
+
key: category
|
|
101708
|
+
});
|
|
101709
|
+
if (webTool !== void 0) {
|
|
101710
|
+
logger?.warn(`Vibe 3.x retired its '${webTool.retired}' tool (web access goes through the '${webTool.connector}' connector tool); skipping ${ruleCount} '${category}' rule(s) instead of emitting an inert [tools.${webTool.retired}] table. Author a '${webTool.connector}' rule (a '*' deny adds it to disabled_tools) to restrict it on Vibe.`);
|
|
101711
|
+
return;
|
|
101712
|
+
}
|
|
100622
101713
|
logger?.warn(`Vibe has no tool table for the '${category}' category; skipping ${ruleCount} rule(s) instead of emitting an inert [tools.${category}] table.`);
|
|
100623
101714
|
}
|
|
100624
101715
|
/**
|
|
@@ -100829,7 +101920,7 @@ function retireWithheldAllows({ source, permission, tools, resolveNames }) {
|
|
|
100829
101920
|
fromAllToolsCategory: false
|
|
100830
101921
|
}));
|
|
100831
101922
|
const globShadowed = createShadowingRestrictionsTest(restrictions);
|
|
100832
|
-
const shadowed = (pattern) =>
|
|
101923
|
+
const shadowed = (pattern) => globShadowed(pattern).length > 0;
|
|
100833
101924
|
const retires = (pattern) => withheld.has(pattern) || restrictions.length > 0 && honored[pattern] !== "allow" && shadowed(pattern);
|
|
100834
101925
|
for (const vibeToolName of resolveNames(category) ?? []) {
|
|
100835
101926
|
if (!Object.hasOwn(tools, vibeToolName)) continue;
|
|
@@ -105996,4 +107087,4 @@ const CHECKS_IMPORT_STRATEGY = {
|
|
|
105996
107087
|
};
|
|
105997
107088
|
export { RulesyncRule as $, RULESYNC_RULES_RELATIVE_DIR_PATH as $n, getFileSizeAndExecutableBit as $t, CODEBUDDY_LOCAL_RULE_FILE_NAME as A, ToolTargetSchema as An, fallbackLogger as At, CLAUDECODE_LOCAL_RULE_FILE_NAME as B, RULESYNC_CONFIG_RELATIVE_FILE_PATH as Bn, assertDirectoryIfExists as Bt, LETTACODE_DIR as C, toPosixPath as Cn, SourceEntrySchema as Ct, COMMANDCODE_DIR as D, ALL_TOOL_TARGETS as Dn, ConsoleLogger as Dt, FACTORYDROID_SETTINGS_LOCAL_FILE_NAME as E, mapWithConcurrency as En, findControlCharacter as Et, sweepRefusalReason as F, FEATURE_SOURCE_TREE_ENTRIES as Fn, CLIError as Ft, toInstructionBudgetFile as G, RULESYNC_IGNORE_RELATIVE_FILE_PATH as Gn, assertWritablePathInsideRoot as Gt, CLAUDECODE_SETTINGS_LOCAL_FILE_NAME as H, RULESYNC_CURATED_RULES_RELATIVE_DIR_PATH as Hn, assertNoSymlinkBelowRoot as Ht, CODEXCLI_BASH_RULES_FILE_NAME as I, MAX_FILE_SIZE as In, ErrorCodes as It, getLocalSkillDirNames as J, RULESYNC_MCP_SCHEMA_URL as Jn, directoryExists as Jt, classifyRemoteName as K, RULESYNC_LOCAL_CONFIG_RELATIVE_FILE_PATH as Kn, checkPathTraversal as Kt, CODEXCLI_DIR as L, RULESYNC_AIIGNORE_RELATIVE_FILE_PATH as Ln, parseJsonc as Lt, AUGMENTCODE_SETTINGS_LOCAL_FILE_NAME as M, ALL_FEATURES_WITH_WILDCARD as Mn, withFallbackLoggerTarget as Mt, caseFoldIdentity as N, DEPRECATED_FEATURE_REPLACEMENTS as Nn, resetRunWarningState as Nt, COMMANDCODE_SETTINGS_LOCAL_FILE_NAME as O, ALL_TOOL_TARGETS_WITH_WILDCARD as On, JsonLogger as Ot, groupSpellingsByCaseFoldedIdentity as P, CURATED_RULES_FEATURE_SUBDIR as Pn, withWarnOnceScope as Pt, RulesyncSkillFrontmatterSchema as Q, RULESYNC_RELATIVE_DIR_PATH as Qn, findFilesByGlobs as Qt, CLAUDECODE_AGENT_MEMORY_LOCAL_DIR_NAME as R, RULESYNC_CHECKS_RELATIVE_DIR_PATH as Rn, PathOutsideRootError as Rt, QWENCODE_LOCAL_RULE_FILE_NAME as S, splitPathSegments as Sn, GITIGNORE_DESTINATION_KEY as St, FACTORYDROID_DIR as T, writeFileContent as Tn, getSourceTransport as Tt, CLAUDECODE_SKILLS_DIR_PATH as U, RULESYNC_CURATED_SKILLS_RELATIVE_DIR_PATH as Un, assertPathResolvesInsideRoot as Ut, CLAUDECODE_MEMORIES_DIR_NAME as V, RULESYNC_CONFIG_SCHEMA_URL as Vn, assertLandingOutsideVcsMetadata as Vt, findProjectInstructionBudgetFindings as W, RULESYNC_HOOKS_RELATIVE_FILE_PATH as Wn, assertTreeContainsNoSymlinks as Wt, RulesyncSubagentFrontmatterSchema as X, RULESYNC_PERMISSIONS_RELATIVE_FILE_PATH as Xn, fileExists as Xt, RulesyncSubagent as Y, RULESYNC_NPM_SOURCES_LOCK_RELATIVE_FILE_PATH as Yn, ensureDir as Yt, RulesyncSkill as Z, RULESYNC_PERMISSIONS_SCHEMA_URL as Zn, fileExistsStrict as Zt, SkillsProcessor as _, removeFileWithoutFollowingSymlinks as _n, mergeInputRootConfigs as _t, convertFromTool as a, listDirectoryEntryNames as an, formatMegabytes as ar, getRulesyncSourceCandidates as at, REASONIX_LOCAL_RULE_FILE_NAME as b, resolvedRelativePath as bn, CONFLICTING_TARGET_PAIRS as bt, ELLIPSIS_WIDTH as c, normalizePosixDirPath as cn, hasEnclosingMarkOutsideKeycap as cr, RulesyncCommandFrontmatterSchema as ct, McpProcessor as d, readFileContent as dn, stripControlCharactersKeepingLineFeeds as dr, stringifyFrontmatter as dt, getHomeDirectory as en, RULESYNC_SKILLS_RELATIVE_DIR_PATH as er, RulesyncRuleFrontmatterSchema as et, IgnoreProcessor as f, readFileContentOrNull as fn, stripControlCharactersKeepingLineFeedsAndTabs as fr, loadYaml as ft, SubagentsProcessor as g, removeFileStrict as gn, ConfigResolver as gt, RulesProcessor as h, removeFile as hn, SKILL_FILE_NAME as ht, inspectInputRoots as i, isSymlink as in, RULESYNC_XDG_CONFIG_HOME_DEFAULT_DIR_NAME as ir, RulesyncHooks as it, AUGMENTCODE_DIR as j, ALL_FEATURES as jn, warnOnConflictingFlags as jt, CODEBUDDY_DIR as k, PACKAGING_TOOL_TARGETS as kn, WarningCollectingLogger as kt, displayWidthOf as l, pathEscapesRoot as ln, quoteForLog as lr, RulesyncCheck as lt, ChecksProcessor as m, removeDirectoryStrict as mn, SHARED_USER_MANAGED_CONFIG_PATHS as mt, formatSourceLoadFailure as n, isFileSystemError as nn, RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH as nr, RulesyncMcp as nt, getProcessorRegistryEntry as o, listFilePathsRecursively as on, formatError as or, resolveRulesyncSourceWritePath as ot, HooksProcessor as p, removeDirectory as pn, stripHiddenCharacters as pr, isRecord as pt, hasWindowsFoldableName as q, RULESYNC_MCP_RELATIVE_FILE_PATH as qn, createTempDirectory as qt, generate as r, isRootDirPath as rn, RULESYNC_USER_CONFIG_DIR_NAME as rr, RulesyncIgnore as rt, parseCommaSeparatedList as s, listSubdirectoryNames as sn, truncateText as sr, RulesyncCommand as st, importFromTool as t, isFileNotFoundError as tn, RULESYNC_SOURCES_LOCK_RELATIVE_FILE_PATH as tr, RulesyncPermissions as tt, shortenToWidth as u, posixRelativePathEscapesRoot as un, stripControlCharacters as ur, RulesyncCheckFrontmatterSchema as ut, CRUSH_LOCAL_RULE_FILE_NAME as v, removeTempDirectory as vn, parseConfigFileContent as vt, LETTACODE_SETTINGS_LOCAL_FILE_NAME as w, writeFileBuffer as wn, assertTargetsFeaturesExclusive as wt, QWENCODE_DIR as x, runWithDirectoryRollback as xn, ConfigFileSchema as xt, CommandsProcessor as y, resolvePath as yn, resolveEffectiveInputRoots as yt, CLAUDECODE_DIR as z, RULESYNC_COMMANDS_RELATIVE_DIR_PATH as zn, applyFileMode as zt };
|
|
105998
107089
|
|
|
105999
|
-
//# sourceMappingURL=import-
|
|
107090
|
+
//# sourceMappingURL=import-CDUGMCum.js.map
|