@stigmer/cli 3.19.0 → 3.20.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/commands/apply.d.ts.map +1 -1
- package/commands/apply.js +42 -100
- package/commands/apply.js.map +1 -1
- package/commands/validate.js +3 -4
- package/commands/validate.js.map +1 -1
- package/local/bootstrap.d.ts +1 -2
- package/local/bootstrap.d.ts.map +1 -1
- package/local/bootstrap.js +13 -41
- package/local/bootstrap.js.map +1 -1
- package/local/daemon/launch.d.ts +2 -2
- package/local/daemon/launch.d.ts.map +1 -1
- package/local/daemon/launch.js +2 -2
- package/local/daemon/launch.js.map +1 -1
- package/local/plugins/defaults.js +2 -2
- package/local/plugins/defaults.js.map +1 -1
- package/package.json +7 -7
- package/registry/index.d.ts +2 -2
- package/registry/index.d.ts.map +1 -1
- package/registry/index.js +2 -2
- package/registry/index.js.map +1 -1
- package/registry/metadata.d.ts +9 -0
- package/registry/metadata.d.ts.map +1 -1
- package/registry/metadata.js +14 -5
- package/registry/metadata.js.map +1 -1
- package/registry/registry.d.ts +9 -0
- package/registry/registry.d.ts.map +1 -1
- package/registry/registry.js +16 -1
- package/registry/registry.js.map +1 -1
- package/registry/verb-support.d.ts.map +1 -1
- package/registry/verb-support.js +0 -13
- package/registry/verb-support.js.map +1 -1
- package/resources/apply/apply.d.ts +11 -12
- package/resources/apply/apply.d.ts.map +1 -1
- package/resources/apply/apply.js +12 -21
- package/resources/apply/apply.js.map +1 -1
- package/resources/apply/handlers.js +2 -2
- package/resources/apply/handlers.js.map +1 -1
- package/resources/delete.d.ts.map +1 -1
- package/resources/delete.js +0 -1
- package/resources/delete.js.map +1 -1
- package/resources/get-bindings.d.ts.map +1 -1
- package/resources/get-bindings.js +0 -5
- package/resources/get-bindings.js.map +1 -1
- package/resources/list.d.ts.map +1 -1
- package/resources/list.js +0 -1
- package/resources/list.js.map +1 -1
- package/resources/validate.d.ts.map +1 -1
- package/resources/validate.js +0 -2
- package/resources/validate.js.map +1 -1
- package/src/commands/apply.ts +35 -150
- package/src/commands/validate.ts +2 -4
- package/src/local/bootstrap.test.ts +15 -59
- package/src/local/bootstrap.ts +12 -53
- package/src/local/daemon/launch.ts +4 -4
- package/src/local/plugins/defaults.ts +2 -2
- package/src/registry/index.ts +7 -1
- package/src/registry/metadata.ts +15 -5
- package/src/registry/registry.test.ts +1 -7
- package/src/registry/registry.ts +17 -1
- package/src/registry/verb-support.ts +0 -13
- package/src/resources/apply/apply.integration.test.ts +15 -3
- package/src/resources/apply/apply.ts +15 -26
- package/src/resources/apply/handlers.ts +2 -2
- package/src/resources/delete.ts +0 -1
- package/src/resources/get-bindings.ts +0 -5
- package/src/resources/list.ts +0 -1
- package/src/resources/validate.test.ts +0 -1
- package/src/resources/validate.ts +0 -2
- package/local/seedpack-retire.d.ts +0 -63
- package/local/seedpack-retire.d.ts.map +0 -1
- package/local/seedpack-retire.js +0 -361
- package/local/seedpack-retire.js.map +0 -1
- package/resources/apply/declarative.d.ts +0 -106
- package/resources/apply/declarative.d.ts.map +0 -1
- package/resources/apply/declarative.js +0 -397
- package/resources/apply/declarative.js.map +0 -1
- package/resources/apply/synth/project-track.d.ts +0 -21
- package/resources/apply/synth/project-track.d.ts.map +0 -1
- package/resources/apply/synth/project-track.js +0 -102
- package/resources/apply/synth/project-track.js.map +0 -1
- package/resources/apply/synth/reader.d.ts +0 -18
- package/resources/apply/synth/reader.d.ts.map +0 -1
- package/resources/apply/synth/reader.js +0 -55
- package/resources/apply/synth/reader.js.map +0 -1
- package/resources/apply/synth/runtime.d.ts +0 -8
- package/resources/apply/synth/runtime.d.ts.map +0 -1
- package/resources/apply/synth/runtime.js +0 -32
- package/resources/apply/synth/runtime.js.map +0 -1
- package/resources/apply/synth/synthesize.d.ts +0 -43
- package/resources/apply/synth/synthesize.d.ts.map +0 -1
- package/resources/apply/synth/synthesize.js +0 -115
- package/resources/apply/synth/synthesize.js.map +0 -1
- package/src/local/seedpack-retire.test.ts +0 -499
- package/src/local/seedpack-retire.ts +0 -474
- package/src/resources/apply/declarative.integration.test.ts +0 -204
- package/src/resources/apply/declarative.test.ts +0 -132
- package/src/resources/apply/declarative.ts +0 -491
- package/src/resources/apply/synth/capstone.integration.test.ts +0 -134
- package/src/resources/apply/synth/project-track.integration.test.ts +0 -194
- package/src/resources/apply/synth/project-track.ts +0 -126
- package/src/resources/apply/synth/reader.test.ts +0 -90
- package/src/resources/apply/synth/reader.ts +0 -68
- package/src/resources/apply/synth/runtime.test.ts +0 -29
- package/src/resources/apply/synth/runtime.ts +0 -39
- package/src/resources/apply/synth/synthesize.test.ts +0 -109
- package/src/resources/apply/synth/synthesize.ts +0 -161
|
@@ -1,397 +0,0 @@
|
|
|
1
|
-
// Declarative apply (`stigmer apply` inside a stigmer.yaml project directory).
|
|
2
|
-
//
|
|
3
|
-
// The project is a lightweight membership tracker: it stores only references
|
|
4
|
-
// (org/kind/slug) to its members and the server reconciles by set-difference
|
|
5
|
-
// against the previous member list. The CLI's job is to discover the resources
|
|
6
|
-
// that live beside stigmer.yaml, apply each one, collect references to the
|
|
7
|
-
// member-eligible ones, then apply the project with that member set. Pruning of
|
|
8
|
-
// orphans is therefore entirely server-side — see the note on `--prune` in
|
|
9
|
-
// commands/apply.ts (S1).
|
|
10
|
-
//
|
|
11
|
-
// Two project layouts are supported, mirroring the Go CLI:
|
|
12
|
-
// flat: project/agent.yaml, project/my-skill/SKILL.md
|
|
13
|
-
// organized: project/agents/*.yaml, project/skills/my-skill/SKILL.md
|
|
14
|
-
// Scanning is top-level plus one level of subdirectories — deep trees are not
|
|
15
|
-
// walked, matching Go (this keeps membership predictable and fast).
|
|
16
|
-
import { existsSync, mkdtempSync, readdirSync, rmSync, statSync } from "node:fs";
|
|
17
|
-
import { tmpdir } from "node:os";
|
|
18
|
-
import { basename, dirname, extname, join, resolve } from "node:path";
|
|
19
|
-
import { create, fromJson } from "@bufbuild/protobuf";
|
|
20
|
-
import { ApiResourceReferenceSchema, } from "@stigmer/protos/ai/stigmer/commons/apiresource/io_pb";
|
|
21
|
-
import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
|
|
22
|
-
import { ApiResourceMetadataSchema, } from "@stigmer/protos/ai/stigmer/commons/apiresource/metadata_pb";
|
|
23
|
-
import { ProjectSchema } from "@stigmer/protos/ai/stigmer/tenancy/project/v1/api_pb";
|
|
24
|
-
import { ProjectCommandController } from "@stigmer/protos/ai/stigmer/tenancy/project/v1/command_pb";
|
|
25
|
-
import { ProjectSpecSchema } from "@stigmer/protos/ai/stigmer/tenancy/project/v1/spec_pb";
|
|
26
|
-
import { UsageError } from "../../errors/index.js";
|
|
27
|
-
import { CommandResult } from "../../output/index.js";
|
|
28
|
-
import { loadDocuments } from "../documents.js";
|
|
29
|
-
import { cloneRepository } from "../git.js";
|
|
30
|
-
import { hasSkillFile, pushSkill, pushSkillFromClone } from "../skill.js";
|
|
31
|
-
import { applyMessage, marshalItem, resolveHandlerForKind, resourceMetadata, sortApplyItems } from "./apply.js";
|
|
32
|
-
import { discoverAppliedMcpServers } from "./discovery.js";
|
|
33
|
-
const CONFIG_FILE_NAME = "stigmer.yaml";
|
|
34
|
-
const DEFAULT_MAX_DEPTH = 10;
|
|
35
|
-
/**
|
|
36
|
-
* Walk up from `startDir` (max 10 levels, matching Go) looking for stigmer.yaml.
|
|
37
|
-
* Absent → atomic track. Present-but-invalid → a hard error (the user clearly
|
|
38
|
-
* intended a project; help them fix it rather than silently falling back).
|
|
39
|
-
* Present with an entry_point → the SDK "project" track (synthesis), which this
|
|
40
|
-
* wave does not implement.
|
|
41
|
-
*/
|
|
42
|
-
export function detectTrack(startDir, maxDepth = DEFAULT_MAX_DEPTH) {
|
|
43
|
-
let dir = resolve(startDir);
|
|
44
|
-
for (let depth = 0; depth < maxDepth; depth++) {
|
|
45
|
-
const candidate = join(dir, CONFIG_FILE_NAME);
|
|
46
|
-
if (existsSync(candidate) && statSync(candidate).isFile()) {
|
|
47
|
-
const project = loadProject(candidate);
|
|
48
|
-
const track = project.spec?.entryPoint ? "project" : "declarative";
|
|
49
|
-
return { track, configPath: candidate, configDir: dirname(candidate), project };
|
|
50
|
-
}
|
|
51
|
-
const parent = dirname(dir);
|
|
52
|
-
if (parent === dir)
|
|
53
|
-
break;
|
|
54
|
-
dir = parent;
|
|
55
|
-
}
|
|
56
|
-
return { track: "atomic" };
|
|
57
|
-
}
|
|
58
|
-
// Strict parse of stigmer.yaml into a Project (proto carries apiVersion/kind as
|
|
59
|
-
// real fields, so the discriminator is accepted, not rejected). Unknown fields
|
|
60
|
-
// are an error — a typo in stigmer.yaml should fail loudly.
|
|
61
|
-
function loadProject(configPath) {
|
|
62
|
-
const docs = loadDocuments(configPath, { strict: true });
|
|
63
|
-
if (docs.length === 0)
|
|
64
|
-
throw new UsageError(`${configPath} contains no document`);
|
|
65
|
-
const doc = docs[0];
|
|
66
|
-
if (doc.kind !== "Project") {
|
|
67
|
-
throw new UsageError(`${configPath} must declare 'kind: Project' (found '${doc.kind}')`);
|
|
68
|
-
}
|
|
69
|
-
try {
|
|
70
|
-
return fromJson(ProjectSchema, doc.document, { ignoreUnknownFields: false });
|
|
71
|
-
}
|
|
72
|
-
catch (err) {
|
|
73
|
-
throw new UsageError(`invalid project configuration in ${configPath}: ${err.message}\n\n` +
|
|
74
|
-
"Fix the issues above or remove the file to use file mode (stigmer apply -f).");
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
// =============================================================================
|
|
78
|
-
// Directory scanning
|
|
79
|
-
// =============================================================================
|
|
80
|
-
/**
|
|
81
|
-
* YAML resource files beside stigmer.yaml: top-level files plus files in
|
|
82
|
-
* immediate subdirectories. stigmer.yaml itself is excluded, as are skill
|
|
83
|
-
* directories (handled separately) and grouping dirs that hold skills.
|
|
84
|
-
*/
|
|
85
|
-
export function scanResourceFiles(projectDir) {
|
|
86
|
-
const files = [];
|
|
87
|
-
for (const entry of readdirSync(projectDir, { withFileTypes: true })) {
|
|
88
|
-
const full = join(projectDir, entry.name);
|
|
89
|
-
if (entry.isDirectory()) {
|
|
90
|
-
if (isSkillDirectory(full) || containsSkillDirectories(full))
|
|
91
|
-
continue;
|
|
92
|
-
for (const sub of readdirSync(full, { withFileTypes: true })) {
|
|
93
|
-
if (!sub.isDirectory() && isYaml(sub.name))
|
|
94
|
-
files.push(join(full, sub.name));
|
|
95
|
-
}
|
|
96
|
-
continue;
|
|
97
|
-
}
|
|
98
|
-
if (isYaml(entry.name) && entry.name.toLowerCase() !== CONFIG_FILE_NAME) {
|
|
99
|
-
files.push(full);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
return files.sort();
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Skill directories beside stigmer.yaml: immediate children that contain a
|
|
106
|
-
* SKILL.md (flat layout), plus grandchildren under a grouping dir like skills/
|
|
107
|
-
* (organized layout). Scanning stops one level deep, matching Go.
|
|
108
|
-
*/
|
|
109
|
-
export function scanSkillDirectories(projectDir) {
|
|
110
|
-
const skillDirs = [];
|
|
111
|
-
for (const entry of readdirSync(projectDir, { withFileTypes: true })) {
|
|
112
|
-
if (!entry.isDirectory())
|
|
113
|
-
continue;
|
|
114
|
-
const full = join(projectDir, entry.name);
|
|
115
|
-
if (isSkillDirectory(full)) {
|
|
116
|
-
skillDirs.push(full);
|
|
117
|
-
continue;
|
|
118
|
-
}
|
|
119
|
-
for (const sub of readdirSync(full, { withFileTypes: true })) {
|
|
120
|
-
const nested = join(full, sub.name);
|
|
121
|
-
if (sub.isDirectory() && isSkillDirectory(nested))
|
|
122
|
-
skillDirs.push(nested);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
return skillDirs.sort();
|
|
126
|
-
}
|
|
127
|
-
function containsSkillDirectories(dir) {
|
|
128
|
-
try {
|
|
129
|
-
return readdirSync(dir, { withFileTypes: true }).some((e) => e.isDirectory() && isSkillDirectory(join(dir, e.name)));
|
|
130
|
-
}
|
|
131
|
-
catch {
|
|
132
|
-
return false;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
function isSkillDirectory(dir) {
|
|
136
|
-
return hasSkillFile(dir);
|
|
137
|
-
}
|
|
138
|
-
function isYaml(name) {
|
|
139
|
-
const ext = extname(name).toLowerCase();
|
|
140
|
-
return ext === ".yaml" || ext === ".yml";
|
|
141
|
-
}
|
|
142
|
-
// =============================================================================
|
|
143
|
-
// Item building
|
|
144
|
-
// =============================================================================
|
|
145
|
-
/**
|
|
146
|
-
* Build ordered apply items from scanned resource files. Project documents are
|
|
147
|
-
* skipped (stigmer.yaml is already loaded) and Organization documents are
|
|
148
|
-
* skipped with a warning — an organization sits above a project in the resource
|
|
149
|
-
* hierarchy and must be applied independently with file mode.
|
|
150
|
-
*/
|
|
151
|
-
export function buildDeclarativeItems(files, warn) {
|
|
152
|
-
const items = [];
|
|
153
|
-
for (const file of files) {
|
|
154
|
-
for (const doc of loadDocuments(file, { strict: true })) {
|
|
155
|
-
if (doc.kind === "Project")
|
|
156
|
-
continue;
|
|
157
|
-
if (doc.kind === "Organization") {
|
|
158
|
-
warn(`Skipping ${file}: Organization is not a project resource. Use 'stigmer apply -f' to manage organizations.`);
|
|
159
|
-
continue;
|
|
160
|
-
}
|
|
161
|
-
items.push({ filePath: file, handler: resolveHandlerForKind(doc.kind, file), document: doc.document });
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
return sortApplyItems(items);
|
|
165
|
-
}
|
|
166
|
-
// Member-eligible kinds participate in project membership and reconciliation.
|
|
167
|
-
// Mirrors Go's types.IsProjectMemberKind.
|
|
168
|
-
const MEMBER_KINDS = new Set([
|
|
169
|
-
ApiResourceKind.agent,
|
|
170
|
-
ApiResourceKind.workflow,
|
|
171
|
-
ApiResourceKind.mcp_server,
|
|
172
|
-
ApiResourceKind.skill,
|
|
173
|
-
]);
|
|
174
|
-
/**
|
|
175
|
-
* Apply a declarative project: scan the directory for YAML resources and skill
|
|
176
|
-
* directories, marshal each resource, then hand everything to the shared
|
|
177
|
-
* reconciler. This adapter's only job is "filesystem → resources + skill
|
|
178
|
-
* sources"; the synthesis track has its own adapter ("SDK → resources + skill
|
|
179
|
-
* sources") and both converge on {@link reconcileProjectMembers} (DD-009 §6).
|
|
180
|
-
*/
|
|
181
|
-
export async function applyDeclarative(detect, deps) {
|
|
182
|
-
const { project, configDir } = detect;
|
|
183
|
-
if (project === undefined || configDir === undefined) {
|
|
184
|
-
throw new UsageError("declarative apply requires a stigmer.yaml project");
|
|
185
|
-
}
|
|
186
|
-
const resourceFiles = scanResourceFiles(configDir);
|
|
187
|
-
const skillDirs = scanSkillDirectories(configDir);
|
|
188
|
-
if (resourceFiles.length === 0 && skillDirs.length === 0) {
|
|
189
|
-
return buildNoResourcesResult(configDir);
|
|
190
|
-
}
|
|
191
|
-
const items = buildDeclarativeItems(resourceFiles, deps.warn);
|
|
192
|
-
deps.info(`Found ${items.length} resource(s) in ${resourceFiles.length} file(s), ${skillDirs.length} skill(s)`);
|
|
193
|
-
const resources = items.map((item) => ({ handler: item.handler, message: marshalItem(item) }));
|
|
194
|
-
const skillSources = skillDirs.map((dir) => ({ kind: "local", dir, tag: "latest" }));
|
|
195
|
-
return reconcileProjectMembers(project, resources, skillSources, deps);
|
|
196
|
-
}
|
|
197
|
-
// Both tracks treat skill artifacts the same way; the default ignore policy
|
|
198
|
-
// mirrors the declarative push (respect .gitignore, no extra patterns).
|
|
199
|
-
const DEFAULT_IGNORE_OPTIONS = { respectGitignore: true, extraIgnore: [], extraInclude: [] };
|
|
200
|
-
/**
|
|
201
|
-
* Reconcile a project's membership: push skills first (agents may reference
|
|
202
|
-
* them), apply MCP servers and run capability discovery on them, apply the
|
|
203
|
-
* remaining resources, collect references to the member-eligible ones, then
|
|
204
|
-
* apply the project with that exact member set so the server can reconcile by
|
|
205
|
-
* set-difference (orphan pruning is server-side; see S1 in commands/apply.ts).
|
|
206
|
-
*/
|
|
207
|
-
export async function reconcileProjectMembers(project, resources, skillSources, deps) {
|
|
208
|
-
const members = [];
|
|
209
|
-
// Skills first — agents may reference them.
|
|
210
|
-
for (const src of skillSources) {
|
|
211
|
-
const pushed = await pushSkillSource(deps.stigmer, src, deps.org, deps.info);
|
|
212
|
-
members.push(reference(deps.org, ApiResourceKind.skill, pushed.slug));
|
|
213
|
-
}
|
|
214
|
-
// Each resource is applied through the shared apply core, collecting member
|
|
215
|
-
// references from the APPLIED result so membership carries the server's
|
|
216
|
-
// authoritative slug. (This is the unified policy: the declarative track
|
|
217
|
-
// used to read the pre-apply YAML slug, the Go synthesis track read the
|
|
218
|
-
// applied result — converging on the applied result is correct for both and
|
|
219
|
-
// matches what the backend actually stored.)
|
|
220
|
-
const appliedMcpServers = [];
|
|
221
|
-
const applyOne = async (res) => {
|
|
222
|
-
const outcome = await applyMessage(deps.controller, res.handler, res.message, deps.org, false);
|
|
223
|
-
if (outcome.warning !== undefined)
|
|
224
|
-
deps.warn(outcome.warning);
|
|
225
|
-
if (outcome.appliedMcpServer !== undefined)
|
|
226
|
-
appliedMcpServers.push(outcome.appliedMcpServer);
|
|
227
|
-
if (MEMBER_KINDS.has(res.handler.kind) && outcome.applied !== undefined) {
|
|
228
|
-
const slug = memberSlugOf(outcome.applied);
|
|
229
|
-
if (slug)
|
|
230
|
-
members.push(reference(deps.org, res.handler.kind, slug));
|
|
231
|
-
}
|
|
232
|
-
};
|
|
233
|
-
// MCP servers first, then capability discovery, then everything else — the
|
|
234
|
-
// dependency principle applied to capabilities, not just existence. The
|
|
235
|
-
// server validates agent enabled_tools against discovered capabilities at
|
|
236
|
-
// apply time (stigmer/stigmer#402), and the backend's own post-apply
|
|
237
|
-
// connect is asynchronous; discovering here means agents in this apply
|
|
238
|
-
// validate against the toolset this apply just shipped, not the previous
|
|
239
|
-
// generation's (which would falsely reject e.g. a project upgrade that
|
|
240
|
-
// adds a tool to a server and enables it in an agent in the same pass). Discovery stays
|
|
241
|
-
// best-effort: a failed connect warns, capabilities stay stale, and the
|
|
242
|
-
// dependent apply surfaces an actionable error listing last-known tools.
|
|
243
|
-
for (const res of resources) {
|
|
244
|
-
if (res.handler.kind === ApiResourceKind.mcp_server)
|
|
245
|
-
await applyOne(res);
|
|
246
|
-
}
|
|
247
|
-
await discoverAppliedMcpServers(deps.stigmer, appliedMcpServers, deps.org, deps.info);
|
|
248
|
-
for (const res of resources) {
|
|
249
|
-
if (res.handler.kind !== ApiResourceKind.mcp_server)
|
|
250
|
-
await applyOne(res);
|
|
251
|
-
}
|
|
252
|
-
injectOrg(project, deps.org);
|
|
253
|
-
if (project.spec === undefined)
|
|
254
|
-
project.spec = create(ProjectSpecSchema, {});
|
|
255
|
-
project.spec.members = members;
|
|
256
|
-
const created = (project.metadata?.id ?? "") === "";
|
|
257
|
-
const applied = await deps.controller(ProjectCommandController).apply(project);
|
|
258
|
-
return buildDeclarativeResult(applied, members, created);
|
|
259
|
-
}
|
|
260
|
-
/**
|
|
261
|
-
* Push one skill source and return the result. Local sources push directly;
|
|
262
|
-
* git sources clone to a temp dir, push from the subdir, then clean up
|
|
263
|
-
* (mirrors `commands/push.ts` --git-url and Go's `pushSkillSynth`).
|
|
264
|
-
*/
|
|
265
|
-
export async function pushSkillSource(client, src, org, info) {
|
|
266
|
-
if (src.kind === "local") {
|
|
267
|
-
info(`Pushing skill from ${basename(src.dir)}...`);
|
|
268
|
-
return pushSkill(client, src.dir, org, src.tag, "", DEFAULT_IGNORE_OPTIONS);
|
|
269
|
-
}
|
|
270
|
-
info(`Pushing skill from ${src.url}...`);
|
|
271
|
-
const tempDir = mkdtempSync(join(tmpdir(), "stigmer-skill-"));
|
|
272
|
-
try {
|
|
273
|
-
cloneRepository(src.url, src.ref, tempDir);
|
|
274
|
-
const skillDir = src.subdir !== "" ? join(tempDir, src.subdir) : tempDir;
|
|
275
|
-
return await pushSkillFromClone(client, skillDir, {
|
|
276
|
-
gitUrl: src.url,
|
|
277
|
-
gitRef: src.ref,
|
|
278
|
-
subdir: src.subdir,
|
|
279
|
-
org,
|
|
280
|
-
tag: src.tag,
|
|
281
|
-
message: "",
|
|
282
|
-
options: DEFAULT_IGNORE_OPTIONS,
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
finally {
|
|
286
|
-
rmSync(tempDir, { recursive: true, force: true });
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
// Member slug from an applied resource: prefer the server's slug, fall back to
|
|
290
|
-
// the name (mirrors Go's buildResourceReference / reader name-fallback).
|
|
291
|
-
function memberSlugOf(message) {
|
|
292
|
-
const meta = resourceMetadata(message);
|
|
293
|
-
return meta?.slug || meta?.name || "";
|
|
294
|
-
}
|
|
295
|
-
/** Dry-run: validate every resource without touching the backend. */
|
|
296
|
-
export function previewDeclarative(detect, deps) {
|
|
297
|
-
const { configDir } = detect;
|
|
298
|
-
if (configDir === undefined)
|
|
299
|
-
throw new UsageError("declarative apply requires a stigmer.yaml project");
|
|
300
|
-
const items = buildDeclarativeItems(scanResourceFiles(configDir), deps.warn);
|
|
301
|
-
const results = items.map((item) => buildDryRunPreview(item));
|
|
302
|
-
const summary = CommandResult.success(`Dry run complete: ${items.length} resource(s) validated`);
|
|
303
|
-
summary.hint("Remove --dry-run to apply resources to the backend");
|
|
304
|
-
return { results, summary };
|
|
305
|
-
}
|
|
306
|
-
function buildDryRunPreview(item) {
|
|
307
|
-
const meta = metaOf(item);
|
|
308
|
-
const result = CommandResult.success(`Dry run: ${meta?.name ?? item.handler.displayName} is valid`);
|
|
309
|
-
const section = result.addSection(`${item.handler.displayName} Preview`);
|
|
310
|
-
if (meta?.name)
|
|
311
|
-
section.field("Name", meta.name);
|
|
312
|
-
if (meta?.slug)
|
|
313
|
-
section.field("Slug", meta.slug);
|
|
314
|
-
return result;
|
|
315
|
-
}
|
|
316
|
-
// The document is YAML-shaped JSON; read metadata fields for membership/preview
|
|
317
|
-
// without marshalling (the apply itself marshals strictly).
|
|
318
|
-
function metaOf(item) {
|
|
319
|
-
const meta = item.document.metadata;
|
|
320
|
-
if (meta === undefined)
|
|
321
|
-
return undefined;
|
|
322
|
-
return {
|
|
323
|
-
name: typeof meta.name === "string" ? meta.name : undefined,
|
|
324
|
-
slug: typeof meta.slug === "string" ? meta.slug : undefined,
|
|
325
|
-
};
|
|
326
|
-
}
|
|
327
|
-
function reference(org, kind, slug) {
|
|
328
|
-
return create(ApiResourceReferenceSchema, { org, kind, slug });
|
|
329
|
-
}
|
|
330
|
-
function injectOrg(project, org) {
|
|
331
|
-
if (org === "")
|
|
332
|
-
return;
|
|
333
|
-
const holder = project;
|
|
334
|
-
if (holder.metadata === undefined) {
|
|
335
|
-
holder.metadata = create(ApiResourceMetadataSchema, { org });
|
|
336
|
-
}
|
|
337
|
-
else if (holder.metadata.org === "") {
|
|
338
|
-
holder.metadata.org = org;
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
// =============================================================================
|
|
342
|
-
// Result builders
|
|
343
|
-
// =============================================================================
|
|
344
|
-
function buildNoResourcesResult(projectDir) {
|
|
345
|
-
const result = CommandResult.warning("No resource files found in project directory");
|
|
346
|
-
result
|
|
347
|
-
.addSection("")
|
|
348
|
-
.field("Directory", projectDir)
|
|
349
|
-
.item("Add YAML resource files (Agent, Workflow, McpServer) or skill directories (with SKILL.md) next to stigmer.yaml");
|
|
350
|
-
result.hint("Example: create agent.yaml with kind: Agent, then run 'stigmer apply'");
|
|
351
|
-
return result;
|
|
352
|
-
}
|
|
353
|
-
function buildDeclarativeResult(project, members, created) {
|
|
354
|
-
const name = project.metadata?.name ?? "project";
|
|
355
|
-
const result = CommandResult.success(`Project ${name} successfully (${created ? "created" : "updated"})`);
|
|
356
|
-
const section = result.addSection("Project");
|
|
357
|
-
if (project.metadata?.name)
|
|
358
|
-
section.field("Name", project.metadata.name);
|
|
359
|
-
if (project.metadata?.slug)
|
|
360
|
-
section.field("Slug", project.metadata.slug);
|
|
361
|
-
if (project.metadata?.id)
|
|
362
|
-
section.field("ID", project.metadata.id);
|
|
363
|
-
const counts = countByKind(members);
|
|
364
|
-
if (counts.size > 0) {
|
|
365
|
-
const memberSection = result.addSection("Members Applied");
|
|
366
|
-
for (const kind of [
|
|
367
|
-
ApiResourceKind.agent,
|
|
368
|
-
ApiResourceKind.workflow,
|
|
369
|
-
ApiResourceKind.mcp_server,
|
|
370
|
-
ApiResourceKind.skill,
|
|
371
|
-
]) {
|
|
372
|
-
const count = counts.get(kind);
|
|
373
|
-
if (count !== undefined)
|
|
374
|
-
memberSection.field(ApiResourceKind[kind], String(count));
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
const recon = project.status?.lastReconciliation;
|
|
378
|
-
if (recon !== undefined && (recon.created.length > 0 || recon.updated.length > 0 || recon.deleted.length > 0)) {
|
|
379
|
-
const reconSection = result.addSection("Reconciliation");
|
|
380
|
-
if (recon.created.length > 0)
|
|
381
|
-
reconSection.field("Created", String(recon.created.length));
|
|
382
|
-
if (recon.updated.length > 0)
|
|
383
|
-
reconSection.field("Updated", String(recon.updated.length));
|
|
384
|
-
if (recon.deleted.length > 0)
|
|
385
|
-
reconSection.field("Pruned", String(recon.deleted.length));
|
|
386
|
-
}
|
|
387
|
-
if (project.metadata?.slug)
|
|
388
|
-
result.hint(`View project: stigmer get project ${project.metadata.slug}`);
|
|
389
|
-
return result;
|
|
390
|
-
}
|
|
391
|
-
function countByKind(members) {
|
|
392
|
-
const counts = new Map();
|
|
393
|
-
for (const member of members)
|
|
394
|
-
counts.set(member.kind, (counts.get(member.kind) ?? 0) + 1);
|
|
395
|
-
return counts;
|
|
396
|
-
}
|
|
397
|
-
//# sourceMappingURL=declarative.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"declarative.js","sourceRoot":"","sources":["../../../src/resources/apply/declarative.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,EAAE;AACF,6EAA6E;AAC7E,6EAA6E;AAC7E,+EAA+E;AAC/E,2EAA2E;AAC3E,gFAAgF;AAChF,2EAA2E;AAC3E,0BAA0B;AAC1B,EAAE;AACF,2DAA2D;AA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AC,OAAO,CAAC,MAAM,GAAG,CAAC;YAAE,YAAY,CAAC,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IAC3F,CAAC;IAED,IAAI,OAAO,CAAC,QAAQ,EAAE,IAAI;QAAE,MAAM,CAAC,IAAI,CAAC,qCAAqC,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IACtG,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,WAAW,CAAC,OAAwC;IAC3D,MAAM,MAAM,GAAG,IAAI,GAAG,EAA2B,CAAC;IAClD,KAAK,MAAM,MAAM,IAAI,OAAO;QAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1F,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { CommandResult } from "../../../output/index.js";
|
|
2
|
-
import { type DeclarativeDeps, type DetectResult } from "../declarative.js";
|
|
3
|
-
import type { SynthesizeDeps } from "./synthesize.js";
|
|
4
|
-
/** Deps for the project track: the reconciler deps plus injectable synthesis. */
|
|
5
|
-
export interface ProjectTrackDeps extends DeclarativeDeps {
|
|
6
|
-
/** Injectable synthesis collaborators (real subprocess by default). */
|
|
7
|
-
readonly synthesizeDeps?: SynthesizeDeps;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Apply an SDK project: synthesize the entry point, read the `.pb` output, and
|
|
11
|
-
* reconcile membership through the shared reconciler. Returns the summary
|
|
12
|
-
* CommandResult for the caller to render.
|
|
13
|
-
*/
|
|
14
|
-
export declare function applyProjectTrack(detect: DetectResult, deps: ProjectTrackDeps): Promise<CommandResult>;
|
|
15
|
-
/**
|
|
16
|
-
* Dry-run preview: validate the project configuration statically (no synthesis,
|
|
17
|
-
* no backend), warning if the entry point file is missing. Port of Go's
|
|
18
|
-
* executeSDKDryRun.
|
|
19
|
-
*/
|
|
20
|
-
export declare function previewProjectTrack(detect: DetectResult): CommandResult;
|
|
21
|
-
//# sourceMappingURL=project-track.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"project-track.d.ts","sourceRoot":"","sources":["../../../../src/resources/apply/synth/project-track.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,YAAY,EAIlB,MAAM,mBAAmB,CAAC;AAK3B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGtD,iFAAiF;AACjF,MAAM,WAAW,gBAAiB,SAAQ,eAAe;IACvD,uEAAuE;IACvE,QAAQ,CAAC,cAAc,CAAC,EAAE,cAAc,CAAC;CAC1C;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC,CAyB5G;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,YAAY,GAAG,aAAa,CAmBvE"}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
// Synthesis (project) track: the consumer adapter for `apply entry_point`.
|
|
2
|
-
//
|
|
3
|
-
// Its job mirrors the declarative adapter's — turn a source into resources +
|
|
4
|
-
// skill sources — but the source here is the SDK program rather than YAML
|
|
5
|
-
// files: infer the runtime, run synthesis (subprocess → `.pb`), decode the
|
|
6
|
-
// output, normalize it into the shared shapes, then hand off to the ONE shared
|
|
7
|
-
// reconciler (DD-009 §6). There is no parallel project-apply path.
|
|
8
|
-
//
|
|
9
|
-
// Resources are emitted in dependency-apply order (mcp_server → agent →
|
|
10
|
-
// workflow), matching the declarative track's APPLY_ORDER so parents land before
|
|
11
|
-
// dependents — a deliberate, more-correct ordering than the Go synth path
|
|
12
|
-
// (which applied agents first).
|
|
13
|
-
import { existsSync } from "node:fs";
|
|
14
|
-
import { isAbsolute, join } from "node:path";
|
|
15
|
-
import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
|
|
16
|
-
import { UsageError } from "../../../errors/index.js";
|
|
17
|
-
import { CommandResult } from "../../../output/index.js";
|
|
18
|
-
import { reconcileProjectMembers, } from "../declarative.js";
|
|
19
|
-
import { APPLY_HANDLERS } from "../handlers.js";
|
|
20
|
-
import { readSynthesisOutput } from "./reader.js";
|
|
21
|
-
import { inferRuntime } from "./runtime.js";
|
|
22
|
-
import { synthesize } from "./synthesize.js";
|
|
23
|
-
/**
|
|
24
|
-
* Apply an SDK project: synthesize the entry point, read the `.pb` output, and
|
|
25
|
-
* reconcile membership through the shared reconciler. Returns the summary
|
|
26
|
-
* CommandResult for the caller to render.
|
|
27
|
-
*/
|
|
28
|
-
export async function applyProjectTrack(detect, deps) {
|
|
29
|
-
const { project, configDir } = detect;
|
|
30
|
-
if (project === undefined || configDir === undefined) {
|
|
31
|
-
throw new UsageError("project synthesis requires a stigmer.yaml project with an entry_point");
|
|
32
|
-
}
|
|
33
|
-
const entryPoint = project.spec?.entryPoint ?? "";
|
|
34
|
-
if (entryPoint === "")
|
|
35
|
-
throw new UsageError("project has no entry_point");
|
|
36
|
-
const runtime = inferRuntime(entryPoint);
|
|
37
|
-
deps.info(`SDK mode: ${entryPoint} (runtime: ${runtime})`);
|
|
38
|
-
const { outputDir } = await synthesize({ projectDir: configDir, entryPoint, runtime, orgId: deps.org }, deps.synthesizeDeps);
|
|
39
|
-
const synth = readSynthesisOutput(outputDir);
|
|
40
|
-
deps.info(`Synthesis complete: ${synth.agents.length} agent(s), ${synth.workflows.length} workflow(s), ` +
|
|
41
|
-
`${synth.mcpServers.length} MCP server(s), ${synth.skillSynths.length} skill(s)`);
|
|
42
|
-
const resources = toReconcileResources(synth);
|
|
43
|
-
const skillSources = toSkillSources(synth, configDir);
|
|
44
|
-
return reconcileProjectMembers(project, resources, skillSources, deps);
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Dry-run preview: validate the project configuration statically (no synthesis,
|
|
48
|
-
* no backend), warning if the entry point file is missing. Port of Go's
|
|
49
|
-
* executeSDKDryRun.
|
|
50
|
-
*/
|
|
51
|
-
export function previewProjectTrack(detect) {
|
|
52
|
-
const { project, configDir } = detect;
|
|
53
|
-
if (project === undefined || configDir === undefined) {
|
|
54
|
-
throw new UsageError("project synthesis requires a stigmer.yaml project with an entry_point");
|
|
55
|
-
}
|
|
56
|
-
const entryPoint = project.spec?.entryPoint ?? "";
|
|
57
|
-
const runtime = inferRuntime(entryPoint);
|
|
58
|
-
const result = CommandResult.success("Dry run: SDK project configuration is valid");
|
|
59
|
-
const section = result.addSection("Project");
|
|
60
|
-
if (project.metadata?.name)
|
|
61
|
-
section.field("Name", project.metadata.name);
|
|
62
|
-
section.field("Entry Point", entryPoint);
|
|
63
|
-
section.field("Runtime", runtime);
|
|
64
|
-
if (!existsSync(join(configDir, entryPoint))) {
|
|
65
|
-
result.addSection("Warning").item(`Entry point file not found: ${entryPoint}`);
|
|
66
|
-
}
|
|
67
|
-
result.hint("Remove --dry-run to execute synthesis and apply resources");
|
|
68
|
-
return result;
|
|
69
|
-
}
|
|
70
|
-
// Normalize decoded protos into ReconcileResources in dependency-apply order.
|
|
71
|
-
function toReconcileResources(synth) {
|
|
72
|
-
const resources = [];
|
|
73
|
-
for (const message of synth.mcpServers)
|
|
74
|
-
resources.push({ handler: handlerFor(ApiResourceKind.mcp_server), message });
|
|
75
|
-
for (const message of synth.agents)
|
|
76
|
-
resources.push({ handler: handlerFor(ApiResourceKind.agent), message });
|
|
77
|
-
for (const message of synth.workflows)
|
|
78
|
-
resources.push({ handler: handlerFor(ApiResourceKind.workflow), message });
|
|
79
|
-
return resources;
|
|
80
|
-
}
|
|
81
|
-
// Normalize SkillSynths into SkillSources; local paths resolve relative to the
|
|
82
|
-
// project dir (matching Go's pushSkillSynth).
|
|
83
|
-
function toSkillSources(synth, configDir) {
|
|
84
|
-
return synth.skillSynths.map((skill) => {
|
|
85
|
-
if (skill.source.case === "local") {
|
|
86
|
-
const path = skill.source.value.path;
|
|
87
|
-
return { kind: "local", dir: isAbsolute(path) ? path : join(configDir, path), tag: skill.tag };
|
|
88
|
-
}
|
|
89
|
-
if (skill.source.case === "git") {
|
|
90
|
-
const git = skill.source.value;
|
|
91
|
-
return { kind: "git", url: git.url, ref: git.ref, subdir: git.subdir, tag: skill.tag };
|
|
92
|
-
}
|
|
93
|
-
throw new UsageError("skill synthesis has no source configured (neither local nor git)");
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
function handlerFor(kind) {
|
|
97
|
-
const handler = APPLY_HANDLERS.get(kind);
|
|
98
|
-
if (handler === undefined)
|
|
99
|
-
throw new UsageError(`apply not implemented for ${ApiResourceKind[kind]}`);
|
|
100
|
-
return handler;
|
|
101
|
-
}
|
|
102
|
-
//# sourceMappingURL=project-track.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"project-track.js","sourceRoot":"","sources":["../../../../src/resources/apply/synth/project-track.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,EAAE;AACF,6EAA6E;AAC7E,0EAA0E;AAC1E,2EAA2E;AAC3E,+EAA+E;AAC/E,mEAAmE;AACnE,EAAE;AACF,wEAAwE;AACxE,iFAAiF;AACjF,0EAA0E;AAC1E,gCAAgC;AAEhC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,qFAAqF,CAAC;AACtH,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;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,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;YAC/B,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC;QACzF,CAAC;QACD,MAAM,IAAI,UAAU,CAAC,kEAAkE,CAAC,CAAC;IAC3F,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,UAAU,CAAC,IAAqB;IACvC,MAAM,OAAO,GAAG,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACzC,IAAI,OAAO,KAAK,SAAS;QAAE,MAAM,IAAI,UAAU,CAAC,6BAA6B,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACtG,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { type Agent } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/api_pb";
|
|
2
|
-
import { type McpServer } from "@stigmer/protos/ai/stigmer/agentic/mcpserver/v1/api_pb";
|
|
3
|
-
import { type SkillSynth } from "@stigmer/protos/ai/stigmer/agentic/skill/v1/synth_pb";
|
|
4
|
-
import { type Workflow } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/api_pb";
|
|
5
|
-
/** Decoded synthesis output, grouped by kind in read order. */
|
|
6
|
-
export interface SynthesisResult {
|
|
7
|
-
readonly skillSynths: SkillSynth[];
|
|
8
|
-
readonly mcpServers: McpServer[];
|
|
9
|
-
readonly agents: Agent[];
|
|
10
|
-
readonly workflows: Workflow[];
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Read and decode all synthesized `.pb` files from `outputDir`. Throws a
|
|
14
|
-
* UsageError if the synthesis produced no resources (a program that registered
|
|
15
|
-
* nothing, or wrote to the wrong directory).
|
|
16
|
-
*/
|
|
17
|
-
export declare function readSynthesisOutput(outputDir: string): SynthesisResult;
|
|
18
|
-
//# sourceMappingURL=reader.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reader.d.ts","sourceRoot":"","sources":["../../../../src/resources/apply/synth/reader.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,KAAK,KAAK,EAAe,MAAM,oDAAoD,CAAC;AAC7F,OAAO,EAAE,KAAK,SAAS,EAAmB,MAAM,wDAAwD,CAAC;AACzG,OAAO,EAAE,KAAK,UAAU,EAAoB,MAAM,sDAAsD,CAAC;AACzG,OAAO,EAAE,KAAK,QAAQ,EAAkB,MAAM,uDAAuD,CAAC;AAGtG,+DAA+D;AAC/D,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,WAAW,EAAE,UAAU,EAAE,CAAC;IACnC,QAAQ,CAAC,UAAU,EAAE,SAAS,EAAE,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,QAAQ,EAAE,CAAC;CAChC;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,eAAe,CAetE"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
// Reader for SDK synthesis output.
|
|
2
|
-
//
|
|
3
|
-
// The SDK writes one binary proto per resource into the out dir:
|
|
4
|
-
// skill-N.pb (SkillSynth — input for skill push)
|
|
5
|
-
// mcpserver-N.pb (McpServer)
|
|
6
|
-
// agent-N.pb (Agent)
|
|
7
|
-
// workflow-N.pb (Workflow)
|
|
8
|
-
// We glob each `<kind>-*.pb`, sort lexically (matching Go's reader so the same
|
|
9
|
-
// bytes read identically on both consumers), and decode with `fromBinary`
|
|
10
|
-
// (DD-009 §3). At least one resource must be present.
|
|
11
|
-
//
|
|
12
|
-
// `dependencies.json` (Go's local-only dependency graph) is deliberately NOT
|
|
13
|
-
// consumed: no dependency-graph validation feature exists, and the TS SDK does
|
|
14
|
-
// not emit it. Its absence is therefore tolerated by construction (DD-009).
|
|
15
|
-
// Port of `internal/cli/synthesis/reader.go`.
|
|
16
|
-
import { readdirSync, readFileSync } from "node:fs";
|
|
17
|
-
import { join } from "node:path";
|
|
18
|
-
import { fromBinary } from "@bufbuild/protobuf";
|
|
19
|
-
import { AgentSchema } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/api_pb";
|
|
20
|
-
import { McpServerSchema } from "@stigmer/protos/ai/stigmer/agentic/mcpserver/v1/api_pb";
|
|
21
|
-
import { SkillSynthSchema } from "@stigmer/protos/ai/stigmer/agentic/skill/v1/synth_pb";
|
|
22
|
-
import { WorkflowSchema } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/api_pb";
|
|
23
|
-
import { UsageError } from "../../../errors/index.js";
|
|
24
|
-
/**
|
|
25
|
-
* Read and decode all synthesized `.pb` files from `outputDir`. Throws a
|
|
26
|
-
* UsageError if the synthesis produced no resources (a program that registered
|
|
27
|
-
* nothing, or wrote to the wrong directory).
|
|
28
|
-
*/
|
|
29
|
-
export function readSynthesisOutput(outputDir) {
|
|
30
|
-
const skillSynths = readProtoFiles(outputDir, "skill-", SkillSynthSchema);
|
|
31
|
-
const mcpServers = readProtoFiles(outputDir, "mcpserver-", McpServerSchema);
|
|
32
|
-
const agents = readProtoFiles(outputDir, "agent-", AgentSchema);
|
|
33
|
-
const workflows = readProtoFiles(outputDir, "workflow-", WorkflowSchema);
|
|
34
|
-
if (skillSynths.length + mcpServers.length + agents.length + workflows.length === 0) {
|
|
35
|
-
throw new UsageError("no resources found in synthesis output\n\n" +
|
|
36
|
-
"The entry point ran but registered no resources. Register at least one " +
|
|
37
|
-
"agent, workflow, MCP server, or skill, and end with `await project.synth()`.");
|
|
38
|
-
}
|
|
39
|
-
return { skillSynths, mcpServers, agents, workflows };
|
|
40
|
-
}
|
|
41
|
-
// Glob `<prefix>*.pb` in `dir`, sort lexically (parity with Go's sort.Strings),
|
|
42
|
-
// and decode each. A missing directory yields an empty list (the caller's
|
|
43
|
-
// zero-resource check produces the user-facing error).
|
|
44
|
-
function readProtoFiles(dir, prefix, schema) {
|
|
45
|
-
let names;
|
|
46
|
-
try {
|
|
47
|
-
names = readdirSync(dir);
|
|
48
|
-
}
|
|
49
|
-
catch {
|
|
50
|
-
return [];
|
|
51
|
-
}
|
|
52
|
-
const matches = names.filter((name) => name.startsWith(prefix) && name.endsWith(".pb")).sort();
|
|
53
|
-
return matches.map((name) => fromBinary(schema, readFileSync(join(dir, name))));
|
|
54
|
-
}
|
|
55
|
-
//# sourceMappingURL=reader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reader.js","sourceRoot":"","sources":["../../../../src/resources/apply/synth/reader.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,EAAE;AACF,iEAAiE;AACjE,yDAAyD;AACzD,iCAAiC;AACjC,6BAA6B;AAC7B,gCAAgC;AAChC,+EAA+E;AAC/E,0EAA0E;AAC1E,sDAAsD;AACtD,EAAE;AACF,6EAA6E;AAC7E,+EAA+E;AAC/E,4EAA4E;AAC5E,8CAA8C;AAE9C,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAoB,UAAU,EAAqB,MAAM,oBAAoB,CAAC;AACrF,OAAO,EAAc,WAAW,EAAE,MAAM,oDAAoD,CAAC;AAC7F,OAAO,EAAkB,eAAe,EAAE,MAAM,wDAAwD,CAAC;AACzG,OAAO,EAAmB,gBAAgB,EAAE,MAAM,sDAAsD,CAAC;AACzG,OAAO,EAAiB,cAAc,EAAE,MAAM,uDAAuD,CAAC;AACtG,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAUtD;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,SAAiB;IACnD,MAAM,WAAW,GAAG,cAAc,CAAC,SAAS,EAAE,QA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