agentsmesh 0.8.0 → 0.9.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/CHANGELOG.md +43 -0
- package/README.md +190 -107
- package/dist/canonical.js +56 -14
- package/dist/canonical.js.map +1 -1
- package/dist/cli.js +117 -117
- package/dist/engine.d.ts +1 -1
- package/dist/engine.js +68 -28
- package/dist/engine.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +69 -28
- package/dist/index.js.map +1 -1
- package/dist/{target-descriptor-Cb9PXaxr.d.ts → target-descriptor-CkH4Z43u.d.ts} +2 -1
- package/dist/targets.d.ts +21 -3
- package/dist/targets.js +43 -13
- package/dist/targets.js.map +1 -1
- package/package.json +2 -2
|
@@ -122,6 +122,7 @@ type ImportFeatureKind = 'rules' | 'commands' | 'agents' | 'skills' | 'mcp' | 'h
|
|
|
122
122
|
* `mcp.json`.
|
|
123
123
|
*/
|
|
124
124
|
type ImportFeatureMode = 'singleFile' | 'directory' | 'flatFile' | 'mcpJson';
|
|
125
|
+
type ContentNormalizer = (content: string, sourceFile: string, destinationFile: string) => string;
|
|
125
126
|
interface ImportEntryContext {
|
|
126
127
|
readonly absolutePath: string;
|
|
127
128
|
readonly relativePath: string;
|
|
@@ -344,4 +345,4 @@ interface TargetDescriptor {
|
|
|
344
345
|
readonly preservesManualActivation?: boolean;
|
|
345
346
|
}
|
|
346
347
|
|
|
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 };
|
|
348
|
+
export type { ContentNormalizer as C, 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,5 +1,5 @@
|
|
|
1
|
-
import { e as TargetDescriptor } from './target-descriptor-
|
|
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,
|
|
1
|
+
import { e as TargetDescriptor, h as TargetLayoutScope, C as ContentNormalizer, d as ImportResult } from './target-descriptor-CkH4Z43u.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, i as TargetLintHooks, j as TargetManagedOutputs, k as TargetOutputFamily, l as TargetPathResolvers } from './target-descriptor-CkH4Z43u.js';
|
|
3
3
|
import './schema-BeGiBqbB.js';
|
|
4
4
|
import 'zod';
|
|
5
5
|
|
|
@@ -9,10 +9,28 @@ declare function registerTargetDescriptor(descriptor: TargetDescriptor): void;
|
|
|
9
9
|
declare function getDescriptor(name: string): TargetDescriptor | undefined;
|
|
10
10
|
declare function getAllDescriptors(): TargetDescriptor[];
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Descriptor-driven importer runner.
|
|
14
|
+
*
|
|
15
|
+
* Walks `descriptor.importer` for each feature in canonical order, resolves
|
|
16
|
+
* scope-specific source paths, and dispatches to the existing helpers
|
|
17
|
+
* (`importFileDirectory`, MCP / ignore writers). Scope variance lives entirely
|
|
18
|
+
* in the spec — features with no source for the current scope are skipped
|
|
19
|
+
* silently, eliminating per-importer `if (scope === 'global')` branches.
|
|
20
|
+
*
|
|
21
|
+
* Targets with bespoke parsing (codex-cli rule splitter, windsurf workflows,
|
|
22
|
+
* gemini-cli policies) keep `generators.importFrom`. They may still call this
|
|
23
|
+
* runner for the declarable parts of their flow.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
declare function runDescriptorImport(descriptor: TargetDescriptor, projectRoot: string, scope: TargetLayoutScope, options?: {
|
|
27
|
+
readonly normalize?: ContentNormalizer;
|
|
28
|
+
}): Promise<ImportResult[]>;
|
|
29
|
+
|
|
12
30
|
/**
|
|
13
31
|
* Public API — built-in target catalog and plugin registration (package.json "exports"."./targets").
|
|
14
32
|
*/
|
|
15
33
|
|
|
16
34
|
declare function getTargetCatalog(): readonly TargetDescriptor[];
|
|
17
35
|
|
|
18
|
-
export { TargetDescriptor, getAllDescriptors, getDescriptor, getTargetCatalog, registerTargetDescriptor };
|
|
36
|
+
export { TargetDescriptor, TargetLayoutScope, getAllDescriptors, getDescriptor, getTargetCatalog, registerTargetDescriptor, runDescriptorImport };
|
package/dist/targets.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { readFile, readdir, stat, mkdir, lstat, writeFile, rename, rm, realpath, access } from 'fs/promises';
|
|
3
|
-
import {
|
|
2
|
+
import { readFile, readdir, stat, mkdir, lstat, unlink, writeFile, rename, rm, realpath, access } from 'fs/promises';
|
|
3
|
+
import { normalize, join, basename, relative, dirname, extname, win32, isAbsolute, posix } from 'path';
|
|
4
4
|
import { existsSync, realpathSync, constants, statSync } from 'fs';
|
|
5
5
|
import { stringify, parse } from 'yaml';
|
|
6
6
|
import { parse as parse$1 } from 'smol-toml';
|
|
@@ -364,6 +364,11 @@ async function writeFileAtomic(path, content) {
|
|
|
364
364
|
{ errnoCode: "EISDIR" }
|
|
365
365
|
);
|
|
366
366
|
}
|
|
367
|
+
if (info.isSymbolicLink()) {
|
|
368
|
+
await unlink(path).catch((e) => {
|
|
369
|
+
if (e.code !== "ENOENT") throw e;
|
|
370
|
+
});
|
|
371
|
+
}
|
|
367
372
|
} catch (err) {
|
|
368
373
|
if (err instanceof FileSystemError) throw err;
|
|
369
374
|
const e = err;
|
|
@@ -372,7 +377,15 @@ async function writeFileAtomic(path, content) {
|
|
|
372
377
|
const tmpPath = `${path}.tmp`;
|
|
373
378
|
const payload = shouldNormalizeLineEndings(path) ? normalizeLineEndings(content) : content;
|
|
374
379
|
try {
|
|
375
|
-
|
|
380
|
+
try {
|
|
381
|
+
const tmpInfo = await lstat(tmpPath);
|
|
382
|
+
if (tmpInfo.isSymbolicLink()) {
|
|
383
|
+
await unlink(tmpPath);
|
|
384
|
+
}
|
|
385
|
+
} catch (tmpErr) {
|
|
386
|
+
if (tmpErr.code !== "ENOENT") throw tmpErr;
|
|
387
|
+
}
|
|
388
|
+
await writeFile(tmpPath, payload, { encoding: "utf-8", flag: "w" });
|
|
376
389
|
await rename(tmpPath, path);
|
|
377
390
|
} catch (err) {
|
|
378
391
|
await rm(tmpPath, { force: true }).catch(() => {
|
|
@@ -2010,18 +2023,24 @@ async function runDirectory(spec, sources, projectRoot, fromTool, normalize) {
|
|
|
2010
2023
|
}
|
|
2011
2024
|
return results;
|
|
2012
2025
|
}
|
|
2026
|
+
function resolveCanonicalFilePath(spec) {
|
|
2027
|
+
const filename = spec.canonicalFilename;
|
|
2028
|
+
if (filename.includes("/") || filename.includes("\\")) return filename;
|
|
2029
|
+
return posix.join(spec.canonicalDir, filename);
|
|
2030
|
+
}
|
|
2013
2031
|
async function runFlatFile(spec, sources, projectRoot, fromTool) {
|
|
2014
2032
|
if (!spec.canonicalFilename) {
|
|
2015
2033
|
throw new Error(`flatFile spec for ${spec.feature} must set canonicalFilename`);
|
|
2016
2034
|
}
|
|
2035
|
+
const canonicalPath = resolveCanonicalFilePath(spec);
|
|
2017
2036
|
for (const rel2 of sources) {
|
|
2018
2037
|
const srcPath = join(projectRoot, rel2);
|
|
2019
2038
|
const content = await readFileSafe(srcPath);
|
|
2020
2039
|
if (content === null) continue;
|
|
2021
|
-
const destPath = join(projectRoot,
|
|
2040
|
+
const destPath = join(projectRoot, canonicalPath);
|
|
2022
2041
|
await mkdirp(dirname(destPath));
|
|
2023
2042
|
await writeFileAtomic(destPath, content.trimEnd());
|
|
2024
|
-
return [{ fromTool, fromPath: srcPath, toPath:
|
|
2043
|
+
return [{ fromTool, fromPath: srcPath, toPath: canonicalPath, feature: spec.feature }];
|
|
2025
2044
|
}
|
|
2026
2045
|
return [];
|
|
2027
2046
|
}
|
|
@@ -2066,24 +2085,21 @@ async function runMcpJson(spec, sources, projectRoot, fromTool) {
|
|
|
2066
2085
|
if (!spec.canonicalFilename) {
|
|
2067
2086
|
throw new Error(`mcpJson spec for ${spec.feature} must set canonicalFilename`);
|
|
2068
2087
|
}
|
|
2088
|
+
const canonicalPath = resolveCanonicalFilePath(spec);
|
|
2069
2089
|
for (const rel2 of sources) {
|
|
2070
2090
|
const srcPath = join(projectRoot, rel2);
|
|
2071
2091
|
const content = await readFileSafe(srcPath);
|
|
2072
2092
|
if (content === null) continue;
|
|
2073
2093
|
const servers = parseMcpJson(content);
|
|
2074
2094
|
if (Object.keys(servers).length === 0) return [];
|
|
2075
|
-
const destPath = join(projectRoot,
|
|
2095
|
+
const destPath = join(projectRoot, canonicalPath);
|
|
2076
2096
|
await mkdirp(dirname(destPath));
|
|
2077
2097
|
await writeFileAtomic(destPath, JSON.stringify({ mcpServers: servers }, null, 2));
|
|
2078
|
-
return [{ fromTool, fromPath: srcPath, toPath:
|
|
2098
|
+
return [{ fromTool, fromPath: srcPath, toPath: canonicalPath, feature: spec.feature }];
|
|
2079
2099
|
}
|
|
2080
2100
|
return [];
|
|
2081
2101
|
}
|
|
2082
|
-
|
|
2083
|
-
const primary = resolveScopedSources(spec.source, scope);
|
|
2084
|
-
const fallback = resolveScopedSources(spec.fallbacks, scope);
|
|
2085
|
-
const sources = primary.length > 0 ? primary : fallback;
|
|
2086
|
-
if (sources.length === 0) return [];
|
|
2102
|
+
function dispatchSpec(spec, sources, projectRoot, fromTool, normalize) {
|
|
2087
2103
|
switch (spec.mode) {
|
|
2088
2104
|
case "singleFile":
|
|
2089
2105
|
return runSingleFile(spec, sources, projectRoot, fromTool, normalize);
|
|
@@ -2095,6 +2111,19 @@ async function runSpec(spec, scope, projectRoot, fromTool, normalize) {
|
|
|
2095
2111
|
return runMcpJson(spec, sources, projectRoot, fromTool);
|
|
2096
2112
|
}
|
|
2097
2113
|
}
|
|
2114
|
+
async function runSpec(spec, scope, projectRoot, fromTool, normalize) {
|
|
2115
|
+
const primary = resolveScopedSources(spec.source, scope);
|
|
2116
|
+
const fallback = resolveScopedSources(spec.fallbacks, scope);
|
|
2117
|
+
if (primary.length === 0 && fallback.length === 0) return [];
|
|
2118
|
+
if (primary.length > 0) {
|
|
2119
|
+
const results = await dispatchSpec(spec, primary, projectRoot, fromTool, normalize);
|
|
2120
|
+
if (results.length > 0) return results;
|
|
2121
|
+
}
|
|
2122
|
+
if (fallback.length > 0) {
|
|
2123
|
+
return dispatchSpec(spec, fallback, projectRoot, fromTool, normalize);
|
|
2124
|
+
}
|
|
2125
|
+
return [];
|
|
2126
|
+
}
|
|
2098
2127
|
function specsForFeature(importer, feature) {
|
|
2099
2128
|
const value = importer[feature];
|
|
2100
2129
|
if (!value) return [];
|
|
@@ -11784,6 +11813,7 @@ var init_builtin_targets = __esm({
|
|
|
11784
11813
|
// src/public/targets.ts
|
|
11785
11814
|
init_builtin_targets();
|
|
11786
11815
|
init_registry();
|
|
11816
|
+
init_descriptor_import_runner();
|
|
11787
11817
|
function copyCapabilities(capabilities) {
|
|
11788
11818
|
return Object.freeze({ ...capabilities });
|
|
11789
11819
|
}
|
|
@@ -11835,6 +11865,6 @@ function getTargetCatalog() {
|
|
|
11835
11865
|
return Object.freeze(BUILTIN_TARGETS.map(copyTargetDescriptor));
|
|
11836
11866
|
}
|
|
11837
11867
|
|
|
11838
|
-
export { getAllDescriptors, getDescriptor, getTargetCatalog, registerTargetDescriptor };
|
|
11868
|
+
export { getAllDescriptors, getDescriptor, getTargetCatalog, registerTargetDescriptor, runDescriptorImport };
|
|
11839
11869
|
//# sourceMappingURL=targets.js.map
|
|
11840
11870
|
//# sourceMappingURL=targets.js.map
|