MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / discover

Function discover

packages/plugins/apps/src/pipeline/discover.ts:43–77  ·  view source on GitHub ↗
(files: ReadonlyMap<string, string>)

Source from the content-addressed store, hash-verified

41export const validToolKey = (key: string): boolean => /^[a-z0-9][a-z0-9-]*$/.test(key);
42
43export const discover = (files: ReadonlyMap<string, string>): DiscoverResult | PublishError => {
44 const diagnostics: FileDiagnostic[] = [];
45 const tools: DiscoveredTool[] = [];
46 const skipped: SkippedArtifact[] = [];
47 const seen = new Set<string>();
48
49 for (const [path] of files) {
50 if (path === "executor.json") continue;
51 const tool = toolKeyFromPath(path);
52 if (tool) {
53 const name = tool;
54 if (seen.has(name)) {
55 diagnostics.push({ path, message: `duplicate tool identity: ${name}` });
56 } else {
57 seen.add(name);
58 tools.push({ name, entry: path });
59 }
60 continue;
61 }
62 if (path.startsWith("tools/")) {
63 diagnostics.push({ path, message: "file does not match the expected layout for tools/" });
64 continue;
65 }
66 if (isReservedArtifactPath(path)) skipped.push({ path, reason: "not supported yet" });
67 }
68
69 if (diagnostics.length > 0) {
70 return new PublishError({
71 message: `discover found ${diagnostics.length} problem(s)`,
72 stage: "discover",
73 diagnostics,
74 });
75 }
76 return { tools, skipped };
77};

Callers 2

publish.test.tsFile · 0.90
publishFunction · 0.90

Calls 3

toolKeyFromPathFunction · 0.85
isReservedArtifactPathFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected