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.
@@ -381,36 +381,36 @@ function formatError(error) {
381
381
  return boundErrorMessage(String(error));
382
382
  }
383
383
  // src/constants/rulesync-paths.ts
384
- const { join: join$360 } = node_path.posix;
384
+ const { join: join$363 } = node_path.posix;
385
385
  const RULESYNC_CONFIG_RELATIVE_FILE_PATH = "rulesync.jsonc";
386
386
  const RULESYNC_LOCAL_CONFIG_RELATIVE_FILE_PATH = "rulesync.local.jsonc";
387
387
  const RULESYNC_USER_CONFIG_DIR_NAME = "rulesync";
388
388
  const RULESYNC_XDG_CONFIG_HOME_DEFAULT_DIR_NAME = ".config";
389
389
  const RULESYNC_RELATIVE_DIR_PATH = ".rulesync";
390
390
  const RULES_FEATURE_SUBDIR = "rules";
391
- const CURATED_RULES_FEATURE_SUBDIR = join$360(RULES_FEATURE_SUBDIR, ".curated");
391
+ const CURATED_RULES_FEATURE_SUBDIR = join$363(RULES_FEATURE_SUBDIR, ".curated");
392
392
  const COMMANDS_FEATURE_SUBDIR = "commands";
393
393
  const SUBAGENTS_FEATURE_SUBDIR = "subagents";
394
394
  const CHECKS_FEATURE_SUBDIR = "checks";
395
395
  const SKILLS_FEATURE_SUBDIR = "skills";
396
- const CURATED_SKILLS_FEATURE_SUBDIR = join$360(SKILLS_FEATURE_SUBDIR, ".curated");
397
- const RULESYNC_RULES_RELATIVE_DIR_PATH = join$360(RULESYNC_RELATIVE_DIR_PATH, RULES_FEATURE_SUBDIR);
398
- const RULESYNC_CURATED_RULES_RELATIVE_DIR_PATH = join$360(RULESYNC_RELATIVE_DIR_PATH, CURATED_RULES_FEATURE_SUBDIR);
399
- const RULESYNC_COMMANDS_RELATIVE_DIR_PATH = join$360(RULESYNC_RELATIVE_DIR_PATH, COMMANDS_FEATURE_SUBDIR);
400
- const RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH = join$360(RULESYNC_RELATIVE_DIR_PATH, SUBAGENTS_FEATURE_SUBDIR);
401
- const RULESYNC_CHECKS_RELATIVE_DIR_PATH = join$360(RULESYNC_RELATIVE_DIR_PATH, CHECKS_FEATURE_SUBDIR);
402
- const RULESYNC_MCP_RELATIVE_FILE_PATH = join$360(RULESYNC_RELATIVE_DIR_PATH, "mcp.jsonc");
403
- const RULESYNC_HOOKS_RELATIVE_FILE_PATH = join$360(RULESYNC_RELATIVE_DIR_PATH, "hooks.jsonc");
404
- const RULESYNC_PERMISSIONS_RELATIVE_FILE_PATH = join$360(RULESYNC_RELATIVE_DIR_PATH, "permissions.jsonc");
405
- join$360(RULESYNC_RELATIVE_DIR_PATH, "mcp.json");
406
- const RULESYNC_HOOKS_LEGACY_RELATIVE_FILE_PATH = join$360(RULESYNC_RELATIVE_DIR_PATH, "hooks.json");
407
- const RULESYNC_PERMISSIONS_LEGACY_RELATIVE_FILE_PATH = join$360(RULESYNC_RELATIVE_DIR_PATH, "permissions.json");
396
+ const CURATED_SKILLS_FEATURE_SUBDIR = join$363(SKILLS_FEATURE_SUBDIR, ".curated");
397
+ const RULESYNC_RULES_RELATIVE_DIR_PATH = join$363(RULESYNC_RELATIVE_DIR_PATH, RULES_FEATURE_SUBDIR);
398
+ const RULESYNC_CURATED_RULES_RELATIVE_DIR_PATH = join$363(RULESYNC_RELATIVE_DIR_PATH, CURATED_RULES_FEATURE_SUBDIR);
399
+ const RULESYNC_COMMANDS_RELATIVE_DIR_PATH = join$363(RULESYNC_RELATIVE_DIR_PATH, COMMANDS_FEATURE_SUBDIR);
400
+ const RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH = join$363(RULESYNC_RELATIVE_DIR_PATH, SUBAGENTS_FEATURE_SUBDIR);
401
+ const RULESYNC_CHECKS_RELATIVE_DIR_PATH = join$363(RULESYNC_RELATIVE_DIR_PATH, CHECKS_FEATURE_SUBDIR);
402
+ const RULESYNC_MCP_RELATIVE_FILE_PATH = join$363(RULESYNC_RELATIVE_DIR_PATH, "mcp.jsonc");
403
+ const RULESYNC_HOOKS_RELATIVE_FILE_PATH = join$363(RULESYNC_RELATIVE_DIR_PATH, "hooks.jsonc");
404
+ const RULESYNC_PERMISSIONS_RELATIVE_FILE_PATH = join$363(RULESYNC_RELATIVE_DIR_PATH, "permissions.jsonc");
405
+ join$363(RULESYNC_RELATIVE_DIR_PATH, "mcp.json");
406
+ const RULESYNC_HOOKS_LEGACY_RELATIVE_FILE_PATH = join$363(RULESYNC_RELATIVE_DIR_PATH, "hooks.json");
407
+ const RULESYNC_PERMISSIONS_LEGACY_RELATIVE_FILE_PATH = join$363(RULESYNC_RELATIVE_DIR_PATH, "permissions.json");
408
408
  const RULESYNC_AIIGNORE_FILE_NAME = ".aiignore";
409
- const RULESYNC_AIIGNORE_RELATIVE_FILE_PATH = join$360(RULESYNC_RELATIVE_DIR_PATH, ".aiignore");
409
+ const RULESYNC_AIIGNORE_RELATIVE_FILE_PATH = join$363(RULESYNC_RELATIVE_DIR_PATH, ".aiignore");
410
410
  const RULESYNC_IGNORE_RELATIVE_FILE_PATH = ".rulesyncignore";
