agentsmesh 0.3.1 → 0.6.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.
@@ -0,0 +1,364 @@
1
+ import { b as CanonicalFiles, c as CanonicalRule } from './canonical-types-CZwrJoBX.js';
2
+ import { z } from 'zod';
3
+
4
+ /** Result of generating files for a target */
5
+ interface GenerateResult {
6
+ /** Target tool ID */
7
+ target: string;
8
+ /** File path (relative to project root) */
9
+ path: string;
10
+ /** File content (what would be written) */
11
+ content: string;
12
+ /** Current on-disk content, set when status is updated or unchanged */
13
+ currentContent?: string;
14
+ /** What happened: created, updated, unchanged, skipped */
15
+ status: 'created' | 'updated' | 'unchanged' | 'skipped';
16
+ /** If skipped, why */
17
+ skipReason?: string;
18
+ }
19
+ /** Result of importing from a tool */
20
+ interface ImportResult {
21
+ /** Source tool */
22
+ fromTool: string;
23
+ /** Source file path */
24
+ fromPath: string;
25
+ /** Destination canonical path */
26
+ toPath: string;
27
+ /** What was imported */
28
+ feature: string;
29
+ }
30
+ /** Lint diagnostic */
31
+ interface LintDiagnostic {
32
+ level: 'error' | 'warning';
33
+ file: string;
34
+ target: string;
35
+ message: string;
36
+ }
37
+ /** Feature support level per target */
38
+ type SupportLevel = 'native' | 'embedded' | 'partial' | 'none';
39
+
40
+ /** Zod schema for agentsmesh.yaml config validation */
41
+ declare const configSchema: z.ZodObject<{
42
+ version: z.ZodLiteral<1>;
43
+ targets: z.ZodDefault<z.ZodArray<z.ZodEnum<{
44
+ "claude-code": "claude-code";
45
+ cursor: "cursor";
46
+ copilot: "copilot";
47
+ continue: "continue";
48
+ junie: "junie";
49
+ kiro: "kiro";
50
+ "gemini-cli": "gemini-cli";
51
+ cline: "cline";
52
+ "codex-cli": "codex-cli";
53
+ windsurf: "windsurf";
54
+ antigravity: "antigravity";
55
+ "roo-code": "roo-code";
56
+ }>>>;
57
+ features: z.ZodDefault<z.ZodArray<z.ZodEnum<{
58
+ rules: "rules";
59
+ commands: "commands";
60
+ agents: "agents";
61
+ skills: "skills";
62
+ mcp: "mcp";
63
+ hooks: "hooks";
64
+ ignore: "ignore";
65
+ permissions: "permissions";
66
+ }>>>;
67
+ extends: z.ZodDefault<z.ZodArray<z.ZodObject<{
68
+ name: z.ZodString;
69
+ source: z.ZodString;
70
+ version: z.ZodOptional<z.ZodString>;
71
+ target: z.ZodOptional<z.ZodEnum<{
72
+ "claude-code": "claude-code";
73
+ cursor: "cursor";
74
+ copilot: "copilot";
75
+ continue: "continue";
76
+ junie: "junie";
77
+ kiro: "kiro";
78
+ "gemini-cli": "gemini-cli";
79
+ cline: "cline";
80
+ "codex-cli": "codex-cli";
81
+ windsurf: "windsurf";
82
+ antigravity: "antigravity";
83
+ "roo-code": "roo-code";
84
+ }>>;
85
+ features: z.ZodArray<z.ZodEnum<{
86
+ rules: "rules";
87
+ commands: "commands";
88
+ agents: "agents";
89
+ skills: "skills";
90
+ mcp: "mcp";
91
+ hooks: "hooks";
92
+ ignore: "ignore";
93
+ permissions: "permissions";
94
+ }>>;
95
+ path: z.ZodOptional<z.ZodString>;
96
+ pick: z.ZodOptional<z.ZodObject<{
97
+ skills: z.ZodOptional<z.ZodArray<z.ZodString>>;
98
+ commands: z.ZodOptional<z.ZodArray<z.ZodString>>;
99
+ rules: z.ZodOptional<z.ZodArray<z.ZodString>>;
100
+ agents: z.ZodOptional<z.ZodArray<z.ZodString>>;
101
+ }, z.core.$strict>>;
102
+ }, z.core.$strip>>>;
103
+ overrides: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
104
+ collaboration: z.ZodDefault<z.ZodObject<{
105
+ strategy: z.ZodDefault<z.ZodEnum<{
106
+ merge: "merge";
107
+ lock: "lock";
108
+ "last-wins": "last-wins";
109
+ }>>;
110
+ lock_features: z.ZodDefault<z.ZodArray<z.ZodString>>;
111
+ }, z.core.$strip>>;
112
+ conversions: z.ZodOptional<z.ZodObject<{
113
+ commands_to_skills: z.ZodOptional<z.ZodObject<{
114
+ 'codex-cli': z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
115
+ project: z.ZodOptional<z.ZodBoolean>;
116
+ global: z.ZodOptional<z.ZodBoolean>;
117
+ }, z.core.$strict>]>>;
118
+ }, z.core.$loose>>;
119
+ agents_to_skills: z.ZodOptional<z.ZodObject<{
120
+ 'gemini-cli': z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
121
+ project: z.ZodOptional<z.ZodBoolean>;
122
+ global: z.ZodOptional<z.ZodBoolean>;
123
+ }, z.core.$strict>]>>;
124
+ cline: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
125
+ project: z.ZodOptional<z.ZodBoolean>;
126
+ global: z.ZodOptional<z.ZodBoolean>;
127
+ }, z.core.$strict>]>>;
128
+ 'codex-cli': z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
129
+ project: z.ZodOptional<z.ZodBoolean>;
130
+ global: z.ZodOptional<z.ZodBoolean>;
131
+ }, z.core.$strict>]>>;
132
+ windsurf: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
133
+ project: z.ZodOptional<z.ZodBoolean>;
134
+ global: z.ZodOptional<z.ZodBoolean>;
135
+ }, z.core.$strict>]>>;
136
+ }, z.core.$loose>>;
137
+ }, z.core.$strict>>;
138
+ plugins: z.ZodDefault<z.ZodArray<z.ZodObject<{
139
+ id: z.ZodString;
140
+ source: z.ZodString;
141
+ version: z.ZodOptional<z.ZodString>;
142
+ }, z.core.$strict>>>;
143
+ pluginTargets: z.ZodDefault<z.ZodArray<z.ZodString>>;
144
+ }, z.core.$strip>;
145
+ type ValidatedConfig = z.infer<typeof configSchema>;
146
+
147
+ /** Serialization / projection variant for a canonical feature (see architecture review §3.3). */
148
+ type FeatureFlavor = 'standard' | 'workflows' | 'settings-embedded' | 'projected-skills' | 'gh-actions-lite' | string;
149
+ /** Normalized capability entry: support level plus optional serialization flavor. */
150
+ interface TargetCapabilityValue {
151
+ readonly level: SupportLevel;
152
+ readonly flavor?: FeatureFlavor;
153
+ }
154
+ /** Descriptor may still use legacy string levels until fully migrated — normalize on read. */
155
+ type TargetCapabilityInput = SupportLevel | TargetCapabilityValue;
156
+
157
+ /**
158
+ * Capabilities of a target tool — each feature has a level and optional serialization flavor.
159
+ * String levels are accepted for authoring; `getTargetCapabilities` normalizes to objects.
160
+ */
161
+ type TargetCapabilities = Record<'rules' | 'additionalRules' | 'commands' | 'agents' | 'skills' | 'mcp' | 'hooks' | 'ignore' | 'permissions', TargetCapabilityInput>;
162
+ /** Optional context passed to feature generators (flavor-aware targets). */
163
+ interface GenerateFeatureContext {
164
+ readonly capability: TargetCapabilityValue;
165
+ readonly scope: TargetLayoutScope;
166
+ }
167
+ type FeatureGeneratorOutput = {
168
+ path: string;
169
+ content: string;
170
+ };
171
+ type FeatureGeneratorFn = (canonical: CanonicalFiles, ctx?: GenerateFeatureContext) => FeatureGeneratorOutput[];
172
+ /**
173
+ * Per-feature generator contract matching engine.ts dispatch tables.
174
+ * Each generator takes CanonicalFiles and returns file outputs.
175
+ * Only generateRules and importFrom are required; all others are optional
176
+ * because not every target supports every feature.
177
+ */
178
+ interface TargetGenerators {
179
+ name: string;
180
+ primaryRootInstructionPath?: string;
181
+ generateRules: FeatureGeneratorFn;
182
+ generateCommands?: FeatureGeneratorFn;
183
+ generateAgents?: FeatureGeneratorFn;
184
+ generateSkills?: FeatureGeneratorFn;
185
+ generateMcp?: FeatureGeneratorFn;
186
+ generatePermissions?: FeatureGeneratorFn;
187
+ generateHooks?: FeatureGeneratorFn;
188
+ generateIgnore?: FeatureGeneratorFn;
189
+ importFrom(projectRoot: string, options?: {
190
+ scope?: TargetLayoutScope;
191
+ }): Promise<ImportResult[]>;
192
+ lint?(files: CanonicalFiles): LintDiagnostic[];
193
+ }
194
+
195
+ /**
196
+ * Self-describing target descriptor interface.
197
+ *
198
+ * A new target exports one TargetDescriptor from its index.ts.
199
+ * The catalog imports it and adds it to BUILTIN_TARGETS — that
200
+ * is the only central registration step.
201
+ *
202
+ * Designed for future plugin support: plugins will export a
203
+ * TargetDescriptor that gets registered at runtime.
204
+ */
205
+
206
+ /** Declared output families for reference rewriting and decoration (architecture P1-3). */
207
+ interface TargetOutputFamily {
208
+ readonly id: string;
209
+ readonly kind: 'primary' | 'mirror' | 'additional';
210
+ /** Match generated paths under this prefix (e.g. Copilot `.github/instructions/`). */
211
+ readonly pathPrefix?: string;
212
+ /** Explicit paths for additional root mirrors (Cursor, Gemini compat). */
213
+ readonly explicitPaths?: readonly string[];
214
+ }
215
+ /**
216
+ * Path resolvers for the output reference map.
217
+ * Each method returns a relative output path, or null to skip.
218
+ *
219
+ * Shared pre-checks (root rule handling, target filtering) remain
220
+ * centralized in map-targets.ts — descriptors only handle the
221
+ * target-specific path logic after those guards pass.
222
+ */
223
+ interface TargetPathResolvers {
224
+ /** Output path for a non-root, non-filtered rule. */
225
+ rulePath(slug: string, rule: CanonicalRule): string;
226
+ /** Output path for a command. Null suppresses generation. */
227
+ commandPath(name: string, config: ValidatedConfig): string | null;
228
+ /** Output path for an agent. Null suppresses generation. */
229
+ agentPath(name: string, config: ValidatedConfig): string | null;
230
+ }
231
+ interface TargetManagedOutputs {
232
+ dirs: readonly string[];
233
+ files: readonly string[];
234
+ }
235
+ interface TargetLayout {
236
+ /** Primary root instruction artifact for this scope, if any. */
237
+ readonly rootInstructionPath?: string;
238
+ /**
239
+ * Extra generated paths that should receive the same AgentsMesh root appendix as
240
+ * `rootInstructionPath` (for example Cursor `AGENTS.md` / `.cursor/AGENTS.md`, Gemini `AGENTS.md`).
241
+ * @deprecated Prefer `outputFamilies` with `kind: 'additional'`.
242
+ */
243
+ readonly additionalRootDecorationPaths?: readonly string[];
244
+ /** Output families for rewrite cache keys and root decoration (see `layout-outputs.ts`). */
245
+ readonly outputFamilies?: readonly TargetOutputFamily[];
246
+ /** Optional renderer for scope-specific primary root instruction content. */
247
+ readonly renderPrimaryRootInstruction?: (canonical: CanonicalFiles) => string;
248
+ /** Target-native skills directory for this scope, if any. */
249
+ readonly skillDir?: string;
250
+ /** Files/directories agentsmesh fully manages for stale cleanup. */
251
+ readonly managedOutputs?: TargetManagedOutputs;
252
+ /** Optional path rewriter for scope-specific generated outputs. Return null to skip emission. */
253
+ readonly rewriteGeneratedPath?: (path: string) => string | null;
254
+ /**
255
+ * Optional mirror hook. Called after rewriteGeneratedPath resolves the primary path.
256
+ * Returns an additional path to emit the same content to, or null to skip mirroring.
257
+ */
258
+ readonly mirrorGlobalPath?: (path: string, activeTargets: readonly string[]) => string | readonly string[] | null;
259
+ /** Path resolvers for this scope. */
260
+ readonly paths: TargetPathResolvers;
261
+ }
262
+ type TargetLayoutScope = 'project' | 'global';
263
+ /** Scope extras hook (e.g. Claude Code global output-styles). */
264
+ type ScopeExtrasFn = (canonical: CanonicalFiles, projectRoot: string, scope: TargetLayoutScope, enabledFeatures: ReadonlySet<string>) => Promise<GenerateResult[]>;
265
+ /** Single block for global-mode support (replaces scattered global* fields). */
266
+ interface GlobalTargetSupport {
267
+ readonly capabilities: TargetCapabilities;
268
+ readonly detectionPaths: readonly string[];
269
+ readonly layout: TargetLayout;
270
+ readonly scopeExtras?: ScopeExtrasFn;
271
+ }
272
+ /** Import-path builder: populates refs with (target path -> canonical path) mappings. */
273
+ type ImportPathBuilder = (refs: Map<string, string>, projectRoot: string, scope?: TargetLayoutScope) => Promise<void>;
274
+ /** Rule linter function signature. */
275
+ type RuleLinter = (canonical: CanonicalFiles, projectRoot: string, projectFiles: string[], options?: {
276
+ scope?: TargetLayoutScope;
277
+ }) => LintDiagnostic[];
278
+ /** Feature-specific lint hook signature. */
279
+ type FeatureLinter = (canonical: CanonicalFiles, options?: unknown) => LintDiagnostic[];
280
+ /** Optional per-feature lint hooks for target-specific validation. */
281
+ interface TargetLintHooks {
282
+ readonly commands?: FeatureLinter;
283
+ readonly mcp?: FeatureLinter;
284
+ readonly permissions?: FeatureLinter;
285
+ readonly hooks?: FeatureLinter;
286
+ readonly ignore?: FeatureLinter;
287
+ readonly settings?: FeatureLinter;
288
+ }
289
+ /**
290
+ * Full self-describing target descriptor.
291
+ * Bundles everything needed to generate, import, lint, and detect a target.
292
+ */
293
+ interface TargetDescriptor {
294
+ /** Unique target identifier, e.g. 'claude-code' */
295
+ readonly id: string;
296
+ /** Feature generators (rules, commands, agents, etc.) */
297
+ readonly generators: TargetGenerators;
298
+ /** Feature support levels */
299
+ readonly capabilities: TargetCapabilities;
300
+ /** Consolidated global-mode metadata (preferred over bare `global*` fields). */
301
+ readonly globalSupport?: GlobalTargetSupport;
302
+ /** Optional global-scope feature support levels when they differ from project mode */
303
+ readonly globalCapabilities?: TargetCapabilities;
304
+ /** Message shown when import finds nothing for this target */
305
+ readonly emptyImportMessage: string;
306
+ /** Optional linter for canonical files */
307
+ readonly lintRules: RuleLinter | null;
308
+ /** Optional per-feature lint hooks */
309
+ readonly lint?: TargetLintHooks;
310
+ /** Project-scope target layout metadata */
311
+ readonly project: TargetLayout;
312
+ /** Optional global-scope layout (use `globalSupport.layout` when `globalSupport` is set). */
313
+ readonly global?: TargetLayout;
314
+ /**
315
+ * Declares which embedded-capability features support user-configured conversion.
316
+ * When the corresponding conversion is disabled in config, the feature generator is skipped.
317
+ */
318
+ readonly supportsConversion?: {
319
+ readonly commands?: true;
320
+ readonly agents?: true;
321
+ };
322
+ /**
323
+ * Optional hook for generating scope-specific extras beyond the standard feature loop.
324
+ * Prefer `globalSupport.scopeExtras` for global-only extras.
325
+ */
326
+ readonly generateScopeExtras?: ScopeExtrasFn;
327
+ /** @deprecated Use project.skillDir */
328
+ readonly skillDir?: string;
329
+ /** @deprecated Use project.paths */
330
+ readonly paths?: TargetPathResolvers;
331
+ /** Import reference map builder */
332
+ readonly buildImportPaths: ImportPathBuilder;
333
+ /** Filesystem paths used to detect this target during `init` */
334
+ readonly detectionPaths: readonly string[];
335
+ /** Optional filesystem paths used to detect this target in global scope during `init --global` */
336
+ readonly globalDetectionPaths?: readonly string[];
337
+ /**
338
+ * Declares which shared artifact paths this target owns or consumes.
339
+ * Used by the reference rewriter to select the correct artifact map for shared outputs.
340
+ * Example: codex-cli owns '.agents/skills/', copilot consumes it in global mode.
341
+ */
342
+ readonly sharedArtifacts?: {
343
+ readonly [pathPrefix: string]: 'owner' | 'consumer';
344
+ };
345
+ /**
346
+ * Optional native settings sidecar (e.g. Gemini `.gemini/settings.json` when embedded features are on).
347
+ */
348
+ readonly emitScopedSettings?: (canonical: CanonicalFiles, scope: TargetLayoutScope) => readonly {
349
+ readonly path: string;
350
+ readonly content: string;
351
+ }[];
352
+ /**
353
+ * Async post-pass for hook generator outputs (e.g. Copilot hook script assets under `.github/hooks/`).
354
+ */
355
+ readonly postProcessHookOutputs?: (projectRoot: string, canonical: CanonicalFiles, outputs: readonly {
356
+ readonly path: string;
357
+ readonly content: string;
358
+ }[]) => Promise<readonly {
359
+ readonly path: string;
360
+ readonly content: string;
361
+ }[]>;
362
+ }
363
+
364
+ export type { FeatureLinter as F, GenerateResult as G, ImportPathBuilder as I, LintDiagnostic as L, RuleLinter as R, ScopeExtrasFn as S, TargetCapabilities as T, ValidatedConfig as V, GlobalTargetSupport as a, ImportResult as b, TargetDescriptor as c, TargetGenerators as d, TargetLayout as e, TargetLayoutScope as f, TargetLintHooks as g, TargetManagedOutputs as h, TargetOutputFamily as i, TargetPathResolvers as j };
@@ -0,0 +1,18 @@
1
+ import { c as TargetDescriptor } from './target-descriptor-DjHhww11.js';
2
+ export { F as FeatureLinter, a as GlobalTargetSupport, I as ImportPathBuilder, R as RuleLinter, S as ScopeExtrasFn, T as TargetCapabilities, d as TargetGenerators, e as TargetLayout, f as TargetLayoutScope, g as TargetLintHooks, h as TargetManagedOutputs, i as TargetOutputFamily, j as TargetPathResolvers } from './target-descriptor-DjHhww11.js';
3
+ import './canonical-types-CZwrJoBX.js';
4
+ import 'zod';
5
+
6
+ /** Register a full target descriptor (for plugins). */
7
+ declare function registerTargetDescriptor(descriptor: TargetDescriptor): void;
8
+ /** Look up a full descriptor by target ID. */
9
+ declare function getDescriptor(name: string): TargetDescriptor | undefined;
10
+ declare function getAllDescriptors(): TargetDescriptor[];
11
+
12
+ /**
13
+ * Public API — built-in target catalog and plugin registration (package.json "exports"."./targets").
14
+ */
15
+
16
+ declare function getTargetCatalog(): readonly TargetDescriptor[];
17
+
18
+ export { TargetDescriptor, getAllDescriptors, getDescriptor, getTargetCatalog, registerTargetDescriptor };