agentsmesh 0.7.0 → 0.8.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.
@@ -1,4 +1,4 @@
1
- import { b as CanonicalFiles, c as CanonicalRule, V as ValidatedConfig } from './schema-B7ZSqkrS.js';
1
+ import { b as CanonicalFiles, c as CanonicalRule, V as ValidatedConfig } from './schema-BeGiBqbB.js';
2
2
 
3
3
  /** Result of generating files for a target */
4
4
  interface GenerateResult {
@@ -84,6 +84,93 @@ interface TargetGenerators {
84
84
  lint?(files: CanonicalFiles): LintDiagnostic[];
85
85
  }
86
86
 
87
+ /**
88
+ * Descriptor-driven importer contract.
89
+ *
90
+ * Each target may declare an `importer: TargetImporterDescriptor` block on its
91
+ * descriptor. The shared runner walks the spec, resolves sources for the active
92
+ * scope, and dispatches to existing helpers (`importFileDirectory`,
93
+ * `importDirectorySkill`, …). Scope variance is expressed as data — features
94
+ * with no `global` source are silently skipped in global mode, eliminating the
95
+ * `if (scope === 'global')` branches that previously leaked into importer bodies.
96
+ *
97
+ * Targets with custom parsing (codex-cli rule splitter, windsurf workflows,
98
+ * gemini-cli policies) keep their own `generators.importFrom` and may also
99
+ * delegate the declarable parts of their flow to the runner.
100
+ */
101
+
102
+ /**
103
+ * Per-scope source paths. Omit `global` to make the feature project-only — the
104
+ * runner skips it under `--global` instead of every importer guarding with
105
+ * `if (scope === 'global')`.
106
+ */
107
+ interface ImportSourcePaths {
108
+ readonly project?: readonly string[];
109
+ readonly global?: readonly string[];
110
+ }
111
+ type ImportFeatureKind = 'rules' | 'commands' | 'agents' | 'skills' | 'mcp' | 'hooks' | 'permissions' | 'ignore';
112
+ /**
113
+ * Mapping modes:
114
+ * - `singleFile` — try each `source` path in order, take the first that
115
+ * exists, write to `${canonicalDir}/${canonicalRootFilename}`.
116
+ * Used for root rule files (`AGENTS.md`, `CLAUDE.md`, …).
117
+ * - `directory` — recurse `source` paths and run a per-entry mapper. Built
118
+ * on top of the existing `importFileDirectory` helper.
119
+ * - `flatFile` — copy a single file verbatim (with `trimEnd`) to a fixed
120
+ * canonical destination. Used for `ignore`.
121
+ * - `mcpJson` — parse a JSON MCP servers file and write canonical
122
+ * `mcp.json`.
123
+ */
124
+ type ImportFeatureMode = 'singleFile' | 'directory' | 'flatFile' | 'mcpJson';
125
+ interface ImportEntryContext {
126
+ readonly absolutePath: string;
127
+ readonly relativePath: string;
128
+ readonly content: string;
129
+ readonly destDir: string;
130
+ readonly normalizeTo: (destinationFile: string) => string;
131
+ }
132
+ interface ImportEntryMapping {
133
+ readonly destPath: string;
134
+ readonly toPath: string;
135
+ readonly content: string;
136
+ }
137
+ type ImportEntryMapper = (ctx: ImportEntryContext) => Promise<ImportEntryMapping | null> | ImportEntryMapping | null;
138
+ /** Optional declarative frontmatter post-processing for the default mappers. */
139
+ type FrontmatterRemap = (frontmatter: Record<string, unknown>) => Record<string, unknown>;
140
+ interface ImportFeatureSpec {
141
+ readonly feature: ImportFeatureKind;
142
+ readonly mode: ImportFeatureMode;
143
+ readonly source: ImportSourcePaths;
144
+ /** Tried after `source` in the same scope when the primary chain finds nothing (singleFile only). */
145
+ readonly fallbacks?: ImportSourcePaths;
146
+ /** Canonical destination directory under the project root (e.g. `.agentsmesh/rules`). */
147
+ readonly canonicalDir: string;
148
+ /** For `singleFile` only: the destination filename inside `canonicalDir`. */
149
+ readonly canonicalRootFilename?: string;
150
+ /** For `directory` mode: file extensions to match (`['.md']`, `['.mdc']`, …). */
151
+ readonly extensions?: readonly string[];
152
+ /** For `directory` mode: pick a built-in mapper. */
153
+ readonly preset?: 'rule' | 'command' | 'agent';
154
+ /** Optional frontmatter post-processing applied by built-in mappers. */
155
+ readonly frontmatterRemap?: FrontmatterRemap;
156
+ /** Custom mapper. Wins over `preset` when both are set. */
157
+ readonly map?: ImportEntryMapper;
158
+ /** For `singleFile` rules: marks the imported entry as a root rule (`root: true`). */
159
+ readonly markAsRoot?: boolean;
160
+ /** For `flatFile` and `mcpJson`: canonical destination filename. */
161
+ readonly canonicalFilename?: string;
162
+ }
163
+ interface TargetImporterDescriptor {
164
+ readonly rules?: ImportFeatureSpec | readonly ImportFeatureSpec[];
165
+ readonly commands?: ImportFeatureSpec;
166
+ readonly agents?: ImportFeatureSpec;
167
+ readonly skills?: ImportFeatureSpec;
168
+ readonly mcp?: ImportFeatureSpec;
169
+ readonly hooks?: ImportFeatureSpec;
170
+ readonly permissions?: ImportFeatureSpec;
171
+ readonly ignore?: ImportFeatureSpec;
172
+ }
173
+
87
174
  /**
88
175
  * Self-describing target descriptor interface.
89
176
  *
@@ -209,6 +296,15 @@ interface TargetDescriptor {
209
296
  readonly commands?: true;
210
297
  readonly agents?: true;
211
298
  };
299
+ /**
300
+ * Optional descriptor-driven importer block. When present, the shared
301
+ * `runDescriptorImport` orchestrator handles scan + map for each declared
302
+ * feature (with scope variance expressed as data, eliminating
303
+ * `if (scope === 'global')` branches in importer bodies). Targets with
304
+ * irreducibly custom parsing keep `generators.importFrom` and may delegate
305
+ * declarable parts of their flow to the runner.
306
+ */
307
+ readonly importer?: TargetImporterDescriptor;
212
308
  /** Import reference map builder */
213
309
  readonly buildImportPaths: ImportPathBuilder;
214
310
  /** Filesystem paths used to detect this target during `init` */
@@ -240,6 +336,12 @@ interface TargetDescriptor {
240
336
  readonly path: string;
241
337
  readonly content: string;
242
338
  }[]>;
339
+ /**
340
+ * When true, the target preserves manual-only activation semantics (e.g.
341
+ * Cursor's `alwaysApply: false` without globs/description). Targets without
342
+ * this flag get a lint warning when canonical rules have `trigger: 'manual'`.
343
+ */
344
+ readonly preservesManualActivation?: boolean;
243
345
  }
