rulesync 43.10.1 → 43.12.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 +4 -3
- 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-DT6BSklJ.cjs → import-Bp-dK2hr.cjs} +1063 -200
- package/dist/{import-fiaj0fDK.js → import-Ctgal4jT.js} +1048 -185
- package/dist/{import-fiaj0fDK.js.map → import-Ctgal4jT.js.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
|
@@ -382,36 +382,36 @@ function formatError(error) {
|
|
|
382
382
|
return boundErrorMessage(String(error));
|
|
383
383
|
}
|
|
384
384
|
// src/constants/rulesync-paths.ts
|
|
385
|
-
const { join: join$
|
|
385
|
+
const { join: join$359 } = node_path.posix;
|
|
386
386
|
const RULESYNC_CONFIG_RELATIVE_FILE_PATH = "rulesync.jsonc";
|
|
387
387
|
const RULESYNC_LOCAL_CONFIG_RELATIVE_FILE_PATH = "rulesync.local.jsonc";
|
|
388
388
|
const RULESYNC_USER_CONFIG_DIR_NAME = "rulesync";
|
|
389
389
|
const RULESYNC_XDG_CONFIG_HOME_DEFAULT_DIR_NAME = ".config";
|
|
390
390
|
const RULESYNC_RELATIVE_DIR_PATH = ".rulesync";
|
|
391
391
|
const RULES_FEATURE_SUBDIR = "rules";
|
|
392
|
-
const CURATED_RULES_FEATURE_SUBDIR = join$
|
|
392
|
+
const CURATED_RULES_FEATURE_SUBDIR = join$359(RULES_FEATURE_SUBDIR, ".curated");
|
|
393
393
|
const COMMANDS_FEATURE_SUBDIR = "commands";
|
|
394
394
|
const SUBAGENTS_FEATURE_SUBDIR = "subagents";
|
|
395
395
|
const CHECKS_FEATURE_SUBDIR = "checks";
|
|
396
396
|
const SKILLS_FEATURE_SUBDIR = "skills";
|
|
397
|
-
const CURATED_SKILLS_FEATURE_SUBDIR = join$
|
|
398
|
-
const RULESYNC_RULES_RELATIVE_DIR_PATH = join$
|
|
399
|
-
const RULESYNC_CURATED_RULES_RELATIVE_DIR_PATH = join$
|
|
400
|
-
const RULESYNC_COMMANDS_RELATIVE_DIR_PATH = join$
|
|
401
|
-
const RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH = join$
|
|
402
|
-
const RULESYNC_CHECKS_RELATIVE_DIR_PATH = join$
|
|
403
|
-
const RULESYNC_MCP_RELATIVE_FILE_PATH = join$
|
|
404
|
-
const RULESYNC_HOOKS_RELATIVE_FILE_PATH = join$
|
|
405
|
-
const RULESYNC_PERMISSIONS_RELATIVE_FILE_PATH = join$
|
|
406
|
-
join$
|
|
407
|
-
const RULESYNC_HOOKS_LEGACY_RELATIVE_FILE_PATH = join$
|
|
408
|
-
const RULESYNC_PERMISSIONS_LEGACY_RELATIVE_FILE_PATH = join$
|
|
397
|
+
const CURATED_SKILLS_FEATURE_SUBDIR = join$359(SKILLS_FEATURE_SUBDIR, ".curated");
|
|
398
|
+
const RULESYNC_RULES_RELATIVE_DIR_PATH = join$359(RULESYNC_RELATIVE_DIR_PATH, RULES_FEATURE_SUBDIR);
|
|
399
|
+
const RULESYNC_CURATED_RULES_RELATIVE_DIR_PATH = join$359(RULESYNC_RELATIVE_DIR_PATH, CURATED_RULES_FEATURE_SUBDIR);
|
|
400
|
+
const RULESYNC_COMMANDS_RELATIVE_DIR_PATH = join$359(RULESYNC_RELATIVE_DIR_PATH, COMMANDS_FEATURE_SUBDIR);
|
|
401
|
+
const RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH = join$359(RULESYNC_RELATIVE_DIR_PATH, SUBAGENTS_FEATURE_SUBDIR);
|
|
402
|
+
const RULESYNC_CHECKS_RELATIVE_DIR_PATH = join$359(RULESYNC_RELATIVE_DIR_PATH, CHECKS_FEATURE_SUBDIR);
|
|
403
|
+
const RULESYNC_MCP_RELATIVE_FILE_PATH = join$359(RULESYNC_RELATIVE_DIR_PATH, "mcp.jsonc");
|
|
404
|
+
const RULESYNC_HOOKS_RELATIVE_FILE_PATH = join$359(RULESYNC_RELATIVE_DIR_PATH, "hooks.jsonc");
|
|
405
|
+
const RULESYNC_PERMISSIONS_RELATIVE_FILE_PATH = join$359(RULESYNC_RELATIVE_DIR_PATH, "permissions.jsonc");
|
|
406
|
+
join$359(RULESYNC_RELATIVE_DIR_PATH, "mcp.json");
|
|
407
|
+
const RULESYNC_HOOKS_LEGACY_RELATIVE_FILE_PATH = join$359(RULESYNC_RELATIVE_DIR_PATH, "hooks.json");
|
|
408
|
+
const RULESYNC_PERMISSIONS_LEGACY_RELATIVE_FILE_PATH = join$359(RULESYNC_RELATIVE_DIR_PATH, "permissions.json");
|
|
409
409
|
const RULESYNC_AIIGNORE_FILE_NAME = ".aiignore";
|
|
410
|
-
const RULESYNC_AIIGNORE_RELATIVE_FILE_PATH = join$
|
|
410
|
+
const RULESYNC_AIIGNORE_RELATIVE_FILE_PATH = join$359(RULESYNC_RELATIVE_DIR_PATH, ".aiignore");
|
|
411
411
|
const RULESYNC_IGNORE_RELATIVE_FILE_PATH = ".rulesyncignore";
|
|
412
412
|
const RULESYNC_OVERVIEW_FILE_NAME = "overview.md";
|
|
413
|
-
const RULESYNC_SKILLS_RELATIVE_DIR_PATH = join$
|
|
414
|
-
const RULESYNC_CURATED_SKILLS_RELATIVE_DIR_PATH = join$
|
|
413
|
+
const RULESYNC_SKILLS_RELATIVE_DIR_PATH = join$359(RULESYNC_RELATIVE_DIR_PATH, SKILLS_FEATURE_SUBDIR);
|
|
414
|
+
const RULESYNC_CURATED_SKILLS_RELATIVE_DIR_PATH = join$359(RULESYNC_RELATIVE_DIR_PATH, CURATED_SKILLS_FEATURE_SUBDIR);
|
|
415
415
|
const RULESYNC_SOURCES_LOCK_RELATIVE_FILE_PATH = "rulesync.lock";
|
|
416
416
|
const RULESYNC_NPM_SOURCES_LOCK_RELATIVE_FILE_PATH = "rulesync-npm.lock.json";
|
|
417
417
|
const RULESYNC_MCP_FILE_NAME = "mcp.jsonc";
|
|
@@ -764,6 +764,7 @@ const subagentsProcessorToolTargetTuple = [
|
|
|
764
764
|
"kiro-ide",
|
|
765
765
|
"lettacode",
|
|
766
766
|
"mimocode",
|
|
767
|
+
"musecode",
|
|
767
768
|
"omp",
|
|
768
769
|
"opencode",
|
|
769
770
|
"opencodev1",
|
|
@@ -5194,6 +5195,8 @@ const HookDefinitionSchema = zod_mini.z.looseObject({
|
|
|
5194
5195
|
tool: zod_mini.z.optional(safeString),
|
|
5195
5196
|
input: zod_mini.z.optional(zod_mini.z.looseObject({})),
|
|
5196
5197
|
model: zod_mini.z.optional(safeString),
|
|
5198
|
+
tools: zod_mini.z.optional(zod_mini.z.array(safeString)),
|
|
5199
|
+
maxTurns: zod_mini.z.optional(zod_mini.z.int().check((0, zod_mini.positive)())),
|
|
5197
5200
|
args: zod_mini.z.optional(zod_mini.z.array(safeString)),
|
|
5198
5201
|
metadata: zod_mini.z.optional(zod_mini.z.looseObject({})),
|
|
5199
5202
|
source: zod_mini.z.optional(zod_mini.z.looseObject({
|
|
@@ -5885,16 +5888,17 @@ const CONTINUE_TO_CANONICAL_EVENT_NAMES = invertRecord(CANONICAL_TO_CONTINUE_EVE
|
|
|
5885
5888
|
* observers, `gateway_platform_event` and `transform_api_error_classification`.
|
|
5886
5889
|
* Shell hooks are gated on the same set.
|
|
5887
5890
|
*
|
|
5888
|
-
* Verified against the tag `v0.
|
|
5891
|
+
* Verified against the tag `v0.23.2`: `VALID_HOOKS` holds 48 entries, grown
|
|
5889
5892
|
* from 23 at `v2026.8.3` (v0.20.0) and 37 at `v2026.8.16` (v0.20.2) — v0.21
|
|
5890
5893
|
* added `agent_loop_stopped` and `on_room_member_activity`, v0.21.5 added
|
|
5891
5894
|
* `pre_auxiliary_call` and `post_auxiliary_call`, v0.21.6 added
|
|
5892
5895
|
* `post_gateway_admission`, `on_human_input_request` and
|
|
5893
|
-
* `on_human_input_resolved`,
|
|
5894
|
-
* `post_compaction
|
|
5896
|
+
* `on_human_input_resolved`, v0.22.3 added `on_session_delete` and
|
|
5897
|
+
* `post_compaction`, and v0.23.1 added `on_session_open` and
|
|
5898
|
+
* `post_curator_run`. This list holds 47 of them — see
|
|
5895
5899
|
* {@link HERMESAGENT_SHELL_UNSUPPORTED_HOOK_EVENTS} for the exclusion.
|
|
5896
5900
|
*
|
|
5897
|
-
* @see https://github.com/NousResearch/hermes-agent/blob/v0.
|
|
5901
|
+
* @see https://github.com/NousResearch/hermes-agent/blob/v0.23.2/hermes_cli/plugins.py
|
|
5898
5902
|
*/
|
|
5899
5903
|
const HERMESAGENT_NATIVE_HOOK_EVENTS = [
|
|
5900
5904
|
"pre_tool_call",
|
|
@@ -5919,6 +5923,7 @@ const HERMESAGENT_NATIVE_HOOK_EVENTS = [
|
|
|
5919
5923
|
"on_session_finalize",
|
|
5920
5924
|
"on_session_reset",
|
|
5921
5925
|
"on_session_delete",
|
|
5926
|
+
"on_session_open",
|
|
5922
5927
|
"on_skill_lifecycle",
|
|
5923
5928
|
"subagent_start",
|
|
5924
5929
|
"subagent_stop",
|
|
@@ -5941,7 +5946,8 @@ const HERMESAGENT_NATIVE_HOOK_EVENTS = [
|
|
|
5941
5946
|
"on_kanban_dispatch_tick",
|
|
5942
5947
|
"gateway_platform_event",
|
|
5943
5948
|
"pre_command",
|
|
5944
|
-
"post_compaction"
|
|
5949
|
+
"post_compaction",
|
|
5950
|
+
"post_curator_run"
|
|
5945
5951
|
];
|
|
5946
5952
|
/**
|
|
5947
5953
|
* `VALID_HOOKS` entries a SHELL hook may not register for. `VALID_HOOKS` doubles
|
|
@@ -5953,8 +5959,8 @@ const HERMESAGENT_NATIVE_HOOK_EVENTS = [
|
|
|
5953
5959
|
* rulesync only ever writes shell hooks, so these are excluded from
|
|
5954
5960
|
* {@link HERMESAGENT_NATIVE_HOOK_EVENTS} and warned about with their own message.
|
|
5955
5961
|
*
|
|
5956
|
-
* @see https://github.com/NousResearch/hermes-agent/blob/v0.
|
|
5957
|
-
* @see https://github.com/NousResearch/hermes-agent/blob/v0.
|
|
5962
|
+
* @see https://github.com/NousResearch/hermes-agent/blob/v0.23.2/hermes_cli/plugins.py — `SHELL_UNSUPPORTED_HOOKS`
|
|
5963
|
+
* @see https://github.com/NousResearch/hermes-agent/blob/v0.23.2/agent/shell_hooks.py — `_parse_hooks_block`
|
|
5958
5964
|
*/
|
|
5959
5965
|
const HERMESAGENT_SHELL_UNSUPPORTED_HOOK_EVENTS = ["transform_api_error_classification"];
|
|
5960
5966
|
/**
|
|
@@ -5974,8 +5980,8 @@ const CANONICAL_TO_HERMESAGENT_EVENT_NAMES = {
|
|
|
5974
5980
|
/**
|
|
5975
5981
|
* Hook events supported by Hermes Agent's native Shell Hooks system.
|
|
5976
5982
|
*
|
|
5977
|
-
* Hermes validates hook events against a fixed `VALID_HOOKS` set —
|
|
5978
|
-
* of v0.
|
|
5983
|
+
* Hermes validates hook events against a fixed `VALID_HOOKS` set — 48 entries as
|
|
5984
|
+
* of v0.23.2 (tag `v0.23.2`); see {@link HERMESAGENT_NATIVE_HOOK_EVENTS} for the
|
|
5979
5985
|
* full list. Only the events with a clean 1:1 canonical equivalent are mapped
|
|
5980
5986
|
* here. All other native events round-trip through `hermesagent.hooks`.
|
|
5981
5987
|
* @see https://github.com/NousResearch/hermes-agent/blob/main/website/docs/user-guide/features/hooks.md
|
|
@@ -6768,6 +6774,7 @@ const CANONICAL_TO_KIRO_IDE_EVENT_NAMES = {
|
|
|
6768
6774
|
beforeSubmitPrompt: "UserPromptSubmit",
|
|
6769
6775
|
preToolUse: "PreToolUse",
|
|
6770
6776
|
postToolUse: "PostToolUse",
|
|
6777
|
+
permissionRequest: "PermissionRequest",
|
|
6771
6778
|
stop: "Stop"
|
|
6772
6779
|
};
|
|
6773
6780
|
/**
|
|
@@ -6776,7 +6783,9 @@ const CANONICAL_TO_KIRO_IDE_EVENT_NAMES = {
|
|
|
6776
6783
|
*
|
|
6777
6784
|
* Kiro exposes PascalCase triggers. rulesync maps the canonical lifecycle
|
|
6778
6785
|
* events that have a clean 1:1 equivalent: `SessionStart`, `Stop`,
|
|
6779
|
-
* `UserPromptSubmit`, `PreToolUse`,
|
|
6786
|
+
* `UserPromptSubmit`, `PreToolUse`, `PostToolUse`, and `PermissionRequest`
|
|
6787
|
+
* (Kiro IDE 1.4.236+ and CLI V3 3.4.0+; it takes a Pre Tool Use–style tool
|
|
6788
|
+
* matcher). Kiro also documents
|
|
6780
6789
|
* file-event (`PostFileCreate`/`PostFileSave`/`PostFileDelete`) and spec-task
|
|
6781
6790
|
* (`PreTaskExec`/`PostTaskExec`) triggers that have no canonical equivalent;
|
|
6782
6791
|
* those can still be emitted verbatim via the shared `kiro` override block
|
|
@@ -8205,6 +8214,15 @@ const CopilotSandboxUserConfiguredPathsSchema = zod_mini.z.strictObject({
|
|
|
8205
8214
|
deniedPaths: zod_mini.z.optional(zod_mini.z.array(zod_mini.z.string()))
|
|
8206
8215
|
});
|
|
8207
8216
|
/**
|
|
8217
|
+
* `chat.agent.sandbox.credentials.envVars` (VS Code 1.146+): environment
|
|
8218
|
+
* variable names (never their secret values) mapped to the HTTPS hosts the
|
|
8219
|
+
* Agent Host sandbox may inject each value into. Inside the sandbox the
|
|
8220
|
+
* variable is masked.
|
|
8221
|
+
*
|
|
8222
|
+
* @see https://code.visualstudio.com/docs/agents/run/agent-sandboxing
|
|
8223
|
+
*/
|
|
8224
|
+
const CopilotSandboxCredentialEnvVarsSchema = zod_mini.z.record(zod_mini.z.string(), zod_mini.z.strictObject({ injectHosts: zod_mini.z.array(zod_mini.z.string()) }));
|
|
8225
|
+
/**
|
|
8208
8226
|
* The Agent Host sandbox settings VS Code 1.141 settled on, as a nested object
|
|
8209
8227
|
* whose path mirrors the dotted setting key under `chat.agent.sandbox.` — e.g.
|
|
8210
8228
|
* `network.allowNetwork` writes `chat.agent.sandbox.network.allowNetwork`.
|
|
@@ -8226,7 +8244,8 @@ const CopilotSandboxSchema = zod_mini.z.strictObject({
|
|
|
8226
8244
|
lspServers: zod_mini.z.optional(zod_mini.z.boolean()),
|
|
8227
8245
|
credentials: zod_mini.z.optional(zod_mini.z.strictObject({
|
|
8228
8246
|
authenticategit: zod_mini.z.optional(zod_mini.z.boolean()),
|
|
8229
|
-
authenticategh: zod_mini.z.optional(zod_mini.z.boolean())
|
|
8247
|
+
authenticategh: zod_mini.z.optional(zod_mini.z.boolean()),
|
|
8248
|
+
envVars: zod_mini.z.optional(CopilotSandboxCredentialEnvVarsSchema)
|
|
8230
8249
|
})),
|
|
8231
8250
|
fileSystem: zod_mini.z.optional(zod_mini.z.strictObject({
|
|
8232
8251
|
allowDevToolAccess: zod_mini.z.optional(zod_mini.z.boolean()),
|
|
@@ -8553,15 +8572,15 @@ const CursorPermissionsOverrideSchema = zod_mini.z.looseObject({
|
|
|
8553
8572
|
* `tools` (`approvalMode` = plan/default/auto-edit/auto/yolo, `autoAccept`,
|
|
8554
8573
|
* `sandbox`, `sandboxImage`, `disabled`, `visible`, `eager`, `listDirectory`,
|
|
8555
8574
|
* `todoWrite`, `codeModeOnly`, `freeform`, `workflowsEnabled`, `workflowNameOnly`,
|
|
8556
|
-
* `executionSandbox`) and
|
|
8575
|
+
* `executionSandbox`, `lspEnabled`) and
|
|
8557
8576
|
* `security` (`folderTrust`, `allowedHttpHookUrls`, `allowPrivateNetworkHooks`,
|
|
8558
8577
|
* `allowedInsecureVoiceBaseUrls`) and `skills` (the skill kill-switches
|
|
8559
8578
|
* `disabled`, `defaultDisabled`, `enabled`, `disabledLevels`, each a list Qwen
|
|
8560
8579
|
* Code unions across scopes) and `general` (`outputStyle`, the output style
|
|
8561
8580
|
* that reshapes how responses are written). Qwen Code strips `tools.workflowsEnabled`,
|
|
8562
|
-
* `tools.executionSandbox`, `security.allowPrivateNetworkHooks` and
|
|
8581
|
+
* `tools.executionSandbox`, `tools.lspEnabled`, `security.allowPrivateNetworkHooks` and
|
|
8563
8582
|
* `security.allowedInsecureVoiceBaseUrls` out of workspace settings, so generate
|
|
8564
|
-
* skips those
|
|
8583
|
+
* skips those five in project scope and announces a granting value in global
|
|
8565
8584
|
* scope (any `executionSandbox` change counts). `tools.workflowNameOnly` is
|
|
8566
8585
|
* written in both scopes, but a workspace may only turn it on, which the
|
|
8567
8586
|
* project-scope note says. `security.allowedHttpHookUrls` (honored in a workspace only while no
|
|
@@ -8728,8 +8747,10 @@ const ReasonixPermissionsOverrideSchema = zod_mini.z.looseObject({
|
|
|
8728
8747
|
* holds: `general.defaultPermissionMode`, `tools.core` / `tools.exclude`, the
|
|
8729
8748
|
* MCP approval and loading keys under `mcp` (`allowed`, `excluded`,
|
|
8730
8749
|
* `enableAllProjectMcpServers`, `enabledProjectMcpServers`, `lazyLoad`),
|
|
8731
|
-
* `agents.overrides`,
|
|
8732
|
-
* `
|
|
8750
|
+
* `agents.overrides`, `security.disableYoloMode` (turns off the
|
|
8751
|
+
* `bypass_permissions` / YOLO mode; it only hardens, so it is not announced),
|
|
8752
|
+
* the top-level `agentsMdExcludes` and the top-level `autoMode` classifier
|
|
8753
|
+
* guidance (`allow` / `soft_deny` / `environment`).
|
|
8733
8754
|
* Qoder reads `autoMode` from the user settings only, so it is written by
|
|
8734
8755
|
* `--global` generate alone. Only the keys listed here are written; any other
|
|
8735
8756
|
* key of these groups or of `autoMode` (`tools.shell.pager`,
|
|
@@ -8763,6 +8784,7 @@ const QoderPermissionsOverrideSchema = zod_mini.z.looseObject({
|
|
|
8763
8784
|
lazyLoad: zod_mini.z.optional(zod_mini.z.boolean())
|
|
8764
8785
|
})),
|
|
8765
8786
|
agents: zod_mini.z.optional(zod_mini.z.looseObject({ overrides: zod_mini.z.optional(zod_mini.z.record(zod_mini.z.string(), zod_mini.z.looseObject({}))) })),
|
|
8787
|
+
security: zod_mini.z.optional(zod_mini.z.looseObject({ disableYoloMode: zod_mini.z.optional(zod_mini.z.boolean()) })),
|
|
8766
8788
|
autoMode: zod_mini.z.optional(zod_mini.z.looseObject({
|
|
8767
8789
|
allow: zod_mini.z.optional(zod_mini.z.array(zod_mini.z.string())),
|
|
8768
8790
|
soft_deny: zod_mini.z.optional(zod_mini.z.array(zod_mini.z.string())),
|
|
@@ -9239,7 +9261,9 @@ const ANTIGRAVITY_CLI_ARTIFACT_REVIEW_POLICIES = [
|
|
|
9239
9261
|
* import filter for the same reason as {@link ANTIGRAVITY_CLI_TOOL_PERMISSIONS}.
|
|
9240
9262
|
* `auto` (Preview) requires the terminal sandbox (`enableTerminalSandbox`), is
|
|
9241
9263
|
* not offered to business or enterprise accounts, and falls back to `default`
|
|
9242
|
-
* when unavailable.
|
|
9264
|
+
* when unavailable. Canonical `default` is stored by the CLI as `""` (the
|
|
9265
|
+
* translation lives in `antigravity-cli-permissions.ts`), and since CLI 1.5.7
|
|
9266
|
+
* an omitted `agentMode` starts in `auto` where available.
|
|
9243
9267
|
* @see https://antigravity.google/docs/cli/modes
|
|
9244
9268
|
*/
|
|
9245
9269
|
const ANTIGRAVITY_CLI_AGENT_MODES = [
|
|
@@ -9540,15 +9564,20 @@ const CodexcliPermissionsOverrideSchema = zod_mini.z.looseObject({
|
|
|
9540
9564
|
/**
|
|
9541
9565
|
* The `[auto_review]` table of `config.toml`, which configures the reviewer
|
|
9542
9566
|
* that `approvals_reviewer = "auto_review"` (Rulesync's default) selects:
|
|
9543
|
-
* `policy` / `extra_policy` (text inserted into the reviewer prompt
|
|
9567
|
+
* `policy` / `extra_policy` (text inserted into the reviewer prompt;
|
|
9568
|
+
* `extra_policy` only up to Codex 0.168.0),
|
|
9544
9569
|
* `timeout_ms` (the review budget, Codex 0.165.0+; `0` waits without a
|
|
9545
9570
|
* deadline), `circuit_break_action` (`default` | `strict`) and
|
|
9546
9571
|
* `conversation_history_max_output_tokens` (a positive token cap). Codex
|
|
9547
9572
|
* rejects the whole config file when one of these has the wrong type or is
|
|
9548
9573
|
* out of range (`timeout_ms` is a `u32`, the token cap a `NonZeroUsize`), so
|
|
9549
9574
|
* they are checked here; every other key passes through verbatim.
|
|
9575
|
+
* `extra_policy` and `experimental_policy_template` were removed in Codex
|
|
9576
|
+
* 0.169.0 (openai/codex PR #60646): newer Codex ignores them and warns at
|
|
9577
|
+
* startup (only `--strict-config` rejects them), so they are still accepted
|
|
9578
|
+
* and written for older Codex, and generate warns when they are authored.
|
|
9550
9579
|
*
|
|
9551
|
-
* @see https://github.com/openai/codex/blob/rust-v0.
|
|
9580
|
+
* @see https://github.com/openai/codex/blob/rust-v0.169.0/codex-rs/config/src/config_toml.rs (`AutoReviewToml`)
|
|
9552
9581
|
*/
|
|
9553
9582
|
auto_review: zod_mini.z.optional(zod_mini.z.looseObject({
|
|
9554
9583
|
policy: zod_mini.z.optional(zod_mini.z.string()),
|
|
@@ -14015,6 +14044,7 @@ const SHARED_CONFIG_OWNERSHIP = {
|
|
|
14015
14044
|
"chat.agent.sandbox.lspServers",
|
|
14016
14045
|
"chat.agent.sandbox.credentials.authenticategit",
|
|
14017
14046
|
"chat.agent.sandbox.credentials.authenticategh",
|
|
14047
|
+
"chat.agent.sandbox.credentials.envVars",
|
|
14018
14048
|
"chat.agent.sandbox.fileSystem.allowDevToolAccess",
|
|
14019
14049
|
"chat.agent.sandbox.fileSystem.userConfiguredPaths",
|
|
14020
14050
|
"zoo-code.allowedCommands",
|
|
@@ -14263,6 +14293,7 @@ const SHARED_CONFIG_OWNERSHIP = {
|
|
|
14263
14293
|
"tools",
|
|
14264
14294
|
"mcp",
|
|
14265
14295
|
"agents",
|
|
14296
|
+
"security",
|
|
14266
14297
|
"autoMode",
|
|
14267
14298
|
"agentsMdExcludes"
|
|
14268
14299
|
]
|
|
@@ -27742,6 +27773,8 @@ const MUSECODE_RULE_FILE_NAME = "AGENTS.md";
|
|
|
27742
27773
|
const MUSECODE_SKILLS_DIR_PATH = AGENTSMD_SKILLS_DIR_PATH;
|
|
27743
27774
|
const MUSECODE_GLOBAL_CONFIG_DIR_PATH = (0, node_path.join)(".config", "muse");
|
|
27744
27775
|
const MUSECODE_GLOBAL_SKILLS_DIR_PATH = (0, node_path.join)(MUSECODE_GLOBAL_CONFIG_DIR_PATH, "skills");
|
|
27776
|
+
const MUSECODE_SUBAGENTS_DIR_PATH = AGENTSMD_SUBAGENTS_DIR_PATH;
|
|
27777
|
+
const MUSECODE_GLOBAL_SUBAGENTS_DIR_PATH = (0, node_path.join)(MUSECODE_GLOBAL_CONFIG_DIR_PATH, "agents");
|
|
27745
27778
|
const MUSECODE_SETTINGS_FILE_NAME = "settings.json";
|
|
27746
27779
|
// src/features/skills/musecode-skill.ts
|
|
27747
27780
|
const MusecodeSkillFrontmatterSchema = zod_mini.z.looseObject({
|
|
@@ -30733,6 +30766,17 @@ const AntigravitySubagentFrontmatterSchema = zod_mini.z.looseObject({
|
|
|
30733
30766
|
*/
|
|
30734
30767
|
const ANTIGRAVITY_SHARED_SUBAGENT_SECTION_KEYS = ["antigravity-ide", "antigravity-cli"];
|
|
30735
30768
|
/**
|
|
30769
|
+
* Tool-specific rulesync sections every writer of the project
|
|
30770
|
+
* `.agents/agents/<name>.md` file merges, in increasing precedence order.
|
|
30771
|
+
*
|
|
30772
|
+
* Muse Code loads its project agents from the same directory, so its section
|
|
30773
|
+
* is merged into the shared file too, below the Antigravity blocks: a key both
|
|
30774
|
+
* set keeps the Antigravity value the file carried before Muse Code joined.
|
|
30775
|
+
* Global agents live in per-tool directories, so this list applies to the
|
|
30776
|
+
* project file only.
|
|
30777
|
+
*/
|
|
30778
|
+
const AGENTS_DIR_SHARED_SUBAGENT_SECTION_KEYS = ["musecode", ...ANTIGRAVITY_SHARED_SUBAGENT_SECTION_KEYS];
|
|
30779
|
+
/**
|
|
30736
30780
|
* Build the frontmatter an `.agents/agents/<name>.md` file carries.
|
|
30737
30781
|
*
|
|
30738
30782
|
* That path is shared: every Antigravity target writes it, and so does the
|
|
@@ -30830,11 +30874,13 @@ var AntigravitySharedSubagent = class extends ToolSubagent {
|
|
|
30830
30874
|
* therefore merges the shared `antigravity-ide` → `antigravity-cli` sections
|
|
30831
30875
|
* (the CLI block wins, matching the fixed order the MCP feature already uses
|
|
30832
30876
|
* for the same shared-output reason), and the plugin target layers its own
|
|
30833
|
-
* section on top of that.
|
|
30834
|
-
*
|
|
30877
|
+
* section on top of that. The project file is also read by Muse Code, so in
|
|
30878
|
+
* project scope the `musecode` section is merged underneath (see
|
|
30879
|
+
* {@link AGENTS_DIR_SHARED_SUBAGENT_SECTION_KEYS}). Only `getToolTarget()`
|
|
30880
|
+
* decides which section an import writes back into.
|
|
30835
30881
|
*/
|
|
30836
|
-
static getReadSectionKeys() {
|
|
30837
|
-
return [...ANTIGRAVITY_SHARED_SUBAGENT_SECTION_KEYS];
|
|
30882
|
+
static getReadSectionKeys({ global = false } = {}) {
|
|
30883
|
+
return global ? [...ANTIGRAVITY_SHARED_SUBAGENT_SECTION_KEYS] : [...AGENTS_DIR_SHARED_SUBAGENT_SECTION_KEYS];
|
|
30838
30884
|
}
|
|
30839
30885
|
static getSettablePaths({ global = false } = {}) {
|
|
30840
30886
|
return { relativeDirPath: global ? ANTIGRAVITY_GLOBAL_AGENTS_DIR_PATH : ANTIGRAVITY_AGENTS_DIR_PATH };
|
|
@@ -30864,7 +30910,7 @@ var AntigravitySharedSubagent = class extends ToolSubagent {
|
|
|
30864
30910
|
static fromRulesyncSubagent({ outputRoot = process.cwd(), rulesyncSubagent, validate = true, global = false }) {
|
|
30865
30911
|
const frontmatter = toAntigravitySubagentFrontmatter({
|
|
30866
30912
|
rulesyncSubagent,
|
|
30867
|
-
sectionKeys: this.getReadSectionKeys(),
|
|
30913
|
+
sectionKeys: this.getReadSectionKeys({ global }),
|
|
30868
30914
|
toolTarget: this.getToolTarget()
|
|
30869
30915
|
});
|
|
30870
30916
|
const body = rulesyncSubagent.getBody();
|
|
@@ -31054,7 +31100,7 @@ var AgentsmdSubagent = class AgentsmdSubagent extends SimulatedSubagent {
|
|
|
31054
31100
|
const defaults = this.fromRulesyncSubagentDefault(params);
|
|
31055
31101
|
const frontmatter = toAntigravitySubagentFrontmatter({
|
|
31056
31102
|
rulesyncSubagent: params.rulesyncSubagent,
|
|
31057
|
-
sectionKeys:
|
|
31103
|
+
sectionKeys: AGENTS_DIR_SHARED_SUBAGENT_SECTION_KEYS,
|
|
31058
31104
|
toolTarget: "agentsmd"
|
|
31059
31105
|
});
|
|
31060
31106
|
return new AgentsmdSubagent({
|
|
@@ -31117,7 +31163,7 @@ var AntigravityPluginSubagent = class extends AntigravitySharedSubagent {
|
|
|
31117
31163
|
return "antigravity-plugin";
|
|
31118
31164
|
}
|
|
31119
31165
|
static getReadSectionKeys() {
|
|
31120
|
-
return [...
|
|
31166
|
+
return [...ANTIGRAVITY_SHARED_SUBAGENT_SECTION_KEYS, "antigravity-plugin"];
|
|
31121
31167
|
}
|
|
31122
31168
|
static getSettablePaths() {
|
|
31123
31169
|
return { relativeDirPath: ANTIGRAVITY_PLUGIN_AGENTS_DIR };
|
|
@@ -31461,7 +31507,7 @@ var RooSubagent = class extends ToolSubagent {
|
|
|
31461
31507
|
* Aggregate every targeted rulesync subagent into a single `.roomodes` file.
|
|
31462
31508
|
* Modes are de-duplicated by `slug` (last one wins) to keep the array unique.
|
|
31463
31509
|
*/
|
|
31464
|
-
static fromRulesyncSubagents({ outputRoot = process.cwd(), rulesyncSubagents, validate = true }) {
|
|
31510
|
+
static fromRulesyncSubagents({ outputRoot = process.cwd(), rulesyncSubagents, validate = true, global = false }) {
|
|
31465
31511
|
const bySlug = /* @__PURE__ */ new Map();
|
|
31466
31512
|
for (const rulesyncSubagent of rulesyncSubagents) {
|
|
31467
31513
|
const mode = this.toRooMode(rulesyncSubagent);
|
|
@@ -31469,17 +31515,19 @@ var RooSubagent = class extends ToolSubagent {
|
|
|
31469
31515
|
}
|
|
31470
31516
|
return new this({
|
|
31471
31517
|
outputRoot,
|
|
31472
|
-
relativeDirPath: this.getSettablePaths().relativeDirPath,
|
|
31518
|
+
relativeDirPath: this.getSettablePaths({ global }).relativeDirPath,
|
|
31473
31519
|
relativeFilePath: this.modesFileName,
|
|
31474
31520
|
modes: [...bySlug.values()],
|
|
31475
|
-
validate
|
|
31521
|
+
validate,
|
|
31522
|
+
global
|
|
31476
31523
|
});
|
|
31477
31524
|
}
|
|
31478
|
-
static fromRulesyncSubagent({ outputRoot = process.cwd(), rulesyncSubagent, validate = true }) {
|
|
31525
|
+
static fromRulesyncSubagent({ outputRoot = process.cwd(), rulesyncSubagent, validate = true, global = false }) {
|
|
31479
31526
|
return this.fromRulesyncSubagents({
|
|
31480
31527
|
outputRoot,
|
|
31481
31528
|
rulesyncSubagents: [rulesyncSubagent],
|
|
31482
|
-
validate
|
|
31529
|
+
validate,
|
|
31530
|
+
global
|
|
31483
31531
|
});
|
|
31484
31532
|
}
|
|
31485
31533
|
/**
|
|
@@ -31535,8 +31583,8 @@ var RooSubagent = class extends ToolSubagent {
|
|
|
31535
31583
|
toolTarget: "roo"
|
|
31536
31584
|
});
|
|
31537
31585
|
}
|
|
31538
|
-
static async fromFile({ outputRoot = process.cwd(), relativeFilePath, validate = true }) {
|
|
31539
|
-
const paths = this.getSettablePaths();
|
|
31586
|
+
static async fromFile({ outputRoot = process.cwd(), relativeFilePath, validate = true, global = false }) {
|
|
31587
|
+
const paths = this.getSettablePaths({ global });
|
|
31540
31588
|
const filePath = (0, node_path.join)(outputRoot, paths.relativeDirPath, relativeFilePath);
|
|
31541
31589
|
const fileContent = await readFileContent(filePath);
|
|
31542
31590
|
let parsed;
|
|
@@ -31552,16 +31600,18 @@ var RooSubagent = class extends ToolSubagent {
|
|
|
31552
31600
|
relativeDirPath: paths.relativeDirPath,
|
|
31553
31601
|
relativeFilePath: (0, node_path.basename)(relativeFilePath),
|
|
31554
31602
|
modes: result.data.customModes,
|
|
31555
|
-
validate
|
|
31603
|
+
validate,
|
|
31604
|
+
global
|
|
31556
31605
|
});
|
|
31557
31606
|
}
|
|
31558
|
-
static forDeletion({ outputRoot = process.cwd(), relativeDirPath, relativeFilePath }) {
|
|
31607
|
+
static forDeletion({ outputRoot = process.cwd(), relativeDirPath, relativeFilePath, global = false }) {
|
|
31559
31608
|
return new this({
|
|
31560
31609
|
outputRoot,
|
|
31561
31610
|
relativeDirPath,
|
|
31562
31611
|
relativeFilePath,
|
|
31563
31612
|
modes: [],
|
|
31564
|
-
validate: false
|
|
31613
|
+
validate: false,
|
|
31614
|
+
global
|
|
31565
31615
|
});
|
|
31566
31616
|
}
|
|
31567
31617
|
};
|
|
@@ -31573,8 +31623,13 @@ var RooSubagent = class extends ToolSubagent {
|
|
|
31573
31623
|
* presets `explore` and `general` — but it reads custom modes from an
|
|
31574
31624
|
* aggregated `customModes` YAML file in Roo's format, so every targeted rulesync
|
|
31575
31625
|
* subagent becomes one mode in `.bob/custom_modes.yaml`, exactly as the `roo`
|
|
31576
|
-
* target fills `.roomodes`.
|
|
31577
|
-
*
|
|
31626
|
+
* target fills `.roomodes`. In global mode the same array goes to
|
|
31627
|
+
* `~/.bob/settings/custom_modes.yaml`, the user file both the Bob IDE and Bob
|
|
31628
|
+
* Shell custom-modes pages name. That file is unversioned and Bob IDE's "Edit
|
|
31629
|
+
* Global Modes" setting writes it too, so rulesync does not own it: a global
|
|
31630
|
+
* generate merges the generated modes into it by `slug`, keeps every other
|
|
31631
|
+
* mode, and the file is never deleted. The project file stays wholly owned by
|
|
31632
|
+
* rulesync, like Roo's `.roomodes`.
|
|
31578
31633
|
*
|
|
31579
31634
|
* The mode fields ride a `bob:` frontmatter section rather than Roo's `roo:`
|
|
31580
31635
|
* one, because Bob's tool groups are spelled differently (`execute` where Roo
|
|
@@ -31591,7 +31646,7 @@ var RooSubagent = class extends ToolSubagent {
|
|
|
31591
31646
|
* @see https://bob.ibm.com/docs/shell/configuration/custom-modes-bobshell
|
|
31592
31647
|
* @see https://bob.ibm.com/docs/ide/features/subagents
|
|
31593
31648
|
*/
|
|
31594
|
-
var BobSubagent = class extends RooSubagent {
|
|
31649
|
+
var BobSubagent = class BobSubagent extends RooSubagent {
|
|
31595
31650
|
static modesFileName = BOB_CUSTOM_MODES_FILE_NAME;
|
|
31596
31651
|
static modeSectionKey = "bob";
|
|
31597
31652
|
static defaultGroups = [
|
|
@@ -31601,12 +31656,74 @@ var BobSubagent = class extends RooSubagent {
|
|
|
31601
31656
|
"mcp"
|
|
31602
31657
|
];
|
|
31603
31658
|
static importTarget = "bob";
|
|
31604
|
-
static getSettablePaths(
|
|
31659
|
+
static getSettablePaths({ global = false } = {}) {
|
|
31605
31660
|
return {
|
|
31606
|
-
relativeDirPath: BOB_DIR,
|
|
31661
|
+
relativeDirPath: global ? BOB_GLOBAL_SETTINGS_DIR_PATH : BOB_DIR,
|
|
31607
31662
|
relativeFilePath: BOB_CUSTOM_MODES_FILE_NAME
|
|
31608
31663
|
};
|
|
31609
31664
|
}
|
|
31665
|
+
/** Receives the merge warnings; set by {@link BobSubagent.fromRulesyncSubagents}. */
|
|
31666
|
+
bobLogger;
|
|
31667
|
+
static fromRulesyncSubagents(params) {
|
|
31668
|
+
const subagent = super.fromRulesyncSubagents(params);
|
|
31669
|
+
if (subagent instanceof BobSubagent) subagent.bobLogger = params.logger;
|
|
31670
|
+
return subagent;
|
|
31671
|
+
}
|
|
31672
|
+
isDeletable() {
|
|
31673
|
+
return !this.global;
|
|
31674
|
+
}
|
|
31675
|
+
shouldMergeExistingFileContent() {
|
|
31676
|
+
return this.global;
|
|
31677
|
+
}
|
|
31678
|
+
/**
|
|
31679
|
+
* Merge the generated modes into the existing global file: a mode whose
|
|
31680
|
+
* `slug` rulesync generates is replaced in place, every other entry is kept
|
|
31681
|
+
* as written, and new modes are appended. A file that cannot be read as a
|
|
31682
|
+
* `customModes` document is an error rather than something to overwrite.
|
|
31683
|
+
*/
|
|
31684
|
+
setFileContent(existingContent) {
|
|
31685
|
+
if (!this.global) {
|
|
31686
|
+
super.setFileContent(existingContent);
|
|
31687
|
+
return;
|
|
31688
|
+
}
|
|
31689
|
+
const filePath = (0, node_path.join)(this.getOutputRoot(), this.getRelativeDirPath(), this.getRelativeFilePath());
|
|
31690
|
+
let parsed;
|
|
31691
|
+
try {
|
|
31692
|
+
parsed = loadYaml(existingContent);
|
|
31693
|
+
} catch (error) {
|
|
31694
|
+
throw new Error(`Failed to parse custom modes (${filePath}); not overwriting it: ${formatError(error)}`, { cause: error });
|
|
31695
|
+
}
|
|
31696
|
+
const existingModes = isRecord(parsed) ? parsed.customModes : void 0;
|
|
31697
|
+
if (!(parsed === null || parsed === void 0 || isRecord(parsed)) || !(existingModes === null || existingModes === void 0 || Array.isArray(existingModes))) throw new Error(`Invalid custom modes in ${filePath}; not overwriting it: expected a "customModes" list.`);
|
|
31698
|
+
const generatedModes = this.getModes();
|
|
31699
|
+
const generatedSlugs = new Set(generatedModes.map((mode) => mode.slug));
|
|
31700
|
+
const pending = new Map(generatedModes.map((mode) => [mode.slug, mode]));
|
|
31701
|
+
const duplicateSlugs = /* @__PURE__ */ new Set();
|
|
31702
|
+
const merged = [];
|
|
31703
|
+
for (const entry of Array.isArray(existingModes) ? existingModes : []) {
|
|
31704
|
+
const slug = isRecord(entry) ? entry.slug : void 0;
|
|
31705
|
+
if (typeof slug !== "string" || !generatedSlugs.has(slug)) {
|
|
31706
|
+
merged.push(entry);
|
|
31707
|
+
continue;
|
|
31708
|
+
}
|
|
31709
|
+
const mode = pending.get(slug);
|
|
31710
|
+
if (mode === void 0) {
|
|
31711
|
+
duplicateSlugs.add(slug);
|
|
31712
|
+
continue;
|
|
31713
|
+
}
|
|
31714
|
+
merged.push(mode);
|
|
31715
|
+
pending.delete(slug);
|
|
31716
|
+
}
|
|
31717
|
+
merged.push(...pending.values());
|
|
31718
|
+
if (duplicateSlugs.size > 0) this.bobLogger?.warn(`Removed duplicate Bob custom mode(s) ${[...duplicateSlugs].map(quoteValueForWarning).join(", ")} from ${filePath}: rulesync generates these slugs and keeps only one entry for each.`);
|
|
31719
|
+
super.setFileContent((0, js_yaml.dump)({
|
|
31720
|
+
...isRecord(parsed) ? parsed : {},
|
|
31721
|
+
customModes: merged
|
|
31722
|
+
}, {
|
|
31723
|
+
lineWidth: -1,
|
|
31724
|
+
noRefs: true
|
|
31725
|
+
}));
|
|
31726
|
+
}
|
|
31610
31727
|
static isTargetedByRulesyncSubagent(rulesyncSubagent) {
|
|
31611
31728
|
return this.isTargetedByRulesyncSubagentDefault({
|
|
31612
31729
|
rulesyncSubagent,
|
|
@@ -35684,6 +35801,87 @@ var OpenCodeSubagent = class extends OpenCodeStyleSubagent {
|
|
|
35684
35801
|
var MimocodeSubagent = class extends OpenCodeSubagent {
|
|
35685
35802
|
static layout = MIMOCODE_LAYOUT;
|
|
35686
35803
|
};
|
|
35804
|
+
// src/features/subagents/musecode-subagent.ts
|
|
35805
|
+
/**
|
|
35806
|
+
* Muse Code agent names are lowercase words joined by single hyphens
|
|
35807
|
+
* (`test-writer`).
|
|
35808
|
+
*
|
|
35809
|
+
* @see https://dev.meta.ai/docs/muse-code/agents
|
|
35810
|
+
*/
|
|
35811
|
+
const MUSECODE_AGENT_NAME_PATTERN = /^[a-z]+(?:-[a-z]+)*$/;
|
|
35812
|
+
/**
|
|
35813
|
+
* The frontmatter keys the Muse Code agents page documents.
|
|
35814
|
+
*
|
|
35815
|
+
* @see https://dev.meta.ai/docs/muse-code/agents
|
|
35816
|
+
*/
|
|
35817
|
+
const MUSECODE_DOCUMENTED_FRONTMATTER_KEYS = /* @__PURE__ */ new Set([
|
|
35818
|
+
"name",
|
|
35819
|
+
"description",
|
|
35820
|
+
"model",
|
|
35821
|
+
"effort",
|
|
35822
|
+
"tools",
|
|
35823
|
+
"disallowedTools"
|
|
35824
|
+
]);
|
|
35825
|
+
/**
|
|
35826
|
+
* Meta Muse Code custom agent (subagent): a Markdown file with YAML
|
|
35827
|
+
* frontmatter (`name`, `description`, and optionally `model`, `effort`,
|
|
35828
|
+
* `tools`, `disallowedTools`) whose body is the agent's prompt.
|
|
35829
|
+
*
|
|
35830
|
+
* Project agents load from `.agents/agents/`, the directory the Antigravity
|
|
35831
|
+
* targets and the simulated `agentsmd` writer already generate into, so the
|
|
35832
|
+
* project file is rendered exactly like theirs (the `musecode` section is part
|
|
35833
|
+
* of the merge every writer of that file performs) and the file on disk does
|
|
35834
|
+
* not depend on which target ran last. User agents load from
|
|
35835
|
+
* `~/.config/muse/agents/`, which only this target writes, so only the
|
|
35836
|
+
* `musecode` section is merged there.
|
|
35837
|
+
*
|
|
35838
|
+
* @see https://dev.meta.ai/docs/muse-code/agents
|
|
35839
|
+
*/
|
|
35840
|
+
var MusecodeSubagent = class extends AntigravitySharedSubagent {
|
|
35841
|
+
static getToolTarget() {
|
|
35842
|
+
return "musecode";
|
|
35843
|
+
}
|
|
35844
|
+
static getReadSectionKeys({ global = false } = {}) {
|
|
35845
|
+
return global ? ["musecode"] : super.getReadSectionKeys({ global });
|
|
35846
|
+
}
|
|
35847
|
+
static getSettablePaths({ global = false } = {}) {
|
|
35848
|
+
return { relativeDirPath: global ? MUSECODE_GLOBAL_SUBAGENTS_DIR_PATH : MUSECODE_SUBAGENTS_DIR_PATH };
|
|
35849
|
+
}
|
|
35850
|
+
static fromRulesyncSubagent(params) {
|
|
35851
|
+
const name = params.rulesyncSubagent.getFrontmatter().name;
|
|
35852
|
+
if (!MUSECODE_AGENT_NAME_PATTERN.test(name)) params.logger?.warn(`Muse Code subagent name '${name}' in ${params.rulesyncSubagent.getRelativeFilePath()} is not lowercase words joined by single hyphens (e.g. 'test-writer'); Muse Code may not load it.`);
|
|
35853
|
+
const subagent = super.fromRulesyncSubagent(params);
|
|
35854
|
+
if (!params.global && subagent instanceof AntigravitySharedSubagent) this.warnAboutSharedProjectFile({
|
|
35855
|
+
params,
|
|
35856
|
+
subagent
|
|
35857
|
+
});
|
|
35858
|
+
return subagent;
|
|
35859
|
+
}
|
|
35860
|
+
/**
|
|
35861
|
+
* The project file is shared with the Antigravity writers, so its content
|
|
35862
|
+
* cannot be narrowed to what Muse Code documents. Say so instead when the
|
|
35863
|
+
* merged file differs from what the `musecode` block alone would produce.
|
|
35864
|
+
*/
|
|
35865
|
+
static warnAboutSharedProjectFile({ params, subagent }) {
|
|
35866
|
+
const { logger, rulesyncSubagent } = params;
|
|
35867
|
+
const relativeFilePath = rulesyncSubagent.getRelativeFilePath();
|
|
35868
|
+
const undocumentedKeys = Object.keys(subagent.getFrontmatter()).filter((key) => !MUSECODE_DOCUMENTED_FRONTMATTER_KEYS.has(key));
|
|
35869
|
+
if (undocumentedKeys.length > 0) logger?.warn(`Muse Code subagent ${relativeFilePath}: the shared .agents/agents/ file carries keys Muse Code does not document (${undocumentedKeys.join(", ")}), set in a musecode or antigravity-* block; Muse Code may refuse to load the agent.`);
|
|
35870
|
+
const rulesyncFrontmatter = rulesyncSubagent.getFrontmatter();
|
|
35871
|
+
const musecodeSection = rulesyncFrontmatter.musecode;
|
|
35872
|
+
if (!isPlainObject(musecodeSection)) return;
|
|
35873
|
+
for (const key of Object.keys(musecodeSection)) {
|
|
35874
|
+
if (key === "name" || key === "description") continue;
|
|
35875
|
+
const overridingSection = ANTIGRAVITY_SHARED_SUBAGENT_SECTION_KEYS.toReversed().find((sectionKey) => {
|
|
35876
|
+
const section = rulesyncFrontmatter[sectionKey];
|
|
35877
|
+
return isPlainObject(section) && section[key] !== void 0;
|
|
35878
|
+
});
|
|
35879
|
+
if (overridingSection === void 0) continue;
|
|
35880
|
+
const overridingValue = rulesyncFrontmatter[overridingSection][key];
|
|
35881
|
+
if (!(0, node_util.isDeepStrictEqual)(overridingValue, musecodeSection[key])) logger?.warn(`Muse Code subagent ${relativeFilePath}: '${key}' from the musecode block is overridden by the ${overridingSection} block in the shared .agents/agents/ file.`);
|
|
35882
|
+
}
|
|
35883
|
+
}
|
|
35884
|
+
};
|
|
35687
35885
|
// src/features/subagents/omp-subagent.ts
|
|
35688
35886
|
/**
|
|
35689
35887
|
* Frontmatter of an oh-my-pi agent definition (`parseAgentFields` in
|
|
@@ -37457,7 +37655,7 @@ const toolSubagentFactories = /* @__PURE__ */ new Map([
|
|
|
37457
37655
|
meta: {
|
|
37458
37656
|
supportsProject: true,
|
|
37459
37657
|
supportsSimulated: false,
|
|
37460
|
-
supportsGlobal:
|
|
37658
|
+
supportsGlobal: true,
|
|
37461
37659
|
filePattern: "custom_modes.yaml"
|
|
37462
37660
|
}
|
|
37463
37661
|
}],
|
|
@@ -37735,6 +37933,15 @@ const toolSubagentFactories = /* @__PURE__ */ new Map([
|
|
|
37735
37933
|
filePattern: "*.md"
|
|
37736
37934
|
}
|
|
37737
37935
|
}],
|
|
37936
|
+
["musecode", {
|
|
37937
|
+
class: MusecodeSubagent,
|
|
37938
|
+
meta: {
|
|
37939
|
+
supportsProject: true,
|
|
37940
|
+
supportsSimulated: false,
|
|
37941
|
+
supportsGlobal: true,
|
|
37942
|
+
filePattern: "*.md"
|
|
37943
|
+
}
|
|
37944
|
+
}],
|
|
37738
37945
|
["omp", {
|
|
37739
37946
|
class: OmpSubagent,
|
|
37740
37947
|
meta: {
|
|
@@ -51756,9 +51963,14 @@ const GooseCheckFrontmatterSchema = zod_mini.z.extend(AmpCheckFrontmatterSchema,
|
|
|
51756
51963
|
"turn-limit": zod_mini.z.optional(zod_mini.z.int().check(zod_mini.z.nonnegative()))
|
|
51757
51964
|
});
|
|
51758
51965
|
/**
|
|
51759
|
-
* Represents a Goose review check
|
|
51966
|
+
* Represents a Goose review check, written to the user-wide
|
|
51760
51967
|
* `~/.config/goose/checks/` (global scope only).
|
|
51761
51968
|
*
|
|
51969
|
+
* Goose v1.60.0 removed the `goose review` subcommand that ran these checks
|
|
51970
|
+
* (aaif-goose/goose#13469). Goose still discovers them, but only lists them as
|
|
51971
|
+
* agent sources (`properties.kind = "check"`), so `model` and `turn-limit`
|
|
51972
|
+
* have no runtime effect there.
|
|
51973
|
+
*
|
|
51762
51974
|
* Goose discovers repository checks in `.agents/checks/*.md`, the same
|
|
51763
51975
|
* cross-tool directory the `amp` checks target already writes (Goose's
|
|
51764
51976
|
* `tools` and `severity-default` fields exist for parity with Amp's), so the
|
|
@@ -53921,13 +54133,29 @@ function isEventApplicable({ events, eventName }) {
|
|
|
53921
54133
|
function describeEvents(names) {
|
|
53922
54134
|
return [...names].map((name) => `"${name}"`).join(", ");
|
|
53923
54135
|
}
|
|
54136
|
+
const COMMAND_HOOK_TYPES = /* @__PURE__ */ new Set(["command"]);
|
|
53924
54137
|
/**
|
|
53925
|
-
*
|
|
53926
|
-
*
|
|
53927
|
-
* the exporter would then drop is silently deleted on the next generate.
|
|
54138
|
+
* The hook types a field is documented on, or `undefined` when unrestricted.
|
|
54139
|
+
* `commandOnly` is shorthand for `command` alone.
|
|
53928
54140
|
*/
|
|
53929
|
-
function
|
|
53930
|
-
return commandOnly
|
|
54141
|
+
function documentedHookTypes({ commandOnly, hookTypes }) {
|
|
54142
|
+
return commandOnly === true ? COMMAND_HOOK_TYPES : hookTypes;
|
|
54143
|
+
}
|
|
54144
|
+
/** Quote the hook types a restricted field is documented on, for a warning. */
|
|
54145
|
+
function describeDocumentedHookTypes(spec) {
|
|
54146
|
+
return describeEvents(documentedHookTypes(spec) ?? COMMAND_HOOK_TYPES);
|
|
54147
|
+
}
|
|
54148
|
+
/**
|
|
54149
|
+
* Whether a field registered for some hook types only (`command` hooks, or
|
|
54150
|
+
* the listed `hookTypes`) applies to this hook. Applied on both export and
|
|
54151
|
+
* import: a value imported into a canonical field the exporter would then
|
|
54152
|
+
* drop is silently deleted on the next generate.
|
|
54153
|
+
*/
|
|
54154
|
+
function isFieldApplicable({ commandOnly, hookTypes, hookType }) {
|
|
54155
|
+
return documentedHookTypes({
|
|
54156
|
+
commandOnly,
|
|
54157
|
+
hookTypes
|
|
54158
|
+
})?.has(hookType) ?? true;
|
|
53931
54159
|
}
|
|
53932
54160
|
/**
|
|
53933
54161
|
* Emit the configured passthrough fields on the tool side, mapping each
|
|
@@ -53942,14 +54170,18 @@ function isFieldApplicable({ commandOnly, hookType }) {
|
|
|
53942
54170
|
* silence — the mirror of the import side.
|
|
53943
54171
|
*/
|
|
53944
54172
|
function emitPassthroughFields({ def, hookType, eventName, fields, isValid, warn }) {
|
|
53945
|
-
for (const { canonical, tool, commandOnly, maxLength, collapseWhitespaceForLength, onlyWithFlag, events } of fields) {
|
|
54173
|
+
for (const { canonical, tool, commandOnly, hookTypes, maxLength, collapseWhitespaceForLength, onlyWithFlag, events } of fields) {
|
|
53946
54174
|
const value = def[canonical];
|
|
53947
54175
|
if (value === void 0) continue;
|
|
53948
54176
|
if (!isFieldApplicable({
|
|
53949
54177
|
commandOnly,
|
|
54178
|
+
hookTypes,
|
|
53950
54179
|
hookType
|
|
53951
54180
|
})) {
|
|
53952
|
-
warn?.(`Dropping "${canonical}" from a "${hookType}" hook on "${eventName}": this tool documents "${tool}" on
|
|
54181
|
+
warn?.(`Dropping "${canonical}" from a "${hookType}" hook on "${eventName}": this tool documents "${tool}" on ${describeDocumentedHookTypes({
|
|
54182
|
+
commandOnly,
|
|
54183
|
+
hookTypes
|
|
54184
|
+
})} hooks only, so it is not generated.`);
|
|
53953
54185
|
continue;
|
|
53954
54186
|
}
|
|
53955
54187
|
if (events !== void 0 && !isEventApplicable({
|
|
@@ -53972,8 +54204,9 @@ function emitPassthroughFields({ def, hookType, eventName, fields, isValid, warn
|
|
|
53972
54204
|
if (length > maxLength) warn?.(`"${canonical}" on a "${hookType}" hook on "${eventName}" is ${length} characters long${collapseWhitespaceForLength ? " after collapsing whitespace" : ""}; this tool caps "${tool}" at ${maxLength} characters and will shorten it.`);
|
|
53973
54205
|
}
|
|
53974
54206
|
}
|
|
53975
|
-
return Object.fromEntries(fields.filter(({ canonical, commandOnly, events }) => isFieldApplicable({
|
|
54207
|
+
return Object.fromEntries(fields.filter(({ canonical, commandOnly, hookTypes, events }) => isFieldApplicable({
|
|
53976
54208
|
commandOnly,
|
|
54209
|
+
hookTypes,
|
|
53977
54210
|
hookType
|
|
53978
54211
|
}) && isEventApplicable({
|
|
53979
54212
|
events,
|
|
@@ -53991,19 +54224,24 @@ function emitPassthroughFields({ def, hookType, eventName, fields, isValid, warn
|
|
|
53991
54224
|
* value into a warning instead of a silent drop.
|
|
53992
54225
|
*/
|
|
53993
54226
|
function importPassthroughFields({ h, hookType, eventName, fields, isValid, describeInvalid, warn }) {
|
|
53994
|
-
const typeApplicable = fields.filter(({ commandOnly }) => isFieldApplicable({
|
|
54227
|
+
const typeApplicable = fields.filter(({ commandOnly, hookTypes }) => isFieldApplicable({
|
|
53995
54228
|
commandOnly,
|
|
54229
|
+
hookTypes,
|
|
53996
54230
|
hookType
|
|
53997
54231
|
}));
|
|
53998
54232
|
const applicable = typeApplicable.filter(({ events }) => isEventApplicable({
|
|
53999
54233
|
events,
|
|
54000
54234
|
eventName
|
|
54001
54235
|
}));
|
|
54002
|
-
const skipped = fields.filter(({ commandOnly }) => !isFieldApplicable({
|
|
54236
|
+
const skipped = fields.filter(({ commandOnly, hookTypes }) => !isFieldApplicable({
|
|
54003
54237
|
commandOnly,
|
|
54238
|
+
hookTypes,
|
|
54004
54239
|
hookType
|
|
54005
54240
|
}));
|
|
54006
|
-
for (const { tool } of skipped) if (h[tool] !== void 0) warn?.(`Dropping "${tool}" from an imported "${hookType}" hook: this tool documents it on
|
|
54241
|
+
for (const { tool, commandOnly, hookTypes } of skipped) if (h[tool] !== void 0) warn?.(`Dropping "${tool}" from an imported "${hookType}" hook: this tool documents it on ${describeDocumentedHookTypes({
|
|
54242
|
+
commandOnly,
|
|
54243
|
+
hookTypes
|
|
54244
|
+
})} hooks only, so it is not imported.`);
|
|
54007
54245
|
for (const { tool, events } of typeApplicable) if (events !== void 0 && !isEventApplicable({
|
|
54008
54246
|
events,
|
|
54009
54247
|
eventName
|
|
@@ -54177,13 +54415,13 @@ function isKeywordFieldApplicable({ spec, hookType, eventName, flags, direction,
|
|
|
54177
54415
|
const field = direction === "generated" ? canonical : tool;
|
|
54178
54416
|
if (!isFieldApplicable({
|
|
54179
54417
|
commandOnly,
|
|
54418
|
+
hookTypes,
|
|
54180
54419
|
hookType
|
|
54181
54420
|
})) {
|
|
54182
|
-
warn?.(`Dropping "${field}" from a "${hookType}" hook on "${eventName}": this tool documents "${tool}" on
|
|
54183
|
-
|
|
54184
|
-
|
|
54185
|
-
|
|
54186
|
-
warn?.(`Dropping "${field}" from a "${hookType}" hook on "${eventName}": this tool documents "${tool}" on ${describeEvents(hookTypes)} hooks only, so it is not ${direction}.`);
|
|
54421
|
+
warn?.(`Dropping "${field}" from a "${hookType}" hook on "${eventName}": this tool documents "${tool}" on ${describeDocumentedHookTypes({
|
|
54422
|
+
commandOnly,
|
|
54423
|
+
hookTypes
|
|
54424
|
+
})} hooks only, so it is not ${direction}.`);
|
|
54187
54425
|
return false;
|
|
54188
54426
|
}
|
|
54189
54427
|
if (events !== void 0 && !events.has(eventName)) {
|
|
@@ -56335,7 +56573,11 @@ const CLAUDE_SPEC = {
|
|
|
56335
56573
|
tool: "onFailure",
|
|
56336
56574
|
trueValue: "block",
|
|
56337
56575
|
falseValue: "continue",
|
|
56338
|
-
hookTypes: /* @__PURE__ */ new Set([
|
|
56576
|
+
hookTypes: /* @__PURE__ */ new Set([
|
|
56577
|
+
"command",
|
|
56578
|
+
"http",
|
|
56579
|
+
"mcp_tool"
|
|
56580
|
+
]),
|
|
56339
56581
|
ignoredEvents: /* @__PURE__ */ new Set([
|
|
56340
56582
|
"stop",
|
|
56341
56583
|
"subagentStop",
|
|
@@ -59130,6 +59372,18 @@ const FACTORYDROID_CONVERTER_CONFIG = {
|
|
|
59130
59372
|
tool: "commandRegex",
|
|
59131
59373
|
valueType: "string",
|
|
59132
59374
|
subdividesGroup: true
|
|
59375
|
+
}],
|
|
59376
|
+
keywordPassthroughFields: [{
|
|
59377
|
+
canonical: "failClosed",
|
|
59378
|
+
tool: "onFailure",
|
|
59379
|
+
trueValue: "block",
|
|
59380
|
+
falseValue: "continue",
|
|
59381
|
+
events: /* @__PURE__ */ new Set([
|
|
59382
|
+
"preToolUse",
|
|
59383
|
+
"postToolUse",
|
|
59384
|
+
"beforeSubmitPrompt",
|
|
59385
|
+
"preCompact"
|
|
59386
|
+
])
|
|
59133
59387
|
}]
|
|
59134
59388
|
};
|
|
59135
59389
|
/** Droid's nine event names, the keys a standalone `hooks.json` is made of. */
|
|
@@ -59635,7 +59889,7 @@ function canonicalToHermesHooks({ config, toolOverrideHooks, logger }) {
|
|
|
59635
59889
|
for (const [nativeEvent, definitions] of Object.entries(toolOverrideHooks ?? {})) {
|
|
59636
59890
|
if (HERMESAGENT_CANONICAL_EVENTS.has(nativeEvent)) continue;
|
|
59637
59891
|
if (HERMESAGENT_SHELL_UNSUPPORTED_EVENTS.has(nativeEvent)) logger?.warn(`Hermes hook event "${nativeEvent}" is Python-plugin-only; Hermes Agent refuses it for shell hooks, so the generated entry will never run.`);
|
|
59638
|
-
else if (!HERMESAGENT_NATIVE_EVENTS.has(nativeEvent)) logger?.warn(`Hermes hook event "${nativeEvent}" is not documented by Hermes Agent v0.
|
|
59892
|
+
else if (!HERMESAGENT_NATIVE_EVENTS.has(nativeEvent)) logger?.warn(`Hermes hook event "${nativeEvent}" is not documented by Hermes Agent v0.23.2; preserving it for forward compatibility.`);
|
|
59639
59893
|
setHermesHookEntries({
|
|
59640
59894
|
result,
|
|
59641
59895
|
event: nativeEvent,
|
|
@@ -60111,7 +60365,8 @@ const BLOCKING_HOOKS = new Set(Object.keys(NAMED_HOOK_MATCHER_SUBJECTS).filter((
|
|
|
60111
60365
|
* 5 minutes). Ordinary commands write to the host's stdout and stderr, as Bun
|
|
60112
60366
|
* Shell echoed them; a `preToolUse` command's are read, 1 MiB each kept (more
|
|
60113
60367
|
* stdout denies; on the Bun Shell fallback the whole output is buffered before
|
|
60114
|
-
* that check)
|
|
60368
|
+
* that check), and a `sessionStart` command's stdout is read the same way while
|
|
60369
|
+
* its stderr goes to the host's (after the command, on Bun Shell). Output
|
|
60115
60370
|
* pipes a background process keeps open are read for 1 s after the command
|
|
60116
60371
|
* exits; what arrived by then is kept, and the reads are then cancelled, as
|
|
60117
60372
|
* they are at a timeout. The OpenCode 1.x-style `event` hooks (`inProcess`)
|
|
@@ -60259,15 +60514,18 @@ function buildRunHelperLinesFor(cwdExpression) {
|
|
|
60259
60514
|
" const timeout = () => new Promise((resolve) => (timer = setTimeout(resolve, seconds * 1000, null)));",
|
|
60260
60515
|
" if (inProcess || !(await __rulesyncCanExec)) {",
|
|
60261
60516
|
` const run = Bun.$\`echo \${input} | \${{ raw: command }}\`.cwd(${cwdExpression}).nothrow();`,
|
|
60262
|
-
"
|
|
60263
|
-
"
|
|
60517
|
+
" // A sessionStart command's stderr reaches the host when it ends, even after its timeout.",
|
|
60518
|
+
" const finished = echo === true ? run : run.quiet().then((done) => (echo && process.stderr.write(done.stderr), done));",
|
|
60519
|
+
" const result = await Promise.race([finished, timeout()]).finally(() => clearTimeout(timer));",
|
|
60520
|
+
" if (!result || echo === true) return result && { exitCode: result.exitCode };",
|
|
60264
60521
|
" const { exitCode, stdout, stderr } = result;",
|
|
60265
60522
|
" return { exitCode, stdout: stdout.toString(), stderr: stderr.toString(), overflow: stdout.length > 1048576 };",
|
|
60266
60523
|
" }",
|
|
60267
|
-
" // An ordinary command writes to the host's stdout and stderr; a preToolUse one is read
|
|
60268
|
-
"
|
|
60269
|
-
` const proc = ${spawn("\"export BUN_BE_BUN=\\n\" + command", "new TextEncoder().encode(input + \"\\n\")", "
|
|
60270
|
-
" const
|
|
60524
|
+
" // An ordinary command writes to the host's stdout and stderr; a preToolUse one is read, and",
|
|
60525
|
+
" // a sessionStart one (`echo: \"stderr\"`) has its stdout read.",
|
|
60526
|
+
` const proc = ${spawn("\"export BUN_BE_BUN=\\n\" + command", "new TextEncoder().encode(input + \"\\n\")", "echo === true ? \"inherit\" : \"pipe\"", "echo ? \"inherit\" : \"pipe\"")};`,
|
|
60527
|
+
" const stdout = echo === true ? undefined : __rulesyncRead(proc.stdout);",
|
|
60528
|
+
" const stderr = echo ? undefined : __rulesyncRead(proc.stderr);",
|
|
60271
60529
|
" const exitCode = await Promise.race([proc.exited, timeout()]).finally(() => clearTimeout(timer));",
|
|
60272
60530
|
" if (exitCode === null) {",
|
|
60273
60531
|
" stdout?.stop(), stderr?.stop();",
|
|
@@ -60275,15 +60533,15 @@ function buildRunHelperLinesFor(cwdExpression) {
|
|
|
60275
60533
|
" else __rulesyncKillTree(proc);",
|
|
60276
60534
|
" return null;",
|
|
60277
60535
|
" }",
|
|
60278
|
-
" if (echo) return { exitCode };",
|
|
60279
|
-
" await Promise.race([Promise.all([stdout.done, stderr
|
|
60280
|
-
" stdout.stop(), stderr
|
|
60281
|
-
" return { exitCode, stdout: stdout.text(), stderr: stderr
|
|
60536
|
+
" if (echo === true) return { exitCode };",
|
|
60537
|
+
" await Promise.race([Promise.all([stdout.done, stderr?.done]), Bun.sleep(1000)]);",
|
|
60538
|
+
" stdout.stop(), stderr?.stop();",
|
|
60539
|
+
" return { exitCode, stdout: stdout.text(), stderr: stderr?.text() ?? \"\", overflow: stdout.overflow() };",
|
|
60282
60540
|
"};",
|
|
60283
|
-
"const __rulesyncRunHook = async ({ label, command, input, blocking, seconds, inProcess = false }) => {",
|
|
60541
|
+
"const __rulesyncRunHook = async ({ label, command, input, blocking, seconds, inProcess = false, context = false }) => {",
|
|
60284
60542
|
" let result;",
|
|
60285
60543
|
" try {",
|
|
60286
|
-
" result = await __rulesyncRunCommand({ command, input, seconds, inProcess, echo: true });",
|
|
60544
|
+
" result = await __rulesyncRunCommand({ command, input, seconds, inProcess, echo: context ? \"stderr\" : true });",
|
|
60287
60545
|
" } catch (error) {",
|
|
60288
60546
|
" if (blocking) throw error;",
|
|
60289
60547
|
" console.error(\"[rulesync-hooks] \" + label + \" hook failed:\", error);",
|
|
@@ -60294,7 +60552,7 @@ function buildRunHelperLinesFor(cwdExpression) {
|
|
|
60294
60552
|
" if (blocking) throw new Error(message);",
|
|
60295
60553
|
" return console.error(message);",
|
|
60296
60554
|
" }",
|
|
60297
|
-
" if (result.exitCode === 0) return;",
|
|
60555
|
+
" if (result.exitCode === 0) return result;",
|
|
60298
60556
|
" const message = \"[rulesync-hooks] \" + label + \" hook exited with code \" + result.exitCode;",
|
|
60299
60557
|
" if (blocking) throw new Error(message);",
|
|
60300
60558
|
" console.error(message);",
|
|
@@ -60362,6 +60620,85 @@ const PRE_TOOL_USE_RESULT_HELPER_LINES = [
|
|
|
60362
60620
|
" );",
|
|
60363
60621
|
"};"
|
|
60364
60622
|
];
|
|
60623
|
+
/**
|
|
60624
|
+
* Helpers the generated plugin defines when a `sessionStart` handler is
|
|
60625
|
+
* present, so the command's stdout reaches the model as Claude Code's
|
|
60626
|
+
* `SessionStart` stdout does:
|
|
60627
|
+
* - `__rulesyncSessionStart(sessionID, run)` runs a session's `sessionStart`
|
|
60628
|
+
* commands (`run` pushes each command's result) and keeps the pending context
|
|
60629
|
+
* for that session. It always settles, since every command is bounded by its
|
|
60630
|
+
* timeout.
|
|
60631
|
+
* - `__rulesyncSessionContext(sessionID)` waits for that context, which the
|
|
60632
|
+
* host's system-prompt hook then adds to each model request of the session.
|
|
60633
|
+
*
|
|
60634
|
+
* A command's context is its stdout on exit code 0, or the
|
|
60635
|
+
* `hookSpecificOutput.additionalContext` string of a JSON object it prints,
|
|
60636
|
+
* trimmed and capped at Claude Code's 10,000 characters; more than 1 MiB of
|
|
60637
|
+
* stdout is logged and ignored. Only sessions whose context is not empty are
|
|
60638
|
+
* kept, the 100 whose context was used or became ready most recently, and a
|
|
60639
|
+
* deleted session is dropped.
|
|
60640
|
+
*/
|
|
60641
|
+
const SESSION_CONTEXT_HELPER_LINES = [
|
|
60642
|
+
"const __rulesyncSessionContexts = new Map();",
|
|
60643
|
+
"const __rulesyncKept = new WeakSet();",
|
|
60644
|
+
"const __rulesyncContextOf = (result) => {",
|
|
60645
|
+
" if (typeof result?.stdout !== \"string\") return \"\";",
|
|
60646
|
+
" if (result.overflow) {",
|
|
60647
|
+
" console.error(\"[rulesync-hooks] sessionStart hook wrote more than 1 MiB to stdout; it is ignored\");",
|
|
60648
|
+
" return \"\";",
|
|
60649
|
+
" }",
|
|
60650
|
+
" let text = result.stdout;",
|
|
60651
|
+
" try {",
|
|
60652
|
+
" const parsed = JSON.parse(text);",
|
|
60653
|
+
" // Like Claude Code, only a JSON object counts as JSON output; anything else is plain text.",
|
|
60654
|
+
" if (parsed && typeof parsed === \"object\" && !Array.isArray(parsed)) text = parsed.hookSpecificOutput?.additionalContext;",
|
|
60655
|
+
" } catch {}",
|
|
60656
|
+
" return typeof text === \"string\" ? text.trim().slice(0, 10000) : \"\";",
|
|
60657
|
+
"};",
|
|
60658
|
+
"const __rulesyncSessionStart = (sessionID, run) => {",
|
|
60659
|
+
" const results = [];",
|
|
60660
|
+
" const pending = run(results)",
|
|
60661
|
+
" .catch(() => {})",
|
|
60662
|
+
" .then(() => results.map(__rulesyncContextOf).filter(Boolean).join(\"\\n\\n\"));",
|
|
60663
|
+
" if (typeof sessionID === \"string\") {",
|
|
60664
|
+
" __rulesyncSessionContexts.delete(sessionID);",
|
|
60665
|
+
" __rulesyncSessionContexts.set(sessionID, pending);",
|
|
60666
|
+
" // Only a non-empty context is kept, and only it counts towards the 100: a running",
|
|
60667
|
+
" // or empty one never evicts another session's context.",
|
|
60668
|
+
" pending.then((context) => {",
|
|
60669
|
+
" if (__rulesyncSessionContexts.get(sessionID) !== pending) return;",
|
|
60670
|
+
" if (!context) return void __rulesyncSessionContexts.delete(sessionID);",
|
|
60671
|
+
" __rulesyncKept.add(pending);",
|
|
60672
|
+
" // Evict in completion order: a context counts as used once it is ready.",
|
|
60673
|
+
" __rulesyncSessionContexts.delete(sessionID);",
|
|
60674
|
+
" __rulesyncSessionContexts.set(sessionID, pending);",
|
|
60675
|
+
" const kept = [...__rulesyncSessionContexts].filter(([, entry]) => __rulesyncKept.has(entry));",
|
|
60676
|
+
" if (kept.length > 100) __rulesyncSessionContexts.delete(kept[0][0]);",
|
|
60677
|
+
" });",
|
|
60678
|
+
" }",
|
|
60679
|
+
" return pending;",
|
|
60680
|
+
"};",
|
|
60681
|
+
"const __rulesyncSessionContext = async (sessionID) => {",
|
|
60682
|
+
" const pending = __rulesyncSessionContexts.get(sessionID);",
|
|
60683
|
+
" if (!pending) return \"\";",
|
|
60684
|
+
" __rulesyncSessionContexts.delete(sessionID);",
|
|
60685
|
+
" __rulesyncSessionContexts.set(sessionID, pending);",
|
|
60686
|
+
" return pending;",
|
|
60687
|
+
"};"
|
|
60688
|
+
];
|
|
60689
|
+
/**
|
|
60690
|
+
* The statements of a `sessionStart` group, run through `__rulesyncSessionStart`.
|
|
60691
|
+
* `__rulesyncSessionStart` registers the session's pending context before its
|
|
60692
|
+
* first `await`, so `"void"` (used by the serial V2 event loop) registers it
|
|
60693
|
+
* as soon as the event is read without waiting for the commands.
|
|
60694
|
+
*/
|
|
60695
|
+
function wrapSessionStartLines(sessionIdExpression, statements, operator = "await") {
|
|
60696
|
+
return [
|
|
60697
|
+
`${operator} __rulesyncSessionStart(${sessionIdExpression}, async (__rulesyncResults) => {`,
|
|
60698
|
+
...statements.map((line) => ` ${line}`),
|
|
60699
|
+
"});"
|
|
60700
|
+
];
|
|
60701
|
+
}
|
|
60365
60702
|
function escapeForTemplateLiteral(command) {
|
|
60366
60703
|
return command.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$\{/g, "\\${");
|
|
60367
60704
|
}
|
|
@@ -60422,6 +60759,14 @@ function warnIgnoredFailClosed({ config, supportedEvents, toolConfigKey, logger
|
|
|
60422
60759
|
}
|
|
60423
60760
|
}
|
|
60424
60761
|
}
|
|
60762
|
+
/** Whether any handler is a `sessionStart` one, whose stdout becomes session context. */
|
|
60763
|
+
function usesSessionContext(handlers) {
|
|
60764
|
+
return handlers.some((handler) => handler.context);
|
|
60765
|
+
}
|
|
60766
|
+
/** The handler fields a canonical event's `sessionStart`-ness adds. */
|
|
60767
|
+
function sessionContextExtrasFor(canonicalEvent) {
|
|
60768
|
+
return canonicalEvent === "sessionStart" ? { context: true } : {};
|
|
60769
|
+
}
|
|
60425
60770
|
/** The per-canonical-event gates and payload every handler of it carries. */
|
|
60426
60771
|
function handlerExtrasFor(canonicalEvent) {
|
|
60427
60772
|
const shellGate = SHELL_EVENT_TOOL_GATES[canonicalEvent];
|
|
@@ -60431,7 +60776,8 @@ function handlerExtrasFor(canonicalEvent) {
|
|
|
60431
60776
|
event: canonicalEvent,
|
|
60432
60777
|
...shellGate ? { toolGate: shellGate.tool } : {},
|
|
60433
60778
|
...propertyGate ? { propertyGate } : {},
|
|
60434
|
-
...payload ? { payload } : {}
|
|
60779
|
+
...payload ? { payload } : {},
|
|
60780
|
+
...sessionContextExtrasFor(canonicalEvent)
|
|
60435
60781
|
};
|
|
60436
60782
|
}
|
|
60437
60783
|
/**
|
|
@@ -60473,22 +60819,22 @@ function buildGenericEventBodyLines(genericEventHandlers) {
|
|
|
60473
60819
|
const bodyLines = [];
|
|
60474
60820
|
if (Object.keys(genericEventHandlers).length === 0) return bodyLines;
|
|
60475
60821
|
bodyLines.push(" event: async ({ event }) => {");
|
|
60822
|
+
if (Object.values(genericEventHandlers).some(usesSessionContext)) bodyLines.push(` if (event.type === "session.deleted") __rulesyncSessionContexts.delete(${V1_SESSION_ID_EXPRESSION});`);
|
|
60476
60823
|
let isFirst = true;
|
|
60477
60824
|
for (const [eventName, handlers] of Object.entries(genericEventHandlers)) {
|
|
60478
60825
|
bodyLines.push(` ${isFirst ? "if" : "else if"} (event.type === "${eventName}") {`);
|
|
60479
60826
|
isFirst = false;
|
|
60480
|
-
|
|
60827
|
+
const statements = buildPayloadClosureLines({
|
|
60481
60828
|
handlers,
|
|
60482
60829
|
cwdExpression: V1_CWD_EXPRESSION
|
|
60483
|
-
})
|
|
60830
|
+
});
|
|
60484
60831
|
for (const handler of handlers) {
|
|
60485
60832
|
const runStatement = buildRunStatement(handler);
|
|
60486
|
-
if (handler.propertyGate) {
|
|
60487
|
-
|
|
60488
|
-
bodyLines.push(` ${runStatement}`);
|
|
60489
|
-
bodyLines.push(" }");
|
|
60490
|
-
} else bodyLines.push(` ${runStatement}`);
|
|
60833
|
+
if (handler.propertyGate) statements.push(`if (${handler.propertyGate}) {`, ` ${runStatement}`, "}");
|
|
60834
|
+
else statements.push(runStatement);
|
|
60491
60835
|
}
|
|
60836
|
+
const lines = usesSessionContext(handlers) ? wrapSessionStartLines(V1_SESSION_ID_EXPRESSION, statements) : statements;
|
|
60837
|
+
bodyLines.push(...lines.map((line) => ` ${line}`));
|
|
60492
60838
|
bodyLines.push(" }");
|
|
60493
60839
|
}
|
|
60494
60840
|
bodyLines.push(" },");
|
|
@@ -60499,6 +60845,19 @@ function stdinPayloadVariable(stdinEvent) {
|
|
|
60499
60845
|
}
|
|
60500
60846
|
/** The `cwd` a V1 payload reports: the session directory, else the process's. */
|
|
60501
60847
|
const V1_CWD_EXPRESSION = "directory ?? process.cwd()";
|
|
60848
|
+
/** The session a V1 `session.created` / `session.deleted` event is about. */
|
|
60849
|
+
const V1_SESSION_ID_EXPRESSION = "event.properties?.info?.id";
|
|
60850
|
+
/**
|
|
60851
|
+
* The V1 named hook that adds a session's `sessionStart` context to the system
|
|
60852
|
+
* prompt of each of its model requests. OpenCode 1.x, Kilo and MiMo Code all
|
|
60853
|
+
* call it with the request's `sessionID`.
|
|
60854
|
+
*/
|
|
60855
|
+
const V1_SYSTEM_TRANSFORM_LINES = [
|
|
60856
|
+
" \"experimental.chat.system.transform\": async (input, output) => {",
|
|
60857
|
+
" const context = await __rulesyncSessionContext(input?.sessionID);",
|
|
60858
|
+
" if (context && Array.isArray(output?.system)) output.system.push(context);",
|
|
60859
|
+
" },"
|
|
60860
|
+
];
|
|
60502
60861
|
/** Lazily serialized closures for the payloads the handlers use (internal tables only). */
|
|
60503
60862
|
function buildPayloadClosureLines({ handlers, cwdExpression }) {
|
|
60504
60863
|
const payloads = /* @__PURE__ */ new Map();
|
|
@@ -60526,20 +60885,27 @@ function buildRunStatement(handler) {
|
|
|
60526
60885
|
const failClosed = handler.failClosed === void 0 ? "" : `, ${handler.failClosed}`;
|
|
60527
60886
|
return `${PRE_TOOL_USE_RESULT_HELPER}(await __rulesyncRunCommand({ command: ${command}, input: ${input}, seconds: ${handler.timeout} })${failClosed});`;
|
|
60528
60887
|
}
|
|
60529
|
-
|
|
60888
|
+
const run = `await __rulesyncRunHook({ ${[
|
|
60530
60889
|
`label: ${JSON.stringify(handler.event)}`,
|
|
60531
60890
|
`command: ${command}`,
|
|
60532
60891
|
`input: ${input}`,
|
|
60533
60892
|
`blocking: ${handler.blocking}`,
|
|
60534
60893
|
`seconds: ${handler.timeout}`,
|
|
60535
|
-
...handler.inProcess ? ["inProcess: true"] : []
|
|
60536
|
-
|
|
60894
|
+
...handler.inProcess ? ["inProcess: true"] : [],
|
|
60895
|
+
...handler.context ? ["context: true"] : []
|
|
60896
|
+
].join(", ")} })`;
|
|
60897
|
+
return handler.context ? `__rulesyncResults.push(${run});` : `${run};`;
|
|
60537
60898
|
}
|
|
60538
60899
|
/** The helpers a plugin body defines before its handlers, run in `cwdExpression`. */
|
|
60539
60900
|
function buildRunHelperLines({ handlers, cwdExpression }) {
|
|
60540
60901
|
if (handlers.length === 0) return [];
|
|
60541
60902
|
const usesPreToolUse = handlers.some((handler) => handler.payload?.name === "PreToolUse");
|
|
60542
|
-
|
|
60903
|
+
const usesContext = usesSessionContext(handlers);
|
|
60904
|
+
return [
|
|
60905
|
+
...buildRunHelperLinesFor(cwdExpression),
|
|
60906
|
+
...usesPreToolUse ? ["", ...PRE_TOOL_USE_RESULT_HELPER_LINES] : [],
|
|
60907
|
+
...usesContext ? ["", ...SESSION_CONTEXT_HELPER_LINES] : []
|
|
60908
|
+
];
|
|
60543
60909
|
}
|
|
60544
60910
|
/** Emit the named (`tool.execute.*`) handler blocks. */
|
|
60545
60911
|
function buildNamedEventBodyLines(namedEventHandlers) {
|
|
@@ -60613,7 +60979,12 @@ function generateOpencodeStylePluginCode(config, supportedEvents, toolConfigKey,
|
|
|
60613
60979
|
namedEventHandlers,
|
|
60614
60980
|
genericEventHandlers
|
|
60615
60981
|
});
|
|
60616
|
-
const
|
|
60982
|
+
const usesContext = Object.values(genericEventHandlers).some(usesSessionContext);
|
|
60983
|
+
const bodyLines = [
|
|
60984
|
+
...buildGenericEventBodyLines(genericEventHandlers),
|
|
60985
|
+
...buildNamedEventBodyLines(namedEventHandlers),
|
|
60986
|
+
...usesContext ? V1_SYSTEM_TRANSFORM_LINES : []
|
|
60987
|
+
];
|
|
60617
60988
|
return wrapInExportShape({
|
|
60618
60989
|
preambleLines: buildRunHelperLines({
|
|
60619
60990
|
handlers: [...Object.values(namedEventHandlers), ...Object.values(genericEventHandlers)].flat(),
|
|
@@ -60926,6 +61297,37 @@ const KiroIdeHooksFileSchema = zod_mini.z.looseObject({
|
|
|
60926
61297
|
hooks: zod_mini.z.optional(zod_mini.z.array(KiroIdeHookEntrySchema))
|
|
60927
61298
|
});
|
|
60928
61299
|
/**
|
|
61300
|
+
* Triggers on which Kiro runs only `command` actions.
|
|
61301
|
+
* @see https://kiro.dev/docs/hooks/types/#permission-request
|
|
61302
|
+
*/
|
|
61303
|
+
const KIRO_COMMAND_ONLY_TRIGGERS = /* @__PURE__ */ new Set(["PermissionRequest"]);
|
|
61304
|
+
/**
|
|
61305
|
+
* Whether an imported entry is an `agent` action on a command-only trigger
|
|
61306
|
+
* (Kiro also accepts the camelCase `permissionRequest` spelling). Kiro never
|
|
61307
|
+
* runs such a hook, so importing it would hand other targets an LLM
|
|
61308
|
+
* permission hook the user never had in effect.
|
|
61309
|
+
*/
|
|
61310
|
+
function isAgentActionOnCommandOnlyTrigger(entry) {
|
|
61311
|
+
if (entry.action?.type !== "agent" || entry.trigger === void 0) return false;
|
|
61312
|
+
const trigger = lookupOwn({
|
|
61313
|
+
record: CANONICAL_TO_KIRO_IDE_EVENT_NAMES,
|
|
61314
|
+
key: entry.trigger
|
|
61315
|
+
}) ?? entry.trigger;
|
|
61316
|
+
return KIRO_COMMAND_ONLY_TRIGGERS.has(trigger);
|
|
61317
|
+
}
|
|
61318
|
+
/**
|
|
61319
|
+
* Drop `prompt` definitions on a {@link KIRO_COMMAND_ONLY_TRIGGERS} trigger with
|
|
61320
|
+
* a warning, rather than writing an `agent` action Kiro never runs.
|
|
61321
|
+
*/
|
|
61322
|
+
function dropPromptHooksOnCommandOnlyTrigger(trigger, definitions, logger) {
|
|
61323
|
+
if (!KIRO_COMMAND_ONLY_TRIGGERS.has(trigger)) return definitions;
|
|
61324
|
+
return definitions.filter((def) => {
|
|
61325
|
+
if (def.type !== "prompt") return true;
|
|
61326
|
+
logger?.warn(`Skipped a prompt hook on Kiro's "${trigger}" trigger: Kiro runs only command actions on it.`);
|
|
61327
|
+
return false;
|
|
61328
|
+
});
|
|
61329
|
+
}
|
|
61330
|
+
/**
|
|
60929
61331
|
* Build the Kiro IDE hook entries for a single canonical event's definitions.
|
|
60930
61332
|
*
|
|
60931
61333
|
* `command`-type definitions become `{ type: "command", command }` actions and
|
|
@@ -60980,7 +61382,7 @@ const KIRO_HOOKS_OVERRIDE_KEY = "kiro";
|
|
|
60980
61382
|
* that is actually read.
|
|
60981
61383
|
*/
|
|
60982
61384
|
const KIRO_HOOKS_IGNORED_OVERRIDE_KEYS = ["kiro-ide", "kiro-cli"];
|
|
60983
|
-
function canonicalToKiroIdeHooks(config) {
|
|
61385
|
+
function canonicalToKiroIdeHooks(config, logger) {
|
|
60984
61386
|
const kiroIdeSupported = new Set(KIRO_IDE_HOOK_EVENTS);
|
|
60985
61387
|
const sharedHooks = {};
|
|
60986
61388
|
for (const [event, defs] of Object.entries(config.hooks)) if (kiroIdeSupported.has(event)) sharedHooks[event] = defs;
|
|
@@ -60997,7 +61399,7 @@ function canonicalToKiroIdeHooks(config) {
|
|
|
60997
61399
|
record: KIRO_LEGACY_TO_KIRO_IDE_TRIGGER_NAMES,
|
|
60998
61400
|
key: eventName
|
|
60999
61401
|
}) ?? eventName;
|
|
61000
|
-
entries.push(...buildKiroIdeEntriesForEvent(trigger, definitions));
|
|
61402
|
+
entries.push(...buildKiroIdeEntriesForEvent(trigger, dropPromptHooksOnCommandOnlyTrigger(trigger, definitions, logger)));
|
|
61001
61403
|
}
|
|
61002
61404
|
return entries;
|
|
61003
61405
|
}
|
|
@@ -61009,25 +61411,35 @@ function copyOptionalHookFields({ entry, def }) {
|
|
|
61009
61411
|
if (entry.enabled === false) def.enabled = false;
|
|
61010
61412
|
if (entry.confirm !== void 0 && entry.confirm !== null) def.confirm = omitPrototypePollutionKeysDeep(entry.confirm);
|
|
61011
61413
|
}
|
|
61012
|
-
|
|
61414
|
+
/**
|
|
61415
|
+
* The canonical `type` plus `command` / `prompt` of an imported Kiro action, or
|
|
61416
|
+
* `undefined` when the action carries nothing to run.
|
|
61417
|
+
*/
|
|
61418
|
+
function toCanonicalAction(action) {
|
|
61419
|
+
if (action.type === "command") return action.command ? {
|
|
61420
|
+
type: "command",
|
|
61421
|
+
command: action.command
|
|
61422
|
+
} : void 0;
|
|
61423
|
+
return action.prompt ? {
|
|
61424
|
+
type: "prompt",
|
|
61425
|
+
prompt: action.prompt
|
|
61426
|
+
} : void 0;
|
|
61427
|
+
}
|
|
61428
|
+
function kiroIdeHooksToCanonical(entries, logger) {
|
|
61013
61429
|
const canonical = {};
|
|
61014
61430
|
for (const entry of entries) {
|
|
61015
61431
|
if (entry.trigger === void 0 || entry.action === void 0) continue;
|
|
61432
|
+
if (isAgentActionOnCommandOnlyTrigger(entry)) {
|
|
61433
|
+
logger?.warn(`Skipped an agent hook on Kiro's "${entry.trigger}" trigger: Kiro runs only command actions on it.`);
|
|
61434
|
+
continue;
|
|
61435
|
+
}
|
|
61016
61436
|
const eventName = lookupOwn({
|
|
61017
61437
|
record: KIRO_IDE_TO_CANONICAL_EVENT_NAMES,
|
|
61018
61438
|
key: entry.trigger
|
|
61019
61439
|
}) ?? entry.trigger;
|
|
61020
61440
|
if (isPrototypePollutionKey(eventName)) continue;
|
|
61021
|
-
const def =
|
|
61022
|
-
if (
|
|
61023
|
-
if (!entry.action.command) continue;
|
|
61024
|
-
def.type = "command";
|
|
61025
|
-
def.command = entry.action.command;
|
|
61026
|
-
} else {
|
|
61027
|
-
if (!entry.action.prompt) continue;
|
|
61028
|
-
def.type = "prompt";
|
|
61029
|
-
def.prompt = entry.action.prompt;
|
|
61030
|
-
}
|
|
61441
|
+
const def = toCanonicalAction(entry.action);
|
|
61442
|
+
if (def === void 0) continue;
|
|
61031
61443
|
if (entry.name !== void 0 && entry.name !== null) def.name = entry.name;
|
|
61032
61444
|
if (entry.description !== void 0 && entry.description !== null) def.description = entry.description;
|
|
61033
61445
|
if (entry.matcher !== void 0 && entry.matcher !== null && entry.matcher !== "") def.matcher = entry.matcher;
|
|
@@ -61093,7 +61505,7 @@ var KiroIdeHooks = class extends ToolHooks {
|
|
|
61093
61505
|
if (config[ignoredKey]?.hooks === void 0) continue;
|
|
61094
61506
|
logger?.warn(`The "${ignoredKey}.hooks" block in ${(0, node_path.join)(rulesyncHooks.getRelativeDirPath(), rulesyncHooks.getRelativeFilePath())} is ignored. Author it under the "${KIRO_HOOKS_OVERRIDE_KEY}.hooks" key instead: the Kiro IDE and Kiro CLI targets write the same hooks file, so they read one shared block.`);
|
|
61095
61507
|
}
|
|
61096
|
-
const hooks = canonicalToKiroIdeHooks(config);
|
|
61508
|
+
const hooks = canonicalToKiroIdeHooks(config, logger);
|
|
61097
61509
|
const fileContent = JSON.stringify({
|
|
61098
61510
|
version: "v1",
|
|
61099
61511
|
hooks
|
|
@@ -61110,7 +61522,7 @@ var KiroIdeHooks = class extends ToolHooks {
|
|
|
61110
61522
|
const hooks = kiroIdeHooksToCanonical(this.parseFileContentOrThrow({
|
|
61111
61523
|
displayName: "Kiro IDE",
|
|
61112
61524
|
parse: (fileContent) => KiroIdeHooksFileSchema.parse(JSON.parse(fileContent))
|
|
61113
|
-
}).hooks ?? []);
|
|
61525
|
+
}).hooks ?? [], logger);
|
|
61114
61526
|
return this.toRulesyncHooksDefault({ fileContent: JSON.stringify(buildImportedHooksConfig({
|
|
61115
61527
|
logger,
|
|
61116
61528
|
hooks,
|
|
@@ -61542,6 +61954,27 @@ const TOOL_MATCHER_HELPER_LINES = [
|
|
|
61542
61954
|
];
|
|
61543
61955
|
/** Hook points whose `matcher` is tested against the tool name. */
|
|
61544
61956
|
const OPENCODE_V2_MATCHABLE_HOOKS = /* @__PURE__ */ new Set(["tool:execute.before", "tool:execute.after"]);
|
|
61957
|
+
/** The session a V2 `session.created` / `session.deleted` event is about. */
|
|
61958
|
+
const V2_SESSION_ID_EXPRESSION = "event.data?.sessionID";
|
|
61959
|
+
/**
|
|
61960
|
+
* The `session:context` registration that adds a session's `sessionStart`
|
|
61961
|
+
* context to the system prompt of each of its agent-loop model requests. A
|
|
61962
|
+
* host that cannot register it (no `ctx.session.hook`, or no `context` hook
|
|
61963
|
+
* point) gets a logged error instead of a setup throw, so the plugin's other
|
|
61964
|
+
* hooks, `preToolUse` guards included, still load.
|
|
61965
|
+
*/
|
|
61966
|
+
const SESSION_CONTEXT_HOOK_LINES = [
|
|
61967
|
+
"try {",
|
|
61968
|
+
" __rulesyncRegistrations.push(",
|
|
61969
|
+
" await ctx.session.hook(\"context\", async (event) => {",
|
|
61970
|
+
" const context = await __rulesyncSessionContext(event?.sessionID);",
|
|
61971
|
+
" if (context && Array.isArray(event?.system)) event.system.push({ type: \"text\", text: context });",
|
|
61972
|
+
" }),",
|
|
61973
|
+
" );",
|
|
61974
|
+
"} catch (error) {",
|
|
61975
|
+
" console.error(\"[rulesync-hooks] could not register the session context hook; sessionStart output does not reach the model:\", error);",
|
|
61976
|
+
"}"
|
|
61977
|
+
];
|
|
61545
61978
|
/** Wrap a statement in the handler's gate and matcher conditions. */
|
|
61546
61979
|
function wrapInConditions(handler, statement, indent) {
|
|
61547
61980
|
const conditions = [];
|
|
@@ -61578,32 +62011,52 @@ function buildHookRegistrationLines(hookPoint, handlers) {
|
|
|
61578
62011
|
* in its own try/catch, so a throw while evaluating its gate or building its
|
|
61579
62012
|
* payload, outside `__rulesyncRunHook`, is logged the same way. The
|
|
61580
62013
|
* subscription passes `types` so the server delivers only the handled events.
|
|
62014
|
+
*
|
|
62015
|
+
* The loop itself never waits for a command, so a slow handler cannot hold back
|
|
62016
|
+
* the events after it: handlers run one after another on
|
|
62017
|
+
* `__rulesyncEventQueue`, in event order, while `sessionStart` starts right
|
|
62018
|
+
* away, outside the queue (so it can overlap other event commands), and its
|
|
62019
|
+
* session's pending context is registered before that session's first model
|
|
62020
|
+
* request asks for it. Handlers still queued at dispose are skipped.
|
|
61581
62021
|
*/
|
|
61582
|
-
function buildEventLoopLines(eventHandlers) {
|
|
62022
|
+
function buildEventLoopLines(eventHandlers, usesContext) {
|
|
61583
62023
|
const lines = [];
|
|
61584
|
-
const
|
|
62024
|
+
const eventTypes = new Set(eventHandlers.keys());
|
|
62025
|
+
if (usesContext) eventTypes.add("session.deleted");
|
|
62026
|
+
const types = [...eventTypes].map((eventType) => JSON.stringify(eventType)).join(", ");
|
|
61585
62027
|
lines.push("const __rulesyncEvents = new AbortController();");
|
|
62028
|
+
lines.push("let __rulesyncEventQueue = Promise.resolve();");
|
|
61586
62029
|
lines.push("void (async () => {");
|
|
61587
62030
|
lines.push(" for await (const event of ctx.event.subscribe({");
|
|
61588
62031
|
lines.push(` types: [${types}],`);
|
|
61589
62032
|
lines.push(" signal: __rulesyncEvents.signal,");
|
|
61590
62033
|
lines.push(" })) {");
|
|
62034
|
+
if (usesContext) lines.push(` if (event.type === "session.deleted") __rulesyncSessionContexts.delete(${V2_SESSION_ID_EXPRESSION});`);
|
|
61591
62035
|
let isFirst = true;
|
|
61592
62036
|
for (const [eventType, handlers] of eventHandlers) {
|
|
61593
62037
|
lines.push(` ${isFirst ? "if" : "} else if"} (event.type === "${eventType}") {`);
|
|
61594
62038
|
isFirst = false;
|
|
61595
|
-
|
|
62039
|
+
const statements = buildPayloadClosureLines({
|
|
61596
62040
|
handlers,
|
|
61597
62041
|
cwdExpression: "directory"
|
|
61598
|
-
})
|
|
62042
|
+
});
|
|
61599
62043
|
for (const handler of handlers) {
|
|
61600
|
-
|
|
61601
|
-
|
|
61602
|
-
|
|
62044
|
+
statements.push("try {");
|
|
62045
|
+
statements.push(...wrapInConditions(handler, buildRunStatement(handler), " "));
|
|
62046
|
+
statements.push("} catch (error) {");
|
|
61603
62047
|
const message = JSON.stringify(`[rulesync-hooks] ${handler.event} hook failed:`);
|
|
61604
|
-
|
|
61605
|
-
|
|
61606
|
-
}
|
|
62048
|
+
statements.push(` console.error(${message}, error);`);
|
|
62049
|
+
statements.push("}");
|
|
62050
|
+
}
|
|
62051
|
+
const body = usesSessionContext(handlers) ? wrapSessionStartLines(V2_SESSION_ID_EXPRESSION, statements, "void") : [
|
|
62052
|
+
"__rulesyncEventQueue = __rulesyncEventQueue",
|
|
62053
|
+
" .then(async () => {",
|
|
62054
|
+
" if (__rulesyncEvents.signal.aborted) return;",
|
|
62055
|
+
...statements.map((line) => ` ${line}`),
|
|
62056
|
+
" })",
|
|
62057
|
+
` .catch((error) => console.error(${JSON.stringify(`[rulesync-hooks] ${eventType} event hook failed:`)}, error));`
|
|
62058
|
+
];
|
|
62059
|
+
lines.push(...body.map((line) => ` ${line}`));
|
|
61607
62060
|
}
|
|
61608
62061
|
lines.push(" }");
|
|
61609
62062
|
lines.push(" }");
|
|
@@ -61634,7 +62087,8 @@ function buildHandlersFor({ canonicalEvent, definitions, target }) {
|
|
|
61634
62087
|
...hookTimingOf(def),
|
|
61635
62088
|
...def.matcher ? { matcher: def.matcher } : {},
|
|
61636
62089
|
...gate ? { gate } : {},
|
|
61637
|
-
...payload ? { payload } : {}
|
|
62090
|
+
...payload ? { payload } : {},
|
|
62091
|
+
...sessionContextExtrasFor(canonicalEvent)
|
|
61638
62092
|
});
|
|
61639
62093
|
}
|
|
61640
62094
|
return handlers;
|
|
@@ -61651,16 +62105,19 @@ function buildSetupBodyLines({ hookHandlers, eventHandlers }) {
|
|
|
61651
62105
|
})
|
|
61652
62106
|
];
|
|
61653
62107
|
if ([...hookHandlers.values()].some((handlers) => handlers.some((handler) => handler.matcher !== void 0))) body.push("", ...TOOL_MATCHER_HELPER_LINES);
|
|
62108
|
+
const usesContext = [...eventHandlers.values()].some(usesSessionContext);
|
|
62109
|
+
const registers = hookHandlers.size > 0 || usesContext;
|
|
61654
62110
|
const cleanup = [];
|
|
61655
|
-
if (
|
|
62111
|
+
if (registers) {
|
|
61656
62112
|
body.push("", "const __rulesyncRegistrations = [];");
|
|
61657
62113
|
for (const [hookPoint, handlers] of hookHandlers) body.push(...buildHookRegistrationLines(hookPoint, handlers));
|
|
62114
|
+
if (usesContext) body.push(...SESSION_CONTEXT_HOOK_LINES);
|
|
61658
62115
|
}
|
|
61659
62116
|
if (eventHandlers.size > 0) {
|
|
61660
|
-
body.push("", ...buildEventLoopLines(eventHandlers));
|
|
62117
|
+
body.push("", ...buildEventLoopLines(eventHandlers, usesContext));
|
|
61661
62118
|
cleanup.push(" __rulesyncEvents.abort();");
|
|
61662
62119
|
}
|
|
61663
|
-
if (
|
|
62120
|
+
if (registers) cleanup.push(" await Promise.all(__rulesyncRegistrations.map((registration) => registration.dispose()));");
|
|
61664
62121
|
body.push("", "return async () => {", ...cleanup, "};");
|
|
61665
62122
|
return body;
|
|
61666
62123
|
}
|
|
@@ -62502,6 +62959,17 @@ var PoolHooks = class PoolHooks extends ToolHooks {
|
|
|
62502
62959
|
}
|
|
62503
62960
|
};
|
|
62504
62961
|
// src/features/hooks/qoder-hooks.ts
|
|
62962
|
+
const QODER_NO_MATCHER_EVENTS = /* @__PURE__ */ new Set([
|
|
62963
|
+
"beforeSubmitPrompt",
|
|
62964
|
+
"stop",
|
|
62965
|
+
"cwdChanged",
|
|
62966
|
+
"worktreeCreate",
|
|
62967
|
+
"worktreeRemove",
|
|
62968
|
+
"taskCreated",
|
|
62969
|
+
"taskCompleted",
|
|
62970
|
+
"teammateIdle"
|
|
62971
|
+
]);
|
|
62972
|
+
const QODER_AGENT_HOOK_TYPES = /* @__PURE__ */ new Set(["agent"]);
|
|
62505
62973
|
const QODER_SPEC = {
|
|
62506
62974
|
displayName: "Qoder",
|
|
62507
62975
|
overrideKey: "qoder",
|
|
@@ -62511,16 +62979,7 @@ const QODER_SPEC = {
|
|
|
62511
62979
|
toolToCanonicalEventNames: QODER_TO_CANONICAL_EVENT_NAMES,
|
|
62512
62980
|
projectDirVar: "$QODER_PROJECT_DIR",
|
|
62513
62981
|
prefixDotRelativeCommandsOnly: true,
|
|
62514
|
-
noMatcherEvents:
|
|
62515
|
-
"beforeSubmitPrompt",
|
|
62516
|
-
"stop",
|
|
62517
|
-
"cwdChanged",
|
|
62518
|
-
"worktreeCreate",
|
|
62519
|
-
"worktreeRemove",
|
|
62520
|
-
"taskCreated",
|
|
62521
|
-
"taskCompleted",
|
|
62522
|
-
"teammateIdle"
|
|
62523
|
-
]),
|
|
62982
|
+
noMatcherEvents: QODER_NO_MATCHER_EVENTS,
|
|
62524
62983
|
supportedHookTypes: /* @__PURE__ */ new Set([
|
|
62525
62984
|
"command",
|
|
62526
62985
|
"http",
|
|
@@ -62577,6 +63036,15 @@ const QODER_SPEC = {
|
|
|
62577
63036
|
canonical: "args",
|
|
62578
63037
|
tool: "args",
|
|
62579
63038
|
commandOnly: true
|
|
63039
|
+
}, {
|
|
63040
|
+
canonical: "tools",
|
|
63041
|
+
tool: "tools",
|
|
63042
|
+
hookTypes: QODER_AGENT_HOOK_TYPES
|
|
63043
|
+
}],
|
|
63044
|
+
numberPassthroughFields: [{
|
|
63045
|
+
canonical: "maxTurns",
|
|
63046
|
+
tool: "maxTurns",
|
|
63047
|
+
hookTypes: QODER_AGENT_HOOK_TYPES
|
|
62580
63048
|
}],
|
|
62581
63049
|
recordPassthroughFields: [{
|
|
62582
63050
|
canonical: "env",
|
|
@@ -72489,12 +72957,22 @@ const MAX_REMOVE_EMPTY_ENTRIES_DEPTH = 32;
|
|
|
72489
72957
|
*/
|
|
72490
72958
|
const GROK_DISABLED_MCP_TOOLS_KEY = "disabled_mcp_tools";
|
|
72491
72959
|
/**
|
|
72960
|
+
* Grok 1.0.88+ runs a command that prints JSON headers at every connect of an
|
|
72961
|
+
* HTTP/SSE server. In `config.toml` the key is `headers_helper`; the camelCase
|
|
72962
|
+
* `headersHelper` (rulesync's canonical spelling) is documented for
|
|
72963
|
+
* `.mcp.json` only, so it is renamed in both directions.
|
|
72964
|
+
* (Grok user guide `07-mcp-servers.md`, "Headers from a command".)
|
|
72965
|
+
*/
|
|
72966
|
+
const CANONICAL_HEADERS_HELPER_KEY = "headersHelper";
|
|
72967
|
+
const GROK_HEADERS_HELPER_KEY = "headers_helper";
|
|
72968
|
+
/**
|
|
72492
72969
|
* Grok Build stores MCP servers in `config.toml` under a `[mcp_servers.<name>]`
|
|
72493
72970
|
* table. Verified against `grok mcp add` (grok 0.2.54): a stdio server emits
|
|
72494
72971
|
* `command`, `args`, `enabled = true`, and an `[mcp_servers.<name>.env]` table;
|
|
72495
72972
|
* a remote server emits `url` and `enabled`. Unlike Codex CLI, Grok uses a
|
|
72496
|
-
* literal `env` table (not the `env_vars` passthrough list), so the
|
|
72497
|
-
*
|
|
72973
|
+
* literal `env` table (not the `env_vars` passthrough list), so the field
|
|
72974
|
+
* renames are `disabled` (rulesync) ↔ `enabled = false` (grok) and
|
|
72975
|
+
* `headersHelper` ↔ `headers_helper`. `disabledTools`
|
|
72498
72976
|
* never lands in the server table: it is lifted into the top-level
|
|
72499
72977
|
* `[disabled_mcp_tools]` table by `buildDisabledMcpTools`.
|
|
72500
72978
|
*/
|
|
@@ -72508,6 +72986,8 @@ function convertToGrokFormat(mcpServers) {
|
|
|
72508
72986
|
if (PROTOTYPE_POLLUTION_KEYS.has(key) || key === "disabledTools") continue;
|
|
72509
72987
|
if (key === "disabled") {
|
|
72510
72988
|
if (value === true) converted["enabled"] = false;
|
|
72989
|
+
} else if (key === CANONICAL_HEADERS_HELPER_KEY) {
|
|
72990
|
+
if (!Object.hasOwn(config, GROK_HEADERS_HELPER_KEY)) converted[GROK_HEADERS_HELPER_KEY] = value;
|
|
72511
72991
|
} else converted[key] = value;
|
|
72512
72992
|
}
|
|
72513
72993
|
result[name] = converted;
|
|
@@ -72523,6 +73003,9 @@ function convertFromGrokFormat(grokMcp) {
|
|
|
72523
73003
|
if (PROTOTYPE_POLLUTION_KEYS.has(key)) continue;
|
|
72524
73004
|
if (key === "enabled") {
|
|
72525
73005
|
if (value === false) converted["disabled"] = true;
|
|
73006
|
+
} else if (key === GROK_HEADERS_HELPER_KEY) converted[CANONICAL_HEADERS_HELPER_KEY] = value;
|
|
73007
|
+
else if (key === CANONICAL_HEADERS_HELPER_KEY) {
|
|
73008
|
+
if (!Object.hasOwn(config, GROK_HEADERS_HELPER_KEY)) converted[CANONICAL_HEADERS_HELPER_KEY] = value;
|
|
72526
73009
|
} else converted[key] = value;
|
|
72527
73010
|
}
|
|
72528
73011
|
result[name] = converted;
|
|
@@ -73638,6 +74121,21 @@ function fromKiroMcpServers(servers) {
|
|
|
73638
74121
|
}];
|
|
73639
74122
|
}));
|
|
73640
74123
|
}
|
|
74124
|
+
/**
|
|
74125
|
+
* Parse an existing user-level `~/.kiro/settings/mcp.json` so a global generate
|
|
74126
|
+
* can merge into it. An unparseable file is refused instead of overwritten:
|
|
74127
|
+
* it is unversioned, so replacing it would lose whatever the user had there.
|
|
74128
|
+
*/
|
|
74129
|
+
function parseExistingKiroMcpConfig(fileContent, configPath) {
|
|
74130
|
+
let parsed;
|
|
74131
|
+
try {
|
|
74132
|
+
parsed = JSON.parse(fileContent);
|
|
74133
|
+
} catch (error) {
|
|
74134
|
+
throw new Error(`Failed to parse Kiro MCP config at ${configPath}: ${formatError(error)}`, { cause: error });
|
|
74135
|
+
}
|
|
74136
|
+
if (!isPlainObject(parsed)) throw new Error(`Failed to parse Kiro MCP config at ${configPath}: expected a JSON object`);
|
|
74137
|
+
return parsed;
|
|
74138
|
+
}
|
|
73641
74139
|
var KiroMcp = class KiroMcp extends ToolMcp {
|
|
73642
74140
|
json;
|
|
73643
74141
|
constructor(params) {
|
|
@@ -73647,13 +74145,26 @@ var KiroMcp = class KiroMcp extends ToolMcp {
|
|
|
73647
74145
|
getJson() {
|
|
73648
74146
|
return this.json;
|
|
73649
74147
|
}
|
|
74148
|
+
/**
|
|
74149
|
+
* The user-level `~/.kiro/settings/mcp.json` also holds settings rulesync
|
|
74150
|
+
* does not manage (such as the top-level `identityProvider` block for
|
|
74151
|
+
* organization sign-in, which Kiro reads only from this file), so it is never
|
|
74152
|
+
* deleted in global mode. The project file is rulesync-managed and may be.
|
|
74153
|
+
* The sweep has no in-place retraction, so a global `--delete` run without a
|
|
74154
|
+
* source leaves the generated `mcpServers` behind; an empty source
|
|
74155
|
+
* (`{ "mcpServers": {} }`) retracts them through the normal merge.
|
|
74156
|
+
* @see https://kiro.dev/docs/mcp/configuration/
|
|
74157
|
+
*/
|
|
74158
|
+
isDeletable() {
|
|
74159
|
+
return !this.global;
|
|
74160
|
+
}
|
|
73650
74161
|
static getSettablePaths() {
|
|
73651
74162
|
return {
|
|
73652
74163
|
relativeDirPath: KIRO_SETTINGS_DIR_PATH,
|
|
73653
74164
|
relativeFilePath: KIRO_MCP_FILE_NAME
|
|
73654
74165
|
};
|
|
73655
74166
|
}
|
|
73656
|
-
static async fromFile({ outputRoot = process.cwd(), validate = true }) {
|
|
74167
|
+
static async fromFile({ outputRoot = process.cwd(), validate = true, global = false }) {
|
|
73657
74168
|
const paths = this.getSettablePaths();
|
|
73658
74169
|
const fileContent = await readFileContentOrNull((0, node_path.join)(outputRoot, paths.relativeDirPath, paths.relativeFilePath)) ?? "{\"mcpServers\":{}}";
|
|
73659
74170
|
return new KiroMcp({
|
|
@@ -73661,18 +74172,34 @@ var KiroMcp = class KiroMcp extends ToolMcp {
|
|
|
73661
74172
|
relativeDirPath: paths.relativeDirPath,
|
|
73662
74173
|
relativeFilePath: paths.relativeFilePath,
|
|
73663
74174
|
fileContent,
|
|
73664
|
-
validate
|
|
74175
|
+
validate,
|
|
74176
|
+
global
|
|
73665
74177
|
});
|
|
73666
74178
|
}
|
|
73667
|
-
|
|
74179
|
+
/**
|
|
74180
|
+
* In global mode the generated `mcpServers` are merged into the existing
|
|
74181
|
+
* user-level file, keeping every other top-level key (for example
|
|
74182
|
+
* `identityProvider`). The project file is written from scratch.
|
|
74183
|
+
*/
|
|
74184
|
+
static async fromRulesyncMcp({ outputRoot = process.cwd(), rulesyncMcp, validate = true, global = false }) {
|
|
73668
74185
|
const paths = this.getSettablePaths();
|
|
73669
|
-
const
|
|
74186
|
+
const mcpServers = toKiroMcpServers(rulesyncMcp.getMcpServers());
|
|
74187
|
+
let existing = {};
|
|
74188
|
+
if (global) {
|
|
74189
|
+
const configPath = (0, node_path.join)(outputRoot, paths.relativeDirPath, paths.relativeFilePath);
|
|
74190
|
+
const existingContent = await readFileContentOrNull(configPath);
|
|
74191
|
+
if (existingContent !== null) existing = parseExistingKiroMcpConfig(existingContent, configPath);
|
|
74192
|
+
}
|
|
73670
74193
|
return new KiroMcp({
|
|
73671
74194
|
outputRoot,
|
|
73672
74195
|
relativeDirPath: paths.relativeDirPath,
|
|
73673
74196
|
relativeFilePath: paths.relativeFilePath,
|
|
73674
|
-
fileContent
|
|
73675
|
-
|
|
74197
|
+
fileContent: JSON.stringify({
|
|
74198
|
+
...existing,
|
|
74199
|
+
mcpServers
|
|
74200
|
+
}, null, 2),
|
|
74201
|
+
validate,
|
|
74202
|
+
global
|
|
73676
74203
|
});
|
|
73677
74204
|
}
|
|
73678
74205
|
toRulesyncMcp() {
|
|
@@ -73680,13 +74207,14 @@ var KiroMcp = class KiroMcp extends ToolMcp {
|
|
|
73680
74207
|
const translated = isMcpServers(mcpServers) ? fromKiroMcpServers(mcpServers) : {};
|
|
73681
74208
|
return this.toRulesyncMcpDefault({ fileContent: JSON.stringify({ mcpServers: translated }, null, 2) });
|
|
73682
74209
|
}
|
|
73683
|
-
static forDeletion({ outputRoot = process.cwd(), relativeDirPath, relativeFilePath }) {
|
|
74210
|
+
static forDeletion({ outputRoot = process.cwd(), relativeDirPath, relativeFilePath, global = false }) {
|
|
73684
74211
|
return new KiroMcp({
|
|
73685
74212
|
outputRoot,
|
|
73686
74213
|
relativeDirPath,
|
|
73687
74214
|
relativeFilePath,
|
|
73688
74215
|
fileContent: "{}",
|
|
73689
|
-
validate: false
|
|
74216
|
+
validate: false,
|
|
74217
|
+
global
|
|
73690
74218
|
});
|
|
73691
74219
|
}
|
|
73692
74220
|
};
|
|
@@ -82111,6 +82639,22 @@ const ANTIGRAVITY_CLI_OVERRIDE_KEYS = [
|
|
|
82111
82639
|
];
|
|
82112
82640
|
const moduleLogger$4 = fallbackLogger;
|
|
82113
82641
|
/**
|
|
82642
|
+
* The value the CLI stores in `agentMode` for its Default mode. Since CLI 1.5.7
|
|
82643
|
+
* an omitted `agentMode` starts the CLI in `auto` where available, and the
|
|
82644
|
+
* documented stored values are `""` (Default), `"accept-edits"`, `"auto"` and
|
|
82645
|
+
* `"plan"` — there is no `"default"` string.
|
|
82646
|
+
* @see https://antigravity.google/docs/cli/modes
|
|
82647
|
+
* @see https://github.com/google-antigravity/antigravity-cli/releases/tag/1.5.7
|
|
82648
|
+
*/
|
|
82649
|
+
const ANTIGRAVITY_CLI_STORED_DEFAULT_AGENT_MODE = "";
|
|
82650
|
+
/**
|
|
82651
|
+
* Translate the canonical `agentMode` override value to the value the CLI
|
|
82652
|
+
* stores: canonical `default` becomes `""`, other modes pass through.
|
|
82653
|
+
*/
|
|
82654
|
+
function toStoredAgentMode(value) {
|
|
82655
|
+
return value === "default" ? ANTIGRAVITY_CLI_STORED_DEFAULT_AGENT_MODE : value;
|
|
82656
|
+
}
|
|
82657
|
+
/**
|
|
82114
82658
|
* Narrow an imported `settings.json` value to one of the documented values of
|
|
82115
82659
|
* an enum-typed override key. The override schema declares `toolPermission`,
|
|
82116
82660
|
* `artifactReviewPolicy` and `agentMode` as `z.enum`, so carrying an
|
|
@@ -82247,7 +82791,7 @@ var AntigravityCliPermissions = class AntigravityCliPermissions extends ToolPerm
|
|
|
82247
82791
|
const override = config["antigravity-cli"];
|
|
82248
82792
|
for (const key of ANTIGRAVITY_CLI_OVERRIDE_KEYS) {
|
|
82249
82793
|
const value = override?.[key];
|
|
82250
|
-
if (value !== void 0) merged[key] = value;
|
|
82794
|
+
if (value !== void 0) merged[key] = key === "agentMode" ? toStoredAgentMode(value) : value;
|
|
82251
82795
|
}
|
|
82252
82796
|
const fileContent = JSON.stringify(merged, null, 2);
|
|
82253
82797
|
return new AntigravityCliPermissions({
|
|
@@ -82291,7 +82835,7 @@ var AntigravityCliPermissions = class AntigravityCliPermissions extends ToolPerm
|
|
|
82291
82835
|
});
|
|
82292
82836
|
if (artifactReviewPolicy !== void 0) override.artifactReviewPolicy = artifactReviewPolicy;
|
|
82293
82837
|
if (typeof settings.allowNonWorkspaceAccess === "boolean") override.allowNonWorkspaceAccess = settings.allowNonWorkspaceAccess;
|
|
82294
|
-
const agentMode = pickDocumentedValue({
|
|
82838
|
+
const agentMode = settings.agentMode === ANTIGRAVITY_CLI_STORED_DEFAULT_AGENT_MODE ? "default" : pickDocumentedValue({
|
|
82295
82839
|
key: "agentMode",
|
|
82296
82840
|
value: settings.agentMode,
|
|
82297
82841
|
documented: ANTIGRAVITY_CLI_AGENT_MODES
|
|
@@ -84120,6 +84664,29 @@ const CLAUDECODE_WIDENING_DEFAULT_MODES = {
|
|
|
84120
84664
|
*/
|
|
84121
84665
|
const CLAUDECODE_PROJECT_SCOPE_IGNORED_DEFAULT_MODES = /* @__PURE__ */ new Set(["auto", "bypassPermissions"]);
|
|
84122
84666
|
/**
|
|
84667
|
+
* The `permissions` fields Claude Code reads only from user or managed settings
|
|
84668
|
+
* (and `--settings`), never from a repository's `.claude/settings.json`, so
|
|
84669
|
+
* they are dropped at project scope and written only under `--global`.
|
|
84670
|
+
* `denyInsteadOfPrompting` (v2.1.319+) only restricts, but committing it to a
|
|
84671
|
+
* project file would promise unattended denials that never happen.
|
|
84672
|
+
*
|
|
84673
|
+
* @see https://code.claude.com/docs/en/settings-reference#permissions-denyinsteadofprompting
|
|
84674
|
+
*/
|
|
84675
|
+
const CLAUDECODE_USER_SCOPE_ONLY_PERMISSIONS_FIELDS = /* @__PURE__ */ new Set(["denyInsteadOfPrompting"]);
|
|
84676
|
+
/**
|
|
84677
|
+
* Drop the project-scope `permissions` fields in
|
|
84678
|
+
* {@link CLAUDECODE_USER_SCOPE_ONLY_PERMISSIONS_FIELDS}, warning once per field
|
|
84679
|
+
* in the same voice as the user-scope-only top-level keys.
|
|
84680
|
+
*/
|
|
84681
|
+
function stripUserScopeOnlyPermissionsFields({ fields, global, relativeFilePath, logger }) {
|
|
84682
|
+
if (global) return;
|
|
84683
|
+
for (const key of CLAUDECODE_USER_SCOPE_ONLY_PERMISSIONS_FIELDS) {
|
|
84684
|
+
if (!Object.hasOwn(fields, key)) continue;
|
|
84685
|
+
logger?.warn(`Claude Code permissions: 'permissions.${key}' is not honored in the project-scoped ${relativeFilePath}, so it is not written there — Claude Code reads it from user or managed settings only. Author it in the global scope instead, and remove any value an earlier generate may have left in ${relativeFilePath}.`);
|
|
84686
|
+
delete fields[key];
|
|
84687
|
+
}
|
|
84688
|
+
}
|
|
84689
|
+
/**
|
|
84123
84690
|
* Drop a project-scope `permissions.defaultMode` Claude Code ignores there (see
|
|
84124
84691
|
* {@link CLAUDECODE_PROJECT_SCOPE_IGNORED_DEFAULT_MODES}), warning in the same
|
|
84125
84692
|
* voice as the other values the project-scoped file cannot honor.
|
|
@@ -84213,7 +84780,7 @@ const CLAUDECODE_TRUST_AFFECTING_SANDBOX_PATHS = [
|
|
|
84213
84780
|
},
|
|
84214
84781
|
{
|
|
84215
84782
|
path: ["enabled"],
|
|
84216
|
-
reason: "turns the sandbox on, and sandboxed Bash commands then run without a permission prompt
|
|
84783
|
+
reason: "turns the sandbox on, and sandboxed Bash commands then run without a permission prompt wherever `autoAllowBashIfSandboxed` is true (it defaults to false since Claude Code v2.1.324)",
|
|
84217
84784
|
widens: isNotFalse
|
|
84218
84785
|
},
|
|
84219
84786
|
{
|
|
@@ -84516,6 +85083,7 @@ const CLAUDECODE_UNHONORED_KEY_SOURCES = {
|
|
|
84516
85083
|
disableCommandPluginSources: "managed settings",
|
|
84517
85084
|
disableDesktopLocalSessions: "managed settings",
|
|
84518
85085
|
disableMobileSimulatorTools: "managed settings",
|
|
85086
|
+
disableRemotePreviewScripts: "managed settings",
|
|
84519
85087
|
disableSideloadFlags: "managed settings",
|
|
84520
85088
|
externalEditorContext: "~/.claude.json",
|
|
84521
85089
|
forceRemoteSettingsRefresh: "managed settings",
|
|
@@ -85009,6 +85577,12 @@ var ClaudecodePermissions = class ClaudecodePermissions extends ToolPermissions
|
|
|
85009
85577
|
relativeFilePath: paths.relativeFilePath,
|
|
85010
85578
|
logger
|
|
85011
85579
|
});
|
|
85580
|
+
stripUserScopeOnlyPermissionsFields({
|
|
85581
|
+
fields: nonListFields,
|
|
85582
|
+
global,
|
|
85583
|
+
relativeFilePath: paths.relativeFilePath,
|
|
85584
|
+
logger
|
|
85585
|
+
});
|
|
85012
85586
|
trustAffecting.push(...collectWideningPermissionFields({ fields: nonListFields }));
|
|
85013
85587
|
settings.permissions = {
|
|
85014
85588
|
...settings.permissions,
|
|
@@ -86986,6 +87560,7 @@ const CODEX_DEFAULT_APPROVAL_POLICY = "on-request";
|
|
|
86986
87560
|
const CODEX_DEFAULT_APPROVALS_REVIEWER = "auto_review";
|
|
86987
87561
|
const CODEX_RETIRED_APPROVAL_POLICY = "untrusted";
|
|
86988
87562
|
const CODEX_DEPRECATED_APPROVAL_POLICY = "on-failure";
|
|
87563
|
+
const CODEX_REMOVED_AUTO_REVIEW_KEYS = ["extra_policy", "experimental_policy_template"];
|
|
86989
87564
|
const CODEX_GLOB_SCAN_MAX_DEPTH = 8;
|
|
86990
87565
|
const CODEX_MINIMAL_KEY = ":minimal";
|
|
86991
87566
|
const CODEX_GIT_WRITE_RULES = { ".git/**": "write" };
|
|
@@ -87587,6 +88162,10 @@ function computeCodexcliOverridePatch({ existing, override, logger }) {
|
|
|
87587
88162
|
value,
|
|
87588
88163
|
logger
|
|
87589
88164
|
})) continue;
|
|
88165
|
+
if (key === "auto_review" && isRecord(value)) warnAboutRemovedAutoReviewKeys({
|
|
88166
|
+
value,
|
|
88167
|
+
logger
|
|
88168
|
+
});
|
|
87590
88169
|
if (key === "sandbox_mode" || key === "sandbox_workspace_write") logger?.warn(`Codex CLI permission override key "${key}" is deprecated. Codex prioritizes the legacy sandbox settings over permission profiles when both are present, so it disables the generated "${RULESYNC_PROFILE_NAME}" permissions profile. Use "base_permission_profile" and the shared "permission" block instead.`);
|
|
87591
88170
|
const existingValue = existing[key];
|
|
87592
88171
|
patch[key] = isRecord(existingValue) && isRecord(value) ? {
|
|
@@ -87626,6 +88205,12 @@ function isWritableApprovalPolicy({ value, logger }) {
|
|
|
87626
88205
|
if (value === CODEX_DEPRECATED_APPROVAL_POLICY) logger?.warn(`Codex CLI permission override "approval_policy": "${CODEX_DEPRECATED_APPROVAL_POLICY}" is deprecated; Codex reads it as "${CODEX_DEFAULT_APPROVAL_POLICY}". Use "${CODEX_DEFAULT_APPROVAL_POLICY}" instead.`);
|
|
87627
88206
|
return true;
|
|
87628
88207
|
}
|
|
88208
|
+
function warnAboutRemovedAutoReviewKeys({ value, logger }) {
|
|
88209
|
+
for (const key of CODEX_REMOVED_AUTO_REVIEW_KEYS) {
|
|
88210
|
+
if (!Object.hasOwn(value, key)) continue;
|
|
88211
|
+
logger?.warn(`Codex CLI permission override "auto_review.${key}" was removed in Codex 0.169.0: newer Codex ignores it and warns at startup (it is rejected only under --strict-config). It is still written for older Codex. Move the text to "auto_review.policy", or to guardian_extra_policy in a managed requirements.toml.`);
|
|
88212
|
+
}
|
|
88213
|
+
}
|
|
87629
88214
|
function extractCodexcliOverride(table) {
|
|
87630
88215
|
const override = {};
|
|
87631
88216
|
for (const key of CODEXCLI_OVERRIDE_KEYS) if (table[key] !== void 0) override[key] = table[key];
|
|
@@ -89000,6 +89585,17 @@ const AUTO_APPROVE_KEYS = {
|
|
|
89000
89585
|
webfetch: "chat.tools.urls.autoApprove"
|
|
89001
89586
|
};
|
|
89002
89587
|
/**
|
|
89588
|
+
* VS Code registers `chat.tools.edits.autoApprove` with
|
|
89589
|
+
* `ConfigurationScope.APPLICATION` (user settings only) and ignores the value
|
|
89590
|
+
* in a workspace `.vscode/settings.json`, so canonical `edit` rules written
|
|
89591
|
+
* there have no effect. The terminal and URL maps are honored in the workspace
|
|
89592
|
+
* only by the Local harness, which VS Code removes in February 2027.
|
|
89593
|
+
*
|
|
89594
|
+
* @see https://github.com/microsoft/vscode/blob/1.147.0/src/vs/workbench/contrib/chat/browser/chat.shared.contribution.ts
|
|
89595
|
+
* @see https://code.visualstudio.com/docs/agents/run/approvals
|
|
89596
|
+
*/
|
|
89597
|
+
const EDITS_KEY_IGNORED_WARNING = "GitHub Copilot: canonical `edit` rules are written to `chat.tools.edits.autoApprove` in .vscode/settings.json, but VS Code reads that setting from user settings only and ignores it in the workspace. Set edit approvals in your VS Code user settings instead.";
|
|
89598
|
+
/**
|
|
89003
89599
|
* The workspace setting holding the starting permission level of new Local
|
|
89004
89600
|
* (`local` harness) chat sessions, authored through the
|
|
89005
89601
|
* `copilot.defaultPermissionMode` override. VS Code 1.144 narrowed it to Local
|
|
@@ -89157,6 +89753,10 @@ const SANDBOX_LEAVES = [
|
|
|
89157
89753
|
path: ["credentials", "authenticategh"],
|
|
89158
89754
|
schema: zod_mini.z.boolean()
|
|
89159
89755
|
},
|
|
89756
|
+
{
|
|
89757
|
+
path: ["credentials", "envVars"],
|
|
89758
|
+
schema: CopilotSandboxCredentialEnvVarsSchema
|
|
89759
|
+
},
|
|
89160
89760
|
{
|
|
89161
89761
|
path: ["fileSystem", "allowDevToolAccess"],
|
|
89162
89762
|
schema: zod_mini.z.boolean()
|
|
@@ -89216,6 +89816,11 @@ const COPILOT_TRUST_AFFECTING_SANDBOX_PATHS = [
|
|
|
89216
89816
|
reason: "hands your GitHub CLI authentication to sandboxed commands",
|
|
89217
89817
|
widens: isNotFalse
|
|
89218
89818
|
},
|
|
89819
|
+
{
|
|
89820
|
+
path: ["credentials", "envVars"],
|
|
89821
|
+
reason: "lets the sandbox send the named environment variables' values to the listed hosts",
|
|
89822
|
+
widens: isNonEmptyMap
|
|
89823
|
+
},
|
|
89219
89824
|
{
|
|
89220
89825
|
path: ["fileSystem", "allowDevToolAccess"],
|
|
89221
89826
|
reason: "grants sandboxed commands developer-tool directories, which can hold credentials such as registry tokens",
|
|
@@ -89241,6 +89846,27 @@ const COPILOT_TRUST_AFFECTING_SANDBOX_PATHS = [
|
|
|
89241
89846
|
}
|
|
89242
89847
|
];
|
|
89243
89848
|
const COPILOT_TOOL_LABEL = "GitHub Copilot";
|
|
89849
|
+
/** The trust-warning label of the `credentials.envVars` leaf. */
|
|
89850
|
+
const ENV_VARS_LABEL = "sandbox.credentials.envVars";
|
|
89851
|
+
/**
|
|
89852
|
+
* Every `VAR -> host, host` pair of a `credentials.envVars` map, so a
|
|
89853
|
+
* developer generating from a cloned repository can spot an unexpected host
|
|
89854
|
+
* without opening the file. Names and hosts are JSON-quoted so control
|
|
89855
|
+
* characters in authored values cannot forge log lines.
|
|
89856
|
+
*/
|
|
89857
|
+
function describeEnvVars(envVars) {
|
|
89858
|
+
return Object.entries(envVars).map(([name, { injectHosts }]) => `${JSON.stringify(name)} -> ${injectHosts.length > 0 ? injectHosts.map((host) => JSON.stringify(host)).join(", ") : "(no hosts)"}`).join("; ");
|
|
89859
|
+
}
|
|
89860
|
+
/**
|
|
89861
|
+
* A separate, stronger warning for `injectHosts` entries containing `*`: the
|
|
89862
|
+
* sandbox may then send the credential to any host the pattern matches.
|
|
89863
|
+
*/
|
|
89864
|
+
function warnOnWildcardInjectHosts({ envVars, relativeFilePath, logger }) {
|
|
89865
|
+
if (envVars === void 0) return;
|
|
89866
|
+
const wildcards = Object.entries(envVars).flatMap(([name, { injectHosts }]) => injectHosts.filter((host) => host.includes("*")).map((host) => `${JSON.stringify(name)} -> ${JSON.stringify(host)}`));
|
|
89867
|
+
if (wildcards.length === 0) return;
|
|
89868
|
+
logger?.warn(`${COPILOT_TOOL_LABEL}: '${ENV_VARS_LABEL}' in ${relativeFilePath} lets the sandbox send credentials to any host matching a wildcard: ${wildcards.join("; ")}. Review these patterns, since the credential can reach every matching host.`);
|
|
89869
|
+
}
|
|
89244
89870
|
function sandboxKey(path) {
|
|
89245
89871
|
return `${SANDBOX_KEY_PREFIX}${path.join(".")}`;
|
|
89246
89872
|
}
|
|
@@ -89433,14 +90059,16 @@ var CopilotPermissions = class CopilotPermissions extends ToolPermissions {
|
|
|
89433
90059
|
const patch = {};
|
|
89434
90060
|
for (const [category, settingKey] of Object.entries(AUTO_APPROVE_KEYS)) {
|
|
89435
90061
|
if (!Object.hasOwn(config.permission, category)) continue;
|
|
90062
|
+
const rules = category === "bash" ? bashRulesHonoringAllTools(config.permission) : honorCopilotAllToolsRestrictions({
|
|
90063
|
+
permission: config.permission,
|
|
90064
|
+
category,
|
|
90065
|
+
logger
|
|
90066
|
+
});
|
|
89436
90067
|
patch[settingKey] = buildAutoApproveValue({
|
|
89437
90068
|
category,
|
|
89438
|
-
rules
|
|
89439
|
-
permission: config.permission,
|
|
89440
|
-
category,
|
|
89441
|
-
logger
|
|
89442
|
-
})
|
|
90069
|
+
rules
|
|
89443
90070
|
});
|
|
90071
|
+
if (category === "edit" && Object.keys(rules).length > 0) logger?.warn(EDITS_KEY_IGNORED_WARNING);
|
|
89444
90072
|
}
|
|
89445
90073
|
const existingSettings = () => parseSharedConfig({
|
|
89446
90074
|
format: "jsonc",
|
|
@@ -89461,13 +90089,23 @@ var CopilotPermissions = class CopilotPermissions extends ToolPermissions {
|
|
|
89461
90089
|
sandbox,
|
|
89462
90090
|
existingSettings: existingSettings()
|
|
89463
90091
|
}));
|
|
90092
|
+
const relativeFilePath = (0, node_path.join)(paths.relativeDirPath, paths.relativeFilePath);
|
|
90093
|
+
const envVars = sandbox.credentials?.envVars;
|
|
89464
90094
|
warnOnTrustAffectingEntries({
|
|
89465
90095
|
toolLabel: COPILOT_TOOL_LABEL,
|
|
89466
90096
|
entries: collectTrustAffectingSandboxPaths({
|
|
89467
90097
|
sandbox,
|
|
89468
90098
|
paths: COPILOT_TRUST_AFFECTING_SANDBOX_PATHS
|
|
89469
|
-
})
|
|
89470
|
-
|
|
90099
|
+
}).map((entry) => entry.label === ENV_VARS_LABEL && envVars !== void 0 ? {
|
|
90100
|
+
...entry,
|
|
90101
|
+
reason: `${entry.reason}: ${describeEnvVars(envVars)}`
|
|
90102
|
+
} : entry),
|
|
90103
|
+
relativeFilePath,
|
|
90104
|
+
logger
|
|
90105
|
+
});
|
|
90106
|
+
warnOnWildcardInjectHosts({
|
|
90107
|
+
envVars,
|
|
90108
|
+
relativeFilePath,
|
|
89471
90109
|
logger
|
|
89472
90110
|
});
|
|
89473
90111
|
}
|
|
@@ -92355,7 +92993,7 @@ function convertGoosePermissionConfigToRulesync(userPermission) {
|
|
|
92355
92993
|
const GROKCLI_UI_KEY = "ui";
|
|
92356
92994
|
const GROKCLI_PERMISSION_MODE_KEY = "permission_mode";
|
|
92357
92995
|
const GROKCLI_PERMISSION_KEY = "permission";
|
|
92358
|
-
const
|
|
92996
|
+
const GROKCLI_DERIVED_PERMISSION_MODES = /* @__PURE__ */ new Set(["ask", "always-approve"]);
|
|
92359
92997
|
const CATEGORY_TO_GROK_TOOL = {
|
|
92360
92998
|
bash: "Bash",
|
|
92361
92999
|
read: "Read",
|
|
@@ -92582,12 +93220,15 @@ function parseGrokRule(rule) {
|
|
|
92582
93220
|
* compact arrays, so a user-authored `rules` array is preserved verbatim
|
|
92583
93221
|
* but not reconciled against them.
|
|
92584
93222
|
*
|
|
92585
|
-
* The coarse `[ui] permission_mode` toggle is
|
|
92586
|
-
* compatibility with older Grok versions
|
|
92587
|
-
*
|
|
93223
|
+
* The coarse `[ui] permission_mode` toggle is kept in sync for backward
|
|
93224
|
+
* compatibility with older Grok versions, but only when the config already
|
|
93225
|
+
* sets it to `ask` or `always-approve`: `always-approve` only when the config
|
|
93226
|
+
* has the all-tools catch-all allow (`"*": { "*": "allow" }`) and no
|
|
93227
|
+
* `deny`/`ask` rule, otherwise `ask` (conservative — it is never `always-approve`
|
|
92588
93228
|
* while any `deny`/`ask` rule exists, so it never contradicts the fine-grained
|
|
92589
|
-
* arrays).
|
|
92590
|
-
* (see
|
|
93229
|
+
* arrays). A missing key is not added, so Grok's own default mode applies. It
|
|
93230
|
+
* is a user-level UI setting, so it is only touched in global scope (see
|
|
93231
|
+
* below).
|
|
92591
93232
|
*
|
|
92592
93233
|
* Both scopes are supported: the adapter syncs the project-level
|
|
92593
93234
|
* `./.grok/config.toml` (default) and the user-level `~/.grok/config.toml`
|
|
@@ -92648,7 +93289,7 @@ var GrokcliPermissions = class GrokcliPermissions extends ToolPermissions {
|
|
|
92648
93289
|
ask: buckets.ask
|
|
92649
93290
|
};
|
|
92650
93291
|
const existingUi = toRecord(parsed[GROKCLI_UI_KEY]);
|
|
92651
|
-
const uiPatch = global && existingUi[GROKCLI_PERMISSION_MODE_KEY]
|
|
93292
|
+
const uiPatch = global && GROKCLI_DERIVED_PERMISSION_MODES.has(existingUi[GROKCLI_PERMISSION_MODE_KEY]) ? { [GROKCLI_UI_KEY]: {
|
|
92652
93293
|
...existingUi,
|
|
92653
93294
|
[GROKCLI_PERMISSION_MODE_KEY]: deriveGrokPermissionMode(config)
|
|
92654
93295
|
} } : {};
|
|
@@ -92829,22 +93470,30 @@ function parseGrokPermissionArrays(permission) {
|
|
|
92829
93470
|
/**
|
|
92830
93471
|
* Legacy coarse fallback: map `[ui] permission_mode` to a canonical action.
|
|
92831
93472
|
* `always-approve` ⇒ `allow`; anything else (including a missing mode) ⇒ `ask`.
|
|
93473
|
+
* A missing mode now means Grok's own default (`auto` in the TUI since 1.0.80),
|
|
93474
|
+
* which has no canonical counterpart, so the narrower `ask` reading is kept.
|
|
92832
93475
|
*/
|
|
92833
93476
|
function legacyModeAction(parsed) {
|
|
92834
93477
|
return toRecord(parsed[GROKCLI_UI_KEY])[GROKCLI_PERMISSION_MODE_KEY] === "always-approve" ? "allow" : "ask";
|
|
92835
93478
|
}
|
|
92836
93479
|
/**
|
|
92837
93480
|
* Collapse a rulesync permissions config into Grok's single coarse mode.
|
|
92838
|
-
*
|
|
92839
|
-
*
|
|
93481
|
+
* `always-approve` lets every tool run without a prompt, so it is derived only
|
|
93482
|
+
* from a true catch-all allow — the all-tools rule `"*": { "*": "allow" }` —
|
|
93483
|
+
* with no `deny`/`ask` rule anywhere. Narrow allows (e.g. `bash: { "git *":
|
|
93484
|
+
* "allow" }`, or even `bash: { "*": "allow" }`) never widen into it; they and
|
|
93485
|
+
* an empty config map to `ask`.
|
|
92840
93486
|
*/
|
|
92841
93487
|
function deriveGrokPermissionMode(config) {
|
|
92842
|
-
|
|
92843
|
-
|
|
92844
|
-
|
|
92845
|
-
|
|
92846
|
-
}
|
|
92847
|
-
return
|
|
93488
|
+
for (const rules of Object.values(config.permission)) for (const action of Object.values(rules)) if (action === "deny" || action === "ask") return "ask";
|
|
93489
|
+
const allTools = lookupOwn({
|
|
93490
|
+
record: config.permission,
|
|
93491
|
+
key: "*"
|
|
93492
|
+
});
|
|
93493
|
+
return allTools !== void 0 && lookupOwn({
|
|
93494
|
+
record: allTools,
|
|
93495
|
+
key: "*"
|
|
93496
|
+
}) === "allow" ? "always-approve" : "ask";
|
|
92848
93497
|
}
|
|
92849
93498
|
// src/features/permissions/hermesagent-permissions.ts
|
|
92850
93499
|
/** Collect the glob patterns in a canonical category that carry a given action. */
|
|
@@ -94147,13 +94796,71 @@ function canonicalToKimiCodeRules({ config, logger }) {
|
|
|
94147
94796
|
});
|
|
94148
94797
|
}
|
|
94149
94798
|
}
|
|
94150
|
-
|
|
94799
|
+
const rules = [...overrideRules, ...sortKimiCodeRulesFailClosed(canonicalRules)];
|
|
94800
|
+
warnAboutIgnoredKimiCodeRuleScopes({
|
|
94801
|
+
rules: overrideRules,
|
|
94802
|
+
logger
|
|
94803
|
+
});
|
|
94804
|
+
warnAboutShadowedKimiCodeRules({
|
|
94805
|
+
rules,
|
|
94806
|
+
logger
|
|
94807
|
+
});
|
|
94808
|
+
return rules;
|
|
94151
94809
|
}
|
|
94152
|
-
|
|
94810
|
+
/**
|
|
94811
|
+
* Scopes Kimi silently ignores on a rule in the user `config.toml`.
|
|
94812
|
+
*
|
|
94813
|
+
* @see https://moonshotai.github.io/kimi-code/en/configuration/config-files.html#permission
|
|
94814
|
+
*/
|
|
94815
|
+
const KIMI_CODE_IGNORED_USER_RULE_SCOPES = /* @__PURE__ */ new Set(["turn-override", "session-runtime"]);
|
|
94816
|
+
function warnAboutIgnoredKimiCodeRuleScopes({ rules, logger }) {
|
|
94817
|
+
for (const rule of rules) if (rule.scope !== void 0 && KIMI_CODE_IGNORED_USER_RULE_SCOPES.has(rule.scope)) logger?.warn(`Kimi Code permissions: the ${rule.decision} rule for "${rule.pattern}" has scope "${rule.scope}", which Kimi ignores in ${KIMI_CODE_CONFIG_SHARED_FILE_KEY}. Use "user" or "project" for it to take effect.`);
|
|
94818
|
+
}
|
|
94819
|
+
/** Split a Kimi rule pattern (`Tool` or `Tool(arg)`) into its tool and argument. */
|
|
94820
|
+
function splitKimiCodePattern(pattern) {
|
|
94153
94821
|
const opening = pattern.indexOf("(");
|
|
94154
94822
|
const hasArguments = opening >= 0 && pattern.endsWith(")");
|
|
94155
|
-
|
|
94156
|
-
|
|
94823
|
+
return {
|
|
94824
|
+
tool: hasArguments ? pattern.slice(0, opening) : pattern,
|
|
94825
|
+
argument: hasArguments ? pattern.slice(opening + 1, -1) : "",
|
|
94826
|
+
hasArguments
|
|
94827
|
+
};
|
|
94828
|
+
}
|
|
94829
|
+
/**
|
|
94830
|
+
* Whether `stricter` certainly matches every call `rule` matches: the same
|
|
94831
|
+
* pattern, or the bare name of the same tool (which matches every call of
|
|
94832
|
+
* it). Wildcard overlaps are not detected, so this never reports a false
|
|
94833
|
+
* shadow but can miss one.
|
|
94834
|
+
*/
|
|
94835
|
+
function kimiCodeRuleCovers({ stricter, rule }) {
|
|
94836
|
+
return stricter.pattern === rule.pattern || stricter.pattern === splitKimiCodePattern(rule.pattern).tool;
|
|
94837
|
+
}
|
|
94838
|
+
/**
|
|
94839
|
+
* Kimi does not let the first matching rule win: a matching `deny` beats a
|
|
94840
|
+
* matching `ask`, which beats a matching `allow` (Kimi Code 2.6.0 docs). An
|
|
94841
|
+
* `allow` or `ask` meant to carve an exception out of a broader, stricter
|
|
94842
|
+
* rule therefore never takes effect, whether it comes from `kimi-code.rules`
|
|
94843
|
+
* or from a canonical category, so say so instead of letting the authored
|
|
94844
|
+
* order suggest otherwise. A rule whose own scope Kimi ignores already got
|
|
94845
|
+
* its warning and is skipped here.
|
|
94846
|
+
*
|
|
94847
|
+
* @see https://moonshotai.github.io/kimi-code/en/configuration/config-files.html#permission
|
|
94848
|
+
*/
|
|
94849
|
+
function warnAboutShadowedKimiCodeRules({ rules, logger }) {
|
|
94850
|
+
for (const rule of rules) {
|
|
94851
|
+
if (rule.decision === "deny" || KIMI_CODE_IGNORED_USER_RULE_SCOPES.has(rule.scope ?? "")) continue;
|
|
94852
|
+
const shadowing = rules.find((other) => isStricterAction({
|
|
94853
|
+
action: other.decision,
|
|
94854
|
+
existing: rule.decision
|
|
94855
|
+
}) && !KIMI_CODE_IGNORED_USER_RULE_SCOPES.has(other.scope ?? "") && kimiCodeRuleCovers({
|
|
94856
|
+
stricter: other,
|
|
94857
|
+
rule
|
|
94858
|
+
}));
|
|
94859
|
+
if (shadowing) logger?.warn(`Kimi Code permissions: the ${rule.decision} rule for "${rule.pattern}" never takes effect: the matching ${shadowing.decision} rule "${shadowing.pattern}" outranks it, because Kimi ranks matching rules deny > ask > allow regardless of their order.`);
|
|
94860
|
+
}
|
|
94861
|
+
}
|
|
94862
|
+
function getKimiCodePatternSpecificity(pattern) {
|
|
94863
|
+
const { tool, argument, hasArguments } = splitKimiCodePattern(pattern);
|
|
94157
94864
|
return {
|
|
94158
94865
|
tool,
|
|
94159
94866
|
toolLiteralLength: tool.replaceAll("*", "").replaceAll("?", "").length,
|
|
@@ -96893,7 +97600,8 @@ const QODER_OVERRIDE_GROUP_KEYS = {
|
|
|
96893
97600
|
"enabledProjectMcpServers",
|
|
96894
97601
|
"lazyLoad"
|
|
96895
97602
|
],
|
|
96896
|
-
agents: ["overrides"]
|
|
97603
|
+
agents: ["overrides"],
|
|
97604
|
+
security: ["disableYoloMode"]
|
|
96897
97605
|
};
|
|
96898
97606
|
const QODER_OVERRIDE_GROUPS = Object.keys(QODER_OVERRIDE_GROUP_KEYS);
|
|
96899
97607
|
/**
|
|
@@ -97156,7 +97864,8 @@ function isLiftableQoderValue(key, value) {
|
|
|
97156
97864
|
switch (key) {
|
|
97157
97865
|
case "defaultPermissionMode": return typeof value === "string" && value.trim() !== "";
|
|
97158
97866
|
case "enableAllProjectMcpServers":
|
|
97159
|
-
case "lazyLoad":
|
|
97867
|
+
case "lazyLoad":
|
|
97868
|
+
case "disableYoloMode": return typeof value === "boolean";
|
|
97160
97869
|
case "overrides": return isRecord(value) && Object.values(value).every(isRecord);
|
|
97161
97870
|
default: return isStringArray(value);
|
|
97162
97871
|
}
|
|
@@ -97417,7 +98126,8 @@ const QWEN_OVERRIDE_TOOLS_KEYS = [
|
|
|
97417
98126
|
"freeform",
|
|
97418
98127
|
"workflowsEnabled",
|
|
97419
98128
|
"workflowNameOnly",
|
|
97420
|
-
"executionSandbox"
|
|
98129
|
+
"executionSandbox",
|
|
98130
|
+
"lspEnabled"
|
|
97421
98131
|
];
|
|
97422
98132
|
const QWEN_OVERRIDE_SECURITY_KEYS = [
|
|
97423
98133
|
"folderTrust",
|
|
@@ -97495,6 +98205,11 @@ const QWEN_SCOPED_TOOLS_KEYS = {
|
|
|
97495
98205
|
grants: () => true,
|
|
97496
98206
|
globalNote: "Qwen Code ignores this key in workspace settings so a repository cannot choose its own sandbox; in the global scope it sets the filesystem and network policy every tool command runs under for every project on this machine (a System value still replaces it, and Qwen Code needs a restart to pick it up)."
|
|
97497
98207
|
},
|
|
98208
|
+
lspEnabled: {
|
|
98209
|
+
rule: "workspace-stripped",
|
|
98210
|
+
grants: (value) => value === true,
|
|
98211
|
+
globalNote: "Qwen Code ignores this key in workspace settings so a repository cannot start language servers on its own behalf; in the global scope it turns on LSP code intelligence for every project on this machine, and the servers run with your permissions. A server declared in a workspace `.lsp.json` still needs an explicitly trusted folder, LSP is refused at startup when `tools.executionSandbox` is set, and the `QWEN_CODE_ENABLE_LSP` / `QWEN_CODE_DISABLE_LSP` environment variables override this setting (disable wins)."
|
|
98212
|
+
},
|
|
97498
98213
|
workflowNameOnly: {
|
|
97499
98214
|
rule: "global-machine-wide",
|
|
97500
98215
|
projectNote: ({ qualifiedKey, quotedValue, filePath }) => `${qualifiedKey} = ${quotedValue} was written to the project-scoped ${filePath}. Qwen Code lets a workspace only turn this key on: \`true\` restricts the model to named workflows in this repository, while any other value cannot lift a restriction set in user or system settings.`,
|
|
@@ -100211,6 +100926,14 @@ const TAKT_SECURITY_POLICIES = {
|
|
|
100211
100926
|
const TAKT_SECURITY_POLICY_KEYS = Object.keys(TAKT_SECURITY_POLICIES);
|
|
100212
100927
|
const TAKT_DEFAULT_PROVIDER = "claude-sdk";
|
|
100213
100928
|
const TAKT_LEGACY_DEFAULT_PROVIDER = "claude";
|
|
100929
|
+
const TAKT_CLAUDE_READ_DENY_PROVIDERS = [
|
|
100930
|
+
"claude-sdk",
|
|
100931
|
+
"claude",
|
|
100932
|
+
"claude-headless"
|
|
100933
|
+
];
|
|
100934
|
+
const TAKT_CLAUDE_PROVIDER_OPTIONS_KEY = "claude";
|
|
100935
|
+
const TAKT_CLAUDE_PERMISSIONS_KEY = "permissions";
|
|
100936
|
+
const TAKT_CLAUDE_PERMISSIONS_DENY_KEY = "deny";
|
|
100214
100937
|
/**
|
|
100215
100938
|
* Permissions adapter for Takt (`.takt/config.yaml`).
|
|
100216
100939
|
*
|
|
@@ -100249,6 +100972,12 @@ const TAKT_LEGACY_DEFAULT_PROVIDER = "claude";
|
|
|
100249
100972
|
* (a top-level per-provider sandbox/network table). Both are authored on
|
|
100250
100973
|
* generate and re-extracted on import.
|
|
100251
100974
|
*
|
|
100975
|
+
* Canonical `read` deny rules are also kept per path where the active provider
|
|
100976
|
+
* is Claude-family (Takt 0.76.0+): they are written as `Read(<pattern>)`
|
|
100977
|
+
* entries into `provider_options.claude.permissions.deny`, in addition to the
|
|
100978
|
+
* `readonly` mode they already derive. The list is only ever added to, so a
|
|
100979
|
+
* deny never turns into a broader allow.
|
|
100980
|
+
*
|
|
100252
100981
|
* Takt 0.56.0 moved provider configuration into a separate `runtime.yaml`
|
|
100253
100982
|
* (`.takt/runtime.yaml`, `~/.takt/runtime.yaml`). Once its `provider:` section
|
|
100254
100983
|
* carries an assignment ("runtime mode" — the state a freshly installed Takt is
|
|
@@ -100313,7 +101042,8 @@ var TaktPermissions = class TaktPermissions extends ToolPermissions {
|
|
|
100313
101042
|
outputRoot,
|
|
100314
101043
|
logger
|
|
100315
101044
|
});
|
|
100316
|
-
const
|
|
101045
|
+
const globalLayer = await readGlobalTaktLayer({
|
|
101046
|
+
global,
|
|
100317
101047
|
projectFilePath: filePath,
|
|
100318
101048
|
logger
|
|
100319
101049
|
});
|
|
@@ -100321,7 +101051,7 @@ var TaktPermissions = class TaktPermissions extends ToolPermissions {
|
|
|
100321
101051
|
const provider = resolveActiveProvider({
|
|
100322
101052
|
config,
|
|
100323
101053
|
runtime: runtime.active ? runtime.config : void 0,
|
|
100324
|
-
inheritedProvider
|
|
101054
|
+
inheritedProvider: globalLayer.provider
|
|
100325
101055
|
});
|
|
100326
101056
|
const mode = deriveTaktPermissionMode(rulesyncJson);
|
|
100327
101057
|
const override = isPlainObject(rulesyncJson.takt) ? rulesyncJson.takt : void 0;
|
|
@@ -100329,9 +101059,20 @@ var TaktPermissions = class TaktPermissions extends ToolPermissions {
|
|
|
100329
101059
|
const authoredProviderOptions = isPlainObject(override?.[TAKT_PROVIDER_OPTIONS_KEY]) ? override[TAKT_PROVIDER_OPTIONS_KEY] : void 0;
|
|
100330
101060
|
const runtimeModeRefusesProviderOptions = authoredProviderOptions !== void 0 && runtime.active;
|
|
100331
101061
|
if (runtimeModeRefusesProviderOptions) logger?.warn(`Takt permissions: not writing "${TAKT_PROVIDER_OPTIONS_KEY}" to ${filePath} because ${runtime.filePaths.join(" + ")} puts Takt in runtime provider mode (Takt 0.56.0+), where any legacy provider setting in config.yaml makes Takt fail with "Mixed provider configuration detected". Move those options to \`provider.profiles.<profile>.options\` in runtime.yaml, and remove them from the \`takt\` block of the rulesync source. A "${TAKT_PROVIDER_OPTIONS_KEY}" already in ${filePath} is left untouched — rulesync does not own that key.`);
|
|
100332
|
-
const overrideProviderOptions =
|
|
100333
|
-
providerOptions:
|
|
100334
|
-
|
|
101062
|
+
const overrideProviderOptions = addClaudeReadDenyRules({
|
|
101063
|
+
providerOptions: runtimeModeRefusesProviderOptions ? void 0 : dropUntrustedProviderOptions({
|
|
101064
|
+
providerOptions: authoredProviderOptions,
|
|
101065
|
+
global,
|
|
101066
|
+
filePath,
|
|
101067
|
+
logger
|
|
101068
|
+
}),
|
|
101069
|
+
readDenyRules: collectReadDenyRules(rulesyncJson),
|
|
101070
|
+
existingProviderOptions: config[TAKT_PROVIDER_OPTIONS_KEY],
|
|
101071
|
+
globalProviderOptions: globalLayer.providerOptions,
|
|
101072
|
+
globalFilePath: globalLayer.filePath,
|
|
101073
|
+
provider,
|
|
101074
|
+
runtimeActive: runtime.active,
|
|
101075
|
+
runtimeFilePaths: runtime.filePaths,
|
|
100335
101076
|
filePath,
|
|
100336
101077
|
logger
|
|
100337
101078
|
});
|
|
@@ -100444,11 +101185,34 @@ function readProviderName(config) {
|
|
|
100444
101185
|
return typeof provider === "string" && provider.trim() !== "" ? provider : void 0;
|
|
100445
101186
|
}
|
|
100446
101187
|
/**
|
|
100447
|
-
*
|
|
100448
|
-
*
|
|
100449
|
-
*
|
|
101188
|
+
* What a project-scope generate inherits from the global `~/.takt/config.yaml`:
|
|
101189
|
+
* its provider and its `provider_options`. Nothing at global scope, where that
|
|
101190
|
+
* file is the one being generated.
|
|
100450
101191
|
*/
|
|
100451
|
-
async function
|
|
101192
|
+
async function readGlobalTaktLayer({ global, projectFilePath, logger }) {
|
|
101193
|
+
const globalConfig = global ? void 0 : await readGlobalTaktConfig({
|
|
101194
|
+
projectFilePath,
|
|
101195
|
+
logger
|
|
101196
|
+
});
|
|
101197
|
+
if (globalConfig === void 0) return {
|
|
101198
|
+
provider: void 0,
|
|
101199
|
+
providerOptions: void 0,
|
|
101200
|
+
filePath: void 0
|
|
101201
|
+
};
|
|
101202
|
+
return {
|
|
101203
|
+
provider: readProviderName(globalConfig.config),
|
|
101204
|
+
providerOptions: globalConfig.config[TAKT_PROVIDER_OPTIONS_KEY],
|
|
101205
|
+
filePath: globalConfig.filePath
|
|
101206
|
+
};
|
|
101207
|
+
}
|
|
101208
|
+
/**
|
|
101209
|
+
* The global `~/.takt/config.yaml`, read for a project-scope generate: its
|
|
101210
|
+
* top-level `provider:` is inherited by a project config that names none, and
|
|
101211
|
+
* its `provider_options.claude.permissions.deny` is the list a project list
|
|
101212
|
+
* would replace. An unresolvable home directory or a missing or unparsable file
|
|
101213
|
+
* all mean "nothing inherited".
|
|
101214
|
+
*/
|
|
101215
|
+
async function readGlobalTaktConfig({ projectFilePath, logger }) {
|
|
100452
101216
|
let globalPath;
|
|
100453
101217
|
try {
|
|
100454
101218
|
globalPath = (0, node_path.join)(getHomeDirectory(), TAKT_DIR, TAKT_CONFIG_FILE_NAME);
|
|
@@ -100459,12 +101223,15 @@ async function readGlobalTaktProvider({ projectFilePath, logger }) {
|
|
|
100459
101223
|
try {
|
|
100460
101224
|
const content = await readFileContentOrNull(globalPath);
|
|
100461
101225
|
if (content === null) return;
|
|
100462
|
-
return
|
|
100463
|
-
format: "yaml",
|
|
100464
|
-
fileContent: content,
|
|
101226
|
+
return {
|
|
100465
101227
|
filePath: globalPath,
|
|
100466
|
-
|
|
100467
|
-
|
|
101228
|
+
config: parseSharedConfig({
|
|
101229
|
+
format: "yaml",
|
|
101230
|
+
fileContent: content,
|
|
101231
|
+
filePath: globalPath,
|
|
101232
|
+
invalidRootPolicy: "error"
|
|
101233
|
+
})
|
|
101234
|
+
};
|
|
100468
101235
|
} catch (error) {
|
|
100469
101236
|
logger?.warn(`Takt permissions: could not read the provider from ${globalPath} (${formatError(error)}); falling back to the project config alone.`);
|
|
100470
101237
|
return;
|
|
@@ -100827,6 +101594,70 @@ function taktModeToRulesyncConfig(mode) {
|
|
|
100827
101594
|
default: return { permission: { bash: { ["*"]: "deny" } } };
|
|
100828
101595
|
}
|
|
100829
101596
|
}
|
|
101597
|
+
/**
|
|
101598
|
+
* The canonical `read` deny rules as Claude Code `Read(...)` entries, in the
|
|
101599
|
+
* form the Claude Code permissions and ignore adapters write them: the pattern
|
|
101600
|
+
* verbatim, and a bare `Read` for the catch-all.
|
|
101601
|
+
*/
|
|
101602
|
+
function collectReadDenyRules(config) {
|
|
101603
|
+
const rules = config.permission.read ?? {};
|
|
101604
|
+
return Object.entries(rules).filter(([, action]) => action === "deny").map(([pattern]) => pattern === "*" ? "Read" : buildReadDenyEntry(pattern));
|
|
101605
|
+
}
|
|
101606
|
+
/**
|
|
101607
|
+
* Add the canonical `read` deny rules to `provider_options.claude.permissions.deny`
|
|
101608
|
+
* (Takt 0.76.0+), which Takt passes to `claude-sdk` / `claude-headless` as
|
|
101609
|
+
* Claude Code `permissions.deny` rules.
|
|
101610
|
+
*
|
|
101611
|
+
* Takt replaces a `deny` list wholesale rather than concatenating it, so the
|
|
101612
|
+
* rules are merged into the list that would otherwise be in force: the one the
|
|
101613
|
+
* `takt` block states (which replaces a hand-written config.yaml list, as any
|
|
101614
|
+
* authored `provider_options` leaf does), else the one already in config.yaml.
|
|
101615
|
+
* Without an authored list nothing is removed from config.yaml's — a rule
|
|
101616
|
+
* written by hand, or by an earlier generate, is kept.
|
|
101617
|
+
*
|
|
101618
|
+
* At project scope the written list also replaces a global `~/.takt/config.yaml`
|
|
101619
|
+
* deny list for this project. That list usually holds personal paths, so it is
|
|
101620
|
+
* not copied into the (committed) project file; a warning names it instead.
|
|
101621
|
+
*
|
|
101622
|
+
* Skipped when the active provider is not Claude-family (no other provider
|
|
101623
|
+
* reads the list) and, with a warning, in runtime mode, where `provider_options`
|
|
101624
|
+
* in config.yaml stops Takt with "Mixed provider configuration detected".
|
|
101625
|
+
* https://github.com/nrslib/takt/blob/main/docs/configuration.md#claude-read-deny-rules
|
|
101626
|
+
*/
|
|
101627
|
+
function addClaudeReadDenyRules({ providerOptions, readDenyRules, existingProviderOptions, globalProviderOptions, globalFilePath, provider, runtimeActive, runtimeFilePaths, filePath, logger }) {
|
|
101628
|
+
if (readDenyRules.length === 0 || !TAKT_CLAUDE_READ_DENY_PROVIDERS.includes(provider)) return providerOptions;
|
|
101629
|
+
if (runtimeActive) {
|
|
101630
|
+
logger?.warn(`Takt permissions: not writing the read deny rules (${readDenyRules.join(", ")}) to "${TAKT_PROVIDER_OPTIONS_KEY}.${TAKT_CLAUDE_PROVIDER_OPTIONS_KEY}.${TAKT_CLAUDE_PERMISSIONS_KEY}.${TAKT_CLAUDE_PERMISSIONS_DENY_KEY}" in ${filePath} because ${runtimeFilePaths.join(" + ")} puts Takt in runtime provider mode. They still make the mode readonly; to have Claude enforce them per path, add them under \`${TAKT_CLAUDE_PERMISSIONS_KEY}.${TAKT_CLAUDE_PERMISSIONS_DENY_KEY}\` in the options of a Claude profile in runtime.yaml.`);
|
|
101631
|
+
return providerOptions;
|
|
101632
|
+
}
|
|
101633
|
+
const authoredClaude = providerOptions?.[TAKT_CLAUDE_PROVIDER_OPTIONS_KEY];
|
|
101634
|
+
const authoredDeny = readClaudeDenyList(authoredClaude);
|
|
101635
|
+
const existingDeny = isPlainObject(existingProviderOptions) ? readClaudeDenyList(existingProviderOptions[TAKT_CLAUDE_PROVIDER_OPTIONS_KEY]) : void 0;
|
|
101636
|
+
const deny = [.../* @__PURE__ */ new Set([...authoredDeny ?? existingDeny ?? [], ...readDenyRules])];
|
|
101637
|
+
const shadowedGlobalDeny = ((isPlainObject(globalProviderOptions) ? readClaudeDenyList(globalProviderOptions[TAKT_CLAUDE_PROVIDER_OPTIONS_KEY]) : void 0) ?? []).filter((rule) => !deny.includes(rule));
|
|
101638
|
+
if (shadowedGlobalDeny.length > 0) logger?.warn(`Takt permissions: the read deny rules written to "${TAKT_PROVIDER_OPTIONS_KEY}.${TAKT_CLAUDE_PROVIDER_OPTIONS_KEY}.${TAKT_CLAUDE_PERMISSIONS_KEY}.${TAKT_CLAUDE_PERMISSIONS_DENY_KEY}" in ${filePath} replace the list in ${globalFilePath ?? "the global config.yaml"} for this project, because Takt does not concatenate deny lists across layers. Claude will no longer apply ${shadowedGlobalDeny.join(", ")} here unless you add them to the project list (the \`takt.provider_options.claude.permissions.deny\` block of the rulesync source) or to the canonical \`read\` rules.`);
|
|
101639
|
+
const claude = isPlainObject(authoredClaude) ? authoredClaude : {};
|
|
101640
|
+
const permissions = isPlainObject(claude[TAKT_CLAUDE_PERMISSIONS_KEY]) ? claude[TAKT_CLAUDE_PERMISSIONS_KEY] : {};
|
|
101641
|
+
return {
|
|
101642
|
+
...providerOptions,
|
|
101643
|
+
[TAKT_CLAUDE_PROVIDER_OPTIONS_KEY]: {
|
|
101644
|
+
...claude,
|
|
101645
|
+
[TAKT_CLAUDE_PERMISSIONS_KEY]: {
|
|
101646
|
+
...permissions,
|
|
101647
|
+
[TAKT_CLAUDE_PERMISSIONS_DENY_KEY]: deny
|
|
101648
|
+
}
|
|
101649
|
+
}
|
|
101650
|
+
};
|
|
101651
|
+
}
|
|
101652
|
+
/** The string entries of `<claude options>.permissions.deny`, when it is a list. */
|
|
101653
|
+
function readClaudeDenyList(claudeOptions) {
|
|
101654
|
+
if (!isPlainObject(claudeOptions)) return;
|
|
101655
|
+
const permissions = claudeOptions[TAKT_CLAUDE_PERMISSIONS_KEY];
|
|
101656
|
+
if (!isPlainObject(permissions)) return;
|
|
101657
|
+
const deny = permissions[TAKT_CLAUDE_PERMISSIONS_DENY_KEY];
|
|
101658
|
+
if (!Array.isArray(deny)) return;
|
|
101659
|
+
return deny.filter((entry) => typeof entry === "string" && entry !== "");
|
|
101660
|
+
}
|
|
100830
101661
|
const TAKT_BASE_URL_PROVIDERS = [
|
|
100831
101662
|
"codex",
|
|
100832
101663
|
"claude",
|
|
@@ -103851,6 +104682,32 @@ function buildZedToolPermissions({ permission, logger }) {
|
|
|
103851
104682
|
inertMcpCategories
|
|
103852
104683
|
};
|
|
103853
104684
|
}
|
|
104685
|
+
/**
|
|
104686
|
+
* Zed's file-edit tools whose `confirm` default does not prompt for files inside
|
|
104687
|
+
* the project.
|
|
104688
|
+
*/
|
|
104689
|
+
const ZED_IN_PROJECT_EDIT_TOOLS = ["edit_file", "write_file"];
|
|
104690
|
+
/**
|
|
104691
|
+
* Zed's `edit_file` and `write_file` skip the permission prompt for files inside
|
|
104692
|
+
* the project when the settings decision is `confirm`: only Zed settings
|
|
104693
|
+
* folders, `.agents/skills/` and paths a symlink places outside the project
|
|
104694
|
+
* still prompt (`authorize_file_edit` in `crates/agent/src/tools/tool_permissions.rs`,
|
|
104695
|
+
* documented under "File Edits Inside the Project" since zed-industries/zed#67037).
|
|
104696
|
+
* A canonical catch-all `ask` on `edit`/`write` — or an all-tools `*` ask those
|
|
104697
|
+
* tools fall back to — therefore lets the agent edit in-project files without
|
|
104698
|
+
* asking, so say so at generate time rather than implying a prompt.
|
|
104699
|
+
*
|
|
104700
|
+
* The check runs on the merged `tools` result: a tool whose entry is a
|
|
104701
|
+
* preserved, hand-written one (not managed by rulesync) is skipped, since its
|
|
104702
|
+
* decision is the user's own. Only the literal `.*` ask pattern counts as
|
|
104703
|
+
* "prompt for every file" and silences the warning; any narrower pattern still
|
|
104704
|
+
* leaves other in-project files unprompted, so the warning stays.
|
|
104705
|
+
*/
|
|
104706
|
+
function warnInProjectEditConfirm({ managedDefault, managedTools, preservedToolNames, logger }) {
|
|
104707
|
+
const confirmTools = ZED_IN_PROJECT_EDIT_TOOLS.filter((tool) => !preservedToolNames.has(tool) && (managedTools[tool]?.default ?? managedDefault) === "confirm" && !managedTools[tool]?.always_confirm?.some((entry) => entry.pattern === ".*"));
|
|
104708
|
+
if (confirmTools.length === 0) return;
|
|
104709
|
+
logger?.warn(`Zed permissions: the catch-all "ask" for ${confirmTools.map((tool) => `"${tool}"`).join(" and ")} becomes Zed's "confirm" default, which does not prompt for edits to files inside the project (only Zed settings folders, ".agents/skills/" and files outside the project still prompt). To be asked before in-project edits, add the "ask" pattern ".*" to the category (only that exact pattern silences this warning; an "always_confirm" match outranks "always_allow" patterns). Zed honors such patterns for in-project files from v1.30 on. Canonical patterns are shared by every target: in glob-matching targets (such as Claude Code's "Edit(.*)") ".*" matches dotfiles only, so there it adds an extra "ask" for those files and loosens nothing.`);
|
|
104710
|
+
}
|
|
103854
104711
|
function asRecord(value) {
|
|
103855
104712
|
if (value === null || typeof value !== "object" || Array.isArray(value)) return {};
|
|
103856
104713
|
return Object.fromEntries(Object.entries(value));
|
|
@@ -103996,6 +104853,12 @@ var ZedPermissions = class ZedPermissions extends ToolPermissions {
|
|
|
103996
104853
|
if ("*" in config.permission) managedToolNames.add("*");
|
|
103997
104854
|
for (const toolName of Object.keys(existingTools)) if (toolName.startsWith("mcp__")) managedToolNames.add(toolName);
|
|
103998
104855
|
const preservedTools = Object.fromEntries(Object.entries(existingTools).filter(([toolName]) => !managedToolNames.has(toolName)));
|
|
104856
|
+
warnInProjectEditConfirm({
|
|
104857
|
+
managedDefault,
|
|
104858
|
+
managedTools,
|
|
104859
|
+
preservedToolNames: new Set(Object.keys(preservedTools)),
|
|
104860
|
+
logger
|
|
104861
|
+
});
|
|
103999
104862
|
return new ZedPermissions({
|
|
104000
104863
|
outputRoot,
|
|
104001
104864
|
relativeDirPath: paths.relativeDirPath,
|