rulesync 43.14.0 → 43.15.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.
@@ -746,6 +746,7 @@ const subagentsProcessorToolTargetTuple = [
746
746
  "omp",
747
747
  "opencode",
748
748
  "opencodev1",
749
+ "openbitfun",
749
750
  "pool",
750
751
  "qoder",
751
752
  "qwencode",
@@ -806,6 +807,7 @@ const skillsProcessorToolTargetTuple = [
806
807
  "omp",
807
808
  "opencode",
808
809
  "opencodev1",
810
+ "openbitfun",
809
811
  "pi",
810
812
  "pool",
811
813
  "qoder",
@@ -854,6 +856,7 @@ const hooksProcessorToolTargetTuple = [
854
856
  "omp",
855
857
  "opencode",
856
858
  "opencodev1",
859
+ "openbitfun",
857
860
  "pi",
858
861
  "pool",
859
862
  "factorydroid",
@@ -6043,6 +6046,7 @@ const HooksConfigSchema = z.looseObject({
6043
6046
  amp: z.optional(z.looseObject({ hooks: z.optional(hooksRecordSchema) })),
6044
6047
  factorydroid: z.optional(z.looseObject({ hooks: z.optional(hooksRecordSchema) })),
6045
6048
  codexcli: z.optional(z.looseObject({ hooks: z.optional(hooksRecordSchema) })),
6049
+ openbitfun: z.optional(z.looseObject({ hooks: z.optional(hooksRecordSchema) })),
6046
6050
  goose: z.optional(z.looseObject({ hooks: z.optional(hooksRecordSchema) })),
6047
6051
  deepagents: z.optional(z.looseObject({ hooks: z.optional(hooksRecordSchema) })),
6048
6052
  kiro: z.optional(z.looseObject({ hooks: z.optional(hooksRecordSchema) })),
@@ -6619,6 +6623,32 @@ const CODEXCLI_HOOK_EVENTS = eventsOf(CANONICAL_TO_CODEXCLI_EVENT_NAMES);
6619
6623
  */
6620
6624
  const CODEXCLI_TO_CANONICAL_EVENT_NAMES = invertRecord(CANONICAL_TO_CODEXCLI_EVENT_NAMES);
6621
6625
  /**
6626
+ * Map canonical camelCase event names to OpenBitFun PascalCase. OpenBitFun
6627
+ * implements the Codex hook contract with Codex's event names, minus the
6628
+ * events it does not dispatch (`Interrupt`, `PreModelRequest`,
6629
+ * `PostModelRequest`).
6630
+ * @see https://github.com/openBitFun/OpenBitFun/blob/main/docs/features/agent-hooks.md
6631
+ */
6632
+ const CANONICAL_TO_OPENBITFUN_EVENT_NAMES = {
6633
+ sessionStart: "SessionStart",
6634
+ sessionEnd: "SessionEnd",
6635
+ preToolUse: "PreToolUse",
6636
+ postToolUse: "PostToolUse",
6637
+ beforeSubmitPrompt: "UserPromptSubmit",
6638
+ stop: "Stop",
6639
+ permissionRequest: "PermissionRequest",
6640
+ subagentStart: "SubagentStart",
6641
+ subagentStop: "SubagentStop",
6642
+ preCompact: "PreCompact",
6643
+ postCompact: "PostCompact"
6644
+ };
6645
+ /** Hook events supported by OpenBitFun. */
6646
+ const OPENBITFUN_HOOK_EVENTS = eventsOf(CANONICAL_TO_OPENBITFUN_EVENT_NAMES);
6647
+ /**
6648
+ * Map OpenBitFun PascalCase event names to canonical camelCase.
6649
+ */
6650
+ const OPENBITFUN_TO_CANONICAL_EVENT_NAMES = invertRecord(CANONICAL_TO_OPENBITFUN_EVENT_NAMES);
6651
+ /**
6622
6652
  * Map canonical camelCase event names to Goose PascalCase.
6623
6653
  */
6624
6654
  const CANONICAL_TO_GOOSE_EVENT_NAMES = {
@@ -28122,6 +28152,135 @@ var PiSkill = class extends ToolSkill {
28122
28152
  var OmpSkill = class extends PiSkill {
28123
28153
  static layout = OMP_LAYOUT;
28124
28154
  };
28155
+ // src/constants/openbitfun-paths.ts
28156
+ /**
28157
+ * OpenBitFun configuration-layout conventions.
28158
+ *
28159
+ * OpenBitFun (formerly BitFun) keeps its project assets under a `.openbitfun/`
28160
+ * directory at the project root and its user assets under an OS-dependent
28161
+ * user root. Rules are not written here: OpenBitFun already reads the shared
28162
+ * `AGENTS.md` / `CLAUDE.md` / `.claude/rules/` files the `agentsmd` and
28163
+ * `claudecode` targets write.
28164
+ *
28165
+ * @see https://github.com/openBitFun/OpenBitFun/blob/main/src/crates/assembly/core/src/infrastructure/app_paths/path_manager.rs
28166
+ */
28167
+ const OPENBITFUN_DIR = ".openbitfun";
28168
+ const OPENBITFUN_AGENTS_DIR_NAME = "agents";
28169
+ const OPENBITFUN_AGENTS_DIR_PATH = join(OPENBITFUN_DIR, OPENBITFUN_AGENTS_DIR_NAME);
28170
+ const OPENBITFUN_SKILLS_DIR_NAME = "skills";
28171
+ const OPENBITFUN_SKILLS_DIR_PATH = join(OPENBITFUN_DIR, OPENBITFUN_SKILLS_DIR_NAME);
28172
+ const OPENBITFUN_CONFIG_DIR_NAME = "config";
28173
+ const OPENBITFUN_CONFIG_DIR_PATH = join(OPENBITFUN_DIR, OPENBITFUN_CONFIG_DIR_NAME);
28174
+ const OPENBITFUN_HOOKS_FILE_NAME = "hooks.json";
28175
+ const OPENBITFUN_DATA_NAMESPACE = "openbitfun";
28176
+ /**
28177
+ * OpenBitFun's user root (`dirs::config_dir()/openbitfun`), relative to the
28178
+ * home directory (the processor resolves the home directory through
28179
+ * `outputRoot`).
28180
+ *
28181
+ * - macOS: `~/Library/Application Support/openbitfun`
28182
+ * - Windows: `%APPDATA%\openbitfun` (`~/AppData/Roaming/openbitfun`)
28183
+ * - Linux and others: `~/.config/openbitfun`
28184
+ *
28185
+ * `$XDG_CONFIG_HOME` and OpenBitFun's `OPENBITFUN_USER_ROOT` override are not
28186
+ * followed; the default locations are assumed (a non-default `$XDG_CONFIG_HOME`
28187
+ * is warned about, see `warnOpenbitfunXdgOverride`).
28188
+ */
28189
+ function openbitfunGlobalRootDir() {
28190
+ switch (process.platform) {
28191
+ case "darwin": return join("Library", "Application Support", OPENBITFUN_DATA_NAMESPACE);
28192
+ case "win32": return join("AppData", "Roaming", OPENBITFUN_DATA_NAMESPACE);
28193
+ default: return join(".config", OPENBITFUN_DATA_NAMESPACE);
28194
+ }
28195
+ }
28196
+ /**
28197
+ * OpenBitFun's user agents directory: `<user root>/agents`.
28198
+ */
28199
+ function openbitfunGlobalAgentsDir() {
28200
+ return join(openbitfunGlobalRootDir(), OPENBITFUN_AGENTS_DIR_NAME);
28201
+ }
28202
+ /**
28203
+ * OpenBitFun's user hooks directory: `<user root>/config` (holding `hooks.json`).
28204
+ */
28205
+ function openbitfunGlobalConfigDir() {
28206
+ return join(openbitfunGlobalRootDir(), OPENBITFUN_CONFIG_DIR_NAME);
28207
+ }
28208
+ /**
28209
+ * OpenBitFun's user skills directory (`user_skills_dir` in `path_manager.rs`).
28210
+ * It is not always under the user root: on Linux it lives in the data dir
28211
+ * (`dirs::data_local_dir()`), not the config dir.
28212
+ *
28213
+ * - macOS: `~/Library/Application Support/openbitfun/skills`
28214
+ * - Windows: `%APPDATA%\openbitfun\skills`
28215
+ * - Linux and others: `~/.local/share/openbitfun/skills`
28216
+ *
28217
+ * `$XDG_DATA_HOME` is not followed; the default location is assumed (a
28218
+ * non-default value is warned about, see `warnOpenbitfunXdgOverride`).
28219
+ */
28220
+ function openbitfunGlobalSkillsDir() {
28221
+ switch (process.platform) {
28222
+ case "darwin":
28223
+ case "win32": return join(openbitfunGlobalRootDir(), OPENBITFUN_SKILLS_DIR_NAME);
28224
+ default: return join(".local", "share", OPENBITFUN_DATA_NAMESPACE, OPENBITFUN_SKILLS_DIR_NAME);
28225
+ }
28226
+ }
28227
+ // src/utils/openbitfun.ts
28228
+ const XDG_OVERRIDES = {
28229
+ config: {
28230
+ envVar: "XDG_CONFIG_HOME",
28231
+ defaultDir: ".config"
28232
+ },
28233
+ data: {
28234
+ envVar: "XDG_DATA_HOME",
28235
+ defaultDir: join(".local", "share")
28236
+ }
28237
+ };
28238
+ /**
28239
+ * Warn, once per run, when an XDG base directory variable moves OpenBitFun's
28240
+ * user tree away from where rulesync writes it in global mode.
28241
+ *
28242
+ * On Linux OpenBitFun resolves its user root through the `dirs` crate
28243
+ * (`dirs::config_dir()`, and `dirs::data_local_dir()` for skills), which
28244
+ * follows `$XDG_CONFIG_HOME` / `$XDG_DATA_HOME` when set to an absolute path.
28245
+ * rulesync writes global files relative to the home directory, at the XDG
28246
+ * default location, so a non-default value means OpenBitFun reads elsewhere.
28247
+ * macOS and Windows do not use these variables.
28248
+ *
28249
+ * @see https://github.com/openBitFun/OpenBitFun/blob/main/src/crates/assembly/core/src/infrastructure/app_paths/path_manager.rs
28250
+ */
28251
+ function warnOpenbitfunXdgOverride({ kind, logger }) {
28252
+ if (process.platform === "darwin" || process.platform === "win32") return;
28253
+ const { envVar, defaultDir } = XDG_OVERRIDES[kind];
28254
+ const value = process.env[envVar]?.trim();
28255
+ if (!value || !isAbsolute(value)) return;
28256
+ const defaultPath = join(getHomeDirectory(), defaultDir);
28257
+ if (resolve(value) === resolve(defaultPath)) return;
28258
+ warnOnceWithFallback(logger, `$${envVar} is set to ${value}, so OpenBitFun reads its user files from ${join(value, "openbitfun")}, but rulesync writes OpenBitFun's global files under ${join("~", defaultDir, "openbitfun")}. Move them there or unset $${envVar} for OpenBitFun.`);
28259
+ }
28260
+ // src/features/skills/openbitfun-skill.ts
28261
+ /**
28262
+ * OpenBitFun skills follow the Agent Skills layout (`<name>/SKILL.md` with
28263
+ * `name` and `description` frontmatter, plus optional supporting files), so
28264
+ * this target reuses {@link AgentsSkillsSkill} with OpenBitFun's locations:
28265
+ * `.openbitfun/skills/` (project) and the OS-dependent user skills directory
28266
+ * (global, see {@link openbitfunGlobalSkillsDir}). A project skill shadows a
28267
+ * user skill of the same name.
28268
+ *
28269
+ * @see https://github.com/openBitFun/OpenBitFun/blob/main/docs/interactive-capabilities/capabilities/feature.skills.md
28270
+ */
28271
+ var OpenbitfunSkill = class extends AgentsSkillsSkill {
28272
+ static getSettablePaths({ global = false } = {}) {
28273
+ return { relativeDirPath: global ? openbitfunGlobalSkillsDir() : OPENBITFUN_SKILLS_DIR_PATH };
28274
+ }
28275
+ static fromRulesyncSkill(params) {
28276
+ if (params.global) warnOpenbitfunXdgOverride({
28277
+ kind: "data",
28278
+ logger: params.logger
28279
+ });
28280
+ return super.fromRulesyncSkill(params);
28281
+ }
28282
+ static toolTarget = "openbitfun";
28283
+ };
28125
28284
  // src/constants/openclaw-paths.ts
28126
28285
  const OPENCLAW_WORKSPACE_DIR_PATH = join(".openclaw", "workspace");
28127
28286
  const OPENCLAW_RULE_FILE_NAME = "AGENTS.md";
@@ -30249,6 +30408,14 @@ const toolSkillFactories = /* @__PURE__ */ new Map([
30249
30408
  supportsGlobal: true
30250
30409
  }
30251
30410
  }],
30411
+ ["openbitfun", {
30412
+ class: OpenbitfunSkill,
30413
+ meta: {
30414
+ supportsProject: true,
30415
+ supportsSimulated: false,
30416
+ supportsGlobal: true
30417
+ }
30418
+ }],
30252
30419
  ["xum", {
30253
30420
  class: XumSkill,
30254
30421
  meta: {
@@ -36067,6 +36234,162 @@ var OmpSubagent = class extends FrontmatterMarkdownToolSubagent {
36067
36234
  };
36068
36235
  }
36069
36236
  };
36237
+ // src/features/subagents/openbitfun-subagent.ts
36238
+ /**
36239
+ * The `kind` rulesync writes: a delegated subagent rather than a top-level
36240
+ * agent mode. It is also OpenBitFun's default when `kind` is omitted.
36241
+ */
36242
+ const OPENBITFUN_SUBAGENT_KIND = "subagent";
36243
+ /**
36244
+ * Frontmatter of an OpenBitFun custom agent. `name` and `description` are
36245
+ * required; `tools` is a list or a comma-separated string. Unknown keys are
36246
+ * kept (looseObject), and OpenBitFun itself ignores keys it does not know.
36247
+ *
36248
+ * @see https://github.com/openBitFun/OpenBitFun/blob/main/src/crates/execution/agent-runtime/src/custom_agent.rs
36249
+ */
36250
+ const OpenbitfunSubagentFrontmatterSchema = z.looseObject({
36251
+ name: z.string(),
36252
+ description: z.string(),
36253
+ kind: z.optional(z.enum(["mode", "subagent"])),
36254
+ tools: z.optional(z.union([z.string(), z.array(z.string())])),
36255
+ model: z.optional(z.string()),
36256
+ readonly: z.optional(z.boolean()),
36257
+ review: z.optional(z.boolean())
36258
+ });
36259
+ /**
36260
+ * Subagent generator for OpenBitFun.
36261
+ *
36262
+ * OpenBitFun reads custom agents — Markdown with YAML frontmatter, the body
36263
+ * being the prompt — from `.openbitfun/agents/` (project) and
36264
+ * `<user root>/agents/` (user; see {@link openbitfunGlobalAgentsDir}).
36265
+ *
36266
+ * rulesync writes `name`, `description` and `kind: subagent`, then spreads the
36267
+ * `openbitfun` section (`kind`, `tools`, `model`, `readonly`, `review`, `id`,
36268
+ * `user_context_policy`, ...) on top, so a value set there wins. OpenBitFun
36269
+ * requires `description`, so an absent one is written as an empty string.
36270
+ *
36271
+ * @see https://github.com/openBitFun/OpenBitFun/blob/main/src/crates/execution/agent-runtime/src/custom_agent.rs
36272
+ */
36273
+ var OpenbitfunSubagent = class OpenbitfunSubagent extends ToolSubagent {
36274
+ frontmatter;
36275
+ body;
36276
+ constructor({ frontmatter, body, ...rest }) {
36277
+ if (rest.validate !== false) {
36278
+ const result = OpenbitfunSubagentFrontmatterSchema.safeParse(frontmatter);
36279
+ if (!result.success) throw new Error(`Invalid frontmatter in ${join(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`);
36280
+ }
36281
+ super({ ...rest });
36282
+ this.frontmatter = frontmatter;
36283
+ this.body = body;
36284
+ }
36285
+ static getSettablePaths({ global = false } = {}) {
36286
+ return { relativeDirPath: global ? openbitfunGlobalAgentsDir() : OPENBITFUN_AGENTS_DIR_PATH };
36287
+ }
36288
+ getFrontmatter() {
36289
+ return this.frontmatter;
36290
+ }
36291
+ getBody() {
36292
+ return this.body;
36293
+ }
36294
+ toRulesyncSubagent() {
36295
+ const { name, description, kind, ...restFields } = this.frontmatter;
36296
+ const openbitfunSection = {
36297
+ ...kind !== void 0 && kind !== OPENBITFUN_SUBAGENT_KIND && { kind },
36298
+ ...restFields
36299
+ };
36300
+ return new RulesyncSubagent({
36301
+ outputRoot: ".",
36302
+ frontmatter: {
36303
+ targets: ["*"],
36304
+ name,
36305
+ ...description && { description },
36306
+ ...Object.keys(openbitfunSection).length > 0 && { openbitfun: openbitfunSection }
36307
+ },
36308
+ body: this.body,
36309
+ relativeDirPath: RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH,
36310
+ relativeFilePath: this.getRelativeFilePath(),
36311
+ validate: true
36312
+ });
36313
+ }
36314
+ static fromRulesyncSubagent({ outputRoot = process.cwd(), rulesyncSubagent, validate = true, global = false, logger }) {
36315
+ if (global) warnOpenbitfunXdgOverride({
36316
+ kind: "config",
36317
+ logger
36318
+ });
36319
+ const rulesyncFrontmatter = rulesyncSubagent.getFrontmatter();
36320
+ const openbitfunSection = this.filterToolSpecificSection(rulesyncFrontmatter.openbitfun ?? {}, ["name", "description"]);
36321
+ const openbitfunFrontmatter = parseGeneratedSubagentFrontmatter({
36322
+ schema: OpenbitfunSubagentFrontmatterSchema,
36323
+ frontmatter: {
36324
+ name: rulesyncFrontmatter.name,
36325
+ description: rulesyncFrontmatter.description ?? "",
36326
+ kind: OPENBITFUN_SUBAGENT_KIND,
36327
+ ...openbitfunSection
36328
+ },
36329
+ toolTarget: "openbitfun",
36330
+ rulesyncSubagent
36331
+ });
36332
+ const body = rulesyncSubagent.getBody();
36333
+ return new OpenbitfunSubagent({
36334
+ outputRoot,
36335
+ frontmatter: openbitfunFrontmatter,
36336
+ body,
36337
+ relativeDirPath: this.getSettablePaths({ global }).relativeDirPath,
36338
+ relativeFilePath: rulesyncSubagent.getRelativeFilePath(),
36339
+ fileContent: stringifyFrontmatter(body, openbitfunFrontmatter),
36340
+ validate
36341
+ });
36342
+ }
36343
+ validate() {
36344
+ if (!this.frontmatter) return {
36345
+ success: true,
36346
+ error: null
36347
+ };
36348
+ return validateFrontmatterSchema({
36349
+ schema: OpenbitfunSubagentFrontmatterSchema,
36350
+ frontmatter: this.frontmatter,
36351
+ relativeDirPath: this.relativeDirPath,
36352
+ relativeFilePath: this.relativeFilePath
36353
+ });
36354
+ }
36355
+ static isTargetedByRulesyncSubagent(rulesyncSubagent) {
36356
+ return this.isTargetedByRulesyncSubagentDefault({
36357
+ rulesyncSubagent,
36358
+ toolTarget: "openbitfun"
36359
+ });
36360
+ }
36361
+ static async fromFile({ outputRoot = process.cwd(), relativeFilePath, validate = true, global = false }) {
36362
+ const paths = this.getSettablePaths({ global });
36363
+ const filePath = join(outputRoot, paths.relativeDirPath, relativeFilePath);
36364
+ const fileContent = await readFileContent(filePath);
36365
+ const { frontmatter, body } = parseFrontmatter(fileContent, filePath);
36366
+ const result = OpenbitfunSubagentFrontmatterSchema.safeParse(frontmatter);
36367
+ if (!result.success) throw new Error(`Invalid frontmatter in ${filePath}: ${formatError(result.error)}`);
36368
+ return new OpenbitfunSubagent({
36369
+ outputRoot,
36370
+ relativeDirPath: paths.relativeDirPath,
36371
+ relativeFilePath,
36372
+ frontmatter: result.data,
36373
+ body: body.trim(),
36374
+ fileContent,
36375
+ validate
36376
+ });
36377
+ }
36378
+ static forDeletion({ outputRoot = process.cwd(), relativeDirPath, relativeFilePath }) {
36379
+ return new OpenbitfunSubagent({
36380
+ outputRoot,
36381
+ relativeDirPath,
36382
+ relativeFilePath,
36383
+ frontmatter: {
36384
+ name: "",
36385
+ description: ""
36386
+ },
36387
+ body: "",
36388
+ fileContent: "",
36389
+ validate: false
36390
+ });
36391
+ }
36392
+ };
36070
36393
  // src/features/subagents/opencodev1-subagent.ts
36071
36394
  /**
36072
36395
  * Subagent generator for **OpenCode V1** (OpenCode 1.x), which reads the V1
@@ -38447,6 +38770,15 @@ const toolSubagentFactories = /* @__PURE__ */ new Map([
38447
38770
  filePattern: "*.toml"
38448
38771
  }
38449
38772
  }],
38773
+ ["openbitfun", {
38774
+ class: OpenbitfunSubagent,
38775
+ meta: {
38776
+ supportsProject: true,
38777
+ supportsSimulated: false,
38778
+ supportsGlobal: true,
38779
+ filePattern: "*.md"
38780
+ }
38781
+ }],
38450
38782
  ["xum", {
38451
38783
  class: XumSubagent,
38452
38784
  meta: {
@@ -45048,7 +45380,7 @@ const TOOL_DISPLAY = [
45048
45380
  },
45049
45381
  {
45050
45382
  key: "firebender",
45051
- label: "Firebender",
45383
+ label: "Firebender ⚠️",
45052
45384
  group: "ai"
45053
45385
  },
45054
45386
  {
@@ -45066,6 +45398,11 @@ const TOOL_DISPLAY = [
45066
45398
  label: "OpenClaw",
45067
45399
  group: "ai"
45068
45400
  },
45401
+ {
45402
+ key: "openbitfun",
45403
+ label: "OpenBitFun",
45404
+ group: "ai"
45405
+ },
45069
45406
  {
45070
45407
  key: "mimocode",
45071
45408
  label: "MiMo Code",
@@ -57741,7 +58078,7 @@ function describeRejectedHandler(handler) {
57741
58078
  * MCP hooks are skipped with a startup warning). Matcher groups left without
57742
58079
  * handlers are removed. https://learn.chatgpt.com/docs/hooks
57743
58080
  */
57744
- function filterCodexHandlers({ hooks, logger }) {
58081
+ function filterCodexHandlers({ hooks, toolLabel, describeRejected, logger }) {
57745
58082
  const result = {};
57746
58083
  const skippedSessionEndTools = [];
57747
58084
  for (const [eventName, groups] of Object.entries(hooks)) {
@@ -57753,9 +58090,9 @@ function filterCodexHandlers({ hooks, logger }) {
57753
58090
  continue;
57754
58091
  }
57755
58092
  const handlers = entry.hooks.filter((handler) => {
57756
- const reason = describeRejectedHandler(handler);
58093
+ const reason = describeRejected(handler);
57757
58094
  if (reason !== void 0) {
57758
- logger?.warn(`Skipping a "${String(handler.type)}" hook on Codex CLI "${eventName}": ${reason}.`);
58095
+ logger?.warn(`Skipping a "${String(handler.type)}" hook on ${toolLabel} "${eventName}": ${reason}.`);
57759
58096
  return false;
57760
58097
  }
57761
58098
  if (eventName === "SessionEnd" && handler.type === "mcp_tool") skippedSessionEndTools.push(`${String(handler.server)}/${String(handler.tool)}`);
@@ -57772,6 +58109,56 @@ function filterCodexHandlers({ hooks, logger }) {
57772
58109
  return result;
57773
58110
  }
57774
58111
  /**
58112
+ * Generate the content of a Codex-shaped `hooks.json` (`{ hooks: { <Event>:
58113
+ * [matcher groups] } }`) at `relativeDirPath/relativeFilePath`. Shared by the
58114
+ * Codex CLI target and tools that read the same document (OpenBitFun), which
58115
+ * differ only in where the file lives, which events and handler types they
58116
+ * run, and which rulesync override section they read.
58117
+ */
58118
+ async function buildCodexStyleHooksFile({ outputRoot, relativeDirPath, relativeFilePath, rulesyncHooks, toolOverrideHooks, converterConfig, toolLabel, describeRejected = describeRejectedHandler, preserveUnowned, logger }) {
58119
+ const merged = mergeGeneratedHookLists({
58120
+ existingContent: await readFileContentOrNull(join(outputRoot, relativeDirPath, relativeFilePath)) ?? "",
58121
+ generatedHooks: filterCodexHandlers({
58122
+ hooks: canonicalToToolHooks({
58123
+ config: rulesyncHooks.getJson(),
58124
+ toolOverrideHooks,
58125
+ converterConfig,
58126
+ logger
58127
+ }),
58128
+ toolLabel,
58129
+ describeRejected,
58130
+ logger
58131
+ }),
58132
+ shape: "matcher-groups",
58133
+ preserveUnowned,
58134
+ previouslyOwned: preserveUnowned ? await readPreviouslyOwnedHooks({
58135
+ outputRoot,
58136
+ relativeDirPath
58137
+ }) : void 0,
58138
+ logger
58139
+ });
58140
+ return {
58141
+ fileContent: JSON.stringify({ hooks: merged.hooks }, null, 2),
58142
+ owned: merged.owned
58143
+ };
58144
+ }
58145
+ /**
58146
+ * Convert the parsed content of a Codex-shaped `hooks.json` back to the
58147
+ * rulesync hooks JSON, with tool-only hooks under `overrideKey`.
58148
+ */
58149
+ function codexStyleHooksToRulesyncContent({ parsed, converterConfig, overrideKey, logger }) {
58150
+ const hooks = toolHooksToCanonical({
58151
+ hooks: parsed.hooks,
58152
+ converterConfig,
58153
+ logger
58154
+ });
58155
+ return JSON.stringify(buildImportedHooksConfig({
58156
+ logger,
58157
+ hooks,
58158
+ overrideKey
58159
+ }), null, 2);
58160
+ }
58161
+ /**
57775
58162
  * Build the content for `.codex/config.toml`, cleaning up the deprecated `codex_hooks` key.
57776
58163
  * Reads the existing file (if any), parses TOML, and returns the content without writing to
57777
58164
  * disk. The caller is responsible for writing via the normal write phase.
@@ -57843,51 +58230,37 @@ var CodexcliHooks = class CodexcliHooks extends ToolHooks {
57843
58230
  }
57844
58231
  static async fromRulesyncHooks({ outputRoot = process.cwd(), rulesyncHooks, validate = true, global = false, preserveUnowned = false, logger }) {
57845
58232
  const paths = CodexcliHooks.getSettablePaths({ global });
57846
- const existingContent = await readFileContentOrNull(join(outputRoot, paths.relativeDirPath, paths.relativeFilePath)) ?? "";
57847
- const config = rulesyncHooks.getJson();
57848
- const merged = mergeGeneratedHookLists({
57849
- existingContent,
57850
- generatedHooks: filterCodexHandlers({
57851
- hooks: canonicalToToolHooks({
57852
- config,
57853
- toolOverrideHooks: config.codexcli?.hooks,
57854
- converterConfig: CODEXCLI_CONVERTER_CONFIG,
57855
- logger
57856
- }),
57857
- logger
57858
- }),
57859
- shape: "matcher-groups",
58233
+ const { fileContent, owned } = await buildCodexStyleHooksFile({
58234
+ outputRoot,
58235
+ relativeDirPath: paths.relativeDirPath,
58236
+ relativeFilePath: paths.relativeFilePath,
58237
+ rulesyncHooks,
58238
+ toolOverrideHooks: rulesyncHooks.getJson().codexcli?.hooks,
58239
+ converterConfig: CODEXCLI_CONVERTER_CONFIG,
58240
+ toolLabel: "Codex CLI",
57860
58241
  preserveUnowned,
57861
- previouslyOwned: preserveUnowned ? await readPreviouslyOwnedHooks({
57862
- outputRoot,
57863
- relativeDirPath: paths.relativeDirPath
57864
- }) : void 0,
57865
58242
  logger
57866
58243
  });
57867
- const fileContent = JSON.stringify({ hooks: merged.hooks }, null, 2);
57868
58244
  return new CodexcliHooks({
57869
58245
  outputRoot,
57870
58246
  relativeDirPath: paths.relativeDirPath,
57871
58247
  relativeFilePath: paths.relativeFilePath,
57872
58248
  fileContent,
57873
- ownedHookRefs: preserveUnowned ? merged.owned : void 0,
58249
+ ownedHookRefs: preserveUnowned ? owned : void 0,
57874
58250
  validate
57875
58251
  });
57876
58252
  }
57877
58253
  toRulesyncHooks({ logger } = {}) {
57878
- const hooks = toolHooksToCanonical({
57879
- hooks: this.parseFileContentOrThrow({
57880
- displayName: "Codex CLI",
57881
- parse: (fileContent) => JSON.parse(fileContent)
57882
- }).hooks,
58254
+ const parsed = this.parseFileContentOrThrow({
58255
+ displayName: "Codex CLI",
58256
+ parse: (fileContent) => JSON.parse(fileContent)
58257
+ });
58258
+ return this.toRulesyncHooksDefault({ fileContent: codexStyleHooksToRulesyncContent({
58259
+ parsed,
57883
58260
  converterConfig: CODEXCLI_CONVERTER_CONFIG,
58261
+ overrideKey: "codexcli",
57884
58262
  logger
57885
- });
57886
- return this.toRulesyncHooksDefault({ fileContent: JSON.stringify(buildImportedHooksConfig({
57887
- logger,
57888
- hooks,
57889
- overrideKey: "codexcli"
57890
- }), null, 2) });
58263
+ }) });
57891
58264
  }
57892
58265
  static supportsPreserveUnowned() {
57893
58266
  return true;
@@ -63600,6 +63973,162 @@ var OmpHooks = class OmpHooks extends ToolHooks {
63600
63973
  });
63601
63974
  }
63602
63975
  };
63976
+ // src/features/hooks/openbitfun-hooks.ts
63977
+ /**
63978
+ * Canonical (Claude Code) tool names whose OpenBitFun runtime name differs.
63979
+ * OpenBitFun's shell tool is `ExecCommand`; its own Claude-dialect skill hook
63980
+ * adapter maps `Bash` onto it, with the shell command in `tool_input.cmd`.
63981
+ * `Read`, `Write`, `Edit`, `Glob`, `Grep`, `WebFetch`, `WebSearch`, `Skill` and
63982
+ * `LS` share their names, so they need no entry.
63983
+ * @see https://github.com/openBitFun/OpenBitFun/blob/main/src/crates/execution/agent-runtime/src/skills/hooks.rs
63984
+ */
63985
+ const CANONICAL_TO_OPENBITFUN_TOOL_NAMES = { Bash: "ExecCommand" };
63986
+ const OPENBITFUN_TO_CANONICAL_TOOL_NAMES = Object.fromEntries(Object.entries(CANONICAL_TO_OPENBITFUN_TOOL_NAMES).map(([canonical, tool]) => [tool, canonical]));
63987
+ /**
63988
+ * OpenBitFun's built-in tool names (the default custom-agent tool sets in
63989
+ * `custom_agent.rs`, plus `LS`). Capitalized matcher names outside this set
63990
+ * are warned about on events that gate a tool call.
63991
+ * @see https://github.com/openBitFun/OpenBitFun/blob/main/src/crates/execution/agent-runtime/src/custom_agent.rs
63992
+ */
63993
+ const OPENBITFUN_TOOL_NAMES = /* @__PURE__ */ new Set([
63994
+ "Read",
63995
+ "Glob",
63996
+ "Grep",
63997
+ "LS",
63998
+ "Write",
63999
+ "Edit",
64000
+ "Delete",
64001
+ "ExecCommand",
64002
+ "WriteStdin",
64003
+ "ExecControl",
64004
+ "AgentSpawn",
64005
+ "AgentFork",
64006
+ "AgentSendInput",
64007
+ "AgentControl",
64008
+ "AgentList",
64009
+ "AgentWait",
64010
+ "ListModels",
64011
+ "Skill",
64012
+ "WebSearch",
64013
+ "WebFetch"
64014
+ ]);
64015
+ /**
64016
+ * Events whose hooks can deny a tool call, so a matcher that never matches
64017
+ * makes the guard fail open. The keys are canonical names, or OpenBitFun's own
64018
+ * names when the hook comes from the `openbitfun.hooks` override block.
64019
+ */
64020
+ const TOOL_GATING_EVENTS = /* @__PURE__ */ new Set([
64021
+ "preToolUse",
64022
+ "permissionRequest",
64023
+ "PreToolUse",
64024
+ "PermissionRequest"
64025
+ ]);
64026
+ function canonicalToOpenbitfunMatcher({ matcher, eventName, warn }) {
64027
+ const translated = replaceMatcherNames(matcher, CANONICAL_TO_OPENBITFUN_TOOL_NAMES);
64028
+ if (TOOL_GATING_EVENTS.has(eventName)) {
64029
+ const unknown = capitalizedMatcherNames(translated).filter((name) => !OPENBITFUN_TOOL_NAMES.has(name));
64030
+ if (unknown.length > 0) warn(`${unknown.map((name) => quoteValueForWarning(name)).join(", ")} in the "${eventName}" matcher ${quoteValueForWarning(matcher)} is not an OpenBitFun built-in tool, so it is written as-is and will likely never match there, and the hook will not run for that tool.`);
64031
+ }
64032
+ return translated;
64033
+ }
64034
+ function openbitfunToCanonicalMatcher(matcher) {
64035
+ return replaceMatcherNames(matcher, OPENBITFUN_TO_CANONICAL_TOOL_NAMES);
64036
+ }
64037
+ /**
64038
+ * Why OpenBitFun would skip a generated handler, or `undefined` when it runs
64039
+ * it. OpenBitFun's `parse_handler` treats a command handler whose `timeout` is
64040
+ * not a positive integer as invalid and skips that handler.
64041
+ * @see https://github.com/openBitFun/OpenBitFun/blob/main/src/crates/execution/agent-runtime/src/native_hooks/settings.rs
64042
+ */
64043
+ function describeRejectedOpenbitfunHandler(handler) {
64044
+ const { timeout } = handler;
64045
+ if (timeout !== void 0 && (typeof timeout !== "number" || !Number.isSafeInteger(timeout) || timeout <= 0)) return `its "timeout" ${JSON.stringify(timeout) ?? String(timeout)} is not a positive integer, so OpenBitFun would skip it as invalid`;
64046
+ }
64047
+ /**
64048
+ * OpenBitFun implements the Codex hook contract: the same `hooks.json`
64049
+ * document, handler fields and matcher semantics (regexes anchored to the
64050
+ * whole tool name). It differs in the events it dispatches, in running only
64051
+ * `type: "command"` handlers (`prompt` and `agent` handlers are parsed but
64052
+ * skipped), in its runtime tool names (`ExecCommand` for `Bash`), and in the
64053
+ * handler fields it reads: `command`, `commandWindows`, `timeout` and
64054
+ * `statusMessage` only, so Codex's `async` and `additionalContextLimit` are
64055
+ * not forwarded.
64056
+ * @see https://github.com/openBitFun/OpenBitFun/blob/main/docs/features/agent-hooks.md
64057
+ * @see https://github.com/openBitFun/OpenBitFun/blob/main/src/crates/execution/agent-runtime/src/native_hooks/settings.rs
64058
+ */
64059
+ const OPENBITFUN_CONVERTER_CONFIG = {
64060
+ ...CODEXCLI_CONVERTER_CONFIG,
64061
+ supportedEvents: OPENBITFUN_HOOK_EVENTS,
64062
+ canonicalToToolEventNames: CANONICAL_TO_OPENBITFUN_EVENT_NAMES,
64063
+ toolToCanonicalEventNames: OPENBITFUN_TO_CANONICAL_EVENT_NAMES,
64064
+ supportedHookTypes: /* @__PURE__ */ new Set(["command"]),
64065
+ numberPassthroughFields: [],
64066
+ booleanPassthroughFields: [],
64067
+ matcherTranslation: {
64068
+ toTool: canonicalToOpenbitfunMatcher,
64069
+ toCanonical: openbitfunToCanonicalMatcher
64070
+ }
64071
+ };
64072
+ /**
64073
+ * Hooks generator for OpenBitFun: a Codex-shaped `hooks.json` at
64074
+ * `.openbitfun/config/hooks.json` (project) and `<user root>/config/hooks.json`
64075
+ * (global; see {@link openbitfunGlobalConfigDir}). Both layers are additive.
64076
+ *
64077
+ * Project hooks are off by default in OpenBitFun: they only run once the
64078
+ * `app.hooks.project_hooks_enabled` setting is turned on.
64079
+ *
64080
+ * @see https://github.com/openBitFun/OpenBitFun/blob/main/docs/features/agent-hooks.md
64081
+ */
64082
+ var OpenbitfunHooks = class OpenbitfunHooks extends ToolHooks {
64083
+ static getSettablePaths({ global = false } = {}) {
64084
+ return {
64085
+ relativeDirPath: global ? openbitfunGlobalConfigDir() : OPENBITFUN_CONFIG_DIR_PATH,
64086
+ relativeFilePath: OPENBITFUN_HOOKS_FILE_NAME
64087
+ };
64088
+ }
64089
+ static async fromRulesyncHooks({ outputRoot = process.cwd(), rulesyncHooks, validate = true, global = false, preserveUnowned = false, logger }) {
64090
+ if (global) warnOpenbitfunXdgOverride({
64091
+ kind: "config",
64092
+ logger
64093
+ });
64094
+ const paths = OpenbitfunHooks.getSettablePaths({ global });
64095
+ const { fileContent, owned } = await buildCodexStyleHooksFile({
64096
+ outputRoot,
64097
+ relativeDirPath: paths.relativeDirPath,
64098
+ relativeFilePath: paths.relativeFilePath,
64099
+ rulesyncHooks,
64100
+ toolOverrideHooks: rulesyncHooks.getJson().openbitfun?.hooks,
64101
+ converterConfig: OPENBITFUN_CONVERTER_CONFIG,
64102
+ toolLabel: "OpenBitFun",
64103
+ describeRejected: describeRejectedOpenbitfunHandler,
64104
+ preserveUnowned,
64105
+ logger
64106
+ });
64107
+ return new OpenbitfunHooks({
64108
+ outputRoot,
64109
+ relativeDirPath: paths.relativeDirPath,
64110
+ relativeFilePath: paths.relativeFilePath,
64111
+ fileContent,
64112
+ ownedHookRefs: preserveUnowned ? owned : void 0,
64113
+ validate
64114
+ });
64115
+ }
64116
+ toRulesyncHooks({ logger } = {}) {
64117
+ const parsed = this.parseFileContentOrThrow({
64118
+ displayName: "OpenBitFun",
64119
+ parse: (fileContent) => JSON.parse(fileContent)
64120
+ });
64121
+ return this.toRulesyncHooksDefault({ fileContent: codexStyleHooksToRulesyncContent({
64122
+ parsed,
64123
+ converterConfig: OPENBITFUN_CONVERTER_CONFIG,
64124
+ overrideKey: "openbitfun",
64125
+ logger
64126
+ }) });
64127
+ }
64128
+ static supportsPreserveUnowned() {
64129
+ return true;
64130
+ }
64131
+ };
63603
64132
  // src/features/hooks/opencodev1-hooks.ts
63604
64133
  /**
63605
64134
  * Hooks generator for **OpenCode V1** (OpenCode 1.x). OpenCode 2.x does not
@@ -65680,6 +66209,16 @@ const toolHooksFactories = /* @__PURE__ */ new Map([
65680
66209
  ...converterCapabilities(CODEXCLI_CONVERTER_CONFIG),
65681
66210
  supportsMatcher: true
65682
66211
  }],
66212
+ ["openbitfun", {
66213
+ class: OpenbitfunHooks,
66214
+ meta: {
66215
+ supportsProject: true,
66216
+ supportsGlobal: true,
66217
+ supportsImport: true
66218
+ },
66219
+ ...converterCapabilities(OPENBITFUN_CONVERTER_CONFIG),
66220
+ supportsMatcher: true
66221
+ }],
65683
66222
  ["commandcode", {
65684
66223
  class: CommandcodeHooks,
65685
66224
  meta: {
@@ -109260,4 +109799,4 @@ const CHECKS_IMPORT_STRATEGY = {
109260
109799
  };
109261
109800
  export { RulesyncSkillFrontmatterSchema 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_DIR 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, findProjectInstructionBudgetFindings as G, RULESYNC_IGNORE_RELATIVE_FILE_PATH as Gn, assertWritablePathInsideRoot as Gt, CLAUDECODE_MEMORIES_DIR_NAME as H, RULESYNC_CURATED_RULES_RELATIVE_DIR_PATH as Hn, assertNoSymlinkBelowRoot as Ht, loadYaml as I, MAX_FILE_SIZE as In, ErrorCodes as It, hasWindowsFoldableName as J, RULESYNC_MCP_SCHEMA_URL as Jn, directoryExists as Jt, toInstructionBudgetFile as K, RULESYNC_LOCAL_CONFIG_RELATIVE_FILE_PATH as Kn, checkPathTraversal as Kt, CODEXCLI_BASH_RULES_FILE_NAME 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, RulesyncSkill as Q, RULESYNC_RELATIVE_DIR_PATH as Qn, findFilesByGlobs as Qt, CODEXCLI_DIR 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_SETTINGS_LOCAL_FILE_NAME as U, RULESYNC_CURATED_SKILLS_RELATIVE_DIR_PATH as Un, assertPathResolvesInsideRoot as Ut, CLAUDECODE_LOCAL_RULE_FILE_NAME as V, RULESYNC_CONFIG_SCHEMA_URL as Vn, assertLandingOutsideVcsMetadata as Vt, CLAUDECODE_SKILLS_DIR_PATH as W, RULESYNC_HOOKS_RELATIVE_FILE_PATH as Wn, assertTreeContainsNoSymlinks as Wt, RulesyncSubagent as X, RULESYNC_PERMISSIONS_RELATIVE_FILE_PATH as Xn, fileExists as Xt, getLocalSkillDirNames as Y, RULESYNC_NPM_SOURCES_LOCK_RELATIVE_FILE_PATH as Yn, ensureDir as Yt, RulesyncSubagentFrontmatterSchema 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, RulesyncHooks 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, RulesyncCommand as ct, McpProcessor as d, readFileContent as dn, stripControlCharactersKeepingLineFeeds as dr, RulesyncCheckFrontmatterSchema as dt, getHomeDirectory as en, RULESYNC_SKILLS_RELATIVE_DIR_PATH as er, RulesyncRule as et, IgnoreProcessor as f, readFileContentOrNull as fn, stripControlCharactersKeepingLineFeedsAndTabs as fr, stringifyFrontmatter 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, RulesyncIgnore 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, RulesyncCommandFrontmatterSchema 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, RulesyncPermissions as nt, getProcessorRegistryEntry as o, listFilePathsRecursively as on, formatError as or, getRulesyncSourceCandidates as ot, HooksProcessor as p, removeDirectory as pn, stripHiddenCharacters as pr, isRecord as pt, classifyRemoteName 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, RulesyncMcp as rt, parseCommaSeparatedList as s, listSubdirectoryNames as sn, truncateText as sr, resolveRulesyncSourceWritePath as st, importFromTool as t, isFileNotFoundError as tn, RULESYNC_SOURCES_LOCK_RELATIVE_FILE_PATH as tr, RulesyncRuleFrontmatterSchema as tt, shortenToWidth as u, posixRelativePathEscapesRoot as un, stripControlCharacters as ur, RulesyncCheck 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_AGENT_MEMORY_LOCAL_DIR_NAME as z, RULESYNC_COMMANDS_RELATIVE_DIR_PATH as zn, applyFileMode as zt };
109262
109801
 
109263
- //# sourceMappingURL=import-yOMJuum5.js.map
109802
+ //# sourceMappingURL=import-Ch9kXISC.js.map