244
346
 
245
347
  export type { ExtraRuleOutputContext as E, FeatureLinter as F, GenerateResult as G, ImportPathBuilder as I, LintDiagnostic as L, RuleLinter as R, ScopeExtrasFn as S, TargetCapabilities as T, ExtraRuleOutputResolver as a, GeneratedOutputMerger as b, GlobalTargetSupport as c, ImportResult as d, TargetDescriptor as e, TargetGenerators as f, TargetLayout as g, TargetLayoutScope as h, TargetLintHooks as i, TargetManagedOutputs as j, TargetOutputFamily as k, TargetPathResolvers as l };
package/dist/targets.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { e as TargetDescriptor } from './target-descriptor-COp3nil6.js';
2
- export { E as ExtraRuleOutputContext, a as ExtraRuleOutputResolver, F as FeatureLinter, b as GeneratedOutputMerger, c as GlobalTargetSupport, I as ImportPathBuilder, R as RuleLinter, S as ScopeExtrasFn, T as TargetCapabilities, f as TargetGenerators, g as TargetLayout, h as TargetLayoutScope, i as TargetLintHooks, j as TargetManagedOutputs, k as TargetOutputFamily, l as TargetPathResolvers } from './target-descriptor-COp3nil6.js';
3
- import './schema-B7ZSqkrS.js';
1
+ import { e as TargetDescriptor } from './target-descriptor-Cb9PXaxr.js';
2
+ export { E as ExtraRuleOutputContext, a as ExtraRuleOutputResolver, F as FeatureLinter, b as GeneratedOutputMerger, c as GlobalTargetSupport, I as ImportPathBuilder, R as RuleLinter, S as ScopeExtrasFn, T as TargetCapabilities, f as TargetGenerators, g as TargetLayout, h as TargetLayoutScope, i as TargetLintHooks, j as TargetManagedOutputs, k as TargetOutputFamily, l as TargetPathResolvers } from './target-descriptor-Cb9PXaxr.js';
3
+ import './schema-BeGiBqbB.js';
4
4
  import 'zod';
5
5
 
6
6
  /** Register a full target descriptor (for plugins). */