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,237 @@
1
+ import { b as CanonicalFiles } from './canonical-types-CZwrJoBX.js';
2
+ import { G as GenerateResult, V as ValidatedConfig, f as TargetLayoutScope, L as LintDiagnostic, b as ImportResult } from './target-descriptor-DjHhww11.js';
3
+ import 'zod';
4
+
5
+ /**
6
+ * Resolve duplicate generated outputs that target the same path.
7
+ * Identical content is deduplicated; conflicting content throws.
8
+ *
9
+ * @param results - Raw generated outputs collected per target/feature
10
+ * @returns Deduplicated results preserving first-seen order
11
+ */
12
+ declare function resolveOutputCollisions(results: GenerateResult[]): GenerateResult[];
13
+
14
+ /**
15
+ * Generate orchestrator: produces target-specific files from canonical sources.
16
+ */
17
+
18
+ interface GenerateContext {
19
+ config: ValidatedConfig;
20
+ canonical: CanonicalFiles;
21
+ projectRoot: string;
22
+ scope?: TargetLayoutScope;
23
+ targetFilter?: string[];
24
+ }
25
+
26
+ /**
27
+ * Generate target files from canonical sources.
28
+ * @param ctx - Config, canonical files, project root, optional target filter
29
+ * @returns GenerateResult[] with status per file
30
+ */
31
+ declare function generate(ctx: GenerateContext): Promise<GenerateResult[]>;
32
+
33
+ /**
34
+ * Typed error taxonomy for agentsmesh programmatic consumers.
35
+ *
36
+ * All public-API errors inherit from AgentsMeshError and carry a stable `code`
37
+ * property. Consumers can branch on `err instanceof AgentsMeshError && err.code === 'AM_...'`
38
+ * without relying on error message strings.
39
+ */
40
+ type AgentsMeshErrorCode = 'AM_CONFIG_NOT_FOUND' | 'AM_CONFIG_INVALID' | 'AM_TARGET_NOT_FOUND' | 'AM_TARGET_UNSUPPORTED' | 'AM_IMPORT_FAILED' | 'AM_GENERATION_FAILED' | 'AM_REMOTE_FETCH_FAILED' | 'AM_LOCK_ACQUISITION_FAILED' | 'AM_LOCK_CONFLICT' | 'AM_FILESYSTEM';
41
+ declare class AgentsMeshError extends Error {
42
+ readonly code: AgentsMeshErrorCode;
43
+ constructor(code: AgentsMeshErrorCode, message: string, options?: {
44
+ cause?: unknown;
45
+ });
46
+ }
47
+ declare class ConfigNotFoundError extends AgentsMeshError {
48
+ readonly path: string;
49
+ constructor(path: string, options?: {
50
+ cause?: unknown;
51
+ message?: string;
52
+ });
53
+ }
54
+ declare class ConfigValidationError extends AgentsMeshError {
55
+ readonly issues: readonly string[];
56
+ constructor(path: string, issues: readonly string[], options?: {
57
+ cause?: unknown;
58
+ });
59
+ }
60
+ declare class TargetNotFoundError extends AgentsMeshError {
61
+ readonly target: string;
62
+ constructor(target: string, options?: {
63
+ cause?: unknown;
64
+ supported?: readonly string[];
65
+ });
66
+ }
67
+ declare class ImportError extends AgentsMeshError {
68
+ readonly target: string;
69
+ constructor(target: string, message: string, options?: {
70
+ cause?: unknown;
71
+ });
72
+ }
73
+ declare class GenerationError extends AgentsMeshError {
74
+ constructor(message: string, options?: {
75
+ cause?: unknown;
76
+ });
77
+ }
78
+ declare class RemoteFetchError extends AgentsMeshError {
79
+ readonly source: string;
80
+ constructor(source: string, message: string, options?: {
81
+ cause?: unknown;
82
+ });
83
+ }
84
+ declare class LockAcquisitionError extends AgentsMeshError {
85
+ readonly lockPath: string;
86
+ readonly holder: string;
87
+ constructor(lockPath: string, holder: string, options?: {
88
+ cause?: unknown;
89
+ });
90
+ }
91
+ declare class FileSystemError extends AgentsMeshError {
92
+ readonly path: string;
93
+ readonly errnoCode?: string;
94
+ constructor(path: string, message: string, options?: {
95
+ cause?: unknown;
96
+ errnoCode?: string;
97
+ });
98
+ }
99
+
100
+ /**
101
+ * Standalone target ID constants.
102
+ *
103
+ * Extracted from builtin-targets.ts to break a circular type dependency:
104
+ * schema.ts → builtin-targets.ts → descriptors → ValidatedConfig → schema.ts
105
+ *
106
+ * When adding a new target, add its ID here AND its descriptor to
107
+ * BUILTIN_TARGETS in builtin-targets.ts. A compile-time assertion
108
+ * in builtin-targets.ts ensures they stay in sync.
109
+ */
110
+ declare const TARGET_IDS: readonly ["claude-code", "cursor", "copilot", "continue", "junie", "kiro", "gemini-cli", "cline", "codex-cli", "windsurf", "antigravity", "roo-code"];
111
+ type BuiltinTargetId = (typeof TARGET_IDS)[number];
112
+
113
+ /**
114
+ * Diff engine: produces unified diffs between generated content and on-disk files.
115
+ */
116
+
117
+ interface DiffEntry {
118
+ path: string;
119
+ patch: string;
120
+ }
121
+ interface DiffSummary {
122
+ new: number;
123
+ updated: number;
124
+ unchanged: number;
125
+ deleted: number;
126
+ }
127
+ interface ComputeDiffResult {
128
+ diffs: DiffEntry[];
129
+ summary: DiffSummary;
130
+ }
131
+ /**
132
+ * Format diff summary for user display.
133
+ * @param summary - Counts from computeDiff
134
+ * @returns Human-readable string
135
+ */
136
+ declare function formatDiffSummary(summary: DiffSummary): string;
137
+
138
+ /**
139
+ * Pure lock-vs-current drift detection used by `agentsmesh check` and the
140
+ * public Programmatic API. The CLI command formats and exits; this helper
141
+ * returns a structured report.
142
+ */
143
+
144
+ interface LockSyncReport {
145
+ /** True when the canonical state matches the lock file and no extend drifted. */
146
+ readonly inSync: boolean;
147
+ /** True when a `.lock` file was found at the canonical directory. */
148
+ readonly hasLock: boolean;
149
+ /** Canonical files whose checksum differs from the lock. */
150
+ readonly modified: readonly string[];
151
+ /** Canonical files present now but not in the lock. */
152
+ readonly added: readonly string[];
153
+ /** Canonical files in the lock but missing now. */
154
+ readonly removed: readonly string[];
155
+ /** Extend names whose pinned version/checksum differs from the lock. */
156
+ readonly extendsModified: readonly string[];
157
+ /**
158
+ * Subset of `modified ∪ added ∪ removed` that violates
159
+ * `collaboration.lock_features`. Empty when no `lock_features` are configured.
160
+ */
161
+ readonly lockedViolations: readonly string[];
162
+ }
163
+ interface CheckLockSyncOptions {
164
+ readonly config: ValidatedConfig;
165
+ /** Directory containing `agentsmesh.yaml` (used to resolve relative extends). */
166
+ readonly configDir: string;
167
+ /** Directory containing `.agentsmesh/.lock` and canonical files. */
168
+ readonly canonicalDir: string;
169
+ }
170
+
171
+ declare function importFrom(target: BuiltinTargetId, opts: {
172
+ root: string;
173
+ scope?: 'project' | 'global';
174
+ }): Promise<ImportResult[]>;
175
+ /**
176
+ * Load and validate `agentsmesh.yaml` from a project root, merging
177
+ * `agentsmesh.local.yaml` if present. Searches upward from `projectRoot` for
178
+ * the config file (matches CLI behaviour).
179
+ *
180
+ * Throws `ConfigNotFoundError` when no config is found, or
181
+ * `ConfigValidationError` when YAML parses but fails schema validation.
182
+ */
183
+ declare function loadConfig(projectRoot: string): Promise<{
184
+ config: ValidatedConfig;
185
+ configDir: string;
186
+ }>;
187
+ /**
188
+ * Like {@link loadConfig} but does not search upward — reads
189
+ * `<configDir>/agentsmesh.yaml` directly. Used by global scope where the
190
+ * canonical directory is `~/.agentsmesh/`.
191
+ */
192
+ declare function loadConfigFromDirectory(configDir: string): Promise<{
193
+ config: ValidatedConfig;
194
+ configDir: string;
195
+ }>;
196
+ interface LintOptions {
197
+ readonly config: ValidatedConfig;
198
+ readonly canonical: CanonicalFiles;
199
+ /** Directory used for project-file glob matching (typically the project root). */
200
+ readonly projectRoot: string;
201
+ /** Optional whitelist of target IDs to lint. Defaults to all enabled. */
202
+ readonly targetFilter?: readonly string[];
203
+ /** Defaults to `'project'`. */
204
+ readonly scope?: TargetLayoutScope;
205
+ }
206
+ interface LintResult {
207
+ readonly diagnostics: readonly LintDiagnostic[];
208
+ readonly hasErrors: boolean;
209
+ }
210
+ /**
211
+ * Run lint across all enabled targets and return diagnostics. Pure: no I/O,
212
+ * no logging. Equivalent to `agentsmesh lint` minus formatting and exit code.
213
+ */
214
+ declare function lint(opts: LintOptions): Promise<LintResult>;
215
+ /**
216
+ * Compute unified diffs from a generate-result set. Use this when you already
217
+ * have results in hand (e.g. from {@link import('./engine.js').generate})
218
+ * and want to display drift without re-running generation.
219
+ */
220
+ declare function computeDiff(results: readonly GenerateResult[]): ComputeDiffResult;
221
+ /**
222
+ * Run generation and return the unified diff against on-disk content.
223
+ * Equivalent to `agentsmesh diff` minus formatting. Calls {@link generate}
224
+ * internally; returns both the raw results and the diff.
225
+ */
226
+ declare function diff(ctx: GenerateContext): Promise<ComputeDiffResult & {
227
+ results: readonly GenerateResult[];
228
+ }>;
229
+ /**
230
+ * Compare the lock file at `canonicalDir/.lock` against the current canonical
231
+ * state and resolved extends. Equivalent to `agentsmesh check` minus
232
+ * formatting and exit code. Returns `hasLock: false` and `inSync: false` when
233
+ * no lock is present.
234
+ */
235
+ declare function check(opts: CheckLockSyncOptions): Promise<LockSyncReport>;
236
+
237
+ export { AgentsMeshError, type AgentsMeshErrorCode, CanonicalFiles, type CheckLockSyncOptions, type ComputeDiffResult, ConfigNotFoundError, ConfigValidationError, type DiffEntry, type DiffSummary, FileSystemError, type GenerateContext, GenerateResult, GenerationError, ImportError, ImportResult, LintDiagnostic, type LintOptions, type LintResult, LockAcquisitionError, type LockSyncReport, RemoteFetchError, TargetLayoutScope, TargetNotFoundError, ValidatedConfig, check, computeDiff, diff, formatDiffSummary, generate, importFrom, lint, loadConfig, loadConfigFromDirectory, resolveOutputCollisions };