agentsmesh 0.28.0 → 0.30.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/dist/engine.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { V as ValidatedConfig, b as CanonicalFiles } from './schema-CzaoYJlG.js';
2
- import { G as GenerateResult, h as TargetLayoutScope, L as LintDiagnostic, d as ImportResult } from './target-descriptor-ItDY3NR0.js';
1
+ import { V as ValidatedConfig, b as CanonicalFiles } from './schema-CH_JJep8.js';
2
+ import { G as GenerateResult, h as TargetLayoutScope, L as LintDiagnostic, d as ImportResult } from './target-descriptor-CaLUz7SR.js';
3
3
  import 'zod';
4
4
 
5
5
  /**
package/dist/engine.js CHANGED
@@ -2940,6 +2940,18 @@ var init_linter = __esm({
2940
2940
  }
2941
2941
  });
2942
2942
 
2943
+ // src/core/hook-types.ts
2944
+ var BEST_EFFORT_HOOK_EVENTS;
2945
+ var init_hook_types = __esm({
2946
+ "src/core/hook-types.ts"() {
2947
+ BEST_EFFORT_HOOK_EVENTS = /* @__PURE__ */ new Set([
2948
+ "UserPromptSubmit",
2949
+ "PostToolUseFailure",
2950
+ "SessionStart"
2951
+ ]);
2952
+ }
2953
+ });
2954
+
2943
2955
  // src/core/lint/shared/helpers.ts
