rulesync 43.12.0 → 43.14.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 -2
- 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-Bp-dK2hr.cjs → import-BEtASli7.cjs} +1516 -251
- package/dist/{import-Ctgal4jT.js → import-yOMJuum5.js} +1491 -225
- package/dist/{import-Ctgal4jT.js.map → import-yOMJuum5.js.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +14 -14
|
@@ -41,9 +41,8 @@ let es_toolkit = require("es-toolkit");
|
|
|
41
41
|
let globby = require("globby");
|
|
42
42
|
let node_async_hooks = require("node:async_hooks");
|
|
43
43
|
let node_util = require("node:util");
|
|
44
|
-
let gray_matter = require("gray-matter");
|
|
45
|
-
gray_matter = __toESM(gray_matter, 1);
|
|
46
44
|
let js_yaml = require("js-yaml");
|
|
45
|
+
let js_yaml_v4 = require("js-yaml-v4");
|
|
47
46
|
let es_toolkit_object = require("es-toolkit/object");
|
|
48
47
|
let node_crypto = require("node:crypto");
|
|
49
48
|
let _toon_format_toon = require("@toon-format/toon");
|
|
@@ -382,36 +381,36 @@ function formatError(error) {
|
|
|
382
381
|
return boundErrorMessage(String(error));
|
|
383
382
|
}
|
|
384
383
|
// src/constants/rulesync-paths.ts
|
|
385
|
-
const { join: join$
|
|
384
|
+
const { join: join$360 } = node_path.posix;
|
|
386
385
|
const RULESYNC_CONFIG_RELATIVE_FILE_PATH = "rulesync.jsonc";
|
|
387
386
|
const RULESYNC_LOCAL_CONFIG_RELATIVE_FILE_PATH = "rulesync.local.jsonc";
|
|
388
387
|
const RULESYNC_USER_CONFIG_DIR_NAME = "rulesync";
|
|
389
388
|
const RULESYNC_XDG_CONFIG_HOME_DEFAULT_DIR_NAME = ".config";
|
|
390
389
|
const RULESYNC_RELATIVE_DIR_PATH = ".rulesync";
|
|
391
390
|
const RULES_FEATURE_SUBDIR = "rules";
|
|
392
|
-
const CURATED_RULES_FEATURE_SUBDIR = join$
|
|
391
|
+
const CURATED_RULES_FEATURE_SUBDIR = join$360(RULES_FEATURE_SUBDIR, ".curated");
|
|
393
392
|
const COMMANDS_FEATURE_SUBDIR = "commands";
|
|
394
393
|
const SUBAGENTS_FEATURE_SUBDIR = "subagents";
|
|
395
394
|
const CHECKS_FEATURE_SUBDIR = "checks";
|
|
396
395
|
const SKILLS_FEATURE_SUBDIR = "skills";
|
|
397
|
-
const CURATED_SKILLS_FEATURE_SUBDIR = join$
|
|
398
|
-
const RULESYNC_RULES_RELATIVE_DIR_PATH = join$
|
|
399
|
-
const RULESYNC_CURATED_RULES_RELATIVE_DIR_PATH = join$
|
|
400
|
-
const RULESYNC_COMMANDS_RELATIVE_DIR_PATH = join$
|
|
401
|
-
const RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH = join$
|
|
402
|
-
const RULESYNC_CHECKS_RELATIVE_DIR_PATH = join$
|
|
403
|
-
const RULESYNC_MCP_RELATIVE_FILE_PATH = join$
|
|
404
|
-
const RULESYNC_HOOKS_RELATIVE_FILE_PATH = join$
|
|
405
|
-
const RULESYNC_PERMISSIONS_RELATIVE_FILE_PATH = join$
|
|
406
|
-
join$
|
|
407
|
-
const RULESYNC_HOOKS_LEGACY_RELATIVE_FILE_PATH = join$
|
|
408
|
-
const RULESYNC_PERMISSIONS_LEGACY_RELATIVE_FILE_PATH = join$
|
|
396
|
+
const CURATED_SKILLS_FEATURE_SUBDIR = join$360(SKILLS_FEATURE_SUBDIR, ".curated");
|
|
397
|
+
const RULESYNC_RULES_RELATIVE_DIR_PATH = join$360(RULESYNC_RELATIVE_DIR_PATH, RULES_FEATURE_SUBDIR);
|
|
398
|
+
const RULESYNC_CURATED_RULES_RELATIVE_DIR_PATH = join$360(RULESYNC_RELATIVE_DIR_PATH, CURATED_RULES_FEATURE_SUBDIR);
|
|
399
|
+
const RULESYNC_COMMANDS_RELATIVE_DIR_PATH = join$360(RULESYNC_RELATIVE_DIR_PATH, COMMANDS_FEATURE_SUBDIR);
|
|
400
|
+
const RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH = join$360(RULESYNC_RELATIVE_DIR_PATH, SUBAGENTS_FEATURE_SUBDIR);
|
|
401
|
+
const RULESYNC_CHECKS_RELATIVE_DIR_PATH = join$360(RULESYNC_RELATIVE_DIR_PATH, CHECKS_FEATURE_SUBDIR);
|
|
402
|
+
const RULESYNC_MCP_RELATIVE_FILE_PATH = join$360(RULESYNC_RELATIVE_DIR_PATH, "mcp.jsonc");
|
|
403
|
+
const RULESYNC_HOOKS_RELATIVE_FILE_PATH = join$360(RULESYNC_RELATIVE_DIR_PATH, "hooks.jsonc");
|
|
404
|
+
const RULESYNC_PERMISSIONS_RELATIVE_FILE_PATH = join$360(RULESYNC_RELATIVE_DIR_PATH, "permissions.jsonc");
|
|
405
|
+
join$360(RULESYNC_RELATIVE_DIR_PATH, "mcp.json");
|
|
406
|
+
const RULESYNC_HOOKS_LEGACY_RELATIVE_FILE_PATH = join$360(RULESYNC_RELATIVE_DIR_PATH, "hooks.json");
|
|
407
|
+
const RULESYNC_PERMISSIONS_LEGACY_RELATIVE_FILE_PATH = join$360(RULESYNC_RELATIVE_DIR_PATH, "permissions.json");
|
|
409
408
|
const RULESYNC_AIIGNORE_FILE_NAME = ".aiignore";
|
|
410
|
-
const RULESYNC_AIIGNORE_RELATIVE_FILE_PATH = join$
|
|
409
|
+
const RULESYNC_AIIGNORE_RELATIVE_FILE_PATH = join$360(RULESYNC_RELATIVE_DIR_PATH, ".aiignore");
|
|
411
410
|
const RULESYNC_IGNORE_RELATIVE_FILE_PATH = ".rulesyncignore";
|
|
412
411
|
const RULESYNC_OVERVIEW_FILE_NAME = "overview.md";
|
|
413
|
-
const RULESYNC_SKILLS_RELATIVE_DIR_PATH = join$
|
|
414
|
-
const RULESYNC_CURATED_SKILLS_RELATIVE_DIR_PATH = join$
|
|
412
|
+
const RULESYNC_SKILLS_RELATIVE_DIR_PATH = join$360(RULESYNC_RELATIVE_DIR_PATH, SKILLS_FEATURE_SUBDIR);
|
|
413
|
+
const RULESYNC_CURATED_SKILLS_RELATIVE_DIR_PATH = join$360(RULESYNC_RELATIVE_DIR_PATH, CURATED_SKILLS_FEATURE_SUBDIR);
|
|
415
414
|
const RULESYNC_SOURCES_LOCK_RELATIVE_FILE_PATH = "rulesync.lock";
|
|
416
415
|
const RULESYNC_NPM_SOURCES_LOCK_RELATIVE_FILE_PATH = "rulesync-npm.lock.json";
|
|
417
416
|
const RULESYNC_MCP_FILE_NAME = "mcp.jsonc";
|
|
@@ -926,6 +925,7 @@ const permissionsProcessorToolTargetTuple = [
|
|
|
926
925
|
"deepagents",
|
|
927
926
|
"devin",
|
|
928
927
|
"factorydroid",
|
|
928
|
+
"gitlabduo",
|
|
929
929
|
"goose",
|
|
930
930
|
"grokcli",
|
|
931
931
|
"hermesagent",
|
|
@@ -1829,6 +1829,32 @@ async function relativeWriteLanding({ rootPath, targetPath }) {
|
|
|
1829
1829
|
return (0, node_path.relative)(rootLanding, targetLanding);
|
|
1830
1830
|
}
|
|
1831
1831
|
/**
|
|
1832
|
+
* The first symbolic link on the way from `rootPath` down to `targetPath`, or
|
|
1833
|
+
* `null` when no existing entry below the root is a link. Only the segments
|
|
1834
|
+
* below the root are looked at, so a root that is itself a link (macOS
|
|
1835
|
+
* `/tmp -> /private/tmp`, a linked home directory) does not count; nor does a
|
|
1836
|
+
* target that is not spelled below the root. Once a segment is missing,
|
|
1837
|
+
* nothing below it exists, so the walk stops there.
|
|
1838
|
+
*/
|
|
1839
|
+
async function firstLinkBelowRoot({ rootPath, targetPath }) {
|
|
1840
|
+
const relativeTarget = (0, node_path.relative)((0, node_path.resolve)(rootPath), (0, node_path.resolve)(targetPath));
|
|
1841
|
+
if (relativeTarget === "" || pathEscapesRoot(relativeTarget)) return null;
|
|
1842
|
+
let current = (0, node_path.resolve)(rootPath);
|
|
1843
|
+
for (const segment of splitPathSegments(relativeTarget)) {
|
|
1844
|
+
if (segment === "") continue;
|
|
1845
|
+
current = (0, node_path.join)(current, segment);
|
|
1846
|
+
let stats;
|
|
1847
|
+
try {
|
|
1848
|
+
stats = await (0, node_fs_promises.lstat)(current);
|
|
1849
|
+
} catch (error) {
|
|
1850
|
+
if (isFileNotFoundError(error) || isNotADirectoryError(error)) return null;
|
|
1851
|
+
throw error;
|
|
1852
|
+
}
|
|
1853
|
+
if (stats.isSymbolicLink()) return current;
|
|
1854
|
+
}
|
|
1855
|
+
return null;
|
|
1856
|
+
}
|
|
1857
|
+
/**
|
|
1832
1858
|
* Directory names that hold version-control metadata. Bytes landing in one of
|
|
1833
1859
|
* them change how the VCS behaves rather than what it tracks: `.git/config`
|
|
1834
1860
|
* can set `core.fsmonitor`, `.git/hooks/*` run on the next commit.
|
|
@@ -4485,37 +4511,6 @@ function toStringArray$1(value) {
|
|
|
4485
4511
|
function toRecord(value) {
|
|
4486
4512
|
return isRecord(value) ? value : {};
|
|
4487
4513
|
}
|
|
4488
|
-
// src/utils/yaml.ts
|
|
4489
|
-
/**
|
|
4490
|
-
* js-yaml v5's `reason` for an empty document. `load("")` — and any
|
|
4491
|
-
* whitespace/comment-only input — throws a `YAMLException` with this reason
|
|
4492
|
-
* instead of returning `undefined` the way v4 did.
|
|
4493
|
-
*/
|
|
4494
|
-
const EMPTY_INPUT_REASON = "expected a document, but the input is empty";
|
|
4495
|
-
/**
|
|
4496
|
-
* Load YAML content while preserving js-yaml v4's behavior of returning
|
|
4497
|
-
* `undefined` for empty documents (empty, whitespace-only, or comment-only
|
|
4498
|
-
* input).
|
|
4499
|
-
*
|
|
4500
|
-
* js-yaml v5 changed `load("")` to **throw** ("expected a document, but the
|
|
4501
|
-
* input is empty") instead of returning `undefined`. Many call sites here parse
|
|
4502
|
-
* config/lock/frontmatter files that can legitimately be empty and rely on the
|
|
4503
|
-
* old `undefined` sentinel (`load(input) ?? {}`, `if (loaded === undefined)`,
|
|
4504
|
-
* "an empty file parses to undefined/null"). Routing every load through this
|
|
4505
|
-
* wrapper keeps that contract in one place so a future js-yaml bump cannot
|
|
4506
|
-
* reintroduce the empty-input regression. Genuine parse errors still propagate.
|
|
4507
|
-
*
|
|
4508
|
-
* @see https://github.com/nodeca/js-yaml/blob/master/docs/migrate_v4_to_v5.md#empty-input-throws
|
|
4509
|
-
*/
|
|
4510
|
-
function loadYaml(content, options) {
|
|
4511
|
-
if (content.trim() === "") return;
|
|
4512
|
-
try {
|
|
4513
|
-
return (0, js_yaml.load)(content, options);
|
|
4514
|
-
} catch (error) {
|
|
4515
|
-
if (error instanceof js_yaml.YAMLException && error.reason === EMPTY_INPUT_REASON) return;
|
|
4516
|
-
throw error;
|
|
4517
|
-
}
|
|
4518
|
-
}
|
|
4519
4514
|
// src/utils/frontmatter.ts
|
|
4520
4515
|
/**
|
|
4521
4516
|
* Upper bound on the number of values a frontmatter document may expand to
|
|
@@ -4547,10 +4542,10 @@ const MAX_FRONTMATTER_STRING_CHARS = 4e6;
|
|
|
4547
4542
|
* block itself, checked before it is ever handed to the YAML parser.
|
|
4548
4543
|
*
|
|
4549
4544
|
* The budgets above only bound the *parsed* document — the walk over
|
|
4550
|
-
*
|
|
4545
|
+
* the parser's output — but a complex YAML key (an array or mapping used as a
|
|
4551
4546
|
* mapping key) is joined into a string by js-yaml while it parses, and a
|
|
4552
4547
|
* mapping with many such keys can cost real memory before that walk ever
|
|
4553
|
-
* starts, or even before
|
|
4548
|
+
* starts, or even before the parser returns. Capping the raw block size keeps
|
|
4554
4549
|
* that parse-time cost bounded regardless of what the block contains. Real
|
|
4555
4550
|
* frontmatter blocks are a few hundred bytes at most; even a large project
|
|
4556
4551
|
* manifest stays well under this.
|
|
@@ -4572,8 +4567,8 @@ function estimateLeafChars(value) {
|
|
|
4572
4567
|
/**
|
|
4573
4568
|
* Copy one parsed value, dropping nullish leaves and cyclic references.
|
|
4574
4569
|
*
|
|
4575
|
-
* Every alias is still written out as an independent copy, as
|
|
4576
|
-
*
|
|
4570
|
+
* Every alias is still written out as an independent copy, as js-yaml's
|
|
4571
|
+
* dumper would otherwise serialize shared references as `&ref_0`
|
|
4577
4572
|
* anchors that simplified frontmatter parsers cannot read; the expansion is
|
|
4578
4573
|
* bounded by {@link MAX_FRONTMATTER_VALUES} instead.
|
|
4579
4574
|
*/
|
|
@@ -4649,63 +4644,27 @@ function deepFlattenStringsObject(obj) {
|
|
|
4649
4644
|
function stringifyFrontmatter(body, frontmatter, options) {
|
|
4650
4645
|
const { avoidBlockScalars = false } = options ?? {};
|
|
4651
4646
|
const cleanFrontmatter = avoidBlockScalars ? deepFlattenStringsObject(frontmatter) : deepRemoveNullishObject(frontmatter);
|
|
4652
|
-
const
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
}
|
|
4659
|
-
/**
|
|
4660
|
-
* Thrown in place of gray-matter's built-in JavaScript engine.
|
|
4661
|
-
*
|
|
4662
|
-
* gray-matter picks the parser from the text after the opening fence, so a
|
|
4663
|
-
* file that opens with `---js` or `---javascript` has its frontmatter handed
|
|
4664
|
-
* to `eval()`. Frontmatter here comes from third-party skills, fetched sources
|
|
4665
|
-
* and untrusted repositories, so that would run arbitrary code on the machine
|
|
4666
|
-
* of whoever generates or imports it. Every engine name that resolves to code
|
|
4667
|
-
* execution is mapped to this refusal; {@link assertYamlFrontmatterLanguage}
|
|
4668
|
-
* refuses those fences earlier still, so this is the second line of defense.
|
|
4669
|
-
*/
|
|
4670
|
-
function refuseExecutableFrontmatter() {
|
|
4671
|
-
throw new Error("Frontmatter written in an executable language (JavaScript / CoffeeScript) is not supported; use YAML");
|
|
4672
|
-
}
|
|
4673
|
-
const REFUSED_FRONTMATTER_ENGINE = {
|
|
4674
|
-
parse: refuseExecutableFrontmatter,
|
|
4675
|
-
stringify: refuseExecutableFrontmatter
|
|
4676
|
-
};
|
|
4677
|
-
/**
|
|
4678
|
-
* Engines passed to every gray-matter parse. Supplying them merges over
|
|
4679
|
-
* gray-matter's defaults, so the JavaScript engine (and the CoffeeScript names
|
|
4680
|
-
* a plugin could register) can never be reached through an alias.
|
|
4681
|
-
*
|
|
4682
|
-
* `patches/gray-matter@4.0.3.patch` also deletes the JavaScript engine, but a
|
|
4683
|
-
* pnpm patch only applies inside this repository: gray-matter is an external
|
|
4684
|
-
* dependency of the published package, so an installed rulesync runs the
|
|
4685
|
-
* unpatched gray-matter, and this override plus the language check are what
|
|
4686
|
-
* protect it. Exported for the test that pins that.
|
|
4687
|
-
*/
|
|
4688
|
-
const FRONTMATTER_PARSE_OPTIONS = { engines: {
|
|
4689
|
-
javascript: REFUSED_FRONTMATTER_ENGINE,
|
|
4690
|
-
js: REFUSED_FRONTMATTER_ENGINE,
|
|
4691
|
-
coffee: REFUSED_FRONTMATTER_ENGINE,
|
|
4692
|
-
coffeescript: REFUSED_FRONTMATTER_ENGINE,
|
|
4693
|
-
cson: REFUSED_FRONTMATTER_ENGINE
|
|
4694
|
-
} };
|
|
4647
|
+
const yaml = (avoidBlockScalars ? (0, js_yaml.dump)(cleanFrontmatter, { lineWidth: -1 }) : (0, js_yaml_v4.dump)(cleanFrontmatter)).trim();
|
|
4648
|
+
return (yaml === "{}" ? "" : `---\n${yaml}\n---\n`) + withTrailingNewline(body);
|
|
4649
|
+
}
|
|
4650
|
+
function withTrailingNewline(text) {
|
|
4651
|
+
return text.endsWith("\n") ? text : `${text}\n`;
|
|
4652
|
+
}
|
|
4695
4653
|
/** Frontmatter languages accepted after the opening `---` fence. */
|
|
4696
4654
|
const ALLOWED_FRONTMATTER_LANGUAGE_PATTERN = /^(?:ya?ml)?$/i;
|
|
4697
4655
|
/**
|
|
4698
|
-
* Read the opening frontmatter fence
|
|
4699
|
-
*
|
|
4656
|
+
* Read the opening frontmatter fence, or return `undefined` when the content
|
|
4657
|
+
* carries no frontmatter at all.
|
|
4700
4658
|
*
|
|
4701
|
-
* gray-matter
|
|
4702
|
-
*
|
|
4703
|
-
* fence
|
|
4704
|
-
*
|
|
4705
|
-
*
|
|
4706
|
-
*
|
|
4707
|
-
*
|
|
4708
|
-
*
|
|
4659
|
+
* The grammar is gray-matter's, which rulesync used to depend on, kept so that
|
|
4660
|
+
* every file reads the same as before: one byte order mark is skipped, `---`
|
|
4661
|
+
* is a fence only when a fourth `-` does not follow, and the language is the
|
|
4662
|
+
* text between the fence and the first `\r?\n`, trimmed — dropping the last
|
|
4663
|
+
* character when there is no line break at all. Every check that has to agree
|
|
4664
|
+
* with {@link splitFrontmatter} on where the block is (the language check and
|
|
4665
|
+
* the repair pass) goes through this one reading, so none of them
|
|
4666
|
+
* can be bypassed by a fence line the splitter accepts and a stricter pattern
|
|
4667
|
+
* would not (a stray `\r` before the line break, say).
|
|
4709
4668
|
*/
|
|
4710
4669
|
function readFrontmatterFence(content) {
|
|
4711
4670
|
const offset = content.startsWith("") ? 1 : 0;
|
|
@@ -4724,26 +4683,60 @@ function readFrontmatterFence(content) {
|
|
|
4724
4683
|
/**
|
|
4725
4684
|
* Refuse a frontmatter fence that names any language other than YAML.
|
|
4726
4685
|
*
|
|
4727
|
-
* Only YAML is ever written by rulesync or by the tools it targets
|
|
4728
|
-
*
|
|
4729
|
-
*
|
|
4686
|
+
* Only YAML is ever written by rulesync or by the tools it targets. Generic
|
|
4687
|
+
* frontmatter libraries pick a parser from the fence language, and some hand a
|
|
4688
|
+
* `---js` block to `eval()`; rulesync parses everything as YAML, and refusing
|
|
4689
|
+
* any other language keeps a file meant for such a parser from being read as
|
|
4690
|
+
* something it is not.
|
|
4730
4691
|
*/
|
|
4731
4692
|
function assertYamlFrontmatterLanguage(content) {
|
|
4732
4693
|
const fence = readFrontmatterFence(content);
|
|
4733
4694
|
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`);
|
|
4734
4695
|
}
|
|
4735
4696
|
/**
|
|
4736
|
-
*
|
|
4737
|
-
*
|
|
4738
|
-
*
|
|
4739
|
-
*
|
|
4697
|
+
* Split `content` into its raw frontmatter block and its body, the way
|
|
4698
|
+
* gray-matter 4 did (see {@link readFrontmatterFence}).
|
|
4699
|
+
*
|
|
4700
|
+
* The block ends at the first `\n---`, with no requirement that the delimiter
|
|
4701
|
+
* be alone on its line, and one line break after it is dropped from the body.
|
|
4702
|
+
* A fence nothing closes makes the rest of the file the block and leaves the
|
|
4703
|
+
* body empty. Without a fence, `block` is `""` and the body is the content
|
|
4704
|
+
* minus a leading byte order mark.
|
|
4740
4705
|
*/
|
|
4741
|
-
function
|
|
4742
|
-
const
|
|
4743
|
-
if (
|
|
4744
|
-
|
|
4706
|
+
function splitFrontmatter(content) {
|
|
4707
|
+
const text = content.startsWith("") ? content.slice(1) : content;
|
|
4708
|
+
if (!text.startsWith("---") || text.charAt(3) === "-") return {
|
|
4709
|
+
block: "",
|
|
4710
|
+
body: text
|
|
4711
|
+
};
|
|
4712
|
+
let rest = text.slice(3);
|
|
4713
|
+
const rawLanguage = rest.slice(0, rest.search(/\r?\n/));
|
|
4714
|
+
if (rawLanguage.trim() !== "") rest = rest.slice(rawLanguage.length);
|
|
4745
4715
|
const closeIndex = rest.indexOf("\n---");
|
|
4746
|
-
|
|
4716
|
+
if (closeIndex === -1) return {
|
|
4717
|
+
block: rest,
|
|
4718
|
+
body: ""
|
|
4719
|
+
};
|
|
4720
|
+
let body = rest.slice(closeIndex + 4);
|
|
4721
|
+
if (body.startsWith("\r")) body = body.slice(1);
|
|
4722
|
+
if (body.startsWith("\n")) body = body.slice(1);
|
|
4723
|
+
return {
|
|
4724
|
+
block: rest.slice(0, closeIndex),
|
|
4725
|
+
body
|
|
4726
|
+
};
|
|
4727
|
+
}
|
|
4728
|
+
/**
|
|
4729
|
+
* Whether a raw block holds nothing but blank and comment lines. Checked line
|
|
4730
|
+
* by line rather than with gray-matter's `/^\s*#[^\n]+/gm`, whose `\s*` also
|
|
4731
|
+
* spans line breaks and backtracks quadratically on a long run of blank lines.
|
|
4732
|
+
* The one known difference: a lone `\r` now ends a comment line, as it does
|
|
4733
|
+
* in YAML, where the old pattern let the comment run on past it.
|
|
4734
|
+
*/
|
|
4735
|
+
function isBlankFrontmatterBlock(block) {
|
|
4736
|
+
return block.split(/\r\n|\r|\n/).every((line) => {
|
|
4737
|
+
const trimmed = line.trim();
|
|
4738
|
+
return trimmed === "" || trimmed.startsWith("#");
|
|
4739
|
+
});
|
|
4747
4740
|
}
|
|
4748
4741
|
function parseFrontmatter(content, filePath) {
|
|
4749
4742
|
let frontmatter;
|
|
@@ -4751,11 +4744,11 @@ function parseFrontmatter(content, filePath) {
|
|
|
4751
4744
|
let hasFrontmatter;
|
|
4752
4745
|
try {
|
|
4753
4746
|
assertYamlFrontmatterLanguage(content);
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
frontmatter = deepRemoveNullishObject(
|
|
4757
|
-
body =
|
|
4758
|
-
hasFrontmatter =
|
|
4747
|
+
const split = splitFrontmatter(content);
|
|
4748
|
+
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)`);
|
|
4749
|
+
frontmatter = deepRemoveNullishObject(isBlankFrontmatterBlock(split.block) ? {} : (0, js_yaml_v4.load)(split.block));
|
|
4750
|
+
body = split.body;
|
|
4751
|
+
hasFrontmatter = content === "" || split.block !== "" || content.trimStart().startsWith("---");
|
|
4759
4752
|
} catch (error) {
|
|
4760
4753
|
if (filePath) throw new Error(`Failed to parse frontmatter in ${filePath}: ${formatError(error)}`, { cause: error });
|
|
4761
4754
|
throw error;
|
|
@@ -4812,11 +4805,11 @@ function repairFrontmatterLine(line) {
|
|
|
4812
4805
|
/**
|
|
4813
4806
|
* Locate a raw `---`-delimited frontmatter block's bounds within `content`,
|
|
4814
4807
|
* without parsing it, for the YAML repair pass below and the rule loaders that
|
|
4815
|
-
* pre-process `globs:`. The opening fence is read exactly as
|
|
4808
|
+
* pre-process `globs:`. The opening fence is read exactly as the splitter reads
|
|
4816
4809
|
* it ({@link readFrontmatterFence}); an explicit `yaml` / `yml` language is
|
|
4817
|
-
* still YAML, any other language yields no bounds.
|
|
4810
|
+
* still YAML, any other language yields no bounds. The splitter ends the block
|
|
4818
4811
|
* at the first `\n---`, with no requirement that the delimiter be alone on its
|
|
4819
|
-
* line, so a stricter pattern here would run past
|
|
4812
|
+
* line, so a stricter pattern here would run past the splitter's delimiter and
|
|
4820
4813
|
* act on text that is really the body. A block with no closing fence has no
|
|
4821
4814
|
* bounds; the size guard measures that case separately.
|
|
4822
4815
|
*/
|
|
@@ -5592,20 +5585,57 @@ const CANONICAL_TO_BOB_EVENT_NAMES = {
|
|
|
5592
5585
|
stop: "Stop"
|
|
5593
5586
|
};
|
|
5594
5587
|
/**
|
|
5595
|
-
* Hook events
|
|
5588
|
+
* Hook events rulesync emits for IBM Bob from the shared `hooks` block.
|
|
5596
5589
|
*
|
|
5597
5590
|
* Bob reads `hooks` from `.bob/settings.json` (project) and
|
|
5598
5591
|
* `~/.bob/settings/settings.json` (user) in the Claude-Code shape and fires
|
|
5599
|
-
* seven events: SessionStart, UserPromptSubmit, PreToolUse,
|
|
5600
|
-
* PreCompact, PostCompact and Stop (Bob IDE and Bob Shell list
|
|
5601
|
-
* seven). Handlers are `command` or `http` hooks.
|
|
5602
|
-
*
|
|
5603
|
-
*
|
|
5592
|
+
* seven documented events: SessionStart, UserPromptSubmit, PreToolUse,
|
|
5593
|
+
* PostToolUse, PreCompact, PostCompact and Stop (Bob IDE and Bob Shell list
|
|
5594
|
+
* the same seven). Handlers are `command` or `http` hooks. Bob Shell 2.1.0
|
|
5595
|
+
* adds more events; see {@link BOB_OPT_IN_HOOK_EVENTS} for why they are not
|
|
5596
|
+
* emitted from the shared block.
|
|
5604
5597
|
*
|
|
5605
5598
|
* @see https://bob.ibm.com/docs/shell/configuration/lifecycle-hooks
|
|
5606
5599
|
* @see https://bob.ibm.com/docs/ide/configuration/lifecycle-hooks
|
|
5607
5600
|
*/
|
|
5608
5601
|
const BOB_HOOK_EVENTS = eventsOf(CANONICAL_TO_BOB_EVENT_NAMES);
|
|
5602
|
+
/**
|
|
5603
|
+
* The {@link BOB_HOOK_EVENTS} whose `matcher` regex Bob applies: the tool name
|
|
5604
|
+
* on PreToolUse / PostToolUse, `source` on SessionStart and `trigger` on
|
|
5605
|
+
* PreCompact / PostCompact. UserPromptSubmit and Stop have no matchable value.
|
|
5606
|
+
*/
|
|
5607
|
+
const BOB_MATCHER_HOOK_EVENTS = BOB_HOOK_EVENTS.filter((event) => event !== "beforeSubmitPrompt" && event !== "stop");
|
|
5608
|
+
/**
|
|
5609
|
+
* Canonical events that Bob Shell 2.1.0 (`@ibm/bob` on npm, 2026-11-09) can
|
|
5610
|
+
* fire under the native name given here, next to the override-only
|
|
5611
|
+
* `PermissionResolved`. They are not on the lifecycle-hooks pages yet.
|
|
5612
|
+
*
|
|
5613
|
+
* They are deliberately not emitted from the shared `hooks` block: Bob Shell
|
|
5614
|
+
* before 2.1.0 validates the `hooks` object strictly against the seven
|
|
5615
|
+
* documented keys, and on any unknown key it ignores that settings file's
|
|
5616
|
+
* whole `hooks` block (PreToolUse guards included). Writing them must
|
|
5617
|
+
* therefore be an explicit opt-in under the `bob.hooks` override block, by
|
|
5618
|
+
* their native name, which is emitted verbatim and imported back there.
|
|
5619
|
+
*
|
|
5620
|
+
* @see https://registry.npmjs.org/@ibm/bob/-/bob-2.1.0.tgz
|
|
5621
|
+
*/
|
|
5622
|
+
const BOB_OPT_IN_HOOK_EVENTS = {
|
|
5623
|
+
sessionEnd: "SessionEnd",
|
|
5624
|
+
permissionRequest: "PermissionRequest",
|
|
5625
|
+
notification: "Notification"
|
|
5626
|
+
};
|
|
5627
|
+
/**
|
|
5628
|
+
* Every native event key Bob Shell 2.1.0's strict hooks schema accepts: the
|
|
5629
|
+
* seven documented events, the three opt-in ones and `PermissionResolved`,
|
|
5630
|
+
* which has no canonical counterpart. Any other key under `bob.hooks` is
|
|
5631
|
+
* dropped on generate, because one unknown key makes Bob ignore the file's
|
|
5632
|
+
* whole hooks block.
|
|
5633
|
+
*/
|
|
5634
|
+
const BOB_NATIVE_HOOK_EVENTS = [
|
|
5635
|
+
...Object.values(CANONICAL_TO_BOB_EVENT_NAMES),
|
|
5636
|
+
...Object.values(BOB_OPT_IN_HOOK_EVENTS),
|
|
5637
|
+
"PermissionResolved"
|
|
5638
|
+
];
|
|
5609
5639
|
const BOB_TO_CANONICAL_EVENT_NAMES = invertRecord(CANONICAL_TO_BOB_EVENT_NAMES);
|
|
5610
5640
|
const CANONICAL_TO_TABNINE_EVENT_NAMES = {
|
|
5611
5641
|
sessionStart: "SessionStart",
|
|
@@ -5888,17 +5918,18 @@ const CONTINUE_TO_CANONICAL_EVENT_NAMES = invertRecord(CANONICAL_TO_CONTINUE_EVE
|
|
|
5888
5918
|
* observers, `gateway_platform_event` and `transform_api_error_classification`.
|
|
5889
5919
|
* Shell hooks are gated on the same set.
|
|
5890
5920
|
*
|
|
5891
|
-
* Verified against the tag `v0.23.
|
|
5921
|
+
* Verified against the tag `v0.23.4`: `VALID_HOOKS` holds 50 entries, grown
|
|
5892
5922
|
* from 23 at `v2026.8.3` (v0.20.0) and 37 at `v2026.8.16` (v0.20.2) — v0.21
|
|
5893
5923
|
* added `agent_loop_stopped` and `on_room_member_activity`, v0.21.5 added
|
|
5894
5924
|
* `pre_auxiliary_call` and `post_auxiliary_call`, v0.21.6 added
|
|
5895
5925
|
* `post_gateway_admission`, `on_human_input_request` and
|
|
5896
5926
|
* `on_human_input_resolved`, v0.22.3 added `on_session_delete` and
|
|
5897
|
-
* `post_compaction`,
|
|
5898
|
-
* `post_curator_run
|
|
5927
|
+
* `post_compaction`, v0.23.1 added `on_session_open` and
|
|
5928
|
+
* `post_curator_run`, and v0.23.4 added `on_session_prompt` and
|
|
5929
|
+
* `on_session_prompt_settled`. This list holds 49 of them — see
|
|
5899
5930
|
* {@link HERMESAGENT_SHELL_UNSUPPORTED_HOOK_EVENTS} for the exclusion.
|
|
5900
5931
|
*
|
|
5901
|
-
* @see https://github.com/NousResearch/hermes-agent/blob/v0.23.
|
|
5932
|
+
* @see https://github.com/NousResearch/hermes-agent/blob/v0.23.4/hermes_cli/plugins.py
|
|
5902
5933
|
*/
|
|
5903
5934
|
const HERMESAGENT_NATIVE_HOOK_EVENTS = [
|
|
5904
5935
|
"pre_tool_call",
|
|
@@ -5924,6 +5955,8 @@ const HERMESAGENT_NATIVE_HOOK_EVENTS = [
|
|
|
5924
5955
|
"on_session_reset",
|
|
5925
5956
|
"on_session_delete",
|
|
5926
5957
|
"on_session_open",
|
|
5958
|
+
"on_session_prompt",
|
|
5959
|
+
"on_session_prompt_settled",
|
|
5927
5960
|
"on_skill_lifecycle",
|
|
5928
5961
|
"subagent_start",
|
|
5929
5962
|
"subagent_stop",
|
|
@@ -5959,8 +5992,8 @@ const HERMESAGENT_NATIVE_HOOK_EVENTS = [
|
|
|
5959
5992
|
* rulesync only ever writes shell hooks, so these are excluded from
|
|
5960
5993
|
* {@link HERMESAGENT_NATIVE_HOOK_EVENTS} and warned about with their own message.
|
|
5961
5994
|
*
|
|
5962
|
-
* @see https://github.com/NousResearch/hermes-agent/blob/v0.23.
|
|
5963
|
-
* @see https://github.com/NousResearch/hermes-agent/blob/v0.23.
|
|
5995
|
+
* @see https://github.com/NousResearch/hermes-agent/blob/v0.23.4/hermes_cli/plugins.py — `SHELL_UNSUPPORTED_HOOKS`
|
|
5996
|
+
* @see https://github.com/NousResearch/hermes-agent/blob/v0.23.4/agent/shell_hooks.py — `_parse_hooks_block`
|
|
5964
5997
|
*/
|
|
5965
5998
|
const HERMESAGENT_SHELL_UNSUPPORTED_HOOK_EVENTS = ["transform_api_error_classification"];
|
|
5966
5999
|
/**
|
|
@@ -5980,8 +6013,8 @@ const CANONICAL_TO_HERMESAGENT_EVENT_NAMES = {
|
|
|
5980
6013
|
/**
|
|
5981
6014
|
* Hook events supported by Hermes Agent's native Shell Hooks system.
|
|
5982
6015
|
*
|
|
5983
|
-
* Hermes validates hook events against a fixed `VALID_HOOKS` set —
|
|
5984
|
-
* of v0.23.
|
|
6016
|
+
* Hermes validates hook events against a fixed `VALID_HOOKS` set — 50 entries as
|
|
6017
|
+
* of v0.23.4 (tag `v0.23.4`); see {@link HERMESAGENT_NATIVE_HOOK_EVENTS} for the
|
|
5985
6018
|
* full list. Only the events with a clean 1:1 canonical equivalent are mapped
|
|
5986
6019
|
* here. All other native events round-trip through `hermesagent.hooks`.
|
|
5987
6020
|
* @see https://github.com/NousResearch/hermes-agent/blob/main/website/docs/user-guide/features/hooks.md
|
|
@@ -9798,6 +9831,7 @@ const PermissionsConfigSchema = zod_mini.z.looseObject({
|
|
|
9798
9831
|
commandcode: zod_mini.z.optional(CommandcodePermissionsOverrideSchema),
|
|
9799
9832
|
lettacode: zod_mini.z.optional(CanonicalPermissionsOverrideSchema),
|
|
9800
9833
|
crush: zod_mini.z.optional(CanonicalPermissionsOverrideSchema),
|
|
9834
|
+
gitlabduo: zod_mini.z.optional(CanonicalPermissionsOverrideSchema),
|
|
9801
9835
|
goose: zod_mini.z.optional(CanonicalPermissionsOverrideSchema),
|
|
9802
9836
|
omp: zod_mini.z.optional(OmpPermissionsOverrideSchema),
|
|
9803
9837
|
pool: zod_mini.z.optional(CanonicalPermissionsOverrideSchema),
|
|
@@ -12731,6 +12765,37 @@ function serialize(value) {
|
|
|
12731
12765
|
function stripStrings(_key, value) {
|
|
12732
12766
|
return typeof value === "string" ? stripControlCharacters(value) : value;
|
|
12733
12767
|
}
|
|
12768
|
+
// src/utils/yaml.ts
|
|
12769
|
+
/**
|
|
12770
|
+
* js-yaml v5's `reason` for an empty document. `load("")` — and any
|
|
12771
|
+
* whitespace/comment-only input — throws a `YAMLException` with this reason
|
|
12772
|
+
* instead of returning `undefined` the way v4 did.
|
|
12773
|
+
*/
|
|
12774
|
+
const EMPTY_INPUT_REASON = "expected a document, but the input is empty";
|
|
12775
|
+
/**
|
|
12776
|
+
* Load YAML content while preserving js-yaml v4's behavior of returning
|
|
12777
|
+
* `undefined` for empty documents (empty, whitespace-only, or comment-only
|
|
12778
|
+
* input).
|
|
12779
|
+
*
|
|
12780
|
+
* js-yaml v5 changed `load("")` to **throw** ("expected a document, but the
|
|
12781
|
+
* input is empty") instead of returning `undefined`. Many call sites here parse
|
|
12782
|
+
* config/lock/frontmatter files that can legitimately be empty and rely on the
|
|
12783
|
+
* old `undefined` sentinel (`load(input) ?? {}`, `if (loaded === undefined)`,
|
|
12784
|
+
* "an empty file parses to undefined/null"). Routing every load through this
|
|
12785
|
+
* wrapper keeps that contract in one place so a future js-yaml bump cannot
|
|
12786
|
+
* reintroduce the empty-input regression. Genuine parse errors still propagate.
|
|
12787
|
+
*
|
|
12788
|
+
* @see https://github.com/nodeca/js-yaml/blob/master/docs/migrate_v4_to_v5.md#empty-input-throws
|
|
12789
|
+
*/
|
|
12790
|
+
function loadYaml(content, options) {
|
|
12791
|
+
if (content.trim() === "") return;
|
|
12792
|
+
try {
|
|
12793
|
+
return (0, js_yaml.load)(content, options);
|
|
12794
|
+
} catch (error) {
|
|
12795
|
+
if (error instanceof js_yaml.YAMLException && error.reason === EMPTY_INPUT_REASON) return;
|
|
12796
|
+
throw error;
|
|
12797
|
+
}
|
|
12798
|
+
}
|
|
12734
12799
|
// src/features/shared/jsonc-object-edit.ts
|
|
12735
12800
|
/**
|
|
12736
12801
|
* In-place editing of a JSONC object's text: the engine behind the shared
|
|
@@ -14741,7 +14806,7 @@ function tryParseStructured({ filePath, content }) {
|
|
|
14741
14806
|
}
|
|
14742
14807
|
}
|
|
14743
14808
|
/**
|
|
14744
|
-
*
|
|
14809
|
+
* The parsed body often starts with extra newlines right after the closing ---; strip those so the
|
|
14745
14810
|
* body matches across generators vs on-disk formatters. Trailing whitespace is normalized via
|
|
14746
14811
|
* addTrailingNewline (trimEnd + single newline), same as writes.
|
|
14747
14812
|
*/
|
|
@@ -14832,7 +14897,7 @@ function fileContentIsEmptyPayload({ filePath, content }) {
|
|
|
14832
14897
|
* Whether on-disk content is equivalent to generated content for --check / dry-run.
|
|
14833
14898
|
*
|
|
14834
14899
|
* Uses structured comparison for JSON/JSONC (via jsonc-parser), YAML, TOML, and Markdown-like
|
|
14835
|
-
* frontmatter files (.md, .mdc — same
|
|
14900
|
+
* frontmatter files (.md, .mdc — same frontmatter parser as elsewhere).
|
|
14836
14901
|
*/
|
|
14837
14902
|
function fileContentsEquivalent({ filePath, expected, existing }) {
|
|
14838
14903
|
if (existing === null) return false;
|
|
@@ -15014,6 +15079,11 @@ var FeatureProcessor = class extends RulesyncSourceConsumer {
|
|
|
15014
15079
|
if (fileMode !== void 0 && !this.dryRun) await restoreMissingExecutableBit(filePath, fileMode);
|
|
15015
15080
|
continue;
|
|
15016
15081
|
}
|
|
15082
|
+
await warnIfWriteFollowsLink({
|
|
15083
|
+
logger: this.logger,
|
|
15084
|
+
rootPath: aiFile.getOutputRoot(),
|
|
15085
|
+
targetPath: filePath
|
|
15086
|
+
});
|
|
15017
15087
|
if (this.dryRun) this.logger.info(`[DRY RUN] Would write: ${stripControlCharacters(filePath)}`);
|
|
15018
15088
|
else {
|
|
15019
15089
|
await writeFileContent(filePath, contentWithNewline);
|
|
@@ -15198,6 +15268,37 @@ async function refusesWriteOutsideRoot({ logger, rootPath, targetPath }) {
|
|
|
15198
15268
|
return true;
|
|
15199
15269
|
}
|
|
15200
15270
|
/**
|
|
15271
|
+
* Warn, once per run and link, that a write to `targetPath` goes through a
|
|
15272
|
+
* symbolic link below `rootPath`: the warning names the link and the real path
|
|
15273
|
+
* it leads to, so the file the write really changes is visible.
|
|
15274
|
+
*
|
|
15275
|
+
* Links that lead out of the root (or into version-control metadata) are
|
|
15276
|
+
* refused by {@link refusesWriteOutsideRoot} before this is asked; an in-root
|
|
15277
|
+
* link is written through on purpose (dotfiles setups rely on it), but a
|
|
15278
|
+
* committed `AGENTS.md -> .claude/CLAUDE.md` would otherwise have one target
|
|
15279
|
+
* silently replace another target's file. Writers call this only for a file
|
|
15280
|
+
* they are about to change (or, in a dry run, would change), so an unchanged
|
|
15281
|
+
* file reached through a link stays quiet. The warning is keyed on the first
|
|
15282
|
+
* link on the path rather than on the file, so a linked directory such as
|
|
15283
|
+
* `~/.claude -> ~/dotfiles/.claude` is reported once however many files below
|
|
15284
|
+
* it a run writes.
|
|
15285
|
+
*/
|
|
15286
|
+
async function warnIfWriteFollowsLink({ logger, rootPath, targetPath }) {
|
|
15287
|
+
const linkPath = await firstLinkBelowRoot({
|
|
15288
|
+
rootPath,
|
|
15289
|
+
targetPath
|
|
15290
|
+
});
|
|
15291
|
+
if (linkPath === null) return;
|
|
15292
|
+
const linkLanding = await writeLandingPath(linkPath);
|
|
15293
|
+
if (linkLanding === null) return;
|
|
15294
|
+
warnOnceWithFallback(logger, `${quoteForLog(linkPath)} is a symbolic link to ${quoteForLog(linkLanding)}; files rulesync writes through it land there`);
|
|
15295
|
+
const restOfPath = (0, node_path.relative)(linkPath, (0, node_path.resolve)(targetPath));
|
|
15296
|
+
if (restOfPath === "") return;
|
|
15297
|
+
const targetLanding = await writeLandingPath(targetPath);
|
|
15298
|
+
if (targetLanding === null || targetLanding === (0, node_path.join)(linkLanding, restOfPath)) return;
|
|
15299
|
+
warnOnceWithFallback(logger, `${quoteForLog(targetPath)} is reached through further symbolic links; rulesync writes it to ${quoteForLog(targetLanding)}`);
|
|
15300
|
+
}
|
|
15301
|
+
/**
|
|
15201
15302
|
* Why the orphan sweep has to leave the files in `dirPath` alone, or `null`
|
|
15202
15303
|
* when it may delete them.
|
|
15203
15304
|
*
|
|
@@ -18240,6 +18341,14 @@ const GITLABDUO_DIR = (0, node_path.join)(".gitlab", "duo");
|
|
|
18240
18341
|
const GITLABDUO_RULE_FILE_NAME = "chat-rules.md";
|
|
18241
18342
|
/** MCP servers. @see https://docs.gitlab.com/user/gitlab_duo/model_context_protocol/mcp_clients/ */
|
|
18242
18343
|
const GITLABDUO_MCP_FILE_NAME = "mcp.json";
|
|
18344
|
+
/**
|
|
18345
|
+
* Settings. Only the user file `~/.gitlab/duo/settings.json` carries the
|
|
18346
|
+
* `permissions` setting rulesync writes; the project files are deliberately not
|
|
18347
|
+
* read for it.
|
|
18348
|
+
*
|
|
18349
|
+
* @see https://gitlab.com/gitlab-org/editor-extensions/gitlab-lsp/-/blob/v10.5.0/packages/core/settings/src/definitions.ts
|
|
18350
|
+
*/
|
|
18351
|
+
const GITLABDUO_SETTINGS_FILE_NAME = "settings.json";
|
|
18243
18352
|
/** Lifecycle hooks (experiment). @see https://docs.gitlab.com/user/gitlab_duo_cli/customize/ */
|
|
18244
18353
|
const GITLABDUO_HOOKS_FILE_NAME = "hooks.json";
|
|
18245
18354
|
/** Merge request review instructions. @see https://docs.gitlab.com/user/project/merge_requests/duo_in_merge_requests/ */
|
|
@@ -18532,6 +18641,11 @@ var GooseCommand = class GooseCommand extends ToolCommand {
|
|
|
18532
18641
|
entries: []
|
|
18533
18642
|
});
|
|
18534
18643
|
if (nextContent === currentContent) return 0;
|
|
18644
|
+
await warnIfWriteFollowsLink({
|
|
18645
|
+
logger,
|
|
18646
|
+
rootPath: outputRoot,
|
|
18647
|
+
targetPath: configPath
|
|
18648
|
+
});
|
|
18535
18649
|
if (dryRun) logger.info(`[DRY RUN] Would write: ${configPath}`);
|
|
18536
18650
|
else await writeFileContent(configPath, nextContent);
|
|
18537
18651
|
return 1;
|
|
@@ -19714,6 +19828,11 @@ var HermesagentCommand = class HermesagentCommand extends ToolCommand {
|
|
|
19714
19828
|
global
|
|
19715
19829
|
});
|
|
19716
19830
|
if (nextContent === currentContent) return 0;
|
|
19831
|
+
await warnIfWriteFollowsLink({
|
|
19832
|
+
logger,
|
|
19833
|
+
rootPath: outputRoot,
|
|
19834
|
+
targetPath: configPath
|
|
19835
|
+
});
|
|
19717
19836
|
if (dryRun) logger.info(`[DRY RUN] Would write: ${configPath}`);
|
|
19718
19837
|
else await writeFileContent(configPath, nextContent);
|
|
19719
19838
|
return 1;
|
|
@@ -23330,6 +23449,17 @@ var DirFeatureProcessor = class extends RulesyncSourceConsumer {
|
|
|
23330
23449
|
});
|
|
23331
23450
|
}
|
|
23332
23451
|
/**
|
|
23452
|
+
* Warn about each file of `aiDir` about to be written through a symbolic link
|
|
23453
|
+
* that stays inside the output root (see {@link warnIfWriteFollowsLink}).
|
|
23454
|
+
*/
|
|
23455
|
+
async warnIfFilesFollowLinks({ aiDir, filePaths }) {
|
|
23456
|
+
for (const targetPath of filePaths) await warnIfWriteFollowsLink({
|
|
23457
|
+
logger: this.logger,
|
|
23458
|
+
rootPath: aiDir.getOutputRoot(),
|
|
23459
|
+
targetPath
|
|
23460
|
+
});
|
|
23461
|
+
}
|
|
23462
|
+
/**
|
|
23333
23463
|
* Once converted to rulesync/tool dirs, write them to the filesystem.
|
|
23334
23464
|
* Returns the number of directories written.
|
|
23335
23465
|
*
|
|
@@ -23382,6 +23512,10 @@ var DirFeatureProcessor = class extends RulesyncSourceConsumer {
|
|
|
23382
23512
|
}
|
|
23383
23513
|
continue;
|
|
23384
23514
|
}
|
|
23515
|
+
await this.warnIfFilesFollowLinks({
|
|
23516
|
+
aiDir,
|
|
23517
|
+
filePaths: writtenPaths.slice(1)
|
|
23518
|
+
});
|
|
23385
23519
|
const relativeDir = aiDir.getRelativePathFromCwd();
|
|
23386
23520
|
if (this.dryRun) {
|
|
23387
23521
|
this.logger.info(`[DRY RUN] Would create directory: ${stripControlCharacters(dirPath)}`);
|
|
@@ -34569,6 +34703,24 @@ function isMissingDescription(value) {
|
|
|
34569
34703
|
function nameFromFileName(relativeFilePath) {
|
|
34570
34704
|
return relativeFilePath.replace(/(\.agent)?\.md$/, "");
|
|
34571
34705
|
}
|
|
34706
|
+
/**
|
|
34707
|
+
* Normalizes a subagent name the way Junie does: the result is what Junie
|
|
34708
|
+
* accepts for `--agent` and must match `[a-z0-9][a-z0-9_-]*`.
|
|
34709
|
+
*
|
|
34710
|
+
* - Surrounding whitespace is trimmed first, so a quoted `" Code Reviewer "`
|
|
34711
|
+
* (or a file named ` Reviewer.md`) does not start or end with a hyphen,
|
|
34712
|
+
* which the leading-character rule would reject.
|
|
34713
|
+
* - Uppercase letters are lowercased.
|
|
34714
|
+
* - Each run of whitespace (spaces, tabs, ...) becomes a single hyphen. The
|
|
34715
|
+
* upstream docs only say Junie "replaces spaces with hyphens"; collapsing
|
|
34716
|
+
* runs gives `code-reviewer` for `Code Reviewer`, which is the name a user
|
|
34717
|
+
* would expect and still matches the pattern, instead of `code--reviewer`.
|
|
34718
|
+
*
|
|
34719
|
+
* @see https://junie.jetbrains.com/docs/junie-cli-subagents.html
|
|
34720
|
+
*/
|
|
34721
|
+
function normalizeJunieName(name) {
|
|
34722
|
+
return name.trim().toLowerCase().replace(/\s+/g, "-");
|
|
34723
|
+
}
|
|
34572
34724
|
var JunieSubagent = class JunieSubagent extends ToolSubagent {
|
|
34573
34725
|
frontmatter;
|
|
34574
34726
|
body;
|
|
@@ -34593,14 +34745,30 @@ var JunieSubagent = class JunieSubagent extends ToolSubagent {
|
|
|
34593
34745
|
getBody() {
|
|
34594
34746
|
return this.body;
|
|
34595
34747
|
}
|
|
34748
|
+
/**
|
|
34749
|
+
* The name Junie resolves after normalization, so `Code Reviewer.md` and
|
|
34750
|
+
* `code-reviewer.md` (both `code-reviewer`) are reported as duplicates on
|
|
34751
|
+
* import instead of becoming two rulesync subagents with the same name.
|
|
34752
|
+
*/
|
|
34753
|
+
getImportIdentity() {
|
|
34754
|
+
return this.getNormalizedName();
|
|
34755
|
+
}
|
|
34756
|
+
/**
|
|
34757
|
+
* An empty or whitespace-only `name` would normalize to `""`, which is not a
|
|
34758
|
+
* valid Junie name and would make every such file share one import identity,
|
|
34759
|
+
* so it falls back to the file name just like a missing `name` does.
|
|
34760
|
+
*/
|
|
34761
|
+
getNormalizedName() {
|
|
34762
|
+
return (this.frontmatter.name === void 0 ? "" : normalizeJunieName(this.frontmatter.name)) || normalizeJunieName(nameFromFileName(this.getRelativeFilePath()));
|
|
34763
|
+
}
|
|
34596
34764
|
toRulesyncSubagent() {
|
|
34597
|
-
const { name, description, ...restFields } = this.frontmatter;
|
|
34765
|
+
const { name: _name, description, ...restFields } = this.frontmatter;
|
|
34598
34766
|
const junieSection = { ...restFields };
|
|
34599
34767
|
return new RulesyncSubagent({
|
|
34600
34768
|
outputRoot: ".",
|
|
34601
34769
|
frontmatter: {
|
|
34602
34770
|
targets: ["*"],
|
|
34603
|
-
name:
|
|
34771
|
+
name: this.getNormalizedName(),
|
|
34604
34772
|
...description !== void 0 && { description },
|
|
34605
34773
|
...Object.keys(junieSection).length > 0 && { junie: junieSection }
|
|
34606
34774
|
},
|
|
@@ -36971,8 +37139,208 @@ const VIBE_PROMPTS_DIR_PATH = (0, node_path.join)(".vibe", "prompts");
|
|
|
36971
37139
|
* @see https://github.com/mistralai/mistral-vibe/blob/v3.0.3/vibe/core/agents/models.py
|
|
36972
37140
|
*/
|
|
36973
37141
|
const VIBE_RESERVED_AGENT_NAME = "main";
|
|
37142
|
+
/**
|
|
37143
|
+
* The approval policies Vibe ships since v3.1.4. `AgentRegistry._discover`
|
|
37144
|
+
* never loads an agents-directory file named after one as an agent, whatever
|
|
37145
|
+
* its `agent_type`: from a project's `.vibe/agents/` the file is ignored with
|
|
37146
|
+
* an `approval_policy.project_override_ignored` config issue, and from
|
|
37147
|
+
* `~/.vibe/agents/` it redefines that approval policy for every session. Vibe
|
|
37148
|
+
* compares the file stem exactly (`agent.name in BUILTIN_APPROVAL_POLICIES`).
|
|
37149
|
+
* @see https://github.com/mistralai/mistral-vibe/blob/v3.1.5/vibe/core/agents/registry.py
|
|
37150
|
+
* @see https://github.com/mistralai/mistral-vibe/blob/v3.1.5/vibe/core/agents/models.py
|
|
37151
|
+
*/
|
|
37152
|
+
const VIBE_APPROVAL_POLICY_NAMES = /* @__PURE__ */ new Set([
|
|
37153
|
+
"ask",
|
|
37154
|
+
"accept-edits",
|
|
37155
|
+
"smart-approve",
|
|
37156
|
+
"auto-approve"
|
|
37157
|
+
]);
|
|
37158
|
+
function vibeAgentFileStem(relativeFilePath) {
|
|
37159
|
+
return (0, node_path.basename)(relativeFilePath).replace(/\.(md|toml)$/, "");
|
|
37160
|
+
}
|
|
36974
37161
|
function isReservedVibeAgentFileName(relativeFilePath) {
|
|
36975
|
-
return (
|
|
37162
|
+
return vibeAgentFileStem(relativeFilePath).toLowerCase() === VIBE_RESERVED_AGENT_NAME;
|
|
37163
|
+
}
|
|
37164
|
+
function isVibeApprovalPolicyFileName(relativeFilePath) {
|
|
37165
|
+
return VIBE_APPROVAL_POLICY_NAMES.has(vibeAgentFileStem(relativeFilePath));
|
|
37166
|
+
}
|
|
37167
|
+
/**
|
|
37168
|
+
* The keys Vibe ignores on a custom `agent_type = "agent"` profile since
|
|
37169
|
+
* v3.1.4, listing each as a config issue: `_agent_settings` drops every
|
|
37170
|
+
* `VibeConfigSchema` field outside its `_AGENT_KEYS`, plus `safety` and
|
|
37171
|
+
* `approval_policy`, because what runs without asking belongs to the approval
|
|
37172
|
+
* policy, not to the agent. A key outside this list is kept, as Vibe keeps it:
|
|
37173
|
+
* an agent key passes, and an unknown key (a typo such as `disabled_tool`)
|
|
37174
|
+
* stays so Vibe can report it — or refuse it under `strict_config`.
|
|
37175
|
+
* Generated from the `VibeConfigSchema` fields of v3.1.5 minus `_AGENT_KEYS`.
|
|
37176
|
+
* @see https://github.com/mistralai/mistral-vibe/blob/v3.1.5/vibe/core/agents/models.py
|
|
37177
|
+
* @see https://github.com/mistralai/mistral-vibe/blob/v3.1.5/vibe/core/config/vibe_schema.py
|
|
37178
|
+
*/
|
|
37179
|
+
const VIBE_AGENT_IGNORED_KEYS = /* @__PURE__ */ new Set([
|
|
37180
|
+
"safety",
|
|
37181
|
+
"approval_policy",
|
|
37182
|
+
"catalog_model_aliases",
|
|
37183
|
+
"catalog_recommended_model",
|
|
37184
|
+
"catalog_default_model",
|
|
37185
|
+
"utility_models",
|
|
37186
|
+
"active_transcribe_model",
|
|
37187
|
+
"transcribe_providers",
|
|
37188
|
+
"transcribe_models",
|
|
37189
|
+
"active_tts_model",
|
|
37190
|
+
"tts_providers",
|
|
37191
|
+
"tts_models",
|
|
37192
|
+
"outside_workdir",
|
|
37193
|
+
"mcp_servers",
|
|
37194
|
+
"enable_connectors",
|
|
37195
|
+
"enable_mcp",
|
|
37196
|
+
"experimental_enable_document_library_connector",
|
|
37197
|
+
"experimental_enable_mistral_mcp_connector",
|
|
37198
|
+
"connectors",
|
|
37199
|
+
"agent_paths",
|
|
37200
|
+
"enabled_agents",
|
|
37201
|
+
"disabled_agents",
|
|
37202
|
+
"installed_agents",
|
|
37203
|
+
"default_agent",
|
|
37204
|
+
"default_approval_policy",
|
|
37205
|
+
"vibe_bot_max_approval_policy",
|
|
37206
|
+
"vibe_bot_local_tools",
|
|
37207
|
+
"vibe_bot_local_tool_max_bytes",
|
|
37208
|
+
"smart_approve_available",
|
|
37209
|
+
"enable_auto_approve",
|
|
37210
|
+
"enabled_plugins",
|
|
37211
|
+
"disabled_plugins",
|
|
37212
|
+
"experimental_enable_remote_plugins",
|
|
37213
|
+
"experimental_enable_registry_skills",
|
|
37214
|
+
"enable_model_catalog",
|
|
37215
|
+
"enable_builtin_models",
|
|
37216
|
+
"experimental_enable_storage_usage",
|
|
37217
|
+
"enable_pr_monitoring",
|
|
37218
|
+
"experimental_local_runtime_session_api",
|
|
37219
|
+
"experimental_target_runtime",
|
|
37220
|
+
"enable_otel",
|
|
37221
|
+
"otel_endpoint",
|
|
37222
|
+
"otel_redaction",
|
|
37223
|
+
"console_base_url",
|
|
37224
|
+
"theme",
|
|
37225
|
+
"applied_migrations",
|
|
37226
|
+
"disable_welcome_banner_animation",
|
|
37227
|
+
"disable_selection_animation",
|
|
37228
|
+
"cursor_blink",
|
|
37229
|
+
"vim_keybindings",
|
|
37230
|
+
"show_dangerous_directory_warning",
|
|
37231
|
+
"autocopy_to_clipboard",
|
|
37232
|
+
"enable_mouse_capture",
|
|
37233
|
+
"enable_sticky_prompt",
|
|
37234
|
+
"collapse_turn_details",
|
|
37235
|
+
"enable_file_autocomplete",
|
|
37236
|
+
"file_watcher_for_autocomplete",
|
|
37237
|
+
"ask_confirmation_on_exit",
|
|
37238
|
+
"displayed_workdir",
|
|
37239
|
+
"context_warnings",
|
|
37240
|
+
"voice_mode_enabled",
|
|
37241
|
+
"narrator_enabled",
|
|
37242
|
+
"show_thinking_nodes",
|
|
37243
|
+
"show_subagent_status_list",
|
|
37244
|
+
"worktree_limit",
|
|
37245
|
+
"auto_worktree",
|
|
37246
|
+
"worktree_copy_on_write",
|
|
37247
|
+
"bypass_tool_permissions",
|
|
37248
|
+
"raise_on_compaction_failure",
|
|
37249
|
+
"enable_telemetry",
|
|
37250
|
+
"managed_shell_tools_enabled",
|
|
37251
|
+
"enable_background_processes",
|
|
37252
|
+
"enable_subagents",
|
|
37253
|
+
"max_subagents",
|
|
37254
|
+
"max_concurrent_subagents",
|
|
37255
|
+
"compaction_prompt_id",
|
|
37256
|
+
"title_prompt_id",
|
|
37257
|
+
"include_commit_signature",
|
|
37258
|
+
"include_model_info",
|
|
37259
|
+
"include_project_context",
|
|
37260
|
+
"include_prompt_detail",
|
|
37261
|
+
"strict_config",
|
|
37262
|
+
"enable_update_checks",
|
|
37263
|
+
"enable_auto_update",
|
|
37264
|
+
"enable_notifications",
|
|
37265
|
+
"keep_awake",
|
|
37266
|
+
"experimental_enable_tab_status",
|
|
37267
|
+
"enable_system_trust_store",
|
|
37268
|
+
"api_timeout",
|
|
37269
|
+
"api_retry_max_elapsed_time",
|
|
37270
|
+
"max_goal_token_budget",
|
|
37271
|
+
"api_stream_idle_timeout",
|
|
37272
|
+
"agent_max_output_tokens",
|
|
37273
|
+
"compaction_max_output_tokens",
|
|
37274
|
+
"compaction_reasoning_limit_tokens",
|
|
37275
|
+
"output_limit_retries",
|
|
37276
|
+
"api_connect_timeout",
|
|
37277
|
+
"api_write_timeout",
|
|
37278
|
+
"api_pool_timeout",
|
|
37279
|
+
"vibe_base_url",
|
|
37280
|
+
"vibe_code_sessions_base_url",
|
|
37281
|
+
"log_level",
|
|
37282
|
+
"project_context",
|
|
37283
|
+
"session_logging",
|
|
37284
|
+
"experiments"
|
|
37285
|
+
]);
|
|
37286
|
+
/**
|
|
37287
|
+
* The legacy key Vibe folds into `disabled_tools` before it filters an agent
|
|
37288
|
+
* profile (`migrate_agent_profile_config`).
|
|
37289
|
+
* @see https://github.com/mistralai/mistral-vibe/blob/v3.1.5/vibe/core/agents/_migration.py
|
|
37290
|
+
*/
|
|
37291
|
+
const VIBE_LEGACY_BASE_DISABLED_KEY = "base_disabled";
|
|
37292
|
+
/** Per tool, an agent keeps only the shell timeouts and a narrowing `permission`. */
|
|
37293
|
+
const VIBE_AGENT_TOOL_KEYS = /* @__PURE__ */ new Set(["default_timeout", "max_timeout_seconds"]);
|
|
37294
|
+
const VIBE_AGENT_NARROWING_PERMISSIONS = /* @__PURE__ */ new Set(["ask", "never"]);
|
|
37295
|
+
/**
|
|
37296
|
+
* Fold a legacy `base_disabled` list into `disabled_tools` the way Vibe's
|
|
37297
|
+
* `migrate_agent_profile_config` does, so the restriction it carries is kept.
|
|
37298
|
+
*/
|
|
37299
|
+
function migrateVibeBaseDisabled(tomlObj) {
|
|
37300
|
+
const legacyDisabled = tomlObj[VIBE_LEGACY_BASE_DISABLED_KEY];
|
|
37301
|
+
if (!Array.isArray(legacyDisabled)) return tomlObj;
|
|
37302
|
+
const rest = Object.fromEntries(Object.entries(tomlObj).filter(([key]) => key !== VIBE_LEGACY_BASE_DISABLED_KEY));
|
|
37303
|
+
const disabledTools = rest.disabled_tools;
|
|
37304
|
+
return {
|
|
37305
|
+
...rest,
|
|
37306
|
+
disabled_tools: Array.isArray(disabledTools) ? [.../* @__PURE__ */ new Set([...disabledTools, ...legacyDisabled])] : legacyDisabled
|
|
37307
|
+
};
|
|
37308
|
+
}
|
|
37309
|
+
/**
|
|
37310
|
+
* Drop the settings Vibe ignores on an `agent_type = "agent"` profile, so the
|
|
37311
|
+
* generated file does not pretend to grant what Vibe refuses. Mirrors Vibe's
|
|
37312
|
+
* `_agent_settings`; returns the kept TOML object and the dotted keys that
|
|
37313
|
+
* were dropped.
|
|
37314
|
+
*/
|
|
37315
|
+
function stripVibeAgentIgnoredSettings(tomlObj) {
|
|
37316
|
+
const kept = {};
|
|
37317
|
+
const dropped = [];
|
|
37318
|
+
for (const [key, value] of Object.entries(migrateVibeBaseDisabled(tomlObj))) {
|
|
37319
|
+
if (VIBE_AGENT_IGNORED_KEYS.has(key)) {
|
|
37320
|
+
dropped.push(key);
|
|
37321
|
+
continue;
|
|
37322
|
+
}
|
|
37323
|
+
if (key !== "tools" || typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
37324
|
+
kept[key] = value;
|
|
37325
|
+
continue;
|
|
37326
|
+
}
|
|
37327
|
+
const tools = {};
|
|
37328
|
+
for (const [tool, settings] of Object.entries(value)) {
|
|
37329
|
+
if (typeof settings !== "object" || settings === null || Array.isArray(settings)) {
|
|
37330
|
+
dropped.push(`tools.${tool}`);
|
|
37331
|
+
continue;
|
|
37332
|
+
}
|
|
37333
|
+
const own = {};
|
|
37334
|
+
for (const [setting, settingValue] of Object.entries(settings)) if (VIBE_AGENT_TOOL_KEYS.has(setting) || setting === "permission" && VIBE_AGENT_NARROWING_PERMISSIONS.has(settingValue)) own[setting] = settingValue;
|
|
37335
|
+
else dropped.push(`tools.${tool}.${setting}`);
|
|
37336
|
+
if (Object.keys(own).length > 0) tools[tool] = own;
|
|
37337
|
+
}
|
|
37338
|
+
if (Object.keys(tools).length > 0) kept.tools = tools;
|
|
37339
|
+
}
|
|
37340
|
+
return {
|
|
37341
|
+
kept,
|
|
37342
|
+
dropped: dropped.toSorted()
|
|
37343
|
+
};
|
|
36976
37344
|
}
|
|
36977
37345
|
/**
|
|
36978
37346
|
* Vibe resolves a `system_prompt_id` by file name, and
|
|
@@ -37052,7 +37420,7 @@ var VibeSubagent = class VibeSubagent extends ToolSubagent {
|
|
|
37052
37420
|
validate: true
|
|
37053
37421
|
});
|
|
37054
37422
|
}
|
|
37055
|
-
static fromRulesyncSubagent({ outputRoot = process.cwd(), rulesyncSubagent, validate = true, global = false }) {
|
|
37423
|
+
static fromRulesyncSubagent({ outputRoot = process.cwd(), rulesyncSubagent, validate = true, global = false, logger }) {
|
|
37056
37424
|
const frontmatter = rulesyncSubagent.getFrontmatter();
|
|
37057
37425
|
const rawSection = frontmatter.vibe ?? {};
|
|
37058
37426
|
const vibeSection = this.filterToolSpecificSection(rawSection, [
|
|
@@ -37070,7 +37438,13 @@ var VibeSubagent = class VibeSubagent extends ToolSubagent {
|
|
|
37070
37438
|
...vibeSection,
|
|
37071
37439
|
...promptBody ? { system_prompt_id: slug } : {}
|
|
37072
37440
|
};
|
|
37073
|
-
|
|
37441
|
+
let finalToml = tomlObj;
|
|
37442
|
+
if (tomlObj.agent_type === "agent") {
|
|
37443
|
+
const { kept, dropped } = stripVibeAgentIgnoredSettings(tomlObj);
|
|
37444
|
+
if (dropped.length > 0) logger?.warn(`Vibe subagent ${rulesyncSubagent.getRelativeFilePath()}: dropped ${dropped.map((key) => `'${key}'`).join(", ")}, which Vibe v3.1.4+ ignores on an agent_type = "agent" profile and reports as a config issue. What runs without asking belongs to the approval policy: set default_approval_policy and [tools.*] in config.toml, or use agent_type = "subagent".`);
|
|
37445
|
+
finalToml = kept;
|
|
37446
|
+
}
|
|
37447
|
+
const body = smol_toml.stringify(finalToml);
|
|
37074
37448
|
const paths = this.getSettablePaths({ global });
|
|
37075
37449
|
const relativeFilePath = rulesyncSubagent.getRelativeFilePath().replace(/\.md$/, ".toml");
|
|
37076
37450
|
return new VibeSubagent({
|
|
@@ -37091,7 +37465,10 @@ var VibeSubagent = class VibeSubagent extends ToolSubagent {
|
|
|
37091
37465
|
* with a warning.
|
|
37092
37466
|
*
|
|
37093
37467
|
* A subagent named `main` is skipped with a warning: Vibe reserves that name
|
|
37094
|
-
* for hook matching and does not load an agent file called `main.toml`.
|
|
37468
|
+
* for hook matching and does not load an agent file called `main.toml`. So is
|
|
37469
|
+
* one named after an approval policy (`ask`, `accept-edits`, `smart-approve`,
|
|
37470
|
+
* `auto-approve`): Vibe ignores such a file in a project and treats it as a
|
|
37471
|
+
* redefinition of that policy in `~/.vibe/agents/`, never as an agent.
|
|
37095
37472
|
*/
|
|
37096
37473
|
static fromRulesyncSubagents({ rulesyncSubagents, outputRoot = process.cwd(), global = false, logger }) {
|
|
37097
37474
|
return rulesyncSubagents.flatMap((rulesyncSubagent) => {
|
|
@@ -37100,11 +37477,17 @@ var VibeSubagent = class VibeSubagent extends ToolSubagent {
|
|
|
37100
37477
|
logger?.warn(`Skipping Vibe subagent ${sourcePath}: Vibe reserves the agent name '${VIBE_RESERVED_AGENT_NAME}' for hook matching and does not load an agent file named '${VIBE_RESERVED_AGENT_NAME}'. Rename the subagent file.`);
|
|
37101
37478
|
return [];
|
|
37102
37479
|
}
|
|
37480
|
+
if (isVibeApprovalPolicyFileName(sourcePath)) {
|
|
37481
|
+
const policy = vibeAgentFileStem(sourcePath);
|
|
37482
|
+
logger?.warn(`Skipping Vibe subagent ${sourcePath}: '${policy}' is a Vibe approval policy name (v3.1.4+), so Vibe never loads an agent file of that name — a project's .vibe/agents/ file is ignored and a ~/.vibe/agents/ file redefines the approval policy instead. Rename the subagent file.`);
|
|
37483
|
+
return [];
|
|
37484
|
+
}
|
|
37103
37485
|
const agentFile = VibeSubagent.fromRulesyncSubagent({
|
|
37104
37486
|
outputRoot,
|
|
37105
37487
|
relativeDirPath: VibeSubagent.getSettablePaths({ global }).relativeDirPath,
|
|
37106
37488
|
rulesyncSubagent,
|
|
37107
|
-
global
|
|
37489
|
+
global,
|
|
37490
|
+
logger
|
|
37108
37491
|
});
|
|
37109
37492
|
const promptBody = rulesyncSubagent.getBody();
|
|
37110
37493
|
if (!promptBody) return [agentFile];
|
|
@@ -37180,6 +37563,22 @@ var VibeSubagent = class VibeSubagent extends ToolSubagent {
|
|
|
37180
37563
|
if (typeof promptId !== "string" || promptId === "" || /[\\/]/.test(promptId)) return;
|
|
37181
37564
|
return await readFileContentOrNull((0, node_path.join)(outputRoot, VIBE_PROMPTS_DIR_PATH, `${promptId}.md`)) ?? void 0;
|
|
37182
37565
|
}
|
|
37566
|
+
/**
|
|
37567
|
+
* A file in `.vibe/agents/` named after an approval policy is not an agent:
|
|
37568
|
+
* in `~/.vibe/agents/` it is the user's override of that policy (often a
|
|
37569
|
+
* narrower one), and in a project Vibe ignores it. It is therefore neither
|
|
37570
|
+
* imported as a subagent (with a warning) nor swept as an orphan, since
|
|
37571
|
+
* deleting a narrowing override would fall back to the broader builtin.
|
|
37572
|
+
*/
|
|
37573
|
+
static async isFileOwned({ relativeFilePath, forDeletion = false, logger }) {
|
|
37574
|
+
if (!isVibeApprovalPolicyFileName(relativeFilePath)) return true;
|
|
37575
|
+
if (!forDeletion) logger?.warn(`Skipping Vibe agent file ${relativeFilePath}: '${vibeAgentFileStem(relativeFilePath)}' is a Vibe approval policy name (v3.1.4+), so the file overrides that approval policy rather than defining an agent, and it is not imported as a subagent.`);
|
|
37576
|
+
return false;
|
|
37577
|
+
}
|
|
37578
|
+
/** Never delete an approval-policy override; see {@link VibeSubagent.isFileOwned}. */
|
|
37579
|
+
isDeletable() {
|
|
37580
|
+
return this.promptFile || !isVibeApprovalPolicyFileName(this.getRelativeFilePath());
|
|
37581
|
+
}
|
|
37183
37582
|
static forDeletion({ outputRoot = process.cwd(), relativeDirPath, relativeFilePath, global = false }) {
|
|
37184
37583
|
return new VibeSubagent({
|
|
37185
37584
|
outputRoot,
|
|
@@ -38353,7 +38752,9 @@ var SubagentsProcessor = class extends FeatureProcessor {
|
|
|
38353
38752
|
const ownership = await Promise.all(subagentFilePaths.map((path) => factory.class.isFileOwned({
|
|
38354
38753
|
outputRoot: rootOutputRoot,
|
|
38355
38754
|
relativeDirPath: dirPath,
|
|
38356
|
-
relativeFilePath: toRelativeFilePath(path)
|
|
38755
|
+
relativeFilePath: toRelativeFilePath(path),
|
|
38756
|
+
forDeletion,
|
|
38757
|
+
logger: this.logger
|
|
38357
38758
|
})));
|
|
38358
38759
|
ownedFilePaths = subagentFilePaths.filter((_, index) => ownership[index]);
|
|
38359
38760
|
}
|
|
@@ -46382,10 +46783,18 @@ var MimocodeRule = class extends OpenCodeRule {
|
|
|
46382
46783
|
* from the working directory to the `.git` boundary and loads one instruction
|
|
46383
46784
|
* file per directory level, preferring `AGENTS.md` over `CLAUDE.md` when both
|
|
46384
46785
|
* exist. rulesync emits the project-root `AGENTS.md` (the same shared root file
|
|
46385
|
-
* the agentsmd/codexcli targets write). Muse Code
|
|
46386
|
-
*
|
|
46387
|
-
* (
|
|
46388
|
-
*
|
|
46786
|
+
* the agentsmd/codexcli targets write). Muse Code also loads machine-wide user
|
|
46787
|
+
* rules; since 1.4.23 its changelog names `~/.claude/CLAUDE.md` as that file
|
|
46788
|
+
* (the filename of the alternative under Muse's own config directory is not
|
|
46789
|
+
* published). `~/.claude/CLAUDE.md` is exactly what the `claudecode` target
|
|
46790
|
+
* writes in global mode, so no global scope is supported here: emitting the
|
|
46791
|
+
* same file from two targets would make the result depend on target order.
|
|
46792
|
+
* `rulesync generate --targets claudecode --global` feeds Muse Code's user
|
|
46793
|
+
* rules instead, but only for the root rule (global non-root rules go to
|
|
46794
|
+
* `~/.claude/rules/*.md`, which Muse Code is not documented to read) and only
|
|
46795
|
+
* for rules that target `claudecode`. (Verified against the official docs:
|
|
46796
|
+
* https://dev.meta.ai/docs/muse-code/configuration and
|
|
46797
|
+
* https://dev.meta.ai/docs/muse-code/changelog)
|
|
46389
46798
|
*
|
|
46390
46799
|
* rulesync's topic-based non-root rules have no project subdirectory to map
|
|
46391
46800
|
* onto, so their bodies are folded into the single root `AGENTS.md` by the
|
|
@@ -48380,8 +48789,8 @@ var TraeRule = class TraeRule extends ToolRule {
|
|
|
48380
48789
|
* before parsing, inside the frontmatter block only so the body is never
|
|
48381
48790
|
* rewritten. A quoted value, a YAML flow list, a null or boolean keyword and a
|
|
48382
48791
|
* block scalar indicator (`|`, `>`) are left alone. The block bounds are
|
|
48383
|
-
*
|
|
48384
|
-
* `----` line), so the quoting never reaches text
|
|
48792
|
+
* `parseFrontmatter`'s own (it closes the block at the first `\n---`, even
|
|
48793
|
+
* inside a `----` line), so the quoting never reaches text it reads as body.
|
|
48385
48794
|
*/
|
|
48386
48795
|
static parseTraeFrontmatter(fileContent, filePath) {
|
|
48387
48796
|
const bounds = findFrontmatterBlockBounds(fileContent);
|
|
@@ -50800,9 +51209,10 @@ const AmpCheckFrontmatterSchema = zod_mini.z.looseObject({
|
|
|
50800
51209
|
* Amp reads code review checks as Markdown files with YAML frontmatter,
|
|
50801
51210
|
* scoped to the project (`.agents/checks/`) and user-wide (`~/.config/amp/checks/`;
|
|
50802
51211
|
* Amp also reads `~/.config/agents/checks/`, which rulesync does not write).
|
|
50803
|
-
*
|
|
50804
|
-
* `@amp/review-checks` plugin
|
|
50805
|
-
* this format
|
|
51212
|
+
* Amp has since removed `amp review` and deprecated project-defined checks
|
|
51213
|
+
* in `.agents/checks/`, together with the `@amp/review-checks` plugin that runs
|
|
51214
|
+
* them. rulesync keeps writing this format because Goose discovers the same
|
|
51215
|
+
* `.agents/checks/` directory and existing setups may still load the plugin.
|
|
50806
51216
|
* @see https://ampcode.com/docs/review
|
|
50807
51217
|
*/
|
|
50808
51218
|
var AmpCheck = class extends ToolCheck {
|
|
@@ -51686,19 +52096,17 @@ var CursorCheck = class extends AggregatedToolCheck {
|
|
|
51686
52096
|
*
|
|
51687
52097
|
* rulesync never writes frontmatter here, but a user who authored this path as
|
|
51688
52098
|
* an ordinary skill did, and that block is the skill's metadata rather than
|
|
51689
|
-
* review instructions.
|
|
51690
|
-
*
|
|
51691
|
-
*
|
|
51692
|
-
*
|
|
51693
|
-
*
|
|
51694
|
-
*
|
|
51695
|
-
*
|
|
51696
|
-
*
|
|
51697
|
-
*
|
|
51698
|
-
*
|
|
51699
|
-
*
|
|
51700
|
-
* a fence nothing closes: gray-matter would swallow the rest of the file, so
|
|
51701
|
-
* only the rule line goes and the prose under it is kept.
|
|
52099
|
+
* review instructions. Left in place it would be carried into the body of
|
|
52100
|
+
* the check written to `.rulesync/checks/` as a block of YAML right behind
|
|
52101
|
+
* that file's own frontmatter, where a `severity: bogus` copied out of a skill
|
|
52102
|
+
* looks like the check's own setting to anyone reading or editing it.
|
|
52103
|
+
*
|
|
52104
|
+
* The block is therefore found the way `parseFrontmatter` finds it rather than
|
|
52105
|
+
* by parsing it, so that what the parser would have read as frontmatter is
|
|
52106
|
+
* what goes: the opening delimiter may carry a language name (`---yaml`), but
|
|
52107
|
+
* four dashes are a horizontal rule the parser itself skips. The one
|
|
52108
|
+
* deliberate difference is a fence nothing closes: the parser would take the
|
|
52109
|
+
* rest of the file, so only the rule line goes and the prose under it is kept.
|
|
51702
52110
|
*/
|
|
51703
52111
|
const FRONTMATTER_OPEN_PATTERN = /^\uFEFF?---(?!-)[^\r\n]*\r?\n/;
|
|
51704
52112
|
const FRONTMATTER_CLOSE_PATTERN = /^---|\r?\n---/;
|
|
@@ -56383,9 +56791,12 @@ var SettingsJsonHooks = class extends ToolHooks {
|
|
|
56383
56791
|
const config = rulesyncHooks.getJson();
|
|
56384
56792
|
const generatedHooks = canonicalToToolHooks({
|
|
56385
56793
|
config,
|
|
56386
|
-
toolOverrideHooks:
|
|
56387
|
-
|
|
56388
|
-
|
|
56794
|
+
toolOverrideHooks: knownOverrideHooks({
|
|
56795
|
+
hooks: overrideHooksOf({
|
|
56796
|
+
config,
|
|
56797
|
+
overrideKey: this.getSpec().overrideKey
|
|
56798
|
+
}),
|
|
56799
|
+
spec: this.getSpec()
|
|
56389
56800
|
}),
|
|
56390
56801
|
converterConfig: this.getConverterConfig(),
|
|
56391
56802
|
logger
|
|
@@ -56448,6 +56859,16 @@ var SettingsJsonHooks = class extends ToolHooks {
|
|
|
56448
56859
|
}
|
|
56449
56860
|
};
|
|
56450
56861
|
/**
|
|
56862
|
+
* The override hooks the tool can take: all of them, unless the spec lists
|
|
56863
|
+
* {@link SettingsJsonHooksSpec.knownOverrideEvents}, in which case only those
|
|
56864
|
+
* native names and the canonical supported events are kept.
|
|
56865
|
+
*/
|
|
56866
|
+
function knownOverrideHooks({ hooks, spec }) {
|
|
56867
|
+
if (hooks === void 0 || spec.knownOverrideEvents === void 0) return hooks;
|
|
56868
|
+
const known = /* @__PURE__ */ new Set([...spec.converterConfig.supportedEvents, ...spec.knownOverrideEvents]);
|
|
56869
|
+
return Object.fromEntries(Object.entries(hooks).filter(([event]) => known.has(event)));
|
|
56870
|
+
}
|
|
56871
|
+
/**
|
|
56451
56872
|
* The `hooks` map of a tool's override block (`config.<overrideKey>.hooks`),
|
|
56452
56873
|
* or `undefined` when the block states none. The schema keeps every override
|
|
56453
56874
|
* block loose, so the lookup goes through the record form.
|
|
@@ -56461,7 +56882,6 @@ function overrideHooksOf({ config, overrideKey }) {
|
|
|
56461
56882
|
const hooks = override.hooks;
|
|
56462
56883
|
return isPlainObject(hooks) ? hooks : void 0;
|
|
56463
56884
|
}
|
|
56464
|
-
// src/features/hooks/bob-hooks.ts
|
|
56465
56885
|
const BOB_SPEC = {
|
|
56466
56886
|
displayName: "Bob",
|
|
56467
56887
|
overrideKey: "bob",
|
|
@@ -56470,11 +56890,12 @@ const BOB_SPEC = {
|
|
|
56470
56890
|
canonicalToToolEventNames: CANONICAL_TO_BOB_EVENT_NAMES,
|
|
56471
56891
|
toolToCanonicalEventNames: BOB_TO_CANONICAL_EVENT_NAMES,
|
|
56472
56892
|
projectDirVar: "",
|
|
56473
|
-
noMatcherEvents:
|
|
56893
|
+
noMatcherEvents: new Set(BOB_HOOK_EVENTS.filter((event) => !BOB_MATCHER_HOOK_EVENTS.includes(event))),
|
|
56474
56894
|
supportedHookTypes: /* @__PURE__ */ new Set(["command", "http"]),
|
|
56475
56895
|
importedHookTypeAliases: { https: "http" },
|
|
56476
56896
|
wildcardMatcherMeansAll: true
|
|
56477
|
-
}
|
|
56897
|
+
},
|
|
56898
|
+
knownOverrideEvents: BOB_NATIVE_HOOK_EVENTS
|
|
56478
56899
|
};
|
|
56479
56900
|
/**
|
|
56480
56901
|
* IBM Bob lifecycle hooks.
|
|
@@ -59889,7 +60310,7 @@ function canonicalToHermesHooks({ config, toolOverrideHooks, logger }) {
|
|
|
59889
60310
|
for (const [nativeEvent, definitions] of Object.entries(toolOverrideHooks ?? {})) {
|
|
59890
60311
|
if (HERMESAGENT_CANONICAL_EVENTS.has(nativeEvent)) continue;
|
|
59891
60312
|
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.`);
|
|
59892
|
-
else if (!HERMESAGENT_NATIVE_EVENTS.has(nativeEvent)) logger?.warn(`Hermes hook event "${nativeEvent}" is not documented by Hermes Agent v0.23.
|
|
60313
|
+
else if (!HERMESAGENT_NATIVE_EVENTS.has(nativeEvent)) logger?.warn(`Hermes hook event "${nativeEvent}" is not documented by Hermes Agent v0.23.4; preserving it for forward compatibility.`);
|
|
59893
60314
|
setHermesHookEntries({
|
|
59894
60315
|
result,
|
|
59895
60316
|
event: nativeEvent,
|
|
@@ -60566,7 +60987,9 @@ function buildRunHelperLinesFor(cwdExpression) {
|
|
|
60566
60987
|
* hook denies it:
|
|
60567
60988
|
* - exit code 2 → deny, with the command's stderr as the reason;
|
|
60568
60989
|
* - exit code 0 with JSON stdout whose `hookSpecificOutput.permissionDecision`
|
|
60569
|
-
* is `"deny"` → deny, with `permissionDecisionReason` as the reason;
|
|
60990
|
+
* is `"deny"` → deny, with `permissionDecisionReason` as the reason; when it
|
|
60991
|
+
* sets no `permissionDecision`, the deprecated top-level `decision: "block"`
|
|
60992
|
+
* that Claude Code still honors denies too, with `reason` as the reason;
|
|
60570
60993
|
* - exit code 0 otherwise → allow;
|
|
60571
60994
|
* - any other non-zero exit → deny too, with stderr or the exit code;
|
|
60572
60995
|
* - more than 1 MiB of stdout → deny, without parsing it;
|
|
@@ -60601,12 +61024,13 @@ const PRE_TOOL_USE_RESULT_HELPER_LINES = [
|
|
|
60601
61024
|
" } catch {",
|
|
60602
61025
|
" return;",
|
|
60603
61026
|
" }",
|
|
60604
|
-
"
|
|
60605
|
-
"
|
|
61027
|
+
" if (!parsed || typeof parsed !== \"object\") return;",
|
|
61028
|
+
" const specific = parsed.hookSpecificOutput;",
|
|
61029
|
+
" const hasDecision = typeof specific === \"object\" && specific !== null && specific.permissionDecision !== undefined;",
|
|
61030
|
+
" const reason = hasDecision ? specific.permissionDecisionReason : parsed.reason;",
|
|
61031
|
+
" if (hasDecision ? specific.permissionDecision === \"deny\" : parsed.decision === \"block\") {",
|
|
60606
61032
|
" throw new Error(",
|
|
60607
|
-
" (typeof
|
|
60608
|
-
" sanitizeBlockReason(specific.permissionDecisionReason)) ||",
|
|
60609
|
-
" \"Blocked by a preToolUse hook.\",",
|
|
61033
|
+
" (typeof reason === \"string\" && sanitizeBlockReason(reason)) || \"Blocked by a preToolUse hook.\",",
|
|
60610
61034
|
" );",
|
|
60611
61035
|
" }",
|
|
60612
61036
|
" return;",
|
|
@@ -60759,6 +61183,51 @@ function warnIgnoredFailClosed({ config, supportedEvents, toolConfigKey, logger
|
|
|
60759
61183
|
}
|
|
60760
61184
|
}
|
|
60761
61185
|
}
|
|
61186
|
+
/**
|
|
61187
|
+
* Canonical (Claude Code) tool names mapped to the lowercase tool ids OpenCode
|
|
61188
|
+
* 1.x and its forks (Kilo, MiMo Code) pass as `input.tool`, which a matcher is
|
|
61189
|
+
* tested against case-sensitively. The shell tool is `bash` here, the same id
|
|
61190
|
+
* the shell events gate on (see {@link SHELL_EVENT_TOOL_GATES}).
|
|
61191
|
+
* @see https://opencode.ai/docs/plugins/
|
|
61192
|
+
*/
|
|
61193
|
+
const CANONICAL_TO_OPENCODE_V1_TOOL_NAMES = {
|
|
61194
|
+
Bash: "bash",
|
|
61195
|
+
Read: "read",
|
|
61196
|
+
Write: "write",
|
|
61197
|
+
Edit: "edit"
|
|
61198
|
+
};
|
|
61199
|
+
/**
|
|
61200
|
+
* A matcher made only of plain names joined by `|`, which Claude Code matches
|
|
61201
|
+
* as an exact tool name list rather than as a regex.
|
|
61202
|
+
*/
|
|
61203
|
+
const PLAIN_NAME_MATCHER_PATTERN = /^[A-Za-z0-9_]+(?:\|[A-Za-z0-9_]+)*$/;
|
|
61204
|
+
/**
|
|
61205
|
+
* Build a translator that rewrites the canonical tool names in a matcher
|
|
61206
|
+
* through `toolNames` and warns about a capitalized name left over
|
|
61207
|
+
* (`MultiEdit`, `Glob`), which no lowercase tool id can match. Each distinct
|
|
61208
|
+
* matcher of an event is translated once, so hooks sharing one do not repeat
|
|
61209
|
+
* its warning.
|
|
61210
|
+
*
|
|
61211
|
+
* The plugins test the matcher unanchored, so a translated plain-name matcher
|
|
61212
|
+
* is anchored as `^(?:...)$` to keep Claude Code's exact-name semantics:
|
|
61213
|
+
* otherwise `write` would also match OpenCode's `todowrite`. Regex-style and
|
|
61214
|
+
* untranslated matchers are left as written.
|
|
61215
|
+
*/
|
|
61216
|
+
function createOpencodeMatcherTranslator({ toolNames, toolConfigKey, logger }) {
|
|
61217
|
+
const label = FAIL_CLOSED_TOOL_LABELS[toolConfigKey];
|
|
61218
|
+
const translated = /* @__PURE__ */ new Map();
|
|
61219
|
+
return (matcher, eventName) => {
|
|
61220
|
+
const key = `${eventName}\0${matcher}`;
|
|
61221
|
+
const cached = translated.get(key);
|
|
61222
|
+
if (cached !== void 0) return cached;
|
|
61223
|
+
const replaced = replaceMatcherNames(matcher, toolNames);
|
|
61224
|
+
const result = replaced !== matcher && PLAIN_NAME_MATCHER_PATTERN.test(stripControlChars(matcher)) ? `^(?:${replaced})$` : replaced;
|
|
61225
|
+
const unmatched = capitalizedMatcherNames(result);
|
|
61226
|
+
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.`);
|
|
61227
|
+
translated.set(key, result);
|
|
61228
|
+
return result;
|
|
61229
|
+
};
|
|
61230
|
+
}
|
|
60762
61231
|
/** Whether any handler is a `sessionStart` one, whose stdout becomes session context. */
|
|
60763
61232
|
function usesSessionContext(handlers) {
|
|
60764
61233
|
return handlers.some((handler) => handler.context);
|
|
@@ -60784,7 +61253,7 @@ function handlerExtrasFor(canonicalEvent) {
|
|
|
60784
61253
|
* Group the effective hooks into named (tool.execute.*) and generic event
|
|
60785
61254
|
* handler groups, keyed by tool event name. Mutates the supplied groups.
|
|
60786
61255
|
*/
|
|
60787
|
-
function collectOpencodeStyleHandlers({ effectiveHooks, eventMap, namedEventHandlers, genericEventHandlers }) {
|
|
61256
|
+
function collectOpencodeStyleHandlers({ effectiveHooks, eventMap, namedEventHandlers, genericEventHandlers, translateMatcher }) {
|
|
60788
61257
|
for (const [canonicalEvent, definitions] of Object.entries(effectiveHooks)) {
|
|
60789
61258
|
const shellGate = SHELL_EVENT_TOOL_GATES[canonicalEvent];
|
|
60790
61259
|
const extras = handlerExtrasFor(canonicalEvent);
|
|
@@ -60792,6 +61261,7 @@ function collectOpencodeStyleHandlers({ effectiveHooks, eventMap, namedEventHand
|
|
|
60792
61261
|
if (!toolEvent) continue;
|
|
60793
61262
|
const isNamedHook = Object.hasOwn(NAMED_HOOK_MATCHER_SUBJECTS, toolEvent);
|
|
60794
61263
|
const matcherSupported = !shellGate && isNamedHook && NAMED_HOOK_MATCHER_SUBJECTS[toolEvent] !== null;
|
|
61264
|
+
const matchesToolName = NAMED_HOOK_MATCHER_SUBJECTS[toolEvent] === "input.tool";
|
|
60795
61265
|
const handlers = [];
|
|
60796
61266
|
for (const def of definitions) {
|
|
60797
61267
|
if ((def.type ?? "command") !== "command") continue;
|
|
@@ -60799,7 +61269,7 @@ function collectOpencodeStyleHandlers({ effectiveHooks, eventMap, namedEventHand
|
|
|
60799
61269
|
if (def.matcher && !matcherSupported) continue;
|
|
60800
61270
|
handlers.push({
|
|
60801
61271
|
command: def.command,
|
|
60802
|
-
matcher: def.matcher ? def.matcher : void 0,
|
|
61272
|
+
matcher: def.matcher ? matchesToolName ? translateMatcher(def.matcher, canonicalEvent) : def.matcher : void 0,
|
|
60803
61273
|
blocking: BLOCKING_HOOKS.has(toolEvent),
|
|
60804
61274
|
...hookTimingOf(def),
|
|
60805
61275
|
inProcess: !isNamedHook,
|
|
@@ -60963,7 +61433,7 @@ function wrapInExportShape({ preambleLines, bodyLines, exportStyle }) {
|
|
|
60963
61433
|
lines.push("");
|
|
60964
61434
|
return lines;
|
|
60965
61435
|
}
|
|
60966
|
-
function generateOpencodeStylePluginCode(config, supportedEvents, toolConfigKey, eventMap, exportStyle = "named") {
|
|
61436
|
+
function generateOpencodeStylePluginCode(config, supportedEvents, toolConfigKey, eventMap, exportStyle = "named", logger) {
|
|
60967
61437
|
const supported = new Set(supportedEvents);
|
|
60968
61438
|
const configHooks = {
|
|
60969
61439
|
...config.hooks,
|
|
@@ -60977,7 +61447,12 @@ function generateOpencodeStylePluginCode(config, supportedEvents, toolConfigKey,
|
|
|
60977
61447
|
effectiveHooks,
|
|
60978
61448
|
eventMap,
|
|
60979
61449
|
namedEventHandlers,
|
|
60980
|
-
genericEventHandlers
|
|
61450
|
+
genericEventHandlers,
|
|
61451
|
+
translateMatcher: createOpencodeMatcherTranslator({
|
|
61452
|
+
toolNames: CANONICAL_TO_OPENCODE_V1_TOOL_NAMES,
|
|
61453
|
+
toolConfigKey,
|
|
61454
|
+
logger
|
|
61455
|
+
})
|
|
60981
61456
|
});
|
|
60982
61457
|
const usesContext = Object.values(genericEventHandlers).some(usesSessionContext);
|
|
60983
61458
|
const bodyLines = [
|
|
@@ -61031,7 +61506,7 @@ var KiloHooks = class KiloHooks extends ToolHooks {
|
|
|
61031
61506
|
toolConfigKey: "kilo",
|
|
61032
61507
|
logger
|
|
61033
61508
|
});
|
|
61034
|
-
const fileContent = generateOpencodeStylePluginCode(config, KILO_HOOK_EVENTS, "kilo", CANONICAL_TO_KILO_EVENT_NAMES, "default");
|
|
61509
|
+
const fileContent = generateOpencodeStylePluginCode(config, KILO_HOOK_EVENTS, "kilo", CANONICAL_TO_KILO_EVENT_NAMES, "default", logger);
|
|
61035
61510
|
const paths = KiloHooks.getSettablePaths({ global });
|
|
61036
61511
|
return new KiloHooks({
|
|
61037
61512
|
outputRoot,
|
|
@@ -61895,6 +62370,21 @@ var LettacodeHooks = class LettacodeHooks extends ToolHooks {
|
|
|
61895
62370
|
/** Tool name OpenCode V2 gives its shell tool (V1 called it `bash`). */
|
|
61896
62371
|
const OPENCODE_V2_SHELL_TOOL = "shell";
|
|
61897
62372
|
/**
|
|
62373
|
+
* Canonical (Claude Code) tool names mapped to the lowercase names OpenCode 2.x
|
|
62374
|
+
* reports in `event.tool`, which a matcher is tested against case-sensitively.
|
|
62375
|
+
* Observed on OpenCode 2.3.2: a `preToolUse` hook fires with `read`, `write`,
|
|
62376
|
+
* `edit` and `shell`, so a canonical `Read|Edit|Write` or `Bash` never matched.
|
|
62377
|
+
* `Bash` becomes the V2 name `shell`; the generated helper still accepts the
|
|
62378
|
+
* V1 name `bash` for a matcher written that way.
|
|
62379
|
+
* https://opencode.ai/v2/docs/build/plugins/
|
|
62380
|
+
*/
|
|
62381
|
+
const CANONICAL_TO_OPENCODE_V2_TOOL_NAMES = {
|
|
62382
|
+
Bash: OPENCODE_V2_SHELL_TOOL,
|
|
62383
|
+
Read: "read",
|
|
62384
|
+
Write: "write",
|
|
62385
|
+
Edit: "edit"
|
|
62386
|
+
};
|
|
62387
|
+
/**
|
|
61898
62388
|
* Per-canonical-event conditions the generated handler gates on, because the
|
|
61899
62389
|
* hook point or event it shares fires more broadly than the canonical event:
|
|
61900
62390
|
* - the shell events run only for the `shell` tool's calls;
|
|
@@ -62071,7 +62561,7 @@ function isBlockingOpencodeV2Target(target) {
|
|
|
62071
62561
|
return !target.startsWith("event:") && target !== "tool:execute.after";
|
|
62072
62562
|
}
|
|
62073
62563
|
/** Build the handlers of one canonical event's command definitions. */
|
|
62074
|
-
function buildHandlersFor({ canonicalEvent, definitions, target }) {
|
|
62564
|
+
function buildHandlersFor({ canonicalEvent, definitions, target, translateMatcher }) {
|
|
62075
62565
|
const gate = OPENCODE_V2_HANDLER_GATES[canonicalEvent];
|
|
62076
62566
|
const payload = OPENCODE_V2_STDIN_PAYLOADS[canonicalEvent];
|
|
62077
62567
|
const matcherSupported = !(canonicalEvent === "beforeShellExecution" || canonicalEvent === "afterShellExecution") && OPENCODE_V2_MATCHABLE_HOOKS.has(target);
|
|
@@ -62085,7 +62575,7 @@ function buildHandlersFor({ canonicalEvent, definitions, target }) {
|
|
|
62085
62575
|
event: canonicalEvent,
|
|
62086
62576
|
blocking: isBlockingOpencodeV2Target(target),
|
|
62087
62577
|
...hookTimingOf(def),
|
|
62088
|
-
...def.matcher ? { matcher: def.matcher } : {},
|
|
62578
|
+
...def.matcher ? { matcher: translateMatcher(def.matcher, canonicalEvent) } : {},
|
|
62089
62579
|
...gate ? { gate } : {},
|
|
62090
62580
|
...payload ? { payload } : {},
|
|
62091
62581
|
...sessionContextExtrasFor(canonicalEvent)
|
|
@@ -62121,12 +62611,17 @@ function buildSetupBodyLines({ hookHandlers, eventHandlers }) {
|
|
|
62121
62611
|
body.push("", "return async () => {", ...cleanup, "};");
|
|
62122
62612
|
return body;
|
|
62123
62613
|
}
|
|
62124
|
-
function generateOpencodeV2PluginCode({ config, supportedEvents, toolConfigKey, eventMap }) {
|
|
62614
|
+
function generateOpencodeV2PluginCode({ config, supportedEvents, toolConfigKey, eventMap, logger }) {
|
|
62125
62615
|
const supported = new Set(supportedEvents);
|
|
62126
62616
|
const configHooks = {
|
|
62127
62617
|
...config.hooks,
|
|
62128
62618
|
...config[toolConfigKey]?.hooks
|
|
62129
62619
|
};
|
|
62620
|
+
const translateMatcher = createOpencodeMatcherTranslator({
|
|
62621
|
+
toolNames: CANONICAL_TO_OPENCODE_V2_TOOL_NAMES,
|
|
62622
|
+
toolConfigKey,
|
|
62623
|
+
logger
|
|
62624
|
+
});
|
|
62130
62625
|
const hookHandlers = /* @__PURE__ */ new Map();
|
|
62131
62626
|
const eventHandlers = /* @__PURE__ */ new Map();
|
|
62132
62627
|
for (const [canonicalEvent, definitions] of Object.entries(configHooks)) {
|
|
@@ -62136,7 +62631,8 @@ function generateOpencodeV2PluginCode({ config, supportedEvents, toolConfigKey,
|
|
|
62136
62631
|
const handlers = buildHandlersFor({
|
|
62137
62632
|
canonicalEvent,
|
|
62138
62633
|
definitions,
|
|
62139
|
-
target
|
|
62634
|
+
target,
|
|
62635
|
+
translateMatcher
|
|
62140
62636
|
});
|
|
62141
62637
|
if (handlers.length === 0) continue;
|
|
62142
62638
|
const isEvent = target.startsWith("event:");
|
|
@@ -62191,8 +62687,9 @@ var OpencodeHooks = class extends ToolHooks {
|
|
|
62191
62687
|
config,
|
|
62192
62688
|
supportedEvents: OPENCODE_V2_HOOK_EVENTS,
|
|
62193
62689
|
toolConfigKey: this.layout.toolTarget,
|
|
62194
|
-
eventMap: CANONICAL_TO_OPENCODE_V2_EVENT_NAMES
|
|
62195
|
-
|
|
62690
|
+
eventMap: CANONICAL_TO_OPENCODE_V2_EVENT_NAMES,
|
|
62691
|
+
logger
|
|
62692
|
+
}) : generateOpencodeStylePluginCode(config, OPENCODE_HOOK_EVENTS, this.layout.toolTarget, CANONICAL_TO_OPENCODE_EVENT_NAMES, "named", logger);
|
|
62196
62693
|
const paths = this.getSettablePaths({ global });
|
|
62197
62694
|
return new this({
|
|
62198
62695
|
outputRoot,
|
|
@@ -62309,11 +62806,123 @@ const PI_SETTLE_BLOCKING_EVENT = "agent_before_settle";
|
|
|
62309
62806
|
* @see https://github.com/can1357/oh-my-pi/blob/fa5ff4a3a977a28b93d025f4cf50f046e019f18c/packages/coding-agent/src/session/agent-session.ts
|
|
62310
62807
|
*/
|
|
62311
62808
|
const OMP_SESSION_STOP_BLOCKING_EVENT = "session_stop";
|
|
62809
|
+
/**
|
|
62810
|
+
* Pi's `resolveToCwd` (`core/tools/path-utils.ts`), which calls
|
|
62811
|
+
* `resolvePath(path, cwd, { normalizeUnicodeSpaces: true, stripAtPrefix: true })`
|
|
62812
|
+
* from `utils/paths.ts`: Unicode spaces become plain spaces, a leading `@` is
|
|
62813
|
+
* dropped, on Windows Git Bash / WSL drive paths are converted, `~` is
|
|
62814
|
+
* expanded, a `file://` URL is converted, and the result is resolved against
|
|
62815
|
+
* cwd. Pi has no URL passthrough, so any other `scheme://` text is a relative
|
|
62816
|
+
* path too.
|
|
62817
|
+
*
|
|
62818
|
+
* @see https://github.com/earendil-works/pi/blob/v1.6.0/packages/coding-agent/src/utils/paths.ts
|
|
62819
|
+
*/
|
|
62820
|
+
const PI_PATH_RESOLVER_LINES = [
|
|
62821
|
+
"function absoluteToolPath(path: unknown, cwd: string): unknown {",
|
|
62822
|
+
" if (typeof path !== \"string\") return path;",
|
|
62823
|
+
" let normalized = path.replace(/[\\u00A0\\u2000-\\u200A\\u202F\\u205F\\u3000]/g, \" \");",
|
|
62824
|
+
" if (normalized.startsWith(\"@\")) normalized = normalized.slice(1);",
|
|
62825
|
+
" if (process.platform === \"win32\" && normalized.startsWith(\"/\") && !normalized.startsWith(\"//\") && !normalized.includes(\"\\\\\")) {",
|
|
62826
|
+
" const drive = normalized.match(/^\\/(?:mnt\\/|cygdrive\\/)?([a-z])(?:\\/(.*))?$/i);",
|
|
62827
|
+
" if (drive?.[1]) normalized = `${drive[1].toUpperCase()}:\\\\${drive[2]?.replaceAll(\"/\", \"\\\\\") ?? \"\"}`;",
|
|
62828
|
+
" }",
|
|
62829
|
+
" if (normalized === \"~\") normalized = homedir();",
|
|
62830
|
+
" else if (normalized.startsWith(\"~/\") || (process.platform === \"win32\" && normalized.startsWith(\"~\\\\\"))) {",
|
|
62831
|
+
" normalized = joinPath(homedir(), normalized.slice(2));",
|
|
62832
|
+
" } else if (/^file:\\/\\//.test(normalized)) {",
|
|
62833
|
+
" try {",
|
|
62834
|
+
" normalized = fileURLToPath(normalized);",
|
|
62835
|
+
" } catch {",
|
|
62836
|
+
" return path;",
|
|
62837
|
+
" }",
|
|
62838
|
+
" }",
|
|
62839
|
+
" return resolvePath(cwd, normalized);",
|
|
62840
|
+
"}"
|
|
62841
|
+
];
|
|
62842
|
+
/**
|
|
62843
|
+
* oh-my-pi's `resolveToCwd` (`tools/path-utils.ts`): `expandPath` strips a
|
|
62844
|
+
* stray leading `:` before a path shape, strips a leading `@` only before an
|
|
62845
|
+
* absolute path, `~` or an internal URL, turns Unicode spaces into plain
|
|
62846
|
+
* spaces, converts a `file://` URL and expands `~`; an internal URL is not a
|
|
62847
|
+
* filesystem path, a bare root (`/`) is the workspace root, and anything else
|
|
62848
|
+
* is resolved against cwd. Windows drive-alias handling is not mirrored.
|
|
62849
|
+
*
|
|
62850
|
+
* @see https://github.com/can1357/oh-my-pi/blob/76b7d843d59bc83cc40cd5decadc89dc808a14e6/packages/coding-agent/src/tools/path-utils.ts
|
|
62851
|
+
*/
|
|
62852
|
+
const OMP_PATH_RESOLVER_LINES = [
|
|
62853
|
+
`const INTERNAL_URL_SCHEME = /^(?:${[
|
|
62854
|
+
"skill",
|
|
62855
|
+
"rule",
|
|
62856
|
+
"memory",
|
|
62857
|
+
"out",
|
|
62858
|
+
"agent",
|
|
62859
|
+
"history",
|
|
62860
|
+
"local",
|
|
62861
|
+
"proc",
|
|
62862
|
+
"cfg",
|
|
62863
|
+
"ssh",
|
|
62864
|
+
"security",
|
|
62865
|
+
"vault",
|
|
62866
|
+
"issue",
|
|
62867
|
+
"pr",
|
|
62868
|
+
"mr",
|
|
62869
|
+
"mcp",
|
|
62870
|
+
"omp",
|
|
62871
|
+
"help",
|
|
62872
|
+
"attachment",
|
|
62873
|
+
"conflict"
|
|
62874
|
+
].join("|")}):\\/\\/?/i;`,
|
|
62875
|
+
"",
|
|
62876
|
+
"function absoluteToolPath(path: unknown, cwd: string): unknown {",
|
|
62877
|
+
" if (typeof path !== \"string\") return path;",
|
|
62878
|
+
" let normalized = /^:(?=[/\\\\~]|\\.\\.?[/\\\\]|[A-Za-z]:)/.test(path) ? path.slice(1) : path;",
|
|
62879
|
+
" if (normalized.startsWith(\"@\")) {",
|
|
62880
|
+
" const rest = normalized.slice(1);",
|
|
62881
|
+
" if (rest.startsWith(\"/\") || rest === \"~\" || rest.startsWith(\"~/\") || win32Path.isAbsolute(rest) || INTERNAL_URL_SCHEME.test(rest)) {",
|
|
62882
|
+
" normalized = rest;",
|
|
62883
|
+
" }",
|
|
62884
|
+
" }",
|
|
62885
|
+
" normalized = normalized.replace(/[\\u00A0\\u2000-\\u200A\\u202F\\u205F\\u3000]/g, \" \");",
|
|
62886
|
+
" if (normalized.toLowerCase().startsWith(\"file://\")) {",
|
|
62887
|
+
" try {",
|
|
62888
|
+
" normalized = fileURLToPath(normalized);",
|
|
62889
|
+
" } catch {",
|
|
62890
|
+
" // oh-my-pi keeps an unconvertible `file://` text as written.",
|
|
62891
|
+
" }",
|
|
62892
|
+
" }",
|
|
62893
|
+
" if (normalized === \"~\") normalized = homedir();",
|
|
62894
|
+
" else if (normalized.startsWith(\"~/\")) normalized = joinPath(homedir(), normalized.slice(2));",
|
|
62895
|
+
" if (INTERNAL_URL_SCHEME.test(normalized)) return normalized;",
|
|
62896
|
+
" if (/^\\/+$/.test(normalized)) return resolvePath(cwd);",
|
|
62897
|
+
" return resolvePath(cwd, normalized);",
|
|
62898
|
+
"}"
|
|
62899
|
+
];
|
|
62900
|
+
/**
|
|
62901
|
+
* Tool names both Pi and oh-my-pi share with a canonical counterpart. Pi's
|
|
62902
|
+
* `powershell` tool is deliberately left out: Rulesync has no canonical name
|
|
62903
|
+
* for it, so it keeps its own.
|
|
62904
|
+
*/
|
|
62905
|
+
const SHARED_CANONICAL_TOOL_NAMES = {
|
|
62906
|
+
bash: "Bash",
|
|
62907
|
+
read: "Read",
|
|
62908
|
+
write: "Write",
|
|
62909
|
+
edit: "Edit",
|
|
62910
|
+
grep: "Grep"
|
|
62911
|
+
};
|
|
62312
62912
|
const PI_EXTENSION_DIALECT = {
|
|
62313
62913
|
overrideKey: "pi",
|
|
62314
62914
|
typesPackage: "@earendil-works/pi-coding-agent",
|
|
62315
62915
|
promptPassLine: "return { action: \"continue\" };",
|
|
62316
|
-
promptCancelLine: "return { action: \"handled\" };"
|
|
62916
|
+
promptCancelLine: "return { action: \"handled\" };",
|
|
62917
|
+
toolNames: {
|
|
62918
|
+
...SHARED_CANONICAL_TOOL_NAMES,
|
|
62919
|
+
find: "Glob"
|
|
62920
|
+
},
|
|
62921
|
+
editTextKeys: {
|
|
62922
|
+
old: "oldText",
|
|
62923
|
+
new: "newText"
|
|
62924
|
+
},
|
|
62925
|
+
pathResolverLines: PI_PATH_RESOLVER_LINES
|
|
62317
62926
|
};
|
|
62318
62927
|
/**
|
|
62319
62928
|
* oh-my-pi's `emitInput` stops at the first result with `handled` set and
|
|
@@ -62325,7 +62934,16 @@ const OMP_EXTENSION_DIALECT = {
|
|
|
62325
62934
|
overrideKey: "omp",
|
|
62326
62935
|
typesPackage: "@oh-my-pi/pi-coding-agent",
|
|
62327
62936
|
promptPassLine: "return {};",
|
|
62328
|
-
promptCancelLine: "return { handled: true };"
|
|
62937
|
+
promptCancelLine: "return { handled: true };",
|
|
62938
|
+
toolNames: {
|
|
62939
|
+
...SHARED_CANONICAL_TOOL_NAMES,
|
|
62940
|
+
glob: "Glob"
|
|
62941
|
+
},
|
|
62942
|
+
editTextKeys: {
|
|
62943
|
+
old: "old_string",
|
|
62944
|
+
new: "new_string"
|
|
62945
|
+
},
|
|
62946
|
+
pathResolverLines: OMP_PATH_RESOLVER_LINES
|
|
62329
62947
|
};
|
|
62330
62948
|
const PI_BLOCKING_MODE_BY_EVENT = {
|
|
62331
62949
|
[PI_BLOCKING_EVENT]: "tool",
|
|
@@ -62349,7 +62967,284 @@ function failureLinesByMode(dialect) {
|
|
|
62349
62967
|
};
|
|
62350
62968
|
}
|
|
62351
62969
|
/**
|
|
62352
|
-
*
|
|
62970
|
+
* Canonical events whose command receives Claude Code's JSON input for the
|
|
62971
|
+
* event on stdin, mapped to its `hook_event_name`; every other command gets an
|
|
62972
|
+
* empty stdin, as in the OpenCode-style plugin (`STDIN_PAYLOADS` in
|
|
62973
|
+
* `opencode-style-generator.ts`). All three ride on Pi's tool events, whose
|
|
62974
|
+
* `event.toolName`, `event.toolCallId` and `event.input` the payload is built
|
|
62975
|
+
* from. A payload is serialized lazily, once per invocation, by the first
|
|
62976
|
+
* handler that runs.
|
|
62977
|
+
*
|
|
62978
|
+
* @see https://github.com/earendil-works/pi/blob/v1.6.0/packages/coding-agent/docs/extensions.md#tool_call
|
|
62979
|
+
* @see https://code.claude.com/docs/en/hooks
|
|
62980
|
+
*/
|
|
62981
|
+
const STDIN_PAYLOAD_EVENTS = {
|
|
62982
|
+
preToolUse: "PreToolUse",
|
|
62983
|
+
postToolUse: "PostToolUse",
|
|
62984
|
+
postToolUseFailure: "PostToolUseFailure"
|
|
62985
|
+
};
|
|
62986
|
+
/**
|
|
62987
|
+
* The fields each payload adds to the tool call's own (`session_id`, `cwd`,
|
|
62988
|
+
* `hook_event_name`, `tool_name`, `tool_input`, `tool_use_id`), as TypeScript
|
|
62989
|
+
* object entries evaluated against the `tool_result` event.
|
|
62990
|
+
*/
|
|
62991
|
+
const STDIN_PAYLOAD_EXTRA_FIELDS = {
|
|
62992
|
+
PreToolUse: "",
|
|
62993
|
+
PostToolUse: "tool_response: { content: event.content, details: event.details }",
|
|
62994
|
+
PostToolUseFailure: "error: toolResultText(event.content)"
|
|
62995
|
+
};
|
|
62996
|
+
/**
|
|
62997
|
+
* Helpers emitted when a handler receives a stdin payload or tests a matcher.
|
|
62998
|
+
*
|
|
62999
|
+
* `claudeToolName` maps the dialect's built-in tool names to the canonical
|
|
63000
|
+
* Claude Code names Rulesync uses elsewhere (`bash` → `Bash`, ...). MCP tools
|
|
63001
|
+
* are already named `mcp__<server>__<tool>` by Pi, and other tools keep their
|
|
63002
|
+
* own name.
|
|
63003
|
+
*
|
|
63004
|
+
* `claudeToolInput` passes the tool's arguments through, except for the file
|
|
63005
|
+
* tools: `path` becomes Claude Code's absolute `file_path`, resolved against
|
|
63006
|
+
* the session cwd the way Pi's `resolveToCwd` does, and on Pi each `edits`
|
|
63007
|
+
* entry's `oldText` / `newText` becomes `old_string` / `new_string` (oh-my-pi
|
|
63008
|
+
* already uses those, see `editTextKeys`). When the call has no top-level
|
|
63009
|
+
* `old_string` / `new_string`, every edit's text is joined into them, as
|
|
63010
|
+
* Claude Code's `Edit` input carries, so a guard reading those sees every
|
|
63011
|
+
* change. The mapped keys are written last and any same-named key the model
|
|
63012
|
+
* added is dropped, so an extra argument (Pi's schemas allow them) cannot make
|
|
63013
|
+
* a guard check a different file or text than the one the tool acts on.
|
|
63014
|
+
*/
|
|
63015
|
+
function buildToolPayloadHelperLines(dialect) {
|
|
63016
|
+
return [
|
|
63017
|
+
`const CLAUDE_TOOL_NAMES: Record<string, string> = ${JSON.stringify(dialect.toolNames)};`,
|
|
63018
|
+
"",
|
|
63019
|
+
"function claudeToolName(toolName: string): string {",
|
|
63020
|
+
" return Object.hasOwn(CLAUDE_TOOL_NAMES, toolName) ? (CLAUDE_TOOL_NAMES[toolName] ?? toolName) : toolName;",
|
|
63021
|
+
"}",
|
|
63022
|
+
"",
|
|
63023
|
+
"function matchesTool(matcher: RegExp, toolName: string): boolean {",
|
|
63024
|
+
" return matcher.test(toolName) || matcher.test(claudeToolName(toolName));",
|
|
63025
|
+
"}",
|
|
63026
|
+
"",
|
|
63027
|
+
...dialect.pathResolverLines,
|
|
63028
|
+
"",
|
|
63029
|
+
`const EDIT_TEXT_KEYS = ${JSON.stringify(dialect.editTextKeys)};`,
|
|
63030
|
+
"const CLAUDE_EDIT_TEXT_KEYS = EDIT_TEXT_KEYS.old === \"old_string\";",
|
|
63031
|
+
"",
|
|
63032
|
+
"function claudeEditEntry(edit: unknown): unknown {",
|
|
63033
|
+
" if (CLAUDE_EDIT_TEXT_KEYS || !edit || typeof edit !== \"object\") return edit;",
|
|
63034
|
+
" const {",
|
|
63035
|
+
" [EDIT_TEXT_KEYS.old]: oldText,",
|
|
63036
|
+
" [EDIT_TEXT_KEYS.new]: newText,",
|
|
63037
|
+
" old_string: _old,",
|
|
63038
|
+
" new_string: _new,",
|
|
63039
|
+
" ...others",
|
|
63040
|
+
" } = edit as Record<string, unknown>;",
|
|
63041
|
+
" return { ...others, old_string: oldText, new_string: newText };",
|
|
63042
|
+
"}",
|
|
63043
|
+
"",
|
|
63044
|
+
"function joinedEditText(edits: unknown[], key: string): string | undefined {",
|
|
63045
|
+
" const texts = edits",
|
|
63046
|
+
" .map((edit: unknown) => (edit as Record<string, unknown> | null)?.[key])",
|
|
63047
|
+
" .filter((text): text is string => typeof text === \"string\");",
|
|
63048
|
+
" return texts.length > 0 ? texts.join(\"\\n\") : undefined;",
|
|
63049
|
+
"}",
|
|
63050
|
+
"",
|
|
63051
|
+
"function claudeToolInput(toolName: string, input: unknown, cwd: string): unknown {",
|
|
63052
|
+
" if (![\"read\", \"write\", \"edit\"].includes(toolName)) return input;",
|
|
63053
|
+
" if (!input || typeof input !== \"object\" || Array.isArray(input)) return input;",
|
|
63054
|
+
" const { path, file_path: _filePath, ...rest } = input as Record<string, unknown>;",
|
|
63055
|
+
" if (!CLAUDE_EDIT_TEXT_KEYS) {",
|
|
63056
|
+
" delete rest.old_string;",
|
|
63057
|
+
" delete rest.new_string;",
|
|
63058
|
+
" }",
|
|
63059
|
+
" // The raw `path` stays, so a guard can check what the model wrote too.",
|
|
63060
|
+
" const claudeInput: Record<string, unknown> = { ...rest, path, file_path: absoluteToolPath(path, cwd) };",
|
|
63061
|
+
" if (!Array.isArray(rest.edits)) return claudeInput;",
|
|
63062
|
+
" const edits = rest.edits.map(claudeEditEntry);",
|
|
63063
|
+
" return {",
|
|
63064
|
+
" ...claudeInput,",
|
|
63065
|
+
" edits,",
|
|
63066
|
+
" old_string: claudeInput.old_string ?? joinedEditText(edits, \"old_string\"),",
|
|
63067
|
+
" new_string: claudeInput.new_string ?? joinedEditText(edits, \"new_string\"),",
|
|
63068
|
+
" };",
|
|
63069
|
+
"}",
|
|
63070
|
+
"",
|
|
63071
|
+
"function toolResultText(content: unknown): string {",
|
|
63072
|
+
" if (!Array.isArray(content)) return \"\";",
|
|
63073
|
+
" return content",
|
|
63074
|
+
" .map((block: unknown) => {",
|
|
63075
|
+
" const part = block as { type?: unknown; text?: unknown } | null;",
|
|
63076
|
+
" return part?.type === \"text\" && typeof part.text === \"string\" ? part.text : \"\";",
|
|
63077
|
+
" })",
|
|
63078
|
+
" .filter(Boolean)",
|
|
63079
|
+
" .join(\"\\n\");",
|
|
63080
|
+
"}",
|
|
63081
|
+
"",
|
|
63082
|
+
"type ToolHookEvent = { toolName: string; toolCallId?: string; input?: unknown };",
|
|
63083
|
+
"",
|
|
63084
|
+
"function toolHookInput(",
|
|
63085
|
+
" hookEventName: string,",
|
|
63086
|
+
" event: ToolHookEvent,",
|
|
63087
|
+
" ctx: ExtensionContext | undefined,",
|
|
63088
|
+
" extra: Record<string, unknown> = {},",
|
|
63089
|
+
"): string {",
|
|
63090
|
+
" const cwd = ctx?.cwd ?? process.cwd();",
|
|
63091
|
+
" return JSON.stringify({",
|
|
63092
|
+
" session_id: ctx?.sessionManager?.getSessionId?.(),",
|
|
63093
|
+
" cwd,",
|
|
63094
|
+
" hook_event_name: hookEventName,",
|
|
63095
|
+
" tool_name: claudeToolName(event.toolName),",
|
|
63096
|
+
" tool_input: claudeToolInput(event.toolName, event.input, cwd),",
|
|
63097
|
+
" tool_use_id: event.toolCallId,",
|
|
63098
|
+
" ...extra,",
|
|
63099
|
+
" });",
|
|
63100
|
+
"}"
|
|
63101
|
+
];
|
|
63102
|
+
}
|
|
63103
|
+
/**
|
|
63104
|
+
* Helpers emitted alongside `tool_call` handlers. A command that exits 0 may
|
|
63105
|
+
* still decide the call the way Claude Code reads a `PreToolUse` hook's JSON
|
|
63106
|
+
* stdout: `hookSpecificOutput.permissionDecision` `"deny"` or `"ask"` (with
|
|
63107
|
+
* `permissionDecisionReason`) or, when no `permissionDecision` is given, the
|
|
63108
|
+
* deprecated top-level `decision: "block"` (with `reason`). Output that is not
|
|
63109
|
+
* such JSON allows the call, so hooks that print plain text keep working. The
|
|
63110
|
+
* deny side is the OpenCode-style plugin's `__rulesyncEnforcePreToolUseResult`
|
|
63111
|
+
* contract, plus the deprecated form Claude Code still honors.
|
|
63112
|
+
*
|
|
63113
|
+
* Pi has no permission prompt of its own, so `"ask"` is put to the user with
|
|
63114
|
+
* `ctx.ui.confirm` when a UI is attached, and denies the call when none is (print
|
|
63115
|
+
* and JSON modes) or the dialog fails: a hook asking for a human must not pass
|
|
63116
|
+
* silently.
|
|
63117
|
+
*/
|
|
63118
|
+
const TOOL_DECISION_HELPER_LINES = [
|
|
63119
|
+
"type ToolHookDecision = { kind: \"deny\" | \"ask\"; reason: string };",
|
|
63120
|
+
"",
|
|
63121
|
+
"function toolHookDecision(stdout: string): ToolHookDecision | undefined {",
|
|
63122
|
+
" let parsed: unknown;",
|
|
63123
|
+
" try {",
|
|
63124
|
+
" parsed = JSON.parse(stdout);",
|
|
63125
|
+
" } catch {",
|
|
63126
|
+
" return undefined;",
|
|
63127
|
+
" }",
|
|
63128
|
+
" if (!parsed || typeof parsed !== \"object\") return undefined;",
|
|
63129
|
+
" const output = parsed as { decision?: unknown; reason?: unknown; hookSpecificOutput?: unknown };",
|
|
63130
|
+
" const specific = output.hookSpecificOutput as",
|
|
63131
|
+
" | { permissionDecision?: unknown; permissionDecisionReason?: unknown }",
|
|
63132
|
+
" | null",
|
|
63133
|
+
" | undefined;",
|
|
63134
|
+
" const hasDecision = typeof specific === \"object\" && specific !== null && specific.permissionDecision !== undefined;",
|
|
63135
|
+
" const decision = hasDecision ? specific?.permissionDecision : output.decision === \"block\" ? \"deny\" : undefined;",
|
|
63136
|
+
" if (decision !== \"deny\" && decision !== \"ask\") return undefined;",
|
|
63137
|
+
" const reason = hasDecision ? specific?.permissionDecisionReason : output.reason;",
|
|
63138
|
+
" return {",
|
|
63139
|
+
" kind: decision,",
|
|
63140
|
+
" reason:",
|
|
63141
|
+
" (typeof reason === \"string\" && sanitizeBlockReason(reason)) ||",
|
|
63142
|
+
" (decision === \"ask\" ? \"A preToolUse hook asked for confirmation.\" : \"Blocked by a preToolUse hook.\"),",
|
|
63143
|
+
" };",
|
|
63144
|
+
"}",
|
|
63145
|
+
"",
|
|
63146
|
+
"async function allowsToolCall(",
|
|
63147
|
+
" decision: ToolHookDecision,",
|
|
63148
|
+
" ctx: ExtensionContext | undefined,",
|
|
63149
|
+
"): Promise<boolean> {",
|
|
63150
|
+
" if (decision.kind !== \"ask\" || !ctx?.hasUI) return false;",
|
|
63151
|
+
" try {",
|
|
63152
|
+
" return await ctx.ui.confirm(\"Allow this tool call?\", decision.reason);",
|
|
63153
|
+
" } catch {",
|
|
63154
|
+
" return false;",
|
|
63155
|
+
" }",
|
|
63156
|
+
"}"
|
|
63157
|
+
];
|
|
63158
|
+
/**
|
|
63159
|
+
* Runs a hook command through the platform shell with `input` as its stdin
|
|
63160
|
+
* (empty when the event has no payload, so a command that reads stdin never
|
|
63161
|
+
* waits on Pi's own), bounded by the hook's `timeout` in seconds (Claude
|
|
63162
|
+
* Code's default of 600 when unset, as in the OpenCode-style plugin). A stdin
|
|
63163
|
+
* the command never reads is not an error.
|
|
63164
|
+
*
|
|
63165
|
+
* The command runs in its own process group (except on Windows), so a command
|
|
63166
|
+
* past its timeout is killed together with everything it started, and the
|
|
63167
|
+
* call rejects with a `HookTimeoutError` right away rather than waiting for a
|
|
63168
|
+
* descendant still holding its output open. Like `promisify(exec)`, which
|
|
63169
|
+
* earlier versions used, a non-zero exit rejects with an error carrying
|
|
63170
|
+
* `code`, `stdout` and `stderr`, and more than 1 MiB on either stream rejects
|
|
63171
|
+
* and kills the command.
|
|
63172
|
+
*
|
|
63173
|
+
* A detached group does not get the terminal's Ctrl+C, so the extension
|
|
63174
|
+
* kills every command still running on `session_shutdown`, after the other
|
|
63175
|
+
* handlers (including a `sessionEnd` hook's) have run: Pi awaits them in
|
|
63176
|
+
* registration order. A Pi process killed outright never fires it, and since
|
|
63177
|
+
* the timeout timer lives in that process too, its commands then keep running
|
|
63178
|
+
* with no deadline until they exit on their own.
|
|
63179
|
+
*/
|
|
63180
|
+
const RUN_HELPER_LINES = [
|
|
63181
|
+
"const MAX_HOOK_OUTPUT_LENGTH = 1024 * 1024;",
|
|
63182
|
+
"",
|
|
63183
|
+
"class HookTimeoutError extends Error {}",
|
|
63184
|
+
"",
|
|
63185
|
+
"// Kills of the commands still running, for `session_shutdown`.",
|
|
63186
|
+
"const runningHookCommands = new Set<() => void>();",
|
|
63187
|
+
"",
|
|
63188
|
+
"function run(",
|
|
63189
|
+
" command: string,",
|
|
63190
|
+
" { input = \"\", seconds }: { input?: string; seconds: number },",
|
|
63191
|
+
"): Promise<{ stdout: string; stderr: string }> {",
|
|
63192
|
+
" return new Promise((resolve, reject) => {",
|
|
63193
|
+
" const detached = process.platform !== \"win32\";",
|
|
63194
|
+
" const child = spawn(command, { shell: true, detached, windowsHide: true });",
|
|
63195
|
+
" const output = { stdout: \"\", stderr: \"\" };",
|
|
63196
|
+
" let settled = false;",
|
|
63197
|
+
" const finish = (error?: Error) => {",
|
|
63198
|
+
" if (settled) return;",
|
|
63199
|
+
" settled = true;",
|
|
63200
|
+
" clearTimeout(timer);",
|
|
63201
|
+
" runningHookCommands.delete(killTree);",
|
|
63202
|
+
" if (error) reject(error);",
|
|
63203
|
+
" else resolve(output);",
|
|
63204
|
+
" };",
|
|
63205
|
+
" const killTree = () => {",
|
|
63206
|
+
" try {",
|
|
63207
|
+
" if (detached && child.pid !== undefined) process.kill(-child.pid, \"SIGKILL\");",
|
|
63208
|
+
" else child.kill(\"SIGKILL\");",
|
|
63209
|
+
" } catch {",
|
|
63210
|
+
" // Already gone.",
|
|
63211
|
+
" }",
|
|
63212
|
+
" child.stdout?.destroy();",
|
|
63213
|
+
" child.stderr?.destroy();",
|
|
63214
|
+
" };",
|
|
63215
|
+
" runningHookCommands.add(killTree);",
|
|
63216
|
+
" const timer = setTimeout(() => {",
|
|
63217
|
+
" killTree();",
|
|
63218
|
+
" finish(new HookTimeoutError(`Hook command timed out after ${seconds} seconds.`));",
|
|
63219
|
+
" }, seconds * 1000);",
|
|
63220
|
+
" for (const stream of [\"stdout\", \"stderr\"] as const) {",
|
|
63221
|
+
" child[stream]?.setEncoding(\"utf8\");",
|
|
63222
|
+
" child[stream]?.on(\"data\", (chunk: string) => {",
|
|
63223
|
+
" output[stream] += chunk;",
|
|
63224
|
+
" if (output[stream].length <= MAX_HOOK_OUTPUT_LENGTH) return;",
|
|
63225
|
+
" killTree();",
|
|
63226
|
+
" finish(new Error(`Hook command wrote more than 1 MiB to ${stream}.`));",
|
|
63227
|
+
" });",
|
|
63228
|
+
" }",
|
|
63229
|
+
" child.on(\"error\", (error) => finish(error));",
|
|
63230
|
+
" child.on(\"close\", (code, signal) => {",
|
|
63231
|
+
" if (code === 0) return finish();",
|
|
63232
|
+
" finish(",
|
|
63233
|
+
" Object.assign(new Error(`Command failed: ${command}`), {",
|
|
63234
|
+
" code,",
|
|
63235
|
+
" signal,",
|
|
63236
|
+
" stdout: output.stdout,",
|
|
63237
|
+
" stderr: output.stderr,",
|
|
63238
|
+
" }),",
|
|
63239
|
+
" );",
|
|
63240
|
+
" });",
|
|
63241
|
+
" child.stdin?.on(\"error\", () => {});",
|
|
63242
|
+
" child.stdin?.end(input);",
|
|
63243
|
+
" });",
|
|
63244
|
+
"}"
|
|
63245
|
+
];
|
|
63246
|
+
/**
|
|
63247
|
+
* Helper emitted alongside blocking handlers. `run` rejects on a
|
|
62353
63248
|
* non-zero exit with an error carrying `stdout` / `stderr` / `code`, so the
|
|
62354
63249
|
* reason is derived from the rejection rather than from a resolved exit code.
|
|
62355
63250
|
* A command that could not be run at all (spawn failure, `maxBuffer` overflow)
|
|
@@ -62453,7 +63348,9 @@ function collectPiHandlers({ effectiveHooks, eventMap }) {
|
|
|
62453
63348
|
handlers.push({
|
|
62454
63349
|
command: def.command,
|
|
62455
63350
|
matcher: def.matcher ? def.matcher : void 0,
|
|
62456
|
-
onlyOnError: PI_ERROR_GATED_CANONICAL_EVENTS.has(canonicalEvent)
|
|
63351
|
+
onlyOnError: PI_ERROR_GATED_CANONICAL_EVENTS.has(canonicalEvent),
|
|
63352
|
+
...hookTimingOf(def),
|
|
63353
|
+
...PI_TOOL_EVENTS.has(piEvent) && STDIN_PAYLOAD_EVENTS[canonicalEvent] ? { payload: STDIN_PAYLOAD_EVENTS[canonicalEvent] } : {}
|
|
62457
63354
|
});
|
|
62458
63355
|
}
|
|
62459
63356
|
if (handlers.length > 0) {
|
|
@@ -62468,22 +63365,63 @@ function buildCommandLines({ handler, usesToolName, blocking, dialect }) {
|
|
|
62468
63365
|
const lines = [];
|
|
62469
63366
|
const conditions = [];
|
|
62470
63367
|
if (handler.onlyOnError) conditions.push("event.isError");
|
|
62471
|
-
if (usesToolName && handler.matcher) conditions.push(`new RegExp(${matcherToEmbeddedLiteral(handler.matcher)})
|
|
63368
|
+
if (usesToolName && handler.matcher) conditions.push(`matchesTool(new RegExp(${matcherToEmbeddedLiteral(handler.matcher)}), event.toolName)`);
|
|
62472
63369
|
const gated = conditions.length > 0;
|
|
62473
63370
|
const indent = gated ? " " : " ";
|
|
62474
|
-
const
|
|
63371
|
+
const options = [...handler.payload ? [`input: ${payloadAccessorName(handler.payload)}()`] : [], `seconds: ${handler.timeout}`];
|
|
63372
|
+
const runCall = `run(${JSON.stringify(handler.command)}, { ${options.join(", ")} })`;
|
|
62475
63373
|
if (gated) lines.push(` if (${conditions.join(" && ")}) {`);
|
|
62476
63374
|
const onFailure = failureLinesByMode(dialect)[blocking];
|
|
62477
|
-
if (
|
|
63375
|
+
if (blocking === "tool") {
|
|
63376
|
+
lines.push(`${indent}try {`);
|
|
63377
|
+
lines.push(`${indent} const decision = toolHookDecision((await ${runCall}).stdout);`);
|
|
63378
|
+
lines.push(`${indent} if (decision && !(await allowsToolCall(decision, ctx))) return { block: true, reason: decision.reason };`);
|
|
63379
|
+
lines.push(`${indent}} catch (error) {`);
|
|
63380
|
+
if (handler.failClosed === false) {
|
|
63381
|
+
lines.push(`${indent} if (error instanceof HookTimeoutError) {`);
|
|
63382
|
+
lines.push(`${indent} console.error("[rulesync-hooks] preToolUse hook timed out");`);
|
|
63383
|
+
lines.push(`${indent} } else {`);
|
|
63384
|
+
for (const line of onFailure) lines.push(`${indent} ${line}`);
|
|
63385
|
+
lines.push(`${indent} }`);
|
|
63386
|
+
} else for (const line of onFailure) lines.push(`${indent} ${line}`);
|
|
63387
|
+
lines.push(`${indent}}`);
|
|
63388
|
+
} else if (onFailure.length > 0) {
|
|
62478
63389
|
lines.push(`${indent}try {`);
|
|
62479
|
-
lines.push(`${indent} await
|
|
63390
|
+
lines.push(`${indent} await ${runCall};`);
|
|
62480
63391
|
lines.push(`${indent}} catch (error) {`);
|
|
62481
63392
|
for (const line of onFailure) lines.push(`${indent} ${line}`);
|
|
62482
63393
|
lines.push(`${indent}}`);
|
|
62483
|
-
} else lines.push(`${indent}await
|
|
63394
|
+
} else lines.push(`${indent}await ${runCall};`);
|
|
62484
63395
|
if (gated) lines.push(" }");
|
|
62485
63396
|
return lines;
|
|
62486
63397
|
}
|
|
63398
|
+
/** The per-invocation closure a handler calls for its serialized payload. */
|
|
63399
|
+
function payloadAccessorName(hookEventName) {
|
|
63400
|
+
return `${hookEventName.charAt(0).toLowerCase()}${hookEventName.slice(1)}Input`;
|
|
63401
|
+
}
|
|
63402
|
+
/** Lazily serialized payloads the handlers of one subscription use. */
|
|
63403
|
+
function buildPayloadLines(handlers) {
|
|
63404
|
+
const payloads = [...new Set(handlers.flatMap((h) => h.payload ? [h.payload] : []))];
|
|
63405
|
+
const lines = [];
|
|
63406
|
+
for (const payload of payloads) {
|
|
63407
|
+
const accessor = payloadAccessorName(payload);
|
|
63408
|
+
const extra = STDIN_PAYLOAD_EXTRA_FIELDS[payload] ?? "";
|
|
63409
|
+
const extraArgument = extra ? `, { ${extra} }` : "";
|
|
63410
|
+
lines.push(` let ${accessor}Cache: string | undefined;`);
|
|
63411
|
+
lines.push(` const ${accessor} = () => (${accessor}Cache ??= toolHookInput(${JSON.stringify(payload)}, event, ctx${extraArgument}));`);
|
|
63412
|
+
}
|
|
63413
|
+
return lines;
|
|
63414
|
+
}
|
|
63415
|
+
/**
|
|
63416
|
+
* The handler's parameter list. `ctx` is the second handler argument, so the
|
|
63417
|
+
* prompt gate and the payload builders (which read the session id and cwd)
|
|
63418
|
+
* name both.
|
|
63419
|
+
*/
|
|
63420
|
+
function handlerParams({ handlers, readsEvent, isPromptGate }) {
|
|
63421
|
+
const usesPayload = handlers.some((h) => h.payload);
|
|
63422
|
+
if (isPromptGate || usesPayload) return "event, ctx";
|
|
63423
|
+
return readsEvent || handlers.some((h) => h.onlyOnError) ? "event" : "";
|
|
63424
|
+
}
|
|
62487
63425
|
function buildSubscriptionLines(handlerGroups, dialect) {
|
|
62488
63426
|
const lines = [];
|
|
62489
63427
|
for (const [piEvent, handlers] of Object.entries(handlerGroups)) {
|
|
@@ -62493,13 +63431,17 @@ function buildSubscriptionLines(handlerGroups, dialect) {
|
|
|
62493
63431
|
const isSessionStopGate = blocking === "sessionStop";
|
|
62494
63432
|
const collectsStopFailures = isSettleGate || isSessionStopGate;
|
|
62495
63433
|
const usesToolName = PI_TOOL_EVENTS.has(piEvent) && handlers.some((h) => h.matcher);
|
|
62496
|
-
const usesErrorFlag = handlers.some((h) => h.onlyOnError);
|
|
62497
63434
|
const gatesOnAssistant = PI_ASSISTANT_MESSAGE_EVENTS.has(piEvent);
|
|
62498
|
-
const params =
|
|
63435
|
+
const params = handlerParams({
|
|
63436
|
+
handlers,
|
|
63437
|
+
readsEvent: usesToolName || gatesOnAssistant || collectsStopFailures,
|
|
63438
|
+
isPromptGate
|
|
63439
|
+
});
|
|
62499
63440
|
lines.push(` pi.on(${JSON.stringify(piEvent)}, async (${params}) => {`);
|
|
62500
63441
|
if (gatesOnAssistant) lines.push(` if (event.message.role !== "assistant") return;`);
|
|
62501
63442
|
if (isPromptGate) lines.push(` if (event.source === "extension") ${dialect.promptPassLine}`);
|
|
62502
63443
|
if (collectsStopFailures) lines.push(" const stopHookFailures: unknown[] = [];");
|
|
63444
|
+
lines.push(...buildPayloadLines(handlers));
|
|
62503
63445
|
for (const handler of handlers) lines.push(...buildCommandLines({
|
|
62504
63446
|
handler,
|
|
62505
63447
|
usesToolName,
|
|
@@ -62535,6 +63477,10 @@ function buildSubscriptionLines(handlerGroups, dialect) {
|
|
|
62535
63477
|
}
|
|
62536
63478
|
return lines;
|
|
62537
63479
|
}
|
|
63480
|
+
/** Whether a handler belongs to a tool event, where its matcher is tested. */
|
|
63481
|
+
function handlerGroupHasToolEvent(handlerGroups, handler) {
|
|
63482
|
+
return Object.entries(handlerGroups).some(([piEvent, handlers]) => PI_TOOL_EVENTS.has(piEvent) && handlers.includes(handler));
|
|
63483
|
+
}
|
|
62538
63484
|
/**
|
|
62539
63485
|
* Generate the rulesync-owned Pi extension (a TypeScript module with a
|
|
62540
63486
|
* default-export factory receiving Pi's ExtensionAPI) that subscribes to the
|
|
@@ -62549,6 +63495,12 @@ function buildSubscriptionLines(handlerGroups, dialect) {
|
|
|
62549
63495
|
* command's output as feedback.
|
|
62550
63496
|
* `postToolUse` and `postToolUseFailure` share Pi's `tool_result` event; the
|
|
62551
63497
|
* latter's commands run only when `event.isError` is set.
|
|
63498
|
+
* Commands on the tool events receive Claude Code's hook input on stdin (see
|
|
63499
|
+
* `STDIN_PAYLOAD_EVENTS`), and a tool matcher is tested against both Pi's tool
|
|
63500
|
+
* name and its canonical Claude Code name. On `tool_call`, a command that exits
|
|
63501
|
+
* 0 with a JSON deny decision also denies the call, and one past its `timeout`
|
|
63502
|
+
* denies it unless the hook sets `failClosed: false`, mirroring the
|
|
63503
|
+
* OpenCode-style plugin.
|
|
62552
63504
|
*
|
|
62553
63505
|
* @see https://github.com/earendil-works/pi/blob/main/packages/coding-agent/docs/extensions.md
|
|
62554
63506
|
*/
|
|
@@ -62568,7 +63520,9 @@ function generatePiExtensionCode({ config, supportedEvents, eventMap, dialect =
|
|
|
62568
63520
|
const hasPromptGate = Boolean(handlerGroups[PI_PROMPT_BLOCKING_EVENT]);
|
|
62569
63521
|
const hasSettleGate = Boolean(handlerGroups[PI_SETTLE_BLOCKING_EVENT]);
|
|
62570
63522
|
const hasSessionStopGate = Boolean(handlerGroups[OMP_SESSION_STOP_BLOCKING_EVENT]);
|
|
62571
|
-
const
|
|
63523
|
+
const needsToolHelpers = Object.values(handlerGroups).flat().some((h) => h.payload || h.matcher && handlerGroupHasToolEvent(handlerGroups, h));
|
|
63524
|
+
const hasToolGate = Boolean(handlerGroups[PI_BLOCKING_EVENT]);
|
|
63525
|
+
const needsBlockReasonHelper = hasToolGate || hasPromptGate || hasSettleGate || hasSessionStopGate;
|
|
62572
63526
|
const lines = ["// Generated by rulesync. Do not edit manually."];
|
|
62573
63527
|
if (subscriptionLines.length === 0) {
|
|
62574
63528
|
lines.push("export default function () {}");
|
|
@@ -62578,34 +63532,33 @@ function generatePiExtensionCode({ config, supportedEvents, eventMap, dialect =
|
|
|
62578
63532
|
const importedTypes = [
|
|
62579
63533
|
...hasSettleGate ? ["AgentBeforeSettleEvent", "AgentBeforeSettleEventResult"] : [],
|
|
62580
63534
|
"ExtensionAPI",
|
|
62581
|
-
...hasPromptGate ? ["ExtensionContext"] : []
|
|
63535
|
+
...hasPromptGate || needsToolHelpers ? ["ExtensionContext"] : []
|
|
62582
63536
|
].join(", ");
|
|
62583
|
-
lines.push("import {
|
|
62584
|
-
|
|
63537
|
+
lines.push("import { spawn } from \"node:child_process\";");
|
|
63538
|
+
if (needsToolHelpers) {
|
|
63539
|
+
lines.push("import { homedir } from \"node:os\";");
|
|
63540
|
+
lines.push(dialect.pathResolverLines === OMP_PATH_RESOLVER_LINES ? "import { join as joinPath, resolve as resolvePath, win32 as win32Path } from \"node:path\";" : "import { join as joinPath, resolve as resolvePath } from \"node:path\";");
|
|
63541
|
+
lines.push("import { fileURLToPath } from \"node:url\";");
|
|
63542
|
+
}
|
|
62585
63543
|
lines.push("");
|
|
62586
63544
|
lines.push(`import type { ${importedTypes} } from ${JSON.stringify(dialect.typesPackage)};`);
|
|
62587
63545
|
lines.push("");
|
|
62588
|
-
|
|
62589
|
-
|
|
62590
|
-
|
|
62591
|
-
|
|
62592
|
-
|
|
62593
|
-
|
|
62594
|
-
|
|
62595
|
-
|
|
62596
|
-
|
|
62597
|
-
|
|
62598
|
-
if (hasSettleGate || hasSessionStopGate) {
|
|
62599
|
-
lines.push(...STOP_HOOK_BLOCK_HELPER_LINES);
|
|
62600
|
-
lines.push("");
|
|
62601
|
-
}
|
|
62602
|
-
if (hasSettleGate) {
|
|
62603
|
-
lines.push(...STOP_HOOK_HELPER_LINES);
|
|
62604
|
-
lines.push("");
|
|
62605
|
-
}
|
|
63546
|
+
const helperBlocks = [
|
|
63547
|
+
[true, RUN_HELPER_LINES],
|
|
63548
|
+
[needsBlockReasonHelper, BLOCK_REASON_HELPER_LINES],
|
|
63549
|
+
[hasToolGate, TOOL_DECISION_HELPER_LINES],
|
|
63550
|
+
[needsToolHelpers, needsToolHelpers ? buildToolPayloadHelperLines(dialect) : []],
|
|
63551
|
+
[hasPromptGate, PROMPT_GATE_HELPER_LINES],
|
|
63552
|
+
[hasSettleGate || hasSessionStopGate, STOP_HOOK_BLOCK_HELPER_LINES],
|
|
63553
|
+
[hasSettleGate, STOP_HOOK_HELPER_LINES]
|
|
63554
|
+
];
|
|
63555
|
+
for (const [included, block] of helperBlocks) if (included) lines.push(...block, "");
|
|
62606
63556
|
lines.push("export default function (pi: ExtensionAPI) {");
|
|
62607
63557
|
if (hasSettleGate) lines.push(" let stopHookContinued = false;");
|
|
62608
63558
|
lines.push(...subscriptionLines);
|
|
63559
|
+
lines.push(" pi.on(\"session_shutdown\", async () => {");
|
|
63560
|
+
lines.push(" for (const kill of [...runningHookCommands]) kill();");
|
|
63561
|
+
lines.push(" });");
|
|
62609
63562
|
lines.push("}");
|
|
62610
63563
|
lines.push("");
|
|
62611
63564
|
return lines.join("\n");
|
|
@@ -65030,7 +65983,13 @@ const toolHooksFactories = /* @__PURE__ */ new Map([
|
|
|
65030
65983
|
},
|
|
65031
65984
|
...converterCapabilities(BobHooks.getConverterConfig()),
|
|
65032
65985
|
supportsMatcher: true,
|
|
65033
|
-
matcherEvents:
|
|
65986
|
+
matcherEvents: BOB_MATCHER_HOOK_EVENTS,
|
|
65987
|
+
dropsUnknownOverrideEvents: true,
|
|
65988
|
+
overrideOnlyEvents: BOB_NATIVE_HOOK_EVENTS,
|
|
65989
|
+
overrideOptIn: {
|
|
65990
|
+
events: BOB_OPT_IN_HOOK_EVENTS,
|
|
65991
|
+
note: "They need Bob Shell 2.1.0 or later, and an older Bob Shell ignores the whole hooks block of a settings file that names them."
|
|
65992
|
+
}
|
|
65034
65993
|
}],
|
|
65035
65994
|
["continue", {
|
|
65036
65995
|
class: ContinueHooks,
|
|
@@ -65356,12 +66315,26 @@ var HooksProcessor = class extends FeatureProcessor {
|
|
|
65356
66315
|
...overrideHooks
|
|
65357
66316
|
};
|
|
65358
66317
|
{
|
|
65359
|
-
const
|
|
66318
|
+
const optInEvents = factory.overrideOptIn?.events ?? {};
|
|
66319
|
+
const isOptIn = (e) => Object.hasOwn(optInEvents, e);
|
|
66320
|
+
const overrideKeys = new Set(Object.keys(overrideHooks));
|
|
66321
|
+
const skippedEvents = unsupportedEventNames({
|
|
65360
66322
|
factory,
|
|
65361
66323
|
sharedHooks,
|
|
65362
66324
|
effectiveHooks
|
|
65363
66325
|
});
|
|
66326
|
+
const skipped = skippedEvents.filter((e) => !isOptIn(e));
|
|
66327
|
+
const optIn = skippedEvents.filter(isOptIn).filter((e) => Object.hasOwn(sharedHooks, e) && !overrideKeys.has(optInEvents[e] ?? ""));
|
|
66328
|
+
const misnamed = skippedEvents.filter(isOptIn).filter((e) => overrideKeys.has(e));
|
|
65364
66329
|
if (skipped.length > 0) this.logger.warn(`Skipped hook event(s) for ${this.toolTarget} (not supported): ${skipped.join(", ")}`);
|
|
66330
|
+
if (optIn.length > 0) {
|
|
66331
|
+
const nativeNames = optIn.map((e) => optInEvents[e]).join(", ");
|
|
66332
|
+
this.logger.warn(`Skipped hook event(s) for ${this.toolTarget}: ${optIn.join(", ")}. ${factory.overrideOptIn?.note} To opt in, author them under the "${overrideKey}.hooks" override with the native name(s) ${nativeNames}.`);
|
|
66333
|
+
}
|
|
66334
|
+
if (misnamed.length > 0) {
|
|
66335
|
+
const nativeNames = misnamed.map((e) => optInEvents[e]).join(", ");
|
|
66336
|
+
this.logger.warn(`Skipped "${overrideKey}.hooks" key(s) for ${this.toolTarget}: ${misnamed.join(", ")}. Use the native name(s) ${nativeNames} instead.`);
|
|
66337
|
+
}
|
|
65365
66338
|
}
|
|
65366
66339
|
{
|
|
65367
66340
|
const supportedHookTypes = new Set(factory.supportedHookTypes);
|
|
@@ -73321,7 +74294,8 @@ const HERMES_OPAQUE_MAPPING_KEYS = [
|
|
|
73321
74294
|
* alias — `auth` (`oauth` for OAuth 2.1/PKCE), mTLS `client_cert` (string PEM
|
|
73322
74295
|
* path, or `[cert, key]`/`[cert, key, password]` list) and `client_key`,
|
|
73323
74296
|
* `connect_timeout` (seconds), `supports_parallel_tool_calls`, `protocol`,
|
|
73324
|
-
* `lazy`, `events` (see {@link copyHermesBoolLikeFields}), `
|
|
74297
|
+
* `lazy`, `events` (see {@link copyHermesBoolLikeFields}), `single_instance`,
|
|
74298
|
+
* `keepalive_interval`,
|
|
73325
74299
|
* `elicitation`, `trust`, `identity_header`, and
|
|
73326
74300
|
* the cost keys (see {@link copyHermesCostFields}) —
|
|
73327
74301
|
* verbatim from `source` to `target`. Field names are identical on both sides
|
|
@@ -73372,6 +74346,10 @@ function copyHermesAdvancedFields(source, target, logger) {
|
|
|
73372
74346
|
target.skip_preflight = source.skip_preflight;
|
|
73373
74347
|
copied = true;
|
|
73374
74348
|
}
|
|
74349
|
+
if (typeof source.single_instance === "boolean") {
|
|
74350
|
+
target.single_instance = source.single_instance;
|
|
74351
|
+
copied = true;
|
|
74352
|
+
}
|
|
73375
74353
|
if (typeof source.keepalive_interval === "number") {
|
|
73376
74354
|
target.keepalive_interval = source.keepalive_interval;
|
|
73377
74355
|
copied = true;
|
|
@@ -83963,7 +84941,7 @@ function buildVscodeCommandLists({ rules, toolLabel, logger, prefixSemantics = "
|
|
|
83963
84941
|
};
|
|
83964
84942
|
}
|
|
83965
84943
|
// src/features/permissions/bob-permissions.ts
|
|
83966
|
-
const TOOL_LABEL = "IBM Bob";
|
|
84944
|
+
const TOOL_LABEL$1 = "IBM Bob";
|
|
83967
84945
|
/** The top-level settings key holding Bob's auto-approval configuration. */
|
|
83968
84946
|
const APPROVAL_KEY$1 = "approval";
|
|
83969
84947
|
/** The top-level settings key holding Bob's per-feature auto-approve toggles. */
|
|
@@ -84045,7 +85023,7 @@ function warnAboutSkippedCategories({ permission, bashStated, authorsGroupSwitch
|
|
|
84045
85023
|
if (skipped.length === 0) return;
|
|
84046
85024
|
const names = skipped.map((category) => `'${category}'`).join(", ");
|
|
84047
85025
|
const hint = authorsGroupSwitches ? "" : ` ${GROUP_SWITCH_HINT}`;
|
|
84048
|
-
warnWithFallback(logger, bashStated ? `${TOOL_LABEL} only models shell-command permissions (${SURFACE_LABEL}); ${names} allow rules cannot be represented and were skipped.${hint}` : `${TOOL_LABEL} only models shell-command permissions (${SURFACE_LABEL}), and .rulesync/permissions.jsonc states no 'bash' category, so ${names} ${skipped.length === 1 ? "was" : "were"} skipped and the command lists were left untouched.${hint}`);
|
|
85026
|
+
warnWithFallback(logger, bashStated ? `${TOOL_LABEL$1} only models shell-command permissions (${SURFACE_LABEL}); ${names} allow rules cannot be represented and were skipped.${hint}` : `${TOOL_LABEL$1} only models shell-command permissions (${SURFACE_LABEL}), and .rulesync/permissions.jsonc states no 'bash' category, so ${names} ${skipped.length === 1 ? "was" : "were"} skipped and the command lists were left untouched.${hint}`);
|
|
84049
85027
|
}
|
|
84050
85028
|
/**
|
|
84051
85029
|
* Warn about what the `bob` override writes that Bob does not document: an
|
|
@@ -84065,7 +85043,7 @@ function warnAboutUndocumentedSettings({ override, logger }) {
|
|
|
84065
85043
|
...outsideWorkspace.length > 0 ? [`'enableOutsideWorkspace' for group(s) ${quoteAll(outsideWorkspace)}`] : []
|
|
84066
85044
|
];
|
|
84067
85045
|
if (parts.length === 0) return;
|
|
84068
|
-
warnWithFallback(logger, `${TOOL_LABEL} permissions: the bob override sets ${parts.join("; ")}, which Bob does not document; they were written as authored. Bob documents the groups ${quoteAll(BOB_PERMISSION_GROUP_IDS)}, the '${AUTO_APPROVE_KEY}' toggle(s) ${quoteAll(BOB_AUTO_APPROVE_KEYS)}, and 'enableOutsideWorkspace' for the '${OUTSIDE_WORKSPACE_GROUP_ID}' group only.`);
|
|
85046
|
+
warnWithFallback(logger, `${TOOL_LABEL$1} permissions: the bob override sets ${parts.join("; ")}, which Bob does not document; they were written as authored. Bob documents the groups ${quoteAll(BOB_PERMISSION_GROUP_IDS)}, the '${AUTO_APPROVE_KEY}' toggle(s) ${quoteAll(BOB_AUTO_APPROVE_KEYS)}, and 'enableOutsideWorkspace' for the '${OUTSIDE_WORKSPACE_GROUP_ID}' group only.`);
|
|
84069
85047
|
}
|
|
84070
85048
|
/**
|
|
84071
85049
|
* Name what the `bob` override newly auto-approves. The settings file is Bob's
|
|
@@ -84084,7 +85062,7 @@ function warnAboutNewAutoApprovals({ settings, override, filePath, logger }) {
|
|
|
84084
85062
|
...Object.entries(override?.autoApprove ?? {}).filter(([key, value]) => value === true && existingAutoApprove[key] !== true).map(([key]) => quoteValueForWarning(`${AUTO_APPROVE_KEY}.${key}`))
|
|
84085
85063
|
]);
|
|
84086
85064
|
if (added.size === 0) return;
|
|
84087
|
-
warnWithFallback(logger, `${TOOL_LABEL} permissions: the bob override now auto-approves ${[...added].join(", ")} in ${filePath}, Bob's user settings, so this applies to every project on this machine. Check it if .rulesync/permissions.jsonc arrived with a repository you cloned.`);
|
|
85065
|
+
warnWithFallback(logger, `${TOOL_LABEL$1} permissions: the bob override now auto-approves ${[...added].join(", ")} in ${filePath}, Bob's user settings, so this applies to every project on this machine. Check it if .rulesync/permissions.jsonc arrived with a repository you cloned.`);
|
|
84088
85066
|
}
|
|
84089
85067
|
/**
|
|
84090
85068
|
* Split the canonical `bash` rules — plus the restricting rules of the
|
|
@@ -84101,7 +85079,7 @@ function buildBobCommandLists({ permission, logger }) {
|
|
|
84101
85079
|
normalizePattern: widenToPrefixGlob$1
|
|
84102
85080
|
});
|
|
84103
85081
|
warnAboutUnwrittenCommandRules({
|
|
84104
|
-
toolLabel: TOOL_LABEL,
|
|
85082
|
+
toolLabel: TOOL_LABEL$1,
|
|
84105
85083
|
surfaceLabel: SURFACE_LABEL,
|
|
84106
85084
|
foreignRestrictingCategories,
|
|
84107
85085
|
shadowedAllowPatterns,
|
|
@@ -84116,7 +85094,7 @@ function buildBobCommandLists({ permission, logger }) {
|
|
|
84116
85094
|
for (const pattern of deny) lists[pattern] = "deny";
|
|
84117
85095
|
return buildVscodeCommandLists({
|
|
84118
85096
|
rules: lists,
|
|
84119
|
-
toolLabel: TOOL_LABEL,
|
|
85097
|
+
toolLabel: TOOL_LABEL$1,
|
|
84120
85098
|
logger,
|
|
84121
85099
|
prefixSemantics: "documented-prefix"
|
|
84122
85100
|
});
|
|
@@ -84288,7 +85266,7 @@ var BobPermissions = class BobPermissions extends ToolPermissions {
|
|
|
84288
85266
|
const rules = importVscodeCommandLists({
|
|
84289
85267
|
allowed: toStringArray$1(entry?.approvedCommands),
|
|
84290
85268
|
denied: toStringArray$1(entry?.deniedCommands),
|
|
84291
|
-
toolLabel: TOOL_LABEL,
|
|
85269
|
+
toolLabel: TOOL_LABEL$1,
|
|
84292
85270
|
logger,
|
|
84293
85271
|
prefixSemantics: "documented-prefix"
|
|
84294
85272
|
});
|
|
@@ -85085,6 +86063,7 @@ const CLAUDECODE_UNHONORED_KEY_SOURCES = {
|
|
|
85085
86063
|
disableMobileSimulatorTools: "managed settings",
|
|
85086
86064
|
disableRemotePreviewScripts: "managed settings",
|
|
85087
86065
|
disableSideloadFlags: "managed settings",
|
|
86066
|
+
enforceAnthropicSignIn: "managed settings",
|
|
85088
86067
|
externalEditorContext: "~/.claude.json",
|
|
85089
86068
|
forceRemoteSettingsRefresh: "managed settings",
|
|
85090
86069
|
gatewayInternalNetworks: "managed settings",
|
|
@@ -85237,12 +86216,14 @@ const CLAUDECODE_ENV_IGNORED_IN_EVERY_FILE = /* @__PURE__ */ new Set([
|
|
|
85237
86216
|
"CLAUDE_CODE_DISABLE_MOUNTED_DRIVE_RM_PROMPT",
|
|
85238
86217
|
"CLAUDE_CODE_DISABLE_POWERSHELL_CMD_RM_DENY",
|
|
85239
86218
|
"CLAUDE_CODE_DISABLE_SUBSTITUTION_RM_PROMPT",
|
|
86219
|
+
"CLAUDE_CODE_DISABLE_ULTRAREVIEW_TRUST_CHECK",
|
|
85240
86220
|
"CLAUDE_CODE_EVEN_MORE_DANGEROUSLY_SKIP_PERMISSIONS",
|
|
85241
86221
|
"CLAUDE_CODE_MESSAGING_SOCKET",
|
|
85242
86222
|
"CLAUDE_CODE_MESSAGING_TOKEN",
|
|
85243
86223
|
"CLAUDE_CODE_PROJECT_DIR_NAME",
|
|
85244
86224
|
"CLAUDE_CODE_REMOTE",
|
|
85245
86225
|
"CLAUDE_CODE_RESTRICTED",
|
|
86226
|
+
"CLAUDE_CODE_STRICT_INLINE_SHELL_RM_PROMPT",
|
|
85246
86227
|
"CLAUDE_CODE_WARN_DISK_FREE_GIB",
|
|
85247
86228
|
"CLAUDE_CODE_WARN_MEMORY_FREE_GIB"
|
|
85248
86229
|
]);
|
|
@@ -85254,6 +86235,13 @@ const CLAUDECODE_ENV_IGNORED_IN_EVERY_FILE = /* @__PURE__ */ new Set([
|
|
|
85254
86235
|
* dialog, and whether it processes attachments or expands `@` file mentions,
|
|
85255
86236
|
* and the screen reader (`CLAUDE_AX_*`) variables. Claude Code drops them there, so they are skipped at project scope and emitted only under `--global`.
|
|
85256
86237
|
*
|
|
86238
|
+
* `OTEL_RESOURCE_INCLUDE_HOST` (Claude Code v2.1.326+) adds the machine's name
|
|
86239
|
+
* and ID to telemetry, so it sits with the telemetry group. The reference lists
|
|
86240
|
+
* `CLAUDE_CODE_EXPERIMENTAL_CODE_MODE` separately: Code Mode follows it only
|
|
86241
|
+
* from the shell, user settings or a `--settings` file, and a project `0` does
|
|
86242
|
+
* not keep Code Mode off either, so any project value is skipped while user
|
|
86243
|
+
* settings (`--global`) still honor it.
|
|
86244
|
+
*
|
|
85257
86245
|
* Only the names the settings reference lists are covered; its directory,
|
|
85258
86246
|
* Windows and sign-in groups are introduced with "such as", so an unlisted member of those
|
|
85259
86247
|
* families is still written. Windows variable names are case-insensitive, so
|
|
@@ -85272,6 +86260,7 @@ const CLAUDECODE_ENV_PROJECT_IGNORED_NAMES = /* @__PURE__ */ new Set([
|
|
|
85272
86260
|
"CLAUDE_CODE_DISABLE_FILE_MENTIONS",
|
|
85273
86261
|
"CLAUDE_CODE_ENABLE_TELEMETRY",
|
|
85274
86262
|
"CLAUDE_CODE_ENHANCED_TELEMETRY_BETA",
|
|
86263
|
+
"CLAUDE_CODE_EXPERIMENTAL_CODE_MODE",
|
|
85275
86264
|
"CLAUDE_CODE_OAUTH_REFRESH_TOKEN",
|
|
85276
86265
|
"CLAUDE_CODE_OAUTH_SCOPES",
|
|
85277
86266
|
"CLAUDE_CODE_OAUTH_TOKEN",
|
|
@@ -85290,6 +86279,7 @@ const CLAUDECODE_ENV_PROJECT_IGNORED_NAMES = /* @__PURE__ */ new Set([
|
|
|
85290
86279
|
"OTEL_EXPORTER_PROMETHEUS_PORT",
|
|
85291
86280
|
"OTEL_LOG_ASSISTANT_RESPONSES",
|
|
85292
86281
|
"OTEL_LOG_RAW_API_BODIES",
|
|
86282
|
+
"OTEL_RESOURCE_INCLUDE_HOST",
|
|
85293
86283
|
"TEMP",
|
|
85294
86284
|
"TMP",
|
|
85295
86285
|
"TMPDIR"
|
|
@@ -90486,9 +91476,9 @@ function createSafeCommandShadowTest(permission) {
|
|
|
90486
91476
|
});
|
|
90487
91477
|
const withSeparator = (spellings) => spellings.flatMap((spelling) => [spelling, `${spelling} --*`]);
|
|
90488
91478
|
const wrapped = (base) => CRUSH_COMMAND_PREFIXES.map((prefix) => `${prefix}*${base}`);
|
|
90489
|
-
return (line) => uniq$
|
|
91479
|
+
return (line) => uniq$12([...withSeparator([line, ...wrapped(line)]).flatMap((spelling) => test(spelling)), ...withSeparator([line.toLowerCase(), ...wrapped(line.toLowerCase())]).flatMap((spelling) => testNormalized(spelling).map((pattern) => originalOf.get(pattern) ?? pattern))]);
|
|
90490
91480
|
}
|
|
90491
|
-
function uniq$
|
|
91481
|
+
function uniq$12(values) {
|
|
90492
91482
|
return [...new Set(values)];
|
|
90493
91483
|
}
|
|
90494
91484
|
function stringList(value) {
|
|
@@ -90623,8 +91613,8 @@ var CrushPermissions = class CrushPermissions extends ToolPermissions {
|
|
|
90623
91613
|
});
|
|
90624
91614
|
const preservedAllowed = (isStringArray(existingPermissions?.["allowed_tools"]) ? existingPermissions[CRUSH_ALLOWED_TOOLS_KEY] : []).filter((entry) => entry.includes(":") || !managedToolNames.has(entry));
|
|
90625
91615
|
const preservedDisabled = (isStringArray(existingOptions?.["disabled_tools"]) ? existingOptions[CRUSH_DISABLED_TOOLS_KEY] : []).filter((entry) => !managedToolNames.has(entry));
|
|
90626
|
-
const allowedList = uniq$
|
|
90627
|
-
const disabledList = uniq$
|
|
91616
|
+
const allowedList = uniq$12([...preservedAllowed, ...generated.allowed]);
|
|
91617
|
+
const disabledList = uniq$12([...preservedDisabled, ...generated.disabled]);
|
|
90628
91618
|
const permissionsHasContent = allowedList.length > 0 || commands.safe.length > 0 || commands.blocked.length > 0;
|
|
90629
91619
|
const patch = {};
|
|
90630
91620
|
if (permissionsHasContent || existingPermissions !== void 0) patch[CRUSH_PERMISSIONS_KEY] = {
|
|
@@ -90678,7 +91668,7 @@ function rebuildCrushCommandLists({ config, existingPermissions, logger }) {
|
|
|
90678
91668
|
shadowTest,
|
|
90679
91669
|
logger
|
|
90680
91670
|
});
|
|
90681
|
-
const safe = uniq$
|
|
91671
|
+
const safe = uniq$12([...preserveSafeCommands({
|
|
90682
91672
|
existing: stringList(existingPermissions?.[CRUSH_SAFE_COMMANDS_KEY]),
|
|
90683
91673
|
bashRules,
|
|
90684
91674
|
shadowTest,
|
|
@@ -90700,7 +91690,7 @@ function rebuildCrushCommandLists({ config, existingPermissions, logger }) {
|
|
|
90700
91690
|
}
|
|
90701
91691
|
return {
|
|
90702
91692
|
safe,
|
|
90703
|
-
blocked: uniq$
|
|
91693
|
+
blocked: uniq$12([...existingBlocked, ...blocked])
|
|
90704
91694
|
};
|
|
90705
91695
|
}
|
|
90706
91696
|
/**
|
|
@@ -90815,8 +91805,8 @@ function convertRulesyncToCrushLists({ config, logger }) {
|
|
|
90815
91805
|
else if (catchAllAction === "deny") lists.disabled.push(toolName);
|
|
90816
91806
|
}
|
|
90817
91807
|
return {
|
|
90818
|
-
allowed: uniq$
|
|
90819
|
-
disabled: uniq$
|
|
91808
|
+
allowed: uniq$12(lists.allowed),
|
|
91809
|
+
disabled: uniq$12(lists.disabled)
|
|
90820
91810
|
};
|
|
90821
91811
|
}
|
|
90822
91812
|
/**
|
|
@@ -90875,8 +91865,8 @@ function convertBashCommandRules({ bashRules, shadowTest, logger }) {
|
|
|
90875
91865
|
lists.blocked.push(name);
|
|
90876
91866
|
}
|
|
90877
91867
|
return {
|
|
90878
|
-
safe: uniq$
|
|
90879
|
-
blocked: uniq$
|
|
91868
|
+
safe: uniq$12(lists.safe),
|
|
91869
|
+
blocked: uniq$12(lists.blocked)
|
|
90880
91870
|
};
|
|
90881
91871
|
}
|
|
90882
91872
|
/**
|
|
@@ -92801,6 +93791,263 @@ function convertFactorydroidToRulesyncPermissions({ allow, deny }) {
|
|
|
92801
93791
|
for (const pattern of deny) bash[pattern] = "deny";
|
|
92802
93792
|
return { permission: Object.keys(bash).length > 0 ? { bash } : {} };
|
|
92803
93793
|
}
|
|
93794
|
+
// src/features/permissions/gitlabduo-permissions.ts
|
|
93795
|
+
const GITLABDUO_GLOBAL_ONLY_MESSAGE = "GitLab Duo CLI reads the permissions setting only from the user settings file; use --global to sync ~/.gitlab/duo/settings.json";
|
|
93796
|
+
const TOOL_LABEL = "GitLab Duo CLI";
|
|
93797
|
+
const PERMISSIONS_KEY = "permissions";
|
|
93798
|
+
/** The Duo tool that runs a shell command; the only one rulesync writes statements for. */
|
|
93799
|
+
const COMMAND_TOOL_NAME = "run_command";
|
|
93800
|
+
/** The server refuses a pattern longer than this (`MAX_PATTERN_LENGTH`). */
|
|
93801
|
+
const MAX_PATTERN_LENGTH = 256;
|
|
93802
|
+
/**
|
|
93803
|
+
* Characters a written pattern must not hold:
|
|
93804
|
+
* - `; & | < > $ \` ( ) { }` and line breaks are shell metacharacters the
|
|
93805
|
+
* server refuses in a command-tool pattern.
|
|
93806
|
+
* - Quotes and the backslash are taken off by the shell-style word split the
|
|
93807
|
+
* server reads a pattern through, so the pattern would be matched as
|
|
93808
|
+
* something other than what it says.
|
|
93809
|
+
* - `[` and `]` start an `fnmatch` character class inside a token, which the
|
|
93810
|
+
* canonical glob does not read the same way.
|
|
93811
|
+
*/
|
|
93812
|
+
const UNSUPPORTED_PATTERN_CHARACTERS = /[;&|<>$`(){}\n\r'"\\[\]]/;
|
|
93813
|
+
/** Quotes and the backslash escape, which a shell-style word split takes off. */
|
|
93814
|
+
const SHELL_QUOTING_CHARACTERS = /['"\\]/g;
|
|
93815
|
+
/** A canonical pattern may spell "any arguments" as a trailing `:*` (`git:*`). */
|
|
93816
|
+
const TRAILING_ARGUMENT_WILDCARD = /:\*$/;
|
|
93817
|
+
/** Glob characters that make a Duo pattern match more than its literal spelling. */
|
|
93818
|
+
const GLOB_CHARACTERS = /[*?[\]]/;
|
|
93819
|
+
/**
|
|
93820
|
+
* Permissions adapter for GitLab Duo CLI.
|
|
93821
|
+
*
|
|
93822
|
+
* Duo CLI 10.5.0 reads a `permissions` array of
|
|
93823
|
+
* `{ action, resource, effect }` statements from the managed settings file and
|
|
93824
|
+
* the user's `~/.gitlab/duo/settings.json`. The project files
|
|
93825
|
+
* (`.gitlab/duo/settings.json`, `.gitlab/duo/settings.local.json`) are
|
|
93826
|
+
* deliberately not read for it, so this surface is **global only**.
|
|
93827
|
+
* @see https://gitlab.com/gitlab-org/editor-extensions/gitlab-lsp/-/blob/v10.5.0/packages/core/settings/src/definitions.ts
|
|
93828
|
+
* @see https://gitlab.com/gitlab-org/editor-extensions/gitlab-lsp/-/blob/v10.5.0/packages/core/settings/src/tool_permissions.ts
|
|
93829
|
+
*
|
|
93830
|
+
* Only `allow` is enforced: each allow statement is submitted to the GitLab
|
|
93831
|
+
* instance as a session pattern approval when a session starts. `ask` and
|
|
93832
|
+
* `deny` statements are accepted but only logged. rulesync therefore writes
|
|
93833
|
+
* allow statements only, and never one that could auto-approve something the
|
|
93834
|
+
* canonical file restricts:
|
|
93835
|
+
*
|
|
93836
|
+
* - Only canonical `bash` `allow` rules are written, as
|
|
93837
|
+
* `{ action: "run_command", resource: <pattern>, effect: "allow" }`. Other
|
|
93838
|
+
* categories have no Duo spelling that is known to match no wider than the
|
|
93839
|
+
* canonical rule (the server matches other tools' patterns against their raw
|
|
93840
|
+
* JSON arguments), so their allow rules are skipped with a warning.
|
|
93841
|
+
* - Every `deny` and `ask` rule under `bash` or the all-tools `*` category
|
|
93842
|
+
* withholds the allow rules that could match the same command, because Duo
|
|
93843
|
+
* cannot enforce the restriction itself. A deny is also reported: the command
|
|
93844
|
+
* is asked about, not blocked.
|
|
93845
|
+
* - The GitLab server matches a command-tool pattern token by token
|
|
93846
|
+
* (`CommandPatternMatcher`): a literal token must match exactly, `*` is one
|
|
93847
|
+
* token that does not start with `-`, and a token holding a glob is matched
|
|
93848
|
+
* on its own. That is never wider than the canonical glob, where `*` spans
|
|
93849
|
+
* any characters. A trailing `:*` is written as ` *`. A pattern the server
|
|
93850
|
+
* refuses (a lone `*`, `**`, shell metacharacters, more than 256 characters)
|
|
93851
|
+
* or would read differently (quotes, escapes, character classes) is skipped
|
|
93852
|
+
* with a warning.
|
|
93853
|
+
* @see https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/app/models/ai/duo_workflows/command_pattern_matcher.rb
|
|
93854
|
+
*
|
|
93855
|
+
* On generate, the statements rulesync owns — those for `run_command` — are
|
|
93856
|
+
* replaced, and every other statement and key of the file is kept, with the
|
|
93857
|
+
* comments outside the `permissions` array (the array is rewritten whole).
|
|
93858
|
+
* On import, `run_command` statements come back under `bash`. An allow is
|
|
93859
|
+
* skipped when its resource holds a glob, which the canonical glob would read
|
|
93860
|
+
* more widely than Duo does, or when the server would refuse it, since it
|
|
93861
|
+
* approves nothing in Duo but would approve the command for other tools.
|
|
93862
|
+
*/
|
|
93863
|
+
var GitlabduoPermissions = class GitlabduoPermissions extends ToolPermissions {
|
|
93864
|
+
constructor(params) {
|
|
93865
|
+
super({
|
|
93866
|
+
...params,
|
|
93867
|
+
fileContent: params.fileContent ?? "{}"
|
|
93868
|
+
});
|
|
93869
|
+
}
|
|
93870
|
+
/**
|
|
93871
|
+
* `settings.json` holds every Duo CLI setting, so rulesync never brings it
|
|
93872
|
+
* into existence just to hold nothing.
|
|
93873
|
+
*/
|
|
93874
|
+
shouldSkipCreationWhenPayloadEmpty() {
|
|
93875
|
+
return true;
|
|
93876
|
+
}
|
|
93877
|
+
static getSettablePaths(_options = {}) {
|
|
93878
|
+
return {
|
|
93879
|
+
relativeDirPath: GITLABDUO_DIR,
|
|
93880
|
+
relativeFilePath: GITLABDUO_SETTINGS_FILE_NAME
|
|
93881
|
+
};
|
|
93882
|
+
}
|
|
93883
|
+
static async fromFile({ outputRoot = process.cwd(), validate = true, global = false }) {
|
|
93884
|
+
if (!global) throw new Error(GITLABDUO_GLOBAL_ONLY_MESSAGE);
|
|
93885
|
+
const paths = GitlabduoPermissions.getSettablePaths({ global });
|
|
93886
|
+
const fileContent = await readFileContentOrNull((0, node_path.join)(outputRoot, paths.relativeDirPath, paths.relativeFilePath)) ?? "{}";
|
|
93887
|
+
return new GitlabduoPermissions({
|
|
93888
|
+
outputRoot,
|
|
93889
|
+
relativeDirPath: paths.relativeDirPath,
|
|
93890
|
+
relativeFilePath: paths.relativeFilePath,
|
|
93891
|
+
fileContent,
|
|
93892
|
+
validate,
|
|
93893
|
+
global: true
|
|
93894
|
+
});
|
|
93895
|
+
}
|
|
93896
|
+
static async fromRulesyncPermissions({ outputRoot = process.cwd(), rulesyncPermissions, logger, global = false }) {
|
|
93897
|
+
if (!global) throw new Error(GITLABDUO_GLOBAL_ONLY_MESSAGE);
|
|
93898
|
+
const paths = GitlabduoPermissions.getSettablePaths({ global });
|
|
93899
|
+
const filePath = (0, node_path.join)(outputRoot, paths.relativeDirPath, paths.relativeFilePath);
|
|
93900
|
+
const existingContent = await readFileContentOrNull(filePath) ?? "";
|
|
93901
|
+
const baseContent = existingContent.trim() === "" ? "{}" : existingContent;
|
|
93902
|
+
const existing = parseSettings({
|
|
93903
|
+
content: baseContent,
|
|
93904
|
+
filePath
|
|
93905
|
+
})[PERMISSIONS_KEY];
|
|
93906
|
+
const generated = convertRulesyncToGitlabduoStatements({
|
|
93907
|
+
config: rulesyncPermissions.getJson(),
|
|
93908
|
+
logger
|
|
93909
|
+
});
|
|
93910
|
+
let fileContent = baseContent;
|
|
93911
|
+
if (existing !== void 0 && !Array.isArray(existing)) warnWithFallback(logger, `${TOOL_LABEL}: '${PERMISSIONS_KEY}' in ${filePath} is not an array, so it was left untouched rather than overwritten, and no rule was written.`);
|
|
93912
|
+
else {
|
|
93913
|
+
const statements = [...(existing ?? []).filter((statement) => !(isPlainObject(statement) && statement.action === COMMAND_TOOL_NAME)), ...generated];
|
|
93914
|
+
if (statements.length > 0 || existing !== void 0) {
|
|
93915
|
+
const edits = (0, jsonc_parser.modify)(baseContent, [PERMISSIONS_KEY], statements.length > 0 ? statements : void 0, { formattingOptions: {
|
|
93916
|
+
insertSpaces: true,
|
|
93917
|
+
tabSize: 2
|
|
93918
|
+
} });
|
|
93919
|
+
fileContent = (0, jsonc_parser.applyEdits)(baseContent, edits);
|
|
93920
|
+
}
|
|
93921
|
+
}
|
|
93922
|
+
return new GitlabduoPermissions({
|
|
93923
|
+
outputRoot,
|
|
93924
|
+
relativeDirPath: paths.relativeDirPath,
|
|
93925
|
+
relativeFilePath: paths.relativeFilePath,
|
|
93926
|
+
fileContent,
|
|
93927
|
+
validate: true,
|
|
93928
|
+
global: true
|
|
93929
|
+
});
|
|
93930
|
+
}
|
|
93931
|
+
toRulesyncPermissions() {
|
|
93932
|
+
const selfPath = (0, node_path.join)(this.getRelativeDirPath(), this.getRelativeFilePath());
|
|
93933
|
+
const raw = parseSettings({
|
|
93934
|
+
content: this.getFileContent() || "{}",
|
|
93935
|
+
filePath: selfPath
|
|
93936
|
+
})[PERMISSIONS_KEY];
|
|
93937
|
+
const statements = Array.isArray(raw) ? raw : [];
|
|
93938
|
+
if (raw !== void 0 && !Array.isArray(raw)) warnWithFallback(void 0, `${TOOL_LABEL} ignores '${PERMISSIONS_KEY}' unless it is an array, so nothing was imported from ${selfPath}.`);
|
|
93939
|
+
const bash = {};
|
|
93940
|
+
const skippedAllows = [];
|
|
93941
|
+
for (const statement of statements) {
|
|
93942
|
+
if (!isDuoPermissionStatement(statement) || statement.action !== COMMAND_TOOL_NAME) continue;
|
|
93943
|
+
const { resource, effect } = statement;
|
|
93944
|
+
if (effect === "allow" && (GLOB_CHARACTERS.test(resource) || toGitlabduoCommandResource(resource) !== resource)) {
|
|
93945
|
+
skippedAllows.push(resource);
|
|
93946
|
+
continue;
|
|
93947
|
+
}
|
|
93948
|
+
const previous = bash[resource];
|
|
93949
|
+
if (previous === void 0 || rank(effect) > rank(previous)) bash[resource] = effect;
|
|
93950
|
+
}
|
|
93951
|
+
if (skippedAllows.length > 0) warnWithFallback(void 0, `The run_command allow statement(s) for ${(0, es_toolkit.uniq)(skippedAllows).join(", ")} in ${selfPath} were not imported: a glob matches more as a canonical pattern than in ${TOOL_LABEL} (where '*' is one argument that is not a flag), and a pattern the GitLab server refuses approves nothing in Duo but would for other tools.`);
|
|
93952
|
+
const config = { permission: Object.keys(bash).length > 0 ? { [SHELL_PERMISSION_CATEGORY]: bash } : {} };
|
|
93953
|
+
return RulesyncPermissions.fromImportedFileContent({
|
|
93954
|
+
outputRoot: this.outputRoot,
|
|
93955
|
+
sourcePath: this.getRelativePathFromCwd(),
|
|
93956
|
+
fileContent: JSON.stringify(config, null, 2)
|
|
93957
|
+
});
|
|
93958
|
+
}
|
|
93959
|
+
};
|
|
93960
|
+
function rank(effect) {
|
|
93961
|
+
return effect === "deny" ? 2 : effect === "ask" ? 1 : 0;
|
|
93962
|
+
}
|
|
93963
|
+
function isDuoPermissionStatement(value) {
|
|
93964
|
+
return isPlainObject(value) && typeof value.action === "string" && value.action.length > 0 && typeof value.resource === "string" && (value.effect === "allow" || value.effect === "ask" || value.effect === "deny");
|
|
93965
|
+
}
|
|
93966
|
+
function parseSettings({ content, filePath }) {
|
|
93967
|
+
let parsed;
|
|
93968
|
+
try {
|
|
93969
|
+
parsed = parseJsonc$6(content);
|
|
93970
|
+
} catch (error) {
|
|
93971
|
+
throw new Error(`Failed to parse GitLab Duo CLI settings at ${filePath}: ${formatError(error)}`, { cause: error });
|
|
93972
|
+
}
|
|
93973
|
+
if (!isPlainObject(parsed)) throw new Error(`GitLab Duo CLI settings at ${filePath} must contain a JSON object.`);
|
|
93974
|
+
return parsed;
|
|
93975
|
+
}
|
|
93976
|
+
/**
|
|
93977
|
+
* A canonical command pattern as Duo's token matcher reads it: trimmed, runs
|
|
93978
|
+
* of whitespace collapsed to one space (Duo splits a command into words, so
|
|
93979
|
+
* `git push` and `git push` are one command), and a trailing `:*` ("any
|
|
93980
|
+
* arguments") spelled ` *`.
|
|
93981
|
+
*/
|
|
93982
|
+
function normalizeGitlabduoCommandPattern(pattern) {
|
|
93983
|
+
let normalized = pattern.trim();
|
|
93984
|
+
if (TRAILING_ARGUMENT_WILDCARD.test(normalized)) normalized = `${normalized.slice(0, -2)} *`;
|
|
93985
|
+
return normalized.trim().split(/\s+/).join(" ");
|
|
93986
|
+
}
|
|
93987
|
+
/**
|
|
93988
|
+
* The Duo `resource` for a canonical `bash` allow pattern, or `null` when the
|
|
93989
|
+
* server would refuse it or read it differently from what it says. The result
|
|
93990
|
+
* never matches a command the canonical pattern does not match.
|
|
93991
|
+
*/
|
|
93992
|
+
function toGitlabduoCommandResource(pattern) {
|
|
93993
|
+
const resource = normalizeGitlabduoCommandPattern(pattern);
|
|
93994
|
+
if (resource === "" || resource === "*" || resource.length > MAX_PATTERN_LENGTH) return null;
|
|
93995
|
+
if (UNSUPPORTED_PATTERN_CHARACTERS.test(resource)) return null;
|
|
93996
|
+
if (resource.includes("**")) return null;
|
|
93997
|
+
return resource;
|
|
93998
|
+
}
|
|
93999
|
+
/**
|
|
94000
|
+
* Convert the canonical config into the `run_command` allow statements Duo CLI
|
|
94001
|
+
* enforces, reporting every rule that could not be carried.
|
|
94002
|
+
*/
|
|
94003
|
+
function convertRulesyncToGitlabduoStatements({ config, logger }) {
|
|
94004
|
+
const { rules, foreignRestrictingCategories, ignoredAllToolsAllowPatterns } = collectShellCommandRules(config.permission);
|
|
94005
|
+
const restrictions = (0, es_toolkit.uniq)(rules.filter(({ action }) => action !== "allow").flatMap(({ pattern }) => [
|
|
94006
|
+
pattern,
|
|
94007
|
+
normalizeGitlabduoCommandPattern(pattern),
|
|
94008
|
+
normalizeGitlabduoCommandPattern(pattern.replaceAll(SHELL_QUOTING_CHARACTERS, ""))
|
|
94009
|
+
]).filter((pattern) => pattern !== "")).map((pattern) => ({
|
|
94010
|
+
pattern,
|
|
94011
|
+
fromAllToolsCategory: false
|
|
94012
|
+
}));
|
|
94013
|
+
const budget = createIntersectionBudget();
|
|
94014
|
+
const shadowingRestrictions = createShadowingRestrictionsTest(restrictions, { budget });
|
|
94015
|
+
const resources = [];
|
|
94016
|
+
const shadowedAllowPatterns = [];
|
|
94017
|
+
const unsupportedPatterns = [];
|
|
94018
|
+
for (const { pattern, action } of rules) {
|
|
94019
|
+
if (action !== "allow") continue;
|
|
94020
|
+
const resource = toGitlabduoCommandResource(pattern);
|
|
94021
|
+
if (resource === null) {
|
|
94022
|
+
unsupportedPatterns.push(pattern);
|
|
94023
|
+
continue;
|
|
94024
|
+
}
|
|
94025
|
+
if (shadowingRestrictions(resource).length > 0) {
|
|
94026
|
+
shadowedAllowPatterns.push(pattern);
|
|
94027
|
+
continue;
|
|
94028
|
+
}
|
|
94029
|
+
resources.push(resource);
|
|
94030
|
+
}
|
|
94031
|
+
warnAboutUnwrittenCommandRules({
|
|
94032
|
+
toolLabel: TOOL_LABEL,
|
|
94033
|
+
surfaceLabel: `${PERMISSIONS_KEY} statements for ${COMMAND_TOOL_NAME}`,
|
|
94034
|
+
foreignRestrictingCategories,
|
|
94035
|
+
shadowedAllowPatterns: (0, es_toolkit.uniq)(shadowedAllowPatterns),
|
|
94036
|
+
ignoredAllToolsAllowPatterns,
|
|
94037
|
+
intersectionBudgetExhausted: budget.remaining === 0,
|
|
94038
|
+
logger
|
|
94039
|
+
});
|
|
94040
|
+
const denyPatterns = (0, es_toolkit.uniq)(rules.filter(({ action }) => action === "deny").map(({ pattern }) => pattern));
|
|
94041
|
+
if (denyPatterns.length > 0) warnWithFallback(logger, `${TOOL_LABEL} enforces only allow statements in '${PERMISSIONS_KEY}' (ask and deny are logged and ignored), so the deny rule(s) for ${denyPatterns.join(", ")} were not written. Those commands are asked about rather than blocked.`);
|
|
94042
|
+
const foreignAllowCategories = Object.entries(config.permission).filter(([category, categoryRules]) => category !== "bash" && category !== "*" && Object.values(categoryRules).includes("allow")).map(([category]) => category);
|
|
94043
|
+
if (foreignAllowCategories.length > 0) warnWithFallback(logger, `${TOOL_LABEL}: only 'bash' allow rules are written (as ${COMMAND_TOOL_NAME} statements), so the allow rules of '${foreignAllowCategories.join("', '")}' were skipped.`);
|
|
94044
|
+
if (unsupportedPatterns.length > 0) warnWithFallback(logger, `${TOOL_LABEL} refuses a ${COMMAND_TOOL_NAME} pattern that is a lone '*', holds '**' or a shell metacharacter, or is longer than ${MAX_PATTERN_LENGTH} characters, and reads quotes, escapes and '[...]' differently from the canonical glob, so the allow rule(s) for ${(0, es_toolkit.uniq)(unsupportedPatterns).join(", ")} were skipped.`);
|
|
94045
|
+
return (0, es_toolkit.uniq)(resources).map((resource) => ({
|
|
94046
|
+
action: COMMAND_TOOL_NAME,
|
|
94047
|
+
resource,
|
|
94048
|
+
effect: "allow"
|
|
94049
|
+
}));
|
|
94050
|
+
}
|
|
92804
94051
|
// src/features/permissions/goose-permissions.ts
|
|
92805
94052
|
const GOOSE_GLOBAL_ONLY_MESSAGE = "Goose permissions are global-only; use --global to sync ~/.config/goose/permission.yaml";
|
|
92806
94053
|
const GOOSE_USER_KEY = "user";
|
|
@@ -105119,6 +106366,13 @@ const toolPermissionsFactories = /* @__PURE__ */ new Map([
|
|
|
105119
106366
|
supportsGlobal: true
|
|
105120
106367
|
}
|
|
105121
106368
|
}],
|
|
106369
|
+
["gitlabduo", {
|
|
106370
|
+
class: GitlabduoPermissions,
|
|
106371
|
+
meta: {
|
|
106372
|
+
supportsProject: false,
|
|
106373
|
+
supportsGlobal: true
|
|
106374
|
+
}
|
|
106375
|
+
}],
|
|
105122
106376
|
["goose", {
|
|
105123
106377
|
class: GoosePermissions,
|
|
105124
106378
|
meta: {
|
|
@@ -105902,6 +107156,11 @@ async function ensureAntigravityPluginManifests({ outputRoots, dryRun, logger })
|
|
|
105902
107156
|
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)}.`);
|
|
105903
107157
|
noteName(name, filePath);
|
|
105904
107158
|
const content = addTrailingNewline(JSON.stringify({ name }, null, 2));
|
|
107159
|
+
await warnIfWriteFollowsLink({
|
|
107160
|
+
logger,
|
|
107161
|
+
rootPath: outputRoot,
|
|
107162
|
+
targetPath: filePath
|
|
107163
|
+
});
|
|
105905
107164
|
if (dryRun) logger.info(`[DRY RUN] Would write: ${stripControlCharacters(filePath)}`);
|
|
105906
107165
|
else await writeFileContent(filePath, content);
|
|
105907
107166
|
paths.push(ANTIGRAVITY_PLUGIN_MANIFEST_FILE_NAME);
|
|
@@ -105950,7 +107209,7 @@ function mergeEnabledPlugins({ existingContent, filePath, pluginNames }) {
|
|
|
105950
107209
|
}
|
|
105951
107210
|
});
|
|
105952
107211
|
}
|
|
105953
|
-
async function writeActivationFile({ filePath, relativePath, expectedContent, dryRun, logger }) {
|
|
107212
|
+
async function writeActivationFile({ rootPath, filePath, relativePath, expectedContent, dryRun, logger }) {
|
|
105954
107213
|
const existingContent = await readFileContentOrNull(filePath);
|
|
105955
107214
|
const normalizedExpected = addTrailingNewline(expectedContent);
|
|
105956
107215
|
if (fileContentsEquivalent({
|
|
@@ -105958,6 +107217,11 @@ async function writeActivationFile({ filePath, relativePath, expectedContent, dr
|
|
|
105958
107217
|
expected: normalizedExpected,
|
|
105959
107218
|
existing: existingContent
|
|
105960
107219
|
})) return false;
|
|
107220
|
+
await warnIfWriteFollowsLink({
|
|
107221
|
+
logger,
|
|
107222
|
+
rootPath,
|
|
107223
|
+
targetPath: filePath
|
|
107224
|
+
});
|
|
105961
107225
|
if (dryRun) logger.info(`[DRY RUN] Would write: ${filePath}`);
|
|
105962
107226
|
else await writeFileContent(filePath, normalizedExpected);
|
|
105963
107227
|
logger.debug(`Hermes project-plugin activation requires ${relativePath}`);
|
|
@@ -105994,6 +107258,7 @@ async function activateHermesProjectPlugins({ pluginNames, dryRun, logger }) {
|
|
|
105994
107258
|
const paths = [];
|
|
105995
107259
|
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.`);
|
|
105996
107260
|
if (await writeActivationFile({
|
|
107261
|
+
rootPath: configRoot,
|
|
105997
107262
|
filePath: configPath,
|
|
105998
107263
|
relativePath: relativeConfigPath,
|
|
105999
107264
|
expectedContent: expectedConfig,
|