rulesync 43.11.0 → 43.13.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 +2 -1
- package/dist/cli/index.cjs +4 -4
- package/dist/cli/index.js +4 -4
- package/dist/cli/index.js.map +1 -1
- package/dist/{import-BVWVIY-6.js → import-9NB0tQm3.js} +1071 -265
- package/dist/{import-BVWVIY-6.js.map → import-9NB0tQm3.js.map} +1 -1
- package/dist/{import-1cdCo1uU.cjs → import-Djgg1Lrf.cjs} +1069 -264
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +15 -15
|
@@ -9,8 +9,8 @@ import { intersection, kebabCase, uniq } from "es-toolkit";
|
|
|
9
9
|
import { globbySync, isGitIgnoredSync } from "globby";
|
|
10
10
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
11
11
|
import { format, isDeepStrictEqual } from "node:util";
|
|
12
|
-
import matter from "gray-matter";
|
|
13
12
|
import { CORE_SCHEMA, DUMP_SCHEMA, YAMLException, defineScalarTag, dump, load } from "js-yaml";
|
|
13
|
+
import { dump as dump$1, load as load$1 } from "js-yaml-v4";
|
|
14
14
|
import { omit } from "es-toolkit/object";
|
|
15
15
|
import { createHash } from "node:crypto";
|
|
16
16
|
import { encode } from "@toon-format/toon";
|
|
@@ -1807,6 +1807,32 @@ async function relativeWriteLanding({ rootPath, targetPath }) {
|
|
|
1807
1807
|
return relative(rootLanding, targetLanding);
|
|
1808
1808
|
}
|
|
1809
1809
|
/**
|
|
1810
|
+
* The first symbolic link on the way from `rootPath` down to `targetPath`, or
|
|
1811
|
+
* `null` when no existing entry below the root is a link. Only the segments
|
|
1812
|
+
* below the root are looked at, so a root that is itself a link (macOS
|
|
1813
|
+
* `/tmp -> /private/tmp`, a linked home directory) does not count; nor does a
|
|
1814
|
+
* target that is not spelled below the root. Once a segment is missing,
|
|
1815
|
+
* nothing below it exists, so the walk stops there.
|
|
1816
|
+
*/
|
|
1817
|
+
async function firstLinkBelowRoot({ rootPath, targetPath }) {
|
|
1818
|
+
const relativeTarget = relative(resolve(rootPath), resolve(targetPath));
|
|
1819
|
+
if (relativeTarget === "" || pathEscapesRoot(relativeTarget)) return null;
|
|
1820
|
+
let current = resolve(rootPath);
|
|
1821
|
+
for (const segment of splitPathSegments(relativeTarget)) {
|
|
1822
|
+
if (segment === "") continue;
|
|
1823
|
+
current = join(current, segment);
|
|
1824
|
+
let stats;
|
|
1825
|
+
try {
|
|
1826
|
+
stats = await lstat(current);
|
|
1827
|
+
} catch (error) {
|
|
1828
|
+
if (isFileNotFoundError(error) || isNotADirectoryError(error)) return null;
|
|
1829
|
+
throw error;
|
|
1830
|
+
}
|
|
1831
|
+
if (stats.isSymbolicLink()) return current;
|
|
1832
|
+
}
|
|
1833
|
+
return null;
|
|
1834
|
+
}
|
|
1835
|
+
/**
|
|
1810
1836
|
* Directory names that hold version-control metadata. Bytes landing in one of
|
|
1811
1837
|
* them change how the VCS behaves rather than what it tracks: `.git/config`
|
|
1812
1838
|
* can set `core.fsmonitor`, `.git/hooks/*` run on the next commit.
|
|
@@ -4463,37 +4489,6 @@ function toStringArray$1(value) {
|
|
|
4463
4489
|
function toRecord(value) {
|
|
4464
4490
|
return isRecord(value) ? value : {};
|
|
4465
4491
|
}
|
|
4466
|
-
// src/utils/yaml.ts
|
|
4467
|
-
/**
|
|
4468
|
-
* js-yaml v5's `reason` for an empty document. `load("")` — and any
|
|
4469
|
-
* whitespace/comment-only input — throws a `YAMLException` with this reason
|
|
4470
|
-
* instead of returning `undefined` the way v4 did.
|
|
4471
|
-
*/
|
|
4472
|
-
const EMPTY_INPUT_REASON = "expected a document, but the input is empty";
|
|
4473
|
-
/**
|
|
4474
|
-
* Load YAML content while preserving js-yaml v4's behavior of returning
|
|
4475
|
-
* `undefined` for empty documents (empty, whitespace-only, or comment-only
|
|
4476
|
-
* input).
|
|
4477
|
-
*
|
|
4478
|
-
* js-yaml v5 changed `load("")` to **throw** ("expected a document, but the
|
|
4479
|
-
* input is empty") instead of returning `undefined`. Many call sites here parse
|
|
4480
|
-
* config/lock/frontmatter files that can legitimately be empty and rely on the
|
|
4481
|
-
* old `undefined` sentinel (`load(input) ?? {}`, `if (loaded === undefined)`,
|
|
4482
|
-
* "an empty file parses to undefined/null"). Routing every load through this
|
|
4483
|
-
* wrapper keeps that contract in one place so a future js-yaml bump cannot
|
|
4484
|
-
* reintroduce the empty-input regression. Genuine parse errors still propagate.
|
|
4485
|
-
*
|
|
4486
|
-
* @see https://github.com/nodeca/js-yaml/blob/master/docs/migrate_v4_to_v5.md#empty-input-throws
|
|
4487
|
-
*/
|
|
4488
|
-
function loadYaml(content, options) {
|
|
4489
|
-
if (content.trim() === "") return;
|
|
4490
|
-
try {
|
|
4491
|
-
return load(content, options);
|
|
4492
|
-
} catch (error) {
|
|
4493
|
-
if (error instanceof YAMLException && error.reason === EMPTY_INPUT_REASON) return;
|
|
4494
|
-
throw error;
|
|
4495
|
-
}
|
|
4496
|
-
}
|
|
4497
4492
|
// src/utils/frontmatter.ts
|
|
4498
4493
|
/**
|
|
4499
4494
|
* Upper bound on the number of values a frontmatter document may expand to
|
|
@@ -4525,10 +4520,10 @@ const MAX_FRONTMATTER_STRING_CHARS = 4e6;
|
|
|
4525
4520
|
* block itself, checked before it is ever handed to the YAML parser.
|
|
4526
4521
|
*
|
|
4527
4522
|
* The budgets above only bound the *parsed* document — the walk over
|
|
4528
|
-
*
|
|
4523
|
+
* the parser's output — but a complex YAML key (an array or mapping used as a
|
|
4529
4524
|
* mapping key) is joined into a string by js-yaml while it parses, and a
|
|
4530
4525
|
* mapping with many such keys can cost real memory before that walk ever
|
|
4531
|
-
* starts, or even before
|
|
4526
|
+
* starts, or even before the parser returns. Capping the raw block size keeps
|
|
4532
4527
|
* that parse-time cost bounded regardless of what the block contains. Real
|
|
4533
4528
|
* frontmatter blocks are a few hundred bytes at most; even a large project
|
|
4534
4529
|
* manifest stays well under this.
|
|
@@ -4550,8 +4545,8 @@ function estimateLeafChars(value) {
|
|
|
4550
4545
|
/**
|
|
4551
4546
|
* Copy one parsed value, dropping nullish leaves and cyclic references.
|
|
4552
4547
|
*
|
|
4553
|
-
* Every alias is still written out as an independent copy, as
|
|
4554
|
-
*
|
|
4548
|
+
* Every alias is still written out as an independent copy, as js-yaml's
|
|
4549
|
+
* dumper would otherwise serialize shared references as `&ref_0`
|
|
4555
4550
|
* anchors that simplified frontmatter parsers cannot read; the expansion is
|
|
4556
4551
|
* bounded by {@link MAX_FRONTMATTER_VALUES} instead.
|
|
4557
4552
|
*/
|
|
@@ -4627,63 +4622,27 @@ function deepFlattenStringsObject(obj) {
|
|
|
4627
4622
|
function stringifyFrontmatter(body, frontmatter, options) {
|
|
4628
4623
|
const { avoidBlockScalars = false } = options ?? {};
|
|
4629
4624
|
const cleanFrontmatter = avoidBlockScalars ? deepFlattenStringsObject(frontmatter) : deepRemoveNullishObject(frontmatter);
|
|
4630
|
-
const
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
}
|
|
4637
|
-
/**
|
|
4638
|
-
* Thrown in place of gray-matter's built-in JavaScript engine.
|
|
4639
|
-
*
|
|
4640
|
-
* gray-matter picks the parser from the text after the opening fence, so a
|
|
4641
|
-
* file that opens with `---js` or `---javascript` has its frontmatter handed
|
|
4642
|
-
* to `eval()`. Frontmatter here comes from third-party skills, fetched sources
|
|
4643
|
-
* and untrusted repositories, so that would run arbitrary code on the machine
|
|
4644
|
-
* of whoever generates or imports it. Every engine name that resolves to code
|
|
4645
|
-
* execution is mapped to this refusal; {@link assertYamlFrontmatterLanguage}
|
|
4646
|
-
* refuses those fences earlier still, so this is the second line of defense.
|
|
4647
|
-
*/
|
|
4648
|
-
function refuseExecutableFrontmatter() {
|
|
4649
|
-
throw new Error("Frontmatter written in an executable language (JavaScript / CoffeeScript) is not supported; use YAML");
|
|
4650
|
-
}
|
|
4651
|
-
const REFUSED_FRONTMATTER_ENGINE = {
|
|
4652
|
-
parse: refuseExecutableFrontmatter,
|
|
4653
|
-
stringify: refuseExecutableFrontmatter
|
|
4654
|
-
};
|
|
4655
|
-
/**
|
|
4656
|
-
* Engines passed to every gray-matter parse. Supplying them merges over
|
|
4657
|
-
* gray-matter's defaults, so the JavaScript engine (and the CoffeeScript names
|
|
4658
|
-
* a plugin could register) can never be reached through an alias.
|
|
4659
|
-
*
|
|
4660
|
-
* `patches/gray-matter@4.0.3.patch` also deletes the JavaScript engine, but a
|
|
4661
|
-
* pnpm patch only applies inside this repository: gray-matter is an external
|
|
4662
|
-
* dependency of the published package, so an installed rulesync runs the
|
|
4663
|
-
* unpatched gray-matter, and this override plus the language check are what
|
|
4664
|
-
* protect it. Exported for the test that pins that.
|
|
4665
|
-
*/
|
|
4666
|
-
const FRONTMATTER_PARSE_OPTIONS = { engines: {
|
|
4667
|
-
javascript: REFUSED_FRONTMATTER_ENGINE,
|
|
4668
|
-
js: REFUSED_FRONTMATTER_ENGINE,
|
|
4669
|
-
coffee: REFUSED_FRONTMATTER_ENGINE,
|
|
4670
|
-
coffeescript: REFUSED_FRONTMATTER_ENGINE,
|
|
4671
|
-
cson: REFUSED_FRONTMATTER_ENGINE
|
|
4672
|
-
} };
|
|
4625
|
+
const yaml = (avoidBlockScalars ? dump(cleanFrontmatter, { lineWidth: -1 }) : dump$1(cleanFrontmatter)).trim();
|
|
4626
|
+
return (yaml === "{}" ? "" : `---\n${yaml}\n---\n`) + withTrailingNewline(body);
|
|
4627
|
+
}
|
|
4628
|
+
function withTrailingNewline(text) {
|
|
4629
|
+
return text.endsWith("\n") ? text : `${text}\n`;
|
|
4630
|
+
}
|
|
4673
4631
|
/** Frontmatter languages accepted after the opening `---` fence. */
|
|
4674
4632
|
const ALLOWED_FRONTMATTER_LANGUAGE_PATTERN = /^(?:ya?ml)?$/i;
|
|
4675
4633
|
/**
|
|
4676
|
-
* Read the opening frontmatter fence
|
|
4677
|
-
*
|
|
4634
|
+
* Read the opening frontmatter fence, or return `undefined` when the content
|
|
4635
|
+
* carries no frontmatter at all.
|
|
4678
4636
|
*
|
|
4679
|
-
* gray-matter
|
|
4680
|
-
*
|
|
4681
|
-
* fence
|
|
4682
|
-
*
|
|
4683
|
-
*
|
|
4684
|
-
*
|
|
4685
|
-
*
|
|
4686
|
-
*
|
|
4637
|
+
* The grammar is gray-matter's, which rulesync used to depend on, kept so that
|
|
4638
|
+
* every file reads the same as before: one byte order mark is skipped, `---`
|
|
4639
|
+
* is a fence only when a fourth `-` does not follow, and the language is the
|
|
4640
|
+
* text between the fence and the first `\r?\n`, trimmed — dropping the last
|
|
4641
|
+
* character when there is no line break at all. Every check that has to agree
|
|
4642
|
+
* with {@link splitFrontmatter} on where the block is (the language check and
|
|
4643
|
+
* the repair pass) goes through this one reading, so none of them
|
|
4644
|
+
* can be bypassed by a fence line the splitter accepts and a stricter pattern
|
|
4645
|
+
* would not (a stray `\r` before the line break, say).
|
|
4687
4646
|
*/
|
|
4688
4647
|
function readFrontmatterFence(content) {
|
|
4689
4648
|
const offset = content.startsWith("") ? 1 : 0;
|
|
@@ -4702,26 +4661,60 @@ function readFrontmatterFence(content) {
|
|
|
4702
4661
|
/**
|
|
4703
4662
|
* Refuse a frontmatter fence that names any language other than YAML.
|
|
4704
4663
|
*
|
|
4705
|
-
* Only YAML is ever written by rulesync or by the tools it targets
|
|
4706
|
-
*
|
|
4707
|
-
*
|
|
4664
|
+
* Only YAML is ever written by rulesync or by the tools it targets. Generic
|
|
4665
|
+
* frontmatter libraries pick a parser from the fence language, and some hand a
|
|
4666
|
+
* `---js` block to `eval()`; rulesync parses everything as YAML, and refusing
|
|
4667
|
+
* any other language keeps a file meant for such a parser from being read as
|
|
4668
|
+
* something it is not.
|
|
4708
4669
|
*/
|
|
4709
4670
|
function assertYamlFrontmatterLanguage(content) {
|
|
4710
4671
|
const fence = readFrontmatterFence(content);
|
|
4711
4672
|
if (fence && !ALLOWED_FRONTMATTER_LANGUAGE_PATTERN.test(fence.language)) throw new Error(`Unsupported frontmatter language ${JSON.stringify(fence.language.slice(0, 40))}; only YAML frontmatter is supported`);
|
|
4712
4673
|
}
|
|
4713
4674
|
/**
|
|
4714
|
-
*
|
|
4715
|
-
*
|
|
4716
|
-
*
|
|
4717
|
-
*
|
|
4675
|
+
* Split `content` into its raw frontmatter block and its body, the way
|
|
4676
|
+
* gray-matter 4 did (see {@link readFrontmatterFence}).
|
|
4677
|
+
*
|
|
4678
|
+
* The block ends at the first `\n---`, with no requirement that the delimiter
|
|
4679
|
+
* be alone on its line, and one line break after it is dropped from the body.
|
|
4680
|
+
* A fence nothing closes makes the rest of the file the block and leaves the
|
|
4681
|
+
* body empty. Without a fence, `block` is `""` and the body is the content
|
|
4682
|
+
* minus a leading byte order mark.
|
|
4718
4683
|
*/
|
|
4719
|
-
function
|
|
4720
|
-
const
|
|
4721
|
-
if (
|
|
4722
|
-
|
|
4684
|
+
function splitFrontmatter(content) {
|
|
4685
|
+
const text = content.startsWith("") ? content.slice(1) : content;
|
|
4686
|
+
if (!text.startsWith("---") || text.charAt(3) === "-") return {
|
|
4687
|
+
block: "",
|
|
4688
|
+
body: text
|
|
4689
|
+
};
|
|
4690
|
+
let rest = text.slice(3);
|
|
4691
|
+
const rawLanguage = rest.slice(0, rest.search(/\r?\n/));
|
|
4692
|
+
if (rawLanguage.trim() !== "") rest = rest.slice(rawLanguage.length);
|
|
4723
4693
|
const closeIndex = rest.indexOf("\n---");
|
|
4724
|
-
|
|
4694
|
+
if (closeIndex === -1) return {
|
|
4695
|
+
block: rest,
|
|
4696
|
+
body: ""
|
|
4697
|
+
};
|
|
4698
|
+
let body = rest.slice(closeIndex + 4);
|
|
4699
|
+
if (body.startsWith("\r")) body = body.slice(1);
|
|
4700
|
+
if (body.startsWith("\n")) body = body.slice(1);
|
|
4701
|
+
return {
|
|
4702
|
+
block: rest.slice(0, closeIndex),
|
|
4703
|
+
body
|
|
4704
|
+
};
|
|
4705
|
+
}
|
|
4706
|
+
/**
|
|
4707
|
+
* Whether a raw block holds nothing but blank and comment lines. Checked line
|
|
4708
|
+
* by line rather than with gray-matter's `/^\s*#[^\n]+/gm`, whose `\s*` also
|
|
4709
|
+
* spans line breaks and backtracks quadratically on a long run of blank lines.
|
|
4710
|
+
* The one known difference: a lone `\r` now ends a comment line, as it does
|
|
4711
|
+
* in YAML, where the old pattern let the comment run on past it.
|
|
4712
|
+
*/
|
|
4713
|
+
function isBlankFrontmatterBlock(block) {
|
|
4714
|
+
return block.split(/\r\n|\r|\n/).every((line) => {
|
|
4715
|
+
const trimmed = line.trim();
|
|
4716
|
+
return trimmed === "" || trimmed.startsWith("#");
|
|
4717
|
+
});
|
|
4725
4718
|
}
|
|
4726
4719
|
function parseFrontmatter(content, filePath) {
|
|
4727
4720
|
let frontmatter;
|
|
@@ -4729,11 +4722,11 @@ function parseFrontmatter(content, filePath) {
|
|
|
4729
4722
|
let hasFrontmatter;
|
|
4730
4723
|
try {
|
|
4731
4724
|
assertYamlFrontmatterLanguage(content);
|
|
4732
|
-
|
|
4733
|
-
|
|
4734
|
-
frontmatter = deepRemoveNullishObject(
|
|
4735
|
-
body =
|
|
4736
|
-
hasFrontmatter =
|
|
4725
|
+
const split = splitFrontmatter(content);
|
|
4726
|
+
if (split.block.length > 65536) throw new Error(`Frontmatter block is larger than ${MAX_FRONTMATTER_RAW_CHARS} characters; refusing to parse it (a complex YAML key can cost memory while parsing, before any post-parse budget applies)`);
|
|
4727
|
+
frontmatter = deepRemoveNullishObject(isBlankFrontmatterBlock(split.block) ? {} : load$1(split.block));
|
|
4728
|
+
body = split.body;
|
|
4729
|
+
hasFrontmatter = content === "" || split.block !== "" || content.trimStart().startsWith("---");
|
|
4737
4730
|
} catch (error) {
|
|
4738
4731
|
if (filePath) throw new Error(`Failed to parse frontmatter in ${filePath}: ${formatError(error)}`, { cause: error });
|
|
4739
4732
|
throw error;
|
|
@@ -4790,11 +4783,11 @@ function repairFrontmatterLine(line) {
|
|
|
4790
4783
|
/**
|
|
4791
4784
|
* Locate a raw `---`-delimited frontmatter block's bounds within `content`,
|
|
4792
4785
|
* without parsing it, for the YAML repair pass below and the rule loaders that
|
|
4793
|
-
* pre-process `globs:`. The opening fence is read exactly as
|
|
4786
|
+
* pre-process `globs:`. The opening fence is read exactly as the splitter reads
|
|
4794
4787
|
* it ({@link readFrontmatterFence}); an explicit `yaml` / `yml` language is
|
|
4795
|
-
* still YAML, any other language yields no bounds.
|
|
4788
|
+
* still YAML, any other language yields no bounds. The splitter ends the block
|
|
4796
4789
|
* at the first `\n---`, with no requirement that the delimiter be alone on its
|
|
4797
|
-
* line, so a stricter pattern here would run past
|
|
4790
|
+
* line, so a stricter pattern here would run past the splitter's delimiter and
|
|
4798
4791
|
* act on text that is really the body. A block with no closing fence has no
|
|
4799
4792
|
* bounds; the size guard measures that case separately.
|
|
4800
4793
|
*/
|
|
@@ -5866,16 +5859,17 @@ const CONTINUE_TO_CANONICAL_EVENT_NAMES = invertRecord(CANONICAL_TO_CONTINUE_EVE
|
|
|
5866
5859
|
* observers, `gateway_platform_event` and `transform_api_error_classification`.
|
|
5867
5860
|
* Shell hooks are gated on the same set.
|
|
5868
5861
|
*
|
|
5869
|
-
* Verified against the tag `v0.
|
|
5862
|
+
* Verified against the tag `v0.23.2`: `VALID_HOOKS` holds 48 entries, grown
|
|
5870
5863
|
* from 23 at `v2026.8.3` (v0.20.0) and 37 at `v2026.8.16` (v0.20.2) — v0.21
|
|
5871
5864
|
* added `agent_loop_stopped` and `on_room_member_activity`, v0.21.5 added
|
|
5872
5865
|
* `pre_auxiliary_call` and `post_auxiliary_call`, v0.21.6 added
|
|
5873
5866
|
* `post_gateway_admission`, `on_human_input_request` and
|
|
5874
|
-
* `on_human_input_resolved`,
|
|
5875
|
-
* `post_compaction
|
|
5867
|
+
* `on_human_input_resolved`, v0.22.3 added `on_session_delete` and
|
|
5868
|
+
* `post_compaction`, and v0.23.1 added `on_session_open` and
|
|
5869
|
+
* `post_curator_run`. This list holds 47 of them — see
|
|
5876
5870
|
* {@link HERMESAGENT_SHELL_UNSUPPORTED_HOOK_EVENTS} for the exclusion.
|
|
5877
5871
|
*
|
|
5878
|
-
* @see https://github.com/NousResearch/hermes-agent/blob/v0.
|
|
5872
|
+
* @see https://github.com/NousResearch/hermes-agent/blob/v0.23.2/hermes_cli/plugins.py
|
|
5879
5873
|
*/
|
|
5880
5874
|
const HERMESAGENT_NATIVE_HOOK_EVENTS = [
|
|
5881
5875
|
"pre_tool_call",
|
|
@@ -5900,6 +5894,7 @@ const HERMESAGENT_NATIVE_HOOK_EVENTS = [
|
|
|
5900
5894
|
"on_session_finalize",
|
|
5901
5895
|
"on_session_reset",
|
|
5902
5896
|
"on_session_delete",
|
|
5897
|
+
"on_session_open",
|
|
5903
5898
|
"on_skill_lifecycle",
|
|
5904
5899
|
"subagent_start",
|
|
5905
5900
|
"subagent_stop",
|
|
@@ -5922,7 +5917,8 @@ const HERMESAGENT_NATIVE_HOOK_EVENTS = [
|
|
|
5922
5917
|
"on_kanban_dispatch_tick",
|
|
5923
5918
|
"gateway_platform_event",
|
|
5924
5919
|
"pre_command",
|
|
5925
|
-
"post_compaction"
|
|
5920
|
+
"post_compaction",
|
|
5921
|
+
"post_curator_run"
|
|
5926
5922
|
];
|
|
5927
5923
|
/**
|
|
5928
5924
|
* `VALID_HOOKS` entries a SHELL hook may not register for. `VALID_HOOKS` doubles
|
|
@@ -5934,8 +5930,8 @@ const HERMESAGENT_NATIVE_HOOK_EVENTS = [
|
|
|
5934
5930
|
* rulesync only ever writes shell hooks, so these are excluded from
|
|
5935
5931
|
* {@link HERMESAGENT_NATIVE_HOOK_EVENTS} and warned about with their own message.
|
|
5936
5932
|
*
|
|
5937
|
-
* @see https://github.com/NousResearch/hermes-agent/blob/v0.
|
|
5938
|
-
* @see https://github.com/NousResearch/hermes-agent/blob/v0.
|
|
5933
|
+
* @see https://github.com/NousResearch/hermes-agent/blob/v0.23.2/hermes_cli/plugins.py — `SHELL_UNSUPPORTED_HOOKS`
|
|
5934
|
+
* @see https://github.com/NousResearch/hermes-agent/blob/v0.23.2/agent/shell_hooks.py — `_parse_hooks_block`
|
|
5939
5935
|
*/
|
|
5940
5936
|
const HERMESAGENT_SHELL_UNSUPPORTED_HOOK_EVENTS = ["transform_api_error_classification"];
|
|
5941
5937
|
/**
|
|
@@ -5955,8 +5951,8 @@ const CANONICAL_TO_HERMESAGENT_EVENT_NAMES = {
|
|
|
5955
5951
|
/**
|
|
5956
5952
|
* Hook events supported by Hermes Agent's native Shell Hooks system.
|
|
5957
5953
|
*
|
|
5958
|
-
* Hermes validates hook events against a fixed `VALID_HOOKS` set —
|
|
5959
|
-
* of v0.
|
|
5954
|
+
* Hermes validates hook events against a fixed `VALID_HOOKS` set — 48 entries as
|
|
5955
|
+
* of v0.23.2 (tag `v0.23.2`); see {@link HERMESAGENT_NATIVE_HOOK_EVENTS} for the
|
|
5960
5956
|
* full list. Only the events with a clean 1:1 canonical equivalent are mapped
|
|
5961
5957
|
* here. All other native events round-trip through `hermesagent.hooks`.
|
|
5962
5958
|
* @see https://github.com/NousResearch/hermes-agent/blob/main/website/docs/user-guide/features/hooks.md
|
|
@@ -6749,6 +6745,7 @@ const CANONICAL_TO_KIRO_IDE_EVENT_NAMES = {
|
|
|
6749
6745
|
beforeSubmitPrompt: "UserPromptSubmit",
|
|
6750
6746
|
preToolUse: "PreToolUse",
|
|
6751
6747
|
postToolUse: "PostToolUse",
|
|
6748
|
+
permissionRequest: "PermissionRequest",
|
|
6752
6749
|
stop: "Stop"
|
|
6753
6750
|
};
|
|
6754
6751
|
/**
|
|
@@ -6757,7 +6754,9 @@ const CANONICAL_TO_KIRO_IDE_EVENT_NAMES = {
|
|
|
6757
6754
|
*
|
|
6758
6755
|
* Kiro exposes PascalCase triggers. rulesync maps the canonical lifecycle
|
|
6759
6756
|
* events that have a clean 1:1 equivalent: `SessionStart`, `Stop`,
|
|
6760
|
-
* `UserPromptSubmit`, `PreToolUse`,
|
|
6757
|
+
* `UserPromptSubmit`, `PreToolUse`, `PostToolUse`, and `PermissionRequest`
|
|
6758
|
+
* (Kiro IDE 1.4.236+ and CLI V3 3.4.0+; it takes a Pre Tool Use–style tool
|
|
6759
|
+
* matcher). Kiro also documents
|
|
6761
6760
|
* file-event (`PostFileCreate`/`PostFileSave`/`PostFileDelete`) and spec-task
|
|
6762
6761
|
* (`PreTaskExec`/`PostTaskExec`) triggers that have no canonical equivalent;
|
|
6763
6762
|
* those can still be emitted verbatim via the shared `kiro` override block
|
|
@@ -8186,6 +8185,15 @@ const CopilotSandboxUserConfiguredPathsSchema = z.strictObject({
|
|
|
8186
8185
|
deniedPaths: z.optional(z.array(z.string()))
|
|
8187
8186
|
});
|
|
8188
8187
|
/**
|
|
8188
|
+
* `chat.agent.sandbox.credentials.envVars` (VS Code 1.146+): environment
|
|
8189
|
+
* variable names (never their secret values) mapped to the HTTPS hosts the
|
|
8190
|
+
* Agent Host sandbox may inject each value into. Inside the sandbox the
|
|
8191
|
+
* variable is masked.
|
|
8192
|
+
*
|
|
8193
|
+
* @see https://code.visualstudio.com/docs/agents/run/agent-sandboxing
|
|
8194
|
+
*/
|
|
8195
|
+
const CopilotSandboxCredentialEnvVarsSchema = z.record(z.string(), z.strictObject({ injectHosts: z.array(z.string()) }));
|
|
8196
|
+
/**
|
|
8189
8197
|
* The Agent Host sandbox settings VS Code 1.141 settled on, as a nested object
|
|
8190
8198
|
* whose path mirrors the dotted setting key under `chat.agent.sandbox.` — e.g.
|
|
8191
8199
|
* `network.allowNetwork` writes `chat.agent.sandbox.network.allowNetwork`.
|
|
@@ -8207,7 +8215,8 @@ const CopilotSandboxSchema = z.strictObject({
|
|
|
8207
8215
|
lspServers: z.optional(z.boolean()),
|
|
8208
8216
|
credentials: z.optional(z.strictObject({
|
|
8209
8217
|
authenticategit: z.optional(z.boolean()),
|
|
8210
|
-
authenticategh: z.optional(z.boolean())
|
|
8218
|
+
authenticategh: z.optional(z.boolean()),
|
|
8219
|
+
envVars: z.optional(CopilotSandboxCredentialEnvVarsSchema)
|
|
8211
8220
|
})),
|
|
8212
8221
|
fileSystem: z.optional(z.strictObject({
|
|
8213
8222
|
allowDevToolAccess: z.optional(z.boolean()),
|
|
@@ -9526,15 +9535,20 @@ const CodexcliPermissionsOverrideSchema = z.looseObject({
|
|
|
9526
9535
|
/**
|
|
9527
9536
|
* The `[auto_review]` table of `config.toml`, which configures the reviewer
|
|
9528
9537
|
* that `approvals_reviewer = "auto_review"` (Rulesync's default) selects:
|
|
9529
|
-
* `policy` / `extra_policy` (text inserted into the reviewer prompt
|
|
9538
|
+
* `policy` / `extra_policy` (text inserted into the reviewer prompt;
|
|
9539
|
+
* `extra_policy` only up to Codex 0.168.0),
|
|
9530
9540
|
* `timeout_ms` (the review budget, Codex 0.165.0+; `0` waits without a
|
|
9531
9541
|
* deadline), `circuit_break_action` (`default` | `strict`) and
|
|
9532
9542
|
* `conversation_history_max_output_tokens` (a positive token cap). Codex
|
|
9533
9543
|
* rejects the whole config file when one of these has the wrong type or is
|
|
9534
9544
|
* out of range (`timeout_ms` is a `u32`, the token cap a `NonZeroUsize`), so
|
|
9535
9545
|
* they are checked here; every other key passes through verbatim.
|
|
9546
|
+
* `extra_policy` and `experimental_policy_template` were removed in Codex
|
|
9547
|
+
* 0.169.0 (openai/codex PR #60646): newer Codex ignores them and warns at
|
|
9548
|
+
* startup (only `--strict-config` rejects them), so they are still accepted
|
|
9549
|
+
* and written for older Codex, and generate warns when they are authored.
|
|
9536
9550
|
*
|
|
9537
|
-
* @see https://github.com/openai/codex/blob/rust-v0.
|
|
9551
|
+
* @see https://github.com/openai/codex/blob/rust-v0.169.0/codex-rs/config/src/config_toml.rs (`AutoReviewToml`)
|
|
9538
9552
|
*/
|
|
9539
9553
|
auto_review: z.optional(z.looseObject({
|
|
9540
9554
|
policy: z.optional(z.string()),
|
|
@@ -12688,6 +12702,37 @@ function serialize(value) {
|
|
|
12688
12702
|
function stripStrings(_key, value) {
|
|
12689
12703
|
return typeof value === "string" ? stripControlCharacters(value) : value;
|
|
12690
12704
|
}
|
|
12705
|
+
// src/utils/yaml.ts
|
|
12706
|
+
/**
|
|
12707
|
+
* js-yaml v5's `reason` for an empty document. `load("")` — and any
|
|
12708
|
+
* whitespace/comment-only input — throws a `YAMLException` with this reason
|
|
12709
|
+
* instead of returning `undefined` the way v4 did.
|
|
12710
|
+
*/
|
|
12711
|
+
const EMPTY_INPUT_REASON = "expected a document, but the input is empty";
|
|
12712
|
+
/**
|
|
12713
|
+
* Load YAML content while preserving js-yaml v4's behavior of returning
|
|
12714
|
+
* `undefined` for empty documents (empty, whitespace-only, or comment-only
|
|
12715
|
+
* input).
|
|
12716
|
+
*
|
|
12717
|
+
* js-yaml v5 changed `load("")` to **throw** ("expected a document, but the
|
|
12718
|
+
* input is empty") instead of returning `undefined`. Many call sites here parse
|
|
12719
|
+
* config/lock/frontmatter files that can legitimately be empty and rely on the
|
|
12720
|
+
* old `undefined` sentinel (`load(input) ?? {}`, `if (loaded === undefined)`,
|
|
12721
|
+
* "an empty file parses to undefined/null"). Routing every load through this
|
|
12722
|
+
* wrapper keeps that contract in one place so a future js-yaml bump cannot
|
|
12723
|
+
* reintroduce the empty-input regression. Genuine parse errors still propagate.
|
|
12724
|
+
*
|
|
12725
|
+
* @see https://github.com/nodeca/js-yaml/blob/master/docs/migrate_v4_to_v5.md#empty-input-throws
|
|
12726
|
+
*/
|
|
12727
|
+
function loadYaml(content, options) {
|
|
12728
|
+
if (content.trim() === "") return;
|
|
12729
|
+
try {
|
|
12730
|
+
return load(content, options);
|
|
12731
|
+
} catch (error) {
|
|
12732
|
+
if (error instanceof YAMLException && error.reason === EMPTY_INPUT_REASON) return;
|
|
12733
|
+
throw error;
|
|
12734
|
+
}
|
|
12735
|
+
}
|
|
12691
12736
|
// src/features/shared/jsonc-object-edit.ts
|
|
12692
12737
|
/**
|
|
12693
12738
|
* In-place editing of a JSONC object's text: the engine behind the shared
|
|
@@ -14001,6 +14046,7 @@ const SHARED_CONFIG_OWNERSHIP = {
|
|
|
14001
14046
|
"chat.agent.sandbox.lspServers",
|
|
14002
14047
|
"chat.agent.sandbox.credentials.authenticategit",
|
|
14003
14048
|
"chat.agent.sandbox.credentials.authenticategh",
|
|
14049
|
+
"chat.agent.sandbox.credentials.envVars",
|
|
14004
14050
|
"chat.agent.sandbox.fileSystem.allowDevToolAccess",
|
|
14005
14051
|
"chat.agent.sandbox.fileSystem.userConfiguredPaths",
|
|
14006
14052
|
"zoo-code.allowedCommands",
|
|
@@ -14697,7 +14743,7 @@ function tryParseStructured({ filePath, content }) {
|
|
|
14697
14743
|
}
|
|
14698
14744
|
}
|
|
14699
14745
|
/**
|
|
14700
|
-
*
|
|
14746
|
+
* The parsed body often starts with extra newlines right after the closing ---; strip those so the
|
|
14701
14747
|
* body matches across generators vs on-disk formatters. Trailing whitespace is normalized via
|
|
14702
14748
|
* addTrailingNewline (trimEnd + single newline), same as writes.
|
|
14703
14749
|
*/
|
|
@@ -14788,7 +14834,7 @@ function fileContentIsEmptyPayload({ filePath, content }) {
|
|
|
14788
14834
|
* Whether on-disk content is equivalent to generated content for --check / dry-run.
|
|
14789
14835
|
*
|
|
14790
14836
|
* Uses structured comparison for JSON/JSONC (via jsonc-parser), YAML, TOML, and Markdown-like
|
|
14791
|
-
* frontmatter files (.md, .mdc — same
|
|
14837
|
+
* frontmatter files (.md, .mdc — same frontmatter parser as elsewhere).
|
|
14792
14838
|
*/
|
|
14793
14839
|
function fileContentsEquivalent({ filePath, expected, existing }) {
|
|
14794
14840
|
if (existing === null) return false;
|
|
@@ -14970,6 +15016,11 @@ var FeatureProcessor = class extends RulesyncSourceConsumer {
|
|
|
14970
15016
|
if (fileMode !== void 0 && !this.dryRun) await restoreMissingExecutableBit(filePath, fileMode);
|
|
14971
15017
|
continue;
|
|
14972
15018
|
}
|
|
15019
|
+
await warnIfWriteFollowsLink({
|
|
15020
|
+
logger: this.logger,
|
|
15021
|
+
rootPath: aiFile.getOutputRoot(),
|
|
15022
|
+
targetPath: filePath
|
|
15023
|
+
});
|
|
14973
15024
|
if (this.dryRun) this.logger.info(`[DRY RUN] Would write: ${stripControlCharacters(filePath)}`);
|
|
14974
15025
|
else {
|
|
14975
15026
|
await writeFileContent(filePath, contentWithNewline);
|
|
@@ -15154,6 +15205,37 @@ async function refusesWriteOutsideRoot({ logger, rootPath, targetPath }) {
|
|
|
15154
15205
|
return true;
|
|
15155
15206
|
}
|
|
15156
15207
|
/**
|
|
15208
|
+
* Warn, once per run and link, that a write to `targetPath` goes through a
|
|
15209
|
+
* symbolic link below `rootPath`: the warning names the link and the real path
|
|
15210
|
+
* it leads to, so the file the write really changes is visible.
|
|
15211
|
+
*
|
|
15212
|
+
* Links that lead out of the root (or into version-control metadata) are
|
|
15213
|
+
* refused by {@link refusesWriteOutsideRoot} before this is asked; an in-root
|
|
15214
|
+
* link is written through on purpose (dotfiles setups rely on it), but a
|
|
15215
|
+
* committed `AGENTS.md -> .claude/CLAUDE.md` would otherwise have one target
|
|
15216
|
+
* silently replace another target's file. Writers call this only for a file
|
|
15217
|
+
* they are about to change (or, in a dry run, would change), so an unchanged
|
|
15218
|
+
* file reached through a link stays quiet. The warning is keyed on the first
|
|
15219
|
+
* link on the path rather than on the file, so a linked directory such as
|
|
15220
|
+
* `~/.claude -> ~/dotfiles/.claude` is reported once however many files below
|
|
15221
|
+
* it a run writes.
|
|
15222
|
+
*/
|
|
15223
|
+
async function warnIfWriteFollowsLink({ logger, rootPath, targetPath }) {
|
|
15224
|
+
const linkPath = await firstLinkBelowRoot({
|
|
15225
|
+
rootPath,
|
|
15226
|
+
targetPath
|
|
15227
|
+
});
|
|
15228
|
+
if (linkPath === null) return;
|
|
15229
|
+
const linkLanding = await writeLandingPath(linkPath);
|
|
15230
|
+
if (linkLanding === null) return;
|
|
15231
|
+
warnOnceWithFallback(logger, `${quoteForLog(linkPath)} is a symbolic link to ${quoteForLog(linkLanding)}; files rulesync writes through it land there`);
|
|
15232
|
+
const restOfPath = relative(linkPath, resolve(targetPath));
|
|
15233
|
+
if (restOfPath === "") return;
|
|
15234
|
+
const targetLanding = await writeLandingPath(targetPath);
|
|
15235
|
+
if (targetLanding === null || targetLanding === join(linkLanding, restOfPath)) return;
|
|
15236
|
+
warnOnceWithFallback(logger, `${quoteForLog(targetPath)} is reached through further symbolic links; rulesync writes it to ${quoteForLog(targetLanding)}`);
|
|
15237
|
+
}
|
|
15238
|
+
/**
|
|
15157
15239
|
* Why the orphan sweep has to leave the files in `dirPath` alone, or `null`
|
|
15158
15240
|
* when it may delete them.
|
|
15159
15241
|
*
|
|
@@ -18488,6 +18570,11 @@ var GooseCommand = class GooseCommand extends ToolCommand {
|
|
|
18488
18570
|
entries: []
|
|
18489
18571
|
});
|
|
18490
18572
|
if (nextContent === currentContent) return 0;
|
|
18573
|
+
await warnIfWriteFollowsLink({
|
|
18574
|
+
logger,
|
|
18575
|
+
rootPath: outputRoot,
|
|
18576
|
+
targetPath: configPath
|
|
18577
|
+
});
|
|
18491
18578
|
if (dryRun) logger.info(`[DRY RUN] Would write: ${configPath}`);
|
|
18492
18579
|
else await writeFileContent(configPath, nextContent);
|
|
18493
18580
|
return 1;
|
|
@@ -19670,6 +19757,11 @@ var HermesagentCommand = class HermesagentCommand extends ToolCommand {
|
|
|
19670
19757
|
global
|
|
19671
19758
|
});
|
|
19672
19759
|
if (nextContent === currentContent) return 0;
|
|
19760
|
+
await warnIfWriteFollowsLink({
|
|
19761
|
+
logger,
|
|
19762
|
+
rootPath: outputRoot,
|
|
19763
|
+
targetPath: configPath
|
|
19764
|
+
});
|
|
19673
19765
|
if (dryRun) logger.info(`[DRY RUN] Would write: ${configPath}`);
|
|
19674
19766
|
else await writeFileContent(configPath, nextContent);
|
|
19675
19767
|
return 1;
|
|
@@ -23286,6 +23378,17 @@ var DirFeatureProcessor = class extends RulesyncSourceConsumer {
|
|
|
23286
23378
|
});
|
|
23287
23379
|
}
|
|
23288
23380
|
/**
|
|
23381
|
+
* Warn about each file of `aiDir` about to be written through a symbolic link
|
|
23382
|
+
* that stays inside the output root (see {@link warnIfWriteFollowsLink}).
|
|
23383
|
+
*/
|
|
23384
|
+
async warnIfFilesFollowLinks({ aiDir, filePaths }) {
|
|
23385
|
+
for (const targetPath of filePaths) await warnIfWriteFollowsLink({
|
|
23386
|
+
logger: this.logger,
|
|
23387
|
+
rootPath: aiDir.getOutputRoot(),
|
|
23388
|
+
targetPath
|
|
23389
|
+
});
|
|
23390
|
+
}
|
|
23391
|
+
/**
|
|
23289
23392
|
* Once converted to rulesync/tool dirs, write them to the filesystem.
|
|
23290
23393
|
* Returns the number of directories written.
|
|
23291
23394
|
*
|
|
@@ -23338,6 +23441,10 @@ var DirFeatureProcessor = class extends RulesyncSourceConsumer {
|
|
|
23338
23441
|
}
|
|
23339
23442
|
continue;
|
|
23340
23443
|
}
|
|
23444
|
+
await this.warnIfFilesFollowLinks({
|
|
23445
|
+
aiDir,
|
|
23446
|
+
filePaths: writtenPaths.slice(1)
|
|
23447
|
+
});
|
|
23341
23448
|
const relativeDir = aiDir.getRelativePathFromCwd();
|
|
23342
23449
|
if (this.dryRun) {
|
|
23343
23450
|
this.logger.info(`[DRY RUN] Would create directory: ${stripControlCharacters(dirPath)}`);
|
|
@@ -34525,6 +34632,24 @@ function isMissingDescription(value) {
|
|
|
34525
34632
|
function nameFromFileName(relativeFilePath) {
|
|
34526
34633
|
return relativeFilePath.replace(/(\.agent)?\.md$/, "");
|
|
34527
34634
|
}
|
|
34635
|
+
/**
|
|
34636
|
+
* Normalizes a subagent name the way Junie does: the result is what Junie
|
|
34637
|
+
* accepts for `--agent` and must match `[a-z0-9][a-z0-9_-]*`.
|
|
34638
|
+
*
|
|
34639
|
+
* - Surrounding whitespace is trimmed first, so a quoted `" Code Reviewer "`
|
|
34640
|
+
* (or a file named ` Reviewer.md`) does not start or end with a hyphen,
|
|
34641
|
+
* which the leading-character rule would reject.
|
|
34642
|
+
* - Uppercase letters are lowercased.
|
|
34643
|
+
* - Each run of whitespace (spaces, tabs, ...) becomes a single hyphen. The
|
|
34644
|
+
* upstream docs only say Junie "replaces spaces with hyphens"; collapsing
|
|
34645
|
+
* runs gives `code-reviewer` for `Code Reviewer`, which is the name a user
|
|
34646
|
+
* would expect and still matches the pattern, instead of `code--reviewer`.
|
|
34647
|
+
*
|
|
34648
|
+
* @see https://junie.jetbrains.com/docs/junie-cli-subagents.html
|
|
34649
|
+
*/
|
|
34650
|
+
function normalizeJunieName(name) {
|
|
34651
|
+
return name.trim().toLowerCase().replace(/\s+/g, "-");
|
|
34652
|
+
}
|
|
34528
34653
|
var JunieSubagent = class JunieSubagent extends ToolSubagent {
|
|
34529
34654
|
frontmatter;
|
|
34530
34655
|
body;
|
|
@@ -34549,14 +34674,30 @@ var JunieSubagent = class JunieSubagent extends ToolSubagent {
|
|
|
34549
34674
|
getBody() {
|
|
34550
34675
|
return this.body;
|
|
34551
34676
|
}
|
|
34677
|
+
/**
|
|
34678
|
+
* The name Junie resolves after normalization, so `Code Reviewer.md` and
|
|
34679
|
+
* `code-reviewer.md` (both `code-reviewer`) are reported as duplicates on
|
|
34680
|
+
* import instead of becoming two rulesync subagents with the same name.
|
|
34681
|
+
*/
|
|
34682
|
+
getImportIdentity() {
|
|
34683
|
+
return this.getNormalizedName();
|
|
34684
|
+
}
|
|
34685
|
+
/**
|
|
34686
|
+
* An empty or whitespace-only `name` would normalize to `""`, which is not a
|
|
34687
|
+
* valid Junie name and would make every such file share one import identity,
|
|
34688
|
+
* so it falls back to the file name just like a missing `name` does.
|
|
34689
|
+
*/
|
|
34690
|
+
getNormalizedName() {
|
|
34691
|
+
return (this.frontmatter.name === void 0 ? "" : normalizeJunieName(this.frontmatter.name)) || normalizeJunieName(nameFromFileName(this.getRelativeFilePath()));
|
|
34692
|
+
}
|
|
34552
34693
|
toRulesyncSubagent() {
|
|
34553
|
-
const { name, description, ...restFields } = this.frontmatter;
|
|
34694
|
+
const { name: _name, description, ...restFields } = this.frontmatter;
|
|
34554
34695
|
const junieSection = { ...restFields };
|
|
34555
34696
|
return new RulesyncSubagent({
|
|
34556
34697
|
outputRoot: ".",
|
|
34557
34698
|
frontmatter: {
|
|
34558
34699
|
targets: ["*"],
|
|
34559
|
-
name:
|
|
34700
|
+
name: this.getNormalizedName(),
|
|
34560
34701
|
...description !== void 0 && { description },
|
|
34561
34702
|
...Object.keys(junieSection).length > 0 && { junie: junieSection }
|
|
34562
34703
|
},
|
|
@@ -48336,8 +48477,8 @@ var TraeRule = class TraeRule extends ToolRule {
|
|
|
48336
48477
|
* before parsing, inside the frontmatter block only so the body is never
|
|
48337
48478
|
* rewritten. A quoted value, a YAML flow list, a null or boolean keyword and a
|
|
48338
48479
|
* block scalar indicator (`|`, `>`) are left alone. The block bounds are
|
|
48339
|
-
*
|
|
48340
|
-
* `----` line), so the quoting never reaches text
|
|
48480
|
+
* `parseFrontmatter`'s own (it closes the block at the first `\n---`, even
|
|
48481
|
+
* inside a `----` line), so the quoting never reaches text it reads as body.
|
|
48341
48482
|
*/
|
|
48342
48483
|
static parseTraeFrontmatter(fileContent, filePath) {
|
|
48343
48484
|
const bounds = findFrontmatterBlockBounds(fileContent);
|
|
@@ -51642,19 +51783,17 @@ var CursorCheck = class extends AggregatedToolCheck {
|
|
|
51642
51783
|
*
|
|
51643
51784
|
* rulesync never writes frontmatter here, but a user who authored this path as
|
|
51644
51785
|
* an ordinary skill did, and that block is the skill's metadata rather than
|
|
51645
|
-
* review instructions.
|
|
51646
|
-
*
|
|
51647
|
-
*
|
|
51648
|
-
*
|
|
51649
|
-
*
|
|
51650
|
-
*
|
|
51651
|
-
*
|
|
51652
|
-
*
|
|
51653
|
-
*
|
|
51654
|
-
*
|
|
51655
|
-
*
|
|
51656
|
-
* a fence nothing closes: gray-matter would swallow the rest of the file, so
|
|
51657
|
-
* only the rule line goes and the prose under it is kept.
|
|
51786
|
+
* review instructions. Left in place it would be carried into the body of
|
|
51787
|
+
* the check written to `.rulesync/checks/` as a block of YAML right behind
|
|
51788
|
+
* that file's own frontmatter, where a `severity: bogus` copied out of a skill
|
|
51789
|
+
* looks like the check's own setting to anyone reading or editing it.
|
|
51790
|
+
*
|
|
51791
|
+
* The block is therefore found the way `parseFrontmatter` finds it rather than
|
|
51792
|
+
* by parsing it, so that what the parser would have read as frontmatter is
|
|
51793
|
+
* what goes: the opening delimiter may carry a language name (`---yaml`), but
|
|
51794
|
+
* four dashes are a horizontal rule the parser itself skips. The one
|
|
51795
|
+
* deliberate difference is a fence nothing closes: the parser would take the
|
|
51796
|
+
* rest of the file, so only the rule line goes and the prose under it is kept.
|
|
51658
51797
|
*/
|
|
51659
51798
|
const FRONTMATTER_OPEN_PATTERN = /^\uFEFF?---(?!-)[^\r\n]*\r?\n/;
|
|
51660
51799
|
const FRONTMATTER_CLOSE_PATTERN = /^---|\r?\n---/;
|
|
@@ -51919,9 +52058,14 @@ const GooseCheckFrontmatterSchema = z.extend(AmpCheckFrontmatterSchema, {
|
|
|
51919
52058
|
"turn-limit": z.optional(z.int().check(z.nonnegative()))
|
|
51920
52059
|
});
|
|
51921
52060
|
/**
|
|
51922
|
-
* Represents a Goose review check
|
|
52061
|
+
* Represents a Goose review check, written to the user-wide
|
|
51923
52062
|
* `~/.config/goose/checks/` (global scope only).
|
|
51924
52063
|
*
|
|
52064
|
+
* Goose v1.60.0 removed the `goose review` subcommand that ran these checks
|
|
52065
|
+
* (aaif-goose/goose#13469). Goose still discovers them, but only lists them as
|
|
52066
|
+
* agent sources (`properties.kind = "check"`), so `model` and `turn-limit`
|
|
52067
|
+
* have no runtime effect there.
|
|
52068
|
+
*
|
|
51925
52069
|
* Goose discovers repository checks in `.agents/checks/*.md`, the same
|
|
51926
52070
|
* cross-tool directory the `amp` checks target already writes (Goose's
|
|
51927
52071
|
* `tools` and `severity-default` fields exist for parity with Amp's), so the
|
|
@@ -56524,7 +56668,11 @@ const CLAUDE_SPEC = {
|
|
|
56524
56668
|
tool: "onFailure",
|
|
56525
56669
|
trueValue: "block",
|
|
56526
56670
|
falseValue: "continue",
|
|
56527
|
-
hookTypes: /* @__PURE__ */ new Set([
|
|
56671
|
+
hookTypes: /* @__PURE__ */ new Set([
|
|
56672
|
+
"command",
|
|
56673
|
+
"http",
|
|
56674
|
+
"mcp_tool"
|
|
56675
|
+
]),
|
|
56528
56676
|
ignoredEvents: /* @__PURE__ */ new Set([
|
|
56529
56677
|
"stop",
|
|
56530
56678
|
"subagentStop",
|
|
@@ -59836,7 +59984,7 @@ function canonicalToHermesHooks({ config, toolOverrideHooks, logger }) {
|
|
|
59836
59984
|
for (const [nativeEvent, definitions] of Object.entries(toolOverrideHooks ?? {})) {
|
|
59837
59985
|
if (HERMESAGENT_CANONICAL_EVENTS.has(nativeEvent)) continue;
|
|
59838
59986
|
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.`);
|
|
59839
|
-
else if (!HERMESAGENT_NATIVE_EVENTS.has(nativeEvent)) logger?.warn(`Hermes hook event "${nativeEvent}" is not documented by Hermes Agent v0.
|
|
59987
|
+
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.`);
|
|
59840
59988
|
setHermesHookEntries({
|
|
59841
59989
|
result,
|
|
59842
59990
|
event: nativeEvent,
|
|
@@ -60312,7 +60460,8 @@ const BLOCKING_HOOKS = new Set(Object.keys(NAMED_HOOK_MATCHER_SUBJECTS).filter((
|
|
|
60312
60460
|
* 5 minutes). Ordinary commands write to the host's stdout and stderr, as Bun
|
|
60313
60461
|
* Shell echoed them; a `preToolUse` command's are read, 1 MiB each kept (more
|
|
60314
60462
|
* stdout denies; on the Bun Shell fallback the whole output is buffered before
|
|
60315
|
-
* that check)
|
|
60463
|
+
* that check), and a `sessionStart` command's stdout is read the same way while
|
|
60464
|
+
* its stderr goes to the host's (after the command, on Bun Shell). Output
|
|
60316
60465
|
* pipes a background process keeps open are read for 1 s after the command
|
|
60317
60466
|
* exits; what arrived by then is kept, and the reads are then cancelled, as
|
|
60318
60467
|
* they are at a timeout. The OpenCode 1.x-style `event` hooks (`inProcess`)
|
|
@@ -60460,15 +60609,18 @@ function buildRunHelperLinesFor(cwdExpression) {
|
|
|
60460
60609
|
" const timeout = () => new Promise((resolve) => (timer = setTimeout(resolve, seconds * 1000, null)));",
|
|
60461
60610
|
" if (inProcess || !(await __rulesyncCanExec)) {",
|
|
60462
60611
|
` const run = Bun.$\`echo \${input} | \${{ raw: command }}\`.cwd(${cwdExpression}).nothrow();`,
|
|
60463
|
-
"
|
|
60464
|
-
"
|
|
60612
|
+
" // A sessionStart command's stderr reaches the host when it ends, even after its timeout.",
|
|
60613
|
+
" const finished = echo === true ? run : run.quiet().then((done) => (echo && process.stderr.write(done.stderr), done));",
|
|
60614
|
+
" const result = await Promise.race([finished, timeout()]).finally(() => clearTimeout(timer));",
|
|
60615
|
+
" if (!result || echo === true) return result && { exitCode: result.exitCode };",
|
|
60465
60616
|
" const { exitCode, stdout, stderr } = result;",
|
|
60466
60617
|
" return { exitCode, stdout: stdout.toString(), stderr: stderr.toString(), overflow: stdout.length > 1048576 };",
|
|
60467
60618
|
" }",
|
|
60468
|
-
" // An ordinary command writes to the host's stdout and stderr; a preToolUse one is read
|
|
60469
|
-
"
|
|
60470
|
-
` const proc = ${spawn("\"export BUN_BE_BUN=\\n\" + command", "new TextEncoder().encode(input + \"\\n\")", "
|
|
60471
|
-
" const
|
|
60619
|
+
" // An ordinary command writes to the host's stdout and stderr; a preToolUse one is read, and",
|
|
60620
|
+
" // a sessionStart one (`echo: \"stderr\"`) has its stdout read.",
|
|
60621
|
+
` const proc = ${spawn("\"export BUN_BE_BUN=\\n\" + command", "new TextEncoder().encode(input + \"\\n\")", "echo === true ? \"inherit\" : \"pipe\"", "echo ? \"inherit\" : \"pipe\"")};`,
|
|
60622
|
+
" const stdout = echo === true ? undefined : __rulesyncRead(proc.stdout);",
|
|
60623
|
+
" const stderr = echo ? undefined : __rulesyncRead(proc.stderr);",
|
|
60472
60624
|
" const exitCode = await Promise.race([proc.exited, timeout()]).finally(() => clearTimeout(timer));",
|
|
60473
60625
|
" if (exitCode === null) {",
|
|
60474
60626
|
" stdout?.stop(), stderr?.stop();",
|
|
@@ -60476,15 +60628,15 @@ function buildRunHelperLinesFor(cwdExpression) {
|
|
|
60476
60628
|
" else __rulesyncKillTree(proc);",
|
|
60477
60629
|
" return null;",
|
|
60478
60630
|
" }",
|
|
60479
|
-
" if (echo) return { exitCode };",
|
|
60480
|
-
" await Promise.race([Promise.all([stdout.done, stderr
|
|
60481
|
-
" stdout.stop(), stderr
|
|
60482
|
-
" return { exitCode, stdout: stdout.text(), stderr: stderr
|
|
60631
|
+
" if (echo === true) return { exitCode };",
|
|
60632
|
+
" await Promise.race([Promise.all([stdout.done, stderr?.done]), Bun.sleep(1000)]);",
|
|
60633
|
+
" stdout.stop(), stderr?.stop();",
|
|
60634
|
+
" return { exitCode, stdout: stdout.text(), stderr: stderr?.text() ?? \"\", overflow: stdout.overflow() };",
|
|
60483
60635
|
"};",
|
|
60484
|
-
"const __rulesyncRunHook = async ({ label, command, input, blocking, seconds, inProcess = false }) => {",
|
|
60636
|
+
"const __rulesyncRunHook = async ({ label, command, input, blocking, seconds, inProcess = false, context = false }) => {",
|
|
60485
60637
|
" let result;",
|
|
60486
60638
|
" try {",
|
|
60487
|
-
" result = await __rulesyncRunCommand({ command, input, seconds, inProcess, echo: true });",
|
|
60639
|
+
" result = await __rulesyncRunCommand({ command, input, seconds, inProcess, echo: context ? \"stderr\" : true });",
|
|
60488
60640
|
" } catch (error) {",
|
|
60489
60641
|
" if (blocking) throw error;",
|
|
60490
60642
|
" console.error(\"[rulesync-hooks] \" + label + \" hook failed:\", error);",
|
|
@@ -60495,7 +60647,7 @@ function buildRunHelperLinesFor(cwdExpression) {
|
|
|
60495
60647
|
" if (blocking) throw new Error(message);",
|
|
60496
60648
|
" return console.error(message);",
|
|
60497
60649
|
" }",
|
|
60498
|
-
" if (result.exitCode === 0) return;",
|
|
60650
|
+
" if (result.exitCode === 0) return result;",
|
|
60499
60651
|
" const message = \"[rulesync-hooks] \" + label + \" hook exited with code \" + result.exitCode;",
|
|
60500
60652
|
" if (blocking) throw new Error(message);",
|
|
60501
60653
|
" console.error(message);",
|
|
@@ -60563,6 +60715,85 @@ const PRE_TOOL_USE_RESULT_HELPER_LINES = [
|
|
|
60563
60715
|
" );",
|
|
60564
60716
|
"};"
|
|
60565
60717
|
];
|
|
60718
|
+
/**
|
|
60719
|
+
* Helpers the generated plugin defines when a `sessionStart` handler is
|
|
60720
|
+
* present, so the command's stdout reaches the model as Claude Code's
|
|
60721
|
+
* `SessionStart` stdout does:
|
|
60722
|
+
* - `__rulesyncSessionStart(sessionID, run)` runs a session's `sessionStart`
|
|
60723
|
+
* commands (`run` pushes each command's result) and keeps the pending context
|
|
60724
|
+
* for that session. It always settles, since every command is bounded by its
|
|
60725
|
+
* timeout.
|
|
60726
|
+
* - `__rulesyncSessionContext(sessionID)` waits for that context, which the
|
|
60727
|
+
* host's system-prompt hook then adds to each model request of the session.
|
|
60728
|
+
*
|
|
60729
|
+
* A command's context is its stdout on exit code 0, or the
|
|
60730
|
+
* `hookSpecificOutput.additionalContext` string of a JSON object it prints,
|
|
60731
|
+
* trimmed and capped at Claude Code's 10,000 characters; more than 1 MiB of
|
|
60732
|
+
* stdout is logged and ignored. Only sessions whose context is not empty are
|
|
60733
|
+
* kept, the 100 whose context was used or became ready most recently, and a
|
|
60734
|
+
* deleted session is dropped.
|
|
60735
|
+
*/
|
|
60736
|
+
const SESSION_CONTEXT_HELPER_LINES = [
|
|
60737
|
+
"const __rulesyncSessionContexts = new Map();",
|
|
60738
|
+
"const __rulesyncKept = new WeakSet();",
|
|
60739
|
+
"const __rulesyncContextOf = (result) => {",
|
|
60740
|
+
" if (typeof result?.stdout !== \"string\") return \"\";",
|
|
60741
|
+
" if (result.overflow) {",
|
|
60742
|
+
" console.error(\"[rulesync-hooks] sessionStart hook wrote more than 1 MiB to stdout; it is ignored\");",
|
|
60743
|
+
" return \"\";",
|
|
60744
|
+
" }",
|
|
60745
|
+
" let text = result.stdout;",
|
|
60746
|
+
" try {",
|
|
60747
|
+
" const parsed = JSON.parse(text);",
|
|
60748
|
+
" // Like Claude Code, only a JSON object counts as JSON output; anything else is plain text.",
|
|
60749
|
+
" if (parsed && typeof parsed === \"object\" && !Array.isArray(parsed)) text = parsed.hookSpecificOutput?.additionalContext;",
|
|
60750
|
+
" } catch {}",
|
|
60751
|
+
" return typeof text === \"string\" ? text.trim().slice(0, 10000) : \"\";",
|
|
60752
|
+
"};",
|
|
60753
|
+
"const __rulesyncSessionStart = (sessionID, run) => {",
|
|
60754
|
+
" const results = [];",
|
|
60755
|
+
" const pending = run(results)",
|
|
60756
|
+
" .catch(() => {})",
|
|
60757
|
+
" .then(() => results.map(__rulesyncContextOf).filter(Boolean).join(\"\\n\\n\"));",
|
|
60758
|
+
" if (typeof sessionID === \"string\") {",
|
|
60759
|
+
" __rulesyncSessionContexts.delete(sessionID);",
|
|
60760
|
+
" __rulesyncSessionContexts.set(sessionID, pending);",
|
|
60761
|
+
" // Only a non-empty context is kept, and only it counts towards the 100: a running",
|
|
60762
|
+
" // or empty one never evicts another session's context.",
|
|
60763
|
+
" pending.then((context) => {",
|
|
60764
|
+
" if (__rulesyncSessionContexts.get(sessionID) !== pending) return;",
|
|
60765
|
+
" if (!context) return void __rulesyncSessionContexts.delete(sessionID);",
|
|
60766
|
+
" __rulesyncKept.add(pending);",
|
|
60767
|
+
" // Evict in completion order: a context counts as used once it is ready.",
|
|
60768
|
+
" __rulesyncSessionContexts.delete(sessionID);",
|
|
60769
|
+
" __rulesyncSessionContexts.set(sessionID, pending);",
|
|
60770
|
+
" const kept = [...__rulesyncSessionContexts].filter(([, entry]) => __rulesyncKept.has(entry));",
|
|
60771
|
+
" if (kept.length > 100) __rulesyncSessionContexts.delete(kept[0][0]);",
|
|
60772
|
+
" });",
|
|
60773
|
+
" }",
|
|
60774
|
+
" return pending;",
|
|
60775
|
+
"};",
|
|
60776
|
+
"const __rulesyncSessionContext = async (sessionID) => {",
|
|
60777
|
+
" const pending = __rulesyncSessionContexts.get(sessionID);",
|
|
60778
|
+
" if (!pending) return \"\";",
|
|
60779
|
+
" __rulesyncSessionContexts.delete(sessionID);",
|
|
60780
|
+
" __rulesyncSessionContexts.set(sessionID, pending);",
|
|
60781
|
+
" return pending;",
|
|
60782
|
+
"};"
|
|
60783
|
+
];
|
|
60784
|
+
/**
|
|
60785
|
+
* The statements of a `sessionStart` group, run through `__rulesyncSessionStart`.
|
|
60786
|
+
* `__rulesyncSessionStart` registers the session's pending context before its
|
|
60787
|
+
* first `await`, so `"void"` (used by the serial V2 event loop) registers it
|
|
60788
|
+
* as soon as the event is read without waiting for the commands.
|
|
60789
|
+
*/
|
|
60790
|
+
function wrapSessionStartLines(sessionIdExpression, statements, operator = "await") {
|
|
60791
|
+
return [
|
|
60792
|
+
`${operator} __rulesyncSessionStart(${sessionIdExpression}, async (__rulesyncResults) => {`,
|
|
60793
|
+
...statements.map((line) => ` ${line}`),
|
|
60794
|
+
"});"
|
|
60795
|
+
];
|
|
60796
|
+
}
|
|
60566
60797
|
function escapeForTemplateLiteral(command) {
|
|
60567
60798
|
return command.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$\{/g, "\\${");
|
|
60568
60799
|
}
|
|
@@ -60623,6 +60854,59 @@ function warnIgnoredFailClosed({ config, supportedEvents, toolConfigKey, logger
|
|
|
60623
60854
|
}
|
|
60624
60855
|
}
|
|
60625
60856
|
}
|
|
60857
|
+
/**
|
|
60858
|
+
* Canonical (Claude Code) tool names mapped to the lowercase tool ids OpenCode
|
|
60859
|
+
* 1.x and its forks (Kilo, MiMo Code) pass as `input.tool`, which a matcher is
|
|
60860
|
+
* tested against case-sensitively. The shell tool is `bash` here, the same id
|
|
60861
|
+
* the shell events gate on (see {@link SHELL_EVENT_TOOL_GATES}).
|
|
60862
|
+
* @see https://opencode.ai/docs/plugins/
|
|
60863
|
+
*/
|
|
60864
|
+
const CANONICAL_TO_OPENCODE_V1_TOOL_NAMES = {
|
|
60865
|
+
Bash: "bash",
|
|
60866
|
+
Read: "read",
|
|
60867
|
+
Write: "write",
|
|
60868
|
+
Edit: "edit"
|
|
60869
|
+
};
|
|
60870
|
+
/**
|
|
60871
|
+
* A matcher made only of plain names joined by `|`, which Claude Code matches
|
|
60872
|
+
* as an exact tool name list rather than as a regex.
|
|
60873
|
+
*/
|
|
60874
|
+
const PLAIN_NAME_MATCHER_PATTERN = /^[A-Za-z0-9_]+(?:\|[A-Za-z0-9_]+)*$/;
|
|
60875
|
+
/**
|
|
60876
|
+
* Build a translator that rewrites the canonical tool names in a matcher
|
|
60877
|
+
* through `toolNames` and warns about a capitalized name left over
|
|
60878
|
+
* (`MultiEdit`, `Glob`), which no lowercase tool id can match. Each distinct
|
|
60879
|
+
* matcher of an event is translated once, so hooks sharing one do not repeat
|
|
60880
|
+
* its warning.
|
|
60881
|
+
*
|
|
60882
|
+
* The plugins test the matcher unanchored, so a translated plain-name matcher
|
|
60883
|
+
* is anchored as `^(?:...)$` to keep Claude Code's exact-name semantics:
|
|
60884
|
+
* otherwise `write` would also match OpenCode's `todowrite`. Regex-style and
|
|
60885
|
+
* untranslated matchers are left as written.
|
|
60886
|
+
*/
|
|
60887
|
+
function createOpencodeMatcherTranslator({ toolNames, toolConfigKey, logger }) {
|
|
60888
|
+
const label = FAIL_CLOSED_TOOL_LABELS[toolConfigKey];
|
|
60889
|
+
const translated = /* @__PURE__ */ new Map();
|
|
60890
|
+
return (matcher, eventName) => {
|
|
60891
|
+
const key = `${eventName}\0${matcher}`;
|
|
60892
|
+
const cached = translated.get(key);
|
|
60893
|
+
if (cached !== void 0) return cached;
|
|
60894
|
+
const replaced = replaceMatcherNames(matcher, toolNames);
|
|
60895
|
+
const result = replaced !== matcher && PLAIN_NAME_MATCHER_PATTERN.test(stripControlChars(matcher)) ? `^(?:${replaced})$` : replaced;
|
|
60896
|
+
const unmatched = capitalizedMatcherNames(result);
|
|
60897
|
+
if (unmatched.length > 0) logger?.warn(`${label} matches hook matchers case-sensitively against lowercase tool names, and ${unmatched.map((name) => quoteValueForWarning(name)).join(", ")} in the ${quoteValueForWarning(eventName)} matcher ${quoteValueForWarning(matcher)} is not translated by rulesync, so it is written as-is and will likely never match. Use the tool name ${label} reports instead.`);
|
|
60898
|
+
translated.set(key, result);
|
|
60899
|
+
return result;
|
|
60900
|
+
};
|
|
60901
|
+
}
|
|
60902
|
+
/** Whether any handler is a `sessionStart` one, whose stdout becomes session context. */
|
|
60903
|
+
function usesSessionContext(handlers) {
|
|
60904
|
+
return handlers.some((handler) => handler.context);
|
|
60905
|
+
}
|
|
60906
|
+
/** The handler fields a canonical event's `sessionStart`-ness adds. */
|
|
60907
|
+
function sessionContextExtrasFor(canonicalEvent) {
|
|
60908
|
+
return canonicalEvent === "sessionStart" ? { context: true } : {};
|
|
60909
|
+
}
|
|
60626
60910
|
/** The per-canonical-event gates and payload every handler of it carries. */
|
|
60627
60911
|
function handlerExtrasFor(canonicalEvent) {
|
|
60628
60912
|
const shellGate = SHELL_EVENT_TOOL_GATES[canonicalEvent];
|
|
@@ -60632,14 +60916,15 @@ function handlerExtrasFor(canonicalEvent) {
|
|
|
60632
60916
|
event: canonicalEvent,
|
|
60633
60917
|
...shellGate ? { toolGate: shellGate.tool } : {},
|
|
60634
60918
|
...propertyGate ? { propertyGate } : {},
|
|
60635
|
-
...payload ? { payload } : {}
|
|
60919
|
+
...payload ? { payload } : {},
|
|
60920
|
+
...sessionContextExtrasFor(canonicalEvent)
|
|
60636
60921
|
};
|
|
60637
60922
|
}
|
|
60638
60923
|
/**
|
|
60639
60924
|
* Group the effective hooks into named (tool.execute.*) and generic event
|
|
60640
60925
|
* handler groups, keyed by tool event name. Mutates the supplied groups.
|
|
60641
60926
|
*/
|
|
60642
|
-
function collectOpencodeStyleHandlers({ effectiveHooks, eventMap, namedEventHandlers, genericEventHandlers }) {
|
|
60927
|
+
function collectOpencodeStyleHandlers({ effectiveHooks, eventMap, namedEventHandlers, genericEventHandlers, translateMatcher }) {
|
|
60643
60928
|
for (const [canonicalEvent, definitions] of Object.entries(effectiveHooks)) {
|
|
60644
60929
|
const shellGate = SHELL_EVENT_TOOL_GATES[canonicalEvent];
|
|
60645
60930
|
const extras = handlerExtrasFor(canonicalEvent);
|
|
@@ -60647,6 +60932,7 @@ function collectOpencodeStyleHandlers({ effectiveHooks, eventMap, namedEventHand
|
|
|
60647
60932
|
if (!toolEvent) continue;
|
|
60648
60933
|
const isNamedHook = Object.hasOwn(NAMED_HOOK_MATCHER_SUBJECTS, toolEvent);
|
|
60649
60934
|
const matcherSupported = !shellGate && isNamedHook && NAMED_HOOK_MATCHER_SUBJECTS[toolEvent] !== null;
|
|
60935
|
+
const matchesToolName = NAMED_HOOK_MATCHER_SUBJECTS[toolEvent] === "input.tool";
|
|
60650
60936
|
const handlers = [];
|
|
60651
60937
|
for (const def of definitions) {
|
|
60652
60938
|
if ((def.type ?? "command") !== "command") continue;
|
|
@@ -60654,7 +60940,7 @@ function collectOpencodeStyleHandlers({ effectiveHooks, eventMap, namedEventHand
|
|
|
60654
60940
|
if (def.matcher && !matcherSupported) continue;
|
|
60655
60941
|
handlers.push({
|
|
60656
60942
|
command: def.command,
|
|
60657
|
-
matcher: def.matcher ? def.matcher : void 0,
|
|
60943
|
+
matcher: def.matcher ? matchesToolName ? translateMatcher(def.matcher, canonicalEvent) : def.matcher : void 0,
|
|
60658
60944
|
blocking: BLOCKING_HOOKS.has(toolEvent),
|
|
60659
60945
|
...hookTimingOf(def),
|
|
60660
60946
|
inProcess: !isNamedHook,
|
|
@@ -60674,22 +60960,22 @@ function buildGenericEventBodyLines(genericEventHandlers) {
|
|
|
60674
60960
|
const bodyLines = [];
|
|
60675
60961
|
if (Object.keys(genericEventHandlers).length === 0) return bodyLines;
|
|
60676
60962
|
bodyLines.push(" event: async ({ event }) => {");
|
|
60963
|
+
if (Object.values(genericEventHandlers).some(usesSessionContext)) bodyLines.push(` if (event.type === "session.deleted") __rulesyncSessionContexts.delete(${V1_SESSION_ID_EXPRESSION});`);
|
|
60677
60964
|
let isFirst = true;
|
|
60678
60965
|
for (const [eventName, handlers] of Object.entries(genericEventHandlers)) {
|
|
60679
60966
|
bodyLines.push(` ${isFirst ? "if" : "else if"} (event.type === "${eventName}") {`);
|
|
60680
60967
|
isFirst = false;
|
|
60681
|
-
|
|
60968
|
+
const statements = buildPayloadClosureLines({
|
|
60682
60969
|
handlers,
|
|
60683
60970
|
cwdExpression: V1_CWD_EXPRESSION
|
|
60684
|
-
})
|
|
60971
|
+
});
|
|
60685
60972
|
for (const handler of handlers) {
|
|
60686
60973
|
const runStatement = buildRunStatement(handler);
|
|
60687
|
-
if (handler.propertyGate) {
|
|
60688
|
-
|
|
60689
|
-
bodyLines.push(` ${runStatement}`);
|
|
60690
|
-
bodyLines.push(" }");
|
|
60691
|
-
} else bodyLines.push(` ${runStatement}`);
|
|
60974
|
+
if (handler.propertyGate) statements.push(`if (${handler.propertyGate}) {`, ` ${runStatement}`, "}");
|
|
60975
|
+
else statements.push(runStatement);
|
|
60692
60976
|
}
|
|
60977
|
+
const lines = usesSessionContext(handlers) ? wrapSessionStartLines(V1_SESSION_ID_EXPRESSION, statements) : statements;
|
|
60978
|
+
bodyLines.push(...lines.map((line) => ` ${line}`));
|
|
60693
60979
|
bodyLines.push(" }");
|
|
60694
60980
|
}
|
|
60695
60981
|
bodyLines.push(" },");
|
|
@@ -60700,6 +60986,19 @@ function stdinPayloadVariable(stdinEvent) {
|
|
|
60700
60986
|
}
|
|
60701
60987
|
/** The `cwd` a V1 payload reports: the session directory, else the process's. */
|
|
60702
60988
|
const V1_CWD_EXPRESSION = "directory ?? process.cwd()";
|
|
60989
|
+
/** The session a V1 `session.created` / `session.deleted` event is about. */
|
|
60990
|
+
const V1_SESSION_ID_EXPRESSION = "event.properties?.info?.id";
|
|
60991
|
+
/**
|
|
60992
|
+
* The V1 named hook that adds a session's `sessionStart` context to the system
|
|
60993
|
+
* prompt of each of its model requests. OpenCode 1.x, Kilo and MiMo Code all
|
|
60994
|
+
* call it with the request's `sessionID`.
|
|
60995
|
+
*/
|
|
60996
|
+
const V1_SYSTEM_TRANSFORM_LINES = [
|
|
60997
|
+
" \"experimental.chat.system.transform\": async (input, output) => {",
|
|
60998
|
+
" const context = await __rulesyncSessionContext(input?.sessionID);",
|
|
60999
|
+
" if (context && Array.isArray(output?.system)) output.system.push(context);",
|
|
61000
|
+
" },"
|
|
61001
|
+
];
|
|
60703
61002
|
/** Lazily serialized closures for the payloads the handlers use (internal tables only). */
|
|
60704
61003
|
function buildPayloadClosureLines({ handlers, cwdExpression }) {
|
|
60705
61004
|
const payloads = /* @__PURE__ */ new Map();
|
|
@@ -60727,20 +61026,27 @@ function buildRunStatement(handler) {
|
|
|
60727
61026
|
const failClosed = handler.failClosed === void 0 ? "" : `, ${handler.failClosed}`;
|
|
60728
61027
|
return `${PRE_TOOL_USE_RESULT_HELPER}(await __rulesyncRunCommand({ command: ${command}, input: ${input}, seconds: ${handler.timeout} })${failClosed});`;
|
|
60729
61028
|
}
|
|
60730
|
-
|
|
61029
|
+
const run = `await __rulesyncRunHook({ ${[
|
|
60731
61030
|
`label: ${JSON.stringify(handler.event)}`,
|
|
60732
61031
|
`command: ${command}`,
|
|
60733
61032
|
`input: ${input}`,
|
|
60734
61033
|
`blocking: ${handler.blocking}`,
|
|
60735
61034
|
`seconds: ${handler.timeout}`,
|
|
60736
|
-
...handler.inProcess ? ["inProcess: true"] : []
|
|
60737
|
-
|
|
61035
|
+
...handler.inProcess ? ["inProcess: true"] : [],
|
|
61036
|
+
...handler.context ? ["context: true"] : []
|
|
61037
|
+
].join(", ")} })`;
|
|
61038
|
+
return handler.context ? `__rulesyncResults.push(${run});` : `${run};`;
|
|
60738
61039
|
}
|
|
60739
61040
|
/** The helpers a plugin body defines before its handlers, run in `cwdExpression`. */
|
|
60740
61041
|
function buildRunHelperLines({ handlers, cwdExpression }) {
|
|
60741
61042
|
if (handlers.length === 0) return [];
|
|
60742
61043
|
const usesPreToolUse = handlers.some((handler) => handler.payload?.name === "PreToolUse");
|
|
60743
|
-
|
|
61044
|
+
const usesContext = usesSessionContext(handlers);
|
|
61045
|
+
return [
|
|
61046
|
+
...buildRunHelperLinesFor(cwdExpression),
|
|
61047
|
+
...usesPreToolUse ? ["", ...PRE_TOOL_USE_RESULT_HELPER_LINES] : [],
|
|
61048
|
+
...usesContext ? ["", ...SESSION_CONTEXT_HELPER_LINES] : []
|
|
61049
|
+
];
|
|
60744
61050
|
}
|
|
60745
61051
|
/** Emit the named (`tool.execute.*`) handler blocks. */
|
|
60746
61052
|
function buildNamedEventBodyLines(namedEventHandlers) {
|
|
@@ -60798,7 +61104,7 @@ function wrapInExportShape({ preambleLines, bodyLines, exportStyle }) {
|
|
|
60798
61104
|
lines.push("");
|
|
60799
61105
|
return lines;
|
|
60800
61106
|
}
|
|
60801
|
-
function generateOpencodeStylePluginCode(config, supportedEvents, toolConfigKey, eventMap, exportStyle = "named") {
|
|
61107
|
+
function generateOpencodeStylePluginCode(config, supportedEvents, toolConfigKey, eventMap, exportStyle = "named", logger) {
|
|
60802
61108
|
const supported = new Set(supportedEvents);
|
|
60803
61109
|
const configHooks = {
|
|
60804
61110
|
...config.hooks,
|
|
@@ -60812,9 +61118,19 @@ function generateOpencodeStylePluginCode(config, supportedEvents, toolConfigKey,
|
|
|
60812
61118
|
effectiveHooks,
|
|
60813
61119
|
eventMap,
|
|
60814
61120
|
namedEventHandlers,
|
|
60815
|
-
genericEventHandlers
|
|
61121
|
+
genericEventHandlers,
|
|
61122
|
+
translateMatcher: createOpencodeMatcherTranslator({
|
|
61123
|
+
toolNames: CANONICAL_TO_OPENCODE_V1_TOOL_NAMES,
|
|
61124
|
+
toolConfigKey,
|
|
61125
|
+
logger
|
|
61126
|
+
})
|
|
60816
61127
|
});
|
|
60817
|
-
const
|
|
61128
|
+
const usesContext = Object.values(genericEventHandlers).some(usesSessionContext);
|
|
61129
|
+
const bodyLines = [
|
|
61130
|
+
...buildGenericEventBodyLines(genericEventHandlers),
|
|
61131
|
+
...buildNamedEventBodyLines(namedEventHandlers),
|
|
61132
|
+
...usesContext ? V1_SYSTEM_TRANSFORM_LINES : []
|
|
61133
|
+
];
|
|
60818
61134
|
return wrapInExportShape({
|
|
60819
61135
|
preambleLines: buildRunHelperLines({
|
|
60820
61136
|
handlers: [...Object.values(namedEventHandlers), ...Object.values(genericEventHandlers)].flat(),
|
|
@@ -60861,7 +61177,7 @@ var KiloHooks = class KiloHooks extends ToolHooks {
|
|
|
60861
61177
|
toolConfigKey: "kilo",
|
|
60862
61178
|
logger
|
|
60863
61179
|
});
|
|
60864
|
-
const fileContent = generateOpencodeStylePluginCode(config, KILO_HOOK_EVENTS, "kilo", CANONICAL_TO_KILO_EVENT_NAMES, "default");
|
|
61180
|
+
const fileContent = generateOpencodeStylePluginCode(config, KILO_HOOK_EVENTS, "kilo", CANONICAL_TO_KILO_EVENT_NAMES, "default", logger);
|
|
60865
61181
|
const paths = KiloHooks.getSettablePaths({ global });
|
|
60866
61182
|
return new KiloHooks({
|
|
60867
61183
|
outputRoot,
|
|
@@ -61127,6 +61443,37 @@ const KiroIdeHooksFileSchema = z.looseObject({
|
|
|
61127
61443
|
hooks: z.optional(z.array(KiroIdeHookEntrySchema))
|
|
61128
61444
|
});
|
|
61129
61445
|
/**
|
|
61446
|
+
* Triggers on which Kiro runs only `command` actions.
|
|
61447
|
+
* @see https://kiro.dev/docs/hooks/types/#permission-request
|
|
61448
|
+
*/
|
|
61449
|
+
const KIRO_COMMAND_ONLY_TRIGGERS = /* @__PURE__ */ new Set(["PermissionRequest"]);
|
|
61450
|
+
/**
|
|
61451
|
+
* Whether an imported entry is an `agent` action on a command-only trigger
|
|
61452
|
+
* (Kiro also accepts the camelCase `permissionRequest` spelling). Kiro never
|
|
61453
|
+
* runs such a hook, so importing it would hand other targets an LLM
|
|
61454
|
+
* permission hook the user never had in effect.
|
|
61455
|
+
*/
|
|
61456
|
+
function isAgentActionOnCommandOnlyTrigger(entry) {
|
|
61457
|
+
if (entry.action?.type !== "agent" || entry.trigger === void 0) return false;
|
|
61458
|
+
const trigger = lookupOwn({
|
|
61459
|
+
record: CANONICAL_TO_KIRO_IDE_EVENT_NAMES,
|
|
61460
|
+
key: entry.trigger
|
|
61461
|
+
}) ?? entry.trigger;
|
|
61462
|
+
return KIRO_COMMAND_ONLY_TRIGGERS.has(trigger);
|
|
61463
|
+
}
|
|
61464
|
+
/**
|
|
61465
|
+
* Drop `prompt` definitions on a {@link KIRO_COMMAND_ONLY_TRIGGERS} trigger with
|
|
61466
|
+
* a warning, rather than writing an `agent` action Kiro never runs.
|
|
61467
|
+
*/
|
|
61468
|
+
function dropPromptHooksOnCommandOnlyTrigger(trigger, definitions, logger) {
|
|
61469
|
+
if (!KIRO_COMMAND_ONLY_TRIGGERS.has(trigger)) return definitions;
|
|
61470
|
+
return definitions.filter((def) => {
|
|
61471
|
+
if (def.type !== "prompt") return true;
|
|
61472
|
+
logger?.warn(`Skipped a prompt hook on Kiro's "${trigger}" trigger: Kiro runs only command actions on it.`);
|
|
61473
|
+
return false;
|
|
61474
|
+
});
|
|
61475
|
+
}
|
|
61476
|
+
/**
|
|
61130
61477
|
* Build the Kiro IDE hook entries for a single canonical event's definitions.
|
|
61131
61478
|
*
|
|
61132
61479
|
* `command`-type definitions become `{ type: "command", command }` actions and
|
|
@@ -61181,7 +61528,7 @@ const KIRO_HOOKS_OVERRIDE_KEY = "kiro";
|
|
|
61181
61528
|
* that is actually read.
|
|
61182
61529
|
*/
|
|
61183
61530
|
const KIRO_HOOKS_IGNORED_OVERRIDE_KEYS = ["kiro-ide", "kiro-cli"];
|
|
61184
|
-
function canonicalToKiroIdeHooks(config) {
|
|
61531
|
+
function canonicalToKiroIdeHooks(config, logger) {
|
|
61185
61532
|
const kiroIdeSupported = new Set(KIRO_IDE_HOOK_EVENTS);
|
|
61186
61533
|
const sharedHooks = {};
|
|
61187
61534
|
for (const [event, defs] of Object.entries(config.hooks)) if (kiroIdeSupported.has(event)) sharedHooks[event] = defs;
|
|
@@ -61198,7 +61545,7 @@ function canonicalToKiroIdeHooks(config) {
|
|
|
61198
61545
|
record: KIRO_LEGACY_TO_KIRO_IDE_TRIGGER_NAMES,
|
|
61199
61546
|
key: eventName
|
|
61200
61547
|
}) ?? eventName;
|
|
61201
|
-
entries.push(...buildKiroIdeEntriesForEvent(trigger, definitions));
|
|
61548
|
+
entries.push(...buildKiroIdeEntriesForEvent(trigger, dropPromptHooksOnCommandOnlyTrigger(trigger, definitions, logger)));
|
|
61202
61549
|
}
|
|
61203
61550
|
return entries;
|
|
61204
61551
|
}
|
|
@@ -61210,25 +61557,35 @@ function copyOptionalHookFields({ entry, def }) {
|
|
|
61210
61557
|
if (entry.enabled === false) def.enabled = false;
|
|
61211
61558
|
if (entry.confirm !== void 0 && entry.confirm !== null) def.confirm = omitPrototypePollutionKeysDeep(entry.confirm);
|
|
61212
61559
|
}
|
|
61213
|
-
|
|
61560
|
+
/**
|
|
61561
|
+
* The canonical `type` plus `command` / `prompt` of an imported Kiro action, or
|
|
61562
|
+
* `undefined` when the action carries nothing to run.
|
|
61563
|
+
*/
|
|
61564
|
+
function toCanonicalAction(action) {
|
|
61565
|
+
if (action.type === "command") return action.command ? {
|
|
61566
|
+
type: "command",
|
|
61567
|
+
command: action.command
|
|
61568
|
+
} : void 0;
|
|
61569
|
+
return action.prompt ? {
|
|
61570
|
+
type: "prompt",
|
|
61571
|
+
prompt: action.prompt
|
|
61572
|
+
} : void 0;
|
|
61573
|
+
}
|
|
61574
|
+
function kiroIdeHooksToCanonical(entries, logger) {
|
|
61214
61575
|
const canonical = {};
|
|
61215
61576
|
for (const entry of entries) {
|
|
61216
61577
|
if (entry.trigger === void 0 || entry.action === void 0) continue;
|
|
61578
|
+
if (isAgentActionOnCommandOnlyTrigger(entry)) {
|
|
61579
|
+
logger?.warn(`Skipped an agent hook on Kiro's "${entry.trigger}" trigger: Kiro runs only command actions on it.`);
|
|
61580
|
+
continue;
|
|
61581
|
+
}
|
|
61217
61582
|
const eventName = lookupOwn({
|
|
61218
61583
|
record: KIRO_IDE_TO_CANONICAL_EVENT_NAMES,
|
|
61219
61584
|
key: entry.trigger
|
|
61220
61585
|
}) ?? entry.trigger;
|
|
61221
61586
|
if (isPrototypePollutionKey(eventName)) continue;
|
|
61222
|
-
const def =
|
|
61223
|
-
if (
|
|
61224
|
-
if (!entry.action.command) continue;
|
|
61225
|
-
def.type = "command";
|
|
61226
|
-
def.command = entry.action.command;
|
|
61227
|
-
} else {
|
|
61228
|
-
if (!entry.action.prompt) continue;
|
|
61229
|
-
def.type = "prompt";
|
|
61230
|
-
def.prompt = entry.action.prompt;
|
|
61231
|
-
}
|
|
61587
|
+
const def = toCanonicalAction(entry.action);
|
|
61588
|
+
if (def === void 0) continue;
|
|
61232
61589
|
if (entry.name !== void 0 && entry.name !== null) def.name = entry.name;
|
|
61233
61590
|
if (entry.description !== void 0 && entry.description !== null) def.description = entry.description;
|
|
61234
61591
|
if (entry.matcher !== void 0 && entry.matcher !== null && entry.matcher !== "") def.matcher = entry.matcher;
|
|
@@ -61294,7 +61651,7 @@ var KiroIdeHooks = class extends ToolHooks {
|
|
|
61294
61651
|
if (config[ignoredKey]?.hooks === void 0) continue;
|
|
61295
61652
|
logger?.warn(`The "${ignoredKey}.hooks" block in ${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.`);
|
|
61296
61653
|
}
|
|
61297
|
-
const hooks = canonicalToKiroIdeHooks(config);
|
|
61654
|
+
const hooks = canonicalToKiroIdeHooks(config, logger);
|
|
61298
61655
|
const fileContent = JSON.stringify({
|
|
61299
61656
|
version: "v1",
|
|
61300
61657
|
hooks
|
|
@@ -61311,7 +61668,7 @@ var KiroIdeHooks = class extends ToolHooks {
|
|
|
61311
61668
|
const hooks = kiroIdeHooksToCanonical(this.parseFileContentOrThrow({
|
|
61312
61669
|
displayName: "Kiro IDE",
|
|
61313
61670
|
parse: (fileContent) => KiroIdeHooksFileSchema.parse(JSON.parse(fileContent))
|
|
61314
|
-
}).hooks ?? []);
|
|
61671
|
+
}).hooks ?? [], logger);
|
|
61315
61672
|
return this.toRulesyncHooksDefault({ fileContent: JSON.stringify(buildImportedHooksConfig({
|
|
61316
61673
|
logger,
|
|
61317
61674
|
hooks,
|
|
@@ -61684,6 +62041,21 @@ var LettacodeHooks = class LettacodeHooks extends ToolHooks {
|
|
|
61684
62041
|
/** Tool name OpenCode V2 gives its shell tool (V1 called it `bash`). */
|
|
61685
62042
|
const OPENCODE_V2_SHELL_TOOL = "shell";
|
|
61686
62043
|
/**
|
|
62044
|
+
* Canonical (Claude Code) tool names mapped to the lowercase names OpenCode 2.x
|
|
62045
|
+
* reports in `event.tool`, which a matcher is tested against case-sensitively.
|
|
62046
|
+
* Observed on OpenCode 2.3.2: a `preToolUse` hook fires with `read`, `write`,
|
|
62047
|
+
* `edit` and `shell`, so a canonical `Read|Edit|Write` or `Bash` never matched.
|
|
62048
|
+
* `Bash` becomes the V2 name `shell`; the generated helper still accepts the
|
|
62049
|
+
* V1 name `bash` for a matcher written that way.
|
|
62050
|
+
* https://opencode.ai/v2/docs/build/plugins/
|
|
62051
|
+
*/
|
|
62052
|
+
const CANONICAL_TO_OPENCODE_V2_TOOL_NAMES = {
|
|
62053
|
+
Bash: OPENCODE_V2_SHELL_TOOL,
|
|
62054
|
+
Read: "read",
|
|
62055
|
+
Write: "write",
|
|
62056
|
+
Edit: "edit"
|
|
62057
|
+
};
|
|
62058
|
+
/**
|
|
61687
62059
|
* Per-canonical-event conditions the generated handler gates on, because the
|
|
61688
62060
|
* hook point or event it shares fires more broadly than the canonical event:
|
|
61689
62061
|
* - the shell events run only for the `shell` tool's calls;
|
|
@@ -61743,6 +62115,27 @@ const TOOL_MATCHER_HELPER_LINES = [
|
|
|
61743
62115
|
];
|
|
61744
62116
|
/** Hook points whose `matcher` is tested against the tool name. */
|
|
61745
62117
|
const OPENCODE_V2_MATCHABLE_HOOKS = /* @__PURE__ */ new Set(["tool:execute.before", "tool:execute.after"]);
|
|
62118
|
+
/** The session a V2 `session.created` / `session.deleted` event is about. */
|
|
62119
|
+
const V2_SESSION_ID_EXPRESSION = "event.data?.sessionID";
|
|
62120
|
+
/**
|
|
62121
|
+
* The `session:context` registration that adds a session's `sessionStart`
|
|
62122
|
+
* context to the system prompt of each of its agent-loop model requests. A
|
|
62123
|
+
* host that cannot register it (no `ctx.session.hook`, or no `context` hook
|
|
62124
|
+
* point) gets a logged error instead of a setup throw, so the plugin's other
|
|
62125
|
+
* hooks, `preToolUse` guards included, still load.
|
|
62126
|
+
*/
|
|
62127
|
+
const SESSION_CONTEXT_HOOK_LINES = [
|
|
62128
|
+
"try {",
|
|
62129
|
+
" __rulesyncRegistrations.push(",
|
|
62130
|
+
" await ctx.session.hook(\"context\", async (event) => {",
|
|
62131
|
+
" const context = await __rulesyncSessionContext(event?.sessionID);",
|
|
62132
|
+
" if (context && Array.isArray(event?.system)) event.system.push({ type: \"text\", text: context });",
|
|
62133
|
+
" }),",
|
|
62134
|
+
" );",
|
|
62135
|
+
"} catch (error) {",
|
|
62136
|
+
" console.error(\"[rulesync-hooks] could not register the session context hook; sessionStart output does not reach the model:\", error);",
|
|
62137
|
+
"}"
|
|
62138
|
+
];
|
|
61746
62139
|
/** Wrap a statement in the handler's gate and matcher conditions. */
|
|
61747
62140
|
function wrapInConditions(handler, statement, indent) {
|
|
61748
62141
|
const conditions = [];
|
|
@@ -61779,32 +62172,52 @@ function buildHookRegistrationLines(hookPoint, handlers) {
|
|
|
61779
62172
|
* in its own try/catch, so a throw while evaluating its gate or building its
|
|
61780
62173
|
* payload, outside `__rulesyncRunHook`, is logged the same way. The
|
|
61781
62174
|
* subscription passes `types` so the server delivers only the handled events.
|
|
62175
|
+
*
|
|
62176
|
+
* The loop itself never waits for a command, so a slow handler cannot hold back
|
|
62177
|
+
* the events after it: handlers run one after another on
|
|
62178
|
+
* `__rulesyncEventQueue`, in event order, while `sessionStart` starts right
|
|
62179
|
+
* away, outside the queue (so it can overlap other event commands), and its
|
|
62180
|
+
* session's pending context is registered before that session's first model
|
|
62181
|
+
* request asks for it. Handlers still queued at dispose are skipped.
|
|
61782
62182
|
*/
|
|
61783
|
-
function buildEventLoopLines(eventHandlers) {
|
|
62183
|
+
function buildEventLoopLines(eventHandlers, usesContext) {
|
|
61784
62184
|
const lines = [];
|
|
61785
|
-
const
|
|
62185
|
+
const eventTypes = new Set(eventHandlers.keys());
|
|
62186
|
+
if (usesContext) eventTypes.add("session.deleted");
|
|
62187
|
+
const types = [...eventTypes].map((eventType) => JSON.stringify(eventType)).join(", ");
|
|
61786
62188
|
lines.push("const __rulesyncEvents = new AbortController();");
|
|
62189
|
+
lines.push("let __rulesyncEventQueue = Promise.resolve();");
|
|
61787
62190
|
lines.push("void (async () => {");
|
|
61788
62191
|
lines.push(" for await (const event of ctx.event.subscribe({");
|
|
61789
62192
|
lines.push(` types: [${types}],`);
|
|
61790
62193
|
lines.push(" signal: __rulesyncEvents.signal,");
|
|
61791
62194
|
lines.push(" })) {");
|
|
62195
|
+
if (usesContext) lines.push(` if (event.type === "session.deleted") __rulesyncSessionContexts.delete(${V2_SESSION_ID_EXPRESSION});`);
|
|
61792
62196
|
let isFirst = true;
|
|
61793
62197
|
for (const [eventType, handlers] of eventHandlers) {
|
|
61794
62198
|
lines.push(` ${isFirst ? "if" : "} else if"} (event.type === "${eventType}") {`);
|
|
61795
62199
|
isFirst = false;
|
|
61796
|
-
|
|
62200
|
+
const statements = buildPayloadClosureLines({
|
|
61797
62201
|
handlers,
|
|
61798
62202
|
cwdExpression: "directory"
|
|
61799
|
-
})
|
|
62203
|
+
});
|
|
61800
62204
|
for (const handler of handlers) {
|
|
61801
|
-
|
|
61802
|
-
|
|
61803
|
-
|
|
62205
|
+
statements.push("try {");
|
|
62206
|
+
statements.push(...wrapInConditions(handler, buildRunStatement(handler), " "));
|
|
62207
|
+
statements.push("} catch (error) {");
|
|
61804
62208
|
const message = JSON.stringify(`[rulesync-hooks] ${handler.event} hook failed:`);
|
|
61805
|
-
|
|
61806
|
-
|
|
61807
|
-
}
|
|
62209
|
+
statements.push(` console.error(${message}, error);`);
|
|
62210
|
+
statements.push("}");
|
|
62211
|
+
}
|
|
62212
|
+
const body = usesSessionContext(handlers) ? wrapSessionStartLines(V2_SESSION_ID_EXPRESSION, statements, "void") : [
|
|
62213
|
+
"__rulesyncEventQueue = __rulesyncEventQueue",
|
|
62214
|
+
" .then(async () => {",
|
|
62215
|
+
" if (__rulesyncEvents.signal.aborted) return;",
|
|
62216
|
+
...statements.map((line) => ` ${line}`),
|
|
62217
|
+
" })",
|
|
62218
|
+
` .catch((error) => console.error(${JSON.stringify(`[rulesync-hooks] ${eventType} event hook failed:`)}, error));`
|
|
62219
|
+
];
|
|
62220
|
+
lines.push(...body.map((line) => ` ${line}`));
|
|
61808
62221
|
}
|
|
61809
62222
|
lines.push(" }");
|
|
61810
62223
|
lines.push(" }");
|
|
@@ -61819,7 +62232,7 @@ function isBlockingOpencodeV2Target(target) {
|
|
|
61819
62232
|
return !target.startsWith("event:") && target !== "tool:execute.after";
|
|
61820
62233
|
}
|
|
61821
62234
|
/** Build the handlers of one canonical event's command definitions. */
|
|
61822
|
-
function buildHandlersFor({ canonicalEvent, definitions, target }) {
|
|
62235
|
+
function buildHandlersFor({ canonicalEvent, definitions, target, translateMatcher }) {
|
|
61823
62236
|
const gate = OPENCODE_V2_HANDLER_GATES[canonicalEvent];
|
|
61824
62237
|
const payload = OPENCODE_V2_STDIN_PAYLOADS[canonicalEvent];
|
|
61825
62238
|
const matcherSupported = !(canonicalEvent === "beforeShellExecution" || canonicalEvent === "afterShellExecution") && OPENCODE_V2_MATCHABLE_HOOKS.has(target);
|
|
@@ -61833,9 +62246,10 @@ function buildHandlersFor({ canonicalEvent, definitions, target }) {
|
|
|
61833
62246
|
event: canonicalEvent,
|
|
61834
62247
|
blocking: isBlockingOpencodeV2Target(target),
|
|
61835
62248
|
...hookTimingOf(def),
|
|
61836
|
-
...def.matcher ? { matcher: def.matcher } : {},
|
|
62249
|
+
...def.matcher ? { matcher: translateMatcher(def.matcher, canonicalEvent) } : {},
|
|
61837
62250
|
...gate ? { gate } : {},
|
|
61838
|
-
...payload ? { payload } : {}
|
|
62251
|
+
...payload ? { payload } : {},
|
|
62252
|
+
...sessionContextExtrasFor(canonicalEvent)
|
|
61839
62253
|
});
|
|
61840
62254
|
}
|
|
61841
62255
|
return handlers;
|
|
@@ -61852,25 +62266,33 @@ function buildSetupBodyLines({ hookHandlers, eventHandlers }) {
|
|
|
61852
62266
|
})
|
|
61853
62267
|
];
|
|
61854
62268
|
if ([...hookHandlers.values()].some((handlers) => handlers.some((handler) => handler.matcher !== void 0))) body.push("", ...TOOL_MATCHER_HELPER_LINES);
|
|
62269
|
+
const usesContext = [...eventHandlers.values()].some(usesSessionContext);
|
|
62270
|
+
const registers = hookHandlers.size > 0 || usesContext;
|
|
61855
62271
|
const cleanup = [];
|
|
61856
|
-
if (
|
|
62272
|
+
if (registers) {
|
|
61857
62273
|
body.push("", "const __rulesyncRegistrations = [];");
|
|
61858
62274
|
for (const [hookPoint, handlers] of hookHandlers) body.push(...buildHookRegistrationLines(hookPoint, handlers));
|
|
62275
|
+
if (usesContext) body.push(...SESSION_CONTEXT_HOOK_LINES);
|
|
61859
62276
|
}
|
|
61860
62277
|
if (eventHandlers.size > 0) {
|
|
61861
|
-
body.push("", ...buildEventLoopLines(eventHandlers));
|
|
62278
|
+
body.push("", ...buildEventLoopLines(eventHandlers, usesContext));
|
|
61862
62279
|
cleanup.push(" __rulesyncEvents.abort();");
|
|
61863
62280
|
}
|
|
61864
|
-
if (
|
|
62281
|
+
if (registers) cleanup.push(" await Promise.all(__rulesyncRegistrations.map((registration) => registration.dispose()));");
|
|
61865
62282
|
body.push("", "return async () => {", ...cleanup, "};");
|
|
61866
62283
|
return body;
|
|
61867
62284
|
}
|
|
61868
|
-
function generateOpencodeV2PluginCode({ config, supportedEvents, toolConfigKey, eventMap }) {
|
|
62285
|
+
function generateOpencodeV2PluginCode({ config, supportedEvents, toolConfigKey, eventMap, logger }) {
|
|
61869
62286
|
const supported = new Set(supportedEvents);
|
|
61870
62287
|
const configHooks = {
|
|
61871
62288
|
...config.hooks,
|
|
61872
62289
|
...config[toolConfigKey]?.hooks
|
|
61873
62290
|
};
|
|
62291
|
+
const translateMatcher = createOpencodeMatcherTranslator({
|
|
62292
|
+
toolNames: CANONICAL_TO_OPENCODE_V2_TOOL_NAMES,
|
|
62293
|
+
toolConfigKey,
|
|
62294
|
+
logger
|
|
62295
|
+
});
|
|
61874
62296
|
const hookHandlers = /* @__PURE__ */ new Map();
|
|
61875
62297
|
const eventHandlers = /* @__PURE__ */ new Map();
|
|
61876
62298
|
for (const [canonicalEvent, definitions] of Object.entries(configHooks)) {
|
|
@@ -61880,7 +62302,8 @@ function generateOpencodeV2PluginCode({ config, supportedEvents, toolConfigKey,
|
|
|
61880
62302
|
const handlers = buildHandlersFor({
|
|
61881
62303
|
canonicalEvent,
|
|
61882
62304
|
definitions,
|
|
61883
|
-
target
|
|
62305
|
+
target,
|
|
62306
|
+
translateMatcher
|
|
61884
62307
|
});
|
|
61885
62308
|
if (handlers.length === 0) continue;
|
|
61886
62309
|
const isEvent = target.startsWith("event:");
|
|
@@ -61935,8 +62358,9 @@ var OpencodeHooks = class extends ToolHooks {
|
|
|
61935
62358
|
config,
|
|
61936
62359
|
supportedEvents: OPENCODE_V2_HOOK_EVENTS,
|
|
61937
62360
|
toolConfigKey: this.layout.toolTarget,
|
|
61938
|
-
eventMap: CANONICAL_TO_OPENCODE_V2_EVENT_NAMES
|
|
61939
|
-
|
|
62361
|
+
eventMap: CANONICAL_TO_OPENCODE_V2_EVENT_NAMES,
|
|
62362
|
+
logger
|
|
62363
|
+
}) : generateOpencodeStylePluginCode(config, OPENCODE_HOOK_EVENTS, this.layout.toolTarget, CANONICAL_TO_OPENCODE_EVENT_NAMES, "named", logger);
|
|
61940
62364
|
const paths = this.getSettablePaths({ global });
|
|
61941
62365
|
return new this({
|
|
61942
62366
|
outputRoot,
|
|
@@ -72701,12 +73125,22 @@ const MAX_REMOVE_EMPTY_ENTRIES_DEPTH = 32;
|
|
|
72701
73125
|
*/
|
|
72702
73126
|
const GROK_DISABLED_MCP_TOOLS_KEY = "disabled_mcp_tools";
|
|
72703
73127
|
/**
|
|
73128
|
+
* Grok 1.0.88+ runs a command that prints JSON headers at every connect of an
|
|
73129
|
+
* HTTP/SSE server. In `config.toml` the key is `headers_helper`; the camelCase
|
|
73130
|
+
* `headersHelper` (rulesync's canonical spelling) is documented for
|
|
73131
|
+
* `.mcp.json` only, so it is renamed in both directions.
|
|
73132
|
+
* (Grok user guide `07-mcp-servers.md`, "Headers from a command".)
|
|
73133
|
+
*/
|
|
73134
|
+
const CANONICAL_HEADERS_HELPER_KEY = "headersHelper";
|
|
73135
|
+
const GROK_HEADERS_HELPER_KEY = "headers_helper";
|
|
73136
|
+
/**
|
|
72704
73137
|
* Grok Build stores MCP servers in `config.toml` under a `[mcp_servers.<name>]`
|
|
72705
73138
|
* table. Verified against `grok mcp add` (grok 0.2.54): a stdio server emits
|
|
72706
73139
|
* `command`, `args`, `enabled = true`, and an `[mcp_servers.<name>.env]` table;
|
|
72707
73140
|
* a remote server emits `url` and `enabled`. Unlike Codex CLI, Grok uses a
|
|
72708
|
-
* literal `env` table (not the `env_vars` passthrough list), so the
|
|
72709
|
-
*
|
|
73141
|
+
* literal `env` table (not the `env_vars` passthrough list), so the field
|
|
73142
|
+
* renames are `disabled` (rulesync) ↔ `enabled = false` (grok) and
|
|
73143
|
+
* `headersHelper` ↔ `headers_helper`. `disabledTools`
|
|
72710
73144
|
* never lands in the server table: it is lifted into the top-level
|
|
72711
73145
|
* `[disabled_mcp_tools]` table by `buildDisabledMcpTools`.
|
|
72712
73146
|
*/
|
|
@@ -72720,6 +73154,8 @@ function convertToGrokFormat(mcpServers) {
|
|
|
72720
73154
|
if (PROTOTYPE_POLLUTION_KEYS.has(key) || key === "disabledTools") continue;
|
|
72721
73155
|
if (key === "disabled") {
|
|
72722
73156
|
if (value === true) converted["enabled"] = false;
|
|
73157
|
+
} else if (key === CANONICAL_HEADERS_HELPER_KEY) {
|
|
73158
|
+
if (!Object.hasOwn(config, GROK_HEADERS_HELPER_KEY)) converted[GROK_HEADERS_HELPER_KEY] = value;
|
|
72723
73159
|
} else converted[key] = value;
|
|
72724
73160
|
}
|
|
72725
73161
|
result[name] = converted;
|
|
@@ -72735,6 +73171,9 @@ function convertFromGrokFormat(grokMcp) {
|
|
|
72735
73171
|
if (PROTOTYPE_POLLUTION_KEYS.has(key)) continue;
|
|
72736
73172
|
if (key === "enabled") {
|
|
72737
73173
|
if (value === false) converted["disabled"] = true;
|
|
73174
|
+
} else if (key === GROK_HEADERS_HELPER_KEY) converted[CANONICAL_HEADERS_HELPER_KEY] = value;
|
|
73175
|
+
else if (key === CANONICAL_HEADERS_HELPER_KEY) {
|
|
73176
|
+
if (!Object.hasOwn(config, GROK_HEADERS_HELPER_KEY)) converted[CANONICAL_HEADERS_HELPER_KEY] = value;
|
|
72738
73177
|
} else converted[key] = value;
|
|
72739
73178
|
}
|
|
72740
73179
|
result[name] = converted;
|
|
@@ -73850,6 +74289,21 @@ function fromKiroMcpServers(servers) {
|
|
|
73850
74289
|
}];
|
|
73851
74290
|
}));
|
|
73852
74291
|
}
|
|
74292
|
+
/**
|
|
74293
|
+
* Parse an existing user-level `~/.kiro/settings/mcp.json` so a global generate
|
|
74294
|
+
* can merge into it. An unparseable file is refused instead of overwritten:
|
|
74295
|
+
* it is unversioned, so replacing it would lose whatever the user had there.
|
|
74296
|
+
*/
|
|
74297
|
+
function parseExistingKiroMcpConfig(fileContent, configPath) {
|
|
74298
|
+
let parsed;
|
|
74299
|
+
try {
|
|
74300
|
+
parsed = JSON.parse(fileContent);
|
|
74301
|
+
} catch (error) {
|
|
74302
|
+
throw new Error(`Failed to parse Kiro MCP config at ${configPath}: ${formatError(error)}`, { cause: error });
|
|
74303
|
+
}
|
|
74304
|
+
if (!isPlainObject(parsed)) throw new Error(`Failed to parse Kiro MCP config at ${configPath}: expected a JSON object`);
|
|
74305
|
+
return parsed;
|
|
74306
|
+
}
|
|
73853
74307
|
var KiroMcp = class KiroMcp extends ToolMcp {
|
|
73854
74308
|
json;
|
|
73855
74309
|
constructor(params) {
|
|
@@ -73859,13 +74313,26 @@ var KiroMcp = class KiroMcp extends ToolMcp {
|
|
|
73859
74313
|
getJson() {
|
|
73860
74314
|
return this.json;
|
|
73861
74315
|
}
|
|
74316
|
+
/**
|
|
74317
|
+
* The user-level `~/.kiro/settings/mcp.json` also holds settings rulesync
|
|
74318
|
+
* does not manage (such as the top-level `identityProvider` block for
|
|
74319
|
+
* organization sign-in, which Kiro reads only from this file), so it is never
|
|
74320
|
+
* deleted in global mode. The project file is rulesync-managed and may be.
|
|
74321
|
+
* The sweep has no in-place retraction, so a global `--delete` run without a
|
|
74322
|
+
* source leaves the generated `mcpServers` behind; an empty source
|
|
74323
|
+
* (`{ "mcpServers": {} }`) retracts them through the normal merge.
|
|
74324
|
+
* @see https://kiro.dev/docs/mcp/configuration/
|
|
74325
|
+
*/
|
|
74326
|
+
isDeletable() {
|
|
74327
|
+
return !this.global;
|
|
74328
|
+
}
|
|
73862
74329
|
static getSettablePaths() {
|
|
73863
74330
|
return {
|
|
73864
74331
|
relativeDirPath: KIRO_SETTINGS_DIR_PATH,
|
|
73865
74332
|
relativeFilePath: KIRO_MCP_FILE_NAME
|
|
73866
74333
|
};
|
|
73867
74334
|
}
|
|
73868
|
-
static async fromFile({ outputRoot = process.cwd(), validate = true }) {
|
|
74335
|
+
static async fromFile({ outputRoot = process.cwd(), validate = true, global = false }) {
|
|
73869
74336
|
const paths = this.getSettablePaths();
|
|
73870
74337
|
const fileContent = await readFileContentOrNull(join(outputRoot, paths.relativeDirPath, paths.relativeFilePath)) ?? "{\"mcpServers\":{}}";
|
|
73871
74338
|
return new KiroMcp({
|
|
@@ -73873,18 +74340,34 @@ var KiroMcp = class KiroMcp extends ToolMcp {
|
|
|
73873
74340
|
relativeDirPath: paths.relativeDirPath,
|
|
73874
74341
|
relativeFilePath: paths.relativeFilePath,
|
|
73875
74342
|
fileContent,
|
|
73876
|
-
validate
|
|
74343
|
+
validate,
|
|
74344
|
+
global
|
|
73877
74345
|
});
|
|
73878
74346
|
}
|
|
73879
|
-
|
|
74347
|
+
/**
|
|
74348
|
+
* In global mode the generated `mcpServers` are merged into the existing
|
|
74349
|
+
* user-level file, keeping every other top-level key (for example
|
|
74350
|
+
* `identityProvider`). The project file is written from scratch.
|
|
74351
|
+
*/
|
|
74352
|
+
static async fromRulesyncMcp({ outputRoot = process.cwd(), rulesyncMcp, validate = true, global = false }) {
|
|
73880
74353
|
const paths = this.getSettablePaths();
|
|
73881
|
-
const
|
|
74354
|
+
const mcpServers = toKiroMcpServers(rulesyncMcp.getMcpServers());
|
|
74355
|
+
let existing = {};
|
|
74356
|
+
if (global) {
|
|
74357
|
+
const configPath = join(outputRoot, paths.relativeDirPath, paths.relativeFilePath);
|
|
74358
|
+
const existingContent = await readFileContentOrNull(configPath);
|
|
74359
|
+
if (existingContent !== null) existing = parseExistingKiroMcpConfig(existingContent, configPath);
|
|
74360
|
+
}
|
|
73882
74361
|
return new KiroMcp({
|
|
73883
74362
|
outputRoot,
|
|
73884
74363
|
relativeDirPath: paths.relativeDirPath,
|
|
73885
74364
|
relativeFilePath: paths.relativeFilePath,
|
|
73886
|
-
fileContent
|
|
73887
|
-
|
|
74365
|
+
fileContent: JSON.stringify({
|
|
74366
|
+
...existing,
|
|
74367
|
+
mcpServers
|
|
74368
|
+
}, null, 2),
|
|
74369
|
+
validate,
|
|
74370
|
+
global
|
|
73888
74371
|
});
|
|
73889
74372
|
}
|
|
73890
74373
|
toRulesyncMcp() {
|
|
@@ -73892,13 +74375,14 @@ var KiroMcp = class KiroMcp extends ToolMcp {
|
|
|
73892
74375
|
const translated = isMcpServers(mcpServers) ? fromKiroMcpServers(mcpServers) : {};
|
|
73893
74376
|
return this.toRulesyncMcpDefault({ fileContent: JSON.stringify({ mcpServers: translated }, null, 2) });
|
|
73894
74377
|
}
|
|
73895
|
-
static forDeletion({ outputRoot = process.cwd(), relativeDirPath, relativeFilePath }) {
|
|
74378
|
+
static forDeletion({ outputRoot = process.cwd(), relativeDirPath, relativeFilePath, global = false }) {
|
|
73896
74379
|
return new KiroMcp({
|
|
73897
74380
|
outputRoot,
|
|
73898
74381
|
relativeDirPath,
|
|
73899
74382
|
relativeFilePath,
|
|
73900
74383
|
fileContent: "{}",
|
|
73901
|
-
validate: false
|
|
74384
|
+
validate: false,
|
|
74385
|
+
global
|
|
73902
74386
|
});
|
|
73903
74387
|
}
|
|
73904
74388
|
};
|
|
@@ -84348,6 +84832,29 @@ const CLAUDECODE_WIDENING_DEFAULT_MODES = {
|
|
|
84348
84832
|
*/
|
|
84349
84833
|
const CLAUDECODE_PROJECT_SCOPE_IGNORED_DEFAULT_MODES = /* @__PURE__ */ new Set(["auto", "bypassPermissions"]);
|
|
84350
84834
|
/**
|
|
84835
|
+
* The `permissions` fields Claude Code reads only from user or managed settings
|
|
84836
|
+
* (and `--settings`), never from a repository's `.claude/settings.json`, so
|
|
84837
|
+
* they are dropped at project scope and written only under `--global`.
|
|
84838
|
+
* `denyInsteadOfPrompting` (v2.1.319+) only restricts, but committing it to a
|
|
84839
|
+
* project file would promise unattended denials that never happen.
|
|
84840
|
+
*
|
|
84841
|
+
* @see https://code.claude.com/docs/en/settings-reference#permissions-denyinsteadofprompting
|
|
84842
|
+
*/
|
|
84843
|
+
const CLAUDECODE_USER_SCOPE_ONLY_PERMISSIONS_FIELDS = /* @__PURE__ */ new Set(["denyInsteadOfPrompting"]);
|
|
84844
|
+
/**
|
|
84845
|
+
* Drop the project-scope `permissions` fields in
|
|
84846
|
+
* {@link CLAUDECODE_USER_SCOPE_ONLY_PERMISSIONS_FIELDS}, warning once per field
|
|
84847
|
+
* in the same voice as the user-scope-only top-level keys.
|
|
84848
|
+
*/
|
|
84849
|
+
function stripUserScopeOnlyPermissionsFields({ fields, global, relativeFilePath, logger }) {
|
|
84850
|
+
if (global) return;
|
|
84851
|
+
for (const key of CLAUDECODE_USER_SCOPE_ONLY_PERMISSIONS_FIELDS) {
|
|
84852
|
+
if (!Object.hasOwn(fields, key)) continue;
|
|
84853
|
+
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}.`);
|
|
84854
|
+
delete fields[key];
|
|
84855
|
+
}
|
|
84856
|
+
}
|
|
84857
|
+
/**
|
|
84351
84858
|
* Drop a project-scope `permissions.defaultMode` Claude Code ignores there (see
|
|
84352
84859
|
* {@link CLAUDECODE_PROJECT_SCOPE_IGNORED_DEFAULT_MODES}), warning in the same
|
|
84353
84860
|
* voice as the other values the project-scoped file cannot honor.
|
|
@@ -84441,7 +84948,7 @@ const CLAUDECODE_TRUST_AFFECTING_SANDBOX_PATHS = [
|
|
|
84441
84948
|
},
|
|
84442
84949
|
{
|
|
84443
84950
|
path: ["enabled"],
|
|
84444
|
-
reason: "turns the sandbox on, and sandboxed Bash commands then run without a permission prompt
|
|
84951
|
+
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)",
|
|
84445
84952
|
widens: isNotFalse
|
|
84446
84953
|
},
|
|
84447
84954
|
{
|
|
@@ -84744,6 +85251,7 @@ const CLAUDECODE_UNHONORED_KEY_SOURCES = {
|
|
|
84744
85251
|
disableCommandPluginSources: "managed settings",
|
|
84745
85252
|
disableDesktopLocalSessions: "managed settings",
|
|
84746
85253
|
disableMobileSimulatorTools: "managed settings",
|
|
85254
|
+
disableRemotePreviewScripts: "managed settings",
|
|
84747
85255
|
disableSideloadFlags: "managed settings",
|
|
84748
85256
|
externalEditorContext: "~/.claude.json",
|
|
84749
85257
|
forceRemoteSettingsRefresh: "managed settings",
|
|
@@ -85237,6 +85745,12 @@ var ClaudecodePermissions = class ClaudecodePermissions extends ToolPermissions
|
|
|
85237
85745
|
relativeFilePath: paths.relativeFilePath,
|
|
85238
85746
|
logger
|
|
85239
85747
|
});
|
|
85748
|
+
stripUserScopeOnlyPermissionsFields({
|
|
85749
|
+
fields: nonListFields,
|
|
85750
|
+
global,
|
|
85751
|
+
relativeFilePath: paths.relativeFilePath,
|
|
85752
|
+
logger
|
|
85753
|
+
});
|
|
85240
85754
|
trustAffecting.push(...collectWideningPermissionFields({ fields: nonListFields }));
|
|
85241
85755
|
settings.permissions = {
|
|
85242
85756
|
...settings.permissions,
|
|
@@ -87214,6 +87728,7 @@ const CODEX_DEFAULT_APPROVAL_POLICY = "on-request";
|
|
|
87214
87728
|
const CODEX_DEFAULT_APPROVALS_REVIEWER = "auto_review";
|
|
87215
87729
|
const CODEX_RETIRED_APPROVAL_POLICY = "untrusted";
|
|
87216
87730
|
const CODEX_DEPRECATED_APPROVAL_POLICY = "on-failure";
|
|
87731
|
+
const CODEX_REMOVED_AUTO_REVIEW_KEYS = ["extra_policy", "experimental_policy_template"];
|
|
87217
87732
|
const CODEX_GLOB_SCAN_MAX_DEPTH = 8;
|
|
87218
87733
|
const CODEX_MINIMAL_KEY = ":minimal";
|
|
87219
87734
|
const CODEX_GIT_WRITE_RULES = { ".git/**": "write" };
|
|
@@ -87815,6 +88330,10 @@ function computeCodexcliOverridePatch({ existing, override, logger }) {
|
|
|
87815
88330
|
value,
|
|
87816
88331
|
logger
|
|
87817
88332
|
})) continue;
|
|
88333
|
+
if (key === "auto_review" && isRecord(value)) warnAboutRemovedAutoReviewKeys({
|
|
88334
|
+
value,
|
|
88335
|
+
logger
|
|
88336
|
+
});
|
|
87818
88337
|
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.`);
|
|
87819
88338
|
const existingValue = existing[key];
|
|
87820
88339
|
patch[key] = isRecord(existingValue) && isRecord(value) ? {
|
|
@@ -87854,6 +88373,12 @@ function isWritableApprovalPolicy({ value, logger }) {
|
|
|
87854
88373
|
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.`);
|
|
87855
88374
|
return true;
|
|
87856
88375
|
}
|
|
88376
|
+
function warnAboutRemovedAutoReviewKeys({ value, logger }) {
|
|
88377
|
+
for (const key of CODEX_REMOVED_AUTO_REVIEW_KEYS) {
|
|
88378
|
+
if (!Object.hasOwn(value, key)) continue;
|
|
88379
|
+
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.`);
|
|
88380
|
+
}
|
|
88381
|
+
}
|
|
87857
88382
|
function extractCodexcliOverride(table) {
|
|
87858
88383
|
const override = {};
|
|
87859
88384
|
for (const key of CODEXCLI_OVERRIDE_KEYS) if (table[key] !== void 0) override[key] = table[key];
|
|
@@ -89228,6 +89753,17 @@ const AUTO_APPROVE_KEYS = {
|
|
|
89228
89753
|
webfetch: "chat.tools.urls.autoApprove"
|
|
89229
89754
|
};
|
|
89230
89755
|
/**
|
|
89756
|
+
* VS Code registers `chat.tools.edits.autoApprove` with
|
|
89757
|
+
* `ConfigurationScope.APPLICATION` (user settings only) and ignores the value
|
|
89758
|
+
* in a workspace `.vscode/settings.json`, so canonical `edit` rules written
|
|
89759
|
+
* there have no effect. The terminal and URL maps are honored in the workspace
|
|
89760
|
+
* only by the Local harness, which VS Code removes in February 2027.
|
|
89761
|
+
*
|
|
89762
|
+
* @see https://github.com/microsoft/vscode/blob/1.147.0/src/vs/workbench/contrib/chat/browser/chat.shared.contribution.ts
|
|
89763
|
+
* @see https://code.visualstudio.com/docs/agents/run/approvals
|
|
89764
|
+
*/
|
|
89765
|
+
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.";
|
|
89766
|
+
/**
|
|
89231
89767
|
* The workspace setting holding the starting permission level of new Local
|
|
89232
89768
|
* (`local` harness) chat sessions, authored through the
|
|
89233
89769
|
* `copilot.defaultPermissionMode` override. VS Code 1.144 narrowed it to Local
|
|
@@ -89385,6 +89921,10 @@ const SANDBOX_LEAVES = [
|
|
|
89385
89921
|
path: ["credentials", "authenticategh"],
|
|
89386
89922
|
schema: z.boolean()
|
|
89387
89923
|
},
|
|
89924
|
+
{
|
|
89925
|
+
path: ["credentials", "envVars"],
|
|
89926
|
+
schema: CopilotSandboxCredentialEnvVarsSchema
|
|
89927
|
+
},
|
|
89388
89928
|
{
|
|
89389
89929
|
path: ["fileSystem", "allowDevToolAccess"],
|
|
89390
89930
|
schema: z.boolean()
|
|
@@ -89444,6 +89984,11 @@ const COPILOT_TRUST_AFFECTING_SANDBOX_PATHS = [
|
|
|
89444
89984
|
reason: "hands your GitHub CLI authentication to sandboxed commands",
|
|
89445
89985
|
widens: isNotFalse
|
|
89446
89986
|
},
|
|
89987
|
+
{
|
|
89988
|
+
path: ["credentials", "envVars"],
|
|
89989
|
+
reason: "lets the sandbox send the named environment variables' values to the listed hosts",
|
|
89990
|
+
widens: isNonEmptyMap
|
|
89991
|
+
},
|
|
89447
89992
|
{
|
|
89448
89993
|
path: ["fileSystem", "allowDevToolAccess"],
|
|
89449
89994
|
reason: "grants sandboxed commands developer-tool directories, which can hold credentials such as registry tokens",
|
|
@@ -89469,6 +90014,27 @@ const COPILOT_TRUST_AFFECTING_SANDBOX_PATHS = [
|
|
|
89469
90014
|
}
|
|
89470
90015
|
];
|
|
89471
90016
|
const COPILOT_TOOL_LABEL = "GitHub Copilot";
|
|
90017
|
+
/** The trust-warning label of the `credentials.envVars` leaf. */
|
|
90018
|
+
const ENV_VARS_LABEL = "sandbox.credentials.envVars";
|
|
90019
|
+
/**
|
|
90020
|
+
* Every `VAR -> host, host` pair of a `credentials.envVars` map, so a
|
|
90021
|
+
* developer generating from a cloned repository can spot an unexpected host
|
|
90022
|
+
* without opening the file. Names and hosts are JSON-quoted so control
|
|
90023
|
+
* characters in authored values cannot forge log lines.
|
|
90024
|
+
*/
|
|
90025
|
+
function describeEnvVars(envVars) {
|
|
90026
|
+
return Object.entries(envVars).map(([name, { injectHosts }]) => `${JSON.stringify(name)} -> ${injectHosts.length > 0 ? injectHosts.map((host) => JSON.stringify(host)).join(", ") : "(no hosts)"}`).join("; ");
|
|
90027
|
+
}
|
|
90028
|
+
/**
|
|
90029
|
+
* A separate, stronger warning for `injectHosts` entries containing `*`: the
|
|
90030
|
+
* sandbox may then send the credential to any host the pattern matches.
|
|
90031
|
+
*/
|
|
90032
|
+
function warnOnWildcardInjectHosts({ envVars, relativeFilePath, logger }) {
|
|
90033
|
+
if (envVars === void 0) return;
|
|
90034
|
+
const wildcards = Object.entries(envVars).flatMap(([name, { injectHosts }]) => injectHosts.filter((host) => host.includes("*")).map((host) => `${JSON.stringify(name)} -> ${JSON.stringify(host)}`));
|
|
90035
|
+
if (wildcards.length === 0) return;
|
|
90036
|
+
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.`);
|
|
90037
|
+
}
|
|
89472
90038
|
function sandboxKey(path) {
|
|
89473
90039
|
return `${SANDBOX_KEY_PREFIX}${path.join(".")}`;
|
|
89474
90040
|
}
|
|
@@ -89661,14 +90227,16 @@ var CopilotPermissions = class CopilotPermissions extends ToolPermissions {
|
|
|
89661
90227
|
const patch = {};
|
|
89662
90228
|
for (const [category, settingKey] of Object.entries(AUTO_APPROVE_KEYS)) {
|
|
89663
90229
|
if (!Object.hasOwn(config.permission, category)) continue;
|
|
90230
|
+
const rules = category === "bash" ? bashRulesHonoringAllTools(config.permission) : honorCopilotAllToolsRestrictions({
|
|
90231
|
+
permission: config.permission,
|
|
90232
|
+
category,
|
|
90233
|
+
logger
|
|
90234
|
+
});
|
|
89664
90235
|
patch[settingKey] = buildAutoApproveValue({
|
|
89665
90236
|
category,
|
|
89666
|
-
rules
|
|
89667
|
-
permission: config.permission,
|
|
89668
|
-
category,
|
|
89669
|
-
logger
|
|
89670
|
-
})
|
|
90237
|
+
rules
|
|
89671
90238
|
});
|
|
90239
|
+
if (category === "edit" && Object.keys(rules).length > 0) logger?.warn(EDITS_KEY_IGNORED_WARNING);
|
|
89672
90240
|
}
|
|
89673
90241
|
const existingSettings = () => parseSharedConfig({
|
|
89674
90242
|
format: "jsonc",
|
|
@@ -89689,13 +90257,23 @@ var CopilotPermissions = class CopilotPermissions extends ToolPermissions {
|
|
|
89689
90257
|
sandbox,
|
|
89690
90258
|
existingSettings: existingSettings()
|
|
89691
90259
|
}));
|
|
90260
|
+
const relativeFilePath = join(paths.relativeDirPath, paths.relativeFilePath);
|
|
90261
|
+
const envVars = sandbox.credentials?.envVars;
|
|
89692
90262
|
warnOnTrustAffectingEntries({
|
|
89693
90263
|
toolLabel: COPILOT_TOOL_LABEL,
|
|
89694
90264
|
entries: collectTrustAffectingSandboxPaths({
|
|
89695
90265
|
sandbox,
|
|
89696
90266
|
paths: COPILOT_TRUST_AFFECTING_SANDBOX_PATHS
|
|
89697
|
-
})
|
|
89698
|
-
|
|
90267
|
+
}).map((entry) => entry.label === ENV_VARS_LABEL && envVars !== void 0 ? {
|
|
90268
|
+
...entry,
|
|
90269
|
+
reason: `${entry.reason}: ${describeEnvVars(envVars)}`
|
|
90270
|
+
} : entry),
|
|
90271
|
+
relativeFilePath,
|
|
90272
|
+
logger
|
|
90273
|
+
});
|
|
90274
|
+
warnOnWildcardInjectHosts({
|
|
90275
|
+
envVars,
|
|
90276
|
+
relativeFilePath,
|
|
89699
90277
|
logger
|
|
89700
90278
|
});
|
|
89701
90279
|
}
|
|
@@ -92583,7 +93161,7 @@ function convertGoosePermissionConfigToRulesync(userPermission) {
|
|
|
92583
93161
|
const GROKCLI_UI_KEY = "ui";
|
|
92584
93162
|
const GROKCLI_PERMISSION_MODE_KEY = "permission_mode";
|
|
92585
93163
|
const GROKCLI_PERMISSION_KEY = "permission";
|
|
92586
|
-
const
|
|
93164
|
+
const GROKCLI_DERIVED_PERMISSION_MODES = /* @__PURE__ */ new Set(["ask", "always-approve"]);
|
|
92587
93165
|
const CATEGORY_TO_GROK_TOOL = {
|
|
92588
93166
|
bash: "Bash",
|
|
92589
93167
|
read: "Read",
|
|
@@ -92810,12 +93388,15 @@ function parseGrokRule(rule) {
|
|
|
92810
93388
|
* compact arrays, so a user-authored `rules` array is preserved verbatim
|
|
92811
93389
|
* but not reconciled against them.
|
|
92812
93390
|
*
|
|
92813
|
-
* The coarse `[ui] permission_mode` toggle is
|
|
92814
|
-
* compatibility with older Grok versions
|
|
92815
|
-
*
|
|
93391
|
+
* The coarse `[ui] permission_mode` toggle is kept in sync for backward
|
|
93392
|
+
* compatibility with older Grok versions, but only when the config already
|
|
93393
|
+
* sets it to `ask` or `always-approve`: `always-approve` only when the config
|
|
93394
|
+
* has the all-tools catch-all allow (`"*": { "*": "allow" }`) and no
|
|
93395
|
+
* `deny`/`ask` rule, otherwise `ask` (conservative — it is never `always-approve`
|
|
92816
93396
|
* while any `deny`/`ask` rule exists, so it never contradicts the fine-grained
|
|
92817
|
-
* arrays).
|
|
92818
|
-
* (see
|
|
93397
|
+
* arrays). A missing key is not added, so Grok's own default mode applies. It
|
|
93398
|
+
* is a user-level UI setting, so it is only touched in global scope (see
|
|
93399
|
+
* below).
|
|
92819
93400
|
*
|
|
92820
93401
|
* Both scopes are supported: the adapter syncs the project-level
|
|
92821
93402
|
* `./.grok/config.toml` (default) and the user-level `~/.grok/config.toml`
|
|
@@ -92876,7 +93457,7 @@ var GrokcliPermissions = class GrokcliPermissions extends ToolPermissions {
|
|
|
92876
93457
|
ask: buckets.ask
|
|
92877
93458
|
};
|
|
92878
93459
|
const existingUi = toRecord(parsed[GROKCLI_UI_KEY]);
|
|
92879
|
-
const uiPatch = global && existingUi[GROKCLI_PERMISSION_MODE_KEY]
|
|
93460
|
+
const uiPatch = global && GROKCLI_DERIVED_PERMISSION_MODES.has(existingUi[GROKCLI_PERMISSION_MODE_KEY]) ? { [GROKCLI_UI_KEY]: {
|
|
92880
93461
|
...existingUi,
|
|
92881
93462
|
[GROKCLI_PERMISSION_MODE_KEY]: deriveGrokPermissionMode(config)
|
|
92882
93463
|
} } : {};
|
|
@@ -93057,22 +93638,30 @@ function parseGrokPermissionArrays(permission) {
|
|
|
93057
93638
|
/**
|
|
93058
93639
|
* Legacy coarse fallback: map `[ui] permission_mode` to a canonical action.
|
|
93059
93640
|
* `always-approve` ⇒ `allow`; anything else (including a missing mode) ⇒ `ask`.
|
|
93641
|
+
* A missing mode now means Grok's own default (`auto` in the TUI since 1.0.80),
|
|
93642
|
+
* which has no canonical counterpart, so the narrower `ask` reading is kept.
|
|
93060
93643
|
*/
|
|
93061
93644
|
function legacyModeAction(parsed) {
|
|
93062
93645
|
return toRecord(parsed[GROKCLI_UI_KEY])[GROKCLI_PERMISSION_MODE_KEY] === "always-approve" ? "allow" : "ask";
|
|
93063
93646
|
}
|
|
93064
93647
|
/**
|
|
93065
93648
|
* Collapse a rulesync permissions config into Grok's single coarse mode.
|
|
93066
|
-
*
|
|
93067
|
-
*
|
|
93649
|
+
* `always-approve` lets every tool run without a prompt, so it is derived only
|
|
93650
|
+
* from a true catch-all allow — the all-tools rule `"*": { "*": "allow" }` —
|
|
93651
|
+
* with no `deny`/`ask` rule anywhere. Narrow allows (e.g. `bash: { "git *":
|
|
93652
|
+
* "allow" }`, or even `bash: { "*": "allow" }`) never widen into it; they and
|
|
93653
|
+
* an empty config map to `ask`.
|
|
93068
93654
|
*/
|
|
93069
93655
|
function deriveGrokPermissionMode(config) {
|
|
93070
|
-
|
|
93071
|
-
|
|
93072
|
-
|
|
93073
|
-
|
|
93074
|
-
}
|
|
93075
|
-
return
|
|
93656
|
+
for (const rules of Object.values(config.permission)) for (const action of Object.values(rules)) if (action === "deny" || action === "ask") return "ask";
|
|
93657
|
+
const allTools = lookupOwn({
|
|
93658
|
+
record: config.permission,
|
|
93659
|
+
key: "*"
|
|
93660
|
+
});
|
|
93661
|
+
return allTools !== void 0 && lookupOwn({
|
|
93662
|
+
record: allTools,
|
|
93663
|
+
key: "*"
|
|
93664
|
+
}) === "allow" ? "always-approve" : "ask";
|
|
93076
93665
|
}
|
|
93077
93666
|
// src/features/permissions/hermesagent-permissions.ts
|
|
93078
93667
|
/** Collect the glob patterns in a canonical category that carry a given action. */
|
|
@@ -94375,13 +94964,71 @@ function canonicalToKimiCodeRules({ config, logger }) {
|
|
|
94375
94964
|
});
|
|
94376
94965
|
}
|
|
94377
94966
|
}
|
|
94378
|
-
|
|
94967
|
+
const rules = [...overrideRules, ...sortKimiCodeRulesFailClosed(canonicalRules)];
|
|
94968
|
+
warnAboutIgnoredKimiCodeRuleScopes({
|
|
94969
|
+
rules: overrideRules,
|
|
94970
|
+
logger
|
|
94971
|
+
});
|
|
94972
|
+
warnAboutShadowedKimiCodeRules({
|
|
94973
|
+
rules,
|
|
94974
|
+
logger
|
|
94975
|
+
});
|
|
94976
|
+
return rules;
|
|
94379
94977
|
}
|
|
94380
|
-
|
|
94978
|
+
/**
|
|
94979
|
+
* Scopes Kimi silently ignores on a rule in the user `config.toml`.
|
|
94980
|
+
*
|
|
94981
|
+
* @see https://moonshotai.github.io/kimi-code/en/configuration/config-files.html#permission
|
|
94982
|
+
*/
|
|
94983
|
+
const KIMI_CODE_IGNORED_USER_RULE_SCOPES = /* @__PURE__ */ new Set(["turn-override", "session-runtime"]);
|
|
94984
|
+
function warnAboutIgnoredKimiCodeRuleScopes({ rules, logger }) {
|
|
94985
|
+
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.`);
|
|
94986
|
+
}
|
|
94987
|
+
/** Split a Kimi rule pattern (`Tool` or `Tool(arg)`) into its tool and argument. */
|
|
94988
|
+
function splitKimiCodePattern(pattern) {
|
|
94381
94989
|
const opening = pattern.indexOf("(");
|
|
94382
94990
|
const hasArguments = opening >= 0 && pattern.endsWith(")");
|
|
94383
|
-
|
|
94384
|
-
|
|
94991
|
+
return {
|
|
94992
|
+
tool: hasArguments ? pattern.slice(0, opening) : pattern,
|
|
94993
|
+
argument: hasArguments ? pattern.slice(opening + 1, -1) : "",
|
|
94994
|
+
hasArguments
|
|
94995
|
+
};
|
|
94996
|
+
}
|
|
94997
|
+
/**
|
|
94998
|
+
* Whether `stricter` certainly matches every call `rule` matches: the same
|
|
94999
|
+
* pattern, or the bare name of the same tool (which matches every call of
|
|
95000
|
+
* it). Wildcard overlaps are not detected, so this never reports a false
|
|
95001
|
+
* shadow but can miss one.
|
|
95002
|
+
*/
|
|
95003
|
+
function kimiCodeRuleCovers({ stricter, rule }) {
|
|
95004
|
+
return stricter.pattern === rule.pattern || stricter.pattern === splitKimiCodePattern(rule.pattern).tool;
|
|
95005
|
+
}
|
|
95006
|
+
/**
|
|
95007
|
+
* Kimi does not let the first matching rule win: a matching `deny` beats a
|
|
95008
|
+
* matching `ask`, which beats a matching `allow` (Kimi Code 2.6.0 docs). An
|
|
95009
|
+
* `allow` or `ask` meant to carve an exception out of a broader, stricter
|
|
95010
|
+
* rule therefore never takes effect, whether it comes from `kimi-code.rules`
|
|
95011
|
+
* or from a canonical category, so say so instead of letting the authored
|
|
95012
|
+
* order suggest otherwise. A rule whose own scope Kimi ignores already got
|
|
95013
|
+
* its warning and is skipped here.
|
|
95014
|
+
*
|
|
95015
|
+
* @see https://moonshotai.github.io/kimi-code/en/configuration/config-files.html#permission
|
|
95016
|
+
*/
|
|
95017
|
+
function warnAboutShadowedKimiCodeRules({ rules, logger }) {
|
|
95018
|
+
for (const rule of rules) {
|
|
95019
|
+
if (rule.decision === "deny" || KIMI_CODE_IGNORED_USER_RULE_SCOPES.has(rule.scope ?? "")) continue;
|
|
95020
|
+
const shadowing = rules.find((other) => isStricterAction({
|
|
95021
|
+
action: other.decision,
|
|
95022
|
+
existing: rule.decision
|
|
95023
|
+
}) && !KIMI_CODE_IGNORED_USER_RULE_SCOPES.has(other.scope ?? "") && kimiCodeRuleCovers({
|
|
95024
|
+
stricter: other,
|
|
95025
|
+
rule
|
|
95026
|
+
}));
|
|
95027
|
+
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.`);
|
|
95028
|
+
}
|
|
95029
|
+
}
|
|
95030
|
+
function getKimiCodePatternSpecificity(pattern) {
|
|
95031
|
+
const { tool, argument, hasArguments } = splitKimiCodePattern(pattern);
|
|
94385
95032
|
return {
|
|
94386
95033
|
tool,
|
|
94387
95034
|
toolLiteralLength: tool.replaceAll("*", "").replaceAll("?", "").length,
|
|
@@ -100447,6 +101094,14 @@ const TAKT_SECURITY_POLICIES = {
|
|
|
100447
101094
|
const TAKT_SECURITY_POLICY_KEYS = Object.keys(TAKT_SECURITY_POLICIES);
|
|
100448
101095
|
const TAKT_DEFAULT_PROVIDER = "claude-sdk";
|
|
100449
101096
|
const TAKT_LEGACY_DEFAULT_PROVIDER = "claude";
|
|
101097
|
+
const TAKT_CLAUDE_READ_DENY_PROVIDERS = [
|
|
101098
|
+
"claude-sdk",
|
|
101099
|
+
"claude",
|
|
101100
|
+
"claude-headless"
|
|
101101
|
+
];
|
|
101102
|
+
const TAKT_CLAUDE_PROVIDER_OPTIONS_KEY = "claude";
|
|
101103
|
+
const TAKT_CLAUDE_PERMISSIONS_KEY = "permissions";
|
|
101104
|
+
const TAKT_CLAUDE_PERMISSIONS_DENY_KEY = "deny";
|
|
100450
101105
|
/**
|
|
100451
101106
|
* Permissions adapter for Takt (`.takt/config.yaml`).
|
|
100452
101107
|
*
|
|
@@ -100485,6 +101140,12 @@ const TAKT_LEGACY_DEFAULT_PROVIDER = "claude";
|
|
|
100485
101140
|
* (a top-level per-provider sandbox/network table). Both are authored on
|
|
100486
101141
|
* generate and re-extracted on import.
|
|
100487
101142
|
*
|
|
101143
|
+
* Canonical `read` deny rules are also kept per path where the active provider
|
|
101144
|
+
* is Claude-family (Takt 0.76.0+): they are written as `Read(<pattern>)`
|
|
101145
|
+
* entries into `provider_options.claude.permissions.deny`, in addition to the
|
|
101146
|
+
* `readonly` mode they already derive. The list is only ever added to, so a
|
|
101147
|
+
* deny never turns into a broader allow.
|
|
101148
|
+
*
|
|
100488
101149
|
* Takt 0.56.0 moved provider configuration into a separate `runtime.yaml`
|
|
100489
101150
|
* (`.takt/runtime.yaml`, `~/.takt/runtime.yaml`). Once its `provider:` section
|
|
100490
101151
|
* carries an assignment ("runtime mode" — the state a freshly installed Takt is
|
|
@@ -100549,7 +101210,8 @@ var TaktPermissions = class TaktPermissions extends ToolPermissions {
|
|
|
100549
101210
|
outputRoot,
|
|
100550
101211
|
logger
|
|
100551
101212
|
});
|
|
100552
|
-
const
|
|
101213
|
+
const globalLayer = await readGlobalTaktLayer({
|
|
101214
|
+
global,
|
|
100553
101215
|
projectFilePath: filePath,
|
|
100554
101216
|
logger
|
|
100555
101217
|
});
|
|
@@ -100557,7 +101219,7 @@ var TaktPermissions = class TaktPermissions extends ToolPermissions {
|
|
|
100557
101219
|
const provider = resolveActiveProvider({
|
|
100558
101220
|
config,
|
|
100559
101221
|
runtime: runtime.active ? runtime.config : void 0,
|
|
100560
|
-
inheritedProvider
|
|
101222
|
+
inheritedProvider: globalLayer.provider
|
|
100561
101223
|
});
|
|
100562
101224
|
const mode = deriveTaktPermissionMode(rulesyncJson);
|
|
100563
101225
|
const override = isPlainObject(rulesyncJson.takt) ? rulesyncJson.takt : void 0;
|
|
@@ -100565,9 +101227,20 @@ var TaktPermissions = class TaktPermissions extends ToolPermissions {
|
|
|
100565
101227
|
const authoredProviderOptions = isPlainObject(override?.[TAKT_PROVIDER_OPTIONS_KEY]) ? override[TAKT_PROVIDER_OPTIONS_KEY] : void 0;
|
|
100566
101228
|
const runtimeModeRefusesProviderOptions = authoredProviderOptions !== void 0 && runtime.active;
|
|
100567
101229
|
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.`);
|
|
100568
|
-
const overrideProviderOptions =
|
|
100569
|
-
providerOptions:
|
|
100570
|
-
|
|
101230
|
+
const overrideProviderOptions = addClaudeReadDenyRules({
|
|
101231
|
+
providerOptions: runtimeModeRefusesProviderOptions ? void 0 : dropUntrustedProviderOptions({
|
|
101232
|
+
providerOptions: authoredProviderOptions,
|
|
101233
|
+
global,
|
|
101234
|
+
filePath,
|
|
101235
|
+
logger
|
|
101236
|
+
}),
|
|
101237
|
+
readDenyRules: collectReadDenyRules(rulesyncJson),
|
|
101238
|
+
existingProviderOptions: config[TAKT_PROVIDER_OPTIONS_KEY],
|
|
101239
|
+
globalProviderOptions: globalLayer.providerOptions,
|
|
101240
|
+
globalFilePath: globalLayer.filePath,
|
|
101241
|
+
provider,
|
|
101242
|
+
runtimeActive: runtime.active,
|
|
101243
|
+
runtimeFilePaths: runtime.filePaths,
|
|
100571
101244
|
filePath,
|
|
100572
101245
|
logger
|
|
100573
101246
|
});
|
|
@@ -100680,11 +101353,34 @@ function readProviderName(config) {
|
|
|
100680
101353
|
return typeof provider === "string" && provider.trim() !== "" ? provider : void 0;
|
|
100681
101354
|
}
|
|
100682
101355
|
/**
|
|
100683
|
-
*
|
|
100684
|
-
*
|
|
100685
|
-
*
|
|
101356
|
+
* What a project-scope generate inherits from the global `~/.takt/config.yaml`:
|
|
101357
|
+
* its provider and its `provider_options`. Nothing at global scope, where that
|
|
101358
|
+
* file is the one being generated.
|
|
100686
101359
|
*/
|
|
100687
|
-
async function
|
|
101360
|
+
async function readGlobalTaktLayer({ global, projectFilePath, logger }) {
|
|
101361
|
+
const globalConfig = global ? void 0 : await readGlobalTaktConfig({
|
|
101362
|
+
projectFilePath,
|
|
101363
|
+
logger
|
|
101364
|
+
});
|
|
101365
|
+
if (globalConfig === void 0) return {
|
|
101366
|
+
provider: void 0,
|
|
101367
|
+
providerOptions: void 0,
|
|
101368
|
+
filePath: void 0
|
|
101369
|
+
};
|
|
101370
|
+
return {
|
|
101371
|
+
provider: readProviderName(globalConfig.config),
|
|
101372
|
+
providerOptions: globalConfig.config[TAKT_PROVIDER_OPTIONS_KEY],
|
|
101373
|
+
filePath: globalConfig.filePath
|
|
101374
|
+
};
|
|
101375
|
+
}
|
|
101376
|
+
/**
|
|
101377
|
+
* The global `~/.takt/config.yaml`, read for a project-scope generate: its
|
|
101378
|
+
* top-level `provider:` is inherited by a project config that names none, and
|
|
101379
|
+
* its `provider_options.claude.permissions.deny` is the list a project list
|
|
101380
|
+
* would replace. An unresolvable home directory or a missing or unparsable file
|
|
101381
|
+
* all mean "nothing inherited".
|
|
101382
|
+
*/
|
|
101383
|
+
async function readGlobalTaktConfig({ projectFilePath, logger }) {
|
|
100688
101384
|
let globalPath;
|
|
100689
101385
|
try {
|
|
100690
101386
|
globalPath = join(getHomeDirectory(), TAKT_DIR, TAKT_CONFIG_FILE_NAME);
|
|
@@ -100695,12 +101391,15 @@ async function readGlobalTaktProvider({ projectFilePath, logger }) {
|
|
|
100695
101391
|
try {
|
|
100696
101392
|
const content = await readFileContentOrNull(globalPath);
|
|
100697
101393
|
if (content === null) return;
|
|
100698
|
-
return
|
|
100699
|
-
format: "yaml",
|
|
100700
|
-
fileContent: content,
|
|
101394
|
+
return {
|
|
100701
101395
|
filePath: globalPath,
|
|
100702
|
-
|
|
100703
|
-
|
|
101396
|
+
config: parseSharedConfig({
|
|
101397
|
+
format: "yaml",
|
|
101398
|
+
fileContent: content,
|
|
101399
|
+
filePath: globalPath,
|
|
101400
|
+
invalidRootPolicy: "error"
|
|
101401
|
+
})
|
|
101402
|
+
};
|
|
100704
101403
|
} catch (error) {
|
|
100705
101404
|
logger?.warn(`Takt permissions: could not read the provider from ${globalPath} (${formatError(error)}); falling back to the project config alone.`);
|
|
100706
101405
|
return;
|
|
@@ -101063,6 +101762,70 @@ function taktModeToRulesyncConfig(mode) {
|
|
|
101063
101762
|
default: return { permission: { bash: { ["*"]: "deny" } } };
|
|
101064
101763
|
}
|
|
101065
101764
|
}
|
|
101765
|
+
/**
|
|
101766
|
+
* The canonical `read` deny rules as Claude Code `Read(...)` entries, in the
|
|
101767
|
+
* form the Claude Code permissions and ignore adapters write them: the pattern
|
|
101768
|
+
* verbatim, and a bare `Read` for the catch-all.
|
|
101769
|
+
*/
|
|
101770
|
+
function collectReadDenyRules(config) {
|
|
101771
|
+
const rules = config.permission.read ?? {};
|
|
101772
|
+
return Object.entries(rules).filter(([, action]) => action === "deny").map(([pattern]) => pattern === "*" ? "Read" : buildReadDenyEntry(pattern));
|
|
101773
|
+
}
|
|
101774
|
+
/**
|
|
101775
|
+
* Add the canonical `read` deny rules to `provider_options.claude.permissions.deny`
|
|
101776
|
+
* (Takt 0.76.0+), which Takt passes to `claude-sdk` / `claude-headless` as
|
|
101777
|
+
* Claude Code `permissions.deny` rules.
|
|
101778
|
+
*
|
|
101779
|
+
* Takt replaces a `deny` list wholesale rather than concatenating it, so the
|
|
101780
|
+
* rules are merged into the list that would otherwise be in force: the one the
|
|
101781
|
+
* `takt` block states (which replaces a hand-written config.yaml list, as any
|
|
101782
|
+
* authored `provider_options` leaf does), else the one already in config.yaml.
|
|
101783
|
+
* Without an authored list nothing is removed from config.yaml's — a rule
|
|
101784
|
+
* written by hand, or by an earlier generate, is kept.
|
|
101785
|
+
*
|
|
101786
|
+
* At project scope the written list also replaces a global `~/.takt/config.yaml`
|
|
101787
|
+
* deny list for this project. That list usually holds personal paths, so it is
|
|
101788
|
+
* not copied into the (committed) project file; a warning names it instead.
|
|
101789
|
+
*
|
|
101790
|
+
* Skipped when the active provider is not Claude-family (no other provider
|
|
101791
|
+
* reads the list) and, with a warning, in runtime mode, where `provider_options`
|
|
101792
|
+
* in config.yaml stops Takt with "Mixed provider configuration detected".
|
|
101793
|
+
* https://github.com/nrslib/takt/blob/main/docs/configuration.md#claude-read-deny-rules
|
|
101794
|
+
*/
|
|
101795
|
+
function addClaudeReadDenyRules({ providerOptions, readDenyRules, existingProviderOptions, globalProviderOptions, globalFilePath, provider, runtimeActive, runtimeFilePaths, filePath, logger }) {
|
|
101796
|
+
if (readDenyRules.length === 0 || !TAKT_CLAUDE_READ_DENY_PROVIDERS.includes(provider)) return providerOptions;
|
|
101797
|
+
if (runtimeActive) {
|
|
101798
|
+
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.`);
|
|
101799
|
+
return providerOptions;
|
|
101800
|
+
}
|
|
101801
|
+
const authoredClaude = providerOptions?.[TAKT_CLAUDE_PROVIDER_OPTIONS_KEY];
|
|
101802
|
+
const authoredDeny = readClaudeDenyList(authoredClaude);
|
|
101803
|
+
const existingDeny = isPlainObject(existingProviderOptions) ? readClaudeDenyList(existingProviderOptions[TAKT_CLAUDE_PROVIDER_OPTIONS_KEY]) : void 0;
|
|
101804
|
+
const deny = [.../* @__PURE__ */ new Set([...authoredDeny ?? existingDeny ?? [], ...readDenyRules])];
|
|
101805
|
+
const shadowedGlobalDeny = ((isPlainObject(globalProviderOptions) ? readClaudeDenyList(globalProviderOptions[TAKT_CLAUDE_PROVIDER_OPTIONS_KEY]) : void 0) ?? []).filter((rule) => !deny.includes(rule));
|
|
101806
|
+
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.`);
|
|
101807
|
+
const claude = isPlainObject(authoredClaude) ? authoredClaude : {};
|
|
101808
|
+
const permissions = isPlainObject(claude[TAKT_CLAUDE_PERMISSIONS_KEY]) ? claude[TAKT_CLAUDE_PERMISSIONS_KEY] : {};
|
|
101809
|
+
return {
|
|
101810
|
+
...providerOptions,
|
|
101811
|
+
[TAKT_CLAUDE_PROVIDER_OPTIONS_KEY]: {
|
|
101812
|
+
...claude,
|
|
101813
|
+
[TAKT_CLAUDE_PERMISSIONS_KEY]: {
|
|
101814
|
+
...permissions,
|
|
101815
|
+
[TAKT_CLAUDE_PERMISSIONS_DENY_KEY]: deny
|
|
101816
|
+
}
|
|
101817
|
+
}
|
|
101818
|
+
};
|
|
101819
|
+
}
|
|
101820
|
+
/** The string entries of `<claude options>.permissions.deny`, when it is a list. */
|
|
101821
|
+
function readClaudeDenyList(claudeOptions) {
|
|
101822
|
+
if (!isPlainObject(claudeOptions)) return;
|
|
101823
|
+
const permissions = claudeOptions[TAKT_CLAUDE_PERMISSIONS_KEY];
|
|
101824
|
+
if (!isPlainObject(permissions)) return;
|
|
101825
|
+
const deny = permissions[TAKT_CLAUDE_PERMISSIONS_DENY_KEY];
|
|
101826
|
+
if (!Array.isArray(deny)) return;
|
|
101827
|
+
return deny.filter((entry) => typeof entry === "string" && entry !== "");
|
|
101828
|
+
}
|
|
101066
101829
|
const TAKT_BASE_URL_PROVIDERS = [
|
|
101067
101830
|
"codex",
|
|
101068
101831
|
"claude",
|
|
@@ -104087,6 +104850,32 @@ function buildZedToolPermissions({ permission, logger }) {
|
|
|
104087
104850
|
inertMcpCategories
|
|
104088
104851
|
};
|
|
104089
104852
|
}
|
|
104853
|
+
/**
|
|
104854
|
+
* Zed's file-edit tools whose `confirm` default does not prompt for files inside
|
|
104855
|
+
* the project.
|
|
104856
|
+
*/
|
|
104857
|
+
const ZED_IN_PROJECT_EDIT_TOOLS = ["edit_file", "write_file"];
|
|
104858
|
+
/**
|
|
104859
|
+
* Zed's `edit_file` and `write_file` skip the permission prompt for files inside
|
|
104860
|
+
* the project when the settings decision is `confirm`: only Zed settings
|
|
104861
|
+
* folders, `.agents/skills/` and paths a symlink places outside the project
|
|
104862
|
+
* still prompt (`authorize_file_edit` in `crates/agent/src/tools/tool_permissions.rs`,
|
|
104863
|
+
* documented under "File Edits Inside the Project" since zed-industries/zed#67037).
|
|
104864
|
+
* A canonical catch-all `ask` on `edit`/`write` — or an all-tools `*` ask those
|
|
104865
|
+
* tools fall back to — therefore lets the agent edit in-project files without
|
|
104866
|
+
* asking, so say so at generate time rather than implying a prompt.
|
|
104867
|
+
*
|
|
104868
|
+
* The check runs on the merged `tools` result: a tool whose entry is a
|
|
104869
|
+
* preserved, hand-written one (not managed by rulesync) is skipped, since its
|
|
104870
|
+
* decision is the user's own. Only the literal `.*` ask pattern counts as
|
|
104871
|
+
* "prompt for every file" and silences the warning; any narrower pattern still
|
|
104872
|
+
* leaves other in-project files unprompted, so the warning stays.
|
|
104873
|
+
*/
|
|
104874
|
+
function warnInProjectEditConfirm({ managedDefault, managedTools, preservedToolNames, logger }) {
|
|
104875
|
+
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 === ".*"));
|
|
104876
|
+
if (confirmTools.length === 0) return;
|
|
104877
|
+
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.`);
|
|
104878
|
+
}
|
|
104090
104879
|
function asRecord(value) {
|
|
104091
104880
|
if (value === null || typeof value !== "object" || Array.isArray(value)) return {};
|
|
104092
104881
|
return Object.fromEntries(Object.entries(value));
|
|
@@ -104232,6 +105021,12 @@ var ZedPermissions = class ZedPermissions extends ToolPermissions {
|
|
|
104232
105021
|
if ("*" in config.permission) managedToolNames.add("*");
|
|
104233
105022
|
for (const toolName of Object.keys(existingTools)) if (toolName.startsWith("mcp__")) managedToolNames.add(toolName);
|
|
104234
105023
|
const preservedTools = Object.fromEntries(Object.entries(existingTools).filter(([toolName]) => !managedToolNames.has(toolName)));
|
|
105024
|
+
warnInProjectEditConfirm({
|
|
105025
|
+
managedDefault,
|
|
105026
|
+
managedTools,
|
|
105027
|
+
preservedToolNames: new Set(Object.keys(preservedTools)),
|
|
105028
|
+
logger
|
|
105029
|
+
});
|
|
104235
105030
|
return new ZedPermissions({
|
|
104236
105031
|
outputRoot,
|
|
104237
105032
|
relativeDirPath: paths.relativeDirPath,
|
|
@@ -105275,6 +106070,11 @@ async function ensureAntigravityPluginManifests({ outputRoots, dryRun, logger })
|
|
|
105275
106070
|
if (name !== dirName) warnOnceWithFallback(logger, `The Antigravity plugin directory ${quoteForLog(dirName)} is not lowercase kebab-case, which \`agy plugin validate --strict\` and the Marketplace reject, so ${quoteForLog(filePath)} names the plugin ${quoteForLog(name)}.`);
|
|
105276
106071
|
noteName(name, filePath);
|
|
105277
106072
|
const content = addTrailingNewline(JSON.stringify({ name }, null, 2));
|
|
106073
|
+
await warnIfWriteFollowsLink({
|
|
106074
|
+
logger,
|
|
106075
|
+
rootPath: outputRoot,
|
|
106076
|
+
targetPath: filePath
|
|
106077
|
+
});
|
|
105278
106078
|
if (dryRun) logger.info(`[DRY RUN] Would write: ${stripControlCharacters(filePath)}`);
|
|
105279
106079
|
else await writeFileContent(filePath, content);
|
|
105280
106080
|
paths.push(ANTIGRAVITY_PLUGIN_MANIFEST_FILE_NAME);
|
|
@@ -105323,7 +106123,7 @@ function mergeEnabledPlugins({ existingContent, filePath, pluginNames }) {
|
|
|
105323
106123
|
}
|
|
105324
106124
|
});
|
|
105325
106125
|
}
|
|
105326
|
-
async function writeActivationFile({ filePath, relativePath, expectedContent, dryRun, logger }) {
|
|
106126
|
+
async function writeActivationFile({ rootPath, filePath, relativePath, expectedContent, dryRun, logger }) {
|
|
105327
106127
|
const existingContent = await readFileContentOrNull(filePath);
|
|
105328
106128
|
const normalizedExpected = addTrailingNewline(expectedContent);
|
|
105329
106129
|
if (fileContentsEquivalent({
|
|
@@ -105331,6 +106131,11 @@ async function writeActivationFile({ filePath, relativePath, expectedContent, dr
|
|
|
105331
106131
|
expected: normalizedExpected,
|
|
105332
106132
|
existing: existingContent
|
|
105333
106133
|
})) return false;
|
|
106134
|
+
await warnIfWriteFollowsLink({
|
|
106135
|
+
logger,
|
|
106136
|
+
rootPath,
|
|
106137
|
+
targetPath: filePath
|
|
106138
|
+
});
|
|
105334
106139
|
if (dryRun) logger.info(`[DRY RUN] Would write: ${filePath}`);
|
|
105335
106140
|
else await writeFileContent(filePath, normalizedExpected);
|
|
105336
106141
|
logger.debug(`Hermes project-plugin activation requires ${relativePath}`);
|
|
@@ -105367,6 +106172,7 @@ async function activateHermesProjectPlugins({ pluginNames, dryRun, logger }) {
|
|
|
105367
106172
|
const paths = [];
|
|
105368
106173
|
logger.warn(`Hermes project plugins require explicit trust. Run Hermes from this trusted repository with ${HERMESAGENT_PROJECT_PLUGINS_ENV_VAR}=true. RuleSync does not persist this global setting.`);
|
|
105369
106174
|
if (await writeActivationFile({
|
|
106175
|
+
rootPath: configRoot,
|
|
105370
106176
|
filePath: configPath,
|
|
105371
106177
|
relativePath: relativeConfigPath,
|
|
105372
106178
|
expectedContent: expectedConfig,
|
|
@@ -107387,6 +108193,6 @@ const CHECKS_IMPORT_STRATEGY = {
|
|
|
107387
108193
|
missingLabel: "check files",
|
|
107388
108194
|
createdLabel: "check files"
|
|
107389
108195
|
};
|
|
107390
|
-
export {
|
|
108196
|
+
export { RulesyncSkillFrontmatterSchema as $, RULESYNC_RULES_RELATIVE_DIR_PATH as $n, getFileSizeAndExecutableBit as $t, CODEBUDDY_LOCAL_RULE_FILE_NAME as A, ToolTargetSchema as An, fallbackLogger as At, CLAUDECODE_DIR as B, RULESYNC_CONFIG_RELATIVE_FILE_PATH as Bn, assertDirectoryIfExists as Bt, LETTACODE_DIR as C, toPosixPath as Cn, SourceEntrySchema as Ct, COMMANDCODE_DIR as D, ALL_TOOL_TARGETS as Dn, ConsoleLogger as Dt, FACTORYDROID_SETTINGS_LOCAL_FILE_NAME as E, mapWithConcurrency as En, findControlCharacter as Et, sweepRefusalReason as F, FEATURE_SOURCE_TREE_ENTRIES as Fn, CLIError as Ft, findProjectInstructionBudgetFindings as G, RULESYNC_IGNORE_RELATIVE_FILE_PATH as Gn, assertWritablePathInsideRoot as Gt, CLAUDECODE_MEMORIES_DIR_NAME as H, RULESYNC_CURATED_RULES_RELATIVE_DIR_PATH as Hn, assertNoSymlinkBelowRoot as Ht, loadYaml as I, MAX_FILE_SIZE as In, ErrorCodes as It, hasWindowsFoldableName as J, RULESYNC_MCP_SCHEMA_URL as Jn, directoryExists as Jt, toInstructionBudgetFile as K, RULESYNC_LOCAL_CONFIG_RELATIVE_FILE_PATH as Kn, checkPathTraversal as Kt, CODEXCLI_BASH_RULES_FILE_NAME as L, RULESYNC_AIIGNORE_RELATIVE_FILE_PATH as Ln, parseJsonc as Lt, AUGMENTCODE_SETTINGS_LOCAL_FILE_NAME as M, ALL_FEATURES_WITH_WILDCARD as Mn, withFallbackLoggerTarget as Mt, caseFoldIdentity as N, DEPRECATED_FEATURE_REPLACEMENTS as Nn, resetRunWarningState as Nt, COMMANDCODE_SETTINGS_LOCAL_FILE_NAME as O, ALL_TOOL_TARGETS_WITH_WILDCARD as On, JsonLogger as Ot, groupSpellingsByCaseFoldedIdentity as P, CURATED_RULES_FEATURE_SUBDIR as Pn, withWarnOnceScope as Pt, RulesyncSkill as Q, RULESYNC_RELATIVE_DIR_PATH as Qn, findFilesByGlobs as Qt, CODEXCLI_DIR as R, RULESYNC_CHECKS_RELATIVE_DIR_PATH as Rn, PathOutsideRootError as Rt, QWENCODE_LOCAL_RULE_FILE_NAME as S, splitPathSegments as Sn, GITIGNORE_DESTINATION_KEY as St, FACTORYDROID_DIR as T, writeFileContent as Tn, getSourceTransport as Tt, CLAUDECODE_SETTINGS_LOCAL_FILE_NAME as U, RULESYNC_CURATED_SKILLS_RELATIVE_DIR_PATH as Un, assertPathResolvesInsideRoot as Ut, CLAUDECODE_LOCAL_RULE_FILE_NAME as V, RULESYNC_CONFIG_SCHEMA_URL as Vn, assertLandingOutsideVcsMetadata as Vt, CLAUDECODE_SKILLS_DIR_PATH as W, RULESYNC_HOOKS_RELATIVE_FILE_PATH as Wn, assertTreeContainsNoSymlinks as Wt, RulesyncSubagent as X, RULESYNC_PERMISSIONS_RELATIVE_FILE_PATH as Xn, fileExists as Xt, getLocalSkillDirNames as Y, RULESYNC_NPM_SOURCES_LOCK_RELATIVE_FILE_PATH as Yn, ensureDir as Yt, RulesyncSubagentFrontmatterSchema as Z, RULESYNC_PERMISSIONS_SCHEMA_URL as Zn, fileExistsStrict as Zt, SkillsProcessor as _, removeFileWithoutFollowingSymlinks as _n, mergeInputRootConfigs as _t, convertFromTool as a, listDirectoryEntryNames as an, formatMegabytes as ar, RulesyncHooks as at, REASONIX_LOCAL_RULE_FILE_NAME as b, resolvedRelativePath as bn, CONFLICTING_TARGET_PAIRS as bt, ELLIPSIS_WIDTH as c, normalizePosixDirPath as cn, hasEnclosingMarkOutsideKeycap as cr, RulesyncCommand as ct, McpProcessor as d, readFileContent as dn, stripControlCharactersKeepingLineFeeds as dr, RulesyncCheckFrontmatterSchema as dt, getHomeDirectory as en, RULESYNC_SKILLS_RELATIVE_DIR_PATH as er, RulesyncRule as et, IgnoreProcessor as f, readFileContentOrNull as fn, stripControlCharactersKeepingLineFeedsAndTabs as fr, stringifyFrontmatter as ft, SubagentsProcessor as g, removeFileStrict as gn, ConfigResolver as gt, RulesProcessor as h, removeFile as hn, SKILL_FILE_NAME as ht, inspectInputRoots as i, isSymlink as in, RULESYNC_XDG_CONFIG_HOME_DEFAULT_DIR_NAME as ir, RulesyncIgnore as it, AUGMENTCODE_DIR as j, ALL_FEATURES as jn, warnOnConflictingFlags as jt, CODEBUDDY_DIR as k, PACKAGING_TOOL_TARGETS as kn, WarningCollectingLogger as kt, displayWidthOf as l, pathEscapesRoot as ln, quoteForLog as lr, RulesyncCommandFrontmatterSchema as lt, ChecksProcessor as m, removeDirectoryStrict as mn, SHARED_USER_MANAGED_CONFIG_PATHS as mt, formatSourceLoadFailure as n, isFileSystemError as nn, RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH as nr, RulesyncPermissions as nt, getProcessorRegistryEntry as o, listFilePathsRecursively as on, formatError as or, getRulesyncSourceCandidates as ot, HooksProcessor as p, removeDirectory as pn, stripHiddenCharacters as pr, isRecord as pt, classifyRemoteName as q, RULESYNC_MCP_RELATIVE_FILE_PATH as qn, createTempDirectory as qt, generate as r, isRootDirPath as rn, RULESYNC_USER_CONFIG_DIR_NAME as rr, RulesyncMcp as rt, parseCommaSeparatedList as s, listSubdirectoryNames as sn, truncateText as sr, resolveRulesyncSourceWritePath as st, importFromTool as t, isFileNotFoundError as tn, RULESYNC_SOURCES_LOCK_RELATIVE_FILE_PATH as tr, RulesyncRuleFrontmatterSchema as tt, shortenToWidth as u, posixRelativePathEscapesRoot as un, stripControlCharacters as ur, RulesyncCheck as ut, CRUSH_LOCAL_RULE_FILE_NAME as v, removeTempDirectory as vn, parseConfigFileContent as vt, LETTACODE_SETTINGS_LOCAL_FILE_NAME as w, writeFileBuffer as wn, assertTargetsFeaturesExclusive as wt, QWENCODE_DIR as x, runWithDirectoryRollback as xn, ConfigFileSchema as xt, CommandsProcessor as y, resolvePath as yn, resolveEffectiveInputRoots as yt, CLAUDECODE_AGENT_MEMORY_LOCAL_DIR_NAME as z, RULESYNC_COMMANDS_RELATIVE_DIR_PATH as zn, applyFileMode as zt };
|
|
107391
108197
|
|
|
107392
|
-
//# sourceMappingURL=import-
|
|
108198
|
+
//# sourceMappingURL=import-9NB0tQm3.js.map
|