2944
2956
  function createWarning(file, target31, message) {
2945
2957
  return {
@@ -2955,6 +2967,13 @@ function formatOxfordComma(items) {
2955
2967
  if (items.length === 2) return `${items[0]} and ${items[1]}`;
2956
2968
  return `${items.slice(0, -1).join(", ")}, and ${items[items.length - 1]}`;
2957
2969
  }
2970
+ function unsupportedHookEventNames(hooks, supportedEvents) {
2971
+ if (!hooks) return [];
2972
+ const supported = new Set(supportedEvents);
2973
+ return Object.keys(hooks).filter(
2974
+ (event) => !supported.has(event) && !BEST_EFFORT_HOOK_EVENTS.has(event)
2975
+ );
2976
+ }
2958
2977
  function createUnsupportedHookWarning(event, target31, supportedEvents, options) {
2959
2978
  const by = options?.unsupportedBy ?? target31;
2960
2979
  const supported = formatOxfordComma(supportedEvents);
@@ -2966,6 +2985,7 @@ function createUnsupportedHookWarning(event, target31, supportedEvents, options)
2966
2985
  }
2967
2986
  var init_helpers = __esm({
2968
2987
  "src/core/lint/shared/helpers.ts"() {
2988
+ init_hook_types();
2969
2989
  }
2970
2990
  });
2971
2991
 
@@ -6309,8 +6329,7 @@ var init_linter5 = __esm({
6309
6329
  // src/targets/augment-code/lint.ts
6310
6330
  function lintHooks3(canonical) {
6311
6331
  if (!canonical.hooks || Object.keys(canonical.hooks).length === 0) return [];
6312
- const supportedSet = new Set(SUPPORTED_HOOK_EVENTS);
6313
- return Object.keys(canonical.hooks).filter((event) => !supportedSet.has(event)).map(
6332
+ return unsupportedHookEventNames(canonical.hooks, SUPPORTED_HOOK_EVENTS).map(
6314
6333
  (event) => createUnsupportedHookWarning(event, "augment-code", SUPPORTED_HOOK_EVENTS, {
6315
6334
  unsupportedBy: "AugmentCode hooks"
6316
6335
  })
@@ -10315,8 +10334,7 @@ function lintCommands3(canonical) {
10315
10334
  function lintHooks5(canonical) {
10316
10335
  if (!canonical.hooks || Object.keys(canonical.hooks).length === 0) return [];
10317
10336
  const supported = ["PreToolUse", "PostToolUse", "Notification", "UserPromptSubmit"];
10318
- const supportedSet = new Set(supported);
10319
- const diagnostics = Object.keys(canonical.hooks).filter((event) => !supportedSet.has(event)).map(
10337
+ const diagnostics = unsupportedHookEventNames(canonical.hooks, supported).map(
10320
10338
  (event) => createUnsupportedHookWarning(event, "copilot", supported, {
10321
10339
  unsupportedBy: "Copilot hooks"
10322
10340
  })
@@ -11434,7 +11452,7 @@ var init_permissions2 = __esm({
11434
11452
  // src/targets/cursor/hook-format.ts
11435
11453
  function unmappedCursorHookEvents(hooks) {
11436
11454
  return Object.keys(hooks).filter(
11437
- (event) => Array.isArray(hooks[event]) && hooks[event].length > 0 && !(event in CANONICAL_TO_CURSOR)
11455
+ (event) => Array.isArray(hooks[event]) && hooks[event].length > 0 && !(event in CANONICAL_TO_CURSOR) && !BEST_EFFORT_HOOK_EVENTS.has(event)
11438
11456
  );
11439
11457
  }
11440
11458
  function toCursorHooks(hooks) {
@@ -11482,6 +11500,7 @@ function cursorHooksToCanonical(hooks) {
11482
11500
  var CANONICAL_TO_CURSOR, CURSOR_TO_CANONICAL;
11483
11501
  var init_hook_format = __esm({
11484
11502
  "src/targets/cursor/hook-format.ts"() {
11503
+ init_hook_types();
11485
11504
  init_hook_command();
11486
11505
  CANONICAL_TO_CURSOR = {
11487
11506
  PreToolUse: "preToolUse",
@@ -13932,8 +13951,9 @@ function lintCommands6(canonical) {
13932
13951
  function lintHooks7(canonical) {
13933
13952
  if (!canonical.hooks || Object.keys(canonical.hooks).length === 0) return [];
13934
13953
  const supported = ["PreToolUse", "PostToolUse", "Notification"];
13935
- const supportedSet = new Set(supported);
13936
- return Object.keys(canonical.hooks).filter((event) => !supportedSet.has(event)).map((event) => createUnsupportedHookWarning(event, "gemini-cli", supported));
13954
+ return unsupportedHookEventNames(canonical.hooks, supported).map(
13955
+ (event) => createUnsupportedHookWarning(event, "gemini-cli", supported)
13956
+ );
13937
13957
  }
13938
13958
  var init_lint14 = __esm({
13939
13959
  "src/targets/gemini-cli/lint.ts"() {
@@ -16185,8 +16205,7 @@ var init_linter20 = __esm({
16185
16205
  function lintHooks10(canonical) {
16186
16206
  if (!canonical.hooks || Object.keys(canonical.hooks).length === 0) return [];
16187
16207
  const supported = ["PreToolUse", "PostToolUse", "UserPromptSubmit", "SubagentStop"];
16188
- const supportedSet = new Set(supported);
16189
- return Object.keys(canonical.hooks).filter((event) => !supportedSet.has(event)).map(
16208
+ return unsupportedHookEventNames(canonical.hooks, supported).map(
16190
16209
  (event) => createUnsupportedHookWarning(event, "kiro", supported, { unsupportedBy: "Kiro hooks" })
16191
16210
  );
16192
16211
  }
@@ -21593,7 +21612,14 @@ var extendSourceSchema = z.object({
21593
21612
  features: z.array(featureSchema),
21594
21613
  /** Repo-relative POSIX path for discovery (skill packs, nested .agentsmesh). */
21595
21614
  path: z.string().optional(),
21596
- pick: extendPickSchema.optional()
21615
+ pick: extendPickSchema.optional(),
21616
+ /**
21617
+ * Per-entry consent for "elevated" artifacts (`hooks`, `permissions`, `mcp`)
21618
+ * from a remote source. These control local code execution at generate time,
21619
+ * so for non-local extends they are stripped by default and only merged for
21620
+ * the artifacts listed here. Local extends are trusted and ignore this field.
21621
+ */
21622
+ accept: z.array(z.enum(["hooks", "permissions", "mcp"])).optional()
21597
21623
  });
21598
21624
  var collaborationSchema = z.object({
21599
21625
  strategy: z.enum(["merge", "lock", "last-wins"]).default("merge"),
@@ -22302,7 +22328,9 @@ async function resolveExtendPaths(config, configDir, options = {}) {
22302
22328
  as: ext.as,
22303
22329
  version: fetched.version,
22304
22330
  path: ext.path,
22305
- pick: ext.pick
22331
+ pick: ext.pick,
22332
+ isRemote: true,
22333
+ accept: ext.accept
22306
22334
  });
22307
22335
  continue;
22308
22336
  }
@@ -22319,7 +22347,9 @@ async function resolveExtendPaths(config, configDir, options = {}) {
22319
22347
  target: ext.target,
22320
22348
  as: ext.as,
22321
22349
  path: ext.path,
22322
- pick: ext.pick
22350
+ pick: ext.pick,
22351
+ isRemote: false,
22352
+ accept: ext.accept
22323
22353
  });
22324
22354
  }
22325
22355
  return result;
@@ -23768,6 +23798,47 @@ function applyExtendPick(canonical, features, pick, extendName) {
23768
23798
  return next;
23769
23799
  }
23770
23800
 
23801
+ // src/install/core/elevated-artifacts.ts
23802
+ function stripUntrustedElevatedArtifacts(canonical, options) {
23803
+ if (options.sourceKind === "local") {
23804
+ return { canonical, stripped: [] };
23805
+ }
23806
+ const stripped = [];
23807
+ let hooks = canonical.hooks;
23808
+ let permissions = canonical.permissions;
23809
+ let mcp = canonical.mcp;
23810
+ if (hooks !== null && !options.acceptHooks) {
23811
+ hooks = null;
23812
+ stripped.push("hooks");
23813
+ }
23814
+ if (permissions !== null && !options.acceptPermissions) {
23815
+ permissions = null;
23816
+ stripped.push("permissions");
23817
+ }
23818
+ if (mcp !== null && !options.acceptMcp) {
23819
+ mcp = null;
23820
+ stripped.push("mcp");
23821
+ }
23822
+ if (stripped.length === 0) {
23823
+ return { canonical, stripped: [] };
23824
+ }
23825
+ return {
23826
+ canonical: { ...canonical, hooks, permissions, mcp },
23827
+ stripped
23828
+ };
23829
+ }
23830
+
23831
+ // src/canonical/extends/extend-elevated.ts
23832
+ function gateExtendElevatedArtifacts(canonical, ext) {
23833
+ const accept = ext.accept ?? [];
23834
+ return stripUntrustedElevatedArtifacts(canonical, {
23835
+ sourceKind: ext.isRemote ? "git" : "local",
23836
+ acceptHooks: accept.includes("hooks"),
23837
+ acceptPermissions: accept.includes("permissions"),
23838
+ acceptMcp: accept.includes("mcp")
23839
+ });
23840
+ }
23841
+
23771
23842
  // src/install/pack/pack-reader.ts
23772
23843
  init_fs();
23773
23844
  var MANUAL_INSTALL_AS = ["rules", "commands", "agents", "skills"];
@@ -23917,7 +23988,14 @@ async function loadCanonicalWithExtends(config, configDir, options = {}, canonic
23917
23988
  for (const ext of resolvedExtends) {
23918
23989
  const extCanonical = await loadCanonicalForExtend(ext);
23919
23990
  const filtered = filterCanonicalByFeatures(extCanonical, ext.features);
23920
- const picked = applyExtendPick(filtered, ext.features, ext.pick, ext.name);
23991
+ const gated = gateExtendElevatedArtifacts(filtered, ext);
23992
+ if (gated.stripped.length > 0) {
23993
+ const list = gated.stripped.join(", ");
23994
+ logger.warn(
23995
+ `[agentsmesh] Extend "${ext.name}": stripped elevated artifacts from a remote source: ${list}. Add \`accept: [${list}]\` to this extends entry in agentsmesh.yaml to keep them.`
23996
+ );
23997
+ }
23998
+ const picked = applyExtendPick(gated.canonical, ext.features, ext.pick, ext.name);
23921
23999
  merged = mergeCanonicalFiles(merged, picked);
23922
24000
  }
23923
24001
  const packsCanonical = await loadPacksCanonical(canonicalDir);
@@ -23953,7 +24031,18 @@ function canonicalize(path) {
23953
24031
  try {
23954
24032
  return realpathSync(path);
23955
24033
  } catch {
23956
- return path;
24034
+ let current = resolve(path);
24035
+ const tail = [];
24036
+ for (; ; ) {
24037
+ const parent = dirname(current);
24038
+ if (parent === current) return resolve(path);
24039
+ tail.unshift(basename(current));
24040
+ try {
24041
+ return join(realpathSync(parent), ...tail);
24042
+ } catch {
24043
+ current = parent;
24044
+ }
24045
+ }
23957
24046
  }
23958
24047
  }
23959
24048
  function assertSourceInsideProjectRoot(resolvedPath, projectRoot) {
@@ -24211,7 +24300,7 @@ function lintRuleScopeInversion(input) {
24211
24300
  }
24212
24301
  return out2;
24213
24302
  }
24214
- var CURRENT_GRAPH_VERSION = 1;
24303
+ var VersionSchema = z.union([z.literal(1), z.literal(2)]);
24215
24304
  var IdSchema = z.string().regex(/^[a-z0-9-]+$/, "id must be kebab-case");
24216
24305
  var DateSchema = z.string().regex(
24217
24306
  /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d{1,3})?Z?)?$/,
@@ -24234,10 +24323,17 @@ var LessonSchema = z.object({
24234
24323
  evidence: z.array(z.string().min(1)),
24235
24324
  status: LessonStatusSchema,
24236
24325
  supersededBy: IdSchema.optional(),
24237
- createdAt: DateSchema
24326
+ createdAt: DateSchema,
24327
+ /**
24328
+ * `'always'` marks an ALWAYS-ON lesson: a universal standard delivered on
24329
+ * every task (via the UserPromptSubmit hook / a `--always` recall) rather than
24330
+ * matched by triggers. Such a lesson needs no trigger and is excluded from
24331
+ * triggered recall. Absent = a normal triggered lesson.
24332
+ */
24333
+ scope: z.literal("always").optional()
24238
24334
  }).strict();
24239
24335
  var LessonsGraphSchema = z.object({
24240
- version: z.literal(CURRENT_GRAPH_VERSION),
24336
+ version: VersionSchema,
24241
24337
  lessons: z.record(IdSchema, LessonSchema),
24242
24338
  topics: z.record(IdSchema, TopicSchema),
24243
24339
  triggers: z.record(IdSchema, TriggerSchema)