411
411
  const RULESYNC_OVERVIEW_FILE_NAME = "overview.md";
412
- const RULESYNC_SKILLS_RELATIVE_DIR_PATH = join$360(RULESYNC_RELATIVE_DIR_PATH, SKILLS_FEATURE_SUBDIR);
413
- const RULESYNC_CURATED_SKILLS_RELATIVE_DIR_PATH = join$360(RULESYNC_RELATIVE_DIR_PATH, CURATED_SKILLS_FEATURE_SUBDIR);
412
+ const RULESYNC_SKILLS_RELATIVE_DIR_PATH = join$363(RULESYNC_RELATIVE_DIR_PATH, SKILLS_FEATURE_SUBDIR);
413
+ const RULESYNC_CURATED_SKILLS_RELATIVE_DIR_PATH = join$363(RULESYNC_RELATIVE_DIR_PATH, CURATED_SKILLS_FEATURE_SUBDIR);
414
414
  const RULESYNC_SOURCES_LOCK_RELATIVE_FILE_PATH = "rulesync.lock";
415
415
  const RULESYNC_NPM_SOURCES_LOCK_RELATIVE_FILE_PATH = "rulesync-npm.lock.json";
416
416
  const RULESYNC_MCP_FILE_NAME = "mcp.jsonc";
@@ -767,6 +767,7 @@ const subagentsProcessorToolTargetTuple = [
767
767
  "omp",
768
768
  "opencode",
769
769
  "opencodev1",
770
+ "openbitfun",
770
771
  "pool",
771
772
  "qoder",
772
773
  "qwencode",
@@ -827,6 +828,7 @@ const skillsProcessorToolTargetTuple = [
827
828
  "omp",
828
829
  "opencode",
829
830
  "opencodev1",
831
+ "openbitfun",
830
832
  "pi",
831
833
  "pool",
832
834
  "qoder",
@@ -875,6 +877,7 @@ const hooksProcessorToolTargetTuple = [
875
877
  "omp",
876
878
  "opencode",
877
879
  "opencodev1",
880
+ "openbitfun",
878
881
  "pi",
879
882
  "pool",
880
883
  "factorydroid",
@@ -6064,6 +6067,7 @@ const HooksConfigSchema = zod_mini.z.looseObject({
6064
6067
  amp: zod_mini.z.optional(zod_mini.z.looseObject({ hooks: zod_mini.z.optional(hooksRecordSchema) })),
6065
6068
  factorydroid: zod_mini.z.optional(zod_mini.z.looseObject({ hooks: zod_mini.z.optional(hooksRecordSchema) })),
6066
6069
  codexcli: zod_mini.z.optional(zod_mini.z.looseObject({ hooks: zod_mini.z.optional(hooksRecordSchema) })),
6070
+ openbitfun: zod_mini.z.optional(zod_mini.z.looseObject({ hooks: zod_mini.z.optional(hooksRecordSchema) })),
6067
6071
  goose: zod_mini.z.optional(zod_mini.z.looseObject({ hooks: zod_mini.z.optional(hooksRecordSchema) })),
6068
6072
  deepagents: zod_mini.z.optional(zod_mini.z.looseObject({ hooks: zod_mini.z.optional(hooksRecordSchema) })),
6069
6073
  kiro: zod_mini.z.optional(zod_mini.z.looseObject({ hooks: zod_mini.z.optional(hooksRecordSchema) })),
@@ -6640,6 +6644,32 @@ const CODEXCLI_HOOK_EVENTS = eventsOf(CANONICAL_TO_CODEXCLI_EVENT_NAMES);
6640
6644
  */
6641
6645
  const CODEXCLI_TO_CANONICAL_EVENT_NAMES = invertRecord(CANONICAL_TO_CODEXCLI_EVENT_NAMES);
6642
6646
  /**
6647
+ * Map canonical camelCase event names to OpenBitFun PascalCase. OpenBitFun
6648
+ * implements the Codex hook contract with Codex's event names, minus the
6649
+ * events it does not dispatch (`Interrupt`, `PreModelRequest`,
6650
+ * `PostModelRequest`).
6651
+ * @see https://github.com/openBitFun/OpenBitFun/blob/main/docs/features/agent-hooks.md
6652
+ */
6653
+ const CANONICAL_TO_OPENBITFUN_EVENT_NAMES = {
6654
+ sessionStart: "SessionStart",
6655
+ sessionEnd: "SessionEnd",
6656
+ preToolUse: "PreToolUse",
6657
+ postToolUse: "PostToolUse",
6658
+ beforeSubmitPrompt: "UserPromptSubmit",
6659
+ stop: "Stop",
6660
+ permissionRequest: "PermissionRequest",
6661
+ subagentStart: "SubagentStart",
6662
+ subagentStop: "SubagentStop",
6663
+ preCompact: "PreCompact",
6664
+ postCompact: "PostCompact"
6665
+ };
6666
+ /** Hook events supported by OpenBitFun. */
6667
+ const OPENBITFUN_HOOK_EVENTS = eventsOf(CANONICAL_TO_OPENBITFUN_EVENT_NAMES);
6668
+ /**
6669
+ * Map OpenBitFun PascalCase event names to canonical camelCase.
6670
+ */
6671
+ const OPENBITFUN_TO_CANONICAL_EVENT_NAMES = invertRecord(CANONICAL_TO_OPENBITFUN_EVENT_NAMES);
6672
+ /**
6643
6673
  * Map canonical camelCase event names to Goose PascalCase.
6644
6674
  */
6645
6675
  const CANONICAL_TO_GOOSE_EVENT_NAMES = {
@@ -28143,6 +28173,135 @@ var PiSkill = class extends ToolSkill {
28143
28173
  var OmpSkill = class extends PiSkill {
28144
28174
  static layout = OMP_LAYOUT;
28145
28175
  };
28176
+ // src/constants/openbitfun-paths.ts
28177
+ /**
28178
+ * OpenBitFun configuration-layout conventions.
28179
+ *
28180
+ * OpenBitFun (formerly BitFun) keeps its project assets under a `.openbitfun/`
28181
+ * directory at the project root and its user assets under an OS-dependent
28182
+ * user root. Rules are not written here: OpenBitFun already reads the shared
28183
+ * `AGENTS.md` / `CLAUDE.md` / `.claude/rules/` files the `agentsmd` and
28184
+ * `claudecode` targets write.
28185
+ *
28186
+ * @see https://github.com/openBitFun/OpenBitFun/blob/main/src/crates/assembly/core/src/infrastructure/app_paths/path_manager.rs
28187
+ */
28188
+ const OPENBITFUN_DIR = ".openbitfun";
28189
+ const OPENBITFUN_AGENTS_DIR_NAME = "agents";
28190
+ const OPENBITFUN_AGENTS_DIR_PATH = (0, node_path.join)(OPENBITFUN_DIR, OPENBITFUN_AGENTS_DIR_NAME);
28191
+ const OPENBITFUN_SKILLS_DIR_NAME = "skills";
28192
+ const OPENBITFUN_SKILLS_DIR_PATH = (0, node_path.join)(OPENBITFUN_DIR, OPENBITFUN_SKILLS_DIR_NAME);
28193
+ const OPENBITFUN_CONFIG_DIR_NAME = "config";
28194
+ const OPENBITFUN_CONFIG_DIR_PATH = (0, node_path.join)(OPENBITFUN_DIR, OPENBITFUN_CONFIG_DIR_NAME);
28195
+ const OPENBITFUN_HOOKS_FILE_NAME = "hooks.json";
28196
+ const OPENBITFUN_DATA_NAMESPACE = "openbitfun";
28197
+ /**
28198
+ * OpenBitFun's user root (`dirs::config_dir()/openbitfun`), relative to the
28199
+ * home directory (the processor resolves the home directory through
28200
+ * `outputRoot`).
28201
+ *
28202
+ * - macOS: `~/Library/Application Support/openbitfun`
28203
+ * - Windows: `%APPDATA%\openbitfun` (`~/AppData/Roaming/openbitfun`)
28204
+ * - Linux and others: `~/.config/openbitfun`
28205
+ *
28206
+ * `$XDG_CONFIG_HOME` and OpenBitFun's `OPENBITFUN_USER_ROOT` override are not
28207
+ * followed; the default locations are assumed (a non-default `$XDG_CONFIG_HOME`
28208
+ * is warned about, see `warnOpenbitfunXdgOverride`).
28209
+ */
28210
+ function openbitfunGlobalRootDir() {
28211
+ switch (process.platform) {
28212
+ case "darwin": return (0, node_path.join)("Library", "Application Support", OPENBITFUN_DATA_NAMESPACE);
28213
+ case "win32": return (0, node_path.join)("AppData", "Roaming", OPENBITFUN_DATA_NAMESPACE);
28214
+ default: return (0, node_path.join)(".config", OPENBITFUN_DATA_NAMESPACE);
28215
+ }
28216
+ }
28217
+ /**
28218
+ * OpenBitFun's user agents directory: `<user root>/agents`.
28219
+ */
28220
+ function openbitfunGlobalAgentsDir() {
28221
+ return (0, node_path.join)(openbitfunGlobalRootDir(), OPENBITFUN_AGENTS_DIR_NAME);
28222
+ }
28223
+ /**
28224
+ * OpenBitFun's user hooks directory: `<user root>/config` (holding `hooks.json`).
28225
+ */
28226
+ function openbitfunGlobalConfigDir() {
28227
+ return (0, node_path.join)(openbitfunGlobalRootDir(), OPENBITFUN_CONFIG_DIR_NAME);
28228
+ }
28229
+ /**
28230
+ * OpenBitFun's user skills directory (`user_skills_dir` in `path_manager.rs`).
28231
+ * It is not always under the user root: on Linux it lives in the data dir
28232
+ * (`dirs::data_local_dir()`), not the config dir.
28233
+ *
28234
+ * - macOS: `~/Library/Application Support/openbitfun/skills`
28235
+ * - Windows: `%APPDATA%\openbitfun\skills`
28236
+ * - Linux and others: `~/.local/share/openbitfun/skills`
28237
+ *
28238
+ * `$XDG_DATA_HOME` is not followed; the default location is assumed (a
28239
+ * non-default value is warned about, see `warnOpenbitfunXdgOverride`).
28240
+ */
28241
+ function openbitfunGlobalSkillsDir() {
28242
+ switch (process.platform) {
28243
+ case "darwin":
28244
+ case "win32": return (0, node_path.join)(openbitfunGlobalRootDir(), OPENBITFUN_SKILLS_DIR_NAME);
28245
+ default: return (0, node_path.join)(".local", "share", OPENBITFUN_DATA_NAMESPACE, OPENBITFUN_SKILLS_DIR_NAME);
28246
+ }
28247
+ }
28248
+ // src/utils/openbitfun.ts
28249
+ const XDG_OVERRIDES = {
28250
+ config: {
28251
+ envVar: "XDG_CONFIG_HOME",
28252
+ defaultDir: ".config"
28253
+ },
28254
+ data: {
28255
+ envVar: "XDG_DATA_HOME",
28256
+ defaultDir: (0, node_path.join)(".local", "share")
28257
+ }
28258
+ };
28259
+ /**
28260
+ * Warn, once per run, when an XDG base directory variable moves OpenBitFun's
28261
+ * user tree away from where rulesync writes it in global mode.
28262
+ *
28263
+ * On Linux OpenBitFun resolves its user root through the `dirs` crate
28264
+ * (`dirs::config_dir()`, and `dirs::data_local_dir()` for skills), which
28265
+ * follows `$XDG_CONFIG_HOME` / `$XDG_DATA_HOME` when set to an absolute path.
28266
+ * rulesync writes global files relative to the home directory, at the XDG
28267
+ * default location, so a non-default value means OpenBitFun reads elsewhere.
28268
+ * macOS and Windows do not use these variables.
28269
+ *
28270
+ * @see https://github.com/openBitFun/OpenBitFun/blob/main/src/crates/assembly/core/src/infrastructure/app_paths/path_manager.rs
28271
+ */
28272
+ function warnOpenbitfunXdgOverride({ kind, logger }) {
28273
+ if (process.platform === "darwin" || process.platform === "win32") return;
28274
+ const { envVar, defaultDir } = XDG_OVERRIDES[kind];
28275
+ const value = process.env[envVar]?.trim();
28276
+ if (!value || !(0, node_path.isAbsolute)(value)) return;
28277
+ const defaultPath = (0, node_path.join)(getHomeDirectory(), defaultDir);
28278
+ if ((0, node_path.resolve)(value) === (0, node_path.resolve)(defaultPath)) return;
28279
+ warnOnceWithFallback(logger, `$${envVar} is set to ${value}, so OpenBitFun reads its user files from ${(0, node_path.join)(value, "openbitfun")}, but rulesync writes OpenBitFun's global files under ${(0, node_path.join)("~", defaultDir, "openbitfun")}. Move them there or unset $${envVar} for OpenBitFun.`);
28280
+ }
28281
+ // src/features/skills/openbitfun-skill.ts
28282
+ /**
28283
+ * OpenBitFun skills follow the Agent Skills layout (`<name>/SKILL.md` with
28284
+ * `name` and `description` frontmatter, plus optional supporting files), so
28285
+ * this target reuses {@link AgentsSkillsSkill} with OpenBitFun's locations:
28286
+ * `.openbitfun/skills/` (project) and the OS-dependent user skills directory
28287
+ * (global, see {@link openbitfunGlobalSkillsDir}). A project skill shadows a
28288
+ * user skill of the same name.
28289
+ *
28290
+ * @see https://github.com/openBitFun/OpenBitFun/blob/main/docs/interactive-capabilities/capabilities/feature.skills.md
28291
+ */
28292
+ var OpenbitfunSkill = class extends AgentsSkillsSkill {
28293
+ static getSettablePaths({ global = false } = {}) {
28294
+ return { relativeDirPath: global ? openbitfunGlobalSkillsDir() : OPENBITFUN_SKILLS_DIR_PATH };
28295
+ }
28296
+ static fromRulesyncSkill(params) {
28297
+ if (params.global) warnOpenbitfunXdgOverride({
28298
+ kind: "data",
28299
+ logger: params.logger
28300
+ });
28301
+ return super.fromRulesyncSkill(params);
28302
+ }
28303
+ static toolTarget = "openbitfun";
28304
+ };
28146
28305
  // src/constants/openclaw-paths.ts
28147
28306
  const OPENCLAW_WORKSPACE_DIR_PATH = (0, node_path.join)(".openclaw", "workspace");
28148
28307
  const OPENCLAW_RULE_FILE_NAME = "AGENTS.md";
@@ -30270,6 +30429,14 @@ const toolSkillFactories = /* @__PURE__ */ new Map([
30270
30429
  supportsGlobal: true
30271
30430
  }
30272
30431
  }],
30432
+ ["openbitfun", {
30433
+ class: OpenbitfunSkill,
30434
+ meta: {
30435
+ supportsProject: true,
30436
+ supportsSimulated: false,
30437
+ supportsGlobal: true
30438
+ }
30439
+ }],
30273
30440
  ["xum", {
30274
30441
  class: XumSkill,
30275
30442
  meta: {
@@ -36088,6 +36255,162 @@ var OmpSubagent = class extends FrontmatterMarkdownToolSubagent {
36088
36255
  };
36089
36256
  }
36090
36257
  };
36258
+ // src/features/subagents/openbitfun-subagent.ts
36259
+ /**
36260
+ * The `kind` rulesync writes: a delegated subagent rather than a top-level
36261
+ * agent mode. It is also OpenBitFun's default when `kind` is omitted.
36262
+ */
36263
+ const OPENBITFUN_SUBAGENT_KIND = "subagent";
36264
+ /**
36265
+ * Frontmatter of an OpenBitFun custom agent. `name` and `description` are
36266
+ * required; `tools` is a list or a comma-separated string. Unknown keys are
36267
+ * kept (looseObject), and OpenBitFun itself ignores keys it does not know.
36268
+ *
36269
+ * @see https://github.com/openBitFun/OpenBitFun/blob/main/src/crates/execution/agent-runtime/src/custom_agent.rs
36270
+ */
36271
+ const OpenbitfunSubagentFrontmatterSchema = zod_mini.z.looseObject({
36272
+ name: zod_mini.z.string(),
36273
+ description: zod_mini.z.string(),
36274
+ kind: zod_mini.z.optional(zod_mini.z.enum(["mode", "subagent"])),
36275
+ tools: zod_mini.z.optional(zod_mini.z.union([zod_mini.z.string(), zod_mini.z.array(zod_mini.z.string())])),
36276
+ model: zod_mini.z.optional(zod_mini.z.string()),
36277
+ readonly: zod_mini.z.optional(zod_mini.z.boolean()),
36278
+ review: zod_mini.z.optional(zod_mini.z.boolean())
36279
+ });
36280
+ /**
36281
+ * Subagent generator for OpenBitFun.
36282
+ *
36283
+ * OpenBitFun reads custom agents — Markdown with YAML frontmatter, the body
36284
+ * being the prompt — from `.openbitfun/agents/` (project) and
36285
+ * `<user root>/agents/` (user; see {@link openbitfunGlobalAgentsDir}).
36286
+ *
36287
+ * rulesync writes `name`, `description` and `kind: subagent`, then spreads the
36288
+ * `openbitfun` section (`kind`, `tools`, `model`, `readonly`, `review`, `id`,
36289
+ * `user_context_policy`, ...) on top, so a value set there wins. OpenBitFun
36290
+ * requires `description`, so an absent one is written as an empty string.
36291
+ *
36292
+ * @see https://github.com/openBitFun/OpenBitFun/blob/main/src/crates/execution/agent-runtime/src/custom_agent.rs
36293
+ */
36294
+ var OpenbitfunSubagent = class OpenbitfunSubagent extends ToolSubagent {
36295
+ frontmatter;
36296
+ body;
36297
+ constructor({ frontmatter, body, ...rest }) {
36298
+ if (rest.validate !== false) {
36299
+ const result = OpenbitfunSubagentFrontmatterSchema.safeParse(frontmatter);
36300
+ if (!result.success) throw new Error(`Invalid frontmatter in ${(0, node_path.join)(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`);
36301
+ }
36302
+ super({ ...rest });
36303
+ this.frontmatter = frontmatter;
36304
+ this.body = body;
36305
+ }
36306
+ static getSettablePaths({ global = false } = {}) {
36307
+ return { relativeDirPath: global ? openbitfunGlobalAgentsDir() : OPENBITFUN_AGENTS_DIR_PATH };
36308
+ }
36309
+ getFrontmatter() {
36310
+ return this.frontmatter;
36311
+ }
36312
+ getBody() {
36313
+ return this.body;
36314
+ }
36315
+ toRulesyncSubagent() {
36316
+ const { name, description, kind, ...restFields } = this.frontmatter;
36317
+ const openbitfunSection = {
36318
+ ...kind !== void 0 && kind !== OPENBITFUN_SUBAGENT_KIND && { kind },
36319
+ ...restFields
36320
+ };
36321
+ return new RulesyncSubagent({
36322
+ outputRoot: ".",
36323
+ frontmatter: {
36324
+ targets: ["*"],
36325
+ name,
36326
+ ...description && { description },
36327
+ ...Object.keys(openbitfunSection).length > 0 && { openbitfun: openbitfunSection }
36328
+ },
36329
+ body: this.body,
36330
+ relativeDirPath: RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH,
36331
+ relativeFilePath: this.getRelativeFilePath(),
36332
+ validate: true
36333
+ });
36334
+ }
36335
+ static fromRulesyncSubagent({ outputRoot = process.cwd(), rulesyncSubagent, validate = true, global = false, logger }) {
36336
+ if (global) warnOpenbitfunXdgOverride({
36337
+ kind: "config",
36338
+ logger
36339
+ });
36340
+ const rulesyncFrontmatter = rulesyncSubagent.getFrontmatter();
36341
+ const openbitfunSection = this.filterToolSpecificSection(rulesyncFrontmatter.openbitfun ?? {}, ["name", "description"]);
36342
+ const openbitfunFrontmatter = parseGeneratedSubagentFrontmatter({
36343
+ schema: OpenbitfunSubagentFrontmatterSchema,
36344
+ frontmatter: {
36345
+ name: rulesyncFrontmatter.name,
36346
+ description: rulesyncFrontmatter.description ?? "",
36347
+ kind: OPENBITFUN_SUBAGENT_KIND,
36348
+ ...openbitfunSection
36349
+ },
36350
+ toolTarget: "openbitfun",
36351
+ rulesyncSubagent
36352
+ });
36353
+ const body = rulesyncSubagent.getBody();
36354
+ return new OpenbitfunSubagent({
36355
+ outputRoot,
36356
+ frontmatter: openbitfunFrontmatter,
36357
+ body,
36358
+ relativeDirPath: this.getSettablePaths({ global }).relativeDirPath,
36359
+ relativeFilePath: rulesyncSubagent.getRelativeFilePath(),
36360
+ fileContent: stringifyFrontmatter(body, openbitfunFrontmatter),
36361
+ validate
36362
+ });
36363
+ }
36364
+ validate() {
36365
+ if (!this.frontmatter) return {
36366
+ success: true,
36367
+ error: null
36368
+ };
36369
+ return validateFrontmatterSchema({
36370
+ schema: OpenbitfunSubagentFrontmatterSchema,
36371
+ frontmatter: this.frontmatter,
36372
+ relativeDirPath: this.relativeDirPath,
36373
+ relativeFilePath: this.relativeFilePath
36374
+ });
36375
+ }
36376
+ static isTargetedByRulesyncSubagent(rulesyncSubagent) {
36377
+ return this.isTargetedByRulesyncSubagentDefault({
36378
+ rulesyncSubagent,
36379
+ toolTarget: "openbitfun"
36380
+ });
36381
+ }
36382
+ static async fromFile({ outputRoot = process.cwd(), relativeFilePath, validate = true, global = false }) {
36383
+ const paths = this.getSettablePaths({ global });
36384
+ const filePath = (0, node_path.join)(outputRoot, paths.relativeDirPath, relativeFilePath);
36385
+ const fileContent = await readFileContent(filePath);
36386
+ const { frontmatter, body } = parseFrontmatter(fileContent, filePath);
36387
+ const result = OpenbitfunSubagentFrontmatterSchema.safeParse(frontmatter);
36388
+ if (!result.success) throw new Error(`Invalid frontmatter in ${filePath}: ${formatError(result.error)}`);
36389
+ return new OpenbitfunSubagent({
36390
+ outputRoot,
36391
+ relativeDirPath: paths.relativeDirPath,
36392
+ relativeFilePath,
36393
+ frontmatter: result.data,
36394
+ body: body.trim(),
36395
+ fileContent,
36396
+ validate
36397
+ });
36398
+ }
36399
+ static forDeletion({ outputRoot = process.cwd(), relativeDirPath, relativeFilePath }) {
36400
+ return new OpenbitfunSubagent({
36401
+ outputRoot,
36402
+ relativeDirPath,
36403
+ relativeFilePath,
36404
+ frontmatter: {
36405
+ name: "",
36406
+ description: ""
36407
+ },
36408
+ body: "",
36409
+ fileContent: "",
36410
+ validate: false
36411
+ });
36412
+ }
36413
+ };
36091
36414
  // src/features/subagents/opencodev1-subagent.ts
36092
36415
  /**
36093
36416
  * Subagent generator for **OpenCode V1** (OpenCode 1.x), which reads the V1
@@ -38468,6 +38791,15 @@ const toolSubagentFactories = /* @__PURE__ */ new Map([
38468
38791
  filePattern: "*.toml"
38469
38792
  }
38470
38793
  }],
38794
+ ["openbitfun", {
38795
+ class: OpenbitfunSubagent,
38796
+ meta: {
38797
+ supportsProject: true,
38798
+ supportsSimulated: false,
38799
+ supportsGlobal: true,
38800
+ filePattern: "*.md"
38801
+ }
38802
+ }],
38471
38803
  ["xum", {
38472
38804
  class: XumSubagent,
38473
38805
  meta: {
@@ -45069,7 +45401,7 @@ const TOOL_DISPLAY = [
45069
45401
  },
45070
45402
  {
45071
45403
  key: "firebender",
45072
- label: "Firebender",
45404
+ label: "Firebender ⚠️",
45073
45405
  group: "ai"
45074
45406
  },
45075
45407
  {
@@ -45087,6 +45419,11 @@ const TOOL_DISPLAY = [
45087
45419
  label: "OpenClaw",
45088
45420
  group: "ai"
45089
45421
  },
45422
+ {
45423
+ key: "openbitfun",
45424
+ label: "OpenBitFun",
45425
+ group: "ai"
45426
+ },
45090
45427
  {
45091
45428
  key: "mimocode",
45092
45429
  label: "MiMo Code",
@@ -57762,7 +58099,7 @@ function describeRejectedHandler(handler) {
57762
58099
  * MCP hooks are skipped with a startup warning). Matcher groups left without
57763
58100
  * handlers are removed. https://learn.chatgpt.com/docs/hooks
57764
58101
  */
57765
- function filterCodexHandlers({ hooks, logger }) {
58102
+ function filterCodexHandlers({ hooks, toolLabel, describeRejected, logger }) {
57766
58103
  const result = {};
57767
58104
  const skippedSessionEndTools = [];
57768
58105
  for (const [eventName, groups] of Object.entries(hooks)) {
@@ -57774,9 +58111,9 @@ function filterCodexHandlers({ hooks, logger }) {
57774
58111
  continue;
57775
58112
  }
57776
58113
  const handlers = entry.hooks.filter((handler) => {
57777
- const reason = describeRejectedHandler(handler);
58114
+ const reason = describeRejected(handler);
57778
58115
  if (reason !== void 0) {
57779
- logger?.warn(`Skipping a "${String(handler.type)}" hook on Codex CLI "${eventName}": ${reason}.`);
58116
+ logger?.warn(`Skipping a "${String(handler.type)}" hook on ${toolLabel} "${eventName}": ${reason}.`);
57780
58117
  return false;
57781
58118
  }
57782
58119
  if (eventName === "SessionEnd" && handler.type === "mcp_tool") skippedSessionEndTools.push(`${String(handler.server)}/${String(handler.tool)}`);
@@ -57793,6 +58130,56 @@ function filterCodexHandlers({ hooks, logger }) {
57793
58130
  return result;
57794
58131
  }
57795
58132
  /**
58133
+ * Generate the content of a Codex-shaped `hooks.json` (`{ hooks: { <Event>:
58134
+ * [matcher groups] } }`) at `relativeDirPath/relativeFilePath`. Shared by the
58135
+ * Codex CLI target and tools that read the same document (OpenBitFun), which
58136
+ * differ only in where the file lives, which events and handler types they
58137
+ * run, and which rulesync override section they read.
58138
+ */
58139
+ async function buildCodexStyleHooksFile({ outputRoot, relativeDirPath, relativeFilePath, rulesyncHooks, toolOverrideHooks, converterConfig, toolLabel, describeRejected = describeRejectedHandler, preserveUnowned, logger }) {
58140
+ const merged = mergeGeneratedHookLists({
58141
+ existingContent: await readFileContentOrNull((0, node_path.join)(outputRoot, relativeDirPath, relativeFilePath)) ?? "",
58142
+ generatedHooks: filterCodexHandlers({
58143
+ hooks: canonicalToToolHooks({
58144
+ config: rulesyncHooks.getJson(),
58145
+ toolOverrideHooks,
58146
+ converterConfig,
58147
+ logger
58148
+ }),
58149
+ toolLabel,
58150
+ describeRejected,
58151
+ logger
58152
+ }),
58153
+ shape: "matcher-groups",
58154
+ preserveUnowned,
58155
+ previouslyOwned: preserveUnowned ? await readPreviouslyOwnedHooks({
58156
+ outputRoot,
58157
+ relativeDirPath
58158
+ }) : void 0,
58159
+ logger
58160
+ });
58161
+ return {
58162
+ fileContent: JSON.stringify({ hooks: merged.hooks }, null, 2),
58163
+ owned: merged.owned
58164
+ };
58165
+ }
58166
+ /**
58167
+ * Convert the parsed content of a Codex-shaped `hooks.json` back to the
58168
+ * rulesync hooks JSON, with tool-only hooks under `overrideKey`.
58169
+ */
58170
+ function codexStyleHooksToRulesyncContent({ parsed, converterConfig, overrideKey, logger }) {
58171
+ const hooks = toolHooksToCanonical({
58172
+ hooks: parsed.hooks,
58173
+ converterConfig,
58174
+ logger
58175
+ });
58176
+ return JSON.stringify(buildImportedHooksConfig({
58177
+ logger,
58178
+ hooks,
58179
+ overrideKey
58180
+ }), null, 2);
58181
+ }
58182
+ /**
57796
58183
  * Build the content for `.codex/config.toml`, cleaning up the deprecated `codex_hooks` key.
57797
58184
  * Reads the existing file (if any), parses TOML, and returns the content without writing to
57798
58185
  * disk. The caller is responsible for writing via the normal write phase.
@@ -57864,51 +58251,37 @@ var CodexcliHooks = class CodexcliHooks extends ToolHooks {
57864
58251
  }
57865
58252
  static async fromRulesyncHooks({ outputRoot = process.cwd(), rulesyncHooks, validate = true, global = false, preserveUnowned = false, logger }) {
57866
58253
  const paths = CodexcliHooks.getSettablePaths({ global });
57867
- const existingContent = await readFileContentOrNull((0, node_path.join)(outputRoot, paths.relativeDirPath, paths.relativeFilePath)) ?? "";
57868
- const config = rulesyncHooks.getJson();
57869
- const merged = mergeGeneratedHookLists({
57870
- existingContent,
57871
- generatedHooks: filterCodexHandlers({
57872
- hooks: canonicalToToolHooks({
57873
- config,
57874
- toolOverrideHooks: config.codexcli?.hooks,
57875
- converterConfig: CODEXCLI_CONVERTER_CONFIG,
57876
- logger
57877
- }),
57878
- logger
57879
- }),
57880
- shape: "matcher-groups",
58254
+ const { fileContent, owned } = await buildCodexStyleHooksFile({
58255
+ outputRoot,
58256
+ relativeDirPath: paths.relativeDirPath,
58257
+ relativeFilePath: paths.relativeFilePath,
58258
+ rulesyncHooks,
58259
+ toolOverrideHooks: rulesyncHooks.getJson().codexcli?.hooks,
58260
+ converterConfig: CODEXCLI_CONVERTER_CONFIG,
58261
+ toolLabel: "Codex CLI",
57881
58262
  preserveUnowned,
57882
- previouslyOwned: preserveUnowned ? await readPreviouslyOwnedHooks({
57883
- outputRoot,
57884
- relativeDirPath: paths.relativeDirPath
57885
- }) : void 0,
57886
58263
  logger
57887
58264
  });
57888
- const fileContent = JSON.stringify({ hooks: merged.hooks }, null, 2);
57889
58265
  return new CodexcliHooks({
57890
58266
  outputRoot,
57891
58267
  relativeDirPath: paths.relativeDirPath,
57892
58268
  relativeFilePath: paths.relativeFilePath,
57893
58269
  fileContent,
57894
- ownedHookRefs: preserveUnowned ? merged.owned : void 0,
58270
+ ownedHookRefs: preserveUnowned ? owned : void 0,
57895
58271
  validate
57896
58272
  });
57897
58273
  }
57898
58274
  toRulesyncHooks({ logger } = {}) {
57899
- const hooks = toolHooksToCanonical({
57900
- hooks: this.parseFileContentOrThrow({
57901
- displayName: "Codex CLI",
57902
- parse: (fileContent) => JSON.parse(fileContent)
57903
- }).hooks,
58275
+ const parsed = this.parseFileContentOrThrow({
58276
+ displayName: "Codex CLI",
58277
+ parse: (fileContent) => JSON.parse(fileContent)
58278
+ });
58279
+ return this.toRulesyncHooksDefault({ fileContent: codexStyleHooksToRulesyncContent({
58280
+ parsed,
57904
58281
  converterConfig: CODEXCLI_CONVERTER_CONFIG,
58282
+ overrideKey: "codexcli",
57905
58283
  logger
57906
- });
57907
- return this.toRulesyncHooksDefault({ fileContent: JSON.stringify(buildImportedHooksConfig({
57908
- logger,
57909
- hooks,
57910
- overrideKey: "codexcli"
57911
- }), null, 2) });
58284
+ }) });
57912
58285
  }
57913
58286
  static supportsPreserveUnowned() {
57914
58287
  return true;
@@ -63621,6 +63994,162 @@ var OmpHooks = class OmpHooks extends ToolHooks {
63621
63994
  });
63622
63995
  }
63623
63996
  };
63997
+ // src/features/hooks/openbitfun-hooks.ts
63998
+ /**
63999
+ * Canonical (Claude Code) tool names whose OpenBitFun runtime name differs.
64000
+ * OpenBitFun's shell tool is `ExecCommand`; its own Claude-dialect skill hook
64001
+ * adapter maps `Bash` onto it, with the shell command in `tool_input.cmd`.
64002
+ * `Read`, `Write`, `Edit`, `Glob`, `Grep`, `WebFetch`, `WebSearch`, `Skill` and
64003
+ * `LS` share their names, so they need no entry.
64004
+ * @see https://github.com/openBitFun/OpenBitFun/blob/main/src/crates/execution/agent-runtime/src/skills/hooks.rs
64005
+ */
64006
+ const CANONICAL_TO_OPENBITFUN_TOOL_NAMES = { Bash: "ExecCommand" };
64007
+ const OPENBITFUN_TO_CANONICAL_TOOL_NAMES = Object.fromEntries(Object.entries(CANONICAL_TO_OPENBITFUN_TOOL_NAMES).map(([canonical, tool]) => [tool, canonical]));
64008
+ /**
64009
+ * OpenBitFun's built-in tool names (the default custom-agent tool sets in
64010
+ * `custom_agent.rs`, plus `LS`). Capitalized matcher names outside this set
64011
+ * are warned about on events that gate a tool call.
64012
+ * @see https://github.com/openBitFun/OpenBitFun/blob/main/src/crates/execution/agent-runtime/src/custom_agent.rs
64013
+ */
64014
+ const OPENBITFUN_TOOL_NAMES = /* @__PURE__ */ new Set([
64015
+ "Read",
64016
+ "Glob",
64017
+ "Grep",
64018
+ "LS",
64019
+ "Write",
64020
+ "Edit",
64021
+ "Delete",
64022
+ "ExecCommand",
64023
+ "WriteStdin",
64024
+ "ExecControl",
64025
+ "AgentSpawn",
64026
+ "AgentFork",
64027
+ "AgentSendInput",
64028
+ "AgentControl",
64029
+ "AgentList",
64030
+ "AgentWait",
64031
+ "ListModels",
64032
+ "Skill",
64033
+ "WebSearch",
64034
+ "WebFetch"
64035
+ ]);
64036
+ /**
64037
+ * Events whose hooks can deny a tool call, so a matcher that never matches
64038
+ * makes the guard fail open. The keys are canonical names, or OpenBitFun's own
64039
+ * names when the hook comes from the `openbitfun.hooks` override block.
64040
+ */
64041
+ const TOOL_GATING_EVENTS = /* @__PURE__ */ new Set([
64042
+ "preToolUse",
64043
+ "permissionRequest",
64044
+ "PreToolUse",
64045
+ "PermissionRequest"
64046
+ ]);
64047
+ function canonicalToOpenbitfunMatcher({ matcher, eventName, warn }) {
64048
+ const translated = replaceMatcherNames(matcher, CANONICAL_TO_OPENBITFUN_TOOL_NAMES);
64049
+ if (TOOL_GATING_EVENTS.has(eventName)) {
64050
+ const unknown = capitalizedMatcherNames(translated).filter((name) => !OPENBITFUN_TOOL_NAMES.has(name));
64051
+ 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.`);
64052
+ }
64053
+ return translated;
64054
+ }
64055
+ function openbitfunToCanonicalMatcher(matcher) {
64056
+ return replaceMatcherNames(matcher, OPENBITFUN_TO_CANONICAL_TOOL_NAMES);
64057
+ }
64058
+ /**
64059
+ * Why OpenBitFun would skip a generated handler, or `undefined` when it runs
64060
+ * it. OpenBitFun's `parse_handler` treats a command handler whose `timeout` is
64061
+ * not a positive integer as invalid and skips that handler.
64062
+ * @see https://github.com/openBitFun/OpenBitFun/blob/main/src/crates/execution/agent-runtime/src/native_hooks/settings.rs
64063
+ */
64064
+ function describeRejectedOpenbitfunHandler(handler) {
64065
+ const { timeout } = handler;
64066
+ 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`;
64067
+ }
64068
+ /**
64069
+ * OpenBitFun implements the Codex hook contract: the same `hooks.json`
64070
+ * document, handler fields and matcher semantics (regexes anchored to the
64071
+ * whole tool name). It differs in the events it dispatches, in running only
64072
+ * `type: "command"` handlers (`prompt` and `agent` handlers are parsed but
64073
+ * skipped), in its runtime tool names (`ExecCommand` for `Bash`), and in the
64074
+ * handler fields it reads: `command`, `commandWindows`, `timeout` and
64075
+ * `statusMessage` only, so Codex's `async` and `additionalContextLimit` are
64076
+ * not forwarded.
64077
+ * @see https://github.com/openBitFun/OpenBitFun/blob/main/docs/features/agent-hooks.md
64078
+ * @see https://github.com/openBitFun/OpenBitFun/blob/main/src/crates/execution/agent-runtime/src/native_hooks/settings.rs
64079
+ */
64080
+ const OPENBITFUN_CONVERTER_CONFIG = {
64081
+ ...CODEXCLI_CONVERTER_CONFIG,
64082
+ supportedEvents: OPENBITFUN_HOOK_EVENTS,
64083
+ canonicalToToolEventNames: CANONICAL_TO_OPENBITFUN_EVENT_NAMES,
64084
+ toolToCanonicalEventNames: OPENBITFUN_TO_CANONICAL_EVENT_NAMES,
64085
+ supportedHookTypes: /* @__PURE__ */ new Set(["command"]),
64086
+ numberPassthroughFields: [],
64087
+ booleanPassthroughFields: [],
64088
+ matcherTranslation: {
64089
+ toTool: canonicalToOpenbitfunMatcher,
64090
+ toCanonical: openbitfunToCanonicalMatcher
64091
+ }
64092
+ };
64093
+ /**
64094
+ * Hooks generator for OpenBitFun: a Codex-shaped `hooks.json` at
64095
+ * `.openbitfun/config/hooks.json` (project) and `<user root>/config/hooks.json`
64096
+ * (global; see {@link openbitfunGlobalConfigDir}). Both layers are additive.
64097
+ *
64098
+ * Project hooks are off by default in OpenBitFun: they only run once the
64099
+ * `app.hooks.project_hooks_enabled` setting is turned on.
64100
+ *
64101
+ * @see https://github.com/openBitFun/OpenBitFun/blob/main/docs/features/agent-hooks.md
64102
+ */
64103
+ var OpenbitfunHooks = class OpenbitfunHooks extends ToolHooks {
64104
+ static getSettablePaths({ global = false } = {}) {
64105
+ return {
64106
+ relativeDirPath: global ? openbitfunGlobalConfigDir() : OPENBITFUN_CONFIG_DIR_PATH,
64107
+ relativeFilePath: OPENBITFUN_HOOKS_FILE_NAME
64108
+ };
64109
+ }
64110
+ static async fromRulesyncHooks({ outputRoot = process.cwd(), rulesyncHooks, validate = true, global = false, preserveUnowned = false, logger }) {
64111
+ if (global) warnOpenbitfunXdgOverride({
64112
+ kind: "config",
64113
+ logger
64114
+ });
64115
+ const paths = OpenbitfunHooks.getSettablePaths({ global });
64116
+ const { fileContent, owned } = await buildCodexStyleHooksFile({
64117
+ outputRoot,
64118
+ relativeDirPath: paths.relativeDirPath,
64119
+ relativeFilePath: paths.relativeFilePath,
64120
+ rulesyncHooks,
64121
+ toolOverrideHooks: rulesyncHooks.getJson().openbitfun?.hooks,
64122
+ converterConfig: OPENBITFUN_CONVERTER_CONFIG,
64123
+ toolLabel: "OpenBitFun",
64124
+ describeRejected: describeRejectedOpenbitfunHandler,
64125
+ preserveUnowned,
64126
+ logger
64127
+ });
64128
+ return new OpenbitfunHooks({
64129
+ outputRoot,
64130
+ relativeDirPath: paths.relativeDirPath,
64131
+ relativeFilePath: paths.relativeFilePath,
64132
+ fileContent,
64133
+ ownedHookRefs: preserveUnowned ? owned : void 0,
64134
+ validate
64135
+ });
64136
+ }
64137
+ toRulesyncHooks({ logger } = {}) {
64138
+ const parsed = this.parseFileContentOrThrow({
64139
+ displayName: "OpenBitFun",
64140
+ parse: (fileContent) => JSON.parse(fileContent)
64141
+ });
64142
+ return this.toRulesyncHooksDefault({ fileContent: codexStyleHooksToRulesyncContent({
64143
+ parsed,
64144
+ converterConfig: OPENBITFUN_CONVERTER_CONFIG,
64145
+ overrideKey: "openbitfun",
64146
+ logger
64147
+ }) });
64148
+ }
64149
+ static supportsPreserveUnowned() {
64150
+ return true;
64151
+ }
64152
+ };
63624
64153
  // src/features/hooks/opencodev1-hooks.ts
63625
64154
  /**
63626
64155
  * Hooks generator for **OpenCode V1** (OpenCode 1.x). OpenCode 2.x does not
@@ -65701,6 +66230,16 @@ const toolHooksFactories = /* @__PURE__ */ new Map([
65701
66230
  ...converterCapabilities(CODEXCLI_CONVERTER_CONFIG),
65702
66231
  supportsMatcher: true
65703
66232
  }],
66233
+ ["openbitfun", {
66234
+ class: OpenbitfunHooks,
66235
+ meta: {
66236
+ supportsProject: true,
66237
+ supportsGlobal: true,
66238
+ supportsImport: true
66239
+ },
66240
+ ...converterCapabilities(OPENBITFUN_CONVERTER_CONFIG),
66241
+ supportsMatcher: true
66242
+ }],
65704
66243
  ["commandcode", {
65705
66244
  class: CommandcodeHooks,
65706
66245
  meta: {